11import { Component , Input , OnChanges , OnInit , SimpleChanges } from '@angular/core' ;
2- import { DelinquencyBucket , LoanProduct } from '../../models/loan-product.model' ;
2+ import { AccountingMappingDTO , DelinquencyBucket , LoanProduct } from '../../models/loan-product.model' ;
33import {
44 AccountingMapping ,
55 Charge ,
6- ChargeOffReasonCodeValue ,
6+ CodeValue ,
77 ChargeOffReasonToExpenseAccountMapping ,
88 ChargeToIncomeAccountMapping ,
9+ ClassificationToIncomeAccountMapping ,
910 GLAccount ,
1011 PaymentChannelToFundSourceMapping ,
1112 PaymentType ,
@@ -114,6 +115,8 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
114115 feeToIncomeAccountMappings : ChargeToIncomeAccountMapping [ ] = [ ] ;
115116 penaltyToIncomeAccountMappings : ChargeToIncomeAccountMapping [ ] = [ ] ;
116117 chargeOffReasonToExpenseAccountMappings : ChargeOffReasonToExpenseAccountMapping [ ] = [ ] ;
118+ buydownFeeClassificationToIncomeAccountMappings : ClassificationToIncomeAccountMapping [ ] = [ ] ;
119+ capitalizedIncomeClassificationToIncomeAccountMappings : ClassificationToIncomeAccountMapping [ ] = [ ] ;
117120
118121 constructor ( private accounting : Accounting ) { }
119122
@@ -145,6 +148,10 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
145148 this . feeToIncomeAccountMappings = this . loanProduct . feeToIncomeAccountMappings || [ ] ;
146149 this . penaltyToIncomeAccountMappings = this . loanProduct . penaltyToIncomeAccountMappings || [ ] ;
147150 this . chargeOffReasonToExpenseAccountMappings = this . loanProduct . chargeOffReasonToExpenseAccountMappings || [ ] ;
151+ this . buydownFeeClassificationToIncomeAccountMappings =
152+ this . loanProduct . buydownFeeClassificationToIncomeAccountMappings || [ ] ;
153+ this . capitalizedIncomeClassificationToIncomeAccountMappings =
154+ this . loanProduct . capitalizedIncomeClassificationToIncomeAccountMappings || [ ] ;
148155 } else {
149156 this . accountingMappings = { } ;
150157
@@ -159,6 +166,9 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
159166 const assetAndLiabilityAccountData =
160167 this . loanProductsTemplate . accountingMappingOptions . assetAndLiabilityAccountOptions || [ ] ;
161168 const chargeOffReasonOptions : any = this . loanProductsTemplate . chargeOffReasonOptions || [ ] ;
169+ const buydownFeeClassificationOptions : any = this . loanProductsTemplate . buydownFeeClassificationOptions || [ ] ;
170+ const capitalizedIncomeClassificationOptions : any =
171+ this . loanProductsTemplate . capitalizedIncomeClassificationOptions || [ ] ;
162172
163173 this . accountingMappings = {
164174 fundSourceAccount : this . glAccountLookUp ( this . loanProduct . fundSourceAccountId , assetAndLiabilityAccountData ) ,
@@ -262,11 +272,42 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
262272 chargeOffReasonCodeValue : {
263273 id : optionData . id ,
264274 name : optionData . value
265- } as ChargeOffReasonCodeValue
275+ } as CodeValue
266276 } ) ;
267277 }
268278 ) ;
269279 }
280+
281+ this . buydownFeeClassificationToIncomeAccountMappings = [ ] ;
282+ if ( this . loanProduct . buydownFeeClassificationToIncomeAccountMappings ?. length > 0 ) {
283+ this . loanProduct . buydownFeeClassificationToIncomeAccountMappings . forEach ( ( m : any ) => {
284+ let optionData = this . optionDataLookUp ( m . classificationCodeValueId , buydownFeeClassificationOptions ) ;
285+ if ( optionData !== null ) {
286+ this . buydownFeeClassificationToIncomeAccountMappings . push ( {
287+ incomeAccount : this . glAccountLookUp ( m . incomeAccountId , incomeAccountData ) ,
288+ classificationCodeValue : {
289+ id : optionData . id ,
290+ name : optionData . value
291+ } as CodeValue
292+ } ) ;
293+ }
294+ } ) ;
295+ }
296+ this . capitalizedIncomeClassificationToIncomeAccountMappings = [ ] ;
297+ if ( this . loanProduct . capitalizedIncomeClassificationToIncomeAccountMappings ?. length > 0 ) {
298+ this . loanProduct . capitalizedIncomeClassificationToIncomeAccountMappings . forEach ( ( m : any ) => {
299+ let optionData = this . optionDataLookUp ( m . classificationCodeValueId , capitalizedIncomeClassificationOptions ) ;
300+ if ( optionData !== null ) {
301+ this . capitalizedIncomeClassificationToIncomeAccountMappings . push ( {
302+ incomeAccount : this . glAccountLookUp ( m . incomeAccountId , incomeAccountData ) ,
303+ classificationCodeValue : {
304+ id : optionData . id ,
305+ name : optionData . value
306+ } as CodeValue
307+ } ) ;
308+ }
309+ } ) ;
310+ }
270311 }
271312
272313 if ( this . loanProduct . isInterestRecalculationEnabled ) {
@@ -453,7 +494,7 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
453494 }
454495
455496 optionDataLookUp ( itemId : any , optionsData : any [ ] ) : OptionData {
456- let optionData : OptionData | null ;
497+ let optionData : OptionData | null = null ;
457498 optionsData . some ( ( o : any ) => {
458499 if ( o . id === itemId ) {
459500 optionData = {
@@ -576,7 +617,9 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
576617 this . loanProduct . paymentChannelToFundSourceMappings ?. length > 0 ||
577618 this . loanProduct . feeToIncomeAccountMappings ?. length > 0 ||
578619 this . loanProduct . penaltyToIncomeAccountMappings ?. length > 0 ||
579- this . loanProduct . chargeOffReasonToExpenseAccountMappings ?. length > 0
620+ this . loanProduct . chargeOffReasonToExpenseAccountMappings ?. length > 0 ||
621+ this . loanProduct . buydownFeeClassificationToIncomeAccountMappings ?. length > 0 ||
622+ this . loanProduct . capitalizedIncomeClassificationToIncomeAccountMappings ?. length > 0
580623 ) ;
581624 }
582625
0 commit comments