Skip to content

Commit b193337

Browse files
Merge pull request #2472 from alberto-art3ch/enhancement/loan_contract_termination
Loan Contrac Termination
2 parents d1d06ec + 28dfe56 commit b193337

33 files changed

+7035
-5130
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,4 @@ Thumbs.db
5858
cypress/
5959

6060
src/assets/env.js
61+
src/environments/.env.ts

package-lock.json

Lines changed: 6836 additions & 5066 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/loans/common-resolvers/loan-action-button.resolver.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ export class LoanActionButtonResolver {
7575
return this.loansService.getLoanActionTemplate(loanId, 'charge-off');
7676
} else if (loanActionButton === 'Capitalized Income') {
7777
return this.loansService.getLoanActionTemplate(loanId, 'capitalizedIncome');
78+
} else if (loanActionButton === 'Contract Termination') {
79+
return this.loansService.getLoanActionTemplate(loanId, 'contractTermination');
7880
} else {
7981
return undefined;
8082
}

src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
[dataObject]="actionButtonData"
66
></mifosx-assign-loan-officer>
77
<mifosx-foreclosure [dataObject]="actionButtonData" *ngIf="actions['Foreclosure']"></mifosx-foreclosure>
8-
<mifosx-prepay-loan [dataObject]="actionButtonData" *ngIf="actions['Prepay Loan']"></mifosx-prepay-loan>
8+
<mifosx-prepay-loan
9+
[dataObject]="actionButtonData"
10+
*ngIf="actions['Prepay Loan'] || actions['Contract Termination']"
11+
></mifosx-prepay-loan>
912
<mifosx-make-repayment [dataObject]="actionButtonData" *ngIf="actions['Make Repayment']"></mifosx-make-repayment>
1013
<mifosx-make-repayment [dataObject]="actionButtonData" *ngIf="actions['Capitalized Income']"></mifosx-make-repayment>
1114
<mifosx-make-repayment [dataObject]="actionButtonData" *ngIf="actions['Goodwill Credit']"></mifosx-make-repayment>

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export class LoanAccountActionsComponent {
5252
'Interest Payment Waiver': boolean;
5353
'Add Interest Pause': boolean;
5454
'Capitalized Income': boolean;
55+
'Contract Termination': boolean;
5556
} = {
5657
Close: false,
5758
'Undo Approval': false,
@@ -88,7 +89,8 @@ export class LoanAccountActionsComponent {
8889
'Re-Amortize': false,
8990
'Interest Payment Waiver': false,
9091
'Add Interest Pause': false,
91-
'Capitalized Income': false
92+
'Capitalized Income': false,
93+
'Contract Termination': false
9294
};
9395

9496
actionButtonData: any;
@@ -119,5 +121,7 @@ export class LoanAccountActionsComponent {
119121
}
120122
this.actions[this.actionName as keyof typeof this.actions] = true;
121123
});
124+
125+
this.actionButtonData['actionName'] = this.actionName;
122126
}
123127
}

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,22 @@ export class MakeRepaymentComponent implements OnInit {
8181
note: ''
8282
});
8383

84-
this.repaymentLoanForm.addControl(
85-
'transactionAmount',
86-
new UntypedFormControl('', [
87-
Validators.required,
88-
Validators.min(0.001)])
89-
);
84+
if (this.isCapitalizedIncome()) {
85+
this.repaymentLoanForm.addControl(
86+
'transactionAmount',
87+
new UntypedFormControl('', [
88+
Validators.required,
89+
Validators.min(0.001),
90+
Validators.max(this.dataObject.amount)])
91+
);
92+
} else {
93+
this.repaymentLoanForm.addControl(
94+
'transactionAmount',
95+
new UntypedFormControl('', [
96+
Validators.required,
97+
Validators.min(0.001)])
98+
);
99+
}
90100
}
91101

92102
setRepaymentLoanDetails() {

src/app/loans/loans-view/loan-account-actions/prepay-loan/prepay-loan.component.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<form [formGroup]="prepayLoanForm" (ngSubmit)="submit()">
44
<mat-card-content>
55
<div class="layout-column">
6-
<mat-form-field (click)="transactionDatePicker.open()">
6+
<mat-form-field (click)="transactionDatePicker.open()" *ngIf="!contractTermination">
77
<mat-label>{{ 'labels.inputs.Transaction Date' | translate }}</mat-label>
88
<input
99
matInput
@@ -56,6 +56,7 @@
5656
</div>
5757

5858
<mifosx-input-amount
59+
*ngIf="!contractTermination"
5960
[currency]="currency"
6061
[isRequired]="true"
6162
[inputFormControl]="prepayLoanForm.controls.transactionAmount"
@@ -68,7 +69,7 @@
6869
<input matInput formControlName="externalId" />
6970
</mat-form-field>
7071

71-
<mat-form-field>
72+
<mat-form-field *ngIf="!contractTermination">
7273
<mat-label>{{ 'labels.inputs.Payment Type' | translate }}</mat-label>
7374
<mat-select formControlName="paymentTypeId">
7475
<mat-option *ngFor="let paymentType of paymentTypes" [value]="paymentType.id">
@@ -77,7 +78,7 @@
7778
</mat-select>
7879
</mat-form-field>
7980

80-
<div class="flex-fill">
81+
<div class="flex-fill" *ngIf="!contractTermination">
8182
<span class="expandcollapsebutton m-l-10 m-t-40 flex-75" (click)="addPaymentDetails()">
8283
<mat-slide-toggle>
8384
<div [className]="showPaymentDetails ? 'enabled' : 'disabled'">

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

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class PrepayLoanComponent implements OnInit {
3838

3939
prepayData: any;
4040
currency: Currency | null = null;
41+
contractTermination: boolean;
4142

4243
/**
4344
* @param {FormBuilder} formBuilder Form Builder.
@@ -62,10 +63,13 @@ export class PrepayLoanComponent implements OnInit {
6263
* and initialize with the required values
6364
*/
6465
ngOnInit() {
66+
this.prepayData = this.dataObject;
67+
this.contractTermination = this.dataObject['actionName'] == 'Contract Termination';
6568
this.maxDate = this.settingsService.businessDate;
6669
this.createprepayLoanForm();
67-
this.setPrepayLoanDetails();
68-
this.prepayData = this.dataObject;
70+
if (!this.contractTermination) {
71+
this.setPrepayLoanDetails();
72+
}
6973
if (this.dataObject.currency) {
7074
this.currency = this.dataObject.currency;
7175
}
@@ -75,19 +79,26 @@ export class PrepayLoanComponent implements OnInit {
7579
* Creates the prepay loan form.
7680
*/
7781
createprepayLoanForm() {
78-
this.prepayLoanForm = this.formBuilder.group({
79-
transactionDate: [
80-
new Date(),
81-
Validators.required
82-
],
83-
transactionAmount: [
84-
'',
85-
Validators.required
86-
],
87-
externalId: [''],
88-
paymentTypeId: [''],
89-
note: ['']
90-
});
82+
if (this.contractTermination) {
83+
this.prepayLoanForm = this.formBuilder.group({
84+
externalId: [''],
85+
note: ['']
86+
});
87+
} else {
88+
this.prepayLoanForm = this.formBuilder.group({
89+
transactionDate: [
90+
new Date(),
91+
Validators.required
92+
],
93+
transactionAmount: [
94+
'',
95+
Validators.required
96+
],
97+
externalId: [''],
98+
paymentTypeId: [''],
99+
note: ['']
100+
});
101+
}
91102
}
92103

93104
/**
@@ -133,7 +144,7 @@ export class PrepayLoanComponent implements OnInit {
133144
/**
134145
* Submits the prepay loan form
135146
*/
136-
submit() {
147+
submitRepayment() {
137148
const prepayLoanFormData = this.prepayLoanForm.value;
138149
const locale = this.settingsService.language.code;
139150
const dateFormat = this.settingsService.dateFormat;
@@ -151,4 +162,21 @@ export class PrepayLoanComponent implements OnInit {
151162
this.router.navigate(['../../general'], { relativeTo: this.route });
152163
});
153164
}
165+
166+
submitContractTermination() {
167+
const data = {
168+
...this.prepayLoanForm.value
169+
};
170+
this.loanService.loanActionButtons(this.loanId, 'contractTermination', data).subscribe((response: any) => {
171+
this.router.navigate(['../../general'], { relativeTo: this.route });
172+
});
173+
}
174+
175+
submit() {
176+
if (this.contractTermination) {
177+
this.submitContractTermination();
178+
} else {
179+
this.submitRepayment();
180+
}
181+
}
154182
}

src/app/loans/loans-view/loan-accounts-button-config.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { OptionData } from 'app/shared/models/option-data.model';
2+
13
/** Recurring Deposits Account Buttons Configuration */
24
export class LoansAccountButtonConfiguration {
35
optionArray: {
@@ -16,8 +18,8 @@ export class LoansAccountButtonConfiguration {
1618
taskPermissionName?: string;
1719
}[];
1820

19-
constructor(status: string) {
20-
this.setOptions(status);
21+
constructor(status: string, substatus: OptionData) {
22+
this.setOptions(status, substatus);
2123
this.setButtons(status);
2224
}
2325

@@ -154,7 +156,7 @@ export class LoansAccountButtonConfiguration {
154156
}
155157
}
156158

157-
setOptions(status: string) {
159+
setOptions(status: string, substatus: OptionData) {
158160
switch (status) {
159161
case 'Active':
160162
this.optionArray = [
@@ -199,6 +201,12 @@ export class LoansAccountButtonConfiguration {
199201
taskPermissionName: 'SALE_LOAN'
200202
}
201203
];
204+
if (!this.isContractTermination(substatus)) {
205+
this.optionArray.push({
206+
name: 'Contract Termination',
207+
taskPermissionName: 'CONTRACT_TERMINATION_LOAN'
208+
});
209+
}
202210
this.optionPaymentArray = [
203211
{
204212
name: 'Goodwill Credit',
@@ -281,4 +289,11 @@ export class LoansAccountButtonConfiguration {
281289
addButton(option: { name: string; icon: string; taskPermissionName?: string }) {
282290
this.buttonsArray.push(option);
283291
}
292+
293+
private isContractTermination(substatus: OptionData): boolean {
294+
if (substatus == null) {
295+
return false;
296+
}
297+
return substatus.code === 'loanSubStatus.loanSubStatusType.contractTermination';
298+
}
284299
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ <h3>
2222
<i
2323
class="fa fa-stop"
2424
matTooltip="{{ 'labels.status.' + loanDetailsData.status.value | translate }}"
25-
[ngClass]="
26-
loanDetailsData.inArrears ? 'status-active-overdue' : (iconLoanStatusColor() | statusLookup)
27-
"
25+
[ngClass]="iconLoanStatusColor() | statusLookup"
2826
></i>
2927
<span class="m-r-5">{{ 'labels.heading.Loan Product' | translate }} :</span>
3028
<span class="m-r-5"

0 commit comments

Comments
 (0)