1
1
import { 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' ;
3
3
import {
4
4
AccountingMapping ,
5
5
Charge ,
6
- ChargeOffReasonCodeValue ,
6
+ CodeValue ,
7
7
ChargeOffReasonToExpenseAccountMapping ,
8
8
ChargeToIncomeAccountMapping ,
9
+ ClassificationToIncomeAccountMapping ,
9
10
GLAccount ,
10
11
PaymentChannelToFundSourceMapping ,
11
12
PaymentType ,
@@ -114,6 +115,8 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
114
115
feeToIncomeAccountMappings : ChargeToIncomeAccountMapping [ ] = [ ] ;
115
116
penaltyToIncomeAccountMappings : ChargeToIncomeAccountMapping [ ] = [ ] ;
116
117
chargeOffReasonToExpenseAccountMappings : ChargeOffReasonToExpenseAccountMapping [ ] = [ ] ;
118
+ buydownFeeClassificationToIncomeAccountMappings : ClassificationToIncomeAccountMapping [ ] = [ ] ;
119
+ capitalizedIncomeClassificationToIncomeAccountMappings : ClassificationToIncomeAccountMapping [ ] = [ ] ;
117
120
118
121
constructor ( private accounting : Accounting ) { }
119
122
@@ -145,6 +148,10 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
145
148
this . feeToIncomeAccountMappings = this . loanProduct . feeToIncomeAccountMappings || [ ] ;
146
149
this . penaltyToIncomeAccountMappings = this . loanProduct . penaltyToIncomeAccountMappings || [ ] ;
147
150
this . chargeOffReasonToExpenseAccountMappings = this . loanProduct . chargeOffReasonToExpenseAccountMappings || [ ] ;
151
+ this . buydownFeeClassificationToIncomeAccountMappings =
152
+ this . loanProduct . buydownFeeClassificationToIncomeAccountMappings || [ ] ;
153
+ this . capitalizedIncomeClassificationToIncomeAccountMappings =
154
+ this . loanProduct . capitalizedIncomeClassificationToIncomeAccountMappings || [ ] ;
148
155
} else {
149
156
this . accountingMappings = { } ;
150
157
@@ -159,6 +166,9 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
159
166
const assetAndLiabilityAccountData =
160
167
this . loanProductsTemplate . accountingMappingOptions . assetAndLiabilityAccountOptions || [ ] ;
161
168
const chargeOffReasonOptions : any = this . loanProductsTemplate . chargeOffReasonOptions || [ ] ;
169
+ const buydownFeeClassificationOptions : any = this . loanProductsTemplate . buydownFeeClassificationOptions || [ ] ;
170
+ const capitalizedIncomeClassificationOptions : any =
171
+ this . loanProductsTemplate . capitalizedIncomeClassificationOptions || [ ] ;
162
172
163
173
this . accountingMappings = {
164
174
fundSourceAccount : this . glAccountLookUp ( this . loanProduct . fundSourceAccountId , assetAndLiabilityAccountData ) ,
@@ -262,11 +272,42 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
262
272
chargeOffReasonCodeValue : {
263
273
id : optionData . id ,
264
274
name : optionData . value
265
- } as ChargeOffReasonCodeValue
275
+ } as CodeValue
266
276
} ) ;
267
277
}
268
278
) ;
269
279
}
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
+ }
270
311
}
271
312
272
313
if ( this . loanProduct . isInterestRecalculationEnabled ) {
@@ -453,7 +494,7 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
453
494
}
454
495
455
496
optionDataLookUp ( itemId : any , optionsData : any [ ] ) : OptionData {
456
- let optionData : OptionData | null ;
497
+ let optionData : OptionData | null = null ;
457
498
optionsData . some ( ( o : any ) => {
458
499
if ( o . id === itemId ) {
459
500
optionData = {
@@ -576,7 +617,9 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges {
576
617
this . loanProduct . paymentChannelToFundSourceMappings ?. length > 0 ||
577
618
this . loanProduct . feeToIncomeAccountMappings ?. length > 0 ||
578
619
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
580
623
) ;
581
624
}
582
625
0 commit comments