From 4271ca92dc20a531c9fbf0251c5b4fca82d8c80b Mon Sep 17 00:00:00 2001 From: Jose Alberto Hernandez Date: Tue, 28 Nov 2023 20:51:40 -0600 Subject: [PATCH] Loan Product views enhancements --- .../loans-view/loans-view.component.html | 2 +- .../loan-product-summary.component.html | 46 ++++---- .../loan-product-summary.component.ts | 101 +++++++++++++++--- ...product-payment-strategy-step.component.ts | 4 +- .../loan-product-preview-step.component.html | 1 + .../loan-product-settings-step.component.ts | 2 + .../models/loan-product.model.ts | 1 + .../general-tab/general-tab.component.html | 1 + 8 files changed, 116 insertions(+), 42 deletions(-) diff --git a/src/app/loans/loans-view/loans-view.component.html b/src/app/loans/loans-view/loans-view.component.html index 97a04510a..00a65a3cf 100644 --- a/src/app/loans/loans-view/loans-view.component.html +++ b/src/app/loans/loans-view/loans-view.component.html @@ -46,7 +46,7 @@
-

{{"labels.heading.Account OverView" | translate}}

+

{{"labels.heading.Account Overview" | translate}}

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 36c7e49e6..12fbf73f9 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 @@ -43,27 +43,27 @@ -
+
Currency: - {{ loanProduct.currencyCode | find:loanProductsTemplate.currencyOptions:'code':'name' }} + {{ loanProduct.currency.code }}
-
+
Currency: - {{ loanProduct.currency.name }} + {{ loanProduct.currency.displayLabel }}
-
+
Decimal Places: {{ loanProduct.currency.decimalPlaces }}
-
+
Currency in multiples of: {{ loanProduct.currency.inMultiplesOf }}
-
+
Installment in multiples of: {{ loanProduct.installmentAmountInMultiplesOf }}
@@ -87,17 +87,17 @@
Over Applied Amount: - {{ loanProduct.overAppliedNumber + {{ loanProduct.overAppliedNumber | formatNumber }} % - {{ loanProduct.overAppliedNumber | + {{ loanProduct.overAppliedNumber | formatNumber }} {{ loanProduct.currencyCode }}
Installment day calculation from: - {{ loanProduct.repaymentStartDateType.value }} + {{ loanProduct.repaymentStartDateType?.value }}
@@ -118,7 +118,7 @@ {{ loanProduct.interestRatePerPeriod + ' (Min: ' + (loanProduct.minInterestRatePerPeriod ? loanProduct.minInterestRatePerPeriod : loanProduct.interestRatePerPeriod) + ', Max: ' + (loanProduct.maxInterestRatePerPeriod ? loanProduct.maxInterestRatePerPeriod : loanProduct.interestRatePerPeriod) - + ')' + ' ' + loanProduct.interestRateFrequencyType.value }} + + ')' + ' ' + loanProduct.interestRateFrequencyType?.value }}
@@ -300,7 +300,7 @@ -
+
Amortization: {{ loanProduct.amortizationType.value }}
@@ -312,15 +312,15 @@
Interest Method: - {{ loanProduct.interestType.value }} + {{ loanProduct.interestType?.value }}
Interest Calculation Period: - {{ loanProduct.interestCalculationPeriodType.value }} + {{ loanProduct.interestCalculationPeriodType?.value }}
-
+
Allow Partial Interest Calculation with same as repayment: {{ loanProduct.allowPartialPeriodInterestCalculation | yesNo }}
@@ -339,7 +339,12 @@ {{ loanProduct.transactionProcessingStrategyName }}
-
+
+ Loan Schedule Processing Type: + {{ loanProduct.loanScheduleProcessingType.value }} +
+ +
Advanced Payment Allocation Transactions: @@ -351,11 +356,6 @@
-
- Loan Schedule Processing Type: - {{ loanProduct.loanScheduleProcessingType.value }} -
-

Down Payments

@@ -414,12 +414,12 @@
Days in year: - {{ loanProduct.daysInYearType.value }} + {{ loanProduct.daysInYearType?.value }}
Days in month: - {{ loanProduct.daysInMonthType.value }} + {{ loanProduct.daysInMonthType?.value }}
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 2d65cef6c..a181d2a66 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 @@ -3,7 +3,7 @@ import { LoanProduct } from '../../models/loan-product.model'; import { AccountingMapping, Charge, ChargeToIncomeAccountMapping, GLAccount, PaymentChannelToFundSourceMapping, PaymentType, PaymentTypeOption } from '../../../../shared/models/general.model'; import { AdvancePaymentAllocationData, PaymentAllocation } from '../../loan-product-stepper/loan-product-payment-strategy-step/payment-allocation-model'; import { LoanProducts } from '../../loan-products'; -import { OptionData } from '../../../../shared/models/option-data.model'; +import { CodeName, OptionData } from '../../../../shared/models/option-data.model'; @Component({ selector: 'mifosx-loan-product-summary', @@ -12,6 +12,7 @@ import { OptionData } from '../../../../shared/models/option-data.model'; }) export class LoanProductSummaryComponent implements OnInit, OnChanges { + @Input() action: string; @Input() loanProduct: LoanProduct; @Input() loanProductsTemplate: any | null; @Input() useDueForRepaymentsConfigurations: boolean; @@ -43,9 +44,19 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges { } setCurrentValues(): void { - if (this.loanProduct.accountingMappings) { + this.isAdvancedPaymentAllocation = LoanProducts.isAdvancedPaymentAllocationStrategy(this.loanProduct.transactionProcessingStrategyCode); + + if (!this.loanProduct.currency) { + this.loanProductsTemplate.currencyOptions.some((o: any) => { + if (o.code === this.loanProduct.currencyCode) { + this.loanProduct.currency = o; + } + }); + } + + if (this.action === 'view') { this.accountingMappings = this.loanProduct.accountingMappings; - this.paymentChannelToFundSourceMappings = this.loanProduct.paymentChannelToFundSourceMappings || []; + this.paymentChannelToFundSourceMappings = this.loanProduct.paymentChannelToFundSourceMappings || []; this.feeToIncomeAccountMappings = this.loanProduct.feeToIncomeAccountMappings || []; this.penaltyToIncomeAccountMappings = this.loanProduct.penaltyToIncomeAccountMappings || []; @@ -125,15 +136,49 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges { this.loanProductsTemplate.interestRecalculationFrequencyTypeOptions), preClosureInterestCalculationStrategy: this.optionDataLookUp(this.loanProduct.preClosureInterestCalculationStrategy, this.loanProductsTemplate.preClosureInterestCalculationStrategyOptions), - allowCompoundingOnEod: this.loanProduct.allowCompoundingOnEod, - isArrearsBasedOnOriginalSchedule: this.loanProduct.isArrearsBasedOnOriginalSchedule, - isCompoundingToBePostedAsTransaction: this.loanProduct.isCompoundingToBePostedAsTransaction, - recalculationRestFrequencyInterval: this.loanProduct.recalculationRestFrequencyInterval + allowCompoundingOnEod: this.loanProduct.allowCompoundingOnEod, + isArrearsBasedOnOriginalSchedule: this.loanProduct.isArrearsBasedOnOriginalSchedule, + isCompoundingToBePostedAsTransaction: this.loanProduct.isCompoundingToBePostedAsTransaction, + recalculationRestFrequencyInterval: this.loanProduct.recalculationRestFrequencyInterval }; } - } - this.isAdvancedPaymentAllocation = LoanProducts.isAdvancedPaymentAllocationStrategy(this.loanProduct.transactionProcessingStrategyCode); + let optionValue: OptionData = this.optionDataLookUp(this.loanProduct.amortizationType, this.loanProductsTemplate.amortizationTypeOptions); + this.loanProduct.amortizationType = optionValue; + + optionValue = this.optionDataLookUp(this.loanProduct.interestType, this.loanProductsTemplate.interestTypeOptions); + this.loanProduct.interestType = optionValue; + + optionValue = this.optionDataLookUp(this.loanProduct.interestCalculationPeriodType, this.loanProductsTemplate.interestCalculationPeriodTypeOptions); + this.loanProduct.interestCalculationPeriodType = optionValue; + + optionValue = this.optionDataLookUp(this.loanProduct.daysInMonthType, this.loanProductsTemplate.daysInMonthTypeOptions); + this.loanProduct.daysInMonthType = optionValue; + optionValue = this.optionDataLookUp(this.loanProduct.daysInYearType, this.loanProductsTemplate.daysInYearTypeOptions); + this.loanProduct.daysInYearType = optionValue; + optionValue = this.optionDataLookUp(this.loanProduct.interestRateFrequencyType, this.loanProductsTemplate.interestRateFrequencyTypeOptions); + this.loanProduct.interestRateFrequencyType = optionValue; + + optionValue = this.optionDataLookUp(this.loanProduct.repaymentStartDateType, this.loanProductsTemplate.repaymentStartDateTypeOptions); + this.loanProduct.repaymentStartDateType = optionValue; + + const codeValue: CodeName = this.codeNameLookUpByCode(this.loanProduct.transactionProcessingStrategyCode, + this.loanProductsTemplate.transactionProcessingStrategyOptions); + this.loanProduct.transactionProcessingStrategyName = codeValue.name; + + if (this.isAdvancedPaymentAllocation) { + + if (!this.loanProduct.loanScheduleProcessingType || !this.loanProduct.loanScheduleProcessingType.value) { + this.loanProduct.loanScheduleProcessingType = this.optionDataLookUpByCode(this.loanProduct.loanScheduleProcessingType, + this.loanProductsTemplate.loanScheduleProcessingTypeOptions); + } + + if (!this.loanProduct.loanScheduleType || !this.loanProduct.loanScheduleType.value) { + this.loanProduct.loanScheduleType = this.optionDataLookUpByCode(this.loanProduct.loanScheduleType, + this.loanProductsTemplate.loanScheduleTypeOptions); + } + } + } if (this.loanProduct.advancedPaymentAllocationTransactionTypes) { this.advancePaymentAllocationData = { @@ -148,10 +193,9 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges { futureInstallmentAllocationRules: this.loanProductsTemplate.advancedPaymentAllocationFutureInstallmentAllocationRules }; } - } - optionDataLookUp(itemId: number, optionsData: any[]): OptionData { + optionDataLookUp(itemId: any, optionsData: any[]): OptionData { let optionData: OptionData | null; optionsData.some((o: any) => { if (o.id === itemId) { @@ -165,12 +209,39 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges { return optionData; } + optionDataLookUpByCode(currentValue: any, optionsData: any[]): OptionData { + let optionData: OptionData | null; + optionsData.some((o: any) => { + if (o.code === currentValue) { + optionData = { + id: o.id || 0, + code: o.code, + value: o.value || o.name + }; + } + }); + return optionData; + } + + codeNameLookUpByCode(currentValue: any, optionsData: any[]): CodeName { + let optionData: CodeName | null; + optionsData.some((o: any) => { + if (o.code === currentValue) { + optionData = { + code: o.code, + name: o.name + }; + } + }); + return optionData; + } + glAccountLookUp(glAccountId: number, glAccounts: GLAccount[]): AccountingMapping { let accountMapping: AccountingMapping | null = null; if (glAccountId) { glAccounts.some((glAccount: GLAccount) => { if (glAccount.id === glAccountId) { - accountMapping = {id: glAccount.id, name: glAccount.name, glCode: glAccount.glCode}; + accountMapping = { id: glAccount.id, name: glAccount.name, glCode: glAccount.glCode }; } }); } @@ -182,7 +253,7 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges { if (chargeId) { charges.some((charge: Charge) => { if (charge.id === chargeId) { - chargeData = {id: charge.id, name: charge.name, penalty: charge.penalty}; + chargeData = { id: charge.id, name: charge.name, penalty: charge.penalty }; } }); } @@ -220,8 +291,4 @@ export class LoanProductSummaryComponent implements OnInit, OnChanges { || this.loanProduct.penaltyToIncomeAccountMappings?.length > 0); } - isAdvancedPaymentAllocationStrategy(): boolean { - return LoanProducts.isAdvancedPaymentAllocationStrategy(this.loanProduct.transactionProcessingStrategyCode); - } - } diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.ts b/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.ts index fe9358bc6..8c8441aa3 100644 --- a/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.ts +++ b/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.ts @@ -25,7 +25,9 @@ export class LoanProductPaymentStrategyStepComponent implements OnInit { constructor(private dialog: MatDialog, private advancedPaymentStrategy: AdvancedPaymentStrategy) { } - ngOnInit(): void { } + ngOnInit(): void { + this.sendPaymentAllocation(); + } sendPaymentAllocation(): void { const data = this.advancedPaymentStrategy.buildPaymentAllocations(this.advancedPaymentAllocations); diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-preview-step/loan-product-preview-step.component.html b/src/app/products/loan-products/loan-product-stepper/loan-product-preview-step/loan-product-preview-step.component.html index e9f38bdca..c80016c6a 100644 --- a/src/app/products/loan-products/loan-product-stepper/loan-product-preview-step/loan-product-preview-step.component.html +++ b/src/app/products/loan-products/loan-product-stepper/loan-product-preview-step/loan-product-preview-step.component.html @@ -1,5 +1,6 @@