scripts.airtable.variation_pricing_report

Read-only report on the variation-pricing migration. Run it BEFORE the migration: it reads the current hand-typed “Prix de vente HT” of every unit, which the migration then replaces by a formula.

It replays the migration (variation_pricing_migration) and the new “Prix de vente HT” formula on the current data, writes nothing to Airtable, and creates in –out:

  • rapport_migration_prix.pdf the analysis: changes, statistics, products to review

  • unites_prix_avant_apres.csv every unit: current price, price after migration, gap, flags

  • variations_prix_avant_apres.csv every Variation: prices before/after, spread of its units

  • historique_prix.csv a dated copy of every current price (long format: files of

    several dates can simply be concatenated)

Source: the Airtable base in .env (default), or an AirtableToCSV export (–from-csv DIR). Grid: the file at PRICING_GRID_PATH, or the default grid.

Usage: uv run python -m scripts.airtable.variation_pricing_report [–from-csv DIR] [–out DIR]

Attributes

Functions

formula_price(condition, declasse_price, variation) → float | None

The new "Prix de vente HT" formula of "Toutes les unités", in Python.

simulate(units, variations, grid) → dict[str, Any]

Every unit and Variation before/after the migration, with the migration's own counts.

shopify_rows(sim) → list[dict[str, Any]]

The price each listed Shopify variant (Model × variant value × état) shows, before and after:

build_report(sim, grid, source, data_at, generated_at) → dict[str, Any]

render_pdf(report, path) → None

write_history(path, units, variations, source, taken_at) → int

Every non-empty price as it is now, one line per record and field.

main() → int

Module Contents

scripts.airtable.variation_pricing_report.TEMPLATE_DIR
scripts.airtable.variation_pricing_report.SOLD_PRICE = 'Prix vendu HT'
scripts.airtable.variation_pricing_report.BUYBACK_PRICE = 'Prix de rachat'
scripts.airtable.variation_pricing_report.STATUS = 'Statut commercial'
scripts.airtable.variation_pricing_report.CONDITION = 'Etat esthétique'
scripts.airtable.variation_pricing_report.BRAND = 'Nom de la marque (à partir de Model)'
scripts.airtable.variation_pricing_report.TYPE = 'Type (à partir de Model)'
scripts.airtable.variation_pricing_report.REPORT_UNIT_FIELDS
scripts.airtable.variation_pricing_report.REPORT_VARIATION_FIELDS
scripts.airtable.variation_pricing_report.REQUIRED
scripts.airtable.variation_pricing_report.ACCEPTED_CONDITIONS
scripts.airtable.variation_pricing_report.BON_CONDITIONS = ('Bon',)
scripts.airtable.variation_pricing_report.ABIME_CONDITIONS = ('Abimé', 'Très abimé')
scripts.airtable.variation_pricing_report.SOURCE_LABELS
scripts.airtable.variation_pricing_report.REFERENCE_CONDITIONS = ('Très bon', '')
scripts.airtable.variation_pricing_report.NUMBER_FIELDS
scripts.airtable.variation_pricing_report.LOOKUP_FIELDS
scripts.airtable.variation_pricing_report.SPREAD_CV = 0.25
scripts.airtable.variation_pricing_report.SPREAD_RATIO = 1.5
scripts.airtable.variation_pricing_report.FAR_FROM_UNITS = 0.3
scripts.airtable.variation_pricing_report.HISTOGRAM_BUCKETS
scripts.airtable.variation_pricing_report.formula_price(condition: str, declasse_price: Any, variation: dict[str, Any] | None) → float | None

The new “Prix de vente HT” formula of “Toutes les unités”, in Python.

scripts.airtable.variation_pricing_report.simulate(units: list[dict[str, Any]], variations: list[dict[str, Any]], grid: api.services.pricing.PricingGrid) → dict[str, Any]

Every unit and Variation before/after the migration, with the migration’s own counts.

scripts.airtable.variation_pricing_report.shopify_rows(sim: dict[str, Any]) → list[dict[str, Any]]

The price each listed Shopify variant (Model × variant value × état) shows, before and after: the cheapest unit “A vendre”, else the cheapest listed one (as update_product does).

scripts.airtable.variation_pricing_report.build_report(sim: dict[str, Any], grid: api.services.pricing.PricingGrid, source: str, data_at: datetime.datetime, generated_at: datetime.datetime) → dict[str, Any]
scripts.airtable.variation_pricing_report.render_pdf(report: dict[str, Any], path: pathlib.Path) → None
scripts.airtable.variation_pricing_report.UNIT_COLUMNS
scripts.airtable.variation_pricing_report.VARIATION_COLUMNS
scripts.airtable.variation_pricing_report.HISTORY_UNIT_FIELDS
scripts.airtable.variation_pricing_report.HISTORY_VARIATION_FIELDS
scripts.airtable.variation_pricing_report.write_history(path: pathlib.Path, units: list[dict[str, Any]], variations: list[dict[str, Any]], source: str, taken_at: datetime.datetime) → int

Every non-empty price as it is now, one line per record and field.

scripts.airtable.variation_pricing_report.main() → int