Merge main into front-7a

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

# Conflicts:
#	.gitea/workflows/deploy.yml
#	app/app.py
#	app/schema.sql
#	web/kanban.html
#	web/kanban.js
This commit is contained in:
Cauê Faleiros
2026-11-09 14:14:25 -03:00
22 changed files with 571 additions and 39 deletions

View File

@@ -582,6 +582,42 @@ CREATE TABLE IF NOT EXISTS dtf_local.machine_snoozes (
PRIMARY KEY(machine_id, alert, cycle_from)
);
-- Orders generated before the print file was a PNG with its strips (item 13)
-- open blank in the 100% viewer. Those not approved yet are generated again,
-- once: the same layout, now as PNG with strips. An approved final, a
-- customer's correction or a cancelled order is left as it is.
DO $$ BEGIN
IF NOT EXISTS (SELECT 1 FROM dtf_local.migrations WHERE name='png-regenerate-v1') THEN
UPDATE dtf_local.print_files p SET status='pending', attempts=0, claimed_at=NULL, claim_token=NULL,
finished_at=NULL, upload_id=NULL, detail='{}'
FROM dtf_local.orders o
WHERE o.id=p.order_id AND o.state='rec' AND o.cancelled_at IS NULL
AND p.status='ready' AND NOT (p.detail ? 'format')
AND NOT EXISTS (SELECT 1 FROM dtf_local.order_files f WHERE f.order_id=p.order_id
AND f.item_index=p.item_index AND f.active);
INSERT INTO dtf_local.migrations VALUES('png-regenerate-v1');
END IF;
END $$;
-- Front 8: what the Site sells and at what price, edited in the Kanban's Site tab.
CREATE TABLE IF NOT EXISTS dtf_local.products (
id text PRIMARY KEY CHECK (id IN ('file','avulsa','uvfile','uv','tratamento')),
enabled boolean NOT NULL DEFAULT true,
updated_by text NOT NULL DEFAULT 'sistema',
updated_at timestamptz NOT NULL DEFAULT now()
);
INSERT INTO dtf_local.products(id) VALUES ('file'),('avulsa'),('uvfile'),('uv'),('tratamento')
ON CONFLICT (id) DO NOTHING;
CREATE TABLE IF NOT EXISTS dtf_local.product_prices (
id bigserial PRIMARY KEY,
product text NOT NULL REFERENCES dtf_local.products(id),
unit_cents integer NOT NULL CHECK (unit_cents >= 0 AND unit_cents <= 10000000),
starts_at timestamptz NOT NULL,
created_by text NOT NULL,
created_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS product_prices_current ON dtf_local.product_prices(product, starts_at DESC);
-- Front 7a: the stamp sizes of the Kanban's montador; Gestão edits them.
CREATE TABLE IF NOT EXISTS dtf_local.stamp_sizes (
letter text PRIMARY KEY CHECK (letter ~ '^[A-Z]{1,2}$'),