diff --git a/.github/AL-Go-Settings.json b/.github/AL-Go-Settings.json index 437230967c..6c30f81eff 100644 --- a/.github/AL-Go-Settings.json +++ b/.github/AL-Go-Settings.json @@ -5,7 +5,7 @@ "runs-on": "windows-latest", "cacheImageName": "", "UsePsSession": false, - "artifact": "https://bcinsider-fvh2ekdjecfjd6gk.b02.azurefd.net/sandbox/26.0.27457.0/base", + "artifact": "https://bcinsider-fvh2ekdjecfjd6gk.b02.azurefd.net/sandbox/26.0.27721.0/base", "country": "base", "useProjectDependencies": true, "repoVersion": "26.0", diff --git a/Apps/CA/ContosoCoffeeDemoDatasetCA/app/DemoTool/CAContosoLocalization.Codeunit.al b/Apps/CA/ContosoCoffeeDemoDatasetCA/app/DemoTool/CAContosoLocalization.Codeunit.al index a23c639baf..3156ecf9bc 100644 --- a/Apps/CA/ContosoCoffeeDemoDatasetCA/app/DemoTool/CAContosoLocalization.Codeunit.al +++ b/Apps/CA/ContosoCoffeeDemoDatasetCA/app/DemoTool/CAContosoLocalization.Codeunit.al @@ -54,12 +54,12 @@ codeunit 27054 "CA Contoso Localization" Codeunit.Run(Codeunit::"Create CA General Ledger Setup"); Codeunit.Run(Codeunit::"Create CA Posting Group"); CreateCAVatPostingGroup.UpdateVATPostingSetup(); - Codeunit.Run(Codeunit::"Create CA Acc. Schedule Line"); Codeunit.Run(Codeunit::"Create CA Column Layout Name"); CreateCAGLAccounts.AddCategoriesToGLAccountsForMini(); end; Enum::"Contoso Demo Data Level"::"Master Data": begin + Codeunit.Run(Codeunit::"Create CA Acc. Schedule Line"); Codeunit.Run(Codeunit::"Create CA Column Layout"); Codeunit.Run(Codeunit::"Create CA Tax Group"); Codeunit.Run(Codeunit::"Create CA Tax Jurisdiction"); diff --git a/Apps/CH/ContosoCoffeeDemoDatasetCH/app/DemoData/Finance/1.Setup Data/CreateCHVATPostingGroups.Codeunit.al b/Apps/CH/ContosoCoffeeDemoDatasetCH/app/DemoData/Finance/1.Setup Data/CreateCHVATPostingGroups.Codeunit.al index 51f6ec96eb..48b1779739 100644 --- a/Apps/CH/ContosoCoffeeDemoDatasetCH/app/DemoData/Finance/1.Setup Data/CreateCHVATPostingGroups.Codeunit.al +++ b/Apps/CH/ContosoCoffeeDemoDatasetCH/app/DemoData/Finance/1.Setup Data/CreateCHVATPostingGroups.Codeunit.al @@ -7,7 +7,7 @@ codeunit 11616 "Create CH VAT Posting Groups" trigger OnRun() begin - CreateVATProductPostingGroup(); + UpdateVATProductPostingGroup(); CreateVATPostingSetup(); end; @@ -43,11 +43,6 @@ codeunit 11616 "Create CH VAT Posting Groups" procedure CreateVATProductPostingGroup() var ContosoPostingGroup: Codeunit "Contoso Posting Group"; - CreateCHPostingGroups: Codeunit "Create CH Posting Groups"; - CreateCHGLAccounts: Codeunit "Create CH GL Accounts"; - CreateGLAccount: Codeunit "Create G/L Account"; - CreatePostingGroup: Codeunit "Create Posting Groups"; - CreateVATPostingGroups: Codeunit "Create VAT Posting Groups"; begin ContosoPostingGroup.InsertVATProductPostingGroup(HalfNormal(), HalfStandardRateLbl); ContosoPostingGroup.InsertVATProductPostingGroup(Hotel(), HotelsLbl); @@ -56,7 +51,16 @@ codeunit 11616 "Create CH VAT Posting Groups" ContosoPostingGroup.InsertVATProductPostingGroup(Normal(), NormalVATRateLbl); ContosoPostingGroup.InsertVATProductPostingGroup(OperatingExpense(), VATOperatingExpensesLbl); ContosoPostingGroup.InsertVATProductPostingGroup(Reduced(), ReducedRateLbl); + end; + procedure UpdateVATProductPostingGroup() + var + CreateCHPostingGroups: Codeunit "Create CH Posting Groups"; + CreateCHGLAccounts: Codeunit "Create CH GL Accounts"; + CreateGLAccount: Codeunit "Create G/L Account"; + CreatePostingGroup: Codeunit "Create Posting Groups"; + CreateVATPostingGroups: Codeunit "Create VAT Posting Groups"; + begin CreateCHPostingGroups.UpdateVATProdPostingGroup(CreatePostingGroup.RawMatPostingGroup(), Normal()); CreateCHPostingGroups.UpdateVATProdPostingGroup(CreatePostingGroup.RetailPostingGroup(), Normal()); CreateCHPostingGroups.UpdateVATProdPostingGroup(CreatePostingGroup.MiscPostingGroup(), Normal()); diff --git a/Apps/CH/ContosoCoffeeDemoDatasetCH/app/DemoTool/CHContosoLocalization.Codeunit.al b/Apps/CH/ContosoCoffeeDemoDatasetCH/app/DemoTool/CHContosoLocalization.Codeunit.al index 05de1c3617..92b462f25b 100644 --- a/Apps/CH/ContosoCoffeeDemoDatasetCH/app/DemoTool/CHContosoLocalization.Codeunit.al +++ b/Apps/CH/ContosoCoffeeDemoDatasetCH/app/DemoTool/CHContosoLocalization.Codeunit.al @@ -166,6 +166,7 @@ codeunit 11620 "CH Contoso Localization" Enum::"Contoso Demo Data Module"::Finance: begin + CreateCHVATPostingGroups.CreateVATProductPostingGroup(); BindSubscription(CreateCHAccScheduleLine); BindSubscription(CreateCHColumnLayout); BindSubscription(CreateCHCurrency); diff --git a/Apps/CZ/AdvancedLocalizationPack/app/Src/Codeunits/GLEntryPostApplicationCZA.Codeunit.al b/Apps/CZ/AdvancedLocalizationPack/app/Src/Codeunits/GLEntryPostApplicationCZA.Codeunit.al index 6ec5370f78..2e65689606 100644 --- a/Apps/CZ/AdvancedLocalizationPack/app/Src/Codeunits/GLEntryPostApplicationCZA.Codeunit.al +++ b/Apps/CZ/AdvancedLocalizationPack/app/Src/Codeunits/GLEntryPostApplicationCZA.Codeunit.al @@ -15,9 +15,7 @@ codeunit 31370 "G/L Entry Post Application CZA" tabledata "Detailed G/L Entry CZA" = rim; var - GLEntry: Record "G/L Entry"; ConfirmManagement: Codeunit "Confirm Management"; - ApplyingAmount: Decimal; NotUseDialog: Boolean; ApplicationEntryErr: Label '%1 No. %2 does not have an application entry.', Comment = '%1 = TableCaption G/L Entry, %2 = Entry No.'; PrecedeLatestErr: Label 'The entered %1 must not precede the latest %1 on %2.', Comment = '%1 = FieldCatpion Postig Date, %2 = TableCaption G/L Entry'; @@ -35,34 +33,32 @@ codeunit 31370 "G/L Entry Post Application CZA" var ApplyUnapplyParameters: Record "Apply Unapply Parameters"; DetailedGLEntryCZA: Record "Detailed G/L Entry CZA"; + GLEntry: Record "G/L Entry"; + TempAppliedGLEntry: Record "G/L Entry" temporary; PostApplication: Page "Post Application"; WindowDialog: Dialog; + ApplyingAmount: Decimal; DocumentNo: Code[20]; PostingDate: Date; ApplicationDate: Date; TransactionNo: Integer; - IsZero, IsHandled : Boolean; begin Clear(PostingDate); - GLEntry.SetCurrentKey("Applies-to ID CZA", "Applying Entry CZA"); - GLEntry.SetLoadFields("Entry No.", "Applies-to ID CZA", "Amount to Apply CZA", Amount, "Posting Date"); + GLEntry.ReadIsolation(IsolationLevel::ReadCommitted); + GLEntry.SetCurrentKey("Applies-to ID CZA"); GLEntry.SetRange("Applies-to ID CZA", ApplyingGLEntry."Applies-to ID CZA"); - GLEntry.SetRange("G/L Account No.", ApplyingGLEntry."G/L Account No."); - if ApplyingGLEntry.Amount > 0 then - GLEntry.SetFilter(Amount, '<0') - else - GLEntry.SetFilter(Amount, '>0'); OnPostApplyGLEntryOnAfterSetFilters(GLEntry, ApplyingGLEntry); if GLEntry.FindSet(false) then repeat - IsHandled := false; - OnPostApplyGLEntryOnBeforeSignAmtCheck(GLEntry, ApplyingGLEntry, IsHandled); - if not IsHandled then - if GLEntry."Amount to Apply CZA" <> 0 then - if (GLEntry.Amount * ApplyingGLEntry.Amount) > 0 then - Error(SignAmtMustBediffErr); - if GLEntry."Posting Date" > PostingDate then - PostingDate := GLEntry."Posting Date" + if IsAppliedEntry(GLEntry, ApplyingGLEntry) then begin + CheckAmountSign(GLEntry, ApplyingGLEntry); + if GLEntry."Posting Date" > PostingDate then + PostingDate := GLEntry."Posting Date"; + + TempAppliedGLEntry.Init(); + TempAppliedGLEntry := GLEntry; + TempAppliedGLEntry.Insert(); + end; until GLEntry.Next() = 0; if ApplyingGLEntry."Posting Date" > PostingDate then @@ -88,115 +84,89 @@ codeunit 31370 "G/L Entry Post Application CZA" end else ApplicationDate := PostingDate; - ApplyingAmount := 0; - if GLEntry.FindSet(true) then - repeat - ApplyingAmount := ApplyingAmount + GLEntry."Amount to Apply CZA"; - if GLEntry.Amount = 0 then begin - IsZero := true; - GLEntry."Closed at Date CZA" := ApplicationDate; - GLEntry."Closed CZA" := true; - GLEntry."Applying Entry CZA" := false; - GLEntry."Amount to Apply CZA" := 0; - GLEntry."Applies-to ID CZA" := ''; - GLEntry.Modify(); - end; - until GLEntry.Next() = 0; - ApplyingAmount := ApplyingAmount + ApplyingGLEntry."Amount to Apply CZA"; + TempAppliedGLEntry.Reset(); + TempAppliedGLEntry.CalcSums("Amount to Apply CZA"); + ApplyingAmount := TempAppliedGLEntry."Amount to Apply CZA"; + ApplyingAmount += ApplyingGLEntry."Amount to Apply CZA"; if ApplyingAmount <> 0 then begin if ApplyingAmount > 0 then - GLEntry.SetFilter(Amount, '>0') + TempAppliedGLEntry.SetFilter(Amount, '>0') else - GLEntry.SetFilter(Amount, '<0'); - GLEntry.SetRange("Applying Entry CZA", false); - GLEntry.Ascending(false); - if GLEntry.FindSet(true) then + TempAppliedGLEntry.SetFilter(Amount, '<0'); + TempAppliedGLEntry.SetRange("Applying Entry CZA", false); + TempAppliedGLEntry.Ascending(false); + if TempAppliedGLEntry.FindSet(true) then repeat - if (ApplyingGLEntry.Amount > 0) and (GLEntry.Amount < 0) or - (ApplyingGLEntry.Amount < 0) and (GLEntry.Amount > 0) + if (ApplyingGLEntry.Amount > 0) and (TempAppliedGLEntry.Amount < 0) or + (ApplyingGLEntry.Amount < 0) and (TempAppliedGLEntry.Amount > 0) then begin - GLEntry.CalcFields("Applied Amount CZA"); + TempAppliedGLEntry.CalcFields("Applied Amount CZA"); if (ApplyingAmount <> 0) and - (GLEntry.Amount = GLEntry."Amount to Apply CZA" + GLEntry."Applied Amount CZA") + (TempAppliedGLEntry.Amount = TempAppliedGLEntry."Amount to Apply CZA" + TempAppliedGLEntry."Applied Amount CZA") then begin - SetAmountToApply(); - GLEntry.Modify(); + SetAmountToApply(TempAppliedGLEntry, ApplyingAmount); + TempAppliedGLEntry.Modify(); end; end; - until GLEntry.Next() = 0; + until TempAppliedGLEntry.Next() = 0; if ApplyingAmount <> 0 then begin - GLEntry.SetFilter("Amount to Apply CZA", '<>0'); - if GLEntry.FindSet(true) then + TempAppliedGLEntry.SetFilter("Amount to Apply CZA", '<>0'); + if TempAppliedGLEntry.FindSet(true) then repeat - if (ApplyingGLEntry.Amount > 0) and (GLEntry.Amount < 0) or - (ApplyingGLEntry.Amount < 0) and (GLEntry.Amount > 0) + if (ApplyingGLEntry.Amount > 0) and (TempAppliedGLEntry.Amount < 0) or + (ApplyingGLEntry.Amount < 0) and (TempAppliedGLEntry.Amount > 0) then begin - SetAmountToApply(); - GLEntry.Modify(); + SetAmountToApply(TempAppliedGLEntry, ApplyingAmount); + TempAppliedGLEntry.Modify(); end; - until GLEntry.Next() = 0; - end; - GLEntry.Ascending(true); - - if ApplyingAmount <> 0 then begin - GLEntry.SetRange("Applying Entry CZA", true); - if GLEntry.FindFirst() then begin - GLEntry."Amount to Apply CZA" := GLEntry."Amount to Apply CZA" - ApplyingAmount; - ApplyingAmount := 0; - GLEntry.Modify(); - end; + until TempAppliedGLEntry.Next() = 0; end; + TempAppliedGLEntry.Ascending(true); end; - GLEntry.Reset(); - GLEntry.SetCurrentKey("Applies-to ID CZA"); - GLEntry.SetRange("Applies-to ID CZA", ApplyingGLEntry."Applies-to ID CZA"); - GLEntry.SetRange("G/L Account No.", ApplyingGLEntry."G/L Account No."); - GLEntry.SetRange("Amount to Apply CZA", 0); - if not GLEntry.IsEmpty() then - GLEntry.ModifyAll("Applies-to ID CZA", ''); - TransactionNo := FindLastTransactionNo() + 1; - GLEntry.Reset(); - GLEntry.SetCurrentKey("Applies-to ID CZA"); - GLEntry.SetLoadFields("Entry No.", "G/L Account No.", "Amount to Apply CZA", "Applies-to ID CZA", Amount); - GLEntry.SetRange("Applies-to ID CZA", ApplyingGLEntry."Applies-to ID CZA"); - GLEntry.SetRange("G/L Account No.", ApplyingGLEntry."G/L Account No."); - if GLEntry.FindSet(true) then + TempAppliedGLEntry.Init(); + TempAppliedGLEntry := ApplyingGLEntry; + TempAppliedGLEntry."Amount to Apply CZA" -= ApplyingAmount; + TempAppliedGLEntry.Insert(); + + TempAppliedGLEntry.Reset(); + TempAppliedGLEntry.SetRange("Applies-to ID CZA", ApplyingGLEntry."Applies-to ID CZA"); + if TempAppliedGLEntry.FindSet() then repeat - DetailedGLEntryCZA.Init(); - DetailedGLEntryCZA."Entry No." := FindLastDtldGLEntryNo() + 1; - DetailedGLEntryCZA."G/L Entry No." := GLEntry."Entry No."; - DetailedGLEntryCZA."Applied G/L Entry No." := ApplyingGLEntry."Entry No."; - DetailedGLEntryCZA."G/L Account No." := GLEntry."G/L Account No."; - DetailedGLEntryCZA."Posting Date" := ApplicationDate; - DetailedGLEntryCZA."Document No." := DocumentNo; - DetailedGLEntryCZA."Transaction No." := TransactionNo; - DetailedGLEntryCZA.Amount := -GLEntry."Amount to Apply CZA"; - if NotUseDialog then - DetailedGLEntryCZA."User ID" := CopyStr(UserId, 1, MaxStrLen(DetailedGLEntryCZA."User ID")) - else - DetailedGLEntryCZA."User ID" := GLEntry."Applies-to ID CZA"; - DetailedGLEntryCZA.Insert(); - GLEntry.CalcFields("Applied Amount CZA"); - if GLEntry."Applied Amount CZA" = GLEntry.Amount then begin - GLEntry."Closed at Date CZA" := ApplicationDate; - GLEntry."Closed CZA" := true; + if TempAppliedGLEntry.Amount = 0 then + CloseGLEntry(TempAppliedGLEntry, ApplicationDate); + if TempAppliedGLEntry."Amount to Apply CZA" = 0 then + TempAppliedGLEntry."Applies-to ID CZA" := '' + else begin + DetailedGLEntryCZA.Init(); + DetailedGLEntryCZA."Entry No." := FindLastDtldGLEntryNo() + 1; + DetailedGLEntryCZA."G/L Entry No." := TempAppliedGLEntry."Entry No."; + DetailedGLEntryCZA."Applied G/L Entry No." := ApplyingGLEntry."Entry No."; + DetailedGLEntryCZA."G/L Account No." := TempAppliedGLEntry."G/L Account No."; + DetailedGLEntryCZA."Posting Date" := ApplicationDate; + DetailedGLEntryCZA."Document No." := DocumentNo; + DetailedGLEntryCZA."Transaction No." := TransactionNo; + DetailedGLEntryCZA.Amount := -TempAppliedGLEntry."Amount to Apply CZA"; + if NotUseDialog then + DetailedGLEntryCZA."User ID" := CopyStr(UserId, 1, MaxStrLen(DetailedGLEntryCZA."User ID")) + else + DetailedGLEntryCZA."User ID" := TempAppliedGLEntry."Applies-to ID CZA"; + DetailedGLEntryCZA.Insert(); + + CloseGLEntry(TempAppliedGLEntry, ApplicationDate); end; - GLEntry."Applying Entry CZA" := false; - GLEntry."Amount to Apply CZA" := 0; - GLEntry."Applies-to ID CZA" := ''; - GLEntry.Modify(); - until GLEntry.Next() = 0 + + WriteToDatabase(TempAppliedGLEntry); + until TempAppliedGLEntry.Next() = 0 else - if not NotUseDialog then - if not IsZero then begin - WindowDialog.Close(); - Error(NothingToApplyErr); - end; + if not NotUseDialog then begin + WindowDialog.Close(); + Error(NothingToApplyErr); + end; if not NotUseDialog then begin Commit(); WindowDialog.Close(); @@ -206,8 +176,9 @@ codeunit 31370 "G/L Entry Post Application CZA" procedure PostUnApplyGLEntry(var DetailedGLEntryCZA: Record "Detailed G/L Entry CZA"; DocumentNo: Code[20]; PostingDate: Date) var - SelectedDetailedGLEntryCZA: Record "Detailed G/L Entry CZA"; ChangedDetailedGLEntryCZA: Record "Detailed G/L Entry CZA"; + GLEntry: Record "G/L Entry"; + SelectedDetailedGLEntryCZA: Record "Detailed G/L Entry CZA"; WindowDialog: Dialog; ApplicationEntryNo: Integer; TransactionNo: Integer; @@ -273,6 +244,7 @@ codeunit 31370 "G/L Entry Post Application CZA" procedure UnApplyGLEntry(GLEntryNo: Integer) var DetailedGLEntryCZA: Record "Detailed G/L Entry CZA"; + GLEntry: Record "G/L Entry"; ApplicationEntryNo: Integer; begin GLEntry.Get(GLEntryNo); @@ -339,13 +311,22 @@ codeunit 31370 "G/L Entry Post Application CZA" DtldGLEntryNo := 0; end; + [Obsolete('The local SetAmountToApply procedure is used instead.', '26.0')] procedure SetAmountToApply() + var + GLEntry: Record "G/L Entry"; + ApplyingAmount: Decimal; + begin + SetAmountToApply(GLEntry, ApplyingAmount); + end; + + local procedure SetAmountToApply(var GLEntry: Record "G/L Entry"; var ApplyingAmount: Decimal) begin if Abs(GLEntry."Amount to Apply CZA") - Abs(ApplyingAmount) <= 0 then begin - ApplyingAmount := ApplyingAmount - GLEntry."Amount to Apply CZA"; + ApplyingAmount -= GLEntry."Amount to Apply CZA"; GLEntry."Amount to Apply CZA" := 0; end else begin - GLEntry."Amount to Apply CZA" := GLEntry."Amount to Apply CZA" - ApplyingAmount; + GLEntry."Amount to Apply CZA" -= ApplyingAmount; ApplyingAmount := 0; end; end; @@ -389,7 +370,7 @@ codeunit 31370 "G/L Entry Post Application CZA" IsHandled: Boolean; begin IsHandled := false; - OnBeforeAtomatedGLEntryApplication(GenJournalLine, GLEntry, IsHandled); + OnBeforeAtomatedGLEntryApplication(GenJournalLine, VarGLEntry, IsHandled); if IsHandled then exit; @@ -424,6 +405,55 @@ codeunit 31370 "G/L Entry Post Application CZA" end; end; + local procedure IsAppliedEntry(GLEntry: Record "G/L Entry"; ApplyingGLEntry: Record "G/L Entry") IsOk: Boolean + begin + IsOk := + (GLEntry."G/L Account No." = ApplyingGLEntry."G/L Account No.") and + ((GLEntry.Amount * ApplyingGLEntry.Amount) < 0) and + (GLEntry.Amount <> 0); + OnAfterIsAppliedEntry(GLEntry, ApplyingGLEntry, IsOk); + end; + + local procedure CheckAmountSign(GLEntry: Record "G/L Entry"; ApplyingGLEntry: Record "G/L Entry") + var + IsHandled: Boolean; + begin + IsHandled := false; + OnPostApplyGLEntryOnBeforeSignAmtCheck(GLEntry, ApplyingGLEntry, IsHandled); + if IsHandled then + exit; + + if GLEntry."Amount to Apply CZA" <> 0 then + if (GLEntry.Amount * ApplyingGLEntry.Amount) > 0 then + Error(SignAmtMustBediffErr); + end; + + local procedure CloseGLEntry(var GLEntry: Record "G/L Entry"; ClosedAtDate: Date) + begin + if GLEntry.Amount <> 0 then + GLEntry.CalcFields("Applied Amount CZA"); + if GLEntry."Applied Amount CZA" = GLEntry.Amount then begin + GLEntry."Closed at Date CZA" := ClosedAtDate; + GLEntry."Closed CZA" := true; + end; + GLEntry."Applying Entry CZA" := false; + GLEntry."Amount to Apply CZA" := 0; + GLEntry."Applies-to ID CZA" := ''; + end; + + local procedure WriteToDatabase(GLEntry: Record "G/L Entry") + var + ModifiedGLEntry: Record "G/L Entry"; + begin + ModifiedGLEntry.Get(GLEntry."Entry No."); + ModifiedGLEntry."Closed at Date CZA" := GLEntry."Closed at Date CZA"; + ModifiedGLEntry."Closed CZA" := GLEntry."Closed CZA"; + ModifiedGLEntry."Applying Entry CZA" := GLEntry."Applying Entry CZA"; + ModifiedGLEntry."Amount to Apply CZA" := GLEntry."Amount to Apply CZA"; + ModifiedGLEntry."Applies-to ID CZA" := GLEntry."Applies-to ID CZA"; + ModifiedGLEntry.Modify(); + end; + [IntegrationEvent(false, false)] local procedure OnBeforeAtomatedGLEntryApplication(var GenJournalLine: Record "Gen. Journal Line"; var GLEntry: Record "G/L Entry"; var IsHandled: Boolean) begin @@ -438,4 +468,9 @@ codeunit 31370 "G/L Entry Post Application CZA" local procedure OnPostApplyGLEntryOnBeforeSignAmtCheck(GLEntry: Record "G/L Entry"; ApplyingGLEntry: Record "G/L Entry"; var IsHandled: Boolean) begin end; + + [IntegrationEvent(true, false)] + local procedure OnAfterIsAppliedEntry(GLEntry: Record "G/L Entry"; ApplyingGLEntry: Record "G/L Entry"; var IsOk: Boolean) + begin + end; } diff --git a/Apps/CZ/AdvancedLocalizationPack/app/Src/Codeunits/GenJnlApplyHandlerCZA.Codeunit.al b/Apps/CZ/AdvancedLocalizationPack/app/Src/Codeunits/GenJnlApplyHandlerCZA.Codeunit.al index e3ae1e47e2..b6285eaf11 100644 --- a/Apps/CZ/AdvancedLocalizationPack/app/Src/Codeunits/GenJnlApplyHandlerCZA.Codeunit.al +++ b/Apps/CZ/AdvancedLocalizationPack/app/Src/Codeunits/GenJnlApplyHandlerCZA.Codeunit.al @@ -51,6 +51,7 @@ codeunit 31379 "Gen. Jnl.-Apply Handler CZA" local procedure ApplyGLEntryCZA(var GenJournalLine: Record "Gen. Journal Line"; AccNo: Code[20]; AccBalance: Boolean) var GLEntry: Record "G/L Entry"; + TempGLEntry: Record "G/L Entry" temporary; ApplyGenLedgerEntriesCZA: Page "Apply Gen. Ledger Entries CZA"; PreviousAppliesToID: Code[50]; EntrySelected: Boolean; @@ -86,25 +87,23 @@ codeunit 31379 "Gen. Jnl.-Apply Handler CZA" ApplyGenLedgerEntriesCZA.SetGenJournalLine(GenJournalLine); ApplyGenLedgerEntriesCZA.LookupMode(true); EntrySelected := ApplyGenLedgerEntriesCZA.RunModal() = Action::LookupOK; - Clear(ApplyGenLedgerEntriesCZA); if not EntrySelected then begin GenJournalLine."Applies-to ID" := PreviousAppliesToID; exit; end; + ApplyGenLedgerEntriesCZA.CopyEntry(TempGLEntry); - GLEntry.Reset(); - GLEntry.SetCurrentKey("G/L Account No.", "Applies-to ID CZA"); - GLEntry.SetRange("G/L Account No.", AccNo); - GLEntry.SetRange("Closed CZA", false); - GLEntry.SetRange("Applies-to ID CZA", GenJournalLine."Applies-to ID"); - if GLEntry.FindSet() then begin + TempGLEntry.Reset(); + TempGLEntry.SetRange("Closed CZA", false); + TempGLEntry.SetRange("Applies-to ID CZA", GenJournalLine."Applies-to ID"); + if TempGLEntry.FindSet() then begin if GenJournalLine.Amount = 0 then begin repeat - if Abs(GLEntry."Amount to Apply CZA") >= Abs(GLEntry.RemainingAmountCZA()) then - GenJournalLine.Amount := GenJournalLine.Amount - GLEntry.RemainingAmountCZA() + if Abs(TempGLEntry."Amount to Apply CZA") >= Abs(TempGLEntry.RemainingAmountCZA()) then + GenJournalLine.Amount := GenJournalLine.Amount - TempGLEntry.RemainingAmountCZA() else - GenJournalLine.Amount := GenJournalLine.Amount - GLEntry."Amount to Apply CZA"; - until GLEntry.Next() = 0; + GenJournalLine.Amount := GenJournalLine.Amount - TempGLEntry."Amount to Apply CZA"; + until TempGLEntry.Next() = 0; if GenJournalLine."Account Type" <> GenJournalLine."Bal. Account Type"::"G/L Account" then GenJournalLine.Amount := -GenJournalLine.Amount; GenJournalLine.Validate(Amount); diff --git a/Apps/CZ/AdvancedLocalizationPack/app/Src/Pages/ApplyGenLedgerEntriesCZA.Page.al b/Apps/CZ/AdvancedLocalizationPack/app/Src/Pages/ApplyGenLedgerEntriesCZA.Page.al index 0d969c1358..6e2b05f6cb 100644 --- a/Apps/CZ/AdvancedLocalizationPack/app/Src/Pages/ApplyGenLedgerEntriesCZA.Page.al +++ b/Apps/CZ/AdvancedLocalizationPack/app/Src/Pages/ApplyGenLedgerEntriesCZA.Page.al @@ -512,6 +512,12 @@ page 31287 "Apply Gen. Ledger Entries CZA" until NewGLEntry.Next() = 0; end; + internal procedure CopyEntry(var TempGLEntry: Record "G/L Entry" temporary) + begin + Rec.Reset(); + TempGLEntry.Copy(Rec, true); + end; + local procedure FindApplyingGLEntry() begin AppliesToID := Rec.GetDefaultAppliesToID(); diff --git a/Apps/CZ/AdvancedLocalizationPack/app/Src/Reports/GLEntryApplyingCZA.Report.al b/Apps/CZ/AdvancedLocalizationPack/app/Src/Reports/GLEntryApplyingCZA.Report.al index 0e58c5514c..fc21e674ed 100644 --- a/Apps/CZ/AdvancedLocalizationPack/app/Src/Reports/GLEntryApplyingCZA.Report.al +++ b/Apps/CZ/AdvancedLocalizationPack/app/Src/Reports/GLEntryApplyingCZA.Report.al @@ -101,7 +101,7 @@ report 31132 "G/L Entry Applying CZA" if Apply then begin OriginalEntry."Applies-to ID CZA" := OriginalEntry."Document No."; - OriginalEntry."Amount to Apply CZA" := OriginalEntry.Amount - OriginalEntry."Applied Amount CZA"; + OriginalEntry."Amount to Apply CZA" := -TotalAmount; OriginalEntry.Modify(); Clear(GLEntryPostApplicationCZA); diff --git a/Apps/CZ/AdvancedLocalizationPack/app/Src/TableExtensions/GLEntryCZA.TableExt.al b/Apps/CZ/AdvancedLocalizationPack/app/Src/TableExtensions/GLEntryCZA.TableExt.al index 6fe8654c6b..50704afc9b 100644 --- a/Apps/CZ/AdvancedLocalizationPack/app/Src/TableExtensions/GLEntryCZA.TableExt.al +++ b/Apps/CZ/AdvancedLocalizationPack/app/Src/TableExtensions/GLEntryCZA.TableExt.al @@ -50,7 +50,7 @@ tableextension 31265 "G/L Entry CZA" extends "G/L Entry" field(11788; "Applied Amount CZA"; Decimal) { - CalcFormula = - Sum("Detailed G/L Entry CZA".Amount where("G/L Entry No." = field("Entry No."), + CalcFormula = - sum("Detailed G/L Entry CZA".Amount where("G/L Entry No." = field("Entry No."), "Posting Date" = field("Date Filter CZA"))); Caption = 'Applied Amount'; Editable = false; @@ -62,7 +62,6 @@ tableextension 31265 "G/L Entry CZA" extends "G/L Entry" { key(AppliestoIDKeyCZA; "Applies-to ID CZA", "Applying Entry CZA") { - SumIndexFields = "Amount to Apply CZA"; } } diff --git a/Apps/CZ/AdvancedLocalizationPack/test/Src/ApplyingGLEntriesCZA.Codeunit.al b/Apps/CZ/AdvancedLocalizationPack/test/Src/ApplyingGLEntriesCZA.Codeunit.al index eed6eb89fd..c3998bbff4 100644 --- a/Apps/CZ/AdvancedLocalizationPack/test/Src/ApplyingGLEntriesCZA.Codeunit.al +++ b/Apps/CZ/AdvancedLocalizationPack/test/Src/ApplyingGLEntriesCZA.Codeunit.al @@ -15,6 +15,7 @@ codeunit 148081 "Applying G/L Entries CZA" LibraryRandom: Codeunit "Library - Random"; LibraryReportDataset: Codeunit "Library - Report Dataset"; LibraryVariableStorage: Codeunit "Library - Variable Storage"; + FromGLEntryNo: Integer; isInitialized: Boolean; UnexpectedRemAmtErr: Label 'Unexpected Remaining Amount.'; @@ -24,6 +25,9 @@ codeunit 148081 "Applying G/L Entries CZA" begin LibraryTestInitialize.OnTestInitialize(Codeunit::"Applying G/L Entries CZA"); LibraryRandom.Init(); + + InitFromGLEntryNo(); + if isInitialized then exit; LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Applying G/L Entries CZA"); @@ -213,6 +217,615 @@ codeunit 148081 "Applying G/L Entries CZA" Assert.AreEqual(true, GLEntry."Closed CZA", GLEntry.FieldCaption("Closed CZA")); end; + [Test] + [HandlerFunctions('ModalApplyGLEntriesHandlerSingle,ModalPostApplicationHandler,MessageHandler')] + procedure ApplyingGLEntriesWithSamePostingDateToZero() + var + ApplyingGLEntry: Record "G/L Entry"; + AppliedGLEntry: Record "G/L Entry"; + begin + // [SCENARIO] Applying G/L Entries with the same posting date to zero + Initialize(); + + // [GIVEN] The general journal lines with more than 10 lines have been posted + PostGenJournalLines(); + + // [GIVEN] The G/L entry with work date and the positive amount has been found + ApplyingGLEntry.SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + ApplyingGLEntry.SetRange("Posting Date", WorkDate()); + ApplyingGLEntry.SetFilter(Amount, '>%1', 0); + ApplyingGLEntry.FindFirst(); + + // [GIVEN] The G/L entry with work date and the negative amount has been found + AppliedGLEntry.SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry.SetRange("Posting Date", ApplyingGLEntry."Posting Date"); + AppliedGLEntry.SetRange(Amount, -ApplyingGLEntry.Amount); + AppliedGLEntry.FindFirst(); + + // [WHEN] Run the applying of the G/L entries + ApplyGLEntryFromGLEntry(ApplyingGLEntry, AppliedGLEntry); + + // [THEN] The applied G/L entry will be fully applied + AppliedGLEntry.Find('='); + VerifyGLEntry(AppliedGLEntry); + + // [THEN] The applying G/L entry will be fully applied + ApplyingGLEntry.Find('='); + VerifyGLEntry(ApplyingGLEntry); + end; + + [Test] + [HandlerFunctions('ModalApplyGLEntriesHandlerSingle,ModalPostApplicationHandler,MessageHandler')] + procedure ApplyingGLEntriesWithDifferentPostingDateToZero() + var + ApplyingGLEntry: Record "G/L Entry"; + AppliedGLEntry: Record "G/L Entry"; + begin + // [SCENARIO] Applying G/L Entries with the different posting date to zero + Initialize(); + + // [GIVEN] The general journal lines with more than 10 lines have been posted + PostGenJournalLines(); + + // [GIVEN] The G/L entry with work date and the positive amount has been found + ApplyingGLEntry.SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + ApplyingGLEntry.SetRange("Posting Date", WorkDate()); + ApplyingGLEntry.SetFilter(Amount, '>%1', 0); + ApplyingGLEntry.FindFirst(); + + // [GIVEN] The G/L entry with work date +1D and the negative amount has been found + AppliedGLEntry.SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry.SetRange("Posting Date", CalcDate('', ApplyingGLEntry."Posting Date")); + AppliedGLEntry.SetRange(Amount, -ApplyingGLEntry.Amount); + AppliedGLEntry.FindFirst(); + + // [WHEN] Run the applying of the G/L entries + ApplyGLEntryFromGLEntry(ApplyingGLEntry, AppliedGLEntry); + + // [THEN] The applied G/L entry will be fully applied + AppliedGLEntry.Find('='); + VerifyGLEntry(AppliedGLEntry, AppliedGLEntry."Posting Date"); + + // [THEN] The applying G/L entry will be fully applied + ApplyingGLEntry.Find('='); + VerifyGLEntry(ApplyingGLEntry, AppliedGLEntry."Posting Date"); + end; + + [Test] + [HandlerFunctions('ModalApplyGLEntriesHandlerSingle,ModalPostApplicationHandler,MessageHandler')] + procedure ApplyingGLEntriesWithPositiveBalance() + var + ApplyingGLEntry: Record "G/L Entry"; + AppliedGLEntry: Record "G/L Entry"; + begin + // [SCENARIO] Applying G/L Entries with positive balance + Initialize(); + + // [GIVEN] The general journal lines with more than 10 lines have been posted + PostGenJournalLines(); + + // [GIVEN] The G/L entry with work date and the highest positive amount has been found + ApplyingGLEntry.SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + ApplyingGLEntry.SetRange("Posting Date", WorkDate()); + ApplyingGLEntry.SetFilter(Amount, '>%1', 0); + ApplyingGLEntry.FindLast(); + + // [GIVEN] The G/L entry with work date and the abs value of amount less than applying amount has been found + AppliedGLEntry.SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry.SetRange("Posting Date", ApplyingGLEntry."Posting Date"); + AppliedGLEntry.SetFilter(Amount, '>%1&<%2', -ApplyingGLEntry.Amount, 0); + AppliedGLEntry.FindLast(); + + // [WHEN] Start the applying of the G/L entries + ApplyGLEntryFromGLEntry(ApplyingGLEntry, AppliedGLEntry); + + // [THEN] The applied G/L entry will be fully applied + AppliedGLEntry.Find('='); + VerifyGLEntry(AppliedGLEntry); + + // [THEN] The applying G/L entry will be partly applied + ApplyingGLEntry.Find('='); + VerifyGLEntry(ApplyingGLEntry, + Abs(ApplyingGLEntry.Amount) - Abs(AppliedGLEntry.Amount), + -AppliedGLEntry.Amount, ApplyingGLEntry."Posting Date"); + end; + + [Test] + [HandlerFunctions('ModalApplyGLEntriesHandlerSingle,ModalPostApplicationHandler,MessageHandler')] + procedure ApplyingGLEntriesWithNegativeBalance() + var + ApplyingGLEntry: Record "G/L Entry"; + AppliedGLEntry: Record "G/L Entry"; + begin + // [SCENARIO] Applying G/L Entries with negative balance + Initialize(); + + // [GIVEN] The general journal lines with more than 10 lines have been posted + PostGenJournalLines(); + + // [GIVEN] The G/L entry with work date and the lowest negative amount has been found + ApplyingGLEntry.SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + ApplyingGLEntry.SetRange("Posting Date", WorkDate()); + ApplyingGLEntry.SetFilter(Amount, '<%1', 0); + ApplyingGLEntry.FindLast(); + + // [GIVEN] The G/L entry with work date and the abs value of amount less than applying amount has been found + AppliedGLEntry.SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry.SetRange("Posting Date", ApplyingGLEntry."Posting Date"); + AppliedGLEntry.SetFilter(Amount, '<%1&>%2', -ApplyingGLEntry.Amount, 0); + AppliedGLEntry.FindLast(); + + // [WHEN] Start the applying of the G/L entries + ApplyGLEntryFromGLEntry(ApplyingGLEntry, AppliedGLEntry); + + // [THEN] The applied G/L entry will be fully applied + AppliedGLEntry.Find('='); + VerifyGLEntry(AppliedGLEntry); + + // [THEN] The applying G/L entry will be partly applied + ApplyingGLEntry.Find('='); + VerifyGLEntry(ApplyingGLEntry, + -(Abs(ApplyingGLEntry.Amount) - Abs(AppliedGLEntry.Amount)), + -AppliedGLEntry.Amount, ApplyingGLEntry."Posting Date"); + end; + + [Test] + [HandlerFunctions('ModalApplyGLEntriesHandlerMultiple,ModalPostApplicationHandler,MessageHandler')] + procedure ApplyingPositiveGLEntryToMultipleNegativeGLEntriesWithPositiveBalance() + var + ApplyingGLEntry: Record "G/L Entry"; + AppliedGLEntry: array[2] of Record "G/L Entry"; + ListOfGLEntryNo: List of [Integer]; + begin + // [SCENARIO] Applying positive G/L entry to multiple negative G/L entries with positive balance + Initialize(); + + // [GIVEN] The general journal lines with more than 10 lines have been posted + PostGenJournalLines(); + + // [GIVEN] The G/L entry with work date and the highest positive amount has been found + ApplyingGLEntry.SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + ApplyingGLEntry.SetRange("Posting Date", WorkDate()); + ApplyingGLEntry.SetFilter(Amount, '>%1', 0); + ApplyingGLEntry.FindLast(); + + // [GIVEN] The G/L entry with work date and the lowest negative amount has been found + AppliedGLEntry[1].SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry[1].SetRange("Posting Date", ApplyingGLEntry."Posting Date"); + AppliedGLEntry[1].SetFilter(Amount, '<%1', 0); + AppliedGLEntry[1].FindFirst(); + ListOfGLEntryNo.Add(AppliedGLEntry[1]."Entry No."); + + // [GIVEN] The G/L entry with work date and the second owest negative amount has been found + AppliedGLEntry[2].SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry[2].SetRange("Posting Date", ApplyingGLEntry."Posting Date"); + AppliedGLEntry[2].SetFilter(Amount, '<%1&<%2', 0, AppliedGLEntry[1].Amount); + AppliedGLEntry[2].FindFirst(); + ListOfGLEntryNo.Add(AppliedGLEntry[2]."Entry No."); + + // [WHEN] Start the applying of the G/L entries + ApplyGLEntryFromGLEntry(ApplyingGLEntry, ListOfGLEntryNo); + + // [THEN] The applying G/L entry will be partly applied + ApplyingGLEntry.Find('='); + VerifyGLEntry(ApplyingGLEntry, + Abs(ApplyingGLEntry.Amount) - Abs(AppliedGLEntry[1].Amount) - Abs(AppliedGLEntry[2].Amount), + Abs(AppliedGLEntry[1].Amount) + Abs(AppliedGLEntry[2].Amount), ApplyingGLEntry."Posting Date"); + end; + + [Test] + [HandlerFunctions('ModalApplyGLEntriesHandlerMultiple,ModalPostApplicationHandler,MessageHandler')] + procedure ApplyingPositiveGLEntryToMultipleNegativeGLEntriesAndDiffPostingDateWithPositiveBalance() + var + ApplyingGLEntry: Record "G/L Entry"; + AppliedGLEntry: array[2] of Record "G/L Entry"; + ListOfGLEntryNo: List of [Integer]; + begin + // [SCENARIO] Applying positive G/L entry to multiple negative G/L entries and different posting date with positive balance + Initialize(); + + // [GIVEN] The general journal lines with more than 10 lines have been posted + PostGenJournalLines(); + + // [GIVEN] The G/L entry with work date and the highest positive amount has been found + ApplyingGLEntry.SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + ApplyingGLEntry.SetRange("Posting Date", WorkDate()); + ApplyingGLEntry.SetFilter(Amount, '>%1', 0); + ApplyingGLEntry.FindLast(); + + // [GIVEN] The G/L entry with work date + 1D and the lowest negative amount has been found + AppliedGLEntry[1].SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry[1].SetRange("Posting Date", CalcDate('', ApplyingGLEntry."Posting Date")); + AppliedGLEntry[1].SetFilter(Amount, '<%1', 0); + AppliedGLEntry[1].FindFirst(); + ListOfGLEntryNo.Add(AppliedGLEntry[1]."Entry No."); + + // [GIVEN] The G/L entry with work date + 1D and the second owest negative amount has been found + AppliedGLEntry[2].SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry[2].SetRange("Posting Date", CalcDate('', ApplyingGLEntry."Posting Date")); + AppliedGLEntry[2].SetFilter(Amount, '<%1&<%2', 0, AppliedGLEntry[1].Amount); + AppliedGLEntry[2].FindFirst(); + ListOfGLEntryNo.Add(AppliedGLEntry[2]."Entry No."); + + // [WHEN] Start the applying of the G/L entries + ApplyGLEntryFromGLEntry(ApplyingGLEntry, ListOfGLEntryNo); + + // [THEN] The applying G/L entry will be fully applied + ApplyingGLEntry.Find('='); + VerifyGLEntry(ApplyingGLEntry, + Abs(ApplyingGLEntry.Amount) - Abs(AppliedGLEntry[1].Amount) - Abs(AppliedGLEntry[2].Amount), + Abs(AppliedGLEntry[1].Amount) + Abs(AppliedGLEntry[2].Amount), AppliedGLEntry[1]."Posting Date"); + end; + + [Test] + [HandlerFunctions('ModalApplyGLEntriesHandlerMultiple,ModalPostApplicationHandler,MessageHandler')] + procedure ApplyingNegativeGLEntryToMultiplePositiveGLEntriesWithNegativeBalance() + var + ApplyingGLEntry: Record "G/L Entry"; + AppliedGLEntry: array[2] of Record "G/L Entry"; + ListOfGLEntryNo: List of [Integer]; + begin + // [SCENARIO] Applying negative G/L entry to multiple positive G/L entries with negative balance + Initialize(); + + // [GIVEN] The general journal lines with more than 10 lines have been posted + PostGenJournalLines(); + + // [GIVEN] The G/L entry with work date and the highest positive amount has been found + ApplyingGLEntry.SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + ApplyingGLEntry.SetRange("Posting Date", WorkDate()); + ApplyingGLEntry.SetFilter(Amount, '<%1', 0); + ApplyingGLEntry.FindLast(); + + // [GIVEN] The G/L entry with work date and the lowest negative amount has been found + AppliedGLEntry[1].SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry[1].SetRange("Posting Date", ApplyingGLEntry."Posting Date"); + AppliedGLEntry[1].SetFilter(Amount, '>%1', 0); + AppliedGLEntry[1].FindFirst(); + ListOfGLEntryNo.Add(AppliedGLEntry[1]."Entry No."); + + // [GIVEN] The G/L entry with work date and the second owest negative amount has been found + AppliedGLEntry[2].SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry[2].SetRange("Posting Date", ApplyingGLEntry."Posting Date"); + AppliedGLEntry[2].SetFilter(Amount, '>%1&>%2', 0, AppliedGLEntry[1].Amount); + AppliedGLEntry[2].FindFirst(); + ListOfGLEntryNo.Add(AppliedGLEntry[2]."Entry No."); + + // [WHEN] Start the applying of the G/L entries + ApplyGLEntryFromGLEntry(ApplyingGLEntry, ListOfGLEntryNo); + + // [THEN] The applying G/L entry will be partly applied + ApplyingGLEntry.Find('='); + VerifyGLEntry(ApplyingGLEntry, + -(Abs(ApplyingGLEntry.Amount) - Abs(AppliedGLEntry[1].Amount) - Abs(AppliedGLEntry[2].Amount)), + -(Abs(AppliedGLEntry[1].Amount) + Abs(AppliedGLEntry[2].Amount)), ApplyingGLEntry."Posting Date"); + end; + + [Test] + [HandlerFunctions('ModalApplyGLEntriesHandlerSingle,ModalPostApplicationHandler,MessageHandler')] + procedure ApplyingPositiveGLEntryToGLEntryWithHigherAmount() + var + ApplyingGLEntry: Record "G/L Entry"; + AppliedGLEntry: Record "G/L Entry"; + begin + // [SCENARIO] Applying positive G/L entry to G/L entry with higher amount + Initialize(); + + // [GIVEN] The general journal lines with more than 10 lines have been posted + PostGenJournalLines(); + + // [GIVEN] The G/L entry with work date and the lowest positive amount has been found + ApplyingGLEntry.SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + ApplyingGLEntry.SetRange("Posting Date", WorkDate()); + ApplyingGLEntry.SetFilter(Amount, '>%1', 0); + ApplyingGLEntry.FindFirst(); + + // [GIVEN] The G/L entry with work date has been found + AppliedGLEntry.SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry.SetRange("Posting Date", ApplyingGLEntry."Posting Date"); + AppliedGLEntry.SetFilter(Amount, '<%1', 0); + AppliedGLEntry.FindLast(); + + // [WHEN] Start the applying of the G/L entries + ApplyGLEntryFromGLEntry(ApplyingGLEntry, AppliedGLEntry); + + // [THEN] The applied G/L entry will be partly applied + AppliedGLEntry.Find('='); + VerifyGLEntry(AppliedGLEntry, -(Abs(AppliedGLEntry.Amount) - Abs(ApplyingGLEntry.Amount)), -ApplyingGLEntry.Amount, ApplyingGLEntry."Posting Date"); + + // [THEN] The applying G/L entry will be fully applied + ApplyingGLEntry.Find('='); + VerifyGLEntry(ApplyingGLEntry); + end; + + [Test] + [HandlerFunctions('ModalApplyGLEntriesHandlerSingle,ModalPostApplicationHandler,MessageHandler')] + procedure ApplyingNegativeGLEntryToGLEntryWithHigherAmount() + var + ApplyingGLEntry: Record "G/L Entry"; + AppliedGLEntry: Record "G/L Entry"; + begin + // [SCENARIO] Applying negative G/L entry to G/L entry with higher amount + Initialize(); + + // [GIVEN] The general journal lines with more than 10 lines have been posted + PostGenJournalLines(); + + // [GIVEN] The G/L entry with work date and the lowest negative amount has been found + ApplyingGLEntry.SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + ApplyingGLEntry.SetRange("Posting Date", WorkDate()); + ApplyingGLEntry.SetFilter(Amount, '<%1', 0); + ApplyingGLEntry.FindFirst(); + + // [GIVEN] The G/L entry with work date has been found + AppliedGLEntry.SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry.SetRange("Posting Date", ApplyingGLEntry."Posting Date"); + AppliedGLEntry.SetFilter(Amount, '>%1', 0); + AppliedGLEntry.FindLast(); + + // [WHEN] Start the applying of the G/L entries + ApplyGLEntryFromGLEntry(ApplyingGLEntry, AppliedGLEntry); + + // [THEN] The applied G/L entry will be partly applied + AppliedGLEntry.Find('='); + VerifyGLEntry(AppliedGLEntry, Abs(AppliedGLEntry.Amount) - Abs(ApplyingGLEntry.Amount), -ApplyingGLEntry.Amount, ApplyingGLEntry."Posting Date"); + + // [THEN] The applying G/L entry will be fully applied + ApplyingGLEntry.Find('='); + VerifyGLEntry(ApplyingGLEntry); + end; + + [Test] + [HandlerFunctions('ModalApplyGLEntriesHandlerMultiple,ModalPostApplicationHandler,MessageHandler')] + procedure ApplyingPositiveGLEntryToMultipleNegativeGLEntries() + var + ApplyingGLEntry: Record "G/L Entry"; + AppliedGLEntry: array[2] of Record "G/L Entry"; + ListOfGLEntryNo: List of [Integer]; + begin + // [SCENARIO] Applying positive G/L entry to multiple negative G/L entries + Initialize(); + + // [GIVEN] The general journal lines with more than 10 lines have been posted + PostGenJournalLines(); + + // [GIVEN] The G/L entry with work date and the lowest positive amount has been found + ApplyingGLEntry.SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + ApplyingGLEntry.SetRange("Posting Date", WorkDate()); + ApplyingGLEntry.SetFilter(Amount, '>%1', 0); + ApplyingGLEntry.FindFirst(); + + // [GIVEN] The G/L entry with work date and the lowest negative amount has been found + AppliedGLEntry[1].SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry[1].SetRange("Posting Date", CalcDate('', ApplyingGLEntry."Posting Date")); + AppliedGLEntry[1].SetFilter(Amount, '<%1', 0); + AppliedGLEntry[1].FindLast(); + ListOfGLEntryNo.Add(AppliedGLEntry[1]."Entry No."); + + // [GIVEN] The G/L entry with work date and the second lowest negative amount has been found + AppliedGLEntry[2].SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry[2].SetRange("Posting Date", CalcDate('', ApplyingGLEntry."Posting Date")); + AppliedGLEntry[2].SetFilter(Amount, '<%1&>%2', 0, AppliedGLEntry[1].Amount); + AppliedGLEntry[2].FindLast(); + ListOfGLEntryNo.Add(AppliedGLEntry[2]."Entry No."); + + // [WHEN] Start the applying of the G/L entries + ApplyGLEntryFromGLEntry(ApplyingGLEntry, ListOfGLEntryNo); + + // [THEN] The applying G/L entry will be fully applied + ApplyingGLEntry.Find('='); + VerifyGLEntry(ApplyingGLEntry, 0, ApplyingGLEntry.Amount, AppliedGLEntry[1]."Posting Date"); + end; + + [Test] + [HandlerFunctions('ModalApplyGLEntriesHandlerMultiple,ModalPostApplicationHandler,MessageHandler')] + procedure ApplyingNegativeGLEntryToMultiplePositiveGLEntries() + var + ApplyingGLEntry: Record "G/L Entry"; + AppliedGLEntry: array[2] of Record "G/L Entry"; + ListOfGLEntryNo: List of [Integer]; + begin + // [SCENARIO] Applying negative G/L entry to multiple positive G/L entries + Initialize(); + + // [GIVEN] The general journal lines with more than 10 lines have been posted + PostGenJournalLines(); + + // [GIVEN] The G/L entry with work date and the lowest negative amount has been found + ApplyingGLEntry.SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + ApplyingGLEntry.SetRange("Posting Date", WorkDate()); + ApplyingGLEntry.SetFilter(Amount, '<%1', 0); + ApplyingGLEntry.FindFirst(); + + // [GIVEN] The G/L entry with work date and the lowest negative amount has been found + AppliedGLEntry[1].SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry[1].SetRange("Posting Date", CalcDate('', ApplyingGLEntry."Posting Date")); + AppliedGLEntry[1].SetFilter(Amount, '>%1', 0); + AppliedGLEntry[1].FindLast(); + ListOfGLEntryNo.Add(AppliedGLEntry[1]."Entry No."); + + // [GIVEN] The G/L entry with work date and the second owest negative amount has been found + AppliedGLEntry[2].SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry[2].SetRange("Posting Date", CalcDate('', ApplyingGLEntry."Posting Date")); + AppliedGLEntry[2].SetFilter(Amount, '>%1&<%2', 0, AppliedGLEntry[1].Amount); + AppliedGLEntry[2].FindLast(); + ListOfGLEntryNo.Add(AppliedGLEntry[2]."Entry No."); + + // [WHEN] Start the applying of the G/L entries + ApplyGLEntryFromGLEntry(ApplyingGLEntry, ListOfGLEntryNo); + + // [THEN] The applying G/L entry will be fully applied + ApplyingGLEntry.Find('='); + VerifyGLEntry(ApplyingGLEntry, 0, ApplyingGLEntry.Amount, AppliedGLEntry[1]."Posting Date"); + end; + + [Test] + [HandlerFunctions('ModalApplyGLEntriesHandlerSingle,ModalPostApplicationHandler,MessageHandler')] + procedure DoubleApplyingGLEntriesWithPositiveBalance() + var + ApplyingGLEntry: Record "G/L Entry"; + AppliedGLEntry: array[2] of Record "G/L Entry"; + begin + // [SCENARIO] Double applying G/L Entries with positive balance + Initialize(); + + // [GIVEN] The general journal lines with more than 10 lines have been posted + PostGenJournalLines(); + + // [GIVEN] The G/L entry with work date and the highest positive amount has been found + ApplyingGLEntry.SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + ApplyingGLEntry.SetRange("Posting Date", WorkDate()); + ApplyingGLEntry.SetFilter(Amount, '>%1', 0); + ApplyingGLEntry.FindLast(); + + // [GIVEN] The G/L entry with work date and the abs value of amount less than applying amount has been found + AppliedGLEntry[1].SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry[1].SetRange("Posting Date", ApplyingGLEntry."Posting Date"); + AppliedGLEntry[1].SetFilter(Amount, '<%1', 0); + AppliedGLEntry[1].FindFirst(); + + // [GIVEN] Applying of the G/L entries has been started + ApplyGLEntryFromGLEntry(ApplyingGLEntry, AppliedGLEntry[1]); + + // [GIVEN] The G/L entry with work date and the abs value of amount less than applying amount has been found + AppliedGLEntry[2].SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry[2].SetRange("Posting Date", ApplyingGLEntry."Posting Date"); + AppliedGLEntry[2].SetFilter(Amount, '<%1&<%2', 0, AppliedGLEntry[1].Amount); + AppliedGLEntry[2].FindFirst(); + + // [WHEN] Start applying of the G/L entries + ApplyGLEntryFromGLEntry(ApplyingGLEntry, AppliedGLEntry[2]); + + // [THEN] The applying G/L entry will be partly applied + ApplyingGLEntry.Find('='); + VerifyGLEntry(ApplyingGLEntry, + Abs(ApplyingGLEntry.Amount) - Abs(AppliedGLEntry[1].Amount) - Abs(AppliedGLEntry[2].Amount), + -(AppliedGLEntry[1].Amount + AppliedGLEntry[2].Amount), ApplyingGLEntry."Posting Date"); + end; + + [Test] + [HandlerFunctions('ModalApplyGLEntriesHandlerSingle,ModalPostApplicationHandler,MessageHandler')] + procedure DoubleApplyingGLEntriesWithNegativeBalance() + var + ApplyingGLEntry: Record "G/L Entry"; + AppliedGLEntry: array[2] of Record "G/L Entry"; + begin + // [SCENARIO] Double applying G/L Entries with negative balance + Initialize(); + + // [GIVEN] The general journal lines with more than 10 lines have been posted + PostGenJournalLines(); + + // [GIVEN] The G/L entry with work date and the lowest negative amount has been found + ApplyingGLEntry.SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + ApplyingGLEntry.SetRange("Posting Date", WorkDate()); + ApplyingGLEntry.SetFilter(Amount, '<%1', 0); + ApplyingGLEntry.FindLast(); + + // [GIVEN] The G/L entry with work date and the abs value of amount less than applying amount has been found + AppliedGLEntry[1].SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry[1].SetRange("Posting Date", ApplyingGLEntry."Posting Date"); + AppliedGLEntry[1].SetFilter(Amount, '>%1', 0); + AppliedGLEntry[1].FindFirst(); + + // [GIVEN] Applying of the G/L entries has been started + ApplyGLEntryFromGLEntry(ApplyingGLEntry, AppliedGLEntry[1]); + + // [GIVEN] The G/L entry with work date and the abs value of amount less than applying amount has been found + AppliedGLEntry[2].SetFilter("Entry No.", '>%1', GetFromGLEntryNo()); + AppliedGLEntry[2].SetRange("Posting Date", ApplyingGLEntry."Posting Date"); + AppliedGLEntry[2].SetFilter(Amount, '>%1&>%2', 0, AppliedGLEntry[1].Amount); + AppliedGLEntry[2].FindFirst(); + + // [WHEN] Start applying of the G/L entries + ApplyGLEntryFromGLEntry(ApplyingGLEntry, AppliedGLEntry[2]); + + // [THEN] The applying G/L entry will be partly applied + ApplyingGLEntry.Find('='); + VerifyGLEntry(ApplyingGLEntry, + -(Abs(ApplyingGLEntry.Amount) - Abs(AppliedGLEntry[1].Amount) - Abs(AppliedGLEntry[2].Amount)), + -(AppliedGLEntry[1].Amount + AppliedGLEntry[2].Amount), ApplyingGLEntry."Posting Date"); + end; + + local procedure PostGenJournalLines() + begin + PostGenJournalLines(WorkDate(), CalcDate('', WorkDate()), + LibraryRandom.RandDec(100, 2), LibraryRandom.RandIntInRange(10, 15)); + end; + + local procedure PostGenJournalLines(StartPostingDate: Date; EndPostingDate: Date; StartAmount: Decimal; LinesCount: Integer) + var + GenJournalBatch: Record "Gen. Journal Batch"; + GenJournalLine: Record "Gen. Journal Line"; + GLAccountNo: Code[20]; + Amount: Decimal; + PostingDate: Date; + i: Integer; + begin + SelectGenJournalBatch(GenJournalBatch); + LibraryERM.ClearGenJournalLines(GenJournalBatch); + GLAccountNo := LibraryERM.CreateGLAccountNo(); + + for PostingDate := StartPostingDate to EndPostingDate do begin + i := 0; + Amount := StartAmount; + WorkDate := PostingDate; + for i := 1 to LinesCount do begin + LibraryERM.CreateGeneralJnlLineWithBalAcc( + GenJournalLine, GenJournalBatch."Journal Template Name", GenJournalBatch.Name, GenJournalLine."Document Type"::" ", + GenJournalLine."Account Type"::"G/L Account", GLAccountNo, + GenJournalLine."Account Type"::"G/L Account", GLAccountNo, + Amount); + Amount += StartAmount; + end; + end; + + LibraryERM.PostGeneralJnlLine(GenJournalLine); + WorkDate := StartPostingDate; + end; + + local procedure InitFromGLEntryNo() + begin + FromGLEntryNo := 0; + FromGLEntryNo := GetFromGLEntryNo(); + end; + + local procedure GetFromGLEntryNo(): Integer + begin + if FromGLEntryNo = 0 then + FromGLEntryNo := GetLastGLEntryNo() + 1; + exit(FromGLEntryNo); + end; + + local procedure GetLastGLEntryNo(): Integer + var + GLEntry: Record "G/L Entry"; + begin + GLEntry.FindLast(); + exit(GLEntry."Entry No."); + end; + + local procedure VerifyGLEntry(GLEntry: Record "G/L Entry") + begin + VerifyGLEntry(GLEntry, WorkDate()); + end; + + local procedure VerifyGLEntry(GLEntry: Record "G/L Entry"; PostingDate: Date) + begin + VerifyGLEntry(GLEntry, 0, GLEntry.Amount, PostingDate); + end; + + local procedure VerifyGLEntry(GLEntry: Record "G/L Entry"; ExpectedRemainingAmount: Decimal; ExpectedAppliedAmount: Decimal; PostingDate: Date) + var + DetailedGLEntryCZA: Record "Detailed G/L Entry CZA"; + begin + GLEntry.CalcFields("Applied Amount CZA"); + Assert.AreEqual(ExpectedRemainingAmount, GLEntry.RemainingAmountCZA(), 'Unexpected Remaining Amount.'); + Assert.AreEqual(ExpectedAppliedAmount, GLEntry."Applied Amount CZA", 'Unexpected Applied Amount.'); + DetailedGLEntryCZA.SetRange("G/L Entry No.", GLEntry."Entry No."); + DetailedGLEntryCZA.FindFirst(); + Assert.AreEqual(PostingDate, DetailedGLEntryCZA."Posting Date", 'Unexpected Posting Date.'); + end; local procedure ApplyGenJournalLine(var GenJournalLine: Record "Gen. Journal Line") begin @@ -222,14 +835,30 @@ codeunit 148081 "Applying G/L Entries CZA" local procedure SelectGenJournalBatch(var GenJournalBatch: Record "Gen. Journal Batch") begin LibraryERM.SelectGenJnlBatch(GenJournalBatch); - LibraryERM.ClearGenJournalLines(GenJournalBatch) + LibraryERM.ClearGenJournalLines(GenJournalBatch); end; - local procedure ApplyGLEntryFromGLEntry(var GLEntry: Record "G/L Entry") + local procedure ApplyGLEntryFromGLEntry(var AppplyingGLEntry: Record "G/L Entry") var - GLENtryPostApplicationCZA: Codeunit "G/L Entry Post Application CZA"; + GLEntryPostApplicationCZA: Codeunit "G/L Entry Post Application CZA"; begin - GLENtryPostApplicationCZA.ApplyGLEntry(GLEntry); + GLEntryPostApplicationCZA.ApplyGLEntry(AppplyingGLEntry); + end; + + local procedure ApplyGLEntryFromGLEntry(var AppplyingGLEntry: Record "G/L Entry"; var AppliedGLEntry: Record "G/L Entry") + var + GLEntryPostApplicationCZA: Codeunit "G/L Entry Post Application CZA"; + begin + LibraryVariableStorage.Enqueue(AppliedGLEntry); + GLEntryPostApplicationCZA.ApplyGLEntry(AppplyingGLEntry); + end; + + local procedure ApplyGLEntryFromGLEntry(var AppplyingGLEntry: Record "G/L Entry"; AppliedGLEntryNoList: List of [Integer]) + var + GLEntryPostApplicationCZA: Codeunit "G/L Entry Post Application CZA"; + begin + LibraryVariableStorage.Enqueue(AppliedGLEntryNoList); + GLEntryPostApplicationCZA.ApplyGLEntry(AppplyingGLEntry); end; local procedure ApplyGLEntries() @@ -258,6 +887,39 @@ codeunit 148081 "Applying G/L Entries CZA" ApplyGenLedgerEntriesCZA.OK().Invoke(); end; + [ModalPageHandler] + procedure ModalApplyGLEntriesHandlerSingle(var ApplyGenLedgerEntriesCZA: TestPage "Apply Gen. Ledger Entries CZA") + var + GLEntry: Record "G/L Entry"; + FieldVariant: Variant; + begin + LibraryVariableStorage.Dequeue(FieldVariant); + GLEntry := FieldVariant; + ApplyGenLedgerEntriesCZA.Filter.SetFilter("Entry No.", Format(GLEntry."Entry No.")); + ApplyGenLedgerEntriesCZA.First(); + ApplyGenLedgerEntriesCZA."Set Applies-to ID".Invoke(); + ApplyGenLedgerEntriesCZA."Post Application".Invoke(); + ApplyGenLedgerEntriesCZA.OK().Invoke(); + end; + + [ModalPageHandler] + procedure ModalApplyGLEntriesHandlerMultiple(var ApplyGenLedgerEntriesCZA: TestPage "Apply Gen. Ledger Entries CZA") + var + ListOfGLEntryNo: List of [Integer]; + GLEntryNo: Integer; + FieldVariant: Variant; + begin + LibraryVariableStorage.Dequeue(FieldVariant); + ListOfGLEntryNo := FieldVariant; + foreach GLEntryNo in ListOfGLEntryNo do begin + ApplyGenLedgerEntriesCZA.Filter.SetFilter("Entry No.", Format(GLEntryNo)); + ApplyGenLedgerEntriesCZA.First(); + ApplyGenLedgerEntriesCZA."Set Applies-to ID".Invoke(); + end; + ApplyGenLedgerEntriesCZA."Post Application".Invoke(); + ApplyGenLedgerEntriesCZA.OK().Invoke(); + end; + [ModalPageHandler] procedure ModalPostApplicationHandler(var PostApplication: TestPage "Post Application") begin diff --git a/Apps/CZ/ContosoCoffeeDemoDatasetCZ/app/Codeunits/CreateCZGLAccounts.Codeunit.al b/Apps/CZ/ContosoCoffeeDemoDatasetCZ/app/Codeunits/CreateCZGLAccounts.Codeunit.al index 0e3746d60f..9ff75b2e06 100644 --- a/Apps/CZ/ContosoCoffeeDemoDatasetCZ/app/Codeunits/CreateCZGLAccounts.Codeunit.al +++ b/Apps/CZ/ContosoCoffeeDemoDatasetCZ/app/Codeunits/CreateCZGLAccounts.Codeunit.al @@ -293,4 +293,10 @@ codeunit 31212 "Create CZ GL Accounts" ContosoGLAccount.AddAccountForLocalization(JobGLAccount.JobCostsAppliedName(), '581100'); ContosoGLAccount.AddAccountForLocalization(JobGLAccount.RecognizedCostsName(), '581100'); end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Contoso GL Account", 'OnBeforeValidateGLAccountCategory', '', false, false)] + local procedure SkipAccountCategoryValidation(var GLAccount: Record "G/L Account"; var Category: Enum "G/L Account Category"; var SubCategory: Text[80]) + begin + Category := Enum::"G/L Account Category"::" "; + end; } \ No newline at end of file diff --git a/Apps/CZ/ContosoCoffeeDemoDatasetCZ/app/Demo Data/Finance/2. Master Data/CreateVATPeriodCZ.Codeunit.al b/Apps/CZ/ContosoCoffeeDemoDatasetCZ/app/Demo Data/Finance/2. Master Data/CreateVATPeriodCZ.Codeunit.al new file mode 100644 index 0000000000..d46914653a --- /dev/null +++ b/Apps/CZ/ContosoCoffeeDemoDatasetCZ/app/Demo Data/Finance/2. Master Data/CreateVATPeriodCZ.Codeunit.al @@ -0,0 +1,28 @@ +codeunit 31214 "Create VAT Period CZ" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "VAT Period CZL" = ri; + + trigger OnRun() + var + ContosoUtilities: Codeunit "Contoso Utilities"; + begin + InsertData(ContosoUtilities.AdjustDate(19010101D), ContosoUtilities.AdjustDate(19040101D)); + end; + + procedure InsertData(StartingDate: Date; EndingDate: Date) + var + VATPeriodCZL: Record "VAT Period CZL"; + begin + while StartingDate <= EndingDate do begin + VATPeriodCZL.Init(); + VATPeriodCZL.Validate("Starting Date", StartingDate); + if (Date2DMY(StartingDate, 1) = 1) and (Date2DMY(StartingDate, 2) = 1) then + VATPeriodCZL."New VAT Year" := true; + VATPeriodCZL.Insert(); + StartingDate := CalcDate('<1M>', StartingDate); + end; + end; +} + diff --git a/Apps/CZ/ContosoCoffeeDemoDatasetCZ/app/Demo Tool/ContosoCZLocalization.Codeunit.al b/Apps/CZ/ContosoCoffeeDemoDatasetCZ/app/Demo Tool/ContosoCZLocalization.Codeunit.al new file mode 100644 index 0000000000..de55207425 --- /dev/null +++ b/Apps/CZ/ContosoCoffeeDemoDatasetCZ/app/Demo Tool/ContosoCZLocalization.Codeunit.al @@ -0,0 +1,30 @@ +codeunit 31215 "Contoso CZ Localization" +{ + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Contoso Demo Tool", 'OnAfterGeneratingDemoData', '', false, false)] + local procedure OnAfterGeneratingDemoData(Module: Enum "Contoso Demo Data Module"; ContosoDemoDataLevel: Enum "Contoso Demo Data Level") + begin + case Module of + Enum::"Contoso Demo Data Module"::Finance: + FinanceModule(ContosoDemoDataLevel); + end; + end; + + local procedure FinanceModule(ContosoDemoDataLevel: Enum "Contoso Demo Data Level") + var + GLSetup: Record "General Ledger Setup"; + begin + case ContosoDemoDataLevel of + Enum::"Contoso Demo Data Level"::"Setup Data": + begin + GLSetup.Get(); + GLSetup."VAT Reporting Date Usage" := GLSetup."VAT Reporting Date Usage"::Disabled; + GLSetup.Modify(); + end; + Enum::"Contoso Demo Data Level"::"Master Data": + Codeunit.Run(Codeunit::"Create VAT Period CZ"); + end; + end; +} \ No newline at end of file diff --git a/Apps/CZ/ContosoCoffeeDemoDatasetCZ/app/app.json b/Apps/CZ/ContosoCoffeeDemoDatasetCZ/app/app.json index 15b11c9aec..ace1ac40d4 100644 --- a/Apps/CZ/ContosoCoffeeDemoDatasetCZ/app/app.json +++ b/Apps/CZ/ContosoCoffeeDemoDatasetCZ/app/app.json @@ -23,6 +23,12 @@ "name": "Fixed Asset Localization for Czech", "publisher": "Microsoft", "version": "26.0.0.0" + }, + { + "id": "267b59d3-7302-44c5-ba77-c87000380514", + "name": "Core Localization Pack for Czech", + "publisher": "Microsoft", + "version": "26.0.0.0" } ], "screenshots": [], diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/ExchRateAdjmtMgtCZL.Codeunit.al b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/ExchRateAdjmtMgtCZL.Codeunit.al new file mode 100644 index 0000000000..f9ca637565 --- /dev/null +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/ExchRateAdjmtMgtCZL.Codeunit.al @@ -0,0 +1,45 @@ +namespace Microsoft.Finance.Currency; + +using Microsoft.Finance.GeneralLedger.Journal; +using Microsoft.Finance.GeneralLedger.Setup; +using Microsoft.Finance.ReceivablesPayables; + +codeunit 31167 "Exch. Rate Adjmt. Mgt. CZL" +{ + procedure AdjustRemainingAmountLCY(var NewCVLedgEntryBuf: Record "CV Ledger Entry Buffer"; var DtldCVLedgEntryBuf: Record "Detailed CV Ledg. Entry Buffer"; GenJournalLine: Record "Gen. Journal Line") + var + GeneralLedgerSetup: Record "General Ledger Setup"; + AdjustedAmountLCY: Decimal; + IsHandled: Boolean; + begin + OnBeforeAdjustRemainingAmountLCY(NewCVLedgEntryBuf, DtldCVLedgEntryBuf, GenJournalLine, IsHandled); + if IsHandled then + exit; + + if NewCVLedgEntryBuf."Currency Code" = '' then + exit; + + GeneralLedgerSetup.Get(); + if GeneralLedgerSetup."Pmt. Disc. Excl. VAT" or not GeneralLedgerSetup."Adjust for Payment Disc." then + exit; + + AdjustedAmountLCY := Round(NewCVLedgEntryBuf."Remaining Amount" / NewCVLedgEntryBuf."Adjusted Currency Factor"); + + if AdjustedAmountLCY = NewCVLedgEntryBuf."Remaining Amt. (LCY)" then + exit; + + if (AdjustedAmountLCY - NewCVLedgEntryBuf."Remaining Amt. (LCY)") < 0 then + DtldCVLedgEntryBuf.InitDetailedCVLedgEntryBuf( + GenJournalLine, NewCVLedgEntryBuf, DtldCVLedgEntryBuf, + DtldCVLedgEntryBuf."Entry Type"::"Realized Loss", 0, AdjustedAmountLCY - NewCVLedgEntryBuf."Remaining Amt. (LCY)", 0, 0, 0, 0) + else + DtldCVLedgEntryBuf.InitDetailedCVLedgEntryBuf( + GenJournalLine, NewCVLedgEntryBuf, DtldCVLedgEntryBuf, + DtldCVLedgEntryBuf."Entry Type"::"Realized Gain", 0, AdjustedAmountLCY - NewCVLedgEntryBuf."Remaining Amt. (LCY)", 0, 0, 0, 0); + end; + + [IntegrationEvent(false, false)] + local procedure OnBeforeAdjustRemainingAmountLCY(var NewCVLedgEntryBuf: Record "CV Ledger Entry Buffer"; var DtldCVLedgEntryBuf: Record "Detailed CV Ledg. Entry Buffer"; GenJnlLine: Record "Gen. Journal Line"; var IsHandled: Boolean) + begin + end; +} diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/GenJnlPostLineHandlerCZL.Codeunit.al b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/GenJnlPostLineHandlerCZL.Codeunit.al index bc983b2b3e..84d626183d 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/GenJnlPostLineHandlerCZL.Codeunit.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/GenJnlPostLineHandlerCZL.Codeunit.al @@ -4,10 +4,10 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.Finance.GeneralLedger.Posting; +using Microsoft.Finance.Currency; using Microsoft.Finance.Deferral; using Microsoft.Finance.GeneralLedger.Journal; using Microsoft.Finance.GeneralLedger.Ledger; -using Microsoft.Finance.GeneralLedger.Setup; using Microsoft.Finance.ReceivablesPayables; using Microsoft.Finance.VAT.Calculation; using Microsoft.Finance.VAT.Ledger; @@ -79,6 +79,8 @@ codeunit 31315 "Gen.Jnl. Post Line Handler CZL" [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnCalcPmtDiscOnAfterAssignPmtDisc', '', false, false)] local procedure SavePmtDiscOnCalcPmtDiscOnAfterAssignPmtDisc(var OldCVLedgEntryBuf2: Record "CV Ledger Entry Buffer"; var PmtDisc: Decimal; var PmtDiscLCY: Decimal) begin + if OldCVLedgEntryBuf2."Currency Code" = '' then + exit; OldCVLedgEntryBuf2."Orig. Pmt. Disc. CZL" := PmtDisc; OldCVLedgEntryBuf2."Orig. Pmt. Disc. (LCY) CZL" := PmtDiscLCY; end; @@ -131,29 +133,9 @@ codeunit 31315 "Gen.Jnl. Post Line Handler CZL" [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnAfterPostApply', '', false, false)] local procedure CalcRemAmtLCYAdjustmentOnAfterPostApply(GenJnlLine: Record "Gen. Journal Line"; var DtldCVLedgEntryBuf: Record "Detailed CV Ledg. Entry Buffer"; var NewCVLedgEntryBuf: Record "CV Ledger Entry Buffer") var - GeneralLedgerSetup: Record "General Ledger Setup"; - AdjustedAmountLCY: Decimal; + ExchRateAdjmtMgtCZL: Codeunit "Exch. Rate Adjmt. Mgt. CZL"; begin - if NewCVLedgEntryBuf."Currency Code" = '' then - exit; - GeneralLedgerSetup.Get(); - if GeneralLedgerSetup."Pmt. Disc. Excl. VAT" or not GeneralLedgerSetup."Adjust for Payment Disc." then - exit; - - AdjustedAmountLCY := - Round(NewCVLedgEntryBuf."Remaining Amount" / NewCVLedgEntryBuf."Adjusted Currency Factor"); - - if AdjustedAmountLCY = NewCVLedgEntryBuf."Remaining Amt. (LCY)" then - exit; - - if (AdjustedAmountLCY - NewCVLedgEntryBuf."Remaining Amt. (LCY)") < 0 then - DtldCVLedgEntryBuf.InitDetailedCVLedgEntryBuf( - GenJnlLine, NewCVLedgEntryBuf, DtldCVLedgEntryBuf, - DtldCVLedgEntryBuf."Entry Type"::"Realized Loss", 0, AdjustedAmountLCY - NewCVLedgEntryBuf."Remaining Amt. (LCY)", 0, 0, 0, 0) - else - DtldCVLedgEntryBuf.InitDetailedCVLedgEntryBuf( - GenJnlLine, NewCVLedgEntryBuf, DtldCVLedgEntryBuf, - DtldCVLedgEntryBuf."Entry Type"::"Realized Gain", 0, AdjustedAmountLCY - NewCVLedgEntryBuf."Remaining Amt. (LCY)", 0, 0, 0, 0); + ExchRateAdjmtMgtCZL.AdjustRemainingAmountLCY(NewCVLedgEntryBuf, DtldCVLedgEntryBuf, GenJnlLine); end; local procedure IsAdjustPmtDiscFactorEnabled(CVLedgEntryBuf: Record "CV Ledger Entry Buffer"): Boolean diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/VATLCYCorrectionPostCZL.Codeunit.al b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/VATLCYCorrectionPostCZL.Codeunit.al index 125e636259..08055cf565 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/VATLCYCorrectionPostCZL.Codeunit.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/VATLCYCorrectionPostCZL.Codeunit.al @@ -137,6 +137,7 @@ codeunit 31013 "VAT LCY Correction-Post CZL" GenJournalLine."VAT Registration No." := VATLCYCorrectionBufferCZL."VAT Registration No."; GenJournalLine."Registration No. CZL" := VATLCYCorrectionBufferCZL."Registration No."; GenJournalLine."Tax Registration No. CZL" := VATLCYCorrectionBufferCZL."Tax Registration No."; + GenJournalLine."Dimension Set ID" := VATLCYCorrectionBufferCZL."Dimension Set ID"; if VATPosting then begin GenJournalLine."VAT Base Amount" := 0; diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/VATLCYCorrectionCZL.Page.al b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/VATLCYCorrectionCZL.Page.al index f1cd25d737..7372a81bc9 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/VATLCYCorrectionCZL.Page.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/VATLCYCorrectionCZL.Page.al @@ -283,6 +283,7 @@ page 31025 "VAT LCY Correction CZL" SourceCodeSetup: Record "Source Code Setup"; DocumentNo: Code[20]; PostingDate: Date; + DimensionSetID: Integer; TransactionNo: Integer; CorrectedVATAmountEditable: Boolean; TotalVATBase: Decimal; @@ -300,7 +301,7 @@ page 31025 "VAT LCY Correction CZL" DocRecordRef: RecordRef; IsHandled: Boolean; begin - SetDocumentGlobals('', 0D, 0); + SetDocumentGlobals('', 0D, 0, 0); DocRecordRef.GetTable(Variant); case DocRecordRef.Number of Database::"Purch. Inv. Header": @@ -310,7 +311,8 @@ page 31025 "VAT LCY Correction CZL" Error(NotAllowedCorrectErr, PurchInvHeader.TableCaption(), PurchInvHeader."No."); SetDocumentGlobals(PurchInvHeader."No.", PurchInvHeader."Posting Date", - VendorLedgerEntry.GetTransactionNoCZL(PurchInvHeader."Vendor Ledger Entry No.")); + VendorLedgerEntry.GetTransactionNoCZL(PurchInvHeader."Vendor Ledger Entry No."), + PurchInvHeader."Dimension Set ID"); end; Database::"Purch. Cr. Memo Hdr.": begin @@ -319,7 +321,8 @@ page 31025 "VAT LCY Correction CZL" Error(NotAllowedCorrectErr, PurchCrMemoHdr.TableCaption(), PurchCrMemoHdr."No."); SetDocumentGlobals(PurchCrMemoHdr."No.", PurchCrMemoHdr."Posting Date", - VendorLedgerEntry.GetTransactionNoCZL(PurchCrMemoHdr."Vendor Ledger Entry No.")); + VendorLedgerEntry.GetTransactionNoCZL(PurchCrMemoHdr."Vendor Ledger Entry No."), + PurchCrMemoHdr."Dimension Set ID"); end; else begin IsHandled := false; @@ -328,11 +331,12 @@ page 31025 "VAT LCY Correction CZL" end; end; - local procedure SetDocumentGlobals(NewDocumentNo: Code[20]; NewPostingDate: Date; NewTransactionNo: Integer) + local procedure SetDocumentGlobals(NewDocumentNo: Code[20]; NewPostingDate: Date; NewTransactionNo: Integer; NewDimensionSetID: Integer) begin DocumentNo := NewDocumentNo; PostingDate := NewPostingDate; TransactionNo := NewTransactionNo; + DimensionSetID := NewDimensionSetID; end; local procedure GetDocumentVATEntries() @@ -347,6 +351,8 @@ page 31025 "VAT LCY Correction CZL" if VATEntry.FindSet() then repeat Rec.InsertFromVATEntry(VATEntry); + Rec."Dimension Set ID" := DimensionSetID; + Rec.Modify(); until VATEntry.Next() = 0; VATEntry.Reset(); @@ -357,6 +363,8 @@ page 31025 "VAT LCY Correction CZL" if VATEntry.FindSet() then repeat Rec.InsertFromVATEntry(VATEntry); + Rec."Dimension Set ID" := DimensionSetID; + Rec.Modify(); until VATEntry.Next() = 0; end; diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Permissions/CZCorePackObjectsCZL.PermissionSet.al b/Apps/CZ/CoreLocalizationPack/app/Src/Permissions/CZCorePackObjectsCZL.PermissionSet.al index f3a4e774d1..1d9f1ad536 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Permissions/CZCorePackObjectsCZL.PermissionSet.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Permissions/CZCorePackObjectsCZL.PermissionSet.al @@ -37,6 +37,7 @@ codeunit "EET Xml Sign. Provider CZL" = X, codeunit "Employee Handler CZL" = X, codeunit "EPO API Submission CZL" = X, + codeunit "Exch. Rate Adjmt. Mgt. CZL" = X, codeunit "FA Jnl. Check Line Handler CZL" = X, codeunit "FA Recl. Jnl. Line Handler CZL" = X, codeunit "Fin. Charge Memo Handler CZL" = X, diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Reports/AccountingSheetsCZL.Report.al b/Apps/CZ/CoreLocalizationPack/app/Src/Reports/AccountingSheetsCZL.Report.al index 17b2c1f995..58f6e76148 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Reports/AccountingSheetsCZL.Report.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Reports/AccountingSheetsCZL.Report.al @@ -647,7 +647,6 @@ report 11703 "Accounting Sheets CZL" var CompanyInformation: Record "Company Information"; UserSetup: Record "User Setup"; - TempGLEntry: Record "G/L Entry" temporary; GLEntry: Record "G/L Entry"; LastDocNo: Code[20]; FCYRate: Decimal; @@ -658,6 +657,7 @@ report 11703 "Accounting Sheets CZL" DescriptionTxt: Label 'Description'; protected var + TempGLEntry: Record "G/L Entry" temporary; LastDataItem: Integer; GeneralDocExists: Boolean; GroupGLAccounts: Boolean; diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Reports/AdjustExchangeRatesCZL.Report.al b/Apps/CZ/CoreLocalizationPack/app/Src/Reports/AdjustExchangeRatesCZL.Report.al index 83ccb153a8..72945f43a8 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Reports/AdjustExchangeRatesCZL.Report.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Reports/AdjustExchangeRatesCZL.Report.al @@ -3112,10 +3112,10 @@ report 31004 "Adjust Exchange Rates CZL" TwoDetailedEmployeeLedgerEntry."Entry Type"::"Realized Gain"); TwoDetailedEmployeeLedgerEntry.CalcSums("Amount (LCY)"); - Temp2DetailedCustLedgEntry.SetRange("Posting Date", EntryPostingDate); - Temp2DetailedCustLedgEntry.CalcSums("Amount (LCY)"); + Temp2DetailedEmployeeLedgerEntry.SetRange("Posting Date", EntryPostingDate); + Temp2DetailedEmployeeLedgerEntry.CalcSums("Amount (LCY)"); - RealGainLossAmt := TwoDetailedCustLedgEntry."Amount (LCY)" + Temp2DetailedCustLedgEntry."Amount (LCY)"; + RealGainLossAmt := TwoDetailedEmployeeLedgerEntry."Amount (LCY)" + Temp2DetailedEmployeeLedgerEntry."Amount (LCY)"; end; procedure GetInitialGLAccountNo(InitialEntryNo: Integer; SourceType: Option Customer,Vendor,Employee; PostingGroup: Code[20]): Code[20] diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Tables/VATLCYCorrectionBufferCZL.Table.al b/Apps/CZ/CoreLocalizationPack/app/Src/Tables/VATLCYCorrectionBufferCZL.Table.al index 840a9b0a5c..005fdd427c 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Tables/VATLCYCorrectionBufferCZL.Table.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Tables/VATLCYCorrectionBufferCZL.Table.al @@ -4,6 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.Finance.VAT.Calculation; +using Microsoft.Finance.Dimension; using Microsoft.Finance.GeneralLedger.Journal; using Microsoft.Finance.GeneralLedger.Setup; using Microsoft.Finance.VAT.Ledger; @@ -17,63 +18,55 @@ using Microsoft.Sales.Customer; table 11727 "VAT LCY Correction Buffer CZL" { Caption = 'VAT LCY Correction Buffer'; + DataClassification = SystemMetadata; fields { field(1; "Entry No."; Integer) { Caption = 'Entry No.'; - DataClassification = SystemMetadata; Editable = false; } field(4; "Posting Date"; Date) { Caption = 'Posting Date'; - DataClassification = SystemMetadata; Editable = false; } field(5; "Document No."; Code[20]) { Caption = 'Document No.'; - DataClassification = SystemMetadata; Editable = false; } field(6; "Document Type"; Enum "Gen. Journal Document Type") { Caption = 'Document Type'; - DataClassification = SystemMetadata; Editable = false; } field(7; Type; Enum "General Posting Type") { Caption = 'Type'; - DataClassification = SystemMetadata; Editable = false; } field(8; "VAT Base"; Decimal) { AutoFormatType = 1; Caption = 'VAT Base'; - DataClassification = SystemMetadata; Editable = false; } field(9; "VAT Amount"; Decimal) { AutoFormatType = 1; Caption = 'VAT Amount'; - DataClassification = SystemMetadata; Editable = false; } field(11; "VAT Date"; Date) { Caption = 'VAT Date'; - DataClassification = SystemMetadata; Editable = false; } field(12; "Bill-to/Pay-to No."; Code[20]) { Caption = 'Bill-to/Pay-to No.'; - DataClassification = SystemMetadata; Editable = false; TableRelation = if (Type = const(Purchase)) Vendor else if (Type = const(Sale)) Customer; @@ -81,28 +74,24 @@ table 11727 "VAT LCY Correction Buffer CZL" field(15; "Source Code"; Code[10]) { Caption = 'Source Code'; - DataClassification = SystemMetadata; Editable = false; TableRelation = "Source Code"; } field(19; "Country/Region Code"; Code[10]) { Caption = 'Country/Region Code'; - DataClassification = SystemMetadata; Editable = false; TableRelation = "Country/Region"; } field(39; "VAT Bus. Posting Group"; Code[20]) { Caption = 'VAT Bus. Posting Group'; - DataClassification = SystemMetadata; Editable = false; TableRelation = "VAT Business Posting Group"; } field(40; "VAT Prod. Posting Group"; Code[20]) { Caption = 'VAT Prod. Posting Group'; - DataClassification = SystemMetadata; Editable = false; TableRelation = "VAT Product Posting Group"; } @@ -110,7 +99,6 @@ table 11727 "VAT LCY Correction Buffer CZL" { Caption = 'VAT %'; DecimalPlaces = 0 : 5; - DataClassification = SystemMetadata; Editable = false; MaxValue = 100; MinValue = 0; @@ -119,14 +107,12 @@ table 11727 "VAT LCY Correction Buffer CZL" { AutoFormatType = 1; Caption = 'VAT Correction Amount'; - DataClassification = SystemMetadata; Editable = false; } field(55; "Corrected VAT Amount"; Decimal) { AutoFormatType = 1; Caption = 'Corrected VAT Amount'; - DataClassification = SystemMetadata; trigger OnValidate() begin @@ -137,25 +123,27 @@ table 11727 "VAT LCY Correction Buffer CZL" { Caption = 'VAT LCY Correction'; Editable = false; - DataClassification = SystemMetadata; } field(65; "VAT Registration No."; Text[20]) { Caption = 'VAT Registration No.'; Editable = false; - DataClassification = SystemMetadata; + } + field(480; "Dimension Set ID"; Integer) + { + Caption = 'Dimension Set ID'; + Editable = false; + TableRelation = "Dimension Set Entry"; } field(11781; "Registration No."; Text[20]) { Caption = 'Registration No.'; Editable = false; - DataClassification = SystemMetadata; } field(11782; "Tax Registration No."; Text[20]) { Caption = 'Tax Registration No.'; Editable = false; - DataClassification = SystemMetadata; } } diff --git a/Apps/CZ/IntrastatCZ/app/src/Codeunits/IntrastatReportManagementCZ.Codeunit.al b/Apps/CZ/IntrastatCZ/app/src/Codeunits/IntrastatReportManagementCZ.Codeunit.al index 37bf19b6e6..a3bef670eb 100644 --- a/Apps/CZ/IntrastatCZ/app/src/Codeunits/IntrastatReportManagementCZ.Codeunit.al +++ b/Apps/CZ/IntrastatCZ/app/src/Codeunits/IntrastatReportManagementCZ.Codeunit.al @@ -54,7 +54,7 @@ codeunit 31302 IntrastatReportManagementCZ IntrastatReportSetup."Data Exch. Def. Code - Receipt" := DefaultDataExchDefCodeLbl; IntrastatReportSetup."Data Exch. Def. Code - Shpt." := DefaultDataExchDefCodeLbl; IntrastatReportSetup."Shipments Based On" := IntrastatReportSetup."Shipments Based On"::"Ship-to Country"; - IntrastatReportSetup."VAT No. Based On" := IntrastatReportSetup."VAT No. Based On"::"Sell-to VAT"; + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::Document; IntrastatReportSetup."Def. Private Person VAT No." := DefPrivatePersonVATNoLbl; IntrastatReportSetup."Def. 3-Party Trade VAT No." := Def3DPartyTradeVATNoLbl; IntrastatReportSetup."Def. VAT for Unknown State" := DefUnknowVATNoLbl; @@ -1146,26 +1146,33 @@ codeunit 31302 IntrastatReportManagementCZ #region Helper functions internal procedure GetCustomerBasedOnSetup(SellTo: Code[20]; BillTo: Code[20]) Customer: Record Customer + var + IntrastatReportSetup: Record "Intrastat Report Setup"; + PartnerNo: Code[20]; begin - Customer.Get(GetPartnerNoBasedOnSetup(SellTo, BillTo)); - end; - - internal procedure GetVendorBasedOnSetup(SellTo: Code[20]; BillTo: Code[20]) Vendor: Record Vendor - begin - Vendor.Get(GetPartnerNoBasedOnSetup(SellTo, BillTo)); + IntrastatReportSetup.Get(); + case IntrastatReportSetup."Sales Intrastat Info Based On" of + IntrastatReportSetup."Sales Intrastat Info Based On"::"Sell-to Customer": + PartnerNo := SellTo; + IntrastatReportSetup."Sales Intrastat Info Based On"::"Bill-to Customer": + PartnerNo := BillTo; + end; + Customer.Get(PartnerNo); end; - internal procedure GetPartnerNoBasedOnSetup(SellTo: Code[20]; BillTo: Code[20]) PartnerNo: Code[20] + internal procedure GetVendorBasedOnSetup(BuyFrom: Code[20]; PayTo: Code[20]) Vendor: Record Vendor var IntrastatReportSetup: Record "Intrastat Report Setup"; + PartnerNo: Code[20]; begin IntrastatReportSetup.Get(); - case IntrastatReportSetup."VAT No. Based On" of - IntrastatReportSetup."VAT No. Based On"::"Sell-to VAT": - PartnerNo := SellTo; - IntrastatReportSetup."VAT No. Based On"::"Bill-to VAT": - PartnerNo := BillTo; + case IntrastatReportSetup."Purch. Intrastat Info Based On" of + IntrastatReportSetup."Purch. Intrastat Info Based On"::"Buy-from Vendor": + PartnerNo := BuyFrom; + IntrastatReportSetup."Purch. Intrastat Info Based On"::"Pay-to Vendor": + PartnerNo := PayTo; end; + Vendor.Get(PartnerNo); end; internal procedure GetDefaultTransactionType(ServiceHeader: Record "Service Header"): Code[10] diff --git a/Apps/CZ/IntrastatCZ/test/Src/IntrastatCZTest.Codeunit.al b/Apps/CZ/IntrastatCZ/test/Src/IntrastatCZTest.Codeunit.al index 4ad60b8b95..847ad80413 100644 --- a/Apps/CZ/IntrastatCZ/test/Src/IntrastatCZTest.Codeunit.al +++ b/Apps/CZ/IntrastatCZ/test/Src/IntrastatCZTest.Codeunit.al @@ -17,6 +17,7 @@ codeunit 148125 "Intrastat CZ Test" LibraryERM: Codeunit "Library - ERM"; LibraryPurchase: Codeunit "Library - Purchase"; LibrarySales: Codeunit "Library - Sales"; + LibraryService: Codeunit "Library - Service"; LibraryUtility: Codeunit "Library - Utility"; LibraryPatterns: Codeunit "Library - Patterns"; LibraryVariableStorage: Codeunit "Library - Variable Storage"; @@ -1900,42 +1901,75 @@ codeunit 148125 "Intrastat CZ Test" BillToCustomer: Record Customer; SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line"; - IntrastatReportHeader: Record "Intrastat Report Header"; SalesInvoiceHeader: Record "Sales Invoice Header"; - DocumentNo: Code[20]; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + DocumentVATNo: Code[20]; IntrastatReportNo: Code[20]; begin - // [FEATURE] [Sales] [Shipment] - // [SCENARIO 422720] Partner VAT ID is taken as VAT Registration No from Sell-to Customer No. of Sales Invoice + // [FEATURE] [Sales] [Invoice] + // [SCENARIO 422720] Partner VAT ID of Sales Invoice is taken according to Intrastat Setup Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Shipment; + IntrastatReportSetup.Modify(); - // [GIVEN] G/L Setup "Bill-to/Sell-to VAT Calc." = "Bill-to/Pay-to No." // [GIVEN] Shipment on Sales Invoice = false LibraryCZIntrastat.UpdateShipmentOnInvoiceSalesSetup(false); - // [GIVEN] Sell-to Customer with VAT Registration No = 'AT0123456' - // [GIVEN] Bill-to Customer with VAT Registration No = 'DE1234567' - // [GIVEN] Sales Invoice with different Sell-to and Bill-To customers + // [GIVEN] Sell-to Customer with VAT Registration No = 1 + // [GIVEN] Bill-to Customer with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Sales Invoice with different Sell-to and Bill-To customers, and different VAT Registration No SellToCustomer.Get(LibraryCZIntrastat.CreateCustomerWithVATRegNo(true)); BillToCustomer.Get(LibraryCZIntrastat.CreateCustomerWithVATRegNo(true)); - LibraryCZIntrastat.CreateSalesDocument( - SalesHeader, SalesLine, SellToCustomer."No.", WorkDate(), SalesLine."Document Type"::Invoice, - SalesLine.Type::Item, LibraryCZIntrastat.CreateItem(), 1); + LibraryCZIntrastat.CreateSalesDocument(SalesHeader, SalesLine, SellToCustomer."No.", WorkDate(), SalesLine."Document Type"::Invoice, SalesLine.Type::Item, LibraryCZIntrastat.CreateItem(), 1); SalesHeader.Validate("Bill-to Customer No.", BillToCustomer."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(SellToCustomer."Country/Region Code"); + SalesHeader.Validate("VAT Registration No.", DocumentVATNo); SalesHeader.Modify(true); // [GIVEN] Post the invoice - DocumentNo := LibrarySales.PostSalesDocument(SalesHeader, true, true); + LibrarySales.PostSalesDocument(SalesHeader, true, true); + + // Sell-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Sell-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + // Bill-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Bill-to VAT"; + IntrastatReportSetup.Modify(); // [WHEN] Suggest Intrastat Report Lines CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", BillToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); - // [THEN] Posted Sales Invoice has VAT Registration No. = 'DE1234567' - // [THEN] Partner VAT ID = 'AT0123456' in Intrastat Report Line - SalesInvoiceHeader.Get(DocumentNo); - SalesInvoiceHeader.TestField("VAT Registration No.", BillToCustomer."VAT Registration No."); + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + + // Delete all posted sales invoices + SalesInvoiceHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); end; [Test] @@ -1947,71 +1981,915 @@ codeunit 148125 "Intrastat CZ Test" BillToCustomer: Record Customer; SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line"; - IntrastatReportHeader: Record "Intrastat Report Header"; SalesShipmentHeader: Record "Sales Shipment Header"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; IntrastatReportNo: Code[20]; + DocumentVATNo: Code[20]; begin // [FEATURE] [Sales] [Shipment] - // [SCENARIO 422720] Partner VAT ID is taken as VAT Registration No from Sell-to Customer No. of Sales Shipment + // [SCENARIO 422720] Partner VAT ID of Sales Shipment is taken according to Intrastat Setup Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Shipment; + IntrastatReportSetup.Modify(); - // [GIVEN] G/L Setup "Bill-to/Sell-to VAT Calc." = "Bill-to/Pay-to No." // [GIVEN] Shipment on Sales Invoice = true LibraryCZIntrastat.UpdateShipmentOnInvoiceSalesSetup(true); - // [GIVEN] Sell-to Customer with VAT Registration No = 'AT0123456' - // [GIVEN] Bill-to Customer with VAT Registration No = 'DE1234567' - // [GIVEN] Sales Invoice with different Sell-to and Bill-To customers + // [GIVEN] Sell-to Customer with VAT Registration No = 1 + // [GIVEN] Bill-to Customer with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Sales Invoice with different Sell-to and Bill-To customers and different VAT Registration No SellToCustomer.Get(LibraryCZIntrastat.CreateCustomerWithVATRegNo(true)); BillToCustomer.Get(LibraryCZIntrastat.CreateCustomerWithVATRegNo(true)); - LibraryCZIntrastat.CreateSalesDocument( - SalesHeader, SalesLine, SellToCustomer."No.", WorkDate(), SalesLine."Document Type"::Invoice, - SalesLine.Type::Item, LibraryCZIntrastat.CreateItem(), 1); + LibraryCZIntrastat.CreateSalesDocument(SalesHeader, SalesLine, SellToCustomer."No.", WorkDate(), SalesLine."Document Type"::Invoice, SalesLine.Type::Item, LibraryCZIntrastat.CreateItem(), 1); SalesHeader.Validate("Bill-to Customer No.", BillToCustomer."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(SellToCustomer."Country/Region Code"); + SalesHeader.Validate("VAT Registration No.", DocumentVATNo); SalesHeader.Modify(true); // [GIVEN] Post the invoice LibrarySales.PostSalesDocument(SalesHeader, true, true); + // Sell-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Sell-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Bill-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Bill-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", BillToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); // [WHEN] Suggest Intrastat Report Lines CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); - // [THEN] Posted Sales Shipment has VAT Registration No. = 'DE1234567' - // [THEN] Partner VAT ID = 'AT0123456' in Intrastat Report Line - SalesShipmentHeader.SetRange("Bill-to Customer No.", BillToCustomer."No."); - SalesShipmentHeader.FindFirst(); - SalesShipmentHeader.TestField("VAT Registration No.", BillToCustomer."VAT Registration No."); + // Delete all posted sales shipments + SalesShipmentHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); end; [Test] [Scope('OnPrem')] - [HandlerFunctions('IntrastatReportGetLinesPageHandler')] + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfSalesCrMemo() + var + SellToCustomer: Record Customer; + BillToCustomer: Record Customer; + SalesHeader: Record "Sales Header"; + SalesLine: Record "Sales Line"; + SalesCrMemoHeader: Record "Sales Cr.Memo Header"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + DocumentVATNo: Code[20]; + IntrastatReportNo: Code[20]; + begin + // [FEATURE] [Sales] [Cr.. Memo] + // [SCENARIO 422720] Partner VAT ID of Sales Cr. Memo is taken according to Intrastat Setup + Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Both; + IntrastatReportSetup.Modify(); + + // [GIVEN] Return Receipt on Cr. Memo = false + LibraryCZIntrastat.UpdateRetReceiptOnCrMemoSalesSetup(false); + + // [GIVEN] Sell-to Customer with VAT Registration No = 1 + // [GIVEN] Bill-to Customer with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Sales Cr. Memo with different Sell-to and Bill-To customers, and different VAT Registration No + SellToCustomer.Get(LibraryCZIntrastat.CreateCustomerWithVATRegNo(true)); + BillToCustomer.Get(LibraryCZIntrastat.CreateCustomerWithVATRegNo(true)); + LibraryCZIntrastat.CreateSalesDocument(SalesHeader, SalesLine, SellToCustomer."No.", WorkDate(), SalesLine."Document Type"::"Credit Memo", SalesLine.Type::Item, LibraryCZIntrastat.CreateItem(), 1); + SalesHeader.Validate("Bill-to Customer No.", BillToCustomer."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(SellToCustomer."Country/Region Code"); + SalesHeader.Validate("VAT Registration No.", DocumentVATNo); + SalesHeader.Modify(true); + + // [GIVEN] Post the Cr. Memo + LibrarySales.PostSalesDocument(SalesHeader, true, true); + + // Sell-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Sell-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Bill-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Bill-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", BillToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + + // Delete all posted sales credit memos + SalesCrMemoHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + end; + + [Test] + [Scope('OnPrem')] + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfSalesReturnReceipt() + var + SellToCustomer: Record Customer; + BillToCustomer: Record Customer; + SalesHeader: Record "Sales Header"; + SalesLine: Record "Sales Line"; + ReturnReceiptHeader: Record "Return Receipt Header"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + IntrastatReportNo: Code[20]; + DocumentVATNo: Code[20]; + begin + // [FEATURE] [Sales] [Return Receipt] + // [SCENARIO 422720] Partner VAT ID of Sales Return Receipt is taken according to Intrastat Setup + Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Both; + IntrastatReportSetup.Modify(); + + // [GIVEN] Return Receipt on Cr. Memo = false + LibraryCZIntrastat.UpdateRetReceiptOnCrMemoSalesSetup(true); + + // [GIVEN] Sell-to Customer with VAT Registration No = 1 + // [GIVEN] Bill-to Customer with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Sales Return Receipt with different Sell-to and Bill-To customers and different VAT Registration No + SellToCustomer.Get(LibraryCZIntrastat.CreateCustomerWithVATRegNo(true)); + BillToCustomer.Get(LibraryCZIntrastat.CreateCustomerWithVATRegNo(true)); + LibraryCZIntrastat.CreateSalesDocument(SalesHeader, SalesLine, SellToCustomer."No.", WorkDate(), SalesLine."Document Type"::"Credit Memo", SalesLine.Type::Item, LibraryCZIntrastat.CreateItem(), 1); + SalesHeader.Validate("Bill-to Customer No.", BillToCustomer."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(SellToCustomer."Country/Region Code"); + SalesHeader.Validate("VAT Registration No.", DocumentVATNo); + SalesHeader.Modify(true); + + // [GIVEN] Post the Cr. Memo + LibrarySales.PostSalesDocument(SalesHeader, true, true); + + // Sell-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Sell-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Bill-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Bill-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", BillToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + + // Delete all posted sales return receipts + ReturnReceiptHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + end; + + [Test] + [Scope('OnPrem')] + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfServiceInvoice() + var + SellToCustomer: Record Customer; + BillToCustomer: Record Customer; + ServiceHeader: Record "Service Header"; + ServiceLine: Record "Service Line"; + ServiceInvoiceHeader: Record "Service Invoice Header"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + DocumentVATNo: Code[20]; + IntrastatReportNo: Code[20]; + begin + // [FEATURE] [Service] [Invoice] + // [SCENARIO 422720] Partner VAT ID of Service Invoice is taken according to Intrastat Setup + Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Shipment; + IntrastatReportSetup.Modify(); + + // [GIVEN] Shipment on Service Invoice = false + LibraryCZIntrastat.UpdateShipmentOnInvoiceServiceSetup(false); + + // [GIVEN] Sell-to Customer with VAT Registration No = 1 + // [GIVEN] Bill-to Customer with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Service Invoice with different Sell-to and Bill-To customers, and different VAT Registration No + SellToCustomer.Get(LibraryCZIntrastat.CreateCustomerWithVATRegNo(true)); + BillToCustomer.Get(LibraryCZIntrastat.CreateCustomerWithVATRegNo(true)); + LibraryCZIntrastat.CreateServiceDocument(ServiceHeader, ServiceLine, SellToCustomer."No.", WorkDate(), ServiceLine."Document Type"::Invoice, ServiceLine.Type::Item, LibraryCZIntrastat.CreateItem(), 1); + ServiceHeader.Validate("Bill-to Customer No.", BillToCustomer."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(SellToCustomer."Country/Region Code"); + ServiceHeader.Validate("VAT Registration No.", DocumentVATNo); + ServiceHeader.Modify(true); + + // [GIVEN] Post the invoice + LibraryService.PostServiceOrder(ServiceHeader, false, false, false); + + // Sell-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Sell-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Bill-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Bill-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", BillToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + + // Delete all posted service invoices + ServiceInvoiceHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + end; + + [Test] + [Scope('OnPrem')] + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfServiceShipment() + var + SellToCustomer: Record Customer; + BillToCustomer: Record Customer; + ServiceHeader: Record "Service Header"; + ServiceLine: Record "Service Line"; + ServiceShipmentHeader: Record "Service Shipment Header"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + DocumentVATNo: Code[20]; + IntrastatReportNo: Code[20]; + begin + // [FEATURE] [Service] [Shipment] + // [SCENARIO 422720] Partner VAT ID of Service Shipment is taken according to Intrastat Setup + Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Shipment; + IntrastatReportSetup.Modify(); + + // [GIVEN] Shipment on Service Invoice = true + LibraryCZIntrastat.UpdateShipmentOnInvoiceServiceSetup(true); + + // [GIVEN] Sell-to Customer with VAT Registration No = 1 + // [GIVEN] Bill-to Customer with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Service Shipment with different Sell-to and Bill-To customers, and different VAT Registration No + SellToCustomer.Get(LibraryCZIntrastat.CreateCustomerWithVATRegNo(true)); + BillToCustomer.Get(LibraryCZIntrastat.CreateCustomerWithVATRegNo(true)); + LibraryCZIntrastat.CreateServiceDocument(ServiceHeader, ServiceLine, SellToCustomer."No.", WorkDate(), ServiceLine."Document Type"::Invoice, ServiceLine.Type::Item, LibraryCZIntrastat.CreateItem(), 1); + ServiceHeader.Validate("Bill-to Customer No.", BillToCustomer."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(SellToCustomer."Country/Region Code"); + ServiceHeader.Validate("VAT Registration No.", DocumentVATNo); + ServiceHeader.Modify(true); + + // [GIVEN] Post the invoice + LibraryService.PostServiceOrder(ServiceHeader, false, false, false); + + // Sell-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Sell-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Bill-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Bill-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", BillToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + + // Delete all posted service shipments + ServiceShipmentHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + end; + + [Test] + [Scope('OnPrem')] + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfServiceCrMemo() + var + SellToCustomer: Record Customer; + BillToCustomer: Record Customer; + ServiceHeader: Record "Service Header"; + ServiceLine: Record "Service Line"; + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + DocumentVATNo: Code[20]; + IntrastatReportNo: Code[20]; + begin + // [FEATURE] [Service] [Cr. Memo] + // [SCENARIO 422720] Partner VAT ID of Service Cr. Memo is taken according to Intrastat Setup + Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Both; + IntrastatReportSetup.Modify(); + + // [GIVEN] Sell-to Customer with VAT Registration No = 1 + // [GIVEN] Bill-to Customer with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Service Cr. Memo with different Sell-to and Bill-To customers, and different VAT Registration No + SellToCustomer.Get(LibraryCZIntrastat.CreateCustomerWithVATRegNo(true)); + BillToCustomer.Get(LibraryCZIntrastat.CreateCustomerWithVATRegNo(true)); + LibraryCZIntrastat.CreateServiceDocument(ServiceHeader, ServiceLine, SellToCustomer."No.", WorkDate(), ServiceLine."Document Type"::"Credit Memo", ServiceLine.Type::Item, LibraryCZIntrastat.CreateItem(), 1); + ServiceHeader.Validate("Bill-to Customer No.", BillToCustomer."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(SellToCustomer."Country/Region Code"); + ServiceHeader.Validate("VAT Registration No.", DocumentVATNo); + ServiceHeader.Modify(true); + + // [GIVEN] Post the cr. memo + LibraryService.PostServiceOrder(ServiceHeader, false, false, false); + + // Sell-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Sell-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Bill-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Bill-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", BillToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + + // Delete all posted service credit memos + ServiceCrMemoHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + end; + + [Test] + [Scope('OnPrem')] + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfPurchaseInvoice() + var + PurchaseHeader: Record "Purchase Header"; + PurchaseLine: Record "Purchase Line"; + PurchInvHeader: Record "Purch. Inv. Header"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + BuyFromVendor, PayToVendor : Record Vendor; + IntrastatReportNo: Code[20]; + DocumentVATNo: Code[20]; + begin + // [FEATURE] [Purchase] [Invoice] + // [SCENARIO 422720] Partner VAT ID of Purchase Invoice is taken according to Intrastat Setup + Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Receipt; + IntrastatReportSetup.Modify(); + + // [GIVEN] Receipt on Invoice = false + LibraryCZIntrastat.UpdateReceiptOnInvoicePurchSetup(false); + + // [GIVEN] Buy-from Vendor with VAT Registration No = 1 + // [GIVEN] Pay-to Vendor with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Purchase Invoice with different Buy-from and Pay-To vendors, and different VAT Registration No + BuyFromVendor.Get(LibraryCZIntrastat.CreateVendorWithVATRegNo(true)); + PayToVendor.Get(LibraryCZIntrastat.CreateVendorWithVATRegNo(true)); + LibraryCZIntrastat.CreatePurchaseHeader(PurchaseHeader, PurchaseHeader."Document Type"::Invoice, WorkDate(), BuyFromVendor."No."); + LibraryCZIntrastat.CreatePurchaseLine(PurchaseHeader, PurchaseLine, PurchaseLine.Type::Item, LibraryCZIntrastat.CreateItem()); + PurchaseHeader.Validate("Pay-to Vendor No.", PayToVendor."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(BuyFromVendor."Country/Region Code"); + PurchaseHeader.Validate("VAT Registration No.", DocumentVATNo); + PurchaseHeader.Modify(true); + + // [GIVEN] Post the invoice + LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true); + + // Buy-from VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Buy-from VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", BuyFromVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Pay-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Pay-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", PayToVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + + // Delete all posted purchase invoices + PurchInvHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", BuyFromVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + end; + + [Test] + [Scope('OnPrem')] + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] procedure GetPartnerIDFromVATRegNoOfPurchaseReceipt() var PurchaseHeader: Record "Purchase Header"; PurchaseLine: Record "Purchase Line"; + PurchRcptHeader: Record "Purch. Rcpt. Header"; IntrastatReportHeader: Record "Intrastat Report Header"; - VendorNo: Code[20]; + IntrastatReportSetup: Record "Intrastat Report Setup"; + BuyFromVendor, PayToVendor : Record Vendor; IntrastatReportNo: Code[20]; + DocumentVATNo: Code[20]; begin // [FEATURE] [Purchase] [Receipt] - // [SCENARIO 389253] Partner VAT ID is blank for Purchase Receipt + // [SCENARIO 422720] Partner VAT ID of Purchase Receipt is taken according to Intrastat Setup Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Receipt; + IntrastatReportSetup.Modify(); - // [GIVEN] Posted purchase order with Pay-to Vendor with VAT Registration No = 'AT0123456' - VendorNo := LibraryCZIntrastat.CreateVendorWithVATRegNo(true); - LibraryCZIntrastat.CreatePurchaseHeader(PurchaseHeader, PurchaseHeader."Document Type"::Order, WorkDate(), VendorNo); + // [GIVEN] Receipt on Invoice = true + LibraryCZIntrastat.UpdateReceiptOnInvoicePurchSetup(true); + + // [GIVEN] Buy-from Vendor with VAT Registration No = 1 + // [GIVEN] Pay-to Vendor with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Purchase Receipt with different Buy-from and Pay-To vendors, and different VAT Registration No + BuyFromVendor.Get(LibraryCZIntrastat.CreateVendorWithVATRegNo(true)); + PayToVendor.Get(LibraryCZIntrastat.CreateVendorWithVATRegNo(true)); + LibraryCZIntrastat.CreatePurchaseHeader(PurchaseHeader, PurchaseHeader."Document Type"::Invoice, WorkDate(), BuyFromVendor."No."); LibraryCZIntrastat.CreatePurchaseLine(PurchaseHeader, PurchaseLine, PurchaseLine.Type::Item, LibraryCZIntrastat.CreateItem()); + PurchaseHeader.Validate("Pay-to Vendor No.", PayToVendor."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(BuyFromVendor."Country/Region Code"); + PurchaseHeader.Validate("VAT Registration No.", DocumentVATNo); + PurchaseHeader.Modify(true); + + // [GIVEN] Post the invoice LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true); - // [WHEN] Intrastat Report Line is created + // Buy-from VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Buy-from VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", BuyFromVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); - // [THEN] Partner VAT ID = '' in Intrastat Report Line - VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", ''); + // Pay-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Pay-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", PayToVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + + // Delete all posted purchase receipts + PurchRcptHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", BuyFromVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + end; + + [Test] + [Scope('OnPrem')] + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfPurchaseCrMemo() + var + PurchaseHeader: Record "Purchase Header"; + PurchaseLine: Record "Purchase Line"; + PurchCrMemoHdr: Record "Purch. Cr. Memo Hdr."; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + BuyFromVendor, PayToVendor : record Vendor; + IntrastatReportNo: Code[20]; + DocumentVATNo: Code[20]; + begin + // [FEATURE] [Purchase] [Cr Memo] + // [SCENARIO 422720] Partner VAT ID of Purchase Cr Memo is taken according to Intrastat Setup + Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Both; + IntrastatReportSetup.Modify(); + + // [GIVEN] Return Shipment on Credit Memo = false + LibraryCZIntrastat.UpdateRetShpmtOnCrMemoPurchSetup(false); + + // [GIVEN] Buy-from Vendor with VAT Registration No = 1 + // [GIVEN] Pay-to Vendor with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Purchase Cr. Memo with different Buy-from and Pay-To vendors, and different VAT Registration No + BuyFromVendor.Get(LibraryCZIntrastat.CreateVendorWithVATRegNo(true)); + PayToVendor.Get(LibraryCZIntrastat.CreateVendorWithVATRegNo(true)); + LibraryCZIntrastat.CreatePurchaseHeader(PurchaseHeader, PurchaseHeader."Document Type"::"Credit Memo", WorkDate(), BuyFromVendor."No."); + LibraryCZIntrastat.CreatePurchaseLine(PurchaseHeader, PurchaseLine, PurchaseLine.Type::Item, LibraryCZIntrastat.CreateItem()); + PurchaseHeader.Validate("Pay-to Vendor No.", PayToVendor."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(BuyFromVendor."Country/Region Code"); + PurchaseHeader.Validate("VAT Registration No.", DocumentVATNo); + PurchaseHeader.Modify(true); + + // [GIVEN] Post the cr. memo + LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true); + + // Buy-from VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Buy-from VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", BuyFromVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Pay-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Pay-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", PayToVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + + // Delete all posted purchase credit memos + PurchCrMemoHdr.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", BuyFromVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + end; + + [Test] + [Scope('OnPrem')] + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfPurchaseRetShpmt() + var + PurchaseHeader: Record "Purchase Header"; + PurchaseLine: Record "Purchase Line"; + ReturnShipmentHeader: Record "Return Shipment Header"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + BuyFromVendor, PayToVendor : record Vendor; + IntrastatReportNo: Code[20]; + DocumentVATNo: Code[20]; + begin + // [FEATURE] [Purchase] [Return Shipment] + // [SCENARIO 422720] Partner VAT ID of Purchase Return Shipment is taken according to Intrastat Setup + Initialize(); + + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Both; + IntrastatReportSetup.Modify(); + + // [GIVEN] Return Shipment on Credit Memo = true + LibraryCZIntrastat.UpdateRetShpmtOnCrMemoPurchSetup(true); + + // [GIVEN] Buy-from Vendor with VAT Registration No = 1 + // [GIVEN] Pay-to Vendor with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Purchase Receipt with different Buy-from and Pay-To vendors, and different VAT Registration No + BuyFromVendor.Get(LibraryCZIntrastat.CreateVendorWithVATRegNo(true)); + PayToVendor.Get(LibraryCZIntrastat.CreateVendorWithVATRegNo(true)); + LibraryCZIntrastat.CreatePurchaseHeader(PurchaseHeader, PurchaseHeader."Document Type"::"Credit Memo", WorkDate(), BuyFromVendor."No."); + LibraryCZIntrastat.CreatePurchaseLine(PurchaseHeader, PurchaseLine, PurchaseLine.Type::Item, LibraryCZIntrastat.CreateItem()); + PurchaseHeader.Validate("Pay-to Vendor No.", PayToVendor."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(BuyFromVendor."Country/Region Code"); + PurchaseHeader.Validate("VAT Registration No.", DocumentVATNo); + PurchaseHeader.Modify(true); + + // [GIVEN] Post the cr. memo + LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true); + + // Buy-from VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Buy-from VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", BuyFromVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Pay-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Pay-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", PayToVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + + // Delete all posted purchase return shipments + ReturnShipmentHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", BuyFromVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + end; + + [Test] + [Scope('OnPrem')] + [HandlerFunctions('IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfTransferReceipt() + var + FromCountryRegion: Record "Country/Region"; + FromLocation, ToLocation, InTransitLocation : Record Location; + TransferHeader: Record "Transfer Header"; + TransferLine: Record "Transfer Line"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + ItemNo: Code[20]; + IntrastatReportNo: Code[20]; + DocumentVATNo: Code[20]; + WD: Date; + begin + // [SCENARIO 465378] Verify receipt transaction in Intrastat Journal when transferring items from EU country to company country + Initialize(); + + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Receipt; + IntrastatReportSetup.Modify(); + + // [GIVEN] Source Location and Country with Intrastat Code. Location: "L1". Country "C1" + LibraryWarehouse.CreateLocationWithInventoryPostingSetup(FromLocation); + LibraryCZIntrastat.CreateCountryRegion(FromCountryRegion, true); + FromLocation."Country/Region Code" := FromCountryRegion.Code; + FromLocation.Modify(); + + // [GIVEN] Item on inventory for L1 + WD := WorkDate(); + WorkDate(CalcDate('<-1M>', WD)); + ItemNo := LibraryCZIntrastat.CreateItem(); + LibraryCZIntrastat.CreateAndPostPurchaseItemJournalLine(FromLocation.Code, ItemNo); + WorkDate(WD); + + // [GIVEN] Detination Location and Country, set in Company Information, with Intrastat Code. Location: "L2". Country "C2" + LibraryWarehouse.CreateLocationWithInventoryPostingSetup(ToLocation); + ToLocation."Country/Region Code" := LibraryCZIntrastat.GetCompanyInfoCountryRegionCode(); + ToLocation.Modify(); + + LibraryWarehouse.CreateInTransitLocation(InTransitLocation); + + // [GIVEN] Create Transfer Order + LibraryWarehouse.CreateTransferHeader(TransferHeader, FromLocation.Code, ToLocation.Code, InTransitLocation.Code); + LibraryWarehouse.CreateTransferLine(TransferHeader, TransferLine, ItemNo, 1); + + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(FromLocation.Code); + TransferHeader.Validate("Partner VAT ID", DocumentVATNo); + TransferHeader.Modify(true); + + // [GIVEN] Post Transfer Order + LibraryWarehouse.PostTransferOrder(TransferHeader, true, true); + + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID is taken from transfer receipt header + VerifyPartnerID(IntrastatReportHeader, TransferLine."Item No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + end; + + [Test] + [Scope('OnPrem')] + [HandlerFunctions('IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfTransferShipment() + var + ToCountryRegion: Record "Country/Region"; + FromLocation, ToLocation, InTransitLocation : Record Location; + TransferHeader: Record "Transfer Header"; + TransferLine: Record "Transfer Line"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + ItemNo: Code[20]; + IntrastatReportNo: Code[20]; + DocumentVATNo: Code[20]; + WD: Date; + begin + // [SCENARIO 465378] Verify shipment transaction in Intrastat Journal when transferring items from company country to EU country + Initialize(); + + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Shipment; + IntrastatReportSetup.Modify(); + + // [GIVEN] Source Location and Country, set in Company Information, with Intrastat Code. Location: "L1". Country "C1" + LibraryWarehouse.CreateLocationWithInventoryPostingSetup(FromLocation); + FromLocation."Country/Region Code" := LibraryCZIntrastat.GetCompanyInfoCountryRegionCode(); + FromLocation.Modify(); + + // [GIVEN] Item on inventory for L1 + WD := WorkDate(); + WorkDate(CalcDate('<-1M>', WD)); + ItemNo := LibraryCZIntrastat.CreateItem(); + LibraryCZIntrastat.CreateAndPostPurchaseItemJournalLine(FromLocation.Code, ItemNo); + WorkDate(WD); + + // [GIVEN] Destination Location and Country with Intrastat Code. Location: "L2". Country "C2" + LibraryWarehouse.CreateLocationWithInventoryPostingSetup(ToLocation); + LibraryCZIntrastat.CreateCountryRegion(ToCountryRegion, true); + ToLocation."Country/Region Code" := ToCountryRegion.Code; + ToLocation.Modify(); + + LibraryWarehouse.CreateInTransitLocation(InTransitLocation); + + // [GIVEN] Create Transfer Order + LibraryWarehouse.CreateTransferHeader(TransferHeader, FromLocation.Code, ToLocation.Code, InTransitLocation.Code); + LibraryWarehouse.CreateTransferLine(TransferHeader, TransferLine, ItemNo, 1); + + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(FromLocation.Code); + TransferHeader.Validate("Partner VAT ID", DocumentVATNo); + TransferHeader.Modify(true); + + // [GIVEN] Post Transfer Order + LibraryWarehouse.PostTransferOrder(TransferHeader, true, true); + + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID is taken from transfer shipment header + VerifyPartnerID(IntrastatReportHeader, TransferLine."Item No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); end; [Test] diff --git a/Apps/CZ/IntrastatCZ/test/Src/LibraryCZIntrastat.Codeunit.al b/Apps/CZ/IntrastatCZ/test/Src/LibraryCZIntrastat.Codeunit.al index 08cade0602..909dd59161 100644 --- a/Apps/CZ/IntrastatCZ/test/Src/LibraryCZIntrastat.Codeunit.al +++ b/Apps/CZ/IntrastatCZ/test/Src/LibraryCZIntrastat.Codeunit.al @@ -14,6 +14,7 @@ codeunit 148126 "Library - CZ Intrastat" LibraryInventory: Codeunit "Library - Inventory"; LibraryFixedAsset: Codeunit "Library - Fixed Asset"; LibrarySales: Codeunit "Library - Sales"; + LibraryService: Codeunit "Library - Service"; LibraryRandom: Codeunit "Library - Random"; LibraryWarehouse: Codeunit "Library - Warehouse"; @@ -201,6 +202,28 @@ codeunit 148126 "Library - CZ Intrastat" SalesHeader.Modify(true); end; + procedure CreateServiceDocument(var ServiceHeader: Record "Service Header"; var ServiceLine: Record "Service Line"; CustomerNo: Code[20]; PostingDate: Date; DocumentType: Enum "Service Document Type"; Type: Enum "Service Line Type"; No: Code[20]; + NoOfLines: Integer) + var + i: Integer; + begin + // Create Service Order with Random Quantity and Unit Price. + CreateServiceHeader(ServiceHeader, CustomerNo, PostingDate, DocumentType); + for i := 1 to NoOfLines do begin + LibraryService.CreateServiceLine(ServiceLine, ServiceHeader, Type, No); + ServiceLine.Validate(Quantity, LibraryRandom.RandDec(100, 2)); + ServiceLine.Validate("Unit Price", LibraryRandom.RandDec(100, 2)); + ServiceLine.Modify(true); + end; + end; + + procedure CreateServiceHeader(var ServiceHeader: Record "Service Header"; CustomerNo: Code[20]; PostingDate: Date; DocumentType: Enum "Service Document Type") + begin + LibraryService.CreateServiceHeader(ServiceHeader, DocumentType, CustomerNo); + ServiceHeader.Validate("Posting Date", PostingDate); + ServiceHeader.Modify(true); + end; + procedure CreateAndPostSalesInvoiceWithItemAndItemCharge(PostingDate: Date): Code[20] var SalesHeader: Record "Sales Header"; @@ -426,6 +449,7 @@ codeunit 148126 "Library - CZ Intrastat" LibraryFixedAsset.CreateDepreciationBook(DepreciationBook); DepreciationBook.Validate("G/L Integration - Acq. Cost", true); DepreciationBook.Validate("G/L Integration - Disposal", true); + DepreciationBook.Validate("G/L Integration - Custom 2", true); DepreciationBook.Modify(true); LibraryFixedAsset.CreateFADepreciationBook(FADepreciationBook, No, DepreciationBook.Code); @@ -734,6 +758,42 @@ codeunit 148126 "Library - CZ Intrastat" SalesReceivablesSetup.Modify(true); end; + procedure UpdateRetReceiptOnCrMemoSalesSetup(RetReceiptOnCrMemo: Boolean) + var + SalesReceivablesSetup: Record "Sales & Receivables Setup"; + begin + SalesReceivablesSetup.Get(); + SalesReceivablesSetup.Validate("Return Receipt on Credit Memo", RetReceiptOnCrMemo); + SalesReceivablesSetup.Modify(true); + end; + + procedure UpdateShipmentOnInvoiceServiceSetup(ShipmentOnInvoice: Boolean) + var + ServiceMgtSetup: Record "Service Mgt. Setup"; + begin + ServiceMgtSetup.Get(); + ServiceMgtSetup.Validate("Shipment on Invoice", ShipmentOnInvoice); + ServiceMgtSetup.Modify(true); + end; + + procedure UpdateRetShpmtOnCrMemoPurchSetup(RetShpmtOnCrMemo: Boolean) + var + PurchasesPayablesSetup: Record "Purchases & Payables Setup"; + begin + PurchasesPayablesSetup.Get(); + PurchasesPayablesSetup.Validate("Return Shipment on Credit Memo", RetShpmtOnCrMemo); + PurchasesPayablesSetup.Modify(true); + end; + + procedure UpdateReceiptOnInvoicePurchSetup(ReceiptOnInvoice: Boolean) + var + PurchasesPayablesSetup: Record "Purchases & Payables Setup"; + begin + PurchasesPayablesSetup.Get(); + PurchasesPayablesSetup.Validate("Receipt on Invoice", ReceiptOnInvoice); + PurchasesPayablesSetup.Modify(true); + end; + procedure UpdateIntrastatCodeInCountryRegion() var CompanyInformation: Record "Company Information"; diff --git a/Apps/ES/EDocumentFormats/FacturaE/app/ExtensionLogo.png b/Apps/ES/EDocumentFormats/FacturaE/app/ExtensionLogo.png new file mode 100644 index 0000000000..4d2c9a626c Binary files /dev/null and b/Apps/ES/EDocumentFormats/FacturaE/app/ExtensionLogo.png differ diff --git a/Apps/ES/EDocumentFormats/FacturaE/app/app.json b/Apps/ES/EDocumentFormats/FacturaE/app/app.json new file mode 100644 index 0000000000..2b38665975 --- /dev/null +++ b/Apps/ES/EDocumentFormats/FacturaE/app/app.json @@ -0,0 +1,37 @@ +{ + "id": "8238f99b-cbe5-4b9c-b247-7771145b7470", + "name": "E-Document Format for Factura-E", + "publisher": "Microsoft", + "brief": "E-Document Format for Factura-E.", + "description": "E-Document Format for Factura-E is a customization for Spanish business requirements. This app supports Factura-E format for working with E-documents app.", + "version": "26.0.0.0", + "privacyStatement": "https://go.microsoft.com/fwlink/?LinkId=724009", + "EULA": "https://go.microsoft.com/fwlink/?linkid=2009120", + "help": "https://go.microsoft.com/fwlink/?linkid=2299409", + "url": "https://go.microsoft.com/fwlink/?LinkId=724011", + "contextSensitiveHelpUrl": "https://go.microsoft.com/fwlink/?linkid=2299409", + "logo": "ExtensionLogo.png", + "dependencies": [ + { + "id": "e1d97edc-c239-46b4-8d84-6368bdf67c8b", + "name": "E-Document Core", + "publisher": "Microsoft", + "version": "26.0.0.0" + } + ], + "features": ["TranslationFile"], + "screenshots": [], + "platform": "26.0.0.0", + "idRanges": [ + { + "from": 10772, + "to": 10776 + } + ], + "resourceExposurePolicy": { + "allowDebugging": true, + "allowDownloadingSource": true, + "includeSourceInSymbolFile": true + }, + "application": "26.0.0.0" +} \ No newline at end of file diff --git a/Apps/ES/EDocumentFormats/FacturaE/app/src/Core/EDocFacturaEFormat.EnumExt.al b/Apps/ES/EDocumentFormats/FacturaE/app/src/Core/EDocFacturaEFormat.EnumExt.al new file mode 100644 index 0000000000..b55ad5693d --- /dev/null +++ b/Apps/ES/EDocumentFormats/FacturaE/app/src/Core/EDocFacturaEFormat.EnumExt.al @@ -0,0 +1,15 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.eServices.EDocument.Format; + +using Microsoft.eServices.EDocument; + +enumextension 10772 "E-Doc. Factura-E Format" extends "E-Document Format" +{ + value(10772; "Factura-E 3.2.2") + { + Implementation = "E-Document" = "Factura-E"; + } +} \ No newline at end of file diff --git a/Apps/ES/EDocumentFormats/FacturaE/app/src/Core/FacturaE.Codeunit.al b/Apps/ES/EDocumentFormats/FacturaE/app/src/Core/FacturaE.Codeunit.al new file mode 100644 index 0000000000..dc0815c3fe --- /dev/null +++ b/Apps/ES/EDocumentFormats/FacturaE/app/src/Core/FacturaE.Codeunit.al @@ -0,0 +1,79 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.eServices.EDocument.Format; + +using Microsoft.eServices.EDocument; +using Microsoft.Purchases.Document; +using Microsoft.Sales.History; +using System.Utilities; + +codeunit 10772 "Factura-E" implements "E-Document" +{ + InherentEntitlements = X; + InherentPermissions = X; + + var + FacturaEImport: Codeunit "Factura-E Import"; + FacturaEExport: Codeunit "Factura-E Export"; + + procedure Check(var SourceDocumentHeader: RecordRef; EDocumentService: Record "E-Document Service"; EDocumentProcessingPhase: Enum "E-Document Processing Phase") + var + SalesCrMemoHeader: Record "Sales Cr.Memo Header"; + begin + case SourceDocumentHeader.Number of + Database::"Sales Cr.Memo Header": + begin + SourceDocumentHeader.SetTable(SalesCrMemoHeader); + SalesCrMemoHeader.SetRecFilter(); + SalesCrMemoHeader.TestField("Factura-E Reason Code"); + end; + end; + end; + + procedure Create(EDocumentService: Record "E-Document Service"; var EDocument: Record "E-Document"; var SourceDocumentHeader: RecordRef; var SourceDocumentLines: RecordRef; var TempBlob: Codeunit "Temp Blob") + begin + FacturaEExport.Export(SourceDocumentHeader, SourceDocumentLines, TempBlob, false); + end; + + procedure CreateBatch(EDocumentService: Record "E-Document Service"; var EDocuments: Record "E-Document"; var SourceDocumentHeaders: RecordRef; var SourceDocumentsLines: RecordRef; var TempBlob: Codeunit "Temp Blob") + begin + FacturaEExport.Export(SourceDocumentHeaders, SourceDocumentsLines, TempBlob, true); + end; + + procedure GetBasicInfoFromReceivedDocument(var EDocument: Record "E-Document"; var TempBlob: Codeunit "Temp Blob") + begin + FacturaEImport.ParseBasicInfo(EDocument, TempBlob); + end; + + procedure GetCompleteInfoFromReceivedDocument(var EDocument: Record "E-Document"; var CreatedDocumentHeader: RecordRef; var CreatedDocumentLines: RecordRef; var TempBlob: Codeunit "Temp Blob") + var + TempPurchaseHeader: Record "Purchase Header" temporary; + TempPurchaseLine: Record "Purchase Line" temporary; + begin + FacturaEImport.ParseCompleteInfo(EDocument, TempPurchaseHeader, TempPurchaseLine, TempBlob); + + CreatedDocumentHeader.GetTable(TempPurchaseHeader); + CreatedDocumentLines.GetTable(TempPurchaseLine); + end; + + [EventSubscriber(ObjectType::Table, Database::"E-Document Service", 'OnAfterValidateEvent', 'Document Format', false, false)] + local procedure OnAfterValidateDocumentFormat(var Rec: Record "E-Document Service"; var xRec: Record "E-Document Service"; CurrFieldNo: Integer) + var + EDocServiceSupportedType: Record "E-Doc. Service Supported Type"; + begin + if Rec."Document Format" = Rec."Document Format"::"Factura-E 3.2.2" then begin + EDocServiceSupportedType.SetRange("E-Document Service Code", Rec.Code); + if EDocServiceSupportedType.IsEmpty() then begin + EDocServiceSupportedType.Init(); + EDocServiceSupportedType."E-Document Service Code" := Rec.Code; + EDocServiceSupportedType."Source Document Type" := EDocServiceSupportedType."Source Document Type"::"Sales Invoice"; + EDocServiceSupportedType.Insert(); + + EDocServiceSupportedType."Source Document Type" := EDocServiceSupportedType."Source Document Type"::"Sales Credit Memo"; + EDocServiceSupportedType.Insert(); + end; + end; + end; +} \ No newline at end of file diff --git a/Apps/ES/EDocumentFormats/FacturaE/app/src/Core/FacturaEExport.Codeunit.al b/Apps/ES/EDocumentFormats/FacturaE/app/src/Core/FacturaEExport.Codeunit.al new file mode 100644 index 0000000000..bf9c533ca5 --- /dev/null +++ b/Apps/ES/EDocumentFormats/FacturaE/app/src/Core/FacturaEExport.Codeunit.al @@ -0,0 +1,799 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.eServices.EDocument.Format; + +using Microsoft.eServices.EDocument; +using Microsoft.Finance.Currency; +using Microsoft.Finance.GeneralLedger.Setup; +using Microsoft.Finance.VAT.Reporting; +using Microsoft.Foundation.Company; +using Microsoft.Foundation.Address; +using Microsoft.Foundation.Period; +using Microsoft.Foundation.UOM; +using Microsoft.Sales.Customer; +using Microsoft.Sales.History; +using System.Telemetry; +using System.Utilities; + +codeunit 10774 "Factura-E Export" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + var + CompanyInformation: Record "Company Information"; + GeneralLedgerSetup: Record "General Ledger Setup"; + FeatureTelemetry: Codeunit "Feature Telemetry"; + FeatureNameTok: Label 'EDocument Format Factura-E', Locked = true; + StartEventNameTok: Label 'Export initiated. IsBatch is: %1', Locked = true; + EndEventNameTok: Label 'Export completed', Locked = true; + + procedure Export(var SourceDocumentHeader: RecordRef; var SourceDocumentLines: RecordRef; var TempBlob: Codeunit "Temp Blob"; IsBatch: Boolean) + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + SalesCrMemoHeader: Record "Sales Cr.Memo Header"; + SalesInvoiceLine: Record "Sales Invoice Line"; + SalesCrMemoLine: Record "Sales Cr.Memo Line"; + begin + OnBeforeExport(SourceDocumentHeader, SourceDocumentLines, TempBlob, IsBatch); + FeatureTelemetry.LogUsage('0000OCR', FeatureNameTok, StrSubstNo(StartEventNameTok, Format(IsBatch))); + CompanyInformation.Get(); + GeneralLedgerSetup.Get(); + + case SourceDocumentHeader.Number of + Database::"Sales Invoice Header": + begin + SourceDocumentHeader.SetTable(SalesInvoiceHeader); + SalesInvoiceHeader.SetRecFilter(); + SourceDocumentLines.SetTable(SalesInvoiceLine); + ExportInvoice(SalesInvoiceHeader, SalesInvoiceLine, TempBlob, IsBatch); + end; + Database::"Sales Cr.Memo Header": + begin + SourceDocumentHeader.SetTable(SalesCrMemoHeader); + SalesCrMemoHeader.SetRecFilter(); + SourceDocumentLines.SetTable(SalesCrMemoLine); + ExportCreditMemo(SalesCrMemoHeader, SalesCrMemoLine, TempBlob, IsBatch); + end; + end; + FeatureTelemetry.LogUsage('0000OCT', FeatureNameTok, EndEventNameTok); + OnAfterExport(SourceDocumentHeader, SourceDocumentLines, TempBlob, IsBatch); + end; + + local procedure ExportInvoice(var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesInvoiceLine: Record "Sales Invoice Line"; var TempBlob: Codeunit "Temp Blob"; IsBatch: Boolean) + var + RootXMLNode: XmlElement; + XMLDocOut: XmlDocument; + FileHeaderNode: XmlElement; + InvoicesNode: XmlElement; + PartiesNode: XmlElement; + FileOutStream: OutStream; + FileHeaderData, SellerData, BuyerData : Dictionary of [Text, Text]; + FileHeaderTotals: Dictionary of [Text, Decimal]; + begin + TempBlob.CreateOutStream(FileOutStream); + + XmlDocument.ReadFrom(GetBasicXMLHeader(), XMLDocOut); + XMLDocOut.GetRoot(RootXMLNode); + + GatherSellerData(SellerData); + GatherBuyerData(BuyerData, SalesInvoiceHeader."Bill-to Customer No."); + InvoicesNode := CreateInvoicesNode(FileHeaderTotals, SalesInvoiceHeader, SalesInvoiceLine, IsBatch); + GatherFileHeaderData(FileHeaderData, SalesInvoiceHeader, FileHeaderTotals); + + PartiesNode := CreatePartiesNode(SellerData, BuyerData); + FileHeaderNode := CreateFileHeaderNode(FileHeaderData, FileHeaderTotals); + + RootXMLNode.Add(FileHeaderNode); + RootXMLNode.Add(PartiesNode); + RootXMLNode.Add(InvoicesNode); + + XmlDocOut.WriteTo(FileOutStream); + end; + + local procedure ExportCreditMemo(var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; var SalesCrMemoLine: Record "Sales Cr.Memo Line"; var TempBlob: Codeunit "Temp Blob"; IsBatch: Boolean) + var + RootXMLNode: XmlElement; + FileHeaderNode: XmlElement; + InvoicesNode: XmlElement; + PartiesNode: XmlElement; + XMLDocOut: XmlDocument; + FileOutStream: OutStream; + FileHeaderData, SellerData, BuyerData : Dictionary of [Text, Text]; + FileHeaderTotals: Dictionary of [Text, Decimal]; + begin + TempBlob.CreateOutStream(FileOutStream); + + XmlDocument.ReadFrom(GetBasicXMLHeader(), XMLDocOut); + XMLDocOut.GetRoot(RootXMLNode); + + GatherSellerData(SellerData); + GatherBuyerData(BuyerData, SalesCrMemoHeader."Bill-to Customer No."); + InvoicesNode := CreateInvoicesNode(FileHeaderTotals, SalesCrMemoHeader, SalesCrMemoLine, IsBatch); + GatherFileHeaderData(FileHeaderData, SalesCrMemoHeader, FileHeaderTotals); + PartiesNode := CreatePartiesNode(SellerData, BuyerData); + FileHeaderNode := CreateFileHeaderNode(FileHeaderData, FileHeaderTotals); + + RootXMLNode.Add(FileHeaderNode); + RootXMLNode.Add(PartiesNode); + RootXMLNode.Add(InvoicesNode); + + XmlDocOut.WriteTo(FileOutStream); + end; + + local procedure GatherFileHeaderData(var FileHeaderData: Dictionary of [Text, Text]; var SalesInvoiceHeader: Record "Sales Invoice Header"; var FileHeaderTotals: Dictionary of [Text, Decimal]) + var + Count: Integer; + begin + Count := FileHeaderTotals.Get('Count'); + FileHeaderData.Add('SchemaVersion', '3.2.2'); + if Count > 1 then + FileHeaderData.Add('Modality', 'L') + else + FileHeaderData.Add('Modality', 'I'); + FileHeaderData.Add('InvoiceIssuerType', 'EM'); + FileHeaderData.Add('BatchIdentifier', CopyStr(SalesInvoiceHeader."No.", 1, 70)); + FileHeaderData.Add('InvoicesCount', Format(Count)); + FileHeaderData.Add('InvoiceCurrencyCode', GetCurrencyISOCode(SalesInvoiceHeader."Currency Code")); + end; + + local procedure GatherFileHeaderData(var FileHeaderData: Dictionary of [Text, Text]; var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; var FileHeaderTotals: Dictionary of [Text, Decimal]) + var + Count: Integer; + begin + Count := FileHeaderTotals.Get('Count'); + FileHeaderData.Add('SchemaVersion', '3.2.2'); + if Count > 1 then + FileHeaderData.Add('Modality', 'L') + else + FileHeaderData.Add('Modality', 'I'); + FileHeaderData.Add('InvoiceIssuerType', 'EM'); + FileHeaderData.Add('BatchIdentifier', CopyStr(SalesCrMemoHeader."No.", 1, 70)); + FileHeaderData.Add('InvoicesCount', Format(Count)); + FileHeaderData.Add('InvoiceCurrencyCode', GetCurrencyISOCode(SalesCrMemoHeader."Currency Code")); + end; + + local procedure GatherSellerData(var SellerData: Dictionary of [Text, Text]) + var + CountrySymbol: Text[1]; + CountryISO: Text[3]; + begin + SellerData.Add('PersonTypeCode', 'J'); + CountryCodeToSymbolAndISO(CompanyInformation."Country/Region Code", CountrySymbol, CountryISO); + SellerData.Add('ResidenceTypeCode', CountrySymbol); + SellerData.Add('TaxIdentificationNumber', CopyStr(CompanyInformation."VAT Registration No.", 1, 30)); + SellerData.Add('CorporateName', CopyStr(CompanyInformation.Name + CompanyInformation."Name 2", 1, 80)); + SellerData.Add('Address', CopyStr(CompanyInformation.Address + CompanyInformation."Address 2", 1, 80)); + SellerData.Add('PostCode', CopyStr(CompanyInformation."Post Code", 1, 5)); + SellerData.Add('Town', CopyStr(CompanyInformation.City, 1, 50)); + SellerData.Add('Province', CopyStr(CompanyInformation.County, 1, 20)); + SellerData.Add('CountryCode', CopyStr(CountryISO, 1, 3)); + SellerData.Add('Telephone', CopyStr(CompanyInformation."Phone No.", 1, 15)); + SellerData.Add('ElectronicMail', CopyStr(CompanyInformation."E-Mail", 1, 60)); + end; + + local procedure GatherBuyerData(var BuyerData: Dictionary of [Text, Text]; BillToCustomerNo: Code[20]) + var + Customer: Record "Customer"; + CountrySymbol: Text[1]; + CountryISO: Text[3]; + begin + Customer.Get(BillToCustomerNo); + if Customer."Partner Type" = Customer."Partner Type"::Person then + BuyerData.Add('PersonTypeCode', 'F') + else + BuyerData.Add('PersonTypeCode', 'J'); + CountryCodeToSymbolAndISO(Customer."Country/Region Code", CountrySymbol, CountryISO); + BuyerData.Add('ResidenceTypeCode', CountrySymbol); + BuyerData.Add('TaxIdentificationNumber', CopyStr(Customer."VAT Registration No.", 1, 30)); + if Customer."Partner Type" = Customer."Partner Type"::Person then begin + BuyerData.Add('Name', CopyStr(Customer.Name, 1, 40)); + BuyerData.Add('FirstSurname', CopyStr(Customer."Name 2", 1, 40)); + end else + BuyerData.Add('CorporateName', CopyStr(Customer.Name + Customer."Name 2", 1, 80)); + BuyerData.Add('Address', CopyStr(Customer.Address + Customer."Address 2", 1, 80)); + BuyerData.Add('PostCode', CopyStr(Customer."Post Code", 1, 5)); + BuyerData.Add('Town', CopyStr(Customer.City, 1, 50)); + BuyerData.Add('Province', CopyStr(Customer.County, 1, 20)); + BuyerData.Add('CountryCode', CopyStr(CountryISO, 1, 3)); + BuyerData.Add('Telephone', CopyStr(Customer."Phone No.", 1, 15)); + BuyerData.Add('ElectronicMail', CopyStr(Customer."E-Mail", 1, 60)); + end; + + local procedure CreateFileHeaderNode(var FileHeaderData: Dictionary of [Text, Text]; var FileHeaderTotals: Dictionary of [Text, Decimal]) FileHeaderNode: XmlElement + var + BatchNode: XmlElement; + TempXmlNode: XmlElement; + begin + FileHeaderNode := XmlElement.Create('FileHeader', ''); + FileHeaderNode.Add(XmlElement.Create('SchemaVersion', '', FileHeaderData.Get('SchemaVersion'))); + FileHeaderNode.Add(XmlElement.Create('Modality', '', FileHeaderData.Get('Modality'))); + FileHeaderNode.Add(XmlElement.Create('InvoiceIssuerType', '', FileHeaderData.Get('InvoiceIssuerType'))); + + BatchNode := XmlElement.Create('Batch', ''); + BatchNode.Add(XmlElement.Create('BatchIdentifier', '', FileHeaderData.Get('BatchIdentifier'))); + BatchNode.Add(XmlElement.Create('InvoicesCount', '', FileHeaderData.Get('InvoicesCount'))); + + TempXmlNode := XmlElement.Create('TotalInvoicesAmount', ''); + TempXmlNode.Add(XmlElement.Create('TotalAmount', '', ToXMLDecimal8(FileHeaderTotals.Get('TotalInvoicesAmount')))); + BatchNode.Add(TempXmlNode); + + TempXmlNode := XmlElement.Create('TotalOutstandingAmount', ''); + TempXmlNode.Add(XmlElement.Create('TotalAmount', '', ToXMLDecimal8(FileHeaderTotals.Get('TotalInvoicesAmount')))); + BatchNode.Add(TempXmlNode); + + TempXmlNode := XmlElement.Create('TotalExecutableAmount', ''); + TempXmlNode.Add(XmlElement.Create('TotalAmount', '', ToXMLDecimal8(FileHeaderTotals.Get('TotalInvoicesAmount')))); + BatchNode.Add(TempXmlNode); + + BatchNode.Add(XmlElement.Create('InvoiceCurrencyCode', '', FileHeaderData.Get('InvoiceCurrencyCode'))); + + FileHeaderNode.Add(BatchNode); + end; + + local procedure CreatePartiesNode(var SellerData: Dictionary of [Text, Text]; var BuyerData: Dictionary of [Text, Text]) PartiesNode: XmlElement + var + SellerPartyNode: XmlElement; + BuyerPartyNode: XmlElement; + begin + PartiesNode := XmlElement.Create('Parties', ''); + + SellerPartyNode := XmlElement.Create('SellerParty', ''); + AddPartyNode(SellerPartyNode, SellerData); + + BuyerPartyNode := XmlElement.Create('BuyerParty', ''); + AddPartyNode(BuyerPartyNode, BuyerData); + + PartiesNode.Add(SellerPartyNode); + PartiesNode.Add(BuyerPartyNode); + end; + + local procedure AddPartyNode(var PartyNode: XmlElement; var PartyData: Dictionary of [Text, Text]) + var + TaxIdentificationNode: XmlElement; + LegalEntityNode: XmlElement; + TempXmlNode: XmlElement; + begin + // Parties -> SellerParty/BuyerParty -> TaxIdentification + TaxIdentificationNode := XmlElement.Create('TaxIdentification', ''); + TaxIdentificationNode.Add(XmlElement.Create('PersonTypeCode', '', PartyData.Get('PersonTypeCode'))); + TaxIdentificationNode.Add(XmlElement.Create('ResidenceTypeCode', '', PartyData.Get('ResidenceTypeCode'))); + TaxIdentificationNode.Add(XmlElement.Create('TaxIdentificationNumber', '', PartyData.Get('TaxIdentificationNumber'))); + PartyNode.Add(TaxIdentificationNode); + + // Parties -> SellerParty/BuyerParty -> LegalEntity + LegalEntityNode := XmlElement.Create('LegalEntity', ''); + if PartyData.ContainsKey('Name') then begin + LegalEntityNode.Add(XmlElement.Create('Name', '', PartyData.Get('Name'))); + LegalEntityNode.Add(XmlElement.Create('FirstSurname', '', PartyData.Get('FirstSurname'))); + end else + LegalEntityNode.Add(XmlElement.Create('CorporateName', '', PartyData.Get('CorporateName'))); + + // Parties -> SellerParty/BuyerParty -> LegalEntity -> Address + if PartyData.Get('ResidenceTypeCode') = 'R' then begin + // Local + TempXmlNode := XmlElement.Create('AddressInSpain', ''); + TempXmlNode.Add(XmlElement.Create('Address', '', PartyData.Get('Address'))); + TempXmlNode.Add(XmlElement.Create('PostCode', '', PartyData.Get('PostCode'))); + TempXmlNode.Add(XmlElement.Create('Town', '', PartyData.Get('Town'))); + TempXmlNode.Add(XmlElement.Create('Province', '', PartyData.Get('Province'))); + TempXmlNode.Add(XmlElement.Create('CountryCode', '', PartyData.Get('CountryCode'))); + end else begin + // Foreign + TempXmlNode := XmlElement.Create('OverseasAddress', ''); + TempXmlNode.Add(XmlElement.Create('Address', '', PartyData.Get('Address'))); + TempXmlNode.Add(XmlElement.Create('PostCodeAndTown', '', PartyData.Get('PostCode'))); + TempXmlNode.Add(XmlElement.Create('Province', '', PartyData.Get('Province'))); + TempXmlNode.Add(XmlElement.Create('CountryCode', '', PartyData.Get('CountryCode'))); + end; + LegalEntityNode.Add(TempXmlNode); + + // Parties -> SellerParty/BuyerParty -> LegalEntity -> ContactDetails + TempXmlNode := XmlElement.Create('ContactDetails', ''); + TempXmlNode.Add(XmlElement.Create('Telephone', '', PartyData.Get('Telephone'))); + TempXmlNode.Add(XmlElement.Create('ElectronicMail', '', PartyData.Get('ElectronicMail'))); + LegalEntityNode.Add(TempXmlNode); + + PartyNode.Add(LegalEntityNode); + end; + + local procedure CreateInvoicesNode(var FileHeaderTotals: Dictionary of [Text, Decimal]; var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesInvoiceLine: Record "Sales Invoice Line"; IsBatch: Boolean) InvoicesNode: XmlElement + begin + InvoicesNode := XmlElement.Create('Invoices', ''); + + if IsBatch then + repeat + AddInvoiceNode(InvoicesNode, SalesInvoiceHeader, SalesInvoiceLine, FileHeaderTotals); + until SalesInvoiceHeader.Next() = 0 + else + AddInvoiceNode(InvoicesNode, SalesInvoiceHeader, SalesInvoiceLine, FileHeaderTotals); + end; + + local procedure CreateInvoicesNode(var FileHeaderTotals: Dictionary of [Text, Decimal]; var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; var SalesCrMemoLine: Record "Sales Cr.Memo Line"; IsBatch: Boolean) InvoicesNode: XmlElement + begin + InvoicesNode := XmlElement.Create('Invoices', ''); + + if IsBatch then + repeat + AddInvoiceNode(InvoicesNode, SalesCrMemoHeader, SalesCrMemoLine, FileHeaderTotals); + until SalesCrMemoHeader.Next() = 0 + else + AddInvoiceNode(InvoicesNode, SalesCrMemoHeader, SalesCrMemoLine, FileHeaderTotals); + end; + + local procedure AddInvoiceNode(var InvoicesNode: XmlElement; var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; var SalesCrMemoLine: Record "Sales Cr.Memo Line"; var FileHeaderTotals: Dictionary of [Text, Decimal]) + var + InvoiceNode: XmlElement; + InvoiceHeaderNode: XmlElement; + InvoiceIssueDataNode: XmlElement; + TaxesOutputsNode: XmlElement; + InvoiceLineNode: XmlElement; + InvoiceTotalsNode: XmlElement; + TotalsData: Dictionary of [Text, Decimal]; + begin + InvoiceNode := XmlElement.Create('Invoice', ''); + + // Lines + SalesCrMemoLine.SetRange("Document No.", SalesCrMemoHeader."No."); + CreateLineNodes(InvoiceLineNode, SalesCrMemoLine, TotalsData); + + // InvoiceTotals + CreateInvoiceTotalsNode(InvoiceTotalsNode, TotalsData); + + // TaxesOutputs + CreateTaxesOutputsNode(TaxesOutputsNode, SalesCrMemoLine, TotalsData); + + // InvoiceIssueData + CreateInvoiceIssueDataNode(InvoiceIssueDataNode, SalesCrMemoHeader); + + // InvoiceHeader + CreateInvoiceHeaderNode(InvoiceHeaderNode, SalesCrMemoHeader); + + // Add in correct order + InvoiceNode.Add(InvoiceHeaderNode); + InvoiceNode.Add(InvoiceIssueDataNode); + InvoiceNode.Add(TaxesOutputsNode); + InvoiceNode.Add(InvoiceTotalsNode); + InvoiceNode.Add(InvoiceLineNode); + + InvoicesNode.Add(InvoiceNode); + + AddToTotals(FileHeaderTotals, 'TotalInvoicesAmount', TotalsData.Get('GrossAmount') + TotalsData.Get('TaxAmount')); + AddToTotals(FileHeaderTotals, 'Count', 1); + end; + + local procedure AddInvoiceNode(var InvoicesNode: XmlElement; var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesInvoiceLine: Record "Sales Invoice Line"; var FileHeaderTotals: Dictionary of [Text, Decimal]) + var + InvoiceNode: XmlElement; + InvoiceHeaderNode: XmlElement; + InvoiceIssueDataNode: XmlElement; + TaxesOutputsNode: XmlElement; + InvoiceLineNode: XmlElement; + InvoiceTotalsNode: XmlElement; + TotalsData: Dictionary of [Text, Decimal]; + begin + InvoiceNode := XmlElement.Create('Invoice', ''); + + // Lines + SalesInvoiceLine.SetRange("Document No.", SalesInvoiceHeader."No."); + CreateLineNodes(InvoiceLineNode, SalesInvoiceLine, TotalsData); + + // InvoiceTotals + CreateInvoiceTotalsNode(InvoiceTotalsNode, TotalsData); + + // TaxesOutputs + CreateTaxesOutputsNode(TaxesOutputsNode, SalesInvoiceLine, TotalsData); + + // InvoiceIssueData + CreateInvoiceIssueDataNode(InvoiceIssueDataNode, SalesInvoiceHeader); + + // InvoiceHeader + CreateInvoiceHeaderNode(InvoiceHeaderNode, SalesInvoiceHeader); + + // Add in correct order + InvoiceNode.Add(InvoiceHeaderNode); + InvoiceNode.Add(InvoiceIssueDataNode); + InvoiceNode.Add(TaxesOutputsNode); + InvoiceNode.Add(InvoiceTotalsNode); + InvoiceNode.Add(InvoiceLineNode); + + InvoicesNode.Add(InvoiceNode); + + AddToTotals(FileHeaderTotals, 'TotalInvoicesAmount', TotalsData.Get('GrossAmount') + TotalsData.Get('TaxAmount')); + AddToTotals(FileHeaderTotals, 'Count', 1); + end; + + local procedure CreateInvoiceHeaderNode(var InvoiceHeaderNode: XmlElement; var SalesInvoiceHeader: Record "Sales Invoice Header") + begin + InvoiceHeaderNode := XmlElement.Create('InvoiceHeader', ''); + InvoiceHeaderNode.Add(XmlElement.Create('InvoiceNumber', '', CopyStr(SalesInvoiceHeader."No.", 1, 30))); + InvoiceHeaderNode.Add(XmlElement.Create('InvoiceDocumentType', '', ConvertInvoiceTypeToSymbols(SalesInvoiceHeader."Invoice Type"))); + InvoiceHeaderNode.Add(XmlElement.Create('InvoiceClass', '', ConvertInvoiceTypeToClass(SalesInvoiceHeader."Invoice Type"))); + end; + + local procedure CreateInvoiceHeaderNode(var InvoiceHeaderNode: XmlElement; var SalesCrMemoHeader: Record "Sales Cr.Memo Header") + var + CorrectiveNode: XmlElement; + begin + InvoiceHeaderNode := XmlElement.Create('InvoiceHeader', ''); + InvoiceHeaderNode.Add(XmlElement.Create('InvoiceNumber', '', CopyStr(SalesCrMemoHeader."No.", 1, 30))); + InvoiceHeaderNode.Add(XmlElement.Create('InvoiceDocumentType', '', ConvertInvoiceTypeToSymbols(SalesCrMemoHeader."Invoice Type"))); + InvoiceHeaderNode.Add(XmlElement.Create('InvoiceClass', '', ConvertInvoiceTypeToClass(SalesCrMemoHeader."Invoice Type"))); + // Corrective Node + CreateCorrectiveNode(CorrectiveNode, SalesCrMemoHeader); + InvoiceHeaderNode.Add(CorrectiveNode); + end; + + local procedure CreateCorrectiveNode(var CorrectiveNode: XmlElement; var SalesCrMemoHeader: Record "Sales Cr.Memo Header") + var + TaxPeriodNode: XmlElement; + StartingDate, EndingDate : Text; + ReasonCode, ReasonDescription : Text; + begin + CorrectiveNode := XmlElement.Create('Corrective', ''); + GetReasonCodeAndDescription(ReasonCode, ReasonDescription, SalesCrMemoHeader); + CorrectiveNode.Add(XmlElement.Create('ReasonCode', '', ReasonCode)); + CorrectiveNode.Add(XmlElement.Create('ReasonDescription', '', ReasonDescription)); + TaxPeriodNode := XmlElement.Create('TaxPeriod', ''); + GetStartingAndEndingDate(StartingDate, EndingDate, SalesCrMemoHeader); + TaxPeriodNode.Add(XmlElement.Create('StartDate', '', StartingDate)); + TaxPeriodNode.Add(XmlElement.Create('EndDate', '', EndingDate)); + CorrectiveNode.Add(TaxPeriodNode); + CorrectiveNode.Add(XmlElement.Create('CorrectionMethod', '', '02')); + CorrectiveNode.Add(XmlElement.Create('CorrectionMethodDescription', '', 'Rectificación por diferencias')); + end; + + local procedure CreateInvoiceIssueDataNode(var InvoiceIssueDataNode: XmlElement; var SalesInvoiceHeader: Record "Sales Invoice Header") + var + TempXmlNode: XmlElement; + begin + InvoiceIssueDataNode := XmlElement.Create('InvoiceIssueData', ''); + TempXmlNode := XmlElement.Create('IssueDate', '', Format(SalesInvoiceHeader."Posting Date", 0, 9)); + InvoiceIssueDataNode.Add(TempXmlNode); + TempXmlNode := XmlElement.Create('InvoiceCurrencyCode', '', GetCurrencyISOCode(SalesInvoiceHeader."Currency Code")); + InvoiceIssueDataNode.Add(TempXmlNode); + if SalesInvoiceHeader."Currency Code" <> '' then begin + TempXmlNode := XmlElement.Create('ExchangeRateDetails', ''); + TempXmlNode.Add(XmlElement.Create('ExchangeRate', '', ToXMLDecimal8(SalesInvoiceHeader."Currency Factor"))); + TempXmlNode.Add(XmlElement.Create('ExchangeRateDate', '', Format(SalesInvoiceHeader."Posting Date", 0, 9))); + InvoiceIssueDataNode.Add(TempXmlNode); + end; + InvoiceIssueDataNode.Add(XmlElement.Create('TaxCurrencyCode', '', GetCurrencyISOCode(SalesInvoiceHeader."Currency Code"))); + InvoiceIssueDataNode.Add(XmlElement.Create('LanguageName', '', CopyStr(SalesInvoiceHeader."Language Code", 1, 2).ToLower())); + end; + + local procedure CreateInvoiceIssueDataNode(var InvoiceIssueDataNode: XmlElement; var SalesCrMemoHeader: Record "Sales Cr.Memo Header") + var + TempXmlNode: XmlElement; + begin + InvoiceIssueDataNode := XmlElement.Create('InvoiceIssueData', ''); + TempXmlNode := XmlElement.Create('IssueDate', '', Format(SalesCrMemoHeader."Posting Date", 0, 9)); + InvoiceIssueDataNode.Add(TempXmlNode); + TempXmlNode := XmlElement.Create('InvoiceCurrencyCode', '', GetCurrencyISOCode(SalesCrMemoHeader."Currency Code")); + InvoiceIssueDataNode.Add(TempXmlNode); + if SalesCrMemoHeader."Currency Code" <> '' then begin + TempXmlNode := XmlElement.Create('ExchangeRateDetails', ''); + TempXmlNode.Add(XmlElement.Create('ExchangeRate', '', ToXMLDecimal8(SalesCrMemoHeader."Currency Factor"))); + TempXmlNode.Add(XmlElement.Create('ExchangeRateDate', '', Format(SalesCrMemoHeader."Posting Date", 0, 9))); + InvoiceIssueDataNode.Add(TempXmlNode); + end; + InvoiceIssueDataNode.Add(XmlElement.Create('TaxCurrencyCode', '', GetCurrencyISOCode(SalesCrMemoHeader."Currency Code"))); + InvoiceIssueDataNode.Add(XmlElement.Create('LanguageName', '', CopyStr(SalesCrMemoHeader."Language Code", 1, 2).ToLower())); + end; + + local procedure CreateLineNodes(var InvoiceLineNode: XmlElement; var SalesInvoiceLine: Record "Sales Invoice Line"; var TotalsData: Dictionary of [Text, Decimal]) + var + UnitOfMeasure: Record "Unit of Measure"; + SingleLineNode: XmlElement; + DiscountsNode: XmlElement; + DiscountNode: XmlElement; + TaxesOutputsNode: XmlElement; + TaxNode: XmlElement; + TaxAmountNode: XmlElement; + TaxableBaseNode: XmlElement; + UnitOfMeasureInteger: Integer; + DiscountAmount, TotalCost, GrossAmount, TaxableBase, TaxAmount : Decimal; + ItemDescription: Text; + begin + InvoiceLineNode := XmlElement.Create('Items', ''); + SalesInvoiceLine.SetFilter(Type, '<>%1', SalesInvoiceLine.Type::" "); + if SalesInvoiceLine.FindSet() then + repeat + SingleLineNode := XmlElement.Create('InvoiceLine', ''); + ItemDescription := SalesInvoiceLine.Description; + if SalesInvoiceLine."Description 2" <> '' then + ItemDescription += ' ' + SalesInvoiceLine."Description 2"; + SingleLineNode.Add(XmlElement.Create('ItemDescription', '', CopyStr(ItemDescription, 1, 2500))); + SingleLineNode.Add(XmlElement.Create('Quantity', '', ToXMLDecimal8(SalesInvoiceLine.Quantity))); + if SalesInvoiceLine."Unit of Measure Code" <> '' then begin + UnitOfMeasure.Get(SalesInvoiceLine."Unit of Measure Code"); + if Enum::"Factura-E Units of Measure".Names().Contains(UnitOfMeasure."International Standard Code") then begin + UnitOfMeasureInteger := Enum::"Factura-E Units of Measure".Names().IndexOf(UnitOfMeasure."International Standard Code"); + SingleLineNode.Add(XmlElement.Create('UnitOfMeasure', '', Format(UnitOfMeasureInteger))); + end; + end; + SingleLineNode.Add(XmlElement.Create('UnitPriceWithoutTax', '', ToXMLDecimal8(SalesInvoiceLine."Unit Price"))); + TotalCost := SalesInvoiceLine."Unit Price" * SalesInvoiceLine.Quantity; + SingleLineNode.Add(XmlElement.Create('TotalCost', '', ToXMLDecimal8(TotalCost))); + AddToTotals(TotalsData, 'TotalCost', TotalCost); + // Discount + DiscountAmount := SalesInvoiceLine."Line Discount Amount" + SalesInvoiceLine."Inv. Discount Amount"; + if DiscountAmount <> 0 then begin + DiscountsNode := XmlElement.Create('DiscountsAndRebates', ''); + DiscountNode := XmlElement.Create('Discount', ''); + DiscountNode.Add(XmlElement.Create('DiscountReason', '', ToXMLDecimal2(SalesInvoiceLine."Line Discount %") + '%')); + DiscountNode.Add(XmlElement.Create('DiscountAmount', '', ToXMLDecimal8(DiscountAmount))); + DiscountsNode.Add(DiscountNode); + SingleLineNode.Add(DiscountsNode); + end; + + GrossAmount := TotalCost - DiscountAmount; + SingleLineNode.Add(XmlElement.Create('GrossAmount', '', ToXMLDecimal8(GrossAmount))); + AddToTotals(TotalsData, 'GrossAmount', GrossAmount); + // TaxesOutputs + TaxesOutputsNode := XmlElement.Create('TaxesOutputs', ''); + + TaxNode := XmlElement.Create('Tax', ''); + TaxNode.Add(XmlElement.Create('TaxTypeCode', '', '01')); + TaxNode.Add(XmlElement.Create('TaxRate', '', ToXMLDecimal8(SalesInvoiceLine."VAT %" + SalesInvoiceLine."EC %"))); + + TaxableBaseNode := XmlElement.Create('TaxableBase', ''); + TaxableBase := SalesInvoiceLine."VAT Base Amount"; + TaxableBaseNode.Add(XmlElement.Create('TotalAmount', '', ToXMLDecimal8(TaxableBase))); + TaxNode.Add(TaxableBaseNode); + AddToTotals(TotalsData, 'TaxableBase', TaxableBase); + + TaxAmountNode := XmlElement.Create('TaxAmount', ''); + TaxAmount := SalesInvoiceLine."Amount Including VAT" - SalesInvoiceLine.Amount; + TaxAmountNode.Add(XmlElement.Create('TotalAmount', '', ToXMLDecimal8(TaxAmount))); + TaxNode.Add(TaxAmountNode); + AddToTotals(TotalsData, 'TaxAmount', TaxAmount); + + TaxesOutputsNode.Add(TaxNode); + SingleLineNode.Add(TaxesOutputsNode); + + InvoiceLineNode.Add(SingleLineNode); + until SalesInvoiceLine.Next() = 0; + end; + + local procedure CreateLineNodes(var InvoiceLineNode: XmlElement; var SalesCrMemoLine: Record "Sales Cr.Memo Line"; var TotalsData: Dictionary of [Text, Decimal]) + var + UnitOfMeasure: Record "Unit of Measure"; + SingleLineNode: XmlElement; + DiscountsNode: XmlElement; + DiscountNode: XmlElement; + TaxesOutputsNode: XmlElement; + TaxNode: XmlElement; + TaxAmountNode: XmlElement; + TaxableBaseNode: XmlElement; + UnitOfMeasureInteger: Integer; + DiscountAmount, TotalCost, GrossAmount, TaxableBase, TaxAmount : Decimal; + ItemDescription: Text; + begin + InvoiceLineNode := XmlElement.Create('Items', ''); + SalesCrMemoLine.SetFilter(Type, '<>%1', SalesCrMemoLine.Type::" "); + if SalesCrMemoLine.FindSet() then + repeat + SingleLineNode := XmlElement.Create('InvoiceLine', ''); + ItemDescription := SalesCrMemoLine.Description; + if SalesCrMemoLine."Description 2" <> '' then + ItemDescription += ' ' + SalesCrMemoLine."Description 2"; + SingleLineNode.Add(XmlElement.Create('ItemDescription', '', CopyStr(ItemDescription, 1, 2500))); + SingleLineNode.Add(XmlElement.Create('Quantity', '', ToXMLDecimal8(SalesCrMemoLine.Quantity))); + if SalesCrMemoLine."Unit of Measure Code" <> '' then begin + UnitOfMeasure.Get(SalesCrMemoLine."Unit of Measure Code"); + if Enum::"Factura-E Units of Measure".Names().Contains(UnitOfMeasure."International Standard Code") then begin + UnitOfMeasureInteger := Enum::"Factura-E Units of Measure".Names().IndexOf(UnitOfMeasure."International Standard Code"); + SingleLineNode.Add(XmlElement.Create('UnitOfMeasure', '', Format(UnitOfMeasureInteger))); + end; + end; + SingleLineNode.Add(XmlElement.Create('UnitPriceWithoutTax', '', Format(SalesCrMemoLine."Unit Price", 0, 9))); + TotalCost := SalesCrMemoLine."Unit Price" * SalesCrMemoLine.Quantity; + SingleLineNode.Add(XmlElement.Create('TotalCost', '', ToXMLDecimal8(TotalCost))); + AddToTotals(TotalsData, 'TotalCost', TotalCost); + // Discount + DiscountAmount := SalesCrMemoLine."Line Discount Amount" + SalesCrMemoLine."Inv. Discount Amount"; + if DiscountAmount <> 0 then begin + DiscountsNode := XmlElement.Create('DiscountsAndRebates', ''); + DiscountNode := XmlElement.Create('Discount', ''); + DiscountNode.Add(XmlElement.Create('DiscountReason', '', ToXMLDecimal2(SalesCrMemoLine."Line Discount %") + '%')); + DiscountNode.Add(XmlElement.Create('DiscountAmount', '', ToXMLDecimal8(DiscountAmount))); + DiscountsNode.Add(DiscountNode); + SingleLineNode.Add(DiscountsNode); + end; + + GrossAmount := TotalCost - DiscountAmount; + SingleLineNode.Add(XmlElement.Create('GrossAmount', '', ToXMLDecimal8(GrossAmount))); + AddToTotals(TotalsData, 'GrossAmount', GrossAmount); + // TaxesOutputs + TaxesOutputsNode := XmlElement.Create('TaxesOutputs', ''); + + TaxNode := XmlElement.Create('Tax', ''); + TaxNode.Add(XmlElement.Create('TaxTypeCode', '', '01')); + TaxNode.Add(XmlElement.Create('TaxRate', '', ToXMLDecimal8(SalesCrMemoLine."VAT %" + SalesCrMemoLine."EC %"))); + + TaxableBaseNode := XmlElement.Create('TaxableBase', ''); + TaxableBase := SalesCrMemoLine."VAT Base Amount"; + TaxableBaseNode.Add(XmlElement.Create('TotalAmount', '', ToXMLDecimal8(TaxableBase))); + TaxNode.Add(TaxableBaseNode); + AddToTotals(TotalsData, 'TaxableBase', TaxableBase); + + TaxAmountNode := XmlElement.Create('TaxAmount', ''); + TaxAmount := SalesCrMemoLine."Amount Including VAT" - SalesCrMemoLine.Amount; + TaxAmountNode.Add(XmlElement.Create('TotalAmount', '', ToXMLDecimal8(TaxAmount))); + TaxNode.Add(TaxAmountNode); + AddToTotals(TotalsData, 'TaxAmount', TaxAmount); + + TaxesOutputsNode.Add(TaxNode); + SingleLineNode.Add(TaxesOutputsNode); + + InvoiceLineNode.Add(SingleLineNode); + until SalesCrMemoLine.Next() = 0; + end; + + local procedure CreateInvoiceTotalsNode(var InvoiceTotalsNode: XmlElement; var TotalsData: Dictionary of [Text, Decimal]) + begin + InvoiceTotalsNode := XmlElement.Create('InvoiceTotals', ''); + InvoiceTotalsNode.Add(XmlElement.Create('TotalGrossAmount', '', ToXMLDecimal8(TotalsData.Get('GrossAmount')))); + InvoiceTotalsNode.Add(XmlElement.Create('TotalGrossAmountBeforeTaxes', '', ToXMLDecimal8(TotalsData.Get('GrossAmount')))); + InvoiceTotalsNode.Add(XmlElement.Create('TotalTaxOutputs', '', ToXMLDecimal8(TotalsData.Get('TaxAmount')))); + InvoiceTotalsNode.Add(XmlElement.Create('TotalTaxesWithheld', '', '0')); + InvoiceTotalsNode.Add(XmlElement.Create('InvoiceTotal', '', ToXMLDecimal8(TotalsData.Get('GrossAmount') + TotalsData.Get('TaxAmount')))); + InvoiceTotalsNode.Add(XmlElement.Create('TotalOutstandingAmount', '', ToXMLDecimal8(TotalsData.Get('GrossAmount') + TotalsData.Get('TaxAmount')))); + InvoiceTotalsNode.Add(XmlElement.Create('TotalExecutableAmount', '', ToXMLDecimal8(TotalsData.Get('GrossAmount') + TotalsData.Get('TaxAmount')))); + end; + + local procedure CreateTaxesOutputsNode(var TaxesOutputsNode: XmlElement; var SalesInvoiceLine: Record "Sales Invoice Line"; var TotalsData: Dictionary of [Text, Decimal]) + var + TempXMLNode: XmlElement; + TaxNode: XmlElement; + begin + TaxesOutputsNode := XmlElement.Create('TaxesOutputs', ''); + TaxNode := XmlElement.Create('Tax', ''); + TaxNode.Add(XmlElement.Create('TaxTypeCode', '', '01')); + TaxNode.Add(XmlElement.Create('TaxRate', '', ToXMLDecimal8(SalesInvoiceLine."VAT %" + SalesInvoiceLine."EC %"))); + TempXMLNode := XmlElement.Create('TaxableBase', ''); + TempXMLNode.Add(XmlElement.Create('TotalAmount', '', ToXMLDecimal8(TotalsData.Get('TaxableBase')))); + TaxNode.Add(TempXMLNode); + TempXMLNode := XmlElement.Create('TaxAmount', ''); + TempXMLNode.Add(XmlElement.Create('TotalAmount', '', ToXMLDecimal8(TotalsData.Get('TaxAmount')))); + TaxNode.Add(TempXMLNode); + + TaxesOutputsNode.Add(TaxNode); + end; + + local procedure CreateTaxesOutputsNode(var TaxesOutputsNode: XmlElement; var SalesCrMemoLine: Record "Sales Cr.Memo Line"; var TotalsData: Dictionary of [Text, Decimal]) + var + TempXMLNode: XmlElement; + TaxNode: XmlElement; + begin + TaxesOutputsNode := XmlElement.Create('TaxesOutputs', ''); + TaxNode := XmlElement.Create('Tax', ''); + TaxNode.Add(XmlElement.Create('TaxTypeCode', '', '01')); + TaxNode.Add(XmlElement.Create('TaxRate', '', ToXMLDecimal8(SalesCrMemoLine."VAT %" + SalesCrMemoLine."EC %"))); + TempXMLNode := XmlElement.Create('TaxableBase', ''); + TempXMLNode.Add(XmlElement.Create('TotalAmount', '', ToXMLDecimal8(TotalsData.Get('TaxableBase')))); + TaxNode.Add(TempXMLNode); + TempXMLNode := XmlElement.Create('TaxAmount', ''); + TempXMLNode.Add(XmlElement.Create('TotalAmount', '', ToXMLDecimal8(TotalsData.Get('TaxAmount')))); + TaxNode.Add(TempXMLNode); + + TaxesOutputsNode.Add(TaxNode); + end; + + local procedure AddToTotals(var TotalsData: Dictionary of [Text, Decimal]; KeyText: Text; Value: Decimal) + begin + if TotalsData.ContainsKey(KeyText) then + TotalsData.Set(KeyText, TotalsData.Get(KeyText) + Value) + else + TotalsData.Add(KeyText, Value); + end; + + local procedure CountryCodeToSymbolAndISO(CountryRegionCode: Code[10]; var CountrySymbol: Text[1]; var CountryISO: Text[3]) + var + CountryRegion: Record "Country/Region"; + FacturaECountires: Codeunit "Factura-E Countries"; + begin + if CountryRegionCode = 'ES' then + CountrySymbol := 'R' + else + if CountryRegion.IsEUCountry(CountryRegionCode) then + CountrySymbol := 'U' + else + CountrySymbol := 'E'; + + CountryRegion.Get(CountryRegionCode); + CountryISO := FacturaECountires.Convert2LetterCountryCodeTo3LetterCountryCode(CountryRegion."ISO Code"); + end; + + local procedure ConvertInvoiceTypeToSymbols(SIIInvoiceType: Enum "SII Sales Invoice Type"): Text[2] + begin + if SIIInvoiceType = Enum::"SII Sales Invoice Type"::"F1 Invoice" then + exit('FC'); + if SIIInvoiceType = Enum::"SII Sales Invoice Type"::"F2 Simplified Invoice" then + exit('FA'); + exit('FC'); + end; + + local procedure ConvertInvoiceTypeToClass(SIIInvoiceType: Enum "SII Sales Invoice Type"): Text[2] + begin + if SIIInvoiceType in [Enum::"SII Sales Invoice Type"::"F1 Invoice", + Enum::"SII Sales Invoice Type"::"F2 Simplified Invoice", + Enum::"SII Sales Invoice Type"::"F3 Invoice issued to replace simplified invoices"] then + exit('OO'); + if SIIInvoiceType = Enum::"SII Sales Invoice Type"::"F4 Invoice summary entry" then + exit('OC'); + exit('OR'); + end; + + local procedure GetReasonCodeAndDescription(var ReasonCode: Text; var ReasonDescription: Text; var SalesCrMemoHeader: Record "Sales Cr.Memo Header") + var + CodeAndDescription: Text; + begin + CodeAndDescription := Format(SalesCrMemoHeader."Factura-E Reason Code"); + ReasonCode := CopyStr(CodeAndDescription, 1, 2); + ReasonDescription := CopyStr(CodeAndDescription, 4, 100); + end; + + local procedure GetStartingAndEndingDate(var StartingDate: Text; var EndingDate: Text; var SalesCrMemoHeader: Record "Sales Cr.Memo Header") + var + VATReturnPeriod: Record "VAT Return Period"; + AccountingPeriod: Record "Accounting Period"; + begin + VATReturnPeriod.SetFilter("Start Date", '<=%1', SalesCrMemoHeader."Posting Date"); + VATReturnPeriod.SetFilter("End Date", '>=%1', SalesCrMemoHeader."Posting Date"); + if VATReturnPeriod.FindFirst() then begin + StartingDate := Format(VATReturnPeriod."Start Date", 0, 9); + EndingDate := Format(VATReturnPeriod."End Date", 0, 9); + exit; + end; + AccountingPeriod.SetFilter("Starting Date", '<=%1', SalesCrMemoHeader."Posting Date"); + if AccountingPeriod.FindLast() then begin + StartingDate := Format(AccountingPeriod."Starting Date", 0, 9); + EndingDate := Format(AccountingPeriod.GetFiscalYearEndDate(AccountingPeriod."Starting Date"), 0, 9); + exit; + end; + StartingDate := Format(CalcDate('<-CY>', SalesCrMemoHeader."Posting Date"), 0, 9); + EndingDate := Format(CalcDate('', SalesCrMemoHeader."Posting Date"), 0, 9); + end; + + local procedure GetCurrencyISOCode(CurrencyCode: Code[10]): Text[3] + var + Currency: Record Currency; + begin + if CurrencyCode = '' then + exit(CopyStr(GeneralLedgerSetup."LCY Code", 1, 3)); + Currency.Get(CurrencyCode); + exit(Currency."ISO Code"); + end; + + local procedure GetBasicXMLHeader(): Text + begin + exit('' + + ''); + end; + + local procedure ToXMLDecimal2(Value: Decimal): Text + begin + exit(Format(Round(Value, 0.01), 0, 9)); + end; + + local procedure ToXMLDecimal8(Value: Decimal): Text + begin + exit(Format(Round(Value, 0.00000001), 0, 9)); + end; + + [IntegrationEvent(false, false)] + local procedure OnAfterExport(var SourceDocumentHeader: RecordRef; var SourceDocumentLines: RecordRef; var TempBlob: Codeunit "Temp Blob"; IsBatch: Boolean) + begin + end; + + [IntegrationEvent(false, false)] + local procedure OnBeforeExport(var SourceDocumentHeader: RecordRef; var SourceDocumentLines: RecordRef; var TempBlob: Codeunit "Temp Blob"; IsBatch: Boolean) + begin + end; +} \ No newline at end of file diff --git a/Apps/ES/EDocumentFormats/FacturaE/app/src/Core/FacturaEImport.Codeunit.al b/Apps/ES/EDocumentFormats/FacturaE/app/src/Core/FacturaEImport.Codeunit.al new file mode 100644 index 0000000000..043e2ac4b9 --- /dev/null +++ b/Apps/ES/EDocumentFormats/FacturaE/app/src/Core/FacturaEImport.Codeunit.al @@ -0,0 +1,297 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.eServices.EDocument.Format; + +using Microsoft.eServices.EDocument; +using Microsoft.eServices.EDocument.Service.Participant; +using Microsoft.Finance.Currency; +using Microsoft.Finance.GeneralLedger.Setup; +using Microsoft.Foundation.UOM; +using Microsoft.Purchases.Document; +using Microsoft.Purchases.Vendor; +using System.IO; +using System.Telemetry; +using System.Utilities; + +codeunit 10775 "Factura-E Import" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + var + EDocumentImportHelper: Codeunit "E-Document Import Helper"; + FeatureTelemetry: Codeunit "Feature Telemetry"; + FeatureNameTok: Label 'EDocument Format Factura-E', Locked = true; + StartEventNameTok: Label 'Import initiated. Parsing basic info.', Locked = true; + ContinueEventNameTok: Label 'Parsing complete info.', Locked = true; + EndEntEventNameTok: Label 'Import completed. %1 #%2 created.', Locked = true; + LCYCode: Code[10]; + + procedure ParseBasicInfo(var EDocument: Record "E-Document"; var TempBlob: Codeunit "Temp Blob") + var + TempXMLBuffer: Record "XML Buffer" temporary; + GLSetup: Record "General Ledger Setup"; + DocStream: InStream; + begin + FeatureTelemetry.LogUsage('0000OCU', FeatureNameTok, StartEventNameTok); + TempXMLBuffer.DeleteAll(); + TempBlob.CreateInStream(DocStream); + TempXMLBuffer.LoadFromStream(DocStream); + + GLSetup.Get(); + LCYCode := GLSetup."LCY Code"; + + EDocument.Direction := EDocument.Direction::Incoming; + + ParseDocumentBasicInfo(EDocument, TempXMLBuffer); + OnAfterParseBasicInfo(EDocument, TempBlob); + end; + + procedure ParseCompleteInfo(var EDocument: Record "E-Document"; var PurchaseHeader: Record "Purchase Header" temporary; var PurchaseLine: Record "Purchase Line" temporary; var TempBlob: Codeunit "Temp Blob") + var + TempXMLBuffer: Record "XML Buffer" temporary; + DocStream: InStream; + begin + FeatureTelemetry.LogUsage('0000OCV', FeatureNameTok, ContinueEventNameTok); + TempXMLBuffer.DeleteAll(); + TempBlob.CreateInStream(DocStream); + TempXMLBuffer.LoadFromStream(DocStream); + + CreateDocument(EDocument, PurchaseHeader, PurchaseLine, TempXMLBuffer); + FeatureTelemetry.LogUsage('0000OCW', FeatureNameTok, StrSubstNo(EndEntEventNameTok, EDocument."Document Type", EDocument."Incoming E-Document No.")); + + OnAfterParseCompleteInfo(EDocument, PurchaseHeader, PurchaseLine, TempBlob); + end; + + local procedure ParseSellerParty(var EDocument: Record "E-Document"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + Vendor: Record Vendor; + ServiceParticipant: Record "Service Participant"; + EDocumentService: Record "E-Document Service"; + EDocumentHelper: Codeunit "E-Document Helper"; + VendorName, VendorAddress : Text; + VATRegistrationNo: Text[20]; + VendorNo: Code[20]; + VendorId: Text; + SellerPartyLbl: Label '/namespace:Facturae/Parties/SellerParty/', Locked = true; + begin + VATRegistrationNo := CopyStr(GetNodeByPath(TempXMLBuffer, SellerPartyLbl + 'TaxIdentification/TaxIdentificationNumber'), 1, MaxStrLen(VATRegistrationNo)); + VendorNo := EDocumentImportHelper.FindVendor('', '', VATRegistrationNo); + + if VendorNo = '' then begin + VendorId := GetNodeByPath(TempXMLBuffer, SellerPartyLbl + 'PartyIdentificationType'); + + if VendorId <> '' then begin + EDocumentHelper.GetEdocumentService(EDocument, EDocumentService); + ServiceParticipant.SetRange("Participant Type", ServiceParticipant."Participant Type"::Vendor); + ServiceParticipant.SetRange("Participant Identifier", VendorId); + ServiceParticipant.SetRange(Service, EDocumentService.Code); + if not ServiceParticipant.FindFirst() then begin + ServiceParticipant.SetRange(Service); + if ServiceParticipant.FindFirst() then; + end; + end; + + VendorNo := ServiceParticipant.Participant; + end; + + if VendorNo = '' then begin + VendorName := GetNameDependingOnType(TempXMLBuffer, SellerPartyLbl); + VendorAddress := GetAddressDependingOnType(TempXMLBuffer, SellerPartyLbl); + VendorNo := EDocumentImportHelper.FindVendorByNameAndAddress(VendorName, VendorAddress); + EDocument."Bill-to/Pay-to Name" := CopyStr(VendorName, 1, MaxStrLen(EDocument."Bill-to/Pay-to Name")); + end; + + Vendor := EDocumentImportHelper.GetVendor(EDocument, VendorNo); + if Vendor."No." <> '' then begin + EDocument."Bill-to/Pay-to No." := Vendor."No."; + EDocument."Bill-to/Pay-to Name" := Vendor.Name; + end; + end; + + local procedure GetNameDependingOnType(var TempXMLBuffer: Record "XML Buffer" temporary; PathPrefix: Text) Name: Text + begin + if GetNodeByPath(TempXMLBuffer, PathPrefix + 'TaxIdentification/PersonTypeCode') = 'F' then begin + // Person + Name := GetNodeByPath(TempXMLBuffer, PathPrefix + 'LegalEntity/Name'); + Name += ' ' + GetNodeByPath(TempXMLBuffer, PathPrefix + 'LegalEntity/FirstSurname'); + Name += ' ' + GetNodeByPath(TempXMLBuffer, PathPrefix + 'LegalEntity/SecondSurname'); + end else + // Company + Name := GetNodeByPath(TempXMLBuffer, PathPrefix + 'LegalEntity/CorporateName'); + end; + + local procedure GetAddressDependingOnType(var TempXMLBuffer: Record "XML Buffer" temporary; PathPrefix: Text) Address: Text + begin + if GetNodeByPath(TempXMLBuffer, PathPrefix + 'TaxIdentification/ResidenceTypeCode') = 'R' then + // Local + Address := GetNodeByPath(TempXMLBuffer, PathPrefix + 'LegalEntity/AddressInSpain/Address') + else + // Foreign + Address := GetNodeByPath(TempXMLBuffer, PathPrefix + 'LegalEntity/OverseasAddress/Address'); + end; + + local procedure ParseBuyerParty(var EDocument: Record "E-Document"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + BuyerPartyLbl: Label '/namespace:Facturae/Parties/BuyerParty/', Locked = true; + begin + EDocument."Receiving Company Name" := CopyStr(GetNameDependingOnType(TempXMLBuffer, BuyerPartyLbl), 1, MaxStrLen(EDocument."Receiving Company Name")); + EDocument."Receiving Company Address" := CopyStr(GetAddressDependingOnType(TempXMLBuffer, BuyerPartyLbl), 1, MaxStrLen(EDocument."Receiving Company Address")); + EDocument."Receiving Company VAT Reg. No." := CopyStr(GetNodeByPath(TempXMLBuffer, BuyerPartyLbl + 'TaxIdentification/TaxIdentificationNumber'), 1, MaxStrLen(EDocument."Receiving Company VAT Reg. No.")); + EDocument."Receiving Company Id" := CopyStr(GetNodeByPath(TempXMLBuffer, BuyerPartyLbl + 'PartyIdentificationType'), 1, MaxStrLen(EDocument."Receiving Company Id")); + end; + + local procedure ParseDocumentBasicInfo(var EDocument: Record "E-Document"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + IssueDate: Text; + Currency: Text; + AmountInclVAT: Text; + begin + EDocument."Document Type" := EDocument."Document Type"::"Purchase Invoice"; + EDocument."Incoming E-Document No." := CopyStr(GetNodeByPath(TempXMLBuffer, '/namespace:Facturae/FileHeader/Batch/BatchIdentifier'), 1, MaxStrLen(EDocument."Document No.")); + ParseSellerParty(EDocument, TempXMLBuffer); + ParseBuyerParty(EDocument, TempXMLBuffer); + + IssueDate := GetNodeByPath(TempXMLBuffer, '/namespace:Facturae/Invoice/InvoiceIssueData/IssueDate'); + if IssueDate <> '' then + Evaluate(EDocument."Document Date", IssueDate, 9); + + AmountInclVAT := GetNodeByPath(TempXMLBuffer, '/namespace:Facturae/FileHeader/Batch/TotalOutstandingAmount/TotalAmount'); + if AmountInclVAT <> '' then + Evaluate(EDocument."Amount Incl. VAT", AmountInclVAT, 9); + + Currency := GetNodeByPath(TempXMLBuffer, '/namespace:Facturae/FileHeader/Batch/InvoiceCurrencyCode'); + Currency := ISOCurrencyToRegularCode(Currency); + if LCYCode <> Currency then + EDocument."Currency Code" := CopyStr(Currency, 1, MaxStrLen(EDocument."Currency Code")); + end; + + local procedure ISOCurrencyToRegularCode(ISOCode: Text): Text + var + Currency: Record Currency; + begin + Currency.SetRange("ISO Code", ISOCode); + if Currency.FindFirst() then + exit(Currency.Code); + exit(ISOCode); + end; + + local procedure CreateDocument(var EDocument: Record "E-Document"; var PurchaseHeader: Record "Purchase Header" temporary; var PurchaseLine: Record "Purchase Line" temporary; var TempXMLBuffer: Record "XML Buffer" temporary) + var + LineNo: Integer; + begin + PurchaseHeader.Init(); + PurchaseHeader."Buy-from Vendor No." := EDocument."Bill-to/Pay-to No."; + PurchaseHeader."Currency Code" := EDocument."Currency Code"; + PurchaseHeader."Document Type" := PurchaseHeader."Document Type"::Invoice; // Invoice by default, will be changed to Cr.Memo if relevant fields are found + PurchaseHeader.Insert(); + LineNo := 0; + + TempXMLBuffer.Reset(); + if TempXMLBuffer.FindSet() then + repeat + ParseInvoice(PurchaseHeader, PurchaseLine, TempXMLBuffer.Path, TempXMLBuffer.Value, LineNo); + until TempXMLBuffer.Next() = 0; + + // Apply all header changes + PurchaseHeader.Modify(); + + // Insert last line + PurchaseLine.Insert(); + + end; + + local procedure ParseInvoice(var PurchaseHeader: Record "Purchase Header" temporary; var PurchaseLine: Record "Purchase Line" temporary; Path: Text; Value: Text; var LineNo: Integer) + var + PathPrefixTxt: Label '/namespace:Facturae/Invoices/Invoice', Locked = true; + begin + case Path of + PathPrefixTxt + '/InvoiceHeader/InvoiceNumber': + PurchaseHeader."Vendor Invoice No." := CopyStr(Value, 1, MaxStrLen(PurchaseHeader."Vendor Invoice No.")); + PathPrefixTxt + '/Corrective': + PurchaseHeader."Document Type" := PurchaseHeader."Document Type"::"Credit Memo"; + PathPrefixTxt + '/Corrective/InvoiceNumber': + PurchaseHeader."Applies-to Doc. No." := CopyStr(Value, 1, MaxStrLen(PurchaseHeader."Applies-to Doc. No.")); + PathPrefixTxt + '/InvoiceHeader/InvoiceIssueData/IssueDate': + if Value <> '' then + Evaluate(PurchaseHeader."Document Date", Value, 9); + PathPrefixTxt + '/InvoiceHeader/InvoiceIssueData/InvoiceCurrencyCode': + PurchaseHeader."Currency Code" := CopyStr(ISOCurrencyToRegularCode(Value), 1, MaxStrLen(PurchaseHeader."Currency Code")); + PathPrefixTxt + '/InvoiceHeader/InvoiceIssueData/LanguageName': + PurchaseHeader."Language Code" := CopyStr(Value, 1, MaxStrLen(PurchaseHeader."Language Code")); + PathPrefixTxt + '/Items/InvoiceLine': + begin + if PurchaseLine."Document Type" <> PurchaseLine."Document Type"::Quote then + PurchaseLine.Insert(); + + PurchaseLine.Init(); + PurchaseLine."Document Type" := PurchaseHeader."Document Type"; + PurchaseLine."Document No." := PurchaseHeader."No."; + LineNo += 10000; + PurchaseLine."Line No." := LineNo; + end; + PathPrefixTxt + '/Items/InvoiceLine/Quantity': + if Value <> '' then + Evaluate(PurchaseLine.Quantity, Value, 9); + PathPrefixTxt + '/Items/InvoiceLine/UnitOfMeasure': + PurchaseLine."Unit of Measure Code" := TryGetUOMCodeFromInternationalCode(Value); + PathPrefixTxt + '/Items/InvoiceLine/ReceiverContractReference': + PurchaseHeader."Your Reference" := CopyStr(Value, 1, MaxStrLen(PurchaseHeader."Your Reference")); + PathPrefixTxt + '/Items/InvoiceLine/GrossAmount': + if Value <> '' then + Evaluate(PurchaseLine.Amount, Value, 9); + PathPrefixTxt + '/Items/InvoiceLine/ItemDescription': + PurchaseLine.Description := CopyStr(Value, 1, MaxStrLen(PurchaseLine.Description)); + PathPrefixTxt + '/Items/InvoiceLine/IssuerContractReference': + PurchaseLine."Description 2" := CopyStr(Value, 1, MaxStrLen(PurchaseLine."Description 2")); + PathPrefixTxt + '/Items/InvoiceLine/DiscountsAndRebates/Discount/DiscountAmount': + if Value <> '' then + Evaluate(PurchaseLine."Line Discount Amount", Value, 9); + PathPrefixTxt + '/Items/InvoiceLine/ArticleCode': + PurchaseLine."No." := CopyStr(Value, 1, MaxStrLen(PurchaseLine."No.")); + PathPrefixTxt + '/Items/InvoiceLine/UnitPriceWithoutTax': + if Value <> '' then + Evaluate(PurchaseLine."Direct Unit Cost", Value, 9); + PathPrefixTxt + '/Items/InvoiceLine/TransactionDate': + if Value <> '' then + Evaluate(PurchaseLine."Order Date", Value, 9); + end; + end; + + local procedure GetNodeByPath(var TempXMLBuffer: Record "XML Buffer" temporary; XPath: Text): Text + begin + TempXMLBuffer.Reset(); + TempXMLBuffer.SetRange(Type, TempXMLBuffer.Type::Element); + TempXMLBuffer.SetRange(Path, XPath); + + if TempXMLBuffer.FindFirst() then + exit(TempXMLBuffer.Value); + end; + + local procedure TryGetUOMCodeFromInternationalCode(TextValue: Text): Code[10] + var + UnitOfMeasure: Record "Unit of Measure"; + Code: Integer; + begin + if TextValue = '' then + exit(''); + + Evaluate(Code, TextValue, 9); + UnitOfMeasure.SetRange("International Standard Code", Enum::"Factura-E Units of Measure".Names().Get(Code)); + if UnitOfMeasure.FindFirst() then + exit(UnitOfMeasure.Code); + end; + + [IntegrationEvent(false, false)] + local procedure OnAfterParseBasicInfo(var EDocument: Record "E-Document"; var TempBlob: Codeunit "Temp Blob") + begin + end; + + [IntegrationEvent(false, false)] + local procedure OnAfterParseCompleteInfo(var EDocument: Record "E-Document"; var PurchaseHeader: Record "Purchase Header" temporary; var PurchaseLine: Record "Purchase Line" temporary; var TempBlob: Codeunit "Temp Blob") + begin + end; +} \ No newline at end of file diff --git a/Apps/ES/EDocumentFormats/FacturaE/app/src/Data/FacturaECountries.Codeunit.al b/Apps/ES/EDocumentFormats/FacturaE/app/src/Data/FacturaECountries.Codeunit.al new file mode 100644 index 0000000000..ab2bfa0952 --- /dev/null +++ b/Apps/ES/EDocumentFormats/FacturaE/app/src/Data/FacturaECountries.Codeunit.al @@ -0,0 +1,512 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.eServices.EDocument.Format; + +codeunit 10773 "Factura-E Countries" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure Convert2LetterCountryCodeTo3LetterCountryCode(CountryCode: Code[10]): Text[3] + begin + case CountryCode of + 'AD': + exit('AND'); + 'AE': + exit('ARE'); + 'AF': + exit('AFG'); + 'AG': + exit('ATG'); + 'AI': + exit('AIA'); + 'AL': + exit('ALB'); + 'AM': + exit('ARM'); + 'AO': + exit('AGO'); + 'AQ': + exit('ATA'); + 'AR': + exit('ARG'); + 'AS': + exit('ASM'); + 'AT': + exit('AUT'); + 'AU': + exit('AUS'); + 'AW': + exit('ABW'); + 'AX': + exit('ALA'); + 'AZ': + exit('AZE'); + 'BA': + exit('BIH'); + 'BB': + exit('BRB'); + 'BD': + exit('BGD'); + 'BE': + exit('BEL'); + 'BF': + exit('BFA'); + 'BG': + exit('BGR'); + 'BH': + exit('BHR'); + 'BI': + exit('BDI'); + 'BJ': + exit('BEN'); + 'BL': + exit('BLM'); + 'BM': + exit('BMU'); + 'BN': + exit('BRN'); + 'BO': + exit('BOL'); + 'BQ': + exit('BES'); + 'BR': + exit('BRA'); + 'BS': + exit('BHS'); + 'BT': + exit('BTN'); + 'BV': + exit('BVT'); + 'BW': + exit('BWA'); + 'BY': + exit('BLR'); + 'BZ': + exit('BLZ'); + 'CA': + exit('CAN'); + 'CC': + exit('CCK'); + 'CD': + exit('COD'); + 'CF': + exit('CAF'); + 'CG': + exit('COG'); + 'CH': + exit('CHE'); + 'CI': + exit('CIV'); + 'CK': + exit('COK'); + 'CL': + exit('CHL'); + 'CM': + exit('CMR'); + 'CN': + exit('CHN'); + 'CO': + exit('COL'); + 'CR': + exit('CRI'); + 'CU': + exit('CUB'); + 'CV': + exit('CPV'); + 'CW': + exit('CUW'); + 'CX': + exit('CXR'); + 'CY': + exit('CYP'); + 'CZ': + exit('CZE'); + 'DE': + exit('DEU'); + 'DJ': + exit('DJI'); + 'DK': + exit('DNK'); + 'DM': + exit('DMA'); + 'DO': + exit('DOM'); + 'DZ': + exit('DZA'); + 'EC': + exit('ECU'); + 'EE': + exit('EST'); + 'EG': + exit('EGY'); + 'EH': + exit('ESH'); + 'ER': + exit('ERI'); + 'ES': + exit('ESP'); + 'ET': + exit('ETH'); + 'FI': + exit('FIN'); + 'FJ': + exit('FJI'); + 'FK': + exit('FLK'); + 'FM': + exit('FSM'); + 'FO': + exit('FRO'); + 'FR': + exit('FRA'); + 'GA': + exit('GAB'); + 'GB': + exit('GBR'); + 'GD': + exit('GRD'); + 'GE': + exit('GEO'); + 'GF': + exit('GUF'); + 'GG': + exit('GGY'); + 'GH': + exit('GHA'); + 'GI': + exit('GIB'); + 'GL': + exit('GRL'); + 'GM': + exit('GMB'); + 'GN': + exit('GIN'); + 'GP': + exit('GLP'); + 'GQ': + exit('GNQ'); + 'GR': + exit('GRC'); + 'GS': + exit('SGS'); + 'GT': + exit('GTM'); + 'GU': + exit('GUM'); + 'GW': + exit('GNB'); + 'GY': + exit('GUY'); + 'HK': + exit('HKG'); + 'HM': + exit('HMD'); + 'HN': + exit('HND'); + 'HR': + exit('HRV'); + 'HT': + exit('HTI'); + 'HU': + exit('HUN'); + 'ID': + exit('IDN'); + 'IE': + exit('IRL'); + 'IL': + exit('ISR'); + 'IM': + exit('IMN'); + 'IN': + exit('IND'); + 'IO': + exit('IOT'); + 'IQ': + exit('IRQ'); + 'IR': + exit('IRN'); + 'IS': + exit('ISL'); + 'IT': + exit('ITA'); + 'JE': + exit('JEY'); + 'JM': + exit('JAM'); + 'JO': + exit('JOR'); + 'JP': + exit('JPN'); + 'KE': + exit('KEN'); + 'KG': + exit('KGZ'); + 'KH': + exit('KHM'); + 'KI': + exit('KIR'); + 'KM': + exit('COM'); + 'KN': + exit('KNA'); + 'KP': + exit('PRK'); + 'KR': + exit('KOR'); + 'KW': + exit('KWT'); + 'KY': + exit('CYM'); + 'KZ': + exit('KAZ'); + 'LA': + exit('LAO'); + 'LB': + exit('LBN'); + 'LC': + exit('LCA'); + 'LI': + exit('LIE'); + 'LK': + exit('LKA'); + 'LR': + exit('LBR'); + 'LS': + exit('LSO'); + 'LT': + exit('LTU'); + 'LU': + exit('LUX'); + 'LV': + exit('LVA'); + 'LY': + exit('LBY'); + 'MA': + exit('MAR'); + 'MC': + exit('MCO'); + 'MD': + exit('MDA'); + 'ME': + exit('MNE'); + 'MF': + exit('MAF'); + 'MG': + exit('MDG'); + 'MH': + exit('MHL'); + 'MK': + exit('MKD'); + 'ML': + exit('MLI'); + 'MM': + exit('MMR'); + 'MN': + exit('MNG'); + 'MO': + exit('MAC'); + 'MP': + exit('MNP'); + 'MQ': + exit('MTQ'); + 'MR': + exit('MRT'); + 'MS': + exit('MSR'); + 'MT': + exit('MLT'); + 'MU': + exit('MUS'); + 'MV': + exit('MDV'); + 'MW': + exit('MWI'); + 'MX': + exit('MEX'); + 'MY': + exit('MYS'); + 'MZ': + exit('MOZ'); + 'NA': + exit('NAM'); + 'NC': + exit('NCL'); + 'NE': + exit('NER'); + 'NF': + exit('NFK'); + 'NG': + exit('NGA'); + 'NI': + exit('NIC'); + 'NL': + exit('NLD'); + 'NO': + exit('NOR'); + 'NP': + exit('NPL'); + 'NR': + exit('NRU'); + 'NU': + exit('NIU'); + 'NZ': + exit('NZL'); + 'OM': + exit('OMN'); + 'PA': + exit('PAN'); + 'PE': + exit('PER'); + 'PF': + exit('PYF'); + 'PG': + exit('PNG'); + 'PH': + exit('PHL'); + 'PK': + exit('PAK'); + 'PL': + exit('POL'); + 'PM': + exit('SPM'); + 'PN': + exit('PCN'); + 'PR': + exit('PRI'); + 'PT': + exit('PRT'); + 'PW': + exit('PLW'); + 'PY': + exit('PRY'); + 'QA': + exit('QAT'); + 'RE': + exit('REU'); + 'RO': + exit('ROU'); + 'RS': + exit('SRB'); + 'RU': + exit('RUS'); + 'RW': + exit('RWA'); + 'SA': + exit('SAU'); + 'SB': + exit('SLB'); + 'SC': + exit('SYC'); + 'SD': + exit('SDN'); + 'SE': + exit('SWE'); + 'SG': + exit('SGP'); + 'SH': + exit('SHN'); + 'SI': + exit('SVN'); + 'SJ': + exit('SJM'); + 'SK': + exit('SVK'); + 'SL': + exit('SLE'); + 'SM': + exit('SMR'); + 'SN': + exit('SEN'); + 'SO': + exit('SOM'); + 'SR': + exit('SUR'); + 'SS': + exit('SSD'); + 'ST': + exit('STP'); + 'SV': + exit('SLV'); + 'SX': + exit('SXM'); + 'SY': + exit('SYR'); + 'SZ': + exit('SWZ'); + 'TC': + exit('TCA'); + 'TD': + exit('TCD'); + 'TF': + exit('ATF'); + 'TG': + exit('TGO'); + 'TH': + exit('THA'); + 'TJ': + exit('TJK'); + 'TK': + exit('TKL'); + 'TL': + exit('TLS'); + 'TM': + exit('TKM'); + 'TN': + exit('TUN'); + 'TO': + exit('TON'); + 'TR': + exit('TUR'); + 'TT': + exit('TTO'); + 'TV': + exit('TUV'); + 'TZ': + exit('TZA'); + 'UA': + exit('UKR'); + 'UG': + exit('UGA'); + 'UM': + exit('UMI'); + 'US': + exit('USA'); + 'UY': + exit('URY'); + 'UZ': + exit('UZB'); + 'VA': + exit('VAT'); + 'VC': + exit('VCT'); + 'VE': + exit('VEN'); + 'VG': + exit('VGB'); + 'VI': + exit('VIR'); + 'VN': + exit('VNM'); + 'VU': + exit('VUT'); + 'WF': + exit('WLF'); + 'WS': + exit('WSM'); + 'YE': + exit('YEM'); + 'YT': + exit('MYT'); + 'ZA': + exit('ZAF'); + 'ZM': + exit('ZMB'); + 'ZW': + exit('ZWE'); + end; + end; +} \ No newline at end of file diff --git a/Apps/ES/EDocumentFormats/FacturaE/app/src/Data/FacturaECrMemoReason.Enum.al b/Apps/ES/EDocumentFormats/FacturaE/app/src/Data/FacturaECrMemoReason.Enum.al new file mode 100644 index 0000000000..ccf3d66b08 --- /dev/null +++ b/Apps/ES/EDocumentFormats/FacturaE/app/src/Data/FacturaECrMemoReason.Enum.al @@ -0,0 +1,98 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.eServices.EDocument.Format; + +enum 10772 "Factura-E Cr. Memo Reason" +{ + value(1; "01") + { + Caption = '01 Número de la factura', Locked = true; + } + value(2; "02") + { + Caption = '02 Serie de la factura', Locked = true; + } + value(3; "03") + { + Caption = '03 Fecha expedición', Locked = true; + } + value(4; "04") + { + Caption = '04 Nombre y apellidos/Razón social - Emisor', Locked = true; + } + value(5; "05") + { + Caption = '05 Nombre y apellidos/Razón social - Receptor', Locked = true; + } + value(6; "06") + { + Caption = '06 Identificación fiscal Emisor/Obligado', Locked = true; + } + value(7; "07") + { + Caption = '07 Identificación fiscal Receptor', Locked = true; + } + value(8; "08") + { + Caption = '08 Domicilio Emisor/Obligado', Locked = true; + } + value(9; "09") + { + Caption = '09 Domicilio Receptor', Locked = true; + } + value(10; "10") + { + Caption = '10 Detalle Operación', Locked = true; + } + value(11; "11") + { + Caption = '11 Porcentaje impositivo a aplicar', Locked = true; + } + value(12; "12") + { + Caption = '12 Cuota tributaria a aplicar', Locked = true; + } + value(13; "13") + { + Caption = '13 Fecha/Periodo a aplicar', Locked = true; + } + value(14; "14") + { + Caption = '14 Clase de factura', Locked = true; + } + value(15; "15") + { + Caption = '15 Literales legales', Locked = true; + } + value(16; "16") + { + Caption = '16 Base imponible', Locked = true; + } + value(80; "80") + { + Caption = '80 Cálculo de cuotas repercutidas', Locked = true; + } + value(81; "81") + { + Caption = '81 Cálculo de cuotas retenidas', Locked = true; + } + value(82; "82") + { + Caption = '82 Base imponible modificada por devolución de envases/embalajes', Locked = true; + } + value(83; "83") + { + Caption = '83 Base imponible modificada por descuentos y bonificaciones', Locked = true; + } + value(84; "84") + { + Caption = '84 Base imponible modificada por resolución firme judicial o administrativa', Locked = true; + } + value(85; "85") + { + Caption = '85 Base imponible modificada cuotas repercutidas no satisfechas. Auto de declaración de concurso', Locked = true; + + } +} \ No newline at end of file diff --git a/Apps/ES/EDocumentFormats/FacturaE/app/src/Data/FacturaEUnitsOfMeasure.Enum.al b/Apps/ES/EDocumentFormats/FacturaE/app/src/Data/FacturaEUnitsOfMeasure.Enum.al new file mode 100644 index 0000000000..8ba89efd15 --- /dev/null +++ b/Apps/ES/EDocumentFormats/FacturaE/app/src/Data/FacturaEUnitsOfMeasure.Enum.al @@ -0,0 +1,120 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.eServices.EDocument.Format; + +enum 10773 "Factura-E Units of Measure" +{ + value(0; None) + { + } + value(1; Units) + { + } + value(2; HUR) + { + } + value(3; KGM) + { + } + value(4; LTR) + { + } + value(5; Other) + { + } + value(6; BX) + { + } + value(7; DS) + { + } + value(8; BA) + { + } + value(9; JY) + { + } + value(10; BG) + { + } + value(11; CO) + { + } + value(12; BO) + { + } + value(13; CI) + { + } + value(14; TetraBriks) + { + } + value(15; CLT) + { + } + value(16; CMT) + { + } + value(17; BI) + { + } + value(18; Dozens) + { + } + value(19; CS) + { + } + value(20; DJ) + { + } + value(21; GRM) + { + } + value(22; KMT) + { + } + value(23; CA) + { + } + value(24; BH) + { + } + value(25; MTR) + { + } + value(26; MMT) + { + } + value(27; SixPacks) + { + } + value(28; PK) + { + } + value(29; Portions) + { + } + value(30; RO) + { + } + value(31; EN) + { + } + value(32; TB) + { + } + value(33; MTQ) + { + } + value(34; SEC) + { + } + value(35; WTT) + { + } + value(36; KWh) + { + } +} \ No newline at end of file diff --git a/Apps/ES/EDocumentFormats/FacturaE/app/src/Extensions/FacturaEPostedSCrMemo.PageExt.al b/Apps/ES/EDocumentFormats/FacturaE/app/src/Extensions/FacturaEPostedSCrMemo.PageExt.al new file mode 100644 index 0000000000..bd0c4c9df4 --- /dev/null +++ b/Apps/ES/EDocumentFormats/FacturaE/app/src/Extensions/FacturaEPostedSCrMemo.PageExt.al @@ -0,0 +1,23 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.eServices.EDocument.Format; + +using Microsoft.Sales.History; + +pageextension 10773 "Factura-E Posted S. Cr. Memo" extends "Posted Sales Credit Memo" +{ + layout + { + addafter("Customer Posting Group") + { + field("Factura-E Reason Code"; Rec."Factura-E Reason Code") + { + ApplicationArea = Basic, Suite; + Importance = Additional; + ToolTip = 'Specifies the Factura-E reason code for the credit memo.'; + } + } + } +} \ No newline at end of file diff --git a/Apps/ES/EDocumentFormats/FacturaE/app/src/Extensions/FacturaESalesCrMemoHeader.TableExt.al b/Apps/ES/EDocumentFormats/FacturaE/app/src/Extensions/FacturaESalesCrMemoHeader.TableExt.al new file mode 100644 index 0000000000..f7b71b8404 --- /dev/null +++ b/Apps/ES/EDocumentFormats/FacturaE/app/src/Extensions/FacturaESalesCrMemoHeader.TableExt.al @@ -0,0 +1,19 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.eServices.EDocument.Format; + +using Microsoft.Sales.History; + +tableextension 10772 "Factura-E Sales Cr.Memo Header" extends "Sales Cr.Memo Header" +{ + fields + { + field(10772; "Factura-E Reason Code"; Enum "Factura-E Cr. Memo Reason") + { + Caption = 'Factura-E Reason Code'; + DataClassification = CustomerContent; + } + } +} \ No newline at end of file diff --git a/Apps/ES/EDocumentFormats/FacturaE/app/src/Extensions/FacturaESalesCreditMemo.PageExt.al b/Apps/ES/EDocumentFormats/FacturaE/app/src/Extensions/FacturaESalesCreditMemo.PageExt.al new file mode 100644 index 0000000000..c7aacf9fa9 --- /dev/null +++ b/Apps/ES/EDocumentFormats/FacturaE/app/src/Extensions/FacturaESalesCreditMemo.PageExt.al @@ -0,0 +1,23 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.eServices.EDocument.Format; + +using Microsoft.Sales.Document; + +pageextension 10772 "Factura-E Sales Credit Memo" extends "Sales Credit Memo" +{ + layout + { + addafter("Shipment Date") + { + field("Factura-E Reason Code"; Rec."Factura-E Reason Code") + { + ApplicationArea = Basic, Suite; + Importance = Additional; + ToolTip = 'Specifies the Factura-E reason code for the credit memo.'; + } + } + } +} \ No newline at end of file diff --git a/Apps/ES/EDocumentFormats/FacturaE/app/src/Extensions/FacturaESalesHeader.TableExt.al b/Apps/ES/EDocumentFormats/FacturaE/app/src/Extensions/FacturaESalesHeader.TableExt.al new file mode 100644 index 0000000000..2d52ca68d7 --- /dev/null +++ b/Apps/ES/EDocumentFormats/FacturaE/app/src/Extensions/FacturaESalesHeader.TableExt.al @@ -0,0 +1,19 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.eServices.EDocument.Format; + +using Microsoft.Sales.Document; + +tableextension 10773 "Factura-E Sales Header" extends "Sales Header" +{ + fields + { + field(10772; "Factura-E Reason Code"; Enum "Factura-E Cr. Memo Reason") + { + Caption = 'Factura-E Reason Code'; + DataClassification = CustomerContent; + } + } +} \ No newline at end of file diff --git a/Apps/ES/EDocumentFormats/FacturaE/test/ExtensionLogo.png b/Apps/ES/EDocumentFormats/FacturaE/test/ExtensionLogo.png new file mode 100644 index 0000000000..4d2c9a626c Binary files /dev/null and b/Apps/ES/EDocumentFormats/FacturaE/test/ExtensionLogo.png differ diff --git a/Apps/ES/EDocumentFormats/FacturaE/test/app.json b/Apps/ES/EDocumentFormats/FacturaE/test/app.json new file mode 100644 index 0000000000..e52789e8ba --- /dev/null +++ b/Apps/ES/EDocumentFormats/FacturaE/test/app.json @@ -0,0 +1,61 @@ +{ + "id": "8238f78b-cbe5-4b9c-b247-7771145b7470", + "name": "E-Document Format for Factura-E Tests", + "publisher": "Microsoft", + "brief": "E-Document Format for Factura-E Tests.", + "description": "Tests for E-Document Format for Factura-E.", + "version": "26.0.0.0", + "privacyStatement": "https://go.microsoft.com/fwlink/?LinkId=724009", + "EULA": "https://go.microsoft.com/fwlink/?linkid=2009120", + "help": "https://go.microsoft.com/fwlink/?linkid=2299409", + "url": "https://go.microsoft.com/fwlink/?LinkId=724011", + "contextSensitiveHelpUrl": "https://go.microsoft.com/fwlink/?linkid=2299409", + "logo": "ExtensionLogo.png", + "dependencies": [ + { + "id": "e1d97edc-c239-46b4-8d84-6368bdf67c8b", + "name": "E-Document Core", + "publisher": "Microsoft", + "version": "26.0.0.0" + }, + { + "id": "5d86850b-0d76-4eca-bd7b-951ad998e997", + "name": "Tests-TestLibraries", + "publisher": "Microsoft", + "version": "26.0.0.0" + }, + { + "id": "9856ae4f-d1a7-46ef-89bb-6ef056398228", + "name": "System Application Test Library", + "publisher": "Microsoft", + "version": "26.0.0.0" + }, + { + "id": "5095f467-0a01-4b99-99d1-9ff1237d286f", + "publisher": "Microsoft", + "name": "Library Variable Storage", + "version": "26.0.0.0" + }, + { + "id": "8238f99b-cbe5-4b9c-b247-7771145b7470", + "name": "E-Document Format for Factura-E", + "publisher": "Microsoft", + "version": "26.0.0.0" + } + ], + "screenshots": [], + "platform": "26.0.0.0", + "features": ["TranslationFile"], + "idRanges": [ + { + "from": 148001, + "to": 148002 + } + ], + "resourceExposurePolicy": { + "allowDebugging": true, + "allowDownloadingSource": true, + "includeSourceInSymbolFile": true + }, + "application": "26.0.0.0" +} \ No newline at end of file diff --git a/Apps/ES/EDocumentFormats/FacturaE/test/src/FacturaEXML.Codeunit.al b/Apps/ES/EDocumentFormats/FacturaE/test/src/FacturaEXML.Codeunit.al new file mode 100644 index 0000000000..a517b95224 --- /dev/null +++ b/Apps/ES/EDocumentFormats/FacturaE/test/src/FacturaEXML.Codeunit.al @@ -0,0 +1,501 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.eServices.EDocument.Format; + +using Microsoft.eServices.EDocument; +using Microsoft.Foundation.Company; +using Microsoft.Sales.Customer; +using Microsoft.Sales.Document; +using Microsoft.Sales.History; +using System.IO; +using System.Utilities; + +codeunit 148001 "Factura-E XML" +{ + Subtype = Test; + + var + Assert: Codeunit Assert; + LibraryERM: Codeunit "Library - ERM"; + LibraryRandom: Codeunit "Library - Random"; + LibrarySales: Codeunit "Library - Sales"; + LibraryTestInitialize: Codeunit "Library - Test Initialize"; + FacturaE: Codeunit "Factura-E"; + IsInitialized: Boolean; + WrongValueForPathErr: Label 'Wrong value for path %1', Locked = true; + + [Test] + procedure ExportInvoice_SellerNode() + var + SalesHeader: Record "Sales Header"; + SalesInvoiceHeader: Record "Sales Invoice Header"; + SalesInvoiceLine: Record "Sales Invoice Line"; + Customer: Record Customer; + CompanyInformation: Record "Company Information"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [SCENARIO] Export invoice with Seller data + Initialize(); + + // [GIVEN] Seller and buyer exist + CompanyInformation.Get(); + LibrarySales.CreateCustomerWithAddressAndContactInfo(Customer); + + // [GIVEN] Create invoice for customer + LibrarySales.CreateSalesInvoiceForCustomerNo(SalesHeader, Customer."No."); + SalesInvoiceHeader.Get(LibrarySales.PostSalesDocument(SalesHeader, false, true)); + + // [WHEN] Export invoice + ExportInvoice(SalesInvoiceHeader, SalesInvoiceLine, TempXMLBuffer); + + // [THEN] Seller Data has been exported correctly + VerifySeller(TempXMLBuffer, CompanyInformation); + end; + + [Test] + procedure ExportInvoice_BuyerNode() + var + SalesHeader: Record "Sales Header"; + SalesInvoiceHeader: Record "Sales Invoice Header"; + SalesInvoiceLine: Record "Sales Invoice Line"; + Customer: Record Customer; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [SCENARIO] Export invoice with Buyer data + Initialize(); + + // [GIVEN] Buyer with contact data exists + LibrarySales.CreateCustomerWithAddressAndContactInfo(Customer); + + // [GIVEN] Create invoice for customer + LibrarySales.CreateSalesInvoiceForCustomerNo(SalesHeader, Customer."No."); + SalesInvoiceHeader.Get(LibrarySales.PostSalesDocument(SalesHeader, false, true)); + + // [WHEN] Export invoice + ExportInvoice(SalesInvoiceHeader, SalesInvoiceLine, TempXMLBuffer); + + // [THEN] Buyer Data has been exported correctly + VerifyBuyer(TempXMLBuffer, Customer); + end; + + [Test] + procedure ExportInvoice_FileHeader() + var + SalesHeader: Record "Sales Header"; + SalesLine: Record "Sales Line"; + SalesInvoiceHeader: Record "Sales Invoice Header"; + SalesInvoiceLine: Record "Sales Invoice Line"; + Customer: Record Customer; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [SCENARIO] Export invoice with FileHeader data + Initialize(); + + // [GIVEN] Buyer with contact data exists + LibrarySales.CreateCustomerWithAddressAndContactInfo(Customer); + + // [GIVEN] Create invoice for customer with a line + CreateSalesInvoiceWithExtraLines(SalesHeader, SalesLine, SalesInvoiceHeader, SalesInvoiceLine, Customer, 0); + + // [WHEN] Export invoice + ExportInvoice(SalesInvoiceHeader, SalesInvoiceLine, TempXMLBuffer); + + // [THEN] FileHeader Data has been exported correctly + VerifyFileHeader(TempXMLBuffer, SalesInvoiceHeader); + end; + + [Test] + procedure ExportInvoice_InvoiceLines() + var + SalesHeader: Record "Sales Header"; + SalesLine: Record "Sales Line"; + SalesInvoiceHeader: Record "Sales Invoice Header"; + SalesInvoiceLine: Record "Sales Invoice Line"; + Customer: Record Customer; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [SCENARIO] Export invoice with Invoices lines data + Initialize(); + + // [GIVEN] Buyer with contact data exists + LibrarySales.CreateCustomerWithAddressAndContactInfo(Customer); + + // [GIVEN] Create invoice for customer with a line + CreateSalesInvoiceWithExtraLines(SalesHeader, SalesLine, SalesInvoiceHeader, SalesInvoiceLine, Customer, 0); + + // [WHEN] Export invoice + ExportInvoice(SalesInvoiceHeader, SalesInvoiceLine, TempXMLBuffer); + + // [THEN] Invoice Lines Node has been exported correctly + VerifyInvoiceLine(TempXMLBuffer, SalesInvoiceLine); + end; + + [Test] + procedure ExportInvoice_InvoiceHeader() + var + SalesHeader: Record "Sales Header"; + SalesLine: Record "Sales Line"; + SalesInvoiceHeader: Record "Sales Invoice Header"; + SalesInvoiceLine: Record "Sales Invoice Line"; + Customer: Record Customer; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [SCENARIO] Export invoice with Invoice header data + Initialize(); + + // [GIVEN] Buyer with contact data exists + LibrarySales.CreateCustomerWithAddressAndContactInfo(Customer); + + // [GIVEN] Create invoice for customer with a line + CreateSalesInvoiceWithExtraLines(SalesHeader, SalesLine, SalesInvoiceHeader, SalesInvoiceLine, Customer, 0); + + // [WHEN] Export invoice + ExportInvoice(SalesInvoiceHeader, SalesInvoiceLine, TempXMLBuffer); + + // [THEN] Invoice Header Node has been exported correctly + VerifyInvoiceHeader(TempXMLBuffer, SalesInvoiceHeader); + end; + + [Test] + procedure ExportInvoice_MultipleInvoiceLines() + var + SalesHeader: Record "Sales Header"; + SalesLine: Record "Sales Line"; + SalesInvoiceHeader: Record "Sales Invoice Header"; + SalesInvoiceLine: Record "Sales Invoice Line"; + Customer: Record Customer; + TempXMLBuffer: Record "XML Buffer" temporary; + NumberOfLines: Integer; + begin + // [SCENARIO] Export invoice with alot of Invoice lines + Initialize(); + + // [GIVEN] Buyer with contact data exists + LibrarySales.CreateCustomerWithAddressAndContactInfo(Customer); + + // [GIVEN] Create invoice for customer with a lot of lines + NumberOfLines := LibraryRandom.RandIntInRange(10, 20); + CreateSalesInvoiceWithExtraLines(SalesHeader, SalesLine, SalesInvoiceHeader, SalesInvoiceLine, Customer, NumberOfLines); + + // [WHEN] Export invoice + ExportInvoice(SalesInvoiceHeader, SalesInvoiceLine, TempXMLBuffer); + + // [THEN] Verify number of lines in the file + VerifyNumberOfLines(TempXMLBuffer, NumberOfLines + 1); + end; + + [Test] + procedure ExportCreditMemo_Error() + var + SalesHeader: Record "Sales Header"; + SalesLine: Record "Sales Line"; + SalesCrMemoHeader: Record "Sales Cr.Memo Header"; + SalesCrMemoLine: Record "Sales Cr.Memo Line"; + Customer: Record Customer; + begin + // [SCENARIO] Export credit memo fails because reason code is not set + Initialize(); + + // [GIVEN] Buyer with contact data exists + LibrarySales.CreateCustomerWithAddressAndContactInfo(Customer); + + // [GIVEN] Create Credit memo for customer with a line + CreateSalesCreditMemoWithExtraLines(SalesHeader, SalesLine, SalesCrMemoHeader, SalesCrMemoLine, Customer, 0); + + // [WHEN] Check invoice before export + asserterror CheckCreditMemo(SalesCrMemoHeader); + + // [THEN] Check failed because reason code is not set + Assert.ExpectedErrorCode('TestField'); + end; + + [Test] + procedure ExportCreditMemo_NoError() + var + SalesHeader: Record "Sales Header"; + SalesCrMemoHeader: Record "Sales Cr.Memo Header"; + SalesCrMemoLine: Record "Sales Cr.Memo Line"; + Customer: Record Customer; + begin + // [SCENARIO] Export credit memo is successful when reason code is set + Initialize(); + + // [GIVEN] Buyer with contact data exists + LibrarySales.CreateCustomerWithAddressAndContactInfo(Customer); + + // [GIVEN] Create Credit memo for customer with a line + LibrarySales.CreateSalesCreditMemoForCustomerNo(SalesHeader, Customer."No."); + + // [GIVEN] Set reason code in Credit Memo + SalesHeader."Factura-E Reason Code" := SalesCrMemoHeader."Factura-E Reason Code"::"01"; + SalesHeader.Modify(true); + + // [GIVEN] Post Credit memo + SalesCrMemoHeader.Get(LibrarySales.PostSalesDocument(SalesHeader, true, true)); + SalesCrMemoLine.SetRange("Document No.", SalesCrMemoLine."No."); + + // [WHEN] Check credit memo before export + CheckCreditMemo(SalesCrMemoHeader); + + // [THEN] Check is successful + end; + + [Test] + procedure ExportCreditMemo_CorrectiveNode() + var + SalesHeader: Record "Sales Header"; + SalesCrMemoHeader: Record "Sales Cr.Memo Header"; + SalesCrMemoLine: Record "Sales Cr.Memo Line"; + Customer: Record Customer; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [SCENARIO] Export credit memo and check Corrective node + Initialize(); + + // [GIVEN] Buyer with contact data exists + LibrarySales.CreateCustomerWithAddressAndContactInfo(Customer); + + // [GIVEN] Create Credit memo for customer with a line + LibrarySales.CreateSalesCreditMemoForCustomerNo(SalesHeader, Customer."No."); + + // [GIVEN] Set reason code in Credit Memo + SalesHeader."Factura-E Reason Code" := SalesCrMemoHeader."Factura-E Reason Code"::"01"; + SalesHeader.Modify(true); + + // [GIVEN] Post Credit memo + SalesCrMemoHeader.Get(LibrarySales.PostSalesDocument(SalesHeader, true, true)); + SalesCrMemoLine.SetRange("Document No.", SalesCrMemoLine."No."); + + // [WHEN] Export credit memo + ExportCreditMemo(SalesCrMemoHeader, SalesCrMemoLine, TempXMLBuffer); + + // [THEN] Check Corrective node + VerifyCorrectiveNode(TempXMLBuffer, SalesCrMemoHeader); + end; + + local procedure Initialize() + begin + LibraryTestInitialize.OnTestInitialize(Codeunit::"Factura-E XML"); + if not IsInitialized then begin + LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Factura-E XML"); + IsInitialized := true; + + LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::"Factura-E XML"); + end; + end; + + local procedure CreateSalesInvoiceWithExtraLines(var SalesHeader: Record "Sales Header"; var SalesLine: Record "Sales Line"; var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesInvoiceLine: Record "Sales Invoice Line"; Customer: Record "Customer"; ExtraLines: Integer) + var + i: Integer; + begin + LibrarySales.CreateSalesInvoiceForCustomerNo(SalesHeader, Customer."No."); + for i := 1 to ExtraLines do + AddLineToSalesHeader(SalesHeader, SalesLine); + SalesInvoiceHeader.Get(LibrarySales.PostSalesDocument(SalesHeader, false, true)); + SalesInvoiceLine.SetRange("Document No.", SalesInvoiceHeader."No."); + SalesInvoiceLine.FindSet(); + end; + + local procedure CreateSalesCreditMemoWithExtraLines(var SalesHeader: Record "Sales Header"; var SalesLine: Record "Sales Line"; var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; var SalesCrMemoLine: Record "Sales Cr.Memo Line"; Customer: Record "Customer"; ExtraLines: Integer) + var + i: Integer; + begin + LibrarySales.CreateSalesCreditMemoForCustomerNo(SalesHeader, Customer."No."); + for i := 1 to ExtraLines do + AddLineToSalesHeader(SalesHeader, SalesLine); + SalesCrMemoHeader.Get(LibrarySales.PostSalesDocument(SalesHeader, true, true)); + SalesCrMemoLine.SetRange("Document No.", SalesCrMemoLine."No."); + end; + + local procedure AddLineToSalesHeader(var SalesHeader: Record "Sales Header"; var SalesLine: Record "Sales Line") + var + GLAccountNo: Code[20]; + begin + GLAccountNo := LibraryERM.CreateGLAccountWithSalesSetup(); + LibrarySales.CreateSalesLine(SalesLine, SalesHeader, SalesLine.Type::"G/L Account", GLAccountNo, LibraryRandom.RandInt(10)); + SalesLine.Validate("Unit Price", -LibraryRandom.RandDec(100, 2)); + SalesLine.Modify(); + end; + + local procedure VerifySeller(var TempXMLBuffer: Record "XML Buffer" temporary; CompanyInformation: Record "Company Information") + var + SellerPrefixTok: Label '/namespace:Facturae/Parties/SellerParty', Locked = true; + Path: Text; + begin + // VAT Reg No + Path := SellerPrefixTok + '/TaxIdentification/TaxIdentificationNumber'; + Assert.AreEqual(CompanyInformation."VAT Registration No.", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(WrongValueForPathErr, Path)); + // Seller Name + Path := SellerPrefixTok + '/LegalEntity/CorporateName'; + Assert.AreEqual(CompanyInformation.Name, GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(WrongValueForPathErr, Path)); + // Contact info + Path := SellerPrefixTok + '/LegalEntity/ContactDetails/Telephone'; + Assert.AreEqual(CopyStr(CompanyInformation."Phone No.", 1, 15), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(WrongValueForPathErr, Path)); + end; + + local procedure VerifyBuyer(var TempXMLBuffer: Record "XML Buffer" temporary; Customer: Record "Customer") + var + BuyerPrefixTok: Label '/namespace:Facturae/Parties/BuyerParty', Locked = true; + Path: Text; + begin + // VAT Reg No + Path := BuyerPrefixTok + '/TaxIdentification/TaxIdentificationNumber'; + Assert.AreEqual(Customer."VAT Registration No.", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(WrongValueForPathErr, Path)); + // Seller Name + Path := BuyerPrefixTok + '/LegalEntity/CorporateName'; + Assert.AreEqual(Customer.Name, GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(WrongValueForPathErr, Path)); + // Contact info + Path := BuyerPrefixTok + '/LegalEntity/ContactDetails/Telephone'; + Assert.AreEqual(CopyStr(Customer."Phone No.", 1, 15), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(WrongValueForPathErr, Path)); + end; + + local procedure VerifyFileHeader(var TempXMLBuffer: Record "XML Buffer" temporary; SalesInvoiceHeader: Record "Sales Invoice Header") + var + FileHeaderTok: Label '/namespace:Facturae/FileHeader', Locked = true; + Amount: Decimal; + Path: Text; + begin + // Modality + Path := FileHeaderTok + '/Modality'; + Assert.AreEqual('I', GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(WrongValueForPathErr, Path)); + // Schema version + Path := FileHeaderTok + '/SchemaVersion'; + Assert.AreEqual('3.2.2', GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(WrongValueForPathErr, Path)); + // Invoice total + Path := FileHeaderTok + '/Batch/TotalInvoicesAmount/TotalAmount'; + SalesInvoiceHeader.CalcFields("Amount Including VAT"); + Evaluate(Amount, GetNodeByPathWithError(TempXMLBuffer, Path)); + Assert.AreEqual(SalesInvoiceHeader."Amount Including VAT", Amount, StrSubstNo(WrongValueForPathErr, Path)); + end; + + local procedure VerifyInvoiceLine(var TempXMLBuffer: Record "XML Buffer" temporary; SalesInvoiceLine: Record "Sales Invoice Line") + var + LineTok: Label '/namespace:Facturae/Invoices/Invoice/Items/InvoiceLine', Locked = true; + Amount: Decimal; + Path: Text; + begin + // Description + Path := LineTok + '/ItemDescription'; + Assert.AreEqual(SalesInvoiceLine.Description, GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(WrongValueForPathErr, Path)); + // Quantity + Path := LineTok + '/Quantity'; + Evaluate(Amount, GetNodeByPathWithError(TempXMLBuffer, Path)); + Assert.AreEqual(SalesInvoiceLine.Quantity, Amount, StrSubstNo(WrongValueForPathErr, Path)); + // Unit Price + Path := LineTok + '/UnitPriceWithoutTax'; + Evaluate(Amount, GetNodeByPathWithError(TempXMLBuffer, Path)); + Assert.AreEqual(SalesInvoiceLine."Unit Price", Amount, StrSubstNo(WrongValueForPathErr, Path)); + // Tax + Path := LineTok + '/TaxesOutputs/Tax/TaxAmount/TotalAmount'; + Evaluate(Amount, GetNodeByPathWithError(TempXMLBuffer, Path)); + Assert.AreEqual(SalesInvoiceLine."Amount Including VAT" - SalesInvoiceLine.Amount, Amount, StrSubstNo(WrongValueForPathErr, Path)); + end; + + local procedure VerifyInvoiceHeader(var TempXMLBuffer: Record "XML Buffer" temporary; SalesInvoiceHeader: Record "Sales Invoice Header") + var + InvoiceHeaderTok: Label '/namespace:Facturae/Invoices/Invoice', Locked = true; + Amount: Decimal; + Path: Text; + begin + // Invoice number + Path := InvoiceHeaderTok + '/InvoiceHeader/InvoiceNumber'; + Assert.AreEqual(SalesInvoiceHeader."No.", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(WrongValueForPathErr, Path)); + // Invoice date + Path := InvoiceHeaderTok + '/InvoiceIssueData/IssueDate'; + Assert.AreEqual(Format(SalesInvoiceHeader."Posting Date", 0, 9), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(WrongValueForPathErr, Path)); + // Tax + Path := InvoiceHeaderTok + '/TaxesOutputs/Tax/TaxAmount/TotalAmount'; + SalesInvoiceHeader.CalcFields("Amount Including VAT", Amount); + Evaluate(Amount, GetNodeByPathWithError(TempXMLBuffer, Path)); + Assert.AreEqual(SalesInvoiceHeader."Amount Including VAT" - SalesInvoiceHeader."Amount", Amount, StrSubstNo(WrongValueForPathErr, Path)); + // Executable amount + Path := InvoiceHeaderTok + '/InvoiceTotals/TotalExecutableAmount'; + Evaluate(Amount, GetNodeByPathWithError(TempXMLBuffer, Path)); + Assert.AreEqual(SalesInvoiceHeader."Amount Including VAT", Amount, StrSubstNo(WrongValueForPathErr, Path)); + end; + + local procedure VerifyNumberOfLines(var TempXMLBuffer: Record "XML Buffer" temporary; NumberOfLines: Integer) + var + InvoiceLineTok: Label '/namespace:Facturae/Invoices/Invoice/Items/InvoiceLine', Locked = true; + begin + TempXMLBuffer.Reset(); + TempXMLBuffer.SetRange(Type, TempXMLBuffer.Type::Element); + TempXMLBuffer.SetRange(Path, InvoiceLineTok); + Assert.AreEqual(NumberOfLines, TempXMLBuffer.Count, 'Wrong number of invoice lines'); + end; + + local procedure VerifyCorrectiveNode(var TempXMLBuffer: Record "XML Buffer" temporary; SalesCrMemoHeader: Record "Sales Cr.Memo Header") + var + CorrectiveTok: Label '/namespace:Facturae/Invoices/Invoice/InvoiceHeader/Corrective', Locked = true; + Path, Reason : Text; + begin + // Reason code + Path := CorrectiveTok + '/ReasonCode'; + Reason := GetNodeByPathWithError(TempXMLBuffer, Path); + Path := CorrectiveTok + '/ReasonDescription'; + Reason += ' ' + GetNodeByPathWithError(TempXMLBuffer, Path); + Assert.AreEqual(Format(SalesCrMemoHeader."Factura-E Reason Code"::"01"), Reason, StrSubstNo(WrongValueForPathErr, Path)); + // Correction Method + Path := CorrectiveTok + '/CorrectionMethod'; + Assert.AreEqual('02', GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(WrongValueForPathErr, Path)); + end; + + local procedure ExportInvoice(SalesInvoiceHeader: Record "Sales Invoice Header"; SalesInvoiceLine: Record "Sales Invoice Line"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + EDocumentService: Record "E-Document Service"; + EDocument: Record "E-Document"; + TempBlob: Codeunit "Temp Blob"; + SourceDocumentHeader: RecordRef; + SourceDocumentLines: RecordRef; + begin + SourceDocumentHeader.GetTable(SalesInvoiceHeader); + SourceDocumentLines.GetTable(SalesInvoiceLine); + FacturaE.Create(EDocumentService, EDocument, SourceDocumentHeader, SourceDocumentLines, TempBlob); + TempBlobToXMLBuffer(TempBlob, TempXMLBuffer); + end; + + local procedure ExportCreditMemo(SalesCrMemoHeader: Record "Sales Cr.Memo Header"; SalesCrMemoLine: Record "Sales Cr.Memo Line"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + EDocumentService: Record "E-Document Service"; + EDocument: Record "E-Document"; + TempBlob: Codeunit "Temp Blob"; + SourceDocumentHeader: RecordRef; + SourceDocumentLines: RecordRef; + begin + SourceDocumentHeader.GetTable(SalesCrMemoHeader); + SourceDocumentLines.GetTable(SalesCrMemoLine); + FacturaE.Create(EDocumentService, EDocument, SourceDocumentHeader, SourceDocumentLines, TempBlob); + TempBlobToXMLBuffer(TempBlob, TempXMLBuffer); + end; + + local procedure CheckCreditMemo(SalesCrMemoHeader: Record "Sales Cr.Memo Header") + var + EDocumentService: Record "E-Document Service"; + SourceDocumentHeader: RecordRef; + begin + SourceDocumentHeader.GetTable(SalesCrMemoHeader); + FacturaE.Check(SourceDocumentHeader, EDocumentService, Enum::"E-Document Processing Phase"::Create); + end; + + local procedure TempBlobToXMLBuffer(var TempBlob: Codeunit "Temp Blob"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + DocStream: InStream; + begin + TempXMLBuffer.DeleteAll(); + TempBlob.CreateInStream(DocStream); + TempXMLBuffer.LoadFromStream(DocStream); + end; + + local procedure GetNodeByPathWithError(var TempXMLBuffer: Record "XML Buffer" temporary; XPath: Text): Text + begin + TempXMLBuffer.Reset(); + TempXMLBuffer.SetRange(Type, TempXMLBuffer.Type::Element); + TempXMLBuffer.SetRange(Path, XPath); + + if TempXMLBuffer.FindFirst() then + exit(TempXMLBuffer.Value); + Error('Node not found: %1', XPath); + end; +} \ No newline at end of file diff --git a/Apps/IS/ContosoCoffeeDemoDatasetIS/app/DemoData/Bank/2.Master Data/CreateGenJournalLineIS.Codeunit.al b/Apps/IS/ContosoCoffeeDemoDatasetIS/app/DemoData/Bank/2.Master Data/CreateGenJournalLineIS.Codeunit.al deleted file mode 100644 index 78df619d98..0000000000 --- a/Apps/IS/ContosoCoffeeDemoDatasetIS/app/DemoData/Bank/2.Master Data/CreateGenJournalLineIS.Codeunit.al +++ /dev/null @@ -1,61 +0,0 @@ -codeunit 14626 "Create Gen. Journal Line IS" -{ - SingleInstance = true; - EventSubscriberInstance = Manual; - InherentEntitlements = X; - InherentPermissions = X; - trigger OnRun() - begin - UpdateGenJournalLine(); - UpdateBankAccReconciliationLine(); - end; - - [EventSubscriber(ObjectType::Table, Database::"Gen. Journal Line", 'OnBeforeInsertEvent', '', false, false)] - local procedure OnBeforeInsertGenJournalLine(var Rec: Record "Gen. Journal Line") - var - CreateGenJournalTemplate: Codeunit "Create Gen. Journal Template"; - CreateBankJnlBatch: Codeunit "Create Bank Jnl. Batches"; - begin - if (Rec."Journal Template Name" = CreateGenJournalTemplate.General()) and (Rec."Journal Batch Name" = CreateBankJnlBatch.Daily()) then - case Rec."Line No." of - 10000: - Rec.Validate(Amount, -178919.2); - 20000: - Rec.Validate(Amount, -268378.8); - 30000: - Rec.Validate(Amount, -357838.4); - 40000: - Rec.Validate(Amount, -357838.4); - end; - end; - - local procedure UpdateGenJournalLine() - var - GenJournalLine: Record "Gen. Journal Line"; - CreateGenJournalTemplate: Codeunit "Create Gen. Journal Template"; - CreateBankJnlBatch: Codeunit "Create Bank Jnl. Batches"; - begin - GenJournalLine.Get(CreateGenJournalTemplate.General(), CreateBankJnlBatch.Daily(), 10000); - if GenJournalLine."Account No." = '' then begin - GenJournalLine.Validate(Amount, 0); - GenJournalLine.Modify(true); - end; - end; - - local procedure UpdateBankAccReconciliationLine() - var - BankAccReconciliationLine: Record "Bank Acc. Reconciliation Line"; - BankAccount: Record "Bank Account"; - CreateBankAccount: Codeunit "Create Bank Account"; - begin - BankAccount.Get(CreateBankAccount.Checking()); - - BankAccReconciliationLine.Get(BankAccReconciliationLine."Statement Type"::"Bank Reconciliation", BankAccount."No.", BankAccount."Last Statement No.", 30000); - BankAccReconciliationLine.Validate("Transaction Text", DepositToAccountLbl); - BankAccReconciliationLine.Validate(Description, CopyStr(BankAccReconciliationLine."Transaction Text", 1, MaxStrLen(BankAccReconciliationLine.Description))); - BankAccReconciliationLine.Modify(true); - end; - - var - DepositToAccountLbl: Label 'Deposit to Account 18.01.24', MaxLength = 100; -} \ No newline at end of file diff --git a/Apps/IS/ContosoCoffeeDemoDatasetIS/app/DemoData/FA/1.Setup Data/CreateFAInsJnlTemplateIS.Codeunit.al b/Apps/IS/ContosoCoffeeDemoDatasetIS/app/DemoData/FA/1.Setup Data/CreateFAInsJnlTemplateIS.Codeunit.al deleted file mode 100644 index 4639193154..0000000000 --- a/Apps/IS/ContosoCoffeeDemoDatasetIS/app/DemoData/FA/1.Setup Data/CreateFAInsJnlTemplateIS.Codeunit.al +++ /dev/null @@ -1,21 +0,0 @@ -codeunit 14613 "Create FA Ins Jnl. Template IS" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - ContosoFixedAsset: Codeunit "Contoso Fixed Asset"; - CreateFANoSeries: Codeunit "Create FA No Series"; - CreateFAInsJnlTemplate: Codeunit "Create FA Ins Jnl. Template"; - begin - ContosoFixedAsset.SetOverwriteData(true); - ContosoFixedAsset.InsertInsuranceJournalTemplate(CreateFAInsJnlTemplate.Insurance(), InsuranceJournalLbl, CreateFANoSeries.InsuranceJournal()); - ContosoFixedAsset.InsertInsuranceJournalBatch(CreateFAInsJnlTemplate.Insurance(), CreateFAInsJnlTemplate.Default(), DefaultJournalBatchLbl); - ContosoFixedAsset.SetOverwriteData(false); - end; - - var - InsuranceJournalLbl: Label 'Insurance Journal', MaxLength = 50; - DefaultJournalBatchLbl: Label 'Default Journal Batch', MaxLength = 50; -} \ No newline at end of file diff --git a/Apps/IS/ContosoCoffeeDemoDatasetIS/app/DemoData/Finance/1.Setup Data/CreateAccScheduleLineIS.Codeunit.al b/Apps/IS/ContosoCoffeeDemoDatasetIS/app/DemoData/Finance/1.Setup Data/CreateAccScheduleLineIS.Codeunit.al index 780e1f76d5..634f7f3d1c 100644 --- a/Apps/IS/ContosoCoffeeDemoDatasetIS/app/DemoData/Finance/1.Setup Data/CreateAccScheduleLineIS.Codeunit.al +++ b/Apps/IS/ContosoCoffeeDemoDatasetIS/app/DemoData/Finance/1.Setup Data/CreateAccScheduleLineIS.Codeunit.al @@ -62,10 +62,7 @@ codeunit 14629 "Create Acc. Schedule Line IS" if Rec."Schedule Name" = CreateAccountScheduleName.ReducedTrialBalance() then case Rec."Line No." of 10000: - begin - ValidateRecordFields(Rec, CreateGLAccount.TotalRevenue(), Enum::"Acc. Schedule Line Totaling Type"::"Total Accounts", false); - Rec.Validate(Description, TotalRevenueLbl); - end; + ValidateRecordFields(Rec, CreateGLAccount.TotalRevenue(), Enum::"Acc. Schedule Line Totaling Type"::"Total Accounts", false); 20000: ValidateRecordFields(Rec, CreateGLAccount.TotalCost(), Enum::"Acc. Schedule Line Totaling Type"::"Total Accounts", false); 40000: @@ -88,7 +85,4 @@ codeunit 14629 "Create Acc. Schedule Line IS" if HideCurrencySymbol then AccScheduleLine.Validate("Hide Currency Symbol", HideCurrencySymbol); end; - - var - TotalRevenueLbl: Label 'Total Revenue', MaxLength = 100; } \ No newline at end of file diff --git a/Apps/IS/ContosoCoffeeDemoDatasetIS/app/DemoTool/ISContosoLocalization.Codeunit.al b/Apps/IS/ContosoCoffeeDemoDatasetIS/app/DemoTool/ISContosoLocalization.Codeunit.al index de92de88d7..5370d0ac3f 100644 --- a/Apps/IS/ContosoCoffeeDemoDatasetIS/app/DemoTool/ISContosoLocalization.Codeunit.al +++ b/Apps/IS/ContosoCoffeeDemoDatasetIS/app/DemoTool/ISContosoLocalization.Codeunit.al @@ -12,10 +12,6 @@ codeunit 14628 "IS Contoso Localization" HumanResourceModule(ContosoDemoDataLevel); if Module = Enum::"Contoso Demo Data Module"::Finance then FinanceModule(ContosoDemoDataLevel); - if Module = Enum::"Contoso Demo Data Module"::"Fixed Asset Module" then - FixedAssetModule(ContosoDemoDataLevel); - if Module = Enum::"Contoso Demo Data Module"::Bank then - BankModule(ContosoDemoDataLevel); if Module = Enum::"Contoso Demo Data Module"::Finance then InventoryModule(ContosoDemoDataLevel); @@ -51,22 +47,6 @@ codeunit 14628 "IS Contoso Localization" end; end; - local procedure FixedAssetModule(ContosoDemoDataLevel: Enum "Contoso Demo Data Level") - begin - case ContosoDemoDataLevel of - Enum::"Contoso Demo Data Level"::"Master Data": - Codeunit.Run(Codeunit::"Create FA Ins Jnl. Template IS"); - end; - end; - - local procedure BankModule(ContosoDemoDataLevel: Enum "Contoso Demo Data Level") - begin - case ContosoDemoDataLevel of - Enum::"Contoso Demo Data Level"::"Historical Data": - Codeunit.Run(Codeunit::"Create Gen. Journal Line IS"); - end; - end; - local procedure InventoryModule(ContosoDemoDataLevel: Enum "Contoso Demo Data Level") begin case ContosoDemoDataLevel of @@ -104,14 +84,10 @@ codeunit 14628 "IS Contoso Localization" CreateVATSetupPostingGrpIS: Codeunit "Create VAT Setup PostingGrpIS"; CreateVATStatementIS: Codeunit "Create VAT Statement IS"; CreateAccScheduleLineIS: Codeunit "Create Acc. Schedule Line IS"; - CreateGenJournalLineIS: Codeunit "Create Gen. Journal Line IS"; begin case Module of Enum::"Contoso Demo Data Module"::Bank: - begin - BindSubscription(CreateBankAccountIS); - BindSubscription(CreateGenJournalLineIS) - end; + BindSubscription(CreateBankAccountIS); Enum::"Contoso Demo Data Module"::Inventory: begin BindSubscription(CreateItemIS); @@ -161,14 +137,10 @@ codeunit 14628 "IS Contoso Localization" CreateVATSetupPostingGrpIS: Codeunit "Create VAT Setup PostingGrpIS"; CreateVATStatementIS: Codeunit "Create VAT Statement IS"; CreateAccScheduleLineIS: Codeunit "Create Acc. Schedule Line IS"; - CreateGenJournalLineIS: Codeunit "Create Gen. Journal Line IS"; begin case Module of Enum::"Contoso Demo Data Module"::Bank: - begin - UnbindSubscription(CreateGenJournalLineIS); - UnBindSubscription(CreateBankAccountIS); - end; + UnBindSubscription(CreateBankAccountIS); Enum::"Contoso Demo Data Module"::Inventory: begin UnBindSubscription(CreateItemIS); diff --git a/Apps/IT/ContosoCoffeeDemoDatasetIT/app/Demo Data/Sales/1.Setup Data/CreateSalesRecvSetupIT.Codeunit.al b/Apps/IT/ContosoCoffeeDemoDatasetIT/app/Demo Data/Sales/1.Setup Data/CreateSalesRecvSetupIT.Codeunit.al index 91bcf89e6a..a36c2a916c 100644 --- a/Apps/IT/ContosoCoffeeDemoDatasetIT/app/Demo Data/Sales/1.Setup Data/CreateSalesRecvSetupIT.Codeunit.al +++ b/Apps/IT/ContosoCoffeeDemoDatasetIT/app/Demo Data/Sales/1.Setup Data/CreateSalesRecvSetupIT.Codeunit.al @@ -15,7 +15,7 @@ codeunit 12211 "Create Sales Recv. Setup IT" begin SalesReceivablesSetup.Get(); - Evaluate(SalesReceivablesSetup."Bank Receipts Risk Period", BankReceiptsRiskPeriodLbl); + Evaluate(SalesReceivablesSetup."Bank Receipts Risk Period", '<20D>'); SalesReceivablesSetup.Validate("Bank Receipts Risk Period"); SalesReceivablesSetup.Validate("Temporary Bill List No.", CreateNoSeriesIT.TemporaryCustBillListNo()); SalesReceivablesSetup.Validate("Recall Bill Description", RecallBillLbl); @@ -27,7 +27,6 @@ codeunit 12211 "Create Sales Recv. Setup IT" end; var - BankReceiptsRiskPeriodLbl: Label '<20D>', MaxLength = 20; RecallBillLbl: Label 'Recall Bill', MaxLength = 50, Locked = true; FatturapaLbl: Label 'FATTURAPA', MaxLength = 20, Locked = true; } \ No newline at end of file diff --git a/Apps/IT/ServiceDeclarationIT/app/src/ServiceDeclSubformIT.PageExt.al b/Apps/IT/ServiceDeclarationIT/app/src/ServiceDeclSubformIT.PageExt.al index cd881ce5aa..3f36df54cb 100644 --- a/Apps/IT/ServiceDeclarationIT/app/src/ServiceDeclSubformIT.PageExt.al +++ b/Apps/IT/ServiceDeclarationIT/app/src/ServiceDeclSubformIT.PageExt.al @@ -20,10 +20,6 @@ pageextension 12217 "Service Decl. Subform IT" extends "Service Declaration Subf { Visible = false; } - modify("Service Transaction Code") - { - Visible = false; - } modify("VAT Reg. No.") { Visible = true; diff --git a/Apps/MX/ContosoCoffeeDemoDatasetMX/app/DemoData/Bank/3.Transaction Data/CreateGenJournalLineMX.Codeunit.al b/Apps/MX/ContosoCoffeeDemoDatasetMX/app/DemoData/Bank/3.Transaction Data/CreateGenJournalLineMX.Codeunit.al deleted file mode 100644 index f85537d6cf..0000000000 --- a/Apps/MX/ContosoCoffeeDemoDatasetMX/app/DemoData/Bank/3.Transaction Data/CreateGenJournalLineMX.Codeunit.al +++ /dev/null @@ -1,62 +0,0 @@ -codeunit 14121 "Create Gen. Journal Line MX" -{ - SingleInstance = true; - EventSubscriberInstance = Manual; - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - begin - UpdateGenJournalLine(); - UpdateBankAccReconciliationLine(); - end; - - [EventSubscriber(ObjectType::Table, Database::"Gen. Journal Line", 'OnBeforeInsertEvent', '', false, false)] - local procedure OnBeforeInsertGenJournalLine(var Rec: Record "Gen. Journal Line") - var - CreateGenJournalTemplate: Codeunit "Create Gen. Journal Template"; - CreateBankJnlBatch: Codeunit "Create Bank Jnl. Batches"; - begin - if (Rec."Journal Template Name" = CreateGenJournalTemplate.General()) and (Rec."Journal Batch Name" = CreateBankJnlBatch.Daily()) then - case Rec."Line No." of - 10000: - Rec.Validate(Amount, -24695.12); - 20000: - Rec.Validate(Amount, -37042.68); - 30000: - Rec.Validate(Amount, -49390.24); - 40000: - Rec.Validate(Amount, -49390.24); - end; - end; - - local procedure UpdateGenJournalLine() - var - GenJournalLine: Record "Gen. Journal Line"; - CreateGenJournalTemplate: Codeunit "Create Gen. Journal Template"; - CreateBankJnlBatch: Codeunit "Create Bank Jnl. Batches"; - begin - GenJournalLine.Get(CreateGenJournalTemplate.General(), CreateBankJnlBatch.Daily(), 10000); - if GenJournalLine."Account No." = '' then begin - GenJournalLine.Validate(Amount, 0); - GenJournalLine.Modify(true); - end; - end; - - local procedure UpdateBankAccReconciliationLine() - var - BankAccReconciliationLine: Record "Bank Acc. Reconciliation Line"; - BankAccount: Record "Bank Account"; - CreateBankAccount: Codeunit "Create Bank Account"; - begin - BankAccount.Get(CreateBankAccount.Checking()); - - BankAccReconciliationLine.Get(BankAccReconciliationLine."Statement Type"::"Bank Reconciliation", BankAccount."No.", BankAccount."Last Statement No.", 30000); - BankAccReconciliationLine.Validate("Transaction Text", DepositToAccountLbl); - BankAccReconciliationLine.Validate(Description, CopyStr(BankAccReconciliationLine."Transaction Text", 1, MaxStrLen(BankAccReconciliationLine.Description))); - BankAccReconciliationLine.Modify(true); - end; - - var - DepositToAccountLbl: Label 'Deposit to Account 18/01/24', MaxLength = 100; -} \ No newline at end of file diff --git a/Apps/MX/ContosoCoffeeDemoDatasetMX/app/DemoData/Finance/1.Setup Data/CreateAccScheduleLineMX.Codeunit.al b/Apps/MX/ContosoCoffeeDemoDatasetMX/app/DemoData/Finance/1.Setup Data/CreateAccScheduleLineMX.Codeunit.al index 2285a2a2dc..3396a66ec0 100644 --- a/Apps/MX/ContosoCoffeeDemoDatasetMX/app/DemoData/Finance/1.Setup Data/CreateAccScheduleLineMX.Codeunit.al +++ b/Apps/MX/ContosoCoffeeDemoDatasetMX/app/DemoData/Finance/1.Setup Data/CreateAccScheduleLineMX.Codeunit.al @@ -70,7 +70,7 @@ codeunit 14112 "Create Acc. Schedule Line MX" if Rec."Schedule Name" = CreateAccountScheduleName.ReducedTrialBalance() then case Rec."Line No." of 10000: - ValidateRecordFieldsReducedTrialBalance(Rec, CreateGLAccount.TotalRevenue(), Enum::"Acc. Schedule Line Totaling Type"::"Total Accounts", false, TotalRevenueLbl); + ValidateRecordFields(Rec, CreateGLAccount.TotalRevenue(), Enum::"Acc. Schedule Line Totaling Type"::"Total Accounts", false); 20000: ValidateRecordFields(Rec, CreateGLAccount.TotalCost(), Enum::"Acc. Schedule Line Totaling Type"::"Total Accounts", false); 40000: @@ -93,16 +93,4 @@ codeunit 14112 "Create Acc. Schedule Line MX" if HideCurrencySymbol then AccScheduleLine.Validate("Hide Currency Symbol", HideCurrencySymbol); end; - - local procedure ValidateRecordFieldsReducedTrialBalance(var AccScheduleLine: Record "Acc. Schedule Line"; Totaling: Text; TotalingType: Enum "Acc. Schedule Line Totaling Type"; HideCurrencySymbol: Boolean; Description: Text[100]) - begin - AccScheduleLine.Validate(Totaling, Totaling); - AccScheduleLine.Validate("Totaling Type", TotalingType); - AccScheduleLine.Validate(Description, Description); - if HideCurrencySymbol then - AccScheduleLine.Validate("Hide Currency Symbol", HideCurrencySymbol); - end; - - var - TotalRevenueLbl: Label 'Total Revenue', MaxLength = 100, Locked = true; } \ No newline at end of file diff --git a/Apps/MX/ContosoCoffeeDemoDatasetMX/app/DemoData/Finance/2.Master Data/CreateMXGLAccounts.Codeunit.al b/Apps/MX/ContosoCoffeeDemoDatasetMX/app/DemoData/Finance/2.Master Data/CreateMXGLAccounts.Codeunit.al index cc1e33fd81..94d120479d 100644 --- a/Apps/MX/ContosoCoffeeDemoDatasetMX/app/DemoData/Finance/2.Master Data/CreateMXGLAccounts.Codeunit.al +++ b/Apps/MX/ContosoCoffeeDemoDatasetMX/app/DemoData/Finance/2.Master Data/CreateMXGLAccounts.Codeunit.al @@ -113,6 +113,8 @@ codeunit 14099 "Create MX GL Accounts" var CreateGLAccount: Codeunit "Create G/L Account"; begin + ModifyGLAccountForW1(); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.IncomeStatementName(), '1000'); ContosoGLAccount.AddAccountForLocalization(BankLcyPostingName(), '10100'); ContosoGLAccount.AddAccountForLocalization(CashPostingName(), '10300'); @@ -369,50 +371,6 @@ codeunit 14099 "Create MX GL Accounts" ContosoGLAccount.AddAccountForLocalization(PurchaseVat16PercUnrealizedName(), '9635'); ContosoGLAccount.AddAccountForLocalization(AccountsReceivablePostingName(), '10400'); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.LandandBuildingsName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.VendorPrepaymentsVat10Name(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.VendorPrepaymentsVat25Name(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.CustomerPrepaymentsVat10Name(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.CustomerPrepaymentsVat25Name(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.SalesVat25Name(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.SalesVat10Name(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.PurchaseVat25EuName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.PurchaseVat10EuName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.PurchaseVat25Name(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.PurchaseVat10Name(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobSalesAppliedRetailName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobSalesAdjmtRetailName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.SalesOfRawMaterialsName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.SalesRawMaterialsDomName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.SalesRawMaterialsEuName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.SalesRawMaterialsExportName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobSalesAppliedRawMatName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobSalesAdjmtRawMatName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.TotalSalesOfRawMaterialsName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobSalesAppliedResourcesName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobSalesAdjmtResourcesName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.SalesOfJobsName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.SalesOtherJobExpensesName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.TotalSalesOfJobsName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobCostAppliedRetailName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobCostAdjmtRetailName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.CostOfRawMaterialsName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.PurchRawMaterialsDomName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.PurchRawMaterialsEuName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.PurchRawMaterialsExportName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.DiscReceivedRawMaterialsName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.DeliveryExpensesRawMatName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.InventoryAdjmtRawMatName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobCostAppliedRawMatName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobCostAdjmtRawMaterialsName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.CostOfRawMaterialsSoldName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.TotalCostOfRawMaterialsName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.CostOfResourcesName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobCostAppliedResourcesName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobCostAdjmtResourcesName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.CostOfResourcesUsedName(), ''); - ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.TotalCostOfResourcesName(), ''); - CreateGLAccountForLocalization(); end; @@ -611,6 +569,56 @@ codeunit 14099 "Create MX GL Accounts" GLAccount.Modify(true); end; + local procedure ModifyGLAccountForW1() + var + CreateGLAccount: Codeunit "Create G/L Account"; + begin + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.LandandBuildingsName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.VendorPrepaymentsVat10Name(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.VendorPrepaymentsVat25Name(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.CustomerPrepaymentsVat10Name(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.CustomerPrepaymentsVat25Name(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.SalesVat25Name(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.SalesVat10Name(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.PurchaseVat25EuName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.PurchaseVat10EuName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.PurchaseVat25Name(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.PurchaseVat10Name(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobSalesAppliedRetailName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobSalesAdjmtRetailName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.SalesOfRawMaterialsName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.SalesRawMaterialsDomName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.SalesRawMaterialsEuName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.SalesRawMaterialsExportName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobSalesAppliedRawMatName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobSalesAdjmtRawMatName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.TotalSalesOfRawMaterialsName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobSalesAppliedResourcesName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobSalesAdjmtResourcesName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.SalesOfJobsName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.SalesOtherJobExpensesName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.TotalSalesOfJobsName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobCostAppliedRetailName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobCostAdjmtRetailName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.CostOfRawMaterialsName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.PurchRawMaterialsDomName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.PurchRawMaterialsEuName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.PurchRawMaterialsExportName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.DiscReceivedRawMaterialsName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.DeliveryExpensesRawMatName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.InventoryAdjmtRawMatName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobCostAppliedRawMatName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobCostAdjmtRawMaterialsName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.CostOfRawMaterialsSoldName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.TotalCostOfRawMaterialsName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.CostOfResourcesName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobCostAppliedResourcesName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.JobCostAdjmtResourcesName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.CostOfResourcesUsedName(), ''); + ContosoGLAccount.AddAccountForLocalization(CreateGLAccount.TotalCostOfResourcesName(), ''); + + end; + procedure Equipment(): Code[20] begin exit(ContosoGLAccount.GetAccountNo(EquipmentName())); diff --git a/Apps/MX/ContosoCoffeeDemoDatasetMX/app/DemoData/Finance/2.Master Data/CreateVATStatementMX.Codeunit.al b/Apps/MX/ContosoCoffeeDemoDatasetMX/app/DemoData/Finance/2.Master Data/CreateVATStatementMX.Codeunit.al index 0345b661a8..20b2f2cf70 100644 --- a/Apps/MX/ContosoCoffeeDemoDatasetMX/app/DemoData/Finance/2.Master Data/CreateVATStatementMX.Codeunit.al +++ b/Apps/MX/ContosoCoffeeDemoDatasetMX/app/DemoData/Finance/2.Master Data/CreateVATStatementMX.Codeunit.al @@ -152,7 +152,7 @@ codeunit 14105 "Create VAT Statement MX" Co2TaxLbl: Label 'CO2 Tax', MaxLength = 100; WaterTaxLbl: Label 'Water Tax', MaxLength = 100; TotalTaxesLbl: Label 'Total Taxes', MaxLength = 100; - BlankLbl: Label '--------------------------------------------------', MaxLength = 100; + BlankLbl: Label '--------------------------------------------------', Locked = true; TotalDeductionsLbl: Label 'Total Deductions', MaxLength = 100; VatPayableLbl: Label 'VAT Payable', MaxLength = 100; ValueOfEuPurchases16PercLbl: Label 'Value of EU Purchases 16 %', MaxLength = 100; diff --git a/Apps/MX/ContosoCoffeeDemoDatasetMX/app/DemoTool/MXContosoLocalization.Codeunit.al b/Apps/MX/ContosoCoffeeDemoDatasetMX/app/DemoTool/MXContosoLocalization.Codeunit.al index a8bae840b0..542441cad8 100644 --- a/Apps/MX/ContosoCoffeeDemoDatasetMX/app/DemoTool/MXContosoLocalization.Codeunit.al +++ b/Apps/MX/ContosoCoffeeDemoDatasetMX/app/DemoTool/MXContosoLocalization.Codeunit.al @@ -39,8 +39,6 @@ codeunit 14108 "MX Contoso Localization" case ContosoDemoDataLevel of Enum::"Contoso Demo Data Level"::"Setup Data": Codeunit.Run(Codeunit::"Create Bank Ex/Import SetupMX"); - Enum::"Contoso Demo Data Level"::"Historical Data": - Codeunit.Run(Codeunit::"Create Gen. Journal Line MX"); end; end; @@ -108,7 +106,6 @@ codeunit 14108 "MX Contoso Localization" CreateVendorMX: Codeunit "Create Vendor MX"; CreateResourceMX: Codeunit "Create Resource MX"; CreateReminderLevelMX: Codeunit "Create Reminder Level MX"; - CreateGenJournalLineMX: Codeunit "Create Gen. Journal Line MX"; CreateSalesDimValueMX: Codeunit "Create Sales Dim Value MX"; CreatePurchDimValueMX: Codeunit "Create Purch. Dim. Value MX"; CreateInvPostingSetupMX: Codeunit "Create Inv. Posting Setup MX"; @@ -117,10 +114,7 @@ codeunit 14108 "MX Contoso Localization" begin case Module of Enum::"Contoso Demo Data Module"::Bank: - begin - BindSubscription(CreateBankAccountMX); - BindSubscription(CreateGenJournalLineMX); - end; + BindSubscription(CreateBankAccountMX); Enum::"Contoso Demo Data Module"::Inventory: begin BindSubscription(CreateItemChargeMX); @@ -167,7 +161,6 @@ codeunit 14108 "MX Contoso Localization" CreateVendorMX: Codeunit "Create Vendor MX"; CreateResourceMX: Codeunit "Create Resource MX"; CreateReminderLevelMX: Codeunit "Create Reminder Level MX"; - CreateGenJournalLineMX: Codeunit "Create Gen. Journal Line MX"; CreateSalesDimValueMX: Codeunit "Create Sales Dim Value MX"; CreatePurchDimValueMX: Codeunit "Create Purch. Dim. Value MX"; CreateInvPostingSetupMX: Codeunit "Create Inv. Posting Setup MX"; @@ -177,10 +170,7 @@ codeunit 14108 "MX Contoso Localization" begin case Module of Enum::"Contoso Demo Data Module"::Bank: - begin - UnbindSubscription(CreateBankAccountMX); - UnbindSubscription(CreateGenJournalLineMX); - end; + UnbindSubscription(CreateBankAccountMX); Enum::"Contoso Demo Data Module"::Inventory: begin UnbindSubscription(CreateItemChargeMX); diff --git a/Apps/NL/ContosoCoffeeDemoDatasetNL/app/Demo Data/Foundation/1.Setup Data/CreateCompanyInformationNL.Codeunit.al b/Apps/NL/ContosoCoffeeDemoDatasetNL/app/Demo Data/Foundation/1.Setup Data/CreateCompanyInformationNL.Codeunit.al index 2bba89f3ca..a847363d07 100644 --- a/Apps/NL/ContosoCoffeeDemoDatasetNL/app/Demo Data/Foundation/1.Setup Data/CreateCompanyInformationNL.Codeunit.al +++ b/Apps/NL/ContosoCoffeeDemoDatasetNL/app/Demo Data/Foundation/1.Setup Data/CreateCompanyInformationNL.Codeunit.al @@ -29,5 +29,5 @@ codeunit 11516 "Create Company Information NL" var CityLbl: Label 'Apeldoorn', Maxlength = 30, Locked = true; PostCodeLbl: Label '1111 DA', MaxLength = 20; - VatRegNoLbl: Label 'NL777777770B77', MaxLength = 20; + VatRegNoLbl: Label 'NL777777770B77', Locked = true; } \ No newline at end of file diff --git a/Apps/NO/ContosoCoffeeDemoDatasetNO/app/Demo Data/Bank/2.Master Data/CreateGenJournalLineNO.Codeunit.al b/Apps/NO/ContosoCoffeeDemoDatasetNO/app/Demo Data/Bank/2.Master Data/CreateGenJournalLineNO.Codeunit.al deleted file mode 100644 index bebbe49e89..0000000000 --- a/Apps/NO/ContosoCoffeeDemoDatasetNO/app/Demo Data/Bank/2.Master Data/CreateGenJournalLineNO.Codeunit.al +++ /dev/null @@ -1,62 +0,0 @@ -codeunit 10704 "Create Gen. Journal Line NO" -{ - SingleInstance = true; - EventSubscriberInstance = Manual; - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - begin - UpdateGenJournalLine(); - UpdateBankAccReconciliationLine(); - end; - - [EventSubscriber(ObjectType::Table, Database::"Gen. Journal Line", 'OnBeforeInsertEvent', '', false, false)] - local procedure OnBeforeInsertGenJournalLine(var Rec: Record "Gen. Journal Line") - var - CreateGenJournalTemplate: Codeunit "Create Gen. Journal Template"; - CreateBankJnlBatch: Codeunit "Create Bank Jnl. Batches"; - begin - if (Rec."Journal Template Name" = CreateGenJournalTemplate.General()) and (Rec."Journal Batch Name" = CreateBankJnlBatch.Daily()) then - case Rec."Line No." of - 10000: - Rec.Validate(Amount, -17352.13); - 20000: - Rec.Validate(Amount, -26028.2); - 30000: - Rec.Validate(Amount, -34704.27); - 40000: - Rec.Validate(Amount, -34704.27); - end; - end; - - local procedure UpdateGenJournalLine() - var - GenJournalLine: Record "Gen. Journal Line"; - CreateGenJournalTemplate: Codeunit "Create Gen. Journal Template"; - CreateBankJnlBatch: Codeunit "Create Bank Jnl. Batches"; - begin - GenJournalLine.Get(CreateGenJournalTemplate.General(), CreateBankJnlBatch.Daily(), 10000); - if GenJournalLine."Account No." = '' then begin - GenJournalLine.Validate(Amount, 0); - GenJournalLine.Modify(true); - end; - end; - - local procedure UpdateBankAccReconciliationLine() - var - BankAccReconciliationLine: Record "Bank Acc. Reconciliation Line"; - BankAccount: Record "Bank Account"; - CreateBankAccount: Codeunit "Create Bank Account"; - begin - BankAccount.Get(CreateBankAccount.Checking()); - - BankAccReconciliationLine.Get(BankAccReconciliationLine."Statement Type"::"Bank Reconciliation", BankAccount."No.", BankAccount."Last Statement No.", 30000); - BankAccReconciliationLine.Validate("Transaction Text", DepositToAccountLbl); - BankAccReconciliationLine.Validate(Description, CopyStr(BankAccReconciliationLine."Transaction Text", 1, MaxStrLen(BankAccReconciliationLine.Description))); - BankAccReconciliationLine.Modify(true); - end; - - var - DepositToAccountLbl: Label 'Deposit to Account 18.01.24', MaxLength = 100; -} \ No newline at end of file diff --git a/Apps/NO/ContosoCoffeeDemoDatasetNO/app/Demo Data/Finance/2.Master Data/CreateAccScheduleLineNO.Codeunit.al b/Apps/NO/ContosoCoffeeDemoDatasetNO/app/Demo Data/Finance/2.Master Data/CreateAccScheduleLineNO.Codeunit.al index c70fa22099..10c05a313d 100644 --- a/Apps/NO/ContosoCoffeeDemoDatasetNO/app/Demo Data/Finance/2.Master Data/CreateAccScheduleLineNO.Codeunit.al +++ b/Apps/NO/ContosoCoffeeDemoDatasetNO/app/Demo Data/Finance/2.Master Data/CreateAccScheduleLineNO.Codeunit.al @@ -68,7 +68,7 @@ codeunit 10726 "Create Acc. Schedule Line NO" if Rec."Schedule Name" = CreateAccountScheduleName.ReducedTrialBalance() then case Rec."Line No." of 10000: - ValidateRecordFieldsReducedTrialBalance(Rec, CreateGLAccount.TotalRevenue(), Enum::"Acc. Schedule Line Totaling Type"::"Total Accounts", false, TotalRevenueLbl); + ValidateRecordFields(Rec, CreateGLAccount.TotalRevenue(), Enum::"Acc. Schedule Line Totaling Type"::"Total Accounts", false); 20000: ValidateRecordFields(Rec, CreateGLAccount.TotalCost(), Enum::"Acc. Schedule Line Totaling Type"::"Total Accounts", false); 40000: @@ -91,16 +91,4 @@ codeunit 10726 "Create Acc. Schedule Line NO" if HideCurrencySymbol then AccScheduleLine.Validate("Hide Currency Symbol", HideCurrencySymbol); end; - - local procedure ValidateRecordFieldsReducedTrialBalance(var AccScheduleLine: Record "Acc. Schedule Line"; Totaling: Text; TotalingType: Enum "Acc. Schedule Line Totaling Type"; HideCurrencySymbol: Boolean; Description: Text[100]) - begin - AccScheduleLine.Validate(Totaling, Totaling); - AccScheduleLine.Validate("Totaling Type", TotalingType); - AccScheduleLine.Validate(Description, Description); - if HideCurrencySymbol then - AccScheduleLine.Validate("Hide Currency Symbol", HideCurrencySymbol); - end; - - var - TotalRevenueLbl: Label 'Total Revenue', MaxLength = 100, Locked = true; } \ No newline at end of file diff --git a/Apps/NO/ContosoCoffeeDemoDatasetNO/app/Demo Helper/Contoso Helper/NOContosoLocalization.Codeunit.al b/Apps/NO/ContosoCoffeeDemoDatasetNO/app/Demo Helper/Contoso Helper/NOContosoLocalization.Codeunit.al index d817997ad4..0cdd51b00f 100644 --- a/Apps/NO/ContosoCoffeeDemoDatasetNO/app/Demo Helper/Contoso Helper/NOContosoLocalization.Codeunit.al +++ b/Apps/NO/ContosoCoffeeDemoDatasetNO/app/Demo Helper/Contoso Helper/NOContosoLocalization.Codeunit.al @@ -10,8 +10,6 @@ codeunit 10669 "NO Contoso Localization" FoundationModule(ContosoDemoDataLevel); if Module = Enum::"Contoso Demo Data Module"::Finance then FinanceModule(ContosoDemoDataLevel); - if Module = Enum::"Contoso Demo Data Module"::Bank then - BankModule(ContosoDemoDataLevel); if Module = Enum::"Contoso Demo Data Module"::Inventory then InventoryModule(ContosoDemoDataLevel); if Module = Enum::"Contoso Demo Data Module"::Sales then @@ -51,14 +49,6 @@ codeunit 10669 "NO Contoso Localization" end; end; - local procedure BankModule(ContosoDemoDataLevel: Enum "Contoso Demo Data Level") - begin - case ContosoDemoDataLevel of - Enum::"Contoso Demo Data Level"::"Historical Data": - Codeunit.Run(Codeunit::"Create Gen. Journal Line NO"); - end; - end; - local procedure SalesModule(ContosoDemoDataLevel: Enum "Contoso Demo Data Level") begin case ContosoDemoDataLevel of @@ -86,7 +76,6 @@ codeunit 10669 "NO Contoso Localization" CreateCurrencyExchRateNO: Codeunit "Create Currency Ex. Rate NO"; CreatePurchDimValueNO: Codeunit "Create Purch. Dim. Value NO"; CreateSalesDimValueNO: Codeunit "Create Sales Dim Value NO"; - CreateGenJournalLineNO: Codeunit "Create Gen. Journal Line NO"; CreateLocationNO: Codeunit "Create Location NO"; CreateResourceNO: Codeunit "Create Resource NO"; CreateCustomerNO: Codeunit "Create Customer NO"; @@ -133,10 +122,7 @@ codeunit 10669 "NO Contoso Localization" BindSubscription(CreateCustomerTemplateNO); end; Enum::"Contoso Demo Data Module"::Bank: - begin - BindSubscription(CreateBankAccountNO); - BindSubscription(CreateGenJournalLineNO); - end; + BindSubscription(CreateBankAccountNO); Enum::"Contoso Demo Data Module"::"Fixed Asset Module": BindSubscription(CreateFADepreciationBookNO); end; @@ -149,7 +135,6 @@ codeunit 10669 "NO Contoso Localization" CreateCurrencyExchRateNO: Codeunit "Create Currency Ex. Rate NO"; CreatePurchDimValueNO: Codeunit "Create Purch. Dim. Value NO"; CreateSalesDimValueNO: Codeunit "Create Sales Dim Value NO"; - CreateGenJournalLineNO: Codeunit "Create Gen. Journal Line NO"; CreateLocationNO: Codeunit "Create Location NO"; CreateResourceNO: Codeunit "Create Resource NO"; CreateCustomerNO: Codeunit "Create Customer NO"; @@ -196,10 +181,7 @@ codeunit 10669 "NO Contoso Localization" UnbindSubscription(CreateCustomerTemplateNO); end; Enum::"Contoso Demo Data Module"::Bank: - begin - UnbindSubscription(CreateBankAccountNO); - UnbindSubscription(CreateGenJournalLineNO); - end; + UnbindSubscription(CreateBankAccountNO); Enum::"Contoso Demo Data Module"::"Fixed Asset Module": UnbindSubscription(CreateFADepreciationBookNO); end; diff --git a/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/1.Setup Data/CreateAccScheduleLineUS.Codeunit.al b/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/1.Setup Data/CreateAccScheduleLineUS.Codeunit.al index e1ae12ce08..7c65270a90 100644 --- a/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/1.Setup Data/CreateAccScheduleLineUS.Codeunit.al +++ b/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/1.Setup Data/CreateAccScheduleLineUS.Codeunit.al @@ -5,10 +5,6 @@ codeunit 11489 "Create Acc. Schedule Line US" InherentEntitlements = X; InherentPermissions = X; - // ToDo: Need to Check with MS Team why standard Schedule Name are commented in W1 - - // ToDO: MS Could not find out several GLAccount Eg. '10910..10950','20500','40250' - trigger OnRun() var CreateAccountScheduleName: Codeunit "Create Acc. Schedule Name"; @@ -17,6 +13,8 @@ codeunit 11489 "Create Acc. Schedule Line US" begin AccountScheduleName := CreateAccountScheduleName.CapitalStructure(); ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 190000, '', CAMinusShortTermLiabLbl, '06|16', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', true, false, false, false, 0); + + CreateUSAccountScheduleLines(); end; [EventSubscriber(ObjectType::Table, Database::"Acc. Schedule Line", 'OnBeforeInsertEvent', '', false, false)] @@ -121,121 +119,6 @@ codeunit 11489 "Create Acc. Schedule Line US" ValidateRecordFields(Rec, '90', IncomeBeforeInterestAndTaxLbl, '60 - 80', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false); end; - //ToDo: Need to Check with MS why standard Schedule Name are commented in W1 - // if Rec."Schedule Name" = CreateAccScheduleName.BalanceSheet() then - // case Rec."Line No." of - // 10000: - // ValidateRecordFields(Rec, 'P0001', AssetsLbl, '10000..12200|12999..13999|15000..16000|16999..18000|18999..19999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', true, false); - // 30000: - // ValidateRecordFields(Rec, 'P0003', CashLbl, '18100..18500', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // 40000: - // ValidateRecordFields(Rec, 'P0004', AccountsReceivableLbl, '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // 50000: - // ValidateRecordFields(Rec, 'P0005', PrepaidExpensesLbl, '16100..16600', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // 60000: - // ValidateRecordFields(Rec, 'P0006', InventoryLbl, '14000..14299', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // 90000: - // ValidateRecordFields(Rec, 'P0009', EquipmentLbl, '12210..12299', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // 100000: - // ValidateRecordFields(Rec, 'P0010', AccumulatedDepreciationLbl, '12900', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // 140000: - // ValidateRecordFields(Rec, 'P0014', LiabilitiesLbl, '20000..22000|25999..29999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', true, true); - // 150000: - // ValidateRecordFields(Rec, 'P0015', CurrentLiabilitiesLbl, '22100..24000|24999..25500', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, true); - // 160000: - // ValidateRecordFields(Rec, 'P0016', PayrollLiabilitiesLbl, '24100..24600', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, true); - // 170000: - // ValidateRecordFields(Rec, 'P0017', LongTermLiabilitiesLbl, '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, true); - // 200000: - // ValidateRecordFields(Rec, 'P0020', EquityLbl, '30000..30310|39999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', true, true); - // 210000: - // ValidateRecordFields(Rec, 'P0021', CommonStockLbl, '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, true); - // 220000: - // ValidateRecordFields(Rec, 'P0022', RetainedEarningsLbl, '40000..99999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, true); - // 230000: - // ValidateRecordFields(Rec, 'P0023', DistributionsToShareholdersLbl, '30320', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, true); - // end; - - // if Rec."Schedule Name" = CreateAccScheduleName.CashFlowStatement() then - // case Rec."Line No." of - // 20000: - // ValidateRecordFields(Rec, 'P0002', NetIncomeLbl, '40000..99999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, true); - // 40000: - // ValidateRecordFields(Rec, 'P0004', AccountsReceivableLbl, '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false); - // 50000: - // ValidateRecordFields(Rec, 'P0005', PrepaidExpensesLbl, '16100..16600', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false); - // 60000: - // ValidateRecordFields(Rec, 'P0006', InventoryLbl, '14000..14299', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false); - // 70000: - // ValidateRecordFields(Rec, 'P0007', CurrentLiabilitiesLbl, '22100..24000|24999..25500', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false); - // 80000: - // ValidateRecordFields(Rec, 'P0008', PayrollLiabilitiesLbl, '24100..24600', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false); - // 120000: - // ValidateRecordFields(Rec, 'P0012', EquipmentLbl, '12210..12299', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false); - // 130000: - // ValidateRecordFields(Rec, 'P0013', AccumulatedDepreciationLbl, '12900', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false); - // 170000: - // ValidateRecordFields(Rec, 'P0017', LongTermLiabilitiesLbl, '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false); - // 180000: - // ValidateRecordFields(Rec, 'P0018', DistributionsToShareholdersLbl, '30320', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false); - // 220000: - // ValidateRecordFields(Rec, 'P0022', CashBeginningofThePeriodLbl, '18100..18500', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false); - // end; - - // if Rec."Schedule Name" = CreateAccScheduleName.IncomeStatement() then - // case Rec."Line No." of - // 10000: - // ValidateRecordFields(Rec, 'P0001', IncomeLbl, '40000..40001|40300..40320|40380..49990|99999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', true, true); - // 20000: - // ValidateRecordFields(Rec, 'P0002', IncomeServicesLbl, '40200..40299', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, true); - // 30000: - // ValidateRecordFields(Rec, 'P0003', IncomeProductSalesLbl, '40100..40199', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, true); - // 50000: - // ValidateRecordFields(Rec, 'P0005', SalesDiscountsLbl, '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, true); - // 110000: - // ValidateRecordFields(Rec, 'P0011', CostOfGoodsSoldLbl, '50001|50400..59990', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', true, false); - // 120000: - // ValidateRecordFields(Rec, 'P0012', LaborLbl, '50200..50299', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // 130000: - // ValidateRecordFields(Rec, 'P0013', MaterialsLbl, '50100..50199', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // 200000: - // ValidateRecordFields(Rec, 'P0020', ExpenseLbl, '60001..60100|60170..63000|63400..65200|65400..67000|67300..71999|80000..98990', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', true, false); - // 210000: - // ValidateRecordFields(Rec, 'P0021', RentExpenseLbl, '60110', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // 220000: - // ValidateRecordFields(Rec, 'P0022', AdvertisingExpenseLbl, '63100..63399', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // 230000: - // ValidateRecordFields(Rec, 'P0023', InterestExpenseLbl, '40330', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // 240000: - // ValidateRecordFields(Rec, 'P0024', FeesExpenseLbl, '67100..67200', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // 250000: - // ValidateRecordFields(Rec, 'P0025', InsuranceExpenseLbl, '73000..73999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // 260000: - // ValidateRecordFields(Rec, 'P0026', PayrollExpenseLbl, '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // 270000: - // ValidateRecordFields(Rec, 'P0027', BenefitsExpenseLbl, '72000..72999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // 290000: - // ValidateRecordFields(Rec, 'P0029', RepairsMaintenanceExpenseLbl, '60160', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // 300000: - // ValidateRecordFields(Rec, 'P0030', UtilitiesExpenseLbl, '60120..60150', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // 310000: - // ValidateRecordFields(Rec, 'P0031', OtherIncomeExpensesLbl, '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // 320000: - // ValidateRecordFields(Rec, 'P0032', TaxExpenseLbl, '74000..79999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // 350000: - // ValidateRecordFields(Rec, 'P0035', BadDebtExpenseLbl, '65300', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::"If Any Column Not Zero", '', false, false); - // end; - - // if Rec."Schedule Name" = CreateAccScheduleName.RetainedEarnings() then - // case Rec."Line No." of - // 10000: - // ValidateRecordFields(Rec, 'P0001', RetainedEarningsPeriodStartLbl, '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, true); - // 20000: - // ValidateRecordFields(Rec, 'P0002', NetIncomeLbl, '40000..99999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, true); - // 50000: - // ValidateRecordFields(Rec, 'P0005', DistributionsToShareholdersLbl, '30320', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false); - // end; - if Rec."Schedule Name" = CreateAccScheduleName.Revenues() then case Rec."Line No." of 40000: @@ -272,6 +155,139 @@ codeunit 11489 "Create Acc. Schedule Line US" AccScheduleLine.Validate("New Page", NewPage); end; + internal procedure CreateUSAccountScheduleLines() + var + GLAccount: Record "G/L Account"; + AccScheduleLine: Record "Acc. Schedule Line"; + CreateAccountScheduleName: Codeunit "Create Acc. Schedule Name"; + ContosoAccountSchedule: Codeunit "Contoso Account Schedule"; + AccountScheduleName: Code[10]; + LineNo: Integer; + begin + AccountScheduleName := CreateAccountScheduleName.BalanceSheetDetailed(); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 10000, '', 'Current Assets', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 20000, 'CA', 'Cash', '18000..18999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 30000, 'CA', 'Accounts Receivable', '15000..15999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 40000, 'CA', 'Other Receivables', '13000..13999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 50000, 'CA', 'Inventory', '14000..14999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 60000, 'CA', 'Prepaid Expenses', '16000..16999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 70000, 'CA', 'Other Current Assets', '10000..11999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, true, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 80000, 'F1', 'Total Current Assets', 'CA', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 90000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 100000, '', 'Long Term Assets', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 110000, 'LTA', 'Fixed Assets', '12000..12899', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 120000, 'LTA', 'Accumulated Depreciation', '12900..12999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 130000, 'LTA', 'Other Long Term Assets', '17000..17999|19000..19999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, true, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 140000, 'F2', 'Total Long Term Assets', 'LTA', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 150000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 160000, 'F3', 'Total Assets', 'F1+F2', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + DoubleUnderscoreCurrentLine(AccountScheduleName, 160000); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 170000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 180000, '', 'Current Liabilities', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 190000, 'CL', 'Accounts Payable', '22100..22399', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 200000, 'CL', 'Accrued Payroll', '23500..25399|26100..26399', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 210000, 'CL', 'Accrued Tax', '23100..23499', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 220000, 'CL', 'Accrued Other', '26400..29999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 230000, 'CL', 'Other Current Liabilities', '22400..23099|25400..26099', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 240000, 'F4', 'Total Current Liabilities', 'CL', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 250000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 260000, '', 'Long Term Liabilities', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 270000, 'LTL', 'Notes Payable', '20000..21299', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 280000, 'LTL', 'Other Long Term Liabilities', '21300..22099', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, true, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 290000, 'F5', 'Total Long Term Liabilities', 'LTL', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 300000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 310000, 'F6', 'Total Liabilities', 'F4+F5', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 320000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 330000, '', 'Equity', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 340000, 'E', 'Common Stock', '30000..30299', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 350000, 'E', 'Retained Earnings', '30300..39999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 360000, 'E', 'Current Year Earnings', '40000..99999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, true, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 370000, 'F7', 'Total Equity', 'E', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 380000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 390000, 'F8', 'Total Liabilities and Equity', 'F6+F7', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + DoubleUnderscoreCurrentLine(AccountScheduleName, 390000); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 400000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 410000, 'F9', 'Check Figure', 'F3+F8', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + + AccountScheduleName := CreateAccountScheduleName.BalanceSheetSummarized(); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 10000, '1', 'Assets', '10000..19999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 1); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 20000, '2', 'Total Assets', '1', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 1); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 30000, '3', '', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 1); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 40000, '4', 'Liabilities', '20000..29999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 1); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 50000, '5', 'Equity', '30000..39999|40000..99999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, true, false, 1); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 60000, '6', 'Total Liabilities and Equity', '4+5', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 1); + DoubleUnderscoreCurrentLine(AccountScheduleName, 60000); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 70000, '7', 'Check Figure', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 1); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 80000, '8', 'Check Figure', '2+6', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 1); + + AccountScheduleName := CreateAccountScheduleName.IncomeStatementDetailed(); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 10000, '', 'Revenue', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 20000, 'R', 'Product Revenue', '40000..40209', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 30000, 'R', 'Job Revenue', '40410..40429', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 40000, 'R', 'Services Revenue', '40210..40309|40430..40909', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 50000, 'R', 'Other Revenue', '40310..40409|40920..40939', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 60000, 'R', 'Discounts and Returns', '40910..40919|40940..49999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, true, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 70000, 'F1', 'Total Revenue', 'R', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 80000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 90000, '', 'Cost of Goods', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 100000, 'C', 'Materials', '50000..50209', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 110000, 'C', 'Labor', '50210..59999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 120000, 'C', 'Manufacturing Overhead', '60000..69999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, true, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 130000, 'F2', 'Total Cost of Goods', 'C', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 140000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 150000, 'F3', 'Gross Margin $', 'F1+F2', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 160000, 'F4', 'Gross Margin %', 'F3/F1*100', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 170000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 180000, '', 'Operating Expense', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 190000, 'OE', 'Salaries and Wages', '70000..72109', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 200000, 'OE', 'Employee Benefits', '72110..73299', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 210000, 'OE', 'Employee Insurance', '73300..74109', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 220000, 'OE', 'Employee Tax', '74110..79999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 230000, 'OE', 'Depreciation', '80000..89999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 240000, 'OE', 'Other Expense', '90000..99999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, true, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 250000, 'F5', 'Total Operating Expense', 'OE', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 260000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 270000, 'F6', 'Net (Income) / Loss', 'F1+F2+F5', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + DoubleUnderscoreCurrentLine(AccountScheduleName, 270000); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 280000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 290000, 'F7', 'Total of Income Statement', '40000..99999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 300000, 'F8', 'Check Figure', 'F6-F7', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + + AccountScheduleName := CreateAccountScheduleName.IncomeStatementSummarized(); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 10000, '1', 'Revenue', '40000..49999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 20000, '2', 'Cost of Goods', '50000..59999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, true, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 30000, '3', 'Gross Margin', '1+2', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 40000, '4', 'Gross Margin %', '3/1*100', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 50000, '5', '', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 60000, '6', 'Operating Expense', '60000..99999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, true, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 70000, '7', 'Net (Income) / Loss', '1+2+6', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + DoubleUnderscoreCurrentLine(AccountScheduleName, 70000); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 80000, '8', '', '', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 90000, '9', 'Total of Income Statement', '40000..99999', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 100000, '10', 'Check Figure', '7-9', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + + + AccountScheduleName := CreateAccountScheduleName.TrialBalance(); + LineNo := 10000; + GLAccount.SetRange("Account Type", Enum::"G/L Account Type"::Posting); + GLAccount.SetLoadFields("No.", "Name"); + if GLAccount.FindSet() then + repeat + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, LineNo, CopyStr(GLAccount."No.", 1, MaxStrLen(AccScheduleLine."Row No.")), CopyStr(GLAccount."No." + ' ' + GLAccount.Name, 1, MaxStrLen(AccScheduleLine.Description)), GLAccount."No.", Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + LineNo := LineNo + 10000; + until GLAccount.Next() = 0; + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, LineNo, '', 'Check Figure', '10000..99999', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + end; + + local procedure DoubleUnderscoreCurrentLine(AccScheduleNameCode: Code[10]; LineNo: Integer) + var + CurrentAccScheduleLine: Record "Acc. Schedule Line"; + begin + CurrentAccScheduleLine.Get(AccScheduleNameCode, LineNo); + CurrentAccScheduleLine."Double Underline" := true; + CurrentAccScheduleLine.Modify(); + end; + var IncomeThisYearLbl: Label 'Income This Year', MaxLength = 100; AcidTestAnalysisLbl: Label 'ACID-TEST ANALYSIS', MaxLength = 100; diff --git a/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/1.Setup Data/CreateGeneralLedgerSetupUS.Codeunit.al b/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/1.Setup Data/CreateGeneralLedgerSetupUS.Codeunit.al index 419fe0e566..445de94256 100644 --- a/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/1.Setup Data/CreateGeneralLedgerSetupUS.Codeunit.al +++ b/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/1.Setup Data/CreateGeneralLedgerSetupUS.Codeunit.al @@ -11,7 +11,6 @@ codeunit 11485 "Create General Ledger Setup US" local procedure UpdateGeneralLedgerSetup() var GeneralLedgerSetup: Record "General Ledger Setup"; - // Currency: Record Currency; CreateCurrency: Codeunit "Create Currency"; begin GeneralLedgerSetup.Get(); @@ -21,14 +20,9 @@ codeunit 11485 "Create General Ledger Setup US" GeneralLedgerSetup.Validate("Local Currency Symbol", ''); GeneralLedgerSetup.Validate("Local Currency Description", ''); GeneralLedgerSetup.Validate("LCY Code", CreateCurrency.USD()); - GeneralLedgerSetup.Validate("Max. VAT Difference Allowed", 10); GeneralLedgerSetup.Validate("Payment Tolerance %", 0.1); GeneralLedgerSetup.Validate("Max. Payment Tolerance Amount", 1); - // Currency.Get(GeneralLedgerSetup."LCY Code"); - // GeneralLedgerSetup.Validate("Enable Data Check", true); GeneralLedgerSetup."Unit-Amount Rounding Precision" := 0.001; - // GeneralLedgerSetup.Validate("VAT in Use", false); - // GeneralLedgerSetup.Validate("Send PDF Report", false); GeneralLedgerSetup.Modify(true); end; } \ No newline at end of file diff --git a/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/1.Setup Data/CreateUSGLAccounts.Codeunit.al b/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/1.Setup Data/CreateUSGLAccounts.Codeunit.al index 0782ee8b3b..3212565c35 100644 --- a/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/1.Setup Data/CreateUSGLAccounts.Codeunit.al +++ b/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/1.Setup Data/CreateUSGLAccounts.Codeunit.al @@ -713,352 +713,418 @@ codeunit 10499 "Create US GL Accounts" CreateGLAccountForLocalization(); end; + local procedure CreateGLAccountForLocalization() var + AccountCategory: Record "G/L Account Category"; CreatePostingGroups: Codeunit "Create Posting Groups"; CreateGLAccount: Codeunit "Create G/L Account"; - begin - ContosoGLAccount.InsertGLAccount(CreateGLAccount.BalanceSheet(), CreateGLAccount.BalanceSheetName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Heading, '', '', 1, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(DiscountsandAllowances(), DiscountsandAllowancesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(IntangibleFixedAssets(), IntangibleFixedAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(DevelopmentExpenditure(), DevelopmentExpenditureName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TenancySiteLeaseHoldandSimilarRights(), TenancySiteLeaseHoldandSimilarRightsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(Goodwill(), GoodwillName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(AdvancedPaymentsforIntangibleFixedAssets(), AdvancedPaymentsforIntangibleFixedAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalIntangibleFixedAssets(), TotalIntangibleFixedAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"End-Total", '', '', 0, IntangibleFixedAssets() + '..' + TotalIntangibleFixedAssets(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(LandandBuildings(), LandandBuildingsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(Building(), BuildingName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CostofImprovementstoLeasedProperty(), CostofImprovementstoLeasedPropertyName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(Land(), LandName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalLandandbuilding(), TotalLandandbuildingName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"End-Total", '', '', 0, LandandBuildings() + '..' + TotalLandandbuilding(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(MachineryandEquipment(), MachineryandEquipmentName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(EquipmentsandTools(), EquipmentsandToolsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(Computers(), ComputersName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CarsandOtherTransportEquipments(), CarsandOtherTransportEquipmentsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(LeasedAssets(), LeasedAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalMachineryandEquipment(), TotalMachineryandEquipmentName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"End-Total", '', '', 0, MachineryandEquipment() + '..' + TotalMachineryandEquipment(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(AccumulatedDepreciation(), AccumulatedDepreciationName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalTangibleAssets(), TotalTangibleAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"End-Total", '', '', 0, CreateGLAccount.TangibleFixedAssets() + '..' + TotalTangibleAssets(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(FinancialandFixedAssets(), FinancialandFixedAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(LongTermReceivables(), LongTermReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ParticipationinGroupCompanies(), ParticipationinGroupCompaniesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(LoanstoPartnersorRelatedParties(), LoanstoPartnersorRelatedPartiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(DeferredTaxAssets(), DeferredTaxAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(OtherLongTermReceivables(), OtherLongTermReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalFinancialandFixedAssets(), TotalFinancialandFixedAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"End-Total", '', '', 0, FinancialandFixedAssets() + '..' + TotalFinancialandFixedAssets(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(InventoriesProductsandWorkinProgress(), InventoriesProductsandWorkinProgressName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(SuppliesandConsumables(), SuppliesandConsumablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ProductsinProgress(), ProductsinProgressName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(GoodsforResale(), GoodsforResaleName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(AdvancedPaymentsforGoodsandServices(), AdvancedPaymentsforGoodsandServicesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(OtherInventoryItems(), OtherInventoryItemsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(WorkinProgress(), WorkinProgressName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(WorkinProgressFinishedGoods(), WorkinProgressFinishedGoodsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(WIPAccruedCosts(), WIPAccruedCostsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(WIPInvoicedSales(), WIPInvoicedSalesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalWorkinProgress(), TotalWorkinProgressName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"End-Total", '', '', 0, WorkinProgress() + '..' + TotalWorkinProgress(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(Receivables(), ReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(AccountsReceivables(), AccountsReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(AccountReceivableDomestic(), AccountReceivableDomesticName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(AccountReceivableForeign(), AccountReceivableForeignName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ContractualReceivables(), ContractualReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ConsignmentReceivables(), ConsignmentReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CreditcardsandVouchersReceivables(), CreditcardsandVouchersReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalAccountReceivables(), TotalAccountReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"End-Total", '', '', 0, AccountsReceivables() + '..' + TotalAccountReceivables(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(OtherCurrentReceivables(), OtherCurrentReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(CurrentReceivablefromEmployees(), CurrentReceivablefromEmployeesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(AccruedincomenotYetInvoiced(), AccruedincomenotYetInvoicedName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ClearingAccountsforTaxesandCharges(), ClearingAccountsforTaxesandChargesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TaxAssets(), TaxAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CurrentReceivablesFromGroupCompanies(), CurrentReceivablesFromGroupCompaniesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalOtherCurrentReceivables(), TotalOtherCurrentReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"End-Total", '', '', 0, OtherCurrentReceivables() + '..' + TotalOtherCurrentReceivables(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(TotalReceivables(), TotalReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"End-Total", '', '', 0, Receivables() + '..' + TotalReceivables(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(PrepaidexpensesandAccruedIncome(), PrepaidexpensesandAccruedIncomeName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(PrepaidRent(), PrepaidRentName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(PrepaidInterestExpense(), PrepaidInterestExpenseName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(AccruedRentalIncome(), AccruedRentalIncomeName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(AccruedInterestIncome(), AccruedInterestIncomeName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(AssetsInFormOfPrepaidExpenses(), AssetsInFormOfPrepaidExpensesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(OtherPrepaidExpensesAndAccruedIncome(), OtherPrepaidExpensesAndAccruedIncomeName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalPrepaidExpensesAndAccruedIncome(), TotalPrepaidExpensesAndAccruedIncomeName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"End-Total", '', '', 0, PrepaidexpensesandAccruedIncome() + '..' + TotalPrepaidExpensesAndAccruedIncome(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(ShortTermInvestments(), ShortTermInvestmentsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(ConvertibleDebtInstruments(), ConvertibleDebtInstrumentsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(OtherShortTermInvestments(), OtherShortTermInvestmentsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(WriteDownofShortTermInvestments(), WriteDownofShortTermInvestmentsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalShortTermInvestments(), TotalShortTermInvestmentsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"End-Total", '', '', 0, ShortTermInvestments() + '..' + TotalShortTermInvestments(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(CashandBank(), CashandBankName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(BusinessAccountOperatingDomestic(), BusinessAccountOperatingDomesticName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(BusinessAccountOperatingForeign(), BusinessAccountOperatingForeignName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(OtherBankAccounts(), OtherBankAccountsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CertificateofDeposit(), CertificateofDepositName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalCashandBank(), TotalCashandBankName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::"End-Total", '', '', 0, CashandBank() + '..' + TotalCashandBank(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(Liability(), LiabilityName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(BondsandDebentureLoans(), BondsandDebentureLoansName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ConvertiblesLoans(), ConvertiblesLoansName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(OtherLongTermLiabilities(), OtherLongTermLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(BankOverdraftFacilities(), BankOverdraftFacilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalLongTermLiabilities(), TotalLongTermLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::"End-Total", '', '', 0, CreateGLAccount.LongtermLiabilities() + '..' + TotalLongTermLiabilities(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(CurrentLiabilities(), CurrentLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(AccountsPayableDomestic(), AccountsPayableDomesticName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(AccountsPayableForeign(), AccountsPayableForeignName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(Advancesfromcustomers(), AdvancesfromcustomersName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ChangeinWorkinProgress(), ChangeinWorkinProgressName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(BankOverdraftShortTerm(), BankOverdraftShortTermName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CreateGLAccount.OtherLiabilities(), CreateGLAccount.OtherLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalCurrentLiabilities(), TotalCurrentLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::"End-Total", '', '', 0, CurrentLiabilities() + '..' + TotalCurrentLiabilities(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(TaxLiabilities(), TaxLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(SalesTaxVATLiable(), SalesTaxVATLiableName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TaxesLiable(), TaxesLiableName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(EstimatedIncomeTax(), EstimatedIncomeTaxName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(EstimatedPayrolltaxonPensionCosts(), EstimatedPayrolltaxonPensionCostsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalTaxLiabilities(), TotalTaxLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::"End-Total", '', '', 0, TaxLiabilities() + '..' + TotalTaxLiabilities(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(PayrollLiabilities(), PayrollLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(EmployeesWithholdingTaxes(), EmployeesWithholdingTaxesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(StatutorySocialsecurityContributions(), StatutorySocialsecurityContributionsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ContractualSocialSecurityContributions(), ContractualSocialSecurityContributionsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(AttachmentsofEarning(), AttachmentsofEarningName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(HolidayPayfund(), HolidayPayfundName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(OtherSalaryWageDeductions(), OtherSalaryWageDeductionsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalPayrollLiabilities(), TotalPayrollLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::"End-Total", '', '', 0, PayrollLiabilities() + '..' + TotalPayrollLiabilities(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(OtherCurrentLiabilities(), OtherCurrentLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(ClearingAccountforFactoringCurrentPortion(), ClearingAccountforFactoringCurrentPortionName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CurrentLiabilitiestoEmployees(), CurrentLiabilitiestoEmployeesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ClearingAccountforThirdParty(), ClearingAccountforThirdPartyName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CurrentLoans(), CurrentLoansName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(LiabilitiesGrantsReceived(), LiabilitiesGrantsReceivedName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalOtherCurrentLiabilities(), TotalOtherCurrentLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::"End-Total", '', '', 0, OtherCurrentLiabilities() + '..' + TotalOtherCurrentLiabilities(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(AccruedExpensesandDeferredIncome(), AccruedExpensesandDeferredIncomeName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(AccruedWagesSalaries(), AccruedWagesSalariesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(AccruedHolidayPay(), AccruedHolidayPayName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(AccruedPensionCosts(), AccruedPensionCostsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(AccruedInterestExpense(), AccruedInterestExpenseName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(DeferredIncome(), DeferredIncomeName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(AccruedContractualCosts(), AccruedContractualCostsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(OtherAccruedExpensesandDeferredIncome(), OtherAccruedExpensesandDeferredIncomeName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalAccruedExpensesandDeferredIncome(), TotalAccruedExpensesandDeferredIncomeName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, Enum::"G/L Account Type"::"End-Total", '', '', 0, AccruedExpensesandDeferredIncome() + '..' + TotalAccruedExpensesandDeferredIncome(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(Equity(), EquityName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(EquityPartner(), EquityPartnerName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(NetResults(), NetResultsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(RestrictedEquity(), RestrictedEquityName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ShareCapital(), ShareCapitalName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(NonRestrictedEquity(), NonRestrictedEquityName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ProfitorLossFromthePreviousYear(), ProfitorLossFromthePreviousYearName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ResultsfortheFinancialYear(), ResultsfortheFinancialYearName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(DistributionstoShareholders(), DistributionstoShareholdersName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalEquity(), TotalEquityName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, Enum::"G/L Account Type"::"End-Total", '', '', 0, Equity() + '..' + TotalEquity(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(CreateGLAccount.IncomeStatement(), CreateGLAccount.IncomeStatementName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Heading, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(Income(), IncomeName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(SalesofGoods(), SalesofGoodsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(SaleofFinishedGoods(), SaleofFinishedGoodsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Posting, CreatePostingGroups.DomesticPostingGroup(), CreatePostingGroups.RetailPostingGroup(), 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(SaleofRawMaterials(), SaleofRawMaterialsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Posting, CreatePostingGroups.DomesticPostingGroup(), CreatePostingGroups.RetailPostingGroup(), 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ResaleofGoods(), ResaleofGoodsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Posting, CreatePostingGroups.DomesticPostingGroup(), CreatePostingGroups.RetailPostingGroup(), 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalSalesofGoods(), TotalSalesofGoodsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::"End-Total", '', '', 0, SalesofGoods() + '..' + TotalSalesofGoods(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(SaleofResources(), SaleofResourcesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Posting, CreatePostingGroups.DomesticPostingGroup(), CreatePostingGroups.ServicesPostingGroup(), 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(SaleofSubcontracting(), SaleofSubcontractingName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Posting, CreatePostingGroups.DomesticPostingGroup(), CreatePostingGroups.ServicesPostingGroup(), 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalSalesofResources(), TotalSalesofResourcesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::"End-Total", '', '', 0, CreateGLAccount.SalesofResources() + '..' + TotalSalesofResources(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(AdditionalRevenue(), AdditionalRevenueName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(IncomeFromSecurities(), IncomeFromSecuritiesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ManagementFeeRevenue(), ManagementFeeRevenueName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CurrencyGains(), CurrencyGainsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(OtherIncidentalRevenue(), OtherIncidentalRevenueName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalAdditionalRevenue(), TotalAdditionalRevenueName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::"End-Total", '', '', 0, AdditionalRevenue() + '..' + TotalAdditionalRevenue(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(JobsandServices(), JobsandServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(JobSalesApplied(), JobSalesAppliedName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(SalesofServiceContracts(), SalesofServiceContractsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Posting, CreatePostingGroups.DomesticPostingGroup(), CreatePostingGroups.RetailPostingGroup(), 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(SalesofServiceWork(), SalesofServiceWorkName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalJobsandServices(), TotalJobsandServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::"End-Total", '', '', 0, JobsandServices() + '..' + TotalJobsandServices(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(RevenueReductions(), RevenueReductionsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(SalesDiscounts(), SalesDiscountsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(SalesInvoiceRounding(), SalesInvoiceRoundingName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Posting, CreatePostingGroups.DomesticPostingGroup(), CreatePostingGroups.RetailPostingGroup(), 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(PaymentToleranceandAllowances(), PaymentToleranceandAllowancesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(SalesReturns(), SalesReturnsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalRevenueReductions(), TotalRevenueReductionsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::"End-Total", '', '', 0, RevenueReductions() + '..' + TotalRevenueReductions(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(TotalIncome(), TotalIncomeName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::"End-Total", '', '', 0, Income() + '..' + TotalIncome(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(CostofGoodsSold(), CostofGoodsSoldName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(CostofGoods(), CostofGoodsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(CostofMaterials(), CostofMaterialsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CostofMaterialsProjects(), CostofMaterialsProjectsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalCostofGoods(), TotalCostofGoodsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", Enum::"G/L Account Type"::"End-Total", '', '', 0, CostofGoods() + '..' + TotalCostofGoods(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(CostofResourcesandServices(), CostofResourcesandServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(CostofLabor(), CostofLaborName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CostofLaborProjects(), CostofLaborProjectsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CostofLaborWarrantyContract(), CostofLaborWarrantyContractName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalCostofResources(), TotalCostofResourcesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", Enum::"G/L Account Type"::"End-Total", '', '', 0, CostofResourcesandServices() + '..' + TotalCostofResources(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(SubcontractedWork(), SubcontractedWorkName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CostofVariances(), CostofVariancesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalCostofGoodsSold(), TotalCostofGoodsSoldName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", Enum::"G/L Account Type"::"End-Total", '', '', 0, CostofGoodsSold() + '..' + TotalCostofGoodsSold(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(Expenses(), ExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(FacilityExpenses(), FacilityExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(RentalFacilities(), RentalFacilitiesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(RentLeases(), RentLeasesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ElectricityforRental(), ElectricityforRentalName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(HeatingforRental(), HeatingforRentalName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(WaterandSewerageforRental(), WaterandSewerageforRentalName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CleaningandWasteforRental(), CleaningandWasteforRentalName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(RepairsandMaintenanceforRental(), RepairsandMaintenanceforRentalName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(InsurancesRental(), InsurancesRentalName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(OtherRentalExpenses(), OtherRentalExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalRentalFacilities(), TotalRentalFacilitiesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, RentalFacilities() + '..' + TotalRentalFacilities(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(PropertyExpenses(), PropertyExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(SiteFeesLeases(), SiteFeesLeasesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ElectricityforProperty(), ElectricityforPropertyName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(HeatingforProperty(), HeatingforPropertyName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(WaterandSewerageforProperty(), WaterandSewerageforPropertyName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CleaningandWasteforProperty(), CleaningandWasteforPropertyName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(RepairsandMaintenanceforProperty(), RepairsandMaintenanceforPropertyName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(InsurancesProperty(), InsurancesPropertyName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(OtherPropertyExpenses(), OtherPropertyExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalPropertyExpenses(), TotalPropertyExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, PropertyExpenses() + '..' + TotalPropertyExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(TotalFacilityExpenses(), TotalFacilityExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, FacilityExpenses() + '..' + TotalFacilityExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(FixedAssetsLeases(), FixedAssetsLeasesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(HireofMachinery(), HireofMachineryName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(HireofComputers(), HireofComputersName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(HireofOtherFixedAssets(), HireofOtherFixedAssetsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalFixedAssetLeases(), TotalFixedAssetLeasesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, FixedAssetsLeases() + '..' + TotalFixedAssetLeases(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(LogisticsExpenses(), LogisticsExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(PassengerCarCosts(), PassengerCarCostsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TruckCosts(), TruckCostsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(OtherVehicleExpenses(), OtherVehicleExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalVehicleExpenses(), TotalVehicleExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, CreateGLAccount.VehicleExpenses() + '..' + TotalVehicleExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(FreightCosts(), FreightCostsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(FreightFeesForGoods(), FreightFeesForGoodsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CustomsandForwarding(), CustomsandForwardingName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(FreightFeesProjects(), FreightFeesProjectsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalFreightCosts(), TotalFreightCostsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, FreightCosts() + '..' + TotalFreightCosts(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(TravelExpenses(), TravelExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(Tickets(), TicketsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(RentalVehicles(), RentalVehiclesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(BoardandLodging(), BoardandLodgingName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(OtherTravelExpenses(), OtherTravelExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalTravelExpenses(), TotalTravelExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, TravelExpenses() + '..' + TotalTravelExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(TotalLogisticsExpenses(), TotalLogisticsExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, LogisticsExpenses() + '..' + TotalLogisticsExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(MarketingandSales(), MarketingandSalesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(CreateGlAccount.Advertising(), CreateGlAccount.AdvertisingName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(AdvertisementDevelopment(), AdvertisementDevelopmentName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(OutdoorandTransportationAds(), OutdoorandTransportationAdsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(AdMatterandDirectMailings(), AdMatterandDirectMailingsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ConferenceExhibitionSponsorship(), ConferenceExhibitionSponsorshipName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(SamplesContestsGifts(), SamplesContestsGiftsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(FilmTVRadioInternetAds(), FilmTVRadioInternetAdsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(PRandAgencyFees(), PRandAgencyFeesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(OtherAdvertisingFees(), OtherAdvertisingFeesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalAdvertising(), TotalAdvertisingName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, CreateGLAccount.Advertising() + '..' + TotalAdvertising(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(OtherMarketingExpenses(), OtherMarketingExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(CatalogsPriceLists(), CatalogsPriceListsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TradePublications(), TradePublicationsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalOtherMarketingExpenses(), TotalOtherMarketingExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, OtherMarketingExpenses() + '..' + TotalOtherMarketingExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(SalesExpenses(), SalesExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(CreditCardCharges(), CreditCardChargesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(BusinessEntertainingDeductible(), BusinessEntertainingDeductibleName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(BusinessEntertainingNonDeductible(), BusinessEntertainingNonDeductibleName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalSalesExpenses(), TotalSalesExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, SalesExpenses() + '..' + TotalSalesExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(TotalMarketingandSales(), TotalMarketingandSalesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, MarketingandSales() + '..' + TotalMarketingandSales(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(OfficeExpenses(), OfficeExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(PhoneServices(), PhoneServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(DataServices(), DataServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(PostalFees(), PostalFeesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ConsumableExpensibleHardware(), ConsumableExpensibleHardwareName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(SoftwareandSubscriptionFees(), SoftwareandSubscriptionFeesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalOfficeExpenses(), TotalOfficeExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, OfficeExpenses() + '..' + TotalOfficeExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(InsurancesandRisks(), InsurancesandRisksName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(CorporateInsurance(), CorporateInsuranceName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(DamagesPaid(), DamagesPaidName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(BadDebtLosses(), BadDebtLossesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(SecurityServices(), SecurityServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(OtherRiskExpenses(), OtherRiskExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalInsurancesandRisks(), TotalInsurancesandRisksName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, InsurancesandRisks() + '..' + TotalInsurancesandRisks(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(ManagementandAdmin(), ManagementandAdminName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(Management(), ManagementName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(RemunerationtoDirectors(), RemunerationtoDirectorsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ManagementFees(), ManagementFeesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(AnnualInterrimReports(), AnnualInterrimReportsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(AnnualGeneralMeeting(), AnnualGeneralMeetingName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(AuditandAuditServices(), AuditandAuditServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TaxAdvisoryServices(), TaxAdvisoryServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalManagementFees(), TotalManagementFeesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, Management() + '..' + TotalManagementFees(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(TotalManagementandAdmin(), TotalManagementandAdminName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, ManagementandAdmin() + '..' + TotalManagementandAdmin(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(BankingandInterest(), BankingandInterestName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(BankingFees(), BankingFeesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CreateGlAccount.InterestExpenses(), CreateGlAccount.InterestExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(PayableInvoiceRounding(), PayableInvoiceRoundingName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, CreatePostingGroups.DomesticPostingGroup(), CreatePostingGroups.RetailPostingGroup(), 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalBankingandInterest(), TotalBankingandInterestName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, BankingandInterest() + '..' + TotalBankingandInterest(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(ExternalServicesExpenses(), ExternalServicesExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(ExternalServices(), ExternalServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(AccountingServices(), AccountingServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ITServices(), ITServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(MediaServices(), MediaServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(ConsultingServices(), ConsultingServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(LegalFeesandAttorneyServices(), LegalFeesandAttorneyServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(OtherExternalServices(), OtherExternalServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalExternalServices(), TotalExternalServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, ExternalServices() + '..' + TotalExternalServices(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(OtherExternalExpenses(), OtherExternalExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(LicenseFeesRoyalties(), LicenseFeesRoyaltiesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TrademarksPatents(), TrademarksPatentsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(AssociationFees(), AssociationFeesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(MiscExternalExpenses(), MiscExternalExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(PurchaseDiscounts(), PurchaseDiscountsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalOtherExternalExpenses(), TotalOtherExternalExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, OtherExternalExpenses() + '..' + TotalOtherExternalExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(TotalExternalServicesExpenses(), TotalExternalServicesExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, ExternalServicesExpenses() + '..' + TotalExternalServicesExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(Personnel(), PersonnelName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(WagesandSalaries(), WagesandSalariesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(HourlyWages(), HourlyWagesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(OvertimeWages(), OvertimeWagesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(Bonuses(), BonusesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CommissionsPaid(), CommissionsPaidName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(PTOAccrued(), PTOAccruedName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalWagesandSalaries(), TotalWagesandSalariesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, WagesandSalaries() + '..' + TotalWagesandSalaries(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(BenefitsPension(), BenefitsPensionName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(Benefits(), BenefitsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(TrainingCosts(), TrainingCostsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(HealthCareContributions(), HealthCareContributionsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(EntertainmentofPersonnel(), EntertainmentofPersonnelName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CreateGlAccount.Allowances(), CreateGlAccount.AllowancesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 1, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(MandatoryClothingExpenses(), MandatoryClothingExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(OtherCashRemunerationBenefits(), OtherCashRemunerationBenefitsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalBenefits(), TotalBenefitsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, Benefits() + '..' + TotalBenefits(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(Pension(), PensionName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(PensionFeesandRecurringCosts(), PensionFeesandRecurringCostsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(EmployerContributions(), EmployerContributionsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalPension(), TotalPensionName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, Pension() + '..' + TotalPension(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(TotalBenefitsPension(), TotalBenefitsPensionName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, BenefitsPension() + '..' + TotalBenefitsPension(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(InsurancesPersonnel(), InsurancesPersonnelName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(HealthInsurance(), HealthInsuranceName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(DentalInsurance(), DentalInsuranceName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(WorkersCompensation(), WorkersCompensationName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(LifeInsurance(), LifeInsuranceName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalInsurancesPersonnel(), TotalInsurancesPersonnelName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, InsurancesPersonnel() + '..' + TotalInsurancesPersonnel(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(PersonnelTaxes(), PersonnelTaxesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(FederalPersonnelTaxes(), FederalPersonnelTaxesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(FederalWithholdingExpense(), FederalWithholdingExpenseName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(FICAExpense(), FICAExpenseName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(FUTAExpense(), FUTAExpenseName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(MedicareExpense(), MedicareExpenseName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(OtherFederalExpense(), OtherFederalExpenseName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalFederalPersonnelTaxes(), TotalFederalPersonnelTaxesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, FederalPersonnelTaxes() + '..' + TotalFederalPersonnelTaxes(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(StatePersonnelTaxes(), StatePersonnelTaxesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(StateWithholdingExpense(), StateWithholdingExpenseName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(SUTAExpense(), SUTAExpenseName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalStatePersonnelTaxes(), TotalStatePersonnelTaxesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, StatePersonnelTaxes() + '..' + TotalStatePersonnelTaxes(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(TotalPersonnelTaxes(), TotalPersonnelTaxesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, PersonnelTaxes() + '..' + TotalPersonnelTaxes(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(TotalPersonnel(), TotalPersonnelName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, Personnel() + '..' + TotalPersonnel(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(Depreciation(), DepreciationName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(DepreciationLandandProperty(), DepreciationLandandPropertyName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(DepreciationFixedAssets(), DepreciationFixedAssetsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalDepreciation(), TotalDepreciationName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, Depreciation() + '..' + TotalDepreciation(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(MiscExpenses(), MiscExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(CurrencyLosses(), CurrencyLossesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(TotalMiscExpenses(), TotalMiscExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, MiscExpenses() + '..' + TotalMiscExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(TotalExpenses(), TotalExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"End-Total", '', '', 0, Expenses() + '..' + TotalExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(InterestIncome(), InterestIncomeName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, CreatePostingGroups.DomesticPostingGroup(), CreatePostingGroups.RetailPostingGroup(), 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CreateGlAccount.NetIncome(), CreateGlAccount.NetIncomeName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Total, '', '', 1, CreateGLAccount.INCOMESTATEMENT() + '..' + '49999' + '|' + '50000' + '..' + '59999' + '|' + '60000' + '..' + CreateGLAccount.NETINCOME(), Enum::"General Posting Type"::" ", '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(CreateGlAccount.OfficeSupplies(), CreateGlAccount.OfficeSuppliesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CreateGlAccount.VehicleExpenses(), CreateGlAccount.VehicleExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); - ContosoGLAccount.InsertGLAccount(CreateGlAccount.Salaries(), CreateGlAccount.SalariesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CreateGlAccount.FinishedGoods(), CreateGlAccount.FinishedGoodsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CreateGlAccount.WIPJobSales(), CreateGlAccount.WIPJobSalesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CreateGlAccount.WIPJobCosts(), CreateGlAccount.WIPJobCostsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CreateGlAccount.RawMaterials(), CreateGlAccount.RawMaterialsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); - ContosoGLAccount.InsertGLAccount(CreateGlAccount.JobSales(), CreateGlAccount.JobSalesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + GLAccountCategoryMgt: Codeunit "G/L Account Category Mgt."; + SubCategory: Text[80]; + begin + SubCategory := Format(AccountCategory."Account Category"::Assets); + ContosoGLAccount.InsertGLAccount(CreateGLAccount.TotalAssets(), CreateGLAccount.TotalAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, CreateGLAccount.Assets() + '..' + CreateGLAccount.TotalAssets(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(CreateGLAccount.Assets(), CreateGLAccount.AssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(CreateGLAccount.TangibleFixedAssets(), CreateGLAccount.TangibleFixedAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(DeferredTaxAssets(), DeferredTaxAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CreateGLAccount.BalanceSheet(), CreateGLAccount.BalanceSheetName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Heading, '', '', 1, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(IntangibleFixedAssets(), IntangibleFixedAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(DevelopmentExpenditure(), DevelopmentExpenditureName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TenancySiteLeaseHoldandSimilarRights(), TenancySiteLeaseHoldandSimilarRightsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(Goodwill(), GoodwillName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(AdvancedPaymentsforIntangibleFixedAssets(), AdvancedPaymentsforIntangibleFixedAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalIntangibleFixedAssets(), TotalIntangibleFixedAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, IntangibleFixedAssets() + '..' + TotalIntangibleFixedAssets(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(LandandBuildings(), LandandBuildingsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(Building(), BuildingName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CostofImprovementstoLeasedProperty(), CostofImprovementstoLeasedPropertyName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(Land(), LandName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalLandandbuilding(), TotalLandandbuildingName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, LandandBuildings() + '..' + TotalLandandbuilding(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(MachineryandEquipment(), MachineryandEquipmentName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(TotalTangibleAssets(), TotalTangibleAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, CreateGLAccount.TangibleFixedAssets() + '..' + TotalTangibleAssets(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(FinancialandFixedAssets(), FinancialandFixedAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(LongTermReceivables(), LongTermReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ParticipationinGroupCompanies(), ParticipationinGroupCompaniesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(LoanstoPartnersorRelatedParties(), LoanstoPartnersorRelatedPartiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherLongTermReceivables(), OtherLongTermReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalFinancialandFixedAssets(), TotalFinancialandFixedAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, FinancialandFixedAssets() + '..' + TotalFinancialandFixedAssets(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(OtherCurrentReceivables(), OtherCurrentReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(CurrentReceivablefromEmployees(), CurrentReceivablefromEmployeesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(AccruedincomenotYetInvoiced(), AccruedincomenotYetInvoicedName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ClearingAccountsforTaxesandCharges(), ClearingAccountsforTaxesandChargesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TaxAssets(), TaxAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CurrentReceivablesFromGroupCompanies(), CurrentReceivablesFromGroupCompaniesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalOtherCurrentReceivables(), TotalOtherCurrentReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, OtherCurrentReceivables() + '..' + TotalOtherCurrentReceivables(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(TotalReceivables(), TotalReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, Receivables() + '..' + TotalReceivables(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(PrepaidexpensesandAccruedIncome(), PrepaidexpensesandAccruedIncomeName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(TotalPrepaidExpensesAndAccruedIncome(), TotalPrepaidExpensesAndAccruedIncomeName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, PrepaidexpensesandAccruedIncome() + '..' + TotalPrepaidExpensesAndAccruedIncome(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(ShortTermInvestments(), ShortTermInvestmentsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(ConvertibleDebtInstruments(), ConvertibleDebtInstrumentsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherShortTermInvestments(), OtherShortTermInvestmentsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(WriteDownofShortTermInvestments(), WriteDownofShortTermInvestmentsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalShortTermInvestments(), TotalShortTermInvestmentsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, ShortTermInvestments() + '..' + TotalShortTermInvestments(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(CashandBank(), CashandBankName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(TotalCashandBank(), TotalCashandBankName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, CashandBank() + '..' + TotalCashandBank(), Enum::"General Posting Type"::" ", '', '', false, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetCash(), 80); + ContosoGLAccount.InsertGLAccount(BusinessAccountOperatingDomestic(), BusinessAccountOperatingDomesticName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(BusinessAccountOperatingForeign(), BusinessAccountOperatingForeignName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(OtherBankAccounts(), OtherBankAccountsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CertificateofDeposit(), CertificateofDepositName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetAR(), 80); + ContosoGLAccount.InsertGLAccount(Receivables(), ReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(AccountsReceivables(), AccountsReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(AccountReceivableDomestic(), AccountReceivableDomesticName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(AccountReceivableForeign(), AccountReceivableForeignName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ContractualReceivables(), ContractualReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ConsignmentReceivables(), ConsignmentReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CreditcardsandVouchersReceivables(), CreditcardsandVouchersReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalAccountReceivables(), TotalAccountReceivablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, AccountsReceivables() + '..' + TotalAccountReceivables(), Enum::"General Posting Type"::" ", '', '', false, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetPrepaidExpenses(), 80); + ContosoGLAccount.InsertGLAccount(PrepaidRent(), PrepaidRentName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(PrepaidInterestExpense(), PrepaidInterestExpenseName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(AccruedRentalIncome(), AccruedRentalIncomeName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(AccruedInterestIncome(), AccruedInterestIncomeName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(AssetsInFormOfPrepaidExpenses(), AssetsInFormOfPrepaidExpensesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherPrepaidExpensesAndAccruedIncome(), OtherPrepaidExpensesAndAccruedIncomeName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetInventory(), 80); + ContosoGLAccount.InsertGLAccount(InventoriesProductsandWorkinProgress(), InventoriesProductsandWorkinProgressName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(SuppliesandConsumables(), SuppliesandConsumablesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ProductsinProgress(), ProductsinProgressName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(GoodsforResale(), GoodsforResaleName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(AdvancedPaymentsforGoodsandServices(), AdvancedPaymentsforGoodsandServicesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherInventoryItems(), OtherInventoryItemsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(WorkinProgress(), WorkinProgressName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(WorkinProgressFinishedGoods(), WorkinProgressFinishedGoodsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(WIPAccruedCosts(), WIPAccruedCostsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(WIPInvoicedSales(), WIPInvoicedSalesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalWorkinProgress(), TotalWorkinProgressName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, WorkinProgress() + '..' + TotalWorkinProgress(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(CreateGlAccount.FinishedGoods(), CreateGlAccount.FinishedGoodsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CreateGlAccount.WIPJobSales(), CreateGlAccount.WIPJobSalesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CreateGlAccount.WIPJobCosts(), CreateGlAccount.WIPJobCostsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CreateGlAccount.RawMaterials(), CreateGlAccount.RawMaterialsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetEquipment(), 80); + ContosoGLAccount.InsertGLAccount(EquipmentsandTools(), EquipmentsandToolsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(Computers(), ComputersName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CarsandOtherTransportEquipments(), CarsandOtherTransportEquipmentsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(LeasedAssets(), LeasedAssetsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalMachineryandEquipment(), TotalMachineryandEquipmentName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, MachineryandEquipment() + '..' + TotalMachineryandEquipment(), Enum::"General Posting Type"::" ", '', '', false, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetAccumDeprec(), 80); + ContosoGLAccount.InsertGLAccount(AccumulatedDepreciation(), AccumulatedDepreciationName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(AccountCategory."Account Category"::Liabilities, 80); + ContosoGLAccount.InsertGLAccount(Liability(), LiabilityName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(BondsandDebentureLoans(), BondsandDebentureLoansName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ConvertiblesLoans(), ConvertiblesLoansName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherLongTermLiabilities(), OtherLongTermLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(BankOverdraftFacilities(), BankOverdraftFacilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalLongTermLiabilities(), TotalLongTermLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, CreateGLAccount.LongtermLiabilities() + '..' + TotalLongTermLiabilities(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(CurrentLiabilities(), CurrentLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(TotalOtherCurrentLiabilities(), TotalOtherCurrentLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, OtherCurrentLiabilities() + '..' + TotalOtherCurrentLiabilities(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(AccruedExpensesandDeferredIncome(), AccruedExpensesandDeferredIncomeName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(AccruedWagesSalaries(), AccruedWagesSalariesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(AccruedHolidayPay(), AccruedHolidayPayName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(AccruedPensionCosts(), AccruedPensionCostsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(AccruedInterestExpense(), AccruedInterestExpenseName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(DeferredIncome(), DeferredIncomeName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(AccruedContractualCosts(), AccruedContractualCostsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherAccruedExpensesandDeferredIncome(), OtherAccruedExpensesandDeferredIncomeName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalAccruedExpensesandDeferredIncome(), TotalAccruedExpensesandDeferredIncomeName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, AccruedExpensesandDeferredIncome() + '..' + TotalAccruedExpensesandDeferredIncome(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(CreateGLAccount.LongtermLiabilities(), CreateGLAccount.LongtermLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetCurrentLiabilities(), 80); + ContosoGLAccount.InsertGLAccount(AccountsPayableDomestic(), AccountsPayableDomesticName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(AccountsPayableForeign(), AccountsPayableForeignName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(Advancesfromcustomers(), AdvancesfromcustomersName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ChangeinWorkinProgress(), ChangeinWorkinProgressName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(BankOverdraftShortTerm(), BankOverdraftShortTermName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CreateGLAccount.OtherLiabilities(), CreateGLAccount.OtherLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalCurrentLiabilities(), TotalCurrentLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, CurrentLiabilities() + '..' + TotalCurrentLiabilities(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(TaxLiabilities(), TaxLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(SalesTaxVATLiable(), SalesTaxVATLiableName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TaxesLiable(), TaxesLiableName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(EstimatedIncomeTax(), EstimatedIncomeTaxName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(EstimatedPayrolltaxonPensionCosts(), EstimatedPayrolltaxonPensionCostsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalTaxLiabilities(), TotalTaxLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, TaxLiabilities() + '..' + TotalTaxLiabilities(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(PayrollLiabilities(), PayrollLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(TotalPayrollLiabilities(), TotalPayrollLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, PayrollLiabilities() + '..' + TotalPayrollLiabilities(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(OtherCurrentLiabilities(), OtherCurrentLiabilitiesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(ClearingAccountforFactoringCurrentPortion(), ClearingAccountforFactoringCurrentPortionName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CurrentLiabilitiestoEmployees(), CurrentLiabilitiestoEmployeesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ClearingAccountforThirdParty(), ClearingAccountforThirdPartyName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CurrentLoans(), CurrentLoansName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(LiabilitiesGrantsReceived(), LiabilitiesGrantsReceivedName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetPayrollLiabilities(), 80); + ContosoGLAccount.InsertGLAccount(EmployeesWithholdingTaxes(), EmployeesWithholdingTaxesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(StatutorySocialsecurityContributions(), StatutorySocialsecurityContributionsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ContractualSocialSecurityContributions(), ContractualSocialSecurityContributionsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(AttachmentsofEarning(), AttachmentsofEarningName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(HolidayPayfund(), HolidayPayfundName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherSalaryWageDeductions(), OtherSalaryWageDeductionsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(AccountCategory."Account Category"::Equity, 80); + ContosoGLAccount.InsertGLAccount(Equity(), EquityName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(EquityPartner(), EquityPartnerName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(NetResults(), NetResultsName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(RestrictedEquity(), RestrictedEquityName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ShareCapital(), ShareCapitalName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(NonRestrictedEquity(), NonRestrictedEquityName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ProfitorLossFromthePreviousYear(), ProfitorLossFromthePreviousYearName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ResultsfortheFinancialYear(), ResultsfortheFinancialYearName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalEquity(), TotalEquityName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, Equity() + '..' + TotalEquity(), Enum::"General Posting Type"::" ", '', '', false, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetDistrToShareholders(), 80); + ContosoGLAccount.InsertGLAccount(DistributionstoShareholders(), DistributionstoShareholdersName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(AccountCategory."Account Category"::Income, 80); + ContosoGLAccount.InsertGLAccount(DiscountsandAllowances(), DiscountsandAllowancesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CreateGlAccount.JobSales(), CreateGlAccount.JobSalesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CreateGLAccount.IncomeStatement(), CreateGLAccount.IncomeStatementName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Heading, '', '', 1, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(Income(), IncomeName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(AdditionalRevenue(), AdditionalRevenueName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(IncomeFromSecurities(), IncomeFromSecuritiesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ManagementFeeRevenue(), ManagementFeeRevenueName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CurrencyGains(), CurrencyGainsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherIncidentalRevenue(), OtherIncidentalRevenueName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalAdditionalRevenue(), TotalAdditionalRevenueName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, AdditionalRevenue() + '..' + TotalAdditionalRevenue(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(JobsandServices(), JobsandServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(JobSalesApplied(), JobSalesAppliedName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(SalesofServiceContracts(), SalesofServiceContractsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Posting, CreatePostingGroups.DomesticPostingGroup(), CreatePostingGroups.RetailPostingGroup(), 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(SalesofServiceWork(), SalesofServiceWorkName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalJobsandServices(), TotalJobsandServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, JobsandServices() + '..' + TotalJobsandServices(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(RevenueReductions(), RevenueReductionsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(SalesDiscounts(), SalesDiscountsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(SalesInvoiceRounding(), SalesInvoiceRoundingName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Posting, CreatePostingGroups.DomesticPostingGroup(), CreatePostingGroups.RetailPostingGroup(), 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(PaymentToleranceandAllowances(), PaymentToleranceandAllowancesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(SalesReturns(), SalesReturnsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalRevenueReductions(), TotalRevenueReductionsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, RevenueReductions() + '..' + TotalRevenueReductions(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(TotalIncome(), TotalIncomeName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, Income() + '..' + TotalIncome(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(CreateGlAccount.NetIncome(), CreateGlAccount.NetIncomeName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Total, '', '', 0, CreateGLAccount.INCOMESTATEMENT() + '..' + '49999' + '|' + '50000' + '..' + '59999' + '|' + '60000' + '..' + CreateGLAccount.NETINCOME(), Enum::"General Posting Type"::" ", '', '', false, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetIncomeService(), 80); + ContosoGLAccount.InsertGLAccount(CreateGlAccount.SalesofResources(), CreateGlAccount.SalesofResourcesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(SaleofResources(), SaleofResourcesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Posting, CreatePostingGroups.DomesticPostingGroup(), CreatePostingGroups.ServicesPostingGroup(), 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(SaleofSubcontracting(), SaleofSubcontractingName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Posting, CreatePostingGroups.DomesticPostingGroup(), CreatePostingGroups.ServicesPostingGroup(), 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalSalesofResources(), TotalSalesofResourcesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, CreateGLAccount.SalesofResources() + '..' + TotalSalesofResources(), Enum::"General Posting Type"::" ", '', '', false, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetIncomeProdSales(), 80); + ContosoGLAccount.InsertGLAccount(SalesofGoods(), SalesofGoodsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(SaleofFinishedGoods(), SaleofFinishedGoodsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Posting, CreatePostingGroups.DomesticPostingGroup(), CreatePostingGroups.RetailPostingGroup(), 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(SaleofRawMaterials(), SaleofRawMaterialsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Posting, CreatePostingGroups.DomesticPostingGroup(), CreatePostingGroups.RetailPostingGroup(), 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ResaleofGoods(), ResaleofGoodsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Posting, CreatePostingGroups.DomesticPostingGroup(), CreatePostingGroups.RetailPostingGroup(), 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalSalesofGoods(), TotalSalesofGoodsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, SalesofGoods() + '..' + TotalSalesofGoods(), Enum::"General Posting Type"::" ", '', '', false, false, false); + + SubCategory := Format(AccountCategory."Account Category"::"Cost of Goods Sold", 80); + ContosoGLAccount.InsertGLAccount(TotalCostofGoodsSold(), TotalCostofGoodsSoldName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, CostofGoodsSold() + '..' + TotalCostofGoodsSold(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(CostofGoodsSold(), CostofGoodsSoldName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(SubcontractedWork(), SubcontractedWorkName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CostofVariances(), CostofVariancesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetCOGSLabor(), 80); + ContosoGLAccount.InsertGLAccount(TotalCostofResources(), TotalCostofResourcesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, CostofResourcesandServices() + '..' + TotalCostofResources(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(CostofResourcesandServices(), CostofResourcesandServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(CostofLabor(), CostofLaborName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CostofLaborProjects(), CostofLaborProjectsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CostofLaborWarrantyContract(), CostofLaborWarrantyContractName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetCOGSMaterials(), 80); + ContosoGLAccount.InsertGLAccount(TotalCostofGoods(), TotalCostofGoodsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, CostofGoods() + '..' + TotalCostofGoods(), Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(CostofGoods(), CostofGoodsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(CostofMaterials(), CostofMaterialsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CostofMaterialsProjects(), CostofMaterialsProjectsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::"Cost of Goods Sold", SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetRentExpense(), 80); + ContosoGLAccount.InsertGLAccount(RentLeases(), RentLeasesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetAdvertisingExpense(), 80); + ContosoGLAccount.InsertGLAccount(CreateGlAccount.Advertising(), CreateGlAccount.AdvertisingName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(AdvertisementDevelopment(), AdvertisementDevelopmentName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OutdoorandTransportationAds(), OutdoorandTransportationAdsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(AdMatterandDirectMailings(), AdMatterandDirectMailingsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ConferenceExhibitionSponsorship(), ConferenceExhibitionSponsorshipName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(SamplesContestsGifts(), SamplesContestsGiftsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(FilmTVRadioInternetAds(), FilmTVRadioInternetAdsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(PRandAgencyFees(), PRandAgencyFeesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherAdvertisingFees(), OtherAdvertisingFeesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalAdvertising(), TotalAdvertisingName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, CreateGLAccount.Advertising() + '..' + TotalAdvertising(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(OtherMarketingExpenses(), OtherMarketingExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(CatalogsPriceLists(), CatalogsPriceListsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TradePublications(), TradePublicationsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalOtherMarketingExpenses(), TotalOtherMarketingExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, OtherMarketingExpenses() + '..' + TotalOtherMarketingExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetInterestExpense(), 80); + ContosoGLAccount.InsertGLAccount(InterestIncome(), InterestIncomeName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, CreatePostingGroups.DomesticPostingGroup(), CreatePostingGroups.RetailPostingGroup(), 0, '', Enum::"General Posting Type"::Sale, '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetFeesExpense(), 80); + ContosoGLAccount.InsertGLAccount(BankingFees(), BankingFeesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CreateGlAccount.InterestExpenses(), CreateGlAccount.InterestExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetInsuranceExpense(), 80); + ContosoGLAccount.InsertGLAccount(InsurancesPersonnel(), InsurancesPersonnelName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(HealthInsurance(), HealthInsuranceName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(DentalInsurance(), DentalInsuranceName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(WorkersCompensation(), WorkersCompensationName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(LifeInsurance(), LifeInsuranceName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalInsurancesPersonnel(), TotalInsurancesPersonnelName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, InsurancesPersonnel() + '..' + TotalInsurancesPersonnel(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetBenefitsExpense(), 80); + ContosoGLAccount.InsertGLAccount(BenefitsPension(), BenefitsPensionName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(Benefits(), BenefitsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(TrainingCosts(), TrainingCostsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(HealthCareContributions(), HealthCareContributionsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(EntertainmentofPersonnel(), EntertainmentofPersonnelName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CreateGlAccount.Allowances(), CreateGlAccount.AllowancesName(), Enum::"G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(MandatoryClothingExpenses(), MandatoryClothingExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherCashRemunerationBenefits(), OtherCashRemunerationBenefitsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalBenefits(), TotalBenefitsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, Benefits() + '..' + TotalBenefits(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(Pension(), PensionName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(PensionFeesandRecurringCosts(), PensionFeesandRecurringCostsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(EmployerContributions(), EmployerContributionsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalPension(), TotalPensionName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, Pension() + '..' + TotalPension(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(TotalBenefitsPension(), TotalBenefitsPensionName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, BenefitsPension() + '..' + TotalBenefitsPension(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetRepairsExpense(), 80); + ContosoGLAccount.InsertGLAccount(RepairsandMaintenanceforRental(), RepairsandMaintenanceforRentalName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetUtilitiesExpense(), 80); + ContosoGLAccount.InsertGLAccount(ElectricityforRental(), ElectricityforRentalName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(HeatingforRental(), HeatingforRentalName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(WaterandSewerageforRental(), WaterandSewerageforRentalName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CleaningandWasteforRental(), CleaningandWasteforRentalName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetBadDebtExpense(), 80); + ContosoGLAccount.InsertGLAccount(BadDebtLosses(), BadDebtLossesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetTaxExpense(), 80); + ContosoGLAccount.InsertGLAccount(PersonnelTaxes(), PersonnelTaxesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(FederalPersonnelTaxes(), FederalPersonnelTaxesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(FederalWithholdingExpense(), FederalWithholdingExpenseName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(FICAExpense(), FICAExpenseName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(FUTAExpense(), FUTAExpenseName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(MedicareExpense(), MedicareExpenseName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherFederalExpense(), OtherFederalExpenseName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalFederalPersonnelTaxes(), TotalFederalPersonnelTaxesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, FederalPersonnelTaxes() + '..' + TotalFederalPersonnelTaxes(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(StatePersonnelTaxes(), StatePersonnelTaxesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(StateWithholdingExpense(), StateWithholdingExpenseName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(SUTAExpense(), SUTAExpenseName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalStatePersonnelTaxes(), TotalStatePersonnelTaxesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, StatePersonnelTaxes() + '..' + TotalStatePersonnelTaxes(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(TotalPersonnelTaxes(), TotalPersonnelTaxesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, PersonnelTaxes() + '..' + TotalPersonnelTaxes(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(TotalPersonnel(), TotalPersonnelName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, Personnel() + '..' + TotalPersonnel(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + + SubCategory := Format(AccountCategory."Account Category"::Expense, 80); + ContosoGLAccount.InsertGLAccount(Expenses(), ExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(FacilityExpenses(), FacilityExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(RentalFacilities(), RentalFacilitiesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(InsurancesRental(), InsurancesRentalName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherRentalExpenses(), OtherRentalExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalRentalFacilities(), TotalRentalFacilitiesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, RentalFacilities() + '..' + TotalRentalFacilities(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(PropertyExpenses(), PropertyExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(SiteFeesLeases(), SiteFeesLeasesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ElectricityforProperty(), ElectricityforPropertyName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(HeatingforProperty(), HeatingforPropertyName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(WaterandSewerageforProperty(), WaterandSewerageforPropertyName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CleaningandWasteforProperty(), CleaningandWasteforPropertyName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(RepairsandMaintenanceforProperty(), RepairsandMaintenanceforPropertyName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(InsurancesProperty(), InsurancesPropertyName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherPropertyExpenses(), OtherPropertyExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalPropertyExpenses(), TotalPropertyExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, PropertyExpenses() + '..' + TotalPropertyExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(TotalFacilityExpenses(), TotalFacilityExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, FacilityExpenses() + '..' + TotalFacilityExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(FixedAssetsLeases(), FixedAssetsLeasesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(HireofMachinery(), HireofMachineryName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(HireofComputers(), HireofComputersName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(HireofOtherFixedAssets(), HireofOtherFixedAssetsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalFixedAssetLeases(), TotalFixedAssetLeasesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, FixedAssetsLeases() + '..' + TotalFixedAssetLeases(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(LogisticsExpenses(), LogisticsExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(PassengerCarCosts(), PassengerCarCostsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TruckCosts(), TruckCostsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherVehicleExpenses(), OtherVehicleExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalVehicleExpenses(), TotalVehicleExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, CreateGLAccount.VehicleExpenses() + '..' + TotalVehicleExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(FreightCosts(), FreightCostsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(FreightFeesForGoods(), FreightFeesForGoodsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CustomsandForwarding(), CustomsandForwardingName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(FreightFeesProjects(), FreightFeesProjectsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalFreightCosts(), TotalFreightCostsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, FreightCosts() + '..' + TotalFreightCosts(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(TravelExpenses(), TravelExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(Tickets(), TicketsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(RentalVehicles(), RentalVehiclesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(BoardandLodging(), BoardandLodgingName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherTravelExpenses(), OtherTravelExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalTravelExpenses(), TotalTravelExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, TravelExpenses() + '..' + TotalTravelExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(TotalLogisticsExpenses(), TotalLogisticsExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, LogisticsExpenses() + '..' + TotalLogisticsExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(MarketingandSales(), MarketingandSalesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(SalesExpenses(), SalesExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(CreditCardCharges(), CreditCardChargesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(BusinessEntertainingDeductible(), BusinessEntertainingDeductibleName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(BusinessEntertainingNonDeductible(), BusinessEntertainingNonDeductibleName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalSalesExpenses(), TotalSalesExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, SalesExpenses() + '..' + TotalSalesExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(TotalMarketingandSales(), TotalMarketingandSalesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, MarketingandSales() + '..' + TotalMarketingandSales(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(OfficeExpenses(), OfficeExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(PhoneServices(), PhoneServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(DataServices(), DataServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(PostalFees(), PostalFeesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ConsumableExpensibleHardware(), ConsumableExpensibleHardwareName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(SoftwareandSubscriptionFees(), SoftwareandSubscriptionFeesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalOfficeExpenses(), TotalOfficeExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, OfficeExpenses() + '..' + TotalOfficeExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(InsurancesandRisks(), InsurancesandRisksName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(CorporateInsurance(), CorporateInsuranceName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(DamagesPaid(), DamagesPaidName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(SecurityServices(), SecurityServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherRiskExpenses(), OtherRiskExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalInsurancesandRisks(), TotalInsurancesandRisksName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, InsurancesandRisks() + '..' + TotalInsurancesandRisks(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(ManagementandAdmin(), ManagementandAdminName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(Management(), ManagementName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(RemunerationtoDirectors(), RemunerationtoDirectorsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ManagementFees(), ManagementFeesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(AnnualInterrimReports(), AnnualInterrimReportsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(AnnualGeneralMeeting(), AnnualGeneralMeetingName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(AuditandAuditServices(), AuditandAuditServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TaxAdvisoryServices(), TaxAdvisoryServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalManagementFees(), TotalManagementFeesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, Management() + '..' + TotalManagementFees(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(TotalManagementandAdmin(), TotalManagementandAdminName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, ManagementandAdmin() + '..' + TotalManagementandAdmin(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(BankingandInterest(), BankingandInterestName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(PayableInvoiceRounding(), PayableInvoiceRoundingName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, CreatePostingGroups.DomesticPostingGroup(), CreatePostingGroups.RetailPostingGroup(), 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalBankingandInterest(), TotalBankingandInterestName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, BankingandInterest() + '..' + TotalBankingandInterest(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(ExternalServicesExpenses(), ExternalServicesExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(ExternalServices(), ExternalServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(AccountingServices(), AccountingServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ITServices(), ITServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(MediaServices(), MediaServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ConsultingServices(), ConsultingServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(LegalFeesandAttorneyServices(), LegalFeesandAttorneyServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherExternalServices(), OtherExternalServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalExternalServices(), TotalExternalServicesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, ExternalServices() + '..' + TotalExternalServices(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(OtherExternalExpenses(), OtherExternalExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(LicenseFeesRoyalties(), LicenseFeesRoyaltiesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TrademarksPatents(), TrademarksPatentsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(AssociationFees(), AssociationFeesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(MiscExternalExpenses(), MiscExternalExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(PurchaseDiscounts(), PurchaseDiscountsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalOtherExternalExpenses(), TotalOtherExternalExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, OtherExternalExpenses() + '..' + TotalOtherExternalExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(TotalExternalServicesExpenses(), TotalExternalServicesExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, ExternalServicesExpenses() + '..' + TotalExternalServicesExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(Personnel(), PersonnelName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(WagesandSalaries(), WagesandSalariesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(HourlyWages(), HourlyWagesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OvertimeWages(), OvertimeWagesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(Bonuses(), BonusesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CommissionsPaid(), CommissionsPaidName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(PTOAccrued(), PTOAccruedName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalWagesandSalaries(), TotalWagesandSalariesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, WagesandSalaries() + '..' + TotalWagesandSalaries(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(Depreciation(), DepreciationName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(DepreciationLandandProperty(), DepreciationLandandPropertyName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(DepreciationFixedAssets(), DepreciationFixedAssetsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalDepreciation(), TotalDepreciationName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, Depreciation() + '..' + TotalDepreciation(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(MiscExpenses(), MiscExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(CurrencyLosses(), CurrencyLossesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TotalMiscExpenses(), TotalMiscExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, MiscExpenses() + '..' + TotalMiscExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(TotalExpenses(), TotalExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', 0, Expenses() + '..' + TotalExpenses(), Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(CreateGlAccount.OfficeSupplies(), CreateGlAccount.OfficeSuppliesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CreateGlAccount.VehicleExpenses(), CreateGlAccount.VehicleExpensesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(CreateGlAccount.Salaries(), CreateGlAccount.SalariesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); end; procedure DiscountsandAllowancesName(): Text[100] diff --git a/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/2.Master Data/CreateResourceUS.Codeunit.al b/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/2.Master Data/CreateResourceUS.Codeunit.al index e34eb565f1..6794abf4bd 100644 --- a/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/2.Master Data/CreateResourceUS.Codeunit.al +++ b/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/2.Master Data/CreateResourceUS.Codeunit.al @@ -5,8 +5,6 @@ codeunit 10519 "Create Resource US" InherentEntitlements = X; InherentPermissions = X; - //TODO- Post Code Hard coded. - [EventSubscriber(ObjectType::Table, Database::Resource, 'OnBeforeOnInsert', '', false, false)] local procedure OnInsertRecord(var Resource: Record Resource; var IsHandled: Boolean) var @@ -35,6 +33,27 @@ codeunit 10519 "Create Resource US" Resource.Validate("VAT Prod. Posting Group", VATProdPostingGroup); end; + internal procedure UpdateResourcesTaxGroup() + var + CreateResource: Codeunit "Create Resource"; + CreateTaxGroupUS: Codeunit "Create Tax Group US"; + begin + UpdateTaxGroupOnResource(CreateResource.Katherine(), CreateTaxGroupUS.Labor()); + UpdateTaxGroupOnResource(CreateResource.Lina(), CreateTaxGroupUS.Labor()); + UpdateTaxGroupOnResource(CreateResource.Marty(), CreateTaxGroupUS.Labor()); + UpdateTaxGroupOnResource(CreateResource.Terry(), CreateTaxGroupUS.Labor()); + end; + + local procedure UpdateTaxGroupOnResource(ResourceNo: Code[20]; TaxGroupCode: Code[20]) + var + Resource: Record Resource; + begin + Resource.Get(ResourceNo); + + Resource.Validate("Tax Group Code", TaxGroupCode); + Resource.Modify(true); + end; + var AtlantaLbl: Label 'Atlanta', MaxLength = 30; } \ No newline at end of file diff --git a/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/2.Master Data/CreateTaxGroupUS.Codeunit.al b/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/2.Master Data/CreateTaxGroupUS.Codeunit.al index 59ab9bab92..a9080b4463 100644 --- a/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/2.Master Data/CreateTaxGroupUS.Codeunit.al +++ b/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/2.Master Data/CreateTaxGroupUS.Codeunit.al @@ -5,7 +5,6 @@ codeunit 11463 "Create Tax Group US" trigger OnRun() var ContosoTaxUS: Codeunit "Contoso Tax US"; - CreateResource: Codeunit "Create Resource"; CreateUSGLAccount: Codeunit "Create US GL Accounts"; CreateGLAccount: Codeunit "Create G/L Account"; begin @@ -15,11 +14,6 @@ codeunit 11463 "Create Tax Group US" ContosoTaxUS.InsertTaxGroup(NonTaxable(), NonTaxableLbl); ContosoTaxUS.InsertTaxGroup(Supplies(), SuppliesLbl); - UpdateTaxGroupOnResource(CreateResource.Katherine(), Labor()); - UpdateTaxGroupOnResource(CreateResource.Lina(), Labor()); - UpdateTaxGroupOnResource(CreateResource.Marty(), Labor()); - UpdateTaxGroupOnResource(CreateResource.Terry(), Labor()); - UpdateTaxGroupOnGLAccount(CreateUSGLAccount.DevelopmentExpenditure(), NonTaxable()); UpdateTaxGroupOnGLAccount(CreateUSGLAccount.TenancySiteLeaseHoldandSimilarRights(), NonTaxable()); UpdateTaxGroupOnGLAccount(CreateUSGLAccount.Goodwill(), NonTaxable()); @@ -242,16 +236,6 @@ codeunit 11463 "Create Tax Group US" UpdateTaxGroupOnGLAccount(CreateUSGLAccount.CurrencyLosses(), NonTaxable()); end; - local procedure UpdateTaxGroupOnResource(ResourceNo: Code[20]; TaxGroupCode: Code[20]) - var - Resource: Record Resource; - begin - Resource.Get(ResourceNo); - - Resource.Validate("Tax Group Code", TaxGroupCode); - Resource.Modify(true); - end; - local procedure UpdateTaxGroupOnGLAccount(GLAccountNo: Code[20]; TaxGroupCode: Code[20]) var GLAccount: Record "G/L Account"; diff --git a/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Foundation/1.Setup Data/CreateSourceCodeUS.Codeunit.al b/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Foundation/1.Setup Data/CreateSourceCodeUS.Codeunit.al new file mode 100644 index 0000000000..5b82742a69 --- /dev/null +++ b/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Foundation/1.Setup Data/CreateSourceCodeUS.Codeunit.al @@ -0,0 +1,35 @@ +codeunit 10550 "Create Source Code US" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + SourceCodeSetup: Record "Source Code Setup"; + ContosoSourceCode: Codeunit "Contoso Source Code"; + begin + ContosoSourceCode.InsertSourceCode(COMPRTAX(), DateCompressTaxEntriesLbl); + ContosoSourceCode.InsertSourceCode(TAXSTMT(), CalculatePostTaxSettlementLbl); + + SourceCodeSetup.Get(); + SourceCodeSetup.Validate("VAT Settlement", TAXSTMT()); + SourceCodeSetup.Validate("Compress VAT Entries", COMPRTAX()); + SourceCodeSetup.Modify(true); + end; + + procedure COMPRTAX(): Code[10] + begin + exit(COMPRTAXTok); + end; + + procedure TAXSTMT(): Code[10] + begin + exit(TAXSTMTTok); + end; + + var + COMPRTAXTok: Label 'COMPRTAX', MaxLength = 10, Locked = true; + DateCompressTaxEntriesLbl: Label 'Date Compress Tax Entries', MaxLength = 100; + TAXSTMTTok: Label 'TAXSTMT', MaxLength = 10, Locked = true; + CalculatePostTaxSettlementLbl: Label 'Calculate and Post Tax Settlement', MaxLength = 100; +} \ No newline at end of file diff --git a/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Sales/2.Master Data/CreateShiptoAddressUS.Codeunit.al b/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Sales/2.Master Data/CreateShiptoAddressUS.Codeunit.al deleted file mode 100644 index 184b238a85..0000000000 --- a/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Sales/2.Master Data/CreateShiptoAddressUS.Codeunit.al +++ /dev/null @@ -1,61 +0,0 @@ -codeunit 11471 "Create Ship-to Address US" -{ - InherentEntitlements = X; - InherentPermissions = X; - - //TODO: PostCode Later to be replaced - - //ToDo Need to check later as Primary Key fields are changing - - trigger OnRun() - var - // ContosoCoffeeDemoDataSetup: Record "Contoso Coffee Demo Data Setup"; - // ContosoCustomerVendor: Codeunit "Contoso Customer/Vendor"; - // CreateCustomer: Codeunit "Create Customer"; - begin - // ContosoCoffeeDemoDataSetup.Get(); - // ContosoCustomerVendor.InsertShiptoAddress(CreateCustomer.DomesticAdatumCorporation(), LewesRoad(), AdatumCorporationLbl, LewesRoadAddressLbl, AtlantaCityLbl, ContosoCoffeeDemoDataSetup."Country/Region Code", '31772', GaLbl); - // ContosoCustomerVendor.InsertShiptoAddress(CreateCustomer.DomesticAdatumCorporation(), ParkRoad(), AdatumCorporationLbl, ParkRoadAddressLbl, AtlantaCityLbl, ContosoCoffeeDemoDataSetup."Country/Region Code", '31772', GaLbl); - // ContosoCustomerVendor.InsertShiptoAddress(CreateCustomer.DomesticTreyResearch(), Chicago(), TreyResearchLbl, ChicagoAddressLbl, ChicagoCityLbl, ContosoCoffeeDemoDataSetup."Country/Region Code", '61236', IlLbl); - // ContosoCustomerVendor.InsertShiptoAddress(CreateCustomer.DomesticTreyResearch(), Miami(), TreyResearchLbl, MiamiAddressLbl, MiamiCityLbl, ContosoCoffeeDemoDataSetup."Country/Region Code", '37125', FlLbl); - //ToDo Need to check later as Primary Key fields are changing - end; - - // procedure LewesRoad(): Code[10] - // begin - // exit(LewesRoadTok); - // end; - - // procedure ParkRoad(): Code[10] - // begin - // exit(ParkRoadTok); - // end; - - // procedure Chicago(): Code[10] - // begin - // exit(ChicagoTok); - // end; - - // procedure Miami(): Code[10] - // begin - // exit(MiamiTok); - // end; - - // var - // LewesRoadTok: Label 'LEWES ROAD', MaxLength = 10; - // ParkRoadTok: Label 'PARK ROAD', MaxLength = 10; - // ChicagoTok: Label 'CHICAGO', MaxLength = 10; - // MiamiTok: Label 'MIAMI', MaxLength = 10; - // AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; - // TreyResearchLbl: Label 'Trey Research', MaxLength = 100; - // LewesRoadAddressLbl: Label '2 Lewes Road', MaxLength = 100; - // ParkRoadAddressLbl: Label '10 Park Road', MaxLength = 100; - // ChicagoAddressLbl: Label '53 East Acton Road', MaxLength = 100; - // MiamiAddressLbl: Label '55 Cross Court', MaxLength = 100; - // AtlantaCityLbl: Label 'Atlanta', MaxLength = 30; - // ChicagoCityLbl: Label 'Chicago', MaxLength = 30; - // MiamiCityLbl: Label 'Miami', MaxLength = 30; - // GaLbl: Label 'GA', MaxLength = 30; - // IlLbl: Label 'IL', MaxLength = 30; - // FlLbl: Label 'FL', MaxLength = 30; -} \ No newline at end of file diff --git a/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoTool/USContosoLocalization.Codeunit.al b/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoTool/USContosoLocalization.Codeunit.al index fa1ecddee1..941247dce9 100644 --- a/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoTool/USContosoLocalization.Codeunit.al +++ b/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoTool/USContosoLocalization.Codeunit.al @@ -31,34 +31,39 @@ codeunit 11465 "US Contoso Localization" begin Codeunit.Run(Codeunit::"Create No. Series US"); Codeunit.Run(Codeunit::"Create Post Code US"); - Codeunit.Run(Codeunit::"Create Company Information US"); Codeunit.Run(Codeunit::"Create Job Queue Category US"); Codeunit.Run(Codeunit::"Create Data Exchange Def US"); + Codeunit.Run(Codeunit::"Create Source Code US"); end; + Enum::"Contoso Demo Data Level"::"Master Data": + Codeunit.Run(Codeunit::"Create Company Information US"); end; end; local procedure FinanceModule(ContosoDemoDataLevel: Enum "Contoso Demo Data Level") + var + CreateResourceUS: Codeunit "Create Resource US"; begin case ContosoDemoDataLevel of Enum::"Contoso Demo Data Level"::"Setup Data": begin Codeunit.Run(Codeunit::"Create General Ledger Setup US"); Codeunit.Run(Codeunit::"Create Posting Groups US"); - Codeunit.Run(Codeunit::"Create Acc. Schedule Line US"); Codeunit.Run(Codeunit::"Create Column Layout Name US"); Codeunit.Run(Codeunit::"Create Currency US"); + Codeunit.Run(Codeunit::"Create Tax Group US"); + Codeunit.Run(Codeunit::"Create Tax Setup US"); end; Enum::"Contoso Demo Data Level"::"Master Data": begin + Codeunit.Run(Codeunit::"Create Acc. Schedule Line US"); Codeunit.Run(Codeunit::"Create Column Layout US"); Codeunit.Run(Codeunit::"Create Curr Exchange Rate US"); - Codeunit.Run(Codeunit::"Create Tax Group US"); Codeunit.Run(Codeunit::"Create Tax Jurisdiction US"); - Codeunit.Run(Codeunit::"Create Tax Setup US"); Codeunit.Run(Codeunit::"Create Tax Area US"); Codeunit.Run(Codeunit::"Create Tax Area Line US"); Codeunit.Run(Codeunit::"Create Tax Detail US"); + CreateResourceUS.UpdateResourcesTaxGroup(); end; end; end; @@ -72,7 +77,6 @@ codeunit 11465 "US Contoso Localization" begin Codeunit.Run(Codeunit::"Create Customer US"); Codeunit.Run(Codeunit::"Create Sales Dimension ValueUS"); - Codeunit.Run(Codeunit::"Create Ship-to Address US"); end; Enum::"Contoso Demo Data Level"::"Transactional Data": Codeunit.Run(Codeunit::"Create Sales Document US"); @@ -100,11 +104,10 @@ codeunit 11465 "US Contoso Localization" local procedure InventoryModule(ContosoDemoDataLevel: Enum "Contoso Demo Data Level") begin case ContosoDemoDataLevel of + Enum::"Contoso Demo Data Level"::"Setup Data": + Codeunit.Run(Codeunit::"Create InventoryPostingSetupUS"); Enum::"Contoso Demo Data Level"::"Master Data": - begin - Codeunit.Run(Codeunit::"Create Location US"); - Codeunit.Run(Codeunit::"Create InventoryPostingSetupUS"); - end; + Codeunit.Run(Codeunit::"Create Location US"); end; end; diff --git a/Apps/US/IRSForms/app/src/APIs/IRSFormsExternalEvents.Codeunit.al b/Apps/US/IRSForms/app/src/APIs/IRSFormsExternalEvents.Codeunit.al index 8ffcd7f9f5..224e020eb1 100644 --- a/Apps/US/IRSForms/app/src/APIs/IRSFormsExternalEvents.Codeunit.al +++ b/Apps/US/IRSForms/app/src/APIs/IRSFormsExternalEvents.Codeunit.al @@ -17,7 +17,7 @@ codeunit 10043 "IRS Forms External Events" APIId: Guid; Url: Text[250]; WebClientUrl: Text[250]; - IRS1099FormDocApiUrlTok: Label 'v1.0/companies(%1)/irs1099documents(%2)', Locked = true; + IRS1099FormDocApiUrlTok: Label 'microsoft/irsforms/v1.0/companies(%1)/irs1099documents(%2)', Locked = true; begin if Rec.IsTemporary then exit; diff --git a/Apps/US/IRSForms/app/src/Extensions/IRS1099BaseAppSubscribers.Codeunit.al b/Apps/US/IRSForms/app/src/Extensions/IRS1099BaseAppSubscribers.Codeunit.al index a90094f474..b2481cc7d6 100644 --- a/Apps/US/IRSForms/app/src/Extensions/IRS1099BaseAppSubscribers.Codeunit.al +++ b/Apps/US/IRSForms/app/src/Extensions/IRS1099BaseAppSubscribers.Codeunit.al @@ -118,6 +118,8 @@ codeunit 10032 "IRS 1099 BaseApp Subscribers" if not IRSFormsFeature.IsEnabled() then exit; #endif + VendLedgEntry."IRS 1099 Reporting Period" := FromVendLedgEntry."IRS 1099 Reporting Period"; + VendLedgEntry."IRS 1099 Form No." := FromVendLedgEntry."IRS 1099 Form No."; VendLedgEntry."IRS 1099 Form Box No." := FromVendLedgEntry."IRS 1099 Form Box No."; VendLedgEntry."IRS 1099 Reporting Amount" := FromVendLedgEntry."IRS 1099 Reporting Amount"; VendLedgEntry."IRS 1099 Subject For Reporting" := FromVendLedgEntry."IRS 1099 Subject For Reporting"; diff --git a/Apps/US/IRSForms/app/src/Extensions/IRS1099VendorLedgerEntry.TableExt.al b/Apps/US/IRSForms/app/src/Extensions/IRS1099VendorLedgerEntry.TableExt.al index d6190fb638..e709287e20 100644 --- a/Apps/US/IRSForms/app/src/Extensions/IRS1099VendorLedgerEntry.TableExt.al +++ b/Apps/US/IRSForms/app/src/Extensions/IRS1099VendorLedgerEntry.TableExt.al @@ -20,7 +20,12 @@ tableextension 10035 "IRS 1099 Vendor Ledger Entry" extends "Vendor Ledger Entry { DataClassification = CustomerContent; TableRelation = "IRS Reporting Period"; - Editable = false; + + trigger OnValidate() + begin + IRS1099FormDocument.CheckIfVendLedgEntryAllowed(Rec."Entry No."); + Validate("IRS 1099 Form No.", ''); + end; } field(10032; "IRS 1099 Form No."; Code[20]) { diff --git a/Apps/US/IRSForms/test/src/IRS1099FormCalcTests.Codeunit.al b/Apps/US/IRSForms/test/src/IRS1099FormCalcTests.Codeunit.al index 6e754e90ad..401daa6dee 100644 --- a/Apps/US/IRSForms/test/src/IRS1099FormCalcTests.Codeunit.al +++ b/Apps/US/IRSForms/test/src/IRS1099FormCalcTests.Codeunit.al @@ -414,10 +414,10 @@ codeunit 148014 "IRS 1099 Form Calc. Tests" end; [Test] - [TransactionModel(TransactionModel::AutoRollback)] procedure OnlyAdjustment() var TempVendFormBoxBuffer: Record "IRS 1099 Vend. Form Box Buffer" temporary; + IRSReportingPeriod: Record "IRS Reporting Period"; PeriodNo: Code[20]; FormNo: Code[20]; FormBoxNo: Code[20]; @@ -446,6 +446,10 @@ codeunit 148014 "IRS 1099 Form Calc. Tests" LibraryIRS1099FormBox.VerifyCurrTempVendFormBoxBuffer( TempVendFormBoxBuffer, PeriodNo, FormNo, FormBoxNo, VendNo, 0, AdjustmentAmount, true); TempVendFormBoxBuffer.TestField("Adjustment Amount", AdjustmentAmount); + + // Tear Down + IRSReportingPeriod.SetRange("No.", PeriodNo); + IRSReportingPeriod.DeleteAll(true); end; [Test] diff --git a/Apps/US/IRSForms/test/src/IRS1099VendorTests.Codeunit.al b/Apps/US/IRSForms/test/src/IRS1099VendorTests.Codeunit.al index 94e8c6389e..c1c9a65fc9 100644 --- a/Apps/US/IRSForms/test/src/IRS1099VendorTests.Codeunit.al +++ b/Apps/US/IRSForms/test/src/IRS1099VendorTests.Codeunit.al @@ -152,8 +152,9 @@ codeunit 148011 "IRS 1099 Vendor Tests" #pragma warning restore AL0432 #endif VendorLedgerEntriesPage: TestPage "Vendor Ledger Entries"; - PeriodNo, FormNo, FormBoxNo, NewFormBoxNo : Code[20]; + NewPeriodNo, FormNo, NewFormNo, FormBoxNo, NewFormBoxNo : Code[20]; IRSAmount: Decimal; + NewDate: Date; begin // [SCENARIO 495389] Stan can change the IRS data in the posted vendor ledger entry @@ -161,28 +162,33 @@ codeunit 148011 "IRS 1099 Vendor Tests" #if not CLEAN25 BindSubscription(IRSFormsEnableFeature); #endif - PeriodNo := LibraryIRSReportingPeriod.CreateOneDayReportingPeriod(WorkDate()); + LibraryIRSReportingPeriod.CreateOneDayReportingPeriod(WorkDate()); FormNo := LibraryIRS1099FormBox.CreateSingleFormInReportingPeriod(WorkDate()); FormBoxNo := LibraryIRS1099FormBox.CreateSingleFormBoxInReportingPeriod(WorkDate(), FormNo); IRSAmount := LibraryRandom.RandDec(100, 2); // [GIVEN] Vendor Ledger Entry with IRS 1099 Code = MISC-01 and IRS Amount = 100 LibraryIRS1099Document.MockVendLedgEntryWithIRSData( VendorLedgerEntry, WorkDate(), WorkDate(), FormNo, FormBoxNo, IRSAmount); - NewFormBoxNo := LibraryIRS1099FormBox.CreateSingleFormBoxInReportingPeriod(WorkDate(), FormNo); + + NewDate := CalcDate('<1Y>', WorkDate()); + NewPeriodNo := LibraryIRSReportingPeriod.CreateOneDayReportingPeriod(NewDate); + NewFormNo := LibraryIRS1099FormBox.CreateSingleFormInReportingPeriod(NewDate); + NewFormBoxNo := LibraryIRS1099FormBox.CreateSingleFormBoxInReportingPeriod(NewDate, NewFormNo); IRSAmount := IRSAmount / 3; // [GIVEN] Vendor Ledger Entries page opened and filtered by Entry No. VendorLedgerEntriesPage.OpenEdit(); VendorLedgerEntriesPage.Filter.SetFilter("Entry No.", Format(VendorLedgerEntry."Entry No.")); // [WHEN] IRS 1099 Code is changed to MISC-2 and IRS Amount is changed to 90 - VendorLedgerEntriesPage."IRS 1099 Form No.".SetValue(FormNo); + VendorLedgerEntriesPage."IRS 1099 Reporting Period".SetValue(NewPeriodNo); + VendorLedgerEntriesPage."IRS 1099 Form No.".SetValue(NewFormNo); VendorLedgerEntriesPage."IRS 1099 Form Box No.".SetValue(NewFormBoxNo); VendorLedgerEntriesPage."IRS 1099 Reporting Amount".SetValue(IRSAmount); VendorLedgerEntriesPage.Close(); // [THEN] IRS 1099 Code in the Vendor Ledger Entry is MISC-2 and IRS Amount is 90 VendorLedgerEntry.Find(); VendorLedgerEntry.TestField("IRS 1099 Subject For Reporting", true); - VendorLedgerEntry.TestField("IRS 1099 Reporting Period", PeriodNo); - VendorLedgerEntry.TestField("IRS 1099 Form No.", FormNo); + VendorLedgerEntry.TestField("IRS 1099 Reporting Period", NewPeriodNo); + VendorLedgerEntry.TestField("IRS 1099 Form No.", NewFormNo); VendorLedgerEntry.TestField("IRS 1099 Form Box No.", NewFormBoxNo); VendorLedgerEntry.TestField("IRS 1099 Reporting Amount", IRSAmount); diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Bank/2.Master Data/CreateBankAccount.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Bank/2.Master Data/CreateBankAccount.Codeunit.al index 81c83a9dfa..b6df5bcdb1 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Bank/2.Master Data/CreateBankAccount.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Bank/2.Master Data/CreateBankAccount.Codeunit.al @@ -10,11 +10,27 @@ codeunit 5457 "Create Bank Account" CreateBankExImportSetup: Codeunit "Create Bank Ex/Import Setup"; CreateNoSeries: Codeunit "Create No. Series"; SalespersonPurchaser: Codeunit "Create Salesperson/Purchaser"; + CreateGenJournalTemplate: Codeunit "Create Gen. Journal Template"; + CreateBankJnlBaches: Codeunit "Create Bank Jnl. Batches"; begin ContosoCoffeeDemoDataSetup.Get(); ContosoBank.InsertBankAccount(Checking(), BankAccountDescriptionLbl, BankaccountAddressLbl, BankAccountCityLbl, BankAccountContactLbl, CheckingBankAccountNoLbl, -934400, CheckingTok, SalespersonPurchaser.OtisFalls(), ContosoCoffeeDemoDataSetup."Country/Region Code", '23', CreateNoSeries.PaymentReconciliationJournals(), PostCodeLbl, '199', BankBranchNoLbl, CreateBankExImportSetup.SEPACAMT()); ContosoBank.InsertBankAccount(Savings(), BankAccountDescriptionLbl, BankaccountAddressLbl, BankAccountCityLbl, BankAccountContactLbl, SavingBankAccountNoLbl, 0, SavingTok, SalespersonPurchaser.OtisFalls(), ContosoCoffeeDemoDataSetup."Country/Region Code", '', '', PostCodeLbl, '', BankBranchNoLbl, ''); + + UpdateBankJnlBatches(CreateGenJournalTemplate.General(), CreateBankJnlBaches.Daily(), Checking(), ''); + UpdateBankJnlBatches(CreateGenJournalTemplate.PaymentJournal(), CreateBankJnlBaches.PaymentReconciliation(), Checking(), CreateNoSeries.PaymentJournal()); + end; + + local procedure UpdateBankJnlBatches(JournalTemplateName: Code[10]; JournalBatchName: Code[10]; BankAccounNo: Code[20]; NoSeries: Code[20]) + var + GenJournalBatch: Record "Gen. Journal Batch"; + begin + GenJournalBatch.Get(JournalTemplateName, JournalBatchName); + + GenJournalBatch.Validate("Bal. Account No.", BankAccounNo); + GenJournalBatch.Validate("No. Series", NoSeries); + GenJournalBatch.Modify(true); end; procedure Checking(): Code[20] diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Bank/2.Master Data/CreateBankJnlBatches.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Bank/2.Master Data/CreateBankJnlBatches.Codeunit.al index 26484fa361..91be32479e 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Bank/2.Master Data/CreateBankJnlBatches.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Bank/2.Master Data/CreateBankJnlBatches.Codeunit.al @@ -8,10 +8,9 @@ codeunit 5665 "Create Bank Jnl. Batches" ContosoGeneralLedger: Codeunit "Contoso General Ledger"; CreateGenJournalTemplate: Codeunit "Create Gen. Journal Template"; CreateNoSeries: Codeunit "Create No. Series"; - CreateBankAccount: Codeunit "Create Bank Account"; begin - ContosoGeneralLedger.InsertGeneralJournalBatch(CreateGenJournalTemplate.General(), Daily(), DailyLbl, Enum::"Gen. Journal Account Type"::"Bank Account", CreateBankAccount.Checking(), '', false); - ContosoGeneralLedger.InsertGeneralJournalBatch(CreateGenJournalTemplate.PaymentJournal(), PaymentReconciliation(), PaymentReconciliationLbl, Enum::"Gen. Journal Account Type"::"Bank Account", CreateBankAccount.Checking(), CreateNoSeries.PaymentJournal(), true); + ContosoGeneralLedger.InsertGeneralJournalBatch(CreateGenJournalTemplate.General(), Daily(), DailyLbl, Enum::"Gen. Journal Account Type"::"Bank Account", '', CreateNoSeries.GeneralJournal(), false); + ContosoGeneralLedger.InsertGeneralJournalBatch(CreateGenJournalTemplate.PaymentJournal(), PaymentReconciliation(), PaymentReconciliationLbl, Enum::"Gen. Journal Account Type"::"Bank Account", '', CreateNoSeries.PaymentJournal(), true); end; procedure Daily(): Code[10] diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Bank/BankModule.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Bank/BankModule.Codeunit.al index 8f1e224b4c..108cfc6787 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Bank/BankModule.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Bank/BankModule.Codeunit.al @@ -20,12 +20,12 @@ codeunit 5635 "Bank Module" implements "Contoso Demo Data Module" Codeunit.Run(Codeunit::"Create Bank Acc. Posting Grp"); Codeunit.Run(Codeunit::"Create Bank Ex/Import Setup"); Codeunit.Run(Codeunit::"Create Payment Method"); + Codeunit.Run(Codeunit::"Create Bank Jnl. Batches"); end; procedure CreateMasterData() begin Codeunit.Run(Codeunit::"Create Bank Account"); - Codeunit.Run(Codeunit::"Create Bank Jnl. Batches"); Codeunit.Run(Codeunit::"Create Payment Reg. Setup"); end; diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/CRM/CRMModule.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/CRM/CRMModule.Codeunit.al index c6e510c11c..dccfc88aa5 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/CRM/CRMModule.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/CRM/CRMModule.Codeunit.al @@ -20,6 +20,10 @@ codeunit 5481 "CRM Module" implements "Contoso Demo Data Module" Codeunit.Run(Codeunit::"Create Interaction Template"); Codeunit.Run(Codeunit::"Create Business Relation"); Codeunit.Run(Codeunit::"Create Sales Cycle"); + Codeunit.Run(Codeunit::"Create Activity"); + Codeunit.Run(Codeunit::"Create Activity Step"); + Codeunit.Run(Codeunit::"Create Sales Cycle Stage"); + Codeunit.Run(Codeunit::"Create Profile Questionnaire"); Codeunit.Run(Codeunit::"Create Salutations"); Codeunit.Run(Codeunit::"Create Marketing Setup"); Codeunit.Run(Codeunit::"Create Word Template"); @@ -31,8 +35,6 @@ codeunit 5481 "CRM Module" implements "Contoso Demo Data Module" procedure CreateMasterData() begin - Codeunit.Run(Codeunit::"Create Activity"); - Codeunit.Run(Codeunit::"Create Activity Step"); Codeunit.Run(Codeunit::"Create Salesperson/Purchaser"); Codeunit.Run(Codeunit::"Create Campaign"); Codeunit.Run(Codeunit::"Create Close Opportunity Code"); @@ -40,7 +42,6 @@ codeunit 5481 "CRM Module" implements "Contoso Demo Data Module" Codeunit.Run(Codeunit::"Create Job Responsibility"); Codeunit.Run(Codeunit::"Create Mailing Group"); Codeunit.Run(Codeunit::"Create CRM Dimension Value"); - Codeunit.Run(Codeunit::"Create Sales Cycle Stage"); Codeunit.Run(Codeunit::"Create Salutation Formula"); Codeunit.Run(Codeunit::"Create Web Source"); end; @@ -49,7 +50,6 @@ codeunit 5481 "CRM Module" implements "Contoso Demo Data Module" begin Codeunit.Run(Codeunit::"Create Segment"); Codeunit.Run(Codeunit::"Create Opportunity"); - Codeunit.Run(Codeunit::"Create Profile Questionnaire"); end; procedure CreateHistoricalData() diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateAccScheduleLine.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateAccScheduleLine.Codeunit.al index c14c28e9c2..fb342298c0 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateAccScheduleLine.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateAccScheduleLine.Codeunit.al @@ -13,16 +13,6 @@ codeunit 5224 "Create Acc. Schedule Line" CreateGLAccount: Codeunit "Create G/L Account"; AccountScheduleName: Code[10]; begin - ContosoAccountSchedule.InsertAccScheduleLine('', 10000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine('', 20000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine('', 30000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine('', 40000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine('', 50000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine('', 60000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine('', 70000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine('', 80000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine('', 90000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); - AccountScheduleName := CreateAccountScheduleName.AccountCategoriesOverview(); ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 10000, '1000', BalanceSheetLbl, '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 20000, '1010', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); @@ -91,6 +81,38 @@ codeunit 5224 "Create Acc. Schedule Line" ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 290000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Cash Flow Entry Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 300000, 'R70', TotalCashFlowLbl, 'R50|R60', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + AccountScheduleName := CreateAccountScheduleName.Revenues(); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 10000, '', REVENUELbl, '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 20000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 30000, '', SalesofRetailLbl, '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 40000, '11', SalesRetailDomLbl, CreateGLAccount.SalesRetailDom(), Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 50000, '12', SalesRetailEULbl, CreateGLAccount.SalesRetailEU(), Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 60000, '13', SalesRetailExportLbl, CreateGLAccount.SalesRetailExport(), Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 70000, '14', JobSalesAdjmtRetailLbl, CreateGLAccount.JobSalesAppliedRetail(), Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 80000, '15', SalesofRetailTotalLbl, CreateGLAccount.TotalSalesofRetail(), Enum::"Acc. Schedule Line Totaling Type"::"Total Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 90000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 100000, '', RevenueArea10to30TotalLbl, CreateGLAccount.SalesRetailDom() + '..' + CreateGLAccount.TotalSalesofRetail(), Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '10..30', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 110000, '', RevenueArea40to85TotalLbl, CreateGLAccount.SalesRetailDom() + '..' + CreateGLAccount.TotalSalesofRetail(), Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '40..85', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 120000, '', RevenueNoAreacodeTotalLbl, CreateGLAccount.SalesRetailDom() + '..' + CreateGLAccount.TotalSalesofRetail(), Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 130000, '', RevenueTotalLbl, CreateGLAccount.SalesRetailDom() + '..' + CreateGLAccount.TotalSalesofRetail(), Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); + end; + + internal procedure CreateSetupAccScheduleLine() + var + CreateAccountScheduleName: Codeunit "Create Acc. Schedule Name"; + ContosoAccountSchedule: Codeunit "Contoso Account Schedule"; + AccountScheduleName: Code[10]; + begin + ContosoAccountSchedule.InsertAccScheduleLine('', 10000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine('', 20000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine('', 30000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine('', 40000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine('', 50000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine('', 60000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine('', 70000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine('', 80000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + ContosoAccountSchedule.InsertAccScheduleLine('', 90000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); + AccountScheduleName := CreateAccountScheduleName.CashCycle(); // ToDo: MS 10990 G/L Account could not be found ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 10000, '10', TotalRevenueLbl, '10990', Enum::"Acc. Schedule Line Totaling Type"::"Total Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 1); @@ -133,21 +155,6 @@ codeunit 5224 "Create Acc. Schedule Line" ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 70000, '70', OperatingMarginPerLbl, '-''60''/''10''*100', Enum::"Acc. Schedule Line Totaling Type"::Formula, Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 80000, '80', OtherExpensesLbl, '30300|30600|31200|31500|31900', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 90000, '90', IncomeBeforeInterestAndTaxLbl, '31995', Enum::"Acc. Schedule Line Totaling Type"::"Total Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, true, 0); - - AccountScheduleName := CreateAccountScheduleName.Revenues(); - ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 10000, '', REVENUELbl, '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 20000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 30000, '', SalesofRetailLbl, '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 40000, '11', SalesRetailDomLbl, CreateGLAccount.SalesRetailDom(), Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 50000, '12', SalesRetailEULbl, CreateGLAccount.SalesRetailEU(), Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 60000, '13', SalesRetailExportLbl, CreateGLAccount.SalesRetailExport(), Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 70000, '14', JobSalesAdjmtRetailLbl, CreateGLAccount.JobSalesAppliedRetail(), Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 80000, '15', SalesofRetailTotalLbl, CreateGLAccount.TotalSalesofRetail(), Enum::"Acc. Schedule Line Totaling Type"::"Total Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 90000, '', '', '', Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 100000, '', RevenueArea10to30TotalLbl, CreateGLAccount.SalesRetailDom() + '..' + CreateGLAccount.TotalSalesofRetail(), Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '10..30', false, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 110000, '', RevenueArea40to85TotalLbl, CreateGLAccount.SalesRetailDom() + '..' + CreateGLAccount.TotalSalesofRetail(), Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '40..85', false, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 120000, '', RevenueNoAreacodeTotalLbl, CreateGLAccount.SalesRetailDom() + '..' + CreateGLAccount.TotalSalesofRetail(), Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', false, false, false, false, 0); - ContosoAccountSchedule.InsertAccScheduleLine(AccountScheduleName, 130000, '', RevenueTotalLbl, CreateGLAccount.SalesRetailDom() + '..' + CreateGLAccount.TotalSalesofRetail(), Enum::"Acc. Schedule Line Totaling Type"::"Posting Accounts", Enum::"Acc. Schedule Line Show"::Yes, '', true, false, false, false, 0); end; var diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateAccScheduleName.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateAccScheduleName.Codeunit.al index e93a6dec48..31bae12342 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateAccScheduleName.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateAccScheduleName.Codeunit.al @@ -11,10 +11,6 @@ codeunit 5223 "Create Acc. Schedule Name" ContosoAccountSchedule.InsertAccScheduleName(AccountCategoriesOverview(), AccountCategoriesOverviewLbl, ''); ContosoAccountSchedule.InsertAccScheduleName(CapitalStructure(), CapitalStructureLbl, ''); ContosoAccountSchedule.InsertAccScheduleName(CashFlowCalculation(), CashFlowCalculationLbl, ''); - ContosoAccountSchedule.InsertAccScheduleName(CashCycle(), CashCycleDataLbl, ''); - ContosoAccountSchedule.InsertAccScheduleName(CashFlow(), CashFlowDataLbl, ''); - ContosoAccountSchedule.InsertAccScheduleName(IncomeExpense(), IncomeExpenseDataLbl, ''); - ContosoAccountSchedule.InsertAccScheduleName(ReducedTrialBalance(), ReducedTrialBalanceDataLbl, ''); ContosoAccountSchedule.InsertAccScheduleName(Revenues(), RevenuesLbl, CreateAnalysisView.SalesRevenue()); ContosoAccountSchedule.InsertAccScheduleName(BalanceSheetDetailed(), BalanceSheetDetailedLbl, ''); ContosoAccountSchedule.InsertAccScheduleName(BalanceSheetSummarized(), BalanceSheetSummarizedLbl, ''); @@ -23,6 +19,16 @@ codeunit 5223 "Create Acc. Schedule Name" ContosoAccountSchedule.InsertAccScheduleName(TrialBalance(), TrialBalanceLbl, ''); end; + internal procedure CreateSetupAccScheduleName() + var + ContosoAccountSchedule: Codeunit "Contoso Account Schedule"; + begin + ContosoAccountSchedule.InsertAccScheduleName(CashCycle(), CashCycleDataLbl, ''); + ContosoAccountSchedule.InsertAccScheduleName(CashFlow(), CashFlowDataLbl, ''); + ContosoAccountSchedule.InsertAccScheduleName(IncomeExpense(), IncomeExpenseDataLbl, ''); + ContosoAccountSchedule.InsertAccScheduleName(ReducedTrialBalance(), ReducedTrialBalanceDataLbl, ''); + end; + procedure AccountCategoriesOverview(): Code[10] begin exit(AccountCategoriesOverviewTok); diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateColumnLayoutName.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateColumnLayoutName.Codeunit.al index 05a92e63f7..9a656eebfa 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateColumnLayoutName.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateColumnLayoutName.Codeunit.al @@ -13,7 +13,6 @@ codeunit 5401 "Create Column Layout Name" ContosoAccountSchedule.InsertColumnLayoutName(CashFlowComparison(), CashFlowComparisonLbl); ContosoAccountSchedule.InsertColumnLayoutName(DefaultLayout(), DefaultLayoutLbl); ContosoAccountSchedule.InsertColumnLayoutName(KeyCashFlowRatio(), KeyCashFlowRatioLbl); - ContosoAccountSchedule.InsertColumnLayoutName(PeriodsDefinition(), PeriodsDefinitionLbl); ContosoAccountSchedule.InsertColumnLayoutName(BalanceSheetTrend(), BalanceSheetLbl); ContosoAccountSchedule.InsertColumnLayoutName(IncomeStatementTrend(), IncomeStatementLbl); @@ -30,6 +29,12 @@ codeunit 5401 "Create Column Layout Name" ContosoAccountSchedule.InsertColumnLayoutName(CurrentMonthVBudgetYearToDate(), CurrentMonthVBudgetYearToDateLbl); end; + internal procedure CreateSetupColumnLayoutName() + var + ContosoAccountSchedule: Codeunit "Contoso Account Schedule"; + begin + ContosoAccountSchedule.InsertColumnLayoutName(PeriodsDefinition(), PeriodsDefinitionLbl); + end; procedure ActualBudgetComparison(): Code[10] begin diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateDimension.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateDimension.Codeunit.al index 17b40a1c9a..b9d6a0a5a4 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateDimension.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateDimension.Codeunit.al @@ -12,6 +12,18 @@ codeunit 5463 "Create Dimension" ContosoDimension.InsertDimension(CustomerGroupDimension(), CustomerGroupLbl); ContosoDimension.InsertDimension(DepartmentDimension(), DepartmentLbl); ContosoDimension.InsertDimension(SalesCampaignDimension(), SalesCampaignLbl); + UpdateDimensionOnGeneralLedgerSetup() + end; + + local procedure UpdateDimensionOnGeneralLedgerSetup() + var + GeneralLedgerSetup: Record "General Ledger Setup"; + begin + GeneralLedgerSetup.Get(); + + GeneralLedgerSetup.Validate("Global Dimension 1 Code", DepartmentDimension()); + GeneralLedgerSetup.Validate("Global Dimension 2 Code", CustomerGroupDimension()); + GeneralLedgerSetup.Modify(true); end; procedure AreaDimension(): Code[20] diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateGenJournalBatch.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateGenJournalBatch.Codeunit.al index 5d67ef91fa..381e553b8d 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateGenJournalBatch.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateGenJournalBatch.Codeunit.al @@ -11,7 +11,7 @@ codeunit 5246 "Create Gen. Journal Batch" CreateGLAccount: Codeunit "Create G/L Account"; begin ContosoGeneralLedger.InsertGeneralJournalBatch(CreateGenJournalTemplate.General(), Monthly(), MonthlyLbl, Enum::"Gen. Journal Account Type"::"G/L Account", CreateGLAccount.Cash(), CreateNoSeries.GeneralJournal(), false); - ContosoGeneralLedger.InsertGeneralJournalBatch(CreateGenJournalTemplate.General(), Default(), DefaultLbl, Enum::"Gen. Journal Account Type"::"G/L Account", '', '', false); + ContosoGeneralLedger.InsertGeneralJournalBatch(CreateGenJournalTemplate.General(), Default(), DefaultLbl, Enum::"Gen. Journal Account Type"::"G/L Account", '', CreateNoSeries.GeneralJournal(), false); ContosoGeneralLedger.InsertGeneralJournalBatch(CreateGenJournalTemplate.CashReceipts(), General(), GeneralLbl, Enum::"Gen. Journal Account Type"::"G/L Account", CreateGLAccount.Cash(), CreateNoSeries.CashReceiptsJournal(), false); diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateGeneralLedgerSetup.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateGeneralLedgerSetup.Codeunit.al index 411ac944ef..bbae3cba77 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateGeneralLedgerSetup.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreateGeneralLedgerSetup.Codeunit.al @@ -8,12 +8,11 @@ codeunit 5230 "Create General Ledger Setup" CreateJobQueueCategory: Codeunit "Create Job Queue Category"; CreateNoSeries: Codeunit "Create No. Series"; CreateCurrency: Codeunit "Create Currency"; - CreateDimension: Codeunit "Create Dimension"; begin - InsertData(CreateJobQueueCategory.GeneralLedgerPosting(), 0.01, 1, CreateNoSeries.Bank(), CreateCurrency.GBP(), CreateDimension.DepartmentDimension(), CreateDimension.CustomerGroupDimension(), true, 4); + InsertData(CreateJobQueueCategory.GeneralLedgerPosting(), 0.01, 1, CreateNoSeries.Bank(), CreateCurrency.GBP(), true, 4); end; - procedure InsertData(JobQueueCategoryCode: Code[10]; InvoiceRoundingPrecisionLCY: Decimal; LocalContAddrFormat: Integer; BankAccountNo: Code[20]; LCYCode: Code[10]; GlobalDimension1Code: Code[20]; GlobalDimension2Code: Code[20]; DataCheck: Boolean; AccReceivablesCategory: Integer) + procedure InsertData(JobQueueCategoryCode: Code[10]; InvoiceRoundingPrecisionLCY: Decimal; LocalContAddrFormat: Integer; BankAccountNo: Code[20]; LCYCode: Code[10]; DataCheck: Boolean; AccReceivablesCategory: Integer) var GeneralLedgerSetup: Record "General Ledger Setup"; begin @@ -25,8 +24,6 @@ codeunit 5230 "Create General Ledger Setup" GeneralLedgerSetup.Validate("Local Cont. Addr. Format", LocalContAddrFormat); GeneralLedgerSetup.Validate("Bank Account Nos.", BankAccountNo); GeneralLedgerSetup.Validate("LCY Code", LCYCode); - GeneralLedgerSetup.Validate("Global Dimension 1 Code", GlobalDimension1Code); - GeneralLedgerSetup.Validate("Global Dimension 2 Code", GlobalDimension2Code); GeneralLedgerSetup.Validate("Enable Data Check", DataCheck); GeneralLedgerSetup.Validate("Acc. Receivables Category", AccReceivablesCategory); GeneralLedgerSetup.Modify(true); diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/2.Master data/CreateColumnLayout.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/2.Master data/CreateColumnLayout.Codeunit.al index 8ffafe7353..d4435b9c12 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/2.Master data/CreateColumnLayout.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/2.Master data/CreateColumnLayout.Codeunit.al @@ -9,10 +9,6 @@ codeunit 5395 "Create Column Layout" ContosoAccountSchedule: Codeunit "Contoso Account Schedule"; ColumnLayoutName: Code[10]; begin - ContosoAccountSchedule.InsertColumnLayout('', 10000, '', '', Enum::"Column Layout Type"::"Net Change", Enum::"Column Layout Entry Type"::Entries, '', false, Enum::"Column Layout Show"::Always, '', false); - ContosoAccountSchedule.InsertColumnLayout('', 20000, '', '', Enum::"Column Layout Type"::"Net Change", Enum::"Column Layout Entry Type"::Entries, '', false, Enum::"Column Layout Show"::Always, '', false); - ContosoAccountSchedule.InsertColumnLayout('', 30000, '', '', Enum::"Column Layout Type"::"Net Change", Enum::"Column Layout Entry Type"::Entries, '', false, Enum::"Column Layout Show"::Always, '', false); - ColumnLayoutName := CreateColumnLayoutName.ActualBudgetComparison(); ContosoAccountSchedule.InsertColumnLayout(ColumnLayoutName, 10000, 'A', NetChangeLbl, Enum::"Column Layout Type"::"Net Change", Enum::"Column Layout Entry Type"::Entries, '', false, Enum::"Column Layout Show"::Always, '', false); ContosoAccountSchedule.InsertColumnLayout(ColumnLayoutName, 20000, 'B', BudgetLbl, Enum::"Column Layout Type"::"Net Change", Enum::"Column Layout Entry Type"::"Budget Entries", '', false, Enum::"Column Layout Show"::Always, '', false); @@ -41,11 +37,6 @@ codeunit 5395 "Create Column Layout" ColumnLayoutName := CreateColumnLayoutName.KeyCashFlowRatio(); ContosoAccountSchedule.InsertColumnLayout(ColumnLayoutName, 10000, 'S10', KeyFigureLbl, Enum::"Column Layout Type"::"Balance at Date", Enum::"Column Layout Entry Type"::Entries, '', false, Enum::"Column Layout Show"::Always, '', false); - ColumnLayoutName := CreateColumnLayoutName.PeriodsDefinition(); - ContosoAccountSchedule.InsertColumnLayout(ColumnLayoutName, 10000, '10', CurrentPeriodLbl, Enum::"Column Layout Type"::"Net Change", Enum::"Column Layout Entry Type"::Entries, '', false, Enum::"Column Layout Show"::Always, '', false); - ContosoAccountSchedule.InsertColumnLayout(ColumnLayoutName, 20000, '10', CurrentPeriodMinus1Lbl, Enum::"Column Layout Type"::"Net Change", Enum::"Column Layout Entry Type"::Entries, '', false, Enum::"Column Layout Show"::Always, '-1P', false); - ContosoAccountSchedule.InsertColumnLayout(ColumnLayoutName, 30000, '10', CurrentPeriodMinus2Lbl, Enum::"Column Layout Type"::"Net Change", Enum::"Column Layout Entry Type"::Entries, '', false, Enum::"Column Layout Show"::Always, '-2P', false); - ColumnLayoutName := CreateColumnLayoutName.BeginningBalanceDebitsCreditsEndingBalance(); ContosoAccountSchedule.InsertColumnLayout(ColumnLayoutName, 10000, '1', BeginningBalanceLbl, Enum::"Column Layout Type"::"Beginning Balance", Enum::"Column Layout Entry Type"::Entries, '', false, Enum::"Column Layout Show"::Always, 'P', false); ContosoAccountSchedule.InsertColumnLayout(ColumnLayoutName, 20000, '2', DebitsLbl, Enum::"Column Layout Type"::"Net Change", Enum::"Column Layout Entry Type"::Entries, Enum::"Account Schedule Amount Type"::"Debit Amount", '', false, Enum::"Column Layout Show"::Always, 'P', false, 1033); @@ -144,6 +135,22 @@ codeunit 5395 "Create Column Layout" ContosoAccountSchedule.InsertColumnLayout(ColumnLayoutName, 130000, '', TotalLbl, Enum::"Column Layout Type"::Formula, Enum::"Column Layout Entry Type"::Entries, 'A', false, Enum::"Column Layout Show"::Always, '', false); end; + internal procedure CreateSetupColumnLayout() + var + CreateColumnLayoutName: Codeunit "Create Column Layout Name"; + ContosoAccountSchedule: Codeunit "Contoso Account Schedule"; + ColumnLayoutName: Code[10]; + begin + ContosoAccountSchedule.InsertColumnLayout('', 10000, '', '', Enum::"Column Layout Type"::"Net Change", Enum::"Column Layout Entry Type"::Entries, '', false, Enum::"Column Layout Show"::Always, '', false); + ContosoAccountSchedule.InsertColumnLayout('', 20000, '', '', Enum::"Column Layout Type"::"Net Change", Enum::"Column Layout Entry Type"::Entries, '', false, Enum::"Column Layout Show"::Always, '', false); + ContosoAccountSchedule.InsertColumnLayout('', 30000, '', '', Enum::"Column Layout Type"::"Net Change", Enum::"Column Layout Entry Type"::Entries, '', false, Enum::"Column Layout Show"::Always, '', false); + + ColumnLayoutName := CreateColumnLayoutName.PeriodsDefinition(); + ContosoAccountSchedule.InsertColumnLayout(ColumnLayoutName, 10000, '10', CurrentPeriodLbl, Enum::"Column Layout Type"::"Net Change", Enum::"Column Layout Entry Type"::Entries, '', false, Enum::"Column Layout Show"::Always, '', false); + ContosoAccountSchedule.InsertColumnLayout(ColumnLayoutName, 20000, '10', CurrentPeriodMinus1Lbl, Enum::"Column Layout Type"::"Net Change", Enum::"Column Layout Entry Type"::Entries, '', false, Enum::"Column Layout Show"::Always, '-1P', false); + ContosoAccountSchedule.InsertColumnLayout(ColumnLayoutName, 30000, '10', CurrentPeriodMinus2Lbl, Enum::"Column Layout Type"::"Net Change", Enum::"Column Layout Entry Type"::Entries, '', false, Enum::"Column Layout Show"::Always, '-2P', false); + end; + var NetChangeLbl: Label 'Net Change', MaxLength = 30; BudgetLbl: Label 'Budget', MaxLength = 30; diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/2.Master data/CreateFinancialReport.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/2.Master data/CreateFinancialReport.Codeunit.al index c16fa68f91..30a00262e1 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/2.Master data/CreateFinancialReport.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/2.Master data/CreateFinancialReport.Codeunit.al @@ -12,10 +12,6 @@ codeunit 5425 "Create Financial Report" ContosoAccountSchedule.InsertFinancialReport(AccountCategoriesOverview(), AccountCategoriesOverviewLbl, AccountScheduleName.AccountCategoriesOverview(), ColumnLayoutName.PeriodsDefinition()); ContosoAccountSchedule.InsertFinancialReport(CapitalStructure(), CapitalStructureLbl, AccountScheduleName.CapitalStructure(), ColumnLayoutName.BalanceOnly()); ContosoAccountSchedule.InsertFinancialReport(CalculationOfCashFlow(), CalculationOfCashFlowLbl, AccountScheduleName.CashFlowCalculation(), ColumnLayoutName.CashFlowComparison()); - ContosoAccountSchedule.InsertFinancialReport(DataForCashCycleChart(), DataForCashCycleChartLbl, AccountScheduleName.CashCycle(), ColumnLayoutName.PeriodsDefinition()); - ContosoAccountSchedule.InsertFinancialReport(DataForCashFlowChart(), DataForCashFlowChartLbl, AccountScheduleName.CashFlow(), ColumnLayoutName.PeriodsDefinition()); - ContosoAccountSchedule.InsertFinancialReport(DataForIncomeExpenseChart(), DataForIncomeExpenseChartLbl, AccountScheduleName.IncomeExpense(), ColumnLayoutName.PeriodsDefinition()); - ContosoAccountSchedule.InsertFinancialReport(DataForReducedTrialBalanceInfoPart(), DataForReducedTrialBalanceInfoPartLbl, AccountScheduleName.ReducedTrialBalance(), ColumnLayoutName.PeriodsDefinition()); ContosoAccountSchedule.InsertFinancialReport(Revenues(), RevenuesLbl, AccountScheduleName.Revenues(), ColumnLayoutName.BudgetAnalysis()); ContosoAccountSchedule.InsertFinancialReport(BalanceSheetDetailed(), BalanceSheetDetailedLbl, AccountScheduleName.BalanceSheetDetailed(), ColumnLayoutName.BalanceSheetTrend()); @@ -25,6 +21,18 @@ codeunit 5425 "Create Financial Report" ContosoAccountSchedule.InsertFinancialReport(TrialBalance(), TrialBalanceLbl, AccountScheduleName.TrialBalance(), ColumnLayoutName.BeginningBalanceDebitsCreditsEndingBalance()); end; + internal procedure CreateSetupFinancialReport() + var + ColumnLayoutName: Codeunit "Create Column Layout Name"; + ContosoAccountSchedule: Codeunit "Contoso Account Schedule"; + AccountScheduleName: Codeunit "Create Acc. Schedule Name"; + begin + ContosoAccountSchedule.InsertFinancialReport(DataForCashCycleChart(), DataForCashCycleChartLbl, AccountScheduleName.CashCycle(), ColumnLayoutName.PeriodsDefinition()); + ContosoAccountSchedule.InsertFinancialReport(DataForCashFlowChart(), DataForCashFlowChartLbl, AccountScheduleName.CashFlow(), ColumnLayoutName.PeriodsDefinition()); + ContosoAccountSchedule.InsertFinancialReport(DataForIncomeExpenseChart(), DataForIncomeExpenseChartLbl, AccountScheduleName.IncomeExpense(), ColumnLayoutName.PeriodsDefinition()); + ContosoAccountSchedule.InsertFinancialReport(DataForReducedTrialBalanceInfoPart(), DataForReducedTrialBalanceInfoPartLbl, AccountScheduleName.ReducedTrialBalance(), ColumnLayoutName.PeriodsDefinition()); + end; + procedure AccountCategoriesOverview(): Code[10] begin exit(AccountCategoriesOverviewTok); diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/FinanceModule.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/FinanceModule.Codeunit.al index b23e753d1e..f7729d6b14 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/FinanceModule.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/FinanceModule.Codeunit.al @@ -17,20 +17,25 @@ codeunit 5415 "Finance Module" implements "Contoso Demo Data Module" var CreatePostingGroups: Codeunit "Create Posting Groups"; CreateVATPostingGroups: Codeunit "Create VAT Posting Groups"; + CreateAccScheduleName: Codeunit "Create Acc. Schedule Name"; + CreateAccScheduleLine: Codeunit "Create Acc. Schedule Line"; + CreateColumnLayoutName: Codeunit "Create Column Layout Name"; + CreateColumnLayout: Codeunit "Create Column Layout"; + CreateFinancialReport: Codeunit "Create Financial Report"; begin Codeunit.Run(Codeunit::"Create VAT Posting Groups"); Codeunit.Run(Codeunit::"Create Posting Groups"); Codeunit.Run(Codeunit::"Create G/L Account"); CreatePostingGroups.UpdateGenPostingSetup(); CreateVATPostingGroups.UpdateVATPostingSetup(); - Codeunit.Run(Codeunit::"Create Dimension"); Codeunit.Run(Codeunit::"Create KPI Web Srv Setup"); - Codeunit.Run(Codeunit::"Create Analysis View"); - Codeunit.Run(Codeunit::"Create Acc. Schedule Name"); + CreateAccScheduleName.CreateSetupAccScheduleName(); + CreateAccScheduleLine.CreateSetupAccScheduleLine(); + CreateColumnLayoutName.CreateSetupColumnLayoutName(); + CreateColumnLayout.CreateSetupColumnLayout(); Codeunit.Run(Codeunit::"Create KPI Web Srv Line"); - Codeunit.Run(Codeunit::"Create Acc. Schedule Line"); - Codeunit.Run(Codeunit::"Create Column Layout Name"); Codeunit.Run(Codeunit::"Create Acc. Schedule Chart"); + Codeunit.Run(Codeunit::"Create Acc. Sched. Chart Line"); Codeunit.Run(Codeunit::"Create Chart Definition"); Codeunit.Run(Codeunit::"Create Currency"); Codeunit.Run(Codeunit::"Create General Ledger Setup"); @@ -40,18 +45,23 @@ codeunit 5415 "Finance Module" implements "Contoso Demo Data Module" Codeunit.Run(Codeunit::"Create VAT Reg. No. Format"); Codeunit.Run(Codeunit::"Create VAT Setup Posting Grp."); Codeunit.Run(Codeunit::"Create VAT Report Setup"); + Codeunit.Run(Codeunit::"Create VAT Statement"); + CreateFinancialReport.CreateSetupFinancialReport(); end; procedure CreateMasterData() begin + Codeunit.Run(Codeunit::"Create Dimension"); Codeunit.Run(Codeunit::"Create Dimension Value"); + Codeunit.Run(Codeunit::"Create Analysis View"); + Codeunit.Run(Codeunit::"Create Acc. Schedule Name"); + Codeunit.Run(Codeunit::"Create Acc. Schedule Line"); + Codeunit.Run(Codeunit::"Create Column Layout Name"); Codeunit.Run(Codeunit::"Create Column Layout"); Codeunit.Run(Codeunit::"Create Financial Report"); - Codeunit.Run(Codeunit::"Create Acc. Sched. Chart Line"); Codeunit.Run(Codeunit::"Categ. Generate Acc. Schedules"); Codeunit.Run(Codeunit::"Create Currency Exchange Rate"); Codeunit.Run(Codeunit::"Create Resource"); - Codeunit.Run(Codeunit::"Create VAT Statement"); end; procedure CreateTransactionalData() diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Foundation/1.Setup data/CreateCompanyInformation.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Foundation/1.Setup data/CreateCompanyInformation.Codeunit.al index c02067e355..245a4a7d5a 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Foundation/1.Setup data/CreateCompanyInformation.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Foundation/1.Setup data/CreateCompanyInformation.Codeunit.al @@ -2,6 +2,9 @@ codeunit 5228 "Create Company Information" { InherentEntitlements = X; InherentPermissions = X; + Permissions = + tabledata "Company Information" = rim, + tabledata "O365 Brand Color" = rimd; trigger OnRun() var @@ -11,6 +14,7 @@ codeunit 5228 "Create Company Information" ContosoCoffeeDemoDataSetup.Get(); ContosoCompany.SetOverwriteData(true); + CreateSetupCompany(); ContosoCompany.InsertCompanyInformation(DefaultCronusCompanyName(), '5 The Ring', 'Westminster', ContosoCoffeeDemoDataSetup."Country/Region Code", 'W2 8HG', 'London', 'Adam Matteson', '0666-666-6666', '0666-666-6660', '888-9999', 'World Wide Bank', 'BG99999', '99-99-888', 'GB 12 CPBK 08929965044991', '99-99-999', '777777777', DefaultCronusCompanyName(), '5 The Ring', 'Westminster', ContosoCoffeeDemoDataSetup."Country/Region Code", 'W2 8HG', 'London', 'todo:picturename', '<90D>'); AddDefaultCompanyPicture(); @@ -52,4 +56,20 @@ codeunit 5228 "Create Company Information" exit('777777777'); end; + internal procedure CreateSetupCompany() + var + O365BrandColor, DefaultColor : Record "O365 Brand Color"; + CompanyInformation: Record "Company Information"; + begin + O365BrandColor.DeleteAll(); + O365BrandColor.CreateDefaultBrandColors(); + // when color value is empty, we get the default color (blue) + O365BrandColor.FindColor(DefaultColor, ''); + + if not CompanyInformation.Get() then + CompanyInformation.Insert(); + + CompanyInformation.Validate("Brand Color Code", DefaultColor.Code); + CompanyInformation.Modify(true); + end; } diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Foundation/1.Setup data/CreateWebServices.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Foundation/1.Setup data/CreateWebServices.Codeunit.al index 5bf89d3070..5957b7f50c 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Foundation/1.Setup data/CreateWebServices.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Foundation/1.Setup data/CreateWebServices.Codeunit.al @@ -1,5 +1,8 @@ codeunit 5690 "Create Web Services" { + InherentEntitlements = X; + InherentPermissions = X; + trigger OnRun() var WebService: Record "Web Service"; diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Foundation/FoundationModule.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Foundation/FoundationModule.Codeunit.al index 4dfd6f6cc0..d4025dc570 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Foundation/FoundationModule.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Foundation/FoundationModule.Codeunit.al @@ -13,13 +13,15 @@ codeunit 5203 "Foundation Module" implements "Contoso Demo Data Module" end; procedure CreateSetupData() + var + CreateCompanyInformation: Codeunit "Create Company Information"; begin + CreateCompanyInformation.CreateSetupCompany(); Codeunit.Run(Codeunit::"Create Shipping Data"); Codeunit.Run(Codeunit::"Create Language"); Codeunit.Run(Codeunit::"Create Unit of Measure"); Codeunit.Run(Codeunit::"Create Country/Region"); Codeunit.Run(Codeunit::"Create Doc Sending Profile"); - Codeunit.Run(Codeunit::"Create Company Information"); Codeunit.Run(Codeunit::"Create Payment Terms"); Codeunit.Run(Codeunit::"Create Job Queue Category"); Codeunit.Run(Codeunit::"Create Accounting Period"); @@ -36,7 +38,7 @@ codeunit 5203 "Foundation Module" implements "Contoso Demo Data Module" procedure CreateMasterData() begin - exit; + Codeunit.Run(Codeunit::"Create Company Information"); end; procedure CreateTransactionalData() diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Manufacturing/ManufacturingModule.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Manufacturing/ManufacturingModule.Codeunit.al index e8509e0a5f..599445c03e 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Manufacturing/ManufacturingModule.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Manufacturing/ManufacturingModule.Codeunit.al @@ -26,13 +26,13 @@ codeunit 4783 "Manufacturing Module" implements "Contoso Demo Data Module" Codeunit.Run(Codeunit::"Create Mfg Location"); Codeunit.Run(Codeunit::"Create Mfg Posting Group"); Codeunit.Run(Codeunit::"Create Mfg Posting Setup"); - Codeunit.Run(Codeunit::"Create Mfg Availability Setup"); Codeunit.Run(Codeunit::"Create Mfg Order Promising"); Codeunit.Run(Codeunit::"Create Mfg Stop Scrap"); end; procedure CreateMasterData() begin + Codeunit.Run(Codeunit::"Create Mfg Availability Setup"); Codeunit.Run(Codeunit::"Create Mfg Vendor"); Codeunit.Run(Codeunit::"Create Mfg Item"); Codeunit.Run(Codeunit::"Create Mfg Capacity"); diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/AccessibleCompaniesContoso.PageExt.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/AccessibleCompaniesContoso.PageExt.al new file mode 100644 index 0000000000..dfc0875795 --- /dev/null +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/AccessibleCompaniesContoso.PageExt.al @@ -0,0 +1,31 @@ +pageextension 5279 "Accessible Companies Contoso" extends "Accessible Companies" +{ + layout + { + addafter(SetupStatus) + { + field(CompanyDemoData; CompanyDemoData.Get(Rec.Name)) + { + ApplicationArea = All; + Caption = 'Company Demo Data'; + ToolTip = 'Specifies the demo data used during the company''s creation.'; + Visible = false; + } + } + } + + + trigger OnAfterGetRecord() + var + AssistedCompanySetupStatus: Record "Assisted Company Setup Status"; + + begin + if AssistedCompanySetupStatus.Get(Rec.Name) then + CompanyDemoData.Set(Rec.Name, AssistedCompanySetupStatus."Company Demo Data") + else + CompanyDemoData.Set(Rec.Name, ''); + end; + + var + CompanyDemoData: Dictionary of [Text, Text]; +} \ No newline at end of file diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/CompanyCreationContoso.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/CompanyCreationContoso.Codeunit.al index b5269cf154..938b4ce1c5 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/CompanyCreationContoso.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/CompanyCreationContoso.Codeunit.al @@ -10,11 +10,12 @@ codeunit 5382 "Company Creation Contoso" GLSetup: Record "General Ledger Setup"; ContosoDemoTool: Codeunit "Contoso Demo Tool"; begin - AssistedCompanySetupStatus.Get(CompanyName); - AssistedCompanySetupStatus."Server Instance ID" := ServiceInstanceId(); - AssistedCompanySetupStatus."Company Setup Session ID" := SessionId(); - AssistedCompanySetupStatus.Modify(); - Commit(); + if AssistedCompanySetupStatus.Get(CompanyName) then begin + AssistedCompanySetupStatus."Server Instance ID" := ServiceInstanceId(); + AssistedCompanySetupStatus."Company Setup Session ID" := SessionId(); + AssistedCompanySetupStatus.Modify(); + Commit(); + end; // Init Company if not GLSetup.Get() then @@ -56,10 +57,10 @@ codeunit 5382 "Company Creation Contoso" ContosoDemoDataModuleTemp."Is Setup Company" := IsSetup; until ContosoDemoDataModuleTemp.Next() = 0; - ScheduleRunningContosoDemoData(ContosoDemoDataModuleTemp, NewCompanyName); + ScheduleRunningContosoDemoData(ContosoDemoDataModuleTemp, NewCompanyName, IsSetup); end; - local procedure ScheduleRunningContosoDemoData(var ContosoDemoDataModuleTemp: Record "Contoso Demo Data Module" temporary; NewCompanyName: Text[30]) + local procedure ScheduleRunningContosoDemoData(var ContosoDemoDataModuleTemp: Record "Contoso Demo Data Module" temporary; NewCompanyName: Text[30]; IsSetup: Boolean) var AssistedCompanySetupStatus: Record "Assisted Company Setup Status"; ImportSessionID: Integer; @@ -76,7 +77,12 @@ codeunit 5382 "Company Creation Contoso" AssistedCompanySetupStatus."Company Setup Session ID" := ImportSessionID; if AssistedCompanySetupStatus."Company Setup Session ID" = 0 then Clear(AssistedCompanySetupStatus."Task ID"); + if IsSetup then + AssistedCompanySetupStatus."Company Demo Data" := Format(Enum::"Company Demo Data Type"::"Production - Setup Data Only") + else + AssistedCompanySetupStatus."Company Demo Data" := Format(Enum::"Company Demo Data Type"::"Evaluation - Contoso Sample Data"); AssistedCompanySetupStatus.Modify(); + Commit(); end; diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoAccountSchedule.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoAccountSchedule.Codeunit.al index 90680dc2e2..a775a7b5c4 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoAccountSchedule.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoAccountSchedule.Codeunit.al @@ -64,13 +64,13 @@ codeunit 5239 "Contoso Account Schedule" AccScheduleLine.Validate("Line No.", LineNo); AccScheduleLine.Validate("Row No.", RowNo); AccScheduleLine.Validate(Description, Description); - AccScheduleLine.Validate("Totaling Type", TotalingType); + AccScheduleLine."Totaling Type" := TotalingType; // For Localization, condition added as GL Account filters are blank if (Totaling = '..') then - AccScheduleLine.Validate(Totaling) + AccScheduleLine.Totaling := '' else - AccScheduleLine.Validate(Totaling, Totaling); + AccScheduleLine.Totaling := Totaling; AccScheduleLine.Validate(Show, Show); AccScheduleLine.Validate("Dimension 1 Totaling", Dimension1Totaling); diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoBank.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoBank.Codeunit.al index 322976720f..1a7ddf4e96 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoBank.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoBank.Codeunit.al @@ -37,7 +37,7 @@ codeunit 5697 "Contoso Bank" BankAccount.Validate(Contact, Contact); BankAccount."Bank Account No." := BankAccountNo; BankAccount.Validate("Min. Balance", MinBalance); - BankAccount.Validate("Bank Acc. Posting Group", BankAccPostingGroup); + BankAccount."Bank Acc. Posting Group" := BankAccPostingGroup; BankAccount.Validate("Our Contact Code", OurContactCode); BankAccount."Country/Region Code" := CountryRegionCode; BankAccount.Validate("Last Statement No.", LastStatementNo); diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoCompany.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoCompany.Codeunit.al index 84b49abf22..232db62f7c 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoCompany.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoCompany.Codeunit.al @@ -52,7 +52,7 @@ codeunit 5408 "Contoso Company" CompanyInformation.Validate("Bank Account No.", BankAccountNo); CompanyInformation.Validate(IBAN, IBAN); CompanyInformation.Validate("Payment Routing No.", PaymentRoutingNo); - CompanyInformation.Validate("VAT Registration No.", VATRegistrationNo); + CompanyInformation."VAT Registration No." := VATRegistrationNo; CompanyInformation.Validate("Ship-to Name", ShipToName); CompanyInformation.Validate("Ship-to Address", ShipToAddress); CompanyInformation.Validate("Ship-to Address 2", ShipToAddress2); diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoGLAccount.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoGLAccount.Codeunit.al index a424f8d74c..ba7895983f 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoGLAccount.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoGLAccount.Codeunit.al @@ -81,15 +81,7 @@ codeunit 5133 "Contoso GL Account" GLAccount.Validate("Income/Balance", GLAccount."Income/Balance"::"Balance Sheet"); end; - if AccountCategory <> Enum::"G/L Account Category"::" " then begin - GLAccount.Validate("Account Category", AccountCategory); - - if AccountSubCategory = '' then - GLAccount.Validate("Account Subcategory Entry No.", 0) - else - GLAccount.ValidateAccountSubCategory(AccountSubCategory); - end else - GLAccount.Validate("Account Category", Enum::"G/L Account Category"::" "); + ValidateAccountCategory(GLAccount, AccountCategory, AccountSubCategory); GLAccount.Validate("Account Type", AccountType); if GLAccount."Account Type" = GLAccount."Account Type"::Posting then @@ -120,4 +112,24 @@ codeunit 5133 "Contoso GL Account" else GLAccount.Insert(true); end; + + local procedure ValidateAccountCategory(var GLAccount: Record "G/L Account"; Category: Enum "G/L Account Category"; SubCategory: Text[80]) + begin + OnBeforeValidateGLAccountCategory(GLAccount, Category, SubCategory); + + if Category <> Enum::"G/L Account Category"::" " then begin + GLAccount.Validate("Account Category", Category); + + if SubCategory = '' then + GLAccount.Validate("Account Subcategory Entry No.", 0) + else + GLAccount.ValidateAccountSubCategory(SubCategory); + end else + GLAccount.Validate("Account Category", Enum::"G/L Account Category"::" "); + end; + + [IntegrationEvent(false, false)] + local procedure OnBeforeValidateGLAccountCategory(var GLAccount: Record "G/L Account"; var Category: Enum "G/L Account Category"; var SubCategory: Text[80]) + begin + end; } diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoPostingSetup.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoPostingSetup.Codeunit.al index c6b7da262e..cd5691ec1e 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoPostingSetup.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoPostingSetup.Codeunit.al @@ -88,7 +88,8 @@ codeunit 5136 "Contoso Posting Setup" VATPostingSetup.Validate("VAT Bus. Posting Group", VATBusinessGroupCode); VATPostingSetup.Validate("VAT Prod. Posting Group", VATProductGroupCode); - VATPostingSetup.Validate(Description, StrSubstNo(VATSetupDescTok, VATBusinessGroupCode, VATProductGroupCode)); + if (VATBusinessGroupCode <> '') or (VATProductGroupCode <> '') then + VATPostingSetup.Validate(Description, StrSubstNo(VATSetupDescTok, VATBusinessGroupCode, VATProductGroupCode)); // Need to check if we are changing the VAT Calculation Type before we validate it // The validation tries to find VAT Entry no matter we are changing the VAT Calculation Type or not diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/ContosoDemoTool.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/ContosoDemoTool.Codeunit.al index 951d23b327..30d465d3ac 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/ContosoDemoTool.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/ContosoDemoTool.Codeunit.al @@ -282,4 +282,17 @@ codeunit 5193 "Contoso Demo Tool" DataClassificationMgt.SetTableFieldsToNormal(Database::"Contoso Demo Data Module"); DataClassificationMgt.SetTableFieldsToNormal(Database::"Contoso Module Dependency"); end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Assisted Company Setup", 'OnSetupNewCompanyWithDemoData', '', false, false)] + local procedure OnSetupNewCompanyWithDemoData(NewCompanyName: Text[30]; NewCompanyData: Enum "Company Demo Data Type") + var + TempContosoDemoDataModule: Record "Contoso Demo Data Module" temporary; + ContosoDemoTool: Codeunit "Contoso Demo Tool"; + CompanyCreationContoso: Codeunit "Company Creation Contoso"; + begin + ContosoDemoTool.RefreshModules(TempContosoDemoDataModule); + TempContosoDemoDataModule.ModifyAll(Install, true); + + CompanyCreationContoso.CreateContosoDemodataInCompany(TempContosoDemoDataModule, NewCompanyName, NewCompanyData); + end; } \ No newline at end of file diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/ContosoDemoTool.Page.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/ContosoDemoTool.Page.al index a9fc0cc77e..960803b8f5 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/ContosoDemoTool.Page.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/ContosoDemoTool.Page.al @@ -11,6 +11,7 @@ page 5194 "Contoso Demo Tool" DeleteAllowed = false; Editable = false; RefreshOnActivate = true; + AnalysisModeEnabled = false; layout { diff --git a/Apps/W1/EDocument/app/src/Document/EDocument.Table.al b/Apps/W1/EDocument/app/src/Document/EDocument.Table.al index 03578a0618..4ec6ab4122 100644 --- a/Apps/W1/EDocument/app/src/Document/EDocument.Table.al +++ b/Apps/W1/EDocument/app/src/Document/EDocument.Table.al @@ -153,11 +153,6 @@ table 6121 "E-Document" { Caption = 'Receiving Company Address'; } - field(31; "Receiving Company Id"; Text[250]) - { - Caption = 'Receiving Company Id'; - ToolTip = 'Specifies the receiving company id, such as PEPPOL id, or other identifiers used in the electronic document exchange.'; - } field(26; "Currency Code"; Code[10]) { Caption = 'Currency Code'; @@ -182,6 +177,11 @@ table 6121 "E-Document" { DataClassification = SystemMetadata; } + field(31; "Receiving Company Id"; Text[250]) + { + Caption = 'Receiving Company Id'; + ToolTip = 'Specifies the receiving company id, such as PEPPOL id, or other identifiers used in the electronic document exchange.'; + } } keys diff --git a/Apps/W1/EDocument/app/src/Document/EDocumentServiceStatus.Enum.al b/Apps/W1/EDocument/app/src/Document/EDocumentServiceStatus.Enum.al index ad49ffec3c..a48e18a1e2 100644 --- a/Apps/W1/EDocument/app/src/Document/EDocumentServiceStatus.Enum.al +++ b/Apps/W1/EDocument/app/src/Document/EDocumentServiceStatus.Enum.al @@ -28,4 +28,5 @@ enum 6106 "E-Document Service Status" value(17; "Order Linked") { Caption = 'Order linked'; } value(18; "Pending") { Caption = 'Pending Document Link'; } value(19; "Approval Error") { Caption = 'Approval error'; } + value(20; "Ready For Processing") { Caption = 'Ready for processing'; } } diff --git a/Apps/W1/EDocument/app/src/Format/EDocImportPEPPOLBIS30.Codeunit.al b/Apps/W1/EDocument/app/src/Format/EDocImportPEPPOLBIS30.Codeunit.al index 58c4fc77b0..15b1147ddb 100644 --- a/Apps/W1/EDocument/app/src/Format/EDocImportPEPPOLBIS30.Codeunit.al +++ b/Apps/W1/EDocument/app/src/Format/EDocImportPEPPOLBIS30.Codeunit.al @@ -399,7 +399,8 @@ codeunit 6166 "EDoc Import PEPPOL BIS 3.0" Evaluate(PurchaseLine."Quantity (Base)", Value, 9); '/CreditNote/cac:CreditNoteLine/cbc:Note': setlineType(PurchaseLine, Value); - end + end; + OnAfterParseCreditMemo(EDocument, PurchaseHeader, PurchaseLine, DocumentAttachment, DocumentAttachmentData, TempXMLBuffer, Path, Value); end; /// @@ -512,6 +513,7 @@ codeunit 6166 "EDoc Import PEPPOL BIS 3.0" '/Invoice/cac:InvoiceLine/cbc:Note': setlineType(PurchaseLine, Value); end; + OnAfterParseInvoice(EDocument, PurchaseHeader, PurchaseLine, DocumentAttachment, DocumentAttachmentData, TempXMLBuffer, Path, Value); end; procedure DetermineFileType(MimeType: Text) FileExension: Text @@ -590,4 +592,14 @@ codeunit 6166 "EDoc Import PEPPOL BIS 3.0" EDocumentAttachmentGen: Codeunit "E-Doc. Attachment Processor"; EDocumentImportHelper: Codeunit "E-Document Import Helper"; LCYCode: Code[10]; + + [IntegrationEvent(false, false)] + internal procedure OnAfterParseInvoice(EDocument: Record "E-Document"; var PurchaseHeader: Record "Purchase Header" temporary; var PurchaseLine: Record "Purchase Line" temporary; DocumentAttachment: Record "Document Attachment"; DocumentAttachmentData: Codeunit "Temp Blob"; TempXMLBuffer: Record "XML Buffer" temporary; Path: Text; Value: Text) + begin + end; + + [IntegrationEvent(false, false)] + internal procedure OnAfterParseCreditMemo(EDocument: Record "E-Document"; var PurchaseHeader: Record "Purchase Header" temporary; var PurchaseLine: Record "Purchase Line" temporary; DocumentAttachment: Record "Document Attachment"; DocumentAttachmentData: Codeunit "Temp Blob"; TempXMLBuffer: Record "XML Buffer" temporary; Path: Text; Value: Text) + begin + end; } \ No newline at end of file diff --git a/Apps/W1/EDocument/app/src/Helpers/EDocumentHelper.Codeunit.al b/Apps/W1/EDocument/app/src/Helpers/EDocumentHelper.Codeunit.al index b382780d93..de8767b30b 100644 --- a/Apps/W1/EDocument/app/src/Helpers/EDocumentHelper.Codeunit.al +++ b/Apps/W1/EDocument/app/src/Helpers/EDocumentHelper.Codeunit.al @@ -24,6 +24,17 @@ codeunit 6148 "E-Document Helper" exit(DocumentSendingProfile."Electronic Document" = DocumentSendingProfile."Electronic Document"::"Extended E-Document Service Flow"); end; + /// + /// Returns the EDocuments services used in a workflow. + /// E-Document service record has code filter set. + /// + procedure GetServicesInWorkflow(Workflow: Record Workflow; var EDocumentService: Record "E-Document Service"): Boolean + var + EDocumentWorkFlowProcessing: Codeunit "E-Document Workflow Processing"; + begin + exit(EDocumentWorkFlowProcessing.DoesFlowHasEDocService(EDocumentService, Workflow.Code)); + end; + /// /// Use it to set allow EDocument CoreHttpCalls. /// diff --git a/Apps/W1/EDocument/app/src/Helpers/EDocumentImportHelper.Codeunit.al b/Apps/W1/EDocument/app/src/Helpers/EDocumentImportHelper.Codeunit.al index 7b1e6d0cd3..58feafbcce 100644 --- a/Apps/W1/EDocument/app/src/Helpers/EDocumentImportHelper.Codeunit.al +++ b/Apps/W1/EDocument/app/src/Helpers/EDocumentImportHelper.Codeunit.al @@ -248,8 +248,7 @@ codeunit 6109 "E-Document Import Helper" LineAmount := LineAmountFieldRef.Value(); LineDiscountAmount := (LineQuantity * LineDirectUnitCost) - LineAmount; - - LineDiscountAmountFieldRef.Value(Format(LineDiscountAmount, 0, 9)); + LineDiscountAmountFieldRef.Value(LineDiscountAmount); end; /// diff --git a/Apps/W1/EDocument/app/src/Processing/EDocExport.Codeunit.al b/Apps/W1/EDocument/app/src/Processing/EDocExport.Codeunit.al index 4060413d6b..168cf544c7 100644 --- a/Apps/W1/EDocument/app/src/Processing/EDocExport.Codeunit.al +++ b/Apps/W1/EDocument/app/src/Processing/EDocExport.Codeunit.al @@ -320,21 +320,22 @@ codeunit 6102 "E-Doc. Export" EDocument.Insert(); end; - local procedure CreateEDocument(EDocService: Record "E-Document Service"; var EDocument: Record "E-Document"; var SourceDocumentHeader: RecordRef; var SourceDocumentLines: RecordRef; var TempBlob: Codeunit "Temp Blob") + local procedure CreateEDocument(EDocumentService: Record "E-Document Service"; var EDocument: Record "E-Document"; var SourceDocumentHeader: RecordRef; var SourceDocumentLines: RecordRef; var TempBlob: Codeunit "Temp Blob") var EDocumentCreate: Codeunit "E-Document Create"; TelemetryDimensions: Dictionary of [Text, Text]; begin // Commit before create document with error handling Commit(); - EDocumentProcessing.GetTelemetryDimensions(EDocService, EDocument, TelemetryDimensions); + EDocumentProcessing.GetTelemetryDimensions(EDocumentService, EDocument, TelemetryDimensions); Telemetry.LogMessage('0000LBF', EDocTelemetryCreateScopeStartLbl, Verbosity::Normal, DataClassification::OrganizationIdentifiableInformation, TelemetryScope::All, TelemetryDimensions); - EDocumentCreate.SetSource(EDocService, EDocument, SourceDocumentHeader, SourceDocumentLines, TempBlob); + EDocumentCreate.SetSource(EDocumentService, EDocument, SourceDocumentHeader, SourceDocumentLines, TempBlob); if not EDocumentCreate.Run() then EDocumentErrorHelper.LogSimpleErrorMessage(EDocument, GetLastErrorText()); - EDocumentCreate.GetSource(EDocument); + // After interface call, reread the EDocument for the latest values. + EDocument.Get(EDocument."Entry No"); Telemetry.LogMessage('0000LBG', EDocTelemetryCreateScopeEndLbl, Verbosity::Normal, DataClassification::OrganizationIdentifiableInformation, TelemetryScope::All); end; diff --git a/Apps/W1/EDocument/app/src/Processing/EDocumentBackgroundJobs.Codeunit.al b/Apps/W1/EDocument/app/src/Processing/EDocumentBackgroundJobs.Codeunit.al index 8e8d996ded..d688b52eec 100644 --- a/Apps/W1/EDocument/app/src/Processing/EDocumentBackgroundJobs.Codeunit.al +++ b/Apps/W1/EDocument/app/src/Processing/EDocumentBackgroundJobs.Codeunit.al @@ -37,7 +37,7 @@ codeunit 6133 "E-Document Background Jobs" ScheduleEDocumentJob(Codeunit::"E-Document Get Response", BlankRecord, 300000); end; - procedure ScheduleRecurrentBatchJob(EDocumentService: Record "E-Document Service") + procedure ScheduleRecurrentBatchJob(var EDocumentService: Record "E-Document Service") var JobQueueEntry: Record "Job Queue Entry"; Telemetry: Codeunit Telemetry; @@ -69,7 +69,7 @@ codeunit 6133 "E-Document Background Jobs" Telemetry.LogMessage('0000LC4', EDocumentJobTelemetryLbl, Verbosity::Normal, DataClassification::OrganizationIdentifiableInformation, TelemetryScope::All, TelemetryDimensions); end; - procedure ScheduleRecurrentImportJob(EDocumentService: Record "E-Document Service") + procedure ScheduleRecurrentImportJob(var EDocumentService: Record "E-Document Service") var JobQueueEntry: Record "Job Queue Entry"; Telemetry: Codeunit Telemetry; @@ -104,18 +104,17 @@ codeunit 6133 "E-Document Background Jobs" Telemetry.LogMessage('0000LC5', EDocumentJobTelemetryLbl, Verbosity::Normal, DataClassification::OrganizationIdentifiableInformation, TelemetryScope::All, TelemetryDimensions); end; - procedure HandleRecurrentBatchJob(EDocumentService: Record "E-Document Service") + procedure HandleRecurrentBatchJob(var EDocumentService: Record "E-Document Service") begin - if EDocumentService."Use Batch Processing" then - if EDocumentService."Batch Mode" = EDocumentService."Batch Mode"::Recurrent then begin - EDocumentService.TestField("Batch Start Time"); - EDocumentService.TestField("Batch Minutes between runs"); - ScheduleRecurrentBatchJob(EDocumentService); - end else - RemoveJob(EDocumentService."Batch Recurrent Job Id"); + if (EDocumentService."Use Batch Processing") and (EDocumentService."Batch Mode" = EDocumentService."Batch Mode"::Recurrent) then begin + EDocumentService.TestField("Batch Start Time"); + EDocumentService.TestField("Batch Minutes between runs"); + ScheduleRecurrentBatchJob(EDocumentService); + end else + RemoveJob(EDocumentService."Batch Recurrent Job Id"); end; - procedure HandleRecurrentImportJob(EDocumentService: Record "E-Document Service") + procedure HandleRecurrentImportJob(var EDocumentService: Record "E-Document Service") begin if EDocumentService."Auto Import" then begin EDocumentService.TestField("Import Start Time"); diff --git a/Apps/W1/EDocument/app/src/Service/EDocumentService.Table.al b/Apps/W1/EDocument/app/src/Service/EDocumentService.Table.al index c78e73e8c6..7f152dd481 100644 --- a/Apps/W1/EDocument/app/src/Service/EDocumentService.Table.al +++ b/Apps/W1/EDocument/app/src/Service/EDocumentService.Table.al @@ -60,6 +60,10 @@ table 6103 "E-Document Service" { Caption = 'Use Batch Processing'; DataClassification = SystemMetadata; + trigger OnValidate() + begin + EDocumentBackgroundJobs.HandleRecurrentBatchJob(Rec); + end; } field(6; "Update Order"; Boolean) { @@ -173,6 +177,11 @@ table 6103 "E-Document Service" Caption = 'Auto Import'; DataClassification = SystemMetadata; InitValue = false; + + trigger OnValidate() + begin + EDocumentBackgroundJobs.HandleRecurrentImportJob(Rec); + end; } field(19; "Import Start Time"; Time) { @@ -255,7 +264,11 @@ table 6103 "E-Document Service" var EDocServiceSupportedType: Record "E-Doc. Service Supported Type"; EDocBackgroundJobs: Codeunit "E-Document Background Jobs"; + EDocumentWorkflowProcesssing: Codeunit "E-Document WorkFlow Processing"; begin + if EDocumentWorkflowProcesssing.IsServiceUsedInActiveWorkflow(Rec) then + Error(ServiceInActiveFlowErr); + EDocServiceSupportedType.SetRange("E-Document Service Code", Rec.Code); EDocServiceSupportedType.DeleteAll(); @@ -273,7 +286,9 @@ table 6103 "E-Document Service" end; var + EDocumentBackgroundJobs: Codeunit "E-Document Background Jobs"; EDocStringLbl: Label '%1,%2,%3,%4,%5', Locked = true; TemplateTypeErr: Label 'Only General Journal Templates of type %1, %2, %3, %4, or %5 are allowed.', Comment = '%1 - General, %2 - Purchases, %3 - Payments, %4 - Sales, %5 - Cash, %6 - Receipts'; ChooseIntegrationConsentTxt: Label 'By choosing this option, you consent to use third party systems. These systems may have their own terms of use, license, pricing and privacy, and they may not meet the same compliance and security standards as Microsoft Dynamics 365 Business Central. Your privacy is important to us.'; + ServiceInActiveFlowErr: Label 'The service is used in an active workflow. You cannot delete it.'; } diff --git a/Apps/W1/EDocument/app/src/Service/EdocumentService.Page.al b/Apps/W1/EDocument/app/src/Service/EdocumentService.Page.al index 452050a46e..76d903cfa8 100644 --- a/Apps/W1/EDocument/app/src/Service/EdocumentService.Page.al +++ b/Apps/W1/EDocument/app/src/Service/EdocumentService.Page.al @@ -253,14 +253,6 @@ page 6133 "E-Document Service" CurrPage.EDocumentImportFormatMapping.Page.SaveAsImport(true); end; - trigger OnClosePage() - var - EDocumentBackgroundJobs: Codeunit "E-Document Background Jobs"; - begin - EDocumentBackgroundJobs.HandleRecurrentBatchJob(Rec); - EDocumentBackgroundJobs.HandleRecurrentImportJob(Rec); - end; - #if not CLEAN26 local procedure RunSetupServiceIntegration() var diff --git a/Apps/W1/EDocument/app/src/Workflow/EDocumentWorkFlowProcessing.Codeunit.al b/Apps/W1/EDocument/app/src/Workflow/EDocumentWorkFlowProcessing.Codeunit.al index b64fe69eba..4e13d2eb88 100644 --- a/Apps/W1/EDocument/app/src/Workflow/EDocumentWorkFlowProcessing.Codeunit.al +++ b/Apps/W1/EDocument/app/src/Workflow/EDocumentWorkFlowProcessing.Codeunit.al @@ -15,6 +15,26 @@ codeunit 6135 "E-Document WorkFlow Processing" tabledata "E-Document" = m, tabledata "E-Doc. Mapping Log" = i; + + internal procedure IsServiceUsedInActiveWorkflow(EDocumentService: Record "E-Document Service"): Boolean + var + Workflow: Record Workflow; + WorkflowStep: Record "Workflow Step"; + WorkflowStepArgument: Record "Workflow Step Argument"; + begin + Workflow.SetRange(Enabled, true); + if Workflow.FindSet() then + repeat + WorkflowStep.SetRange("Workflow Code", Workflow.Code); + if WorkflowStep.FindSet() then + repeat + if WorkflowStepArgument.Get(WorkflowStep.Argument) then + if WorkflowStepArgument."E-Document Service" = EDocumentService.Code then + exit(true); + until WorkflowStep.Next() = 0; + until Workflow.Next() = 0; + end; + internal procedure DoesFlowHasEDocService(var EDocServices: Record "E-Document Service"; WorkfLowCode: Code[20]): Boolean var WorkflowStepArgument: Record "Workflow Step Argument"; diff --git a/Apps/W1/EDocument/demo data/3.Transactions/CreateEDocumentTransactions.Codeunit.al b/Apps/W1/EDocument/demo data/3.Transactions/CreateEDocumentTransactions.Codeunit.al index ff1ecf39e1..ca54faf2f6 100644 --- a/Apps/W1/EDocument/demo data/3.Transactions/CreateEDocumentTransactions.Codeunit.al +++ b/Apps/W1/EDocument/demo data/3.Transactions/CreateEDocumentTransactions.Codeunit.al @@ -22,12 +22,13 @@ codeunit 5376 "Create E-Document Transactions" PurchaseHeader: Record "Purchase Header"; EDocumentModuleSetup: Record "E-Document Module Setup"; ContosoPurchase: Codeunit "Contoso Purchase"; + CreateWhseItem: Codeunit "Create Whse Item"; CommonUoM: Codeunit "Create Common Unit Of Measure"; begin EDocumentModuleSetup.Get(); PurchaseHeader := CreateOrder(EDocumentModuleSetup."Vendor No. 1"); - ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, 'WRB-1000', 50, CommonUoM.Piece(), 100); - ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, 'WRB-1001', 50, CommonUoM.Piece(), 100); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateWhseItem.Item1(), 50, CommonUoM.Piece(), 100); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateWhseItem.Item2(), 50, CommonUoM.Piece(), 100); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, 'WRB-1003', 50, CommonUoM.Piece(), 120); PostPurchaseOrder(PurchaseHeader, PurchaseOrdersList); @@ -48,7 +49,7 @@ codeunit 5376 "Create E-Document Transactions" PostPurchaseOrder(PurchaseHeader, PurchaseOrdersList); PurchaseHeader := CreateOrder(EDocumentModuleSetup."Vendor No. 2"); - ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, 'WRB-1001', 150, CommonUoM.Piece(), 125, 20); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateWhseItem.Item2(), 150, CommonUoM.Piece(), 125, 20); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, 'WDB-1003', 25, CommonUoM.Piece(), 170, 10); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, 'WDB-1004', 50, CommonUoM.Piece(), 120); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, 'WDB-1005', 50, CommonUoM.Piece(), 140); diff --git a/Apps/W1/EDocument/test/src/Log/EDocLogTest.Codeunit.al b/Apps/W1/EDocument/test/src/Log/EDocLogTest.Codeunit.al index b0d49914be..5f44ae3476 100644 --- a/Apps/W1/EDocument/test/src/Log/EDocLogTest.Codeunit.al +++ b/Apps/W1/EDocument/test/src/Log/EDocLogTest.Codeunit.al @@ -303,9 +303,9 @@ codeunit 139616 "E-Doc Log Test" // [GIVEN] Exporting E-Documents for service with mapping Initialize(Enum::"Service Integration"::"Mock Sync"); LibraryEDoc.CreateServiceMapping(EDocumentService); - EDocumentService."Use Batch Processing" := true; EDocumentService."Batch Mode" := enum::"E-Document Batch Mode"::Threshold; EDocumentService."Batch Threshold" := 2; + EDocumentService.Validate("Use Batch Processing", true); EDocumentService.Modify(); BindSubscription(EDocLogTest); EDocLog.SetAutoCalcFields("E-Doc. Data Storage Size"); @@ -409,9 +409,9 @@ codeunit 139616 "E-Doc Log Test" // [GIVEN] A flow to send to service with threshold batch Initialize(Enum::"Service Integration"::"Mock Sync"); LibraryEDoc.CreateServiceMapping(EDocumentService); - EDocumentService."Use Batch Processing" := true; EDocumentService."Batch Mode" := enum::"E-Document Batch Mode"::Threshold; EDocumentService."Batch Threshold" := 2; + EDocumentService.Validate("Use Batch Processing", true); EDocumentService.Modify(); BindSubscription(EDocLogTest); // Bind subscription to get events to insert into blobs EDocLogTest.SetLastEntryInBatchToError(); // Make sure last entry in create batch fails @@ -513,10 +513,10 @@ codeunit 139616 "E-Doc Log Test" // [GIVEN] A flow to send to service with recurrent batch Initialize(Enum::"Service Integration"::"Mock Sync"); LibraryEDoc.CreateServiceMapping(EDocumentService); - EDocumentService."Use Batch Processing" := true; EDocumentService."Batch Mode" := EDocumentService."Batch Mode"::Recurrent; EDocumentService."Batch Minutes between runs" := 1; EDocumentService."Batch Start Time" := Time(); + EDocumentService.Validate("Use Batch Processing", true); EDocumentService.Modify(); BindSubscription(EDocLogTest); // Bind subscription to get events to insert into blobs @@ -640,10 +640,10 @@ codeunit 139616 "E-Doc Log Test" Initialize(Enum::"Service Integration"::"Mock Sync"); LibraryEDoc.CreateServiceMapping(EDocumentService); EDocumentService.Get(EDocumentService.Code); - EDocumentService."Use Batch Processing" := true; EDocumentService."Batch Mode" := EDocumentService."Batch Mode"::Recurrent; EDocumentService."Batch Minutes between runs" := 1; EDocumentService."Batch Start Time" := Time(); + EDocumentService.Validate("Use Batch Processing", true); EDocumentService.Modify(); BindSubscription(EDocLogTest); // Bind subscription to get events to insert into blobs diff --git a/Apps/W1/EDocument/test/src/Processing/EDocE2ETest.Codeunit.al b/Apps/W1/EDocument/test/src/Processing/EDocE2ETest.Codeunit.al index 5b3e0f7d9e..5a156bd006 100644 --- a/Apps/W1/EDocument/test/src/Processing/EDocE2ETest.Codeunit.al +++ b/Apps/W1/EDocument/test/src/Processing/EDocE2ETest.Codeunit.al @@ -397,9 +397,9 @@ codeunit 139624 "E-Doc E2E Test" EDocImplState.SetThrowLoggedError(); BindSubscription(EDocImplState); - EDocumentService."Use Batch Processing" := true; EDocumentService."Batch Mode" := EDocumentService."Batch Mode"::Threshold; EDocumentService."Batch Threshold" := 1; + EDocumentService.Validate("Use Batch Processing", true); EDocumentService.Modify(); if EDocument.FindLast() then @@ -447,9 +447,9 @@ codeunit 139624 "E-Doc E2E Test" EDocImplState.SetThrowRuntimeError(); BindSubscription(EDocImplState); - EDocumentService."Use Batch Processing" := true; EDocumentService."Batch Mode" := EDocumentService."Batch Mode"::Threshold; EDocumentService."Batch Threshold" := 1; + EDocumentService.Validate("Use Batch Processing", true); EDocumentService.Modify(); if EDocument.FindLast() then @@ -498,9 +498,9 @@ codeunit 139624 "E-Doc E2E Test" Initialize(Enum::"Service Integration"::"Mock Sync"); BindSubscription(EDocImplState); - EDocumentService."Use Batch Processing" := true; EDocumentService."Batch Mode" := EDocumentService."Batch Mode"::Threshold; EDocumentService."Batch Threshold" := 2; + EDocumentService.Validate("Use Batch Processing", true); EDocumentService.Modify(); // [WHEN] Team member post invoice @@ -586,8 +586,8 @@ codeunit 139624 "E-Doc E2E Test" Initialize(Enum::"Service Integration"::"Mock Sync"); BindSubscription(EDocImplState); - EDocumentService."Use Batch Processing" := true; EDocumentService."Batch Mode" := EDocumentService."Batch Mode"::Recurrent; + EDocumentService.Validate("Use Batch Processing", true); EDocumentService.Modify(); EDocumentServicePage.OpenView(); @@ -638,8 +638,8 @@ codeunit 139624 "E-Doc E2E Test" EDocumentService.SetRecFilter(); EDocumentService.FindFirst(); - EDocumentService."Use Batch Processing" := true; EDocumentService."Batch Mode" := EDocumentService."Batch Mode"::Recurrent; + EDocumentService.Validate("Use Batch Processing", true); EDocumentService.Modify(); EDocumentServicePage.OpenView(); @@ -673,7 +673,7 @@ codeunit 139624 "E-Doc E2E Test" LibraryLowerPermission.SetOutsideO365Scope(); EDocumentService.FindFirst(); - EDocumentService."Use Batch Processing" := false; + EDocumentService.Validate("Use Batch Processing", false); EDocumentService.Modify(); Clear(EDocumentService); diff --git a/Apps/W1/EDocument/test/src/Receive/EDocHelperTest.Codeunit.al b/Apps/W1/EDocument/test/src/Receive/EDocHelperTest.Codeunit.al new file mode 100644 index 0000000000..af04f19155 --- /dev/null +++ b/Apps/W1/EDocument/test/src/Receive/EDocHelperTest.Codeunit.al @@ -0,0 +1,33 @@ +codeunit 139799 "E-Doc. Helper Test" +{ + Subtype = Test; + Access = Internal; + + var + Assert: Codeunit "Assert"; + + trigger OnRun() + begin + // [FEATURE] [E-Document] + end; + + [Test] + procedure ValidateLineDiscountTest() + var + EDocument: Record "E-Document"; + TempPurchaseLine: Record "Purchase Line" temporary; + EDocumentImportHelper: Codeunit "E-Document Import Helper"; + RecordRef: RecordRef; + begin + TempPurchaseLine."Direct Unit Cost" := 0.99; + TempPurchaseLine.Amount := 0.88 * 5; + TempPurchaseLine.Quantity := 5; + + RecordRef.GetTable(TempPurchaseLine); + EDocumentImportHelper.ValidateLineDiscount(EDocument, RecordRef); + RecordRef.SetTable(TempPurchaseLine); + Assert.AreEqual(TempPurchaseLine."Line Discount Amount", 0.55, 'Line Discount Amount does not equal'); + end; + + +} \ No newline at end of file diff --git a/Apps/W1/EDocumentConnectors/Avalara/test/src/IntegrationTests.Codeunit.al b/Apps/W1/EDocumentConnectors/Avalara/test/src/IntegrationTests.Codeunit.al index dbc98fe408..37608aebdf 100644 --- a/Apps/W1/EDocumentConnectors/Avalara/test/src/IntegrationTests.Codeunit.al +++ b/Apps/W1/EDocumentConnectors/Avalara/test/src/IntegrationTests.Codeunit.al @@ -550,7 +550,7 @@ codeunit 148191 "Integration Tests" EDocumentService."Avalara Mandate" := 'GB-Test-Mandate'; LibraryEDocument.SetupStandardPurchaseScenario(Vendor, EDocumentService, Enum::"E-Document Format"::"PEPPOL BIS 3.0", Enum::"Service Integration"::Avalara); - EDocumentService."Auto Import" := true; + EDocumentService.Validate("Auto Import", true); EDocumentService."Import Minutes between runs" := 10; EDocumentService."Import Start Time" := Time(); EDocumentService.Modify(); diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/app/ExtensionLogo.png b/Apps/W1/EDocumentConnectors/Microsoft365/app/ExtensionLogo.png new file mode 100644 index 0000000000..4d2c9a626c Binary files /dev/null and b/Apps/W1/EDocumentConnectors/Microsoft365/app/ExtensionLogo.png differ diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/app/app.json b/Apps/W1/EDocumentConnectors/Microsoft365/app/app.json new file mode 100644 index 0000000000..be0af2f61e --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/app/app.json @@ -0,0 +1,53 @@ +{ + "id": "ec6b3b0e-f983-408b-8476-bafb4368ecbc", + "name": "E-Document Connector - Microsoft 365", + "publisher": "Microsoft", + "brief": "This app extends Microsoft standard E-documents framework, offering connectors to Microsoft 365.", + "description": "This app extends Microsoft standard E-documents framework, offering connectors to Microsoft 365.", + "version": "26.0.0.0", + "privacyStatement": "https://go.microsoft.com/fwlink/?LinkId=724009", + "EULA": "https://go.microsoft.com/fwlink/?linkid=2009120", + "help": " https://learn.microsoft.com/en-us/dynamics365/business-central/finance-edocuments-overview", + "url": "https://go.microsoft.com/fwlink/?LinkId=724011", + "logo": "ExtensionLogo.png", + "contextSensitiveHelpUrl": "https://go.microsoft.com/fwlink/?linkid=2206603", + "dependencies": [ + { + "id": "e1d97edc-c239-46b4-8d84-6368bdf67c8b", + "name": "E-Document Core", + "publisher": "Microsoft", + "version": "26.0.0.0" + }, + { + "id": "d852a468-263e-49e5-bfda-f09e33342b89", + "name": "E-Documents Connector with External Endpoints", + "publisher": "Microsoft", + "version": "26.0.0.0" + } + ], + "internalsVisibleTo": [ + { + "id": "44efdf6d-efe4-4af7-9aaa-30df07c0d5a1", + "name": "E-Document Connector - Microsoft 365 Tests", + "publisher": "Microsoft" + } + ], + "screenshots": [], + "platform": "26.0.0.0", + "idRanges": [ + { + "from": 6381, + "to": 6385 + } + ], + "resourceExposurePolicy": { + "allowDebugging": true, + "allowDownloadingSource": true, + "includeSourceInSymbolFile": true + }, + "application": "26.0.0.0", + "target": "OnPrem", + "features": [ + "TranslationFile" + ] +} \ No newline at end of file diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/app/src/DriveProcessing.Codeunit.al b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/DriveProcessing.Codeunit.al new file mode 100644 index 0000000000..d2000392b5 --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/DriveProcessing.Codeunit.al @@ -0,0 +1,336 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.EServices.EDocumentConnector.Microsoft365; + +using Microsoft.EServices.EDocument; +using System.Text; +using Microsoft.eServices.EDocument.Integration; +using System.Utilities; +using System.Integration; +using Microsoft.eServices.EDocument.Integration.Receive; +using System.Telemetry; + +codeunit 6381 "Drive Processing" +{ + Access = Internal; + Permissions = tabledata "E-Document" = m, + tabledata "E-Document Service Status" = m, + tabledata "OneDrive Setup" = r, + tabledata "Sharepoint Setup" = r; + InherentPermissions = X; + InherentEntitlements = X; + + internal procedure MarkEDocumentAsDownloaded(EDocument: Record "E-Document"; EDocumentService: Record "E-Document Service") + var + GraphClient: Codeunit "Graph Client"; + FeatureTelemetry: Codeunit "Feature Telemetry"; + SiteId: Text; + NewFolderId: Text; + begin + FeatureTelemetry.LogUptake('0000OAY', FeatureName(), Enum::"Feature Uptake Status"::Used); + FeatureTelemetry.LogUsage('0000OB1', FeatureName(), Format(EDocumentService."Service Integration V2")); + if EDocument."Document Id" = '' then + Error(DocumentIdEmptyErr, EDocument."Entry No"); + + SiteId := GetSiteId(EDocumentService."Service Integration V2"); + NewFolderId := GetImportedDocumentsFolderId(EDocumentService."Service Integration V2"); + + GraphClient.MoveDriveItem(SiteId, EDocument."Document Id", NewFolderId); + end; + + procedure GetSiteId(FolderSharedLink: Text[2048]): Text + var + GraphClient: Codeunit "Graph Client"; + Base64Convert: Codeunit "Base64 Convert"; + MySiteLink, Base64SharedLink, ErrorMessageTxt : Text; + FilesJson: JsonObject; + SiteIdToken: JsonToken; + begin + Base64SharedLink := Base64Convert.ToBase64(FolderSharedLink); + Base64SharedLink := 'u!' + Base64SharedLink.TrimEnd('=').Replace('/', '_').Replace('+', '-'); + MySiteLink := GetGraphSharesURL() + Base64SharedLink + '/driveItem/parentReference'; + if not GraphClient.GetDriveFolderInfo(MySiteLink, FilesJson) then begin + ErrorMessageTxt := GetLastErrorText() + GetLastErrorCallStack(); + ClearLastError(); + Error(ErrorMessageTxt); + end; + + if FilesJson.Get('siteId', SiteIdToken) then + exit(SiteIdToken.AsValue().AsText()) + end; + + procedure GetId(FolderSharedLink: Text[2048]): Text + var + GraphClient: Codeunit "Graph Client"; + Base64Convert: Codeunit "Base64 Convert"; + MyFolderIdLink, Base64SharedLink, ErrorMessageTxt : Text; + FilesJson: JsonObject; + IdToken: JsonToken; + begin + Base64SharedLink := Base64Convert.ToBase64(FolderSharedLink); + Base64SharedLink := 'u!' + Base64SharedLink.TrimEnd('=').Replace('/', '_').Replace('+', '-'); + MyFolderIdLink := GetGraphSharesURL() + Base64SharedLink + '/driveItem?$select=id'; + if not GraphClient.GetDriveFolderInfo(MyFolderIdLink, FilesJson) then begin + ErrorMessageTxt := GetLastErrorText() + GetLastErrorCallStack(); + ClearLastError(); + Error(ErrorMessageTxt); + end; + + if FilesJson.Get('id', IdToken) then + exit(IdToken.AsValue().AsText()) + end; + + procedure ReceiveDocuments(var EDocumentService: Record "E-Document Service"; Documents: Codeunit "Temp Blob List"; ReceiveContext: Codeunit ReceiveContext) + var + GraphClient: Codeunit "Graph Client"; + FeatureTelemetry: Codeunit "Feature Telemetry"; + MyBCFilesLink, ErrorMessageTxt : Text; + FilesJson: JsonObject; + begin + FeatureTelemetry.LogUptake('0000OAZ', FeatureName(), Enum::"Feature Uptake Status"::Used); + FeatureTelemetry.LogUsage('0000OB2', FeatureName(), Format(EDocumentService."Service Integration V2")); + MyBCFilesLink := GetGraphSharesURL() + GetDocumentsSharedLink(EDocumentService."Service Integration V2") + '/driveItem/children?$top=100&$select=id,name,file,malware'; + if not GraphClient.GetDriveFolderInfo(MyBCFilesLink, FilesJson) then begin + ErrorMessageTxt := GetLastErrorText() + GetLastErrorCallStack(); + ClearLastError(); + Error(ErrorMessageTxt); + end; + + AddToDocumentsList(Documents, FilesJson); + end; + + internal procedure FeatureName(): Text + begin + exit('Microsoft 365 E-Document Connector') + end; + + internal procedure AddToReceiveContext(ReceiveContext: Codeunit ReceiveContext; var FilesJson: JSonObject) + var + TempBlob: Codeunit "Temp Blob"; + OutStream: OutStream; + begin + Clear(TempBlob); + TempBlob.CreateOutStream(OutStream, TextEncoding::UTF8); + FilesJson.WriteTo(OutStream); + ReceiveContext.SetTempBlob(TempBlob); + end; + + internal procedure AddToDocumentsList(Documents: Codeunit "Temp Blob List"; var FilesJson: JSonObject) + var + TempBlob: Codeunit "Temp Blob"; + Child: JSonObject; + Children: JSonArray; + OutStream: OutStream; + ChildTxt: Text; + I: Integer; + ChildCount: Integer; + begin + Children := FilesJson.GetArray('value'); + ChildCount := Children.Count(); + if ChildCount > 0 then + for I := 0 to (ChildCount - 1) do begin + Clear(TempBlob); + TempBlob.CreateOutStream(OutStream, TextEncoding::UTF8); + Child := Children.GetObject(I); + Child.WriteTo(ChildTxt); + if not IgnoreDriveItem(ChildTxt.ToLower()) then begin + OutStream.Write(ChildTxt); + Documents.Add(TempBlob); + end; + end; + end; + + local procedure IgnoreDriveItem(ItemAsTxt: Text): Boolean + begin + if ItemAsTxt.Contains('"malware"') then + exit(true); + + if not DelChr(ItemAsTxt, '=', ' ').Contains('"mimetype":"application/pdf"') then + exit(true); + end; + + procedure DownloadDocument(var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service"; DocumentMetadataBlob: Codeunit "Temp Blob"; ReceiveContext: Codeunit ReceiveContext) + var + TempDocumentSharing: Record "Document Sharing" temporary; + GraphClient: Codeunit "Graph Client"; + FeatureTelemetry: Codeunit "Feature Telemetry"; + DocumentOutStream: OutStream; + DocumentInStream: InStream; + DocumentId, FileId, SiteId : Text; + begin + ExtractItemIdAndName(DocumentMetadataBlob, DocumentId, FileId); + + TempDocumentSharing.Init(); + TempDocumentSharing."Item Id" := CopyStr(DocumentId, 1, MaxStrLen(TempDocumentSharing."Item Id")); + TempDocumentSharing.Insert(); + + SiteId := GetSiteId(EDocumentService."Service Integration V2"); + + FeatureTelemetry.LogUptake('0000OB0', FeatureName(), Enum::"Feature Uptake Status"::Used); + FeatureTelemetry.LogUsage('0000OB3', FeatureName(), Format(EDocumentService."Service Integration V2")); + + if not GraphClient.GetFileContent(SiteId, TempDocumentSharing) then begin + EDocumentErrorHelper.LogSimpleErrorMessage(EDocument, GetLastErrorText()); + ClearLastError(); + exit; + end; + + TempDocumentSharing.CalcFields(Data); + if not TempDocumentSharing.Data.HasValue() then + EDocumentErrorHelper.LogSimpleErrorMessage(EDocument, StrSubstNo(NoContentErr, DocumentId)); + + ReceiveContext.GetTempBlob().CreateOutStream(DocumentOutStream, TextEncoding::UTF8); + TempDocumentSharing.Data.CreateInStream(DocumentInStream, TextEncoding::UTF8); + CopyStream(DocumentOutStream, DocumentInStream); + + UpdateEDocumentAfterDocumentDownload(Edocument, DocumentId, FileId); + UpdateReceiveContextAfterDocumentDownload(ReceiveContext); + end; + + internal procedure UpdateReceiveContextAfterDocumentDownload(ReceiveContext: Codeunit ReceiveContext) + begin + ReceiveContext.Status().SetStatus(Enum::"E-Document Service Status"::"Ready For Processing"); + end; + + internal procedure UpdateEDocumentAfterDocumentDownload(var EDocument: Record "E-Document"; DocumentId: Text; FileId: Text) + begin + EDocument."Document Id" := CopyStr(DocumentId, 1, MaxStrLen(EDocument."Document Id")); + EDocument."File Id" := CopyStr(FileId, 1, MaxStrLen(EDocument."File Id")); + EDocument.Modify(); + end; + + internal procedure ExtractItemIdAndName(DocumentMetadataBlob: Codeunit "Temp Blob"; var DocumentId: Text; var FileId: Text) + var + Instream: InStream; + ItemObject: JsonObject; + ContentData: Text; + begin + DocumentMetadataBlob.CreateInStream(Instream); + Instream.ReadText(ContentData); + ItemObject.ReadFrom(ContentData); + DocumentId := ItemObject.GetText('id'); + FileId := ItemObject.GetText('name'); + end; + + local procedure GetGraphSharesURL(): Text + var + URLHelper: Codeunit "Url Helper"; + begin + exit(URLHelper.GetGraphURL() + 'v1.0/shares/') + end; + + local procedure GetDocumentsSharedLink(var ServiceIntegration: Enum "Service Integration"): Text + var + SharepointSetup: Record "Sharepoint Setup"; + OneDriveSetup: Record "OneDrive Setup"; + Base64Convert: Codeunit "Base64 Convert"; + FolderSharedLink: Text; + Base64Value: Text; + begin + case ServiceIntegration of + ServiceIntegration::Sharepoint: + begin + if SharepointSetup.Get() then + if SharepointSetup.Enabled then + FolderSharedLink := SharepointSetup."Documents Folder"; + + CheckFolderSharedLinkNotEmpty(FolderSharedLink, SharepointSetup.TableCaption()); + end; + ServiceIntegration::OneDrive: + begin + if OneDriveSetup.Get() then + if OneDriveSetup.Enabled then + FolderSharedLink := OneDriveSetup."Documents Folder"; + CheckFolderSharedLinkNotEmpty(FolderSharedLink, OneDriveSetup.TableCaption()); + end; + else + Error(UnsupportedIntegrationTypeErr); + end; + if FolderSharedLink <> '' then begin + Base64Value := Base64Convert.ToBase64(FolderSharedLink); + Base64Value := 'u!' + Base64Value.TrimEnd('=').Replace('/', '_').Replace('+', '-'); + exit(Base64Value); + end; + end; + + local procedure GetSiteId(var ServiceIntegration: Enum "Service Integration"): Text + var + SharepointSetup: Record "Sharepoint Setup"; + OneDriveSetup: Record "OneDrive Setup"; + SiteId: Text; + begin + case ServiceIntegration of + ServiceIntegration::Sharepoint: + begin + CheckSetupEnabled(SharepointSetup); + CheckFolderSharedLinkNotEmpty(SharepointSetup."Documents Folder", SharepointSetup.TableCaption()); + SiteId := SharepointSetup.SiteId; + end; + ServiceIntegration::OneDrive: + begin + CheckSetupEnabled(OneDriveSetup); + CheckFolderSharedLinkNotEmpty(OneDriveSetup."Documents Folder", OneDriveSetup.TableCaption()); + SiteId := OneDriveSetup.SiteId; + end; + else + Error(UnsupportedIntegrationTypeErr); + end; + exit(SiteId); + end; + + local procedure GetImportedDocumentsFolderId(var ServiceIntegration: Enum "Service Integration"): Text + var + SharepointSetup: Record "Sharepoint Setup"; + OneDriveSetup: Record "OneDrive Setup"; + ImportedDocumentsFolderId: Text; + begin + case ServiceIntegration of + ServiceIntegration::Sharepoint: + begin + CheckSetupEnabled(SharepointSetup); + CheckFolderSharedLinkNotEmpty(SharepointSetup."Imp. Documents Folder", SharepointSetup.TableCaption()); + ImportedDocumentsFolderId := SharepointSetup."Imp. Documents Folder Id"; + end; + ServiceIntegration::OneDrive: + begin + CheckSetupEnabled(OneDriveSetup); + CheckFolderSharedLinkNotEmpty(OneDriveSetup."Imp. Documents Folder", OneDriveSetup.TableCaption()); + ImportedDocumentsFolderId := OneDriveSetup."Imp. Documents Folder Id"; + end; + else + Error(UnsupportedIntegrationTypeErr); + end; + exit(ImportedDocumentsFolderId); + end; + + local procedure CheckSetupEnabled(var OneDriveSetup: Record "OneDrive Setup") + begin + if not OneDriveSetup.Get() then + Error(IntegrationNotEnabledErr, OneDriveSetup.TableCaption()); + if not OneDriveSetup.Enabled then + Error(IntegrationNotEnabledErr, OneDriveSetup.TableCaption()); + end; + + local procedure CheckSetupEnabled(var SharepointSetup: Record "Sharepoint Setup") + begin + if not SharepointSetup.Get() then + Error(IntegrationNotEnabledErr, SharepointSetup.TableCaption()); + if not SharepointSetup.Enabled then + Error(IntegrationNotEnabledErr, SharepointSetup.TableCaption()); + end; + + local procedure CheckFolderSharedLinkNotEmpty(FolderSharedLink: Text; SetupTableCaption: Text) + begin + if FolderSharedLink = '' then + Error(IntegrationNotEnabledErr, SetupTableCaption); + end; + + var + EDocumentErrorHelper: Codeunit "E-Document Error Helper"; + NoContentErr: Label 'Empty content retrieved from the service for document id: %1.', Comment = '%1 - Document ID'; + IntegrationNotEnabledErr: Label '%1 must be enabled.', Comment = '%1 - a table caption, Sharepoint Document Import Setup'; + UnsupportedIntegrationTypeErr: Label 'You must choose a upported integration type.'; + DocumentIdEmptyErr: Label 'Document Id is empty on e-document %1.', Comment = '%1 - an integer'; +} \ No newline at end of file diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/app/src/EDocumentCardExt.PageExt.al b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/EDocumentCardExt.PageExt.al new file mode 100644 index 0000000000..bdcde5941e --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/EDocumentCardExt.PageExt.al @@ -0,0 +1,44 @@ +namespace Microsoft.EServices.EDocumentConnector.Microsoft365; + +using Microsoft.eServices.EDocument; + +pageextension 6384 EDocumentCardExt extends "E-Document" +{ + layout + { + addafter(General) + { + group(Service) + { + Caption = 'Service'; + Visible = ServiceFieldGroupVisible; + + field("File Id"; Rec."File Id") + { + ApplicationArea = All; + Caption = 'File Name'; + ToolTip = 'Specifies the name of the attached file'; + Visible = ServiceFieldGroupVisible; + Editable = false; + + trigger OnDrillDown() + var + IntegrationImpl: Codeunit "Integration Impl."; + begin + IntegrationImpl.PreviewContent(Rec); + end; + } + } + } + } + + trigger OnOpenPage() + var + IntegrationImpl: Codeunit "Integration Impl."; + begin + IntegrationImpl.SetConditionalVisibilityFlag(ServiceFieldGroupVisible); + end; + + var + ServiceFieldGroupVisible: Boolean; +} \ No newline at end of file diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/app/src/EDocumentListExt.PageExt.al b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/EDocumentListExt.PageExt.al new file mode 100644 index 0000000000..e4338f34b0 --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/EDocumentListExt.PageExt.al @@ -0,0 +1,38 @@ +namespace Microsoft.EServices.EDocumentConnector.Microsoft365; + +using Microsoft.eServices.EDocument; + +pageextension 6383 EDocumentListExt extends "E-Documents" +{ + layout + { + addafter("Entry No") + { + field("File Id"; Rec."File Id") + { + ApplicationArea = All; + Caption = 'File Name'; + ToolTip = 'Specifies the name of the attached file'; + Visible = FileIdVisible; + Editable = false; + + trigger OnDrillDown() + var + IntegrationImpl: Codeunit "Integration Impl."; + begin + IntegrationImpl.PreviewContent(Rec); + end; + } + } + } + + trigger OnOpenPage() + var + IntegrationImpl: Codeunit "Integration Impl."; + begin + IntegrationImpl.SetConditionalVisibilityFlag(FileIdVisible); + end; + + var + FileIdVisible: Boolean; +} \ No newline at end of file diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/app/src/GraphAuthentication.Codeunit.al b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/GraphAuthentication.Codeunit.al new file mode 100644 index 0000000000..638fc3ee0a --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/GraphAuthentication.Codeunit.al @@ -0,0 +1,110 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.EServices.EDocumentConnector.Microsoft365; + +using System.Environment; +using System.Security.Authentication; +using System.Azure.KeyVault; + +codeunit 6383 "Graph Authentication" +{ + Access = Internal; + + internal procedure GetAccessToken(var Token: SecretText) + var + OAuth2: Codeunit OAuth2; + FirstPartyAppId: Text; + FirstPartyAppCertificate: SecretText; + RedirectUrl, ResourceURL, AuthorityURL, AuthError : Text; + begin + if not EnvironmentInformation.IsSaaSInfrastructure() then + Error(AvailableOnlyOnSaaSErr); + + FirstPartyAppId := GetFirstPartyAppId(); + FirstPartyAppCertificate := GetFirstPartyAppCertificate(); + AuthorityURL := GetOAuthAuthorityURL(); + RedirectURL := GetRedirectURL(); + ResourceURL := GetResourceURL(); + + if (FirstPartyAppId = '') or FirstPartyAppCertificate.IsEmpty() then + Error(MissingFirstPartyappIdOrCertificateTelemetryTxt); + + if OAuth2.AcquireAuthorizationCodeTokenFromCacheWithCertificate(FirstPartyAppId, FirstPartyAppCertificate, RedirectUrl, AuthorityURL, ResourceURL, Token) then + if not Token.IsEmpty() then begin + Session.LogMessage('0000NWC', StrSubstNo(AcquiredTokenFromCacheTelemetry1PAppMsg, FirstPartyAppId, ResourceURL), Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CategoryLbl); + exit; + end; + + if OAuth2.AcquireTokenByAuthorizationCodeWithCertificate(FirstPartyAppId, FirstPartyAppCertificate, AuthorityURL, RedirectURL, ResourceURL, Enum::"Prompt Interaction"::"Select Account", Token, AuthError) then + if not Token.IsEmpty() then begin + Session.LogMessage('0000NWD', StrSubstNo(AcquiredTokenTelemetry1PAppMsg, FirstPartyAppId, ResourceURL), Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CategoryLbl); + exit; + end; + + Session.LogMessage('0000NWE', StrSubstNo(EmptyTokenTelemetry1PAppMsg, FirstPartyAppId, ResourceURL), Verbosity::Warning, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CategoryLbl); + end; + + [NonDebuggable] + procedure GetFirstPartyAppId(): Text + var + AzureKeyVault: Codeunit "Azure Key Vault"; + ClientId: Text; + begin + if EnvironmentInformation.IsSaaSInfrastructure() then + if not AzureKeyVault.GetAzureKeyVaultSecret(BCToGraphAppIdSecretNameLbl, ClientId) then + Session.LogMessage('0000NWF', MissingFirstPartyappIdOrCertificateTelemetryTxt, Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CategoryLbl) + else + exit(ClientId); + exit(ClientId); + end; + + [NonDebuggable] + procedure GetFirstPartyAppCertificate(): SecretText; + var + AzureKeyVault: Codeunit "Azure Key Vault"; + Certificate: SecretText; + CertificateName: Text; + begin + if EnvironmentInformation.IsSaaSInfrastructure() then + if not AzureKeyVault.GetAzureKeyVaultSecret(BCToGraphAppCertificateNameSecretNameLbl, CertificateName) then begin + Session.LogMessage('0000EBV', MissingFirstPartyappIdOrCertificateTelemetryTxt, Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CategoryLbl); + exit(Certificate); + end; + + if not AzureKeyVault.GetAzureKeyVaultCertificate(CertificateName, Certificate) then + Session.LogMessage('0000EC2', MissingFirstPartyappIdOrCertificateTelemetryTxt, Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CategoryLbl); + + exit(Certificate); + end; + + local procedure GetOAuthAuthorityURL(): Text + begin + exit(OAuthAuthorityUrlLbl); + end; + + local procedure GetResourceURL(): Text + begin + exit(GraphApiUrlTxt); + end; + + local procedure GetRedirectURL(): Text + begin + if EnvironmentInformation.IsSaaSInfrastructure() then + exit(''); + end; + + var + EnvironmentInformation: Codeunit "Environment Information"; + GraphApiUrlTxt: Label 'https://graph.microsoft.com', Locked = true; + OAuthAuthorityUrlLbl: Label 'https://login.microsoftonline.com/common/oauth2', Locked = true; + EmptyTokenTelemetry1PAppMsg: Label 'Empty access token from 1P App %1 for resource %2.', Locked = true; + AcquiredTokenTelemetry1PAppMsg: Label 'Access token acquired via 1P App %1 for resource %2.', Locked = true; + AcquiredTokenFromCacheTelemetry1PAppMsg: Label 'Access token acquired from cache via 1P App %1 for resource %2.', Locked = true; + BCToGraphAppIdSecretNameLbl: Label 'BCToGraphAppId', Locked = true; + BCToGraphAppCertificateNameSecretNameLbl: Label 'BCToGraphCertificateName', Locked = true; + MissingFirstPartyappIdOrCertificateTelemetryTxt: Label 'The OAuth2 app id or certificate have not been initialized. Note that this functionality is available only on fully Microsoft-hosted environemnts, excluding Embed ISV environments.', Locked = true; + CategoryLbl: Label 'EDoc Connector M365', Locked = true; + AvailableOnlyOnSaaSErr: Label 'This functionality is available only when running on Business Central Online environment.'; +} \ No newline at end of file diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/app/src/GraphClient.Codeunit.al b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/GraphClient.Codeunit.al new file mode 100644 index 0000000000..266f608472 --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/GraphClient.Codeunit.al @@ -0,0 +1,152 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.EServices.EDocumentConnector.Microsoft365; + +using System; +using System.Environment; +using System.Integration; +using System.Utilities; + +codeunit 6384 "Graph Client" +{ + Access = Internal; + + internal procedure InitializeWebRequest(Url: Text; Method: Text; ReturnType: Text; var HttpWebRequestMgt: Codeunit "Http Web Request Mgt.") + var + GraphAuthentication: Codeunit "Graph Authentication"; + Token: SecretText; + begin + if not EnvironmentInformation.IsSaaSInfrastructure() then + Error(AvailableOnlyOnSaaSErr); + + GraphAuthentication.GetAccessToken(Token); + + if Token.IsEmpty() then begin + Session.LogMessage('0000OB4', EmptyTokenTelemetryMsg, Verbosity::Warning, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CategoryLbl); + Error(SignInAgainErr); + end; + + HttpWebRequestMgt.Initialize(Url); + HttpWebRequestMgt.DisableUI(); + HttpWebRequestMgt.SetMethod(Method); + HttpWebRequestMgt.SetReturnType(ReturnType); + HttpWebRequestMgt.AddHeader('Authorization', SecretStrSubstNo('Bearer %1', Token)); + end; + + [TryFunction] + [NonDebuggable] + procedure GetDriveFolderInfo(FolderUrl: Text; var FolderJson: JsonObject) + var + HttpWebRequestMgt: Codeunit "Http Web Request Mgt."; + ResponseBody: Text; + ErrorMessage: Text; + ErrorDetails: Text; + HttpStatusCode: DotNet HttpStatusCode; + ResponseHeaders: DotNet NameValueCollection; + begin + InitializeWebRequest(FolderUrl, 'GET', 'application/json', HttpWebRequestMgt); + + if not HttpWebRequestMgt.SendRequestAndReadTextResponse(ResponseBody, ErrorMessage, ErrorDetails, HttpStatusCode, ResponseHeaders) then begin + Session.LogMessage('0000OB5', StrSubstNo(GraphStatusCodeTelemetryMsg, HttpStatusCode), Verbosity::Warning, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CategoryLbl); + + CheckNoAccessError(HttpStatusCode, ErrorDetails); + Error(UnexpectedStatusCodeErr, HttpStatusCode); + end; + + if not FolderJson.ReadFrom(ResponseBody) then + Error(InvalidJsonErr, ResponseBody); + end; + + [TryFunction] + [NonDebuggable] + procedure GetFileContent(SiteId: Text; var TempDocumentSharing: Record "Document Sharing" temporary) + var + HttpWebRequestMgt: Codeunit "Http Web Request Mgt."; + TempBlob: Codeunit "Temp Blob"; + ErrorMessage: Text; + ErrorDetails: Text; + FileUrl: Text; + HttpStatusCode: DotNet HttpStatusCode; + ResponseHeaders: DotNet NameValueCollection; + InStream: InStream; + OutStream: OutStream; + begin + FileUrl := GetGraphItemByIdUrl(SiteId, TempDocumentSharing."Item Id") + '/content'; + + InitializeWebRequest(FileUrl, 'GET', '', HttpWebRequestMgt); + + if not HttpWebRequestMgt.SendRequestAndReadResponse(TempBlob, ErrorMessage, ErrorDetails, HttpStatusCode, ResponseHeaders) then begin + Session.LogMessage('0000OB6', StrSubstNo(GraphStatusCodeTelemetryMsg, HttpStatusCode), Verbosity::Warning, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CategoryLbl); + + CheckNoAccessError(HttpStatusCode, ErrorDetails); + Error(UnexpectedStatusCodeErr, HttpStatusCode); + end; + + if TempBlob.Length() = 0 then + Session.LogMessage('0000OB7', GraphEmptyFileTelemetryMsg, Verbosity::Warning, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CategoryLbl) + else begin + Session.LogMessage('0000OB8', StrSubstNo(GraphFileTelemetryMsg, TempBlob.Length()), Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CategoryLbl); + TempDocumentSharing.Data.CreateOutStream(OutStream); + TempBlob.CreateInStream(InStream); + CopyStream(OutStream, InStream); + end; + end; + + [TryFunction] + [NonDebuggable] + procedure MoveDriveItem(SiteId: Text; ItemId: Text; NewFolderId: Text) + var + HttpWebRequestMgt: Codeunit "Http Web Request Mgt."; + ResponseBody: Text; + ErrorMessage: Text; + ErrorDetails: Text; + ItemUrl: Text; + BodyTxt: Text; + HttpStatusCode: DotNet HttpStatusCode; + ResponseHeaders: DotNet NameValueCollection; + begin + ItemUrl := GetGraphItemByIdUrl(SiteId, ItemId); + BodyTxt := '{ "parentReference": { "id": "' + NewFolderId + '" } }'; + InitializeWebRequest(ItemUrl, 'PATCH', '', HttpWebRequestMgt); + HttpWebRequestMgt.SetContentType('application/json'); + HttpWebRequestMgt.AddBodyAsText(BodyTxt); + if not HttpWebRequestMgt.SendRequestAndReadTextResponse(ResponseBody, ErrorMessage, ErrorDetails, HttpStatusCode, ResponseHeaders) then begin + Session.LogMessage('0000N7U', StrSubstNo(GraphStatusCodeTelemetryMsg, HttpStatusCode), Verbosity::Warning, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CategoryLbl); + + CheckNoAccessError(HttpStatusCode, ErrorDetails); + Error(UnexpectedStatusCodeErr, HttpStatusCode); + end; + end; + + local procedure GetGraphItemByIdUrl(SiteId: Text; ItemId: Text): Text + begin + exit(StrSubstNo(GraphItemUrlTxt, SiteId, ItemId)); + end; + + local procedure CheckNoAccessError(HttpStatusCode: Integer; HttpErrorDetails: Text) + var + ErrorTxt: Text; + begin + if HttpStatusCode in [401, 403, 404] then begin + ErrorTxt := DocumentFolderNotAccessibleErr + '\\' + HttpErrorDetails; + Error(ErrorTxt); + end; + end; + + var + EnvironmentInformation: Codeunit "Environment Information"; + GraphItemUrlTxt: Label 'https://graph.microsoft.com/v1.0/sites/%1/drive/items/%2', Locked = true; + EmptyTokenTelemetryMsg: Label 'No Microsoft 365 access token received', Locked = true; + AvailableOnlyOnSaaSErr: Label 'This functionality is available only when running on Business Central Online environment.'; + SignInAgainErr: Label 'No access token is available. You must sign in to the target resource with the correct credentials. If the problem persists, open a Business Central support request.'; + DocumentFolderNotAccessibleErr: Label 'Unable to access the folder specified on the setup page. Verify that the shared link points to an existing folder and that you have access to it.'; + GraphStatusCodeTelemetryMsg: Label 'Microsoft 365 returned an error code: %1.', Locked = true; + UnexpectedStatusCodeErr: Label 'Remote service returned an unexpected error code: %1.', Comment = '%1 = An error code from OneDrive or Sharepoint, for example 503'; + InvalidJsonErr: Label 'Remote service returned an invalid response. Details: %1.', Comment = '%1 = The response details from OneDrive or Sharepoint (e.g. "Your Drive is not available")'; + CategoryLbl: Label 'EDoc Connector M365', Locked = true; + GraphEmptyFileTelemetryMsg: Label 'Microsoft 365 returned an empty file.', Locked = true; + GraphFileTelemetryMsg: Label 'Microsoft 365 file size: %1', Locked = true; + +} \ No newline at end of file diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/app/src/Integration.EnumExt.al b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/Integration.EnumExt.al new file mode 100644 index 0000000000..9e89742177 --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/Integration.EnumExt.al @@ -0,0 +1,20 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.EServices.EDocumentConnector.Microsoft365; + +using Microsoft.eServices.EDocument.Integration; +using Microsoft.eServices.EDocument.Integration.Interfaces; + +enumextension 6381 "Integration" extends "Service Integration" +{ + value(6381; "OneDrive") + { + Implementation = IDocumentSender = "Integration Impl.", IDocumentReceiver = "Integration Impl."; + } + value(6382; "Sharepoint") + { + Implementation = IDocumentSender = "Integration Impl.", IDocumentReceiver = "Integration Impl."; + } +} \ No newline at end of file diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/app/src/IntegrationImpl.Codeunit.al b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/IntegrationImpl.Codeunit.al new file mode 100644 index 0000000000..6bc7232c3b --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/IntegrationImpl.Codeunit.al @@ -0,0 +1,120 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.EServices.EDocumentConnector.Microsoft365; + +using System.Utilities; +using Microsoft.EServices.EDocument; +using Microsoft.eServices.EDocument.Integration.Interfaces; +using Microsoft.eServices.EDocument.Integration.Receive; +using Microsoft.eServices.EDocument.Integration.Send; + +codeunit 6382 "Integration Impl." implements IDocumentReceiver, IDocumentSender, IReceivedDocumentMarker +{ + Permissions = tabledata "E-Document" = r, + tabledata "E-Document Log" = r, + tabledata "E-Doc. Data Storage" = r, + tabledata "OneDrive Setup" = r, + tabledata "Sharepoint Setup" = r; + InherentPermissions = X; + InherentEntitlements = X; + + procedure Send(var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service"; SendContext: Codeunit SendContext) + begin + Error(SendNotSupportedErr); + end; + + procedure ReceiveDocuments(var EDocumentService: Record "E-Document Service"; Documents: Codeunit "Temp Blob List"; ReceiveContext: Codeunit ReceiveContext) + begin + DriveProcessing.ReceiveDocuments(EDocumentService, Documents, ReceiveContext); + end; + + procedure DownloadDocument(var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service"; DocumentMetadataBlob: Codeunit "Temp Blob"; ReceiveContext: Codeunit ReceiveContext) + begin + DriveProcessing.DownloadDocument(EDocument, EDocumentService, DocumentMetadataBlob, ReceiveContext); + end; + + procedure MarkFetched(var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service"; var DocumentBlob: Codeunit "Temp Blob"; ReceiveContext: Codeunit ReceiveContext) + begin + DriveProcessing.MarkEDocumentAsDownloaded(EDocument, EDocumentService); + end; + + internal procedure PreviewContent(var EDocument: Record "E-Document") + var + EDocDataStorage: Record "E-Doc. Data Storage"; + EDocumentLog: Record "E-Document Log"; + FileInStr: InStream; + begin + if not LowerCase(EDocument."File Id").EndsWith('pdf') then + exit; + + EDocumentLog.SetRange("E-Doc. Entry No", EDocument."Entry No"); + EDocumentLog.SetFilter(Status, '<>' + Format(EDocumentLog.Status::"Batch Imported")); + + if not EDocumentLog.FindFirst() then + Error(NoFileErr, EDocument.TableCaption()); + + EDocDataStorage.SetAutoCalcFields("Data Storage"); + if not EDocDataStorage.Get(EDocumentLog."E-Doc. Data Storage Entry No.") then + Error(NoFileErr, EDocument.TableCaption()); + + if not EDocDataStorage."Data Storage".HasValue() then + Error(NoFileContentErr, EDocument."File Id", EDocDataStorage.TableCaption()); + + EDocDataStorage."Data Storage".CreateInStream(FileInStr); + File.ViewFromStream(FileInStr, EDocument."File Id", true); + end; + + internal procedure SetConditionalVisibilityFlag(var VisibilityFlag: Boolean) + var + OneDriveSetup: Record "OneDrive Setup"; + SharepointSetup: Record "Sharepoint Setup"; + begin + if SharepointSetup.Get() then + if SharepointSetup.Enabled then + VisibilityFlag := true; + + if not VisibilityFlag then + if OneDriveSetup.Get() then + if OneDriveSetup.Enabled then + VisibilityFlag := true; + end; + + [EventSubscriber(ObjectType::Page, Page::"E-Document Service", OnBeforeOpenServiceIntegrationSetupPage, '', false, false)] + local procedure OnBeforeOpenServiceIntegrationSetupPage(EDocumentService: Record "E-Document Service"; var IsServiceIntegrationSetupRun: Boolean) + var + OneDriveSetup: Page "OneDrive Setup"; + SharepointSetup: Page "Sharepoint Setup"; + begin + if EDocumentService."Service Integration V2" = EDocumentService."Service Integration V2"::OneDrive then begin + OneDriveSetup.RunModal(); + IsServiceIntegrationSetupRun := true; + end; + + if EDocumentService."Service Integration V2" = EDocumentService."Service Integration V2"::Sharepoint then begin + SharepointSetup.RunModal(); + IsServiceIntegrationSetupRun := true; + end; + end; + + [EventSubscriber(ObjectType::Table, Database::"E-Document Log", OnBeforeExportDataStorage, '', false, false)] + local procedure HandleOnBeforeExportDataStorage(EDocumentLog: Record "E-Document Log"; var FileName: Text) + var + EDocument: Record "E-Document"; + begin + if not EDocument.Get(EDocumentLog."E-Doc. Entry No") then + exit; + + if EDocument."File Id" = '' then + exit; + + FileName := EDocument."File Id"; + end; + + var + DriveProcessing: Codeunit "Drive Processing"; + SendNotSupportedErr: label 'Sending document is not supported in this context.'; + NoFileErr: label 'No previewable attachment exists for this %2.', Comment = '%1 - a table caption'; + NoFileContentErr: label 'Previewing file %1 failed. The file was found in table %2, but it has no content.', Comment = '%1 - a file name; %2 - a table caption'; +} \ No newline at end of file diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/app/src/OneDriveSetup.Page.al b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/OneDriveSetup.Page.al new file mode 100644 index 0000000000..b2ddbcfb9a --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/OneDriveSetup.Page.al @@ -0,0 +1,100 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.EServices.EDocumentConnector.Microsoft365; + +using System.Telemetry; + +page 6381 "OneDrive Setup" +{ + Permissions = tabledata "OneDrive Setup" = rim; + ApplicationArea = Basic, Suite; + Caption = 'OneDrive Document Import Setup'; + DeleteAllowed = false; + InsertAllowed = false; + LinksAllowed = false; + ShowFilter = false; + SourceTable = "OneDrive Setup"; + UsageCategory = Administration; + InherentPermissions = X; + InherentEntitlements = X; + + layout + { + area(content) + { + group(Status) + { + Caption = ' '; + ShowCaption = false; + + field(Enabled; Rec.Enabled) + { + ApplicationArea = Basic, Suite; + ToolTip = 'Specifies is the document import enabled.'; + } + } + group(General) + { + Caption = 'Shared Links to Document Folders'; + InstructionalText = 'Use the OneDrive ''Copy Link'' feature to create the shared links and define who they work for, then paste them to the corresponding fields.'; + + field("Documents Folder URL"; Rec."Documents Folder") + { + Caption = 'Documents'; + ApplicationArea = Basic, Suite; + Editable = EditableByNotEnabled; + ShowMandatory = true; + ToolTip = 'Specifies the shared link of the folder from which to import documents.'; + } + field("Imported Documents Folder URL"; Rec."Imp. Documents Folder") + { + Caption = 'Imported Documents'; + ApplicationArea = Basic, Suite; + Editable = EditableByNotEnabled; + ShowMandatory = true; + ToolTip = 'Specifies the shared link of the folder to which the imported documents will be moved.'; + } + } + } + } + + trigger OnAfterGetRecord() + begin + UpdateBasedOnEnable(); + end; + + trigger OnOpenPage() + var + FeatureTelemetry: Codeunit "Feature Telemetry"; + DriveProcessing: Codeunit "Drive Processing"; + begin + Rec.Reset(); + if not Rec.Get() then begin + Rec.Init(); + Rec.Insert(true); + FeatureTelemetry.LogUptake('0000OBD', DriveProcessing.FeatureName(), Enum::"Feature Uptake Status"::Discovered); + FeatureTelemetry.LogUsage('0000OBE', DriveProcessing.FeatureName(), 'OneDrive'); + end; + UpdateBasedOnEnable(); + end; + + trigger OnQueryClosePage(CloseAction: Action): Boolean + begin + if not Rec.Enabled then + if not Confirm(StrSubstNo(EnableServiceQst, CurrPage.Caption), true) then + exit(false); + end; + + var + EditableByNotEnabled: Boolean; + EnableServiceQst: Label 'The %1 is not enabled. Are you sure you want to exit?', Comment = '%1 = page caption'; + + local procedure UpdateBasedOnEnable() + begin + EditableByNotEnabled := (not Rec.Enabled) and CurrPage.Editable; + end; + +} + diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/app/src/OneDriveSetup.Table.al b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/OneDriveSetup.Table.al new file mode 100644 index 0000000000..907605d638 --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/OneDriveSetup.Table.al @@ -0,0 +1,93 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.EServices.EDocumentConnector.Microsoft365; +using System.Telemetry; + +table 6381 "OneDrive Setup" +{ + ReplicateData = false; + DataClassification = CustomerContent; + Caption = 'OneDrive Document Import Setup'; + InherentPermissions = X; + InherentEntitlements = X; + + fields + { + field(1; "Primary Key"; Code[10]) + { + Caption = 'Primary Key'; + DataClassification = CustomerContent; + } + field(2; Enabled; Boolean) + { + Caption = 'Enabled'; + DataClassification = CustomerContent; + + trigger OnValidate() + var + FeatureTelemetry: Codeunit "Feature Telemetry"; + DriveProcessing: Codeunit "Drive Processing"; + begin + if Rec.Enabled then begin + if (Rec."Imp. Documents Folder" = '') or (Rec."Documents Folder" = '') then + Error(URLsMustBeSpecifiedErr); + FeatureTelemetry.LogUptake('0000OB9', DriveProcessing.FeatureName(), Enum::"Feature Uptake Status"::Used); + FeatureTelemetry.LogUsage('0000OBA', DriveProcessing.FeatureName(), 'OneDrive'); + end; + end; + } + field(3; "Documents Folder"; Text[2048]) + { + Caption = 'Documents Folder'; + DataClassification = CustomerContent; + trigger OnValidate() + var + DriveProcessing: Codeunit "Drive Processing"; + begin + if Rec."Documents Folder" <> '' then + Rec.SiteId := CopyStr(DriveProcessing.GetSiteId(Rec."Documents Folder"), 1, MaxStrLen(Rec.SiteId)) + else + Rec.SiteId := ''; + end; + } + field(4; "Imp. Documents Folder"; Text[2048]) + { + Caption = 'Imported Documents Folder'; + DataClassification = CustomerContent; + + trigger OnValidate() + var + DriveProcessing: Codeunit "Drive Processing"; + begin + if Rec."Imp. Documents Folder" <> '' then + Rec."Imp. Documents Folder Id" := CopyStr(DriveProcessing.GetId(Rec."Imp. Documents Folder"), 1, MaxStrLen(Rec."Imp. Documents Folder Id")) + else + Rec."Imp. Documents Folder Id" := ''; + end; + } + field(5; "SiteId"; Text[2048]) + { + Caption = 'Site Id'; + DataClassification = CustomerContent; + } + field(6; "Imp. Documents Folder Id"; Text[2048]) + { + Caption = 'Imported Documents Folder Id'; + DataClassification = CustomerContent; + } + } + + keys + { + key(Key1; "Primary Key") + { + Clustered = true; + } + } + + var + URLsMustBeSpecifiedErr: label 'You must specify the URL to the folder that contains documents to be imported and the URL to the folder to which the imported documents will be moved.'; +} + diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/app/src/Permissions/M365EDocConnEdit.PermissionSet.al b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/Permissions/M365EDocConnEdit.PermissionSet.al new file mode 100644 index 0000000000..a3d2c25974 --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/Permissions/M365EDocConnEdit.PermissionSet.al @@ -0,0 +1,16 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.EServices.EDocumentConnector.Microsoft365; + +permissionset 6381 M365EDocConnEdit +{ + Access = Public; + Assignable = true; + IncludedPermissionSets = M365EDocConnRead; + Caption = 'Microsoft 365 E-Document Connector - Edit'; + + Permissions = tabledata "OneDrive Setup" = imd, + tabledata "Sharepoint Setup" = imd; +} \ No newline at end of file diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/app/src/Permissions/M365EDocConnRead.PermissionSet.al b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/Permissions/M365EDocConnRead.PermissionSet.al new file mode 100644 index 0000000000..7f4cdd7da2 --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/Permissions/M365EDocConnRead.PermissionSet.al @@ -0,0 +1,15 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.EServices.EDocumentConnector.Microsoft365; + +permissionset 6382 M365EDocConnRead +{ + Access = Public; + Assignable = true; + Caption = 'Microsoft 365 E-Document Connector - Read'; + + Permissions = tabledata "OneDrive Setup" = r, + tabledata "Sharepoint Setup" = r; +} \ No newline at end of file diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/app/src/Permissions/M365EDocConnectorEdit.PermissionSetExt.al b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/Permissions/M365EDocConnectorEdit.PermissionSetExt.al new file mode 100644 index 0000000000..1a2b3234dc --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/Permissions/M365EDocConnectorEdit.PermissionSetExt.al @@ -0,0 +1,12 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.EServices.EDocumentConnector.Microsoft365; + +using Microsoft.EServices.EDocumentConnector; + +permissionsetextension 6385 "M365 EDoc. Connector - Edit" extends "EDocConnector - Edit" +{ + IncludedPermissionSets = M365EDocConnEdit; +} \ No newline at end of file diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/app/src/Permissions/M365EDocConnectorRead.PermissionSetExt.al b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/Permissions/M365EDocConnectorRead.PermissionSetExt.al new file mode 100644 index 0000000000..c25d0d2efa --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/Permissions/M365EDocConnectorRead.PermissionSetExt.al @@ -0,0 +1,12 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.EServices.EDocumentConnector.Microsoft365; + +using Microsoft.EServices.EDocumentConnector; + +permissionsetextension 6384 "M365 EDoc. Connector - Read" extends "EDocConnector - Read" +{ + IncludedPermissionSets = M365EDocConnRead; +} \ No newline at end of file diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/app/src/SharepointSetup.Page.al b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/SharepointSetup.Page.al new file mode 100644 index 0000000000..ca0e9c2978 --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/SharepointSetup.Page.al @@ -0,0 +1,95 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.EServices.EDocumentConnector.Microsoft365; + +using System.Telemetry; + +page 6382 "Sharepoint Setup" +{ + Permissions = tabledata "Sharepoint Setup" = rim; + ApplicationArea = Basic, Suite; + DeleteAllowed = false; + InsertAllowed = false; + LinksAllowed = false; + ShowFilter = false; + SourceTable = "Sharepoint Setup"; + UsageCategory = Administration; + Caption = 'Sharepoint Document Import Setup'; + InherentPermissions = X; + InherentEntitlements = X; + + layout + { + area(content) + { + group(Status) + { + field(Enabled; Rec.Enabled) + { + ApplicationArea = Basic, Suite; + ToolTip = 'Specifies is the document import enabled.'; + } + } + group(General) + { + Caption = 'Shared Links to Document Folders'; + InstructionalText = 'Use the Sharepoint ''Copy Link'' feature to create the shared links and define who they work for, then paste them to the corresponding fields.'; + + field("Documents"; Rec."Documents Folder") + { + ApplicationArea = Basic, Suite; + Editable = EditableByNotEnabled; + ShowMandatory = true; + ToolTip = 'Specifies the shared link of the folder from which to import documents.'; + } + field("Imported Documents"; Rec."Imp. Documents Folder") + { + ApplicationArea = Basic, Suite; + Editable = EditableByNotEnabled; + ShowMandatory = true; + ToolTip = 'Specifies the shared link of the folder to which the imported documents will be moved.'; + } + } + } + } + + trigger OnAfterGetRecord() + begin + UpdateBasedOnEnable(); + end; + + trigger OnOpenPage() + var + FeatureTelemetry: Codeunit "Feature Telemetry"; + DriveProcessing: Codeunit "Drive Processing"; + begin + Rec.Reset(); + if not Rec.Get() then begin + Rec.Init(); + Rec.Insert(true); + FeatureTelemetry.LogUptake('0000OBF', DriveProcessing.FeatureName(), Enum::"Feature Uptake Status"::Discovered); + FeatureTelemetry.LogUsage('0000OBG', DriveProcessing.FeatureName(), 'Sharepoint'); + end; + UpdateBasedOnEnable(); + end; + + trigger OnQueryClosePage(CloseAction: Action): Boolean + begin + if not Rec.Enabled then + if not Confirm(StrSubstNo(EnableServiceQst, CurrPage.Caption), true) then + exit(false); + end; + + var + EditableByNotEnabled: Boolean; + EnableServiceQst: Label 'The %1 is not enabled. Are you sure you want to exit?', Comment = '%1 = page caption'; + + local procedure UpdateBasedOnEnable() + begin + EditableByNotEnabled := (not Rec.Enabled) and CurrPage.Editable; + end; + +} + diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/app/src/SharepointSetup.Table.al b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/SharepointSetup.Table.al new file mode 100644 index 0000000000..b59eb6dbb1 --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/SharepointSetup.Table.al @@ -0,0 +1,96 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.EServices.EDocumentConnector.Microsoft365; + +using System.Telemetry; + +table 6382 "Sharepoint Setup" +{ + Caption = 'Sharepoint Document Import Setup'; + ReplicateData = false; + DataClassification = CustomerContent; + InherentPermissions = X; + InherentEntitlements = X; + + fields + { + field(1; "Primary Key"; Code[10]) + { + Caption = 'Primary Key'; + DataClassification = CustomerContent; + } + field(2; Enabled; Boolean) + { + Caption = 'Enabled'; + DataClassification = CustomerContent; + + trigger OnValidate() + var + FeatureTelemetry: Codeunit "Feature Telemetry"; + DriveProcessing: Codeunit "Drive Processing"; + begin + if Rec.Enabled then begin + if (Rec."Imp. Documents Folder" = '') or (Rec."Documents Folder" = '') then + Error(URLsMustBeSpecifiedErr); + + FeatureTelemetry.LogUptake('0000OBB', DriveProcessing.FeatureName(), Enum::"Feature Uptake Status"::Used); + FeatureTelemetry.LogUsage('0000OBC', DriveProcessing.FeatureName(), 'Sharepoint'); + end; + end; + } + field(3; "Documents Folder"; Text[2048]) + { + Caption = 'Documents'; + DataClassification = CustomerContent; + + trigger OnValidate() + var + DriveProcessing: Codeunit "Drive Processing"; + begin + if Rec."Documents Folder" <> '' then + Rec.SiteId := CopyStr(DriveProcessing.GetSiteId(Rec."Documents Folder"), 1, MaxStrLen(Rec.SiteId)) + else + Rec.SiteId := ''; + end; + } + field(4; "Imp. Documents Folder"; Text[2048]) + { + Caption = 'Imported Documents'; + DataClassification = CustomerContent; + + trigger OnValidate() + var + DriveProcessing: Codeunit "Drive Processing"; + begin + if Rec."Imp. Documents Folder" <> '' then + Rec."Imp. Documents Folder Id" := CopyStr(DriveProcessing.GetId(Rec."Imp. Documents Folder"), 1, MaxStrLen(Rec."Imp. Documents Folder Id")) + else + Rec."Imp. Documents Folder Id" := ''; + end; + } + field(5; "SiteId"; Text[2048]) + { + Caption = 'Site Id'; + DataClassification = CustomerContent; + } + field(6; "Imp. Documents Folder Id"; Text[2048]) + { + Caption = 'Imported Documents Folder Id'; + DataClassification = CustomerContent; + } + } + + keys + { + key(Key1; "Primary Key") + { + Clustered = true; + } + } + + var + URLsMustBeSpecifiedErr: label 'You must specify the URL to the folder that contains documents to be imported and the URL to the folder to which the imported documents will be moved.'; +} + diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/test/ExtensionLogo.png b/Apps/W1/EDocumentConnectors/Microsoft365/test/ExtensionLogo.png new file mode 100644 index 0000000000..4d2c9a626c Binary files /dev/null and b/Apps/W1/EDocumentConnectors/Microsoft365/test/ExtensionLogo.png differ diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/test/app.json b/Apps/W1/EDocumentConnectors/Microsoft365/test/app.json new file mode 100644 index 0000000000..81e13c724c --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/test/app.json @@ -0,0 +1,84 @@ +{ + "id": "44efdf6d-efe4-4af7-9aaa-30df07c0d5a1", + "name": "E-Document Connector - Microsoft 365 Tests", + "publisher": "Microsoft", + "brief": "E-Document Connector - Microsoft 365 Tests", + "description": "E-Document Connector - Microsoft 365 Tests", + "version": "26.0.0.0", + "privacyStatement": "https://go.microsoft.com/fwlink/?LinkId=724009", + "EULA": "https://go.microsoft.com/fwlink/?linkid=2009120", + "help": "https://go.microsoft.com/fwlink/?linkid=2204541", + "url": "https://go.microsoft.com/fwlink/?LinkId=724011", + "logo": "ExtensionLogo.png", + "contextSensitiveHelpUrl": "https://go.microsoft.com/fwlink/?linkid=2206603", + "dependencies": [ + { + "id": "e1d97edc-c239-46b4-8d84-6368bdf67c8b", + "name": "E-Document Core", + "publisher": "Microsoft", + "version": "26.0.0.0" + }, + { + "id": "ec6b3b0e-f983-408b-8476-bafb4368ecbc", + "name": "E-Document Connector - Microsoft 365", + "publisher": "Microsoft", + "version": "26.0.0.0" + }, + { + "id": "d852a468-263e-49e5-bfda-f09e33342b89", + "name": "E-Documents Connector with External Endpoints", + "publisher": "Microsoft", + "version": "26.0.0.0" + }, + { + "id": "e1d97edc-c239-46b4-8d84-6368bdf67c8c", + "name": "E-Document Core Tests", + "publisher": "Microsoft", + "version": "26.0.0.0" + }, + { + "id": "5d86850b-0d76-4eca-bd7b-951ad998e997", + "name": "Tests-TestLibraries", + "publisher": "Microsoft", + "version": "26.0.0.0" + }, + { + "id": "9856ae4f-d1a7-46ef-89bb-6ef056398228", + "name": "System Application Test Library", + "publisher": "Microsoft", + "version": "26.0.0.0" + }, + { + "id": "5095f467-0a01-4b99-99d1-9ff1237d286f", + "publisher": "Microsoft", + "name": "Library Variable Storage", + "version": "26.0.0.0" + }, + { + "id": "40860557-a18d-42ad-aecb-22b7dd80dc80", + "name": "Permissions Mock", + "publisher": "Microsoft", + "version": "26.0.0.0" + } + ], + "screenshots": [ + + ], + "platform": "26.0.0.0", + "idRanges": [ + { + "from": 148195, + "to": 148196 + } + ], + "resourceExposurePolicy": { + "allowDebugging": true, + "allowDownloadingSource": true, + "includeSourceInSymbolFile": true + }, + "application": "26.0.0.0", + "target": "OnPrem", + "features": [ + "TranslationFile" + ] +} \ No newline at end of file diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/test/src/M365IntTestImpl.Codeunit.al b/Apps/W1/EDocumentConnectors/Microsoft365/test/src/M365IntTestImpl.Codeunit.al new file mode 100644 index 0000000000..6ecac7106c --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/test/src/M365IntTestImpl.Codeunit.al @@ -0,0 +1,59 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.EServices.EDocumentConnector.Microsoft365; + +using System.Utilities; +using Microsoft.EServices.EDocument; +using Microsoft.eServices.EDocument.Integration.Interfaces; +using Microsoft.eServices.EDocument.Integration.Receive; +using Microsoft.eServices.EDocument.Integration.Send; + +codeunit 148195 "M365 Int. Test Impl." implements IDocumentReceiver, IDocumentSender, IReceivedDocumentMarker +{ + Access = Internal; + + procedure Send(var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service"; SendContext: Codeunit SendContext) + begin + Error(SendNotSupportedErr); + end; + + procedure ReceiveDocuments(var EDocumentService: Record "E-Document Service"; Documents: Codeunit "Temp Blob List"; ReceiveContext: Codeunit ReceiveContext) + begin + OneDriveSharepointInt.ReceiveDocuments(EDocumentService, Documents, ReceiveContext); + end; + + procedure DownloadDocument(var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service"; DocumentMetadataBlob: Codeunit "Temp Blob"; ReceiveContext: Codeunit ReceiveContext) + begin + OneDriveSharepointInt.DownloadDocument(EDocument, EDocumentService, DocumentMetadataBlob, ReceiveContext); + end; + + procedure MarkFetched(var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service"; var DocumentBlob: Codeunit "Temp Blob"; ReceiveContext: Codeunit ReceiveContext) + var + Assert: Codeunit Assert; + begin + Assert.AreNotEqual(EDocument."Document Id", '', 'Document Id must have a value when MarkFetched is called'); + end; + + [EventSubscriber(ObjectType::Page, Page::"E-Document Service", OnBeforeOpenServiceIntegrationSetupPage, '', false, false)] + local procedure OnBeforeOpenServiceIntegrationSetupPage(EDocumentService: Record "E-Document Service"; var IsServiceIntegrationSetupRun: Boolean) + var + OneDriveSetup: Page "OneDrive Setup"; + SharepointSetup: Page "Sharepoint Setup"; + begin + if EDocumentService."Service Integration V2" <> EDocumentService."Service Integration V2"::TestOneDrive then begin + OneDriveSetup.RunModal(); + IsServiceIntegrationSetupRun := true; + end; + + if EDocumentService."Service Integration V2" <> EDocumentService."Service Integration V2"::TestSharepoint then begin + SharepointSetup.RunModal(); + IsServiceIntegrationSetupRun := true; + end; + end; + + var + OneDriveSharepointInt: Codeunit "OneDrive Sharepoint Int."; + SendNotSupportedErr: label 'Sending document is not supported in this context.'; +} \ No newline at end of file diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/test/src/M365IntegrationTest.EnumExt.al b/Apps/W1/EDocumentConnectors/Microsoft365/test/src/M365IntegrationTest.EnumExt.al new file mode 100644 index 0000000000..f94370f71e --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/test/src/M365IntegrationTest.EnumExt.al @@ -0,0 +1,20 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.EServices.EDocumentConnector.Microsoft365; + +using Microsoft.eServices.EDocument.Integration; +using Microsoft.eServices.EDocument.Integration.Interfaces; + +enumextension 148195 "M365 Integration Test" extends "Service Integration" +{ + value(148195; "TestOneDrive") + { + Implementation = IDocumentSender = "M365 Int. Test Impl.", IDocumentReceiver = "M365 Int. Test Impl."; + } + value(148196; "TestSharepoint") + { + Implementation = IDocumentSender = "M365 Int. Test Impl.", IDocumentReceiver = "M365 Int. Test Impl."; + } +} \ No newline at end of file diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/test/src/OneDriveSharepointInt.Codeunit.al b/Apps/W1/EDocumentConnectors/Microsoft365/test/src/OneDriveSharepointInt.Codeunit.al new file mode 100644 index 0000000000..e206873bcb --- /dev/null +++ b/Apps/W1/EDocumentConnectors/Microsoft365/test/src/OneDriveSharepointInt.Codeunit.al @@ -0,0 +1,530 @@ +namespace Microsoft.EServices.EDocumentConnector.Microsoft365; + +using Microsoft.eServices.EDocument; +using Microsoft.eServices.EDocument.Integration.Receive; +using System.Utilities; +using Microsoft.eServices.EDocument.Integration; + +codeunit 148196 "OneDrive Sharepoint Int." +{ + Subtype = Test; + TestPermissions = Disabled; + + trigger OnRun() + begin + // [FEATURE] [Bookkeeping Assistance] E-Document connector for OneDrive and Sharepoint + end; + + [Test] + [Scope('OnPrem')] + procedure ReceiveSingleIncomingDocumentOneDrive() + var + EDocument: Record "E-Document"; + EDocumentLog: Record "E-Document Log"; + EDocDataStorage: Record "E-Doc. Data Storage"; + EDocumentService: Record "E-Document Service"; + EDocIntegrationManagement: Codeunit "E-Doc. Integration Management"; + ReceiveContext: Codeunit ReceiveContext; + InitialIncomingDocumentCount: Integer; + TestInStream: InStream; + EDocDataStorageContentTxt: Text; + begin + // [SCENARIO 540009] When using Receive Document functionality, and there is one document available in the specified OneDrive folder, one e-document is correctly created with attachment and name + + // [GIVEN] A setup for importing OneDrive documents as e-documents + // [GIVEN] That one document is available (in test, this is determined by description TestImportOneDocumentTxt) + Initialize(EDocumentService, Enum::"Service Integration"::TestOneDrive, TestImportOneDocumentTxt); + InitialIncomingDocumentCount := EDocument.Count(); + + // [WHEN] ReceiveDocument method is called (either from UI or from scheduled task) + EDocIntegrationManagement.ReceiveDocuments(EDocumentService, ReceiveContext); + + // [THEN] One new e-document is created with correct name and attachment + Assert.AreEqual(InitialIncomingDocumentCount + 1, EDocument.Count(), ''); + EDocument.SetRange("File Id", 'Propsoal.pdf'); + Assert.IsTrue(EDocument.FindFirst(), ''); + EDocumentLog.SetRange("E-Doc. Entry No", EDocument."Entry No"); + Assert.IsTrue(EDocumentLog.FindFirst(), ''); + Assert.IsTrue(EDocDataStorage.Get(EDocumentLog."E-Doc. Data Storage Entry No."), ''); + EDocDataStorage.CalcFields("Data Storage"); + EDocDataStorage."Data Storage".CreateInStream(TestInStream); + TestInStream.ReadText(EDocDataStorageContentTxt); + Assert.AreEqual('1', EDocDataStorageContentTxt, ''); + end; + + [Test] + [Scope('OnPrem')] + procedure ReceiveOnlyPdfDocumentOneDrive() + var + EDocument: Record "E-Document"; + EDocumentLog: Record "E-Document Log"; + EDocDataStorage: Record "E-Doc. Data Storage"; + EDocumentService: Record "E-Document Service"; + EDocIntegrationManagement: Codeunit "E-Doc. Integration Management"; + ReceiveContext: Codeunit ReceiveContext; + InitialIncomingDocumentCount: Integer; + TestInStream: InStream; + EDocDataStorageContentTxt: Text; + begin + // [SCENARIO 540009] When using Receive Document functionality, and there are two documents available in the specified OneDrive folder, one e-document is not a PDF + + // [GIVEN] A setup for importing OneDrive documents as e-documents + // [GIVEN] That one document is downloaded (in test, this is determined by description TestImportOnlyPdfDocumentsTxt) + Initialize(EDocumentService, Enum::"Service Integration"::TestOneDrive, TestImportOnlyPdfDocumentsTxt); + InitialIncomingDocumentCount := EDocument.Count(); + + // [WHEN] ReceiveDocument method is called (either from UI or from scheduled task) + EDocIntegrationManagement.ReceiveDocuments(EDocumentService, ReceiveContext); + + // [THEN] One new e-document is created with correct name and attachment + Assert.AreEqual(InitialIncomingDocumentCount + 1, EDocument.Count(), ''); + EDocument.SetRange("File Id", 'DoImport.pdf'); + Assert.IsTrue(EDocument.FindFirst(), ''); + EDocumentLog.SetRange("E-Doc. Entry No", EDocument."Entry No"); + Assert.IsTrue(EDocumentLog.FindFirst(), ''); + Assert.IsTrue(EDocDataStorage.Get(EDocumentLog."E-Doc. Data Storage Entry No."), ''); + EDocDataStorage.CalcFields("Data Storage"); + EDocDataStorage."Data Storage".CreateInStream(TestInStream); + TestInStream.ReadText(EDocDataStorageContentTxt); + Assert.AreEqual('1', EDocDataStorageContentTxt, ''); + end; + + [Test] + [Scope('OnPrem')] + procedure ReceiveOnlyPdfDocumentSharepoint() + var + EDocument: Record "E-Document"; + EDocumentLog: Record "E-Document Log"; + EDocDataStorage: Record "E-Doc. Data Storage"; + EDocumentService: Record "E-Document Service"; + EDocIntegrationManagement: Codeunit "E-Doc. Integration Management"; + ReceiveContext: Codeunit ReceiveContext; + InitialIncomingDocumentCount: Integer; + TestInStream: InStream; + EDocDataStorageContentTxt: Text; + begin + // [SCENARIO 540009] When using Receive Document functionality, and there are two documents available in the specified Sharepoint folder, one e-document is not a PDF + + // [GIVEN] A setup for importing Sharepoint documents as e-documents + // [GIVEN] That one document is downloaded (in test, this is determined by description TestImportOnlyPdfDocumentsTxt) + Initialize(EDocumentService, Enum::"Service Integration"::TestSharepoint, TestImportOnlyPdfDocumentsTxt); + InitialIncomingDocumentCount := EDocument.Count(); + + // [WHEN] ReceiveDocument method is called (either from UI or from scheduled task) + EDocIntegrationManagement.ReceiveDocuments(EDocumentService, ReceiveContext); + + // [THEN] One new e-document is created with correct name and attachment + Assert.AreEqual(InitialIncomingDocumentCount + 1, EDocument.Count(), ''); + EDocument.SetRange("File Id", 'DoImport.pdf'); + Assert.IsTrue(EDocument.FindFirst(), ''); + EDocumentLog.SetRange("E-Doc. Entry No", EDocument."Entry No"); + Assert.IsTrue(EDocumentLog.FindFirst(), ''); + Assert.IsTrue(EDocDataStorage.Get(EDocumentLog."E-Doc. Data Storage Entry No."), ''); + EDocDataStorage.CalcFields("Data Storage"); + EDocDataStorage."Data Storage".CreateInStream(TestInStream); + TestInStream.ReadText(EDocDataStorageContentTxt); + Assert.AreEqual('1', EDocDataStorageContentTxt, ''); + end; + + [Test] + [Scope('OnPrem')] + procedure DontDownloadMalwareOneDrive() + var + EDocument: Record "E-Document"; + EDocumentLog: Record "E-Document Log"; + EDocDataStorage: Record "E-Doc. Data Storage"; + EDocumentService: Record "E-Document Service"; + EDocIntegrationManagement: Codeunit "E-Doc. Integration Management"; + ReceiveContext: Codeunit ReceiveContext; + InitialIncomingDocumentCount: Integer; + TestInStream: InStream; + EDocDataStorageContentTxt: Text; + begin + // [SCENARIO 540009] When using Receive Document functionality, and there are two documents available in the specified OneDrive folder, one e-document is marked as malware + + // [GIVEN] A setup for importing OneDrive documents as e-documents + // [GIVEN] That one document is downloaded (in test, this is determined by description TestDontImportMalwareTxt) + Initialize(EDocumentService, Enum::"Service Integration"::TestOneDrive, TestDontImportMalwareTxt); + InitialIncomingDocumentCount := EDocument.Count(); + + // [WHEN] ReceiveDocument method is called (either from UI or from scheduled task) + EDocIntegrationManagement.ReceiveDocuments(EDocumentService, ReceiveContext); + + // [THEN] One new e-document is created with correct name and attachment + Assert.AreEqual(InitialIncomingDocumentCount + 1, EDocument.Count(), ''); + EDocument.SetRange("File Id", 'DoImport.pdf'); + Assert.IsTrue(EDocument.FindFirst(), ''); + EDocumentLog.SetRange("E-Doc. Entry No", EDocument."Entry No"); + Assert.IsTrue(EDocumentLog.FindFirst(), ''); + Assert.IsTrue(EDocDataStorage.Get(EDocumentLog."E-Doc. Data Storage Entry No."), ''); + EDocDataStorage.CalcFields("Data Storage"); + EDocDataStorage."Data Storage".CreateInStream(TestInStream); + TestInStream.ReadText(EDocDataStorageContentTxt); + Assert.AreEqual('1', EDocDataStorageContentTxt, ''); + end; + + [Test] + [Scope('OnPrem')] + procedure DontDownloadMalwareSharepoint() + var + EDocument: Record "E-Document"; + EDocumentLog: Record "E-Document Log"; + EDocDataStorage: Record "E-Doc. Data Storage"; + EDocumentService: Record "E-Document Service"; + EDocIntegrationManagement: Codeunit "E-Doc. Integration Management"; + ReceiveContext: Codeunit ReceiveContext; + InitialIncomingDocumentCount: Integer; + TestInStream: InStream; + EDocDataStorageContentTxt: Text; + begin + // [SCENARIO 540009] When using Receive Document functionality, and there are two documents available in the specified Sharepoint folder, one e-document is marked as malware + + // [GIVEN] A setup for importing Sharepoint documents as e-documents + // [GIVEN] That one document is downloaded (in test, this is determined by description TestDontImportMalwareTxt) + Initialize(EDocumentService, Enum::"Service Integration"::TestSharepoint, TestDontImportMalwareTxt); + InitialIncomingDocumentCount := EDocument.Count(); + + // [WHEN] ReceiveDocument method is called (either from UI or from scheduled task) + EDocIntegrationManagement.ReceiveDocuments(EDocumentService, ReceiveContext); + + // [THEN] One new e-document is created with correct name and attachment + Assert.AreEqual(InitialIncomingDocumentCount + 1, EDocument.Count(), ''); + EDocument.SetRange("File Id", 'DoImport.pdf'); + Assert.IsTrue(EDocument.FindFirst(), ''); + EDocumentLog.SetRange("E-Doc. Entry No", EDocument."Entry No"); + Assert.IsTrue(EDocumentLog.FindFirst(), ''); + Assert.IsTrue(EDocDataStorage.Get(EDocumentLog."E-Doc. Data Storage Entry No."), ''); + EDocDataStorage.CalcFields("Data Storage"); + EDocDataStorage."Data Storage".CreateInStream(TestInStream); + TestInStream.ReadText(EDocDataStorageContentTxt); + Assert.AreEqual('1', EDocDataStorageContentTxt, ''); + end; + + [Test] + [Scope('OnPrem')] + procedure ReceiveSingleIncomingDocumentSharepoint() + var + EDocument: Record "E-Document"; + EDocumentLog: Record "E-Document Log"; + EDocDataStorage: Record "E-Doc. Data Storage"; + EDocumentService: Record "E-Document Service"; + EDocIntegrationManagement: Codeunit "E-Doc. Integration Management"; + ReceiveContext: Codeunit ReceiveContext; + InitialIncomingDocumentCount: Integer; + TestInStream: InStream; + EDocDataStorageContentTxt: Text; + begin + // [SCENARIO 540009] When using Receive Document functionality, and there is one document available in the specified Sharepoint folder, one e-document is correctly created with attachment and name + + // [GIVEN] A setup for importing Sharepoint documents as e-documents + // [GIVEN] That one document is available (in test, this is determined by description TestImportOneDocumentTxt) + Initialize(EDocumentService, Enum::"Service Integration"::TestSharepoint, TestImportOneDocumentTxt); + InitialIncomingDocumentCount := EDocument.Count(); + + // [WHEN] ReceiveDocument method is called (either from UI or from scheduled task) + EDocIntegrationManagement.ReceiveDocuments(EDocumentService, ReceiveContext); + + // [THEN] One new e-document is created with correct name and attachment + Assert.AreEqual(InitialIncomingDocumentCount + 1, EDocument.Count(), ''); + EDocument.SetRange("File Id", 'Propsoal.pdf'); + Assert.IsTrue(EDocument.FindFirst(), ''); + EDocumentLog.SetRange("E-Doc. Entry No", EDocument."Entry No"); + Assert.IsTrue(EDocumentLog.FindFirst(), ''); + Assert.IsTrue(EDocDataStorage.Get(EDocumentLog."E-Doc. Data Storage Entry No."), ''); + EDocDataStorage.CalcFields("Data Storage"); + EDocDataStorage."Data Storage".CreateInStream(TestInStream); + TestInStream.ReadText(EDocDataStorageContentTxt); + Assert.AreEqual('1', EDocDataStorageContentTxt, ''); + end; + + [Test] + [Scope('OnPrem')] + procedure ReceiveMultipleIncomingDocumentOneDrive() + var + EDocument: Record "E-Document"; + EDocumentLog: Record "E-Document Log"; + EDocDataStorage: Record "E-Doc. Data Storage"; + EDocumentService: Record "E-Document Service"; + EDocIntegrationManagement: Codeunit "E-Doc. Integration Management"; + ReceiveContext: Codeunit ReceiveContext; + InitialIncomingDocumentCount: Integer; + TestInStream: InStream; + EDocDataStorageContentTxt: Text; + begin + // [SCENARIO 540009] When using Receive Document functionality, and there are multiple documents available in the specified OneDrive folder, one e-document is correctly created with attachment and name + + // [GIVEN] A setup for importing OneDrive documents as e-documents + // [GIVEN] That multiple documents are available (in test, this is determined by description TestImportTwoDocumentsTxt) + Initialize(EDocumentService, Enum::"Service Integration"::TestOneDrive, TestImportTwoDocumentsTxt); + InitialIncomingDocumentCount := EDocument.Count(); + + // [WHEN] ReceiveDocument method is called (either from UI or from scheduled task) + EDocIntegrationManagement.ReceiveDocuments(EDocumentService, ReceiveContext); + + // [THEN] Two new e-documents are created with correct name and attachment + Assert.AreEqual(InitialIncomingDocumentCount + 2, EDocument.Count(), ''); + EDocument.SetRange("File Id", 'Propsoal.pdf'); + Assert.IsTrue(EDocument.FindFirst(), ''); + EDocumentLog.SetRange("E-Doc. Entry No", EDocument."Entry No"); + Assert.IsTrue(EDocumentLog.FindFirst(), ''); + Assert.IsTrue(EDocDataStorage.Get(EDocumentLog."E-Doc. Data Storage Entry No."), ''); + EDocDataStorage.CalcFields("Data Storage"); + EDocDataStorage."Data Storage".CreateInStream(TestInStream); + TestInStream.ReadText(EDocDataStorageContentTxt); + Assert.AreEqual('1', EDocDataStorageContentTxt, ''); + Clear(TestInStream); + EDocument.SetRange("File Id", 'AnotherProposal.pdf'); + Assert.IsTrue(EDocument.FindFirst(), ''); + EDocumentLog.SetRange("E-Doc. Entry No", EDocument."Entry No"); + Assert.IsTrue(EDocumentLog.FindFirst(), ''); + Assert.IsTrue(EDocDataStorage.Get(EDocumentLog."E-Doc. Data Storage Entry No."), ''); + EDocDataStorage.CalcFields("Data Storage"); + EDocDataStorage."Data Storage".CreateInStream(TestInStream); + TestInStream.ReadText(EDocDataStorageContentTxt); + Assert.AreEqual('2', EDocDataStorageContentTxt, ''); + end; + + [Test] + [Scope('OnPrem')] + procedure ReceiveMultipleIncomingDocumentSharepoint() + var + EDocument: Record "E-Document"; + EDocumentLog: Record "E-Document Log"; + EDocDataStorage: Record "E-Doc. Data Storage"; + EDocumentService: Record "E-Document Service"; + EDocIntegrationManagement: Codeunit "E-Doc. Integration Management"; + ReceiveContext: Codeunit ReceiveContext; + InitialIncomingDocumentCount: Integer; + TestInStream: InStream; + EDocDataStorageContentTxt: Text; + begin + // [SCENARIO 540009] When using Receive Document functionality, and there are multiple documents available in the specified Sharepoint folder, one e-document is correctly created with attachment and name + + // [GIVEN] A setup for importing Sharepoint documents as e-documents + // [GIVEN] That multiple documents are available (in test, this is determined by description TestImportTwoDocumentsTxt) + Initialize(EDocumentService, Enum::"Service Integration"::TestSharepoint, TestImportTwoDocumentsTxt); + InitialIncomingDocumentCount := EDocument.Count(); + + // [WHEN] ReceiveDocument method is called (either from UI or from scheduled task) + EDocIntegrationManagement.ReceiveDocuments(EDocumentService, ReceiveContext); + + // [THEN] Two new e-documents are created with correct name and attachment + Assert.AreEqual(InitialIncomingDocumentCount + 2, EDocument.Count(), ''); + EDocument.SetRange("File Id", 'Propsoal.pdf'); + Assert.IsTrue(EDocument.FindFirst(), ''); + EDocumentLog.SetRange("E-Doc. Entry No", EDocument."Entry No"); + Assert.IsTrue(EDocumentLog.FindFirst(), ''); + Assert.IsTrue(EDocDataStorage.Get(EDocumentLog."E-Doc. Data Storage Entry No."), ''); + EDocDataStorage.CalcFields("Data Storage"); + EDocDataStorage."Data Storage".CreateInStream(TestInStream); + TestInStream.ReadText(EDocDataStorageContentTxt); + Assert.AreEqual('1', EDocDataStorageContentTxt, ''); + Clear(TestInStream); + EDocument.SetRange("File Id", 'AnotherProposal.pdf'); + Assert.IsTrue(EDocument.FindFirst(), ''); + EDocumentLog.SetRange("E-Doc. Entry No", EDocument."Entry No"); + Assert.IsTrue(EDocumentLog.FindFirst(), ''); + Assert.IsTrue(EDocDataStorage.Get(EDocumentLog."E-Doc. Data Storage Entry No."), ''); + EDocDataStorage.CalcFields("Data Storage"); + EDocDataStorage."Data Storage".CreateInStream(TestInStream); + TestInStream.ReadText(EDocDataStorageContentTxt); + Assert.AreEqual('2', EDocDataStorageContentTxt, ''); + end; + + [Test] + [Scope('OnPrem')] + procedure ReceiveNoIncomingDocumentOneDrive() + var + EDocument: Record "E-Document"; + EDocumentService: Record "E-Document Service"; + EDocIntegrationManagement: Codeunit "E-Doc. Integration Management"; + ReceiveContext: Codeunit ReceiveContext; + InitialIncomingDocumentCount: Integer; + begin + // [SCENARIO 540009] When using Receive Document functionality, and there are no documents available in the specified OneDrive folder, one e-document is correctly created with attachment and name + + // [GIVEN] A setup for importing OneDrive documents as e-documents + // [GIVEN] That no document is available (in test, this is determined by description TestImportNoDocumentsTxt) + Initialize(EDocumentService, Enum::"Service Integration"::TestOneDrive, TestImportNoDocumentsTxt); + InitialIncomingDocumentCount := EDocument.Count(); + + // [WHEN] ReceiveDocument method is called (either from UI or from scheduled task) + EDocIntegrationManagement.ReceiveDocuments(EDocumentService, ReceiveContext); + + // [THEN] No new e-documents are created + Assert.AreEqual(InitialIncomingDocumentCount, EDocument.Count(), ''); + end; + + [Test] + [Scope('OnPrem')] + procedure ReceiveNoIncomingDocumentSharepoint() + var + EDocument: Record "E-Document"; + EDocumentService: Record "E-Document Service"; + EDocIntegrationManagement: Codeunit "E-Doc. Integration Management"; + ReceiveContext: Codeunit ReceiveContext; + InitialIncomingDocumentCount: Integer; + begin + // [SCENARIO 540009] When using Receive Document functionality, and there are no documents available in the specified Sharepoint folder, one e-document is correctly created with attachment and name + + // [GIVEN] A setup for importing Sharepoint documents as e-documents + // [GIVEN] That no document is available (in test, this is determined by description TestImportNoDocumentsTxt) + Initialize(EDocumentService, Enum::"Service Integration"::TestSharepoint, TestImportNoDocumentsTxt); + InitialIncomingDocumentCount := EDocument.Count(); + + // [WHEN] ReceiveDocument method is called (either from UI or from scheduled task) + EDocIntegrationManagement.ReceiveDocuments(EDocumentService, ReceiveContext); + + // [THEN] No new e-documents are created + Assert.AreEqual(InitialIncomingDocumentCount, EDocument.Count(), ''); + end; + + [Test] + [Scope('OnPrem')] + procedure ReceiveSingleIncomingDocumentNoExtensionOneDrive() + var + EDocument: Record "E-Document"; + EDocumentLog: Record "E-Document Log"; + EDocDataStorage: Record "E-Doc. Data Storage"; + EDocumentService: Record "E-Document Service"; + EDocIntegrationManagement: Codeunit "E-Doc. Integration Management"; + ReceiveContext: Codeunit ReceiveContext; + InitialIncomingDocumentCount: Integer; + TestInStream: InStream; + EDocDataStorageContentTxt: Text; + begin + // [SCENARIO 540009] When using Receive Document functionality, and there is one document available in the specified OneDrive folder, one e-document is correctly created with attachment and name + + // [GIVEN] A setup for importing OneDrive documents as e-documents + // [GIVEN] That one document is available (in test, this is determined by description TestImportOneDocumentNoExtTxt) + Initialize(EDocumentService, Enum::"Service Integration"::TestOneDrive, TestImportOneDocumentNoExtTxt); + InitialIncomingDocumentCount := EDocument.Count(); + + // [WHEN] ReceiveDocument method is called (either from UI or from scheduled task) + EDocIntegrationManagement.ReceiveDocuments(EDocumentService, ReceiveContext); + + // [THEN] One new e-document is created with correct name and attachment + Assert.AreEqual(InitialIncomingDocumentCount + 1, EDocument.Count(), ''); + EDocument.SetRange("File Id", 'Propsoal'); + Assert.IsTrue(EDocument.FindFirst(), ''); + EDocumentLog.SetRange("E-Doc. Entry No", EDocument."Entry No"); + Assert.IsTrue(EDocumentLog.FindFirst(), ''); + Assert.IsTrue(EDocDataStorage.Get(EDocumentLog."E-Doc. Data Storage Entry No."), ''); + EDocDataStorage.CalcFields("Data Storage"); + EDocDataStorage."Data Storage".CreateInStream(TestInStream); + TestInStream.ReadText(EDocDataStorageContentTxt); + Assert.AreEqual('1', EDocDataStorageContentTxt, ''); + end; + + [Test] + [Scope('OnPrem')] + procedure ReceiveSingleIncomingDocumentNoExtensionSharepoint() + var + EDocument: Record "E-Document"; + EDocumentLog: Record "E-Document Log"; + EDocDataStorage: Record "E-Doc. Data Storage"; + EDocumentService: Record "E-Document Service"; + EDocIntegrationManagement: Codeunit "E-Doc. Integration Management"; + ReceiveContext: Codeunit ReceiveContext; + InitialIncomingDocumentCount: Integer; + TestInStream: InStream; + EDocDataStorageContentTxt: Text; + begin + // [SCENARIO 540009] When using Receive Document functionality, and there is one document available in the specified Sharepoint folder, one e-document is correctly created with attachment and name + + // [GIVEN] A setup for importing Sharepoint documents as e-documents + // [GIVEN] That one document is available (in test, this is determined by description TestImportOneDocumentNoExtTxt) + Initialize(EDocumentService, Enum::"Service Integration"::TestSharepoint, TestImportOneDocumentNoExtTxt); + InitialIncomingDocumentCount := EDocument.Count(); + + // [WHEN] ReceiveDocument method is called (either from UI or from scheduled task) + EDocIntegrationManagement.ReceiveDocuments(EDocumentService, ReceiveContext); + + // [THEN] One new e-document is created with correct name and attachment + Assert.AreEqual(InitialIncomingDocumentCount + 1, EDocument.Count(), ''); + EDocument.SetRange("File Id", 'Propsoal'); + Assert.IsTrue(EDocument.FindFirst(), ''); + EDocumentLog.SetRange("E-Doc. Entry No", EDocument."Entry No"); + Assert.IsTrue(EDocumentLog.FindFirst(), ''); + Assert.IsTrue(EDocDataStorage.Get(EDocumentLog."E-Doc. Data Storage Entry No."), ''); + EDocDataStorage.CalcFields("Data Storage"); + EDocDataStorage."Data Storage".CreateInStream(TestInStream); + TestInStream.ReadText(EDocDataStorageContentTxt); + Assert.AreEqual('1', EDocDataStorageContentTxt, ''); + end; + + local procedure Initialize(var EDocumentService: Record "E-Document Service"; ServiceIntegration: Enum "Service Integration"; ServiceDescription: Text) + var + SharepointSetup: Record "Sharepoint Setup"; + OneDriveSetup: Record "OneDrive Setup"; + begin + SharepointSetup.DeleteAll(); + OneDriveSetup.DeleteAll(); + EDocumentService.DeleteAll(true); + + EDocumentService.Code := CopyStr(ServiceDescription, 1, MaxStrLen(EDocumentService.Code)); + EDocumentService."Service Integration V2" := ServiceIntegration; + EDocumentService.Description := CopyStr(ServiceDescription, 1, MaxStrLen(EDocumentService.Description)); + EDocumentService.Insert(); + + SharepointSetup."Documents Folder" := 'test'; + SharepointSetup."Imp. Documents Folder" := 'test'; + SharepointSetup.Enabled := true; + SharepointSetup.Insert(); + + OneDriveSetup."Documents Folder" := 'test'; + OneDriveSetup."Imp. Documents Folder" := 'test'; + OneDriveSetup.Enabled := true; + OneDriveSetup.Insert(); + end; + + internal procedure DownloadDocument(var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service"; DocumentMetadataBlob: Codeunit "Temp Blob"; ReceiveContext: Codeunit ReceiveContext) + var + DriveProcessing: Codeunit "Drive Processing"; + DocumentId, FileId : Text; + LocalOutStream: OutStream; + begin + DriveProcessing.ExtractItemIdAndName(DocumentMetadataBlob, DocumentId, FileId); + + ReceiveContext.GetTempBlob().CreateOutStream(LocalOutStream, TextEncoding::UTF8); + LocalOutStream.WriteText(Format(EDocument."Index In Batch")); + + DriveProcessing.UpdateEDocumentAfterDocumentDownload(EDocument, DocumentId, FileId); + DriveProcessing.UpdateReceiveContextAfterDocumentDownload(ReceiveContext); + end; + + internal procedure ReceiveDocuments(var EDocumentService: Record "E-Document Service"; Documents: Codeunit "Temp Blob List"; ReceiveContext: Codeunit ReceiveContext) + var + DriveProcessing: Codeunit "Drive Processing"; + Mock: JSonObject; + + begin + case EDocumentService.Description of + TestImportOneDocumentTxt: + Mock.ReadFrom('{ "id": "9FFFDB3C-5B87-4062-9606-1B008CA88E44", "name": "Contoso Project", "eTag": "2246BD2D-7811-4660-BD0F-1CF36133677B,1", "folder": {}, "size": 10911212, "value": [ { "id": "AFBBDD79-868E-452D-AD4D-24697D4A4044", "name": "Propsoal.pdf", "file": { "mimeType": "application/pdf" }, "size": 19001 } ] }'); + TestImportOneDocumentNoExtTxt: + Mock.ReadFrom('{ "id": "9FFFDB3C-5B87-4062-9606-1B008CA88E44", "name": "Contoso Project", "eTag": "2246BD2D-7811-4660-BD0F-1CF36133677B,1", "folder": {}, "size": 10911212, "value": [ { "id": "AFBBDD79-868E-452D-AD4D-24697D4A4044", "name": "Propsoal", "file": { "mimeType": "application/pdf" }, "size": 19001 } ] }'); + TestImportTwoDocumentsTxt: + Mock.ReadFrom('{ "id": "9FFFDB3C-5B87-4062-9606-1B008CA88E44", "name": "Contoso Project", "eTag": "2246BD2D-7811-4660-BD0F-1CF36133677B,1", "folder": {}, "size": 10911212, "value": [ { "id": "AFBBDD79-868E-452D-AD4D-24697D4A4044", "name": "Propsoal.pdf", "file": { "mimeType": "application/pdf" }, "size": 19001 }, { "id": "A91FE90A-2F2C-4EE6-B412-C4FFBA3F71A6", "name": "AnotherProposal.pdf", "file": { "mimeType": "application/pdf" }, "size": 91001 } ] }'); + TestImportNoDocumentsTxt: + Mock.ReadFrom('{ "id": "9FFFDB3C-5B87-4062-9606-1B008CA88E44", "name": "Contoso Project", "eTag": "2246BD2D-7811-4660-BD0F-1CF36133677B,1", "folder": {}, "size": 10911212, "value": [ ] }'); + TestImportOnlyPdfDocumentsTxt: + Mock.ReadFrom('{ "id": "9FFFDB3C-5B87-4062-9606-1B008CA88E44", "name": "Contoso Project", "eTag": "2246BD2D-7811-4660-BD0F-1CF36133677B,1", "folder": {}, "size": 10911212, "value": [ { "id": "AFBBDD79-868E-452D-AD4D-24697D4A4044", "name": "DoImport.pdf", "file": { "mimeType": "application/pdf" }, "size": 19001 }, { "id": "A91FE90A-2F2C-4EE6-B412-C4FFBA3F71A6", "name": "MeeTooIDontThinkSo.txt", "file": { "mimeType": "application/txt" }, "size": 91001 } ] }'); + TestDontImportMalwareTxt: + Mock.ReadFrom('{ "id": "9FFFDB3C-5B87-4062-9606-1B008CA88E44", "name": "Contoso Project", "eTag": "2246BD2D-7811-4660-BD0F-1CF36133677B,1", "folder": {}, "size": 10911212, "value": [ { "id": "AFBBDD79-868E-452D-AD4D-24697D4A4044", "name": "DoImport.pdf", "file": { "mimeType": "application/pdf" }, "size": 19001 }, { "id": "A91FE90A-2F2C-4EE6-B412-C4FFBA3F71A6", "name": "MeeTooIDontThinkSo.pdf", "malware": { "description": "Ransom Wanted" }, "file": { "mimeType": "application/pdf" }, "size": 91001 } ] }'); + end; + DriveProcessing.AddToDocumentsList(Documents, Mock); + DriveProcessing.AddToReceiveContext(ReceiveContext, Mock); + end; + + var + Assert: Codeunit Assert; + TestImportOneDocumentTxt: label 'TestImportOneDocument', Locked = true; + TestImportTwoDocumentsTxt: label 'TestImportTwoDocuments', Locked = true; + TestImportNoDocumentsTxt: label 'TestImportNoDocuments', Locked = true; + TestImportOneDocumentNoExtTxt: label 'TestImportOneDocumentNoExt', Locked = true; + TestImportOnlyPdfDocumentsTxt: label 'TestImportOnlyPdfDocuments', Locked = true; + TestDontImportMalwareTxt: label 'TestDontImportMalware', Locked = true; + +} + diff --git a/Apps/W1/Email - Microsoft 365 Connector/app/src/Microsoft365Connector.Codeunit.al b/Apps/W1/Email - Microsoft 365 Connector/app/src/Microsoft365Connector.Codeunit.al index 4277a070db..20f0930e77 100644 --- a/Apps/W1/Email - Microsoft 365 Connector/app/src/Microsoft365Connector.Codeunit.al +++ b/Apps/W1/Email - Microsoft 365 Connector/app/src/Microsoft365Connector.Codeunit.al @@ -5,7 +5,8 @@ namespace System.Email; -codeunit 4503 "Microsoft 365 Connector" implements "Default Email Rate Limit", "Email Connector v2" + +codeunit 4503 "Microsoft 365 Connector" implements "Default Email Rate Limit", "Email Connector v3" { Access = Internal; Permissions = tabledata "Email - Outlook Account" = r; @@ -21,9 +22,9 @@ codeunit 4503 "Microsoft 365 Connector" implements "Default Email Rate Limit", " EmailOutlookAPIHelper.Send(EmailMessage, AccountId); end; - procedure RetrieveEmails(AccountId: Guid; var EmailInbox: Record "Email Inbox") + procedure RetrieveEmails(AccountId: Guid; var EmailInbox: Record "Email Inbox"; var Filters: Record "Email Retrieval Filters" temporary) begin - EmailOutlookAPIHelper.RetrieveEmails(AccountId, true, EmailInbox); + EmailOutlookAPIHelper.RetrieveEmails(AccountId, EmailInbox, Filters); end; procedure Reply(var EmailMessage: Codeunit "Email Message"; AccountId: Guid) diff --git a/Apps/W1/Email - Outlook REST API/app/src/EmailOutlookAPIClient.Codeunit.al b/Apps/W1/Email - Outlook REST API/app/src/EmailOutlookAPIClient.Codeunit.al index d8566d9893..1046caa3cb 100644 --- a/Apps/W1/Email - Outlook REST API/app/src/EmailOutlookAPIClient.Codeunit.al +++ b/Apps/W1/Email - Outlook REST API/app/src/EmailOutlookAPIClient.Codeunit.al @@ -10,9 +10,13 @@ using System.Text; using System.Utilities; #if not CLEAN24 -codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Client", "Email - Outlook API Client v2", "Email - Outlook API Client v3" +codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Client", "Email - Outlook API Client v2", "Email - Outlook API Client v3", "Email - Outlook API Client v4" #else -codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Client v2", "Email - Outlook API Client v3" +#if not CLEAN26 +codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Client v2", "Email - Outlook API Client v3", "Email - Outlook API Client v4" +#else +codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Client v2", "Email - Outlook API Client v4" +#endif #endif { var @@ -39,9 +43,8 @@ codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Clien ExternalSecurityChallengeNotSatisfiedMsg: Label 'Multi-Factor Authentication is enabled on this account but the user did not complete the setup. Please sign in to the account and try again.'; EnvironmentBlocksErr: Label 'The request to send email has been blocked. To resolve the problem, enable outgoing HTTP requests for the Email - Outlook REST API app on the Extension Management page.'; ConnectionErr: Label 'Could not establish the connection to the remote service for sending email. Try again later.'; - RetrieveEmailSelectedFieldsTxt: Label 'id,conversationId,sentDateTime,receivedDateTime,subject,webLink,sender,toRecipients,ccRecipients,body,hasAttachments', Locked = true; + RetrieveEmailSelectedFieldsTxt: Label 'id,conversationId,sentDateTime,receivedDateTime,subject,webLink,sender,toRecipients,ccRecipients,body,hasAttachments,isRead,isDraft', Locked = true; RetrieveEmailsUriTxt: Label '/v1.0/users/%1/messages', Locked = true; - RetrieveEmailsFiltersTxt: Label '?$expand=attachments&$filter=isRead ne true&isDraft ne true&$count=true&$top=%1&$select=%2', Locked = true; RetrieveEmailsMessageErr: Label 'Failed to retrieve emails. Error:\\%1', Comment = '%1 = Error message'; MarkAsReadUriTxt: Label '/v1.0/users/%1/messages/%2', Locked = true; RetrieveEmailUriTxt: Label '/v1.0/users/%1/messages/%2', Locked = true; @@ -192,7 +195,17 @@ codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Clien end; end; +#if not CLEAN26 + [Obsolete('Replaced by RetrieveEmails with an additional parameter for filters.', '26.0')] procedure RetrieveEmails(AccessToken: SecretText; MarkAsRead: Boolean; OutlookAccount: Record "Email - Outlook Account"): JsonArray + var + TempFilters: Record "Email Retrieval Filters" temporary; + begin + exit(RetrieveEmails(AccessToken, OutlookAccount, TempFilters)); + end; +#endif + + procedure RetrieveEmails(AccessToken: SecretText; OutlookAccount: Record "Email - Outlook Account"; var Filters: Record "Email Retrieval Filters" temporary): JsonArray var EmailsObject: JsonObject; EmailsArray: JsonArray; @@ -201,7 +214,7 @@ codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Clien begin Session.LogMessage('0000NCA', TelemetryRetrievingEmailsTxt, Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', OutlookCategoryLbl); - SendRetrieveEmailsRequest(AccessToken, OutlookAccount."Email Address", EmailsObject); + SendRetrieveEmailsRequest(AccessToken, OutlookAccount."Email Address", Filters, EmailsObject); if not EmailsObject.Get('@odata.count', JsonToken) then begin Session.LogMessage('0000NCB', FailedToRetrieveEmailsErr, Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', OutlookCategoryLbl); @@ -227,6 +240,17 @@ codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Clien end; procedure RetrieveEmail(AccessToken: SecretText; EmailAddress: Text[250]; ExternalMessageId: Text; AsHtml: Boolean): JsonObject + var + Filters: Record "Email Retrieval Filters"; + begin + if AsHtml then + Filters."Body Type" := Filters."Body Type"::HTML + else + Filters."Body Type" := Filters."Body Type"::Text; + exit(RetrieveEmail(AccessToken, EmailAddress, ExternalMessageId, Filters)); + end; + + procedure RetrieveEmail(AccessToken: SecretText; EmailAddress: Text[250]; ExternalMessageId: Text; var Filters: Record "Email Retrieval Filters" temporary): JsonObject var MailHttpRequestMessage: HttpRequestMessage; MailHttpResponseMessage: HttpResponseMessage; @@ -240,7 +264,7 @@ codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Clien RequestUri := GraphURLTxt + StrSubstNo(RetrieveEmailUriTxt, EmailAddress, ExternalMessageId); CreateRequest('GET', RequestUri, AccessToken, MailHttpRequestMessage); MailHttpRequestMessage.GetHeaders(MailRequestHeaders); - if not AsHtml then + if Filters."Body Type" = Filters."Body Type"::Text then MailRequestHeaders.Add('Prefer', 'outlook.body-content-type="text"'); SendRequest(MailHttpRequestMessage, MailHttpResponseMessage); @@ -283,7 +307,7 @@ codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Clien Error(ConnectionErr); end; - local procedure SendRetrieveEmailsRequest(AccessToken: SecretText; EmailAddress: Text; var ResponseJsonObject: JsonObject): Boolean + local procedure SendRetrieveEmailsRequest(AccessToken: SecretText; EmailAddress: Text; var Filters: Record "Email Retrieval Filters" temporary; var ResponseJsonObject: JsonObject): Boolean var MailHttpRequestMessage: HttpRequestMessage; MailHttpResponseMessage: HttpResponseMessage; @@ -291,12 +315,43 @@ codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Clien HttpErrorMessage: Text; RequestUri: Text; JsonContent: Text; + QueryParameters: Text; + FilterParameters: Text; begin - RequestUri := GraphURLTxt + StrSubstNo(RetrieveEmailsUriTxt, EmailAddress) + StrSubstNo(RetrieveEmailsFiltersTxt, Format(GetMaxNumberOfEmailsToRetrieve()), RetrieveEmailSelectedFieldsTxt); + RequestUri := GraphURLTxt + StrSubstNo(RetrieveEmailsUriTxt, EmailAddress) + '?'; + + if Filters."Load Attachments" then + QueryParameters := QueryParameters + '$expand=attachments&'; + + QueryParameters := QueryParameters + '$top=' + Format(Filters."Max No. of Emails") + '&'; + QueryParameters := QueryParameters + '$select=' + RetrieveEmailSelectedFieldsTxt + '&'; + QueryParameters := QueryParameters + '$count=true&'; + + FilterParameters := '$filter='; + if Filters."Unread Emails" then + FilterParameters := FilterParameters + 'isRead ne true&'; + if Filters."Draft Emails" then + FilterParameters := FilterParameters + 'isDraft eq true&' + else + FilterParameters := FilterParameters + 'isDraft ne true&'; + if Filters."Earliest Email" <> 0DT then + FilterParameters := FilterParameters + 'receivedDateTime ge ' + Format(Filters."Earliest Email", 0, 9) + '&'; + + if FilterParameters <> '$filter=' then begin + QueryParameters := QueryParameters + FilterParameters; + QueryParameters := CopyStr(QueryParameters, 1, StrLen(QueryParameters) - 1); + end; + + RequestUri := RequestUri + QueryParameters; CreateRequest('GET', RequestUri, AccessToken, MailHttpRequestMessage); + MailHttpRequestMessage.GetHeaders(MailRequestHeaders); - MailRequestHeaders.Add('Prefer', 'outlook.body-content-type="text"'); + if Filters."Body Type" = Filters."Body Type"::HTML then + MailRequestHeaders.Add('Prefer', 'outlook.body-content-type="html"') + else + MailRequestHeaders.Add('Prefer', 'outlook.body-content-type="text"'); + SendRequest(MailHttpRequestMessage, MailHttpResponseMessage); if MailHttpResponseMessage.HttpStatusCode <> 200 then begin @@ -319,11 +374,6 @@ codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Clien exit(true); end; - local procedure GetMaxNumberOfEmailsToRetrieve(): Integer - begin - exit(50); - end; - local procedure SendReplyEmailRequest(AccessToken: SecretText; EmailAddress: Text[250]; ExternalMessageId: Text; MessageJsonText: Text): Boolean var MessageJson: JsonObject; diff --git a/Apps/W1/Email - Outlook REST API/app/src/EmailOutlookAPIClientv3.Interface.al b/Apps/W1/Email - Outlook REST API/app/src/EmailOutlookAPIClientv3.Interface.al index 0f9d5062df..6972990f89 100644 --- a/Apps/W1/Email - Outlook REST API/app/src/EmailOutlookAPIClientv3.Interface.al +++ b/Apps/W1/Email - Outlook REST API/app/src/EmailOutlookAPIClientv3.Interface.al @@ -1,3 +1,4 @@ +#if not CLEAN26 // ------------------------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -10,6 +11,10 @@ namespace System.Email; /// interface "Email - Outlook API Client v3" extends "Email - Outlook API Client v2" { + ObsoleteReason = 'This interface is deprecated. Please use the Email - Outlook API Client v4 interface instead.'; + ObsoleteState = Pending; + ObsoleteTag = '26.0'; + /// /// Retrieves the emails from the Outlook API. /// @@ -52,4 +57,5 @@ interface "Email - Outlook API Client v3" extends "Email - Outlook API Client v2 /// The email address of the mailbox. /// The external message id to be marked as read. procedure MarkEmailAsRead(AccessToken: SecretText; EmailAddress: Text[250]; ExternalMessageId: Text); -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Apps/W1/Email - Outlook REST API/app/src/EmailOutlookAPIClientv4.Interface.al b/Apps/W1/Email - Outlook REST API/app/src/EmailOutlookAPIClientv4.Interface.al new file mode 100644 index 0000000000..1885e6836b --- /dev/null +++ b/Apps/W1/Email - Outlook REST API/app/src/EmailOutlookAPIClientv4.Interface.al @@ -0,0 +1,56 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace System.Email; + +/// +/// Interface for the Email - Outlook API Client which allows retrieval of emails, replying to emails and marking emails as read. +/// +interface "Email - Outlook API Client v4" extends "Email - Outlook API Client v2" +{ + /// + /// Retrieves the emails from the Outlook API. + /// + /// The access token used for connecting to exchange via graph. + /// The email account to retrieve emails from. + /// Filters for filtering the retrieval of emails. + /// The json containing the information of the emails." + procedure RetrieveEmails(AccessToken: SecretText; OutlookAccount: Record "Email - Outlook Account"; var Filters: Record "Email Retrieval Filters" temporary): JsonArray; + + /// + /// Retrieves an email from the Outlook API. + /// + /// The access token used for connecting to exchange via graph. + /// The email address of the mailbox. + /// The external message id of the message to retrieve. + /// Filters for filtering the retrieval of emails. + /// The json containing the information of the email. + procedure RetrieveEmail(AccessToken: SecretText; EmailAddress: Text[250]; ExternalMessageId: Text; var Filters: Record "Email Retrieval Filters" temporary): JsonObject; + + /// + /// Creates a draft reply to a specific email. + /// + /// The access token used for connecting to exchange via graph. + /// The email address of the mailbox. + /// The external message id of the message to create a reply for. + /// The external message id of the created draft. + procedure CreateDraftReply(AccessToken: SecretText; EmailAddress: Text[250]; ExternalMessageId: Text): Text; + + /// + /// Replies to an email. + /// + /// The access token used for connecting to exchange via graph. + /// The email address of the mailbox. + /// The email message containg the response for replying to the email. + procedure ReplyEmail(AccessToken: SecretText; EmailAddress: Text[250]; ExternalMessageId: Text; MessageJsonText: Text); + + /// + /// Marks an email as read. + /// + /// The access token used for connecting to exchange via graph. + /// The email address of the mailbox. + /// The external message id to be marked as read. + procedure MarkEmailAsRead(AccessToken: SecretText; EmailAddress: Text[250]; ExternalMessageId: Text); +} \ No newline at end of file diff --git a/Apps/W1/Email - Outlook REST API/app/src/EmailOutlookAPIHelper.Codeunit.al b/Apps/W1/Email - Outlook REST API/app/src/EmailOutlookAPIHelper.Codeunit.al index 6e79573841..04a9f86ccc 100644 --- a/Apps/W1/Email - Outlook REST API/app/src/EmailOutlookAPIHelper.Codeunit.al +++ b/Apps/W1/Email - Outlook REST API/app/src/EmailOutlookAPIHelper.Codeunit.al @@ -292,6 +292,8 @@ codeunit 4509 "Email - Outlook API Helper" OnAfterInitializeClientsV2(OutlookAPIClient, OAuthClient); end; +#if not CLEAN26 + [Obsolete('Update OutlookAPIClient to v4.', '26.0')] procedure InitializeClients(var OutlookAPIClient: interface "Email - Outlook API Client v3"; var OAuthClient: interface "Email - OAuth Client v2") var DefaultAPIClient: Codeunit "Email - Outlook API Client"; @@ -301,6 +303,16 @@ codeunit 4509 "Email - Outlook API Helper" OAuthClient := DefaultOAuthClient; OnAfterInitializeClientsV3(OutlookAPIClient, OAuthClient); end; +#endif + procedure InitializeClients(var OutlookAPIClient: interface "Email - Outlook API Client v4"; var OAuthClient: interface "Email - OAuth Client v2") + var + DefaultAPIClient: Codeunit "Email - Outlook API Client"; + DefaultOAuthClient: Codeunit "Email - OAuth Client"; + begin + OutlookAPIClient := DefaultAPIClient; + OAuthClient := DefaultOAuthClient; + OnAfterInitializeClientsV4(OutlookAPIClient, OAuthClient); + end; procedure Send(EmailMessage: Codeunit "Email Message"; AccountId: Guid) var @@ -328,11 +340,35 @@ codeunit 4509 "Email - Outlook API Helper" OAuthClient.GetAccessToken(AccessToken); APIClient.SendEmail(AccessToken, EmailMessageToJson(EmailMessage)); end; - +#if not CLEAN26 + [Obsolete('Replaced by an overload without the MarkEmailsAsRead parameter.', '26.0')] procedure RetrieveEmails(AccountId: Guid; MarkEmailsAsRead: Boolean; var EmailInbox: Record "Email Inbox") + var + TempFilters: Record "Email Retrieval Filters" temporary; + begin + TempFilters.Init(); + RetrieveEmails(AccountId, EmailInbox, TempFilters); + end; + + [Obsolete('Replaced by an overload without the MarkEmailsAsRead parameter.', '26.0')] + procedure RetrieveEmails(AccountId: Guid; MarkEmailsAsRead: Boolean; var EmailInbox: Record "Email Inbox"; var Filters: Record "Email Retrieval Filters") + begin + RetrieveEmails(AccountId, EmailInbox, Filters); + end; +#endif + + procedure RetrieveEmails(AccountId: Guid; var EmailInbox: Record "Email Inbox") + var + TempFilters: Record "Email Retrieval Filters" temporary; + begin + TempFilters.Init(); + RetrieveEmails(AccountId, EmailInbox, TempFilters); + end; + + procedure RetrieveEmails(AccountId: Guid; var EmailInbox: Record "Email Inbox"; var Filters: Record "Email Retrieval Filters") var EmailOutlookAccount: Record "Email - Outlook Account"; - APIClient: interface "Email - Outlook API Client v3"; + APIClient: interface "Email - Outlook API Client v4"; OAuthClient: interface "Email - OAuth Client v2"; AccessToken: SecretText; EmailsArray: JsonArray; @@ -346,18 +382,16 @@ codeunit 4509 "Email - Outlook API Helper" OAuthClient.GetAccessToken(AccessToken); - EmailsArray := APIClient.RetrieveEmails(AccessToken, MarkEmailsAsRead, EmailOutlookAccount); + EmailsArray := APIClient.RetrieveEmails(AccessToken, EmailOutlookAccount, Filters); for Counter := 0 to EmailsArray.Count() - 1 do begin EmailsArray.Get(Counter, JsonToken); EmailObject := JsonToken.AsObject(); - CreateEmailInboxFromJsonObject(EmailInbox, EmailOutlookAccount, EmailObject); - if MarkEmailsAsRead then - MarkEmailAsRead(EmailOutlookAccount.Id, EmailInbox."External Message Id"); + CreateEmailInboxFromJsonObject(EmailInbox, EmailOutlookAccount, Filters, EmailObject); end; end; - local procedure CreateEmailInboxFromJsonObject(var EmailInbox: Record "Email Inbox"; OutlookAccount: Record "Email - Outlook Account"; EmailJsonObject: JsonObject) + local procedure CreateEmailInboxFromJsonObject(var EmailInbox: Record "Email Inbox"; OutlookAccount: Record "Email - Outlook Account"; var Filters: Record "Email Retrieval Filters"; EmailJsonObject: JsonObject) var EmailInboxDelete: Record "Email Inbox"; EmailMessage: Codeunit "Email Message"; @@ -372,6 +406,9 @@ codeunit 4509 "Email - Outlook API Helper" SenderName: Text; SenderEmail: Text; HasAttachments: Boolean; + HTMLBody: Boolean; + IsRead: Boolean; + IsDraft: Boolean; begin ReceivedDateTime := GetDateTimeFromJsonObject(EmailJsonObject, 'receivedDateTime'); SentDateTime := GetDateTimeFromJsonObject(EmailJsonObject, 'sentDateTime'); @@ -379,6 +416,8 @@ codeunit 4509 "Email - Outlook API Helper" ConversationId := GetTextFromJsonObject(EmailJsonObject, 'conversationId'); Subject := GetTextFromJsonObject(EmailJsonObject, 'subject'); HasAttachments := GetBooleanFromJsonObject(EmailJsonObject, 'hasAttachments'); + IsRead := GetBooleanFromJsonObject(EmailJsonObject, 'isRead'); + IsDraft := GetBooleanFromJsonObject(EmailJsonObject, 'isDraft'); BodyObject := GetJsonObjectFromJsonObject(EmailJsonObject, 'body'); Body := GetTextFromJsonObject(BodyObject, 'content'); @@ -393,12 +432,12 @@ codeunit 4509 "Email - Outlook API Helper" EmailInboxDelete.DeleteAll(); end; - EmailMessage.Create('', Subject, Body, false); + HTMLBody := Filters."Body Type" = Filters."Body Type"::HTML; + EmailMessage.Create('', Subject, Body, HTMLBody, true); if HasAttachments then AddAttachmentsToMessage(EmailJsonObject, EmailMessage); - EmailInbox.Init(); EmailInbox.Id := 0; EmailInbox."External Message Id" := CopyStr(ExternalMessageId, 1, MaxStrLen(EmailInbox."External Message Id")); EmailInbox."Conversation Id" := CopyStr(ConversationId, 1, MaxStrLen(EmailInbox."Conversation Id")); @@ -410,6 +449,8 @@ codeunit 4509 "Email - Outlook API Helper" EmailInbox."Sent DateTime" := SentDateTime; EmailInbox."Sender Name" := CopyStr(SenderName, 1, MaxStrLen(EmailInbox."Sender Name")); EmailInbox."Sender Address" := CopyStr(SenderEmail, 1, MaxStrLen(EmailInbox."Sender Address")); + EmailInbox."Is Read" := IsRead; + EmailInbox."Is Draft" := IsDraft; EmailInbox.Insert(); EmailInbox.Mark(true); end; @@ -432,7 +473,8 @@ codeunit 4509 "Email - Outlook API Helper" ContentType: Text[250]; ContentBytesBase64: Text; begin - EmailJsonObject.Get('attachments', JsonToken); + if not EmailJsonObject.Get('attachments', JsonToken) then + exit; AttachmentsArray := JsonToken.AsArray(); for Counter := 0 to AttachmentsArray.Count() - 1 do begin @@ -482,7 +524,7 @@ codeunit 4509 "Email - Outlook API Helper" procedure MarkEmailAsRead(AccountId: Guid; ExternalMessageId: Text) var EmailOutlookAccount: Record "Email - Outlook Account"; - APIClient: interface "Email - Outlook API Client v3"; + APIClient: interface "Email - Outlook API Client v4"; OAuthClient: interface "Email - OAuth Client v2"; AccessToken: SecretText; begin @@ -497,7 +539,8 @@ codeunit 4509 "Email - Outlook API Helper" procedure ReplyEmail(AccountId: Guid; var EmailMessage: Codeunit "Email Message") var EmailOutlookAccount: Record "Email - Outlook Account"; - APIClient: interface "Email - Outlook API Client v3"; + TempFilters: Record "Email Retrieval Filters" temporary; + APIClient: interface "Email - Outlook API Client v4"; OAuthClient: interface "Email - OAuth Client v2"; AccessToken: SecretText; DraftMessageId: Text; @@ -514,7 +557,10 @@ codeunit 4509 "Email - Outlook API Helper" OAuthClient.GetAccessToken(AccessToken); DraftMessageId := APIClient.CreateDraftReply(AccessToken, EmailOutlookAccount."Email Address", EmailMessage.GetExternalId()); - DraftMessageJson := APIClient.RetrieveEmail(AccessToken, EmailOutlookAccount."Email Address", DraftMessageId, EmailMessage.IsBodyHTMLFormatted()); + + TempFilters."Body Type" := TempFilters."Body Type"::HTML; + TempFilters.Insert(); + DraftMessageJson := APIClient.RetrieveEmail(AccessToken, EmailOutlookAccount."Email Address", DraftMessageId, TempFilters); if EmailMessage.IsBodyHTMLFormatted() then begin DraftMessageBody := GetMessageBody(DraftMessageJson); Position := DraftMessageBody.IndexOf(' '' then Validate("Transaction Type", Vendor."Default Trans. Type - Return") else - Validate("Transaction Type", IntrastatReportSetup."Default Trans. - Return"); - - if "Document Type" in ["Document Type"::Invoice, "Document Type"::Order] then + Validate("Transaction Type", IntrastatReportSetup."Default Trans. - Return") + else if Vendor."Default Trans. Type" <> '' then Validate("Transaction Type", Vendor."Default Trans. Type") else Validate("Transaction Type", IntrastatReportSetup."Default Trans. - Purchase"); end else begin - Validate("Transport Method", Vendor."Def. Transport Method"); - Validate("Transaction Type", Vendor."Default Trans. Type"); + Validate("Transport Method", ''); + Validate("Transaction Type", ''); end; OnAfterUpdateIntrastatFields(Rec, Vendor, IntrastatReportSetup, FieldNo); diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportVendor.TableExt.al b/Apps/W1/Intrastat/app/src/BaseAppExtensions/Purchase/IntrastatReportVendor.TableExt.al similarity index 74% rename from Apps/W1/Intrastat/app/src/IntrastatReportVendor.TableExt.al rename to Apps/W1/Intrastat/app/src/BaseAppExtensions/Purchase/IntrastatReportVendor.TableExt.al index 471008837b..8b81eba014 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReportVendor.TableExt.al +++ b/Apps/W1/Intrastat/app/src/BaseAppExtensions/Purchase/IntrastatReportVendor.TableExt.al @@ -13,17 +13,23 @@ tableextension 4813 "Intrastat Report Vendor" extends Vendor field(4810; "Default Trans. Type"; Code[10]) { Caption = 'Default Trans. Type'; + DataClassification = CustomerContent; TableRelation = "Transaction Type"; + ToolTip = 'Specifies the default transaction type for regular purchase receipts.'; } field(4811; "Default Trans. Type - Return"; Code[10]) { Caption = 'Default Trans. Type - Returns'; + DataClassification = CustomerContent; TableRelation = "Transaction Type"; + ToolTip = 'Specifies the default transaction type for purchase returns.'; } field(4812; "Def. Transport Method"; Code[10]) { Caption = 'Default Transport Method'; + DataClassification = CustomerContent; TableRelation = "Transport Method"; + ToolTip = 'Specifies the default transport method, for the purpose of reporting to Intrastat.'; } } diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportVendorCard.PageExt.al b/Apps/W1/Intrastat/app/src/BaseAppExtensions/Purchase/IntrastatReportVendorCard.PageExt.al similarity index 66% rename from Apps/W1/Intrastat/app/src/IntrastatReportVendorCard.PageExt.al rename to Apps/W1/Intrastat/app/src/BaseAppExtensions/Purchase/IntrastatReportVendorCard.PageExt.al index 2f05e0b68c..abf6941402 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReportVendorCard.PageExt.al +++ b/Apps/W1/Intrastat/app/src/BaseAppExtensions/Purchase/IntrastatReportVendorCard.PageExt.al @@ -17,18 +17,15 @@ pageextension 4814 "Intrastat Report Vendor Card" extends "Vendor Card" Caption = 'Intrastat'; field("Default Trans. Type"; Rec."Default Trans. Type") { - ApplicationArea = BasicEU, BasicCH, BasicNO; - ToolTip = 'Specifies the default transaction type for regular purchase receipts.'; + ApplicationArea = All; } field("Default Trans. Type - Return"; Rec."Default Trans. Type - Return") { - ApplicationArea = BasicEU, BasicCH, BasicNO; - ToolTip = 'Specifies the default transaction type for purchase returns.'; + ApplicationArea = All; } field("Def. Transport Method"; Rec."Def. Transport Method") { - ApplicationArea = BasicEU, BasicCH, BasicNO; - ToolTip = 'Specifies the default transport method, for the purpose of reporting to INTRASTAT.'; + ApplicationArea = All; } } } diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportAccountRC.PageExt.al b/Apps/W1/Intrastat/app/src/BaseAppExtensions/RoleCenter/IntrastatReportAccountRC.PageExt.al similarity index 100% rename from Apps/W1/Intrastat/app/src/IntrastatReportAccountRC.PageExt.al rename to Apps/W1/Intrastat/app/src/BaseAppExtensions/RoleCenter/IntrastatReportAccountRC.PageExt.al diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportBusManRC.PageExt.al b/Apps/W1/Intrastat/app/src/BaseAppExtensions/RoleCenter/IntrastatReportBusManRC.PageExt.al similarity index 100% rename from Apps/W1/Intrastat/app/src/IntrastatReportBusManRC.PageExt.al rename to Apps/W1/Intrastat/app/src/BaseAppExtensions/RoleCenter/IntrastatReportBusManRC.PageExt.al diff --git a/Apps/W1/Intrastat/app/src/IntrastatRepCustTemCard.PageExt.al b/Apps/W1/Intrastat/app/src/BaseAppExtensions/Sales/IntrastatRepCustTemCard.PageExt.al similarity index 76% rename from Apps/W1/Intrastat/app/src/IntrastatRepCustTemCard.PageExt.al rename to Apps/W1/Intrastat/app/src/BaseAppExtensions/Sales/IntrastatRepCustTemCard.PageExt.al index 05d6302cd8..7d18700c70 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatRepCustTemCard.PageExt.al +++ b/Apps/W1/Intrastat/app/src/BaseAppExtensions/Sales/IntrastatRepCustTemCard.PageExt.al @@ -18,17 +18,14 @@ pageextension 4817 "Intrastat Rep. Cust. Tem. Card" extends "Customer Templ. Car field("Default Trans. Type"; Rec."Default Trans. Type") { ApplicationArea = All; - ToolTip = 'Specifies the default transaction type for regular sales shipments and service shipments.'; } field("Default Trans. Type - Return"; Rec."Default Trans. Type - Return") { ApplicationArea = All; - ToolTip = 'Specifies the default transaction type for sales returns and service returns.'; } field("Def. Transport Method"; Rec."Def. Transport Method") { ApplicationArea = All; - ToolTip = 'Specifies the default transport method, for the purpose of reporting to INTRASTAT.'; } } } diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportCustCard.PageExt.al b/Apps/W1/Intrastat/app/src/BaseAppExtensions/Sales/IntrastatReportCustCard.PageExt.al similarity index 76% rename from Apps/W1/Intrastat/app/src/IntrastatReportCustCard.PageExt.al rename to Apps/W1/Intrastat/app/src/BaseAppExtensions/Sales/IntrastatReportCustCard.PageExt.al index 169377c7cf..d888f0a0b0 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReportCustCard.PageExt.al +++ b/Apps/W1/Intrastat/app/src/BaseAppExtensions/Sales/IntrastatReportCustCard.PageExt.al @@ -18,17 +18,14 @@ pageextension 4813 "Intrastat Report Cust. Card" extends "Customer Card" field("Default Trans. Type"; Rec."Default Trans. Type") { ApplicationArea = All; - ToolTip = 'Specifies the default transaction type for regular sales shipments and service shipments.'; } field("Default Trans. Type - Return"; Rec."Default Trans. Type - Return") { ApplicationArea = All; - ToolTip = 'Specifies the default transaction type for sales returns and service returns.'; } field("Def. Transport Method"; Rec."Def. Transport Method") { ApplicationArea = All; - ToolTip = 'Specifies the default transport method, for the purpose of reporting to INTRASTAT.'; } } } diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportCustTempl.TableExt.al b/Apps/W1/Intrastat/app/src/BaseAppExtensions/Sales/IntrastatReportCustTempl.TableExt.al similarity index 69% rename from Apps/W1/Intrastat/app/src/IntrastatReportCustTempl.TableExt.al rename to Apps/W1/Intrastat/app/src/BaseAppExtensions/Sales/IntrastatReportCustTempl.TableExt.al index 060e3a685b..bcf1d82e76 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReportCustTempl.TableExt.al +++ b/Apps/W1/Intrastat/app/src/BaseAppExtensions/Sales/IntrastatReportCustTempl.TableExt.al @@ -13,17 +13,23 @@ tableextension 4822 "Intrastat Report Cust. Templ." extends "Customer Templ." field(4810; "Default Trans. Type"; Code[10]) { Caption = 'Default Trans. Type'; + DataClassification = CustomerContent; TableRelation = "Transaction Type"; + ToolTip = 'Specifies the default transaction type for regular sales shipments and service shipments.'; } field(4811; "Default Trans. Type - Return"; Code[10]) { Caption = 'Default Trans. Type - Returns'; + DataClassification = CustomerContent; TableRelation = "Transaction Type"; + ToolTip = 'Specifies the default transaction type for sales returns and service returns.'; } field(4812; "Def. Transport Method"; Code[10]) { Caption = 'Default Transport Method'; + DataClassification = CustomerContent; TableRelation = "Transport Method"; + ToolTip = 'Specifies the default transport method, for the purpose of reporting to INTRASTAT.'; } } } \ No newline at end of file diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportCustomer.TableExt.al b/Apps/W1/Intrastat/app/src/BaseAppExtensions/Sales/IntrastatReportCustomer.TableExt.al similarity index 68% rename from Apps/W1/Intrastat/app/src/IntrastatReportCustomer.TableExt.al rename to Apps/W1/Intrastat/app/src/BaseAppExtensions/Sales/IntrastatReportCustomer.TableExt.al index e4f5890e49..f1656d7ae1 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReportCustomer.TableExt.al +++ b/Apps/W1/Intrastat/app/src/BaseAppExtensions/Sales/IntrastatReportCustomer.TableExt.al @@ -13,17 +13,23 @@ tableextension 4814 "Intrastat Report Customer" extends Customer field(4810; "Default Trans. Type"; Code[10]) { Caption = 'Default Trans. Type'; + DataClassification = CustomerContent; TableRelation = "Transaction Type"; + ToolTip = 'Specifies the default transaction type for regular sales shipments and service shipments.'; } field(4811; "Default Trans. Type - Return"; Code[10]) { Caption = 'Default Trans. Type - Returns'; + DataClassification = CustomerContent; TableRelation = "Transaction Type"; + ToolTip = 'Specifies the default transaction type for sales returns and service returns.'; } field(4812; "Def. Transport Method"; Code[10]) { Caption = 'Default Transport Method'; + DataClassification = CustomerContent; TableRelation = "Transport Method"; + ToolTip = 'Specifies the default transport method, for the purpose of reporting to Intrastat.'; } } } \ No newline at end of file diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportSalesHead.TableExt.al b/Apps/W1/Intrastat/app/src/BaseAppExtensions/Sales/IntrastatReportSalesHead.TableExt.al similarity index 81% rename from Apps/W1/Intrastat/app/src/IntrastatReportSalesHead.TableExt.al rename to Apps/W1/Intrastat/app/src/BaseAppExtensions/Sales/IntrastatReportSalesHead.TableExt.al index 3ca941ea08..5814a40978 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReportSalesHead.TableExt.al +++ b/Apps/W1/Intrastat/app/src/BaseAppExtensions/Sales/IntrastatReportSalesHead.TableExt.al @@ -44,25 +44,25 @@ tableextension 4815 "Intrastat Report Sales Head." extends "Sales Header" if not IntrastatReportSetup.Get() then exit; - if FieldNo = FieldNo("Sell-to Customer No.") then - CustomerNo := IntrastatReportSetup.GetPartnerNo("Sell-to Customer No.", "Bill-to Customer No.", IntrastatReportSetup."VAT No. Based On"::"Sell-to VAT"); - - if FieldNo = FieldNo("Bill-to Customer No.") then - CustomerNo := IntrastatReportSetup.GetPartnerNo("Sell-to Customer No.", "Bill-to Customer No.", IntrastatReportSetup."VAT No. Based On"::"Bill-to VAT"); - - if CustomerNo = '' then - exit; + case true of + (IntrastatReportSetup."Sales Intrastat Info Based On" = IntrastatReportSetup."Sales Intrastat Info Based On"::"Sell-to Customer") and + (FieldNo = FieldNo("Sell-to Customer No.")): + CustomerNo := "Sell-to Customer No."; + (IntrastatReportSetup."Sales Intrastat Info Based On" = IntrastatReportSetup."Sales Intrastat Info Based On"::"Bill-to Customer") and + (FieldNo = FieldNo("Bill-to Customer No.")): + CustomerNo := "Bill-to Customer No."; + else + exit; + end; if Customer.Get(CustomerNo) then begin Validate("Transport Method", Customer."Def. Transport Method"); - if "Document Type" in ["Document Type"::"Credit Memo", "Document Type"::"Return Order"] then if Customer."Default Trans. Type - Return" <> '' then Validate("Transaction Type", Customer."Default Trans. Type - Return") else - Validate("Transaction Type", IntrastatReportSetup."Default Trans. - Return"); - - if "Document Type" in ["Document Type"::Invoice, "Document Type"::Order] then + Validate("Transaction Type", IntrastatReportSetup."Default Trans. - Return") + else if Customer."Default Trans. Type" <> '' then Validate("Transaction Type", Customer."Default Trans. Type") else diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportServHead.TableExt.al b/Apps/W1/Intrastat/app/src/BaseAppExtensions/Service/IntrastatReportServHead.TableExt.al similarity index 81% rename from Apps/W1/Intrastat/app/src/IntrastatReportServHead.TableExt.al rename to Apps/W1/Intrastat/app/src/BaseAppExtensions/Service/IntrastatReportServHead.TableExt.al index 7eb63e47e4..fd7c0b75a2 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReportServHead.TableExt.al +++ b/Apps/W1/Intrastat/app/src/BaseAppExtensions/Service/IntrastatReportServHead.TableExt.al @@ -44,25 +44,25 @@ tableextension 4816 "Intrastat Report Serv. Head." extends "Service Header" if not IntrastatReportSetup.Get() then exit; - if FieldNo = FieldNo("Customer No.") then - CustomerNo := IntrastatReportSetup.GetPartnerNo("Customer No.", "Bill-to Customer No.", IntrastatReportSetup."VAT No. Based On"::"Sell-to VAT"); - - if FieldNo = FieldNo("Bill-to Customer No.") then - CustomerNo := IntrastatReportSetup.GetPartnerNo("Customer No.", "Bill-to Customer No.", IntrastatReportSetup."VAT No. Based On"::"Bill-to VAT"); - - if CustomerNo = '' then - exit; + case true of + (IntrastatReportSetup."Sales Intrastat Info Based On" = IntrastatReportSetup."Sales Intrastat Info Based On"::"Sell-to Customer") and + (FieldNo = FieldNo("Customer No.")): + CustomerNo := "Customer No."; + (IntrastatReportSetup."Sales Intrastat Info Based On" = IntrastatReportSetup."Sales Intrastat Info Based On"::"Bill-to Customer") and + (FieldNo = FieldNo("Bill-to Customer No.")): + CustomerNo := "Bill-to Customer No."; + else + exit; + end; if Customer.Get(CustomerNo) then begin Validate("Transport Method", Customer."Def. Transport Method"); - if "Document Type" = "Document Type"::"Credit Memo" then if Customer."Default Trans. Type - Return" <> '' then Validate("Transaction Type", Customer."Default Trans. Type - Return") else - Validate("Transaction Type", IntrastatReportSetup."Default Trans. - Return"); - - if "Document Type" in ["Document Type"::Invoice, "Document Type"::Order] then + Validate("Transaction Type", IntrastatReportSetup."Default Trans. - Return") + else if Customer."Default Trans. Type" <> '' then Validate("Transaction Type", Customer."Default Trans. Type") else diff --git a/Apps/W1/Intrastat/app/src/IntrastatReport.Page.al b/Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReport.Page.al similarity index 88% rename from Apps/W1/Intrastat/app/src/IntrastatReport.Page.al rename to Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReport.Page.al index 7a433ddf4d..475db7a997 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReport.Page.al +++ b/Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReport.Page.al @@ -24,46 +24,23 @@ page 4812 "Intrastat Report" Caption = 'General'; field("No."; Rec."No.") { - ToolTip = 'Specifies the number of the Intrastat Report.'; trigger OnAssistEdit() begin if Rec.AssistEdit(xRec) then CurrPage.Update(); end; } - field(Status; Rec.Status) - { - ToolTip = 'Specifies the status of the Intrastat Report.'; - } - field(Description; Rec.Description) - { - ToolTip = 'Specifies some information about the Intrastat Report.'; - } - field("Statistics Period"; Rec."Statistics Period") - { - ToolTip = 'Specifies the month to report data for. Enter the period as a four-digit number, with no spaces or symbols. Enter the year first and then the month, for example, enter 1706 for June, 2017'; - } - field("Currency Identifier"; Rec."Currency Identifier") - { - ToolTip = 'Specifies a code that identifies the currency of the Intrastat report.'; - } + field(Status; Rec.Status) { } + field(Description; Rec.Description) { } + field("Statistics Period"; Rec."Statistics Period") { } + field("Currency Identifier"; Rec."Currency Identifier") { } field("Amounts in Add. Currency"; Rec."Amounts in Add. Currency") { - ToolTip = 'Specifies that you use an additional reporting currency in the general ledger and that you want to report Intrastat in this currency.'; Visible = false; } - field(Reported; Rec.Reported) - { - ToolTip = 'Specifies whether the entry has already been reported to the tax authorities.'; - } - field("Export Date"; Rec."Export Date") - { - ToolTip = 'Specifies the date when the report has been exported.'; - } - field("Export Time"; Rec."Export Time") - { - ToolTip = 'Specifies the time when the report has been exported.'; - } + field(Reported; Rec.Reported) { } + field("Export Date"; Rec."Export Date") { } + field("Export Time"; Rec."Export Time") { } } part(IntrastatLines; "Intrastat Report Subform") { diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportHeader.Table.al b/Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportHeader.Table.al similarity index 92% rename from Apps/W1/Intrastat/app/src/IntrastatReportHeader.Table.al rename to Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportHeader.Table.al index 39e368bcd3..7b4bb3621f 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReportHeader.Table.al +++ b/Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportHeader.Table.al @@ -20,7 +20,7 @@ table 4811 "Intrastat Report Header" field(1; "No."; Code[20]) { Caption = 'No.'; - + ToolTip = 'Specifies the number of the Intrastat Report.'; trigger OnValidate() var NoSeries: Codeunit "No. Series"; @@ -36,20 +36,23 @@ table 4811 "Intrastat Report Header" { Caption = 'Status'; Editable = false; + ToolTip = 'Specifies the status of the Intrastat Report.'; } field(3; Description; Text[100]) { Caption = 'Description'; + ToolTip = 'Specifies some information about the Intrastat Report.'; } field(13; Reported; Boolean) { Caption = 'Reported'; Editable = false; + ToolTip = 'Specifies whether the entry has already been reported to the tax authorities.'; } field(14; "Statistics Period"; Code[10]) { Caption = 'Statistics Period'; - + ToolTip = 'Specifies the month to report data for. Enter the period as a four-digit number, with no spaces or symbols. Enter the year first and then the month, for example, enter 1706 for June, 2017'; trigger OnValidate() begin TestField(Reported, false); @@ -66,11 +69,13 @@ table 4811 "Intrastat Report Header" { AccessByPermission = TableData Currency = R; Caption = 'Amounts in Add. Currency'; + ToolTip = 'Specifies that you use an additional reporting currency in the general ledger and that you want to report Intrastat in this currency.'; } field(16; "Currency Identifier"; Code[10]) { AccessByPermission = TableData Currency = R; Caption = 'Currency Identifier'; + ToolTip = 'Specifies a code that identifies the currency of the Intrastat report.'; } field(17; "No. Series"; Code[20]) { @@ -82,7 +87,6 @@ table 4811 "Intrastat Report Header" { Caption = 'Arrivals Reported'; Editable = false; - trigger OnValidate() begin UpdateReported(); @@ -92,7 +96,6 @@ table 4811 "Intrastat Report Header" { Caption = 'Dispatches Reported'; Editable = false; - trigger OnValidate() begin UpdateReported(); @@ -105,7 +108,6 @@ table 4811 "Intrastat Report Header" field(21; Periodicity; Enum "Intrastat Report Periodicity") { Caption = 'Periodicity'; - trigger OnValidate() begin Validate("Statistics Period"); @@ -115,7 +117,6 @@ table 4811 "Intrastat Report Header" { Caption = 'File Disk No.'; Numeric = true; - trigger OnValidate() var IntrastatReportHeader: Record "Intrastat Report Header"; @@ -133,7 +134,6 @@ table 4811 "Intrastat Report Header" field(23; "Corrective Entry"; Boolean) { Caption = 'Corrective Entry'; - trigger OnValidate() begin TestField(Reported, false); @@ -144,7 +144,6 @@ table 4811 "Intrastat Report Header" field(24; "EU Service"; Boolean) { Caption = 'EU Service'; - trigger OnValidate() begin TestField(Reported, false); @@ -158,11 +157,13 @@ table 4811 "Intrastat Report Header" { Caption = 'Export Date'; Editable = false; + ToolTip = 'Specifies the date when the report has been exported.'; } field(26; "Export Time"; Time) { Caption = 'Export Time'; Editable = false; + ToolTip = 'Specifies the time when the report has been exported.'; } } diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportLine.Table.al b/Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportLine.Table.al similarity index 65% rename from Apps/W1/Intrastat/app/src/IntrastatReportLine.Table.al rename to Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportLine.Table.al index 4cc1d688be..69f5d5766d 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReportLine.Table.al +++ b/Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportLine.Table.al @@ -17,6 +17,8 @@ using Microsoft.Inventory.Ledger; using Microsoft.Inventory.Location; using Microsoft.Inventory.Tracking; using Microsoft.Inventory.Transfer; +using Microsoft.Purchases.Document; +using Microsoft.Sales.Document; using Microsoft.Projects.Project.Job; using Microsoft.Projects.Project.Ledger; using Microsoft.Purchases.History; @@ -47,10 +49,12 @@ table 4812 "Intrastat Report Line" field(3; Type; Enum "Intrastat Report Line Type") { Caption = 'Type'; + ToolTip = 'Specifies whether the item was received or shipped by the company.'; } field(4; Date; Date) { Caption = 'Date'; + ToolTip = 'Specifies the date the item entry was posted.'; trigger OnValidate() var StartDate: Date; @@ -74,7 +78,7 @@ table 4812 "Intrastat Report Line" Caption = 'Tariff No.'; NotBlank = true; TableRelation = "Tariff Number"; - + ToolTip = 'Specifies the item''s tariff number.'; trigger OnValidate() begin GetTariffDescription(); @@ -82,28 +86,32 @@ table 4812 "Intrastat Report Line" } field(6; "Tariff Description"; Text[250]) { - Caption = 'Tariff Description'; + Caption = 'Tariff No. Description'; + ToolTip = 'Specifies the name of the tariff no. that is associated with the item.'; } field(7; "Country/Region Code"; Code[10]) { Caption = 'Country/Region Code'; TableRelation = "Country/Region"; + ToolTip = 'Specifies the country/region of the address.'; } field(8; "Transaction Type"; Code[10]) { Caption = 'Transaction Type'; TableRelation = "Transaction Type"; + ToolTip = 'Specifies the type of transaction that the document represents, for the purpose of reporting to Intrastat.'; } field(9; "Transport Method"; Code[10]) { Caption = 'Transport Method'; TableRelation = "Transport Method"; + ToolTip = 'Specifies the transport method, for the purpose of reporting to Intrastat.'; } field(10; "Source Type"; Enum "Intrastat Report Source Type") { BlankZero = true; Caption = 'Source Type'; - + ToolTip = 'Specifies the entry type.'; trigger OnValidate() begin IntrastatReportSetup.GetSetup(); @@ -120,12 +128,13 @@ table 4812 "Intrastat Report Line" TableRelation = if ("Source Type" = const("Item Entry")) "Item Ledger Entry" else if ("Source Type" = const("Job Entry")) "Job Ledger Entry" else if ("Source Type" = const("FA Entry")) "FA Ledger Entry"; + ToolTip = 'Specifies the number that the item entry had in the table it came from.'; } field(12; "Net Weight"; Decimal) { Caption = 'Net Weight'; DecimalPlaces = 0 : 5; - + ToolTip = 'Specifies the net weight of one unit of the item.'; trigger OnValidate() begin if Quantity <> 0 then @@ -138,7 +147,7 @@ table 4812 "Intrastat Report Line" { Caption = 'Amount'; DecimalPlaces = 0 : 5; - + ToolTip = 'Specifies the total amount of the entry, excluding VAT.'; trigger OnValidate() begin if "Cost Regulation %" <> 0 then @@ -151,7 +160,7 @@ table 4812 "Intrastat Report Line" { Caption = 'Quantity'; DecimalPlaces = 0 : 5; - + ToolTip = 'Specifies the number of units of the item in the entry.'; trigger OnValidate() begin if (Quantity <> 0) then @@ -173,7 +182,7 @@ table 4812 "Intrastat Report Line" DecimalPlaces = 0 : 5; MaxValue = 100; MinValue = 0; - + ToolTip = 'Specifies any indirect costs, as a percentage.'; trigger OnValidate() begin "Indirect Cost" := Amount * "Cost Regulation %" / 100; @@ -184,7 +193,7 @@ table 4812 "Intrastat Report Line" { Caption = 'Indirect Cost'; DecimalPlaces = 0 : 5; - + ToolTip = 'Specifies an amount that represents the costs for freight and insurance.'; trigger OnValidate() begin "Cost Regulation %" := 0; @@ -195,10 +204,12 @@ table 4812 "Intrastat Report Line" { Caption = 'Statistical Value'; DecimalPlaces = 0 : 5; + ToolTip = 'Specifies the entry''s statistical value, which must be reported to the statistics authorities.'; } field(18; "Document No."; Code[20]) { Caption = 'Document No.'; + ToolTip = 'Specifies the document number on the entry.'; } field(19; "Item No."; Code[20]) { @@ -206,7 +217,7 @@ table 4812 "Intrastat Report Line" TableRelation = if ("Source Type" = const("Item Entry")) Item else if ("Source Type" = const("Job Entry")) Item else if ("Source Type" = const("FA Entry")) "Fixed Asset"; - + ToolTip = 'Specifies the number of the item.'; trigger OnValidate() var ItemUOM: Record "Item Unit of Measure"; @@ -245,56 +256,67 @@ table 4812 "Intrastat Report Line" field(20; "Item Name"; Text[100]) { Caption = 'Item Name'; + ToolTip = 'Specifies the name of the item.'; } field(21; "Total Weight"; Decimal) { Caption = 'Total Weight'; DecimalPlaces = 0 : 5; Editable = false; + ToolTip = 'Specifies the total weight for the items in the item entry.'; } field(22; "Supplementary Units"; Boolean) { Caption = 'Supplementary Units'; Editable = false; + ToolTip = 'Specifies if you must report information about quantity and units of measure for this item.'; } field(23; "Internal Ref. No."; Text[10]) { Caption = 'Internal Ref. No.'; Editable = false; + ToolTip = 'Specifies a reference number used by the customs and tax authorities.'; } field(24; "Country/Region of Origin Code"; Code[10]) { Caption = 'Country/Region of Origin Code'; TableRelation = "Country/Region"; + ToolTip = 'Specifies a code for the country/region where the item was produced or processed.'; } field(25; "Entry/Exit Point"; Code[10]) { Caption = 'Entry/Exit Point'; TableRelation = "Entry/Exit Point"; + ToolTip = 'Specifies the code of either the port of entry where the items passed into your country/region or the port of exit.'; } field(26; "Area"; Code[10]) { Caption = 'Area'; TableRelation = Area; + ToolTip = 'Specifies the area of the customer or vendor, for the purpose of reporting to Intrastat.'; } field(27; "Transaction Specification"; Code[10]) { Caption = 'Transaction Specification'; TableRelation = "Transaction Specification"; + ToolTip = 'Specifies a specification of the document''s transaction, for the purpose of reporting to Intrastat.'; } field(28; "Shpt. Method Code"; Code[10]) { Caption = 'Shpt. Method Code'; TableRelation = "Shipment Method"; + ToolTip = 'Specifies the item''s shipment method.'; } field(29; "Partner VAT ID"; Text[50]) { Caption = 'VAT Reg. No.'; + ToolTip = 'Specifies the counter party''s VAT number.'; } field(30; "Location Code"; Code[10]) { Caption = 'Location Code'; TableRelation = Location; + ToolTip = 'Specifies the code for the location that the entry is linked to.'; } field(31; Counterparty; Boolean) { @@ -309,7 +331,7 @@ table 4812 "Intrastat Report Line" Caption = 'Supplementary Unit Conversion Factor'; DecimalPlaces = 0 : 5; Editable = false; - + ToolTip = 'Specifies the conversion factor of the item on this Intrastat report line.'; trigger OnValidate() var UOMMgt: Codeunit "Unit of Measure Management"; @@ -322,7 +344,7 @@ table 4812 "Intrastat Report Line" { Caption = 'Supplementary Unit of Measure'; TableRelation = "Item Unit of Measure".Code where("Item No." = field("Item No.")); - + ToolTip = 'Specifies the unit of measure code for the tariff number on this line.'; trigger OnValidate() var ItemUOM: Record "Item Unit of Measure"; @@ -339,6 +361,7 @@ table 4812 "Intrastat Report Line" Caption = 'Supplementary Quantity'; DecimalPlaces = 0 : 5; Editable = false; + ToolTip = 'Specifies the quantity of supplementary units on the Intrastat line.'; } field(36; "Statistical System"; Enum "Intrastat Report Stat. System") { @@ -378,7 +401,6 @@ table 4812 "Intrastat Report Line" { Caption = 'Payment Method'; TableRelation = "Payment Method"; - trigger OnValidate() begin if "Payment Method" <> '' then @@ -389,29 +411,28 @@ table 4812 "Intrastat Report Line" field(44; "Corrected Intrastat Report No."; Code[20]) { Caption = 'Corrected Intrastat Report No.'; - trigger OnLookup() var - IntrastatReportHeader2: Record "Intrastat Report Header"; + IntrastatReportHeaderWithFiltersSet: Record "Intrastat Report Header"; begin - SetIntrastatReportHeaderFilters(IntrastatReportHeader2); - IntrastatReportHeader2."No." := "Corrected Intrastat Report No."; - if Page.RunModal(0, IntrastatReportHeader2, IntrastatReportHeader2."No.") = Action::LookupOK then - Validate("Corrected Intrastat Report No.", IntrastatReportHeader2."No."); + SetIntrastatReportHeaderFilters(IntrastatReportHeaderWithFiltersSet); + IntrastatReportHeaderWithFiltersSet."No." := "Corrected Intrastat Report No."; + if Page.RunModal(0, IntrastatReportHeaderWithFiltersSet, IntrastatReportHeaderWithFiltersSet."No.") = Action::LookupOK then + Validate("Corrected Intrastat Report No.", IntrastatReportHeaderWithFiltersSet."No."); end; trigger OnValidate() var - IntrastatReportHeader2: Record "Intrastat Report Header"; + IntrastatReportHeaderWithFiltersSet: Record "Intrastat Report Header"; begin if "Corrected Intrastat Report No." <> '' then begin IntrastatReportHeader.CheckEUServAndCorrection("Intrastat No.", false, true); - SetIntrastatReportHeaderFilters(IntrastatReportHeader2); - IntrastatReportHeader2.SetRange("No.", "Corrected Intrastat Report No."); - if not IntrastatReportHeader2.FindFirst() then + SetIntrastatReportHeaderFilters(IntrastatReportHeaderWithFiltersSet); + IntrastatReportHeaderWithFiltersSet.SetRange("No.", "Corrected Intrastat Report No."); + if not IntrastatReportHeaderWithFiltersSet.FindFirst() then FieldError("Corrected Intrastat Report No.") else - Validate("Reference Period", IntrastatReportHeader2."Statistics Period"); + Validate("Reference Period", IntrastatReportHeaderWithFiltersSet."Statistics Period"); end; end; } @@ -432,7 +453,6 @@ table 4812 "Intrastat Report Line" field(48; "Corrected Document No."; Code[20]) { Caption = 'Corrected Document No.'; - trigger OnLookup() var IntrastatReportLine: Record "Intrastat Report Line"; @@ -474,33 +494,15 @@ table 4812 "Intrastat Report Line" { Clustered = true; } - key(Key2; "Source Type", "Source Entry No.") - { - } - key(Key3; "Document No.") - { - } - key(Key4; "Intrastat No.", Type, "Internal Ref. No.") - { - } - key(Key5; "Intrastat No.", Type, "Country/Region Code", "Tariff No.", "Transaction Type", "Transport Method", "Country/Region of Origin Code", "Partner VAT ID") - { - } - key(Key6; "Intrastat No.", Type, "Country/Region Code", "Tariff No.", "Transaction Type", "Transport Method", "Area", "Transaction Specification", "Country/Region of Origin Code", "Partner VAT ID") - { - } - key(Key7; "Intrastat No.", Type, "Country/Region Code", "Tariff No.", "Transaction Type", "Transport Method", "Transaction Specification", "Area", "Country/Region of Origin Code", "Partner VAT ID") - { - } - key(Key8; Type, "Country/Region Code", "Partner VAT ID", "Transaction Type", "Tariff No.", "Group Code", "Transport Method", "Transaction Specification", "Country/Region of Origin Code", "Area", "Corrective entry") - { - } - key(Key9; "Intrastat No.", Type) - { - } - key(Key10; "Partner VAT ID", "Transaction Type", "Tariff No.", "Group Code", "Transport Method", "Transaction Specification", "Country/Region of Origin Code", "Area", "Corrective entry") - { - } + key(Key2; "Source Type", "Source Entry No.") { } + key(Key3; "Document No.") { } + key(Key4; "Intrastat No.", Type, "Internal Ref. No.") { } + key(Key5; "Intrastat No.", Type, "Country/Region Code", "Tariff No.", "Transaction Type", "Transport Method", "Country/Region of Origin Code", "Partner VAT ID") { } + key(Key6; "Intrastat No.", Type, "Country/Region Code", "Tariff No.", "Transaction Type", "Transport Method", "Area", "Transaction Specification", "Country/Region of Origin Code", "Partner VAT ID") { } + key(Key7; "Intrastat No.", Type, "Country/Region Code", "Tariff No.", "Transaction Type", "Transport Method", "Transaction Specification", "Area", "Country/Region of Origin Code", "Partner VAT ID") { } + key(Key8; Type, "Country/Region Code", "Partner VAT ID", "Transaction Type", "Tariff No.", "Group Code", "Transport Method", "Transaction Specification", "Country/Region of Origin Code", "Area", "Corrective entry") { } + key(Key9; "Intrastat No.", Type) { } + key(Key10; "Partner VAT ID", "Transaction Type", "Tariff No.", "Group Code", "Transport Method", "Transaction Specification", "Country/Region of Origin Code", "Area", "Corrective entry") { } } trigger OnDelete() @@ -534,6 +536,7 @@ table 4812 "Intrastat Report Line" Item: Record Item; FixedAsset: Record "Fixed Asset"; TariffNumber: Record "Tariff Number"; + TableNumbers: List of [Integer]; DateNotInRageErr: Label 'Date %1 is not within the reporting period.', Comment = '%1 - Date'; NoDocumentNumberWithinTheFilterErr: Label 'There is no %1 %2 with in the filter.\\Filters: %3', Comment = '%1 - Document No. caption, %2 - Document No., %3 - Filters'; @@ -648,25 +651,16 @@ table 4812 "Intrastat Report Line" local procedure GetPartnerIDFromItemEntry(): Text[50] var ItemLedgerEntry: Record "Item Ledger Entry"; - SalesShipmentHeader: Record "Sales Shipment Header"; - SalesInvoiceHeader: Record "Sales Invoice Header"; - SalesCrMemoHeader: Record "Sales Cr.Memo Header"; - ReturnReceiptHeader: Record "Return Receipt Header"; - PurchCrMemoHdr: Record "Purch. Cr. Memo Hdr."; - PurchInvHeader: Record "Purch. Inv. Header"; - PurchRcptHeader: Record "Purch. Rcpt. Header"; - ReturnShipmentHeader: Record "Return Shipment Header"; - ServiceShipmentHeader: Record "Service Shipment Header"; - ServiceInvoiceHeader: Record "Service Invoice Header"; - ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TransferHeader: Record "Transfer Header"; Customer: Record Customer; Vendor: Record Vendor; - TransferReceiptHeader: Record "Transfer Receipt Header"; - TransferShipmentHeader: Record "Transfer Shipment Header"; IntrastatReportMgt: Codeunit IntrastatReportManagement; + DocRecRef: RecordRef; EU3rdPartyTrade: Boolean; IsHandled: Boolean; PartnerID: Text[50]; + PartnerNo: Code[20]; + TableNo: Integer; begin IsHandled := false; OnBeforeGetPartnerIDFromItemEntry(Rec, PartnerID, IsHandled); @@ -678,109 +672,60 @@ table 4812 "Intrastat Report Line" IntrastatReportSetup.GetSetup(); - case ItemLedgerEntry."Document Type" of - ItemLedgerEntry."Document Type"::"Sales Invoice": - if SalesInvoiceHeader.Get(ItemLedgerEntry."Document No.") then begin - if not Customer.Get(IntrastatReportSetup.GetPartnerNo(SalesInvoiceHeader."Sell-to Customer No.", SalesInvoiceHeader."Bill-to Customer No.")) then - exit(''); - EU3rdPartyTrade := SalesInvoiceHeader."EU 3-Party Trade"; - end; - ItemLedgerEntry."Document Type"::"Sales Credit Memo": - if SalesCrMemoHeader.Get(ItemLedgerEntry."Document No.") then begin - if not Customer.Get(IntrastatReportSetup.GetPartnerNo(SalesCrMemoHeader."Sell-to Customer No.", SalesCrMemoHeader."Bill-to Customer No.")) then - exit(''); - EU3rdPartyTrade := SalesCrMemoHeader."EU 3-Party Trade"; - end; - ItemLedgerEntry."Document Type"::"Sales Shipment": - if SalesShipmentHeader.Get(ItemLedgerEntry."Document No.") then begin - if not Customer.Get(IntrastatReportSetup.GetPartnerNo(SalesShipmentHeader."Sell-to Customer No.", SalesShipmentHeader."Bill-to Customer No.")) then - exit(''); - EU3rdPartyTrade := SalesShipmentHeader."EU 3-Party Trade"; - end; - ItemLedgerEntry."Document Type"::"Sales Return Receipt": - if ReturnReceiptHeader.Get(ItemLedgerEntry."Document No.") then begin - if not Customer.Get(IntrastatReportSetup.GetPartnerNo(ReturnReceiptHeader."Sell-to Customer No.", ReturnReceiptHeader."Bill-to Customer No.")) then - exit(''); - EU3rdPartyTrade := ReturnReceiptHeader."EU 3-Party Trade"; - end; - ItemLedgerEntry."Document Type"::"Purchase Credit Memo": - if PurchCrMemoHdr.Get(ItemLedgerEntry."Document No.") then - if not Vendor.Get(IntrastatReportSetup.GetPartnerNo(PurchCrMemoHdr."Buy-from Vendor No.", PurchCrMemoHdr."Pay-to Vendor No.")) then - exit(''); - ItemLedgerEntry."Document Type"::"Purchase Return Shipment": - if ReturnShipmentHeader.Get(ItemLedgerEntry."Document No.") then - if not Vendor.Get(IntrastatReportSetup.GetPartnerNo(ReturnShipmentHeader."Buy-from Vendor No.", ReturnShipmentHeader."Pay-to Vendor No.")) then - exit(''); - ItemLedgerEntry."Document Type"::"Purchase Invoice": - if PurchInvHeader.Get(ItemLedgerEntry."Document No.") then - if not Vendor.Get(IntrastatReportSetup.GetPartnerNo(PurchInvHeader."Buy-from Vendor No.", PurchInvHeader."Pay-to Vendor No.")) then - exit(''); - ItemLedgerEntry."Document Type"::"Purchase Receipt": - if PurchRcptHeader.Get(ItemLedgerEntry."Document No.") then - if not Vendor.Get(IntrastatReportSetup.GetPartnerNo(PurchRcptHeader."Buy-from Vendor No.", PurchRcptHeader."Pay-to Vendor No.")) then - exit(''); - ItemLedgerEntry."Document Type"::"Service Shipment": - if ServiceShipmentHeader.Get(ItemLedgerEntry."Document No.") then begin - if not Customer.Get(IntrastatReportSetup.GetPartnerNo(ServiceShipmentHeader."Customer No.", ServiceShipmentHeader."Bill-to Customer No.")) then - exit(''); - EU3rdPartyTrade := ServiceShipmentHeader."EU 3-Party Trade"; - end; - ItemLedgerEntry."Document Type"::"Service Invoice": - if ServiceInvoiceHeader.Get(ItemLedgerEntry."Document No.") then begin - if not Customer.Get(IntrastatReportSetup.GetPartnerNo(ServiceInvoiceHeader."Customer No.", ServiceInvoiceHeader."Bill-to Customer No.")) then - exit(''); - EU3rdPartyTrade := ServiceInvoiceHeader."EU 3-Party Trade"; - end; - ItemLedgerEntry."Document Type"::"Service Credit Memo": - if ServiceCrMemoHeader.Get(ItemLedgerEntry."Document No.") then begin - if not Customer.Get(IntrastatReportSetup.GetPartnerNo(ServiceCrMemoHeader."Customer No.", ServiceCrMemoHeader."Bill-to Customer No.")) then - exit(''); - EU3rdPartyTrade := ServiceCrMemoHeader."EU 3-Party Trade"; - end; - ItemLedgerEntry."Document Type"::"Transfer Receipt": - if TransferReceiptHeader.Get(ItemLedgerEntry."Document No.") then - exit(GetPartnerIDForCountry(ItemLedgerEntry."Country/Region Code", TransferReceiptHeader."Partner VAT ID", false, false)); - ItemLedgerEntry."Document Type"::"Transfer Shipment": - if TransferShipmentHeader.Get(ItemLedgerEntry."Document No.") then - exit(GetPartnerIDForCountry(ItemLedgerEntry."Country/Region Code", TransferShipmentHeader."Partner VAT ID", false, false)); + InitTableNumbers(); + if TableNumbers.Get(ItemLedgerEntry."Document Type".AsInteger(), TableNo) then begin + DocRecRef.Open(TableNo); + case ItemLedgerEntry."Document Type" of + ItemLedgerEntry."Document Type"::"Transfer Receipt", ItemLedgerEntry."Document Type"::"Transfer Shipment": + begin + DocRecRef.Field(TransferHeader.FieldNo("No.")).SetRange(ItemLedgerEntry."Document No."); + DocRecRef.SetLoadFields(TransferHeader.FieldNo("Partner VAT ID")); + if DocRecRef.FindFirst() then + exit(GetPartnerIDForCountry(ItemLedgerEntry."Country/Region Code", DocRecRef.Field(TransferHeader.FieldNo("Partner VAT ID")).Value(), false, false)); + end; + ItemLedgerEntry."Document Type"::"Sales Shipment", ItemLedgerEntry."Document Type"::"Sales Invoice", + ItemLedgerEntry."Document Type"::"Sales Return Receipt", ItemLedgerEntry."Document Type"::"Sales Credit Memo", + ItemLedgerEntry."Document Type"::"Service Shipment", ItemLedgerEntry."Document Type"::"Service Invoice", + ItemLedgerEntry."Document Type"::"Service Credit Memo": + PartnerID := GetVATNoOrSource("Intrastat Report Type"::Sales, ItemLedgerEntry."Document No.", DocRecRef, PartnerNo, EU3rdPartyTrade); + ItemLedgerEntry."Document Type"::"Purchase Receipt", ItemLedgerEntry."Document Type"::"Purchase Invoice", + ItemLedgerEntry."Document Type"::"Purchase Return Shipment", ItemLedgerEntry."Document Type"::"Purchase Credit Memo": + PartnerID := GetVATNoOrSource("Intrastat Report Type"::Purchases, ItemLedgerEntry."Document No.", DocRecRef, PartnerNo, EU3rdPartyTrade); + end; end; + if PartnerID <> '' then + exit(PartnerID); + + if PartnerNo = '' then + PartnerNo := ItemLedgerEntry."Source No."; + case ItemLedgerEntry."Source Type" of ItemLedgerEntry."Source Type"::Customer: begin - if Customer."No." = '' then - if not Customer.Get(ItemLedgerEntry."Source No.") then - exit(''); + if not Customer.Get(PartnerNo) then + exit(''); IsHandled := false; OnBeforeGetCustomerPartnerIDFromItemEntry(Customer, EU3rdPartyTrade, PartnerID, IsHandled); if IsHandled then exit(PartnerID); - exit( - GetPartnerIDForCountry( - Customer."Country/Region Code", - IntrastatReportMgt.GetVATRegNo( - Customer."Country/Region Code", Customer."VAT Registration No.", IntrastatReportSetup."Cust. VAT No. on File"), - IntrastatReportMgt.IsCustomerPrivatePerson(Customer), EU3rdPartyTrade)); + exit(GetPartnerIDForCountry(Customer."Country/Region Code", IntrastatReportMgt.GetVATRegNo(Customer."Country/Region Code", Customer."VAT Registration No.", IntrastatReportSetup."Cust. VAT No. on File"), + IntrastatReportMgt.IsCustomerPrivatePerson(Customer), EU3rdPartyTrade)); end; ItemLedgerEntry."Source Type"::Vendor: begin - if Vendor."No." = '' then - if not Vendor.Get(ItemLedgerEntry."Source No.") then - exit(''); + if not Vendor.Get(PartnerNo) then + exit(''); IsHandled := false; OnBeforeGetVendorPartnerIDFromItemEntry(Vendor, PartnerID, IsHandled); if IsHandled then exit(PartnerID); - exit( - GetPartnerIDForCountry( - Vendor."Country/Region Code", - IntrastatReportMgt.GetVATRegNo( - Vendor."Country/Region Code", Vendor."VAT Registration No.", IntrastatReportSetup."Vend. VAT No. on File"), - IntrastatReportMgt.IsVendorPrivatePerson(Vendor), false)); + exit(GetPartnerIDForCountry(Vendor."Country/Region Code", IntrastatReportMgt.GetVATRegNo(Vendor."Country/Region Code", Vendor."VAT Registration No.", IntrastatReportSetup."Vend. VAT No. on File"), + IntrastatReportMgt.IsVendorPrivatePerson(Vendor), false)); end; end; end; @@ -803,33 +748,36 @@ table 4812 "Intrastat Report Line" exit(''); if not Job.Get(JobLedgerEntry."Job No.") then exit(''); - if not Customer.Get(IntrastatReportSetup.GetPartnerNo(Job."Sell-to Customer No.", Job."Bill-to Customer No.")) then - exit(''); IntrastatReportSetup.GetSetup(); + case IntrastatReportSetup."Project VAT No. Based On" of + IntrastatReportSetup."Project VAT No. Based On"::"Sell-to Customer": + if not Customer.Get(Job."Sell-to Customer No.") then + exit(''); + IntrastatReportSetup."Project VAT No. Based On"::"Bill-to Customer": + if not Customer.Get(Job."Bill-to Customer No.") then + exit(''); + end; IsHandled := false; OnBeforeGetCustomerPartnerIDFromJobEntry(Customer, PartnerID, IsHandled); if IsHandled then exit(PartnerID); - exit( - GetPartnerIDForCountry( - Customer."Country/Region Code", - IntrastatReportMgt.GetVATRegNo( - Customer."Country/Region Code", Customer."VAT Registration No.", IntrastatReportSetup."Cust. VAT No. on File"), - IntrastatReportMgt.IsCustomerPrivatePerson(Customer), false)); + exit(GetPartnerIDForCountry(Customer."Country/Region Code", IntrastatReportMgt.GetVATRegNo(Customer."Country/Region Code", Customer."VAT Registration No.", IntrastatReportSetup."Cust. VAT No. on File"), + IntrastatReportMgt.IsCustomerPrivatePerson(Customer), false)); end; local procedure GetPartnerIDFromFAEntry(): Text[50] var FALedgerEntry: Record "FA Ledger Entry"; - PurchInvHeader: Record "Purch. Inv. Header"; - PurchCrMemoHdr: Record "Purch. Cr. Memo Hdr."; Vendor: Record Vendor; + Customer: Record Customer; IntrastatReportMgt: Codeunit IntrastatReportManagement; - IsHandled: Boolean; + DocRecRef: RecordRef; + IsHandled, EU3rdPartyTrade : Boolean; PartnerID: Text[50]; + PartnerNo: Code[20]; begin IsHandled := false; OnBeforeGetPartnerIDFromFAEntry(Rec, PartnerID, IsHandled); @@ -839,30 +787,97 @@ table 4812 "Intrastat Report Line" if not FALedgerEntry.Get("Source Entry No.") then exit(''); - case FALedgerEntry."Document Type" of - FALedgerEntry."Document Type"::Invoice: - if PurchInvHeader.Get(FALedgerEntry."Document No.") then - if not Vendor.Get(IntrastatReportSetup.GetPartnerNo(PurchInvHeader."Buy-from Vendor No.", PurchInvHeader."Pay-to Vendor No.")) then + IntrastatReportSetup.GetSetup(); + + case true of + (FALedgerEntry."FA Posting Type" = FALedgerEntry."FA Posting Type"::"Acquisition Cost") and (FALedgerEntry."Document Type" = FALedgerEntry."Document Type"::Invoice): + DocRecRef.Open(Database::"Purch. Inv. Header"); + (FALedgerEntry."FA Posting Type" = FALedgerEntry."FA Posting Type"::"Acquisition Cost") and (FALedgerEntry."Document Type" = FALedgerEntry."Document Type"::"Credit Memo"): + DocRecRef.Open(Database::"Purch. Cr. Memo Hdr."); + (FALedgerEntry."FA Posting Type" = FALedgerEntry."FA Posting Type"::"Proceeds on Disposal") and (FALedgerEntry."Document Type" = FALedgerEntry."Document Type"::Invoice): + DocRecRef.Open(Database::"Sales Invoice Header"); + (FALedgerEntry."FA Posting Type" = FALedgerEntry."FA Posting Type"::"Proceeds on Disposal") and (FALedgerEntry."Document Type" = FALedgerEntry."Document Type"::"Credit Memo"): + DocRecRef.Open(Database::"Sales Cr.Memo Header"); + else + exit(''); + end; + + case DocRecRef.Number of + Database::"Purch. Inv. Header", Database::"Purch. Cr. Memo Hdr.": + begin + PartnerID := GetVATNoOrSource("Intrastat Report Type"::Purchases, FALedgerEntry."Document No.", DocRecRef, PartnerNo, EU3rdPartyTrade); + if PartnerID <> '' then + exit(PartnerID); + + if not Vendor.Get(PartnerNo) then exit(''); - FALedgerEntry."Document Type"::"Credit Memo": - if PurchCrMemoHdr.Get(FALedgerEntry."Document No.") then - if not Vendor.Get(IntrastatReportSetup.GetPartnerNo(PurchCrMemoHdr."Buy-from Vendor No.", PurchCrMemoHdr."Pay-to Vendor No.")) then + + IsHandled := false; + OnBeforeGetVendorPartnerIDFromFAEntry(Vendor, PartnerID, IsHandled); + if IsHandled then + exit(PartnerID); + + exit(GetPartnerIDForCountry(Vendor."Country/Region Code", IntrastatReportMgt.GetVATRegNo(Vendor."Country/Region Code", Vendor."VAT Registration No.", IntrastatReportSetup."Vend. VAT No. on File"), + IntrastatReportMgt.IsVendorPrivatePerson(Vendor), false)); + end; + Database::"Sales Invoice Header", Database::"Sales Cr.Memo Header": + begin + PartnerID := GetVATNoOrSource("Intrastat Report Type"::Sales, FALedgerEntry."Document No.", DocRecRef, PartnerNo, EU3rdPartyTrade); + if PartnerID <> '' then + exit(PartnerID); + + if not Customer.Get(PartnerNo) then exit(''); - end; - IntrastatReportSetup.GetSetup(); + IsHandled := false; + OnBeforeGetCustomerPartnerIDFromFAEntry(Customer, PartnerID, IsHandled); + if IsHandled then + exit(PartnerID); - IsHandled := false; - OnBeforeGetVendorPartnerIDFromFAEntry(Vendor, PartnerID, IsHandled); - if IsHandled then - exit(PartnerID); + exit(GetPartnerIDForCountry(Customer."Country/Region Code", IntrastatReportMgt.GetVATRegNo(Customer."Country/Region Code", Customer."VAT Registration No.", IntrastatReportSetup."Cust. VAT No. on File"), + IntrastatReportMgt.IsCustomerPrivatePerson(Customer), EU3rdPartyTrade)); + end; + end; + end; - exit( - GetPartnerIDForCountry( - Vendor."Country/Region Code", - IntrastatReportMgt.GetVATRegNo( - Vendor."Country/Region Code", Vendor."VAT Registration No.", IntrastatReportSetup."Vend. VAT No. on File"), - IntrastatReportMgt.IsVendorPrivatePerson(Vendor), false)); + local procedure GetVATNoOrSource(DocumentType: Enum "Intrastat Report Type"; DocumentNo: Code[20]; var DocRecRef: RecordRef; var PartnerNo: Code[20]; var EU3rdPartyTrade: Boolean): Text[50] + var + PurchaseHeader: Record "Purchase Header"; + SalesHeader: Record "Sales Header"; + IntrastatReportMgt: Codeunit IntrastatReportManagement; + begin + case DocumentType of + DocumentType::Purchases: + begin + DocRecRef.Field(PurchaseHeader.FieldNo("No.")).SetRange(DocumentNo); + DocRecRef.SetLoadFields(PurchaseHeader.FieldNo("Buy-from Vendor No."), PurchaseHeader.FieldNo("Pay-to Vendor No."), PurchaseHeader.FieldNo("VAT Registration No."), PurchaseHeader.FieldNo("VAT Country/Region Code")); + if DocRecRef.FindFirst() then + case IntrastatReportSetup."Purchase VAT No. Based On" of + IntrastatReportSetup."Purchase VAT No. Based On"::Document: + exit(IntrastatReportMgt.GetVATRegNo(DocRecRef.Field(PurchaseHeader.FieldNo("VAT Country/Region Code")).Value(), DocRecRef.Field(PurchaseHeader.FieldNo("VAT Registration No.")).Value(), IntrastatReportSetup."Vend. VAT No. on File")); + IntrastatReportSetup."Purchase VAT No. Based On"::"Buy-from VAT": + PartnerNo := DocRecRef.Field(PurchaseHeader.FieldNo("Buy-from Vendor No.")).Value(); + IntrastatReportSetup."Purchase VAT No. Based On"::"Pay-to VAT": + PartnerNo := DocRecRef.Field(PurchaseHeader.FieldNo("Pay-to Vendor No.")).Value(); + end; + end; + DocumentType::Sales: + begin + DocRecRef.Field(SalesHeader.FieldNo("No.")).SetRange(DocumentNo); + DocRecRef.SetLoadFields(SalesHeader.FieldNo("Sell-to Customer No."), SalesHeader.FieldNo("Bill-to Customer No."), SalesHeader.FieldNo("VAT Registration No."), SalesHeader.FieldNo("EU 3-Party Trade"), SalesHeader.FieldNo("VAT Country/Region Code")); + if DocRecRef.FindFirst() then begin + case IntrastatReportSetup."Sales VAT No. Based On" of + IntrastatReportSetup."Sales VAT No. Based On"::Document: + exit(IntrastatReportMgt.GetVATRegNo(DocRecRef.Field(SalesHeader.FieldNo("VAT Country/Region Code")).Value(), DocRecRef.Field(SalesHeader.FieldNo("VAT Registration No.")).Value(), IntrastatReportSetup."Cust. VAT No. on File")); + IntrastatReportSetup."Sales VAT No. Based On"::"Sell-to VAT": + PartnerNo := DocRecRef.Field(SalesHeader.FieldNo("Sell-to Customer No.")).Value(); + IntrastatReportSetup."Sales VAT No. Based On"::"Bill-to VAT": + PartnerNo := DocRecRef.Field(SalesHeader.FieldNo("Bill-to Customer No.")).Value(); + end; + EU3rdPartyTrade := DocRecRef.Field(SalesHeader.FieldNo("EU 3-Party Trade")).Value(); + end; + end; + end; end; local procedure GetPartnerIDForCountry(CountryRegionCode: Code[10]; VATRegistrationNo: Text[50]; IsPrivatePerson: Boolean; IsThirdPartyTrade: Boolean): Text[50] @@ -890,16 +905,31 @@ table 4812 "Intrastat Report Line" exit(IntrastatReportSetup."Def. VAT for Unknown State"); end; - procedure SetIntrastatReportHeaderFilters(var IntrastatReportHeader2: Record "Intrastat Report Header") + procedure SetIntrastatReportHeaderFilters(var IntrastatReportHeaderWithFiltersSet: Record "Intrastat Report Header") var - IntrastatReportHeader3: Record "Intrastat Report Header"; + IntrastatReportHeaderForLine: Record "Intrastat Report Header"; begin - IntrastatReportHeader3.Get("Intrastat No."); - IntrastatReportHeader2.SetRange("Corrective Entry", false); - IntrastatReportHeader2.SetRange(Reported, true); - IntrastatReportHeader2.SetRange("EU Service", IntrastatReportHeader3."EU Service"); - IntrastatReportHeader2.SetRange(Periodicity, IntrastatReportHeader3.Periodicity); - IntrastatReportHeader2.SetRange(Type, IntrastatReportHeader3.Type); + IntrastatReportHeaderForLine.SetLoadFields("EU Service", Periodicity, Type); + IntrastatReportHeaderForLine.Get("Intrastat No."); + IntrastatReportHeaderWithFiltersSet.SetRange("Corrective Entry", false); + IntrastatReportHeaderWithFiltersSet.SetRange(Reported, true); + IntrastatReportHeaderWithFiltersSet.SetRange("EU Service", IntrastatReportHeaderForLine."EU Service"); + IntrastatReportHeaderWithFiltersSet.SetRange(Periodicity, IntrastatReportHeaderForLine.Periodicity); + IntrastatReportHeaderWithFiltersSet.SetRange(Type, IntrastatReportHeaderForLine.Type); + + OnAfterSetIntrastatReportHeaderFilters(IntrastatReportHeaderWithFiltersSet, IntrastatReportHeaderForLine); + end; + + local procedure InitTableNumbers() + begin + if TableNumbers.Count() = 0 then + TableNumbers.AddRange(Database::"Sales Shipment Header", Database::"Sales Invoice Header", + Database::"Return Receipt Header", Database::"Sales Cr.Memo Header", + Database::"Purch. Rcpt. Header", Database::"Purch. Inv. Header", + Database::"Return Shipment Header", Database::"Purch. Cr. Memo Hdr.", + Database::"Transfer Shipment Header", Database::"Transfer Receipt Header", + Database::"Service Shipment Header", Database::"Service Invoice Header", + Database::"Service Cr.Memo Header"); end; [IntegrationEvent(false, false)] @@ -957,6 +987,11 @@ table 4812 "Intrastat Report Line" begin end; + [IntegrationEvent(false, false)] + local procedure OnBeforeGetCustomerPartnerIDFromFAEntry(var Customer: Record Customer; var PartnerID: Text[50]; var IsHandled: Boolean) + begin + end; + [IntegrationEvent(false, false)] local procedure OnBeforeGetPartnerIDForCountry(CountryRegionCode: Code[10]; VATRegistrationNo: Text[50]; IsPrivatePerson: Boolean; IsThirdPartyTrade: Boolean; var PartnerID: Text[50]; var IsHandled: Boolean) begin @@ -966,4 +1001,9 @@ table 4812 "Intrastat Report Line" local procedure OnBeforeCheckDateInRange(var IntrastatReportLine: Record "Intrastat Report Line"; var IsHandled: Boolean); begin end; + + [IntegrationEvent(false, false)] + local procedure OnAfterSetIntrastatReportHeaderFilters(var IntrastatReportHeaderWithFiltersSet: Record "Intrastat Report Header"; IntrastatReportHeaderForLine: Record "Intrastat Report Header") + begin + end; } \ No newline at end of file diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportLineType.Enum.al b/Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportLineType.Enum.al similarity index 100% rename from Apps/W1/Intrastat/app/src/IntrastatReportLineType.Enum.al rename to Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportLineType.Enum.al diff --git a/Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportLines.Page.al b/Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportLines.Page.al new file mode 100644 index 0000000000..24fc8363a4 --- /dev/null +++ b/Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportLines.Page.al @@ -0,0 +1,77 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Inventory.Intrastat; + +page 4816 "Intrastat Report Lines" +{ + ApplicationArea = All; + Caption = 'Intrastat Report Lines'; + Editable = false; + PageType = List; + SourceTable = "Intrastat Report Line"; + + layout + { + area(content) + { + repeater(Control1) + { + ShowCaption = false; + field(Type; Rec.Type) { } + field(Date; Rec.Date) { } + field("Document No."; Rec."Document No.") + { + ShowMandatory = true; + } + field("Item No."; Rec."Item No.") { } + field(Name; Rec."Item Name") { } + field("Tariff No."; Rec."Tariff No.") { } + field("Item Description"; Rec."Tariff Description") { } + field("Country/Region Code"; Rec."Country/Region Code") { } + field("Partner VAT ID"; Rec."Partner VAT ID") { } + field("Country/Region of Origin Code"; Rec."Country/Region of Origin Code") { } + field("Area"; Rec.Area) + { + Visible = false; + } + field("Transaction Type"; Rec."Transaction Type") { } + field("Transaction Specification"; Rec."Transaction Specification") + { + Visible = false; + } + field("Transport Method"; Rec."Transport Method") { } + field("Entry/Exit Point"; Rec."Entry/Exit Point") + { + Visible = false; + } + field("Supplementary Units"; Rec."Supplementary Units") { } + field(Quantity; Rec.Quantity) { } + field("Net Weight"; Rec."Net Weight") { } + field("Total Weight"; Rec."Total Weight") { } + field(Amount; Rec.Amount) { } + field("Statistical Value"; Rec."Statistical Value") { } + field("Source Type"; Rec."Source Type") { } + field("Source Entry No."; Rec."Source Entry No.") + { + Editable = false; + } + field("Cost Regulation %"; Rec."Cost Regulation %") + { + Visible = false; + } + field("Indirect Cost"; Rec."Indirect Cost") + { + Visible = false; + } + field("Internal Ref. No."; Rec."Internal Ref. No.") { } + field("Shpt. Method Code"; Rec."Shpt. Method Code") { } + field("Location Code"; Rec."Location Code") { } + field("Suppl. Conversion Factor"; Rec."Suppl. Conversion Factor") { } + field("Suppl. Unit of Measure"; Rec."Suppl. Unit of Measure") { } + field("Supplementary Quantity"; Rec."Supplementary Quantity") { } + } + } + } +} \ No newline at end of file diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportList.Page.al b/Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportList.Page.al similarity index 50% rename from Apps/W1/Intrastat/app/src/IntrastatReportList.Page.al rename to Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportList.Page.al index 54339c1204..53cf596813 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReportList.Page.al +++ b/Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportList.Page.al @@ -17,31 +17,15 @@ page 4811 "Intrastat Report List" repeater(Control1) { ShowCaption = false; - field("No."; Rec."No.") - { - ToolTip = 'Specifies the Intrastat Report number.'; - } - field(Description; Rec.Description) - { - ToolTip = 'Specifies some information about the Intrastat Report.'; - } - field("Statistics Period"; Rec."Statistics Period") - { - ToolTip = 'Specifies the month to report data for. Enter the period as a four-digit number, with no spaces or symbols. Enter the year first and then the month, for example, enter 1706 for June, 2017.'; - } - field("Currency Identifier"; Rec."Currency Identifier") - { - ToolTip = 'Specifies a code that identifies the currency of the Intrastat Report.'; - } + field("No."; Rec."No.") { } + field(Description; Rec.Description) { } + field("Statistics Period"; Rec."Statistics Period") { } + field("Currency Identifier"; Rec."Currency Identifier") { } field("Amounts in Add. Currency"; Rec."Amounts in Add. Currency") { - ToolTip = 'Specifies that you use an additional reporting currency in the general ledger and that you want to report Intrastat in this currency.'; Visible = false; } - field(Reported; Rec.Reported) - { - ToolTip = 'Specifies whether the entry has already been reported to the tax authorities.'; - } + field(Reported; Rec.Reported) { } } } area(factboxes) diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportPeriodicity.Enum.al b/Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportPeriodicity.Enum.al similarity index 100% rename from Apps/W1/Intrastat/app/src/IntrastatReportPeriodicity.Enum.al rename to Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportPeriodicity.Enum.al diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportSourceType.Enum.al b/Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportSourceType.Enum.al similarity index 100% rename from Apps/W1/Intrastat/app/src/IntrastatReportSourceType.Enum.al rename to Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportSourceType.Enum.al diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportStatSystem.Enum.al b/Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportStatSystem.Enum.al similarity index 100% rename from Apps/W1/Intrastat/app/src/IntrastatReportStatSystem.Enum.al rename to Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportStatSystem.Enum.al diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportStatus.Enum.al b/Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportStatus.Enum.al similarity index 100% rename from Apps/W1/Intrastat/app/src/IntrastatReportStatus.Enum.al rename to Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportStatus.Enum.al diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportSubform.Page.al b/Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportSubform.Page.al similarity index 60% rename from Apps/W1/Intrastat/app/src/IntrastatReportSubform.Page.al rename to Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportSubform.Page.al index c9b61ae847..44733c6274 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReportSubform.Page.al +++ b/Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportSubform.Page.al @@ -28,141 +28,68 @@ page 4813 "Intrastat Report Subform" field(Type; Rec.Type) { StyleExpr = LineStyleExpression; - ToolTip = 'Specifies whether the item was received or shipped by the company.'; } field(Date; Rec.Date) { StyleExpr = LineStyleExpression; - ToolTip = 'Specifies the date the item entry was posted.'; } field("Document No."; Rec."Document No.") { StyleExpr = LineStyleExpression; - ToolTip = 'Specifies the document number on the entry.'; ShowMandatory = true; } field("Item No."; Rec."Item No.") { StyleExpr = LineStyleExpression; - ToolTip = 'Specifies the number of the item.'; } field(Name; Rec."Item Name") { StyleExpr = LineStyleExpression; - ToolTip = 'Specifies the name of the item.'; - Caption = 'Item Name'; - } - field("Tariff No."; Rec."Tariff No.") - { - ToolTip = 'Specifies the item''s tariff number.'; - } - field("Item Description"; Rec."Tariff Description") - { - ToolTip = 'Specifies the name of the tariff no. that is associated with the item.'; - Caption = 'Tariff No. Description'; - } - field("Country/Region Code"; Rec."Country/Region Code") - { - ToolTip = 'Specifies the country/region of the address.'; - } - field("Partner VAT ID"; Rec."Partner VAT ID") - { - ToolTip = 'Specifies the counter party''s VAT number.'; - } - field("Country/Region of Origin Code"; Rec."Country/Region of Origin Code") - { - ToolTip = 'Specifies a code for the country/region where the item was produced or processed.'; } + field("Tariff No."; Rec."Tariff No.") { } + field("Item Description"; Rec."Tariff Description") { } + field("Country/Region Code"; Rec."Country/Region Code") { } + field("Partner VAT ID"; Rec."Partner VAT ID") { } + field("Country/Region of Origin Code"; Rec."Country/Region of Origin Code") { } field("Area"; Rec.Area) { - ToolTip = 'Specifies the area of the customer or vendor, for the purpose of reporting to INTRASTAT.'; Visible = false; } - field("Transaction Type"; Rec."Transaction Type") - { - ToolTip = 'Specifies the type of transaction that the document represents, for the purpose of reporting to INTRASTAT.'; - } + field("Transaction Type"; Rec."Transaction Type") { } field("Transaction Specification"; Rec."Transaction Specification") { - ToolTip = 'Specifies a specification of the document''s transaction, for the purpose of reporting to INTRASTAT.'; Visible = false; } - field("Transport Method"; Rec."Transport Method") - { - ToolTip = 'Specifies the transport method, for the purpose of reporting to INTRASTAT.'; - } + field("Transport Method"; Rec."Transport Method") { } field("Entry/Exit Point"; Rec."Entry/Exit Point") { - ToolTip = 'Specifies the code of either the port of entry where the items passed into your country/region or the port of exit.'; Visible = false; } - field("Supplementary Units"; Rec."Supplementary Units") - { - ToolTip = 'Specifies if you must report information about quantity and units of measure for this item.'; - } - field(Quantity; Rec.Quantity) - { - ToolTip = 'Specifies the number of units of the item in the entry.'; - } - field("Net Weight"; Rec."Net Weight") - { - ToolTip = 'Specifies the net weight of one unit of the item.'; - } - field("Total Weight"; Rec."Total Weight") - { - ToolTip = 'Specifies the total weight for the items in the item entry.'; - } - field(Amount; Rec.Amount) - { - ToolTip = 'Specifies the total amount of the entry, excluding VAT.'; - } - field("Statistical Value"; Rec."Statistical Value") - { - ToolTip = 'Specifies the entry''s statistical value, which must be reported to the statistics authorities.'; - } - field("Source Type"; Rec."Source Type") - { - ToolTip = 'Specifies the entry type.'; - } + field("Supplementary Units"; Rec."Supplementary Units") { } + field(Quantity; Rec.Quantity) { } + field("Net Weight"; Rec."Net Weight") { } + field("Total Weight"; Rec."Total Weight") { } + field(Amount; Rec.Amount) { } + field("Statistical Value"; Rec."Statistical Value") { } + field("Source Type"; Rec."Source Type") { } field("Source Entry No."; Rec."Source Entry No.") { - ToolTip = 'Specifies the number that the item entry had in the table it came from.'; Editable = false; } field("Cost Regulation %"; Rec."Cost Regulation %") { - ToolTip = 'Specifies any indirect costs, as a percentage.'; Visible = false; } field("Indirect Cost"; Rec."Indirect Cost") { - ToolTip = 'Specifies an amount that represents the costs for freight and insurance.'; Visible = false; } - field("Internal Ref. No."; Rec."Internal Ref. No.") - { - ToolTip = 'Specifies a reference number used by the customs and tax authorities.'; - } - field("Shpt. Method Code"; Rec."Shpt. Method Code") - { - ToolTip = 'Specifies the item''s shipment method.'; - } - field("Location Code"; Rec."Location Code") - { - ToolTip = 'Specifies the code for the location that the entry is linked to.'; - } - field("Suppl. Conversion Factor"; Rec."Suppl. Conversion Factor") - { - ToolTip = 'Specifies the conversion factor of the item on this Intrastat report line.'; - } - field("Suppl. Unit of Measure"; Rec."Suppl. Unit of Measure") - { - ToolTip = 'Specifies the unit of measure code for the tariff number on this line.'; - } - field("Supplementary Quantity"; Rec."Supplementary Quantity") - { - ToolTip = 'Specifies the quantity of supplementary units on the Intrastat line.'; - } + field("Internal Ref. No."; Rec."Internal Ref. No.") { } + field("Shpt. Method Code"; Rec."Shpt. Method Code") { } + field("Location Code"; Rec."Location Code") { } + field("Suppl. Conversion Factor"; Rec."Suppl. Conversion Factor") { } + field("Suppl. Unit of Measure"; Rec."Suppl. Unit of Measure") { } + field("Supplementary Quantity"; Rec."Supplementary Quantity") { } } group(Control40) { diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportType.Enum.al b/Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportType.Enum.al similarity index 100% rename from Apps/W1/Intrastat/app/src/IntrastatReportType.Enum.al rename to Apps/W1/Intrastat/app/src/IntrastatReport/IntrastatReportType.Enum.al diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportLines.Page.al b/Apps/W1/Intrastat/app/src/IntrastatReportLines.Page.al deleted file mode 100644 index 7a336c17b9..0000000000 --- a/Apps/W1/Intrastat/app/src/IntrastatReportLines.Page.al +++ /dev/null @@ -1,158 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.Inventory.Intrastat; - -page 4816 "Intrastat Report Lines" -{ - ApplicationArea = All; - Caption = 'Intrastat Report Lines'; - Editable = false; - PageType = List; - SourceTable = "Intrastat Report Line"; - - layout - { - area(content) - { - repeater(Control1) - { - ShowCaption = false; - field(Type; Rec.Type) - { - ToolTip = 'Specifies whether the item was received or shipped by the company.'; - } - field(Date; Rec.Date) - { - ToolTip = 'Specifies the date the item entry was posted.'; - } - field("Document No."; Rec."Document No.") - { - ToolTip = 'Specifies the document number on the entry.'; - ShowMandatory = true; - } - field("Item No."; Rec."Item No.") - { - ToolTip = 'Specifies the number of the item.'; - } - field(Name; Rec."Item Name") - { - ToolTip = 'Specifies the name of the item.'; - Caption = 'Item Name'; - } - field("Tariff No."; Rec."Tariff No.") - { - ToolTip = 'Specifies the item''s tariff number.'; - } - field("Item Description"; Rec."Tariff Description") - { - ToolTip = 'Specifies the name of the tariff no. that is associated with the item.'; - Caption = 'Tariff No. Description'; - } - field("Country/Region Code"; Rec."Country/Region Code") - { - ToolTip = 'Specifies the country/region of the address.'; - } - field("Partner VAT ID"; Rec."Partner VAT ID") - { - ToolTip = 'Specifies the counter party''s VAT number.'; - } - field("Country/Region of Origin Code"; Rec."Country/Region of Origin Code") - { - ToolTip = 'Specifies a code for the country/region where the item was produced or processed.'; - } - field("Area"; Rec.Area) - { - ToolTip = 'Specifies the area of the customer or vendor, for the purpose of reporting to INTRASTAT.'; - Visible = false; - } - field("Transaction Type"; Rec."Transaction Type") - { - ToolTip = 'Specifies the type of transaction that the document represents, for the purpose of reporting to INTRASTAT.'; - } - field("Transaction Specification"; Rec."Transaction Specification") - { - ToolTip = 'Specifies a specification of the document''s transaction, for the purpose of reporting to INTRASTAT.'; - Visible = false; - } - field("Transport Method"; Rec."Transport Method") - { - ToolTip = 'Specifies the transport method, for the purpose of reporting to INTRASTAT.'; - } - field("Entry/Exit Point"; Rec."Entry/Exit Point") - { - ToolTip = 'Specifies the code of either the port of entry where the items passed into your country/region or the port of exit.'; - Visible = false; - } - field("Supplementary Units"; Rec."Supplementary Units") - { - ToolTip = 'Specifies if you must report information about quantity and units of measure for this item.'; - } - field(Quantity; Rec.Quantity) - { - ToolTip = 'Specifies the number of units of the item in the entry.'; - } - field("Net Weight"; Rec."Net Weight") - { - ToolTip = 'Specifies the net weight of one unit of the item.'; - } - field("Total Weight"; Rec."Total Weight") - { - ToolTip = 'Specifies the total weight for the items in the item entry.'; - } - field(Amount; Rec.Amount) - { - ToolTip = 'Specifies the total amount of the entry, excluding VAT.'; - } - field("Statistical Value"; Rec."Statistical Value") - { - ToolTip = 'Specifies the entry''s statistical value, which must be reported to the statistics authorities.'; - } - field("Source Type"; Rec."Source Type") - { - ToolTip = 'Specifies the entry type.'; - } - field("Source Entry No."; Rec."Source Entry No.") - { - ToolTip = 'Specifies the number that the item entry had in the table it came from.'; - Editable = false; - } - field("Cost Regulation %"; Rec."Cost Regulation %") - { - ToolTip = 'Specifies any indirect costs, as a percentage.'; - Visible = false; - } - field("Indirect Cost"; Rec."Indirect Cost") - { - ToolTip = 'Specifies an amount that represents the costs for freight and insurance.'; - Visible = false; - } - field("Internal Ref. No."; Rec."Internal Ref. No.") - { - ToolTip = 'Specifies a reference number used by the customs and tax authorities.'; - } - field("Shpt. Method Code"; Rec."Shpt. Method Code") - { - ToolTip = 'Specifies the item''s shipment method.'; - } - field("Location Code"; Rec."Location Code") - { - ToolTip = 'Specifies the code for the location that the entry is linked to.'; - } - field("Suppl. Conversion Factor"; Rec."Suppl. Conversion Factor") - { - ToolTip = 'Specifies the conversion factor of the item on this Intrastat report line.'; - } - field("Suppl. Unit of Measure"; Rec."Suppl. Unit of Measure") - { - ToolTip = 'Specifies the unit of measure code for the tariff number on this line.'; - } - field("Supplementary Quantity"; Rec."Supplementary Quantity") - { - ToolTip = 'Specifies the quantity of supplementary units on the Intrastat line.'; - } - } - } - } -} \ No newline at end of file diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportDocCompl.Codeunit.al b/Apps/W1/Intrastat/app/src/Processing/IntrastatReportDocCompl.Codeunit.al similarity index 100% rename from Apps/W1/Intrastat/app/src/IntrastatReportDocCompl.Codeunit.al rename to Apps/W1/Intrastat/app/src/Processing/IntrastatReportDocCompl.Codeunit.al diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportExpExternal.Codeunit.al b/Apps/W1/Intrastat/app/src/Processing/IntrastatReportExpExternal.Codeunit.al similarity index 100% rename from Apps/W1/Intrastat/app/src/IntrastatReportExpExternal.Codeunit.al rename to Apps/W1/Intrastat/app/src/Processing/IntrastatReportExpExternal.Codeunit.al diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportGetLines.Report.al b/Apps/W1/Intrastat/app/src/Processing/IntrastatReportGetLines.Report.al similarity index 97% rename from Apps/W1/Intrastat/app/src/IntrastatReportGetLines.Report.al rename to Apps/W1/Intrastat/app/src/Processing/IntrastatReportGetLines.Report.al index 8c02a4b5bd..ee9fcd5f93 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReportGetLines.Report.al +++ b/Apps/W1/Intrastat/app/src/Processing/IntrastatReportGetLines.Report.al @@ -770,7 +770,7 @@ report 4810 "Intrastat Report Get Lines" GLSetupRead := true; end; - local procedure CalculateAverageCost(var AverageCost: Decimal; var AverageCostACY: Decimal): Boolean + local procedure CalculateAverageCost(var AvgCost: Decimal; var AvgCostACY: Decimal): Boolean var ValueEntry2: Record "Value Entry"; ItemLedgEntry: Record "Item Ledger Entry"; @@ -794,19 +794,19 @@ report 4810 "Intrastat Report Get Lines" CurrExchRate.ExchangeAmtLCYToFCY( EndDate, GLSetup."Additional Reporting Currency", ValueEntry2."Cost Amount (Expected)", AddCurrencyFactor); AverageQty := ItemLedgEntry.Quantity; - AverageCost := ValueEntry2."Cost Amount (Actual)" + ValueEntry2."Cost Amount (Expected)"; - AverageCostACY := ValueEntry2."Cost Amount (Actual) (ACY)" + ValueEntry2."Cost Amount (Expected) (ACY)"; + AvgCost := ValueEntry2."Cost Amount (Actual)" + ValueEntry2."Cost Amount (Expected)"; + AvgCostACY := ValueEntry2."Cost Amount (Actual) (ACY)" + ValueEntry2."Cost Amount (Expected) (ACY)"; if AverageQty <> 0 then begin - AverageCost := AverageCost / AverageQty; - AverageCostACY := AverageCostACY / AverageQty; - if (AverageCost < 0) or (AverageCostACY < 0) then begin - AverageCost := 0; - AverageCostACY := 0; + AvgCost := AvgCost / AverageQty; + AvgCostACY := AvgCostACY / AverageQty; + if (AvgCost < 0) or (AvgCostACY < 0) then begin + AvgCost := 0; + AvgCostACY := 0; end; end else begin - AverageCost := 0; - AverageCostACY := 0; + AvgCost := 0; + AvgCostACY := 0; end; exit(AverageQty >= 0); @@ -1220,34 +1220,34 @@ report 4810 "Intrastat Report Get Lines" exit(not ItemApplicationEntry.IsEmpty); end; - local procedure SetCountryRegionCode(var IntrastatReportLine: Record "Intrastat Report Line"; ItemLedgerEntry: Record "Item Ledger Entry") + local procedure SetCountryRegionCode(var IntrastatReportLine3: Record "Intrastat Report Line"; ItemLedgerEntry: Record "Item Ledger Entry") var Location: Record Location; begin - if (IntrastatReportLine."Country/Region Code" = '') or - (IntrastatReportLine."Country/Region Code" = CompanyInfo."Country/Region Code") + if (IntrastatReportLine3."Country/Region Code" = '') or + (IntrastatReportLine3."Country/Region Code" = CompanyInfo."Country/Region Code") then if ItemLedgerEntry."Location Code" = '' then - IntrastatReportLine."Country/Region Code" := CompanyInfo."Ship-to Country/Region Code" + IntrastatReportLine3."Country/Region Code" := CompanyInfo."Ship-to Country/Region Code" else begin Location.Get(ItemLedgerEntry."Location Code"); - IntrastatReportLine."Country/Region Code" := Location."Country/Region Code" + IntrastatReportLine3."Country/Region Code" := Location."Country/Region Code" end; end; #if not CLEAN24 - local procedure SetJnlLineType(var IntrastatReportLine: Record "Intrastat Report Line"; ValueEntryDocumentType: Enum "Item Ledger Document Type") + local procedure SetJnlLineType(var IntrastatReportLine3: Record "Intrastat Report Line"; ValueEntryDocumentType: Enum "Item Ledger Document Type") begin - if IntrastatReportLine.Quantity < 0 then begin + if IntrastatReportLine3.Quantity < 0 then begin if ValueEntryDocumentType = "Value Entry"."Document Type"::"Sales Credit Memo" then - IntrastatReportLine.Type := IntrastatReportLine.Type::Receipt + IntrastatReportLine3.Type := IntrastatReportLine3.Type::Receipt else - IntrastatReportLine.Type := IntrastatReportLine.Type::Shipment + IntrastatReportLine3.Type := IntrastatReportLine3.Type::Shipment end else if ValueEntryDocumentType = "Value Entry"."Document Type"::"Purchase Credit Memo" then - IntrastatReportLine.Type := IntrastatReportLine.Type::Shipment + IntrastatReportLine3.Type := IntrastatReportLine3.Type::Shipment else - IntrastatReportLine.Type := IntrastatReportLine.Type::Receipt; + IntrastatReportLine3.Type := IntrastatReportLine3.Type::Receipt; end; #endif diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportItemTracking.Codeunit.al b/Apps/W1/Intrastat/app/src/Processing/IntrastatReportItemTracking.Codeunit.al similarity index 100% rename from Apps/W1/Intrastat/app/src/IntrastatReportItemTracking.Codeunit.al rename to Apps/W1/Intrastat/app/src/Processing/IntrastatReportItemTracking.Codeunit.al diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportManagement.Codeunit.al b/Apps/W1/Intrastat/app/src/Processing/IntrastatReportManagement.Codeunit.al similarity index 99% rename from Apps/W1/Intrastat/app/src/IntrastatReportManagement.Codeunit.al rename to Apps/W1/Intrastat/app/src/Processing/IntrastatReportManagement.Codeunit.al index b099a81d8b..5a0c55803c 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReportManagement.Codeunit.al +++ b/Apps/W1/Intrastat/app/src/Processing/IntrastatReportManagement.Codeunit.al @@ -16,41 +16,33 @@ codeunit 4810 IntrastatReportManagement ReceptFileNameLbl: Label 'Receipt-%1.txt', Comment = '%1 - Statistics Period'; ShipmentFileNameLbl: Label 'Shipment-%1.txt', Comment = '%1 - Statistics Period'; ZipFileNameLbl: Label 'Intrastat-%1.zip', Comment = '%1 - Statistics Period'; -#pragma warning disable AS0072 #if not CLEAN25 FeatureNotEnabledMessageTxt: Label 'The %1 page is part of the new Intrastat Report feature, which is not yet enabled in your Business Central. An administrator can enable the feature on the Feature Management page.', Comment = '%1 - page caption'; NewFeatureEnabledMessageTxt: Label 'The Intrastat Report extension is enabled, which means you can''t use the %1 page. You''ve been redirected to the %2 page for the extension.', Comment = '%1 - old page caption, %2 - new page caption'; #endif -#pragma warning restore AS0072 DisableNotificationTxt: Label 'Disable this notification'; -#pragma warning disable AS0072 #if not CLEAN25 LearnMoreTxt: Label 'Learn more'; IntrastatAwarenessNotificationNameTxt: Label 'Notify the user about the Intrastat Report extension.'; IntrastatAwarenessNotificationDescriptionTxt: Label 'Alert users about the capabilities of the Intrastat Report extension.'; IntrastatAwarenessNotificationTxt: Label 'This version of Intrastat will be deprecated. We recommend that you enable the Intrastat Report extension.'; #endif -#pragma warning restore AS0072 SupplementaryUnitUpdateNotificationNameTxt: Label 'Notify the user about the %1 update.', Comment = '%1 - Supplementary Unit of Measure caption'; SupplementaryUnitUpdateNotificationDescriptionTxt: Label 'Alert users about the update of %1 during %2 change.', Comment = '%1 - Supplementary Unit of Measure caption, %2 - Tariff Number caption'; SupplementaryUnitUpdateNotificationTxt: Label '%1 was updated, due to change of %2.', Comment = '%1 - Supplementary Unit of Measure caption, %2 - Tariff Number caption'; ImportDefaultIntrastatDataExchDefConfirmQst: Label 'This will create the default Intrastat %1 . \\All existing default Intrastat %1 will be overwritten.\\Do you want to continue?', Comment = '%1 - Data Exchange Definition caption'; AssistedSetupTxt: Label 'Set up Intrastat reporting'; AssistedSetupDescriptionTxt: Label 'The Intrastat reporting makes it easy to export the Intrastat report in the format that the authorities in your country require.'; -#pragma warning disable AS0072 #if not CLEAN25 UserDisabledNotificationTxt: Label 'The user disabled notification %1.', Locked = true; IntrastatFeatureKeyIdTok: Label 'ReplaceIntrastat', Locked = true; IntrastatFeatureAwarenessNotificationIdTok: Label 'dcd4e71a-8c6a-44fc-9642-54f931e5e7d9', Locked = true; #endif -#pragma warning restore AS0072 SupplementaryUnitUpdateNotificationIdTok: Label '52f2c034-1857-4922-99cb-448c09e01474', Locked = true; -#pragma warning disable AS0072 #if not CLEAN25 IntrastatCoreAppIdTok: Label '70912191-3c4c-49fc-a1de-bc6ea1ac9da6', Locked = true; IntrastatTelemetryCategoryTok: Label 'AL Intrastat', Locked = true; #endif -#pragma warning restore AS0072 LearnMoreLinkTok: Label 'https://go.microsoft.com/fwlink/?linkid=2283605', Locked = true; RangeCrossingErr: Label 'There is a conflict in checklist rules for ''%1'' in ''%2'' (field must be both blank and not blank). Please review filters in %3.', Comment = '%1=caption of a field, %2=key of record, %3=caption of report checklist page'; DataExchangeXMLTxt: Label 'TRIMALLRemoves all spaces5&#032;0000000.00ALPHANUMERIC_ONLYAlphanumeric Text Only70000000.00ROUNDTOINTRound to integer14&#032;00ALPHANUMERIC_ONLY00001.00=ALPHANUMERIC_ONLYAlphanumeric Text Only70000000.00ROUNDUPTOINTRound up to integer14&#032;00ALPHANUMERIC_ONLY00001.00>ALPHANUMERIC_ONLYAlphanumeric Text Only70000000.00ROUNDTOINTRound to integer14&#032;00ALPHANUMERIC_ONLY00001.00=EUCOUNTRYCODELOOKUPEU Country Lookup13&#032;0091710.00', @@ -492,6 +484,7 @@ codeunit 4810 IntrastatReportManagement else SupplConversionFactor := 0; NetWeight := Item."Net Weight"; + OnRecalculateWeightAndSupplUOMQtyOnAfterCalculateNetWeight(IntrastatReportLine, NetWeight); end; if Selection <> 1 then begin @@ -821,6 +814,7 @@ codeunit 4810 IntrastatReportManagement if not IsHandled then begin IntrastatReportSetup."Shipments Based On" := IntrastatReportSetup."Shipments Based On"::"Ship-to Country"; IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Shipment; + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::Document; IntrastatReportSetup."Def. Private Person VAT No." := 'QV999999999999'; IntrastatReportSetup."Def. 3-Party Trade VAT No." := 'QV999999999999'; IntrastatReportSetup."Def. VAT for Unknown State" := 'QV999999999999'; @@ -922,7 +916,6 @@ codeunit 4810 IntrastatReportManagement ItemUOM.Modify(true); end; -#pragma warning disable AS0072 #if not CLEAN25 [Obsolete('Pending removal.', '25.0')] procedure IsFeatureEnabled() IsEnabled: Boolean @@ -969,7 +962,6 @@ codeunit 4810 IntrastatReportManagement Session.LogMessage('0000I9Q', StrSubstNo(UserDisabledNotificationTxt, HostNotification.GetData('NotificationId')), Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', IntrastatTelemetryCategoryTok); end; #endif -#pragma warning restore AS0072 internal procedure NotifyUserAboutSupplementaryUnitUpdate() var Item: Record Item; @@ -1000,7 +992,6 @@ codeunit 4810 IntrastatReportManagement StrSubstNo(SupplementaryUnitUpdateNotificationDescriptionTxt, Item.FieldCaption("Supplementary Unit of Measure"), Item.FieldCaption("Tariff No.")), false); end; -#pragma warning disable AS0072 #if not CLEAN25 [Obsolete('Pending removal.', '25.0')] procedure ShowNotEnabledMessage(PageCaption: Text) @@ -1014,7 +1005,6 @@ codeunit 4810 IntrastatReportManagement Message(NewFeatureEnabledMessageTxt, OldPageCaption, NewPageCaption); end; #endif -#pragma warning restore AS0072 procedure IsCustomerPrivatePerson(Customer: Record Customer): Boolean; begin if Customer."Intrastat Partner Type" <> "Partner Type"::" " then @@ -1031,7 +1021,6 @@ codeunit 4810 IntrastatReportManagement exit(Vendor."Partner Type" = "Partner Type"::Person); end; -#pragma warning disable AS0072 #if not CLEAN25 [Obsolete('Pending removal.', '25.0')] local procedure GetIntrastatFeatureKeyId(): Text[50] @@ -1045,13 +1034,11 @@ codeunit 4810 IntrastatReportManagement exit(IntrastatFeatureAwarenessNotificationIdTok); end; #endif -#pragma warning restore AS0072 local procedure GetSupplementaryUnitUpdateNotificationId(): Guid; begin exit(SupplementaryUnitUpdateNotificationIdTok); end; -#pragma warning disable AS0072 #if not CLEAN25 [Obsolete('Pending removal.', '25.0')] local procedure GetAppId(): Guid; @@ -1067,7 +1054,6 @@ codeunit 4810 IntrastatReportManagement exit(NAVAppInstalledApp.Get(AppID)); end; #endif -#pragma warning restore AS0072 [EventSubscriber(ObjectType::Codeunit, Codeunit::"Guided Experience", 'OnRegisterAssistedSetup', '', true, true)] local procedure InsertIntoAssistedSetup() var @@ -1129,7 +1115,6 @@ codeunit 4810 IntrastatReportManagement begin end; -#pragma warning disable AS0072 #if not CLEAN25 [Obsolete('Pending removal.', '25.0')] [IntegrationEvent(true, false)] @@ -1137,7 +1122,6 @@ codeunit 4810 IntrastatReportManagement begin end; #endif -#pragma warning restore AS0072 [IntegrationEvent(true, false)] local procedure OnBeforeDefineFileNames(var IntrastatReportHeader: Record "Intrastat Report Header"; var FileName: Text; var ReceptFileName: Text; var ShipmentFileName: Text; var ZipFileName: Text; var IsHandled: Boolean) begin @@ -1207,4 +1191,9 @@ codeunit 4810 IntrastatReportManagement local procedure OnGetOriginalCurrencyFromItemLedgerElseCase(ItemLedgerEntry: Record "Item Ledger Entry"; var CurrencyCode: Code[10]) begin end; + + [IntegrationEvent(false, false)] + local procedure OnRecalculateWeightAndSupplUOMQtyOnAfterCalculateNetWeight(var IntrastatReportLine: Record "Intrastat Report Line"; var NetWeight: Decimal) + begin + end; } \ No newline at end of file diff --git a/Apps/W1/Intrastat/app/src/DefaultCtryCodeItemTrack.Enum.al b/Apps/W1/Intrastat/app/src/Setup/DefaultCtryCodeItemTrack.Enum.al similarity index 76% rename from Apps/W1/Intrastat/app/src/DefaultCtryCodeItemTrack.Enum.al rename to Apps/W1/Intrastat/app/src/Setup/DefaultCtryCodeItemTrack.Enum.al index 3b3bd87c8c..38f753bf19 100644 --- a/Apps/W1/Intrastat/app/src/DefaultCtryCodeItemTrack.Enum.al +++ b/Apps/W1/Intrastat/app/src/Setup/DefaultCtryCodeItemTrack.Enum.al @@ -6,12 +6,6 @@ enum 4822 "Default Ctry. Code-Item Track." { Extensible = true; - value(0; " ") - { - Caption = ' '; - } - value(1; "Purchase Header") - { - Caption = 'Purchase Header'; - } + value(0; " ") { Caption = ' '; } + value(1; "Purchase Header") { Caption = 'Purchase Header'; } } \ No newline at end of file diff --git a/Apps/W1/Intrastat/app/src/Setup/IntrRepProjVATNoBase.Enum.al b/Apps/W1/Intrastat/app/src/Setup/IntrRepProjVATNoBase.Enum.al new file mode 100644 index 0000000000..493b1d43d0 --- /dev/null +++ b/Apps/W1/Intrastat/app/src/Setup/IntrRepProjVATNoBase.Enum.al @@ -0,0 +1,12 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Inventory.Intrastat; + +enum 4826 "Intr. Rep. Proj. VAT No. Base" +{ + Extensible = true; + value(0; "Sell-to Customer") { Caption = 'Sell-to Customer'; } + value(1; "Bill-to Customer") { Caption = 'Bill-to Customer'; } +} \ No newline at end of file diff --git a/Apps/W1/Intrastat/app/src/Setup/IntrRepPurchVATNoBase.Enum.al b/Apps/W1/Intrastat/app/src/Setup/IntrRepPurchVATNoBase.Enum.al new file mode 100644 index 0000000000..012de71c0f --- /dev/null +++ b/Apps/W1/Intrastat/app/src/Setup/IntrRepPurchVATNoBase.Enum.al @@ -0,0 +1,13 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Inventory.Intrastat; + +enum 4823 "Intr. Rep. Purch. VAT No. Base" +{ + Extensible = true; + value(0; "Buy-from VAT") { Caption = 'Buy-from Vendor'; } + value(1; "Pay-to VAT") { Caption = 'Pay-to Vendor'; } + value(2; Document) { Caption = 'Document'; } +} \ No newline at end of file diff --git a/Apps/W1/Intrastat/app/src/Setup/IntrReportPurchInfoBase.Enum.al b/Apps/W1/Intrastat/app/src/Setup/IntrReportPurchInfoBase.Enum.al new file mode 100644 index 0000000000..59da4de45d --- /dev/null +++ b/Apps/W1/Intrastat/app/src/Setup/IntrReportPurchInfoBase.Enum.al @@ -0,0 +1,12 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Inventory.Intrastat; + +enum 4825 "Intr. Report Purch. Info Base" +{ + Extensible = true; + value(0; "Buy-from Vendor") { Caption = 'Buy-from Vendor'; } + value(1; "Pay-to Vendor") { Caption = 'Pay-to Vendor'; } +} \ No newline at end of file diff --git a/Apps/W1/Intrastat/app/src/Setup/IntrReportSalesInfoBase.Enum.al b/Apps/W1/Intrastat/app/src/Setup/IntrReportSalesInfoBase.Enum.al new file mode 100644 index 0000000000..36a5baf865 --- /dev/null +++ b/Apps/W1/Intrastat/app/src/Setup/IntrReportSalesInfoBase.Enum.al @@ -0,0 +1,12 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Inventory.Intrastat; + +enum 4824 "Intr. Report Sales Info Base" +{ + Extensible = true; + value(0; "Sell-to Customer") { Caption = 'Sell-to Customer'; } + value(1; "Bill-to Customer") { Caption = 'Bill-to Customer'; } +} \ No newline at end of file diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportChecklist.Page.al b/Apps/W1/Intrastat/app/src/Setup/IntrastatReportChecklist.Page.al similarity index 52% rename from Apps/W1/Intrastat/app/src/IntrastatReportChecklist.Page.al rename to Apps/W1/Intrastat/app/src/Setup/IntrastatReportChecklist.Page.al index 9ad285729b..0326a5927a 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReportChecklist.Page.al +++ b/Apps/W1/Intrastat/app/src/Setup/IntrastatReportChecklist.Page.al @@ -18,31 +18,17 @@ page 4814 "Intrastat Report Checklist" { repeater(Group) { - field("Field No."; Rec."Field No.") - { - ToolTip = 'Specifies the number of the table field that this entry in the checklist uses.'; - } + field("Field No."; Rec."Field No.") { } field("Field Name"; Rec."Field Name") { - ToolTip = 'Specifies the name of the table field that this entry in the checklist uses.'; - trigger OnAssistEdit() begin Rec.AssistEditFieldName(); end; } - field("Filter Expression"; Rec."Filter Expression") - { - ToolTip = 'Specifies the filter expression that must be applied to the Intrastat line. The check for fields is run only on the lines that meet the filter criteria.'; - } - field("Reversed Filter Expression"; Rec."Reversed Filter Expression") - { - ToolTip = 'Specifies that the check for fields is run only on those lines that do not match the filter expression. If the line is not filtered, this field is ignored.'; - } - field("Must Be Blank For Filter Expr."; Rec."Must Be Blank For Filter Expr.") - { - ToolTip = 'Specifies the filter expression that must be applied to the Intrastat line where field must be blank. The check for fields is run only on the lines that meet the filter criteria.'; - } + field("Filter Expression"; Rec."Filter Expression") { } + field("Reversed Filter Expression"; Rec."Reversed Filter Expression") { } + field("Must Be Blank For Filter Expr."; Rec."Must Be Blank For Filter Expr.") { } } } } diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportChecklist.Table.al b/Apps/W1/Intrastat/app/src/Setup/IntrastatReportChecklist.Table.al similarity index 91% rename from Apps/W1/Intrastat/app/src/IntrastatReportChecklist.Table.al rename to Apps/W1/Intrastat/app/src/Setup/IntrastatReportChecklist.Table.al index 4aa21e5553..1e801e44bf 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReportChecklist.Table.al +++ b/Apps/W1/Intrastat/app/src/Setup/IntrastatReportChecklist.Table.al @@ -21,17 +21,20 @@ table 4813 "Intrastat Report Checklist" Caption = 'Field No.'; NotBlank = true; TableRelation = Field."No." where(TableNo = const(4812), "No." = filter(<> 1 & <> 2 & < 2000000000), Class = const(Normal), ObsoleteState = const(No)); // Intrastat Report Line table fields excluding key and system fields + ToolTip = 'Specifies the number of the table field that this entry in the checklist uses.'; } field(2; "Field Name"; Text[250]) { Caption = 'Field Name'; FieldClass = FlowField; Editable = false; - CalcFormula = Lookup(Field."Field Caption" where(TableNo = const(4812), "No." = field("Field No."))); // lookup Intrastat Report Line table + CalcFormula = lookup(Field."Field Caption" where(TableNo = const(4812), "No." = field("Field No."))); // lookup Intrastat Report Line table + ToolTip = 'Specifies the name of the table field that this entry in the checklist uses.'; } field(3; "Filter Expression"; Text[1024]) { Caption = 'Filter Expression'; + ToolTip = 'Specifies the filter expression that must be applied to the Intrastat line. The check for fields is run only on the lines that meet the filter criteria.'; trigger OnValidate() var IntrastatReportLine: Record "Intrastat Report Line"; @@ -57,10 +60,12 @@ table 4813 "Intrastat Report Checklist" field(5; "Reversed Filter Expression"; Boolean) { Caption = 'Reversed Filter Expression'; + ToolTip = 'Specifies that the check for fields is run only on those lines that do not match the filter expression. If the line is not filtered, this field is ignored.'; } field(6; "Must Be Blank For Filter Expr."; Text[1024]) { Caption = 'Field Must Be Blank For Filter Expression'; + ToolTip = 'Specifies the filter expression that must be applied to the Intrastat line where field must be blank. The check for fields is run only on the lines that meet the filter criteria.'; trigger OnValidate() var IntrastatReportLine: Record "Intrastat Report Line"; diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportContactType.Enum.al b/Apps/W1/Intrastat/app/src/Setup/IntrastatReportContactType.Enum.al similarity index 100% rename from Apps/W1/Intrastat/app/src/IntrastatReportContactType.Enum.al rename to Apps/W1/Intrastat/app/src/Setup/IntrastatReportContactType.Enum.al diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportLineTypeSel.Enum.al b/Apps/W1/Intrastat/app/src/Setup/IntrastatReportLineTypeSel.Enum.al similarity index 100% rename from Apps/W1/Intrastat/app/src/IntrastatReportLineTypeSel.Enum.al rename to Apps/W1/Intrastat/app/src/Setup/IntrastatReportLineTypeSel.Enum.al diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportSetup.Page.al b/Apps/W1/Intrastat/app/src/Setup/IntrastatReportSetup.Page.al similarity index 53% rename from Apps/W1/Intrastat/app/src/IntrastatReportSetup.Page.al rename to Apps/W1/Intrastat/app/src/Setup/IntrastatReportSetup.Page.al index 3554177733..35f01497be 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReportSetup.Page.al +++ b/Apps/W1/Intrastat/app/src/Setup/IntrastatReportSetup.Page.al @@ -20,136 +20,82 @@ page 4810 "Intrastat Report Setup" group(General) { Caption = 'General'; - field("Report Receipts"; Rec."Report Receipts") - { - ToolTip = 'Specifies that you must include arrivals of received goods in Intrastat reports.'; - } - field("Report Shipments"; Rec."Report Shipments") - { - ToolTip = 'Specifies that you must include shipments of dispatched items in Intrastat reports.'; - } - field("Include Drop Shipment"; Rec."Include Drop Shipment") - { - ToolTip = 'Specifies if drop shipment transactions are included in Intrastat reports.'; - } - field("Shipments Based On"; Rec."Shipments Based On") - { - ToolTip = 'Specifies based on which country code Intrastat report lines are taken.'; - } + field("Report Receipts"; Rec."Report Receipts") { } + field("Report Shipments"; Rec."Report Shipments") { } + field("Include Drop Shipment"; Rec."Include Drop Shipment") { } + field("Shipments Based On"; Rec."Shipments Based On") { } +#if not CLEAN26 field("VAT No. Based On"; Rec."VAT No. Based On") { - ToolTip = 'Specifies based on which customer/vendor code VAT number is taken for the Intrastat report.'; - } - field("Intrastat Contact Type"; Rec."Intrastat Contact Type") - { - ToolTip = 'Specifies the Intrastat contact type.'; - } - field("Intrastat Contact No."; Rec."Intrastat Contact No.") - { - ToolTip = 'Specifies the Intrastat contact.'; - } - field("Company VAT No. on File"; Rec."Company VAT No. on File") - { - ToolTip = 'Specifies the information to include in the company''s VAT registration number when it''s exported to the Intrastat file.'; - } - field("Vend. VAT No. on File"; Rec."Vend. VAT No. on File") - { - ToolTip = 'Specifies the information to include in a vendor''s VAT registration number when it''s exported to the Intrastat file.'; - } - field("Cust. VAT No. on File"; Rec."Cust. VAT No. on File") - { - ToolTip = 'Specifies the information to include in a customer''s VAT registration number when it''s exported to the Intrastat file.'; - } - field("Get Partner VAT For"; Rec."Get Partner VAT For") - { - ToolTip = 'Specifies the type of line that the partner''s VAT registration number is updated for.'; - } - field("Def. Country Code for Item Tr."; Rec."Def. Country Code for Item Tr.") - { - ToolTip = 'Specifies the default source of country code for item tracking.'; - } + Visible = false; + ObsoleteReason = 'Use "Sales VAT No. Based On" and "Purchase VAT No. Based On" fields instead.'; + ObsoleteState = Pending; + ObsoleteTag = '26.0'; + } +#endif + field("Sales VAT No. Based On"; Rec."Sales VAT No. Based On") { } + field("Purchase VAT No. Based On"; Rec."Purchase VAT No. Based On") { } + field("Project VAT No. Based On"; Rec."Project VAT No. Based On") { } + field("Sales Intrastat Info Based On"; Rec."Sales Intrastat Info Based On") { } + field("Purch. Intrastat Info Based On"; Rec."Purch. Intrastat Info Based On") { } + field("Intrastat Contact Type"; Rec."Intrastat Contact Type") { } + field("Intrastat Contact No."; Rec."Intrastat Contact No.") { } + field("Company VAT No. on File"; Rec."Company VAT No. on File") { } + field("Vend. VAT No. on File"; Rec."Vend. VAT No. on File") { } + field("Cust. VAT No. on File"; Rec."Cust. VAT No. on File") { } + field("Get Partner VAT For"; Rec."Get Partner VAT For") { } + field("Def. Country Code for Item Tr."; Rec."Def. Country Code for Item Tr.") { } } group("Default Transactions") { Caption = 'Default Transactions'; - field("Default Transaction Type"; Rec."Default Trans. - Purchase") - { - ToolTip = 'Specifies the default transaction type for regular sales shipments and service shipments, and purchase receipts.'; - } - field("Default Trans. Type - Returns"; Rec."Default Trans. - Return") - { - ToolTip = 'Specifies the default transaction type for sales returns and service returns, and purchase returns.'; - } - field("Def. Private Person VAT No."; Rec."Def. Private Person VAT No.") - { - ToolTip = 'Specifies the default private person VAT number.'; - } - field("Def. 3-Party Trade VAT No."; Rec."Def. 3-Party Trade VAT No.") - { - ToolTip = 'Specifies the default 3-party trade VAT number.'; - } - field("Def. VAT for Unknown State"; Rec."Def. VAT for Unknown State") - { - ToolTip = 'Specifies the default VAT number for unknown state.'; - } - field("Def. Country/Region Code"; Rec."Def. Country/Region Code") - { - ToolTip = 'Specifies the default receiving country code.'; - } + field("Default Transaction Type"; Rec."Default Trans. - Purchase") { } + field("Default Trans. Type - Returns"; Rec."Default Trans. - Return") { } + field("Def. Private Person VAT No."; Rec."Def. Private Person VAT No.") { } + field("Def. 3-Party Trade VAT No."; Rec."Def. 3-Party Trade VAT No.") { } + field("Def. VAT for Unknown State"; Rec."Def. VAT for Unknown State") { } + field("Def. Country/Region Code"; Rec."Def. Country/Region Code") { } } group(Reporting) { Caption = 'Reporting'; field("Data Exch. Def. Code"; Rec."Data Exch. Def. Code") { - ToolTip = 'Specifies the data exchange definition code to generate the intrastat file.'; Enabled = not Rec."Split Files"; } field("Data Exch. Def. Name"; Rec."Data Exch. Def. Name") { - ToolTip = 'Specifies the data exchange definition name to generate the intrastat file.'; Enabled = not Rec."Split Files"; } field("Split Files"; Rec."Split Files") { - ToolTip = 'Specifies if Receipts and Shipments shall be reported in two separate files.'; trigger OnValidate() begin CurrPage.Update(); end; } - field("Zip Files"; Rec."Zip Files") - { - ToolTip = 'Specifies if report file (-s) shall be added to Zip file.'; - } + field("Zip Files"; Rec."Zip Files") { } field("Data Exch. Def. Code - Receipt"; Rec."Data Exch. Def. Code - Receipt") { - ToolTip = 'Specifies the data exchange definition code to generate the intrastat file for received goods.'; Enabled = Rec."Split Files"; } field("Data Exch. Def. Name - Receipt"; Rec."Data Exch. Def. Name - Receipt") { - ToolTip = 'Specifies the data exchange definition name to generate the intrastat file for received goods.'; Enabled = Rec."Split Files"; } field("Data Exch. Def. Code - Shpt."; Rec."Data Exch. Def. Code - Shpt.") { - ToolTip = 'Specifies the data exchange definition code to generate the intrastat file for shipped goods.'; Enabled = Rec."Split Files"; } field("Data Exch. Def. Name - Shpt."; Rec."Data Exch. Def. Name - Shpt.") { - ToolTip = 'Specifies the data exchange definition name to generate the intrastat file for shipped goods.'; Enabled = Rec."Split Files"; } } group(Numbering) { Caption = 'Numbering'; - field("Intrastat Nos."; Rec."Intrastat Nos.") - { - ToolTip = 'Specifies the code for the number series that will be used to assign numbers to intrastat documents. To see the number series that have been set up in the No. Series table, click the drop-down arrow in the field.'; - } + field("Intrastat Nos."; Rec."Intrastat Nos.") { } } } } diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportSetup.Table.al b/Apps/W1/Intrastat/app/src/Setup/IntrastatReportSetup.Table.al similarity index 61% rename from Apps/W1/Intrastat/app/src/IntrastatReportSetup.Table.al rename to Apps/W1/Intrastat/app/src/Setup/IntrastatReportSetup.Table.al index 9a3b886a00..94f000bee7 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReportSetup.Table.al +++ b/Apps/W1/Intrastat/app/src/Setup/IntrastatReportSetup.Table.al @@ -24,25 +24,29 @@ table 4810 "Intrastat Report Setup" field(2; "Report Receipts"; Boolean) { Caption = 'Report Receipts'; + ToolTip = 'Specifies that you must include arrivals of received goods in Intrastat reports.'; } field(3; "Report Shipments"; Boolean) { Caption = 'Report Shipments'; + ToolTip = 'Specifies that you must include shipments of dispatched items in Intrastat reports.'; } field(4; "Default Trans. - Purchase"; Code[10]) { Caption = 'Default Trans. Type'; TableRelation = "Transaction Type"; + ToolTip = 'Specifies the default transaction type for regular sales shipments and service shipments, and purchase receipts.'; } field(5; "Default Trans. - Return"; Code[10]) { Caption = 'Default Trans. Type - Returns'; TableRelation = "Transaction Type"; + ToolTip = 'Specifies the default transaction type for sales returns and service returns, and purchase returns.'; } field(6; "Intrastat Contact Type"; Enum "Intrastat Report Contact Type") { Caption = 'Intrastat Contact Type'; - + ToolTip = 'Specifies the Intrastat contact type.'; trigger OnValidate() begin if "Intrastat Contact Type" <> xRec."Intrastat Contact Type" then @@ -54,18 +58,22 @@ table 4810 "Intrastat Report Setup" Caption = 'Intrastat Contact No.'; TableRelation = if ("Intrastat Contact Type" = const(Contact)) Contact."No." else if ("Intrastat Contact Type" = const(Vendor)) Vendor."No."; + ToolTip = 'Specifies the Intrastat contact.'; } field(9; "Cust. VAT No. on File"; Enum "Intrastat Report VAT File Fmt") { Caption = 'Customer VAT Reg. No. on File'; + ToolTip = 'Specifies how a customer''s VAT registration number exports to the Intrastat file. 0 is the value of the VAT Reg. No. field, 1 adds the EU country code as a prefix, and 2 removes the EU country code.'; } field(10; "Vend. VAT No. on File"; Enum "Intrastat Report VAT File Fmt") { Caption = 'Vendor VAT Reg. No. on File'; + ToolTip = 'Specifies how a vendor''s VAT registration number exports to the Intrastat file. 0 is the value of the VAT Reg. No. field, 1 adds the EU country code as a prefix, and 2 removes the EU country code.'; } field(11; "Company VAT No. on File"; Enum "Intrastat Report VAT File Fmt") { Caption = 'Company VAT Reg. No. on File'; + ToolTip = 'Specifies how the company''s VAT registration number exports to the Intrastat file. 0 is the value of the VAT Reg. No. field, 1 adds the EU country code as a prefix, and 2 removes the EU country code.'; } field(12; "Default Trans. Spec. Code"; Code[10]) { @@ -81,19 +89,23 @@ table 4810 "Intrastat Report Setup" { Caption = 'Intrastat Nos.'; TableRelation = "No. Series"; + ToolTip = 'Specifies the code for the number series that will be used to assign numbers to intrastat documents. To see the number series that have been set up in the No. Series table, click the drop-down arrow in the field.'; } field(15; "Split Files"; Boolean) { Caption = 'Split Receipts/Shipments Files'; + ToolTip = 'Specifies if Receipts and Shipments shall be reported in two separate files.'; } field(16; "Zip Files"; Boolean) { Caption = 'Zip File(-s)'; + ToolTip = 'Specifies if report file (-s) shall be added to Zip file.'; } field(17; "Data Exch. Def. Code"; Code[20]) { Caption = 'Data Exch. Def. Code'; TableRelation = "Data Exch. Def"; + ToolTip = 'Specifies the data exchange definition code to generate the intrastat file.'; } field(18; "Data Exch. Def. Name"; Text[100]) { @@ -101,11 +113,13 @@ table 4810 "Intrastat Report Setup" CalcFormula = lookup("Data Exch. Def".Name where(Code = field("Data Exch. Def. Code"))); Editable = false; FieldClass = FlowField; + ToolTip = 'Specifies the data exchange definition name to generate the intrastat file.'; } field(19; "Data Exch. Def. Code - Receipt"; Code[20]) { Caption = 'Data Exch. Def. Code - Receipt'; TableRelation = "Data Exch. Def"; + ToolTip = 'Specifies the data exchange definition code to generate the intrastat file for received goods.'; } field(20; "Data Exch. Def. Name - Receipt"; Text[100]) { @@ -113,11 +127,13 @@ table 4810 "Intrastat Report Setup" CalcFormula = lookup("Data Exch. Def".Name where(Code = field("Data Exch. Def. Code - Receipt"))); Editable = false; FieldClass = FlowField; + ToolTip = 'Specifies the data exchange definition name to generate the intrastat file for received goods.'; } field(21; "Data Exch. Def. Code - Shpt."; Code[20]) { Caption = 'Data Exch. Def. Code - Shipment'; TableRelation = "Data Exch. Def"; + ToolTip = 'Specifies the data exchange definition code to generate the intrastat file for shipped goods.'; } field(22; "Data Exch. Def. Name - Shpt."; Text[100]) { @@ -125,26 +141,42 @@ table 4810 "Intrastat Report Setup" CalcFormula = lookup("Data Exch. Def".Name where(Code = field("Data Exch. Def. Code - Shpt."))); Editable = false; FieldClass = FlowField; + ToolTip = 'Specifies the data exchange definition name to generate the intrastat file for shipped goods.'; } field(23; "Shipments Based On"; Enum "Intrastat Report Shpt. Base") { Caption = 'Shipments Based On'; + ToolTip = 'Specifies based on which country code Intrastat report lines are taken.'; } +#if not CLEANSCHEMA29 field(24; "VAT No. Based On"; Enum "Intrastat Report VAT No. Base") { Caption = 'VAT Reg. No. Based On'; - } + ToolTip = 'Specifies based on which customer/vendor code VAT number is taken for the Intrastat report.'; + ObsoleteReason = 'Use "Sales VAT No. Based On" and "Purchase VAT No. Based On" fields instead.'; +#if CLEAN26 + ObsoleteState = Removed; + ObsoleteTag = '29.0'; +#else + ObsoleteState = Pending; + ObsoleteTag = '26.0'; +#endif + } +#endif field(25; "Def. Private Person VAT No."; Text[50]) { Caption = 'Default Private Person VAT Reg. No.'; + ToolTip = 'Specifies the default private person VAT number.'; } field(26; "Def. 3-Party Trade VAT No."; Text[50]) { Caption = 'Default 3-Party Trade VAT Reg. No.'; + ToolTip = 'Specifies the default 3-party trade VAT number.'; } field(27; "Def. VAT for Unknown State"; Text[50]) { Caption = 'Def. VAT Reg. No. for Unknown State'; + ToolTip = 'Specifies the default VAT number for unknown state.'; } field(28; "Def. Country/Region Code"; Code[10]) { @@ -152,6 +184,7 @@ table 4810 "Intrastat Report Setup" FieldClass = FlowField; CalcFormula = lookup("Company Information"."Ship-to Country/Region Code" where("Primary Key" = const(''))); Editable = false; + ToolTip = 'Specifies the default receiving country code.'; } field(29; "Suppl. Units Weight"; Enum "Intrastat Report Suppl. Weight") { @@ -160,16 +193,45 @@ table 4810 "Intrastat Report Setup" field(30; "Get Partner VAT For"; Enum "Intrastat Report Line Type Sel") { Caption = 'Get VAT Reg. No. For'; + ToolTip = 'Specifies the type of line that the partner''s VAT registration number is updated for.'; } field(31; "Include Drop Shipment"; Boolean) { Caption = 'Include Drop Shipment'; + ToolTip = 'Specifies if drop shipment transactions are included in Intrastat reports.'; } field(32; "Def. Country Code for Item Tr."; Enum "Default Ctry. Code-Item Track.") { Caption = 'Default Country Code for Item Tracking'; + ToolTip = 'Specifies the default source of country code for item tracking.'; + } + field(33; "Sales VAT No. Based On"; Enum "Intrastat Report VAT No. Base") + { + Caption = 'Sales VAT Reg. No. Based On'; + ToolTip = 'Specifies based on which customer code, or document VAT number is taken for the Intrastat report.'; + } + field(34; "Purchase VAT No. Based On"; Enum "Intr. Rep. Purch. VAT No. Base") + { + Caption = 'Purchase VAT Reg. No. Based On'; + ToolTip = 'Specifies based on which vendor code, or document VAT number is taken for the Intrastat report.'; + } + field(35; "Project VAT No. Based On"; Enum "Intr. Rep. Proj. VAT No. Base") + { + Caption = 'Project VAT Reg. No. Based On'; + ToolTip = 'Specifies based on which customer code VAT number is taken for the Intrastat report.'; + } + field(36; "Sales Intrastat Info Based On"; Enum "Intr. Report Sales Info Base") + { + Caption = 'Sales Intrastat Info Based On'; + ToolTip = 'Specifies based on which customer code Intrastat settings are added to the document.'; + } + field(37; "Purch. Intrastat Info Based On"; Enum "Intr. Report Purch. Info Base") + { + Caption = 'Purchase Intrastat Info Based On'; + ToolTip = 'Specifies based on which vendor code Intrastat settings are added to the document.'; } } + keys { key(Key1; "Code") @@ -196,6 +258,8 @@ table 4810 "Intrastat Report Setup" end; end; +#if not CLEAN26 + [Obsolete('Pending removal.', '26.0')] procedure GetPartnerNo(SellTo: Code[20]; BillTo: Code[20]; VATNoBasedToCheck: Enum "Intrastat Report VAT No. Base") PartnerNo: Code[20] begin GetSetup(); @@ -205,6 +269,7 @@ table 4810 "Intrastat Report Setup" exit(GetPartnerNo(SellTo, BillTo)); end; + [Obsolete('Pending removal.', '26.0')] procedure GetPartnerNo(SellTo: Code[20]; BillTo: Code[20]) PartnerNo: Code[20] begin GetSetup(); @@ -215,7 +280,7 @@ table 4810 "Intrastat Report Setup" PartnerNo := BillTo; end; end; - +#endif procedure GetSetup() begin if not SetupRead then begin diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportSetupWizard.Page.al b/Apps/W1/Intrastat/app/src/Setup/IntrastatReportSetupWizard.Page.al similarity index 73% rename from Apps/W1/Intrastat/app/src/IntrastatReportSetupWizard.Page.al rename to Apps/W1/Intrastat/app/src/Setup/IntrastatReportSetupWizard.Page.al index ea70e7634d..bedb18c89f 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReportSetupWizard.Page.al +++ b/Apps/W1/Intrastat/app/src/Setup/IntrastatReportSetupWizard.Page.al @@ -72,62 +72,42 @@ page 4815 "Intrastat Report Setup Wizard" Caption = 'General Information'; field("Report Receipts"; Rec."Report Receipts") { - ToolTip = 'Specifies that you must include arrivals of received goods in Intrastat reports.'; Editable = true; } field("Report Shipments"; Rec."Report Shipments") { - ToolTip = 'Specifies that you must include shipments of dispatched items in Intrastat reports.'; Editable = true; } field("Include Drop Shipment"; Rec."Include Drop Shipment") { - ToolTip = 'Specifies if drop shipment transactions are included in Intrastat reports.'; Editable = true; } - field("Shipments Based On"; Rec."Shipments Based On") - { - ToolTip = 'Specifies based on which country code Intrastat report lines are taken.'; - } + field("Shipments Based On"; Rec."Shipments Based On") { } +#if not CLEAN26 field("VAT No. Based On"; Rec."VAT No. Based On") { - ToolTip = 'Specifies based on which customer/vendor code VAT number is taken for the Intrastat report.'; - } - field("Intrastat Contact Type"; Rec."Intrastat Contact Type") - { - ToolTip = 'Specifies the Intrastat contact type.'; - } - field("Intrastat Contact No."; Rec."Intrastat Contact No.") - { - ToolTip = 'Specifies the Intrastat contact.'; - } - field("Company VAT No. on File"; Rec."Company VAT No. on File") - { - ToolTip = 'Specifies how the company''s VAT registration number exports to the Intrastat file. 0 is the value of the VAT Reg. No. field, 1 adds the EU country code as a prefix, and 2 removes the EU country code.'; - } - field("Vend. VAT No. on File"; Rec."Vend. VAT No. on File") - { - ToolTip = 'Specifies how a vendor''s VAT registration number exports to the Intrastat file. 0 is the value of the VAT Reg. No. field, 1 adds the EU country code as a prefix, and 2 removes the EU country code.'; - } - field("Cust. VAT No. on File"; Rec."Cust. VAT No. on File") - { - ToolTip = 'Specifies how a customer''s VAT registration number exports to the Intrastat file. 0 is the value of the VAT Reg. No. field, 1 adds the EU country code as a prefix, and 2 removes the EU country code.'; - } - field("Get Partner VAT For"; Rec."Get Partner VAT For") - { - ToolTip = 'Specifies for which type of line Partner''s VAT registration number is updated.'; - } - field("Def. Country Code for Item Tr."; Rec."Def. Country Code for Item Tr.") - { - ToolTip = 'Specifies the default source of country code for item tracking.'; + Visible = false; + ObsoleteReason = 'Use "Sales VAT No. Based On" and "Purchase VAT No. Based On" fields instead.'; + ObsoleteState = Pending; + ObsoleteTag = '26.0'; } +#endif + field("Sales VAT No. Based On"; Rec."Sales VAT No. Based On") { } + field("Purchase VAT No. Based On"; Rec."Purchase VAT No. Based On") { } + field("Project VAT No. Based On"; Rec."Project VAT No. Based On") { } + field("Sales Intrastat Info Based On"; Rec."Sales Intrastat Info Based On") { } + field("Purch. Intrastat Info Based On"; Rec."Purch. Intrastat Info Based On") { } + field("Intrastat Contact Type"; Rec."Intrastat Contact Type") { } + field("Intrastat Contact No."; Rec."Intrastat Contact No.") { } + field("Company VAT No. on File"; Rec."Company VAT No. on File") { } + field("Vend. VAT No. on File"; Rec."Vend. VAT No. on File") { } + field("Cust. VAT No. on File"; Rec."Cust. VAT No. on File") { } + field("Get Partner VAT For"; Rec."Get Partner VAT For") { } + field("Def. Country Code for Item Tr."; Rec."Def. Country Code for Item Tr.") { } group(Numbering) { Caption = 'Numbering'; - field("Intrastat Nos."; Rec."Intrastat Nos.") - { - ToolTip = 'Specifies the code for the number series that will be used to assign numbers to intrastat documents. To see the number series that have been set up in the No. Series table, click the drop-down arrow in the field.'; - } + field("Intrastat Nos."; Rec."Intrastat Nos.") { } } } } @@ -139,30 +119,12 @@ page 4815 "Intrastat Report Setup Wizard" group(Defaults) { Caption = 'Defaults'; - field("Default Transaction Type"; Rec."Default Trans. - Purchase") - { - ToolTip = 'Specifies the default transaction type for regular sales shipments and service shipments, and purchase receipts.'; - } - field("Default Trans. Type - Returns"; Rec."Default Trans. - Return") - { - ToolTip = 'Specifies the default transaction type for sales returns and service returns, and purchase returns.'; - } - field("Def. Private Person VAT No."; Rec."Def. Private Person VAT No.") - { - ToolTip = 'Specifies the default private person VAT number.'; - } - field("Def. 3-Party Trade VAT No."; Rec."Def. 3-Party Trade VAT No.") - { - ToolTip = 'Specifies the default 3-party trade VAT number.'; - } - field("Def. VAT for Unknown State"; Rec."Def. VAT for Unknown State") - { - ToolTip = 'Specifies the default VAT number for unknown state.'; - } - field("Def. Country/Region Code"; Rec."Def. Country/Region Code") - { - ToolTip = 'Shows the default receiving country code.'; - } + field("Default Transaction Type"; Rec."Default Trans. - Purchase") { } + field("Default Trans. Type - Returns"; Rec."Default Trans. - Return") { } + field("Def. Private Person VAT No."; Rec."Def. Private Person VAT No.") { } + field("Def. 3-Party Trade VAT No."; Rec."Def. 3-Party Trade VAT No.") { } + field("Def. VAT for Unknown State"; Rec."Def. VAT for Unknown State") { } + field("Def. Country/Region Code"; Rec."Def. Country/Region Code") { } } } group(Step4) @@ -174,44 +136,34 @@ page 4815 "Intrastat Report Setup Wizard" Caption = 'Reporting'; field("Data Exch. Def. Code"; Rec."Data Exch. Def. Code") { - ToolTip = 'Specifies the data exchange definition code to generate the intrastat file.'; Enabled = not Rec."Split Files"; } field("Data Exch. Def. Name"; Rec."Data Exch. Def. Name") { - ToolTip = 'Specifies the data exchange definition name to generate the intrastat file.'; Enabled = not Rec."Split Files"; } field("Split Files"; Rec."Split Files") { - ToolTip = 'Specifies if Receipts and Shipments shall be reported in two separate files.'; trigger OnValidate() begin CurrPage.Update(); end; } - field("Zip Files"; Rec."Zip Files") - { - ToolTip = 'Specifies if report file (-s) shall be added to Zip file.'; - } + field("Zip Files"; Rec."Zip Files") { } field("Data Exch. Def. Code - Receipt"; Rec."Data Exch. Def. Code - Receipt") { - ToolTip = 'Specifies the data exchange definition code to generate the intrastat file for received goods.'; Enabled = Rec."Split Files"; } field("Data Exch. Def. Name - Receipt"; Rec."Data Exch. Def. Name - Receipt") { - ToolTip = 'Specifies the data exchange definition name to generate the intrastat file for received goods.'; Enabled = Rec."Split Files"; } field("Data Exch. Def. Code - Shpt."; Rec."Data Exch. Def. Code - Shpt.") { - ToolTip = 'Specifies the data exchange definition code to generate the intrastat file for shipped goods.'; Enabled = Rec."Split Files"; } field("Data Exch. Def. Name - Shpt."; Rec."Data Exch. Def. Name - Shpt.") { - ToolTip = 'Specifies the data exchange definition name to generate the intrastat file for shipped goods.'; Enabled = Rec."Split Files"; } } diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportShptBase.Enum.al b/Apps/W1/Intrastat/app/src/Setup/IntrastatReportShptBase.Enum.al similarity index 100% rename from Apps/W1/Intrastat/app/src/IntrastatReportShptBase.Enum.al rename to Apps/W1/Intrastat/app/src/Setup/IntrastatReportShptBase.Enum.al diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportSupplWeight.Enum.al b/Apps/W1/Intrastat/app/src/Setup/IntrastatReportSupplWeight.Enum.al similarity index 100% rename from Apps/W1/Intrastat/app/src/IntrastatReportSupplWeight.Enum.al rename to Apps/W1/Intrastat/app/src/Setup/IntrastatReportSupplWeight.Enum.al diff --git a/Apps/W1/Intrastat/app/src/Setup/IntrastatReportUpgrade.Codeunit.al b/Apps/W1/Intrastat/app/src/Setup/IntrastatReportUpgrade.Codeunit.al new file mode 100644 index 0000000000..6755bf2eca --- /dev/null +++ b/Apps/W1/Intrastat/app/src/Setup/IntrastatReportUpgrade.Codeunit.al @@ -0,0 +1,43 @@ +codeunit 4815 "Intrastat Report Upgrade" +{ + Subtype = Upgrade; + trigger OnUpgradePerCompany() + var + IntrastatReportSetup: Record "Intrastat Report Setup"; + UpgradeTag: Codeunit "Upgrade Tag"; + begin + if UpgradeTag.HasUpgradeTag(GetIntrastatDocumentVATIDUpgradeTag()) then + exit; + + if IntrastatReportSetup.Get() then begin + if IntrastatReportSetup."VAT No. Based On" = IntrastatReportSetup."VAT No. Based On"::"Sell-to VAT" then begin + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Sell-to VAT"; + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Buy-from VAT"; + IntrastatReportSetup."Sales Intrastat Info Based On" := IntrastatReportSetup."Sales Intrastat Info Based On"::"Sell-to Customer"; + IntrastatReportSetup."Purch. Intrastat Info Based On" := IntrastatReportSetup."Purch. Intrastat Info Based On"::"Buy-from Vendor"; + IntrastatReportSetup."Project VAT No. Based On" := IntrastatReportSetup."Project VAT No. Based On"::"Sell-to Customer"; + end; + if IntrastatReportSetup."VAT No. Based On" = IntrastatReportSetup."VAT No. Based On"::"Bill-to VAT" then begin + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Bill-to VAT"; + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Pay-to VAT"; + IntrastatReportSetup."Sales Intrastat Info Based On" := IntrastatReportSetup."Sales Intrastat Info Based On"::"Bill-to Customer"; + IntrastatReportSetup."Purch. Intrastat Info Based On" := IntrastatReportSetup."Purch. Intrastat Info Based On"::"Pay-to Vendor"; + IntrastatReportSetup."Project VAT No. Based On" := IntrastatReportSetup."Project VAT No. Based On"::"Bill-to Customer"; + end; + IntrastatReportSetup.Modify(); + end; + + UpgradeTag.SetUpgradeTag(GetIntrastatDocumentVATIDUpgradeTag()); + end; + + local procedure GetIntrastatDocumentVATIDUpgradeTag(): Code[250] + begin + exit('MS-548317-IntrastatDocumentVATID-20241130'); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Upgrade Tag", 'OnGetPerCompanyUpgradeTags', '', false, false)] + local procedure RegisterUpgradeTags(var PerCompanyUpgradeTags: List of [Code[250]]) + begin + PerCompanyUpgradeTags.Add(GetIntrastatDocumentVATIDUpgradeTag()); + end; +} \ No newline at end of file diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportVATFileFmt.Enum.al b/Apps/W1/Intrastat/app/src/Setup/IntrastatReportVATFileFmt.Enum.al similarity index 100% rename from Apps/W1/Intrastat/app/src/IntrastatReportVATFileFmt.Enum.al rename to Apps/W1/Intrastat/app/src/Setup/IntrastatReportVATFileFmt.Enum.al diff --git a/Apps/W1/Intrastat/app/src/IntrastatReportVATNoBase.Enum.al b/Apps/W1/Intrastat/app/src/Setup/IntrastatReportVATNoBase.Enum.al similarity index 92% rename from Apps/W1/Intrastat/app/src/IntrastatReportVATNoBase.Enum.al rename to Apps/W1/Intrastat/app/src/Setup/IntrastatReportVATNoBase.Enum.al index cbe85854c0..1e2b04d931 100644 --- a/Apps/W1/Intrastat/app/src/IntrastatReportVATNoBase.Enum.al +++ b/Apps/W1/Intrastat/app/src/Setup/IntrastatReportVATNoBase.Enum.al @@ -9,4 +9,5 @@ enum 4818 "Intrastat Report VAT No. Base" Extensible = true; value(0; "Sell-to VAT") { Caption = 'Sell-to Customer'; } value(1; "Bill-to VAT") { Caption = 'Bill-to Customer'; } + value(2; Document) { Caption = 'Document'; } } \ No newline at end of file diff --git a/Apps/W1/Intrastat/test/src/IntrastatReportTest.Codeunit.al b/Apps/W1/Intrastat/test/src/IntrastatReportTest.Codeunit.al index 9aa5f81dbd..07e2b73f4d 100644 --- a/Apps/W1/Intrastat/test/src/IntrastatReportTest.Codeunit.al +++ b/Apps/W1/Intrastat/test/src/IntrastatReportTest.Codeunit.al @@ -17,6 +17,7 @@ codeunit 139550 "Intrastat Report Test" LibraryERM: Codeunit "Library - ERM"; LibraryPurchase: Codeunit "Library - Purchase"; LibrarySales: Codeunit "Library - Sales"; + LibraryService: Codeunit "Library - Service"; LibraryUtility: Codeunit "Library - Utility"; LibraryPatterns: Codeunit "Library - Patterns"; LibraryVariableStorage: Codeunit "Library - Variable Storage"; @@ -1835,42 +1836,75 @@ codeunit 139550 "Intrastat Report Test" BillToCustomer: Record Customer; SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line"; - IntrastatReportHeader: Record "Intrastat Report Header"; SalesInvoiceHeader: Record "Sales Invoice Header"; - DocumentNo: Code[20]; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + DocumentVATNo: Code[20]; IntrastatReportNo: Code[20]; begin - // [FEATURE] [Sales] [Shipment] - // [SCENARIO 422720] Partner VAT ID is taken as VAT Registration No from Sell-to Customer No. of Sales Invoice + // [FEATURE] [Sales] [Invoice] + // [SCENARIO 422720] Partner VAT ID of Sales Invoice is taken according to Intrastat Setup Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Shipment; + IntrastatReportSetup.Modify(); - // [GIVEN] G/L Setup "Bill-to/Sell-to VAT Calc." = "Bill-to/Pay-to No." // [GIVEN] Shipment on Sales Invoice = false LibraryIntrastat.UpdateShipmentOnInvoiceSalesSetup(false); - // [GIVEN] Sell-to Customer with VAT Registration No = 'AT0123456' - // [GIVEN] Bill-to Customer with VAT Registration No = 'DE1234567' - // [GIVEN] Sales Invoice with different Sell-to and Bill-To customers + // [GIVEN] Sell-to Customer with VAT Registration No = 1 + // [GIVEN] Bill-to Customer with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Sales Invoice with different Sell-to and Bill-To customers, and different VAT Registration No SellToCustomer.Get(LibraryIntrastat.CreateCustomerWithVATRegNo(true)); BillToCustomer.Get(LibraryIntrastat.CreateCustomerWithVATRegNo(true)); - LibraryIntrastat.CreateSalesDocument( - SalesHeader, SalesLine, SellToCustomer."No.", WorkDate(), SalesLine."Document Type"::Invoice, - SalesLine.Type::Item, LibraryIntrastat.CreateItem(), 1); + LibraryIntrastat.CreateSalesDocument(SalesHeader, SalesLine, SellToCustomer."No.", WorkDate(), SalesLine."Document Type"::Invoice, SalesLine.Type::Item, LibraryIntrastat.CreateItem(), 1); SalesHeader.Validate("Bill-to Customer No.", BillToCustomer."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(SellToCustomer."Country/Region Code"); + SalesHeader.Validate("VAT Registration No.", DocumentVATNo); SalesHeader.Modify(true); // [GIVEN] Post the invoice - DocumentNo := LibrarySales.PostSalesDocument(SalesHeader, true, true); + LibrarySales.PostSalesDocument(SalesHeader, true, true); + + // Sell-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Sell-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Bill-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Bill-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", BillToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); // [WHEN] Suggest Intrastat Report Lines CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); - // [THEN] Posted Sales Invoice has VAT Registration No. = 'DE1234567' - // [THEN] Partner VAT ID = 'AT0123456' in Intrastat Report Line - SalesInvoiceHeader.Get(DocumentNo); - SalesInvoiceHeader.TestField("VAT Registration No.", BillToCustomer."VAT Registration No."); + // Delete all posted sales invoices + SalesInvoiceHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); end; [Test] @@ -1882,143 +1916,1057 @@ codeunit 139550 "Intrastat Report Test" BillToCustomer: Record Customer; SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line"; - IntrastatReportHeader: Record "Intrastat Report Header"; SalesShipmentHeader: Record "Sales Shipment Header"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; IntrastatReportNo: Code[20]; + DocumentVATNo: Code[20]; begin // [FEATURE] [Sales] [Shipment] - // [SCENARIO 422720] Partner VAT ID is taken as VAT Registration No from Sell-to Customer No. of Sales Shipment + // [SCENARIO 422720] Partner VAT ID of Sales Shipment is taken according to Intrastat Setup Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Shipment; + IntrastatReportSetup.Modify(); - // [GIVEN] G/L Setup "Bill-to/Sell-to VAT Calc." = "Bill-to/Pay-to No." // [GIVEN] Shipment on Sales Invoice = true LibraryIntrastat.UpdateShipmentOnInvoiceSalesSetup(true); - // [GIVEN] Sell-to Customer with VAT Registration No = 'AT0123456' - // [GIVEN] Bill-to Customer with VAT Registration No = 'DE1234567' - // [GIVEN] Sales Invoice with different Sell-to and Bill-To customers + // [GIVEN] Sell-to Customer with VAT Registration No = 1 + // [GIVEN] Bill-to Customer with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Sales Invoice with different Sell-to and Bill-To customers and different VAT Registration No SellToCustomer.Get(LibraryIntrastat.CreateCustomerWithVATRegNo(true)); BillToCustomer.Get(LibraryIntrastat.CreateCustomerWithVATRegNo(true)); - LibraryIntrastat.CreateSalesDocument( - SalesHeader, SalesLine, SellToCustomer."No.", WorkDate(), SalesLine."Document Type"::Invoice, - SalesLine.Type::Item, LibraryIntrastat.CreateItem(), 1); + LibraryIntrastat.CreateSalesDocument(SalesHeader, SalesLine, SellToCustomer."No.", WorkDate(), SalesLine."Document Type"::Invoice, SalesLine.Type::Item, LibraryIntrastat.CreateItem(), 1); SalesHeader.Validate("Bill-to Customer No.", BillToCustomer."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(SellToCustomer."Country/Region Code"); + SalesHeader.Validate("VAT Registration No.", DocumentVATNo); SalesHeader.Modify(true); // [GIVEN] Post the invoice LibrarySales.PostSalesDocument(SalesHeader, true, true); + // Sell-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Sell-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Bill-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Bill-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", BillToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); // [WHEN] Suggest Intrastat Report Lines CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); - // [THEN] Posted Sales Shipment has VAT Registration No. = 'DE1234567' - // [THEN] Partner VAT ID = 'AT0123456' in Intrastat Report Line - SalesShipmentHeader.SetRange("Bill-to Customer No.", BillToCustomer."No."); - SalesShipmentHeader.FindFirst(); - SalesShipmentHeader.TestField("VAT Registration No.", BillToCustomer."VAT Registration No."); + // Delete all posted sales shipments + SalesShipmentHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); end; [Test] [Scope('OnPrem')] - [HandlerFunctions('IntrastatReportGetLinesPageHandler')] - procedure GetPartnerIDFromVATRegNoOfPurchaseCrMemo() + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfSalesCrMemo() var - Vendor: Record Vendor; - PurchaseHeader: Record "Purchase Header"; - PurchaseLine: Record "Purchase Line"; + SellToCustomer: Record Customer; + BillToCustomer: Record Customer; + SalesHeader: Record "Sales Header"; + SalesLine: Record "Sales Line"; + SalesCrMemoHeader: Record "Sales Cr.Memo Header"; IntrastatReportHeader: Record "Intrastat Report Header"; - PurchCrMemoHdr: Record "Purch. Cr. Memo Hdr."; + IntrastatReportSetup: Record "Intrastat Report Setup"; + DocumentVATNo: Code[20]; IntrastatReportNo: Code[20]; begin - // [FEATURE] [Purchase] [Return Shipment] - // [SCENARIO 373278] Partner VAT ID is taken as VAT Registration No from Pay-to Vendor No. of Purchase Credit Memo + // [FEATURE] [Sales] [Cr.. Memo] + // [SCENARIO 422720] Partner VAT ID of Sales Cr. Memo is taken according to Intrastat Setup Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Receipt; + IntrastatReportSetup.Modify(); - // [GIVEN] Return Shipment on Credit Memo = false - LibraryIntrastat.UpdateRetShpmtOnCrMemoPurchSetup(false); + // [GIVEN] Return Receipt on Cr. Memo = false + LibraryIntrastat.UpdateRetReceiptOnCrMemoSalesSetup(false); - // [GIVEN] Pay-to Vendor with VAT Registration No = 'AT0123456' - Vendor.Get(LibraryIntrastat.CreateVendorWithVATRegNo(true)); - LibraryIntrastat.CreatePurchaseHeader(PurchaseHeader, PurchaseHeader."Document Type"::"Credit Memo", WorkDate(), Vendor."No."); - LibraryIntrastat.CreatePurchaseLine(PurchaseHeader, PurchaseLine, PurchaseLine.Type::Item, LibraryIntrastat.CreateItem()); - LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true); + // [GIVEN] Sell-to Customer with VAT Registration No = 1 + // [GIVEN] Bill-to Customer with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Sales Cr. Memo with different Sell-to and Bill-To customers, and different VAT Registration No + SellToCustomer.Get(LibraryIntrastat.CreateCustomerWithVATRegNo(true)); + BillToCustomer.Get(LibraryIntrastat.CreateCustomerWithVATRegNo(true)); + LibraryIntrastat.CreateSalesDocument(SalesHeader, SalesLine, SellToCustomer."No.", WorkDate(), SalesLine."Document Type"::"Credit Memo", SalesLine.Type::Item, LibraryIntrastat.CreateItem(), 1); + SalesHeader.Validate("Bill-to Customer No.", BillToCustomer."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(SellToCustomer."Country/Region Code"); + SalesHeader.Validate("VAT Registration No.", DocumentVATNo); + SalesHeader.Modify(true); - // [WHEN] Intrastat Report Line is created + // [GIVEN] Post the Cr. Memo + LibrarySales.PostSalesDocument(SalesHeader, true, true); + + // Sell-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Sell-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Bill-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Bill-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", BillToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); - // [THEN] Partner VAT ID = 'AT0123456' in Intrastat Report Line - PurchCrMemoHdr.SetRange("Pay-to Vendor No.", Vendor."No."); - PurchCrMemoHdr.FindFirst(); - VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", Vendor."VAT Registration No."); - VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", PurchCrMemoHdr."VAT Registration No."); + // Delete all posted sales credit memos + SalesCrMemoHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); end; [Test] [Scope('OnPrem')] - [HandlerFunctions('IntrastatReportGetLinesPageHandler')] - procedure GetPartnerIDFromVATRegNoOfPurchaseReturnOrder() + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfSalesReturnReceipt() var - Vendor: Record Vendor; - PurchaseHeader: Record "Purchase Header"; - PurchaseLine: Record "Purchase Line"; + SellToCustomer: Record Customer; + BillToCustomer: Record Customer; + SalesHeader: Record "Sales Header"; + SalesLine: Record "Sales Line"; + ReturnReceiptHeader: Record "Return Receipt Header"; IntrastatReportHeader: Record "Intrastat Report Header"; - ReturnShipmentHeader: Record "Return Shipment Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; IntrastatReportNo: Code[20]; + DocumentVATNo: Code[20]; begin - // [FEATURE] [Purchase] [Return Shipment] - // [SCENARIO 373278] Partner VAT ID is taken as VAT Registration No from Pay-to Vendor No. of Purchase Return Order + // [FEATURE] [Sales] [Return Receipt] + // [SCENARIO 422720] Partner VAT ID of Sales Return Receipt is taken according to Intrastat Setup Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Receipt; + IntrastatReportSetup.Modify(); - // [GIVEN] Return Shipment on Credit Memo = true - LibraryIntrastat.UpdateRetShpmtOnCrMemoPurchSetup(true); + // [GIVEN] Return Receipt on Cr. Memo = false + LibraryIntrastat.UpdateRetReceiptOnCrMemoSalesSetup(true); - // [GIVEN] Pay-to Vendor with VAT Registration No = 'AT0123456' - Vendor.Get(LibraryIntrastat.CreateVendorWithVATRegNo(true)); - LibraryIntrastat.CreatePurchaseHeader(PurchaseHeader, PurchaseHeader."Document Type"::"Credit Memo", WorkDate(), Vendor."No."); - LibraryIntrastat.CreatePurchaseLine(PurchaseHeader, PurchaseLine, PurchaseLine.Type::Item, LibraryIntrastat.CreateItem()); - LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true); + // [GIVEN] Sell-to Customer with VAT Registration No = 1 + // [GIVEN] Bill-to Customer with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Sales Return Receipt with different Sell-to and Bill-To customers and different VAT Registration No + SellToCustomer.Get(LibraryIntrastat.CreateCustomerWithVATRegNo(true)); + BillToCustomer.Get(LibraryIntrastat.CreateCustomerWithVATRegNo(true)); + LibraryIntrastat.CreateSalesDocument(SalesHeader, SalesLine, SellToCustomer."No.", WorkDate(), SalesLine."Document Type"::"Credit Memo", SalesLine.Type::Item, LibraryIntrastat.CreateItem(), 1); + SalesHeader.Validate("Bill-to Customer No.", BillToCustomer."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(SellToCustomer."Country/Region Code"); + SalesHeader.Validate("VAT Registration No.", DocumentVATNo); + SalesHeader.Modify(true); - // [WHEN] Intrastat Report Line is created + // [GIVEN] Post the Cr. Memo + LibrarySales.PostSalesDocument(SalesHeader, true, true); + + // Sell-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Sell-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Bill-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Bill-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", BillToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + + // Delete all posted sales return receipts + ReturnReceiptHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + end; + + [Test] + [Scope('OnPrem')] + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfServiceInvoice() + var + SellToCustomer: Record Customer; + BillToCustomer: Record Customer; + ServiceHeader: Record "Service Header"; + ServiceLine: Record "Service Line"; + ServiceInvoiceHeader: Record "Service Invoice Header"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + DocumentVATNo: Code[20]; + IntrastatReportNo: Code[20]; + begin + // [FEATURE] [Service] [Invoice] + // [SCENARIO 422720] Partner VAT ID of Service Invoice is taken according to Intrastat Setup + Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Shipment; + IntrastatReportSetup.Modify(); + + // [GIVEN] Shipment on Service Invoice = false + LibraryIntrastat.UpdateShipmentOnInvoiceServiceSetup(false); + + // [GIVEN] Sell-to Customer with VAT Registration No = 1 + // [GIVEN] Bill-to Customer with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Service Invoice with different Sell-to and Bill-To customers, and different VAT Registration No + SellToCustomer.Get(LibraryIntrastat.CreateCustomerWithVATRegNo(true)); + BillToCustomer.Get(LibraryIntrastat.CreateCustomerWithVATRegNo(true)); + LibraryIntrastat.CreateServiceDocument(ServiceHeader, ServiceLine, SellToCustomer."No.", WorkDate(), ServiceLine."Document Type"::Invoice, ServiceLine.Type::Item, LibraryIntrastat.CreateItem(), 1); + ServiceHeader.Validate("Bill-to Customer No.", BillToCustomer."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(SellToCustomer."Country/Region Code"); + ServiceHeader.Validate("VAT Registration No.", DocumentVATNo); + ServiceHeader.Modify(true); + + // [GIVEN] Post the invoice + LibraryService.PostServiceOrder(ServiceHeader, false, false, false); + + // Sell-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Sell-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Bill-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Bill-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", BillToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); - // [THEN] Partner VAT ID = 'AT0123456' in Intrastat Report Line - ReturnShipmentHeader.SetRange("Buy-from Vendor No.", Vendor."No."); - ReturnShipmentHeader.FindFirst(); - VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", Vendor."VAT Registration No."); - VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", ReturnShipmentHeader."VAT Registration No."); + // Delete all posted service invoices + ServiceInvoiceHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); end; [Test] [Scope('OnPrem')] - [HandlerFunctions('IntrastatReportGetLinesPageHandler')] - procedure GetPartnerIDFromVATRegNoOfPurchaseReceipt() + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfServiceShipment() var - PurchaseHeader: Record "Purchase Header"; - PurchaseLine: Record "Purchase Line"; + SellToCustomer: Record Customer; + BillToCustomer: Record Customer; + ServiceHeader: Record "Service Header"; + ServiceLine: Record "Service Line"; + ServiceShipmentHeader: Record "Service Shipment Header"; IntrastatReportHeader: Record "Intrastat Report Header"; - VendorNo: Code[20]; + IntrastatReportSetup: Record "Intrastat Report Setup"; + DocumentVATNo: Code[20]; IntrastatReportNo: Code[20]; begin - // [FEATURE] [Purchase] [Receipt] - // [SCENARIO 389253] Partner VAT ID is blank for Purchase Receipt + // [FEATURE] [Service] [Shipment] + // [SCENARIO 422720] Partner VAT ID of Service Shipment is taken according to Intrastat Setup Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Shipment; + IntrastatReportSetup.Modify(); - // [GIVEN] Posted purchase order with Pay-to Vendor with VAT Registration No = 'AT0123456' - VendorNo := LibraryIntrastat.CreateVendorWithVATRegNo(true); - LibraryIntrastat.CreatePurchaseHeader(PurchaseHeader, PurchaseHeader."Document Type"::Order, WorkDate(), VendorNo); - LibraryIntrastat.CreatePurchaseLine(PurchaseHeader, PurchaseLine, PurchaseLine.Type::Item, LibraryIntrastat.CreateItem()); - LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true); + // [GIVEN] Shipment on Service Invoice = true + LibraryIntrastat.UpdateShipmentOnInvoiceServiceSetup(true); - // [WHEN] Intrastat Report Line is created + // [GIVEN] Sell-to Customer with VAT Registration No = 1 + // [GIVEN] Bill-to Customer with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Service Shipment with different Sell-to and Bill-To customers, and different VAT Registration No + SellToCustomer.Get(LibraryIntrastat.CreateCustomerWithVATRegNo(true)); + BillToCustomer.Get(LibraryIntrastat.CreateCustomerWithVATRegNo(true)); + LibraryIntrastat.CreateServiceDocument(ServiceHeader, ServiceLine, SellToCustomer."No.", WorkDate(), ServiceLine."Document Type"::Invoice, ServiceLine.Type::Item, LibraryIntrastat.CreateItem(), 1); + ServiceHeader.Validate("Bill-to Customer No.", BillToCustomer."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(SellToCustomer."Country/Region Code"); + ServiceHeader.Validate("VAT Registration No.", DocumentVATNo); + ServiceHeader.Modify(true); + + // [GIVEN] Post the invoice + LibraryService.PostServiceOrder(ServiceHeader, false, false, false); + + // Sell-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Sell-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Bill-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Bill-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", BillToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + + // Delete all posted service shipments + ServiceShipmentHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + end; + + [Test] + [Scope('OnPrem')] + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfServiceCrMemo() + var + SellToCustomer: Record Customer; + BillToCustomer: Record Customer; + ServiceHeader: Record "Service Header"; + ServiceLine: Record "Service Line"; + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + DocumentVATNo: Code[20]; + IntrastatReportNo: Code[20]; + begin + // [FEATURE] [Service] [Cr. Memo] + // [SCENARIO 422720] Partner VAT ID of Service Cr. Memo is taken according to Intrastat Setup + Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Receipt; + IntrastatReportSetup.Modify(); + + // [GIVEN] Sell-to Customer with VAT Registration No = 1 + // [GIVEN] Bill-to Customer with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Service Cr. Memo with different Sell-to and Bill-To customers, and different VAT Registration No + SellToCustomer.Get(LibraryIntrastat.CreateCustomerWithVATRegNo(true)); + BillToCustomer.Get(LibraryIntrastat.CreateCustomerWithVATRegNo(true)); + LibraryIntrastat.CreateServiceDocument(ServiceHeader, ServiceLine, SellToCustomer."No.", WorkDate(), ServiceLine."Document Type"::"Credit Memo", ServiceLine.Type::Item, LibraryIntrastat.CreateItem(), 1); + ServiceHeader.Validate("Bill-to Customer No.", BillToCustomer."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(SellToCustomer."Country/Region Code"); + ServiceHeader.Validate("VAT Registration No.", DocumentVATNo); + ServiceHeader.Modify(true); + + // [GIVEN] Post the cr. memo + LibraryService.PostServiceOrder(ServiceHeader, false, false, false); + + // Sell-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Sell-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Bill-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Bill-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", BillToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + + // Delete all posted service credit memos + ServiceCrMemoHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, ServiceLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + end; - // [THEN] Partner VAT ID = '' in Intrastat Report Line - VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", ''); + [Test] + [Scope('OnPrem')] + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfPurchaseInvoice() + var + PurchaseHeader: Record "Purchase Header"; + PurchaseLine: Record "Purchase Line"; + PurchInvHeader: Record "Purch. Inv. Header"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + BuyFromVendor, PayToVendor : Record Vendor; + IntrastatReportNo: Code[20]; + DocumentVATNo: Code[20]; + begin + // [FEATURE] [Purchase] [Invoice] + // [SCENARIO 422720] Partner VAT ID of Purchase Invoice is taken according to Intrastat Setup + Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Receipt; + IntrastatReportSetup.Modify(); + + // [GIVEN] Receipt on Invoice = false + LibraryIntrastat.UpdateReceiptOnInvoicePurchSetup(false); + + // [GIVEN] Buy-from Vendor with VAT Registration No = 1 + // [GIVEN] Pay-to Vendor with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Purchase Invoice with different Buy-from and Pay-To vendors, and different VAT Registration No + BuyFromVendor.Get(LibraryIntrastat.CreateVendorWithVATRegNo(true)); + PayToVendor.Get(LibraryIntrastat.CreateVendorWithVATRegNo(true)); + LibraryIntrastat.CreatePurchaseHeader(PurchaseHeader, PurchaseHeader."Document Type"::Invoice, WorkDate(), BuyFromVendor."No."); + LibraryIntrastat.CreatePurchaseLine(PurchaseHeader, PurchaseLine, PurchaseLine.Type::Item, LibraryIntrastat.CreateItem()); + PurchaseHeader.Validate("Pay-to Vendor No.", PayToVendor."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(BuyFromVendor."Country/Region Code"); + PurchaseHeader.Validate("VAT Registration No.", DocumentVATNo); + PurchaseHeader.Modify(true); + + // [GIVEN] Post the invoice + LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true); + + // Buy-from VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Buy-from VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", BuyFromVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Pay-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Pay-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", PayToVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + + // Delete all posted purchase invoices + PurchInvHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", BuyFromVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + end; + + [Test] + [Scope('OnPrem')] + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfPurchaseReceipt() + var + PurchaseHeader: Record "Purchase Header"; + PurchaseLine: Record "Purchase Line"; + PurchRcptHeader: Record "Purch. Rcpt. Header"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + BuyFromVendor, PayToVendor : Record Vendor; + IntrastatReportNo: Code[20]; + DocumentVATNo: Code[20]; + begin + // [FEATURE] [Purchase] [Receipt] + // [SCENARIO 422720] Partner VAT ID of Purchase Receipt is taken according to Intrastat Setup + Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Receipt; + IntrastatReportSetup.Modify(); + + // [GIVEN] Receipt on Invoice = true + LibraryIntrastat.UpdateReceiptOnInvoicePurchSetup(true); + + // [GIVEN] Buy-from Vendor with VAT Registration No = 1 + // [GIVEN] Pay-to Vendor with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Purchase Receipt with different Buy-from and Pay-To vendors, and different VAT Registration No + BuyFromVendor.Get(LibraryIntrastat.CreateVendorWithVATRegNo(true)); + PayToVendor.Get(LibraryIntrastat.CreateVendorWithVATRegNo(true)); + LibraryIntrastat.CreatePurchaseHeader(PurchaseHeader, PurchaseHeader."Document Type"::Invoice, WorkDate(), BuyFromVendor."No."); + LibraryIntrastat.CreatePurchaseLine(PurchaseHeader, PurchaseLine, PurchaseLine.Type::Item, LibraryIntrastat.CreateItem()); + PurchaseHeader.Validate("Pay-to Vendor No.", PayToVendor."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(BuyFromVendor."Country/Region Code"); + PurchaseHeader.Validate("VAT Registration No.", DocumentVATNo); + PurchaseHeader.Modify(true); + + // [GIVEN] Post the invoice + LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true); + + // Buy-from VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Buy-from VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", BuyFromVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Pay-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Pay-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", PayToVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + + // Delete all posted purchase receipts + PurchRcptHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", BuyFromVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + end; + + [Test] + [Scope('OnPrem')] + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfPurchaseCrMemo() + var + PurchaseHeader: Record "Purchase Header"; + PurchaseLine: Record "Purchase Line"; + PurchCrMemoHdr: Record "Purch. Cr. Memo Hdr."; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + BuyFromVendor, PayToVendor : record Vendor; + IntrastatReportNo: Code[20]; + DocumentVATNo: Code[20]; + begin + // [FEATURE] [Purchase] [Cr Memo] + // [SCENARIO 422720] Partner VAT ID of Purchase Cr Memo is taken according to Intrastat Setup + Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Shipment; + IntrastatReportSetup.Modify(); + + // [GIVEN] Return Shipment on Credit Memo = false + LibraryIntrastat.UpdateRetShpmtOnCrMemoPurchSetup(false); + + // [GIVEN] Buy-from Vendor with VAT Registration No = 1 + // [GIVEN] Pay-to Vendor with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Purchase Cr. Memo with different Buy-from and Pay-To vendors, and different VAT Registration No + BuyFromVendor.Get(LibraryIntrastat.CreateVendorWithVATRegNo(true)); + PayToVendor.Get(LibraryIntrastat.CreateVendorWithVATRegNo(true)); + LibraryIntrastat.CreatePurchaseHeader(PurchaseHeader, PurchaseHeader."Document Type"::"Credit Memo", WorkDate(), BuyFromVendor."No."); + LibraryIntrastat.CreatePurchaseLine(PurchaseHeader, PurchaseLine, PurchaseLine.Type::Item, LibraryIntrastat.CreateItem()); + PurchaseHeader.Validate("Pay-to Vendor No.", PayToVendor."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(BuyFromVendor."Country/Region Code"); + PurchaseHeader.Validate("VAT Registration No.", DocumentVATNo); + PurchaseHeader.Modify(true); + + // [GIVEN] Post the cr. memo + LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true); + + // Buy-from VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Buy-from VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", BuyFromVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Pay-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Pay-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", PayToVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + + // Delete all posted purchase credit memos + PurchCrMemoHdr.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", BuyFromVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + end; + + [Test] + [Scope('OnPrem')] + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfPurchaseRetShpmt() + var + PurchaseHeader: Record "Purchase Header"; + PurchaseLine: Record "Purchase Line"; + ReturnShipmentHeader: Record "Return Shipment Header"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + BuyFromVendor, PayToVendor : record Vendor; + IntrastatReportNo: Code[20]; + DocumentVATNo: Code[20]; + begin + // [FEATURE] [Purchase] [Return Shipment] + // [SCENARIO 422720] Partner VAT ID of Purchase Return Shipment is taken according to Intrastat Setup + Initialize(); + + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Shipment; + IntrastatReportSetup.Modify(); + + // [GIVEN] Return Shipment on Credit Memo = true + LibraryIntrastat.UpdateRetShpmtOnCrMemoPurchSetup(true); + + // [GIVEN] Buy-from Vendor with VAT Registration No = 1 + // [GIVEN] Pay-to Vendor with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Purchase Receipt with different Buy-from and Pay-To vendors, and different VAT Registration No + BuyFromVendor.Get(LibraryIntrastat.CreateVendorWithVATRegNo(true)); + PayToVendor.Get(LibraryIntrastat.CreateVendorWithVATRegNo(true)); + LibraryIntrastat.CreatePurchaseHeader(PurchaseHeader, PurchaseHeader."Document Type"::"Credit Memo", WorkDate(), BuyFromVendor."No."); + LibraryIntrastat.CreatePurchaseLine(PurchaseHeader, PurchaseLine, PurchaseLine.Type::Item, LibraryIntrastat.CreateItem()); + PurchaseHeader.Validate("Pay-to Vendor No.", PayToVendor."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(BuyFromVendor."Country/Region Code"); + PurchaseHeader.Validate("VAT Registration No.", DocumentVATNo); + PurchaseHeader.Modify(true); + + // [GIVEN] Post the cr. memo + LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true); + + // Buy-from VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Buy-from VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", BuyFromVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Pay-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Pay-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", PayToVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + + // Delete all posted purchase return shipments + ReturnShipmentHeader.DeleteAll(false); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", BuyFromVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + end; + + [Test] + [Scope('OnPrem')] + [HandlerFunctions('IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfTransferReceipt() + var + FromCountryRegion: Record "Country/Region"; + FromLocation, ToLocation, InTransitLocation : Record Location; + TransferHeader: Record "Transfer Header"; + TransferLine: Record "Transfer Line"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + ItemNo: Code[20]; + IntrastatReportNo: Code[20]; + DocumentVATNo: Code[20]; + WD: Date; + begin + // [SCENARIO 465378] Verify receipt transaction in Intrastat Journal when transferring items from EU country to company country + Initialize(); + + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Receipt; + IntrastatReportSetup.Modify(); + + // [GIVEN] Source Location and Country with Intrastat Code. Location: "L1". Country "C1" + LibraryWarehouse.CreateLocationWithInventoryPostingSetup(FromLocation); + LibraryIntrastat.CreateCountryRegion(FromCountryRegion, true); + FromLocation."Country/Region Code" := FromCountryRegion.Code; + FromLocation.Modify(); + + // [GIVEN] Item on inventory for L1 + WD := WorkDate(); + WorkDate(CalcDate('<-1M>', WD)); + ItemNo := LibraryIntrastat.CreateItem(); + LibraryIntrastat.CreateAndPostPurchaseItemJournalLine(FromLocation.Code, ItemNo); + WorkDate(WD); + + // [GIVEN] Detination Location and Country, set in Company Information, with Intrastat Code. Location: "L2". Country "C2" + LibraryWarehouse.CreateLocationWithInventoryPostingSetup(ToLocation); + ToLocation."Country/Region Code" := LibraryIntrastat.GetCompanyInfoCountryRegionCode(); + ToLocation.Modify(); + + LibraryWarehouse.CreateInTransitLocation(InTransitLocation); + + // [GIVEN] Create Transfer Order + LibraryWarehouse.CreateTransferHeader(TransferHeader, FromLocation.Code, ToLocation.Code, InTransitLocation.Code); + LibraryWarehouse.CreateTransferLine(TransferHeader, TransferLine, ItemNo, 1); + + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(FromLocation.Code); + TransferHeader.Validate("Partner VAT ID", DocumentVATNo); + TransferHeader.Modify(true); + + // [GIVEN] Post Transfer Order + LibraryWarehouse.PostTransferOrder(TransferHeader, true, true); + + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID is taken from transfer receipt header + VerifyPartnerID(IntrastatReportHeader, TransferLine."Item No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + end; + + [Test] + [Scope('OnPrem')] + [HandlerFunctions('IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfTransferShipment() + var + ToCountryRegion: Record "Country/Region"; + FromLocation, ToLocation, InTransitLocation : Record Location; + TransferHeader: Record "Transfer Header"; + TransferLine: Record "Transfer Line"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + ItemNo: Code[20]; + IntrastatReportNo: Code[20]; + DocumentVATNo: Code[20]; + WD: Date; + begin + // [SCENARIO 465378] Verify shipment transaction in Intrastat Journal when transferring items from company country to EU country + Initialize(); + + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Shipment; + IntrastatReportSetup.Modify(); + + // [GIVEN] Source Location and Country, set in Company Information, with Intrastat Code. Location: "L1". Country "C1" + LibraryWarehouse.CreateLocationWithInventoryPostingSetup(FromLocation); + FromLocation."Country/Region Code" := LibraryIntrastat.GetCompanyInfoCountryRegionCode(); + FromLocation.Modify(); + + // [GIVEN] Item on inventory for L1 + WD := WorkDate(); + WorkDate(CalcDate('<-1M>', WD)); + ItemNo := LibraryIntrastat.CreateItem(); + LibraryIntrastat.CreateAndPostPurchaseItemJournalLine(FromLocation.Code, ItemNo); + WorkDate(WD); + + // [GIVEN] Destination Location and Country with Intrastat Code. Location: "L2". Country "C2" + LibraryWarehouse.CreateLocationWithInventoryPostingSetup(ToLocation); + LibraryIntrastat.CreateCountryRegion(ToCountryRegion, true); + ToLocation."Country/Region Code" := ToCountryRegion.Code; + ToLocation.Modify(); + + LibraryWarehouse.CreateInTransitLocation(InTransitLocation); + + // [GIVEN] Create Transfer Order + LibraryWarehouse.CreateTransferHeader(TransferHeader, FromLocation.Code, ToLocation.Code, InTransitLocation.Code); + LibraryWarehouse.CreateTransferLine(TransferHeader, TransferLine, ItemNo, 1); + + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(FromLocation.Code); + TransferHeader.Validate("Partner VAT ID", DocumentVATNo); + TransferHeader.Modify(true); + + // [GIVEN] Post Transfer Order + LibraryWarehouse.PostTransferOrder(TransferHeader, true, true); + + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID is taken from transfer shipment header + VerifyPartnerID(IntrastatReportHeader, TransferLine."Item No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + end; + + [Test] + [Scope('OnPrem')] + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfFixedAssetPurchase() + var + PurchaseHeader: Record "Purchase Header"; + PurchaseLine: Record "Purchase Line"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + BuyFromVendor, PayToVendor : record Vendor; + IntrastatReportNo: Code[20]; + DocumentVATNo: Code[20]; + begin + // [FEATURE] [Purchase] [Invoice] + // [SCENARIO 422720] Partner VAT ID of Purchase Invoice is taken according to Intrastat Setup + Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Receipt; + IntrastatReportSetup.Modify(); + + // [GIVEN] Receipt on Invoice = false + LibraryIntrastat.UpdateReceiptOnInvoicePurchSetup(false); + + // [GIVEN] Buy-from Vendor with VAT Registration No = 1 + // [GIVEN] Pay-to Vendor with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Purchase Invoice with different Buy-from and Pay-To vendors, and different VAT Registration No + BuyFromVendor.Get(LibraryIntrastat.CreateVendorWithVATRegNo(true)); + PayToVendor.Get(LibraryIntrastat.CreateVendorWithVATRegNo(true)); + LibraryIntrastat.CreatePurchaseHeader(PurchaseHeader, PurchaseHeader."Document Type"::Invoice, WorkDate(), BuyFromVendor."No."); + LibraryIntrastat.CreatePurchaseLine(PurchaseHeader, PurchaseLine, PurchaseLine.Type::"Fixed Asset", LibraryIntrastat.CreateFixedAsset()); + PurchaseHeader.Validate("Pay-to Vendor No.", PayToVendor."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(BuyFromVendor."Country/Region Code"); + PurchaseHeader.Validate("VAT Registration No.", DocumentVATNo); + PurchaseHeader.Modify(true); + + // [GIVEN] Post the invoice + LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true); + + // Buy-from VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Buy-from VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", BuyFromVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Pay-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::"Pay-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", PayToVendor."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Purchase VAT No. Based On" := IntrastatReportSetup."Purchase VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, PurchaseLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); + end; + + [Test] + [Scope('OnPrem')] + [HandlerFunctions('ConfirmHandler,IntrastatReportGetLinesPageHandler')] + procedure GetPartnerIDFromVATRegNoOfFixedAssetSale() + var + SellToCustomer: Record Customer; + BillToCustomer: Record Customer; + SalesHeader: Record "Sales Header"; + SalesLine: Record "Sales Line"; + PurchaseLine: Record "Purchase Line"; + IntrastatReportHeader: Record "Intrastat Report Header"; + IntrastatReportSetup: Record "Intrastat Report Setup"; + DocumentVATNo: Code[20]; + IntrastatReportNo: Code[20]; + begin + // [FEATURE] [Sales] [Invoice] + // [SCENARIO 422720] Partner VAT ID of Sales Invoice is taken according to Intrastat Setup + Initialize(); + IntrastatReportSetup.Get(); + IntrastatReportSetup."Get Partner VAT For" := IntrastatReportSetup."Get Partner VAT For"::Shipment; + IntrastatReportSetup.Modify(); + + LibraryIntrastat.CreateAndPostFixedAssetPurchaseOrder(PurchaseLine, CalcDate('<-1M>', WorkDate())); + // [GIVEN] Shipment on Sales Invoice = false + LibraryIntrastat.UpdateShipmentOnInvoiceSalesSetup(false); + + // [GIVEN] Sell-to Customer with VAT Registration No = 1 + // [GIVEN] Bill-to Customer with VAT Registration No = 2 + // [GIVEN] Document VAT Registration No = 3 + // [GIVEN] Sales Invoice with different Sell-to and Bill-To customers, and different VAT Registration No + SellToCustomer.Get(LibraryIntrastat.CreateCustomerWithVATRegNo(true)); + BillToCustomer.Get(LibraryIntrastat.CreateCustomerWithVATRegNo(true)); + LibraryIntrastat.CreateSalesDocument(SalesHeader, SalesLine, SellToCustomer."No.", WorkDate(), SalesLine."Document Type"::Invoice, SalesLine.Type::"Fixed Asset", PurchaseLine."No.", 1); + SalesHeader.Validate("Bill-to Customer No.", BillToCustomer."No."); + DocumentVATNo := LibraryERM.GenerateVATRegistrationNo(SellToCustomer."Country/Region Code"); + SalesHeader.Validate("VAT Registration No.", DocumentVATNo); + SalesHeader.Modify(true); + + // [GIVEN] Post the invoice + LibrarySales.PostSalesDocument(SalesHeader, true, true); + + // Sell-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Sell-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 1 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", SellToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Bill-to VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::"Bill-to VAT"; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 2 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", BillToCustomer."VAT Registration No."); + IntrastatReportHeader.Delete(true); + + // Document VAT No. is taken as Partner VAT ID + IntrastatReportSetup."Sales VAT No. Based On" := IntrastatReportSetup."Sales VAT No. Based On"::Document; + IntrastatReportSetup.Modify(); + // [WHEN] Suggest Intrastat Report Lines + CreateIntrastatReportAndSuggestLines(WorkDate(), IntrastatReportNo); + IntrastatReportHeader.Get(IntrastatReportNo); + // [THEN] Partner VAT ID = 3 in Intrastat Report Line + VerifyPartnerID(IntrastatReportHeader, SalesLine."No.", DocumentVATNo); + IntrastatReportHeader.Delete(true); end; [Test] diff --git a/Apps/W1/Intrastat/test/src/LibraryIntrastat.Codeunit.al b/Apps/W1/Intrastat/test/src/LibraryIntrastat.Codeunit.al index b77b20fd76..37bf003776 100644 --- a/Apps/W1/Intrastat/test/src/LibraryIntrastat.Codeunit.al +++ b/Apps/W1/Intrastat/test/src/LibraryIntrastat.Codeunit.al @@ -14,6 +14,7 @@ codeunit 139554 "Library - Intrastat" LibraryInventory: Codeunit "Library - Inventory"; LibraryFixedAsset: Codeunit "Library - Fixed Asset"; LibrarySales: Codeunit "Library - Sales"; + LibraryService: Codeunit "Library - Service"; LibraryRandom: Codeunit "Library - Random"; LibraryWarehouse: Codeunit "Library - Warehouse"; LibraryItemTracking: Codeunit "Library - Item Tracking"; @@ -236,6 +237,28 @@ codeunit 139554 "Library - Intrastat" SalesHeader.Modify(true); end; + procedure CreateServiceDocument(var ServiceHeader: Record "Service Header"; var ServiceLine: Record "Service Line"; CustomerNo: Code[20]; PostingDate: Date; DocumentType: Enum "Service Document Type"; Type: Enum "Service Line Type"; No: Code[20]; + NoOfLines: Integer) + var + i: Integer; + begin + // Create Service Order with Random Quantity and Unit Price. + CreateServiceHeader(ServiceHeader, CustomerNo, PostingDate, DocumentType); + for i := 1 to NoOfLines do begin + LibraryService.CreateServiceLine(ServiceLine, ServiceHeader, Type, No); + ServiceLine.Validate(Quantity, LibraryRandom.RandDec(100, 2)); + ServiceLine.Validate("Unit Price", LibraryRandom.RandDec(100, 2)); + ServiceLine.Modify(true); + end; + end; + + procedure CreateServiceHeader(var ServiceHeader: Record "Service Header"; CustomerNo: Code[20]; PostingDate: Date; DocumentType: Enum "Service Document Type") + begin + LibraryService.CreateServiceHeader(ServiceHeader, DocumentType, CustomerNo); + ServiceHeader.Validate("Posting Date", PostingDate); + ServiceHeader.Modify(true); + end; + procedure CreateAndPostSalesInvoiceWithItemAndItemCharge(PostingDate: Date): Code[20] var SalesHeader: Record "Sales Header"; @@ -869,6 +892,24 @@ codeunit 139554 "Library - Intrastat" SalesReceivablesSetup.Modify(true); end; + procedure UpdateRetReceiptOnCrMemoSalesSetup(RetReceiptOnCrMemo: Boolean) + var + SalesReceivablesSetup: Record "Sales & Receivables Setup"; + begin + SalesReceivablesSetup.Get(); + SalesReceivablesSetup.Validate("Return Receipt on Credit Memo", RetReceiptOnCrMemo); + SalesReceivablesSetup.Modify(true); + end; + + procedure UpdateShipmentOnInvoiceServiceSetup(ShipmentOnInvoice: Boolean) + var + ServiceMgtSetup: Record "Service Mgt. Setup"; + begin + ServiceMgtSetup.Get(); + ServiceMgtSetup.Validate("Shipment on Invoice", ShipmentOnInvoice); + ServiceMgtSetup.Modify(true); + end; + procedure UpdateRetShpmtOnCrMemoPurchSetup(RetShpmtOnCrMemo: Boolean) var PurchasesPayablesSetup: Record "Purchases & Payables Setup"; @@ -878,6 +919,15 @@ codeunit 139554 "Library - Intrastat" PurchasesPayablesSetup.Modify(true); end; + procedure UpdateReceiptOnInvoicePurchSetup(ReceiptOnInvoice: Boolean) + var + PurchasesPayablesSetup: Record "Purchases & Payables Setup"; + begin + PurchasesPayablesSetup.Get(); + PurchasesPayablesSetup.Validate("Receipt on Invoice", ReceiptOnInvoice); + PurchasesPayablesSetup.Modify(true); + end; + procedure UpdateReturnReceiptOnCreditMemoSalesSetup(ReturnReceiptOnCreditMemo: Boolean) var SalesReceivablesSetup: Record "Sales & Receivables Setup"; diff --git a/Apps/W1/PowerBIReports/app/src/Core/Codeunits/SetupHelper.Codeunit.al b/Apps/W1/PowerBIReports/app/src/Core/Codeunits/SetupHelper.Codeunit.al index 6e7d8f84f7..47a2cd54c4 100644 --- a/Apps/W1/PowerBIReports/app/src/Core/Codeunits/SetupHelper.Codeunit.al +++ b/Apps/W1/PowerBIReports/app/src/Core/Codeunits/SetupHelper.Codeunit.al @@ -105,7 +105,10 @@ codeunit 36961 "Setup Helper" begin PowerBiServiceMgt.InitializeAddinToken(PowerBIManagement); PowerBIManagement.SetLocale(TypeHelper.GetCultureName()); - PowerBIManagement.SetSettings(false, true, ReportPageTok = '', false, false, false, true); + PowerBIManagement.SetFiltersVisible(true); + PowerBIManagement.AddBottomPadding(true); + PowerBIManagement.SetPageSelectionVisible(ReportPageTok = ''); + PowerBIManagement.EmbedPowerBIReport( StrSubstNo(PowerBIEmbedReportUrlTemplateTxt, ReportId), ReportId, diff --git a/Apps/W1/ServiceDeclaration/app/src/Setup/ServDeclSetupWizard.Page.al b/Apps/W1/ServiceDeclaration/app/src/Setup/ServDeclSetupWizard.Page.al index 1e9a57ea18..ad7eb4fc0c 100644 --- a/Apps/W1/ServiceDeclaration/app/src/Setup/ServDeclSetupWizard.Page.al +++ b/Apps/W1/ServiceDeclaration/app/src/Setup/ServDeclSetupWizard.Page.al @@ -98,6 +98,11 @@ page 5021 "Serv. Decl. Setup Wizard" ApplicationArea = Basic, Suite; ToolTip = 'Specifies whether the VAT Registration No. is enabled for the service declaration.'; } + field("Enable Serv. Trans. Types"; Rec."Enable Serv. Trans. Types") + { + ApplicationArea = Basic, Suite; + ToolTip = 'Specifies whether the service transaction types are enabled for the service declaration.'; + } field("Vend. VAT Reg. No. Type"; Rec."Vend. VAT Reg. No. Type") { ApplicationArea = Basic, Suite; diff --git a/Apps/W1/ServiceDeclaration/app/src/Setup/ServiceDeclarationSetup.Page.al b/Apps/W1/ServiceDeclaration/app/src/Setup/ServiceDeclarationSetup.Page.al index 8b77cd8b0c..4a7a68cbca 100644 --- a/Apps/W1/ServiceDeclaration/app/src/Setup/ServiceDeclarationSetup.Page.al +++ b/Apps/W1/ServiceDeclaration/app/src/Setup/ServiceDeclarationSetup.Page.al @@ -48,6 +48,12 @@ page 5010 "Service Declaration Setup" ApplicationArea = Basic, Suite; ToolTip = 'Specifies whether the VAT Registration No. is enabled for the service declaration.'; } + field("Enable Serv. Trans. Types"; Rec."Enable Serv. Trans. Types") + { + ApplicationArea = Basic, Suite; + ToolTip = 'Specifies whether the service transaction types are enabled for the service declaration.'; + + } field("Vend. VAT Reg. No. Type"; Rec."Vend. VAT Reg. No. Type") { ApplicationArea = Basic, Suite; diff --git a/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLGetFulfillments.Codeunit.al b/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLGetFulfillments.Codeunit.al index 8fc5db971f..a5633781c2 100644 --- a/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLGetFulfillments.Codeunit.al +++ b/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLGetFulfillments.Codeunit.al @@ -1,4 +1,5 @@ namespace Microsoft.Integration.Shopify; + /// /// Codeunit Shpfy GQL Get Fulfillments (ID 30317) implements Interface Shpfy IGraphQL. /// diff --git a/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLGetNextSChannels.Codeunit.al b/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLGetNextSChannels.Codeunit.al index 4da64241b8..cb2ad20d3a 100644 --- a/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLGetNextSChannels.Codeunit.al +++ b/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLGetNextSChannels.Codeunit.al @@ -1,6 +1,7 @@ namespace Microsoft.Integration.Shopify; + /// -/// Codeunit Shpfy GQL Get Next S. Channels (ID 30375) implements Interface Shpfy IGraphQL. +/// Codeunit Shpfy GQL Get Next S. Channels (ID 30384) implements Interface Shpfy IGraphQL. /// codeunit 30384 "Shpfy GQL Get Next S. Channels" implements "Shpfy IGraphQL" { diff --git a/Apps/W1/Shopify/app/src/Metafields/Codeunits/IOwnerType/ShpfyMetafieldOwnerCompany.Codeunit.al b/Apps/W1/Shopify/app/src/Metafields/Codeunits/IOwnerType/ShpfyMetafieldOwnerCompany.Codeunit.al index 44ef1d693a..0abee274cd 100644 --- a/Apps/W1/Shopify/app/src/Metafields/Codeunits/IOwnerType/ShpfyMetafieldOwnerCompany.Codeunit.al +++ b/Apps/W1/Shopify/app/src/Metafields/Codeunits/IOwnerType/ShpfyMetafieldOwnerCompany.Codeunit.al @@ -17,6 +17,7 @@ codeunit 30366 "Shpfy Metafield Owner Company" implements "Shpfy IMetafield Owne JResponse: JsonToken; JMetafields: JsonArray; JNode: JsonObject; + JCompany: JsonObject; JItem: JsonToken; Id: BigInteger; UpdatedAt: DateTime; @@ -24,13 +25,14 @@ codeunit 30366 "Shpfy Metafield Owner Company" implements "Shpfy IMetafield Owne Parameters.Add('CompanyId', Format(OwnerId)); GraphQLType := GraphQLType::CompanyMetafieldIds; JResponse := CommunicationMgt.ExecuteGraphQL(GraphQLType, Parameters); - if JsonHelper.GetJsonArray(JResponse, JMetafields, 'data.company.metafields.edges') then - foreach JItem in JMetafields do - if JsonHelper.GetJsonObject(JItem.AsObject(), JNode, 'node') then begin - Id := CommunicationMgt.GetIdOfGId(JsonHelper.GetValueAsText(JNode, 'legacyResourceId')); - UpdatedAt := JsonHelper.GetValueAsDateTime(JNode, 'updatedAt'); - MetafieldIds.Add(Id, UpdatedAt); - end; + if JsonHelper.GetJsonObject(JResponse, JCompany, 'data.company') then + if JsonHelper.GetJsonArray(JResponse, JMetafields, 'data.company.metafields.edges') then + foreach JItem in JMetafields do + if JsonHelper.GetJsonObject(JItem.AsObject(), JNode, 'node') then begin + Id := CommunicationMgt.GetIdOfGId(JsonHelper.GetValueAsText(JNode, 'legacyResourceId')); + UpdatedAt := JsonHelper.GetValueAsDateTime(JNode, 'updatedAt'); + MetafieldIds.Add(Id, UpdatedAt); + end; end; procedure GetShopCode(OwnerId: BigInteger): Code[20] diff --git a/Apps/W1/Shopify/app/src/Metafields/Codeunits/IOwnerType/ShpfyMetafieldOwnerCustomer.Codeunit.al b/Apps/W1/Shopify/app/src/Metafields/Codeunits/IOwnerType/ShpfyMetafieldOwnerCustomer.Codeunit.al index 779fd82d80..0ca88a76a5 100644 --- a/Apps/W1/Shopify/app/src/Metafields/Codeunits/IOwnerType/ShpfyMetafieldOwnerCustomer.Codeunit.al +++ b/Apps/W1/Shopify/app/src/Metafields/Codeunits/IOwnerType/ShpfyMetafieldOwnerCustomer.Codeunit.al @@ -16,6 +16,7 @@ codeunit 30333 "Shpfy Metafield Owner Customer" implements "Shpfy IMetafield Own JResponse: JsonToken; JMetafields: JsonArray; JNode: JsonObject; + JCustomer: JsonObject; JItem: JsonToken; Id: BigInteger; UpdatedAt: DateTime; @@ -23,13 +24,14 @@ codeunit 30333 "Shpfy Metafield Owner Customer" implements "Shpfy IMetafield Own Parameters.Add('CustomerId', Format(OwnerId)); GraphQLType := GraphQLType::CustomerMetafieldIds; JResponse := CommunicationMgt.ExecuteGraphQL(GraphQLType, Parameters); - if JsonHelper.GetJsonArray(JResponse, JMetafields, 'data.customer.metafields.edges') then - foreach JItem in JMetafields do - if JsonHelper.GetJsonObject(JItem.AsObject(), JNode, 'node') then begin - Id := CommunicationMgt.GetIdOfGId(JsonHelper.GetValueAsText(JNode, 'legacyResourceId')); - UpdatedAt := JsonHelper.GetValueAsDateTime(JNode, 'updatedAt'); - MetafieldIds.Add(Id, UpdatedAt); - end; + if JsonHelper.GetJsonObject(JResponse, JCustomer, 'data.customer') then + if JsonHelper.GetJsonArray(JResponse, JMetafields, 'data.customer.metafields.edges') then + foreach JItem in JMetafields do + if JsonHelper.GetJsonObject(JItem.AsObject(), JNode, 'node') then begin + Id := CommunicationMgt.GetIdOfGId(JsonHelper.GetValueAsText(JNode, 'legacyResourceId')); + UpdatedAt := JsonHelper.GetValueAsDateTime(JNode, 'updatedAt'); + MetafieldIds.Add(Id, UpdatedAt); + end; end; procedure GetShopCode(OwnerId: BigInteger): Code[20] diff --git a/Apps/W1/Shopify/app/src/Metafields/Codeunits/IOwnerType/ShpfyMetafieldOwnerProduct.Codeunit.al b/Apps/W1/Shopify/app/src/Metafields/Codeunits/IOwnerType/ShpfyMetafieldOwnerProduct.Codeunit.al index 998a98036d..33df388352 100644 --- a/Apps/W1/Shopify/app/src/Metafields/Codeunits/IOwnerType/ShpfyMetafieldOwnerProduct.Codeunit.al +++ b/Apps/W1/Shopify/app/src/Metafields/Codeunits/IOwnerType/ShpfyMetafieldOwnerProduct.Codeunit.al @@ -16,6 +16,7 @@ codeunit 30334 "Shpfy Metafield Owner Product" implements "Shpfy IMetafield Owne JResponse: JsonToken; JMetafields: JsonArray; JNode: JsonObject; + JProduct: JsonObject; JItem: JsonToken; Id: BigInteger; UpdatedAt: DateTime; @@ -23,13 +24,14 @@ codeunit 30334 "Shpfy Metafield Owner Product" implements "Shpfy IMetafield Owne Parameters.Add('ProductId', Format(OwnerId)); GraphQLType := GraphQLType::ProductMetafieldIds; JResponse := CommunicationMgt.ExecuteGraphQL(GraphQLType, Parameters); - if JsonHelper.GetJsonArray(JResponse, JMetafields, 'data.product.metafields.edges') then - foreach JItem in JMetafields do - if JsonHelper.GetJsonObject(JItem.AsObject(), JNode, 'node') then begin - Id := CommunicationMgt.GetIdOfGId(JsonHelper.GetValueAsText(JNode, 'legacyResourceId')); - UpdatedAt := JsonHelper.GetValueAsDateTime(JNode, 'updatedAt'); - MetafieldIds.Add(Id, UpdatedAt); - end; + if JsonHelper.GetJsonObject(JResponse, JProduct, 'data.product') then + if JsonHelper.GetJsonArray(JResponse, JMetafields, 'data.product.metafields.edges') then + foreach JItem in JMetafields do + if JsonHelper.GetJsonObject(JItem.AsObject(), JNode, 'node') then begin + Id := CommunicationMgt.GetIdOfGId(JsonHelper.GetValueAsText(JNode, 'legacyResourceId')); + UpdatedAt := JsonHelper.GetValueAsDateTime(JNode, 'updatedAt'); + MetafieldIds.Add(Id, UpdatedAt); + end; end; procedure GetShopCode(OwnerId: BigInteger): Code[20] diff --git a/Apps/W1/Shopify/app/src/Metafields/Codeunits/IOwnerType/ShpfyMetafieldOwnerVariant.Codeunit.al b/Apps/W1/Shopify/app/src/Metafields/Codeunits/IOwnerType/ShpfyMetafieldOwnerVariant.Codeunit.al index 66b98ebf03..6017eb6d74 100644 --- a/Apps/W1/Shopify/app/src/Metafields/Codeunits/IOwnerType/ShpfyMetafieldOwnerVariant.Codeunit.al +++ b/Apps/W1/Shopify/app/src/Metafields/Codeunits/IOwnerType/ShpfyMetafieldOwnerVariant.Codeunit.al @@ -16,6 +16,7 @@ codeunit 30335 "Shpfy Metafield Owner Variant" implements "Shpfy IMetafield Owne JResponse: JsonToken; JMetafields: JsonArray; JNode: JsonObject; + JProductVariant: JsonObject; JItem: JsonToken; Id: BigInteger; UpdatedAt: DateTime; @@ -23,13 +24,14 @@ codeunit 30335 "Shpfy Metafield Owner Variant" implements "Shpfy IMetafield Owne Parameters.Add('VariantId', Format(OwnerId)); GraphQLType := GraphQLType::VariantMetafieldIds; JResponse := CommunicationMgt.ExecuteGraphQL(GraphQLType, Parameters); - if JsonHelper.GetJsonArray(JResponse, JMetafields, 'data.product.metafields.edges') then - foreach JItem in JMetafields do - if JsonHelper.GetJsonObject(JItem.AsObject(), JNode, 'node') then begin - Id := CommunicationMgt.GetIdOfGId(JsonHelper.GetValueAsText(JNode, 'legacyResourceId')); - UpdatedAt := JsonHelper.GetValueAsDateTime(JNode, 'updatedAt'); - MetafieldIds.Add(Id, UpdatedAt); - end; + if JsonHelper.GetJsonObject(JResponse, JProductVariant, 'data.productVariant') then + if JsonHelper.GetJsonArray(JResponse, JMetafields, 'data.productVariant.metafields.edges') then + foreach JItem in JMetafields do + if JsonHelper.GetJsonObject(JItem.AsObject(), JNode, 'node') then begin + Id := CommunicationMgt.GetIdOfGId(JsonHelper.GetValueAsText(JNode, 'legacyResourceId')); + UpdatedAt := JsonHelper.GetValueAsDateTime(JNode, 'updatedAt'); + MetafieldIds.Add(Id, UpdatedAt); + end; end; procedure GetShopCode(OwnerId: BigInteger): Code[20] diff --git a/Apps/W1/Shopify/app/src/PermissionSets/ShpfyObjects.PermissionSet.al b/Apps/W1/Shopify/app/src/PermissionSets/ShpfyObjects.PermissionSet.al index ce226d32a3..69e21bdb88 100644 --- a/Apps/W1/Shopify/app/src/PermissionSets/ShpfyObjects.PermissionSet.al +++ b/Apps/W1/Shopify/app/src/PermissionSets/ShpfyObjects.PermissionSet.al @@ -171,6 +171,8 @@ permissionset 30104 "Shpfy - Objects" codeunit "Shpfy GQL FindVariantBySKU" = X, codeunit "Shpfy GQL Fulfill Order" = X, codeunit "Shpfy GQL Get Fulfillments" = X, + codeunit "Shpfy GQL Get Next S. Channels" = X, + codeunit "Shpfy GQL Get SalesChannels" = X, codeunit "Shpfy GQL GetProductImage" = X, codeunit "Shpfy GQL InventoryActivate" = X, codeunit "Shpfy GQL InventoryEntries" = X, @@ -328,6 +330,7 @@ permissionset 30104 "Shpfy - Objects" codeunit "Shpfy RetRefProc ImportOnly" = X, codeunit "Shpfy Return Enum Convertor" = X, codeunit "Shpfy Returns API" = X, + codeunit "Shpfy Sales Channel API" = X, codeunit "Shpfy Shipping Charges" = X, codeunit "Shpfy Shipping Events" = X, codeunit "Shpfy Shipping Methods" = X, @@ -410,6 +413,7 @@ permissionset 30104 "Shpfy - Objects" page "Shpfy Return" = X, page "Shpfy Return Lines" = X, page "Shpfy Returns" = X, + page "Shpfy Sales Channels" = X, page "Shpfy Shipment Methods Mapping" = X, page "Shpfy Shop Card" = X, page "Shpfy Shop Locations Mapping" = X, diff --git a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyProductAPI.Codeunit.al b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyProductAPI.Codeunit.al index 70a79ce555..d5c10083f4 100644 --- a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyProductAPI.Codeunit.al +++ b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyProductAPI.Codeunit.al @@ -66,7 +66,6 @@ codeunit 30176 "Shpfy Product API" GraphQuery.Append(CommunicationMgt.EscapeGraphQLData(ShopifyProduct.Vendor)); GraphQuery.Append('\"'); end; - if ShopifyProduct."Has Variants" or (ShopifyVariant."UoM Option Id" > 0) then begin GraphQuery.Append(', productOptions: [{name: \"'); GraphQuery.Append(CommunicationMgt.EscapeGraphQLData(ShopifyVariant."Option 1 Name")); diff --git a/Apps/W1/Shopify/app/src/Transactions/Reports/ShpfySuggestPayments.Report.al b/Apps/W1/Shopify/app/src/Transactions/Reports/ShpfySuggestPayments.Report.al index b11552f5b6..773ba11602 100644 --- a/Apps/W1/Shopify/app/src/Transactions/Reports/ShpfySuggestPayments.Report.al +++ b/Apps/W1/Shopify/app/src/Transactions/Reports/ShpfySuggestPayments.Report.al @@ -223,6 +223,7 @@ report 30118 "Shpfy Suggest Payments" begin SalesInvoiceHeader.SetLoadFields("No.", "Shpfy Order Id"); SalesInvoiceHeader.SetRange("Shpfy Order Id", OrderTransaction."Shopify Order Id"); + SalesInvoiceHeader.SetRange(Closed, false); if SalesInvoiceHeader.FindSet() then begin repeat CustLedgerEntry.SetAutoCalcFields("Remaining Amount"); @@ -250,6 +251,7 @@ report 30118 "Shpfy Suggest Payments" repeat SalesCreditMemoHeader.SetLoadFields("Shpfy Refund Id", "No."); SalesCreditMemoHeader.SetRange("Shpfy Refund Id", RefundHeader."Refund Id"); + SalesCreditMemoHeader.SetRange(Paid, false); if SalesCreditMemoHeader.FindSet() then repeat CustLedgerEntry.SetAutoCalcFields("Remaining Amount"); diff --git a/Apps/W1/Shopify/test/.resources/Products/CreatedProductResponse.txt b/Apps/W1/Shopify/test/.resources/Products/CreatedProductResponse.txt new file mode 100644 index 0000000000..9c9b573a54 --- /dev/null +++ b/Apps/W1/Shopify/test/.resources/Products/CreatedProductResponse.txt @@ -0,0 +1 @@ +{ "data": { "productCreate": { "product": { "legacyResourceId": "1234567890"} }}} \ No newline at end of file diff --git a/Apps/W1/Shopify/test/.resources/Products/DefaultSalesChannelResponse.txt b/Apps/W1/Shopify/test/.resources/Products/DefaultSalesChannelResponse.txt new file mode 100644 index 0000000000..d4d1dd63c6 --- /dev/null +++ b/Apps/W1/Shopify/test/.resources/Products/DefaultSalesChannelResponse.txt @@ -0,0 +1 @@ +[ { "node": { "id": "gid://shopify/Publication/%1", "catalog": {"apps": { "edges": [ { "node": { "handle": "online_store", "title": "Online Store" } } ] } } } }, { "node": { "id": "gid://shopify/Publication/%2", "catalog": { "apps": { "edges": [ { "node": {"handle": "pos", "title": "Point of Sale" } } ] } } } } ] \ No newline at end of file diff --git a/Apps/W1/Shopify/test/.resources/Products/EmptyPublishResponse.txt b/Apps/W1/Shopify/test/.resources/Products/EmptyPublishResponse.txt new file mode 100644 index 0000000000..00f240da71 --- /dev/null +++ b/Apps/W1/Shopify/test/.resources/Products/EmptyPublishResponse.txt @@ -0,0 +1 @@ +{ "data": { "publishablePublish": { "userErrors": [] } }, "extensions": { "cost": { "requestedQueryCost": 10, "actualQueryCost": 10, "throttleStatus": { "maximumAvailable": 2000, "currentlyAvailable": 1990, "restoreRate": 100 } } } } \ No newline at end of file diff --git a/Apps/W1/Shopify/test/.resources/Products/UpdatedVariantResponse.txt b/Apps/W1/Shopify/test/.resources/Products/UpdatedVariantResponse.txt new file mode 100644 index 0000000000..4ae5d41d37 --- /dev/null +++ b/Apps/W1/Shopify/test/.resources/Products/UpdatedVariantResponse.txt @@ -0,0 +1 @@ +{ "data": { "productVariantUpdate": { "productVariant": { "legacyResourceId": "1234567890"} }}} \ No newline at end of file diff --git a/Apps/W1/Shopify/test/Base/ShpfyInitializeTest.Codeunit.al b/Apps/W1/Shopify/test/Base/ShpfyInitializeTest.Codeunit.al index 31726db87f..56ecb3729b 100644 --- a/Apps/W1/Shopify/test/Base/ShpfyInitializeTest.Codeunit.al +++ b/Apps/W1/Shopify/test/Base/ShpfyInitializeTest.Codeunit.al @@ -380,10 +380,7 @@ codeunit 139561 "Shpfy Initialize Test" ShippingChargesGLAccount.Get(LibraryERM.CreateGLAccountWithVATPostingSetup(VATPostingSetup, GenPostingType::Sale)); ShippingChargesGLAccount."Direct Posting" := true; ShippingChargesGLAccount.Modify(false); - CreateVATPostingSetup(PostingGroupCode, ShippingChargesGLAccount."VAT Prod. Posting Group"); - exit(ShippingChargesGLAccount."No."); end; - -} +} \ No newline at end of file diff --git a/Apps/W1/Shopify/test/Products/ShpfySalesChannelHelper.Codeunit.al b/Apps/W1/Shopify/test/Products/ShpfySalesChannelHelper.Codeunit.al index a1d6ddde0e..4e99e56ced 100644 --- a/Apps/W1/Shopify/test/Products/ShpfySalesChannelHelper.Codeunit.al +++ b/Apps/W1/Shopify/test/Products/ShpfySalesChannelHelper.Codeunit.al @@ -1,16 +1,14 @@ -/// -/// Codeunit Shpfy Sales Channel Helper (ID 139583). -/// codeunit 139699 "Shpfy Sales Channel Helper" { internal procedure GetDefaultShopifySalesChannelResponse(OnlineStoreId: BigInteger; POSId: BigInteger): JsonArray var JPublications: JsonArray; NodesTxt: Text; - ResponseTok: Label '[ { "node": { "id": "gid://shopify/Publication/%1", "catalog": {"apps": { "edges": [ { "node": { "handle": "online_store", "title": "Online Store" } } ] } } } }, { "node": { "id": "gid://shopify/Publication/%2", "catalog": { "apps": { "edges": [ { "node": {"handle": "pos", "title": "Point of Sale" } } ] } } } } ]', Locked = true; + ResInStream: InStream; begin - NodesTxt := StrSubstNo(ResponseTok, OnlineStoreId, POSId); - JPublications.ReadFrom(NodesTxt); + NavApp.GetResource('Products/DefaultSalesChannelResponse.txt', ResInStream, TextEncoding::UTF8); + ResInStream.ReadText(NodesTxt); + JPublications.ReadFrom(StrSubstNo(NodesTxt, OnlineStoreId, POSId)); exit(JPublications); end; } \ No newline at end of file diff --git a/Apps/W1/Shopify/test/Products/ShpfySalesChannelSubs.Codeunit.al b/Apps/W1/Shopify/test/Products/ShpfySalesChannelSubs.Codeunit.al index ebcaa29b7e..eada6af602 100644 --- a/Apps/W1/Shopify/test/Products/ShpfySalesChannelSubs.Codeunit.al +++ b/Apps/W1/Shopify/test/Products/ShpfySalesChannelSubs.Codeunit.al @@ -25,7 +25,8 @@ codeunit 139697 "Shpfy Sales Channel Subs." GraphQlQuery: Text; PublishProductTok: Label '{"query":"mutation {publishablePublish(id: \"gid://shopify/Product/', locked = true; ProductCreateTok: Label '{"query":"mutation {productCreate(', locked = true; - + VariantUpdateTok: Label '{"query":"mutation { productVariantUpdate(', locked = true; + InventoryActivationTok: Label '{"query":"mutation inventoryBulkToggleActivation(', locked = true; GraphQLCmdTxt: Label '/graphql.json', Locked = true; begin case HttpRequestMessage.Method of @@ -44,6 +45,10 @@ codeunit 139697 "Shpfy Sales Channel Subs." HttpResponseMessage := GetCreateProductResponse(); GraphQlQuery = GQLGetSalesChannels.GetGraphQL(): HttpResponseMessage := GetSalesChannelsResponse(); + GraphQlQuery.Contains(VariantUpdateTok): + HttpResponseMessage := GetUpdateVariantResponse(); + GraphQlQuery.Contains(InventoryActivationTok): + HttpResponseMessage := GetInventoryActivateResponse(); end; end; end; @@ -53,8 +58,10 @@ codeunit 139697 "Shpfy Sales Channel Subs." var HttpResponseMessage: HttpResponseMessage; BodyTxt: Text; + ResInStream: InStream; begin - BodyTxt := '{ "data": { "publishablePublish": { "userErrors": [] } }, "extensions": { "cost": { "requestedQueryCost": 10, "actualQueryCost": 10, "throttleStatus": { "maximumAvailable": 2000, "currentlyAvailable": 1990, "restoreRate": 100 } } } }'; + NavApp.GetResource('Products/EmptyPublishResponse.txt', ResInStream, TextEncoding::UTF8); + ResInStream.ReadText(BodyTxt); HttpResponseMessage.Content.WriteFrom(BodyTxt); exit(HttpResponseMessage); end; @@ -63,12 +70,34 @@ codeunit 139697 "Shpfy Sales Channel Subs." var HttpResponseMessage: HttpResponseMessage; BodyTxt: Text; + ResInStream: InStream; begin - BodyTxt := '{ "data": { "productCreate": { "product": { "legacyResourceId": "1234567890"} }}}'; + NavApp.GetResource('Products/CreatedProductResponse.txt', ResInStream, TextEncoding::UTF8); + ResInStream.ReadText(BodyTxt); HttpResponseMessage.Content.WriteFrom(BodyTxt); exit(HttpResponseMessage); end; + local procedure GetUpdateVariantResponse(): HttpResponseMessage + var + HttpResponseMessage: HttpResponseMessage; + BodyTxt: Text; + ResInStream: InStream; + begin + NavApp.GetResource('Products/UpdatedVariantResponse.txt', ResInStream, TextEncoding::UTF8); + ResInStream.ReadText(BodyTxt); + HttpResponseMessage.Content.WriteFrom(BodyTxt); + exit(HttpResponseMessage); + end; + + local procedure GetInventoryActivateResponse(): HttpResponseMessage + var + HttpResponseMessage: HttpResponseMessage; + begin + HttpResponseMessage.Content.WriteFrom('{}'); + exit(HttpResponseMessage); + end; + local procedure GetSalesChannelsResponse(): HttpResponseMessage var HttpResponseMessage: HttpResponseMessage; diff --git a/Apps/W1/Shopify/test/Products/ShpfySalesChannelTest.Codeunit.al b/Apps/W1/Shopify/test/Products/ShpfySalesChannelTest.Codeunit.al index e8790d848c..f31b382973 100644 --- a/Apps/W1/Shopify/test/Products/ShpfySalesChannelTest.Codeunit.al +++ b/Apps/W1/Shopify/test/Products/ShpfySalesChannelTest.Codeunit.al @@ -1,6 +1,3 @@ -/// -/// Codeunit Shpfy Sales Channel Test (ID 139581). -/// codeunit 139698 "Shpfy Sales Channel Test" { Subtype = Test; diff --git a/Apps/W1/StatisticalAccounts/app/src/StatAccPostBatch.Codeunit.al b/Apps/W1/StatisticalAccounts/app/src/StatAccPostBatch.Codeunit.al index e1ee4ea237..eb279343c2 100644 --- a/Apps/W1/StatisticalAccounts/app/src/StatAccPostBatch.Codeunit.al +++ b/Apps/W1/StatisticalAccounts/app/src/StatAccPostBatch.Codeunit.al @@ -30,6 +30,8 @@ codeunit 2626 "Stat. Acc. Post. Batch" VerifyLines(StatisticalAccJournalLine); ProcessLines(StatisticalAccJournalLine); StatisticalAccJournalLine.DeleteAll(); + StatisticalAccJournalLine.SetRange("Journal Template Name"); + StatisticalAccJournalLine.SetRange("Journal Batch Name"); Commit(); diff --git a/Apps/W1/StatisticalAccounts/test/src/StatisticalAccountTest.Codeunit.al b/Apps/W1/StatisticalAccounts/test/src/StatisticalAccountTest.Codeunit.al index 7a06b8eb9e..e30470f843 100644 --- a/Apps/W1/StatisticalAccounts/test/src/StatisticalAccountTest.Codeunit.al +++ b/Apps/W1/StatisticalAccounts/test/src/StatisticalAccountTest.Codeunit.al @@ -499,6 +499,50 @@ codeunit 139683 "Statistical Account Test" StatAccJnlPage.Close(); end; + [Test] + [HandlerFunctions('MessageDialogHandler,ConfirmationDialogHandler')] + procedure JnlLinesBindToNewBatchAfterPostingInOldBatch() + var + StatisticalAccount: Record "Statistical Account"; + StatisticalAccJournalBatch: Record "Statistical Acc. Journal Batch"; + TempStatisticalAccountLedgerEntries: Record "Statistical Ledger Entry" temporary; + StatisticalAccountsJournal: TestPage "Statistical Accounts Journal"; + begin + // [SCENARIO 559516] Stan can create journal lines in the new batch after posting in the old one + + Initialize(); + // [GIVEN] A statistical journal line is registered in the default batch + CreateStatisticalAccount(StatisticalAccount); + CreateTransactions(StatisticalAccount, 1, TempStatisticalAccountLedgerEntries); + CreateJournal(StatisticalAccountsJournal, TempStatisticalAccountLedgerEntries); + RegisterJournal(StatisticalAccountsJournal); + + // [GIVEN] New batch is created + StatisticalAccJournalBatch.Name := LibraryUtility.GenerateGUID(); + StatisticalAccJournalBatch.Insert(); + + // [GIVEN] New batch is chosen in the journal + StatisticalAccountsJournal.CurrentJnlBatchName.SetValue(StatisticalAccJournalBatch.Name); + + // [GIVEN] A new line is added to the journal for the new batch + CreateStatisticalAccount(StatisticalAccount); + CreateTransactions(StatisticalAccount, 1, TempStatisticalAccountLedgerEntries); + StatisticalAccountsJournal.New(); + StatisticalAccountsJournal."Posting Date".SetValue(TempStatisticalAccountLedgerEntries."Posting Date"); + StatisticalAccountsJournal.StatisticalAccountNo.SetValue(TempStatisticalAccountLedgerEntries."Statistical Account No."); + StatisticalAccountsJournal.Amount.SetValue(TempStatisticalAccountLedgerEntries.Amount); + + // [WHEN] Click register journal and choose "No" + CancelRegisterJournal(StatisticalAccountsJournal); + + // [THEN] The line is still under the new batch + StatisticalAccountsJournal.StatisticalAccountNo.AssertEquals(StatisticalAccount."No."); + + // Tear down + StatisticalAccountsJournal.Close(); + + end; + local procedure SetupFinancialReport() var AccScheduleLine: Record "Acc. Schedule Line"; @@ -564,6 +608,13 @@ codeunit 139683 "Statistical Account Test" StatisticalAccountsJournal.Register.Invoke(); end; + local procedure CancelRegisterJournal(var StatisticalAccountsJournal: TestPage "Statistical Accounts Journal") + begin + LibraryVariableStorage.Enqueue('register'); + LibraryVariableStorage.Enqueue(false); + StatisticalAccountsJournal.Register.Invoke(); + end; + local procedure VerifyStatisticalAccountBalances(var StatAccountBalance: TestPage "Stat. Account Balance"; var TempStatisticalAccountLedgerEntries: Record "Statistical Ledger Entry" temporary) var AnalysisPeriodType: Enum "Analysis Period Type"; diff --git a/Build/DisabledTests/RecommendedApps.json b/Build/DisabledTests/RecommendedApps.json new file mode 100644 index 0000000000..a01a5e1629 --- /dev/null +++ b/Build/DisabledTests/RecommendedApps.json @@ -0,0 +1,6 @@ +{ + "bug": "405058", + "codeunitId": 139527, + "codeunitName": "Recommended Apps Tests", + "method": "*" +} \ No newline at end of file