From ec6f76ba899a11b5a186cfedefa456f05f28824a Mon Sep 17 00:00:00 2001 From: Jason Claxton Date: Wed, 1 Nov 2023 15:13:47 +0000 Subject: [PATCH 1/3] Charge periods shown on bills are incorrect https://eaflood.atlassian.net/browse/WATER-4179 It has been reported by a customer that that the charge period shown on a recent supplementary bill they received showed the whole financial year as a charge period, rather than the dates related to the charge versions and financial years. The data passed to the charge module for supplementary appears to be using the financial year dates in all circumstances, when it should be using the charge period dates as shown on the transaction screen. This PR will fix that issue by passing the correct dates to the CM. From 7a828d63cb404a5e9bf96b66ac91c68111a1c69d Mon Sep 17 00:00:00 2001 From: Jason Claxton Date: Wed, 1 Nov 2023 16:41:55 +0000 Subject: [PATCH 2/3] Fix dates --- .../charging-module/create-transaction.presenter.js | 6 +++--- .../billing/supplementary/process-billing-period.service.js | 3 +-- .../billing/supplementary/send-transactions.service.js | 6 ++---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/app/presenters/charging-module/create-transaction.presenter.js b/app/presenters/charging-module/create-transaction.presenter.js index 7c8633f2fb..7f73d2d129 100644 --- a/app/presenters/charging-module/create-transaction.presenter.js +++ b/app/presenters/charging-module/create-transaction.presenter.js @@ -12,9 +12,9 @@ const { formatChargingModuleDate } = require('../base.presenter.js') * * @returns {Object} an object to be used as the body in a Charging Module POST transaction request */ -function go (transaction, billingPeriod, invoiceAccountNumber, licence) { - const periodStart = formatChargingModuleDate(billingPeriod.startDate) - const periodEnd = formatChargingModuleDate(billingPeriod.endDate) +function go (transaction, invoiceAccountNumber, licence) { + const periodStart = formatChargingModuleDate(transaction.startDate) + const periodEnd = formatChargingModuleDate(transaction.endDate) return { clientId: transaction.billingTransactionId, diff --git a/app/services/billing/supplementary/process-billing-period.service.js b/app/services/billing/supplementary/process-billing-period.service.js index 786f9d72d9..052a1215d3 100644 --- a/app/services/billing/supplementary/process-billing-period.service.js +++ b/app/services/billing/supplementary/process-billing-period.service.js @@ -66,8 +66,7 @@ async function _buildDataToPersist (billingData, billingPeriod, billRunExternalI currentBillingData.bill, currentBillingData.billLicence, billRunExternalId, - cleansedTransactions, - billingPeriod + cleansedTransactions ) dataToPersist.transactions.push(...transactions) diff --git a/app/services/billing/supplementary/send-transactions.service.js b/app/services/billing/supplementary/send-transactions.service.js index fe2ccf80bd..14d0f87f44 100644 --- a/app/services/billing/supplementary/send-transactions.service.js +++ b/app/services/billing/supplementary/send-transactions.service.js @@ -24,14 +24,13 @@ const ChargingModuleCreateTransactionPresenter = require('../../../presenters/ch * * @returns {Object[]} Array of transactions which have been sent to the Charging Module */ -async function go (licence, bill, billLicence, billRunExternalId, transactions, billingPeriod) { +async function go (licence, bill, billLicence, billRunExternalId, transactions) { try { const sentTransactions = [] for (const transaction of transactions) { const chargingModuleResponse = await _sendTransactionToChargingModule( transaction, - billingPeriod, bill, licence, billRunExternalId @@ -48,10 +47,9 @@ async function go (licence, bill, billLicence, billRunExternalId, transactions, } } -async function _sendTransactionToChargingModule (transaction, billingPeriod, bill, licence, billRunExternalId) { +async function _sendTransactionToChargingModule (transaction, bill, licence, billRunExternalId) { const chargingModuleRequest = ChargingModuleCreateTransactionPresenter.go( transaction, - billingPeriod, bill.invoiceAccountNumber, licence ) From 120642cb75b8f0bb1bff2157973fab0b47dde57c Mon Sep 17 00:00:00 2001 From: Jason Claxton Date: Wed, 1 Nov 2023 16:58:55 +0000 Subject: [PATCH 3/3] Fix test --- .../charging-module/create-transaction.presenter.test.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/presenters/charging-module/create-transaction.presenter.test.js b/test/presenters/charging-module/create-transaction.presenter.test.js index 71c7341653..c7e9aea583 100644 --- a/test/presenters/charging-module/create-transaction.presenter.test.js +++ b/test/presenters/charging-module/create-transaction.presenter.test.js @@ -19,10 +19,6 @@ const TransactionHelper = require('../../support/helpers/water/transaction.helpe const CreateTransactionPresenter = require('../../../app/presenters/charging-module/create-transaction.presenter.js') describe('Charging Module Create Transaction presenter', () => { - const billingPeriod = { - startDate: new Date('2022-04-01'), - endDate: new Date('2023-03-31') - } const invoiceAccountNumber = 'A51542397A' let transaction @@ -69,10 +65,12 @@ describe('Charging Module Create Transaction presenter', () => { transaction.chargeCategoryCode = '4.5.6' transaction.section127Agreement = false transaction.section130Agreement = false + transaction.startDate = new Date('2022-04-01') + transaction.endDate = new Date('2023-03-31') }) it('correctly presents the data', () => { - const result = CreateTransactionPresenter.go(transaction, billingPeriod, invoiceAccountNumber, licence) + const result = CreateTransactionPresenter.go(transaction, invoiceAccountNumber, licence) expect(result.clientId).to.equal(transaction.billingTransactionId) expect(result.ruleset).to.equal('sroc')