Repository navigation
Fix #10839: Use document bank account IBAN in FatturaPA - #12216
Marco Antonio Mauro (marcus905) wants to merge 8 commits into
Conversation
Good Sense Reviewer - Round 1Recommendation: AcceptWhat this PR doesThis change carries the selected company bank account from posted sales and service documents into the temporary Fattura header, then exports that account's IBAN. The existing company-information fallback remains when the account cannot be found. The implementation covers invoices and credit memos consistently, preserves the existing event boundary, and the focused tests exercise all four document types plus the fallback. Problem-solution fitFit: Strong The change directly corrects the reported payment instruction and covers every supported document type described by the scenario. Its scope is limited to collecting and exporting the selected bank account. SuggestionsNone. Risk assessment and necessityRisk: Payment export is financially sensitive because an incorrect IBAN can direct a customer to the wrong account. The change is narrow, does not alter posting calculations or public event signatures, and follows the established sales and service bank-account propagation and fallback patterns. Necessity: The change is required to honor the bank account selected on the posted document. Without it, generated invoices can contain incorrect payment instructions.
|
| var | ||
| BankAccount: Record "Bank Account"; | ||
| begin | ||
| if BankAccount.Get(TempFatturaHeader."Company Bank Account Code") then |
There was a problem hiding this comment.
GetPaymentIBAN calls BankAccount.Get before guarding the optional Company Bank Account Code, so documents without a selected bank account perform an unnecessary database lookup before falling back to Company Information. Check that the code is non-empty before calling Get.
Suggested fix (apply manually — could not be anchored as a one-click suggestion):
if TempFatturaHeader."Company Bank Account Code" <> '' then
if BankAccount.Get(TempFatturaHeader."Company Bank Account Code") then
exit(BankAccount.IBAN);Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.51.6
Avoid a Bank Account.Get on a blank document Company Bank Account Code, retaining the existing Company Information.IBAN fallback. Add an independent Service Invoice regression for the blank-code fallback, complementing the existing Sales Invoice and four document-bank tests.
|
Thanks for the review. Addressed in
I also added Validation: Codeunit 144200 executed 51 tests, with 43 passed, including all six IBAN-specific scenarios. The 8 remaining failures are unchanged test-environment issues (Error Messages TestPage failures). No further changes to payment calculation, bank-account selection or the XML serializer were required. |
Good Sense Reviewer - Round 2Recommendation: AcceptWhat this PR doesThe change carries the selected bank account from posted sales and service invoices and credit memos into the Fattura header, then exports that account's IBAN. The new commit skips the Bank Account lookup when the code is blank and adds a service-invoice fallback test. A nonblank code still uses the selected account when found; a blank or missing account falls back to Company Information.IBAN. The existing payment-data event can still handle the operation before any lookup. Problem-solution fitFit: Strong The implementation directly fixes payment instructions that ignored the document's selected bank account, consistently covering all four supported sales and service document types. The new guard preserves the requested blank-code fallback, and the added service test verifies the exact exported IBAN after normal posting. Status of previous suggestionsNo previous suggestions. New observations (commits since round 1)None. No new issue was found in the PR-owned changes since the previous round. Risk assessment and necessityRisk: An incorrect IBAN can send customers to the wrong account, so payment export is financially sensitive. The round-2 production change only guards an optional lookup; it does not change account selection for nonblank codes, payment amounts, posting, public signatures, or XML structure. The added test uses the existing setup restoration, normal service posting, a blank-code assertion on the posted invoice, and an exact XML value assertion. Necessity: The fix is needed to honor the bank account selected on the document. Without it, payment XML can direct customers to another company account, requiring a payment-data event replacement as a workaround. The round-2 guard avoids an unnecessary lookup, and the service regression protects the existing fallback without expanding production scope.
|
What & why
The Italian FatturaPA exporter currently always writes
Company Information.IBANtoDatiPagamento/DettaglioPagamento/IBAN, even when the posted document contains a differentCompany Bank Account Code.This change carries the document-specific company bank account into the temporary
Fattura Headerwhile the source document is collected, and uses that bank account's IBAN when generating the payment XML.The existing localization layering is preserved:
Fattura Doc. Helper.Serv. Fattura Subscribers.Export FatturaPA Documentconsumes the normalized value from the temporaryFattura Headerand does not depend directly on Service document tables.When no document-specific company bank account can be resolved, the exporter continues to use
Company Information.IBAN, preserving the existing fallback behavior.Linked work
Fixes #10839
Fixes AB#657000
How I validated this
What I tested and the outcome
Built the localized IT Base Application and Tests-Local and ran codeunit
144200 "FatturaPA Test".Added regression coverage for:
Company Information.IBANfallback.The four positive scenarios set the Company Bank Account Code on the source document before posting, so the tests cover both normal posting propagation and FatturaPA export.
Result:
All five tests added for this fix pass.
The remaining 8 failures are unrelated existing test-environment failures in the
PostAndSend...WithMissingFields/SendPosted...WithMissingFieldstests. They all fail inLibrary - Error Message.LoadErrorMessageswith:The standard FatturaPA Sales/Service Invoice and Credit Memo exports, batch exports, and XSD validation tests pass.
Risk & compatibility
The behavior change is limited to the IBAN emitted in FatturaPA payment data.
Documents with a
Company Bank Account Codenow export the IBAN from that Bank Account. Documents without a document-specific bank account retain the existingCompany Information.IBANbehavior.The existing
OnBeforePopulatePaymentDataextensibility point remains unchanged.No changes are made to posting behavior, payment calculations, FatturaPA routing, or document validation.