Backend: Zapisnik o vraćanju – view
GitHub Issue: #197
Last modified with commit 374306c on
by Aljaž.
Backend task for the return part of GET /drivepark/records/{recordId} – check the API spec and DB structure, return the return data, photos and signatures, compute Voženo, implement, and verify against the spec.
Docs: Zapisnik o vraćanju – view
Spec: GET /drivepark/records/{recordId} (getDriveParkRecord), DriveParkRecordDetail (return*, drivenDays, drivenHours) in api-docs/openapi.yaml
DB: DriveParkRecords (Return* columns), DriveParkRecordPhotos in api/database/pending_schema.sql (-- DRIVE PARK --)
The endpoint itself is built in Backend: Zapisnik o preuzimanju – view. This task covers the return part.
1. Double check API spec and DB structure
- Every section of the view is in
DriveParkRecordDetail: the pickup data, Stanje vozila pri vraćanju (returnMileageKm,returnDate,returnTime,drivenDays/drivenHours,returnBatteryPercent,returnFuelLevel,returnDamage), Fotografije (stage: return), Potpisi (returnUserSignature,returnCompanySignature). - Voženo: not specified in the docs (comment: “Recommended: minutes are rounded up to the next hour”). The spec: whole days, then the remaining minutes rounded up to hours, 24 h carry over to a day. Confirm with the project manager.
- The frontend uses the Croatian forms (“1 dan / 2 dana / 5 dana”, “1 sat / 2 sata / 5 sati”); the API returns numbers only.
- Roles and permissions:
drivepark.access.
2. Implementation
- Roles and permissions: require
drivepark.access→ 403. - Compute
drivenDays/drivenHoursfromPickupDate+PickupTimeandReturnDate+ReturnTime(local wall-clock values, no time zone conversion); null if any of the four is missing. Put it in one helper, also used by the PDF. - Return signatures as data URLs, null until the return is completed.
3. Verify implementation against spec
- Response fields match
DriveParkRecordDetail. - Voženo: 12.08. 9:00 → 14.08. 20:00 = 2 days 11 hours; 12.08. 9:00 → 12.08. 9:01 = 0 days 1 hour; 12.08. 9:00 → 13.08. 8:30 = 1 day 0 hours (23:30 rounds up to 24 h).
- Preuzeto record with a return draft → return values set, return signatures null.
Done when
A returned record can be opened read-only with the return data, Voženo, photos and both return signatures.