icefoganalytics / travel-authorization

0 stars 0 forks source link

ytgov/issue#96: Preapproved Submission Not Working Properly #197

Closed klondikemarlen closed 5 months ago

klondikemarlen commented 5 months ago

Fixes https://github.com/ytgov/travel-authorization/issues/96

Context

Is your feature request related to a problem? Please describe. on the request tab. Selected all (2) the requests I wanted to include in my submission. Selected "Submit Selected Travel" and hit save. The submissions got moved over to the submission tab. But only one of the two requests came over.

Describe the solution you'd like I want both selected requests to be included in the submissions.

image image image

Submission date is wrong I made a submission June 13, 2024 and June 12, 2024 Location should have a comma seperate list of locations of all the request selected

image

The print button shows that only 1 of the 3 requests were submitted.

image

only shows 1 of 3 requests submitted.

Implementation

  1. Page load failure identified as user lookup being commented out in https://github.com/ytgov/travel-authorization/pull/41, (specifically 074a3fffc8b480) and was introduced by removing user lookup after route change https://github.com/icefoganalytics/travel-authorization/pull/196 (specifically https://github.com/icefoganalytics/travel-authorization/commit/379c6c9e2853d81659f309bc0546a3133c2be02e) The code could be replaced by global useCurrentUser composable; which loads user once during sign-in.

  2. Identified further issues do to data modeling mismatch. Introduced in https://github.com/ytgov/travel-authorization/commit/db9194308725e908b79f9587a201d70ab48101c5.

    Relationship between preapprovedSubmissions and travel_authorization_pre_approvals is one-to-many not one-to-one.

  3. UI changes referring to .preApproval as singular need to be reverted; one example is https://github.com/icefoganalytics/travel-authorization/commit/dc55491d934aad0bef555f1dde7e11c2d39507d6. Probably other similar issues in https://github.com/icefoganalytics/travel-authorization/pull/179.

  4. Identified issue with submission date being incorrect introduced in https://github.com/ytgov/travel-authorization/commit/98f86b1134b2650a23ec315566955bfc23a21670. Migrating sets default date to date that the migration ran at, rather than CURRENT_TIMESTAMP.

    This issue was probably suppressed by someone manually setting submittedDate on submission; although, I can't find where after digging through the git history. Or maybe by us regularly dropping the database in production?

Key Takeaways

  1. Variable naming consistency is important.
  2. Setting dynamic database level defaults should use database functions, not static values.

Screenshots

Print multiple selected requests image

Print Submission with multiple references image

Submission Approval with multiple references image

Testing Instructions

  1. Run the test suite via dev test (or dev test_api)
  2. Boot the app via dev up
  3. Log in to the app at http://localhost:8080
  4. Go to the http://localhost:8080/preapproved page via the top drop down nav.
  5. Add a new travel request via the "Add new travel button". Pick the Highways and Public Works department.
  6. Add a second travel request with the same department.
  7. Check the boxes, to the left of the table, by both submissions to select them both.
  8. Click the "Print Report" button, and check that both submission show up.
  9. Click the "Export to Excel" button and check that the export shows the correct data.

    Note that the file name is manged by the export-to-csv library; see https://github.com/icefoganalytics/travel-authorization/issues/198

  10. Re-select the submissions, and then click the "Submit Selected Travel" button.
  11. Go to the "Submissions" tab and find your new submission.
  12. Location should include both locations from the two submissions.
  13. Click the Print button, both submissions will now show up.
  14. Click the "Approve" button, both submissions will now show up.