From e643c64711dff7982ee3f4ebae7b103fd4d9ec9e Mon Sep 17 00:00:00 2001 From: Gopi Kishan Date: Wed, 14 May 2025 08:02:32 +0530 Subject: [PATCH] WEB-172 Merging all changes from main branch into dev branch (#2450) --- src/app/directives/directives.module.ts | 7 +- .../directives/validate-on-focus.directive.ts | 18 +++++ .../loans-account-schedule-step.component.ts | 1 + .../make-repayment.component.ts | 31 +++++-- .../loan-tranche-details.component.ts | 3 +- .../transactions-tab.component.html | 10 +++ .../transactions-tab.component.ts | 80 ++++++++++++++++++- src/app/loans/loans.service.ts | 5 ++ .../models/loan-transaction-type.model.ts | 2 + .../create-charge.component.html | 17 ++-- .../create-charge/create-charge.component.ts | 76 ++++++++++-------- .../edit-charge/edit-charge.component.html | 21 ++--- .../edit-charge/edit-charge.component.ts | 73 +++++++++-------- .../validators/max-number-value.validator.ts | 26 ++++++ .../validators/min-number-value.validator.ts | 26 ++++++ src/assets/translations/cs-CS.json | 2 + src/assets/translations/de-DE.json | 2 + src/assets/translations/en-US.json | 2 + src/assets/translations/es-CL.json | 2 + src/assets/translations/es-MX.json | 2 + src/assets/translations/fr-FR.json | 2 + src/assets/translations/it-IT.json | 2 + src/assets/translations/ko-KO.json | 2 + src/assets/translations/lt-LT.json | 2 + src/assets/translations/lv-LV.json | 2 + src/assets/translations/ne-NE.json | 2 + src/assets/translations/pt-PT.json | 2 + src/assets/translations/sw-SW.json | 2 + src/environments/.env.ts | 4 +- 29 files changed, 331 insertions(+), 95 deletions(-) create mode 100644 src/app/directives/validate-on-focus.directive.ts create mode 100644 src/app/shared/validators/max-number-value.validator.ts create mode 100644 src/app/shared/validators/min-number-value.validator.ts diff --git a/src/app/directives/directives.module.ts b/src/app/directives/directives.module.ts index 968e837fb..5bcc19a9f 100644 --- a/src/app/directives/directives.module.ts +++ b/src/app/directives/directives.module.ts @@ -5,6 +5,7 @@ import { CommonModule } from '@angular/common'; /** Custom Directives */ import { HasPermissionDirective } from './has-permission/has-permission.directive'; import { FormatAmountDirective } from './format-amount.directive'; +import { ValidateOnFocusDirective } from './validate-on-focus.directive'; /** * Directives Module @@ -17,11 +18,13 @@ import { FormatAmountDirective } from './format-amount.directive'; ], declarations: [ HasPermissionDirective, - FormatAmountDirective + FormatAmountDirective, + ValidateOnFocusDirective ], exports: [ HasPermissionDirective, - FormatAmountDirective + FormatAmountDirective, + ValidateOnFocusDirective ] }) export class DirectivesModule {} diff --git a/src/app/directives/validate-on-focus.directive.ts b/src/app/directives/validate-on-focus.directive.ts new file mode 100644 index 000000000..d5d5a9be6 --- /dev/null +++ b/src/app/directives/validate-on-focus.directive.ts @@ -0,0 +1,18 @@ +import { Directive, ElementRef, HostListener } from '@angular/core'; +import { NgControl } from '@angular/forms'; + +@Directive({ + selector: '[mifosxValidateOnFocus]' +}) +export class ValidateOnFocusDirective { + constructor( + private control: NgControl, + private el: ElementRef + ) {} + + @HostListener('focus') + onFocus() { + this.control.control?.markAsTouched(); + this.control.control?.updateValueAndValidity(); + } +} diff --git a/src/app/loans/loans-account-stepper/loans-account-schedule-step/loans-account-schedule-step.component.ts b/src/app/loans/loans-account-stepper/loans-account-schedule-step/loans-account-schedule-step.component.ts index 466c58524..dca4c448b 100644 --- a/src/app/loans/loans-account-stepper/loans-account-schedule-step/loans-account-schedule-step.component.ts +++ b/src/app/loans/loans-account-stepper/loans-account-schedule-step/loans-account-schedule-step.component.ts @@ -42,6 +42,7 @@ export class LoansAccountScheduleStepComponent { dateFormat ); delete payload['enableInstallmentLevelDelinquency']; + delete payload['externalId']; this.loansService.calculateLoanSchedule(payload).subscribe((response: any) => { this.repaymentScheduleDetails = response; diff --git a/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.ts b/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.ts index d9edc0d1d..ddceadfcc 100644 --- a/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.ts @@ -58,6 +58,7 @@ export class MakeRepaymentComponent implements OnInit { * and initialize with the required values */ ngOnInit() { + this.command = this.dataObject.type.code.split('.')[1]; this.maxDate = this.settingsService.businessDate; this.createRepaymentLoanForm(); this.setRepaymentLoanDetails(); @@ -76,14 +77,27 @@ export class MakeRepaymentComponent implements OnInit { this.settingsService.businessDate, Validators.required ], - transactionAmount: [ - '', - Validators.required - ], externalId: '', paymentTypeId: '', note: '' }); + + if (this.isCapitalizedIncome()) { + this.repaymentLoanForm.addControl( + 'transactionAmount', + new UntypedFormControl('', [ + Validators.required, + Validators.min(0.001), + Validators.max(this.dataObject.amount)]) + ); + } else { + this.repaymentLoanForm.addControl( + 'transactionAmount', + new UntypedFormControl('', [ + Validators.required, + Validators.min(0.001)]) + ); + } } setRepaymentLoanDetails() { @@ -114,7 +128,14 @@ export class MakeRepaymentComponent implements OnInit { } showDetails(): boolean { - return !['capitalizedIncome'].includes(this.command); + return !this.isCapitalizedIncome(); + } + + isCapitalizedIncome(): boolean { + return [ + 'capitalizedIncome', + 'capitalizedIncomeAdjustment' + ].includes(this.command); } /** Submits the repayment form */ diff --git a/src/app/loans/loans-view/loan-tranche-details/loan-tranche-details.component.ts b/src/app/loans/loans-view/loan-tranche-details/loan-tranche-details.component.ts index 63c2dac93..d661755a3 100644 --- a/src/app/loans/loans-view/loan-tranche-details/loan-tranche-details.component.ts +++ b/src/app/loans/loans-view/loan-tranche-details/loan-tranche-details.component.ts @@ -212,7 +212,8 @@ export class LoanTrancheDetailsComponent implements OnInit { item.expectedDisbursementDate, this.settingsService.dateFormat ), - principal: item.principal + principal: item.principal, + id: item.id }); }); diff --git a/src/app/loans/loans-view/transactions-tab/transactions-tab.component.html b/src/app/loans/loans-view/transactions-tab/transactions-tab.component.html index abcaca159..a94608338 100644 --- a/src/app/loans/loans-view/transactions-tab/transactions-tab.component.html +++ b/src/app/loans/loans-view/transactions-tab/transactions-tab.component.html @@ -194,6 +194,16 @@ {{ 'labels.menus.Undo Re-Amortize' | translate }} + + +