Skip to content

Commit 3ce8b8a

Browse files
WEB-657: Working Capital Loan Discount Fee
1 parent 92b9984 commit 3ce8b8a

24 files changed

Lines changed: 64 additions & 44 deletions

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class LoanActionButtonResolver {
9999
return this.loansService.getLoanActionTemplate(loanId, 'reAmortization');
100100
} else if (loanActionButton === 'Attach Loan Originator') {
101101
return this.organizationService.getLoanOriginators();
102-
} else if (loanActionButton === 'Update discount') {
102+
} else if (loanActionButton === 'Discount Fee') {
103103
return this.loansService.getWorkingCapitalLoanDetails(loanId);
104104
} else {
105105
return undefined;

src/app/loans/loans-account-stepper/loans-account-preview-step/loans-account-preview-step.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ <h3 class="mat-h3 margin-t flex-fill">{{ 'labels.heading.Terms' | translate }}</
9191
<span class="flex-30">{{ 'labels.inputs.Total Payment Volume' | translate }}:</span>
9292
<span class="flex-70">
9393
{{
94-
loansAccount.totalPaymentVolume
95-
| currency: loansAccountProductTemplate.currency.code : 'symbol-narrow' : '1.2-2'
94+
loansAccount.totalPayment | currency: loansAccountProductTemplate.currency.code : 'symbol-narrow' : '1.2-2'
9695
}}
9796
<span class="m-l-5">{{ loansAccountProductTemplate.currency.code }}</span>
9897
</span>

src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.html

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,8 @@ <h4 class="mat-h4 flex-98">
2727
@if (loanProductService.isWorkingCapital) {
2828
<mat-form-field class="flex-48">
2929
<mat-label>{{ 'labels.inputs.Total Payment Volume' | translate }}</mat-label>
30-
<input
31-
type="number"
32-
matInput
33-
mifosxPositiveNumber
34-
min="0"
35-
required
36-
formControlName="totalPaymentVolume"
37-
step="any"
38-
/>
39-
@if (loansAccountTermsForm.controls.totalPaymentVolume.hasError('highAmountValue')) {
30+
<input type="number" matInput mifosxPositiveNumber min="0" required formControlName="totalPayment" step="any" />
31+
@if (loansAccountTermsForm.controls.totalPayment.hasError('highAmountValue')) {
4032
<mat-error>
4133
{{ 'labels.inputs.Total Payment' | translate }} {{ 'labels.commons.is' | translate }}
4234
<strong>{{ 'labels.commons.higher than allowed' | translate }}</strong>

src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ export class LoansAccountTermsStepComponent extends LoanProductBaseComponent imp
355355
discount: this.loansAccountTermsData.discountProposed || this.loansAccountTermsData.discount || '',
356356
principalAmount: this.loansAccountTermsData.proposedPrincipal,
357357
periodPaymentRate: this.loansAccountTermsData.periodPaymentRate,
358-
totalPaymentVolume: this.loansAccountTermsData.totalPaymentVolume,
358+
totalPayment: this.loansAccountTermsData.totalPayment,
359359
repaymentEvery: this.loansAccountTermsData.repaymentEvery,
360360
repaymentFrequencyType: this.loansAccountTermsData.repaymentFrequencyType?.id,
361361
delinquencyGraceDays: this.loansAccountTermsData.delinquencyGraceDays,
@@ -723,7 +723,7 @@ export class LoansAccountTermsStepComponent extends LoanProductBaseComponent imp
723723
amountValueValidator()
724724
]
725725
],
726-
totalPaymentVolume: [
726+
totalPayment: [
727727
'',
728728
[
729729
Validators.required,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,6 @@
117117
@if (actions['Attach Loan Originator']) {
118118
<mifosx-attach-originator [dataObject]="actionButtonData"></mifosx-attach-originator>
119119
}
120-
@if (actions['Update discount']) {
120+
@if (actions['Discount Fee']) {
121121
<mifosx-update-discount [dataObject]="actionButtonData"></mifosx-update-discount>
122122
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export class LoanAccountActionsComponent {
137137
'Buy Down Fee': boolean;
138138
'Undo Write-off': boolean;
139139
'Attach Loan Originator': boolean;
140-
'Update discount': boolean;
140+
'Discount Fee': boolean;
141141
} = {
142142
Close: false,
143143
'Undo Approval': false,
@@ -179,7 +179,7 @@ export class LoanAccountActionsComponent {
179179
'Buy Down Fee': false,
180180
'Undo Write-off': false,
181181
'Attach Loan Originator': false,
182-
'Update discount': false
182+
'Discount Fee': false
183183
};
184184

185185
actionButtonData: any;

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

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ import { amountValueValidator } from 'app/shared/validators/amount-value.validat
1818
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
1919
import { CdkTextareaAutosize } from '@angular/cdk/text-field';
2020
import { LoanAccountActionsBaseComponent } from '../loan-account-actions-base.component';
21-
import { WorkingCapitalLoanDiscountUpdateRequest } from 'app/loans/loans.service';
2221
import { Currency } from 'app/shared/models/general.model';
2322
import { InputAmountComponent } from 'app/shared/input-amount/input-amount.component';
23+
import { WorkingCapitalLoanDiscountUpdateRequest } from 'app/loans/models/working-capital/working-capital-loan-account.model';
2424

2525
/**
26-
* Update discount action for Working Capital Loan.
26+
* Discount Fee action for Working Capital Loan.
2727
*/
2828
@Component({
2929
selector: 'mifosx-update-discount',
@@ -61,7 +61,7 @@ export class UpdateDiscountComponent extends LoanAccountActionsBaseComponent imp
6161
}
6262
this.updateDiscountForm = this.formBuilder.group({
6363
transactionAmount: [
64-
this.dataObject?.discount ?? this.dataObject?.discountAmount ?? '',
64+
this.dataObject?.discount ?? this.dataObject?.transactionAmount ?? '',
6565
[
6666
Validators.required,
6767
Validators.min(0),
@@ -91,18 +91,20 @@ export class UpdateDiscountComponent extends LoanAccountActionsBaseComponent imp
9191
dateFormat: this.settingsService.dateFormat
9292
};
9393

94-
this.loanService.applyWorkingCapitalLoanAccountCommand(this.loanId, 'discountfee', payload).subscribe({
95-
next: () => {
96-
this.alertService.alert({
97-
type: 'Success',
98-
message: this.translateService.instant('labels.messages.workingCapitalDiscountUpdated')
99-
});
100-
this.gotoLoanDefaultView();
101-
},
102-
error: (error: HttpErrorResponse) => {
103-
this.submitErrorMessage = this.mapDiscountError(error);
104-
}
105-
});
94+
this.loanService
95+
.executeWorkingCapitalLoanAccountTransactionsCommand(this.loanId, 'discountFee', payload)
96+
.subscribe({
97+
next: () => {
98+
this.alertService.alert({
99+
type: 'Success',
100+
message: this.translateService.instant('labels.messages.workingCapitalDiscountUpdated')
101+
});
102+
this.gotoLoanDefaultView();
103+
},
104+
error: (error: HttpErrorResponse) => {
105+
this.submitErrorMessage = this.mapDiscountError(error);
106+
}
107+
});
106108
}
107109

108110
private mapDiscountError(error: HttpErrorResponse): string {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ export class LoansViewComponent extends LoanProductBaseComponent implements OnIn
260260
this.buttonConfig = new LoansAccountButtonConfiguration(this.status, this.loanSubStatus);
261261
if (this.canShowWorkingCapitalDiscountUpdate()) {
262262
this.buttonConfig.addButton({
263-
name: 'Update discount',
263+
name: 'Discount Fee',
264264
icon: 'edit',
265265
taskPermissionName: 'UPDATEDISCOUNT_WORKINGCAPITALLOAN'
266266
});

src/app/loans/loans-view/working-capital/loan-balances-tab/loan-balances-tab.component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import { CurrencyPipe } from '@angular/common';
1010
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
1111
import { ActivatedRoute } from '@angular/router';
12-
import { FormatNumberPipe } from '@pipes/format-number.pipe';
1312
import { WorkingCapitalBalances } from 'app/loans/models/working-capital/working-capital-loan-account.model';
1413
import { LoanProductBaseComponent } from 'app/products/loan-products/common/loan-product-base.component';
1514
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
@@ -20,7 +19,6 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
2019
styleUrl: './loan-balances-tab.component.scss',
2120
imports: [
2221
...STANDALONE_SHARED_IMPORTS,
23-
FormatNumberPipe,
2422
CurrencyPipe
2523
],
2624
changeDetection: ChangeDetectionStrategy.OnPush

src/app/loans/loans.service.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,7 @@ import { Observable } from 'rxjs';
1515
import { Dates } from 'app/core/utils/dates';
1616
import { SettingsService } from 'app/settings/settings.service';
1717
import { DisbursementData } from './models/loan-account.model';
18-
19-
export interface WorkingCapitalLoanDiscountUpdateRequest {
20-
transactionAmount: number;
21-
relatedResourceId: number;
22-
note?: string;
23-
locale: string;
24-
dateFormat: string;
25-
}
18+
import { WorkingCapitalLoanDiscountUpdateRequest } from './models/working-capital/working-capital-loan-account.model';
2619

2720
/**
2821
* Loans service.
@@ -383,6 +376,21 @@ export class LoansService {
383376
return this.http.post(`/working-capital-loans/${loanId}`, data, { params: httpParams });
384377
}
385378

379+
executeWorkingCapitalLoanAccountTransactionsCommand(
380+
accountId: string,
381+
command: string,
382+
data: any,
383+
transactionId?: any
384+
): Observable<any> {
385+
const httpParams = new HttpParams().set('command', command);
386+
if (transactionId !== null && transactionId !== undefined) {
387+
return this.http.post(`/working-capital-loans/${accountId}/transactions/${transactionId}`, data, {
388+
params: httpParams
389+
});
390+
}
391+
return this.http.post(`/working-capital-loans/${accountId}/transactions`, data, { params: httpParams });
392+
}
393+
386394
addInterestPauseToLoan(loanId: any, data?: any): Observable<any> {
387395
return this.http.post(`/loans/${loanId}/interest-pauses`, data);
388396
}

0 commit comments

Comments
 (0)