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

Handle soft deleted workflow in supp. billing #213

Merged
merged 5 commits into from
May 5, 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 @@ -47,6 +47,7 @@ async function _fetch (regionId, billingPeriod) {
ChargeVersionWorkflow.query()
.select(1)
.whereColumn('chargeVersions.licenceId', 'chargeVersionWorkflows.licenceId')
.whereNull('chargeVersionWorkflows.dateDeleted')
)
.orderBy([
{ column: 'chargeVersions.invoiceAccountId' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,21 @@ describe('Fetch Charge Versions service', () => {
let chargeElement
let chargePurpose
let changeReason
let licence

beforeEach(async () => {
billingPeriod = {
startDate: new Date('2022-04-01'),
endDate: new Date('2023-03-31')
}

const { licenceId } = await LicenceHelper.add({
licence = await LicenceHelper.add({
regionId,
isWaterUndertaker: true,
includeInSrocSupplementaryBilling: true,
includeInSupplementaryBilling: 'yes'
})
const { licenceId } = licence
changeReason = await ChangeReasonHelper.add({ triggersMinimumCharge: true })

// This creates a 'current' SROC charge version
Expand Down Expand Up @@ -87,6 +89,20 @@ describe('Fetch Charge Versions service', () => {
})
})

describe('including those linked to soft-deleted workflow records', () => {
beforeEach(async () => {
await ChargeVersionWorkflowHelper.add({ licenceId: licence.licenceId, dateDeleted: new Date('2022-04-01') })
})

it('returns the SROC charge versions that are applicable', async () => {
const result = await FetchChargeVersionsService.go(regionId, billingPeriod)

expect(result).to.have.length(2)
expect(result[0].chargeVersionId).to.equal(testRecords[0].chargeVersionId)
expect(result[1].chargeVersionId).to.equal(testRecords[1].chargeVersionId)
})
})

it("returns both 'current' and 'superseded' SROC charge versions that are applicable", async () => {
const result = await FetchChargeVersionsService.go(regionId, billingPeriod)

Expand Down