📂 Fail MD
📄 api-spec.md
📄 architecture.md
📄 compound-rules.md
📄 council-sync.md
📄 data-model.md
📄 money-ledger.md
📄 parking-rules.md
Sedang mengedit: parking-rules.md
# Smart Parking — Parking Rules Rules for parking sessions: time, charging windows, rest periods, public holidays, validity, and extension. ## Time-Based, Not Bay-Based - Payment buys **time** (e.g. 6 hours), not a specific bay. - A session is valid **anywhere within one tenant** for its duration. The user may move between streets within the same tenant. - A session is tied to a **`tenant_id`** (set at creation by location). It is NOT valid in another tenant. - Sensors do not affect a session; they only report bay occupancy (see `architecture.md`). ## Charging Windows (per tenant) Each tenant defines charging windows. Time outside windows is **free**. ``` Example (MBPP): 08:00 - 12:00 = chargeable (4.0 h) 12:00 - 13:30 = REST (free, skipped) 13:30 - 17:00 = chargeable (3.5 h) ──────────────────────────────────── Daily max chargeable = 7.5 h ``` - **Rest period** = the gap between windows. The paid timer **pauses** during rest. - **Daily max chargeable** = sum of all windows (here 7.5h). The user cannot buy more chargeable time than this in a day. ## Clock-Time Within a Window Within a continuous chargeable window, time is exact clock-time. ``` Pay 1 hour, start 09:11:00 (inside 08:00-12:00) → end_at = 10:11:00 → valid while now < end_at 10:10:59 → valid ✅ 10:11:00 → expired ❌ ``` ## Crossing a Rest Period (timer pauses) When a session spans a rest period, the rest time is skipped — it does not consume paid time. ``` Pay 8 hours, start 08:00: 08:00-12:00 → consume 4.0h (3.5h left) 12:00-13:30 → REST, paused (3.5h left) 13:30-17:00 → consume 3.5h (0h left) ────────────────────────────────────────── Requested 8h, but daily max is 7.5h → capped, ends 17:00 ``` The user app computes/displays this; the backend stores the resulting `end_at` and `paid_hours`. ## Public Holiday vs Rest Time | | Public Holiday | Rest Time | |---|---|---| | Free duration | All day | Temporary (between windows) | | Message | "Free Parking on Public Holiday" | "Free Parking for Rest Time" | | Can pay? | ❌ Blocked entirely | ✅ Option to start at next window | | Reason | No charging that day | Charging resumes after rest | - **Public Holiday** comes from the Settings → Public Holiday list. Paying is blocked. - **Rest Time:** if a user tries to pay during rest, offer "start paying at next window" (e.g. 13:30). ## Session Lifecycle ``` Start → validate plate + user (registered) → check time rules (window / rest / holiday) → compute fee + end_at (skip rest, cap at daily max) → choose pay method (wallet / FPX / card) → create session (tenant_id, start_at, end_at, paid_hours) → ledger entry + notify user Active → valid while now < end_at within the tenant Expired → now >= end_at ``` ## Extend - Supported by the backend data model (session `end_at` can be extended). - The **extend button lives in the user-app**. - Extension must respect the same rules: charging windows, rest skipping, and **daily max chargeable**. - Decision (implementation detail): extend updates the same session's `end_at` vs creating a linked session — to be finalized in user-app phase. ## Backend Responsibilities (even though UI is in user-app) 1. Store **charging windows** per tenant (and day type). 2. Compute **daily max chargeable**. 3. Store session with the **real `end_at`** (rest-adjusted) so the scanner verifies correctly. 4. Apply **public holiday** = free all day (block payment). 5. Enforce **tenant scoping** on every session. ## Open Items - Pay during rest time: confirmed approach (offer next window) — UI detail in user-app. - Extend storage model (same session vs linked) — user-app phase.
Simpan Perubahan