Skip to content

Commit

Permalink
Fix miscalculated preview 2PT charge in review pt2 (#1584)
Browse files Browse the repository at this point in the history
https://eaflood.atlassian.net/browse/WATER-4849

In [Fix miscalculated preview 2PT charge in review](#1583) we attempted to resolve an issue where the two-part tariff preview charge feature was incorrectly telling the [Charging Module API](https://github.com/DEFRA/sroc-charging-module-api) to include the £141 water company charge in its calculation.

We deduced the issue as logic based on whether a field was populated rather than incorporating whether that value was 'true' or 'false'.

What we didn't clock until testing was that when the value is populated, it is a boolean value. However, our fetch service is casting it to text, which means our fix still equates `isSupplyPublicWater = false` as 'true' because the value it is testing is `'false'` and not `false`.

This updates the fetch service to cast the value properly, which means the logic we amended in part 1 will now behave as expected.
  • Loading branch information
Cruikshanks authored Dec 23, 2024
1 parent 40f4bf1 commit 5fb2330
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async function _fetch(reviewChargeReferenceId) {
'volume',
'loss',
ref('chargeReferences.additionalCharges:supportedSource.name').castText().as('supportedSourceName'),
ref('chargeReferences.additionalCharges:isSupplyPublicWater').castText().as('waterCompanyCharge')
ref('chargeReferences.additionalCharges:isSupplyPublicWater').castBool().as('waterCompanyCharge')
])
.withGraphFetched('chargeCategory')
.modifyGraph('chargeCategory', (chargeCategoryBuilder) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('Bill Runs Review - Fetch Review Charge Reference service', () => {
volume: 6.819,
loss: 'low',
supportedSourceName: 'Foo source',
waterCompanyCharge: 'true',
waterCompanyCharge: true,
chargeCategory: {
id: chargeCategory.id,
reference: chargeCategory.reference,
Expand Down

0 comments on commit 5fb2330

Please sign in to comment.