Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ export class CreateLoansAccountComponent extends LoanProductBaseComponent implem
setProductType($event: any): void {
this.productType = $event;
this.loanProductService.initialize(this.productType);
this.loansAccountProductTemplate = null;
this.productId = null;
this.cdr.detectChanges();
}

setDatatables(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ <h3 class="mat-h3 margin-t flex-fill">{{ 'labels.heading.Terms' | translate }}</
@if (loansAccount.delinquencyStartType) {
<div class="flex-fill">
<span class="flex-30">{{ 'labels.inputs.Delinquency Start Type' | translate }}:</span>
<span class="flex-60">{{ camalize(loansAccount.delinquencyStartType) | translateKey: 'catalogs' }}</span>
<span class="flex-60">{{ camalize(delinquencyStartTypeOption?.value) | translateKey: 'catalogs' }}</span>
</div>
}

Expand Down Expand Up @@ -151,7 +151,7 @@ <h3 class="mat-h3 margin-t flex-fill">{{ 'labels.heading.Terms' | translate }}</
<span class="flex-30">{{ 'labels.inputs.Period Payment Frequency' | translate }}:</span>
<span class="flex-60"
>{{ loansAccount.repaymentEvery }}
{{ camalize(loansAccount.repaymentFrequencyType) | translateKey: 'catalogs' }}</span
{{ camalize(repaymentFrequencyTypeOption?.value) | translateKey: 'catalogs' }}</span
>
</div>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { LoanProductBasicDetails } from 'app/loans/models/loan-product.model';
import { LongTextComponent } from 'app/shared/long-text/long-text.component';
import { Breach, NearBreach } from 'app/products/loan-products/models/loan-product.model';
import { BreachDisplayComponent } from 'app/shared/loan/breach-display/breach-display.component';
import { OptionData, StringEnumOptionData } from 'app/shared/models/option-data.model';

/**
* Create Loans Account Preview Step
Expand Down Expand Up @@ -124,11 +125,17 @@ export class LoansAccountPreviewStepComponent extends LoanProductBaseComponent i
dataSource: any;
productEnableDownPayment = false;

repaymentFrequencyTypeOption: OptionData | null = null;
delinquencyStartTypeOption: StringEnumOptionData | null = null;

constructor() {
super();
}

ngOnChanges(changes: SimpleChanges): void {
if (!this.loansAccountProductTemplate?.product) {
return;
}
Comment thread
alberto-art3ch marked this conversation as resolved.
this.productEnableDownPayment = this.loansAccountProductTemplate.product.enableDownPayment;
if (this.activeClientMembers) {
this.loanPurposeOptions = this.loansAccountProductTemplate.loanPurposeOptions;
Expand All @@ -144,6 +151,30 @@ export class LoansAccountPreviewStepComponent extends LoanProductBaseComponent i
.filter((member: any) => member.selected)
.reduce((acc: number, member: any) => acc + (member.principal ?? 0), 0);
}
if (this.loanProductService.isWorkingCapital) {
const options = this.loansAccountProductTemplate.options ?? {};
this.repaymentFrequencyTypeOption = this.optionDataLookUp(
this.loansAccount?.repaymentFrequencyType,
options.periodFrequencyTypeOptions ?? []
);
this.delinquencyStartTypeOption = this.stringEnumOptionDataLookUp(
this.loansAccount?.delinquencyStartType,
options.delinquencyStartTypeOptions ?? []
);
} else {
this.repaymentFrequencyTypeOption = null;
this.delinquencyStartTypeOption = null;
}
}

private optionDataLookUp(itemId: any, optionsData: any[]): OptionData | null {
const match = optionsData.find((o: any) => o.id === itemId);
return match ? { id: match.id, code: match.code, value: match.value || match.name } : null;
}

private stringEnumOptionDataLookUp(itemId: any, optionsData: any[]): StringEnumOptionData | null {
const match = optionsData.find((o: any) => o.id === itemId || o.code === itemId);
return match ? { id: match.id, code: match.code, value: match.value } : null;
}

loanProductName(id: number): string {
Expand All @@ -164,7 +195,10 @@ export class LoansAccountPreviewStepComponent extends LoanProductBaseComponent i
return fund ? fund.name : '';
}

camalize(word: string) {
camalize(word: unknown): string {
if (typeof word !== 'string' || word.length === 0) {
return '';
}
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
}

Expand Down
Loading