diff --git a/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-accounting-step/recurring-deposit-product-accounting-step.component.ts b/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-accounting-step/recurring-deposit-product-accounting-step.component.ts index 7f20525e7..4b2457882 100644 --- a/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-accounting-step/recurring-deposit-product-accounting-step.component.ts +++ b/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-accounting-step/recurring-deposit-product-accounting-step.component.ts @@ -175,18 +175,13 @@ export class RecurringDepositProductAccountingStepComponent implements OnInit { if (this.isCashOrAccrualAccounting()) { const glMappings = mappings.otherGlMappingsMap || mappings.otherGlMappings; this.setOtherGlMappings('assetsOtherGlMappings', glMappings?.assets || [], this.assetAccountOptions); - // Interest Paid is a liability clearing account (Dr Payable / Cr Paid, then Dr Paid / Cr RD), saved under - // liabilities. Products saved before that kept it under expenses, so both groups are read. - const fromLiabilities = this.extractNamedGlMapping( - this.extractNamedGlMapping( - glMappings?.liabilities || [], - RECURRING_DEPOSIT_INTEREST_PAID_ACCOUNT_NAME, - 'savingsInterestPaidAccountId', - this.liabilityAccountOptions - ), - SAVINGS_INTEREST_PAID_ACCOUNT_NAME, - 'savingsInterestPaidAccountId', - this.liabilityAccountOptions + // Interest Paid sits under expenses, as on the fixed deposit and savings products (the backend finds it by name + // in any group). Products saved while it was under liabilities are read from there too, so the name is not + // left behind as an "other" liability row; a liability GL chosen then has to be picked again from expenses. + const fromLiabilities = (glMappings?.liabilities || []).filter( + (mapping: any) => + mapping?.accountName !== RECURRING_DEPOSIT_INTEREST_PAID_ACCOUNT_NAME && + mapping?.accountName !== SAVINGS_INTEREST_PAID_ACCOUNT_NAME ); this.setOtherGlMappings('liabilitiesOtherGlMappings', fromLiabilities, this.liabilityAccountOptions); const fromExpenses = this.extractNamedGlMapping( @@ -277,15 +272,15 @@ export class RecurringDepositProductAccountingStepComponent implements OnInit { const otherGlMappings = { assets: map('assetsOtherGlMappings', this.assetAccountOptions), - liabilities: [ + liabilities: map('liabilitiesOtherGlMappings', this.liabilityAccountOptions), + expenses: [ ...namedAsOtherGlMapping( 'savingsInterestPaidAccountId', RECURRING_DEPOSIT_INTEREST_PAID_ACCOUNT_NAME, - this.liabilityAccountOptions + this.expenseAccountOptions ), - ...map('liabilitiesOtherGlMappings', this.liabilityAccountOptions) + ...map('expensesOtherGlMappings', this.expenseAccountOptions) ], - expenses: map('expensesOtherGlMappings', this.expenseAccountOptions), income: map('incomeOtherGlMappings', this.incomeAccountOptions) }; return Object.values(otherGlMappings).some((v) => v.length) ? otherGlMappings : null; @@ -393,7 +388,8 @@ export class RecurringDepositProductAccountingStepComponent implements OnInit { }, // Offered on cash as well as accrual: the interest credited at maturity or premature closure is routed // Dr Interest On Recurring Deposits / Cr Payable, Dr Payable / Cr Interest Paid, Dr Interest Paid / Cr - // the RD. Optional - a product naming neither posts straight to the control account as before. + // the RD. Optional - a product naming neither posts straight to the control account as before. Interest + // Paid itself is under Expenses. { key: 'interestPayableAccountId', label: 'Interest Payable Account', @@ -401,13 +397,6 @@ export class RecurringDepositProductAccountingStepComponent implements OnInit { controlName: 'interestPayableAccountId', options: this.liabilityAccountOptions }, - { - key: 'savingsInterestPaidAccountId', - label: 'Recurring Deposit Interest Paid', - inputLabel: 'Recurring deposit interest paid', - controlName: 'savingsInterestPaidAccountId', - options: this.liabilityAccountOptions - }, { key: 'escheatLiabilityId', label: 'Escheat Liability Account', @@ -433,6 +422,13 @@ export class RecurringDepositProductAccountingStepComponent implements OnInit { controlName: 'interestOnSavingsAccountId', options: this.expenseAccountOptions, required: true + }, + { + key: 'savingsInterestPaidAccountId', + label: 'Recurring Deposit Interest Paid', + inputLabel: 'Recurring deposit interest paid', + controlName: 'savingsInterestPaidAccountId', + options: this.expenseAccountOptions } ], otherMappingsControlName: 'expensesOtherGlMappings',