Skip to content

Commit 72097b6

Browse files
authored
Merge pull request #2554 from alberto-art3ch/WEB-249/loan_buy_down_fee_when_enable
Loan Buy Down Fee transaction only when the Loan has enable this feature
2 parents 177d45a + 08938c9 commit 72097b6

File tree

13 files changed

+92
-26
lines changed

13 files changed

+92
-26
lines changed

src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
/** Angular Imports */
22
import { Component, OnInit, Input } from '@angular/core';
3-
import {
4-
UntypedFormGroup,
5-
UntypedFormBuilder,
6-
Validators,
7-
UntypedFormControl,
8-
ReactiveFormsModule
9-
} from '@angular/forms';
10-
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
3+
import { UntypedFormGroup, UntypedFormBuilder, Validators, UntypedFormControl } from '@angular/forms';
4+
import { ActivatedRoute, Router } from '@angular/router';
115

126
/** Custom Services */
137
import { LoansService } from 'app/loans/loans.service';
@@ -77,6 +71,8 @@ export class MakeRepaymentComponent implements OnInit {
7771
*/
7872
ngOnInit() {
7973
this.command = this.dataObject.type.code.split('.')[1];
74+
console.log(this.command);
75+
console.log(this.dataObject.type);
8076
this.maxDate = this.settingsService.businessDate;
8177
this.createRepaymentLoanForm();
8278
this.setRepaymentLoanDetails();

src/app/loans/loans-view/loans-view.component.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,18 @@ export class LoansViewComponent implements OnInit {
183183
taskPermissionName: 'DISBURSE_LOAN'
184184
});
185185
} else if (this.status === 'Active') {
186-
this.buttonConfig.addButton({
187-
name: 'Buy Down Fee',
188-
icon: 'plus',
189-
taskPermissionName: 'BUY_DOWN_FEE_LOAN'
190-
});
186+
if (this.loanDetailsData.enableBuyDownFee) {
187+
this.buttonConfig.addButton({
188+
name: 'Buy Down Fee',
189+
icon: 'plus',
190+
taskPermissionName: 'BUYDOWNFEE_LOAN'
191+
});
192+
}
191193
if (this.loanDetailsData.enableIncomeCapitalization) {
192194
this.buttonConfig.addButton({
193195
name: 'Capitalized Income',
194196
icon: 'coins',
195-
taskPermissionName: 'CAPITALIZED_INCOME_LOAN'
197+
taskPermissionName: 'CAPITALIZEDINCOME_LOAN'
196198
});
197199
}
198200

src/app/loans/loans-view/transactions-tab/transactions-tab.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
<span *ngIf="isCapitalizedIncome(transaction.type) && !transaction.manuallyReversed">
198198
<button
199199
mat-menu-item
200-
*mifosxHasPermission="'CAPITALIZED_INCOME_LOAN'"
200+
*mifosxHasPermission="'CAPITALIZEDINCOME_LOAN'"
201201
(click)="capitalizedIncomeAdjustmentTransaction(transaction, $event)"
202202
>
203203
<mat-icon><fa-icon icon="coins" size="sm"></fa-icon></mat-icon>
@@ -207,7 +207,7 @@
207207
<span *ngIf="isBuyDownFee(transaction.type) && !transaction.manuallyReversed">
208208
<button
209209
mat-menu-item
210-
*mifosxHasPermission="'BUY_DOWN_FEE_LOAN'"
210+
*mifosxHasPermission="'BUYDOWNFEE_LOAN'"
211211
(click)="buyDownFeeAdjustmentTransaction(transaction, $event)"
212212
>
213213
<mat-icon><fa-icon icon="coins" size="sm"></fa-icon></mat-icon>

src/app/loans/loans-view/transactions-tab/transactions-tab.component.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,10 @@ export class TransactionsTabComponent implements OnInit {
429429
return this.isReAmortize(transactionType) || this.isReAge(transactionType);
430430
}
431431

432+
isBuyDownFee(transactionType: LoanTransactionType): boolean {
433+
return transactionType.buyDownFee || transactionType.code === 'loanTransactionType.buyDownFee';
434+
}
435+
432436
viewJournalEntry(transactionType: LoanTransactionType): boolean {
433437
return !(this.isReAmortize(transactionType) || this.isReAge(transactionType));
434438
}
@@ -446,6 +450,70 @@ export class TransactionsTabComponent implements OnInit {
446450
return true;
447451
}
448452

453+
buyDownFeeAdjustmentTransaction(transaction: LoanTransaction) {
454+
const accountId = `${this.loanId}`;
455+
this.loansService
456+
.getLoanTransactionActionTemplate(accountId, 'buyDownFeeAdjustment', `${transaction.id}`)
457+
.subscribe((response: any) => {
458+
const transactionDate = response.date || transaction.date;
459+
if (response.amount == 0) {
460+
this.displayAlertMessage('Buy Down Fee amount adjusted already adjusted', transaction.amount);
461+
} else {
462+
const transactionAmount = response.amount || transaction.amount;
463+
const formfields: FormfieldBase[] = [
464+
new DatepickerBase({
465+
controlName: 'transactionDate',
466+
label: 'Date',
467+
value: this.dateUtils.parseDate(transactionDate),
468+
type: 'datetime-local',
469+
required: true,
470+
minDate: this.dateUtils.parseDate(transaction.date),
471+
order: 1
472+
}),
473+
new InputBase({
474+
controlName: 'amount',
475+
label: 'Amount',
476+
value: transactionAmount,
477+
type: 'number',
478+
required: true,
479+
max: transactionAmount,
480+
min: 0.001,
481+
order: 2
482+
})
483+
484+
];
485+
const data = {
486+
title: `Adjustment ${transaction.type.value} Transaction`,
487+
layout: { addButtonText: 'Adjustment' },
488+
formfields: formfields
489+
};
490+
const chargebackDialogRef = this.dialog.open(FormDialogComponent, { data });
491+
chargebackDialogRef.afterClosed().subscribe((response: { data: any }) => {
492+
if (response.data) {
493+
const dateFormat = this.settingsService.dateFormat;
494+
495+
if (response.data.value.amount <= transactionAmount) {
496+
const locale = this.settingsService.language.code;
497+
const payload = {
498+
transactionDate: this.dateUtils.formatDate(response.data.value.transactionDate, dateFormat),
499+
transactionAmount: response.data.value.amount,
500+
locale,
501+
dateFormat
502+
};
503+
this.loansService
504+
.executeLoansAccountTransactionsCommand(accountId, 'buyDownFeeAdjustment', payload, transaction.id)
505+
.subscribe(() => {
506+
this.reload();
507+
});
508+
} else {
509+
this.displayAlertMessage('Buy Down Fee Adjustment amount must be lower or equal to', transactionAmount);
510+
}
511+
}
512+
});
513+
}
514+
});
515+
}
516+
449517
capitalizedIncomeAdjustmentTransaction(transaction: LoanTransaction) {
450518
const accountId = `${this.loanId}`;
451519
this.loansService

src/assets/translations/de-DE.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2523,8 +2523,8 @@
25232523
"Block Deposit": "Blockeinzahlung",
25242524
"Block Withdrawal": "Auszahlung blockieren",
25252525
"Breadcrumbs": "Semmelbrösel",
2526-
"Buy Down Fee": "Ankaufsgebühr",
2527-
"Buy Down Fee Adjustment": "Anpassung der Ankaufsgebühr",
2526+
"Buy Down Fee": "Anzahlungsgebühr",
2527+
"Buy Down Fee Adjustment": "Anpassung der Buy-Down-Gebühr",
25282528
"Calculate Interest": "Zinsen berechnen",
25292529
"Capitalized Income": "Kapitalisiertes Einkommen",
25302530
"Capitalized Income Adjustment": "Anpassung des kapitalisierten Einkommens",

src/assets/translations/es-CL.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2524,7 +2524,7 @@
25242524
"Block Withdrawal": "Bloquear retiros",
25252525
"Breadcrumbs": "Migas de pan",
25262526
"Buy Down Fee": "Comisión de compra inicial",
2527-
"Buy Down Fee Adjustment": "Ajuste de la tasa de recompra",
2527+
"Buy Down Fee Adjustment": "Ajuste de la comisión de compra",
25282528
"Calculate Interest": "Calcular interés",
25292529
"Capitalized Income": "Ingreso capitalizado",
25302530
"Capitalized Income Adjustment": "Ajuste de ingresos capitalizados",

src/assets/translations/es-MX.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2524,7 +2524,7 @@
25242524
"Block Withdrawal": "Bloquear retiros",
25252525
"Breadcrumbs": "Migas de pan",
25262526
"Buy Down Fee": "Comisión de compra inicial",
2527-
"Buy Down Fee Adjustment": "Ajuste de la tasa de recompra",
2527+
"Buy Down Fee Adjustment": "Ajuste de la comisión de compra",
25282528
"Calculate Interest": "Calcular interés",
25292529
"Capitalized Income": "Ingreso capitalizado",
25302530
"Capitalized Income Adjustment": "Ajuste de ingresos capitalizados",

src/assets/translations/fr-FR.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2524,7 +2524,7 @@
25242524
"Block Withdrawal": "Bloquer le retrait",
25252525
"Breadcrumbs": "Chapelure",
25262526
"Buy Down Fee": "Frais d'achat initial",
2527-
"Buy Down Fee Adjustment": "Ajustement de la commission de rachat",
2527+
"Buy Down Fee Adjustment": "Ajustement des frais d'achat",
25282528
"Calculate Interest": "Calculer les intérêts",
25292529
"Capitalized Income": "Revenu capitalisé",
25302530
"Capitalized Income Adjustment": "Ajustement du revenu capitalisé",

src/assets/translations/ko-KO.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2525,7 +2525,7 @@
25252525
"Block Withdrawal": "출금 차단",
25262526
"Breadcrumbs": "빵 부스러기",
25272527
"Buy Down Fee": "구매 수수료",
2528-
"Buy Down Fee Adjustment": "바이 다운 수수료 조정",
2528+
"Buy Down Fee Adjustment": "매수 수수료 조정",
25292529
"Calculate Interest": "이자 계산",
25302530
"Capitalized Income": "자본화 소득",
25312531
"Capitalized Income Adjustment": "자본화 소득 조정",

src/assets/translations/lt-LT.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2524,7 +2524,7 @@
25242524
"Block Withdrawal": "Blokuoti išėmimą",
25252525
"Breadcrumbs": "Duonos trupiniai",
25262526
"Buy Down Fee": "Pirkimo mokestis",
2527-
"Buy Down Fee Adjustment": "Išpirkimo mokesčio koregavimas",
2527+
"Buy Down Fee Adjustment": "Nupirkimo mokesčio koregavimas",
25282528
"Calculate Interest": "Apskaičiuokite palūkanas",
25292529
"Capitalized Income": "Kapitalizuotos pajamos",
25302530
"Capitalized Income Adjustment": "Kapitalizuotų pajamų koregavimas",

0 commit comments

Comments
 (0)