Skip to content

Commit

Permalink
fix: Loan product charge-off reasons accounting mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Alberto Hernandez authored and alberto-art3ch committed Jan 7, 2025
1 parent d04890f commit c9ff143
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
optionData = {
id: o.id,
code: o.code,
value: o.value
value: o.value || o.name
};
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,12 @@ export class EditLoanProductComponent implements OnInit {
private advancedPaymentStrategy: AdvancedPaymentStrategy) {
this.route.data.subscribe((data: { loanProductAndTemplate: any, configurations: any }) => {
this.loanProductAndTemplate = data.loanProductAndTemplate;
console.log(this.loanProductAndTemplate);
const assetAccountData = this.loanProductAndTemplate.accountingMappingOptions.assetAccountOptions || [];
const liabilityAccountData = this.loanProductAndTemplate.accountingMappingOptions.liabilityAccountOptions || [];
this.loanProductAndTemplate.accountingMappingOptions.assetAndLiabilityAccountOptions = assetAccountData.concat(liabilityAccountData);

this.itemsByDefault = loanProducts.setItemsByDefault(data.configurations);
this.loanProductAndTemplate['itemsByDefault'] = this.itemsByDefault;
// this.loanProductAndTemplate = loanProducts.updateLoanProductDefaults(this.loanProductAndTemplate, true);

console.log(this.loanProductAndTemplate);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ <h4 fxFlex="33%" class="mat-h4">
>
<fa-icon icon="edit"></fa-icon>
</button>
<button mat-icon-button color="warn" (click)="delete(paymentChannelToFundSourceMappings, i)">
<button mat-icon-button color="warn" (click)="delete('PaymentFundSource', paymentChannelToFundSourceMappings, i)">
<fa-icon icon="trash"></fa-icon>
</button>
</td>
Expand Down Expand Up @@ -353,7 +353,7 @@ <h4 fxFlex="33%" class="mat-h4">{{ 'labels.heading.Map Fees to Specific Income A
<button mat-icon-button color="primary" (click)="edit('FeesIncome', feeToIncomeAccountMappings, i)">
<fa-icon icon="edit"></fa-icon>
</button>
<button mat-icon-button color="warn" (click)="delete(feeToIncomeAccountMappings, i)">
<button mat-icon-button color="warn" (click)="delete('FeesIncome', feeToIncomeAccountMappings, i)">
<fa-icon icon="trash"></fa-icon>
</button>
</td>
Expand Down Expand Up @@ -410,7 +410,7 @@ <h4 fxFlex="33%" class="mat-h4">
>
<fa-icon icon="edit"></fa-icon>
</button>
<button mat-icon-button color="warn" (click)="delete(penaltyToIncomeAccountMappings, i)">
<button mat-icon-button color="warn" (click)="delete('PenaltyIncome', penaltyToIncomeAccountMappings, i)">
<fa-icon icon="trash"></fa-icon>
</button>
</td>
Expand All @@ -429,6 +429,7 @@ <h4 fxFlex="33%" class="mat-h4">
type="button"
mat-raised-button
color="primary"
[disabled]="!allowAddChargeOffReasonExpense"
(click)="add('ChargeOffReasonExpense', chargeOffReasonToExpenseAccountMappings)"
>
<fa-icon icon="plus" class="m-r-10"></fa-icon>
Expand Down Expand Up @@ -466,7 +467,7 @@ <h4 fxFlex="33%" class="mat-h4">
>
<fa-icon icon="edit"></fa-icon>
</button>
<button mat-icon-button color="warn" (click)="delete(chargeOffReasonToExpenseAccountMappings, i)">
<button mat-icon-button color="warn" (click)="delete('ChargeOffReasonExpense', chargeOffReasonToExpenseAccountMappings, i)">
<fa-icon icon="trash"></fa-icon>
</button>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export class LoanProductAccountingStepComponent implements OnInit {
assetAndLiabilityAccountData: any;
chargeOffReasonOptions: any;

currentFormValues: any[] = [];
allowAddChargeOffReasonExpense = true;

paymentFundSourceDisplayedColumns: string[] = ['paymentTypeId', 'fundSourceAccountId', 'actions'];
feesPenaltyIncomeDisplayedColumns: string[] = ['chargeId', 'incomeAccountId', 'actions'];
chargeOffReasonExpenseDisplayedColumns: string[] = ['chargeOffReasonCodeValueId', 'expenseAccountId', 'actions'];
Expand Down Expand Up @@ -215,11 +218,24 @@ export class LoanProductAccountingStepComponent implements OnInit {
}

add(formType: string, formArray: UntypedFormArray) {
this.currentFormValues = [];
if (formType == 'ChargeOffReasonExpense') {
this.allowAddChargeOffReasonExpense = true;
formArray.value.forEach((item: any) => this.currentFormValues.push(item.chargeOffReasonCodeValueId));
if (this.chargeOffReasonOptions.length == this.currentFormValues.length) {
this.allowAddChargeOffReasonExpense = false;
return;
}
}
const data = { ...this.getData(formType), pristine: false };
const dialogRef = this.dialog.open(FormDialogComponent, { data });
dialogRef.afterClosed().subscribe((response: any) => {
if (response.data) {
formArray.push(response.data);
if (formType == 'ChargeOffReasonExpense') {
this.allowAddChargeOffReasonExpense = (formArray.value.length < this.chargeOffReasonOptions.length);
}

this.setLoanProductAccountingFormDirty();
}
});
Expand All @@ -236,13 +252,16 @@ export class LoanProductAccountingStepComponent implements OnInit {
});
}

delete(formArray: UntypedFormArray, index: number) {
delete(formType: string, formArray: UntypedFormArray, index: number) {
const dialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: this.translateService.instant('labels.text.this') }
});
dialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
formArray.removeAt(index);
if (formType == 'ChargeOffReasonExpense') {
this.allowAddChargeOffReasonExpense = (formArray.value.length < this.chargeOffReasonOptions.length);
}
this.setLoanProductAccountingFormDirty();
}
});
Expand Down Expand Up @@ -324,12 +343,13 @@ export class LoanProductAccountingStepComponent implements OnInit {
}

getChargeOffReasonExpenseFormfields(values?: any) {
const reasonOptions = this.chargeOffReasonOptions.filter((item: any) => !this.currentFormValues.includes(item.id));
const formfields: FormfieldBase[] = [
new SelectBase({
controlName: 'chargeOffReasonCodeValueId',
label: 'Charge-off reason',
value: values ? values.chargeOffReasonCodeValueId : this.chargeOffReasonOptions[0].id,
options: { label: 'name', value: 'id', data: this.chargeOffReasonOptions },
value: values ? values.chargeOffReasonCodeValueId : reasonOptions[0].id,
options: { label: 'name', value: 'id', data: reasonOptions },
required: true,
order: 1
}),
Expand Down
8 changes: 4 additions & 4 deletions src/assets/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
window["env"] = window["env"] || {};

// BackEnd Environment variables
window["env"]["fineractApiUrls"] = 'https://ps-test.dev.alluvial.cloud';
window["env"]["fineractApiUrl"] = 'https://ps-test.dev.alluvial.cloud';
window["env"]["fineractApiUrls"] = '';
window["env"]["fineractApiUrl"] = '';

window["env"]["apiProvider"] = '';
window["env"]["apiVersion"] = '';

window["env"]["fineractPlatformTenantId"] = 'pstest';
window["env"]["fineractPlatformTenantIds"] = 'pstest';
window["env"]["fineractPlatformTenantId"] = '';
window["env"]["fineractPlatformTenantIds"] = '';

// Language Environment variables
window["env"]["defaultLanguage"] = '';
Expand Down

0 comments on commit c9ff143

Please sign in to comment.