To begin with, it started off with the simplest of formulas to get the first and last day of the year, thus:
/// Returns a container of dates with the start and end dates of the current year.
/// Not to be confused with the start and end of the current financial year.
/// Example '[01/01/2011,31/12/2011]'
public static container getCurrentYearStartEnd()
{
int yr = DateTimeUtil::year(DateTimeUtil::getSystemDateTime());
date dtStart, dtEnd;
;
// see http://sysdictcoder.com/blog/constructing-date-values/
//dtStart = str2Date(strfmt("01/01/%1",yr), 123);
//dtEnd = str2Date(strfmt("31/12/%1",yr), 123);
dtStart = mkDate(1, 1, yr);
dtEnd = mkDate(31, 12, yr);
return [dtStart, dtEnd];
}
Now Spain is quite reasonable, they work their finances from the 1st of January to the 31st of December. We're not so fortunate in multinational companies however, so we need to do this right. Revisiting the LedgerPeriod buffer we can see that they have already done the hard work for us, it's sweet./// Returns a container of dates with the start and end dates of the current financial year.
/// In Spain the fiscal year starts on January 1 and ends December 31.
/// The Australian government's financial year begins on July 1 and concludes on June 30 of the following year.
/// @link http://en.wikipedia.org/wiki/Fiscal_year
/// Example '[01/04/2011,31/03/2012]'
public static container getCurrentFinancialYearStartEnd()
{
date frmdt = DateTimeUtil::date(DateTimeUtil::getSystemDateTime());
;
return LedgerPeriod::findFiscalYearDates(frmdt);
}
That wasn't so bad after all was it? Let us know if there was an even easier/more correct way.
No hay comentarios:
Publicar un comentario