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:
@@ -12,6 +12,7 @@ from uuid import uuid5, NAMESPACE_URL
|
||||
from fastapi import HTTPException
|
||||
from psycopg.types.json import Jsonb
|
||||
|
||||
from . import catalog
|
||||
from .adapters import FakeFreight, FakePayment, LocalS3Storage, require_runtime
|
||||
from .freight import FreightOptions
|
||||
from .core.secrets import load as load_secret_files
|
||||
@@ -33,7 +34,6 @@ if os.environ.get('FREIGHT_ADAPTER') == 'jadlog':
|
||||
_carriers.append(JadlogFreight())
|
||||
from . import correios as _correios
|
||||
from . import prumo
|
||||
from .core.pricing import treatment_cents
|
||||
if _correios.configured():
|
||||
_carriers.append(_correios.CorreiosFreight())
|
||||
freight = FreightOptions(_carriers or [FakeFreight()])
|
||||
@@ -141,8 +141,10 @@ def quote_view(c, row, order=None, attempt=None, known=False):
|
||||
datetime.now(timezone.utc)-timedelta(hours=QUOTE_VALID_HOURS)))
|
||||
items = (row['approved'] or row['draft']).get('items') or []
|
||||
treatment = (row['approved'] or {}).get('treatment')
|
||||
if not treatment and (row['draft'] or {}).get('treatment') and treatment_cents():
|
||||
treatment = {'cents': treatment_cents(), 'hours': 24}
|
||||
if not treatment and (row['draft'] or {}).get('treatment'):
|
||||
offer = catalog.current(c)['tratamento']
|
||||
if offer['enabled'] and offer['unit_cents'] > 0:
|
||||
treatment = {'cents': offer['unit_cents'], 'hours': 24}
|
||||
return {'id': row['id'], 'created_at': row['created_at'],
|
||||
'draft': row['draft'], 'approved': row['approved'],
|
||||
'expires_at': expires_at.isoformat() if expires_at else None,
|
||||
|
||||
Reference in New Issue
Block a user