adityanandanx / adityanandanx/raftaar

14. Pricing Management & Discount Codes

Offen
#15 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
0
Forks
0
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

## Parent PRD

#1

## What to build

Admin pricing configuration and customer-facing discount code system. Admins can adjust base fare, per-minute rate, and threshold minutes dynamically. Admins can create promotional discount codes. Customers can apply codes to get discounts on trips.

Implements pricing rule storage, discount code generation/tracking, discount application logic, and admin pricing UI.

## Acceptance criteria

- [ ] `GET /admin/pricing/config` returns current pricing rules (admin only)
- [ ] Returns: base_fare, per_minute_rate, threshold_minutes
- [ ] Example: {base_fare: 2.0, per_minute_rate: 0.20, threshold_minutes: 20}
- [ ] `POST /admin/pricing/update` updates pricing rules (admin only)
- [ ] Accepts: base_fare, per_minute_rate, threshold_minutes
- [ ] New pricing applies to all trips AFTER the update (not retroactive)
- [ ] `POST /admin/discounts/create` creates discount code (admin only)
- [ ] Accepts: code (e.g. 'SAVE10'), discount_percent (0-100), max_uses (nullable), expiry_date
- [ ] Response includes: discount_id, code, discount_percent, valid_until
- [ ] `GET /admin/discounts` lists all discount codes with usage stats (admin only)
- [ ] `POST /trips/apply-discount` applies discount code to active trip/reservation (JWT required)
- [ ] Accepts: discount_code
- [ ] Validates: code exists, not expired, max_uses not exceeded
- [ ] Updates trip.discount_code, recalculates cost with discount
- [ ] Cost after discount = original_cost * (1 - discount_percent/100)
- [ ] Example: ₹4 trip with 10% discount = ₹3.60
- [ ] Database schema: `pricing_config` (id, base_fare, per_minute_rate, threshold_minutes, effective_date), `discount_codes` (id, code, discount_percent, max_uses, uses_count, expiry_date)
- [ ] Discount can only be applied once per trip
- [ ] Frontend (Admin): Pricing config card showing current rates, update button
- [ ] Frontend (Admin): Discount codes table with: code, discount %, max uses, current uses, expiry
- [ ] Frontend (Admin): Create discount code form
- [ ] Frontend (Customer): Discount code input field on trip/booking screen
- [ ] Frontend (Customer): Shows discount applied if valid
- [ ] Edge cases: invalid code, expired code, max uses reached, discount > 100%, negative values

## Blocked by

- Blocked by #7 (Trip End - pricing calculated on trip end)

## User stories addressed

- User story 17: Apply discount codes to trips
- User story 42: Update base fare, per-minute rate, threshold minutes
- User story 43: Create and manage discount codes
- User story 44: See which discount codes are most used

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Start by reading blocked issue #7 and parent PRD #1, then map the listed admin, trip, and customer entry points across the existing backend and frontend. Done means the pricing, discount-code, schema, authorization, validation, recalculation, and UI acceptance criteria are implemented and verified, including the stated edge cases.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
api, authentication, backend, database, frontend
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.