fix(savings): interest posting reports no longer fail when a product names no payable or paid GL

A ternary mixing a long with a Long unboxed a null GL id and failed the whole report with a
NullPointerException. The values are boxed with Long.valueOf, so a product that names no
payable or paid GL (allowed) is read as null.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-28 21:03:31 +05:30
co-authored by Claude Sonnet 5.5
parent a6dbe01cfc
commit bb492c82b5
2 changed files with 11 additions and 4 deletions
@@ -223,10 +223,13 @@ public class SavingsPooledInterestPostingService {
final long runId = openRun(reportId, productId, officeId, cycleDate, lines.size());
final PostingGlAccounts current = resolvePostingGlAccounts(productId);
// Long.valueOf, not the bare long: a ternary mixing a long with a Long is a long, so a GL the product does not name
// (null, and allowed) was unboxed here and the whole report failed with a NullPointerException.
final Long payableGl = report.get("payable_gl_account_id") != null
? ((Number) report.get("payable_gl_account_id")).longValue()
? Long.valueOf(((Number) report.get("payable_gl_account_id")).longValue())
: current.payableGl();
final Long paidGl = report.get("paid_gl_account_id") != null ? ((Number) report.get("paid_gl_account_id")).longValue()
final Long paidGl = report.get("paid_gl_account_id") != null
? Long.valueOf(((Number) report.get("paid_gl_account_id")).longValue())
: current.paidGl();
final String currency = (String) lines.get(0).get("currency_code");
@@ -210,9 +210,13 @@ public class FixedDepositInterestPostingService {
final Long expenseGl = mappedGlAccount(productId, GL_INTEREST_ON_SAVINGS);
final Long controlGl = mappedGlAccount(productId, GL_SAVINGS_CONTROL);
final PostingGlAccounts current = resolvePostingGlAccounts(productId);
final Long payableGl = report.get("payable_gl_account_id") != null ? ((Number) report.get("payable_gl_account_id")).longValue()
// Long.valueOf, not the bare long: a ternary mixing a long with a Long is a long, so a product that names no payable
// or paid GL (null, and allowed) was unboxed here and the whole report failed with a NullPointerException.
final Long payableGl = report.get("payable_gl_account_id") != null
? Long.valueOf(((Number) report.get("payable_gl_account_id")).longValue())
: current.payableGl();
final Long paidGl = report.get("paid_gl_account_id") != null ? ((Number) report.get("paid_gl_account_id")).longValue()
final Long paidGl = report.get("paid_gl_account_id") != null
? Long.valueOf(((Number) report.get("paid_gl_account_id")).longValue())
: current.paidGl();
final String currency = (String) lines.get(0).get("currency_code");