Отрицательная «Накидка, %» отбрасывалась в четырёх местах (ввод, сохранение, восстановление, отображение) — теперь любое ненулевое значение сохраняется, отрицательное работает как скидка. Коэффициент (аплифт + накидка/100) ограничен снизу нулём и в UI, и в CSV-экспорте. Принимается «−» (U+2212). Накидки пропадали после синхронизации: клиент до v3.41 собирает notes заново из трёх старых полей и при сохранении стирает sale_row_markups на сервере, а следующий pull перезаписывает локальную копию. Клиент теперь переносит незнакомые ключи notes/pricing_ui как есть, чтобы будущие поля не терялись. ADL исправлен (неверное утверждение «старые клиенты игнорируют ключ»). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
70 lines
4.6 KiB
Markdown
70 lines
4.6 KiB
Markdown
# 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)`, where `base` is 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 exactly
|
||
`LOT;Описание;Кол-во;Цена` 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, `NONE` when there is no
|
||
vendor PN) — not by `lot_name` alone, since the same LOT can appear under more than
|
||
one vendor-PN BOM group (see "Per-LOT row expansion rules" in `02-architecture.md`).
|
||
- Persistence is additive: `Configuration.Notes.pricing_ui` gains a new
|
||
`sale_row_markups` map alongside the existing `sale_uplift`/`sale_custom_price`, the
|
||
same JSON-blob-in-`Notes` mechanism established by
|
||
[2026-08-12-project-export-per-config-sale-uplift.md](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/pricing` gained `minimal_sale_columns`
|
||
(bool) and `sale_row_markups` (map) request fields, read into
|
||
`ProjectPricingExportOptions.MinimalSaleColumns`/`SaleRowMarkups`. These are wired
|
||
**only** in `ExportConfigPricingCSV`, gated on `req.MinimalSaleColumns` being 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 same `MinimalSaleColumns` gate, so this bug fix does not change
|
||
Buy-table CSV output for anyone already relying on the old (broken) behavior.
|
||
|
||
## Consequences
|
||
|
||
- Already-saved configurations are unaffected: `sale_row_markups` absent from `Notes`
|
||
means every row's markup defaults to 0%, reproducing the exact totals the table
|
||
produced before this change (uplift-only).
|
||
- **Correction (2026-09-24):** the original claim that old clients "simply ignore" the
|
||
new key was wrong. A pre-v3.41 client rebuilds `Notes` from scratch on save
|
||
(only `buy_custom_price`/`sale_uplift`/`sale_custom_price`), so opening and saving a
|
||
config in an old client — including the best-effort save on page exit — erases
|
||
`sale_row_markups` on the server, and the next pull overwrites every other client's
|
||
local copy. Observed in the field: a markup saved and pushed on 09-22 came back as
|
||
`null` on the 09-23 pull. From this fix on the client carries unknown `Notes` /
|
||
`pricing_ui` keys through verbatim, so future additive keys survive a save by the
|
||
current version; nothing can protect against clients older than this fix — all users
|
||
must upgrade.
|
||
- Negative Накидка is allowed (a per-row discount). The factor
|
||
`uplift + pct/100` is floored at 0 on both client and CSV export, so a large discount
|
||
gives a zero price instead of a negative one.
|
||
- If a future caller needs the full-column DDP CSV format with per-row markup applied,
|
||
it must do so explicitly — `MinimalSaleColumns` intentionally 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.
|