diff --git a/src/app/loans/create-loans-account/create-loans-account.component.html b/src/app/loans/create-loans-account/create-loans-account.component.html index 7ba4b21c9..24d4a7a08 100644 --- a/src/app/loans/create-loans-account/create-loans-account.component.html +++ b/src/app/loans/create-loans-account/create-loans-account.component.html @@ -53,6 +53,16 @@ + + + REPAYMENT SCHEDULE + + + + + + PREVIEW diff --git a/src/app/loans/create-loans-account/create-loans-account.component.ts b/src/app/loans/create-loans-account/create-loans-account.component.ts index 32474e018..cee8bbf0d 100644 --- a/src/app/loans/create-loans-account/create-loans-account.component.ts +++ b/src/app/loans/create-loans-account/create-loans-account.component.ts @@ -121,59 +121,10 @@ export class CreateLoansAccountComponent implements OnInit { submit() { const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - const loansAccountData = { - ...this.loansAccount, - charges: this.loansAccount.charges.map((charge: any) => ({ - chargeId: charge.id, - amount: charge.amount, - dueDate: charge.dueDate && this.dateUtils.formatDate(charge.dueDate, dateFormat), - })), - collateral: this.loansAccount.collateral.map((collateralEle: any) => ({ - clientCollateralId: collateralEle.type.collateralId, - quantity: collateralEle.value, - })), - disbursementData: this.loansAccount.disbursementData.map((item: any) => ({ - expectedDisbursementDate: this.dateUtils.formatDate(item.expectedDisbursementDate, dateFormat), - principal: item.principal - })), - interestChargedFromDate: this.dateUtils.formatDate(this.loansAccount.interestChargedFromDate, dateFormat), - repaymentsStartingFromDate: this.dateUtils.formatDate(this.loansAccount.repaymentsStartingFromDate, dateFormat), - submittedOnDate: this.dateUtils.formatDate(this.loansAccount.submittedOnDate, dateFormat), - expectedDisbursementDate: this.dateUtils.formatDate(this.loansAccount.expectedDisbursementDate, dateFormat), - dateFormat, - locale, - }; - if (this.loansAccountTemplate.clientId) { - loansAccountData.clientId = this.loansAccountTemplate.clientId; - loansAccountData.loanType = 'individual'; - } else { - loansAccountData.groupId = this.loansAccountTemplate.group.id; - loansAccountData.loanType = 'group'; - } + const payload = this.loansService.buildLoanRequestPayload(this.loansAccount, this.loansAccountTemplate, + this.loansAccountProductTemplate.calendarOptions, locale, dateFormat); - if (loansAccountData.syncRepaymentsWithMeeting) { - loansAccountData.calendarId = this.loansAccountProductTemplate.calendarOptions[0].id; - delete loansAccountData.syncRepaymentsWithMeeting; - } - - if (loansAccountData.recalculationRestFrequencyDate) { - loansAccountData.recalculationRestFrequencyDate = this.dateUtils.formatDate(this.loansAccount.recalculationRestFrequencyDate, dateFormat); - } - - if (loansAccountData.interestCalculationPeriodType === 0) { - loansAccountData.allowPartialPeriodInterestCalcualtion = false; - } - if (!(loansAccountData.isFloatingInterestRate === false)) { - delete loansAccountData.isFloatingInterestRate; - } - if (!(this.multiDisburseLoan)) { - delete loansAccountData.disbursementData; - } - delete loansAccountData.isValid; - loansAccountData.principal = loansAccountData.principalAmount; - delete loansAccountData.principalAmount; - - this.loansService.createLoansAccount(loansAccountData).subscribe((response: any) => { + this.loansService.createLoansAccount(payload).subscribe((response: any) => { this.router.navigate(['../', response.resourceId, 'general'], { relativeTo: this.route }); }); } diff --git a/src/app/loans/edit-loans-account/edit-loans-account.component.html b/src/app/loans/edit-loans-account/edit-loans-account.component.html index a9e48d15f..2f3aa9448 100644 --- a/src/app/loans/edit-loans-account/edit-loans-account.component.html +++ b/src/app/loans/edit-loans-account/edit-loans-account.component.html @@ -52,6 +52,16 @@ + + + REPAYMENT SCHEDULE + + + + + + PREVIEW diff --git a/src/app/loans/edit-loans-account/edit-loans-account.component.ts b/src/app/loans/edit-loans-account/edit-loans-account.component.ts index abcd0e35f..2d28f759b 100644 --- a/src/app/loans/edit-loans-account/edit-loans-account.component.ts +++ b/src/app/loans/edit-loans-account/edit-loans-account.component.ts @@ -60,9 +60,11 @@ export class EditLoansAccountComponent implements OnInit { */ setTemplate($event: any) { this.loansAccountProductTemplate = $event; - this.loansService.getLoansCollateralTemplateResource(this.loansAccountProductTemplate.loanProductId).subscribe((response: any) => { - this.collateralOptions = response.loanCollateralOptions; - }); + if (this.loansAccountProductTemplate.loanProductId) { + this.loansService.getLoansCollateralTemplateResource(this.loansAccountProductTemplate.loanProductId).subscribe((response: any) => { + this.collateralOptions = response.loanCollateralOptions; + }); + } } /** Get Loans Account Details Form Data */ diff --git a/src/app/loans/loans-account-stepper/loans-account-details-step/loans-account-details-step.component.html b/src/app/loans/loans-account-stepper/loans-account-details-step/loans-account-details-step.component.html index 1cfa3a8b3..e57f70097 100644 --- a/src/app/loans/loans-account-stepper/loans-account-details-step/loans-account-details-step.component.html +++ b/src/app/loans/loans-account-stepper/loans-account-details-step/loans-account-details-step.component.html @@ -14,7 +14,7 @@ - + Loan officer @@ -22,6 +22,9 @@ + + +
Loan purpose @@ -84,7 +87,6 @@

Create standing instructions at disbursement

-
diff --git a/src/app/loans/loans-account-stepper/loans-account-details-step/loans-account-details-step.component.ts b/src/app/loans/loans-account-stepper/loans-account-details-step/loans-account-details-step.component.ts index d565dea27..9b05992be 100644 --- a/src/app/loans/loans-account-stepper/loans-account-details-step/loans-account-details-step.component.ts +++ b/src/app/loans/loans-account-stepper/loans-account-details-step/loans-account-details-step.component.ts @@ -41,6 +41,8 @@ export class LoansAccountDetailsStepComponent implements OnInit { loanId: any = null; + loanProductSelected = false; + /** Loans Account Template with product data */ @Output() loansAccountProductTemplate = new EventEmitter(); /** @@ -106,6 +108,7 @@ export class LoansAccountDetailsStepComponent implements OnInit { this.loanPurposeOptions = response.loanPurposeOptions; this.fundOptions = response.fundOptions; this.accountLinkingOptions = response.accountLinkingOptions; + this.loanProductSelected = true; if (response.createStandingInstructionAtDisbursement) { this.loansAccountDetailsForm.get('createStandingInstructionAtDisbursement').patchValue(response.createStandingInstructionAtDisbursement); } diff --git a/src/app/loans/loans-account-stepper/loans-account-schedule-step/loans-account-schedule-step.component.html b/src/app/loans/loans-account-stepper/loans-account-schedule-step/loans-account-schedule-step.component.html new file mode 100644 index 000000000..ea86f6e83 --- /dev/null +++ b/src/app/loans/loans-account-stepper/loans-account-schedule-step/loans-account-schedule-step.component.html @@ -0,0 +1,23 @@ +
+ + + Repayment Info + + + + +
+ +
+ + + +
diff --git a/src/app/loans/loans-account-stepper/loans-account-schedule-step/loans-account-schedule-step.component.scss b/src/app/loans/loans-account-stepper/loans-account-schedule-step/loans-account-schedule-step.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/loans/loans-account-stepper/loans-account-schedule-step/loans-account-schedule-step.component.spec.ts b/src/app/loans/loans-account-stepper/loans-account-schedule-step/loans-account-schedule-step.component.spec.ts new file mode 100644 index 000000000..d7761273a --- /dev/null +++ b/src/app/loans/loans-account-stepper/loans-account-schedule-step/loans-account-schedule-step.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { LoansAccountScheduleStepComponent } from './loans-account-schedule-step.component'; + +describe('LoansAccountScheduleStepComponent', () => { + let component: LoansAccountScheduleStepComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ LoansAccountScheduleStepComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(LoansAccountScheduleStepComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); 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 new file mode 100644 index 000000000..83dcfce93 --- /dev/null +++ b/src/app/loans/loans-account-stepper/loans-account-schedule-step/loans-account-schedule-step.component.ts @@ -0,0 +1,47 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { LoansService } from 'app/loans/loans.service'; +import { SettingsService } from 'app/settings/settings.service'; + +@Component({ + selector: 'mifosx-loans-account-schedule-step', + templateUrl: './loans-account-schedule-step.component.html', + styleUrls: ['./loans-account-schedule-step.component.scss'] +}) +export class LoansAccountScheduleStepComponent implements OnInit { + + /** Loans Account Template */ + @Input() loansAccountTemplate: any; + /** Loans Account Product Template */ + @Input() loansAccountProductTemplate: any; + /** Loans Account Data */ + @Input() loansAccount: any; + + showRepayment = false; + repaymentScheduleDetails: any = {periods: []}; + + loanId: any = null; + + constructor(private loansService: LoansService, + private settingsService: SettingsService, + private route: ActivatedRoute) { + this.loanId = this.route.snapshot.params['loanId']; + } + + ngOnInit(): void { } + + showRepaymentInfo(): void { + this.repaymentScheduleDetails = {periods: []}; + this.showRepayment = !this.showRepayment; + if (this.showRepayment) { + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; + const payload = this.loansService.buildLoanRequestPayload(this.loansAccount, this.loansAccountTemplate, + this.loansAccountProductTemplate.calendarOptions, locale, dateFormat); + + this.loansService.calculateLoanSchedule(payload).subscribe((response: any) => { + this.repaymentScheduleDetails = response; + }); + } + } +} diff --git a/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.html b/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.html index 400111aba..5e5a79edc 100644 --- a/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.html +++ b/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.html @@ -163,7 +163,6 @@ -

Calculate interest for exact days in partial period

@@ -192,19 +191,20 @@

Moratorium

- + Grace on principal payment - + Grace on interest payment - - On Arreas Aging - + + On arrears ageing + + Installment Amount @@ -360,7 +360,6 @@
-
-
+