Skip to content

Commit

Permalink
Advanced accounting - Charge-off reason mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsaghy committed Dec 18, 2024
1 parent 69ef977 commit 5d3271d
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -934,17 +934,17 @@ <h4 class="mat-h4" fxFlexFill>{{'labels.heading.Map Penalties to Specific Income

</div>

<div *ngIf="chargeOffReasonsToExpenseMappings.length" fxFlexFill fxLayout="row wrap"
<div *ngIf="chargeOffReasonToExpenseAccountMappings.length" fxFlexFill fxLayout="row wrap"
fxLayout.lt-md="column">

<h4 class="mat-h4" fxFlexFill>{{'labels.heading.Map Charge-off reasons to Expense accounts' | translate}}</h4>

<table fxFlexFill class="mat-elevation-z1" mat-table [dataSource]="chargeOffReasonsToExpenseMappings">
<table fxFlexFill class="mat-elevation-z1" mat-table [dataSource]="chargeOffReasonToExpenseAccountMappings">

<ng-container matColumnDef="chargeOffReasonCodeValueId">
<th mat-header-cell *matHeaderCellDef> {{'labels.inputs.Charge-off reason' | translate}} </th>
<td mat-cell *matCellDef="let chargeOffReasonsToExpenseMapping">
{{ chargeOffReasonsToExpenseMapping.chargeOffReasonsCodeValue.name }}
{{ chargeOffReasonsToExpenseMapping.chargeOffReasonCodeValue.name }}
</td>
</ng-container>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';
import { DelinquencyBucket, LoanProduct } from '../../models/loan-product.model';
import {AccountingMapping, Charge, ChargeOffReasonsToGLAccountMapping, ChargeToIncomeAccountMapping, GLAccount, PaymentChannelToFundSourceMapping, PaymentType, PaymentTypeOption} from '../../../../shared/models/general.model';
import {AccountingMapping, Charge, ChargeOffReasonToExpenseAccountMapping, ChargeToIncomeAccountMapping, GLAccount, PaymentChannelToFundSourceMapping, PaymentType, PaymentTypeOption} from '../../../../shared/models/general.model';
import { AdvancePaymentAllocationData, CreditAllocation, PaymentAllocation } from '../../loan-product-stepper/loan-product-payment-strategy-step/payment-allocation-model';
import { LoanProducts } from '../../loan-products';
import { CodeName, OptionData, StringEnumOptionData } from '../../../../shared/models/option-data.model';
Expand Down Expand Up @@ -36,7 +36,7 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
paymentChannelToFundSourceMappings: PaymentChannelToFundSourceMapping[] = [];
feeToIncomeAccountMappings: ChargeToIncomeAccountMapping[] = [];
penaltyToIncomeAccountMappings: ChargeToIncomeAccountMapping[] = [];
chargeOffReasonsToExpenseMappings: ChargeOffReasonsToGLAccountMapping[] = [];
chargeOffReasonToExpenseAccountMappings: ChargeOffReasonToExpenseAccountMapping[] = [];

constructor(private accounting: Accounting) { }

Expand Down Expand Up @@ -65,7 +65,7 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
this.paymentChannelToFundSourceMappings = this.loanProduct.paymentChannelToFundSourceMappings || [];
this.feeToIncomeAccountMappings = this.loanProduct.feeToIncomeAccountMappings || [];
this.penaltyToIncomeAccountMappings = this.loanProduct.penaltyToIncomeAccountMappings || [];
this.chargeOffReasonsToExpenseMappings = this.loanProduct.chargeOffReasonToGLAccountMappings || [];
this.chargeOffReasonToExpenseAccountMappings = this.loanProduct.chargeOffReasonToExpenseAccountMappings || [];

} else {
this.accountingMappings = {};
Expand Down Expand Up @@ -132,10 +132,10 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
});
}

this.chargeOffReasonsToExpenseMappings = [];
if (this.loanProduct.chargeOffReasonToGLAccountMappings?.length > 0) {
this.loanProduct.chargeOffReasonToGLAccountMappings.forEach((m: ChargeOffReasonsToGLAccountMapping) => {
this.chargeOffReasonsToExpenseMappings.push(m);
this.chargeOffReasonToExpenseAccountMappings = [];
if (this.loanProduct.chargeOffReasonToExpenseAccountMappings?.length > 0) {
this.loanProduct.chargeOffReasonToExpenseAccountMappings.forEach((m: ChargeOffReasonToExpenseAccountMapping) => {
this.chargeOffReasonToExpenseAccountMappings.push(m);
});
}
}
Expand Down Expand Up @@ -355,7 +355,7 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
return (this.loanProduct.paymentChannelToFundSourceMappings?.length > 0
|| this.loanProduct.feeToIncomeAccountMappings?.length > 0
|| this.loanProduct.penaltyToIncomeAccountMappings?.length > 0
|| this.loanProduct.chargeOffReasonToGLAccountMappings?.length > 0);
|| this.loanProduct.chargeOffReasonToExpenseAccountMappings?.length > 0);
}

getAccountingRuleName(value: string): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,12 @@ <h4 fxFlex="33%" class="mat-h4">{{'labels.heading.Map Penalties to Specific Inco
<h4 fxFlex="33%" class="mat-h4">{{'labels.heading.Map Charge-off reasons to Expense accounts' | translate}}</h4>

<div fxFlex="63%">
<button type="button" mat-raised-button color="primary" (click)="add('ChargeOffReasonExpense', chargeOffReasonsToExpenseMappings)">
<button type="button" mat-raised-button color="primary" (click)="add('ChargeOffReasonExpense', chargeOffReasonToExpenseAccountMappings)">
<fa-icon icon="plus" class="m-r-10"></fa-icon>
{{'labels.buttons.Add' | translate}}
</button>
</div>
<table fxFlex="98%" class="mat-elevation-z1" mat-table [dataSource]="chargeOffReasonsToExpenseMappings.value" *ngIf="chargeOffReasonsToExpenseMappings.value.length !== 0">
<table fxFlex="98%" class="mat-elevation-z1" mat-table [dataSource]="chargeOffReasonToExpenseAccountMappings.value" *ngIf="chargeOffReasonToExpenseAccountMappings.value.length !== 0">

<ng-container matColumnDef="chargeOffReasonCodeValueId">
<th mat-header-cell *matHeaderCellDef> {{'labels.inputs.Charge-off reason' | translate}} </th>
Expand All @@ -361,10 +361,10 @@ <h4 fxFlex="33%" class="mat-h4">{{'labels.heading.Map Charge-off reasons to Expe
<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef> {{'labels.inputs.Actions' | translate}} </th>
<td mat-cell *matCellDef="let chargeOffReasonsToExpenseMapping; let i = index">
<button mat-icon-button color="primary" (click)="edit('ChargeOffReasonExpense', chargeOffReasonsToExpenseMappings, i)">
<button mat-icon-button color="primary" (click)="edit('ChargeOffReasonExpense', chargeOffReasonToExpenseAccountMappings, i)">
<fa-icon icon="edit"></fa-icon>
</button>
<button mat-icon-button color="warn" (click)="delete(chargeOffReasonsToExpenseMappings, i)">
<button mat-icon-button color="warn" (click)="delete(chargeOffReasonToExpenseAccountMappings, i)">
<fa-icon icon="trash"></fa-icon>
</button>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.componen
import { TranslateService } from '@ngx-translate/core';
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
import { SelectBase } from 'app/shared/form-dialog/formfield/model/select-base';
import { ChargeOffReasonsToGLAccountMapping } from 'app/shared/models/general.model';
import { ChargeOffReasonToExpenseAccountMapping } from 'app/shared/models/general.model';

@Component({
selector: 'mifosx-loan-product-accounting-step',
Expand Down Expand Up @@ -94,7 +94,7 @@ export class LoanProductAccountingStepComponent implements OnInit {
'incomeFromGoodwillCreditInterestAccountId': accountingMappings.incomeFromGoodwillCreditInterestAccount ? accountingMappings.incomeFromGoodwillCreditInterestAccount.id : '',
'incomeFromGoodwillCreditFeesAccountId': accountingMappings.incomeFromGoodwillCreditFeesAccount ? accountingMappings.incomeFromGoodwillCreditFeesAccount.id : '',
'incomeFromGoodwillCreditPenaltyAccountId': accountingMappings.incomeFromGoodwillCreditPenaltyAccount ? accountingMappings.incomeFromGoodwillCreditPenaltyAccount.id : '',
'advancedAccountingRules': (this.loanProductsTemplate.paymentChannelToFundSourceMappings || this.loanProductsTemplate.feeToIncomeAccountMappings || this.loanProductsTemplate.penaltyToIncomeAccountMappings || this.loanProductsTemplate.chargeOffReasonsToExpenseMappings) ? true : false
'advancedAccountingRules': (this.loanProductsTemplate.paymentChannelToFundSourceMappings || this.loanProductsTemplate.feeToIncomeAccountMappings || this.loanProductsTemplate.penaltyToIncomeAccountMappings || this.loanProductsTemplate.chargeOffReasonToExpenseAccountMappings) ? true : false
});

this.loanProductAccountingForm.setControl('paymentChannelToFundSourceMappings',
Expand All @@ -106,9 +106,9 @@ export class LoanProductAccountingStepComponent implements OnInit {
this.loanProductAccountingForm.setControl('penaltyToIncomeAccountMappings',
this.formBuilder.array((this.loanProductsTemplate.penaltyToIncomeAccountMappings || []).map((penaltyIncome: any) =>
({ chargeId: penaltyIncome.charge.id, incomeAccountId: penaltyIncome.incomeAccount.id }))));
this.loanProductAccountingForm.setControl('chargeOffReasonsToExpenseMappings',
this.formBuilder.array((this.loanProductsTemplate.chargeOffReasonToGLAccountMappings || []).map((m: ChargeOffReasonsToGLAccountMapping) =>
({ chargeOffReasonCodeValueId: m.chargeOffReasonsCodeValue.id, expenseGLAccountId: m.chargeOffExpenseAccount.id }))));
this.loanProductAccountingForm.setControl('chargeOffReasonToExpenseAccountMappings',
this.formBuilder.array((this.loanProductsTemplate.chargeOffReasonToExpenseAccountMappings || []).map((m: ChargeOffReasonToExpenseAccountMapping) =>
({ chargeOffReasonCodeValueId: m.chargeOffReasonCodeValue.id, expenseGLAccountId: m.chargeOffExpenseAccount.id }))));
}
}

Expand Down Expand Up @@ -148,12 +148,12 @@ export class LoanProductAccountingStepComponent implements OnInit {
this.loanProductAccountingForm.addControl('paymentChannelToFundSourceMappings', this.formBuilder.array([]));
this.loanProductAccountingForm.addControl('feeToIncomeAccountMappings', this.formBuilder.array([]));
this.loanProductAccountingForm.addControl('penaltyToIncomeAccountMappings', this.formBuilder.array([]));
this.loanProductAccountingForm.addControl('chargeOffReasonsToExpenseMappings', this.formBuilder.array([]));
this.loanProductAccountingForm.addControl('chargeOffReasonToExpenseAccountMappings', this.formBuilder.array([]));
} else {
this.loanProductAccountingForm.removeControl('paymentChannelToFundSourceMappings');
this.loanProductAccountingForm.removeControl('feeToIncomeAccountMappings');
this.loanProductAccountingForm.removeControl('penaltyToIncomeAccountMappings');
this.loanProductAccountingForm.removeControl('chargeOffReasonsToExpenseMappings');
this.loanProductAccountingForm.removeControl('chargeOffReasonToExpenseAccountMappings');
}
});
} else {
Expand Down Expand Up @@ -204,8 +204,8 @@ export class LoanProductAccountingStepComponent implements OnInit {
return this.loanProductAccountingForm.get('penaltyToIncomeAccountMappings') as UntypedFormArray;
}

get chargeOffReasonsToExpenseMappings(): UntypedFormArray {
return this.loanProductAccountingForm.get('chargeOffReasonsToExpenseMappings') as UntypedFormArray;
get chargeOffReasonToExpenseAccountMappings(): UntypedFormArray {
return this.loanProductAccountingForm.get('chargeOffReasonToExpenseAccountMappings') as UntypedFormArray;
}

setLoanProductAccountingFormDirty() {
Expand Down
4 changes: 2 additions & 2 deletions src/app/products/loan-products/models/loan-product.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {AccountingMapping, ChargeOffReasonsToGLAccountMapping, ChargeToIncomeAccountMapping, Currency, PaymentChannelToFundSourceMapping} from 'app/shared/models/general.model';
import {AccountingMapping, ChargeOffReasonToExpenseAccountMapping, ChargeToIncomeAccountMapping, Currency, PaymentChannelToFundSourceMapping} from 'app/shared/models/general.model';
import { OptionData, StringEnumOptionData } from 'app/shared/models/option-data.model';
import { CreditAllocation, PaymentAllocation } from '../loan-product-stepper/loan-product-payment-strategy-step/payment-allocation-model';

Expand Down Expand Up @@ -125,7 +125,7 @@ export interface LoanProduct {
paymentChannelToFundSourceMappings?: PaymentChannelToFundSourceMapping[];
feeToIncomeAccountMappings?: ChargeToIncomeAccountMapping[];
penaltyToIncomeAccountMappings?: ChargeToIncomeAccountMapping[];
chargeOffReasonToGLAccountMappings?: ChargeOffReasonsToGLAccountMapping[];
chargeOffReasonToExpenseAccountMappings?: ChargeOffReasonToExpenseAccountMapping[];
enableAccrualActivityPosting?: boolean;
supportedInterestRefundTypes?: StringEnumOptionData[];
chargeOffBehaviour?: StringEnumOptionData;
Expand Down
6 changes: 3 additions & 3 deletions src/app/shared/models/general.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ export interface PaymentChannelToFundSourceMapping {
fundSourceAccount: AccountingMapping;
}

export interface ChargeOffReasonsToGLAccountMapping {
export interface ChargeOffReasonToExpenseAccountMapping {
chargeOffReasonCodeValueId?: number;
chargeOffReason? : OptionData;
chargeOffReasonsCodeValue?: ChargeOffReasonsCodeValue;
chargeOffReasonCodeValue?: ChargeOffReasonCodeValue;
chargeOffExpenseAccount?: AccountingMapping;
}

export interface ChargeOffReasonsCodeValue {
export interface ChargeOffReasonCodeValue {
active: boolean;
description: string;
id: number;
Expand Down

0 comments on commit 5d3271d

Please sign in to comment.