Skip to content

Show how the fare is calculated (#6) - #55

Open
tribhuvneshsharma wants to merge 1 commit into
wncc:mainfrom
tribhuvneshsharma:issue-006-fare-breakdown
Open

tribhuvneshsharma wants to merge 1 commit into
wncc:mainfrom
tribhuvneshsharma:issue-006-fare-breakdown

Conversation

@tribhuvneshsharma

Copy link
Copy Markdown

Closes #6

What this PR does

Shows riders how each vehicle's fare is calculated:

  • Backend Pricing Logic: Added FareBreakdown dataclass and fare_breakdown() in backend/app/services/pricing.py returning base fare, distance charge, duration charge, booking fee, minimum fare top-up, and rupee rounding.
  • API & Schemas: Exposing breakdown on EstimateOption in backend/app/schemas.py and populated in /rides/estimate in backend/app/api/rides.py.
  • Rider UI: Tapping a vehicle option on the rider choose screen expands an itemized breakdown showing each component.
  • Unit Tests: Added backend/tests/test_pricing.py to verify that all breakdown parts always sum up to the total fare, including minimum fare adjustments and rupee rounding.

Verification

  • Unit test verifying parts always sum to the total (pytest backend/tests/test_pricing.py)
  • Rider can see the breakdown for each vehicle
  • python test_all.py --quick passes (pytest, tsc typecheck, eslint, jest)

- Add FareBreakdown dataclass and fare_breakdown() in backend/app/services/pricing.py
- Expose FareBreakdownOut on EstimateOption in backend/app/schemas.py and backend/app/api/rides.py
- Add FareBreakdown type in mobile/src/lib/types.ts
- Add expandable fare breakdown view in mobile/src/app/rider/index.tsx on tapping vehicle options
- Add comprehensive unit tests in backend/tests/test_pricing.py ensuring parts always sum to total with minimum topup and rounding
- Add API assertion in backend/tests/test_api.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show how the fare is calculated

1 participant