Skip to content

Commit

Permalink
Fix bill total in single licence bill page
Browse files Browse the repository at this point in the history
https://eaflood.atlassian.net/browse/WATER-4132

An issue was found with how credits were displayed that we sorted; [Fix display of credit transactions in bill views](#522). Or we thought we did. 😩

The bill information has a total which needs to be `£100.00 credit`. The transactions table beneath also has a total but it needs to display `-£100.00`.

To build the single licence bill view we combine the output from `BillPresenter` with `ViewBillLicencePresenter`. It just so happens both return a `total:` property. 🤦

This means one is overriding the other leading to an issue on the single licence bill page. This change fixes it.
  • Loading branch information
Cruikshanks committed Nov 14, 2023
1 parent c74ae0d commit ade6de0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions app/presenters/bills/bill.presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function go (bill, billingAccount) {
billRunNumber: billRun.billRunNumber,
billRunStatus: billRun.status,
billRunType: _billRunType(billRun),
billTotal: _billTotal(bill.netAmount, bill.isCredit),
chargeScheme: _scheme(billRun),
contactName: _contactName(billingAccount),
credit: bill.isCredit,
Expand All @@ -36,7 +37,6 @@ function go (bill, billingAccount) {
financialYear: _financialYear(bill),
flaggedForReissue: bill.isFlaggedForRebilling,
region: capitalize(billRun.region.displayName),
total: _total(bill.netAmount, bill.isCredit),
transactionFile: billRun.transactionFileReference
}

Expand Down Expand Up @@ -148,7 +148,7 @@ function _scheme (billRun) {
return 'Old'
}

function _total (valueInPence, credit) {
function _billTotal (valueInPence, credit) {
const valueAsMoney = formatMoney(valueInPence)

if (credit) {
Expand Down
2 changes: 1 addition & 1 deletion app/views/bills/view-multi-licence.njk
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<div class="govuk-grid-row govuk-!-margin-bottom-3">
<div class="govuk-grid-column-one-half">
<h2>
<span class="govuk-body govuk-!-font-weight-bold govuk-!-font-size-80" data-test="bill-total">{{ total }}</span><br>
<span class="govuk-body govuk-!-font-weight-bold govuk-!-font-size-80" data-test="bill-total">{{ billTotal }}</span><br>
<span class="govuk-body govuk-!-font-weight-bold govuk-!-font-size-24">Total</span>
</h2>
{% if deminimis %}
Expand Down
2 changes: 1 addition & 1 deletion app/views/bills/view-single-licence-presroc.njk
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<div class="govuk-grid-row govuk-!-margin-bottom-3">
<div class="govuk-grid-column-one-half">
<h2>
<span class="govuk-body govuk-!-font-weight-bold govuk-!-font-size-80" data-test="bill-total">{{ total }}</span><br>
<span class="govuk-body govuk-!-font-weight-bold govuk-!-font-size-80" data-test="bill-total">{{ billTotal }}</span><br>
<span class="govuk-body govuk-!-font-weight-bold govuk-!-font-size-24">Total</span>
</h2>
{% if deminimis %}
Expand Down
2 changes: 1 addition & 1 deletion app/views/bills/view-single-licence-sroc.njk
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<div class="govuk-grid-row govuk-!-margin-bottom-3">
<div class="govuk-grid-column-one-half">
<h2>
<span class="govuk-body govuk-!-font-weight-bold govuk-!-font-size-80" data-test="bill-total">{{ total }}</span><br>
<span class="govuk-body govuk-!-font-weight-bold govuk-!-font-size-80" data-test="bill-total">{{ billTotal }}</span><br>
<span class="govuk-body govuk-!-font-weight-bold govuk-!-font-size-24">Total</span>
</h2>
{% if deminimis %}
Expand Down
46 changes: 23 additions & 23 deletions test/presenters/bills/bill.presenter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('Bill presenter', () => {
billRunNumber: 10003,
billRunStatus: 'sent',
billRunType: 'Annual',
billTotal: '£213,178.00',
chargeScheme: 'Current',
contactName: null,
credit: false,
Expand All @@ -48,7 +49,6 @@ describe('Bill presenter', () => {
financialYear: '2022 to 2023',
flaggedForReissue: false,
region: 'South West',
total: '£213,178.00',
transactionFile: 'nalei50002t'
})
})
Expand Down Expand Up @@ -151,6 +151,28 @@ describe('Bill presenter', () => {
})
})

describe("the 'billTotal' property", () => {
describe('when the bill is a debit', () => {
it('returns just the bill total formatted as money', () => {
const result = BillPresenter.go(bill, billingAccount)

expect(result.billTotal).to.equal('£213,178.00')
})
})

describe('when the bill is a credit', () => {
beforeEach(() => {
bill.isCredit = true
})

it("returns the bill total formatted as money plus 'credit' as a suffix", () => {
const result = BillPresenter.go(bill, billingAccount)

expect(result.billTotal).to.equal('£213,178.00 credit')
})
})
})

describe("the 'chargeScheme' property", () => {
describe('when the bill run is sroc', () => {
it('returns Current', () => {
Expand Down Expand Up @@ -341,28 +363,6 @@ describe('Bill presenter', () => {
expect(result.region).to.equal('South West')
})
})

describe("the 'total' property", () => {
describe('when the bill is a debit', () => {
it('returns just the bill total formatted as money', () => {
const result = BillPresenter.go(bill, billingAccount)

expect(result.total).to.equal('£213,178.00')
})
})

describe('when the bill is a credit', () => {
beforeEach(() => {
bill.isCredit = true
})

it("returns the bill total formatted as money plus 'credit' as a suffix", () => {
const result = BillPresenter.go(bill, billingAccount)

expect(result.total).to.equal('£213,178.00 credit')
})
})
})
})
})

Expand Down

0 comments on commit ade6de0

Please sign in to comment.