Amend ChargeReferenceModel for PRESROC #502
Merged
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-4156
Related to WATER-4155 and the work to replace the legacy bill page with our own we're now starting to build the page it will link to; a view of the bill licence and all its transactions.
We are adding a new fetch bill licence service that will return data for both SROC and PRESROC transactions. Unfortunately, the previous team chose to store data related to the transactions differently. This means depending on what scheme a transaction is linked to you need to pull information from different places.
To support this we need to make a tweak to our
ChargeReferenceModel
. Under SROC a charge reference has multiple charge elements which in turn have multiple charge purposes. These purposes then link to aPurposeModel
.Under PRESROC the charge reference is actually a charge element (hence the table name is
charge_elements
) and directly links to aPurposeModel
.So, this change updates the ChargeReferenceModel so that it can pull through the linked purpose should one exist.
We also update the
PurposeModel
with the new relationship. Note, whilst doing this we spotted that the existing relationship to charge elements was wrong. It should be aHasManyRelation
so we also use this opportunity to fix it.