feat: products and prices from the database, edited in the Kanban's Site tab (front 8.1)
Gestão and the administrators switch each product on and off and set its price from a start date; a price that has started is history and cannot change, a scheduled one can be cancelled. The Site and the server read the current price; with no row the code's prices and TREATMENT_CENTS still apply, so nothing changes until someone sets one. A switched-off product disappears from the Site and new quotes with it are refused. Approved quotes and paid orders keep their price. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -581,3 +581,22 @@ CREATE TABLE IF NOT EXISTS dtf_local.machine_snoozes (
|
||||
snoozed_by text NOT NULL, snoozed_at timestamptz NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY(machine_id, alert, cycle_from)
|
||||
);
|
||||
|
||||
-- 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);
|
||||
|
||||
Reference in New Issue
Block a user