Cashier creates an ETTN receipt in Checkbox bound to the TTN with payment control; Checkbox fiscalizes it itself when the parcel is paid for. - cash_registers (Fernet-encrypted license key / PIN) and receipts tables - Checkbox HTTP client + stub (ETTN does not work on test registers) - two-phase create via ARQ job, timeout reconciliation, cron status polling - /receipts and /cash-registers API, audit records - dashboard: per-order and bulk create, prepayment, cancel; cash registers page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
"""Кассы (ПРРО) Checkbox.
|
|
|
|
Ключ лицензии и PIN кассира хранятся только в зашифрованном виде
|
|
(`app/core/crypto.py`): утечка дампа БД не должна давать доступ к кассе.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from sqlalchemy import Boolean, Index, String, text
|
|
from sqlalchemy.dialects.postgresql import JSONB
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.db.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
|
|
|
|
|
|
class CashRegister(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
|
__tablename__ = "cash_registers"
|
|
|
|
name: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
fiscal_number: Mapped[str | None] = mapped_column(String(64))
|
|
license_key_enc: Mapped[str] = mapped_column(String(512), nullable=False)
|
|
cashier_pin_enc: Mapped[str] = mapped_column(String(512), nullable=False)
|
|
# Коды налоговых ставок Checkbox для всех товаров чека; пусто — поле `tax`
|
|
# не передаётся (неплательщик ПДВ).
|
|
tax_codes: Mapped[list[Any]] = mapped_column(JSONB, nullable=False, default=list)
|
|
is_active: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True)
|
|
is_default: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
|
|
|
__table_args__ = (
|
|
# Касса по умолчанию может быть только одна.
|
|
Index(
|
|
"uq_cash_registers_default",
|
|
"is_default",
|
|
unique=True,
|
|
postgresql_where=text("is_default"),
|
|
),
|
|
)
|