Refactor CreateEventService for bill runs #73
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-3831
We've created the model and a service wrapper for creating events. But at this time we are only interested in creating an
event
when a new bill run is initialised. That means some fields will always be set with a certain value.Also, based on reviewing existing events created by the legacy code the
metadata
holds a formatted version of a bill run. So, we need to handle that.All this means we'd be better placed to refactor the existing service to focus on new bill-run events.
** Notes
Add migrations for missing fields
There are columns on the
regions
andbilling_batches
tables that the existing logic extracts data from that isn't present in our test db. So, we add alter migrations for the missing fields and update our helpers accordingly.Add presenter needed to format metadata content
The metadata field in an event record doesn't just contain a dump of the BillingBatch as JSON. Instead, it is a specifically formatted object. So, we need something that will convert the
BillingBatchModel
instance into the content we need.Add source as a default in BillingBatchHelper
Source is populated when a billing batch event is created for real. So, we ensure it's populated in our helper to reflect that.
Example of bill run metadata