-
Notifications
You must be signed in to change notification settings - Fork 373
Add VAT rate resolution and VAT amount difference for E-Document purchases #8251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
79657ea
3baca49
98fae1a
31a7c57
b8fb566
34b2207
47c64e8
dbb35b7
e0dd7f7
4bfea7d
5d4b175
f6c8e55
91447d6
a89ec5c
b634ab3
8a0a6d7
05edca8
ac58f63
31784c7
72373db
0c0ed31
1bb68d8
9e9d974
b745f53
307a1de
b0e91be
da77a1c
4f497cd
886c294
bb35470
074152d
eb04ce2
f3f27b9
e9360b6
8f1d64e
bc5d54d
7c5f77e
ad40024
5a34323
3caf30f
c96a46d
0604d4f
fb6df3a
1d41664
ddfcd2a
35cdfac
fc4e7aa
39a9379
20f51b0
2e8171c
eee3358
a826a76
224dba0
0582b39
98e9df4
2cc30fd
9db4a01
8e9474d
73a0312
36d5570
13c97d3
63562f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -176,6 +176,7 @@ codeunit 6117 "E-Doc. Create Purchase Invoice" implements IEDocumentFinishDraft, | |||||||||||
| LastReceiptNo := EDocLineByReceipt.ReceiptNo; | ||||||||||||
| end; | ||||||||||||
| EDocLineByReceipt.Close(); | ||||||||||||
| EDocPurchaseDocumentHelper.ApplyVATDifferenceToLines(PurchaseHeader, EDocumentPurchaseHeader); | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ApplyVATDifference called before invoice discount
Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||||||||
| PurchaseHeader.Modify(); | ||||||||||||
| PurchCalcDiscByType.ApplyInvDiscBasedOnAmt(EDocumentPurchaseHeader."Total Discount", PurchaseHeader); | ||||||||||||
| exit(PurchaseHeader); | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,7 +7,9 @@ namespace Microsoft.eServices.EDocument.Processing.Import; | |||||||||
| using Microsoft.eServices.EDocument; | ||||||||||
| using Microsoft.eServices.EDocument.Processing; | ||||||||||
| using Microsoft.eServices.EDocument.Processing.Import.Purchase; | ||||||||||
| using Microsoft.Finance.Currency; | ||||||||||
| using Microsoft.Finance.Dimension; | ||||||||||
| using Microsoft.Finance.VAT.Setup; | ||||||||||
| using Microsoft.Foundation.Attachment; | ||||||||||
| using Microsoft.Purchases.Document; | ||||||||||
| using Microsoft.Purchases.Posting; | ||||||||||
|
|
@@ -40,6 +42,9 @@ codeunit 6402 "E-Doc. Purch. Doc. Helper" | |||||||||
| PurchaseLine."Variant Code" := EDocumentPurchaseLine."[BC] Variant Code"; | ||||||||||
| PurchaseLine.Type := EDocumentPurchaseLine."[BC] Purchase Line Type"; | ||||||||||
| ValidateFieldWithContext(PurchaseLine, PurchaseLine.FieldNo("No."), EDocumentPurchaseLine."[BC] Purchase Type No."); | ||||||||||
| if EDocumentPurchaseLine."[BC] VAT Prod. Posting Group" <> '' then | ||||||||||
| ValidateFieldWithContext( | ||||||||||
| PurchaseLine, PurchaseLine.FieldNo("VAT Prod. Posting Group"), EDocumentPurchaseLine."[BC] VAT Prod. Posting Group"); | ||||||||||
| if (PurchaseLine.Type = PurchaseLine.Type::"G/L Account") and HasTotalDiscount then | ||||||||||
| ValidateFieldWithContext(PurchaseLine, PurchaseLine.FieldNo("Allow Invoice Disc."), true); | ||||||||||
| PurchaseLine.Description := EDocumentPurchaseLine.Description; | ||||||||||
|
|
@@ -154,6 +159,43 @@ codeunit 6402 "E-Doc. Purch. Doc. Helper" | |||||||||
| EDocImpSessionTelemetry.SetBool('Totals Validation', TryValidateDocumentTotals(PurchaseHeader)); | ||||||||||
| end; | ||||||||||
|
|
||||||||||
| procedure ApplyVATDifferenceToLines(PurchaseHeader: Record "Purchase Header"; EDocumentPurchaseHeader: Record "E-Document Purchase Header") | ||||||||||
| var | ||||||||||
| PurchaseLine: Record "Purchase Line"; | ||||||||||
| Currency: Record Currency; | ||||||||||
| LineAmount: Decimal; | ||||||||||
| TotalLineAmount, VATDiffRemainder, VATDiffForLine : Decimal; | ||||||||||
| begin | ||||||||||
| if EDocumentPurchaseHeader."Applied VAT Amount Diff." = 0 then | ||||||||||
| exit; | ||||||||||
|
|
||||||||||
| TotalLineAmount := ComputeTotalLineAmount(EDocumentPurchaseHeader."E-Document Entry No."); | ||||||||||
| if TotalLineAmount = 0 then | ||||||||||
| exit; | ||||||||||
|
|
||||||||||
| if PurchaseHeader."Currency Code" = '' then | ||||||||||
| Currency.InitRoundingPrecision() | ||||||||||
| else | ||||||||||
| Currency.Get(PurchaseHeader."Currency Code"); | ||||||||||
|
|
||||||||||
| PurchaseLine.SetRange("Document Type", PurchaseHeader."Document Type"); | ||||||||||
| PurchaseLine.SetRange("Document No.", PurchaseHeader."No."); | ||||||||||
| PurchaseLine.SetFilter(Type, '<>%1', PurchaseLine.Type::" "); | ||||||||||
| if not PurchaseLine.FindSet() then | ||||||||||
| exit; | ||||||||||
|
|
||||||||||
| VATDiffRemainder := 0; | ||||||||||
| repeat | ||||||||||
| LineAmount := PurchaseLine."Line Amount" - PurchaseLine."Inv. Discount Amount"; | ||||||||||
| if LineAmount <> 0 then begin | ||||||||||
| VATDiffForLine := VATDiffRemainder + EDocumentPurchaseHeader."Applied VAT Amount Diff." * LineAmount / TotalLineAmount; | ||||||||||
| PurchaseLine."VAT Difference" := Round(VATDiffForLine, Currency."Amount Rounding Precision"); | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. VAT Difference set without Validate, skips BC checks
Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||||||
| VATDiffRemainder := VATDiffForLine - PurchaseLine."VAT Difference"; | ||||||||||
| PurchaseLine.Modify(); | ||||||||||
| end; | ||||||||||
| until PurchaseLine.Next() = 0; | ||||||||||
| end; | ||||||||||
|
|
||||||||||
| procedure RevertCreatedDocument(EDocument: Record "E-Document") | ||||||||||
| var | ||||||||||
| PurchaseHeader: Record "Purchase Header"; | ||||||||||
|
|
@@ -181,4 +223,25 @@ codeunit 6402 "E-Doc. Purch. Doc. Helper" | |||||||||
| exit; | ||||||||||
| PurchaseHeader.Validate("Posting Date", EDocumentPurchaseHeader."Document Date"); | ||||||||||
| end; | ||||||||||
|
|
||||||||||
| procedure SetNormalReverseChargeFilter(var VATPostingSetup: Record "VAT Posting Setup"; VATBusPostingGroup: Code[20]) | ||||||||||
| begin | ||||||||||
| VATPostingSetup.SetRange("VAT Bus. Posting Group", VATBusPostingGroup); | ||||||||||
| VATPostingSetup.SetFilter("VAT Calculation Type", '%1|%2', | ||||||||||
| VATPostingSetup."VAT Calculation Type"::"Normal VAT", | ||||||||||
| VATPostingSetup."VAT Calculation Type"::"Reverse Charge VAT"); | ||||||||||
| end; | ||||||||||
|
|
||||||||||
| local procedure ComputeTotalLineAmount(EDocEntryNo: Integer): Decimal | ||||||||||
| var | ||||||||||
| EDocPurchLine: Record "E-Document Purchase Line"; | ||||||||||
| TotalLineAmount: Decimal; | ||||||||||
| begin | ||||||||||
| EDocPurchLine.SetRange("E-Document Entry No.", EDocEntryNo); | ||||||||||
| if EDocPurchLine.FindSet() then | ||||||||||
| repeat | ||||||||||
| TotalLineAmount += Round(EDocPurchLine.Quantity * EDocPurchLine."Unit Price" - EDocPurchLine."Total Discount"); | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ComputeTotalLineAmount uses default Round precision
Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||||||
| until EDocPurchLine.Next() = 0; | ||||||||||
| exit(TotalLineAmount); | ||||||||||
| end; | ||||||||||
| } | ||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,8 +8,11 @@ using Microsoft.eServices.EDocument; | |||||||||||||||
| using Microsoft.eServices.EDocument.Processing.AI; | ||||||||||||||||
| using Microsoft.eServices.EDocument.Processing.Import.Purchase; | ||||||||||||||||
| using Microsoft.eServices.EDocument.Processing.Interfaces; | ||||||||||||||||
| using Microsoft.Finance.GeneralLedger.Setup; | ||||||||||||||||
| using Microsoft.Finance.VAT.Setup; | ||||||||||||||||
| using Microsoft.Foundation.UOM; | ||||||||||||||||
| using Microsoft.Purchases.Document; | ||||||||||||||||
| using Microsoft.Purchases.Setup; | ||||||||||||||||
| using Microsoft.Purchases.Vendor; | ||||||||||||||||
| using System.Log; | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -36,6 +39,9 @@ codeunit 6406 "EDoc Prepare Purch. Draft" | |||||||||||||||
| IUnitOfMeasureProvider: Interface IUnitOfMeasureProvider; | ||||||||||||||||
| IPurchaseLineProvider: Interface IPurchaseLineProvider; | ||||||||||||||||
| IPurchaseOrderProvider: Interface IPurchaseOrderProvider; | ||||||||||||||||
| LineAmount: Decimal; | ||||||||||||||||
| LineVATAmount: Decimal; | ||||||||||||||||
| TotalLineVATAmount: Decimal; | ||||||||||||||||
| begin | ||||||||||||||||
| IUnitOfMeasureProvider := EDocImportParameters."Processing Customizations"; | ||||||||||||||||
| IPurchaseLineProvider := EDocImportParameters."Processing Customizations"; | ||||||||||||||||
|
|
@@ -72,16 +78,26 @@ codeunit 6406 "EDoc Prepare Purch. Draft" | |||||||||||||||
| EDocumentPurchaseLine.Modify(); | ||||||||||||||||
| until EDocumentPurchaseLine.Next() = 0; | ||||||||||||||||
|
|
||||||||||||||||
| // Resolve VAT Product Posting Groups from extracted VAT rates | ||||||||||||||||
| ResolveVATProductPostingGroups(EDocument."Entry No", EDocumentPurchaseHeader); | ||||||||||||||||
|
|
||||||||||||||||
| CopilotLineMatching(EDocument."Entry No"); | ||||||||||||||||
| end; | ||||||||||||||||
|
|
||||||||||||||||
| Clear(EDocumentPurchaseLine); | ||||||||||||||||
| EDocumentPurchaseLine.SetRange("E-Document Entry No.", EDocument."Entry No"); | ||||||||||||||||
| TotalLineVATAmount := 0; | ||||||||||||||||
| if EDocumentPurchaseLine.FindSet() then | ||||||||||||||||
| repeat | ||||||||||||||||
| LineAmount := Round(EDocumentPurchaseLine.Quantity * EDocumentPurchaseLine."Unit Price" - EDocumentPurchaseLine."Total Discount"); | ||||||||||||||||
| LineVATAmount := Round(LineAmount * EDocumentPurchaseLine."VAT Rate" / 100); | ||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TotalLineVATAmount uses default Round, ignores currency precision
Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||||||||||||
| TotalLineVATAmount += LineVATAmount; | ||||||||||||||||
| EDocImpSessionTelemetry.SetLine(EDocumentPurchaseLine.SystemId); | ||||||||||||||||
| until EDocumentPurchaseLine.Next() = 0; | ||||||||||||||||
|
|
||||||||||||||||
| ComputeAndApplyVATAmountDifference(EDocumentPurchaseHeader, TotalLineVATAmount); | ||||||||||||||||
| EDocumentPurchaseHeader.Modify(); | ||||||||||||||||
|
|
||||||||||||||||
| LogAllActivitySessionChanges(EDocActivityLogSession); | ||||||||||||||||
|
|
||||||||||||||||
| if EDocActivityLogSession.EndSession() then; | ||||||||||||||||
|
|
@@ -138,6 +154,67 @@ codeunit 6406 "EDoc Prepare Purch. Draft" | |||||||||||||||
| ActivityLog.Log(); | ||||||||||||||||
| end; | ||||||||||||||||
|
|
||||||||||||||||
| local procedure ResolveVATProductPostingGroups(EDocumentEntryNo: Integer; EDocumentPurchaseHeader: Record "E-Document Purchase Header") | ||||||||||||||||
| var | ||||||||||||||||
| PurchasesPayablesSetup: Record "Purchases & Payables Setup"; | ||||||||||||||||
| EDocumentPurchaseLine: Record "E-Document Purchase Line"; | ||||||||||||||||
| Vendor: Record Vendor; | ||||||||||||||||
| VATRate: Decimal; | ||||||||||||||||
| LineCount: Integer; | ||||||||||||||||
| begin | ||||||||||||||||
| if not PurchasesPayablesSetup.Get() then | ||||||||||||||||
| exit; | ||||||||||||||||
| if not PurchasesPayablesSetup."Resolve VAT Group Purch EDoc" then | ||||||||||||||||
| exit; | ||||||||||||||||
| Vendor := EDocumentPurchaseHeader.GetBCVendor(); | ||||||||||||||||
| if Vendor."No." = '' then | ||||||||||||||||
| exit; | ||||||||||||||||
| if Vendor."VAT Bus. Posting Group" = '' then | ||||||||||||||||
| exit; | ||||||||||||||||
|
|
||||||||||||||||
| EDocumentPurchaseLine.SetRange("E-Document Entry No.", EDocumentEntryNo); | ||||||||||||||||
| LineCount := EDocumentPurchaseLine.Count(); | ||||||||||||||||
| if LineCount = 0 then | ||||||||||||||||
| exit; | ||||||||||||||||
|
|
||||||||||||||||
| if EDocumentPurchaseLine.FindSet() then | ||||||||||||||||
| repeat | ||||||||||||||||
| VATRate := EDocumentPurchaseLine."VAT Rate"; | ||||||||||||||||
|
|
||||||||||||||||
| // Single-line fallback: compute from header Total VAT | ||||||||||||||||
| if (VATRate = 0) and (LineCount = 1) and | ||||||||||||||||
| (EDocumentPurchaseHeader."Total VAT" > 0) and (EDocumentPurchaseHeader."Sub Total" > 0) | ||||||||||||||||
| then | ||||||||||||||||
| VATRate := Round((EDocumentPurchaseHeader."Total VAT" / EDocumentPurchaseHeader."Sub Total") * 100, 0.01); | ||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Single-line VAT rate fallback uses header-level Sub TotalFor a single-line document where Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||||||||||||
|
|
||||||||||||||||
| if VATRate > 0 then begin | ||||||||||||||||
| EDocumentPurchaseLine."[BC] VAT Prod. Posting Group" := | ||||||||||||||||
| FindVATProductPostingGroup(Vendor."VAT Bus. Posting Group", VATRate); | ||||||||||||||||
| EDocumentPurchaseLine."[BC] VAT Rate Mismatch" := | ||||||||||||||||
| EDocumentPurchaseLine."[BC] VAT Prod. Posting Group" = ''; | ||||||||||||||||
| EDocumentPurchaseLine.Modify(); | ||||||||||||||||
| if EDocumentPurchaseLine."[BC] VAT Rate Mismatch" then | ||||||||||||||||
| EDocumentPurchaseLine.LogVATRateMismatch(Vendor."VAT Bus. Posting Group", VATRate) | ||||||||||||||||
| else | ||||||||||||||||
| EDocumentPurchaseLine.LogVATRateResolved(Vendor."VAT Bus. Posting Group", VATRate); | ||||||||||||||||
| end; | ||||||||||||||||
| until EDocumentPurchaseLine.Next() = 0; | ||||||||||||||||
| end; | ||||||||||||||||
|
|
||||||||||||||||
| local procedure FindVATProductPostingGroup(VATBusPostingGroup: Code[20]; VATRate: Decimal): Code[20] | ||||||||||||||||
| var | ||||||||||||||||
| VATPostingSetup: Record "VAT Posting Setup"; | ||||||||||||||||
| EDocPurchDocHelper: Codeunit "E-Doc. Purch. Doc. Helper"; | ||||||||||||||||
| begin | ||||||||||||||||
| EDocPurchDocHelper.SetNormalReverseChargeFilter(VATPostingSetup, VATBusPostingGroup); | ||||||||||||||||
| VATPostingSetup.SetRange("VAT %", VATRate); | ||||||||||||||||
| if VATPostingSetup.Count() = 1 then begin | ||||||||||||||||
| VATPostingSetup.FindFirst(); | ||||||||||||||||
| exit(VATPostingSetup."VAT Prod. Posting Group"); | ||||||||||||||||
| end; | ||||||||||||||||
| exit(''); | ||||||||||||||||
| end; | ||||||||||||||||
|
|
||||||||||||||||
| local procedure CopilotLineMatching(EDocumentEntryNo: Integer) | ||||||||||||||||
| var | ||||||||||||||||
| EDocumentPurchaseLine: Record "E-Document Purchase Line"; | ||||||||||||||||
|
|
@@ -172,4 +249,68 @@ codeunit 6406 "EDoc Prepare Purch. Draft" | |||||||||||||||
| if Codeunit.Run(Codeunit::"E-Doc. Deferral Matching", EDocumentPurchaseLine) then; | ||||||||||||||||
| end; | ||||||||||||||||
| end; | ||||||||||||||||
|
|
||||||||||||||||
| local procedure ComputeAndApplyVATAmountDifference(var EDocumentPurchaseHeader: Record "E-Document Purchase Header"; TotalLineVATAmount: Decimal) | ||||||||||||||||
| var | ||||||||||||||||
| PurchasesPayablesSetup: Record "Purchases & Payables Setup"; | ||||||||||||||||
| GeneralLedgerSetup: Record "General Ledger Setup"; | ||||||||||||||||
| ActivityLog: Codeunit "Activity Log Builder"; | ||||||||||||||||
| VATAmountDiff: Decimal; | ||||||||||||||||
| Reasoning: Text[250]; | ||||||||||||||||
| VATDiffAppliedLbl: Label 'Applied VAT amount difference of %1 to reconcile document Total VAT %2 with computed Total Line VAT Amount %3.', Comment = '%1 = VAT difference, %2 = Total VAT, %3 = Total Line VAT Amount'; | ||||||||||||||||
| VATDiffSkippedSetupLbl: Label 'VAT amount difference of %1 was not applied because Apply VAT Diff. For Purch. E-Doc. is disabled in Purchases & Payables Setup.', Comment = '%1 = VAT difference'; | ||||||||||||||||
| VATDiffSkippedAllowLbl: Label 'VAT amount difference of %1 was not applied because Allow VAT Difference is disabled in Purchases & Payables Setup.', Comment = '%1 = VAT difference'; | ||||||||||||||||
| VATDiffSkippedMaxLbl: Label 'VAT amount difference of %1 was not applied because it exceeds the Max. VAT Difference Allowed of %2 in General Ledger Setup.', Comment = '%1 = VAT difference, %2 = Max. VAT Difference Allowed'; | ||||||||||||||||
| begin | ||||||||||||||||
| EDocumentPurchaseHeader."Applied VAT Amount Diff." := 0; | ||||||||||||||||
|
|
||||||||||||||||
| if (EDocumentPurchaseHeader."Total VAT" = 0) or (TotalLineVATAmount = EDocumentPurchaseHeader."Total VAT") then | ||||||||||||||||
| exit; | ||||||||||||||||
|
|
||||||||||||||||
| VATAmountDiff := EDocumentPurchaseHeader."Total VAT" - TotalLineVATAmount; | ||||||||||||||||
|
|
||||||||||||||||
| if not PurchasesPayablesSetup.Get() then | ||||||||||||||||
| exit; | ||||||||||||||||
|
|
||||||||||||||||
| if not PurchasesPayablesSetup."Apply VAT Diff. For Purch EDoc" then begin | ||||||||||||||||
| Reasoning := CopyStr(StrSubstNo(VATDiffSkippedSetupLbl, VATAmountDiff), 1, MaxStrLen(Reasoning)); | ||||||||||||||||
| ActivityLog | ||||||||||||||||
| .Init(Database::"E-Document Purchase Header", EDocumentPurchaseHeader.FieldNo("Applied VAT Amount Diff."), EDocumentPurchaseHeader.SystemId) | ||||||||||||||||
| .SetExplanation(Reasoning) | ||||||||||||||||
| .SetType(Enum::"Activity Log Type"::"AL") | ||||||||||||||||
| .Log(); | ||||||||||||||||
| exit; | ||||||||||||||||
| end; | ||||||||||||||||
|
|
||||||||||||||||
| if not PurchasesPayablesSetup."Allow VAT Difference" then begin | ||||||||||||||||
| Reasoning := CopyStr(StrSubstNo(VATDiffSkippedAllowLbl, VATAmountDiff), 1, MaxStrLen(Reasoning)); | ||||||||||||||||
| ActivityLog | ||||||||||||||||
| .Init(Database::"E-Document Purchase Header", EDocumentPurchaseHeader.FieldNo("Applied VAT Amount Diff."), EDocumentPurchaseHeader.SystemId) | ||||||||||||||||
| .SetExplanation(Reasoning) | ||||||||||||||||
| .SetType(Enum::"Activity Log Type"::"AL") | ||||||||||||||||
| .Log(); | ||||||||||||||||
| exit; | ||||||||||||||||
| end; | ||||||||||||||||
|
|
||||||||||||||||
| if not GeneralLedgerSetup.Get() then | ||||||||||||||||
| exit; | ||||||||||||||||
| if Abs(VATAmountDiff) > GeneralLedgerSetup."Max. VAT Difference Allowed" then begin | ||||||||||||||||
| Reasoning := CopyStr(StrSubstNo(VATDiffSkippedMaxLbl, VATAmountDiff, GeneralLedgerSetup."Max. VAT Difference Allowed"), 1, MaxStrLen(Reasoning)); | ||||||||||||||||
| ActivityLog | ||||||||||||||||
| .Init(Database::"E-Document Purchase Header", EDocumentPurchaseHeader.FieldNo("Applied VAT Amount Diff."), EDocumentPurchaseHeader.SystemId) | ||||||||||||||||
| .SetExplanation(Reasoning) | ||||||||||||||||
| .SetType(Enum::"Activity Log Type"::"AL") | ||||||||||||||||
| .Log(); | ||||||||||||||||
| exit; | ||||||||||||||||
| end; | ||||||||||||||||
|
|
||||||||||||||||
| EDocumentPurchaseHeader."Applied VAT Amount Diff." := VATAmountDiff; | ||||||||||||||||
|
|
||||||||||||||||
| Reasoning := CopyStr(StrSubstNo(VATDiffAppliedLbl, VATAmountDiff, EDocumentPurchaseHeader."Total VAT", TotalLineVATAmount), 1, MaxStrLen(Reasoning)); | ||||||||||||||||
| ActivityLog | ||||||||||||||||
| .Init(Database::"E-Document Purchase Header", EDocumentPurchaseHeader.FieldNo("Applied VAT Amount Diff."), EDocumentPurchaseHeader.SystemId) | ||||||||||||||||
| .SetExplanation(Reasoning) | ||||||||||||||||
| .SetType(Enum::"Activity Log Type"::"AL") | ||||||||||||||||
| .Log(); | ||||||||||||||||
| end; | ||||||||||||||||
| } | ||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolve VAT Group defaults false, Apply VAT Diff defaults true
After upgrade, existing tenants will have
"Apply VAT Diff. For Purch EDoc"=true(explicitInitValue = true) but"Resolve VAT Group Purch EDoc"=false(no InitValue). VAT differences will be redistributed across lines that still carry the BC-default VAT Prod. Posting Group rather than the e-document-matched one, potentially resulting in incorrect VAT postings.Recommendation:
InitValue = trueto"Resolve VAT Group Purch EDoc"to match the paired field's default, or setInitValue = falseon"Apply VAT Diff. For Purch EDoc"so both features are opt-in together.👍 useful · ❤️ especially valuable · 👎 wrong - reply with why