Auto Generate Calendar
I found that generating separate asset calendar in every new Fixed Asset implementation is rather important. There is a requirement to have all the years available for your migrated fixed asset before you can upload the value model. Let's say you have the asset since 1990 in the register and this asset is included as part of the migration. This will require you to have the calendar since 1990 before you can upload the opening balance.
Creating the calendar since 1990 can be a bit painful, especially if you have different environment such as Development, Training, Testing, and Production environment. It means that you have to populate the calendar since 1990 to years in the future in all server environment.
I've created a script to help populate the calendar easily. You may need to change the calendar name in variable.
static void TI_PopulateFACalendar(Args _args)
{
AVIFiles
FiscalCalendar _fiscalCalendar;
int i,startYear=1980, endYear=2026;
SysOperationProgress progressBar;
Dialog _dialog;
DialogField fieldStartYear, fieldEndYear;
;
_dialog = new Dialog();
fieldStartYear = _dialog.addField(extendedTypeStr(Integer), "Start Year");
fieldEndYear = _dialog.addField(extendedTypeStr(Integer), "End Year");
if(!_dialog.run())
{
return;
}
ttsBegin;
startYear = fieldStartYear.value();
endYear = fieldEndYear.value();
_fiscalCalendar.initValue();
_fiscalCalendar.CalendarId = "FA"; //Change the name of the calendar
_fiscalCalendar.Description = "Fixed Asset Calendar";
_fiscalCalendar.insert();
select _fiscalCalendar where _fiscalCalendar.CalendarId == "FA";
if(!_fiscalCalendar)
{
warning("FA calendar couldn't be found");
return;
}
progressBar = new SysOperationProgress();
startLengthyOperation();
progressBar.setTotal(endYear - startYear + 1);
progressBar.setAnimation(AVIUpdate);
for(i=startYear; i<=endYear; i++)
{
FiscalCalendars::createYear(_fiscalCalendar.RecId,
mkDate(1,7,i),
mkDate(30,6,i+1),
1,
PeriodUnit::Month,
strFmt("%1-%2", int2str(i), subStr(int2str(i+1), 3, 2)),
false);
progressBar.setText(strFmt("Creating Fixed Asset Calendar - Year %1 of %2", i, endYear));
progressBar.incCount();
}
endLengthyOperation();
ttsCommit;
info("FA calendar has been populated");
}
Creating the calendar since 1990 can be a bit painful, especially if you have different environment such as Development, Training, Testing, and Production environment. It means that you have to populate the calendar since 1990 to years in the future in all server environment.
I've created a script to help populate the calendar easily. You may need to change the calendar name in variable.
static void TI_PopulateFACalendar(Args _args)
{
AVIFiles
FiscalCalendar _fiscalCalendar;
int i,startYear=1980, endYear=2026;
SysOperationProgress progressBar;
Dialog _dialog;
DialogField fieldStartYear, fieldEndYear;
;
_dialog = new Dialog();
fieldStartYear = _dialog.addField(extendedTypeStr(Integer), "Start Year");
fieldEndYear = _dialog.addField(extendedTypeStr(Integer), "End Year");
if(!_dialog.run())
{
return;
}
ttsBegin;
startYear = fieldStartYear.value();
endYear = fieldEndYear.value();
_fiscalCalendar.initValue();
_fiscalCalendar.CalendarId = "FA"; //Change the name of the calendar
_fiscalCalendar.Description = "Fixed Asset Calendar";
_fiscalCalendar.insert();
select _fiscalCalendar where _fiscalCalendar.CalendarId == "FA";
if(!_fiscalCalendar)
{
warning("FA calendar couldn't be found");
return;
}
progressBar = new SysOperationProgress();
startLengthyOperation();
progressBar.setTotal(endYear - startYear + 1);
progressBar.setAnimation(AVIUpdate);
for(i=startYear; i<=endYear; i++)
{
FiscalCalendars::createYear(_fiscalCalendar.RecId,
mkDate(1,7,i),
mkDate(30,6,i+1),
1,
PeriodUnit::Month,
strFmt("%1-%2", int2str(i), subStr(int2str(i+1), 3, 2)),
false);
progressBar.setText(strFmt("Creating Fixed Asset Calendar - Year %1 of %2", i, endYear));
progressBar.incCount();
}
endLengthyOperation();
ttsCommit;
info("FA calendar has been populated");
}
Comments
Post a Comment