feat(pos): refunds at the counter on a fiscal driver layer (platform-v2 3.3e)
- services/fiscal/: one driver interface (prepare_receipt / prepare_credit_note -> send,
credit_notes flag, status); the dTEC100extra folder bridge moved into txt_file.py as the
first driver, same command files. fiscal_service.py removed, callers moved.
- Refunds: models/refund.py + Alembic 0016 (refunds, refund_items; ordering.refunds for
existing owners/managers). services/refunds.py: today's business day, the cashier's open
shift, partial quantities, items from another shift need ordering.refunds or a manager's
approval (check()/authorize() return the override row). Paid items are never edited.
- POS: GET /api/pos/receipts, GET /api/pos/receipts/{id}, POST /api/pos/orders/{id}/refund
(cash opens the drawer; fiscal "manual" when the driver can't issue credit notes).
- Shift totals subtract refunds and now count discounts; day close and business-day
reports carry refunds.
- Terminal: Receipts mode (ReceiptsView, ReceiptPanel, logic/refunds.js), en/el texts.
- Tests: test_pos_refunds.py (12), terminal unit +1, terminal.mjs +7.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -44,8 +44,9 @@ def can(user, key: str, db=None) -> bool:
|
||||
return is_effective(module_of(key), db) and holds(user, key)
|
||||
|
||||
|
||||
def check(ctx: AccessContext, key: str, db=None) -> None:
|
||||
"""Raise the right XeniaError unless `key` is allowed for this request."""
|
||||
def check(ctx: AccessContext, key: str, db=None):
|
||||
"""Raise the right XeniaError unless `key` is allowed for this request. Returns the
|
||||
AccessOverride row when a manager's approval was used (else None)."""
|
||||
from core.modules.state import blocked_error, is_effective
|
||||
module = module_of(key)
|
||||
if not is_effective(module, db):
|
||||
@@ -59,7 +60,6 @@ def check(ctx: AccessContext, key: str, db=None) -> None:
|
||||
from core.access.override import consume, is_overridable
|
||||
if is_overridable(key):
|
||||
if ctx.override_token:
|
||||
consume(db, ctx.override_token, key, ctx.session, ctx.target)
|
||||
return
|
||||
return consume(db, ctx.override_token, key, ctx.session, ctx.target)
|
||||
raise XeniaError("access.override_possible", key=key)
|
||||
raise XeniaError("access.denied", key=key)
|
||||
|
||||
@@ -127,13 +127,14 @@ def context_for(request: Request, user, db) -> AccessContext:
|
||||
target=f"{request.method} {request.url.path}")
|
||||
|
||||
|
||||
def authorize(request: Request, db, user, key: str, target: str | None = None) -> None:
|
||||
"""check() from inside an endpoint (module, device scope, key, manager override)."""
|
||||
def authorize(request: Request, db, user, key: str, target: str | None = None):
|
||||
"""check() from inside an endpoint (module, device scope, key, manager override). Returns
|
||||
the AccessOverride row when a manager approved it, else None."""
|
||||
from core.access.check import check
|
||||
ctx = context_for(request, user, db)
|
||||
if target:
|
||||
ctx.target = target
|
||||
check(ctx, key, db)
|
||||
return check(ctx, key, db)
|
||||
|
||||
|
||||
def get_context(request: Request, db: Session = Depends(get_db),
|
||||
|
||||
@@ -74,6 +74,9 @@ CODES: dict[str, tuple[int, str]] = {
|
||||
"pos.table_not_yours": (403, "{table} isn't in your zones. A manager can add the zone to your account."),
|
||||
"pos.items_changed": (409, "Some of these items were paid or cancelled in the meantime. Check the order and try again."),
|
||||
"pos.order_unpaid": (409, "Items still unpaid: {count}. Take the payment or cancel them first."),
|
||||
"refund.invalid": (422, "This refund doesn't add up ({reason})."),
|
||||
"refund.too_old": (409, "Only payments from today's business day can be refunded at the counter."),
|
||||
"refund.items_changed": (409, "Some of these items were refunded in the meantime. Check the order and try again."),
|
||||
"online.not_found": (404, "Online order {order_id} not found."),
|
||||
"online.status_changed": (409, "This online order was changed on another screen in the meantime. Check where it is now."),
|
||||
"kds.item_not_found": (404, "Item {item_id} not found on this order."),
|
||||
|
||||
Reference in New Issue
Block a user