feat: rework register, opened by Gestao with a locked cause and authorized by an Administrador (Dropstar's rules D-02 to D-04)
All checks were successful
Build and deploy / Validate source (push) Successful in 10s
Build and deploy / Integration suite on a real stack (push) Successful in 3m27s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m2s

Gestao opens a rework from the order panel with its cause (falha de
impressao, perfil de cor, erro de tratamento, erro de pedido, or arte
aprovada pelo cliente, outside the goal), the metres redone and a note; the
cause never changes. An Administrador authorizes or declines it with a
reason, never one they opened, and only an authorized rework counts. The
order keeps who printed it. Numeros shows the metres redone per cause over
the film printed, against 0,4% per cause and 1,6% for the house, by who
printed, and the reworks waiting for authorization. Vendedor goes back to
viewing only (D-30): registering orders paid outside is Administrador and
Gestao.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-27 13:09:56 -03:00
parent babd9e327c
commit 5692804c6f
8 changed files with 282 additions and 17 deletions

View File

@@ -383,3 +383,21 @@ UPDATE dtf_local.orders SET origin='site' WHERE origin IS NULL;
ALTER TABLE dtf_local.orders ALTER COLUMN origin SET NOT NULL;
ALTER TABLE dtf_local.orders DROP CONSTRAINT IF EXISTS orders_origin_check;
ALTER TABLE dtf_local.orders ADD CONSTRAINT orders_origin_check CHECK (origin IN ('site','dropflow','atendimento'));
-- Rework (Dropstar's rules D-02 to D-04, 2026-10-26; the user's answers of
-- 2026-10-27). Gestão opens it with its cause, and the cause never changes
-- after (D-03); an Administrador authorizes or declines it, never one they
-- opened, and only an authorized rework counts. Bad art the customer approved
-- is recorded apart, outside the goal (D-04). printed_by is who sent the
-- sheet to Revisão, as the rework enters the printer's pay.
CREATE TABLE IF NOT EXISTS dtf_local.reworks (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
order_id uuid NOT NULL REFERENCES dtf_local.orders(id) ON DELETE CASCADE,
cause text NOT NULL CHECK (cause IN ('impressao','perfil_cor','tratamento','pedido','arte_cliente')),
metres numeric NOT NULL CHECK (metres > 0),
note text NOT NULL DEFAULT '',
printed_by text,
opened_by text NOT NULL, opened_at timestamptz NOT NULL DEFAULT now(),
authorized boolean, decided_by text, decided_at timestamptz, decline_reason text
);
CREATE INDEX IF NOT EXISTS reworks_order ON dtf_local.reworks(order_id);