api.services.pricing ==================== .. py:module:: api.services.pricing .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: api.services.pricing.DEFAULT_GRID Classes ------- .. autoapisummary:: api.services.pricing.Tier api.services.pricing.PricingGrid Functions --------- .. autoapisummary:: api.services.pricing.load_grid api.services.pricing.grid_saved api.services.pricing.load_grid_meta api.services.pricing.save_grid Module Contents --------------- .. py:class:: Tier Bases: :py:obj:`pydantic.BaseModel` .. py:attribute:: max_price :type: float | None .. py:attribute:: bon_pct :type: float .. py:attribute:: abime_pct :type: float .. py:class:: PricingGrid Bases: :py:obj:`pydantic.BaseModel` .. py:attribute:: tiers :type: list[Tier] .. py:method:: tier_for(price: float) -> Tier .. py:method:: 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. .. py:method:: prices(price: float) -> tuple[float, float] (bon état, abimé) for a Variation price, rounded to the cent. .. py:data:: DEFAULT_GRID .. py:function:: load_grid() -> PricingGrid .. py:function:: grid_saved() -> bool Whether an admin has saved a grid yet (until then, prices are not managed by the API). .. py:function:: load_grid_meta() -> dict[str, Any] The grid with when/who last changed it (None until first saved). .. py:function:: save_grid(grid: PricingGrid, updated_at: str, updated_by: str | None) -> None