icefoganalytics / elcc-data-management

Data Management application for Education's Early Learning Child Centre
Apache License 2.0
0 stars 0 forks source link

ELCC-50: Fix Payment Date Returns Incorrect Date On Page Reload #73

Closed klondikemarlen closed 9 months ago

klondikemarlen commented 9 months ago

Fixes https://yg-hpw.atlassian.net/browse/ELCC-50

Relates to:

Context

See https://elcc.ynet.gov.yk.ca/child-care-centres/2/2022-23/summary/payments

When the first advance is updated to 2022-04-01, it updates correctly, as seen from the Network pane, but the list view endpoint returns the previous day.

image

Implementation

Issue is caused by how Sequelize handles "DATEONLY" fields. When not using a non-UTC timezone the dateonly fields are cast to the local timezone on data retrieval. The solution is to switch production node environment timezone to UTC.

Testing Instructions

  1. Edit the docker-compose.development.yaml and set the TZ value to "America/Whitehorse"
  2. Boot the app via dev up
  3. Check that the app complies, and that you can log in at http://localhost:8080.
  4. Check that you can go to http://localhost:8080/child-care-centres/1/2023-24/summary/payments.
  5. Create or save a new payment with the Payment Date set to 2023-04-01.
  6. Note that while the payment looks correct after saving, if you reload the page it will reveal the bug as the Payment Date is then converted to 2023-03-31 - immediately upon retrieval from the database.
  7. Now repeat the steps with the TZ set to UTC and the Payment Date will no longer be cast back a day.