fix(charges): normalize chargeId, skip invalid charges, and preserve UI charge fields to fix preview errors and disbursement failures (#2822)

improve the line is missing the empty string fallback present
This commit is contained in:
Shubham Kumar
2025-11-27 09:14:50 -06:00
committed by GitHub
parent 5effdb9570
commit 753b623eb1
5 changed files with 60 additions and 30 deletions
+25 -5
View File
@@ -642,11 +642,31 @@ export class LoansService {
): any {
const loansAccountData = {
...loansAccount,
charges: loansAccount.charges.map((charge: any) => ({
chargeId: charge.id,
amount: charge.amount,
dueDate: charge.dueDate && this.dateUtils.formatDate(charge.dueDate, dateFormat)
})),
charges: (loansAccount.charges ?? [])
.map((charge: any) => {
const chargeId = charge.chargeId ?? charge.id;
if (chargeId == null) {
return null;
}
const mappedCharge: any = {
chargeId,
amount: charge.amount
};
if (charge.id && charge.id !== chargeId) {
mappedCharge.id = charge.id;
}
if (charge.dueDate) {
mappedCharge.dueDate = this.dateUtils.formatDate(charge.dueDate, dateFormat);
}
if (charge.feeInterval !== undefined) {
mappedCharge.feeInterval = charge.feeInterval;
}
if (charge.feeOnMonthDay !== undefined) {
mappedCharge.feeOnMonthDay = charge.feeOnMonthDay;
}
return mappedCharge;
})
.filter(Boolean),
disbursementData: loansAccount.disbursementData.map((item: any) => ({
expectedDisbursementDate: this.dateUtils.formatDate(item.expectedDisbursementDate, dateFormat),
principal: item.principal