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

Tidy supplementary billing code - second pass #208

Merged
merged 13 commits into from
May 9, 2023

Conversation

StuAA78
Copy link
Contributor

@StuAA78 StuAA78 commented May 2, 2023

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.

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.
@StuAA78 StuAA78 added the housekeeping Refactoring, tidying up or other work which supports the project label May 2, 2023
@StuAA78 StuAA78 self-assigned this May 2, 2023
StuAA78 added 10 commits May 2, 2023 15:35
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.
@StuAA78 StuAA78 marked this pull request as ready for review May 5, 2023 12:19
Copy link
Member

@Cruikshanks Cruikshanks left a comment

Choose a reason for hiding this comment

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

Comment on lines +36 to +45
// 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)
Copy link
Member

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 ❤️😍

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.

👍🏼

@StuAA78 StuAA78 merged commit 54e2bf6 into main May 9, 2023
@StuAA78 StuAA78 deleted the second-pass-tidy-of-supplementary-code branch May 9, 2023 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Refactoring, tidying up or other work which supports the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants