@@ -18,12 +18,14 @@ import {
18
18
AdvancedCreditAllocation ,
19
19
AdvancedPaymentAllocation ,
20
20
AdvancedPaymentStrategy ,
21
+ CapitalizedIncome ,
21
22
CreditAllocation ,
22
23
PaymentAllocation
23
24
} from '../loan-product-stepper/loan-product-payment-strategy-step/payment-allocation-model' ;
24
25
import { Accounting } from 'app/core/utils/accounting' ;
25
26
import { LoanProductInterestRefundStepComponent } from '../loan-product-stepper/loan-product-interest-refund-step/loan-product-interest-refund-step.component' ;
26
27
import { StringEnumOptionData } from '../../../shared/models/option-data.model' ;
28
+ import { LoanProductCapitalizedIncomeStepComponent } from '../loan-product-stepper/loan-product-capitalized-income-step/loan-product-capitalized-income-step.component' ;
27
29
28
30
@Component ( {
29
31
selector : 'mifosx-edit-loan-product' ,
@@ -36,6 +38,8 @@ export class EditLoanProductComponent implements OnInit {
36
38
loanProductCurrencyStep : LoanProductCurrencyStepComponent ;
37
39
@ViewChild ( LoanProductInterestRefundStepComponent , { static : true } )
38
40
loanProductInterestRefundStep : LoanProductInterestRefundStepComponent ;
41
+ @ViewChild ( LoanProductCapitalizedIncomeStepComponent , { static : true } )
42
+ loanProductCapitalizedIncomeStep : LoanProductCapitalizedIncomeStepComponent ;
39
43
@ViewChild ( LoanProductTermsStepComponent , { static : true } ) loanProductTermsStep : LoanProductTermsStepComponent ;
40
44
@ViewChild ( LoanProductSettingsStepComponent , { static : true } )
41
45
loanProductSettingsStep : LoanProductSettingsStepComponent ;
@@ -55,6 +59,8 @@ export class EditLoanProductComponent implements OnInit {
55
59
advancedCreditAllocations : AdvancedCreditAllocation [ ] = [ ] ;
56
60
supportedInterestRefundTypes : StringEnumOptionData [ ] = [ ] ;
57
61
62
+ capitalizedIncome : CapitalizedIncome | null = null ;
63
+
58
64
/**
59
65
* @param {ActivatedRoute } route Activated Route.
60
66
* @param {ProductsService } productsService Product Service.
@@ -90,6 +96,17 @@ export class EditLoanProductComponent implements OnInit {
90
96
this . paymentAllocation = this . loanProductAndTemplate . paymentAllocation ;
91
97
this . creditAllocation = this . loanProductAndTemplate . creditAllocation ;
92
98
this . supportedInterestRefundTypes = this . loanProductAndTemplate . supportedInterestRefundTypes ;
99
+ if ( this . loanProductAndTemplate . enableIncomeCapitalization ) {
100
+ this . capitalizedIncome = {
101
+ enableIncomeCapitalization : true ,
102
+ incomeCapitalizationCalculationType : this . loanProductAndTemplate . capitalizedIncomeCalculationType . id ,
103
+ incomeCapitalizationStrategy : this . loanProductAndTemplate . capitalizedIncomeStrategy . id
104
+ } ;
105
+ } else {
106
+ this . capitalizedIncome = {
107
+ enableIncomeCapitalization : false
108
+ } ;
109
+ }
93
110
}
94
111
}
95
112
@@ -115,6 +132,12 @@ export class EditLoanProductComponent implements OnInit {
115
132
}
116
133
}
117
134
135
+ get loanIncomeCapitalizationForm ( ) {
136
+ if ( this . loanProductCapitalizedIncomeStep != null ) {
137
+ return this . loanProductCapitalizedIncomeStep . loanIncomeCapitalizationForm ;
138
+ }
139
+ }
140
+
118
141
advancePaymentStrategy ( value : string ) : void {
119
142
this . isAdvancedPaymentStrategy = LoanProducts . isAdvancedPaymentAllocationStrategy ( value ) ;
120
143
}
@@ -146,6 +169,12 @@ export class EditLoanProductComponent implements OnInit {
146
169
this . wasPaymentAllocationChanged = value ;
147
170
}
148
171
172
+ setCapitalizedIncome ( capitalizedIncome : CapitalizedIncome ) : void {
173
+ if ( this . isAdvancedPaymentStrategy ) {
174
+ this . capitalizedIncome = capitalizedIncome ;
175
+ }
176
+ }
177
+
149
178
get loanProductAccountingForm ( ) {
150
179
return this . loanProductAccountingStep . loanProductAccountingForm ;
151
180
}
@@ -184,6 +213,13 @@ export class EditLoanProductComponent implements OnInit {
184
213
loanProduct [ 'paymentAllocation' ] = this . paymentAllocation ;
185
214
loanProduct [ 'creditAllocation' ] = this . creditAllocation ;
186
215
loanProduct [ 'supportedInterestRefundTypes' ] = this . supportedInterestRefundTypes ;
216
+ if ( this . capitalizedIncome != null ) {
217
+ loanProduct [ 'enableIncomeCapitalization' ] = this . capitalizedIncome . enableIncomeCapitalization ;
218
+ if ( this . capitalizedIncome . enableIncomeCapitalization ) {
219
+ loanProduct [ 'capitalizedIncomeCalculationType' ] = this . capitalizedIncome . incomeCapitalizationCalculationType ;
220
+ loanProduct [ 'capitalizedIncomeStrategy' ] = this . capitalizedIncome . incomeCapitalizationStrategy ;
221
+ }
222
+ }
187
223
}
188
224
return loanProduct ;
189
225
}
0 commit comments