feat: montador Interno and Venda, Tiny customers, brand per stamp (front 7a.3, Marcus 10/11)

Interno: the Expedição assembles the marketplace's own sales on the fixed
internal customer Gestão fills in once; no Tiny order, no paid e-mail,
marked interno, it stays in house. Venda: a Vendedor or Gestão picks the
customer from the Tiny base and the order goes to Tiny like an approved
quote, faturado (Boleto from TINY_RECEIPT_BOLETO when set), pickup or
'junto com o pedido de roupa nº X'. Números counts both at table price,
apart from cash (and the average ticket over cash orders only). Each stamp
can carry a brand and a public flag for the future catalogue.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-11 11:01:44 -03:00
parent e6197d6e40
commit b5a51137fb
15 changed files with 710 additions and 97 deletions

View File

@@ -0,0 +1,24 @@
-- Front 7a.3: a brand per stamp, for the future catalogue, and the montador's
-- fixed internal customer. The brand is only recorded here for now; nothing
-- else reads it yet (Marcus, 2026-11-10).
CREATE TABLE IF NOT EXISTS dtf_local.stamps (
code text PRIMARY KEY CHECK (code ~ '^[A-Za-z0-9_-]{1,40}$'),
brand text NOT NULL DEFAULT '',
public boolean NOT NULL DEFAULT false,
updated_by text NOT NULL,
updated_at timestamptz NOT NULL DEFAULT now()
);
-- The one customer every Interno order belongs to (the marketplace's own
-- sales). Gestão completes it; until then an Interno order is refused.
CREATE TABLE IF NOT EXISTS dtf_local.internal_customer (
id integer PRIMARY KEY DEFAULT 1 CHECK (id=1),
name text NOT NULL DEFAULT '',
cnpj text NOT NULL DEFAULT '',
zap text NOT NULL DEFAULT '',
mail text NOT NULL DEFAULT '',
updated_by text NOT NULL DEFAULT 'sistema',
updated_at timestamptz NOT NULL DEFAULT now()
);
INSERT INTO dtf_local.internal_customer(id,name) VALUES(1,'Nexstar · Marketplace')
ON CONFLICT (id) DO NOTHING;