Sale-таблица показывает LOT/Описание/Кол-во/Накидка,%/Цена вместо Estimate/ Склад/Конкуренты/Ручная цена; итоговая цена строки = база (raw estimate или доля от общей «Ручная цена») × (Аплифт к estimate + своя Накидка%). Экспорт CSV этой таблицы теперь выводит только LOT;Описание;Кол-во;Цена. Buy-таблица и массовый экспорт по проекту не затронуты — новые поля запроса опциональны и включаются только кнопкой «Экспорт CSV» у Sale-таблицы. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
3.7 KiB
3.7 KiB
Decision: per-row "Накидка" on the Sale table + minimal Sale CSV columns
Date: 2026-09-15 Status: active
Context
The Sale (Цена продажи) table only had one table-wide "Аплифт к estimate" multiplier and one table-wide "Ручная цена" override. There was no way to push margin up on individual rows (e.g. scarce GPUs) without changing the uplift for every row, and the table showed Estimate/Склад/Конкуренты/Ручная-цена columns that a sales rep handing a quote to a customer never needed — the actual deliverable is just LOT, Описание, Кол-во, and a final price.
Decision
- The Sale table gains a per-row "Накидка, %" input. Each row's final "Цена" is
base × (Аплифт к estimate + Накидка% / 100), wherebaseis the row's raw Estimate unit price × qty, or — when the table-wide "Ручная цена" is set — that row's proportional share of the manual total (same last-row-absorbs-remainder distribution the table-wide manual price already used, now overwriting the row's base instead of filling a separate column). - The Sale table's visible/exported columns collapse to
PN вендора | Описание | LOT | Кол-во | Накидка, % | Ценаon screen, and exactlyLOT;Описание;Кол-во;Ценаin its own CSV export. Estimate, Склад, Конкуренты, and the old Ручная-цена column are no longer shown or exported for this table. The Buy table (Цена покупки) is untouched. - Per-row markup is keyed by
"<vendorPN>::<lot>"(uppercased,NONEwhen there is no vendor PN) — not bylot_namealone, since the same LOT can appear under more than one vendor-PN BOM group (see "Per-LOT row expansion rules" in02-architecture.md). - Persistence is additive:
Configuration.Notes.pricing_uigains a newsale_row_markupsmap alongside the existingsale_uplift/sale_custom_price, the same JSON-blob-in-Notesmechanism established by 2026-08-12-project-export-per-config-sale-uplift.md. Zero/unset rows are omitted from the map entirely. - CSV export:
POST /api/configs/:uuid/export/pricinggainedminimal_sale_columns(bool) andsale_row_markups(map) request fields, read intoProjectPricingExportOptions.MinimalSaleColumns/SaleRowMarkups. These are wired only inExportConfigPricingCSV, gated onreq.MinimalSaleColumnsbeing true — the Sale table's own "Экспорт CSV" button is the only caller that sets it. Buy export (basis=fob) and the project-level bulk export (ExportProjectPricingCSV) never send it and keep their full existing column sets/output unchanged. ProjectPricingExportOptions.ManualPrice, previously parsed from the request but never actually read into the options struct (a pre-existing dead field), is now wired — but only inside the sameMinimalSaleColumnsgate, so this bug fix does not change Buy-table CSV output for anyone already relying on the old (broken) behavior.
Consequences
- Old clients / already-saved configurations are unaffected:
sale_row_markupsabsent fromNotesmeans every row's markup defaults to 0%, reproducing the exact totals the table produced before this change (uplift-only). Old clients that don't know the newNoteskey simply ignore it, exactly likesale_upliftis ignored by even older code. - If a future caller needs the full-column DDP CSV format with per-row markup applied,
it must do so explicitly —
MinimalSaleColumnsintentionally couples "reduced columns" and "per-row markup applied" as one request-level switch rather than two independent options, since the only current caller needs both together.