feat: progressive price bands per product (front 8.2)
A price may carry up to five bands, "from N m, R$ Y": the order's total billed metres of that product chooses one price for its whole quantity, the manual-file extra still on top. Bands start and become history with their price row. The Site charges the same band for the cart, shows "Faltam X m para R$ Y o metro" and lists the bands under the price table; the Kanban's Site tab edits them. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -22,7 +22,7 @@ from psycopg.types.json import Jsonb
|
||||
from . import catalog, payments
|
||||
from .proof import PROOF_ABOVE_METRES
|
||||
from .core.models import PRODUCTION_VERSIONS
|
||||
from .core.pricing import bill_splits, is_manual, manual_extra_cents, price
|
||||
from .core.pricing import apply_bands, bill_splits, is_manual, manual_extra_cents, price
|
||||
from .runtime import freight, upload_row
|
||||
from .scanning import require_clean
|
||||
|
||||
@@ -92,6 +92,17 @@ def approve(c, row, items, reviewer):
|
||||
**({'source_dpi': original['source_dpi']} if original.get('source_dpi') else {}),
|
||||
**({'split': original['split']} if original.get('split') else {})})
|
||||
bill_splits(priced)
|
||||
# Progressive bands (front 8.2): one price for the whole quantity of each
|
||||
# product, chosen by the order's total billed metres of that mode.
|
||||
totals = {}
|
||||
for item in priced:
|
||||
totals[item['mode']] = totals.get(item['mode'], Decimal('0')) + Decimal(item['billed_metres'])
|
||||
banded = {}
|
||||
for mode, total in totals.items():
|
||||
price_for_total = catalog.unit_cents_for(c, mode, total)
|
||||
if price_for_total != catalog.unit_cents(c, mode):
|
||||
banded[mode] = price_for_total
|
||||
apply_bands(priced, banded)
|
||||
metres = sum(Decimal(i['billed_metres']) for i in priced)
|
||||
try:
|
||||
quoted_freight = freight.quote(draft['freight']['service'], draft['freight'].get('postal_code', ''),
|
||||
|
||||
Reference in New Issue
Block a user