[Master]-Slice 425446: Payment Journal Batch Total - #10538
[Master]-Slice 425446: Payment Journal Batch Total#10538ViditGupta1277 wants to merge 2 commits into
Conversation
| begin | ||
| end; | ||
|
|
||
| [IntegrationEvent(false, false)] |
There was a problem hiding this comment.
The new OnCalcBatchTotalOnAfterCopyFilters publisher is added without the XML summary/param documentation used by neighboring GenJnlManagement events, which makes the subscriber contract less discoverable. Add matching event documentation in the ES/NL/W1 GenJnlManagement.Codeunit.al publishers.
Agent judgement — not directly backed by a BCQuality knowledge article.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4
| begin | ||
| end; | ||
|
|
||
| [IntegrationEvent(true, false)] |
There was a problem hiding this comment.
The new OnBeforeUpdateBatchTotal publisher is added without the XML summary/param documentation that the surrounding Payment Journal events use, so subscribers lose the inline contract description for this new extensibility point. Add matching event documentation for each localized PaymentJournal.Page.al publisher.
Agent judgement — not directly backed by a BCQuality knowledge article.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4
| trigger OnValidate() | ||
| begin | ||
| CheckAmountMatchedToAppliedLines(); | ||
| UpdateBalance(); |
There was a problem hiding this comment.
Adding UpdateBalance() (which now also calls UpdateBatchTotal()) to the Amount, Amount (LCY), Debit Amount, and Credit Amount OnValidate triggers makes every amount edit recompute batch-wide aggregates through CalcBalance and CalcBatchTotal (CalcSums("Balance (LCY)"), Rec.Count(), and CalcSums("Amount (LCY)")). This pattern is duplicated across all localized PaymentJournal.Page.al copies in the PR, so large payment batches now pay several SQL aggregate round-trips on each line edit instead of one. Prefer updating the displayed totals from the old/new line delta, or defer the full batch refresh until the record changes instead of re-aggregating the whole batch on every field validation.
Agent judgement — not directly backed by a BCQuality knowledge article.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4
| InsertCBGStatement(GenJnlTemplate); | ||
| end; | ||
|
|
||
| procedure CalcBatchTotal(var GenJnlLine: Record "Gen. Journal Line"; var BatchTotal: Decimal; var ShowBatchTotal: Boolean) |
There was a problem hiding this comment.
CalcBatchTotal adds a new public entry point on the shared GenJnlManagement library codeunit, but unlike the surrounding public procedures it has no XML documentation. Add a <summary> and <param> doc comments so extensions and callers can understand the method contract without reading the implementation.
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4
| OnAfterCalcBalance(GenJnlLine); | ||
| end; | ||
|
|
||
| procedure CalcBatchTotal(var GenJnlLine: Record "Gen. Journal Line"; var BatchTotal: Decimal; var ShowBatchTotal: Boolean) |
There was a problem hiding this comment.
CalcBatchTotal adds a new public entry point on the shared GenJnlManagement library codeunit (added identically in ES, NL, and W1 layers), but unlike the surrounding public procedures it has no XML documentation. Add a <summary> and <param> doc comments so extensions and callers can understand the method contract without reading the implementation.
Knowledge:
The same issue exists in these regional copies — apply the equivalent fix in each:
src/Layers/ES/BaseApp/Finance/GeneralLedger/Journal/GenJnlManagement.Codeunit.al:620(ES)
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4
| GenJournalLine.Modify(true); | ||
| end; | ||
|
|
||
| [Test] |
There was a problem hiding this comment.
Across the APAC/CH/CZ/ES/IT/W1 ERMGeneralJournalUT additions, the new Batch Total coverage only exercises the default interactive client path. Production code explicitly sets ShowBatchTotal := false for SOAP/OData/ODataV4/API client types, but none of these tests bind a Test Client Type Subscriber and assert that hidden-path contract. Add a client-type-driven unit test per layer that forces a non-UI client type, calls CalcBatchTotal, and verifies ShowBatchTotal = false and BatchTotal remains 0.
Agent judgement — not directly backed by a BCQuality knowledge article.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4
Agentic PR Review - Round 1Recommendation: Request ChangesWhat this PR doesThis Slice adds a Batch Total (LCY) field to Payment Journal pages across localized layers, backed by GenJnlManagement.CalcBatchTotal, and adds tests for totals, empty batches, batch changes, and amount edits. The feature goal is valid: users need a batch-level payment total before posting. The sum itself uses the current page filters and Amount (LCY), which matches the stated batch-total behavior. The main correctness risk is that the page recalculates the total during amount field validation by reading persisted lines, but the edited line has not been explicitly saved first. SuggestionsS1 - Save before recalculating edited amounts S2 - Avoid extra full-batch sums per edit S3 - Document new public extension points Risk assessment and necessityRisk: This is a financial UI surface, so a stale Batch Total can mislead users about the amount selected for payment before posting. The diff does not change posting or ledger-entry creation, but it adds a public helper and event publishers and it runs extra aggregate calculations on Payment Journal navigation and amount validation in all localized page copies. Necessity: The change is justified by Slice 425446 and the Ideas-site request: Balance and Total Balance do not answer the batch-level payment-total question. The scope is mostly right because all Payment Journal page copies are covered and tests were added, but the edited-line refresh path should be fixed before merge.
|
| BatchTotalVisible := ShowBatchTotal; | ||
| end; | ||
|
|
||
| local procedure UpdateBatchTotalAfterAmountChange() |
There was a problem hiding this comment.
UpdateBatchTotalAfterAmountChange() forces an explicit CurrPage.SaveRecord() and then reruns the full-batch CalcBatchTotal from the OnValidate triggers of Amount, Amount (LCY), Debit Amount, and Credit Amount — even though the amount-field validation path already saves via CheckAmountMatchedToAppliedLines(). This second save re-enters OnModifyRecord (payment-file validation, approval status cleanup) purely to refresh BatchTotal, so save-time errors can surface from the new UI-refresh path, and every amount edit now pays an extra save plus a full-batch CalcSums — which scales poorly on large payment journals. Recalculate the total from the already-saved record and drop the redundant second save.
Suggested fix (apply manually — could not be anchored as a one-click suggestion):
local procedure UpdateBatchTotalAfterAmountChange()
begin
UpdateBatchTotal();
end;👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4
| OnAfterCalcBalance(GenJnlLine); | ||
| end; | ||
|
|
||
| procedure CalcBatchTotal(var GenJnlLine: Record "Gen. Journal Line"; var BatchTotal: Decimal; var ShowBatchTotal: Boolean) |
There was a problem hiding this comment.
CalcBatchTotal introduces a new public journal-total calculation seam, but unlike the adjacent CalcBalance flow it exposes no OnBefore.../OnAfter... integration events around the filter-copy / CalcSums work. That leaves extensions no supported way to adjust which lines contribute to Batch Total or react to the computed value without duplicating the procedure, so this new total becomes a hard extensibility wall.
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4
| OnAfterUpdateBalance(TotalBalanceVisible); | ||
| end; | ||
|
|
||
| local procedure UpdateBatchTotal() |
There was a problem hiding this comment.
The new UpdateBatchTotal / UpdateBatchTotalAfterAmountChange path on Payment Journal is wired into UpdateBalance() and multiple amount OnValidate triggers, but it adds no OnBefore.../OnAfter... publishers even though the existing sibling UpdateBalance routine already exposes them. Page extensions therefore cannot suppress, replace, or post-process the new batch-total refresh flow through supported events.
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4
|
UpdateBalance now unconditionally calls UpdateBatchTotal on every current-record refresh and OnNewRecord. That means each row navigation/new line adds another full filtered CalcSums over Gen. Journal Line on top of the existing CalcBalance work, and the same pattern is duplicated across all localized Payment Journal page copies in this PR. Compute Batch Total only when the batch/filter context changes, or fold it into the existing balance calculation instead of issuing a third aggregate query per refresh. Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4 |
|
|
||
| [Test] | ||
| [Scope('OnPrem')] | ||
| procedure CalcBatchTotalReturnsSumOfAmountLCYOfFilteredLines() |
There was a problem hiding this comment.
The new CalcBatchTotal unit test only exercises the visible branch (ShowBatchTotal = true). GenJnlManagement.CalcBatchTotal now suppresses Batch Total for ClientType::SOAP, OData, ODataV4, and Api, but this codeunit never binds Test Client Type Subscriber to verify that ShowBatchTotal becomes false and BatchTotal stays 0 for those clients. Add a negative client-type test so the suppression branch cannot regress silently.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4
|
|
||
| [Test] | ||
| [Scope('OnPrem')] | ||
| procedure CalcBatchTotalReturnsSumOfAmountLCYOfFilteredLines() |
There was a problem hiding this comment.
The new CalcBatchTotal unit test only exercises the visible branch (ShowBatchTotal = true). GenJnlManagement.CalcBatchTotal now suppresses Batch Total for ClientType::SOAP, OData, ODataV4, and Api, but this codeunit never binds Test Client Type Subscriber to verify that ShowBatchTotal becomes false and BatchTotal stays 0 for those clients. Add a negative client-type test so the suppression branch cannot regress silently.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4
|
|
||
| [Test] | ||
| [Scope('OnPrem')] | ||
| procedure CalcBatchTotalReturnsSumOfAmountLCYOfFilteredLines() |
There was a problem hiding this comment.
The new CalcBatchTotal unit test only exercises the visible branch (ShowBatchTotal = true). GenJnlManagement.CalcBatchTotal now suppresses Batch Total for ClientType::SOAP, OData, ODataV4, and Api, but this codeunit never binds Test Client Type Subscriber to verify that ShowBatchTotal becomes false and BatchTotal stays 0 for those clients. Add a negative client-type test so the suppression branch cannot regress silently.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4
|
|
||
| [Test] | ||
| [Scope('OnPrem')] | ||
| procedure CalcBatchTotalReturnsSumOfAmountLCYOfFilteredLines() |
There was a problem hiding this comment.
The new CalcBatchTotal unit test only exercises the visible branch (ShowBatchTotal = true). GenJnlManagement.CalcBatchTotal now suppresses Batch Total for ClientType::SOAP, OData, ODataV4, and Api, but this codeunit never binds Test Client Type Subscriber to verify that ShowBatchTotal becomes false and BatchTotal stays 0 for those clients. Add a negative client-type test so the suppression branch cannot regress silently.
The same issue exists in these regional copies — apply the equivalent fix in each:
src/Layers/CZ/Tests/General Journal/ERMGeneralJournalUT.Codeunit.al:6432(CZ)src/Layers/IT/Tests/General Journal/ERMGeneralJournalUT.Codeunit.al:6432(IT)
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4
| OnAfterCalcBalance(GenJnlLine); | ||
| end; | ||
|
|
||
| procedure CalcBatchTotal(var GenJnlLine: Record "Gen. Journal Line"; var BatchTotal: Decimal; var ShowBatchTotal: Boolean) |
There was a problem hiding this comment.
This PR adds a new public procedure CalcBatchTotal on codeunit 230 in W1/ES/NL, but within the change its only consumers are the in-box Payment Journal pages and new tests. Publishing the helper as a public API makes its current signature part of the app's upgrade contract for dependent extensions, so changing or removing it after release becomes a breaking change. If external consumption is not intended, narrow the surface before the release baseline is cut.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4
Agentic PR Review - Round 2Recommendation: Accept with SuggestionsWhat this PR doesThis round updates the Payment Journal Batch Total implementation after round 1. Amount validation now saves the current line and refreshes only Batch Total, so the edited amount is included without forcing the full balance refresh path. The new Batch Total filter hook events were also removed. The feature still matches the Slice goal: show the total selected for payment at batch level, with tests for totals, empty batches, batch switching, and amount edits. Status of previous suggestions
New observations (commits since round 1)None - the new commit only addresses prior review feedback. Risk assessment and necessityRisk: This is a financial UI surface, so a wrong or stale Batch Total can mislead users before posting. The round-2 change lowers the main correctness risk by saving the edited line before recalculating. It does not change posting or ledger entries. One non-blocking maintainability issue remains: the new public Necessity: The Slice remains justified by the Ideas-site request. Balance and Total Balance do not show the batch-level amount selected for payment, and the scope covers the Payment Journal page copies plus relevant tests.
|
Fixes AB#425446
Requirement:
Would be nice to have a Batch Total for Payment Journal. Currently, have to post a payment journal before knowing how much was selected for payment.
Balance and Total Balance is only related to balancing the transaction for each row and not useful for batch totals.