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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user