api.scripts.variation_pricing

Variation prices from the discount grid (api/services/pricing.py).

Writes each Variation’s “Prix bon état €HT” and “Prix abimé €HT” from its “Prix de la variation” (hand edits are overwritten), then queues one update_product per Model on Shopify whose prices changed. The units’ “Prix de vente HT” is an Airtable formula over these prices (by “Etat esthétique”), so nothing is written on the units.

Two entry points:

  • record_id (a Variation id): sent by the Airtable automation when “Prix de la variation” changes; that Variation is recomputed now and its product updated.

  • no record_id (every day at 19:00 Europe/Paris, or on demand): recomputes every Variation, only when the grid changed since the last applied one. Only the values that differ are written. The first run (no snapshot yet) also updates every Shopify product, which pushes the prices of the new formula once.

Attributes

Classes

Functions

price_updates(variations, grid) → list[dict[str, Any]]

[{"id", "fields"}] for each Variation whose bon/abimé prices differ from the grid's.

models_on_shopify(variations) → list[str]

Model ids (deduplicated, in order) of the Variations sold on an existing Shopify

Module Contents

api.scripts.variation_pricing.logger
api.scripts.variation_pricing.PRICE_FIELD = 'Prix de la variation'
api.scripts.variation_pricing.BON_FIELD = 'Prix bon état €HT'
api.scripts.variation_pricing.ABIME_FIELD = 'Prix abimé €HT'
api.scripts.variation_pricing.FIELDS
api.scripts.variation_pricing.UPDATE_PRODUCT_DELAY_SECONDS = 15
api.scripts.variation_pricing.price_updates(variations: list[dict[str, Any]], grid: api.services.pricing.PricingGrid) → list[dict[str, Any]]

[{“id”, “fields”}] for each Variation whose bon/abimé prices differ from the grid’s. A Variation without a positive price is left alone.

api.scripts.variation_pricing.models_on_shopify(variations: list[dict[str, Any]]) → list[str]

Model ids (deduplicated, in order) of the Variations sold on an existing Shopify product – the others have nothing to update (and an unset to_sell_on_shopify would only raise an alert per Model).

class api.scripts.variation_pricing.VariationPricing
name = 'variation_pricing'
schedule
is_configured() → bool
run(previous_snapshot: dict[str, Any] | None = None, report_stage: api.scripts.base.StageReporter = lambda stage: ..., **kwargs: Any) → tuple[api.scripts.base.ScriptResult, dict[str, Any] | None]