Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Charge periods shown on bills in supplementary billing show all year #492

Merged
merged 4 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ async function _buildDataToPersist (billingData, billingPeriod, billRunExternalI
currentBillingData.bill,
currentBillingData.billLicence,
billRunExternalId,
cleansedTransactions,
billingPeriod
cleansedTransactions
)

dataToPersist.transactions.push(...transactions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down
Loading