feat: discount coupons (front 8.3)
Gestão creates coupons in the Site tab: a code, a percentage or an amount per billed metre, validity, a minimum of metres, use limits in all and per customer, one product or all, and a note; they can be paused and deleted (kept for history). The customer types the code at checkout; the server checks it when the quote is made and again at approval, discounts only the eligible items after the bands (never freight or the treatment) and keeps the coupon on the order. Tiny gets the discount, the e-mail and receipt show it, the order panel carries a badge and Números counts orders, metres, discount and money per coupon. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -267,6 +267,8 @@ class QuoteRequest(StrictModel):
|
||||
proof: bool = False
|
||||
# "Quero o tratamento pelo designer": a fixed service line, when priced (front 5).
|
||||
treatment: bool = False
|
||||
# A coupon code typed at checkout (front 8.3); the server prices it.
|
||||
coupon: str | None = Field(default=None, max_length=30)
|
||||
# What the browser measured while the customer built the cart (item 0.12).
|
||||
timings: ClientTimings | None = None
|
||||
|
||||
@@ -371,6 +373,34 @@ class SitePriceNew(StrictModel):
|
||||
bands: list[PriceBand] = Field(default_factory=list)
|
||||
|
||||
|
||||
class CouponNew(StrictModel):
|
||||
"""Um cupom novo, criado na aba Site (front 8.3)."""
|
||||
code: str = Field(min_length=1, max_length=30)
|
||||
kind: Literal['percent', 'per_metre']
|
||||
value: int = Field(gt=0, le=10000000, strict=True)
|
||||
valid_from: datetime | None = None
|
||||
valid_until: datetime | None = None
|
||||
min_metres: Decimal | None = Field(default=None, gt=0, decimal_places=1)
|
||||
max_uses: int | None = Field(default=None, gt=0, strict=True)
|
||||
max_uses_per_customer: int | None = Field(default=None, gt=0, strict=True)
|
||||
product: Literal['file', 'avulsa', 'uvfile', 'uv'] | None = None
|
||||
note: str = Field(default='', max_length=1000)
|
||||
|
||||
|
||||
class CouponUpdate(StrictModel):
|
||||
"""Os campos de um cupom que podem mudar; o código fica como foi criado."""
|
||||
kind: Literal['percent', 'per_metre'] | None = None
|
||||
value: int | None = Field(default=None, gt=0, le=10000000, strict=True)
|
||||
valid_from: datetime | None = None
|
||||
valid_until: datetime | None = None
|
||||
min_metres: Decimal | None = Field(default=None, gt=0, decimal_places=1)
|
||||
max_uses: int | None = Field(default=None, gt=0, strict=True)
|
||||
max_uses_per_customer: int | None = Field(default=None, gt=0, strict=True)
|
||||
product: Literal['file', 'avulsa', 'uvfile', 'uv'] | None = None
|
||||
note: str | None = Field(default=None, max_length=1000)
|
||||
paused: bool | None = None
|
||||
|
||||
|
||||
class Contraction(StrictModel):
|
||||
item_index: int = Field(ge=0, le=100)
|
||||
# None returns the item to the class the browser measured.
|
||||
|
||||
Reference in New Issue
Block a user