From 261b6dbc825e87f364d91dd1488b2e709aab74ef Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Mon, 18 Mar 2024 11:39:33 +0000 Subject: [PATCH] Fix std charge transaction presenter for S130 (#823) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../view-standard-charge-transaction.presenter.js | 4 +++- .../view-standard-charge-transaction.presenter.test.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/presenters/bill-licences/view-standard-charge-transaction.presenter.js b/app/presenters/bill-licences/view-standard-charge-transaction.presenter.js index e46d9c2bff..67d961b791 100644 --- a/app/presenters/bill-licences/view-standard-charge-transaction.presenter.js +++ b/app/presenters/bill-licences/view-standard-charge-transaction.presenter.js @@ -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)') } diff --git a/test/presenters/bill-licences/view-standard-charge-transaction.presenter.test.js b/test/presenters/bill-licences/view-standard-charge-transaction.presenter.test.js index 213ebe6c9c..374424f7a7 100644 --- a/test/presenters/bill-licences/view-standard-charge-transaction.presenter.test.js +++ b/test/presenters/bill-licences/view-standard-charge-transaction.presenter.test.js @@ -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)'", () => {