Merge pull request #2546 from Cocoa-Puffs/feature/buy-down-fees-adjustment-transaction

WEB-242: add buy down fee adjustment transaction to existing non reversed buy down fee transactions
This commit is contained in:
Felix van Hove
2025-07-03 18:59:59 +02:00
committed by GitHub
17 changed files with 167 additions and 5 deletions
@@ -204,6 +204,16 @@
<span>{{ 'labels.menus.Capitalized Income Adjustment' | translate }}</span>
</button>
</span>
<span *ngIf="isBuyDownFee(transaction.type) && !transaction.manuallyReversed">
<button
mat-menu-item
*mifosxHasPermission="'BUY_DOWN_FEE_LOAN'"
(click)="buyDownFeeAdjustmentTransaction(transaction, $event)"
>
<mat-icon><fa-icon icon="coins" size="sm"></fa-icon></mat-icon>
<span>{{ 'labels.menus.Buy Down Fee Adjustment' | translate }}</span>
</button>
</span>
<span *ngIf="viewJournalEntry(transaction.type)">
<button
mat-menu-item
@@ -245,6 +245,8 @@ export class TransactionsTabComponent implements OnInit {
* CAPITALIZED INCOME:35
* CAPITALIZED INCOME ADJUSTMENT:37
* CONTRACT_TERMINATION:38
* BUY_DOWN_FEE:40
* BUY_DOWN_FEE_ADJUSTMENT:41
*/
showTransaction(transactionsData: LoanTransaction): boolean {
return [
@@ -264,7 +266,9 @@ export class TransactionsTabComponent implements OnInit {
33,
35,
37,
38
38,
40,
41
].includes(transactionsData.type.id);
}
@@ -417,6 +421,10 @@ export class TransactionsTabComponent implements OnInit {
);
}
private isBuyDownFee(transactionType: LoanTransactionType): boolean {
return transactionType.buyDownFee || transactionType.code === 'loanTransactionType.buyDownFee';
}
private isReAgoeOrReAmortize(transactionType: LoanTransactionType): boolean {
return this.isReAmortize(transactionType) || this.isReAge(transactionType);
}
@@ -510,6 +518,70 @@ export class TransactionsTabComponent implements OnInit {
});
}
buyDownFeeAdjustmentTransaction(transaction: LoanTransaction) {
const accountId = `${this.loanId}`;
this.loansService
.getLoanTransactionActionTemplate(accountId, 'buyDownFeeAdjustment', `${transaction.id}`)
.subscribe((response: any) => {
const transactionDate = response.date || transaction.date;
if (response.amount == 0) {
this.displayAlertMessage('Buy Down Fee amount 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: this.dateUtils.parseDate(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;
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, 'buyDownFeeAdjustment', payload, transaction.id)
.subscribe(() => {
this.reload();
});
} else {
this.displayAlertMessage('Buy Down Fee 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) {
@@ -37,4 +37,6 @@ export interface LoanTransactionType {
capitalizedIncomeAmortization: boolean;
capitalizedIncomeAmortizationAdjustment: boolean;
contractTermination: boolean;
buyDownFee: boolean;
buyDownFeeAdjustment: boolean;
}