OBJECT Codeunit 9999 Hand-made Fake Code Unit { OBJECT-PROPERTIES { Date=; Time=; Version List=TargetVers.01; } PROPERTIES { TableNo=50; OnRun=BEGIN AccountingPeriod.COPY(Rec); Code; Rec := AccountingPeriod; END; } CODE { VAR Text001@1000 : TextConst 'ENU=You must create a new fiscal year before you can close the old year.'; Text002@1001 : TextConst 'ENU="This function closes the fiscal year from %1 to %2. "'; Text003@1002 : TextConst 'ENU=Once the fiscal year is closed it cannot be opened again, and the periods in the fiscal year cannot be changed.\\'; Text004@1003 : TextConst 'ENU=Do you want to close the fiscal year?'; AccountingPeriod@1004 : Record 50; LOCAL PROCEDURE Code@1(); BEGIN WITH AccountingPeriod DO BEGIN AccountingPeriod2.SETRANGE(Closed,FALSE); AccountingPeriod2.FIND('-'); FiscalYearStartDate := AccountingPeriod2."Starting Date"; AccountingPeriod := AccountingPeriod2; TESTFIELD("New Fiscal Year",TRUE); AccountingPeriod2.SETRANGE("New Fiscal Year",TRUE); IF AccountingPeriod2.FIND('>') THEN BEGIN FiscalYearEndDate := CALCDATE('<-1D>',AccountingPeriod2."Starting Date"); AccountingPeriod3 := AccountingPeriod2; AccountingPeriod2.SETRANGE("New Fiscal Year"); AccountingPeriod2.FIND('<'); END ELSE ERROR(Text001); IF NOT CONFIRM( Text002 + Text003 + Text004,FALSE, FiscalYearStartDate,FiscalYearEndDate) THEN EXIT; RESET; SETRANGE("Starting Date",FiscalYearStartDate,AccountingPeriod2."Starting Date"); MODIFYALL(Closed,TRUE); SETRANGE("Starting Date",FiscalYearStartDate,AccountingPeriod3."Starting Date"); MODIFYALL("Date Locked",TRUE); RESET; END; END; BEGIN END. } }