Skip to content

[main] features 640066 Add integration events for events for CZ Adv. Payment and CZ Cash Desk - #10079

Open
v-janpopr wants to merge 1 commit into
mainfrom
features/640066-main-EventsforAdvPaymentandCashDesk
Open

[main] features 640066 Add integration events for events for CZ Adv. Payment and CZ Cash Desk#10079
v-janpopr wants to merge 1 commit into
mainfrom
features/640066-main-EventsforAdvPaymentandCashDesk

Conversation

@v-janpopr

@v-janpopr v-janpopr commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

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

  • I read the full diff and it contains only changes I intended.
  • I built the affected app(s) locally with no new analyzer warnings.
  • I ran the change in Business Central and confirmed it behaves as expected.
  • I added or updated tests for the new behavior, or explained below why none are needed.

Risk & compatibility

  • Non-breaking change: The default behavior is identical
  • No data migration, upgrade, or permission changes required.

@github-actions github-actions Bot added the Finance GitHub request for Finance area label Aug 10, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Aug 10, 2026
@v-janpopr
v-janpopr marked this pull request as ready for review August 10, 2026 13:42
@v-janpopr
v-janpopr requested a review from a team August 10, 2026 13:42
PurchAdvLetterHeaderCZZ: Record "Purch. Adv. Letter Header CZZ";
IsHandled: Boolean;
begin
IsHandled := false;

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.

$\textbf{🟠\ High\ Severity\ —\ Events}$

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)");

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.

$\textbf{🟡\ Medium\ Severity\ —\ Performance}$

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

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

Labels

Finance GitHub request for Finance area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant