Skip to content

Commit

Permalink
Stop showing supp source charge as negative (#719)
Browse files Browse the repository at this point in the history
https://eaflood.atlassian.net/browse/WATER-4363

We've just dealt with [Fix bill licence supp source decimal in wrong place](#714). This caused us to take a closer look at how the supported source charge is displayed in the new views.

Our eagle-eyed testers spotted we were showing the value as a negative if the transaction itself is a credit and whether this is correct. When we double-checked the legacy view we found it's not! 🤦

This change fixes the display so the supported source charge is always displayed as a positive.
  • Loading branch information
Cruikshanks authored Feb 9, 2024
1 parent d290c0e commit edf1c48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,11 @@ function go (transaction) {
return _presrocContent(transaction)
}

function _additionalCharges (credit, waterCompanyCharge, supportedSourceCharge, supportedSourceName) {
function _additionalCharges (waterCompanyCharge, supportedSourceCharge, supportedSourceName) {
const charges = []

if (supportedSourceName) {
let chargeInPounds = 0
if (credit) {
chargeInPounds = formatPounds(supportedSourceCharge * -1)
} else {
chargeInPounds = formatPounds(supportedSourceCharge)
}
const chargeInPounds = formatPounds(supportedSourceCharge)

charges.push(`Supported source ${supportedSourceName}${chargeInPounds})`)
}
Expand Down Expand Up @@ -207,7 +202,7 @@ function _srocContent (transaction) {
const supportedSourceChargeInPence = supportedSourceCharge * 100

return {
additionalCharges: _additionalCharges(credit, waterCompanyCharge, supportedSourceChargeInPence, supportedSourceName),
additionalCharges: _additionalCharges(waterCompanyCharge, supportedSourceChargeInPence, supportedSourceName),
adjustments: _adjustments(
adjustmentFactor,
aggregateFactor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,10 @@ describe('View Standard Charge Transaction presenter', () => {
transaction.supportedSourceCharge = '14567'
})

describe('and the transaction is a credit', () => {
beforeEach(() => {
transaction.credit = true
})

it("returns 'Supported source Candover (£-14567.00)'", () => {
const result = ViewStandardChargeTransactionPresenter.go(transaction)

expect(result.additionalCharges).to.equal('Supported source Candover (£-14567.00)')
})
})

describe('and the transaction is a debit', () => {
beforeEach(() => {
transaction.credit = false
})

it("returns 'Supported source Candover (£14567.00)'", () => {
const result = ViewStandardChargeTransactionPresenter.go(transaction)
it("returns 'Supported source Candover (£14567.00)'", () => {
const result = ViewStandardChargeTransactionPresenter.go(transaction)

expect(result.additionalCharges).to.equal('Supported source Candover (£14567.00)')
})
expect(result.additionalCharges).to.equal('Supported source Candover (£14567.00)')
})
})

Expand Down

0 comments on commit edf1c48

Please sign in to comment.