Skip to content

Commit

Permalink
Advanced accounting - Charge-off reason mapping fix
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsaghy committed Dec 19, 2024
1 parent f693318 commit bf1d99f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1117,16 +1117,16 @@ <h4 class="mat-h4" fxFlexFill>
<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.chargeOffReasonCodeValue.name }}
<td mat-cell *matCellDef="let chargeOffReasonToExpenseAccountMapping">
{{ chargeOffReasonToExpenseAccountMapping.chargeOffReasonCodeValue.name }}
</td>
</ng-container>

<ng-container matColumnDef="expenseGLAccountId">
<ng-container matColumnDef="expenseAccountId">
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Expense Account' | translate }}</th>
<td mat-cell *matCellDef="let chargeOffReasonsToExpenseMapping">
({{ chargeOffReasonsToExpenseMapping.chargeOffExpenseAccount.glCode }})
{{ chargeOffReasonsToExpenseMapping.chargeOffExpenseAccount.name }}
<td mat-cell *matCellDef="let chargeOffReasonToExpenseAccountMapping">
({{ chargeOffReasonToExpenseAccountMapping.expenseAccount.glCode }})
{{ chargeOffReasonToExpenseAccountMapping.expenseAccount.name }}
</td>
</ng-container>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';
import { DelinquencyBucket, LoanProduct } from '../../models/loan-product.model';
import {AccountingMapping, Charge, ChargeOffReasonToExpenseAccountMapping, ChargeToIncomeAccountMapping, GLAccount, PaymentChannelToFundSourceMapping, PaymentType, PaymentTypeOption} from '../../../../shared/models/general.model';
import {
AccountingMapping,
Charge,
ChargeOffReasonCodeValue,
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 All @@ -25,7 +35,7 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
chargesDisplayedColumns: string[] = ['name', 'chargeCalculationType', 'amount', 'chargeTimeType'];
paymentFundSourceDisplayedColumns: string[] = ['paymentTypeId', 'fundSourceAccountId'];
feesPenaltyIncomeDisplayedColumns: string[] = ['chargeId', 'incomeAccountId'];
chargeOffReasonExpenseDisplayedColumns: string[] = ['chargeOffReasonCodeValueId', 'expenseGLAccountId'];
chargeOffReasonExpenseDisplayedColumns: string[] = ['chargeOffReasonCodeValueId', 'expenseAccountId'];
accountingRuleData: string[] = [];

isAdvancedPaymentAllocation = false;
Expand Down Expand Up @@ -76,6 +86,7 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
const expenseAccountData = this.loanProductsTemplate.accountingMappingOptions.expenseAccountOptions || [];
const liabilityAccountData = this.loanProductsTemplate.accountingMappingOptions.liabilityAccountOptions || [];
const assetAndLiabilityAccountData = this.loanProductsTemplate.accountingMappingOptions.assetAndLiabilityAccountOptions || [];
const chargeOffReasonOptions: any = this.loanProductsTemplate.chargeOffReasonOptions || [];

this.accountingMappings = {
'fundSourceAccount': this.glAccountLookUp(this.loanProduct.fundSourceAccountId, assetAndLiabilityAccountData),
Expand Down Expand Up @@ -135,7 +146,14 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
this.chargeOffReasonToExpenseAccountMappings = [];
if (this.loanProduct.chargeOffReasonToExpenseAccountMappings?.length > 0) {
this.loanProduct.chargeOffReasonToExpenseAccountMappings.forEach((m: ChargeOffReasonToExpenseAccountMapping) => {
this.chargeOffReasonToExpenseAccountMappings.push(m);
let optionData = this.optionDataLookUp(m.chargeOffReasonCodeValueId, chargeOffReasonOptions);
this.chargeOffReasonToExpenseAccountMappings.push({
expenseAccount: this.glAccountLookUp(m.expenseAccountId, expenseAccountData),
chargeOffReasonCodeValue: {
id: optionData.id,
name: optionData.value
} as ChargeOffReasonCodeValue
});
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,24 +444,21 @@ <h4 fxFlex="33%" class="mat-h4">
>
<ng-container matColumnDef="chargeOffReasonCodeValueId">
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Charge-off reason' | translate }}</th>
<td mat-cell *matCellDef="let chargeOffReasonsToExpenseMapping">
{{
chargeOffReasonsToExpenseMapping.chargeOffReasonCodeValueId
| find: chargeOffReasonOptions : 'id' : 'name'
}}
<td mat-cell *matCellDef="let chargeOffReasonExpense">
{{ chargeOffReasonExpense.chargeOffReasonCodeValueId | find: chargeOffReasonOptions : 'id' : 'name' }}
</td>
</ng-container>

<ng-container matColumnDef="expenseGLAccountId">
<ng-container matColumnDef="expenseAccountId">
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Expense Account' | translate }}</th>
<td mat-cell *matCellDef="let chargeOffReasonsToExpenseMapping">
{{ chargeOffReasonsToExpenseMapping.expenseGLAccountId | find: expenseAccountData : 'id' : 'name' }}
<td mat-cell *matCellDef="let chargeOffReasonExpense">
{{ chargeOffReasonExpense.expenseAccountId | find: expenseAccountData : 'id' : 'name' }}
</td>
</ng-container>

<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Actions' | translate }}</th>
<td mat-cell *matCellDef="let chargeOffReasonsToExpenseMapping; let i = index">
<td mat-cell *matCellDef="let chargeOffReasonExpense; let i = index">
<button
mat-icon-button
color="primary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class LoanProductAccountingStepComponent implements OnInit {

paymentFundSourceDisplayedColumns: string[] = ['paymentTypeId', 'fundSourceAccountId', 'actions'];
feesPenaltyIncomeDisplayedColumns: string[] = ['chargeId', 'incomeAccountId', 'actions'];
chargeOffReasonExpenseDisplayedColumns: string[] = ['chargeOffReasonCodeValueId', 'expenseGLAccountId', 'actions'];
chargeOffReasonExpenseDisplayedColumns: string[] = ['chargeOffReasonCodeValueId', 'expenseAccountId', 'actions'];

constructor(private formBuilder: UntypedFormBuilder,
public dialog: MatDialog,
Expand Down Expand Up @@ -108,7 +108,7 @@ export class LoanProductAccountingStepComponent implements OnInit {
({ chargeId: penaltyIncome.charge.id, incomeAccountId: penaltyIncome.incomeAccount.id }))));
this.loanProductAccountingForm.setControl('chargeOffReasonToExpenseAccountMappings',
this.formBuilder.array((this.loanProductsTemplate.chargeOffReasonToExpenseAccountMappings || []).map((m: ChargeOffReasonToExpenseAccountMapping) =>
({ chargeOffReasonCodeValueId: m.chargeOffReasonCodeValue.id, expenseGLAccountId: m.chargeOffExpenseAccount.id }))));
({ chargeOffReasonCodeValueId: m.chargeOffReasonCodeValue.id, expenseAccountId: m.expenseAccount.id }))));
}
}

Expand All @@ -134,7 +134,7 @@ export class LoanProductAccountingStepComponent implements OnInit {
this.loanProductAccountingForm.addControl('overpaymentLiabilityAccountId', new UntypedFormControl('', Validators.required));
this.loanProductAccountingForm.addControl('advancedAccountingRules', new UntypedFormControl(false));
this.loanProductAccountingForm.addControl('chargeOffFraudExpenseAccountId', new UntypedFormControl('', Validators.required));
this.loanProductAccountingForm.addControl('chargeOffExpenseAccountId', new UntypedFormControl('', Validators.required));
this.loanProductAccountingForm.addControl('expenseAccountId', new UntypedFormControl('', Validators.required));
this.loanProductAccountingForm.addControl('incomeFromChargeOffPenaltyAccountId', new UntypedFormControl('', Validators.required));
this.loanProductAccountingForm.addControl('incomeFromChargeOffFeesAccountId', new UntypedFormControl('', Validators.required));
this.loanProductAccountingForm.addControl('incomeFromChargeOffInterestAccountId', new UntypedFormControl('', Validators.required));
Expand Down Expand Up @@ -168,7 +168,7 @@ export class LoanProductAccountingStepComponent implements OnInit {
this.loanProductAccountingForm.removeControl('goodwillCreditAccountId');
this.loanProductAccountingForm.removeControl('overpaymentLiabilityAccountId');
this.loanProductAccountingForm.removeControl('advancedAccountingRules');
this.loanProductAccountingForm.removeControl('chargeOffExpenseAccountId');
this.loanProductAccountingForm.removeControl('expenseAccountId');
this.loanProductAccountingForm.removeControl('chargeOffFraudExpenseAccountId');
this.loanProductAccountingForm.removeControl('incomeFromChargeOffPenaltyAccountId');
this.loanProductAccountingForm.removeControl('incomeFromChargeOffFeesAccountId');
Expand Down Expand Up @@ -334,9 +334,9 @@ export class LoanProductAccountingStepComponent implements OnInit {
order: 1
}),
new SelectBase({
controlName: 'expenseGLAccountId',
controlName: 'expenseAccountId',
label: 'Expense Account',
value: values ? values.expenseGLAccountId : this.expenseAccountData[0].id,
value: values ? values.expenseAccountId : this.expenseAccountData[0].id,
options: { label: 'name', value: 'id', data: this.expenseAccountData },
required: true,
order: 2
Expand Down
4 changes: 2 additions & 2 deletions src/app/shared/models/general.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ export interface PaymentChannelToFundSourceMapping {

export interface ChargeOffReasonToExpenseAccountMapping {
chargeOffReasonCodeValueId?: number;
chargeOffReason? : OptionData;
expenseAccountId? : number;
chargeOffReasonCodeValue?: ChargeOffReasonCodeValue;
chargeOffExpenseAccount?: AccountingMapping;
expenseAccount?: AccountingMapping;
}

export interface ChargeOffReasonCodeValue {
Expand Down

0 comments on commit bf1d99f

Please sign in to comment.