OBJECT Codeunit 3 G/L Account-Indent { OBJECT-PROPERTIES { Date=; Time=; Version List=; } PROPERTIES { OnRun=BEGIN IF NOT CONFIRM( Text1100000 + Text1100001 + Text1100002 + Text1100003 + Text1100004 + Text1100005,TRUE) THEN EXIT; Indent; END; } CODE { VAR Text000@1000 : TextConst 'ENU="This function updates the indentation of all the G/L accounts in the chart of accounts. "'; Text001@1001 : TextConst 'ENU="All accounts between a Begin-Total and the matching End-Total are indented one level. "'; Text002@1002 : TextConst 'ENU=The Totaling for each End-total is also updated.'; Text003@1003 : TextConst 'ENU=\\Do you want to indent the chart of accounts?'; Text004@1004 : TextConst 'ENU=Indenting the Chart of Accounts #1##########'; Text005@1005 : TextConst 'ENU=End-Total %1 is missing a matching Begin-Total.'; Text1100000@1100000 : TextConst 'ENU=This function checks the consistency of and completes the Chart of Accounts:\\'; Text1100001@1100001 : TextConst 'ENU=- Checks that a corresponding heading account exists for every posting account.\'; Text1100002@1100002 : TextConst 'ENU=- Checks that all accounts comply with the Chart of Account account length requisites.\'; Text1100003@1100003 : TextConst 'ENU=- Assigns values to the following fields: Income/Balance/Capital, Account Type, Indentation, Totaling and Debit/Credit.\'; Text1100004@1100004 : TextConst 'ENU=- Checks that an Adjustment Account exists for every account of the Income Statement and Capital types. \\'; Text1100005@1100005 : TextConst 'ENU=Do you wish to check the Chart of Accounts?'; GLAcc@1006 : Record 15; Window@1007 : Dialog; AccNo@1008 : ARRAY [10] OF Code[20]; i@1009 : Integer; Text1100006@1100006 : TextConst 'ENU=Checking the Chart of Accounts #1########## @2@@@@@@@@@@@@@'; Text1100007@1100007 : TextConst 'ENU=The length of a heading account cannot be greater than 8, account %1'; Text1100008@1100008 : TextConst 'ENU=" Missing group %1 - Account No. %2"'; Text1100009@1100009 : TextConst 'ENU=..'; Text1100010@1100010 : TextConst 'ENU=" Missing group %1 - Account No. %2"'; Text1100011@1100011 : TextConst 'ENU=The length of account %1 cannot be different than the next ones'; Text1100012@1100012 : TextConst 'ENU=The Chart of Accounts is correct.'; FindAcc@1100020 : Record 15; HidePrintDialog@1100100 : Boolean; NewGLAcc@1100050 : Record 10722; FindNewGLAcc@1100051 : Record 10722; PROCEDURE Indent@1(); VAR LineCounter@1100001 : Integer; NoOfRecords@1100000 : Integer; BEGIN Window.OPEN(Text1100006); WITH GLAcc DO BEGIN RESET; LineCounter := 0; NoOfRecords := COUNT; IF NoOfRecords <> 0 THEN BEGIN IF FIND('-') THEN REPEAT Window.UPDATE(1,"No."); TESTFIELD(Name); IF STRLEN("No.") > 5 THEN "Account Type" := "Account Type"::Posting ELSE "Account Type" := "Account Type"::Heading; IF "Account Type" = "Account Type"::Heading THEN BEGIN //The length of a heading account cannot be greater than 9 IF STRLEN("No.") > 8 THEN ERROR(Text1100007,"No."); //a heading account must exist at the previous higher level IF STRLEN("No.") > 1 THEN IF NOT FindAcc.GET( COPYSTR("No.",1,STRLEN("No.")-1)) THEN ERROR(Text1100008,COPYSTR("No.",1,STRLEN("No.")-1),"No."); Totaling := "No." + Text1100009 + PADSTR("No.", 20 - (STRLEN("No.") + 2), '9'); Indentation := STRLEN("No.") - 1; END ELSE BEGIN //the corresponding heading account must exist IF NOT FindAcc.GET( COPYSTR("No.",1,3)) THEN ERROR(Text1100010,COPYSTR("No.",1,3),"No."); //a posting account must be the same length as the next FindAcc := GLAcc; IF FindAcc.NEXT <> 0 THEN IF (FindAcc."Account Type" = FindAcc."Account Type"::Posting) AND (STRLEN("No.") <> STRLEN(FindAcc."No.")) THEN ERROR(Text1100011,"No."); IF COPYSTR("No.",1,1) IN ['6','7'] THEN "Income/Balance" := "Income/Balance"::"Income Statement" ELSE IF COPYSTR("No.",1,1) IN ['8','9'] THEN "Income/Balance" := "Income/Balance"::Capital ELSE "Income/Balance" := "Income/Balance"::"Balance Sheet"; IF "Income/Balance" IN ["Income/Balance"::"Income Statement","Income/Balance"::Capital] THEN TESTFIELD("Income Stmt. Bal. Acc.") ELSE "Income Stmt. Bal. Acc." := ''; Indentation := 5; END; MODIFY; LineCounter := LineCounter + 1; Window.UPDATE(2,ROUND(LineCounter / NoOfRecords * 10000,1)); UNTIL NEXT = 0; END; END; Window.CLOSE; IF NOT HidePrintDialog THEN MESSAGE(Text1100012); END; PROCEDURE RunICAccountIndent@4(); BEGIN IF NOT CONFIRM( Text1100000 + Text1100001 + Text1100002 + Text1100003 + Text1100004 + Text1100005,TRUE) THEN EXIT; IndentICAccount; END; PROCEDURE IndentICAccount@2(); VAR ICGLAcc@1000 : Record 410; LineCounter@1000001 : Integer; NoOfRecords@1000000 : Integer; BEGIN Window.OPEN(Text1100006); WITH ICGLAcc DO BEGIN RESET; LineCounter := 0; NoOfRecords := COUNT; IF NoOfRecords <> 0 THEN BEGIN IF FIND('-') THEN REPEAT Window.UPDATE(1,"No."); TESTFIELD(Name); IF STRLEN("No.") > 5 THEN "Account Type" := "Account Type"::Posting ELSE "Account Type" := "Account Type"::Heading; IF "Account Type" = "Account Type"::Heading THEN BEGIN //The length of a heading account cannot be greater than 9 IF STRLEN("No.") > 8 THEN ERROR(Text1100007,"No."); //a heading account must exist at the previous higher level IF STRLEN("No.") > 1 THEN IF NOT FindAcc.GET( COPYSTR("No.",1,STRLEN("No.")-1)) THEN ERROR(Text1100008,COPYSTR("No.",1,STRLEN("No.")-1),"No."); Indentation := STRLEN("No.") - 1; END ELSE BEGIN //the corresponding heading account must exist IF NOT FindAcc.GET( COPYSTR("No.",1,3)) THEN ERROR(Text1100010,COPYSTR("No.",1,3),"No."); //a posting account must be the same length as the next FindAcc := GLAcc; IF FindAcc.NEXT <> 0 THEN IF (FindAcc."Account Type" = FindAcc."Account Type"::Posting) AND (STRLEN("No.") <> STRLEN(FindAcc."No.")) THEN ERROR(Text1100011,"No."); IF COPYSTR("No.",1,1) IN ['6','7'] THEN "Income/Balance" := "Income/Balance"::"Income Statement" ELSE "Income/Balance" := "Income/Balance"::"Balance Sheet"; Indentation := 4; END; MODIFY; LineCounter := LineCounter + 1; Window.UPDATE(2,ROUND(LineCounter / NoOfRecords * 10000,1)); UNTIL NEXT = 0; END; END; Window.CLOSE; IF NOT HidePrintDialog THEN MESSAGE(Text1100012); END; PROCEDURE SetHidePrintDialog@1100100(NewHidePrintDialog@1100000 : Boolean); BEGIN HidePrintDialog := NewHidePrintDialog; END; PROCEDURE IndentNewChartOfAccounts@1100101(); VAR LineCounter@1100001 : Integer; NoOfRecords@1100000 : Integer; BEGIN IF NOT CONFIRM( Text1100000 + Text1100001 + Text1100002 + Text1100003 + Text1100004 + Text1100005,TRUE) THEN EXIT; Window.OPEN(Text1100006); WITH NewGLAcc DO BEGIN RESET; LineCounter := 0; NoOfRecords := COUNT; IF NoOfRecords <> 0 THEN BEGIN IF FIND('-') THEN REPEAT Window.UPDATE(1,"No."); TESTFIELD(Name); IF STRLEN("No.") > 5 THEN "Account Type" := "Account Type"::Posting ELSE "Account Type" := "Account Type"::Heading; IF "Account Type" = "Account Type"::Heading THEN BEGIN //The length of a heading account cannot be greater than 9 IF STRLEN("No.") > 8 THEN ERROR(Text1100007,"No."); //a heading account must exist at the previous higher level IF STRLEN("No.") > 1 THEN IF NOT FindNewGLAcc.GET( COPYSTR("No.",1,STRLEN("No.")-1)) THEN ERROR(Text1100008,COPYSTR("No.",1,STRLEN("No.")-1),"No."); Totaling := "No." + Text1100009 + PADSTR("No.", 20 - (STRLEN("No.") + 2) , '9'); // PART III Indentation := STRLEN("No.") - 1; END ELSE BEGIN //the corresponding heading account must exist IF NOT FindNewGLAcc.GET( COPYSTR("No.",1,3)) THEN ERROR(Text1100010,COPYSTR("No.",1,3),"No."); //a posting account must be the same length as the next FindNewGLAcc := NewGLAcc; IF FindNewGLAcc.NEXT <> 0 THEN IF (FindNewGLAcc."Account Type" = FindNewGLAcc."Account Type"::Posting) AND (STRLEN("No.") <> STRLEN(FindNewGLAcc."No.")) THEN ERROR(Text1100011,"No."); IF COPYSTR("No.",1,1) IN ['6','7'] THEN "Income/Balance" := "Income/Balance"::"Income Statement" ELSE IF COPYSTR("No.",1,1) IN ['8','9'] THEN "Income/Balance" := "Income/Balance"::Capital ELSE "Income/Balance" := "Income/Balance"::"Balance Sheet"; IF "Income/Balance" IN ["Income/Balance"::"Income Statement","Income/Balance"::Capital] THEN TESTFIELD("Income Stmt. Bal. Acc.") ELSE "Income Stmt. Bal. Acc." := ''; Indentation := 4; END; MODIFY; LineCounter := LineCounter + 1; Window.UPDATE(2,ROUND(LineCounter / NoOfRecords * 10000,1)); UNTIL NEXT = 0; END; END; Window.CLOSE; IF NOT HidePrintDialog THEN MESSAGE(Text1100012); END; BEGIN END. } }