@@ -12,12 +12,8 @@ import {
1212 MatTableDataSource ,
1313 MatTable ,
1414 MatColumnDef ,
15- MatHeaderCellDef ,
16- MatHeaderCell ,
1715 MatCellDef ,
1816 MatCell ,
19- MatHeaderRowDef ,
20- MatHeaderRow ,
2117 MatRowDef ,
2218 MatRow
2319} from '@angular/material/table' ;
@@ -28,6 +24,7 @@ import { FormatNumberPipe } from '../../../pipes/format-number.pipe';
2824import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module' ;
2925import { LoanProductService } from 'app/products/loan-products/services/loan-product.service' ;
3026import { LoanProductBaseComponent } from 'app/products/loan-products/common/loan-product-base.component' ;
27+ import { LoanSummaryBalanceComponentComponent } from './loan-summary-balance-component/loan-summary-balance-component.component' ;
3128
3229@Component ( {
3330 selector : 'mifosx-general-tab' ,
@@ -37,58 +34,34 @@ import { LoanProductBaseComponent } from 'app/products/loan-products/common/loan
3734 ...STANDALONE_SHARED_IMPORTS ,
3835 MatTable ,
3936 MatColumnDef ,
40- MatHeaderCellDef ,
41- MatHeaderCell ,
4237 MatCellDef ,
4338 MatCell ,
44- MatHeaderRowDef ,
45- MatHeaderRow ,
4639 MatRowDef ,
4740 MatRow ,
4841 ExternalIdentifierComponent ,
4942 CurrencyPipe ,
5043 DateFormatPipe ,
51- FormatNumberPipe
44+ FormatNumberPipe ,
45+ LoanSummaryBalanceComponentComponent
5246 ] ,
5347 changeDetection : ChangeDetectionStrategy . OnPush
5448} )
5549export class GeneralTabComponent extends LoanProductBaseComponent implements OnInit {
5650 private route = inject ( ActivatedRoute ) ;
5751
5852 /** Currency Code */
59- currencyCode : string ;
53+ currencyCode : string | null = null ;
6054 loanDetails : any ;
6155 status : any ;
62- loanSummaryColumns : string [ ] = [
63- 'Empty' ,
64- 'Original' ,
65- 'Paid' ,
66- 'Waived' ,
67- 'Written Off' ,
68- 'Outstanding' ,
69- 'Over Due'
70- ] ;
56+
7157 loanDetailsColumns : string [ ] = [
7258 'Key' ,
7359 'Value'
7460 ] ;
75- loanSummaryTableData : {
76- property : string ;
77- original : number ;
78- adjustment : number ;
79- paid : number ;
80- waived : number ;
81- writtenOff : number ;
82- outstanding : number ;
83- overdue : number ;
84- } [ ] ;
85- loanDetailsTableData : {
86- key : string ;
87- value ?: string ;
88- } [ ] ;
61+ loanDetailsTableData : { key : string ; value ?: string } [ ] = [ ] ;
62+ hasChargeBack : boolean = false ;
8963
90- /** Data source for loans summary table. */
91- dataSource : MatTableDataSource < any > ;
64+ /** Data source for loans details table. */
9265 detailsDataSource : MatTableDataSource < any > ;
9366
9467 constructor ( ) {
@@ -101,91 +74,22 @@ export class GeneralTabComponent extends LoanProductBaseComponent implements OnI
10174 this . loanDetails = data . loanDetailsData ;
10275 this . currencyCode = this . loanDetails . currency . code ;
10376 if ( this . loanDetails . transactions ) {
104- this . loanDetails . transactions . some ( ( transaction : any ) => {
105- if ( transaction . type . code === 'loanTransactionType.chargeback' ) {
106- this . loanSummaryColumns = [
107- 'Empty' ,
108- 'Original' ,
109- 'Adjustments' ,
110- 'Paid' ,
111- 'Waived' ,
112- 'Written Off' ,
113- 'Outstanding' ,
114- 'Over Due'
115- ] ;
116- return ;
117- }
118- } ) ;
77+ this . hasChargeBack = this . loanDetails . transactions . some (
78+ ( transaction : any ) => transaction . type . code === 'loanTransactionType.chargeback'
79+ ) ;
11980 }
12081 } ) ;
12182 }
12283
12384 ngOnInit ( ) {
12485 this . status = this . loanDetails . value ;
12586 if ( this . loanDetails . summary ) {
126- this . setloanSummaryTableData ( ) ;
12787 this . setloanDetailsTableData ( ) ;
12888 } else {
12989 this . setloanNonDetailsTableData ( ) ;
13090 }
13191 }
13292
133- setloanSummaryTableData ( ) {
134- this . loanSummaryTableData = [
135- {
136- property : 'Principal' ,
137- original : this . loanDetails . summary . totalPrincipal ,
138- adjustment : this . loanDetails . summary . principalAdjustments || 0 ,
139- paid : this . loanDetails . summary . principalPaid ,
140- waived : this . loanDetails . summary . principalWaived || 0 ,
141- writtenOff : this . loanDetails . summary . principalWrittenOff ,
142- outstanding : this . loanDetails . summary . principalOutstanding ,
143- overdue : this . loanDetails . summary . principalOverdue
144- } ,
145- {
146- property : 'Interest' ,
147- original : this . loanDetails . summary . interestCharged ,
148- adjustment : 0 ,
149- paid : this . loanDetails . summary . interestPaid ,
150- waived : this . loanDetails . summary . interestWaived ,
151- writtenOff : this . loanDetails . summary . interestWrittenOff ,
152- outstanding : this . loanDetails . summary . interestOutstanding ,
153- overdue : this . loanDetails . summary . interestOverdue
154- } ,
155- {
156- property : 'Fees' ,
157- original : this . loanDetails . summary . feeChargesCharged ,
158- adjustment : 0 ,
159- paid : this . loanDetails . summary . feeChargesPaid ,
160- waived : this . loanDetails . summary . feeChargesWaived ,
161- writtenOff : this . loanDetails . summary . feeChargesWrittenOff ,
162- outstanding : this . loanDetails . summary . feeChargesOutstanding ,
163- overdue : this . loanDetails . summary . feeChargesOverdue
164- } ,
165- {
166- property : 'Penalties' ,
167- original : this . loanDetails . summary . penaltyChargesCharged ,
168- adjustment : 0 ,
169- paid : this . loanDetails . summary . penaltyChargesPaid ,
170- waived : this . loanDetails . summary . penaltyChargesWaived ,
171- writtenOff : this . loanDetails . summary . penaltyChargesWrittenOff ,
172- outstanding : this . loanDetails . summary . penaltyChargesOutstanding ,
173- overdue : this . loanDetails . summary . penaltyChargesOverdue
174- } ,
175- {
176- property : 'Total' ,
177- original : this . loanDetails . summary . totalExpectedRepayment ,
178- adjustment : this . loanDetails . summary . principalAdjustments || 0 ,
179- paid : this . loanDetails . summary . totalRepayment ,
180- waived : this . loanDetails . summary . totalWaived ,
181- writtenOff : this . loanDetails . summary . totalWrittenOff ,
182- outstanding : this . loanDetails . summary . totalOutstanding ,
183- overdue : this . loanDetails . summary . totalOverdue
184- }
185- ] ;
186- this . dataSource = new MatTableDataSource ( this . loanSummaryTableData ) ;
187- }
188-
18993 setloanDetailsTableData ( ) {
19094 this . loanDetailsTableData = [
19195 {
0 commit comments