Skip to content

[master]-[BE] [PEPPOL] There is a problem between the totals on the invoice printout and the XML PEPPOL with Payment discount#9648

Draft
MSNehaNawal wants to merge 2 commits into
microsoft:mainfrom
MSNehaNawal:bugs/Bug-643204-BE_Peppol_Unmatchedtotals_PmtDisc
Draft

[master]-[BE] [PEPPOL] There is a problem between the totals on the invoice printout and the XML PEPPOL with Payment discount#9648
MSNehaNawal wants to merge 2 commits into
microsoft:mainfrom
MSNehaNawal:bugs/Bug-643204-BE_Peppol_Unmatchedtotals_PmtDisc

Conversation

@MSNehaNawal

@MSNehaNawal MSNehaNawal commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Bug 643204: [ALL-E] [BE] [PEPPOL] There is a problem between the totals on the invoice printout and the XML PEPPOL file that is generated when using a discount % in the payment condtions. So in Belgium we calc the taxable amount on the total amount - discount%

Fixes AB#643204

@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 From Fork Pull request is coming from a fork Integration GitHub request for Integration area Linked Issue is linked to a Azure Boards work item labels Jul 22, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Jul 22, 2026
exit(CountryRegion."ISO Code" = 'DK');
end;

local procedure IsBelgianCompany(): Boolean

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont we have a BE localization of PEPPOL?

@MSNehaNawal MSNehaNawal Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Groenbech96 Peppol BE, do not have this codeunit.
Below is the call stack-
image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to use different service code in BE env. ("PEPPOL 3.0 - BE Sales")

and do changes in
https://github.com/microsoft/BCApps/tree/main/src/Apps/BE/PeppolBE/App

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Groenbech96 @djukicmilica
I have made the suggested changes, can you please have a look.


if TempVATAmtLine.FindSet() then
repeat
if TempVATAmtLine."Pmt. Discount Amount" <> 0 then begin

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use ModifyAll instead of the loop?

@Groenbech96

Copy link
Copy Markdown
Contributor

Recommendation: implement this through the PEPPOL Tax Info Provider interface instead of a new integration event.

This module currently has no integration events — all format-specific behavior goes through the enum-implements-interface pattern (the BE format values in PEPPOL30FormatBE.EnumExt.al already override PEPPOL30 Validation and the posted-document iterator). Adding the module''s first [IntegrationEvent] that mutates the shared TempVATAmtLine buffer introduces a second, less discoverable extensibility mechanism.

Pmt. Discount Amount is written to the buffer in exactly one place — PEPPOL30 Impl.GetTaxTotals (VATAmtLine."Pmt. Discount Amount" += SalesLine."Pmt. Discount Amount";) — and GetTaxTotals is part of the PEPPOL Tax Info Provider interface. So the same result can be achieved on-pattern:

1. Add a BE codeunit implementing PEPPOL Tax Info Provider that delegates every method to codeunit PEPPOL30 (it''s Access = Public), and in GetTaxTotals zeroes the payment discount before delegating:

procedure GetTaxTotals(SalesLine: Record "Sales Line"; var VATAmtLine: Record "VAT Amount Line")
begin
    SalesLine."Pmt. Discount Amount" := 0; // BE: exclude payment discount from PEPPOL totals
    PEPPOL30.GetTaxTotals(SalesLine, VATAmtLine);
end;

2. Point the BE format values at it in PEPPOL30FormatBE.EnumExt.al (on both PEPPOL 3.0 - BE Sales and PEPPOL 3.0 - BE Service):

Implementation = ... , "PEPPOL Tax Info Provider" = "PEPPOL30 BE Tax Info";

3. Remove the OnAfterGetSalesTotals event from PEPPOL30 Common and the subscriber from PEPPOL30 BE Subscribers.

Because GetTaxTotals is the sole writer of that field, zeroing the by-value SalesLine copy before accumulation produces the identical buffer as the post-loop in the subscriber (every line ends with Pmt. Discount Amount = 0), so all downstream totals and the payment-discount AllowanceCharge (auto-skipped via its = 0 guard) stay consistent. The conditional handling is fine as-is — it only takes effect when a payment discount is actually present.

This keeps all format-specific logic behind the interface, avoids mutating shared state through an event, and needs no new publisher.

@djukicmilica

Copy link
Copy Markdown
Contributor

Also, add some tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1 From Fork Pull request is coming from a fork Integration GitHub request for Integration area Linked Issue is linked to a Azure Boards work item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants