[main] features 640066 Add integration events for events for CZ Adv. Payment and CZ Cash Desk - #10079
[main] features 640066 Add integration events for events for CZ Adv. Payment and CZ Cash Desk#10079v-janpopr wants to merge 1 commit into
Conversation
…nce mandatory fields check
| PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ"; | ||
| IsHandled: Boolean; | ||
| begin | ||
| IsHandled := false; |
There was a problem hiding this comment.
The new OnBeforeValidateAdvanceLetterNoCZZ IsHandled hook wraps the entire OnValidate trigger of "Advance Letter No. CZZ", so a subscriber that sets IsHandled := true silently skips all referential and consistency validation below it: the Gen. Document Type payment check, the Document Type/Account Type case validation, the Get()/TestField() cross-checks against the sales/purchase advance letter header (Bill-to Customer No./Pay-to Vendor No., Currency Code), and the Amount/Dimension Set ID defaulting. Per BCQuality guidance, IsHandled should scope only a safe, side-effect-free value calculation - critical referential-integrity validation should run unconditionally, or be exposed via a separate OnAfter... event, not be bypassable via IsHandled.
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.31.4
| CashDocumentHeaderCZP.VATRounding(); | ||
| CashDocumentHeaderCZP.CalcFields(CashDocumentHeaderCZP."Amount Including VAT", CashDocumentHeaderCZP."Amount Including VAT (LCY)"); | ||
| CashDocumentHeaderCZP.TestField(CashDocumentHeaderCZP."Amount Including VAT"); | ||
| CashDocumentHeaderCZP.TestField(CashDocumentHeaderCZP."Amount Including VAT (LCY)"); |
There was a problem hiding this comment.
The new SkipAmountsTestFields extension point lets a subscriber skip the two TestField checks on the Amount Including VAT FlowFields, but CalcFields for both FlowFields still runs unconditionally beforehand. When SkipAmountsTestFields is set true, this performs a database-backed FlowField recalculation whose result is now never used. Move CalcFields inside the if not SkipAmountsTestFields then block so the expensive read is skipped together with the validation it exists to support.
Suggested fix (apply manually — could not be anchored as a one-click suggestion):
CashDocumentHeaderCZP.VATRounding();
if not SkipAmountsTestFields then begin
CashDocumentHeaderCZP.CalcFields(CashDocumentHeaderCZP."Amount Including VAT", CashDocumentHeaderCZP."Amount Including VAT (LCY)");
CashDocumentHeaderCZP.TestField(CashDocumentHeaderCZP."Amount Including VAT");
CashDocumentHeaderCZP.TestField(CashDocumentHeaderCZP."Amount Including VAT (LCY)");
end;👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.31.4
What & why
Added the OnBeforeValidateAdvanceLetterNoCZZ and OnBeforeLookupAdvanceLetterNoCZZ integration events. These events allow subscribers to override the default validation and lookup behavior of the Advance Letter No. CZZ field on cash document lines. Added the SkipAmountsTestFields parameter to the OnBeforeCheckMandatoryFields event.
To enable partners to customize selected parts of advance payment processing and better adapt the functionality to specific business requirements. Allows subscribers to skip mandatory validation of the cash document amount fields when needed.
Linked work
Fixes AB#640066
How I validated this
Risk & compatibility