adityanandanx / adityanandanx/raftaar
7. Trip End & Pricing Calculation
- Vorherrschende Sprache
- Python
- Sterne
- 0
- Forks
- 0
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
## Parent PRD
#1
## What to build
Trip completion and automatic pricing calculation. When customer returns bike to any station and locks it, the trip ends, trip duration is calculated, and price is computed using the hybrid model: base ₹2 + ₹0.20/min (after 20 min threshold).
Implements trip state machine, pricing formula with edge cases, distance validation to ensure bike returns to valid station, and frontend end-trip flow.
## Acceptance criteria
- [ ] `POST /trips/end` accepts end_station_id (JWT required)
- [ ] Calculates trip duration in minutes (end_time - start_time)
- [ ] Applies pricing formula: Cost = 2 + max(0, (duration_minutes - 20) * 0.20)
- [ ] Examples: 10 min trip = ₹2, 20 min = ₹2, 30 min = ₹4, 100 min = ₹18
- [ ] Validates end_station_id is valid (exists in stations table)
- [ ] Updates trip: end_time, end_station_id, duration_minutes, cost, status='completed'
- [ ] Bike status changes from 'in_use' → 'available'
- [ ] Response includes: trip_id, duration_minutes, cost, receipt_url (for next step)
- [ ] Cannot end trip if status != 'in_progress'
- [ ] Frontend: End trip button, final cost display with breakdown
- [ ] Frontend: Shows: base fare (₹2), per-minute charges, threshold logic
- [ ] Database: trip record updated with all calculations
- [ ] Edge cases: 0 minute trip (instant return), very long trip (100+ minutes)
## Blocked by
- Blocked by #6 (Trip Start - needs in-progress trip)
## User stories addressed
- User story 10: Return bike to any station
- User story 11: Trip ends automatically
- User story 14: Charged by actual trip duration (hybrid pricing model)
- User story 13: See estimated cost before booking
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.