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

Add changeReason to two-part-tariff fetch-charge-versions service #603

Merged
merged 3 commits into from
Dec 18, 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 @@ -80,6 +80,12 @@ async function _fetch (regionCode, billingPeriod) {
.whereJsonPath('chargeReferences.adjustments', '$.s127', '=', true)
)
.orderBy('chargeVersions.licenceRef')
.withGraphFetched('changeReason')
.modifyGraph('changeReason', (builder) => {
builder.select([
'description'
])
})
.withGraphFetched('licence')
.modifyGraph('licence', (builder) => {
builder.select([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const { describe, it, beforeEach } = exports.lab = Lab.script()
const { expect } = Code

// Test helpers
const ChangeReasonHelper = require('../../../support/helpers/change-reason.helper.js')
const ChargeCategoryHelper = require('../../../support/helpers/charge-category.helper.js')
const ChargeElementHelper = require('../../../support/helpers/charge-element.helper.js')
const ChargeReferenceHelper = require('../../../support/helpers/charge-reference.helper.js')
Expand Down Expand Up @@ -49,10 +50,12 @@ describe('Fetch Charge Versions service', () => {
const chargeVersionId = '2c2f0ab5-4f73-416e-b3f8-5ed19d81bd59'

beforeEach(async () => {
const { id: changeReasonId } = await ChangeReasonHelper.add()

// NOTE: The first part of the setup creates a charge version we will test exactly matches what we expect. The
// second part is to create another charge version with a different licence ref so we can test the order of the
// results
await ChargeVersionHelper.add({ id: chargeVersionId, licenceId, licenceRef, regionCode })
await ChargeVersionHelper.add({ id: chargeVersionId, licenceId, licenceRef, regionCode, changeReasonId })

const { id: chargeReferenceId } = await ChargeReferenceHelper.add({
id: 'a86837fa-cf25-42fe-8216-ea8c2d2c939d',
Expand Down Expand Up @@ -81,7 +84,7 @@ describe('Fetch Charge Versions service', () => {
// Second charge version to test ordering
const otherLicence = await LicenceHelper.add({ licenceRef: '01/130', regionId })
const chargeVersion = await ChargeVersionHelper.add(
{ licenceId: otherLicence.id, licenceRef: '01/130', regionCode }
{ licenceId: otherLicence.id, licenceRef: '01/130', regionCode, changeReasonId }
)
const chargeReference = await ChargeReferenceHelper.add({
chargeVersionId: chargeVersion.id,
Expand Down Expand Up @@ -153,7 +156,10 @@ describe('Fetch Charge Versions service', () => {
}
}
]
}]
}],
changeReason: {
description: 'Strategic review of charges (SRoC)'
}
})
})

Expand Down
Loading