diff --git a/.github/AL-Go-Settings.json b/.github/AL-Go-Settings.json
index 667cbffc6b..379ec9f4f4 100644
--- a/.github/AL-Go-Settings.json
+++ b/.github/AL-Go-Settings.json
@@ -5,7 +5,7 @@
"runs-on": "windows-latest",
"cacheImageName": "",
"UsePsSession": false,
- "artifact": "https://bcinsider-fvh2ekdjecfjd6gk.b02.azurefd.net/sandbox/25.0.20074.0/base",
+ "artifact": "https://bcinsider-fvh2ekdjecfjd6gk.b02.azurefd.net/sandbox/25.0.20906.0/base",
"country": "base",
"useProjectDependencies": true,
"repoVersion": "25.0",
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/GenJnlPostLineHandlerCZZ.Codeunit.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/GenJnlPostLineHandlerCZZ.Codeunit.al
index 19407206f8..d74f0e936b 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/GenJnlPostLineHandlerCZZ.Codeunit.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/GenJnlPostLineHandlerCZZ.Codeunit.al
@@ -26,19 +26,11 @@ codeunit 31003 "Gen.Jnl.-Post Line Handler CZZ"
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnBeforeCreateGLEntriesForTotalAmountsV19', '', false, false)]
local procedure GenJnlPostLineOnBeforeCreateGLEntriesForTotalAmounts(GenJournalLine: Record "Gen. Journal Line"; var GLAccNo: Code[20])
- var
- SalesAdvLetterManagement: Codeunit "SalesAdvLetterManagement CZZ";
- PurchAdvLetterManagement: Codeunit "PurchAdvLetterManagement CZZ";
begin
if not GenJournalLine."Use Advance G/L Account CZZ" then
exit;
- case GenJournalLine."Account Type" of
- GenJournalLine."Account Type"::Customer:
- GLAccNo := SalesAdvLetterManagement.GetAdvanceGLAccount(GenJournalLine);
- GenJournalLine."Account Type"::Vendor:
- GLAccNo := PurchAdvLetterManagement.GetAdvanceGLAccount(GenJournalLine);
- end;
+ GLAccNo := GenJournalLine.GetAdvanceGLAccountNoCZZ();
end;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnBeforePostApply', '', false, false)]
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/PurchAdvLetterManagementCZZ.Codeunit.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/PurchAdvLetterManagementCZZ.Codeunit.al
index bb8c20ad71..b9b2628647 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/PurchAdvLetterManagementCZZ.Codeunit.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/PurchAdvLetterManagementCZZ.Codeunit.al
@@ -23,7 +23,6 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
var
PurchAdvLetterEntryCZZGlob: Record "Purch. Adv. Letter Entry CZZ";
TempPurchAdvLetterEntryCZZGlob: Record "Purch. Adv. Letter Entry CZZ" temporary;
- CurrencyGlob: Record Currency;
PurchAdvLetterPostCZZ: Codeunit "Purch. Adv. Letter-Post CZZ";
DateEmptyErr: Label 'Posting Date and VAT Date cannot be empty.';
DocumentNoOrDatesEmptyErr: Label 'Document No. and Dates cannot be empty.';
@@ -229,7 +228,9 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
AdvanceLetterLink.GetLetterLink(TempAdvanceLetterLinkBuffer);
TempAdvanceLetterLinkBuffer.SetFilter(Amount, '>0');
if not TempAdvanceLetterLinkBuffer.IsEmpty() then begin
- PostingDate := GetPostingDateUI(VendorLedgerEntry."Posting Date");
+ PostingDate := VendorLedgerEntry."Posting Date";
+ if not GetPostingDateUI(PostingDate) then
+ exit;
if PostingDate = 0D then
Error(PostingDateEmptyErr);
LinkAdvancePayment(VendorLedgerEntry, TempAdvanceLetterLinkBuffer, PostingDate);
@@ -252,7 +253,9 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
var
PostingDate: Date;
begin
- PostingDate := GetPostingDateUI(VendorLedgerEntry."Posting Date");
+ PostingDate := VendorLedgerEntry."Posting Date";
+ if not GetPostingDateUI(PostingDate) then
+ exit;
if PostingDate = 0D then
Error(PostingDateEmptyErr);
@@ -263,7 +266,9 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
var
PostingDate: Date;
begin
- PostingDate := GetPostingDateUI(VendorLedgerEntry."Posting Date");
+ PostingDate := VendorLedgerEntry."Posting Date";
+ if not GetPostingDateUI(PostingDate) then
+ exit;
if PostingDate = 0D then
Error(PostingDateEmptyErr);
@@ -289,7 +294,8 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
PurchAdvLetterPostCZZ.PostAdvancePayment(
VendorLedgerEntry, PostedGenJournalLine, GenJnlPostLine, AdvancePostingParametersCZZ);
end;
-
+#if not CLEAN25
+ [Obsolete('Replaced by GetAdvanceGLAccountNoCZZ function in GenJournalLine.', '25.0')]
procedure GetAdvanceGLAccount(var GenJournalLine: Record "Gen. Journal Line"): Code[20]
var
PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ";
@@ -301,6 +307,7 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
AdvanceLetterTemplateCZZ.TestField("Advance Letter G/L Account");
exit(AdvanceLetterTemplateCZZ."Advance Letter G/L Account");
end;
+#endif
procedure PostAdvancePaymentVAT(var PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ"; PostingDate: Date)
var
@@ -351,15 +358,24 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
AdvanceLetterTemplateCZZ.Get(PurchAdvLetterHeaderCZZ."Advance Letter Code");
AdvanceLetterTemplateCZZ.TestField("Advance Letter Invoice Nos.");
- InitVATAmountLine(TempAdvancePostingBufferCZZ, PurchAdvLetterEntryCZZ."Purch. Adv. Letter No.", PurchAdvLetterEntryCZZ.Amount, PurchAdvLetterEntryCZZ."Currency Factor");
- VATDocumentCZZ.InitDocument(AdvanceLetterTemplateCZZ."Advance Letter Invoice Nos.", '', PurchAdvLetterHeaderCZZ."Document Date",
+ InitVATAmountLine(TempAdvancePostingBufferCZZ, PurchAdvLetterEntryCZZ."Purch. Adv. Letter No.",
+ PurchAdvLetterEntryCZZ.Amount, PurchAdvLetterEntryCZZ."Currency Factor");
+
+ TempAdvancePostingBufferCZZ.Reset();
+ TempAdvancePostingBufferCZZ.SetRange("Auxiliary Entry", false);
+ if TempAdvancePostingBufferCZZ.IsEmpty() then
+ DocumentNo := PurchAdvLetterHeaderCZZ."No.";
+ TempAdvancePostingBufferCZZ.Reset();
+
+ VATDocumentCZZ.InitDocument(AdvanceLetterTemplateCZZ."Advance Letter Invoice Nos.", DocumentNo, PurchAdvLetterHeaderCZZ."Document Date",
PostingDate, PurchAdvLetterEntryCZZ."VAT Date", PurchAdvLetterHeaderCZZ."Original Document VAT Date",
PurchAdvLetterHeaderCZZ."Currency Code", PurchAdvLetterEntryCZZ."Currency Factor", '', TempAdvancePostingBufferCZZ);
if VATDocumentCZZ.RunModal() <> Action::OK then
exit;
VATDocumentCZZ.SaveNoSeries();
- VATDocumentCZZ.GetDocument(DocumentNo, PostingDate, DocumentDate, VATDate, OriginalDocumentVATDate, ExternalDocumentNo, TempAdvancePostingBufferCZZ);
+ VATDocumentCZZ.GetDocument(DocumentNo, PostingDate, DocumentDate, VATDate,
+ OriginalDocumentVATDate, ExternalDocumentNo, TempAdvancePostingBufferCZZ);
Clear(AdvancePostingParametersCZZ);
AdvancePostingParametersCZZ."Document Type" := Enum::"Gen. Journal Document Type"::Invoice;
@@ -413,24 +429,29 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
local procedure BufferAdvanceLines(PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ"; var AdvancePostingBufferCZZ: Record "Advance Posting Buffer CZZ")
var
+ AdvanceLetterTemplateCZZ: Record "Advance Letter Template CZZ";
PurchAdvLetterLineCZZ: Record "Purch. Adv. Letter Line CZZ";
TempAdvancePostingBufferCZZ: Record "Advance Posting Buffer CZZ" temporary;
begin
AdvancePostingBufferCZZ.Reset();
AdvancePostingBufferCZZ.DeleteAll();
+ AdvanceLetterTemplateCZZ.Get(PurchAdvLetterHeaderCZZ."Advance Letter Code");
+
PurchAdvLetterLineCZZ.SetRange("Document No.", PurchAdvLetterHeaderCZZ."No.");
PurchAdvLetterLineCZZ.SetFilter(Amount, '<>0');
if PurchAdvLetterLineCZZ.FindSet() then
repeat
TempAdvancePostingBufferCZZ.PrepareForPurchAdvLetterLine(PurchAdvLetterLineCZZ);
AdvancePostingBufferCZZ.Update(TempAdvancePostingBufferCZZ);
- until PurchAdvLetterLineCZZ.Next() = 0;
- end;
- local procedure GetCurrency(CurrencyCode: Code[10])
- begin
- CurrencyGlob.Initialize(CurrencyCode, true);
+ if (not AdvanceLetterTemplateCZZ."Post VAT Doc. for Rev. Charge") and
+ (AdvancePostingBufferCZZ."VAT Calculation Type" = "Tax Calculation Type"::"Reverse Charge VAT")
+ then begin
+ AdvancePostingBufferCZZ."Auxiliary Entry" := true;
+ AdvancePostingBufferCZZ.Modify();
+ end;
+ until PurchAdvLetterLineCZZ.Next() = 0;
end;
procedure LinkAdvanceLetter(AdvLetterUsageDocTypeCZZ: Enum "Adv. Letter Usage Doc.Type CZZ"; DocumentNo: Code[20]; PayToVendorNo: Code[20]; PostingDate: Date; CurrencyCode: Code[10])
@@ -488,7 +509,9 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
begin
VendorLedgerEntry.TestField("Advance Letter No. CZZ");
- PostingDate := GetPostingDateUI(VendorLedgerEntry."Posting Date");
+ PostingDate := VendorLedgerEntry."Posting Date";
+ if not GetPostingDateUI(PostingDate) then
+ exit;
if PostingDate = 0D then
Error(PostingDateEmptyErr);
@@ -508,7 +531,9 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
PostingDate: Date;
begin
VendorLedgerEntry.Get(PurchAdvLetterEntryCZZ."Vendor Ledger Entry No.");
- PostingDate := GetPostingDateUI(VendorLedgerEntry."Posting Date");
+ PostingDate := VendorLedgerEntry."Posting Date";
+ if not GetPostingDateUI(PostingDate) then
+ exit;
if PostingDate = 0D then
Error(PostingDateEmptyErr);
UnlinkAdvancePayment(PurchAdvLetterEntryCZZ, PostingDate);
@@ -651,46 +676,6 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
PurchAdvLetterEntryCZZ, TempAdvancePostingBufferCZZ, GenJnlPostLine, AdvancePostingParametersCZZ);
end;
- local procedure PostExchangeRate(ExchRateAmount: Decimal; ExchRateVATAmount: Decimal; var PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ";
- var PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ"; var VATPostingSetup: Record "VAT Posting Setup";
- DocumentNo: Code[20]; PostingDate: Date; VATDate: Date; SourceCode: Code[10]; PostDescription: Text[100]; UsageEntryNo: Integer; Correction: Boolean;
- var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; Preview: Boolean)
- var
- AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ";
- begin
- Clear(AdvancePostingParametersCZZ);
- AdvancePostingParametersCZZ."Document No." := DocumentNo;
- AdvancePostingParametersCZZ."Posting Date" := PostingDate;
- AdvancePostingParametersCZZ."VAT Date" := VATDate;
- AdvancePostingParametersCZZ."Source Code" := SourceCode;
- AdvancePostingParametersCZZ."Posting Description" := PostDescription;
- AdvancePostingParametersCZZ."Temporary Entries Only" := Preview;
-
- PurchAdvLetterPostCZZ.PostExchangeRate(
- PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, VATPostingSetup,
- ExchRateAmount, ExchRateVATAmount, UsageEntryNo, Correction, GenJnlPostLine, AdvancePostingParametersCZZ);
- end;
-
- local procedure InitGenJnlLineFromAdvance(var PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ"; var PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ"; DocumentNo: Code[20]; ExternalDocumentNo: Code[35]; SourceCode: Code[10]; PostDescription: Text[100]; var GenJournalLine: Record "Gen. Journal Line")
- begin
- GenJournalLine.Init();
- GenJournalLine."System-Created Entry" := true;
- GenJournalLine."Document No." := DocumentNo;
- GenJournalLine."External Document No." := ExternalDocumentNo;
- GenJournalLine.Description := PostDescription;
- GenJournalLine."Source Code" := SourceCode;
- GenJournalLine."Bill-to/Pay-to No." := PurchAdvLetterHeaderCZZ."Pay-to Vendor No.";
- GenJournalLine."Country/Region Code" := PurchAdvLetterHeaderCZZ."Pay-to Country/Region Code";
- GenJournalLine."VAT Registration No." := PurchAdvLetterHeaderCZZ."VAT Registration No.";
- GenJournalLine."Registration No. CZL" := PurchAdvLetterHeaderCZZ."Registration No.";
- GenJournalLine."Tax Registration No. CZL" := PurchAdvLetterHeaderCZZ."Tax Registration No.";
- GenJournalLine."Shortcut Dimension 1 Code" := PurchAdvLetterEntryCZZ."Global Dimension 1 Code";
- GenJournalLine."Shortcut Dimension 2 Code" := PurchAdvLetterEntryCZZ."Global Dimension 2 Code";
- GenJournalLine."Dimension Set ID" := PurchAdvLetterEntryCZZ."Dimension Set ID";
- GenJournalLine."Adv. Letter No. (Entry) CZZ" := PurchAdvLetterEntryCZZ."Purch. Adv. Letter No.";
- OnAfterInitGenJnlLineFromAdvance(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, GenJournalLine);
- end;
-
procedure GetRemAmtPurchAdvPayment(var PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ"; BalanceAtDate: Date): Decimal
var
PurchAdvLetterEntry2: Record "Purch. Adv. Letter Entry CZZ";
@@ -834,6 +819,7 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
VATDocumentCZZ: Page "VAT Document CZZ";
DocumentNo: Code[20];
ExternalDocumentNo: Code[35];
+ SourceCode: Code[10];
VATDate: Date;
OriginalDocumentVATDate: Date;
DocumentDate: Date;
@@ -844,7 +830,13 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
PurchAdvLetterHeaderCZZ.Get(PurchAdvLetterEntryCZZ."Purch. Adv. Letter No.");
AdvanceLetterTemplateCZZ.Get(PurchAdvLetterHeaderCZZ."Advance Letter Code");
- VATEntry.Get(PurchAdvLetterEntryCZZ."VAT Entry No.");
+
+ // find VAT entry of the VAT document due to source code
+ SourceCode := '';
+ VATEntry.SetRange("Document No.", PurchAdvLetterEntryCZZ."Document No.");
+ VATEntry.SetRange("Posting Date", PurchAdvLetterEntryCZZ."Posting Date");
+ if VATEntry.FindFirst() then
+ SourceCode := VATEntry."Source Code";
PurchAdvLetterEntryCZZ2.SetRange("Purch. Adv. Letter No.", PurchAdvLetterEntryCZZ."Purch. Adv. Letter No.");
PurchAdvLetterEntryCZZ2.SetRange(Cancelled, false);
@@ -856,7 +848,13 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
TempAdvancePostingBufferCZZ1.Update(TempAdvancePostingBufferCZZ);
until PurchAdvLetterEntryCZZ2.Next() = 0;
- VATDocumentCZZ.InitDocument(AdvanceLetterTemplateCZZ."Advance Letter Cr. Memo Nos.", '', PurchAdvLetterEntryCZZ."Posting Date",
+ TempAdvancePostingBufferCZZ1.Reset();
+ TempAdvancePostingBufferCZZ1.SetRange("Auxiliary Entry", false);
+ if TempAdvancePostingBufferCZZ1.IsEmpty() then
+ DocumentNo := PurchAdvLetterHeaderCZZ."No.";
+ TempAdvancePostingBufferCZZ1.Reset();
+
+ VATDocumentCZZ.InitDocument(AdvanceLetterTemplateCZZ."Advance Letter Cr. Memo Nos.", DocumentNo, PurchAdvLetterEntryCZZ."Posting Date",
PurchAdvLetterEntryCZZ."Posting Date", PurchAdvLetterEntryCZZ."VAT Date", PurchAdvLetterEntryCZZ."Original Document VAT Date",
PurchAdvLetterHeaderCZZ."Currency Code", PurchAdvLetterEntryCZZ."Currency Factor", PurchAdvLetterEntryCZZ."External Document No.", TempAdvancePostingBufferCZZ1);
if VATDocumentCZZ.RunModal() <> Action::OK then
@@ -873,7 +871,7 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
AdvancePostingParametersCZZ."Document Type" := "Gen. Journal Document Type"::"Credit Memo";
AdvancePostingParametersCZZ."Document No." := DocumentNo;
AdvancePostingParametersCZZ."External Document No." := ExternalDocumentNo;
- AdvancePostingParametersCZZ."Source Code" := VATEntry."Source Code";
+ AdvancePostingParametersCZZ."Source Code" := SourceCode;
AdvancePostingParametersCZZ."Posting Description" := PurchAdvLetterHeaderCZZ."Posting Description";
AdvancePostingParametersCZZ."Posting Date" := PostingDate;
AdvancePostingParametersCZZ."Document Date" := PostingDate;
@@ -888,105 +886,16 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
procedure PostCancelUsageVAT(var PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ")
var
- PurchAdvLetterEntryCZZ2: Record "Purch. Adv. Letter Entry CZZ";
- PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ";
- AdvanceLetterTemplateCZZ: Record "Advance Letter Template CZZ";
- VATPostingSetup: Record "VAT Posting Setup";
- GenJournalLine: Record "Gen. Journal Line";
+ AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ";
GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
- VATPostingSetupHandlerCZZ: Codeunit "VAT Posting Setup Handler CZZ";
begin
- PurchAdvLetterEntryCZZ.TestField("Entry Type", PurchAdvLetterEntryCZZ."Entry Type"::"VAT Usage");
- PurchAdvLetterEntryCZZ.TestField(Cancelled, false);
-
- PurchAdvLetterHeaderCZZ.Get(PurchAdvLetterEntryCZZ."Purch. Adv. Letter No.");
- AdvanceLetterTemplateCZZ.Get(PurchAdvLetterHeaderCZZ."Advance Letter Code");
- AdvanceLetterTemplateCZZ.TestField("Advance Letter Cr. Memo Nos.");
-
- GetCurrency(PurchAdvLetterEntryCZZ."Currency Code");
-
- PurchAdvLetterEntryCZZ2.Reset();
- PurchAdvLetterEntryCZZ2.SetRange("Document No.", PurchAdvLetterEntryCZZ."Document No.");
- PurchAdvLetterEntryCZZ2.SetFilter("Entry Type", '%1|%2|%3', PurchAdvLetterEntryCZZ2."Entry Type"::"VAT Adjustment",
- PurchAdvLetterEntryCZZ2."Entry Type"::"VAT Rate", PurchAdvLetterEntryCZZ2."Entry Type"::"VAT Usage");
- PurchAdvLetterEntryCZZ2.SetRange(Cancelled, false);
- PurchAdvLetterEntryCZZ2.Find('+');
- PurchAdvLetterEntryCZZ2.SetFilter("Entry No.", '..%1', PurchAdvLetterEntryCZZ2."Entry No.");
- repeat
- case PurchAdvLetterEntryCZZ2."Entry Type" of
- PurchAdvLetterEntryCZZ2."Entry Type"::"VAT Adjustment":
- begin
- VATPostingSetup.Get(PurchAdvLetterEntryCZZ2."VAT Bus. Posting Group", PurchAdvLetterEntryCZZ2."VAT Prod. Posting Group");
- PostUnrealizedExchangeRate(PurchAdvLetterEntryCZZ2, PurchAdvLetterHeaderCZZ, VATPostingSetup, -PurchAdvLetterEntryCZZ2."Amount (LCY)", -PurchAdvLetterEntryCZZ2."VAT Amount (LCY)",
- PurchAdvLetterEntryCZZ2."Related Entry", 0, PurchAdvLetterEntryCZZ2."Document No.", PurchAdvLetterEntryCZZ2."Posting Date", PurchAdvLetterEntryCZZ2."VAT Date", '', GenJnlPostLine, true, false);
- end;
- PurchAdvLetterEntryCZZ2."Entry Type"::"VAT Rate":
- begin
- VATPostingSetup.Get(PurchAdvLetterEntryCZZ2."VAT Bus. Posting Group", PurchAdvLetterEntryCZZ2."VAT Prod. Posting Group");
- PostExchangeRate(-PurchAdvLetterEntryCZZ2."Amount (LCY)", -PurchAdvLetterEntryCZZ2."VAT Amount (LCY)", PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ2, VATPostingSetup,
- PurchAdvLetterEntryCZZ2."Document No.", PurchAdvLetterEntryCZZ2."Posting Date", PurchAdvLetterEntryCZZ2."VAT Date", '',
- '', PurchAdvLetterEntryCZZ2."Related Entry", true, GenJnlPostLine, false);
- end;
- PurchAdvLetterEntryCZZ2."Entry Type"::"VAT Usage":
- begin
- VATPostingSetup.Get(PurchAdvLetterEntryCZZ2."VAT Bus. Posting Group", PurchAdvLetterEntryCZZ2."VAT Prod. Posting Group");
- InitGenJnlLineFromAdvance(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ2, PurchAdvLetterEntryCZZ2."Document No.", PurchAdvLetterEntryCZZ2."External Document No.",
- '', '', GenJournalLine);
- GenJournalLine.Validate("Posting Date", PurchAdvLetterEntryCZZ2."Posting Date");
- GenJournalLine.Validate("VAT Reporting Date", PurchAdvLetterEntryCZZ2."VAT Date");
- GenJournalLine.Validate("Original Doc. VAT Date CZL", PurchAdvLetterEntryCZZ2."Original Document VAT Date");
- GenJournalLine."Account No." := VATPostingSetup."Purch. Adv. Letter Account CZZ";
- GenJournalLine.SetCurrencyFactor(PurchAdvLetterEntryCZZ2."Currency Code", PurchAdvLetterEntryCZZ2."Currency Factor");
- GenJournalLine."Gen. Posting Type" := GenJournalLine."Gen. Posting Type"::Purchase;
- GenJournalLine."VAT Calculation Type" := PurchAdvLetterEntryCZZ2."VAT Calculation Type";
- GenJournalLine."VAT Bus. Posting Group" := PurchAdvLetterEntryCZZ2."VAT Bus. Posting Group";
- GenJournalLine.Validate("VAT Prod. Posting Group", PurchAdvLetterEntryCZZ2."VAT Prod. Posting Group");
- GenJournalLine.Correction := true;
- GenJournalLine.Validate(Amount, -PurchAdvLetterEntryCZZ2.Amount);
- GenJournalLine."VAT Amount" := -PurchAdvLetterEntryCZZ2."VAT Amount";
- GenJournalLine."VAT Base Amount" := GenJournalLine.Amount - GenJournalLine."VAT Amount";
- GenJournalLine."VAT Difference" := GenJournalLine."VAT Amount" - Round(GenJournalLine.Amount * GenJournalLine."VAT %" / (100 + GenJournalLine."VAT %"),
- CurrencyGlob."Amount Rounding Precision", CurrencyGlob.VATRoundingDirection());
- if GenJournalLine."Currency Code" = '' then begin
- GenJournalLine."Amount (LCY)" := GenJournalLine.Amount;
- GenJournalLine."VAT Amount (LCY)" := GenJournalLine."VAT Amount";
- GenJournalLine."VAT Base Amount (LCY)" := GenJournalLine."VAT Base Amount";
- end else begin
- GenJournalLine."Amount (LCY)" := -PurchAdvLetterEntryCZZ2."Amount (LCY)";
- GenJournalLine."VAT Amount (LCY)" := -PurchAdvLetterEntryCZZ2."VAT Amount (LCY)";
- GenJournalLine."VAT Base Amount (LCY)" := GenJournalLine."Amount (LCY)" - GenJournalLine."VAT Amount (LCY)";
- end;
- BindSubscription(VATPostingSetupHandlerCZZ);
- GenJnlPostLine.RunWithCheck(GenJournalLine);
- UnbindSubscription(VATPostingSetupHandlerCZZ);
-
- AdvEntryInit(false);
- AdvEntryInitRelatedEntry(PurchAdvLetterEntryCZZ2."Related Entry");
- AdvEntryInitCancel();
- AdvEntryInitVAT(GenJournalLine."VAT Bus. Posting Group", GenJournalLine."VAT Prod. Posting Group",
- GenJournalLine."VAT Reporting Date", GenJournalLine."Original Doc. VAT Date CZL",
- GenJnlPostLine.GetNextVATEntryNo() - 1, GenJournalLine."VAT %", VATPostingSetup."VAT Identifier", GenJournalLine."VAT Calculation Type",
- GenJournalLine."VAT Amount", GenJournalLine."VAT Amount (LCY)", GenJournalLine."VAT Base Amount", GenJournalLine."VAT Base Amount (LCY)");
- AdvEntryInsert("Advance Letter Entry Type CZZ"::"VAT Usage", PurchAdvLetterEntryCZZ2."Purch. Adv. Letter No.", GenJournalLine."Posting Date",
- GenJournalLine.Amount, GenJournalLine."Amount (LCY)",
- GenJournalLine."Currency Code", GenJournalLine."Currency Factor", GenJournalLine."Document No.", GenJournalLine."External Document No.",
- GenJournalLine."Shortcut Dimension 1 Code", GenJournalLine."Shortcut Dimension 2 Code", GenJournalLine."Dimension Set ID", false);
-
- InitGenJnlLineFromAdvance(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ2, PurchAdvLetterEntryCZZ2."Document No.", PurchAdvLetterEntryCZZ2."External Document No.", '', '', GenJournalLine);
- GenJournalLine.Validate("Posting Date", PurchAdvLetterEntryCZZ2."Posting Date");
- GenJournalLine.Validate("VAT Reporting Date", PurchAdvLetterEntryCZZ2."VAT Date");
- GenJournalLine.Validate("Original Doc. VAT Date CZL", PurchAdvLetterEntryCZZ2."Original Document VAT Date");
- GenJournalLine."Account No." := VATPostingSetup."Purch. Adv. Letter Account CZZ";
- GenJournalLine.SetCurrencyFactor(PurchAdvLetterEntryCZZ2."Currency Code", PurchAdvLetterEntryCZZ2."Currency Factor");
- GenJournalLine.Correction := true;
- GenJournalLine.Validate(Amount, PurchAdvLetterEntryCZZ2.Amount);
- GenJnlPostLine.RunWithCheck(GenJournalLine);
- end;
- end;
- until PurchAdvLetterEntryCZZ2.Next(-1) = 0;
+ Clear(AdvancePostingParametersCZZ);
+ AdvancePostingParametersCZZ."Document No." := PurchAdvLetterEntryCZZ."Document No.";
+ AdvancePostingParametersCZZ."Posting Date" := PurchAdvLetterEntryCZZ."Posting Date";
+ AdvancePostingParametersCZZ."VAT Date" := PurchAdvLetterEntryCZZ."VAT Date";
+ AdvancePostingParametersCZZ."Original Document VAT Date" := PurchAdvLetterEntryCZZ."Original Document VAT Date";
- PurchAdvLetterEntryCZZ2.ModifyAll(Cancelled, true);
- PurchAdvLetterHeaderCZZ.UpdateStatus(PurchAdvLetterHeaderCZZ.Status::"To Use");
+ PurchAdvLetterPostCZZ.PostAdvancePaymentUsageVATCancellation(PurchAdvLetterEntryCZZ, GenJnlPostLine, AdvancePostingParametersCZZ);
end;
procedure PostAdvancePaymentUsagePreview(var PurchaseHeader: Record "Purchase Header"; Amount: Decimal; AmountLCY: Decimal; var PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ")
@@ -1190,7 +1099,7 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
repeat
VATPostingSetup.Get(TempAdvancePostingBufferCZZ2."VAT Bus. Posting Group", TempAdvancePostingBufferCZZ2."VAT Prod. Posting Group");
PostUnrealizedExchangeRate(PurchAdvLetterEntryCZZ, PurchAdvLetterHeaderCZZ, VATPostingSetup, TempAdvancePostingBufferCZZ2.Amount, TempAdvancePostingBufferCZZ2."VAT Amount",
- PurchAdvLetterEntryCZZ."Entry No.", DetEntryNo, DocumentNo, ToDate, ToDate, PostDescription, GenJnlPostLine, false, false);
+ PurchAdvLetterEntryCZZ."Entry No.", DetEntryNo, DocumentNo, ToDate, ToDate, PostDescription, GenJnlPostLine, false, false, TempAdvancePostingBufferCZZ2."Auxiliary Entry");
until TempAdvancePostingBufferCZZ2.Next() = 0;
PurchAdvLetterPostCZZ.BufferAdvanceVATLines(PurchAdvLetterEntryCZZ, TempAdvancePostingBufferCZZ1, 0D);
@@ -1246,7 +1155,8 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
VATPostingSetup.Get(PurchAdvLetterEntryCZZ3."VAT Bus. Posting Group", PurchAdvLetterEntryCZZ3."VAT Prod. Posting Group");
PostUnrealizedExchangeRate(PurchAdvLetterEntryCZZ, PurchAdvLetterHeaderCZZ, VATPostingSetup, -AmountToPost, -VATAmountToPost,
- PurchAdvLetterEntryCZZ2."Entry No.", 0, DocumentNo, PurchAdvLetterEntryCZZ3."Posting Date", PurchAdvLetterEntryCZZ3."VAT Date", PostDescription, GenJnlPostLine, false, false);
+ PurchAdvLetterEntryCZZ2."Entry No.", 0, DocumentNo, PurchAdvLetterEntryCZZ3."Posting Date", PurchAdvLetterEntryCZZ3."VAT Date",
+ PostDescription, GenJnlPostLine, false, false, PurchAdvLetterEntryCZZ3."Auxiliary Entry");
until PurchAdvLetterEntryCZZ3.Next() = 0;
until PurchAdvLetterEntryCZZ2.Next() = 0;
end;
@@ -1255,7 +1165,7 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
local procedure PostUnrealizedExchangeRate(var PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ"; var PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ"; var VATPostingSetup: Record "VAT Posting Setup";
Amount: Decimal; VATAmount: Decimal; RelatedEntryNo: Integer; RelatedDetEntryNo: Integer; DocumentNo: Code[20]; PostingDate: Date; VATDate: Date; PostDescription: Text[100]; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
- Correction: Boolean; Preview: Boolean)
+ Correction: Boolean; Preview: Boolean; AuxiliaryEntry: Boolean)
var
AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ";
begin
@@ -1267,21 +1177,23 @@ codeunit 31019 "PurchAdvLetterManagement CZZ"
AdvancePostingParametersCZZ."Temporary Entries Only" := Preview;
PurchAdvLetterPostCZZ.PostUnrealizedExchangeRate(
- PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, VATPostingSetup, Amount, VATAmount, RelatedEntryNo, RelatedDetEntryNo, Correction, GenJnlPostLine, AdvancePostingParametersCZZ);
+ PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, VATPostingSetup, Amount, VATAmount,
+ RelatedEntryNo, RelatedDetEntryNo, Correction, AuxiliaryEntry, GenJnlPostLine, AdvancePostingParametersCZZ);
end;
- local procedure GetPostingDateUI(DefaultPostingDate: Date): Date
+ local procedure GetPostingDateUI(var PostingDate: Date): Boolean
var
GetPostingDateCZZ: Page "Get Posting Date CZZ";
- PostingDate: Date;
begin
if not GuiAllowed() then
- exit(DefaultPostingDate);
+ exit(true);
+
+ GetPostingDateCZZ.SetValues(PostingDate);
+ if GetPostingDateCZZ.RunModal() <> Action::OK then
+ exit(false);
- GetPostingDateCZZ.SetValues(DefaultPostingDate);
- if GetPostingDateCZZ.RunModal() = Action::OK then
- GetPostingDateCZZ.GetValues(PostingDate);
- exit(PostingDate);
+ GetPostingDateCZZ.GetValues(PostingDate);
+ exit(true);
end;
#if not CLEAN24
#pragma warning disable AL0432
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/PurchAdvLetterPostCZZ.Codeunit.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/PurchAdvLetterPostCZZ.Codeunit.al
index 102b7f2939..d6ee9a42a3 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/PurchAdvLetterPostCZZ.Codeunit.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/PurchAdvLetterPostCZZ.Codeunit.al
@@ -262,7 +262,7 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ";
VATPostingSetup: Record "VAT Posting Setup";
VendorLedgerEntry: Record "Vendor Ledger Entry";
- GLEntryNo: Integer;
+ GLEntryNo, VATEntryNo : Integer;
IsHandled: Boolean;
begin
IsHandled := false;
@@ -305,55 +305,60 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
AdvancePostingParametersCZZ."Source Code" := VendorLedgerEntry."Source Code";
end;
- AdvancePostingBufferCZZ.FindSet();
- repeat
- VATPostingSetup.Get(AdvancePostingBufferCZZ."VAT Bus. Posting Group", AdvancePostingBufferCZZ."VAT Prod. Posting Group");
-
- // Post VAT amount and VAT base of VAT document
- InitGenJournalLine(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingParametersCZZ, GenJournalLine);
- GenJournalLine."Account No." := VATPostingSetup.GetPurchAdvLetterAccountCZZ();
- GenJournalLine."Gen. Posting Type" := GenJournalLine."Gen. Posting Type"::Purchase;
- GenJournalLine.CopyFromAdvancePostingBufferCZZ(AdvancePostingBufferCZZ);
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
- OnPostAdvancePaymentVATOnBeforePost(
- PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
- AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
+ if AdvancePostingBufferCZZ.FindSet() then
+ repeat
+ GLEntryNo := 0;
+ VATEntryNo := 0;
+
+ VATPostingSetup.Get(AdvancePostingBufferCZZ."VAT Bus. Posting Group", AdvancePostingBufferCZZ."VAT Prod. Posting Group");
+
+ // Post VAT amount and VAT base of VAT document
+ InitGenJournalLine(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingParametersCZZ, GenJournalLine);
+ GenJournalLine."Account No." := VATPostingSetup.GetPurchAdvLetterAccountCZZ();
+ GenJournalLine."Gen. Posting Type" := GenJournalLine."Gen. Posting Type"::Purchase;
+ GenJournalLine.CopyFromAdvancePostingBufferCZZ(AdvancePostingBufferCZZ);
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
+ OnPostAdvancePaymentVATOnBeforePost(
+ PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
+ AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
#if not CLEAN24
- RaiseOnPostAdvancePaymentVATOnBeforeGenJnlPostLine(
- PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, GenJournalLine);
+ RaiseOnPostAdvancePaymentVATOnBeforeGenJnlPostLine(
+ PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, GenJournalLine);
#endif
- GLEntryNo := RunGenJnlPostLine(GenJournalLine, GenJnlPostLine, true, true, false);
- OnPostAdvancePaymentVATOnAfterPost(
- PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
- AdvancePostingParametersCZZ, GLEntryNo, GenJnlPostLine, GenJournalLine);
- end;
-
- TempPurchAdvLetterEntryCZZGlob.InitNewEntry();
- TempPurchAdvLetterEntryCZZGlob.InitRelatedEntry(PurchAdvLetterEntryCZZ);
- TempPurchAdvLetterEntryCZZGlob.CopyFromGenJnlLine(GenJournalLine);
- TempPurchAdvLetterEntryCZZGlob."Entry Type" := "Advance Letter Entry Type CZZ"::"VAT Payment";
- TempPurchAdvLetterEntryCZZGlob."Purch. Adv. Letter No." := PurchAdvLetterHeaderCZZ."No.";
- TempPurchAdvLetterEntryCZZGlob."VAT Entry No." := GenJnlPostLine.GetNextVATEntryNo() - 1;
- TempPurchAdvLetterEntryCZZGlob."VAT Identifier" := VATPostingSetup."VAT Identifier";
- TempPurchAdvLetterEntryCZZGlob.InsertNewEntry(not AdvancePostingParametersCZZ."Temporary Entries Only");
+ GLEntryNo := RunGenJnlPostLine(GenJournalLine, GenJnlPostLine, true, true, false);
+ VATEntryNo := GenJnlPostLine.GetNextVATEntryNo() - 1;
+ OnPostAdvancePaymentVATOnAfterPost(
+ PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
+ AdvancePostingParametersCZZ, GLEntryNo, GenJnlPostLine, GenJournalLine);
+ end;
- // Post balance of VAT document
- AdvancePostingParametersCZZ2.InitNew(AdvancePostingParametersCZZ);
- AdvancePostingParametersCZZ2."Document Type" := "Gen. Journal Document Type"::" ";
- InitGenJournalLine(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingParametersCZZ2, GenJournalLine);
- GenJournalLine."Account No." := VATPostingSetup.GetPurchAdvLetterAccountCZZ();
- AdvancePostingBufferCZZ.ReverseAmounts();
- GenJournalLine.CopyFromAdvancePostingBufferAmountsCZZ(AdvancePostingBufferCZZ);
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
- OnPostAdvancePaymentVATOnBeforePostBalance(
- PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
- AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
- GLEntryNo := RunGenJnlPostLine(GenJournalLine, GenJnlPostLine, false, false, false);
- OnPostAdvancePaymentVATOnAfterPostBalance(
- PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
- AdvancePostingParametersCZZ, GLEntryNo, GenJnlPostLine, GenJournalLine);
- end;
- until AdvancePostingBufferCZZ.Next() = 0;
+ TempPurchAdvLetterEntryCZZGlob.InitNewEntry();
+ TempPurchAdvLetterEntryCZZGlob.InitRelatedEntry(PurchAdvLetterEntryCZZ);
+ TempPurchAdvLetterEntryCZZGlob.CopyFromGenJnlLine(GenJournalLine);
+ TempPurchAdvLetterEntryCZZGlob."Entry Type" := "Advance Letter Entry Type CZZ"::"VAT Payment";
+ TempPurchAdvLetterEntryCZZGlob."Purch. Adv. Letter No." := PurchAdvLetterHeaderCZZ."No.";
+ TempPurchAdvLetterEntryCZZGlob."VAT Entry No." := VATEntryNo;
+ TempPurchAdvLetterEntryCZZGlob."VAT Identifier" := VATPostingSetup."VAT Identifier";
+ TempPurchAdvLetterEntryCZZGlob."Auxiliary Entry" := AdvancePostingBufferCZZ."Auxiliary Entry";
+ TempPurchAdvLetterEntryCZZGlob.InsertNewEntry(not AdvancePostingParametersCZZ."Temporary Entries Only");
+
+ // Post balance of VAT document
+ AdvancePostingParametersCZZ2.InitNew(AdvancePostingParametersCZZ);
+ AdvancePostingParametersCZZ2."Document Type" := "Gen. Journal Document Type"::" ";
+ InitGenJournalLine(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingParametersCZZ2, GenJournalLine);
+ GenJournalLine."Account No." := VATPostingSetup.GetPurchAdvLetterAccountCZZ();
+ AdvancePostingBufferCZZ.ReverseAmounts();
+ GenJournalLine.CopyFromAdvancePostingBufferAmountsCZZ(AdvancePostingBufferCZZ);
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
+ OnPostAdvancePaymentVATOnBeforePostBalance(
+ PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
+ AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
+ GLEntryNo := RunGenJnlPostLine(GenJournalLine, GenJnlPostLine, false, false, false);
+ OnPostAdvancePaymentVATOnAfterPostBalance(
+ PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
+ AdvancePostingParametersCZZ, GLEntryNo, GenJnlPostLine, GenJournalLine);
+ end;
+ until AdvancePostingBufferCZZ.Next() = 0;
OnAfterPostAdvancePaymentVAT(
PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
@@ -370,7 +375,7 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
AdvancePostingParametersCZZ2: Record "Advance Posting Parameters CZZ";
VATPostingSetup: Record "VAT Posting Setup";
GenJournalLine: Record "Gen. Journal Line";
- EntryNo, GLEntryNo : Integer;
+ EntryNo, GLEntryNo, VATEntryNo : Integer;
IsHandled: Boolean;
begin
IsHandled := false;
@@ -385,17 +390,21 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
VATPostingSetup.Get(AdvancePostingBufferCZZ."VAT Bus. Posting Group", AdvancePostingBufferCZZ."VAT Prod. Posting Group");
+ GLEntryNo := 0;
+ VATEntryNo := 0;
+
// Post advance payment VAT unlinking
InitGenJournalLine(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingParametersCZZ, GenJournalLine);
GenJournalLine."Account No." := VATPostingSetup.GetPurchAdvLetterAccountCZZ();
GenJournalLine."Gen. Posting Type" := GenJournalLine."Gen. Posting Type"::Purchase;
AdvancePostingBufferCZZ.ReverseAmounts();
GenJournalLine.CopyFromAdvancePostingBufferCZZ(AdvancePostingBufferCZZ);
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
OnPostAdvancePaymentVATUnlinkingOnBeforePost(
PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, VATPostingSetup,
AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
GLEntryNo := RunGenJnlPostLine(GenJournalLine, GenJnlPostLine, true, true, false);
+ VATEntryNo := GenJnlPostLine.GetNextVATEntryNo() - 1;
OnPostAdvancePaymentVATUnlinkingOnAfterPost(
PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, VATPostingSetup,
AdvancePostingParametersCZZ, GLEntryNo, GenJnlPostLine, GenJournalLine);
@@ -406,8 +415,9 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
TempPurchAdvLetterEntryCZZGlob.CopyFromGenJnlLine(GenJournalLine);
TempPurchAdvLetterEntryCZZGlob."Entry Type" := "Advance Letter Entry Type CZZ"::"VAT Payment";
TempPurchAdvLetterEntryCZZGlob."Purch. Adv. Letter No." := PurchAdvLetterHeaderCZZ."No.";
- TempPurchAdvLetterEntryCZZGlob."VAT Entry No." := GenJnlPostLine.GetNextVATEntryNo() - 1;
+ TempPurchAdvLetterEntryCZZGlob."VAT Entry No." := VATEntryNo;
TempPurchAdvLetterEntryCZZGlob."VAT Identifier" := VATPostingSetup."VAT Identifier";
+ TempPurchAdvLetterEntryCZZGlob."Auxiliary Entry" := AdvancePostingBufferCZZ."Auxiliary Entry";
TempPurchAdvLetterEntryCZZGlob.Cancelled := true;
EntryNo := TempPurchAdvLetterEntryCZZGlob.InsertNewEntry(not AdvancePostingParametersCZZ."Temporary Entries Only");
@@ -418,7 +428,7 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
InitGenJournalLine(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingParametersCZZ2, GenJournalLine);
GenJournalLine."Account No." := VATPostingSetup.GetPurchAdvLetterAccountCZZ();
GenJournalLine.CopyFromAdvancePostingBufferAmountsCZZ(AdvancePostingBufferCZZ);
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
OnPostAdvancePaymentVATUnlinkingOnBeforePostBalance(
PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
@@ -577,7 +587,7 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ")
var
- PurchAdvLetterEntryCZZ2: Record "Purch. Adv. Letter Entry CZZ";
+ RelatedPurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ";
IsHandled: Boolean;
begin
IsHandled := false;
@@ -590,18 +600,130 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
exit;
PurchAdvLetterEntryCZZ.TestField(Cancelled, false);
- PurchAdvLetterEntryCZZ2.Get(PurchAdvLetterEntryCZZ."Related Entry");
- if PurchAdvLetterEntryCZZ2."Entry Type" <> PurchAdvLetterEntryCZZ2."Entry Type"::Payment then
+ RelatedPurchAdvLetterEntryCZZ.Get(PurchAdvLetterEntryCZZ."Related Entry");
+ if RelatedPurchAdvLetterEntryCZZ."Entry Type" <> RelatedPurchAdvLetterEntryCZZ."Entry Type"::Payment then
exit;
ReverseAdvancePaymentVAT(
- PurchAdvLetterEntryCZZ2, AdvancePostingBufferCZZ, PurchAdvLetterEntryCZZ."Entry No.",
+ RelatedPurchAdvLetterEntryCZZ, AdvancePostingBufferCZZ, PurchAdvLetterEntryCZZ."Entry No.",
"Advance Letter Entry Type CZZ"::"VAT Usage", GenJnlPostLine, AdvancePostingParametersCZZ);
OnAfterPostAdvancePaymentUsageVAT(
PurchAdvLetterEntryCZZ, AdvancePostingBufferCZZ, GenJnlPostLine, AdvancePostingParametersCZZ);
end;
+ procedure PostAdvancePaymentUsageVATCancellation(
+ var PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ";
+ var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
+ AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ")
+ var
+ AdvancePostingBufferCZZ: Record "Advance Posting Buffer CZZ";
+ AdvancePostingParametersCZZ2: Record "Advance Posting Parameters CZZ";
+ PurchAdvLetterEntryCZZ2: Record "Purch. Adv. Letter Entry CZZ";
+ PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ";
+ VATPostingSetup: Record "VAT Posting Setup";
+ GenJournalLine: Record "Gen. Journal Line";
+ GLEntryNo, VATEntryNo : Integer;
+ IsHandled: Boolean;
+ begin
+ IsHandled := false;
+ OnBeforePostAdvancePaymentUsageVATCancellation(
+ PurchAdvLetterEntryCZZ, GenJnlPostLine, AdvancePostingParametersCZZ, IsHandled);
+ if IsHandled then
+ exit;
+
+ PurchAdvLetterEntryCZZ.TestField("Entry Type", PurchAdvLetterEntryCZZ."Entry Type"::"VAT Usage");
+ PurchAdvLetterEntryCZZ.TestField(Cancelled, false);
+
+ PurchAdvLetterHeaderCZZ.Get(PurchAdvLetterEntryCZZ."Purch. Adv. Letter No.");
+
+ PurchAdvLetterEntryCZZ2.Reset();
+ PurchAdvLetterEntryCZZ2.SetRange("Document No.", PurchAdvLetterEntryCZZ."Document No.");
+ PurchAdvLetterEntryCZZ2.SetFilter("Entry Type", '%1|%2|%3',
+ PurchAdvLetterEntryCZZ2."Entry Type"::"VAT Adjustment",
+ PurchAdvLetterEntryCZZ2."Entry Type"::"VAT Rate",
+ PurchAdvLetterEntryCZZ2."Entry Type"::"VAT Usage");
+ PurchAdvLetterEntryCZZ2.SetRange(Cancelled, false);
+ PurchAdvLetterEntryCZZ2.Find('+');
+ PurchAdvLetterEntryCZZ2.SetFilter("Entry No.", '..%1', PurchAdvLetterEntryCZZ2."Entry No.");
+ VATPostingSetup.Get(PurchAdvLetterEntryCZZ2."VAT Bus. Posting Group", PurchAdvLetterEntryCZZ2."VAT Prod. Posting Group");
+ repeat
+ case PurchAdvLetterEntryCZZ2."Entry Type" of
+ PurchAdvLetterEntryCZZ2."Entry Type"::"VAT Adjustment":
+ PostUnrealizedExchangeRate(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ2, VATPostingSetup,
+ -PurchAdvLetterEntryCZZ2."Amount (LCY)", -PurchAdvLetterEntryCZZ2."VAT Amount (LCY)",
+ PurchAdvLetterEntryCZZ2."Related Entry", 0, true, PurchAdvLetterEntryCZZ2."Auxiliary Entry",
+ GenJnlPostLine, AdvancePostingParametersCZZ);
+ PurchAdvLetterEntryCZZ2."Entry Type"::"VAT Rate":
+ PostExchangeRate(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ2, VATPostingSetup,
+ -PurchAdvLetterEntryCZZ2."Amount (LCY)", -PurchAdvLetterEntryCZZ2."VAT Amount (LCY)",
+ PurchAdvLetterEntryCZZ2."Related Entry", true, PurchAdvLetterEntryCZZ2."Auxiliary Entry",
+ GenJnlPostLine, AdvancePostingParametersCZZ);
+ PurchAdvLetterEntryCZZ2."Entry Type"::"VAT Usage":
+ begin
+ AdvancePostingParametersCZZ2.InitNew(AdvancePostingParametersCZZ);
+ AdvancePostingParametersCZZ2."Currency Code" := PurchAdvLetterEntryCZZ2."Currency Code";
+ AdvancePostingParametersCZZ2."Currency Factor" := PurchAdvLetterEntryCZZ2."Currency Factor";
+
+ AdvancePostingBufferCZZ.PrepareForPurchAdvLetterEntry(PurchAdvLetterEntryCZZ2);
+
+ // Post advance payment VAT cancellation
+ InitGenJournalLine(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ2, AdvancePostingParametersCZZ2, GenJournalLine);
+ GenJournalLine."Account No." := VATPostingSetup.GetPurchAdvLetterAccountCZZ();
+ GenJournalLine."Gen. Posting Type" := GenJournalLine."Gen. Posting Type"::Purchase;
+ GenJournalLine.Correction := true;
+ AdvancePostingBufferCZZ.ReverseAmounts();
+ GenJournalLine.CopyFromAdvancePostingBufferCZZ(AdvancePostingBufferCZZ);
+ if not AdvancePostingParametersCZZ2."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
+ OnPostAdvancePaymentUsageVATCancellationOnBeforePost(
+ PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ2, AdvancePostingBufferCZZ,
+ AdvancePostingParametersCZZ2, GenJnlPostLine, GenJournalLine);
+ GLEntryNo := RunGenJnlPostLine(GenJournalLine, GenJnlPostLine, true, false, false);
+ VATEntryNo := GenJnlPostLine.GetNextVATEntryNo() - 1;
+ OnPostAdvancePaymentUsageVATCancellationOnAfterPost(
+ PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ2, AdvancePostingBufferCZZ,
+ AdvancePostingParametersCZZ2, GLEntryNo, GenJnlPostLine, GenJournalLine);
+ end;
+
+ TempPurchAdvLetterEntryCZZGlob.InitNewEntry();
+ TempPurchAdvLetterEntryCZZGlob.InitRelatedEntry(PurchAdvLetterEntryCZZ2."Related Entry");
+ TempPurchAdvLetterEntryCZZGlob.CopyFromGenJnlLine(GenJournalLine);
+ TempPurchAdvLetterEntryCZZGlob."Entry Type" := "Advance Letter Entry Type CZZ"::"VAT Usage";
+ TempPurchAdvLetterEntryCZZGlob."Purch. Adv. Letter No." := PurchAdvLetterHeaderCZZ."No.";
+ TempPurchAdvLetterEntryCZZGlob."VAT Entry No." := VATEntryNo;
+ TempPurchAdvLetterEntryCZZGlob."VAT Identifier" := VATPostingSetup."VAT Identifier";
+ TempPurchAdvLetterEntryCZZGlob."Auxiliary Entry" := PurchAdvLetterEntryCZZ2."Auxiliary Entry";
+ TempPurchAdvLetterEntryCZZGlob.Cancelled := true;
+ TempPurchAdvLetterEntryCZZGlob.InsertNewEntry(true);
+
+ // Post balance of advance payment VAT cancellation
+ AdvancePostingBufferCZZ.ReverseAmounts();
+ InitGenJournalLine(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingParametersCZZ2, GenJournalLine);
+ GenJournalLine."Account No." := VATPostingSetup.GetPurchAdvLetterAccountCZZ();
+ GenJournalLine.Correction := true;
+ GenJournalLine.CopyFromAdvancePostingBufferAmountsCZZ(AdvancePostingBufferCZZ);
+ if not AdvancePostingParametersCZZ2."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
+ OnPostAdvancePaymentUsageVATCancellationOnBeforePostBalance(
+ PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ2, AdvancePostingBufferCZZ,
+ AdvancePostingParametersCZZ2, GenJnlPostLine, GenJournalLine);
+ GLEntryNo := RunGenJnlPostLine(GenJournalLine, GenJnlPostLine, false, false, false);
+ OnPostAdvancePaymentUsageVATCancellationOnAfterPostBalance(
+ PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ2, AdvancePostingBufferCZZ,
+ AdvancePostingParametersCZZ2, GLEntryNo, GenJnlPostLine, GenJournalLine);
+ end;
+ end;
+ end;
+ until PurchAdvLetterEntryCZZ2.Next(-1) = 0;
+
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
+ PurchAdvLetterEntryCZZ2.ModifyAll(Cancelled, true);
+ PurchAdvLetterHeaderCZZ.UpdateStatus(PurchAdvLetterHeaderCZZ.Status::"To Use");
+ end;
+
+ OnAfterPostAdvancePaymentUsageVATCancellation(
+ PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, GenJnlPostLine, AdvancePostingParametersCZZ);
+ end;
+
procedure PostAdvanceCreditMemoVAT(
var PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ";
var AdvancePostingBufferCZZ: Record "Advance Posting Buffer CZZ";
@@ -610,13 +732,13 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
var
AdvancePostingParametersCZZ2: Record "Advance Posting Parameters CZZ";
GenJournalLine: Record "Gen. Journal Line";
- PurchAdvLetterEntryCZZ2: Record "Purch. Adv. Letter Entry CZZ";
- PurchAdvLetterEntryCZZ3: Record "Purch. Adv. Letter Entry CZZ";
+ RelatedPurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ";
+ VATDocumentPurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ";
PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ";
TempAdvancePostingBufferCZZ: Record "Advance Posting Buffer CZZ" temporary;
VATPostingSetup: Record "VAT Posting Setup";
ExchRateAmount, ExchRateVATAmount : Decimal;
- GLEntryNo: Integer;
+ GLEntryNo, VATEntryNo : Integer;
IsHandled: Boolean;
begin
IsHandled := false;
@@ -635,12 +757,15 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
Error(NothingToPostErr);
if PurchAdvLetterEntryCZZ."Currency Code" <> '' then begin
- PurchAdvLetterEntryCZZ2.Get(PurchAdvLetterEntryCZZ."Related Entry");
- BufferAdvanceVATLines(PurchAdvLetterEntryCZZ2, TempAdvancePostingBufferCZZ, 0D);
+ RelatedPurchAdvLetterEntryCZZ.Get(PurchAdvLetterEntryCZZ."Related Entry");
+ BufferAdvanceVATLines(RelatedPurchAdvLetterEntryCZZ, TempAdvancePostingBufferCZZ, 0D);
end;
AdvancePostingBufferCZZ.FindSet();
repeat
+ GLEntryNo := 0;
+ VATEntryNo := 0;
+
VATPostingSetup.Get(AdvancePostingBufferCZZ."VAT Bus. Posting Group", AdvancePostingBufferCZZ."VAT Prod. Posting Group");
// Post credit memo VAT
@@ -649,11 +774,12 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
GenJournalLine."Gen. Posting Type" := GenJournalLine."Gen. Posting Type"::Purchase;
AdvancePostingBufferCZZ.ReverseAmounts();
GenJournalLine.CopyFromAdvancePostingBufferCZZ(AdvancePostingBufferCZZ);
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
OnPostAdvanceCreditMemoVATOnBeforePost(
PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
GLEntryNo := RunGenJnlPostLine(GenJournalLine, GenJnlPostLine, true, true, false);
+ VATEntryNo := GenJnlPostLine.GetNextVATEntryNo() - 1;
OnPostAdvanceCreditMemoVATOnAfterPost(
PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
AdvancePostingParametersCZZ, GLEntryNo, GenJnlPostLine, GenJournalLine);
@@ -664,8 +790,9 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
TempPurchAdvLetterEntryCZZGlob.CopyFromGenJnlLine(GenJournalLine);
TempPurchAdvLetterEntryCZZGlob."Entry Type" := "Advance Letter Entry Type CZZ"::"VAT Payment";
TempPurchAdvLetterEntryCZZGlob."Purch. Adv. Letter No." := PurchAdvLetterHeaderCZZ."No.";
- TempPurchAdvLetterEntryCZZGlob."VAT Entry No." := GenJnlPostLine.GetNextVATEntryNo() - 1;
+ TempPurchAdvLetterEntryCZZGlob."VAT Entry No." := VATEntryNo;
TempPurchAdvLetterEntryCZZGlob."VAT Identifier" := VATPostingSetup."VAT Identifier";
+ TempPurchAdvLetterEntryCZZGlob."Auxiliary Entry" := AdvancePostingBufferCZZ."Auxiliary Entry";
TempPurchAdvLetterEntryCZZGlob.Cancelled := true;
TempPurchAdvLetterEntryCZZGlob.InsertNewEntry(not AdvancePostingParametersCZZ."Temporary Entries Only");
@@ -682,25 +809,27 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
AdvancePostingParametersCZZ2."Currency Code" := '';
AdvancePostingParametersCZZ2."Currency Factor" := 0;
- PurchAdvLetterEntryCZZ3.Reset();
- PurchAdvLetterEntryCZZ3.SetRange("Purch. Adv. Letter No.", PurchAdvLetterEntryCZZ."Purch. Adv. Letter No.");
- PurchAdvLetterEntryCZZ3.SetRange("Document No.", PurchAdvLetterEntryCZZ."Document No.");
- PurchAdvLetterEntryCZZ3.SetRange("Entry Type", "Advance Letter Entry Type CZZ"::"VAT Payment");
- PurchAdvLetterEntryCZZ3.SetRange("VAT Bus. Posting Group", AdvancePostingBufferCZZ."VAT Bus. Posting Group");
- PurchAdvLetterEntryCZZ3.SetRange("VAT Prod. Posting Group", AdvancePostingBufferCZZ."VAT Prod. Posting Group");
- PurchAdvLetterEntryCZZ3.SetRange(Cancelled, false);
- PurchAdvLetterEntryCZZ3.CalcSums("Amount (LCY)", "VAT Amount (LCY)");
-
- ExchRateAmount := PurchAdvLetterEntryCZZ3."Amount (LCY)" + GenJournalLine."Amount (LCY)";
- ExchRateVATAmount := PurchAdvLetterEntryCZZ3."VAT Amount (LCY)" + GenJournalLine."VAT Amount (LCY)";
+ VATDocumentPurchAdvLetterEntryCZZ.Reset();
+ VATDocumentPurchAdvLetterEntryCZZ.SetRange("Purch. Adv. Letter No.", PurchAdvLetterEntryCZZ."Purch. Adv. Letter No.");
+ VATDocumentPurchAdvLetterEntryCZZ.SetRange("Document No.", PurchAdvLetterEntryCZZ."Document No.");
+ VATDocumentPurchAdvLetterEntryCZZ.SetRange("Entry Type", "Advance Letter Entry Type CZZ"::"VAT Payment");
+ VATDocumentPurchAdvLetterEntryCZZ.SetRange("VAT Bus. Posting Group", AdvancePostingBufferCZZ."VAT Bus. Posting Group");
+ VATDocumentPurchAdvLetterEntryCZZ.SetRange("VAT Prod. Posting Group", AdvancePostingBufferCZZ."VAT Prod. Posting Group");
+ VATDocumentPurchAdvLetterEntryCZZ.SetRange(Cancelled, false);
+ VATDocumentPurchAdvLetterEntryCZZ.CalcSums("Amount (LCY)", "VAT Amount (LCY)");
+
+ ExchRateAmount := VATDocumentPurchAdvLetterEntryCZZ."Amount (LCY)" + GenJournalLine."Amount (LCY)";
+ ExchRateVATAmount := VATDocumentPurchAdvLetterEntryCZZ."VAT Amount (LCY)" + GenJournalLine."VAT Amount (LCY)";
if (ExchRateAmount <> 0) or (ExchRateVATAmount <> 0) then
- PostExchangeRate(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, VATPostingSetup, -ExchRateAmount, -ExchRateVATAmount,
- PurchAdvLetterEntryCZZ."Related Entry", true, GenJnlPostLine, AdvancePostingParametersCZZ2);
+ PostExchangeRate(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, VATPostingSetup,
+ -ExchRateAmount, -ExchRateVATAmount, PurchAdvLetterEntryCZZ."Related Entry",
+ true, AdvancePostingBufferCZZ."Auxiliary Entry", GenJnlPostLine, AdvancePostingParametersCZZ2);
ReverseUnrealizedExchangeRate(
- PurchAdvLetterEntryCZZ2, PurchAdvLetterHeaderCZZ, VATPostingSetup,
+ RelatedPurchAdvLetterEntryCZZ, PurchAdvLetterHeaderCZZ, VATPostingSetup,
AdvancePostingBufferCZZ.Amount / TempAdvancePostingBufferCZZ.Amount,
- PurchAdvLetterEntryCZZ2."Entry No.", GenJnlPostLine, AdvancePostingParametersCZZ2);
+ RelatedPurchAdvLetterEntryCZZ."Entry No.", AdvancePostingBufferCZZ."Auxiliary Entry",
+ GenJnlPostLine, AdvancePostingParametersCZZ2);
end;
// Post balance of credit memo VAT
@@ -709,7 +838,7 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
InitGenJournalLine(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingParametersCZZ2, GenJournalLine);
GenJournalLine."Account No." := VATPostingSetup.GetPurchAdvLetterAccountCZZ();
GenJournalLine.CopyFromAdvancePostingBufferAmountsCZZ(AdvancePostingBufferCZZ);
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
OnPostAdvanceCreditMemoVATOnBeforePostBalance(
PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
@@ -721,12 +850,12 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
until AdvancePostingBufferCZZ.Next() = 0;
if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
- PurchAdvLetterEntryCZZ3.Reset();
- PurchAdvLetterEntryCZZ3.SetRange("Purch. Adv. Letter No.", PurchAdvLetterEntryCZZ."Purch. Adv. Letter No.");
- PurchAdvLetterEntryCZZ3.SetRange("Document No.", PurchAdvLetterEntryCZZ."Document No.");
- PurchAdvLetterEntryCZZ3.SetRange("Entry Type", "Advance Letter Entry Type CZZ"::"VAT Payment");
- PurchAdvLetterEntryCZZ3.SetRange(Cancelled, false);
- PurchAdvLetterEntryCZZ3.ModifyAll(Cancelled, true);
+ VATDocumentPurchAdvLetterEntryCZZ.Reset();
+ VATDocumentPurchAdvLetterEntryCZZ.SetRange("Purch. Adv. Letter No.", PurchAdvLetterEntryCZZ."Purch. Adv. Letter No.");
+ VATDocumentPurchAdvLetterEntryCZZ.SetRange("Document No.", PurchAdvLetterEntryCZZ."Document No.");
+ VATDocumentPurchAdvLetterEntryCZZ.SetRange("Entry Type", "Advance Letter Entry Type CZZ"::"VAT Payment");
+ VATDocumentPurchAdvLetterEntryCZZ.SetRange(Cancelled, false);
+ VATDocumentPurchAdvLetterEntryCZZ.ModifyAll(Cancelled, true);
end;
OnAfterPostAdvanceCreditMemoVAT(
@@ -798,7 +927,8 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
VATPostingSetup.Get(PurchAdvLetterEntryCZZ."VAT Bus. Posting Group", PurchAdvLetterEntryCZZ."VAT Prod. Posting Group");
PostUnrealizedExchangeRate(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, VATPostingSetup,
-PurchAdvLetterEntryCZZ."Amount (LCY)", -PurchAdvLetterEntryCZZ."VAT Amount (LCY)",
- PurchAdvLetterEntryCZZ."Related Entry", 0, true, GenJnlPostLine, AdvancePostingParametersCZZ2);
+ PurchAdvLetterEntryCZZ."Related Entry", 0, true, PurchAdvLetterEntryCZZ."Auxiliary Entry",
+ GenJnlPostLine, AdvancePostingParametersCZZ2);
end;
PurchAdvLetterEntryCZZ."Entry Type"::"VAT Rate":
begin
@@ -807,7 +937,8 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
VATPostingSetup.Get(PurchAdvLetterEntryCZZ."VAT Bus. Posting Group", PurchAdvLetterEntryCZZ."VAT Prod. Posting Group");
PostExchangeRate(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, VATPostingSetup,
-PurchAdvLetterEntryCZZ."Amount (LCY)", -PurchAdvLetterEntryCZZ."VAT Amount (LCY)",
- PurchAdvLetterEntryCZZ."Related Entry", true, GenJnlPostLine, AdvancePostingParametersCZZ2);
+ PurchAdvLetterEntryCZZ."Related Entry", true, PurchAdvLetterEntryCZZ."Auxiliary Entry",
+ GenJnlPostLine, AdvancePostingParametersCZZ2);
end;
PurchAdvLetterEntryCZZ."Entry Type"::"VAT Usage":
begin
@@ -852,8 +983,7 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
GenJournalLine: Record "Gen. Journal Line";
VATPostingSetup: Record "VAT Posting Setup";
VATEntry: Record "VAT Entry";
- EntryNo: Integer;
- GLEntryNo: Integer;
+ EntryNo, GLEntryNo, VATEntryNo : Integer;
IsHandled: Boolean;
begin
IsHandled := false;
@@ -862,6 +992,9 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
if IsHandled then
exit;
+ GLEntryNo := 0;
+ VATEntryNo := 0;
+
VATPostingSetup.Get(AdvancePostingBufferCZZ."VAT Bus. Posting Group", AdvancePostingBufferCZZ."VAT Prod. Posting Group");
InitGenJournalLine(
@@ -875,15 +1008,15 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
GenJournalLine."VAT Posting" := GenJournalLine."VAT Posting"::"Manual VAT Entry";
if (GenJournalLine."Currency Code" <> '') and
(GenJournalLine."VAT Calculation Type" = GenJournalLine."VAT Calculation Type"::"Reverse Charge VAT")
- then begin
- VATEntry.Get(PurchAdvLetterEntryCZZ."VAT Entry No.");
- GenJournalLine."VAT Amount (LCY)" := -VATEntry.Amount;
- end;
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
+ then
+ if VATEntry.Get(PurchAdvLetterEntryCZZ."VAT Entry No.") then
+ GenJournalLine."VAT Amount (LCY)" := -VATEntry.Amount;
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
OnPostAdvanceLetterEntryVATUsageUnapplyingOnBeforePost(
PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
GLEntryNo := RunGenJnlPostLine(GenJournalLine, GenJnlPostLine, true, true, false);
+ VATEntryNo := GenJnlPostLine.GetNextVATEntryNo() - 1;
OnPostAdvanceLetterEntryVATUsageUnapplyingOnAfterPost(
PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
AdvancePostingParametersCZZ, GLEntryNo, GenJnlPostLine, GenJournalLine);
@@ -894,8 +1027,9 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
TempPurchAdvLetterEntryCZZGlob.CopyFromGenJnlLine(GenJournalLine);
TempPurchAdvLetterEntryCZZGlob."Entry Type" := PurchAdvLetterEntryCZZ."Entry Type";
TempPurchAdvLetterEntryCZZGlob."Purch. Adv. Letter No." := PurchAdvLetterHeaderCZZ."No.";
- TempPurchAdvLetterEntryCZZGlob."VAT Entry No." := GenJnlPostLine.GetNextVATEntryNo() - 1;
+ TempPurchAdvLetterEntryCZZGlob."VAT Entry No." := VATEntryNo;
TempPurchAdvLetterEntryCZZGlob."VAT Identifier" := VATPostingSetup."VAT Identifier";
+ TempPurchAdvLetterEntryCZZGlob."Auxiliary Entry" := AdvancePostingBufferCZZ."Auxiliary Entry";
TempPurchAdvLetterEntryCZZGlob.Cancelled := true;
EntryNo := TempPurchAdvLetterEntryCZZGlob.InsertNewEntry(not AdvancePostingParametersCZZ."Temporary Entries Only");
@@ -907,7 +1041,7 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
GenJournalLine."Account No." := VATPostingSetup.GetPurchAdvLetterAccountCZZ();
GenJournalLine.Correction := true;
GenJournalLine.CopyFromAdvancePostingBufferAmountsCZZ(AdvancePostingBufferCZZ);
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
OnPostAdvanceLetterEntryVATUsageUnapplyingOnBeforePostBalance(
PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
@@ -1323,13 +1457,13 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ")
var
AdvancePostingParametersCZZ2: Record "Advance Posting Parameters CZZ";
- PurchAdvLetterEntryCZZ2: Record "Purch. Adv. Letter Entry CZZ";
TempAdvancePostingBufferCZZ: Record "Advance Posting Buffer CZZ" temporary;
GenJournalLine: Record "Gen. Journal Line";
+ VATDocumentPurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ";
VATPostingSetup: Record "VAT Posting Setup";
PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ";
CalcVATAmountLCY, CalcAmountLCY, ExchRateAmount, ExchRateVATAmount, AmountToUse : Decimal;
- GLEntryNo: Integer;
+ GLEntryNo, VATEntryNo : Integer;
IsHandled: Boolean;
begin
IsHandled := false;
@@ -1345,11 +1479,12 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
if PurchAdvLetterEntryCZZ."Entry Type" <> PurchAdvLetterEntryCZZ."Entry Type"::Payment then
exit;
- PurchAdvLetterEntryCZZ2.SetRange("Purch. Adv. Letter No.", PurchAdvLetterEntryCZZ."Purch. Adv. Letter No.");
- PurchAdvLetterEntryCZZ2.SetRange(Cancelled, false);
- PurchAdvLetterEntryCZZ2.SetRange("Related Entry", PurchAdvLetterEntryCZZ."Entry No.");
- PurchAdvLetterEntryCZZ2.SetRange("Entry Type", PurchAdvLetterEntryCZZ2."Entry Type"::"VAT Payment");
- if PurchAdvLetterEntryCZZ2.IsEmpty() then
+ VATDocumentPurchAdvLetterEntryCZZ.Reset();
+ VATDocumentPurchAdvLetterEntryCZZ.SetRange("Purch. Adv. Letter No.", PurchAdvLetterEntryCZZ."Purch. Adv. Letter No.");
+ VATDocumentPurchAdvLetterEntryCZZ.SetRange(Cancelled, false);
+ VATDocumentPurchAdvLetterEntryCZZ.SetRange("Related Entry", PurchAdvLetterEntryCZZ."Entry No.");
+ VATDocumentPurchAdvLetterEntryCZZ.SetRange("Entry Type", VATDocumentPurchAdvLetterEntryCZZ."Entry Type"::"VAT Payment");
+ if VATDocumentPurchAdvLetterEntryCZZ.IsEmpty() then
exit;
AdvancePostingBufferCZZ.FilterGroup(-1);
@@ -1373,6 +1508,9 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
AdvancePostingBufferCZZ.FindSet();
repeat
+ GLEntryNo := 0;
+ VATEntryNo := 0;
+
VATPostingSetup.Get(AdvancePostingBufferCZZ."VAT Bus. Posting Group", AdvancePostingBufferCZZ."VAT Prod. Posting Group");
// Post reverse advance payment VAT
@@ -1383,11 +1521,12 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
GenJournalLine.CopyFromAdvancePostingBufferCZZ(AdvancePostingBufferCZZ);
if GenJournalLine."VAT Calculation Type" = GenJournalLine."VAT Calculation Type"::"Reverse Charge VAT" then
GenJournalLine."VAT Posting" := GenJournalLine."VAT Posting"::"Manual VAT Entry";
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
OnReverseAdvancePaymentVATOnBeforePost(
PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, VATPostingSetup,
AdvancePostingBufferCZZ, AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
GLEntryNo := RunGenJnlPostLine(GenJournalLine, GenJnlPostLine, true, true, false);
+ VATEntryNo := GenJnlPostLine.GetNextVATEntryNo() - 1;
OnReverseAdvancePaymentVATOnAfterPost(
PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, VATPostingSetup, AdvancePostingBufferCZZ,
AdvancePostingParametersCZZ, GLEntryNo, GenJnlPostLine, GenJournalLine);
@@ -1403,8 +1542,9 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
TempPurchAdvLetterEntryCZZGlob.CopyFromGenJnlLine(GenJournalLine);
TempPurchAdvLetterEntryCZZGlob."Entry Type" := EntryType;
TempPurchAdvLetterEntryCZZGlob."Purch. Adv. Letter No." := PurchAdvLetterHeaderCZZ."No.";
- TempPurchAdvLetterEntryCZZGlob."VAT Entry No." := GenJnlPostLine.GetNextVATEntryNo() - 1;
+ TempPurchAdvLetterEntryCZZGlob."VAT Entry No." := VATEntryNo;
TempPurchAdvLetterEntryCZZGlob."VAT Identifier" := VATPostingSetup."VAT Identifier";
+ TempPurchAdvLetterEntryCZZGlob."Auxiliary Entry" := AdvancePostingBufferCZZ."Auxiliary Entry";
TempPurchAdvLetterEntryCZZGlob.InsertNewEntry(not AdvancePostingParametersCZZ."Temporary Entries Only");
AdvancePostingBufferCZZ.ReverseAmounts();
@@ -1426,12 +1566,12 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
ExchRateVATAmount := CalcVATAmountLCY + GenJournalLine."VAT Amount (LCY)";
if (ExchRateAmount <> 0) or (ExchRateVATAmount <> 0) then
PostExchangeRate(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, VATPostingSetup, -ExchRateAmount, -ExchRateVATAmount,
- RelatedEntryNo, false, GenJnlPostLine, AdvancePostingParametersCZZ2);
+ RelatedEntryNo, false, AdvancePostingBufferCZZ."Auxiliary Entry", GenJnlPostLine, AdvancePostingParametersCZZ2);
AdvancePostingParametersCZZ2."Source Code" := '';
ReverseUnrealizedExchangeRate(
PurchAdvLetterEntryCZZ, PurchAdvLetterHeaderCZZ, VATPostingSetup, AdvancePostingBufferCZZ.Amount / AmountToUse,
- RelatedEntryNo, GenJnlPostLine, AdvancePostingParametersCZZ2);
+ RelatedEntryNo, AdvancePostingBufferCZZ."Auxiliary Entry", GenJnlPostLine, AdvancePostingParametersCZZ2);
end;
// Post balance of reverse advance payment VAT
@@ -1440,7 +1580,7 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
InitGenJournalLine(PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, AdvancePostingParametersCZZ2, GenJournalLine);
GenJournalLine."Account No." := VATPostingSetup.GetPurchAdvLetterAccountCZZ();
GenJournalLine.CopyFromAdvancePostingBufferAmountsCZZ(AdvancePostingBufferCZZ);
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
OnReverseAdvancePaymentVATOnBeforePostBalance(
PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, VATPostingSetup,
AdvancePostingBufferCZZ, AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
@@ -1464,6 +1604,7 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
VATPostingSetup: Record "VAT Posting Setup";
Coef: Decimal;
RelatedEntryNo: Integer;
+ AuxiliaryEntry: Boolean;
var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ")
var
@@ -1491,7 +1632,7 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
PostUnrealizedExchangeRate(
PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, VATPostingSetup, -AmountLCY, -VATAmountLCY,
- RelatedEntryNo, 0, false, GenJnlPostLine, AdvancePostingParametersCZZ);
+ RelatedEntryNo, 0, false, AuxiliaryEntry, GenJnlPostLine, AdvancePostingParametersCZZ);
end;
internal procedure PostExchangeRate(
@@ -1502,6 +1643,7 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
VATAmount: Decimal;
RelatedEntryNo: Integer;
Correction: Boolean;
+ AuxiliaryEntry: Boolean;
var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ")
var
@@ -1591,6 +1733,7 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
TempPurchAdvLetterEntryCZZGlob."Global Dimension 2 Code" := PurchAdvLetterEntryCZZ."Global Dimension 2 Code";
TempPurchAdvLetterEntryCZZGlob."Dimension Set ID" := PurchAdvLetterEntryCZZ."Dimension Set ID";
TempPurchAdvLetterEntryCZZGlob.Cancelled := Correction;
+ TempPurchAdvLetterEntryCZZGlob."Auxiliary Entry" := AuxiliaryEntry;
OnPostExchangeRateOnBeforeInsertEntry(
PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, VATPostingSetup,
AdvancePostingParametersCZZ, TempPurchAdvLetterEntryCZZGlob);
@@ -1610,6 +1753,7 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
RelatedEntryNo: Integer;
RelatedDetEntryNo: Integer;
Correction: Boolean;
+ AuxiliaryEntry: Boolean;
var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ")
var
@@ -1686,6 +1830,7 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
TempPurchAdvLetterEntryCZZGlob."Global Dimension 2 Code" := PurchAdvLetterEntryCZZ."Global Dimension 2 Code";
TempPurchAdvLetterEntryCZZGlob."Dimension Set ID" := PurchAdvLetterEntryCZZ."Dimension Set ID";
TempPurchAdvLetterEntryCZZGlob.Cancelled := Correction;
+ TempPurchAdvLetterEntryCZZGlob."Auxiliary Entry" := AuxiliaryEntry;
OnPostUnrealizedExchangeRateOnBeforeInsertEntry(
PurchAdvLetterHeaderCZZ, PurchAdvLetterEntryCZZ, VATPostingSetup,
AdvancePostingParametersCZZ, TempPurchAdvLetterEntryCZZGlob);
@@ -2005,7 +2150,12 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
GenJournalLine."Posting Group" := VendorLedgerEntry."Vendor Posting Group";
GenJournalLine."Source Currency Code" := DetailedVendorLedgEntry1."Currency Code";
GenJournalLine."System-Created Entry" := true;
+ OnUnapplyVendLedgEntryOnBeforeUnapplyVendLedgEntry(VendorLedgerEntry, DetailedVendorLedgEntry1, GenJournalLine);
+#if not CLEAN25
+#pragma warning disable AL0432
OnUnapplyVendLedgEntryOnBeforePostUnapplyVendLedgEntry(VendorLedgerEntry, DetailedVendorLedgEntry1, GenJournalLine);
+#pragma warning restore AL0432
+#endif
#if not CLEAN24
RaiseOnUnapplyVendLedgEntryOnBeforePostUnapplyVendLedgEntry(VendorLedgerEntry, DetailedVendorLedgEntry1, GenJournalLine);
#endif
@@ -2383,6 +2533,36 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
begin
end;
+ [IntegrationEvent(false, false)]
+ local procedure OnBeforePostAdvancePaymentUsageVATCancellation(var PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ"; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; var AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ"; var IsHandled: Boolean)
+ begin
+ end;
+
+ [IntegrationEvent(false, false)]
+ local procedure OnAfterPostAdvancePaymentUsageVATCancellation(PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ"; var PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ"; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; var AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ")
+ begin
+ end;
+
+ [IntegrationEvent(false, false)]
+ local procedure OnPostAdvancePaymentUsageVATCancellationOnBeforePost(PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ"; var PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ"; var AdvancePostingBufferCZZ: Record "Advance Posting Buffer CZZ"; var AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ"; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; GenJournalLine: Record "Gen. Journal Line")
+ begin
+ end;
+
+ [IntegrationEvent(false, false)]
+ local procedure OnPostAdvancePaymentUsageVATCancellationOnAfterPost(PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ"; var PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ"; var AdvancePostingBufferCZZ: Record "Advance Posting Buffer CZZ"; var AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ"; GLEntryNo: Integer; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; GenJournalLine: Record "Gen. Journal Line")
+ begin
+ end;
+
+ [IntegrationEvent(false, false)]
+ local procedure OnPostAdvancePaymentUsageVATCancellationOnBeforePostBalance(PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ"; var PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ"; var AdvancePostingBufferCZZ: Record "Advance Posting Buffer CZZ"; var AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ"; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; GenJournalLine: Record "Gen. Journal Line")
+ begin
+ end;
+
+ [IntegrationEvent(false, false)]
+ local procedure OnPostAdvancePaymentUsageVATCancellationOnAfterPostBalance(PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ"; var PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ"; var AdvancePostingBufferCZZ: Record "Advance Posting Buffer CZZ"; var AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ"; GLEntryNo: Integer; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; GenJournalLine: Record "Gen. Journal Line")
+ begin
+ end;
+
[IntegrationEvent(false, false)]
local procedure OnBeforePostAdvanceCreditMemoVAT(var PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ"; var AdvancePostingBufferCZZ: Record "Advance Posting Buffer CZZ"; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; var AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ"; var IsHandled: Boolean)
begin
@@ -2698,9 +2878,16 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
local procedure OnAfterInitGenJournalLineFromVendorLedgerEntry(var VendorLedgerEntry: Record "Vendor Ledger Entry"; var GenJournalLine: Record "Gen. Journal Line")
begin
end;
-
+#if not CLEAN25
+ [Obsolete('Replaced by OnUnapplyVendLedgEntryOnBeforeUnapplyVendLedgEntry event.', '25.0')]
[IntegrationEvent(false, false)]
local procedure OnUnapplyVendLedgEntryOnBeforePostUnapplyVendLedgEntry(var VendorLedgerEntry: Record "Vendor Ledger Entry"; DetailedVendorLedgEntry1: Record "Detailed Vendor Ledg. Entry"; GenJournalLine: Record "Gen. Journal Line")
begin
end;
+#endif
+
+ [IntegrationEvent(false, false)]
+ local procedure OnUnapplyVendLedgEntryOnBeforeUnapplyVendLedgEntry(var VendorLedgerEntry: Record "Vendor Ledger Entry"; var DetailedVendorLedgEntry: Record "Detailed Vendor Ledg. Entry"; var GenJournalLine: Record "Gen. Journal Line")
+ begin
+ end;
}
\ No newline at end of file
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/SalesAdvLetterManagementCZZ.Codeunit.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/SalesAdvLetterManagementCZZ.Codeunit.al
index 24cd481a5b..3ac27310d0 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/SalesAdvLetterManagementCZZ.Codeunit.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/SalesAdvLetterManagementCZZ.Codeunit.al
@@ -228,7 +228,9 @@ codeunit 31002 "SalesAdvLetterManagement CZZ"
AdvanceLetterLinkCZZ.GetLetterLink(TempAdvanceLetterLinkBufferCZZ);
TempAdvanceLetterLinkBufferCZZ.SetFilter(Amount, '>0');
if not TempAdvanceLetterLinkBufferCZZ.IsEmpty() then begin
- PostingDate := GetPostingDateUI(CustLedgerEntry."Posting Date");
+ PostingDate := CustLedgerEntry."Posting Date";
+ if not GetPostingDateUI(PostingDate) then
+ exit;
if PostingDate = 0D then
Error(PostingDateEmptyErr);
LinkAdvancePayment(CustLedgerEntry, TempAdvanceLetterLinkBufferCZZ, PostingDate);
@@ -266,7 +268,9 @@ codeunit 31002 "SalesAdvLetterManagement CZZ"
var
PostingDate: Date;
begin
- PostingDate := GetPostingDateUI(CustLedgerEntry."Posting Date");
+ PostingDate := CustLedgerEntry."Posting Date";
+ if not GetPostingDateUI(PostingDate) then
+ exit;
if PostingDate = 0D then
Error(PostingDateEmptyErr);
@@ -277,7 +281,9 @@ codeunit 31002 "SalesAdvLetterManagement CZZ"
var
PostingDate: Date;
begin
- PostingDate := GetPostingDateUI(CustLedgerEntry."Posting Date");
+ PostingDate := CustLedgerEntry."Posting Date";
+ if not GetPostingDateUI(PostingDate) then
+ exit;
if PostingDate = 0D then
Error(PostingDateEmptyErr);
@@ -303,7 +309,8 @@ codeunit 31002 "SalesAdvLetterManagement CZZ"
InsertedEntryNo := SalesAdvLetterPostCZZ.PostAdvancePayment(
CustLedgerEntry, PostedGenJournalLine, GenJnlPostLine, AdvancePostingParametersCZZ);
end;
-
+#if not CLEAN25
+ [Obsolete('Replaced by GetAdvanceGLAccountNoCZZ function in GenJournalLine.', '25.0')]
procedure GetAdvanceGLAccount(var GenJournalLine: Record "Gen. Journal Line"): Code[20]
var
SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ";
@@ -315,6 +322,7 @@ codeunit 31002 "SalesAdvLetterManagement CZZ"
AdvanceLetterTemplateCZZ.TestField("Advance Letter G/L Account");
exit(AdvanceLetterTemplateCZZ."Advance Letter G/L Account");
end;
+#endif
procedure PostAdvancePaymentVAT(var SalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ"; PostingDate: Date)
begin
@@ -367,11 +375,18 @@ codeunit 31002 "SalesAdvLetterManagement CZZ"
InitVATAmountLine(TempAdvancePostingBufferCZZ, SalesAdvLetterEntryCZZ."Sales Adv. Letter No.", SalesAdvLetterEntryCZZ.Amount, SalesAdvLetterEntryCZZ."Currency Factor");
+ TempAdvancePostingBufferCZZ.Reset();
+ TempAdvancePostingBufferCZZ.SetRange("Auxiliary Entry", false);
+ if TempAdvancePostingBufferCZZ.IsEmpty() then
+ DocumentNo := SalesAdvLetterHeaderCZZ."No.";
+ TempAdvancePostingBufferCZZ.Reset();
+
if Silently or not GuiAllowed then begin
- DocumentNo := NoSeries.GetNextNo(AdvanceLetterTemplateCZZ."Advance Letter Invoice Nos.", PostingDate);
+ if DocumentNo = '' then
+ DocumentNo := NoSeries.GetNextNo(AdvanceLetterTemplateCZZ."Advance Letter Invoice Nos.", PostingDate);
TempAdvancePostingBufferCZZ.SetFilter(Amount, '<>0');
end else begin
- VATDocumentCZZ.InitSalesDocument(AdvanceLetterTemplateCZZ."Advance Letter Invoice Nos.", '',
+ VATDocumentCZZ.InitSalesDocument(AdvanceLetterTemplateCZZ."Advance Letter Invoice Nos.", DocumentNo,
SalesAdvLetterHeaderCZZ."Document Date", PostingDate, VATDate, 0D,
SalesAdvLetterHeaderCZZ."Currency Code", SalesAdvLetterEntryCZZ."Currency Factor", '', TempAdvancePostingBufferCZZ);
if VATDocumentCZZ.RunModal() <> Action::OK then
@@ -447,18 +462,28 @@ codeunit 31002 "SalesAdvLetterManagement CZZ"
local procedure BufferAdvanceLines(SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ"; var AdvancePostingBufferCZZ: Record "Advance Posting Buffer CZZ")
var
+ AdvanceLetterTemplateCZZ: Record "Advance Letter Template CZZ";
SalesAdvLetterLineCZZ: Record "Sales Adv. Letter Line CZZ";
TempAdvancePostingBufferCZZ: Record "Advance Posting Buffer CZZ" temporary;
begin
AdvancePostingBufferCZZ.Reset();
AdvancePostingBufferCZZ.DeleteAll();
+ AdvanceLetterTemplateCZZ.Get(SalesAdvLetterHeaderCZZ."Advance Letter Code");
+
SalesAdvLetterLineCZZ.SetRange("Document No.", SalesAdvLetterHeaderCZZ."No.");
SalesAdvLetterLineCZZ.SetFilter(Amount, '<>0');
if SalesAdvLetterLineCZZ.FindSet() then
repeat
TempAdvancePostingBufferCZZ.PrepareForSalesAdvLetterLine(SalesAdvLetterLineCZZ);
AdvancePostingBufferCZZ.Update(TempAdvancePostingBufferCZZ);
+
+ if (not AdvanceLetterTemplateCZZ."Post VAT Doc. for Rev. Charge") and
+ (AdvancePostingBufferCZZ."VAT Calculation Type" = "Tax Calculation Type"::"Reverse Charge VAT")
+ then begin
+ AdvancePostingBufferCZZ."Auxiliary Entry" := true;
+ AdvancePostingBufferCZZ.Modify();
+ end;
until SalesAdvLetterLineCZZ.Next() = 0;
end;
@@ -517,7 +542,9 @@ codeunit 31002 "SalesAdvLetterManagement CZZ"
begin
CustLedgerEntry.TestField("Advance Letter No. CZZ");
- PostingDate := GetPostingDateUI(CustLedgerEntry."Posting Date");
+ PostingDate := CustLedgerEntry."Posting Date";
+ if not GetPostingDateUI(PostingDate) then
+ exit;
if PostingDate = 0D then
Error(PostingDateEmptyErr);
@@ -537,7 +564,9 @@ codeunit 31002 "SalesAdvLetterManagement CZZ"
PostingDate: Date;
begin
CustLedgerEntry.Get(SalesAdvLetterEntryCZZ."Cust. Ledger Entry No.");
- PostingDate := GetPostingDateUI(CustLedgerEntry."Posting Date");
+ PostingDate := CustLedgerEntry."Posting Date";
+ if not GetPostingDateUI(PostingDate) then
+ exit;
if PostingDate = 0D then
Error(PostingDateEmptyErr);
UnlinkAdvancePayment(SalesAdvLetterEntryCZZ, PostingDate);
@@ -911,6 +940,8 @@ codeunit 31002 "SalesAdvLetterManagement CZZ"
NoSeries: Codeunit "No. Series";
GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
AdvPaymentCloseDialog: Page "Adv. Payment Close Dialog CZZ";
+ DocumentNo: Code[20];
+ SourceCode: Code[10];
VATDate: Date;
PostingDate: Date;
CurrencyFactor: Decimal;
@@ -939,15 +970,29 @@ codeunit 31002 "SalesAdvLetterManagement CZZ"
TempAdvancePostingBufferCZZ.Modify();
until SalesAdvLetterEntryCZZ2.Next() = 0;
- VATEntry.Get(SalesAdvLetterEntryCZZ."VAT Entry No.");
SalesAdvLetterHeaderCZZ.Get(SalesAdvLetterEntryCZZ."Sales Adv. Letter No.");
AdvanceLetterTemplateCZZ.Get(SalesAdvLetterHeaderCZZ."Advance Letter Code");
+ // find VAT entry of the VAT document due to source code
+ SourceCode := '';
+ VATEntry.SetRange("Document No.", SalesAdvLetterEntryCZZ."Document No.");
+ VATEntry.SetRange("Posting Date", SalesAdvLetterEntryCZZ."Posting Date");
+ if VATEntry.FindFirst() then
+ SourceCode := VATEntry."Source Code";
+
+ TempAdvancePostingBufferCZZ.Reset();
+ TempAdvancePostingBufferCZZ.SetRange("Auxiliary Entry", false);
+ if TempAdvancePostingBufferCZZ.IsEmpty() then
+ DocumentNo := SalesAdvLetterHeaderCZZ."No.";
+ TempAdvancePostingBufferCZZ.Reset();
+
+ if DocumentNo = '' then
+ DocumentNo := NoSeries.GetNextNo(AdvanceLetterTemplateCZZ."Advance Letter Cr. Memo Nos.", WorkDate());
+
Clear(AdvancePostingParametersCZZ);
AdvancePostingParametersCZZ."Document Type" := "Gen. Journal Document Type"::"Credit Memo";
- AdvancePostingParametersCZZ."Document No." :=
- NoSeries.GetNextNo(AdvanceLetterTemplateCZZ."Advance Letter Cr. Memo Nos.", WorkDate());
- AdvancePostingParametersCZZ."Source Code" := VATEntry."Source Code";
+ AdvancePostingParametersCZZ."Document No." := DocumentNo;
+ AdvancePostingParametersCZZ."Source Code" := SourceCode;
AdvancePostingParametersCZZ."Posting Description" := SalesAdvLetterHeaderCZZ."Posting Description";
AdvancePostingParametersCZZ."Posting Date" := PostingDate;
AdvancePostingParametersCZZ."Document Date" := PostingDate;
@@ -1162,8 +1207,10 @@ codeunit 31002 "SalesAdvLetterManagement CZZ"
if TempAdvancePostingBufferCZZ2.FindSet() then
repeat
VATPostingSetup.Get(TempAdvancePostingBufferCZZ2."VAT Bus. Posting Group", TempAdvancePostingBufferCZZ2."VAT Prod. Posting Group");
- PostUnrealizedExchangeRate(SalesAdvLetterEntryCZZ, SalesAdvLetterHeaderCZZ, VATPostingSetup, TempAdvancePostingBufferCZZ2.Amount, TempAdvancePostingBufferCZZ2."VAT Amount",
- SalesAdvLetterEntryCZZ."Entry No.", DetEntryNo, DocumentNo, ToDate, ToDate, PostDescription, GenJnlPostLine, false, false);
+ PostUnrealizedExchangeRate(SalesAdvLetterEntryCZZ, SalesAdvLetterHeaderCZZ, VATPostingSetup,
+ TempAdvancePostingBufferCZZ2.Amount, TempAdvancePostingBufferCZZ2."VAT Amount",
+ SalesAdvLetterEntryCZZ."Entry No.", DetEntryNo, DocumentNo, ToDate, ToDate, PostDescription,
+ GenJnlPostLine, false, false, TempAdvancePostingBufferCZZ2."Auxiliary Entry");
until TempAdvancePostingBufferCZZ2.Next() = 0;
SalesAdvLetterPostCZZ.BufferAdvanceVATLines(SalesAdvLetterEntryCZZ, TempAdvancePostingBufferCZZ1, 0D);
@@ -1218,8 +1265,10 @@ codeunit 31002 "SalesAdvLetterManagement CZZ"
end;
VATPostingSetup.Get(SalesAdvLetterEntryCZZ3."VAT Bus. Posting Group", SalesAdvLetterEntryCZZ3."VAT Prod. Posting Group");
- PostUnrealizedExchangeRate(SalesAdvLetterEntryCZZ, SalesAdvLetterHeaderCZZ, VATPostingSetup, -AmountToPost, -VATAmountToPost,
- SalesAdvLetterEntryCZZ2."Entry No.", 0, DocumentNo, SalesAdvLetterEntryCZZ3."Posting Date", SalesAdvLetterEntryCZZ3."VAT Date", PostDescription, GenJnlPostLine, false, false);
+ PostUnrealizedExchangeRate(SalesAdvLetterEntryCZZ, SalesAdvLetterHeaderCZZ, VATPostingSetup,
+ -AmountToPost, -VATAmountToPost, SalesAdvLetterEntryCZZ2."Entry No.", 0, DocumentNo,
+ SalesAdvLetterEntryCZZ3."Posting Date", SalesAdvLetterEntryCZZ3."VAT Date", PostDescription,
+ GenJnlPostLine, false, false, SalesAdvLetterEntryCZZ3."Auxiliary Entry");
until SalesAdvLetterEntryCZZ3.Next() = 0;
until SalesAdvLetterEntryCZZ2.Next() = 0;
end;
@@ -1228,7 +1277,7 @@ codeunit 31002 "SalesAdvLetterManagement CZZ"
local procedure PostUnrealizedExchangeRate(var SalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ"; var SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ"; var VATPostingSetup: Record "VAT Posting Setup";
Amount: Decimal; VATAmount: Decimal; RelatedEntryNo: Integer; RelatedDetEntryNo: Integer; DocumentNo: Code[20]; PostingDate: Date; VATDate: Date; PostDescription: Text[100]; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
- Correction: Boolean; Preview: Boolean)
+ Correction: Boolean; Preview: Boolean; AuxiliaryEntry: Boolean)
var
AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ";
begin
@@ -1240,21 +1289,23 @@ codeunit 31002 "SalesAdvLetterManagement CZZ"
AdvancePostingParametersCZZ."Temporary Entries Only" := Preview;
SalesAdvLetterPostCZZ.PostUnrealizedExchangeRate(
- SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, VATPostingSetup, Amount, VATAmount, RelatedEntryNo, RelatedDetEntryNo, Correction, GenJnlPostLine, AdvancePostingParametersCZZ);
+ SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, VATPostingSetup, Amount, VATAmount,
+ RelatedEntryNo, RelatedDetEntryNo, Correction, AuxiliaryEntry, GenJnlPostLine, AdvancePostingParametersCZZ);
end;
- local procedure GetPostingDateUI(DefaultPostingDate: Date): Date
+ local procedure GetPostingDateUI(var PostingDate: Date): Boolean
var
GetPostingDateCZZ: Page "Get Posting Date CZZ";
- PostingDate: Date;
begin
if not GuiAllowed() then
- exit(DefaultPostingDate);
+ exit(true);
+
+ GetPostingDateCZZ.SetValues(PostingDate);
+ if GetPostingDateCZZ.RunModal() <> Action::OK then
+ exit(false);
- GetPostingDateCZZ.SetValues(DefaultPostingDate);
- if GetPostingDateCZZ.RunModal() = Action::OK then
- GetPostingDateCZZ.GetValues(PostingDate);
- exit(PostingDate);
+ GetPostingDateCZZ.GetValues(PostingDate);
+ exit(true);
end;
#if not CLEAN24
#pragma warning disable AL0432
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/SalesAdvLetterPostCZZ.Codeunit.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/SalesAdvLetterPostCZZ.Codeunit.al
index a238f581c1..9ed4f7ae42 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/SalesAdvLetterPostCZZ.Codeunit.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/SalesAdvLetterPostCZZ.Codeunit.al
@@ -259,7 +259,7 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
SalesAdvLetterEntryCZZ2: Record "Sales Adv. Letter Entry CZZ";
SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ";
VATPostingSetup: Record "VAT Posting Setup";
- GLEntryNo: Integer;
+ GLEntryNo, VATEntryNo : Integer;
IsHandled: Boolean;
begin
IsHandled := false;
@@ -298,55 +298,60 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
AdvancePostingParametersCZZ."Source Code" := CustLedgerEntry."Source Code";
end;
- AdvancePostingBufferCZZ.FindSet();
- repeat
- VATPostingSetup.Get(AdvancePostingBufferCZZ."VAT Bus. Posting Group", AdvancePostingBufferCZZ."VAT Prod. Posting Group");
-
- // Post VAT amount and VAT base of VAT document
- InitGenJournalLine(SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingParametersCZZ, GenJournalLine);
- GenJournalLine."Account No." := VATPostingSetup.GetSalesAdvLetterAccountCZZ();
- GenJournalLine."Gen. Posting Type" := GenJournalLine."Gen. Posting Type"::Sale;
- GenJournalLine.CopyFromAdvancePostingBufferCZZ(AdvancePostingBufferCZZ);
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
- OnPostAdvancePaymentVATOnBeforePost(
- SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
- AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
+ if AdvancePostingBufferCZZ.FindSet() then
+ repeat
+ GLEntryNo := 0;
+ VATEntryNo := 0;
+
+ VATPostingSetup.Get(AdvancePostingBufferCZZ."VAT Bus. Posting Group", AdvancePostingBufferCZZ."VAT Prod. Posting Group");
+
+ // Post VAT amount and VAT base of VAT document
+ InitGenJournalLine(SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingParametersCZZ, GenJournalLine);
+ GenJournalLine."Account No." := VATPostingSetup.GetSalesAdvLetterAccountCZZ();
+ GenJournalLine."Gen. Posting Type" := GenJournalLine."Gen. Posting Type"::Sale;
+ GenJournalLine.CopyFromAdvancePostingBufferCZZ(AdvancePostingBufferCZZ);
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
+ OnPostAdvancePaymentVATOnBeforePost(
+ SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
+ AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
#if not CLEAN24
- RaiseOnPostAdvancePaymentVATOnBeforeGenJnlPostLine(
- SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, GenJournalLine);
+ RaiseOnPostAdvancePaymentVATOnBeforeGenJnlPostLine(
+ SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, GenJournalLine);
#endif
- GLEntryNo := RunGenJnlPostLine(GenJournalLine, GenJnlPostLine, true, true, false);
- OnPostAdvancePaymentVATOnAfterPost(
- SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
- AdvancePostingParametersCZZ, GLEntryNo, GenJnlPostLine, GenJournalLine);
- end;
-
- TempSalesAdvLetterEntryCZZGlob.InitNewEntry();
- TempSalesAdvLetterEntryCZZGlob.InitRelatedEntry(SalesAdvLetterEntryCZZ);
- TempSalesAdvLetterEntryCZZGlob.CopyFromGenJnlLine(GenJournalLine);
- TempSalesAdvLetterEntryCZZGlob."Entry Type" := "Advance Letter Entry Type CZZ"::"VAT Payment";
- TempSalesAdvLetterEntryCZZGlob."Sales Adv. Letter No." := SalesAdvLetterHeaderCZZ."No.";
- TempSalesAdvLetterEntryCZZGlob."VAT Entry No." := GenJnlPostLine.GetNextVATEntryNo() - 1;
- TempSalesAdvLetterEntryCZZGlob."VAT Identifier" := VATPostingSetup."VAT Identifier";
- TempSalesAdvLetterEntryCZZGlob.InsertNewEntry(not AdvancePostingParametersCZZ."Temporary Entries Only");
+ GLEntryNo := RunGenJnlPostLine(GenJournalLine, GenJnlPostLine, true, true, false);
+ VATEntryNo := GenJnlPostLine.GetNextVATEntryNo() - 1;
+ OnPostAdvancePaymentVATOnAfterPost(
+ SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
+ AdvancePostingParametersCZZ, GLEntryNo, GenJnlPostLine, GenJournalLine);
+ end;
- // Post balance of VAT document
- AdvancePostingParametersCZZ2.InitNew(AdvancePostingParametersCZZ);
- AdvancePostingParametersCZZ2."Document Type" := "Gen. Journal Document Type"::" ";
- InitGenJournalLine(SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingParametersCZZ2, GenJournalLine);
- GenJournalLine."Account No." := VATPostingSetup.GetSalesAdvLetterAccountCZZ();
- AdvancePostingBufferCZZ.ReverseAmounts();
- GenJournalLine.CopyFromAdvancePostingBufferAmountsCZZ(AdvancePostingBufferCZZ);
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
- OnPostAdvancePaymentVATOnBeforePostBalance(
- SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
- AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
- GLEntryNo := RunGenJnlPostLine(GenJournalLine, GenJnlPostLine, false, false, false);
- OnPostAdvancePaymentVATOnAfterPostBalance(
- SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
- AdvancePostingParametersCZZ, GLEntryNo, GenJnlPostLine, GenJournalLine);
- end;
- until AdvancePostingBufferCZZ.Next() = 0;
+ TempSalesAdvLetterEntryCZZGlob.InitNewEntry();
+ TempSalesAdvLetterEntryCZZGlob.InitRelatedEntry(SalesAdvLetterEntryCZZ);
+ TempSalesAdvLetterEntryCZZGlob.CopyFromGenJnlLine(GenJournalLine);
+ TempSalesAdvLetterEntryCZZGlob."Entry Type" := "Advance Letter Entry Type CZZ"::"VAT Payment";
+ TempSalesAdvLetterEntryCZZGlob."Sales Adv. Letter No." := SalesAdvLetterHeaderCZZ."No.";
+ TempSalesAdvLetterEntryCZZGlob."VAT Entry No." := VATEntryNo;
+ TempSalesAdvLetterEntryCZZGlob."VAT Identifier" := VATPostingSetup."VAT Identifier";
+ TempSalesAdvLetterEntryCZZGlob."Auxiliary Entry" := AdvancePostingBufferCZZ."Auxiliary Entry";
+ TempSalesAdvLetterEntryCZZGlob.InsertNewEntry(not AdvancePostingParametersCZZ."Temporary Entries Only");
+
+ // Post balance of VAT document
+ AdvancePostingParametersCZZ2.InitNew(AdvancePostingParametersCZZ);
+ AdvancePostingParametersCZZ2."Document Type" := "Gen. Journal Document Type"::" ";
+ InitGenJournalLine(SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingParametersCZZ2, GenJournalLine);
+ GenJournalLine."Account No." := VATPostingSetup.GetSalesAdvLetterAccountCZZ();
+ AdvancePostingBufferCZZ.ReverseAmounts();
+ GenJournalLine.CopyFromAdvancePostingBufferAmountsCZZ(AdvancePostingBufferCZZ);
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
+ OnPostAdvancePaymentVATOnBeforePostBalance(
+ SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
+ AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
+ GLEntryNo := RunGenJnlPostLine(GenJournalLine, GenJnlPostLine, false, false, false);
+ OnPostAdvancePaymentVATOnAfterPostBalance(
+ SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
+ AdvancePostingParametersCZZ, GLEntryNo, GenJnlPostLine, GenJournalLine);
+ end;
+ until AdvancePostingBufferCZZ.Next() = 0;
OnAfterPostAdvancePaymentVAT(
SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
@@ -363,7 +368,7 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
AdvancePostingParametersCZZ2: Record "Advance Posting Parameters CZZ";
VATPostingSetup: Record "VAT Posting Setup";
GenJournalLine: Record "Gen. Journal Line";
- EntryNo, GLEntryNo : Integer;
+ EntryNo, GLEntryNo, VATEntryNo : Integer;
IsHandled: Boolean;
begin
IsHandled := false;
@@ -378,17 +383,21 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
VATPostingSetup.Get(AdvancePostingBufferCZZ."VAT Bus. Posting Group", AdvancePostingBufferCZZ."VAT Prod. Posting Group");
+ GLEntryNo := 0;
+ VATEntryNo := 0;
+
// Post advance payment VAT unlinking
InitGenJournalLine(SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingParametersCZZ, GenJournalLine);
GenJournalLine."Account No." := VATPostingSetup.GetSalesAdvLetterAccountCZZ();
GenJournalLine."Gen. Posting Type" := GenJournalLine."Gen. Posting Type"::Sale;
AdvancePostingBufferCZZ.ReverseAmounts();
GenJournalLine.CopyFromAdvancePostingBufferCZZ(AdvancePostingBufferCZZ);
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
OnPostAdvancePaymentVATUnlinkingOnBeforePost(
SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, VATPostingSetup,
AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
GLEntryNo := RunGenJnlPostLine(GenJournalLine, GenJnlPostLine, true, true, false);
+ VATEntryNo := GenJnlPostLine.GetNextVATEntryNo() - 1;
OnPostAdvancePaymentVATUnlinkingOnAfterPost(
SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, VATPostingSetup,
AdvancePostingParametersCZZ, GLEntryNo, GenJnlPostLine, GenJournalLine);
@@ -399,8 +408,9 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
TempSalesAdvLetterEntryCZZGlob.CopyFromGenJnlLine(GenJournalLine);
TempSalesAdvLetterEntryCZZGlob."Entry Type" := "Advance Letter Entry Type CZZ"::"VAT Payment";
TempSalesAdvLetterEntryCZZGlob."Sales Adv. Letter No." := SalesAdvLetterHeaderCZZ."No.";
- TempSalesAdvLetterEntryCZZGlob."VAT Entry No." := GenJnlPostLine.GetNextVATEntryNo() - 1;
+ TempSalesAdvLetterEntryCZZGlob."VAT Entry No." := VATEntryNo;
TempSalesAdvLetterEntryCZZGlob."VAT Identifier" := VATPostingSetup."VAT Identifier";
+ TempSalesAdvLetterEntryCZZGlob."Auxiliary Entry" := AdvancePostingBufferCZZ."Auxiliary Entry";
TempSalesAdvLetterEntryCZZGlob.Cancelled := true;
EntryNo := TempSalesAdvLetterEntryCZZGlob.InsertNewEntry(not AdvancePostingParametersCZZ."Temporary Entries Only");
@@ -411,7 +421,7 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
InitGenJournalLine(SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingParametersCZZ2, GenJournalLine);
GenJournalLine."Account No." := VATPostingSetup.GetSalesAdvLetterAccountCZZ();
GenJournalLine.CopyFromAdvancePostingBufferAmountsCZZ(AdvancePostingBufferCZZ);
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
OnPostAdvancePaymentVATUnlinkingOnBeforePostBalance(
SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
@@ -573,7 +583,7 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ")
var
- SalesAdvLetterEntryCZZ2: Record "Sales Adv. Letter Entry CZZ";
+ RelatedSalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ";
IsHandled: Boolean;
begin
IsHandled := false;
@@ -586,12 +596,12 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
exit;
SalesAdvLetterEntryCZZ.TestField(Cancelled, false);
- SalesAdvLetterEntryCZZ2.Get(SalesAdvLetterEntryCZZ."Related Entry");
- if SalesAdvLetterEntryCZZ2."Entry Type" <> SalesAdvLetterEntryCZZ2."Entry Type"::Payment then
+ RelatedSalesAdvLetterEntryCZZ.Get(SalesAdvLetterEntryCZZ."Related Entry");
+ if RelatedSalesAdvLetterEntryCZZ."Entry Type" <> RelatedSalesAdvLetterEntryCZZ."Entry Type"::Payment then
exit;
ReverseAdvancePaymentVAT(
- SalesAdvLetterEntryCZZ2, AdvancePostingBufferCZZ, SalesAdvLetterEntryCZZ."Entry No.",
+ RelatedSalesAdvLetterEntryCZZ, AdvancePostingBufferCZZ, SalesAdvLetterEntryCZZ."Entry No.",
"Advance Letter Entry Type CZZ"::"VAT Usage", GenJnlPostLine, AdvancePostingParametersCZZ);
OnAfterPostAdvancePaymentUsageVAT(
@@ -606,13 +616,13 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
var
AdvancePostingParametersCZZ2: Record "Advance Posting Parameters CZZ";
GenJournalLine: Record "Gen. Journal Line";
- SalesAdvLetterEntryCZZ2: Record "Sales Adv. Letter Entry CZZ";
- SalesAdvLetterEntryCZZ3: Record "Sales Adv. Letter Entry CZZ";
+ RelatedSalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ";
+ VATDocumentSalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ";
SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ";
TempAdvancePostingBufferCZZ: Record "Advance Posting Buffer CZZ" temporary;
VATPostingSetup: Record "VAT Posting Setup";
ExchRateAmount, ExchRateVATAmount : Decimal;
- GLEntryNo: Integer;
+ GLEntryNo, VATEntryNo : Integer;
IsHandled: Boolean;
begin
IsHandled := false;
@@ -631,12 +641,15 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
Error(NothingToPostErr);
if SalesAdvLetterEntryCZZ."Currency Code" <> '' then begin
- SalesAdvLetterEntryCZZ2.Get(SalesAdvLetterEntryCZZ."Related Entry");
- BufferAdvanceVATLines(SalesAdvLetterEntryCZZ2, TempAdvancePostingBufferCZZ, 0D);
+ RelatedSalesAdvLetterEntryCZZ.Get(SalesAdvLetterEntryCZZ."Related Entry");
+ BufferAdvanceVATLines(RelatedSalesAdvLetterEntryCZZ, TempAdvancePostingBufferCZZ, 0D);
end;
AdvancePostingBufferCZZ.FindSet();
repeat
+ GLEntryNo := 0;
+ VATEntryNo := 0;
+
VATPostingSetup.Get(AdvancePostingBufferCZZ."VAT Bus. Posting Group", AdvancePostingBufferCZZ."VAT Prod. Posting Group");
// Post credit memo VAT
@@ -645,11 +658,12 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
GenJournalLine."Gen. Posting Type" := GenJournalLine."Gen. Posting Type"::Sale;
AdvancePostingBufferCZZ.ReverseAmounts();
GenJournalLine.CopyFromAdvancePostingBufferCZZ(AdvancePostingBufferCZZ);
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
OnPostAdvanceCreditMemoVATOnBeforePost(
SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
GLEntryNo := RunGenJnlPostLine(GenJournalLine, GenJnlPostLine, true, true, false);
+ VATEntryNo := GenJnlPostLine.GetNextVATEntryNo() - 1;
OnPostAdvanceCreditMemoVATOnAfterPost(
SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
AdvancePostingParametersCZZ, GLEntryNo, GenJnlPostLine, GenJournalLine);
@@ -660,8 +674,9 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
TempSalesAdvLetterEntryCZZGlob.CopyFromGenJnlLine(GenJournalLine);
TempSalesAdvLetterEntryCZZGlob."Entry Type" := "Advance Letter Entry Type CZZ"::"VAT Payment";
TempSalesAdvLetterEntryCZZGlob."Sales Adv. Letter No." := SalesAdvLetterHeaderCZZ."No.";
- TempSalesAdvLetterEntryCZZGlob."VAT Entry No." := GenJnlPostLine.GetNextVATEntryNo() - 1;
+ TempSalesAdvLetterEntryCZZGlob."VAT Entry No." := VATEntryNo;
TempSalesAdvLetterEntryCZZGlob."VAT Identifier" := VATPostingSetup."VAT Identifier";
+ TempSalesAdvLetterEntryCZZGlob."Auxiliary Entry" := AdvancePostingBufferCZZ."Auxiliary Entry";
TempSalesAdvLetterEntryCZZGlob.Cancelled := true;
TempSalesAdvLetterEntryCZZGlob.InsertNewEntry(not AdvancePostingParametersCZZ."Temporary Entries Only");
@@ -678,25 +693,27 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
AdvancePostingParametersCZZ2."Currency Code" := '';
AdvancePostingParametersCZZ2."Currency Factor" := 0;
- SalesAdvLetterEntryCZZ3.Reset();
- SalesAdvLetterEntryCZZ3.SetRange("Sales Adv. Letter No.", SalesAdvLetterEntryCZZ."Sales Adv. Letter No.");
- SalesAdvLetterEntryCZZ3.SetRange("Document No.", SalesAdvLetterEntryCZZ."Document No.");
- SalesAdvLetterEntryCZZ3.SetRange("Entry Type", SalesAdvLetterEntryCZZ."Entry Type");
- SalesAdvLetterEntryCZZ3.SetRange("VAT Bus. Posting Group", AdvancePostingBufferCZZ."VAT Bus. Posting Group");
- SalesAdvLetterEntryCZZ3.SetRange("VAT Prod. Posting Group", AdvancePostingBufferCZZ."VAT Prod. Posting Group");
- SalesAdvLetterEntryCZZ3.SetRange(Cancelled, false);
- SalesAdvLetterEntryCZZ3.CalcSums("Amount (LCY)", "VAT Amount (LCY)");
-
- ExchRateAmount := -SalesAdvLetterEntryCZZ3."Amount (LCY)" - GenJournalLine."Amount (LCY)";
- ExchRateVATAmount := -SalesAdvLetterEntryCZZ3."VAT Amount (LCY)" - GenJournalLine."VAT Amount (LCY)";
+ VATDocumentSalesAdvLetterEntryCZZ.Reset();
+ VATDocumentSalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", SalesAdvLetterEntryCZZ."Sales Adv. Letter No.");
+ VATDocumentSalesAdvLetterEntryCZZ.SetRange("Document No.", SalesAdvLetterEntryCZZ."Document No.");
+ VATDocumentSalesAdvLetterEntryCZZ.SetRange("Entry Type", SalesAdvLetterEntryCZZ."Entry Type");
+ VATDocumentSalesAdvLetterEntryCZZ.SetRange("VAT Bus. Posting Group", AdvancePostingBufferCZZ."VAT Bus. Posting Group");
+ VATDocumentSalesAdvLetterEntryCZZ.SetRange("VAT Prod. Posting Group", AdvancePostingBufferCZZ."VAT Prod. Posting Group");
+ VATDocumentSalesAdvLetterEntryCZZ.SetRange(Cancelled, false);
+ VATDocumentSalesAdvLetterEntryCZZ.CalcSums("Amount (LCY)", "VAT Amount (LCY)");
+
+ ExchRateAmount := -VATDocumentSalesAdvLetterEntryCZZ."Amount (LCY)" - GenJournalLine."Amount (LCY)";
+ ExchRateVATAmount := -VATDocumentSalesAdvLetterEntryCZZ."VAT Amount (LCY)" - GenJournalLine."VAT Amount (LCY)";
if (ExchRateAmount <> 0) or (ExchRateVATAmount <> 0) then
PostExchangeRate(SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, VATPostingSetup, ExchRateAmount, ExchRateVATAmount,
- SalesAdvLetterEntryCZZ."Related Entry", true, GenJnlPostLine, AdvancePostingParametersCZZ2);
+ SalesAdvLetterEntryCZZ."Related Entry", true, AdvancePostingBufferCZZ."Auxiliary Entry",
+ GenJnlPostLine, AdvancePostingParametersCZZ2);
ReverseUnrealizedExchangeRate(
- SalesAdvLetterEntryCZZ2, SalesAdvLetterHeaderCZZ, VATPostingSetup,
+ RelatedSalesAdvLetterEntryCZZ, SalesAdvLetterHeaderCZZ, VATPostingSetup,
AdvancePostingBufferCZZ.Amount / TempAdvancePostingBufferCZZ.Amount,
- SalesAdvLetterEntryCZZ2."Entry No.", GenJnlPostLine, AdvancePostingParametersCZZ2);
+ RelatedSalesAdvLetterEntryCZZ."Entry No.", AdvancePostingBufferCZZ."Auxiliary Entry",
+ GenJnlPostLine, AdvancePostingParametersCZZ2);
end;
// Post balance of credit memo VAT
@@ -705,7 +722,7 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
InitGenJournalLine(SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingParametersCZZ2, GenJournalLine);
GenJournalLine."Account No." := VATPostingSetup.GetSalesAdvLetterAccountCZZ();
GenJournalLine.CopyFromAdvancePostingBufferAmountsCZZ(AdvancePostingBufferCZZ);
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
OnPostAdvanceCreditMemoVATOnBeforePostBalance(
SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
@@ -717,12 +734,12 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
until AdvancePostingBufferCZZ.Next() = 0;
if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
- SalesAdvLetterEntryCZZ3.Reset();
- SalesAdvLetterEntryCZZ3.SetRange("Sales Adv. Letter No.", SalesAdvLetterEntryCZZ."Sales Adv. Letter No.");
- SalesAdvLetterEntryCZZ3.SetRange("Document No.", SalesAdvLetterEntryCZZ."Document No.");
- SalesAdvLetterEntryCZZ3.SetRange("Entry Type", SalesAdvLetterEntryCZZ."Entry Type");
- SalesAdvLetterEntryCZZ3.SetRange(Cancelled, false);
- SalesAdvLetterEntryCZZ3.ModifyAll(Cancelled, true);
+ VATDocumentSalesAdvLetterEntryCZZ.Reset();
+ VATDocumentSalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", SalesAdvLetterEntryCZZ."Sales Adv. Letter No.");
+ VATDocumentSalesAdvLetterEntryCZZ.SetRange("Document No.", SalesAdvLetterEntryCZZ."Document No.");
+ VATDocumentSalesAdvLetterEntryCZZ.SetRange("Entry Type", SalesAdvLetterEntryCZZ."Entry Type");
+ VATDocumentSalesAdvLetterEntryCZZ.SetRange(Cancelled, false);
+ VATDocumentSalesAdvLetterEntryCZZ.ModifyAll(Cancelled, true);
end;
OnAfterPostAdvanceCreditMemoVAT(
@@ -794,7 +811,8 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
VATPostingSetup.Get(SalesAdvLetterEntryCZZ."VAT Bus. Posting Group", SalesAdvLetterEntryCZZ."VAT Prod. Posting Group");
PostUnrealizedExchangeRate(SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, VATPostingSetup,
-SalesAdvLetterEntryCZZ."Amount (LCY)", -SalesAdvLetterEntryCZZ."VAT Amount (LCY)",
- SalesAdvLetterEntryCZZ."Related Entry", 0, true, GenJnlPostLine, AdvancePostingParametersCZZ2);
+ SalesAdvLetterEntryCZZ."Related Entry", 0, true, SalesAdvLetterEntryCZZ."Auxiliary Entry",
+ GenJnlPostLine, AdvancePostingParametersCZZ2);
end;
SalesAdvLetterEntryCZZ."Entry Type"::"VAT Rate":
begin
@@ -803,7 +821,8 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
VATPostingSetup.Get(SalesAdvLetterEntryCZZ."VAT Bus. Posting Group", SalesAdvLetterEntryCZZ."VAT Prod. Posting Group");
PostExchangeRate(SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, VATPostingSetup,
-SalesAdvLetterEntryCZZ."Amount (LCY)", -SalesAdvLetterEntryCZZ."VAT Amount (LCY)",
- SalesAdvLetterEntryCZZ."Related Entry", true, GenJnlPostLine, AdvancePostingParametersCZZ2);
+ SalesAdvLetterEntryCZZ."Related Entry", true, SalesAdvLetterEntryCZZ."Auxiliary Entry",
+ GenJnlPostLine, AdvancePostingParametersCZZ2);
end;
SalesAdvLetterEntryCZZ."Entry Type"::"VAT Usage":
begin
@@ -845,8 +864,7 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
AdvancePostingParametersCZZ2: Record "Advance Posting Parameters CZZ";
GenJournalLine: Record "Gen. Journal Line";
VATPostingSetup: Record "VAT Posting Setup";
- EntryNo: Integer;
- GLEntryNo: Integer;
+ EntryNo, GLEntryNo, VATEntryNo : Integer;
IsHandled: Boolean;
begin
IsHandled := false;
@@ -855,6 +873,9 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
if IsHandled then
exit;
+ GLEntryNo := 0;
+ VATEntryNo := 0;
+
VATPostingSetup.Get(AdvancePostingBufferCZZ."VAT Bus. Posting Group", AdvancePostingBufferCZZ."VAT Prod. Posting Group");
InitGenJournalLine(
@@ -864,11 +885,12 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
GenJournalLine.Correction := true;
AdvancePostingBufferCZZ.ReverseAmounts();
GenJournalLine.CopyFromAdvancePostingBufferCZZ(AdvancePostingBufferCZZ);
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
OnPostAdvanceLetterEntryVATUsageUnapplyingOnBeforePost(
SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
GLEntryNo := RunGenJnlPostLine(GenJournalLine, GenJnlPostLine, true, true, false);
+ VATEntryNo := GenJnlPostLine.GetNextVATEntryNo() - 1;
OnPostAdvanceLetterEntryVATUsageUnapplyingOnAfterPost(
SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
AdvancePostingParametersCZZ, GLEntryNo, GenJnlPostLine, GenJournalLine);
@@ -879,8 +901,9 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
TempSalesAdvLetterEntryCZZGlob.CopyFromGenJnlLine(GenJournalLine);
TempSalesAdvLetterEntryCZZGlob."Entry Type" := SalesAdvLetterEntryCZZ."Entry Type";
TempSalesAdvLetterEntryCZZGlob."Sales Adv. Letter No." := SalesAdvLetterHeaderCZZ."No.";
- TempSalesAdvLetterEntryCZZGlob."VAT Entry No." := GenJnlPostLine.GetNextVATEntryNo() - 1;
+ TempSalesAdvLetterEntryCZZGlob."VAT Entry No." := VATEntryNo;
TempSalesAdvLetterEntryCZZGlob."VAT Identifier" := VATPostingSetup."VAT Identifier";
+ TempSalesAdvLetterEntryCZZGlob."Auxiliary Entry" := AdvancePostingBufferCZZ."Auxiliary Entry";
TempSalesAdvLetterEntryCZZGlob.Cancelled := true;
EntryNo := TempSalesAdvLetterEntryCZZGlob.InsertNewEntry(not AdvancePostingParametersCZZ."Temporary Entries Only");
@@ -892,7 +915,7 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
GenJournalLine."Account No." := VATPostingSetup.GetSalesAdvLetterAccountCZZ();
GenJournalLine.Correction := true;
GenJournalLine.CopyFromAdvancePostingBufferAmountsCZZ(AdvancePostingBufferCZZ);
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
OnPostAdvanceLetterEntryVATUsageUnapplyingOnBeforePostBalance(
SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingBufferCZZ,
AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
@@ -1306,13 +1329,13 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ")
var
AdvancePostingParametersCZZ2: Record "Advance Posting Parameters CZZ";
- SalesAdvLetterEntryCZZ2: Record "Sales Adv. Letter Entry CZZ";
+ VATDocumentSalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ";
TempAdvancePostingBufferCZZ: Record "Advance Posting Buffer CZZ" temporary;
GenJournalLine: Record "Gen. Journal Line";
VATPostingSetup: Record "VAT Posting Setup";
SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ";
CalcVATAmountLCY, CalcAmountLCY, ExchRateAmount, ExchRateVATAmount, AmountToUse : Decimal;
- GLEntryNo: Integer;
+ GLEntryNo, VATEntryNo : Integer;
IsHandled: Boolean;
begin
IsHandled := false;
@@ -1328,11 +1351,12 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
if SalesAdvLetterEntryCZZ."Entry Type" <> SalesAdvLetterEntryCZZ."Entry Type"::Payment then
exit;
- SalesAdvLetterEntryCZZ2.SetRange("Sales Adv. Letter No.", SalesAdvLetterEntryCZZ."Sales Adv. Letter No.");
- SalesAdvLetterEntryCZZ2.SetRange(Cancelled, false);
- SalesAdvLetterEntryCZZ2.SetRange("Related Entry", SalesAdvLetterEntryCZZ."Entry No.");
- SalesAdvLetterEntryCZZ2.SetRange("Entry Type", SalesAdvLetterEntryCZZ2."Entry Type"::"VAT Payment");
- if SalesAdvLetterEntryCZZ2.IsEmpty() then
+ VATDocumentSalesAdvLetterEntryCZZ.Reset();
+ VATDocumentSalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", SalesAdvLetterEntryCZZ."Sales Adv. Letter No.");
+ VATDocumentSalesAdvLetterEntryCZZ.SetRange(Cancelled, false);
+ VATDocumentSalesAdvLetterEntryCZZ.SetRange("Related Entry", SalesAdvLetterEntryCZZ."Entry No.");
+ VATDocumentSalesAdvLetterEntryCZZ.SetRange("Entry Type", VATDocumentSalesAdvLetterEntryCZZ."Entry Type"::"VAT Payment");
+ if VATDocumentSalesAdvLetterEntryCZZ.IsEmpty() then
exit;
AdvancePostingBufferCZZ.FilterGroup(-1);
@@ -1352,6 +1376,9 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
AdvancePostingBufferCZZ.FindSet();
repeat
+ GLEntryNo := 0;
+ VATEntryNo := 0;
+
VATPostingSetup.Get(AdvancePostingBufferCZZ."VAT Bus. Posting Group", AdvancePostingBufferCZZ."VAT Prod. Posting Group");
// Post reverse advance payment VAT
@@ -1360,11 +1387,12 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
GenJournalLine."Gen. Posting Type" := GenJournalLine."Gen. Posting Type"::Sale;
AdvancePostingBufferCZZ.ReverseAmounts();
GenJournalLine.CopyFromAdvancePostingBufferCZZ(AdvancePostingBufferCZZ);
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
OnReverseAdvancePaymentVATOnBeforePost(
SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, VATPostingSetup,
AdvancePostingBufferCZZ, AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
GLEntryNo := RunGenJnlPostLine(GenJournalLine, GenJnlPostLine, true, true, false);
+ VATEntryNo := GenJnlPostLine.GetNextVATEntryNo() - 1;
OnReverseAdvancePaymentVATOnAfterPost(
SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, VATPostingSetup, AdvancePostingBufferCZZ,
AdvancePostingParametersCZZ, GLEntryNo, GenJnlPostLine, GenJournalLine);
@@ -1375,8 +1403,9 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
TempSalesAdvLetterEntryCZZGlob.CopyFromGenJnlLine(GenJournalLine);
TempSalesAdvLetterEntryCZZGlob."Entry Type" := EntryType;
TempSalesAdvLetterEntryCZZGlob."Sales Adv. Letter No." := SalesAdvLetterHeaderCZZ."No.";
- TempSalesAdvLetterEntryCZZGlob."VAT Entry No." := GenJnlPostLine.GetNextVATEntryNo() - 1;
+ TempSalesAdvLetterEntryCZZGlob."VAT Entry No." := VATEntryNo;
TempSalesAdvLetterEntryCZZGlob."VAT Identifier" := VATPostingSetup."VAT Identifier";
+ TempSalesAdvLetterEntryCZZGlob."Auxiliary Entry" := AdvancePostingBufferCZZ."Auxiliary Entry";
TempSalesAdvLetterEntryCZZGlob.InsertNewEntry(not AdvancePostingParametersCZZ."Temporary Entries Only");
AdvancePostingBufferCZZ.ReverseAmounts();
@@ -1398,12 +1427,12 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
ExchRateVATAmount := -CalcVATAmountLCY - GenJournalLine."VAT Amount (LCY)";
if (ExchRateAmount <> 0) or (ExchRateVATAmount <> 0) then
PostExchangeRate(SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, VATPostingSetup, ExchRateAmount, ExchRateVATAmount,
- RelatedEntryNo, false, GenJnlPostLine, AdvancePostingParametersCZZ2);
+ RelatedEntryNo, false, AdvancePostingBufferCZZ."Auxiliary Entry", GenJnlPostLine, AdvancePostingParametersCZZ2);
AdvancePostingParametersCZZ2."Source Code" := '';
ReverseUnrealizedExchangeRate(
SalesAdvLetterEntryCZZ, SalesAdvLetterHeaderCZZ, VATPostingSetup, AdvancePostingBufferCZZ.Amount / AmountToUse,
- RelatedEntryNo, GenJnlPostLine, AdvancePostingParametersCZZ2);
+ RelatedEntryNo, AdvancePostingBufferCZZ."Auxiliary Entry", GenJnlPostLine, AdvancePostingParametersCZZ2);
end;
// Post balance of reverse advance payment VAT
@@ -1412,7 +1441,7 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
InitGenJournalLine(SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, AdvancePostingParametersCZZ2, GenJournalLine);
GenJournalLine."Account No." := VATPostingSetup.GetSalesAdvLetterAccountCZZ();
GenJournalLine.CopyFromAdvancePostingBufferAmountsCZZ(AdvancePostingBufferCZZ);
- if not AdvancePostingParametersCZZ."Temporary Entries Only" then begin
+ if not AdvancePostingParametersCZZ."Temporary Entries Only" and not AdvancePostingBufferCZZ."Auxiliary Entry" then begin
OnReverseAdvancePaymentVATOnBeforePostBalance(
SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, VATPostingSetup,
AdvancePostingBufferCZZ, AdvancePostingParametersCZZ, GenJnlPostLine, GenJournalLine);
@@ -1436,6 +1465,7 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
VATPostingSetup: Record "VAT Posting Setup";
Coef: Decimal;
RelatedEntryNo: Integer;
+ AuxiliaryEntry: Boolean;
var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ")
var
@@ -1463,7 +1493,7 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
PostUnrealizedExchangeRate(
SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, VATPostingSetup, -AmountLCY, -VATAmountLCY,
- RelatedEntryNo, 0, false, GenJnlPostLine, AdvancePostingParametersCZZ);
+ RelatedEntryNo, 0, false, AuxiliaryEntry, GenJnlPostLine, AdvancePostingParametersCZZ);
end;
local procedure PostExchangeRate(
@@ -1474,6 +1504,7 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
VATAmount: Decimal;
RelatedEntryNo: Integer;
Correction: Boolean;
+ AuxiliaryEntry: Boolean;
var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ")
var
@@ -1561,6 +1592,7 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
TempSalesAdvLetterEntryCZZGlob."Global Dimension 2 Code" := SalesAdvLetterEntryCZZ."Global Dimension 2 Code";
TempSalesAdvLetterEntryCZZGlob."Dimension Set ID" := SalesAdvLetterEntryCZZ."Dimension Set ID";
TempSalesAdvLetterEntryCZZGlob.Cancelled := Correction;
+ TempSalesAdvLetterEntryCZZGlob."Auxiliary Entry" := AuxiliaryEntry;
OnPostExchangeRateOnBeforeInsertEntry(
SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, VATPostingSetup,
AdvancePostingParametersCZZ, TempSalesAdvLetterEntryCZZGlob);
@@ -1580,6 +1612,7 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
RelatedEntryNo: Integer;
RelatedDetEntryNo: Integer;
Correction: Boolean;
+ AuxiliaryEntry: Boolean;
var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
AdvancePostingParametersCZZ: Record "Advance Posting Parameters CZZ")
var
@@ -1654,6 +1687,7 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
TempSalesAdvLetterEntryCZZGlob."Global Dimension 2 Code" := SalesAdvLetterEntryCZZ."Global Dimension 2 Code";
TempSalesAdvLetterEntryCZZGlob."Dimension Set ID" := SalesAdvLetterEntryCZZ."Dimension Set ID";
TempSalesAdvLetterEntryCZZGlob.Cancelled := Correction;
+ TempSalesAdvLetterEntryCZZGlob."Auxiliary Entry" := AuxiliaryEntry;
OnPostUnrealizedExchangeRateOnBeforeInsertEntry(
SalesAdvLetterHeaderCZZ, SalesAdvLetterEntryCZZ, VATPostingSetup,
AdvancePostingParametersCZZ, TempSalesAdvLetterEntryCZZGlob);
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/UpgradeApplicationCZZ.Codeunit.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/UpgradeApplicationCZZ.Codeunit.al
index 1f83d371c2..89f8922b77 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/UpgradeApplicationCZZ.Codeunit.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/UpgradeApplicationCZZ.Codeunit.al
@@ -46,6 +46,7 @@ codeunit 31088 "Upgrade Application CZZ"
InstallApplicationCZZ.CopyData();
UpgradeCustomerNoInSalesAdvLetterEntries();
UpgradeAdvanceLetterApplicationAmountLCY();
+ UpgradePostVATDocForReverseCharge();
end;
local procedure UpgradeAdvancePaymentsReportReportSelections();
@@ -121,6 +122,21 @@ codeunit 31088 "Upgrade Application CZZ"
UpgradeTag.SetUpgradeTag(UpgradeTagDefinitionsCZZ.GetAdvanceLetterApplicationAmountLCYUpgradeTag());
end;
+ local procedure UpgradePostVATDocForReverseCharge()
+ var
+ AdvanceLetterTemplate: Record "Advance Letter Template CZZ";
+ AdvLetterTemplateDataTransfer: DataTransfer;
+ begin
+ if UpgradeTag.HasUpgradeTag(UpgradeTagDefinitionsCZZ.GetPostVATDocForReverseChargeUpgradeTag()) then
+ exit;
+
+ AdvLetterTemplateDataTransfer.SetTables(Database::"Advance Letter Template CZZ", Database::"Advance Letter Template CZZ");
+ AdvLetterTemplateDataTransfer.AddConstantValue(true, AdvanceLetterTemplate.FieldNo("Post VAT Doc. for Rev. Charge"));
+ AdvLetterTemplateDataTransfer.CopyFields();
+
+ UpgradeTag.SetUpgradeTag(UpgradeTagDefinitionsCZZ.GetPostVATDocForReverseChargeUpgradeTag());
+ end;
+
local procedure GetCurrencyFactor(AdvanceLetterType: Enum "Advance Letter Type CZZ"; AdvanceLetterNo: Code[20]): Decimal
var
PurchAdvLetterHeader: Record "Purch. Adv. Letter Header CZZ";
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/UpgradeTagDefinitionsCZZ.Codeunit.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/UpgradeTagDefinitionsCZZ.Codeunit.al
index af436f1592..13f89997d8 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/UpgradeTagDefinitionsCZZ.Codeunit.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Codeunits/UpgradeTagDefinitionsCZZ.Codeunit.al
@@ -24,6 +24,7 @@ codeunit 31089 "Upgrade Tag Definitions CZZ"
PerCompanyUpgradeTags.Add(GetDataVersion210PerCompanyUpgradeTag());
PerCompanyUpgradeTags.Add(GetSalesAdvLetterEntryCustomerNoUpgradeTag());
PerCompanyUpgradeTags.Add(GetAdvanceLetterApplicationAmountLCYUpgradeTag());
+ PerCompanyUpgradeTags.Add(GetPostVATDocForReverseChargeUpgradeTag());
end;
procedure GetDataVersion190PerDatabaseUpgradeTag(): Code[250]
@@ -65,4 +66,9 @@ codeunit 31089 "Upgrade Tag Definitions CZZ"
begin
exit('CZZ-478403-AdvanceLetterApplicationAmountLCYUpgradeTag-20230717');
end;
+
+ procedure GetPostVATDocForReverseChargeUpgradeTag(): Code[250]
+ begin
+ exit('CZZ-494279-PostVATDocForReverseChargeUpgradeTag-20240426');
+ end;
}
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Pages/AdvanceLetterApplEditCZZ.Page.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Pages/AdvanceLetterApplEditCZZ.Page.al
index 17afa64d7a..236139c79d 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Pages/AdvanceLetterApplEditCZZ.Page.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Pages/AdvanceLetterApplEditCZZ.Page.al
@@ -35,6 +35,8 @@ page 31175 "Advance Letter Appl. Edit CZZ"
trigger OnLookup(var Text: Text): Boolean
begin
+ OnBeforeOnLookupAdvanceLetterNo(Rec, TempAdvanceLetterApplication);
+
if Page.RunModal(Page::"Advance Letter Application CZZ", TempAdvanceLetterApplication) = Action::LookupOK then
Rec.CopyFrom(TempAdvanceLetterApplication);
end;
@@ -156,4 +158,9 @@ page 31175 "Advance Letter Appl. Edit CZZ"
end;
until Rec.Next() = 0;
end;
+
+ [IntegrationEvent(true, false)]
+ local procedure OnBeforeOnLookupAdvanceLetterNo(var AdvanceLetterApplicationCZZ: Record "Advance Letter Application CZZ"; var TempAdvanceLetterApplicationCZZ: Record "Advance Letter Application CZZ" temporary)
+ begin
+ end;
}
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Pages/AdvanceLetterTemplatesCZZ.Page.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Pages/AdvanceLetterTemplatesCZZ.Page.al
index 18a33e3b61..5ba015d3f2 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Pages/AdvanceLetterTemplatesCZZ.Page.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Pages/AdvanceLetterTemplatesCZZ.Page.al
@@ -64,6 +64,11 @@ page 31179 "Advance Letter Templates CZZ"
ApplicationArea = Basic, Suite;
ToolTip = 'Specifies automatic post VAT document.';
}
+ field("Post VAT Doc. for Rev. Charge"; Rec."Post VAT Doc. for Rev. Charge")
+ {
+ ApplicationArea = Basic, Suite;
+ ToolTip = 'Specifies whether the VAT document will be posting for reverse charge.';
+ }
#if not CLEAN23
#pragma warning disable AL0432,AS0074
field("Document Report ID"; '')
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Reports/PurchaseAdvanceVATDocCZZ.Report.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Reports/PurchaseAdvanceVATDocCZZ.Report.al
index 84328cdcca..11c21ab3b7 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Reports/PurchaseAdvanceVATDocCZZ.Report.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Reports/PurchaseAdvanceVATDocCZZ.Report.al
@@ -270,7 +270,7 @@ report 31017 "Purchase - Advance VAT Doc.CZZ"
{
DataItemLink = "Purch. Adv. Letter No." = field("Purch. Adv. Letter No."), "Document No." = field("Document No.");
DataItemLinkReference = TempPurchAdvLetterEntry;
- DataItemTableView = sorting("Document No.") where("Entry Type" = filter("VAT Payment" | "VAT Usage" | "VAT Close"));
+ DataItemTableView = sorting("Document No.") where("Entry Type" = filter("VAT Payment" | "VAT Usage" | "VAT Close"), "Auxiliary Entry" = const(false));
trigger OnAfterGetRecord()
begin
@@ -492,9 +492,12 @@ report 31017 "Purchase - Advance VAT Doc.CZZ"
NoOfCop: Integer;
local procedure IsCreditMemo(PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ"): Boolean
+ var
+ DocumentAmount: Decimal;
begin
- exit(((PurchAdvLetterEntryCZZ.CalcDocumentAmount() < 0) and (PurchAdvLetterEntryCZZ."Entry Type" = PurchAdvLetterEntryCZZ."Entry Type"::"VAT Payment")) or
- ((PurchAdvLetterEntryCZZ.CalcDocumentAmount() > 0) and (PurchAdvLetterEntryCZZ."Entry Type" = PurchAdvLetterEntryCZZ."Entry Type"::"VAT Usage")) or
+ DocumentAmount := PurchAdvLetterEntryCZZ.CalcDocumentAmount();
+ exit(((PurchAdvLetterEntryCZZ."Entry Type" = PurchAdvLetterEntryCZZ."Entry Type"::"VAT Payment") and (DocumentAmount < 0)) or
+ ((PurchAdvLetterEntryCZZ."Entry Type" = PurchAdvLetterEntryCZZ."Entry Type"::"VAT Usage") and (DocumentAmount > 0)) or
(PurchAdvLetterEntryCZZ."Entry Type" = PurchAdvLetterEntryCZZ."Entry Type"::"VAT Close"));
end;
}
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Reports/PurchaseInvoicewithAdvCZZ.Report.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Reports/PurchaseInvoicewithAdvCZZ.Report.al
index 97de61978b..efb3090c17 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Reports/PurchaseInvoicewithAdvCZZ.Report.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Reports/PurchaseInvoicewithAdvCZZ.Report.al
@@ -634,7 +634,15 @@ report 31028 "Purchase-Invoice with Adv. CZZ"
}
trigger OnAfterGetRecord()
+ var
+ PurchAdvLetterEntryCZZVATUsage: Record "Purch. Adv. Letter Entry CZZ";
begin
+ PurchAdvLetterEntryCZZVATUsage.SetRange("Entry Type", PurchAdvLetterEntryCZZVATUsage."Entry Type"::"VAT Usage");
+ PurchAdvLetterEntryCZZVATUsage.SetRange("Related Entry", PurchAdvanceUsage."Entry No.");
+ PurchAdvLetterEntryCZZVATUsage.Setrange("Auxiliary Entry", false);
+ if PurchAdvLetterEntryCZZVATUsage.IsEmpty() then
+ CurrReport.Break();
+
SetRange("Purch. Adv. Letter No.", "Purch. Adv. Letter No.");
SetRange("Document No.", "Document No.");
FindLast();
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Reports/SalesAdvanceVATDocCZZ.Report.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Reports/SalesAdvanceVATDocCZZ.Report.al
index f6f667d130..04589af441 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Reports/SalesAdvanceVATDocCZZ.Report.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Reports/SalesAdvanceVATDocCZZ.Report.al
@@ -290,7 +290,7 @@ report 31015 "Sales - Advance VAT Doc. CZZ"
{
DataItemLink = "Sales Adv. Letter No." = field("Sales Adv. Letter No."), "Document No." = field("Document No.");
DataItemLinkReference = TempSalesAdvLetterEntry;
- DataItemTableView = sorting("Document No.") where("Entry Type" = filter("VAT Payment" | "VAT Usage" | "VAT Close"));
+ DataItemTableView = sorting("Document No.") where("Entry Type" = filter("VAT Payment" | "VAT Usage" | "VAT Close"), "Auxiliary Entry" = const(false));
trigger OnAfterGetRecord()
begin
@@ -542,9 +542,12 @@ report 31015 "Sales - Advance VAT Doc. CZZ"
NoOfCop: Integer;
local procedure IsCreditMemo(SalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ"): Boolean
+ var
+ DocumentAmount: Decimal;
begin
- exit(((SalesAdvLetterEntryCZZ.CalcDocumentAmount() > 0) and (SalesAdvLetterEntryCZZ."Entry Type" = SalesAdvLetterEntryCZZ."Entry Type"::"VAT Payment")) or
- ((SalesAdvLetterEntryCZZ.CalcDocumentAmount() < 0) and (SalesAdvLetterEntryCZZ."Entry Type" = SalesAdvLetterEntryCZZ."Entry Type"::"VAT Usage")) or
+ DocumentAmount := SalesAdvLetterEntryCZZ.CalcDocumentAmount();
+ exit(((SalesAdvLetterEntryCZZ."Entry Type" = SalesAdvLetterEntryCZZ."Entry Type"::"VAT Payment") and (DocumentAmount > 0)) or
+ ((SalesAdvLetterEntryCZZ."Entry Type" = SalesAdvLetterEntryCZZ."Entry Type"::"VAT Usage") and (DocumentAmount < 0)) or
(SalesAdvLetterEntryCZZ."Entry Type" = SalesAdvLetterEntryCZZ."Entry Type"::"VAT Close"));
end;
}
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Reports/SalesInvoicewithAdvCZZ.Report.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Reports/SalesInvoicewithAdvCZZ.Report.al
index 21ccb4041b..f11258edcd 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Reports/SalesInvoicewithAdvCZZ.Report.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Reports/SalesInvoicewithAdvCZZ.Report.al
@@ -462,7 +462,15 @@ report 31018 "Sales - Invoice with Adv. CZZ"
}
trigger OnAfterGetRecord()
+ var
+ SalesAdvLetterEntryCZZVATUsage: Record "Sales Adv. Letter Entry CZZ";
begin
+ SalesAdvLetterEntryCZZVATUsage.SetRange("Entry Type", SalesAdvLetterEntryCZZVATUsage."Entry Type"::"VAT Usage");
+ SalesAdvLetterEntryCZZVATUsage.SetRange("Related Entry", SalesAdvanceUsage."Entry No.");
+ SalesAdvLetterEntryCZZVATUsage.Setrange("Auxiliary Entry", false);
+ if SalesAdvLetterEntryCZZVATUsage.IsEmpty() then
+ CurrReport.Break();
+
SetRange("Sales Adv. Letter No.", "Sales Adv. Letter No.");
SetRange("Document No.", "Document No.");
FindLast();
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/TableExtensions/GenJournalLineCZZ.TableExt.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/TableExtensions/GenJournalLineCZZ.TableExt.al
index 762ef455c5..b26b42d62a 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/TableExtensions/GenJournalLineCZZ.TableExt.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/TableExtensions/GenJournalLineCZZ.TableExt.al
@@ -167,7 +167,12 @@ tableextension 31004 "Gen. Journal Line CZZ" extends "Gen. Journal Line"
"Registration No. CZL" := SalesAdvLetterHeaderCZZ."Registration No.";
"Tax Registration No. CZL" := SalesAdvLetterHeaderCZZ."Tax Registration No.";
"System-Created Entry" := true;
+#if not CLEAN25
+#pragma warning disable AL0432
OnAfterCopyGenJnlLineFromSalesAdvLetterHeaderCZZ(SalesAdvLetterHeaderCZZ, Rec);
+#pragma warning restore AL0432
+#endif
+ OnAfterCopyGenJournalLineFromSalesAdvLetterHeaderCZZ(SalesAdvLetterHeaderCZZ, Rec);
end;
procedure CopyFromSalesAdvLetterEntryCZZ(SalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ")
@@ -176,7 +181,12 @@ tableextension 31004 "Gen. Journal Line CZZ" extends "Gen. Journal Line"
"Shortcut Dimension 2 Code" := SalesAdvLetterEntryCZZ."Global Dimension 2 Code";
"Dimension Set ID" := SalesAdvLetterEntryCZZ."Dimension Set ID";
"Adv. Letter No. (Entry) CZZ" := SalesAdvLetterEntryCZZ."Sales Adv. Letter No.";
+#if not CLEAN25
+#pragma warning disable AL0432
OnAfterCopyGenJnlLineFromSalesAdvLetterEntryCZZ(SalesAdvLetterEntryCZZ, Rec);
+#pragma warning restore AL0432
+#endif
+ OnAfterCopyGenJournalLineFromSalesAdvLetterEntryCZZ(SalesAdvLetterEntryCZZ, Rec);
end;
procedure CopyFromPurchAdvLetterHeaderCZZ(PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ")
@@ -262,20 +272,58 @@ tableextension 31004 "Gen. Journal Line CZZ" extends "Gen. Journal Line"
OnAfterCopyFromVendorLedgerEntryCZZ(VendorLedgerEntry, Rec);
end;
+ procedure GetAdvanceGLAccountNoCZZ(): Code[20]
+ var
+ AdvanceLetterTemplateCZZ: Record "Advance Letter Template CZZ";
+ PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ";
+ SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ";
+ begin
+ case "Account Type" of
+ "Account Type"::Customer:
+ begin
+ SalesAdvLetterHeaderCZZ.Get("Adv. Letter No. (Entry) CZZ");
+ SalesAdvLetterHeaderCZZ.TestField("Advance Letter Code");
+ AdvanceLetterTemplateCZZ.Get(SalesAdvLetterHeaderCZZ."Advance Letter Code");
+ end;
+ "Account Type"::Vendor:
+ begin
+ PurchAdvLetterHeaderCZZ.Get("Adv. Letter No. (Entry) CZZ");
+ PurchAdvLetterHeaderCZZ.TestField("Advance Letter Code");
+ AdvanceLetterTemplateCZZ.Get(PurchAdvLetterHeaderCZZ."Advance Letter Code");
+ end;
+ end;
+
+ AdvanceLetterTemplateCZZ.TestField("Advance Letter G/L Account");
+ exit(AdvanceLetterTemplateCZZ."Advance Letter G/L Account");
+ end;
+
[IntegrationEvent(false, false)]
local procedure OnAfterInitNewLineCZZ(var GenJournalLine: Record "Gen. Journal Line")
begin
end;
-
+#if not CLEAN25
+ [Obsolete('Replaced by OnAfterCopyGenJournalLineFromSalesAdvLetterHeaderCZZ event.', '25.0')]
[IntegrationEvent(false, false)]
local procedure OnAfterCopyGenJnlLineFromSalesAdvLetterHeaderCZZ(SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ"; Rec: Record "Gen. Journal Line")
begin
end;
+ [Obsolete('Replaced by OnAfterCopyGenJournalLineFromSalesAdvLetterEntryCZZ event.', '25.0')]
[IntegrationEvent(false, false)]
local procedure OnAfterCopyGenJnlLineFromSalesAdvLetterEntryCZZ(SalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ"; Rec: Record "Gen. Journal Line")
begin
end;
+#endif
+
+ [IntegrationEvent(false, false)]
+ local procedure OnAfterCopyGenJournalLineFromSalesAdvLetterHeaderCZZ(SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ"; var GenJournalLine: Record "Gen. Journal Line")
+ begin
+ end;
+
+ [IntegrationEvent(false, false)]
+ local procedure OnAfterCopyGenJournalLineFromSalesAdvLetterEntryCZZ(SalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ"; var GenJournalLine: Record "Gen. Journal Line")
+ begin
+ end;
[IntegrationEvent(false, false)]
local procedure OnAfterCopyGenJnlLineFromPurchAdvLetterHeaderCZZ(PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ"; var GenJournalLine: Record "Gen. Journal Line")
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/AdvanceLetterTemplateCZZ.Table.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/AdvanceLetterTemplateCZZ.Table.al
index fd341e1fc1..8adad0f4de 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/AdvanceLetterTemplateCZZ.Table.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/AdvanceLetterTemplateCZZ.Table.al
@@ -146,6 +146,12 @@ table 31003 "Advance Letter Template CZZ"
Caption = 'Automatic Post VAT Document';
DataClassification = CustomerContent;
}
+ field(26; "Post VAT Doc. for Rev. Charge"; Boolean)
+ {
+ Caption = 'Post VAT Document for Reverse Charge';
+ DataClassification = CustomerContent;
+ InitValue = true;
+ }
}
keys
{
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/AdvancePostingBufferCZZ.Table.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/AdvancePostingBufferCZZ.Table.al
index 3f591666ae..87f6e5ce87 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/AdvancePostingBufferCZZ.Table.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/AdvancePostingBufferCZZ.Table.al
@@ -60,6 +60,10 @@ table 31013 "Advance Posting Buffer CZZ"
Caption = 'VAT %';
DecimalPlaces = 1 : 1;
}
+ field(35; "Auxiliary Entry"; Boolean)
+ {
+ Caption = 'Auxiliary Entry';
+ }
}
keys
@@ -83,6 +87,7 @@ table 31013 "Advance Posting Buffer CZZ"
"Amount (ACY)" := PurchAdvLetterEntry."Amount (LCY)";
"VAT Base Amount (ACY)" := PurchAdvLetterEntry."VAT Base Amount (LCY)";
"VAT Amount (ACY)" := PurchAdvLetterEntry."VAT Amount (LCY)";
+ "Auxiliary Entry" := PurchAdvLetterEntry."Auxiliary Entry";
OnAfterPrepareForPurchAdvLetterEntry(PurchAdvLetterEntry, Rec);
end;
@@ -115,6 +120,7 @@ table 31013 "Advance Posting Buffer CZZ"
"Amount (ACY)" := SalesAdvLetterEntry."Amount (LCY)";
"VAT Base Amount (ACY)" := SalesAdvLetterEntry."VAT Base Amount (LCY)";
"VAT Amount (ACY)" := SalesAdvLetterEntry."VAT Amount (LCY)";
+ "Auxiliary Entry" := SalesAdvLetterEntry."Auxiliary Entry";
OnAfterPrepareForSalesAdvLetterEntry(SalesAdvLetterEntry, Rec);
end;
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/PurchAdvLetterEntryCZZ.Table.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/PurchAdvLetterEntryCZZ.Table.al
index db413623a8..888b4989eb 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/PurchAdvLetterEntryCZZ.Table.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/PurchAdvLetterEntryCZZ.Table.al
@@ -189,6 +189,12 @@ table 31009 "Purch. Adv. Letter Entry CZZ"
Caption = 'External Document No.';
DataClassification = CustomerContent;
}
+ field(80; "Auxiliary Entry"; Boolean)
+ {
+ Caption = 'Auxiliary Entry';
+ DataClassification = CustomerContent;
+ Editable = false;
+ }
field(480; "Dimension Set ID"; Integer)
{
Caption = 'Dimension Set ID';
@@ -255,6 +261,7 @@ table 31009 "Purch. Adv. Letter Entry CZZ"
begin
PurchAdvLetterEntryCZZ.SetRange("Document No.", PurchInvHeader."No.");
PurchAdvLetterEntryCZZ.SetRange("Entry Type", PurchAdvLetterEntryCZZ."Entry Type"::"VAT Usage");
+ PurchAdvLetterEntryCZZ.SetRange("Auxiliary Entry", false);
PurchAdvLetterEntryCZZ.SetRange(Cancelled, false);
if PurchAdvLetterEntryCZZ.FindSet() then
repeat
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/PurchAdvLetterHeaderCZZ.Table.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/PurchAdvLetterHeaderCZZ.Table.al
index 1a1eee5d21..847bdca347 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/PurchAdvLetterHeaderCZZ.Table.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/PurchAdvLetterHeaderCZZ.Table.al
@@ -407,8 +407,8 @@ table 31008 "Purch. Adv. Letter Header CZZ"
end;
GetSetup();
- GeneralLedgerSetup.UpdateVATDate("Posting Date", Enum::"VAT Reporting Date"::"Posting Date", "VAT Date");
- Validate("VAT Date");
+ GeneralLedgerSetup.UpdateVATDate("Posting Date", Enum::"VAT Reporting Date"::"Posting Date", "VAT Date");
+ Validate("VAT Date");
GeneralLedgerSetup.UpdateOriginalDocumentVATDateCZL("Posting Date", Enum::"Default Orig.Doc. VAT Date CZL"::"Posting Date", "Original Document VAT Date");
Validate("Original Document VAT Date");
@@ -434,8 +434,8 @@ table 31008 "Purch. Adv. Letter Header CZZ"
Validate("Payment Terms Code");
GetSetup();
- if GeneralLedgerSetup."VAT Reporting Date" = GeneralLedgerSetup."VAT Reporting Date"::"Document Date" then
- Validate("VAT Date", "Document Date");
+ if GeneralLedgerSetup."VAT Reporting Date" = GeneralLedgerSetup."VAT Reporting Date"::"Document Date" then
+ Validate("VAT Date", "Document Date");
GeneralLedgerSetup.UpdateOriginalDocumentVATDateCZL("Document Date", Enum::"Default Orig.Doc. VAT Date CZL"::"Document Date", "Original Document VAT Date");
Validate("Original Document VAT Date");
@@ -855,6 +855,7 @@ table 31008 "Purch. Adv. Letter Header CZZ"
ConfirmChangeQst: Label 'Do you want to change %1?', Comment = '%1 = a Field Caption like Currency Code';
DocumentResetErr: Label 'You cannot reset %1 because the document still has one or more lines.', Comment = '%1 = a Field Caption like Bill-to Contact No.';
DocumentDeleteErr: Label 'You cannot delete this document. Your identification is set up to process from %1 %2 only.', Comment = '%1 = table caption of responsibility center, %2 = code of responsibility center';
+ PostedEntriesExistErr: Label 'You cannot delete this document because there are posted entries.';
trigger OnInsert()
begin
@@ -876,10 +877,16 @@ table 31008 "Purch. Adv. Letter Header CZZ"
DocumentDeleteErr,
ResponsibilityCenter.TableCaption(), UserSetupManagement.GetPurchasesFilter());
+ PurchAdvLetterEntryCZZ.SetRange("Purch. Adv. Letter No.", "No.");
+ PurchAdvLetterEntryCZZ.SetFilter("Entry Type", '<>%1', PurchAdvLetterEntryCZZ."Entry Type"::"Initial Entry");
+ if not PurchAdvLetterEntryCZZ.IsEmpty() then
+ Error(PostedEntriesExistErr);
+
PurchAdvLetterLineCZZ.SetRange("Document No.", "No.");
if not PurchAdvLetterLineCZZ.IsEmpty() then
PurchAdvLetterLineCZZ.DeleteAll(true);
+ PurchAdvLetterEntryCZZ.Reset();
PurchAdvLetterEntryCZZ.SetRange("Purch. Adv. Letter No.", "No.");
if not PurchAdvLetterEntryCZZ.IsEmpty() then
PurchAdvLetterEntryCZZ.DeleteAll();
@@ -1474,6 +1481,7 @@ table 31008 "Purch. Adv. Letter Header CZZ"
begin
PurchAdvLetterEntryCZZ.SetRange("Purch. Adv. Letter No.", "No.");
PurchAdvLetterEntryCZZ.SetRange(Cancelled, false);
+ PurchAdvLetterEntryCZZ.SetRange("Auxiliary Entry", false);
PurchAdvLetterEntryCZZ.SetFilter("Entry Type", '<>%1', PurchAdvLetterEntryCZZ."Entry Type"::"Initial Entry");
PurchAdvLetterEntryCZZ.CalcSums("VAT Base Amount", "VAT Amount", "VAT Base Amount (LCY)", "VAT Amount (LCY)");
VATBaseAmount := PurchAdvLetterEntryCZZ."VAT Base Amount";
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/PurchAdvLetterLineCZZ.Table.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/PurchAdvLetterLineCZZ.Table.al
index e9735468d8..13a1e80af2 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/PurchAdvLetterLineCZZ.Table.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/PurchAdvLetterLineCZZ.Table.al
@@ -230,13 +230,13 @@ table 31011 "Purch. Adv. Letter Line CZZ"
var
IsHandled: Boolean;
begin
- TestField("VAT Prod. Posting Group");
-
IsHandled := false;
OnBeforeUpdateAmounts(Rec, xRec, CurrFieldNo, IsHandled);
if IsHandled then
exit;
+ TestField("VAT Prod. Posting Group");
+
GetHeader();
"Amount Including VAT" := Round("Amount Including VAT", Currency."Amount Rounding Precision");
case "VAT Calculation Type" of
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/SalesAdvLetterEntryCZZ.Table.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/SalesAdvLetterEntryCZZ.Table.al
index 6c624a829b..873efb6050 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/SalesAdvLetterEntryCZZ.Table.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/SalesAdvLetterEntryCZZ.Table.al
@@ -187,6 +187,12 @@ table 31006 "Sales Adv. Letter Entry CZZ"
TableRelation = Customer;
Editable = false;
}
+ field(80; "Auxiliary Entry"; Boolean)
+ {
+ Caption = 'Auxiliary Entry';
+ DataClassification = CustomerContent;
+ Editable = false;
+ }
field(480; "Dimension Set ID"; Integer)
{
Caption = 'Dimension Set ID';
@@ -270,6 +276,7 @@ table 31006 "Sales Adv. Letter Entry CZZ"
begin
SalesAdvLetterEntryCZZ.SetRange("Document No.", SalesInvoiceHeader."No.");
SalesAdvLetterEntryCZZ.SetRange("Entry Type", SalesAdvLetterEntryCZZ."Entry Type"::"VAT Usage");
+ SalesAdvLetterEntryCZZ.SetRange("Auxiliary Entry", false);
SalesAdvLetterEntryCZZ.SetRange(Cancelled, false);
if SalesAdvLetterEntryCZZ.FindSet() then
repeat
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/SalesAdvLetterHeaderCZZ.Table.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/SalesAdvLetterHeaderCZZ.Table.al
index a0c6b957c8..cfc55aa612 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/SalesAdvLetterHeaderCZZ.Table.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/SalesAdvLetterHeaderCZZ.Table.al
@@ -379,8 +379,8 @@ table 31004 "Sales Adv. Letter Header CZZ"
ValidateDocumentDateWithPostingDate();
GetSetup();
- GeneralLedgerSetup.UpdateVATDate("Posting Date", Enum::"VAT Reporting Date"::"Posting Date", "VAT Date");
- Validate("VAT Date");
+ GeneralLedgerSetup.UpdateVATDate("Posting Date", Enum::"VAT Reporting Date"::"Posting Date", "VAT Date");
+ Validate("VAT Date");
if "Currency Code" <> '' then begin
UpdateCurrencyFactor();
@@ -404,8 +404,8 @@ table 31004 "Sales Adv. Letter Header CZZ"
Validate("Payment Terms Code");
GetSetup();
- if GeneralLedgerSetup."VAT Reporting Date" = GeneralLedgerSetup."VAT Reporting Date"::"Document Date" then
- Validate("VAT Date", "Document Date");
+ if GeneralLedgerSetup."VAT Reporting Date" = GeneralLedgerSetup."VAT Reporting Date"::"Document Date" then
+ Validate("VAT Date", "Document Date");
end;
}
field(36; "VAT Date"; Date)
@@ -821,10 +821,16 @@ table 31004 "Sales Adv. Letter Header CZZ"
DocumentDeleteErr,
ResponsibilityCenter.TableCaption(), UserSetupManagement.GetSalesFilter());
+ SalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", "No.");
+ SalesAdvLetterEntryCZZ.SetFilter("Entry Type", '<>%1', SalesAdvLetterEntryCZZ."Entry Type"::"Initial Entry");
+ if not SalesAdvLetterEntryCZZ.IsEmpty() then
+ Error(PostedEntriesExistErr);
+
SalesAdvLetterLineCZZ.SetRange("Document No.", "No.");
if not SalesAdvLetterLineCZZ.IsEmpty() then
SalesAdvLetterLineCZZ.DeleteAll(true);
+ SalesAdvLetterEntryCZZ.Reset();
SalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", "No.");
if not SalesAdvLetterEntryCZZ.IsEmpty() then
SalesAdvLetterEntryCZZ.DeleteAll();
@@ -863,6 +869,7 @@ table 31004 "Sales Adv. Letter Header CZZ"
ConfirmChangeQst: Label 'Do you want to change %1?', Comment = '%1 = a Field Caption like Currency Code';
DocumentResetErr: Label 'You cannot reset %1 because the document still has one or more lines.', Comment = '%1 = a Field Caption like Bill-to Contact No.';
DocumentDeleteErr: Label 'You cannot delete this document. Your identification is set up to process from %1 %2 only.', Comment = '%1 = table caption of responsibility center, %2 = code of responsibility center';
+ PostedEntriesExistErr: Label 'You cannot delete this document because there are posted entries.';
procedure AssistEdit(): Boolean
var
@@ -1507,6 +1514,7 @@ table 31004 "Sales Adv. Letter Header CZZ"
begin
SalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", "No.");
SalesAdvLetterEntryCZZ.SetRange(Cancelled, false);
+ SalesAdvLetterEntryCZZ.SetRange("Auxiliary Entry", false);
SalesAdvLetterEntryCZZ.SetFilter("Entry Type", '<>%1', SalesAdvLetterEntryCZZ."Entry Type"::"Initial Entry");
SalesAdvLetterEntryCZZ.CalcSums("VAT Base Amount", "VAT Amount", "VAT Base Amount (LCY)", "VAT Amount (LCY)");
VATBaseAmount := SalesAdvLetterEntryCZZ."VAT Base Amount";
diff --git a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/SalesAdvLetterLineCZZ.Table.al b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/SalesAdvLetterLineCZZ.Table.al
index 814a45a55d..5b1ae41ef6 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/SalesAdvLetterLineCZZ.Table.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/app/Src/Tables/SalesAdvLetterLineCZZ.Table.al
@@ -195,13 +195,13 @@ table 31005 "Sales Adv. Letter Line CZZ"
CurrencyExchangeRate: Record "Currency Exchange Rate";
IsHandled: Boolean;
begin
- TestField("VAT Prod. Posting Group");
-
IsHandled := false;
OnBeforeUpdateAmounts(Rec, xRec, CurrFieldNo, IsHandled);
if IsHandled then
exit;
+ TestField("VAT Prod. Posting Group");
+
GetHeader();
"Amount Including VAT" := Round("Amount Including VAT", Currency."Amount Rounding Precision");
case "VAT Calculation Type" of
diff --git a/Apps/CZ/AdvancePaymentsLocalization/test/Src/PurchAdvPmtRevChargeCZZ.Codeunit.al b/Apps/CZ/AdvancePaymentsLocalization/test/Src/PurchAdvPmtRevChargeCZZ.Codeunit.al
new file mode 100644
index 0000000000..ae56077286
--- /dev/null
+++ b/Apps/CZ/AdvancePaymentsLocalization/test/Src/PurchAdvPmtRevChargeCZZ.Codeunit.al
@@ -0,0 +1,821 @@
+codeunit 148127 "Purch. Adv. Pmt.Rev.Charge CZZ"
+{
+ Subtype = Test;
+ TestPermissions = Disabled;
+
+ trigger OnRun()
+ begin
+ // [FEATURE] [Advance Payments] [Purchase] [Feverse Charge]
+ isInitialized := false;
+ end;
+
+ var
+ AdvanceLetterTemplateCZZ: Record "Advance Letter Template CZZ";
+ GeneralLedgerSetup: Record "General Ledger Setup";
+ Assert: Codeunit Assert;
+ LibraryDialogHandler: Codeunit "Library - Dialog Handler";
+ LibraryPurchAdvancesCZZ: Codeunit "Library - Purch. Advances CZZ";
+ LibraryPurchase: Codeunit "Library - Purchase";
+ LibraryRandom: Codeunit "Library - Random";
+ LibraryVariableStorage: Codeunit "Library - Variable Storage";
+ isInitialized: Boolean;
+
+ local procedure Initialize()
+ var
+ LibraryTestInitialize: Codeunit "Library - Test Initialize";
+ begin
+ LibraryTestInitialize.OnTestInitialize(Codeunit::"Purch. Adv. Pmt.Rev.Charge CZZ");
+ LibraryRandom.Init();
+ LibraryVariableStorage.Clear();
+ LibraryDialogHandler.ClearVariableStorage();
+ if isInitialized then
+ exit;
+ LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Purch. Adv. Pmt.Rev.Charge CZZ");
+
+ GeneralLedgerSetup.Get();
+ GeneralLedgerSetup."VAT Reporting Date Usage" := GeneralLedgerSetup."VAT Reporting Date Usage"::Enabled;
+ GeneralLedgerSetup."Def. Orig. Doc. VAT Date CZL" := GeneralLedgerSetup."Def. Orig. Doc. VAT Date CZL"::"VAT Date";
+ GeneralLedgerSetup."Max. VAT Difference Allowed" := 0.5;
+ GeneralLedgerSetup.Modify();
+
+ LibraryPurchAdvancesCZZ.CreatePurchAdvanceLetterTemplate(AdvanceLetterTemplateCZZ);
+ AdvanceLetterTemplateCZZ."Post VAT Doc. for Rev. Charge" := false;
+ AdvanceLetterTemplateCZZ.Modify();
+
+ isInitialized := true;
+ Commit();
+ LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::"Purch. Adv. Pmt.Rev.Charge CZZ");
+ end;
+
+ [Test]
+ [HandlerFunctions('ModalVATDocumentHandler')]
+ procedure PurchAdvLetterWithReverseCharge()
+ var
+ PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ";
+ PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ";
+ PurchAdvLetterLineCZZ: Record "Purch. Adv. Letter Line CZZ";
+ begin
+ // [SCENARIO] VAT document of purchase advance letter with reverse charge
+ Initialize();
+
+ // [GIVEN] Purchase advance letter has been created
+ // [GIVEN] Purchase advance letter line with reverse charge has been created
+ CreatePurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ);
+
+ // [GIVEN] Purchase advance letter has been released
+ ReleasePurchAdvLetter(PurchAdvLetterHeaderCZZ);
+
+ // [GIVEN] Purchase advance letter has been paid in full by the general journal
+ CreateAndPostPaymentPurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ."Amount Including VAT");
+
+ // [WHEN] Post payment VAT
+ PostPurchAdvancePaymentVAT(PurchAdvLetterHeaderCZZ);
+
+ // [THEN] Purchase advance letter entry of "VAT Payment" type will be created
+ PurchAdvLetterEntryCZZ.Reset();
+ PurchAdvLetterEntryCZZ.SetRange("Purch. Adv. Letter No.", PurchAdvLetterHeaderCZZ."No.");
+ PurchAdvLetterEntryCZZ.SetRange("Entry Type", PurchAdvLetterEntryCZZ."Entry Type"::"VAT Payment");
+ Assert.RecordIsNotEmpty(PurchAdvLetterEntryCZZ);
+
+ // [THEN] VAT entry won't be created for the purchase advance letter entry with reverse charge
+ PurchAdvLetterEntryCZZ.FindFirst();
+ Assert.AreEqual(0, PurchAdvLetterEntryCZZ."VAT Entry No.", 'VAT entry mustn''t be created.');
+
+ // [THEN] Created purchase advance letter entry will be marked as auxiliary
+ Assert.AreEqual(true, PurchAdvLetterEntryCZZ."Auxiliary Entry", 'Auxiliary entry must be true.');
+
+ // [THEN] The document no. will be equal to the advance letter no.
+ Assert.AreEqual(PurchAdvLetterHeaderCZZ."No.", PurchAdvLetterEntryCZZ."Document No.", 'Document No. must be equal to advance letter no.');
+ end;
+
+ [Test]
+ [HandlerFunctions('ModalVATDocumentHandler')]
+ procedure LinkPurchAdvLetterWithReverseChargeToInvoice()
+ var
+ PurchaseHeader: Record "Purchase Header";
+ PurchaseLine: Record "Purchase Line";
+ PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ";
+ PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ";
+ PurchAdvLetterLineCZZ: Record "Purch. Adv. Letter Line CZZ";
+ VATEntry: Record "VAT Entry";
+ PostedDocumentNo: Code[20];
+ begin
+ // [SCENARIO] Link purchase advance letter with reverse charge to purchase invoice
+ Initialize();
+
+ // [GIVEN] Purchase advance letter has been created
+ // [GIVEN] Purchase advance letter line with reverse charge has been created
+ CreatePurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ);
+
+ // [GIVEN] Purchase advance letter has been released
+ ReleasePurchAdvLetter(PurchAdvLetterHeaderCZZ);
+
+ // [GIVEN] Purchase advance letter has been paid in full by the general journal
+ CreateAndPostPaymentPurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ."Amount Including VAT");
+
+ // [GIVEN] Payment VAT has been posted
+ PostPurchAdvancePaymentVAT(PurchAdvLetterHeaderCZZ);
+
+ // [GIVEN] Purchase invoice has been created
+ // [GIVEN] Purchase invoice line with reverse charge has been created
+ LibraryPurchAdvancesCZZ.CreatePurchInvoice(
+ PurchaseHeader, PurchaseLine, PurchAdvLetterHeaderCZZ."Pay-to Vendor No.", PurchAdvLetterHeaderCZZ."Posting Date",
+ PurchAdvLetterLineCZZ."VAT Bus. Posting Group", PurchAdvLetterLineCZZ."VAT Prod. Posting Group", '', 0,
+ true, PurchAdvLetterLineCZZ."Amount Including VAT");
+
+ // [GIVEN] Whole advance letter has been linked to purchase invoice
+ LibraryPurchAdvancesCZZ.LinkPurchAdvanceLetterToDocument(
+ PurchAdvLetterHeaderCZZ, Enum::"Adv. Letter Usage Doc.Type CZZ"::"Purchase Invoice", PurchaseHeader."No.",
+ PurchAdvLetterLineCZZ."Amount Including VAT", PurchAdvLetterLineCZZ."Amount Including VAT (LCY)");
+
+ // [WHEN] Post purchase invoice
+ PostedDocumentNo := PostPurchaseDocument(PurchaseHeader);
+
+ // [THEN] VAT entries of purchase invoice will exist
+ VATEntry.Reset();
+ VATEntry.SetRange("Document No.", PostedDocumentNo);
+ VATEntry.SetRange("Posting Date", PurchaseHeader."Posting Date");
+ VATEntry.SetRange("Advance Letter No. CZZ", '');
+ Assert.RecordIsNotEmpty(VATEntry);
+
+ // [THEN] VAT entries of advance letter won't be exist
+ VATEntry.SetRange("Advance Letter No. CZZ", PurchAdvLetterHeaderCZZ."No.");
+ Assert.RecordIsEmpty(VATEntry);
+
+ // [THEN] Purchase advance letter entry of "Usage" type will be created
+ PurchAdvLetterEntryCZZ.Reset();
+ PurchAdvLetterEntryCZZ.SetRange("Purch. Adv. Letter No.", PurchAdvLetterHeaderCZZ."No.");
+ PurchAdvLetterEntryCZZ.CalcSums("VAT Base Amount", "VAT Base Amount (LCY)");
+ Assert.AreNearlyEqual(0, PurchAdvLetterEntryCZZ."VAT Base Amount", 1, 'The sum of VAT base amount must be zero.');
+ Assert.AreNearlyEqual(0, PurchAdvLetterEntryCZZ."VAT Base Amount (LCY)", 1, 'The sum of VAT base amount (LCY) must be zero.');
+
+ // [THEN] Purchase advance letter will be closed
+ PurchAdvLetterHeaderCZZ.Get(PurchAdvLetterHeaderCZZ."No.");
+ PurchAdvLetterHeaderCZZ.TestField(Status, PurchAdvLetterHeaderCZZ.Status::Closed);
+ end;
+
+ [Test]
+ [HandlerFunctions('ModalVATDocumentHandler')]
+ procedure PurchAdvLetterWithNormalVAT()
+ var
+ PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ";
+ PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ";
+ PurchAdvLetterLineCZZ: Record "Purch. Adv. Letter Line CZZ";
+ VATPostingSetup: Record "VAT Posting Setup";
+ begin
+ // [SCENARIO] VAT document of purchase advance letter with normal VAT
+ Initialize();
+
+ // [GIVEN] Purchase advance letter has been created
+ // [GIVEN] Purchase advance letter line with normal VAT has been created
+ LibraryPurchAdvancesCZZ.FindVATPostingSetup(VATPostingSetup);
+ CreatePurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ, VATPostingSetup);
+
+ // [GIVEN] Purchase advance letter has been released
+ ReleasePurchAdvLetter(PurchAdvLetterHeaderCZZ);
+
+ // [GIVEN] Purchase advance letter has been paid in full by the general journal
+ CreateAndPostPaymentPurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ."Amount Including VAT");
+
+ // [WHEN] Post payment VAT
+ PostPurchAdvancePaymentVAT(PurchAdvLetterHeaderCZZ);
+
+ // [THEN] Purchase advance letter entry of "VAT Payment" type will be created
+ PurchAdvLetterEntryCZZ.Reset();
+ PurchAdvLetterEntryCZZ.SetRange("Purch. Adv. Letter No.", PurchAdvLetterHeaderCZZ."No.");
+ PurchAdvLetterEntryCZZ.SetRange("Entry Type", PurchAdvLetterEntryCZZ."Entry Type"::"VAT Payment");
+ Assert.RecordIsNotEmpty(PurchAdvLetterEntryCZZ);
+
+ // [THEN] Created purchase advance letter entry will have VAT amounts
+ PurchAdvLetterEntryCZZ.FindFirst();
+ Assert.AreNotEqual(0, PurchAdvLetterEntryCZZ."VAT Amount", 'VAT amount mustn''t be zero.');
+ Assert.AreNotEqual(0, PurchAdvLetterEntryCZZ."VAT Amount (LCY)", 'VAT amount (LCY) mustn''t be zero.');
+ Assert.AreNotEqual(0, PurchAdvLetterEntryCZZ."VAT Base Amount", 'VAT base amount mustn''t be zero.');
+ Assert.AreNotEqual(0, PurchAdvLetterEntryCZZ."VAT Base Amount (LCY)", 'VAT base amount (LCY) mustn''t be zero.');
+ Assert.AreNotEqual(0, PurchAdvLetterEntryCZZ."VAT Entry No.", 'VAT entry must be created.');
+
+ // [THEN] Created purchase advance letter entry won't be marked as auxiliary
+ Assert.AreEqual(false, PurchAdvLetterEntryCZZ."Auxiliary Entry", 'Auxiliary entry must be false.');
+
+ // [THEN] The document no. won't be equal to the advance letter no.
+ Assert.AreNotEqual(PurchAdvLetterHeaderCZZ."No.", PurchAdvLetterEntryCZZ."Document No.", 'Document No. mustn''t be equal to advance letter no.');
+ end;
+
+ [Test]
+ [HandlerFunctions('ModalVATDocumentHandler')]
+ procedure PurchAdvLetterWithNormalVATAndReverseCharge()
+ var
+ PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ";
+ PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ";
+ PurchAdvLetterLineCZZ: Record "Purch. Adv. Letter Line CZZ";
+ VATPostingSetup: Record "VAT Posting Setup";
+ begin
+ // [SCENARIO] VAT document of purchase advance letter with normal VAT and reverse charge
+ Initialize();
+
+ // [GIVEN] Purchase advance letter has been created
+ // [GIVEN] Purchase advance letter line with reverse charge has been created
+ CreatePurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ);
+
+ // [GIVEN] Purchase advance letter line with normal VAT has been created
+ LibraryPurchAdvancesCZZ.FindVATPostingSetup(VATPostingSetup);
+ LibraryPurchAdvancesCZZ.CreatePurchAdvLetterLine(
+ PurchAdvLetterLineCZZ, PurchAdvLetterHeaderCZZ,
+ VATPostingSetup."VAT Prod. Posting Group", LibraryRandom.RandDec(1000, 2));
+
+ // [GIVEN] Purchase advance letter has been released
+ ReleasePurchAdvLetter(PurchAdvLetterHeaderCZZ);
+
+ // [GIVEN] Purchase advance letter has been paid in full by the general journal
+ PurchAdvLetterHeaderCZZ.CalcFields("Amount Including VAT");
+ CreateAndPostPaymentPurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterHeaderCZZ."Amount Including VAT");
+
+ // [WHEN] Post payment VAT
+ PostPurchAdvancePaymentVAT(PurchAdvLetterHeaderCZZ);
+
+ // [THEN] Purchase advance letter entry of "VAT Payment" type with normal VAT will be created
+ PurchAdvLetterEntryCZZ.Reset();
+ PurchAdvLetterEntryCZZ.SetRange("Purch. Adv. Letter No.", PurchAdvLetterHeaderCZZ."No.");
+ PurchAdvLetterEntryCZZ.SetRange("Entry Type", PurchAdvLetterEntryCZZ."Entry Type"::"VAT Payment");
+ PurchAdvLetterEntryCZZ.SetRange("VAT Calculation Type", PurchAdvLetterEntryCZZ."VAT Calculation Type"::"Normal VAT");
+ Assert.RecordIsNotEmpty(PurchAdvLetterEntryCZZ);
+
+ // [THEN] Created purchase advance letter entry with normal VAT will have VAT amounts
+ PurchAdvLetterEntryCZZ.FindFirst();
+ Assert.AreNotEqual(0, PurchAdvLetterEntryCZZ."VAT Amount", 'VAT amount mustn''t be zero.');
+ Assert.AreNotEqual(0, PurchAdvLetterEntryCZZ."VAT Amount (LCY)", 'VAT amount (LCY) mustn''t be zero.');
+ Assert.AreNotEqual(0, PurchAdvLetterEntryCZZ."VAT Base Amount", 'VAT base amount mustn''t be zero.');
+ Assert.AreNotEqual(0, PurchAdvLetterEntryCZZ."VAT Base Amount (LCY)", 'VAT base amount (LCY) mustn''t be zero.');
+ Assert.AreNotEqual(0, PurchAdvLetterEntryCZZ."VAT Entry No.", 'VAT entry must be created.');
+
+ // [THEN] Purchase advance letter entry with normal VAT won't be marked as auxiliary
+ Assert.AreEqual(false, PurchAdvLetterEntryCZZ."Auxiliary Entry", 'Auxiliary entry must be false.');
+
+ // [THEN] The document no. won't be equal to the advance letter no.
+ Assert.AreNotEqual(PurchAdvLetterHeaderCZZ."No.", PurchAdvLetterEntryCZZ."Document No.", 'Document No. mustn''t be equal to advance letter no.');
+
+ // [THEN] Purchase advance letter entry of "VAT Payment" type with reverse charge will be created
+ PurchAdvLetterEntryCZZ.SetRange("VAT Calculation Type", PurchAdvLetterEntryCZZ."VAT Calculation Type"::"Reverse Charge VAT");
+ Assert.RecordIsNotEmpty(PurchAdvLetterEntryCZZ);
+
+ // [THEN] VAT entry won't be created for the purchase advance letter entry with reverse charge
+ PurchAdvLetterEntryCZZ.FindFirst();
+ Assert.AreEqual(0, PurchAdvLetterEntryCZZ."VAT Entry No.", 'VAT entry mustn''t be created.');
+
+ // [THEN] Purchase advance letter entry with reverse charge will be marked as auxiliary
+ Assert.AreEqual(true, PurchAdvLetterEntryCZZ."Auxiliary Entry", 'Auxiliary entry must be true.');
+
+ // [THEN] The document no. won't be equal to the advance letter no.
+ Assert.AreNotEqual(PurchAdvLetterHeaderCZZ."No.", PurchAdvLetterEntryCZZ."Document No.", 'Document No. mustn''t be equal to advance letter no.');
+ end;
+
+ [Test]
+ [HandlerFunctions('ModalVATDocumentHandler')]
+ procedure PurchAdvLetterWithNormalVATAndReverseChargePartiallyPaid()
+ var
+ PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ";
+ PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ";
+ PurchAdvLetterLineCZZ: Record "Purch. Adv. Letter Line CZZ";
+ VATPostingSetup: Record "VAT Posting Setup";
+ PaymentAmount: Decimal;
+ VATPaymentAmount: Decimal;
+ begin
+ // [SCENARIO] VAT document of purchase advance letter with normal VAT and reverse charge is partially paid
+ Initialize();
+
+ // [GIVEN] Purchase advance letter has been created
+ // [GIVEN] Purchase advance letter line with reverse charge has been created
+ CreatePurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ);
+
+ // [GIVEN] Purchase advance letter line with normal VAT has been created
+ LibraryPurchAdvancesCZZ.FindVATPostingSetup(VATPostingSetup);
+ LibraryPurchAdvancesCZZ.CreatePurchAdvLetterLine(
+ PurchAdvLetterLineCZZ, PurchAdvLetterHeaderCZZ,
+ VATPostingSetup."VAT Prod. Posting Group", LibraryRandom.RandDec(1000, 2));
+
+ // [GIVEN] Purchase advance letter has been released
+ ReleasePurchAdvLetter(PurchAdvLetterHeaderCZZ);
+
+ // [GIVEN] Purchase advance letter has been paid in half by the general journal
+ PurchAdvLetterHeaderCZZ.CalcFields("Amount Including VAT");
+ CreateAndPostPaymentPurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterHeaderCZZ."Amount Including VAT" / 2);
+
+ // [WHEN] Post payment VAT
+ PostPurchAdvancePaymentVAT(PurchAdvLetterHeaderCZZ);
+
+ // [THEN] Purchase advance letter entry of "VAT Payment" type with normal VAT will be created
+ PurchAdvLetterEntryCZZ.Reset();
+ PurchAdvLetterEntryCZZ.SetRange("Purch. Adv. Letter No.", PurchAdvLetterHeaderCZZ."No.");
+ PurchAdvLetterEntryCZZ.SetRange("Entry Type", PurchAdvLetterEntryCZZ."Entry Type"::"VAT Payment");
+ PurchAdvLetterEntryCZZ.SetRange("VAT Calculation Type", PurchAdvLetterEntryCZZ."VAT Calculation Type"::"Normal VAT");
+ Assert.RecordIsNotEmpty(PurchAdvLetterEntryCZZ);
+
+ // [THEN] Created purchase advance letter entry with normal VAT will have VAT amounts
+ PurchAdvLetterEntryCZZ.FindFirst();
+ VATPaymentAmount := PurchAdvLetterEntryCZZ."Amount";
+ Assert.AreNotEqual(0, PurchAdvLetterEntryCZZ."VAT Amount", 'VAT amount mustn''t be zero.');
+ Assert.AreNotEqual(0, PurchAdvLetterEntryCZZ."VAT Amount (LCY)", 'VAT amount (LCY) mustn''t be zero.');
+ Assert.AreNotEqual(0, PurchAdvLetterEntryCZZ."VAT Base Amount", 'VAT base amount mustn''t be zero.');
+ Assert.AreNotEqual(0, PurchAdvLetterEntryCZZ."VAT Base Amount (LCY)", 'VAT base amount (LCY) mustn''t be zero.');
+ Assert.AreNotEqual(0, PurchAdvLetterEntryCZZ."VAT Entry No.", 'VAT entry must be created.');
+
+ // [THEN] Created purchase advance letter entry with normal VAT won't be marked as auxiliary
+ Assert.AreEqual(false, PurchAdvLetterEntryCZZ."Auxiliary Entry", 'Auxiliary entry must be false.');
+
+ // [THEN] The document no. won't be equal to the advance letter no.
+ Assert.AreNotEqual(PurchAdvLetterHeaderCZZ."No.", PurchAdvLetterEntryCZZ."Document No.", 'Document No. mustn''t be equal to advance letter no.');
+
+ // [THEN] Purchase advance letter entry of "VAT Payment" type with reverse charge will be created
+ PurchAdvLetterEntryCZZ.SetRange("VAT Calculation Type", PurchAdvLetterEntryCZZ."VAT Calculation Type"::"Reverse Charge VAT");
+ Assert.RecordIsNotEmpty(PurchAdvLetterEntryCZZ);
+
+ // [THEN] VAT entry won't be created for the purchase advance letter entry with reverse charge
+ PurchAdvLetterEntryCZZ.FindFirst();
+ VATPaymentAmount += PurchAdvLetterEntryCZZ."Amount";
+ Assert.AreEqual(0, PurchAdvLetterEntryCZZ."VAT Entry No.", 'VAT entry mustn''t be created.');
+
+ // [THEN] Created purchase advance letter entry with reverse charge will be marked as auxiliary
+ Assert.AreEqual(true, PurchAdvLetterEntryCZZ."Auxiliary Entry", 'Auxiliary entry must be true.');
+
+ // [THEN] The document no. won't be equal to the advance letter no.
+ Assert.AreNotEqual(PurchAdvLetterHeaderCZZ."No.", PurchAdvLetterEntryCZZ."Document No.", 'Document No. mustn''t be equal to advance letter no.');
+
+ // [THEN] The sum of payment amount must be equal to the sum of VAT payment amount
+ PurchAdvLetterEntryCZZ.Reset();
+ FindLastPaymentAdvanceLetterEntry(PurchAdvLetterHeaderCZZ."No.", PurchAdvLetterEntryCZZ);
+ PaymentAmount := PurchAdvLetterEntryCZZ."Amount";
+ Assert.AreEqual(PaymentAmount, VATPaymentAmount, 'The sum of payment amount must be equal to the sum of VAT payment amount.');
+ end;
+
+ [Test]
+ [HandlerFunctions('ModalVATDocumentHandler')]
+ procedure LinkPurchAdvLetterWithNormalVATAndReverseChargeToInvoice1()
+ var
+ PurchaseHeader: Record "Purchase Header";
+ PurchaseLine: Record "Purchase Line";
+ PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ";
+ PurchAdvLetterLineCZZ1: Record "Purch. Adv. Letter Line CZZ";
+ PurchAdvLetterLineCZZ2: Record "Purch. Adv. Letter Line CZZ";
+ VATEntry: Record "VAT Entry";
+ VATPostingSetup: Record "VAT Posting Setup";
+ PostedDocumentNo: Code[20];
+ begin
+ // [SCENARIO] Link purchase advance letter with normal VAT and reverse charge to purchase invoice with normal VAT
+ Initialize();
+
+ // [GIVEN] Purchase advance letter has been created
+ // [GIVEN] Purchase advance letter line with reverse charge has been created
+ CreatePurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ1);
+
+ // [GIVEN] Purchase advance letter line with normal VAT has been created
+ LibraryPurchAdvancesCZZ.FindVATPostingSetup(VATPostingSetup); // normal VAT
+ LibraryPurchAdvancesCZZ.CreatePurchAdvLetterLine(
+ PurchAdvLetterLineCZZ2, PurchAdvLetterHeaderCZZ,
+ VATPostingSetup."VAT Prod. Posting Group", LibraryRandom.RandDec(1000, 2));
+
+ // [GIVEN] Purchase advance letter has been released
+ ReleasePurchAdvLetter(PurchAdvLetterHeaderCZZ);
+
+ // [GIVEN] Purchase advance letter has been paid in full by the general journal
+ PurchAdvLetterHeaderCZZ.CalcFields("Amount Including VAT");
+ CreateAndPostPaymentPurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterHeaderCZZ."Amount Including VAT");
+
+ // [GIVEN] Payment VAT has been posted
+ PostPurchAdvancePaymentVAT(PurchAdvLetterHeaderCZZ);
+
+ // [GIVEN] Purchase invoice has been created
+ // [GIVEN] Purchase invoice line with normal VAT has been created
+ LibraryPurchAdvancesCZZ.CreatePurchInvoice(
+ PurchaseHeader, PurchaseLine, PurchAdvLetterHeaderCZZ."Pay-to Vendor No.", PurchAdvLetterHeaderCZZ."Posting Date",
+ PurchAdvLetterLineCZZ2."VAT Bus. Posting Group", PurchAdvLetterLineCZZ2."VAT Prod. Posting Group", '', 0,
+ true, PurchAdvLetterLineCZZ2."Amount Including VAT");
+
+ // [GIVEN] Second line with normal VAT has been linked to purchase invoice
+ LibraryPurchAdvancesCZZ.LinkPurchAdvanceLetterToDocument(
+ PurchAdvLetterHeaderCZZ, Enum::"Adv. Letter Usage Doc.Type CZZ"::"Purchase Invoice", PurchaseHeader."No.",
+ PurchAdvLetterHeaderCZZ."Amount Including VAT", PurchAdvLetterHeaderCZZ."Amount Including VAT (LCY)");
+
+ // [WHEN] Post purchase invoice
+ PostedDocumentNo := PostPurchaseDocument(PurchaseHeader);
+
+ // [THEN] VAT entries of purchase invoice will exist
+ VATEntry.Reset();
+ VATEntry.SetRange("Document No.", PostedDocumentNo);
+ VATEntry.SetRange("Posting Date", PurchaseHeader."Posting Date");
+ VATEntry.SetRange("Advance Letter No. CZZ", '');
+ Assert.RecordIsNotEmpty(VATEntry);
+
+ // [THEN] VAT entries of advance letter will exist
+ VATEntry.SetRange("Advance Letter No. CZZ", PurchAdvLetterHeaderCZZ."No.");
+ Assert.RecordIsNotEmpty(VATEntry);
+
+ // [THEN] Sum of base and VAT amounts in VAT entries will be zero
+ VATEntry.SetRange("Advance Letter No. CZZ");
+ VATEntry.CalcSums(Base, Amount);
+ Assert.AreEqual(0, VATEntry.Base, 'The sum of base amount in VAT Entries must be zero.');
+ Assert.AreEqual(0, VATEntry.Amount, 'The sum of VAT amount in VAT Entries must be zero.');
+
+ // [THEN] VAT entries will have the same VAT calculation type
+ VATEntry.SetFilter("VAT Calculation Type", '<>%1', PurchAdvLetterLineCZZ2."VAT Calculation Type");
+ Assert.RecordIsEmpty(VATEntry);
+ end;
+
+ [Test]
+ [HandlerFunctions('ModalVATDocumentHandler')]
+ procedure LinkPurchAdvLetterWithNormalVATAndReverseChargeToInvoice2()
+ var
+ PurchaseHeader: Record "Purchase Header";
+ PurchaseLine: Record "Purchase Line";
+ PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ";
+ PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ";
+ PurchAdvLetterLineCZZ1: Record "Purch. Adv. Letter Line CZZ";
+ PurchAdvLetterLineCZZ2: Record "Purch. Adv. Letter Line CZZ";
+ VATEntry: Record "VAT Entry";
+ VATPostingSetup: Record "VAT Posting Setup";
+ PostedDocumentNo: Code[20];
+ begin
+ // [SCENARIO] Link purchase advance letter with normal VAT and reverse charge to purchase invoice with reverse charge
+ Initialize();
+
+ // [GIVEN] Purchase advance letter has been created
+ // [GIVEN] Purchase advance letter line with reverse charge has been created
+ CreatePurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ1);
+
+ // [GIVEN] Purchase advance letter line with normal VAT has been created
+ LibraryPurchAdvancesCZZ.FindVATPostingSetup(VATPostingSetup);
+ LibraryPurchAdvancesCZZ.CreatePurchAdvLetterLine(
+ PurchAdvLetterLineCZZ2, PurchAdvLetterHeaderCZZ,
+ VATPostingSetup."VAT Prod. Posting Group", LibraryRandom.RandDec(1000, 2));
+
+ // [GIVEN] Purchase advance letter has been released
+ ReleasePurchAdvLetter(PurchAdvLetterHeaderCZZ);
+
+ // [GIVEN] Purchase advance letter has been paid in full by the general journal
+ PurchAdvLetterHeaderCZZ.CalcFields("Amount Including VAT");
+ CreateAndPostPaymentPurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterHeaderCZZ."Amount Including VAT");
+
+ // [GIVEN] Payment VAT has been posted
+ PostPurchAdvancePaymentVAT(PurchAdvLetterHeaderCZZ);
+
+ // [GIVEN] Purchase invoice has been created
+ // [GIVEN] Purchase invoice line with reverse charge has been created
+ LibraryPurchAdvancesCZZ.CreatePurchInvoice(
+ PurchaseHeader, PurchaseLine, PurchAdvLetterHeaderCZZ."Pay-to Vendor No.", PurchAdvLetterHeaderCZZ."Posting Date",
+ PurchAdvLetterLineCZZ1."VAT Bus. Posting Group", PurchAdvLetterLineCZZ1."VAT Prod. Posting Group", '', 0,
+ true, PurchAdvLetterLineCZZ1."Amount Including VAT");
+
+ // [GIVEN] First line with reverse charge has been linked to purchase invoice
+ LibraryPurchAdvancesCZZ.LinkPurchAdvanceLetterToDocument(
+ PurchAdvLetterHeaderCZZ, Enum::"Adv. Letter Usage Doc.Type CZZ"::"Purchase Invoice", PurchaseHeader."No.",
+ PurchAdvLetterHeaderCZZ."Amount Including VAT", PurchAdvLetterHeaderCZZ."Amount Including VAT (LCY)");
+
+ // [WHEN] Post purchase invoice
+ PostedDocumentNo := PostPurchaseDocument(PurchaseHeader);
+
+ // [THEN] VAT entries of purchase invoice will exist
+ VATEntry.Reset();
+ VATEntry.SetRange("Document No.", PostedDocumentNo);
+ VATEntry.SetRange("Posting Date", PurchaseHeader."Posting Date");
+ VATEntry.SetRange("Advance Letter No. CZZ", '');
+ Assert.RecordIsNotEmpty(VATEntry);
+
+ // [THEN] VAT entries of advance letter won't exist
+ VATEntry.SetRange("Advance Letter No. CZZ", PurchAdvLetterHeaderCZZ."No.");
+ Assert.RecordIsEmpty(VATEntry);
+
+ // [THEN] Sum of base and VAT amounts in VAT entries won't be zero
+ VATEntry.SetRange("Advance Letter No. CZZ");
+ VATEntry.CalcSums(Base, Amount);
+ Assert.AreNotEqual(0, VATEntry.Base, 'The sum of base amount in VAT Entries mustn''t be zero.');
+ Assert.AreNotEqual(0, VATEntry.Amount, 'The sum of VAT amount in VAT Entries mustn''t be zero.');
+
+ // [THEN] Purchase advance letter entry of "VAT Usage" type with reverse charge will be created
+ PurchAdvLetterEntryCZZ.Reset();
+ PurchAdvLetterEntryCZZ.SetRange("Purch. Adv. Letter No.", PurchAdvLetterHeaderCZZ."No.");
+ PurchAdvLetterEntryCZZ.SetRange("Entry Type", PurchAdvLetterEntryCZZ."Entry Type"::"VAT Usage");
+ PurchAdvLetterEntryCZZ.SetRange("VAT Calculation Type", PurchAdvLetterEntryCZZ."VAT Calculation Type"::"Reverse Charge VAT");
+ PurchAdvLetterEntryCZZ.SetRange("Auxiliary Entry", true);
+ Assert.RecordIsNotEmpty(PurchAdvLetterEntryCZZ);
+
+ // [THEN] Purchase advance letter entry of "VAT Usage" type with normal VAT won't be created
+ PurchAdvLetterEntryCZZ.Reset();
+ PurchAdvLetterEntryCZZ.SetRange("Purch. Adv. Letter No.", PurchAdvLetterHeaderCZZ."No.");
+ PurchAdvLetterEntryCZZ.SetRange("Entry Type", PurchAdvLetterEntryCZZ."Entry Type"::"VAT Usage");
+ PurchAdvLetterEntryCZZ.SetRange("VAT Calculation Type", PurchAdvLetterEntryCZZ."VAT Calculation Type"::"Normal VAT");
+ Assert.RecordIsEmpty(PurchAdvLetterEntryCZZ);
+ end;
+
+ [Test]
+ [HandlerFunctions('ModalVATDocumentHandler')]
+ procedure LinkPurchAdvLetterWithNormalVATAndReverseChargeToInvoice3()
+ var
+ PurchaseHeader: Record "Purchase Header";
+ PurchaseLine: Record "Purchase Line";
+ PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ";
+ PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ";
+ PurchAdvLetterLineCZZ1: Record "Purch. Adv. Letter Line CZZ";
+ PurchAdvLetterLineCZZ2: Record "Purch. Adv. Letter Line CZZ";
+ VATEntry: Record "VAT Entry";
+ VATPostingSetup: Record "VAT Posting Setup";
+ PostedDocumentNo: Code[20];
+ VATPaymentAmount, VATPaymentAmountLCY : Decimal;
+ begin
+ // [SCENARIO] Link purchase advance letter with normal VAT and reverse charge to purchase invoice with normal VAT and higher amount than the advance letter
+ Initialize();
+
+ // [GIVEN] Purchase advance letter has been created
+ // [GIVEN] Purchase advance letter line with reverse charge has been created
+ CreatePurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ1);
+
+ // [GIVEN] Purchase advance letter line with normal VAT has been created
+ LibraryPurchAdvancesCZZ.FindVATPostingSetup(VATPostingSetup);
+ LibraryPurchAdvancesCZZ.CreatePurchAdvLetterLine(
+ PurchAdvLetterLineCZZ2, PurchAdvLetterHeaderCZZ,
+ VATPostingSetup."VAT Prod. Posting Group", LibraryRandom.RandDec(1000, 2));
+
+ // [GIVEN] Purchase advance letter has been released
+ ReleasePurchAdvLetter(PurchAdvLetterHeaderCZZ);
+
+ // [GIVEN] Purchase advance letter has been paid in full by the general journal
+ PurchAdvLetterHeaderCZZ.CalcFields("Amount Including VAT");
+ CreateAndPostPaymentPurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterHeaderCZZ."Amount Including VAT");
+
+ // [GIVEN] Payment VAT has been posted
+ PostPurchAdvancePaymentVAT(PurchAdvLetterHeaderCZZ);
+
+ // [GIVEN] Purchase invoice has been created
+ // [GIVEN] Purchase invoice line with normal VAT has been created
+ LibraryPurchAdvancesCZZ.CreatePurchInvoice(
+ PurchaseHeader, PurchaseLine, PurchAdvLetterHeaderCZZ."Pay-to Vendor No.", PurchAdvLetterHeaderCZZ."Posting Date",
+ PurchAdvLetterLineCZZ2."VAT Bus. Posting Group", PurchAdvLetterLineCZZ2."VAT Prod. Posting Group", '', 0,
+ true, PurchAdvLetterLineCZZ2."Amount Including VAT" + (PurchAdvLetterLineCZZ1."Amount Including VAT" / 2));
+
+ // [GIVEN] First line with normal VAT has been linked to purchase invoice
+ LibraryPurchAdvancesCZZ.LinkPurchAdvanceLetterToDocument(
+ PurchAdvLetterHeaderCZZ, Enum::"Adv. Letter Usage Doc.Type CZZ"::"Purchase Invoice", PurchaseHeader."No.",
+ PurchAdvLetterHeaderCZZ."Amount Including VAT", PurchAdvLetterHeaderCZZ."Amount Including VAT (LCY)");
+
+ // [WHEN] Post purchase invoice
+ PostedDocumentNo := PostPurchaseDocument(PurchaseHeader);
+
+ // [THEN] Purchase advance letter entry of "VAT Usage" type will have amount equal to the amount of "VAT Payment" entry
+ PurchAdvLetterEntryCZZ.Reset();
+ PurchAdvLetterEntryCZZ.SetRange("Purch. Adv. Letter No.", PurchAdvLetterHeaderCZZ."No.");
+ PurchAdvLetterEntryCZZ.SetRange("Entry Type", PurchAdvLetterEntryCZZ."Entry Type"::"VAT Payment");
+ PurchAdvLetterEntryCZZ.SetRange("VAT Calculation Type", PurchAdvLetterLineCZZ2."VAT Calculation Type");
+ PurchAdvLetterEntryCZZ.CalcSums(Amount, "Amount (LCY)");
+ VATPaymentAmount := PurchAdvLetterEntryCZZ.Amount;
+ VATPaymentAmountLCY := PurchAdvLetterEntryCZZ."Amount (LCY)";
+
+ PurchAdvLetterEntryCZZ.Reset();
+ PurchAdvLetterEntryCZZ.SetRange("Purch. Adv. Letter No.", PurchAdvLetterHeaderCZZ."No.");
+ PurchAdvLetterEntryCZZ.SetRange("Entry Type", PurchAdvLetterEntryCZZ."Entry Type"::"VAT Usage");
+ PurchAdvLetterEntryCZZ.SetRange("VAT Calculation Type", PurchAdvLetterLineCZZ2."VAT Calculation Type");
+ PurchAdvLetterEntryCZZ.FindFirst();
+ Assert.AreEqual(VATPaymentAmount, -PurchAdvLetterEntryCZZ.Amount, 'The amount of VAT Payment entry must be equal to the amount of VAT Usage entry.');
+ Assert.AreEqual(VATPaymentAmountLCY, -PurchAdvLetterEntryCZZ."Amount (LCY)", 'The amount (LCY) of VAT Payment entry must be equal to the amount (LCY) of VAT Usage entry.');
+
+ // [THEN] Sum of base and VAT amounts in VAT entries won't be zero
+ VATEntry.Reset();
+ VATEntry.SetRange("Document No.", PostedDocumentNo);
+ VATEntry.SetRange("Posting Date", PurchaseHeader."Posting Date");
+ VATEntry.CalcSums(Base, Amount);
+ Assert.AreNotEqual(0, VATEntry.Base, 'The sum of base amount in VAT Entries mustn''t be zero.');
+ Assert.AreNotEqual(0, VATEntry.Amount, 'The sum of VAT amount in VAT Entries mustn''t be zero.');
+ end;
+
+ [Test]
+ [HandlerFunctions('ModalVATDocumentHandler')]
+ procedure LinkPurchAdvLetterWithNormalVATAndReverseChargeToInvoice4()
+ var
+ PurchaseHeader: Record "Purchase Header";
+ PurchaseLine: Record "Purchase Line";
+ PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ";
+ PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ";
+ PurchAdvLetterLineCZZ1: Record "Purch. Adv. Letter Line CZZ";
+ PurchAdvLetterLineCZZ2: Record "Purch. Adv. Letter Line CZZ";
+ VATPostingSetup: Record "VAT Posting Setup";
+ begin
+ // [SCENARIO] Link purchase advance letter with normal VAT and reverse charge to purchase invoice with reverse charge and higher amount than the advance letter
+ Initialize();
+
+ // [GIVEN] Purchase advance letter has been created
+ // [GIVEN] Purchase advance letter line with reverse charge has been created
+ CreatePurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ1);
+
+ // [GIVEN] Purchase advance letter line with normal VAT has been created
+ LibraryPurchAdvancesCZZ.FindVATPostingSetup(VATPostingSetup);
+ LibraryPurchAdvancesCZZ.CreatePurchAdvLetterLine(
+ PurchAdvLetterLineCZZ2, PurchAdvLetterHeaderCZZ,
+ VATPostingSetup."VAT Prod. Posting Group", LibraryRandom.RandDec(1000, 2));
+
+ // [GIVEN] Purchase advance letter has been released
+ ReleasePurchAdvLetter(PurchAdvLetterHeaderCZZ);
+
+ // [GIVEN] Purchase advance letter has been paid in full by the general journal
+ PurchAdvLetterHeaderCZZ.CalcFields("Amount Including VAT");
+ CreateAndPostPaymentPurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterHeaderCZZ."Amount Including VAT");
+
+ // [GIVEN] Payment VAT has been posted
+ PostPurchAdvancePaymentVAT(PurchAdvLetterHeaderCZZ);
+
+ // [GIVEN] Purchase invoice has been created
+ // [GIVEN] Purchase invoice line with reverse charge has been created
+ LibraryPurchAdvancesCZZ.CreatePurchInvoice(
+ PurchaseHeader, PurchaseLine, PurchAdvLetterHeaderCZZ."Pay-to Vendor No.", PurchAdvLetterHeaderCZZ."Posting Date",
+ PurchAdvLetterLineCZZ1."VAT Bus. Posting Group", PurchAdvLetterLineCZZ1."VAT Prod. Posting Group", '', 0,
+ true, PurchAdvLetterLineCZZ1."Amount Including VAT" + Round(PurchAdvLetterLineCZZ2."Amount Including VAT" / 2));
+
+ // [GIVEN] First line with reverse charge has been linked to purchase invoice
+ LibraryPurchAdvancesCZZ.LinkPurchAdvanceLetterToDocument(
+ PurchAdvLetterHeaderCZZ, Enum::"Adv. Letter Usage Doc.Type CZZ"::"Purchase Invoice", PurchaseHeader."No.",
+ PurchAdvLetterHeaderCZZ."Amount Including VAT", PurchAdvLetterHeaderCZZ."Amount Including VAT (LCY)");
+
+ // [WHEN] Post purchase invoice
+ PostPurchaseDocument(PurchaseHeader);
+
+ // [THEN] Purchase advance letter entry of "VAT Usage" type will have amount equal to part of the amount of "VAT Payment" entry with normal VAT
+ PurchAdvLetterEntryCZZ.Reset();
+ PurchAdvLetterEntryCZZ.SetRange("Purch. Adv. Letter No.", PurchAdvLetterHeaderCZZ."No.");
+ PurchAdvLetterEntryCZZ.SetRange("Entry Type", PurchAdvLetterEntryCZZ."Entry Type"::"VAT Usage");
+ PurchAdvLetterEntryCZZ.SetRange("VAT Calculation Type", PurchAdvLetterLineCZZ2."VAT Calculation Type");
+ PurchAdvLetterEntryCZZ.FindFirst();
+ Assert.AreEqual(Round(PurchAdvLetterLineCZZ2."Amount Including VAT" / 2), -PurchAdvLetterEntryCZZ.Amount, 'The amount of VAT Payment entry must be equal to the amount of VAT Usage entry.');
+
+ // [THEN] Purchase advance letter entry of "VAT Usage" type will have amount equal to the amount of "VAT Payment" entry with reverse charge
+ PurchAdvLetterEntryCZZ.Reset();
+ PurchAdvLetterEntryCZZ.SetRange("Purch. Adv. Letter No.", PurchAdvLetterHeaderCZZ."No.");
+ PurchAdvLetterEntryCZZ.SetRange("Entry Type", PurchAdvLetterEntryCZZ."Entry Type"::"VAT Usage");
+ PurchAdvLetterEntryCZZ.SetRange("VAT Calculation Type", PurchAdvLetterLineCZZ1."VAT Calculation Type");
+ PurchAdvLetterEntryCZZ.SetRange("Auxiliary Entry", true);
+ PurchAdvLetterEntryCZZ.SetRange("VAT Entry No.", 0);
+ PurchAdvLetterEntryCZZ.FindFirst();
+ Assert.AreEqual(PurchAdvLetterLineCZZ1."Amount Including VAT", -PurchAdvLetterEntryCZZ.Amount, 'The amount of VAT Payment entry must be equal to the amount of VAT Usage entry.');
+ end;
+
+ [Test]
+ [HandlerFunctions('ModalVATDocumentHandler')]
+ procedure LinkPurchAdvLetterWithNormalVATAndReverseChargeToInvoice5()
+ var
+ GLAccount: Record "G/L Account";
+ PurchaseHeader: Record "Purchase Header";
+ PurchaseLine: Record "Purchase Line";
+ PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ";
+ PurchAdvLetterLineCZZ1: Record "Purch. Adv. Letter Line CZZ";
+ PurchAdvLetterLineCZZ2: Record "Purch. Adv. Letter Line CZZ";
+ VATEntry: Record "VAT Entry";
+ VATPostingSetup: Record "VAT Posting Setup";
+ PostedDocumentNo: Code[20];
+ begin
+ // [SCENARIO] Link purchase advance letter with normal VAT and reverse charge to purchase invoice with normal VAT and reverse charge and lower amount than the advance letter
+ Initialize();
+
+ // [GIVEN] Purchase advance letter has been created
+ // [GIVEN] Purchase advance letter line with reverse charge has been created
+ CreatePurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ1);
+
+ // [GIVEN] Purchase advance letter line with normal VAT has been created
+ LibraryPurchAdvancesCZZ.FindVATPostingSetup(VATPostingSetup);
+ LibraryPurchAdvancesCZZ.CreatePurchAdvLetterLine(
+ PurchAdvLetterLineCZZ2, PurchAdvLetterHeaderCZZ,
+ VATPostingSetup."VAT Prod. Posting Group", LibraryRandom.RandDec(1000, 2));
+
+ // [GIVEN] Purchase advance letter has been released
+ ReleasePurchAdvLetter(PurchAdvLetterHeaderCZZ);
+
+ // [GIVEN] Purchase advance letter has been paid in full by the general journal
+ PurchAdvLetterHeaderCZZ.CalcFields("Amount Including VAT");
+ CreateAndPostPaymentPurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterHeaderCZZ."Amount Including VAT");
+
+ // [GIVEN] Payment VAT has been posted
+ PostPurchAdvancePaymentVAT(PurchAdvLetterHeaderCZZ);
+
+ // [GIVEN] Purchase invoice has been created
+ // [GIVEN] First purchase invoice line with reverse charge has been created
+ LibraryPurchAdvancesCZZ.CreatePurchInvoice(
+ PurchaseHeader, PurchaseLine, PurchAdvLetterHeaderCZZ."Pay-to Vendor No.", PurchAdvLetterHeaderCZZ."Posting Date",
+ PurchAdvLetterLineCZZ1."VAT Bus. Posting Group", PurchAdvLetterLineCZZ1."VAT Prod. Posting Group", '', 0,
+ true, PurchAdvLetterLineCZZ1."Amount Including VAT" / 2);
+
+ // [GIVEN] Second purchase invoice line with normal VAT has been created
+ LibraryPurchAdvancesCZZ.CreateGLAccount(GLAccount);
+ GLAccount.Validate("VAT Bus. Posting Group", PurchAdvLetterLineCZZ2."VAT Bus. Posting Group");
+ GLAccount.Validate("VAT Prod. Posting Group", PurchAdvLetterLineCZZ2."VAT Prod. Posting Group");
+ GLAccount.Modify(true);
+
+ LibraryPurchase.CreatePurchaseLine(PurchaseLine, PurchaseHeader, PurchaseLine.Type::"G/L Account", GLAccount."No.", 1);
+ PurchaseLine.Validate("Direct Unit Cost", PurchAdvLetterLineCZZ2."Amount Including VAT" / 2);
+ PurchaseLine.Modify(true);
+
+ // [GIVEN] First line with reverse charge has been linked to purchase invoice
+ LibraryPurchAdvancesCZZ.LinkPurchAdvanceLetterToDocument(
+ PurchAdvLetterHeaderCZZ, Enum::"Adv. Letter Usage Doc.Type CZZ"::"Purchase Invoice", PurchaseHeader."No.",
+ PurchAdvLetterHeaderCZZ."Amount Including VAT", PurchAdvLetterHeaderCZZ."Amount Including VAT (LCY)");
+
+ // [WHEN] Post purchase invoice
+ PostedDocumentNo := PostPurchaseDocument(PurchaseHeader);
+
+ // [THEN] Sum of base and VAT amounts in VAT entries of invoice won't be zero
+ VATEntry.Reset();
+ VATEntry.SetRange("Document No.", PostedDocumentNo);
+ VATEntry.SetRange("Posting Date", PurchaseHeader."Posting Date");
+ VATEntry.CalcSums(Base, Amount);
+ Assert.AreNotEqual(0, VATEntry.Base, 'The sum of base amount in VAT Entries mustn''t be zero.');
+ Assert.AreNotEqual(0, VATEntry.Amount, 'The sum of VAT amount in VAT Entries mustn''t be zero.');
+
+ // [THEN] Sum of base and VAT amounts in VAT entries with reverse charge VAT won't be zero
+ VATEntry.SetRange("VAT Calculation Type", PurchAdvLetterLineCZZ1."VAT Calculation Type"::"Reverse Charge VAT");
+ VATEntry.CalcSums(Base, Amount);
+ Assert.AreNotEqual(0, VATEntry.Base, 'The sum of base amount in VAT Entries mustn''t be zero.');
+ Assert.AreNotEqual(0, VATEntry.Amount, 'The sum of VAT amount in VAT Entries mustn''t be zero.');
+
+ // [THEN] Sum of base and VAT amounts in VAT entries with normal VAT will be zero
+ VATEntry.SetRange("VAT Calculation Type", PurchAdvLetterLineCZZ1."VAT Calculation Type"::"Normal VAT");
+ VATEntry.CalcSums(Base, Amount);
+ Assert.AreEqual(0, VATEntry.Base, 'The sum of base amount in VAT Entries must be zero.');
+ Assert.AreEqual(0, VATEntry.Amount, 'The sum of VAT amount in VAT Entries must be zero.');
+ end;
+
+ local procedure CreatePurchAdvLetter(var PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ"; var PurchAdvLetterLineCZZ: Record "Purch. Adv. Letter Line CZZ"; VATPostingSetup: Record "VAT Posting Setup"; VendorNo: Code[20])
+ var
+ Vendor: Record Vendor;
+ begin
+ if VendorNo = '' then begin
+ LibraryPurchAdvancesCZZ.CreateVendor(Vendor);
+ Vendor.Validate("VAT Bus. Posting Group", VATPostingSetup."VAT Bus. Posting Group");
+ Vendor.Modify(true);
+ VendorNo := Vendor."No.";
+ end;
+
+ LibraryPurchAdvancesCZZ.CreatePurchAdvLetterHeader(PurchAdvLetterHeaderCZZ, AdvanceLetterTemplateCZZ.Code, VendorNo, '');
+ LibraryPurchAdvancesCZZ.CreatePurchAdvLetterLine(PurchAdvLetterLineCZZ, PurchAdvLetterHeaderCZZ, VATPostingSetup."VAT Prod. Posting Group", LibraryRandom.RandDec(1000, 2));
+ end;
+
+ local procedure CreatePurchAdvLetter(var PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ"; var PurchAdvLetterLineCZZ: Record "Purch. Adv. Letter Line CZZ"; VATPostingSetup: Record "VAT Posting Setup")
+ begin
+ CreatePurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ, VATPostingSetup, '');
+ end;
+
+ local procedure CreatePurchAdvLetter(var PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ"; var PurchAdvLetterLineCZZ: Record "Purch. Adv. Letter Line CZZ")
+ var
+ VATPostingSetup: Record "VAT Posting Setup";
+ begin
+ LibraryPurchAdvancesCZZ.FindVATPostingSetupEU(VATPostingSetup);
+ CreatePurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ, VATPostingSetup, '');
+ end;
+
+ local procedure CreateAndPostPaymentPurchAdvLetter(var PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ"; Amount: Decimal; ExchangeRate: Decimal; PostingDate: Date)
+ var
+ GenJournalLine: Record "Gen. Journal Line";
+ begin
+ LibraryPurchAdvancesCZZ.CreatePurchAdvancePayment(
+ GenJournalLine, PurchAdvLetterHeaderCZZ."Pay-to Vendor No.", Amount, PurchAdvLetterHeaderCZZ."Currency Code",
+ PurchAdvLetterHeaderCZZ."No.", ExchangeRate, PostingDate);
+ LibraryPurchAdvancesCZZ.PostPurchAdvancePayment(GenJournalLine);
+ end;
+
+ local procedure CreateAndPostPaymentPurchAdvLetter(var PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ"; Amount: Decimal)
+ begin
+ CreateAndPostPaymentPurchAdvLetter(PurchAdvLetterHeaderCZZ, Amount, 0, 0D);
+ end;
+
+ local procedure ReleasePurchAdvLetter(var PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ")
+ begin
+ LibraryPurchAdvancesCZZ.ReleasePurchAdvLetter(PurchAdvLetterHeaderCZZ);
+ end;
+
+ local procedure PostPurchaseDocument(var PurchaseHeader: Record "Purchase Header"): Code[20]
+ begin
+ exit(LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true));
+ end;
+
+ local procedure FindLastPaymentAdvanceLetterEntry(AdvanceLetterNo: Code[20]; var PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ")
+ begin
+ PurchAdvLetterEntryCZZ.SetRange("Purch. Adv. Letter No.", AdvanceLetterNo);
+ PurchAdvLetterEntryCZZ.SetRange("Entry Type", PurchAdvLetterEntryCZZ."Entry Type"::Payment);
+ PurchAdvLetterEntryCZZ.FindLast();
+ end;
+
+ local procedure PostPurchAdvancePaymentVAT(var PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ");
+ var
+ PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ";
+ begin
+ FindLastPaymentAdvanceLetterEntry(PurchAdvLetterHeaderCZZ."No.", PurchAdvLetterEntryCZZ);
+ PostPurchAdvancePaymentVAT(PurchAdvLetterEntryCZZ);
+ end;
+
+ local procedure PostPurchAdvancePaymentVAT(var PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ");
+ begin
+ LibraryVariableStorage.Enqueue(WorkDate()); // original document vat date
+ LibraryVariableStorage.Enqueue(PurchAdvLetterEntryCZZ."Document No."); // external document no.
+ LibraryPurchAdvancesCZZ.PostPurchAdvancePaymentVAT(PurchAdvLetterEntryCZZ);
+ end;
+
+ [ModalPageHandler]
+ procedure ModalVATDocumentHandler(var VATDocument: TestPage "VAT Document CZZ")
+ begin
+ VATDocument.OriginalDocumentVATDate.SetValue(LibraryVariableStorage.DequeueDate());
+ VATDocument.ExternalDocumentNo.SetValue(LibraryVariableStorage.DequeueText());
+ VATDocument.OK().Invoke();
+ end;
+}
diff --git a/Apps/CZ/AdvancePaymentsLocalization/test/Src/PurchaseAdvancePaymentsCZZ.Codeunit.al b/Apps/CZ/AdvancePaymentsLocalization/test/Src/PurchaseAdvancePaymentsCZZ.Codeunit.al
index 4c41130e98..8389c02b81 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/test/Src/PurchaseAdvancePaymentsCZZ.Codeunit.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/test/Src/PurchaseAdvancePaymentsCZZ.Codeunit.al
@@ -675,6 +675,9 @@ codeunit 148108 "Purchase Advance Payments CZZ"
// [SCENARIO] Link purchase advance letter with reverse charge to invoice
Initialize();
+ // [GIVEN] Posting of VAT documents for reverse charge has been enabled
+ SetPostVATDocForReverseCharge(true);
+
// [GIVEN] Purchase advance letter has been created
// [GIVEN] Purchase advance letter line with reverse charge has been created
CreatePurchAdvLetterWithReverseCharge(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ);
@@ -724,6 +727,8 @@ codeunit 148108 "Purchase Advance Payments CZZ"
// [THEN] Purchase advance letter will be closed
PurchAdvLetterHeaderCZZ.Get(PurchAdvLetterHeaderCZZ."No.");
PurchAdvLetterHeaderCZZ.TestField(Status, PurchAdvLetterHeaderCZZ.Status::Closed);
+
+ SetPostVATDocForReverseCharge(false);
end;
[Test]
@@ -2320,6 +2325,9 @@ codeunit 148108 "Purchase Advance Payments CZZ"
// [SCENARIO] Create purchase advance letter with two lines with different VAT rates and link to invoice with line which is the same as second line in advance letter and one VAT rate
Initialize();
+ // [GIVEN] Posting of VAT documents for reverse charge has been enabled
+ SetPostVATDocForReverseCharge(true);
+
// [GIVEN] Purchase advance letter has been created
// [GIVEN] Purchase advance letter line with normal VAT has been created
CreatePurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ1);
@@ -2379,6 +2387,8 @@ codeunit 148108 "Purchase Advance Payments CZZ"
VATEntry.SetRange("VAT Bus. Posting Group", VATEntry."VAT Bus. Posting Group");
VATEntry.SetRange("VAT Prod. Posting Group", VATEntry."VAT Prod. Posting Group");
Assert.RecordCount(VATEntry, VATEntryCount);
+
+ SetPostVATDocForReverseCharge(false);
end;
[Test]
@@ -2397,6 +2407,9 @@ codeunit 148108 "Purchase Advance Payments CZZ"
// [SCENARIO] Create purchase advance letter with two lines with different VAT rates and link to invoice with line which has the higher amount as first line in advance letter and one VAT rate
Initialize();
+ // [GIVEN] Posting of VAT documents for reverse charge has been enabled
+ SetPostVATDocForReverseCharge(true);
+
// [GIVEN] Purchase advance letter has been created
// [GIVEN] Purchase advance letter line with normal VAT has been created
CreatePurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ1);
@@ -2451,6 +2464,8 @@ codeunit 148108 "Purchase Advance Payments CZZ"
purchAdvLetterEntryCZZ2.SetRange("VAT Prod. Posting Group", PurchAdvLetterLineCZZ2."VAT Prod. Posting Group");
purchAdvLetterEntryCZZ2.SetRange("Entry Type", purchAdvLetterEntryCZZ2."Entry Type"::"VAT Usage");
Assert.RecordIsNotEmpty(PurchAdvLetterEntryCZZ2);
+
+ SetPostVATDocForReverseCharge(false);
end;
[Test]
@@ -2469,6 +2484,9 @@ codeunit 148108 "Purchase Advance Payments CZZ"
// [SCENARIO] Create purchase advance letter with two lines with different VAT rates and link to invoice with line which has the higher amount as second line in advance letter and one VAT rate
Initialize();
+ // [GIVEN] Posting of VAT documents for reverse charge has been enabled
+ SetPostVATDocForReverseCharge(true);
+
// [GIVEN] Purchase advance letter has been created
// [GIVEN] Purchase advance letter line with normal VAT has been created
CreatePurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ1);
@@ -2523,6 +2541,8 @@ codeunit 148108 "Purchase Advance Payments CZZ"
purchAdvLetterEntryCZZ2.SetRange("VAT Prod. Posting Group", PurchAdvLetterLineCZZ1."VAT Prod. Posting Group");
purchAdvLetterEntryCZZ2.SetRange("Entry Type", purchAdvLetterEntryCZZ2."Entry Type"::"VAT Usage");
Assert.RecordIsNotEmpty(PurchAdvLetterEntryCZZ2);
+
+ SetPostVATDocForReverseCharge(false);
end;
[Test]
@@ -2543,6 +2563,9 @@ codeunit 148108 "Purchase Advance Payments CZZ"
// [SCENARIO] Create purchase advance letter with two lines with different VAT rates and link to invoice with two lines which have the lower amounts as lines in advance letter
Initialize();
+ // [GIVEN] Posting of VAT documents for reverse charge has been enabled
+ SetPostVATDocForReverseCharge(true);
+
// [GIVEN] Purchase advance letter has been created
// [GIVEN] Purchase advance letter line with normal VAT has been created
CreatePurchAdvLetter(PurchAdvLetterHeaderCZZ, PurchAdvLetterLineCZZ1);
@@ -2616,6 +2639,8 @@ codeunit 148108 "Purchase Advance Payments CZZ"
VATEntry.CalcSums(Base, Amount);
Assert.AreEqual(0, VATEntry.Base, 'The sum of base amount in VAT Entries must be zero.');
Assert.AreEqual(0, VATEntry.Amount, 'The sum of VAT amount in VAT Entries must be zero.');
+
+ SetPostVATDocForReverseCharge(false);
end;
local procedure CreatePurchAdvLetterBase(var PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ"; var PurchAdvLetterLineCZZ: Record "Purch. Adv. Letter Line CZZ"; VendorNo: Code[20]; CurrencyCode: Code[10]; VATPostingSetup: Record "VAT Posting Setup")
@@ -2844,6 +2869,12 @@ codeunit 148108 "Purchase Advance Payments CZZ"
LibraryCashDocumentCZP.PostCashDocumentCZP(CashDocumentHeaderCZP);
end;
+ local procedure SetPostVATDocForReverseCharge(Value: Boolean)
+ begin
+ AdvanceLetterTemplateCZZ."Post VAT Doc. for Rev. Charge" := Value;
+ AdvanceLetterTemplateCZZ.Modify();
+ end;
+
local procedure FindNextVATPostingSetup(var VATPostingSetup: Record "VAT Posting Setup")
begin
LibraryERM.FindVATPostingSetup(VATPostingSetup, VATPostingSetup."VAT Calculation Type"::"Normal VAT");
diff --git a/Apps/CZ/AdvancePaymentsLocalization/test/Src/SalesAdvPmtRevChargeCZZ.Codeunit.al b/Apps/CZ/AdvancePaymentsLocalization/test/Src/SalesAdvPmtRevChargeCZZ.Codeunit.al
new file mode 100644
index 0000000000..d703b760b6
--- /dev/null
+++ b/Apps/CZ/AdvancePaymentsLocalization/test/Src/SalesAdvPmtRevChargeCZZ.Codeunit.al
@@ -0,0 +1,755 @@
+codeunit 148129 "Sales Adv. Pmt.Rev.Charge CZZ"
+{
+ Subtype = Test;
+ TestPermissions = Disabled;
+
+ trigger OnRun()
+ begin
+ // [FEATURE] [Advance Payments] [Sales] [Feverse Charge]
+ isInitialized := false;
+ end;
+
+ var
+ AdvanceLetterTemplateCZZ: Record "Advance Letter Template CZZ";
+ GeneralLedgerSetup: Record "General Ledger Setup";
+ Assert: Codeunit Assert;
+ LibraryDialogHandler: Codeunit "Library - Dialog Handler";
+ LibrarySalesAdvancesCZZ: Codeunit "Library - Sales Advances CZZ";
+ LibrarySales: Codeunit "Library - Sales";
+ LibraryRandom: Codeunit "Library - Random";
+ LibraryVariableStorage: Codeunit "Library - Variable Storage";
+ isInitialized: Boolean;
+
+ local procedure Initialize()
+ var
+ LibraryTestInitialize: Codeunit "Library - Test Initialize";
+ begin
+ LibraryTestInitialize.OnTestInitialize(Codeunit::"Sales Adv. Pmt.Rev.Charge CZZ");
+ LibraryRandom.Init();
+ LibraryVariableStorage.Clear();
+ LibraryDialogHandler.ClearVariableStorage();
+ if isInitialized then
+ exit;
+ LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Sales Adv. Pmt.Rev.Charge CZZ");
+
+ GeneralLedgerSetup.Get();
+ GeneralLedgerSetup."VAT Reporting Date Usage" := GeneralLedgerSetup."VAT Reporting Date Usage"::Enabled;
+ GeneralLedgerSetup."Def. Orig. Doc. VAT Date CZL" := GeneralLedgerSetup."Def. Orig. Doc. VAT Date CZL"::"VAT Date";
+ GeneralLedgerSetup."Max. VAT Difference Allowed" := 0.5;
+ GeneralLedgerSetup.Modify();
+
+ LibrarySalesAdvancesCZZ.CreateSalesAdvanceLetterTemplate(AdvanceLetterTemplateCZZ);
+ AdvanceLetterTemplateCZZ."Post VAT Doc. for Rev. Charge" := false;
+ AdvanceLetterTemplateCZZ.Modify();
+
+ isInitialized := true;
+ Commit();
+ LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::"Sales Adv. Pmt.Rev.Charge CZZ");
+ end;
+
+ [Test]
+ procedure SalesAdvLetterWithReverseCharge()
+ var
+ SalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ";
+ SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ";
+ SalesAdvLetterLineCZZ: Record "Sales Adv. Letter Line CZZ";
+ begin
+ // [SCENARIO] VAT document of sales advance letter with reverse charge
+ Initialize();
+
+ // [GIVEN] Sales advance letter has been created
+ // [GIVEN] Sales advance letter line with reverse charge has been created
+ CreateSalesAdvLetter(SalesAdvLetterHeaderCZZ, SalesAdvLetterLineCZZ);
+
+ // [GIVEN] Sales advance letter has been released
+ ReleaseSalesAdvLetter(SalesAdvLetterHeaderCZZ);
+
+ // [WHEN] Pay sales advance letter in full by the general journal
+ CreateAndPostPaymentSalesAdvLetter(SalesAdvLetterHeaderCZZ, -SalesAdvLetterLineCZZ."Amount Including VAT");
+
+ // [THEN] Sales advance letter entry of "VAT Payment" type will be created
+ SalesAdvLetterEntryCZZ.Reset();
+ SalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", SalesAdvLetterHeaderCZZ."No.");
+ SalesAdvLetterEntryCZZ.SetRange("Entry Type", SalesAdvLetterEntryCZZ."Entry Type"::"VAT Payment");
+ Assert.RecordIsNotEmpty(SalesAdvLetterEntryCZZ);
+
+ // [THEN] VAT entry won't be created for the sales advance letter entry with reverse charge
+ SalesAdvLetterEntryCZZ.FindFirst();
+ Assert.AreEqual(0, SalesAdvLetterEntryCZZ."VAT Entry No.", 'VAT entry mustn''t be created.');
+
+ // [THEN] Created sales advance letter entry will be marked as auxiliary
+ Assert.AreEqual(true, SalesAdvLetterEntryCZZ."Auxiliary Entry", 'Auxiliary entry must be true.');
+
+ // [THEN] The document no. will be equal to the advance letter no.
+ Assert.AreEqual(SalesAdvLetterHeaderCZZ."No.", SalesAdvLetterEntryCZZ."Document No.", 'Document No. must be equal to advance letter no.');
+ end;
+
+ [Test]
+ procedure LinkSalesAdvLetterWithReverseChargeToInvoice()
+ var
+ SalesHeader: Record "Sales Header";
+ SalesLine: Record "Sales Line";
+ SalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ";
+ SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ";
+ SalesAdvLetterLineCZZ: Record "Sales Adv. Letter Line CZZ";
+ VATEntry: Record "VAT Entry";
+ PostedDocumentNo: Code[20];
+ begin
+ // [SCENARIO] Link sales advance letter with reverse charge to sales invoice
+ Initialize();
+
+ // [GIVEN] Sales advance letter has been created
+ // [GIVEN] Sales advance letter line with reverse charge has been created
+ CreateSalesAdvLetter(SalesAdvLetterHeaderCZZ, SalesAdvLetterLineCZZ);
+
+ // [GIVEN] Sales advance letter has been released
+ ReleaseSalesAdvLetter(SalesAdvLetterHeaderCZZ);
+
+ // [GIVEN] Sales advance letter has been paid in full by the general journal
+ CreateAndPostPaymentSalesAdvLetter(SalesAdvLetterHeaderCZZ, -SalesAdvLetterLineCZZ."Amount Including VAT");
+
+ // [GIVEN] Sales invoice has been created
+ // [GIVEN] Sales invoice line with reverse charge has been created
+ LibrarySalesAdvancesCZZ.CreateSalesInvoice(
+ SalesHeader, SalesLine, SalesAdvLetterHeaderCZZ."Bill-to Customer No.", SalesAdvLetterHeaderCZZ."Posting Date",
+ SalesAdvLetterLineCZZ."VAT Bus. Posting Group", SalesAdvLetterLineCZZ."VAT Prod. Posting Group", '', 0,
+ true, SalesAdvLetterLineCZZ."Amount Including VAT");
+
+ // [GIVEN] Whole advance letter has been linked to sales invoice
+ LibrarySalesAdvancesCZZ.LinkSalesAdvanceLetterToDocument(
+ SalesAdvLetterHeaderCZZ, Enum::"Adv. Letter Usage Doc.Type CZZ"::"Sales Invoice", SalesHeader."No.",
+ SalesAdvLetterLineCZZ."Amount Including VAT", SalesAdvLetterLineCZZ."Amount Including VAT (LCY)");
+
+ // [WHEN] Post sales invoice
+ PostedDocumentNo := PostSalesDocument(SalesHeader);
+
+ // [THEN] VAT entries of sales invoice will exist
+ VATEntry.Reset();
+ VATEntry.SetRange("Document No.", PostedDocumentNo);
+ VATEntry.SetRange("Posting Date", SalesHeader."Posting Date");
+ VATEntry.SetRange("Advance Letter No. CZZ", '');
+ Assert.RecordIsNotEmpty(VATEntry);
+
+ // [THEN] VAT entries of advance letter won't be exist
+ VATEntry.SetRange("Advance Letter No. CZZ", SalesAdvLetterHeaderCZZ."No.");
+ Assert.RecordIsEmpty(VATEntry);
+
+ // [THEN] Sales advance letter entry of "Usage" type will be created
+ SalesAdvLetterEntryCZZ.Reset();
+ SalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", SalesAdvLetterHeaderCZZ."No.");
+ SalesAdvLetterEntryCZZ.CalcSums("VAT Base Amount", "VAT Base Amount (LCY)");
+ Assert.AreNearlyEqual(0, SalesAdvLetterEntryCZZ."VAT Base Amount", 1, 'The sum of VAT base amount must be zero.');
+ Assert.AreNearlyEqual(0, SalesAdvLetterEntryCZZ."VAT Base Amount (LCY)", 1, 'The sum of VAT base amount (LCY) must be zero.');
+
+ // [THEN] Sales advance letter will be closed
+ SalesAdvLetterHeaderCZZ.Get(SalesAdvLetterHeaderCZZ."No.");
+ SalesAdvLetterHeaderCZZ.TestField(Status, SalesAdvLetterHeaderCZZ.Status::Closed);
+ end;
+
+ [Test]
+ procedure SalesAdvLetterWithNormalVAT()
+ var
+ SalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ";
+ SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ";
+ SalesAdvLetterLineCZZ: Record "Sales Adv. Letter Line CZZ";
+ VATPostingSetup: Record "VAT Posting Setup";
+ begin
+ // [SCENARIO] VAT document of sales advance letter with normal VAT
+ Initialize();
+
+ // [GIVEN] Sales advance letter has been created
+ // [GIVEN] Sales advance letter line with normal VAT has been created
+ LibrarySalesAdvancesCZZ.FindVATPostingSetup(VATPostingSetup);
+ CreateSalesAdvLetter(SalesAdvLetterHeaderCZZ, SalesAdvLetterLineCZZ, VATPostingSetup);
+
+ // [GIVEN] Sales advance letter has been released
+ ReleaseSalesAdvLetter(SalesAdvLetterHeaderCZZ);
+
+ // [WHEN] Pay sales advance letter in full by the general journal
+ CreateAndPostPaymentSalesAdvLetter(SalesAdvLetterHeaderCZZ, -SalesAdvLetterLineCZZ."Amount Including VAT");
+
+ // [THEN] Sales advance letter entry of "VAT Payment" type will be created
+ SalesAdvLetterEntryCZZ.Reset();
+ SalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", SalesAdvLetterHeaderCZZ."No.");
+ SalesAdvLetterEntryCZZ.SetRange("Entry Type", SalesAdvLetterEntryCZZ."Entry Type"::"VAT Payment");
+ Assert.RecordIsNotEmpty(SalesAdvLetterEntryCZZ);
+
+ // [THEN] Created sales advance letter entry will have VAT amounts
+ SalesAdvLetterEntryCZZ.FindFirst();
+ Assert.AreNotEqual(0, SalesAdvLetterEntryCZZ."VAT Amount", 'VAT amount mustn''t be zero.');
+ Assert.AreNotEqual(0, SalesAdvLetterEntryCZZ."VAT Amount (LCY)", 'VAT amount (LCY) mustn''t be zero.');
+ Assert.AreNotEqual(0, SalesAdvLetterEntryCZZ."VAT Base Amount", 'VAT base amount mustn''t be zero.');
+ Assert.AreNotEqual(0, SalesAdvLetterEntryCZZ."VAT Base Amount (LCY)", 'VAT base amount (LCY) mustn''t be zero.');
+ Assert.AreNotEqual(0, SalesAdvLetterEntryCZZ."VAT Entry No.", 'VAT entry must be created.');
+
+ // [THEN] Created sales advance letter entry won't be marked as auxiliary
+ Assert.AreEqual(false, SalesAdvLetterEntryCZZ."Auxiliary Entry", 'Auxiliary entry must be false.');
+
+ // [THEN] The document no. won't be equal to the advance letter no.
+ Assert.AreNotEqual(SalesAdvLetterHeaderCZZ."No.", SalesAdvLetterEntryCZZ."Document No.", 'Document No. mustn''t be equal to advance letter no.');
+ end;
+
+ [Test]
+ procedure SalesAdvLetterWithNormalVATAndReverseCharge()
+ var
+ SalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ";
+ SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ";
+ SalesAdvLetterLineCZZ: Record "Sales Adv. Letter Line CZZ";
+ VATPostingSetup: Record "VAT Posting Setup";
+ begin
+ // [SCENARIO] VAT document of sales advance letter with normal VAT and reverse charge
+ Initialize();
+
+ // [GIVEN] Sales advance letter has been created
+ // [GIVEN] Sales advance letter line with reverse charge has been created
+ CreateSalesAdvLetter(SalesAdvLetterHeaderCZZ, SalesAdvLetterLineCZZ);
+
+ // [GIVEN] Sales advance letter line with normal VAT has been created
+ LibrarySalesAdvancesCZZ.FindVATPostingSetup(VATPostingSetup);
+ LibrarySalesAdvancesCZZ.CreateSalesAdvLetterLine(
+ SalesAdvLetterLineCZZ, SalesAdvLetterHeaderCZZ,
+ VATPostingSetup."VAT Prod. Posting Group", LibraryRandom.RandDec(1000, 2));
+
+ // [GIVEN] Sales advance letter has been released
+ ReleaseSalesAdvLetter(SalesAdvLetterHeaderCZZ);
+
+ // [WHEN] Pay sales advance letter in full by the general journal
+ SalesAdvLetterHeaderCZZ.CalcFields("Amount Including VAT");
+ CreateAndPostPaymentSalesAdvLetter(SalesAdvLetterHeaderCZZ, -SalesAdvLetterHeaderCZZ."Amount Including VAT");
+
+ // [THEN] Sales advance letter entry of "VAT Payment" type with normal VAT will be created
+ SalesAdvLetterEntryCZZ.Reset();
+ SalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", SalesAdvLetterHeaderCZZ."No.");
+ SalesAdvLetterEntryCZZ.SetRange("Entry Type", SalesAdvLetterEntryCZZ."Entry Type"::"VAT Payment");
+ SalesAdvLetterEntryCZZ.SetRange("VAT Calculation Type", SalesAdvLetterEntryCZZ."VAT Calculation Type"::"Normal VAT");
+ Assert.RecordIsNotEmpty(SalesAdvLetterEntryCZZ);
+
+ // [THEN] Created sales advance letter entry with normal VAT will have VAT amounts
+ SalesAdvLetterEntryCZZ.FindFirst();
+ Assert.AreNotEqual(0, SalesAdvLetterEntryCZZ."VAT Amount", 'VAT amount mustn''t be zero.');
+ Assert.AreNotEqual(0, SalesAdvLetterEntryCZZ."VAT Amount (LCY)", 'VAT amount (LCY) mustn''t be zero.');
+ Assert.AreNotEqual(0, SalesAdvLetterEntryCZZ."VAT Base Amount", 'VAT base amount mustn''t be zero.');
+ Assert.AreNotEqual(0, SalesAdvLetterEntryCZZ."VAT Base Amount (LCY)", 'VAT base amount (LCY) mustn''t be zero.');
+ Assert.AreNotEqual(0, SalesAdvLetterEntryCZZ."VAT Entry No.", 'VAT entry must be created.');
+
+ // [THEN] Sales advance letter entry with normal VAT won't be marked as auxiliary
+ Assert.AreEqual(false, SalesAdvLetterEntryCZZ."Auxiliary Entry", 'Auxiliary entry must be false.');
+
+ // [THEN] The document no. won't be equal to the advance letter no.
+ Assert.AreNotEqual(SalesAdvLetterHeaderCZZ."No.", SalesAdvLetterEntryCZZ."Document No.", 'Document No. mustn''t be equal to advance letter no.');
+
+ // [THEN] Sales advance letter entry of "VAT Payment" type with reverse charge will be created
+ SalesAdvLetterEntryCZZ.SetRange("VAT Calculation Type", SalesAdvLetterEntryCZZ."VAT Calculation Type"::"Reverse Charge VAT");
+ Assert.RecordIsNotEmpty(SalesAdvLetterEntryCZZ);
+
+ // [THEN] VAT entry won't be created for the sales advance letter entry with reverse charge
+ SalesAdvLetterEntryCZZ.FindFirst();
+ Assert.AreEqual(0, SalesAdvLetterEntryCZZ."VAT Entry No.", 'VAT entry mustn''t be created.');
+
+ // [THEN] Sales advance letter entry with reverse charge will be marked as auxiliary
+ Assert.AreEqual(true, SalesAdvLetterEntryCZZ."Auxiliary Entry", 'Auxiliary entry must be true.');
+
+ // [THEN] The document no. won't be equal to the advance letter no.
+ Assert.AreNotEqual(SalesAdvLetterHeaderCZZ."No.", SalesAdvLetterEntryCZZ."Document No.", 'Document No. mustn''t be equal to advance letter no.');
+ end;
+
+ [Test]
+ procedure SalesAdvLetterWithNormalVATAndReverseChargePartiallyPaid()
+ var
+ SalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ";
+ SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ";
+ SalesAdvLetterLineCZZ: Record "Sales Adv. Letter Line CZZ";
+ VATPostingSetup: Record "VAT Posting Setup";
+ PaymentAmount: Decimal;
+ VATPaymentAmount: Decimal;
+ begin
+ // [SCENARIO] VAT document of sales advance letter with normal VAT and reverse charge is partially paid
+ Initialize();
+
+ // [GIVEN] Sales advance letter has been created
+ // [GIVEN] Sales advance letter line with reverse charge has been created
+ CreateSalesAdvLetter(SalesAdvLetterHeaderCZZ, SalesAdvLetterLineCZZ);
+
+ // [GIVEN] Sales advance letter line with normal VAT has been created
+ LibrarySalesAdvancesCZZ.FindVATPostingSetup(VATPostingSetup);
+ LibrarySalesAdvancesCZZ.CreateSalesAdvLetterLine(
+ SalesAdvLetterLineCZZ, SalesAdvLetterHeaderCZZ,
+ VATPostingSetup."VAT Prod. Posting Group", LibraryRandom.RandDec(1000, 2));
+
+ // [GIVEN] Sales advance letter has been released
+ ReleaseSalesAdvLetter(SalesAdvLetterHeaderCZZ);
+
+ // [WHEN] Pay sales advance letter in half by the general journal
+ SalesAdvLetterHeaderCZZ.CalcFields("Amount Including VAT");
+ CreateAndPostPaymentSalesAdvLetter(SalesAdvLetterHeaderCZZ, -SalesAdvLetterHeaderCZZ."Amount Including VAT" / 2);
+
+ // [THEN] Sales advance letter entry of "VAT Payment" type with normal VAT will be created
+ SalesAdvLetterEntryCZZ.Reset();
+ SalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", SalesAdvLetterHeaderCZZ."No.");
+ SalesAdvLetterEntryCZZ.SetRange("Entry Type", SalesAdvLetterEntryCZZ."Entry Type"::"VAT Payment");
+ SalesAdvLetterEntryCZZ.SetRange("VAT Calculation Type", SalesAdvLetterEntryCZZ."VAT Calculation Type"::"Normal VAT");
+ Assert.RecordIsNotEmpty(SalesAdvLetterEntryCZZ);
+
+ // [THEN] Created sales advance letter entry with normal VAT will have VAT amounts
+ SalesAdvLetterEntryCZZ.FindFirst();
+ VATPaymentAmount := SalesAdvLetterEntryCZZ."Amount";
+ Assert.AreNotEqual(0, SalesAdvLetterEntryCZZ."VAT Amount", 'VAT amount mustn''t be zero.');
+ Assert.AreNotEqual(0, SalesAdvLetterEntryCZZ."VAT Amount (LCY)", 'VAT amount (LCY) mustn''t be zero.');
+ Assert.AreNotEqual(0, SalesAdvLetterEntryCZZ."VAT Base Amount", 'VAT base amount mustn''t be zero.');
+ Assert.AreNotEqual(0, SalesAdvLetterEntryCZZ."VAT Base Amount (LCY)", 'VAT base amount (LCY) mustn''t be zero.');
+ Assert.AreNotEqual(0, SalesAdvLetterEntryCZZ."VAT Entry No.", 'VAT entry must be created.');
+
+ // [THEN] Created sales advance letter entry with normal VAT won't be marked as auxiliary
+ Assert.AreEqual(false, SalesAdvLetterEntryCZZ."Auxiliary Entry", 'Auxiliary entry must be false.');
+
+ // [THEN] The document no. won't be equal to the advance letter no.
+ Assert.AreNotEqual(SalesAdvLetterHeaderCZZ."No.", SalesAdvLetterEntryCZZ."Document No.", 'Document No. mustn''t be equal to advance letter no.');
+
+ // [THEN] Sales advance letter entry of "VAT Payment" type with reverse charge will be created
+ SalesAdvLetterEntryCZZ.SetRange("VAT Calculation Type", SalesAdvLetterEntryCZZ."VAT Calculation Type"::"Reverse Charge VAT");
+ Assert.RecordIsNotEmpty(SalesAdvLetterEntryCZZ);
+
+ // [THEN] VAT entry won't be created for the sales advance letter entry with reverse charge
+ SalesAdvLetterEntryCZZ.FindFirst();
+ VATPaymentAmount += SalesAdvLetterEntryCZZ."Amount";
+ Assert.AreEqual(0, SalesAdvLetterEntryCZZ."VAT Entry No.", 'VAT entry mustn''t be created.');
+
+ // [THEN] Created sales advance letter entry with reverse charge will be marked as auxiliary
+ Assert.AreEqual(true, SalesAdvLetterEntryCZZ."Auxiliary Entry", 'Auxiliary entry must be true.');
+
+ // [THEN] The document no. won't be equal to the advance letter no.
+ Assert.AreNotEqual(SalesAdvLetterHeaderCZZ."No.", SalesAdvLetterEntryCZZ."Document No.", 'Document No. mustn''t be equal to advance letter no.');
+
+ // [THEN] The sum of payment amount must be equal to the sum of VAT payment amount
+ SalesAdvLetterEntryCZZ.Reset();
+ FindLastPaymentAdvanceLetterEntry(SalesAdvLetterHeaderCZZ."No.", SalesAdvLetterEntryCZZ);
+ PaymentAmount := SalesAdvLetterEntryCZZ."Amount";
+ Assert.AreEqual(PaymentAmount, VATPaymentAmount, 'The sum of payment amount must be equal to the sum of VAT payment amount.');
+ end;
+
+ [Test]
+ procedure LinkSalesAdvLetterWithNormalVATAndReverseChargeToInvoice1()
+ var
+ SalesHeader: Record "Sales Header";
+ SalesLine: Record "Sales Line";
+ SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ";
+ SalesAdvLetterLineCZZ1: Record "Sales Adv. Letter Line CZZ";
+ SalesAdvLetterLineCZZ2: Record "Sales Adv. Letter Line CZZ";
+ VATEntry: Record "VAT Entry";
+ VATPostingSetup: Record "VAT Posting Setup";
+ PostedDocumentNo: Code[20];
+ begin
+ // [SCENARIO] Link sales advance letter with normal VAT and reverse charge to sales invoice with normal VAT
+ Initialize();
+
+ // [GIVEN] Sales advance letter has been created
+ // [GIVEN] Sales advance letter line with reverse charge has been created
+ CreateSalesAdvLetter(SalesAdvLetterHeaderCZZ, SalesAdvLetterLineCZZ1);
+
+ // [GIVEN] Sales advance letter line with normal VAT has been created
+ LibrarySalesAdvancesCZZ.FindVATPostingSetup(VATPostingSetup); // normal VAT
+ LibrarySalesAdvancesCZZ.CreateSalesAdvLetterLine(
+ SalesAdvLetterLineCZZ2, SalesAdvLetterHeaderCZZ,
+ VATPostingSetup."VAT Prod. Posting Group", LibraryRandom.RandDec(1000, 2));
+
+ // [GIVEN] Sales advance letter has been released
+ ReleaseSalesAdvLetter(SalesAdvLetterHeaderCZZ);
+
+ // [GIVEN] Sales advance letter has been paid in full by the general journal
+ SalesAdvLetterHeaderCZZ.CalcFields("Amount Including VAT");
+ CreateAndPostPaymentSalesAdvLetter(SalesAdvLetterHeaderCZZ, -SalesAdvLetterHeaderCZZ."Amount Including VAT");
+
+ // [GIVEN] Sales invoice has been created
+ // [GIVEN] Sales invoice line with normal VAT has been created
+ LibrarySalesAdvancesCZZ.CreateSalesInvoice(
+ SalesHeader, SalesLine, SalesAdvLetterHeaderCZZ."Bill-to Customer No.", SalesAdvLetterHeaderCZZ."Posting Date",
+ SalesAdvLetterLineCZZ2."VAT Bus. Posting Group", SalesAdvLetterLineCZZ2."VAT Prod. Posting Group", '', 0,
+ true, SalesAdvLetterLineCZZ2."Amount Including VAT");
+
+ // [GIVEN] Second line with normal VAT has been linked to sales invoice
+ LibrarySalesAdvancesCZZ.LinkSalesAdvanceLetterToDocument(
+ SalesAdvLetterHeaderCZZ, Enum::"Adv. Letter Usage Doc.Type CZZ"::"Sales Invoice", SalesHeader."No.",
+ SalesAdvLetterHeaderCZZ."Amount Including VAT", SalesAdvLetterHeaderCZZ."Amount Including VAT (LCY)");
+
+ // [WHEN] Post sales invoice
+ PostedDocumentNo := PostSalesDocument(SalesHeader);
+
+ // [THEN] VAT entries of sales invoice will exist
+ VATEntry.Reset();
+ VATEntry.SetRange("Document No.", PostedDocumentNo);
+ VATEntry.SetRange("Posting Date", SalesHeader."Posting Date");
+ VATEntry.SetRange("Advance Letter No. CZZ", '');
+ Assert.RecordIsNotEmpty(VATEntry);
+
+ // [THEN] VAT entries of advance letter will exist
+ VATEntry.SetRange("Advance Letter No. CZZ", SalesAdvLetterHeaderCZZ."No.");
+ Assert.RecordIsNotEmpty(VATEntry);
+
+ // [THEN] Sum of base and VAT amounts in VAT entries will be zero
+ VATEntry.SetRange("Advance Letter No. CZZ");
+ VATEntry.CalcSums(Base, Amount);
+ Assert.AreEqual(0, VATEntry.Base, 'The sum of base amount in VAT Entries must be zero.');
+ Assert.AreEqual(0, VATEntry.Amount, 'The sum of VAT amount in VAT Entries must be zero.');
+
+ // [THEN] VAT entries will have the same VAT calculation type
+ VATEntry.SetFilter("VAT Calculation Type", '<>%1', SalesAdvLetterLineCZZ2."VAT Calculation Type");
+ Assert.RecordIsEmpty(VATEntry);
+ end;
+
+ [Test]
+ procedure LinkSalesAdvLetterWithNormalVATAndReverseChargeToInvoice2()
+ var
+ SalesHeader: Record "Sales Header";
+ SalesLine: Record "Sales Line";
+ SalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ";
+ SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ";
+ SalesAdvLetterLineCZZ1: Record "Sales Adv. Letter Line CZZ";
+ SalesAdvLetterLineCZZ2: Record "Sales Adv. Letter Line CZZ";
+ VATEntry: Record "VAT Entry";
+ VATPostingSetup: Record "VAT Posting Setup";
+ PostedDocumentNo: Code[20];
+ begin
+ // [SCENARIO] Link sales advance letter with normal VAT and reverse charge to sales invoice with reverse charge
+ Initialize();
+
+ // [GIVEN] Sales advance letter has been created
+ // [GIVEN] Sales advance letter line with reverse charge has been created
+ CreateSalesAdvLetter(SalesAdvLetterHeaderCZZ, SalesAdvLetterLineCZZ1);
+
+ // [GIVEN] Sales advance letter line with normal VAT has been created
+ LibrarySalesAdvancesCZZ.FindVATPostingSetup(VATPostingSetup);
+ LibrarySalesAdvancesCZZ.CreateSalesAdvLetterLine(
+ SalesAdvLetterLineCZZ2, SalesAdvLetterHeaderCZZ,
+ VATPostingSetup."VAT Prod. Posting Group", LibraryRandom.RandDec(1000, 2));
+
+ // [GIVEN] Sales advance letter has been released
+ ReleaseSalesAdvLetter(SalesAdvLetterHeaderCZZ);
+
+ // [GIVEN] Sales advance letter has been paid in full by the general journal
+ SalesAdvLetterHeaderCZZ.CalcFields("Amount Including VAT");
+ CreateAndPostPaymentSalesAdvLetter(SalesAdvLetterHeaderCZZ, -SalesAdvLetterHeaderCZZ."Amount Including VAT");
+
+ // [GIVEN] Sales invoice has been created
+ // [GIVEN] Sales invoice line with reverse charge has been created
+ LibrarySalesAdvancesCZZ.CreateSalesInvoice(
+ SalesHeader, SalesLine, SalesAdvLetterHeaderCZZ."Bill-to Customer No.", SalesAdvLetterHeaderCZZ."Posting Date",
+ SalesAdvLetterLineCZZ1."VAT Bus. Posting Group", SalesAdvLetterLineCZZ1."VAT Prod. Posting Group", '', 0,
+ true, SalesAdvLetterLineCZZ1."Amount Including VAT");
+
+ // [GIVEN] First line with reverse charge has been linked to sales invoice
+ LibrarySalesAdvancesCZZ.LinkSalesAdvanceLetterToDocument(
+ SalesAdvLetterHeaderCZZ, Enum::"Adv. Letter Usage Doc.Type CZZ"::"Sales Invoice", SalesHeader."No.",
+ SalesAdvLetterHeaderCZZ."Amount Including VAT", SalesAdvLetterHeaderCZZ."Amount Including VAT (LCY)");
+
+ // [WHEN] Post sales invoice
+ PostedDocumentNo := PostSalesDocument(SalesHeader);
+
+ // [THEN] VAT entries of sales invoice will exist
+ VATEntry.Reset();
+ VATEntry.SetRange("Document No.", PostedDocumentNo);
+ VATEntry.SetRange("Posting Date", SalesHeader."Posting Date");
+ VATEntry.SetRange("Advance Letter No. CZZ", '');
+ Assert.RecordIsNotEmpty(VATEntry);
+
+ // [THEN] VAT entries of advance letter won't exist
+ VATEntry.SetRange("Advance Letter No. CZZ", SalesAdvLetterHeaderCZZ."No.");
+ Assert.RecordIsEmpty(VATEntry);
+
+ // [THEN] Sum of base and VAT amounts in VAT entries won't be zero
+ VATEntry.SetRange("Advance Letter No. CZZ");
+ VATEntry.CalcSums(Base, Amount);
+ Assert.AreNotEqual(0, VATEntry.Base, 'The sum of base amount in VAT Entries mustn''t be zero.');
+
+ // [THEN] Sales advance letter entry of "VAT Usage" type with reverse charge will be created
+ SalesAdvLetterEntryCZZ.Reset();
+ SalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", SalesAdvLetterHeaderCZZ."No.");
+ SalesAdvLetterEntryCZZ.SetRange("Entry Type", SalesAdvLetterEntryCZZ."Entry Type"::"VAT Usage");
+ SalesAdvLetterEntryCZZ.SetRange("VAT Calculation Type", SalesAdvLetterEntryCZZ."VAT Calculation Type"::"Reverse Charge VAT");
+ SalesAdvLetterEntryCZZ.SetRange("Auxiliary Entry", true);
+ Assert.RecordIsNotEmpty(SalesAdvLetterEntryCZZ);
+
+ // [THEN] Sales advance letter entry of "VAT Usage" type with normal VAT won't be created
+ SalesAdvLetterEntryCZZ.Reset();
+ SalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", SalesAdvLetterHeaderCZZ."No.");
+ SalesAdvLetterEntryCZZ.SetRange("Entry Type", SalesAdvLetterEntryCZZ."Entry Type"::"VAT Usage");
+ SalesAdvLetterEntryCZZ.SetRange("VAT Calculation Type", SalesAdvLetterEntryCZZ."VAT Calculation Type"::"Normal VAT");
+ Assert.RecordIsEmpty(SalesAdvLetterEntryCZZ);
+ end;
+
+ [Test]
+ procedure LinkSalesAdvLetterWithNormalVATAndReverseChargeToInvoice3()
+ var
+ SalesHeader: Record "Sales Header";
+ SalesLine: Record "Sales Line";
+ SalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ";
+ SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ";
+ SalesAdvLetterLineCZZ1: Record "Sales Adv. Letter Line CZZ";
+ SalesAdvLetterLineCZZ2: Record "Sales Adv. Letter Line CZZ";
+ VATEntry: Record "VAT Entry";
+ VATPostingSetup: Record "VAT Posting Setup";
+ PostedDocumentNo: Code[20];
+ VATPaymentAmount, VATPaymentAmountLCY : Decimal;
+ begin
+ // [SCENARIO] Link sales advance letter with normal VAT and reverse charge to sales invoice with normal VAT and higher amount than the advance letter
+ Initialize();
+
+ // [GIVEN] Sales advance letter has been created
+ // [GIVEN] Sales advance letter line with reverse charge has been created
+ CreateSalesAdvLetter(SalesAdvLetterHeaderCZZ, SalesAdvLetterLineCZZ1);
+
+ // [GIVEN] Sales advance letter line with normal VAT has been created
+ LibrarySalesAdvancesCZZ.FindVATPostingSetup(VATPostingSetup);
+ LibrarySalesAdvancesCZZ.CreateSalesAdvLetterLine(
+ SalesAdvLetterLineCZZ2, SalesAdvLetterHeaderCZZ,
+ VATPostingSetup."VAT Prod. Posting Group", LibraryRandom.RandDec(1000, 2));
+
+ // [GIVEN] Sales advance letter has been released
+ ReleaseSalesAdvLetter(SalesAdvLetterHeaderCZZ);
+
+ // [GIVEN] Sales advance letter has been paid in full by the general journal
+ SalesAdvLetterHeaderCZZ.CalcFields("Amount Including VAT");
+ CreateAndPostPaymentSalesAdvLetter(SalesAdvLetterHeaderCZZ, -SalesAdvLetterHeaderCZZ."Amount Including VAT");
+
+ // [GIVEN] Sales invoice has been created
+ // [GIVEN] Sales invoice line with normal VAT has been created
+ LibrarySalesAdvancesCZZ.CreateSalesInvoice(
+ SalesHeader, SalesLine, SalesAdvLetterHeaderCZZ."Bill-to Customer No.", SalesAdvLetterHeaderCZZ."Posting Date",
+ SalesAdvLetterLineCZZ2."VAT Bus. Posting Group", SalesAdvLetterLineCZZ2."VAT Prod. Posting Group", '', 0,
+ true, SalesAdvLetterLineCZZ2."Amount Including VAT" + (SalesAdvLetterLineCZZ1."Amount Including VAT" / 2));
+
+ // [GIVEN] First line with normal VAT has been linked to sales invoice
+ LibrarySalesAdvancesCZZ.LinkSalesAdvanceLetterToDocument(
+ SalesAdvLetterHeaderCZZ, Enum::"Adv. Letter Usage Doc.Type CZZ"::"Sales Invoice", SalesHeader."No.",
+ SalesAdvLetterHeaderCZZ."Amount Including VAT", SalesAdvLetterHeaderCZZ."Amount Including VAT (LCY)");
+
+ // [WHEN] Post sales invoice
+ PostedDocumentNo := PostSalesDocument(SalesHeader);
+
+ // [THEN] Sales advance letter entry of "VAT Usage" type will have amount equal to the amount of "VAT Payment" entry
+ SalesAdvLetterEntryCZZ.Reset();
+ SalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", SalesAdvLetterHeaderCZZ."No.");
+ SalesAdvLetterEntryCZZ.SetRange("Entry Type", SalesAdvLetterEntryCZZ."Entry Type"::"VAT Payment");
+ SalesAdvLetterEntryCZZ.SetRange("VAT Calculation Type", SalesAdvLetterLineCZZ2."VAT Calculation Type");
+ SalesAdvLetterEntryCZZ.CalcSums(Amount, "Amount (LCY)");
+ VATPaymentAmount := SalesAdvLetterEntryCZZ.Amount;
+ VATPaymentAmountLCY := SalesAdvLetterEntryCZZ."Amount (LCY)";
+
+ SalesAdvLetterEntryCZZ.Reset();
+ SalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", SalesAdvLetterHeaderCZZ."No.");
+ SalesAdvLetterEntryCZZ.SetRange("Entry Type", SalesAdvLetterEntryCZZ."Entry Type"::"VAT Usage");
+ SalesAdvLetterEntryCZZ.SetRange("VAT Calculation Type", SalesAdvLetterLineCZZ2."VAT Calculation Type");
+ SalesAdvLetterEntryCZZ.FindFirst();
+ Assert.AreEqual(VATPaymentAmount, -SalesAdvLetterEntryCZZ.Amount, 'The amount of VAT Payment entry must be equal to the amount of VAT Usage entry.');
+ Assert.AreEqual(VATPaymentAmountLCY, -SalesAdvLetterEntryCZZ."Amount (LCY)", 'The amount (LCY) of VAT Payment entry must be equal to the amount (LCY) of VAT Usage entry.');
+
+ // [THEN] Sum of base and VAT amounts in VAT entries won't be zero
+ VATEntry.Reset();
+ VATEntry.SetRange("Document No.", PostedDocumentNo);
+ VATEntry.SetRange("Posting Date", SalesHeader."Posting Date");
+ VATEntry.CalcSums(Base, Amount);
+ Assert.AreNotEqual(0, VATEntry.Base, 'The sum of base amount in VAT Entries mustn''t be zero.');
+ Assert.AreNotEqual(0, VATEntry.Amount, 'The sum of VAT amount in VAT Entries mustn''t be zero.');
+ end;
+
+ [Test]
+ procedure LinkSalesAdvLetterWithNormalVATAndReverseChargeToInvoice4()
+ var
+ SalesHeader: Record "Sales Header";
+ SalesLine: Record "Sales Line";
+ SalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ";
+ SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ";
+ SalesAdvLetterLineCZZ1: Record "Sales Adv. Letter Line CZZ";
+ SalesAdvLetterLineCZZ2: Record "Sales Adv. Letter Line CZZ";
+ VATPostingSetup: Record "VAT Posting Setup";
+ begin
+ // [SCENARIO] Link sales advance letter with normal VAT and reverse charge to sales invoice with reverse charge and higher amount than the advance letter
+ Initialize();
+
+ // [GIVEN] Sales advance letter has been created
+ // [GIVEN] Sales advance letter line with reverse charge has been created
+ CreateSalesAdvLetter(SalesAdvLetterHeaderCZZ, SalesAdvLetterLineCZZ1);
+
+ // [GIVEN] Sales advance letter line with normal VAT has been created
+ LibrarySalesAdvancesCZZ.FindVATPostingSetup(VATPostingSetup);
+ LibrarySalesAdvancesCZZ.CreateSalesAdvLetterLine(
+ SalesAdvLetterLineCZZ2, SalesAdvLetterHeaderCZZ,
+ VATPostingSetup."VAT Prod. Posting Group", LibraryRandom.RandDec(1000, 2));
+
+ // [GIVEN] Sales advance letter has been released
+ ReleaseSalesAdvLetter(SalesAdvLetterHeaderCZZ);
+
+ // [GIVEN] Sales advance letter has been paid in full by the general journal
+ SalesAdvLetterHeaderCZZ.CalcFields("Amount Including VAT");
+ CreateAndPostPaymentSalesAdvLetter(SalesAdvLetterHeaderCZZ, -SalesAdvLetterHeaderCZZ."Amount Including VAT");
+
+ // [GIVEN] Sales invoice has been created
+ // [GIVEN] Sales invoice line with reverse charge has been created
+ LibrarySalesAdvancesCZZ.CreateSalesInvoice(
+ SalesHeader, SalesLine, SalesAdvLetterHeaderCZZ."Bill-to Customer No.", SalesAdvLetterHeaderCZZ."Posting Date",
+ SalesAdvLetterLineCZZ1."VAT Bus. Posting Group", SalesAdvLetterLineCZZ1."VAT Prod. Posting Group", '', 0,
+ true, SalesAdvLetterLineCZZ1."Amount Including VAT" + Round(SalesAdvLetterLineCZZ2."Amount Including VAT" / 2));
+
+ // [GIVEN] First line with reverse charge has been linked to sales invoice
+ LibrarySalesAdvancesCZZ.LinkSalesAdvanceLetterToDocument(
+ SalesAdvLetterHeaderCZZ, Enum::"Adv. Letter Usage Doc.Type CZZ"::"Sales Invoice", SalesHeader."No.",
+ SalesAdvLetterHeaderCZZ."Amount Including VAT", SalesAdvLetterHeaderCZZ."Amount Including VAT (LCY)");
+
+ // [WHEN] Post sales invoice
+ PostSalesDocument(SalesHeader);
+
+ // [THEN] Sales advance letter entry of "VAT Usage" type will have amount equal to part of the amount of "VAT Payment" entry with normal VAT
+ SalesAdvLetterEntryCZZ.Reset();
+ SalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", SalesAdvLetterHeaderCZZ."No.");
+ SalesAdvLetterEntryCZZ.SetRange("Entry Type", SalesAdvLetterEntryCZZ."Entry Type"::"VAT Usage");
+ SalesAdvLetterEntryCZZ.SetRange("VAT Calculation Type", SalesAdvLetterLineCZZ2."VAT Calculation Type");
+ SalesAdvLetterEntryCZZ.FindFirst();
+ Assert.AreEqual(Round(SalesAdvLetterLineCZZ2."Amount Including VAT" / 2), SalesAdvLetterEntryCZZ.Amount, 'The amount of VAT Payment entry must be equal to the amount of VAT Usage entry.');
+
+ // [THEN] Sales advance letter entry of "VAT Usage" type will have amount equal to the amount of "VAT Payment" entry with reverse charge
+ SalesAdvLetterEntryCZZ.Reset();
+ SalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", SalesAdvLetterHeaderCZZ."No.");
+ SalesAdvLetterEntryCZZ.SetRange("Entry Type", SalesAdvLetterEntryCZZ."Entry Type"::"VAT Usage");
+ SalesAdvLetterEntryCZZ.SetRange("VAT Calculation Type", SalesAdvLetterLineCZZ1."VAT Calculation Type");
+ SalesAdvLetterEntryCZZ.SetRange("Auxiliary Entry", true);
+ SalesAdvLetterEntryCZZ.SetRange("VAT Entry No.", 0);
+ SalesAdvLetterEntryCZZ.FindFirst();
+ Assert.AreEqual(SalesAdvLetterLineCZZ1."Amount Including VAT", SalesAdvLetterEntryCZZ.Amount, 'The amount of VAT Payment entry must be equal to the amount of VAT Usage entry.');
+ end;
+
+ [Test]
+ procedure LinkSalesAdvLetterWithNormalVATAndReverseChargeToInvoice5()
+ var
+ GLAccount: Record "G/L Account";
+ SalesHeader: Record "Sales Header";
+ SalesLine: Record "Sales Line";
+ SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ";
+ SalesAdvLetterLineCZZ1: Record "Sales Adv. Letter Line CZZ";
+ SalesAdvLetterLineCZZ2: Record "Sales Adv. Letter Line CZZ";
+ VATEntry: Record "VAT Entry";
+ VATPostingSetup: Record "VAT Posting Setup";
+ PostedDocumentNo: Code[20];
+ begin
+ // [SCENARIO] Link sales advance letter with normal VAT and reverse charge to sales invoice with normal VAT and reverse charge and lower amount than the advance letter
+ Initialize();
+
+ // [GIVEN] Sales advance letter has been created
+ // [GIVEN] Sales advance letter line with reverse charge has been created
+ CreateSalesAdvLetter(SalesAdvLetterHeaderCZZ, SalesAdvLetterLineCZZ1);
+
+ // [GIVEN] Sales advance letter line with normal VAT has been created
+ LibrarySalesAdvancesCZZ.FindVATPostingSetup(VATPostingSetup);
+ LibrarySalesAdvancesCZZ.CreateSalesAdvLetterLine(
+ SalesAdvLetterLineCZZ2, SalesAdvLetterHeaderCZZ,
+ VATPostingSetup."VAT Prod. Posting Group", LibraryRandom.RandDec(1000, 2));
+
+ // [GIVEN] Sales advance letter has been released
+ ReleaseSalesAdvLetter(SalesAdvLetterHeaderCZZ);
+
+ // [GIVEN] Sales advance letter has been paid in full by the general journal
+ SalesAdvLetterHeaderCZZ.CalcFields("Amount Including VAT");
+ CreateAndPostPaymentSalesAdvLetter(SalesAdvLetterHeaderCZZ, -SalesAdvLetterHeaderCZZ."Amount Including VAT");
+
+ // [GIVEN] Sales invoice has been created
+ // [GIVEN] First sales invoice line with reverse charge has been created
+ LibrarySalesAdvancesCZZ.CreateSalesInvoice(
+ SalesHeader, SalesLine, SalesAdvLetterHeaderCZZ."Bill-to Customer No.", SalesAdvLetterHeaderCZZ."Posting Date",
+ SalesAdvLetterLineCZZ1."VAT Bus. Posting Group", SalesAdvLetterLineCZZ1."VAT Prod. Posting Group", '', 0,
+ true, SalesAdvLetterLineCZZ1."Amount Including VAT" / 2);
+
+ // [GIVEN] Second sales invoice line with normal VAT has been created
+ LibrarySalesAdvancesCZZ.CreateGLAccount(GLAccount);
+ GLAccount.Validate("VAT Bus. Posting Group", SalesAdvLetterLineCZZ2."VAT Bus. Posting Group");
+ GLAccount.Validate("VAT Prod. Posting Group", SalesAdvLetterLineCZZ2."VAT Prod. Posting Group");
+ GLAccount.Modify(true);
+
+ LibrarySales.CreateSalesLine(SalesLine, SalesHeader, SalesLine.Type::"G/L Account", GLAccount."No.", 1);
+ SalesLine.Validate("Unit Price", SalesAdvLetterLineCZZ2."Amount Including VAT" / 2);
+ SalesLine.Modify(true);
+
+ // [GIVEN] First line with reverse charge has been linked to sales invoice
+ LibrarySalesAdvancesCZZ.LinkSalesAdvanceLetterToDocument(
+ SalesAdvLetterHeaderCZZ, Enum::"Adv. Letter Usage Doc.Type CZZ"::"Sales Invoice", SalesHeader."No.",
+ SalesAdvLetterHeaderCZZ."Amount Including VAT", SalesAdvLetterHeaderCZZ."Amount Including VAT (LCY)");
+
+ // [WHEN] Post sales invoice
+ PostedDocumentNo := PostSalesDocument(SalesHeader);
+
+ // [THEN] Sum of base and VAT amounts in VAT entries of invoice won't be zero
+ VATEntry.Reset();
+ VATEntry.SetRange("Document No.", PostedDocumentNo);
+ VATEntry.SetRange("Posting Date", SalesHeader."Posting Date");
+ VATEntry.CalcSums(Base, Amount);
+ Assert.AreNotEqual(0, VATEntry.Base, 'The sum of base amount in VAT Entries mustn''t be zero.');
+
+ // [THEN] Sum of base and VAT amounts in VAT entries with reverse charge VAT won't be zero
+ VATEntry.SetRange("VAT Calculation Type", SalesAdvLetterLineCZZ1."VAT Calculation Type"::"Reverse Charge VAT");
+ VATEntry.CalcSums(Base, Amount);
+ Assert.AreNotEqual(0, VATEntry.Base, 'The sum of base amount in VAT Entries mustn''t be zero.');
+
+ // [THEN] Sum of base and VAT amounts in VAT entries with normal VAT will be zero
+ VATEntry.SetRange("VAT Calculation Type", SalesAdvLetterLineCZZ1."VAT Calculation Type"::"Normal VAT");
+ VATEntry.CalcSums(Base, Amount);
+ Assert.AreEqual(0, VATEntry.Base, 'The sum of base amount in VAT Entries must be zero.');
+ Assert.AreEqual(0, VATEntry.Amount, 'The sum of VAT amount in VAT Entries must be zero.');
+ end;
+
+ local procedure CreateSalesAdvLetter(var SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ"; var SalesAdvLetterLineCZZ: Record "Sales Adv. Letter Line CZZ"; VATPostingSetup: Record "VAT Posting Setup"; VendorNo: Code[20])
+ var
+ Customer: Record Customer;
+ begin
+ if VendorNo = '' then begin
+ LibrarySalesAdvancesCZZ.CreateCustomer(Customer);
+ Customer.Validate("VAT Bus. Posting Group", VATPostingSetup."VAT Bus. Posting Group");
+ Customer.Modify(true);
+ VendorNo := Customer."No.";
+ end;
+
+ LibrarySalesAdvancesCZZ.CreateSalesAdvLetterHeader(SalesAdvLetterHeaderCZZ, AdvanceLetterTemplateCZZ.Code, VendorNo, '');
+ LibrarySalesAdvancesCZZ.CreateSalesAdvLetterLine(SalesAdvLetterLineCZZ, SalesAdvLetterHeaderCZZ, VATPostingSetup."VAT Prod. Posting Group", LibraryRandom.RandDec(1000, 2));
+ end;
+
+ local procedure CreateSalesAdvLetter(var SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ"; var SalesAdvLetterLineCZZ: Record "Sales Adv. Letter Line CZZ"; VATPostingSetup: Record "VAT Posting Setup")
+ begin
+ CreateSalesAdvLetter(SalesAdvLetterHeaderCZZ, SalesAdvLetterLineCZZ, VATPostingSetup, '');
+ end;
+
+ local procedure CreateSalesAdvLetter(var SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ"; var SalesAdvLetterLineCZZ: Record "Sales Adv. Letter Line CZZ")
+ var
+ VATPostingSetup: Record "VAT Posting Setup";
+ begin
+ LibrarySalesAdvancesCZZ.FindVATPostingSetupEU(VATPostingSetup);
+ CreateSalesAdvLetter(SalesAdvLetterHeaderCZZ, SalesAdvLetterLineCZZ, VATPostingSetup, '');
+ end;
+
+ local procedure CreateAndPostPaymentSalesAdvLetter(var SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ"; Amount: Decimal; ExchangeRate: Decimal; PostingDate: Date)
+ var
+ GenJournalLine: Record "Gen. Journal Line";
+ begin
+ LibrarySalesAdvancesCZZ.CreateSalesAdvancePayment(
+ GenJournalLine, SalesAdvLetterHeaderCZZ."Bill-to Customer No.", Amount, SalesAdvLetterHeaderCZZ."Currency Code",
+ SalesAdvLetterHeaderCZZ."No.", ExchangeRate, PostingDate);
+ LibrarySalesAdvancesCZZ.PostSalesAdvancePayment(GenJournalLine);
+ end;
+
+ local procedure CreateAndPostPaymentSalesAdvLetter(var SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ"; Amount: Decimal)
+ begin
+ CreateAndPostPaymentSalesAdvLetter(SalesAdvLetterHeaderCZZ, Amount, 0, 0D);
+ end;
+
+ local procedure ReleaseSalesAdvLetter(var SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ")
+ begin
+ LibrarySalesAdvancesCZZ.ReleaseSalesAdvLetter(SalesAdvLetterHeaderCZZ);
+ end;
+
+ local procedure PostSalesDocument(var SalesHeader: Record "Sales Header"): Code[20]
+ begin
+ exit(LibrarySales.PostSalesDocument(SalesHeader, true, true));
+ end;
+
+ local procedure FindLastPaymentAdvanceLetterEntry(AdvanceLetterNo: Code[20]; var SalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ")
+ begin
+ SalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", AdvanceLetterNo);
+ SalesAdvLetterEntryCZZ.SetRange("Entry Type", SalesAdvLetterEntryCZZ."Entry Type"::Payment);
+ SalesAdvLetterEntryCZZ.FindLast();
+ end;
+}
diff --git a/Apps/CZ/AdvancePaymentsLocalization/test/Src/SalesAdvancePaymentsCZZ.Codeunit.al b/Apps/CZ/AdvancePaymentsLocalization/test/Src/SalesAdvancePaymentsCZZ.Codeunit.al
index 3b77a3e512..31661dd798 100644
--- a/Apps/CZ/AdvancePaymentsLocalization/test/Src/SalesAdvancePaymentsCZZ.Codeunit.al
+++ b/Apps/CZ/AdvancePaymentsLocalization/test/Src/SalesAdvancePaymentsCZZ.Codeunit.al
@@ -688,6 +688,9 @@ codeunit 148109 "Sales Advance Payments CZZ"
// [SCENARIO] Link sales advance letter with reverse charge to invoice
Initialize();
+ // [GIVEN] Posting of VAT documents for reverse charge has been enabled
+ SetPostVATDocForReverseCharge(true);
+
// [GIVEN] Sales advance letter has been created
// [GIVEN] Sales advance letter line with reverse charge has been created
CreateSalesAdvLetterWithReverseCharge(SalesAdvLetterHeaderCZZ, SalesAdvLetterLineCZZ);
@@ -734,6 +737,8 @@ codeunit 148109 "Sales Advance Payments CZZ"
// [THEN] Sales advance letter will be closed
SalesAdvLetterHeaderCZZ.Get(SalesAdvLetterHeaderCZZ."No.");
SalesAdvLetterHeaderCZZ.TestField(Status, SalesAdvLetterHeaderCZZ.Status::Closed);
+
+ SetPostVATDocForReverseCharge(false);
end;
[Test]
@@ -2215,6 +2220,9 @@ codeunit 148109 "Sales Advance Payments CZZ"
// with line which is the same as first line in advance letter and one VAT rate
Initialize();
+ // [GIVEN] Posting of VAT documents for reverse charge has been enabled
+ SetPostVATDocForReverseCharge(true);
+
// [GIVEN] Sales advance letter has been created
// [GIVEN] Sales advance letter line with normal VAT has been created
CreateSalesAdvLetter(SalesAdvLetterHeaderCZZ, SalesAdvLetterLineCZZ1);
@@ -2271,6 +2279,8 @@ codeunit 148109 "Sales Advance Payments CZZ"
VATEntry.SetRange("VAT Bus. Posting Group", VATEntry."VAT Bus. Posting Group");
VATEntry.SetRange("VAT Prod. Posting Group", VATEntry."VAT Prod. Posting Group");
Assert.RecordCount(VATEntry, VATEntryCount);
+
+ SetPostVATDocForReverseCharge(false);
end;
[Test]
@@ -2289,6 +2299,9 @@ codeunit 148109 "Sales Advance Payments CZZ"
// [SCENARIO] Create Sales advance letter with two lines with different VAT rates and link to invoice with line which is the same as second line in advance letter and one VAT rate
Initialize();
+ // [GIVEN] Posting of VAT documents for reverse charge has been enabled
+ SetPostVATDocForReverseCharge(true);
+
// [GIVEN] Sales advance letter has been created
// [GIVEN] Sales advance letter line with normal VAT has been created
CreateSalesAdvLetter(SalesAdvLetterHeaderCZZ, SalesAdvLetterLineCZZ1);
@@ -2345,6 +2358,8 @@ codeunit 148109 "Sales Advance Payments CZZ"
VATEntry.SetRange("VAT Bus. Posting Group", VATEntry."VAT Bus. Posting Group");
VATEntry.SetRange("VAT Prod. Posting Group", VATEntry."VAT Prod. Posting Group");
Assert.RecordCount(VATEntry, VATEntryCount);
+
+ SetPostVATDocForReverseCharge(false);
end;
[Test]
@@ -2362,6 +2377,9 @@ codeunit 148109 "Sales Advance Payments CZZ"
// [SCENARIO] Create Sales advance letter with two lines with different VAT rates and link to invoice with line which has the higher amount as first line in advance letter and one VAT rate
Initialize();
+ // [GIVEN] Posting of VAT documents for reverse charge has been enabled
+ SetPostVATDocForReverseCharge(true);
+
// [GIVEN] Sales advance letter has been created
// [GIVEN] Sales advance letter line with normal VAT has been created
CreateSalesAdvLetter(SalesAdvLetterHeaderCZZ, SalesAdvLetterLineCZZ1);
@@ -2413,6 +2431,8 @@ codeunit 148109 "Sales Advance Payments CZZ"
SalesAdvLetterEntryCZZ2.SetRange("VAT Prod. Posting Group", SalesAdvLetterLineCZZ2."VAT Prod. Posting Group");
SalesAdvLetterEntryCZZ2.SetRange("Entry Type", SalesAdvLetterEntryCZZ2."Entry Type"::"VAT Usage");
Assert.RecordIsNotEmpty(SalesAdvLetterEntryCZZ2);
+
+ SetPostVATDocForReverseCharge(false);
end;
[Test]
@@ -2430,6 +2450,9 @@ codeunit 148109 "Sales Advance Payments CZZ"
// [SCENARIO] Create Sales advance letter with two lines with different VAT rates and link to invoice with line which has the higher amount as second line in advance letter and one VAT rate
Initialize();
+ // [GIVEN] Posting of VAT documents for reverse charge has been enabled
+ SetPostVATDocForReverseCharge(true);
+
// [GIVEN] Sales advance letter has been created
// [GIVEN] Sales advance letter line with normal VAT has been created
CreateSalesAdvLetter(SalesAdvLetterHeaderCZZ, SalesAdvLetterLineCZZ1);
@@ -2481,6 +2504,8 @@ codeunit 148109 "Sales Advance Payments CZZ"
SalesAdvLetterEntryCZZ2.SetRange("VAT Prod. Posting Group", SalesAdvLetterLineCZZ1."VAT Prod. Posting Group");
SalesAdvLetterEntryCZZ2.SetRange("Entry Type", SalesAdvLetterEntryCZZ2."Entry Type"::"VAT Usage");
Assert.RecordIsNotEmpty(SalesAdvLetterEntryCZZ2);
+
+ SetPostVATDocForReverseCharge(false);
end;
[Test]
@@ -2500,6 +2525,9 @@ codeunit 148109 "Sales Advance Payments CZZ"
// [SCENARIO] Create Sales advance letter with two lines with different VAT rates and link to invoice with two lines which have the lower amounts as lines in advance letter
Initialize();
+ // [GIVEN] Posting of VAT documents for reverse charge has been enabled
+ SetPostVATDocForReverseCharge(true);
+
// [GIVEN] Sales advance letter has been created
// [GIVEN] Sales advance letter line with normal VAT has been created
CreateSalesAdvLetter(SalesAdvLetterHeaderCZZ, SalesAdvLetterLineCZZ1);
@@ -2570,6 +2598,8 @@ codeunit 148109 "Sales Advance Payments CZZ"
VATEntry.CalcSums(Base, Amount);
Assert.AreEqual(0, VATEntry.Base, 'The sum of base amount in VAT Entries must be zero.');
Assert.AreEqual(0, VATEntry.Amount, 'The sum of VAT amount in VAT Entries must be zero.');
+
+ SetPostVATDocForReverseCharge(false);
end;
local procedure CreateSalesAdvLetterBase(var SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ"; var SalesAdvLetterLineCZZ: Record "Sales Adv. Letter Line CZZ"; CustomerNo: Code[20]; CurrencyCode: Code[10]; VATPostingSetup: Record "VAT Posting Setup")
@@ -2693,6 +2723,12 @@ codeunit 148109 "Sales Advance Payments CZZ"
exit(LibrarySales.PostSalesDocument(SalesHeader, true, true));
end;
+ local procedure SetPostVATDocForReverseCharge(Value: Boolean)
+ begin
+ AdvanceLetterTemplateCZZ."Post VAT Doc. for Rev. Charge" := Value;
+ AdvanceLetterTemplateCZZ.Modify();
+ end;
+
local procedure FindLastPaymentAdvanceLetterEntry(AdvanceLetterNo: Code[20]; var SalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ")
begin
SalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", AdvanceLetterNo);
diff --git a/Apps/CZ/CashDeskLocalization/app/Src/Codeunits/CashDeskManagementCZP.Codeunit.al b/Apps/CZ/CashDeskLocalization/app/Src/Codeunits/CashDeskManagementCZP.Codeunit.al
index 7ee41a931e..f81cc00862 100644
--- a/Apps/CZ/CashDeskLocalization/app/Src/Codeunits/CashDeskManagementCZP.Codeunit.al
+++ b/Apps/CZ/CashDeskLocalization/app/Src/Codeunits/CashDeskManagementCZP.Codeunit.al
@@ -74,7 +74,6 @@ codeunit 11724 "Cash Desk Management CZP"
procedure CashDocumentSelection(var CashDocumentHeaderCZP: Record "Cash Document Header CZP"; var CashDeskSelected: Boolean)
var
CashDeskCZP: Record "Cash Desk CZP";
- CashDeskFilter: Text;
IsHandled: Boolean;
begin
IsHandled := false;
@@ -85,13 +84,8 @@ codeunit 11724 "Cash Desk Management CZP"
CashDeskSelected := true;
CheckCashDesks();
- CashDeskFilter := GetCashDesksFilter();
+ SetCashDeskFilter(CashDeskCZP);
- if CashDeskFilter <> '' then begin
- CashDeskCZP.FilterGroup(2);
- CashDeskCZP.SetFilter("No.", CashDeskFilter);
- CashDeskCZP.FilterGroup(0);
- end;
case CashDeskCZP.Count() of
0:
Error(CashDeskNotExistErr);
@@ -586,7 +580,7 @@ codeunit 11724 "Cash Desk Management CZP"
if User.IsEmpty() then
exit;
- UserCode := CopyStr(UserId(), 1, 50);
+ UserCode := GetUserCode();
GetCashDesksForCashDeskUser(UserCode, TempCashDeskCZP);
if CashDeskNo <> '' then
@@ -607,11 +601,62 @@ codeunit 11724 "Cash Desk Management CZP"
end;
end;
+ procedure SetCashDeskFilter(var CashDeskCZP: Record "Cash Desk CZP")
+ var
+ CashDeskFilter: Text;
+ begin
+ if IsCashDeskUserEmpty() then
+ exit;
+
+ CashDeskFilter := GetCashDesksFilter();
+ CashDeskCZP.FilterGroup(2);
+ if CashDeskFilter <> '' then
+ CashDeskCZP.SetFilter("No.", CashDeskFilter)
+ else
+ CashDeskCZP.SetRange("No.", '');
+ CashDeskCZP.FilterGroup(0);
+ end;
+
+ procedure SetCashDeskFilter(var CashDeskCueCZP: Record "Cash Desk Cue CZP")
+ var
+ CashDeskCZP: Record "Cash Desk CZP";
+ begin
+ SetCashDeskFilter(CashDeskCZP);
+ CashDeskCZP.FilterGroup(2);
+ CashDeskCZP.CopyFilter("No.", CashDeskCueCZP."Cash Desk Filter");
+ end;
+
+ procedure SetCashDeskFilter(var CashDocumentHeaderCZP: Record "Cash Document Header CZP")
+ var
+ CashDeskCZP: Record "Cash Desk CZP";
+ begin
+ SetCashDeskFilter(CashDeskCZP);
+ CashDeskCZP.FilterGroup(2);
+ CashDeskCZP.CopyFilter("No.", CashDocumentHeaderCZP."Cash Desk No.");
+ end;
+
+ procedure SetCashDeskFilter(var PostedCashDocumentHdrCZP: Record "Posted Cash Document Hdr. CZP")
+ var
+ CashDeskCZP: Record "Cash Desk CZP";
+ begin
+ SetCashDeskFilter(CashDeskCZP);
+ CashDeskCZP.FilterGroup(2);
+ CashDeskCZP.CopyFilter("No.", PostedCashDocumentHdrCZP."Cash Desk No.");
+ end;
+
+ local procedure IsCashDeskUserEmpty(): Boolean
+ var
+ CashDeskUserCZP: Record "Cash Desk User CZP";
+ begin
+ CashDeskUserCZP.Reset();
+ exit(CashDeskUserCZP.IsEmpty());
+ end;
+
procedure GetCashDesksFilter(): Text
var
TempCashDeskCZP: Record "Cash Desk CZP" temporary;
begin
- GetCashDesks(CopyStr(UserId(), 1, 50), TempCashDeskCZP);
+ GetCashDesks(GetUserCode(), TempCashDeskCZP);
exit(GetCashDesksFilterFromBuffer(TempCashDeskCZP));
end;
@@ -630,16 +675,12 @@ codeunit 11724 "Cash Desk Management CZP"
CompanyInformation: Record "Company Information";
UserSetup: Record "User Setup";
CashUserRespCenter: Code[10];
- HasGotCashUserSetup: Boolean;
- begin
- if not HasGotCashUserSetup then begin
- CompanyInformation.Get();
- CashUserRespCenter := CompanyInformation."Responsibility Center";
- if UserSetup.Get(UserCode) and (UserCode <> '') then
- if UserSetup."Cash Resp. Ctr. Filter CZP" <> '' then
- CashUserRespCenter := UserSetup."Cash Resp. Ctr. Filter CZP";
- HasGotCashUserSetup := true;
- end;
+ begin
+ CompanyInformation.Get();
+ CashUserRespCenter := CompanyInformation."Responsibility Center";
+ if UserSetup.Get(UserCode) and (UserCode <> '') then
+ if UserSetup."Cash Resp. Ctr. Filter CZP" <> '' then
+ CashUserRespCenter := UserSetup."Cash Resp. Ctr. Filter CZP";
exit(CashUserRespCenter);
end;
@@ -726,6 +767,35 @@ codeunit 11724 "Cash Desk Management CZP"
PreviewMode := NewPreviewMode;
end;
+ internal procedure CheckResponsibilityCenter(RespCenter: Code[10]): Boolean
+ begin
+ exit(CheckResponsibilityCenter(RespCenter, GetUserCode()));
+ end;
+
+ internal procedure CheckResponsibilityCenter(RespCenter: Code[10]; UserCode: Code[50]): Boolean
+ var
+ UserRespCenter: Code[10];
+ IsHandled: Boolean;
+ Result: Boolean;
+ begin
+ OnBeforeCheckResponsibilityCenter(RespCenter, UserCode, IsHandled, Result);
+ if IsHandled then
+ exit(Result);
+
+ UserRespCenter := GetUserCashResponsibilityFilter(UserCode);
+ if (UserRespCenter <> '') and
+ (RespCenter <> UserRespCenter)
+ then
+ exit(false);
+
+ exit(true);
+ end;
+
+ local procedure GetUserCode(): Code[50]
+ begin
+ exit(CopyStr(UserId(), 1, 50));
+ end;
+
[IntegrationEvent(false, false)]
local procedure OnBeforeCheckUserRights(CashDeskNo: Code[20]; ActionType: Enum "Cash Document Action CZP"; var IsHandled: Boolean)
begin
@@ -745,4 +815,9 @@ codeunit 11724 "Cash Desk Management CZP"
local procedure OnBeforeGetCashDesksForCashDeskUser(UserCode: Code[50]; var TempCashDeskCZP: Record "Cash Desk CZP" temporary; var IsHandled: Boolean)
begin
end;
+
+ [IntegrationEvent(false, false)]
+ local procedure OnBeforeCheckResponsibilityCenter(RespCenter: Code[10]; UserCode: Code[50]; var IsHandled: Boolean; var Result: Boolean)
+ begin
+ end;
}
diff --git a/Apps/CZ/CashDeskLocalization/app/Src/Pages/CashDeskActivitiesCZP.Page.al b/Apps/CZ/CashDeskLocalization/app/Src/Pages/CashDeskActivitiesCZP.Page.al
index 118cdda245..747a1abb73 100644
--- a/Apps/CZ/CashDeskLocalization/app/Src/Pages/CashDeskActivitiesCZP.Page.al
+++ b/Apps/CZ/CashDeskLocalization/app/Src/Pages/CashDeskActivitiesCZP.Page.al
@@ -44,7 +44,6 @@ page 31154 "Cash Desk Activities CZP"
trigger OnOpenPage()
var
CashDeskManagementCZP: Codeunit "Cash Desk Management CZP";
- CashDeskFilter: Text;
begin
Rec.Reset();
if not Rec.Get() then begin
@@ -52,12 +51,9 @@ page 31154 "Cash Desk Activities CZP"
Rec.Insert();
end;
+ CashDeskManagementCZP.SetCashDeskFilter(Rec);
+
Rec.FilterGroup(2);
- CashDeskFilter := CashDeskManagementCZP.GetCashDesksFilter();
- if CashDeskFilter <> '' then
- Rec.SetFilter("Cash Desk Filter", CashDeskFilter)
- else
- Rec.SetRange("Cash Desk Filter", '');
Rec.SetRange("Date Filter", CalcDate('<-30D>', WorkDate()), WorkDate());
Rec.FilterGroup(0);
end;
diff --git a/Apps/CZ/CashDeskLocalization/app/Src/Pages/CashDeskListCZP.Page.al b/Apps/CZ/CashDeskLocalization/app/Src/Pages/CashDeskListCZP.Page.al
index d49753787e..cd357f84d5 100644
--- a/Apps/CZ/CashDeskLocalization/app/Src/Pages/CashDeskListCZP.Page.al
+++ b/Apps/CZ/CashDeskLocalization/app/Src/Pages/CashDeskListCZP.Page.al
@@ -376,15 +376,8 @@ page 31150 "Cash Desk List CZP"
}
trigger OnOpenPage()
- var
- CashDesksFilter: Text;
begin
- CashDesksFilter := CashDeskManagementCZP.GetCashDesksFilter();
-
- Rec.FilterGroup(2);
- if CashDesksFilter <> '' then
- Rec.SetFilter("No.", CashDesksFilter);
- Rec.FilterGroup(0);
+ CashDeskManagementCZP.SetCashDeskFilter(Rec);
end;
var
diff --git a/Apps/CZ/CashDeskLocalization/app/Src/Pages/CashDocumentListCZP.Page.al b/Apps/CZ/CashDeskLocalization/app/Src/Pages/CashDocumentListCZP.Page.al
index c7288f7d03..862876cbcf 100644
--- a/Apps/CZ/CashDeskLocalization/app/Src/Pages/CashDocumentListCZP.Page.al
+++ b/Apps/CZ/CashDeskLocalization/app/Src/Pages/CashDocumentListCZP.Page.al
@@ -429,16 +429,9 @@ page 31162 "Cash Document List CZP"
end;
trigger OnOpenPage()
- var
- CashDeskFilter: Text;
begin
CashDeskManagementCZP.CheckCashDesks();
- CashDeskFilter := CashDeskManagementCZP.GetCashDesksFilter();
-
- Rec.FilterGroup(2);
- if CashDeskFilter <> '' then
- Rec.SetFilter("Cash Desk No.", CashDeskFilter);
- Rec.FilterGroup(0);
+ CashDeskManagementCZP.SetCashDeskFilter(Rec);
end;
var
diff --git a/Apps/CZ/CashDeskLocalization/app/Src/Pages/PostedCashDocumentListCZP.Page.al b/Apps/CZ/CashDeskLocalization/app/Src/Pages/PostedCashDocumentListCZP.Page.al
index 33db82bf1b..0da8a943a7 100644
--- a/Apps/CZ/CashDeskLocalization/app/Src/Pages/PostedCashDocumentListCZP.Page.al
+++ b/Apps/CZ/CashDeskLocalization/app/Src/Pages/PostedCashDocumentListCZP.Page.al
@@ -245,16 +245,9 @@ page 31167 "Posted Cash Document List CZP"
}
trigger OnOpenPage()
- var
- CashDeskFilter: Text;
begin
CashDeskManagementCZP.CheckCashDesks();
- CashDeskFilter := CashDeskManagementCZP.GetCashDesksFilter();
-
- Rec.FilterGroup(2);
- if CashDeskFilter <> '' then
- Rec.SetFilter("Cash Desk No.", CashDeskFilter);
- Rec.FilterGroup(0);
+ CashDeskManagementCZP.SetCashDeskFilter(Rec);
end;
var
diff --git a/Apps/CZ/CashDeskLocalization/app/Src/Tables/CashDocumentHeaderCZP.Table.al b/Apps/CZ/CashDeskLocalization/app/Src/Tables/CashDocumentHeaderCZP.Table.al
index 4c483c3502..0836175e6f 100644
--- a/Apps/CZ/CashDeskLocalization/app/Src/Tables/CashDocumentHeaderCZP.Table.al
+++ b/Apps/CZ/CashDeskLocalization/app/Src/Tables/CashDocumentHeaderCZP.Table.al
@@ -24,7 +24,6 @@ using Microsoft.Utilities;
using System.Automation;
using System.Reflection;
using System.Security.AccessControl;
-using System.Security.User;
using System.Utilities;
#pragma warning disable AA0232
@@ -323,7 +322,7 @@ table 11732 "Cash Document Header CZP"
trigger OnValidate()
begin
- if not UserSetupManagement.CheckRespCenter(3, "Responsibility Center") then
+ if not CashDeskManagementCZP.CheckResponsibilityCenter("Responsibility Center") then
Error(RespCenterErr, FieldCaption("Responsibility Center"), CashDeskManagementCZP.GetUserCashResponsibilityFilter(CopyStr(UserId(), 1, 50)));
CreateDimFromDefaultDim(Rec.FieldNo("Responsibility Center"));
@@ -618,7 +617,7 @@ table 11732 "Cash Document Header CZP"
DeleteRecordInApprovalRequest();
CashDeskManagementCZP.CheckCashDesks();
- if not UserSetupManagement.CheckRespCenter(3, "Responsibility Center") then
+ if not CashDeskManagementCZP.CheckResponsibilityCenter("Responsibility Center") then
Error(RespCenterDeleteErr, FieldCaption("Responsibility Center"), CashDeskManagementCZP.GetUserCashResponsibilityFilter(CopyStr(UserId(), 1, 50)));
CashDocumentPostCZP.DeleteCashDocumentHeader(Rec);
@@ -710,7 +709,7 @@ table 11732 "Cash Document Header CZP"
trigger OnModify()
begin
- if not UserSetupManagement.CheckRespCenter(3, "Responsibility Center") then
+ if not CashDeskManagementCZP.CheckResponsibilityCenter("Responsibility Center") then
Error(RespCenterModifyErr, FieldCaption("Responsibility Center"), CashDeskManagementCZP.GetUserCashResponsibilityFilter(CopyStr(UserId(), 1, 50)));
end;
@@ -731,7 +730,6 @@ table 11732 "Cash Document Header CZP"
NoSeriesManagement: Codeunit NoSeriesManagement;
#endif
DimensionManagement: Codeunit DimensionManagement;
- UserSetupManagement: Codeunit "User Setup Management";
ConfirmManagement: Codeunit "Confirm Management";
CashDeskManagementCZP: Codeunit "Cash Desk Management CZP";
RenameErr: Label 'You cannot rename a %1.', Comment = '%1 = TableCaption';
diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/AccSchedExtensionMgtCZL.Codeunit.al b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/AccSchedExtensionMgtCZL.Codeunit.al
index e774e8ec06..b39f5bca54 100644
--- a/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/AccSchedExtensionMgtCZL.Codeunit.al
+++ b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/AccSchedExtensionMgtCZL.Codeunit.al
@@ -4,8 +4,10 @@
// ------------------------------------------------------------------------------------------------
namespace Microsoft.Finance.FinancialReports;
+using Microsoft.Finance.Analysis;
using Microsoft.Finance.GeneralLedger.Setup;
using Microsoft.Finance.VAT.Ledger;
+using Microsoft.Foundation.Enums;
using Microsoft.Foundation.NoSeries;
using Microsoft.Foundation.Period;
using Microsoft.Inventory.Ledger;
@@ -421,6 +423,7 @@ codeunit 31326 "Acc. Sched. Extension Mgt. CZL"
var
ColumnLayoutCreate: Record "Column Layout";
AccScheduleResultValueCZL: Record "Acc. Schedule Result Value CZL";
+ MatrixManagement: Codeunit "Matrix Management";
SaveAccScheduleResultCZL: Page "Save Acc. Schedule Result CZL";
AccSchedName: Code[10];
DimFilter: array[4] of Text[250];
@@ -460,7 +463,11 @@ codeunit 31326 "Acc. Sched. Extension Mgt. CZL"
repeat
if ColumnLayoutCreate.FindSet() then
repeat
- Result := AccSchedManagement.CalcCell(AccScheduleLine, ColumnLayoutCreate, UseAmtsInAddCurr);
+ Result := RoundIfNotNone(
+ MatrixManagement.RoundAmount(
+ AccSchedManagement.CalcCell(AccScheduleLine, ColumnLayoutCreate, UseAmtsInAddCurr),
+ ColumnLayoutCreate."Rounding Factor"),
+ ColumnLayoutCreate."Rounding Factor");
AccScheduleResultValueCZL."Result Code" := AccScheduleResultHdrCZL."Result Code";
AccScheduleResultValueCZL."Row No." := AccScheduleLine."Line No.";
AccScheduleResultValueCZL."Column No." := ColumnLayoutCreate."Line No.";
@@ -522,6 +529,14 @@ codeunit 31326 "Acc. Sched. Extension Mgt. CZL"
GLSetupRead := true;
end;
+ local procedure RoundIfNotNone(Value: Decimal; RoundingFactor: Enum "Analysis Rounding Factor"): Decimal
+ begin
+ if RoundingFactor <> RoundingFactor::None then
+ exit(Value);
+
+ exit(Round(Value));
+ end;
+
[IntegrationEvent(false, false)]
local procedure OnFindSharedAccountScheduleOnBeforeCalcAccSchedLineCellValue(SourceAccScheduleLine: Record "Acc. Schedule Line"; var "; var AccScheduleLine: Record ": Record "Acc. Schedule Line"; var ColumnLayout: Record "Column Layout"; CalcAddCurr: Boolean; var CellValue: Decimal; var IsHandled: Boolean)
begin
diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/GenJnlPostLineHandlerCZL.Codeunit.al b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/GenJnlPostLineHandlerCZL.Codeunit.al
index 74e4e35ee5..0e7156404e 100644
--- a/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/GenJnlPostLineHandlerCZL.Codeunit.al
+++ b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/GenJnlPostLineHandlerCZL.Codeunit.al
@@ -4,14 +4,17 @@
// ------------------------------------------------------------------------------------------------
namespace Microsoft.Finance.GeneralLedger.Posting;
-using Microsoft.Sales.Customer;
+using Microsoft.Finance.Deferral;
using Microsoft.Finance.GeneralLedger.Journal;
using Microsoft.Finance.GeneralLedger.Ledger;
using Microsoft.Finance.GeneralLedger.Setup;
using Microsoft.Finance.ReceivablesPayables;
+using Microsoft.Finance.VAT.Calculation;
using Microsoft.Finance.VAT.Ledger;
using Microsoft.Finance.VAT.Setup;
using Microsoft.Foundation.AuditCodes;
+using Microsoft.Purchases.Vendor;
+using Microsoft.Sales.Customer;
using System.Utilities;
using System.Security.User;
@@ -380,6 +383,8 @@ codeunit 31315 "Gen.Jnl. Post Line Handler CZL"
local procedure OnBeforePostDtldCVLedgEntry(sender: Codeunit "Gen. Jnl.-Post Line"; var GenJournalLine: Record "Gen. Journal Line"; var DetailedCVLedgEntryBuffer: Record "Detailed CV Ledg. Entry Buffer"; var AccNo: Code[20]; var IsHandled: Boolean; AddCurrencyCode: Code[10]; MultiplePostingGroups: Boolean)
var
CustomerPostingGroup: Record "Customer Posting Group";
+ VendorPostingGroup: Record "Vendor Posting Group";
+ PostingGroupAccountNo: Code[20];
OldCorrection: Boolean;
begin
if IsHandled then
@@ -388,8 +393,22 @@ codeunit 31315 "Gen.Jnl. Post Line Handler CZL"
if MultiplePostingGroups and
(DetailedCVLedgEntryBuffer."Entry Type" = DetailedCVLedgEntryBuffer."Entry Type"::Application)
then begin
- CustomerPostingGroup.Get(GenJournalLine."Posting Group");
- if AccNo = CustomerPostingGroup.GetReceivablesAccount() then begin
+ case GenJournalLine."Account Type" of
+ GenJournalLine."Account Type"::Customer:
+ begin
+ CustomerPostingGroup.Get(GenJournalLine."Posting Group");
+ PostingGroupAccountNo := CustomerPostingGroup.GetReceivablesAccount();
+ end;
+ GenJournalLine."Account Type"::Vendor:
+ begin
+ VendorPostingGroup.Get(GenJournalLine."Posting Group");
+ PostingGroupAccountNo := VendorPostingGroup.GetPayablesAccount();
+ end;
+ else
+ exit;
+ end;
+
+ if AccNo = PostingGroupAccountNo then begin
OldCorrection := GenJournalLine.Correction;
GenJournalLine.Correction := true;
sender.CreateGLEntry(GenJournalLine, AccNo, DetailedCVLedgEntryBuffer."Amount (LCY)", 0, DetailedCVLedgEntryBuffer."Currency Code" = AddCurrencyCode);
@@ -399,6 +418,18 @@ codeunit 31315 "Gen.Jnl. Post Line Handler CZL"
end;
end;
+ [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnPostDeferralPostBufferOnAfterFindDeferalPostingBuffer', '', false, false)]
+ local procedure GetNonDeductibleVATPctOnPostDeferralPostBufferOnAfterFindDeferalPostingBuffer(GenJournalLine: Record "Gen. Journal Line"; var DeferralPostingBuffer: Record "Deferral Posting Buffer"; var NonDeductibleVATPct: Decimal)
+ var
+ NonDeductibleVATCZL: Codeunit "Non-Deductible VAT CZL";
+ begin
+ NonDeductibleVATPct :=
+ NonDeductibleVATCZL.GetNonDeductibleVATPct(
+ GenJournalLine."VAT Bus. Posting Group", GenJournalLine."VAT Prod. Posting Group",
+ NonDeductibleVATCZL.GetGeneralPostingTypeFromDeferralDocType(DeferralPostingBuffer."Deferral Doc. Type"),
+ GenJournalLine."VAT Reporting Date");
+ end;
+
[IntegrationEvent(false, false)]
local procedure OnBeforeUpdateVATAmountOnAfterInitVAT(var GenJournalLine: Record "Gen. Journal Line"; var GLEntry: Record "G/L Entry"; var IsHandled: Boolean)
begin
diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/NonDeductibleVATCZL.Codeunit.al b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/NonDeductibleVATCZL.Codeunit.al
index 6166178a9c..52b7cd76d8 100644
--- a/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/NonDeductibleVATCZL.Codeunit.al
+++ b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/NonDeductibleVATCZL.Codeunit.al
@@ -4,6 +4,7 @@
// ------------------------------------------------------------------------------------------------
namespace Microsoft.Finance.VAT.Calculation;
+using Microsoft.Finance.Deferral;
using Microsoft.Finance.GeneralLedger.Journal;
using Microsoft.Finance.VAT.Setup;
using Microsoft.Foundation.Enums;
@@ -107,6 +108,18 @@ codeunit 31147 "Non-Deductible VAT CZL"
Error(PurchaseSettlementOnlyErr);
end;
+ internal procedure GetGeneralPostingTypeFromDeferralDocType(DeferralDocType: Enum "Deferral Document Type") GeneralPostingType: Enum "General Posting Type"
+ begin
+ case DeferralDocType of
+ DeferralDocType::"G/L":
+ exit(GeneralPostingType::" ");
+ DeferralDocType::Purchase:
+ exit(GeneralPostingType::Purchase);
+ DeferralDocType::Sales:
+ exit(GeneralPostingType::Sale);
+ end;
+ end;
+
[IntegrationEvent(false, false)]
local procedure OnBeforeGetNonDeductibleVATPct(VATPostingSetup: Record "VAT Posting Setup"; GeneralPostingType: Enum "General Posting Type"; ToDate: Date; var NonDeductibleVATPct: Decimal; var IsHandled: Boolean)
begin
diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/PstdGenJnlLineHandlerCZL.Codeunit.al b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/PstdGenJnlLineHandlerCZL.Codeunit.al
new file mode 100644
index 0000000000..d1f2b90729
--- /dev/null
+++ b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/PstdGenJnlLineHandlerCZL.Codeunit.al
@@ -0,0 +1,18 @@
+// ------------------------------------------------------------------------------------------------
+// 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.GeneralLedger.Journal;
+
+codeunit 31156 "Pstd.Gen.Jnl.Line Handler CZL"
+{
+ Access = Internal;
+ SingleInstance = true;
+
+ [EventSubscriber(ObjectType::Table, Database::"Posted Gen. Journal Line", 'OnAfterInsertFromGenJournalLine', '', false, false)]
+ local procedure UpdateVATDateOnAfterInsertFromGenJournalLine(GenJournalLine: Record "Gen. Journal Line"; sender: Record "Posted Gen. Journal Line")
+ begin
+ sender."VAT Date CZL" := GenJournalLine."VAT Reporting Date";
+ sender.Modify();
+ end;
+}
\ No newline at end of file
diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/VATDateHandlerCZL.Codeunit.al b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/VATDateHandlerCZL.Codeunit.al
index d179b1623a..bdcc13ce84 100644
--- a/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/VATDateHandlerCZL.Codeunit.al
+++ b/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/VATDateHandlerCZL.Codeunit.al
@@ -218,14 +218,8 @@ codeunit 11742 "VAT Date Handler CZL"
else begin
PurchaseHeader.TestField("VAT Reporting Date");
VATPeriodCZLCheck(PurchaseHeader."VAT Reporting Date");
- if PurchaseHeader.Invoice then begin
- // FIX
- if PurchaseHeader."Original Doc. VAT Date CZL" = 0D then begin
- PurchaseHeader."Original Doc. VAT Date CZL" := PurchaseHeader."VAT Reporting Date";
- PurchaseHeader.Modify();
- end;
+ if PurchaseHeader.Invoice then
PurchaseHeader.TestField("Original Doc. VAT Date CZL");
- end;
if PurchaseHeader."Original Doc. VAT Date CZL" > PurchaseHeader."VAT Reporting Date" then
PurchaseHeader.FieldError("Original Doc. VAT Date CZL", StrSubstNo(MustBeLessOrEqualErr, PurchaseHeader.FieldCaption("VAT Reporting Date")));
end;
diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/AccScheduleOverviewCZL.PageExt.al b/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/AccScheduleOverviewCZL.PageExt.al
index 0aa10f09ca..2c309046f7 100644
--- a/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/AccScheduleOverviewCZL.PageExt.al
+++ b/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/AccScheduleOverviewCZL.PageExt.al
@@ -25,7 +25,7 @@ pageextension 11798 "Acc. Schedule Overview CZL" extends "Acc. Schedule Overview
var
AccSchedExtensionMgtCZL: Codeunit "Acc. Sched. Extension Mgt. CZL";
begin
- AccSchedExtensionMgtCZL.CreateResults(Rec, CurrentColumnName, false);
+ AccSchedExtensionMgtCZL.CreateResults(Rec, TempFinancialReport."Financial Report Column Group", false);
end;
}
action("Results CZL")
diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/SalesOrderSubformCZL.PageExt.al b/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/SalesOrderSubformCZL.PageExt.al
index 16381551f4..2f6ed16290 100644
--- a/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/SalesOrderSubformCZL.PageExt.al
+++ b/Apps/CZ/CoreLocalizationPack/app/Src/PageExtensions/SalesOrderSubformCZL.PageExt.al
@@ -8,7 +8,7 @@ pageextension 11790 "Sales Order Subform CZL" extends "Sales Order Subform"
{
layout
{
- addafter("Invoice Discount Amount")
+ addafter("Inv. Discount Amount")
{
field("Tariff No. CZL"; Rec."Tariff No. CZL")
{
diff --git a/Apps/CZ/CoreLocalizationPack/app/Src/Reports/DocumentationforVATCZL.Report.al b/Apps/CZ/CoreLocalizationPack/app/Src/Reports/DocumentationforVATCZL.Report.al
index 7a90586c62..533e2b0d51 100644
--- a/Apps/CZ/CoreLocalizationPack/app/Src/Reports/DocumentationforVATCZL.Report.al
+++ b/Apps/CZ/CoreLocalizationPack/app/Src/Reports/DocumentationforVATCZL.Report.al
@@ -251,9 +251,6 @@ report 11757 "Documentation for VAT CZL"
}
trigger OnAfterGetRecord()
begin
- if "Original VAT Entry No. CZL" <> 0 then
- Base := CalcDeductibleVATBaseCZL();
-
VATEntrySubtotalAmt[1] += Base;
VATEntrySubtotalAmt[2] += Amount;
VATEntrySubtotalAmt[3] += "Original VAT Base CZL";
@@ -410,6 +407,9 @@ report 11757 "Documentation for VAT CZL"
VATEntry.Amount := VATEntry."Additional-Currency Amount";
end;
+ if VATEntry."Original VAT Entry No. CZL" <> 0 then
+ VATEntry.Base := VATEntry.CalcDeductibleVATBaseCZL();
+
if MergeByDocumentNo then begin
"VAT Entry".SetRange("VAT Reporting Date", VATEntry."VAT Reporting Date");
"VAT Entry".SetRange("VAT Bus. Posting Group", VATEntry."VAT Bus. Posting Group");
@@ -567,11 +567,11 @@ report 11757 "Documentation for VAT CZL"
begin
if "VAT Posting Setup".GetFilters() <> '' then
VATPostingSetupFilter := "VAT Posting Setup".TableCaption() + ': ' + "VAT Posting Setup".GetFilters();
- if EndDateReq = 0D then
- VATEntry.SetFilter("VAT Reporting Date", '%1..', StartDateReq)
- else
- VATEntry.SetRange("VAT Reporting Date", StartDateReq, EndDateReq);
- VATDateFilter := VATEntry.GetFilter("VAT Reporting Date");
+ if EndDateReq = 0D then
+ VATEntry.SetFilter("VAT Reporting Date", '%1..', StartDateReq)
+ else
+ VATEntry.SetRange("VAT Reporting Date", StartDateReq, EndDateReq);
+ VATDateFilter := VATEntry.GetFilter("VAT Reporting Date");
end;
var
diff --git a/Apps/CZ/CoreLocalizationPack/test/Src/PurchPostPrepmtHandlerCZL.Codeunit.al b/Apps/CZ/CoreLocalizationPack/test/Src/PurchPostPrepmtHandlerCZL.Codeunit.al
new file mode 100644
index 0000000000..ac33795f23
--- /dev/null
+++ b/Apps/CZ/CoreLocalizationPack/test/Src/PurchPostPrepmtHandlerCZL.Codeunit.al
@@ -0,0 +1,8 @@
+codeunit 148128 "Purch.Post Prepmt. Handler CZL"
+{
+ [EventSubscriber(ObjectType::Codeunit, Codeunit::"Purchase-Post Prepayments", 'OnPostVendorEntryOnAfterInitNewLine', '', false, false)]
+ local procedure MyProcedure(var GenJnlLine: Record "Gen. Journal Line"; PurchHeader: Record "Purchase Header")
+ begin
+ GenJnlLine."Original Doc. VAT Date CZL" := PurchHeader."Original Doc. VAT Date CZL";
+ end;
+}
\ No newline at end of file
diff --git a/Apps/CZ/CoreLocalizationPack/test/Src/TestInitializeHandlerCZL.Codeunit.al b/Apps/CZ/CoreLocalizationPack/test/Src/TestInitializeHandlerCZL.Codeunit.al
index ab6860f3d6..187a6f04aa 100644
--- a/Apps/CZ/CoreLocalizationPack/test/Src/TestInitializeHandlerCZL.Codeunit.al
+++ b/Apps/CZ/CoreLocalizationPack/test/Src/TestInitializeHandlerCZL.Codeunit.al
@@ -11,8 +11,6 @@ codeunit 148104 "Test Initialize Handler CZL"
case CallerCodeunitID of
137462: // "Phys. Invt. Order Subform UT":
UpdateInventorySetup();
- 135300: // "O365 Purch Item Charge Tests"
- UpdateGeneralLedgerSetup();
end;
end;
@@ -39,11 +37,13 @@ codeunit 148104 "Test Initialize Handler CZL"
134992: // ERM Financial Reports IV
begin
TryBindSuppConfVATEntUpdate();
- UpdateGeneralLedgerSetup();
UpdateUserSetup();
end;
+ 137161: // SCM Warehouse Orders
+ DisableVATDateUsage();
end;
- if not (CallerCodeunitID = 134045) then
+
+ if not (CallerCodeunitID in [134008, 134045, 134088, 134992]) then
TryUnbindSuppConfVATEntUpdate();
end;
@@ -79,15 +79,6 @@ codeunit 148104 "Test Initialize Handler CZL"
end;
end;
- local procedure UpdateGeneralLedgerSetup()
- var
- GeneralLedgerSetup: Record "General Ledger Setup";
- begin
- GeneralLedgerSetup.Get();
- GeneralLedgerSetup."Def. Orig. Doc. VAT Date CZL" := GeneralLedgerSetup."Def. Orig. Doc. VAT Date CZL"::"VAT Date";
- GeneralLedgerSetup.Modify();
- end;
-
local procedure UpdateUserSetup()
var
UserSetup: Record "User Setup";
@@ -102,6 +93,15 @@ codeunit 148104 "Test Initialize Handler CZL"
UserSetup.Modify();
end;
+ local procedure DisableVATDateUsage()
+ var
+ GeneralLedgerSetup: Record "General Ledger Setup";
+ begin
+ GeneralLedgerSetup.Get();
+ GeneralLedgerSetup."VAT Reporting Date Usage" := GeneralLedgerSetup."VAT Reporting Date Usage"::Disabled;
+ GeneralLedgerSetup.Modify();
+ end;
+
local procedure TryBindSuppConfVATEntUpdate(): Boolean
begin
exit(BindSubscription(SuppConfVATEntUpdate));
diff --git a/Apps/DK/ElectronicVATDeclarationDK/app/app.json b/Apps/DK/ElectronicVATDeclarationDK/app/app.json
index de7398de1a..de95ceb05b 100644
--- a/Apps/DK/ElectronicVATDeclarationDK/app/app.json
+++ b/Apps/DK/ElectronicVATDeclarationDK/app/app.json
@@ -30,7 +30,7 @@
},
{
"from": 13668,
- "to": 13668
+ "to": 13669
}
],
"resourceExposurePolicy": {
diff --git a/Apps/DK/ElectronicVATDeclarationDK/app/src/Engine/ElecVATDeclInstall.Codeunit.al b/Apps/DK/ElectronicVATDeclarationDK/app/src/Engine/ElecVATDeclInstall.Codeunit.al
index 3aee102e00..1d0121e392 100644
--- a/Apps/DK/ElectronicVATDeclarationDK/app/src/Engine/ElecVATDeclInstall.Codeunit.al
+++ b/Apps/DK/ElectronicVATDeclarationDK/app/src/Engine/ElecVATDeclInstall.Codeunit.al
@@ -3,6 +3,7 @@ namespace Microsoft.Finance.VAT.Reporting;
using Microsoft.Foundation.Company;
using System.Environment;
using System.Privacy;
+using System.Upgrade;
codeunit 13611 "Elec. VAT Decl. Install"
{
@@ -35,6 +36,8 @@ codeunit 13611 "Elec. VAT Decl. Install"
InsertVATReportsConfiguration();
UpdateVATReportSetup();
InsertEmptySetup();
+
+ SetAllUpgradeTags();
end;
local procedure ApplyEvaluationClassificationsForPrivacy()
@@ -91,4 +94,13 @@ codeunit 13611 "Elec. VAT Decl. Install"
ElecVATDeclSetup."Use Azure Key Vault" := true;
if ElecVATDeclSetup.Modify(true) then;
end;
+
+ local procedure SetAllUpgradeTags()
+ var
+ UpgradeTag: Codeunit "Upgrade Tag";
+ ElecVATDeclUpgrade: Codeunit "Elec. VAT Decl. Upgrade";
+ begin
+ if not UpgradeTag.HasUpgradeTag(ElecVATDeclUpgrade.GetElecVATDeclAKVSetupUpgradeTag()) then
+ UpgradeTag.SetUpgradeTag(ElecVATDeclUpgrade.GetElecVATDeclAKVSetupUpgradeTag());
+ end;
}
\ No newline at end of file
diff --git a/Apps/DK/ElectronicVATDeclarationDK/app/src/Engine/ElecVATDeclUpgrade.Codeunit.al b/Apps/DK/ElectronicVATDeclarationDK/app/src/Engine/ElecVATDeclUpgrade.Codeunit.al
new file mode 100644
index 0000000000..b91a7463ce
--- /dev/null
+++ b/Apps/DK/ElectronicVATDeclarationDK/app/src/Engine/ElecVATDeclUpgrade.Codeunit.al
@@ -0,0 +1,46 @@
+namespace Microsoft.Finance.VAT.Reporting;
+
+using System.Upgrade;
+
+codeunit 13669 "Elec. VAT Decl. Upgrade"
+{
+ Subtype = Upgrade;
+ Access = Internal;
+
+ trigger OnUpgradePerCompany()
+ begin
+ UpgradeUseAKVSetup();
+ end;
+
+ local procedure UpgradeUseAKVSetup()
+ var
+ ElecVATDeclSetup: Record "Elec. VAT Decl. Setup";
+ UpgradeTag: Codeunit "Upgrade Tag";
+ begin
+ if UpgradeTag.HasUpgradeTag(GetElecVATDeclAKVSetupUpgradeTag()) then
+ exit;
+
+ if not ElecVATDeclSetup.Get() then
+ exit;
+
+ ElecVATDeclSetup."Use Azure Key Vault" := true;
+ ElecVATDeclSetup.Modify();
+
+ UpgradeTag.SetUpgradeTag(GetElecVATDeclAKVSetupUpgradeTag());
+ end;
+
+
+ procedure GetElecVATDeclAKVSetupUpgradeTag(): Code[250];
+ begin
+ exit('MS-537717-ElecVATDeclSetupWithAKVVariableTag-20250609');
+ end;
+
+ [EventSubscriber(ObjectType::Codeunit, Codeunit::"Upgrade Tag", 'OnGetPerCompanyUpgradeTags', '', false, false)]
+ local procedure RegisterPerCompanyags(var PerCompanyUpgradeTags: List of [Code[250]])
+ var
+ UpgradeTag: Codeunit "Upgrade Tag";
+ begin
+ if not UpgradeTag.HasUpgradeTag(GetElecVATDeclAKVSetupUpgradeTag()) then
+ PerCompanyUpgradeTags.Add(GetElecVATDeclAKVSetupUpgradeTag());
+ end;
+}
\ No newline at end of file
diff --git a/Apps/DK/OIOUBL/app/src/SalesCreditMemo/OIOUBLExportSalesCrMemo.Codeunit.al b/Apps/DK/OIOUBL/app/src/SalesCreditMemo/OIOUBLExportSalesCrMemo.Codeunit.al
index 42dc23f357..fd011d5572 100644
--- a/Apps/DK/OIOUBL/app/src/SalesCreditMemo/OIOUBLExportSalesCrMemo.Codeunit.al
+++ b/Apps/DK/OIOUBL/app/src/SalesCreditMemo/OIOUBLExportSalesCrMemo.Codeunit.al
@@ -58,7 +58,7 @@ codeunit 13637 "OIOUBL-Export Sales Cr. Memo"
OIOUBLManagement: Codeunit "OIOUBL-Management";
TempBlob: Codeunit "Temp Blob";
FileOutStream: OutStream;
- FileName: Text[250];
+ FileName: Text;
begin
TempBlob.CreateOutStream(FileOutStream);
CreateXML(SalesCrMemoHeader, FileOutStream);
@@ -69,6 +69,7 @@ codeunit 13637 "OIOUBL-Export Sales Cr. Memo"
OIOUBLManagement.UpdateRecordExportBuffer(SalesCrMemoHeader.RecordId(), TempBlob, FileName);
OIOUBLManagement.ExportXMLFile(SalesCrMemoHeader."No.", TempBlob, SalesSetup."OIOUBL-Cr. Memo Path", FileName);
+ OnExportXMLOnAfterExportXMLFile(SalesCrMemoHeader, TempBlob, FileName);
SalesCrMemoHeader2.Get(SalesCrMemoHeader."No.");
SalesCrMemoHeader2."OIOUBL-Electronic Credit Memo Created" := true;
@@ -398,4 +399,9 @@ codeunit 13637 "OIOUBL-Export Sales Cr. Memo"
local procedure OnCreateXMLOnAfterSalesCrMemoLineSetFilters(var SalesCrMemoLine: Record "Sales Cr.Memo Line"; SalesCrMemoHeader: Record "Sales Cr.Memo Header")
begin
end;
+
+ [IntegrationEvent(false, false)]
+ local procedure OnExportXMLOnAfterExportXMLFile(var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; var TempBlob: Codeunit "Temp Blob"; FileName: Text)
+ begin
+ end;
}
diff --git a/Apps/DK/OIOUBL/app/src/SalesInvoice/OIOUBLExportSalesInvoice.Codeunit.al b/Apps/DK/OIOUBL/app/src/SalesInvoice/OIOUBLExportSalesInvoice.Codeunit.al
index 67e256e4f3..7e9d7e0a86 100644
--- a/Apps/DK/OIOUBL/app/src/SalesInvoice/OIOUBLExportSalesInvoice.Codeunit.al
+++ b/Apps/DK/OIOUBL/app/src/SalesInvoice/OIOUBLExportSalesInvoice.Codeunit.al
@@ -59,7 +59,7 @@ codeunit 13636 "OIOUBL-Export Sales Invoice"
OIOUBLManagement: Codeunit "OIOUBL-Management";
TempBlob: Codeunit "Temp Blob";
FileOutStream: OutStream;
- FileName: Text[250];
+ FileName: Text;
begin
TempBlob.CreateOutStream(FileOutStream);
CreateXML(SalesInvoiceHeader, FileOutStream);
@@ -70,6 +70,7 @@ codeunit 13636 "OIOUBL-Export Sales Invoice"
OIOUBLManagement.UpdateRecordExportBuffer(SalesInvoiceHeader.RecordId(), TempBlob, FileName);
OIOUBLManagement.ExportXMLFile(SalesInvoiceHeader."No.", TempBlob, SalesSetup."OIOUBL-Invoice Path", FileName);
+ OnExportXMLOnAfterExportXMLFile(SalesInvoiceHeader, TempBlob, FileName);
SalesInvHeader2.Get(SalesInvoiceHeader."No.");
SalesInvHeader2."OIOUBL-Electronic Invoice Created" := true;
@@ -491,4 +492,9 @@ codeunit 13636 "OIOUBL-Export Sales Invoice"
local procedure OnCreateXMLOnAfterSalesInvLineSetFilters(var SalesInvoiceLine: Record "Sales Invoice Line"; SalesInvoiceHeader: Record "Sales Invoice Header")
begin
end;
+
+ [IntegrationEvent(false, false)]
+ local procedure OnExportXMLOnAfterExportXMLFile(var SalesInvoiceHeader: Record "Sales Invoice Header"; var TempBlob: Codeunit "Temp Blob"; FileName: Text)
+ begin
+ end;
}
diff --git a/Apps/IN/INGST/app/GSTBase/src/TaxEngineSetup/GSTTaxConfiguration.Codeunit.al b/Apps/IN/INGST/app/GSTBase/src/TaxEngineSetup/GSTTaxConfiguration.Codeunit.al
index 7577d73079..e4eebec3b1 100644
--- a/Apps/IN/INGST/app/GSTBase/src/TaxEngineSetup/GSTTaxConfiguration.Codeunit.al
+++ b/Apps/IN/INGST/app/GSTBase/src/TaxEngineSetup/GSTTaxConfiguration.Codeunit.al
@@ -309,7 +309,7 @@ codeunit 18017 "GST Tax Configuration"
UseCases.Add('{01C97F7D-4263-4387-84E1-610D2EA4A762}', 5);
UseCases.Add('{66A099C8-9660-498E-9BEB-61296A76CFAF}', 1);
UseCases.Add('{929EB05F-45B5-4F4F-9DD4-61AFAB36F21B}', 3);
- UseCases.Add('{E75A7A67-D332-41BE-B7EA-61C8BF69E9F7}', 3);
+ UseCases.Add('{E75A7A67-D332-41BE-B7EA-61C8BF69E9F7}', 4);
UseCases.Add('{4738101C-19E3-418C-A19D-61E67100D199}', 4);
UseCases.Add('{4CB6ACCD-BD47-4485-A757-62924EA09524}', 6);
UseCases.Add('{8B96F1E1-FC2C-48FD-AD1E-62986961AC0D}', 1);
diff --git a/Apps/IN/INGST/app/GSTBase/src/table/HSNSAC.table.al b/Apps/IN/INGST/app/GSTBase/src/table/HSNSAC.table.al
index 18e76f5951..547ce184bb 100644
--- a/Apps/IN/INGST/app/GSTBase/src/table/HSNSAC.table.al
+++ b/Apps/IN/INGST/app/GSTBase/src/table/HSNSAC.table.al
@@ -13,15 +13,13 @@ table 18009 "HSN/SAC"
fields
{
-#pragma warning disable AS0118
- field(1; "GST Group Code"; Code[20])
+ field(1; "GST Group Code"; Code[10])
{
Caption = 'GST Group Code';
NotBlank = true;
DataClassification = CustomerContent;
TableRelation = "GST Group";
}
-#pragma warning restore AS0118
field(2; "Code"; code[10])
{
Caption = 'Code';
diff --git a/Apps/IN/INGST/app/Translations/India GST.en-GB.xlf b/Apps/IN/INGST/app/Translations/India GST.en-GB.xlf
index 4c6b2f63f4..fe5bc75753 100644
--- a/Apps/IN/INGST/app/Translations/India GST.en-GB.xlf
+++ b/Apps/IN/INGST/app/Translations/India GST.en-GB.xlf
@@ -12964,7 +12964,7 @@
GST Use Cases
-
+
Codeunit GST Use Case Labels - Method GetConfig - NamedType {E75A7A67-D332-41BE-B7EA-61C8BF69E9F7}Lbl
diff --git a/Apps/IN/INGST/app/Translations/India GST.en-US.xlf b/Apps/IN/INGST/app/Translations/India GST.en-US.xlf
index bdcb504533..6c7ab1335d 100644
--- a/Apps/IN/INGST/app/Translations/India GST.en-US.xlf
+++ b/Apps/IN/INGST/app/Translations/India GST.en-US.xlf
@@ -12964,7 +12964,7 @@
GST Use Cases
-
+
Codeunit GST Use Case Labels - Method GetConfig - NamedType {E75A7A67-D332-41BE-B7EA-61C8BF69E9F7}Lbl
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 6fbdd14806..0a1f793ee0 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}', 2);
UseCases.Add('{271D5BC6-17E8-424E-9E34-3BEE548F938F}', 1);
- UseCases.Add('{A8E114BF-F8CD-44DB-A2B3-614BC18F4442}', 18);
+ UseCases.Add('{A8E114BF-F8CD-44DB-A2B3-614BC18F4442}', 19);
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/IN/INTDS/app/Translations/India TDS.en-GB.xlf b/Apps/IN/INTDS/app/Translations/India TDS.en-GB.xlf
index 72f2fbc3c5..e1ec420ee6 100644
--- a/Apps/IN/INTDS/app/Translations/India TDS.en-GB.xlf
+++ b/Apps/IN/INTDS/app/Translations/India TDS.en-GB.xlf
@@ -1988,7 +1988,7 @@
TDS Use Cases
-
+
Codeunit TDS Tax Engine Setup - Method GetConfig - NamedType {A8E114BF-F8CD-44DB-A2B3-614BC18F4442}Lbl
diff --git a/Apps/IN/INTDS/app/Translations/India TDS.en-US.xlf b/Apps/IN/INTDS/app/Translations/India TDS.en-US.xlf
index f37fcbbd2a..3134018327 100644
--- a/Apps/IN/INTDS/app/Translations/India TDS.en-US.xlf
+++ b/Apps/IN/INTDS/app/Translations/India TDS.en-US.xlf
@@ -1988,7 +1988,7 @@
TDS Use Cases
-
+
Codeunit TDS Tax Engine Setup - Method GetConfig - NamedType {A8E114BF-F8CD-44DB-A2B3-614BC18F4442}Lbl
diff --git a/Apps/IS/ISCore/app/src/Codeunits/EnableISCoreApp.Codeunit.al b/Apps/IS/ISCore/app/src/Codeunits/EnableISCoreApp.Codeunit.al
index f8b75581c5..62d75980d2 100644
--- a/Apps/IS/ISCore/app/src/Codeunits/EnableISCoreApp.Codeunit.al
+++ b/Apps/IS/ISCore/app/src/Codeunits/EnableISCoreApp.Codeunit.al
@@ -92,8 +92,20 @@ codeunit 14611 "Enable IS Core App"
SourceRecRef.Close();
end;
+ procedure UpdateDocumentRetentionPeriod();
+ var
+ ISCoreInstall: codeunit "IS Core Install";
+ begin
+ ISCoreInstall.UpdateGeneralLedgserSetup();
+ end;
+
procedure GetISCoreAppUpdateTag(): Code[250]
begin
exit('MS-460511-ISCoreApp-20231118');
end;
+
+ procedure GetISDocRetentionPeriodTag(): Code[250]
+ begin
+ exit('MS-534853-DocRetentionPeriod-20240514');
+ end;
}
\ No newline at end of file
diff --git a/Apps/IS/ISCore/app/src/Codeunits/ISCoreUpgrade.Codeunit.al b/Apps/IS/ISCore/app/src/Codeunits/ISCoreUpgrade.Codeunit.al
index ed61c3304f..978d30e41d 100644
--- a/Apps/IS/ISCore/app/src/Codeunits/ISCoreUpgrade.Codeunit.al
+++ b/Apps/IS/ISCore/app/src/Codeunits/ISCoreUpgrade.Codeunit.al
@@ -4,9 +4,7 @@
// ------------------------------------------------------------------------------------------------
namespace Microsoft.Finance;
-#if CLEAN24
using System.Upgrade;
-#endif
codeunit 14602 "IS Core Upgrade"
{
@@ -17,6 +15,7 @@ codeunit 14602 "IS Core Upgrade"
var
begin
TransferISCpecificData();
+ UpdateDocumentRetentionPeriod();
end;
local procedure TransferISCpecificData()
@@ -35,4 +34,25 @@ codeunit 14602 "IS Core Upgrade"
UpgradeTag.SetUpgradeTag(EnableISCoreApp.GetISCoreAppUpdateTag());
#endif
end;
+
+ local procedure UpdateDocumentRetentionPeriod()
+ var
+ UpgradeTag: Codeunit "Upgrade Tag";
+ ISCoreInstall: Codeunit "IS Core Install";
+ EnableISCoreApp: Codeunit "Enable IS Core App";
+ begin
+ if UpgradeTag.HasUpgradeTag(EnableISCoreApp.GetISDocRetentionPeriodTag()) then
+ exit;
+ ISCoreInstall.UpdateGeneralLedgserSetup();
+ UpgradeTag.SetUpgradeTag(EnableISCoreApp.GetISDocRetentionPeriodTag());
+ end;
+
+ [EventSubscriber(ObjectType::Codeunit, Codeunit::"Upgrade Tag", 'OnGetPerCompanyUpgradeTags', '', false, false)]
+ local procedure RegisterPerCompanyTags(var PerCompanyUpgradeTags: List of [Code[250]])
+ var
+ EnableISCoreApp: Codeunit "Enable IS Core App";
+ begin
+ PerCompanyUpgradeTags.Add(EnableISCoreApp.GetISCoreAppUpdateTag());
+ PerCompanyUpgradeTags.Add(EnableISCoreApp.GetISDocRetentionPeriodTag());
+ end;
}
\ No newline at end of file
diff --git a/Apps/IS/ISCore/app/src/Pages/ISCoreAppSetupWizard.Page.al b/Apps/IS/ISCore/app/src/Pages/ISCoreAppSetupWizard.Page.al
index 6454c7bf62..dd27cb8adb 100644
--- a/Apps/IS/ISCore/app/src/Pages/ISCoreAppSetupWizard.Page.al
+++ b/Apps/IS/ISCore/app/src/Pages/ISCoreAppSetupWizard.Page.al
@@ -293,6 +293,7 @@ page 14604 "IS Core App Setup Wizard"
OnBeforeFinishAction();
SetupFinished := true;
EnableISCoreApp.TransferData();
+ EnableISCoreApp.UpdateDocumentRetentionPeriod();
ISCoreAppSetup.Get();
ISCoreAppSetup.Enabled := true;
diff --git a/Apps/US/IRSForms/app/src/Printing/IRS 1099 Print.docx b/Apps/US/IRSForms/app/src/Printing/IRS 1099 Print.docx
index 6d5d85da6a..76965c59ed 100644
Binary files a/Apps/US/IRSForms/app/src/Printing/IRS 1099 Print.docx and b/Apps/US/IRSForms/app/src/Printing/IRS 1099 Print.docx differ
diff --git a/Apps/W1/AMCBanking365Fundamentals/app/Codeunits/AMCBankingMgt.Codeunit.al b/Apps/W1/AMCBanking365Fundamentals/app/Codeunits/AMCBankingMgt.Codeunit.al
index 81e091aa49..702cbaff83 100644
--- a/Apps/W1/AMCBanking365Fundamentals/app/Codeunits/AMCBankingMgt.Codeunit.al
+++ b/Apps/W1/AMCBanking365Fundamentals/app/Codeunits/AMCBankingMgt.Codeunit.al
@@ -229,6 +229,9 @@ codeunit 20105 "AMC Banking Mgt."
var
AMCBankingSetup: Record "AMC Banking Setup";
begin
+ if CompanyName() <> CompanyName then
+ AMCBankingSetup.ChangeCompany(CompanyName);
+
if (AMCBankingSetup.Get()) then
if (IsSolutionSandbox(AMCBankingSetup)) then
SetURLsToDefault(AMCBankingSetup);
diff --git a/Apps/W1/APIV2/app/src/pages/APIV2CustContacts.Page.al b/Apps/W1/APIV2/app/src/pages/APIV2CustContacts.Page.al
index 13244ff3b8..810ddb84cb 100644
--- a/Apps/W1/APIV2/app/src/pages/APIV2CustContacts.Page.al
+++ b/Apps/W1/APIV2/app/src/pages/APIV2CustContacts.Page.al
@@ -1,3 +1,7 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
namespace Microsoft.API.V2;
using Microsoft.CRM.Contact;
@@ -17,6 +21,7 @@ page 30089 "APIV2 - CustContacts"
PageType = API;
SourceTable = Contact;
Extensible = false;
+ InsertAllowed = false;
layout
{
@@ -57,9 +62,8 @@ page 30089 "APIV2 - CustContacts"
RegisterFieldSet(Rec.FieldNo("Job Title"));
end;
}
- field(customerId; Customer.SystemId)
+ field(customerId; CustomerId)
{
- Editable = false;
}
field(customerName; Customer.Name)
{
@@ -78,9 +82,8 @@ page 30089 "APIV2 - CustContacts"
Multiplicity = ZeroOrOne;
EntityName = 'pdfDocument';
EntitySetName = 'pdfDocument';
- SubPageLink = "Document Id" = field(Systemid), "Document Type" = const("Customer Statemet");
+ SubPageLink = "Document Id" = field(SystemId), "Document Type" = const("Customer Statement");
}
-
}
}
}
@@ -91,6 +94,7 @@ page 30089 "APIV2 - CustContacts"
var
Customer: Record Customer;
TempFieldSet: Record System.Reflection.Field temporary;
+ CustomerId: Guid;
trigger OnAfterGetRecord()
begin
@@ -98,7 +102,22 @@ page 30089 "APIV2 - CustContacts"
end;
trigger OnModifyRecord(): Boolean
+ var
+ ChangedCustomer: Record Customer;
+ ContactBusinessRelation: Record "Contact Business Relation";
+ CustomerWithProvidedIdDoesNotExistErr: Label 'Customer with provided id - does not exist';
begin
+ if CustomerId <> Customer.SystemId then begin
+ if not ChangedCustomer.GetBySystemId(CustomerId) then
+ Error(CustomerWithProvidedIdDoesNotExistErr);
+ ContactBusinessRelation.SetRange("Contact No.", Rec."Company No.");
+ ContactBusinessRelation.SetRange("Link to Table", ContactBusinessRelation."Link to Table"::Customer);
+ ContactBusinessRelation.SetRange("No.", Customer."No.");
+ if ContactBusinessRelation.FindFirst() then begin
+ ContactBusinessRelation.Validate("No.", ChangedCustomer."No.");
+ ContactBusinessRelation.Modify(true);
+ end;
+ end;
SetCalculatedFields();
end;
@@ -114,8 +133,10 @@ page 30089 "APIV2 - CustContacts"
Clear(Customer);
ContactBusinessRelation.SetRange("Contact No.", Rec."Company No.");
ContactBusinessRelation.SetRange("Link to Table", ContactBusinessRelation."Link to Table"::Customer);
- if ContactBusinessRelation.FindFirst() then
+ if ContactBusinessRelation.FindFirst() then begin
Customer.Get(ContactBusinessRelation."No.");
+ CustomerId := Customer.SystemId;
+ end;
end;
local procedure RegisterFieldSet(FieldNo: Integer)
@@ -132,6 +153,7 @@ page 30089 "APIV2 - CustContacts"
local procedure ClearCalculatedFields()
begin
Clear(Customer);
+ Clear(CustomerId);
end;
trigger OnOpenPage()
diff --git a/Apps/W1/BankDeposits/app/src/codeunits/NavigateBankDepositExt.Codeunit.al b/Apps/W1/BankDeposits/app/src/codeunits/NavigateBankDepositExt.Codeunit.al
index 3009fd09e4..60f77ec4cd 100644
--- a/Apps/W1/BankDeposits/app/src/codeunits/NavigateBankDepositExt.Codeunit.al
+++ b/Apps/W1/BankDeposits/app/src/codeunits/NavigateBankDepositExt.Codeunit.al
@@ -9,16 +9,11 @@ using Microsoft.Finance.GeneralLedger.Ledger;
using Microsoft.Finance.VAT.Ledger;
using Microsoft.Purchases.Payables;
using Microsoft.Service.Ledger;
-using Microsoft.Sales.Receivables;
-using Microsoft.Bank.Ledger;
codeunit 1699 "Navigate Bank Deposit Ext."
{
Access = Internal;
- var
- RecordWithoutKeysMsg: Label 'Before you can navigate on a deposit, you must create and activate a key group called "NavDep". If you cannot do this yourself, ask your system administrator.';
-
local procedure SetPostedBankDepositHeaderFilters(var PostedBankDepositHeader: Record "Posted Bank Deposit Header"; DocNoFilter: Text): Boolean
begin
if not PostedBankDepositHeader.ReadPermission() then
@@ -99,89 +94,4 @@ codeunit 1699 "Navigate Bank Deposit Ext."
DocType := CopyStr(PostedBankDepositHeader.TableCaption(), 1, MaxStrLen(DocType));
Sender.SetSource(PostedBankDepositHeader."Posting Date", DocType, PostedBankDepositHeader."No.", 4, PostedBankDepositHeader."Bank Account No.");
end;
-
- // OVERRRIDING HOW TO GET RELATED ENTRIES FOR POSTED BANK DEPOSITS
-
- // When searching from a Posted Bank Deposit as source, finding the related GL Entries, Customer Ledger Entries, etc.
- // is done differently, as their ExtDocNo has the corresponding Bank Deposit No.
-
- [EventSubscriber(ObjectType::Page, Page::Navigate, 'OnBeforeFindCustLedgerEntry', '', false, false)]
- local procedure OnBeforeFindCustLedgerEntry(Sender: Page Navigate; var CustLedgerEntry: Record "Cust. Ledger Entry"; DocNoFilter: Text; PostingDateFilter: Text; ExtDocNo: Text; var IsHandled: Boolean)
- begin
- if not Sender.GetNavigationFromPostedBankDeposit() then
- exit;
- if not CustLedgerEntry.ReadPermission() then
- exit;
- if IsHandled then
- exit;
-
- IsHandled := true;
-
- CustLedgerEntry.Reset();
- if not CustLedgerEntry.SetCurrentKey("External Document No.", "Posting Date") then
- Error(RecordWithoutKeysMsg);
- CustLedgerEntry.SetFilter("External Document No.", DocNoFilter);
- CustLedgerEntry.SetFilter("Posting Date", PostingDateFilter);
- Sender.InsertIntoDocEntry(DATABASE::"Cust. Ledger Entry", CustLedgerEntry.TableCaption(), CustLedgerEntry.Count());
- end;
-
- [EventSubscriber(ObjectType::Page, Page::Navigate, 'OnBeforeFindVendorLedgerEntry', '', false, false)]
- local procedure OnBeforeFindVendorLedgerEntry(Sender: Page Navigate; var VendorLedgerEntry: Record "Vendor Ledger Entry"; DocNoFilter: Text; PostingDateFilter: Text; ExtDocNo: Text; var IsHandled: Boolean)
- begin
- if not Sender.GetNavigationFromPostedBankDeposit() then
- exit;
- if not VendorLedgerEntry.ReadPermission() then
- exit;
- if IsHandled then
- exit;
-
- IsHandled := true;
-
- VendorLedgerEntry.Reset();
- if not VendorLedgerEntry.SetCurrentKey("External Document No.", "Posting Date") then
- Error(RecordWithoutKeysMsg);
- VendorLedgerEntry.SetFilter("External Document No.", DocNoFilter);
- VendorLedgerEntry.SetFilter("Posting Date", PostingDateFilter);
- Sender.InsertIntoDocEntry(DATABASE::"Vendor Ledger Entry", VendorLedgerEntry.TableCaption(), VendorLedgerEntry.Count());
- end;
-
- [EventSubscriber(ObjectType::Page, Page::Navigate, 'OnBeforeFindBankAccountLedgerEntry', '', false, false)]
- local procedure OnBeforeFindBankAccountLedgerEntry(Sender: Page Navigate; var BankAccountLedgerEntry: Record "Bank Account Ledger Entry"; DocNoFilter: Text; PostingDateFilter: Text; ExtDocNo: Text; var IsHandled: Boolean)
- begin
- if not Sender.GetNavigationFromPostedBankDeposit() then
- exit;
- if not BankAccountLedgerEntry.ReadPermission() then
- exit;
- if IsHandled then
- exit;
-
- IsHandled := true;
-
- BankAccountLedgerEntry.Reset();
- if not BankAccountLedgerEntry.SetCurrentKey("External Document No.", "Posting Date") then
- Error(RecordWithoutKeysMsg);
- BankAccountLedgerEntry.SetFilter("External Document No.", DocNoFilter);
- BankAccountLedgerEntry.SetFilter("Posting Date", PostingDateFilter);
- Sender.InsertIntoDocEntry(DATABASE::"Bank Account Ledger Entry", BankAccountLedgerEntry.TableCaption(), BankAccountLedgerEntry.Count());
- end;
-
- [EventSubscriber(ObjectType::Page, Page::Navigate, 'OnBeforeFindGLEntry', '', false, false)]
- local procedure OnBeforeFindGLEntry(Sender: Page Navigate; var GLEntry: Record "G/L Entry"; DocNoFilter: Text; PostingDateFilter: Text; ExtDocNo: Text; var IsHandled: Boolean)
- begin
- if not Sender.GetNavigationFromPostedBankDeposit() then
- exit;
- if not GLEntry.ReadPermission() then
- exit;
- if IsHandled then
- exit;
-
- IsHandled := true;
-
- GLEntry.Reset();
- if not GLEntry.SetCurrentKey("External Document No.", "Posting Date") then
- Error(RecordWithoutKeysMsg);
- GLEntry.SetFilter("External Document No.", DocNoFilter);
- GLEntry.SetFilter("Posting Date", PostingDateFilter);
- Sender.InsertIntoDocEntry(DATABASE::"G/L Entry", GLEntry.TableCaption(), GLEntry.Count());
- end;
}
\ No newline at end of file
diff --git a/Apps/W1/BankDeposits/app/src/pages/BankDepositSubform.Page.al b/Apps/W1/BankDeposits/app/src/pages/BankDepositSubform.Page.al
index cce9c1cb02..16907b1ef3 100644
--- a/Apps/W1/BankDeposits/app/src/pages/BankDepositSubform.Page.al
+++ b/Apps/W1/BankDeposits/app/src/pages/BankDepositSubform.Page.al
@@ -431,7 +431,8 @@ page 1693 "Bank Deposit Subform"
Rec."Currency Factor" := BankDepositHeader."Currency Factor";
Rec."Document Date" := BankDepositHeader."Document Date";
Rec."Posting Date" := BankDepositHeader."Posting Date";
- Rec."External Document No." := BankDepositHeader."No.";
+ Rec."Document No." := BankDepositHeader."No.";
+ Rec."External Document No." := '';
Rec."Reason Code" := BankDepositHeader."Reason Code";
end;
diff --git a/Apps/W1/BankDeposits/test/src/BankDepositPostingTests.Codeunit.al b/Apps/W1/BankDeposits/test/src/BankDepositPostingTests.Codeunit.al
index c055d285f4..b51a11dfe5 100644
--- a/Apps/W1/BankDeposits/test/src/BankDepositPostingTests.Codeunit.al
+++ b/Apps/W1/BankDeposits/test/src/BankDepositPostingTests.Codeunit.al
@@ -490,6 +490,62 @@ codeunit 139769 "Bank Deposit Posting Tests"
Assert.AreEqual(-Amount, PostedBankDepositHeader."Total Deposit Lines", 'The total amount of the deposit should be the sum of the lines');
end;
+ [Test]
+ [HandlerFunctions('GeneralJournalBatchesPageHandler,ConfirmHandler')]
+ procedure NavigatePageOfAPostedBankDepositShowsRelatedEntries()
+ var
+ BankDepositHeader: Record "Bank Deposit Header";
+ GLAccount: Record "G/L Account";
+ Customer: Record Customer;
+ GenJournalBatch: Record "Gen. Journal Batch";
+ GenJournalTemplate: Record "Gen. Journal Template";
+ GenJournalLine: Record "Gen. Journal Line";
+ BankAccountLedgerEntry: Record "Bank Account Ledger Entry";
+ CustLedgerEntry: Record "Cust. Ledger Entry";
+ BankDeposit: TestPage "Bank Deposit";
+ PostedBankDeposit: TestPage "Posted Bank Deposit";
+ Navigate: TestPage Navigate;
+ BankEntryFound, CustomerEntryFound : Boolean;
+ TableName: Text;
+ begin
+ // [SCENARIO 537831] Related entries are shown on the Navigate page of a posted bank deposit
+ Initialize();
+ // [GIVEN] A Posted Bank Deposit with a G/L Account and a Customer.
+ CreateGenJournalBatch(GenJournalBatch, GenJournalTemplate.Type::"Bank Deposits");
+ CreateBankDepositHeaderWithBankAccount(BankDepositHeader, GenJournalBatch);
+ BankDepositHeader."Total Deposit Amount" := 1000;
+ BankDepositHeader.Modify();
+ BankDeposit.Trap();
+ BankDepositHeader.SetRecFilter();
+ Page.Run(Page::"Bank Deposit", BankDepositHeader);
+ LibraryERM.CreateGLAccount(GLAccount);
+ BankDeposit.Subform."Account Type".SetValue(GenJournalLine."Account Type"::"G/L Account");
+ BankDeposit.Subform."Account No.".SetValue(GLAccount."No.");
+ BankDeposit.Subform."Credit Amount".SetValue(-10);
+ BankDeposit.Subform.Next();
+ LibrarySales.CreateCustomer(Customer);
+ BankDeposit.Subform."Account Type".SetValue(GenJournalLine."Account Type"::Customer);
+ BankDeposit.Subform."Account No.".SetValue(Customer."No.");
+ BankDeposit.Subform."Credit Amount".SetValue(1010);
+ PostedBankDeposit.Trap();
+ BankDeposit.Post.Invoke();
+ // [WHEN] Navigate action is invoked from the posted bank deposit
+ Navigate.Trap();
+ PostedBankDeposit."&Navigate".Invoke();
+
+ repeat
+ TableName := Navigate."Table Name".Value();
+ case TableName of
+ BankAccountLedgerEntry.TableCaption():
+ BankEntryFound := true;
+ CustLedgerEntry.TableCaption():
+ CustomerEntryFound := true;
+ end;
+ until (not Navigate.Next());
+ // [THEN] The entries posted are found.
+ Assert.IsTrue(BankEntryFound, 'Bank Account Ledger Entry should be found');
+ Assert.IsTrue(CustomerEntryFound, 'Customer Ledger Entry should be found');
+ end;
local procedure Initialize()
var
diff --git a/Apps/W1/BankDeposits/test/src/UTPageBankDeposit.Codeunit.al b/Apps/W1/BankDeposits/test/src/UTPageBankDeposit.Codeunit.al
index 17532253d8..8b8917a15e 100644
--- a/Apps/W1/BankDeposits/test/src/UTPageBankDeposit.Codeunit.al
+++ b/Apps/W1/BankDeposits/test/src/UTPageBankDeposit.Codeunit.al
@@ -663,11 +663,11 @@ codeunit 139768 "UT Page Bank Deposit"
Page.Run(Page::"Bank Deposit", BankDepositHeader);
BankDeposit.Subform."Account Type".SetValue(GenJnlLine."Account Type"::Vendor.AsInteger());
BankDeposit.Subform."Account No.".SetValue(LibraryPurchase.CreateVendorNo());
- BankDeposit.Subform."Document No.".SetValue(LibraryUtility.GenerateRandomNumericText(2));
+ BankDeposit.Subform."External Document No.".SetValue(LibraryUtility.GenerateRandomNumericText(2));
BankDeposit.Subform."Credit Amount".SetValue(BankDepositHeader."Total Deposit Amount");
// [GIVEN] Get the created General Jnl Line.
- GenJnlLine.SetFilter("External Document No.", BankDepositHeader."No.");
+ GenJnlLine.SetFilter("Document No.", BankDepositHeader."No.");
GenJnlLine.FindFirst();
SourceCodeSetup.Get();
@@ -748,6 +748,22 @@ codeunit 139768 "UT Page Bank Deposit"
Assert.AreEqual(GenJournalTemplate.Name, BAnkDepositHeader."Journal Template Name", '');
end;
+ [Test]
+ procedure DefaultValueOfDocumentNoForDepositLineIsTheBankDepositNo()
+ var
+ BankDepositHeader: Record "Bank Deposit Header";
+ BankDeposit: TestPage "Bank Deposit";
+ begin
+ // [SCENARIO 537832] Bank Deposit default values for lines should be the bank deposit number for the "Document No." and blank for the "External Document No."
+ // [GIVEN] A Bank Deposit Header without lines
+ CreateBankDepositHeader(BankDepositHeader, '');
+ // [WHEN] Opening the Bank Deposit page
+ OpenDepositPage(BankDeposit, BankDepositHeader);
+ // [THEN] The default values for the lines are as expected.
+ Assert.AreEqual(BankDepositHeader."No.", BankDeposit.Subform."Document No.".Value(), 'The default value of Document No. for the Deposit Line should be the Bank Deposit No.');
+ Assert.AreEqual('', BankDeposit.Subform."External Document No.".Value(), 'The default value of External Document No. for the Deposit Line should be empty.');
+ end;
+
local procedure GetBankDepositsFeature(var FeatureDataUpdateStatus: Record "Feature Data Update Status"; ID: Text[50])
begin
if FeatureDataUpdateStatus.Get(ID, CompanyName()) then
diff --git a/Apps/W1/CrossEnvironmentIntercompany/app/src/pages/APIBufICInboxPurchaseLine.Page.al b/Apps/W1/CrossEnvironmentIntercompany/app/src/pages/APIBufICInboxPurchaseLine.Page.al
index 8f7a68fa38..24b65b7274 100644
--- a/Apps/W1/CrossEnvironmentIntercompany/app/src/pages/APIBufICInboxPurchaseLine.Page.al
+++ b/Apps/W1/CrossEnvironmentIntercompany/app/src/pages/APIBufICInboxPurchaseLine.Page.al
@@ -82,6 +82,16 @@ page 30419 "API Buf IC Inbox Purchase Line"
Caption = 'Amount Including VAT';
Editable = true;
}
+ field(amount; Rec.Amount)
+ {
+ Caption = 'Amount';
+ Editable = true;
+ }
+ field(invoiceDiscountAmount; Rec."Inv. Discount Amount")
+ {
+ Caption = 'Inv. Discount Amount';
+ Editable = true;
+ }
field(jobNumber; Rec."Job No.")
{
Caption = 'Job Number';
diff --git a/Apps/W1/CrossEnvironmentIntercompany/app/src/pages/APIBufICInboxSalesLine.Page.al b/Apps/W1/CrossEnvironmentIntercompany/app/src/pages/APIBufICInboxSalesLine.Page.al
index f5704a9876..1766a0848e 100644
--- a/Apps/W1/CrossEnvironmentIntercompany/app/src/pages/APIBufICInboxSalesLine.Page.al
+++ b/Apps/W1/CrossEnvironmentIntercompany/app/src/pages/APIBufICInboxSalesLine.Page.al
@@ -82,6 +82,16 @@ page 30422 "API Buf IC Inbox Sales Line"
Caption = 'Amount Including VAT';
Editable = true;
}
+ field(amount; Rec.Amount)
+ {
+ Caption = 'Amount';
+ Editable = true;
+ }
+ field(invoiceDiscountAmount; Rec."Inv. Discount Amount")
+ {
+ Caption = 'Inv. Discount Amount';
+ Editable = true;
+ }
field(jobNumber; Rec."Job No.")
{
Caption = 'Job Number';
diff --git a/Apps/W1/EDocument/app/src/Processing/OrderMatching/Copilot/EDocPOCopilotMatching.Codeunit.al b/Apps/W1/EDocument/app/src/Processing/OrderMatching/Copilot/EDocPOCopilotMatching.Codeunit.al
index 9da1edc3b1..74b8e660a5 100644
--- a/Apps/W1/EDocument/app/src/Processing/OrderMatching/Copilot/EDocPOCopilotMatching.Codeunit.al
+++ b/Apps/W1/EDocument/app/src/Processing/OrderMatching/Copilot/EDocPOCopilotMatching.Codeunit.al
@@ -8,7 +8,6 @@ using Microsoft.eServices.EDocument.OrderMatch;
using System.Environment;
using System.Telemetry;
using System.Upgrade;
-using System.Globalization;
codeunit 6163 "E-Doc. PO Copilot Matching"
{
@@ -163,9 +162,6 @@ codeunit 6163 "E-Doc. PO Copilot Matching"
if not EnvironmentInformation.IsSaaSInfrastructure() then
exit(false);
- if not IsSupportedLanguage() then
- exit(false);
-
exit(true);
end;
@@ -205,20 +201,6 @@ codeunit 6163 "E-Doc. PO Copilot Matching"
exit(Prompt);
end;
- local procedure IsSupportedLanguage(): Boolean
- var
- LanguageSelection: Record "Language Selection";
- UserSessionSettings: SessionSettings;
- begin
- UserSessionSettings.Init();
- LanguageSelection.SetLoadFields("Language Tag");
- LanguageSelection.SetRange("Language ID", UserSessionSettings.LanguageId());
- if LanguageSelection.FindFirst() then
- if LanguageSelection."Language Tag".StartsWith('pt-') then
- exit(false);
- exit(true);
- end;
-
local procedure GroundCopilotMatching(var TempEDocumentImportedLine: Record "E-Doc. Imported Line" temporary; var TempPurchaseLine: Record "Purchase Line" temporary; var TempAIProposalBuffer: Record "E-Doc. PO Match Prop. Buffer" temporary)
var
TempEDocMatchesThatWasMatched: Record "E-Doc. Order Match" temporary;
diff --git a/Apps/W1/Email - Outlook REST API/app/src/EmailOAuthClient.Codeunit.al b/Apps/W1/Email - Outlook REST API/app/src/EmailOAuthClient.Codeunit.al
index 68e5f36796..04c65b622e 100644
--- a/Apps/W1/Email - Outlook REST API/app/src/EmailOAuthClient.Codeunit.al
+++ b/Apps/W1/Email - Outlook REST API/app/src/EmailOAuthClient.Codeunit.al
@@ -26,9 +26,12 @@ codeunit 4507 "Email - OAuth Client" implements "Email - OAuth Client v2"
[NonDebuggable]
[Obsolete('Replaced by GetAccessToken with SecretText data type for AccessToken parameter.', '24.0')]
procedure GetAccessToken(var AccessToken: Text)
+ var
+ CallerModuleInfo: ModuleInfo;
begin
+ NavApp.GetCallerModuleInfo(CallerModuleInfo);
#pragma warning disable AL0432
- TryGetAccessTokenInternal(AccessToken);
+ TryGetAccessTokenInternal(AccessToken, CallerModuleInfo);
#pragma warning restore AL0432
end;
@@ -36,8 +39,11 @@ codeunit 4507 "Email - OAuth Client" implements "Email - OAuth Client v2"
[Obsolete('Replaced by GetAccessToken with SecretText data type for AccessToken parameter.', '24.0')]
procedure TryGetAccessToken(var AccessToken: Text): Boolean
+ var
+ CallerModuleInfo: ModuleInfo;
begin
- exit(TryGetAccessTokenInternal(AccessToken));
+ NavApp.GetCallerModuleInfo(CallerModuleInfo);
+ exit(TryGetAccessTokenInternal(AccessToken, CallerModuleInfo));
end;
#endif
@@ -47,25 +53,46 @@ codeunit 4507 "Email - OAuth Client" implements "Email - OAuth Client v2"
/// Out parameter with the Access token of the account
[NonDebuggable]
procedure GetAccessToken(var AccessToken: SecretText)
+ var
+ CallerModuleInfo: ModuleInfo;
begin
- TryGetAccessTokenInternal(AccessToken);
+ NavApp.GetCallerModuleInfo(CallerModuleInfo);
+ TryGetAccessTokenInternal(AccessToken, CallerModuleInfo);
end;
[NonDebuggable]
procedure TryGetAccessToken(var AccessToken: SecretText): Boolean
+ var
+ CallerModuleInfo: ModuleInfo;
+ begin
+ NavApp.GetCallerModuleInfo(CallerModuleInfo);
+ exit(TryGetAccessTokenInternal(AccessToken, CallerModuleInfo));
+ end;
+
+ local procedure CheckIfThirdParty(CallerModuleInfo: ModuleInfo)
+ var
+ EnvironmentInformation: Codeunit "Environment Information";
+ CurrentModuleInfo: ModuleInfo;
begin
- exit(TryGetAccessTokenInternal(AccessToken));
+ NavApp.GetCurrentModuleInfo(CurrentModuleInfo);
+
+ if EnvironmentInformation.IsSaaSInfrastructure() <> true then
+ exit;
+
+ if CallerModuleInfo.Publisher <> CurrentModuleInfo.Publisher then
+ Error(ThirdPartyExtensionsNotAllowedErr);
end;
#if not CLEAN24
// Interfaces do not support properties for the procedures, so using an internal function
[TryFunction]
[NonDebuggable]
- local procedure TryGetAccessTokenInternal(var AccessToken: Text)
+ local procedure TryGetAccessTokenInternal(var AccessToken: Text; CallerModuleInfo: ModuleInfo)
var
Token: SecretText;
begin
- TryGetAccessTokenInternal(Token);
+ CheckIfThirdParty(CallerModuleInfo);
+ TryGetAccessTokenInternal(Token, CallerModuleInfo);
if not Token.IsEmpty() then
AccessToken := Token.Unwrap();
end;
@@ -74,13 +101,14 @@ codeunit 4507 "Email - OAuth Client" implements "Email - OAuth Client v2"
// Interfaces do not support properties for the procedures, so using an internal function
[TryFunction]
[NonDebuggable]
- local procedure TryGetAccessTokenInternal(var AccessToken: SecretText)
+ local procedure TryGetAccessTokenInternal(var AccessToken: SecretText; CallerModuleInfo: ModuleInfo)
var
AzureAdMgt: Codeunit "Azure AD Mgt.";
UrlHelper: Codeunit "Url Helper";
EnvironmentInformation: Codeunit "Environment Information";
OAuthErr: Text;
begin
+ CheckIfThirdParty(CallerModuleInfo);
Initialize();
ClearLastError();
@@ -165,4 +193,5 @@ codeunit 4507 "Email - OAuth Client" implements "Email - OAuth Client v2"
CouldNotGetAccessTokenErr: Label 'Could not get access token.';
EmailCategoryLbl: Label 'EmailOAuth', Locked = true;
CouldNotAcquireAccessTokenErr: Label 'Failed to acquire access token.', Locked = true;
+ ThirdPartyExtensionsNotAllowedErr: Label 'Third-party extensions are restricted from obtaining access tokens. Please contact your system administrator.';
}
\ No newline at end of file
diff --git a/Apps/W1/EnforcedDigitalVouchers/app/src/Extensions/DigVoucherIncDocAttach.TableExt.al b/Apps/W1/EnforcedDigitalVouchers/app/src/Extensions/DigVoucherIncDocAttach.TableExt.al
new file mode 100644
index 0000000000..a86976dc86
--- /dev/null
+++ b/Apps/W1/EnforcedDigitalVouchers/app/src/Extensions/DigVoucherIncDocAttach.TableExt.al
@@ -0,0 +1,16 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+namespace Microsoft.EServices.EDocument;
+
+tableextension 5582 "Dig. Voucher Inc. Doc. Attach." extends "Incoming Document Attachment"
+{
+ fields
+ {
+ field(5582; "Is Digital Voucher"; Boolean)
+ {
+ DataClassification = SystemMetadata;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Apps/W1/EnforcedDigitalVouchers/app/src/Implementation/DigitalVoucherImpl.Codeunit.al b/Apps/W1/EnforcedDigitalVouchers/app/src/Implementation/DigitalVoucherImpl.Codeunit.al
index 2f096ea286..8c8d1dbaaf 100644
--- a/Apps/W1/EnforcedDigitalVouchers/app/src/Implementation/DigitalVoucherImpl.Codeunit.al
+++ b/Apps/W1/EnforcedDigitalVouchers/app/src/Implementation/DigitalVoucherImpl.Codeunit.al
@@ -16,6 +16,7 @@ using Microsoft.Sales.Document;
using Microsoft.Sales.History;
using Microsoft.Sales.Posting;
using Microsoft.Sales.Receivables;
+using System.Email;
using System.Environment.Configuration;
using System.Media;
using System.Reflection;
@@ -70,6 +71,7 @@ codeunit 5579 "Digital Voucher Impl."
procedure HandleDigitalVoucherForPostedGLEntry(GLEntry: Record "G/L Entry"; GenJournalLine: Record "Gen. Journal Line"; GenJournalSourceType: Enum "Gen. Journal Source Type")
var
DigitalVoucherEntrySetup: Record "Digital Voucher Entry Setup";
+ ConnectedGenJournalLine: Record "Gen. Journal Line";
RecRef: RecordRef;
DigitalVoucherCheck: Interface "Digital Voucher Check";
begin
@@ -78,7 +80,8 @@ codeunit 5579 "Digital Voucher Impl."
if DigitalVoucherEntrySetup."Check Type" = DigitalVoucherEntrySetup."Check Type"::"No Check" then
exit;
DigitalVoucherCheck := DigitalVoucherEntrySetup."Check Type";
- RecRef.GetTable(GenJournalLine);
+ FindGenJournalLineFromGLEntry(ConnectedGenJournalLine, GenJournalLine, GLEntry);
+ RecRef.GetTable(ConnectedGenJournalLine);
DigitalVoucherCheck.GenerateDigitalVoucherForPostedDocument(DigitalVoucherEntrySetup."Entry Type", RecRef);
end;
@@ -138,11 +141,15 @@ codeunit 5579 "Digital Voucher Impl."
IncomingDocumentAttachment.SetRange("Document No.", DocNo);
IncomingDocumentAttachment.SetRange("Posting Date", PostingDate);
IncomingDocumentAttachment.SetContentFromBlob(TempBlob);
- ImportAttachmentIncDoc.ImportAttachment(
+ if not ImportAttachmentIncDoc.ImportAttachment(
IncomingDocumentAttachment,
StrSubstNo(
DigitalVoucherFileTxt, DocType,
- Format(PostingDate, 0, ''), DocNo), TempBlob);
+ Format(PostingDate, 0, ''), DocNo), TempBlob)
+ then
+ exit;
+ IncomingDocumentAttachment."Is Digital Voucher" := true;
+ IncomingDocumentAttachment.Modify();
end;
procedure CheckDigitalVoucherForDocument(DigitalVoucherEntryType: Enum "Digital Voucher Entry Type"; RecRef: RecordRef): Boolean
@@ -199,10 +206,23 @@ codeunit 5579 "Digital Voucher Impl."
RecRef.SetTable(GenJournalLine);
GenJournalLine.SetRange("Journal Template Name", GenJournalLine."Journal Template Name");
GenJournalLine.SetRange("Journal Batch Name", GenJournalLine."Journal Batch Name");
+ GenJournalLine.SetRange("Posting Date", GenJournalLine."Posting Date");
+ GenJournalLine.SetRange("Document No.", GenJournalLine."Document No.");
ReportSelections.SaveReportAsPDFInTempBlob(TempBlob, Report::"General Journal - Test", GenJournalLine, '', DummyReportUsage);
AttachBlobToIncomingDocument(TempBlob, Format(GenJournalLine."Document Type"), GenJournalLine."Posting Date", GenJournalLine."Document No.");
end;
+ local procedure FindGenJournalLineFromGLEntry(var ConnectedGenJnlLine: Record "Gen. Journal Line"; CurrGenJnlLine: Record "Gen. Journal Line"; GLEntry: Record "G/L Entry")
+ begin
+ ConnectedGenJnlLine.SetRange("Journal Template Name", CurrGenJnlLine."Journal Template Name");
+ ConnectedGenJnlLine.SetRange("Journal Batch Name", CurrGenJnlLine."Journal Batch Name");
+ ConnectedGenJnlLine.SetRange("Posting Date", GLEntry."Posting Date");
+ ConnectedGenJnlLine.SetRange("Document No.", GLEntry."Document No.");
+ if ConnectedGenJnlLine.FindFirst() then
+ exit;
+ ConnectedGenJnlLine := CurrGenJnlLine;
+ end;
+
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Guided Experience", 'OnRegisterAssistedSetup', '', true, true)]
local procedure InsertIntoAssistedSetup()
var
@@ -323,6 +343,7 @@ codeunit 5579 "Digital Voucher Impl."
local procedure OnProcessLinesOnAfterPostGenJnlLines(var GenJournalLine: Record "Gen. Journal Line"; GLRegister: Record "G/L Register"; var GLRegNo: Integer; PreviewMode: Boolean)
var
GLEntry: Record "G/L Entry";
+ GLEntryToHandle: Record "G/L Entry";
CurrPostingDateDocNoCode: Text;
PostingDateDocNoCode: Text;
GenJournalSourceType: Enum "Gen. Journal Source Type";
@@ -340,9 +361,10 @@ codeunit 5579 "Digital Voucher Impl."
PostingDateDocNoCode := Format(GLEntry."Posting Date") + GLEntry."Document No.";
if PostingDateDocNoCode <> CurrPostingDateDocNoCode then begin
if CurrPostingDateDocNoCode <> '' then
- HandleDigitalVoucherForPostedGLEntry(GLEntry, GenJournalLine, GenJournalSourceType);
+ HandleDigitalVoucherForPostedGLEntry(GLEntryToHandle, GenJournalLine, GenJournalSourceType);
CurrPostingDateDocNoCode := PostingDateDocNoCode;
GenJournalSourceType := GenJournalSourceType::" ";
+ GLEntryToHandle := GLEntry;
end;
if GLEntry."Source Type" <> GLEntry."Source Type"::" " then
GenJournalSourceType := GLEntry."Source Type";
@@ -395,6 +417,12 @@ codeunit 5579 "Digital Voucher Impl."
DigitalVoucherFeature.CheckIfDigitalVoucherSetupChangeIsAllowed();
end;
+ [EventSubscriber(ObjectType::Table, Database::"Email Item", 'OnAttachIncomingDocumentsOnAfterSetFilter', '', false, false)]
+ local procedure ExcludeDigitalVouchersOnAttachIncomingDocumentsOnAfterSetFilter(var IncomingDocumentAttachment: Record "Incoming Document Attachment")
+ begin
+ IncomingDocumentAttachment.SetRange("Is Digital Voucher", false);
+ end;
+
[EventSubscriber(ObjectType::Table, Database::"Digital Voucher Setup", 'OnBeforeDeleteEvent', '', false, false)]
local procedure CheckIfChangeIsAllowedOnDeleteDigitalVoucherSetup(var Rec: Record "Digital Voucher Setup"; RunTrigger: Boolean)
begin
diff --git a/Apps/W1/EnforcedDigitalVouchers/app/src/Implementation/VoucherAttachmentCheck.Codeunit.al b/Apps/W1/EnforcedDigitalVouchers/app/src/Implementation/VoucherAttachmentCheck.Codeunit.al
index c8839742d9..7668aa33ac 100644
--- a/Apps/W1/EnforcedDigitalVouchers/app/src/Implementation/VoucherAttachmentCheck.Codeunit.al
+++ b/Apps/W1/EnforcedDigitalVouchers/app/src/Implementation/VoucherAttachmentCheck.Codeunit.al
@@ -17,7 +17,7 @@ codeunit 5580 "Voucher Attachment Check" implements "Digital Voucher Check"
procedure CheckVoucherIsAttachedToDocument(var ErrorMessageMgt: Codeunit "Error Message Management"; DigitalVoucherEntryType: Enum "Digital Voucher Entry Type"; RecRef: RecordRef)
begin
if not DigitalVoucherImpl.CheckDigitalVoucherForDocument(DigitalVoucherEntryType, RecRef) then
- if DigitalVoucherEntryType = DigitalVoucherEntryType::"General Journal" then
+ if DigitalVoucherEntryType in [DigitalVoucherEntryType::"General Journal", DigitalVoucherEntryType::"Purchase Journal", DigitalVoucherEntryType::"Sales Journal"] then
error(NotPossibleToPostWithoutVoucherErr)
else
ErrorMessageMgt.LogSimpleErrorMessage(NotPossibleToPostWithoutVoucherErr);
diff --git a/Apps/W1/EnforcedDigitalVouchers/test/src/DigitalVouchersTests.Codeunit.al b/Apps/W1/EnforcedDigitalVouchers/test/src/DigitalVouchersTests.Codeunit.al
index ed3495fccb..a3d1f90f3e 100644
--- a/Apps/W1/EnforcedDigitalVouchers/test/src/DigitalVouchersTests.Codeunit.al
+++ b/Apps/W1/EnforcedDigitalVouchers/test/src/DigitalVouchersTests.Codeunit.al
@@ -8,15 +8,22 @@ codeunit 139515 "Digital Vouchers Tests"
LibraryTestInitialize: Codeunit "Library - Test Initialize";
LibraryPurchase: Codeunit "Library - Purchase";
LibraryERM: Codeunit "Library - ERM";
+ LibraryJournals: Codeunit "Library - Journals";
LibraryUtility: Codeunit "Library - Utility";
LibraryVariableStorage: Codeunit "Library - Variable Storage";
+ LibraryInventory: Codeunit "Library - Inventory";
+ LibrarySales: Codeunit "Library - Sales";
+ LibraryRandom: Codeunit "Library - Random";
Assert: Codeunit Assert;
+ LibraryWorkflow: Codeunit "Library - Workflow";
+ ActiveDirectoryMockEvents: Codeunit "Active Directory Mock Events";
IsInitialized: Boolean;
NotPossibleToPostWithoutVoucherErr: Label 'Not possible to post without attaching the digital voucher.';
DialogErrorCodeTok: Label 'Dialog', Locked = true;
CannotRemoveReferenceRecordFromIncDocErr: Label 'Cannot remove the reference record from the incoming document because it is used for the enforced digital voucher functionality';
DetachQst: Label 'Do you want to remove the reference from this incoming document to posted document';
RemovePostedRecordManuallyMsg: Label 'The reference to the posted record has been removed.\\Remember to correct the posted record if needed.';
+ DoYouWantToPostQst: Label 'Do you want to post the journal lines?';
trigger OnRun()
begin
@@ -242,6 +249,185 @@ codeunit 139515 "Digital Vouchers Tests"
Assert.ExpectedError(CannotRemoveReferenceRecordFromIncDocErr);
end;
+ [Test]
+ [HandlerFunctions('ConfirmHandler,ErrorMessagePageHandler')]
+ procedure PostGeneralJournalLineWithRequiredAttachmentAndNoDigitalVoucher()
+ var
+ GenJournalLine: Record "Gen. Journal Line";
+ DigVouchersDisableEnforce: Codeunit "Dig. Vouchers Disable Enforce";
+ BatchProcessingMgt: Codeunit "Batch Processing Mgt.";
+ begin
+ // [SCENARIO 537136] Stan cannot post a general journal line with required attachment and no digital voucher
+
+ Initialize();
+ BindSubscription(DigVouchersDisableEnforce);
+ // [GIVEN] Digital voucher entry setup for general journal is "Attachment"
+ InitSetupCheckOnly("Digital Voucher Entry Type"::"General Journal", "Digital Voucher Check Type"::Attachment);
+ // [GIVEN] General journal line is created
+ LibraryJournals.CreateGenJournalLineWithBatch(
+ GenJournalLine, GenJournalLine."Document Type"::" ", GenJournalLine."Account Type"::"G/L Account",
+ LibraryERm.CreateGLAccountNo(), LibraryRandom.RandDec(100, 2));
+ LibraryVariableStorage.Enqueue(DoYouWantToPostQst);
+ LibraryVariableStorage.Enqueue(true);
+ LibraryVariableStorage.Enqueue(NotPossibleToPostWithoutVoucherErr);
+ // [WHEN] Post general journal
+ asserterror BatchProcessingMgt.BatchProcessGenJournalLine(GenJournalLine, Codeunit::"Gen. Jnl.-Post");
+
+ // [THEN] Error "Not possible to post without the voucher" is shown in the error message page
+ // Verified in the ErrorMessagePageHandler
+
+ LibraryVariableStorage.AssertEmpty();
+ UnbindSubscription(DigVouchersDisableEnforce);
+ end;
+
+ [Test]
+ [HandlerFunctions('ConfirmHandler,ErrorMessagePageHandler')]
+ procedure PostSalesJournalLineWithRequiredAttachmentAndNoDigitalVoucher()
+ var
+ GenJournalLine: Record "Gen. Journal Line";
+ DigVouchersDisableEnforce: Codeunit "Dig. Vouchers Disable Enforce";
+ BatchProcessingMgt: Codeunit "Batch Processing Mgt.";
+ begin
+ // [SCENARIO 537136] Stan cannot post a sales journal line with required attachment and no digital voucher
+
+ Initialize();
+ BindSubscription(DigVouchersDisableEnforce);
+ // [GIVEN] Digital voucher entry setup for sales journal is "Attachment"
+ InitSetupCheckOnly("Digital Voucher Entry Type"::"Sales Journal", "Digital Voucher Check Type"::Attachment);
+ // [GIVEN] Sales journal line is created
+ LibraryJournals.CreateGenJournalLineWithBatch(
+ GenJournalLine, GenJournalLine."Document Type"::Invoice, GenJournalLine."Account Type"::Customer,
+ LibrarySales.CreateCustomerNo(), LibraryRandom.RandDec(100, 2));
+ LibraryVariableStorage.Enqueue(DoYouWantToPostQst);
+ LibraryVariableStorage.Enqueue(true);
+ LibraryVariableStorage.Enqueue(NotPossibleToPostWithoutVoucherErr);
+ // [WHEN] Post sales journal
+ asserterror BatchProcessingMgt.BatchProcessGenJournalLine(GenJournalLine, Codeunit::"Gen. Jnl.-Post");
+
+ // [THEN] Error "Not possible to post without the voucher" is shown in the error message page
+ // Verified in the ErrorMessagePageHandler
+
+ LibraryVariableStorage.AssertEmpty();
+ UnbindSubscription(DigVouchersDisableEnforce);
+ end;
+
+ [Test]
+ [HandlerFunctions('ConfirmHandler,ErrorMessagePageHandler')]
+ procedure PostPurchaseJournalLineWithRequiredAttachmentAndNoDigitalVoucher()
+ var
+ GenJournalLine: Record "Gen. Journal Line";
+ DigVouchersDisableEnforce: Codeunit "Dig. Vouchers Disable Enforce";
+ BatchProcessingMgt: Codeunit "Batch Processing Mgt.";
+ begin
+ // [SCENARIO 537136] Stan cannot post a purchase journal line with required attachment and no digital voucher
+
+ Initialize();
+ BindSubscription(DigVouchersDisableEnforce);
+ // [GIVEN] Digital voucher entry setup for purchase journal is "Attachment"
+ InitSetupCheckOnly("Digital Voucher Entry Type"::"Purchase Journal", "Digital Voucher Check Type"::Attachment);
+ // [GIVEN] Purchase journal line is created
+ LibraryJournals.CreateGenJournalLineWithBatch(
+ GenJournalLine, GenJournalLine."Document Type"::Invoice, GenJournalLine."Account Type"::Vendor,
+ LibraryPurchase.CreateVendorNo(), LibraryRandom.RandDec(100, 2));
+ LibraryVariableStorage.Enqueue(DoYouWantToPostQst);
+ LibraryVariableStorage.Enqueue(true);
+ LibraryVariableStorage.Enqueue(NotPossibleToPostWithoutVoucherErr);
+ // [WHEN] Post purchase journal
+ asserterror BatchProcessingMgt.BatchProcessGenJournalLine(GenJournalLine, Codeunit::"Gen. Jnl.-Post");
+
+ // [THEN] Error "Not possible to post without the voucher" is shown in the error message page
+ // Verified in the ErrorMessagePageHandler
+
+ LibraryVariableStorage.AssertEmpty();
+ UnbindSubscription(DigVouchersDisableEnforce);
+ end;
+
+ [Test]
+ [HandlerFunctions('StrMenuHandler,VerifyNoAttachmentsInEmailEditorModalPageHandler')]
+ procedure PostSalesDocAndSendEmailWithDigitalVoucherAutomaticallyGenerated()
+ var
+ SalesHeader: Record "Sales Header";
+ SalesLine: Record "Sales Line";
+ DigVouchersDisableEnforce: Codeunit "Dig. Vouchers Disable Enforce";
+ begin
+ // [SCENARIO 537262] The automatically generated digital voucher is not suggested as an attachment during emailing
+
+ BindSubscription(DigVouchersDisableEnforce);
+ // [GIVEN] Email account is set up
+ LibraryWorkflow.SetUpEmailAccount();
+ BindActiveDirectoryMockEvents();
+ // [GIVEN] Sales shipment report selections without attachment
+ PrepareSalesShipmentReportSelectionsForEmailBodyWithoutAttachment();
+ // [GIVEN] Digital voucher feature is enabled
+ EnableDigitalVoucherFeature();
+ // [GIVEN] Digital voucher entry setup for sales document is "Attachment" and "Generate Automatically" option is enabled
+ InitSetupGenerateAutomatically("Digital Voucher Entry Type"::"Sales Document", "Digital Voucher Check Type"::Attachment);
+
+ // [GIVEN] Sales Order
+ LibrarySales.CreateSalesHeader(SalesHeader, SalesHeader."Document Type"::Order, '');
+ LibrarySales.CreateSalesLineWithUnitPrice(
+ SalesLine, SalesHeader, LibraryInventory.CreateItemNo(),
+ LibraryRandom.RandDec(100, 2), LibraryRandom.RandInt(100));
+
+ // [GIVEN] Custom report selection for the customer for email body
+ CreateCustomReportSelectionForCustomer(SalesHeader."Sell-to Customer No.", "Report Selection Usage"::"S.Shipment", Report::"Sales - Shipment");
+
+ LibraryVariableStorage.Enqueue(1); // option for posting only shipment
+ LibraryVariableStorage.Enqueue(3); // option for emailing to discard and not send any email
+ // [WHEN] Post sales order and send email
+ LibrarySales.PostSalesDocumentAndEmail(SalesHeader, true, true);
+
+ // [THEN] No attachments are suggested in the E-mail editor
+ // Verified in the VerifyNoAttachmentsInEmailEditorModalPageHandler
+
+ UnbindSubscription(DigVouchersDisableEnforce);
+ end;
+
+ [Test]
+ procedure PostMultipleGeneralJournalLinesWithGenerateAutomaticallyOption()
+ var
+ GenJournalLine: array[2] of Record "Gen. Journal Line";
+ GenJournalLineToPost: Record "Gen. Journal Line";
+ GenJournalTemplate: Record "Gen. Journal Template";
+ GenJournalBatch: Record "Gen. Journal Batch";
+ IncomingDocument: Record "Incoming Document";
+ DigVouchersEnableEnforce: Codeunit "Dig. Vouchers Enable Enforce";
+ i: Integer;
+ begin
+ // [SCENARIO 537486] Stan can post multiple general journals lines with different documents and digital voucher set to by automatically generated
+
+ Initialize();
+ BindSubscription(DigVouchersEnableEnforce);
+ // [GIVEN] Digital voucher entry setup for general journal is "Attachment" and "Generate Automatically" option is enabled
+ InitSetupGenerateAutomatically("Digital Voucher Entry Type"::"General Journal", "Digital Voucher Check Type"::Attachment);
+ // [GIVEN] General journal lines with the same template and batch are created
+ // [GIVEN] General journal line "X" with "Posting Date" = 01.01.2024 and "Document No." = "X"
+ // [GIVEN] General journal line "Y" with "Posting Date" = 01.01.2024 and "Document No." = "Y"
+ LibraryERM.CreateGenJournalTemplate(GenJournalTemplate);
+ GenJournalTemplate.Validate("Force Doc. Balance", false);
+ GenJournalTemplate.Modify(true);
+ LibraryERM.CreateGenJournalBatch(GenJournalBatch, GenJournalTemplate.Name);
+ for i := 1 to ArrayLen(GenJournalLine) do
+ LibraryJournals.CreateGenJournalLine(
+ GenJournalLine[i], GenJournalTemplate.Name, GenJournalBatch.Name,
+ GenJournalLine[i]."Document Type"::" ", GenJournalLine[i]."Account Type"::"G/L Account",
+ LibraryERM.CreateGLAccountNo(), GenJournalLine[i]."Bal. Account Type"::"G/L Account",
+ LibraryERM.CreateGLAccountNo(), LibraryRandom.RandDec(100, 2));
+ GenJournalLineToPost.SetRange("Journal Template Name", GenJournalTemplate.Name);
+ GenJournalLineToPost.SetRange("Journal Batch Name", GenJournalBatch.Name);
+ GenJournalLineToPost.FindSet();
+ // [WHEN] Post both general journal lines
+ Codeunit.Run(Codeunit::"Gen. Jnl.-Post Batch", GenJournalLineToPost);
+
+ // [THEN] Two digital vouchers generated for each combination of "Document No." and "Posting Date"
+ for i := 1 to ArrayLen(GenJournalLine) do
+ Assert.IsTrue(
+ IncomingDocument.FindByDocumentNoAndPostingDate(
+ IncomingDocument, GenJournalLine[i]."Document No.", Format(GenJournalLine[i]."Posting Date")),
+ 'Digital voucher has not been generated');
+ UnbindSubscription(DigVouchersEnableEnforce);
+ end;
+
local procedure Initialize()
begin
LibraryTestInitialize.OnTestInitialize(Codeunit::"Digital Vouchers Tests");
@@ -364,6 +550,41 @@ codeunit 139515 "Digital Vouchers Tests"
LibraryERM.FindVendorLedgerEntry(VendorLedgerEntry, VendorLedgerEntry."Document Type"::Invoice, DocNo);
end;
+ local procedure PrepareSalesShipmentReportSelectionsForEmailBodyWithoutAttachment()
+ var
+ ReportSelections: Record "Report Selections";
+ begin
+ ReportSelections.SetRange(Usage, ReportSelections.Usage::"S.Shipment");
+ ReportSelections.ModifyAll("Use for Email Body", false);
+ ReportSelections.ModifyAll("Use for Email Attachment", false);
+ end;
+
+ local procedure CreateCustomReportSelectionForCustomer(CustomerNo: Code[20]; ReportSelectionUsage: Enum "Report Selection Usage"; ReportID: Integer)
+ var
+ CustomReportSelection: Record "Custom Report Selection";
+ CustomReportLayout: Record "Custom Report Layout";
+ begin
+ CustomReportSelection.Init();
+ CustomReportSelection.Validate("Source Type", Database::Customer);
+ CustomReportSelection.Validate("Source No.", CustomerNo);
+ CustomReportSelection.Validate(Usage, ReportSelectionUsage);
+ CustomReportSelection.Validate(Sequence, 1);
+ CustomReportSelection.Validate("Report ID", ReportID);
+ CustomReportSelection.Validate("Use for Email Body", true);
+ CustomReportSelection.Validate("Use for Email Attachment", false);
+ CustomReportSelection.Validate(
+ "Email Body Layout Code", CustomReportLayout.InitBuiltInLayout(CustomReportSelection."Report ID", CustomReportLayout.Type::Word.AsInteger()));
+ CustomReportSelection.Insert(true);
+ end;
+
+ local procedure BindActiveDirectoryMockEvents()
+ begin
+ if ActiveDirectoryMockEvents.Enabled() then
+ exit;
+ BindSubscription(ActiveDirectoryMockEvents);
+ ActiveDirectoryMockEvents.Enable();
+ end;
+
local procedure VerifyIncomingDocumentWithAttachmentsExists(PostingDate: Date; DocNo: Code[20]; AttachmentsCount: Integer)
var
IncomingDocument: Record "Incoming Document";
@@ -389,4 +610,24 @@ codeunit 139515 "Digital Vouchers Tests"
begin
Assert.ExpectedMessage(LibraryVariableStorage.DequeueText(), Message);
end;
+
+ [PageHandler]
+ procedure ErrorMessagePageHandler(var ErrorMessagesPage: TestPage "Error Messages")
+ begin
+ Assert.AreEqual(LibraryVariableStorage.DequeueText(), ErrorMessagesPage.Description, 'Error message description is not correct');
+ end;
+
+ [StrMenuHandler]
+ [Scope('OnPrem')]
+ procedure StrMenuHandler(Options: Text[1024]; var Choice: Integer; Instruction: Text[1024])
+ begin
+ Choice := LibraryVariableStorage.DequeueInteger();
+ end;
+
+ [ModalPageHandler]
+ [Scope('OnPrem')]
+ procedure VerifyNoAttachmentsInEmailEditorModalPageHandler(var TestEmailEditor: TestPage "Email Editor")
+ begin
+ TestEmailEditor.Attachments.FileName.AssertEquals('');
+ end;
}
\ No newline at end of file
diff --git a/Apps/W1/ExcelReports/app/ReportLayouts/Excel/FixedAsset/FixedAssetAnalysisExcel.xlsx b/Apps/W1/ExcelReports/app/ReportLayouts/Excel/FixedAsset/FixedAssetAnalysisExcel.xlsx
new file mode 100644
index 0000000000..9ea27a44d0
Binary files /dev/null and b/Apps/W1/ExcelReports/app/ReportLayouts/Excel/FixedAsset/FixedAssetAnalysisExcel.xlsx differ
diff --git a/Apps/W1/ExcelReports/app/ReportLayouts/Excel/FixedAsset/FixedAssetDetailsExcel.xlsx b/Apps/W1/ExcelReports/app/ReportLayouts/Excel/FixedAsset/FixedAssetDetailsExcel.xlsx
index 17594016fc..337b682577 100644
Binary files a/Apps/W1/ExcelReports/app/ReportLayouts/Excel/FixedAsset/FixedAssetDetailsExcel.xlsx and b/Apps/W1/ExcelReports/app/ReportLayouts/Excel/FixedAsset/FixedAssetDetailsExcel.xlsx differ
diff --git a/Apps/W1/ExcelReports/app/ReportLayouts/Excel/FixedAsset/FixedAssetProjectedValueExcel.xlsx b/Apps/W1/ExcelReports/app/ReportLayouts/Excel/FixedAsset/FixedAssetProjectedValueExcel.xlsx
new file mode 100644
index 0000000000..3088883453
Binary files /dev/null and b/Apps/W1/ExcelReports/app/ReportLayouts/Excel/FixedAsset/FixedAssetProjectedValueExcel.xlsx differ
diff --git a/Apps/W1/ExcelReports/app/ReportLayouts/Excel/GeneralLedger/ConsolidatedTrialBalanceExcel.xlsx b/Apps/W1/ExcelReports/app/ReportLayouts/Excel/GeneralLedger/ConsolidatedTrialBalanceExcel.xlsx
index 5832cc4c94..06f02c1c86 100644
Binary files a/Apps/W1/ExcelReports/app/ReportLayouts/Excel/GeneralLedger/ConsolidatedTrialBalanceExcel.xlsx and b/Apps/W1/ExcelReports/app/ReportLayouts/Excel/GeneralLedger/ConsolidatedTrialBalanceExcel.xlsx differ
diff --git a/Apps/W1/ExcelReports/app/src/Financials/EXRFixedAssetAnalysisExcel.Report.al b/Apps/W1/ExcelReports/app/src/Financials/EXRFixedAssetAnalysisExcel.Report.al
new file mode 100644
index 0000000000..d741914eb9
--- /dev/null
+++ b/Apps/W1/ExcelReports/app/src/Financials/EXRFixedAssetAnalysisExcel.Report.al
@@ -0,0 +1,222 @@
+namespace Microsoft.Finance.ExcelReports;
+
+using Microsoft.FixedAssets.FixedAsset;
+using Microsoft.FixedAssets.Depreciation;
+using Microsoft.FixedAssets.Posting;
+
+report 4412 "EXR Fixed Asset Analysis Excel"
+{
+ ApplicationArea = All;
+ Caption = 'Fixed Asset Analysis Excel (Preview)';
+ DataAccessIntent = ReadOnly;
+ DefaultRenderingLayout = FixedAssetAnalysisExcel;
+ ExcelLayoutMultipleDataSheets = true;
+ PreviewMode = PrintLayout;
+ UsageCategory = ReportsAndAnalysis;
+ MaximumDatasetSize = 1000000;
+ dataset
+ {
+ dataitem(FixedAssetData; "Fixed Asset")
+ {
+ DataItemTableView = sorting("No.");
+ PrintOnlyIfDetail = true;
+ column(AssetNumber; "No.") { IncludeCaption = true; }
+ column(AssetDescription; Description) { IncludeCaption = true; }
+ column(FixedAssetClassCode; "FA Class Code") { IncludeCaption = true; }
+ column(FixedAssetSubclassCode; "FA Subclass Code") { IncludeCaption = true; }
+ column(FixedAssetLocationCode; "FA Location Code") { IncludeCaption = true; }
+ column(BudgetedAsset; "Budgeted Asset") { IncludeCaption = true; }
+ column(AcquisitionDateField; AcquisitionDate) { }
+ column(DisposalDateField; DisposalDate) { }
+ dataitem(FAPostingType; "FA Posting Type")
+ {
+ DataItemTableView = where("FA Entry" = const(true));
+ column(FixedAssetPostingTypeNumber; "FA Posting Type No.") { IncludeCaption = true; }
+ column(FixedAssetPostingTypeName; "FA Posting Type Name") { IncludeCaption = true; }
+ column(BeforeStartingDate; BeforeStartingDate) { }
+ column(AtEndingDate; AtEndingDate) { }
+ column(NetChange; NetChange) { }
+ trigger OnAfterGetRecord()
+ var
+ FADepreciationBook: Record "FA Depreciation Book";
+ FAGeneralReport: Codeunit "FA General Report";
+ BudgetDepreciation: Codeunit "Budget Depreciation";
+ BeforeAmount, EndingAmount : Decimal;
+ begin
+ if ShouldSkipRecord() then
+ CurrReport.Skip();
+ FADepreciationBook.Get(FixedAssetData."No.", DepreciationBookCode);
+ AcquisitionDate := FADepreciationBook."Acquisition Date";
+ DisposalDate := FADepreciationBook."Disposal Date";
+ if BudgetReport then
+ BudgetDepreciation.Calculate(FixedAssetData."No.", StartingDate - 1, EndingDate, DepreciationBookCode, BeforeAmount, EndingAmount);
+
+ Period := Period::"Before Starting Date";
+ BeforeStartingDate := GetFixedAssetPostedAmount(BeforeAmount, EndingAmount);
+ BeforeStartingDate := FAGeneralReport.CalcFAPostedAmount(FixedAssetData."No.", FAPostingType."FA Posting Type No.", Period, StartingDate, EndingDate, DepreciationBookCode, BeforeAmount, EndingAmount, false, false);
+ Period := Period::"At Ending Date";
+ AtEndingDate := FAGeneralReport.CalcFAPostedAmount(FixedAssetData."No.", FAPostingType."FA Posting Type No.", Period, StartingDate, EndingDate, DepreciationBookCode, BeforeAmount, EndingAmount, false, false);
+ Period := Period::"Net Change";
+ NetChange := FAGeneralReport.CalcFAPostedAmount(FixedAssetData."No.", FAPostingType."FA Posting Type No.", Period, StartingDate, EndingDate, DepreciationBookCode, BeforeAmount, EndingAmount, false, false);
+ end;
+ }
+ }
+ }
+ requestpage
+ {
+ SaveValues = true;
+ AboutTitle = 'Fixed Asset Analysis Excel';
+ AboutText = 'This report shows different fixed asset details in the given time periods, such as book value, depreciation, and acquisitions. You can specify the starting and ending dates for the report, and whether you want to include only sold assets or include inactive fixed assets.';
+ layout
+ {
+ area(Content)
+ {
+ group(Options)
+ {
+ Caption = 'Options';
+ field(DepreciationBookCodeField; DepreciationBookCode)
+ {
+ ApplicationArea = All;
+ Caption = 'Depreciation Book';
+ TableRelation = "Depreciation Book";
+ ToolTip = 'Specifies the code for the depreciation book to be included in the report or batch job.';
+ ShowMandatory = true;
+ }
+ field(StartingDateField; StartingDate)
+ {
+ ApplicationArea = FixedAssets;
+ Caption = 'Starting Date';
+ ToolTip = 'Specifies the date when you want the report to start.';
+ ShowMandatory = true;
+ }
+ field(EndingDateField; EndingDate)
+ {
+ ApplicationArea = FixedAssets;
+ Caption = 'Ending Date';
+ ToolTip = 'Specifies the date when you want the report to end.';
+ ShowMandatory = true;
+ }
+ field(SalesReportField; SalesReport)
+ {
+ ApplicationArea = FixedAssets;
+ Caption = 'Only Sold Assets';
+ ToolTip = 'Specifies if you want the report to show information only for sold fixed assets.';
+ }
+ field(BudgetReportField; BudgetReport)
+ {
+ ApplicationArea = Suite;
+ Caption = 'Budget Report';
+ ToolTip = 'Specifies if you want the report to consider future depreciation and book value.';
+ }
+ field(IncludeInactiveField; IncludeInactive)
+ {
+ ApplicationArea = All;
+ Caption = 'Include Inactive Fixed Assets';
+ ToolTip = 'Specifies if you want to include inactive fixed assets in the report.';
+ }
+ }
+ }
+ }
+ trigger OnOpenPage()
+ var
+ DepreciationBook: Record "Depreciation Book";
+ begin
+ EndingDate := WorkDate();
+ StartingDate := CalcDate('<-1M>', EndingDate);
+ if DepreciationBook.FindFirst() then
+ DepreciationBookCode := DepreciationBook.Code;
+ end;
+ }
+ rendering
+ {
+ layout(FixedAssetAnalysisExcel)
+ {
+ Type = Excel;
+ LayoutFile = './ReportLayouts/Excel/FixedAsset/FixedAssetAnalysisExcel.xlsx';
+ Caption = 'Fixed Asset Analysis Excel';
+ Summary = 'Built in layout for Fixed Asset Analysis.';
+ }
+ }
+ labels
+ {
+ DataRetrieved = 'Data retrieved:';
+ FixedAssetAnalysis = 'Fixed Asset Analysis';
+ BeforeStartingDateLabel = 'Before Starting Date';
+ AtEndingDateLabel = 'At Ending Date';
+ NetChangeLabel = 'Net Change';
+ DepreciationBook = 'Depreciation Book';
+ Period = 'Period:';
+ BookValue = 'Book Value';
+ AcquisitionDateLabel = 'Acquisition Date';
+ DisposalDateLabel = 'Disposal Date';
+ BookValueAnalysis = 'Book Value Analysis';
+ AcquisitionCostAfter = 'Acquisition Cost After';
+ AcquisitionCostBefore = 'Acquisition Cost Before';
+ AcquisitionCostNetChange = 'Addition in Period';
+ ProceedsOnDisposalNetChange = 'Disposal in Period';
+ DepreciationNetChange = 'Depreciation in Period';
+ DepreciationAfter = 'Depreciation After';
+ DepreciationBefore = 'Depreciation Before';
+ BookValueAfter = 'Book Value After';
+ BookValueBefore = 'Book Value Before';
+ }
+
+ trigger OnPreReport()
+ var
+ DepreciationBook: Record "Depreciation Book";
+ begin
+ DepreciationBook.Get(DepreciationBookCode);
+ if (StartingDate = 0D) or (EndingDate = 0D) then
+ Error(SpecifyStartingAndEndingDatesErr);
+ if StartingDate > EndingDate then
+ Error(SpecifyStartingAndEndingDatesErr);
+ end;
+
+ var
+ DepreciationBookCode: Code[10];
+ StartingDate, EndingDate, AcquisitionDate, DisposalDate : Date;
+ BeforeStartingDate, AtEndingDate, NetChange : Decimal;
+ Period: Option "Before Starting Date","Net Change","At Ending Date";
+ SalesReport, BudgetReport, IncludeInactive : Boolean;
+ SpecifyStartingAndEndingDatesErr: Label 'Please specify valid starting and ending dates.';
+
+ local procedure ShouldSkipRecord(): Boolean
+ var
+ FADepreciationBook: Record "FA Depreciation Book";
+ begin
+ if not FADepreciationBook.Get(FixedAssetData."No.", DepreciationBookCode) then
+ exit(true);
+ if FixedAssetData.Inactive and (not IncludeInactive) then
+ exit(true);
+ if FADepreciationBook."Acquisition Date" = 0D then
+ exit(true);
+ if FADepreciationBook."Acquisition Date" > EndingDate then
+ exit(true);
+ if SalesReport and ((FADepreciationBook."Disposal Date" > EndingDate) or (FADepreciationBook."Disposal Date" < StartingDate)) then
+ exit(true);
+ if (not SalesReport) and (FADepreciationBook."Disposal Date" > 0D) and (FADepreciationBook."Disposal Date" < StartingDate) then
+ exit(true);
+ exit(false);
+ end;
+
+ local procedure GetFixedAssetPostedAmount(BeforeAmount: Decimal; EndingAmount: Decimal): Decimal
+ var
+ FADepreciationBook: Record "FA Depreciation Book";
+ FAGeneralReport: Codeunit "FA General Report";
+ begin
+ if FAPostingType."FA Posting Type No." = FADepreciationBook.FieldNo("Proceeds on Disposal") then
+ exit(0);
+ FADepreciationBook.Get(FixedAssetData."No.", DepreciationBookCode);
+ if not SalesReport and (Period = Period::"at Ending Date") and SoldBeforeEndingDate(FADepreciationBook."Disposal Date") then
+ exit(0);
+ exit(FAGeneralReport.CalcFAPostedAmount(FixedAssetData."No.", FAPostingType."FA Posting Type No.", Period, StartingDate, EndingDate, DepreciationBookCode, BeforeAmount, EndingAmount, false, false));
+ end;
+
+ local procedure SoldBeforeEndingDate(DisposalDate: Date): Boolean
+ begin
+ if DisposalDate = 0D then
+ exit(false);
+ exit(DisposalDate <= EndingDate);
+ end;
+
+}
\ No newline at end of file
diff --git a/Apps/W1/ExcelReports/app/src/Financials/EXRFixedAssetDetailsExcel.Report.al b/Apps/W1/ExcelReports/app/src/Financials/EXRFixedAssetDetailsExcel.Report.al
index c5d06e1e08..71906ed7d8 100644
--- a/Apps/W1/ExcelReports/app/src/Financials/EXRFixedAssetDetailsExcel.Report.al
+++ b/Apps/W1/ExcelReports/app/src/Financials/EXRFixedAssetDetailsExcel.Report.al
@@ -26,6 +26,7 @@ report 4411 "EXR Fixed Asset Details Excel"
column(AssetDescription; Description) { IncludeCaption = true; }
column(FixedAssetClassCode; "FA Class Code") { IncludeCaption = true; }
column(FixedAssetSubclassCode; "FA Subclass Code") { IncludeCaption = true; }
+ column(FixedAssetLocation; "FA Location Code") { IncludeCaption = true; }
column(BudgetedAsset; "Budgeted Asset") { IncludeCaption = true; }
dataitem(FixedAssetLedgerEntry; "FA Ledger Entry")
{
diff --git a/Apps/W1/ExcelReports/app/src/Financials/EXRFixedAssetProjected.Report.al b/Apps/W1/ExcelReports/app/src/Financials/EXRFixedAssetProjected.Report.al
new file mode 100644
index 0000000000..4d156fec0a
--- /dev/null
+++ b/Apps/W1/ExcelReports/app/src/Financials/EXRFixedAssetProjected.Report.al
@@ -0,0 +1,282 @@
+namespace Microsoft.Finance.ExcelReports;
+
+using Microsoft.FixedAssets.FixedAsset;
+using Microsoft.FixedAssets.Depreciation;
+using Microsoft.Foundation.Period;
+using Microsoft.FixedAssets.Ledger;
+
+report 4413 "EXR Fixed Asset Projected"
+{
+ ApplicationArea = All;
+ Caption = 'Fixed Asset Projected Value Excel (Preview)';
+ DataAccessIntent = ReadOnly;
+ DefaultRenderingLayout = FixedAssetProjectedValueExcel;
+ ExcelLayoutMultipleDataSheets = true;
+ PreviewMode = PrintLayout;
+ UsageCategory = ReportsAndAnalysis;
+ MaximumDatasetSize = 1000000;
+ dataset
+ {
+ dataitem(FixedAssetData; "Fixed Asset")
+ {
+ DataItemTableView = sorting("No.");
+ PrintOnlyIfDetail = true;
+ column(AssetNumber; "No.") { IncludeCaption = true; }
+ column(AssetDescription; Description) { IncludeCaption = true; }
+ column(FixedAssetClassCode; "FA Class Code") { IncludeCaption = true; }
+ column(FixedAssetSubclassCode; "FA Subclass Code") { IncludeCaption = true; }
+ column(FixedAssetLocationCode; "FA Location Code") { IncludeCaption = true; }
+ dataitem(FixedAssetLedgerEntries; "FA Ledger Entry")
+ {
+ DataItemLink = "FA No." = field("No.");
+ UseTemporary = true;
+ column(FixedAssetPostingDate; "FA Posting Date") { IncludeCaption = true; }
+ column(FixedAssetPostingType; "FA Posting Type") { IncludeCaption = true; }
+ column(Amount; Amount) { IncludeCaption = true; }
+ column(BookValue; BookValue) { }
+ column(ProjectedEntry; ProjectedEntry) { }
+ column(NumberOfDepreciationDays; "No. of Depreciation Days") { IncludeCaption = true; }
+
+ trigger OnAfterGetRecord()
+ var
+ FADepreciationBook: Record "FA Depreciation Book";
+ begin
+ ProjectedEntry := FixedAssetLedgerEntries."Reason Code" = ProjectionTok;
+
+ if FirstFixedAssetLedgerEntry then begin
+ FADepreciationBook.SetFilter("FA Posting Date Filter", '<%1', FixedAssetLedgerEntries."FA Posting Date");
+ FADepreciationBook.SetAutoCalcFields("Book Value");
+ FADepreciationBook.Get(FixedAssetData."No.", SelectedDepreciationBookCode);
+ BookValue := FADepreciationBook."Book Value";
+ end;
+ FirstFixedAssetLedgerEntry := false;
+ BookValue += FixedAssetLedgerEntries.Amount;
+ end;
+ }
+ trigger OnAfterGetRecord()
+ begin
+ if FixedAssetData.Inactive or FixedAssetData.Blocked then
+ CurrReport.Skip();
+ InsertPostedAndProjectedEntries(FixedAssetData."No.", FixedAssetLedgerEntries);
+ FirstFixedAssetLedgerEntry := true;
+ end;
+ }
+ }
+ requestpage
+ {
+ SaveValues = true;
+ AboutTitle = 'Fixed Asset Projected Value Excel';
+ AboutText = 'This report shows how Fixed Asset Ledger entries would look if depreciated in the given dates.';
+ layout
+ {
+ area(Content)
+ {
+ group(Options)
+ {
+ Caption = 'Options';
+ field(DepreciationBookCodeField; SelectedDepreciationBookCode)
+ {
+ ApplicationArea = All;
+ Caption = 'Depreciation Book';
+ TableRelation = "Depreciation Book";
+ ToolTip = 'Specifies the code for the depreciation book to be included in the report or batch job.';
+ ShowMandatory = true;
+ }
+ field(FirstDepreciationDateField; FirstDepreciationDate)
+ {
+ ApplicationArea = All;
+ Caption = 'First Depreciation Date';
+ ToolTip = 'Specifies the date to be used as the first date in the period for which you want to calculate projected depreciation.';
+ ShowMandatory = true;
+ }
+ field(SecondDepreciationDateField; SecondDepreciationDate)
+ {
+ ApplicationArea = All;
+ Caption = 'Second Depreciation Date';
+ ToolTip = 'Specifies the Fixed Asset posting date of the last posted depreciation.';
+ ShowMandatory = true;
+ }
+ field(PeriodLengthField; PeriodLength)
+ {
+ ApplicationArea = FixedAssets;
+ BlankZero = true;
+ Caption = 'Number of Days';
+ MinValue = 0;
+ ToolTip = 'Specifies the length of the periods between the first depreciation date and the last depreciation date. The program then calculates depreciation for each period. If you leave this field blank, the program automatically sets the contents of this field to equal the number of days in a fiscal year, normally 360.';
+
+ trigger OnValidate()
+ begin
+ if PeriodLength > 0 then
+ UseAccountingPeriod := false;
+ end;
+ }
+ field(DaysInFirstPeriodField; DaysInFirstPeriod)
+ {
+ ApplicationArea = All;
+ BlankZero = true;
+ Caption = 'No. of Days in First Period';
+ MinValue = 0;
+ ToolTip = 'Specifies the number of days that must be used for calculating the depreciation as of the first depreciation date, regardless of the actual number of days from the last depreciation entry. The number you enter in this field does not affect the total number of days from the starting date to the ending date.';
+ }
+ field(IncludePostedFromField; IncludePostedFrom)
+ {
+ ApplicationArea = All;
+ Caption = 'Posted Entries From';
+ ToolTip = 'Specifies the fixed asset posting date from which the report includes all types of posted entries.';
+ }
+ field(ProjectedDisposalField; ProjectedDisposal)
+ {
+ ApplicationArea = All;
+ Caption = 'Projected Disposal';
+ ToolTip = 'Specifies if you want the report to include projected disposals: the contents of the Projected Proceeds on Disposal field and the Projected Disposal Date field on the FA depreciation book.';
+ }
+ field(UseAccountingPeriodField; UseAccountingPeriod)
+ {
+ ApplicationArea = FixedAssets;
+ Caption = 'Use Accounting Period';
+ ToolTip = 'Specifies if you want the periods between the starting date and the ending date to correspond to the accounting periods you have specified in the Accounting Period table. When you select this field, the Number of Days field is cleared.';
+ }
+ }
+ }
+ }
+ }
+ rendering
+ {
+ layout(FixedAssetProjectedValueExcel)
+ {
+ Type = Excel;
+ LayoutFile = './ReportLayouts/Excel/FixedAsset/FixedAssetProjectedValueExcel.xlsx';
+ Caption = 'Fixed Asset Projected Value Excel';
+ Summary = 'Built in layout for Fixed Asset Projected Value.';
+ }
+ }
+ labels
+ {
+ DataRetrieved = 'Data retrieved:';
+ FixedAssetProjectedValue = 'Fixed Asset Projected Value';
+ ProjectedValue = 'Projected Value';
+ BookValueCaption = 'Book Value';
+ ProjectedEntryCaption = 'Projected entry';
+ }
+
+ local procedure InsertPostedAndProjectedEntries(FixedAssetNo: Code[20]; var TempFixedAssetLedgerEntry: Record "FA Ledger Entry" temporary)
+ var
+ TempProjectedDepreciationDates: Record "Accounting Period" temporary;
+ begin
+ TempFixedAssetLedgerEntry.DeleteAll();
+ InsertPostedEntries(FixedAssetNo, IncludePostedFrom, SelectedDepreciationBookCode, TempFixedAssetLedgerEntry);
+ TempProjectedDepreciationDates."Starting Date" := FirstDepreciationDate;
+ TempProjectedDepreciationDates.Insert();
+
+ if UseAccountingPeriod then
+ InsertDatesForAccountingPeriods(TempProjectedDepreciationDates, FirstDepreciationDate, SecondDepreciationDate);
+
+ TempProjectedDepreciationDates."Starting Date" := SecondDepreciationDate;
+ TempProjectedDepreciationDates.Insert();
+
+ InsertProjectedEntries(FixedAssetNo, SelectedDepreciationBookCode, TempProjectedDepreciationDates, TempFixedAssetLedgerEntry);
+ end;
+
+ local procedure InsertProjectedEntries(FixedAssetNo: Code[20]; DepreciationBookCode: Code[10]; var TempProjectedDepreciationDates: Record "Accounting Period" temporary; var TempFixedAssetLedgerEntry: Record "FA Ledger Entry" temporary)
+ var
+ DepreciationBook: Record "Depreciation Book";
+ FADepreciationBook: Record "FA Depreciation Book";
+ CalculateDepreciation: Codeunit "Calculate Depreciation";
+ DepreciationCalculation: Codeunit "Depreciation Calculation";
+ DateFromProjection: Date;
+ DepreciationAmount, Custom1Amount : Decimal;
+ NumberOfDays, Custom1NumberOfDays, DaysInPeriod : Integer;
+ EntryAmounts: array[4] of Decimal;
+ First: Boolean;
+ begin
+ if TempProjectedDepreciationDates.IsEmpty() then
+ exit;
+
+ FADepreciationBook.SetAutoCalcFields("Book Value", "Custom 1");
+ FADepreciationBook.Get(FixedAssetNo, DepreciationBookCode);
+ DepreciationBook.Get(DepreciationBookCode);
+ EntryAmounts[1] := FADepreciationBook."Book Value";
+ EntryAmounts[2] := FADepreciationBook."Custom 1";
+ EntryAmounts[3] := DepreciationCalculation.DeprInFiscalYear(FixedAssetNo, DepreciationBookCode, FirstDepreciationDate);
+ DateFromProjection := 0D;
+ First := true;
+ TempProjectedDepreciationDates.FindSet();
+ repeat
+ CalculateDepreciation.Calculate(DepreciationAmount, Custom1Amount, NumberOfDays, Custom1NumberOfDays, FixedAssetNo, DepreciationBookCode, TempProjectedDepreciationDates."Starting Date", EntryAmounts, DateFromProjection, DaysInPeriod);
+ DateFromProjection := DepreciationCalculation.ToMorrow(TempProjectedDepreciationDates."Starting Date", DepreciationBook."Fiscal Year 365 Days");
+ EntryAmounts[1] += DepreciationAmount + Custom1Amount;
+ EntryAmounts[2] += Custom1Amount;
+ EntryAmounts[3] += DepreciationAmount + Custom1Amount;
+ if First then begin
+ EntryAmounts[3] := DepreciationCalculation.DeprInFiscalYear(FixedAssetNo, DepreciationBookCode, TempProjectedDepreciationDates."Starting Date");
+ First := false;
+ end;
+ TempFixedAssetLedgerEntry."FA No." := FixedAssetNo;
+ TempFixedAssetLedgerEntry."FA Posting Date" := TempProjectedDepreciationDates."Starting Date";
+ TempFixedAssetLedgerEntry."FA Posting Type" := TempFixedAssetLedgerEntry."FA Posting Type"::Depreciation;
+ TempFixedAssetLedgerEntry.Amount := DepreciationAmount;
+ TempFixedAssetLedgerEntry."No. of Depreciation Days" := NumberOfDays;
+ TempFixedAssetLedgerEntry."Entry No." += 1;
+ TempFixedAssetLedgerEntry."Reason Code" := ProjectionTok;
+ TempFixedAssetLedgerEntry.Insert();
+ until TempProjectedDepreciationDates.Next() = 0;
+ end;
+
+ local procedure InsertDatesForAccountingPeriods(var TempProjectedDepreciationDates: Record "Accounting Period" temporary; FromDate: Date; ToDate: Date)
+ var
+ AccountingPeriod: Record "Accounting Period";
+ begin
+ AccountingPeriod.SetRange("Starting Date", FromDate + 2, ToDate);
+ if AccountingPeriod.IsEmpty() then
+ exit;
+ AccountingPeriod.FindSet();
+ repeat
+ TempProjectedDepreciationDates."Starting Date" := AccountingPeriod."Starting Date" - 1;
+ TempProjectedDepreciationDates.Insert();
+ until AccountingPeriod.Next() = 0;
+ end;
+
+ local procedure InsertPostedEntries(FixedAssetNo: Code[20]; MinFAPostingDate: Date; FixedAssetDepreciationBookCode: Code[10]; var TempFixedAssetLedgerEntry: Record "FA Ledger Entry" temporary)
+ var
+ FixedAssetLedgerEntry: Record "FA Ledger Entry";
+ begin
+ if MinFAPostingDate = 0D then
+ exit;
+ FixedAssetLedgerEntry.SetRange("FA No.", FixedAssetNo);
+ FixedAssetLedgerEntry.SetRange("Depreciation Book Code", FixedAssetDepreciationBookCode);
+ FixedAssetLedgerEntry.SetFilter("FA Posting Date", '>=%1', MinFAPostingDate);
+ if FixedAssetLedgerEntry.IsEmpty() then
+ exit;
+ FixedAssetLedgerEntry.FindSet();
+ repeat
+ TempFixedAssetLedgerEntry.Copy(FixedAssetLedgerEntry);
+ Clear(TempFixedAssetLedgerEntry."Reason Code");
+ TempFixedAssetLedgerEntry.Insert();
+ until FixedAssetLedgerEntry.Next() = 0;
+ end;
+
+ trigger OnPreReport()
+ var
+ DepreciationBook: Record "Depreciation Book";
+ begin
+ DepreciationBook.Get(SelectedDepreciationBookCode);
+ if (FirstDepreciationDate = 0D) or (SecondDepreciationDate = 0D) then
+ Error(SpecifyStartingAndEndingDatesErr);
+ if FirstDepreciationDate > SecondDepreciationDate then
+ Error(SpecifyStartingAndEndingDatesErr);
+ end;
+
+ var
+ ProjectionTok: Label 'PROJECTED', Locked = true;
+ SelectedDepreciationBookCode: Code[10];
+ FirstDepreciationDate, SecondDepreciationDate : Date;
+ BookValue: Decimal;
+ PeriodLength: Integer;
+ DaysInFirstPeriod: Integer;
+ IncludePostedFrom: Date;
+ ProjectedDisposal: Boolean;
+ UseAccountingPeriod: Boolean;
+ ProjectedEntry: Boolean;
+ FirstFixedAssetLedgerEntry: Boolean;
+ SpecifyStartingAndEndingDatesErr: Label 'Please specify valid starting and ending dates.';
+}
\ No newline at end of file
diff --git a/Apps/W1/HybridGP/app/src/Migration/Items/GPItemMigrator.codeunit.al b/Apps/W1/HybridGP/app/src/Migration/Items/GPItemMigrator.codeunit.al
index 5d7a1ab3d1..bfe9697d56 100644
--- a/Apps/W1/HybridGP/app/src/Migration/Items/GPItemMigrator.codeunit.al
+++ b/Apps/W1/HybridGP/app/src/Migration/Items/GPItemMigrator.codeunit.al
@@ -346,15 +346,20 @@ codeunit 4019 "GP Item Migrator"
TempTrackingSpecification: Record "Tracking Specification" temporary;
DataMigrationErrorLogging: Codeunit "Data Migration Error Logging";
CreateReserveEntry: Codeunit "Create Reserv. Entry";
+#if CLEAN25
+ ItemJnlLineReserve: Codeunit "Item Jnl. Line-Reserve";
+#endif
ExpirationDate: Date;
begin
if GPItem.ItemTrackingCode = '' then
exit;
DataMigrationErrorLogging.SetLastRecordUnderProcessing(Format(GPItemTransactions.RecordId));
-
+#if not CLEAN25
TempTrackingSpecification.InitFromItemJnlLine(ItemJnlLine);
-
+#else
+ ItemJnlLineReserve.InitFromItemJnlLine(TempTrackingSpecification, ItemJnlLine);
+#endif
if GPItemTransactions.ExpirationDate = DMY2Date(1, 1, 1900) then
ExpirationDate := 0D
else
diff --git a/Apps/W1/HybridGP/app/src/Migration/Support/HelperFunctions.codeunit.al b/Apps/W1/HybridGP/app/src/Migration/Support/HelperFunctions.codeunit.al
index a940b997dd..75c6c5baf3 100644
--- a/Apps/W1/HybridGP/app/src/Migration/Support/HelperFunctions.codeunit.al
+++ b/Apps/W1/HybridGP/app/src/Migration/Support/HelperFunctions.codeunit.al
@@ -1317,7 +1317,7 @@ codeunit 4037 "Helper Functions"
Session.LogMessage('00007GK', StrSubstNo(FinishedTelemetryTxt, DurationAsInt), Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', GetTelemetryCategory());
end;
- [Obsolete('This procedure will be soon removed.', '26.0')]
+ [Obsolete('This procedure will be soon removed.', '25.0')]
procedure PostGLBatch(JournalBatchName: Code[10])
var
GenJournalLine: Record "Gen. Journal Line";
@@ -1358,7 +1358,7 @@ codeunit 4037 "Helper Functions"
end;
end;
- [Obsolete('This procedure will be soon removed.', '26.0')]
+ [Obsolete('This procedure will be soon removed.', '25.0')]
procedure PostStatisticalAccBatch(JournalBatchName: Code[10])
var
StatisticalAccJournalLine: Record "Statistical Acc. Journal Line";
diff --git a/Apps/W1/HybridGP/test/app.json b/Apps/W1/HybridGP/test/app.json
index e9b11aa0e6..fcb1918782 100644
--- a/Apps/W1/HybridGP/test/app.json
+++ b/Apps/W1/HybridGP/test/app.json
@@ -40,7 +40,7 @@
"id": "ea130081-c669-460f-a5f4-5dde14f03131",
"name": "Statistical Accounts",
"publisher": "Microsoft",
- "version": "24.0.0.0"
+ "version": "25.0.0.0"
},
{
"id": "5d86850b-0d76-4eca-bd7b-951ad998e997",
diff --git a/Apps/W1/MasterDataManagement/app/src/codeunits/MasterDataMgtSubscribers.Codeunit.al b/Apps/W1/MasterDataManagement/app/src/codeunits/MasterDataMgtSubscribers.Codeunit.al
index 85737acf50..0d798acd05 100644
--- a/Apps/W1/MasterDataManagement/app/src/codeunits/MasterDataMgtSubscribers.Codeunit.al
+++ b/Apps/W1/MasterDataManagement/app/src/codeunits/MasterDataMgtSubscribers.Codeunit.al
@@ -104,6 +104,7 @@ codeunit 7237 "Master Data Mgt. Subscribers"
[EventSubscriber(ObjectType::Report, Report::"Copy Company", 'OnAfterCreatedNewCompanyByCopyCompany', '', false, false)]
local procedure CleanupSetupAfterCreatedNewCompanyByCopyCompany(NewCompanyName: Text[30])
var
+ MasterDataMgtSubscriber: Record "Master Data Mgt. Subscriber";
MasterDataMgtCoupling: Record "Master Data Mgt. Coupling";
MasterDataManagementSetup: Record "Master Data Management Setup";
begin
@@ -111,6 +112,8 @@ codeunit 7237 "Master Data Mgt. Subscribers"
MasterDataMgtCoupling.DeleteAll();
MasterDataManagementSetup.ChangeCompany(NewCompanyName);
MasterDataManagementSetup.DeleteAll();
+ MasterDataMgtSubscriber.ChangeCompany(NewCompanyName);
+ MasterDataMgtSubscriber.DeleteAll();
end;
internal procedure HandleOnFindingIfJobNeedsToBeRun(var Sender: Record "Job Queue Entry"; var Result: Boolean)
diff --git a/Apps/W1/QBMigration/test/src/MigrationQBOTests.Codeunit.al b/Apps/W1/QBMigration/test/src/MigrationQBOTests.Codeunit.al
index 6be63222d8..145db11533 100644
--- a/Apps/W1/QBMigration/test/src/MigrationQBOTests.Codeunit.al
+++ b/Apps/W1/QBMigration/test/src/MigrationQBOTests.Codeunit.al
@@ -195,7 +195,6 @@ codeunit 139530 "MigrationQBO Tests"
end;
[Test]
- [HandlerFunctions('ConfirmHandlerNo')]
procedure TestQBOCustomerImport()
var
Customer: Record "Customer";
@@ -792,13 +791,6 @@ codeunit 139530 "MigrationQBO Tests"
MigrationQBAccountSetup.PurchServiceChargeAccount := AccountNumber;
MigrationQBAccountSetup.Insert();
end;
-
- [ConfirmHandler]
- [Scope('OnPrem')]
- procedure ConfirmHandlerNo(Question: Text[1024]; var Reply: Boolean)
- begin
- Reply := false;
- end;
}
diff --git a/Apps/W1/SalesLinesSuggestions/app/SLSPrompts.Codeunit.al b/Apps/W1/SalesLinesSuggestions/app/SLSPrompts.Codeunit.al
index 1545b7f409..12c9dd81a4 100644
--- a/Apps/W1/SalesLinesSuggestions/app/SLSPrompts.Codeunit.al
+++ b/Apps/W1/SalesLinesSuggestions/app/SLSPrompts.Codeunit.al
@@ -46,6 +46,16 @@ codeunit 7276 "SLS Prompts"
exit(BCSLSDocumentLookupPrompt);
end;
+ [NonDebuggable]
+ internal procedure GetSLSSearchItemsWithFiltersPrompt(): Text
+ var
+ BCSLSSearchItemsWithFiltersPrompt: Text;
+ begin
+ GetAzureKeyVaultSecret(BCSLSSearchItemsWithFiltersPrompt, 'BCSLSSearchItemsWithFiltersPrompt');
+
+ exit(BCSLSSearchItemsWithFiltersPrompt);
+ end;
+
[NonDebuggable]
internal procedure GetSLSSearchItemPrompt(): Text
var
@@ -69,5 +79,4 @@ codeunit 7276 "SLS Prompts"
var
ConstructingPromptFailedErr: label 'There was an error with sending the call to Copilot. Log a Business Central support request about this.', Comment = 'Copilot is a Microsoft service name and must not be translated';
TelemetryConstructingPromptFailedErr: label 'There was an error with constructing the chat completion prompt from the Key Vault.', Locked = true;
-
}
\ No newline at end of file
diff --git a/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/DocumentLookupImpl/BlanketSalesOrderLookup.Codeunit.al b/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/DocumentLookupImpl/BlanketSalesOrderLookup.Codeunit.al
new file mode 100644
index 0000000000..bcaab100dd
--- /dev/null
+++ b/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/DocumentLookupImpl/BlanketSalesOrderLookup.Codeunit.al
@@ -0,0 +1,174 @@
+// ------------------------------------------------------------------------------------------------
+// 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.Document;
+
+using Microsoft.Inventory.Item;
+
+codeunit 7281 BlanketSalesOrderLookup implements DocumentLookupSubType
+{
+ Access = Internal;
+
+ var
+ NoDocumentFound1Err: Label 'Copilot could not find the requested Blanket Sales Order for %1. Please rephrase the description and try again.', Comment = '%1 = Customer Name';
+ NoDocumentFound2Err: Label 'Copilot could not find the requested Blanket Sales Order %1. Please rephrase the description and try again.', Comment = '%1 = Document No.';
+ NoLinesFoundInTheDocumentErr: Label 'Copilot found the Blanket Sales Order %1, but it does not have any relevant lines.', Comment = '%1 = Document No.';
+
+ procedure SearchSalesDocument(CustomDimension: Dictionary of [Text, Text]; var TempSalesLineAiSuggestion: Record "Sales Line AI Suggestions" temporary)
+ var
+ SourceSalesHeader: Record "Sales Header";
+ SalesHeader: Record "Sales Header";
+ DocumentLookup: Codeunit "Document Lookup Function";
+ DocumentNo: Text;
+ StartDateStr: Text;
+ EndDateStr: Text;
+ FoundDocNo: Code[20];
+ begin
+ DocumentLookup.GetParametersFromCustomDimension(CustomDimension, SourceSalesHeader, DocumentNo, StartDateStr, EndDateStr);
+ SalesHeader.SetLoadFields("No.");
+ // Setup SecurityFilter
+ SalesHeader.SetSecurityFilterOnRespCenter();
+ // Remove the filter on date from RespCenter
+ SalesHeader.SetFilter("Date Filter", '');
+ FoundDocNo := SearchPossibleNo(DocumentNo);
+ // Set up date range
+ SetFilterOnDateForSalesHeader(StartDateStr, EndDateStr, SalesHeader);
+ SalesHeader.SetRange("Document Type", "Sales Document Type"::"Blanket Order");
+ if FoundDocNo <> '' then
+ SalesHeader.SetRange("No.", FoundDocNo)
+ else begin
+ SalesHeader.SetRange("Sell-to Customer No.", SourceSalesHeader."Sell-to Customer No.");
+ if SourceSalesHeader."Document Type" = "Sales Document Type"::"Blanket Order" then
+ SalesHeader.SetFilter("No.", '<>%1', SourceSalesHeader."No."); // Do not use the same document as the source document when document number is not specified
+ end;
+
+ SalesHeader.SetCurrentKey("Document Date");
+ if SalesHeader.FindLast() then
+ FoundDocNo := SalesHeader."No."
+ else
+ if FoundDocNo = '' then
+ Error(NoDocumentFound1Err, SourceSalesHeader."Sell-to Customer Name")
+ else
+ Error(NoDocumentFound2Err, FoundDocNo);
+
+ GetSalesLinesIntoTempTable(FoundDocNo, TempSalesLineAiSuggestion);
+ end;
+
+ local procedure SetFilterOnDateForSalesHeader(StartDateStr: Text; EndDateStr: Text; var SalesHeader: Record "Sales Header")
+ var
+ StartDate: Date;
+ EndDate: Date;
+ begin
+ // Set up date
+ Evaluate(StartDate, StartDateStr);
+ Evaluate(EndDate, EndDateStr);
+
+ if (EndDate = 0D) then EndDate := dmy2date(31, 12, 9999);
+ SalesHeader.SetRange("Document Date", StartDate, EndDate);
+ end;
+
+ local procedure SearchPossibleNo(DocumentNo: Text): Code[20]
+ var
+ DocNoLen: Integer;
+ Result: Code[20];
+ begin
+ if DocumentNo = '' then
+ exit('');
+
+ DocNoLen := StrLen(DocumentNo);
+ if SearchPreciseNo(DocumentNo, DocNoLen, Result) then
+ exit(Result)
+ else
+ if SearchAmbiguousNo(DocumentNo, Result) then
+ exit(Result)
+ else
+ Error(NoDocumentFound2Err, DocumentNo);
+ end;
+
+ local procedure SearchAmbiguousNo(DocumentNo: Text; var Result: Code[20]): Boolean
+ var
+ SalesHeader: Record "Sales Header";
+ DocumentNoFilter: Text;
+ begin
+ DocumentNoFilter := StrSubstNo('*%1*', DocumentNo);
+
+ SalesHeader.SetLoadFields("No.");
+ SalesHeader.SetRange("Document Type", "Sales Document Type"::"Blanket Order");
+ SalesHeader.FilterGroup := -1;
+ SalesHeader.SetFilter("No.", DocumentNoFilter);
+ SalesHeader.SetFilter("External Document No.", DocumentNoFilter);
+ SalesHeader.SetFilter("Quote No.", DocumentNoFilter);
+ SalesHeader.SetFilter("Your Reference", DocumentNoFilter);
+ if SalesHeader.FindLast() then begin
+ Result := SalesHeader."No.";
+ exit(true);
+ end;
+ exit(false);
+ end;
+
+ local procedure SearchPreciseNo(DocumentNo: Text; DocNoLen: Integer; var Result: Code[20]): Boolean
+ var
+ SalesHeader: Record "Sales Header";
+ begin
+ SalesHeader.SetLoadFields("No.");
+ SalesHeader.SetRange("Document Type", "Sales Document Type"::"Blanket Order");
+ SalesHeader.FilterGroup := -1;
+ if DocNoLen <= MaxStrLen(SalesHeader."No.") then
+ SalesHeader.SetRange("No.", DocumentNo);
+ if DocNoLen <= MaxStrLen(SalesHeader."External Document No.") then
+ SalesHeader.SetRange("External Document No.", DocumentNo);
+ if DocNoLen <= MaxStrLen(SalesHeader."Quote No.") then
+ SalesHeader.SetRange("Quote No.", DocumentNo);
+ if DocNoLen <= MaxStrLen(SalesHeader."Your Reference") then
+ SalesHeader.SetRange("Your Reference", DocumentNo);
+ if SalesHeader.GetFilter("No.") + SalesHeader.GetFilter("External Document No.") + SalesHeader.GetFilter("Quote No.") + SalesHeader.GetFilter("Your Reference") <> '' then
+ if SalesHeader.FindLast() then begin
+ Result := SalesHeader."No.";
+ exit(true);
+ end;
+ exit(false);
+ end;
+
+ local procedure GetSalesLinesIntoTempTable(DocumentNo: Code[20]; var TempSalesLineAiSuggestion: Record "Sales Line AI Suggestions" temporary)
+ var
+ SalesLine: Record "Sales Line";
+ Item: Record Item;
+ LineNumber: Integer;
+ begin
+ if not TempSalesLineAiSuggestion.FindLast() then
+ LineNumber := 1
+ else
+ LineNumber := TempSalesLineAiSuggestion."Line No.";
+
+ SalesLine.SetLoadFields("No.", "Description", "Type", "Outstanding Quantity", "Outstanding Qty. (Base)", "Unit of Measure Code", "Qty. per Unit of Measure", "Variant Code");
+ SalesLine.SetRange("Document Type", Enum::"Sales Document Type"::"Blanket Order");
+ SalesLine.SetRange("Document No.", DocumentNo);
+ SalesLine.SetRange("Type", SalesLine.Type::Item);
+ SalesLine.SetFilter("Outstanding Quantity", '>0');
+ if SalesLine.FindSet() then begin
+ repeat
+ Item.SetRange("No.", SalesLine."No.");
+ Item.SetRange(Blocked, false);
+ Item.SetRange("Sales Blocked", false);
+ if not Item.IsEmpty() then begin
+ TempSalesLineAiSuggestion.Init();
+ LineNumber := LineNumber + 1;
+ TempSalesLineAiSuggestion."Line No." := LineNumber;
+ TempSalesLineAiSuggestion.Type := SalesLine.Type;
+ TempSalesLineAiSuggestion."No." := SalesLine."No.";
+ TempSalesLineAiSuggestion.Description := SalesLine.Description;
+ TempSalesLineAiSuggestion."Variant Code" := SalesLine."Variant Code";
+ TempSalesLineAiSuggestion."Unit of Measure Code" := SalesLine."Unit of Measure Code";
+ TempSalesLineAiSuggestion.Quantity := SalesLine."Outstanding Quantity";
+ TempSalesLineAiSuggestion.SetSourceDocument(SalesLine.RecordId());
+ TempSalesLineAiSuggestion.Insert();
+ end;
+ until SalesLine.Next() = 0;
+ if TempSalesLineAiSuggestion.IsEmpty() then
+ Error(NoLinesFoundInTheDocumentErr, DocumentNo);
+ end
+ else
+ Error(NoLinesFoundInTheDocumentErr, DocumentNo);
+ end;
+}
\ No newline at end of file
diff --git a/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/DocumentLookupImpl/SalesInvoiceLookup.Codeunit.al b/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/DocumentLookupImpl/SalesInvoiceLookup.Codeunit.al
index ba0c678e43..716cb45cb3 100644
--- a/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/DocumentLookupImpl/SalesInvoiceLookup.Codeunit.al
+++ b/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/DocumentLookupImpl/SalesInvoiceLookup.Codeunit.al
@@ -6,7 +6,6 @@ namespace Microsoft.Sales.Document;
using Microsoft.Sales.History;
using Microsoft.Inventory.Item;
-using Microsoft.Foundation.UOM;
codeunit 7286 SalesInvoiceLookup implements DocumentLookupSubType
{
@@ -75,70 +74,29 @@ codeunit 7286 SalesInvoiceLookup implements DocumentLookupSubType
if SearchPreciseNo(DocumentNo, DocNoLen, Result) then
exit(Result)
else
- if SearchAmbiguousNo(DocumentNo, DocNoLen, Result) then
+ if SearchAmbiguousNo(DocumentNo, Result) then
exit(Result)
else
Error(NoDocumentFound2Err, DocumentNo);
end;
- local procedure SearchAmbiguousNo(DocumentNo: Text; DocNoLen: Integer; var Result: Code[20]): Boolean
+ local procedure SearchAmbiguousNo(DocumentNo: Text; var Result: Code[20]): Boolean
var
SalesInvoiceHeader: Record "Sales Invoice Header";
+ DocumentNoFilter: Text;
begin
- if DocNoLen <= MaxStrLen(SalesInvoiceHeader."No.") then begin
- // 1. Check if it is document no
- SalesInvoiceHeader.Reset();
- SalesInvoiceHeader.SetLoadFields("No.");
- SalesInvoiceHeader.SetFilter("No.", StrSubstNo('*%1*', DocumentNo));
+ DocumentNoFilter := StrSubstNo('*%1*', DocumentNo);
- if (SalesInvoiceHeader.FindLast()) then begin
- Result := SalesInvoiceHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesInvoiceHeader."External Document No.") then begin
- //2. Check if it is external document no
- SalesInvoiceHeader.Reset();
- SalesInvoiceHeader.SetLoadFields("No.");
- SalesInvoiceHeader.SetFilter("External Document No.", StrSubstNo('*%1*', DocumentNo));
-
- if (SalesInvoiceHeader.FindLast()) then begin
- Result := SalesInvoiceHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesInvoiceHeader."Order No.") then begin
- //3. Check if it is order no
- SalesInvoiceHeader.Reset();
- SalesInvoiceHeader.SetLoadFields("No.");
- SalesInvoiceHeader.SetFilter("Order No.", StrSubstNo('*%1*', DocumentNo));
-
- if (SalesInvoiceHeader.FindLast()) then begin
- Result := SalesInvoiceHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesInvoiceHeader."Quote No.") then begin
- //4. Check if it is quote no
- SalesInvoiceHeader.Reset();
- SalesInvoiceHeader.SetLoadFields("No.");
- SalesInvoiceHeader.SetFilter("Quote No.", StrSubstNo('*%1*', DocumentNo));
-
- if (SalesInvoiceHeader.FindLast()) then begin
- Result := SalesInvoiceHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesInvoiceHeader."Your Reference") then begin
- //5. Check if it is reference no
- SalesInvoiceHeader.Reset();
- SalesInvoiceHeader.SetLoadFields("No.");
- SalesInvoiceHeader.SetFilter("Your Reference", StrSubstNo('*%1*', DocumentNo));
-
- if (SalesInvoiceHeader.FindLast()) then begin
- Result := SalesInvoiceHeader."No.";
- exit(true);
- end;
+ SalesInvoiceHeader.SetLoadFields("No.");
+ SalesInvoiceHeader.FilterGroup := -1;
+ SalesInvoiceHeader.SetFilter("No.", DocumentNoFilter);
+ SalesInvoiceHeader.SetFilter("External Document No.", DocumentNoFilter);
+ SalesInvoiceHeader.SetFilter("Order No.", DocumentNoFilter);
+ SalesInvoiceHeader.SetFilter("Quote No.", DocumentNoFilter);
+ SalesInvoiceHeader.SetFilter("Your Reference", DocumentNoFilter);
+ if SalesInvoiceHeader.FindLast() then begin
+ Result := SalesInvoiceHeader."No.";
+ exit(true);
end;
exit(false);
end;
@@ -147,61 +105,23 @@ codeunit 7286 SalesInvoiceLookup implements DocumentLookupSubType
var
SalesInvoiceHeader: Record "Sales Invoice Header";
begin
- if DocNoLen <= MaxStrLen(SalesInvoiceHeader."No.") then begin
- // 1. Check if it is document no
- SalesInvoiceHeader.Reset();
- SalesInvoiceHeader.SetLoadFields("No.");
+ SalesInvoiceHeader.SetLoadFields("No.");
+ SalesInvoiceHeader.FilterGroup := -1;
+ if DocNoLen <= MaxStrLen(SalesInvoiceHeader."No.") then
SalesInvoiceHeader.SetRange("No.", DocumentNo);
-
- if (SalesInvoiceHeader.FindLast()) then begin
- Result := SalesInvoiceHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesInvoiceHeader."External Document No.") then begin
- //2. Check if it is external document no
- SalesInvoiceHeader.Reset();
- SalesInvoiceHeader.SetLoadFields("No.");
+ if DocNoLen <= MaxStrLen(SalesInvoiceHeader."External Document No.") then
SalesInvoiceHeader.SetRange("External Document No.", DocumentNo);
-
- if (SalesInvoiceHeader.FindLast()) then begin
- Result := SalesInvoiceHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesInvoiceHeader."Order No.") then begin
- //3. Check if it is order no
- SalesInvoiceHeader.Reset();
- SalesInvoiceHeader.SetLoadFields("No.");
+ if DocNoLen <= MaxStrLen(SalesInvoiceHeader."Order No.") then
SalesInvoiceHeader.SetRange("Order No.", DocumentNo);
-
- if (SalesInvoiceHeader.FindLast()) then begin
- Result := SalesInvoiceHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesInvoiceHeader."Quote No.") then begin
- //4. Check if it is quote no
- SalesInvoiceHeader.Reset();
- SalesInvoiceHeader.SetLoadFields("No.");
+ if DocNoLen <= MaxStrLen(SalesInvoiceHeader."Quote No.") then
SalesInvoiceHeader.SetRange("Quote No.", DocumentNo);
-
- if (SalesInvoiceHeader.FindLast()) then begin
- Result := SalesInvoiceHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesInvoiceHeader."Your Reference") then begin
- //5. Check if it is reference no
- SalesInvoiceHeader.Reset();
- SalesInvoiceHeader.SetLoadFields("No.");
+ if DocNoLen <= MaxStrLen(SalesInvoiceHeader."Your Reference") then
SalesInvoiceHeader.SetRange("Your Reference", DocumentNo);
-
- if (SalesInvoiceHeader.FindLast()) then begin
+ if SalesInvoiceHeader.GetFilter("No.") + SalesInvoiceHeader.GetFilter("External Document No.") + SalesInvoiceHeader.GetFilter("Order No.") + SalesInvoiceHeader.GetFilter("Quote No.") + SalesInvoiceHeader.GetFilter("Your Reference") <> '' then
+ if SalesInvoiceHeader.FindLast() then begin
Result := SalesInvoiceHeader."No.";
exit(true);
end;
- end;
exit(false);
end;
@@ -209,7 +129,6 @@ codeunit 7286 SalesInvoiceLookup implements DocumentLookupSubType
var
SalesInvoiceLine: Record "Sales Invoice Line";
Item: Record Item;
- UoMMgt: Codeunit "Unit of Measure Management";
LineNumber: Integer;
begin
if not TempSalesLineAiSuggestion.FindLast() then
@@ -217,7 +136,6 @@ codeunit 7286 SalesInvoiceLookup implements DocumentLookupSubType
else
LineNumber := TempSalesLineAiSuggestion."Line No.";
- Item.SetLoadFields("No.", "Sales Unit of Measure");
SalesInvoiceLine.SetLoadFields("No.", "Description", "Type", "Quantity", "Quantity (Base)", "Unit of Measure Code", "Qty. per Unit of Measure", "Variant Code");
SalesInvoiceLine.SetRange("Document No.", DocumentNo);
SalesInvoiceLine.SetRange("Type", SalesInvoiceLine.Type::Item);
@@ -226,7 +144,7 @@ codeunit 7286 SalesInvoiceLookup implements DocumentLookupSubType
Item.SetRange("No.", SalesInvoiceLine."No.");
Item.SetRange(Blocked, false);
Item.SetRange("Sales Blocked", false);
- if Item.FindFirst() then begin
+ if not Item.IsEmpty() then begin
TempSalesLineAiSuggestion.Init();
LineNumber := LineNumber + 1;
TempSalesLineAiSuggestion."Line No." := LineNumber;
@@ -234,13 +152,8 @@ codeunit 7286 SalesInvoiceLookup implements DocumentLookupSubType
TempSalesLineAiSuggestion."No." := SalesInvoiceLine."No.";
TempSalesLineAiSuggestion.Description := SalesInvoiceLine.Description;
TempSalesLineAiSuggestion."Variant Code" := SalesInvoiceLine."Variant Code";
- if Item."Sales Unit of Measure" <> '' then
- if SalesInvoiceLine."Unit of Measure Code" = Item."Sales Unit of Measure" then
- TempSalesLineAiSuggestion.Quantity := SalesInvoiceLine.Quantity
- else
- TempSalesLineAiSuggestion.Quantity := UoMMgt.CalcQtyFromBase(SalesInvoiceLine."Quantity (Base)", UoMMgt.GetQtyPerUnitOfMeasure(Item, Item."Sales Unit of Measure"))
- else
- TempSalesLineAiSuggestion.Quantity := SalesInvoiceLine."Quantity (Base)";
+ TempSalesLineAiSuggestion."Unit of Measure Code" := SalesInvoiceLine."Unit of Measure Code";
+ TempSalesLineAiSuggestion.Quantity := SalesInvoiceLine.Quantity;
TempSalesLineAiSuggestion.SetSourceDocument(SalesInvoiceLine.RecordId());
TempSalesLineAiSuggestion.Insert();
end;
diff --git a/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/DocumentLookupImpl/SalesOrderLookup.Codeunit.al b/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/DocumentLookupImpl/SalesOrderLookup.Codeunit.al
index 5f5d24ca53..dfbb0423fa 100644
--- a/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/DocumentLookupImpl/SalesOrderLookup.Codeunit.al
+++ b/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/DocumentLookupImpl/SalesOrderLookup.Codeunit.al
@@ -5,7 +5,6 @@
namespace Microsoft.Sales.Document;
using Microsoft.Inventory.Item;
-using Microsoft.Foundation.UOM;
codeunit 7287 SalesOrderLookup implements DocumentLookupSubType
{
@@ -81,59 +80,29 @@ codeunit 7287 SalesOrderLookup implements DocumentLookupSubType
if SearchPreciseNo(DocumentNo, DocNoLen, Result) then
exit(Result)
else
- if SearchAmbiguousNo(DocumentNo, DocNoLen, Result) then
+ if SearchAmbiguousNo(DocumentNo, Result) then
exit(Result)
else
Error(NoDocumentFound2Err, DocumentNo);
end;
- local procedure SearchAmbiguousNo(DocumentNo: Text; DocNoLen: Integer; var Result: Code[20]): Boolean
+ local procedure SearchAmbiguousNo(DocumentNo: Text; var Result: Code[20]): Boolean
var
SalesHeader: Record "Sales Header";
+ DocumentNoFilter: Text;
begin
- if DocNoLen <= MaxStrLen(SalesHeader."No.") then begin
- // 1. Check if it is document no
- SalesHeader.Reset();
- SalesHeader.SetLoadFields("No.");
- SalesHeader.SetRange("Document Type", "Sales Document Type"::Order);
- SalesHeader.SetFilter("No.", StrSubstNo('*%1*', DocumentNo));
- if (SalesHeader.FindLast()) then begin
- Result := SalesHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesHeader."External Document No.") then begin
- //2. Check if it is external document no
- SalesHeader.Reset();
- SalesHeader.SetLoadFields("No.");
- SalesHeader.SetRange("Document Type", "Sales Document Type"::Order);
- SalesHeader.SetFilter("External Document No.", StrSubstNo('*%1*', DocumentNo));
- if (SalesHeader.FindLast()) then begin
- Result := SalesHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesHeader."Quote No.") then begin
- //3. Check if it is quote no
- SalesHeader.Reset();
- SalesHeader.SetLoadFields("No.");
- SalesHeader.SetRange("Document Type", "Sales Document Type"::Order);
- SalesHeader.SetFilter("Quote No.", StrSubstNo('*%1*', DocumentNo));
- if (SalesHeader.FindLast()) then begin
- Result := SalesHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesHeader."Your Reference") then begin
- //4. Check if it is reference no
- SalesHeader.Reset();
- SalesHeader.SetLoadFields("No.");
- SalesHeader.SetRange("Document Type", "Sales Document Type"::Order);
- SalesHeader.SetFilter("Your Reference", StrSubstNo('*%1*', DocumentNo));
- if (SalesHeader.FindLast()) then begin
- Result := SalesHeader."No.";
- exit(true);
- end;
+ DocumentNoFilter := StrSubstNo('*%1*', DocumentNo);
+
+ SalesHeader.SetLoadFields("No.");
+ SalesHeader.SetRange("Document Type", "Sales Document Type"::Order);
+ SalesHeader.FilterGroup := -1;
+ SalesHeader.SetFilter("No.", DocumentNoFilter);
+ SalesHeader.SetFilter("External Document No.", DocumentNoFilter);
+ SalesHeader.SetFilter("Quote No.", DocumentNoFilter);
+ SalesHeader.SetFilter("Your Reference", DocumentNoFilter);
+ if SalesHeader.FindLast() then begin
+ Result := SalesHeader."No.";
+ exit(true);
end;
exit(false);
end;
@@ -142,50 +111,22 @@ codeunit 7287 SalesOrderLookup implements DocumentLookupSubType
var
SalesHeader: Record "Sales Header";
begin
- if DocNoLen <= MaxStrLen(SalesHeader."No.") then begin
- // 1. Check if it is document no
- SalesHeader.Reset();
- SalesHeader.SetLoadFields("No.");
- SalesHeader.SetRange("Document Type", "Sales Document Type"::Order);
+ SalesHeader.SetLoadFields("No.");
+ SalesHeader.SetRange("Document Type", "Sales Document Type"::Order);
+ SalesHeader.FilterGroup := -1;
+ if DocNoLen <= MaxStrLen(SalesHeader."No.") then
SalesHeader.SetRange("No.", DocumentNo);
- if (SalesHeader.FindLast()) then begin
- Result := SalesHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesHeader."External Document No.") then begin
- //2. Check if it is external document no
- SalesHeader.Reset();
- SalesHeader.SetLoadFields("No.");
- SalesHeader.SetRange("Document Type", "Sales Document Type"::Order);
+ if DocNoLen <= MaxStrLen(SalesHeader."External Document No.") then
SalesHeader.SetRange("External Document No.", DocumentNo);
- if (SalesHeader.FindLast()) then begin
- Result := SalesHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesHeader."Quote No.") then begin
- //3. Check if it is quote no
- SalesHeader.Reset();
- SalesHeader.SetLoadFields("No.");
- SalesHeader.SetRange("Document Type", "Sales Document Type"::Order);
+ if DocNoLen <= MaxStrLen(SalesHeader."Quote No.") then
SalesHeader.SetRange("Quote No.", DocumentNo);
- if (SalesHeader.FindLast()) then begin
- Result := SalesHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesHeader."Your Reference") then begin
- //4. Check if it is reference no
- SalesHeader.Reset();
- SalesHeader.SetLoadFields("No.");
- SalesHeader.SetRange("Document Type", "Sales Document Type"::Order);
+ if DocNoLen <= MaxStrLen(SalesHeader."Your Reference") then
SalesHeader.SetRange("Your Reference", DocumentNo);
- if (SalesHeader.FindLast()) then begin
+ if SalesHeader.GetFilter("No.") + SalesHeader.GetFilter("External Document No.") + SalesHeader.GetFilter("Quote No.") + SalesHeader.GetFilter("Your Reference") <> '' then
+ if SalesHeader.FindLast() then begin
Result := SalesHeader."No.";
exit(true);
end;
- end;
exit(false);
end;
@@ -193,7 +134,6 @@ codeunit 7287 SalesOrderLookup implements DocumentLookupSubType
var
SalesLine: Record "Sales Line";
Item: Record Item;
- UoMMgt: Codeunit "Unit of Measure Management";
LineNumber: Integer;
begin
if not TempSalesLineAiSuggestion.FindLast() then
@@ -201,7 +141,6 @@ codeunit 7287 SalesOrderLookup implements DocumentLookupSubType
else
LineNumber := TempSalesLineAiSuggestion."Line No.";
- Item.SetLoadFields("No.", "Sales Unit of Measure");
SalesLine.SetLoadFields("No.", "Description", "Type", "Quantity", "Quantity (Base)", "Unit of Measure Code", "Qty. per Unit of Measure", "Variant Code");
SalesLine.SetRange("Document Type", Enum::"Sales Document Type"::Order);
SalesLine.SetRange("Document No.", DocumentNo);
@@ -211,7 +150,7 @@ codeunit 7287 SalesOrderLookup implements DocumentLookupSubType
Item.SetRange("No.", SalesLine."No.");
Item.SetRange(Blocked, false);
Item.SetRange("Sales Blocked", false);
- if Item.FindFirst() then begin
+ if not Item.IsEmpty() then begin
TempSalesLineAiSuggestion.Init();
LineNumber := LineNumber + 1;
TempSalesLineAiSuggestion."Line No." := LineNumber;
@@ -219,13 +158,8 @@ codeunit 7287 SalesOrderLookup implements DocumentLookupSubType
TempSalesLineAiSuggestion."No." := SalesLine."No.";
TempSalesLineAiSuggestion.Description := SalesLine.Description;
TempSalesLineAiSuggestion."Variant Code" := SalesLine."Variant Code";
- if Item."Sales Unit of Measure" <> '' then
- if SalesLine."Unit of Measure Code" = Item."Sales Unit of Measure" then
- TempSalesLineAiSuggestion.Quantity := SalesLine.Quantity
- else
- TempSalesLineAiSuggestion.Quantity := UoMMgt.CalcQtyFromBase(SalesLine."Quantity (Base)", UoMMgt.GetQtyPerUnitOfMeasure(Item, Item."Sales Unit of Measure"))
- else
- TempSalesLineAiSuggestion.Quantity := SalesLine."Quantity (Base)";
+ TempSalesLineAiSuggestion."Unit of Measure Code" := SalesLine."Unit of Measure Code";
+ TempSalesLineAiSuggestion.Quantity := SalesLine.Quantity;
TempSalesLineAiSuggestion.SetSourceDocument(SalesLine.RecordId());
TempSalesLineAiSuggestion.Insert();
end;
diff --git a/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/DocumentLookupImpl/SalesQuoteLookup.Codeunit.al b/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/DocumentLookupImpl/SalesQuoteLookup.Codeunit.al
index 0996ca9c74..455181aec2 100644
--- a/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/DocumentLookupImpl/SalesQuoteLookup.Codeunit.al
+++ b/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/DocumentLookupImpl/SalesQuoteLookup.Codeunit.al
@@ -5,7 +5,6 @@
namespace Microsoft.Sales.Document;
using Microsoft.Inventory.Item;
-using Microsoft.Foundation.UOM;
codeunit 7288 SalesQuoteLookup implements DocumentLookupSubType
{
@@ -81,59 +80,29 @@ codeunit 7288 SalesQuoteLookup implements DocumentLookupSubType
if SearchPreciseNo(DocumentNo, DocNoLen, Result) then
exit(Result)
else
- if SearchAmbiguousNo(DocumentNo, DocNoLen, Result) then
+ if SearchAmbiguousNo(DocumentNo, Result) then
exit(Result)
else
Error(NoDocumentFound2Err, DocumentNo);
end;
- local procedure SearchAmbiguousNo(DocumentNo: Text; DocNoLen: Integer; var Result: Code[20]): Boolean
+ local procedure SearchAmbiguousNo(DocumentNo: Text; var Result: Code[20]): Boolean
var
SalesHeader: Record "Sales Header";
+ DocumentNoFilter: Text;
begin
- if DocNoLen <= MaxStrLen(SalesHeader."No.") then begin
- // 1. Check if it is document no
- SalesHeader.Reset();
- SalesHeader.SetLoadFields("No.");
- SalesHeader.SetRange("Document Type", "Sales Document Type"::Quote);
- SalesHeader.SetFilter("No.", StrSubstNo('*%1*', DocumentNo));
- if (SalesHeader.FindLast()) then begin
- Result := SalesHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesHeader."External Document No.") then begin
- //2. Check if it is external document no
- SalesHeader.Reset();
- SalesHeader.SetLoadFields("No.");
- SalesHeader.SetRange("Document Type", "Sales Document Type"::Quote);
- SalesHeader.SetFilter("External Document No.", StrSubstNo('*%1*', DocumentNo));
- if (SalesHeader.FindLast()) then begin
- Result := SalesHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesHeader."Quote No.") then begin
- //3. Check if it is quote no
- SalesHeader.Reset();
- SalesHeader.SetLoadFields("No.");
- SalesHeader.SetRange("Document Type", "Sales Document Type"::Quote);
- SalesHeader.SetFilter("Quote No.", StrSubstNo('*%1*', DocumentNo));
- if (SalesHeader.FindLast()) then begin
- Result := SalesHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesHeader."Your Reference") then begin
- //4. Check if it is reference no
- SalesHeader.Reset();
- SalesHeader.SetLoadFields("No.");
- SalesHeader.SetRange("Document Type", "Sales Document Type"::Quote);
- SalesHeader.SetFilter("Your Reference", StrSubstNo('*%1*', DocumentNo));
- if (SalesHeader.FindLast()) then begin
- Result := SalesHeader."No.";
- exit(true);
- end;
+ DocumentNoFilter := StrSubstNo('*%1*', DocumentNo);
+
+ SalesHeader.SetLoadFields("No.");
+ SalesHeader.SetRange("Document Type", "Sales Document Type"::Quote);
+ SalesHeader.FilterGroup := -1;
+ SalesHeader.SetFilter("No.", DocumentNoFilter);
+ SalesHeader.SetFilter("External Document No.", DocumentNoFilter);
+ SalesHeader.SetFilter("Quote No.", DocumentNoFilter);
+ SalesHeader.SetFilter("Your Reference", DocumentNoFilter);
+ if SalesHeader.FindLast() then begin
+ Result := SalesHeader."No.";
+ exit(true);
end;
exit(false);
end;
@@ -142,50 +111,22 @@ codeunit 7288 SalesQuoteLookup implements DocumentLookupSubType
var
SalesHeader: Record "Sales Header";
begin
- if DocNoLen <= MaxStrLen(SalesHeader."No.") then begin
- // 1. Check if it is document no
- SalesHeader.Reset();
- SalesHeader.SetLoadFields("No.");
- SalesHeader.SetRange("Document Type", "Sales Document Type"::Quote);
+ SalesHeader.SetLoadFields("No.");
+ SalesHeader.SetRange("Document Type", "Sales Document Type"::Quote);
+ SalesHeader.FilterGroup := -1;
+ if DocNoLen <= MaxStrLen(SalesHeader."No.") then
SalesHeader.SetRange("No.", DocumentNo);
- if (SalesHeader.FindLast()) then begin
- Result := SalesHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesHeader."External Document No.") then begin
- //2. Check if it is external document no
- SalesHeader.Reset();
- SalesHeader.SetLoadFields("No.");
- SalesHeader.SetRange("Document Type", "Sales Document Type"::Quote);
+ if DocNoLen <= MaxStrLen(SalesHeader."External Document No.") then
SalesHeader.SetRange("External Document No.", DocumentNo);
- if (SalesHeader.FindLast()) then begin
- Result := SalesHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesHeader."Quote No.") then begin
- //3. Check if it is quote no
- SalesHeader.Reset();
- SalesHeader.SetLoadFields("No.");
- SalesHeader.SetRange("Document Type", "Sales Document Type"::Quote);
+ if DocNoLen <= MaxStrLen(SalesHeader."Quote No.") then
SalesHeader.SetRange("Quote No.", DocumentNo);
- if (SalesHeader.FindLast()) then begin
- Result := SalesHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesHeader."Your Reference") then begin
- //4. Check if it is reference no
- SalesHeader.Reset();
- SalesHeader.SetLoadFields("No.");
- SalesHeader.SetRange("Document Type", "Sales Document Type"::Quote);
+ if DocNoLen <= MaxStrLen(SalesHeader."Your Reference") then
SalesHeader.SetRange("Your Reference", DocumentNo);
- if (SalesHeader.FindLast()) then begin
+ if SalesHeader.GetFilter("No.") + SalesHeader.GetFilter("External Document No.") + SalesHeader.GetFilter("Quote No.") + SalesHeader.GetFilter("Your Reference") <> '' then
+ if SalesHeader.FindLast() then begin
Result := SalesHeader."No.";
exit(true);
end;
- end;
exit(false);
end;
@@ -193,7 +134,6 @@ codeunit 7288 SalesQuoteLookup implements DocumentLookupSubType
var
SalesLine: Record "Sales Line";
Item: Record Item;
- UoMMgt: Codeunit "Unit of Measure Management";
LineNumber: Integer;
begin
if not TempSalesLineAiSuggestion.FindLast() then
@@ -201,7 +141,6 @@ codeunit 7288 SalesQuoteLookup implements DocumentLookupSubType
else
LineNumber := TempSalesLineAiSuggestion."Line No.";
- Item.SetLoadFields("No.", "Sales Unit of Measure");
SalesLine.SetLoadFields("No.", "Description", "Type", "Quantity", "Quantity (Base)", "Unit of Measure Code", "Qty. per Unit of Measure", "Variant Code");
SalesLine.SetRange("Document Type", Enum::"Sales Document Type"::Quote);
SalesLine.SetRange("Document No.", DocumentNo);
@@ -211,7 +150,7 @@ codeunit 7288 SalesQuoteLookup implements DocumentLookupSubType
Item.SetRange("No.", SalesLine."No.");
Item.SetRange(Blocked, false);
Item.SetRange("Sales Blocked", false);
- if Item.FindFirst() then begin
+ if not Item.IsEmpty() then begin
TempSalesLineAiSuggestion.Init();
LineNumber := LineNumber + 1;
TempSalesLineAiSuggestion."Line No." := LineNumber;
@@ -219,13 +158,8 @@ codeunit 7288 SalesQuoteLookup implements DocumentLookupSubType
TempSalesLineAiSuggestion."No." := SalesLine."No.";
TempSalesLineAiSuggestion.Description := SalesLine.Description;
TempSalesLineAiSuggestion."Variant Code" := SalesLine."Variant Code";
- if Item."Sales Unit of Measure" <> '' then
- if SalesLine."Unit of Measure Code" = Item."Sales Unit of Measure" then
- TempSalesLineAiSuggestion.Quantity := SalesLine.Quantity
- else
- TempSalesLineAiSuggestion.Quantity := UoMMgt.CalcQtyFromBase(SalesLine."Quantity (Base)", UoMMgt.GetQtyPerUnitOfMeasure(Item, Item."Sales Unit of Measure"))
- else
- TempSalesLineAiSuggestion.Quantity := SalesLine."Quantity (Base)";
+ TempSalesLineAiSuggestion."Unit of Measure Code" := SalesLine."Unit of Measure Code";
+ TempSalesLineAiSuggestion.Quantity := SalesLine.Quantity;
TempSalesLineAiSuggestion.SetSourceDocument(SalesLine.RecordId());
TempSalesLineAiSuggestion.Insert();
end;
diff --git a/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/DocumentLookupImpl/SalesShipmentLookup.Codeunit.al b/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/DocumentLookupImpl/SalesShipmentLookup.Codeunit.al
index 21f59c7db9..60970415dc 100644
--- a/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/DocumentLookupImpl/SalesShipmentLookup.Codeunit.al
+++ b/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/DocumentLookupImpl/SalesShipmentLookup.Codeunit.al
@@ -5,7 +5,6 @@
namespace Microsoft.Sales.Document;
using Microsoft.Inventory.Item;
-using Microsoft.Foundation.UOM;
using Microsoft.Sales.History;
codeunit 7289 SalesShipmentLookup implements DocumentLookupSubType
@@ -75,70 +74,29 @@ codeunit 7289 SalesShipmentLookup implements DocumentLookupSubType
if SearchPreciseNo(DocumentNo, DocNoLen, Result) then
exit(Result)
else
- if SearchAmbiguousNo(DocumentNo, DocNoLen, Result) then
+ if SearchAmbiguousNo(DocumentNo, Result) then
exit(Result)
else
Error(NoDocumentFound2Err, DocumentNo);
end;
- local procedure SearchAmbiguousNo(DocumentNo: Text; DocNoLen: Integer; var Result: Code[20]): Boolean
+ local procedure SearchAmbiguousNo(DocumentNo: Text; var Result: Code[20]): Boolean
var
SalesShipmentHeader: Record "Sales Shipment Header";
+ DocumentNoFilter: Text;
begin
- if DocNoLen <= MaxStrLen(SalesShipmentHeader."No.") then begin
- // 1. Check if it is document no
- SalesShipmentHeader.Reset();
- SalesShipmentHeader.SetLoadFields("No.");
- SalesShipmentHeader.SetFilter("No.", StrSubstNo('*%1*', DocumentNo));
+ DocumentNoFilter := StrSubstNo('*%1*', DocumentNo);
- if (SalesShipmentHeader.FindLast()) then begin
- Result := SalesShipmentHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesShipmentHeader."External Document No.") then begin
- //2. Check if it is external document no
- SalesShipmentHeader.Reset();
- SalesShipmentHeader.SetLoadFields("No.");
- SalesShipmentHeader.SetFilter("External Document No.", StrSubstNo('*%1*', DocumentNo));
-
- if (SalesShipmentHeader.FindLast()) then begin
- Result := SalesShipmentHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesShipmentHeader."Order No.") then begin
- //3. Check if it is order no
- SalesShipmentHeader.Reset();
- SalesShipmentHeader.SetLoadFields("No.");
- SalesShipmentHeader.SetFilter("Order No.", StrSubstNo('*%1*', DocumentNo));
-
- if (SalesShipmentHeader.FindLast()) then begin
- Result := SalesShipmentHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesShipmentHeader."Quote No.") then begin
- //4. Check if it is quote no
- SalesShipmentHeader.Reset();
- SalesShipmentHeader.SetLoadFields("No.");
- SalesShipmentHeader.SetFilter("Quote No.", StrSubstNo('*%1*', DocumentNo));
-
- if (SalesShipmentHeader.FindLast()) then begin
- Result := SalesShipmentHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesShipmentHeader."Your Reference") then begin
- //5. Check if it is reference no
- SalesShipmentHeader.Reset();
- SalesShipmentHeader.SetLoadFields("No.");
- SalesShipmentHeader.SetFilter("Your Reference", StrSubstNo('*%1*', DocumentNo));
-
- if (SalesShipmentHeader.FindLast()) then begin
- Result := SalesShipmentHeader."No.";
- exit(true);
- end;
+ SalesShipmentHeader.SetLoadFields("No.");
+ SalesShipmentHeader.FilterGroup := -1;
+ SalesShipmentHeader.SetFilter("No.", DocumentNoFilter);
+ SalesShipmentHeader.SetFilter("External Document No.", DocumentNoFilter);
+ SalesShipmentHeader.SetFilter("Order No.", DocumentNoFilter);
+ SalesShipmentHeader.SetFilter("Quote No.", DocumentNoFilter);
+ SalesShipmentHeader.SetFilter("Your Reference", DocumentNoFilter);
+ if SalesShipmentHeader.FindLast() then begin
+ Result := SalesShipmentHeader."No.";
+ exit(true);
end;
exit(false);
end;
@@ -147,61 +105,23 @@ codeunit 7289 SalesShipmentLookup implements DocumentLookupSubType
var
SalesShipmentHeader: Record "Sales Shipment Header";
begin
- if DocNoLen <= MaxStrLen(SalesShipmentHeader."No.") then begin
- // 1. Check if it is document no
- SalesShipmentHeader.Reset();
- SalesShipmentHeader.SetLoadFields("No.");
+ SalesShipmentHeader.SetLoadFields("No.");
+ SalesShipmentHeader.FilterGroup := -1;
+ if DocNoLen <= MaxStrLen(SalesShipmentHeader."No.") then
SalesShipmentHeader.SetRange("No.", DocumentNo);
-
- if (SalesShipmentHeader.FindLast()) then begin
- Result := SalesShipmentHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesShipmentHeader."External Document No.") then begin
- //2. Check if it is external document no
- SalesShipmentHeader.Reset();
- SalesShipmentHeader.SetLoadFields("No.");
+ if DocNoLen <= MaxStrLen(SalesShipmentHeader."External Document No.") then
SalesShipmentHeader.SetRange("External Document No.", DocumentNo);
-
- if (SalesShipmentHeader.FindLast()) then begin
- Result := SalesShipmentHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesShipmentHeader."Order No.") then begin
- //3. Check if it is order no
- SalesShipmentHeader.Reset();
- SalesShipmentHeader.SetLoadFields("No.");
+ if DocNoLen <= MaxStrLen(SalesShipmentHeader."Order No.") then
SalesShipmentHeader.SetRange("Order No.", DocumentNo);
-
- if (SalesShipmentHeader.FindLast()) then begin
- Result := SalesShipmentHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesShipmentHeader."Quote No.") then begin
- //4. Check if it is quote no
- SalesShipmentHeader.Reset();
- SalesShipmentHeader.SetLoadFields("No.");
+ if DocNoLen <= MaxStrLen(SalesShipmentHeader."Quote No.") then
SalesShipmentHeader.SetRange("Quote No.", DocumentNo);
-
- if (SalesShipmentHeader.FindLast()) then begin
- Result := SalesShipmentHeader."No.";
- exit(true);
- end;
- end;
- if DocNoLen <= MaxStrLen(SalesShipmentHeader."Your Reference") then begin
- //5. Check if it is reference no
- SalesShipmentHeader.Reset();
- SalesShipmentHeader.SetLoadFields("No.");
+ if DocNoLen <= MaxStrLen(SalesShipmentHeader."Your Reference") then
SalesShipmentHeader.SetRange("Your Reference", DocumentNo);
-
- if (SalesShipmentHeader.FindLast()) then begin
+ if SalesShipmentHeader.GetFilter("No.") + SalesShipmentHeader.GetFilter("External Document No.") + SalesShipmentHeader.GetFilter("Order No.") + SalesShipmentHeader.GetFilter("Quote No.") + SalesShipmentHeader.GetFilter("Your Reference") <> '' then
+ if SalesShipmentHeader.FindLast() then begin
Result := SalesShipmentHeader."No.";
exit(true);
end;
- end;
exit(false);
end;
@@ -209,7 +129,6 @@ codeunit 7289 SalesShipmentLookup implements DocumentLookupSubType
var
SalesShipmentLine: Record "Sales Shipment Line";
Item: Record Item;
- UoMMgt: Codeunit "Unit of Measure Management";
LineNumber: Integer;
begin
if not TempSalesLineAiSuggestion.FindLast() then
@@ -217,7 +136,6 @@ codeunit 7289 SalesShipmentLookup implements DocumentLookupSubType
else
LineNumber := TempSalesLineAiSuggestion."Line No.";
- Item.SetLoadFields("No.", "Sales Unit of Measure");
SalesShipmentLine.SetLoadFields("No.", "Description", "Type", "Quantity", "Quantity (Base)", "Unit of Measure Code", "Qty. per Unit of Measure", "Variant Code");
SalesShipmentLine.SetRange("Document No.", DocumentNo);
SalesShipmentLine.SetRange("Type", SalesShipmentLine.Type::Item);
@@ -226,7 +144,7 @@ codeunit 7289 SalesShipmentLookup implements DocumentLookupSubType
Item.SetRange("No.", SalesShipmentLine."No.");
Item.SetRange(Blocked, false);
Item.SetRange("Sales Blocked", false);
- if Item.FindFirst() then begin
+ if not Item.IsEmpty() then begin
TempSalesLineAiSuggestion.Init();
LineNumber := LineNumber + 1;
TempSalesLineAiSuggestion."Line No." := LineNumber;
@@ -234,13 +152,8 @@ codeunit 7289 SalesShipmentLookup implements DocumentLookupSubType
TempSalesLineAiSuggestion."No." := SalesShipmentLine."No.";
TempSalesLineAiSuggestion.Description := SalesShipmentLine.Description;
TempSalesLineAiSuggestion."Variant Code" := SalesShipmentLine."Variant Code";
- if Item."Sales Unit of Measure" <> '' then
- if SalesShipmentLine."Unit of Measure Code" = Item."Sales Unit of Measure" then
- TempSalesLineAiSuggestion.Quantity := SalesShipmentLine.Quantity
- else
- TempSalesLineAiSuggestion.Quantity := UoMMgt.CalcQtyFromBase(SalesShipmentLine."Quantity (Base)", UoMMgt.GetQtyPerUnitOfMeasure(Item, Item."Sales Unit of Measure"))
- else
- TempSalesLineAiSuggestion.Quantity := SalesShipmentLine."Quantity (Base)";
+ TempSalesLineAiSuggestion."Unit of Measure Code" := SalesShipmentLine."Unit of Measure Code";
+ TempSalesLineAiSuggestion.Quantity := SalesShipmentLine.Quantity;
TempSalesLineAiSuggestion.SetSourceDocument(SalesShipmentLine.RecordId());
TempSalesLineAiSuggestion.Insert();
end;
diff --git a/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/Enums/DocumentLookupTypes.Enum.al b/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/Enums/DocumentLookupTypes.Enum.al
index aa7cbb6aec..8c48ed8b9f 100644
--- a/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/Enums/DocumentLookupTypes.Enum.al
+++ b/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/Enums/DocumentLookupTypes.Enum.al
@@ -25,4 +25,8 @@ enum 7279 "Document Lookup Types" implements DocumentLookupSubType
{
Implementation = DocumentLookupSubType = SalesQuoteLookup;
}
+ value(4; "Blanket Sales Order")
+ {
+ Implementation = DocumentLookupSubType = BlanketSalesOrderLookup;
+ }
}
\ No newline at end of file
diff --git a/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/FunctionsImpl/SearchItemsWithFiltersFunc.Codeunit.al b/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/FunctionsImpl/SearchItemsWithFiltersFunc.Codeunit.al
new file mode 100644
index 0000000000..67af914f85
--- /dev/null
+++ b/Apps/W1/SalesLinesSuggestions/app/SalesAzureOpenAITools/FunctionsImpl/SearchItemsWithFiltersFunc.Codeunit.al
@@ -0,0 +1,236 @@
+// ------------------------------------------------------------------------------------------------
+// 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.Document;
+
+using System.AI;
+using System.Telemetry;
+using Microsoft.Foundation.UOM;
+using Microsoft.Inventory.Item;
+using System.Text;
+
+codeunit 7291 "Search Items With Filters Func" implements "AOAI Function"
+{
+ Access = Internal;
+
+ var
+ SourceDocumentRecordId: RecordId;
+ SearchQuery: Text;
+ SearchStyle: Enum "Search Style";
+ FunctionNameLbl: Label 'search_items_with_filters', Locked = true;
+ SearchWithFiltersLbl: Label 'function_call: search_items_with_filters', Locked = true;
+ SourceDocumentRecordIDLbl: Label 'SourceDocumentRecordID', Locked = true;
+
+ [NonDebuggable]
+ procedure GetPrompt(): JsonObject
+ var
+ UnitOfMeasure: Record "Unit of Measure";
+ Prompt: Codeunit "SLS Prompts";
+ PromptJson: JsonObject;
+ UnitsOfMeasureText: Text;
+ begin
+ UnitsOfMeasureText := '';
+ UnitOfMeasure.SetFilter(Description, '<>%1', '');
+ if UnitOfMeasure.FindSet() then begin
+ repeat
+ UnitsOfMeasureText += '"' + UnitOfMeasure.Description + '",';
+ until UnitOfMeasure.Next() = 0;
+ UnitsOfMeasureText := UnitsOfMeasureText.TrimEnd(',');
+ end;
+
+ PromptJson.ReadFrom(StrSubstNo(Prompt.GetSLSSearchItemsWithFiltersPrompt(), UnitsOfMeasureText));
+ exit(PromptJson);
+ end;
+
+ [NonDebuggable]
+ procedure Execute(Arguments: JsonObject): Variant
+ var
+ TempSalesLineAiSuggestionFromDocLookup: Record "Sales Line AI Suggestions" temporary;
+ TempSalesLineAiSuggestionFromItemSearch: Record "Sales Line AI Suggestions" temporary;
+ TempSalesLineAiSuggestionFiltered: Record "Sales Line AI Suggestions" temporary;
+ Item: Record Item;
+ SalesLineAISuggestionImpl: Codeunit "Sales Lines Suggestions Impl.";
+ FeatureTelemetry: Codeunit "Feature Telemetry";
+ NotificationManager: Codeunit "Notification Manager";
+ SearchUtility: Codeunit "Search";
+ SelectionFilterManagement: Codeunit SelectionFilterManagement;
+ FeatureTelemetryCD: Dictionary of [Text, Text];
+ DocLookupType: Enum "Document Lookup Types";
+ DocumentLookupSubType: Interface DocumentLookupSubType;
+ ItemsResults: JsonToken;
+ ItemResultsArray: JsonArray;
+ DocumentNo: Text;
+ StartDateTxt: Text;
+ EndDateTxt: Text;
+ ItemNoFilter: Text;
+ SearchIntentLbl: Label 'Add products to a sales order.', Locked = true;
+ begin
+ if Arguments.Get('results', ItemsResults) then begin
+ ItemResultsArray := ItemsResults.AsArray();
+
+ // Find document information from user input
+ if GetDocumentFromUserInput(DocumentNo, StartDateTxt, EndDateTxt, DocLookupType, ItemResultsArray) then begin
+ DocumentLookupSubType := DocLookupType;
+ FeatureTelemetryCD.Add('Document Type', DocLookupType.Names().Get(DocLookupType.Ordinals.IndexOf(DocLookupType.AsInteger())));
+
+ // Search for the sales document in the system
+ if SearchSalesDocument(TempSalesLineAiSuggestionFromDocLookup, DocumentLookupSubType, Format(SourceDocumentRecordId), DocumentNo, StartDateTxt, EndDateTxt) then begin
+ FeatureTelemetry.LogUsage('0000N3I', SalesLineAISuggestionImpl.GetFeatureName(), SearchWithFiltersLbl, FeatureTelemetryCD);
+ if TempSalesLineAiSuggestionFromDocLookup.IsEmpty() then
+ NotificationManager.SendNotification(SalesLineAISuggestionImpl.GetNoSalesLinesSuggestionsMsg());
+ end
+ else begin
+ FeatureTelemetry.LogError('0000N3F', SalesLineAISuggestionImpl.GetFeatureName(), SearchWithFiltersLbl, 'Document lookup resulted in an error', GetLastErrorCallStack(), FeatureTelemetryCD);
+ NotificationManager.SendNotification(GetLastErrorText());
+ exit(TempSalesLineAiSuggestionFromDocLookup);
+ end;
+ end;
+ end;
+
+ // Item search
+ if Arguments.Get('search_items', ItemsResults) then begin
+ FeatureTelemetry.LogUsage('0000N3J', SalesLineAISuggestionImpl.GetFeatureName(), SearchWithFiltersLbl + ': Item Search');
+
+ ItemResultsArray := ItemsResults.AsArray();
+
+ // If document lookup returned results, filter items based on the document
+ if TempSalesLineAiSuggestionFromDocLookup.FindSet() then begin
+ repeat
+ if Item.Get(TempSalesLineAiSuggestionFromDocLookup."No.") then
+ Item.Mark(true);
+ until TempSalesLineAiSuggestionFromDocLookup.Next() = 0;
+ Item.MarkedOnly(true);
+ ItemNoFilter := SelectionFilterManagement.GetSelectionFilterForItem(Item);
+ end;
+
+ if SearchUtility.SearchMultiple(ItemResultsArray, SearchStyle, SearchIntentLbl, SearchQuery, 1, 25, false, true, TempSalesLineAiSuggestionFromItemSearch, ItemNoFilter) then begin
+ if TempSalesLineAiSuggestionFromItemSearch.IsEmpty() then begin
+ FeatureTelemetry.LogError('0000N3G', SalesLineAISuggestionImpl.GetFeatureName(), SearchWithFiltersLbl, 'Item search returned no items.');
+ NotificationManager.SendNotification(SalesLineAISuggestionImpl.GetNoSalesLinesSuggestionsMsg());
+ exit(TempSalesLineAiSuggestionFromDocLookup);
+ end;
+
+ // If document lookup did not return any results, return the items from the item search
+ if TempSalesLineAiSuggestionFromDocLookup.IsEmpty() then
+ exit(TempSalesLineAiSuggestionFromItemSearch);
+
+ // If document lookup returned results, find intersection of items from document and item search
+ TempSalesLineAiSuggestionFromItemSearch.FindSet();
+ repeat
+ TempSalesLineAiSuggestionFromDocLookup.SetRange("No.", TempSalesLineAiSuggestionFromItemSearch."No.");
+ if TempSalesLineAiSuggestionFromDocLookup.FindSet() then
+ repeat
+ TempSalesLineAiSuggestionFiltered.Init();
+ TempSalesLineAiSuggestionFiltered.Copy(TempSalesLineAiSuggestionFromDocLookup);
+ TempSalesLineAiSuggestionFiltered.Quantity := TempSalesLineAiSuggestionFromDocLookup.Quantity;
+ TempSalesLineAiSuggestionFiltered.Insert();
+ until TempSalesLineAiSuggestionFromDocLookup.Next() = 0;
+ until TempSalesLineAiSuggestionFromItemSearch.Next() = 0;
+ TempSalesLineAiSuggestionFiltered.Reset();
+ FeatureTelemetry.LogUsage('0000N3K', SalesLineAISuggestionImpl.GetFeatureName(), SearchWithFiltersLbl + ': Item Search inside document returned items.');
+ exit(TempSalesLineAiSuggestionFiltered);
+ end
+ else begin
+ FeatureTelemetry.LogError('0000N3H', SalesLineAISuggestionImpl.GetFeatureName(), SearchWithFiltersLbl, 'Item search failed.');
+ NotificationManager.SendNotification(SalesLineAISuggestionImpl.GetChatCompletionResponseErr());
+ end;
+ end;
+
+ exit(TempSalesLineAiSuggestionFromDocLookup);
+ end;
+
+ procedure GetName(): Text
+ begin
+ exit(FunctionNameLbl);
+ end;
+
+ procedure SetSearchQuery(NewSearchQuery: Text)
+ begin
+ SearchQuery := NewSearchQuery;
+ end;
+
+ procedure SetSearchStyle(NewSearchStyle: Enum "Search Style")
+ begin
+ SearchStyle := NewSearchStyle;
+ end;
+
+ procedure SetSourceDocumentRecordId(NewSourceDocumentRecordId: RecordId)
+ begin
+ SourceDocumentRecordId := NewSourceDocumentRecordId;
+ end;
+
+ [TryFunction]
+ local procedure SearchSalesDocument(var TempSalesLineAiSuggestion: Record "Sales Line AI Suggestions" temporary; var DocumentLookupSubType: Interface DocumentLookupSubType; SourceDocumentRecordIdText: Text; DocumentNo: Text; StartDateTxt: Text; EndDateTxt: Text)
+ begin
+ DocumentLookupSubType.SearchSalesDocument(AddParametersToCustomDimension(SourceDocumentRecordIdText, DocumentNo, StartDateTxt, EndDateTxt), TempSalesLineAiSuggestion);
+ end;
+
+ local procedure AddParametersToCustomDimension(SourceDocumentRecordIdText: Text; DocumentNo: Text; StartDateStr: Text; EndDateStr: Text): Dictionary of [Text, Text]
+ var
+ CustomDimension: Dictionary of [Text, Text];
+ begin
+ CustomDimension.Add(SourceDocumentRecordIDLbl, SourceDocumentRecordIdText);
+ CustomDimension.Add('DocumentNo', DocumentNo);
+ CustomDimension.Add('StartDateStr', StartDateStr);
+ CustomDimension.Add('EndDateStr', EndDateStr);
+ exit(CustomDimension);
+ end;
+
+ internal procedure GetParametersFromCustomDimension(CustomDimension: Dictionary of [Text, Text]; var SourceSalesHeader: Record "Sales Header"; var DocumentNo: Text; var StartDateStr: Text; var EndDateStr: Text)
+ var
+ SourceSalesHeaderRecId: RecordId;
+ SourceDocumentRecIdTxt: Text;
+ begin
+ SourceDocumentRecIdTxt := CustomDimension.Get(SourceDocumentRecordIDLbl);
+ if SourceDocumentRecIdTxt <> '' then begin
+ SourceSalesHeader.SetLoadFields("No.", "Sell-to Customer No.", "Sell-to Customer Name");
+ Evaluate(SourceSalesHeaderRecId, SourceDocumentRecIdTxt);
+ if SourceSalesHeaderRecId.TableNo = Database::"Sales Header" then begin
+ SourceSalesHeaderRecId.GetRecord().SetTable(SourceSalesHeader);
+ SourceSalesHeader.Get(SourceSalesHeader."Document Type", SourceSalesHeader."No.");
+ end;
+ end;
+ DocumentNo := CustomDimension.Get('DocumentNo');
+ StartDateStr := CustomDimension.Get('StartDateStr');
+ EndDateStr := CustomDimension.Get('EndDateStr');
+ end;
+
+ [TryFunction]
+ local procedure GetDocumentFromUserInput(var DocumentNo: Text; var StartDate: Text; var EndDate: Text; var DocLookupSubType: Enum "Document Lookup Types"; ItemResultsArray: JsonArray)
+ var
+ JsonItem: JsonToken;
+ DocumentNoToken: JsonToken;
+ DocumentTypeToken: JsonToken;
+ UnknownDocTypeErr: Label 'Copilot does not support the specified document type. Please rephrase the description';
+ NoDocumentFoundErr: Label 'Copilot could not find the document. Please rephrase the description';
+ begin
+ if ItemResultsArray.Get(0, JsonItem) then
+ if JsonItem.AsObject().Get('document_type', DocumentTypeToken) then begin
+ case DocumentTypeToken.AsValue().AsText() of
+ 'sales_order':
+ DocLookupSubType := DocLookupSubType::"Sales Order";
+ 'sales_invoice':
+ DocLookupSubType := DocLookupSubType::"Posted Sales Invoice";
+ 'sales_shipment':
+ DocLookupSubType := DocLookupSubType::"Posted Sales Shipment";
+ 'sales_quote':
+ DocLookupSubType := DocLookupSubType::"Sales Quote";
+ 'sales_blanket_order':
+ DocLookupSubType := DocLookupSubType::"Blanket Sales Order";
+ else
+ Error(UnknownDocTypeErr);
+ end;
+
+ if JsonItem.AsObject().Get('document_number', DocumentNoToken) then
+ DocumentNo := DocumentNoToken.AsValue().AsText();
+
+ if JsonItem.AsObject().Get('start_date', DocumentTypeToken) then
+ StartDate := DocumentTypeToken.AsValue().AsText();
+
+ if JsonItem.AsObject().Get('end_date', DocumentTypeToken) then
+ EndDate := DocumentTypeToken.AsValue().AsText();
+ end else
+ Error(NoDocumentFoundErr);
+ end;
+}
\ No newline at end of file
diff --git a/Apps/W1/SalesLinesSuggestions/app/SalesLineAISuggestions.Page.al b/Apps/W1/SalesLinesSuggestions/app/SalesLineAISuggestions.Page.al
index 3af7c45591..15c209d193 100644
--- a/Apps/W1/SalesLinesSuggestions/app/SalesLineAISuggestions.Page.al
+++ b/Apps/W1/SalesLinesSuggestions/app/SalesLineAISuggestions.Page.al
@@ -141,11 +141,11 @@ page 7275 "Sales Line AI Suggestions"
#pragma warning restore AW0005
Caption = 'Copy from order [No.]';
- ToolTip = 'Sample prompt for copying line items from another sales document. Text in brackets specifies the document no.';
+ ToolTip = 'Sample prompt for copying line items from another sales order. Text in brackets refers to the order.';
trigger OnAction()
var
- CopyFromLbl: Label 'Copy from order ';
+ CopyFromLbl: Label 'Copy from sales order ';
begin
SearchQueryTxt := CopyFromLbl;
CurrPage.Update(false);
@@ -156,12 +156,12 @@ page 7275 "Sales Line AI Suggestions"
{
#pragma warning restore AW0005
- Caption = 'Copy from invoice [No.]';
- ToolTip = 'Sample prompt for copying line items from another sales document. Text in brackets specifies the document no.';
+ Caption = 'Copy from posted invoice [No.]';
+ ToolTip = 'Sample prompt for copying line items from a posted sales invoice. Text in brackets refers to the invoice.';
trigger OnAction()
var
- CopyFromLbl: Label 'Copy from invoice ';
+ CopyFromLbl: Label 'Copy from sales invoice ';
begin
SearchQueryTxt := CopyFromLbl;
CurrPage.Update(false);
@@ -171,12 +171,27 @@ page 7275 "Sales Line AI Suggestions"
action(DocumentSearchCopyFromLastInvoicePrompt)
{
#pragma warning restore AW0005
- Caption = 'Copy from the last invoice';
+ Caption = 'Copy from the last posted invoice';
ToolTip = 'Sample prompt for copying line items from the customer''s latest posted sales invoice.';
trigger OnAction()
var
- CopyFromLbl: Label 'Copy from the last invoice';
+ CopyFromLbl: Label 'Copy from the last sales invoice';
+ begin
+ SearchQueryTxt := CopyFromLbl;
+ CurrPage.Update(false);
+ end;
+ }
+#pragma warning disable AW0005
+ action(CopyItemsFromDocumentPrompt)
+#pragma warning restore AW0005
+ {
+ Caption = 'Copy items [description] from posted invoice [No.]';
+ ToolTip = 'Sample prompt for copying specific items from another posted sales invoice. Texts in brackets specify item description and invoice number.';
+
+ trigger OnAction()
+ var
+ CopyFromLbl: Label 'Copy specific items from sales invoice ';
begin
SearchQueryTxt := CopyFromLbl;
CurrPage.Update(false);
diff --git a/Apps/W1/SalesLinesSuggestions/app/SalesLineAISuggestions.Table.al b/Apps/W1/SalesLinesSuggestions/app/SalesLineAISuggestions.Table.al
index 75f257ba82..cad8a6533f 100644
--- a/Apps/W1/SalesLinesSuggestions/app/SalesLineAISuggestions.Table.al
+++ b/Apps/W1/SalesLinesSuggestions/app/SalesLineAISuggestions.Table.al
@@ -12,6 +12,7 @@ table 7275 "Sales Line AI Suggestions"
TableType = Temporary;
InherentEntitlements = X;
InherentPermissions = RIMDX;
+ Caption = 'Sales Line AI Suggestion';
Access = Internal;
fields
@@ -63,6 +64,13 @@ table 7275 "Sales Line AI Suggestions"
{
Caption = 'Source Line Record ID';
}
+ field(5407; "Unit of Measure Code"; Code[10])
+ {
+ Caption = 'Unit of Measure Code';
+ ToolTip = 'Specifies the unit of measure code of the item on the line.';
+ TableRelation = "Item Unit of Measure".Code where("Item No." = field("No."));
+ ValidateTableRelation = false;
+ }
}
keys
diff --git a/Apps/W1/SalesLinesSuggestions/app/SalesLineAISuggestionsSub.Page.al b/Apps/W1/SalesLinesSuggestions/app/SalesLineAISuggestionsSub.Page.al
index 2fa2aefc8e..ed9165dfda 100644
--- a/Apps/W1/SalesLinesSuggestions/app/SalesLineAISuggestionsSub.Page.al
+++ b/Apps/W1/SalesLinesSuggestions/app/SalesLineAISuggestionsSub.Page.al
@@ -61,6 +61,10 @@ page 7276 "Sales Line AI Suggestions Sub"
{
ToolTip = 'Specifies the quantity of the suggested result.';
}
+ field("Unit of Measure Code"; Rec."Unit of Measure Code")
+ {
+ ToolTip = 'Specifies the unit of measure code of the suggested result.';
+ }
field(Confidence; Rec.Confidence)
{
StyleExpr = StyleExprText;
diff --git a/Apps/W1/SalesLinesSuggestions/app/SalesLinesSuggestionsImpl.Codeunit.al b/Apps/W1/SalesLinesSuggestions/app/SalesLinesSuggestionsImpl.Codeunit.al
index 9563c6e742..2da6b0d708 100644
--- a/Apps/W1/SalesLinesSuggestions/app/SalesLinesSuggestionsImpl.Codeunit.al
+++ b/Apps/W1/SalesLinesSuggestions/app/SalesLinesSuggestionsImpl.Codeunit.al
@@ -97,8 +97,7 @@ codeunit 7275 "Sales Lines Suggestions Impl."
AOAIFunctionResponse: Codeunit "AOAI Function Response";
AOAIChatCompletionParams: Codeunit "AOAI Chat Completion Params";
AOAIChatMessages: Codeunit "AOAI Chat Messages";
- DocumentLookup: Codeunit "Document Lookup Function";
- SearchItemsFunction: Codeunit "Search Items Function";
+ SearchItemsWithFiltersFunc: Codeunit "Search Items With Filters Func";
MagicFunction: Codeunit "Magic Function";
FeatureTelemetry: Codeunit "Feature Telemetry";
NotificationManager: Codeunit "Notification Manager";
@@ -119,15 +118,12 @@ codeunit 7275 "Sales Lines Suggestions Impl."
AOAIChatCompletionParams.SetMaxTokens(MaxTokens());
AOAIChatCompletionParams.SetTemperature(0);
- SearchItemsFunction.SetSearchQuery(SearchQuery);
- SearchItemsFunction.SetSearchStyle(SearchStyle);
- DocumentLookup.SetSearchQuery(SearchQuery);
- DocumentLookup.SetSourceDocumentRecordId(SourceSalesHeader.RecordId);
- DocumentLookup.SetSearchStyle(SearchStyle);
+ SearchItemsWithFiltersFunc.SetSearchQuery(SearchQuery);
+ SearchItemsWithFiltersFunc.SetSourceDocumentRecordId(SourceSalesHeader.RecordId);
+ SearchItemsWithFiltersFunc.SetSearchStyle(SearchStyle);
AOAIChatMessages.AddTool(MagicFunction);
- AOAIChatMessages.AddTool(SearchItemsFunction);
- AOAIChatMessages.AddTool(DocumentLookup);
+ AOAIChatMessages.AddTool(SearchItemsWithFiltersFunc);
AOAIChatMessages.SetToolChoice('auto');
AOAIChatMessages.SetPrimarySystemMessage(SystemPromptTxt);
diff --git a/Apps/W1/SalesLinesSuggestions/app/Search/Search.Codeunit.al b/Apps/W1/SalesLinesSuggestions/app/Search/Search.Codeunit.al
index da76030915..40632f761a 100644
--- a/Apps/W1/SalesLinesSuggestions/app/Search/Search.Codeunit.al
+++ b/Apps/W1/SalesLinesSuggestions/app/Search/Search.Codeunit.al
@@ -6,6 +6,7 @@ namespace Microsoft.Sales.Document;
using System;
using System.Telemetry;
+using Microsoft.Foundation.UOM;
using Microsoft.Inventory.Item;
using System.AI;
using System.Security.Encryption;
@@ -34,10 +35,12 @@ codeunit 7282 "Search"
SearchProgress: Dialog;
ItemToken: JsonToken;
QuantityToken: JsonToken;
+ UOMToken: JsonToken;
NameJsonToken: JsonToken;
SearchPrimaryKeyWords: List of [Text];
SearchAdditionalKeyWords: List of [Text];
Quantity: Decimal;
+ UnitOfMeasure: Text;
TelemetryCD: Dictionary of [Text, Text];
StartDateTime: DateTime;
DurationAsBigInt: BigInteger;
@@ -115,10 +118,17 @@ codeunit 7282 "Search"
//Process Search Results
foreach ItemToken in ItemResultsArray do begin
+ Quantity := 0;
+ UnitOfMeasure := '';
+
ItemToken.WriteTo(ItemTokentText);
if ItemToken.AsObject().Get('quantity', QuantityToken) then
if (QuantityToken.IsValue() and (QuantityToken.AsValue().AsText() <> '')) then
- Quantity := QuantityToken.AsValue().AsDecimal();
+ if not JsonValueAsDecimal(QuantityToken.AsValue(), Quantity) then
+ Quantity := 0;
+ if ItemToken.AsObject().Get('unit_of_measure', UOMToken) then
+ if (UOMToken.IsValue() and (UOMToken.AsValue().AsText() <> '')) then
+ UnitOfMeasure := UOMToken.AsValue().AsText();
QueryResults := ALSearchResult.GetResultsForQuery(CryptographyManagement.GenerateHash(ItemTokentText, HashAlgorithmType::SHA256));
@@ -132,7 +142,7 @@ codeunit 7282 "Search"
SearchPrimaryKeyWords := GetItemNameKeywords(ItemToken);
SearchAdditionalKeyWords := GetItemFeaturesKeywords(ItemToken);
- GetSalesLineFromItemSystemIds(TempSearchResponse, Quantity, TempSalesLineAiSuggestion, SearchPrimaryKeyWords, SearchAdditionalKeyWords);
+ GetSalesLineFromItemSystemIds(TempSearchResponse, Quantity, UnitOfMeasure, TempSalesLineAiSuggestion, SearchPrimaryKeyWords, SearchAdditionalKeyWords);
end;
end;
end;
@@ -166,10 +176,13 @@ codeunit 7282 "Search"
ALSearchQuery.Top := Top;
end;
- local procedure GetSalesLineFromItemSystemIds(var TempSearchResponse: Record "Search API Response" temporary; Quantity: Decimal; var TempSalesLineAiSuggestion: Record "Sales Line AI Suggestions" temporary; var SearchPrimaryKeyWords: List of [Text];
+ local procedure GetSalesLineFromItemSystemIds(var TempSearchResponse: Record "Search API Response" temporary; Quantity: Decimal; UnitOfMeasureText: Text; var TempSalesLineAiSuggestion: Record "Sales Line AI Suggestions" temporary; var SearchPrimaryKeyWords: List of [Text];
var SearchAdditionalKeyWords: List of [Text])
var
Item: Record "Item";
+ UnitOfMeasure: Record "Unit of Measure";
+ ItemUnitOfMeasure: Record "Item Unit of Measure";
+ UnitOfMeasureCode: Code[10];
LineNumber: Integer;
begin
@@ -184,6 +197,17 @@ codeunit 7282 "Search"
if Item.GetBySystemId(TempSearchResponse.SysId) then begin
Item.SetRecFilter();
+ UnitOfMeasureCode := Item."Sales Unit of Measure";
+ if UnitOfMeasureCode = '' then
+ UnitOfMeasureCode := Item."Base Unit of Measure";
+ UnitOfMeasure.SetRange(Description, UnitOfMeasureText);
+ if UnitOfMeasure.FindFirst() then begin
+ ItemUnitOfMeasure.SetRange("Item No.", Item."No.");
+ ItemUnitOfMeasure.SetRange(Code, UnitOfMeasure.Code);
+ if ItemUnitOfMeasure.FindFirst() then
+ UnitOfMeasureCode := ItemUnitOfMeasure.Code;
+ end;
+
TempSalesLineAiSuggestion.Init();
LineNumber := LineNumber + 1;
TempSalesLineAiSuggestion."Line No." := LineNumber;
@@ -191,6 +215,7 @@ codeunit 7282 "Search"
TempSalesLineAiSuggestion.Description := Item.Description;
TempSalesLineAiSuggestion.Type := "Sales Line Type"::Item;
TempSalesLineAiSuggestion.Quantity := Quantity;
+ TempSalesLineAiSuggestion."Unit of Measure Code" := UnitOfMeasureCode;
TempSalesLineAiSuggestion.Confidence := GetConfidence(TempSearchResponse.Score);
TempSalesLineAiSuggestion.SetPrimarySearchTerms(SearchPrimaryKeyWords);
TempSalesLineAiSuggestion.SetAdditionalSearchTerms(SearchAdditionalKeyWords);
@@ -206,9 +231,14 @@ codeunit 7282 "Search"
SearchKeywords: List of [Text];
SearchKeyword: Text;
begin
- if ItemObjectToken.AsObject().Get('name', JsonToken) then begin
- SearchKeyword := JsonToken.AsValue().AsText();
- if ItemObjectToken.AsObject().Get('synonyms', JsonToken) then begin
+ if ItemObjectToken.AsObject().Get('split_name_terms', JsonToken) then begin
+ JsonArray := JsonToken.AsArray();
+ foreach JsonToken in JsonArray do
+ if SearchKeyword = '' then
+ SearchKeyword := JsonToken.AsValue().AsText()
+ else
+ SearchKeyword := SearchKeyword + '|' + JsonToken.AsValue().AsText();
+ if ItemObjectToken.AsObject().Get('common_synonyms_of_name', JsonToken) then begin
JsonArray := JsonToken.AsArray();
foreach JsonToken in JsonArray do
SearchKeyword := SearchKeyword + '|' + JsonToken.AsValue().AsText();
@@ -245,4 +275,10 @@ codeunit 7282 "Search"
exit("Search Confidence"::None);
end;
+
+ [TryFunction]
+ local procedure JsonValueAsDecimal(JsonValue: JsonValue; var Value: Decimal)
+ begin
+ Value := JsonValue.AsDecimal();
+ end;
}
\ No newline at end of file
diff --git a/Apps/W1/SalesLinesSuggestions/app/Search/SearchAPIResponse.Table.al b/Apps/W1/SalesLinesSuggestions/app/Search/SearchAPIResponse.Table.al
index 0bf2464a02..67835885da 100644
--- a/Apps/W1/SalesLinesSuggestions/app/Search/SearchAPIResponse.Table.al
+++ b/Apps/W1/SalesLinesSuggestions/app/Search/SearchAPIResponse.Table.al
@@ -10,6 +10,7 @@ table 7276 "Search API Response"
TableType = Temporary;
InherentEntitlements = X;
InherentPermissions = X;
+ Caption = 'Search API Response';
fields
{
diff --git a/Apps/W1/SalesLinesSuggestions/app/Search/SearchConfidence.Enum.al b/Apps/W1/SalesLinesSuggestions/app/Search/SearchConfidence.Enum.al
index ec1ae8109b..a1d14bae95 100644
--- a/Apps/W1/SalesLinesSuggestions/app/Search/SearchConfidence.Enum.al
+++ b/Apps/W1/SalesLinesSuggestions/app/Search/SearchConfidence.Enum.al
@@ -11,14 +11,18 @@ enum 7276 "Search Confidence"
value(0; "None")
{
+ Caption = 'None';
}
value(1; "Low")
{
+ Caption = 'Low';
}
value(2; "Medium")
{
+ Caption = 'Medium';
}
value(3; "High")
{
+ Caption = 'High';
}
}
\ No newline at end of file
diff --git a/Apps/W1/SalesLinesSuggestions/app/Utilities/SalesLineUtility.Codeunit.al b/Apps/W1/SalesLinesSuggestions/app/Utilities/SalesLineUtility.Codeunit.al
index 205c8204d0..d96d8420f9 100644
--- a/Apps/W1/SalesLinesSuggestions/app/Utilities/SalesLineUtility.Codeunit.al
+++ b/Apps/W1/SalesLinesSuggestions/app/Utilities/SalesLineUtility.Codeunit.al
@@ -16,6 +16,7 @@ codeunit 7280 "Sales Line Utility"
ProcessingLinesLbl: Label 'Processing lines... \#1#########################################################################################', Comment = '#1 = PreparingSalesLineLbl or InsertingSalesLineLbl ';
PreparingSalesLineLbl: Label 'Preparing %1 of %2', Comment = '%1 = Counter, %2 = Total Lines';
InsertingSalesLineLbl: Label 'Inserting %1 of %2', Comment = '%1 = Counter, %2 = Total Lines';
+ CopyingFromBlanketOrderLbl: Label 'Copying from Blanket Order...';
SalesLineValidationErr: Label 'There was an error while validating the line with No. %1, Description %2.\Error: %3', Comment = '%1 = No., %2 = Description, %3 = Error Message';
SalesLineCopyErr: Label 'There was an error while copying the line with No. %1, Description %2, Quantity %3.', Comment = '%1 = No., %2 = Description, %3 = Quantity';
@@ -35,8 +36,12 @@ codeunit 7280 "Sales Line Utility"
NextLineNo := 0;
LinesNotCopied := 0;
- PrepareSalesLine(SalesHeader, TempFromSalesLine, TempSalesLineAiSuggestion, NextLineNo);
- CopySalesLineToDoc(SalesHeader, TempFromSalesLine, LinesNotCopied, NextLineNo);
+ if IsBlanketOrder(TempSalesLineAiSuggestion) then
+ CreateFromBlanketOrder(SalesHeader, TempSalesLineAiSuggestion, NextLineNo)
+ else begin
+ PrepareSalesLine(SalesHeader, TempFromSalesLine, TempSalesLineAiSuggestion, NextLineNo);
+ CopySalesLineToDoc(SalesHeader, TempFromSalesLine, LinesNotCopied, NextLineNo);
+ end;
end;
local procedure CopySalesLineToDoc(var ToSalesHeader: Record "Sales Header"; var FromSalesLine: Record "Sales Line" temporary; var LinesNotCopied: Integer; NextLineNo: Integer)
@@ -73,6 +78,52 @@ codeunit 7280 "Sales Line Utility"
end;
end;
+ local procedure IsBlanketOrder(var TempSalesLineAiSuggestion: Record "Sales Line AI Suggestions" temporary): Boolean
+ var
+ SalesLine: Record "Sales Line";
+ begin
+ if not TempSalesLineAiSuggestion.FindFirst() then
+ exit(false);
+
+ if TempSalesLineAiSuggestion."Source Line Record ID".TableNo = Database::"Sales Line" then
+ TempSalesLineAiSuggestion."Source Line Record ID".GetRecord().SetTable(SalesLine);
+
+ exit(SalesLine."Document Type" = SalesLine."Document Type"::"Blanket Order");
+ end;
+
+ local procedure CreateFromBlanketOrder(var ToSalesHeader: Record "Sales Header"; var TempSalesLineAiSuggestion: Record "Sales Line AI Suggestions" temporary; NextLineNo: Integer)
+ var
+ BlanketSalesHeader: Record "Sales Header";
+ BlanketSalesLine: Record "Sales Line";
+ FromSalesLine: Record "Sales Line";
+ ToSalesLine: Record "Sales Line";
+ BlanketSalesOrderToOrder: Codeunit "Blanket Sales Order to Order";
+ ProgressDialog: Dialog;
+ begin
+ if TempSalesLineAiSuggestion.FindSet() then begin
+ OpenProgressWindow(ProgressDialog);
+ ProgressDialog.Update(1, CopyingFromBlanketOrderLbl);
+
+ TempSalesLineAiSuggestion."Source Line Record ID".GetRecord().SetTable(BlanketSalesLine);
+ BlanketSalesHeader.Get(BlanketSalesLine."Document Type", BlanketSalesLine."Document No.");
+
+ repeat
+ FromSalesLine.Get(TempSalesLineAiSuggestion."Source Line Record ID");
+ FromSalesLine.Validate("Qty. to Ship", TempSalesLineAiSuggestion.Quantity);
+ FromSalesLine.Modify(true);
+ FromSalesLine.Mark(true);
+ until TempSalesLineAiSuggestion.Next() = 0;
+
+ FromSalesLine.MarkedOnly(true);
+
+ BlanketSalesOrderToOrder.SetHideValidationDialog(true);
+ BlanketSalesOrderToOrder.SetSalesOrderHeader(ToSalesHeader);
+ BlanketSalesOrderToOrder.CreateSalesOrderLines(BlanketSalesHeader, FromSalesLine, ToSalesHeader, ToSalesLine, NextLineNo);
+
+ ProgressDialog.Close();
+ end;
+ end;
+
local procedure PrepareSalesLine(SalesHeader: Record "Sales Header"; var TempSalesLine: Record "Sales Line" temporary; var TempSalesLineAiSuggestion: Record "Sales Line AI Suggestions" temporary; LineNo: Integer)
var
TempPreparedSalesLine: Record "Sales Line" temporary;
diff --git a/Apps/W1/SalesLinesSuggestions/app/app.json b/Apps/W1/SalesLinesSuggestions/app/app.json
index 815940a75c..2e447d6c4f 100644
--- a/Apps/W1/SalesLinesSuggestions/app/app.json
+++ b/Apps/W1/SalesLinesSuggestions/app/app.json
@@ -19,7 +19,7 @@
"idRanges": [
{
"from": 7275,
- "to": 7290
+ "to": 7291
}
],
"resourceExposurePolicy": {
diff --git a/Apps/W1/Shopify/app/src/Base/Pages/ShpfyShopCard.Page.al b/Apps/W1/Shopify/app/src/Base/Pages/ShpfyShopCard.Page.al
index 2db501be67..18fa93e076 100644
--- a/Apps/W1/Shopify/app/src/Base/Pages/ShpfyShopCard.Page.al
+++ b/Apps/W1/Shopify/app/src/Base/Pages/ShpfyShopCard.Page.al
@@ -517,13 +517,6 @@ page 30101 "Shpfy Shop Card"
end;
}
#endif
- field(KeepZeroQuantityLines; Rec."Keep Zero Quantity Lines")
- {
- ApplicationArea = All;
- Caption = 'Keep Zero Quantity Lines';
- ToolTip = 'Specifies whether to keep zero quantity lines in the Shopify order. If you do not select this option, zero quantity lines are removed from the Shopify order.';
- Visible = false;
- }
}
group(ReturnsAndRefunds)
{
diff --git a/Apps/W1/Shopify/app/src/Base/Tables/ShpfyShop.Table.al b/Apps/W1/Shopify/app/src/Base/Tables/ShpfyShop.Table.al
index 0cbe7684bf..d521572415 100644
--- a/Apps/W1/Shopify/app/src/Base/Tables/ShpfyShop.Table.al
+++ b/Apps/W1/Shopify/app/src/Base/Tables/ShpfyShop.Table.al
@@ -778,12 +778,6 @@ table 30102 "Shpfy Shop"
end;
#endif
}
- field(128; "Keep Zero Quantity Lines"; Boolean)
- {
- Caption = 'Keep Zero Quantity Lines';
- DataClassification = SystemMetadata;
- InitValue = false;
- }
field(200; "Shop Id"; Integer)
{
DataClassification = SystemMetadata;
diff --git a/Apps/W1/Shopify/app/src/Companies/Codeunits/ShpfyCompanyAPI.Codeunit.al b/Apps/W1/Shopify/app/src/Companies/Codeunits/ShpfyCompanyAPI.Codeunit.al
index 7b440f4430..3e7c83de19 100644
--- a/Apps/W1/Shopify/app/src/Companies/Codeunits/ShpfyCompanyAPI.Codeunit.al
+++ b/Apps/W1/Shopify/app/src/Companies/Codeunits/ShpfyCompanyAPI.Codeunit.al
@@ -341,6 +341,7 @@ codeunit 30286 "Shpfy Company API"
PhoneNo := JsonHelper.GetValueAsText(JItem, 'node.billingAddress.phone');
PhoneNo := CopyStr(DelChr(PhoneNo, '=', DelChr(PhoneNo, '=', '1234567890/+ .()')), 1, MaxStrLen(CompanyLocation."Phone No."));
CompanyLocation."Phone No." := CopyStr(PhoneNo, 1, MaxStrLen(CompanyLocation."Phone No."));
+ CompanyLocation."Tax Registration Id" := CopyStr(JsonHelper.GetValueAsText(JItem, 'node.taxRegistrationId', MaxStrLen(CompanyLocation."Tax Registration Id")), 1, MaxStrLen(CompanyLocation."Tax Registration Id"));
CompanyLocation.Modify();
end;
end;
diff --git a/Apps/W1/Shopify/app/src/Companies/Pages/ShpfyCompanyCard.Page.al b/Apps/W1/Shopify/app/src/Companies/Pages/ShpfyCompanyCard.Page.al
index 92c2668c82..8980b7073f 100644
--- a/Apps/W1/Shopify/app/src/Companies/Pages/ShpfyCompanyCard.Page.al
+++ b/Apps/W1/Shopify/app/src/Companies/Pages/ShpfyCompanyCard.Page.al
@@ -39,6 +39,13 @@ page 30157 "Shpfy Company Card"
Caption = 'Note';
ToolTip = 'Specifies a note about the customer in Shopify.';
}
+ field(TaxId; TaxRegistrationId)
+ {
+ ApplicationArea = All;
+ Caption = 'Tax Id';
+ ToolTip = 'Specifies the company''s tax ID.';
+ Editable = false;
+ }
}
group(Mapping)
@@ -163,15 +170,14 @@ page 30157 "Shpfy Company Card"
var
Customer: Record Customer;
CustomerNo: Code[20];
+ TaxRegistrationId: Text[150];
trigger OnAfterGetCurrRecord()
begin
GetMappedCustomer();
+ GetTaxRegisrationId();
end;
- ///
- /// Get Mapped Customer.
- ///
local procedure GetMappedCustomer()
begin
if IsNullGuid(Rec."Customer SystemId") then begin
@@ -185,4 +191,12 @@ page 30157 "Shpfy Company Card"
Clear(CustomerNo);
end;
end;
+
+ local procedure GetTaxRegisrationId()
+ var
+ CompanyLocation: Record "Shpfy Company Location";
+ begin
+ if CompanyLocation.Get(Rec."Location Id") then
+ TaxRegistrationId := CompanyLocation."Tax Registration Id";
+ end;
}
diff --git a/Apps/W1/Shopify/app/src/Companies/Tables/ShpfyCompanyLocation.Table.al b/Apps/W1/Shopify/app/src/Companies/Tables/ShpfyCompanyLocation.Table.al
index d73ca0e433..f94a8a2f33 100644
--- a/Apps/W1/Shopify/app/src/Companies/Tables/ShpfyCompanyLocation.Table.al
+++ b/Apps/W1/Shopify/app/src/Companies/Tables/ShpfyCompanyLocation.Table.al
@@ -68,6 +68,11 @@ table 30151 "Shpfy Company Location"
Caption = 'Province Name';
DataClassification = CustomerContent;
}
+ field(12; "Tax Registration Id"; Text[150])
+ {
+ Caption = 'Tax Registration Id';
+ DataClassification = CustomerContent;
+ }
}
keys
{
diff --git a/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLCompany.Codeunit.al b/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLCompany.Codeunit.al
index 1e836f24f7..e6a5806e2a 100644
--- a/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLCompany.Codeunit.al
+++ b/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLCompany.Codeunit.al
@@ -13,7 +13,7 @@ codeunit 30302 "Shpfy GQL Company" implements "Shpfy IGraphQL"
/// Return value of type Text.
internal procedure GetGraphQL(): Text
begin
- exit('{"query":"{company(id: \"gid://shopify/Company/{{CompanyId}}\") {name id note createdAt updatedAt mainContact { id customer { id firstName lastName email phone}} locations(first:1, sortKey: CREATED_AT ) {edges { node { id name billingAddress {address1 address2 city countryCode phone province zip zoneCode}}}}}}"}');
+ exit('{"query":"{company(id: \"gid://shopify/Company/{{CompanyId}}\") {name id note createdAt updatedAt mainContact { id customer { id firstName lastName email phone}} locations(first:1, sortKey: CREATED_AT ) {edges { node { id name billingAddress {address1 address2 city countryCode phone province zip zoneCode} taxRegistrationId}}}}}"}');
end;
///
diff --git a/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLOrderHeader.Codeunit.al b/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLOrderHeader.Codeunit.al
index e6f4ecc4c8..8dca96eea2 100644
--- a/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLOrderHeader.Codeunit.al
+++ b/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLOrderHeader.Codeunit.al
@@ -6,7 +6,7 @@ codeunit 30207 "Shpfy GQL OrderHeader" implements "Shpfy IGraphQL"
procedure GetGraphQL(): Text
begin
- exit('{"query": "query { order(id: \"gid:\/\/shopify\/Order\/{{OrderId}}\") { legacyResourceId name createdAt confirmed updatedAt cancelReason cancelledAt closed closedAt currentSubtotalLineItemsQuantity test email phone poNumber customer { legacyResourceId email phone defaultAddress { id phone }} displayAddress { id firstName lastName company address1 address2 zip city provinceCode province countryCode country phone } shippingAddress { id name firstName lastName company address1 address2 zip city provinceCode province countryCode country phone latitude longitude } billingAddressMatchesShippingAddress billingAddress { id name firstName lastName company address1 address2 zip city provinceCode province countryCode country phone } publication { name } app { name } currencyCode presentmentCurrencyCode fullyPaid unpaid location physicalLocation { legacyResourceId name } note customAttributes { key value } discountCode displayFinancialStatus displayFulfillmentStatus edited totalWeight refundable returnStatus riskLevel risks(first: 10) { level display message } tags paymentGatewayNames processedAt requiresShipping sourceIdentifier paymentTerms { id dueInDays paymentTermsName paymentTermsType translatedName } taxesIncluded cartDiscountAmountSet { presentmentMoney { amount } shopMoney { amount }} currentCartDiscountAmountSet { presentmentMoney { amount } shopMoney { amount }} currentSubtotalPriceSet { presentmentMoney { amount } shopMoney { amount }} currentTotalDiscountsSet { presentmentMoney { amount } shopMoney { amount }} currentTotalDutiesSet { presentmentMoney { amount } shopMoney { amount }} currentTotalPriceSet { presentmentMoney { amount } shopMoney { amount }} currentTotalTaxSet { presentmentMoney { amount } shopMoney { amount }} netPaymentSet { presentmentMoney { amount } shopMoney { amount }} originalTotalDutiesSet { presentmentMoney { amount } shopMoney { amount }} originalTotalPriceSet { presentmentMoney { amount } shopMoney { amount }} refundDiscrepancySet { presentmentMoney { amount } shopMoney { amount }} subtotalPriceSet { presentmentMoney { amount } shopMoney { amount }} totalCapturableSet { presentmentMoney { amount } shopMoney { amount }} totalDiscountsSet { presentmentMoney { amount } shopMoney { amount }} totalOutstandingSet { presentmentMoney { amount } shopMoney { amount }} totalPriceSet { presentmentMoney { amount } shopMoney { amount }} totalReceivedSet { presentmentMoney { amount } shopMoney { amount }} totalRefundedSet { presentmentMoney { amount } shopMoney { amount }} totalRefundedShippingSet { presentmentMoney { amount } shopMoney { amount }} totalShippingPriceSet { presentmentMoney { amount } shopMoney { amount }} totalTaxSet { presentmentMoney { amount } shopMoney { amount }} totalTipReceivedSet { presentmentMoney { amount } shopMoney { amount }} taxLines { channelLiable rate ratePercentage title priceSet { presentmentMoney { amount } shopMoney { amount }}} refunds { legacyResourceId updatedAt } returns(first: 20) { pageInfo { endCursor hasNextPage } nodes { id }} purchasingEntity { ... on PurchasingCompany { company { id name mainContact { id customer { legacyResourceId email phone }}} location { id }}}}}"}');
+ exit('{"query": "query { order(id: \"gid:\/\/shopify\/Order\/{{OrderId}}\") { legacyResourceId name createdAt confirmed updatedAt cancelReason cancelledAt closed closedAt currentSubtotalLineItemsQuantity test email phone poNumber customer { legacyResourceId email phone defaultAddress { id phone }} displayAddress { id firstName lastName company address1 address2 zip city provinceCode province countryCode country phone } shippingAddress { id name firstName lastName company address1 address2 zip city provinceCode province countryCode country phone latitude longitude } billingAddressMatchesShippingAddress billingAddress { id name firstName lastName company address1 address2 zip city provinceCode province countryCode country phone } publication { name } app { name } currencyCode presentmentCurrencyCode fullyPaid unpaid note customAttributes { key value } discountCode displayFinancialStatus displayFulfillmentStatus edited totalWeight refundable returnStatus riskLevel risks(first: 10) { level display message } tags paymentGatewayNames processedAt requiresShipping sourceIdentifier paymentTerms { id dueInDays paymentTermsName paymentTermsType translatedName } taxesIncluded cartDiscountAmountSet { presentmentMoney { amount } shopMoney { amount }} currentCartDiscountAmountSet { presentmentMoney { amount } shopMoney { amount }} currentSubtotalPriceSet { presentmentMoney { amount } shopMoney { amount }} currentTotalDiscountsSet { presentmentMoney { amount } shopMoney { amount }} currentTotalDutiesSet { presentmentMoney { amount } shopMoney { amount }} currentTotalPriceSet { presentmentMoney { amount } shopMoney { amount }} currentTotalTaxSet { presentmentMoney { amount } shopMoney { amount }} netPaymentSet { presentmentMoney { amount } shopMoney { amount }} originalTotalDutiesSet { presentmentMoney { amount } shopMoney { amount }} originalTotalPriceSet { presentmentMoney { amount } shopMoney { amount }} refundDiscrepancySet { presentmentMoney { amount } shopMoney { amount }} subtotalPriceSet { presentmentMoney { amount } shopMoney { amount }} totalCapturableSet { presentmentMoney { amount } shopMoney { amount }} totalDiscountsSet { presentmentMoney { amount } shopMoney { amount }} totalOutstandingSet { presentmentMoney { amount } shopMoney { amount }} totalPriceSet { presentmentMoney { amount } shopMoney { amount }} totalReceivedSet { presentmentMoney { amount } shopMoney { amount }} totalRefundedSet { presentmentMoney { amount } shopMoney { amount }} totalRefundedShippingSet { presentmentMoney { amount } shopMoney { amount }} totalShippingPriceSet { presentmentMoney { amount } shopMoney { amount }} totalTaxSet { presentmentMoney { amount } shopMoney { amount }} totalTipReceivedSet { presentmentMoney { amount } shopMoney { amount }} taxLines { channelLiable rate ratePercentage title priceSet { presentmentMoney { amount } shopMoney { amount }}} refunds { legacyResourceId updatedAt } returns(first: 20) { pageInfo { endCursor hasNextPage } nodes { id }} purchasingEntity { ... on PurchasingCompany { company { id name mainContact { id customer { legacyResourceId email phone }}} location { id }}}}}"}');
end;
procedure GetExpectedCost(): Integer
diff --git a/Apps/W1/Shopify/app/src/Order handling/Codeunits/ShpfyImportOrder.Codeunit.al b/Apps/W1/Shopify/app/src/Order handling/Codeunits/ShpfyImportOrder.Codeunit.al
index a92bb50c4e..7fbd4921da 100644
--- a/Apps/W1/Shopify/app/src/Order handling/Codeunits/ShpfyImportOrder.Codeunit.al
+++ b/Apps/W1/Shopify/app/src/Order handling/Codeunits/ShpfyImportOrder.Codeunit.al
@@ -112,8 +112,7 @@ codeunit 30161 "Shpfy Import Order"
OrderFulfillments.GetFulfillments(Shop, OrderHeader."Shopify Order Id");
ConsiderRefundsInQuantityAndAmounts(OrderHeader);
- if not Shop."Keep Zero Quantity Lines" then
- DeleteZeroQuantityLines(OrderHeader);
+ DeleteZeroQuantityLines(OrderHeader);
if CheckToCloseOrder(OrderHeader) then
CloseOrder(OrderHeader);
@@ -207,6 +206,7 @@ codeunit 30161 "Shpfy Import Order"
OrderHeader."Presentment Subtotal Amount" -= RefundLine."Presentment Subtotal Amount";
OrderHeader."VAT Amount" -= RefundLine."Total Tax Amount";
OrderHeader."Presentment VAT Amount" -= RefundLine."Presentment Total Tax Amount";
+ OrderEvents.OnAfterConsiderRefundsInQuantityAndAmounts(OrderHeader, OrderLine, RefundLine);
until OrderLine.Next() = 0;
OrderHeader.Modify();
end;
diff --git a/Apps/W1/Shopify/app/src/Order handling/Codeunits/ShpfyOrderEvents.Codeunit.al b/Apps/W1/Shopify/app/src/Order handling/Codeunits/ShpfyOrderEvents.Codeunit.al
index 0fcc3adfad..2bcf4bc5b1 100644
--- a/Apps/W1/Shopify/app/src/Order handling/Codeunits/ShpfyOrderEvents.Codeunit.al
+++ b/Apps/W1/Shopify/app/src/Order handling/Codeunits/ShpfyOrderEvents.Codeunit.al
@@ -226,4 +226,15 @@ codeunit 30162 "Shpfy Order Events"
internal procedure OnAfterMapCompany(var ShopifyOrderHeader: Record "Shpfy Order Header")
begin
end;
+
+ [IntegrationEvent(false, false)]
+ ///
+ /// Raised after refunds are deducted from the quantity and amounts of the orders.
+ ///
+ /// Parameter of type Record "Shopify Order Header".
+ /// Parameter of type Record "Shopify Order Line".
+ /// Parameter of type Record "Shopify Refund Line".
+ internal procedure OnAfterConsiderRefundsInQuantityAndAmounts(OrderHeader: Record "Shpfy Order Header"; var OrderLine: Record "Shpfy Order Line"; RefundLine: Record "Shpfy Refund Line")
+ begin
+ end;
}
diff --git a/Apps/W1/Shopify/app/src/Order handling/Codeunits/ShpfyOrdersAPI.Codeunit.al b/Apps/W1/Shopify/app/src/Order handling/Codeunits/ShpfyOrdersAPI.Codeunit.al
index 4af1062b69..a2e7904454 100644
--- a/Apps/W1/Shopify/app/src/Order handling/Codeunits/ShpfyOrdersAPI.Codeunit.al
+++ b/Apps/W1/Shopify/app/src/Order handling/Codeunits/ShpfyOrdersAPI.Codeunit.al
@@ -113,7 +113,7 @@ codeunit 30165 "Shpfy Orders API"
/// Parameter of type Record "Shpfy Shop".
internal procedure AddOrderAttribute(OrderHeader: Record "Shpfy Order Header"; KeyName: Text; Value: Text; ShopifyShop: Record "Shpfy Shop")
#else
- internal procedure AddOrderAttribute(OrderHeader: Record "Shpfy Order Header"; KeyName: Text; Value: Text)
+ internal procedure AddOrderAttribute(OrderHeader: Record "Shpfy Order Header"; KeyName: Text; Value: Text; ShopifyShop: Record "Shpfy Shop")
#endif
var
OrderAttribute: Record "Shpfy Order Attribute";
@@ -121,6 +121,7 @@ codeunit 30165 "Shpfy Orders API"
JAttributes: JsonArray;
JAttrib: JsonObject;
begin
+ CommunicationMgt.SetShop(ShopifyShop);
if CommunicationMgt.GetTestInProgress() then
exit;
Clear(OrderAttribute);
diff --git a/Apps/W1/Shopify/app/src/Order handling/Codeunits/ShpfyProcessOrder.Codeunit.al b/Apps/W1/Shopify/app/src/Order handling/Codeunits/ShpfyProcessOrder.Codeunit.al
index afc8ec9ef4..82209b7f75 100644
--- a/Apps/W1/Shopify/app/src/Order handling/Codeunits/ShpfyProcessOrder.Codeunit.al
+++ b/Apps/W1/Shopify/app/src/Order handling/Codeunits/ShpfyProcessOrder.Codeunit.al
@@ -58,7 +58,6 @@ codeunit 30166 "Shpfy Process Order"
/// Parameter of type Record "Shopify Order Header".
local procedure CreateHeaderFromShopifyOrder(var SalesHeader: Record "Sales Header"; ShopifyOrderHeader: Record "Shpfy Order Header")
var
- ShopLocation: Record "Shpfy Shop Location";
ShopifyTaxArea: Record "Shpfy Tax Area";
DocLinkToBCDoc: Record "Shpfy Doc. Link To Doc.";
OrdersAPI: Codeunit "Shpfy Orders API";
@@ -115,8 +114,6 @@ codeunit 30166 "Shpfy Process Order"
SalesHeader."Shpfy Order No." := ShopifyOrderHeader."Shopify Order No.";
SalesHeader.Validate("Document Date", ShopifyOrderHeader."Document Date");
SalesHeader.Validate("External Document No.", ShopifyOrderHeader."PO Number");
- if ShopLocation.Get(ShopifyOrderHeader."Shop Code", ShopifyOrderHeader."Location Id") and (ShopLocation."Default Location Code" <> '') then
- SalesHeader.Validate("Location Code", ShopLocation."Default Location Code");
if OrderMgt.FindTaxArea(ShopifyOrderHeader, ShopifyTaxArea) and (ShopifyTaxArea."Tax Area Code" <> '') then
SalesHeader.Validate("Tax Area Code", ShopifyTaxArea."Tax Area Code");
if ShopifyOrderHeader."Shipping Method Code" <> '' then
@@ -136,11 +133,7 @@ codeunit 30166 "Shpfy Process Order"
if ShopifyOrderHeader."Work Description".HasValue then
SalesHeader.SetWorkDescription(ShopifyOrderHeader.GetWorkDescription());
end;
-#if not CLEAN24
OrdersAPI.AddOrderAttribute(ShopifyOrderHeader, 'BC Doc. No.', SalesHeader."No.", ShopifyShop);
-#else
- OrdersAPI.AddOrderAttribute(ShopifyOrderHeader, 'BC Doc. No.', SalesHeader."No.");
-#endif
DocLinkToBCDoc.Init();
DocLinkToBCDoc."Shopify Document Type" := "Shpfy Shop Document Type"::"Shopify Shop Order";
DocLinkToBCDoc."Shopify Document Id" := ShopifyOrderHeader."Shopify Order Id";
@@ -217,16 +210,10 @@ codeunit 30166 "Shpfy Process Order"
end else begin
SalesLine.Validate(Type, SalesLine.Type::Item);
SalesLine.Validate("No.", ShopifyOrderLine."Item No.");
- if Item.Get(SalesLine."No.") then begin
+ if Item.Get(SalesLine."No.") then
if (ShopifyOrderLine."Location Id" <> 0) then
- if ShopLocation.Get(ShopifyOrderHeader."Shop Code", ShopifyOrderLine."Location Id") then
+ if ShopLocation.Get(ShopifyOrderHeader."Shop Code", ShopifyOrderLine."Location Id") and (ShopLocation."Default Location Code" <> '') then
SalesLine.Validate("Location Code", ShopLocation."Default Location Code");
- if (ShopifyOrderLine."Location Id" <> 0)
- and ShopLocation.Get(ShopifyOrderHeader."Shop Code", ShopifyOrderLine."Location Id")
- and (ShopLocation."Default Location Code" <> '')
- then
- SalesLine.Validate("Location Code", ShopLocation."Default Location Code");
- end;
end;
SalesLine.Validate("Unit of Measure Code", ShopifyOrderLine."Unit of Measure Code");
SalesLine.Validate("Variant Code", ShopifyOrderLine."Variant Code");
diff --git a/Apps/W1/Shopify/app/src/Order handling/Tables/ShpfyOrderHeader.Table.al b/Apps/W1/Shopify/app/src/Order handling/Tables/ShpfyOrderHeader.Table.al
index 16fabfc966..b71f4c1934 100644
--- a/Apps/W1/Shopify/app/src/Order handling/Tables/ShpfyOrderHeader.Table.al
+++ b/Apps/W1/Shopify/app/src/Order handling/Tables/ShpfyOrderHeader.Table.al
@@ -443,6 +443,14 @@ table 30118 "Shpfy Order Header"
Caption = 'Location Id';
DataClassification = CustomerContent;
Editable = false;
+ ObsoleteReason = 'Location Id on Order Header is not used. Instead use Location Id on Order Lines.';
+#if not CLEAN25
+ ObsoleteState = Pending;
+ ObsoleteTag = '25.0';
+#else
+ ObsoleteState = Removed;
+ ObsoleteTag = '28.0';
+#endif
}
field(102; "Channel Name"; Text[100])
{
diff --git a/Apps/W1/Shopify/app/src/Shipping/Codeunits/ShpfyShippingCharges.Codeunit.al b/Apps/W1/Shopify/app/src/Shipping/Codeunits/ShpfyShippingCharges.Codeunit.al
index 0119c566d3..9b2268da5a 100644
--- a/Apps/W1/Shopify/app/src/Shipping/Codeunits/ShpfyShippingCharges.Codeunit.al
+++ b/Apps/W1/Shopify/app/src/Shipping/Codeunits/ShpfyShippingCharges.Codeunit.al
@@ -11,36 +11,11 @@ codeunit 30191 "Shpfy Shipping Charges"
CommunicationMgt: Codeunit "Shpfy Communication Mgt.";
JsonHelper: Codeunit "Shpfy Json Helper";
- ///
- /// Description for UpdateShippingCostInfos.
- ///
- /// Parameter of type BigInteger.
- internal procedure UpdateShippingCostInfos(OrderId: BigInteger)
- var
- OrderHeader: Record "Shpfy Order Header";
- begin
- if OrderHeader.Get(OrderId) then
- UpdateShippingCostInfos(OrderHeader);
- end;
-
- ///
- /// Description for UpdateShippingCostInfos.
- ///
- /// Parameter of type BigInteger.
- /// Parameter of type JsonArray.
- internal procedure UpdateShippingCostInfos(OrderId: BigInteger; JShippingLines: JsonArray)
- var
- OrderHeader: Record "Shpfy Order Header";
- begin
- if OrderHeader.Get(OrderId) then
- UpdateShippingCostInfos(OrderHeader, JShippingLines);
- end;
-
///
/// Description for UpdateShippingCostInfos.
///
/// Parameter of type Record "Shopify Order Header".
- internal procedure UpdateShippingCostInfos(OrderHeader: Record "Shpfy Order Header")
+ internal procedure UpdateShippingCostInfos(var OrderHeader: Record "Shpfy Order Header")
var
Parameters: Dictionary of [Text, Text];
GraphQLType: Enum "Shpfy GraphQL Type";
@@ -70,7 +45,7 @@ codeunit 30191 "Shpfy Shipping Charges"
///
/// Parameter of type Record "Shopify Order Header".
/// Parameter of type JsonArray.
- internal procedure UpdateShippingCostInfos(OrderHeader: Record "Shpfy Order Header"; JShippingLines: JsonArray)
+ internal procedure UpdateShippingCostInfos(var OrderHeader: Record "Shpfy Order Header"; JShippingLines: JsonArray)
var
OrderShippingCharges: Record "Shpfy Order Shipping Charges";
ShipmentMethodMapping: Record "Shpfy Shipment Method Mapping";
@@ -79,9 +54,11 @@ codeunit 30191 "Shpfy Shipping Charges"
Id: BigInteger;
JToken: JsonToken;
IsNew: Boolean;
+ ShippingLineIds: List of [BigInteger];
begin
foreach JToken in JShippingLines do begin
Id := CommunicationMgt.GetIdOfGId(JsonHelper.GetValueAsText(JToken, 'id'));
+ ShippingLineIds.Add(Id);
IsNew := not OrderShippingCharges.Get(Id);
if IsNew then begin
Clear(OrderShippingCharges);
@@ -111,6 +88,24 @@ codeunit 30191 "Shpfy Shipping Charges"
ShipmentMethodMapping.Insert();
end;
end;
+
+ if ShippingLineIds.Count() > 0 then
+ DeleteRemovedShippingLines(OrderHeader, ShippingLineIds);
+ end;
+
+ local procedure DeleteRemovedShippingLines(var OrderHeader: Record "Shpfy Order Header"; ShippingLineIds: List of [BigInteger])
+ var
+ OrderShippingCharges: Record "Shpfy Order Shipping Charges";
+ begin
+ OrderShippingCharges.SetRange("Shopify Order Id", OrderHeader."Shopify Order Id");
+ if OrderShippingCharges.FindSet() then
+ repeat
+ if not ShippingLineIds.Contains(OrderShippingCharges."Shopify Shipping Line Id") then begin
+ OrderHeader."Shipping Charges Amount" -= OrderShippingCharges.Amount - OrderShippingCharges."Discount Amount";
+ OrderHeader."Total Amount" -= OrderShippingCharges.Amount - OrderShippingCharges."Discount Amount";
+ OrderShippingCharges.Delete(true);
+ end;
+ until OrderShippingCharges.Next() = 0;
end;
local procedure GetShippingDiscountAmount(JDiscountAllocations: JsonArray; MoneyType: Text) Result: Decimal
diff --git a/Apps/W1/Shopify/app/src/Shipping/Tables/ShpfyOrderShippingCharges.Table.al b/Apps/W1/Shopify/app/src/Shipping/Tables/ShpfyOrderShippingCharges.Table.al
index abf119098d..c4ace2b63b 100644
--- a/Apps/W1/Shopify/app/src/Shipping/Tables/ShpfyOrderShippingCharges.Table.al
+++ b/Apps/W1/Shopify/app/src/Shipping/Tables/ShpfyOrderShippingCharges.Table.al
@@ -70,5 +70,15 @@ table 30130 "Shpfy Order Shipping Charges"
Clustered = true;
}
}
+
+ trigger OnDelete()
+ var
+ DataCapture: Record "Shpfy Data Capture";
+ begin
+ DataCapture.SetRange("Linked To Table", Database::"Shpfy Order Shipping Charges");
+ DataCapture.SetRange("Linked To Id", Rec.SystemId);
+ if not DataCapture.IsEmpty then
+ DataCapture.DeleteAll(false);
+ end;
}
diff --git a/Apps/W1/Shopify/app/src/Transactions/Reports/ShpfySuggestPayments.Report.al b/Apps/W1/Shopify/app/src/Transactions/Reports/ShpfySuggestPayments.Report.al
index 30abf3fbe3..3cfa432ece 100644
--- a/Apps/W1/Shopify/app/src/Transactions/Reports/ShpfySuggestPayments.Report.al
+++ b/Apps/W1/Shopify/app/src/Transactions/Reports/ShpfySuggestPayments.Report.al
@@ -56,7 +56,7 @@ report 30118 "Shpfy Suggest Payments"
ToolTip = 'Specifies the name of the journal template that is used for the posting.';
Visible = not IsGenJournalLineSet;
Editable = not IsJournalTemplateFound;
-
+ ShowMandatory = true;
trigger OnValidate()
begin
ValidatePostingDate();
@@ -69,7 +69,7 @@ report 30118 "Shpfy Suggest Payments"
Lookup = true;
ToolTip = 'Specifies the name of the journal batch that is used for the posting.';
Visible = not IsGenJournalLineSet;
-
+ ShowMandatory = true;
trigger OnLookup(var Text: Text): Boolean
var
GenJnlManagement: Codeunit GenJnlManagement;
@@ -91,6 +91,7 @@ report 30118 "Shpfy Suggest Payments"
Caption = 'Posting Date';
Importance = Promoted;
ToolTip = 'Specifies the date for the posting of this batch job. By default, the working date is entered, but you can change it.';
+ ShowMandatory = true;
trigger OnValidate()
begin
diff --git a/Apps/W1/Sustainability/app/src/APIs/SustainabilityLedgEntries.Page.al b/Apps/W1/Sustainability/app/src/APIs/SustainabilityLedgEntries.Page.al
index c763d5e4b5..3e46a57fae 100644
--- a/Apps/W1/Sustainability/app/src/APIs/SustainabilityLedgEntries.Page.al
+++ b/Apps/W1/Sustainability/app/src/APIs/SustainabilityLedgEntries.Page.al
@@ -20,6 +20,9 @@ page 6231 "Sustainability Ledg. Entries"
ODataKeyFields = SystemId;
SourceTable = "Sustainability Ledger Entry";
Extensible = false;
+ InsertAllowed = false;
+ ModifyAllowed = false;
+ DeleteAllowed = false;
layout
{
diff --git a/Apps/W1/Sustainability/app/src/Journal/SustainabilityJnlLine.Table.al b/Apps/W1/Sustainability/app/src/Journal/SustainabilityJnlLine.Table.al
index 8c4291d2c1..a5773a6a1a 100644
--- a/Apps/W1/Sustainability/app/src/Journal/SustainabilityJnlLine.Table.al
+++ b/Apps/W1/Sustainability/app/src/Journal/SustainabilityJnlLine.Table.al
@@ -310,7 +310,7 @@ table 6214 "Sustainability Jnl. Line"
DimMgt: Codeunit DimensionManagement;
JnlRecRefLbl: Label '%1 %2 %3', Locked = true;
- internal procedure SetupNewLine(PreviousLine: Record "Sustainability Jnl. Line")
+ procedure SetupNewLine(PreviousLine: Record "Sustainability Jnl. Line")
var
SustainabilityJnlBatch: Record "Sustainability Jnl. Batch";
SustainabilityJnlLine: Record "Sustainability Jnl. Line";
diff --git a/Apps/W1/Sustainability/test/src/SustainabilityAPITests.Codeunit.al b/Apps/W1/Sustainability/test/src/SustainabilityAPITests.Codeunit.al
new file mode 100644
index 0000000000..2af04ea968
--- /dev/null
+++ b/Apps/W1/Sustainability/test/src/SustainabilityAPITests.Codeunit.al
@@ -0,0 +1,385 @@
+codeunit 148185 "Sustainability API Tests"
+{
+ Subtype = Test;
+ TestPermissions = Disabled;
+
+ trigger OnRun()
+ begin
+ // [FEATURE] [Sustainability] [API] [UI]
+ end;
+
+ var
+ Assert: Codeunit "Assert";
+ LibraryGraphMgt: Codeunit "Library - Graph Mgt";
+ LibrarySustainability: Codeunit "Library - Sustainability";
+ LibraryUtility: Codeunit "Library - Utility";
+ IsInitialized: Boolean;
+ CodeLbl: Label 'code', Locked = true;
+ NumberLbl: Label 'number', Locked = true;
+ LineNumberLbl: Label 'lineNumber', Locked = true;
+ AccountCodeLbl: Label 'AccountCode%1', Locked = true, Comment = '%1 = Number';
+ CategoryCodeLbl: Label 'CategoryCode%1', Locked = true, Comment = '%1 = Number';
+ SubcategoryCodeLbl: Label 'SubcategoryCode%1', Locked = true, Comment = '%1 = Number';
+ SustainabilityAccountCategoriesServiceNameLbl: Label 'sustainabilityAccountCategories', Locked = true;
+ SustainabilityAccountSubcategoriesServiceNameLbl: Label 'sustainabilityAccountSubcategories', Locked = true;
+ SustainabilityAccountsServiceNameLbl: Label 'sustainabilityAccounts', Locked = true;
+ SustainabilityJournalLinesServiceNameLbl: Label 'sustainabilityJournalLines', Locked = true;
+ CreateRecordErr: Label 'The record hasn''t been created.', Locked = true;
+
+ #region GET methods
+ [Test]
+ procedure TestGetSustainabilityCategory()
+ var
+ CategoryCode: array[2] of Code[20];
+ ResponseText: Text;
+ i: Integer;
+ begin
+ // [SCENARIO 521279] Create two Sustainability Account Categories and use GET method to retrieve them
+
+ Initialize();
+
+ // [GIVEN] Sustainability Account Category X
+ // [GIVEN] Sustainability Account Category Y
+ for i := 1 to ArrayLen(CategoryCode) do
+ CreateSustainabilityCategory(CategoryCode[i], i);
+ Commit();
+
+ // [WHEN] GET request is made to the Sustainability Account Categories API
+ LibraryGraphMgt.GetFromWebService(ResponseText, LibraryGraphMgt.CreateTargetURL('', Page::"Sust. Account Categories", SustainabilityAccountCategoriesServiceNameLbl));
+
+ // [THEN] Two Sustainability Account Category Codes have been found in the response
+ GetAndVerifyIDFromJSON(ResponseText, CategoryCode[1], CategoryCode[2], CodeLbl);
+ end;
+
+ [Test]
+ procedure TestGetSustainabilitySubcategory()
+ var
+ CategoryCode: array[2] of Code[20];
+ SubcategoryCode: array[2] of Code[20];
+ ResponseText: Text;
+ i: Integer;
+ begin
+ // [SCENARIO 521279] Create two Sustainability Account Subcategories and use GET method to retrieve them
+ Initialize();
+
+ // [GIVEN] Sustainability Account Subcategory X, Sustainability Account Category X
+ // [GIVEN] Sustainability Account Subcategory Y, Sustainability Account Category Y
+ for i := 1 to ArrayLen(SubcategoryCode) do
+ CreateSustainabilitySubcategory(CategoryCode[i], SubcategoryCode[i], i + 2);
+ Commit();
+
+ // [WHEN] GET request is made to the Sustainability Account Subcategories API
+ LibraryGraphMgt.GetFromWebService(ResponseText, LibraryGraphMgt.CreateTargetURL('', Page::"Sust. Acc. Subcategory", SustainabilityAccountSubcategoriesServiceNameLbl));
+
+ // [THEN] Two Sustainability Account Subcategory Codes have been found in the response
+ GetAndVerifyIDFromJSON(ResponseText, SubcategoryCode[1], SubcategoryCode[2], CodeLbl);
+ end;
+
+ [Test]
+ procedure TestGetSustainabilityAccounts()
+ var
+ CategoryCode: array[2] of Code[20];
+ SubcategoryCode: array[2] of Code[20];
+ AccountCode: array[2] of Code[20];
+ ResponseText: Text;
+ i: Integer;
+ begin
+ // [SCENARIO 521279] Create two Sustainability Accounts and use GET method to retrieve them
+
+ Initialize();
+
+ // [GIVEN] Sustainability Account X, Sustainability Account Subcategory X, Sustainability Account Category X
+ // [GIVEN] Sustainability Account Y, Sustainability Account Subcategory Y, Sustainability Account Category Y
+ for i := 1 to ArrayLen(AccountCode) do
+ CreateSustainabilityAccount(AccountCode[i], CategoryCode[i], SubcategoryCode[i], i + 4);
+ Commit();
+
+ // [WHEN] GET request is made to the Sustainability Accounts API
+ LibraryGraphMgt.GetFromWebService(ResponseText, LibraryGraphMgt.CreateTargetURL('', Page::"Sustainability Accounts", SustainabilityAccountsServiceNameLbl));
+
+ // [THEN] Two Sustainability Account Codes have been found in the response
+ GetAndVerifyIDFromJSON(ResponseText, AccountCode[1], AccountCode[2], NumberLbl);
+ end;
+
+ [Test]
+ procedure TestGetSustainabilityJournalLines()
+ var
+ SustainabilityAccount: array[2] of Record "Sustainability Account";
+ SustainabilityJournalLine: array[2] of Record "Sustainability Jnl. Line";
+ CategoryCode: array[2] of Code[20];
+ SubcategoryCode: array[2] of Code[20];
+ AccountCode: array[2] of Code[20];
+ ResponseText: Text;
+ i: Integer;
+ begin
+ // [SCENARIO 521279] Create two Sustainability Journal Lines and use GET method to retrieve them
+
+ Initialize();
+
+ // [GIVEN] Sustainability Journal Line 1, Sustainability Account X, Sustainability Account Subcategory X, Sustainability Account Category X
+ // [GIVEN] Sustainability Journal Line 2, Sustainability Account Y, Sustainability Account Subcategory Y, Sustainability Account Category Y
+ for i := 1 to ArrayLen(SustainabilityJournalLine) do begin
+ SustainabilityAccount[i] := CreateSustainabilityAccount(AccountCode[i], CategoryCode[i], SubcategoryCode[i], i + 6);
+ SustainabilityJournalLine[i] := CreateSustainabilityJnlLine(SustainabilityAccount[i]);
+ end;
+ Commit();
+
+ // [WHEN] GET request is made to the Sustainability Journal Lines API
+ LibraryGraphMgt.GetFromWebService(ResponseText, LibraryGraphMgt.CreateTargetURL('', Page::"Sustainability Journal Line", SustainabilityJournalLinesServiceNameLbl));
+
+ // [THEN] Two Sustainability Journal Line Numbers have been found in the response
+ GetAndVerifyIDFromJSON(ResponseText, Format(SustainabilityJournalLine[1]."Line No."), Format(SustainabilityJournalLine[2]."Line No."), LineNumberLbl);
+ end;
+
+ [Test]
+ procedure TestGetSustainabilityEntries()
+ var
+ SustainabilityAccount: array[2] of Record "Sustainability Account";
+ SustainabilityJournalLine: array[2] of Record "Sustainability Jnl. Line";
+ CategoryCode: array[2] of Code[20];
+ SubcategoryCode: array[2] of Code[20];
+ AccountCode: array[2] of Code[20];
+ ResponseText: Text;
+ LedgerEntryNo: array[2] of Integer;
+ i: Integer;
+ SustainabilityEntriesServiceNameLbl: Label 'sustainabilityLedgerEntries', Locked = true;
+ EntryNumberLbl: Label 'entryNumber', Locked = true;
+ begin
+ // [SCENARIO 521279] Create two Sustainability Entries and use GET method to retrieve them
+ Initialize();
+
+ // [GIVEN] Sustainability Lendger Entry 1, Sustainability Account X, Sustainability Account Subcategory X, Sustainability Account Category X
+ // [GIVEN] Sustainability Lendger Entry 2, Sustainability Account Y, Sustainability Account Subcategory Y, Sustainability Account Category Y
+ for i := 1 to ArrayLen(LedgerEntryNo) do begin
+ SustainabilityAccount[i] := CreateSustainabilityAccount(AccountCode[i], CategoryCode[i], SubcategoryCode[i], i + 8);
+ SustainabilityJournalLine[i] := CreateSustainabilityJnlLine(SustainabilityAccount[i]);
+ LedgerEntryNo[i] := CreateSustainabilityEntries(SustainabilityJournalLine[i]);
+ end;
+ Commit();
+
+ // [WHEN] GET request is made to the Sustainability Entries API
+ LibraryGraphMgt.GetFromWebService(ResponseText, LibraryGraphMgt.CreateTargetURL('', Page::"Sustainability Ledg. Entries", SustainabilityEntriesServiceNameLbl));
+
+ // [THEN] Two Sustainability Entries have been found in the response
+ GetAndVerifyIDFromJSON(ResponseText, Format(LedgerEntryNo[1]), Format(LedgerEntryNo[2]), EntryNumberLbl);
+ end;
+
+ #endregion GET methods
+
+ #region POST methods
+ [Test]
+ procedure TestPostSustainabilityCategory()
+ var
+ SustainAccountCategory: Record "Sustain. Account Category";
+ SustainAccountCategoryJSON: Text;
+ ResponseText: Text;
+ begin
+ // [SCENARIO 521279] Create Sustainability Account Category using POST method
+ Initialize();
+
+ // [GIVEN] Create JSON file with the data for a new Sustainability Account Category Z
+ SustainAccountCategoryJSON := CreateSustainabilityJSON(CodeLbl, StrSubstNo(CategoryCodeLbl, 'X'));
+
+ // [WHEN] POST request is made to the Sustainability Account Categories API
+ LibraryGraphMgt.PostToWebService(LibraryGraphMgt.CreateTargetURL('', Page::"Sust. Account Categories", SustainabilityAccountCategoriesServiceNameLbl), SustainAccountCategoryJSON, ResponseText);
+
+ // [THEN] New Sustainability Account Category Z has been created
+ Assert.IsTrue(SustainAccountCategory.Get(StrSubstNo(CategoryCodeLbl, 'X')), CreateRecordErr);
+ end;
+
+ [Test]
+ procedure TestPostSustainabilitySubcategory()
+ var
+ SustainAccountSubcategory: Record "Sustain. Account Subcategory";
+ CategoryCode: Code[20];
+ SustainAccountSubcategoryJSON: Text;
+ ResponseText: Text;
+ CategoryLbl: Label 'category', Locked = true;
+ begin
+ // [SCENARIO 521279] Create Sustainability Account Subcategory using POST method
+ Initialize();
+
+ // [GIVEN] Create Sustainability Account Category Y
+ CreateSustainabilityCategory(CategoryCode, 99);
+
+ // [GIVEN] Create JSON file with the data for a new Sustainability Account Subcategory Z
+ SustainAccountSubcategoryJSON := CreateSustainabilitySubCategoryJSON(CodeLbl, StrSubstNo(SubcategoryCodeLbl, 'Y'), CategoryLbl, CategoryCode);
+ Commit();
+ // [WHEN] POST request is made to the Sustainability Account Subcategory API
+ LibraryGraphMgt.PostToWebService(LibraryGraphMgt.CreateTargetURL('', Page::"Sust. Acc. Subcategory", SustainabilityAccountSubcategoriesServiceNameLbl), SustainAccountSubcategoryJSON, ResponseText);
+
+ // [THEN] New Sustainability Account Subcategory Z has been created
+ Assert.IsTrue(SustainAccountSubcategory.Get(CategoryCode, StrSubstNo(SubcategoryCodeLbl, 'Y')), CreateRecordErr);
+ end;
+
+ [Test]
+ procedure TestPostSustainabilityAccount()
+ var
+ SustainabilityAccount: Record "Sustainability Account";
+ SustainabilityAccountJSON: Text;
+ ResponseText: Text;
+ begin
+ // [SCENARIO 521279] Create Sustainability Account using POST method
+ Initialize();
+
+ // [GIVEN] Create JSON file with the data for a new Sustainability Account Z
+ SustainabilityAccountJSON := CreateSustainabilityJSON(NumberLbl, StrSubstNo(AccountCodeLbl, 'Z'));
+ Commit();
+
+ // [WHEN] POST request is made to the Sustainability Account API
+ LibraryGraphMgt.PostToWebService(LibraryGraphMgt.CreateTargetURL('', Page::"Sustainability Accounts", SustainabilityAccountsServiceNameLbl), SustainabilityAccountJSON, ResponseText);
+
+ // [THEN] New Sustainability Account Z has been created
+ Assert.IsTrue(SustainabilityAccount.Get(StrSubstNo(AccountCodeLbl, 'Z')), CreateRecordErr);
+ end;
+
+ [Test]
+ procedure TestPostSustainabilityJournalLine()
+ var
+ SustainabilityJnlLine: Record "Sustainability Jnl. Line";
+ SustainabilityJnlBatch: Record "Sustainability Jnl. Batch";
+ SustainabilityJournalLineJSON: Text;
+ ResponseText: Text;
+ LineNo: Integer;
+ begin
+ // [SCENARIO 521279] Create Sustainability Jnl. Line using POST method
+ Initialize();
+
+ // [GIVEN] Create JSON file with the data for a new Sustainability Jnl. Line
+ SustainabilityJournalLineJSON := CreateSustainabilityJnlLineJSON(SustainabilityJnlBatch, LineNo);
+ Commit();
+
+ // [WHEN] POST request is made to the Sustainability Jnl. Line API
+ LibraryGraphMgt.PostToWebService(LibraryGraphMgt.CreateTargetURL('', Page::"Sustainability Journal Line", SustainabilityJournalLinesServiceNameLbl), SustainabilityJournalLineJSON, ResponseText);
+
+ // [THEN] New Sustainability Jnl. Line has been created
+ Assert.IsTrue(SustainabilityJnlLine.Get(SustainabilityJnlBatch."Journal Template Name", SustainabilityJnlBatch.Name, LineNo), CreateRecordErr);
+ end;
+ #endregion POST methods
+
+ local procedure Initialize()
+ var
+ LibraryTestInitialize: Codeunit "Library - Test Initialize";
+ begin
+ LibraryTestInitialize.OnTestInitialize(Codeunit::"Sustainability API Tests");
+
+ if IsInitialized then
+ exit;
+
+ LibrarySustainability.CleanUpBeforeTesting();
+
+ IsInitialized := true;
+
+ LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::"Sustainability API Tests");
+ end;
+
+ local procedure CreateSustainabilityCategory(var CategoryCode: Code[20]; i: Integer)
+ begin
+ CategoryCode := StrSubstNo(CategoryCodeLbl, i);
+ LibrarySustainability.InsertAccountCategory(
+ CategoryCode, CategoryCode, Enum::"Emission Scope"::"Scope 1", Enum::"Calculation Foundation"::"Fuel/Electricity",
+ true, true, true, '', false);
+ end;
+
+ local procedure CreateSustainabilitySubcategory(var CategoryCode: Code[20]; var SubcategoryCode: Code[20]; i: Integer)
+ begin
+ CategoryCode := StrSubstNo(CategoryCodeLbl, i);
+ CreateSustainabilityCategory(CategoryCode, i);
+
+ SubcategoryCode := StrSubstNo(SubcategoryCodeLbl, i);
+ LibrarySustainability.InsertAccountSubcategory(CategoryCode, SubcategoryCode, SubcategoryCode, 1, 2, 3, false);
+ end;
+
+ local procedure CreateSustainabilityAccount(var AccountCode: Code[20]; CategoryCode: Code[20]; SubcategoryCode: Code[20]; i: Integer): Record "Sustainability Account"
+ begin
+ CreateSustainabilitySubcategory(CategoryCode, SubcategoryCode, i);
+ AccountCode := StrSubstNo(AccountCodeLbl, i);
+ exit(LibrarySustainability.InsertSustainabilityAccount(
+ AccountCode, '', CategoryCode, SubcategoryCode, Enum::"Sustainability Account Type"::Posting, '', true));
+ end;
+
+ local procedure CreateSustainabilityJnlLine(SustainabilityAccount: Record "Sustainability Account") SustainabilityJournalLine: Record "Sustainability Jnl. Line";
+ var
+ SustainabilityJnlBatch: Record "Sustainability Jnl. Batch";
+ begin
+ SetSustainabilityJournalLine(SustainabilityJournalLine, SustainabilityJnlBatch);
+ exit(
+ LibrarySustainability.InsertSustainabilityJournalLine(
+ SustainabilityJnlBatch, SustainabilityAccount, GetLastLineNo(SustainabilityJournalLine)));
+ end;
+
+ local procedure CreateSustainabilityEntries(SustainabilityJournalLine: Record "Sustainability Jnl. Line"): Integer
+ var
+ SustainabilityLedgerEntry: Record "Sustainability Ledger Entry";
+ SustainabilityPostMgt: Codeunit "Sustainability Post Mgt";
+ begin
+ SustainabilityPostMgt.InsertLedgerEntry(SustainabilityJournalLine);
+ SustainabilityLedgerEntry.FindLast();
+ exit(SustainabilityLedgerEntry."Entry No.");
+ end;
+
+ local procedure SetSustainabilityJournalLine(var SustainabilityJournalLine: Record "Sustainability Jnl. Line"; var SustainabilityJnlBatch: Record "Sustainability Jnl. Batch")
+ var
+ SustainabilityJournalMgt: Codeunit "Sustainability Journal Mgt.";
+ begin
+ SustainabilityJnlBatch := SustainabilityJournalMgt.GetASustainabilityJournalBatch(false);
+ SustainabilityJournalLine."Journal Template Name" := SustainabilityJnlBatch."Journal Template Name";
+ SustainabilityJournalLine."Journal Batch Name" := SustainabilityJnlBatch.Name;
+ end;
+
+ local procedure GetLastLineNo(var SustainabilityJournalLine: Record "Sustainability Jnl. Line"): Integer
+ var
+ RecordRef: RecordRef;
+ begin
+ RecordRef.GetTable(SustainabilityJournalLine);
+ exit(LibraryUtility.GetNewLineNo(RecordRef, SustainabilityJournalLine.FieldNo("Line No.")));
+ end;
+
+ local procedure GetAndVerifyIDFromJSON(ResponseText: Text; Code1: Code[20]; Code2: Code[20]; ObjectIDFieldName: Text)
+ var
+ JSONText: array[2] of Text;
+ DataNonExistErr: Label 'Could not find the data in JSON', Locked = true;
+ begin
+ Assert.IsTrue(
+ LibraryGraphMgt.GetObjectsFromJSONResponse(ResponseText, ObjectIDFieldName, Code1, Code2, JSONText[1], JSONText[2]), DataNonExistErr);
+ LibraryGraphMgt.VerifyIDInJson(JSONText[1]);
+ LibraryGraphMgt.VerifyIDInJson(JSONText[2]);
+ end;
+
+ local procedure CreateSustainabilityJSON(PropertyName: Text; PropertyValue: Variant): Text
+ var
+ LineJSON: Text;
+ begin
+ LineJSON := LibraryGraphMgt.AddPropertytoJSON('', 'id', CreateGuid());
+ LineJSON := LibraryGraphMgt.AddPropertytoJSON(LineJSON, PropertyName, PropertyValue);
+ exit(LineJSON);
+ end;
+
+ local procedure CreateSustainabilitySubCategoryJSON(PropertyName: Text; PropertyValue: Variant; PropertyName2: Text; PropertyValue2: Variant): Text
+ var
+ LineJSON: Text;
+ begin
+ LineJSON := LibraryGraphMgt.AddPropertytoJSON('', 'id', CreateGuid());
+ LineJSON := LibraryGraphMgt.AddPropertytoJSON(LineJSON, PropertyName, PropertyValue);
+ LineJSON := LibraryGraphMgt.AddPropertytoJSON(LineJSON, PropertyName2, PropertyValue2);
+ exit(LineJSON);
+ end;
+
+ local procedure CreateSustainabilityJnlLineJSON(var SustainabilityJnlBatch: Record "Sustainability Jnl. Batch"; var LineNo: Integer): Text
+ var
+ SustainabilityJournalLine: Record "Sustainability Jnl. Line";
+ LineJSON: Text;
+ JournalTemplateNameLbl: Label 'journalTemplateName', Locked = true;
+ JournalBatchNameLbl: Label 'journalBatchName', Locked = true;
+ begin
+ SetSustainabilityJournalLine(SustainabilityJournalLine, SustainabilityJnlBatch);
+
+ LineNo := GetLastLineNo(SustainabilityJournalLine);
+
+ LineJSON := LibraryGraphMgt.AddPropertytoJSON('', 'id', CreateGuid());
+ LineJSON := LibraryGraphMgt.AddPropertytoJSON(LineJSON, JournalTemplateNameLbl, SustainabilityJnlBatch."Journal Template Name");
+ LineJSON := LibraryGraphMgt.AddPropertytoJSON(LineJSON, JournalBatchNameLbl, SustainabilityJnlBatch.Name);
+ LineJSON := LibraryGraphMgt.AddPropertytoJSON(LineJSON, LineNumberLbl, LineNo);
+ exit(LineJSON);
+ end;
+}
diff --git a/Apps/W1/TransactionStorage/app/src/TransStorageErrorHandler.Codeunit.al b/Apps/W1/TransactionStorage/app/src/TransStorageErrorHandler.Codeunit.al
index 2424f458ef..81d84ae20c 100644
--- a/Apps/W1/TransactionStorage/app/src/TransStorageErrorHandler.Codeunit.al
+++ b/Apps/W1/TransactionStorage/app/src/TransStorageErrorHandler.Codeunit.al
@@ -8,7 +8,8 @@ codeunit 6204 "Trans. Storage Error Handler"
TableNo = "Transact. Storage Task Entry";
InherentEntitlements = X;
InherentPermissions = X;
- Permissions = tabledata "Transact. Storage Export State" = RIM;
+ Permissions = tabledata "Transact. Storage Export State" = RIM,
+ tabledata "Trans. Storage Export Data" = RD;
var
TransactionStorageTok: Label 'Transaction Storage', Locked = true;
@@ -19,6 +20,7 @@ codeunit 6204 "Trans. Storage Error Handler"
trigger OnRun()
var
TransactStorageExportState: Record "Transact. Storage Export State";
+ TransStorageExportData: Record "Trans. Storage Export Data";
TransStorageScheduleTask: Codeunit "Trans. Storage Schedule Task";
FeatureTelemetry: Codeunit "Feature Telemetry";
ExportDateTime: DateTime;
@@ -38,6 +40,7 @@ codeunit 6204 "Trans. Storage Error Handler"
TransStorageScheduleTask.CreateTaskToExport(ExportDateTime, false);
TransactStorageExportState."Number Of Attempts" -= 1;
TransactStorageExportState.Modify();
+ TransStorageExportData.DeleteAll(true);
end;
local procedure CheckMultipleTaskFailures()
diff --git a/Apps/W1/TransactionStorage/app/src/TransStorageExportData.Table.al b/Apps/W1/TransactionStorage/app/src/TransStorageExportData.Table.al
new file mode 100644
index 0000000000..dbc4ec19d8
--- /dev/null
+++ b/Apps/W1/TransactionStorage/app/src/TransStorageExportData.Table.al
@@ -0,0 +1,49 @@
+namespace System.DataAdministration;
+
+table 6205 "Trans. Storage Export Data"
+{
+ Access = Internal;
+ DataClassification = OrganizationIdentifiableInformation;
+ InherentEntitlements = rimdX;
+ InherentPermissions = rimdX;
+ Permissions = tabledata "Trans. Storage Export Data" = rimd;
+
+ fields
+ {
+ field(1; "Table ID"; Integer)
+ {
+ }
+ field(2; Part; Integer)
+ {
+ }
+ field(3; Content; Blob)
+ {
+ }
+ field(4; "Record Count"; Integer)
+ {
+
+ }
+ }
+
+ keys
+ {
+ key(PK; "Table ID", Part)
+ {
+ Clustered = true;
+ }
+ }
+
+ internal procedure Add(var NewPart: Integer; var JsonArray: JsonArray; TableID: Integer; RecordCount: Integer)
+ var
+ OutStream: OutStream;
+ begin
+ Rec.Init();
+ Rec."Table ID" := TableID;
+ NewPart += 1;
+ Rec.Part := NewPart;
+ Rec.Content.CreateOutStream(OutStream, TextEncoding::UTF8);
+ JsonArray.WriteTo(OutStream);
+ Rec."Record Count" := RecordCount;
+ Rec.Insert();
+ end;
+}
\ No newline at end of file
diff --git a/Apps/W1/TransactionStorage/app/src/TransactStorageExportData.Codeunit.al b/Apps/W1/TransactionStorage/app/src/TransactStorageExportData.Codeunit.al
index 1eb1488b93..66e5ab363c 100644
--- a/Apps/W1/TransactionStorage/app/src/TransactStorageExportData.Codeunit.al
+++ b/Apps/W1/TransactionStorage/app/src/TransactStorageExportData.Codeunit.al
@@ -32,6 +32,7 @@ codeunit 6202 "Transact. Storage Export Data"
InherentPermissions = X;
Permissions = tabledata "Transact. Storage Table Entry" = RIMD,
tabledata "Transact. Storage Task Entry" = RIM,
+ tabledata "Trans. Storage Export Data" = RIMD,
tabledata "G/L Entry" = r,
tabledata "VAT Entry" = r,
tabledata "Cust. Ledger Entry" = r,
@@ -56,34 +57,38 @@ codeunit 6202 "Transact. Storage Export Data"
FeatureTelemetry: Codeunit "Feature Telemetry";
TransactStorageExport: Codeunit "Transact. Storage Export";
TransactionStorageTok: Label 'Transaction Storage', Locked = true;
- NoOfCollectedRecordsTxt: Label 'Number of collected records.', Locked = true;
+ NoOfCollectedRecordTxt: Label 'Number of collected records', Locked = true;
+ NoOfCollectedPartsTxt: Label 'Parts', Locked = true;
NoPermissionsForTableErr: Label 'User does not have permissions to read the table %1', Comment = '%1 = table name', Locked = true;
procedure ExportData(TaskStartingDateTime: DateTime)
var
+ TransStorageExportData: Record "Trans. Storage Export Data";
TempFieldList: Record Field temporary;
TransactionStorageABS: Codeunit "Transaction Storage ABS";
HandledIncomingDocs: Dictionary of [Text, Integer];
MasterData: Dictionary of [Integer, List of [Code[50]]];
- DataJsonArrays: Dictionary of [Integer, JsonArray];
TablesToExport: List of [Integer];
TableID: Integer;
begin
+ TransStorageExportData.DeleteAll(true);
TablesToExport := GetTablesToExport();
foreach TableID in TablesToExport do
- CollectDataFromTable(DataJsonArrays, HandledIncomingDocs, TempFieldList, MasterData, TaskStartingDateTime, TableID);
- LogNumberOfCollectedRecords(DataJsonArrays);
- CollectMasterData(DataJsonArrays, MasterData);
- if (DataJsonArrays.Count() <> 0) or (HandledIncomingDocs.Count() <> 0) then
- TransactionStorageABS.ArchiveTransactionsToABS(DataJsonArrays, HandledIncomingDocs);
+ CollectDataFromTable(HandledIncomingDocs, TempFieldList, MasterData, TaskStartingDateTime, TableID);
+ LogNumberOfCollectedRecords(TablesToExport);
+ CollectMasterData(MasterData);
+ if (not TransStorageExportData.IsEmpty()) or (HandledIncomingDocs.Count() <> 0) then
+ TransactionStorageABS.ArchiveTransactionsToABS(HandledIncomingDocs);
end;
- local procedure CollectDataFromTable(var DataJsonArrays: Dictionary of [Integer, JsonArray]; var HandledIncomingDocs: Dictionary of [Text, Integer]; var TempFieldList: Record Field temporary; var MasterData: Dictionary of [Integer, List of [Code[50]]]; TaskStartingDateTime: DateTime; TableID: Integer)
+ local procedure CollectDataFromTable(var HandledIncomingDocs: Dictionary of [Text, Integer]; var TempFieldList: Record Field temporary; var MasterData: Dictionary of [Integer, List of [Code[50]]]; TaskStartingDateTime: DateTime; TableID: Integer)
var
TransactStorageTableEntry: Record "Transact. Storage Table Entry";
RecRef: RecordRef;
RecordJsonObject: JsonObject;
TableJsonArray: JsonArray;
+ RecordsHandled: Integer;
+ Part: Integer;
begin
RecRef.Open(TableID);
if not RecRef.ReadPermission() then begin
@@ -98,12 +103,14 @@ codeunit 6202 "Transact. Storage Export Data"
if RecRef.FindSet() then begin
Clear(TableJsonArray);
repeat
+ RecordsHandled += 1;
TransactStorageTableEntry."No. Of Records Exported" += 1;
HandleTableFieldSet(RecordJsonObject, MasterData, TempFieldList, RecRef, true);
TableJsonArray.Add(RecordJsonObject);
+ AddJsonArrayToTransStorageExportData(Part, TableJsonArray, RecordsHandled, GetRecordChunkSize(), RecRef.Number());
TransactStorageExport.HandleIncomingDocuments(HandledIncomingDocs, RecRef);
until RecRef.Next() = 0;
- DataJsonArrays.Add(RecRef.Number, TableJsonArray);
+ AddJsonArrayToTransStorageExportData(Part, TableJsonArray, RecordsHandled, 0, RecRef.Number());
end else
TransactStorageExport.SetTableEntryProcessed(TransactStorageTableEntry, TransactStorageTableEntry."Filter Record To DT", false, '');
TransactStorageExport.CheckTimeDeadline(TaskStartingDateTime);
@@ -112,7 +119,7 @@ codeunit 6202 "Transact. Storage Export Data"
RecRef.Close();
end;
- local procedure CollectMasterData(var DataJsonArrays: Dictionary of [Integer, JsonArray]; var MasterData: Dictionary of [Integer, List of [Code[50]]])
+ local procedure CollectMasterData(var MasterData: Dictionary of [Integer, List of [Code[50]]])
var
TempFieldList: Record Field temporary;
RecRef: RecordRef;
@@ -123,8 +130,12 @@ codeunit 6202 "Transact. Storage Export Data"
MasterDataCode: Code[50];
RecordJsonObject: JsonObject;
TableJsonArray: JsonArray;
+ RecordsHandled: Integer;
+ Part: Integer;
begin
foreach MasterDataTableNo in MasterData.Keys() do begin
+ Part := 0;
+ RecordsHandled := 0;
MasterDataCodes := MasterData.Get(MasterDataTableNo);
RecRef.Open(MasterDataTableNo);
if not RecRef.ReadPermission() then begin
@@ -140,17 +151,30 @@ codeunit 6202 "Transact. Storage Export Data"
foreach MasterDataCode in MasterDataCodes do begin
FieldRef.SetRange(MasterDataCode);
if RecRef.FindFirst() then begin
+ RecordsHandled += 1;
HandleTableFieldSet(RecordJsonObject, MasterData, TempFieldList, RecRef, false);
TableJsonArray.Add(RecordJsonObject);
+ AddJsonArrayToTransStorageExportData(Part, TableJsonArray, RecordsHandled, GetRecordChunkSize(), RecRef.Number());
end;
end;
- DataJsonArrays.Add(RecRef.Number, TableJsonArray);
+ AddJsonArrayToTransStorageExportData(Part, TableJsonArray, RecordsHandled, 0, RecRef.Number());
end;
RecRef.Close();
Commit();
end;
end;
+ local procedure AddJsonArrayToTransStorageExportData(var Part: Integer; var TableJsonArray: JsonArray; var RecordsHandled: Integer; ChunkSize: Integer; TableID: Integer)
+ var
+ TransStorageExportData: Record "Trans. Storage Export Data";
+ begin
+ if RecordsHandled < ChunkSize then
+ exit;
+ TransStorageExportData.Add(Part, TableJsonArray, TableID, RecordsHandled);
+ RecordsHandled := 0;
+ Clear(TableJsonArray);
+ end;
+
local procedure SetRangeOnDataTable(var RecRef: RecordRef; var TransactStorageTableEntry: Record "Transact. Storage Table Entry"; TaskStartingDateTime: DateTime)
var
SystemCreateAtFieldRef: FieldRef;
@@ -224,17 +248,23 @@ codeunit 6202 "Transact. Storage Export Data"
UpdateTempFieldList(TempFieldList, TableID, FieldID);
end;
- local procedure LogNumberOfCollectedRecords(var DataJsonArrays: Dictionary of [Integer, JsonArray])
+ local procedure LogNumberOfCollectedRecords(TablesToExport: List of [Integer])
var
+ TransStorageExportData: Record "Trans. Storage Export Data";
TableMetadata: Record "Table Metadata";
- CustomDimensions: Dictionary of [Text, Text];
+ RecordsCustomDimensions: Dictionary of [Text, Text];
+ PartsCustomDimensions: Dictionary of [Text, Text];
TableID: Integer;
begin
- foreach TableID in DataJsonArrays.Keys() do begin
+ foreach TableID in TablesToExport do begin
TableMetadata.Get(TableID);
- CustomDimensions.Add(TableMetadata.Name, Format(DataJsonArrays.Get(TableID).Count()));
+ TransStorageExportData.SetRange("Table ID", TableID);
+ TransStorageExportData.CalcSums("Record Count");
+ RecordsCustomDimensions.Add(TableMetadata.Name, Format(TransStorageExportData."Record Count"));
+ PartsCustomDimensions.Add(TableMetadata.Name, Format(TransStorageExportData.Count()));
end;
- FeatureTelemetry.LogUsage('0000LK7', TransactionStorageTok, NoOfCollectedRecordsTxt, CustomDimensions);
+ FeatureTelemetry.LogUsage('0000LK7', TransactionStorageTok, NoOfCollectedRecordTxt, RecordsCustomDimensions);
+ FeatureTelemetry.LogUsage('0000N1I', TransactionStorageTok, NoOfCollectedPartsTxt, PartsCustomDimensions);
end;
local procedure GetTablesToExport() TablesToExport: List of [Integer]
@@ -1230,4 +1260,9 @@ codeunit 6202 "Transact. Storage Export Data"
RecRef.SetLoadFields(TempFieldList."No.");
until TempFieldList.Next() = 0;
end;
+
+ local procedure GetRecordChunkSize(): Integer
+ begin
+ exit(200000);
+ end;
}
\ No newline at end of file
diff --git a/Apps/W1/TransactionStorage/app/src/TransactionStorageABS.Codeunit.al b/Apps/W1/TransactionStorage/app/src/TransactionStorageABS.Codeunit.al
index 50b369dd30..18b2e29f44 100644
--- a/Apps/W1/TransactionStorage/app/src/TransactionStorageABS.Codeunit.al
+++ b/Apps/W1/TransactionStorage/app/src/TransactionStorageABS.Codeunit.al
@@ -20,6 +20,7 @@ codeunit 6205 "Transaction Storage ABS"
InherentPermissions = X;
Permissions = tabledata "Transact. Storage Task Entry" = R,
tabledata "Transact. Storage Table Entry" = RM,
+ tabledata "Trans. Storage Export Data" = RD,
tabledata "Table Metadata" = r,
tabledata "Incoming Document Attachment" = r,
tabledata "ABS Container" = ri;
@@ -37,11 +38,11 @@ codeunit 6205 "Transaction Storage ABS"
CollectedDocsCountTxt: Label 'Collected docs count', Locked = true;
ExportedDocsCountTxt: Label 'Exported docs count', Locked = true;
TablesExportedTxt: Label 'Tables were exported.', Locked = true;
- CollectedTablesCountTxt: Label 'Collected tables count', Locked = true;
ExportedTablesCountTxt: Label 'Exported tables count', Locked = true;
ExportedToABSTxt: Label 'Exported to Azure Blob Storage using certificate authorized Azure Function', Locked = true;
BlobFolderNameTxt: Label '%1_%2/%3', Comment = '%1 - aad tenant id, %2 - environment name, %3 - date', Locked = true;
JsonBlobNameTxt: Label '%1/%2.json', Comment = '%1 - blob folder name, %2 - table name', Locked = true;
+ JsonBlobNameWithPartTxt: Label '%1/%2_%3.json', Comment = '%1 - blob folder name, %2 - table name, %3 - part', Locked = true;
IncomingDocBlobNameTxt: Label '%1/%2-%3.%4', Comment = '%1 - blob folder name, %2 - incoming document entry no., %3 - incoming document name, %4 - incoming document extension', Locked = true;
CannotGetAuthorityURLFromKeyVaultErr: Label 'Cannot get Authority URL from Azure Key Vault using key %1', Locked = true;
CannotGetClientIdFromKeyVaultErr: Label 'Cannot get Client ID from Azure Key Vault using key %1', Locked = true;
@@ -60,7 +61,7 @@ codeunit 6205 "Transaction Storage ABS"
AzFuncEndpointBase64KeyTok: Label 'TransactionStorage-AzFuncEndpointBase64', Locked = true;
[NonDebuggable]
- procedure ArchiveTransactionsToABS(DataJsonArrays: Dictionary of [Integer, JsonArray]; IncomingDocs: Dictionary of [Text, Integer])
+ procedure ArchiveTransactionsToABS(IncomingDocs: Dictionary of [Text, Integer])
var
AzureFunctionsAuthentication: Codeunit "Azure Functions Authentication";
AzureFunctionsAuthForJson: Interface "Azure Functions Authentication";
@@ -76,51 +77,73 @@ codeunit 6205 "Transaction Storage ABS"
AzureFunctionsAuthForDoc := AzureFunctionsAuthentication.CreateOAuth2WithCert(EndpointBase64, '', ClientID, Cert, AuthURL, '', ResourceURL);
CurrentDate := Today();
- WriteJsonBlobsToABS(DataJsonArrays, AzureFunctionsAuthForJson, CurrentDate, ExportLog);
+ WriteJsonBlobsToABS(AzureFunctionsAuthForJson, CurrentDate, ExportLog);
WriteIncomingDocumentsToABS(IncomingDocs, AzureFunctionsAuthForDoc, CurrentDate, ExportLog);
WriteExportLog(ExportLog, AzureFunctionsAuthForJson, CurrentDate);
FeatureTelemetry.LogUsage('0000LQ4', TransactionStorageTok, ExportedToABSTxt);
end;
[NonDebuggable]
- local procedure WriteJsonBlobsToABS(DataJsonArrays: Dictionary of [Integer, JsonArray]; AzureFunctionsAuth: Interface "Azure Functions Authentication"; CurrentDate: Date; var ExportLog: JsonObject)
+ local procedure WriteJsonBlobsToABS(AzureFunctionsAuth: Interface "Azure Functions Authentication"; CurrentDate: Date; var ExportLog: JsonObject)
var
TableMetadata: Record "Table Metadata";
+ TransStorageExportData: Record "Trans. Storage Export Data";
TransactStorageTableEntry: Record "Transact. Storage Table Entry";
- TransactStorageExport: Codeunit "Transact. Storage Export";
AzureFunctionsResponse: Codeunit "Azure Functions Response";
StringConversionManagement: Codeunit StringConversionManagement;
- TableDataJsonArray: JsonArray;
- TableID: Integer;
ExportedTableCount: Integer;
+ TotalRecordCount: Integer;
ContainerName: Text;
BlobFolder: Text;
BlobName: Text;
JsonData: Text;
CustomDimensions: Dictionary of [Text, Text];
BlobExpirationDate: Date;
+ InStream: InStream;
begin
+ TransStorageExportData.SetAutoCalcFields(Content);
+ if not TransStorageExportData.FindSet() then
+ exit;
+
ContainerName := GetCompanyCVRNumber();
BlobFolder := GetBlobFolder(CurrentDate);
BlobExpirationDate := GetBlobExpirationDate(CurrentDate);
- foreach TableID in DataJsonArrays.Keys() do begin
- TableDataJsonArray := DataJsonArrays.Get(TableID);
- TableDataJsonArray.WriteTo(JsonData);
- TableMetadata.Get(TableID);
- BlobName := StrSubstNo(JsonBlobNameTxt, BlobFolder, StringConversionManagement.RemoveNonAlphaNumericCharacters(TableMetadata.Name));
- AzureFunctionsResponse := SendJsonTextToAzureFunction(AzureFunctionsAuth, ContainerName, BlobName, JsonData, BlobExpirationDate);
- HandleAzureFunctionResponse(AzureFunctionsResponse, StrSubstNo(SendBlobBlockForTableTok, TableID, BlobName), TableID);
- ExportedTableCount += 1;
- ExportLog.Add(BlobName, TableDataJsonArray.Count());
-
- if TransactStorageTableEntry.Get(TableID) then
- TransactStorageExport.SetTableEntryProcessed(TransactStorageTableEntry, TransactStorageTableEntry."Filter Record To DT", true, CopyStr(BlobName, 1, MaxStrLen(TransactStorageTableEntry."Blob Name in ABS")));
- end;
- CustomDimensions.Add(CollectedTablesCountTxt, Format(DataJsonArrays.Count()));
+ repeat
+ TransStorageExportData.SetRange("Table ID", TransStorageExportData."Table ID");
+ TotalRecordCount := 0;
+ repeat
+ TotalRecordCount += TransStorageExportData."Record Count";
+ TransStorageExportData.Content.CreateInStream(InStream);
+ InStream.ReadText(JsonData);
+ TableMetadata.Get(TransStorageExportData."Table ID");
+ BlobName :=
+ StrSubstNo(
+ JsonBlobNameWithPartTxt, BlobFolder,
+ StringConversionManagement.RemoveNonAlphaNumericCharacters(TableMetadata.Name),
+ TransStorageExportData.Part);
+ AzureFunctionsResponse := SendJsonTextToAzureFunction(AzureFunctionsAuth, ContainerName, BlobName, JsonData, BlobExpirationDate);
+ HandleAzureFunctionResponse(
+ AzureFunctionsResponse, StrSubstNo(SendBlobBlockForTableTok, TransStorageExportData."Table ID", BlobName), TransStorageExportData."Table ID");
+ until TransStorageExportData.Next() = 0;
+ UpdateExportedTableData(
+ TransStorageExportData, TransactStorageTableEntry, ExportLog, ExportedTableCount, BlobName, TotalRecordCount);
+ until TransStorageExportData.Next() = 0;
+ TransStorageExportData.DeleteAll(true);
CustomDimensions.Add(ExportedTablesCountTxt, Format(ExportedTableCount));
FeatureTelemetry.LogUsage('0000LQ6', TransactionStorageTok, TablesExportedTxt, CustomDimensions);
end;
+ local procedure UpdateExportedTableData(var TransStorageExportData: Record "Trans. Storage Export Data"; var TransactStorageTableEntry: Record "Transact. Storage Table Entry"; var ExportLog: JsonObject; var ExportedTableCount: Integer; BlobName: Text; TotalRecordCount: Integer)
+ var
+ TransactStorageExport: Codeunit "Transact. Storage Export";
+ begin
+ ExportedTableCount += 1;
+ ExportLog.Add(BlobName, TotalRecordCount);
+ if TransactStorageTableEntry.Get(TransStorageExportData."Table ID") then
+ TransactStorageExport.SetTableEntryProcessed(TransactStorageTableEntry, TransactStorageTableEntry."Filter Record To DT", true, CopyStr(BlobName, 1, MaxStrLen(TransactStorageTableEntry."Blob Name in ABS")));
+ TransStorageExportData.SetRange("Table ID");
+ end;
+
[NonDebuggable]
local procedure WriteIncomingDocumentsToABS(IncomingDocs: Dictionary of [Text, Integer]; AzureFunctionsAuth: Interface "Azure Functions Authentication"; CurrentDate: Date; var ExportLog: JsonObject)
var
diff --git a/Build/DisabledTests/SustainabilityAPITests.json b/Build/DisabledTests/SustainabilityAPITests.json
new file mode 100644
index 0000000000..5a6f777e04
--- /dev/null
+++ b/Build/DisabledTests/SustainabilityAPITests.json
@@ -0,0 +1,7 @@
+[
+ {
+ "codeunitId": 148185,
+ "CodeunitName": "Sustainability API Tests",
+ "Method": "*"
+ }
+]
\ No newline at end of file