-
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
Tidy supplementary billing code - second pass #208
Conversation
We've been working quickly to get supplementary billing completed on time. This means we haven't always been able to spend as much time as we'd like on some of the finer details -- documentation, consistency of standards, naming conventions, etc. This PR is a second pass at spotting these things and amending them.
Although not part of our supplementary billing, we spotted redundant `return await` statements in `RequestLib` and `LegacyRequestLib`, which we remove
In `DetermineChargePeriodService` we were creating a variable for each timestamp, defaulting to `financialYearEndDate` if the timestamp is `null`, then using `Math.min()` to find the earliest of these -- the defaulting is required as a `null` value would be counted as `0` by `Math.min()`. We can streamline this and cut the number of lines required by simply putting the original values into an array then filtering out the `null` values, then passing our array values to `Math.min()`.
While refactoring `ProcessBillingBatchService` we've identified a couple of ways we can restructure the process. This will be handled in a separate PR; for now, we simply refactor code into helper functions which more accurately describe the flow of the process
We're using `.filter()` to filter out null timestamps. Just prior to submitting the PR for review we realised our `.filter(timestamp => timestamp)` didn't fit our standard of always putting brackets around single params. We therefore fix this, along with one other instance we spotted in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// We use .filter() to remove any null timestamps, as Math.min() assumes a value of `0` for these | ||
const endDateTimestamps = [ | ||
financialYearEndDate, | ||
chargeVersionEndDate, | ||
licenceExpiredDate, | ||
licencelapsedDate, | ||
licencerevokedDate | ||
) | ||
chargeVersion.endDate, | ||
chargeVersion.licence.expiredDate, | ||
chargeVersion.licence.lapsedDate, | ||
chargeVersion.licence.revokedDate | ||
].filter((timestamp) => timestamp) | ||
|
||
const earliestEndDateTimestamp = Math.min(...endDateTimestamps) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just wanted to say ❤️😍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼
We've been working quickly to get supplementary billing completed on time. This means we haven't always been able to spend as much time as we'd like on some of the finer details -- documentation, consistency of standards, naming conventions, etc. Following our first pass, this PR is a second pass at spotting these things and amending them.
Note that while refactoring
ProcessBillingBatchService
we identified a couple of ways we can restructure the process. This will be handled in a separate PR; for now, we have simply refactored code into helper functions which more accurately describe the flow of the process.