diff --git a/src/app/directives/directives.module.ts b/src/app/directives/directives.module.ts
index 968e837fbf..5bcc19a9f9 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 0000000000..d5d5a9be64
--- /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 466c585245..dca4c448b2 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 d9edc0d1de..ddceadfcc0 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 63c2dac934..d661755a30 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 abcaca1594..a94608338e 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 }}
+
+
+