api.services.pricing

Discount grid (“grille de décote”): a Variation’s “Prix de la variation” gives its “Prix bon état €HT” and “Prix abimé €HT” by price tier. Edited by admins from the app, applied by api/scripts/variation_pricing.py.

Stored as one JSON file on the API’s persistent volume (shared by the api and worker containers).

Attributes

Classes

Functions

load_grid() → PricingGrid

grid_saved() → bool

Whether an admin has saved a grid yet (until then, prices are not managed by the API).

load_grid_meta() → dict[str, Any]

The grid with when/who last changed it (None until first saved).

save_grid(grid, updated_at, updated_by) → None

Module Contents

class api.services.pricing.Tier

Bases: pydantic.BaseModel

max_price: float | None
bon_pct: float
abime_pct: float
class api.services.pricing.PricingGrid

Bases: pydantic.BaseModel

tiers: list[Tier]
tier_for(price: float) → Tier
variation_price_for(price: float, abime: bool = False) → float | None

The grid reversed: the Variation price whose bon état (or abimé) price is price. A price no tier can give (in the gap between two tiers) gets the closest one; None if every percentage is 0.

prices(price: float) → tuple[float, float]

(bon état, abimé) for a Variation price, rounded to the cent.

api.services.pricing.DEFAULT_GRID
api.services.pricing.load_grid() → PricingGrid
api.services.pricing.grid_saved() → bool

Whether an admin has saved a grid yet (until then, prices are not managed by the API).

api.services.pricing.load_grid_meta() → dict[str, Any]

The grid with when/who last changed it (None until first saved).

api.services.pricing.save_grid(grid: PricingGrid, updated_at: str, updated_by: str | None) → None