From 497fc3b9d94b0d14725f439e2203eb59daa294b2 Mon Sep 17 00:00:00 2001 From: Jose Alberto Hernandez Date: Thu, 28 Nov 2024 12:36:07 -0500 Subject: [PATCH] Loan product using externalId input field --- .../loan-product-summary.component.html | 9 +++- .../loan-product-summary.component.ts | 19 +++----- ...oan-product-accounting-step.component.html | 2 - .../loan-product-accounting-step.component.ts | 46 ++++++++++--------- .../loan-product-details-step.component.html | 9 +++- .../loan-product-details-step.component.ts | 2 + .../models/loan-product.model.ts | 4 +- src/app/shared/footer/footer.component.ts | 8 ++-- src/app/shared/models/general.model.ts | 19 ++++++-- 9 files changed, 68 insertions(+), 50 deletions(-) diff --git a/src/app/products/loan-products/common/loan-product-summary/loan-product-summary.component.html b/src/app/products/loan-products/common/loan-product-summary/loan-product-summary.component.html index 0ea1ff088a..41d9ab3741 100644 --- a/src/app/products/loan-products/common/loan-product-summary/loan-product-summary.component.html +++ b/src/app/products/loan-products/common/loan-product-summary/loan-product-summary.component.html @@ -14,6 +14,11 @@

{{ 'labels.heading.Details' | translate}}

{{ loanProduct.shortName }} +
+ {{ 'labels.inputs.External Id' | translate}}: + {{ loanProduct.externalId }} +
+
{{ 'labels.inputs.Fund' | translate}}: {{ loanProduct.fundName }} @@ -928,14 +933,14 @@

{{'labels.heading.Map Charge-off reasons to Expens {{'labels.inputs.Charge-off reason' | translate}} - {{ chargeOffReasonsToExpenseMapping.chargeOffReason.name }} + {{ chargeOffReasonsToExpenseMapping.chargeOffReasonsCodeValue.name }} {{'labels.inputs.Expense Account' | translate}} - {{ chargeOffReasonsToExpenseMapping.expenseGLAccount.name }} + ({{ chargeOffReasonsToExpenseMapping.chargeOffExpenseAccount.glCode }}) {{ chargeOffReasonsToExpenseMapping.chargeOffExpenseAccount.name }} diff --git a/src/app/products/loan-products/common/loan-product-summary/loan-product-summary.component.ts b/src/app/products/loan-products/common/loan-product-summary/loan-product-summary.component.ts index d799044933..0bec713eeb 100644 --- a/src/app/products/loan-products/common/loan-product-summary/loan-product-summary.component.ts +++ b/src/app/products/loan-products/common/loan-product-summary/loan-product-summary.component.ts @@ -1,6 +1,6 @@ import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; import { DelinquencyBucket, LoanProduct } from '../../models/loan-product.model'; -import {AccountingMapping, Charge, ChargeOffReasonsToExpenseMapping, ChargeToIncomeAccountMapping, GLAccount, PaymentChannelToFundSourceMapping, PaymentType, PaymentTypeOption} from '../../../../shared/models/general.model'; +import {AccountingMapping, Charge, ChargeOffReasonsToGLAccountMapping, ChargeToIncomeAccountMapping, GLAccount, PaymentChannelToFundSourceMapping, PaymentType, PaymentTypeOption} from '../../../../shared/models/general.model'; import { AdvancePaymentAllocationData, CreditAllocation, PaymentAllocation } from '../../loan-product-stepper/loan-product-payment-strategy-step/payment-allocation-model'; import { LoanProducts } from '../../loan-products'; import { CodeName, OptionData, StringEnumOptionData } from '../../../../shared/models/option-data.model'; @@ -36,7 +36,7 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges { paymentChannelToFundSourceMappings: PaymentChannelToFundSourceMapping[] = []; feeToIncomeAccountMappings: ChargeToIncomeAccountMapping[] = []; penaltyToIncomeAccountMappings: ChargeToIncomeAccountMapping[] = []; - chargeOffReasonsToExpenseMappings: ChargeOffReasonsToExpenseMapping[] = []; + chargeOffReasonsToExpenseMappings: ChargeOffReasonsToGLAccountMapping[] = []; constructor(private accounting: Accounting) { } @@ -65,7 +65,7 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges { this.paymentChannelToFundSourceMappings = this.loanProduct.paymentChannelToFundSourceMappings || []; this.feeToIncomeAccountMappings = this.loanProduct.feeToIncomeAccountMappings || []; this.penaltyToIncomeAccountMappings = this.loanProduct.penaltyToIncomeAccountMappings || []; - this.chargeOffReasonsToExpenseMappings = this.loanProduct.chargeOffReasonsToExpenseMappings || []; + this.chargeOffReasonsToExpenseMappings = this.loanProduct.chargeOffReasonToGLAccountMappings || []; } else { this.accountingMappings = {}; @@ -133,14 +133,9 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges { } this.chargeOffReasonsToExpenseMappings = []; - if (this.loanProduct.chargeOffReasonsToExpenseMappings?.length > 0) { - this.loanProduct.chargeOffReasonsToExpenseMappings.forEach((m: ChargeOffReasonsToExpenseMapping) => { - this.chargeOffReasonsToExpenseMappings.push({ - chargeOffReasonCodeValueId: m.chargeOffReasonCodeValueId, - chargeOffReason: this.optionDataLookUp(m.chargeOffReasonCodeValueId, this.loanProductsTemplate.chargeOffReasonOptions), - expenseGLAccountId: m.expenseGLAccountId, - expenseGLAccount: this.glAccountLookUp(m.expenseGLAccountId, expenseAccountData) - }); + if (this.loanProduct.chargeOffReasonToGLAccountMappings?.length > 0) { + this.loanProduct.chargeOffReasonToGLAccountMappings.forEach((m: ChargeOffReasonsToGLAccountMapping) => { + this.chargeOffReasonsToExpenseMappings.push(m); }); } } @@ -343,7 +338,7 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges { return (this.loanProduct.paymentChannelToFundSourceMappings?.length > 0 || this.loanProduct.feeToIncomeAccountMappings?.length > 0 || this.loanProduct.penaltyToIncomeAccountMappings?.length > 0 - || this.loanProduct.chargeOffReasonsToExpenseMappings?.length > 0); + || this.loanProduct.chargeOffReasonToGLAccountMappings?.length > 0); } getAccountingRuleName(value: string): string { diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/loan-product-accounting-step.component.html b/src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/loan-product-accounting-step.component.html index 6b0513378a..7e88302843 100644 --- a/src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/loan-product-accounting-step.component.html +++ b/src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/loan-product-accounting-step.component.html @@ -342,8 +342,6 @@

{{'labels.heading.Map Charge-off reasons to Expe {{'labels.buttons.Add' | translate}}

- - diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/loan-product-accounting-step.component.ts b/src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/loan-product-accounting-step.component.ts index b6e74f7bcc..78f6c32752 100644 --- a/src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/loan-product-accounting-step.component.ts +++ b/src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/loan-product-accounting-step.component.ts @@ -8,7 +8,7 @@ import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.componen import { TranslateService } from '@ngx-translate/core'; import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base'; import { SelectBase } from 'app/shared/form-dialog/formfield/model/select-base'; -import {ChargeOffReasonsToExpenseMapping} from '../../../../shared/models/general.model'; +import { ChargeOffReasonsToGLAccountMapping } from 'app/shared/models/general.model'; @Component({ selector: 'mifosx-loan-product-accounting-step', @@ -107,8 +107,8 @@ export class LoanProductAccountingStepComponent implements OnInit { this.formBuilder.array((this.loanProductsTemplate.penaltyToIncomeAccountMappings || []).map((penaltyIncome: any) => ({ chargeId: penaltyIncome.charge.id, incomeAccountId: penaltyIncome.incomeAccount.id })))); this.loanProductAccountingForm.setControl('chargeOffReasonsToExpenseMappings', - this.formBuilder.array((this.loanProductsTemplate.chargeOffReasonsToExpenseMappings || []).map((m: ChargeOffReasonsToExpenseMapping) => - ({ chargeOffReasonCodeValueId: m.chargeOffReasonCodeValueId, expenseGLAccountId: m.expenseGLAccountId })))); + this.formBuilder.array((this.loanProductsTemplate.chargeOffReasonsToExpenseMappings || []).map((m: ChargeOffReasonsToGLAccountMapping) => + ({ chargeOffReasonCodeValueId: m.chargeOffReasonsCodeValue.id, expenseGLAccountId: m.chargeOffExpenseAccount.id })))); } } @@ -324,25 +324,27 @@ export class LoanProductAccountingStepComponent implements OnInit { } getChargeOffReasonExpenseFormfields(values?: any) { - const formfields: FormfieldBase[] = [ - new SelectBase({ - controlName: 'chargeOffReasonCodeValueId', - label: 'Charge-off reason', - value: values ? values.chargeOffReasonCodeValueId : this.chargeOffReasonOptions[0].id, - options: { label: 'name', value: 'id', data: this.chargeOffReasonOptions }, - required: true, - order: 1 - }), - new SelectBase({ - controlName: 'expenseGLAccountId', - label: 'Expense Account', - value: values ? values.expenseGLAccountId : this.expenseAccountData[0].id, - options: { label: 'name', value: 'id', data: this.expenseAccountData }, - required: true, - order: 2 - }) - ]; - return formfields; + if (values != null) { + const formfields: FormfieldBase[] = [ + new SelectBase({ + controlName: 'chargeOffReasonCodeValueId', + label: 'Charge-off reason', + value: values ? values.chargeOffReasonCodeValueId : this.chargeOffReasonOptions[0].id, + options: { label: 'name', value: 'id', data: this.chargeOffReasonOptions }, + required: true, + order: 1 + }), + new SelectBase({ + controlName: 'expenseGLAccountId', + label: 'Expense Account', + value: values ? values.expenseGLAccountId : this.expenseAccountData[0].id, + options: { label: 'name', value: 'id', data: this.expenseAccountData }, + required: true, + order: 2 + }) + ]; + return formfields; + } } get isAccountingAccrualBased() { diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-details-step/loan-product-details-step.component.html b/src/app/products/loan-products/loan-product-stepper/loan-product-details-step/loan-product-details-step.component.html index 544e6825d4..e8fb7d989a 100644 --- a/src/app/products/loan-products/loan-product-stepper/loan-product-details-step/loan-product-details-step.component.html +++ b/src/app/products/loan-products/loan-product-stepper/loan-product-details-step/loan-product-details-step.component.html @@ -2,7 +2,7 @@
- + {{'labels.inputs.Product Name' | translate}} @@ -10,7 +10,7 @@ - + {{'labels.inputs.Short Name' | translate}} @@ -18,6 +18,11 @@ + + {{'labels.inputs.External Id' | translate}} + + + {{'labels.inputs.Fund' | translate}} diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-details-step/loan-product-details-step.component.ts b/src/app/products/loan-products/loan-product-stepper/loan-product-details-step/loan-product-details-step.component.ts index b813cf8ce4..f94a365402 100644 --- a/src/app/products/loan-products/loan-product-stepper/loan-product-details-step/loan-product-details-step.component.ts +++ b/src/app/products/loan-products/loan-product-stepper/loan-product-details-step/loan-product-details-step.component.ts @@ -42,6 +42,7 @@ export class LoanProductDetailsStepComponent implements OnInit { 'name': this.loanProductsTemplate.name, 'shortName': this.loanProductsTemplate.shortName, 'description': this.loanProductsTemplate.description, + 'externalId': this.loanProductsTemplate.externalId, 'fundId': this.loanProductsTemplate.fundId, 'startDate': this.loanProductsTemplate.startDate && new Date(this.loanProductsTemplate.startDate), 'closeDate': this.loanProductsTemplate.closeDate && new Date(this.loanProductsTemplate.closeDate), @@ -54,6 +55,7 @@ export class LoanProductDetailsStepComponent implements OnInit { 'name': ['', Validators.required], 'shortName': ['', Validators.required], 'description': [''], + 'externalId': [''], 'fundId': [''], 'startDate': [''], 'closeDate': [''], diff --git a/src/app/products/loan-products/models/loan-product.model.ts b/src/app/products/loan-products/models/loan-product.model.ts index e0e08e7296..5a72b85377 100644 --- a/src/app/products/loan-products/models/loan-product.model.ts +++ b/src/app/products/loan-products/models/loan-product.model.ts @@ -1,4 +1,4 @@ -import {AccountingMapping, ChargeOffReasonsToExpenseMapping, ChargeToIncomeAccountMapping, Currency, PaymentChannelToFundSourceMapping} from 'app/shared/models/general.model'; +import {AccountingMapping, ChargeOffReasonsToGLAccountMapping, ChargeToIncomeAccountMapping, Currency, PaymentChannelToFundSourceMapping} from 'app/shared/models/general.model'; import { OptionData, StringEnumOptionData } from 'app/shared/models/option-data.model'; import { CreditAllocation, PaymentAllocation } from '../loan-product-stepper/loan-product-payment-strategy-step/payment-allocation-model'; @@ -125,7 +125,7 @@ export interface LoanProduct { paymentChannelToFundSourceMappings?: PaymentChannelToFundSourceMapping[]; feeToIncomeAccountMappings?: ChargeToIncomeAccountMapping[]; penaltyToIncomeAccountMappings?: ChargeToIncomeAccountMapping[]; - chargeOffReasonsToExpenseMappings?: ChargeOffReasonsToExpenseMapping[]; + chargeOffReasonToGLAccountMappings?: ChargeOffReasonsToGLAccountMapping[]; enableAccrualActivityPosting?: boolean; supportedInterestRefundTypes?: StringEnumOptionData[]; } diff --git a/src/app/shared/footer/footer.component.ts b/src/app/shared/footer/footer.component.ts index 18f4445d39..4e5763665c 100644 --- a/src/app/shared/footer/footer.component.ts +++ b/src/app/shared/footer/footer.component.ts @@ -74,9 +74,11 @@ export class FooterComponent implements OnInit, OnDestroy { this.getConfigurations(); this.server = this.settingsService.server; this.versionService.getBackendInfo().subscribe((data: any) => { - const buildVersion: string = data.git.build.version.split('-'); - this.versions.fineract.version = buildVersion[0]; - this.versions.fineract.hash = buildVersion[1]; + if (data.git && data.git.build && data.git.build.version) { + const buildVersion: string = data.git.build.version.split('-'); + this.versions.fineract.version = buildVersion[0]; + this.versions.fineract.hash = buildVersion[1]; + } }); } } diff --git a/src/app/shared/models/general.model.ts b/src/app/shared/models/general.model.ts index 9fafcde84a..8a7c4044c6 100644 --- a/src/app/shared/models/general.model.ts +++ b/src/app/shared/models/general.model.ts @@ -39,11 +39,20 @@ export interface PaymentChannelToFundSourceMapping { fundSourceAccount: AccountingMapping; } -export interface ChargeOffReasonsToExpenseMapping { - chargeOffReasonCodeValueId: number; - expenseGLAccountId: number; - chargeOffReason?: OptionData; - expenseGLAccount?: AccountingMapping; +export interface ChargeOffReasonsToGLAccountMapping { + chargeOffReasonCodeValueId?: number; + chargeOffReason? : OptionData; + chargeOffReasonsCodeValue?: ChargeOffReasonsCodeValue; + chargeOffExpenseAccount?: AccountingMapping; +} + +export interface ChargeOffReasonsCodeValue { + active: boolean; + description: string; + id: number; + mandatory: boolean; + name: string; + position?: number; } export interface PaymentType {