-
Notifications
You must be signed in to change notification settings - Fork 888
WEB-813: Working Capital loan account creation #3257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,8 +7,8 @@ | |
| */ | ||
|
|
||
| /** Angular Imports */ | ||
| import { Component, OnInit, OnDestroy, inject } from '@angular/core'; | ||
| import { Router, ActivatedRoute, RouterLink } from '@angular/router'; | ||
| import { Component, OnDestroy, inject } from '@angular/core'; | ||
| import { Router, ActivatedRoute } from '@angular/router'; | ||
| import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'; | ||
|
|
||
| /** Custom Services. */ | ||
|
|
@@ -45,6 +45,7 @@ import { Subject } from 'rxjs'; | |
| import { takeUntil, catchError } from 'rxjs/operators'; | ||
| import { AlertService } from 'app/core/alert/alert.service'; | ||
| import { EMPTY } from 'rxjs'; | ||
| import { LoanProductService } from 'app/products/loan-products/services/loan-product.service'; | ||
|
|
||
| /** | ||
| * General Tab component. | ||
|
|
@@ -155,6 +156,7 @@ export class GeneralTabComponent implements OnDestroy { | |
| /** Open Loan Accounts Columns */ | ||
| openLoansColumns: string[] = [ | ||
| 'Account No', | ||
| 'Product Type', | ||
| 'Loan Account', | ||
| 'Original Loan', | ||
| 'Loan Balance', | ||
|
|
@@ -165,6 +167,7 @@ export class GeneralTabComponent implements OnDestroy { | |
| /** Closed Loan Accounts Columns */ | ||
| closedLoansColumns: string[] = [ | ||
| 'Account No', | ||
| 'Product Type', | ||
| 'Loan Account', | ||
| 'Original Loan', | ||
| 'Loan Balance', | ||
|
|
@@ -226,6 +229,7 @@ export class GeneralTabComponent implements OnDestroy { | |
| clientAccountData: any; | ||
| /** Loan Accounts Data */ | ||
| loanAccounts: any[] = []; | ||
| workingCapitalLoanAccounts: any[] = []; | ||
| /** Savings Accounts Data */ | ||
| savingAccounts: any[] = []; | ||
| /** Shares Accounts Data */ | ||
|
|
@@ -273,7 +277,10 @@ export class GeneralTabComponent implements OnDestroy { | |
| (data: { clientAccountsData: any; clientChargesData: any; clientSummary: any; clientCollateralData: any }) => { | ||
| this.clientAccountData = data.clientAccountsData; | ||
| this.savingAccounts = data.clientAccountsData?.savingsAccounts ?? []; | ||
| this.loanAccounts = data.clientAccountsData?.loanAccounts ?? []; | ||
| this.loanAccounts = []; | ||
| this.processLoanAccounts(data.clientAccountsData?.loanAccounts ?? [], 'loan'); | ||
| this.processLoanAccounts(data.clientAccountsData?.workingCapitalLoanAccounts ?? [], 'working-capital'); | ||
| this.workingCapitalLoanAccounts = data.clientAccountsData?.workingCapitalLoanAccounts ?? []; | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| this.shareAccounts = data.clientAccountsData?.shareAccounts ?? []; | ||
|
|
||
| this.upcomingCharges = data.clientChargesData?.pageItems ?? []; | ||
|
|
@@ -417,4 +424,17 @@ export class GeneralTabComponent implements OnDestroy { | |
| return 'labels.buttons.View Closed Accounts'; | ||
| } | ||
| } | ||
|
|
||
| loanProductTypeLabel(productType: string): string { | ||
| return LoanProductService.productTypeLabel(productType); | ||
| } | ||
|
|
||
| private processLoanAccounts(accounts: any[], productType: string): void { | ||
| accounts.map((account: any) => { | ||
| this.loanAccounts.push({ | ||
| productType: productType, | ||
| ...account | ||
| }); | ||
| }); | ||
|
Comment on lines
+432
to
+438
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Return mapped accounts instead of using Biome already flags this callback because it never returns. It also lets an existing ♻️ Proposed fix private processLoanAccounts(accounts: any[], productType: string): void {
- accounts.map((account: any) => {
- this.loanAccounts.push({
- productType: productType,
- ...account
- });
- });
+ this.loanAccounts.push(
+ ...accounts.map((account: any) => ({
+ ...account,
+ productType
+ }))
+ );
}🧰 Tools🪛 Biome (2.4.6)[error] 433-433: This callback passed to map() iterable method should always return a value. (lint/suspicious/useIterableCallbackReturn) 🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,22 +15,33 @@ import { Observable } from 'rxjs'; | |
|
|
||
| /** Custom Services */ | ||
| import { LoansService } from '../loans.service'; | ||
| import { LoanProductService } from 'app/products/loan-products/services/loan-product.service'; | ||
| import { LOAN_PRODUCT_TYPE } from 'app/products/loan-products/models/loan-product.model'; | ||
|
|
||
| /** | ||
| * Clients data resolver. | ||
| */ | ||
| @Injectable() | ||
| export class LoanDetailsResolver { | ||
| private loansService = inject(LoansService); | ||
| private loanProductService = inject(LoanProductService); | ||
|
|
||
| /** | ||
| * Returns the Loans with Association data. | ||
| * @returns {Observable<any>} | ||
| */ | ||
| resolve(route: ActivatedRouteSnapshot): Observable<any> { | ||
| const loanId = route.paramMap.get('loanId') || route.parent.paramMap.get('loanId'); | ||
| const productType = route.queryParams['productType']; | ||
| const resolvedProductType = | ||
| productType === LOAN_PRODUCT_TYPE.WORKING_CAPITAL ? LOAN_PRODUCT_TYPE.WORKING_CAPITAL : LOAN_PRODUCT_TYPE.LOAN; | ||
| this.loanProductService.initialize(resolvedProductType); | ||
| if (!isNaN(+loanId)) { | ||
| return this.loansService.getLoanAccountAssociationDetails(loanId); | ||
| if (resolvedProductType === LOAN_PRODUCT_TYPE.LOAN) { | ||
| return this.loansService.getLoanAccountAssociationDetails(loanId); | ||
| } else { | ||
| return this.loansService.getWorkingCapitalLoannDetails(loanId); | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
33
to
46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing return path when When 🛡️ Proposed fix to handle invalid loanId+import { EMPTY } from 'rxjs';
+
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const loanId = route.paramMap.get('loanId') || route.parent.paramMap.get('loanId');
const productType = route.queryParams['productType'];
const resolvedProductType =
productType === LOAN_PRODUCT_TYPE.WORKING_CAPITAL ? LOAN_PRODUCT_TYPE.WORKING_CAPITAL : LOAN_PRODUCT_TYPE.LOAN;
this.loanProductService.initialize(resolvedProductType);
if (!isNaN(+loanId)) {
if (resolvedProductType === LOAN_PRODUCT_TYPE.LOAN) {
return this.loansService.getLoanAccountAssociationDetails(loanId);
} else {
return this.loansService.getWorkingCapitalLoannDetails(loanId);
}
}
+ return EMPTY;
}🤖 Prompt for AI Agents |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /** | ||
| * Copyright since 2025 Mifos Initiative | ||
| * | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
|
|
||
| /** Angular Imports */ | ||
| import { Injectable, inject } from '@angular/core'; | ||
| import { ActivatedRouteSnapshot } from '@angular/router'; | ||
|
|
||
| /** rxjs Imports */ | ||
| import { Observable } from 'rxjs'; | ||
|
|
||
| /** Custom Services */ | ||
| import { ProductsService } from 'app/products/products.service'; | ||
|
|
||
| /** | ||
| * Loan Product list data resolver. | ||
| */ | ||
| @Injectable() | ||
| export class LoanProductsResolver { | ||
| private productsService = inject(ProductsService); | ||
|
|
||
| /** | ||
| * Returns the loan account template data. | ||
| * @returns {Observable<any>} | ||
| */ | ||
| resolve(route: ActivatedRouteSnapshot): Observable<any> { | ||
| return this.productsService.getLoanProductsBasicDetails(); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.