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

Add create licence supplementary years service #1256

Merged
merged 9 commits into from
Aug 15, 2024

Conversation

Beckyrose200
Copy link
Contributor

@Beckyrose200 Beckyrose200 commented Aug 14, 2024

https://eaflood.atlassian.net/browse/WATER-4588
#1236

The new two-part tariff supplementary bill run requires licences to be recorded in our new LicenceSupplementaryYears table, along with the years they affect. The first ticket we picked up for this new process was amending the existing annual two-part tariff review pages. A licence can be removed from the bill run there and this should be flagged. This was added to the existing review page journey. Since starting work on the other flagging tickets it became clear that the process of adding the licence into our LicenceSupplementaryYears table is going to be repeated if we don't pull this out into its own service. So that is what this PR is for, making a service just for creating the licence record that can be shared amongst the various ways a licence can be flagged.

https://eaflood.atlassian.net/jira/software/c/projects/WATER/boards/96?selectedIssue=WATER-4588
#1236

The new two-part tariff supplementary bill run requires licences to be recorded in our new LicenceSupplementaryYears table, along with the years they affect. The first ticket we picked up for this new process was amending the existing annual two-part tariff review pages. A licence can be removed from the bill run there and this should be flagged. This was added to the existing review pages journey. Since starting work on the other flagging tickets it became clear that the process of adding the licence into our LicenceSupplementaryYears table is going to be repeated if we don't pull this out into its own service. So that is what this PR is for, making a service just for creating the licence record that can be shared amongst the various ways a licence can be flagged.
@Beckyrose200 Beckyrose200 added the enhancement New feature or request label Aug 14, 2024
@Beckyrose200 Beckyrose200 self-assigned this Aug 14, 2024
@Beckyrose200
Copy link
Contributor Author

Just a note, on the service I have resorted to creating a private fetch function to look for any existing records with the same properties that we want to persist. We did discuss using a where clause on the query insert, but after some research, I don't think this is possible due to the where clause only being used for 'selects', 'updates', and 'deletes'. I could not find any examples in our code that have a where clause on an insert.

I also looked into the option of using onConflict however, this again was a no-go due to the fact the database itself needs to have constraints on the table for the onConflict to be triggered. Any suggestions on this let me know :)

@Beckyrose200 Beckyrose200 marked this pull request as ready for review August 15, 2024 08:35
@Beckyrose200 Beckyrose200 requested a review from Jozzey August 15, 2024 09:32
@Cruikshanks
Copy link
Member

Just a note, on the service I have resorted to creating a private fetch function to look for any existing records with the same properties that we want to persist. We did discuss using a where clause on the query insert, but after some research, I don't think this is possible due to the where clause only being used for 'selects', 'updates', and 'deletes'. I could not find any examples in our code that have a where clause on an insert.

I also looked into the option of using onConflict however, this again was a no-go due to the fact the database itself needs to have constraints on the table for the onConflict to be triggered. Any suggestions on this let me know :)

My bad. It can be done in raw SQL or by dropping down to Knex, but it would be pretty messy. We don't need to optimise this, so don't worry about it!

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.

Just some suggested tweaks.

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.

@Beckyrose200 Beckyrose200 merged commit 50c68a5 into main Aug 15, 2024
6 checks passed
@Beckyrose200 Beckyrose200 deleted the create-licence-supplementary-years-service branch August 15, 2024 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants