-
-
Save cdeckert/6412770 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Date currentFYStartDate | |
{ | |
get | |
{ | |
if (currentFYStartDate == null) | |
{ | |
Organization orgInfo = [SELECT FiscalYearStartMonth, UsesStartDateAsFiscalYearName | |
FROM Organization | |
WHERE id = : Userinfo.getOrganizationId()]; | |
Date today = system.today(); | |
Integer currentFY; | |
if (today.month() >= orgInfo.FiscalYearStartMonth) | |
{ | |
if (orgInfo.UsesStartDateAsFiscalYearName) | |
{ | |
currentFY = today.year(); | |
} | |
else | |
{ | |
currentFY = today.year() + 1; | |
} | |
} | |
else | |
{ | |
if (orgInfo.UsesStartDateAsFiscalYearName) | |
{ | |
currentFY = today.year() - 1; | |
} | |
else | |
{ | |
currentFY = today.year(); | |
} | |
} | |
currentFYStartDate = Date.newInstance(currentFY, orgInfo.FiscalYearStartMonth, 1); | |
} | |
return currentFYStartDate; | |
} | |
set; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment