Skip to content

feat: implement contract downloads and update contract start date (EN-351, EN-352)

Musa Ali requested to merge fix/update-contract-date into dev

Summary

This MR includes an implementation for uploading signed contracts, updates for adding a required "contractStartDate" field, and minor updates and fixes where spotted. Major additions were made to the Contract route, controller, and service layers. A route api/v1/contracts/:contractId/upload was created which allows Loan Officers and Admins to upload signed contract PDFs - it uses the same upload middleware created for Document uploads. The buffer of the uploaded PDF is saved to the Contract in the database and the "contractFileName" is assigned a name in the format of Signed_Loan_Contract-contractId.pdf.

Changes

Upload contracts

  • add "contractFileBuffer" field to Contract model
  • create Contract upload route, controller, service, and integration tests
  • add validation for Contract uploads (among other things it checks file extension, must be .pdf)

Contract start date

  • change contractStartDate to be required
  • add contractStartDate to route Swagger documentation
  • add contractStartDate check to create and update Contract request body validation
  • add contractStartDate to Contract fixture
  • add contractStartDate to Contract model and integration tests
  • add contractStartDate to generated Contract PDFs

Unrelated

  • needs attention: when adding an example contractStartDate to the contract PDF generation, a date of 2001-01-01 was being converted to 2000-12-31. As a temporary solution, I converted (inside the addDateFields function inside createContractPDF.js) the date to a UTC string and converted that back to a Date object
  • fix a missed field in the updateContract validation (officer field was still there, changed it to client)
  • add a "0" to the start of single-digit months and days in the addDateFields function inside createContractPDF.js so dates look like "01 01 2001" instead of "1 1 2001"
Edited by Musa Ali

Merge request reports