build: Use prettier for typescript
Stop ignoring .ts files in prettier and fix existing issues.
This commit is contained in:
+2
-3
@@ -8,9 +8,8 @@ describe('LoansAccountTermsStepComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ LoansAccountTermsStepComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [LoansAccountTermsStepComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
+202
-150
@@ -24,7 +24,6 @@ import { CodeName, OptionData } from 'app/shared/models/option-data.model';
|
||||
styleUrls: ['./loans-account-terms-step.component.scss']
|
||||
})
|
||||
export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||
|
||||
/** Loans Product Options */
|
||||
@Input() loansProductOptions: any;
|
||||
/** Loans Account Product Template */
|
||||
@@ -74,9 +73,19 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||
/** Collateral Data Source */
|
||||
collateralDataSource: {}[] = [];
|
||||
/** Columns to be displayed in collateral table. */
|
||||
loanCollateralDisplayedColumns: string[] = ['type', 'value', 'totalValue', 'totalCollateralValue', 'action'];
|
||||
loanCollateralDisplayedColumns: string[] = [
|
||||
'type',
|
||||
'value',
|
||||
'totalValue',
|
||||
'totalCollateralValue',
|
||||
'action'
|
||||
];
|
||||
/** Disbursement Data Displayed Columns */
|
||||
disbursementDisplayedColumns: string[] = ['expectedDisbursementDate', 'principal', 'actions'];
|
||||
disbursementDisplayedColumns: string[] = [
|
||||
'expectedDisbursementDate',
|
||||
'principal',
|
||||
'actions'
|
||||
];
|
||||
/** Multi Disbursement Control */
|
||||
totalMultiDisbursed: any = 0;
|
||||
isMultiDisbursedCompleted = false;
|
||||
@@ -97,12 +106,14 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||
* @param formBuilder FormBuilder
|
||||
* @param {SettingsService} settingsService SettingsService
|
||||
*/
|
||||
constructor(private formBuilder: UntypedFormBuilder,
|
||||
constructor(
|
||||
private formBuilder: UntypedFormBuilder,
|
||||
private settingsService: SettingsService,
|
||||
private route: ActivatedRoute,
|
||||
public dialog: MatDialog) {
|
||||
this.loanId = this.route.snapshot.params['loanId'];
|
||||
this.createloansAccountTermsForm();
|
||||
public dialog: MatDialog
|
||||
) {
|
||||
this.loanId = this.route.snapshot.params['loanId'];
|
||||
this.createloansAccountTermsForm();
|
||||
}
|
||||
/**
|
||||
* Executes on change of input values
|
||||
@@ -124,30 +135,30 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||
this.interestRateFrequencyTypeData = this.loansAccountTermsData.interestRateFrequencyTypeOptions;
|
||||
|
||||
this.loansAccountTermsForm.patchValue({
|
||||
'principalAmount': this.loansAccountTermsData.principal,
|
||||
'loanTermFrequency': this.loansAccountTermsData.termFrequency,
|
||||
'loanTermFrequencyType': this.loansAccountTermsData.termPeriodFrequencyType.id,
|
||||
'numberOfRepayments': this.loansAccountTermsData.numberOfRepayments,
|
||||
'repaymentEvery': this.loansAccountTermsData.repaymentEvery,
|
||||
'repaymentFrequencyType': this.loansAccountTermsData.repaymentFrequencyType.id,
|
||||
'amortizationType': this.loansAccountTermsData.amortizationType.id,
|
||||
'isEqualAmortization': this.loansAccountTermsData.isEqualAmortization,
|
||||
'interestType': this.loansAccountTermsData.interestType.id,
|
||||
'isFloatingInterestRate': this.loansAccountTermsData.isLoanProductLinkedToFloatingRate ? false : '',
|
||||
'interestCalculationPeriodType': this.loansAccountTermsData.interestCalculationPeriodType.id,
|
||||
'allowPartialPeriodInterestCalcualtion': this.loansAccountTermsData.allowPartialPeriodInterestCalcualtion,
|
||||
'inArrearsTolerance': this.loansAccountTermsData.inArrearsTolerance,
|
||||
'graceOnPrincipalPayment': this.loansAccountTermsData.graceOnPrincipalPayment,
|
||||
'graceOnInterestPayment': this.loansAccountTermsData.graceOnInterestPayment,
|
||||
'graceOnArrearsAgeing': this.loansAccountTermsData.graceOnArrearsAgeing,
|
||||
'graceOnInterestCharged': this.loansAccountTermsData.graceOnInterestCharged,
|
||||
'fixedEmiAmount': this.loansAccountTermsData.fixedEmiAmount,
|
||||
'maxOutstandingLoanBalance': this.loansAccountTermsData.maxOutstandingLoanBalance,
|
||||
'transactionProcessingStrategyCode': this.loansAccountTermsData.transactionProcessingStrategyCode,
|
||||
'interestRateDifferential': this.loansAccountTermsData.interestRateDifferential,
|
||||
'multiDisburseLoan': this.loansAccountTermsData.multiDisburseLoan,
|
||||
'interestRateFrequencyType': this.loansAccountTermsData.interestRateFrequencyType.id,
|
||||
'balloonRepaymentAmount': this.loansAccountTermsData.balloonRepaymentAmount,
|
||||
principalAmount: this.loansAccountTermsData.principal,
|
||||
loanTermFrequency: this.loansAccountTermsData.termFrequency,
|
||||
loanTermFrequencyType: this.loansAccountTermsData.termPeriodFrequencyType.id,
|
||||
numberOfRepayments: this.loansAccountTermsData.numberOfRepayments,
|
||||
repaymentEvery: this.loansAccountTermsData.repaymentEvery,
|
||||
repaymentFrequencyType: this.loansAccountTermsData.repaymentFrequencyType.id,
|
||||
amortizationType: this.loansAccountTermsData.amortizationType.id,
|
||||
isEqualAmortization: this.loansAccountTermsData.isEqualAmortization,
|
||||
interestType: this.loansAccountTermsData.interestType.id,
|
||||
isFloatingInterestRate: this.loansAccountTermsData.isLoanProductLinkedToFloatingRate ? false : '',
|
||||
interestCalculationPeriodType: this.loansAccountTermsData.interestCalculationPeriodType.id,
|
||||
allowPartialPeriodInterestCalcualtion: this.loansAccountTermsData.allowPartialPeriodInterestCalcualtion,
|
||||
inArrearsTolerance: this.loansAccountTermsData.inArrearsTolerance,
|
||||
graceOnPrincipalPayment: this.loansAccountTermsData.graceOnPrincipalPayment,
|
||||
graceOnInterestPayment: this.loansAccountTermsData.graceOnInterestPayment,
|
||||
graceOnArrearsAgeing: this.loansAccountTermsData.graceOnArrearsAgeing,
|
||||
graceOnInterestCharged: this.loansAccountTermsData.graceOnInterestCharged,
|
||||
fixedEmiAmount: this.loansAccountTermsData.fixedEmiAmount,
|
||||
maxOutstandingLoanBalance: this.loansAccountTermsData.maxOutstandingLoanBalance,
|
||||
transactionProcessingStrategyCode: this.loansAccountTermsData.transactionProcessingStrategyCode,
|
||||
interestRateDifferential: this.loansAccountTermsData.interestRateDifferential,
|
||||
multiDisburseLoan: this.loansAccountTermsData.multiDisburseLoan,
|
||||
interestRateFrequencyType: this.loansAccountTermsData.interestRateFrequencyType.id,
|
||||
balloonRepaymentAmount: this.loansAccountTermsData.balloonRepaymentAmount
|
||||
});
|
||||
|
||||
this.setAdvancedPaymentStrategyControls();
|
||||
@@ -165,11 +176,17 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||
});
|
||||
}
|
||||
if (this.isDelinquencyEnabled()) {
|
||||
this.loansAccountTermsForm.addControl('enableInstallmentLevelDelinquency', new UntypedFormControl(this.loansAccountTermsData.enableInstallmentLevelDelinquency || this.loanProduct.enableInstallmentLevelDelinquency));
|
||||
this.loansAccountTermsForm.addControl(
|
||||
'enableInstallmentLevelDelinquency',
|
||||
new UntypedFormControl(
|
||||
this.loansAccountTermsData.enableInstallmentLevelDelinquency ||
|
||||
this.loanProduct.enableInstallmentLevelDelinquency
|
||||
)
|
||||
);
|
||||
}
|
||||
this.collateralDataSource = this.loansAccountTermsData.collateral || [];
|
||||
if (this.productEnableDownPayment) {
|
||||
const enableDownPayment = (this.loansAccountTermsData['enableDownPayment'] === false) ? false : true;
|
||||
const enableDownPayment = this.loansAccountTermsData['enableDownPayment'] === false ? false : true;
|
||||
this.loansAccountTermsForm.addControl('enableDownPayment', new UntypedFormControl(enableDownPayment));
|
||||
}
|
||||
|
||||
@@ -217,34 +234,36 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||
if (this.loansAccountTermsData) {
|
||||
if (this.loansAccountTermsData.loanProductId) {
|
||||
this.loansAccountTermsForm.patchValue({
|
||||
'repaymentsStartingFromDate': this.loansAccountTermsData.expectedFirstRepaymentOnDate && new Date(this.loansAccountTermsData.expectedFirstRepaymentOnDate)
|
||||
repaymentsStartingFromDate:
|
||||
this.loansAccountTermsData.expectedFirstRepaymentOnDate &&
|
||||
new Date(this.loansAccountTermsData.expectedFirstRepaymentOnDate)
|
||||
});
|
||||
}
|
||||
this.loansAccountTermsForm.patchValue({
|
||||
'principalAmount': this.loansAccountTermsData.principal,
|
||||
'loanTermFrequency': this.loansAccountTermsData.termFrequency,
|
||||
'loanTermFrequencyType': this.loansAccountTermsData.termPeriodFrequencyType.id,
|
||||
'numberOfRepayments': this.loansAccountTermsData.numberOfRepayments,
|
||||
'repaymentEvery': this.loansAccountTermsData.repaymentEvery,
|
||||
'repaymentFrequencyType': this.loansAccountTermsData.repaymentFrequencyType.id,
|
||||
'amortizationType': this.loansAccountTermsData.amortizationType.id,
|
||||
'isEqualAmortization': this.loansAccountTermsData.isEqualAmortization,
|
||||
'interestType': this.loansAccountTermsData.interestType.id,
|
||||
'isFloatingInterestRate': this.loansAccountTermsData.isLoanProductLinkedToFloatingRate ? false : '',
|
||||
'interestCalculationPeriodType': this.loansAccountTermsData.interestCalculationPeriodType.id,
|
||||
'allowPartialPeriodInterestCalcualtion': this.loansAccountTermsData.allowPartialPeriodInterestCalcualtion,
|
||||
'inArrearsTolerance': this.loansAccountTermsData.inArrearsTolerance,
|
||||
'graceOnPrincipalPayment': this.loansAccountTermsData.graceOnPrincipalPayment,
|
||||
'graceOnInterestPayment': this.loansAccountTermsData.graceOnInterestPayment,
|
||||
'graceOnArrearsAgeing': this.loansAccountTermsData.graceOnArrearsAgeing,
|
||||
'graceOnInterestCharged': this.loansAccountTermsData.graceOnInterestCharged,
|
||||
'fixedEmiAmount': this.loansAccountTermsData.fixedEmiAmount,
|
||||
'maxOutstandingLoanBalance': this.loansAccountTermsData.maxOutstandingLoanBalance,
|
||||
'transactionProcessingStrategyCode': this.loansAccountTermsData.transactionProcessingStrategyCode,
|
||||
'interestRateDifferential': this.loansAccountTermsData.interestRateDifferential,
|
||||
'multiDisburseLoan': this.loansAccountTermsData.multiDisburseLoan,
|
||||
'interestRateFrequencyType': this.loansAccountTermsData.interestRateFrequencyType.id,
|
||||
'balloonRepaymentAmount': this.loansAccountTermsData.balloonRepaymentAmount
|
||||
principalAmount: this.loansAccountTermsData.principal,
|
||||
loanTermFrequency: this.loansAccountTermsData.termFrequency,
|
||||
loanTermFrequencyType: this.loansAccountTermsData.termPeriodFrequencyType.id,
|
||||
numberOfRepayments: this.loansAccountTermsData.numberOfRepayments,
|
||||
repaymentEvery: this.loansAccountTermsData.repaymentEvery,
|
||||
repaymentFrequencyType: this.loansAccountTermsData.repaymentFrequencyType.id,
|
||||
amortizationType: this.loansAccountTermsData.amortizationType.id,
|
||||
isEqualAmortization: this.loansAccountTermsData.isEqualAmortization,
|
||||
interestType: this.loansAccountTermsData.interestType.id,
|
||||
isFloatingInterestRate: this.loansAccountTermsData.isLoanProductLinkedToFloatingRate ? false : '',
|
||||
interestCalculationPeriodType: this.loansAccountTermsData.interestCalculationPeriodType.id,
|
||||
allowPartialPeriodInterestCalcualtion: this.loansAccountTermsData.allowPartialPeriodInterestCalcualtion,
|
||||
inArrearsTolerance: this.loansAccountTermsData.inArrearsTolerance,
|
||||
graceOnPrincipalPayment: this.loansAccountTermsData.graceOnPrincipalPayment,
|
||||
graceOnInterestPayment: this.loansAccountTermsData.graceOnInterestPayment,
|
||||
graceOnArrearsAgeing: this.loansAccountTermsData.graceOnArrearsAgeing,
|
||||
graceOnInterestCharged: this.loansAccountTermsData.graceOnInterestCharged,
|
||||
fixedEmiAmount: this.loansAccountTermsData.fixedEmiAmount,
|
||||
maxOutstandingLoanBalance: this.loansAccountTermsData.maxOutstandingLoanBalance,
|
||||
transactionProcessingStrategyCode: this.loansAccountTermsData.transactionProcessingStrategyCode,
|
||||
interestRateDifferential: this.loansAccountTermsData.interestRateDifferential,
|
||||
multiDisburseLoan: this.loansAccountTermsData.multiDisburseLoan,
|
||||
interestRateFrequencyType: this.loansAccountTermsData.interestRateFrequencyType.id,
|
||||
balloonRepaymentAmount: this.loansAccountTermsData.balloonRepaymentAmount
|
||||
});
|
||||
}
|
||||
this.createloansAccountTermsForm();
|
||||
@@ -254,7 +273,7 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
allowAddDisbursementDetails() {
|
||||
return (this.multiDisburseLoan && !this.loansAccountTermsData.disallowExpectedDisbursements);
|
||||
return this.multiDisburseLoan && !this.loansAccountTermsData.disallowExpectedDisbursements;
|
||||
}
|
||||
|
||||
/** Custom Validators for the form */
|
||||
@@ -262,63 +281,68 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||
const repaymentFrequencyNthDayType = this.loansAccountTermsForm.get('repaymentFrequencyNthDayType');
|
||||
const repaymentFrequencyDayOfWeekType = this.loansAccountTermsForm.get('repaymentFrequencyDayOfWeekType');
|
||||
|
||||
this.loansAccountTermsForm.get('repaymentFrequencyType').valueChanges
|
||||
.subscribe(repaymentFrequencyType => {
|
||||
this.loansAccountTermsForm.get('repaymentFrequencyType').valueChanges.subscribe((repaymentFrequencyType) => {
|
||||
if (repaymentFrequencyType === 2) {
|
||||
repaymentFrequencyNthDayType.setValidators([Validators.required]);
|
||||
repaymentFrequencyDayOfWeekType.setValidators([Validators.required]);
|
||||
} else {
|
||||
repaymentFrequencyNthDayType.setValidators(null);
|
||||
repaymentFrequencyDayOfWeekType.setValidators(null);
|
||||
}
|
||||
|
||||
if (repaymentFrequencyType === 2) {
|
||||
repaymentFrequencyNthDayType.setValidators([Validators.required]);
|
||||
repaymentFrequencyDayOfWeekType.setValidators([Validators.required]);
|
||||
} else {
|
||||
repaymentFrequencyNthDayType.setValidators(null);
|
||||
repaymentFrequencyDayOfWeekType.setValidators(null);
|
||||
}
|
||||
|
||||
repaymentFrequencyNthDayType.updateValueAndValidity();
|
||||
repaymentFrequencyDayOfWeekType.updateValueAndValidity();
|
||||
});
|
||||
repaymentFrequencyNthDayType.updateValueAndValidity();
|
||||
repaymentFrequencyDayOfWeekType.updateValueAndValidity();
|
||||
});
|
||||
}
|
||||
|
||||
/** Custom Listeners for the form to calculate Loan Term */
|
||||
setLoanTermListener() {
|
||||
this.loansAccountTermsForm.get('numberOfRepayments').valueChanges
|
||||
.subscribe(numberOfRepayments => {
|
||||
const repaymentEvery: number = this.loansAccountTermsForm.value.repaymentEvery;
|
||||
this.calculateLoanTerm(numberOfRepayments, repaymentEvery);
|
||||
});
|
||||
this.loansAccountTermsForm.get('numberOfRepayments').valueChanges.subscribe((numberOfRepayments) => {
|
||||
const repaymentEvery: number = this.loansAccountTermsForm.value.repaymentEvery;
|
||||
this.calculateLoanTerm(numberOfRepayments, repaymentEvery);
|
||||
});
|
||||
|
||||
this.loansAccountTermsForm.get('repaymentEvery').valueChanges
|
||||
.subscribe(repaymentEvery => {
|
||||
const numberOfRepayments: number = this.loansAccountTermsForm.value.numberOfRepayments;
|
||||
this.calculateLoanTerm(numberOfRepayments, repaymentEvery);
|
||||
});
|
||||
this.loansAccountTermsForm.get('repaymentEvery').valueChanges.subscribe((repaymentEvery) => {
|
||||
const numberOfRepayments: number = this.loansAccountTermsForm.value.numberOfRepayments;
|
||||
this.calculateLoanTerm(numberOfRepayments, repaymentEvery);
|
||||
});
|
||||
|
||||
this.loansAccountTermsForm.get('loanTermFrequencyType').valueChanges
|
||||
.subscribe(loanTermFrequencyType => {
|
||||
this.loansAccountTermsForm.patchValue({'repaymentFrequencyType': loanTermFrequencyType});
|
||||
});
|
||||
this.loansAccountTermsForm.get('loanTermFrequencyType').valueChanges.subscribe((loanTermFrequencyType) => {
|
||||
this.loansAccountTermsForm.patchValue({ repaymentFrequencyType: loanTermFrequencyType });
|
||||
});
|
||||
|
||||
this.loansAccountTermsForm.get('amortizationType').valueChanges
|
||||
.subscribe(amortizationType => {
|
||||
if (amortizationType === 0) { // Equal Principal Payments
|
||||
this.loansAccountTermsForm.addControl('fixedPrincipalPercentagePerInstallment', new UntypedFormControl(''));
|
||||
} else { // Equal Installments
|
||||
this.loansAccountTermsForm.removeControl('fixedPrincipalPercentagePerInstallment');
|
||||
}
|
||||
this.loansAccountTermsForm.get('amortizationType').valueChanges.subscribe((amortizationType) => {
|
||||
if (amortizationType === 0) {
|
||||
// Equal Principal Payments
|
||||
this.loansAccountTermsForm.addControl('fixedPrincipalPercentagePerInstallment', new UntypedFormControl(''));
|
||||
} else {
|
||||
// Equal Installments
|
||||
this.loansAccountTermsForm.removeControl('fixedPrincipalPercentagePerInstallment');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setAdvancedPaymentStrategyControls(): void {
|
||||
// Fixed Length validation
|
||||
if (this.loansAccountTermsData) {
|
||||
this.loansAccountTermsForm.removeControl('interestRatePerPeriod');
|
||||
this.loansAccountTermsForm.removeControl('fixedLength');
|
||||
if (this.loansAccountTermsData.product.fixedLength) {
|
||||
this.loansAccountTermsForm.addControl('interestRatePerPeriod', new UntypedFormControl({value: 0, disabled: true}, Validators.required));
|
||||
this.loansAccountTermsForm.addControl('fixedLength', new UntypedFormControl(this.loansAccountTermsData.product.fixedLength));
|
||||
} else {
|
||||
this.loansAccountTermsForm.addControl('interestRatePerPeriod', new UntypedFormControl(this.loansAccountTermsData.interestRatePerPeriod, Validators.required));
|
||||
}
|
||||
// Fixed Length validation
|
||||
if (this.loansAccountTermsData) {
|
||||
this.loansAccountTermsForm.removeControl('interestRatePerPeriod');
|
||||
this.loansAccountTermsForm.removeControl('fixedLength');
|
||||
if (this.loansAccountTermsData.product.fixedLength) {
|
||||
this.loansAccountTermsForm.addControl(
|
||||
'interestRatePerPeriod',
|
||||
new UntypedFormControl({ value: 0, disabled: true }, Validators.required)
|
||||
);
|
||||
this.loansAccountTermsForm.addControl(
|
||||
'fixedLength',
|
||||
new UntypedFormControl(this.loansAccountTermsData.product.fixedLength)
|
||||
);
|
||||
} else {
|
||||
this.loansAccountTermsForm.addControl(
|
||||
'interestRatePerPeriod',
|
||||
new UntypedFormControl(this.loansAccountTermsData.interestRatePerPeriod, Validators.required)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hasFixedLength(): boolean {
|
||||
@@ -329,49 +353,73 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
isEqualPrincipalPayments(): boolean {
|
||||
return (this.loansAccountTermsForm.value.amortizationType === 0);
|
||||
return this.loansAccountTermsForm.value.amortizationType === 0;
|
||||
}
|
||||
|
||||
/** Create Loans Account Terms Form */
|
||||
createloansAccountTermsForm() {
|
||||
this.loansAccountTermsForm = this.formBuilder.group({
|
||||
'principalAmount': ['', Validators.required],
|
||||
'loanTermFrequency': [{ value: '', disabled: true }, Validators.required],
|
||||
'loanTermFrequencyType': ['', Validators.required],
|
||||
'numberOfRepayments': ['', Validators.required],
|
||||
'repaymentEvery': ['', Validators.required],
|
||||
'repaymentFrequencyType': [{ value: '', disabled: true }, Validators.required],
|
||||
'repaymentFrequencyNthDayType': [''],
|
||||
'repaymentFrequencyDayOfWeekType': [''],
|
||||
'repaymentsStartingFromDate': [''],
|
||||
'interestChargedFromDate': [''],
|
||||
'interestRatePerPeriod': [''],
|
||||
'interestType': [''],
|
||||
'isFloatingInterestRate': [''],
|
||||
'isEqualAmortization': [''],
|
||||
'amortizationType': ['', Validators.required],
|
||||
'interestCalculationPeriodType': [''],
|
||||
'allowPartialPeriodInterestCalcualtion': [''],
|
||||
'inArrearsTolerance': [''],
|
||||
'graceOnInterestCharged': [''],
|
||||
'graceOnPrincipalPayment': [''],
|
||||
'graceOnInterestPayment': [''],
|
||||
'graceOnArrearsAgeing': [''],
|
||||
'loanIdToClose': [''],
|
||||
'fixedEmiAmount': [''],
|
||||
'isTopup': [''],
|
||||
'maxOutstandingLoanBalance': [''],
|
||||
'interestRateDifferential': [''],
|
||||
'transactionProcessingStrategyCode': ['', Validators.required],
|
||||
'multiDisburseLoan': [false],
|
||||
'interestRateFrequencyType': [''],
|
||||
'balloonRepaymentAmount': ['']
|
||||
principalAmount: [
|
||||
'',
|
||||
Validators.required
|
||||
],
|
||||
loanTermFrequency: [
|
||||
{ value: '', disabled: true },
|
||||
Validators.required
|
||||
],
|
||||
loanTermFrequencyType: [
|
||||
'',
|
||||
Validators.required
|
||||
],
|
||||
numberOfRepayments: [
|
||||
'',
|
||||
Validators.required
|
||||
],
|
||||
repaymentEvery: [
|
||||
'',
|
||||
Validators.required
|
||||
],
|
||||
repaymentFrequencyType: [
|
||||
{ value: '', disabled: true },
|
||||
Validators.required
|
||||
],
|
||||
repaymentFrequencyNthDayType: [''],
|
||||
repaymentFrequencyDayOfWeekType: [''],
|
||||
repaymentsStartingFromDate: [''],
|
||||
interestChargedFromDate: [''],
|
||||
interestRatePerPeriod: [''],
|
||||
interestType: [''],
|
||||
isFloatingInterestRate: [''],
|
||||
isEqualAmortization: [''],
|
||||
amortizationType: [
|
||||
'',
|
||||
Validators.required
|
||||
],
|
||||
interestCalculationPeriodType: [''],
|
||||
allowPartialPeriodInterestCalcualtion: [''],
|
||||
inArrearsTolerance: [''],
|
||||
graceOnInterestCharged: [''],
|
||||
graceOnPrincipalPayment: [''],
|
||||
graceOnInterestPayment: [''],
|
||||
graceOnArrearsAgeing: [''],
|
||||
loanIdToClose: [''],
|
||||
fixedEmiAmount: [''],
|
||||
isTopup: [''],
|
||||
maxOutstandingLoanBalance: [''],
|
||||
interestRateDifferential: [''],
|
||||
transactionProcessingStrategyCode: [
|
||||
'',
|
||||
Validators.required
|
||||
],
|
||||
multiDisburseLoan: [false],
|
||||
interestRateFrequencyType: [''],
|
||||
balloonRepaymentAmount: ['']
|
||||
});
|
||||
}
|
||||
|
||||
calculateLoanTerm(numberOfRepayments: number, repaymentEvery: number): void {
|
||||
const loanTerm = numberOfRepayments * repaymentEvery;
|
||||
this.loansAccountTermsForm.patchValue({'loanTermFrequency': loanTerm});
|
||||
this.loansAccountTermsForm.patchValue({ loanTermFrequency: loanTerm });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -408,6 +456,7 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||
required: true,
|
||||
order: 2
|
||||
})
|
||||
|
||||
];
|
||||
const data = {
|
||||
title: 'Add Disbursement Details',
|
||||
@@ -418,10 +467,10 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||
disbursementDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.data) {
|
||||
const principal = response.data.value.principal * 1;
|
||||
if ((this.totalMultiDisbursed + principal) <= currentPrincipalAmount) {
|
||||
if (this.totalMultiDisbursed + principal <= currentPrincipalAmount) {
|
||||
this.disbursementDataSource = this.disbursementDataSource.concat(response.data.value);
|
||||
this.totalMultiDisbursed += principal;
|
||||
this.isMultiDisbursedCompleted = (this.totalMultiDisbursed === currentPrincipalAmount);
|
||||
this.isMultiDisbursedCompleted = this.totalMultiDisbursed === currentPrincipalAmount;
|
||||
this.pristine = false;
|
||||
}
|
||||
}
|
||||
@@ -443,7 +492,7 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||
this.disbursementDataSource.splice(index, 1);
|
||||
this.disbursementDataSource = this.disbursementDataSource.concat([]);
|
||||
this.totalMultiDisbursed -= principal;
|
||||
this.isMultiDisbursedCompleted = (this.totalMultiDisbursed === currentPrincipalAmount);
|
||||
this.isMultiDisbursedCompleted = this.totalMultiDisbursed === currentPrincipalAmount;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -459,11 +508,14 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||
if (response.data) {
|
||||
const collateralData = {
|
||||
type: response.data.value.collateral,
|
||||
value: response.data.value.quantity,
|
||||
value: response.data.value.quantity
|
||||
};
|
||||
this.totalCollateralValue += collateralData.type.pctToBase * collateralData.type.basePrice * collateralData.value / 100;
|
||||
this.totalCollateralValue +=
|
||||
(collateralData.type.pctToBase * collateralData.type.basePrice * collateralData.value) / 100;
|
||||
this.collateralDataSource = this.collateralDataSource.concat(collateralData);
|
||||
this.collateralOptions = this.collateralOptions.filter((user: any) => user.collateralId !== response.data.value.collateral.collateralId);
|
||||
this.collateralOptions = this.collateralOptions.filter(
|
||||
(user: any) => user.collateralId !== response.data.value.collateral.collateralId
|
||||
);
|
||||
if (this.loanPrincipal < this.totalCollateralValue) {
|
||||
this.isCollateralSufficient = true;
|
||||
} else {
|
||||
@@ -484,7 +536,7 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||
if (response.delete) {
|
||||
const removed: any = this.collateralDataSource.splice(id, 1);
|
||||
this.collateralOptions = this.collateralOptions.concat(removed[0].type);
|
||||
this.totalCollateralValue -= removed[0].type.pctToBase * removed[0].type.basePrice * removed[0].value / 100;
|
||||
this.totalCollateralValue -= (removed[0].type.pctToBase * removed[0].type.basePrice * removed[0].value) / 100;
|
||||
this.collateralDataSource = this.collateralDataSource.concat([]);
|
||||
this.pristine = false;
|
||||
if (this.loanPrincipal < this.totalCollateralValue) {
|
||||
@@ -502,7 +554,8 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||
setOptions() {
|
||||
this.termFrequencyTypeData = this.loansAccountProductTemplate.termFrequencyTypeOptions;
|
||||
this.repaymentFrequencyNthDayTypeData = this.loansAccountProductTemplate.repaymentFrequencyNthDayTypeOptions;
|
||||
this.repaymentFrequencyDaysOfWeekTypeData = this.loansAccountProductTemplate.repaymentFrequencyDaysOfWeekTypeOptions;
|
||||
this.repaymentFrequencyDaysOfWeekTypeData =
|
||||
this.loansAccountProductTemplate.repaymentFrequencyDaysOfWeekTypeOptions;
|
||||
this.interestTypeData = this.loansAccountProductTemplate.interestTypeOptions;
|
||||
this.amortizationTypeData = this.loansAccountProductTemplate.amortizationTypeOptions;
|
||||
this.interestCalculationPeriodTypeData = this.loansAccountProductTemplate.interestCalculationPeriodTypeOptions;
|
||||
@@ -511,14 +564,14 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||
this.transactionProcessingStrategyOptions = [];
|
||||
if (this.loanScheduleType.code === LoanProducts.LOAN_SCHEDULE_TYPE_CUMULATIVE) {
|
||||
// Filter Advanced Payment Allocation Strategy
|
||||
this.transactionProcessingStrategyOptions = this.loansAccountProductTemplate.transactionProcessingStrategyOptions.filter(
|
||||
(cn: CodeName) => !LoanProducts.isAdvancedPaymentAllocationStrategy(cn.code)
|
||||
);
|
||||
this.transactionProcessingStrategyOptions =
|
||||
this.loansAccountProductTemplate.transactionProcessingStrategyOptions.filter(
|
||||
(cn: CodeName) => !LoanProducts.isAdvancedPaymentAllocationStrategy(cn.code)
|
||||
);
|
||||
this.repaymentStrategyDisabled = false;
|
||||
} else {
|
||||
// Only Advanced Payment Allocation Strategy
|
||||
this.loansAccountProductTemplate.transactionProcessingStrategyOptions.some(
|
||||
(cn: CodeName) => {
|
||||
this.loansAccountProductTemplate.transactionProcessingStrategyOptions.some((cn: CodeName) => {
|
||||
if (LoanProducts.isAdvancedPaymentAllocationStrategy(cn.code)) {
|
||||
this.transactionProcessingStrategyOptions.push(cn);
|
||||
}
|
||||
@@ -554,5 +607,4 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||
collateral: this.collateralDataSource
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user