Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix comparison Section 126 factor in supp. billing #224

Merged
merged 4 commits into from
May 16, 2023

Conversation

Cruikshanks
Copy link
Member

https://eaflood.atlassian.net/browse/WATER-4010

We found another scenario where the bill run always added credit and debit for the charge version on each bill run.

The scenario was a new charge version was added which applied an abatement agreement (section 126 factor). The bill run gets run and sent.

Another minor change is then made. No new debit and credit are needed. But when the engine grabs the previous debit, flips it to credit and compares it against the calculated line it finds they don't match.

This results in a debit and credit for the same amount appearing each time when they should be cancelled out and not appear at all.

We tracked the problem down to the charge_element holding all the values as strings inside a JSONB field (adjustments). But when they get persisted to the billing_transactions table they are properly stored as a number.

This is the same issue as Fix including unnecessary supp. billing trans. only in reverse. Thanks, legacy code!

This change ensures when it comes to the comparison of section126Factor both previous and calculated and looking at the same data type.

https://eaflood.atlassian.net/browse/WATER-4010

We found another scenario where the bill run was always adding a credit and debit for a charge version on each bill run.

The scenario was a new charge version is added which applies an abatement agreement (section 126 factor). The bill run gets run and sent.

Another minor change is then made. No new debit and credit is needed. But when the engine grabs the previous debit, flips it to a credit and compares it against the calculated line it finds they don't match.

This results in a debit and credit for the same amount appearing each time when they should be cancelled out and not appear at all.

We tracked the problem down to the `charge_element` holding all the values as strings inside a JSONB field (`adjustments`). But when they get persisted to the `billing_transactions` table they are properly stored as a number.

This is the same issue as [Fix including unnecessary supp. billing trans.](#210) only in reverse. Thanks legacy code!

This change ensures when it comes to the comparison of `section126Factor` both previous and calculated and looking at the same data type.
@Cruikshanks Cruikshanks added the bug Something isn't working label May 16, 2023
@Cruikshanks Cruikshanks self-assigned this May 16, 2023
If we pass `undefined` or `null` to `Number()` it will return `NaN` which is interpreted as `false`. So, the result is the same as previous and the default value is returned.

If it has a value though, we'll now have it set as a number ready for comparison with any previous billing transactions, which save them as numbers.
Having spotted this issue we update the charge element helper to default the adjustments to match how they are actually stored in the DB.

This also means we by default test our changes. `aggregate` when converted during testing of `GenerateBillingTransactionsService` should match as a number. `s126` and `charge` left as is will confirm we still use the default when no value exists.
@Cruikshanks Cruikshanks marked this pull request as ready for review May 16, 2023 08:53
Copy link
Contributor

@Jozzey Jozzey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cruikshanks Cruikshanks merged commit 38b9634 into main May 16, 2023
@Cruikshanks Cruikshanks deleted the fix-section-126-factor-comparision branch May 16, 2023 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants