fix(billing): EN16931 critical compliance gaps in UBL XML builder (#177)#178
Open
b3lz3but wants to merge 1 commit intocaptainpragmatic:masterfrom
Open
fix(billing): EN16931 critical compliance gaps in UBL XML builder (#177)#178b3lz3but wants to merge 1 commit intocaptainpragmatic:masterfrom
b3lz3but wants to merge 1 commit intocaptainpragmatic:masterfrom
Conversation
…ptainpragmatic#177) - BR-42: emit AllowanceChargeReasonCode ("95") and AllowanceChargeReason on line-level AllowanceCharge; ANAF Schematron rejected any invoice with a line discount because BT-140 was missing - BT-131: LineExtensionAmount is now net of line-level allowances so the line sum matches Invoice.subtotal_cents (already net); fixes BR-CO-10 violation that cascaded into wrong TaxExclusive/TaxInclusive totals - BT-113/BT-115: LegalMonetaryTotal now subtracts prepaid payments. Emits PrepaidAmount when any collected payment exists and PayableAmount reflects the remaining balance; fully-unpaid invoices still omit PrepaidAmount - Mirror all three fixes in UBLCreditNoteBuilder for symmetry Addresses captainpragmatic#177. Dead payment_means entries, meta JSON sanitization, and the credit-note document-level allowances/charges gap are tied to PR captainpragmatic#160's additions and will be handled there. Signed-off-by: Ciprian Radulescu <craps2003@gmail.com>
Contributor
Author
|
@mostlyvirtual PR ready — this addresses the CRITICAL+HIGH findings from #177 (BR-42, BT-131, BT-113/115) on master. The MEDIUM items (meta JSON validation, credit-note doc-level allowances, dead |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes three critical EN16931 compliance gaps in the e-Factura XML builder that caused ANAF Schematron rejection for any invoice with line discounts or partial payments.
AllowanceChargeReasonCode=\"95\"andAllowanceChargeReason=\"Discount\"(BT-140). Previously missing — every invoice with a line discount was rejected.LineExtensionAmountis now net of line-level allowances. Previously gross (unit_price × quantity), which violated BR-CO-10 (line sum must equalInvoice.subtotal_cents, already net) and cascaded into wrong TaxExclusive/TaxInclusive totals.LegalMonetaryTotalnow subtracts prepaid payments. EmitsPrepaidAmountwhen any collected payment exists andPayableAmountreflects the remaining balance. Fully-unpaid invoices still omitPrepaidAmount.All three fixes are mirrored in
UBLCreditNoteBuilderfor symmetry.Out of scope (tied to PR #160)
The meta-JSON validation, credit-note document-level allowances/charges parity, and dead
PAYMENT_MEANS_CODESentries listed in #177 all touch code introduced by PR #160 and will be addressed there (or in a follow-up once it merges).Test plan
Closes #177
🤖 Generated with Claude Code