mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 17:01:35 -05:00
Fix the filenames for international precompiled letters
We were determing the filename for precompiled letters before we had checked if the letters were international. This meant that a letter could have a filename indicating it was 2nd class, but once we had sanitised the letter and checked the address we were setting the notification to international. This stopped these letters from being picked up to be sent to the DVLA, since the filename and postage of the letter did not match. We now regenerate the filename after the letter has been sanitised (and when we know the postage) and use the updated filename when moving the letter into the live PDF letters bucket.
This commit is contained in:
@@ -306,7 +306,23 @@ def process_sanitised_letter(self, sanitise_data):
|
||||
billable_units=billable_units,
|
||||
recipient_address=letter_details['address']
|
||||
)
|
||||
move_sanitised_letter_to_test_or_live_pdf_bucket(filename, is_test_key, notification.created_at)
|
||||
|
||||
# The original filename could be wrong because we didn't know the postage.
|
||||
# Now we know if the letter is international, we can check what the filename should be.
|
||||
upload_file_name = get_letter_pdf_filename(
|
||||
reference=notification.reference,
|
||||
crown=notification.service.crown,
|
||||
sending_date=notification.created_at,
|
||||
dont_use_sending_date=True,
|
||||
postage=notification.postage
|
||||
)
|
||||
|
||||
move_sanitised_letter_to_test_or_live_pdf_bucket(
|
||||
filename,
|
||||
is_test_key,
|
||||
notification.created_at,
|
||||
upload_file_name,
|
||||
)
|
||||
# We've moved the sanitised PDF from the sanitise bucket, but still need to delete the original file:
|
||||
original_pdf_object.delete()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user