Skip to content

Commit

Permalink
Remove abstraction text for under query licence (#736)
Browse files Browse the repository at this point in the history
https://eaflood.atlassian.net/browse/WATER-4191

During the testing for the review licence page in a twp part tariff bill run, it was discussed in a blocker review the text for a return that is under query. Currently if a return is under query it shows a text box stating the return is either fully abstracted or over abstracted. This is wrong as a return that is under query is not allocated on the charge element and therefore does not meet any of those definitions. This change is to remove that text box for returns under query. This change also includes content changes on the page for unmatched returns. This is since an unmatched return would not be allocated to a charge element so we are removing the allocated text field.
  • Loading branch information
Beckyrose200 authored Feb 14, 2024
1 parent 70352f8 commit 4c6da68
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function go (matchedReturns, unmatchedReturns, chargePeriods, billRun, licenceRe
return {
licenceRef,
billRunId: billRun.id,
status: 'Review',
status: 'review',
region: billRun.region.displayName,
matchedReturns: _prepareMatchedReturns(matchedReturns),
unmatchedReturns: _prepareUnmatchedReturns(unmatchedReturns),
Expand All @@ -40,22 +40,22 @@ function _prepareLicenceChargePeriods (chargePeriods) {

function _prepareUnmatchedReturns (unmatchedReturns) {
return unmatchedReturns.map((unmatchedReturn) => {
const { returnReference, status, description, purposes, allocated, quantity, startDate, endDate } = unmatchedReturn.reviewReturnResults
const { returnReference, status, description, purposes, quantity, startDate, endDate } = unmatchedReturn.reviewReturnResults

return {
reference: returnReference,
dates: _prepareDate(startDate, endDate),
status,
description,
purpose: purposes[0].tertiary.description,
total: `${allocated} ML / ${quantity} ML`
total: `${quantity} ML`
}
})
}

function _prepareMatchedReturns (matchedReturns) {
return matchedReturns.map((matchedReturn) => {
const { returnStatus, total, allocated } = _checkStatusAndReturnTotal(matchedReturn)
const { returnStatus, total } = _checkStatusAndReturnTotal(matchedReturn)
const { returnReference, description, purposes, startDate, endDate } = matchedReturn.reviewReturnResults

return {
Expand All @@ -65,35 +65,36 @@ function _prepareMatchedReturns (matchedReturns) {
description,
purpose: purposes[0].tertiary.description,
total,
allocated
allocated: _allocated(matchedReturn)
}
})
}

function _checkStatusAndReturnTotal (returnLog) {
const { status, allocated, quantity, underQuery } = returnLog.reviewReturnResults

let allocatedStatus
let total
let returnStatus = underQuery ? 'query' : status

if (status === 'void' || status === 'received') {
total = '/'
allocatedStatus = 'Not processed'
} else if (status === 'due') {
returnStatus = 'overdue'
total = '/'
allocatedStatus = 'Not processed'
} else {
total = `${allocated} ML / ${quantity} ML`
allocatedStatus = _allocated(quantity, allocated)
}

return { returnStatus, total, allocated: allocatedStatus }
return { returnStatus, total }
}

function _allocated (quantity, allocated) {
if (quantity > allocated) {
function _allocated (returnLog) {
const { quantity, allocated, status, underQuery } = returnLog.reviewReturnResults
if (underQuery) {
return ''
} else if (status === 'void' || status === 'received' || status === 'due') {
return 'Not processed'
} else if (quantity > allocated) {
return 'Over abstraction'
} else {
return 'Fully allocated'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Review Licence presenter', () => {
expect(result).to.equal({
licenceRef: '7/34/10/*S/0084',
billRunId: '6620135b-0ecf-4fd4-924e-371f950c0526',
status: 'Review',
status: 'review',
region: 'Anglian',
matchedReturns: [
{
Expand Down Expand Up @@ -57,11 +57,20 @@ describe('Review Licence presenter', () => {
{
reference: '10042951',
dates: '1 April 2022 to 31 March 2023',
status: 'query',
status: 'complete',
description: 'Ormesby Broad - Point 1',
purpose: 'Spray Irrigation - Storage',
total: '1 ML / 10 ML',
allocated: 'Over abstraction'
},
{
reference: '10042951',
dates: '1 April 2022 to 31 March 2023',
status: 'query',
description: 'Ormesby Broad - Point 1',
purpose: 'Spray Irrigation - Storage',
total: '0 ML / 10 ML',
allocated: ''
}
],
unmatchedReturns: [
Expand All @@ -71,7 +80,7 @@ describe('Review Licence presenter', () => {
status: 'completed',
description: 'Ormesby Broad - Point 1',
purpose: 'Spray Irrigation - Storage',
total: '0 ML / 20 ML'
total: '20 ML'
}
],
chargePeriodDates: ['1 April 2022 to 31 March 2023']
Expand Down Expand Up @@ -190,7 +199,7 @@ function _matchingReturns () {
dueDate: new Date('2023-04-28'),
receivedDate: null,
status: 'complete',
underQuery: true,
underQuery: false,
nilReturn: false,
description: 'Ormesby Broad - Point 1',
purposes: [{
Expand All @@ -205,6 +214,32 @@ function _matchingReturns () {
licence: {
licenceRef: '7/34/10/*S/0084'
}
},
{
chargePeriodStartDate: new Date('2022-04-01'),
chargePeriodEndDate: new Date('2023-03-31'),
reviewReturnResults: {
returnReference: '10042951',
startDate: new Date('2022-04-01'),
endDate: new Date('2023-03-31'),
dueDate: new Date('2023-04-28'),
receivedDate: null,
status: 'complete',
underQuery: true,
nilReturn: false,
description: 'Ormesby Broad - Point 1',
purposes: [{
tertiary: {
description: 'Spray Irrigation - Storage'
}
}],
quantity: 10,
allocated: 0,
abstractionOutsidePeriod: false
},
licence: {
licenceRef: '7/34/10/*S/0084'
}
}
]
}
Expand Down

0 comments on commit 4c6da68

Please sign in to comment.