Loan Buy Down Fee transaction only when the Loan has enable this feature
This commit is contained in:
+4
-8
@@ -1,13 +1,7 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import {
|
||||
UntypedFormGroup,
|
||||
UntypedFormBuilder,
|
||||
Validators,
|
||||
UntypedFormControl,
|
||||
ReactiveFormsModule
|
||||
} from '@angular/forms';
|
||||
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
||||
import { UntypedFormGroup, UntypedFormBuilder, Validators, UntypedFormControl } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
/** Custom Services */
|
||||
import { LoansService } from 'app/loans/loans.service';
|
||||
@@ -77,6 +71,8 @@ export class MakeRepaymentComponent implements OnInit {
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.command = this.dataObject.type.code.split('.')[1];
|
||||
console.log(this.command);
|
||||
console.log(this.dataObject.type);
|
||||
this.maxDate = this.settingsService.businessDate;
|
||||
this.createRepaymentLoanForm();
|
||||
this.setRepaymentLoanDetails();
|
||||
|
||||
@@ -183,16 +183,18 @@ export class LoansViewComponent implements OnInit {
|
||||
taskPermissionName: 'DISBURSE_LOAN'
|
||||
});
|
||||
} else if (this.status === 'Active') {
|
||||
this.buttonConfig.addButton({
|
||||
name: 'Buy Down Fee',
|
||||
icon: 'plus',
|
||||
taskPermissionName: 'BUY_DOWN_FEE_LOAN'
|
||||
});
|
||||
if (this.loanDetailsData.enableBuyDownFee) {
|
||||
this.buttonConfig.addButton({
|
||||
name: 'Buy Down Fee',
|
||||
icon: 'plus',
|
||||
taskPermissionName: 'BUYDOWNFEE_LOAN'
|
||||
});
|
||||
}
|
||||
if (this.loanDetailsData.enableIncomeCapitalization) {
|
||||
this.buttonConfig.addButton({
|
||||
name: 'Capitalized Income',
|
||||
icon: 'coins',
|
||||
taskPermissionName: 'CAPITALIZED_INCOME_LOAN'
|
||||
taskPermissionName: 'CAPITALIZEDINCOME_LOAN'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@
|
||||
<span *ngIf="isCapitalizedIncome(transaction.type) && !transaction.manuallyReversed">
|
||||
<button
|
||||
mat-menu-item
|
||||
*mifosxHasPermission="'CAPITALIZED_INCOME_LOAN'"
|
||||
*mifosxHasPermission="'CAPITALIZEDINCOME_LOAN'"
|
||||
(click)="capitalizedIncomeAdjustmentTransaction(transaction, $event)"
|
||||
>
|
||||
<mat-icon><fa-icon icon="coins" size="sm"></fa-icon></mat-icon>
|
||||
@@ -207,7 +207,7 @@
|
||||
<span *ngIf="isBuyDownFee(transaction.type) && !transaction.manuallyReversed">
|
||||
<button
|
||||
mat-menu-item
|
||||
*mifosxHasPermission="'BUY_DOWN_FEE_LOAN'"
|
||||
*mifosxHasPermission="'BUYDOWNFEE_LOAN'"
|
||||
(click)="buyDownFeeAdjustmentTransaction(transaction, $event)"
|
||||
>
|
||||
<mat-icon><fa-icon icon="coins" size="sm"></fa-icon></mat-icon>
|
||||
|
||||
@@ -429,6 +429,10 @@ export class TransactionsTabComponent implements OnInit {
|
||||
return this.isReAmortize(transactionType) || this.isReAge(transactionType);
|
||||
}
|
||||
|
||||
isBuyDownFee(transactionType: LoanTransactionType): boolean {
|
||||
return transactionType.buyDownFee || transactionType.code === 'loanTransactionType.buyDownFee';
|
||||
}
|
||||
|
||||
viewJournalEntry(transactionType: LoanTransactionType): boolean {
|
||||
return !(this.isReAmortize(transactionType) || this.isReAge(transactionType));
|
||||
}
|
||||
@@ -446,6 +450,70 @@ export class TransactionsTabComponent implements OnInit {
|
||||
return true;
|
||||
}
|
||||
|
||||
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 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: 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
capitalizedIncomeAdjustmentTransaction(transaction: LoanTransaction) {
|
||||
const accountId = `${this.loanId}`;
|
||||
this.loansService
|
||||
|
||||
Reference in New Issue
Block a user