feat: products and prices from the database, edited in the Kanban's Site tab (front 8.1)
Gestão and the administrators switch each product on and off and set its price from a start date; a price that has started is history and cannot change, a scheduled one can be cancelled. The Site and the server read the current price; with no row the code's prices and TREATMENT_CENTS still apply, so nothing changes until someone sets one. A switched-off product disappears from the Site and new quotes with it are refused. Approved quotes and paid orders keep their price. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,7 @@ from uuid import UUID, uuid4
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from psycopg.types.json import Jsonb
|
||||
|
||||
from .. import payments
|
||||
from .. import catalog, payments
|
||||
from ..core import db
|
||||
from ..core.auth import owner
|
||||
from ..core.models import QuoteRequest
|
||||
@@ -35,15 +35,19 @@ def create_quote(body: QuoteRequest, session_id=Depends(owner)):
|
||||
if item.get('stroke_choice'):
|
||||
item['stroke_choice_at'] = accepted_at
|
||||
reason = quote_review.review_reason(draft)
|
||||
if reason is not None:
|
||||
# Waits for review: check the delivery now, priced at approval.
|
||||
try:
|
||||
priced = [price(item.mode, str(item.metres), item.grade) for item in body.items]
|
||||
freight.quote(body.freight.service, body.freight.postal_code,
|
||||
sum(Decimal(i['billed_metres']) for i in priced), sum(i['total_cents'] for i in priced))
|
||||
except ValueError as exc:
|
||||
raise HTTPException(422, str(exc))
|
||||
with db.connect() as c:
|
||||
if reason is not None:
|
||||
# Waits for review: check the delivery now, priced at approval.
|
||||
try:
|
||||
priced = []
|
||||
for item in body.items:
|
||||
catalog.require_enabled(c, item.mode)
|
||||
priced.append(price(item.mode, str(item.metres), item.grade,
|
||||
unit_cents=catalog.unit_cents(c, item.mode)))
|
||||
freight.quote(body.freight.service, body.freight.postal_code,
|
||||
sum(Decimal(i['billed_metres']) for i in priced), sum(i['total_cents'] for i in priced))
|
||||
except ValueError as exc:
|
||||
raise HTTPException(422, str(exc))
|
||||
rows = {}
|
||||
for item in body.items:
|
||||
for uid in item.uploads:
|
||||
|
||||
Reference in New Issue
Block a user