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.
Context
Once we've sent out the claims to ESFA to be paid, we want to update their status when ESFA sends a response CSV file.
We need to store a record of these to show a claims activity record of action "payment_response_uploaded".
Changes proposed in this pull request
Claims::PaymentResponse
model to store the response CSV file onto aClaims::ClaimActivity
record.Claims::PaymentResponse::Process
service to process the uploaded CSV file.Claims::Claim#unpaid_reason
field.Guidance to review
I have tried the following approaches and both run into issues:
Don't add/use a
processed
attribute and cleanup cron job on payment responses.The issue with this approach is the passing of the
csv_file
from thenew
page to thecheck
page. We need to show how many rows are present in the CSV, therefore we need to store it.The read value of the
#csv_file
attachment is of typeActiveStorage::Attached::One
, therefore we can't pass it through via memory. There is also the possibility of the first and second request hitting different pods.Use a form object.
Using a form object without the
processed
attribute runs us into a very similar issue as above, the difference is that thecsv_file
field is serialized to a string via an implicit#to_s
call. Once thecsv_file
field value is read on thecreate
(prior to the implementation ofcheck
going toupdate
), it is read as a string, not a file, and raises an error when attempted to be saved to Active Storage.Note
Individual payment actions on their
show
pages will be added in an upcoming PR.claim_unpaid_reason
in the CSV.Screenshots
Action button
Upload form
Check page
Success notification
Activity log
Claim details