fix(chequebook,ctsclearing): surface global stock allocation in UI; fix decided-state check
build-run / Run Lint, Build and Deploy (push) Canceled after 0s
Publish Image in Docker Hub / build (push) Canceled after 0s
Playwright E2E Tests / Run Playwright Tests (push) Canceled after 0s
Tests / testRigor (push) Canceled after 0s

Receive Stock form now displays the actual highest-allocated serial across
every series (not just silently prefilling the field), so the operator
can see and trust the auto-suggested range start rather than taking it
on faith.

Fixes a real bug where item.decision (which InwardClearingItem.java always
sets to the literal string "PENDING" at creation, never null) was checked
with a plain truthy test everywhere a "has this been decided yet" branch
was needed. Since "PENDING" is a non-empty string, that check was always
true — silently breaking the Decide/View button label, the collapsed
validation summary, the "Awaiting settlement" text, and the decision
dialog itself (which never showed the actual Pass/Return form, even for
still-pending items). Replaced with a proper isDecided() check everywhere.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-23 17:08:10 +05:30
co-authored by Claude Sonnet 5
parent ca85bae4fb
commit 97d0545f07
9 changed files with 73 additions and 23 deletions
@@ -281,17 +281,22 @@ export class StockManagementComponent implements OnInit {
return start + leaves - 1;
}
/** Highest leaf-serial allocated so far, across every series/office — the actual number the "Range Start"
* suggestion is based on. Shown directly in the form (not just silently applied to the field) so the operator
* can see and trust the reasoning instead of taking a pre-filled number on faith. */
get globalHighestAllocated(): number {
return this.allStockLots.reduce((m, l) => Math.max(m, l.rangeEnd || 0), 0);
}
/**
* Next unused serial WITHIN this series, so a fresh receipt continues that series' own numbering —
* each series is numbered independently (a separate stationery order from the press), so a different
* series' stock is not relevant here.
* Next unused serial across EVERY series, not just the one being received — a real bank allocates leaf-serial
* numbers from one bank-wide numbering authority, so two different cheque designs never legitimately reuse the
* same range. Suggesting a start that only avoids the same series' own lots is exactly what let two series end
* up overlapping (and, once both got issued to the same account, an unresolvable serial collision) before the
* backend's own overlap check was widened to match (ChequeStockLotRepository.countOverlappingAnySeries).
*/
private nextFreeSerial(): number {
const seriesId = this.receiveForm.get('seriesId')?.value;
const maxEnd = this.allStockLots
.filter((l) => l.seriesId === seriesId)
.reduce((m, l) => Math.max(m, l.rangeEnd || 0), 0);
return maxEnd + 1;
return this.globalHighestAllocated + 1;
}
onReceiveSeriesChange(): void {