diff --git a/.github/AL-Go-Settings.json b/.github/AL-Go-Settings.json index 8dc7cf12cd..cea11585c1 100644 --- a/.github/AL-Go-Settings.json +++ b/.github/AL-Go-Settings.json @@ -6,7 +6,7 @@ "runs-on": "windows-latest", "cacheImageName": "", "UsePsSession": false, - "artifact": "https://bcinsider-fvh2ekdjecfjd6gk.b02.azurefd.net/sandbox/28.0.45946.0/base", + "artifact": "https://bcinsider-fvh2ekdjecfjd6gk.b02.azurefd.net/sandbox/28.0.46297.0/base", "country": "base", "useProjectDependencies": true, "repoVersion": "28.0", diff --git a/Apps/AT/ContosoCoffeeDemoDatasetAT/app/DemoData/Finance/2. Master Data/CreateCurrencyExRateAT.Codeunit.al b/Apps/AT/ContosoCoffeeDemoDatasetAT/app/DemoData/Finance/2. Master Data/CreateCurrencyExRateAT.Codeunit.al index 7790b87081..a595ea2741 100644 --- a/Apps/AT/ContosoCoffeeDemoDatasetAT/app/DemoData/Finance/2. Master Data/CreateCurrencyExRateAT.Codeunit.al +++ b/Apps/AT/ContosoCoffeeDemoDatasetAT/app/DemoData/Finance/2. Master Data/CreateCurrencyExRateAT.Codeunit.al @@ -189,4 +189,14 @@ codeunit 11154 "Create Currency Ex. Rate AT" CurrencyExchangeRate.Validate("Relational Exch. Rate Amount", RelationalExchRateAmount); CurrencyExchangeRate.Validate("Relational Adjmt Exch Rate Amt", RelationalAdjmtExchRateAmt); end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Add. Reporting Currency", OnBeforeGetResidualCurrencyAccounts, '', false, false)] + local procedure GetResidualCurrencyAccountsAT(var FXGainsAccount: Code[20]; var FXLossesAccount: Code[20]; var IsHandled: Boolean) + var + CreateATGLAccount: Codeunit "Create AT GL Account"; + begin + FXGainsAccount := CreateATGLAccount.FCYRealizedExchangeGains(); + FXLossesAccount := CreateATGLAccount.FCYRealizedExchangeLosses(); + IsHandled := true; + end; } diff --git a/Apps/BE/ContosoCoffeeDemoDatasetBE/app/DemoData/Finance/2. Master Data/CreateCurrencyExRateBE.Codeunit.al b/Apps/BE/ContosoCoffeeDemoDatasetBE/app/DemoData/Finance/2. Master Data/CreateCurrencyExRateBE.Codeunit.al index 38572b64f3..2034ef83c0 100644 --- a/Apps/BE/ContosoCoffeeDemoDatasetBE/app/DemoData/Finance/2. Master Data/CreateCurrencyExRateBE.Codeunit.al +++ b/Apps/BE/ContosoCoffeeDemoDatasetBE/app/DemoData/Finance/2. Master Data/CreateCurrencyExRateBE.Codeunit.al @@ -199,4 +199,14 @@ codeunit 11367 "Create Currency Ex. Rate BE" CurrencyExchangeRate.Validate("Relational Exch. Rate Amount", RelationalExchRateAmount); CurrencyExchangeRate.Validate("Relational Adjmt Exch Rate Amt", RelationalAdjmtExchRateAmt); end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Add. Reporting Currency", OnBeforeGetResidualCurrencyAccounts, '', false, false)] + local procedure GetResidualCurrencyAccountsBE(var FXGainsAccount: Code[20]; var FXLossesAccount: Code[20]; var IsHandled: Boolean) + var + CreateBEGLAccount: Codeunit "Create GL Account BE"; + begin + FXGainsAccount := CreateBEGLAccount.RealizedExchRateDiffIncome(); + FXLossesAccount := CreateBEGLAccount.RealizedExchRateDiffExpense(); + IsHandled := true; + end; } diff --git a/Apps/CH/ContosoCoffeeDemoDatasetCH/app/DemoData/Finance/1.Setup Data/CreateCHPostingGroups.Codeunit.al b/Apps/CH/ContosoCoffeeDemoDatasetCH/app/DemoData/Finance/1.Setup Data/CreateCHPostingGroups.Codeunit.al index 2cf5c51adb..22d5561abe 100644 --- a/Apps/CH/ContosoCoffeeDemoDatasetCH/app/DemoData/Finance/1.Setup Data/CreateCHPostingGroups.Codeunit.al +++ b/Apps/CH/ContosoCoffeeDemoDatasetCH/app/DemoData/Finance/1.Setup Data/CreateCHPostingGroups.Codeunit.al @@ -48,21 +48,30 @@ codeunit 11602 "Create CH Posting Groups" CreatePostingGroup: Codeunit "Create Posting Groups"; begin ContosoGenPostingSetup.SetOverwriteData(true); - ContosoGenPostingSetup.InsertGeneralPostingSetup('', CreatePostingGroup.RetailPostingGroup(), '', '', CreateCHGLAccounts.InvChangeCommGoods(), '', '', '', '', '', '', '', CreateCHGLAccounts.InvChangeCommGoods(), '', ''); - ContosoGenPostingSetup.InsertGeneralPostingSetup(CreatePostingGroup.DomesticPostingGroup(), CreatePostingGroup.RetailPostingGroup(), CreateCHGLAccounts.TradeDomestic(), CreateCHGLAccounts.CostOfCommGoodsDomestic(), CreateCHGLAccounts.InvChangeCommGoods(), CreateCHGLAccounts.InvChangeCommGoods(), '', '', CreateCHGLAccounts.TradeDomestic(), CreateCHGLAccounts.Discounts(), CreateCHGLAccounts.CostOfCommGoodsDomestic(), CreateCHGLAccounts.CostReductionDiscount(), CreateCHGLAccounts.InvChangeCommGoods(), '', ''); - ContosoGenPostingSetup.InsertGeneralPostingSetup(CreatePostingGroup.DomesticPostingGroup(), CreatePostingGroup.ServicesPostingGroup(), CreateCHGLAccounts.ServiceEarningsDomestic(), CreateCHGLAccounts.SubcontrOfSpOperations(), CreateCHGLAccounts.InvChangeFinishedProducts(), '', '', '', CreateCHGLAccounts.ServiceEarningsDomestic(), CreateCHGLAccounts.Discounts(), CreateCHGLAccounts.SubcontrOfSpOperations(), CreateCHGLAccounts.CostReductionDiscount(), CreateCHGLAccounts.InvChangeFinishedProducts(), '', ''); - ContosoGenPostingSetup.InsertGeneralPostingSetup(CreatePostingGroup.EUPostingGroup(), CreatePostingGroup.RetailPostingGroup(), CreateCHGLAccounts.TradeEurope(), CreateCHGLAccounts.CostOfCommGoodsEurope(), CreateCHGLAccounts.InvChangeCommGoods(), CreateCHGLAccounts.InvChangeCommGoods(), '', '', CreateCHGLAccounts.TradeEurope(), CreateCHGLAccounts.Discounts(), CreateCHGLAccounts.CostOfCommGoodsEurope(), CreateCHGLAccounts.CostReductionDiscount(), CreateCHGLAccounts.InvChangeCommGoods(), '', ''); - ContosoGenPostingSetup.InsertGeneralPostingSetup(CreatePostingGroup.EUPostingGroup(), CreatePostingGroup.ServicesPostingGroup(), CreateCHGLAccounts.ProdEarningsEurope(), CreateCHGLAccounts.CostOfMaterialsEurope(), CreateCHGLAccounts.InvChangeFinishedProducts(), '', '', '', CreateCHGLAccounts.ProdEarningsEurope(), CreateCHGLAccounts.Discounts(), CreateCHGLAccounts.CostOfMaterialsEurope(), CreateCHGLAccounts.CostReductionDiscount(), CreateCHGLAccounts.InvChangeFinishedProducts(), '', ''); - ContosoGenPostingSetup.InsertGeneralPostingSetup(CreatePostingGroup.ExportPostingGroup(), CreatePostingGroup.RetailPostingGroup(), CreateCHGLAccounts.TradeInternat(), CreateCHGLAccounts.CostOfCommGoodsIntl(), CreateCHGLAccounts.InvChangeCommGoods(), CreateCHGLAccounts.InvChangeCommGoods(), '', '', CreateCHGLAccounts.TradeInternat(), CreateCHGLAccounts.Discounts(), CreateCHGLAccounts.CostOfCommGoodsIntl(), CreateCHGLAccounts.CostReductionDiscount(), CreateCHGLAccounts.InvChangeCommGoods(), '', ''); + ContosoGenPostingSetup.InsertGeneralPostingSetup('', CreatePostingGroup.RetailPostingGroup(), '', '', CreateCHGLAccounts.InvChangeCommGoods(), '', '', '', '', '', '', '', '', '', ''); + ContosoGenPostingSetup.InsertGeneralPostingSetup('', CreatePostingGroup.ServicesPostingGroup(), '', '', CreateCHGLAccounts.InvChangeCommGoods(), '', '', '', '', '', '', '', '', '', ''); + ContosoGenPostingSetup.InsertGeneralPostingSetup('', CreatePostingGroup.ZeroPostingGroup(), '', '', CreateCHGLAccounts.InvChangeCommGoods(), '', '', '', '', '', '', '', '', '', ''); + ContosoGenPostingSetup.InsertGeneralPostingSetup(CreatePostingGroup.DomesticPostingGroup(), CreatePostingGroup.RetailPostingGroup(), CreateCHGLAccounts.TradeDomestic(), CreateCHGLAccounts.CostOfCommGoodsDomestic(), CreateCHGLAccounts.InvChangeCommGoods(), CreateCHGLAccounts.CostOfCommGoodsDomestic(), '', '', CreateCHGLAccounts.TradeDomestic(), CreateCHGLAccounts.Discounts(), CreateCHGLAccounts.CostOfCommGoodsDomestic(), CreateCHGLAccounts.CostReductionDiscount(), CreateCHGLAccounts.CostOfCommGoodsDomestic(), '', ''); + ContosoGenPostingSetup.InsertGeneralPostingSetup(CreatePostingGroup.DomesticPostingGroup(), CreatePostingGroup.ServicesPostingGroup(), CreateCHGLAccounts.ServiceEarningsDomestic(), CreateCHGLAccounts.SubcontrOfSpOperations(), CreateCHGLAccounts.InvChangeCommGoods(), CreateCHGLAccounts.SubcontrOfSpOperations(), '', '', CreateCHGLAccounts.ServiceEarningsDomestic(), CreateCHGLAccounts.Discounts(), CreateCHGLAccounts.SubcontrOfSpOperations(), CreateCHGLAccounts.CostReductionDiscount(), CreateCHGLAccounts.SubcontrOfSpOperations(), '', ''); + ContosoGenPostingSetup.InsertGeneralPostingSetup(CreatePostingGroup.DomesticPostingGroup(), CreatePostingGroup.ZeroPostingGroup(), CreateCHGLAccounts.TradeDomestic(), CreateCHGLAccounts.CostOfCommGoodsDomestic(), CreateCHGLAccounts.InvChangeCommGoods(), CreateCHGLAccounts.CostOfCommGoodsDomestic(), '', '', CreateCHGLAccounts.TradeDomestic(), CreateCHGLAccounts.Discounts(), CreateCHGLAccounts.CostOfCommGoodsDomestic(), CreateCHGLAccounts.CostReductionDiscount(), CreateCHGLAccounts.CostOfCommGoodsDomestic(), '', ''); + ContosoGenPostingSetup.InsertGeneralPostingSetup(CreatePostingGroup.EUPostingGroup(), CreatePostingGroup.RetailPostingGroup(), CreateCHGLAccounts.TradeEurope(), CreateCHGLAccounts.CostOfCommGoodsEurope(), CreateCHGLAccounts.InvChangeCommGoods(), CreateCHGLAccounts.CostOfCommGoodsEurope(), '', '', CreateCHGLAccounts.TradeEurope(), CreateCHGLAccounts.Discounts(), CreateCHGLAccounts.CostOfCommGoodsEurope(), CreateCHGLAccounts.CostReductionDiscount(), CreateCHGLAccounts.CostOfCommGoodsEurope(), '', ''); + ContosoGenPostingSetup.InsertGeneralPostingSetup(CreatePostingGroup.EUPostingGroup(), CreatePostingGroup.ServicesPostingGroup(), CreateCHGLAccounts.ServiceEarningsEurope(), CreateCHGLAccounts.SubcontrOfSpOperations(), CreateCHGLAccounts.InvChangeCommGoods(), CreateCHGLAccounts.SubcontrOfSpOperations(), '', '', CreateCHGLAccounts.ServiceEarningsEurope(), CreateCHGLAccounts.Discounts(), CreateCHGLAccounts.SubcontrOfSpOperations(), CreateCHGLAccounts.CostReductionDiscount(), CreateCHGLAccounts.SubcontrOfSpOperations(), '', ''); + ContosoGenPostingSetup.InsertGeneralPostingSetup(CreatePostingGroup.ExportPostingGroup(), CreatePostingGroup.RetailPostingGroup(), CreateCHGLAccounts.TradeInternat(), CreateCHGLAccounts.CostOfCommGoodsIntl(), CreateCHGLAccounts.InvChangeCommGoods(), CreateCHGLAccounts.CostOfCommGoodsIntl(), '', '', CreateCHGLAccounts.TradeInternat(), CreateCHGLAccounts.Discounts(), CreateCHGLAccounts.CostOfCommGoodsIntl(), CreateCHGLAccounts.CostReductionDiscount(), CreateCHGLAccounts.CostOfCommGoodsIntl(), '', ''); + ContosoGenPostingSetup.InsertGeneralPostingSetup(CreatePostingGroup.ExportPostingGroup(), CreatePostingGroup.ServicesPostingGroup(), CreateCHGLAccounts.ServiceEarningsInternat(), CreateCHGLAccounts.SubcontrOfSpOperations(), CreateCHGLAccounts.InvChangeCommGoods(), CreateCHGLAccounts.SubcontrOfSpOperations(), '', '', CreateCHGLAccounts.ServiceEarningsInternat(), CreateCHGLAccounts.Discounts(), CreateCHGLAccounts.SubcontrOfSpOperations(), CreateCHGLAccounts.CostReductionDiscount(), CreateCHGLAccounts.SubcontrOfSpOperations(), '', ''); + ContosoGenPostingSetup.InsertGeneralPostingSetup(CreatePostingGroup.ExportPostingGroup(), CreatePostingGroup.ZeroPostingGroup(), CreateCHGLAccounts.TradeInternat(), CreateCHGLAccounts.CostOfCommGoodsIntl(), CreateCHGLAccounts.InvChangeCommGoods(), CreateCHGLAccounts.CostOfCommGoodsIntl(), '', '', CreateCHGLAccounts.TradeInternat(), CreateCHGLAccounts.Discounts(), CreateCHGLAccounts.CostOfCommGoodsIntl(), CreateCHGLAccounts.CostReductionDiscount(), CreateCHGLAccounts.CostOfCommGoodsIntl(), '', ''); ContosoGenPostingSetup.SetOverwriteData(false); UpdateGeneralPostingSetup('', CreatePostingGroup.RetailPostingGroup(), '', '', CreateCHGLAccounts.VendorPrepaymentsVat0Percent(), CreateCHGLAccounts.CustomerPrepaymentsVat0Percent()); UpdateGeneralPostingSetup('', CreatePostingGroup.ServicesPostingGroup(), '', '', CreateCHGLAccounts.VendorPrepaymentsVat0Percent(), CreateCHGLAccounts.CustomerPrepaymentsVat0Percent()); + UpdateGeneralPostingSetup('', CreatePostingGroup.ZeroPostingGroup(), '', '', CreateCHGLAccounts.VendorPrepaymentsVat0Percent(), CreateCHGLAccounts.CustomerPrepaymentsVat0Percent()); UpdateGeneralPostingSetup(CreatePostingGroup.DomesticPostingGroup(), CreatePostingGroup.RetailPostingGroup(), CreateCHGLAccounts.TradeDomestic(), CreateCHGLAccounts.CostOfCommGoodsDomestic(), CreateCHGLAccounts.VendorPrepaymentsVat80Percent(), CreateCHGLAccounts.CustomerPrepaymentsVat80Percent()); UpdateGeneralPostingSetup(CreatePostingGroup.DomesticPostingGroup(), CreatePostingGroup.ServicesPostingGroup(), CreateCHGLAccounts.ServiceEarningsDomestic(), CreateCHGLAccounts.SubcontrOfSpOperations(), CreateCHGLAccounts.VendorPrepaymentsVat80Percent(), CreateCHGLAccounts.CustomerPrepaymentsVat80Percent()); + UpdateGeneralPostingSetup(CreatePostingGroup.DomesticPostingGroup(), CreatePostingGroup.ZeroPostingGroup(), CreateCHGLAccounts.TradeDomestic(), CreateCHGLAccounts.CostOfCommGoodsDomestic(), CreateCHGLAccounts.VendorPrepaymentsVat80Percent(), CreateCHGLAccounts.CustomerPrepaymentsVat80Percent()); UpdateGeneralPostingSetup(CreatePostingGroup.EUPostingGroup(), CreatePostingGroup.RetailPostingGroup(), CreateCHGLAccounts.TradeEurope(), CreateCHGLAccounts.CostOfCommGoodsEurope(), CreateCHGLAccounts.VendorPrepaymentsVat0Percent(), CreateCHGLAccounts.CustomerPrepaymentsVat0Percent()); - UpdateGeneralPostingSetup(CreatePostingGroup.EUPostingGroup(), CreatePostingGroup.ServicesPostingGroup(), CreateCHGLAccounts.ProdEarningsEurope(), CreateCHGLAccounts.CostOfMaterialsEurope(), CreateCHGLAccounts.VendorPrepaymentsVat0Percent(), CreateCHGLAccounts.CustomerPrepaymentsVat0Percent()); + UpdateGeneralPostingSetup(CreatePostingGroup.EUPostingGroup(), CreatePostingGroup.ServicesPostingGroup(), CreateCHGLAccounts.ServiceEarningsEurope(), CreateCHGLAccounts.SubcontrOfSpOperations(), CreateCHGLAccounts.VendorPrepaymentsVat0Percent(), CreateCHGLAccounts.CustomerPrepaymentsVat0Percent()); UpdateGeneralPostingSetup(CreatePostingGroup.ExportPostingGroup(), CreatePostingGroup.RetailPostingGroup(), CreateCHGLAccounts.TradeInternat(), CreateCHGLAccounts.CostOfCommGoodsIntl(), CreateCHGLAccounts.VendorPrepaymentsVat0Percent(), CreateCHGLAccounts.CustomerPrepaymentsVat0Percent()); + UpdateGeneralPostingSetup(CreatePostingGroup.ExportPostingGroup(), CreatePostingGroup.ServicesPostingGroup(), CreateCHGLAccounts.ServiceEarningsInternat(), CreateCHGLAccounts.SubcontrOfSpOperations(), CreateCHGLAccounts.VendorPrepaymentsVat0Percent(), CreateCHGLAccounts.CustomerPrepaymentsVat0Percent()); + UpdateGeneralPostingSetup(CreatePostingGroup.ExportPostingGroup(), CreatePostingGroup.ZeroPostingGroup(), CreateCHGLAccounts.TradeInternat(), CreateCHGLAccounts.CostOfCommGoodsIntl(), CreateCHGLAccounts.VendorPrepaymentsVat0Percent(), CreateCHGLAccounts.CustomerPrepaymentsVat0Percent()); end; local procedure UpdateGeneralPostingSetup(GenBusPostingGroup: Code[20]; GenProdPostingGroup: Code[20]; SalesCreditMemoAccount: Code[20]; PurchCreditMemoAccount: Code[20]; SalesPrepaymentsAccount: Code[20]; PurchPrepaymentsAccount: Code[20]) diff --git a/Apps/CH/ContosoCoffeeDemoDatasetCH/app/DemoData/Finance/2.Master Data/CreateCHCurrencyExRate.Codeunit.al b/Apps/CH/ContosoCoffeeDemoDatasetCH/app/DemoData/Finance/2.Master Data/CreateCHCurrencyExRate.Codeunit.al index df2253f499..aef2bd458e 100644 --- a/Apps/CH/ContosoCoffeeDemoDatasetCH/app/DemoData/Finance/2.Master Data/CreateCHCurrencyExRate.Codeunit.al +++ b/Apps/CH/ContosoCoffeeDemoDatasetCH/app/DemoData/Finance/2.Master Data/CreateCHCurrencyExRate.Codeunit.al @@ -203,4 +203,14 @@ codeunit 11630 "Create CH Currency Ex. Rate" CurrencyExchangeRate.Validate("Relational Exch. Rate Amount", RelationalExchRateAmount); CurrencyExchangeRate.Validate("Relational Adjmt Exch Rate Amt", RelationalAdjmtExchRateAmt); end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Add. Reporting Currency", OnBeforeGetResidualCurrencyAccounts, '', false, false)] + local procedure GetResidualCurrencyAccountsCH(var FXGainsAccount: Code[20]; var FXLossesAccount: Code[20]; var IsHandled: Boolean) + var + CreateCHGLAccounts: Codeunit "Create CH GL Accounts"; + begin + FXGainsAccount := CreateCHGLAccounts.UnrealizedExchRateAdjmts(); + FXLossesAccount := CreateCHGLAccounts.UnrealizedExchRateAdjmts(); + IsHandled := true; + end; } diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/UpdateRelVendLedgEntryCZZ.Codeunit.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/UpdateRelVendLedgEntryCZZ.Codeunit.al new file mode 100644 index 0000000000..503e363a46 --- /dev/null +++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/UpdateRelVendLedgEntryCZZ.Codeunit.al @@ -0,0 +1,71 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Finance.AdvancePayments; + +using Microsoft.Purchases.Payables; + +codeunit 11734 "Update Rel.Vend.Ledg.Entry CZZ" +{ + Access = Internal; + EventSubscriberInstance = Manual; + TableNo = "Vendor Ledger Entry"; + + trigger OnRun() + var + RelatedVendorLedgerEntry: Record "Vendor Ledger Entry"; + begin + if IsActivated() then + exit; + + Activate(); + + RelatedVendorLedgerEntry.ReadIsolation(IsolationLevel::UpdLock); + RelatedVendorLedgerEntry.SetCurrentKey("Document No."); + RelatedVendorLedgerEntry.SetRange("Document No.", Rec."Document No."); + RelatedVendorLedgerEntry.SetFilter("Entry No.", '<>%1', Rec."Entry No."); + if RelatedVendorLedgerEntry.FindSet() then + repeat + RelatedVendorLedgerEntry."Specific Symbol CZL" := Rec."Specific Symbol CZL"; + RelatedVendorLedgerEntry."Variable Symbol CZL" := Rec."Variable Symbol CZL"; + RelatedVendorLedgerEntry."Constant Symbol CZL" := Rec."Constant Symbol CZL"; + RelatedVendorLedgerEntry."Bank Account Code CZL" := Rec."Bank Account Code CZL"; + RelatedVendorLedgerEntry."Bank Account No. CZL" := Rec."Bank Account No. CZL"; + RelatedVendorLedgerEntry."Transit No. CZL" := Rec."Transit No. CZL"; + RelatedVendorLedgerEntry."IBAN CZL" := Rec."IBAN CZL"; + RelatedVendorLedgerEntry."SWIFT Code CZL" := Rec."SWIFT Code CZL"; + RelatedVendorLedgerEntry."VAT Date CZL" := Rec."VAT Date CZL"; + RelatedVendorLedgerEntry."External Document No." := Rec."External Document No."; + Codeunit.Run(Codeunit::"Vend. Entry-Edit", RelatedVendorLedgerEntry); + until RelatedVendorLedgerEntry.Next() = 0; + + Deactivate(); + end; + + local procedure Activate() + begin + BindSubscription(this); + end; + + local procedure Deactivate() + begin + UnbindSubscription(this); + end; + + local procedure IsActivated() Result: Boolean + begin + OnIsActivated(Result); + end; + + [IntegrationEvent(false, false)] + local procedure OnIsActivated(var Result: Boolean) + begin + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Update Rel.Vend.Ledg.Entry CZZ", OnIsActivated, '', false, false)] + local procedure SetTrueOnIsActivated(var Result: Boolean) + begin + Result := true; + end; +} \ No newline at end of file diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/VendEntryEditHandlerCZZ.Codeunit.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/VendEntryEditHandlerCZZ.Codeunit.al index 83af79fdfb..d516fd2afd 100644 --- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/VendEntryEditHandlerCZZ.Codeunit.al +++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/VendEntryEditHandlerCZZ.Codeunit.al @@ -15,4 +15,26 @@ codeunit 31061 "Vend. Entry-Edit Handler CZZ" VendLedgEntry."Advance Letter No. CZZ" := FromVendLedgEntry."Advance Letter No. CZZ"; VendLedgEntry.Prepayment := FromVendLedgEntry.Prepayment; end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Vend. Entry-Edit", 'OnRunOnAfterVendLedgEntryMofidy', '', false, false)] + local procedure UpdateRelatedEntriesOnRunOnAfterVendLedgEntryMofidy(var VendorLedgerEntry: Record "Vendor Ledger Entry") + begin + if VendorLedgerEntry."Advance Letter No. CZZ" <> '' then + UpdateAdvanceLetterEntries(VendorLedgerEntry); + if VendorLedgerEntry."Adv. Letter Template Code CZZ" <> '' then + Codeunit.Run(Codeunit::"Update Rel.Vend.Ledg.Entry CZZ", VendorLedgerEntry); + end; + + local procedure UpdateAdvanceLetterEntries(VendorLedgerEntry: Record "Vendor Ledger Entry") + var + PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ"; + begin + PurchAdvLetterEntryCZZ.SetRange("Vendor Ledger Entry No.", VendorLedgerEntry."Entry No."); + PurchAdvLetterEntryCZZ.SetLoadFields("External Document No."); + if PurchAdvLetterEntryCZZ.FindSet() then + repeat + PurchAdvLetterEntryCZZ."External Document No." := VendorLedgerEntry."External Document No."; + PurchAdvLetterEntryCZZ.Modify(false); + until PurchAdvLetterEntryCZZ.Next() = 0; + end; } diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Permissions/CZAdvancePaymentsObjCZZ.PermissionSet.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Permissions/CZAdvancePaymentsObjCZZ.PermissionSet.al index 9d36d4e908..828a8b0a1b 100644 --- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Permissions/CZAdvancePaymentsObjCZZ.PermissionSet.al +++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Permissions/CZAdvancePaymentsObjCZZ.PermissionSet.al @@ -49,6 +49,7 @@ permissionset 11752 "CZ Advance Payments - Obj. CZZ" Codeunit "Sales Post Advance Letter CZZ" = X, Codeunit "Show Preview Handler CZZ" = X, Codeunit "Sugg. Wksh. Lines Handler CZZ" = X, + Codeunit "Update Rel.Vend.Ledg.Entry CZZ" = X, Codeunit "Upgrade Application CZZ" = X, Codeunit "Upgrade Tag Definitions CZZ" = X, Codeunit "VAT Entry Handler CZZ" = X, diff --git a/Apps/CZ/AdvancedLocalizationPack/app/Src/Codeunits/GenJnlPostLineHandlerCZA.Codeunit.al b/Apps/CZ/AdvancedLocalizationPack/app/Src/Codeunits/GenJnlPostLineHandlerCZA.Codeunit.al index 3d6d0c7bfb..9f427cc92f 100644 --- a/Apps/CZ/AdvancedLocalizationPack/app/Src/Codeunits/GenJnlPostLineHandlerCZA.Codeunit.al +++ b/Apps/CZ/AdvancedLocalizationPack/app/Src/Codeunits/GenJnlPostLineHandlerCZA.Codeunit.al @@ -34,13 +34,13 @@ codeunit 31373 "Gen. Jnl.Post Line Handler CZA" GLEntryPostApplicationCZA.AutomatedGLEntryApplication(GenJournalLine, GLEntry); end; - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnAfterInitGLEntry', '', false, false)] - local procedure CloseZeroEntryOnAfterInitGLEntry(var GLEntry: Record "G/L Entry") + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnBeforeInsertGLEntryBuffer', '', false, false)] + local procedure CloseZeroEntryOnBeforeInsertGLEntryBuffer(var TempGLEntryBuf: Record "G/L Entry" temporary) begin - if GLEntry.Amount <> 0 then + if TempGLEntryBuf.Amount <> 0 then exit; - GLEntry."Closed CZA" := true; - GLEntry."Closed at Date CZA" := GLEntry."Posting Date"; + TempGLEntryBuf."Closed CZA" := true; + TempGLEntryBuf."Closed at Date CZA" := TempGLEntryBuf."Posting Date"; end; } diff --git a/Apps/CZ/AdvancedLocalizationPack/app/Src/Pages/ApplyGenLedgerEntriesCZA.Page.al b/Apps/CZ/AdvancedLocalizationPack/app/Src/Pages/ApplyGenLedgerEntriesCZA.Page.al index 6e2b05f6cb..71db2904ac 100644 --- a/Apps/CZ/AdvancedLocalizationPack/app/Src/Pages/ApplyGenLedgerEntriesCZA.Page.al +++ b/Apps/CZ/AdvancedLocalizationPack/app/Src/Pages/ApplyGenLedgerEntriesCZA.Page.al @@ -376,6 +376,7 @@ page 31287 "Apply Gen. Ledger Entries CZA" Rec.SetRange("Applies-to ID CZA", AppliesToID) else Rec.SetRange("Applies-to ID CZA"); + CurrPage.Update(false); end; } } @@ -565,17 +566,16 @@ page 31287 "Apply Gen. Ledger Entries CZA" begin if Rec.Get(TempApplyingGLEntry."Entry No.") then begin GLEntryPostApplicationCZA.SetApplyingGLEntry(Rec, false, ''); - Rec.SetRange(Amount); Rec."Applying Entry CZA" := false; Rec.Modify(); - - Clear(TempApplyingGLEntry); - Rec.SetCurrentKey("Entry No."); - Rec.SetRange("Entry No."); - AvailableAmount := 0; - ApplyingRemainingAmount := 0; - CalcApplyingAmount(); end; + + Clear(TempApplyingGLEntry); + Rec.SetCurrentKey("Entry No."); + Rec.Reset(); + AvailableAmount := 0; + ApplyingRemainingAmount := 0; + CalcApplyingAmount(); end; local procedure SetAppliesToID() @@ -674,6 +674,7 @@ page 31287 "Apply Gen. Ledger Entries CZA" TempModifiedGLEntry.DeleteAll(); TempGLEntry.Copy(Rec, true); + TempGLEntry.Reset(); TempGLEntry.SetRange("Applies-to ID CZA", TempApplyingGLEntry."Applies-to ID CZA"); if TempGLEntry.FindSet() then repeat diff --git a/Apps/CZ/ContosoCoffeeDemoDatasetCZ/app/DemoData/Finance/2. Master Data/CreateCurrencyExRateCZ.Codeunit.al b/Apps/CZ/ContosoCoffeeDemoDatasetCZ/app/DemoData/Finance/2. Master Data/CreateCurrencyExRateCZ.Codeunit.al index cced4322a3..1955b8c2a1 100644 --- a/Apps/CZ/ContosoCoffeeDemoDatasetCZ/app/DemoData/Finance/2. Master Data/CreateCurrencyExRateCZ.Codeunit.al +++ b/Apps/CZ/ContosoCoffeeDemoDatasetCZ/app/DemoData/Finance/2. Master Data/CreateCurrencyExRateCZ.Codeunit.al @@ -60,4 +60,14 @@ codeunit 31337 "Create Currency Ex. Rate CZ" begin exit(0.026618); end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Add. Reporting Currency", OnBeforeGetResidualCurrencyAccounts, '', false, false)] + local procedure GetResidualCurrencyAccountsCZ(var FXGainsAccount: Code[20]; var FXLossesAccount: Code[20]; var IsHandled: Boolean) + var + CreateGLAccountCZ: Codeunit "Create G/L Account CZ"; + begin + FXGainsAccount := CreateGLAccountCZ.ExchangeGainsRealized(); + FXLossesAccount := CreateGLAccountCZ.ExchangeLossesRealized(); + IsHandled := true; + end; } \ No newline at end of file diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/CompanyBankAccHandlerCZL.Codeunit.al b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/CompanyBankAccHandlerCZL.Codeunit.al index 33f716d32c..f6847fabe2 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/CompanyBankAccHandlerCZL.Codeunit.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/CompanyBankAccHandlerCZL.Codeunit.al @@ -225,6 +225,9 @@ codeunit 31447 "Company Bank Acc. Handler CZL" [EventSubscriber(ObjectType::Codeunit, Codeunit::"Purch. Inv. Header - Edit", 'OnBeforePurchInvHeaderModify', '', false, false)] local procedure PurchInvoiceEditOnBeforePurchInvHeaderModify(var PurchInvHeader: Record "Purch. Inv. Header"; PurchInvHeaderRec: Record "Purch. Inv. Header") begin + if PurchInvHeader."Vendor Invoice No." <> PurchInvHeaderRec."Vendor Invoice No." then + PurchInvHeaderRec.CheckAndConfirmExternalDocumentNumber(); + PurchInvHeader.Validate("Due Date", PurchInvHeaderRec."Due Date"); PurchInvHeader.Validate("Bank Account Code CZL", PurchInvHeaderRec."Bank Account Code CZL"); PurchInvHeader.Validate("Vendor Invoice No.", PurchInvHeaderRec."Vendor Invoice No."); diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/CorrPostSInvHandlerCZL.Codeunit.al b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/CorrPostSInvHandlerCZL.Codeunit.al new file mode 100644 index 0000000000..1970dc7f82 --- /dev/null +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/CorrPostSInvHandlerCZL.Codeunit.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.Sales.History; + +using Microsoft.Sales.Document; + +codeunit 11735 "Corr. Post. S.Inv. Handler CZL" +{ + Access = Internal; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Correct Posted Sales Invoice", OnAfterCreateCorrectiveSalesCrMemo, '', false, false)] + local procedure SetCreditMemoTypeOnAfterCreateCorrectiveSalesCrMemo(var SalesHeader: Record "Sales Header") + begin + SalesHeader."Credit Memo Type CZL" := SalesHeader."Credit Memo Type CZL"::"Internal Correction"; + SalesHeader.Modify(); + end; +} \ No newline at end of file diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/GuidedExperienceHandlerCZL.Codeunit.al b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/GuidedExperienceHandlerCZL.Codeunit.al index 26b2e54120..1d46fc17d5 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/GuidedExperienceHandlerCZL.Codeunit.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/GuidedExperienceHandlerCZL.Codeunit.al @@ -140,8 +140,8 @@ codeunit 11747 "Guided Experience Handler CZL" local procedure RegisterExcelTemplates() var ExcelTemplateNameTxt: Label 'Excel Templates'; - ExcelTemplateDescriptionTxt: Label 'Set up a Excel templates into which you can export Account Schedules.'; - ExcelTemplateKeywordsTxt: Label 'Excel, Template, Account Schedule'; + ExcelTemplateDescriptionTxt: Label 'Set up a Excel templates into which you can export Financial Reports.'; + ExcelTemplateKeywordsTxt: Label 'Excel, Template, Financial Report'; begin GuidedExperience.InsertManualSetup(ExcelTemplateNameTxt, ExcelTemplateNameTxt, ExcelTemplateDescriptionTxt, 2, ObjectType::Page, Page::"Excel Templates CZL", ManualSetupCategory::General, ExcelTemplateKeywordsTxt); diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/AccScheduleOverviewCZL.PageExt.al b/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/AccScheduleOverviewCZL.PageExt.al index 2c309046f7..5166b50703 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/AccScheduleOverviewCZL.PageExt.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/AccScheduleOverviewCZL.PageExt.al @@ -19,7 +19,7 @@ pageextension 11798 "Acc. Schedule Overview CZL" extends "Acc. Schedule Overview Caption = 'Save Results'; Ellipsis = true; Image = Save; - ToolTip = 'Opens window for saving results of account schedule'; + ToolTip = 'Opens window for saving results of financial report.'; trigger OnAction() var @@ -35,7 +35,7 @@ pageextension 11798 "Acc. Schedule Overview CZL" extends "Acc. Schedule Overview Image = ViewDetails; RunObject = page "Acc. Sched. Res. Hdr. List CZL"; RunPageLink = "Acc. Schedule Name" = field("Schedule Name"); - ToolTip = 'Opens account schedule result header list'; + ToolTip = 'Opens financial report result header list.'; } } } diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/AccountScheduleCZL.PageExt.al b/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/AccountScheduleCZL.PageExt.al index 7eb0c47ea4..187a9c9a89 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/AccountScheduleCZL.PageExt.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/AccountScheduleCZL.PageExt.al @@ -39,7 +39,7 @@ pageextension 11782 "Account Schedule CZL" extends "Account Schedule" field("Calc CZL"; Rec."Calc CZL") { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies when the value can be calculated in the Account Schedule - Always, Never, When Positive, When Negative.'; + ToolTip = 'Specifies when the value can be calculated in the Financial Report - Always, Never, When Positive, When Negative.'; } } addlast(Control1) @@ -47,7 +47,7 @@ pageextension 11782 "Account Schedule CZL" extends "Account Schedule" field("Assets/Liabilities Type CZL"; Rec."Assets/Liabilities Type CZL") { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies the assets or liabilities type for the account schedule line.'; + ToolTip = 'Specifies the assets or liabilities type for the financial report line.'; Visible = false; } } diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/AccountScheduleNamesCZL.PageExt.al b/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/AccountScheduleNamesCZL.PageExt.al index e74af39012..a259469406 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/AccountScheduleNamesCZL.PageExt.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/AccountScheduleNamesCZL.PageExt.al @@ -13,7 +13,7 @@ pageextension 11781 "Account Schedule Names CZL" extends "Account Schedule Names field("Acc. Schedule Type CZL"; Rec."Acc. Schedule Type CZL") { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies the type of account schedule (Balance Sheet or Income Statement).'; + ToolTip = 'Specifies the type of financial report (Balance Sheet or Income Statement).'; } } } diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/FinancialReportsCZL.PageExt.al b/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/FinancialReportsCZL.PageExt.al index 80fae29c71..9b7e8e7a4f 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/FinancialReportsCZL.PageExt.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/FinancialReportsCZL.PageExt.al @@ -17,7 +17,7 @@ pageextension 11702 "Financial Reports CZL" extends "Financial Reports" Ellipsis = true; Image = NewSum; RunObject = page "Acc. Schedule Extensions CZL"; - ToolTip = 'Specifies acc. schedule extensions page'; + ToolTip = 'Specifies financial report extensions page.'; } action("File Mapping CZL") { @@ -42,7 +42,7 @@ pageextension 11702 "Financial Reports CZL" extends "Financial Reports" Image = ViewDetails; RunObject = page "Acc. Sched. Res. Hdr. List CZL"; RunPageLink = "Acc. Schedule Name" = field("Financial Report Row Group"); - ToolTip = 'Opens acc. schedule res. header list'; + ToolTip = 'Opens financial report res. header list.'; } } addlast(Category_Process) diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/GeneralLedgerSetupCZL.PageExt.al b/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/GeneralLedgerSetupCZL.PageExt.al index 876c20ad08..85bd0a9dc4 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/GeneralLedgerSetupCZL.PageExt.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/GeneralLedgerSetupCZL.PageExt.al @@ -31,7 +31,7 @@ pageextension 11717 "General Ledger Setup CZL" extends "General Ledger Setup" field("Acc. Schedule Results Nos. CZL"; Rec."Acc. Schedule Results Nos. CZL") { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies the code for the number series that will be used to assign numbers to account schedule results.'; + ToolTip = 'Specifies the code for the number series that will be used to assign numbers to financial report results.'; } } addlast(content) @@ -118,7 +118,7 @@ pageextension 11717 "General Ledger Setup CZL" extends "General Ledger Setup" field("Shared Account Schedule CZL"; Rec."Shared Account Schedule CZL") { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies to share the account schedule in general ledger setup.'; + ToolTip = 'Specifies to share the financial report in general ledger setup.'; } } movefirst(VatCZL; "VAT Reporting Date Usage", "Default VAT Reporting Date") diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccSchResSubMatrixCZL.Page.al b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccSchResSubMatrixCZL.Page.al index aa16bb0eaa..c5a69e4bbc 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccSchResSubMatrixCZL.Page.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccSchResSubMatrixCZL.Page.al @@ -23,20 +23,20 @@ page 31207 "Acc. Sch. Res. Sub. Matrix CZL" { ApplicationArea = Basic, Suite; Editable = false; - ToolTip = 'Specifies a Row number for the account schedule line.'; + ToolTip = 'Specifies a Row number for the financial report line.'; } field(Description; Rec.Description) { ApplicationArea = Basic, Suite; Editable = false; - ToolTip = 'Specifies the description of account schedule results.'; + ToolTip = 'Specifies the description of financial report results.'; } field(Field1; Value[1]) { ApplicationArea = All; BlankZero = true; CaptionClass = '3,' + MATRIX_CaptionSet[1]; - ToolTip = 'Specifies the value of account schedule result subpage matrix'; + ToolTip = 'Specifies the value of financial report result subpage matrix'; Visible = Field1Visible; trigger OnAssistEdit() @@ -55,7 +55,7 @@ page 31207 "Acc. Sch. Res. Sub. Matrix CZL" ApplicationArea = All; BlankZero = true; CaptionClass = '3,' + MATRIX_CaptionSet[2]; - ToolTip = 'Specifies the value of account schedule result subpage matrix'; + ToolTip = 'Specifies the value of financial report result subpage matrix'; Visible = Field2Visible; trigger OnAssistEdit() @@ -74,7 +74,7 @@ page 31207 "Acc. Sch. Res. Sub. Matrix CZL" ApplicationArea = All; BlankZero = true; CaptionClass = '3,' + MATRIX_CaptionSet[3]; - ToolTip = 'Specifies the value of account schedule result subpage matrix'; + ToolTip = 'Specifies the value of financial report result subpage matrix'; Visible = Field3Visible; trigger OnAssistEdit() @@ -93,7 +93,7 @@ page 31207 "Acc. Sch. Res. Sub. Matrix CZL" ApplicationArea = All; BlankZero = true; CaptionClass = '3,' + MATRIX_CaptionSet[4]; - ToolTip = 'Specifies the value of account schedule result subpage matrix'; + ToolTip = 'Specifies the value of financial report result subpage matrix'; Visible = Field4Visible; trigger OnAssistEdit() diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccSchedPageDrillDownCZL.Page.al b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccSchedPageDrillDownCZL.Page.al index 930035e394..84c7b7ba26 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccSchedPageDrillDownCZL.Page.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccSchedPageDrillDownCZL.Page.al @@ -24,7 +24,7 @@ page 31204 "Acc. Sched.Page.Drill-Down CZL" ApplicationArea = Basic, Suite; Caption = 'Formula'; Editable = false; - ToolTip = 'Specifies the formula of account schedule.'; + ToolTip = 'Specifies the formula of financial report.'; } repeater(Lines) { @@ -33,17 +33,17 @@ page 31204 "Acc. Sched.Page.Drill-Down CZL" field("Acc. Sched. Row No."; Rec."Acc. Sched. Row No.") { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies the number of the account schedule row.'; + ToolTip = 'Specifies the number of the financial report row.'; } field("Totaling Type"; Rec."Totaling Type") { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies the totaling type for the account schedule line. The type determines which accounts within the totaling interval you specify in the Totaling field will be totaled.'; + ToolTip = 'Specifies the totaling type for the financial report line. The type determines which accounts within the totaling interval you specify in the Totaling field will be totaled.'; } field(Expression; Rec.Expression) { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies expression of account schedule.'; + ToolTip = 'Specifies expression of financial report.'; } field(Amount; Rec.Amount) { diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccSchedResHdrListCZL.Page.al b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccSchedResHdrListCZL.Page.al index ca27b602dd..6138fc1cc5 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccSchedResHdrListCZL.Page.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccSchedResHdrListCZL.Page.al @@ -8,7 +8,7 @@ using System.Security.User; page 31203 "Acc. Sched. Res. Hdr. List CZL" { - Caption = 'Acc. Schedule Res. Header List'; + Caption = 'Fin. Report Res. Header List'; CardPageId = "Acc. Sched. Res. Overview CZL"; Editable = false; PageType = List; @@ -24,22 +24,22 @@ page 31203 "Acc. Sched. Res. Hdr. List CZL" field("Result Code"; Rec."Result Code") { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies the result code of account schedule results.'; + ToolTip = 'Specifies the result code of financial report results.'; } field(Description; Rec.Description) { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies the description of account schedule results.'; + ToolTip = 'Specifies the description of financial report results.'; } field("Date Filter"; Rec."Date Filter") { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies the date filter of account schedule results.'; + ToolTip = 'Specifies the date filter of financial report results.'; } field("Acc. Schedule Name"; Rec."Acc. Schedule Name") { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies the name of the account schedule.'; + ToolTip = 'Specifies the name of the financial report.'; } field("Column Layout Name"; Rec."Column Layout Name") { @@ -61,12 +61,12 @@ page 31203 "Acc. Sched. Res. Hdr. List CZL" field("Result Date"; Rec."Result Date") { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies the created date of account schedule results.'; + ToolTip = 'Specifies the created date of financial report results.'; } field("Result Time"; Rec."Result Time") { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies the created time of account schedule results.'; + ToolTip = 'Specifies the created time of financial report results.'; } } } @@ -78,7 +78,7 @@ page 31203 "Acc. Sched. Res. Hdr. List CZL" { group("Acc. Schedule Result") { - Caption = 'Acc. Schedule Result'; + Caption = 'Fin. Report Result'; action(Card) { ApplicationArea = Basic, Suite; @@ -88,7 +88,7 @@ page 31203 "Acc. Sched. Res. Hdr. List CZL" RunPageLink = "Result Code" = field("Result Code"), "Acc. Schedule Name" = field("Acc. Schedule Name"); ShortcutKey = 'Shift+F7'; - ToolTip = 'The funkction opens the account schedule result card.'; + ToolTip = 'The function opens the financial report result card.'; } } } @@ -103,7 +103,7 @@ page 31203 "Acc. Sched. Res. Hdr. List CZL" Caption = 'Print'; Ellipsis = true; Image = Print; - ToolTip = 'Allows print the account schedule results.'; + ToolTip = 'Allows print the financial report results.'; trigger OnAction() begin @@ -118,7 +118,7 @@ page 31203 "Acc. Sched. Res. Hdr. List CZL" Caption = 'Export to Excel'; Ellipsis = true; Image = ExportToExcel; - ToolTip = 'Allows the account schedule results export to excel.'; + ToolTip = 'Allows the financial report results export to excel.'; trigger OnAction() var diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccSchedResOverviewCZL.Page.al b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccSchedResOverviewCZL.Page.al index 0df66eb31c..f6c3581e24 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccSchedResOverviewCZL.Page.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccSchedResOverviewCZL.Page.al @@ -8,7 +8,7 @@ using System.Security.User; page 31206 "Acc. Sched. Res. Overview CZL" { - Caption = 'Acc. Schedule Results Overview'; + Caption = 'Fin. Report Results Overview'; InsertAllowed = false; PageType = Card; SourceTable = "Acc. Schedule Result Hdr. CZL"; @@ -24,24 +24,24 @@ page 31206 "Acc. Sched. Res. Overview CZL" { ApplicationArea = Basic, Suite; Editable = false; - ToolTip = 'Specifies the result code of account schedule results.'; + ToolTip = 'Specifies the result code of financial report results.'; } field(Description; Rec.Description) { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies the description of account schedule results.'; + ToolTip = 'Specifies the description of financial report results.'; } field("Date Filter"; Rec."Date Filter") { ApplicationArea = Basic, Suite; Editable = false; - ToolTip = 'Specifies the date filter of account schedule results.'; + ToolTip = 'Specifies the date filter of financial report results.'; } field("Acc. Schedule Name"; Rec."Acc. Schedule Name") { ApplicationArea = Basic, Suite; Editable = false; - ToolTip = 'Specifies the name of the account schedule.'; + ToolTip = 'Specifies the name of the financial report.'; } field("Column Layout Name"; Rec."Column Layout Name") { @@ -62,25 +62,25 @@ page 31206 "Acc. Sched. Res. Overview CZL" { ApplicationArea = Basic, Suite; Editable = false; - ToolTip = 'Specifies dimensions which was used by account schedule results creating.'; + ToolTip = 'Specifies dimensions which was used by financial report results creating.'; } field("Dimension 2 Filter"; Rec."Dimension 2 Filter") { ApplicationArea = Basic, Suite; Editable = false; - ToolTip = 'Specifies dimensions which was used by account schedule results creating.'; + ToolTip = 'Specifies dimensions which was used by financial report results creating.'; } field("Dimension 3 Filter"; Rec."Dimension 3 Filter") { ApplicationArea = Basic, Suite; Editable = false; - ToolTip = 'Specifies dimensions which was used by account schedule results creating.'; + ToolTip = 'Specifies dimensions which was used by financial report results creating.'; } field("Dimension 4 Filter"; Rec."Dimension 4 Filter") { ApplicationArea = Basic, Suite; Editable = false; - ToolTip = 'Specifies dimensions which was used by account schedule results creating.'; + ToolTip = 'Specifies dimensions which was used by financial report results creating.'; } } group(Options) @@ -101,12 +101,12 @@ page 31206 "Acc. Sched. Res. Overview CZL" field("Result Date"; Rec."Result Date") { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies the created date of account schedule results.'; + ToolTip = 'Specifies the created date of financial report results.'; } field("Result Time"; Rec."Result Time") { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies the created time of account schedule results.'; + ToolTip = 'Specifies the created time of financial report results.'; } field(ShowOnlyChangedValues; ShowOnlyChangedValues) { @@ -136,7 +136,7 @@ page 31206 "Acc. Sched. Res. Overview CZL" Caption = 'Print'; Ellipsis = true; Image = Print; - ToolTip = 'Allows print the account schedule results.'; + ToolTip = 'Allows print the financial report results.'; trigger OnAction() var @@ -153,7 +153,7 @@ page 31206 "Acc. Sched. Res. Overview CZL" Caption = 'Export to Excel'; Ellipsis = true; Image = ExportToExcel; - ToolTip = 'Allows the account schedule results export to excel.'; + ToolTip = 'Allows the financial report results export to excel.'; trigger OnAction() var @@ -169,7 +169,7 @@ page 31206 "Acc. Sched. Res. Overview CZL" ApplicationArea = Basic, Suite; Caption = 'Next Set'; Image = NextSet; - ToolTip = 'Go to the next set of the account schedule results.'; + ToolTip = 'Go to the next set of the financial report results.'; trigger OnAction() begin @@ -183,7 +183,7 @@ page 31206 "Acc. Sched. Res. Overview CZL" ApplicationArea = Basic, Suite; Caption = 'Previous Set'; Image = PreviousSet; - ToolTip = 'Go to the previous set of the account schedule results.'; + ToolTip = 'Go to the previous set of the financial report results.'; trigger OnAction() begin diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccScheduleExtensionsCZL.Page.al b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccScheduleExtensionsCZL.Page.al index cbd589017d..8a19e9374e 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccScheduleExtensionsCZL.Page.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccScheduleExtensionsCZL.Page.al @@ -6,7 +6,7 @@ namespace Microsoft.Finance.FinancialReports; page 31201 "Acc. Schedule Extensions CZL" { - Caption = 'Acc. Schedule Extensions'; + Caption = 'Fin. Report Extensions'; DelayedInsert = true; PageType = Worksheet; PopulateAllFields = true; @@ -23,7 +23,7 @@ page 31201 "Acc. Schedule Extensions CZL" field(Code; Rec.Code) { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies the code of account schedule extensions.'; + ToolTip = 'Specifies the code of financial report extensions.'; } field("Source Table"; Rec."Source Table") { @@ -33,7 +33,7 @@ page 31201 "Acc. Schedule Extensions CZL" field(Description; Rec.Description) { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies the description of account schedule extensions.'; + ToolTip = 'Specifies the description of financial report extensions.'; } field("Source Type"; Rec."Source Type") { @@ -104,13 +104,13 @@ page 31201 "Acc. Schedule Extensions CZL" field("Amount Sign"; Rec."Amount Sign") { ApplicationArea = All; - ToolTip = 'Specifies the amount sign for the account schedule extension.'; + ToolTip = 'Specifies the amount sign for the financial report extension.'; Visible = AmtSignVisible; } field("Document Type Filter"; Rec."Document Type Filter") { ApplicationArea = All; - ToolTip = 'Specifies setup of documents type for filtr account schedule (invoice, payment).'; + ToolTip = 'Specifies setup of documents type for filtr financial report (invoice, payment).'; Visible = DocumentTypeFilterVisible; } field("Posting Date Filter"; Rec."Posting Date Filter") diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccScheduleFileMappingCZL.Page.al b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccScheduleFileMappingCZL.Page.al index c5da2a2d25..a719df0930 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccScheduleFileMappingCZL.Page.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccScheduleFileMappingCZL.Page.al @@ -25,10 +25,10 @@ page 11702 "Acc. Schedule File Mapping CZL" field(CurrentSchedName; CurrentSchedName) { ApplicationArea = Basic, Suite; - Caption = 'Account Schedule Name'; + Caption = 'Financial Report Name'; Lookup = true; LookupPageId = "Account Schedule Names"; - ToolTip = 'Specifies the account schedule name.'; + ToolTip = 'Specifies the financial report name.'; Editable = false; } field(CurrentColumnName; CurrentColumnName) @@ -48,13 +48,13 @@ page 11702 "Acc. Schedule File Mapping CZL" { ApplicationArea = Basic, Suite; Editable = false; - ToolTip = 'Specifies a number for the account schedule line.'; + ToolTip = 'Specifies a number for the financial report line.'; } field(Description; Rec.Description) { ApplicationArea = Basic, Suite; Editable = false; - ToolTip = 'Specifies text that will appear on the account schedule line.'; + ToolTip = 'Specifies text that will appear on the financial report line.'; } field("ColumnValues[1]"; ColumnValues[1]) { @@ -334,7 +334,7 @@ page 11702 "Acc. Schedule File Mapping CZL" ApplicationArea = Basic, Suite; Caption = 'Previous Column'; Image = PreviousRecord; - ToolTip = 'Show the account schedule based on the previous column.'; + ToolTip = 'Show the financial report based on the previous column.'; trigger OnAction() begin @@ -346,7 +346,7 @@ page 11702 "Acc. Schedule File Mapping CZL" ApplicationArea = Basic, Suite; Caption = 'Next Column'; Image = NextRecord; - ToolTip = 'Show the account schedule based on the next column.'; + ToolTip = 'Show the financial report based on the next column.'; trigger OnAction() begin diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccScheduleLineListCZL.Page.al b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccScheduleLineListCZL.Page.al index c3cc57ec5b..a51d1b713f 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccScheduleLineListCZL.Page.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccScheduleLineListCZL.Page.al @@ -5,7 +5,7 @@ namespace Microsoft.Finance.FinancialReports; page 31194 "Acc. Schedule Line List CZL" { - Caption = 'Acc. Schedule Line List'; + Caption = 'Fin. Report Line List'; Editable = false; PageType = List; SourceTable = "Acc. Schedule Line"; @@ -21,28 +21,28 @@ page 31194 "Acc. Schedule Line List CZL" field("Schedule Name"; Rec."Schedule Name") { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies the account schedule name.'; + ToolTip = 'Specifies the financial report name.'; Visible = false; } field("Row No."; Rec."Row No.") { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies a number for the account schedule line.'; + ToolTip = 'Specifies a number for the financial report line.'; } field(Description; Rec.Description) { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies text that will appear on the account schedule line.'; + ToolTip = 'Specifies text that will appear on the financial report line.'; } field("Totaling Type"; Rec."Totaling Type") { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies the totaling type for the account schedule line. The type determines which accounts within the totaling interval you specify in the Totaling field will be totaled.'; + ToolTip = 'Specifies the totaling type for the financial report line. The type determines which accounts within the totaling interval you specify in the Totaling field will be totaled.'; } field(Totaling; Rec.Totaling) { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies totaling for acc. schedule line'; + ToolTip = 'Specifies totaling for financial report line'; } } } diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccScheduleResultHistCZL.Page.al b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccScheduleResultHistCZL.Page.al index d4a1565e3b..3156ad3341 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccScheduleResultHistCZL.Page.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/AccScheduleResultHistCZL.Page.al @@ -8,7 +8,7 @@ using System.Security.User; page 31205 "Acc. Schedule Result Hist. CZL" { - Caption = 'Acc. Schedule Result History'; + Caption = 'Fin. Report Result History'; Editable = false; PageType = List; SourceTable = "Acc. Schedule Result Hist. CZL"; @@ -33,7 +33,7 @@ page 31205 "Acc. Schedule Result Hist. CZL" field("Old Value"; Rec."Old Value") { ApplicationArea = Basic, Suite; - ToolTip = 'Specifies the old value of the account schedule result'; + ToolTip = 'Specifies the old value of the financial report result'; } field("User ID"; Rec."User ID") { diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/SaveAccScheduleResultCZL.Page.al b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/SaveAccScheduleResultCZL.Page.al index 03fb992f22..29e2e4d70c 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Pages/SaveAccScheduleResultCZL.Page.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Pages/SaveAccScheduleResultCZL.Page.al @@ -8,7 +8,7 @@ using System.Text; page 31202 "Save Acc. Schedule Result CZL" { - Caption = 'Save Acc. Schedule Result'; + Caption = 'Save Fin. Report Result'; PageType = Card; layout @@ -21,10 +21,10 @@ page 31202 "Save Acc. Schedule Result CZL" field(AccSchedName; AccSchedName) { ApplicationArea = Basic, Suite; - Caption = 'Acc. Schedule Name'; + Caption = 'Fin. Report Name'; Lookup = true; TableRelation = "Acc. Schedule Name"; - ToolTip = 'Specifies the name of account schedule.'; + ToolTip = 'Specifies the name of financial report.'; Editable = false; } field(ColumnLayoutName; ColumnLayoutName) @@ -55,7 +55,7 @@ page 31202 "Save Acc. Schedule Result CZL" { ApplicationArea = Basic, Suite; Caption = 'Description'; - ToolTip = 'Specifies the description of account schedule result.'; + ToolTip = 'Specifies the description of financial report result.'; } field(UseAmtsInAddCurr; UseAmtsInAddCurr) { diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Reports/AccScheduleExportFileCZL.Report.al b/Apps/CZ/CoreLocalizationPack/app/Src/Reports/AccScheduleExportFileCZL.Report.al index 06be857ddb..7ac3951c32 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Reports/AccScheduleExportFileCZL.Report.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Reports/AccScheduleExportFileCZL.Report.al @@ -16,7 +16,7 @@ using System.Utilities; report 11776 "Acc. Schedule Export File CZL" { - Caption = 'Account Schedule Export File'; + Caption = 'Fin. Report Export File'; ProcessingOnly = true; dataset @@ -138,9 +138,9 @@ report 11776 "Acc. Schedule Export File CZL" field(AccSchedNameCZL; AccSchedName) { ApplicationArea = Basic, Suite; - Caption = 'Acc. Schedule Name'; + Caption = 'Fin. Report Name'; TableRelation = "Acc. Schedule Name"; - ToolTip = 'Specifies the name of the account schedule to be shown in the report.'; + ToolTip = 'Specifies the name of the financial report to be shown in the report.'; trigger OnLookup(var Text: Text): Boolean var @@ -191,7 +191,7 @@ report 11776 "Acc. Schedule Export File CZL" ApplicationArea = Basic, Suite; Caption = 'Excel Template'; TableRelation = "Excel Template CZL"; - ToolTip = 'Specifies the excel template for the account schedule export.'; + ToolTip = 'Specifies the excel template for the financial report export.'; Visible = TemplateIsVisible; trigger OnValidate() diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Reports/AccountScheduleResultCZL.Report.al b/Apps/CZ/CoreLocalizationPack/app/Src/Reports/AccountScheduleResultCZL.Report.al index abdb2ed3b9..c75cb0b37a 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Reports/AccountScheduleResultCZL.Report.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Reports/AccountScheduleResultCZL.Report.al @@ -8,7 +8,7 @@ report 31202 "Account Schedule Result CZL" { DefaultLayout = RDLC; RDLCLayout = './Src/Reports/AccountScheduleResult.rdl'; - Caption = 'Account Schedule Result'; + Caption = 'Financial Report Result'; dataset { @@ -136,7 +136,7 @@ report 31202 "Account Schedule Result CZL" { PeriodLbl = 'Period'; ColumnLayoutLbl = 'Column Layout'; - AccountScheduleLbl = 'Account Schedule'; + AccountScheduleLbl = 'Financial Report'; PageLbl = 'Page'; ResultDescriptionbl = 'Result Description'; } diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Reports/BalanceSheetCZL.Report.al b/Apps/CZ/CoreLocalizationPack/app/Src/Reports/BalanceSheetCZL.Report.al index 1720a65e2e..db2872f37c 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Reports/BalanceSheetCZL.Report.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Reports/BalanceSheetCZL.Report.al @@ -440,7 +440,7 @@ report 11794 "Balance Sheet CZL" Caption = 'Row Definition'; Lookup = true; TableRelation = "Acc. Schedule Name"; - ToolTip = 'Specifies the name of the account schedule to be shown in the report.'; + ToolTip = 'Specifies the name of the financial report to be shown in the report.'; trigger OnLookup(var Text: Text): Boolean var @@ -657,9 +657,9 @@ report 11794 "Balance Sheet CZL" field(ShowAccSchedSetupCZL; ShowAccSchedSetup) { ApplicationArea = Basic, Suite; - Caption = 'Show Account Schedule Setup'; + Caption = 'Show Financial Report Setup'; MultiLine = true; - ToolTip = 'Specifies when the account schedule setup is to be show'; + ToolTip = 'Specifies when the financial report setup is to be show'; } field(SkipEmptyLinesCZL; SkipEmptyLines) { @@ -695,7 +695,7 @@ report 11794 "Balance Sheet CZL" labels { ReportCaptionLbl = 'Balance Sheet'; - AccScheduleName_Name_CaptionLbl = 'Account Schedule'; + AccScheduleName_Name_CaptionLbl = 'Financial Report'; ColumnLayoutNameCaptionLbl = 'Column Layout'; FiscalStartDateCaptionLbl = 'Fiscal Start Date'; PeriodTextCaptionLbl = 'Period'; diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Reports/IncomeStatementCZL.Report.al b/Apps/CZ/CoreLocalizationPack/app/Src/Reports/IncomeStatementCZL.Report.al index af0101c4bd..7e57b3ecd2 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Reports/IncomeStatementCZL.Report.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Reports/IncomeStatementCZL.Report.al @@ -387,7 +387,7 @@ report 11795 "Income Statement CZL" Caption = 'Row Definition'; Lookup = true; TableRelation = "Acc. Schedule Name"; - ToolTip = 'Specifies the name of the account schedule to be shown in the report.'; + ToolTip = 'Specifies the name of the financial report to be shown in the report.'; trigger OnLookup(var Text: Text): Boolean var @@ -604,9 +604,9 @@ report 11795 "Income Statement CZL" field(ShowAccSchedSetupCZL; ShowAccSchedSetup) { ApplicationArea = Basic, Suite; - Caption = 'Show Account Schedule Setup'; + Caption = 'Show Financial Report Setup'; MultiLine = true; - ToolTip = 'Specifies when the account schedule setup is to be show'; + ToolTip = 'Specifies when the financial report setup is to be show'; } field(SkipEmptyLinesCZL; SkipEmptyLines) { @@ -642,7 +642,7 @@ report 11795 "Income Statement CZL" labels { ReportCaptionLbl = 'Income Statement'; - AccScheduleName_Name_CaptionLbl = 'Account Schedule'; + AccScheduleName_Name_CaptionLbl = 'Financial Report'; ColumnLayoutNameCaptionLbl = 'Column Layout'; FiscalStartDateCaptionLbl = 'Fiscal Start Date'; PeriodTextCaptionLbl = 'Period'; diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/TableExtensions/GeneralLedgerSetupCZL.TableExt.al b/Apps/CZ/CoreLocalizationPack/app/Src/TableExtensions/GeneralLedgerSetupCZL.TableExt.al index d949f5032a..b2fdc9911a 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/TableExtensions/GeneralLedgerSetupCZL.TableExt.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/TableExtensions/GeneralLedgerSetupCZL.TableExt.al @@ -123,13 +123,13 @@ tableextension 11713 "General Ledger Setup CZL" extends "General Ledger Setup" } field(31085; "Shared Account Schedule CZL"; Code[10]) { - Caption = 'Shared Account Schedule'; + Caption = 'Shared Financial Report'; DataClassification = CustomerContent; TableRelation = "Acc. Schedule Name"; } field(31086; "Acc. Schedule Results Nos. CZL"; Code[20]) { - Caption = 'Acc. Schedule Results Nos.'; + Caption = 'Fin. Report Results Nos.'; DataClassification = CustomerContent; TableRelation = "No. Series"; } diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/TableExtensions/PurchInvHeaderCZL.TableExt.al b/Apps/CZ/CoreLocalizationPack/app/Src/TableExtensions/PurchInvHeaderCZL.TableExt.al index 6a388c8d57..fb0f272736 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/TableExtensions/PurchInvHeaderCZL.TableExt.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/TableExtensions/PurchInvHeaderCZL.TableExt.al @@ -6,8 +6,12 @@ namespace Microsoft.Purchases.History; using Microsoft.Bank.Setup; using Microsoft.Finance.Currency; +using Microsoft.Finance.GeneralLedger.Journal; using Microsoft.Finance.VAT.Calculation; +using Microsoft.Purchases.Payables; +using Microsoft.Purchases.Setup; using Microsoft.Purchases.Vendor; +using System.Utilities; tableextension 11730 "Purch. Inv. Header CZL" extends "Purch. Inv. Header" { @@ -186,6 +190,7 @@ tableextension 11730 "Purch. Inv. Header CZL" extends "Purch. Inv. Header" var PopUpVATLCYCorrection: Boolean; + PurchaseInvoiceAlreadyExistsQst: Label 'Purchase invoice %1 already exists for this vendor.\Do you want to continue?', Comment = '%1 = External Document No.; e.g. Purchase Invoice 123 already exists...'; procedure SetPopUpVATLCYCorrectionCZL(NewPopUpVATLCYCorrection: Boolean) begin @@ -223,6 +228,35 @@ tableextension 11730 "Purch. Inv. Header CZL" extends "Purch. Inv. Header" OnAfterUpdateBankInfoCZL(Rec); end; + internal procedure CheckAndConfirmExternalDocumentNumber() + var + PurchasesPayablesSetup: Record "Purchases & Payables Setup"; + ConfirmManagement: Codeunit "Confirm Management"; + begin + if not GuiAllowed() then + exit; + + PurchasesPayablesSetup.Get(); + if not PurchasesPayablesSetup."Ext. Doc. No. Mandatory" and ("Vendor Invoice No." = '') then + exit; + + if not ExistEntriesWithSameExternalDocNo("Vendor Invoice No.") then + exit; + + if not ConfirmManagement.GetResponse(StrSubstNo(PurchaseInvoiceAlreadyExistsQst, "Vendor Invoice No."), false) then + Error(''); + end; + + local procedure ExistEntriesWithSameExternalDocNo(ExternalDocumentNo: Code[35]): Boolean + var + VendorLedgerEntry: Record "Vendor Ledger Entry"; + VendorMgt: Codeunit "Vendor Mgt."; + begin + VendorMgt.SetFilterForExternalDocNo( + VendorLedgerEntry, Enum::"Gen. Journal Document Type"::Invoice, ExternalDocumentNo, "Pay-to Vendor No.", "Document Date"); + exit(not VendorLedgerEntry.IsEmpty()); + end; + [IntegrationEvent(false, false)] local procedure OnAfterUpdateBankInfoCZL(var PurchInvHeader: Record "Purch. Inv. Header") begin diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleExtensionCZL.Table.al b/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleExtensionCZL.Table.al index ebe312f295..b74e560349 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleExtensionCZL.Table.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleExtensionCZL.Table.al @@ -17,7 +17,7 @@ using Microsoft.Warehouse.Structure; table 31092 "Acc. Schedule Extension CZL" { - Caption = 'Acc. Schedule Extension'; + Caption = 'Fin. Report Extension'; LookupPageId = "Acc. Schedule Extensions CZL"; fields diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultColCZL.Table.al b/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultColCZL.Table.al index c79d0a33ca..593090673b 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultColCZL.Table.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultColCZL.Table.al @@ -6,7 +6,7 @@ namespace Microsoft.Finance.FinancialReports; table 31112 "Acc. Schedule Result Col. CZL" { - Caption = 'Acc. Schedule Result Column'; + Caption = 'Fin. Report Result Column'; fields { diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultHdrCZL.Table.al b/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultHdrCZL.Table.al index 214205a41f..1f76a39c35 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultHdrCZL.Table.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultHdrCZL.Table.al @@ -8,7 +8,7 @@ using System.Security.AccessControl; table 31099 "Acc. Schedule Result Hdr. CZL" { - Caption = 'Acc. Schedule Result Header'; + Caption = 'Fin. Report Result Header'; LookupPageId = "Acc. Sched. Res. Hdr. List CZL"; fields @@ -30,7 +30,7 @@ table 31099 "Acc. Schedule Result Hdr. CZL" } field(4; "Acc. Schedule Name"; Code[10]) { - Caption = 'Acc. Schedule Name'; + Caption = 'Fin. Report Name'; DataClassification = CustomerContent; TableRelation = "Acc. Schedule Name"; } diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultHistCZL.Table.al b/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultHistCZL.Table.al index 6072384ce3..c1d4743d15 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultHistCZL.Table.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultHistCZL.Table.al @@ -8,7 +8,7 @@ using System.Security.AccessControl; table 31114 "Acc. Schedule Result Hist. CZL" { - Caption = 'Acc. Schedule Result History'; + Caption = 'Fin. Report Result History'; fields { diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultLineCZL.Table.al b/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultLineCZL.Table.al index c4f8ceb994..16bda1735a 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultLineCZL.Table.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultLineCZL.Table.al @@ -9,7 +9,7 @@ using Microsoft.Finance.GeneralLedger.Account; table 31111 "Acc. Schedule Result Line CZL" { - Caption = 'Acc. Schedule Result Line'; + Caption = 'Fin. Report Result Line'; fields { diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultValueCZL.Table.al b/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultValueCZL.Table.al index dd667c0460..69caa8427c 100644 --- a/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultValueCZL.Table.al +++ b/Apps/CZ/CoreLocalizationPack/app/Src/Tables/AccScheduleResultValueCZL.Table.al @@ -6,7 +6,7 @@ namespace Microsoft.Finance.FinancialReports; table 31113 "Acc. Schedule Result Value CZL" { - Caption = 'Acc. Schedule Result Value'; + Caption = 'Fin. Report Result Value'; fields { diff --git a/Apps/CZ/IntrastatCZ/app/src/Codeunits/IntrastatReportManagementCZ.Codeunit.al b/Apps/CZ/IntrastatCZ/app/src/Codeunits/IntrastatReportManagementCZ.Codeunit.al index f58175d663..af72759ab7 100644 --- a/Apps/CZ/IntrastatCZ/app/src/Codeunits/IntrastatReportManagementCZ.Codeunit.al +++ b/Apps/CZ/IntrastatCZ/app/src/Codeunits/IntrastatReportManagementCZ.Codeunit.al @@ -515,10 +515,14 @@ codeunit 31302 IntrastatReportManagementCZ var IntrastatReportHeader: Record "Intrastat Report Header"; IntrastatReportSetup: Record "Intrastat Report Setup"; + Item: Record Item; SpecificMovementCZ: Record "Specific Movement CZ"; TempSalesHeader: Record "Sales Header" temporary; IntrastatReportManagement: Codeunit IntrastatReportManagement; RoundingDirection: Text[1]; + CurrencyFactor: Decimal; + FairMarketValue: Decimal; + ToleranceFairMarketValuePer: Decimal; begin IntrastatReportHeader.Get(IntrastatReportLine."Intrastat No."); IntrastatReportLine."Partner VAT ID" := ''; @@ -551,6 +555,29 @@ codeunit 31302 IntrastatReportManagementCZ TempSalesHeader."VAT Currency Factor CZL"), 1, RoundingDirection); end; + + if (IntrastatReportLine.Amount = 0) or (IntrastatReportLine.Quantity = 0) then + exit; + + IntrastatReportSetup.Get(); + if IntrastatReportSetup."Min. Tol. Fair Market Value CZ" = 0 then + exit; + + Item.SetLoadFields("Fair Market Value CZ"); + Item.Get(ItemLedgerEntry."Item No."); + if Item."Fair Market Value CZ" = 0 then + exit; + + FairMarketValue := Item."Fair Market Value CZ" * IntrastatReportLine.Quantity; + if IntrastatReportLine.Amount >= FairMarketValue then + exit; + + CurrencyFactor := IntrastatReportLine."Source Currency Amount" / IntrastatReportLine.Amount; + ToleranceFairMarketValuePer := Abs(IntrastatReportLine.Amount - FairMarketValue) / FairMarketValue * 100; + if ToleranceFairMarketValuePer >= IntrastatReportSetup."Min. Tol. Fair Market Value CZ" then begin + IntrastatReportLine.Validate(Amount, FairMarketValue); + IntrastatReportLine."Source Currency Amount" := IntrastatReportLine.Amount * CurrencyFactor; + end; end; procedure GetDocument(DocumentType: Enum "Item Ledger Document Type"; DocumentNo: Code[20]; var SalesHeader: Record "Sales Header") IsDocumentExist: Boolean diff --git a/Apps/CZ/IntrastatCZ/app/src/PageExtensions/IntrastatReportSetupCZ.PageExt.al b/Apps/CZ/IntrastatCZ/app/src/PageExtensions/IntrastatReportSetupCZ.PageExt.al index 407dd63008..6d39d1ecbd 100644 --- a/Apps/CZ/IntrastatCZ/app/src/PageExtensions/IntrastatReportSetupCZ.PageExt.al +++ b/Apps/CZ/IntrastatCZ/app/src/PageExtensions/IntrastatReportSetupCZ.PageExt.al @@ -29,6 +29,13 @@ pageextension 31342 "Intrastat Report Setup CZ" extends "Intrastat Report Setup" ToolTip = 'Specifies the rounding type for amount calculation for Intrastat declaration.'; } } + addlast(Reporting) + { + field("Min. Tol. Fair Market Value CZ"; Rec."Min. Tol. Fair Market Value CZ") + { + ApplicationArea = Basic, Suite; + } + } #if not CLEAN26 addafter(Numbering) { diff --git a/Apps/CZ/IntrastatCZ/app/src/PageExtensions/ItemCardCZ.PageExt.al b/Apps/CZ/IntrastatCZ/app/src/PageExtensions/ItemCardCZ.PageExt.al index 7a5abf5541..da43d9419d 100644 --- a/Apps/CZ/IntrastatCZ/app/src/PageExtensions/ItemCardCZ.PageExt.al +++ b/Apps/CZ/IntrastatCZ/app/src/PageExtensions/ItemCardCZ.PageExt.al @@ -23,5 +23,12 @@ pageextension 31301 "Item Card CZ" extends "Item Card" ToolTip = 'Specifies the Specific Movement for Intrastat reporting purposes.'; } } + addlast(ForeignTrade) + { + field("Fair Market Value CZ"; Rec."Fair Market Value CZ") + { + ApplicationArea = Basic, Suite; + } + } } } diff --git a/Apps/CZ/IntrastatCZ/app/src/TableExtensions/IntrastatReportSetupCZ.TableExt.al b/Apps/CZ/IntrastatCZ/app/src/TableExtensions/IntrastatReportSetupCZ.TableExt.al index 8d74459a32..4df3acf63e 100644 --- a/Apps/CZ/IntrastatCZ/app/src/TableExtensions/IntrastatReportSetupCZ.TableExt.al +++ b/Apps/CZ/IntrastatCZ/app/src/TableExtensions/IntrastatReportSetupCZ.TableExt.al @@ -91,6 +91,14 @@ tableextension 31326 "Intrastat Report Setup CZ" extends "Intrastat Report Setup Caption = 'Default Phys. Trans. - Returns'; DataClassification = CustomerContent; } + field(31320; "Min. Tol. Fair Market Value CZ"; Decimal) + { + Caption = 'Minimum Tolerance from Fair Market Value (%)'; + DataClassification = CustomerContent; + MinValue = 0; + MaxValue = 100; + ToolTip = 'Specifies the minimum percentage tolerance at which the system replaces the sales or purchase price from the item ledger entries with the fair market value entered on the item card when generating Intrastat line suggestions. This tolerance is evaluated during the Intrastat report line creation process.'; + } } var diff --git a/Apps/CZ/IntrastatCZ/app/src/TableExtensions/ItemCZ.TableExt.al b/Apps/CZ/IntrastatCZ/app/src/TableExtensions/ItemCZ.TableExt.al index 62fa994c9f..85e347252f 100644 --- a/Apps/CZ/IntrastatCZ/app/src/TableExtensions/ItemCZ.TableExt.al +++ b/Apps/CZ/IntrastatCZ/app/src/TableExtensions/ItemCZ.TableExt.al @@ -22,5 +22,11 @@ tableextension 31301 "Item CZ" extends Item DataClassification = CustomerContent; TableRelation = "Specific Movement CZ".Code; } + field(31310; "Fair Market Value CZ"; Decimal) + { + Caption = 'Fair Market Value'; + DataClassification = CustomerContent; + ToolTip = 'Specifies the price which the system compares with the sales or purchase price from the item ledger entries with this value when generating Intrastat line suggestions. If the calculated tolerance is equal to or greater than the Minimum Tolerance from Fair Market Value (%) defined in the Intrastat Report Setup, the system will use this fair market value in the suggested lines instead of the actual sales or purchase price.'; + } } } \ No newline at end of file diff --git a/Apps/DE/ContosoCoffeeDemoDatasetDE/app/DemoData/Finance/2. Master data/CreateDECurrencyExRate.Codeunit.al b/Apps/DE/ContosoCoffeeDemoDatasetDE/app/DemoData/Finance/2. Master data/CreateDECurrencyExRate.Codeunit.al index 2949a35cb3..969cccaff8 100644 --- a/Apps/DE/ContosoCoffeeDemoDatasetDE/app/DemoData/Finance/2. Master data/CreateDECurrencyExRate.Codeunit.al +++ b/Apps/DE/ContosoCoffeeDemoDatasetDE/app/DemoData/Finance/2. Master data/CreateDECurrencyExRate.Codeunit.al @@ -195,4 +195,14 @@ codeunit 11376 "Create DE Currency Ex. Rate" CurrencyExchangeRate.Validate("Relational Exch. Rate Amount", RelationalExchRateAmount); CurrencyExchangeRate.Validate("Relational Adjmt Exch Rate Amt", RelationalAdjmtExchRateAmt); end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Add. Reporting Currency", OnBeforeGetResidualCurrencyAccounts, '', false, false)] + local procedure GetResidualCurrencyAccountsDe(var FXGainsAccount: Code[20]; var FXLossesAccount: Code[20]; var IsHandled: Boolean) + var + CreateDEGLAcc: Codeunit "Create DE GL Acc."; + begin + FXGainsAccount := CreateDEGLAcc.CurrencyGains(); + FXLossesAccount := CreateDEGLAcc.CurrencyLosses(); + IsHandled := true; + end; } diff --git a/Apps/DE/EDocumentDE/app/src/EDocSalesCrMemoHeaderDE.TableExt.al b/Apps/DE/EDocumentDE/app/src/EDocSalesCrMemoHeaderDE.TableExt.al index 6713af73a0..7415157900 100644 --- a/Apps/DE/EDocumentDE/app/src/EDocSalesCrMemoHeaderDE.TableExt.al +++ b/Apps/DE/EDocumentDE/app/src/EDocSalesCrMemoHeaderDE.TableExt.al @@ -9,10 +9,12 @@ tableextension 11038 "E-Doc Sales CrMemo Header DE" extends "Sales Cr.Memo Heade { fields { +#pragma warning disable AS0125 field(11035; "Buyer Reference"; Text[100]) { Caption = 'Buyer Reference'; DataClassification = CustomerContent; } +#pragma warning restore AS0125 } } \ No newline at end of file diff --git a/Apps/DE/EDocumentDE/app/src/EDocSalesHeaderDE.TableExt.al b/Apps/DE/EDocumentDE/app/src/EDocSalesHeaderDE.TableExt.al index b974a18c46..ba6414808a 100644 --- a/Apps/DE/EDocumentDE/app/src/EDocSalesHeaderDE.TableExt.al +++ b/Apps/DE/EDocumentDE/app/src/EDocSalesHeaderDE.TableExt.al @@ -9,10 +9,12 @@ tableextension 11036 "E-Doc Sales Header DE" extends "Sales Header" { fields { +#pragma warning disable AS0125 field(11035; "Buyer Reference"; Text[100]) { Caption = 'Buyer Reference'; DataClassification = CustomerContent; } +#pragma warning restore AS0125 } } \ No newline at end of file diff --git a/Apps/DE/EDocumentDE/app/src/EDocSalesInvoiceHeaderDE.TableExt.al b/Apps/DE/EDocumentDE/app/src/EDocSalesInvoiceHeaderDE.TableExt.al index 737ba659f7..e37b027cce 100644 --- a/Apps/DE/EDocumentDE/app/src/EDocSalesInvoiceHeaderDE.TableExt.al +++ b/Apps/DE/EDocumentDE/app/src/EDocSalesInvoiceHeaderDE.TableExt.al @@ -9,10 +9,12 @@ tableextension 11037 "E-Doc Sales Invoice Header DE" extends "Sales Invoice Head { fields { +#pragma warning disable AS0125 field(11035; "Buyer Reference"; Text[100]) { Caption = 'Buyer Reference'; DataClassification = CustomerContent; } +#pragma warning restore AS0125 } } \ No newline at end of file diff --git a/Apps/DE/EDocumentDE/app/src/EDocServiceCrMemoHdrDE.TableExt.al b/Apps/DE/EDocumentDE/app/src/EDocServiceCrMemoHdrDE.TableExt.al new file mode 100644 index 0000000000..5511dbd3eb --- /dev/null +++ b/Apps/DE/EDocumentDE/app/src/EDocServiceCrMemoHdrDE.TableExt.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.EDocument.Formats; +using Microsoft.Service.History; + +tableextension 11041 "E-Doc Service CrMemo Hdr DE" extends "Service Cr.Memo Header" +{ + fields + { +#pragma warning disable AS0125 + field(11035; "Buyer Reference"; Text[100]) + { + Caption = 'Buyer Reference'; + DataClassification = CustomerContent; + } +#pragma warning restore AS0125 + } +} diff --git a/Apps/DE/EDocumentDE/app/src/EDocServiceHeaderDE.TableExt.al b/Apps/DE/EDocumentDE/app/src/EDocServiceHeaderDE.TableExt.al new file mode 100644 index 0000000000..d258c6d3d4 --- /dev/null +++ b/Apps/DE/EDocumentDE/app/src/EDocServiceHeaderDE.TableExt.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.EDocument.Formats; +using Microsoft.Service.Document; + +tableextension 11039 "E-Doc Service Header DE" extends "Service Header" +{ + fields + { +#pragma warning disable AS0125 + field(11035; "Buyer Reference"; Text[100]) + { + Caption = 'Buyer Reference'; + DataClassification = CustomerContent; + } +#pragma warning restore AS0125 + } +} diff --git a/Apps/DE/EDocumentDE/app/src/EDocServiceInvoiceHdrDE.TableExt.al b/Apps/DE/EDocumentDE/app/src/EDocServiceInvoiceHdrDE.TableExt.al new file mode 100644 index 0000000000..7b8daed787 --- /dev/null +++ b/Apps/DE/EDocumentDE/app/src/EDocServiceInvoiceHdrDE.TableExt.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.EDocument.Formats; +using Microsoft.Service.History; + +tableextension 11040 "E-Doc Service Invoice Hdr DE" extends "Service Invoice Header" +{ + fields + { +#pragma warning disable AS0125 + field(11035; "Buyer Reference"; Text[100]) + { + Caption = 'Buyer Reference'; + DataClassification = CustomerContent; + } +#pragma warning restore AS0125 + } +} diff --git a/Apps/DE/EDocumentDE/app/src/PEPPOL/EDocPEPPOLBIS30DE.Codeunit.al b/Apps/DE/EDocumentDE/app/src/PEPPOL/EDocPEPPOLBIS30DE.Codeunit.al index 255c46d904..7e4a4d3f0e 100644 --- a/Apps/DE/EDocumentDE/app/src/PEPPOL/EDocPEPPOLBIS30DE.Codeunit.al +++ b/Apps/DE/EDocumentDE/app/src/PEPPOL/EDocPEPPOLBIS30DE.Codeunit.al @@ -132,6 +132,15 @@ codeunit 11035 "EDoc PEPPOL BIS 3.0 DE" implements "E-Document" EDocServiceSupportedType."Source Document Type" := Enum::"E-Document Type"::"Sales Credit Memo"; EDocServiceSupportedType.Insert(); + + EDocServiceSupportedType."Source Document Type" := Enum::"E-Document Type"::"Service Invoice"; + EDocServiceSupportedType.Insert(); + + EDocServiceSupportedType."Source Document Type" := Enum::"E-Document Type"::"Service Credit Memo"; + EDocServiceSupportedType.Insert(); + + EDocServiceSupportedType."Source Document Type" := Enum::"E-Document Type"::"Service Order"; + EDocServiceSupportedType.Insert(); end; local procedure CheckBuyerReferenceMandatory(EDocumentService: Record "E-Document Service"; SourceDocumentHeader: RecordRef) @@ -178,6 +187,8 @@ codeunit 11035 "EDoc PEPPOL BIS 3.0 DE" implements "E-Document" var SalesInvoiceHeader: Record "Sales Invoice Header"; SalesCrMemoHeader: Record "Sales Cr.Memo Header"; + ServiceInvoiceHeader: Record "Service Invoice Header"; + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; Customer: Record Customer; CustomerNoFieldRef: FieldRef; YourReferenceFieldRef: FieldRef; @@ -210,6 +221,19 @@ codeunit 11035 "EDoc PEPPOL BIS 3.0 DE" implements "E-Document" SalesCrMemoHeader.Validate("Buyer Reference", BuyerReference); SalesCrMemoHeader.Modify(true); end; + + Database::"Service Invoice Header": + begin + SourceDocumentHeader.SetTable(ServiceInvoiceHeader); + ServiceInvoiceHeader.Validate("Buyer Reference", BuyerReference); + ServiceInvoiceHeader.Modify(true); + end; + Database::"Service Cr.Memo Header": + begin + SourceDocumentHeader.SetTable(ServiceCrMemoHeader); + ServiceCrMemoHeader.Validate("Buyer Reference", BuyerReference); + ServiceCrMemoHeader.Modify(true); + end; end; end; diff --git a/Apps/DE/EDocumentDE/app/src/XRechnung/ExportXRechnungDocument.Codeunit.al b/Apps/DE/EDocumentDE/app/src/XRechnung/ExportXRechnungDocument.Codeunit.al index e5b7895848..85b6207ba3 100644 --- a/Apps/DE/EDocumentDE/app/src/XRechnung/ExportXRechnungDocument.Codeunit.al +++ b/Apps/DE/EDocumentDE/app/src/XRechnung/ExportXRechnungDocument.Codeunit.al @@ -20,12 +20,12 @@ using Microsoft.Sales.Customer; using Microsoft.Sales.Document; using Microsoft.Sales.History; using Microsoft.Sales.Peppol; +using Microsoft.Service.History; using System.IO; using System.Reflection; using System.Telemetry; using System.Text; using System.Utilities; - codeunit 13916 "Export XRechnung Document" { TableNo = "Record Export Buffer"; @@ -37,6 +37,7 @@ codeunit 13916 "Export XRechnung Document" GeneralLedgerSetup: Record "General Ledger Setup"; EDocumentService: Record "E-Document Service"; FeatureTelemetry: Codeunit "Feature Telemetry"; + PEPPOLMgt: Codeunit "PEPPOL Management"; FeatureNameTok: Label 'E-document XRechnung Format', Locked = true; StartEventNameTok: Label 'E-document XRechnung export started', Locked = true; EndEventNameTok: Label 'E-document XRechnung export completed', Locked = true; @@ -50,43 +51,81 @@ codeunit 13916 "Export XRechnung Document" ExportSalesInvoice(Rec); Database::"Sales Cr.Memo Header": ExportSalesCreditMemo(Rec); + Database::"Service Invoice Header": + ExportServiceInvoice(Rec); + Database::"Service Cr.Memo Header": + ExportServiceCreditMemo(Rec); end; end; - procedure ExportSalesInvoice(var Rec: Record "Record Export Buffer") + procedure ExportSalesInvoice(var RecordExportBuffer: Record "Record Export Buffer") var SalesInvoiceHeader: Record "Sales Invoice Header"; RecordRef: RecordRef; FileOutStream: OutStream; begin FeatureTelemetry.LogUsage('0000EXD', FeatureNameTok, StartEventNameTok); - RecordRef.Get(Rec.RecordID); + RecordRef.Get(RecordExportBuffer.RecordID); RecordRef.SetTable(SalesInvoiceHeader); - FindEDocumentService(Rec."Electronic Document Format"); - Rec."File Content".CreateOutStream(FileOutStream, TextEncoding::UTF8); + FindEDocumentService(RecordExportBuffer."Electronic Document Format"); + RecordExportBuffer."File Content".CreateOutStream(FileOutStream, TextEncoding::UTF8); CreateXML(SalesInvoiceHeader, FileOutStream); - Rec.Modify(); + RecordExportBuffer.Modify(); FeatureTelemetry.LogUsage('0000EXE', FeatureNameTok, EndEventNameTok); end; - procedure ExportSalesCreditMemo(var Rec: Record "Record Export Buffer") + procedure ExportSalesCreditMemo(var RecordExportBuffer: Record "Record Export Buffer") var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; RecordRef: RecordRef; FileOutStream: OutStream; begin FeatureTelemetry.LogUsage('0000EXF', FeatureNameTok, StartEventNameTok); - RecordRef.Get(Rec.RecordID); + RecordRef.Get(RecordExportBuffer.RecordID); RecordRef.SetTable(SalesCrMemoHeader); - FindEDocumentService(Rec."Electronic Document Format"); - Rec."File Content".CreateOutStream(FileOutStream, TextEncoding::UTF8); + FindEDocumentService(RecordExportBuffer."Electronic Document Format"); + RecordExportBuffer."File Content".CreateOutStream(FileOutStream, TextEncoding::UTF8); CreateXML(SalesCrMemoHeader, FileOutStream); - Rec.Modify(); + RecordExportBuffer.Modify(); FeatureTelemetry.LogUsage('0000EXG', FeatureNameTok, EndEventNameTok); end; + procedure ExportServiceInvoice(var RecordExportBuffer: Record "Record Export Buffer") + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + RecordRef: RecordRef; + FileOutStream: OutStream; + begin + FeatureTelemetry.LogUsage('0000EXH', FeatureNameTok, StartEventNameTok); + RecordRef.Get(RecordExportBuffer.RecordID); + RecordRef.SetTable(ServiceInvoiceHeader); + + FindEDocumentService(RecordExportBuffer."Electronic Document Format"); + RecordExportBuffer."File Content".CreateOutStream(FileOutStream, TextEncoding::UTF8); + CreateXML(ServiceInvoiceHeader, FileOutStream); + RecordExportBuffer.Modify(); + FeatureTelemetry.LogUsage('0000EXI', FeatureNameTok, EndEventNameTok); + end; + + procedure ExportServiceCreditMemo(var RecordExportBuffer: Record "Record Export Buffer") + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + RecordRef: RecordRef; + FileOutStream: OutStream; + begin + FeatureTelemetry.LogUsage('0000EXJ', FeatureNameTok, StartEventNameTok); + RecordRef.Get(RecordExportBuffer.RecordID); + RecordRef.SetTable(ServiceCrMemoHeader); + + FindEDocumentService(RecordExportBuffer."Electronic Document Format"); + RecordExportBuffer."File Content".CreateOutStream(FileOutStream, TextEncoding::UTF8); + CreateXML(ServiceCrMemoHeader, FileOutStream); + RecordExportBuffer.Modify(); + FeatureTelemetry.LogUsage('0000EXK', FeatureNameTok, EndEventNameTok); + end; + procedure CreateXML(SalesInvoiceHeader: Record "Sales Invoice Header"; var FileOutstream: Outstream) var Currency: Record "Currency"; @@ -177,6 +216,115 @@ codeunit 13916 "Export XRechnung Document" Clear(XMLDoc); end; + procedure CreateXML(ServiceInvoiceHeader: Record "Service Invoice Header"; var FileOutstream: Outstream) + var + Currency: Record "Currency"; + SalesInvoiceHeader: Record "Sales Invoice Header"; + TempSalesInvLine: Record "Sales Invoice Line" temporary; + ServiceInvoiceLine: Record "Service Invoice Line"; + RootXMLNode: XmlElement; + XMLDoc: XmlDocument; + XMLDocText: Text; + CurrencyCode: Code[10]; + LineAmounts: Dictionary of [Text, Decimal]; + LineVATAmount: Dictionary of [Decimal, Decimal]; + LineAmount: Dictionary of [Decimal, Decimal]; + LineDiscAmount: Dictionary of [Decimal, Decimal]; + begin + GetSetups(); + PEPPOLMgt.TransferHeaderToSalesInvoiceHeader(ServiceInvoiceHeader, SalesInvoiceHeader); + ServiceInvoiceLine.SetRange("Document No.", ServiceInvoiceHeader."No."); + if ServiceInvoiceLine.FindSet() then + repeat + PEPPOLMgt.TransferLineToSalesInvoiceLine(ServiceInvoiceLine, TempSalesInvLine); + TempSalesInvLine.Insert(); + until ServiceInvoiceLine.Next() = 0; + + if not DocumentLinesExist(SalesInvoiceHeader, TempSalesInvLine) then + exit; + + CurrencyCode := GetCurrencyCode(SalesInvoiceHeader."Currency Code", Currency); + + XmlDocument.ReadFrom(GetInvoiceXMLHeader(), XMLDoc); + XmlDoc.GetRoot(RootXMLNode); + + InitializeNamespaces(); + + InsertHeaderData(RootXMLNode, SalesInvoiceHeader, CurrencyCode); + InsertOrderReference(RootXMLNode, SalesInvoiceHeader); + InsertEmbeddedDocument(RootXMLNode, SalesInvoiceHeader); + InsertAttachment(RootXMLNode, Database::"Sales Invoice Header", SalesInvoiceHeader."No."); + CalculateLineAmounts(SalesInvoiceHeader, TempSalesInvLine, Currency, LineAmounts); + InsertAccountingSupplierParty(SalesInvoiceHeader."Responsibility Center", SalesInvoiceHeader."Salesperson Code", RootXMLNode); + InsertAccountingCustomerParty(RootXMLNode, SalesInvoiceHeader); + InsertDelivery(RootXMLNode, SalesInvoiceHeader); + InsertPaymentMeans(RootXMLNode, '68', 'PayeeFinancialAccount', SalesInvoiceHeader."Company Bank Account Code"); + InsertPaymentTerms(RootXMLNode, SalesInvoiceHeader."Payment Terms Code"); + InsertVATAmounts(TempSalesInvLine, LineVATAmount, LineAmount, LineDiscAmount, SalesInvoiceHeader."Prices Including VAT", Currency); + InsertInvDiscountAllowanceCharge(LineAmounts, TempSalesInvLine, CurrencyCode, RootXMLNode, LineDiscAmount, LineAmount, Currency."Amount Rounding Precision"); + InsertTaxTotal(RootXMLNode, TempSalesInvLine, CurrencyCode, LineAmount, LineVATAmount); + InsertLegalMonetaryTotal(RootXMLNode, TempSalesInvLine, LineAmounts, CurrencyCode); + InsertInvoiceLines(RootXMLNode, TempSalesInvLine, Currency, CurrencyCode, SalesInvoiceHeader."Prices Including VAT"); + OnCreateXMLOnBeforeSalesInvXmlDocumentWriteToFile(XMLDoc, SalesInvoiceHeader); + XMLDoc.WriteTo(XMLDocText); + FileOutstream.WriteText(XMLDocText); + Clear(XMLDoc); + end; + + procedure CreateXML(ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var FileOutstream: Outstream) + var + Currency: Record "Currency"; + SalesCrMemoHeader: Record "Sales Cr.Memo Header"; + TempSalesCrMemoLine: Record "Sales Cr.Memo Line" temporary; + ServiceCrMemoLine: Record "Service Cr.Memo Line"; + RootXMLNode: XmlElement; + XMLDoc: XmlDocument; + XMLDocText: Text; + CurrencyCode: Code[10]; + LineAmounts: Dictionary of [Text, Decimal]; + LineVATAmount: Dictionary of [Decimal, Decimal]; + LineAmount: Dictionary of [Decimal, Decimal]; + LineDiscAmount: Dictionary of [Decimal, Decimal]; + begin + GetSetups(); + PEPPOLMgt.TransferHeaderToSalesCrMemoHeader(ServiceCrMemoHeader, SalesCrMemoHeader); + ServiceCrMemoLine.SetRange("Document No.", ServiceCrMemoHeader."No."); + if ServiceCrMemoLine.FindSet() then + repeat + PEPPOLMgt.TransferLineToSalesCrMemoLine(ServiceCrMemoLine, TempSalesCrMemoLine); + TempSalesCrMemoLine.Insert(); + until ServiceCrMemoLine.Next() = 0; + if not DocumentLinesExist(SalesCrMemoHeader, TempSalesCrMemoLine) then + exit; + + CurrencyCode := GetCurrencyCode(SalesCrMemoHeader."Currency Code", Currency); + + XmlDocument.ReadFrom(GetCrMemoXMLHeader(), XMLDoc); + XmlDoc.GetRoot(RootXMLNode); + + InitializeNamespaces(); + + InsertHeaderData(RootXMLNode, SalesCrMemoHeader, CurrencyCode); + InsertOrderReference(RootXMLNode, SalesCrMemoHeader); + InsertEmbeddedDocument(RootXMLNode, SalesCrMemoHeader); + InsertAttachment(RootXMLNode, Database::"Sales Cr.Memo Header", SalesCrMemoHeader."No."); + CalculateLineAmounts(SalesCrMemoHeader, TempSalesCrMemoLine, Currency, LineAmounts); + InsertAccountingSupplierParty(SalesCrMemoHeader."Responsibility Center", SalesCrMemoHeader."Salesperson Code", RootXMLNode); + InsertAccountingCustomerParty(RootXMLNode, SalesCrMemoHeader); + InsertDelivery(RootXMLNode, SalesCrMemoHeader); + InsertPaymentMeans(RootXMLNode, '68', '', SalesCrMemoHeader."Company Bank Account Code"); + InsertPaymentTerms(RootXMLNode, SalesCrMemoHeader."Payment Terms Code"); + InsertVATAmounts(TempSalesCrMemoLine, LineVATAmount, LineAmount, LineDiscAmount, SalesCrMemoHeader."Prices Including VAT", Currency); + InsertInvDiscountAllowanceCharge(LineAmounts, TempSalesCrMemoLine, CurrencyCode, RootXMLNode, LineDiscAmount, LineAmount, Currency."Amount Rounding Precision"); + InsertTaxTotal(RootXMLNode, TempSalesCrMemoLine, CurrencyCode, LineAmount, LineVATAmount); + InsertLegalMonetaryTotal(RootXMLNode, TempSalesCrMemoLine, LineAmounts, CurrencyCode); + InsertCrMemoLines(RootXMLNode, TempSalesCrMemoLine, Currency, CurrencyCode, SalesCrMemoHeader."Prices Including VAT"); + OnCreateXMLOnBeforeSalesCrMemoXmlDocumentWriteToFile(XMLDoc, SalesCrMemoHeader); + XMLDoc.WriteTo(XMLDocText); + FileOutstream.WriteText(XMLDocText); + Clear(XMLDoc); + end; + local procedure GetInvoiceXMLHeader(): Text begin exit('' + @@ -936,7 +1084,6 @@ codeunit 13916 "Export XRechnung Document" SalesHeader: Record "Sales Header"; SalesInvoiceHeader: Record "Sales Invoice Header"; SalesCrMemoHeader: Record "Sales Cr.Memo Header"; - PEPPOLMgt: Codeunit "PEPPOL Management"; DataTypeManagement: Codeunit "Data Type Management"; HeaderRecordRef: RecordRef; AttachmentElement: XmlElement; diff --git a/Apps/DE/EDocumentDE/app/src/XRechnung/XRechnungFormat.Codeunit.al b/Apps/DE/EDocumentDE/app/src/XRechnung/XRechnungFormat.Codeunit.al index 1a21ce99bc..83bcc9e5b4 100644 --- a/Apps/DE/EDocumentDE/app/src/XRechnung/XRechnungFormat.Codeunit.al +++ b/Apps/DE/EDocumentDE/app/src/XRechnung/XRechnungFormat.Codeunit.al @@ -150,6 +150,15 @@ codeunit 13914 "XRechnung Format" implements "E-Document" EDocServiceSupportedType."Source Document Type" := EDocServiceSupportedType."Source Document Type"::"Purchase Credit Memo"; EDocServiceSupportedType.Insert(); + + EDocServiceSupportedType."Source Document Type" := EDocServiceSupportedType."Source Document Type"::"Service Invoice"; + EDocServiceSupportedType.Insert(); + + EDocServiceSupportedType."Source Document Type" := EDocServiceSupportedType."Source Document Type"::"Service Credit Memo"; + EDocServiceSupportedType.Insert(); + + EDocServiceSupportedType."Source Document Type" := EDocServiceSupportedType."Source Document Type"::"Service Order"; + EDocServiceSupportedType.Insert(); end; [IntegrationEvent(false, false)] diff --git a/Apps/DE/EDocumentDE/app/src/ZUGFeRD/ExportZUGFeRDDocument.Codeunit.al b/Apps/DE/EDocumentDE/app/src/ZUGFeRD/ExportZUGFeRDDocument.Codeunit.al index 54c911b064..7357b0168d 100644 --- a/Apps/DE/EDocumentDE/app/src/ZUGFeRD/ExportZUGFeRDDocument.Codeunit.al +++ b/Apps/DE/EDocumentDE/app/src/ZUGFeRD/ExportZUGFeRDDocument.Codeunit.al @@ -17,6 +17,8 @@ using Microsoft.Foundation.UOM; using Microsoft.Inventory.Location; using Microsoft.Sales.Customer; using Microsoft.Sales.History; +using Microsoft.Sales.Peppol; +using Microsoft.Service.History; using System.IO; using System.Reflection; using System.Telemetry; @@ -33,6 +35,7 @@ codeunit 13917 "Export ZUGFeRD Document" GeneralLedgerSetup: Record "General Ledger Setup"; EDocumentService: Record "E-Document Service"; FeatureTelemetry: Codeunit "Feature Telemetry"; + PEPPOLMgt: Codeunit "PEPPOL Management"; FeatureNameTok: Label 'E-document ZUGFeRD Format', Locked = true; StartEventNameTok: Label 'E-document ZUGFeRD export started', Locked = true; EndEventNameTok: Label 'E-document ZUGFeRD export completed', Locked = true; @@ -99,6 +102,38 @@ codeunit 13917 "Export ZUGFeRD Document" AddXMLAttachmentToRenderingPayload(TempBlob, RenderingPayload); end; + /// + /// Creates a ZUGFeRD XML document from the service invoice and adds it as an attachment to the rendering payload. + /// + /// The service invoice header record to export. + /// The JSON object to add the XML attachment to. + procedure CreateAndAddXMLAttachmentToRenderingPayload(var ServiceInvoiceHeader: Record "Service Invoice Header"; var RenderingPayload: JsonObject) + var + TempBlob: Codeunit "Temp Blob"; + XmlOutStream: OutStream; + begin + TempBlob.CreateOutStream(XmlOutStream, TextEncoding::UTF8); + CreateXML(ServiceInvoiceHeader, XmlOutStream); + + AddXMLAttachmentToRenderingPayload(TempBlob, RenderingPayload); + end; + + /// + /// Creates a ZUGFeRD XML document from the service credit memo and adds it as an attachment to the rendering payload. + /// + /// The service credit memo header record to export. + /// The JSON object to add the XML attachment to. + procedure CreateAndAddXMLAttachmentToRenderingPayload(var ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var RenderingPayload: JsonObject) + var + TempBlob: Codeunit "Temp Blob"; + XmlOutStream: OutStream; + begin + TempBlob.CreateOutStream(XmlOutStream, TextEncoding::UTF8); + CreateXML(ServiceCrMemoHeader, XmlOutStream); + + AddXMLAttachmentToRenderingPayload(TempBlob, RenderingPayload); + end; + local procedure AddXMLAttachmentToRenderingPayload(var XmlAttachmentTempBlob: Codeunit "Temp Blob"; var RenderingPayload: JsonObject) var PDFDocument: Codeunit "PDF Document"; @@ -107,12 +142,13 @@ codeunit 13917 "Export ZUGFeRD Document" Name: Text; MimeType: Text; Description: Text; + DescriptionLbl: Label 'This is the e-invoicing xml document'; begin PDFDocument.Initialize(); Name := 'factur-x.xml'; DataType := Enum::"PDF Attach. Data Relationship"::Alternative; MimeType := 'text/xml'; - Description := 'This is the e-invoicing xml document'; + Description := DescriptionLbl; XmlAttachmentTempBlob.CreateInStream(XmlInStream, TextEncoding::UTF8); PDFDocument.AddAttachment(Name, DataType, MimeType, XmlInStream, Description, true); @@ -124,6 +160,8 @@ codeunit 13917 "Export ZUGFeRD Document" var SalesInvoiceHeader: Record "Sales Invoice Header"; SalesCrMemoHeader: Record "Sales Cr.Memo Header"; + ServiceInvoiceHeader: Record "Service Invoice Header"; + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; TempBlob: Codeunit "Temp Blob"; FileOutStream: OutStream; FileInStream: InStream; @@ -143,6 +181,18 @@ codeunit 13917 "Export ZUGFeRD Document" if not GenerateSalesCrMemoPDFAttachment(SalesCrMemoHeader, TempBlob) then exit; end; + Database::"Service Invoice Header": + begin + ServiceInvoiceHeader.Get(RecordExportBuffer.RecordID); + if not GenerateServiceInvoicePDFAttachment(ServiceInvoiceHeader, TempBlob) then + exit; + end; + Database::"Service Cr.Memo Header": + begin + ServiceCrMemoHeader.Get(RecordExportBuffer.RecordID); + if not GenerateServiceCrMemoPDFAttachment(ServiceCrMemoHeader, TempBlob) then + exit; + end; end; TempBlob.CreateInStream(FileInStream); RecordExportBuffer."File Content".CreateOutStream(FileOutStream, TextEncoding::UTF8); @@ -183,6 +233,38 @@ codeunit 13917 "Export ZUGFeRD Document" exit(TempBlob.HasValue()); end; + procedure GenerateServiceInvoicePDFAttachment(ServiceInvoiceHeader: Record "Service Invoice Header"; var TempBlob: Codeunit "Temp Blob"): Boolean + var + ReportSelections: Record "Report Selections"; + IsHandled: Boolean; + begin + IsHandled := false; + OnBeforeGenerateServiceInvoicePDFAttachment(ServiceInvoiceHeader, TempBlob, IsHandled); + if IsHandled then + exit(TempBlob.HasValue()); + ServiceInvoiceHeader.SetRange("No.", ServiceInvoiceHeader."No."); + ReportSelections.GetPdfReportForCust( + TempBlob, "Report Selection Usage"::"SM.Invoice", + ServiceInvoiceHeader, ServiceInvoiceHeader."Bill-to Customer No."); + exit(TempBlob.HasValue()); + end; + + procedure GenerateServiceCrMemoPDFAttachment(ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var TempBlob: Codeunit "Temp Blob"): Boolean + var + ReportSelections: Record "Report Selections"; + IsHandled: Boolean; + begin + IsHandled := false; + OnBeforeGenerateServiceCrMemoPDFAttachment(ServiceCrMemoHeader, TempBlob, IsHandled); + if IsHandled then + exit(TempBlob.HasValue()); + ServiceCrMemoHeader.SetRange("No.", ServiceCrMemoHeader."No."); + ReportSelections.GetPdfReportForCust( + TempBlob, "Report Selection Usage"::"SM.Credit Memo", + ServiceCrMemoHeader, ServiceCrMemoHeader."Bill-to Customer No."); + exit(TempBlob.HasValue()); + end; + procedure CreateXML(SalesInvoiceHeader: Record "Sales Invoice Header"; var FileOutstream: Outstream) var SalesInvLine: Record "Sales Invoice Line"; @@ -249,6 +331,90 @@ codeunit 13917 "Export ZUGFeRD Document" Clear(XMLDoc); end; + procedure CreateXML(ServiceInvoiceHeader: Record "Service Invoice Header"; var FileOutstream: Outstream) + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + ServiceInvoiceLine: Record "Service Invoice Line"; + TempSalesInvLine: Record "Sales Invoice Line" temporary; + Currency: Record Currency; + CurrencyCode: Code[10]; + RootXMLNode: XmlElement; + XMLDoc: XmlDocument; + XMLDocText: Text; + LineAmounts: Dictionary of [Text, Decimal]; + LineVATAmount: Dictionary of [Decimal, Decimal]; + LineAmount: Dictionary of [Decimal, Decimal]; + LineDiscAmount: Dictionary of [Decimal, Decimal]; + begin + GetSetups(); + FindEDocumentService(); + PEPPOLMgt.TransferHeaderToSalesInvoiceHeader(ServiceInvoiceHeader, SalesInvoiceHeader); + ServiceInvoiceLine.SetRange("Document No.", ServiceInvoiceHeader."No."); + if ServiceInvoiceLine.FindSet() then + repeat + PEPPOLMgt.TransferLineToSalesInvoiceLine(ServiceInvoiceLine, TempSalesInvLine); + TempSalesInvLine.Insert(); + until ServiceInvoiceLine.Next() = 0; + if not DocumentLinesExist(SalesInvoiceHeader, TempSalesInvLine) then + exit; + + XmlDocument.ReadFrom(GetInvoiceXMLHeader(), XMLDoc); + XmlDoc.GetRoot(RootXMLNode); + + InitializeNamespaces(); + CurrencyCode := GetCurrencyCode(SalesInvoiceHeader."Currency Code", Currency); + CalculateLineAmounts(SalesInvoiceHeader, TempSalesInvLine, Currency, LineAmounts); + InsertVATAmounts(TempSalesInvLine, LineVATAmount, LineAmount, LineDiscAmount, SalesInvoiceHeader."Prices Including VAT", Currency); + InsertHeaderData(RootXMLNode, SalesInvoiceHeader); + InsertSupplyChainTradeTransaction(RootXMLNode, SalesInvoiceHeader, TempSalesInvLine, CurrencyCode, Currency, LineAmount, LineVATAmount, LineAmounts, LineDiscAmount); + OnCreateXMLOnBeforeSalesInvXmlDocumentWriteToFile(XMLDoc, SalesInvoiceHeader); + XMLDoc.WriteTo(XMLDocText); + FileOutstream.WriteText(XMLDocText); + Clear(XMLDoc); + end; + + procedure CreateXML(ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var FileOutstream: Outstream) + var + SalesCrMemoHeader: Record "Sales Cr.Memo Header"; + TempSalesCrMemoLine: Record "Sales Cr.Memo Line" temporary; + ServiceCrMemoLine: Record "Service Cr.Memo Line"; + Currency: Record Currency; + CurrencyCode: Code[10]; + RootXMLNode: XmlElement; + XMLDoc: XmlDocument; + XMLDocText: Text; + LineAmounts: Dictionary of [Text, Decimal]; + LineVATAmount: Dictionary of [Decimal, Decimal]; + LineAmount: Dictionary of [Decimal, Decimal]; + LineDiscAmount: Dictionary of [Decimal, Decimal]; + begin + GetSetups(); + FindEDocumentService(); + PEPPOLMgt.TransferHeaderToSalesCrMemoHeader(ServiceCrMemoHeader, SalesCrMemoHeader); + ServiceCrMemoLine.SetRange("Document No.", ServiceCrMemoHeader."No."); + if ServiceCrMemoLine.FindSet() then + repeat + PEPPOLMgt.TransferLineToSalesCrMemoLine(ServiceCrMemoLine, TempSalesCrMemoLine); + TempSalesCrMemoLine.Insert(); + until ServiceCrMemoLine.Next() = 0; + if not DocumentLinesExist(SalesCrMemoHeader, TempSalesCrMemoLine) then + exit; + + XmlDocument.ReadFrom(GetInvoiceXMLHeader(), XMLDoc); + XmlDoc.GetRoot(RootXMLNode); + + InitializeNamespaces(); + CurrencyCode := GetCurrencyCode(SalesCrMemoHeader."Currency Code", Currency); + CalculateLineAmounts(SalesCrMemoHeader, TempSalesCrMemoLine, Currency, LineAmounts); + InsertVATAmounts(TempSalesCrMemoLine, LineVATAmount, LineAmount, LineDiscAmount, SalesCrMemoHeader."Prices Including VAT", Currency); + InsertHeaderData(RootXMLNode, SalesCrMemoHeader); + InsertSupplyChainTradeTransaction(RootXMLNode, SalesCrMemoHeader, TempSalesCrMemoLine, CurrencyCode, Currency, LineAmount, LineVATAmount, LineAmounts, LineDiscAmount); + OnCreateXMLOnBeforeSalesCrMemoXmlDocumentWriteToFile(XMLDoc, SalesCrMemoHeader); + XMLDoc.WriteTo(XMLDocText); + FileOutstream.WriteText(XMLDocText); + Clear(XMLDoc); + end; + local procedure DocumentLinesExist(SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesInvLine: Record "Sales Invoice Line"): Boolean begin SalesInvLine.SetRange("Document No.", SalesInvoiceHeader."No."); @@ -573,13 +739,13 @@ codeunit 13917 "Export ZUGFeRD Document" InsertPaymentTerms(SettlementElement, SalesInvHeader."Payment Terms Code", SalesInvHeader."Due Date"); MonetarySummationElement := XmlElement.Create('SpecifiedTradeSettlementHeaderMonetarySummation', XmlNamespaceRAM); - MonetarySummationElement.Add(XmlElement.Create('LineTotalAmount', XmlNamespaceRAM, FormatDecimal(SalesInvHeader.Amount + LineAmounts.Get(SalesInvLine.FieldName("Inv. Discount Amount"))))); + MonetarySummationElement.Add(XmlElement.Create('LineTotalAmount', XmlNamespaceRAM, FormatDecimal(SalesInvLine.Amount + LineAmounts.Get(SalesInvLine.FieldName("Inv. Discount Amount"))))); MonetarySummationElement.Add(XmlElement.Create('AllowanceTotalAmount', XmlNamespaceRAM, FormatDecimal(LineAmounts.Get(SalesInvLine.FieldName("Inv. Discount Amount"))))); - MonetarySummationElement.Add(XmlElement.Create('TaxBasisTotalAmount', XmlNamespaceRAM, FormatDecimal(SalesInvHeader.Amount))); - MonetarySummationElement.Add(XmlElement.Create('TaxTotalAmount', XmlNamespaceRAM, XmlAttribute.Create('currencyID', CurrencyCode), FormatDecimal(SalesInvHeader."Amount Including VAT" - SalesInvHeader.Amount))); - MonetarySummationElement.Add(XmlElement.Create('GrandTotalAmount', XmlNamespaceRAM, FormatDecimal(SalesInvHeader."Amount Including VAT"))); + MonetarySummationElement.Add(XmlElement.Create('TaxBasisTotalAmount', XmlNamespaceRAM, FormatDecimal(SalesInvLine.Amount))); + MonetarySummationElement.Add(XmlElement.Create('TaxTotalAmount', XmlNamespaceRAM, XmlAttribute.Create('currencyID', CurrencyCode), FormatDecimal(SalesInvLine."Amount Including VAT" - SalesInvLine.Amount))); + MonetarySummationElement.Add(XmlElement.Create('GrandTotalAmount', XmlNamespaceRAM, FormatDecimal(SalesInvLine."Amount Including VAT"))); MonetarySummationElement.Add(XmlElement.Create('TotalPrepaidAmount', XmlNamespaceRAM, FormatDecimal(0))); - MonetarySummationElement.Add(XmlElement.Create('DuePayableAmount', XmlNamespaceRAM, FormatDecimal(SalesInvHeader."Amount Including VAT"))); + MonetarySummationElement.Add(XmlElement.Create('DuePayableAmount', XmlNamespaceRAM, FormatDecimal(SalesInvLine."Amount Including VAT"))); SettlementElement.Add(MonetarySummationElement); RootXMLNode.Add(SettlementElement); @@ -598,13 +764,13 @@ codeunit 13917 "Export ZUGFeRD Document" InsertPaymentTerms(SettlementElement, SalesCrMemoHeader."Payment Terms Code", SalesCrMemoHeader."Due Date"); MonetarySummationElement := XmlElement.Create('SpecifiedTradeSettlementHeaderMonetarySummation', XmlNamespaceRAM); - MonetarySummationElement.Add(XmlElement.Create('LineTotalAmount', XmlNamespaceRAM, FormatDecimal(SalesCrMemoHeader.Amount + LineAmounts.Get(SalesCrMemoLine.FieldName("Inv. Discount Amount"))))); + MonetarySummationElement.Add(XmlElement.Create('LineTotalAmount', XmlNamespaceRAM, FormatDecimal(SalesCrMemoLine.Amount + LineAmounts.Get(SalesCrMemoLine.FieldName("Inv. Discount Amount"))))); MonetarySummationElement.Add(XmlElement.Create('AllowanceTotalAmount', XmlNamespaceRAM, FormatDecimal(LineAmounts.Get(SalesCrMemoLine.FieldName("Inv. Discount Amount"))))); - MonetarySummationElement.Add(XmlElement.Create('TaxBasisTotalAmount', XmlNamespaceRAM, FormatDecimal(SalesCrMemoHeader.Amount))); - MonetarySummationElement.Add(XmlElement.Create('TaxTotalAmount', XmlNamespaceRAM, XmlAttribute.Create('currencyID', CurrencyCode), FormatDecimal(SalesCrMemoHeader."Amount Including VAT" - SalesCrMemoHeader.Amount))); - MonetarySummationElement.Add(XmlElement.Create('GrandTotalAmount', XmlNamespaceRAM, FormatDecimal(SalesCrMemoHeader."Amount Including VAT"))); + MonetarySummationElement.Add(XmlElement.Create('TaxBasisTotalAmount', XmlNamespaceRAM, FormatDecimal(SalesCrMemoLine.Amount))); + MonetarySummationElement.Add(XmlElement.Create('TaxTotalAmount', XmlNamespaceRAM, XmlAttribute.Create('currencyID', CurrencyCode), FormatDecimal(SalesCrMemoLine."Amount Including VAT" - SalesCrMemoLine.Amount))); + MonetarySummationElement.Add(XmlElement.Create('GrandTotalAmount', XmlNamespaceRAM, FormatDecimal(SalesCrMemoLine."Amount Including VAT"))); MonetarySummationElement.Add(XmlElement.Create('TotalPrepaidAmount', XmlNamespaceRAM, FormatDecimal(0))); - MonetarySummationElement.Add(XmlElement.Create('DuePayableAmount', XmlNamespaceRAM, FormatDecimal(SalesCrMemoHeader."Amount Including VAT"))); + MonetarySummationElement.Add(XmlElement.Create('DuePayableAmount', XmlNamespaceRAM, FormatDecimal(SalesCrMemoLine."Amount Including VAT"))); SettlementElement.Add(MonetarySummationElement); RootXMLNode.Add(SettlementElement); @@ -682,7 +848,7 @@ codeunit 13917 "Export ZUGFeRD Document" until SalesInvoiceLine.Next() = 0; InsertApplicableHeaderTradeAgreement(SupplyChainTradeTransactionElement, SalesInvoiceHeader); InsertApplicableHeaderTradeDelivery(SupplyChainTradeTransactionElement, SalesInvoiceHeader); - SalesInvoiceHeader.CalcFields("Amount Including VAT", Amount); + SalesInvoiceLine.CalcSums(Amount, "Amount Including VAT"); InsertApplicableHeaderTradeSettlement(SupplyChainTradeTransactionElement, SalesInvoiceHeader, SalesInvoiceLine, CurrencyCode, LineAmount, LineVATAmount, LineAmounts, LineDiscAmount); RootXMLNode.Add(SupplyChainTradeTransactionElement); @@ -783,7 +949,7 @@ codeunit 13917 "Export ZUGFeRD Document" until SalesCrMemoLine.Next() = 0; InsertApplicableHeaderTradeAgreement(SupplyChainTradeTransactionElement, SalesCrMemoHeader); InsertApplicableHeaderTradeDelivery(SupplyChainTradeTransactionElement, SalesCrMemoHeader); - SalesCrMemoHeader.CalcFields("Amount Including VAT", Amount); + SalesCrMemoLine.CalcSums(Amount, "Amount Including VAT"); InsertApplicableHeaderTradeSettlement(SupplyChainTradeTransactionElement, SalesCrMemoHeader, SalesCrMemoLine, CurrencyCode, LineAmount, LineVATAmount, LineAmounts, LineDiscAmount); RootXMLNode.Add(SupplyChainTradeTransactionElement); @@ -1267,6 +1433,16 @@ codeunit 13917 "Export ZUGFeRD Document" begin end; + [IntegrationEvent(false, false)] + local procedure OnBeforeGenerateServiceInvoicePDFAttachment(ServiceInvoiceHeader: Record "Service Invoice Header"; var TempBlob: Codeunit "Temp Blob"; var IsHandled: Boolean) + begin + end; + + [IntegrationEvent(false, false)] + local procedure OnBeforeGenerateServiceCrMemoPDFAttachment(ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var TempBlob: Codeunit "Temp Blob"; var IsHandled: Boolean) + begin + end; + [IntegrationEvent(false, false)] local procedure OnAfterGetSetups(var CompanyInformation: Record "Company Information"; var GeneralLedgerSetup: Record "General Ledger Setup") begin diff --git a/Apps/DE/EDocumentDE/app/src/ZUGFeRD/PostedSalesInvoice.ReportExt.al b/Apps/DE/EDocumentDE/app/src/ZUGFeRD/PostedSalesInvoice.ReportExt.al index a2a27eaef7..726811d572 100644 --- a/Apps/DE/EDocumentDE/app/src/ZUGFeRD/PostedSalesInvoice.ReportExt.al +++ b/Apps/DE/EDocumentDE/app/src/ZUGFeRD/PostedSalesInvoice.ReportExt.al @@ -5,7 +5,6 @@ namespace Microsoft.eServices.EDocument.Formats; using Microsoft.Sales.History; - reportextension 13918 "Posted Sales Invoice" extends "Standard Sales - Invoice" { trigger OnPreRendering(var RenderingPayload: JsonObject) diff --git a/Apps/DE/EDocumentDE/app/src/ZUGFeRD/PostedServiceCrMemo.ReportExt.al b/Apps/DE/EDocumentDE/app/src/ZUGFeRD/PostedServiceCrMemo.ReportExt.al new file mode 100644 index 0000000000..81ab844e17 --- /dev/null +++ b/Apps/DE/EDocumentDE/app/src/ZUGFeRD/PostedServiceCrMemo.ReportExt.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// 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.Formats; + +using Microsoft.Service.History; + +reportextension 13921 "Posted Service Cr. Memo" extends "Service - Credit Memo" +{ + + trigger OnPreRendering(var RenderingPayload: JsonObject) + begin + AddXMLAttachmentforZUGFeRDExport(RenderingPayload); + end; + + local procedure AddXMLAttachmentforZUGFeRDExport(var RenderingPayload: JsonObject) + var + ExportZUGFeRDDocument: Codeunit "Export ZUGFeRD Document"; + begin + if CurrReport.TargetFormat() <> ReportFormat::PDF then + exit; + + if not ExportZUGFeRDDocument.IsZUGFeRDPrintProcess() then + exit; + + ExportZUGFeRDDocument.CreateAndAddXMLAttachmentToRenderingPayload("Service Cr.Memo Header", RenderingPayload); + end; +} diff --git a/Apps/DE/EDocumentDE/app/src/ZUGFeRD/PostedServiceInvoice.ReportExt.al b/Apps/DE/EDocumentDE/app/src/ZUGFeRD/PostedServiceInvoice.ReportExt.al new file mode 100644 index 0000000000..989f2d33dd --- /dev/null +++ b/Apps/DE/EDocumentDE/app/src/ZUGFeRD/PostedServiceInvoice.ReportExt.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// 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.Formats; + +using Microsoft.Service.History; + +reportextension 13920 "Posted Service Invoice" extends "Service - Invoice" +{ + + trigger OnPreRendering(var RenderingPayload: JsonObject) + begin + AddXMLAttachmentforZUGFeRDExport(RenderingPayload); + end; + + local procedure AddXMLAttachmentforZUGFeRDExport(var RenderingPayload: JsonObject) + var + ExportZUGFeRDDocument: Codeunit "Export ZUGFeRD Document"; + begin + if CurrReport.TargetFormat() <> ReportFormat::PDF then + exit; + + if not ExportZUGFeRDDocument.IsZUGFeRDPrintProcess() then + exit; + + ExportZUGFeRDDocument.CreateAndAddXMLAttachmentToRenderingPayload("Service Invoice Header", RenderingPayload); + end; +} diff --git a/Apps/DE/EDocumentDE/app/src/ZUGFeRD/ZUGFeRDFormat.Codeunit.al b/Apps/DE/EDocumentDE/app/src/ZUGFeRD/ZUGFeRDFormat.Codeunit.al index 018dfd4f31..59e3b0aeff 100644 --- a/Apps/DE/EDocumentDE/app/src/ZUGFeRD/ZUGFeRDFormat.Codeunit.al +++ b/Apps/DE/EDocumentDE/app/src/ZUGFeRD/ZUGFeRDFormat.Codeunit.al @@ -102,6 +102,15 @@ codeunit 13920 "ZUGFeRD Format" implements "E-Document" EDocServiceSupportedType."Source Document Type" := EDocServiceSupportedType."Source Document Type"::"Purchase Credit Memo"; EDocServiceSupportedType.Insert(); + + EDocServiceSupportedType."Source Document Type" := EDocServiceSupportedType."Source Document Type"::"Service Invoice"; + EDocServiceSupportedType.Insert(); + + EDocServiceSupportedType."Source Document Type" := EDocServiceSupportedType."Source Document Type"::"Service Credit Memo"; + EDocServiceSupportedType.Insert(); + + EDocServiceSupportedType."Source Document Type" := EDocServiceSupportedType."Source Document Type"::"Service Order"; + EDocServiceSupportedType.Insert(); end; [EventSubscriber(ObjectType::Table, Database::"E-Document Log", OnBeforeExportDataStorage, '', false, false)] diff --git a/Apps/DE/EDocumentDE/test/src/XRechnungXMLDocumentTests.Codeunit.al b/Apps/DE/EDocumentDE/test/src/XRechnungXMLDocumentTests.Codeunit.al index 03b0924e35..b550cc5f52 100644 --- a/Apps/DE/EDocumentDE/test/src/XRechnungXMLDocumentTests.Codeunit.al +++ b/Apps/DE/EDocumentDE/test/src/XRechnungXMLDocumentTests.Codeunit.al @@ -18,6 +18,9 @@ using Microsoft.Purchases.Vendor; using Microsoft.Sales.Customer; using Microsoft.Sales.Document; using Microsoft.Sales.History; +using Microsoft.Service.Document; +using Microsoft.Service.History; +using Microsoft.Service.Test; using System.IO; using System.Utilities; @@ -38,6 +41,7 @@ codeunit 13918 "XRechnung XML Document Tests" LibraryTestInitialize: Codeunit "Library - Test Initialize"; LibraryPurchase: Codeunit "Library - Purchase"; LibrarySales: Codeunit "Library - Sales"; + LibraryService: Codeunit "Library - Service"; LibraryInventory: Codeunit "Library - Inventory"; LibraryRandom: Codeunit "Library - Random"; LibraryERM: Codeunit "Library - ERM"; @@ -289,84 +293,326 @@ codeunit 13918 "XRechnung XML Document Tests" end; [Test] - procedure ExportPostedSalesInvoiceInXRechnungFormatVerifyInvoiceWithInvoiceDiscounts(); + procedure ExportPostedSalesInvoiceInXRechnungFormatVerifyPDFEmbeddedToXML() var SalesInvoiceHeader: Record "Sales Invoice Header"; TempXMLBuffer: Record "XML Buffer" temporary; begin - // [SCENARIO 575895] Export posted sales invoice creates electronic document in XRechnung format with 2 invoice lines and invoice discount + // [SCENARIO] Export posted sales invoice creates electronic document in XRechnung format with embedded PDF Initialize(); - // [GIVEN] Create and Post Sales Invoice with invoice discount - SalesInvoiceHeader.Get(CreateAndPostSalesDocumentWithTwoLines("Sales Document Type"::Invoice, Enum::"Sales Line Type"::Item, true)); + // [GIVEN] Enable Embedding of PDF in export + SetEdocumentServiceEmbedPDFInExport(true); + + // [GIVEN] Create and Post Sales Invoice. + SalesInvoiceHeader.Get(CreateAndPostSalesDocument("Sales Document Type"::Invoice, Enum::"Sales Line Type"::Item, false)); // [WHEN] Export XRechnung Electronic Document. ExportInvoice(SalesInvoiceHeader, TempXMLBuffer); - // [THEN] XRechnung Electronic Document is created with 2 invoice lines and invoice discount - VerifyInvoiceWithInvDiscount(SalesInvoiceHeader, TempXMLBuffer); + // [THEN] PDF is embedded in the XML + VerifyInvoicePDFEmbeddedToXML(TempXMLBuffer); end; [Test] - procedure ExportPostedSalesInvoiceInXRechnungFormatVerifyInvoiceWithInvoiceDiscountsAndLineDiscount(); + procedure ExportPostedSalesInvoiceInXRechnungFormatVerifySellerAddressFromRespCenter(); var + ResponsibilityCenter: Record "Responsibility Center"; SalesInvoiceHeader: Record "Sales Invoice Header"; TempXMLBuffer: Record "XML Buffer" temporary; begin - // [SCENARIO 575895] Export posted sales invoice creates electronic document in XRechnung format with 2 invoice lines with discount and invoice discount + // [SCENARIO] Export posted sales invoice creates electronic document in XRechnung format with seller info from responsibility center Initialize(); - // [GIVEN] Create and Post Sales Invoice with invoice discount and line discount on one line - SalesInvoiceHeader.Get(CreateAndPostSalesDocumentWithTwoLinesLineDiscount("Sales Document Type"::Invoice, Enum::"Sales Line Type"::Item, true)); + // [GIVEN] Responsibility Center + CreateResponsibilityCenter(ResponsibilityCenter); + + // [GIVEN] Create and Post Sales Invoice. + SalesInvoiceHeader.Get(CreateAndPostSalesDocumentWithRespCenter("Sales Document Type"::Invoice, Enum::"Sales Line Type"::Item, ResponsibilityCenter.Code)); // [WHEN] Export XRechnung Electronic Document. ExportInvoice(SalesInvoiceHeader, TempXMLBuffer); - // [THEN] XRechnung Electronic Document is created with 2 invoice lines with line discount and invoice discount - VerifyInvoiceWithInvDiscount(SalesInvoiceHeader, TempXMLBuffer); - VerifyInvoiceLineWithDiscount(SalesInvoiceHeader, TempXMLBuffer); + // [THEN] XRechnung Electronic Document is created with company data as accounting supplier party + VerifyAccountingSupplierParty(TempXMLBuffer, '/ubl:Invoice/cac:AccountingSupplierParty/cac:Party', ResponsibilityCenter); end; + #endregion + #region ServiceInvoice [Test] - procedure ExportPostedSalesInvoiceInXRechnungFormatVerifyPDFEmbeddedToXML() + procedure ExportPostedServiceInvoiceInXRechnungFormatVerifyHeaderData(); var - SalesInvoiceHeader: Record "Sales Invoice Header"; + ServiceInvoiceHeader: Record "Service Invoice Header"; TempXMLBuffer: Record "XML Buffer" temporary; begin - // [SCENARIO] Export posted sales invoice creates electronic document in XRechnung format with embedded PDF + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in XRechnung format with header data from the document + Initialize(); + + // [GIVEN] Create and Post Service Invoice. + ServiceInvoiceHeader.Get(CreateAndPostServiceDocument()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created + VerifyHeaderData(ServiceInvoiceHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedServiceInvoiceInXRechnungFormatVerifyBuyerReferenceAsCustomerReference(); + var + Customer: Record Customer; + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in XRechnung format with customer reference + Initialize(); + + // [GIVEN] Set Buyer reference = customer reference + SetEdocumentServiceBuyerReference("E-Document Buyer Reference"::"Customer Reference"); + + // [GIVEN] Create and Post Service Invoice with Customer X, E-invoice routing no. = XY + ServiceInvoiceHeader.Get(CreateAndPostServiceDocument()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with buyer reference XY + Customer.Get(ServiceInvoiceHeader."Customer No."); + VerifyBuyerReference(Customer."E-Invoice Routing No.", TempXMLBuffer, '/ubl:Invoice'); + end; + + [Test] + procedure ExportPostedServiceInvoiceInXRechnungFormatVerifyBuyerReferenceAsYourReference(); + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in XRechnung format with your reference from the document + Initialize(); + + // [GIVEN] Set Buyer reference = your reference + SetEdocumentServiceBuyerReference("E-Document Buyer Reference"::"Your Reference"); + + // [GIVEN] Create and Post Service Invoice with your reference = XX + ServiceInvoiceHeader.Get(CreateAndPostServiceDocument()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with buyer reference XX + VerifyBuyerReference(ServiceInvoiceHeader."Your Reference", TempXMLBuffer, '/ubl:Invoice'); + end; + + [Test] + procedure ExportPostedServiceInvoiceInXRechnungFormatMandateBuyerReferenceAsYourReference(); + var + ServiceHeader: Record "Service Header"; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Mandate buyer reference as your reference when releasing service invoice for XRechnung format + Initialize(); + + // [GIVEN] Set Buyer reference = your reference + SetEdocumentServiceBuyerReference("E-Document Buyer Reference"::"Your Reference"); + + // [GIVEN] Create Service Invoice with your reference = XX + ServiceHeader.Get(ServiceHeader."Document Type"::Invoice, CreateServiceDocumentWithLine()); + + // [WHEN] Remove your reference + ServiceHeader.Validate("Your Reference", ''); + ServiceHeader.Modify(false); + + // [THEN] Error message is shown when releasing the service invoice + asserterror CheckServiceHeader(ServiceHeader); + end; + + [Test] + procedure ExportPostedServiceInvoiceInXRechnungFormatVerifyAccountingSupplierParty(); + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in XRechnung format with company data as accounting supplier party + Initialize(); + + // [GIVEN] Create and Post Service Invoice. + ServiceInvoiceHeader.Get(CreateAndPostServiceDocument()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with company data as accounting supplier party + VerifyAccountingSupplierParty(TempXMLBuffer, '/ubl:Invoice/cac:AccountingSupplierParty/cac:Party'); + end; + + [Test] + procedure ExportPostedServiceInvoiceInXRechnungFormatVerifyAccountingCustomerParty(); + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in XRechnung format with customer data as accounting customer party + Initialize(); + + // [GIVEN] Create and Post Service Invoice. + ServiceInvoiceHeader.Get(CreateAndPostServiceDocument()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with customer data as accounting customer party + VerifyAccountingCustomerParty(ServiceInvoiceHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedServiceInvoiceInXRechnungFormatVerifyPaymentMeans(); + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in XRechnung format with bank information as payment means + Initialize(); + + // [GIVEN] Create and Post Service Invoice. + ServiceInvoiceHeader.Get(CreateAndPostServiceDocument()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with bank information as payment means + VerifyPaymentMeans(TempXMLBuffer, '/ubl:Invoice/cac:PaymentMeans'); + end; + + [Test] + procedure ExportPostedServiceInvoiceInXRechnungFormatVerifyPaymentTerms(); + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in XRechnung format with payment terms + Initialize(); + + // [GIVEN] Create and Post Service Invoice. + ServiceInvoiceHeader.Get(CreateAndPostServiceDocument()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with payment terms + VerifyPaymentTerms(ServiceInvoiceHeader."Payment Terms Code", TempXMLBuffer, '/ubl:Invoice/cac:PaymentTerms'); + end; + + [Test] + procedure ExportPostedServiceInvoiceInXRechnungFormatVerifyTaxTotal(); + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in XRechnung format with different tax totals + Initialize(); + + // [GIVEN] Create and Post Service Invoice. + ServiceInvoiceHeader.Get(CreateAndPostServiceDocument()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with different tax totals + VerifyTaxTotals(ServiceInvoiceHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedServiceInvoiceInXRechnungFormatVerifyLegalMonetaryTotal(); + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in XRechnung format with document totals + Initialize(); + + // [GIVEN] Create and Post Service Invoice. + ServiceInvoiceHeader.Get(CreateAndPostServiceDocument()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with document totals + VerifyLegalMonetaryTotal(ServiceInvoiceHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedServiceInvoiceInXRechnungFormatVerifyInvoiceLine(); + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in XRechnung format with 2 invoice lines + Initialize(); + + // [GIVEN] Create and Post Service Invoice. + ServiceInvoiceHeader.Get(CreateAndPostServiceDocumentWithTwoLines()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with 2 invoice lines + VerifyServiceInvoiceLine(ServiceInvoiceHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedServiceInvoiceInXRechnungFormatVerifyPDFEmbeddedToXML() + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in XRechnung format with embedded PDF Initialize(); // [GIVEN] Enable Embedding of PDF in export SetEdocumentServiceEmbedPDFInExport(true); - // [GIVEN] Create and Post Sales Invoice. - SalesInvoiceHeader.Get(CreateAndPostSalesDocument("Sales Document Type"::Invoice, Enum::"Sales Line Type"::Item, false)); + // [GIVEN] Create and Post Service Invoice. + ServiceInvoiceHeader.Get(CreateAndPostServiceDocument()); // [WHEN] Export XRechnung Electronic Document. - ExportInvoice(SalesInvoiceHeader, TempXMLBuffer); + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); // [THEN] PDF is embedded in the XML VerifyInvoicePDFEmbeddedToXML(TempXMLBuffer); end; [Test] - procedure ExportPostedSalesInvoiceInXRechnungFormatVerifySellerAddressFromRespCenter(); + [HandlerFunctions('ConfirmHandlerYes')] + procedure ExportPostedServiceInvoiceInXRechnungFormatVerifySellerAddressFromRespCenter(); var ResponsibilityCenter: Record "Responsibility Center"; - SalesInvoiceHeader: Record "Sales Invoice Header"; + ServiceInvoiceHeader: Record "Service Invoice Header"; TempXMLBuffer: Record "XML Buffer" temporary; begin - // [SCENARIO] Export posted sales invoice creates electronic document in XRechnung format with seller info from responsibility center + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in XRechnung format with seller info from responsibility center Initialize(); // [GIVEN] Responsibility Center CreateResponsibilityCenter(ResponsibilityCenter); - // [GIVEN] Create and Post Sales Invoice. - SalesInvoiceHeader.Get(CreateAndPostSalesDocumentWithRespCenter("Sales Document Type"::Invoice, Enum::"Sales Line Type"::Item, ResponsibilityCenter.Code)); + // [GIVEN] Create and Post Service Invoice. + ServiceInvoiceHeader.Get(CreateAndPostServiceDocumentWithRespCenter(ResponsibilityCenter.Code)); // [WHEN] Export XRechnung Electronic Document. - ExportInvoice(SalesInvoiceHeader, TempXMLBuffer); + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); // [THEN] XRechnung Electronic Document is created with company data as accounting supplier party VerifyAccountingSupplierParty(TempXMLBuffer, '/ubl:Invoice/cac:AccountingSupplierParty/cac:Party', ResponsibilityCenter); @@ -595,90 +841,411 @@ codeunit 13918 "XRechnung XML Document Tests" end; [Test] - procedure ExportPostedSalesCrMemoInXRechnungFormatVerifyCrMemoWithInvoiceDiscounts(); + procedure ExportPostedSalesCrMemoInXRechnungFormatVerifyPDFEmbeddedToXML() var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; TempXMLBuffer: Record "XML Buffer" temporary; begin - // [SCENARIO 575895] Export posted sales cr. memo creates electronic document in XRechnung format with 2 lines and invoice discount + // [SCENARIO] Export posted sales cr. memo creates electronic document in XRechnung format with embedded PDF Initialize(); - // [GIVEN] Create and Post Sales Invoice with invoice discount - SalesCrMemoHeader.Get(CreateAndPostSalesDocumentWithTwoLines("Sales Document Type"::"Credit Memo", Enum::"Sales Line Type"::Item, true)); + // [GIVEN] Enable Embedding of PDF in export + SetEdocumentServiceEmbedPDFInExport(true); + + // [GIVEN] Create and Post Sales Cr. Memo. + SalesCrMemoHeader.Get(CreateAndPostSalesDocument("Sales Document Type"::"Credit Memo", Enum::"Sales Line Type"::Item, false)); // [WHEN] Export XRechnung Electronic Document. ExportCreditMemo(SalesCrMemoHeader, TempXMLBuffer); - // [THEN] XRechnung Electronic Document is created with 2 lines and invoice discount - VerifyCrMemoWithInvDiscount(SalesCrMemoHeader, TempXMLBuffer); + // [THEN] PDF is embedded in the XML + VerifyCrMemoPDFEmbeddedToXML(TempXMLBuffer); end; [Test] - procedure ExportPostedSalesCrMemoInXRechnungFormatVerifyCrMemoWithInvoiceDiscountsAndLineDiscount(); + procedure ExportPostedSalesCrMemoInXRechnungFormatVerifySellerAddressFromRespCenter(); var + ResponsibilityCenter: Record "Responsibility Center"; SalesCrMemoHeader: Record "Sales Cr.Memo Header"; TempXMLBuffer: Record "XML Buffer" temporary; begin - // [SCENARIO 575895] Export posted sales cr.memo creates electronic document in XRechnung format with 2 cr.memo lines with discount and invoice discount + // [SCENARIO] Export posted sales credit memo creates electronic document in XRechnung format with seller info from responsibility center Initialize(); - // [GIVEN] Create and Post Sales Cr. Memo with invoice discount and line discount on one line - SalesCrMemoHeader.Get(CreateAndPostSalesDocumentWithTwoLinesLineDiscount("Sales Document Type"::"Credit Memo", Enum::"Sales Line Type"::Item, true)); + // [GIVEN] Responsibility Center + CreateResponsibilityCenter(ResponsibilityCenter); + + // [GIVEN] Create and Post Sales Invoice. + SalesCrMemoHeader.Get(CreateAndPostSalesDocumentWithRespCenter("Sales Document Type"::"Credit Memo", Enum::"Sales Line Type"::Item, ResponsibilityCenter.Code)); // [WHEN] Export XRechnung Electronic Document. ExportCreditMemo(SalesCrMemoHeader, TempXMLBuffer); - // [THEN] XRechnung Electronic Document is created with 2 lines with line discount and invoice discount - VerifyCrMemoWithInvDiscount(SalesCrMemoHeader, TempXMLBuffer); - VerifyCrMemoLineWithDiscounts(SalesCrMemoHeader, TempXMLBuffer); + // [THEN] XRechnung Electronic Document is created with company data as accounting supplier party + VerifyAccountingSupplierParty(TempXMLBuffer, '/ns0:CreditNote/cac:AccountingSupplierParty/cac:Party', ResponsibilityCenter); end; + #endregion + #region ServiceCreditMemo [Test] - procedure ExportPostedSalesCrMemoInXRechnungFormatVerifyPDFEmbeddedToXML() + procedure ExportPostedServiceCrMemoInXRechnungFormatVerifyHeaderData(); var - SalesCrMemoHeader: Record "Sales Cr.Memo Header"; + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; TempXMLBuffer: Record "XML Buffer" temporary; begin - // [SCENARIO] Export posted sales cr. memo creates electronic document in XRechnung format with embedded PDF + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in XRechnung format with header data from the document + Initialize(); + + // [GIVEN] Create and Post service cr. memo. + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocument()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created + VerifyHeaderData(ServiceCrMemoHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedServiceCrMemoInXRechnungFormatVerifyBuyerReferenceAsCustomerReference(); + var + Customer: Record Customer; + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in XRechnung format with customer reference + Initialize(); + + // [GIVEN] Set Buyer reference = customer reference + SetEdocumentServiceBuyerReference("E-Document Buyer Reference"::"Customer Reference"); + + // [GIVEN] Create and Post service cr. memo with Customer X, E-invoice routing no. = XY + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocument()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with buyer reference XY + Customer.Get(ServiceCrMemoHeader."Customer No."); + VerifyBuyerReference(Customer."E-Invoice Routing No.", TempXMLBuffer, '/ns0:CreditNote'); + end; + + [Test] + procedure ExportPostedServiceCrMemoInXRechnungFormatVerifyBuyerReferenceAsYourReference(); + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in XRechnung format with your reference from the document + Initialize(); + + // [GIVEN] Set Buyer reference = your reference + SetEdocumentServiceBuyerReference("E-Document Buyer Reference"::"Your Reference"); + + // [GIVEN] Create and Post service cr. memo with your reference = XX + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocument()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with buyer reference XX + VerifyBuyerReference(ServiceCrMemoHeader."Your Reference", TempXMLBuffer, '/ns0:CreditNote'); + end; + + [Test] + procedure ExportPostedServiceCrMemoInXRechnungFormatMandateBuyerReferenceAsYourReference(); + var + ServiceHeader: Record "Service Header"; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Mandate buyer reference as your reference when releasing service credit memo for XRechnung format + Initialize(); + + // [GIVEN] Set Buyer reference = your reference + SetEdocumentServiceBuyerReference("E-Document Buyer Reference"::"Your Reference"); + + // [GIVEN] Create Service Credit Memo with your reference = XX + ServiceHeader.Get(ServiceHeader."Document Type"::"Credit Memo", CreateServiceCrMemoDocumentWithLine()); + + // [WHEN] Remove your reference + ServiceHeader.Validate("Your Reference", ''); + ServiceHeader.Modify(false); + + // [THEN] Error message is shown when releasing the service credit memo + asserterror CheckServiceHeader(ServiceHeader); + end; + + [Test] + procedure ExportPostedServiceCrMemoInXRechnungFormatVerifyAccountingSupplierParty(); + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in XRechnung format with company data as accounting supplier party + Initialize(); + + // [GIVEN] Create and Post service cr. memo. + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocument()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with company data as accounting supplier party + VerifyAccountingSupplierParty(TempXMLBuffer, '/ns0:CreditNote/cac:AccountingSupplierParty/cac:Party'); + end; + + [Test] + procedure ExportPostedServiceCrMemoInXRechnungFormatVerifyAccountingCustomerParty(); + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in XRechnung format with customer data as accounting customer party + Initialize(); + + // [GIVEN] Create and Post service cr. memo. + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocument()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with customer data as accounting customer party + VerifyAccountingCustomerParty(ServiceCrMemoHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedServiceCrMemoInXRechnungFormatVerifyPaymentMeans(); + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in XRechnung format with bank information as payment means + Initialize(); + + // [GIVEN] Create and Post service cr. memo. + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocument()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with bank information as payment means + VerifyPaymentMeans(TempXMLBuffer, '/ns0:CreditNote/cac:PaymentMeans'); + end; + + [Test] + procedure ExportPostedServiceCrMemoInXRechnungFormatVerifyPaymentTerms(); + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in XRechnung format with payment terms + Initialize(); + + // [GIVEN] Create and Post service cr. memo. + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocument()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with payment terms + VerifyPaymentTerms(ServiceCrMemoHeader."Payment Terms Code", TempXMLBuffer, '/ns0:CreditNote/cac:PaymentTerms'); + end; + + [Test] + procedure ExportPostedServiceCrMemoInXRechnungFormatVerifyTaxTotal(); + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in XRechnung format with different tax totals + Initialize(); + + // [GIVEN] Create and Post service cr. memo. + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocument()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with different tax totals + VerifyTaxTotals(ServiceCrMemoHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedServiceCrMemoInXRechnungFormatVerifyLegalMonetaryTotal(); + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in XRechnung format with document totals + Initialize(); + + // [GIVEN] Create and Post service cr. memo. + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocument()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with document totals + VerifyLegalMonetaryTotal(ServiceCrMemoHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedServiceCrMemoInXRechnungFormatVerifyCrMemoLine(); + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in XRechnung format with 2 cr.memo lines + Initialize(); + + // [GIVEN] Create and Post service cr. memo. + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocumentWithTwoLines()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with 2 cr.memo lines + VerifyServiceCrMemoLine(ServiceCrMemoHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedServiceCrMemoInXRechnungFormatVerifyPDFEmbeddedToXML() + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in XRechnung format with embedded PDF Initialize(); // [GIVEN] Enable Embedding of PDF in export SetEdocumentServiceEmbedPDFInExport(true); - // [GIVEN] Create and Post Sales Cr. Memo. - SalesCrMemoHeader.Get(CreateAndPostSalesDocument("Sales Document Type"::"Credit Memo", Enum::"Sales Line Type"::Item, false)); + // [GIVEN] Create and Post Service Cr. Memo. + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocument()); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] PDF is embedded in the XML + VerifyCrMemoPDFEmbeddedToXML(TempXMLBuffer); + end; + + [Test] + [HandlerFunctions('ConfirmHandlerYes')] + procedure ExportPostedServiceCrMemoInXRechnungFormatVerifySellerAddressFromRespCenter(); + var + ResponsibilityCenter: Record "Responsibility Center"; + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service credit memo creates electronic document in XRechnung format with seller info from responsibility center + Initialize(); + + // [GIVEN] Responsibility Center + CreateResponsibilityCenter(ResponsibilityCenter); + + // [GIVEN] Create and Post Service Credit Memo. + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocumentWithRespCenter(ResponsibilityCenter.Code)); + + // [WHEN] Export XRechnung Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with company data as accounting supplier party + VerifyAccountingSupplierParty(TempXMLBuffer, '/ns0:CreditNote/cac:AccountingSupplierParty/cac:Party', ResponsibilityCenter); + end; + #endregion + + #region InvoiceDiscount + [Test] + procedure ExportPostedSalesInvoiceInXRechnungFormatVerifyInvoiceWithInvoiceDiscounts(); + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [SCENARIO 575895] Export posted sales invoice creates electronic document in XRechnung format with 2 invoice lines and invoice discount + Initialize(); + + // [GIVEN] Create and Post Sales Invoice with invoice discount + SalesInvoiceHeader.Get(CreateAndPostSalesDocumentWithTwoLines("Sales Document Type"::Invoice, Enum::"Sales Line Type"::Item, true)); + + // [WHEN] Export XRechnung Electronic Document. + ExportInvoice(SalesInvoiceHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with 2 invoice lines and invoice discount + VerifyInvoiceWithInvDiscount(SalesInvoiceHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedSalesInvoiceInXRechnungFormatVerifyInvoiceWithInvoiceDiscountsAndLineDiscount(); + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [SCENARIO 575895] Export posted sales invoice creates electronic document in XRechnung format with 2 invoice lines with discount and invoice discount + Initialize(); + + // [GIVEN] Create and Post Sales Invoice with invoice discount and line discount on one line + SalesInvoiceHeader.Get(CreateAndPostSalesDocumentWithTwoLinesLineDiscount("Sales Document Type"::Invoice, Enum::"Sales Line Type"::Item, true)); + + // [WHEN] Export XRechnung Electronic Document. + ExportInvoice(SalesInvoiceHeader, TempXMLBuffer); + + // [THEN] XRechnung Electronic Document is created with 2 invoice lines with line discount and invoice discount + VerifyInvoiceWithInvDiscount(SalesInvoiceHeader, TempXMLBuffer); + VerifyInvoiceLineWithDiscount(SalesInvoiceHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedSalesCrMemoInXRechnungFormatVerifyCrMemoWithInvoiceDiscounts(); + var + SalesCrMemoHeader: Record "Sales Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [SCENARIO 575895] Export posted sales cr. memo creates electronic document in XRechnung format with 2 lines and invoice discount + Initialize(); + + // [GIVEN] Create and Post Sales Invoice with invoice discount + SalesCrMemoHeader.Get(CreateAndPostSalesDocumentWithTwoLines("Sales Document Type"::"Credit Memo", Enum::"Sales Line Type"::Item, true)); // [WHEN] Export XRechnung Electronic Document. ExportCreditMemo(SalesCrMemoHeader, TempXMLBuffer); - // [THEN] PDF is embedded in the XML - VerifyCrMemoPDFEmbeddedToXML(TempXMLBuffer); + // [THEN] XRechnung Electronic Document is created with 2 lines and invoice discount + VerifyCrMemoWithInvDiscount(SalesCrMemoHeader, TempXMLBuffer); end; [Test] - procedure ExportPostedSalesCrMemoInXRechnungFormatVerifySellerAddressFromRespCenter(); + procedure ExportPostedSalesCrMemoInXRechnungFormatVerifyCrMemoWithInvoiceDiscountsAndLineDiscount(); var - ResponsibilityCenter: Record "Responsibility Center"; SalesCrMemoHeader: Record "Sales Cr.Memo Header"; TempXMLBuffer: Record "XML Buffer" temporary; begin - // [SCENARIO] Export posted sales credit memo creates electronic document in XRechnung format with seller info from responsibility center + // [SCENARIO 575895] Export posted sales cr.memo creates electronic document in XRechnung format with 2 cr.memo lines with discount and invoice discount Initialize(); - // [GIVEN] Responsibility Center - CreateResponsibilityCenter(ResponsibilityCenter); - - // [GIVEN] Create and Post Sales Invoice. - SalesCrMemoHeader.Get(CreateAndPostSalesDocumentWithRespCenter("Sales Document Type"::"Credit Memo", Enum::"Sales Line Type"::Item, ResponsibilityCenter.Code)); + // [GIVEN] Create and Post Sales Cr. Memo with invoice discount and line discount on one line + SalesCrMemoHeader.Get(CreateAndPostSalesDocumentWithTwoLinesLineDiscount("Sales Document Type"::"Credit Memo", Enum::"Sales Line Type"::Item, true)); // [WHEN] Export XRechnung Electronic Document. ExportCreditMemo(SalesCrMemoHeader, TempXMLBuffer); - // [THEN] XRechnung Electronic Document is created with company data as accounting supplier party - VerifyAccountingSupplierParty(TempXMLBuffer, '/ns0:CreditNote/cac:AccountingSupplierParty/cac:Party', ResponsibilityCenter); + // [THEN] XRechnung Electronic Document is created with 2 lines with line discount and invoice discount + VerifyCrMemoWithInvDiscount(SalesCrMemoHeader, TempXMLBuffer); + VerifyCrMemoLineWithDiscounts(SalesCrMemoHeader, TempXMLBuffer); end; #endregion - #region PurchaseInvoice [Test] procedure ReleasePurchaseInvoiceInXRechnungFormat(); @@ -727,6 +1294,76 @@ codeunit 13918 "XRechnung XML Document Tests" exit(LibrarySales.PostSalesDocument(SalesHeader, true, true)); end; + local procedure CreateAndPostServiceDocument(): Code[20]; + var + ServiceHeader: Record "Service Header"; + begin + ServiceHeader.Get(ServiceHeader."Document Type"::Invoice, CreateServiceDocumentWithLine()); + exit(PostServiceDocument(ServiceHeader)); + end; + + local procedure CreateAndPostServiceDocumentWithTwoLines(): Code[20]; + var + ServiceHeader: Record "Service Header"; + begin + ServiceHeader.Get(ServiceHeader."Document Type"::Invoice, CreateServiceDocumentWithTwoLines()); + exit(PostServiceDocument(ServiceHeader)); + end; + + local procedure CreateAndPostServiceDocumentWithRespCenter(RespCenterCode: Code[10]): Code[20]; + var + ServiceHeader: Record "Service Header"; + begin + ServiceHeader.Get(ServiceHeader."Document Type"::Invoice, CreateServiceDocumentWithLine()); + ServiceHeader.Validate("Responsibility Center", RespCenterCode); + ServiceHeader.Modify(true); + exit(PostServiceDocument(ServiceHeader)); + end; + + local procedure PostServiceDocument(var ServiceHeader: Record "Service Header"): Code[20] + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + begin + LibraryService.PostServiceOrder(ServiceHeader, true, false, true); + ServiceInvoiceHeader.FindLast(); + exit(ServiceInvoiceHeader."No."); + end; + + local procedure CreateAndPostServiceCrMemoDocument(): Code[20] + var + ServiceHeader: Record "Service Header"; + begin + ServiceHeader.Get(ServiceHeader."Document Type"::"Credit Memo", CreateServiceCrMemoDocumentWithLine()); + exit(PostServiceCrMemoDocument(ServiceHeader)); + end; + + local procedure CreateAndPostServiceCrMemoDocumentWithTwoLines(): Code[20] + var + ServiceHeader: Record "Service Header"; + begin + ServiceHeader.Get(ServiceHeader."Document Type"::"Credit Memo", CreateServiceCrMemoDocumentWithTwoLines()); + exit(PostServiceCrMemoDocument(ServiceHeader)); + end; + + local procedure CreateAndPostServiceCrMemoDocumentWithRespCenter(RespCenterCode: Code[10]): Code[20] + var + ServiceHeader: Record "Service Header"; + begin + ServiceHeader.Get(ServiceHeader."Document Type"::"Credit Memo", CreateServiceCrMemoDocumentWithLine()); + ServiceHeader.Validate("Responsibility Center", RespCenterCode); + ServiceHeader.Modify(true); + exit(PostServiceCrMemoDocument(ServiceHeader)); + end; + + local procedure PostServiceCrMemoDocument(var ServiceHeader: Record "Service Header"): Code[20] + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + begin + LibraryService.PostServiceOrder(ServiceHeader, true, false, true); + ServiceCrMemoHeader.FindLast(); + exit(ServiceCrMemoHeader."No."); + end; + local procedure CreateAndPostSalesDocumentWithTwoLines(DocumentType: Enum "Sales Document Type"; LineType: Enum "Sales Line Type"; InvoiceDiscount: Boolean): Code[20]; var SalesHeader: Record "Sales Header"; @@ -893,6 +1530,105 @@ codeunit 13918 "XRechnung XML Document Tests" SalesLine.Modify(true); end; + local procedure CreateServiceDocumentWithLine(): Code[20] + var + ServiceHeader: Record "Service Header"; + begin + CreateServiceHeader(ServiceHeader); + CreateServiceLine(ServiceHeader); + exit(ServiceHeader."No."); + end; + + local procedure CreateServiceDocumentWithTwoLines(): Code[20] + var + ServiceHeader: Record "Service Header"; + begin + CreateServiceHeader(ServiceHeader); + CreateServiceLine(ServiceHeader); + CreateServiceLine(ServiceHeader); + exit(ServiceHeader."No."); + end; + + local procedure CreateServiceHeader(var ServiceHeader: Record "Service Header") + var + PostCode: Record "Post Code"; + PaymentTermsCode: Code[10]; + begin + LibraryERM.FindPostCode(PostCode); + PaymentTermsCode := LibraryERM.FindPaymentTermsCode(); + LibraryService.CreateServiceHeader(ServiceHeader, ServiceHeader."Document Type"::Invoice, CreateCustomer()); + ServiceHeader.Validate("Bill-to Address", LibraryUtility.GenerateGUID()); + ServiceHeader.Validate("Bill-to City", PostCode.City); + ServiceHeader.Validate("Ship-to Address", LibraryUtility.GenerateGUID()); + ServiceHeader.Validate("Ship-to City", PostCode.City); + ServiceHeader.Validate(Address, LibraryUtility.GenerateGUID()); + ServiceHeader.Validate(City, PostCode.City); + ServiceHeader.Validate("Your Reference", LibraryUtility.GenerateRandomText(20)); + ServiceHeader.Validate("Payment Terms Code", PaymentTermsCode); + ServiceHeader.Modify(true); + end; + + local procedure CreateServiceLine(ServiceHeader: Record "Service Header") + var + ServiceLine: Record "Service Line"; + UnitOfMeasure: Record "Unit of Measure"; + begin + LibraryInventory.CreateUnitOfMeasureCode(UnitOfMeasure); + UnitOfMeasure."International Standard Code" := LibraryUtility.GenerateGUID(); + UnitOfMeasure.Modify(true); + LibraryService.CreateServiceLine(ServiceLine, ServiceHeader, ServiceLine.Type::Item, LibraryInventory.CreateItemNo()); + ServiceLine.Validate(Quantity, LibraryRandom.RandDecInRange(10, 20, 2)); + ServiceLine.Validate("Unit Price", LibraryRandom.RandDecInRange(100, 200, 2)); + ServiceLine.Validate("Unit of Measure", UnitOfMeasure.Code); + ServiceLine.Modify(true); + end; + + local procedure CreateServiceCrMemoDocumentWithLine(): Code[20] + var + ServiceHeader: Record "Service Header"; + begin + CreateServiceCrMemoHeader(ServiceHeader); + CreateServiceLine(ServiceHeader); + exit(ServiceHeader."No."); + end; + + local procedure CreateServiceCrMemoDocumentWithTwoLines(): Code[20] + var + ServiceHeader: Record "Service Header"; + begin + CreateServiceCrMemoHeader(ServiceHeader); + CreateServiceLine(ServiceHeader); + CreateServiceLine(ServiceHeader); + exit(ServiceHeader."No."); + end; + + local procedure CreateServiceCrMemoHeader(var ServiceHeader: Record "Service Header") + var + PostCode: Record "Post Code"; + PaymentTermsCode: Code[10]; + begin + LibraryERM.FindPostCode(PostCode); + PaymentTermsCode := LibraryERM.FindPaymentTermsCode(); + LibraryService.CreateServiceHeader(ServiceHeader, ServiceHeader."Document Type"::"Credit Memo", CreateCustomer()); + ServiceHeader.Validate("Bill-to Address", LibraryUtility.GenerateGUID()); + ServiceHeader.Validate("Bill-to City", PostCode.City); + ServiceHeader.Validate("Ship-to Address", LibraryUtility.GenerateGUID()); + ServiceHeader.Validate("Ship-to City", PostCode.City); + ServiceHeader.Validate(Address, LibraryUtility.GenerateGUID()); + ServiceHeader.Validate(City, PostCode.City); + ServiceHeader.Validate("Your Reference", LibraryUtility.GenerateRandomText(20)); + ServiceHeader.Validate("Payment Terms Code", PaymentTermsCode); + ServiceHeader.Modify(true); + end; + + local procedure CheckServiceHeader(ServiceHeader: Record "Service Header") + var + SourceDocumentHeader: RecordRef; + begin + SourceDocumentHeader.GetTable(ServiceHeader); + ExportXRechnungFormat.Check(SourceDocumentHeader, EDocumentService, "E-Document Processing Phase"::Release); + end; + local procedure CheckSalesHeader(SalesHeader: Record "Sales Header") var SourceDocumentHeader: RecordRef; @@ -917,6 +1653,22 @@ codeunit 13918 "XRechnung XML Document Tests" TempXMLBuffer.LoadFromStream(FileInStream); end; + local procedure ExportServiceInvoice(ServiceInvoiceHeader: Record "Service Invoice Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + ServiceInvoiceLine: Record "Service Invoice Line"; + EDocument: Record "E-Document"; + TempBlob: Codeunit "Temp Blob"; + SourceDocumentHeader: RecordRef; + SourceDocumentLines: RecordRef; + FileInStream: InStream; + begin + SourceDocumentHeader.GetTable(ServiceInvoiceHeader); + SourceDocumentLines.GetTable(ServiceInvoiceLine); + ExportXRechnungFormat.Create(EDocumentService, EDocument, SourceDocumentHeader, SourceDocumentLines, TempBlob); + TempBlob.CreateInStream(FileInStream); + TempXMLBuffer.LoadFromStream(FileInStream); + end; + local procedure ExportCreditMemo(SalesCrMemoHeader: Record "Sales Cr.Memo Header"; var TempXMLBuffer: Record "XML Buffer" temporary); var SalesCrMemoLine: Record "Sales Cr.Memo Line"; @@ -933,6 +1685,22 @@ codeunit 13918 "XRechnung XML Document Tests" TempXMLBuffer.LoadFromStream(FileInStream); end; + local procedure ExportServiceCreditMemo(ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + ServiceCrMemoLine: Record "Service Cr.Memo Line"; + EDocument: Record "E-Document"; + TempBlob: Codeunit "Temp Blob"; + SourceDocumentHeader: RecordRef; + SourceDocumentLines: RecordRef; + FileInStream: InStream; + begin + SourceDocumentHeader.GetTable(ServiceCrMemoHeader); + SourceDocumentLines.GetTable(ServiceCrMemoLine); + ExportXRechnungFormat.Create(EDocumentService, EDocument, SourceDocumentHeader, SourceDocumentLines, TempBlob); + TempBlob.CreateInStream(FileInStream); + TempXMLBuffer.LoadFromStream(FileInStream); + end; + local procedure VerifyHeaderData(SalesInvoiceHeader: Record "Sales Invoice Header"; var TempXMLBuffer: Record "XML Buffer" temporary); var DocumentTok: Label '/ubl:Invoice', Locked = true; @@ -963,6 +1731,36 @@ codeunit 13918 "XRechnung XML Document Tests" Assert.AreEqual(GetCurrencyCode(SalesCrMemoHeader."Currency Code"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); end; + local procedure VerifyHeaderData(ServiceInvoiceHeader: Record "Service Invoice Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + ServiceDocumentTok: Label '/ubl:Invoice', Locked = true; + Path: Text; + begin + Path := ServiceDocumentTok + '/cbc:InvoiceTypeCode'; + Assert.AreEqual('380', GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentTok + '/cbc:ID'; + Assert.AreEqual(ServiceInvoiceHeader."No.", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentTok + '/cbc:IssueDate'; + Assert.AreEqual(FormatDate(ServiceInvoiceHeader."Posting Date"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentTok + '/cbc:DocumentCurrencyCode'; + Assert.AreEqual(GetCurrencyCode(ServiceInvoiceHeader."Currency Code"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + + local procedure VerifyHeaderData(ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + ServiceDocumentCreditNoteTok: Label '/ns0:CreditNote', Locked = true; + Path: Text; + begin + Path := ServiceDocumentCreditNoteTok + '/cbc:CreditNoteTypeCode'; + Assert.AreEqual('381', GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentCreditNoteTok + '/cbc:ID'; + Assert.AreEqual(ServiceCrMemoHeader."No.", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentCreditNoteTok + '/cbc:IssueDate'; + Assert.AreEqual(FormatDate(ServiceCrMemoHeader."Posting Date"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentCreditNoteTok + '/cbc:DocumentCurrencyCode'; + Assert.AreEqual(GetCurrencyCode(ServiceCrMemoHeader."Currency Code"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + local procedure VerifyBuyerReference(BuyerReference: Text[50]; var TempXMLBuffer: Record "XML Buffer" temporary; DocumentTok: Text); var Path: Text; @@ -998,14 +1796,14 @@ codeunit 13918 "XRechnung XML Document Tests" local procedure VerifyAccountingCustomerParty(SalesInvoiceHeader: Record "Sales Invoice Header"; var TempXMLBuffer: Record "XML Buffer" temporary); var - DocumentPartyTok: Label '/ubl:Invoice/cac:AccountingCustomerParty/cac:Party', Locked = true; + SalesDocumentPartyTok: Label '/ubl:Invoice/cac:AccountingCustomerParty/cac:Party', Locked = true; Path: Text; begin - Path := DocumentPartyTok + '/cbc:EndpointID'; + Path := SalesDocumentPartyTok + '/cbc:EndpointID'; Assert.AreEqual(SalesInvoiceHeader."Sell-to E-Mail", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); - Path := DocumentPartyTok + '/cac:PostalAddress/cbc:StreetName'; + Path := SalesDocumentPartyTok + '/cac:PostalAddress/cbc:StreetName'; Assert.AreEqual(SalesInvoiceHeader."Bill-to Address", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); - Path := DocumentPartyTok + '/cac:PostalAddress/cbc:CityName'; + Path := SalesDocumentPartyTok + '/cac:PostalAddress/cbc:CityName'; Assert.AreEqual(SalesInvoiceHeader."Bill-to City", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); end; @@ -1022,6 +1820,32 @@ codeunit 13918 "XRechnung XML Document Tests" Assert.AreEqual(SalesCrMemoHeader."Bill-to City", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); end; + local procedure VerifyAccountingCustomerParty(ServiceInvoiceHeader: Record "Service Invoice Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + DocumentServicePartyTok: Label '/ubl:Invoice/cac:AccountingCustomerParty/cac:Party', Locked = true; + Path: Text; + begin + Path := DocumentServicePartyTok + '/cbc:EndpointID'; + Assert.AreEqual(ServiceInvoiceHeader."E-Mail", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentServicePartyTok + '/cac:PostalAddress/cbc:StreetName'; + Assert.AreEqual(ServiceInvoiceHeader."Bill-to Address", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentServicePartyTok + '/cac:PostalAddress/cbc:CityName'; + Assert.AreEqual(ServiceInvoiceHeader."Bill-to City", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + + local procedure VerifyAccountingCustomerParty(ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + ServiceDocumentAccountingCustomerPartyTok: Label '/ns0:CreditNote/cac:AccountingCustomerParty/cac:Party', Locked = true; + Path: Text; + begin + Path := ServiceDocumentAccountingCustomerPartyTok + '/cbc:EndpointID'; + Assert.AreEqual(ServiceCrMemoHeader."E-Mail", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentAccountingCustomerPartyTok + '/cac:PostalAddress/cbc:StreetName'; + Assert.AreEqual(ServiceCrMemoHeader."Bill-to Address", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentAccountingCustomerPartyTok + '/cac:PostalAddress/cbc:CityName'; + Assert.AreEqual(ServiceCrMemoHeader."Bill-to City", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + local procedure VerifyPaymentMeans(var TempXMLBuffer: Record "XML Buffer" temporary; DocumentTok: Text); var Path: Text; @@ -1058,6 +1882,24 @@ codeunit 13918 "XRechnung XML Document Tests" Assert.AreEqual(FormatDecimal(GetTotalTaxAmount(SalesCrMemoHeader)), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); end; + local procedure VerifyTaxTotals(ServiceInvoiceHeader: Record "Service Invoice Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + ServiceDocumentTaxTotalTok: Label '/ubl:Invoice/cac:TaxTotal', Locked = true; + Path: Text; + begin + Path := ServiceDocumentTaxTotalTok + '/cbc:TaxAmount'; + Assert.AreEqual(FormatDecimal(GetTotalTaxAmount(ServiceInvoiceHeader)), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + + local procedure VerifyTaxTotals(ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + ServiceDocumentTaxTotalsTok: Label '/ns0:CreditNote/cac:TaxTotal', Locked = true; + Path: Text; + begin + Path := ServiceDocumentTaxTotalsTok + '/cbc:TaxAmount'; + Assert.AreEqual(FormatDecimal(GetTotalTaxAmount(ServiceCrMemoHeader)), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + local procedure VerifyLegalMonetaryTotal(SalesInvoiceHeader: Record "Sales Invoice Header"; var TempXMLBuffer: Record "XML Buffer" temporary); var LineAmounts: Dictionary of [Text, Decimal]; @@ -1092,6 +1934,40 @@ codeunit 13918 "XRechnung XML Document Tests" Assert.AreEqual(FormatDecimal(LineAmounts.Get(SalesCrMemoHeader.FieldName("Amount Including VAT"))), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); end; + local procedure VerifyLegalMonetaryTotal(ServiceInvoiceHeader: Record "Service Invoice Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + LineAmounts: Dictionary of [Text, Decimal]; + ServiceDocumentLegalMonetaryTotalTok: Label '/ubl:Invoice/cac:LegalMonetaryTotal', Locked = true; + Path: Text; + begin + CalculateLineAmounts(ServiceInvoiceHeader, LineAmounts); + Path := ServiceDocumentLegalMonetaryTotalTok + '/cbc:LineExtensionAmount'; + Assert.AreEqual(FormatDecimal(LineAmounts.Get(ServiceInvoiceHeader.FieldName(Amount))), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentLegalMonetaryTotalTok + '/cbc:TaxExclusiveAmount'; + Assert.AreEqual(FormatDecimal(LineAmounts.Get(ServiceInvoiceHeader.FieldName(Amount))), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentLegalMonetaryTotalTok + '/cbc:TaxInclusiveAmount'; + Assert.AreEqual(FormatDecimal(LineAmounts.Get(ServiceInvoiceHeader.FieldName("Amount Including VAT"))), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentLegalMonetaryTotalTok + '/cbc:PayableAmount'; + Assert.AreEqual(FormatDecimal(LineAmounts.Get(ServiceInvoiceHeader.FieldName("Amount Including VAT"))), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + + local procedure VerifyLegalMonetaryTotal(ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + LineAmounts: Dictionary of [Text, Decimal]; + ServiceDocumentLegalMonetaryTotalsTok: Label '/ns0:CreditNote/cac:LegalMonetaryTotal', Locked = true; + Path: Text; + begin + CalculateLineAmounts(ServiceCrMemoHeader, LineAmounts); + Path := ServiceDocumentLegalMonetaryTotalsTok + '/cbc:LineExtensionAmount'; + Assert.AreEqual(FormatDecimal(LineAmounts.Get(ServiceCrMemoHeader.FieldName(Amount))), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentLegalMonetaryTotalsTok + '/cbc:TaxExclusiveAmount'; + Assert.AreEqual(FormatDecimal(LineAmounts.Get(ServiceCrMemoHeader.FieldName(Amount))), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentLegalMonetaryTotalsTok + '/cbc:TaxInclusiveAmount'; + Assert.AreEqual(FormatDecimal(LineAmounts.Get(ServiceCrMemoHeader.FieldName("Amount Including VAT"))), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentLegalMonetaryTotalsTok + '/cbc:PayableAmount'; + Assert.AreEqual(FormatDecimal(LineAmounts.Get(ServiceCrMemoHeader.FieldName("Amount Including VAT"))), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + local procedure VerifyInvoiceLine(SalesInvoiceHeader: Record "Sales Invoice Header"; var TempXMLBuffer: Record "XML Buffer" temporary); var SalesInvoiceLine: Record "Sales Invoice Line"; @@ -1104,6 +1980,102 @@ codeunit 13918 "XRechnung XML Document Tests" VerifySecondInvoiceLine(SalesInvoiceLine, TempXMLBuffer, DocumentTok); end; + local procedure VerifyServiceInvoiceLine(ServiceInvoiceHeader: Record "Service Invoice Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + ServiceInvoiceLine: Record "Service Invoice Line"; + DocumentTok: Label '/ubl:Invoice/cac:InvoiceLine', Locked = true; + begin + ServiceInvoiceLine.SetRange("Document No.", ServiceInvoiceHeader."No."); + ServiceInvoiceLine.FindSet(); + VerifyFirstServiceInvoiceLine(ServiceInvoiceLine, TempXMLBuffer, DocumentTok); + ServiceInvoiceLine.Next(); + VerifySecondServiceInvoiceLine(ServiceInvoiceLine, TempXMLBuffer, DocumentTok); + end; + + local procedure VerifyFirstServiceInvoiceLine(ServiceInvoiceLine: Record "Service Invoice Line"; var TempXMLBuffer: Record "XML Buffer" temporary; DocumentTok: Text) + var + Path: Text; + begin + Path := DocumentTok + '/cbc:ID'; + Assert.AreEqual(Format(ServiceInvoiceLine."Line No."), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cbc:InvoicedQuantity'; + Assert.AreEqual(FormatDecimal(ServiceInvoiceLine."Quantity"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cbc:LineExtensionAmount'; + Assert.AreEqual(FormatDecimal(ServiceInvoiceLine."Amount"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cac:Item/cbc:Name'; + Assert.AreEqual(ServiceInvoiceLine."Description", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cac:Item/cac:SellersItemIdentification/cbc:ID'; + Assert.AreEqual(ServiceInvoiceLine."No.", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cac:Price/cbc:PriceAmount'; + Assert.AreEqual(FormatFourDecimal(ServiceInvoiceLine."Unit Price"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + + local procedure VerifySecondServiceInvoiceLine(ServiceInvoiceLine: Record "Service Invoice Line"; var TempXMLBuffer: Record "XML Buffer" temporary; DocumentTok: Text) + var + Path: Text; + begin + Path := DocumentTok + '/cbc:ID'; + Assert.AreEqual(Format(ServiceInvoiceLine."Line No."), GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cbc:InvoicedQuantity'; + Assert.AreEqual(FormatDecimal(ServiceInvoiceLine."Quantity"), GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cbc:LineExtensionAmount'; + Assert.AreEqual(FormatDecimal(ServiceInvoiceLine."Amount"), GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cac:Item/cbc:Name'; + Assert.AreEqual(ServiceInvoiceLine."Description", GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cac:Item/cac:SellersItemIdentification/cbc:ID'; + Assert.AreEqual(ServiceInvoiceLine."No.", GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cac:Price/cbc:PriceAmount'; + Assert.AreEqual(FormatFourDecimal(ServiceInvoiceLine."Unit Price"), GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + + local procedure VerifyServiceCrMemoLine(ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + ServiceCrMemoLine: Record "Service Cr.Memo Line"; + DocumentTok: Label '/ns0:CreditNote/cac:CreditNoteLine', Locked = true; + begin + ServiceCrMemoLine.SetRange("Document No.", ServiceCrMemoHeader."No."); + ServiceCrMemoLine.FindSet(); + VerifyFirstServiceCrMemoLine(ServiceCrMemoLine, TempXMLBuffer, DocumentTok); + ServiceCrMemoLine.Next(); + VerifySecondServiceCrMemoLine(ServiceCrMemoLine, TempXMLBuffer, DocumentTok); + end; + + local procedure VerifyFirstServiceCrMemoLine(ServiceCrMemoLine: Record "Service Cr.Memo Line"; var TempXMLBuffer: Record "XML Buffer" temporary; DocumentTok: Text) + var + Path: Text; + begin + Path := DocumentTok + '/cbc:ID'; + Assert.AreEqual(Format(ServiceCrMemoLine."Line No."), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cbc:CreditedQuantity '; + Assert.AreEqual(FormatDecimal(ServiceCrMemoLine."Quantity"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cbc:LineExtensionAmount'; + Assert.AreEqual(FormatDecimal(ServiceCrMemoLine."Amount"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cac:Item/cbc:Name'; + Assert.AreEqual(ServiceCrMemoLine."Description", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cac:Item/cac:SellersItemIdentification/cbc:ID'; + Assert.AreEqual(ServiceCrMemoLine."No.", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cac:Price/cbc:PriceAmount'; + Assert.AreEqual(FormatFourDecimal(ServiceCrMemoLine."Unit Price"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + + local procedure VerifySecondServiceCrMemoLine(ServiceCrMemoLine: Record "Service Cr.Memo Line"; var TempXMLBuffer: Record "XML Buffer" temporary; DocumentTok: Text) + var + Path: Text; + begin + Path := DocumentTok + '/cbc:ID'; + Assert.AreEqual(Format(ServiceCrMemoLine."Line No."), GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cbc:CreditedQuantity '; + Assert.AreEqual(FormatDecimal(ServiceCrMemoLine."Quantity"), GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cbc:LineExtensionAmount'; + Assert.AreEqual(FormatDecimal(ServiceCrMemoLine."Amount"), GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cac:Item/cbc:Name'; + Assert.AreEqual(ServiceCrMemoLine."Description", GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cac:Item/cac:SellersItemIdentification/cbc:ID'; + Assert.AreEqual(ServiceCrMemoLine."No.", GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/cac:Price/cbc:PriceAmount'; + Assert.AreEqual(FormatFourDecimal(ServiceCrMemoLine."Unit Price"), GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + local procedure VerifyFirstInvoiceLine(SalesInvoiceLine: Record "Sales Invoice Line"; var TempXMLBuffer: Record "XML Buffer" temporary; DocumentTok: Text); var Path: Text; @@ -1392,6 +2364,58 @@ codeunit 13918 "XRechnung XML Document Tests" LineAmounts.Add(SalesCrMemoLine.FieldName("Inv. Discount Amount"), SalesCrMemoLine."Inv. Discount Amount"); end; + local procedure CalculateLineAmounts(ServiceInvoiceHeader: Record "Service Invoice Header"; var LineAmounts: Dictionary of [Text, Decimal]) + var + ServiceInvLine: Record "Service Invoice Line"; + Currency: Record Currency; + begin + GetCurrencyCode(ServiceInvoiceHeader."Currency Code", Currency); + ServiceInvLine.SetRange("Document No.", ServiceInvoiceHeader."No."); + ServiceInvLine.FindSet(); + if ServiceInvoiceHeader."Prices Including VAT" then + repeat + ServiceInvLine."Line Discount Amount" := Round(ServiceInvLine."Line Discount Amount" / (1 + ServiceInvLine."VAT %" / 100), Currency."Amount Rounding Precision"); + ServiceInvLine."Inv. Discount Amount" := Round(ServiceInvLine."Inv. Discount Amount" / (1 + ServiceInvLine."VAT %" / 100), Currency."Amount Rounding Precision"); + ServiceInvLine."Unit Price" := Round(ServiceInvLine."Unit Price" / (1 + ServiceInvLine."VAT %" / 100), Currency."Amount Rounding Precision"); + ServiceInvLine.Modify(true); + until ServiceInvLine.Next() = 0; + + ServiceInvLine.CalcSums(Amount, "Amount Including VAT", "Inv. Discount Amount"); + + if not LineAmounts.ContainsKey(ServiceInvLine.FieldName(Amount)) then + LineAmounts.Add(ServiceInvLine.FieldName(Amount), ServiceInvLine.Amount); + if not LineAmounts.ContainsKey(ServiceInvLine.FieldName("Amount Including VAT")) then + LineAmounts.Add(ServiceInvLine.FieldName("Amount Including VAT"), ServiceInvLine."Amount Including VAT"); + if not LineAmounts.ContainsKey(ServiceInvLine.FieldName("Inv. Discount Amount")) then + LineAmounts.Add(ServiceInvLine.FieldName("Inv. Discount Amount"), ServiceInvLine."Inv. Discount Amount"); + end; + + local procedure CalculateLineAmounts(ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var LineAmounts: Dictionary of [Text, Decimal]) + var + ServiceCrMemoLine: Record "Service Cr.Memo Line"; + Currency: Record Currency; + begin + GetCurrencyCode(ServiceCrMemoHeader."Currency Code", Currency); + ServiceCrMemoLine.SetRange("Document No.", ServiceCrMemoHeader."No."); + ServiceCrMemoLine.FindSet(); + if ServiceCrMemoHeader."Prices Including VAT" then + repeat + ServiceCrMemoLine."Line Discount Amount" := Round(ServiceCrMemoLine."Line Discount Amount" / (1 + ServiceCrMemoLine."VAT %" / 100), Currency."Amount Rounding Precision"); + ServiceCrMemoLine."Inv. Discount Amount" := Round(ServiceCrMemoLine."Inv. Discount Amount" / (1 + ServiceCrMemoLine."VAT %" / 100), Currency."Amount Rounding Precision"); + ServiceCrMemoLine."Unit Price" := Round(ServiceCrMemoLine."Unit Price" / (1 + ServiceCrMemoLine."VAT %" / 100), Currency."Amount Rounding Precision"); + ServiceCrMemoLine.Modify(true); + until ServiceCrMemoLine.Next() = 0; + + ServiceCrMemoLine.CalcSums(Amount, "Amount Including VAT", "Inv. Discount Amount"); + + if not LineAmounts.ContainsKey(ServiceCrMemoLine.FieldName(Amount)) then + LineAmounts.Add(ServiceCrMemoLine.FieldName(Amount), ServiceCrMemoLine.Amount); + if not LineAmounts.ContainsKey(ServiceCrMemoLine.FieldName("Amount Including VAT")) then + LineAmounts.Add(ServiceCrMemoLine.FieldName("Amount Including VAT"), ServiceCrMemoLine."Amount Including VAT"); + if not LineAmounts.ContainsKey(ServiceCrMemoLine.FieldName("Inv. Discount Amount")) then + LineAmounts.Add(ServiceCrMemoLine.FieldName("Inv. Discount Amount"), ServiceCrMemoLine."Inv. Discount Amount"); + end; + local procedure GetTotalTaxAmount(SalesInvoiceHeader: Record "Sales Invoice Header"): Decimal var SalesInvLine: Record "Sales Invoice Line"; @@ -1422,6 +2446,36 @@ codeunit 13918 "XRechnung XML Document Tests" exit(SalesCrMemoLine."Amount Including VAT" - SalesCrMemoLine.Amount); end; + local procedure GetTotalTaxAmount(ServiceInvoiceHeader: Record "Service Invoice Header"): Decimal + var + ServiceInvLine: Record "Service Invoice Line"; + begin + ServiceInvLine.SetRange("Document No.", ServiceInvoiceHeader."No."); + ServiceInvLine.SetFilter( + "VAT Calculation Type", '%1|%2|%3', + ServiceInvLine."VAT Calculation Type"::"Normal VAT", + ServiceInvLine."VAT Calculation Type"::"Full VAT", + ServiceInvLine."VAT Calculation Type"::"Reverse Charge VAT"); + ServiceInvLine.CalcSums(Amount, "Amount Including VAT"); + ServiceInvLine.SetRange("VAT Calculation Type"); + exit(ServiceInvLine."Amount Including VAT" - ServiceInvLine.Amount); + end; + + local procedure GetTotalTaxAmount(ServiceCrMemoHeader: Record "Service Cr.Memo Header"): Decimal + var + ServiceCrMemoLine: Record "Service Cr.Memo Line"; + begin + ServiceCrMemoLine.SetRange("Document No.", ServiceCrMemoHeader."No."); + ServiceCrMemoLine.SetFilter( + "VAT Calculation Type", '%1|%2|%3', + ServiceCrMemoLine."VAT Calculation Type"::"Normal VAT", + ServiceCrMemoLine."VAT Calculation Type"::"Full VAT", + ServiceCrMemoLine."VAT Calculation Type"::"Reverse Charge VAT"); + ServiceCrMemoLine.CalcSums(Amount, "Amount Including VAT"); + ServiceCrMemoLine.SetRange("VAT Calculation Type"); + exit(ServiceCrMemoLine."Amount Including VAT" - ServiceCrMemoLine.Amount); + end; + local procedure GetCurrencyCode(DocumentCurrencyCode: Code[10]; var Currency: Record Currency): Code[10] begin if DocumentCurrencyCode = '' then begin @@ -1472,4 +2526,10 @@ codeunit 13918 "XRechnung XML Document Tests" LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::"XRechnung XML Document Tests"); end; + + [ConfirmHandler] + procedure ConfirmHandlerYes(Question: Text[1024]; var Reply: Boolean) + begin + Reply := true; + end; } \ No newline at end of file diff --git a/Apps/DE/EDocumentDE/test/src/ZUGFeRDXMLDocumentTests.Codeunit.al b/Apps/DE/EDocumentDE/test/src/ZUGFeRDXMLDocumentTests.Codeunit.al index 7b7aeb7d92..9ea32412f2 100644 --- a/Apps/DE/EDocumentDE/test/src/ZUGFeRDXMLDocumentTests.Codeunit.al +++ b/Apps/DE/EDocumentDE/test/src/ZUGFeRDXMLDocumentTests.Codeunit.al @@ -20,6 +20,9 @@ using Microsoft.Purchases.Vendor; using Microsoft.Sales.Customer; using Microsoft.Sales.Document; using Microsoft.Sales.History; +using Microsoft.Service.Document; +using Microsoft.Service.History; +using Microsoft.Service.Test; using System.IO; using System.Reflection; using System.Utilities; @@ -41,6 +44,7 @@ codeunit 13922 "ZUGFeRD XML Document Tests" LibraryTestInitialize: Codeunit "Library - Test Initialize"; LibraryPurchase: Codeunit "Library - Purchase"; LibrarySales: Codeunit "Library - Sales"; + LibraryService: Codeunit "Library - Service"; LibraryInventory: Codeunit "Library - Inventory"; LibraryRandom: Codeunit "Library - Random"; LibraryERM: Codeunit "Library - ERM"; @@ -337,45 +341,6 @@ codeunit 13922 "ZUGFeRD XML Document Tests" VerifyInvoiceLineWithDiscount(SalesInvoiceHeader, TempXMLBuffer); end; - [Test] - procedure ExportPostedSalesInvoiceInZUGFeRDFormatVerifyInvoiceWithInvoiceDiscounts(); - var - SalesInvoiceHeader: Record "Sales Invoice Header"; - TempXMLBuffer: Record "XML Buffer" temporary; - begin - // [SCENARIO 575895] Export posted sales invoice creates electronic document in ZUGFeRD format with 2 invoice lines and invoice discount - Initialize(); - - // [GIVEN] Create and Post Sales Invoice with invoice discount - SalesInvoiceHeader.Get(CreateAndPostSalesDocumentWithTwoLines("Sales Document Type"::Invoice, Enum::"Sales Line Type"::Item, true)); - - // [WHEN] Export ZUGFeRD Electronic Document. - ExportInvoice(SalesInvoiceHeader, TempXMLBuffer); - - // [THEN] ZUGFeRD Electronic Document is created with 2 invoice lines and invoice discount - VerifyInvoiceWithInvDiscount(SalesInvoiceHeader, TempXMLBuffer); - end; - - [Test] - procedure ExportPostedSalesInvoiceInZUGFeRDFormatVerifyInvoiceWithInvoiceDiscountsAndLineDiscount(); - var - SalesInvoiceHeader: Record "Sales Invoice Header"; - TempXMLBuffer: Record "XML Buffer" temporary; - begin - // [SCENARIO 575895] Export posted sales invoice creates electronic document in ZUGFeRD format with 2 invoice lines with discount and invoice discount - Initialize(); - - // [GIVEN] Create and Post Sales Invoice with invoice discount and line discount on one line - SalesInvoiceHeader.Get(CreateAndPostSalesDocumentWithTwoLinesLineDiscount("Sales Document Type"::Invoice, Enum::"Sales Line Type"::Item, true)); - - // [WHEN] Export ZUGFeRD Electronic Document. - ExportInvoice(SalesInvoiceHeader, TempXMLBuffer); - - // [THEN] ZUGFeRD Electronic Document is created with 2 invoice lines with line discount and invoice discount - VerifyInvoiceWithInvDiscount(SalesInvoiceHeader, TempXMLBuffer); - VerifyInvoiceLineWithDiscount(SalesInvoiceHeader, TempXMLBuffer); - end; - [Test] procedure ExportPostedSalesInvoiceInZUGFeRDFormatWithCustomReportLayout(); var @@ -671,27 +636,584 @@ codeunit 13922 "ZUGFeRD XML Document Tests" // [WHEN] Export ZUGFeRD Electronic Document. ExportCreditMemo(SalesCrMemoHeader, TempXMLBuffer); - // [THEN] ZUGFeRD Electronic Document is created with document totals - VerifyLegalMonetaryTotal(SalesCrMemoHeader, TempXMLBuffer); + // [THEN] ZUGFeRD Electronic Document is created with document totals + VerifyLegalMonetaryTotal(SalesCrMemoHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedSalesCrMemoInZUGFeRDFormatVerifyCrMemoLine(); + var + SalesCrMemoHeader: Record "Sales Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [SCENARIO 556034] Export posted sales cr. memo creates electronic document in ZUGFeRD format with 2 cr.memo lines + Initialize(); + + // [GIVEN] Create and Post sales cr. memo. + SalesCrMemoHeader.Get(CreateAndPostSalesDocumentWithTwoLines("Sales Document Type"::"Credit Memo", Enum::"Sales Line Type"::Item, false)); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportCreditMemo(SalesCrMemoHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with 2 cr.memo lines + VerifyCrMemoLine(SalesCrMemoHeader, TempXMLBuffer); + end; + #endregion + + #region ServiceInvoice + [Test] + procedure ExportPostedServiceInvoiceInZUGFeRDFormatVerifyHeaderData(); + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in ZUGFeRD format with header data from the document + Initialize(); + + // [GIVEN] Create and Post Service Invoice. + ServiceInvoiceHeader.Get(CreateAndPostServiceDocument()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created + VerifyHeaderData(ServiceInvoiceHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedServiceInvoiceInZUGFeRDFormatVerifyBuyerReferenceAsCustomerReference(); + var + Customer: Record Customer; + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in ZUGFeRD format with customer reference + Initialize(); + + // [GIVEN] Set Buyer reference = customer reference + SetEdocumentServiceBuyerReference("E-Document Buyer Reference"::"Customer Reference"); + + // [GIVEN] Create and Post Service Invoice with Customer X, E-invoice routing no. = XY + ServiceInvoiceHeader.Get(CreateAndPostServiceDocument()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with buyer reference XY + Customer.Get(ServiceInvoiceHeader."Customer No."); + VerifyBuyerReference(Customer."E-Invoice Routing No.", TempXMLBuffer, '/rsm:CrossIndustryInvoice'); + end; + + [Test] + procedure ExportPostedServiceInvoiceInZUGFeRDFormatVerifyBuyerReferenceAsYourReference(); + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in ZUGFeRD format with your reference from the document + Initialize(); + + // [GIVEN] Set Buyer reference = your reference + SetEdocumentServiceBuyerReference("E-Document Buyer Reference"::"Your Reference"); + + // [GIVEN] Create and Post Service Invoice with your reference = XX + ServiceInvoiceHeader.Get(CreateAndPostServiceDocument()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with buyer reference XX + VerifyBuyerReference(ServiceInvoiceHeader."Your Reference", TempXMLBuffer, '/rsm:CrossIndustryInvoice'); + end; + + [Test] + procedure ExportPostedServiceInvoiceInZUGFeRDFormatMandateBuyerReferenceAsYourReference(); + var + ServiceHeader: Record "Service Header"; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Mandate buyer reference as your reference when releasing service invoice for ZUGFeRD format + Initialize(); + + // [GIVEN] Set Buyer reference = your reference + SetEdocumentServiceBuyerReference("E-Document Buyer Reference"::"Your Reference"); + + // [GIVEN] Create Service Invoice with your reference = XX + ServiceHeader.Get(ServiceHeader."Document Type"::Invoice, CreateServiceDocumentWithLine()); + + // [WHEN] Remove your reference + ServiceHeader.Validate("Your Reference", ''); + ServiceHeader.Modify(false); + + // [THEN] Error message is shown when releasing the service invoice + asserterror CheckServiceHeader(ServiceHeader); + end; + + [Test] + procedure ExportPostedServiceInvoiceInZUGFeRDFormatVerifySellerDataApplicableHeaderTradeAgreement(); + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in ZUGFeRD format with company data as seller in applicable header trade agreement + Initialize(); + + // [GIVEN] Create and Post Service Invoice. + ServiceInvoiceHeader.Get(CreateAndPostServiceDocument()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with company data as seller in applicable header trade agreement + VerifySellerData(TempXMLBuffer, '/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty'); + end; + + [Test] + [HandlerFunctions('ConfirmHandlerYes')] + procedure ExportPostedServiceInvoiceInZUGFeRDFormatWithRespCenterVerifySellerDataApplicableHeaderTradeAgreement(); + var + ResponsibilityCenter: Record "Responsibility Center"; + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in ZUGFeRD format with responsibility center data as seller in applicable header trade agreement + Initialize(); + + // [GIVEN] Responsibility Center + CreateResponsibilityCenter(ResponsibilityCenter); + + // [GIVEN] Create and Post Service Invoice. + ServiceInvoiceHeader.Get(CreateAndPostServiceDocumentWithRespCenter(ResponsibilityCenter.Code)); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with responsibility data as seller in applicable header trade agreement + VerifySellerData(TempXMLBuffer, '/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty', ResponsibilityCenter); + end; + + [Test] + procedure ExportPostedServiceInvoiceInZUGFeRDFormatVerifyBuyerDataApplicableHeaderTradeAgreement(); + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in ZUGFeRD format with customer data + Initialize(); + + // [GIVEN] Create and Post Service Invoice. + ServiceInvoiceHeader.Get(CreateAndPostServiceDocument()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with customer data + VerifyBuyerData(ServiceInvoiceHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedServiceInvoiceInZUGFeRDFormatVerifyPaymentMeans(); + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in ZUGFeRD format with bank information as payment means + Initialize(); + + // [GIVEN] Create and Post Service Invoice. + ServiceInvoiceHeader.Get(CreateAndPostServiceDocument()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with bank informarion as payment means + VerifyPaymentMeans(TempXMLBuffer, '/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement', ServiceInvoiceHeader."Currency Code"); + end; + + [Test] + procedure ExportPostedServiceInvoiceInZUGFeRDFormatVerifyPaymentTerms(); + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in ZUGFeRD format with payment terms + Initialize(); + + // [GIVEN] Create and Post Service Invoice. + ServiceInvoiceHeader.Get(CreateAndPostServiceDocument()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with payment terms + VerifyPaymentTerms(ServiceInvoiceHeader."Payment Terms Code", ServiceInvoiceHeader."Due Date", TempXMLBuffer, '/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradePaymentTerms'); + end; + + [Test] + procedure ExportPostedServiceInvoiceInZUGFeRDFormatVerifyTaxTotal(); + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in ZUGFeRD format with different tax totals + Initialize(); + + // [GIVEN] Create and Post Service Invoice. + ServiceInvoiceHeader.Get(CreateAndPostServiceDocument()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with different tax totals + VerifyTaxTotals(ServiceInvoiceHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedServiceInvoiceInZUGFeRDFormatVerifyLegalMonetaryTotal(); + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in ZUGFeRD format with document totals + Initialize(); + + // [GIVEN] Create and Post Service Invoice. + ServiceInvoiceHeader.Get(CreateAndPostServiceDocument()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with document totals + VerifyLegalMonetaryTotal(ServiceInvoiceHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedServiceInvoiceInZUGFeRDFormatVerifyInvoiceLine(); + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service invoice creates electronic document in ZUGFeRD format with 2 invoice lines + Initialize(); + + // [GIVEN] Create and Post Service Invoice. + ServiceInvoiceHeader.Get(CreateAndPostServiceDocumentWithTwoLines()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceInvoice(ServiceInvoiceHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with 2 invoice lines + VerifyServiceInvoiceLine(ServiceInvoiceHeader, TempXMLBuffer); + end; + #endregion + + #region ServiceCreditMemo + [Test] + procedure ExportPostedServiceCrMemoInZUGFeRDFormatVerifyHeaderData(); + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in ZUGFeRD format with header data from the document + Initialize(); + + // [GIVEN] Create and Post service cr. memo. + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocument()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created + VerifyHeaderData(ServiceCrMemoHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedServiceCrMemoInZUGFeRDFormatVerifyBuyerReferenceAsCustomerReference(); + var + Customer: Record Customer; + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in ZUGFeRD format with customer reference + Initialize(); + + // [GIVEN] Set Buyer reference = customer reference + SetEdocumentServiceBuyerReference("E-Document Buyer Reference"::"Customer Reference"); + + // [GIVEN] Create and Post service cr. memo with Customer X, E-invoice routing no. = XY + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocument()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with buyer reference XY + Customer.Get(ServiceCrMemoHeader."Customer No."); + VerifyBuyerReference(Customer."E-Invoice Routing No.", TempXMLBuffer, '/rsm:CrossIndustryInvoice'); + end; + + [Test] + procedure ExportPostedServiceCrMemoInZUGFeRDFormatVerifyBuyerReferenceAsYourReference(); + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in ZUGFeRD format with your reference from the document + Initialize(); + + // [GIVEN] Set Buyer reference = your reference + SetEdocumentServiceBuyerReference("E-Document Buyer Reference"::"Your Reference"); + + // [GIVEN] Create and Post service cr. memo with your reference = XX + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocument()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with buyer reference XX + VerifyBuyerReference(ServiceCrMemoHeader."Your Reference", TempXMLBuffer, '/rsm:CrossIndustryInvoice'); + end; + + [Test] + procedure ExportPostedServiceCrMemoInZUGFeRDFormatMandateBuyerReferenceAsYourReference(); + var + ServiceHeader: Record "Service Header"; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Mandate buyer reference as your reference when releasing service credit memo for ZUGFeRD format + Initialize(); + + // [GIVEN] Set Buyer reference = your reference + SetEdocumentServiceBuyerReference("E-Document Buyer Reference"::"Your Reference"); + + // [GIVEN] Create Service Credit Memo with your reference = XX + ServiceHeader.Get(ServiceHeader."Document Type"::"Credit Memo", CreateServiceCrMemoDocumentWithLine()); + + // [WHEN] Remove your reference + ServiceHeader.Validate("Your Reference", ''); + ServiceHeader.Modify(false); + + // [THEN] Error message is shown when releasing the service credit memo + asserterror CheckServiceHeader(ServiceHeader); + end; + + [Test] + procedure ExportPostedServiceCrMemoInZUGFeRDFormatVerifySellerDataApplicableHeaderTradeAgreement(); + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in ZUGFeRD format with company data as seller in applicable header trade agreement + Initialize(); + + // [GIVEN] Create and Post service cr. memo. + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocument()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with company data as seller in applicable header trade agreement + VerifySellerData(TempXMLBuffer, '/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty'); + end; + + [Test] + [HandlerFunctions('ConfirmHandlerYes')] + procedure ExportPostedServiceCrMemoInZUGFeRDFormatWithRespCenterVerifySellerDataApplicableHeaderTradeAgreement(); + var + ResponsibilityCenter: Record "Responsibility Center"; + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in ZUGFeRD format with responsibility center data as seller in applicable header trade agreement + Initialize(); + + // [GIVEN] Responsibility Center + CreateResponsibilityCenter(ResponsibilityCenter); + + // [GIVEN] Create and Post service cr. memo. + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocumentWithRespCenter(ResponsibilityCenter.Code)); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with responsibility data as seller in applicable header trade agreement + VerifySellerData(TempXMLBuffer, '/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty', ResponsibilityCenter); + end; + + [Test] + procedure ExportPostedServiceCrMemoInZUGFeRDFormatVerifyBuyerDataApplicableHeaderTradeAgreement(); + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in ZUGFeRD format with customer data + Initialize(); + + // [GIVEN] Create and Post service cr. memo. + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocument()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with customer data + VerifyBuyerData(ServiceCrMemoHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedServiceCrMemoInZUGFeRDFormatVerifyPaymentMeans(); + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in ZUGFeRD format with bank information as payment means + Initialize(); + + // [GIVEN] Create and Post service cr. memo. + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocument()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with bank informarion as payment means + VerifyPaymentMeans(TempXMLBuffer, '/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement', ServiceCrMemoHeader."Currency Code"); + end; + + [Test] + procedure ExportPostedServiceCrMemoInZUGFeRDFormatVerifyPaymentTerms(); + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in ZUGFeRD format with payment terms + Initialize(); + + // [GIVEN] Create and Post service cr. memo. + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocument()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with payment terms + VerifyPaymentTerms(ServiceCrMemoHeader."Payment Terms Code", ServiceCrMemoHeader."Due Date", TempXMLBuffer, '/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradePaymentTerms'); + end; + + [Test] + procedure ExportPostedServiceCrMemoInZUGFeRDFormatVerifyTaxTotal(); + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in ZUGFeRD format with different tax totals + Initialize(); + + // [GIVEN] Create and Post service cr. memo. + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocument()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with different tax totals + VerifyTaxTotals(ServiceCrMemoHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedServiceCrMemoInZUGFeRDFormatVerifyLegalMonetaryTotal(); + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in ZUGFeRD format with document totals + Initialize(); + + // [GIVEN] Create and Post service cr. memo. + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocument()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with document totals + VerifyLegalMonetaryTotal(ServiceCrMemoHeader, TempXMLBuffer); + end; + + [Test] + procedure ExportPostedServiceCrMemoInZUGFeRDFormatVerifyCrMemoLine(); + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [FEATURE] [AI test] + // [SCENARIO 604872] Export posted service cr. memo creates electronic document in ZUGFeRD format with 2 cr.memo lines + Initialize(); + + // [GIVEN] Create and Post service cr. memo. + ServiceCrMemoHeader.Get(CreateAndPostServiceCrMemoDocumentWithTwoLines()); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportServiceCreditMemo(ServiceCrMemoHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with 2 cr.memo lines + VerifyServiceCrMemoLine(ServiceCrMemoHeader, TempXMLBuffer); + end; + #endregion + #region InvoiceDiscount + + [Test] + procedure ExportPostedSalesInvoiceInZUGFeRDFormatVerifyInvoiceWithInvoiceDiscounts(); + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + TempXMLBuffer: Record "XML Buffer" temporary; + begin + // [SCENARIO 575895] Export posted sales invoice creates electronic document in ZUGFeRD format with 2 invoice lines and invoice discount + Initialize(); + + // [GIVEN] Create and Post Sales Invoice with invoice discount + SalesInvoiceHeader.Get(CreateAndPostSalesDocumentWithTwoLines("Sales Document Type"::Invoice, Enum::"Sales Line Type"::Item, true)); + + // [WHEN] Export ZUGFeRD Electronic Document. + ExportInvoice(SalesInvoiceHeader, TempXMLBuffer); + + // [THEN] ZUGFeRD Electronic Document is created with 2 invoice lines and invoice discount + VerifyInvoiceWithInvDiscount(SalesInvoiceHeader, TempXMLBuffer); end; [Test] - procedure ExportPostedSalesCrMemoInZUGFeRDFormatVerifyCrMemoLine(); + procedure ExportPostedSalesInvoiceInZUGFeRDFormatVerifyInvoiceWithInvoiceDiscountsAndLineDiscount(); var - SalesCrMemoHeader: Record "Sales Cr.Memo Header"; + SalesInvoiceHeader: Record "Sales Invoice Header"; TempXMLBuffer: Record "XML Buffer" temporary; begin - // [SCENARIO 556034] Export posted sales cr. memo creates electronic document in ZUGFeRD format with 2 cr.memo lines + // [SCENARIO 575895] Export posted sales invoice creates electronic document in ZUGFeRD format with 2 invoice lines with discount and invoice discount Initialize(); - // [GIVEN] Create and Post sales cr. memo. - SalesCrMemoHeader.Get(CreateAndPostSalesDocumentWithTwoLines("Sales Document Type"::"Credit Memo", Enum::"Sales Line Type"::Item, false)); + // [GIVEN] Create and Post Sales Invoice with invoice discount and line discount on one line + SalesInvoiceHeader.Get(CreateAndPostSalesDocumentWithTwoLinesLineDiscount("Sales Document Type"::Invoice, Enum::"Sales Line Type"::Item, true)); // [WHEN] Export ZUGFeRD Electronic Document. - ExportCreditMemo(SalesCrMemoHeader, TempXMLBuffer); + ExportInvoice(SalesInvoiceHeader, TempXMLBuffer); - // [THEN] ZUGFeRD Electronic Document is created with 2 cr.memo lines - VerifyCrMemoLine(SalesCrMemoHeader, TempXMLBuffer); + // [THEN] ZUGFeRD Electronic Document is created with 2 invoice lines with line discount and invoice discount + VerifyInvoiceWithInvDiscount(SalesInvoiceHeader, TempXMLBuffer); + VerifyInvoiceLineWithDiscount(SalesInvoiceHeader, TempXMLBuffer); end; [Test] @@ -733,7 +1255,6 @@ codeunit 13922 "ZUGFeRD XML Document Tests" VerifyCrMemoLineWithDiscounts(SalesCrMemoHeader, TempXMLBuffer); end; #endregion - #region PurchaseInvoice [Test] procedure ReleasePurchaseInvoiceInZUGFeRDFormat(); @@ -806,6 +1327,76 @@ codeunit 13922 "ZUGFeRD XML Document Tests" exit(LibrarySales.PostSalesDocument(SalesHeader, true, true)); end; + local procedure CreateAndPostServiceDocument(): Code[20] + var + ServiceHeader: Record "Service Header"; + begin + ServiceHeader.Get(ServiceHeader."Document Type"::Invoice, CreateServiceDocumentWithLine()); + exit(PostServiceDocument(ServiceHeader)); + end; + + local procedure CreateAndPostServiceDocumentWithTwoLines(): Code[20] + var + ServiceHeader: Record "Service Header"; + begin + ServiceHeader.Get(ServiceHeader."Document Type"::Invoice, CreateServiceDocumentWithTwoLines()); + exit(PostServiceDocument(ServiceHeader)); + end; + + local procedure CreateAndPostServiceDocumentWithRespCenter(RespCenterCode: Code[10]): Code[20] + var + ServiceHeader: Record "Service Header"; + begin + ServiceHeader.Get(ServiceHeader."Document Type"::Invoice, CreateServiceDocumentWithLine()); + ServiceHeader.Validate("Responsibility Center", RespCenterCode); + ServiceHeader.Modify(true); + exit(PostServiceDocument(ServiceHeader)); + end; + + local procedure PostServiceDocument(var ServiceHeader: Record "Service Header"): Code[20] + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + begin + LibraryService.PostServiceOrder(ServiceHeader, true, false, true); + ServiceInvoiceHeader.FindLast(); + exit(ServiceInvoiceHeader."No."); + end; + + local procedure CreateAndPostServiceCrMemoDocument(): Code[20] + var + ServiceHeader: Record "Service Header"; + begin + ServiceHeader.Get(ServiceHeader."Document Type"::"Credit Memo", CreateServiceCrMemoDocumentWithLine()); + exit(PostServiceCrMemoDocument(ServiceHeader)); + end; + + local procedure CreateAndPostServiceCrMemoDocumentWithTwoLines(): Code[20] + var + ServiceHeader: Record "Service Header"; + begin + ServiceHeader.Get(ServiceHeader."Document Type"::"Credit Memo", CreateServiceCrMemoDocumentWithTwoLines()); + exit(PostServiceCrMemoDocument(ServiceHeader)); + end; + + local procedure CreateAndPostServiceCrMemoDocumentWithRespCenter(RespCenterCode: Code[10]): Code[20] + var + ServiceHeader: Record "Service Header"; + begin + ServiceHeader.Get(ServiceHeader."Document Type"::"Credit Memo", CreateServiceCrMemoDocumentWithLine()); + ServiceHeader.Validate("Responsibility Center", RespCenterCode); + ServiceHeader.Modify(true); + exit(PostServiceCrMemoDocument(ServiceHeader)); + end; + + local procedure PostServiceCrMemoDocument(var ServiceHeader: Record "Service Header"): Code[20] + var + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + begin + LibraryService.PostServiceOrder(ServiceHeader, true, false, true); + ServiceCrMemoHeader.FindLast(); + exit(ServiceCrMemoHeader."No."); + end; + local procedure CreatePurchDocument(var PurchaseHeader: Record "Purchase Header"; DocumentType: Enum "Purchase Document Type") var PurchaseLine: Record "Purchase Line"; @@ -953,6 +1544,105 @@ codeunit 13922 "ZUGFeRD XML Document Tests" SalesLine.Modify(true); end; + local procedure CreateServiceDocumentWithLine(): Code[20] + var + ServiceHeader: Record "Service Header"; + begin + CreateServiceHeader(ServiceHeader); + CreateServiceLine(ServiceHeader); + exit(ServiceHeader."No."); + end; + + local procedure CreateServiceDocumentWithTwoLines(): Code[20] + var + ServiceHeader: Record "Service Header"; + begin + CreateServiceHeader(ServiceHeader); + CreateServiceLine(ServiceHeader); + CreateServiceLine(ServiceHeader); + exit(ServiceHeader."No."); + end; + + local procedure CreateServiceHeader(var ServiceHeader: Record "Service Header") + var + PostCode: Record "Post Code"; + PaymentTermsCode: Code[10]; + begin + LibraryERM.FindPostCode(PostCode); + PaymentTermsCode := LibraryERM.FindPaymentTermsCode(); + LibraryService.CreateServiceHeader(ServiceHeader, ServiceHeader."Document Type"::Invoice, CreateCustomer()); + ServiceHeader.Validate("Bill-to Address", LibraryUtility.GenerateGUID()); + ServiceHeader.Validate("Bill-to City", PostCode.City); + ServiceHeader.Validate("Ship-to Address", LibraryUtility.GenerateGUID()); + ServiceHeader.Validate("Ship-to City", PostCode.City); + ServiceHeader.Validate(Address, LibraryUtility.GenerateGUID()); + ServiceHeader.Validate(City, PostCode.City); + ServiceHeader.Validate("Your Reference", LibraryUtility.GenerateRandomText(20)); + ServiceHeader.Validate("Payment Terms Code", PaymentTermsCode); + ServiceHeader.Modify(true); + end; + + local procedure CreateServiceLine(ServiceHeader: Record "Service Header") + var + ServiceLine: Record "Service Line"; + UnitOfMeasure: Record "Unit of Measure"; + begin + LibraryInventory.CreateUnitOfMeasureCode(UnitOfMeasure); + UnitOfMeasure."International Standard Code" := LibraryUtility.GenerateGUID(); + UnitOfMeasure.Modify(true); + LibraryService.CreateServiceLine(ServiceLine, ServiceHeader, ServiceLine.Type::Item, LibraryInventory.CreateItemNo()); + ServiceLine.Validate(Quantity, LibraryRandom.RandDecInRange(10, 20, 2)); + ServiceLine.Validate("Unit Price", LibraryRandom.RandDecInRange(100, 200, 2)); + ServiceLine.Validate("Unit of Measure", UnitOfMeasure.Code); + ServiceLine.Modify(true); + end; + + local procedure CreateServiceCrMemoDocumentWithLine(): Code[20] + var + ServiceHeader: Record "Service Header"; + begin + CreateServiceCrMemoHeader(ServiceHeader); + CreateServiceLine(ServiceHeader); + exit(ServiceHeader."No."); + end; + + local procedure CreateServiceCrMemoDocumentWithTwoLines(): Code[20] + var + ServiceHeader: Record "Service Header"; + begin + CreateServiceCrMemoHeader(ServiceHeader); + CreateServiceLine(ServiceHeader); + CreateServiceLine(ServiceHeader); + exit(ServiceHeader."No."); + end; + + local procedure CreateServiceCrMemoHeader(var ServiceHeader: Record "Service Header") + var + PostCode: Record "Post Code"; + PaymentTermsCode: Code[10]; + begin + LibraryERM.FindPostCode(PostCode); + PaymentTermsCode := LibraryERM.FindPaymentTermsCode(); + LibraryService.CreateServiceHeader(ServiceHeader, ServiceHeader."Document Type"::"Credit Memo", CreateCustomer()); + ServiceHeader.Validate("Bill-to Address", LibraryUtility.GenerateGUID()); + ServiceHeader.Validate("Bill-to City", PostCode.City); + ServiceHeader.Validate("Ship-to Address", LibraryUtility.GenerateGUID()); + ServiceHeader.Validate("Ship-to City", PostCode.City); + ServiceHeader.Validate(Address, LibraryUtility.GenerateGUID()); + ServiceHeader.Validate(City, PostCode.City); + ServiceHeader.Validate("Your Reference", LibraryUtility.GenerateRandomText(20)); + ServiceHeader.Validate("Payment Terms Code", PaymentTermsCode); + ServiceHeader.Modify(true); + end; + + local procedure CheckServiceHeader(ServiceHeader: Record "Service Header") + var + SourceDocumentHeader: RecordRef; + begin + SourceDocumentHeader.GetTable(ServiceHeader); + ZUGFeRDFormat.Check(SourceDocumentHeader, EDocumentService, "E-Document Processing Phase"::Release); + end; + local procedure CheckSalesHeader(SalesHeader: Record "Sales Header") var SourceDocumentHeader: RecordRef; @@ -1005,6 +1695,50 @@ codeunit 13922 "ZUGFeRD XML Document Tests" TempXMLBuffer.LoadFromStream(PdfAttachmentStream); end; + local procedure ExportServiceInvoice(ServiceInvoiceHeader: Record "Service Invoice Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + ServiceInvoiceLine: Record "Service Invoice Line"; + EDocument: Record "E-Document"; + TempBlob: Codeunit "Temp Blob"; + TempBlob2: Codeunit "Temp Blob"; + PDFDocument: Codeunit "PDF Document"; + SourceDocumentHeader: RecordRef; + SourceDocumentLines: RecordRef; + PDFInStream: InStream; + PdfAttachmentStream: InStream; + begin + SourceDocumentHeader.GetTable(ServiceInvoiceHeader); + SourceDocumentLines.GetTable(ServiceInvoiceLine); + ZUGFeRDFormat.Create(EDocumentService, EDocument, SourceDocumentHeader, SourceDocumentLines, TempBlob); + + TempBlob.CreateInStream(PdfInStream); + PDFDocument.GetDocumentAttachmentStream(PdfInStream, TempBlob2); + TempBlob2.CreateInStream(PdfAttachmentStream); + TempXMLBuffer.LoadFromStream(PdfAttachmentStream); + end; + + local procedure ExportServiceCreditMemo(ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + ServiceCrMemoLine: Record "Service Cr.Memo Line"; + EDocument: Record "E-Document"; + TempBlob: Codeunit "Temp Blob"; + TempBlob2: Codeunit "Temp Blob"; + PDFDocument: Codeunit "PDF Document"; + SourceDocumentHeader: RecordRef; + SourceDocumentLines: RecordRef; + PDFInStream: InStream; + PdfAttachmentStream: InStream; + begin + SourceDocumentHeader.GetTable(ServiceCrMemoHeader); + SourceDocumentLines.GetTable(ServiceCrMemoLine); + ZUGFeRDFormat.Create(EDocumentService, EDocument, SourceDocumentHeader, SourceDocumentLines, TempBlob); + + TempBlob.CreateInStream(PdfInStream); + PDFDocument.GetDocumentAttachmentStream(PdfInStream, TempBlob2); + TempBlob2.CreateInStream(PdfAttachmentStream); + TempXMLBuffer.LoadFromStream(PdfAttachmentStream); + end; + local procedure VerifyHeaderData(SalesInvoiceHeader: Record "Sales Invoice Header"; var TempXMLBuffer: Record "XML Buffer" temporary); var DocumentTok: Label '/rsm:CrossIndustryInvoice', Locked = true; @@ -1032,6 +1766,32 @@ codeunit 13922 "ZUGFeRD XML Document Tests" Assert.AreEqual(FormatDate(SalesCrMemoHeader."Posting Date"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); end; + local procedure VerifyHeaderData(ServiceInvoiceHeader: Record "Service Invoice Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + ServiceDocumentTok: Label '/rsm:CrossIndustryInvoice', Locked = true; + Path: Text; + begin + Path := ServiceDocumentTok + '/rsm:ExchangedDocument/ram:TypeCode'; + Assert.AreEqual('380', GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentTok + '/rsm:ExchangedDocument/ram:ID'; + Assert.AreEqual(ServiceInvoiceHeader."No.", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentTok + '/rsm:ExchangedDocument/ram:IssueDateTime/udt:DateTimeString'; + Assert.AreEqual(FormatDate(ServiceInvoiceHeader."Posting Date"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + + local procedure VerifyHeaderData(ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + ServiceDocumentCreditNoteTok: Label '/rsm:CrossIndustryInvoice', Locked = true; + Path: Text; + begin + Path := ServiceDocumentCreditNoteTok + '/rsm:ExchangedDocument/ram:TypeCode'; + Assert.AreEqual('381', GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentCreditNoteTok + '/rsm:ExchangedDocument/ram:ID'; + Assert.AreEqual(ServiceCrMemoHeader."No.", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentCreditNoteTok + '/rsm:ExchangedDocument/ram:IssueDateTime/udt:DateTimeString'; + Assert.AreEqual(FormatDate(ServiceCrMemoHeader."Posting Date"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + local procedure VerifyBuyerReference(BuyerReference: Text[50]; var TempXMLBuffer: Record "XML Buffer" temporary; DocumentTok: Text); var Path: Text; @@ -1097,6 +1857,32 @@ codeunit 13922 "ZUGFeRD XML Document Tests" Assert.AreEqual(GetVATRegistrationNo(SalesCrMemoHeader."VAT Registration No.", CompanyInformation."Country/Region Code"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); end; + local procedure VerifyBuyerData(ServiceInvoiceHeader: Record "Service Invoice Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + ServiceDocumentPartyTok: Label '/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:BuyerTradeParty', Locked = true; + Path: Text; + begin + Path := ServiceDocumentPartyTok + '/ram:Name'; + Assert.AreEqual(ServiceInvoiceHeader."Bill-to Name", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + + Path := ServiceDocumentPartyTok + '/ram:URIUniversalCommunication/ram:URIID'; + Assert.AreEqual(ServiceInvoiceHeader."E-Mail", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + + Path := ServiceDocumentPartyTok + '/ram:SpecifiedTaxRegistration/ram:ID'; + Assert.AreEqual(GetVATRegistrationNo(ServiceInvoiceHeader."VAT Registration No.", CompanyInformation."Country/Region Code"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + + local procedure VerifyBuyerData(ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + ServiceDocumentBuyerTradePartyTok: Label '/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:BuyerTradeParty', Locked = true; + Path: Text; + begin + Path := ServiceDocumentBuyerTradePartyTok + '/ram:Name'; + Assert.AreEqual(ServiceCrMemoHeader."Bill-to Name", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentBuyerTradePartyTok + '/ram:SpecifiedTaxRegistration/ram:ID'; + Assert.AreEqual(GetVATRegistrationNo(ServiceCrMemoHeader."VAT Registration No.", CompanyInformation."Country/Region Code"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + local procedure VerifyPaymentMeans(var TempXMLBuffer: Record "XML Buffer" temporary; DocumentTok: Text; CurrencyCode: Code[10]); var Path: Text; @@ -1147,6 +1933,24 @@ codeunit 13922 "ZUGFeRD XML Document Tests" Assert.AreEqual(FormatDecimal(GetTotalTaxAmount(SalesCrMemoHeader)), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); end; + local procedure VerifyTaxTotals(ServiceInvoiceHeader: Record "Service Invoice Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + ServiceDocumentTaxTotalTok: Label '/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:ApplicableTradeTax', Locked = true; + Path: Text; + begin + Path := ServiceDocumentTaxTotalTok + '/ram:CalculatedAmount'; + Assert.AreEqual(FormatDecimal(GetTotalTaxAmount(ServiceInvoiceHeader)), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + + local procedure VerifyTaxTotals(ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + ServiceDocumentTaxTotalsTok: Label '/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:ApplicableTradeTax', Locked = true; + Path: Text; + begin + Path := ServiceDocumentTaxTotalsTok + '/ram:CalculatedAmount'; + Assert.AreEqual(FormatDecimal(GetTotalTaxAmount(ServiceCrMemoHeader)), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + local procedure VerifyLegalMonetaryTotal(SalesInvoiceHeader: Record "Sales Invoice Header"; var TempXMLBuffer: Record "XML Buffer" temporary); var LineAmounts: Dictionary of [Text, Decimal]; @@ -1181,6 +1985,40 @@ codeunit 13922 "ZUGFeRD XML Document Tests" Assert.AreEqual(FormatDecimal(LineAmounts.Get(SalesCrMemoHeader.FieldName("Amount Including VAT"))), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); end; + local procedure VerifyLegalMonetaryTotal(ServiceInvoiceHeader: Record "Service Invoice Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + LineAmounts: Dictionary of [Text, Decimal]; + ServiceDocumentLegalMonetaryTotalTok: Label '/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeSettlementHeaderMonetarySummation', Locked = true; + Path: Text; + begin + CalculateLineAmounts(ServiceInvoiceHeader, LineAmounts); + Path := ServiceDocumentLegalMonetaryTotalTok + '/ram:LineTotalAmount'; + Assert.AreEqual(FormatDecimal(LineAmounts.Get(ServiceInvoiceHeader.FieldName(Amount))), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentLegalMonetaryTotalTok + '/ram:TaxBasisTotalAmount'; + Assert.AreEqual(FormatDecimal(LineAmounts.Get(ServiceInvoiceHeader.FieldName(Amount))), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentLegalMonetaryTotalTok + '/ram:GrandTotalAmount'; + Assert.AreEqual(FormatDecimal(LineAmounts.Get(ServiceInvoiceHeader.FieldName("Amount Including VAT"))), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentLegalMonetaryTotalTok + '/ram:DuePayableAmount'; + Assert.AreEqual(FormatDecimal(LineAmounts.Get(ServiceInvoiceHeader.FieldName("Amount Including VAT"))), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + + local procedure VerifyLegalMonetaryTotal(ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + LineAmounts: Dictionary of [Text, Decimal]; + ServiceDocumentLegalMonetaryTotalsTok: Label '/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeSettlementHeaderMonetarySummation', Locked = true; + Path: Text; + begin + CalculateLineAmounts(ServiceCrMemoHeader, LineAmounts); + Path := ServiceDocumentLegalMonetaryTotalsTok + '/ram:LineTotalAmount'; + Assert.AreEqual(FormatDecimal(LineAmounts.Get(ServiceCrMemoHeader.FieldName(Amount))), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentLegalMonetaryTotalsTok + '/ram:TaxBasisTotalAmount'; + Assert.AreEqual(FormatDecimal(LineAmounts.Get(ServiceCrMemoHeader.FieldName(Amount))), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentLegalMonetaryTotalsTok + '/ram:GrandTotalAmount'; + Assert.AreEqual(FormatDecimal(LineAmounts.Get(ServiceCrMemoHeader.FieldName("Amount Including VAT"))), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := ServiceDocumentLegalMonetaryTotalsTok + '/ram:DuePayableAmount'; + Assert.AreEqual(FormatDecimal(LineAmounts.Get(ServiceCrMemoHeader.FieldName("Amount Including VAT"))), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + local procedure VerifyInvoiceLine(SalesInvoiceHeader: Record "Sales Invoice Header"; var TempXMLBuffer: Record "XML Buffer" temporary); var SalesInvoiceLine: Record "Sales Invoice Line"; @@ -1345,6 +2183,94 @@ codeunit 13922 "ZUGFeRD XML Document Tests" Assert.AreEqual(FormatDecimal(SalesCrMemoHeader."Invoice Discount Amount"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); end; + local procedure VerifyServiceInvoiceLine(ServiceInvoiceHeader: Record "Service Invoice Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + ServiceInvoiceLine: Record "Service Invoice Line"; + DocumentTok: Label '/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:IncludedSupplyChainTradeLineItem', Locked = true; + begin + ServiceInvoiceLine.SetRange("Document No.", ServiceInvoiceHeader."No."); + ServiceInvoiceLine.FindSet(); + VerifyFirstServiceInvoiceLine(ServiceInvoiceLine, TempXMLBuffer, DocumentTok); + ServiceInvoiceLine.Next(); + VerifySecondServiceInvoiceLine(ServiceInvoiceLine, TempXMLBuffer, DocumentTok); + end; + + local procedure VerifyFirstServiceInvoiceLine(ServiceInvoiceLine: Record "Service Invoice Line"; var TempXMLBuffer: Record "XML Buffer" temporary; DocumentTok: Text) + var + Path: Text; + begin + Path := DocumentTok + '/ram:AssociatedDocumentLineDocument/ram:LineID'; + Assert.AreEqual(Format(ServiceInvoiceLine."Line No."), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/ram:SpecifiedLineTradeDelivery/ram:BilledQuantity'; + Assert.AreEqual(FormatFourDecimal(ServiceInvoiceLine."Quantity"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/ram:SpecifiedLineTradeSettlement/ram:SpecifiedTradeSettlementLineMonetarySummation/ram:LineTotalAmount'; + Assert.AreEqual(FormatDecimal(ServiceInvoiceLine."Amount"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/ram:SpecifiedTradeProduct/ram:Name'; + Assert.AreEqual(ServiceInvoiceLine."Description", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/ram:SpecifiedLineTradeAgreement/ram:NetPriceProductTradePrice/ram:ChargeAmount'; + Assert.AreEqual(FormatFourDecimal(ServiceInvoiceLine."Unit Price"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + + local procedure VerifySecondServiceInvoiceLine(ServiceInvoiceLine: Record "Service Invoice Line"; var TempXMLBuffer: Record "XML Buffer" temporary; DocumentTok: Text) + var + Path: Text; + begin + Path := DocumentTok + '/ram:AssociatedDocumentLineDocument/ram:LineID'; + Assert.AreEqual(Format(ServiceInvoiceLine."Line No."), GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/ram:SpecifiedLineTradeDelivery/ram:BilledQuantity'; + Assert.AreEqual(FormatFourDecimal(ServiceInvoiceLine."Quantity"), GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/ram:SpecifiedLineTradeSettlement/ram:SpecifiedTradeSettlementLineMonetarySummation/ram:LineTotalAmount'; + Assert.AreEqual(FormatDecimal(ServiceInvoiceLine."Amount"), GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/ram:SpecifiedTradeProduct/ram:Name'; + Assert.AreEqual(ServiceInvoiceLine."Description", GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/ram:SpecifiedLineTradeAgreement/ram:NetPriceProductTradePrice/ram:ChargeAmount'; + Assert.AreEqual(FormatFourDecimal(ServiceInvoiceLine."Unit Price"), GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + + local procedure VerifyServiceCrMemoLine(ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var TempXMLBuffer: Record "XML Buffer" temporary) + var + ServiceCrMemoLine: Record "Service Cr.Memo Line"; + DocumentTok: Label '/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:IncludedSupplyChainTradeLineItem', Locked = true; + begin + ServiceCrMemoLine.SetRange("Document No.", ServiceCrMemoHeader."No."); + ServiceCrMemoLine.FindSet(); + VerifyFirstServiceCrMemoLine(ServiceCrMemoLine, TempXMLBuffer, DocumentTok); + ServiceCrMemoLine.Next(); + VerifySecondServiceCrMemoLine(ServiceCrMemoLine, TempXMLBuffer, DocumentTok); + end; + + local procedure VerifyFirstServiceCrMemoLine(ServiceCrMemoLine: Record "Service Cr.Memo Line"; var TempXMLBuffer: Record "XML Buffer" temporary; DocumentTok: Text) + var + Path: Text; + begin + Path := DocumentTok + '/ram:AssociatedDocumentLineDocument/ram:LineID'; + Assert.AreEqual(Format(ServiceCrMemoLine."Line No."), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/ram:SpecifiedLineTradeDelivery/ram:BilledQuantity'; + Assert.AreEqual(FormatFourDecimal(ServiceCrMemoLine."Quantity"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/ram:SpecifiedLineTradeSettlement/ram:SpecifiedTradeSettlementLineMonetarySummation/ram:LineTotalAmount'; + Assert.AreEqual(FormatDecimal(ServiceCrMemoLine."Amount"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/ram:SpecifiedTradeProduct/ram:Name'; + Assert.AreEqual(ServiceCrMemoLine."Description", GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/ram:SpecifiedLineTradeAgreement/ram:NetPriceProductTradePrice/ram:ChargeAmount'; + Assert.AreEqual(FormatFourDecimal(ServiceCrMemoLine."Unit Price"), GetNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + + local procedure VerifySecondServiceCrMemoLine(ServiceCrMemoLine: Record "Service Cr.Memo Line"; var TempXMLBuffer: Record "XML Buffer" temporary; DocumentTok: Text) + var + Path: Text; + begin + Path := DocumentTok + '/ram:AssociatedDocumentLineDocument/ram:LineID'; + Assert.AreEqual(Format(ServiceCrMemoLine."Line No."), GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/ram:SpecifiedLineTradeDelivery/ram:BilledQuantity'; + Assert.AreEqual(FormatFourDecimal(ServiceCrMemoLine."Quantity"), GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/ram:SpecifiedLineTradeSettlement/ram:SpecifiedTradeSettlementLineMonetarySummation/ram:LineTotalAmount'; + Assert.AreEqual(FormatDecimal(ServiceCrMemoLine."Amount"), GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/ram:SpecifiedTradeProduct/ram:Name'; + Assert.AreEqual(ServiceCrMemoLine."Description", GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + Path := DocumentTok + '/ram:SpecifiedLineTradeAgreement/ram:NetPriceProductTradePrice/ram:ChargeAmount'; + Assert.AreEqual(FormatFourDecimal(ServiceCrMemoLine."Unit Price"), GetLastNodeByPathWithError(TempXMLBuffer, Path), StrSubstNo(IncorrectValueErr, Path)); + end; + local procedure GetCurrencyCode(CurrencyCode: Code[10]): Code[10]; begin if CurrencyCode <> '' then @@ -1448,6 +2374,32 @@ codeunit 13922 "ZUGFeRD XML Document Tests" LineAmounts.Add(SalesCrMemoLine.FieldName("Inv. Discount Amount"), SalesCrMemoLine."Inv. Discount Amount"); end; + local procedure CalculateLineAmounts(ServiceInvoiceHeader: Record "Service Invoice Header"; var LineAmounts: Dictionary of [Text, Decimal]) + var + ServiceInvoiceLine: Record "Service Invoice Line"; + begin + ServiceInvoiceLine.SetRange("Document No.", ServiceInvoiceHeader."No."); + ServiceInvoiceLine.CalcSums(Amount, "Amount Including VAT"); + + if not LineAmounts.ContainsKey(ServiceInvoiceLine.FieldName(Amount)) then + LineAmounts.Add(ServiceInvoiceLine.FieldName(Amount), ServiceInvoiceLine.Amount); + if not LineAmounts.ContainsKey(ServiceInvoiceLine.FieldName("Amount Including VAT")) then + LineAmounts.Add(ServiceInvoiceLine.FieldName("Amount Including VAT"), ServiceInvoiceLine."Amount Including VAT"); + end; + + local procedure CalculateLineAmounts(ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var LineAmounts: Dictionary of [Text, Decimal]) + var + ServiceCrMemoLine: Record "Service Cr.Memo Line"; + begin + ServiceCrMemoLine.SetRange("Document No.", ServiceCrMemoHeader."No."); + ServiceCrMemoLine.CalcSums(Amount, "Amount Including VAT"); + + if not LineAmounts.ContainsKey(ServiceCrMemoLine.FieldName(Amount)) then + LineAmounts.Add(ServiceCrMemoLine.FieldName(Amount), ServiceCrMemoLine.Amount); + if not LineAmounts.ContainsKey(ServiceCrMemoLine.FieldName("Amount Including VAT")) then + LineAmounts.Add(ServiceCrMemoLine.FieldName("Amount Including VAT"), ServiceCrMemoLine."Amount Including VAT"); + end; + local procedure GetTotalTaxAmount(SalesInvoiceHeader: Record "Sales Invoice Header"): Decimal var SalesInvLine: Record "Sales Invoice Line"; @@ -1478,6 +2430,36 @@ codeunit 13922 "ZUGFeRD XML Document Tests" exit(SalesCrMemoLine."Amount Including VAT" - SalesCrMemoLine.Amount); end; + local procedure GetTotalTaxAmount(ServiceInvoiceHeader: Record "Service Invoice Header"): Decimal + var + ServiceInvoiceLine: Record "Service Invoice Line"; + begin + ServiceInvoiceLine.SetRange("Document No.", ServiceInvoiceHeader."No."); + ServiceInvoiceLine.SetFilter( + "VAT Calculation Type", '%1|%2|%3', + ServiceInvoiceLine."VAT Calculation Type"::"Normal VAT", + ServiceInvoiceLine."VAT Calculation Type"::"Full VAT", + ServiceInvoiceLine."VAT Calculation Type"::"Reverse Charge VAT"); + ServiceInvoiceLine.CalcSums(Amount, "Amount Including VAT"); + ServiceInvoiceLine.SetRange("VAT Calculation Type"); + exit(ServiceInvoiceLine."Amount Including VAT" - ServiceInvoiceLine.Amount); + end; + + local procedure GetTotalTaxAmount(ServiceCrMemoHeader: Record "Service Cr.Memo Header"): Decimal + var + ServiceCrMemoLine: Record "Service Cr.Memo Line"; + begin + ServiceCrMemoLine.SetRange("Document No.", ServiceCrMemoHeader."No."); + ServiceCrMemoLine.SetFilter( + "VAT Calculation Type", '%1|%2|%3', + ServiceCrMemoLine."VAT Calculation Type"::"Normal VAT", + ServiceCrMemoLine."VAT Calculation Type"::"Full VAT", + ServiceCrMemoLine."VAT Calculation Type"::"Reverse Charge VAT"); + ServiceCrMemoLine.CalcSums(Amount, "Amount Including VAT"); + ServiceCrMemoLine.SetRange("VAT Calculation Type"); + exit(ServiceCrMemoLine."Amount Including VAT" - ServiceCrMemoLine.Amount); + end; + local procedure GetCurrencyCode(DocumentCurrencyCode: Code[10]; var Currency: Record Currency): Code[10] begin if DocumentCurrencyCode = '' then begin @@ -1546,4 +2528,10 @@ codeunit 13922 "ZUGFeRD XML Document Tests" LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::"ZUGFeRD XML Document Tests"); end; + + [ConfirmHandler] + procedure ConfirmHandlerYes(Question: Text[1024]; var Reply: Boolean) + begin + Reply := true; + end; } \ No newline at end of file diff --git a/Apps/ES/ContosoCoffeeDemoDatasetES/app/DemoData/Finance/2.Master Data/CreateESCurrencyExch.Codeunit.al b/Apps/ES/ContosoCoffeeDemoDatasetES/app/DemoData/Finance/2.Master Data/CreateESCurrencyExch.Codeunit.al index c9a5e423cf..8acebb9f31 100644 --- a/Apps/ES/ContosoCoffeeDemoDatasetES/app/DemoData/Finance/2.Master Data/CreateESCurrencyExch.Codeunit.al +++ b/Apps/ES/ContosoCoffeeDemoDatasetES/app/DemoData/Finance/2.Master Data/CreateESCurrencyExch.Codeunit.al @@ -189,4 +189,14 @@ codeunit 10834 "Create ES Currency Exch" CurrencyExchangeRate.Validate("Relational Exch. Rate Amount", RelationalExchRateAmount); CurrencyExchangeRate.Validate("Relational Adjmt Exch Rate Amt", RelationalAdjmtExchRateAmt); end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Add. Reporting Currency", OnBeforeGetResidualCurrencyAccounts, '', false, false)] + local procedure GetResidualCurrencyAccountsES(var FXGainsAccount: Code[20]; var FXLossesAccount: Code[20]; var IsHandled: Boolean) + var + CreateESGLAccount: Codeunit "Create ES GL Accounts"; + begin + FXGainsAccount := CreateESGLAccount.ExchangeGainPosting(); + FXLossesAccount := CreateESGLAccount.RealizedLossesOnExchange(); + IsHandled := true; + end; } diff --git a/Apps/ES/EDocumentFormats/DocumentRegistration/app/src/Core/VerifactuExport.Codeunit.al b/Apps/ES/EDocumentFormats/DocumentRegistration/app/src/Core/VerifactuExport.Codeunit.al index d5694080d3..4b32b7d831 100644 --- a/Apps/ES/EDocumentFormats/DocumentRegistration/app/src/Core/VerifactuExport.Codeunit.al +++ b/Apps/ES/EDocumentFormats/DocumentRegistration/app/src/Core/VerifactuExport.Codeunit.al @@ -7,7 +7,6 @@ namespace Microsoft.EServices.EDocument.Verifactu; using Microsoft.EServices.EDocument; using Microsoft.Foundation.Address; using Microsoft.Foundation.Company; -using Microsoft.Sales.Customer; using Microsoft.Sales.History; using Microsoft.Service.History; using System.Reflection; @@ -63,28 +62,32 @@ codeunit 10778 "Verifactu Export" Database::"Sales Invoice Header": begin SourceDocumentHeader.SetTable(SalesInvoiceHeader); - SalesInvoiceHeader.SetRecFilter(); + if not IsBatch then + SalesInvoiceHeader.SetRecFilter(); SourceDocumentLines.SetTable(SalesInvoiceLine); ExportInvoice(EDocument, SalesInvoiceHeader, SalesInvoiceLine, TempBlob, IsBatch); end; Database::"Sales Cr.Memo Header": begin SourceDocumentHeader.SetTable(SalesCrMemoHeader); - SalesCrMemoHeader.SetRecFilter(); + if not IsBatch then + SalesCrMemoHeader.SetRecFilter(); SourceDocumentLines.SetTable(SalesCrMemoLine); ExportCreditMemo(EDocument, SalesCrMemoHeader, SalesCrMemoLine, TempBlob, IsBatch); end; Database::"Service Invoice Header": begin SourceDocumentHeader.SetTable(ServiceInvoiceHeader); - ServiceInvoiceHeader.SetRecFilter(); + if not IsBatch then + ServiceInvoiceHeader.SetRecFilter(); SourceDocumentLines.SetTable(ServiceInvoiceLine); ExportServiceInvoice(EDocument, ServiceInvoiceHeader, ServiceInvoiceLine, TempBlob, IsBatch); end; Database::"Service Cr.Memo Header": begin SourceDocumentHeader.SetTable(ServiceCrMemoHeader); - ServiceCrMemoHeader.SetRecFilter(); + if not IsBatch then + ServiceCrMemoHeader.SetRecFilter(); SourceDocumentLines.SetTable(ServiceCrMemoLine); ExportServiceCreditMemo(EDocument, ServiceCrMemoHeader, ServiceCrMemoLine, TempBlob, IsBatch); end; @@ -95,36 +98,10 @@ codeunit 10778 "Verifactu Export" #region Invoice local procedure ExportInvoice(var EDocument: Record "E-Document"; var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesInvoiceLine: Record "Sales Invoice Line"; var TempBlob: Codeunit "Temp Blob"; IsBatch: Boolean) - var - TempBlobQR: Codeunit "Temp Blob"; - InvoiceType, VerifactuDateTime : Text; - PreviousDocumentNo, PreviousHuella : Text; - VerifactuHash: Text[64]; - PreviousPostingDate: Date; - FileOutStream, OutStr : OutStream; - InStr: InStream; - begin - SalesInvoiceHeader.CalcFields(Amount, "Amount Including VAT"); - InvoiceType := GetOptionFirstTwoChars(SalesInvoiceHeader."Invoice Type"); - VerifactuDateTime := GetCustomDateTimeFormat(CurrentDateTime()); - FindLastRegisteredDocument(PreviousDocumentNo, PreviousPostingDate, PreviousHuella); - VerifactuHash := GenerateHash(SalesInvoiceHeader, InvoiceType, VerifactuDateTime, PreviousHuella); - VerifactuDocUploadMgt.InsertVerifactuDocument(EDocument, SalesInvoiceHeader."No.", SalesInvoiceHeader."Posting Date", VerifactuHash); - - CreateXML(SalesInvoiceHeader, SalesInvoiceLine, IsBatch, TempBlob, FileOutStream, InvoiceType, VerifactuDateTime, VerifactuHash, PreviousDocumentNo, PreviousPostingDate, PreviousHuella); - - TempBlobQR := GenerateQRCode(SalesInvoiceHeader."No.", SalesInvoiceHeader."Posting Date", SalesInvoiceHeader."Amount Including VAT"); - TempBlobQR.CreateInStream(InStr); - SalesInvoiceHeader."QR Code Base64".CreateOutStream(OutStr, TextEncoding::UTF8); - CopyStream(OutStr, InStr); - SalesInvoiceHeader."QR Code Image".ImportStream(InStr, 'image.png'); - SalesInvoiceHeader.Modify(); - end; - - local procedure CreateXML(var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesInvoiceLine: Record "Sales Invoice Line"; IsBatch: Boolean; var TempBlob: Codeunit "Temp Blob"; var FileOutStream: OutStream; InvoiceType: Text; VerifactuDateTime: Text; VerifactuHash: Text[64]; PreviousDocumentNo: Text; PreviousPostingDate: Date; PreviousHuella: Text) var HeaderXMLNode, BodyXMLNode, RegFactuSistemaFacturacionXMLNode, RootXMLNode : XmlElement; XMLDocOut: XmlDocument; + FileOutStream: OutStream; begin TempBlob.CreateOutStream(FileOutStream, TextEncoding::UTF8); @@ -136,7 +113,7 @@ codeunit 10778 "Verifactu Export" BodyXMLNode := XmlElement.Create('Body', XmlNamespaceSoapenv); RegFactuSistemaFacturacionXMLNode := XmlElement.Create('RegFactuSistemaFacturacion', XmlNamespaceSum); InsertHeaderData(RegFactuSistemaFacturacionXMLNode); - InsertInvoicesData(RegFactuSistemaFacturacionXMLNode, SalesInvoiceHeader, SalesInvoiceLine, IsBatch, InvoiceType, VerifactuDateTime, VerifactuHash, PreviousDocumentNo, PreviousPostingDate, PreviousHuella); + InsertInvoicesData(RegFactuSistemaFacturacionXMLNode, SalesInvoiceHeader, SalesInvoiceLine, IsBatch, EDocument); BodyXMLNode.Add(RegFactuSistemaFacturacionXMLNode); RootXMLNode.Add(HeaderXMLNode); @@ -145,29 +122,46 @@ codeunit 10778 "Verifactu Export" XmlDocOut.WriteTo(FileOutStream); end; - local procedure InsertInvoicesData(var RootXMLNode: XmlElement; var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesInvoiceLine: Record "Sales Invoice Line"; IsBatch: Boolean; InvoiceType: Text; VerifactuDateTime: Text; VerifactuHash: Text[64]; PreviousDocumentNo: Text; PreviousPostingDate: Date; PreviousHuella: Text) + local procedure InsertInvoicesData(var RootXMLNode: XmlElement; var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesInvoiceLine: Record "Sales Invoice Line"; IsBatch: Boolean; var EDocument: Record "E-Document") var InvoiceXMLNode: XmlElement; InvoiceCount: Integer; begin InvoiceXMLNode := XmlElement.Create('RegistroFactura', XmlNamespaceSum); - if IsBatch then + if IsBatch then begin + SalesInvoiceHeader.SetAutoCalcFields(Amount, "Amount Including VAT"); + SalesInvoiceHeader.FindSet(); repeat InvoiceCount += 1; if InvoiceCount > 1000 then Error(MaxBatchSizeErr); - InsertInvoice(InvoiceXMLNode, SalesInvoiceHeader, SalesInvoiceLine, InvoiceType, VerifactuDateTime, VerifactuHash, PreviousDocumentNo, PreviousPostingDate, PreviousHuella); - until SalesInvoiceHeader.Next() = 0 - else - InsertInvoice(InvoiceXMLNode, SalesInvoiceHeader, SalesInvoiceLine, InvoiceType, VerifactuDateTime, VerifactuHash, PreviousDocumentNo, PreviousPostingDate, PreviousHuella); + InsertInvoice(InvoiceXMLNode, SalesInvoiceHeader, SalesInvoiceLine, EDocument); + until SalesInvoiceHeader.Next() = 0; + end else begin + SalesInvoiceHeader.CalcFields(Amount, "Amount Including VAT"); + InsertInvoice(InvoiceXMLNode, SalesInvoiceHeader, SalesInvoiceLine, EDocument); + end; RootXMLNode.Add(InvoiceXMLNode); end; - local procedure InsertInvoice(var RootXMLNode: XmlElement; var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesInvoiceLine: Record "Sales Invoice Line"; InvoiceType: Text; VerifactuDateTime: Text; VerifactuHash: Text[64]; PreviousDocumentNo: Text; PreviousPostingDate: Date; PreviousHuella: Text) + local procedure InsertInvoice(var RootXMLNode: XmlElement; var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesInvoiceLine: Record "Sales Invoice Line"; var EDocument: Record "E-Document") var + TempBlobQR: Codeunit "Temp Blob"; + InvoiceType, VerifactuDateTime : Text; + PreviousDocumentNo, PreviousHuella : Text; + VerifactuHash: Text[64]; + PreviousPostingDate: Date; InvoiceXMLNode: XmlElement; + OutStr: OutStream; + InStr: InStream; begin + InvoiceType := GetOptionFirstTwoChars(SalesInvoiceHeader."Invoice Type"); + VerifactuDateTime := GetCustomDateTimeFormat(CurrentDateTime()); + FindLastRegisteredDocument(PreviousDocumentNo, PreviousPostingDate, PreviousHuella); + VerifactuHash := GenerateHash(SalesInvoiceHeader, InvoiceType, VerifactuDateTime, PreviousHuella); + VerifactuDocUploadMgt.InsertVerifactuDocument(EDocument, SalesInvoiceHeader."No.", SalesInvoiceHeader."Posting Date", VerifactuHash); + InvoiceXMLNode := XmlElement.Create('RegistroAlta', XmlNamespaceSum1); InsertInvoiceHeaderData(InvoiceXMLNode, SalesInvoiceHeader, InvoiceType); @@ -178,6 +172,13 @@ codeunit 10778 "Verifactu Export" InsertHuellaDigital(InvoiceXMLNode, VerifactuDateTime, VerifactuHash); RootXMLNode.Add(InvoiceXMLNode); + + TempBlobQR := GenerateQRCode(SalesInvoiceHeader."No.", SalesInvoiceHeader."Posting Date", SalesInvoiceHeader."Amount Including VAT"); + TempBlobQR.CreateInStream(InStr); + SalesInvoiceHeader."QR Code Base64".CreateOutStream(OutStr, TextEncoding::UTF8); + CopyStream(OutStr, InStr); + SalesInvoiceHeader."QR Code Image".ImportStream(InStr, 'image.png'); + SalesInvoiceHeader.Modify(); end; local procedure InsertInvoiceHeaderData(var InvoiceXMLNode: XmlElement; var SalesInvoiceHeader: Record "Sales Invoice Header"; InvoiceType: Text) @@ -287,28 +288,10 @@ codeunit 10778 "Verifactu Export" #endregion #region Service Invoice local procedure ExportServiceInvoice(var EDocument: Record "E-Document"; var ServiceInvoiceHeader: Record "Service Invoice Header"; var ServiceInvoiceLine: Record "Service Invoice Line"; var TempBlob: Codeunit "Temp Blob"; IsBatch: Boolean) - var - InvoiceType, VerifactuDateTime : Text; - PreviousDocumentNo, PreviousHuella : Text; - VerifactuHash: Text[64]; - PreviousPostingDate: Date; - FileOutStream: OutStream; - begin - ServiceInvoiceHeader.CalcFields(Amount, "Amount Including VAT"); - InvoiceType := GetOptionFirstTwoChars(ServiceInvoiceHeader."Invoice Type"); - VerifactuDateTime := GetCustomDateTimeFormat(CurrentDateTime()); - FindLastRegisteredDocument(PreviousDocumentNo, PreviousPostingDate, PreviousHuella); - VerifactuHash := GenerateHash(ServiceInvoiceHeader, InvoiceType, VerifactuDateTime, PreviousHuella); - VerifactuDocUploadMgt.InsertVerifactuDocument(EDocument, ServiceInvoiceHeader."No.", ServiceInvoiceHeader."Posting Date", VerifactuHash); - - CreateXML(ServiceInvoiceHeader, ServiceInvoiceLine, IsBatch, TempBlob, FileOutStream, InvoiceType, VerifactuDateTime, VerifactuHash, PreviousDocumentNo, PreviousPostingDate, PreviousHuella); - ServiceInvoiceHeader.Modify(); - end; - - local procedure CreateXML(var ServiceInvoiceHeader: Record "Service Invoice Header"; var ServiceInvoiceLine: Record "Service Invoice Line"; IsBatch: Boolean; var TempBlob: Codeunit "Temp Blob"; var FileOutStream: OutStream; InvoiceType: Text; VerifactuDateTime: Text; VerifactuHash: Text[64]; PreviousDocumentNo: Text; PreviousPostingDate: Date; PreviousHuella: Text) var HeaderXMLNode, BodyXMLNode, RegFactuSistemaFacturacionXMLNode, RootXMLNode : XmlElement; XMLDocOut: XmlDocument; + FileOutStream: OutStream; begin TempBlob.CreateOutStream(FileOutStream, TextEncoding::UTF8); @@ -320,7 +303,7 @@ codeunit 10778 "Verifactu Export" BodyXMLNode := XmlElement.Create('Body', XmlNamespaceSoapenv); RegFactuSistemaFacturacionXMLNode := XmlElement.Create('RegFactuSistemaFacturacion', XmlNamespaceSum); InsertHeaderData(RegFactuSistemaFacturacionXMLNode); - InsertServiceInvoicesData(RegFactuSistemaFacturacionXMLNode, ServiceInvoiceHeader, ServiceInvoiceLine, IsBatch, InvoiceType, VerifactuDateTime, VerifactuHash, PreviousDocumentNo, PreviousPostingDate, PreviousHuella); + InsertServiceInvoicesData(RegFactuSistemaFacturacionXMLNode, ServiceInvoiceHeader, ServiceInvoiceLine, IsBatch, EDocument); BodyXMLNode.Add(RegFactuSistemaFacturacionXMLNode); RootXMLNode.Add(HeaderXMLNode); @@ -329,25 +312,46 @@ codeunit 10778 "Verifactu Export" XmlDocOut.WriteTo(FileOutStream); end; - local procedure InsertServiceInvoicesData(var RootXMLNode: XmlElement; var ServiceInvoiceHeader: Record "Service Invoice Header"; var ServiceInvoiceLine: Record "Service Invoice Line"; IsBatch: Boolean; InvoiceType: Text; VerifactuDateTime: Text; VerifactuHash: Text[64]; PreviousDocumentNo: Text; PreviousPostingDate: Date; PreviousHuella: Text) + local procedure InsertServiceInvoicesData(var RootXMLNode: XmlElement; var ServiceInvoiceHeader: Record "Service Invoice Header"; var ServiceInvoiceLine: Record "Service Invoice Line"; IsBatch: Boolean; var EDocument: Record "E-Document") var InvoiceXMLNode: XmlElement; + InvoiceCount: Integer; begin InvoiceXMLNode := XmlElement.Create('RegistroFactura', XmlNamespaceSum); - if IsBatch then + if IsBatch then begin + ServiceInvoiceHeader.SetAutoCalcFields(Amount, "Amount Including VAT"); + ServiceInvoiceHeader.FindSet(); repeat - InsertServiceInvoice(InvoiceXMLNode, ServiceInvoiceHeader, ServiceInvoiceLine, InvoiceType, VerifactuDateTime, VerifactuHash, PreviousDocumentNo, PreviousPostingDate, PreviousHuella); - until ServiceInvoiceHeader.Next() = 0 - else - InsertServiceInvoice(InvoiceXMLNode, ServiceInvoiceHeader, ServiceInvoiceLine, InvoiceType, VerifactuDateTime, VerifactuHash, PreviousDocumentNo, PreviousPostingDate, PreviousHuella); + InvoiceCount += 1; + if InvoiceCount > 1000 then + Error(MaxBatchSizeErr); + InsertServiceInvoice(InvoiceXMLNode, ServiceInvoiceHeader, ServiceInvoiceLine, EDocument); + until ServiceInvoiceHeader.Next() = 0; + end else begin + ServiceInvoiceHeader.CalcFields(Amount, "Amount Including VAT"); + InsertServiceInvoice(InvoiceXMLNode, ServiceInvoiceHeader, ServiceInvoiceLine, EDocument); + end; RootXMLNode.Add(InvoiceXMLNode); end; - local procedure InsertServiceInvoice(var RootXMLNode: XmlElement; var ServiceInvoiceHeader: Record "Service Invoice Header"; var ServiceInvoiceLine: Record "Service Invoice Line"; InvoiceType: Text; VerifactuDateTime: Text; VerifactuHash: Text[64]; PreviousDocumentNo: Text; PreviousPostingDate: Date; PreviousHuella: Text) + local procedure InsertServiceInvoice(var RootXMLNode: XmlElement; var ServiceInvoiceHeader: Record "Service Invoice Header"; var ServiceInvoiceLine: Record "Service Invoice Line"; var EDocument: Record "E-Document") var + TempBlobQR: Codeunit "Temp Blob"; + InvoiceType, VerifactuDateTime : Text; + PreviousDocumentNo, PreviousHuella : Text; + VerifactuHash: Text[64]; + PreviousPostingDate: Date; InvoiceXMLNode: XmlElement; + OutStr: OutStream; + InStr: InStream; begin + InvoiceType := GetOptionFirstTwoChars(ServiceInvoiceHeader."Invoice Type"); + VerifactuDateTime := GetCustomDateTimeFormat(CurrentDateTime()); + FindLastRegisteredDocument(PreviousDocumentNo, PreviousPostingDate, PreviousHuella); + VerifactuHash := GenerateHash(ServiceInvoiceHeader, InvoiceType, VerifactuDateTime, PreviousHuella); + VerifactuDocUploadMgt.InsertVerifactuDocument(EDocument, ServiceInvoiceHeader."No.", ServiceInvoiceHeader."Posting Date", VerifactuHash); + InvoiceXMLNode := XmlElement.Create('RegistroAlta', XmlNamespaceSum1); InsertServiceInvoiceHeaderData(InvoiceXMLNode, ServiceInvoiceHeader, InvoiceType); @@ -358,6 +362,13 @@ codeunit 10778 "Verifactu Export" InsertHuellaDigital(InvoiceXMLNode, VerifactuDateTime, VerifactuHash); RootXMLNode.Add(InvoiceXMLNode); + + TempBlobQR := GenerateQRCode(ServiceInvoiceHeader."No.", ServiceInvoiceHeader."Posting Date", ServiceInvoiceHeader."Amount Including VAT"); + TempBlobQR.CreateInStream(InStr); + ServiceInvoiceHeader."QR Code Base64".CreateOutStream(OutStr, TextEncoding::UTF8); + CopyStream(OutStr, InStr); + ServiceInvoiceHeader."QR Code Image".ImportStream(InStr, 'image.png'); + ServiceInvoiceHeader.Modify(); end; local procedure InsertServiceInvoiceHeaderData(var InvoiceXMLNode: XmlElement; var ServiceInvoiceHeader: Record "Service Invoice Header"; InvoiceType: Text) @@ -467,36 +478,10 @@ codeunit 10778 "Verifactu Export" #endregion #region Credit Memo local procedure ExportCreditMemo(var EDocument: Record "E-Document"; var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; var SalesCrMemoLine: Record "Sales Cr.Memo Line"; var TempBlob: Codeunit "Temp Blob"; IsBatch: Boolean) - var - TempBlobQR: Codeunit "Temp Blob"; - InvoiceType, VerifactuDateTime : Text; - PreviousDocumentNo, PreviousHuella : Text; - VerifactuHash: Text[64]; - PreviousPostingDate: Date; - FileOutStream, OutStr : OutStream; - InStr: InStream; - begin - SalesCrMemoHeader.CalcFields(Amount, "Amount Including VAT"); - InvoiceType := GetOptionFirstTwoChars(SalesCrMemoHeader."Cr. Memo Type"); - VerifactuDateTime := GetCustomDateTimeFormat(CurrentDateTime()); - FindLastRegisteredDocument(PreviousDocumentNo, PreviousPostingDate, PreviousHuella); - VerifactuHash := GenerateHash(SalesCrMemoHeader, InvoiceType, VerifactuDateTime, PreviousHuella); - VerifactuDocUploadMgt.InsertVerifactuDocument(EDocument, SalesCrMemoHeader."No.", SalesCrMemoHeader."Posting Date", VerifactuHash); - - CreateXML(SalesCrMemoHeader, SalesCrMemoLine, IsBatch, TempBlob, FileOutStream, InvoiceType, VerifactuDateTime, VerifactuHash, PreviousDocumentNo, PreviousPostingDate, PreviousHuella); - - TempBlobQR := GenerateQRCode(SalesCrMemoHeader."No.", SalesCrMemoHeader."Posting Date", SalesCrMemoHeader."Amount Including VAT"); - TempBlobQR.CreateInStream(InStr); - SalesCrMemoHeader."QR Code Base64".CreateOutStream(OutStr, TextEncoding::UTF8); - CopyStream(OutStr, InStr); - SalesCrMemoHeader."QR Code Image".ImportStream(InStr, 'image.png'); - SalesCrMemoHeader.Modify(); - end; - - local procedure CreateXML(var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; var SalesCrMemoLine: Record "Sales Cr.Memo Line"; IsBatch: Boolean; var TempBlob: Codeunit "Temp Blob"; var FileOutStream: OutStream; InvoiceType: Text; VerifactuDateTime: Text; VerifactuHash: Text[64]; PreviousDocumentNo: Text; PreviousPostingDate: Date; PreviousHuella: Text) var HeaderXMLNode, BodyXMLNode, RegFactuSistemaFacturacionXMLNode, RootXMLNode : XmlElement; XMLDocOut: XmlDocument; + FileOutStream: OutStream; begin TempBlob.CreateOutStream(FileOutStream, TextEncoding::UTF8); @@ -508,7 +493,7 @@ codeunit 10778 "Verifactu Export" BodyXMLNode := XmlElement.Create('Body', XmlNamespaceSoapenv); RegFactuSistemaFacturacionXMLNode := XmlElement.Create('RegFactuSistemaFacturacion', XmlNamespaceSum); InsertHeaderData(RegFactuSistemaFacturacionXMLNode); - InsertCreditMemosData(RegFactuSistemaFacturacionXMLNode, SalesCrMemoHeader, SalesCrMemoLine, IsBatch, InvoiceType, VerifactuDateTime, VerifactuHash, PreviousDocumentNo, PreviousPostingDate, PreviousHuella); + InsertCreditMemosData(RegFactuSistemaFacturacionXMLNode, SalesCrMemoHeader, SalesCrMemoLine, IsBatch, EDocument); BodyXMLNode.Add(RegFactuSistemaFacturacionXMLNode); RootXMLNode.Add(HeaderXMLNode); @@ -517,31 +502,45 @@ codeunit 10778 "Verifactu Export" XmlDocOut.WriteTo(FileOutStream); end; - local procedure InsertCreditMemosData(var RootXMLNode: XmlElement; var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; var SalesCrMemoLine: Record "Sales Cr.Memo Line"; IsBatch: Boolean; InvoiceType: Text; VerifactuDateTime: Text; VerifactuHash: Text[64]; PreviousDocumentNo: Text; PreviousPostingDate: Date; PreviousHuella: Text) + local procedure InsertCreditMemosData(var RootXMLNode: XmlElement; var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; var SalesCrMemoLine: Record "Sales Cr.Memo Line"; IsBatch: Boolean; var EDocument: Record "E-Document") var CreditMemoXMLNode: XmlElement; CreditMemoCount: Integer; begin CreditMemoXMLNode := XmlElement.Create('RegistroFactura', XmlNamespaceSum); - if IsBatch then + if IsBatch then begin + SalesCrMemoHeader.SetAutoCalcFields(Amount, "Amount Including VAT"); + SalesCrMemoHeader.FindSet(); repeat CreditMemoCount += 1; if CreditMemoCount > 1000 then Error(MaxBatchSizeErr); - InsertCreditMemo(CreditMemoXMLNode, SalesCrMemoHeader, SalesCrMemoLine, InvoiceType, VerifactuDateTime, VerifactuHash, PreviousDocumentNo, PreviousPostingDate, PreviousHuella); - until SalesCrMemoHeader.Next() = 0 - else - InsertCreditMemo(CreditMemoXMLNode, SalesCrMemoHeader, SalesCrMemoLine, InvoiceType, VerifactuDateTime, VerifactuHash, PreviousDocumentNo, PreviousPostingDate, PreviousHuella); + InsertCreditMemo(CreditMemoXMLNode, SalesCrMemoHeader, SalesCrMemoLine, EDocument); + until SalesCrMemoHeader.Next() = 0; + end else begin + SalesCrMemoHeader.CalcFields(Amount, "Amount Including VAT"); + InsertCreditMemo(CreditMemoXMLNode, SalesCrMemoHeader, SalesCrMemoLine, EDocument); + end; RootXMLNode.Add(CreditMemoXMLNode); end; - local procedure InsertCreditMemo(var RootXMLNode: XmlElement; var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; var SalesCrMemoLine: Record "Sales Cr.Memo Line"; InvoiceType: Text; VerifactuDateTime: Text; VerifactuHash: Text[64]; PreviousDocumentNo: Text; PreviousPostingDate: Date; PreviousHuella: Text) + local procedure InsertCreditMemo(var RootXMLNode: XmlElement; var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; var SalesCrMemoLine: Record "Sales Cr.Memo Line"; var EDocument: Record "E-Document") var - Customer: Record Customer; + TempBlobQR: Codeunit "Temp Blob"; + InvoiceType, VerifactuDateTime : Text; + PreviousDocumentNo, PreviousHuella : Text; + VerifactuHash: Text[64]; + PreviousPostingDate: Date; CrMemoXMLNode: XmlElement; + OutStr: OutStream; + InStr: InStream; begin - Customer.Get(SalesCrMemoHeader."Bill-to Customer No."); + InvoiceType := GetOptionFirstTwoChars(SalesCrMemoHeader."Cr. Memo Type"); + VerifactuDateTime := GetCustomDateTimeFormat(CurrentDateTime()); + FindLastRegisteredDocument(PreviousDocumentNo, PreviousPostingDate, PreviousHuella); + VerifactuHash := GenerateHash(SalesCrMemoHeader, InvoiceType, VerifactuDateTime, PreviousHuella); + VerifactuDocUploadMgt.InsertVerifactuDocument(EDocument, SalesCrMemoHeader."No.", SalesCrMemoHeader."Posting Date", VerifactuHash); CrMemoXMLNode := XmlElement.Create('RegistroAlta', XmlNamespaceSum1); @@ -553,6 +552,13 @@ codeunit 10778 "Verifactu Export" InsertHuellaDigital(CrMemoXMLNode, VerifactuDateTime, VerifactuHash); RootXMLNode.Add(CrMemoXMLNode); + + TempBlobQR := GenerateQRCode(SalesCrMemoHeader."No.", SalesCrMemoHeader."Posting Date", SalesCrMemoHeader."Amount Including VAT"); + TempBlobQR.CreateInStream(InStr); + SalesCrMemoHeader."QR Code Base64".CreateOutStream(OutStr, TextEncoding::UTF8); + CopyStream(OutStr, InStr); + SalesCrMemoHeader."QR Code Image".ImportStream(InStr, 'image.png'); + SalesCrMemoHeader.Modify(); end; local procedure InsertCreditMemoHeaderData(var InvoiceXMLNode: XmlElement; var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; InvoiceType: Text) @@ -681,29 +687,10 @@ codeunit 10778 "Verifactu Export" #endregion #region Service Credit Memo local procedure ExportServiceCreditMemo(var EDocument: Record "E-Document"; var ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var ServiceCrMemoLine: Record "Service Cr.Memo Line"; var TempBlob: Codeunit "Temp Blob"; IsBatch: Boolean) - var - InvoiceType, VerifactuDateTime : Text; - PreviousDocumentNo, PreviousHuella : Text; - VerifactuHash: Text[64]; - PreviousPostingDate: Date; - FileOutStream: OutStream; - begin - ServiceCrMemoHeader.CalcFields(Amount, "Amount Including VAT"); - InvoiceType := GetOptionFirstTwoChars(ServiceCrMemoHeader."Cr. Memo Type"); - VerifactuDateTime := GetCustomDateTimeFormat(CurrentDateTime()); - FindLastRegisteredDocument(PreviousDocumentNo, PreviousPostingDate, PreviousHuella); - VerifactuHash := GenerateHash(ServiceCrMemoHeader, InvoiceType, VerifactuDateTime, PreviousHuella); - VerifactuDocUploadMgt.InsertVerifactuDocument(EDocument, ServiceCrMemoHeader."No.", ServiceCrMemoHeader."Posting Date", VerifactuHash); - - CreateXML(ServiceCrMemoHeader, ServiceCrMemoLine, IsBatch, TempBlob, FileOutStream, InvoiceType, VerifactuDateTime, VerifactuHash, PreviousDocumentNo, PreviousPostingDate, PreviousHuella); - - ServiceCrMemoHeader.Modify(); - end; - - local procedure CreateXML(var ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var ServiceCrMemoLine: Record "Service Cr.Memo Line"; IsBatch: Boolean; var TempBlob: Codeunit "Temp Blob"; var FileOutStream: OutStream; InvoiceType: Text; VerifactuDateTime: Text; VerifactuHash: Text[64]; PreviousDocumentNo: Text; PreviousPostingDate: Date; PreviousHuella: Text) var HeaderXMLNode, BodyXMLNode, RegFactuSistemaFacturacionXMLNode, RootXMLNode : XmlElement; XMLDocOut: XmlDocument; + FileOutStream: OutStream; begin TempBlob.CreateOutStream(FileOutStream, TextEncoding::UTF8); @@ -715,7 +702,7 @@ codeunit 10778 "Verifactu Export" BodyXMLNode := XmlElement.Create('Body', XmlNamespaceSoapenv); RegFactuSistemaFacturacionXMLNode := XmlElement.Create('RegFactuSistemaFacturacion', XmlNamespaceSum); InsertHeaderData(RegFactuSistemaFacturacionXMLNode); - InsertServiceCreditMemosData(RegFactuSistemaFacturacionXMLNode, ServiceCrMemoHeader, ServiceCrMemoLine, IsBatch, InvoiceType, VerifactuDateTime, VerifactuHash, PreviousDocumentNo, PreviousPostingDate, PreviousHuella); + InsertServiceCreditMemosData(RegFactuSistemaFacturacionXMLNode, ServiceCrMemoHeader, ServiceCrMemoLine, IsBatch, EDocument); BodyXMLNode.Add(RegFactuSistemaFacturacionXMLNode); RootXMLNode.Add(HeaderXMLNode); @@ -724,27 +711,45 @@ codeunit 10778 "Verifactu Export" XmlDocOut.WriteTo(FileOutStream); end; - local procedure InsertServiceCreditMemosData(var RootXMLNode: XmlElement; var ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var ServiceCrMemoLine: Record "Service Cr.Memo Line"; IsBatch: Boolean; InvoiceType: Text; VerifactuDateTime: Text; VerifactuHash: Text[64]; PreviousDocumentNo: Text; PreviousPostingDate: Date; PreviousHuella: Text) + local procedure InsertServiceCreditMemosData(var RootXMLNode: XmlElement; var ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var ServiceCrMemoLine: Record "Service Cr.Memo Line"; IsBatch: Boolean; var EDocument: Record "E-Document") var CreditMemoXMLNode: XmlElement; + CreditMemoCount: Integer; begin CreditMemoXMLNode := XmlElement.Create('RegistroFactura', XmlNamespaceSum); - if IsBatch then + if IsBatch then begin + ServiceCrMemoHeader.SetAutoCalcFields(Amount, "Amount Including VAT"); + ServiceCrMemoHeader.FindSet(); repeat - InsertServiceCreditMemo(CreditMemoXMLNode, ServiceCrMemoHeader, ServiceCrMemoLine, InvoiceType, VerifactuDateTime, VerifactuHash, PreviousDocumentNo, PreviousPostingDate, PreviousHuella); - until ServiceCrMemoHeader.Next() = 0 - else - InsertServiceCreditMemo(CreditMemoXMLNode, ServiceCrMemoHeader, ServiceCrMemoLine, InvoiceType, VerifactuDateTime, VerifactuHash, PreviousDocumentNo, PreviousPostingDate, PreviousHuella); + CreditMemoCount += 1; + if CreditMemoCount > 1000 then + Error(MaxBatchSizeErr); + InsertServiceCreditMemo(CreditMemoXMLNode, ServiceCrMemoHeader, ServiceCrMemoLine, EDocument); + until ServiceCrMemoHeader.Next() = 0; + end else begin + ServiceCrMemoHeader.CalcFields(Amount, "Amount Including VAT"); + InsertServiceCreditMemo(CreditMemoXMLNode, ServiceCrMemoHeader, ServiceCrMemoLine, EDocument); + end; RootXMLNode.Add(CreditMemoXMLNode); end; - local procedure InsertServiceCreditMemo(var RootXMLNode: XmlElement; var ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var ServiceCrMemoLine: Record "Service Cr.Memo Line"; InvoiceType: Text; VerifactuDateTime: Text; VerifactuHash: Text[64]; PreviousDocumentNo: Text; PreviousPostingDate: Date; PreviousHuella: Text) + local procedure InsertServiceCreditMemo(var RootXMLNode: XmlElement; var ServiceCrMemoHeader: Record "Service Cr.Memo Header"; var ServiceCrMemoLine: Record "Service Cr.Memo Line"; var EDocument: Record "E-Document") var - Customer: Record Customer; + TempBlobQR: Codeunit "Temp Blob"; + InvoiceType, VerifactuDateTime : Text; + PreviousDocumentNo, PreviousHuella : Text; + VerifactuHash: Text[64]; + PreviousPostingDate: Date; CrMemoXMLNode: XmlElement; + OutStr: OutStream; + InStr: InStream; begin - Customer.Get(ServiceCrMemoHeader."Bill-to Customer No."); + InvoiceType := GetOptionFirstTwoChars(ServiceCrMemoHeader."Cr. Memo Type"); + VerifactuDateTime := GetCustomDateTimeFormat(CurrentDateTime()); + FindLastRegisteredDocument(PreviousDocumentNo, PreviousPostingDate, PreviousHuella); + VerifactuHash := GenerateHash(ServiceCrMemoHeader, InvoiceType, VerifactuDateTime, PreviousHuella); + VerifactuDocUploadMgt.InsertVerifactuDocument(EDocument, ServiceCrMemoHeader."No.", ServiceCrMemoHeader."Posting Date", VerifactuHash); CrMemoXMLNode := XmlElement.Create('RegistroAlta', XmlNamespaceSum1); @@ -756,6 +761,13 @@ codeunit 10778 "Verifactu Export" InsertHuellaDigital(CrMemoXMLNode, VerifactuDateTime, VerifactuHash); RootXMLNode.Add(CrMemoXMLNode); + + TempBlobQR := GenerateQRCode(ServiceCrMemoHeader."No.", ServiceCrMemoHeader."Posting Date", ServiceCrMemoHeader."Amount Including VAT"); + TempBlobQR.CreateInStream(InStr); + ServiceCrMemoHeader."QR Code Base64".CreateOutStream(OutStr, TextEncoding::UTF8); + CopyStream(OutStr, InStr); + ServiceCrMemoHeader."QR Code Image".ImportStream(InStr, 'image.png'); + ServiceCrMemoHeader.Modify(); end; local procedure InsertServiceCreditMemoHeaderData(var InvoiceXMLNode: XmlElement; var ServiceCrMemoHeader: Record "Service Cr.Memo Header"; InvoiceType: Text) diff --git a/Apps/ES/EDocumentFormats/DocumentRegistration/test/src/TestVerifactuExport.Codeunit.al b/Apps/ES/EDocumentFormats/DocumentRegistration/test/src/TestVerifactuExport.Codeunit.al index e2fa626987..501230ad55 100644 --- a/Apps/ES/EDocumentFormats/DocumentRegistration/test/src/TestVerifactuExport.Codeunit.al +++ b/Apps/ES/EDocumentFormats/DocumentRegistration/test/src/TestVerifactuExport.Codeunit.al @@ -37,6 +37,10 @@ codeunit 148004 "Test Verifactu Export" LibraryEdocument: Codeunit "Library - E-Document"; Assert: Codeunit "Assert"; IsInitialized: Boolean; + XMLShouldContainDocumentLbl: Label 'XML should contain document %1', Comment = '%1 = Document number'; + QRCodeShouldBeGeneratedForDocumentLbl: Label 'QR code should be generated for document %1', Comment = '%1 = Document number'; + TestServiceInvoiceLbl: Label 'Test Service Invoice %1', Comment = '%1 = Invoice number'; + TestServiceCreditMemoLbl: Label 'Test Service Credit Memo %1', Comment = '%1 = Credit memo number'; #region SalesInvoice [Test] @@ -939,6 +943,728 @@ codeunit 148004 "Test Verifactu Export" ServiceCrMemoHeader.CalcFields(Amount, "Amount Including VAT"); VerifyDocumentTotals(XMLText, -(ServiceCrMemoHeader."Amount Including VAT" - ServiceCrMemoHeader.Amount), -ServiceCrMemoHeader."Amount Including VAT"); end; + + [Test] + procedure ExportServiceInvoiceGeneratesQRCode() + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + ServiceHeader: Record "Service Header"; + ServiceLine: Record "Service Line"; + XMLText: Text; + begin + // [FEATURE] [AI test] + // [SCENARIO 617106] Export generates QR code for service invoice + Initialize(); + + // [GIVEN] Service Invoice with G/L Account in the Service Line + CreateServiceDocWithLine( + ServiceHeader, ServiceLine, ServiceHeader."Document Type"::Invoice, + ServiceLine.Type::"G/L Account", CreateGLAccountNo(), WorkDate(), LibrarySales.CreateCustomerNo()); + ServiceHeader.Validate("Invoice Type", ServiceHeader."Invoice Type"::"F1 Invoice"); + ServiceHeader.Validate("Special Scheme Code", ServiceHeader."Special Scheme Code"::"01 General"); + ServiceHeader.Validate("Operation Description", 'Test Service Invoice'); + ServiceHeader.Modify(true); + + // [WHEN] Service Invoice is posted + ServiceInvoiceHeader := PostServiceInvoice(ServiceHeader); + + // [WHEN] Export procedure is invoked for service invoice "SI" + ExportServiceInvoice(ServiceInvoiceHeader, XMLText); + + // [THEN] QR code is generated and stored in service invoice header + ServiceInvoiceHeader.Get(ServiceInvoiceHeader."No."); + Assert.IsTrue(ServiceInvoiceHeader."QR Code Image".Count > 0, 'QR code image should be generated'); + end; + + [Test] + procedure ExportServiceCreditMemoGeneratesQRCode() + var + ServiceInvoiceHeader: Record "Service Invoice Header"; + ServiceCrMemoHeader: Record "Service Cr.Memo Header"; + ServiceHeader: Record "Service Header"; + ServiceLine: Record "Service Line"; + XMLText: Text; + begin + // [FEATURE] [AI test] + // [SCENARIO 617106] Export generates QR code for service credit memo + Initialize(); + + // [GIVEN] Service Invoice is posted + CreateServiceDocWithLine( + ServiceHeader, ServiceLine, ServiceHeader."Document Type"::Invoice, + ServiceLine.Type::"G/L Account", CreateGLAccountNo(), WorkDate(), LibrarySales.CreateCustomerNo()); + ServiceHeader.Validate("Invoice Type", ServiceHeader."Invoice Type"::"F1 Invoice"); + ServiceHeader.Validate("Special Scheme Code", ServiceHeader."Special Scheme Code"::"01 General"); + ServiceHeader.Validate("Operation Description", 'Test Service Invoice'); + ServiceHeader.Modify(true); + ServiceInvoiceHeader := PostServiceInvoice(ServiceHeader); + + // [GIVEN] Service Credit Memo with G/L Account in the Service Line + CreateServiceDocWithLine( + ServiceHeader, ServiceLine, ServiceHeader."Document Type"::"Credit Memo", + ServiceLine.Type::"G/L Account", CreateGLAccountNo(), WorkDate(), ServiceHeader."Customer No."); + ServiceHeader.Validate("Invoice Type", ServiceHeader."Invoice Type"::"R1 Corrected Invoice"); + ServiceHeader.Validate("Special Scheme Code", ServiceHeader."Special Scheme Code"::"01 General"); + ServiceHeader.Validate("Operation Description", 'Test Service Credit Memo'); + ServiceHeader.Validate("Corrected Invoice No.", ServiceInvoiceHeader."No."); + ServiceHeader.Modify(true); + + // [WHEN] Service Credit Memo is posted + ServiceCrMemoHeader := PostServiceCreditMemo(ServiceHeader); + + // [WHEN] Export procedure is invoked for service credit memo "SM" + ExportServiceCreditMemo(ServiceCrMemoHeader, XMLText); + + // [THEN] QR code is generated and stored in service credit memo header + ServiceCrMemoHeader.Get(ServiceCrMemoHeader."No."); + Assert.IsTrue(ServiceCrMemoHeader."QR Code Image".Count > 0, 'QR code image should be generated'); + end; + #endregion + + #region BatchExport + [Test] + procedure ExportMultipleSalesInvoicesInBatch() + var + SalesInvoiceHeader: array[3] of Record "Sales Invoice Header"; + Customer: Record Customer; + XMLText: Text; + i: Integer; + begin + // [FEATURE] [AI test] [Batch] + // [SCENARIO 617106] Export multiple sales invoices in a single batch operation + Initialize(); + + // [GIVEN] 3 posted sales invoices + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + for i := 1 to 3 do + CreatePostedSalesInvoice(SalesInvoiceHeader[i], Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + + // [WHEN] Export batch procedure is invoked for all invoices + ExportInvoiceBatch(SalesInvoiceHeader, XMLText); + + // [THEN] XML contains all invoice numbers + for i := 1 to 3 do + Assert.IsTrue(XMLText.Contains(SalesInvoiceHeader[i]."No."), StrSubstNo(XMLShouldContainDocumentLbl, SalesInvoiceHeader[i]."No.")); + + // [THEN] XML contains multiple RegistroAlta elements + Assert.IsTrue(CountOccurrences(XMLText, 'RegistroAlta') >= 3, 'XML should contain at least 3 RegistroAlta elements'); + end; + + [Test] + procedure ExportMultipleSalesCreditMemosInBatch() + var + SalesInvoiceHeader: array[3] of Record "Sales Invoice Header"; + SalesCrMemoHeader: array[3] of Record "Sales Cr.Memo Header"; + Customer: Record Customer; + XMLText: Text; + i: Integer; + begin + // [FEATURE] [AI test] [Batch] + // [SCENARIO 617106] Export multiple sales credit memos in a single batch operation + Initialize(); + + // [GIVEN] 3 posted sales invoices and corresponding credit memos + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + for i := 1 to 3 do begin + CreatePostedSalesInvoice(SalesInvoiceHeader[i], Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + CreatePostedSalesCreditMemo(SalesCrMemoHeader[i], SalesInvoiceHeader[i]."No.", Customer."No.", LibraryRandom.RandDecInRange(500, 2000, 2)); + end; + + // [WHEN] Export batch procedure is invoked for all credit memos + ExportCreditMemoBatch(SalesCrMemoHeader, XMLText); + + // [THEN] XML contains all credit memo numbers + for i := 1 to 3 do + Assert.IsTrue(XMLText.Contains(SalesCrMemoHeader[i]."No."), StrSubstNo(XMLShouldContainDocumentLbl, SalesCrMemoHeader[i]."No.")); + + // [THEN] XML contains multiple RegistroAlta elements and FacturasRectificadas + Assert.IsTrue(CountOccurrences(XMLText, 'RegistroAlta') >= 3, 'XML should contain at least 3 RegistroAlta elements'); + Assert.IsTrue(CountOccurrences(XMLText, 'FacturasRectificadas') >= 3, 'XML should contain at least 3 FacturasRectificadas elements'); + end; + + [Test] + procedure ExportMultipleServiceInvoicesInBatch() + var + ServiceInvoiceHeader: array[4] of Record "Service Invoice Header"; + ServiceHeader: Record "Service Header"; + ServiceLine: Record "Service Line"; + XMLText: Text; + i: Integer; + begin + // [FEATURE] [AI test] [Batch] + // [SCENARIO 617106] Export multiple service invoices in a single batch operation + Initialize(); + + // [GIVEN] 4 posted service invoices + for i := 1 to 4 do begin + CreateServiceDocWithLine( + ServiceHeader, ServiceLine, ServiceHeader."Document Type"::Invoice, + ServiceLine.Type::"G/L Account", CreateGLAccountNo(), WorkDate(), LibrarySales.CreateCustomerNo()); + ServiceHeader.Validate("Invoice Type", ServiceHeader."Invoice Type"::"F1 Invoice"); + ServiceHeader.Validate("Special Scheme Code", ServiceHeader."Special Scheme Code"::"01 General"); + ServiceHeader.Validate("Operation Description", StrSubstNo(TestServiceInvoiceLbl, i)); + ServiceHeader.Modify(true); + ServiceInvoiceHeader[i] := PostServiceInvoice(ServiceHeader); + end; + + // [WHEN] Export batch procedure is invoked for all service invoices + ExportServiceInvoiceBatch(ServiceInvoiceHeader, XMLText); + + // [THEN] XML contains all service invoice numbers + for i := 1 to 4 do + Assert.IsTrue(XMLText.Contains(ServiceInvoiceHeader[i]."No."), StrSubstNo(XMLShouldContainDocumentLbl, ServiceInvoiceHeader[i]."No.")); + + // [THEN] XML contains multiple RegistroAlta elements + Assert.IsTrue(CountOccurrences(XMLText, 'RegistroAlta') >= 4, 'XML should contain at least 4 RegistroAlta elements'); + end; + + [Test] + procedure ExportMultipleServiceCreditMemosInBatch() + var + ServiceInvoiceHeader: array[3] of Record "Service Invoice Header"; + ServiceCrMemoHeader: array[3] of Record "Service Cr.Memo Header"; + ServiceHeader: Record "Service Header"; + ServiceLine: Record "Service Line"; + XMLText: Text; + i: Integer; + begin + // [FEATURE] [AI test] [Batch] + // [SCENARIO 617106] Export multiple service credit memos in a single batch operation + Initialize(); + + // [GIVEN] 3 posted service invoices and corresponding credit memos + for i := 1 to 3 do begin + CreateServiceDocWithLine( + ServiceHeader, ServiceLine, ServiceHeader."Document Type"::Invoice, + ServiceLine.Type::"G/L Account", CreateGLAccountNo(), WorkDate(), LibrarySales.CreateCustomerNo()); + ServiceHeader.Validate("Invoice Type", ServiceHeader."Invoice Type"::"F1 Invoice"); + ServiceHeader.Validate("Special Scheme Code", ServiceHeader."Special Scheme Code"::"01 General"); + ServiceHeader.Validate("Operation Description", StrSubstNo(TestServiceInvoiceLbl, i)); + ServiceHeader.Modify(true); + ServiceInvoiceHeader[i] := PostServiceInvoice(ServiceHeader); + + CreateServiceDocWithLine( + ServiceHeader, ServiceLine, ServiceHeader."Document Type"::"Credit Memo", + ServiceLine.Type::"G/L Account", CreateGLAccountNo(), WorkDate(), ServiceHeader."Customer No."); + ServiceHeader.Validate("Invoice Type", ServiceHeader."Invoice Type"::"R1 Corrected Invoice"); + ServiceHeader.Validate("Special Scheme Code", ServiceHeader."Special Scheme Code"::"01 General"); + ServiceHeader.Validate("Operation Description", StrSubstNo(TestServiceCreditMemoLbl, i)); + ServiceHeader.Validate("Corrected Invoice No.", ServiceInvoiceHeader[i]."No."); + ServiceHeader.Modify(true); + ServiceCrMemoHeader[i] := PostServiceCreditMemo(ServiceHeader); + end; + + // [WHEN] Export batch procedure is invoked for all service credit memos + ExportServiceCreditMemoBatch(ServiceCrMemoHeader, XMLText); + + // [THEN] XML contains all service credit memo numbers + for i := 1 to 3 do + Assert.IsTrue(XMLText.Contains(ServiceCrMemoHeader[i]."No."), StrSubstNo(XMLShouldContainDocumentLbl, ServiceCrMemoHeader[i]."No.")); + + // [THEN] XML contains multiple RegistroAlta elements + Assert.IsTrue(CountOccurrences(XMLText, 'RegistroAlta') >= 3, 'XML should contain at least 3 RegistroAlta elements'); + end; + + [Test] + procedure ExportBatchVerifiesMaximumBatchSize() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + Customer: Record Customer; + InvoiceCount: Integer; + begin + // [FEATURE] [AI test] [Batch] + // [SCENARIO 617106] Export batch respects maximum batch size of 1000 documents + Initialize(); + + // [GIVEN] Posted sales invoices + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + // Create enough invoices to verify batch processing works + for InvoiceCount := 1 to 10 do + CreatePostedSalesInvoice(SalesInvoiceHeader, Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + + // [WHEN] Export batch procedure is invoked + // [THEN] No error occurs for batch size under 1000 + // Note: Testing with 1001 documents would require creating many records + // This test verifies the batch mechanism works correctly for smaller batches + SalesInvoiceHeader.SetRange("Sell-to Customer No.", Customer."No."); + Assert.IsTrue(SalesInvoiceHeader.Count <= 1000, 'Batch size should be within allowed limit'); + end; + + [Test] + procedure ExportBatchCreatesQRCodesForAllDocuments() + var + SalesInvoiceHeader: array[3] of Record "Sales Invoice Header"; + Customer: Record Customer; + XMLText: Text; + i: Integer; + begin + // [FEATURE] [AI test] [Batch] + // [SCENARIO 617106] Export batch generates QR codes for all documents + Initialize(); + + // [GIVEN] 3 posted sales invoices + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + for i := 1 to 3 do + CreatePostedSalesInvoice(SalesInvoiceHeader[i], Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + + // [WHEN] Export batch procedure is invoked + ExportInvoiceBatch(SalesInvoiceHeader, XMLText); + + // [THEN] QR codes are generated for all invoices + for i := 1 to 3 do begin + SalesInvoiceHeader[i].Get(SalesInvoiceHeader[i]."No."); + Assert.IsTrue(SalesInvoiceHeader[i]."QR Code Image".Count > 0, StrSubstNo(QRCodeShouldBeGeneratedForDocumentLbl, SalesInvoiceHeader[i]."No.")); + end; + end; + + [Test] + procedure ExportBatchMaintainsDocumentChain() + var + SalesInvoiceHeader: array[3] of Record "Sales Invoice Header"; + VerifactuDocument: Record "Verifactu Document"; + Customer: Record Customer; + XMLText: Text; + i: Integer; + begin + // [FEATURE] [AI test] [Batch] + // [SCENARIO 617106] Export batch maintains document chain across multiple documents + Initialize(); + VerifactuDocument.DeleteAll(); + + // [GIVEN] 3 posted sales invoices + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + for i := 1 to 3 do + CreatePostedSalesInvoice(SalesInvoiceHeader[i], Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + + // [WHEN] First invoice is exported individually + ExportInvoice(SalesInvoiceHeader[3], XMLText); + Commit(); + + // [THEN] First invoice contains PrimerRegistro + Assert.IsTrue(XMLText.Contains('PrimerRegistro'), 'First invoice should contain PrimerRegistro'); + + // [WHEN] Remaining invoices are exported in batch + ExportInvoiceBatch(SalesInvoiceHeader, XMLText); + Commit(); + + // [THEN] XML contains multiple RegistroAlta elements + Assert.IsTrue(CountOccurrences(XMLText, 'RegistroAlta') >= 3, 'XML should contain at least 3 RegistroAlta elements'); + end; + #endregion + + #region XMLStructureValidation + [Test] + procedure VerifyXMLIDFacturaStructure() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + Customer: Record Customer; + XMLText: Text; + begin + // [FEATURE] [AI test] [XML] + // [SCENARIO 617106] XML IDFactura section contains all required fields + Initialize(); + + // [GIVEN] Posted sales invoice + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + CreatePostedSalesInvoice(SalesInvoiceHeader, Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + + // [WHEN] Export procedure is invoked + ExportInvoice(SalesInvoiceHeader, XMLText); + + // [THEN] IDFactura contains required elements + Assert.IsTrue(XMLText.Contains('IDEmisorFactura'), 'XML should contain IDEmisorFactura'); + Assert.IsTrue(XMLText.Contains('NumSerieFactura'), 'XML should contain NumSerieFactura'); + Assert.IsTrue(XMLText.Contains('FechaExpedicionFactura'), 'XML should contain FechaExpedicionFactura'); + end; + + [Test] + procedure VerifyXMLTipoFacturaIsPresent() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + Customer: Record Customer; + XMLText: Text; + begin + // [FEATURE] [AI test] [XML] + // [SCENARIO 617106] XML contains TipoFactura element with valid value + Initialize(); + + // [GIVEN] Posted sales invoice + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + CreatePostedSalesInvoice(SalesInvoiceHeader, Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + + // [WHEN] Export procedure is invoked + ExportInvoice(SalesInvoiceHeader, XMLText); + + // [THEN] TipoFactura element exists + Assert.IsTrue(XMLText.Contains('TipoFactura'), 'XML should contain TipoFactura element'); + Assert.IsTrue(XMLText.Contains('F1'), 'TipoFactura should contain F1 for standard invoice'); + end; + + [Test] + procedure VerifyXMLEncadenamientoStructure() + var + SalesInvoiceHeader1: Record "Sales Invoice Header"; + SalesInvoiceHeader2: Record "Sales Invoice Header"; + VerifactuDocument: Record "Verifactu Document"; + Customer: Record Customer; + XMLText: Text; + begin + // [FEATURE] [AI test] [XML] + // [SCENARIO 617106] XML Encadenamiento section has correct structure for chained documents + Initialize(); + VerifactuDocument.DeleteAll(); + + // [GIVEN] Two posted sales invoices + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + CreatePostedSalesInvoice(SalesInvoiceHeader1, Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + CreatePostedSalesInvoice(SalesInvoiceHeader2, Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + + // [WHEN] First invoice is exported + ExportInvoice(SalesInvoiceHeader1, XMLText); + Commit(); + + // [THEN] First invoice contains PrimerRegistro in Encadenamiento + Assert.IsTrue(XMLText.Contains('Encadenamiento'), 'XML should contain Encadenamiento section'); + Assert.IsTrue(XMLText.Contains('PrimerRegistro'), 'First document should contain PrimerRegistro'); + Assert.IsTrue(XMLText.Contains('TipoHuella'), 'Encadenamiento should contain TipoHuella'); + Assert.IsTrue(XMLText.Contains('Huella'), 'Encadenamiento should contain Huella'); + + // [WHEN] Second invoice is exported + ExportInvoice(SalesInvoiceHeader2, XMLText); + + // [THEN] Second invoice contains RegistroAnterior in Encadenamiento + Assert.IsTrue(XMLText.Contains('RegistroAnterior'), 'Second document should contain RegistroAnterior'); + Assert.IsTrue(XMLText.Contains('IDEmisorFactura'), 'RegistroAnterior should contain IDEmisorFactura'); + Assert.IsTrue(XMLText.Contains('Huella'), 'RegistroAnterior should contain Huella'); + end; + + [Test] + procedure VerifyXMLImportesTotalesStructure() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + Customer: Record Customer; + XMLText: Text; + begin + // [FEATURE] [AI test] [XML] + // [SCENARIO 617106] XML ImporteTotalFactura section contains correct totals structure + Initialize(); + + // [GIVEN] Posted sales invoice with amounts + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + CreatePostedSalesInvoice(SalesInvoiceHeader, Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + + // [WHEN] Export procedure is invoked + ExportInvoice(SalesInvoiceHeader, XMLText); + + // [THEN] ImporteTotalFactura section exists with required elements + Assert.IsTrue(XMLText.Contains('CuotaTotal'), 'XML should contain CuotaTotal element'); + Assert.IsTrue(XMLText.Contains('ImporteTotal'), 'XML should contain ImporteTotal element'); + end; + + [Test] + procedure VerifyXMLSistemaInformaticoStructure() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + Customer: Record Customer; + XMLText: Text; + begin + // [FEATURE] [AI test] [XML] + // [SCENARIO 617106] XML contains SistemaInformatico section with required fields + Initialize(); + + // [GIVEN] Posted sales invoice + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + CreatePostedSalesInvoice(SalesInvoiceHeader, Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + + // [WHEN] Export procedure is invoked + ExportInvoice(SalesInvoiceHeader, XMLText); + + // [THEN] SistemaInformatico section exists + Assert.IsTrue(XMLText.Contains('SistemaInformatico'), 'XML should contain SistemaInformatico section'); + Assert.IsTrue(XMLText.Contains('NombreRazon'), 'SistemaInformatico should contain NombreRazon'); + Assert.IsTrue(XMLText.Contains('NIF'), 'SistemaInformatico should contain NIF'); + Assert.IsTrue(XMLText.Contains('IdSistemaInformatico'), 'SistemaInformatico should contain IdSistemaInformatico'); + Assert.IsTrue(XMLText.Contains('Version'), 'SistemaInformatico should contain Version'); + end; + + [Test] + procedure VerifyXMLDesgloseTipoOperacionStructure() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + Customer: Record Customer; + XMLText: Text; + begin + // [FEATURE] [AI test] [XML] + // [SCENARIO 617106] XML DesgloseTipoOperacion contains proper VAT breakdown + Initialize(); + + // [GIVEN] Posted sales invoice with VAT + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + CreatePostedSalesInvoice(SalesInvoiceHeader, Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + + // [WHEN] Export procedure is invoked + ExportInvoice(SalesInvoiceHeader, XMLText); + + // [THEN] DesgloseTipoOperacion section exists with VAT details + Assert.IsTrue(XMLText.Contains('DetalleDesglose'), 'XML should contain DetalleDesglose'); + Assert.IsTrue(XMLText.Contains('BaseImponibleOimporteNoSujeto'), 'DesgloseTipoOperacion should contain BaseImponibleOimporteNoSujeto'); + Assert.IsTrue(XMLText.Contains('TipoImpositivo'), 'DesgloseTipoOperacion should contain TipoImpositivo'); + Assert.IsTrue(XMLText.Contains('CuotaRepercutida'), 'DesgloseTipoOperacion should contain CuotaRepercutida'); + end; + + [Test] + procedure VerifyXMLCreditMemoContainsFacturasRectificadas() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + SalesCrMemoHeader: Record "Sales Cr.Memo Header"; + Customer: Record Customer; + XMLText: Text; + begin + // [FEATURE] [AI test] [XML] + // [SCENARIO 617106] Credit memo XML contains FacturasRectificadas section + Initialize(); + + // [GIVEN] Posted sales invoice and credit memo + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + CreatePostedSalesInvoice(SalesInvoiceHeader, Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + CreatePostedSalesCreditMemo(SalesCrMemoHeader, SalesInvoiceHeader."No.", Customer."No.", LibraryRandom.RandDecInRange(500, 2000, 2)); + + // [WHEN] Credit memo is exported + ExportCreditMemo(SalesCrMemoHeader, XMLText); + + // [THEN] XML contains FacturasRectificadas section + Assert.IsTrue(XMLText.Contains('FacturasRectificadas'), 'Credit memo XML should contain FacturasRectificadas'); + Assert.IsTrue(XMLText.Contains('IDFacturaRectificada'), 'FacturasRectificadas should contain IDFacturaRectificada'); + end; + + [Test] + procedure VerifyXMLDateTimeFormatsAreCorrect() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + Customer: Record Customer; + XMLText: Text; + begin + // [FEATURE] [AI test] [XML] + // [SCENARIO 617106] XML date and datetime fields follow ISO format + Initialize(); + + // [GIVEN] Posted sales invoice + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + CreatePostedSalesInvoice(SalesInvoiceHeader, Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + + // [WHEN] Export procedure is invoked + ExportInvoice(SalesInvoiceHeader, XMLText); + + // [THEN] Date fields are in DD-MM-YYYY format + Assert.IsTrue(XMLText.Contains('FechaExpedicionFactura'), 'XML should contain FechaExpedicionFactura'); + + // [THEN] DateTime fields include timezone offset + Assert.IsTrue(XMLText.Contains('FechaHoraHusoGenRegistro'), 'XML should contain FechaHoraHusoGenRegistro'); + end; + + [Test] + procedure VerifyXMLNumericFormatsUseDecimalPoint() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + Customer: Record Customer; + XMLText: Text; + begin + // [FEATURE] [AI test] [XML] + // [SCENARIO 617106] XML numeric fields use decimal point notation + Initialize(); + + // [GIVEN] Posted sales invoice with decimal amounts + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + CreatePostedSalesInvoice(SalesInvoiceHeader, Customer."No.", 1234.56, 21); + + // [WHEN] Export procedure is invoked + ExportInvoice(SalesInvoiceHeader, XMLText); + + // [THEN] Numeric values use decimal point + Assert.IsTrue(XMLText.Contains('.'), 'XML numeric values should use decimal point separator'); + end; + + [Test] + procedure VerifyXMLSpecialCharactersAreEscaped() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + SalesHeader: Record "Sales Header"; + SalesLine: Record "Sales Line"; + Customer: Record Customer; + Item: Record Item; + XMLText: Text; + begin + // [FEATURE] [AI test] [XML] + // [SCENARIO 617106] XML properly escapes special characters + Initialize(); + + // [GIVEN] Sales invoice with special characters in description + LibraryInventory.CreateItem(Item); + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + + LibrarySales.CreateSalesHeader(SalesHeader, SalesHeader."Document Type"::Invoice, Customer."No."); + SalesHeader.Validate("Invoice Type", SalesHeader."Invoice Type"::"F1 Invoice"); + SalesHeader.Validate("Special Scheme Code", SalesHeader."Special Scheme Code"::"01 General"); + SalesHeader.Validate("Operation Description", 'Test & Special '); + SalesHeader.Modify(true); + + LibrarySales.CreateSalesLine(SalesLine, SalesHeader, SalesLine.Type::Item, Item."No.", 1); + SalesLine.Validate("Unit Price", 100); + SalesLine.Validate("VAT %", 21); + SalesLine.Modify(true); + + SalesInvoiceHeader.Get(LibrarySales.PostSalesDocument(SalesHeader, true, true)); + + // [WHEN] Export procedure is invoked + ExportInvoice(SalesInvoiceHeader, XMLText); + + // [THEN] Special characters are properly escaped or handled + Assert.IsFalse(XMLText.Contains('Test & Special '), 'Raw special characters should be escaped in XML'); + end; + #endregion + + #region DocumentChaining + [Test] + procedure ExportTwoSalesInvoicesCreatesChain() + var + SalesInvoiceHeader1: Record "Sales Invoice Header"; + SalesInvoiceHeader2: Record "Sales Invoice Header"; + VerifactuDocument: Record "Verifactu Document"; + Customer: Record Customer; + XMLText1: Text; + XMLText2: Text; + begin + // [FEATURE] [AI test] + // [SCENARIO 617106] Exporting two invoices creates proper document chain + Initialize(); + VerifactuDocument.DeleteAll(); + + // [GIVEN] Two posted sales invoices "I1" and "I2" + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + CreatePostedSalesInvoice(SalesInvoiceHeader1, Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + CreatePostedSalesInvoice(SalesInvoiceHeader2, Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + + // [WHEN] First invoice is exported + ExportInvoice(SalesInvoiceHeader1, XMLText1); + Commit(); + + // [THEN] First invoice contains PrimerRegistro element + Assert.IsTrue(XMLText1.Contains('PrimerRegistro'), 'First invoice should contain PrimerRegistro'); + + // [WHEN] Second invoice is exported + ExportInvoice(SalesInvoiceHeader2, XMLText2); + Commit(); + + // [THEN] Second invoice contains RegistroAnterior with reference to first invoice + Assert.IsTrue(XMLText2.Contains('RegistroAnterior'), 'Second invoice should contain RegistroAnterior'); + Assert.IsTrue(XMLText2.Contains(SalesInvoiceHeader1."No."), 'Second invoice should reference first invoice number'); + end; + + [Test] + procedure ExportInvoiceAfterCreditMemoMaintainsChain() + var + SalesInvoiceHeader1: Record "Sales Invoice Header"; + SalesInvoiceHeader2: Record "Sales Invoice Header"; + SalesCrMemoHeader: Record "Sales Cr.Memo Header"; + VerifactuDocument: Record "Verifactu Document"; + Customer: Record Customer; + XMLText: Text; + begin + // [FEATURE] [AI test] + // [SCENARIO 617106] Exporting invoice after credit memo maintains document chain + Initialize(); + VerifactuDocument.DeleteAll(); + + // [GIVEN] Posted sales invoice "I1" and credit memo "CM" + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + CreatePostedSalesInvoice(SalesInvoiceHeader1, Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + ExportInvoice(SalesInvoiceHeader1, XMLText); + Commit(); + + CreatePostedSalesCreditMemo(SalesCrMemoHeader, SalesInvoiceHeader1."No.", Customer."No.", LibraryRandom.RandDecInRange(500, 2000, 2)); + ExportCreditMemo(SalesCrMemoHeader, XMLText); + Commit(); + + // [GIVEN] Another posted sales invoice "I2" + CreatePostedSalesInvoice(SalesInvoiceHeader2, Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + + // [WHEN] Second invoice is exported + ExportInvoice(SalesInvoiceHeader2, XMLText); + + // [THEN] Second invoice contains RegistroAnterior with reference to credit memo + Assert.IsTrue(XMLText.Contains('RegistroAnterior'), 'Invoice should contain RegistroAnterior'); + Assert.IsTrue(XMLText.Contains(SalesCrMemoHeader."No."), 'Invoice should reference credit memo number'); + end; + #endregion + + #region CommonProcedures + [Test] + procedure ExportSalesInvoiceIncludesDateTimeWithTimezone() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + Customer: Record Customer; + XMLText: Text; + begin + // [FEATURE] [AI test] + // [SCENARIO 617106] Export includes datetime with timezone in FechaHoraHusoGenRegistro + Initialize(); + + // [GIVEN] Posted sales invoice + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + CreatePostedSalesInvoice(SalesInvoiceHeader, Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + + // [WHEN] Export procedure is invoked + ExportInvoice(SalesInvoiceHeader, XMLText); + + // [THEN] XML contains FechaHoraHusoGenRegistro with ISO datetime format and timezone offset + Assert.IsTrue(XMLText.Contains('FechaHoraHusoGenRegistro'), 'XML should contain FechaHoraHusoGenRegistro'); + Assert.IsTrue(XMLText.Contains('T') and (XMLText.Contains('+') or XMLText.Contains('-')), 'DateTime should have timezone offset'); + end; + + [Test] + procedure ExportSalesInvoiceWithF2InvoiceType() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + Customer: Record Customer; + XMLText: Text; + begin + // [FEATURE] [AI test] + // [SCENARIO 617106] Export handles F2 Simplified Invoice type correctly + Initialize(); + + // [GIVEN] Posted sales invoice with F2 invoice type + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + CreatePostedSalesInvoiceWithF2Type(SalesInvoiceHeader, Customer."No."); + + // [WHEN] Export procedure is invoked + ExportInvoice(SalesInvoiceHeader, XMLText); + + // [THEN] XML contains correct invoice type F2 + Assert.IsTrue(XMLText.Contains('F2'), 'XML should contain invoice type F2'); + end; + + [Test] + procedure ExportSalesInvoiceIncludesVerifactuDateTime() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + Customer: Record Customer; + XMLText: Text; + begin + // [FEATURE] [AI test] + // [SCENARIO 617106] Export includes FechaHoraHusoGenRegistro element + Initialize(); + + // [GIVEN] Posted sales invoice + LibrarySales.CreateCustomerWithCountryCodeAndVATRegNo(Customer); + CreatePostedSalesInvoice(SalesInvoiceHeader, Customer."No.", LibraryRandom.RandDecInRange(1000, 5000, 2), LibraryRandom.RandIntInRange(10, 25)); + + // [WHEN] Export procedure is invoked + ExportInvoice(SalesInvoiceHeader, XMLText); + + // [THEN] XML contains FechaHoraHusoGenRegistro element + Assert.IsTrue(XMLText.Contains('FechaHoraHusoGenRegistro'), 'XML should contain FechaHoraHusoGenRegistro'); + Assert.IsTrue(XMLText.Contains('TipoHuella'), 'XML should contain TipoHuella'); + end; #endregion local procedure Initialize() @@ -1018,6 +1744,111 @@ codeunit 148004 "Test Verifactu Export" ReadXMLFromBlob(TempBlob, XMLText); end; + local procedure ExportInvoiceBatch(var SalesInvoiceHeader: array[3] of Record "Sales Invoice Header"; var XMLText: Text) + var + EDocument: Record "E-Document"; + SalesInvoiceLine: Record "Sales Invoice Line"; + TempBlob: Codeunit "Temp Blob"; + Verifactu: Codeunit Verifactu; + SourceDocumentHeader: RecordRef; + SourceDocumentLines: RecordRef; + FirstInvoiceNo: Code[20]; + begin + // Set filter to include all invoices in the batch + FirstInvoiceNo := SalesInvoiceHeader[1]."No."; + SalesInvoiceHeader[1].SetFilter("No.", '%1|%2|%3', + SalesInvoiceHeader[1]."No.", + SalesInvoiceHeader[2]."No.", + SalesInvoiceHeader[3]."No."); + + SourceDocumentHeader.GetTable(SalesInvoiceHeader[1]); + SourceDocumentLines.Open(Database::"Sales Invoice Line"); + SourceDocumentLines.GetTable(SalesInvoiceLine); + EDocument."Document No." := FirstInvoiceNo; + EDocument."Document Type" := EDocument."Document Type"::"Sales Invoice"; + Verifactu.CreateBatch(EDocumentService, EDocument, SourceDocumentHeader, SourceDocumentLines, TempBlob); + ReadXMLFromBlob(TempBlob, XMLText); + end; + + local procedure ExportCreditMemoBatch(var SalesCrMemoHeader: array[3] of Record "Sales Cr.Memo Header"; var XMLText: Text) + var + EDocument: Record "E-Document"; + SalesCrMemoLine: Record "Sales Cr.Memo Line"; + TempBlob: Codeunit "Temp Blob"; + Verifactu: Codeunit Verifactu; + SourceDocumentHeader: RecordRef; + SourceDocumentLines: RecordRef; + FirstCrMemoNo: Code[20]; + begin + // Set filter to include all credit memos in the batch + FirstCrMemoNo := SalesCrMemoHeader[1]."No."; + SalesCrMemoHeader[1].SetFilter("No.", '%1|%2|%3', + SalesCrMemoHeader[1]."No.", + SalesCrMemoHeader[2]."No.", + SalesCrMemoHeader[3]."No."); + + SourceDocumentHeader.GetTable(SalesCrMemoHeader[1]); + SourceDocumentLines.Open(Database::"Sales Cr.Memo Line"); + SourceDocumentLines.GetTable(SalesCrMemoLine); + EDocument."Document No." := FirstCrMemoNo; + EDocument."Document Type" := EDocument."Document Type"::"Sales Credit Memo"; + Verifactu.CreateBatch(EDocumentService, EDocument, SourceDocumentHeader, SourceDocumentLines, TempBlob); + ReadXMLFromBlob(TempBlob, XMLText); + end; + + local procedure ExportServiceInvoiceBatch(var ServiceInvoiceHeader: array[4] of Record "Service Invoice Header"; var XMLText: Text) + var + EDocument: Record "E-Document"; + ServiceInvoiceLine: Record "Service Invoice Line"; + TempBlob: Codeunit "Temp Blob"; + Verifactu: Codeunit Verifactu; + SourceDocumentHeader: RecordRef; + SourceDocumentLines: RecordRef; + FirstInvoiceNo: Code[20]; + begin + // Set filter to include all service invoices in the batch + FirstInvoiceNo := ServiceInvoiceHeader[1]."No."; + ServiceInvoiceHeader[1].SetFilter("No.", '%1|%2|%3|%4', + ServiceInvoiceHeader[1]."No.", + ServiceInvoiceHeader[2]."No.", + ServiceInvoiceHeader[3]."No.", + ServiceInvoiceHeader[4]."No."); + + SourceDocumentHeader.GetTable(ServiceInvoiceHeader[1]); + SourceDocumentLines.Open(Database::"Service Invoice Line"); + SourceDocumentLines.GetTable(ServiceInvoiceLine); + EDocument."Document No." := FirstInvoiceNo; + EDocument."Document Type" := EDocument."Document Type"::"Service Invoice"; + Verifactu.CreateBatch(EDocumentService, EDocument, SourceDocumentHeader, SourceDocumentLines, TempBlob); + ReadXMLFromBlob(TempBlob, XMLText); + end; + + local procedure ExportServiceCreditMemoBatch(var ServiceCrMemoHeader: array[3] of Record "Service Cr.Memo Header"; var XMLText: Text) + var + EDocument: Record "E-Document"; + ServiceCrMemoLine: Record "Service Cr.Memo Line"; + TempBlob: Codeunit "Temp Blob"; + Verifactu: Codeunit Verifactu; + SourceDocumentHeader: RecordRef; + SourceDocumentLines: RecordRef; + FirstCrMemoNo: Code[20]; + begin + // Set filter to include all service credit memos in the batch + FirstCrMemoNo := ServiceCrMemoHeader[1]."No."; + ServiceCrMemoHeader[1].SetFilter("No.", '%1|%2|%3', + ServiceCrMemoHeader[1]."No.", + ServiceCrMemoHeader[2]."No.", + ServiceCrMemoHeader[3]."No."); + + SourceDocumentHeader.GetTable(ServiceCrMemoHeader[1]); + SourceDocumentLines.Open(Database::"Service Cr.Memo Line"); + SourceDocumentLines.GetTable(ServiceCrMemoLine); + EDocument."Document No." := FirstCrMemoNo; + EDocument."Document Type" := EDocument."Document Type"::"Service Credit Memo"; + Verifactu.CreateBatch(EDocumentService, EDocument, SourceDocumentHeader, SourceDocumentLines, TempBlob); + ReadXMLFromBlob(TempBlob, XMLText); + end; + local procedure SetupCompanyInformation() var CompanyInformation: Record "Company Information"; @@ -1056,6 +1887,28 @@ codeunit 148004 "Test Verifactu Export" SalesInvoiceHeader.Get(CreateAndPostSalesInvoice(CustomerNo, Amount, VATRate)); end; + local procedure CreatePostedSalesInvoiceWithF2Type(var SalesInvoiceHeader: Record "Sales Invoice Header"; CustomerNo: Code[20]) + var + SalesHeader: Record "Sales Header"; + SalesLine: Record "Sales Line"; + Item: Record Item; + begin + LibraryInventory.CreateItem(Item); + + LibrarySales.CreateSalesHeader(SalesHeader, SalesHeader."Document Type"::Invoice, CustomerNo); + SalesHeader.Validate("Invoice Type", SalesHeader."Invoice Type"::"F2 Simplified Invoice"); + SalesHeader.Validate("Special Scheme Code", SalesHeader."Special Scheme Code"::"01 General"); + SalesHeader.Validate("Operation Description", 'Test Simplified Invoice'); + SalesHeader.Modify(true); + + LibrarySales.CreateSalesLine(SalesLine, SalesHeader, SalesLine.Type::Item, Item."No.", 1); + SalesLine.Validate("Unit Price", LibraryRandom.RandDecInRange(100, 500, 2)); + SalesLine.Validate("VAT %", LibraryRandom.RandIntInRange(10, 25)); + SalesLine.Modify(true); + + SalesInvoiceHeader.Get(LibrarySales.PostSalesDocument(SalesHeader, true, true)); + end; + local procedure CreatePostedSalesInvoiceWithMultipleLines(var SalesInvoiceHeader: Record "Sales Invoice Header"; CustomerNo: Code[20]; VATRate: Decimal) var SalesHeader: Record "Sales Header"; @@ -1309,5 +2162,20 @@ codeunit 148004 "Test Verifactu Export" Assert.IsTrue(XMLText.Contains('Cabecera'), 'XML should contain Cabecera'); Assert.IsTrue(XMLText.Contains('RegistroFactura'), 'XML should contain RegistroFactura'); end; + + local procedure CountOccurrences(SourceText: Text; SearchText: Text): Integer + var + Position: Integer; + Count: Integer; + begin + Count := 0; + Position := StrPos(SourceText, SearchText); + while Position > 0 do begin + Count += 1; + SourceText := CopyStr(SourceText, Position + StrLen(SearchText)); + Position := StrPos(SourceText, SearchText); + end; + exit(Count); + end; } diff --git a/Apps/FI/ContosoCoffeeDemoDatasetFI/app/DemoData/Finance/2.Master Data/CreateCurrencyExRateFI.Codeunit.al b/Apps/FI/ContosoCoffeeDemoDatasetFI/app/DemoData/Finance/2.Master Data/CreateCurrencyExRateFI.Codeunit.al index e63c30199a..54e6e0bc44 100644 --- a/Apps/FI/ContosoCoffeeDemoDatasetFI/app/DemoData/Finance/2.Master Data/CreateCurrencyExRateFI.Codeunit.al +++ b/Apps/FI/ContosoCoffeeDemoDatasetFI/app/DemoData/Finance/2.Master Data/CreateCurrencyExRateFI.Codeunit.al @@ -200,4 +200,14 @@ codeunit 13433 "Create Currency Ex. Rate FI" CurrencyExchangeRate.Validate("Relational Exch. Rate Amount", RelationalExchRateAmount); CurrencyExchangeRate.Validate("Relational Adjmt Exch Rate Amt", RelationalAdjmtExchRateAmt); end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Add. Reporting Currency", OnBeforeGetResidualCurrencyAccounts, '', false, false)] + local procedure GetResidualCurrencyAccountsFI(var FXGainsAccount: Code[20]; var FXLossesAccount: Code[20]; var IsHandled: Boolean) + var + CreateFIGLAccount: Codeunit "Create FI GL Accounts"; + begin + FXGainsAccount := CreateFIGLAccount.Otherfinancialincome2(); + FXLossesAccount := CreateFIGLAccount.Financialexpenses9(); + IsHandled := true; + end; } diff --git a/Apps/GB/ContosoCoffeeDemoDatasetGB/app/DemoData/Finance/2.Master Data/CreateGBCurrency.Codeunit.al b/Apps/GB/ContosoCoffeeDemoDatasetGB/app/DemoData/Finance/2.Master Data/CreateGBCurrency.Codeunit.al index 2ba940674a..e320e1b3b8 100644 --- a/Apps/GB/ContosoCoffeeDemoDatasetGB/app/DemoData/Finance/2.Master Data/CreateGBCurrency.Codeunit.al +++ b/Apps/GB/ContosoCoffeeDemoDatasetGB/app/DemoData/Finance/2.Master Data/CreateGBCurrency.Codeunit.al @@ -78,4 +78,14 @@ codeunit 11500 "Create GB Currency" Currency.Validate("Realized Gains Acc.", RealizedGainsAcc); Currency.Validate("Realized Losses Acc.", RealizedLossesAcc); end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Add. Reporting Currency", OnBeforeGetResidualCurrencyAccounts, '', false, false)] + local procedure GetResidualCurrencyAccountsGB(var FXGainsAccount: Code[20]; var FXLossesAccount: Code[20]; var IsHandled: Boolean) + var + CreateGLAccount: Codeunit "Create G/L Account"; + begin + FXGainsAccount := CreateGLAccount.InterestIncome(); + FXLossesAccount := CreateGLAccount.InterestIncome(); + IsHandled := true; + end; } diff --git a/Apps/IN/INTDS/app/.resources/TDSUseCases/a8e114bf-f8cd-44db-a2b3-614bc18f4442.json b/Apps/IN/INTDS/app/.resources/TDSUseCases/a8e114bf-f8cd-44db-a2b3-614bc18f4442.json index f5aa3f5f5b..18afd87d2b 100644 --- a/Apps/IN/INTDS/app/.resources/TDSUseCases/a8e114bf-f8cd-44db-a2b3-614bc18f4442.json +++ b/Apps/IN/INTDS/app/.resources/TDSUseCases/a8e114bf-f8cd-44db-a2b3-614bc18f4442.json @@ -1,13935 +1,14019 @@ [ - { - "CaseID": "{A8E114BF-F8CD-44DB-A2B3-614BC18F4442}", - "Description": "Calculation of Tax Deduction at Source on Vendor Invoice where PAN No. is specified without Concessional Codes.\n", - "Version": 31, - "MinorVersion": 0, - "TaxType": "TDS", - "ChangedBy": "Microsoft", - "Code": "", - "TaxEntity": "Purchase Line", - "ParentUseCase": "Calculation of Tax Deduction at Source on Vendor Invoice (through Purchase Order/Purchase Invoice).\n", - "ParentCaseId": "{B8483E82-4EAB-43DE-B423-B1371AAA9CE0}", - "PresentationOrder": 568, - "Indent": 1, - "PostingTableName": "TDS Posting Setup", - "PostingTableFilters": [ - { - "FiterFieldName": "TDS Section", + { + "CaseID": "{A8E114BF-F8CD-44DB-A2B3-614BC18F4442}", + "Description": "Calculation of Tax Deduction at Source on Vendor Invoice where PAN No. is specified without Concessional Codes.\n", + "Version": 32, + "MinorVersion": 0, + "TaxType": "TDS", + "ChangedBy": "Microsoft", + "Code": "", + "TaxEntity": "Purchase Line", + "ParentUseCase": "Calculation of Tax Deduction at Source on Vendor Invoice (through Purchase Order/Purchase Invoice).\n", + "ParentCaseId": "{B8483E82-4EAB-43DE-B423-B1371AAA9CE0}", + "PresentationOrder": 570, + "Indent": 1, + "PostingTableName": "TDS Posting Setup", + "PostingTableFilters": [ + { + "FiterFieldName": "TDS Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FiterFieldName": "Effective Date", + "FilterType": "Is Less Than Or Equals To", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Posting Date", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", "FilterType": "Equals", "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + } + } + ], + "Attributes": [ + { + "Name": "Assessee Code", + "When": [ + { + "ValueType": "Relation", + "Sequence": 0, + "Relation": { + "IsCurrentRecord": false, + "TableName": "Vendor", + "TableFilters": [ + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { "Type": "Lookup", "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." } + } } - }, - { - "FiterFieldName": "Effective Date", - "FilterType": "Is Less Than Or Equals To", - "FilterValue": { + ] + } + } + ] + }, + { + "Name": "PAN No.", + "When": [ + { + "ValueType": "Relation", + "Sequence": 0, + "Relation": { + "IsCurrentRecord": false, + "TableName": "Vendor", + "TableFilters": [ + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { "Type": "Lookup", "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Posting Date", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." } + } } + ] } - ], - "Attributes": [ - { - "Name": "Assessee Code", - "When": [ - { - "ValueType": "Relation", - "Sequence": 0, - "Relation": { - "IsCurrentRecord": false, - "TableName": "Vendor", - "TableFilters": [ - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - } - ] + } + ] + } + ], + "RateColumns": [ + { + "Name": "Effective Date", + "When": [ + { + "ValueType": "Lookup", + "Sequence": 0, + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Posting Date", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + } + ] + } + ], + "ComputationVariables": [ + { + "Name": "TotalAmount", + "Datatype": "Number" + }, + { + "Name": "TDSTaxableAmount", + "Datatype": "Number" + }, + { + "Name": "SurchargeBaseAmt", + "Datatype": "Number" + }, + { + "Name": "TDSAmount", + "Datatype": "Number" + }, + { + "Name": "PrevInvAmountLCY", + "Datatype": "Number" + }, + { + "Name": "PrevInvAmount", + "Datatype": "Number" + }, + { + "Name": "InvoiceAmount", + "Datatype": "Number" + }, + { + "Name": "PaymentAmount", + "Datatype": "Number" + }, + { + "Name": "PreviousContractAmount", + "Datatype": "Number" + }, + { + "Name": "TotalInvAmountLCY", + "Datatype": "Number" + }, + { + "Name": "TotalInvAmount", + "Datatype": "Number" + }, + { + "Name": "TotalInvAmtWOContractLCY", + "Datatype": "Number" + }, + { + "Name": "TotalInvAmtWOContract", + "Datatype": "Number" + }, + { + "Name": "PreSurchargeBaseAmt", + "Datatype": "Number" + }, + { + "Name": "TotalSurchargeBaseAmt", + "Datatype": "Number" + }, + { + "Name": "PositiveAmount", + "Datatype": "Number" + }, + { + "Name": "PositiveAmountLCY", + "Datatype": "Number" + }, + { + "Name": "TDSBaseAmt", + "Datatype": "Number" + }, + { + "Name": "FiscalYearStartDate", + "Datatype": "Date" + }, + { + "Name": "FiscalYearEndDate", + "Datatype": "Date" + }, + { + "Name": "AccountingDateFilter", + "Datatype": "String" + }, + { + "Name": "TotalCurrAmountLCY", + "Datatype": "Number" + }, + { + "Name": "PositiveTotalCurrAmountLCY", + "Datatype": "Number" + }, + { + "Name": "AppliedAmount", + "Datatype": "Number" + }, + { + "Name": "TotalTaxableInvAmount", + "Datatype": "Number" + }, + { + "Name": "TotalTaxableInvAmtWOContract", + "Datatype": "Number" + }, + { + "Name": "BatchAmountLCY", + "Datatype": "Number" + }, + { + "Name": "BatchPaymentAmountLCY", + "Datatype": "Number" + }, + { + "Name": "BatchInvoiceAmountLCY", + "Datatype": "Number" + }, + { + "Name": "PositiveAmtExclGST", + "Datatype": "Number" + }, + { + "Name": "TaxableAmountExclApplied", + "Datatype": "Number" + }, + { + "Name": "TransactionNo", + "Datatype": "Number" + }, + { + "Name": "RecID", + "Datatype": "String" + }, + { + "Name": "GSTAmount", + "Datatype": "Number" + }, + { + "Name": "AdjustedInvAmount", + "Datatype": "Number" + }, + { + "Name": "PositiveAmountExclThisLine", + "Datatype": "Number" + }, + { + "Name": "PositiveAmountLCYExclThisLine", + "Datatype": "Number" + }, + { + "Name": "TotalInvAmountLCYExclThisLine", + "Datatype": "Number" + }, + { + "Name": "PositiveAmountTillThisLine", + "Datatype": "Number" + }, + { + "Name": "TotalCurrentInvAmt", + "Datatype": "Number" + }, + { + "Name": "PrevPerContractAmt", + "Datatype": "Number" + }, + { + "Name": "TotalAmtExclPerContract", + "Datatype": "Number" + }, + { + "Name": "PreviousTDSAmount", + "Datatype": "Number" + }, + { + "Name": "CurrentPOTDSAmount", + "Datatype": "Number" + }, + { + "Name": "DocumentType", + "Datatype": "String" + }, + { + "Name": "DocumentNo", + "Datatype": "String" + }, + { + "Name": "LineN", + "Datatype": "String" + }, + { + "Name": "RecdID", + "Datatype": "String" + }, + { + "Name": "PreviousBaseAmtWithTDS", + "Datatype": "Number" + }, + { + "Name": "AppliedTDSAmount", + "Datatype": "Number" + }, + { + "Name": "CrossPerContractValue", + "Datatype": "Number" + }, + { + "Name": "CurrentLineAmount", + "Datatype": "Number" + }, + { + "Name": "LineAmountTillThisLine", + "Datatype": "Number" + }, + { + "Name": "LineCrossedThresholdAmount", + "Datatype": "Number" + }, + { + "Name": "CurrentPOContractAmount", + "Datatype": "Number" + }, + { + "Name": "OverAndAboveThreshold", + "Datatype": "Number" + }, + { + "Name": "PreviousLineGSTAmount", + "Datatype": "Number" + }, + { + "Name": "BalanceAmount", + "Datatype": "Number" + }, + { + "Name": "ThresholdTotal", + "Datatype": "Number" + }, + { + "Name": "TotalPrevAndCurrentInvAmt", + "Datatype": "Number" + } + ], + "ComputationScript": [ + { + "ActivityType": "COMMENT", + "Activity": { + "Comment": "Created string for current financial year" + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "FiscalYearStartDate", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Tax Accounting Period", + "TableFieldName": "Starting Date", + "Method": "Last", + "TableFilters": [ + { + "FiterFieldName": "Tax Type Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Tax Type", + "TableFieldName": "Accounting Period", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Setup", + "TableFieldName": "Tax Type", + "Method": "First", + "TableFilters": [] + } + } } + ] } - ] - }, - { - "Name": "PAN No.", - "When": [ - { - "ValueType": "Relation", - "Sequence": 0, - "Relation": { - "IsCurrentRecord": false, - "TableName": "Vendor", - "TableFilters": [ - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - } - ] + } + }, + { + "FiterFieldName": "Starting Date", + "FilterType": "Is Less Than Or Equals To", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Posting Date", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } } + ] } - ] + } + }, + { + "FiterFieldName": "New Fiscal Year", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "true" + } + }, + { + "FiterFieldName": "Closed", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "false" + } + } + ] } - ], - "RateColumns": [ - { - "Name": "Effective Date", - "When": [ - { - "ValueType": "Lookup", - "Sequence": 0, - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Posting Date", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "FiscalYearStartDate" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "FiscalYearStartDate", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Posting Date", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + } + } + } + ] + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "FiscalYearEndDate", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Tax Accounting Period", + "TableFieldName": "Ending Date", + "Method": "Last", + "TableFilters": [ + { + "FiterFieldName": "Tax Type Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Tax Type", + "TableFieldName": "Accounting Period", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Setup", + "TableFieldName": "Tax Type", + "Method": "First", + "TableFilters": [] + } + } } + ] } - ] + } + }, + { + "FiterFieldName": "New Fiscal Year", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "false" + } + }, + { + "FiterFieldName": "Closed", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "false" + } + }, + { + "FiterFieldName": "Ending Date", + "FilterType": "Is Greater Than Or Equals To", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Posting Date", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + } + } + ] } - ], - "ComputationVariables": [ - { - "Name": "TotalAmount", - "Datatype": "Number" - }, - { - "Name": "TDSTaxableAmount", - "Datatype": "Number" - }, - { - "Name": "SurchargeBaseAmt", - "Datatype": "Number" - }, - { - "Name": "TDSAmount", - "Datatype": "Number" - }, - { - "Name": "PrevInvAmountLCY", - "Datatype": "Number" - }, - { - "Name": "PrevInvAmount", - "Datatype": "Number" - }, - { - "Name": "InvoiceAmount", - "Datatype": "Number" - }, - { - "Name": "PaymentAmount", - "Datatype": "Number" - }, - { - "Name": "PreviousContractAmount", - "Datatype": "Number" - }, - { - "Name": "TotalInvAmountLCY", - "Datatype": "Number" - }, - { - "Name": "TotalInvAmount", - "Datatype": "Number" - }, - { - "Name": "TotalInvAmtWOContractLCY", - "Datatype": "Number" - }, - { - "Name": "TotalInvAmtWOContract", - "Datatype": "Number" - }, - { - "Name": "PreSurchargeBaseAmt", - "Datatype": "Number" - }, - { - "Name": "TotalSurchargeBaseAmt", - "Datatype": "Number" - }, - { - "Name": "PositiveAmount", - "Datatype": "Number" - }, - { - "Name": "PositiveAmountLCY", - "Datatype": "Number" - }, - { - "Name": "TDSBaseAmt", - "Datatype": "Number" - }, - { - "Name": "FiscalYearStartDate", - "Datatype": "Date" - }, - { - "Name": "FiscalYearEndDate", - "Datatype": "Date" - }, - { - "Name": "AccountingDateFilter", - "Datatype": "String" - }, - { - "Name": "TotalCurrAmountLCY", - "Datatype": "Number" - }, - { - "Name": "PositiveTotalCurrAmountLCY", - "Datatype": "Number" - }, - { - "Name": "AppliedAmount", - "Datatype": "Number" - }, - { - "Name": "TotalTaxableInvAmount", - "Datatype": "Number" - }, - { - "Name": "TotalTaxableInvAmtWOContract", - "Datatype": "Number" - }, - { - "Name": "BatchAmountLCY", - "Datatype": "Number" - }, - { - "Name": "BatchPaymentAmountLCY", - "Datatype": "Number" - }, - { - "Name": "BatchInvoiceAmountLCY", - "Datatype": "Number" - }, - { - "Name": "PositiveAmtExclGST", - "Datatype": "Number" - }, - { - "Name": "TaxableAmountExclApplied", - "Datatype": "Number" - }, - { - "Name": "TransactionNo", - "Datatype": "Number" - }, - { - "Name": "RecID", - "Datatype": "String" - }, - { - "Name": "GSTAmount", - "Datatype": "Number" - }, - { - "Name": "AdjustedInvAmount", - "Datatype": "Number" - }, - { - "Name": "PositiveAmountExclThisLine", - "Datatype": "Number" - }, - { - "Name": "PositiveAmountLCYExclThisLine", - "Datatype": "Number" - }, - { - "Name": "TotalInvAmountLCYExclThisLine", - "Datatype": "Number" + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "FiscalYearEndDate" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "FiscalYearEndDate", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Posting Date", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + } + } + } + ] + } + }, + { + "ActivityType": "STRINGEXPRESSION", + "Activity": { + "OutputVariableName": "AccountingDateFilter", + "Expression": "{StartDate}..{EndDate}", + "Token": [ + { + "TokenName": "EndDate", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "FiscalYearEndDate" + } + } }, { - "Name": "PositiveAmountTillThisLine", - "Datatype": "Number" - }, - { - "Name": "TotalCurrentInvAmt", - "Datatype": "Number" - }, - { - "Name": "PrevPerContractAmt", - "Datatype": "Number" - }, - { - "Name": "TotalAmtExclPerContract", - "Datatype": "Number" - }, - { - "Name": "PreviousTDSAmount", - "Datatype": "Number" - }, - { - "Name": "CurrentPOTDSAmount", - "Datatype": "Number" - }, - { - "Name": "DocumentType", - "Datatype": "String" - }, - { - "Name": "DocumentNo", - "Datatype": "String" - }, - { - "Name": "LineN", - "Datatype": "String" - }, - { - "Name": "RecdID", - "Datatype": "String" - }, - { - "Name": "PreviousBaseAmtWithTDS", - "Datatype": "Number" - }, - { - "Name": "AppliedTDSAmount", - "Datatype": "Number" - }, - { - "Name": "CrossPerContractValue", - "Datatype": "Number" - }, - { - "Name": "CurrentLineAmount", - "Datatype": "Number" - }, - { - "Name": "LineAmountTillThisLine", - "Datatype": "Number" - }, - { - "Name": "LineCrossedThresholdAmount", - "Datatype": "Number" - }, - { - "Name": "CurrentPOContractAmount", - "Datatype": "Number" - }, - { - "Name": "OverAndAboveThreshold", - "Datatype": "Number" - }, - { - "Name": "PreviousLineGSTAmount", - "Datatype": "Number" - }, - { - "Name": "BalanceAmount", - "Datatype": "Number" - }, - { - "Name": "ThresholdTotal", - "Datatype": "Number" - }, - { - "Name": "TotalPrevAndCurrentInvAmt", - "Datatype": "Number" + "TokenName": "StartDate", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "FiscalYearStartDate" + } + } } - ], - "ComputationScript": [ - { - "ActivityType": "COMMENT", - "Activity": { - "Comment": "Created string for current financial year" + ] + } + }, + { + "ActivityType": "COMMENT", + "Activity": { + "Comment": "Total posted Invoice amount" + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "InvoiceAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Entry", + "TableFieldName": "Invoice Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Vendor No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FiterFieldName": "Assessee Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Tax Attributes", + "AttributeName": "Assessee Code" + } + } + }, + { + "FiterFieldName": "Posting Date", + "FilterType": "CAL Filter", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AccountingDateFilter" + } + } + }, + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "Invoice" + } + } + ] + } + } + } + }, + { + "ActivityType": "COMMENT", + "Activity": { + "Comment": "Get TDS Adjusted Invoice Amount" + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "AdjustedInvAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Entry", + "TableFieldName": "Invoice Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Vendor No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FiterFieldName": "Assessee Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Tax Attributes", + "AttributeName": "Assessee Code" + } + } + }, + { + "FiterFieldName": "Posting Date", + "FilterType": "CAL Filter", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AccountingDateFilter" + } + } + }, + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "Invoice" + } + }, + { + "FiterFieldName": "Adjusted", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "true" + } + } + ] + } + } + } + }, + { + "ActivityType": "COMMENT", + "Activity": { + "Comment": "Total posted Payment amount" + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "PaymentAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Entry", + "TableFieldName": "Payment Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Vendor No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FiterFieldName": "Assessee Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Tax Attributes", + "AttributeName": "Assessee Code" + } + } + }, + { + "FiterFieldName": "Posting Date", + "FilterType": "CAL Filter", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AccountingDateFilter" + } + } + }, + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "Payment" + } + } + ] + } + } + } + }, + { + "ActivityType": "COMMENT", + "Activity": { + "Comment": "Sum of posted payment and invoice amount" + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Entry", + "TableFieldName": "Applied", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Vendor No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FiterFieldName": "Assessee Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Tax Attributes", + "AttributeName": "Assessee Code" + } + } + }, + { + "FiterFieldName": "Posting Date", + "FilterType": "CAL Filter", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AccountingDateFilter" + } + } + }, + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "Payment" + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "true" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "PrevInvAmountLCY", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PaymentAmount" + } } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] }, - { - "ActivityType": "SETVARIABLE", + "Body": [ + { + "ActivityType": "NUMERICEXPRESSION", "Activity": { - "OutputVariableName": "FiscalYearStartDate", - "OutputValue": { + "VariableName": "PrevInvAmountLCY", + "Expression": "PostedInvoiceAmount+PostedPaymentAmount", + "Tokens": [ + { + "TokenName": "PostedInvoiceAmount", + "TokenValue": { "Type": "Lookup", "Lookup": { - "SourceType": "Table", - "TableName": "Tax Accounting Period", - "TableFieldName": "Starting Date", - "Method": "Last", - "TableFilters": [ - { - "FiterFieldName": "Tax Type Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Tax Type", - "TableFieldName": "Accounting Period", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "TDS Setup", - "TableFieldName": "Tax Type", - "Method": "First", - "TableFilters": [] - } - } - } - ] - } - } - }, - { - "FiterFieldName": "Starting Date", - "FilterType": "Is Less Than Or Equals To", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Posting Date", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - } - }, - { - "FiterFieldName": "New Fiscal Year", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "true" - } - }, - { - "FiterFieldName": "Closed", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "false" - } - } - ] + "SourceType": "Variable", + "VariableName": "InvoiceAmount" } - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "FiscalYearStartDate" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] + } }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "FiscalYearStartDate", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Posting Date", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - } - } + { + "TokenName": "PostedPaymentAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PaymentAmount" } - ] + } + } + ] + } + } + ] + } + } + }, + { + "ActivityType": "COMMENT", + "Activity": { + "Comment": "Total posted contract amount" + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "PreviousContractAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Entry", + "TableFieldName": "TDS Base Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Vendor No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FiterFieldName": "Posting Date", + "FilterType": "CAL Filter", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AccountingDateFilter" + } + } + }, + { + "FiterFieldName": "Per Contract", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "true" + } + } + ] + } + } + } + }, + { + "ActivityType": "COMMENT", + "Activity": { + "Comment": "Total Posted amount without contract amount" + } + }, + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TotalInvAmtWOContractLCY", + "Expression": "TotalPostedAmount-PostedContractAmount", + "Tokens": [ + { + "TokenName": "PostedContractAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PreviousContractAmount" } + } }, { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "FiscalYearEndDate", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Tax Accounting Period", - "TableFieldName": "Ending Date", - "Method": "Last", - "TableFilters": [ - { - "FiterFieldName": "Tax Type Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Tax Type", - "TableFieldName": "Accounting Period", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "TDS Setup", - "TableFieldName": "Tax Type", - "Method": "First", - "TableFilters": [] - } - } - } - ] - } - } - }, - { - "FiterFieldName": "New Fiscal Year", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "false" - } - }, - { - "FiterFieldName": "Closed", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "false" - } - }, - { - "FiterFieldName": "Ending Date", - "FilterType": "Is Greater Than Or Equals To", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Posting Date", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - } - } - ] - } + "TokenName": "TotalPostedAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" + } + } + } + ] + } + }, + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TotalInvAmountLCY", + "Operator": "Plus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + } + }, + { + "ActivityType": "COMMENT", + "Activity": { + "Comment": "Converted Amount from LCY to FCY" + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "PositiveAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Line", + "TableFieldName": "Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "Document No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + }, + { + "FiterFieldName": "TDS Section Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" } + } } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "FiscalYearEndDate" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "FiscalYearEndDate", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Posting Date", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - } - } + ] + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "PositiveAmountExclThisLine", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Line", + "TableFieldName": "Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "Document No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + }, + { + "FiterFieldName": "Line No.", + "FilterType": "Is Less Than", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Line No." + } + } + }, + { + "FiterFieldName": "TDS Section Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + } + ] + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Currency Code", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" } - }, - { - "ActivityType": "STRINGEXPRESSION", - "Activity": { - "OutputVariableName": "AccountingDateFilter", - "Expression": "{StartDate}..{EndDate}", - "Token": [ - { - "TokenName": "EndDate", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "FiscalYearEndDate" - } - } - }, - { - "TokenName": "StartDate", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "FiscalYearStartDate" - } - } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TotalInvAmount", + "Operator": "Multiply By", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Currency Factor", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + } + } + }, + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TotalInvAmtWOContract", + "Operator": "Multiply By", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmtWOContractLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Currency Factor", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + } + } + }, + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "PrevInvAmount", + "Operator": "Multiply By", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Currency Factor", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + } + } + }, + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "PositiveAmountLCY", + "Operator": "Divided By", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmount" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Currency Factor", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } } + } ] + } } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] }, - { - "ActivityType": "COMMENT", + "Body": [ + { + "ActivityType": "SETVARIABLE", "Activity": { - "Comment": "Total posted Invoice amount" + "OutputVariableName": "TotalInvAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" + } + } } - }, - { + }, + { "ActivityType": "SETVARIABLE", "Activity": { - "OutputVariableName": "InvoiceAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "TDS Entry", - "TableFieldName": "Invoice Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Vendor No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - }, - { - "FiterFieldName": "Assessee Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Tax Attributes", - "AttributeName": "Assessee Code" - } - } - }, - { - "FiterFieldName": "Posting Date", - "FilterType": "CAL Filter", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AccountingDateFilter" - } - } - }, - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "Invoice" - } - } - ] - } + "OutputVariableName": "TotalInvAmtWOContract", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmtWOContractLCY" } + } } - }, - { - "ActivityType": "COMMENT", + }, + { + "ActivityType": "SETVARIABLE", "Activity": { - "Comment": "Get TDS Adjusted Invoice Amount" + "OutputVariableName": "PrevInvAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" + } + } } - }, - { + }, + { "ActivityType": "SETVARIABLE", "Activity": { - "OutputVariableName": "AdjustedInvAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { + "OutputVariableName": "PositiveAmountLCY", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmount" + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "PositiveAmountLCYExclThisLine", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountExclThisLine" + } + } + } + } + ] + } + } + }, + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TotalInvAmountLCY", + "Operator": "Plus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountLCYExclThisLine" + } + } + } + }, + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TotalInvAmountLCYExclThisLine", + "Operator": "Minus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + } + }, + { + "ActivityType": "COMMENT", + "Activity": { + "Comment": "Get applied amount" + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. Type", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "Payment" + } + }, + { + "Operator": "and", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "AppliedAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Vendor Ledger Entry", + "TableFieldName": "Amount to Apply", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { "SourceType": "Table", - "TableName": "TDS Entry", - "TableFieldName": "Invoice Amount", - "Method": "Sum", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. Type", + "Method": "First", "TableFilters": [ - { - "FiterFieldName": "Vendor No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - }, - { - "FiterFieldName": "Assessee Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Tax Attributes", - "AttributeName": "Assessee Code" - } - } - }, - { - "FiterFieldName": "Posting Date", - "FilterType": "CAL Filter", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AccountingDateFilter" - } - } - }, - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "Invoice" - } - }, - { - "FiterFieldName": "Adjusted", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "true" - } + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + } + }, + { + "FiterFieldName": "Document No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } } + } ] + } + } + } + ] + } + } + } + } + ] + } + }, + { + "ActivityType": "COMMENT", + "Activity": { + "Comment": "Get GST Amount" + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "GSTAmount", + "OutputValue": { + "Type": "Constant", + "Value": "0" + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Include GST in TDS Base", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "true" + } + } + ] + }, + "Body": [ + { + "ActivityType": "STRINGEXPRESSION", + "Activity": { + "OutputVariableName": "RecID", + "Expression": "Purchase Line: {DocType},{DocumentNo},{LineNo}", + "Token": [ + { + "TokenName": "DocType", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "TokenName": "DocumentNo", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + }, + { + "TokenName": "LineNo", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Line No." + } + } + } + ] + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "GSTAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Tax Transaction Value", + "TableFieldName": "Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Tax Record ID", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "RecID" + } + } + }, + { + "FiterFieldName": "Value Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "COMPONENT" + } + }, + { + "FiterFieldName": "Percent", + "FilterType": "Not Equals", + "FilterValue": { + "Type": "Constant", + "Value": "0" + } + }, + { + "FiterFieldName": "Tax Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "GST Setup", + "TableFieldName": "GST Tax Type", + "Method": "First", + "TableFilters": [] + } + } + } + ] + } + } + } + }, + { + "ActivityType": "LOOPTHROUGHRECORDS", + "Activity": { + "TableName": "Purchase Line", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "Document No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + }, + { + "FiterFieldName": "Line No.", + "FilterType": "Is Less Than", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Line No." + } + } + } + ], + "LoopThroughRecordFields": [ + { + "FieldName": "Document Type", + "VariableName": "DocumentType", + "CalculateSum": false + }, + { + "FieldName": "Document No.", + "VariableName": "DocumentNo", + "CalculateSum": false + }, + { + "FieldName": "Line No.", + "VariableName": "LineN", + "CalculateSum": false + } + ], + "Body": [ + { + "ActivityType": "STRINGEXPRESSION", + "Activity": { + "OutputVariableName": "RecdID", + "Expression": "Purchase Line: {DocType},{DocumentNo},{LineNo}", + "Token": [ + { + "TokenName": "DocType", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "DocumentType" + } + } + }, + { + "TokenName": "DocumentNo", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "DocumentNo" + } + } + }, + { + "TokenName": "LineNo", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "LineN" + } + } + } + ] + } + }, + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "PreviousLineGSTAmount", + "Operator": "Plus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PreviousLineGSTAmount" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Tax Transaction Value", + "TableFieldName": "Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Tax Record ID", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "RecdID" + } + } + }, + { + "FiterFieldName": "Value Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "COMPONENT" + } + }, + { + "FiterFieldName": "Percent", + "FilterType": "Not Equals", + "FilterValue": { + "Type": "Constant", + "Value": "0" + } + }, + { + "FiterFieldName": "Tax Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "GST Setup", + "TableFieldName": "GST Tax Type", + "Method": "First", + "TableFilters": [] + } + } + } + ] } + } } + } + ] + } + } + ] + } + }, + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TaxableAmountExclApplied", + "Expression": "Amount+GSTAmount", + "Tokens": [ + { + "TokenName": "Amount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" } + } }, { - "ActivityType": "COMMENT", - "Activity": { - "Comment": "Total posted Payment amount" + "TokenName": "GSTAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "GSTAmount" + } + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmount" + } } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TaxableAmountExclApplied", + "Expression": "Amount+GSTAmount-AppliedAmount", + "Tokens": [ + { + "TokenName": "Amount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + }, + { + "TokenName": "AppliedAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + }, + { + "TokenName": "GSTAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "GSTAmount" + } + } + } + ] + } + }, + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "PositiveAmountTillThisLine", + "Expression": "PositiveAmountExclThisLine+Amount+GSTAmount", + "Tokens": [ + { + "TokenName": "Amount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + }, + { + "TokenName": "GSTAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "GSTAmount" + } + } + }, + { + "TokenName": "PositiveAmountExclThisLine", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountExclThisLine" + } + } + } + ] + } }, { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "PaymentAmount", - "OutputValue": { - "Type": "Lookup", + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { "Lookup": { - "SourceType": "Table", - "TableName": "TDS Entry", - "TableFieldName": "Payment Amount", - "Method": "Sum", - "TableFilters": [ + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TaxableAmountExclApplied", + "Expression": "PositiveAmountTillThisLine-AppliedAmount", + "Tokens": [ + { + "TokenName": "AppliedAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + }, + { + "TokenName": "PositiveAmountTillThisLine", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" + } + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ { - "FiterFieldName": "Vendor No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } + "Operator": " ", + "ConditionType": "Is Less Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" } - }, - { - "FiterFieldName": "Assessee Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Tax Attributes", - "AttributeName": "Assessee Code" - } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" } - }, - { - "FiterFieldName": "Posting Date", - "FilterType": "CAL Filter", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AccountingDateFilter" - } + } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TaxableAmountExclApplied", + "Operator": "Plus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TaxableAmountExclApplied" } - }, - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "Payment" + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" } + } } - ] - } - } - } - }, - { - "ActivityType": "COMMENT", - "Activity": { - "Comment": "Sum of posted payment and invoice amount" - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "TDS Entry", - "TableFieldName": "Applied", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Vendor No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Calc. Over & Above Threshold" + } + }, + "RHS": { + "Type": "Constant", + "Value": "1" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ { - "FiterFieldName": "Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TaxableAmountExclApplied" } - }, - { - "FiterFieldName": "Assessee Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Tax Attributes", - "AttributeName": "Assessee Code" - } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" } - }, - { - "FiterFieldName": "Posting Date", - "FilterType": "CAL Filter", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AccountingDateFilter" - } + } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TaxableAmountExclApplied", + "Operator": "Minus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TaxableAmountExclApplied" } - }, + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "Payment" + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TaxableAmountExclApplied", + "OutputValue": { + "Type": "Constant", + "Value": "" } + } } - ] + ] + } + } } - }, - "RHS": { - "Type": "Constant", - "Value": "true" + ] } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "PrevInvAmountLCY", - "OutputValue": { - "Type": "Lookup", - "Lookup": { + } + ], + "ElseIf": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { "SourceType": "Variable", - "VariableName": "PaymentAmount" + "VariableName": "TaxableAmountExclApplied" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TaxableAmountExclApplied", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } } + } } + ] } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TaxableAmountExclApplied" + } + } + } } - ], - "ElseIf": { + ], + "ElseIf": { "Condition": { - "Body": [] + "Body": [] }, "Body": [ - { - "ActivityType": "NUMERICEXPRESSION", + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TaxableAmountExclApplied", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } + } + ] + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Allowed Sections", + "TableFieldName": "", + "Method": "Exist", + "TableFilters": [ + { + "FiterFieldName": "Vendor No", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "TDS Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FiterFieldName": "Threshold Overlook", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "true" + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "true" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountExclThisLine" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", "Activity": { - "VariableName": "PrevInvAmountLCY", - "Expression": "PostedInvoiceAmount+PostedPaymentAmount", - "Tokens": [ + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TaxableAmountExclApplied", + "Operator": "Minus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TaxableAmountExclApplied", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } + } + ] + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ { - "TokenName": "PostedInvoiceAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "InvoiceAmount" - } + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountExclThisLine" } - }, + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TaxableAmountExclApplied", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ { - "TokenName": "PostedPaymentAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TaxableAmountExclApplied", + "Expression": "PurchLineAmt+(PrevPurchLineAmt-AppliedAmt)", + "Tokens": [ + { + "TokenName": "AppliedAmt", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + }, + { + "TokenName": "PrevPurchLineAmt", + "TokenValue": { + "Type": "Lookup", + "Lookup": { "SourceType": "Variable", - "VariableName": "PaymentAmount" + "VariableName": "PositiveAmountExclThisLine" + } + } + }, + { + "TokenName": "PurchLineAmt", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } } - } + } + ] + } } - ] + ] + } + } } + ] } - ] + } + } + ] + } + } + ] + } + } + ], + "ElseIf": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than Or Equals To", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmount" } + } } + ] }, - { - "ActivityType": "COMMENT", + "Body": [ + { + "ActivityType": "SETVARIABLE", "Activity": { - "Comment": "Total posted contract amount" + "OutputVariableName": "TaxableAmountExclApplied", + "OutputValue": { + "Type": "Constant", + "Value": "" + } } - }, - { - "ActivityType": "SETVARIABLE", + }, + { + "ActivityType": "NUMERICEXPRESSION", "Activity": { - "OutputVariableName": "PreviousContractAmount", - "OutputValue": { + "VariableName": "PositiveAmountTillThisLine", + "Expression": "PositiveAmountExclThisLine+Amount+GSTAmount", + "Tokens": [ + { + "TokenName": "Amount", + "TokenValue": { "Type": "Lookup", "Lookup": { - "SourceType": "Table", - "TableName": "TDS Entry", - "TableFieldName": "TDS Base Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Vendor No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - }, - { - "FiterFieldName": "Posting Date", - "FilterType": "CAL Filter", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AccountingDateFilter" - } - } - }, - { - "FiterFieldName": "Per Contract", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "true" - } - } - ] + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + }, + { + "TokenName": "GSTAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "GSTAmount" + } + } + }, + { + "TokenName": "PositiveAmountExclThisLine", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountExclThisLine" } + } } + ] } + } + ] + } + } + }, + { + "ActivityType": "COMMENT", + "Activity": { + "Comment": "Total Taxable Amount" + } + }, + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TotalTaxableInvAmount", + "Expression": "(PostedAmount+Amount+GSTAmount)-AppliedAmount-AdjustedInvAmount", + "Tokens": [ + { + "TokenName": "AdjustedInvAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AdjustedInvAmount" + } + } }, { - "ActivityType": "COMMENT", - "Activity": { - "Comment": "Total Posted amount without contract amount" + "TokenName": "Amount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" } + } }, { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TotalInvAmtWOContractLCY", - "Expression": "TotalPostedAmount-PostedContractAmount", - "Tokens": [ - { - "TokenName": "PostedContractAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PreviousContractAmount" - } - } - }, - { - "TokenName": "TotalPostedAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" - } - } - } - ] + "TokenName": "AppliedAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" } + } }, { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TotalInvAmountLCY", - "Operator": "Plus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } + "TokenName": "GSTAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "GSTAmount" + } + } + }, + { + "TokenName": "PostedAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmount" + } + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalTaxableInvAmount" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TotalTaxableInvAmount", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } + } + ] + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TotalCurrentInvAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Line", + "TableFieldName": "Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "Document No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + }, + { + "FiterFieldName": "TDS Section Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" } + } + } + ] + } + } + } + }, + { + "ActivityType": "COMMENT", + "Activity": { + "Comment": "Total Taxable Amount excluding posted contract amount" + } + }, + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TotalTaxableInvAmtWOContract", + "Expression": "((PostedAmount+Amount)-ContractAmt+GSTAmount)-AppliedAmount-AdjustedInvAmount", + "Tokens": [ + { + "TokenName": "AdjustedInvAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AdjustedInvAmount" } + } }, { - "ActivityType": "COMMENT", - "Activity": { - "Comment": "Converted Amount from LCY to FCY" + "TokenName": "Amount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalCurrentInvAmt" } + } }, { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "PositiveAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", + "TokenName": "AppliedAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + }, + { + "TokenName": "ContractAmt", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PreviousContractAmount" + } + } + }, + { + "TokenName": "GSTAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "GSTAmount" + } + } + }, + { + "TokenName": "PostedAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmount" + } + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalTaxableInvAmtWOContract" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TotalTaxableInvAmtWOContract", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Include GST in TDS Base", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", "TableName": "Purchase Line", - "TableFieldName": "Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "Document No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - }, - { - "FiterFieldName": "TDS Section Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - } - ] + "FieldName": "Document Type" + } } - } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "true" } - }, + } + ] + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TotalInvAmountLCY", + "Operator": "Plus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "GSTAmount" + } + } + } + }, + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TotalInvAmountLCY", + "Operator": "Plus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PreviousLineGSTAmount" + } + } + } + } + ] + } + }, + { + "ActivityType": "COMMENT", + "Activity": { + "Comment": "Condition to calculate TDS Amount considering Threshold limit" + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Allowed Sections", + "TableFieldName": "", + "Method": "Exist", + "TableFilters": [ + { + "FiterFieldName": "Vendor No", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "TDS Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FiterFieldName": "Threshold Overlook", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "true" + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "false" + } + } + ] + }, + "Body": [ { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "PositiveAmountExclThisLine", - "OutputValue": { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than Or Equals To", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" + } + }, + "RHS": { "Type": "Lookup", "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Line", - "TableFieldName": "Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "Document No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - }, - { - "FiterFieldName": "Line No.", - "FilterType": "Is Less Than", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Line No." - } - } - }, - { - "FiterFieldName": "TDS Section Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - } - ] + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" } + } } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { "Body": [ - { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { + { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Currency Code", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TotalInvAmount", - "Operator": "Multiply By", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" } - }, - "RHS": { + }, + "RHS": { "Type": "Lookup", "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Currency Factor", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" } + } } - } - }, - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TotalInvAmtWOContract", - "Operator": "Multiply By", - "LHS": { + ] + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "Operator": "Minus", + "LHS": { "Type": "Lookup", "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmtWOContractLCY" + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" } - }, - "RHS": { + }, + "RHS": { "Type": "Lookup", "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Currency Factor", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, + "SourceType": "Table", + "TableName": "TDS Entry", + "TableFieldName": "Invoice Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Vendor No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FiterFieldName": "Assessee Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Tax Attributes", + "AttributeName": "Assessee Code" + } + } + }, + { + "FiterFieldName": "Per Contract", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "true" + } + } + ] + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Calc. Over & Above Threshold" + } + }, + "RHS": { + "Type": "Constant", + "Value": "1" + } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TDSTaxableAmount", + "Expression": "TDSTaxableAmount-TDSThresholdAmount", + "Tokens": [ + { + "TokenName": "TDSTaxableAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSTaxableAmount" + } + } + }, + { + "TokenName": "TDSThresholdAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } + "Operator": " ", + "ConditionType": "Is Less Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSTaxableAmount" } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Constant", + "Value": "" + } } + } ] + } } + ] } - } - }, - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "PrevInvAmount", - "Operator": "Multiply By", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Currency Factor", - "Method": "First", - "TableFilters": [ + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Calc. Over & Above Threshold" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { "SourceType": "Current Record", "TableName": "Purchase Line", - "FieldName": "Document Type" + "FieldName": "Amount" + } } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { "SourceType": "Current Record", "TableName": "Purchase Line", - "FieldName": "Document No." + "FieldName": "Amount" + } } + } } + ] } + } ] + } } + ] } - } - }, - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "PositiveAmountLCY", - "Operator": "Divided By", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Currency Factor", - "Method": "First", - "TableFilters": [ + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TaxableAmountExclApplied" + } + } + } + ] + }, + "Body": [ { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountLCY" + } + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountLCY" + } + }, + "RHS": { "Type": "Lookup", "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" + "SourceType": "Variable", + "VariableName": "TaxableAmountExclApplied" } + } } + ] }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { "Type": "Lookup", "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" } + } + } + } + ] + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountLCYExclThisLine" + } } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountLCYExclThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + } + } + ] + } } - ] + ] + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Constant", + "Value": "0" + } + } + } + ] } + } } + ] } + } } - ], - "ElseIf": { + ], + "ElseIf": { "Condition": { - "Body": [] + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] }, "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TotalInvAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TotalInvAmtWOContract", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmtWOContractLCY" - } + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCYExclThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "PrevInvAmount", + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TaxableAmountExclApplied" + } } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "PositiveAmountLCY", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmount" + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Calc. Over & Above Threshold" + } + }, + "RHS": { + "Type": "Constant", + "Value": "1" + } } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "PositiveAmountLCYExclThisLine", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountExclThisLine" + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSTaxableAmount" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } + } + ] } - } + } + ] + } } - } - ] - } - } - }, - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TotalInvAmountLCY", - "Operator": "Plus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountLCYExclThisLine" - } - } - } - }, - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TotalInvAmountLCYExclThisLine", - "Operator": "Minus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - }, - { - "ActivityType": "COMMENT", - "Activity": { - "Comment": "Get applied amount" - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. Type", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" + "SourceType": "Variable", + "VariableName": "AppliedAmount" } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } } + ] }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { "Type": "Lookup", "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." + "SourceType": "Variable", + "VariableName": "TaxableAmountExclApplied" } + } } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "Payment" - } - }, - { - "Operator": "and", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + }, + { + "Operator": "and", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Calc. Over & Above Threshold" } + }, + "RHS": { + "Type": "Constant", + "Value": "1" + } } + ] }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", + "Body": [ + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TDSTaxableAmount", + "Expression": "TDSTaxableAmount-TDSThresholdAmount", + "Tokens": [ + { + "TokenName": "TDSTaxableAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSTaxableAmount" + } + } + }, + { + "TokenName": "TDSThresholdAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } + } + ] + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than", + "LHS": { "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." + "SourceType": "Variable", + "VariableName": "TDSTaxableAmount" } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Constant", + "Value": "" + } } + } + ] + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Constant", + "Value": "" + } } + } ] + } } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } + } + ] + } } + } ] - }, + } + } + } + ], + "ElseIf": { + "Condition": { "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "AppliedAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Vendor Ledger Entry", - "TableFieldName": "Amount to Apply", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. Type", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - } - }, - { - "FiterFieldName": "Document No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - } - } - ] - } - } - } + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } } + } ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TaxableAmountExclApplied" + } + } + } + } + ] } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] }, - { - "ActivityType": "COMMENT", + "Body": [ + { + "ActivityType": "SETVARIABLE", "Activity": { - "Comment": "Get GST Amount" + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TaxableAmountExclApplied" + } + } + } + } + ] + } + } + }, + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TDSAmount", + "Expression": "TDSTaxableAmt*TDSPer/100", + "Tokens": [ + { + "TokenName": "TDSPer", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component Percent", + "ComponentName": "TDS" + } + } + }, + { + "TokenName": "TDSTaxableAmt", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSTaxableAmount" + } + } + } + ] + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "PreSurchargeBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Entry", + "TableFieldName": "Surcharge Base Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Vendor No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FiterFieldName": "Assessee Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Tax Attributes", + "AttributeName": "Assessee Code" + } + } + }, + { + "FiterFieldName": "Posting Date", + "FilterType": "CAL Filter", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AccountingDateFilter" + } + } } + ] + } + } + } + }, + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TotalSurchargeBaseAmt", + "Expression": "PreSurchargeBaseAmt+TDSAmount", + "Tokens": [ + { + "TokenName": "PreSurchargeBaseAmt", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PreSurchargeBaseAmt" + } + } }, { + "TokenName": "TDSAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSAmount" + } + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Allowed Sections", + "TableFieldName": "", + "Method": "Exist", + "TableFilters": [ + { + "FiterFieldName": "Vendor No", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "TDS Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FiterFieldName": "Surcharge Overlook", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "true" + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "true" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Surcharge Threshold Amount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Surcharge Threshold Amount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "SurchargeBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalSurchargeBaseAmt" + } + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "SurchargeBaseAmt", + "OutputValue": { + "Type": "Constant", + "Value": "0" + } + } + } + ] + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "SurchargeBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSAmount" + } + } + } + } + ] + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { "ActivityType": "SETVARIABLE", "Activity": { - "OutputVariableName": "GSTAmount", - "OutputValue": { - "Type": "Constant", - "Value": "0" + "OutputVariableName": "SurchargeBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSAmount" } + } + } + } + ] + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSTaxableAmount" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSTaxableAmount" + } } + } }, { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + } + } + ] + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Include GST in TDS Base", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. Type", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } } - }, - "RHS": { - "Type": "Constant", - "Value": "true" - } - } - ] - }, - "Body": [ - { - "ActivityType": "STRINGEXPRESSION", - "Activity": { - "OutputVariableName": "RecID", - "Expression": "Purchase Line: {DocType},{DocumentNo},{LineNo}", - "Token": [ - { - "TokenName": "DocType", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "TokenName": "DocumentNo", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - }, - { - "TokenName": "LineNo", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Line No." - } - } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "Payment" + } + }, + { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } } + } ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" } - }, + } + ] + }, + "Body": [ { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "GSTAmount", - "OutputValue": { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + }, + "RHS": { "Type": "Lookup", "Lookup": { - "SourceType": "Table", - "TableName": "Tax Transaction Value", - "TableFieldName": "Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Tax Record ID", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "RecID" - } - } - }, - { - "FiterFieldName": "Value Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "COMPONENT" - } - }, - { - "FiterFieldName": "Percent", - "FilterType": "Not Equals", - "FilterValue": { - "Type": "Constant", - "Value": "0" - } - }, - { - "FiterFieldName": "Tax Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "GST Setup", - "TableFieldName": "GST Tax Type", - "Method": "First", - "TableFilters": [] - } - } - } - ] + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" } + } } - } - }, - { - "ActivityType": "LOOPTHROUGHRECORDS", + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } + } + ] + } + } + ], + "ElseIf": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCYExclThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", "Activity": { - "TableName": "Purchase Line", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "Document No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - }, - { - "FiterFieldName": "Line No.", - "FilterType": "Is Less Than", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Line No." - } - } - } - ], - "LoopThroughRecordFields": [ - { - "FieldName": "Document Type", - "VariableName": "DocumentType", - "CalculateSum": false - }, - { - "FieldName": "Document No.", - "VariableName": "DocumentNo", - "CalculateSum": false - }, - { - "FieldName": "Line No.", - "VariableName": "LineN", - "CalculateSum": false - } - ], - "Body": [ - { - "ActivityType": "STRINGEXPRESSION", - "Activity": { - "OutputVariableName": "RecdID", - "Expression": "Purchase Line: {DocType},{DocumentNo},{LineNo}", - "Token": [ - { - "TokenName": "DocType", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "DocumentType" - } - } - }, - { - "TokenName": "DocumentNo", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "DocumentNo" - } - } - }, - { - "TokenName": "LineNo", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "LineN" - } - } - } - ] - } - }, - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "PreviousLineGSTAmount", - "Operator": "Plus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PreviousLineGSTAmount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Tax Transaction Value", - "TableFieldName": "Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Tax Record ID", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "RecdID" - } - } - }, - { - "FiterFieldName": "Value Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "COMPONENT" - } - }, - { - "FiterFieldName": "Percent", - "FilterType": "Not Equals", - "FilterValue": { - "Type": "Constant", - "Value": "0" - } - }, - { - "FiterFieldName": "Tax Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "GST Setup", - "TableFieldName": "GST Tax Type", - "Method": "First", - "TableFilters": [] - } - } - } - ] - } - } - } - } - ] + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } } + } + ] + } + } + } + ] + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Include GST in TDS Base", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } } + } ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "true" + } + }, + { + "Operator": "and", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TaxableAmountExclApplied" + } } + } }, { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TaxableAmountExclApplied", - "Expression": "Amount+GSTAmount", - "Tokens": [ - { - "TokenName": "Amount", - "TokenValue": { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. Type", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { "Type": "Lookup", "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } } - }, - { - "TokenName": "GSTAmount", - "TokenValue": { + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "Payment" + } + }, + { + "Operator": "and", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { "Type": "Lookup", "Lookup": { - "SourceType": "Variable", - "VariableName": "GSTAmount" + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." } + } } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + } + } + } + ] + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Allowed Sections", + "TableFieldName": "Threshold Overlook", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Vendor No", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "TDS Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } } + } ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "true" } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSTaxableAmount" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } + } + ] + } }, { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. No.", + "Method": "First", + "TableFilters": [ { - "Operator": " ", - "ConditionType": "Is Less Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmount" - } + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." } + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSTaxableAmount" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" } + } ] - }, - "Body": [ - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TaxableAmountExclApplied", - "Expression": "Amount+GSTAmount-AppliedAmount", - "Tokens": [ - { - "TokenName": "Amount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - }, - { - "TokenName": "AppliedAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - }, - { - "TokenName": "GSTAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "GSTAmount" - } - } - } - ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + } + } + ] + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TaxableAmountExclApplied" + } + } + } + } + ] + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCYExclThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } + }, + { + "Operator": "and", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCYExclThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSTaxableAmount" + } + } + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Include GST in TDS Base", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "true" + } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "Operator": "Plus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "GSTAmount" + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + } + } + }, + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "CurrentLineAmount", + "Operator": "Plus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "GSTAmount" + } + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "CurrentLineAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + } + } + ] + } + } + } + ] + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "PreviousBaseAmtWithTDS", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Entry", + "TableFieldName": "TDS Base Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Vendor No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FiterFieldName": "Assessee Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Tax Attributes", + "AttributeName": "Assessee Code" + } + } + }, + { + "FiterFieldName": "TDS Amount", + "FilterType": "Not Equals", + "FilterValue": { + "Type": "Constant", + "Value": "0" + } + } + ] + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "AppliedTDSAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Entry", + "TableFieldName": "TDS Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Vendor No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FiterFieldName": "Assessee Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Tax Attributes", + "AttributeName": "Assessee Code" + } + } + }, + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "Payment" + } + }, + { + "FiterFieldName": "Document No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } }, { - "ActivityType": "NUMERICEXPRESSION", + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + } + } + ] + } + } + } + }, + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "PositiveAmountExclThisLine", + "Expression": "PositiveAmountTillThisLine-CurrentLineAmount", + "Tokens": [ + { + "TokenName": "CurrentLineAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" + } + } + }, + { + "TokenName": "PositiveAmountTillThisLine", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" + } + } + } + ] + } + }, + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "LineCrossedThresholdAmount", + "Operator": "Plus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountExclThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountExclThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "CurrentPOContractAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountExclThisLine" + } + } + } + } + ] + } + } + ] + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + }, + { + "Operator": "and", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "LineCrossedThresholdAmount" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than Or Equals To", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", "Activity": { - "VariableName": "PositiveAmountTillThisLine", - "Expression": "PositiveAmountExclThisLine+Amount+GSTAmount", - "Tokens": [ - { - "TokenName": "Amount", + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PreviousContractAmount" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TDSBaseAmt", + "Expression": "(PreviousAmount+CurrentLineAmount)-PreviousContractAmount+CurrentPOAmount", + "Tokens": [ + { + "TokenName": "CurrentLineAmount", "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" + } } - }, - { - "TokenName": "GSTAmount", + }, + { + "TokenName": "CurrentPOAmount", "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "GSTAmount" - } + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountExclThisLine" + } } - }, - { - "TokenName": "PositiveAmountExclThisLine", + }, + { + "TokenName": "PreviousAmount", "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountExclThisLine" - } + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" + } + } + }, + { + "TokenName": "PreviousContractAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PreviousContractAmount" + } } + } + ] + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { + } + } + ], + "ElseIf": { "Condition": { - "Body": [ + "Body": [] + }, + "Body": [ + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TDSBaseAmt", + "Expression": "(PreviousAmount+CurrentLineAmount)-PreviousBaseAmtWithTDS+CurrentPOAmount", + "Tokens": [ + { + "TokenName": "CurrentLineAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" + } + } + }, + { + "TokenName": "CurrentPOAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountExclThisLine" + } + } + }, + { + "TokenName": "PreviousAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" + } + } + }, { + "TokenName": "PreviousBaseAmtWithTDS", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PreviousBaseAmtWithTDS" + } + } + } + ] + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { "Operator": " ", - "ConditionType": "Not Equals", + "ConditionType": "Is Greater Than Or Equals To", "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" + } }, "RHS": { - "Type": "Constant", - "Value": "" + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TaxableAmountExclApplied", - "Expression": "PositiveAmountTillThisLine-AppliedAmount", - "Tokens": [ - { - "TokenName": "AppliedAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - }, - { - "TokenName": "PositiveAmountTillThisLine", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TaxableAmountExclApplied", - "Operator": "Plus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TaxableAmountExclApplied" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Calc. Over & Above Threshold" - } - }, - "RHS": { - "Type": "Constant", - "Value": "1" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TaxableAmountExclApplied" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TaxableAmountExclApplied", - "Operator": "Minus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TaxableAmountExclApplied" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TaxableAmountExclApplied", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ] - } - } - } - ] - } - } - ], - "ElseIf": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TaxableAmountExclApplied" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TaxableAmountExclApplied", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - } - ] - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TaxableAmountExclApplied" - } - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TaxableAmountExclApplied", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ] + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSTaxableAmount" + } + } + } } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Allowed Sections", - "TableFieldName": "", - "Method": "Exist", - "TableFilters": [ - { - "FiterFieldName": "Vendor No", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "TDS Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - }, - { - "FiterFieldName": "Threshold Overlook", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "true" - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "true" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountExclThisLine" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TaxableAmountExclApplied", - "Operator": "Minus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TaxableAmountExclApplied", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ] - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountExclThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TaxableAmountExclApplied", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TaxableAmountExclApplied", - "Expression": "PurchLineAmt+(PrevPurchLineAmt-AppliedAmt)", - "Tokens": [ - { - "TokenName": "AppliedAmt", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - }, - { - "TokenName": "PrevPurchLineAmt", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountExclThisLine" - } - } - }, - { - "TokenName": "PurchLineAmt", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - ] - } - } - ] - } - } - } - ] - } - } - } - ] - } + ] } + } ] + } } - } - ], - "ElseIf": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than Or Equals To", - "LHS": { + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" } - }, - "RHS": { + }, + "RHS": { "Type": "Lookup", "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmount" + "SourceType": "Column", + "RateColumnName": "Per Contract Value" } + } } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TaxableAmountExclApplied", - "OutputValue": { - "Type": "Constant", - "Value": "" + ] + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "Operator": "Minus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentPOContractAmount" + } + } } - } - }, - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "PositiveAmountTillThisLine", - "Expression": "PositiveAmountExclThisLine+Amount+GSTAmount", - "Tokens": [ - { - "TokenName": "Amount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - }, - { - "TokenName": "GSTAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "GSTAmount" - } - } - }, - { - "TokenName": "PositiveAmountExclThisLine", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountExclThisLine" - } - } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" } - ] + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } + } + ] } + } } - ] + ] + } + } } + ] } - }, - { - "ActivityType": "COMMENT", - "Activity": { - "Comment": "Total Taxable Amount" + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" } - }, - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TotalTaxableInvAmount", - "Expression": "(PostedAmount+Amount+GSTAmount)-AppliedAmount-AdjustedInvAmount", - "Tokens": [ - { - "TokenName": "AdjustedInvAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AdjustedInvAmount" - } - } - }, - { - "TokenName": "Amount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } + } + ] + }, + "Body": [ + { + "ActivityType": "LOOPTHROUGHRECORDS", + "Activity": { + "TableName": "Purchase Line", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "Document No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + }, + { + "FiterFieldName": "Line No.", + "FilterType": "Is Less Than", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Line No." + } + } + } + ], + "LoopThroughRecordFields": [ + { + "FieldName": "Document Type", + "VariableName": "DocumentType", + "CalculateSum": false + }, + { + "FieldName": "Document No.", + "VariableName": "DocumentNo", + "CalculateSum": false + }, + { + "FieldName": "Line No.", + "VariableName": "LineN", + "CalculateSum": false + } + ], + "Body": [ + { + "ActivityType": "STRINGEXPRESSION", + "Activity": { + "OutputVariableName": "RecdID", + "Expression": "Purchase Line: {DocType},{DocumentNo},{LineNo}", + "Token": [ + { + "TokenName": "DocType", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "DocumentType" + } + } }, { - "TokenName": "AppliedAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } + "TokenName": "DocumentNo", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "DocumentNo" } + } }, { - "TokenName": "GSTAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "GSTAmount" - } + "TokenName": "LineNo", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "LineN" } - }, - { - "TokenName": "PostedAmount", - "TokenValue": { + } + } + ] + } + }, + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "CurrentPOTDSAmount", + "Operator": "Plus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentPOTDSAmount" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Tax Transaction Value", + "TableFieldName": "Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Tax Record ID", + "FilterType": "Equals", + "FilterValue": { "Type": "Lookup", "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmount" + "SourceType": "Variable", + "VariableName": "RecdID" } - } + } + }, + { + "FiterFieldName": "Value Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "COMPONENT" + } + }, + { + "FiterFieldName": "Percent", + "FilterType": "Not Equals", + "FilterValue": { + "Type": "Constant", + "Value": "0" + } + }, + { + "FiterFieldName": "Tax Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "TDS" + } + } + ] + } + } + } + } + ] + } + } + ] + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "PreviousTDSAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Entry", + "TableFieldName": "TDS Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Vendor No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FiterFieldName": "Assessee Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Tax Attributes", + "AttributeName": "Assessee Code" + } + } + } + ] + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. Type", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } } + } ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "Payment" } - }, + }, + { + "Operator": "and", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalTaxableInvAmount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + } ] - }, - "Body": [ + }, + "Body": [ { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TotalTaxableInvAmount", - "OutputValue": { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PreviousTDSAmount" + } + }, + "RHS": { "Type": "Constant", "Value": "" + } } - } - } - ] - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TotalCurrentInvAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Line", - "TableFieldName": "Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { + ] + }, + "Body": [ + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TDSBaseAmt", + "Expression": "PrevInvAmountLCY+CurrentLineAmount-AppliedAmount", + "Tokens": [ + { + "TokenName": "AppliedAmount", + "TokenValue": { "Type": "Lookup", "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" + "SourceType": "Variable", + "VariableName": "AppliedAmount" } - } - }, - { - "FiterFieldName": "Document No.", - "FilterType": "Equals", - "FilterValue": { + } + }, + { + "TokenName": "CurrentLineAmount", + "TokenValue": { "Type": "Lookup", "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" } - } - }, - { - "FiterFieldName": "TDS Section Code", - "FilterType": "Equals", - "FilterValue": { + } + }, + { + "TokenName": "PrevInvAmountLCY", + "TokenValue": { "Type": "Lookup", "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" } + } } + ] } - ] - } - } - } - }, - { - "ActivityType": "COMMENT", - "Activity": { - "Comment": "Total Taxable Amount excluding posted contract amount" - } - }, - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TotalTaxableInvAmtWOContract", - "Expression": "((PostedAmount+Amount)-ContractAmt+GSTAmount)-AppliedAmount-AdjustedInvAmount", - "Tokens": [ - { - "TokenName": "AdjustedInvAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AdjustedInvAmount" + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } + } + ] } - } - }, - { - "TokenName": "Amount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalCurrentInvAmt" + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + } } - } - }, - { - "TokenName": "AppliedAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - }, - { - "TokenName": "ContractAmt", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PreviousContractAmount" - } - } - }, - { - "TokenName": "GSTAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "GSTAmount" - } - } - }, - { - "TokenName": "PostedAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmount" - } - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalTaxableInvAmtWOContract" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TotalTaxableInvAmtWOContract", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Include GST in TDS Base", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "true" - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TotalInvAmountLCY", - "Operator": "Plus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "GSTAmount" - } - } - } - }, - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TotalInvAmountLCY", - "Operator": "Plus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PreviousLineGSTAmount" - } - } - } - } - ] - } - }, - { - "ActivityType": "COMMENT", - "Activity": { - "Comment": "Condition to calculate TDS Amount considering Threshold limit" - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Allowed Sections", - "TableFieldName": "", - "Method": "Exist", - "TableFilters": [ - { - "FiterFieldName": "Vendor No", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "TDS Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - }, - { - "FiterFieldName": "Threshold Overlook", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "true" - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "false" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ { - "Operator": " ", - "ConditionType": "Is Less Than Or Equals To", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentPOTDSAmount" } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } } - ] - }, - "Body": [ - { + ] + }, + "Body": [ + { "ActivityType": "IFSTATEMENT", "Activity": { - "Condition": { - "Body": [ + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PreviousContractAmount" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedTDSAmount" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TDSBaseAmt", + "Expression": "(PreviousAmount+CurrentLineAmount)-PreviousContractAmount+CurrentPOAmount-AppliedAmount", + "Tokens": [ + { + "TokenName": "AppliedAmount", + "TokenValue": { + "Type": "Lookup", "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" + "SourceType": "Variable", + "VariableName": "AppliedAmount" } + } }, - "RHS": { - "Type": "Constant", - "Value": "" + { + "TokenName": "CurrentLineAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" + } + } + }, + { + "TokenName": "CurrentPOAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountLCYExclThisLine" + } + } + }, + { + "TokenName": "PreviousAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" + } + } + }, + { + "TokenName": "PreviousContractAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PreviousContractAmount" + } + } } + ] } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", + }, + { + "ActivityType": "NUMERICEXPRESSION", "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] + "VariableName": "CrossPerContractValue", + "Expression": "(PreviousAmount+CurrentLineAmount) - AppliedAmount", + "Tokens": [ + { + "TokenName": "AppliedAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "Operator": "Minus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "TDS Entry", - "TableFieldName": "Invoice Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Vendor No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - }, - { - "FiterFieldName": "Assessee Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Tax Attributes", - "AttributeName": "Assessee Code" - } - } - }, - { - "FiterFieldName": "Per Contract", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "true" - } - } - ] - } - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Calc. Over & Above Threshold" - } - }, - "RHS": { - "Type": "Constant", - "Value": "1" - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TDSTaxableAmount", - "Expression": "TDSTaxableAmount-TDSThresholdAmount", - "Tokens": [ - { - "TokenName": "TDSTaxableAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSTaxableAmount" - } - } - }, - { - "TokenName": "TDSThresholdAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSTaxableAmount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ] - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Calc. Over & Above Threshold" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - } - ] - } - } - ] - } - } - ] - } + { + "TokenName": "CurrentLineAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TaxableAmountExclApplied" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountLCY" - } - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TaxableAmountExclApplied" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - } - } - } - ] - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountLCYExclThisLine" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountLCYExclThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - } - ] - } - } - ] - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Constant", - "Value": "0" - } - } - } - ] - } - } - } - ] + } + }, + { + "TokenName": "PreviousAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" + } + } } + ] } - } - ], - "ElseIf": { - "Condition": { - "Body": [ - { + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { "Operator": " ", - "ConditionType": "Equals", + "ConditionType": "Is Less Than Or Equals To", "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } + "Lookup": { + "SourceType": "Variable", + "VariableName": "CrossPerContractValue" + } }, "RHS": { - "Type": "Constant", - "Value": "" + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { + } + ] + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "CrossPerContractValue", + "Operator": "Minus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCYExclThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" } - ] + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + } + } + ] }, "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TaxableAmountExclApplied" - } - } + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" + } } + } }, { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Calc. Over & Above Threshold" - } - }, - "RHS": { - "Type": "Constant", - "Value": "1" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSTaxableAmount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ] - } - } - ] + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } } + } } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" - } - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TaxableAmountExclApplied" - } - } - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - }, - { - "Operator": "and", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Calc. Over & Above Threshold" - } - }, - "RHS": { - "Type": "Constant", - "Value": "1" - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TDSTaxableAmount", - "Expression": "TDSTaxableAmount-TDSThresholdAmount", - "Tokens": [ - { - "TokenName": "TDSTaxableAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSTaxableAmount" - } - } - }, - { - "TokenName": "TDSThresholdAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSTaxableAmount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ] - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ] - } - } - } - ] + ] } + } } + ] } - ] + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TDSBaseAmt", + "Expression": "CurrentLineAmount-AppliedAmount+(PositiveAmountExclThisLine)", + "Tokens": [ + { + "TokenName": "AppliedAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + }, + { + "TokenName": "CurrentLineAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" + } + } + }, + { + "TokenName": "PositiveAmountExclThisLine", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountExclThisLine" + } + } + } + ] + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + } + } + } + ] + } + } } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TDSBaseAmt", + "Expression": "CurrentLineAmount + (PositiveAmountExclThisLine) -AppliedAmount", + "Tokens": [ + { + "TokenName": "AppliedAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + }, + { + "TokenName": "CurrentLineAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" + } + } + }, + { + "TokenName": "PositiveAmountExclThisLine", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountExclThisLine" + } + } } - }, - "RHS": { + ] + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { "Type": "Lookup", "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" } + } } - } - ] - }, - "Body": [ + } + ] + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than Or Equals To", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountExclThisLine" + } + }, + "RHS": { "Type": "Lookup", "Lookup": { - "SourceType": "Variable", - "VariableName": "TaxableAmountExclApplied" + "SourceType": "Variable", + "VariableName": "AppliedAmount" } + } } - } - } - ] - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TaxableAmountExclApplied" - } - } - } - } - ] - } - } - }, - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TDSAmount", - "Expression": "TDSTaxableAmt*TDSPer/100", - "Tokens": [ - { - "TokenName": "TDSPer", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component Percent", - "ComponentName": "TDS" - } - } - }, - { - "TokenName": "TDSTaxableAmt", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSTaxableAmount" - } - } - } - ] - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "PreSurchargeBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "TDS Entry", - "TableFieldName": "Surcharge Base Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Vendor No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - }, - { - "FiterFieldName": "Assessee Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Tax Attributes", - "AttributeName": "Assessee Code" - } - } - }, - { - "FiterFieldName": "Posting Date", - "FilterType": "CAL Filter", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AccountingDateFilter" - } - } - } - ] - } - } - } - }, - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TotalSurchargeBaseAmt", - "Expression": "PreSurchargeBaseAmt+TDSAmount", - "Tokens": [ - { - "TokenName": "PreSurchargeBaseAmt", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PreSurchargeBaseAmt" - } - } - }, - { - "TokenName": "TDSAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSAmount" - } - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Allowed Sections", - "TableFieldName": "", - "Method": "Exist", - "TableFilters": [ - { - "FiterFieldName": "Vendor No", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "TDS Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - }, - { - "FiterFieldName": "Surcharge Overlook", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "true" - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "true" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } + ] }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Surcharge Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { "Operator": " ", - "ConditionType": "Is Greater Than", + "ConditionType": "Not Equals", "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" - } + "Lookup": { + "SourceType": "Variable", + "VariableName": "PreviousContractAmount" + } }, "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TDSBaseAmt", + "Expression": "CurrentLineAmount+(PreviousAmount-PreviousContractAmount)", + "Tokens": [ + { + "TokenName": "CurrentLineAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" + } + } + }, + { + "TokenName": "PreviousAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" + } + } + }, + { + "TokenName": "PreviousContractAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PreviousContractAmount" + } + } + } + ] + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { "Type": "Lookup", "Lookup": { - "SourceType": "Column", - "RateColumnName": "Surcharge Threshold Amount" + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" } + } } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "SurchargeBaseAmt", - "OutputValue": { + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { "Type": "Lookup", "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalSurchargeBaseAmt" + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" } + } } - } + } + ] + } } + } ], "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PreviousContractAmount" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TDSBaseAmt", + "Expression": "CurrentLineAmount-AppliedAmount+(PreviousAmount-PreviousContractAmount)", + "Tokens": [ + { + "TokenName": "AppliedAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + }, + { + "TokenName": "CurrentLineAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" + } + } + }, + { + "TokenName": "PreviousAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" + } + } + }, + { + "TokenName": "PreviousContractAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PreviousContractAmount" + } + } + } + ] + } + }, + { "ActivityType": "SETVARIABLE", "Activity": { - "OutputVariableName": "SurchargeBaseAmt", + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "Operator": "Minus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", "OutputValue": { - "Type": "Constant", - "Value": "0" + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } } + } } + ] } - ] - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "SurchargeBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSAmount" - } + } } + ] } + } } - ] + ] + } + } } + ] } + } } - ], - "ElseIf": { + ], + "ElseIf": { "Condition": { - "Body": [] + "Body": [] }, "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "SurchargeBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSAmount" - } - } - } + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } + } + ] + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "Operator": "Minus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + } + }, + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "BalanceAmount", + "Expression": "TDSBaseAmt * SignFactor", + "Tokens": [ + { + "TokenName": "SignFactor", + "TokenValue": { + "Type": "Constant", + "Value": "1" + } + }, + { + "TokenName": "TDSBaseAmt", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } } + } ] + } } + ] } + } }, { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSTaxableAmount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than Or Equals To", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } + } + ], + "ElseIf": { + "Condition": { "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + } + } + } + ] + } + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Calc. Over & Above Threshold" + } + }, + "RHS": { + "Type": "Constant", + "Value": "1" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedTDSAmount" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "AppliedAmount", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } + } + ] + } + }, + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "OverAndAboveThreshold", + "Expression": "(PrevAmount+CurrentAmount)-AppliedAmount", + "Tokens": [ + { + "TokenName": "AppliedAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + }, + { + "TokenName": "CurrentAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" + } + } + }, + { + "TokenName": "PrevAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" + } + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "OverAndAboveThreshold" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { "Type": "Lookup", "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" + } + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "Operator": "Minus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "OverAndAboveThreshold" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { "SourceType": "Variable", - "VariableName": "TDSTaxableAmount" + "VariableName": "TDSBaseAmt" + } } + } } + ] } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] }, - { + "Body": [ + { "ActivityType": "IFSTATEMENT", "Activity": { - "Condition": { - "Body": [ + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "Operator": "Minus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + } + } + } + ] + } + } + ], + "ElseIf": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { "Operator": " ", "ConditionType": "Is Greater Than", "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" + } }, "RHS": { - "Type": "Lookup", - "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TDSTaxableAmount", + "Expression": "TotalInvAmtLCY-TDSThreshold", + "Tokens": [ + { + "TokenName": "TDSThreshold", + "TokenValue": { + "Type": "Lookup", + "Lookup": { "SourceType": "Column", - "RateColumnName": "Per Contract Value" + "RateColumnName": "TDS Threshold Amount" + } + } + }, + { + "TokenName": "TotalInvAmtLCY", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" + } } - } + } + ] + } } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", + ] + } + }, + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "ThresholdTotal", + "Operator": "Minus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "ThresholdTotal" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } } + } } + ] } + } ] + } } + } + ] + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + } + } } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { "Body": [ - { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountExclThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + } + } + } + ] + } + }, + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "ThresholdTotal", + "Operator": "Minus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCYExclThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } + } ] - }, - "Body": [ + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + } + }, { - "ActivityType": "IFSTATEMENT", + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "CurrentLineAmount" + } + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. Type", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "Payment" - } - }, - { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ] - } - } - ], - "ElseIf": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCYExclThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - } - ] - } - } - } - ] - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" + "OutputVariableName": "TDSBaseAmt", + "Operator": "Minus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmountLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" } + } } - ] - }, - "Body": [ - { + }, + { "ActivityType": "SETVARIABLE", "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" } + } } + } + ] + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Calc. Over & Above Threshold" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" } + } ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Include GST in TDS Base", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. Type", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } } - }, - "RHS": { - "Type": "Constant", - "Value": "true" + ] } + }, + "RHS": { + "Type": "Constant", + "Value": "Payment" + } }, { - "Operator": "and", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" + "Operator": "and", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } } - }, - "RHS": { - "Type": "Constant", - "Value": "" + ] } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { "SourceType": "Variable", - "VariableName": "TaxableAmountExclApplied" + "VariableName": "TDSBaseAmt" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TDSBaseAmt", + "Expression": "TDSBaseAmt-AppliedAmount", + "Tokens": [ + { + "TokenName": "AppliedAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + }, + { + "TokenName": "TDSBaseAmt", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + } + } + ] + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } } + } } + ] } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. Type", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "Payment" - } - }, - { - "Operator": "and", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ] - } + } + ] + } + } + ] + } + } + } + ] + } + }, + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TotalPrevAndCurrentInvAmt", + "Operator": "Plus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Entry", + "TableFieldName": "Original Invoice Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Vendor No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + } + ] + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Allowed Sections", + "TableFieldName": "Threshold Overlook", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Vendor No", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "TDS Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } } + } ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "false" } - }, + } + ] + }, + "Body": [ { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Allowed Sections", - "TableFieldName": "Threshold Overlook", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Vendor No", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "TDS Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - } - ] + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. Type", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } } - }, - "RHS": { - "Type": "Constant", - "Value": "true" - } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "Payment" + } + }, + { + "Operator": "and", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" } + } ] - }, - "Body": [ + }, + "Body": [ { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSTaxableAmount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than Or Equals To", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TDSBaseAmt", + "Expression": "CurrentLineAmt-AppliedAmount", + "Tokens": [ + { + "TokenName": "AppliedAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } } + }, + { + "TokenName": "CurrentLineAmt", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" + } + } + } ] + } }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Constant", - "Value": "" + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" } + } } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { + ] + }, "Body": [ - { + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [ + { "Operator": " ", - "ConditionType": "Equals", + "ConditionType": "Is Greater Than", "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" + } }, "RHS": { - "Type": "Constant", - "Value": "" + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { "Condition": { - "Body": [ + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Calc. Over & Above Threshold" + } + }, + "RHS": { + "Type": "Constant", + "Value": "1" + } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TDSTaxableAmount", + "Expression": "(PrevInvAmtLcy+TdsBaseAmt) - ThresholdAmount", + "Tokens": [ { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSTaxableAmount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" + "TokenName": "PrevInvAmtLcy", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PrevInvAmountLCY" } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } + } + }, + { + "TokenName": "TdsBaseAmt", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" } + } + }, + { + "TokenName": "ThresholdAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } } + ] } + } ] + } } + ] } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "" + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TaxableAmountExclApplied" - } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" } + } } - } - ] - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { + ] + }, "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCYExclThisLine" + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Calc. Over & Above Threshold" + } + }, + "RHS": { + "Type": "Constant", + "Value": "1" } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { + } + ] + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "Operator": "Minus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { "SourceType": "Column", "RateColumnName": "TDS Threshold Amount" + } } + } } - }, - { - "Operator": "and", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCYExclThisLine" + ], + "ElseIf": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Calc. Over & Above Threshold" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } } + ] }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" + } + } } - } + } + ] + } } + } ] + } }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountTillThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" } + } } + ] }, - { + "Body": [ + { "ActivityType": "SETVARIABLE", "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSTaxableAmount" - } - } - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Include GST in TDS Base", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "true" + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" } + } } - ] - }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", + }, + { + "ActivityType": "IFSTATEMENT", "Activity": { - "OutputVariableName": "TDSBaseAmt", - "Operator": "Plus", - "LHS": { - "Type": "Lookup", - "Lookup": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than", + "LHS": { + "Lookup": { "SourceType": "Variable", - "VariableName": "TDSBaseAmt" + "VariableName": "TotalPrevAndCurrentInvAmt" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Constant", + "Value": "" } + } }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "GSTAmount" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - }, - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "CurrentLineAmount", - "Operator": "Plus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "GSTAmount" - } - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "CurrentLineAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Constant", + "Value": "" } + } } + ] } + } ] + } } + ] } + } } - ] - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "PreviousBaseAmtWithTDS", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "TDS Entry", - "TableFieldName": "TDS Base Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Vendor No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "Section", + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than Or Equals To", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalPrevAndCurrentInvAmt" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } + }, + { + "Operator": "and", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", "FilterType": "Equals", "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } } - }, - { - "FiterFieldName": "Assessee Code", + }, + { + "FiterFieldName": "No.", "FilterType": "Equals", "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Tax Attributes", - "AttributeName": "Assessee Code" - } + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } } - }, + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ { - "FiterFieldName": "TDS Amount", - "FilterType": "Not Equals", - "FilterValue": { - "Type": "Constant", - "Value": "0" + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Calc. Over & Above Threshold" } + }, + "RHS": { + "Type": "Constant", + "Value": "1" + } } - ] - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "AppliedTDSAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "TDS Entry", - "TableFieldName": "TDS Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Vendor No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } + ] + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "Operator": "Minus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalPrevAndCurrentInvAmt" } - }, - { - "FiterFieldName": "Assessee Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Tax Attributes", - "AttributeName": "Assessee Code" - } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" } - }, - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "Payment" + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalPrevAndCurrentInvAmt" + } } + } }, { - "FiterFieldName": "Document No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } } + } } - ] - } - } - } - }, - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "PositiveAmountExclThisLine", - "Expression": "PositiveAmountTillThisLine-CurrentLineAmount", - "Tokens": [ - { - "TokenName": "CurrentLineAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } + ] } + } }, { - "TokenName": "PositiveAmountTillThisLine", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TotalPrevAndCurrentInvAmt", + "Operator": "Minus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalPrevAndCurrentInvAmt" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } } + } } - ] + ] + } + } + ] + } + } + ] + } + }, + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "PositiveAmountExclThisLine", + "Operator": "Minus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountExclThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountExclThisLine" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedAmount" + } } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + } }, { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "LineCrossedThresholdAmount", - "Operator": "Plus", - "LHS": { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "PositiveAmountExclThisLine" + } + }, + "RHS": { "Type": "Lookup", "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountExclThisLine" + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" } - }, - "RHS": { + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { "Type": "Lookup", "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" } + } } + } + ] + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Allowed Sections", + "TableFieldName": "Threshold Overlook", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Vendor No", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "TDS Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "false" } - }, + } + ] + }, + "Body": [ { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than Or Equals To", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalPrevAndCurrentInvAmt" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountExclThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "CurrentPOContractAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountExclThisLine" - } - } - } - } - ] - } - } - ] - } + { + "Operator": "and", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + }, + { + "Operator": "and", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. No.", + "Method": "First", + "TableFilters": [ { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "" + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" } + } }, { - "Operator": "and", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "LineCrossedThresholdAmount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than Or Equals To", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PreviousContractAmount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TDSBaseAmt", - "Expression": "(PreviousAmount+CurrentLineAmount)-PreviousContractAmount+CurrentPOAmount", - "Tokens": [ - { - "TokenName": "CurrentLineAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } - } - }, - { - "TokenName": "CurrentPOAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountExclThisLine" - } - } - }, - { - "TokenName": "PreviousAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } - } - }, - { - "TokenName": "PreviousContractAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PreviousContractAmount" - } - } - } - ] - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TDSBaseAmt", - "Expression": "(PreviousAmount+CurrentLineAmount)-PreviousBaseAmtWithTDS+CurrentPOAmount", - "Tokens": [ - { - "TokenName": "CurrentLineAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } - } - }, - { - "TokenName": "CurrentPOAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountExclThisLine" - } - } - }, - { - "TokenName": "PreviousAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } - } - }, - { - "TokenName": "PreviousBaseAmtWithTDS", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PreviousBaseAmtWithTDS" - } - } - } - ] - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than Or Equals To", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSTaxableAmount" - } - } - } - } - ] - } - } - ] - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "Operator": "Minus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentPOContractAmount" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ] - } - } - } - ] - } - } - } - ] + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." } + } } + ] } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { "Body": [ - { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Include GST in TDS Base", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "true" } + } ] - }, - "Body": [ - { - "ActivityType": "LOOPTHROUGHRECORDS", - "Activity": { - "TableName": "Purchase Line", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "Document No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - }, - { - "FiterFieldName": "Line No.", - "FilterType": "Is Less Than", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Line No." - } - } - } - ], - "LoopThroughRecordFields": [ - { - "FieldName": "Document Type", - "VariableName": "DocumentType", - "CalculateSum": false - }, - { - "FieldName": "Document No.", - "VariableName": "DocumentNo", - "CalculateSum": false - }, - { - "FieldName": "Line No.", - "VariableName": "LineN", - "CalculateSum": false - } - ], - "Body": [ - { - "ActivityType": "STRINGEXPRESSION", - "Activity": { - "OutputVariableName": "RecdID", - "Expression": "Purchase Line: {DocType},{DocumentNo},{LineNo}", - "Token": [ - { - "TokenName": "DocType", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "DocumentType" - } - } - }, - { - "TokenName": "DocumentNo", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "DocumentNo" - } - } - }, - { - "TokenName": "LineNo", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "LineN" - } - } - } - ] - } - }, - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "CurrentPOTDSAmount", - "Operator": "Plus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentPOTDSAmount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Tax Transaction Value", - "TableFieldName": "Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Tax Record ID", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "RecdID" - } - } - }, - { - "FiterFieldName": "Value Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "COMPONENT" - } - }, - { - "FiterFieldName": "Percent", - "FilterType": "Not Equals", - "FilterValue": { - "Type": "Constant", - "Value": "0" - } - }, - { - "FiterFieldName": "Tax Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "TDS" - } - } - ] - } - } - } - } - ] - } + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "Operator": "Plus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "GSTAmount" + } + } + } } - ] - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "PreviousTDSAmount", - "OutputValue": { + ] + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { "Type": "Lookup", "Lookup": { - "SourceType": "Table", - "TableName": "TDS Entry", - "TableFieldName": "TDS Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Vendor No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - }, - { - "FiterFieldName": "Assessee Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Tax Attributes", - "AttributeName": "Assessee Code" - } - } - } - ] + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" } + } } + } + ] + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Include GST in TDS Base", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "true" } - }, + } + ] + }, + "Body": [ { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. Type", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "Payment" - } + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } }, - { - "Operator": "and", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } + "RHS": { + "Type": "Constant", + "Value": "" } + } ] - }, - "Body": [ + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSBaseAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TaxableAmountExclApplied" + } + } + } + }, { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PreviousTDSAmount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TDSBaseAmt", - "Expression": "PrevInvAmountLCY+CurrentLineAmount-AppliedAmount", - "Tokens": [ - { - "TokenName": "AppliedAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - }, - { - "TokenName": "CurrentLineAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } - } - }, - { - "TokenName": "PrevInvAmountLCY", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ] - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentPOTDSAmount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PreviousContractAmount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedTDSAmount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TDSBaseAmt", - "Expression": "(PreviousAmount+CurrentLineAmount)-PreviousContractAmount+CurrentPOAmount-AppliedAmount", - "Tokens": [ - { - "TokenName": "AppliedAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - }, - { - "TokenName": "CurrentLineAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } - } - }, - { - "TokenName": "CurrentPOAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountLCYExclThisLine" - } - } - }, - { - "TokenName": "PreviousAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } - } - }, - { - "TokenName": "PreviousContractAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PreviousContractAmount" - } - } - } - ] - } - }, - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "CrossPerContractValue", - "Expression": "(PreviousAmount+CurrentLineAmount) - AppliedAmount", - "Tokens": [ - { - "TokenName": "AppliedAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - }, - { - "TokenName": "CurrentLineAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - } - }, - { - "TokenName": "PreviousAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than Or Equals To", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "CrossPerContractValue" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "CrossPerContractValue", - "Operator": "Minus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ] - } - } - } - ] - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TDSBaseAmt", - "Expression": "CurrentLineAmount-AppliedAmount+(PositiveAmountExclThisLine)", - "Tokens": [ - { - "TokenName": "AppliedAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - }, - { - "TokenName": "CurrentLineAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } - } - }, - { - "TokenName": "PositiveAmountExclThisLine", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountExclThisLine" - } - } - } - ] - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ] - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TDSBaseAmt", - "Expression": "CurrentLineAmount + (PositiveAmountExclThisLine) -AppliedAmount", - "Tokens": [ - { - "TokenName": "AppliedAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - }, - { - "TokenName": "CurrentLineAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } - } - }, - { - "TokenName": "PositiveAmountExclThisLine", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountExclThisLine" - } - } - } - ] - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ] - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than Or Equals To", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountExclThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PreviousContractAmount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TDSBaseAmt", - "Expression": "CurrentLineAmount+(PreviousAmount-PreviousContractAmount)", - "Tokens": [ - { - "TokenName": "CurrentLineAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } - } - }, - { - "TokenName": "PreviousAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } - } - }, - { - "TokenName": "PreviousContractAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PreviousContractAmount" - } - } - } - ] - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ] - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PreviousContractAmount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TDSBaseAmt", - "Expression": "CurrentLineAmount-AppliedAmount+(PreviousAmount-PreviousContractAmount)", - "Tokens": [ - { - "TokenName": "AppliedAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - }, - { - "TokenName": "CurrentLineAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } - } - }, - { - "TokenName": "PreviousAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } - } - }, - { - "TokenName": "PreviousContractAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PreviousContractAmount" - } - } - } - ] - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "Operator": "Minus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ] - } - } - } - ] - } - } - } - ] - } - } - } - ] - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ] - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "Operator": "Minus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - } - }, - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "BalanceAmount", - "Expression": "TDSBaseAmt * SignFactor", - "Tokens": [ - { - "TokenName": "SignFactor", - "TokenValue": { - "Type": "Constant", - "Value": "1" - } - }, - { - "TokenName": "TDSBaseAmt", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - ] - } - } - ] - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than Or Equals To", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ] - } - } + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TDSTaxableAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + } + } } - ] + ] + } + } + ] + } + } + ] + } + } + ], + "PostingVariables": [ + { + "Name": "TDSIncludingSHECess", + "Datatype": "Number" + }, + { + "Name": "TDSIncludingSurcharge", + "Datatype": "Number" + }, + { + "Name": "InvoiceAmt", + "Datatype": "Number" + }, + { + "Name": "PaymentAmt", + "Datatype": "Number" + }, + { + "Name": "TotalAmtLCY", + "Datatype": "Number" + }, + { + "Name": "TotalInvAmt", + "Datatype": "Number" + }, + { + "Name": "PerContract", + "Datatype": "Boolean" + }, + { + "Name": "PaymentAmount", + "Datatype": "Number" + }, + { + "Name": "InvoiceAmount", + "Datatype": "Number" + }, + { + "Name": "FiscalYearStartDate", + "Datatype": "Date" + }, + { + "Name": "FiscalYearEndDate", + "Datatype": "Date" + }, + { + "Name": "AccountingDateFilter", + "Datatype": "String" + }, + { + "Name": "TDSPer", + "Datatype": "Number" + }, + { + "Name": "SurchargePer", + "Datatype": "Number" + }, + { + "Name": "ECessPer", + "Datatype": "Number" + }, + { + "Name": "SHECessPer", + "Datatype": "Number" + }, + { + "Name": "AppliedAmount", + "Datatype": "Number" + }, + { + "Name": "LineAmount", + "Datatype": "Number" + }, + { + "Name": "Applied", + "Datatype": "Boolean" + }, + { + "Name": "TotalInvoiceAmount", + "Datatype": "Number" + }, + { + "Name": "RecID", + "Datatype": "String" + }, + { + "Name": "GSTAmt", + "Datatype": "Number" + }, + { + "Name": "LineNo", + "Datatype": "String" + }, + { + "Name": "TotalInvoiceAmountWithTDS", + "Datatype": "Number" + }, + { + "Name": "TotalInvoiceAmountWithoutTDS", + "Datatype": "Number" + }, + { + "Name": "LineTDSAmount", + "Datatype": "Number" + }, + { + "Name": "LineAmt", + "Datatype": "Number" + }, + { + "Name": "TotalGSTAmt", + "Datatype": "Number" + }, + { + "Name": "QtyFactor", + "Datatype": "Number" + }, + { + "Name": "LintQtyFactor", + "Datatype": "Number" + }, + { + "Name": "LineAmount", + "Datatype": "Number" + }, + { + "Name": "LineQtyToInvoice", + "Datatype": "Number" + }, + { + "Name": "LineQuantity", + "Datatype": "Number" + }, + { + "Name": "AppliedPaymentAmt", + "Datatype": "Number" + }, + { + "Name": "TestTotalInvAmt", + "Datatype": "Number" + }, + { + "Name": "LineN", + "Datatype": "String" + }, + { + "Name": "RecdID", + "Datatype": "String" + }, + { + "Name": "GSTAmount", + "Datatype": "Number" + }, + { + "Name": "EntryNo", + "Datatype": "Number" + }, + { + "Name": "OriginalInvAmount", + "Datatype": "Number" + } + ], + "PostingScript": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "QtyFactor", + "Operator": "Divided By", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Line", + "TableFieldName": "Qty. to Invoice", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "Document No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Line", + "TableFieldName": "Quantity", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "Document No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + } + } + }, + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TDSIncludingSHECess", + "Expression": "{TDS}+{Surcharge}+{eCESS}+{SHECess}", + "Tokens": [ + { + "TokenName": "{eCESS}", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "eCESS" } + } }, { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ + "TokenName": "{SHECess}", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "SHE Cess " + } + } + }, + { + "TokenName": "{Surcharge}", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "Surcharge" + } + } + }, + { + "TokenName": "{TDS}", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "TDS" + } + } + } + ] + } + }, + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TDSIncludingSurcharge", + "Expression": "{TDS}+{Surcharge}", + "Tokens": [ + { + "TokenName": "{Surcharge}", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "Surcharge" + } + } + }, + { + "TokenName": "{TDS}", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "TDS" + } + } + } + ] + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "FiscalYearStartDate", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Tax Accounting Period", + "TableFieldName": "Starting Date", + "Method": "Last", + "TableFilters": [ + { + "FiterFieldName": "Tax Type Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Tax Type", + "TableFieldName": "Accounting Period", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Setup", + "TableFieldName": "Tax Type", + "Method": "First", + "TableFilters": [] + } + } + } + ] + } + } + }, + { + "FiterFieldName": "Starting Date", + "FilterType": "Is Less Than Or Equals To", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Posting Date", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + } + }, + { + "FiterFieldName": "New Fiscal Year", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "true" + } + }, + { + "FiterFieldName": "Closed", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "false" + } + } + ] + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "FiscalYearStartDate" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "FiscalYearStartDate", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Posting Date", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + } + } + } + ] + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "FiscalYearEndDate", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Tax Accounting Period", + "TableFieldName": "Ending Date", + "Method": "Last", + "TableFilters": [ + { + "FiterFieldName": "Tax Type Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Tax Type", + "TableFieldName": "Accounting Period", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Setup", + "TableFieldName": "Tax Type", + "Method": "First", + "TableFilters": [] + } + } + } + ] + } + } + }, + { + "FiterFieldName": "New Fiscal Year", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "false" + } + }, + { + "FiterFieldName": "Closed", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "false" + } + }, + { + "FiterFieldName": "Ending Date", + "FilterType": "Is Greater Than Or Equals To", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Posting Date", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + } + } + ] + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "FiscalYearEndDate" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "FiscalYearEndDate", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Posting Date", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + } + } + } + ] + } + }, + { + "ActivityType": "STRINGEXPRESSION", + "Activity": { + "OutputVariableName": "AccountingDateFilter", + "Expression": "{StartDate}..{EndDate}", + "Token": [ + { + "TokenName": "EndDate", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "FiscalYearStartDate" + } + } + }, + { + "TokenName": "StartDate", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "FiscalYearEndDate" + } + } + } + ] + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "InvoiceAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Entry", + "TableFieldName": "Invoice Amount", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Vendor No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FiterFieldName": "Assessee Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Tax Attributes", + "AttributeName": "Assessee Code" + } + } + }, + { + "FiterFieldName": "Posting Date", + "FilterType": "CAL Filter", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AccountingDateFilter" + } + } + }, + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "Invoice" + } + } + ] + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "PaymentAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Entry", + "TableFieldName": "Payment Amount", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Vendor No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FiterFieldName": "Assessee Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Tax Attributes", + "AttributeName": "Assessee Code" + } + } + }, + { + "FiterFieldName": "Posting Date", + "FilterType": "CAL Filter", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AccountingDateFilter" + } + } + }, + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "Payment" + } + } + ] + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "AppliedAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Vendor Ledger Entry", + "TableFieldName": "Amount to Apply", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Document No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + } + } + ] + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "EntryNo", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Vendor Ledger Entry", + "TableFieldName": "Entry No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. Type", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + } + }, + { + "FiterFieldName": "Document No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + } + } + ] + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "AppliedAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Detailed Vendor Ledg. Entry", + "TableFieldName": "Amount (LCY)", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Vendor Ledger Entry No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "EntryNo" + } + } + }, + { + "FiterFieldName": "Entry Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "Application" + } + }, + { + "FiterFieldName": "Document No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Posting Field", + "PostingVariableName": "Posted Document No." + } + } + } + ] + } + } + } + }, + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TotalInvAmt", + "Expression": "InvoiceAmt+PaymentAmt", + "Tokens": [ + { + "TokenName": "InvoiceAmt", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "InvoiceAmt" + } + } + }, + { + "TokenName": "PaymentAmt", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PaymentAmt" + } + } + } + ] + } + }, + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TotalInvAmt", + "Expression": "{Amt}+{InvAmt}", + "Tokens": [ + { + "TokenName": "{Amt}", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + }, + { + "TokenName": "{InvAmt}", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmt" + } + } + } + ] + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TotalAmtLCY", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Line", + "TableFieldName": "Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "Document No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + }, + { + "FiterFieldName": "TDS Section Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + } + ] + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "OriginalInvAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Line", + "TableFieldName": "Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "Document No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + }, + { + "FiterFieldName": "Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Type" + } + } + }, + { + "FiterFieldName": "TDS Section Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + } + ] + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Allowed Sections", + "TableFieldName": "", + "Method": "Exist", + "TableFilters": [ + { + "FiterFieldName": "Vendor No", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "TDS Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FiterFieldName": "Threshold Overlook", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "true" + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmt" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvAmt" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "TDS Threshold Amount" + } + } + } + ] + }, + "Body": [ + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Calc. Over & Above Threshold" - } - }, - "RHS": { - "Type": "Constant", - "Value": "1" - } - } + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalAmtLCY" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Column", + "RateColumnName": "Per Contract Value" + } + } + } ] - }, - "Body": [ + }, + "Body": [ { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedTDSAmount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "AppliedAmount", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ] - } - }, - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "OverAndAboveThreshold", - "Expression": "(PrevAmount+CurrentAmount)-AppliedAmount", - "Tokens": [ - { - "TokenName": "AppliedAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - }, - { - "TokenName": "CurrentAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } - } - }, - { - "TokenName": "PrevAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "OverAndAboveThreshold" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "Operator": "Minus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "OverAndAboveThreshold" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ] - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "Operator": "Minus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ] - } - } - ], - "ElseIf": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TDSTaxableAmount", - "Expression": "TotalInvAmtLCY-TDSThreshold", - "Tokens": [ - { - "TokenName": "TDSThreshold", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - }, - { - "TokenName": "TotalInvAmtLCY", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" - } - } - } - ] - } - } - ] - } - }, - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "ThresholdTotal", - "Operator": "Minus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "ThresholdTotal" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - } - ] - } - } - ] - } - } - } - ] - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountExclThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ] - } - }, - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "ThresholdTotal", - "Operator": "Minus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCYExclThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "CurrentLineAmount" - } - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "Operator": "Minus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ] - } + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "PerContract", + "OutputValue": { + "Type": "Constant", + "Value": "true" } + } } - ], - "ElseIf": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Calc. Over & Above Threshold" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. Type", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "Payment" - } - }, - { - "Operator": "and", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TDSBaseAmt", - "Expression": "TDSBaseAmt-AppliedAmount", - "Tokens": [ - { - "TokenName": "AppliedAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - }, - { - "TokenName": "TDSBaseAmt", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - ] - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ] - } - } - ] - } - } - ] + ] } - } + } + ] + } + } + ] + } + } + ] + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } } + } ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" } - }, - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TotalPrevAndCurrentInvAmt", - "Operator": "Plus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" + }, + { + "Operator": "or", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to ID", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "TDS Entry", - "TableFieldName": "Original Invoice Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Vendor No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - } - ] + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "Applied", + "OutputValue": { + "Type": "Constant", + "Value": "true" + } + } + } + ] + } + }, + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TotalInvoiceAmount", + "Operator": "Multiply By", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Line", + "TableFieldName": "Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "Document No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." } + } + } + ] + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "QtyFactor" + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Component", + "ComponentName": "Total TDS Amount" + } + }, + "RHS": { + "Type": "Constant", + "Value": "0" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TotalInvoiceAmount", + "OutputValue": { + "Type": "Constant", + "Value": "0" + } + } + } + ] + } + }, + { + "ActivityType": "STRINGEXPRESSION", + "Activity": { + "OutputVariableName": "RecID", + "Expression": "Purchase Line: {DocType},{DocumentNo},{LineNo}", + "Token": [ + { + "TokenName": "DocType", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" } + } }, { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Allowed Sections", - "TableFieldName": "Threshold Overlook", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Vendor No", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "TDS Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "false" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. Type", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "Payment" - } - }, - { - "Operator": "and", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than Or Equals To", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TDSBaseAmt", - "Expression": "CurrentLineAmt-AppliedAmount", - "Tokens": [ - { - "TokenName": "AppliedAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - }, - { - "TokenName": "CurrentLineAmt", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Calc. Over & Above Threshold" - } - }, - "RHS": { - "Type": "Constant", - "Value": "1" - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TDSTaxableAmount", - "Expression": "(PrevInvAmtLcy+TdsBaseAmt) - ThresholdAmount", - "Tokens": [ - { - "TokenName": "PrevInvAmtLcy", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PrevInvAmountLCY" - } - } - }, - { - "TokenName": "TdsBaseAmt", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - }, - { - "TokenName": "ThresholdAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - } - } - ] - } - } - ] - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Calc. Over & Above Threshold" - } - }, - "RHS": { - "Type": "Constant", - "Value": "1" - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "Operator": "Minus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Calc. Over & Above Threshold" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - } - } - } - ] - } - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountTillThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalPrevAndCurrentInvAmt" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ] - } - } - ] - } - } - ] - } - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than Or Equals To", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalPrevAndCurrentInvAmt" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Calc. Over & Above Threshold" - } - }, - "RHS": { - "Type": "Constant", - "Value": "1" - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "Operator": "Minus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalPrevAndCurrentInvAmt" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalPrevAndCurrentInvAmt" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ] - } - } - }, - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TotalPrevAndCurrentInvAmt", - "Operator": "Minus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalPrevAndCurrentInvAmt" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - } - ] - } - } - ] - } + "TokenName": "DocumentNo", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + }, + { + "TokenName": "LineNo", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Line No." + } + } + } + ] + } + }, + { + "ActivityType": "LOOPTHROUGHRECORDS", + "Activity": { + "TableName": "Purchase Line", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "Document No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + }, + { + "FiterFieldName": "Gen. Bus. Posting Group", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Gen. Bus. Posting Group" + } + } + }, + { + "FiterFieldName": "Gen. Prod. Posting Group", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Gen. Prod. Posting Group" + } + } + }, + { + "FiterFieldName": "Dimension Set ID", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Dimension Set ID" + } + } + }, + { + "FiterFieldName": "TDS Section Code", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + } + ], + "LoopThroughRecordFields": [ + { + "FieldName": "Line No.", + "VariableName": "LineNo", + "CalculateSum": false + }, + { + "FieldName": "Quantity", + "VariableName": "LineQuantity", + "CalculateSum": false + }, + { + "FieldName": "Qty. to Invoice", + "VariableName": "LineQtyToInvoice", + "CalculateSum": false + }, + { + "FieldName": "Amount", + "VariableName": "LineAmount", + "CalculateSum": false + } + ], + "Body": [ + { + "ActivityType": "STRINGEXPRESSION", + "Activity": { + "OutputVariableName": "RecID", + "Expression": "Purchase Line: {DocType},{DocumentNo},{LineNo}", + "Token": [ + { + "TokenName": "DocType", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "TokenName": "DocumentNo", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + }, + { + "TokenName": "LineNo", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "LineNo" + } + } + } + ] + } + }, + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "LintQtyFactor", + "Operator": "Divided By", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "LineQtyToInvoice" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "LineQuantity" + } + } + } + }, + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "LineAmt", + "Operator": "Multiply By", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "LineAmount" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "LintQtyFactor" + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "GSTAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Tax Transaction Value", + "TableFieldName": "Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Tax Record ID", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "RecID" + } + } + }, + { + "FiterFieldName": "Value Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "COMPONENT" + } + }, + { + "FiterFieldName": "Percent", + "FilterType": "Not Equals", + "FilterValue": { + "Type": "Constant", + "Value": "0" + } + }, + { + "FiterFieldName": "Tax Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "GST Setup", + "TableFieldName": "GST Tax Type", + "Method": "First", + "TableFilters": [] + } + } + } + ] + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "LineTDSAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Tax Transaction Value", + "TableFieldName": "Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Tax Record ID", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "RecID" + } + } + }, + { + "FiterFieldName": "Value Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "COMPONENT" + } + }, + { + "FiterFieldName": "Percent", + "FilterType": "Not Equals", + "FilterValue": { + "Type": "Constant", + "Value": "0" + } + }, + { + "FiterFieldName": "Amount", + "FilterType": "Not Equals", + "FilterValue": { + "Type": "Constant", + "Value": "0" + } + }, + { + "FiterFieldName": "Tax Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Setup", + "TableFieldName": "Tax Type", + "Method": "First", + "TableFilters": [] + } } + } ] + } } + } }, { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "PositiveAmountExclThisLine", - "Operator": "Minus", - "LHS": { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "LineTDSAmount" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TotalInvoiceAmountWithTDS", + "Operator": "Plus", + "LHS": { "Type": "Lookup", "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountExclThisLine" + "SourceType": "Variable", + "VariableName": "TotalInvoiceAmountWithTDS" } - }, - "RHS": { + }, + "RHS": { "Type": "Lookup", "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" + "SourceType": "Variable", + "VariableName": "LineAmt" + } + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TotalInvoiceAmountWithoutTDS", + "Operator": "Plus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvoiceAmountWithoutTDS" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "LineAmt" + } } + } } + ] } + } }, { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Include GST in TDS Base", + "Method": "First", + "TableFilters": [ { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountExclThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedAmount" - } + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." } + } } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "GSTAmt", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } + } + ] + } + }, + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TotalInvoiceAmount", + "Expression": "TotalInvoiceAmount+GSTAmt", + "Tokens": [ + { + "TokenName": "GSTAmt", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "GSTAmt" + } + } + }, + { + "TokenName": "TotalInvoiceAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvoiceAmount" + } + } + } + ] + } + }, + { + "ActivityType": "NUMERICEXPRESSION", + "Activity": { + "VariableName": "TotalGSTAmt", + "Expression": "TotalGSTAmt+GSTAmt", + "Tokens": [ + { + "TokenName": "GSTAmt", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "GSTAmt" + } + } + }, + { + "TokenName": "TotalGSTAmt", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalGSTAmt" + } + } + } + ] + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Greater Than", + "LHS": { + "Lookup": { + "SourceType": "Component", + "ComponentName": "Total TDS Amount" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TotalInvoiceAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvoiceAmountWithTDS" + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "OriginalInvAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvoiceAmountWithTDS" + } + } + } + } + ], + "ElseIf": { + "Condition": { + "Body": [] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TotalInvoiceAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvoiceAmountWithoutTDS" + } + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "OriginalInvAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvoiceAmountWithoutTDS" + } + } + } + } + ] + } + } + }, + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "AppliedPaymentAmt", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Entry", + "TableFieldName": "Invoice Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "Payment" + } + }, + { + "FiterFieldName": "Document No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } }, { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "PositiveAmountExclThisLine" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ] + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." } + } + } + ] + } + } + } + ] + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to Doc. No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + }, + { + "Operator": "or", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to ID", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TotalInvoiceAmount", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } }, { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TotalInvoiceAmount", + "Operator": "Minus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "AppliedPaymentAmt" + } + } + } + } + ] + } + }, + { + "ActivityType": "LOOPTHROUGHRECORDS", + "Activity": { + "TableName": "Purchase Line", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "Document No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + }, + { + "FiterFieldName": "Line No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Line No." + } + } + } + ], + "LoopThroughRecordFields": [ + { + "FieldName": "Line No.", + "VariableName": "LineN", + "CalculateSum": false + } + ], + "Body": [ + { + "ActivityType": "STRINGEXPRESSION", + "Activity": { + "OutputVariableName": "RecdID", + "Expression": "Purchase Line: {DocType},{DocumentNo},{LineNo}", + "Token": [ + { + "TokenName": "DocType", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "TokenName": "DocumentNo", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + }, + { + "TokenName": "LineNo", + "FormatString": "", + "LookupVariableName": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "LineN" + } + } + } + ] + } + }, + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "GSTAmount", + "Operator": "Plus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "GSTAmount" + } + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Tax Transaction Value", + "TableFieldName": "Amount", + "Method": "Sum", + "TableFilters": [ + { + "FiterFieldName": "Tax Record ID", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "RecdID" + } + } + }, + { + "FiterFieldName": "Value Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Constant", + "Value": "COMPONENT" + } + }, + { + "FiterFieldName": "Percent", + "FilterType": "Not Equals", + "FilterValue": { + "Type": "Constant", + "Value": "0" + } + }, + { + "FiterFieldName": "Tax Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "GST Setup", + "TableFieldName": "GST Tax Type", + "Method": "First", + "TableFilters": [] + } + } + } + ] + } + } + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Include GST in TDS Base", + "Method": "First", + "TableFilters": [ { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Allowed Sections", - "TableFieldName": "Threshold Overlook", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Vendor No", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "TDS Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "false" + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." } + } } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than Or Equals To", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalPrevAndCurrentInvAmt" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - }, - { - "Operator": "and", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Include GST in TDS Base", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "true" - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "Operator": "Plus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "GSTAmount" - } - } - } - } - ] - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ] - } + ] } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Include GST in TDS Base", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "true" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSBaseAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TaxableAmountExclApplied" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TDSTaxableAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - } - ] - } - } - ] - } + }, + "RHS": { + "Type": "Constant", + "Value": "true" + } + } + ] + }, + "Body": [ + { + "ActivityType": "NUMBERCALCULATION", + "Activity": { + "OutputVariableName": "TotalInvoiceAmount", + "Operator": "Plus", + "LHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" } - ] + }, + "RHS": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "GSTAmount" + } + } + } + } + ] + } + } + ] + } + }, + { + "ActivityType": "IFSTATEMENT", + "Activity": { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Is Less Than Or Equals To", + "LHS": { + "Lookup": { + "SourceType": "Variable", + "VariableName": "TotalInvoiceAmount" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" } + } + ] + }, + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TotalInvoiceAmount", + "OutputValue": { + "Type": "Constant", + "Value": "" + } + } } - ], - "PostingVariables": [ - { - "Name": "TDSIncludingSHECess", - "Datatype": "Number" - }, - { - "Name": "TDSIncludingSurcharge", - "Datatype": "Number" - }, - { - "Name": "InvoiceAmt", - "Datatype": "Number" - }, - { - "Name": "PaymentAmt", - "Datatype": "Number" - }, - { - "Name": "TotalAmtLCY", - "Datatype": "Number" - }, - { - "Name": "TotalInvAmt", - "Datatype": "Number" - }, - { - "Name": "PerContract", - "Datatype": "Boolean" - }, - { - "Name": "PaymentAmount", - "Datatype": "Number" - }, - { - "Name": "InvoiceAmount", - "Datatype": "Number" - }, - { - "Name": "FiscalYearStartDate", - "Datatype": "Date" - }, - { - "Name": "FiscalYearEndDate", - "Datatype": "Date" - }, - { - "Name": "AccountingDateFilter", - "Datatype": "String" - }, - { - "Name": "TDSPer", - "Datatype": "Number" - }, - { - "Name": "SurchargePer", - "Datatype": "Number" - }, - { - "Name": "ECessPer", - "Datatype": "Number" - }, - { - "Name": "SHECessPer", - "Datatype": "Number" - }, - { - "Name": "AppliedAmount", - "Datatype": "Number" - }, - { - "Name": "LineAmount", - "Datatype": "Number" - }, - { - "Name": "Applied", - "Datatype": "Boolean" - }, - { - "Name": "TotalInvoiceAmount", - "Datatype": "Number" - }, - { - "Name": "RecID", - "Datatype": "String" - }, - { - "Name": "GSTAmt", - "Datatype": "Number" - }, - { - "Name": "LineNo", - "Datatype": "String" - }, - { - "Name": "TotalInvoiceAmountWithTDS", - "Datatype": "Number" - }, - { - "Name": "TotalInvoiceAmountWithoutTDS", - "Datatype": "Number" - }, - { - "Name": "LineTDSAmount", - "Datatype": "Number" - }, - { - "Name": "LineAmt", - "Datatype": "Number" - }, - { - "Name": "TotalGSTAmt", - "Datatype": "Number" - }, - { - "Name": "QtyFactor", - "Datatype": "Number" + ], + "ElseIf": { + "Condition": { + "Body": [] }, - { - "Name": "LintQtyFactor", - "Datatype": "Number" + "Body": [ + { + "ActivityType": "SETVARIABLE", + "Activity": { + "OutputVariableName": "TotalInvoiceAmount", + "OutputValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Amount" + } + } + } + } + ] + } + } + } + ], + "Components": [ + { + "ComponentName": "Surcharge", + "Sequence": 2, + "Formula": { + "VariableName": "Surcharge", + "Expression": "SurchargeTaxableAmount*SurchargePercent/100", + "Tokens": [ + { + "TokenName": "SurchargePercent", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component Percent", + "ComponentName": "Surcharge" + } + } }, { - "Name": "LineAmount", - "Datatype": "Number" + "TokenName": "SurchargeTaxableAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "SurchargeBaseAmt" + } + } + } + ] + } + }, + { + "ComponentName": "TDS", + "Sequence": 1, + "Formula": { + "VariableName": "TDS", + "Expression": "TDSTaxableAmount*TDSPercent/100", + "Tokens": [ + { + "TokenName": "TDSPercent", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component Percent", + "ComponentName": "TDS" + } + } }, { - "Name": "LineQtyToInvoice", - "Datatype": "Number" + "TokenName": "TDSTaxableAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSTaxableAmount" + } + } + } + ] + } + }, + { + "ComponentName": "Total TDS Amount", + "Sequence": 5, + "Formula": { + "VariableName": "Total TDS Amount", + "Expression": "TDSAmount+SurchargeAmount+ECessAmount+SHECessAmount", + "Tokens": [ + { + "TokenName": "ECessAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "eCESS" + } + } }, { - "Name": "LineQuantity", - "Datatype": "Number" + "TokenName": "SHECessAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "SHE Cess " + } + } }, { - "Name": "AppliedPaymentAmt", - "Datatype": "Number" + "TokenName": "SurchargeAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "Surcharge" + } + } }, { - "Name": "TestTotalInvAmt", - "Datatype": "Number" + "TokenName": "TDSAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "TDS" + } + } + } + ] + } + }, + { + "ComponentName": "TDS Base Amount", + "Sequence": 6, + "Formula": { + "VariableName": "TDS Base Amount", + "Expression": "TDSBaseAmount", + "Tokens": [ + { + "TokenName": "TDSBaseAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSBaseAmt" + } + } + } + ] + } + }, + { + "ComponentName": "eCESS", + "Sequence": 3, + "Formula": { + "VariableName": "eCESS", + "Expression": "(TDSAmount+SurchargeAmount)*EcessPercent/100", + "Tokens": [ + { + "TokenName": "EcessPercent", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component Percent", + "ComponentName": "eCESS" + } + } }, { - "Name": "LineN", - "Datatype": "String" + "TokenName": "SurchargeAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "Surcharge" + } + } }, { - "Name": "RecdID", - "Datatype": "String" + "TokenName": "TDSAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "TDS" + } + } + } + ] + } + }, + { + "ComponentName": "SHE Cess ", + "Sequence": 4, + "Formula": { + "VariableName": "SHE Cess ", + "Expression": "(TDSAmount+SurchargeAmount)*SHECessPercent/100", + "Tokens": [ + { + "TokenName": "SHECessPercent", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component Percent", + "ComponentName": "SHE Cess " + } + } }, { - "Name": "GSTAmount", - "Datatype": "Number" + "TokenName": "SurchargeAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "Surcharge" + } + } }, { - "Name": "EntryNo", - "Datatype": "Number" - }, - { - "Name": "OriginalInvAmount", - "Datatype": "Number" + "TokenName": "TDSAmount", + "TokenValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "TDS" + } + } } - ], - "PostingScript": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "QtyFactor", - "Operator": "Divided By", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Line", - "TableFieldName": "Qty. to Invoice", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "Document No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Line", - "TableFieldName": "Quantity", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "Document No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } + ] + } + } + ], + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + }, + "RHS": { + "Type": "Constant", + "Value": "Order" + } + }, + { + "Operator": "or", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + }, + "RHS": { + "Type": "Constant", + "Value": "Invoice" + } + }, + { + "Operator": "and", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Vendor", + "TableFieldName": "P.A.N. Status", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." } + } } - }, - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TDSIncludingSHECess", - "Expression": "{TDS}+{Surcharge}+{eCESS}+{SHECess}", - "Tokens": [ - { - "TokenName": "{eCESS}", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "eCESS" - } - } - }, - { - "TokenName": "{SHECess}", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "SHE Cess " - } - } - }, - { - "TokenName": "{Surcharge}", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "Surcharge" - } - } - }, - { - "TokenName": "{TDS}", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "TDS" - } - } - } - ] - } - }, - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TDSIncludingSurcharge", - "Expression": "{TDS}+{Surcharge}", - "Tokens": [ - { - "TokenName": "{Surcharge}", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "Surcharge" - } - } - }, - { - "TokenName": "{TDS}", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "TDS" - } - } - } - ] - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "FiscalYearStartDate", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Tax Accounting Period", - "TableFieldName": "Starting Date", - "Method": "Last", - "TableFilters": [ - { - "FiterFieldName": "Tax Type Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Tax Type", - "TableFieldName": "Accounting Period", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "TDS Setup", - "TableFieldName": "Tax Type", - "Method": "First", - "TableFilters": [] - } - } - } - ] - } - } - }, - { - "FiterFieldName": "Starting Date", - "FilterType": "Is Less Than Or Equals To", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Posting Date", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - } - }, - { - "FiterFieldName": "New Fiscal Year", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "true" - } - }, - { - "FiterFieldName": "Closed", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "false" - } - } - ] - } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": " " + } + }, + { + "Operator": "and", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Concessional Code", + "TableFieldName": "Concessional Code", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Vendor No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." } + } + }, + { + "FiterFieldName": "Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "FiscalYearStartDate" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "FiscalYearStartDate", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Posting Date", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - } - } - } - ] + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + }, + { + "Operator": "and", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Vendor", + "TableFieldName": "P.A.N. No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "FiscalYearEndDate", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Tax Accounting Period", - "TableFieldName": "Ending Date", - "Method": "Last", - "TableFilters": [ - { - "FiterFieldName": "Tax Type Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Tax Type", - "TableFieldName": "Accounting Period", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "TDS Setup", - "TableFieldName": "Tax Type", - "Method": "First", - "TableFilters": [] - } - } - } - ] - } - } - }, - { - "FiterFieldName": "New Fiscal Year", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "false" - } - }, - { - "FiterFieldName": "Closed", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "false" - } - }, - { - "FiterFieldName": "Ending Date", - "FilterType": "Is Greater Than Or Equals To", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Posting Date", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - } - } - ] - } - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "FiscalYearEndDate" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "FiscalYearEndDate", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Posting Date", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - } - } - } - ] - } - }, - { - "ActivityType": "STRINGEXPRESSION", - "Activity": { - "OutputVariableName": "AccountingDateFilter", - "Expression": "{StartDate}..{EndDate}", - "Token": [ - { - "TokenName": "EndDate", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "FiscalYearStartDate" - } - } - }, - { - "TokenName": "StartDate", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "FiscalYearEndDate" - } - } - } - ] - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "InvoiceAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "TDS Entry", - "TableFieldName": "Invoice Amount", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Vendor No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - }, - { - "FiterFieldName": "Assessee Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Tax Attributes", - "AttributeName": "Assessee Code" - } - } - }, - { - "FiterFieldName": "Posting Date", - "FilterType": "CAL Filter", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AccountingDateFilter" - } - } - }, - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "Invoice" - } - } - ] - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "PaymentAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "TDS Entry", - "TableFieldName": "Payment Amount", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Vendor No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - }, - { - "FiterFieldName": "Assessee Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Tax Attributes", - "AttributeName": "Assessee Code" - } - } - }, - { - "FiterFieldName": "Posting Date", - "FilterType": "CAL Filter", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AccountingDateFilter" - } - } - }, - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "Payment" - } - } - ] - } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + }, + { + "Operator": "and", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Allowed Sections", + "TableFieldName": "Non Resident Payments", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Vendor No", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "AppliedAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Vendor Ledger Entry", - "TableFieldName": "Amount to Apply", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Document No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - } - } - ] - } + } + }, + { + "FiterFieldName": "TDS Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "EntryNo", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Vendor Ledger Entry", - "TableFieldName": "Entry No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. Type", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - } - }, - { - "FiterFieldName": "Document No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - } - } - ] - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "AppliedAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Detailed Vendor Ledg. Entry", - "TableFieldName": "Amount (LCY)", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Vendor Ledger Entry No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "EntryNo" - } - } - }, - { - "FiterFieldName": "Entry Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "Application" - } - }, - { - "FiterFieldName": "Document No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Posting Field", - "PostingVariableName": "Posted Document No." - } - } - } - ] - } - } - } - }, - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TotalInvAmt", - "Expression": "InvoiceAmt+PaymentAmt", - "Tokens": [ - { - "TokenName": "InvoiceAmt", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "InvoiceAmt" - } - } - }, - { - "TokenName": "PaymentAmt", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PaymentAmt" - } - } - } - ] - } - }, - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TotalInvAmt", - "Expression": "{Amt}+{InvAmt}", - "Tokens": [ - { - "TokenName": "{Amt}", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - }, - { - "TokenName": "{InvAmt}", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmt" - } - } - } - ] - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TotalAmtLCY", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Line", - "TableFieldName": "Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "Document No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - }, - { - "FiterFieldName": "TDS Section Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - } - ] - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "OriginalInvAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Line", - "TableFieldName": "Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "Document No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - }, - { - "FiterFieldName": "Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Type" - } - } - }, - { - "FiterFieldName": "TDS Section Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - } - ] - } - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Allowed Sections", - "TableFieldName": "", - "Method": "Exist", - "TableFilters": [ - { - "FiterFieldName": "Vendor No", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "TDS Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - }, - { - "FiterFieldName": "Threshold Overlook", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "true" - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmt" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvAmt" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "TDS Threshold Amount" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalAmtLCY" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Column", - "RateColumnName": "Per Contract Value" - } - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "PerContract", - "OutputValue": { - "Type": "Constant", - "Value": "true" - } - } - } - ] - } - } - ] - } - } - ] - } - } - ] - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - }, - { - "Operator": "or", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to ID", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "Applied", - "OutputValue": { - "Type": "Constant", - "Value": "true" - } - } - } - ] - } - }, - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TotalInvoiceAmount", - "Operator": "Multiply By", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Line", - "TableFieldName": "Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "Document No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "QtyFactor" - } - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Component", - "ComponentName": "Total TDS Amount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "0" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TotalInvoiceAmount", - "OutputValue": { - "Type": "Constant", - "Value": "0" - } - } - } - ] - } - }, - { - "ActivityType": "STRINGEXPRESSION", - "Activity": { - "OutputVariableName": "RecID", - "Expression": "Purchase Line: {DocType},{DocumentNo},{LineNo}", - "Token": [ - { - "TokenName": "DocType", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "TokenName": "DocumentNo", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - }, - { - "TokenName": "LineNo", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Line No." - } - } - } - ] - } - }, - { - "ActivityType": "LOOPTHROUGHRECORDS", - "Activity": { - "TableName": "Purchase Line", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "Document No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - }, - { - "FiterFieldName": "Gen. Bus. Posting Group", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Gen. Bus. Posting Group" - } - } - }, - { - "FiterFieldName": "Gen. Prod. Posting Group", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Gen. Prod. Posting Group" - } - } - }, - { - "FiterFieldName": "Dimension Set ID", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Dimension Set ID" - } - } - }, - { - "FiterFieldName": "TDS Section Code", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - } - ], - "LoopThroughRecordFields": [ - { - "FieldName": "Line No.", - "VariableName": "LineNo", - "CalculateSum": false - }, - { - "FieldName": "Quantity", - "VariableName": "LineQuantity", - "CalculateSum": false - }, - { - "FieldName": "Qty. to Invoice", - "VariableName": "LineQtyToInvoice", - "CalculateSum": false - }, - { - "FieldName": "Amount", - "VariableName": "LineAmount", - "CalculateSum": false - } - ], - "Body": [ - { - "ActivityType": "STRINGEXPRESSION", - "Activity": { - "OutputVariableName": "RecID", - "Expression": "Purchase Line: {DocType},{DocumentNo},{LineNo}", - "Token": [ - { - "TokenName": "DocType", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "TokenName": "DocumentNo", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - }, - { - "TokenName": "LineNo", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "LineNo" - } - } - } - ] - } - }, - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "LintQtyFactor", - "Operator": "Divided By", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "LineQtyToInvoice" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "LineQuantity" - } - } - } - }, - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "LineAmt", - "Operator": "Multiply By", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "LineAmount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "LintQtyFactor" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "GSTAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Tax Transaction Value", - "TableFieldName": "Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Tax Record ID", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "RecID" - } - } - }, - { - "FiterFieldName": "Value Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "COMPONENT" - } - }, - { - "FiterFieldName": "Percent", - "FilterType": "Not Equals", - "FilterValue": { - "Type": "Constant", - "Value": "0" - } - }, - { - "FiterFieldName": "Tax Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "GST Setup", - "TableFieldName": "GST Tax Type", - "Method": "First", - "TableFilters": [] - } - } - } - ] - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "LineTDSAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Tax Transaction Value", - "TableFieldName": "Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Tax Record ID", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "RecID" - } - } - }, - { - "FiterFieldName": "Value Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "COMPONENT" - } - }, - { - "FiterFieldName": "Percent", - "FilterType": "Not Equals", - "FilterValue": { - "Type": "Constant", - "Value": "0" - } - }, - { - "FiterFieldName": "Amount", - "FilterType": "Not Equals", - "FilterValue": { - "Type": "Constant", - "Value": "0" - } - }, - { - "FiterFieldName": "Tax Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "TDS Setup", - "TableFieldName": "Tax Type", - "Method": "First", - "TableFilters": [] - } - } - } - ] - } - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "LineTDSAmount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TotalInvoiceAmountWithTDS", - "Operator": "Plus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvoiceAmountWithTDS" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "LineAmt" - } - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TotalInvoiceAmountWithoutTDS", - "Operator": "Plus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvoiceAmountWithoutTDS" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "LineAmt" - } - } - } - } - ] - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Include GST in TDS Base", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "GSTAmt", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ] - } - }, - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TotalInvoiceAmount", - "Expression": "TotalInvoiceAmount+GSTAmt", - "Tokens": [ - { - "TokenName": "GSTAmt", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "GSTAmt" - } - } - }, - { - "TokenName": "TotalInvoiceAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvoiceAmount" - } - } - } - ] - } - }, - { - "ActivityType": "NUMERICEXPRESSION", - "Activity": { - "VariableName": "TotalGSTAmt", - "Expression": "TotalGSTAmt+GSTAmt", - "Tokens": [ - { - "TokenName": "GSTAmt", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "GSTAmt" - } - } - }, - { - "TokenName": "TotalGSTAmt", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalGSTAmt" - } - } - } - ] - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Greater Than", - "LHS": { - "Lookup": { - "SourceType": "Component", - "ComponentName": "Total TDS Amount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TotalInvoiceAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvoiceAmountWithTDS" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "OriginalInvAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvoiceAmountWithTDS" - } - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TotalInvoiceAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvoiceAmountWithoutTDS" - } - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "OriginalInvAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvoiceAmountWithoutTDS" - } - } - } - } - ] - } - } - }, - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "AppliedPaymentAmt", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "TDS Entry", - "TableFieldName": "Invoice Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "Payment" - } - }, - { - "FiterFieldName": "Document No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - } - } - ] - } - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to Doc. No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - }, - { - "Operator": "or", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to ID", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TotalInvoiceAmount", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - }, - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TotalInvoiceAmount", - "Operator": "Minus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "AppliedPaymentAmt" - } - } - } - } - ] - } - }, - { - "ActivityType": "LOOPTHROUGHRECORDS", - "Activity": { - "TableName": "Purchase Line", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "Document No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - }, - { - "FiterFieldName": "Line No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Line No." - } - } - } - ], - "LoopThroughRecordFields": [ - { - "FieldName": "Line No.", - "VariableName": "LineN", - "CalculateSum": false - } - ], - "Body": [ - { - "ActivityType": "STRINGEXPRESSION", - "Activity": { - "OutputVariableName": "RecdID", - "Expression": "Purchase Line: {DocType},{DocumentNo},{LineNo}", - "Token": [ - { - "TokenName": "DocType", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "TokenName": "DocumentNo", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - }, - { - "TokenName": "LineNo", - "FormatString": "", - "LookupVariableName": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "LineN" - } - } - } - ] - } - }, - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "GSTAmount", - "Operator": "Plus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "GSTAmount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Tax Transaction Value", - "TableFieldName": "Amount", - "Method": "Sum", - "TableFilters": [ - { - "FiterFieldName": "Tax Record ID", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "RecdID" - } - } - }, - { - "FiterFieldName": "Value Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Constant", - "Value": "COMPONENT" - } - }, - { - "FiterFieldName": "Percent", - "FilterType": "Not Equals", - "FilterValue": { - "Type": "Constant", - "Value": "0" - } - }, - { - "FiterFieldName": "Tax Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "GST Setup", - "TableFieldName": "GST Tax Type", - "Method": "First", - "TableFilters": [] - } - } - } - ] - } - } - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Include GST in TDS Base", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "true" - } - } - ] - }, - "Body": [ - { - "ActivityType": "NUMBERCALCULATION", - "Activity": { - "OutputVariableName": "TotalInvoiceAmount", - "Operator": "Plus", - "LHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - }, - "RHS": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "GSTAmount" - } - } - } - } - ] - } - } - ] - } - }, - { - "ActivityType": "IFSTATEMENT", - "Activity": { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Is Less Than Or Equals To", - "LHS": { - "Lookup": { - "SourceType": "Variable", - "VariableName": "TotalInvoiceAmount" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TotalInvoiceAmount", - "OutputValue": { - "Type": "Constant", - "Value": "" - } - } - } - ], - "ElseIf": { - "Condition": { - "Body": [] - }, - "Body": [ - { - "ActivityType": "SETVARIABLE", - "Activity": { - "OutputVariableName": "TotalInvoiceAmount", - "OutputValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Amount" - } - } - } - } - ] - } - } - } - ], - "Components": [ - { - "ComponentName": "TDS Base Amount", - "Sequence": 6, - "Formula": { - "VariableName": "TDS Base Amount", - "Expression": "TDSBaseAmount", - "Tokens": [ - { - "TokenName": "TDSBaseAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSBaseAmt" - } - } - } - ] - } - }, - { - "ComponentName": "Surcharge", - "Sequence": 2, - "Formula": { - "VariableName": "Surcharge", - "Expression": "SurchargeTaxableAmount*SurchargePercent/100", - "Tokens": [ - { - "TokenName": "SurchargePercent", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component Percent", - "ComponentName": "Surcharge" - } - } - }, - { - "TokenName": "SurchargeTaxableAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "SurchargeBaseAmt" - } - } - } - ] - } - }, - { - "ComponentName": "eCESS", - "Sequence": 3, - "Formula": { - "VariableName": "eCESS", - "Expression": "(TDSAmount+SurchargeAmount)*EcessPercent/100", - "Tokens": [ - { - "TokenName": "EcessPercent", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component Percent", - "ComponentName": "eCESS" - } - } - }, - { - "TokenName": "SurchargeAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "Surcharge" - } - } - }, - { - "TokenName": "TDSAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "TDS" - } - } - } - ] - } - }, - { - "ComponentName": "TDS", - "Sequence": 1, - "Formula": { - "VariableName": "TDS", - "Expression": "TDSTaxableAmount*TDSPercent/100", - "Tokens": [ - { - "TokenName": "TDSPercent", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component Percent", - "ComponentName": "TDS" - } - } - }, - { - "TokenName": "TDSTaxableAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSTaxableAmount" - } - } - } - ] - } - }, - { - "ComponentName": "Total TDS Amount", - "Sequence": 5, - "Formula": { - "VariableName": "Total TDS Amount", - "Expression": "TDSAmount+SurchargeAmount+ECessAmount+SHECessAmount", - "Tokens": [ - { - "TokenName": "ECessAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "eCESS" - } - } - }, - { - "TokenName": "SHECessAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "SHE Cess " - } - } - }, - { - "TokenName": "SurchargeAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "Surcharge" - } - } - }, - { - "TokenName": "TDSAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "TDS" - } - } - } - ] - } - }, - { - "ComponentName": "SHE Cess ", - "Sequence": 4, - "Formula": { - "VariableName": "SHE Cess ", - "Expression": "(TDSAmount+SurchargeAmount)*SHECessPercent/100", - "Tokens": [ - { - "TokenName": "SHECessPercent", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component Percent", - "ComponentName": "SHE Cess " - } - } - }, - { - "TokenName": "SurchargeAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "Surcharge" - } - } - }, - { - "TokenName": "TDSAmount", - "TokenValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "TDS" - } - } - } - ] - } - } - ], - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - }, - "RHS": { - "Type": "Constant", - "Value": "Order" - } - }, - { - "Operator": "or", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - }, - "RHS": { - "Type": "Constant", - "Value": "Invoice" - } - }, - { - "Operator": "and", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Vendor", - "TableFieldName": "P.A.N. Status", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": " " - } - }, - { - "Operator": "and", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "TDS Concessional Code", - "TableFieldName": "Concessional Code", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Vendor No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - }, - { - "Operator": "and", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Vendor", - "TableFieldName": "P.A.N. No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - }, - { - "Operator": "and", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Allowed Sections", - "TableFieldName": "Non Resident Payments", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Vendor No", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "TDS Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "No" - } - }, - { - "Operator": "and", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Work Tax Nature Of Deduction" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - }, - { - "Operator": "and", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - }, - { - "Operator": "and", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Applies-to ID", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - }, - { - "Operator": "and", - "ConditionType": "Equals", - "LHS": { - "Lookup": { - "SourceType": "Table", - "TableName": "Allowed Sections", - "TableFieldName": "Payment Overlook", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Vendor No", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FiterFieldName": "TDS Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - } - ] - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "TaxPostingSetup": [ - { - "ComponentName": "Total TDS Amount", - "TableName": "TDS Posting Setup", - "AccountSourceType": "Field", - "FieldName": "TDS Account", - "AccountingImpact": "Credit", - "ReverseCharge": false, - "ReverseAccountSourceType": "Field", - "ReverseChargeFieldName": "", - "When": [ - { - "Condition": { - "Body": [ - { - "Operator": " ", - "ConditionType": "Not Equals", - "LHS": { - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - }, - "RHS": { - "Type": "Constant", - "Value": "" - } - } - ] - }, - "ValueType": "Insert Record", - "Sequence": 0, - "InsertRecord": { - "TableName": "TDS Entry", - "RunTrigger": true, - "SubLedgerGrpBy": "Component", - "InsertRecordFields": [ - { - "FieldName": "Vendor No.", - "Sequence": 4, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Pay-to Vendor No." - } - } - }, - { - "FieldName": "T.A.N. No.", - "Sequence": 5, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Tax Attributes", - "AttributeName": "TAN No." - } - } - }, - { - "FieldName": "Section", - "Sequence": 6, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - }, - { - "FieldName": "Assessee Code", - "Sequence": 7, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Tax Attributes", - "AttributeName": "Assessee Code" - } - } - }, - { - "FieldName": "TDS Base Amount", - "Sequence": 8, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "TDS Base Amount" - } - } - }, - { - "FieldName": "TDS %", - "Sequence": 9, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component Percent", - "ComponentName": "TDS" - } - } - }, - { - "FieldName": "TDS Amount", - "Sequence": 10, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "TDS" - } - } - }, - { - "FieldName": "Surcharge %", - "Sequence": 11, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component Percent", - "ComponentName": "Surcharge" - } - } - }, - { - "FieldName": "Surcharge Amount", - "Sequence": 12, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "Surcharge" - } - } - }, - { - "FieldName": "eCess %", - "Sequence": 13, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component Percent", - "ComponentName": "eCESS" - } - } - }, - { - "FieldName": "eCess Amount", - "Sequence": 14, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "eCESS" - } - } - }, - { - "FieldName": "SHE Cess %", - "Sequence": 15, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component Percent", - "ComponentName": "SHE Cess " - } - } - }, - { - "FieldName": "SHE Cess Amount", - "Sequence": 16, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "SHE Cess " - } - } - }, - { - "FieldName": "Concessional Code", - "Sequence": 17, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Tax Attributes", - "AttributeName": "Concessional Code" - } - } - }, - { - "FieldName": "Concessional Form No.", - "Sequence": 37, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "TDS Concessional Code", - "TableFieldName": "Certificate No.", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Vendor No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Buy-from Vendor No." - } - } - }, - { - "FiterFieldName": "Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - } - ] - } - } - }, - { - "FieldName": "Deductee PAN No.", - "Sequence": 18, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Tax Attributes", - "AttributeName": "PAN No." - } - } - }, - { - "FieldName": "Nature of Remittance", - "Sequence": 19, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Nature of Remittance" - } - } - }, - { - "FieldName": "Act Applicable", - "Sequence": 20, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Act Applicable" - } - } - }, - { - "FieldName": "Invoice Amount", - "Sequence": 25, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "TDS Base Amount" - } - } - }, - { - "FieldName": "Posting Date", - "Sequence": 3, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Posting Date", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - } - }, - { - "FieldName": "Document Type", - "Sequence": 26, - "ReverseSign": false, - "Lookup": { - "Type": "Constant", - "Value": "Invoice" - } - }, - { - "FieldName": "Document No.", - "Sequence": 2, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Posting Field", - "PostingVariableName": "Posted Document No." - } - } - }, - { - "FieldName": "Account Type", - "Sequence": 23, - "ReverseSign": false, - "Lookup": { - "Type": "Constant", - "Value": "G/L Account" - } - }, - { - "FieldName": "Account No.", - "Sequence": 24, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "TDS Posting Setup", - "TableFieldName": "TDS Account", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "TDS Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - }, - { - "FiterFieldName": "Effective Date", - "FilterType": "Is Less Than Or Equals To", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Posting Date", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - } - } - ] - } - } - }, - { - "FieldName": "Source Code", - "Sequence": 28, - "ReverseSign": false, - "Lookup": { - "Type": "Constant", - "Value": "PURCHASES" - } - }, - { - "FieldName": "TDS Amount Including Surcharge", - "Sequence": 22, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSIncludingSurcharge" - } - } - }, - { - "FieldName": "Bal. TDS Including SHE CESS", - "Sequence": 29, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "TDSIncludingSHECess" - } - } - }, - { - "FieldName": "Applied", - "Sequence": 44, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "Applied" - } - } - }, - { - "FieldName": "Remaining Surcharge Amount", - "Sequence": 31, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "Surcharge" - } - } - }, - { - "FieldName": "Remaining TDS Amount", - "Sequence": 42, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "TDS" - } - } - }, - { - "FieldName": "Total TDS Including SHE CESS", - "Sequence": 21, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "Total TDS Amount" - } - } - }, - { - "FieldName": "Per Contract", - "Sequence": 39, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "PerContract" - } - } - }, - { - "FieldName": "Party Account No.", - "Sequence": 45, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "TDS Posting Setup", - "TableFieldName": "TDS Account", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "TDS Section", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "TDS Section Code" - } - } - }, - { - "FiterFieldName": "Effective Date", - "FilterType": "Is Less Than Or Equals To", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Table", - "TableName": "Purchase Header", - "TableFieldName": "Posting Date", - "Method": "First", - "TableFilters": [ - { - "FiterFieldName": "Document Type", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document Type" - } - } - }, - { - "FiterFieldName": "No.", - "FilterType": "Equals", - "FilterValue": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Current Record", - "TableName": "Purchase Line", - "FieldName": "Document No." - } - } - } - ] - } - } - } - ] - } - } - }, - { - "FieldName": "User ID", - "Sequence": 30, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Database", - "DatabaseVariableName": "UserId" - } - } - }, - { - "FieldName": "Transaction No.", - "Sequence": 38, - "ReverseSign": false, - "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Posting Field", - "PostingVariableName": "G/L Entry Transaction No." - } - } - }, - { - "FieldName": "Original TDS Base Amount", - "Sequence": 27, - "ReverseSign": false, + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "No" + } + }, + { + "Operator": "and", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Work Tax Nature Of Deduction" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + }, + { + "Operator": "and", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + }, + { + "Operator": "and", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Applies-to ID", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + }, + { + "Operator": "and", + "ConditionType": "Equals", + "LHS": { + "Lookup": { + "SourceType": "Table", + "TableName": "Allowed Sections", + "TableFieldName": "Payment Overlook", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Vendor No", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FiterFieldName": "TDS Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + } + ] + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "TaxPostingSetup": [ + { + "ComponentName": "Total TDS Amount", + "TableName": "TDS Posting Setup", + "AccountSourceType": "Field", + "FieldName": "TDS Account", + "AccountingImpact": "Credit", + "ReverseCharge": false, + "ReverseAccountSourceType": "Field", + "ReverseChargeFieldName": "", + "When": [ + { + "Condition": { + "Body": [ + { + "Operator": " ", + "ConditionType": "Not Equals", + "LHS": { + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + }, + "RHS": { + "Type": "Constant", + "Value": "" + } + } + ] + }, + "ValueType": "Insert Record", + "Sequence": 0, + "InsertRecord": { + "TableName": "TDS Entry", + "RunTrigger": true, + "SubLedgerGrpBy": "Component", + "InsertRecordFields": [ + { + "FieldName": "Vendor No.", + "Sequence": 4, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Pay-to Vendor No." + } + } + }, + { + "FieldName": "T.A.N. No.", + "Sequence": 5, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Tax Attributes", + "AttributeName": "TAN No." + } + } + }, + { + "FieldName": "Section", + "Sequence": 6, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FieldName": "Assessee Code", + "Sequence": 7, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Tax Attributes", + "AttributeName": "Assessee Code" + } + } + }, + { + "FieldName": "TDS Base Amount", + "Sequence": 8, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "TDS Base Amount" + } + } + }, + { + "FieldName": "TDS %", + "Sequence": 9, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component Percent", + "ComponentName": "TDS" + } + } + }, + { + "FieldName": "TDS Amount", + "Sequence": 10, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "TDS" + } + } + }, + { + "FieldName": "Surcharge %", + "Sequence": 11, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component Percent", + "ComponentName": "Surcharge" + } + } + }, + { + "FieldName": "Surcharge Amount", + "Sequence": 12, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "Surcharge" + } + } + }, + { + "FieldName": "eCess %", + "Sequence": 13, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component Percent", + "ComponentName": "eCESS" + } + } + }, + { + "FieldName": "eCess Amount", + "Sequence": 14, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "eCESS" + } + } + }, + { + "FieldName": "SHE Cess %", + "Sequence": 15, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component Percent", + "ComponentName": "SHE Cess " + } + } + }, + { + "FieldName": "SHE Cess Amount", + "Sequence": 16, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "SHE Cess " + } + } + }, + { + "FieldName": "Concessional Code", + "Sequence": 17, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Tax Attributes", + "AttributeName": "Concessional Code" + } + } + }, + { + "FieldName": "Concessional Form No.", + "Sequence": 37, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Concessional Code", + "TableFieldName": "Certificate No.", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Vendor No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Buy-from Vendor No." + } + } + }, + { + "FiterFieldName": "Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + } + ] + } + } + }, + { + "FieldName": "Deductee PAN No.", + "Sequence": 18, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Tax Attributes", + "AttributeName": "PAN No." + } + } + }, + { + "FieldName": "Nature of Remittance", + "Sequence": 19, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Nature of Remittance" + } + } + }, + { + "FieldName": "Act Applicable", + "Sequence": 20, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Act Applicable" + } + } + }, + { + "FieldName": "Invoice Amount", + "Sequence": 25, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "TDS Base Amount" + } + } + }, + { + "FieldName": "Posting Date", + "Sequence": 3, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Posting Date", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" + } + } + }, + { + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." + } + } + } + ] + } + } + }, + { + "FieldName": "Document Type", + "Sequence": 26, + "ReverseSign": false, + "Lookup": { + "Type": "Constant", + "Value": "Invoice" + } + }, + { + "FieldName": "Document No.", + "Sequence": 2, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Posting Field", + "PostingVariableName": "Posted Document No." + } + } + }, + { + "FieldName": "Account Type", + "Sequence": 23, + "ReverseSign": false, + "Lookup": { + "Type": "Constant", + "Value": "G/L Account" + } + }, + { + "FieldName": "Account No.", + "Sequence": 24, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Posting Setup", + "TableFieldName": "TDS Account", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "TDS Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FiterFieldName": "Effective Date", + "FilterType": "Is Less Than Or Equals To", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Posting Date", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "TDS Base Amount" - } + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" } + } }, { - "FieldName": "Surcharge Base Amount", - "Sequence": 41, - "ReverseSign": false, + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Component", - "ComponentName": "TDS" - } + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." } - }, - { - "FieldName": "G/L Entry No.", - "Sequence": 1, - "ReverseSign": false, + } + } + ] + } + } + } + ] + } + } + }, + { + "FieldName": "Source Code", + "Sequence": 28, + "ReverseSign": false, + "Lookup": { + "Type": "Constant", + "Value": "PURCHASES" + } + }, + { + "FieldName": "TDS Amount Including Surcharge", + "Sequence": 22, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSIncludingSurcharge" + } + } + }, + { + "FieldName": "Bal. TDS Including SHE CESS", + "Sequence": 29, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "TDSIncludingSHECess" + } + } + }, + { + "FieldName": "Applied", + "Sequence": 44, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "Applied" + } + } + }, + { + "FieldName": "Remaining Surcharge Amount", + "Sequence": 31, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "Surcharge" + } + } + }, + { + "FieldName": "Remaining TDS Amount", + "Sequence": 42, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "TDS" + } + } + }, + { + "FieldName": "Total TDS Including SHE CESS", + "Sequence": 21, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "Total TDS Amount" + } + } + }, + { + "FieldName": "Per Contract", + "Sequence": 39, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "PerContract" + } + } + }, + { + "FieldName": "Party Account No.", + "Sequence": 45, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "TDS Posting Setup", + "TableFieldName": "TDS Account", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "TDS Section", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "TDS Section Code" + } + } + }, + { + "FiterFieldName": "Effective Date", + "FilterType": "Is Less Than Or Equals To", + "FilterValue": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Table", + "TableName": "Purchase Header", + "TableFieldName": "Posting Date", + "Method": "First", + "TableFilters": [ + { + "FiterFieldName": "Document Type", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Posting Field", - "PostingVariableName": "G/L Entry No." - } + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document Type" } + } }, { - "FieldName": "Original Invoice Amount", - "Sequence": 46, - "ReverseSign": false, + "FiterFieldName": "No.", + "FilterType": "Equals", + "FilterValue": { + "Type": "Lookup", "Lookup": { - "Type": "Lookup", - "Lookup": { - "SourceType": "Variable", - "VariableName": "OriginalInvAmount" - } + "SourceType": "Current Record", + "TableName": "Purchase Line", + "FieldName": "Document No." } + } } - ] + ] + } + } } + ] } - ] + } + }, + { + "FieldName": "User ID", + "Sequence": 30, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Database", + "DatabaseVariableName": "UserId" + } + } + }, + { + "FieldName": "Transaction No.", + "Sequence": 38, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Posting Field", + "PostingVariableName": "G/L Entry Transaction No." + } + } + }, + { + "FieldName": "Original TDS Base Amount", + "Sequence": 27, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "TDS Base Amount" + } + } + }, + { + "FieldName": "Surcharge Base Amount", + "Sequence": 41, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Component", + "ComponentName": "TDS" + } + } + }, + { + "FieldName": "G/L Entry No.", + "Sequence": 1, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Posting Field", + "PostingVariableName": "G/L Entry No." + } + } + }, + { + "FieldName": "Original Invoice Amount", + "Sequence": 46, + "ReverseSign": false, + "Lookup": { + "Type": "Lookup", + "Lookup": { + "SourceType": "Variable", + "VariableName": "OriginalInvAmount" + } + } + } + ] } + } ] - } + } + ] + } ] \ No newline at end of file diff --git a/Apps/IN/INTDS/app/TDSBase/src/TaxEngineSetup/TDSTaxConfiguration.Codeunit.al b/Apps/IN/INTDS/app/TDSBase/src/TaxEngineSetup/TDSTaxConfiguration.Codeunit.al index 48aa8bcbd5..72ab2bcd48 100644 --- a/Apps/IN/INTDS/app/TDSBase/src/TaxEngineSetup/TDSTaxConfiguration.Codeunit.al +++ b/Apps/IN/INTDS/app/TDSBase/src/TaxEngineSetup/TDSTaxConfiguration.Codeunit.al @@ -63,7 +63,7 @@ codeunit 18694 "TDS Tax Configuration" UseCases.Add('{B0C259BC-64CC-4818-887A-3337D357CDFF}', 2); UseCases.Add('{33BFBE99-9140-4112-A55B-35EC0D9B61B9}', 5); UseCases.Add('{271D5BC6-17E8-424E-9E34-3BEE548F938F}', 1); - UseCases.Add('{A8E114BF-F8CD-44DB-A2B3-614BC18F4442}', 31); + UseCases.Add('{A8E114BF-F8CD-44DB-A2B3-614BC18F4442}', 32); UseCases.Add('{6FBA1A5C-41A0-4430-976E-6B54E4884164}', 1); UseCases.Add('{FEE5DFFF-0BC1-4246-AD90-6CB3DC44A451}', 1); UseCases.Add('{FA0E357D-1AC0-42AA-94DE-6DACA521D38E}', 2); diff --git a/Apps/IS/ISCore/app/src/PageExtensions/ISSalesReceivablesSetup.PageExt.al b/Apps/IS/ISCore/app/src/PageExtensions/ISSalesReceivablesSetup.PageExt.al index 0fcdc56999..c8812f2866 100644 --- a/Apps/IS/ISCore/app/src/PageExtensions/ISSalesReceivablesSetup.PageExt.al +++ b/Apps/IS/ISCore/app/src/PageExtensions/ISSalesReceivablesSetup.PageExt.al @@ -3,6 +3,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // ------------------------------------------------------------------------------------------------ namespace Microsoft.Sales.Setup; +using Microsoft.Finance; pageextension 14606 "IS Sales & Receivables Setup" extends "Sales & Receivables Setup" { @@ -17,4 +18,28 @@ pageextension 14606 "IS Sales & Receivables Setup" extends "Sales & Receivables } } } + actions + { + addfirst(navigation) + { + group(Action) + { + Caption = 'Actions'; + action("Print Statements") + { + ApplicationArea = Basic, Suite; + Caption = 'Print Statement'; + RunObject = report "IS IRS notification"; + Image = "Report"; + ToolTip = 'Generate a letter that can be sent to the Internal Revenue Service (IRS) if the company wants to print invoices in a single copy. The report includes the company information by default. To change the wording, you must modify the text in Visual Studio Report Designer.'; + } + } + } + addfirst(Category_Report) + { + actionref("Print Statement_Promoted2"; "Print Statements") + { + } + } + } } \ No newline at end of file diff --git a/Apps/NL/ContosoCoffeeDemoDatasetNL/app/DemoData/Finance/2.Master Data/CreateCurrencyNL.Codeunit.al b/Apps/NL/ContosoCoffeeDemoDatasetNL/app/DemoData/Finance/2.Master Data/CreateCurrencyNL.Codeunit.al index cc9f9e7d32..2d82b932c1 100644 --- a/Apps/NL/ContosoCoffeeDemoDatasetNL/app/DemoData/Finance/2.Master Data/CreateCurrencyNL.Codeunit.al +++ b/Apps/NL/ContosoCoffeeDemoDatasetNL/app/DemoData/Finance/2.Master Data/CreateCurrencyNL.Codeunit.al @@ -5,6 +5,7 @@ namespace Microsoft.DemoData.Finance; +using Microsoft.DemoData.Localization; using Microsoft.Finance.Currency; codeunit 11536 "Create Currency NL" @@ -80,4 +81,14 @@ codeunit 11536 "Create Currency NL" Currency.Validate("Realized Gains Acc.", ''); Currency.Validate("Realized Losses Acc.", ''); end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Add. Reporting Currency", OnBeforeGetResidualCurrencyAccounts, '', false, false)] + local procedure GetResidualCurrencyAccountsNL(var FXGainsAccount: Code[20]; var FXLossesAccount: Code[20]; var IsHandled: Boolean) + var + CreateNLGLAccount: Codeunit "Create NL GL Accounts"; + begin + FXGainsAccount := CreateNLGLAccount.CurrencyGains(); + FXLossesAccount := CreateNLGLAccount.CurrencyLosses(); + IsHandled := true; + end; } diff --git a/Apps/NO/ContosoCoffeeDemoDatasetNO/app/DemoData/Finance/2.Master Data/CreatePostingGroupsNO.Codeunit.al b/Apps/NO/ContosoCoffeeDemoDatasetNO/app/DemoData/Finance/2.Master Data/CreatePostingGroupsNO.Codeunit.al index 95759cf4a0..f9f4a09fed 100644 --- a/Apps/NO/ContosoCoffeeDemoDatasetNO/app/DemoData/Finance/2.Master Data/CreatePostingGroupsNO.Codeunit.al +++ b/Apps/NO/ContosoCoffeeDemoDatasetNO/app/DemoData/Finance/2.Master Data/CreatePostingGroupsNO.Codeunit.al @@ -71,10 +71,12 @@ codeunit 10708 "Create Posting Groups NO" ContosoGenPostingSetup.InsertGeneralPostingSetup(CustDom(), NoVatPostingGroup(), CreateGLAccount.SalesRawMaterialsDom(), '', CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); ContosoGenPostingSetup.InsertGeneralPostingSetup(CustDom(), CreatePostingGroups.RetailPostingGroup(), CreateGLAccount.SalesRetailDom(), '', CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); ContosoGenPostingSetup.InsertGeneralPostingSetup(CustDom(), CreatePostingGroups.ServicesPostingGroup(), CreateGLAccount.SalesResourcesDom(), '', CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); + ContosoGenPostingSetup.InsertGeneralPostingSetup(CustDom(), CreatePostingGroups.MiscPostingGroup(), CreateGLAccount.SalesResourcesDom(), '', CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); ContosoGenPostingSetup.InsertGeneralPostingSetup(CustFor(), NoVatPostingGroup(), CreateGLAccount.SalesRawMaterialsDom(), '', CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); ContosoGenPostingSetup.InsertGeneralPostingSetup(CustFor(), CreatePostingGroups.RetailPostingGroup(), CreateGLAccount.SalesRetailExport(), '', CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); ContosoGenPostingSetup.InsertGeneralPostingSetup(CustFor(), CreatePostingGroups.ServicesPostingGroup(), CreateGLAccount.SalesResourcesExport(), '', CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); + ContosoGenPostingSetup.InsertGeneralPostingSetup(CustFor(), CreatePostingGroups.MiscPostingGroup(), CreateGLAccount.SalesResourcesExport(), '', CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); ContosoGenPostingSetup.InsertGeneralPostingSetup(VendDom(), NoVatPostingGroup(), '', CreateGLAccount.PurchRetailDom(), CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); ContosoGenPostingSetup.InsertGeneralPostingSetup(VendDom(), CreatePostingGroups.RetailPostingGroup(), '', CreateGLAccount.PurchRetailDom(), CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); diff --git a/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/1.Setup Data/CreateCurrencyUS.Codeunit.al b/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/1.Setup Data/CreateCurrencyUS.Codeunit.al index 19531c10ac..c9c7171d97 100644 --- a/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/1.Setup Data/CreateCurrencyUS.Codeunit.al +++ b/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/1.Setup Data/CreateCurrencyUS.Codeunit.al @@ -35,4 +35,14 @@ codeunit 11486 "Create Currency US" Currency.Validate("Realized Gains Acc.", RealizedGainsAcc); Currency.Validate("Realized Losses Acc.", RealizedLossesAcc); end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Add. Reporting Currency", OnBeforeGetResidualCurrencyAccounts, '', false, false)] + local procedure GetResidualCurrencyAccountsUS(var FXGainsAccount: Code[20]; var FXLossesAccount: Code[20]; var IsHandled: Boolean) + var + CreateUSGLAccount: Codeunit "Create US GL Accounts"; + begin + FXGainsAccount := CreateUSGLAccount.CurrencyGains(); + FXLossesAccount := CreateUSGLAccount.CurrencyLosses(); + IsHandled := true; + end; } diff --git a/Apps/US/IRSForms/app/src/Document/IRS1099FormDocLine.Table.al b/Apps/US/IRSForms/app/src/Document/IRS1099FormDocLine.Table.al index bae8bce441..24736bb33d 100644 --- a/Apps/US/IRSForms/app/src/Document/IRS1099FormDocLine.Table.al +++ b/Apps/US/IRSForms/app/src/Document/IRS1099FormDocLine.Table.al @@ -61,7 +61,7 @@ table 10036 "IRS 1099 Form Doc. Line" trigger OnValidate() begin TestStatusOpen(); - Validate("Include In 1099", Rec.Amount > Rec."Minimum Reportable Amount"); + Validate("Include In 1099", Rec.Amount >= Rec."Minimum Reportable Amount"); end; } field(20; "Manually Changed"; Boolean) diff --git a/Apps/US/IRSForms/app/src/Extensions/IRS1099BaseAppSubscribers.Codeunit.al b/Apps/US/IRSForms/app/src/Extensions/IRS1099BaseAppSubscribers.Codeunit.al index 57edfcffd1..d63ab290c0 100644 --- a/Apps/US/IRSForms/app/src/Extensions/IRS1099BaseAppSubscribers.Codeunit.al +++ b/Apps/US/IRSForms/app/src/Extensions/IRS1099BaseAppSubscribers.Codeunit.al @@ -8,7 +8,9 @@ using Microsoft.Finance.GeneralLedger.Journal; using Microsoft.Finance.GeneralLedger.Reversal; using Microsoft.Purchases.Document; using Microsoft.Purchases.Payables; +using Microsoft.Purchases.Vendor; using Microsoft.Utilities; +using System.Utilities; codeunit 10032 "IRS 1099 BaseApp Subscribers" { @@ -151,6 +153,25 @@ codeunit 10032 "IRS 1099 BaseApp Subscribers" end; end; + [EventSubscriber(ObjectType::Page, Page::"Error Messages", 'OnOpenRelatedRecord', '', false, false)] + local procedure OpenTransmissionErrorRelatedRecord(ErrorMessage: Record "Error Message"; var IsHandled: Boolean) + var + Vendor: Record Vendor; + PageManagement: Codeunit "Page Management"; + begin + if ErrorMessage."Context Table Number" <> Database::"Transmission IRIS" then + exit; + + case ErrorMessage."Table Number" of + Database::Vendor: + if ErrorMessage."Additional Information" <> '' then begin + Vendor.SetFilter("No.", ErrorMessage."Additional Information"); + PageManagement.PageRunList(Vendor); + IsHandled := true; + end; + end; + end; + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Reverse", 'OnReverseVendLedgEntryOnBeforeInsertVendLedgEntry', '', false, false)] local procedure ReverseIRS1099AmountOnReverseVendLedgEntryOnBeforeInsertVendLedgEntry(var NewVendLedgEntry: Record "Vendor Ledger Entry"; VendLedgEntry: Record "Vendor Ledger Entry") begin diff --git a/Apps/US/IRSForms/app/src/IRIS/DataCheckIRIS.Codeunit.al b/Apps/US/IRSForms/app/src/IRIS/DataCheckIRIS.Codeunit.al index ab6a6035eb..3143280143 100644 --- a/Apps/US/IRSForms/app/src/IRIS/DataCheckIRIS.Codeunit.al +++ b/Apps/US/IRSForms/app/src/IRIS/DataCheckIRIS.Codeunit.al @@ -13,6 +13,7 @@ codeunit 10044 "Data Check IRIS" Access = Internal; var + TransmissionContext: Record "Transmission IRIS"; Helper: Codeunit "Helper IRIS"; OAuthClient: Codeunit "OAuth Client IRIS"; ErrorMessageMgt: Codeunit "Error Message Management"; @@ -20,9 +21,13 @@ codeunit 10044 "Data Check IRIS" PeriodNoErr: Label 'The period of the transmission must be a valid year in the format YYYY.'; VendorNotFoundErr: Label 'The vendor %1 is not found for the document %2.', Comment = '%1 - vendor number, %2 - document ID'; IncorrectTINLengthErr: Label '(TIN) must be exactly %1 digits long.', Comment = '%1 - expected length'; + IncorrectFieldLengthErr: Label 'must be between %1 and %2 characters. Allowed characters: %3.', Comment = '%1 - min length, %2 - max length, %3 - allowed characters'; + IncorrectPhoneNoLengthErr: Label 'must be between %1 and %2 digits. Multiple numbers or extensions numbers can be separated by commas.', Comment = '%1 - min length, %2 - max length'; IncorrectStateAbbrErr: Label 'must be a valid 2-letter US state code. Example: WA, IL, FL.'; IncorrectZipCodeErr: Label 'must be 5, 9 or 12 digits.'; + PersonNameAllowedCharsTxt: Label 'A-Z, a-z, 0-9, hyphen, apostrophe and single space'; UserIDMustBeSetErr: Label 'IRIS User ID must be specified. Use the action Setup IRIS User ID on the IRS Forms Setup page to see instructions for getting your IRIS User ID.'; + DuplicateTINErr: Label '%1 vendors have the same TIN %2. Set up different Preferred Bank Account Codes with unique Bank Account No. for each vendor. Use the Open Related Record action to see the affected vendors.', Comment = '%1 - number of vendors, %2 - TIN'; procedure CheckDataToReport(var Transmission: Record "Transmission IRIS") var @@ -32,6 +37,7 @@ codeunit 10044 "Data Check IRIS" begin Helper.GetAmtXmlElementsFileContent(Transmission."Period No."); + TransmissionContext := Transmission; ErrorMessageMgt.Activate(ErrorMessageHandler); ValidateSetup(); @@ -88,8 +94,10 @@ codeunit 10044 "Data Check IRIS" var CompanyInformation: Record "Company Information"; TIN: Text; + ContactPersonName: Text; + PhoneNo: Text; ZipCode: Text; - StateTypeIRIS: Enum "State Type IRIS"; + StateCode: Text; begin CompanyInformation.Get(); @@ -99,9 +107,21 @@ codeunit 10044 "Data Check IRIS" CompanyInformation, CompanyInformation.FieldNo("Federal ID No."), StrSubstNo(IncorrectTINLengthErr, GetTINLength())); + ContactPersonName := Helper.FormatContactPersonName(CompanyInformation."Contact Person"); + if (StrLen(ContactPersonName) < 1) or (StrLen(ContactPersonName) > GetPersonNameMaxLength()) then + ErrorMessageMgt.LogFieldError( + CompanyInformation, CompanyInformation.FieldNo("Contact Person"), + StrSubstNo(IncorrectFieldLengthErr, 1, GetPersonNameMaxLength(), PersonNameAllowedCharsTxt)); + + PhoneNo := Helper.FormatPhoneNumber(CompanyInformation."Phone No."); + if (StrLen(PhoneNo) < GetPhoneNoMinLength()) or (StrLen(PhoneNo) > GetPhoneNoMaxLength()) then + ErrorMessageMgt.LogFieldError( + CompanyInformation, CompanyInformation.FieldNo("Phone No."), + StrSubstNo(IncorrectPhoneNoLengthErr, GetPhoneNoMinLength(), GetPhoneNoMaxLength())); + // only for US if not Helper.IsForeignCountryRegion(CompanyInformation."Country/Region Code") then begin - if not Evaluate(StateTypeIRIS, CompanyInformation.County) then + if not Helper.MatchStateCode(CompanyInformation.County, StateCode) then ErrorMessageMgt.LogFieldError(CompanyInformation, CompanyInformation.FieldNo(County), IncorrectStateAbbrErr); ZipCode := Helper.FormatZipCode(CompanyInformation."Post Code"); @@ -116,16 +136,17 @@ codeunit 10044 "Data Check IRIS" TIN: Text; ZipCode: Text; CityName: Text; - StateTypeIRIS: Enum "State Type IRIS"; + StateCode: Text; VendorList: Dictionary of [Text, Text]; + VendorsByFormNo: Dictionary of [Code[20], List of [Code[20]]]; VendorNo: Text; begin if not IRS1099FormDocHeader.FindSet() then exit; - Vendor.SetLoadFields("No.", "Federal ID No.", "Country/Region Code", "County", "Post Code", City); + Vendor.SetLoadFields("No.", "Federal ID No.", "Country/Region Code", "County", "Post Code", City, "Preferred Bank Account Code"); - // add unique vendors to the list + // add unique vendors to the list and collect vendor-form mapping repeat if not Vendor.Get(IRS1099FormDocHeader."Vendor No.") then begin ErrorMessageMgt.LogError( @@ -135,6 +156,8 @@ codeunit 10044 "Data Check IRIS" if not VendorList.ContainsKey(Vendor."No.") then VendorList.Add(Vendor."No.", ''); + + AddVendorToFormNoGroup(VendorsByFormNo, Vendor."No.", IRS1099FormDocHeader."Form No."); until IRS1099FormDocHeader.Next() = 0; foreach VendorNo in VendorList.Keys do begin @@ -146,7 +169,7 @@ codeunit 10044 "Data Check IRIS" StrSubstNo(IncorrectTINLengthErr, GetTINLength())); if not Helper.IsForeignCountryRegion(Vendor."Country/Region Code") then begin - if not Evaluate(StateTypeIRIS, Vendor.County) then + if not Helper.MatchStateCode(Vendor.County, StateCode) then ErrorMessageMgt.LogFieldError(Vendor, Vendor.FieldNo(County), IncorrectStateAbbrErr); ZipCode := Helper.FormatZipCode(Vendor."Post Code"); @@ -159,6 +182,103 @@ codeunit 10044 "Data Check IRIS" ErrorMessageMgt.LogFieldError(Vendor, Vendor.FieldNo(City), EmptyFieldErr); end; end; + + ValidateDuplicateTINs(VendorsByFormNo); + end; + + local procedure AddVendorToFormNoGroup(var VendorsByFormNo: Dictionary of [Code[20], List of [Code[20]]]; VendorNo: Code[20]; FormNo: Code[20]) + var + FormVendorNos: List of [Code[20]]; + begin + if not VendorsByFormNo.ContainsKey(FormNo) then + VendorsByFormNo.Add(FormNo, FormVendorNos); + VendorsByFormNo.Get(FormNo, FormVendorNos); + if not FormVendorNos.Contains(VendorNo) then + FormVendorNos.Add(VendorNo); + VendorsByFormNo.Set(FormNo, FormVendorNos); + end; + + local procedure ValidateDuplicateTINs(VendorsByFormNo: Dictionary of [Code[20], List of [Code[20]]]) + var + VendorNos: List of [Code[20]]; + FormNo: Code[20]; + begin + // check duplicate TINs within each submission (form type) + foreach FormNo in VendorsByFormNo.Keys do begin + VendorsByFormNo.Get(FormNo, VendorNos); + ValidateDuplicateTINsForSubmission(VendorNos); + end; + end; + + local procedure ValidateDuplicateTINsForSubmission(SubmissionVendorNos: List of [Code[20]]) + var + Vendor: Record Vendor; + VendorsByTIN: Dictionary of [Text, List of [Code[20]]]; + TINVendorNos: List of [Code[20]]; + BankAccountNumbers: Dictionary of [Text, Text]; + VendorNo: Code[20]; + TIN: Text; + BankAccountNo: Text; + VendorFilter: Text; + HasError: Boolean; + begin + Vendor.SetLoadFields("No.", "Federal ID No.", "Preferred Bank Account Code"); + + // Group vendors by TIN within this submission + foreach VendorNo in SubmissionVendorNos do + if Vendor.Get(VendorNo) then begin + TIN := Helper.FormatTIN(Vendor."Federal ID No."); + if TIN <> '' then begin + if not VendorsByTIN.ContainsKey(TIN) then begin + Clear(TINVendorNos); + VendorsByTIN.Add(TIN, TINVendorNos); + end; + VendorsByTIN.Get(TIN, TINVendorNos); + if not TINVendorNos.Contains(Vendor."No.") then + TINVendorNos.Add(Vendor."No."); + VendorsByTIN.Set(TIN, TINVendorNos); + end; + end; + + // Check each TIN group with multiple vendors + foreach TIN in VendorsByTIN.Keys do begin + VendorsByTIN.Get(TIN, TINVendorNos); + if TINVendorNos.Count() > 1 then begin + Clear(BankAccountNumbers); + HasError := false; + VendorFilter := ''; + + foreach VendorNo in TINVendorNos do begin + Vendor.Get(VendorNo); + BankAccountNo := Helper.GetVendorBankAccountNo(Vendor); + + if BankAccountNo = '' then + HasError := true; + + if BankAccountNumbers.ContainsKey(BankAccountNo) then + HasError := true + else + BankAccountNumbers.Add(BankAccountNo, ''); + + if VendorFilter <> '' then + VendorFilter += '|'; + VendorFilter += Vendor."No."; + end; + + if HasError then + LogDuplicateTINError(TIN, TINVendorNos.Count(), CopyStr(VendorFilter, 1, 250)); + end; + end; + end; + + local procedure LogDuplicateTINError(TIN: Text; VendorCount: Integer; VendorFilter: Text[250]) + var + Vendor: Record Vendor; + ErrorContextElement: Codeunit "Error Context Element"; + begin + ErrorMessageMgt.PushContext(ErrorContextElement, TransmissionContext, 0, VendorFilter); + ErrorMessageMgt.LogError(Vendor, StrSubstNo(DuplicateTINErr, VendorCount, TIN), ''); + ErrorMessageMgt.PopContext(ErrorContextElement); end; procedure GetFormBoxListWithEmptyAmtXmlElemName(PeriodNo: Code[20]) FormBoxes: List of [Text] @@ -182,4 +302,19 @@ codeunit 10044 "Data Check IRIS" begin exit(9); end; + + local procedure GetPersonNameMaxLength(): Integer + begin + exit(35); + end; + + local procedure GetPhoneNoMinLength(): Integer + begin + exit(10); + end; + + local procedure GetPhoneNoMaxLength(): Integer + begin + exit(30); + end; } \ No newline at end of file diff --git a/Apps/US/IRSForms/app/src/IRIS/GenerateXmlFileIRIS.Codeunit.al b/Apps/US/IRSForms/app/src/IRIS/GenerateXmlFileIRIS.Codeunit.al index af4014779c..4b53f262a6 100644 --- a/Apps/US/IRSForms/app/src/IRIS/GenerateXmlFileIRIS.Codeunit.al +++ b/Apps/US/IRSForms/app/src/IRIS/GenerateXmlFileIRIS.Codeunit.al @@ -387,7 +387,7 @@ codeunit 10033 "Generate Xml File IRIS" AddRecipientDetails(Vendor); - Helper.AppendXmlNode('RecipientAccountNum', GetVendorBankAccountNo(Vendor)); + Helper.AppendXmlNode('RecipientAccountNum', Helper.GetVendorBankAccountNo(Vendor)); CalcFormTotalAmounts(TempIRS1099FormDocHeader, TotalAmounts); GetFormBoxAmtXmlElemNamesAndValues(TempIRS1099FormDocHeader, TotalAmounts, FormBoxAmtXmlElemNamesValues); @@ -585,6 +585,7 @@ codeunit 10033 "Generate Xml File IRIS" var AddressLine1: Text; AddressLine2: Text; + FormattedStateCode: Text; begin Helper.AddParentXmlNode(AddressTagName); Helper.AddParentXmlNode(Format(Enum::"Address Type IRIS"::USAddress)); @@ -593,7 +594,8 @@ codeunit 10033 "Generate Xml File IRIS" Helper.AppendXmlNode('AddressLine1Txt', AddressLine1); Helper.AppendXmlNode('AddressLine2Txt', AddressLine2); Helper.AppendXmlNode('CityNm', Helper.FormatCityName(CityName, Enum::"Address Type IRIS"::USAddress)); - Helper.AppendXmlNode('StateAbbreviationCd', Format(StateCode)); + Helper.MatchStateCode(StateCode, FormattedStateCode); + Helper.AppendXmlNode('StateAbbreviationCd', FormattedStateCode); Helper.AppendXmlNode('ZIPCd', Helper.FormatZipCode(PostCode)); Helper.CloseParentXmlNode(); @@ -674,20 +676,6 @@ codeunit 10033 "Generate Xml File IRIS" exit(VendorNos.Keys()); end; - local procedure GetVendorBankAccountNo(var Vendor: Record Vendor) BankAccountNo: Text - var - VendorBankAccount: Record "Vendor Bank Account"; - begin - if Vendor."Preferred Bank Account Code" <> '' then begin - VendorBankAccount.Get(Vendor."No.", Vendor."Preferred Bank Account Code"); - BankAccountNo := VendorBankAccount.GetBankAccountNo(); - end; - - BankAccountNo := Helper.FormatText(BankAccountNo); - if StrLen(BankAccountNo) > 30 then - BankAccountNo := ''; - end; - local procedure CalcFormTotalAmounts(var TempIRS1099FormDocHeader: Record "IRS 1099 Form Doc. Header" temporary; var TotalAmounts: Dictionary of [Text, Decimal]) var DummyTotalReportedAmt: Decimal; diff --git a/Apps/US/IRSForms/app/src/IRIS/HelperIRIS.Codeunit.al b/Apps/US/IRSForms/app/src/IRIS/HelperIRIS.Codeunit.al index eafc94c70b..931b6d9cda 100644 --- a/Apps/US/IRSForms/app/src/IRIS/HelperIRIS.Codeunit.al +++ b/Apps/US/IRSForms/app/src/IRIS/HelperIRIS.Codeunit.al @@ -5,6 +5,7 @@ namespace Microsoft.Finance.VAT.Reporting; using Microsoft.Foundation.Address; +using Microsoft.Purchases.Vendor; using System.Reflection; using System.Utilities; using System.Xml; @@ -561,6 +562,22 @@ codeunit 10035 "Helper IRIS" exit(TB.ToText()); end; + procedure MatchStateCode(InputText: Text; var StateCode: Text): Boolean + var + StateTypeIRIS: Enum "State Type IRIS"; + TrimmedText: Text; + StateName: Text; + begin + TrimmedText := DelChr(InputText, '<>', ' '); + foreach StateName in StateTypeIRIS.Names() do + if UpperCase(TrimmedText) = UpperCase(StateName) then begin + StateCode := StateName; + exit(true); + end; + + exit(false); + end; + procedure FormatPhoneNumber(InputText: Text): Text var TB: TextBuilder; @@ -893,6 +910,24 @@ codeunit 10035 "Helper IRIS" end; end; + procedure GetVendorBankAccountNo(var Vendor: Record Vendor) BankAccountNo: Text + var + VendorBankAccount: Record "Vendor Bank Account"; + begin + if Vendor."Preferred Bank Account Code" <> '' then + if VendorBankAccount.Get(Vendor."No.", Vendor."Preferred Bank Account Code") then + BankAccountNo := VendorBankAccount.GetBankAccountNo(); + + BankAccountNo := FormatText(BankAccountNo); + if StrLen(BankAccountNo) > GetRecipientBankAccountNoMaxLength() then // RecipientAccountNum is optional, but cannot exceed 30 chars + BankAccountNo := ''; + end; + + local procedure GetRecipientBankAccountNoMaxLength(): Integer + begin + exit(30); + end; + [IntegrationEvent(false, false)] local procedure OnAfterGetFormBoxAmountXmlElementNames(PeriodNo: Text; FormType: Text; var FormAmountXmlElementNames: Dictionary of [Text, Text]) begin diff --git a/Apps/US/IRSForms/app/src/IRIS/ProcessTransmissionIRIS.Codeunit.al b/Apps/US/IRSForms/app/src/IRIS/ProcessTransmissionIRIS.Codeunit.al index 3e99512977..dcc0500969 100644 --- a/Apps/US/IRSForms/app/src/IRIS/ProcessTransmissionIRIS.Codeunit.al +++ b/Apps/US/IRSForms/app/src/IRIS/ProcessTransmissionIRIS.Codeunit.al @@ -134,7 +134,7 @@ codeunit 10056 "Process Transmission IRIS" exit(((Transmission.Status = Enum::"Transmission Status IRIS"::Rejected) and not PrevSendIsCorrection) or (Transmission.Status = Enum::"Transmission Status IRIS"::"Partially Accepted") or - TransmHasRejectedSubmissions); + (TransmHasRejectedSubmissions and not PrevSendIsCorrection)); end; procedure IsSendCorrectionAllowed(var Transmission: Record "Transmission IRIS"): Boolean @@ -549,6 +549,34 @@ codeunit 10056 "Process Transmission IRIS" end; end; + procedure GetRecordErrorCount(TransmissionDocumentID: Integer; SubmissionId: Text[20]; RecordId: Text[20]): Integer + var + ErrorInformation: Record "Error Information IRIS"; + begin + if (SubmissionId = '') or (RecordId = '') then + exit(0); + + ErrorInformation.SetRange("Transmission Document ID", TransmissionDocumentID); + ErrorInformation.SetRange("Entity Type", Enum::"Entity Type IRIS"::RecordType); + ErrorInformation.SetRange("Submission ID", SubmissionId); + ErrorInformation.SetRange("Record ID", RecordId); + exit(ErrorInformation.Count()); + end; + + procedure HasSubmissionLevelErrors(TransmissionDocumentID: Integer; SubmissionId: Text[20]): Boolean + var + ErrorInformation: Record "Error Information IRIS"; + begin + if SubmissionId = '' then + exit(false); + + ErrorInformation.SetRange("Transmission Document ID", TransmissionDocumentID); + ErrorInformation.SetRange("Entity Type", Enum::"Entity Type IRIS"::Submission); + ErrorInformation.SetRange("Submission ID", SubmissionId); + ErrorInformation.SetRange("Record ID", ''); + exit(not ErrorInformation.IsEmpty()); + end; + procedure ShowErrorInformation(TransmissionDocumentID: Integer; SubmissionId: Text[20]; RecordId: Text[20]) var ErrorInformation: Record "Error Information IRIS"; diff --git a/Apps/US/IRSForms/app/src/IRIS/TransmissionIRIS.Page.al b/Apps/US/IRSForms/app/src/IRIS/TransmissionIRIS.Page.al index e8a7ff14b2..17f069c871 100644 --- a/Apps/US/IRSForms/app/src/IRIS/TransmissionIRIS.Page.al +++ b/Apps/US/IRSForms/app/src/IRIS/TransmissionIRIS.Page.al @@ -5,6 +5,7 @@ namespace Microsoft.Finance.VAT.Reporting; using System.Privacy; +using System.Telemetry; using System.Utilities; page 10058 "Transmission IRIS" @@ -354,6 +355,23 @@ page 10058 "Transmission IRIS" Message(TokensRemovedMsg); end; } + action(ShowCorrectionActions) + { + Caption = 'Show Correction Actions'; + ToolTip = 'Force show correction actions regardless of the transmission status. Use this action for troubleshooting when the correction actions are hidden but should be available.'; + Image = AddAction; + Visible = false; + + trigger OnAction() + begin + if not ConfirmMgt.GetResponseOrDefault(ShowCorrectionActionsQst, false) then + exit; + + FeatureTelemetry.LogUsage('0000RNZ', Helper.GetIRISFeatureName(), ForceCorrectionActionsEventTxt); + ForceCorrectionActionsVisible := true; + SetActionsVisibility(); + end; + } } area(Promoted) { @@ -394,6 +412,8 @@ page 10058 "Transmission IRIS" ProcessTransmission: Codeunit "Process Transmission IRIS"; ProcessResponse: Codeunit "Process Response IRIS"; ConfirmMgt: Codeunit "Confirm Management"; + FeatureTelemetry: Codeunit "Feature Telemetry"; + Helper: Codeunit "Helper IRIS"; StatusStyle: Text; ErrorInfoCaption: Text; TestModeText: Text; @@ -402,6 +422,7 @@ page 10058 "Transmission IRIS" SendOriginalActionVisible: Boolean; SendReplacementActionVisible: Boolean; SendCorrectionActionVisible: Boolean; + ForceCorrectionActionsVisible: Boolean; SendTransmissionQst: Label 'Do you want to send the transmission to the IRS?'; SendReplacementTransmissionQst: Label 'Do you want to send the replacement transmission to the IRS?'; SendCorrectionTransmissionQst: Label 'Do you want to send the correction transmission to the IRS?'; @@ -410,6 +431,8 @@ page 10058 "Transmission IRIS" SendingCorrectionMsg: Label 'Sending correction transmission to the IRS...'; RequestingStatusMsg: Label 'Requesting transmission status...'; TokensRemovedMsg: Label 'The IRIS auth tokens were removed from the user storage.'; + ShowCorrectionActionsQst: Label 'The standard correction conditions are not met. Do you want to force show the correction actions for troubleshooting purposes?'; + ForceCorrectionActionsEventTxt: Label 'ForceCorrectionActionsEnabled', Locked = true; TwoStepCorrectionHelpMsg: Label 'Use the two-step correction process if incorrect form type was previously filed, e.g., 1099-MISC instead of 1099-NEC. \\Step 1: Submit zero amounts correction. \Step 2.1: After the transmission is accepted, use the action Update Transmission to add the corrected 1099 form documents. \Step 2.2: Send the updated transmission to the IRS.'; FirstStepCompletedMsg: Label 'The correction transmission with zero amounts was sent to the IRS. After the transmission is accepted, use the action Update Transmission to add the corrected 1099 form documents and then send the updated transmission to the IRS.'; ConfirmAssignReceiptIDQst: Label 'Are you sure you want to assign the Receipt ID to the transmission manually?'; @@ -432,7 +455,7 @@ page 10058 "Transmission IRIS" begin SendOriginalActionVisible := ProcessTransmission.IsSendOriginalAllowed(Rec); SendReplacementActionVisible := ProcessTransmission.IsSendReplacementAllowed(Rec); - SendCorrectionActionVisible := ProcessTransmission.IsSendCorrectionAllowed(Rec); + SendCorrectionActionVisible := ProcessTransmission.IsSendCorrectionAllowed(Rec) or ForceCorrectionActionsVisible; end; local procedure SetErrorInfoField() diff --git a/Apps/US/IRSForms/app/src/IRIS/TransmissionIRISSubform.Page.al b/Apps/US/IRSForms/app/src/IRIS/TransmissionIRISSubform.Page.al index 346f2bdb27..9a3a8fba59 100644 --- a/Apps/US/IRSForms/app/src/IRIS/TransmissionIRISSubform.Page.al +++ b/Apps/US/IRSForms/app/src/IRIS/TransmissionIRISSubform.Page.al @@ -80,6 +80,14 @@ page 10059 "Transmission IRIS Subform" ProcessTransmission.ShowErrorInformation(Rec."IRIS Transmission Document ID", Rec."IRIS Submission ID", Rec."IRIS Record ID"); end; } + field("Record Errors"; RecordErrorCount) + { + Caption = 'Record Errors'; + ToolTip = 'Specifies the number of errors returned by IRS for this specific record. Drill down on IRIS Submission Status to see error details.'; + Editable = false; + BlankZero = true; + StyleExpr = RecordErrorsStyle; + } field("IRIS Corrected"; Format(Rec."IRIS Corrected")) { Caption = 'Corrected'; @@ -103,8 +111,10 @@ page 10059 "Transmission IRIS Subform" ProcessTransmission: Codeunit "Process Transmission IRIS"; DocStatusStyle: Text; SubmStatusStyle: Text; + RecordErrorsStyle: Text; CorrectedStyle: Text; NeedsCorrectionEditable: Boolean; + RecordErrorCount: Integer; local procedure SetDocStatusStyle() begin @@ -118,13 +128,18 @@ page 10059 "Transmission IRIS Subform" end; local procedure SetSubmStatusStyle() - var - ErrorInformation: Record "Error Information IRIS"; begin SubmStatusStyle := ''; - ProcessTransmission.FilterErrorInformation(ErrorInformation, Rec."IRIS Transmission Document ID", Rec."IRIS Submission ID", Rec."IRIS Record ID"); - if not ErrorInformation.IsEmpty() then + RecordErrorsStyle := ''; + + if ProcessTransmission.HasSubmissionLevelErrors(Rec."IRIS Transmission Document ID", Rec."IRIS Submission ID") then + SubmStatusStyle := 'Ambiguous'; + + RecordErrorCount := ProcessTransmission.GetRecordErrorCount(Rec."IRIS Transmission Document ID", Rec."IRIS Submission ID", Rec."IRIS Record ID"); + if RecordErrorCount > 0 then begin SubmStatusStyle := 'Attention'; + RecordErrorsStyle := 'Unfavorable'; + end; end; local procedure SetCorrectedStyle() diff --git a/Apps/US/IRSForms/test library/src/LibraryIRS1099IRIS.Codeunit.al b/Apps/US/IRSForms/test library/src/LibraryIRS1099IRIS.Codeunit.al index 9f901c5a84..637ad18dad 100644 --- a/Apps/US/IRSForms/test library/src/LibraryIRS1099IRIS.Codeunit.al +++ b/Apps/US/IRSForms/test library/src/LibraryIRS1099IRIS.Codeunit.al @@ -16,6 +16,9 @@ codeunit 148023 "Library - IRS 1099 IRIS" LibraryPurchase: Codeunit "Library - Purchase"; LibraryUtility: Codeunit "Library - Utility"; LibraryERM: Codeunit "Library - ERM"; + SavedIRISUserIDKey: Guid; + IRISUserIDSaved: Boolean; + TINSequenceNameLbl: Label 'TestUniqueTIN', Locked = true; #region Company procedure InitializeCompanyInformation() @@ -30,9 +33,11 @@ codeunit 148023 "Library - IRS 1099 IRIS" PostCode.Insert(); CompanyInformation.Get(); CompanyInformation.Name := LibraryUtility.GenerateGUID(); - CompanyInformation."Federal ID No." := '00-0123456'; + CompanyInformation."Federal ID No." := GetUniqueTIN(); CompanyInformation.Validate("Post Code", PostCode.Code); CompanyInformation.Address := '6201 Roosevelt Rd'; + CompanyInformation."Contact Person" := 'John Doe Jr.'; + CompanyInformation."Phone No." := LibraryUtility.GenerateRandomPhoneNo(); CompanyInformation.Modify(); end; @@ -87,6 +92,14 @@ codeunit 148023 "Library - IRS 1099 IRIS" CreateVendor(Vendor, 'US', 'IL'); end; + procedure CreateUSVendorWithBankAccount(var Vendor: Record Vendor; BankAccountNo: Code[30]) + var + VendorBankAccount: Record "Vendor Bank Account"; + begin + CreateUSVendor(Vendor); + CreateVendorBankAccount(VendorBankAccount, Vendor."No.", BankAccountNo); + end; + procedure CreateVendor(var Vendor: Record Vendor; CountryRegionCode: Code[10]; ProvinceOrStateName: Text[30]) var PostCode: Record "Post Code"; @@ -100,12 +113,78 @@ codeunit 148023 "Library - IRS 1099 IRIS" LibraryERM.CreatePaymentMethodWithBalAccount(PaymentMethod); + Vendor.SetLoadFields("Federal ID No.", "Post Code", "Address", "Payment Method Code"); Vendor.Get(LibraryPurchase.CreateVendorNo()); - Vendor."Federal ID No." := '00-0654321'; + Vendor."Federal ID No." := GetUniqueTIN(); Vendor.Validate("Post Code", PostCode.Code); Vendor.Validate(Address, LibraryUtility.GenerateGUID()); Vendor.Validate("Payment Method Code", PaymentMethod.Code); // CASH payment method Vendor.Modify(); end; + + procedure CreateVendorBankAccount(var VendorBankAccount: Record "Vendor Bank Account"; VendorNo: Code[20]; BankAccountNo: Code[30]) + var + Vendor: Record Vendor; + begin + VendorBankAccount.Init(); + VendorBankAccount.Validate("Vendor No.", VendorNo); + VendorBankAccount.Validate(Code, LibraryUtility.GenerateGUID()); + VendorBankAccount.Validate("Bank Account No.", BankAccountNo); + VendorBankAccount.Insert(true); + + Vendor.SetLoadFields("Preferred Bank Account Code"); + Vendor.Get(VendorNo); + Vendor."Preferred Bank Account Code" := VendorBankAccount.Code; + Vendor.Modify(); + end; #endregion Vendor + + procedure SaveIRISUserID() + var + UserParamsIRIS: Record "User Params IRIS"; + begin + UserParamsIRIS.GetRecord(); + SavedIRISUserIDKey := UserParamsIRIS."IRIS User ID Key"; + IRISUserIDSaved := not IsNullGuid(SavedIRISUserIDKey); + end; + + procedure RestoreIRISUserID() + var + UserParamsIRIS: Record "User Params IRIS"; + begin + if not IRISUserIDSaved then + exit; + UserParamsIRIS.GetRecord(); + UserParamsIRIS."IRIS User ID Key" := SavedIRISUserIDKey; + UserParamsIRIS.Modify(); + end; + + [NonDebuggable] + procedure InitializeIRISUserID() + var + UserParamsIRIS: Record "User Params IRIS"; + OAuthClient: Codeunit "OAuth Client IRIS"; + NewTokenKey: Guid; + IRISUserID: Text; + IRISUserIDSecret: SecretText; + begin + IRISUserID := 'test-user-id'; + IRISUserIDSecret := IRISUserID; + OAuthClient.SetToken(NewTokenKey, IRISUserIDSecret); + UserParamsIRIS.GetRecord(); + UserParamsIRIS."IRIS User ID Key" := NewTokenKey; + UserParamsIRIS.Modify(); + end; + + procedure GetUniqueTIN(): Text[30] + var + SeqNo: Integer; + SeqNoText: Text; + begin + if not NumberSequence.Exists(TINSequenceNameLbl) then + NumberSequence.Insert(TINSequenceNameLbl, 0, 1, true); + SeqNo := NumberSequence.Next(TINSequenceNameLbl); + SeqNoText := Format(SeqNo); + exit('00-09' + PadStr('', 5 - StrLen(SeqNoText), '0') + SeqNoText); + end; } diff --git a/Apps/US/IRSForms/test/src/IRS1099DocumentTests.Codeunit.al b/Apps/US/IRSForms/test/src/IRS1099DocumentTests.Codeunit.al index 110d8f2721..e319e33b25 100644 --- a/Apps/US/IRSForms/test/src/IRS1099DocumentTests.Codeunit.al +++ b/Apps/US/IRSForms/test/src/IRS1099DocumentTests.Codeunit.al @@ -1131,6 +1131,168 @@ codeunit 148010 "IRS 1099 Document Tests" DeleteDocuments(); end; + [Test] + procedure FormDocLineIncludeIn1099TrueWhenAmountEqualsMinimum() + var + IRS1099FormDocHeader: Record "IRS 1099 Form Doc. Header"; + IRS1099FormDocLine: Record "IRS 1099 Form Doc. Line"; + IRS1099FormBox: Record "IRS 1099 Form Box"; + PeriodNo: Code[20]; + FormNo: Code[20]; + FormBoxNo: Code[20]; + VendNo: Code[20]; + MinimumReportableAmount: Decimal; + begin + // [FEATURE] [AI test] + // [SCENARIO 620524] "Include In 1099" is TRUE when Amount equals "Minimum Reportable Amount" + Initialize(); + MinimumReportableAmount := 600; + + // [GIVEN] IRS Reporting Period with Form "F" and Form Box "FB" having "Minimum Reportable Amount" = 600 + PeriodNo := LibraryIRSReportingPeriod.CreateOneDayReportingPeriod(WorkDate()); + FormNo := LibraryIRS1099FormBox.CreateSingleFormInReportingPeriod(WorkDate()); + FormBoxNo := LibraryIRS1099FormBox.CreateSingleFormBoxInReportingPeriod(WorkDate(), FormNo); + IRS1099FormBox.Get(PeriodNo, FormNo, FormBoxNo); + IRS1099FormBox.Validate("Minimum Reportable Amount", MinimumReportableAmount); + IRS1099FormBox.Modify(true); + + // [GIVEN] Vendor "V" with form box "FB" + VendNo := LibraryIRS1099FormBox.CreateVendorNoWithFormBox(WorkDate(), FormNo, FormBoxNo); + + // [GIVEN] Open form document for vendor "V" + IRS1099FormDocHeader.Validate("Period No.", PeriodNo); + IRS1099FormDocHeader.Validate("Vendor No.", VendNo); + IRS1099FormDocHeader.Validate("Form No.", FormNo); + IRS1099FormDocHeader.Insert(true); + + // [GIVEN] Form document line with "Minimum Reportable Amount" = 600 + IRS1099FormDocLine."Document ID" := IRS1099FormDocHeader.ID; + IRS1099FormDocLine."Period No." := PeriodNo; + IRS1099FormDocLine."Vendor No." := VendNo; + IRS1099FormDocLine."Form No." := FormNo; + IRS1099FormDocLine."Line No." := 10000; + IRS1099FormDocLine."Form Box No." := FormBoxNo; + IRS1099FormDocLine."Minimum Reportable Amount" := MinimumReportableAmount; + IRS1099FormDocLine.Insert(); + + // [WHEN] Validate Amount to exactly equal the Minimum Reportable Amount + IRS1099FormDocLine.Validate(Amount, MinimumReportableAmount); + + // [THEN] "Include In 1099" is TRUE + Assert.IsTrue( + IRS1099FormDocLine."Include In 1099", + 'Include In 1099 should be TRUE when Amount equals Minimum Reportable Amount'); + IRS1099FormDocHeader.Delete(true); + end; + + [Test] + procedure FormDocLineIncludeIn1099TrueWhenAmountAboveMinimum() + var + IRS1099FormDocHeader: Record "IRS 1099 Form Doc. Header"; + IRS1099FormDocLine: Record "IRS 1099 Form Doc. Line"; + IRS1099FormBox: Record "IRS 1099 Form Box"; + PeriodNo: Code[20]; + FormNo: Code[20]; + FormBoxNo: Code[20]; + VendNo: Code[20]; + MinimumReportableAmount: Decimal; + begin + // [FEATURE] [AI test] + // [SCENARIO 620524] "Include In 1099" is TRUE when Amount is above "Minimum Reportable Amount" + Initialize(); + MinimumReportableAmount := 600; + + // [GIVEN] IRS Reporting Period with Form "F" and Form Box "FB" having "Minimum Reportable Amount" = 600 + PeriodNo := LibraryIRSReportingPeriod.CreateOneDayReportingPeriod(WorkDate()); + FormNo := LibraryIRS1099FormBox.CreateSingleFormInReportingPeriod(WorkDate()); + FormBoxNo := LibraryIRS1099FormBox.CreateSingleFormBoxInReportingPeriod(WorkDate(), FormNo); + IRS1099FormBox.Get(PeriodNo, FormNo, FormBoxNo); + IRS1099FormBox.Validate("Minimum Reportable Amount", MinimumReportableAmount); + IRS1099FormBox.Modify(true); + + // [GIVEN] Vendor "V" with form box "FB" + VendNo := LibraryIRS1099FormBox.CreateVendorNoWithFormBox(WorkDate(), FormNo, FormBoxNo); + + // [GIVEN] Open form document for vendor "V" + IRS1099FormDocHeader.Validate("Period No.", PeriodNo); + IRS1099FormDocHeader.Validate("Vendor No.", VendNo); + IRS1099FormDocHeader.Validate("Form No.", FormNo); + IRS1099FormDocHeader.Insert(true); + + // [GIVEN] Form document line with "Minimum Reportable Amount" = 600 + IRS1099FormDocLine."Document ID" := IRS1099FormDocHeader.ID; + IRS1099FormDocLine."Period No." := PeriodNo; + IRS1099FormDocLine."Vendor No." := VendNo; + IRS1099FormDocLine."Form No." := FormNo; + IRS1099FormDocLine."Line No." := 10000; + IRS1099FormDocLine."Form Box No." := FormBoxNo; + IRS1099FormDocLine."Minimum Reportable Amount" := MinimumReportableAmount; + IRS1099FormDocLine.Insert(); + + // [WHEN] Validate Amount to be above the Minimum Reportable Amount + IRS1099FormDocLine.Validate(Amount, MinimumReportableAmount + 100); + + // [THEN] "Include In 1099" is TRUE + Assert.IsTrue( + IRS1099FormDocLine."Include In 1099", + 'Include In 1099 should be TRUE when Amount is above Minimum Reportable Amount'); + IRS1099FormDocHeader.Delete(true); + end; + + [Test] + procedure FormDocLineIncludeIn1099FalseWhenAmountBelowMinimumUT() + var + IRS1099FormDocHeader: Record "IRS 1099 Form Doc. Header"; + IRS1099FormDocLine: Record "IRS 1099 Form Doc. Line"; + IRS1099FormBox: Record "IRS 1099 Form Box"; + PeriodNo: Code[20]; + FormNo: Code[20]; + FormBoxNo: Code[20]; + VendNo: Code[20]; + MinimumReportableAmount: Decimal; + begin + // [FEATURE] [AI test] + // [SCENARIO 620524] "Include In 1099" is FALSE when Amount is below "Minimum Reportable Amount" + Initialize(); + MinimumReportableAmount := 600; + + // [GIVEN] IRS Reporting Period with Form "F" and Form Box "FB" having "Minimum Reportable Amount" = 600 + PeriodNo := LibraryIRSReportingPeriod.CreateOneDayReportingPeriod(WorkDate()); + FormNo := LibraryIRS1099FormBox.CreateSingleFormInReportingPeriod(WorkDate()); + FormBoxNo := LibraryIRS1099FormBox.CreateSingleFormBoxInReportingPeriod(WorkDate(), FormNo); + IRS1099FormBox.Get(PeriodNo, FormNo, FormBoxNo); + IRS1099FormBox.Validate("Minimum Reportable Amount", MinimumReportableAmount); + IRS1099FormBox.Modify(true); + + // [GIVEN] Vendor "V" with form box "FB" + VendNo := LibraryIRS1099FormBox.CreateVendorNoWithFormBox(WorkDate(), FormNo, FormBoxNo); + + // [GIVEN] Open form document for vendor "V" + IRS1099FormDocHeader.Validate("Period No.", PeriodNo); + IRS1099FormDocHeader.Validate("Vendor No.", VendNo); + IRS1099FormDocHeader.Validate("Form No.", FormNo); + IRS1099FormDocHeader.Insert(true); + + // [GIVEN] Form document line with "Minimum Reportable Amount" = 600 + IRS1099FormDocLine."Document ID" := IRS1099FormDocHeader.ID; + IRS1099FormDocLine."Period No." := PeriodNo; + IRS1099FormDocLine."Vendor No." := VendNo; + IRS1099FormDocLine."Form No." := FormNo; + IRS1099FormDocLine."Line No." := 10000; + IRS1099FormDocLine."Form Box No." := FormBoxNo; + IRS1099FormDocLine."Minimum Reportable Amount" := MinimumReportableAmount; + IRS1099FormDocLine.Insert(); + + // [WHEN] Validate Amount to be below the Minimum Reportable Amount + IRS1099FormDocLine.Validate(Amount, MinimumReportableAmount - 100); + + // [THEN] "Include In 1099" is FALSE + Assert.IsFalse( + IRS1099FormDocLine."Include In 1099", + 'Include In 1099 should be FALSE when Amount is below Minimum Reportable Amount'); + IRS1099FormDocHeader.Delete(true); + end; + local procedure Initialize() var IRSReportingPeriod: Record "IRS Reporting Period"; diff --git a/Apps/US/IRSForms/test/src/IRS1099FormCalcTests.Codeunit.al b/Apps/US/IRSForms/test/src/IRS1099FormCalcTests.Codeunit.al index 6cf7441de1..b3ea603f86 100644 --- a/Apps/US/IRSForms/test/src/IRS1099FormCalcTests.Codeunit.al +++ b/Apps/US/IRSForms/test/src/IRS1099FormCalcTests.Codeunit.al @@ -544,6 +544,262 @@ codeunit 148014 "IRS 1099 Form Calc. Tests" IRSReportingPeriod.DeleteAll(true); end; + [Test] + procedure MultipleVendorsDifferentFormBoxes() + var + PurchaseHeader: Record "Purchase Header"; + PurchaseLine: Record "Purchase Line"; + VendorLedgerEntry: array[2] of Record "Vendor Ledger Entry"; + TempVendFormBoxBuffer: Record "IRS 1099 Vend. Form Box Buffer" temporary; + PeriodNo: Code[20]; + FormNo: array[2] of Code[20]; + FormBoxNo: array[2] of Code[20]; + VendNo: array[2] of Code[20]; + PostingDate: Date; + i: Integer; + begin + // [FEATURE] [AI test 0.3] + // [SCENARIO 597565] Multiple vendors with different form boxes are all calculated correctly + Initialize(); + PostingDate := LibraryIRSReportingPeriod.GetPostingDate(); + + // [GIVEN] IRS Reporting Period "X" with one day + PeriodNo := LibraryIRSReportingPeriod.CreateOneDayReportingPeriod(PostingDate); + + // [GIVEN] Form DIV with box DIV-01-A + FormNo[1] := LibraryIRS1099FormBox.CreateSingleFormInReportingPeriod(PostingDate); + FormBoxNo[1] := LibraryIRS1099FormBox.CreateSingleFormBoxInReportingPeriod(PostingDate, FormNo[1]); + + // [GIVEN] Form MISC with box MISC-01 + FormNo[2] := LibraryIRS1099FormBox.CreateSingleFormInReportingPeriod(PostingDate); + FormBoxNo[2] := LibraryIRS1099FormBox.CreateSingleFormBoxInReportingPeriod(PostingDate, FormNo[2]); + + // [GIVEN] Vendor "A" with DIV-01-A form box + VendNo[1] := LibraryIRS1099FormBox.CreateVendorNoWithFormBox(PostingDate, FormNo[1], FormBoxNo[1]); + + // [GIVEN] Vendor "B" with MISC-01 form box + VendNo[2] := LibraryIRS1099FormBox.CreateVendorNoWithFormBox(PostingDate, FormNo[2], FormBoxNo[2]); + + // [GIVEN] Purchase invoice is posted for Vendor "A" with DIV-01-A + // [GIVEN] Purchase invoice is posted for Vendor "B" with MISC-01 + for i := 1 to 2 do begin + LibraryPurchase.CreatePurchHeader(PurchaseHeader, PurchaseHeader."Document Type"::Invoice, VendNo[i]); + PurchaseHeader.Validate("Posting Date", PostingDate); + LibraryPurchase.CreatePurchaseLineWithUnitCost( + PurchaseLine, PurchaseHeader, LibraryInventory.CreateItemNo(), + LibraryRandom.RandInt(100), LibraryRandom.RandDec(100, 2)); + LibraryERM.FindVendorLedgerEntry( + VendorLedgerEntry[i], VendorLedgerEntry[i]."Document Type"::Invoice, + LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true)); + VendorLedgerEntry[i].CalcFields(Amount); + + // [GIVEN] Payment is posted and applied to the invoice + LibraryIRS1099Document.PostPaymentAppliedToInvoice(PostingDate, VendNo[i], VendorLedgerEntry[i]."Document No.", -VendorLedgerEntry[i].Amount); + end; + + // [WHEN] Calculate form boxes for all vendors + LibraryIRS1099FormBox.GetVendorFormBoxAmount(TempVendFormBoxBuffer, PeriodNo, '', ''); + + // [THEN] Two form box records are created, one for each vendor + TempVendFormBoxBuffer.Reset(); + TempVendFormBoxBuffer.SetRange("Buffer Type", TempVendFormBoxBuffer."Buffer Type"::Amount); + Assert.RecordCount(TempVendFormBoxBuffer, 2); + + // [THEN] Vendor "A" has correct amount for DIV-01-A + TempVendFormBoxBuffer.SetRange("Vendor No.", VendNo[1]); + TempVendFormBoxBuffer.FindFirst(); + LibraryIRS1099FormBox.VerifyCurrTempVendFormBoxBufferIncludedIn1099( + TempVendFormBoxBuffer, PeriodNo, FormNo[1], FormBoxNo[1], VendNo[1], -VendorLedgerEntry[1].Amount); + + // [THEN] Vendor "B" has correct amount for MISC-01 + TempVendFormBoxBuffer.SetRange("Vendor No.", VendNo[2]); + TempVendFormBoxBuffer.FindFirst(); + LibraryIRS1099FormBox.VerifyCurrTempVendFormBoxBufferIncludedIn1099( + TempVendFormBoxBuffer, PeriodNo, FormNo[2], FormBoxNo[2], VendNo[2], -VendorLedgerEntry[2].Amount); + end; + + [Test] + procedure VendorWithMultipleFormBoxesAndOtherVendor() + var + PurchaseHeader: Record "Purchase Header"; + PurchaseLine: Record "Purchase Line"; + VendorLedgerEntry: array[3] of Record "Vendor Ledger Entry"; + TempVendFormBoxBuffer: Record "IRS 1099 Vend. Form Box Buffer" temporary; + PeriodNo: Code[20]; + FormNo: array[2] of Code[20]; + FormBoxNo: array[3] of Code[20]; + VendNo: array[2] of Code[20]; + PostingDate: Date; + begin + // [FEATURE] [AI test 0.3] + // [SCENARIO 597565] Vendor with multiple form boxes (one different from default) alongside another vendor - both are processed + Initialize(); + PostingDate := LibraryIRSReportingPeriod.GetPostingDate(); + + // [GIVEN] IRS Reporting Period "X" + PeriodNo := LibraryIRSReportingPeriod.CreateOneDayReportingPeriod(PostingDate); + + // [GIVEN] Form DIV with boxes DIV-01-A and DIV-01-B + FormNo[1] := LibraryIRS1099FormBox.CreateSingleFormInReportingPeriod(PostingDate); + FormBoxNo[1] := LibraryIRS1099FormBox.CreateSingleFormBoxInReportingPeriod(PostingDate, FormNo[1]); + FormBoxNo[2] := LibraryIRS1099FormBox.CreateSingleFormBoxInReportingPeriod(PostingDate, FormNo[1]); + + // [GIVEN] Form MISC with box MISC-01 + FormNo[2] := LibraryIRS1099FormBox.CreateSingleFormInReportingPeriod(PostingDate); + FormBoxNo[3] := LibraryIRS1099FormBox.CreateSingleFormBoxInReportingPeriod(PostingDate, FormNo[2]); + + // [GIVEN] Vendor "A" with default form box DIV-01-A + VendNo[1] := LibraryIRS1099FormBox.CreateVendorNoWithFormBox(PostingDate, FormNo[1], FormBoxNo[1]); + + // [GIVEN] Vendor "B" with default form box MISC-01 + VendNo[2] := LibraryIRS1099FormBox.CreateVendorNoWithFormBox(PostingDate, FormNo[2], FormBoxNo[3]); + + // [GIVEN] Invoice for Vendor "A" with DIV-01-A (default) + LibraryPurchase.CreatePurchHeader(PurchaseHeader, PurchaseHeader."Document Type"::Invoice, VendNo[1]); + PurchaseHeader.Validate("Posting Date", PostingDate); + LibraryPurchase.CreatePurchaseLineWithUnitCost( + PurchaseLine, PurchaseHeader, LibraryInventory.CreateItemNo(), + LibraryRandom.RandInt(100), LibraryRandom.RandDec(100, 2)); + LibraryERM.FindVendorLedgerEntry( + VendorLedgerEntry[1], VendorLedgerEntry[1]."Document Type"::Invoice, + LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true)); + VendorLedgerEntry[1].CalcFields(Amount); + LibraryIRS1099Document.PostPaymentAppliedToInvoice(PostingDate, VendNo[1], VendorLedgerEntry[1]."Document No.", -VendorLedgerEntry[1].Amount); + + // [GIVEN] Invoice for Vendor "A" with DIV-01-B (different from default) + LibraryPurchase.CreatePurchHeader(PurchaseHeader, PurchaseHeader."Document Type"::Invoice, VendNo[1]); + PurchaseHeader.Validate("Posting Date", PostingDate); + PurchaseHeader.Validate("IRS 1099 Reporting Period", LibraryIRSReportingPeriod.GetReportingPeriod(PostingDate)); + PurchaseHeader.Validate("IRS 1099 Form No.", FormNo[1]); + PurchaseHeader.Validate("IRS 1099 Form Box No.", FormBoxNo[2]); + PurchaseHeader.Modify(true); + LibraryPurchase.CreatePurchaseLineWithUnitCost( + PurchaseLine, PurchaseHeader, LibraryInventory.CreateItemNo(), + LibraryRandom.RandInt(100), LibraryRandom.RandDec(100, 2)); + LibraryERM.FindVendorLedgerEntry( + VendorLedgerEntry[2], VendorLedgerEntry[2]."Document Type"::Invoice, + LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true)); + VendorLedgerEntry[2].CalcFields(Amount); + LibraryIRS1099Document.PostPaymentAppliedToInvoice(PostingDate, VendNo[1], VendorLedgerEntry[2]."Document No.", -VendorLedgerEntry[2].Amount); + + // [GIVEN] Invoice for Vendor "B" with MISC-01 + LibraryPurchase.CreatePurchHeader(PurchaseHeader, PurchaseHeader."Document Type"::Invoice, VendNo[2]); + PurchaseHeader.Validate("Posting Date", PostingDate); + LibraryPurchase.CreatePurchaseLineWithUnitCost( + PurchaseLine, PurchaseHeader, LibraryInventory.CreateItemNo(), + LibraryRandom.RandInt(100), LibraryRandom.RandDec(100, 2)); + LibraryERM.FindVendorLedgerEntry( + VendorLedgerEntry[3], VendorLedgerEntry[3]."Document Type"::Invoice, + LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true)); + VendorLedgerEntry[3].CalcFields(Amount); + LibraryIRS1099Document.PostPaymentAppliedToInvoice(PostingDate, VendNo[2], VendorLedgerEntry[3]."Document No.", -VendorLedgerEntry[3].Amount); + + // [WHEN] Calculate form boxes for all vendors + LibraryIRS1099FormBox.GetVendorFormBoxAmount(TempVendFormBoxBuffer, PeriodNo, '', ''); + + // [THEN] Three form box records are created + TempVendFormBoxBuffer.Reset(); + TempVendFormBoxBuffer.SetRange("Buffer Type", TempVendFormBoxBuffer."Buffer Type"::Amount); + Assert.RecordCount(TempVendFormBoxBuffer, 3); + + // [THEN] Vendor "A" has two records: one for DIV-01-A, one for DIV-01-B + TempVendFormBoxBuffer.SetRange("Vendor No.", VendNo[1]); + Assert.RecordCount(TempVendFormBoxBuffer, 2); + TempVendFormBoxBuffer.SetRange("Form Box No.", FormBoxNo[1]); + TempVendFormBoxBuffer.FindFirst(); + LibraryIRS1099FormBox.VerifyCurrTempVendFormBoxBufferIncludedIn1099( + TempVendFormBoxBuffer, PeriodNo, FormNo[1], FormBoxNo[1], VendNo[1], -VendorLedgerEntry[1].Amount); + TempVendFormBoxBuffer.SetRange("Form Box No.", FormBoxNo[2]); + TempVendFormBoxBuffer.FindFirst(); + LibraryIRS1099FormBox.VerifyCurrTempVendFormBoxBufferIncludedIn1099( + TempVendFormBoxBuffer, PeriodNo, FormNo[1], FormBoxNo[2], VendNo[1], -VendorLedgerEntry[2].Amount); + + // [THEN] Vendor "B" has one record for MISC-01 + TempVendFormBoxBuffer.SetRange("Vendor No.", VendNo[2]); + TempVendFormBoxBuffer.SetRange("Form Box No.", FormBoxNo[3]); + TempVendFormBoxBuffer.FindFirst(); + LibraryIRS1099FormBox.VerifyCurrTempVendFormBoxBufferIncludedIn1099( + TempVendFormBoxBuffer, PeriodNo, FormNo[2], FormBoxNo[3], VendNo[2], -VendorLedgerEntry[3].Amount); + end; + + [Test] + procedure SingleVendorMultipleFormBoxesDifferentFromDefault() + var + PurchaseHeader: Record "Purchase Header"; + PurchaseLine: Record "Purchase Line"; + VendorLedgerEntry: array[2] of Record "Vendor Ledger Entry"; + TempVendFormBoxBuffer: Record "IRS 1099 Vend. Form Box Buffer" temporary; + PeriodNo: Code[20]; + FormNo: Code[20]; + FormBoxNo: array[2] of Code[20]; + VendNo: Code[20]; + PostingDate: Date; + begin + // [FEATURE] [AI test 0.3] + // [SCENARIO 597565] Single vendor with multiple form boxes including one different from default + Initialize(); + PostingDate := LibraryIRSReportingPeriod.GetPostingDate(); + + // [GIVEN] IRS Reporting Period "X" + PeriodNo := LibraryIRSReportingPeriod.CreateOneDayReportingPeriod(PostingDate); + + // [GIVEN] Form DIV with boxes DIV-01-A and DIV-01-B + FormNo := LibraryIRS1099FormBox.CreateSingleFormInReportingPeriod(PostingDate); + FormBoxNo[1] := LibraryIRS1099FormBox.CreateSingleFormBoxInReportingPeriod(PostingDate, FormNo); + FormBoxNo[2] := LibraryIRS1099FormBox.CreateSingleFormBoxInReportingPeriod(PostingDate, FormNo); + + // [GIVEN] Vendor "A" with default form box DIV-01-A + VendNo := LibraryIRS1099FormBox.CreateVendorNoWithFormBox(PostingDate, FormNo, FormBoxNo[1]); + + // [GIVEN] Invoice for Vendor "A" with DIV-01-A (default) + LibraryPurchase.CreatePurchHeader(PurchaseHeader, PurchaseHeader."Document Type"::Invoice, VendNo); + PurchaseHeader.Validate("Posting Date", PostingDate); + LibraryPurchase.CreatePurchaseLineWithUnitCost( + PurchaseLine, PurchaseHeader, LibraryInventory.CreateItemNo(), + LibraryRandom.RandInt(100), LibraryRandom.RandDec(100, 2)); + LibraryERM.FindVendorLedgerEntry( + VendorLedgerEntry[1], VendorLedgerEntry[1]."Document Type"::Invoice, + LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true)); + VendorLedgerEntry[1].CalcFields(Amount); + LibraryIRS1099Document.PostPaymentAppliedToInvoice(PostingDate, VendNo, VendorLedgerEntry[1]."Document No.", -VendorLedgerEntry[1].Amount); + + // [GIVEN] Invoice for Vendor "A" with DIV-01-B (different from default) + LibraryPurchase.CreatePurchHeader(PurchaseHeader, PurchaseHeader."Document Type"::Invoice, VendNo); + PurchaseHeader.Validate("Posting Date", PostingDate); + PurchaseHeader.Validate("IRS 1099 Reporting Period", LibraryIRSReportingPeriod.GetReportingPeriod(PostingDate)); + PurchaseHeader.Validate("IRS 1099 Form No.", FormNo); + PurchaseHeader.Validate("IRS 1099 Form Box No.", FormBoxNo[2]); + PurchaseHeader.Modify(true); + LibraryPurchase.CreatePurchaseLineWithUnitCost( + PurchaseLine, PurchaseHeader, LibraryInventory.CreateItemNo(), + LibraryRandom.RandInt(100), LibraryRandom.RandDec(100, 2)); + LibraryERM.FindVendorLedgerEntry( + VendorLedgerEntry[2], VendorLedgerEntry[2]."Document Type"::Invoice, + LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true)); + VendorLedgerEntry[2].CalcFields(Amount); + LibraryIRS1099Document.PostPaymentAppliedToInvoice(PostingDate, VendNo, VendorLedgerEntry[2]."Document No.", -VendorLedgerEntry[2].Amount); + + // [WHEN] Calculate form boxes for the vendor + LibraryIRS1099FormBox.GetVendorFormBoxAmount(TempVendFormBoxBuffer, PeriodNo, FormNo, VendNo); + + // [THEN] Two form box records are created for the vendor + TempVendFormBoxBuffer.Reset(); + TempVendFormBoxBuffer.SetRange("Buffer Type", TempVendFormBoxBuffer."Buffer Type"::Amount); + Assert.RecordCount(TempVendFormBoxBuffer, 2); + + // [THEN] First record is for DIV-01-A with correct amount + TempVendFormBoxBuffer.SetRange("Form Box No.", FormBoxNo[1]); + TempVendFormBoxBuffer.FindFirst(); + LibraryIRS1099FormBox.VerifyCurrTempVendFormBoxBufferIncludedIn1099( + TempVendFormBoxBuffer, PeriodNo, FormNo, FormBoxNo[1], VendNo, -VendorLedgerEntry[1].Amount); + + // [THEN] Second record is for DIV-01-B with correct amount + TempVendFormBoxBuffer.SetRange("Form Box No.", FormBoxNo[2]); + TempVendFormBoxBuffer.FindFirst(); + LibraryIRS1099FormBox.VerifyCurrTempVendFormBoxBufferIncludedIn1099( + TempVendFormBoxBuffer, PeriodNo, FormNo, FormBoxNo[2], VendNo, -VendorLedgerEntry[2].Amount); + end; + local procedure Initialize() begin LibraryTestInitialize.OnTestInitialize(Codeunit::"IRS 1099 Form Calc. Tests"); diff --git a/Apps/US/IRSForms/test/src/IRS1099IRISTests.Codeunit.al b/Apps/US/IRSForms/test/src/IRS1099IRISTests.Codeunit.al index 9dc69b8067..92456a3618 100644 --- a/Apps/US/IRSForms/test/src/IRS1099IRISTests.Codeunit.al +++ b/Apps/US/IRSForms/test/src/IRS1099IRISTests.Codeunit.al @@ -7,6 +7,7 @@ namespace Microsoft.Finance.VAT.Reporting; using Microsoft.Foundation.Company; using Microsoft.Purchases.Document; using Microsoft.Purchases.Vendor; +using System.TestLibraries.Utilities; using System.Utilities; codeunit 148022 "IRS 1099 IRIS Tests" @@ -16,12 +17,14 @@ codeunit 148022 "IRS 1099 IRIS Tests" TestPermissions = Disabled; var + Assert: Codeunit Assert; LibraryIRSReportingPeriod: Codeunit "Library IRS Reporting Period"; LibraryIRS1099FormBox: Codeunit "Library IRS 1099 Form Box"; LibraryIRS1099Document: Codeunit "Library IRS 1099 Document"; LibraryIRS1099IRIS: Codeunit "Library - IRS 1099 IRIS"; LibraryTestInitialize: Codeunit "Library - Test Initialize"; LibrarySetupStorage: Codeunit "Library - Setup Storage"; + LibraryVariableStorage: Codeunit "Library - Variable Storage"; LibraryXPathXMLReader: Codeunit "Library - XPath XML Reader"; LibraryRandom: Codeunit "Library - Random"; LibraryUtility: Codeunit "Library - Utility"; @@ -89,6 +92,483 @@ codeunit 148022 "IRS 1099 IRIS Tests" LibraryXPathXMLReader.VerifyXmlNodeValue('//n1:ContactPersonInformationGrp/n1:ContactEmailAddressTxt', Email); end; + [Test] + procedure StateCodeWithLeadingAndTrailingSpacesIsTrimmed() + var + Transmission: Record "Transmission IRIS"; + IRS1099FormDocHeader: Record "IRS 1099 Form Doc. Header"; + TempIRS1099FormDocHeader: Record "IRS 1099 Form Doc. Header" temporary; + TempBlob: Codeunit "Temp Blob"; + UniqueTransmissionId: Text[100]; + begin + // [FEATURE] [AI test] + // [SCENARIO 619973] State code with leading and trailing spaces is trimmed in the XML + Initialize(); + + // [GIVEN] A vendor "V" with 1099 form document ready for transmission + CreateTransmissionWithSingleFormDoc(Transmission, IRS1099FormDocHeader); + + // [GIVEN] Vendor's County (State) = " CA " (with leading and trailing spaces) + UpdateVendorProvinceOrState(IRS1099FormDocHeader."Vendor No.", ' CA '); + + // [WHEN] Create transmission XML + LibraryIRS1099IRIS.CreateTransmissionXmlContent(Transmission, Enum::"Transmission Type IRIS"::"O", false, UniqueTransmissionId, TempIRS1099FormDocHeader, TempBlob); + + // [THEN] StateAbbreviationCd is "CA" without spaces + InitXMLReader(TempBlob); + LibraryXPathXMLReader.VerifyXmlNodeValue('//n1:RecipientDetail/n1:MailingAddressGrp/n1:USAddress/n1:StateAbbreviationCd', 'CA'); + end; + + [Test] + [HandlerFunctions('ErrorMessagesPageHandler')] + procedure NonExistingStateCodeCausesValidationError() + var + Transmission: Record "Transmission IRIS"; + IRS1099FormDocHeader: Record "IRS 1099 Form Doc. Header"; + IRSFormsFacade: Codeunit "IRS Forms Facade"; + begin + // [FEATURE] [AI test] + // [SCENARIO 619973] Non-existing state code causes validation error when checking data to report + Initialize(); + + // [GIVEN] A vendor "V" with 1099 form document ready for transmission + CreateTransmissionWithSingleFormDoc(Transmission, IRS1099FormDocHeader); + + // [GIVEN] Vendor's County (State) = "A1" (invalid state code) + UpdateVendorProvinceOrState(IRS1099FormDocHeader."Vendor No.", 'A1'); + + // [WHEN] Check data to report + asserterror IRSFormsFacade.CheckDataToReport(Transmission); + + // [THEN] Error is thrown for invalid state code + Assert.ExpectedMessage('State must be a valid 2-letter US state code', LibraryVariableStorage.DequeueText()); + LibraryVariableStorage.AssertEmpty(); + end; + + [Test] + [HandlerFunctions('MultipleErrorMessagesPageHandler')] + procedure TwoDuplicateTINGroupsInSameSubmission() + var + Vendor: array[5] of Record Vendor; + IRS1099FormDocHeader: array[5] of Record "IRS 1099 Form Doc. Header"; + Transmission: Record "Transmission IRIS"; + IRSFormsFacade: Codeunit "IRS Forms Facade"; + PeriodNo: Code[20]; + TINGroup1: Text[30]; + TINGroup2: Text[30]; + i: Integer; + begin + // [FEATURE] [AI test] + // [SCENARIO 621343] Two groups of vendors with duplicate TINs in same submission cause two error messages + Initialize(); + PeriodNo := Format(Date2DMY(WorkDate(), 3)); + + // [GIVEN] 3 vendors "V1", "V2", "V3" share TIN "A" without bank accounts + TINGroup1 := LibraryIRS1099IRIS.GetUniqueTIN(); + for i := 1 to 3 do begin + LibraryIRS1099IRIS.CreateUSVendor(Vendor[i]); + UpdateVendorFederalId(Vendor[i]."No.", TINGroup1); + end; + + // [GIVEN] 2 vendors "V4", "V5" share TIN "B" without bank accounts + TINGroup2 := LibraryIRS1099IRIS.GetUniqueTIN(); + for i := 4 to 5 do begin + LibraryIRS1099IRIS.CreateUSVendor(Vendor[i]); + UpdateVendorFederalId(Vendor[i]."No.", TINGroup2); + end; + + // [GIVEN] Form documents for all vendors with form NEC + for i := 1 to 5 do + CreateReleasedFormDocForVendor(IRS1099FormDocHeader[i], Vendor[i]."No.", 'NEC', 'NEC-01'); + + // [GIVEN] Transmission created that picks up released form documents + LibraryIRS1099IRIS.CreateTransmission(Transmission, PeriodNo); + + // [WHEN] Check data to report + asserterror IRSFormsFacade.CheckDataToReport(Transmission); + + // [THEN] Two error messages are shown for duplicate TINs (one for each group) + Assert.ExpectedErrorCode('Dialog'); + Assert.ExpectedMessage('vendors have the same TIN', LibraryVariableStorage.DequeueText()); + Assert.ExpectedMessage('vendors have the same TIN', LibraryVariableStorage.DequeueText()); + LibraryVariableStorage.AssertEmpty(); + end; + + [Test] + [HandlerFunctions('MultipleErrorMessagesPageHandler')] + procedure DuplicateTINsWithSameBankAccountNo() + var + Vendor: array[2] of Record Vendor; + IRS1099FormDocHeader: array[2] of Record "IRS 1099 Form Doc. Header"; + Transmission: Record "Transmission IRIS"; + IRSFormsFacade: Codeunit "IRS Forms Facade"; + PeriodNo: Code[20]; + SharedTIN: Text[30]; + SharedBankAccountNo: Code[30]; + i: Integer; + begin + // [FEATURE] [AI test] + // [SCENARIO 621343] Two vendors with the same TIN and same Bank Account No. cause validation error + Initialize(); + PeriodNo := Format(Date2DMY(WorkDate(), 3)); + SharedTIN := LibraryIRS1099IRIS.GetUniqueTIN(); + SharedBankAccountNo := 'SHARED-BANK-123'; + + // [GIVEN] 2 vendors "V1", "V2" share the same TIN with same bank account number + LibraryIRS1099IRIS.CreateUSVendorWithBankAccount(Vendor[1], SharedBankAccountNo); + UpdateVendorFederalId(Vendor[1]."No.", SharedTIN); + LibraryIRS1099IRIS.CreateUSVendorWithBankAccount(Vendor[2], SharedBankAccountNo); + UpdateVendorFederalId(Vendor[2]."No.", SharedTIN); + + // [GIVEN] Form documents for both vendors + for i := 1 to 2 do + CreateReleasedFormDocForVendor(IRS1099FormDocHeader[i], Vendor[i]."No.", 'NEC', 'NEC-01'); + + // [GIVEN] Transmission created that picks up released form documents + LibraryIRS1099IRIS.CreateTransmission(Transmission, PeriodNo); + + // [WHEN] Check data to report + asserterror IRSFormsFacade.CheckDataToReport(Transmission); + + // [THEN] Error message is shown for duplicate TINs with same bank account + Assert.ExpectedErrorCode('Dialog'); + Assert.ExpectedMessage('2 vendors have the same TIN', LibraryVariableStorage.DequeueText()); + LibraryVariableStorage.AssertEmpty(); + end; + + [Test] + [HandlerFunctions('MultipleErrorMessagesPageHandler')] + procedure DuplicateTINsOneVendorHasBankAccountOneDoesNot() + var + Vendor: array[2] of Record Vendor; + VendorBankAccount: Record "Vendor Bank Account"; + IRS1099FormDocHeader: array[2] of Record "IRS 1099 Form Doc. Header"; + Transmission: Record "Transmission IRIS"; + IRSFormsFacade: Codeunit "IRS Forms Facade"; + PeriodNo: Code[20]; + SharedTIN: Text[30]; + i: Integer; + begin + // [FEATURE] [AI test] + // [SCENARIO 621343] Two vendors with the same TIN where only one has a bank account cause validation error + Initialize(); + PeriodNo := Format(Date2DMY(WorkDate(), 3)); + SharedTIN := LibraryIRS1099IRIS.GetUniqueTIN(); + + // [GIVEN] 2 vendors "V1", "V2" share the same TIN + for i := 1 to 2 do begin + LibraryIRS1099IRIS.CreateUSVendor(Vendor[i]); + UpdateVendorFederalId(Vendor[i]."No.", SharedTIN); + end; + + // [GIVEN] Only vendor "V1" has a bank account + LibraryIRS1099IRIS.CreateVendorBankAccount(VendorBankAccount, Vendor[1]."No.", 'BANK-ACCOUNT-1'); + + // [GIVEN] Form documents for both vendors + for i := 1 to 2 do + CreateReleasedFormDocForVendor(IRS1099FormDocHeader[i], Vendor[i]."No.", 'NEC', 'NEC-01'); + + // [GIVEN] Transmission created that picks up released form documents + LibraryIRS1099IRIS.CreateTransmission(Transmission, PeriodNo); + + // [WHEN] Check data to report + asserterror IRSFormsFacade.CheckDataToReport(Transmission); + + // [THEN] Error message is shown because "V2" has empty bank account + Assert.ExpectedErrorCode('Dialog'); + Assert.ExpectedMessage('2 vendors have the same TIN', LibraryVariableStorage.DequeueText()); + LibraryVariableStorage.AssertEmpty(); + end; + + [Test] + procedure DuplicateTINsWithUniqueBankAccountNos() + var + Vendor: array[2] of Record Vendor; + IRS1099FormDocHeader: array[2] of Record "IRS 1099 Form Doc. Header"; + Transmission: Record "Transmission IRIS"; + IRSFormsFacade: Codeunit "IRS Forms Facade"; + PeriodNo: Code[20]; + SharedTIN: Text[30]; + i: Integer; + begin + // [FEATURE] [AI test] + // [SCENARIO 621343] Two vendors with the same TIN but unique bank account numbers do not cause error + Initialize(); + PeriodNo := Format(Date2DMY(WorkDate(), 3)); + SharedTIN := LibraryIRS1099IRIS.GetUniqueTIN(); + + // [GIVEN] 2 vendors "V1", "V2" share the same TIN with unique bank account numbers + LibraryIRS1099IRIS.CreateUSVendorWithBankAccount(Vendor[1], 'UNIQUE-BANK-001'); + UpdateVendorFederalId(Vendor[1]."No.", SharedTIN); + LibraryIRS1099IRIS.CreateUSVendorWithBankAccount(Vendor[2], 'UNIQUE-BANK-002'); + UpdateVendorFederalId(Vendor[2]."No.", SharedTIN); + + // [GIVEN] Form documents for both vendors + for i := 1 to 2 do + CreateReleasedFormDocForVendor(IRS1099FormDocHeader[i], Vendor[i]."No.", 'NEC', 'NEC-01'); + + // [GIVEN] Transmission created that picks up released form documents + LibraryIRS1099IRIS.CreateTransmission(Transmission, PeriodNo); + + // [WHEN] Check data to report + IRSFormsFacade.CheckDataToReport(Transmission); + + // [THEN] No error is raised because bank account numbers are unique + end; + + [Test] + procedure DuplicateTINsAcrossDifferentSubmissions() + var + Vendor: array[2] of Record Vendor; + IRS1099FormDocHeader: array[2] of Record "IRS 1099 Form Doc. Header"; + Transmission: Record "Transmission IRIS"; + IRSFormsFacade: Codeunit "IRS Forms Facade"; + PeriodNo: Code[20]; + SharedTIN: Text[30]; + i: Integer; + begin + // [FEATURE] [AI test] + // [SCENARIO 621343] Vendors with the same TIN but different form types do not cause error + Initialize(); + PeriodNo := Format(Date2DMY(WorkDate(), 3)); + SharedTIN := LibraryIRS1099IRIS.GetUniqueTIN(); + + // [GIVEN] 2 vendors "V1", "V2" share the same TIN without bank accounts + for i := 1 to 2 do begin + LibraryIRS1099IRIS.CreateUSVendor(Vendor[i]); + UpdateVendorFederalId(Vendor[i]."No.", SharedTIN); + end; + + // [GIVEN] Vendor "V1" has form doc for NEC, vendor "V2" has form doc for MISC (different submissions) + CreateReleasedFormDocForVendor(IRS1099FormDocHeader[1], Vendor[1]."No.", 'NEC', 'NEC-01'); + CreateReleasedFormDocForVendor(IRS1099FormDocHeader[2], Vendor[2]."No.", 'MISC', 'MISC-03'); + + // [GIVEN] Transmission created that picks up released form documents + LibraryIRS1099IRIS.CreateTransmission(Transmission, PeriodNo); + + // [WHEN] Check data to report + IRSFormsFacade.CheckDataToReport(Transmission); + + // [THEN] No error is raised because vendors are in different submissions (form types) + end; + + [Test] + procedure NoDuplicateTINsNoError() + var + Vendor: array[3] of Record Vendor; + IRS1099FormDocHeader: array[3] of Record "IRS 1099 Form Doc. Header"; + Transmission: Record "Transmission IRIS"; + IRSFormsFacade: Codeunit "IRS Forms Facade"; + PeriodNo: Code[20]; + i: Integer; + begin + // [FEATURE] [AI test] + // [SCENARIO 621343] Multiple vendors with unique TINs do not cause error + Initialize(); + PeriodNo := Format(Date2DMY(WorkDate(), 3)); + + // [GIVEN] 3 vendors "V1", "V2", "V3" with unique TINs + LibraryIRS1099IRIS.CreateUSVendor(Vendor[1]); + UpdateVendorFederalId(Vendor[1]."No.", LibraryIRS1099IRIS.GetUniqueTIN()); + LibraryIRS1099IRIS.CreateUSVendor(Vendor[2]); + UpdateVendorFederalId(Vendor[2]."No.", LibraryIRS1099IRIS.GetUniqueTIN()); + LibraryIRS1099IRIS.CreateUSVendor(Vendor[3]); + UpdateVendorFederalId(Vendor[3]."No.", LibraryIRS1099IRIS.GetUniqueTIN()); + + // [GIVEN] Form documents for all vendors + for i := 1 to 3 do + CreateReleasedFormDocForVendor(IRS1099FormDocHeader[i], Vendor[i]."No.", 'NEC', 'NEC-01'); + + // [GIVEN] Transmission created that picks up released form documents + LibraryIRS1099IRIS.CreateTransmission(Transmission, PeriodNo); + + // [WHEN] Check data to report + IRSFormsFacade.CheckDataToReport(Transmission); + + // [THEN] No error is raised because all TINs are unique + end; + + [Test] + [HandlerFunctions('ErrorMessagesPageHandler')] + procedure EmptyContactPersonCausesValidationError() + var + Transmission: Record "Transmission IRIS"; + IRS1099FormDocHeader: Record "IRS 1099 Form Doc. Header"; + IRSFormsFacade: Codeunit "IRS Forms Facade"; + begin + // [FEATURE] [AI test] + // [SCENARIO 621425] Empty Contact Person in Company Information causes validation error + Initialize(); + + // [GIVEN] Vendor "V" with 1099 form document ready for transmission + CreateTransmissionWithSingleFormDoc(Transmission, IRS1099FormDocHeader); + + // [GIVEN] Company Information with empty Contact Person + UpdateCompanyContactInfo('', '1234567890', 'test@example.com'); + + // [WHEN] Check data to report + asserterror IRSFormsFacade.CheckDataToReport(Transmission); + + // [THEN] Error is thrown for empty Contact Person + Assert.ExpectedErrorCode('Dialog'); + Assert.ExpectedMessage('Contact Person must be between 1 and 35 characters', LibraryVariableStorage.DequeueText()); + LibraryVariableStorage.AssertEmpty(); + end; + + [Test] + procedure ContactPersonWithMaxLengthPasses() + var + Transmission: Record "Transmission IRIS"; + IRS1099FormDocHeader: Record "IRS 1099 Form Doc. Header"; + IRSFormsFacade: Codeunit "IRS Forms Facade"; + ContactPerson35Chars: Text[50]; + begin + // [FEATURE] [AI test] + // [SCENARIO 621425] Contact Person with exactly 35 characters passes validation + Initialize(); + + // [GIVEN] Vendor "V" with 1099 form document ready for transmission + CreateTransmissionWithSingleFormDoc(Transmission, IRS1099FormDocHeader); + + // [GIVEN] Company Information with Contact Person of exactly 35 characters + ContactPerson35Chars := CopyStr(LibraryUtility.GenerateRandomAlphabeticText(35, 0), 1, 50); + UpdateCompanyContactInfo(ContactPerson35Chars, '1234567890', 'test@example.com'); + + // [WHEN] Check data to report + IRSFormsFacade.CheckDataToReport(Transmission); + + // [THEN] No error is raised for Contact Person + end; + + [Test] + [HandlerFunctions('ErrorMessagesPageHandler')] + procedure ContactPersonExceedingMaxLengthCausesError() + var + Transmission: Record "Transmission IRIS"; + IRS1099FormDocHeader: Record "IRS 1099 Form Doc. Header"; + IRSFormsFacade: Codeunit "IRS Forms Facade"; + ContactPersonTooLong: Text[50]; + begin + // [FEATURE] [AI test] + // [SCENARIO 621425] Contact Person exceeding 35 characters after formatting causes validation error + Initialize(); + + // [GIVEN] Vendor "V" with 1099 form document ready for transmission + CreateTransmissionWithSingleFormDoc(Transmission, IRS1099FormDocHeader); + + // [GIVEN] Company Information with Contact Person exceeding 35 characters + ContactPersonTooLong := CopyStr(LibraryUtility.GenerateRandomAlphabeticText(36, 0), 1, 50); + UpdateCompanyContactInfo(ContactPersonTooLong, '1234567890', 'test@example.com'); + + // [WHEN] Check data to report + asserterror IRSFormsFacade.CheckDataToReport(Transmission); + + // [THEN] Error is thrown for Contact Person exceeding max length + Assert.ExpectedErrorCode('Dialog'); + Assert.ExpectedMessage('Contact Person must be between 1 and 35 characters', LibraryVariableStorage.DequeueText()); + LibraryVariableStorage.AssertEmpty(); + end; + + [Test] + [HandlerFunctions('ErrorMessagesPageHandler')] + procedure EmptyPhoneNoCausesValidationError() + var + Transmission: Record "Transmission IRIS"; + IRS1099FormDocHeader: Record "IRS 1099 Form Doc. Header"; + IRSFormsFacade: Codeunit "IRS Forms Facade"; + begin + // [FEATURE] [AI test] + // [SCENARIO 621425] Empty Phone No. in Company Information causes validation error + Initialize(); + + // [GIVEN] Vendor "V" with 1099 form document ready for transmission + CreateTransmissionWithSingleFormDoc(Transmission, IRS1099FormDocHeader); + + // [GIVEN] Company Information with empty Phone No. + UpdateCompanyContactInfo('John Doe', '', 'test@example.com'); + + // [WHEN] Check data to report + asserterror IRSFormsFacade.CheckDataToReport(Transmission); + + // [THEN] Error is thrown for empty Phone No. + Assert.ExpectedErrorCode('Dialog'); + Assert.ExpectedMessage('Phone No. must be between 10 and 30 digits', LibraryVariableStorage.DequeueText()); + LibraryVariableStorage.AssertEmpty(); + end; + + [Test] + procedure PhoneNoWithMinLengthPasses() + var + Transmission: Record "Transmission IRIS"; + IRS1099FormDocHeader: Record "IRS 1099 Form Doc. Header"; + IRSFormsFacade: Codeunit "IRS Forms Facade"; + begin + // [FEATURE] [AI test] + // [SCENARIO 621425] Phone No. with exactly 10 digits passes validation + Initialize(); + + // [GIVEN] Vendor "V" with 1099 form document ready for transmission + CreateTransmissionWithSingleFormDoc(Transmission, IRS1099FormDocHeader); + + // [GIVEN] Company Information with Phone No. of exactly 10 digits + UpdateCompanyContactInfo('John Doe', '1234567890', 'test@example.com'); + + // [WHEN] Check data to report + IRSFormsFacade.CheckDataToReport(Transmission); + + // [THEN] No error is raised for Phone No. + end; + + [Test] + [HandlerFunctions('ErrorMessagesPageHandler')] + procedure PhoneNoTooShortCausesError() + var + Transmission: Record "Transmission IRIS"; + IRS1099FormDocHeader: Record "IRS 1099 Form Doc. Header"; + IRSFormsFacade: Codeunit "IRS Forms Facade"; + begin + // [FEATURE] [AI test] + // [SCENARIO 621425] Phone No. with less than 10 digits causes validation error + Initialize(); + + // [GIVEN] Vendor "V" with 1099 form document ready for transmission + CreateTransmissionWithSingleFormDoc(Transmission, IRS1099FormDocHeader); + + // [GIVEN] Company Information with Phone No. of only 9 digits + UpdateCompanyContactInfo('John Doe', '123456789', 'test@example.com'); + + // [WHEN] Check data to report + asserterror IRSFormsFacade.CheckDataToReport(Transmission); + + // [THEN] Error is thrown for Phone No. too short + Assert.ExpectedErrorCode('Dialog'); + Assert.ExpectedMessage('Phone No. must be between 10 and 30 digits', LibraryVariableStorage.DequeueText()); + LibraryVariableStorage.AssertEmpty(); + end; + + [Test] + procedure PhoneNoWithMaxLengthPasses() + var + Transmission: Record "Transmission IRIS"; + IRS1099FormDocHeader: Record "IRS 1099 Form Doc. Header"; + IRSFormsFacade: Codeunit "IRS Forms Facade"; + begin + // [FEATURE] [AI test] + // [SCENARIO 621425] Phone No. with exactly 30 digits passes validation + Initialize(); + + // [GIVEN] Vendor "V" with 1099 form document ready for transmission + CreateTransmissionWithSingleFormDoc(Transmission, IRS1099FormDocHeader); + + // [GIVEN] Company Information with Phone No. of exactly 30 digits (max allowed) + UpdateCompanyContactInfo('John Doe', '123456789012345678901234567890', 'test@example.com'); + + // [WHEN] Check data to report + IRSFormsFacade.CheckDataToReport(Transmission); + + // [THEN] No error is raised for Phone No. at max length + end; + local procedure Initialize() var MockKeyVaultClientIRIS: Codeunit "Mock Key Vault Client IRIS"; @@ -96,6 +576,7 @@ codeunit 148022 "IRS 1099 IRIS Tests" LibraryTestInitialize.OnTestInitialize(Codeunit::"IRS 1099 IRIS Tests"); LibrarySetupStorage.Restore(); + LibraryIRS1099IRIS.RestoreIRISUserID(); LibraryIRS1099IRIS.DeleteAllTransmissions(); LibraryIRS1099Document.DeleteFormDocuments(); @@ -106,6 +587,8 @@ codeunit 148022 "IRS 1099 IRIS Tests" LibraryIRS1099IRIS.InitializeCompanyInformation(); LibraryIRS1099IRIS.InitializeIRSFormsSetup(); + LibraryIRS1099IRIS.SaveIRISUserID(); + LibraryIRS1099IRIS.InitializeIRISUserID(); MockKeyVaultClientIRIS.SetDefaultValues(); InitializeReportingPeriodAndForms(Date2DMY(WorkDate(), 3)); @@ -182,6 +665,29 @@ codeunit 148022 "IRS 1099 IRIS Tests" IRS1099FormDocHeader.Modify(true); end; + local procedure CreateReleasedFormDocForVendor(var IRS1099FormDocHeader: Record "IRS 1099 Form Doc. Header"; VendorNo: Code[20]; FormNo: Code[20]; FormBoxNo: Code[20]) + var + Year: Integer; + StartingDate: Date; + EndingDate: Date; + PeriodNo: Code[20]; + begin + Year := Date2DMY(WorkDate(), 3); + StartingDate := DMY2Date(1, 1, Year); + EndingDate := CalcDate('', StartingDate); + PeriodNo := Format(Year); + + LibraryIRS1099Document.CreateAndPostPurchaseDocument("Purchase Document Type"::Invoice, VendorNo, Year, FormNo, FormBoxNo); + LibraryIRS1099Document.CreateFormDocuments(StartingDate, EndingDate, VendorNo); + + IRS1099FormDocHeader.SetRange("Period No.", PeriodNo); + IRS1099FormDocHeader.SetRange("Vendor No.", VendorNo); + IRS1099FormDocHeader.SetRange("Form No.", FormNo); + IRS1099FormDocHeader.FindFirst(); + IRS1099FormDocHeader.Validate(Status, IRS1099FormDocHeader.Status::Released); + IRS1099FormDocHeader.Modify(true); + end; + local procedure GetRandomFormAndFormBox(var FormNo: Code[20]; var FormBoxNo: Code[20]; Year: Integer; var ExcludeFormBoxNoList: List of [Code[20]]) var IRS1099FormBox: Record "IRS 1099 Form Box"; @@ -213,4 +719,39 @@ codeunit 148022 "IRS 1099 IRIS Tests" CompanyInformation."E-Mail" := Email; CompanyInformation.Modify(); end; + + local procedure UpdateVendorProvinceOrState(VendorNo: Code[20]; ProvinceOrStateCode: Text[30]) + var + Vendor: Record Vendor; + begin + Vendor.Get(VendorNo); + Vendor.County := ProvinceOrStateCode; + Vendor.Modify(); + end; + + local procedure UpdateVendorFederalId(VendorNo: Code[20]; FederalId: Text[30]) + var + Vendor: Record Vendor; + begin + Vendor.Get(VendorNo); + Vendor."Federal ID No." := FederalId; + Vendor.Modify(); + end; + + [PageHandler] + procedure ErrorMessagesPageHandler(var ErrorMessagesPage: TestPage "Error Messages") + begin + LibraryVariableStorage.Enqueue(ErrorMessagesPage.Description.Value); + ErrorMessagesPage.Close(); + end; + + [PageHandler] + procedure MultipleErrorMessagesPageHandler(var ErrorMessagesPage: TestPage "Error Messages") + begin + ErrorMessagesPage.First(); + repeat + LibraryVariableStorage.Enqueue(ErrorMessagesPage.Description.Value); + until not ErrorMessagesPage.Next(); + ErrorMessagesPage.Close(); + end; } diff --git a/Apps/W1/APIV2/app/src/pages/APIV2Jobs.Page.al b/Apps/W1/APIV2/app/src/pages/APIV2Jobs.Page.al index 7a44feaf63..f89a9c452a 100644 --- a/Apps/W1/APIV2/app/src/pages/APIV2Jobs.Page.al +++ b/Apps/W1/APIV2/app/src/pages/APIV2Jobs.Page.al @@ -47,6 +47,14 @@ page 30050 "APIV2 - Jobs" EntitySetName = 'documentAttachments'; SubPageLink = "Document Id" = field(SystemId), "Document Type" = const(Job); } + part(pdfDocument; "APIV2 - PDF Document") + { + Caption = 'PDF Document'; + Multiplicity = ZeroOrOne; + EntityName = 'pdfDocument'; + EntitySetName = 'pdfDocument'; + SubPageLink = "Document Id" = field(SystemId), "Document Type" = const(Job); + } } } } diff --git a/Apps/W1/APIV2/app/src/pages/APIV2PurchaseOrders.Page.al b/Apps/W1/APIV2/app/src/pages/APIV2PurchaseOrders.Page.al index 41a073ff11..e03c75b8e1 100644 --- a/Apps/W1/APIV2/app/src/pages/APIV2PurchaseOrders.Page.al +++ b/Apps/W1/APIV2/app/src/pages/APIV2PurchaseOrders.Page.al @@ -538,6 +538,14 @@ page 30066 "APIV2 - Purchase Orders" Caption = 'Last Modified Date'; Editable = false; } + part(pdfDocument; "APIV2 - PDF Document") + { + Caption = 'PDF Document'; + Multiplicity = ZeroOrOne; + EntityName = 'pdfDocument'; + EntitySetName = 'pdfDocument'; + SubPageLink = "Document Id" = field(Id), "Document Type" = const("Purchase Order"); + } part(attachments; "APIV2 - Attachments") { Caption = 'Attachments'; diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Analytics/3.Transactions/CreateExtendedPurchDocument.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Analytics/3.Transactions/CreateExtendedPurchDocument.Codeunit.al index 4c8411eefc..5af85ee5f1 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Analytics/3.Transactions/CreateExtendedPurchDocument.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Analytics/3.Transactions/CreateExtendedPurchDocument.Codeunit.al @@ -6,6 +6,7 @@ namespace Microsoft.DemoData.Analytics; using Microsoft.DemoData.Bank; +using Microsoft.DemoData.CRM; using Microsoft.DemoData.Foundation; using Microsoft.DemoData.Inventory; using Microsoft.DemoData.Purchases; @@ -27,6 +28,8 @@ codeunit 5688 "Create Extended Purch Document" CreateItem: Codeunit "Create Item"; CreatePaymentMethod: Codeunit "Create Payment Method"; CreatePaymentTerms: Codeunit "Create Payment Terms"; + CreateReturnReason: Codeunit "Create Return Reason"; + CreatePurchaser: Codeunit "Create Salesperson/Purchaser"; CreateVendor: Codeunit "Create Vendor"; DocumentDate: Date; StartingDate: Date; @@ -36,50 +39,110 @@ codeunit 5688 "Create Extended Purch Document" DocumentDate := CalcDate('<-6M>', StartingDate); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCM(), '', '', '', DocumentDate, CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCM(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 60, '', 219.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.DomesticNodPublisher(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.DomesticNodPublisher(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 30, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensMobilePedestal(), 25, '', 219.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.DomesticFirstUp(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.DomesticFirstUp(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.LondonSwivelChairBlue(), 23, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.DomesticWorldImporter(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.DomesticWorldImporter(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AntwerpConferenceTable(), 50, '', 328); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AmsterdamLamp(), 15, '', 27.8); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.BerlingGuestChairYellow(), 5, '', 27.8); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.DomesticFirstUp(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCM(), '', '', '', DocumentDate, CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.DomesticFirstUp(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCM(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.RomeGuestChairGreen(), 39, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.DomesticWorldImporter(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.DomesticWorldImporter(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.TokyoGuestChairBlue(), 40, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.DomesticFirstUp(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.DomesticFirstUp(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MexicoSwivelChairBlack(), 30, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MunichSwivelChairYellow(), 30, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.DomesticNodPublisher(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.DomesticNodPublisher(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MoscowSwivelChairRed(), 40, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.DomesticFirstUp(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.DomesticFirstUp(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SeoulGuestChairRed(), 40, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AtlantAWhiteboardBase(), 20, '', 707.2); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Order, CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SydneySwivelChairGreen(), 10, '', 96.1); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Credit Memo", CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', '97815', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 60, '', 219.5, CreateReturnReason.Damaged()); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Credit Memo", CreateVendor.DomesticNodPublisher(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', '2523', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 30, '', 97.5, CreateReturnReason.Damaged()); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Credit Memo", CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', 'CR-A914', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 25, '', 219.5, CreateReturnReason.Damaged()); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Credit Memo", CreateVendor.DomesticFirstUp(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', 'C0902', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 23, '', 96.1, CreateReturnReason.WrongItem()); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Credit Memo", CreateVendor.DomesticWorldImporter(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', 'CR-A915', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 50, '', 328, CreateReturnReason.Damaged()); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Credit Memo", CreateVendor.ExportFabrikam(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', 'V0A934', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 15, '', 96.5, CreateReturnReason.WrongSize()); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Credit Memo", CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', 'R20128', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 15, '', 27.8, CreateReturnReason.WrongColor()); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Credit Memo", CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', '908725', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 5, '', 27.8, CreateReturnReason.WrongSize()); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Credit Memo", CreateVendor.DomesticFirstUp(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', '6295', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 39, '', 97.5, CreateReturnReason.Damaged()); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Credit Memo", CreateVendor.DomesticWorldImporter(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', '2589U3', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 40, '', 97.5, CreateReturnReason.Damaged()); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Return Order", CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 60, '', 219.5, CreateReturnReason.Damaged()); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Return Order", CreateVendor.DomesticNodPublisher(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 30, '', 97.5, CreateReturnReason.Damaged()); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Return Order", CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 25, '', 219.5, CreateReturnReason.Damaged()); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Return Order", CreateVendor.DomesticFirstUp(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 23, '', 96.1, CreateReturnReason.WrongItem()); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Return Order", CreateVendor.DomesticWorldImporter(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 50, '', 328, CreateReturnReason.Damaged()); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Return Order", CreateVendor.ExportFabrikam(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 15, '', 96.5, CreateReturnReason.WrongSize()); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Return Order", CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 15, '', 27.8, CreateReturnReason.WrongColor()); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Return Order", CreateVendor.EUGraphicDesign(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 5, '', 27.8, CreateReturnReason.WrongSize()); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Return Order", CreateVendor.DomesticFirstUp(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 39, '', 97.5, CreateReturnReason.Damaged()); + + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::"Return Order", CreateVendor.DomesticWorldImporter(), AnalyticsReference(), ContosoUtilities.AdjustDate(19020101D), DocumentDate, ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', DocumentDate, CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); + ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 40, '', 97.5, CreateReturnReason.Damaged()); end; procedure AnalyticsReference(): Code[35] diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/CRM/2.Master Data/CreateSalespersonPurchaser.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/CRM/2.Master Data/CreateSalespersonPurchaser.Codeunit.al index d659edead6..5b2f86b3d7 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/CRM/2.Master Data/CreateSalespersonPurchaser.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/CRM/2.Master Data/CreateSalespersonPurchaser.Codeunit.al @@ -17,13 +17,13 @@ codeunit 5416 "Create Salesperson/Purchaser" ContosoCRM: Codeunit "Contoso CRM"; ContosoUtilities: Codeunit "Contoso Utilities"; begin - ContosoCRM.InsertSalespersonPurchaser(BenjaminChiu(), BenjaminChiuLbl, 0, ContosoUtilities.EmptyPicture(), 'BC@contoso.com'); + ContosoCRM.InsertSalespersonPurchaser(BenjaminChiu(), BenjaminChiuLbl, 3, ContosoUtilities.EmptyPicture(), 'BC@contoso.com'); ContosoCRM.InsertSalespersonPurchaser(EsterHenderson(), EsterHendersonLbl, 0, ContosoUtilities.EmptyPicture(), 'EH@contoso.com'); ContosoCRM.InsertSalespersonPurchaser(HelenaRay(), HelenaRayLbl, 0, ContosoUtilities.EmptyPicture(), 'HR@contoso.com'); ContosoCRM.InsertSalespersonPurchaser(JimOlive(), JimOliveLbl, 5, ContosoUtilities.EmptyPicture(), 'JO@contoso.com'); ContosoCRM.InsertSalespersonPurchaser(LinaTownsend(), LinaTownsendLbl, 5, ContosoUtilities.EmptyPicture(), 'LT@contoso.com'); ContosoCRM.InsertSalespersonPurchaser(OtisFalls(), OtisFallsLbl, 5, ContosoUtilities.EmptyPicture(), 'OF@contoso.com'); - ContosoCRM.InsertSalespersonPurchaser(RobinBettencourt(), RobinBettencourtLbl, 0, ContosoUtilities.EmptyPicture(), 'RB@contoso.com'); + ContosoCRM.InsertSalespersonPurchaser(RobinBettencourt(), RobinBettencourtLbl, 2, ContosoUtilities.EmptyPicture(), 'RB@contoso.com'); end; procedure BenjaminChiu(): Code[20] diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreatePostingGroups.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreatePostingGroups.Codeunit.al index c69b21e119..6db035b2e5 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreatePostingGroups.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/1.Setup data/CreatePostingGroups.Codeunit.al @@ -69,13 +69,17 @@ codeunit 5252 "Create Posting Groups" ContosoGenPostingSetup.InsertGeneralPostingSetup('', RetailPostingGroup(), '', '', CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', '', '', '', '', CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); ContosoGenPostingSetup.InsertGeneralPostingSetup('', ZeroPostingGroup(), '', '', CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', '', '', '', '', CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); ContosoGenPostingSetup.InsertGeneralPostingSetup('', ServicesPostingGroup(), '', '', CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', '', '', '', '', CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); + ContosoGenPostingSetup.InsertGeneralPostingSetup('', MiscPostingGroup(), '', '', CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', '', '', '', '', CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); ContosoGenPostingSetup.InsertGeneralPostingSetup(DomesticPostingGroup(), RetailPostingGroup(), CreateGLAccount.SalesRetailDom(), CreateGLAccount.PurchRetailDom(), CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); ContosoGenPostingSetup.InsertGeneralPostingSetup(DomesticPostingGroup(), ServicesPostingGroup(), CreateGLAccount.SalesResourcesDom(), CreateGLAccount.PurchRetailDom(), CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); ContosoGenPostingSetup.InsertGeneralPostingSetup(DomesticPostingGroup(), ZeroPostingGroup(), CreateGLAccount.SalesRetailDom(), CreateGLAccount.PurchRetailDom(), CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); + ContosoGenPostingSetup.InsertGeneralPostingSetup(DomesticPostingGroup(), MiscPostingGroup(), CreateGLAccount.SalesRetailDom(), CreateGLAccount.PurchRetailDom(), CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); ContosoGenPostingSetup.InsertGeneralPostingSetup(EUPostingGroup(), RetailPostingGroup(), CreateGLAccount.SalesRetailEU(), CreateGLAccount.PurchRetailEU(), CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); + ContosoGenPostingSetup.InsertGeneralPostingSetup(EUPostingGroup(), MiscPostingGroup(), CreateGLAccount.SalesRetailEU(), CreateGLAccount.PurchRetailEU(), CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); ContosoGenPostingSetup.InsertGeneralPostingSetup(ExportPostingGroup(), RetailPostingGroup(), CreateGLAccount.SalesRetailExport(), CreateGLAccount.PurchRetailExport(), CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); ContosoGenPostingSetup.InsertGeneralPostingSetup(ExportPostingGroup(), ServicesPostingGroup(), CreateGLAccount.SalesResourcesExport(), CreateGLAccount.PurchRetailExport(), CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); ContosoGenPostingSetup.InsertGeneralPostingSetup(ExportPostingGroup(), ZeroPostingGroup(), CreateGLAccount.SalesRetailExport(), CreateGLAccount.PurchRetailExport(), CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); + ContosoGenPostingSetup.InsertGeneralPostingSetup(ExportPostingGroup(), MiscPostingGroup(), CreateGLAccount.SalesRetailExport(), CreateGLAccount.PurchRetailExport(), CreateGLAccount.InventoryAdjmtRetail(), CreateGLAccount.InventoryAdjmtRetail(), '', '', CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscountGranted(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.DiscReceivedRetail(), CreateGLAccount.CostofRetailSold(), CreateGLAccount.CostofResaleSoldInterim(), CreateGLAccount.InvAdjmtInterimRetail()); ContosoGenPostingSetup.SetOverwriteData(false); end; diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/2.Master data/CreateAddReportingCurrency.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/2.Master data/CreateAddReportingCurrency.Codeunit.al new file mode 100644 index 0000000000..1ffcf7b17e --- /dev/null +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/2.Master data/CreateAddReportingCurrency.Codeunit.al @@ -0,0 +1,71 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace Microsoft.DemoData.Finance; + +using Microsoft.Finance.Currency; +using Microsoft.Finance.GeneralLedger.Setup; + +codeunit 5627 "Create Add. Reporting Currency" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "General Ledger Setup" = rm, + tabledata Currency = rm; + + trigger OnRun() + begin + ConfigureAdditionalReportingCurrency(); + UpdateCurrencyResidualAccounts(); + end; + + procedure ConfigureAdditionalReportingCurrency() + var + GeneralLedgerSetup: Record "General Ledger Setup"; + CreateCurrency: Codeunit "Create Currency"; + ACYCode: Code[10]; + begin + GeneralLedgerSetup.Get(); + ACYCode := GeneralLedgerSetup."LCY Code" = CreateCurrency.EUR() ? CreateCurrency.USD() : CreateCurrency.EUR(); + GeneralLedgerSetup."Additional Reporting Currency" := ACYCode; + GeneralLedgerSetup.Modify(true); + end; + + procedure UpdateCurrencyResidualAccounts() + var + Currency: Record "Currency"; + CreateCurrency: Codeunit "Create Currency"; + FXGainsAccount: Code[20]; + FXLossesAccount: Code[20]; + begin + GetResidualCurrencyAccounts(FXGainsAccount, FXLossesAccount); + Currency.SetFilter(Code, '%1|%2', CreateCurrency.EUR(), CreateCurrency.USD()); + if Currency.FindSet(true) then + repeat + Currency.Validate("Residual Gains Account", FXGainsAccount); + Currency.Validate("Residual Losses Account", FXLossesAccount); + Currency.Modify(true); + until Currency.Next() = 0; + end; + + local procedure GetResidualCurrencyAccounts(var FXGainsAccount: Code[20]; var FXLossesAccount: Code[20]) + var + CreateGLAccount: Codeunit "Create G/L Account"; + IsHandled: Boolean; + begin + OnBeforeGetResidualCurrencyAccounts(FXGainsAccount, FXLossesAccount, IsHandled); + if IsHandled then + exit; + + FXGainsAccount := CreateGLAccount.RealizedFXGains(); + FXLossesAccount := CreateGLAccount.RealizedFXLosses(); + end; + + [IntegrationEvent(false, false)] + local procedure OnBeforeGetResidualCurrencyAccounts(var FXGainsAccount: Code[20]; var FXLossesAccount: Code[20]; var IsHandled: Boolean) + begin + end; +} \ No newline at end of file diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/FinanceModule.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/FinanceModule.Codeunit.al index 2e509adb08..79dc9792fe 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/FinanceModule.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Finance/FinanceModule.Codeunit.al @@ -76,6 +76,7 @@ codeunit 5415 "Finance Module" implements "Contoso Demo Data Module" Codeunit.Run(Codeunit::"Create Currency Exchange Rate"); Codeunit.Run(Codeunit::"Create Resource"); Codeunit.Run(Codeunit::"Create Allocation Account"); + Codeunit.Run(Codeunit::"Create Add. Reporting Currency"); end; procedure CreateTransactionalData() diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Purchases/1.Setup Data/CreateReturnReason.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Purchases/1.Setup Data/CreateReturnReason.Codeunit.al new file mode 100644 index 0000000000..5daf859a64 --- /dev/null +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Purchases/1.Setup Data/CreateReturnReason.Codeunit.al @@ -0,0 +1,54 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace Microsoft.DemoData.Purchases; + +using Microsoft.DemoTool.Helpers; + +codeunit 5622 "Create Return Reason" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoPurchase: Codeunit "Contoso Purchase"; + begin + ContosoPurchase.InsertReturnReason(Damaged(), DamageDescriptionLbl); + ContosoPurchase.InsertReturnReason(WrongItem(), WrongItemDescriptionLbl); + ContosoPurchase.InsertReturnReason(WrongSize(), WrongSizeDescriptionLbl); + ContosoPurchase.InsertReturnReason(WrongColor(), WrongColorDescriptionLbl); + end; + + procedure Damaged(): Code[10] + begin + exit(DamagedTok); + end; + + procedure WrongItem(): Code[10] + begin + exit(ItemTok); + end; + + procedure WrongSize(): Code[10] + begin + exit(SizeTok); + end; + + procedure WrongColor(): Code[10] + begin + exit(ColorTok); + end; + + var + ColorTok: Label 'COLOR', MaxLength = 10; + DamageDescriptionLbl: Label 'Damaged or defective', MaxLength = 50; + DamagedTok: Label 'DAMAGED', MaxLength = 10; + ItemTok: Label 'ITEM', MaxLength = 10; + SizeTok: Label 'SIZE', MaxLength = 10; + WrongColorDescriptionLbl: Label 'Wrong color', MaxLength = 50; + WrongItemDescriptionLbl: Label 'Wrong item', MaxLength = 50; + WrongSizeDescriptionLbl: Label 'Wrong size', MaxLength = 50; +} diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Purchases/3.Transactions/CreatePurchaseDocument.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Purchases/3.Transactions/CreatePurchaseDocument.Codeunit.al index 06ffd502ba..150edb3050 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Purchases/3.Transactions/CreatePurchaseDocument.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Purchases/3.Transactions/CreatePurchaseDocument.Codeunit.al @@ -6,6 +6,7 @@ namespace Microsoft.DemoData.Purchases; using Microsoft.DemoData.Bank; +using Microsoft.DemoData.CRM; using Microsoft.DemoData.Finance; using Microsoft.DemoData.Foundation; using Microsoft.DemoData.Inventory; @@ -27,429 +28,430 @@ codeunit 5420 "Create Purchase Document" CreateItem: Codeunit "Create Item"; CreatePaymentMethod: Codeunit "Create Payment Method"; CreateLocation: Codeunit "Create Location"; + CreatePurchaser: Codeunit "Create Salesperson/Purchaser"; begin CreatePurchaseOrders(); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 4, '', 506.6); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensMobilePedestal(), 5, '', 219.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.LondonSwivelChairBlue(), 3, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AmsterdamLamp(), 8, '', 27.8); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.BerlingGuestChairYellow(), 10, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.RomeGuestChairGreen(), 2, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.TokyoGuestChairBlue(), 4, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SydneySwivelChairGreen(), 10, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), CreateLocation.MainLocation(), '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), CreateLocation.MainLocation(), '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MexicoSwivelChairBlack(), 2, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), CreateLocation.EastLocation(), '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), CreateLocation.EastLocation(), '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MexicoSwivelChairBlack(), 3, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), CreateLocation.WestLocation(), '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), CreateLocation.WestLocation(), '', '', ContosoUtilities.AdjustDate(19020101D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MexicoSwivelChairBlack(), 5, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021101D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021101D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021101D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AtlantAWhiteboardBase(), 5, '', 707.2); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020901D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020901D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020901D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020901D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AntwerpConferenceTable(), 10, '', 328); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021201D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021201D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021201D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021201D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.BerlingGuestChairYellow(), 90, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021201D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021201D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021201D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021201D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SydneySwivelChairGreen(), 28, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021201D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021201D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021201D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021201D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AtlantAWhiteboardBase(), 5, '', 707.2); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020108D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020108D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020108D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020108D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.LondonSwivelChairBlue(), 5, '', 96.1); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SeoulGuestChairRed(), 5, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020108D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020108D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020108D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020108D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AntwerpConferenceTable(), 5, '', 328); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020109D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020109D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020109D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020109D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MunichSwivelChairYellow(), 7, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020110D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020110D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020110D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020110D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MexicoSwivelChairBlack(), 6, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020111D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020111D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020111D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020111D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 8, '', 97.5); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MoscowSwivelChairRed(), 4, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020111D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020111D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020111D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020111D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.BerlingGuestChairYellow(), 8, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020112D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020112D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020112D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020112D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 9, '', 506.6); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020113D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020113D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020113D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020113D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.RomeGuestChairGreen(), 7, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020114D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020114D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020114D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020114D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AmsterdamLamp(), 10, '', 27.8); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020114D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020114D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020114D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020114D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AtlantAWhiteboardBase(), 7, '', 707.2); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020115D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020115D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020115D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020115D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.TokyoGuestChairBlue(), 5, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020115D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020115D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020115D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020115D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SydneySwivelChairGreen(), 5, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020116D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020116D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020116D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020116D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensMobilePedestal(), 6, '', 219.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020208D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020208D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020208D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020208D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.LondonSwivelChairBlue(), 5, '', 96.1); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SeoulGuestChairRed(), 5, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020208D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020208D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020208D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020208D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AntwerpConferenceTable(), 4, '', 328); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020209D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020209D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020209D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020209D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MunichSwivelChairYellow(), 7, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020210D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020210D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020210D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020210D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 10, '', 97.5); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MoscowSwivelChairRed(), 4, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020210D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020210D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020210D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020210D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.BerlingGuestChairYellow(), 9, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020210D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020210D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020210D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020210D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MexicoSwivelChairBlack(), 6, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020212D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020212D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020212D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020212D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 13, '', 506.6); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020212D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020212D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020212D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020212D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.RomeGuestChairGreen(), 7, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020213D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020213D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020213D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020213D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AmsterdamLamp(), 11, '', 27.8); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020213D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020213D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020213D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020213D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AtlantAWhiteboardBase(), 6, '', 707.2); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020214D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020214D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020214D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020214D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.TokyoGuestChairBlue(), 5, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020214D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020214D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020214D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020214D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SydneySwivelChairGreen(), 5, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020215D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020215D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020215D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020215D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensMobilePedestal(), 8, '', 219.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020308D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020308D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020308D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020308D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.LondonSwivelChairBlue(), 6, '', 96.1); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SeoulGuestChairRed(), 6, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020308D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020308D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020308D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020308D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AntwerpConferenceTable(), 7, '', 328); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020309D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020309D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020309D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020309D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MunichSwivelChairYellow(), 9, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020310D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020310D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020310D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020310D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MexicoSwivelChairBlack(), 8, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020311D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020311D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020311D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020311D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 11, '', 97.5); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MoscowSwivelChairRed(), 6, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020311D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020311D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020311D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020311D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.BerlingGuestChairYellow(), 10, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020312D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020312D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020312D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020312D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 15, '', 506.6); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020313D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020313D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020313D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020313D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.RomeGuestChairGreen(), 9, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020314D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020314D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020314D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020314D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AmsterdamLamp(), 13, '', 27.8); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020314D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020314D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020314D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020314D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AtlantAWhiteboardBase(), 10, '', 707.2); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020315D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020315D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020315D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020315D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.TokyoGuestChairBlue(), 6, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020315D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020315D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020315D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020315D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SydneySwivelChairGreen(), 7, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020316D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020316D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020316D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020316D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensMobilePedestal(), 9, '', 219.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020408D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020408D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020408D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020408D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.LondonSwivelChairBlue(), 6, '', 96.1); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SeoulGuestChairRed(), 5, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020408D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020408D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020408D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020408D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AntwerpConferenceTable(), 6, '', 328); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020409D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020409D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020409D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020409D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MunichSwivelChairYellow(), 10, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020410D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020410D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020410D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020410D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 11, '', 97.5); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MoscowSwivelChairRed(), 5, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020410D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020410D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020410D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020410D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MexicoSwivelChairBlack(), 9, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020411D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020411D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020411D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020411D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.BerlingGuestChairYellow(), 11, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020412D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020412D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020412D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020412D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 18, '', 506.6); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020413D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020413D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020413D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020413D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AmsterdamLamp(), 13, '', 27.8); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020413D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020413D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020413D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020413D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.RomeGuestChairGreen(), 9, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020413D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020413D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020413D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020413D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AtlantAWhiteboardBase(), 10, '', 707.2); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020414D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020414D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020414D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020414D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.TokyoGuestChairBlue(), 6, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020415D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020415D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020415D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020415D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensMobilePedestal(), 9, '', 219.5); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SydneySwivelChairGreen(), 8, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020508D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020508D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020508D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020508D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.LondonSwivelChairBlue(), 5, '', 96.1); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SeoulGuestChairRed(), 6, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020508D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020508D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020508D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020508D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AntwerpConferenceTable(), 7, '', 328); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020509D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020509D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020509D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020509D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MunichSwivelChairYellow(), 9, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020510D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020510D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020510D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020510D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MexicoSwivelChairBlack(), 8, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020511D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020511D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020511D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020511D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 7, '', 97.5); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MoscowSwivelChairRed(), 5, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020511D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020511D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020511D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020511D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.BerlingGuestChairYellow(), 9, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020512D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020512D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020512D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020512D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 14, '', 506.6); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020513D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020513D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020513D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020513D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.RomeGuestChairGreen(), 8, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020514D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020514D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020514D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020514D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AmsterdamLamp(), 11, '', 27.8); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020514D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020514D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020514D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020514D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AtlantAWhiteboardBase(), 9, '', 707.2); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020515D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020515D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020515D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020515D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.TokyoGuestChairBlue(), 5, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020515D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020515D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020515D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020515D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SydneySwivelChairGreen(), 7, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020516D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020516D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020516D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020516D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensMobilePedestal(), 6, '', 219.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020608D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020608D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020608D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020608D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.LondonSwivelChairBlue(), 5, '', 96.1); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SeoulGuestChairRed(), 6, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020608D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020608D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020608D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020608D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AntwerpConferenceTable(), 5, '', 328); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020609D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020609D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020609D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020609D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MunichSwivelChairYellow(), 10, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020610D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020610D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020610D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020610D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 7, '', 97.5); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MoscowSwivelChairRed(), 5, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020610D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020610D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020610D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020610D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MexicoSwivelChairBlack(), 8, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020611D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020611D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020611D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020611D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.BerlingGuestChairYellow(), 10, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020612D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020612D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020612D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020612D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 15, '', 506.6); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020613D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020613D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020613D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020613D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AmsterdamLamp(), 13, '', 27.8); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020613D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020613D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020613D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020613D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.RomeGuestChairGreen(), 8, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020613D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020613D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020613D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020613D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AtlantAWhiteboardBase(), 9, '', 707.2); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020614D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020614D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020614D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020614D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.TokyoGuestChairBlue(), 5, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020615D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020615D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020615D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020615D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensMobilePedestal(), 5, '', 219.5); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SydneySwivelChairGreen(), 7, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020708D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020708D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020708D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020708D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.LondonSwivelChairBlue(), 4, '', 96.1); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SeoulGuestChairRed(), 3, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020708D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020708D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020708D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020708D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AntwerpConferenceTable(), 5, '', 328); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020709D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020709D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020709D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020709D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MunichSwivelChairYellow(), 6, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020710D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020710D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020710D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020710D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MexicoSwivelChairBlack(), 7, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020711D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020711D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020711D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020711D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 8, '', 97.5); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MoscowSwivelChairRed(), 4, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020711D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020711D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020711D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020711D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.BerlingGuestChairYellow(), 8, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020712D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020712D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020712D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020712D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 10, '', 506.6); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020713D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020713D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020713D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020713D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.RomeGuestChairGreen(), 7, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020714D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020714D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020714D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020714D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AmsterdamLamp(), 11, '', 27.8); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020714D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020714D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020714D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020714D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AtlantAWhiteboardBase(), 7, '', 707.2); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020715D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020715D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020715D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020715D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.TokyoGuestChairBlue(), 4, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020715D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020715D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020715D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020715D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SydneySwivelChairGreen(), 5, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020716D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020716D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020716D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020716D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensMobilePedestal(), 7, '', 219.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020808D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020808D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020808D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020808D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.LondonSwivelChairBlue(), 6, '', 96.1); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SeoulGuestChairRed(), 4, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020808D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020808D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020808D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020808D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AntwerpConferenceTable(), 6, '', 328); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020809D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020809D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020809D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020809D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MunichSwivelChairYellow(), 6, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020810D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020810D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020810D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020810D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MexicoSwivelChairBlack(), 8, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020811D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020811D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020811D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020811D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 8, '', 97.5); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MoscowSwivelChairRed(), 4, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020811D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020811D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020811D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020811D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.BerlingGuestChairYellow(), 9, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020812D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020812D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020812D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020812D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 11, '', 506.6); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020813D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020813D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020813D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020813D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.RomeGuestChairGreen(), 7, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020814D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020814D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020814D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020814D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AmsterdamLamp(), 10, '', 27.8); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020814D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020814D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020814D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020814D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AtlantAWhiteboardBase(), 9, '', 707.2); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020815D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020815D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020815D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020815D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.TokyoGuestChairBlue(), 6, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020815D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020815D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020815D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020815D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SydneySwivelChairGreen(), 7, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020816D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020816D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020816D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020816D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensMobilePedestal(), 7, '', 219.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020908D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020908D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020908D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020908D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.LondonSwivelChairBlue(), 4, '', 96.1); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SeoulGuestChairRed(), 4, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020908D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020908D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020908D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020908D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AntwerpConferenceTable(), 4, '', 328); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020909D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020909D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020909D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020909D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MunichSwivelChairYellow(), 5, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020910D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020910D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020910D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020910D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 4, '', 97.5); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MoscowSwivelChairRed(), 3, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020910D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020910D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020910D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020910D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MexicoSwivelChairBlack(), 5, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020911D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020911D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020911D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020911D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.BerlingGuestChairYellow(), 7, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020912D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020912D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020912D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020912D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 9, '', 506.6); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020913D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020913D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020913D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020913D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AmsterdamLamp(), 9, '', 27.8); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020913D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020913D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020913D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020913D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.RomeGuestChairGreen(), 5, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020913D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020913D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020913D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020913D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AtlantAWhiteboardBase(), 7, '', 707.2); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020914D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020914D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020914D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020914D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.TokyoGuestChairBlue(), 4, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020915D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020915D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19020915D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19020915D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensMobilePedestal(), 3, '', 219.5); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SydneySwivelChairGreen(), 5, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021008D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021008D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021008D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021008D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.LondonSwivelChairBlue(), 4, '', 96.1); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SeoulGuestChairRed(), 5, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021008D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021008D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021008D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021008D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AntwerpConferenceTable(), 4, '', 328); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021009D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021009D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021009D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021009D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MunichSwivelChairYellow(), 7, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021010D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021010D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021010D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021010D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MexicoSwivelChairBlack(), 9, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021011D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021011D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021011D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021011D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 6, '', 97.5); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MoscowSwivelChairRed(), 3, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021011D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021011D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021011D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021011D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.BerlingGuestChairYellow(), 9, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021012D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021012D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021012D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021012D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 9, '', 506.6); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021013D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021013D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021013D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021013D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.RomeGuestChairGreen(), 6, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021014D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021014D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021014D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021014D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AmsterdamLamp(), 10, '', 27.8); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021014D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021014D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021014D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021014D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AtlantAWhiteboardBase(), 7, '', 707.2); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021015D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021015D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021015D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021015D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.TokyoGuestChairBlue(), 4, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021015D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021015D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021015D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021015D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SydneySwivelChairGreen(), 6, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021016D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021016D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021016D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021016D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensMobilePedestal(), 10, '', 219.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021108D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021108D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021108D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021108D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.LondonSwivelChairBlue(), 4, '', 96.1); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SeoulGuestChairRed(), 5, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021108D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021108D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021108D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021108D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AntwerpConferenceTable(), 4, '', 328); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021109D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021109D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021109D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021109D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MunichSwivelChairYellow(), 5, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021110D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021110D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021110D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021110D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 7, '', 97.5); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MoscowSwivelChairRed(), 3, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021110D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021110D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021110D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021110D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MexicoSwivelChairBlack(), 6, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021111D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021111D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021111D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021111D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.BerlingGuestChairYellow(), 7, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021112D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021112D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021112D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021112D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 8, '', 506.6); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021113D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021113D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021113D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021113D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AmsterdamLamp(), 9, '', 27.8); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021113D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021113D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021113D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021113D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.RomeGuestChairGreen(), 6, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021113D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021113D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021113D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021113D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AtlantAWhiteboardBase(), 6, '', 707.2); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021114D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021114D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021114D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021114D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.TokyoGuestChairBlue(), 4, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021115D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021115D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021115D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021115D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensMobilePedestal(), 6, '', 219.5); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SydneySwivelChairGreen(), 5, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021208D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021208D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021208D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021208D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.LondonSwivelChairBlue(), 3, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021208D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021208D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021208D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021208D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AntwerpConferenceTable(), 2, '', 328); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021209D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021209D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021209D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021209D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MunichSwivelChairYellow(), 3, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021209D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021209D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021209D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021209D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SeoulGuestChairRed(), 3, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021210D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021210D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021210D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021210D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MexicoSwivelChairBlack(), 4, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021211D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021211D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021211D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021211D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 3, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021211D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021211D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021211D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021211D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.BerlingGuestChairYellow(), 5, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021212D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021212D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021212D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021212D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 6, '', 506.6); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MoscowSwivelChairRed(), 2, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021212D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021212D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021212D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021212D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SydneySwivelChairGreen(), 3, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021213D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021213D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021213D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021213D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.RomeGuestChairGreen(), 4, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021214D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021214D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021214D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021214D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AmsterdamLamp(), 6, '', 27.8); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021214D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021214D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021214D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021214D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AtlantAWhiteboardBase(), 4, '', 707.2); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021215D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021215D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021215D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021215D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.TokyoGuestChairBlue(), 2, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021216D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021216D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19021216D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19021216D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensMobilePedestal(), 2, '', 219.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030108D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030108D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030108D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030108D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.LondonSwivelChairBlue(), 5, '', 96.1); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SeoulGuestChairRed(), 5, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030108D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030108D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030108D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030108D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AntwerpConferenceTable(), 6, '', 328); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030109D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030109D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030109D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030109D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MunichSwivelChairYellow(), 6, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030110D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030110D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030110D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030110D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MexicoSwivelChairBlack(), 7, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030111D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030111D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030111D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030111D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 8, '', 97.5); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MoscowSwivelChairRed(), 4, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030111D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030111D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030111D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030111D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.BerlingGuestChairYellow(), 9, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030112D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030112D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030112D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030112D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 10, '', 506.6); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030113D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030113D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030113D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030113D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.RomeGuestChairGreen(), 7, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030114D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030114D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030114D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030114D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AmsterdamLamp(), 11, '', 27.8); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030114D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030114D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030114D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030114D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AtlantAWhiteboardBase(), 7, '', 707.2); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030115D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030115D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030115D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030115D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.TokyoGuestChairBlue(), 6, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030115D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030115D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030115D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030115D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SydneySwivelChairGreen(), 5, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030116D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030116D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030116D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030116D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensMobilePedestal(), 6, '', 219.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030208D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030208D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030208D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030208D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.LondonSwivelChairBlue(), 6, '', 96.1); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SeoulGuestChairRed(), 6, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030208D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030208D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030208D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030208D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AntwerpConferenceTable(), 6, '', 328); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030209D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030209D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030209D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030209D), CreatePaymentMethod.Cash(), CreatePurchaser.RobinBettencourt()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MunichSwivelChairYellow(), 7, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030210D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030210D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030210D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030210D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.ParisGuestChairBlack(), 12, '', 97.5); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MoscowSwivelChairRed(), 4, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030210D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030210D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.ExportFabrikam(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030210D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030210D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.BerlingGuestChairYellow(), 11, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030210D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030210D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030210D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030210D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.MexicoSwivelChairBlack(), 6, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030212D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030212D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticNodPublisher(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030212D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030212D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensDesk(), 15, '', 506.6); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030212D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030212D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticFirstUp(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030212D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030212D), CreatePaymentMethod.Cash(), CreatePurchaser.LinaTownsend()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.RomeGuestChairGreen(), 8, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030213D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030213D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030213D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030213D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AmsterdamLamp(), 13, '', 27.8); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030213D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030213D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030213D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030213D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AtlantAWhiteboardBase(), 10, '', 707.2); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030214D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030214D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.DomesticWorldImporter(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030214D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030214D), CreatePaymentMethod.Cash(), CreatePurchaser.JimOlive()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.TokyoGuestChairBlue(), 5, '', 97.5); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030214D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030214D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030214D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030214D), CreatePaymentMethod.Cash(), CreatePurchaser.BenjaminChiu()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.SydneySwivelChairGreen(), 7, '', 96.1); - PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030215D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030215D), CreatePaymentMethod.Cash()); + PurchaseHeader := ContosoPurchase.InsertPurchaseHeader(Enum::"Purchase Document Type"::Invoice, CreateVendor.EUGraphicDesign(), '', ContosoUtilities.AdjustDate(19020101D), ContosoUtilities.AdjustDate(19030215D), ContosoUtilities.AdjustDate(19020101D), CreatePaymentTerms.PaymentTermsCOD(), '', '', '', ContosoUtilities.AdjustDate(19030215D), CreatePaymentMethod.Cash(), CreatePurchaser.OtisFalls()); ContosoPurchase.InsertPurchaseLineWithItem(PurchaseHeader, CreateItem.AthensMobilePedestal(), 10, '', 219.5); CreatePurchaseInvoicesForReconciliation(); @@ -564,4 +566,4 @@ codeunit 5420 "Create Purchase Document" var OpenYourReferenceTok: Label 'OPEN', MaxLength = 35; ReconciliationYourReferenceTok: Label 'RECONCILE', MaxLength = 35; -} +} \ No newline at end of file diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Purchases/PurchaseModule.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Purchases/PurchaseModule.Codeunit.al index abfeaad81a..e52d639451 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Purchases/PurchaseModule.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoData/Purchases/PurchaseModule.Codeunit.al @@ -32,6 +32,7 @@ codeunit 5394 "Purchase Module" implements "Contoso Demo Data Module" begin Codeunit.Run(codeunit::"Create Purchase Payable Setup"); Codeunit.Run(codeunit::"Create Vendor Posting Group"); + Codeunit.Run(Codeunit::"Create Return Reason"); end; procedure CreateMasterData() diff --git a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoPurchase.Codeunit.al b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoPurchase.Codeunit.al index f5fc4e8902..59868f6c77 100644 --- a/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoPurchase.Codeunit.al +++ b/Apps/W1/ContosoCoffeeDemoDataset/app/DemoTool/Contoso Helpers/ContosoPurchase.Codeunit.al @@ -4,6 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.DemoTool.Helpers; +using Microsoft.Foundation.AuditCodes; using Microsoft.Inventory.Item; using Microsoft.Pricing.Calculation; using Microsoft.Projects.Resources.Resource; @@ -22,15 +23,25 @@ codeunit 4781 "Contoso Purchase" procedure InsertPurchaseHeader(DocumentType: Enum "Purchase Document Type"; VendorNo: Code[20]; VendorOrderNo: Code[20]; PostingDate: Date; LocationCode: Code[20]): Record "Purchase Header" begin - exit(InsertPurchaseHeader(DocumentType, VendorNo, '', PostingDate, PostingDate, 0D, '', CopyStr(LocationCode, 1, 10), VendorOrderNo, '', PostingDate, '')); + exit(InsertPurchaseHeader(DocumentType, VendorNo, '', PostingDate, PostingDate, 0D, '', CopyStr(LocationCode, 1, 10), VendorOrderNo, '', PostingDate, '', '')); end; procedure InsertPurchaseHeader(DocumentType: Enum "Purchase Document Type"; VendorNo: Code[20]; YourReference: Code[35]; VendorOrderNo: Code[20]; PostingDate: Date; LocationCode: Code[10]; VendorInvoiceNo: Code[35]; PaymentTermsCode: Code[10]; PaymentMethodCode: Code[10]): Record "Purchase Header" begin - exit(InsertPurchaseHeader(DocumentType, VendorNo, YourReference, PostingDate, PostingDate, 0D, PaymentTermsCode, CopyStr(LocationCode, 1, 10), VendorOrderNo, VendorInvoiceNo, PostingDate, PaymentMethodCode)); + exit(InsertPurchaseHeader(DocumentType, VendorNo, YourReference, PostingDate, PostingDate, 0D, PaymentTermsCode, CopyStr(LocationCode, 1, 10), VendorOrderNo, VendorInvoiceNo, PostingDate, PaymentMethodCode, '')); end; procedure InsertPurchaseHeader(DocumentType: Enum "Purchase Document Type"; BuyfromVendorNo: Code[20]; YourReference: Code[35]; OrderDate: Date; PostingDate: Date; ExpectedReceiptDate: Date; PaymentTermsCode: Code[10]; LocationCode: Code[10]; VendorOrderNo: Code[20]; VendorInvoiceNo: Code[35]; DocumentDate: Date; PaymentMethodCode: Code[10]): Record "Purchase Header"; + begin + exit(InsertPurchaseHeader(DocumentType, BuyfromVendorNo, YourReference, PostingDate, PostingDate, 0D, PaymentTermsCode, CopyStr(LocationCode, 1, 10), VendorOrderNo, VendorInvoiceNo, PostingDate, PaymentMethodCode, '')); + end; + + procedure InsertPurchaseHeader(DocumentType: Enum "Purchase Document Type"; BuyfromVendorNo: Code[20]; YourReference: Code[35]; OrderDate: Date; PostingDate: Date; ExpectedReceiptDate: Date; PaymentTermsCode: Code[10]; LocationCode: Code[10]; VendorOrderNo: Code[20]; VendorInvoiceNo: Code[35]; DocumentDate: Date; PaymentMethodCode: Code[10]; PurchaserCode: Code[20]): Record "Purchase Header"; + begin + exit(InsertPurchaseHeader(DocumentType, BuyfromVendorNo, YourReference, PostingDate, PostingDate, 0D, PaymentTermsCode, CopyStr(LocationCode, 1, 10), VendorOrderNo, VendorInvoiceNo, '', PostingDate, PaymentMethodCode, '')); + end; + + procedure InsertPurchaseHeader(DocumentType: Enum "Purchase Document Type"; BuyfromVendorNo: Code[20]; YourReference: Code[35]; OrderDate: Date; PostingDate: Date; ExpectedReceiptDate: Date; PaymentTermsCode: Code[10]; LocationCode: Code[10]; VendorOrderNo: Code[20]; VendorInvoiceNo: Code[35]; VendorCrMemoNo: Code[35]; DocumentDate: Date; PaymentMethodCode: Code[10]; PurchaserCode: Code[20]): Record "Purchase Header"; var PurchaseHeader: Record "Purchase Header"; begin @@ -49,11 +60,17 @@ codeunit 4781 "Contoso Purchase" PurchaseHeader.Validate("Vendor Order No.", VendorOrderNo); + if PurchaserCode <> '' then + PurchaseHeader.Validate("Purchaser Code", PurchaserCode); + if VendorInvoiceNo <> '' then PurchaseHeader.Validate("Vendor Invoice No.", VendorInvoiceNo) else PurchaseHeader.Validate("Vendor Invoice No.", PurchaseHeader."No."); + if VendorCrMemoNo <> '' then + PurchaseHeader.Validate("Vendor Cr. Memo No.", VendorCrMemoNo); + PurchaseHeader.Validate("Document Date", DocumentDate); PurchaseHeader.Validate("Payment Method Code", PaymentMethodCode); PurchaseHeader.Modify(true); @@ -63,15 +80,25 @@ codeunit 4781 "Contoso Purchase" procedure InsertPurchaseLineWithItem(PurchaseHeader: Record "Purchase Header"; ItemNo: Code[20]; Quantity: Decimal) begin - InsertPurchaseLineWithItem(PurchaseHeader, ItemNo, Quantity, '', 0); + InsertPurchaseLineWithItem(PurchaseHeader, ItemNo, Quantity, '', 0, ''); end; procedure InsertPurchaseLineWithItem(PurchaseHeader: Record "Purchase Header"; ItemNo: Code[20]; Quantity: Decimal; UnitOfMeasureCode: Code[10]; UnitCost: Decimal) begin - InsertPurchaseLineWithItem(PurchaseHeader, ItemNo, Quantity, UnitOfMeasureCode, UnitCost, 0); + InsertPurchaseLineWithItem(PurchaseHeader, ItemNo, Quantity, UnitOfMeasureCode, UnitCost, 0, ''); + end; + + procedure InsertPurchaseLineWithItem(PurchaseHeader: Record "Purchase Header"; ItemNo: Code[20]; Quantity: Decimal; UnitOfMeasureCode: Code[10]; UnitCost: Decimal; ReturnReasonCode: Code[10]) + begin + InsertPurchaseLineWithItem(PurchaseHeader, ItemNo, Quantity, UnitOfMeasureCode, UnitCost, 0, ReturnReasonCode); end; procedure InsertPurchaseLineWithItem(PurchaseHeader: Record "Purchase Header"; ItemNo: Code[20]; Quantity: Decimal; UnitOfMeasureCode: Code[10]; UnitCost: Decimal; LineDiscount: Decimal) + begin + InsertPurchaseLineWithItem(PurchaseHeader, ItemNo, Quantity, UnitOfMeasureCode, UnitCost, LineDiscount, ''); + end; + + procedure InsertPurchaseLineWithItem(PurchaseHeader: Record "Purchase Header"; ItemNo: Code[20]; Quantity: Decimal; UnitOfMeasureCode: Code[10]; UnitCost: Decimal; LineDiscount: Decimal; ReturnReasonCode: Code[10]) var Item: Record Item; PurchaseLine: Record "Purchase Line"; @@ -95,6 +122,8 @@ codeunit 4781 "Contoso Purchase" PurchaseLine.Validate(Quantity, Quantity); PurchaseLine.Validate("Line Discount %", LineDiscount); + if ReturnReasonCode <> '' then + PurchaseLine.Validate("Return Reason Code", ReturnReasonCode); PurchaseLine.Insert(true); end; @@ -122,8 +151,8 @@ codeunit 4781 "Contoso Purchase" procedure InsertPurchaseLineWithResource(PurchaseHeader: Record "Purchase Header"; ResourceNo: Code[20]; Quantity: Decimal) var - Resource: Record Resource; PurchaseLine: Record "Purchase Line"; + Resource: Record Resource; begin PurchaseLine.Validate("Document Type", PurchaseHeader."Document Type"); PurchaseLine.Validate("Document No.", PurchaseHeader."No."); @@ -191,4 +220,14 @@ codeunit 4781 "Contoso Purchase" PurchasesPayablesSetup.Validate("Price List Nos.", PriceListNos); PurchasesPayablesSetup.Modify(true); end; + + procedure InsertReturnReason(ReturnReasonCode: Code[10]; ReturnReasonDescription: Text[50]) + var + ReturnReason: Record "Return Reason"; + begin + ReturnReason.Init(); + ReturnReason.Validate(Code, ReturnReasonCode); + ReturnReason.Validate(Description, ReturnReasonDescription); + ReturnReason.Insert(true); + end; } diff --git a/Apps/W1/EDocumentConnectors/Microsoft365/app/src/OutlookProcessing.Codeunit.al b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/OutlookProcessing.Codeunit.al index f04a7528d9..5106c6b506 100644 --- a/Apps/W1/EDocumentConnectors/Microsoft365/app/src/OutlookProcessing.Codeunit.al +++ b/Apps/W1/EDocumentConnectors/Microsoft365/app/src/OutlookProcessing.Codeunit.al @@ -6,7 +6,6 @@ namespace Microsoft.EServices.EDocumentConnector.Microsoft365; using Microsoft.EServices.EDocument; using Microsoft.eServices.EDocument.Integration.Receive; -using Microsoft.eServices.EDocument.Processing.Import; using System.Email; using System.IO; using System.Telemetry; @@ -259,6 +258,9 @@ codeunit 6385 "Outlook Processing" local procedure IgnoreMailAttachment(EmailMessage: Codeunit "Email Message"; ExternalMessageId: Text[2048]; var IgnoredBecauseExisting: Integer): Boolean var EDocument: Record "E-Document"; + TempBlob: Codeunit "Temp Blob"; + InStream: InStream; + ExceedsPageCountThreshold: Boolean; begin if IgnoreMailAttachment(EmailMessage.Attachments_GetLength(), EmailMessage.Attachments_GetContentType(), EmailMessage.Attachments_GetName()) then exit(true); @@ -272,6 +274,14 @@ codeunit 6385 "Outlook Processing" exit(true); end; + TempBlob.CreateInStream(InStream, TextEncoding::UTF8); + EmailMessage.Attachments_GetContent(InStream); + if not DocumentExceedsPageCountThreshold(InStream, ExceedsPageCountThreshold) then + Session.LogMessage('0000PMR', PageCountCallFailedTelemetryTxt, Verbosity::Warning, DataClassification::SystemMetadata, TelemetryScope::All, 'Category', FeatureName()); + if ExceedsPageCountThreshold then begin + Session.LogMessage('0000PKT', StrSubstNo(PageCountExceededTelemetryTxt, Format(PageCountThreshold())), Verbosity::Warning, DataClassification::SystemMetadata, TelemetryScope::All, 'Category', FeatureName()); + exit(true) + end; exit(false) end; @@ -302,7 +312,6 @@ codeunit 6385 "Outlook Processing" ReceivedDateTime: DateTime; MessageIdGuid, ExternalMessageIdGuid : Guid; ContentId: Text[2048]; - ExceedsPageCountThreshold: Boolean; begin CheckSetupEnabled(OutlookSetup); @@ -339,20 +348,11 @@ codeunit 6385 "Outlook Processing" AttachmentFound := true; TempBlob.CreateInStream(InStream, TextEncoding::UTF8); EmailMessage.Attachments_GetContent(InStream); - if not DocumentExceedsPageCountThreshold(InStream, ExceedsPageCountThreshold) then - Session.LogMessage('0000PMR', PageCountCallFailedTelemetryTxt, Verbosity::Warning, DataClassification::SystemMetadata, TelemetryScope::All, 'Category', FeatureName()); - if ExceedsPageCountThreshold then begin - Session.LogMessage('0000PKT', StrSubstNo(PageCountExceededTelemetryTxt, Format(PageCountThreshold())), Verbosity::Warning, DataClassification::SystemMetadata, TelemetryScope::All, 'Category', FeatureName()); - EDocument."Structure Data Impl." := "Structure Received E-Doc."::"Already Structured"; - EDocument."Read into Draft Impl." := "E-Doc. Read Into Draft"::"Blank Draft"; - EDocumentErrorHelper.LogWarningMessage(EDocument, EDocument, EDocument.FieldNo("Structured Data Entry No."), StrSubstNo(PageCountExceededTxt, FileId, Format(PageCountThreshold()))); - end else begin - ReceiveContext.SetFileFormat("E-Doc. File Format"::PDF); - ReceiveContext.GetTempBlob().CreateOutStream(DocumentOutStream, TextEncoding::UTF8); - CopyStream(DocumentOutStream, InStream); - if not ReceiveContext.GetTempBlob().HasValue() then - EDocumentErrorHelper.LogSimpleErrorMessage(EDocument, StrSubstNo(NoContentErr, FileId)); - end; + ReceiveContext.SetFileFormat("E-Doc. File Format"::PDF); + ReceiveContext.GetTempBlob().CreateOutStream(DocumentOutStream, TextEncoding::UTF8); + CopyStream(DocumentOutStream, InStream); + if not ReceiveContext.GetTempBlob().HasValue() then + EDocumentErrorHelper.LogSimpleErrorMessage(EDocument, StrSubstNo(NoContentErr, FileId)); EDocument.Modify(); end; until (EmailMessage.Attachments_Next() = 0) or AttachmentFound; @@ -428,7 +428,6 @@ codeunit 6385 "Outlook Processing" TooManyAttachmentsTxt: Label 'E-mail with more than %1 attachments is ignored.', Comment = '%1 - an integer (10)'; RetrieveEmailsErr: Label 'Failed to retrieve emails from the email connector.'; ProcessingEmailTxt: label 'Processing email.', Locked = true; - PageCountExceededTxt: Label 'Attachment %1 was ignored because it exceeds the feature limit of %2 pages.', Comment = '%1 - file name, %2 - an integer'; PageCountExceededTelemetryTxt: label 'PDF Attachment ignored because it exceeds page count of %1.', Locked = true; PageCountCallFailedTelemetryTxt: label 'Unable to calculate page count for PDF Attachment.', Locked = true; } \ No newline at end of file diff --git a/Apps/W1/Email - Current User Connector/app/src/CurrentUserConnector.Codeunit.al b/Apps/W1/Email - Current User Connector/app/src/CurrentUserConnector.Codeunit.al index 1126a7ade6..49604e896b 100644 --- a/Apps/W1/Email - Current User Connector/app/src/CurrentUserConnector.Codeunit.al +++ b/Apps/W1/Email - Current User Connector/app/src/CurrentUserConnector.Codeunit.al @@ -8,7 +8,7 @@ namespace System.Email; using System.Environment; using System.Security.AccessControl; -codeunit 4500 "Current User Connector" implements "Default Email Rate Limit", "Email Connector v4" +codeunit 4500 "Current User Connector" implements "Default Email Rate Limit", "Email Connector v5" { Access = Internal; Permissions = tabledata "Email - Outlook Account" = rimd; @@ -141,4 +141,19 @@ codeunit 4500 "Current User Connector" implements "Default Email Rate Limit", "E begin exit(EmailOutlookAPIHelper.DefaultEmailRateLimit()); end; + + procedure GetEmailCategories(AccountId: Guid; var EmailCategories: Record "Email Categories" temporary) + begin + EmailOutlookAPIHelper.GetEmailCategories(AccountId, EmailCategories); + end; + + procedure CreateEmailCategory(AccountId: Guid; CategoryDisplayName: Text; CategoryColor: Text): Text + begin + exit(EmailOutlookAPIHelper.CreateEmailCategory(AccountId, CategoryDisplayName, CategoryColor)); + end; + + procedure ApplyEmailCategory(AccountId: Guid; ExternalId: Text; Categories: List of [Text]) + begin + EmailOutlookAPIHelper.ApplyEmailCategory(AccountId, ExternalId, Categories); + end; } \ No newline at end of file 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 7e2bae02eb..c927e17559 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 @@ -6,7 +6,7 @@ namespace System.Email; -codeunit 4503 "Microsoft 365 Connector" implements "Default Email Rate Limit", "Email Connector v4" +codeunit 4503 "Microsoft 365 Connector" implements "Default Email Rate Limit", "Email Connector v5" { Access = Internal; Permissions = tabledata "Email - Outlook Account" = r; @@ -103,4 +103,19 @@ codeunit 4503 "Microsoft 365 Connector" implements "Default Email Rate Limit", " begin exit(EmailOutlookAPIHelper.DefaultEmailRateLimit()); end; + + procedure GetEmailCategories(AccountId: Guid; var EmailCategories: Record "Email Categories" temporary) + begin + EmailOutlookAPIHelper.GetEmailCategories(AccountId, EmailCategories); + end; + + procedure CreateEmailCategory(AccountId: Guid; CategoryDisplayName: Text; CategoryColor: Text): Text + begin + exit(EmailOutlookAPIHelper.CreateEmailCategory(AccountId, CategoryDisplayName, CategoryColor)); + end; + + procedure ApplyEmailCategory(AccountId: Guid; ExternalId: Text; Categories: List of [Text]) + begin + EmailOutlookAPIHelper.ApplyEmailCategory(AccountId, ExternalId, Categories); + end; } \ No newline at end of file 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 48ae22c206..4e2e8a5b73 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,12 +10,12 @@ using System.Text; using System.Utilities; #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", "Email - Outlook API Client v5" +codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Client v2", "Email - Outlook API Client v3", "Email - Outlook API Client v4", "Email - Outlook API Client v5", "Email - Outlook API Client v6" #else #if not CLEAN28 -codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Client v2", "Email - Outlook API Client v4", "Email - Outlook API Client v5" +codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Client v2", "Email - Outlook API Client v4", "Email - Outlook API Client v5", "Email - Outlook API Client v6" #else -codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Client v5" +codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Client v5", "Email - Outlook API Client v6" #endif #endif { @@ -69,6 +69,7 @@ codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Clien TelemetryMarkingEmailAsReadTxt: Label 'Marking email as read.', Locked = true; TelemetryFailedToDeleteDraftEmailTxt: Label 'Failed to delete draft message.', Locked = true; TelemetryFailedStatusCodeTxt: Label 'Failed with status code %1.', Comment = '%1 - Http status code', Locked = true; + GetEmailCategoriesUriTxt: Label '/v1.0/users/%1/outlook/masterCategories', Locked = true; [NonDebuggable] @@ -372,6 +373,8 @@ codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Clien FilterParameters := FilterParameters + 'isDraft ne true and '; if Filters."Earliest Email" <> 0DT then FilterParameters := FilterParameters + 'receivedDateTime ge ' + Format(Filters."Earliest Email", 0, 9) + ' and '; + if Filters.GetCategoryFilters().Count() > 0 then + FilterParameters := FilterParameters + GetCategoryFilter(Filters.GetCategoryFilters(), Filters."Category Filter Type" = Filters."Category Filter Type"::Exclude) + ' and '; if FilterParameters <> '$filter=' then begin QueryParameters := QueryParameters + FilterParameters; @@ -410,6 +413,27 @@ codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Clien exit(true); end; + local procedure GetCategoryFilter(CategoryFilters: List of [Text]; Exclude: Boolean): Text + var + CategoryFilter: Text; + FilterText: Text; + begin + // Build filter: categories/any(c:c eq 'cat1' or c eq 'cat2' or c eq 'cat3') + // Or for exclude: not(categories/any(c:c eq 'cat1' or c eq 'cat2' or c eq 'cat3')) + foreach CategoryFilter in CategoryFilters do begin + if FilterText <> '' then + if Exclude then + FilterText := FilterText + ' and ' + else + FilterText := FilterText + ' or '; + if Exclude then + FilterText := FilterText + 'not(categories/any(c:c eq ''' + CategoryFilter + '''))' + else + FilterText := FilterText + 'categories/any(c:c eq ''' + CategoryFilter + ''')'; + end; + exit(FilterText); + end; + local procedure SendReplyEmailRequest(AccessToken: SecretText; EmailAddress: Text[250]; ExternalMessageId: Text; MessageJsonText: Text): Boolean var MessageJson: JsonObject; @@ -425,6 +449,7 @@ codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Clien AddAttachmentsToDraft(AccessToken, EmailAddress, ExternalMessageId, AttachmentsJsonArray); end; + MessageJson.WriteTo(MessageJsonText); UpdateDraftMessage(AccessToken, EmailAddress, ExternalMessageId, MessageJsonText); SendDraftMail(AccessToken, EmailAddress, ExternalMessageId); end; @@ -984,4 +1009,180 @@ codeunit 4508 "Email - Outlook API Client" implements "Email - Outlook API Clien begin exit(3145728); // 3 mb end; + + procedure GetEmailCategories(AccessToken: SecretText; OutlookAccount: Record "Email - Outlook Account"): JsonArray + var + MailHttpRequestMessage: HttpRequestMessage; + MailHttpResponseMessage: HttpResponseMessage; + HttpErrorMessage: Text; + RequestUri: Text; + JsonContent: Text; + ResponseJsonObject: JsonObject; + CategoriesArray: JsonArray; + JsonToken: JsonToken; + begin + RequestUri := GraphURLTxt + StrSubstNo(GetEmailCategoriesUriTxt, OutlookAccount."Email Address"); + + CreateRequest('GET', RequestUri, AccessToken, MailHttpRequestMessage); + + SendRequest(MailHttpRequestMessage, MailHttpResponseMessage); + + if MailHttpResponseMessage.HttpStatusCode <> 200 then begin + HttpErrorMessage := GetHttpErrorMessageAsText(MailHttpResponseMessage); + Session.LogMessage('0000RHR', StrSubstNo(TelemetryFailedStatusCodeTxt, Format(MailHttpResponseMessage.HttpStatusCode)), Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', OutlookCategoryLbl); + ProcessRetrieveErrorMessageResponse(HttpErrorMessage, Format(MailHttpResponseMessage.HttpStatusCode)); + end; + + if not MailHttpResponseMessage.Content.ReadAs(JsonContent) then begin + Session.LogMessage('0000RHS', FailedToReadResponseContentErr, Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', OutlookCategoryLbl); + exit; + end; + + if not ResponseJsonObject.ReadFrom(JsonContent) then begin + Session.LogMessage('0000RHT', FailedToReadResponseContentErr, Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', OutlookCategoryLbl); + exit; + end; + + ResponseJsonObject.Get('value', JsonToken); + CategoriesArray := JsonToken.AsArray(); + + exit(CategoriesArray); + end; + + procedure CreateEmailCategory(AccessToken: SecretText; OutlookAccount: Record "Email - Outlook Account"; CategoryDisplayName: Text; CategoryColor: Text): Text + var + MailHttpRequestMessage: HttpRequestMessage; + MailHttpResponseMessage: HttpResponseMessage; + MailContent: HttpContent; + MailContentHeaders: HttpHeaders; + HttpErrorMessage: Text; + RequestUri: Text; + JsonContent: Text; + ResponseJsonObject: JsonObject; + RequestJsonObject: JsonObject; + JsonToken: JsonToken; + begin + RequestUri := GraphURLTxt + StrSubstNo(GetEmailCategoriesUriTxt, OutlookAccount."Email Address"); + + RequestJsonObject.Add('displayName', CategoryDisplayName); + if CategoryColor <> '' then + RequestJsonObject.Add('color', CategoryColor); + RequestJsonObject.WriteTo(JsonContent); + + MailContent.WriteFrom(JsonContent); + MailContent.GetHeaders(MailContentHeaders); + MailContentHeaders.Remove('Content-Type'); + MailContentHeaders.Add('Content-Type', 'application/json'); + + CreateRequest('POST', RequestUri, AccessToken, MailHttpRequestMessage); + MailHttpRequestMessage.Content := MailContent; + + SendRequest(MailHttpRequestMessage, MailHttpResponseMessage); + + if MailHttpResponseMessage.HttpStatusCode <> 201 then begin + HttpErrorMessage := GetHttpErrorMessageAsText(MailHttpResponseMessage); + Session.LogMessage('0000RHU', StrSubstNo(TelemetryFailedStatusCodeTxt, Format(MailHttpResponseMessage.HttpStatusCode)), Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', OutlookCategoryLbl); + Error(HttpErrorMessage); + end; + + if not MailHttpResponseMessage.Content.ReadAs(JsonContent) then begin + Session.LogMessage('0000RHV', FailedToReadResponseContentErr, Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', OutlookCategoryLbl); + exit(''); + end; + + if not ResponseJsonObject.ReadFrom(JsonContent) then begin + Session.LogMessage('0000RHW', FailedToReadResponseContentErr, Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', OutlookCategoryLbl); + exit(''); + end; + + ResponseJsonObject.Get('id', JsonToken); + exit(JsonToken.AsValue().AsText()); + end; + + procedure ApplyEmailCategory(AccessToken: SecretText; OutlookAccount: Record "Email - Outlook Account"; ExternalMessageId: Text; Categories: List of [Text]) + var + MailHttpRequestMessage: HttpRequestMessage; + MailHttpResponseMessage: HttpResponseMessage; + MailContent: HttpContent; + MailContentHeaders: HttpHeaders; + HttpErrorMessage: Text; + RequestUri: Text; + JsonContent: Text; + RequestJsonObject: JsonObject; + CategoriesArray: JsonArray; + ExistingCategories: List of [Text]; + Category: Text; + begin + RequestUri := GraphURLTxt + StrSubstNo(MarkAsReadUriTxt, OutlookAccount."Email Address", ExternalMessageId); + + // Get existing categories from the email first + ExistingCategories := GetEmailMessageCategories(AccessToken, OutlookAccount, ExternalMessageId); + + // Add existing categories to the array + foreach Category in ExistingCategories do + CategoriesArray.Add(Category); + + // Add new categories if they don't already exist + foreach Category in Categories do + if not ExistingCategories.Contains(Category) then + CategoriesArray.Add(Category); + + RequestJsonObject.Add('categories', CategoriesArray); + RequestJsonObject.WriteTo(JsonContent); + + MailContent.WriteFrom(JsonContent); + MailContent.GetHeaders(MailContentHeaders); + MailContentHeaders.Remove('Content-Type'); + MailContentHeaders.Add('Content-Type', 'application/json'); + + CreateRequest('PATCH', RequestUri, AccessToken, MailHttpRequestMessage); + MailHttpRequestMessage.Content := MailContent; + + SendRequest(MailHttpRequestMessage, MailHttpResponseMessage); + + if MailHttpResponseMessage.HttpStatusCode <> 200 then begin + HttpErrorMessage := GetHttpErrorMessageAsText(MailHttpResponseMessage); + Session.LogMessage('0000RHX', StrSubstNo(TelemetryFailedStatusCodeTxt, Format(MailHttpResponseMessage.HttpStatusCode)), Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', OutlookCategoryLbl); + Error(HttpErrorMessage); + end; + end; + + local procedure GetEmailMessageCategories(AccessToken: SecretText; OutlookAccount: Record "Email - Outlook Account"; ExternalMessageId: Text): List of [Text] + var + MailHttpRequestMessage: HttpRequestMessage; + MailHttpResponseMessage: HttpResponseMessage; + RequestUri: Text; + JsonContent: Text; + ResponseJsonObject: JsonObject; + CategoriesArray: JsonArray; + JsonToken: JsonToken; + CategoryToken: JsonToken; + Categories: List of [Text]; + i: Integer; + begin + // Request only the categories field to minimize data transfer + RequestUri := GraphURLTxt + StrSubstNo(MarkAsReadUriTxt, OutlookAccount."Email Address", ExternalMessageId) + '?$select=categories'; + + CreateRequest('GET', RequestUri, AccessToken, MailHttpRequestMessage); + SendRequest(MailHttpRequestMessage, MailHttpResponseMessage); + + if MailHttpResponseMessage.HttpStatusCode <> 200 then + exit(Categories); + + if not MailHttpResponseMessage.Content.ReadAs(JsonContent) then + exit(Categories); + + if not ResponseJsonObject.ReadFrom(JsonContent) then + exit(Categories); + + if ResponseJsonObject.Get('categories', JsonToken) then begin + CategoriesArray := JsonToken.AsArray(); + for i := 0 to CategoriesArray.Count() - 1 do begin + CategoriesArray.Get(i, CategoryToken); + Categories.Add(CategoryToken.AsValue().AsText()); + end; + end; + + exit(Categories); + end; } \ No newline at end of file diff --git a/Apps/W1/Email - Outlook REST API/app/src/EmailOutlookAPIClientv6.Interface.al b/Apps/W1/Email - Outlook REST API/app/src/EmailOutlookAPIClientv6.Interface.al new file mode 100644 index 0000000000..22007df0df --- /dev/null +++ b/Apps/W1/Email - Outlook REST API/app/src/EmailOutlookAPIClientv6.Interface.al @@ -0,0 +1,116 @@ +// ------------------------------------------------------------------------------------------------ +// 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 extends v5 with email category management. +/// +interface "Email - Outlook API Client v6" +{ + /// + /// Gets account information from the Outlook API. + /// + /// The access token used for connecting to exchange via graph. + /// The email address of the mailbox. + /// The name of the mailbox owner. + /// True if the account information was retrieved successfully, false otherwise. + procedure GetAccountInformation(AccessToken: SecretText; var Email: Text[250]; var Name: Text[250]): Boolean; + + /// + /// Sends an email via the Outlook API. + /// + /// The access token used for connecting to exchange via graph. + /// The JSON object containing the email message to be sent. + procedure SendEmail(AccessToken: SecretText; MessageJson: JsonObject); + + /// + /// 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); + + /// + /// Gets mailbox folders from the Outlook API. + /// + /// The access token used for connecting to exchange via graph. + /// The email account to retrieve mailbox folders from. + /// The JSON array containing the information of the mailbox folders. + procedure GetMailboxFolders(AccessToken: SecretText; OutlookAccount: Record "Email - Outlook Account"): JsonArray; + + /// + /// Gets child mailbox folders from the Outlook API. + /// + /// The access token used for connecting to exchange via graph. + /// The email account to retrieve child mailbox folders from. + /// The ID of the parent folder to retrieve child folders for. + /// The JSON array containing the information of the child mailbox folders. + procedure GetChildMailboxFolders(AccessToken: SecretText; OutlookAccount: Record "Email - Outlook Account"; ParentFolderId: Text): JsonArray; + + /// + /// Gets email categories from the Outlook API. + /// + /// The access token used for connecting to exchange via graph. + /// The email account to retrieve categories from. + /// The JSON array containing the information of the email categories. + procedure GetEmailCategories(AccessToken: SecretText; OutlookAccount: Record "Email - Outlook Account"): JsonArray; + + /// + /// Creates a new email category in the Outlook API. + /// + /// The access token used for connecting to exchange via graph. + /// The email account to create the category in. + /// The display name of the category to create. + /// The color of the category. + /// The ID of the created category. + procedure CreateEmailCategory(AccessToken: SecretText; OutlookAccount: Record "Email - Outlook Account"; CategoryDisplayName: Text; CategoryColor: Text): Text; + + /// + /// Applies email categories to an email message in the Outlook API. + /// + /// The access token used for connecting to exchange via graph. + /// The email account containing the email. + /// The external message ID of the email to update. + /// The list of category display names to apply to the email. + procedure ApplyEmailCategory(AccessToken: SecretText; OutlookAccount: Record "Email - Outlook Account"; ExternalMessageId: Text; Categories: List of [Text]); +} 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 2cb5ab3587..8f29f76b9b 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 @@ -314,6 +314,16 @@ codeunit 4509 "Email - Outlook API Helper" OnAfterInitializeClientsV5(OutlookAPIClient, OAuthClient); end; + procedure InitializeClients(var OutlookAPIClient: interface "Email - Outlook API Client v6"; var OAuthClient: interface "Email - OAuth Client v2") + var + DefaultAPIClient: Codeunit "Email - Outlook API Client"; + DefaultOAuthClient: Codeunit "Email - OAuth Client"; + begin + OutlookAPIClient := DefaultAPIClient; + OAuthClient := DefaultOAuthClient; + OnAfterInitializeClientsV6(OutlookAPIClient, OAuthClient); + end; + procedure Send(EmailMessage: Codeunit "Email Message"; AccountId: Guid) var EmailOutlookAccount: Record "Email - Outlook Account"; @@ -674,6 +684,86 @@ codeunit 4509 "Email - Outlook API Helper" APIClient.MarkEmailAsRead(AccessToken, EmailOutlookAccount."Email Address", ExternalMessageId); end; + procedure GetEmailCategories(AccountId: Guid; var EmailCategories: Record "Email Categories" temporary) + var + EmailOutlookAccount: Record "Email - Outlook Account"; + APIClient: interface "Email - Outlook API Client v6"; + OAuthClient: interface "Email - OAuth Client v2"; + AccessToken: SecretText; + CategoriesJsonArray: JsonArray; + CategoryObject: JsonObject; + JsonToken: JsonToken; + Counter: Integer; + CategoryId: Text; + DisplayName: Text; + Color: Text; + begin + InitializeClients(APIClient, OAuthClient); + if not EmailOutlookAccount.Get(AccountId) then + Error(AccountNotFoundErr); + + EmailOutlookAccountAddressValidation(EmailOutlookAccount); + + OAuthClient.GetAccessToken(AccessToken); + + CategoriesJsonArray := APIClient.GetEmailCategories(AccessToken, EmailOutlookAccount); + + for Counter := 0 to CategoriesJsonArray.Count() - 1 do begin + CategoriesJsonArray.Get(Counter, JsonToken); + CategoryObject := JsonToken.AsObject(); + + CategoryId := GetTextFromJsonObject(CategoryObject, 'id'); + DisplayName := GetTextFromJsonObject(CategoryObject, 'displayName'); + if CategoryObject.Get('color', JsonToken) then + Color := JsonToken.AsValue().AsText() + else + Color := ''; + + EmailCategories.Init(); + EmailCategories.Ordering := Counter + 1; + EmailCategories.Id := CopyStr(CategoryId, 1, MaxStrLen(EmailCategories.Id)); + EmailCategories."Display Name" := CopyStr(DisplayName, 1, MaxStrLen(EmailCategories."Display Name")); + EmailCategories.Color := CopyStr(Color, 1, MaxStrLen(EmailCategories.Color)); + EmailCategories.Insert(); + end; + end; + + procedure CreateEmailCategory(AccountId: Guid; CategoryDisplayName: Text; CategoryColor: Text): Text + var + EmailOutlookAccount: Record "Email - Outlook Account"; + APIClient: interface "Email - Outlook API Client v6"; + OAuthClient: interface "Email - OAuth Client v2"; + AccessToken: SecretText; + begin + InitializeClients(APIClient, OAuthClient); + if not EmailOutlookAccount.Get(AccountId) then + Error(AccountNotFoundErr); + + EmailOutlookAccountAddressValidation(EmailOutlookAccount); + + OAuthClient.GetAccessToken(AccessToken); + + exit(APIClient.CreateEmailCategory(AccessToken, EmailOutlookAccount, CategoryDisplayName, CategoryColor)); + end; + + procedure ApplyEmailCategory(AccountId: Guid; ExternalId: Text; Categories: List of [Text]) + var + EmailOutlookAccount: Record "Email - Outlook Account"; + APIClient: interface "Email - Outlook API Client v6"; + OAuthClient: interface "Email - OAuth Client v2"; + AccessToken: SecretText; + begin + InitializeClients(APIClient, OAuthClient); + if not EmailOutlookAccount.Get(AccountId) then + Error(AccountNotFoundErr); + + EmailOutlookAccountAddressValidation(EmailOutlookAccount); + + OAuthClient.GetAccessToken(AccessToken); + + APIClient.ApplyEmailCategory(AccessToken, EmailOutlookAccount, ExternalId, Categories); + end; + procedure ReplyEmail(AccountId: Guid; var EmailMessage: Codeunit "Email Message") var EmailOutlookAccount: Record "Email - Outlook Account"; @@ -757,6 +847,11 @@ codeunit 4509 "Email - Outlook API Helper" begin end; + [InternalEvent(false)] + local procedure OnAfterInitializeClientsV6(var OutlookAPIClient: interface "Email - Outlook API Client v6"; var OAuthClient: interface "Email - OAuth Client v2") + begin + end; + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Environment Cleanup", 'OnClearCompanyConfig', '', false, false)] local procedure ClearCompanyConfigGeneral(CompanyName: Text; SourceEnv: Enum "Environment Type"; DestinationEnv: Enum "Environment Type") var diff --git a/Apps/W1/Email - SMTP Connector/app/src/SMTPAccount.Page.al b/Apps/W1/Email - SMTP Connector/app/src/SMTPAccount.Page.al index 1c2a805a3c..f34041ea1c 100644 --- a/Apps/W1/Email - SMTP Connector/app/src/SMTPAccount.Page.al +++ b/Apps/W1/Email - SMTP Connector/app/src/SMTPAccount.Page.al @@ -115,6 +115,7 @@ page 4512 "SMTP Account" if AuthActionsVisible then Message(EveryUserShouldPressAuthenticateMsg); if Rec."Authentication Type" = Rec."Authentication Type"::"OAuth 2.0" then begin + Rec.DeleteIsolatedStorageIfExists(Rec."Password Key"); Rec."Password Key" := EmptyGuid; Password := ''; Rec.Modify(); @@ -172,6 +173,7 @@ page 4512 "SMTP Account" ClientId := ''; ClientSecret := ''; end else begin + Rec.DeleteIsolatedStorageIfExists(Rec."Password Key"); Rec."Password Key" := EmptyGuid; Password := ''; end; @@ -347,11 +349,11 @@ page 4512 "SMTP Account" begin Rec.SetCurrentKey(Name); - if not IsNullGuid(Rec."Password Key") then + if (not IsNullGuid(Rec."Password Key")) and (Rec."Authentication Type" <> Rec."Authentication Type"::"OAuth 2.0") and (Rec."Authentication Type" <> Rec."Authentication Type"::Anonymous) and IsolatedStorage.Contains(Format(Rec."Password Key"), DataScope::Company) then Password := SecrectContentLbl; - if not IsNullGuid(Rec."Client Id Storage Id") then + if (not IsNullGuid(Rec."Client Id Storage Id")) and IsolatedStorage.Contains(Format(Rec."Client Id Storage Id"), DataScope::Company) then ClientId := SecrectContentLbl; - if not IsNullGuid(Rec."Client Secret Storage Id") then + if (not IsNullGuid(Rec."Client Secret Storage Id")) and IsolatedStorage.Contains(Format(Rec."Client Secret Storage Id"), DataScope::Company) then ClientSecret := SecrectContentLbl; if not IsNullGuid(Rec."Tenant Id") then TenantId := SecrectContentLbl; diff --git a/Apps/W1/Email - SMTP Connector/app/src/SMTPAccount.table.al b/Apps/W1/Email - SMTP Connector/app/src/SMTPAccount.table.al index 9805b84f96..f2d2e47d44 100644 --- a/Apps/W1/Email - SMTP Connector/app/src/SMTPAccount.table.al +++ b/Apps/W1/Email - SMTP Connector/app/src/SMTPAccount.table.al @@ -165,6 +165,8 @@ table 4511 "SMTP Account" [NonDebuggable] procedure GetPassword(PasswordKey: Guid) Password: SecretText begin + if IsNullGuid(PasswordKey) then + exit; if not IsolatedStorage.Get(Format(PasswordKey), DataScope::Company, Password) then Error(UnableToGetPasswordMsg); end; @@ -215,7 +217,7 @@ table 4511 "SMTP Account" Error(UnableToGetClientSecretMsg); end; - local procedure DeleteIsolatedStorageIfExists(KeyToCheck: Guid) + internal procedure DeleteIsolatedStorageIfExists(KeyToCheck: Guid) begin if IsNullGuid(KeyToCheck) then exit; diff --git a/Apps/W1/Email - SMTP Connector/app/src/SMTPAccountWizard.Page.al b/Apps/W1/Email - SMTP Connector/app/src/SMTPAccountWizard.Page.al index a3f0e10af2..d3e0612c13 100644 --- a/Apps/W1/Email - SMTP Connector/app/src/SMTPAccountWizard.Page.al +++ b/Apps/W1/Email - SMTP Connector/app/src/SMTPAccountWizard.Page.al @@ -57,7 +57,7 @@ page 4511 "SMTP Account Wizard" trigger OnValidate() begin - IsNextEnabled := SMTPConnectorImpl.IsAccountValid(Rec); + IsNextEnabled := IsStep1Valid(); end; } @@ -70,7 +70,7 @@ page 4511 "SMTP Account Wizard" trigger OnValidate() begin SetProperties(); - IsNextEnabled := SMTPConnectorImpl.IsAccountValid(Rec); + IsNextEnabled := IsStep1Valid(); end; } @@ -90,14 +90,13 @@ page 4511 "SMTP Account Wizard" Caption = 'Email Address'; ToolTip = 'Specifies the Email Address specified as the from email address.'; Enabled = SenderFieldsEnabled; - ShowMandatory = true; - NotBlank = true; + ShowMandatory = SenderFieldsEnabled; trigger OnValidate() begin if Rec."User Name" = '' then Rec."User Name" := Rec."Email Address"; - IsNextEnabled := SMTPConnectorImpl.IsAccountValid(Rec); + IsNextEnabled := IsStep1Valid(); end; } @@ -109,7 +108,7 @@ page 4511 "SMTP Account Wizard" trigger OnValidate() begin - IsNextEnabled := SMTPConnectorImpl.IsAccountValid(Rec); + IsNextEnabled := IsStep1Valid(); SetProperties(); if ShowMessageAboutSigningIn then Message(EveryUserShouldPressAuthenticateMsg); @@ -135,6 +134,7 @@ page 4511 "SMTP Account Wizard" begin SetProperties(); UpdateVisibility(); + IsNextEnabled := IsStep1Valid(); if ShowMessageAboutSigningIn then Message(EveryUserShouldPressAuthenticateMsg); end; @@ -349,7 +349,7 @@ page 4511 "SMTP Account Wizard" SMTPConnectorImpl.ApplyOffice365Smtp(Rec); - IsNextEnabled := SMTPConnectorImpl.IsAccountValid(Rec); + IsNextEnabled := IsStep1Valid(); SetProperties(); CurrPage.Update(); @@ -384,7 +384,7 @@ page 4511 "SMTP Account Wizard" if Step2Visible then begin Step2Visible := false; Step1Visible := true; - IsNextEnabled := SMTPConnectorImpl.IsAccountValid(Rec); + IsNextEnabled := IsStep1Valid(); CurrPage.Update(); exit; end; @@ -497,6 +497,20 @@ page 4511 "SMTP Account Wizard" IsNextEnabled := false; end; + local procedure IsStep1Valid(): Boolean + begin + if Rec.Name = '' then + exit(false); + + if (Rec."Sender Type" = Rec."Sender Type"::"Specific User") and (Rec."Email Address" = '') then + exit(false); + + if Rec.Server = '' then + exit(false); + + exit(true); + end; + local procedure IsOAuthAuth(): Boolean begin exit(Rec."Authentication Type" = Rec."Authentication Type"::"OAuth 2.0"); diff --git a/Apps/W1/Email - SMTP Connector/test/src/SMTPAccountAuthTests.Codeunit.al b/Apps/W1/Email - SMTP Connector/test/src/SMTPAccountAuthTests.Codeunit.al index e47df6dfcd..5f683359e8 100644 --- a/Apps/W1/Email - SMTP Connector/test/src/SMTPAccountAuthTests.Codeunit.al +++ b/Apps/W1/Email - SMTP Connector/test/src/SMTPAccountAuthTests.Codeunit.al @@ -219,7 +219,7 @@ codeunit 139762 "SMTP Account Auth Tests" // [SCENARIO] SMTP Account page can be opened successfully // [GIVEN] A new SMTP Account record - CreateSMTPAccount(); + CreateSMTPBasicAccount(); // [WHEN] Opening the SMTP Account page SMTPAccountPage.OpenEdit(); @@ -237,7 +237,7 @@ codeunit 139762 "SMTP Account Auth Tests" // [SCENARIO] Account Name field validation works correctly // [GIVEN] A new SMTP Account record - CreateSMTPAccount(); + CreateSMTPBasicAccount(); // [WHEN] Opening the page and setting account name SMTPAccountPage.OpenEdit(); @@ -255,7 +255,7 @@ codeunit 139762 "SMTP Account Auth Tests" // [SCENARIO] Sender Type field changes affect field editability // [GIVEN] A new SMTP Account record - CreateSMTPAccount(); + CreateSMTPBasicAccount(); // [WHEN] Opening the page and changing sender type to Specific User SMTPAccountPage.OpenEdit(); @@ -282,7 +282,7 @@ codeunit 139762 "SMTP Account Auth Tests" // [SCENARIO] Email Address validation auto-fills User Name // [GIVEN] A new SMTP Account record with Specific User sender type - CreateSMTPAccount(); + CreateSMTPBasicAccount(); SMTPAccount."Sender Type" := SMTPAccount."Sender Type"::"Specific User"; SMTPAccount.Modify(); @@ -303,7 +303,7 @@ codeunit 139762 "SMTP Account Auth Tests" // [SCENARIO] Server URL field validation works correctly // [GIVEN] A new SMTP Account record - CreateSMTPAccount(); + CreateSMTPBasicAccount(); // [WHEN] Setting server URL SMTPAccountPage.OpenEdit(); @@ -322,7 +322,7 @@ codeunit 139762 "SMTP Account Auth Tests" // [SCENARIO] Server Port field accepts valid port numbers // [GIVEN] A new SMTP Account record - CreateSMTPAccount(); + CreateSMTPBasicAccount(); // [WHEN] Setting server port SMTPAccountPage.OpenEdit(); @@ -341,7 +341,7 @@ codeunit 139762 "SMTP Account Auth Tests" // [SCENARIO] Authentication Type changes affect field editability // [GIVEN] A new SMTP Account record - CreateSMTPAccount(); + CreateSMTPBasicAccount(); // [WHEN] Setting authentication to Basic SMTPAccountPage.OpenEdit(); @@ -369,7 +369,7 @@ codeunit 139762 "SMTP Account Auth Tests" // [SCENARIO] Apply Office 365 Server Settings action works correctly // [GIVEN] A new SMTP Account record - CreateSMTPAccount(); + CreateSMTPBasicAccount(); // [WHEN] Opening the page and applying Office 365 settings SMTPAccountPage.OpenEdit(); @@ -390,7 +390,7 @@ codeunit 139762 "SMTP Account Auth Tests" // [SCENARIO] Secure Connection field can be toggled // [GIVEN] A new SMTP Account record - CreateSMTPAccount(); + CreateSMTPBasicAccount(); // [WHEN] Opening the page and setting secure connection SMTPAccountPage.OpenEdit(); @@ -415,7 +415,7 @@ codeunit 139762 "SMTP Account Auth Tests" // [SCENARIO] Email Address OnValidate does not override User Name if it is already set. // [GIVEN] A new SMTP Account record with a pre-set User Name - CreateSMTPAccount(); + CreateSMTPBasicAccount(); SMTPAccount."Sender Type" := SMTPAccount."Sender Type"::"Specific User"; SMTPAccount."User Name" := 'existing-user@example.com'; SMTPAccount.Modify(); @@ -443,7 +443,7 @@ codeunit 139762 "SMTP Account Auth Tests" // [GIVEN] OnPrem + an SMTP account EnvironmentInfoTestLibrary.SetTestabilitySoftwareAsAService(true); - CreateSMTPAccount(); + CreateSMTPBasicAccount(); // [WHEN] Open the SMTP Account page and configure OAuth 2.0 with O365 via the UI SMTPAccountPage.OpenEdit(); @@ -483,7 +483,7 @@ codeunit 139762 "SMTP Account Auth Tests" // [SCENARIO] Turning off Custom OAuth 2.0 clears secret-related fields. // [GIVEN] An SMTP account with custom OAuth 2.0 GUIDs filled - CreateSMTPAccount(); + CreateSMTPBasicAccount(); SMTPAccount."Authentication Type" := SMTPAccount."Authentication Type"::"OAuth 2.0"; SMTPAccount."Client Id Storage Id" := CreateGuid(); SMTPAccount."Client Secret Storage Id" := CreateGuid(); @@ -513,7 +513,7 @@ codeunit 139762 "SMTP Account Auth Tests" // [SCENARIO] "Authenticate with Customized OAuth 2.0" errors when Client Id or Secret is missing. // [GIVEN] OAuth 2.0 account using O365 server and Custom OAuth toggled on, but without ClientId/Secret - CreateSMTPAccount(); + CreateSMTPBasicAccount(); SMTPAccount."Authentication Type" := SMTPAccount."Authentication Type"::"OAuth 2.0"; SMTPAccount.Server := 'smtp.office365.com'; SMTPAccount."Client Id Storage Id" := CreateGuid(); // Only ClientId is present to force partial configuration @@ -540,7 +540,7 @@ codeunit 139762 "SMTP Account Auth Tests" // [SCENARIO] When Custom OAuth 2.0 is enabled but required fields are missing, closing page asks for confirmation. // [GIVEN] OAuth 2.0 account with Custom OAuth enabled and incomplete configuration - CreateSMTPAccount(); + CreateSMTPBasicAccount(); SMTPAccount."Authentication Type" := SMTPAccount."Authentication Type"::"OAuth 2.0"; SMTPAccount."Client Id Storage Id" := CreateGuid(); // Only ClientId present SMTPAccount.Modify(); @@ -1047,7 +1047,202 @@ codeunit 139762 "SMTP Account Auth Tests" #endregion - local procedure CreateSMTPAccount() + [Test] + procedure TestWizardCurrentUserNextEnabledAfterApplyOffice365() + begin + // [SCENARIO] Bug fix: When user selects Current User and applies Office 365 settings, + // the Next button should be enabled. Previously, IsAccountValid checked Step 3 fields + // (UserName for Basic auth) which are not yet filled in Step 1, blocking Next. + + // [WHEN] Opening the wizard + SMTPAccountWizardPage.OpenNew(); + + // [WHEN] Filling Name and selecting Current User + SMTPAccountWizardPage.NameField.SetValue('Current User Test'); + SMTPAccountWizardPage.SenderTypeField.SetValue("SMTP Connector Sender Type"::"Current User"); + + // [WHEN] Applying Office 365 settings (sets Auth to Basic, Server to smtp.office365.com) + SMTPAccountWizardPage.ApplyOffice365.Invoke(); + + // [THEN] Next button should be enabled because Step 1 validation only checks + // Name, Email Address (for Specific User), and Server + Assert.IsTrue(SMTPAccountWizardPage.Next.Enabled(), 'Next should be enabled for Current User after Apply Office 365'); + + SMTPAccountWizardPage.Close(); + end; + + [Test] + procedure TestWizardCurrentUserNextEnabledWithManualServerEntry() + begin + // [SCENARIO] Bug fix: When user manually fills in Name and Server with Current User, + // Next should be enabled without needing Email Address. + + // [WHEN] Opening the wizard + SMTPAccountWizardPage.OpenNew(); + + // [WHEN] Filling required fields for Current User + SMTPAccountWizardPage.NameField.SetValue('Manual Server Test'); + SMTPAccountWizardPage.SenderTypeField.SetValue("SMTP Connector Sender Type"::"Current User"); + SMTPAccountWizardPage.ServerUrl.SetValue('smtp.example.com'); + + // [THEN] Next button should be enabled + Assert.IsTrue(SMTPAccountWizardPage.Next.Enabled(), 'Next should be enabled for Current User with Name and Server filled'); + + SMTPAccountWizardPage.Close(); + end; + + [Test] + procedure TestWizardSpecificUserNextDisabledWithoutEmail() + begin + // [SCENARIO] Regression check: Specific User still requires Email Address for Next to be enabled. + + // [WHEN] Opening the wizard + SMTPAccountWizardPage.OpenNew(); + + // [WHEN] Filling Name and Server but not Email Address for Specific User + SMTPAccountWizardPage.NameField.SetValue('Specific User Test'); + SMTPAccountWizardPage.SenderTypeField.SetValue("SMTP Connector Sender Type"::"Specific User"); + SMTPAccountWizardPage.ServerUrl.SetValue('smtp.example.com'); + + // [THEN] Next button should be disabled because Email Address is required + Assert.IsFalse(SMTPAccountWizardPage.Next.Enabled(), 'Next should be disabled for Specific User without Email Address'); + + // [WHEN] Filling Email Address + SMTPAccountWizardPage.EmailAddress.SetValue('test@example.com'); + + // [THEN] Next button should be enabled + Assert.IsTrue(SMTPAccountWizardPage.Next.Enabled(), 'Next should be enabled for Specific User with all fields filled'); + + SMTPAccountWizardPage.Close(); + end; + + [Test] + procedure TestPasswordNotShownForOAuthAccount() + begin + // [SCENARIO] Bug fix: On the SMTP Account page, the password field should not show '***' + // for OAuth 2.0 accounts, even if a Password Key GUID exists. This prevents users from + // thinking a password is set when it is actually empty. + + // [GIVEN] An SMTP account with OAuth 2.0 and a password stored in isolated storage + CreateSMTPOAuthAccount(); + SMTPAccount.SetPassword(SecretStrSubstNo('TestPassword123')); + SMTPAccount.Modify(); + + // [WHEN] Opening the SMTP Account page with the specific record + SMTPAccountPage.Trap(); + Page.Run(Page::"SMTP Account", SMTPAccount); + + // [THEN] Password field should be empty (not showing '***') + Assert.AreEqual('', SMTPAccountPage.Password.Value(), 'Password should not show masked content for OAuth 2.0 accounts'); + + SMTPAccountPage.Close(); + end; + + [Test] + procedure TestPasswordShownForBasicAuthAccount() + begin + // [SCENARIO] Regression check: On the SMTP Account page, the password field should + // show '***' for Basic authentication accounts that have a password set. + + // [GIVEN] An SMTP account with Basic auth and a password set + CreateSMTPBasicAccount(); + SMTPAccount.SetPassword(SecretStrSubstNo('TestPassword123')); + SMTPAccount.Modify(); + + // [WHEN] Opening the SMTP Account page with the specific record + SMTPAccountPage.Trap(); + Page.Run(Page::"SMTP Account", SMTPAccount); + + // [THEN] Password field should show masked content (not empty) + Assert.AreNotEqual('', SMTPAccountPage.Password.Value(), 'Password should show masked content for Basic auth accounts'); + + SMTPAccountPage.Close(); + end; + + [Test] + procedure TestPasswordClearedWhenSwitchingToOAuthAndBackToBasic() + begin + // [SCENARIO] When switching authentication from Basic to OAuth 2.0 and back to Basic, + // the password should be cleared when switching to OAuth 2.0 and remain empty after switching back. + + // [GIVEN] An SMTP account with Basic auth and a password set + CreateSMTPBasicAccount(); + SMTPAccount.SetPassword(SecretStrSubstNo('TestPassword123')); + SMTPAccount.Modify(); + + // [WHEN] Opening the SMTP Account page + SMTPAccountPage.Trap(); + Page.Run(Page::"SMTP Account", SMTPAccount); + + // [THEN] Password field should show masked content for Basic auth + Assert.AreNotEqual('', SMTPAccountPage.Password.Value(), 'Password should show masked content initially for Basic auth'); + + // [WHEN] Switching authentication to OAuth 2.0 + SMTPAccountPage.Authentication.SetValue(SMTPAccount."Authentication Type"::"OAuth 2.0"); + + // [THEN] Password should be cleared + Assert.AreEqual('', SMTPAccountPage.Password.Value(), 'Password should be cleared after switching to OAuth 2.0'); + + // [WHEN] Switching authentication back to Basic + SMTPAccountPage.Authentication.SetValue(SMTPAccount."Authentication Type"::Basic); + + // [THEN] Password should remain empty (it was deleted from isolated storage when switching to OAuth 2.0) + Assert.AreEqual('', SMTPAccountPage.Password.Value(), 'Password should remain empty after switching back to Basic from OAuth 2.0'); + + SMTPAccountPage.Close(); + end; + + [Test] + procedure TestOAuthActionsVisibleOnSaaS() + var + SMTPConnectorImpl: Codeunit "SMTP Connector Impl."; + EnvironmentInfoTestLibrary: Codeunit "Environment Info Test Library"; + begin + // [SCENARIO] Bug fix: OAuth 2.0 authenticate actions should be visible on SaaS environments. + // When Custom OAuth is enabled, the custom authenticate action should be visible and standard ones hidden. + // When Custom OAuth is disabled, the custom authenticate action should not be visible. + + // [GIVEN] SaaS environment with an SMTP account + EnvironmentInfoTestLibrary.SetTestabilitySoftwareAsAService(true); + CreateSMTPBasicAccount(); + + // [WHEN] Opening the SMTP Account page and configuring OAuth 2.0 with O365 server + SMTPAccountPage.OpenEdit(); + SMTPAccountPage.GoToRecord(SMTPAccount); + SMTPAccountPage.Authentication.SetValue(SMTPAccount."Authentication Type"::"OAuth 2.0"); + SMTPAccountPage.ServerUrl.SetValue(SMTPConnectorImpl.GetO365SmtpServer()); + + // [THEN] The standard OAuth 2.0 actions should NOT be visible on SaaS + Assert.IsFalse(SMTPAccountPage."Authenticate with OAuth 2.0".Visible(), 'OAuth 2.0 authenticate action should not be visible on SaaS'); + Assert.IsFalse(SMTPAccountPage."Check OAuth 2.0 authentication".Visible(), 'Check OAuth 2.0 authentication action should not be visible on SaaS'); + + // [THEN] The custom OAuth 2.0 action should NOT be visible when custom OAuth is disabled + Assert.IsFalse(SMTPAccountPage."Authenticate with Customized OAuth 2.0".Visible(), 'Custom OAuth 2.0 authenticate action should not be visible when custom OAuth is disabled'); + + // [WHEN] Enabling custom OAuth 2.0 + SMTPAccountPage.CustomOAuth2Settings.SetValue(true); + + // [THEN] The custom OAuth 2.0 action should be visible + Assert.IsTrue(SMTPAccountPage."Authenticate with Customized OAuth 2.0".Visible(), 'Custom OAuth 2.0 authenticate action should be visible when custom OAuth is enabled'); + + // [THEN] The standard OAuth 2.0 actions should be hidden + Assert.IsFalse(SMTPAccountPage."Authenticate with OAuth 2.0".Visible(), 'Standard OAuth 2.0 authenticate action should be hidden when custom OAuth is enabled'); + Assert.IsFalse(SMTPAccountPage."Check OAuth 2.0 authentication".Visible(), 'Check OAuth 2.0 authentication action should be hidden when custom OAuth is enabled'); + + // [WHEN] Disabling custom OAuth 2.0 + SMTPAccountPage.CustomOAuth2Settings.SetValue(false); + + // [THEN] The custom OAuth 2.0 action should NOT be visible again + Assert.IsFalse(SMTPAccountPage."Authenticate with Customized OAuth 2.0".Visible(), 'Custom OAuth 2.0 authenticate action should not be visible after disabling custom OAuth'); + + // [THEN] The standard OAuth 2.0 actions should NOT be visible after disabling custom OAuth + Assert.IsFalse(SMTPAccountPage."Authenticate with OAuth 2.0".Visible(), 'Standard OAuth 2.0 authenticate action should not be visible after disabling custom OAuth'); + Assert.IsFalse(SMTPAccountPage."Check OAuth 2.0 authentication".Visible(), 'Check OAuth 2.0 authentication action should not be visible after disabling custom OAuth'); + + SMTPAccountPage.Close(); + end; + + local procedure CreateSMTPBasicAccount() var RandomText: Text; begin @@ -1062,6 +1257,23 @@ codeunit 139762 "SMTP Account Auth Tests" SMTPAccount.Insert(); end; + local procedure CreateSMTPOAuthAccount() + var + RandomText: Text; + begin + SMTPAccount.Init(); + SMTPAccount.Id := CreateGuid(); + RandomText := Format(CreateGuid()); + SMTPAccount.Name := 'Test Account ' + CopyStr(RandomText, 1, 10); + SMTPAccount.Server := 'smtp.test.com'; + SMTPAccount."Server Port" := 25; + SMTPAccount."Authentication Type" := SMTPAccount."Authentication Type"::"OAuth 2.0"; + SMTPAccount."Password Key" := CreateGuid(); + SMTPAccount."Sender Type" := SMTPAccount."Sender Type"::"Current User"; + SMTPAccount.Insert(); + end; + + [ConfirmHandler] procedure ConfirmHandler(Question: Text[1024]; var Reply: Boolean) begin diff --git a/Apps/W1/ExciseTaxes/app/ExtensionLogo.png b/Apps/W1/ExciseTaxes/app/ExtensionLogo.png index 7ab63bb28b..86d06645b0 100644 Binary files a/Apps/W1/ExciseTaxes/app/ExtensionLogo.png and b/Apps/W1/ExciseTaxes/app/ExtensionLogo.png differ diff --git a/Apps/W1/ReviewGLEntries/app/src/codeunits/Upgrade.Codeunit.al b/Apps/W1/ReviewGLEntries/app/src/codeunits/Upgrade.Codeunit.al index 931a8ffe5c..629f872a20 100644 --- a/Apps/W1/ReviewGLEntries/app/src/codeunits/Upgrade.Codeunit.al +++ b/Apps/W1/ReviewGLEntries/app/src/codeunits/Upgrade.Codeunit.al @@ -11,29 +11,25 @@ codeunit 22201 "Upgrade" trigger OnUpgradePerCompany() begin MovetoGLEntryReviewLog(); - FixGLEntryReviewLogWithReviewAmountZero(); + FixGLEntryReviewLogWithReviewAmountZeroWithDataTransfer(); end; - local procedure FixGLEntryReviewLogWithReviewAmountZero() + local procedure FixGLEntryReviewLogWithReviewAmountZeroWithDataTransfer() var - GLEntryReviewLog, GLEntryReviewLog2 : Record "G/L Entry Review Log"; + GLEntryReviewLog: Record "G/L Entry Review Log"; GlEntry: Record "G/L Entry"; UpgradeTag: Codeunit "Upgrade Tag"; + GLEntryDataTransfer: DataTransfer; begin - if UpgradeTag.HasUpgradeTag(UpgradeFixGLEntryReviewLogWithReviewedAmountZeroTag()) then exit; + if UpgradeTag.HasUpgradeTag(UpgradeFixGLEntryReviewLogWithReviewedAmountZeroWithDataTransferTag()) then exit; - GLEntryReviewLog.SetCurrentKey("Reviewed Amount"); - GLEntryReviewLog.SetRange("Reviewed Amount", 0); - if GLEntryReviewLog.FindSet() then - repeat - if GlEntry.Get(GLEntryReviewLog."G/L Entry No.") then begin - GLEntryReviewLog2.Copy(GLEntryReviewLog); - GLEntryReviewLog2."Reviewed Amount" := GlEntry.Amount; - GLEntryReviewLog2.Modify(false); - end; - until GLEntryReviewLog.Next() = 0; + GLEntryDataTransfer.SetTables(Database::"G/L Entry", Database::"G/L Entry Review Log"); + GLEntryDataTransfer.AddFieldValue(GLEntry.FieldNo(Amount), GLEntryReviewLog.FieldNo("Reviewed Amount")); + GLEntryDataTransfer.AddJoin(GLEntry.FieldNo("Entry No."), GLEntryReviewLog.FieldNo("G/L Entry No.")); + GLEntryDataTransfer.AddDestinationFilter(GLEntryReviewLog.FieldNo("Reviewed Amount"), '=0'); + GLEntryDataTransfer.CopyFields(); - UpgradeTag.SetUpgradeTag(UpgradeFixGLEntryReviewLogWithReviewedAmountZeroTag()); + UpgradeTag.SetUpgradeTag(UpgradeFixGLEntryReviewLogWithReviewedAmountZeroWithDataTransferTag()); end; local procedure MovetoGLEntryReviewLog() @@ -65,7 +61,7 @@ codeunit 22201 "Upgrade" local procedure RegisterPerCompanyTags(var PerCompanyUpgradeTags: List of [Code[250]]) begin PerCompanyUpgradeTags.Add(UpgradeReviewGLEntryTag()); - PerCompanyUpgradeTags.Add(UpgradeFixGLEntryReviewLogWithReviewedAmountZeroTag()); + PerCompanyUpgradeTags.Add(UpgradeFixGLEntryReviewLogWithReviewedAmountZeroWithDataTransferTag()); end; local procedure UpgradeReviewGLEntryTag(): Code[250] @@ -73,8 +69,9 @@ codeunit 22201 "Upgrade" exit('MS-547765-UpdateReviewGLEntry-20250704'); end; - local procedure UpgradeFixGLEntryReviewLogWithReviewedAmountZeroTag(): Code[250] + local procedure UpgradeFixGLEntryReviewLogWithReviewedAmountZeroWithDataTransferTag(): Code[250] begin - exit('MS-616473-UpgradeFixGLEntryReviewLogWithReviewedAmountZeroTag-20251216'); + exit('MS-621701-UpgradeFixGLEntryReviewLogWithReviewedAmountZero-20260212'); end; + } \ No newline at end of file diff --git a/Apps/W1/StatisticalAccounts/app/src/StatAccBalanceBuffer.Table.al b/Apps/W1/StatisticalAccounts/app/src/StatAccBalanceBuffer.Table.al index 909ed8a7a2..45d5fa3869 100644 --- a/Apps/W1/StatisticalAccounts/app/src/StatAccBalanceBuffer.Table.al +++ b/Apps/W1/StatisticalAccounts/app/src/StatAccBalanceBuffer.Table.al @@ -31,11 +31,15 @@ table 2620 "Stat. Acc. Balance Buffer" } field(10; "Amount"; Decimal) { + AutoFormatType = 1; + AutoFormatExpression = ''; Caption = 'Amount'; DataClassification = SystemMetadata; } field(12; "Net Change"; Decimal) { + AutoFormatType = 1; + AutoFormatExpression = ''; Caption = 'Net Change'; DataClassification = SystemMetadata; } diff --git a/Apps/W1/StatisticalAccounts/app/src/StatisticalAccJournalLine.Table.al b/Apps/W1/StatisticalAccounts/app/src/StatisticalAccJournalLine.Table.al index da575bbc98..e24b04cdea 100644 --- a/Apps/W1/StatisticalAccounts/app/src/StatisticalAccJournalLine.Table.al +++ b/Apps/W1/StatisticalAccounts/app/src/StatisticalAccJournalLine.Table.al @@ -63,6 +63,8 @@ table 2631 "Statistical Acc. Journal Line" } field(13; Amount; Decimal) { + AutoFormatType = 1; + AutoFormatExpression = ''; Caption = 'Amount'; DataClassification = CustomerContent; } @@ -70,6 +72,7 @@ table 2631 "Statistical Acc. Journal Line" field(14; "Amount Change"; Decimal) { AutoFormatType = 1; + AutoFormatExpression = ''; CalcFormula = sum("Statistical Acc. Journal Line".Amount where("Journal Template Name" = field("Journal Template Name"), "Journal Batch Name" = field("Journal Batch Name"), "Statistical Account No." = field("Statistical Account No."))); diff --git a/Apps/W1/StatisticalAccounts/app/src/StatisticalAccount.Table.al b/Apps/W1/StatisticalAccounts/app/src/StatisticalAccount.Table.al index b39970d506..f7f264ea29 100644 --- a/Apps/W1/StatisticalAccounts/app/src/StatisticalAccount.Table.al +++ b/Apps/W1/StatisticalAccounts/app/src/StatisticalAccount.Table.al @@ -70,6 +70,7 @@ table 2632 "Statistical Account" field(31; "Balance at Date"; Decimal) { AutoFormatType = 1; + AutoFormatExpression = ''; CalcFormula = sum("Statistical Ledger Entry".Amount where("Statistical Account No." = field("No."), "Global Dimension 1 Code" = field("Global Dimension 1 Filter"), "Global Dimension 2 Code" = field("Global Dimension 2 Filter"), @@ -83,6 +84,7 @@ table 2632 "Statistical Account" field(32; "Net Change"; Decimal) { AutoFormatType = 1; + AutoFormatExpression = ''; CalcFormula = sum("Statistical Ledger Entry".Amount where("Statistical Account No." = field("No."), "Global Dimension 1 Code" = field("Global Dimension 1 Filter"), "Global Dimension 2 Code" = field("Global Dimension 2 Filter"), @@ -95,6 +97,7 @@ table 2632 "Statistical Account" field(36; Balance; Decimal) { AutoFormatType = 1; + AutoFormatExpression = ''; CalcFormula = sum("Statistical Ledger Entry".Amount where("Statistical Account No." = field("No."), "Global Dimension 1 Code" = field("Global Dimension 1 Filter"), "Global Dimension 2 Code" = field("Global Dimension 2 Filter"), diff --git a/Apps/W1/StatisticalAccounts/app/src/StatisticalAccountsJournal.Page.al b/Apps/W1/StatisticalAccounts/app/src/StatisticalAccountsJournal.Page.al index 59bea6d28b..c111aadae3 100644 --- a/Apps/W1/StatisticalAccounts/app/src/StatisticalAccountsJournal.Page.al +++ b/Apps/W1/StatisticalAccounts/app/src/StatisticalAccountsJournal.Page.al @@ -222,6 +222,7 @@ page 2633 "Statistical Accounts Journal" { ApplicationArea = All; AutoFormatType = 1; + AutoFormatExpression = ''; Caption = 'Balance'; Editable = false; ToolTip = 'Specifies the balance that has accumulated in the journal on the selected line.'; @@ -234,6 +235,7 @@ page 2633 "Statistical Accounts Journal" { ApplicationArea = All; AutoFormatType = 1; + AutoFormatExpression = ''; Caption = 'BalanceAfterPosting'; Editable = false; ToolTip = 'Specifies the balance that has accumulated in the journal selected on the line.'; diff --git a/Apps/W1/StatisticalAccounts/app/src/StatisticalLedgerEntry.Table.al b/Apps/W1/StatisticalAccounts/app/src/StatisticalLedgerEntry.Table.al index 680b41789b..d9b1eafd4d 100644 --- a/Apps/W1/StatisticalAccounts/app/src/StatisticalLedgerEntry.Table.al +++ b/Apps/W1/StatisticalAccounts/app/src/StatisticalLedgerEntry.Table.al @@ -42,6 +42,7 @@ table 2633 "Statistical Ledger Entry" field(17; Amount; Decimal) { AutoFormatType = 1; + AutoFormatExpression = ''; Caption = 'Amount'; DataClassification = CustomerContent; } diff --git a/Apps/W1/Sustainability/app/src/Account/SustainabilityAccount.Table.al b/Apps/W1/Sustainability/app/src/Account/SustainabilityAccount.Table.al index 00b8719bc1..c1d8086c73 100644 --- a/Apps/W1/Sustainability/app/src/Account/SustainabilityAccount.Table.al +++ b/Apps/W1/Sustainability/app/src/Account/SustainabilityAccount.Table.al @@ -179,7 +179,7 @@ table 6210 "Sustainability Account" #pragma warning disable AA0232 // the SIFT key is added, there is a bug in the analyzer field(100; "Net Change (CO2)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Sustainability Ledger Entry"."Emission CO2" where("Account No." = field("No."), "Account No." = field(filter(Totaling)), @@ -195,7 +195,7 @@ table 6210 "Sustainability Account" } field(101; "Balance at Date (CO2)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Sustainability Ledger Entry"."Emission CO2" where("Account No." = field("No."), "Account No." = field(filter(Totaling)), @@ -211,7 +211,7 @@ table 6210 "Sustainability Account" } field(102; "Balance (CO2)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Sustainability Ledger Entry"."Emission CO2" where("Account No." = field("No."), "Account No." = field(filter(Totaling)), @@ -226,7 +226,7 @@ table 6210 "Sustainability Account" } field(103; "Net Change (CH4)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Sustainability Ledger Entry"."Emission CH4" where("Account No." = field("No."), "Account No." = field(filter(Totaling)), @@ -242,7 +242,7 @@ table 6210 "Sustainability Account" } field(104; "Balance at Date (CH4)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Sustainability Ledger Entry"."Emission CH4" where("Account No." = field("No."), "Account No." = field(filter(Totaling)), @@ -258,7 +258,7 @@ table 6210 "Sustainability Account" } field(105; "Balance (CH4)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Sustainability Ledger Entry"."Emission CH4" where("Account No." = field("No."), "Account No." = field(filter(Totaling)), @@ -273,7 +273,7 @@ table 6210 "Sustainability Account" } field(106; "Net Change (N2O)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Sustainability Ledger Entry"."Emission N2O" where("Account No." = field("No."), "Account No." = field(filter(Totaling)), @@ -289,7 +289,7 @@ table 6210 "Sustainability Account" } field(107; "Balance at Date (N2O)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Sustainability Ledger Entry"."Emission N2O" where("Account No." = field("No."), "Account No." = field(filter(Totaling)), @@ -305,7 +305,7 @@ table 6210 "Sustainability Account" } field(108; "Balance (N2O)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Sustainability Ledger Entry"."Emission N2O" where("Account No." = field("No."), "Account No." = field(filter(Totaling)), @@ -320,7 +320,7 @@ table 6210 "Sustainability Account" } field(109; "Net Change (Water)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Sustainability Ledger Entry"."Water Intensity" where("Account No." = field("No."), "Account No." = field(filter(Totaling)), @@ -335,7 +335,7 @@ table 6210 "Sustainability Account" } field(110; "Balance at Date (Water)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Sustainability Ledger Entry"."Water Intensity" where("Account No." = field("No."), "Account No." = field(filter(Totaling)), @@ -350,7 +350,7 @@ table 6210 "Sustainability Account" } field(111; "Balance (Water)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Sustainability Ledger Entry"."Water Intensity" where("Account No." = field("No."), "Account No." = field(filter(Totaling)), @@ -364,7 +364,7 @@ table 6210 "Sustainability Account" } field(112; "Net Change (Disch. Water)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Sustainability Ledger Entry"."Discharged Into Water" where("Account No." = field("No."), "Account No." = field(filter(Totaling)), @@ -379,7 +379,7 @@ table 6210 "Sustainability Account" } field(113; "Balance at Date (Disch. Water)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Sustainability Ledger Entry"."Discharged Into Water" where("Account No." = field("No."), "Account No." = field(filter(Totaling)), @@ -394,7 +394,7 @@ table 6210 "Sustainability Account" } field(114; "Balance (Disch. Water)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Sustainability Ledger Entry"."Discharged Into Water" where("Account No." = field("No."), "Account No." = field(filter(Totaling)), @@ -408,7 +408,7 @@ table 6210 "Sustainability Account" } field(115; "Net Change (Waste)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Sustainability Ledger Entry"."Waste Intensity" where("Account No." = field("No."), "Account No." = field(filter(Totaling)), @@ -423,7 +423,7 @@ table 6210 "Sustainability Account" } field(116; "Balance at Date (Waste)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Sustainability Ledger Entry"."Waste Intensity" where("Account No." = field("No."), "Account No." = field(filter(Totaling)), @@ -438,7 +438,7 @@ table 6210 "Sustainability Account" } field(117; "Balance (Waste)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Sustainability Ledger Entry"."Waste Intensity" where("Account No." = field("No."), "Account No." = field(filter(Totaling)), diff --git a/Apps/W1/Sustainability/app/src/CRM/SustESGFact.Table.al b/Apps/W1/Sustainability/app/src/CRM/SustESGFact.Table.al index de3d63dfc9..56e17efbe0 100644 --- a/Apps/W1/Sustainability/app/src/CRM/SustESGFact.Table.al +++ b/Apps/W1/Sustainability/app/src/CRM/SustESGFact.Table.al @@ -196,6 +196,7 @@ table 6246 "Sust. ESG Fact" } field(40; NumericValue; Decimal) { + AutoFormatType = 0; ExternalName = 'msdyn_numericvalue'; ExternalType = 'Decimal'; Description = 'Numeric Value'; diff --git a/Apps/W1/Sustainability/app/src/CRM/SustUnit.Table.al b/Apps/W1/Sustainability/app/src/CRM/SustUnit.Table.al index 880a8ce0cf..3d1ed8169f 100644 --- a/Apps/W1/Sustainability/app/src/CRM/SustUnit.Table.al +++ b/Apps/W1/Sustainability/app/src/CRM/SustUnit.Table.al @@ -186,6 +186,7 @@ table 6251 "Sust. Unit" } field(36; ConversionFactor; Decimal) { + AutoFormatType = 0; ExternalName = 'msdyn_conversionfactor'; ExternalType = 'Decimal'; Description = 'Conversion factor to convert to the base unit.'; diff --git a/Apps/W1/Sustainability/app/src/Calculation/CollectAmountFromGLEntry.Page.al b/Apps/W1/Sustainability/app/src/Calculation/CollectAmountFromGLEntry.Page.al index 7ea68cbf6d..9dd90ba261 100644 --- a/Apps/W1/Sustainability/app/src/Calculation/CollectAmountFromGLEntry.Page.al +++ b/Apps/W1/Sustainability/app/src/Calculation/CollectAmountFromGLEntry.Page.al @@ -68,6 +68,8 @@ page 6224 "Collect Amount from G/L Entry" ShowCaption = false; field(TotalAmount; SustainabilityCalcMgt.GetCollectableGLAmount(Rec, FromDate, ToDate)) { + AutoFormatType = 1; + AutoFormatExpression = ''; Caption = 'Total Amount'; Editable = false; DrillDown = true; diff --git a/Apps/W1/Sustainability/app/src/Certificate/SustItem.TableExt.al b/Apps/W1/Sustainability/app/src/Certificate/SustItem.TableExt.al index 46aff9f4c1..a32edb351e 100644 --- a/Apps/W1/Sustainability/app/src/Certificate/SustItem.TableExt.al +++ b/Apps/W1/Sustainability/app/src/Certificate/SustItem.TableExt.al @@ -46,6 +46,7 @@ tableextension 6220 "Sust. Item" extends Item } field(6213; "Carbon Credit Per UOM"; Decimal) { + AutoFormatType = 0; DataClassification = CustomerContent; Caption = 'Carbon Credit Per UOM'; diff --git a/Apps/W1/Sustainability/app/src/Certificate/SustainabilityCertificate.Table.al b/Apps/W1/Sustainability/app/src/Certificate/SustainabilityCertificate.Table.al index 431eb663b3..543ef42849 100644 --- a/Apps/W1/Sustainability/app/src/Certificate/SustainabilityCertificate.Table.al +++ b/Apps/W1/Sustainability/app/src/Certificate/SustainabilityCertificate.Table.al @@ -49,6 +49,7 @@ table 6222 "Sustainability Certificate" } field(8; "Value"; Decimal) { + AutoFormatType = 0; DataClassification = CustomerContent; Caption = 'Value'; diff --git a/Apps/W1/Sustainability/app/src/ESGReporting/SustESGReportingPrevLine.Page.al b/Apps/W1/Sustainability/app/src/ESGReporting/SustESGReportingPrevLine.Page.al index 7d4e55b613..c9cb50240a 100644 --- a/Apps/W1/Sustainability/app/src/ESGReporting/SustESGReportingPrevLine.Page.al +++ b/Apps/W1/Sustainability/app/src/ESGReporting/SustESGReportingPrevLine.Page.al @@ -84,7 +84,7 @@ page 6255 "Sust. ESG Reporting Prev. Line" field(ColumnValue; ColumnValue) { ApplicationArea = Basic, Suite; - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; Caption = 'Column Amount'; DrillDown = true; diff --git a/Apps/W1/Sustainability/app/src/ESGReporting/SustESGReportingUnit.Table.al b/Apps/W1/Sustainability/app/src/ESGReporting/SustESGReportingUnit.Table.al index 0d0883a220..45921ad328 100644 --- a/Apps/W1/Sustainability/app/src/ESGReporting/SustESGReportingUnit.Table.al +++ b/Apps/W1/Sustainability/app/src/ESGReporting/SustESGReportingUnit.Table.al @@ -27,6 +27,7 @@ table 6252 "Sust. ESG Reporting Unit" } field(3; "Conversion Factor"; Decimal) { + AutoFormatType = 0; Caption = 'Conversion Factor'; } field(4; "Base Reporting Unit Code"; Code[20]) diff --git a/Apps/W1/Sustainability/app/src/ESGReporting/SustPostedESGReportLine.Table.al b/Apps/W1/Sustainability/app/src/ESGReporting/SustPostedESGReportLine.Table.al index dce294dd03..95ecdb3b33 100644 --- a/Apps/W1/Sustainability/app/src/ESGReporting/SustPostedESGReportLine.Table.al +++ b/Apps/W1/Sustainability/app/src/ESGReporting/SustPostedESGReportLine.Table.al @@ -195,6 +195,8 @@ table 6232 "Sust. Posted ESG Report Line" } field(40; "Posted Amount"; Decimal) { + AutoFormatType = 1; + AutoFormatExpression = ''; Caption = 'Posted Amount'; } field(50; "Coupled to Dataverse"; Boolean) diff --git a/Apps/W1/Sustainability/app/src/Emission/EmissionFee.Table.al b/Apps/W1/Sustainability/app/src/Emission/EmissionFee.Table.al index 2973feb10b..047cd99b7b 100644 --- a/Apps/W1/Sustainability/app/src/Emission/EmissionFee.Table.al +++ b/Apps/W1/Sustainability/app/src/Emission/EmissionFee.Table.al @@ -29,6 +29,8 @@ table 6226 "Emission Fee" } field(3; "Carbon Fee"; Decimal) { + AutoFormatType = 2; + AutoFormatExpression = ''; DataClassification = CustomerContent; Caption = 'Carbon Fee'; DecimalPlaces = 2 : 5; @@ -42,6 +44,7 @@ table 6226 "Emission Fee" } field(4; "Carbon Equivalent Factor"; Decimal) { + AutoFormatType = 0; DataClassification = CustomerContent; Caption = 'Carbon Equivalent Factor'; DecimalPlaces = 2 : 5; diff --git a/Apps/W1/Sustainability/app/src/ExciseTax/SustExciseJnlLine.Table.al b/Apps/W1/Sustainability/app/src/ExciseTax/SustExciseJnlLine.Table.al index b653257063..22e029c96e 100644 --- a/Apps/W1/Sustainability/app/src/ExciseTax/SustExciseJnlLine.Table.al +++ b/Apps/W1/Sustainability/app/src/ExciseTax/SustExciseJnlLine.Table.al @@ -334,6 +334,7 @@ table 6240 "Sust. Excise Jnl. Line" } field(24; "Source Qty."; Decimal) { + AutoFormatType = 0; Caption = 'Source Qty.'; trigger OnValidate() @@ -392,6 +393,7 @@ table 6240 "Sust. Excise Jnl. Line" } field(28; "Material Breakdown Weight"; Decimal) { + AutoFormatType = 0; Caption = 'Material Breakdown Weight'; trigger OnValidate() diff --git a/Apps/W1/Sustainability/app/src/ExciseTax/SustExciseTaxesTransLog.Table.al b/Apps/W1/Sustainability/app/src/ExciseTax/SustExciseTaxesTransLog.Table.al index 445ac9dab1..3facccbad0 100644 --- a/Apps/W1/Sustainability/app/src/ExciseTax/SustExciseTaxesTransLog.Table.al +++ b/Apps/W1/Sustainability/app/src/ExciseTax/SustExciseTaxesTransLog.Table.al @@ -166,6 +166,7 @@ table 6241 "Sust. Excise Taxes Trans. Log" } field(29; "Source Qty."; Decimal) { + AutoFormatType = 0; Caption = 'Source Qty.'; } field(40; "Material Breakdown No."; Code[20]) @@ -178,6 +179,7 @@ table 6241 "Sust. Excise Taxes Trans. Log" } field(42; "Material Breakdown Weight"; Decimal) { + AutoFormatType = 0; Caption = 'Material Breakdown Weight'; } field(43; "Material Breakdown UOM"; Code[10]) diff --git a/Apps/W1/Sustainability/app/src/FinancialReporting/SustAccountAnalysisView.Table.al b/Apps/W1/Sustainability/app/src/FinancialReporting/SustAccountAnalysisView.Table.al index a0629fcfbc..2b330bbd8e 100644 --- a/Apps/W1/Sustainability/app/src/FinancialReporting/SustAccountAnalysisView.Table.al +++ b/Apps/W1/Sustainability/app/src/FinancialReporting/SustAccountAnalysisView.Table.al @@ -222,7 +222,7 @@ table 6225 "Sust. Account (Analysis View)" } field(100; "Net Change (CO2)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Analysis View Entry"."Emission CO2" where("Analysis View Code" = field("Analysis View Filter"), "Business Unit Code" = field("Business Unit Filter"), @@ -241,7 +241,7 @@ table 6225 "Sust. Account (Analysis View)" } field(101; "Balance at Date (CO2)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Analysis View Entry"."Emission CO2" where("Analysis View Code" = field("Analysis View Filter"), "Business Unit Code" = field("Business Unit Filter"), @@ -260,7 +260,7 @@ table 6225 "Sust. Account (Analysis View)" } field(102; "Balance (CO2)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Analysis View Entry"."Emission CO2" where("Analysis View Code" = field("Analysis View Filter"), "Business Unit Code" = field("Business Unit Filter"), @@ -279,7 +279,7 @@ table 6225 "Sust. Account (Analysis View)" } field(103; "Net Change (CH4)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Analysis View Entry"."Emission CH4" where("Analysis View Code" = field("Analysis View Filter"), "Business Unit Code" = field("Business Unit Filter"), @@ -298,7 +298,7 @@ table 6225 "Sust. Account (Analysis View)" } field(104; "Balance at Date (CH4)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Analysis View Entry"."Emission CH4" where("Analysis View Code" = field("Analysis View Filter"), "Business Unit Code" = field("Business Unit Filter"), @@ -317,7 +317,7 @@ table 6225 "Sust. Account (Analysis View)" } field(105; "Balance (CH4)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Analysis View Entry"."Emission CH4" where("Analysis View Code" = field("Analysis View Filter"), "Business Unit Code" = field("Business Unit Filter"), @@ -336,7 +336,7 @@ table 6225 "Sust. Account (Analysis View)" } field(106; "Net Change (N2O)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Analysis View Entry"."Emission N2O" where("Analysis View Code" = field("Analysis View Filter"), "Business Unit Code" = field("Business Unit Filter"), @@ -355,7 +355,7 @@ table 6225 "Sust. Account (Analysis View)" } field(107; "Balance at Date (N2O)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Analysis View Entry"."Emission N2O" where("Analysis View Code" = field("Analysis View Filter"), "Business Unit Code" = field("Business Unit Filter"), @@ -374,7 +374,7 @@ table 6225 "Sust. Account (Analysis View)" } field(108; "Balance (N2O)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Analysis View Entry"."Emission N2O" where("Analysis View Code" = field("Analysis View Filter"), "Business Unit Code" = field("Business Unit Filter"), @@ -393,7 +393,7 @@ table 6225 "Sust. Account (Analysis View)" } field(109; "Net Change (CO2e Emission)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Analysis View Entry"."CO2e Emission" where("Analysis View Code" = field("Analysis View Filter"), "Business Unit Code" = field("Business Unit Filter"), @@ -411,7 +411,7 @@ table 6225 "Sust. Account (Analysis View)" } field(110; "Bal. at Date (CO2e Emission)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Analysis View Entry"."CO2e Emission" where("Analysis View Code" = field("Analysis View Filter"), "Business Unit Code" = field("Business Unit Filter"), @@ -429,7 +429,7 @@ table 6225 "Sust. Account (Analysis View)" } field(111; "Balance (CO2e Emission)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Analysis View Entry"."CO2e Emission" where("Analysis View Code" = field("Analysis View Filter"), "Business Unit Code" = field("Business Unit Filter"), @@ -447,7 +447,7 @@ table 6225 "Sust. Account (Analysis View)" } field(112; "Net Change (Carbon Fee)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Analysis View Entry"."Carbon Fee" where("Analysis View Code" = field("Analysis View Filter"), "Business Unit Code" = field("Business Unit Filter"), @@ -465,7 +465,7 @@ table 6225 "Sust. Account (Analysis View)" } field(113; "Balance at Date (Carbon Fee)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Analysis View Entry"."Carbon Fee" where("Analysis View Code" = field("Analysis View Filter"), "Business Unit Code" = field("Business Unit Filter"), @@ -483,7 +483,7 @@ table 6225 "Sust. Account (Analysis View)" } field(114; "Balance (Carbon Fee)"; Decimal) { - AutoFormatType = 1; + AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Analysis View Entry"."Carbon Fee" where("Analysis View Code" = field("Analysis View Filter"), "Business Unit Code" = field("Business Unit Filter"), diff --git a/Apps/W1/Sustainability/app/src/FinancialReporting/SustAnalysisEntryBuff.TableExt.al b/Apps/W1/Sustainability/app/src/FinancialReporting/SustAnalysisEntryBuff.TableExt.al index 5ca9fd13fd..27e98a0c1b 100644 --- a/Apps/W1/Sustainability/app/src/FinancialReporting/SustAnalysisEntryBuff.TableExt.al +++ b/Apps/W1/Sustainability/app/src/FinancialReporting/SustAnalysisEntryBuff.TableExt.al @@ -30,6 +30,7 @@ tableextension 6222 "Sust. Analysis Entry Buff." extends "Upd Analysis View Entr } field(6213; "CO2e Emission"; Decimal) { + AutoFormatType = 0; DataClassification = CustomerContent; Caption = 'CO2e Emission'; DecimalPlaces = 2 : 5; @@ -37,6 +38,8 @@ tableextension 6222 "Sust. Analysis Entry Buff." extends "Upd Analysis View Entr } field(6214; "Carbon Fee"; Decimal) { + AutoFormatType = 2; + AutoFormatExpression = ''; DataClassification = CustomerContent; Caption = 'Carbon Fee'; DecimalPlaces = 2 : 5; diff --git a/Apps/W1/Sustainability/app/src/FinancialReporting/SustAnalysisViewEntry.TableExt.al b/Apps/W1/Sustainability/app/src/FinancialReporting/SustAnalysisViewEntry.TableExt.al index 2d1d38f48c..26d188f064 100644 --- a/Apps/W1/Sustainability/app/src/FinancialReporting/SustAnalysisViewEntry.TableExt.al +++ b/Apps/W1/Sustainability/app/src/FinancialReporting/SustAnalysisViewEntry.TableExt.al @@ -38,6 +38,7 @@ tableextension 6223 "Sust. Analysis View Entry" extends "Analysis View Entry" } field(6213; "CO2e Emission"; Decimal) { + AutoFormatType = 0; DataClassification = CustomerContent; Caption = 'CO2e Emission'; DecimalPlaces = 2 : 5; @@ -45,6 +46,8 @@ tableextension 6223 "Sust. Analysis View Entry" extends "Analysis View Entry" } field(6214; "Carbon Fee"; Decimal) { + AutoFormatType = 2; + AutoFormatExpression = ''; DataClassification = CustomerContent; Caption = 'Carbon Fee'; DecimalPlaces = 2 : 5; diff --git a/Apps/W1/Sustainability/app/src/Journal/SustainabilityJnlLine.Table.al b/Apps/W1/Sustainability/app/src/Journal/SustainabilityJnlLine.Table.al index d1d21eece4..87748e77eb 100644 --- a/Apps/W1/Sustainability/app/src/Journal/SustainabilityJnlLine.Table.al +++ b/Apps/W1/Sustainability/app/src/Journal/SustainabilityJnlLine.Table.al @@ -186,6 +186,7 @@ table 6214 "Sustainability Jnl. Line" } field(17; "Installation Multiplier"; Decimal) { + AutoFormatType = 0; Caption = 'Installation Multiplier'; InitValue = 1; @@ -198,6 +199,7 @@ table 6214 "Sustainability Jnl. Line" } field(18; "Time Factor"; Decimal) { + AutoFormatType = 0; Caption = 'Time Factor'; MaxValue = 1; @@ -378,6 +380,7 @@ table 6214 "Sustainability Jnl. Line" } field(32; "CO2e Emission"; Decimal) { + AutoFormatType = 0; DataClassification = CustomerContent; Caption = 'CO2e Emission'; DecimalPlaces = 2 : 5; diff --git a/Apps/W1/Sustainability/app/src/Ledger/SustainabilityLedgerEntry.Table.al b/Apps/W1/Sustainability/app/src/Ledger/SustainabilityLedgerEntry.Table.al index 80cc9c4b20..2daa68054b 100644 --- a/Apps/W1/Sustainability/app/src/Ledger/SustainabilityLedgerEntry.Table.al +++ b/Apps/W1/Sustainability/app/src/Ledger/SustainabilityLedgerEntry.Table.al @@ -99,10 +99,12 @@ table 6216 "Sustainability Ledger Entry" } field(17; "Installation Multiplier"; Decimal) { + AutoFormatType = 0; Caption = 'Installation Multiplier'; } field(18; "Time Factor"; Decimal) { + AutoFormatType = 0; Caption = 'Time Factor'; MaxValue = 1; } @@ -184,12 +186,15 @@ table 6216 "Sustainability Ledger Entry" } field(32; "CO2e Emission"; Decimal) { + AutoFormatType = 0; DataClassification = CustomerContent; Caption = 'CO2e Emission'; DecimalPlaces = 2 : 5; } field(33; "Carbon Fee"; Decimal) { + AutoFormatType = 2; + AutoFormatExpression = ''; DataClassification = CustomerContent; Caption = 'Carbon Fee'; DecimalPlaces = 2 : 5; @@ -257,16 +262,19 @@ table 6216 "Sustainability Ledger Entry" } field(5151; "Emission Factor CO2"; Decimal) { + AutoFormatType = 0; Caption = 'Emission Factor CO2'; CaptionClass = '102,5,1'; } field(5152; "Emission Factor CH4"; Decimal) { + AutoFormatType = 0; Caption = 'Emission Factor CH4'; CaptionClass = '102,5,2'; } field(5153; "Emission Factor N2O"; Decimal) { + AutoFormatType = 0; Caption = 'Emission Factor N2O'; CaptionClass = '102,5,3'; } diff --git a/Apps/W1/Sustainability/app/src/Ledger/SustainabilityValueEntry.Table.al b/Apps/W1/Sustainability/app/src/Ledger/SustainabilityValueEntry.Table.al index 4c3f4efbc5..e5338bcd2d 100644 --- a/Apps/W1/Sustainability/app/src/Ledger/SustainabilityValueEntry.Table.al +++ b/Apps/W1/Sustainability/app/src/Ledger/SustainabilityValueEntry.Table.al @@ -58,16 +58,19 @@ table 6227 "Sustainability Value Entry" } field(7; "Valued Quantity"; Decimal) { + AutoFormatType = 0; Caption = 'Sust. Valued Quantity'; DecimalPlaces = 0 : 5; } field(8; "Item Ledger Entry Quantity"; Decimal) { + AutoFormatType = 0; Caption = 'Item Ledger Entry Quantity'; DecimalPlaces = 0 : 5; } field(9; "Invoiced Quantity"; Decimal) { + AutoFormatType = 0; Caption = 'Invoiced Quantity'; DecimalPlaces = 0 : 5; } diff --git a/Apps/W1/Sustainability/app/src/Purchase/SustPurchCrMemoLine.TableExt.al b/Apps/W1/Sustainability/app/src/Purchase/SustPurchCrMemoLine.TableExt.al index c358a27e33..0f7e2775c9 100644 --- a/Apps/W1/Sustainability/app/src/Purchase/SustPurchCrMemoLine.TableExt.al +++ b/Apps/W1/Sustainability/app/src/Purchase/SustPurchCrMemoLine.TableExt.al @@ -166,11 +166,13 @@ tableextension 6213 "Sust. Purch. Cr. Memo Line" extends "Purch. Cr. Memo Line" } field(6238; "Installation Multiplier"; Decimal) { + AutoFormatType = 0; Caption = 'Installation Multiplier'; DataClassification = CustomerContent; } field(6239; "Time Factor"; Decimal) { + AutoFormatType = 0; Caption = 'Time Factor'; MaxValue = 1; DataClassification = CustomerContent; diff --git a/Apps/W1/Sustainability/app/src/Purchase/SustPurchInvLine.TableExt.al b/Apps/W1/Sustainability/app/src/Purchase/SustPurchInvLine.TableExt.al index 3706ef9b6c..fbbe2e1d5a 100644 --- a/Apps/W1/Sustainability/app/src/Purchase/SustPurchInvLine.TableExt.al +++ b/Apps/W1/Sustainability/app/src/Purchase/SustPurchInvLine.TableExt.al @@ -166,11 +166,13 @@ tableextension 6214 "Sust. Purch. Inv. Line" extends "Purch. Inv. Line" } field(6238; "Installation Multiplier"; Decimal) { + AutoFormatType = 0; Caption = 'Installation Multiplier'; DataClassification = CustomerContent; } field(6239; "Time Factor"; Decimal) { + AutoFormatType = 0; Caption = 'Time Factor'; MaxValue = 1; DataClassification = CustomerContent; diff --git a/Apps/W1/Sustainability/app/src/Purchase/SustPurchRcptLine.TableExt.al b/Apps/W1/Sustainability/app/src/Purchase/SustPurchRcptLine.TableExt.al index 03569091f1..45e287c335 100644 --- a/Apps/W1/Sustainability/app/src/Purchase/SustPurchRcptLine.TableExt.al +++ b/Apps/W1/Sustainability/app/src/Purchase/SustPurchRcptLine.TableExt.al @@ -166,11 +166,13 @@ tableextension 6216 "Sust. Purch. Rcpt. Line" extends "Purch. Rcpt. Line" } field(6238; "Installation Multiplier"; Decimal) { + AutoFormatType = 0; Caption = 'Installation Multiplier'; DataClassification = CustomerContent; } field(6239; "Time Factor"; Decimal) { + AutoFormatType = 0; Caption = 'Time Factor'; MaxValue = 1; DataClassification = CustomerContent; diff --git a/Apps/W1/Sustainability/app/src/Purchase/SustPurchRetShptLine.TableExt.al b/Apps/W1/Sustainability/app/src/Purchase/SustPurchRetShptLine.TableExt.al index 288d7e91d4..5d29df2a57 100644 --- a/Apps/W1/Sustainability/app/src/Purchase/SustPurchRetShptLine.TableExt.al +++ b/Apps/W1/Sustainability/app/src/Purchase/SustPurchRetShptLine.TableExt.al @@ -166,11 +166,13 @@ tableextension 6215 "Sust. Purch. Ret. Shpt. Line" extends "Return Shipment Line } field(6238; "Installation Multiplier"; Decimal) { + AutoFormatType = 0; Caption = 'Installation Multiplier'; DataClassification = CustomerContent; } field(6239; "Time Factor"; Decimal) { + AutoFormatType = 0; Caption = 'Time Factor'; MaxValue = 1; DataClassification = CustomerContent; diff --git a/Apps/W1/Sustainability/app/src/Purchase/SustainabilityPurchLine.TableExt.al b/Apps/W1/Sustainability/app/src/Purchase/SustainabilityPurchLine.TableExt.al index 8303ec2548..c87c21b63d 100644 --- a/Apps/W1/Sustainability/app/src/Purchase/SustainabilityPurchLine.TableExt.al +++ b/Apps/W1/Sustainability/app/src/Purchase/SustainabilityPurchLine.TableExt.al @@ -450,6 +450,7 @@ tableextension 6211 "Sustainability Purch. Line" extends "Purchase Line" } field(6238; "Installation Multiplier"; Decimal) { + AutoFormatType = 0; Caption = 'Installation Multiplier'; DataClassification = CustomerContent; @@ -464,6 +465,7 @@ tableextension 6211 "Sustainability Purch. Line" extends "Purchase Line" } field(6239; "Time Factor"; Decimal) { + AutoFormatType = 0; Caption = 'Time Factor'; MaxValue = 1; DataClassification = CustomerContent; diff --git a/Apps/W1/Sustainability/app/src/Reports/SustItemEmissionBuffer.Table.al b/Apps/W1/Sustainability/app/src/Reports/SustItemEmissionBuffer.Table.al index 933409d07d..1eff512869 100644 --- a/Apps/W1/Sustainability/app/src/Reports/SustItemEmissionBuffer.Table.al +++ b/Apps/W1/Sustainability/app/src/Reports/SustItemEmissionBuffer.Table.al @@ -63,6 +63,7 @@ table 6250 "Sust. Item Emission Buffer" } field(15; "Quantity"; Decimal) { + AutoFormatType = 0; Caption = 'Quantity'; DecimalPlaces = 0 : 5; } diff --git a/Apps/W1/Sustainability/app/src/RoleCenters/SustainabilityActivities.Page.al b/Apps/W1/Sustainability/app/src/RoleCenters/SustainabilityActivities.Page.al index 0ab38c27db..50cf82ad04 100644 --- a/Apps/W1/Sustainability/app/src/RoleCenters/SustainabilityActivities.Page.al +++ b/Apps/W1/Sustainability/app/src/RoleCenters/SustainabilityActivities.Page.al @@ -33,6 +33,7 @@ page 6236 "Sustainability Activities" field("Emission CO2"; EmissionCO2) { ApplicationArea = All; + AutoFormatType = 0; Caption = 'CO2 This Month'; StyleExpr = EmissionCO2StyleText; DecimalPlaces = 2 : 2; @@ -47,6 +48,7 @@ page 6236 "Sustainability Activities" field("Emission CH4"; EmissionCH4) { ApplicationArea = All; + AutoFormatType = 0; Caption = 'CH4 This Month'; StyleExpr = EmissionCH4StyleText; DecimalPlaces = 2 : 2; @@ -61,6 +63,7 @@ page 6236 "Sustainability Activities" field("Emission N2O"; EmissionN2O) { ApplicationArea = All; + AutoFormatType = 0; Caption = 'N2O This Month'; StyleExpr = EmissionN2OStyleText; DecimalPlaces = 2 : 2; @@ -82,6 +85,7 @@ page 6236 "Sustainability Activities" field("Water Intensity"; WaterIntensity) { ApplicationArea = All; + AutoFormatType = 0; Caption = 'Water This Month'; StyleExpr = WaterIntensityStyleText; DecimalPlaces = 2 : 2; @@ -96,6 +100,7 @@ page 6236 "Sustainability Activities" field("Waste Intensity"; WasteIntensity) { ApplicationArea = All; + AutoFormatType = 0; Caption = 'Waste This Month'; StyleExpr = WasteIntensityStyleText; DecimalPlaces = 2 : 2; diff --git a/Apps/W1/Sustainability/app/src/RoleCenters/SustainabilityGoalCue.Table.al b/Apps/W1/Sustainability/app/src/RoleCenters/SustainabilityGoalCue.Table.al index 17c12a0634..03dce8e047 100644 --- a/Apps/W1/Sustainability/app/src/RoleCenters/SustainabilityGoalCue.Table.al +++ b/Apps/W1/Sustainability/app/src/RoleCenters/SustainabilityGoalCue.Table.al @@ -15,51 +15,61 @@ table 6221 "Sustainability Goal Cue" } field(2; "Realized % for CO2"; Decimal) { + AutoFormatType = 0; Caption = 'Realized % for CO2'; Editable = false; } field(3; "Realized % for CH4"; Decimal) { + AutoFormatType = 0; Caption = 'Realized % for CH4'; Editable = false; } field(4; "Realized % for N2O"; Decimal) { + AutoFormatType = 0; Caption = 'Realized % for N2O'; Editable = false; } field(5; "CO2 % vs Baseline"; Decimal) { + AutoFormatType = 0; Caption = 'CO2 % vs Baseline'; Editable = false; } field(6; "CH4 % vs Baseline"; Decimal) { + AutoFormatType = 0; Caption = 'CH4 % vs Baseline'; Editable = false; } field(7; "N2O % vs Baseline"; Decimal) { + AutoFormatType = 0; Caption = 'N2O % vs Baseline'; Editable = false; } field(10; "Realized % for Water"; Decimal) { + AutoFormatType = 0; Caption = 'Realized % for Water'; Editable = false; } field(11; "Realized % for Waste"; Decimal) { + AutoFormatType = 0; Caption = 'Realized % for Waste'; Editable = false; } field(12; "Water % vs Baseline"; Decimal) { + AutoFormatType = 0; Caption = 'Water % vs Baseline'; Editable = false; } field(13; "Waste % vs Baseline"; Decimal) { + AutoFormatType = 0; Caption = 'Waste % vs Baseline'; Editable = false; } diff --git a/Apps/W1/Sustainability/app/src/Scorecard/SustainabilityGoal.Table.al b/Apps/W1/Sustainability/app/src/Scorecard/SustainabilityGoal.Table.al index 8872133892..5f67b6094f 100644 --- a/Apps/W1/Sustainability/app/src/Scorecard/SustainabilityGoal.Table.al +++ b/Apps/W1/Sustainability/app/src/Scorecard/SustainabilityGoal.Table.al @@ -178,16 +178,19 @@ table 6219 "Sustainability Goal" } field(19; "Target Value for CO2"; Decimal) { + AutoFormatType = 0; Caption = 'Target Value for CO2'; CaptionClass = '102,9,1'; } field(20; "Target Value for CH4"; Decimal) { + AutoFormatType = 0; Caption = 'Target Value for CH4'; CaptionClass = '102,9,2'; } field(21; "Target Value for N2O"; Decimal) { + AutoFormatType = 0; Caption = 'Target Value for N2O'; CaptionClass = '102,9,3'; } @@ -273,10 +276,12 @@ table 6219 "Sustainability Goal" } field(31; "Target Value for Water Int."; Decimal) { + AutoFormatType = 0; Caption = 'Target Value for Water Intensity'; } field(32; "Target Value for Waste Int."; Decimal) { + AutoFormatType = 0; Caption = 'Target Value for Waste Intensity'; } } diff --git a/Apps/W1/Sustainability/app/src/Setup/ResponsibilityCenterTabExt.TableExt.al b/Apps/W1/Sustainability/app/src/Setup/ResponsibilityCenterTabExt.TableExt.al index 988ab2fd90..70f05b7713 100644 --- a/Apps/W1/Sustainability/app/src/Setup/ResponsibilityCenterTabExt.TableExt.al +++ b/Apps/W1/Sustainability/app/src/Setup/ResponsibilityCenterTabExt.TableExt.al @@ -14,6 +14,7 @@ tableextension 6226 "Responsibility Center - TabExt" extends "Responsibility Cen } field(6211; "Water Capacity Quantity(Month)"; Decimal) { + AutoFormatType = 0; DataClassification = CustomerContent; Caption = 'Water Capacity Quantity(Month)'; DecimalPlaces = 2 : 2; diff --git a/Apps/W1/Sustainability/app/src/Setup/SustainabilitySetup.Table.al b/Apps/W1/Sustainability/app/src/Setup/SustainabilitySetup.Table.al index 8285f39859..efd8f38dbf 100644 --- a/Apps/W1/Sustainability/app/src/Setup/SustainabilitySetup.Table.al +++ b/Apps/W1/Sustainability/app/src/Setup/SustainabilitySetup.Table.al @@ -41,6 +41,7 @@ table 6217 "Sustainability Setup" } field(4; "Reporting UOM Factor"; Decimal) { + AutoFormatType = 0; InitValue = 1; Caption = 'Reporting UOM Factor'; DecimalPlaces = 0 : 10; @@ -56,6 +57,7 @@ table 6217 "Sustainability Setup" } field(6; "Emission Rounding Precision"; Decimal) { + AutoFormatType = 0; Caption = 'Emission Rounding Precision'; DecimalPlaces = 0 : 10; InitValue = 0.01; @@ -186,6 +188,7 @@ table 6217 "Sustainability Setup" } field(28; "Energy Reporting UOM Factor"; Decimal) { + AutoFormatType = 0; InitValue = 1; Caption = 'Energy Reporting UOM Factor'; DecimalPlaces = 0 : 10; diff --git a/Apps/W1/VATGroupManagement/app/app.json b/Apps/W1/VATGroupManagement/app/app.json index fe85a81bfc..b07aefbd70 100644 --- a/Apps/W1/VATGroupManagement/app/app.json +++ b/Apps/W1/VATGroupManagement/app/app.json @@ -31,5 +31,8 @@ "allowDownloadingSource": true, "includeSourceInSymbolFile": true }, - "target": "OnPrem" + "target": "OnPrem", + "features": [ + "TranslationFile" + ] } diff --git a/Apps/W1/VATGroupManagement/app/src/Codeunits/VATGroupCommunication.Codeunit.al b/Apps/W1/VATGroupManagement/app/src/Codeunits/VATGroupCommunication.Codeunit.al index 8660386f2e..e440519177 100644 --- a/Apps/W1/VATGroupManagement/app/src/Codeunits/VATGroupCommunication.Codeunit.al +++ b/Apps/W1/VATGroupManagement/app/src/Codeunits/VATGroupCommunication.Codeunit.al @@ -329,7 +329,7 @@ codeunit 4700 "VAT Group Communication" GroupRepCompanyName: Text; begin CheckLoadVATReportSetup(); - Result := VATReportSetup."Group Representative API URL"; + Result := VATReportSetup.GetGroupRepresentativeURL(); GroupRepCompanyName := VATReportSetup."Group Representative Company"; case VATReportSetup."VAT Group BC Version" of VATReportSetup."VAT Group BC Version"::BC: @@ -356,7 +356,7 @@ codeunit 4700 "VAT Group Communication" local procedure PrepareBatchURI(Endpoint: Text) Result: Text begin - Result := VATReportSetup."Group Representative API URL"; + Result := VATReportSetup.GetGroupRepresentativeURL(); case VATReportSetup."VAT Group BC Version" of VATReportSetup."VAT Group BC Version"::BC: Result += URLAppendixLbl; diff --git a/Apps/W1/VATGroupManagement/app/src/Tables/VATReportSetupExtension.TableExt.al b/Apps/W1/VATGroupManagement/app/src/Tables/VATReportSetupExtension.TableExt.al index ba32386e70..ba0a34fa18 100644 --- a/Apps/W1/VATGroupManagement/app/src/Tables/VATReportSetupExtension.TableExt.al +++ b/Apps/W1/VATGroupManagement/app/src/Tables/VATReportSetupExtension.TableExt.al @@ -7,10 +7,10 @@ namespace Microsoft.Finance.VAT.Group; using Microsoft.Finance.GeneralLedger.Account; using Microsoft.Finance.GeneralLedger.Journal; using Microsoft.Finance.VAT.Reporting; +using System.Environment; tableextension 4701 "VAT Report Setup Extension" extends "VAT Report Setup" { - fields { field(4700; "VAT Group Role"; Enum "VAT Group Role") @@ -35,6 +35,15 @@ tableextension 4701 "VAT Report Setup Extension" extends "VAT Report Setup" DataClassification = OrganizationIdentifiableInformation; Caption = 'Group Representative API URL'; ExtendedDatatype = URL; + + trigger OnValidate() + var + EnvironmentInformation: Codeunit "Environment Information"; + begin + if EnvironmentInformation.IsSaaSInfrastructure() then + if not ValidateGroupRepresentativeAPIURL() then + Error(InvalidURLErr); + end; } #if not CLEANSCHEMA25 #pragma warning disable AL0432 @@ -178,4 +187,29 @@ tableextension 4701 "VAT Report Setup Extension" extends "VAT Report Setup" begin exit("VAT Group Role" = "VAT Group Role"::Member); end; + + procedure GetGroupRepresentativeURL(): Text[250] + var + EnvironmentInformation: Codeunit "Environment Information"; + GroupRepAPIURL: Text[250]; + begin + GroupRepAPIURL := Rec."Group Representative API URL"; + if EnvironmentInformation.IsSaaSInfrastructure() then + if not ValidateGroupRepresentativeAPIURL() then + Error(InvalidURLErr); + exit(GroupRepAPIURL); + end; + + internal procedure ValidateGroupRepresentativeAPIURL(): Boolean + begin + if Rec."Group Representative API URL" <> '' then + if not Lowercase(Rec."Group Representative API URL").StartsWith('https://api.businesscentral.dynamics.com') then + if not Lowercase(Rec."Group Representative API URL").StartsWith('https://api.businesscentral.dynamics-tie.com') then + exit(false); + + exit(true); + end; + + var + InvalidURLErr: Label 'The Group Representative API URL must start with https://api.businesscentral.dynamics.com or https://api.businesscentral.dynamics-tie.com'; } \ No newline at end of file diff --git a/Apps/W1/VATGroupManagement/test/src/VATGroupHelperFunctTest.Codeunit.al b/Apps/W1/VATGroupManagement/test/src/VATGroupHelperFunctTest.Codeunit.al index 67e7353485..019ca9064a 100644 --- a/Apps/W1/VATGroupManagement/test/src/VATGroupHelperFunctTest.Codeunit.al +++ b/Apps/W1/VATGroupManagement/test/src/VATGroupHelperFunctTest.Codeunit.al @@ -808,6 +808,69 @@ codeunit 139520 "VAT Group Helper Funct Test" DummyVATReportSetup."VAT Group BC Version"::BC, 'GetVATGroupDefaultBCVersion'); end; + [Test] + procedure ValidateURLWithValidProductionURL() + var + VATReportSetup: Record "VAT Report Setup"; + begin + // [FEATURE] [AI test] + + // [GIVEN] VAT Report Setup + VATReportSetup."Group Representative API URL" := 'https://api.businesscentral.dynamics.com'; + + // [WHEN] ValidateURL is called with valid production URL "https://api.businesscentral.dynamics.com" + // [THEN] ValidateURL returns true + Assert.IsTrue(VATReportSetup.ValidateGroupRepresentativeAPIURL(), 'The production API URL should be valid'); + end; + + [Test] + procedure ValidateURLWithValidTieURL() + var + VATReportSetup: Record "VAT Report Setup"; + begin + // [FEATURE] [AI test] + // [SCENARIO] Validate URL returns true for valid TIE API URL + + // [GIVEN] VAT Report Setup + VATReportSetup."Group Representative API URL" := 'https://api.businesscentral.dynamics-tie.com'; + + // [WHEN] ValidateURL is called with valid TIE URL "https://api.businesscentral.dynamics-tie.com" + // [THEN] ValidateURL returns true + Assert.IsTrue(VATReportSetup.ValidateGroupRepresentativeAPIURL(), 'The staging API URL should be valid'); + end; + + [Test] + procedure ValidateURLWithEmptyURL() + var + VATReportSetup: Record "VAT Report Setup"; + begin + // [FEATURE] [AI test] + // [SCENARIO] Validate URL returns true for empty URL + + // [GIVEN] VAT Report Setup + VATReportSetup."Group Representative API URL" := ''; + + // [WHEN] ValidateURL is called with empty URL + // [THEN] ValidateURL returns true + Assert.IsTrue(VATReportSetup.ValidateGroupRepresentativeAPIURL(), 'The empty API URL should be valid'); + end; + + [Test] + procedure ValidateURLWithInvalidURL() + var + VATReportSetup: Record "VAT Report Setup"; + begin + // [FEATURE] [AI test] + // [SCENARIO] Validate URL returns false for invalid URL + + // [GIVEN] VAT Report Setup + VATReportSetup."Group Representative API URL" := 'https://invalid.url.com'; + + // [WHEN] ValidateURL is called with invalid URL "https://invalid.url.com" + // [THEN] ValidateURL returns false + Assert.IsFalse(VATReportSetup.ValidateGroupRepresentativeAPIURL(), 'The invalid API URL should not be valid'); + end; + local procedure Initialize() begin LibraryVATGroup.EnableDefaultVATMemberSetup(); diff --git a/Apps/W1/WithholdingTax/Test/src/ERMWithholdingTaxTestsI.Codeunit.al b/Apps/W1/WithholdingTax/Test/src/ERMWithholdingTaxTestsI.Codeunit.al index 61dcf37f22..4c1edd9218 100644 --- a/Apps/W1/WithholdingTax/Test/src/ERMWithholdingTaxTestsI.Codeunit.al +++ b/Apps/W1/WithholdingTax/Test/src/ERMWithholdingTaxTestsI.Codeunit.al @@ -57,19 +57,20 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Create Vendor. WHTGeneralJournalLineWithoutAppliedIdPostingErr( - GenJournalLine."Account Type"::Vendor, LibraryPurchase.CreateVendorWithVATBusPostingGroup(''), - LibraryRandom.RandDec(10, 2)); // Blank VAT Business Posting Group, Random as Amount. + GenJournalLine."Account Type"::Vendor, LibraryRandom.RandDec(10, 2)); // Blank VAT Business Posting Group, Random as Amount. end; - local procedure WHTGeneralJournalLineWithoutAppliedIdPostingErr(AccountType: Enum "Gen. Journal Account Type"; AccountNumber: Code[20]; Amount: Decimal) + local procedure WHTGeneralJournalLineWithoutAppliedIdPostingErr(AccountType: Enum "Gen. Journal Account Type"; Amount: Decimal) var GenJournalLine: Record "Gen. Journal Line"; WHTPostingSetup: Record "Withholding Tax Posting Setup"; + VendorNo: Code[20]; begin UpdateGeneralLedgerSetup(true, false); // Round Amount for WHT Calc and True as Enable WHT. - FindWHTPostingSetup(WHTPostingSetup); + CreateWHTPostingSetup(WHTPostingSetup); + VendorNo := CreateVendorWithPostingGroup('', WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); CreateGeneralJournalLineWithCurrency( - GenJournalLine, WHTPostingSetup, AccountType, GenJournalLine."Document Type"::Payment, AccountNumber, '', '', Amount); // Blank as Applies To Doc No and Currency Code. + GenJournalLine, WHTPostingSetup, AccountType, GenJournalLine."Document Type"::Payment, VendorNo, '', '', Amount); // Blank as Applies To Doc No and Currency Code. // [WHEN] Post Payment Journal with WHT. asserterror LibraryERM.PostGeneralJnlLine(GenJournalLine); @@ -112,13 +113,13 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Create G/L Account and WHT Posting Setup. UpdateGeneralLedgerSetup(true, false); // Round Amount for WHT Calc and True as Enable WHT. LibraryERM.FindVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT"); - FindWHTPostingSetup(WHTPostingSetup); + CreateWHTPostingSetup(WHTPostingSetup); // [WHEN] Create and Post Purchase Document with WHT. DocumentNo := CreateAndPostPurchaseDocumentWithWHT(PurchaseLine, WHTPostingSetup, DocumentType, - LibraryPurchase.CreateVendorWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Posting Group"), - CreateGLAccount(VATPostingSetup."VAT Prod. Posting Group"), ''); // Blank Currency Code. + CreateVendorWithPostingGroup(VATPostingSetup."VAT Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"), + CreateGLAccount(VATPostingSetup."VAT Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), ''); // Blank Currency Code. // [THEN] Verify WHT Entry - Unrealized Amount, Unrealized Base and G/L Entry - Amount. VerifyWHTEntriesAndGLEntry( @@ -145,11 +146,11 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Create Payment Journal with WHT and apply Posted Purchase Invoice. UpdateGeneralLedgerSetup(true, false); // Round Amount for WHT Calc and True as Enable WHT. LibraryERM.FindVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT"); - FindWHTPostingSetup(WHTPostingSetup); - VendorNo := LibraryPurchase.CreateVendorWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Posting Group"); + CreateWHTPostingSetup(WHTPostingSetup); + VendorNo := CreateVendorWithPostingGroup(VATPostingSetup."VAT Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); PostedInvoiceNo := CreateAndPostPurchaseDocumentWithWHT(PurchaseLine, WHTPostingSetup, PurchaseHeader."Document Type"::Invoice, - VendorNo, CreateGLAccount(VATPostingSetup."VAT Prod. Posting Group"), ''); // Blank Currency Code. + VendorNo, CreateGLAccount(VATPostingSetup."VAT Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), ''); // Blank Currency Code. CreateGeneralJournalLineWithCurrency( GenJournalLine, WHTPostingSetup, GenJournalLine."Account Type"::Vendor, GenJournalLine."Document Type"::Payment, VendorNo, PostedInvoiceNo, '', PurchaseLine."Amount Including VAT" + 1); @@ -183,13 +184,13 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Create Payment Journal with Currency Code and WHT and apply Posted Purchase Invoice. UpdateGeneralLedgerSetup(true, false); // Round Amount for WHT Calc and True as Enable WHT. LibraryERM.FindVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT"); - FindWHTPostingSetup(WHTPostingSetup); + CreateWHTPostingSetup(WHTPostingSetup); CurrencyCode := CreateCurrencyWithExchangeRate(); PostedInvoiceNo := CreateAndPostPurchaseDocumentWithWHT( PurchaseLine, WHTPostingSetup, PurchaseHeader."Document Type"::Invoice, - LibraryPurchase.CreateVendorWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Posting Group"), - CreateGLAccount(VATPostingSetup."VAT Prod. Posting Group"), CurrencyCode); + CreateVendorWithPostingGroup(VATPostingSetup."VAT Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"), + CreateGLAccount(VATPostingSetup."VAT Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), CurrencyCode); BankAccountLEAmount := PurchaseLine."Line Amount" * (1 - (GetWHTEntryAmount(PostedInvoiceNo) / PurchaseLine."Amount Including VAT") * WHTPostingSetup."Withholding Tax %" / 100); @@ -223,11 +224,11 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Create Purchase Invoice with WHT. UpdateGeneralLedgerSetup(true, false); // Round Amount for WHT Calc and True as Enable WHT. LibraryERM.FindVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT"); - FindWHTPostingSetup(WHTPostingSetup); + CreateWHTPostingSetup(WHTPostingSetup); CreatePurchaseDocument( PurchaseLine, WHTPostingSetup, PurchaseHeader."Document Type"::Invoice, - LibraryPurchase.CreateVendorWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Posting Group"), - CreateGLAccount(VATPostingSetup."VAT Prod. Posting Group"), ''); // Blank Currency Code. + CreateVendorWithPostingGroup(VATPostingSetup."VAT Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"), + CreateGLAccount(VATPostingSetup."VAT Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), ''); // Blank Currency Code. PurchaseHeader.Get(PurchaseLine."Document Type", PurchaseLine."Document No."); WHTAmount := PurchaseLine.Amount * WHTPostingSetup."Withholding Tax %" / 100; @@ -257,8 +258,8 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Create Payment Journal with WHT and apply Posted Purchase Invoice. UpdateGeneralLedgerSetup(true, false); // Round Amount for WHT Calc and True as Enable WHT. LibraryERM.FindVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT"); - FindWHTPostingSetup(WHTPostingSetup); - VendorNo := LibraryPurchase.CreateVendorWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Posting Group"); + CreateWHTPostingSetup(WHTPostingSetup); + VendorNo := CreateVendorWithPostingGroup(VATPostingSetup."VAT Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); PostedInvoiceNo := PostedPurchaseInvoiceLCY(PurchaseLine, VATPostingSetup, WHTPostingSetup, VendorNo); @@ -291,14 +292,14 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Create Payment Journal with WHT and apply Posted Purchase Invoice. UpdateGeneralLedgerSetup(true, false); // Round Amount for WHT Calc and True as Enable WHT. LibraryERM.FindVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT"); - FindWHTPostingSetup(WHTPostingSetup); + CreateWHTPostingSetup(WHTPostingSetup); LibraryERM.CreateGeneralPostingSetupInvt(GeneralPostingSetup); - VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group"); + VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); PostedInvoiceNo := CreateAndPostPurchaseDocumentWithWHT( PurchaseLine, WHTPostingSetup, PurchaseHeader."Document Type"::Invoice, VendorNo, - CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), CurrencyCode); + CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), CurrencyCode); CreateGeneralJournalLineWithCurrency( GenJournalLine, WHTPostingSetup, GenJournalLine."Account Type"::Vendor, GenJournalLine."Document Type"::Payment, PurchaseLine."Buy-from Vendor No.", PostedInvoiceNo, CurrencyCode, PurchaseLine."Amount Including VAT"); // Random as Amount. @@ -338,10 +339,10 @@ codeunit 148321 "ERM Withholding Tax Tests I" CurrencyCode := CreateCurrencyWithExchangeRate(); UpdateAdditionalCurrency(CurrencyCode); LibraryERM.FindVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT"); - GLAccountNo := CreateGLAccount(VATPostingSetup."VAT Prod. Posting Group"); - UpdateVATBusPostingGroupOnGLAccount(GLAccountNo, VATPostingSetup."VAT Bus. Posting Group"); - VendorNo := LibraryPurchase.CreateVendorWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Posting Group"); CreateWHTPostingSetup(WHTPostingSetup, LibraryRandom.RandIntInRange(10, 20)); + GLAccountNo := CreateGLAccount(VATPostingSetup."VAT Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"); + UpdateVATBusPostingGroupOnGLAccount(GLAccountNo, VATPostingSetup."VAT Bus. Posting Group"); + VendorNo := CreateVendorWithPostingGroup(VATPostingSetup."VAT Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); CreateGeneralJournalLineWithCurrency( GenJournalLine, WHTPostingSetup, GenJournalLine."Account Type"::Vendor, GenJournalLine."Document Type"::Invoice, VendorNo, '', CurrencyCode, -LibraryRandom.RandDecInRange(1, 10, 2)); // Random as Amount and Blank Applies To Doc No. @@ -373,7 +374,7 @@ codeunit 148321 "ERM Withholding Tax Tests I" Initialize(); // [GIVEN] Enabled WHT UpdateGeneralLedgerSetup(true, false); - FindWHTPostingSetup(WHTPostingSetup); + CreateWHTPostingSetup(WHTPostingSetup); // [GIVEN] Bank Account with Currency CurrencyCode := CreateCurrencyWithExchangeRate(); LibraryERM.CreateBankAccount(BankAccount); @@ -555,10 +556,10 @@ codeunit 148321 "ERM Withholding Tax Tests I" Initialize(); UpdateGeneralLedgerSetup(true, false); // Round Amount for WHT Calc and True as Enable WHT. LibraryERM.FindVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT"); - FindWHTPostingSetup(WHTPostingSetup); + CreateWHTPostingSetup(WHTPostingSetup); WHTPostingSetup."Withholding Tax %" := 3; WHTPostingSetup.Modify(); - VendorNo := LibraryPurchase.CreateVendorWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Posting Group"); + VendorNo := CreateVendorWithPostingGroup(VATPostingSetup."VAT Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); // [GIVEN] Posted "Invoice[1]" with Amount = 279729.45 InvoiceNo[1] := PostInvoice(VendorNo, -279729.45, WHTPostingSetup); @@ -610,10 +611,10 @@ codeunit 148321 "ERM Withholding Tax Tests I" Initialize(); UpdateGeneralLedgerSetup(true, false); // Round Amount for WHT Calc and True as Enable WHT. LibraryERM.FindVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT"); - FindWHTPostingSetup(WHTPostingSetup); + CreateWHTPostingSetup(WHTPostingSetup); WHTPostingSetup."Withholding Tax %" := 3; WHTPostingSetup.Modify(); - VendorNo := LibraryPurchase.CreateVendorWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Posting Group"); + VendorNo := CreateVendorWithPostingGroup(VATPostingSetup."VAT Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); // [GIVEN] Posted "Invoice[1]" with Amount = 254299.5 InvoiceNo[1] := PostInvoice(VendorNo, -254299.5, WHTPostingSetup); @@ -660,10 +661,10 @@ codeunit 148321 "ERM Withholding Tax Tests I" Initialize(); UpdateGeneralLedgerSetup(true, false); // Round Amount for WHT Calc and True as Enable WHT. LibraryERM.FindVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT"); - FindWHTPostingSetup(WHTPostingSetup); + CreateWHTPostingSetup(WHTPostingSetup); WHTPostingSetup."Withholding Tax %" := 3; WHTPostingSetup.Modify(); - VendorNo := LibraryPurchase.CreateVendorWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Posting Group"); + VendorNo := CreateVendorWithPostingGroup(VATPostingSetup."VAT Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); AppliedAmount[1] := LibraryRandom.RandIntInRange(100, 200); AppliedAmount[2] := LibraryRandom.RandIntInRange(100, 200); @@ -706,10 +707,10 @@ codeunit 148321 "ERM Withholding Tax Tests I" Initialize(); UpdateGeneralLedgerSetup(true, false); // Round Amount for WHT Calc and True as Enable WHT. LibraryERM.FindVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT"); - FindWHTPostingSetup(WHTPostingSetup); + CreateWHTPostingSetup(WHTPostingSetup); WHTPostingSetup."Withholding Tax %" := 3; WHTPostingSetup.Modify(); - VendorNo := LibraryPurchase.CreateVendorWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Posting Group"); + VendorNo := CreateVendorWithPostingGroup(VATPostingSetup."VAT Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); // [GIVEN] Posted 5 Invoice with Amount = 254299.5 each for Index := 1 to ArrayLen(InvoiceNo) do begin @@ -751,7 +752,7 @@ codeunit 148321 "ERM Withholding Tax Tests I" LibraryERM.CreateGeneralPostingSetupInvt(GeneralPostingSetup); // [GIVEN] Posted Gen. Journal Line "D1" with Vendor "V", empty "Document Type" and negative Amount. - VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group"); + VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); GenJnlLineAmount := LibraryRandom.RandDecInRange(1000, 2000, 2); InvoiceAmount := LibraryRandom.RandDecInRange(1000, 2000, 2); CreateAndPostGenJnlLineVendorAndSetAppliesToID( @@ -760,7 +761,7 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Posted Purchase Invoice "D2" for Vendor "V". Amount is greater than WHTSetup's Minimum Invoice Amount. InvoiceNo := CreateAndPostPurchaseDocumentWithWHTAndAmount(WHTPostingSetup, PurchaseHeader."Document Type"::Invoice, - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), InvoiceAmount); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), InvoiceAmount); AppliesToID := SetAppliesToIDVendorDocument(VendorLedgerEntry."Document Type"::Invoice, InvoiceNo); // [GIVEN] Gen. Journal Line "D3" with Vendor "V", "Document Type" = Payment, Amount is between ABS("D2".Amount) and ABS("D1".Amount + "D2".Amount). @@ -803,7 +804,7 @@ codeunit 148321 "ERM Withholding Tax Tests I" LibraryERM.CreateGeneralPostingSetupInvt(GeneralPostingSetup); // [GIVEN] Posted Gen. Journal Line "D1" with Vendor "V", empty "Document Type" and positive Amount. - VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group"); + VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); GenJnlLineAmount := LibraryRandom.RandDecInRange(100, 200, 2); InvoiceAmount := LibraryRandom.RandDecInRange(1000, 2000, 2); CreateAndPostGenJnlLineVendorAndSetAppliesToID( @@ -812,7 +813,7 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Posted Purchase Invoice "D2" for Vendor "V". Amount is greater than WHTSetup's Minimum Invoice Amount. InvoiceNo := CreateAndPostPurchaseDocumentWithWHTAndAmount(WHTPostingSetup, PurchaseHeader."Document Type"::Invoice, - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), InvoiceAmount); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), InvoiceAmount); AppliesToID := SetAppliesToIDVendorDocument(VendorLedgerEntry."Document Type"::Invoice, InvoiceNo); // [GIVEN] Gen. Journal Line "D3" with Vendor "V", "Document Type" = Payment, Amount is between ABS("D2".Amount - "D1".Amount) and ABS("D2".Amount). @@ -858,14 +859,14 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Posted Purchase Invoice "D1" for Vendor "V". Amount is greater than WHTSetup's Minimum Invoice Amount. // [GIVEN] Posted Purchase Cr. Memo "D2" for Vendor "V". Amount is greater than WHTSetup's Minimum Invoice Amount. // [GIVEN] "D2" is applied to "D1". - VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group"); + VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); InvoiceAmount := LibraryRandom.RandDecInRange(1000, 2000, 2); CrMemoAmount := LibraryRandom.RandDecInRange(100, 200, 2); InvoiceNo := CreateAndPostPurchaseDocumentWithWHTAndAmount(WHTPostingSetup, PurchaseHeader."Document Type"::Invoice, - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), InvoiceAmount); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), InvoiceAmount); CreateAndPostPurchaseDocumentWithWHTAndAppliesToDocNo(WHTPostingSetup, PurchaseHeader."Document Type"::"Credit Memo", - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), InvoiceNo, 1, CrMemoAmount); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), InvoiceNo, 1, CrMemoAmount); AppliesToID := SetAppliesToIDVendorDocument(VendorLedgerEntry."Document Type"::Invoice, InvoiceNo); @@ -912,15 +913,15 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Posted Purchase Invoice "D1" for Vendor "V". Amount is greater than WHTSetup's Minimum Invoice Amount. // [GIVEN] Posted Purchase Cr. Memo "D2" for Vendor "V". Amount is greater than WHTSetup's Minimum Invoice Amount. - VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group"); + VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); InvoiceAmount := LibraryRandom.RandDecInRange(1000, 2000, 2); CrMemoAmount := LibraryRandom.RandDecInRange(100, 200, 2); DocumentNo.Add( CreateAndPostPurchaseDocumentWithWHTAndAmount(WHTPostingSetup, PurchaseHeader."Document Type"::Invoice, - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), InvoiceAmount)); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), InvoiceAmount)); DocumentNo.Add( CreateAndPostPurchaseDocumentWithWHTAndAmount(WHTPostingSetup, PurchaseHeader."Document Type"::"Credit Memo", - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), CrMemoAmount)); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), CrMemoAmount)); AppliesToID := SetAppliesToIDVendorDocument(VendorLedgerEntry."Document Type"::Invoice, DocumentNo.Get(1)); SetAppliesToIDVendorDocument(VendorLedgerEntry."Document Type"::"Credit Memo", DocumentNo.Get(2)); @@ -935,7 +936,7 @@ codeunit 148321 "ERM Withholding Tax Tests I" WHTAmount := WHTTaxManagement.WithholdingAmountJournal(GenJournalLine, false); // [THEN] WHT Amount of "D3" is equal to (InvoiceAmount - CrMemoAmount) * WHT%. - ExpectedWHTAmt := Round((InvoiceAmount - CrMemoAmount) * WHTPostingSetup."Withholding Tax %" / 100); + ExpectedWHTAmt := Round(InvoiceAmount * WHTPostingSetup."Withholding Tax %" / 100) - Round(CrMemoAmount * WHTPostingSetup."Withholding Tax %" / 100); Assert.AreEqual(ExpectedWHTAmt, WHTAmount, ''); end; @@ -969,15 +970,15 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Posted Purchase Invoice "D1" for Vendor "V". Amount is greater than WHTSetup's Minimum Invoice Amount. // [GIVEN] Posted Purchase Cr. Memo "D2" for Vendor "V". Amount is less than WHTSetup's Minimum Invoice Amount. // [GIVEN] "D2" is applied to "D1". - VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group"); + VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); InvoiceAmount := LibraryRandom.RandDecInRange(1000, 2000, 2); CrMemoAmount := LibraryRandom.RandDecInRange(10, 20, 2); InvoiceNo := CreateAndPostPurchaseDocumentWithWHTAndAmount(WHTPostingSetup, PurchaseHeader."Document Type"::Invoice, - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), InvoiceAmount); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), InvoiceAmount); CreateAndPostPurchaseDocumentWithWHTAndAppliesToDocNo( WHTPostingSetup, PurchaseHeader."Document Type"::"Credit Memo", - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), InvoiceNo, 1, CrMemoAmount); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), InvoiceNo, 1, CrMemoAmount); AppliesToID := SetAppliesToIDVendorDocument(VendorLedgerEntry."Document Type"::Invoice, InvoiceNo); @@ -1023,15 +1024,15 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Posted Purchase Invoice "D1" for Vendor "V". Amount is greater than WHTSetup's Minimum Invoice Amount. // [GIVEN] Posted Purchase Cr. Memo "D2" for Vendor "V". Amount is less than WHTSetup's Minimum Invoice Amount. - VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group"); + VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); InvoiceAmount := LibraryRandom.RandDecInRange(1000, 2000, 2); CrMemoAmount := LibraryRandom.RandDecInRange(10, 20, 2); DocumentNo.Add( CreateAndPostPurchaseDocumentWithWHTAndAmount(WHTPostingSetup, PurchaseHeader."Document Type"::Invoice, - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), InvoiceAmount)); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), InvoiceAmount)); DocumentNo.Add( CreateAndPostPurchaseDocumentWithWHTAndAmount(WHTPostingSetup, PurchaseHeader."Document Type"::"Credit Memo", - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), CrMemoAmount)); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), CrMemoAmount)); AppliesToID := SetAppliesToIDVendorDocument(VendorLedgerEntry."Document Type"::Invoice, DocumentNo.Get(1)); SetAppliesToIDVendorDocument(VendorLedgerEntry."Document Type"::"Credit Memo", DocumentNo.Get(2)); @@ -1076,11 +1077,11 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Two Posted Purchase Invoices for Vendor "V". Amounts are 1000 and 800. // [GIVEN] Two Posted Purchase Cr. Memos for Vendor "V" with Amounts > InvoiceAmount / 2. Amounts are 900 and 700. - VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group"); + VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); DiffAmount := LibraryRandom.RandDecInRange(10, 20, 2); CreateMultiplePostedPurchDocumentsWithAppliesToID( - AppliesToID, DocAmount, TotalDocAmount, WHTPostingSetup, VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group")); + AppliesToID, DocAmount, TotalDocAmount, WHTPostingSetup, VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group")); CalcWHTAmountOnInvoiceCrMemoAmounts(ExpectedWHTAmt, DocAmount, DiffAmount, WHTPostingSetup."Withholding Tax %"); // [GIVEN] Gen. Journal Line "D" with Vendor "V", "Document Type" = Payment, Amount is between ABS(InvoiceAmounts - CrMemoAmounts) and ABS(InvoiceAmont). @@ -1122,10 +1123,10 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Two Posted Purchase Invoices for Vendor "V". Amounts are 1000 and 800. // [GIVEN] Two Posted Purchase Cr. Memos for Vendor "V" with Amounts > InvoiceAmount / 2. Amounts are 900 and 700. - VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group"); + VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); CreateMultiplePostedPurchDocumentsWithAppliesToID( - AppliesToID, DocAmount, TotalDocAmount, WHTPostingSetup, VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group")); + AppliesToID, DocAmount, TotalDocAmount, WHTPostingSetup, VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group")); CalcWHTAmountOnInvoiceCrMemoAmounts(ExpectedWHTAmt, DocAmount, 0, WHTPostingSetup."Withholding Tax %"); // [GIVEN] Gen. Journal Line "D" with Vendor "V", "Document Type" = Payment, Amount is equal to ABS(InvoiceAmounts - CrMemoAmounts). @@ -1168,11 +1169,11 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Two Posted Purchase Invoices for Vendor "V". Amounts are 1000 and 800. // [GIVEN] Two Posted Purchase Cr. Memos for Vendor "V" with Amounts > InvoiceAmount / 2. Amounts are 900 and 700. - VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group"); + VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); DiffAmount := LibraryRandom.RandDecInRange(10, 20, 2); CreateMultiplePostedPurchDocumentsWithAppliesToID( - AppliesToID, DocAmount, TotalDocAmount, WHTPostingSetup, VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group")); + AppliesToID, DocAmount, TotalDocAmount, WHTPostingSetup, VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group")); CalcWHTAmountOnInvoiceCrMemoAmounts(ExpectedWHTAmt, DocAmount, 0, WHTPostingSetup."Withholding Tax %"); // [GIVEN] Gen. Journal Line "D" with Vendor "V", "Document Type" = Payment, Amount is larger than ABS(InvoiceAmounts - CrMemoAmounts). @@ -1213,7 +1214,7 @@ codeunit 148321 "ERM Withholding Tax Tests I" LibraryERM.CreateGeneralPostingSetupInvt(GeneralPostingSetup); // [GIVEN] Posted Gen. Journal Line "D1" with Vendor "V", empty "Document Type" and negative Amount. - VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group"); + VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); GenJnlLineAmount := LibraryRandom.RandDecInRange(1000, 2000, 2); InvoiceAmount := LibraryRandom.RandDecInRange(1000, 2000, 2); CreateAndPostGenJnlLineVendorAndSetAppliesToID( @@ -1222,7 +1223,7 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Posted Purchase Invoice "D2" for Vendor "V". Amount is greater than WHTSetup's Minimum Invoice Amount. InvoiceNo := CreateAndPostPurchaseDocumentWithWHTAndAmount(WHTPostingSetup, PurchaseHeader."Document Type"::Invoice, - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), InvoiceAmount); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), InvoiceAmount); AppliesToID := SetAppliesToIDVendorDocument(VendorLedgerEntry."Document Type"::Invoice, InvoiceNo); // [GIVEN] Gen. Journal Line "D3" with Vendor "V", "Document Type" = Payment, Amount is equal to ABS("D1".Amount + "D2".Amount). @@ -1266,7 +1267,7 @@ codeunit 148321 "ERM Withholding Tax Tests I" LibraryERM.CreateGeneralPostingSetupInvt(GeneralPostingSetup); // [GIVEN] Posted Gen. Journal Line "D1" with Vendor "V", empty "Document Type" and positive Amount. - VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group"); + VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); GenJnlLineAmount := LibraryRandom.RandDecInRange(100, 200, 2); InvoiceAmount := LibraryRandom.RandDecInRange(1000, 2000, 2); CreateAndPostGenJnlLineVendorAndSetAppliesToID( @@ -1275,7 +1276,7 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Posted Purchase Invoice "D2" for Vendor "V". Amount is greater than WHTSetup's Minimum Invoice Amount. InvoiceNo := CreateAndPostPurchaseDocumentWithWHTAndAmount(WHTPostingSetup, PurchaseHeader."Document Type"::Invoice, - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), InvoiceAmount); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), InvoiceAmount); AppliesToID := SetAppliesToIDVendorDocument(VendorLedgerEntry."Document Type"::Invoice, InvoiceNo); // [GIVEN] Gen. Journal Line "D3" with Vendor "V", "Document Type" = Payment, Amount is equal to ABS("D2".Amount - "D1".Amount). @@ -1322,15 +1323,15 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Posted Purchase Invoice "D1" for Vendor "V". Amount is greater than WHTSetup's Minimum Invoice Amount. // [GIVEN] Posted Purchase Cr. Memo "D2" for Vendor "V". Amount is greater than WHTSetup's Minimum Invoice Amount. // [GIVEN] "D2" is applied to "D1". - VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group"); + VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); InvoiceAmount := LibraryRandom.RandDecInRange(1000, 2000, 2); CrMemoAmount := LibraryRandom.RandDecInRange(100, 200, 2); InvoiceNo := CreateAndPostPurchaseDocumentWithWHTAndAmount(WHTPostingSetup, PurchaseHeader."Document Type"::Invoice, - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), InvoiceAmount); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), InvoiceAmount); CreateAndPostPurchaseDocumentWithWHTAndAppliesToDocNo( WHTPostingSetup, PurchaseHeader."Document Type"::"Credit Memo", - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), InvoiceNo, 1, CrMemoAmount); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), InvoiceNo, 1, CrMemoAmount); AppliesToID := SetAppliesToIDVendorDocument(VendorLedgerEntry."Document Type"::Invoice, InvoiceNo); @@ -1376,15 +1377,15 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Posted Purchase Invoice "D1" for Vendor "V". Amount is greater than WHTSetup's Minimum Invoice Amount. // [GIVEN] Posted Purchase Cr. Memo "D2" for Vendor "V". Amount is greater than WHTSetup's Minimum Invoice Amount. - VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group"); + VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); InvoiceAmount := LibraryRandom.RandDecInRange(1000, 2000, 2); CrMemoAmount := LibraryRandom.RandDecInRange(100, 200, 2); DocumentNo.Add( CreateAndPostPurchaseDocumentWithWHTAndAmount(WHTPostingSetup, PurchaseHeader."Document Type"::Invoice, - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), InvoiceAmount)); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), InvoiceAmount)); DocumentNo.Add( CreateAndPostPurchaseDocumentWithWHTAndAmount(WHTPostingSetup, PurchaseHeader."Document Type"::"Credit Memo", - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), CrMemoAmount)); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), CrMemoAmount)); AppliesToID := SetAppliesToIDVendorDocument(VendorLedgerEntry."Document Type"::Invoice, DocumentNo.Get(1)); SetAppliesToIDVendorDocument(VendorLedgerEntry."Document Type"::"Credit Memo", DocumentNo.Get(2)); @@ -1434,15 +1435,15 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Posted Purchase Invoice "D1" for Vendor "V". Amount is greater than WHTSetup's Minimum Invoice Amount. // [GIVEN] Posted Purchase Cr. Memo "D2" for Vendor "V". Amount is less than WHTSetup's Minimum Invoice Amount. // [GIVEN] "D2" is applied to "D1". - VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group"); + VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); InvoiceAmount := LibraryRandom.RandDecInRange(1000, 2000, 2); CrMemoAmount := LibraryRandom.RandDecInRange(10, 20, 2); InvoiceNo := CreateAndPostPurchaseDocumentWithWHTAndAmount(WHTPostingSetup, PurchaseHeader."Document Type"::Invoice, - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), InvoiceAmount); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), InvoiceAmount); CreateAndPostPurchaseDocumentWithWHTAndAppliesToDocNo( WHTPostingSetup, PurchaseHeader."Document Type"::"Credit Memo", - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), InvoiceNo, 1, CrMemoAmount); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), InvoiceNo, 1, CrMemoAmount); AppliesToID := SetAppliesToIDVendorDocument(VendorLedgerEntry."Document Type"::Invoice, InvoiceNo); @@ -1487,15 +1488,15 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Posted Purchase Invoice "D1" for Vendor "V". Amount is greater than WHTSetup's Minimum Invoice Amount. // [GIVEN] Posted Purchase Cr. Memo "D2" for Vendor "V". Amount is less than WHTSetup's Minimum Invoice Amount. - VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group"); + VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); InvoiceAmount := LibraryRandom.RandDecInRange(1000, 2000, 2); CrMemoAmount := LibraryRandom.RandDecInRange(10, 20, 2); DocumentNo[1] := CreateAndPostPurchaseDocumentWithWHTAndAmount(WHTPostingSetup, PurchaseHeader."Document Type"::Invoice, - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), InvoiceAmount); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), InvoiceAmount); DocumentNo[2] := CreateAndPostPurchaseDocumentWithWHTAndAmount(WHTPostingSetup, PurchaseHeader."Document Type"::"Credit Memo", - VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), CrMemoAmount); + VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), CrMemoAmount); AppliesToID := SetAppliesToIDVendorDocument(VendorLedgerEntry."Document Type"::Invoice, DocumentNo[1]); SetAppliesToIDVendorDocument(VendorLedgerEntry."Document Type"::"Credit Memo", DocumentNo[2]); @@ -1542,11 +1543,11 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Two Posted Purchase Invoices for Vendor "V". Amounts are 1000 and 800. // [GIVEN] Two Posted Purchase Cr. Memos for Vendor "V" with Amounts > InvoiceAmount / 2. Amounts are 900 and 700. - VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group"); + VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); DiffAmount := LibraryRandom.RandDecInRange(10, 20, 2); CreateMultiplePostedPurchDocumentsWithAppliesToID( - AppliesToID, DocAmount, TotalDocAmount, WHTPostingSetup, VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group")); + AppliesToID, DocAmount, TotalDocAmount, WHTPostingSetup, VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group")); CalcWHTAmountOnInvoiceCrMemoAmounts(ExpectedWHTAmt, DocAmount, DiffAmount, WHTPostingSetup."Withholding Tax %"); // [GIVEN] Gen. Journal Line "D" with Vendor "V", "Document Type" = Payment, Amount is between ABS(InvoiceAmounts - CrMemoAmounts) and ABS(InvoiceAmont). @@ -1591,10 +1592,10 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Two Posted Purchase Invoices for Vendor "V". Amounts are 1000 and 800. // [GIVEN] Two Posted Purchase Cr. Memos for Vendor "V" with Amounts > InvoiceAmount / 2. Amounts are 900 and 700. - VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group"); + VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); CreateMultiplePostedPurchDocumentsWithAppliesToID( - AppliesToID, DocAmount, TotalDocAmount, WHTPostingSetup, VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group")); + AppliesToID, DocAmount, TotalDocAmount, WHTPostingSetup, VendorNo, CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group")); CalcWHTAmountOnInvoiceCrMemoAmounts(ExpectedWHTAmt, DocAmount, 0, WHTPostingSetup."Withholding Tax %"); // [GIVEN] Gen. Journal Line "D" with Vendor "V", "Document Type" = Payment, Amount is equal to ABS(InvoiceAmounts - CrMemoAmounts). @@ -1638,14 +1639,14 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Posted purchase invoice with WHT Entry "No." = "X" LibraryERM.FindVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT"); - FindWHTPostingSetup(WHTPostingSetup); + CreateWHTPostingSetup(WHTPostingSetup); LibraryERM.CreateGeneralPostingSetupInvt(GeneralPostingSetup); - VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group"); + VendorNo := CreateVendorNoWithoutABN(VATPostingSetup."VAT Bus. Posting Group", GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); PostedInvoiceNo := CreateAndPostPurchaseDocumentWithWHT( PurchaseLine, WHTPostingSetup, PurchaseHeader."Document Type"::Invoice, VendorNo, - CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"), ''); + CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), ''); InvoiceWHTEntry.FindLast(); InvoiceWHTEntry.TestField("Entry No.", LastWHTEntry."Entry No." + 1); InvoiceWHTEntry.TestField("Remaining Unrealized Base"); @@ -1705,14 +1706,14 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Find VATPosting setup and WHT posting setup LibraryERM.FindVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT"); - FindWHTPostingSetup(WHTPostingSetup); + CreateWHTPostingSetup(WHTPostingSetup); LibraryERM.CreateGeneralPostingSetupInvt(GeneralPostingSetup); // [GIVEN] Create multiple vendors - CreateMultipleVendors(VendorNo, VATPostingSetup, GeneralPostingSetup."Gen. Bus. Posting Group"); + CreateMultipleVendors(VendorNo, VATPostingSetup, GeneralPostingSetup."Gen. Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); // [GIVEN] Create G/L Account - GLAccountNo := CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group"); + GLAccountNo := CreateGLAccountWithPostingSetup(VATPostingSetup."VAT Prod. Posting Group", GeneralPostingSetup."Gen. Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"); // [GIVEN] Create multiple purchase invoices for multiples Vendors PostMultiplePurchaseInvoice(VendorNo, PostedInvoiceNo, WHTAmount, WHTPostingSetup, GLAccountNo); @@ -1756,13 +1757,13 @@ codeunit 148321 "ERM Withholding Tax Tests I" // [GIVEN] Create Purchase Invoice Journal with WHT . UpdateGeneralLedgerSetup(true, false); // Round Amount for WHT Calc and True as Enable WHT. LibraryERM.FindVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT"); - FindWHTPostingSetup(WHTPostingSetup); - VendorNo := LibraryPurchase.CreateVendorWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Posting Group"); + CreateWHTPostingSetup(WHTPostingSetup); + VendorNo := CreateVendorWithPostingGroup(VATPostingSetup."VAT Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); CreateGeneralJournalLineWithCurrency( GenJournalLine, WHTPostingSetup, GenJournalLine."Account Type"::Vendor, GenJournalLine."Document Type"::Invoice, VendorNo, '', '', -1000); GenJournalLine.Validate("Bal. Account Type", GenJournalLine."Bal. Account Type"::"G/L Account"); - GenJournalLine.validate("Bal. Account No.", CreateGLAccount(VATPostingSetup."VAT Prod. Posting Group")); + GenJournalLine.validate("Bal. Account No.", CreateGLAccount(VATPostingSetup."VAT Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group")); GenJournalLine.validate("Bal. VAT Bus. Posting Group", VATPostingSetup."VAT Bus. Posting Group"); GenJournalLine.validate("Bal. VAT Prod. Posting Group", VATPostingSetup."VAT Prod. Posting Group"); GenJournalLine.validate("Bal. Gen. Posting Type", GenJournalLine."Bal. Gen. Posting Type"::Purchase); @@ -2025,10 +2026,10 @@ codeunit 148321 "ERM Withholding Tax Tests I" exit(BankAccount."No."); end; - local procedure CreateVendorNoWithoutABN(VATBusPostingGroup: Code[20]; GenBusPostingGroup: Code[20]) VendorNo: Code[20] + local procedure CreateVendorNoWithoutABN(VATBusPostingGroup: Code[20]; GenBusPostingGroup: Code[20]; WHTBusPostingGroup: Code[20]) VendorNo: Code[20] begin VendorNo := LibraryPurchase.CreateVendorWithVATBusPostingGroup(VATBusPostingGroup); - UpdateVendor(VendorNo, false, '', GenBusPostingGroup); + UpdateVendor(VendorNo, false, '', GenBusPostingGroup, WHTBusPostingGroup); end; local procedure CreateCurrencyWithExchangeRate(): Code[10] @@ -2099,7 +2100,7 @@ codeunit 148321 "ERM Withholding Tax Tests I" GenJournalLine.Modify(true); end; - local procedure CreateGLAccount(VATProdPostingGroup: Code[20]): Code[20] + local procedure CreateGLAccount(VATProdPostingGroup: Code[20]; WHTProdPostingGroup: Code[20]): Code[20] var GLAccount: Record "G/L Account"; GenProductPostingGroup: Record "Gen. Product Posting Group"; @@ -2108,17 +2109,19 @@ codeunit 148321 "ERM Withholding Tax Tests I" LibraryERM.CreateGLAccount(GLAccount); GLAccount.Validate("Gen. Prod. Posting Group", GenProductPostingGroup.Code); GLAccount.Validate("VAT Prod. Posting Group", VATProdPostingGroup); + GLAccount.Validate("Wthldg. Tax Prod. Post. Group", WHTProdPostingGroup); GLAccount.Modify(true); exit(GLAccount."No."); end; - local procedure CreateGLAccountWithPostingSetup(VATProdPostingGroup: Code[20]; GenProductPostingGroup: Code[20]): Code[20] + local procedure CreateGLAccountWithPostingSetup(VATProdPostingGroup: Code[20]; GenProductPostingGroup: Code[20]; WHTProdPostingGroup: Code[20]): Code[20] var GLAccount: Record "G/L Account"; begin LibraryERM.CreateGLAccount(GLAccount); GLAccount.Validate("Gen. Prod. Posting Group", GenProductPostingGroup); GLAccount.Validate("VAT Prod. Posting Group", VATProdPostingGroup); + GLAccount.Validate("Wthldg. Tax Prod. Post. Group", WHTProdPostingGroup); GLAccount.Modify(true); exit(GLAccount."No."); end; @@ -2206,9 +2209,9 @@ codeunit 148321 "ERM Withholding Tax Tests I" begin UpdateGeneralLedgerSetup(true, false); LibraryERM.FindVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT"); - VendorNo := LibraryPurchase.CreateVendorWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Posting Group"); - GLAccountNo := CreateGLAccount(VATPostingSetup."VAT Prod. Posting Group"); - FindWHTPostingSetup(WHTPostingSetup); + CreateWHTPostingSetup(WHTPostingSetup); + VendorNo := CreateVendorWithPostingGroup(VATPostingSetup."VAT Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"); + GLAccountNo := CreateGLAccount(VATPostingSetup."VAT Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"); end; local procedure FindCurrencyFactor(CurrencyCode: Code[10]): Decimal @@ -2229,19 +2232,22 @@ codeunit 148321 "ERM Withholding Tax Tests I" exit(Amount); end; - local procedure FindWHTPostingSetup(var WHTPostingSetup: Record "Withholding Tax Posting Setup") + local procedure CreateWHTPostingSetup(var WHTPostingSetup: Record "Withholding Tax Posting Setup") + var + WHTBusinessPostingGroup: Record "Wthldg. Tax Bus. Post. Group"; + WHTProductPostingGroup: Record "Wthldg. Tax Prod. Post. Group"; begin - // Enable test cases in NZ, create WHT Posting Setup. - if not WHTPostingSetup.Get('', '') then - CreateWHTPostingSetupWithRealizedWHTType( - WHTPostingSetup, '', '', WHTPostingSetup."Realized Withholding Tax Type"::Payment, LibraryRandom.RandIntInRange(30, 40)); + LibraryWithholdingTax.CreateWHTBusinessPostingGroup(WHTBusinessPostingGroup); + LibraryWithholdingTax.CreateWHTProductPostingGroup(WHTProductPostingGroup); + CreateWHTPostingSetupWithRealizedWHTType( + WHTPostingSetup, WHTBusinessPostingGroup.Code, WHTProductPostingGroup.Code, WHTPostingSetup."Realized Withholding Tax Type"::Payment, LibraryRandom.RandIntInRange(30, 40)); end; local procedure FindAndUpdateSetupsWithGSTAndWHTAndZeroVAT(var VATPostingSetup: Record "VAT Posting Setup"; var WHTPostingSetup: Record "Withholding Tax Posting Setup") begin UpdateGeneralLedgerSetup(true, false); LibraryERM.FindZeroVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT"); - FindWHTPostingSetup(WHTPostingSetup); + CreateWHTPostingSetup(WHTPostingSetup); end; local procedure GetWHTEntryAmount(DocumentNo: Code[20]): Decimal @@ -2273,7 +2279,7 @@ codeunit 148321 "ERM Withholding Tax Tests I" exit( CreateAndPostPurchaseDocumentWithWHT( PurchaseLine, WHTPostingSetup, PurchaseHeader."Document Type"::Invoice, VendorNo, - CreateGLAccount(VATPostingSetup."VAT Prod. Posting Group"), '')); + CreateGLAccount(VATPostingSetup."VAT Prod. Posting Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), '')); end; local procedure PostAppliedPaymentToInvoices(VendorNo: Code[20]; InvoiceNo: array[20] of Code[20]; AppliedAmount: array[20] of Decimal; WHTPostingSetup: Record "Withholding Tax Posting Setup"; InvoiceCount: Integer): Code[20] @@ -2348,12 +2354,14 @@ codeunit 148321 "ERM Withholding Tax Tests I" GLAccount.Modify(true); end; - local procedure UpdateVendor(VendorNo: Code[20]; Registered: Boolean; ABN: Text[11]; GenBusPostingGroup: Code[20]) + local procedure UpdateVendor(VendorNo: Code[20]; Registered: Boolean; ABN: Text[11]; GenBusPostingGroup: Code[20]; WHTBusPostingGroup: Code[20]) var Vendor: Record Vendor; begin Vendor.Get(VendorNo); Vendor."Gen. Bus. Posting Group" := GenBusPostingGroup; + Vendor."Withholding Tax Liable" := true; + Vendor."Wthldg. Tax Bus. Post. Group" := WHTBusPostingGroup; Vendor."WHT Registered" := Registered; Vendor."WHT ABN" := ABN; Vendor.Modify(); @@ -2542,7 +2550,7 @@ codeunit 148321 "ERM Withholding Tax Tests I" until GLEntry.Next() = 0; end; - local procedure CreateMultipleVendors(var VendorNo: array[3] of Code[20]; VATPostingSetup: Record "VAT Posting Setup"; GenBusPostingGroup: Code[20]) + local procedure CreateMultipleVendors(var VendorNo: array[3] of Code[20]; VATPostingSetup: Record "VAT Posting Setup"; GenBusPostingGroup: Code[20]; WHTBusPostingGroup: Code[20]) var Vendor: Record Vendor; i: Integer; @@ -2551,6 +2559,8 @@ codeunit 148321 "ERM Withholding Tax Tests I" VendorNo[i] := LibraryPurchase.CreateVendorWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Posting Group"); Vendor.Get(VendorNo[i]); Vendor."Gen. Bus. Posting Group" := GenBusPostingGroup; + Vendor."Withholding Tax Liable" := true; + Vendor."Wthldg. Tax Bus. Post. Group" := WHTBusPostingGroup; Vendor.Modify(true); end; end; @@ -2648,6 +2658,19 @@ codeunit 148321 "ERM Withholding Tax Tests I" exit(WHTEntry."Unrealized Amount"); end; + local procedure CreateVendorWithPostingGroup(VendorBusPostingGroup: Code[20]; WHTBusPostingGroup: Code[20]): Code[20] + var + Vendor: Record Vendor; + VendorNo: Code[20]; + begin + VendorNo := LibraryPurchase.CreateVendorWithVATBusPostingGroup(VendorBusPostingGroup); + Vendor.Get(VendorNo); + Vendor.Validate("Withholding Tax Liable", true); + Vendor.Validate("Wthldg. Tax Bus. Post. Group", WHTBusPostingGroup); + Vendor.Modify(true); + exit(Vendor."No."); + end; + [ModalPageHandler] [Scope('OnPrem')] procedure UnapplyVendorEntriesPageHandler(var UnapplyVendorEntries: TestPage "Unapply Vendor Entries") diff --git a/Apps/W1/WithholdingTax/Test/src/ERMWithholdingTaxTestsII.Codeunit.al b/Apps/W1/WithholdingTax/Test/src/ERMWithholdingTaxTestsII.Codeunit.al index 64819910b5..e7c1a1dd7b 100644 --- a/Apps/W1/WithholdingTax/Test/src/ERMWithholdingTaxTestsII.Codeunit.al +++ b/Apps/W1/WithholdingTax/Test/src/ERMWithholdingTaxTestsII.Codeunit.al @@ -54,7 +54,9 @@ codeunit 148322 "ERM Withholding Tax Tests II" GenJournalLine2: Record "Gen. Journal Line"; VATPostingSetup: Record "VAT Posting Setup"; WHTEntry: Record "Withholding Tax Entry"; + WHTBusPostingGroup: Record "Wthldg. Tax Bus. Post. Group"; WHTPostingSetup: Record "Withholding Tax Posting Setup"; + WHTProdPostingGroup: Record "Wthldg. Tax Prod. Post. Group"; DocumentNo: Code[20]; WHTAmount: Decimal; begin @@ -64,9 +66,11 @@ codeunit 148322 "ERM Withholding Tax Tests II" Initialize(); UpdateLocalFunctionalitiesOnGeneralLedgerSetup(true); LibraryERM.FindVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT"); + LibraryWithholdingTax.CreateWHTBusinessPostingGroup(WHTBusPostingGroup); + LibraryWithholdingTax.CreateWHTProductPostingGroup(WHTProdPostingGroup); CreateGeneralJournalLineWithBalAccountType( - GenJournalLine, GenJournalLine."Document Type"::Invoice, CreateVendor(VATPostingSetup."VAT Bus. Posting Group", ''), '', - '', GenJournalLine."Bal. Account Type"::"G/L Account", CreateGLAccountWithVATBusPostingGroup(VATPostingSetup), + GenJournalLine, GenJournalLine."Document Type"::Invoice, CreateVendor(VATPostingSetup."VAT Bus. Posting Group", WHTBusPostingGroup.Code), '', + '', GenJournalLine."Bal. Account Type"::"G/L Account", CreateGLAccountWithVATBusPostingGroup(VATPostingSetup, WHTProdPostingGroup.Code), -LibraryRandom.RandDecInRange(100, 200, 2)); // Blank - WHT Bus Posting Group, Applies To Doc. No, Currency, Random - Direct unit cost. UpdateGenJournalLineWHTAbsorbBase(GenJournalLine); FindWHTPostingSetup(WHTPostingSetup, GenJournalLine."Wthldg. Tax Bus. Post. Group", GenJournalLine."Wthldg. Tax Prod. Post. Group", ''); // Blank Currency Code. @@ -77,6 +81,8 @@ codeunit 148322 "ERM Withholding Tax Tests II" CreateGeneralJournalLineWithBalAccountType( GenJournalLine2, GenJournalLine."Document Type"::Payment, GenJournalLine."Account No.", DocumentNo, '', GenJournalLine2."Bal. Account Type"::"Bank Account", BankAccount."No.", -FindVendorLedgerEntryAmount(DocumentNo)); // Currency - Blank. + GenJournalLine2.Validate("Wthldg. Tax Prod. Post. Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"); + GenJournalLine2.Modify(true); // Exercise. LibraryERM.PostGeneralJnlLine(GenJournalLine2); @@ -115,7 +121,7 @@ codeunit 148322 "ERM Withholding Tax Tests II" LibraryRandom.RandIntInRange(1000, 10000)); // Random - Direct unit cost. CreateGeneralJournalLineWithBalAccountType( GenJournalLine, GenJournalLine."Document Type"::Payment, PurchaseLine."Buy-from Vendor No.", '', - CurrencyCode, GenJournalLine."Bal. Account Type"::"G/L Account", CreateGLAccountWithVATBusPostingGroup(VATPostingSetup), + CurrencyCode, GenJournalLine."Bal. Account Type"::"G/L Account", CreateGLAccountWithVATBusPostingGroup(VATPostingSetup, WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), -FindVendorLedgerEntryAmount(DocumentNo)); // Blank - Balance Account No. GenJournalLine.Validate("Wthldg. Tax Prod. Post. Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"); GenJournalLine.Modify(true); @@ -194,12 +200,11 @@ codeunit 148322 "ERM Withholding Tax Tests II" // [GIVEN] Purchase WHT Invoice = "Inv1" UpdateGLSetupAndPurchasesPayablesSetup(VATPostingSetup); - CreateAndPostVendorInvoice(GenJournalLine, CreateVendor(VATPostingSetup."VAT Bus. Posting Group", '')); - FindWHTPostingSetup( - WHTPostingSetup, GenJournalLine."Wthldg. Tax Bus. Post. Group", GenJournalLine."Wthldg. Tax Prod. Post. Group", ''); + CreateWHTPostingSetup(WHTPostingSetup, ''); + CreateAndPostVendorWHTInvoice(GenJournalLine, CreateVendor(VATPostingSetup."VAT Bus. Posting Group", WHTPostingSetup."Wthldg. Tax Bus. Post. Group"), VATPostingSetup, WHTPostingSetup); // [GIVEN] Normal Purchase Invoice = "Inv2" - CreateAndPostVendorInvoice(NormalGenJournalLine, LibraryPurchase.CreateVendorNo()); + CreateAndPostVendorInvoice(NormalGenJournalLine, LibraryPurchase.CreateVendorWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Posting Group")); // [GIVEN] Use General Journal Batch with No. Series defined LibraryJournals.CreateGenJournalBatch(GenJournalBatch); @@ -207,11 +212,11 @@ codeunit 148322 "ERM Withholding Tax Tests II" GenJournalBatch.Modify(true); // [GIVEN] Payment lines within the Batch for "Inv1" and "Inv2" - CreateApplnVendorPayment( + CreateApplnVendorWHTPayment( GenJournalLine, GenJournalBatch, GenJournalLine."Account Type", GenJournalLine."Account No.", -GenJournalLine.Amount, GenJournalLine."Applies-to Doc. Type"::Invoice, GenJournalLine."Document No.", - NoSeriesBatch.GetNextNo(GenJournalBatch."No. Series")); + NoSeriesBatch.GetNextNo(GenJournalBatch."No. Series"), WHTPostingSetup); WHTPaymentNo := GenJournalLine."Document No."; WHTBalAccountNo := GenJournalLine."Bal. Account No."; @@ -270,17 +275,23 @@ codeunit 148322 "ERM Withholding Tax Tests II" procedure WHTPostingSetupGetPrepaidWHTAccountUT() var WHTPostingSetup: Record "Withholding Tax Posting Setup"; + WHTBusPostingGroup: Record "Wthldg. Tax Bus. Post. Group"; + WHTProdPostingGroup: Record "Wthldg. Tax Prod. Post. Group"; begin // [FEATURE] [UT] // [SCENARIO 285194] WHT Posting Setup's functions GetPrepaidWithholdingAccount returns PrepaidWHTAccount or throws an error when empty Initialize(); UpdateLocalFunctionalitiesOnGeneralLedgerSetup(true); + LibraryWithholdingTax.CreateWHTBusinessPostingGroup(WHTBusPostingGroup); + LibraryWithholdingTax.CreateWHTProductPostingGroup(WHTProdPostingGroup); WHTPostingSetup.Init(); + WHTPostingSetup."Wthldg. Tax Bus. Post. Group" := WHTBusPostingGroup.Code; + WHTPostingSetup."Wthldg. Tax Prod. Post. Group" := WHTProdPostingGroup.Code; asserterror WHTPostingSetup.GetPrepaidWithholdingTaxAccount(); Assert.ExpectedErrorCode('TestField'); Assert.ExpectedError(StrSubstNo(WHTAccountCodeEmptyErr, - WHTPostingSetup.FieldCaption("Prepaid Wthldg. Tax Acc. Code"), '', WHTPostingSetup."Wthldg. Tax Prod. Post. Group")); + WHTPostingSetup.FieldCaption("Prepaid Wthldg. Tax Acc. Code"), WHTPostingSetup."Wthldg. Tax Bus. Post. Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group")); WHTPostingSetup.Init(); WHTPostingSetup."Prepaid Wthldg. Tax Acc. Code" := LibraryUtility.GenerateGUID(); @@ -706,17 +717,28 @@ codeunit 148322 "ERM Withholding Tax Tests II" exit(GLAccount."No."); end; - local procedure CreateGLAccountWithVATBusPostingGroup(VATPostingSetup: Record "VAT Posting Setup"): Code[20] + local procedure CreateGLAccountWithVATBusPostingGroup(VATPostingSetup: Record "VAT Posting Setup"; WHTProdPostingGroup: Code[20]): Code[20] var GLAccount: Record "G/L Account"; begin GLAccount.Get(CreateGLAccount(VATPostingSetup."VAT Prod. Posting Group")); GLAccount.Validate("VAT Bus. Posting Group", VATPostingSetup."VAT Bus. Posting Group"); + GLAccount.Validate("Wthldg. Tax Prod. Post. Group", WHTProdPostingGroup); GLAccount.Validate("Gen. Posting Type", GLAccount."Gen. Posting Type"::Purchase); GLAccount.Modify(true); exit(GLAccount."No."); end; + local procedure CreateGLAccountForPayment(WHTProdPostingGroup: Code[20]): Code[20] + var + GLAccount: Record "G/L Account"; + begin + GLAccount.Get(LibraryERM.CreateGLAccountNo()); + GLAccount.Validate("Wthldg. Tax Prod. Post. Group", WHTProdPostingGroup); + GLAccount.Modify(true); + exit(GLAccount."No."); + end; + local procedure CreateVendor(VATBusPostingGroup: Code[20]; WHTBusinessPostingGroup: Code[20]): Code[20] var Vendor: Record Vendor; @@ -724,6 +746,7 @@ codeunit 148322 "ERM Withholding Tax Tests II" LibraryPurchase.CreateVendor(Vendor); Vendor.Validate("VAT Bus. Posting Group", VATBusPostingGroup); Vendor.Validate("WHT ABN", ''); + Vendor.Validate("Withholding Tax Liable", true); Vendor.Validate("Wthldg. Tax Bus. Post. Group", WHTBusinessPostingGroup); Vendor.Modify(true); exit(Vendor."No."); @@ -826,6 +849,30 @@ codeunit 148322 "ERM Withholding Tax Tests II" exit(GenJournalLine."Document No."); end; + local procedure CreateAndPostVendorWHTInvoice(var GenJournalLine: Record "Gen. Journal Line"; VendorNo: Code[20]; VATPostingSetup: Record "VAT Posting Setup"; WHTPostingSetup: Record "Withholding Tax Posting Setup"): Code[20] + begin + CreateGeneralJournalLineWithBalAccountType( + GenJournalLine, GenJournalLine."Document Type"::Invoice, VendorNo, '', + '', GenJournalLine."Bal. Account Type"::"G/L Account", CreateGLAccountWithVATBusPostingGroup(VATPostingSetup, WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), + -LibraryRandom.RandDecInRange(100, 200, 2)); + GenJournalLine.Validate("Wthldg. Tax Prod. Post. Group", WHTPostingSetup."Wthldg. Tax Prod. Post. Group"); + LibraryERM.PostGeneralJnlLine(GenJournalLine); + exit(GenJournalLine."Document No."); + end; + + local procedure CreateApplnVendorWHTPayment(var GenJournalLine: Record "Gen. Journal Line"; GenJournalBatch: Record "Gen. Journal Batch"; AccountType: Enum "Gen. Journal Account Type"; AccountNo: Code[20]; ApplyAmount: Decimal; ApplyToDocType: Enum "Gen. Journal Account Type"; ApplyToDocNo: Code[20]; DocumentNo: Code[20]; WHTPostingSetup: Record "Withholding Tax Posting Setup") + begin + LibraryJournals.CreateGenJournalLine( + GenJournalLine, GenJournalBatch."Journal Template Name", GenJournalBatch.Name, + GenJournalLine."Document Type"::Payment, AccountType, AccountNo, + GenJournalLine."Bal. Account Type"::"G/L Account", CreateGLAccountForPayment(WHTPostingSetup."Wthldg. Tax Prod. Post. Group"), + ApplyAmount); + GenJournalLine.Validate("Document No.", DocumentNo); + GenJournalLine.Validate("Applies-to Doc. Type", ApplyToDocType); + GenJournalLine.Validate("Applies-to Doc. No.", ApplyToDocNo); + GenJournalLine.Modify(true); + end; + local procedure CreateApplnVendorPayment(var GenJournalLine: Record "Gen. Journal Line"; GenJournalBatch: Record "Gen. Journal Batch"; AccountType: Enum "Gen. Journal Account Type"; AccountNo: Code[20]; ApplyAmount: Decimal; ApplyToDocType: Enum "Gen. Journal Account Type"; ApplyToDocNo: Code[20]; DocumentNo: Code[20]) begin LibraryJournals.CreateGenJournalLine( @@ -903,6 +950,17 @@ codeunit 148322 "ERM Withholding Tax Tests II" WHTProductPostingGroup, CurrencyCode, LibraryRandom.RandDecInRange(50, 100, 2)); // WHT Minimum Invoice Amount. end; + local procedure CreateWHTPostingSetup(var WHTPostingSetup: Record "Withholding Tax Posting Setup"; CurrencyCode: Code[10]) + var + WHTBusinessPostingGroup: Record "Wthldg. Tax Bus. Post. Group"; + WHTProductPostingGroup: Record "Wthldg. Tax Prod. Post. Group"; + begin + LibraryWithholdingTax.CreateWHTBusinessPostingGroup(WHTBusinessPostingGroup); + LibraryWithholdingTax.CreateWHTProductPostingGroup(WHTProductPostingGroup); + CreateWHTPostingSetup(WHTPostingSetup, WHTBusinessPostingGroup.Code, + WHTProductPostingGroup.Code, CurrencyCode, LibraryRandom.RandDecInRange(50, 100, 2)); // WHT Minimum Invoice Amount. + end; + local procedure FindVendorLedgerEntry(VendorNo: Code[20]): Code[20] var VendorLedgerEntry: Record "Vendor Ledger Entry"; @@ -949,7 +1007,7 @@ codeunit 148322 "ERM Withholding Tax Tests II" local procedure UpdateGLSetupAndPurchasesPayablesSetup(var VATPostingSetup: Record "VAT Posting Setup") begin UpdateLocalFunctionalitiesOnGeneralLedgerSetup(true); - LibraryERM.FindVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT"); + LibraryERM.FindZeroVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT"); end; local procedure VerifyWHTEntry(DocumentType: Enum "Gen. Journal Document Type"; BillToPayToNo: Code[20]; Amount: Decimal; UnrealizedAmount: Decimal) diff --git a/Apps/W1/WithholdingTax/Test/src/ERMWithholdingVATForSEA.Codeunit.al b/Apps/W1/WithholdingTax/Test/src/ERMWithholdingVATForSEA.Codeunit.al index ea67f1d888..f20628715f 100644 --- a/Apps/W1/WithholdingTax/Test/src/ERMWithholdingVATForSEA.Codeunit.al +++ b/Apps/W1/WithholdingTax/Test/src/ERMWithholdingVATForSEA.Codeunit.al @@ -333,6 +333,7 @@ codeunit 148326 "ERM Withholding VAT For SEA" GenBusinessPostingGroup.Get(GenBusPostingGroup); LibraryPurchase.CreateVendor(Vendor); Vendor.Validate("WHT ABN", ''); + Vendor.Validate("Withholding Tax Liable", true); Vendor.Validate("Wthldg. Tax Bus. Post. Group", WHTBusinessPostingGroup); Vendor.Validate("Gen. Bus. Posting Group", GenBusinessPostingGroup.Code); Vendor.Validate("VAT Bus. Posting Group", GenBusinessPostingGroup."Def. VAT Bus. Posting Group"); diff --git a/Apps/W1/WithholdingTax/app/ExtensionLogo.png b/Apps/W1/WithholdingTax/app/ExtensionLogo.png index b2797835f3..b97e56e27c 100644 Binary files a/Apps/W1/WithholdingTax/app/ExtensionLogo.png and b/Apps/W1/WithholdingTax/app/ExtensionLogo.png differ diff --git a/Apps/W1/WithholdingTax/app/src/Purchase/Master/WithholdingVendorCard.PageExt.al b/Apps/W1/WithholdingTax/app/src/Purchase/Master/WithholdingVendorCard.PageExt.al index 32c892ee2e..40b2994d01 100644 --- a/Apps/W1/WithholdingTax/app/src/Purchase/Master/WithholdingVendorCard.PageExt.al +++ b/Apps/W1/WithholdingTax/app/src/Purchase/Master/WithholdingVendorCard.PageExt.al @@ -12,11 +12,44 @@ pageextension 6784 "Withholding Vendor Card" extends "Vendor Card" { addbefore("Vendor Posting Group") { + field("Withholding Tax Liable"; Rec."Withholding Tax Liable") + { + ApplicationArea = Basic, Suite; + ToolTip = 'Specifies if the vendor is liable for withholding tax.'; + + trigger OnValidate() + begin + Rec.TestField("Wthldg. Tax Bus. Post. Group", ''); + IsWithholdingTaxLiable(); + end; + } field("Wthldg. Tax Bus. Post. Group"; Rec."Wthldg. Tax Bus. Post. Group") { ApplicationArea = Basic, Suite; ToolTip = 'Specifies the withholding tax business posting group for the vendor.'; + Enabled = IsWHTLiable; } } } + + trigger OnAfterGetRecord() + begin + IsWithholdingTaxLiable(); + end; + + trigger OnAfterGetCurrRecord() + begin + IsWithholdingTaxLiable(); + end; + + local procedure IsWithholdingTaxLiable() + begin + if Rec."Withholding Tax Liable" then + IsWHTLiable := true + else + IsWHTLiable := false; + end; + + var + IsWHTLiable: Boolean; } \ No newline at end of file diff --git a/Apps/W1/WithholdingTax/app/src/Purchase/Master/WithholdingVendorExt.TableExt.al b/Apps/W1/WithholdingTax/app/src/Purchase/Master/WithholdingVendorExt.TableExt.al index a610bc023a..99be4de71c 100644 --- a/Apps/W1/WithholdingTax/app/src/Purchase/Master/WithholdingVendorExt.TableExt.al +++ b/Apps/W1/WithholdingTax/app/src/Purchase/Master/WithholdingVendorExt.TableExt.al @@ -74,7 +74,11 @@ tableextension 6784 "Withholding Vendor Ext" extends Vendor Caption = 'Withholding Tax Registration ID'; OptimizeForTextSearch = true; } - + field(6790; "Withholding Tax Liable"; Boolean) + { + DataClassification = CustomerContent; + Caption = 'Withholding Tax Liable'; + } } local procedure CheckABN(ABN: Text[13]; Which: Option Customer,Vendor,Internal,Contact) diff --git a/Apps/W1/WithholdingTax/app/src/Purchase/Permissions/WHTAdmin.permissionset.al b/Apps/W1/WithholdingTax/app/src/Purchase/Permissions/WHTAdmin.permissionset.al new file mode 100644 index 0000000000..f0409757f5 --- /dev/null +++ b/Apps/W1/WithholdingTax/app/src/Purchase/Permissions/WHTAdmin.permissionset.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.WithholdingTax; + +permissionset 6784 "WHT - Admin" +{ + Caption = 'Withholding Tax - Admin'; + Access = Public; + Assignable = true; + + Permissions = + tabledata "Temp Withholding Tax Entry" = IMD, + tabledata "Wthldg. Tax Bus. Post. Group" = IMD, + tabledata "Withholding Tax Cert. Buffer" = IMD, + tabledata "Withholding Tax Entry" = IMD, + tabledata "Withholding Tax Posting Setup" = IMD, + tabledata "Wthldg. Tax Prod. Post. Group" = IMD, + tabledata "Withholding Tax Posting Buffer" = IMD, + tabledata "Withholding Tax Revenue Types" = IMD; +} diff --git a/Apps/W1/WithholdingTax/app/src/Purchase/Permissions/WHTObjects.permissionset.al b/Apps/W1/WithholdingTax/app/src/Purchase/Permissions/WHTObjects.permissionset.al new file mode 100644 index 0000000000..a1fc3cc0bd --- /dev/null +++ b/Apps/W1/WithholdingTax/app/src/Purchase/Permissions/WHTObjects.permissionset.al @@ -0,0 +1,55 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace Microsoft.WithholdingTax; + +using Microsoft.Finance.WithholdingTax; + +permissionset 6786 "WHT - Objects" +{ + Caption = 'Withholding Tax - Objects'; + Access = Internal; + Assignable = false; + + Permissions = + table "Wthldg. Tax Bus. Post. Group" = X, + table "Wthldg. Tax Prod. Post. Group" = X, + table "Withholding Tax Posting Setup" = X, + table "Withholding Tax Revenue Types" = X, + table "Withholding Tax Entry" = X, + table "Withholding Tax Cert. Buffer" = X, + table "Temp Withholding Tax Entry" = X, + table "Withholding Tax Posting Buffer" = X, + table "WHT Purch. Tax Inv. Header" = X, + table "WHT Purch. Tax Inv. Line" = X, + table "WHT Purch. Tax Cr. Memo Hdr." = X, + table "WHT Purch. Tax Cr. Memo Line" = X, + page "Wthldg. Tax Bus. Post. Group" = X, + page "Wthldg. Tax Prod. Post. Group" = X, + page "Withholding Tax Posting Setup" = X, + page "Withholding Tax Revenue Types" = X, + page "Withholding Tax Entry" = X, + page "WHT Posted Purch. Tax Invoice" = X, + page "WHT Pstd. Purch. Tax Inv. Sub." = X, + page "WHT Posted Purch. Tax Invoices" = X, + page "WHT Pstd. Purch. Tax Cr. Memos" = X, + page "WHT Posted Purch. Tax Cr. Memo" = X, + page "WHT Pstd. Purch. Tax Cr. SubP" = X, + codeunit "Wthldg Tax Purch. Subscribers" = X, + codeunit "Withholding Tax Mgmt." = X, + codeunit "Withholding Tax Jnl Subscriber" = X, + codeunit "Wthldg Tax Navigate Handler" = X, + codeunit "Withholding Tax Invoice Mgmt." = X, + codeunit "Withholding Tax Event Handler" = X, + codeunit "WHT Purch. Tax Inv.-Printed" = X, + codeunit "WHT Purch. Tax Cr.Memo-Printed" = X, + report "WHT Calc. and Post Settlement" = X, + report "WHT Annual Information Return" = X, + report "WHT Certificate Creditable tax" = X, + report "WHT Monthly Remittance Return" = X, + report "WHT Purch. - Tax Invoice" = X, + report "WHT Purch. - Tax Cr. Memo" = X, + report "Withholding Tax Certificate" = X; +} \ No newline at end of file diff --git a/Apps/W1/WithholdingTax/app/src/Purchase/Permissions/WHTRead.permissionset.al b/Apps/W1/WithholdingTax/app/src/Purchase/Permissions/WHTRead.permissionset.al new file mode 100644 index 0000000000..c0a49944aa --- /dev/null +++ b/Apps/W1/WithholdingTax/app/src/Purchase/Permissions/WHTRead.permissionset.al @@ -0,0 +1,27 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace Microsoft.WithholdingTax; + +permissionset 6785 "WHT - Read" +{ + Caption = 'Withholding Tax - Read'; + Access = Public; + Assignable = true; + + Permissions = + tabledata "WHT Purch. Tax Cr. Memo Hdr." = R, + tabledata "WHT Purch. Tax Cr. Memo Line" = R, + tabledata "WHT Purch. Tax Inv. Header" = R, + tabledata "WHT Purch. Tax Inv. Line" = R, + tabledata "Temp Withholding Tax Entry" = R, + tabledata "Wthldg. Tax Bus. Post. Group" = R, + tabledata "Withholding Tax Cert. Buffer" = R, + tabledata "Withholding Tax Entry" = R, + tabledata "Withholding Tax Posting Buffer" = R, + tabledata "Withholding Tax Posting Setup" = R, + tabledata "Wthldg. Tax Prod. Post. Group" = R, + tabledata "Withholding Tax Revenue Types" = R; +} \ No newline at end of file diff --git a/Apps/W1/WithholdingTax/app/src/Purchase/Permissions/d365BusFullaccessWHT.permissionsetExt.al b/Apps/W1/WithholdingTax/app/src/Purchase/Permissions/d365BusFullaccessWHT.permissionsetExt.al new file mode 100644 index 0000000000..43284fffee --- /dev/null +++ b/Apps/W1/WithholdingTax/app/src/Purchase/Permissions/d365BusFullaccessWHT.permissionsetExt.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.WithholdingTax; + +using System.Security.AccessControl; + +permissionsetextension 6784 "D365 BUS FULL ACCESS WHT" extends "D365 BUS FULL ACCESS" +{ + IncludedPermissionSets = "WHT - Admin"; +} \ No newline at end of file diff --git a/Apps/W1/WithholdingTax/app/src/Purchase/Permissions/d365ReadWHT.PermissionsetExt.al b/Apps/W1/WithholdingTax/app/src/Purchase/Permissions/d365ReadWHT.PermissionsetExt.al new file mode 100644 index 0000000000..577f6a3b04 --- /dev/null +++ b/Apps/W1/WithholdingTax/app/src/Purchase/Permissions/d365ReadWHT.PermissionsetExt.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.WithholdingTax; + +using System.Security.AccessControl; + +permissionsetextension 6785 "D365 READ WHT" extends "D365 READ" +{ + IncludedPermissionSets = "WHT - Read"; +} \ No newline at end of file diff --git a/Apps/W1/WithholdingTax/app/src/Purchase/Setup/WithholdingTaxPostingSetup.Page.al b/Apps/W1/WithholdingTax/app/src/Purchase/Setup/WithholdingTaxPostingSetup.Page.al index e7dfa3049e..c191c4cd8c 100644 --- a/Apps/W1/WithholdingTax/app/src/Purchase/Setup/WithholdingTaxPostingSetup.Page.al +++ b/Apps/W1/WithholdingTax/app/src/Purchase/Setup/WithholdingTaxPostingSetup.Page.al @@ -23,11 +23,13 @@ page 6786 "Withholding Tax Posting Setup" { ApplicationArea = Basic, Suite; ToolTip = 'Specifies a Withholding Tax Business Posting group code.'; + NotBlank = true; } field("Wthldg. Tax Prod. Post. Group"; Rec."Wthldg. Tax Prod. Post. Group") { ApplicationArea = Basic, Suite; ToolTip = 'Specifies a Withholding Tax Product Posting group code.'; + NotBlank = true; } field("Wthldg. Tax Calculation Rule"; Rec."Wthldg. Tax Calculation Rule") { @@ -93,6 +95,7 @@ page 6786 "Withholding Tax Posting Setup" { ApplicationArea = Basic, Suite; ToolTip = 'Specifies the Revenue Type this combination of Withholding Business and Product Posting group belongs to.'; + ShowMandatory = true; } field("Purch. Wthldg. Tax Adj. Acc No"; Rec."Purch. Wthldg. Tax Adj. Acc No") { @@ -113,9 +116,4 @@ page 6786 "Withholding Tax Posting Setup" } } } - - trigger OnInsertRecord(BelowxRec: Boolean): Boolean - begin - Rec.TestField(Rec."Revenue Type"); - end; } \ No newline at end of file diff --git a/Apps/W1/WithholdingTax/app/src/Purchase/Transaction/WithholdingTaxJnlSubscriber.Codeunit.al b/Apps/W1/WithholdingTax/app/src/Purchase/Transaction/WithholdingTaxJnlSubscriber.Codeunit.al index ca53940c2c..093d86bc96 100644 --- a/Apps/W1/WithholdingTax/app/src/Purchase/Transaction/WithholdingTaxJnlSubscriber.Codeunit.al +++ b/Apps/W1/WithholdingTax/app/src/Purchase/Transaction/WithholdingTaxJnlSubscriber.Codeunit.al @@ -48,23 +48,44 @@ codeunit 6786 "Withholding Tax Jnl Subscriber" [EventSubscriber(ObjectType::Table, Database::"Gen. Journal Line", OnAfterAccountNoOnValidateGetGLAccount, '', false, false)] local procedure AssignGLAccValue(var GenJournalLine: Record "Gen. Journal Line"; var GLAccount: Record "G/L Account") + var + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; begin if CheckWithholdingTaxDisabled() then exit; + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJournalLine) then + exit; + GenJournalLine."Wthldg. Tax Bus. Post. Group" := GLAccount."Wthldg. Tax Bus. Post. Group"; GenJournalLine."Wthldg. Tax Prod. Post. Group" := GLAccount."Wthldg. Tax Prod. Post. Group"; end; + [EventSubscriber(ObjectType::Table, Database::"Gen. Journal Line", OnAfterAccountNoOnValidateGetGLBalAccount, '', false, false)] + local procedure AssignBalGLAccValue(var GenJournalLine: Record "Gen. Journal Line"; var GLAccount: Record "G/L Account") + var + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; + begin + if CheckWithholdingTaxDisabled() then + exit; + + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJournalLine) then + exit; + + GenJournalLine."Wthldg. Tax Prod. Post. Group" := GLAccount."Wthldg. Tax Prod. Post. Group"; + end; + [EventSubscriber(ObjectType::Table, Database::"Gen. Journal Line", OnAfterAccountNoOnValidateGetVendorAccount, '', false, false)] local procedure AssignVendValue(var GenJournalLine: Record "Gen. Journal Line"; var Vendor: Record Vendor) begin if CheckWithholdingTaxDisabled() then exit; + if not Vendor."Withholding Tax Liable" then + exit; + GenJournalLine."Skip Withholding Tax" := Vendor."WHT ABN" <> ''; GenJournalLine."Wthldg. Tax Bus. Post. Group" := Vendor."Wthldg. Tax Bus. Post. Group"; - GenJournalLine."Wthldg. Tax Prod. Post. Group" := ''; end; [EventSubscriber(ObjectType::Table, Database::"Gen. Journal Line", OnAfterClearPostingGroups, '', false, false)] @@ -79,10 +100,15 @@ codeunit 6786 "Withholding Tax Jnl Subscriber" [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", OnBeforeInitGLEntryForGLAcc, '', false, false)] local procedure OnBeforeInitGLEntryForGLAcc(GenJnlLine: Record "Gen. Journal Line"; GLAcc: Record "G/L Account"; var GLEntry: Record "G/L Entry"; var TaxAmount: Decimal; var TaxAmountLCY: Decimal; var IsHandled: Boolean; var sender: Codeunit "Gen. Jnl.-Post Line") + var + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; begin if CheckWithholdingTaxDisabled() then exit; + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJnlLine) then + exit; + CalcGLAccWithholdingTax(GenJnlLine, TaxAmountLCY); sender.InitGLEntry( GenJnlLine, GLEntry, GenJnlLine."Account No.", GenJnlLine."Amount (LCY)" + TaxAmountLCY, @@ -93,10 +119,15 @@ codeunit 6786 "Withholding Tax Jnl Subscriber" [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", OnPostGLAccOnBeforeDeferralPosting, '', false, false)] local procedure PostWithholdingTaxforGL(var GenJournalLine: Record "Gen. Journal Line"; sender: Codeunit "Gen. Jnl.-Post Line"; TaxAmount: Decimal; TaxAmountLCY: Decimal) + var + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; begin if CheckWithholdingTaxDisabled() then exit; + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJournalLine) then + exit; + PostGLAccWithholdingTax(GenJournalLine, TaxAmountLCY, sender); end; @@ -106,6 +137,9 @@ codeunit 6786 "Withholding Tax Jnl Subscriber" if CheckWithholdingTaxDisabled() then exit; + if not Vendor."Withholding Tax Liable" then + exit; + CalcVendWithholdingTax(GenJnlLine, TaxAmountLCY, TaxAmount); VendLedgEntry."Amount to Apply" := GenJnlLine.Amount; end; @@ -114,10 +148,14 @@ codeunit 6786 "Withholding Tax Jnl Subscriber" local procedure OnPostVendAfterTempDtldCVLedgEntryBufInit(var GenJnlLine: Record "Gen. Journal Line"; var TempDtldCVLedgEntryBuf: Record "Detailed CV Ledg. Entry Buffer" temporary; TaxAmount: Decimal; TaxAmountLCY: Decimal) var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; begin if CheckWithholdingTaxDisabled() then exit; + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJnlLine) then + exit; + TempDtldCVLedgEntryBuf.Amount := TempDtldCVLedgEntryBuf.Amount - GenJnlLine."WHT Interest Amount" - GenJnlPostLine.ExchangeAmtLCYToFCY2(TaxAmount); TempDtldCVLedgEntryBuf."Amount (LCY)" := TempDtldCVLedgEntryBuf."Amount (LCY)" - GenJnlLine."WHT Interest Amount (LCY)" - TaxAmountLCY; if GenJnlLine."WHT Vendor Exchange Rate (ACY)" <> 0 then @@ -154,10 +192,15 @@ codeunit 6786 "Withholding Tax Jnl Subscriber" [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", OnBeforePostingDeferral, '', false, false)] local procedure OnAfterVendLedgEntryInsert(GenJnlLine: Record "Gen. Journal Line"; VendLedgEntry: Record "Vendor Ledger Entry"; TaxAmount: Decimal; TaxAmountLCY: Decimal; NextTransactionNo: Integer; var NextTaxEntryNo: Integer; var IsHandled: Boolean; sender: Codeunit "Gen. Jnl.-Post Line") + var + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; begin if CheckWithholdingTaxDisabled() then exit; + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJnlLine) then + exit; + PostVendWithholdingTax(GenJnlLine, VendLedgEntry, TaxAmount, TaxAmountLCY, NextTransactionNo, NextTaxEntryNo, sender); end; @@ -683,10 +726,15 @@ codeunit 6786 "Withholding Tax Jnl Subscriber" [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", OnPostBankAccOnBeforeInitBankAccLedgEntry, '', false, false)] local procedure OnPostBankAccOnBeforeInitBankAccLedgEntry(var GenJournalLine: Record "Gen. Journal Line"; var TaxAmount: Decimal; var TaxAmountLCY: Decimal) + var + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; begin if CheckWithholdingTaxDisabled() then exit; + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJournalLine) then + exit; + CalcBankAccWHT(GenJournalLine, TaxAmountLCY, TaxAmount); end; @@ -706,19 +754,29 @@ codeunit 6786 "Withholding Tax Jnl Subscriber" [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", OnPostBankAccOnBeforeCheckLedgEntryInsert, '', false, false)] local procedure OnPostBankAccOnBeforeCheckLedgEntryInsert(var CheckLedgerEntry: Record "Check Ledger Entry"; var GenJournalLine: Record "Gen. Journal Line"; TaxAmount: Decimal; TaxAmountLCY: Decimal) + var + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; begin if CheckWithholdingTaxDisabled() then exit; + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJournalLine) then + exit; + PostBankAccWHTOnBeforeCheckLedgEntryInsert(CheckLedgerEntry, GenJournalLine, TaxAmountLCY); end; [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", OnPostBankAccOnBeforeCreateGLEntryBalAcc, '', false, false)] local procedure OnPostBankAccOnBeforeCreateGLEntryBalAcc(var GenJnlLine: Record "Gen. Journal Line"; BankAccPostingGr: Record "Bank Account Posting Group"; TaxAmount: Decimal; TaxAmountLCY: Decimal; sender: Codeunit "Gen. Jnl.-Post Line"; var IsHandled: Boolean) + var + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; begin if CheckWithholdingTaxDisabled() then exit; + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJnlLine) then + exit; + sender.CreateGLEntryBalAcc( GenJnlLine, BankAccPostingGr."G/L Account No.", GenJnlLine."Amount (LCY)" + TaxAmountLCY, GenJnlLine."Source Currency Amount" + TaxAmount, @@ -895,28 +953,43 @@ codeunit 6786 "Withholding Tax Jnl Subscriber" [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", OnBeforeCopyFromCVLedgEntryBuffer, '', false, false)] local procedure OnBeforeCopyFromCVLedgEntryBuffer(var GenJnlLine: Record "Gen. Journal Line"; OldVendLedgEntry: Record "Vendor Ledger Entry"; TempOldVendLedgEntry: Record "Vendor Ledger Entry" temporary; AppliedAmount: Decimal; var RemainingTaxAmount: Decimal; NextTransactionNo: Integer; var NextTaxEntryNo: Integer) + var + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; begin if CheckWithholdingTaxDisabled() then exit; + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJnlLine) then + exit; + ApplyVendLedgEntryOnBeforeOldVendLedgEntryModify(GenJnlLine, OldVendLedgEntry, TempOldVendLedgEntry, AppliedAmount, RemainingTaxAmount, NextTransactionNo, NextTaxEntryNo); end; [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", OnBeforeUpdateOldVendLedgEntryAmountToApply, '', false, false)] - local procedure OnBeforeUpdateOldVendLedgEntryAmountToApply(var OldVendLedgEntry: Record "Vendor Ledger Entry"; OldCVLedgEntryBuf: Record "CV Ledger Entry Buffer"; RemainingTaxAmount: Decimal; AppliedAmount: Decimal; var IsHandled: Boolean) + local procedure OnBeforeUpdateOldVendLedgEntryAmountToApply(var OldVendLedgEntry: Record "Vendor Ledger Entry"; OldCVLedgEntryBuf: Record "CV Ledger Entry Buffer"; RemainingTaxAmount: Decimal; AppliedAmount: Decimal; GenJnlLine: Record "Gen. Journal Line"; var IsHandled: Boolean) + var + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; begin if CheckWithholdingTaxDisabled() then exit; + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJnlLine) then + exit; + UpdateAmountToApply(OldVendLedgEntry, RemainingTaxAmount, AppliedAmount, IsHandled); end; [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", OnAfterOldVendLedgEntryModify, '', false, false)] local procedure OnAfterOldVendLedgEntryModify(GenJournalLine: Record "Gen. Journal Line"; AppliedAmount: Decimal; var NextTaxEntryNo: Integer; var NextEntryNo: Integer; var NextCheckEntryNo: Integer; NextTransactionNo: Integer; sender: Codeunit "Gen. Jnl.-Post Line") + var + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; begin if CheckWithholdingTaxDisabled() then exit; + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJournalLine) then + exit; + ApplyWHT(GenJournalLine, AppliedAmount, NextTaxEntryNo, NextEntryNo, NextCheckEntryNo, NextTransactionNo, sender); end; @@ -925,11 +998,15 @@ codeunit 6786 "Withholding Tax Jnl Subscriber" var GLSetup: Record "General Ledger Setup"; PurchCrMemoHeader: Record "Purch. Cr. Memo Hdr."; + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; WithholdingTaxAmount: Decimal; begin if CheckWithholdingTaxDisabled() then exit; + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJournalLine) then + exit; + if GenJournalLine."Document Type" = GenJournalLine."Document Type"::Refund then if GLSetup."Manual Sales Wthldg. Tax Calc." then if PurchCrMemoHeader.Get(VendorLedgerEntry."Document No.") then @@ -1423,11 +1500,15 @@ codeunit 6786 "Withholding Tax Jnl Subscriber" local procedure OnUnapplyVendLedgEntryOnAfterCreateGLEntriesForTotalAmounts(var GenJournalLine: Record "Gen. Journal Line"; DetailedVendorLedgEntry: Record "Detailed Vendor Ledg. Entry"; GenJournalLineToPost: Record "Gen. Journal Line"; var NextTaxEntryNo: Integer; var NextEntryNo: Integer; var NextCheckEntryNo: Integer; NextTransactionNo: Integer; sender: Codeunit "Gen. Jnl.-Post Line") var SourceCodeSetup: Record "Source Code Setup"; + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; VoidCheck: Boolean; begin if CheckWithholdingTaxDisabled() then exit; + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJournalLine) then + exit; + SourceCodeSetup.Get(); if GenJournalLine."Source Code" = SourceCodeSetup."Financially Voided Check" then @@ -1566,10 +1647,15 @@ codeunit 6786 "Withholding Tax Jnl Subscriber" [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Batch", OnBeforeProcessBalanceOfLines, '', false, false)] local procedure OnBeforeProcessBalanceOfLines(var GenJournalBatch: Record "Gen. Journal Batch"; var GenJournalLine: Record "Gen. Journal Line"; var GenJournalTemplate: Record "Gen. Journal Template"; var IsKeySet: Boolean) + var + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; begin if CheckWithholdingTaxDisabled() then exit; + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJournalLine) then + exit; + if (IsWHTPaymentPosting(GenJournalLine) or GenJournalTemplate."Force Doc. Balance") then GenJournalLine.SetCurrentKey("Document No.", "Posting Date") else @@ -1629,10 +1715,14 @@ codeunit 6786 "Withholding Tax Jnl Subscriber" local procedure OnProcessLinesOnAfterProcessICTransaction(var GenJournalLine: Record "Gen. Journal Line"; CurrentICPartner: Code[20]; ICTransactionNo: Integer; var LastTaxLineNo: Integer; sender: Codeunit "Gen. Jnl.-Post Batch") var WHTGenJournalLine: Record "Gen. Journal Line"; + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; begin if CheckWithholdingTaxDisabled() then exit; + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJournalLine) then + exit; + WHTGenJournalLine.SetRange("Journal Template Name", GenJournalLine."Journal Template Name"); WHTGenJournalLine.SetRange("Journal Batch Name", GenJournalLine."Journal Batch Name"); WHTGenJournalLine.SetRange("Is Withholding Tax", true); @@ -1647,20 +1737,30 @@ codeunit 6786 "Withholding Tax Jnl Subscriber" [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Batch", OnBeforeFindGenJnlLineOnProcessLines, '', false, false)] local procedure OnBeforeFindGenJnlLineOnProcessLines(var GenJournalLine: Record "Gen. Journal Line") + var + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; begin if CheckWithholdingTaxDisabled() then exit; + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJournalLine) then + exit; + GenJournalLine.SetRange("Is Withholding Tax"); GenJournalLine.FindSet(true); end; [EventSubscriber(ObjectType::Codeunit, Codeunit::"Bank Acc. Reconciliation Post", OnPostPaymentApplicationsOnAfterPostGenJnlLine, '', false, false)] local procedure OnPostPaymentApplicationsOnAfterPostGenJnlLine(var GenJournalLine: Record "Gen. Journal Line"; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line") + var + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; begin if CheckWithholdingTaxDisabled() then exit; + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJournalLine) then + exit; + PostUnrealizedWHT(GenJournalLine, GenJnlPostLine); end; diff --git a/Apps/W1/WithholdingTax/app/src/Purchase/Transaction/WithholdingTaxMgmt.Codeunit.al b/Apps/W1/WithholdingTax/app/src/Purchase/Transaction/WithholdingTaxMgmt.Codeunit.al index 6d6572e987..d499fb065e 100644 --- a/Apps/W1/WithholdingTax/app/src/Purchase/Transaction/WithholdingTaxMgmt.Codeunit.al +++ b/Apps/W1/WithholdingTax/app/src/Purchase/Transaction/WithholdingTaxMgmt.Codeunit.al @@ -4993,4 +4993,21 @@ codeunit 6785 "Withholding Tax Mgmt." then exit(WithholdingTaxEntry2."Entry No." + 1); end; + + procedure CheckVendorWithholdingTaxLiable(GenJnlLine: Record "Gen. Journal Line"): Boolean + var + Vendor: Record Vendor; + begin + if Vendor.Get(GetVendorNo(GenJnlLine)) then + exit(Vendor."Withholding Tax Liable"); + end; + + local procedure GetVendorNo(GenJnlLine: Record "Gen. Journal Line"): Code[20] + begin + if GenJnlLine."Account Type" = GenJnlLine."Account Type"::Vendor then + exit(GenJnlLine."Account No.") + else + if GenJnlLine."Bal. Account Type" = GenJnlLine."Bal. Account Type"::Vendor then + exit(GenJnlLine."Bal. Account No."); + end; } \ No newline at end of file diff --git a/Apps/W1/WithholdingTax/app/src/Purchase/Transaction/WthldgTaxPurchSubscribers.Codeunit.al b/Apps/W1/WithholdingTax/app/src/Purchase/Transaction/WthldgTaxPurchSubscribers.Codeunit.al index 70adc92762..ebd6748d0e 100644 --- a/Apps/W1/WithholdingTax/app/src/Purchase/Transaction/WthldgTaxPurchSubscribers.Codeunit.al +++ b/Apps/W1/WithholdingTax/app/src/Purchase/Transaction/WthldgTaxPurchSubscribers.Codeunit.al @@ -30,61 +30,85 @@ codeunit 6784 "Wthldg Tax Purch. Subscribers" if CheckWithholdingTaxDisabled() then exit; + if not Vendor."Withholding Tax Liable" then + exit; + PurchaseHeader."Wthldg. Tax Bus. Post. Group" := Vendor."Wthldg. Tax Bus. Post. Group"; end; [EventSubscriber(ObjectType::Table, Database::"Purchase Line", OnAfterInitHeaderDefaults, '', false, false)] - local procedure CopyHeaderInf0(PurchHeader: Record "Purchase Header"; var PurchLine: Record "Purchase Line") + local procedure CopyHeaderInfo(PurchHeader: Record "Purchase Header"; var PurchLine: Record "Purchase Line") begin if CheckWithholdingTaxDisabled() then exit; + if not CheckWithholdingTaxLiable(PurchHeader) then + exit; + PurchLine."Wthldg. Tax Bus. Post. Group" := PurchHeader."Wthldg. Tax Bus. Post. Group"; end; [EventSubscriber(ObjectType::Table, Database::"Purchase Line", OnAfterAssignGLAccountValues, '', false, false)] - local procedure AssignGLAccValue(var PurchLine: Record "Purchase Line"; GLAccount: Record "G/L Account") + local procedure AssignGLAccValue(var PurchLine: Record "Purchase Line"; GLAccount: Record "G/L Account"; PurchHeader: Record "Purchase Header") begin if CheckWithholdingTaxDisabled() then exit; + if not CheckWithholdingTaxLiable(PurchHeader) then + exit; + PurchLine."Wthldg. Tax Prod. Post. Group" := GLAccount."Wthldg. Tax Prod. Post. Group"; end; [EventSubscriber(ObjectType::Table, Database::"Purchase Line", OnAfterAssignItemValues, '', false, false)] - local procedure AssignItemValue(var PurchLine: Record "Purchase Line"; Item: Record Item) + local procedure AssignItemValue(var PurchLine: Record "Purchase Line"; Item: Record Item; PurchHeader: Record "Purchase Header") begin if CheckWithholdingTaxDisabled() then exit; + if not CheckWithholdingTaxLiable(PurchHeader) then + exit; + PurchLine."Wthldg. Tax Prod. Post. Group" := Item."Wthldg. Tax Prod. Post. Group"; end; [EventSubscriber(ObjectType::Table, Database::"Purchase Line", OnAfterAssignFixedAssetValues, '', false, false)] - local procedure AssignFAValue(var PurchLine: Record "Purchase Line"; FixedAsset: Record "Fixed Asset") + local procedure AssignFAValue(var PurchLine: Record "Purchase Line"; FixedAsset: Record "Fixed Asset"; PurchHeader: Record "Purchase Header") begin if CheckWithholdingTaxDisabled() then exit; + if not CheckWithholdingTaxLiable(PurchHeader) then + exit; + PurchLine."Wthldg. Tax Prod. Post. Group" := FixedAsset."Wthldg. Tax Prod. Post. Group"; end; [EventSubscriber(ObjectType::Codeunit, Codeunit::"Purch. Post Invoice Events", OnAfterPrepareInvoicePostingBuffer, '', false, false)] local procedure OnAfterPrepareInvoicePostingBuffer(var InvoicePostingBuffer: Record "Invoice Posting Buffer" temporary; var PurchaseLine: Record "Purchase Line") + var + PurchHeader: Record "Purchase Header"; begin if CheckWithholdingTaxDisabled() then exit; + PurchHeader.Get(PurchaseLine."Document Type", PurchaseLine."Document No."); + if not CheckWithholdingTaxLiable(PurchHeader) then + exit; + InvoicePostingBuffer."Wthldg. Tax Bus. Post. Group" := PurchaseLine."Wthldg. Tax Bus. Post. Group"; InvoicePostingBuffer."Wthldg. Tax Prod. Post. Group" := PurchaseLine."Wthldg. Tax Prod. Post. Group"; end; [EventSubscriber(ObjectType::Codeunit, Codeunit::"Purch. Post Invoice Events", OnPrepareGenJnlLineOnAfterCopyToGenJnlLine, '', false, false)] - local procedure OnPrepareGenJnlLineOnAfterCopyToGenJnlLine(InvoicePostingBuffer: Record "Invoice Posting Buffer" temporary; var GenJnlLine: Record "Gen. Journal Line") + local procedure OnPrepareGenJnlLineOnAfterCopyToGenJnlLine(InvoicePostingBuffer: Record "Invoice Posting Buffer" temporary; var GenJnlLine: Record "Gen. Journal Line"; PurchHeader: Record "Purchase Header") begin if CheckWithholdingTaxDisabled() then exit; + if not CheckWithholdingTaxLiable(PurchHeader) then + exit; + InvoicePostingBuffer."Wthldg. Tax Bus. Post. Group" := GenJnlLine."Wthldg. Tax Bus. Post. Group"; InvoicePostingBuffer."Wthldg. Tax Prod. Post. Group" := GenJnlLine."Wthldg. Tax Prod. Post. Group"; end; @@ -95,6 +119,9 @@ codeunit 6784 "Wthldg Tax Purch. Subscribers" if CheckWithholdingTaxDisabled() then exit; + if not CheckWithholdingTaxLiable(PurchHeader) then + exit; + GenJnlLine."Wthldg. Tax Bus. Post. Group" := PurchHeader."Wthldg. Tax Bus. Post. Group"; end; @@ -104,15 +131,24 @@ codeunit 6784 "Wthldg Tax Purch. Subscribers" if CheckWithholdingTaxDisabled() then exit; + if not CheckWithholdingTaxLiable(PurchHeader) then + exit; + GenJnlLine."Wthldg. Tax Bus. Post. Group" := PurchHeader."Wthldg. Tax Bus. Post. Group"; end; [EventSubscriber(ObjectType::Codeunit, Codeunit::"Purch. Post Invoice Events", OnPrepareLineOnAfterAssignAmounts, '', false, false)] local procedure OnPrepareLineOnAfterAssignAmounts(PurchLine: Record "Purchase Line"; var TotalAmount: Decimal; var TotalAmountACY: Decimal) + var + PurchHeader: Record "Purchase Header"; begin if CheckWithholdingTaxDisabled() then exit; + PurchHeader.Get(PurchLine."Document Type", PurchLine."Document No."); + if not CheckWithholdingTaxLiable(PurchHeader) then + exit; + AssignWithholdingAmounts(PurchLine, TotalAmount, TotalAmountACY); end; @@ -124,6 +160,9 @@ codeunit 6784 "Wthldg Tax Purch. Subscribers" if CheckWithholdingTaxDisabled() then exit; + if not CheckWithholdingTaxLiable(PurchHeader) then + exit; + GenJnlLine.Amount += PurchHeader."Withholding Tax Amount"; GenJnlLine."Source Currency Amount" += PurchHeader."Withholding Tax Amount"; @@ -187,6 +226,9 @@ codeunit 6784 "Wthldg Tax Purch. Subscribers" if CheckWithholdingTaxDisabled() then exit; + if not CheckWithholdingTaxLiable(PurchHeader) then + exit; + if PurchHeader.IsCreditDocType() then begin if (PurchHeader."Applies-to Doc. Type" = PurchHeader."Applies-to Doc. Type"::Invoice) and (PurchHeader."Applies-to Doc. No." <> '') then WithholdingTaxMgmt.CheckApplicationPurchWithholdingTax(PurchHeader); @@ -214,6 +256,9 @@ codeunit 6784 "Wthldg Tax Purch. Subscribers" if CheckWithholdingTaxDisabled() then exit; + if not CheckWithholdingTaxLiable(PurchaseHeader) then + exit; + PostWithholdingTax(PurchaseHeader, SrcCode, GenJnlLineDocType, GenJnlLineDocNo, GenJnlLineExtDocNo, GenJnlPostLine, TotalPurchLineLCY, TempPurchLineGlobal, TotalAmount); end; @@ -225,6 +270,9 @@ codeunit 6784 "Wthldg Tax Purch. Subscribers" if CheckWithholdingTaxDisabled() then exit; + if not CheckWithholdingTaxLiable(PurchaseHeader) then + exit; + if PurchaseHeader."Document Type" in [PurchaseHeader."Document Type"::Order, PurchaseHeader."Document Type"::Invoice] then if DocumentType = DocumentType::Invoice then WithholdingTaxMgmt.InsertVendPrepaymentInvoiceWithholding(PurchInvHeader, PurchaseHeader); @@ -235,12 +283,16 @@ codeunit 6784 "Wthldg Tax Purch. Subscribers" var WithholdingTaxEntry: Record "Withholding Tax Entry"; GLRegister: Record "G/L Register"; + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; WithholdingTaxAmount: Decimal; WithholdingTaxAmountLCY: Decimal; begin if CheckWithholdingTaxDisabled() then exit; + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJnlLine) then + exit; + WithholdingTaxAmount := 0; WithholdingTaxAmountLCY := 0; @@ -259,7 +311,7 @@ codeunit 6784 "Wthldg Tax Purch. Subscribers" end; [EventSubscriber(ObjectType::Codeunit, Codeunit::"Purchase-Post Prepayments", OnBeforePostVendorEntry, '', false, false)] - local procedure OnBeforePostVendorEntry(var GenJnlLine: Record "Gen. Journal Line") + local procedure OnBeforePostVendorEntry(var GenJnlLine: Record "Gen. Journal Line"; PurchaseHeader: Record "Purchase Header") var WithholdingTaxEntry: Record "Withholding Tax Entry"; WithholdingTaxAmount: Decimal; @@ -268,6 +320,9 @@ codeunit 6784 "Wthldg Tax Purch. Subscribers" if CheckWithholdingTaxDisabled() then exit; + if not CheckWithholdingTaxLiable(PurchaseHeader) then + exit; + CalcWithholdingTaxAmounts(GenJnlLine."Document No.", WithholdingTaxEntry, WithholdingTaxAmount, WithholdingTaxAmountLCY); GenJnlLine.Amount += WithholdingTaxAmount; @@ -278,12 +333,16 @@ codeunit 6784 "Wthldg Tax Purch. Subscribers" local procedure OnBeforePostBalancingEntry(var GenJnlLine: Record "Gen. Journal Line") var WithholdingTaxEntry: Record "Withholding Tax Entry"; + WithholdingTaxMgmt: Codeunit "Withholding Tax Mgmt."; WithholdingTaxAmount: Decimal; WithholdingTaxAmountLCY: Decimal; begin if CheckWithholdingTaxDisabled() then exit; + if not WithholdingTaxMgmt.CheckVendorWithholdingTaxLiable(GenJnlLine) then + exit; + CalcWithholdingTaxAmounts(GenJnlLine."Document No.", WithholdingTaxEntry, WithholdingTaxAmount, WithholdingTaxAmountLCY); GenJnlLine.Amount -= WithholdingTaxAmount; @@ -298,6 +357,9 @@ codeunit 6784 "Wthldg Tax Purch. Subscribers" if CheckWithholdingTaxDisabled() then exit; + if not CheckWithholdingTaxLiable(PurchaseHeader) then + exit; + if PurchaseHeader."Document Type" in [PurchaseHeader."Document Type"::Order, PurchaseHeader."Document Type"::Invoice] then if DocumentType = DocumentType::"Credit Memo" then WithholdingTaxMgmt.InsertVendPrepaymentCrMemoWithholding(PurchCrMemoHdr, PurchaseHeader); @@ -502,4 +564,12 @@ codeunit 6784 "Wthldg Tax Purch. Subscribers" exit(false); end; + + local procedure CheckWithholdingTaxLiable(PurchHeader: Record "Purchase Header"): Boolean + var + Vendor: Record Vendor; + begin + Vendor.Get(PurchHeader."Pay-to Vendor No."); + exit(Vendor."Withholding Tax Liable"); + end; } \ No newline at end of file diff --git a/Build/Packages.json b/Build/Packages.json index bf7c798633..1ed931796b 100644 --- a/Build/Packages.json +++ b/Build/Packages.json @@ -4,9 +4,8 @@ "Source": "NuGet.org" }, "AppBaselines-BCArtifacts": { - "Version": "27.5.45926", + "Version": "27.5.46232", "Source": "BCArtifacts", "_comment": "Used to fetch app baselines from BC artifacts" } } -