From 140ae09a6c4cc6bcfc8d002ff89791d721718af1 Mon Sep 17 00:00:00 2001 From: Jose Alberto Hernandez Date: Wed, 28 May 2025 20:03:08 -0500 Subject: [PATCH] fix: Loan transactions refresh after apply Capitalized Income Adjustment transaction --- .../transactions-tab.component.html | 2 +- .../transactions-tab.component.ts | 137 ++++++++++-------- ...oan-product-accounting-step.component.html | 14 +- .../gl-account-selector.component.html | 2 +- src/assets/translations/cs-CS.json | 4 + src/assets/translations/de-DE.json | 4 + src/assets/translations/en-US.json | 4 + src/assets/translations/es-CL.json | 4 + src/assets/translations/es-MX.json | 4 + src/assets/translations/fr-FR.json | 4 + src/assets/translations/it-IT.json | 4 + src/assets/translations/ko-KO.json | 4 + src/assets/translations/lt-LT.json | 4 + src/assets/translations/lv-LV.json | 4 + src/assets/translations/ne-NE.json | 4 + src/assets/translations/pt-PT.json | 4 + src/assets/translations/sw-SW.json | 4 + 17 files changed, 138 insertions(+), 69 deletions(-) diff --git a/src/app/loans/loans-view/transactions-tab/transactions-tab.component.html b/src/app/loans/loans-view/transactions-tab/transactions-tab.component.html index f563e9c64..0b29a3ca5 100644 --- a/src/app/loans/loans-view/transactions-tab/transactions-tab.component.html +++ b/src/app/loans/loans-view/transactions-tab/transactions-tab.component.html @@ -65,7 +65,7 @@ [ngClass]="loanTransactionColor(transaction)" (click)="showTransactions(transaction)" > - {{ transaction.type.value }} + {{ transaction.type.value | translateKey: 'catalogs' }} diff --git a/src/app/loans/loans-view/transactions-tab/transactions-tab.component.ts b/src/app/loans/loans-view/transactions-tab/transactions-tab.component.ts index 5d1692ae4..b708a56e2 100644 --- a/src/app/loans/loans-view/transactions-tab/transactions-tab.component.ts +++ b/src/app/loans/loans-view/transactions-tab/transactions-tab.component.ts @@ -26,6 +26,7 @@ import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicke export class TransactionsTabComponent implements OnInit { /** Loan Details Data */ transactionsData: LoanTransaction[] = []; + loanDetailsData: any; /** Form control to handle accural parameter */ hideAccrualsParam: UntypedFormControl; hideReversedParam: UntypedFormControl; @@ -89,13 +90,14 @@ export class TransactionsTabComponent implements OnInit { private alertService: AlertService ) { this.route.parent.parent.data.subscribe((data: { loanDetailsData: any }) => { - this.transactionsData = data.loanDetailsData.transactions; + this.loanDetailsData = data.loanDetailsData; this.status = data.loanDetailsData.status.value; }); this.loanId = this.route.parent.parent.snapshot.params['loanId']; } ngOnInit() { + this.transactionsData = this.loanDetailsData.transactions; this.hideAccrualsParam = new UntypedFormControl(false); this.hideReversedParam = new UntypedFormControl(false); this.setLoanTransactions(); @@ -179,6 +181,7 @@ export class TransactionsTabComponent implements OnInit { * REAGE:29 * REAMORTIZE:30 * INTEREST REFUND:33 + * CAPITALIZED INCOME:35 * CONTRACT_TERMINATION:90 */ showTransactions(transactionsData: LoanTransaction) { @@ -197,6 +200,7 @@ export class TransactionsTabComponent implements OnInit { 30, 31, 33, + 35, 90 ].includes(transactionsData.type.id)) { this.router.navigate([transactionsData.id], { relativeTo: this.route }); @@ -355,9 +359,7 @@ export class TransactionsTabComponent implements OnInit { private reload() { const clientId = this.route.parent.parent.snapshot.params['clientId']; const url: string = this.router.url; - this.router - .navigateByUrl(`/clients/${clientId}/loans-accounts`, { skipLocationChange: true }) - .then(() => this.router.navigate([url])); + this.router.navigateByUrl(`/clients`, { skipLocationChange: true }).then(() => this.router.navigate([url])); } displaySubMenu(transaction: LoanTransaction): boolean { @@ -373,65 +375,80 @@ export class TransactionsTabComponent implements OnInit { .getLoanTransactionActionTemplate(accountId, 'capitalizedIncomeAdjustment', `${transaction.id}`) .subscribe((response: any) => { const transactionDate = response.date || transaction.date; - const transactionAmount = response.amount || transaction.amount; - const formfields: FormfieldBase[] = [ - new DatepickerBase({ - controlName: 'transactionDate', - label: 'Date', - value: this.dateUtils.parseDate(transactionDate), - type: 'datetime-local', - required: true, - minDate: transaction.date, - order: 1 - }), - new InputBase({ - controlName: 'amount', - label: 'Amount', - value: transactionAmount, - type: 'number', - required: true, - max: transactionAmount, - min: 0.001, - order: 2 - }) + if (response.amount == 0) { + this.displayAlertMessage('Capitalized Income amount adjusted already adjusted', transaction.amount); + } else { + const transactionAmount = response.amount || transaction.amount; + const formfields: FormfieldBase[] = [ + new DatepickerBase({ + controlName: 'transactionDate', + label: 'Date', + value: this.dateUtils.parseDate(transactionDate), + type: 'datetime-local', + required: true, + minDate: transaction.date, + order: 1 + }), + new InputBase({ + controlName: 'amount', + label: 'Amount', + value: transactionAmount, + type: 'number', + required: true, + max: transactionAmount, + min: 0.001, + order: 2 + }) - ]; - const data = { - title: `Adjustment ${transaction.type.value} Transaction`, - layout: { addButtonText: 'Adjustment' }, - formfields: formfields - }; - const chargebackDialogRef = this.dialog.open(FormDialogComponent, { data }); - chargebackDialogRef.afterClosed().subscribe((response: { data: any }) => { - if (response.data) { - const dateFormat = this.settingsService.dateFormat; + ]; + const data = { + title: `Adjustment ${transaction.type.value} Transaction`, + layout: { addButtonText: 'Adjustment' }, + formfields: formfields + }; + const chargebackDialogRef = this.dialog.open(FormDialogComponent, { data }); + chargebackDialogRef.afterClosed().subscribe((response: { data: any }) => { + if (response.data) { + const dateFormat = this.settingsService.dateFormat; - if (response.data.value.amount <= transactionAmount) { - const locale = this.settingsService.language.code; - const payload = { - transactionDate: this.dateUtils.formatDate(response.data.value.transactionDate, dateFormat), - transactionAmount: response.data.value.amount, - locale, - dateFormat - }; - this.loansService - .executeLoansAccountTransactionsCommand( - accountId, - 'capitalizedIncomeAdjustment', - payload, - transaction.id - ) - .subscribe(() => { - this.router.navigate(['../'], { relativeTo: this.route }); - }); - } else { - this.alertService.alert({ - type: 'BusinessRule', - message: 'Chargeback amount must be lower or equal to: ' + transaction.amount - }); + if (response.data.value.amount <= transactionAmount) { + const locale = this.settingsService.language.code; + const payload = { + transactionDate: this.dateUtils.formatDate(response.data.value.transactionDate, dateFormat), + transactionAmount: response.data.value.amount, + locale, + dateFormat + }; + this.loansService + .executeLoansAccountTransactionsCommand( + accountId, + 'capitalizedIncomeAdjustment', + payload, + transaction.id + ) + .subscribe(() => { + this.reload(); + }); + } else { + this.displayAlertMessage( + 'Capitalized Income Adjustment amount must be lower or equal to', + transactionAmount + ); + } } - } - }); + }); + } }); } + + private displayAlertMessage(label: string, amount: number): void { + let message: string = this.translateService.instant('errors.' + label); + if (amount) { + message = message + ': ' + amount; + } + this.alertService.alert({ + type: 'BusinessRule', + message: message + }); + } } diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/loan-product-accounting-step.component.html b/src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/loan-product-accounting-step.component.html index ea43f607d..b82055bb9 100644 --- a/src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/loan-product-accounting-step.component.html +++ b/src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/loan-product-accounting-step.component.html @@ -13,7 +13,7 @@
{{ 'labels.inputs.Enable Accrual Activity Posting on Installment Due Date' | translate @@ -56,7 +56,7 @@ *ngIf=" loanProductAccountingForm.value.accountingRule === 3 || loanProductAccountingForm.value.accountingRule === 4 " - class="flex-fill layout-row-wrap gap-2percent responsive-column" + class="flex-100 layout-row-wrap responsive-column" > {{ 'labels.heading.Expenses' | translate }} - + {{ 'labels.heading.Advanced Accounting Rules' | translate @@ -261,7 +261,7 @@

{{ 'labels.heading.Configure Fund Sources for Payment Channels' | translate }} @@ -492,7 +492,7 @@

-
+