Add Repayment Info as part of the Loan Account request

This commit is contained in:
Jose Alberto Hernandez
2022-11-25 11:50:15 -06:00
parent 5e6f14a5e0
commit 460d9bf8be
16 changed files with 227 additions and 80 deletions
@@ -0,0 +1,23 @@
<div fxLayout="row wrap" fxLayout.lt-md="column">
<a mat-button (click)="showRepaymentInfo()">
Repayment Info
</a>
<mifosx-repayment-schedule-tab fxFlex="100%" [repaymentScheduleDetails]="repaymentScheduleDetails"></mifosx-repayment-schedule-tab>
</div>
<div fxLayout="row" class="margin-t" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="2%">
<button mat-raised-button matStepperPrevious>
<fa-icon icon="arrow-left"></fa-icon>&nbsp;&nbsp;
Previous
</button>
<button mat-raised-button matStepperNext>
Next&nbsp;&nbsp;
<fa-icon icon="arrow-right"></fa-icon>
</button>
<button mat-raised-button *ngIf="loanId" [routerLink]="['../', 'general']">
Cancel
</button>
</div>
@@ -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<LoansAccountScheduleStepComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ LoansAccountScheduleStepComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(LoansAccountScheduleStepComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -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;
});
}
}
}