Skip to content

Commit

Permalink
Add charge reference links to licence review page (#936)
Browse files Browse the repository at this point in the history
This PR is an enhancement to the licence review page for two-part tariff bill runs. It is adding a dynamic link to the charge references being displayed. The link will display 1 of two pieces of text depending on if the charge reference has either an aggregate value or a charge adjustment factor. If it does it will display 'Change details' and if it doesn't then 'view details'.
  • Loading branch information
Beckyrose200 authored Apr 30, 2024
1 parent a228ea8 commit 64a23d1
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,24 @@ function _chargeReferenceDetails (reviewChargeVersion, chargePeriod) {
chargeCategory: `Charge reference ${reviewChargeReference.chargeReference.chargeCategory.reference}`,
chargeDescription: reviewChargeReference.chargeReference.chargeCategory.shortDescription,
totalBillableReturns: _totalBillableReturns(reviewChargeReference),
chargeReferenceLink: _chargeReferenceLink(reviewChargeReference),
chargeElements: _chargeElementDetails(reviewChargeReference, chargePeriod)
})
})

return chargeReference
}

function _chargeReferenceLink (reviewChargeReference) {
const { chargeAdjustment, aggregate } = reviewChargeReference

if (chargeAdjustment !== 1 || aggregate !== 1) {
return { linkName: 'Change details' }
}

return { linkName: 'View details' }
}

function _contactName (billingAccount) {
const contact = billingAccount.billingAccountAddresses[0].contact

Expand Down
8 changes: 8 additions & 0 deletions app/views/bill-runs/review-licence.njk
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,14 @@
value: {
text: chargeReference.totalBillableReturns,
attributes: { 'data-test': 'total-billable-returns' }
},
actions: {
items: [
{
href: "#",
text: chargeReference.chargeReferenceLink.linkName
}
]
}
}
%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ describe('Review Licence presenter', () => {
chargeCategory: 'Charge reference 4.6.7',
chargeDescription: 'High loss, non-tidal, greater than 15 up to and including 50 ML/yr',
totalBillableReturns: '0 ML / 200 ML',
chargeReferenceLink: { linkName: 'View details' },
chargeElements: [
{
elementNumber: 'Element 1 of 1',
Expand Down Expand Up @@ -181,6 +182,53 @@ describe('Review Licence presenter', () => {
})
})
})

describe("the 'adjustment' property's", () => {
describe('when a review charge reference has an aggregate', () => {
beforeEach(() => {
licence[0].reviewChargeVersions[0].reviewChargeReferences[0].aggregate = 0.5
})

it("changes the chargeReferenceLink to 'Change details'", () => {
const result = ReviewLicencePresenter.go(billRun, licence)

expect(result.chargeData[0].chargeReferences[0].chargeReferenceLink.linkName).to.equal('Change details')
})
})

describe('when a review charge reference has a charge factor adjustment', () => {
beforeEach(() => {
licence[0].reviewChargeVersions[0].reviewChargeReferences[0].chargeAdjustment = 0.5
})

it("changes the chargeReferenceLink to 'Change details'", () => {
const result = ReviewLicencePresenter.go(billRun, licence)

expect(result.chargeData[0].chargeReferences[0].chargeReferenceLink.linkName).to.equal('Change details')
})
})

describe('when a review charge reference has an aggregate and charge factor adjustment', () => {
beforeEach(() => {
licence[0].reviewChargeVersions[0].reviewChargeReferences[0].aggregate = 0.5
licence[0].reviewChargeVersions[0].reviewChargeReferences[0].chargeAdjustment = 0.5
})

it("changes the chargeReferenceLink to 'Change details'", () => {
const result = ReviewLicencePresenter.go(billRun, licence)

expect(result.chargeData[0].chargeReferences[0].chargeReferenceLink.linkName).to.equal('Change details')
})
})

describe('when a review charge reference does not have an aggregate or charge factor adjustment', () => {
it("changes the chargeReferenceLink to 'View details'", () => {
const result = ReviewLicencePresenter.go(billRun, licence)

expect(result.chargeData[0].chargeReferences[0].chargeReferenceLink.linkName).to.equal('View details')
})
})
})
})
})

Expand Down Expand Up @@ -274,6 +322,7 @@ function _licenceData () {
reviewChargeVersionId: 'bd16e7b0-c2a3-4258-b873-b965fd74cdf5',
chargeReferenceId: '82ce8695-5841-41b0-a1e7-d016407adad4',
aggregate: 1,
chargeAdjustment: 1,
createdAt: new Date('2024-03-18'),
updatedAt: new Date('2024-03-18'),
chargeReference: {
Expand Down

0 comments on commit 64a23d1

Please sign in to comment.