Skip to content

Commit

Permalink
Fix std charge transaction presenter for S130 (#823)
Browse files Browse the repository at this point in the history
https://eaflood.atlassian.net/browse/WATER-4409

Our users reported that for licences where the Canal and Rivers Trust agreement (S130) has been applied, it isn't displayed against the transaction in the new bill view.

We assumed this was just another thing we missed when building the new views. So, we were surprised when we found there is code to handle displaying the Canal and rivers trust agreement.

After doing some digging we found out why 🙄🤦

We'd already clocked that for some reason the previous team had made this a text field rather than a boolean, even though we are using it to store true or false. We hadn't clocked was that when the legacy code sets the field it includes a space at the end. Computers being computers means 'true' !== 'true '. 😡 

This change updates the code to handle this.
  • Loading branch information
Cruikshanks authored Mar 18, 2024
1 parent 6d2a3c6 commit 261b6db
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ function _adjustments (
adjustments.push('Two-part tariff (0.5)')
}

if (section130Agreement === 'true') {
// NOTE: Not only is this 'boolean' value held in a string field in the DB, when the legacy code sets the value
// it likes to add a space to the end!
if (section130Agreement.trim() === 'true') {
adjustments.push('Canal and River Trust (0.5)')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ describe('View Standard Charge Transaction presenter', () => {
})
})

describe("when the section 130 agreement is 'true' (they stored it as a string!)", () => {
describe("when the section 130 agreement is 'true ' (they stored it as a string!)", () => {
beforeEach(() => {
transaction.section130Agreement = 'true'
transaction.section130Agreement = 'true '
})

it("returns 'Canal and River Trust (0.5)'", () => {
Expand Down

0 comments on commit 261b6db

Please sign in to comment.