-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add billing_transaction model to water-abstraction-system #135
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://eaflood.atlassian.net/browse/WATER-3909 `billing_transaction` is linked to a billing invoice licence record. We need it to store the transaction detail for an invoice. - add the model - update relationships - add unit tests for model - update billing invoice licence model unit tests - add test helper
Cruikshanks
approved these changes
Mar 2, 2023
Cruikshanks
added a commit
that referenced
this pull request
Mar 5, 2023
https://eaflood.atlassian.net/browse/WATER-3906 https://eaflood.atlassian.net/browse/WATER-3927 With our [Add billing_transaction model to water-abstraction-system](#135) change we had our first decimal field. What we didn't realise when we created the migration is that the [pg package](https://www.npmjs.com/package/pg) returns decimals as strings. We've encountered this issue before with BigInt's on the [charging-module-api](https://github.com/DEFRA/sroc-charging-module-api) which is why `db/db.js` has logic to parse the string **pg** returns back into a integer. The root cause is the same. Out of concern about loss of precision the DB values are returned as strings. We know we're not dealing with values where this would be an issue so we can have **pg** implicitly parse the decimal strings into floats. [This post](https://stackoverflow.com/a/39176670/6117745) focuses on the BigInt issue. But the cause and solution are the same for decimals. So, this change ensures when we use [Knex](https://github.com/knex/knex) or [Objection.js](https://github.com/vincit/objection.js) we see floats (numbers) instead of strings.
Cruikshanks
added a commit
that referenced
this pull request
Mar 5, 2023
https://eaflood.atlassian.net/browse/WATER-3906 https://eaflood.atlassian.net/browse/WATER-3927 With our [Add billing_transaction model to water-abstraction-system](#135) change we had our first decimal field. When we created the migration, we didn't realise that the [pg package](https://www.npmjs.com/package/pg) returns decimals as strings. We've encountered this issue with BigInt on the [charging-module-api](https://github.com/DEFRA/sroc-charging-module-api) which is why `db/db.js` has logic to parse the string **pg** returns back into an integer. The root cause is the same. Out of concern about the loss of precision the DB values are returned as strings. We know we're not dealing with values where this would be an issue so we can have **pg** implicitly parse the decimal strings into floats. [This post](https://stackoverflow.com/a/39176670/6117745) focuses on the BigInt issue. But the cause and solution are the same for decimals. So, this change ensures when we use [Knex](https://github.com/knex/knex) or [Objection.js](https://github.com/vincit/objection.js) we see floats (numbers) instead of strings. --- Whilst making this change we also updated the existing fix for BigInts to use the same solution. Using named types rather than a 'magic number' from the DB was preferable in our opinion
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://eaflood.atlassian.net/browse/WATER-3906
https://eaflood.atlassian.net/browse/WATER-3909
billing_transaction
is linked to a billing invoice licence record. We need it to store the transaction detail for an invoice.