From 640f3b46f77feadab124ec77927db327aa253f69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Alberto=20Hern=C3=A1ndez?= <44206706+josehernandezfintecheandomx@users.noreply.github.com> Date: Sun, 23 Jul 2023 20:28:43 -0600 Subject: [PATCH] Fix Loan products to use global settings in default (#1809) Co-authored-by: Jose Alberto Hernandez --- .../loans-account-preview-step.component.html | 5 ++++- .../charges-tab/charges-tab.component.html | 4 ++-- .../loans-view/charges-tab/charges-tab.component.ts | 12 ++++++++++-- .../create-loan-product.component.ts | 2 +- .../edit-loan-product/edit-loan-product.component.ts | 2 +- src/app/products/loan-products/loan-products.ts | 10 ++++++++-- 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/app/loans/loans-account-stepper/loans-account-preview-step/loans-account-preview-step.component.html b/src/app/loans/loans-account-stepper/loans-account-preview-step/loans-account-preview-step.component.html index ba46ec8e4..de649d0d1 100644 --- a/src/app/loans/loans-account-stepper/loans-account-preview-step/loans-account-preview-step.component.html +++ b/src/app/loans/loans-account-stepper/loans-account-preview-step/loans-account-preview-step.component.html @@ -47,7 +47,10 @@
Principal: - {{ loansAccount.principal }} {{loansAccountProductTemplate.currency.DisplaySymbol}} + + {{ loansAccount.principalAmount | currency:loansAccountProductTemplate.currency.code:'symbol-narrow':'1.2-2'}} + {{loansAccountProductTemplate.currency.code}} +
diff --git a/src/app/loans/loans-view/charges-tab/charges-tab.component.html b/src/app/loans/loans-view/charges-tab/charges-tab.component.html index 184c62bb8..2d82efa80 100644 --- a/src/app/loans/loans-view/charges-tab/charges-tab.component.html +++ b/src/app/loans/loans-view/charges-tab/charges-tab.component.html @@ -20,12 +20,12 @@ {{ charge.chargeTimeType.value }} - + Submitted On {{ charge.submittedOnDate | dateFormat }} - + Due as of {{ charge.dueDate | dateFormat }} diff --git a/src/app/loans/loans-view/charges-tab/charges-tab.component.ts b/src/app/loans/loans-view/charges-tab/charges-tab.component.ts index 4b68aa06d..627c89edc 100644 --- a/src/app/loans/loans-view/charges-tab/charges-tab.component.ts +++ b/src/app/loans/loans-view/charges-tab/charges-tab.component.ts @@ -20,6 +20,8 @@ import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield- import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base'; import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicker-base'; import { Dates } from 'app/core/utils/dates'; +import { SystemService } from 'app/system/system.service'; +import { GlobalConfiguration } from 'app/system/configurations/global-configurations-tab/configuration.model'; @Component({ selector: 'mifosx-charges-tab', @@ -35,10 +37,12 @@ export class ChargesTabComponent implements OnInit { /** Status */ status: any; /** Columns to be displayed in charges table. */ - displayedColumns: string[] = ['name', 'feepenalty', 'paymentdueat', 'submittedDate', 'dueDate', 'calculationtype', 'due', 'paid', 'waived', 'outstanding', 'actions']; + displayedColumns: string[] = ['name', 'feepenalty', 'paymentdueat', 'dueDate', 'calculationtype', 'due', 'paid', 'waived', 'outstanding', 'actions']; /** Data source for charges table. */ dataSource: MatTableDataSource; + useDueDate = true; + /** Paginator for charges table. */ @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator; /** Sorter for charges table. */ @@ -54,13 +58,17 @@ export class ChargesTabComponent implements OnInit { private dateUtils: Dates, private router: Router, public dialog: MatDialog, - private settingsService: SettingsService) { + private settingsService: SettingsService, + private systemService: SystemService) { this.route.parent.data.subscribe(( data: { loanDetailsData: any }) => { this.loanDetails = data.loanDetailsData; }); } ngOnInit() { + this.systemService.getConfigurationByName('charge-accrual-date').subscribe((config: GlobalConfiguration) => { + this.useDueDate = (config.stringValue === 'due-date'); + }); this.chargesData = this.loanDetails.charges; this.status = this.loanDetails.status.value; let actionFlag; diff --git a/src/app/products/loan-products/create-loan-product/create-loan-product.component.ts b/src/app/products/loan-products/create-loan-product/create-loan-product.component.ts index b7c650c9b..5f7981a7f 100644 --- a/src/app/products/loan-products/create-loan-product/create-loan-product.component.ts +++ b/src/app/products/loan-products/create-loan-product/create-loan-product.component.ts @@ -52,7 +52,7 @@ export class CreateLoanProductComponent implements OnInit { this.itemsByDefault = loanProducts.setItemsByDefault(data.configurations); this.loanProductsTemplate['itemsByDefault'] = this.itemsByDefault; - this.loanProductsTemplate = loanProducts.updateLoanProductDefaults(this.loanProductsTemplate); + this.loanProductsTemplate = loanProducts.updateLoanProductDefaults(this.loanProductsTemplate, false); }); } diff --git a/src/app/products/loan-products/edit-loan-product/edit-loan-product.component.ts b/src/app/products/loan-products/edit-loan-product/edit-loan-product.component.ts index d9951f42d..1ec078717 100644 --- a/src/app/products/loan-products/edit-loan-product/edit-loan-product.component.ts +++ b/src/app/products/loan-products/edit-loan-product/edit-loan-product.component.ts @@ -52,7 +52,7 @@ export class EditLoanProductComponent implements OnInit { this.itemsByDefault = loanProducts.setItemsByDefault(data.configurations); this.loanProductAndTemplate['itemsByDefault'] = this.itemsByDefault; - this.loanProductAndTemplate = loanProducts.updateLoanProductDefaults(this.loanProductAndTemplate); + this.loanProductAndTemplate = loanProducts.updateLoanProductDefaults(this.loanProductAndTemplate, true); }); } diff --git a/src/app/products/loan-products/loan-products.ts b/src/app/products/loan-products/loan-products.ts index 1a54ce9fe..67be7f8b9 100644 --- a/src/app/products/loan-products/loan-products.ts +++ b/src/app/products/loan-products/loan-products.ts @@ -22,12 +22,18 @@ export class LoanProducts { return itemsByDefault; } - public updateLoanProductDefaults(loanProductTemplate: any) { + public updateLoanProductDefaults(loanProductTemplate: any, isForUpdate: boolean) { const itemsByDefault: GlobalConfiguration[] = loanProductTemplate['itemsByDefault']; itemsByDefault.forEach((config: GlobalConfiguration) => { const propertyName = this.resolvePropertyName(config.name); if (propertyName !== '') { - loanProductTemplate[propertyName] = config.value; + if (isForUpdate) { + if (!loanProductTemplate[propertyName] || loanProductTemplate[propertyName] === '') { + loanProductTemplate[propertyName] = config.value; + } + } else { + loanProductTemplate[propertyName] = config.value; + } } }); return loanProductTemplate;