rd account and rd product code update
This commit is contained in:
+5
-2
@@ -74,7 +74,8 @@
|
||||
<mifosx-recurring-deposits-account-interest-rate-chart-step
|
||||
[recurringDepositsAccountTemplate]="recurringDepositsAccountTemplate"
|
||||
[recurringDepositsAccountProductTemplate]="recurringDepositsAccountProductTemplate"
|
||||
[rdInterestRates]="rdInterestRates"
|
||||
[submittedOnDate]="submittedOnDate"
|
||||
(tenureSelected)="handleTenureSelected($event)"
|
||||
>
|
||||
</mifosx-recurring-deposits-account-interest-rate-chart-step>
|
||||
|
||||
@@ -97,11 +98,13 @@
|
||||
[recurringDepositsAccountTemplate]="recurringDepositsAccountTemplate"
|
||||
[recurringDepositsAccountProductTemplate]="recurringDepositsAccountProductTemplate"
|
||||
[recurringDepositAccountData]="recurringDepositAccountData"
|
||||
[rdInterestRates]="rdInterestRates"
|
||||
[rdNominee]="rdNominee"
|
||||
[rdCurrencyFlags]="rdCurrencyFlags"
|
||||
[rdTenureDays]="rdTenureDays"
|
||||
[rdApplicableSlab]="rdApplicableSlab"
|
||||
[rdMaturityAmount]="rdMaturityAmount"
|
||||
[rdInterestEarned]="rdInterestEarned"
|
||||
[rdDaysInYear]="rdDaysInYear"
|
||||
(submitEvent)="submit()"
|
||||
>
|
||||
</mifosx-recurring-deposits-account-preview-step>
|
||||
|
||||
+102
-28
@@ -75,8 +75,10 @@ export class CreateRecurringDepositsAccountComponent {
|
||||
recurringDepositsAccountTemplate: any;
|
||||
/** Recurring Deposit Account Product Template */
|
||||
recurringDepositsAccountProductTemplate: any;
|
||||
/** Active CBS base interest rate chart */
|
||||
rdInterestRates: any[] = [];
|
||||
/** Selected tenure value and frequency from calculator */
|
||||
selectedTenureValue: number | null = null;
|
||||
selectedTenureFrequencyId: number | null = null;
|
||||
selectedDepositAmount: number | null = null;
|
||||
|
||||
constructor() {
|
||||
this.route.data.subscribe((data: { recurringDepositsAccountTemplate: any }) => {
|
||||
@@ -90,14 +92,13 @@ export class CreateRecurringDepositsAccountComponent {
|
||||
*/
|
||||
setTemplate($event: any) {
|
||||
this.recurringDepositsAccountProductTemplate = $event;
|
||||
this.productsService.getRdBaseInterestRates().subscribe({
|
||||
next: (rates: any[]) => {
|
||||
this.rdInterestRates = rates || [];
|
||||
},
|
||||
error: () => {
|
||||
this.rdInterestRates = [];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Captures tenure selection from calculator */
|
||||
handleTenureSelected($event: any) {
|
||||
this.selectedTenureValue = $event.depositPeriod;
|
||||
this.selectedTenureFrequencyId = $event.depositPeriodFrequencyId;
|
||||
this.selectedDepositAmount = $event.depositAmount;
|
||||
}
|
||||
|
||||
/** Get Recurring Deposit Account Details Form Data */
|
||||
@@ -123,17 +124,31 @@ export class CreateRecurringDepositsAccountComponent {
|
||||
}
|
||||
|
||||
get rdTenureDays(): number | null {
|
||||
return this.recurringDepositsAccountChartStep?.tenureDays ?? null;
|
||||
return this.recurringDepositsAccountChartStep?.matchResult?.tenureDays ?? null;
|
||||
}
|
||||
|
||||
get rdApplicableSlab(): any | null {
|
||||
return this.recurringDepositsAccountChartStep?.applicableSlab ?? null;
|
||||
return this.recurringDepositsAccountChartStep?.matchResult?.slab ?? null;
|
||||
}
|
||||
|
||||
get rdMaturityAmount(): number | null {
|
||||
return this.recurringDepositsAccountChartStep?.matchResult?.maturityAmount ?? null;
|
||||
}
|
||||
|
||||
get rdInterestEarned(): number | null {
|
||||
return this.recurringDepositsAccountChartStep?.matchResult?.interestEarned ?? null;
|
||||
}
|
||||
|
||||
get rdDaysInYear(): number | null {
|
||||
return this.recurringDepositsAccountChartStep?.matchResult?.daysInYear ?? null;
|
||||
}
|
||||
|
||||
get submittedOnDate(): Date | null {
|
||||
return this.recurringDepositAccountDetailsForm?.value?.submittedOnDate ?? null;
|
||||
}
|
||||
|
||||
get rdCurrencyFlags() {
|
||||
return {
|
||||
balanceSwapOption: this.recurringDepositsAccountCurrencyStep?.balanceSwapOption ?? false,
|
||||
msme: this.recurringDepositsAccountCurrencyStep?.msme ?? false,
|
||||
autoDebitFacility: this.recurringDepositsAccountCurrencyStep?.autoDebitFacility ?? false
|
||||
};
|
||||
}
|
||||
@@ -145,34 +160,93 @@ export class CreateRecurringDepositsAccountComponent {
|
||||
const locale = this.settingsService.language.code;
|
||||
const dateFormat = this.settingsService.dateFormat;
|
||||
const monthDayFormat = 'dd MMMM';
|
||||
const pt = this.recurringDepositsAccountProductTemplate;
|
||||
|
||||
const details = this.recurringDepositAccount;
|
||||
const currencyStep = this.recurringDepositsAccountCurrencyStep;
|
||||
|
||||
// Terms — pulled from product template
|
||||
const terms: any = {};
|
||||
if (pt?.nominalAnnualInterestRate != null) terms.nominalAnnualInterestRate = pt.nominalAnnualInterestRate;
|
||||
if (pt?.interestCompoundingPeriodType?.id != null)
|
||||
terms.interestCompoundingPeriodType = pt.interestCompoundingPeriodType.id;
|
||||
if (pt?.interestPostingPeriodType?.id != null) terms.interestPostingPeriodType = pt.interestPostingPeriodType.id;
|
||||
if (pt?.interestCalculationType?.id != null) terms.interestCalculationType = pt.interestCalculationType.id;
|
||||
if (pt?.interestCalculationDaysInYearType?.id != null)
|
||||
terms.interestCalculationDaysInYearType = pt.interestCalculationDaysInYearType.id;
|
||||
|
||||
// Settings — pulled from product template
|
||||
const settings: any = {};
|
||||
if (pt?.lockinPeriodFrequency != null) settings.lockinPeriodFrequency = pt.lockinPeriodFrequency;
|
||||
if (pt?.lockinPeriodFrequencyType?.id != null) settings.lockinPeriodFrequencyType = pt.lockinPeriodFrequencyType.id;
|
||||
if (pt?.minDepositTerm != null) settings.minDepositTerm = pt.minDepositTerm;
|
||||
if (pt?.minDepositTermType?.id != null) settings.minDepositTermTypeId = pt.minDepositTermType.id;
|
||||
if (pt?.inMultiplesOfDepositTerm != null) settings.inMultiplesOfDepositTerm = pt.inMultiplesOfDepositTerm;
|
||||
if (pt?.inMultiplesOfDepositTermType?.id != null)
|
||||
settings.inMultiplesOfDepositTermTypeId = pt.inMultiplesOfDepositTermType.id;
|
||||
if (pt?.maxDepositTerm != null) settings.maxDepositTerm = pt.maxDepositTerm;
|
||||
if (pt?.maxDepositTermType?.id != null) settings.maxDepositTermTypeId = pt.maxDepositTermType.id;
|
||||
if (pt?.preClosurePenalApplicable != null) settings.preClosurePenalApplicable = pt.preClosurePenalApplicable;
|
||||
if (pt?.preClosurePenalInterest != null) settings.preClosurePenalInterest = pt.preClosurePenalInterest;
|
||||
if (pt?.preClosurePenalInterestOnType?.id != null)
|
||||
settings.preClosurePenalInterestOnTypeId = pt.preClosurePenalInterestOnType.id;
|
||||
if (pt?.maturityInstructionId != null) settings.maturityInstructionId = pt.maturityInstructionId;
|
||||
if (pt?.transferInterestToSavings != null) settings.transferInterestToSavings = pt.transferInterestToSavings;
|
||||
if (pt?.withHoldTax != null) settings.withHoldTax = pt.withHoldTax;
|
||||
|
||||
// Flags and other product defaults
|
||||
const productDefaults: any = {
|
||||
isCalendarInherited: pt?.isCalendarInherited ?? false,
|
||||
isMandatoryDeposit: pt?.isMandatoryDeposit ?? false,
|
||||
allowWithdrawal: pt?.allowWithdrawal ?? false,
|
||||
adjustAdvanceTowardsFuturePayments: pt?.adjustAdvanceTowardsFuturePayments ?? false,
|
||||
autoDebitFacility: currencyStep?.autoDebitFacility ?? pt?.autoDebitFacility ?? false
|
||||
};
|
||||
|
||||
// Charges from product template
|
||||
const rawCharges: any[] = pt?.charges ?? [];
|
||||
|
||||
const recurringDepositAccount: any = {
|
||||
...details,
|
||||
...terms,
|
||||
...settings,
|
||||
...productDefaults,
|
||||
clientId: this.recurringDepositsAccountTemplate.clientId,
|
||||
charges: [],
|
||||
isCalendarInherited: false,
|
||||
mandatoryRecommendedDepositAmount: 0,
|
||||
recurringFrequency: 1,
|
||||
recurringFrequencyType: 2,
|
||||
mandatoryRecommendedDepositAmount: pt?.minDepositAmount ?? 0,
|
||||
recurringFrequency: pt?.recurringFrequency ?? 1,
|
||||
recurringFrequencyType: pt?.recurringFrequencyType ?? 2, // Monthly
|
||||
submittedOnDate: this.dateUtils.formatDate(details.submittedOnDate, dateFormat),
|
||||
expectedFirstDepositOnDate: this.dateUtils.formatDate(details.expectedFirstDepositOnDate, dateFormat),
|
||||
dateFormat,
|
||||
monthDayFormat,
|
||||
locale,
|
||||
// Currency step overrides
|
||||
balanceSwapOption: currencyStep?.balanceSwapOption ?? details.balanceSwapOption ?? false,
|
||||
msme: currencyStep?.msme ?? details.msme ?? false,
|
||||
autoDebitFacility: currencyStep?.autoDebitFacility ?? details.autoDebitFacility ?? false
|
||||
charts: [
|
||||
{
|
||||
chartSlabs:
|
||||
pt?.accountChart?.chartSlabs ?? pt?.activeChart?.chartSlabs ?? pt?.interestRateCharts?.[0]?.chartSlabs ?? []
|
||||
}
|
||||
],
|
||||
charges: rawCharges.map((charge: any) => ({
|
||||
chargeId: charge.chargeId ?? charge.id,
|
||||
amount: charge.amount,
|
||||
dueDate: charge.dueDate && this.dateUtils.formatDate(charge.dueDate, dateFormat),
|
||||
feeOnMonthDay: charge.feeOnMonthDay,
|
||||
feeInterval: charge.feeInterval
|
||||
}))
|
||||
};
|
||||
|
||||
// Tenure from interest rate chart step (depositPeriod in days)
|
||||
const tenureDays = this.rdTenureDays;
|
||||
if (tenureDays && tenureDays > 0) {
|
||||
recurringDepositAccount.depositPeriod = tenureDays;
|
||||
recurringDepositAccount.depositPeriodFrequencyId = 0; // 0 = Days
|
||||
// Tenure override from interest rate chart calculator
|
||||
if (this.selectedTenureValue && this.selectedTenureFrequencyId !== null) {
|
||||
recurringDepositAccount.depositPeriod = this.selectedTenureValue;
|
||||
recurringDepositAccount.depositPeriodFrequencyId = this.selectedTenureFrequencyId;
|
||||
} else if (this.rdTenureDays) {
|
||||
recurringDepositAccount.depositPeriod = this.rdTenureDays;
|
||||
recurringDepositAccount.depositPeriodFrequencyId = 0; // Days
|
||||
}
|
||||
|
||||
// Amount override from calculator if provided
|
||||
if (this.selectedDepositAmount) {
|
||||
recurringDepositAccount.mandatoryRecommendedDepositAmount = this.selectedDepositAmount;
|
||||
}
|
||||
|
||||
// Nominee from currency step
|
||||
|
||||
Reference in New Issue
Block a user