Skip to content

Commit

Permalink
Exclude VOID returns from two-part tariff billing (#1419)
Browse files Browse the repository at this point in the history
https://eaflood.atlassian.net/browse/WATER-4709

> Part of our work implementing SROC two-part tariff billing

A request has come from our users after testing the current iteration of reviewing the matches and allocations for a two-part tariff return.

They are satisfied we don't include VOID return logs in the allocation results. But they would rather we exclude them from the process completely. Then, we wouldn't see them in the results, as they seem to make things confusing.

This change excludes VOID return logs (returns that have been replaced because of changes) from the two-part tariff match and allocate process.

---------

Co-authored-by: Jason Claxton <[email protected]>
Co-authored-by: Becky Ransome <[email protected]>
  • Loading branch information
3 people authored Oct 17, 2024
1 parent d4939f1 commit 29eea30
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function _prepareDate (startDate, endDate) {
function _returnLinkAndTotal (returnLog) {
const { returnStatus, allocated, quantity } = returnLog

if (['due', 'received', 'void'].includes(returnStatus)) {
if (['due', 'received'].includes(returnStatus)) {
return { returnTotal: '/', returnLink: `/return/internal?returnId=${returnLog.returnId}` }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ function _prepareReturnVolume (reviewChargeElement) {
reviewReturns.forEach((reviewReturn) => {
if (reviewReturn.returnStatus === 'due') {
returnVolumes.push(`overdue (${reviewReturn.returnReference})`)
} else if (reviewReturn.returnStatus === 'void') {
returnVolumes.push(`void (${reviewReturn.returnReference})`)
} else {
returnVolumes.push(`${reviewReturn.quantity} ML (${reviewReturn.returnReference})`)
}
Expand All @@ -262,7 +260,7 @@ function _prepareReturnVolume (reviewChargeElement) {
}

function _returnLink (returnLog) {
if (['due', 'received', 'void'].includes(returnLog.returnStatus)) {
if (['due', 'received'].includes(returnLog.returnStatus)) {
return `/return/internal?returnId=${returnLog.returnId}`
}

Expand All @@ -284,7 +282,7 @@ function _returnStatus (returnLog) {
function _returnTotal (returnLog) {
const { returnStatus, allocated, quantity } = returnLog

if (['due', 'received', 'void'].includes(returnStatus)) {
if (['due', 'received'].includes(returnStatus)) {
return '/'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ async function _fetch (licenceRef, billingPeriod) {
// water-abstraction-service filters out old return logs in this way: see
// `src/lib/services/returns/api-connector.js`
.where('startDate', '>=', '2008-04-01')
.whereNot('status', 'void')
.where('endDate', '>=', billingPeriod.startDate)
.where('endDate', '<=', billingPeriod.endDate)
.whereJsonPath('metadata', '$.isTwoPartTariff', '=', true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,37 +178,6 @@ describe('Review Licence presenter', () => {
expect(result.matchedReturns[0].returnLink).to.equal('/return/internal?returnId=v1:1:01/60/28/3437:17061181:2022-04-01:2023-03-31')
})
})

describe('when a return has a status of "void"', () => {
beforeEach(() => {
licence[0].reviewReturns[0].returnStatus = 'void'
licence[0].reviewChargeVersions[0].reviewChargeReferences[0].reviewChargeElements[0].reviewReturns[0].returnStatus = 'void'
})

it('changes the status text to "void"', () => {
const result = ReviewLicencePresenter.go(billRun, licence)

expect(result.matchedReturns[0].returnStatus).to.equal('void')
})

it('formats the returns total correctly', () => {
const result = ReviewLicencePresenter.go(billRun, licence)

expect(result.matchedReturns[0].returnTotal).to.equal('/')
})

it('formats the charge elements return total correctly', () => {
const result = ReviewLicencePresenter.go(billRun, licence)

expect(result.chargeData[0].chargeReferences[0].chargeElements[0].returnVolume).to.equal(['void (10031343)'])
})

it('formats the returns link correctly', () => {
const result = ReviewLicencePresenter.go(billRun, licence)

expect(result.matchedReturns[0].returnLink).to.equal('/return/internal?returnId=v1:1:01/60/28/3437:17061181:2022-04-01:2023-03-31')
})
})
})

describe('the "underQuery" property', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,7 @@ describe('Fetch Return Logs for Licence service', () => {

describe('when there are valid return logs that should be considered', () => {
beforeEach(async () => {
const metadata = {
nald: {
periodEndDay: '31',
periodEndMonth: '3',
periodStartDay: '1',
periodStartMonth: '4'
},
purposes: [
{
tertiary: {
code: '400',
description: 'Spray Irrigation - Direct'
}
}
],
description: 'The Description',
isTwoPartTariff: true
}

returnLogRecord = await ReturnLogHelper.add({ metadata })
returnLogRecord = await ReturnLogHelper.add({ metadata: _metadata(true) })
})

describe('which have return submission lines within the billing period', () => {
Expand Down Expand Up @@ -205,26 +186,7 @@ describe('Fetch Return Logs for Licence service', () => {

describe('because the return log is not two-part-tariff', () => {
beforeEach(async () => {
const metadata = {
nald: {
periodEndDay: '31',
periodEndMonth: '3',
periodStartDay: '1',
periodStartMonth: '4'
},
purposes: [
{
tertiary: {
code: '400',
description: 'Spray Irrigation - Direct'
}
}
],
description: 'The Description',
isTwoPartTariff: false
}

returnLogRecord = await ReturnLogHelper.add({ metadata })
returnLogRecord = await ReturnLogHelper.add({ metadata: _metadata(false) })
const { id } = returnLogRecord

await ReturnSubmissionHelper.add({ returnLogId: id })
Expand All @@ -245,5 +207,42 @@ describe('Fetch Return Logs for Licence service', () => {
expect(result).to.have.length(0)
})
})

describe('because the return is void', () => {
beforeEach(async () => {
returnLogRecord = await ReturnLogHelper.add({ metadata: _metadata(true), status: 'void' })
const { id } = returnLogRecord

await ReturnSubmissionHelper.add({ returnLogId: id })
})

it('returns no records', async () => {
const { licenceRef } = returnLogRecord
const result = await FetchReturnLogsForLicenceService.go(licenceRef, billingPeriod)

expect(result).to.have.length(0)
})
})
})
})

function _metadata (isTwoPartTariff) {
return {
nald: {
periodEndDay: '31',
periodEndMonth: '3',
periodStartDay: '1',
periodStartMonth: '4'
},
purposes: [
{
tertiary: {
code: '400',
description: 'Spray Irrigation - Direct'
}
}
],
description: 'The Description',
isTwoPartTariff
}
}

0 comments on commit 29eea30

Please sign in to comment.