@fayz-ai/plugin-tables 0.10.6 → 0.10.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ComandaSettingsView-ZB5RK7TP.js → ComandaSettingsView-66M6MS6M.js} +5 -33
- package/dist/ComandaSettingsView-66M6MS6M.js.map +1 -0
- package/dist/CoverChargePolicyView-6UWTMPM7.js +280 -0
- package/dist/CoverChargePolicyView-6UWTMPM7.js.map +1 -0
- package/dist/ServiceChargePolicyView-CMG2OHRQ.js +286 -0
- package/dist/ServiceChargePolicyView-CMG2OHRQ.js.map +1 -0
- package/dist/data/core-supabase.d.ts.map +1 -1
- package/dist/data/types.d.ts +25 -1
- package/dist/data/types.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +359 -4
- package/dist/index.js.map +1 -1
- package/dist/migrations/index.d.ts +3 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/store.d.ts +25 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/types.d.ts +78 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/views/ComandaSettingsView.d.ts.map +1 -1
- package/dist/views/CoverChargePolicyView.d.ts +3 -0
- package/dist/views/CoverChargePolicyView.d.ts.map +1 -0
- package/dist/views/ServiceChargePolicyView.d.ts +3 -0
- package/dist/views/ServiceChargePolicyView.d.ts.map +1 -0
- package/package.json +4 -4
- package/dist/ComandaSettingsView-ZB5RK7TP.js.map +0 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export declare const MIGRATION_001_FLOOR_PLAN = "-- plugin-tables \u2014 the floor plan's own schema.\n--\n-- A mesa was homeless before this: `public.restaurant_tables` never shipped in\n-- any pool, and `orders.location_id` is a FK to `app.units` \u2014 the BRANCH, not a\n-- table in the sal\u00E3o. So the plugin owns its two tables, plus the row that ties\n-- a comanda to the mesa it is open on (the `plg_*_order_extensions` convention\n-- plugin-shop and plugin-courses already follow).\n--\n-- Idempotent. Applied to klvfxzreepavcpyjiwla on 2026-09-04.\n\ncreate table if not exists public.plg_tables_zones (\n id uuid primary key default gen_random_uuid(),\n tenant_id uuid not null references public.tenants(id) on delete cascade,\n name text not null,\n color text,\n sort_order integer not null default 0,\n is_active boolean not null default true,\n created_at timestamptz not null default now(),\n updated_at timestamptz not null default now()\n);\n\ncreate table if not exists public.plg_tables_tables (\n id uuid primary key default gen_random_uuid(),\n tenant_id uuid not null references public.tenants(id) on delete cascade,\n zone_id uuid references public.plg_tables_zones(id) on delete set null,\n name text not null,\n number integer not null,\n seats integer not null default 2 check (seats > 0),\n shape text not null default 'square'\n check (shape in ('square','round','rectangle','bar')),\n -- The stored state covers what nobody can derive: reserved and cleaning are\n -- decisions. `occupied` is NOT stored \u2014 it is the presence of an open\n -- comanda, and storing it twice is how a floor plan starts disagreeing with\n -- the orders list.\n status text not null default 'available'\n check (status in ('available','reserved','cleaning')),\n grid_col integer not null default 0,\n grid_row integer not null default 0,\n is_active boolean not null default true,\n created_at timestamptz not null default now(),\n updated_at timestamptz not null default now(),\n unique (tenant_id, number)\n);\n\n-- Which mesa a comanda is open on. One row per order, dropped with the order.\ncreate table if not exists public.plg_tables_order_extensions (\n order_id uuid primary key references public.orders(id) on delete cascade,\n tenant_id uuid not null references public.tenants(id) on delete cascade,\n table_id uuid references public.plg_tables_tables(id) on delete set null,\n guests integer check (guests is null or guests > 0),\n seated_at timestamptz not null default now(),\n created_at timestamptz not null default now(),\n updated_at timestamptz not null default now()\n);\n\ncreate index if not exists plg_tables_tables_tenant_idx on public.plg_tables_tables (tenant_id, number);\ncreate index if not exists plg_tables_zones_tenant_idx on public.plg_tables_zones (tenant_id, sort_order);\ncreate index if not exists plg_tables_order_ext_table_idx on public.plg_tables_order_extensions (table_id);\n\ndo $$ begin\n create trigger plg_tables_zones_updated_at before update on public.plg_tables_zones\n for each row execute function public.handle_updated_at();\nexception when duplicate_object then null; end $$;\ndo $$ begin\n create trigger plg_tables_tables_updated_at before update on public.plg_tables_tables\n for each row execute function public.handle_updated_at();\nexception when duplicate_object then null; end $$;\ndo $$ begin\n create trigger plg_tables_order_ext_updated_at before update on public.plg_tables_order_extensions\n for each row execute function public.handle_updated_at();\nexception when duplicate_object then null; end $$;\n\n-- Tenant-scoped, like every other plg_ table here. Deliberately NOT gated on\n-- `units.manage`: changing a mesa's state is a waiter's everyday job, and that\n-- permission is for managing business units.\nalter table public.plg_tables_zones enable row level security;\nalter table public.plg_tables_tables enable row level security;\nalter table public.plg_tables_order_extensions enable row level security;\n\n-- THE ACTIVE ACCOUNT, not every account you belong to.\n--\n-- The first pass scoped these by `user_tenant_ids()`, and the sal\u00E3o of one\n-- restaurant showed the mesas of another: that function honours only a signed\n-- JWT claim, while switching workspace happens through the `x-fayz-tenant`\n-- header \u2014 so it does not see the switch at all and answers with the UNION of\n-- the caller's accounts. Artorius drew Papa L\u00E9guas' two mesas.\n--\n-- `app.current_tenant_id()` is the one that reads the header, and it validates\n-- against app.memberships before trusting it: it CHOOSES among the accounts you\n-- already belong to and can never widen. The writes matter more than the reads\n-- here \u2014 union-scoped, a waiter in one sal\u00E3o could rename a mesa in another.\ndo $$\ndeclare t text;\nbegin\n foreach t in array array['plg_tables_zones','plg_tables_tables','plg_tables_order_extensions'] loop\n execute format('drop policy if exists %I on public.%I', t || '_select', t);\n execute format('drop policy if exists %I on public.%I', t || '_insert', t);\n execute format('drop policy if exists %I on public.%I', t || '_update', t);\n execute format('drop policy if exists %I on public.%I', t || '_delete', t);\n end loop;\n -- The first hand-run named the extension's four policies `..._order_ext_*`,\n -- shortened. The loop above drops `..._order_extensions_*`, so those four\n -- SURVIVED the rewrite \u2014 and a permissive policy that survives is not inert:\n -- Postgres ORs them, so the union-scoped leftovers put the leak straight back\n -- while the strict ones looked correct in the file. Named explicitly here so\n -- a replay onto a cluster that saw that first run comes out clean.\n foreach t in array array['plg_tables_order_ext_select','plg_tables_order_ext_insert',\n 'plg_tables_order_ext_update','plg_tables_order_ext_delete'] loop\n execute format('drop policy if exists %I on public.plg_tables_order_extensions', t);\n end loop;\n foreach t in array array['plg_tables_zones','plg_tables_tables','plg_tables_order_extensions'] loop\n execute format('create policy %I on public.%I for select using (tenant_id = (select app.current_tenant_id()))', t || '_select', t);\n execute format('create policy %I on public.%I for insert with check (tenant_id = (select app.current_tenant_id()))', t || '_insert', t);\n execute format('create policy %I on public.%I for update using (tenant_id = (select app.current_tenant_id()))', t || '_update', t);\n execute format('create policy %I on public.%I for delete using (tenant_id = (select app.current_tenant_id()))', t || '_delete', t);\n execute format('grant select, insert, update, delete on public.%I to authenticated', t);\n end loop;\nend $$;\n\n-- The floor plan as one read: every mesa with the comanda sitting on it, so\n-- \"ocupada\" and \"h\u00E1 um pedido aberto\" are the same fact read from one place.\n--\n-- A LATERAL, not a LEFT JOIN on the extension table: the extension rows are not\n-- filtered by the orders join, so a mesa served three times yesterday would come\n-- back three times today \u2014 once per closed comanda \u2014 and the floor plan would\n-- draw it three times while the summary counted it three times.\ncreate or replace view public.v_tables with (security_invoker = true) as\nselect\n t.id, t.tenant_id, t.zone_id, z.name as zone_name, z.color as zone_color,\n t.name, t.number, t.seats, t.shape, t.grid_col, t.grid_row, t.is_active,\n case when open.order_id is not null then 'occupied' else t.status end as status,\n open.order_id as current_order_id,\n open.reference_number as current_order_reference,\n open.total as current_total,\n open.guests as current_guests,\n open.seated_at as seated_at,\n t.created_at, t.updated_at\nfrom public.plg_tables_tables t\nleft join public.plg_tables_zones z on z.id = t.zone_id\nleft join lateral (\n select o.id as order_id, o.reference_number, o.total, x.guests, x.seated_at\n from public.plg_tables_order_extensions x\n join public.orders o on o.id = x.order_id\n where x.table_id = t.id\n and o.kind in ('dine_in','takeout','delivery')\n and o.status not in ('completed','cancelled')\n order by x.seated_at desc\n limit 1\n) open on true;\n\ngrant select on public.v_tables to authenticated;\n";
|
|
2
2
|
export declare const MIGRATION_002_COMANDA = "-- plugin-tables \u2014 a comanda que fecha a conta.\n--\n-- A mesa j\u00E1 abria, lan\u00E7ava item e somava. O que faltava \u00E9 tudo o que acontece\n-- entre sentar e pagar: de quem \u00E9 cada item, o desconto, o cancelamento com\n-- motivo, a transfer\u00EAncia, e a taxa de servi\u00E7o \u2014 que at\u00E9 aqui era uma\n-- CONSTANTE no c\u00F3digo do app (`serviceChargePercent: 10`) e por isso n\u00E3o\n-- chegava \u00E0 fatura levantada no fechamento.\n--\n-- Nenhuma coluna nova em `public.items` ou `public.orders`: as duas s\u00E3o a\n-- espinha compartilhada com shop, financeiro e CRM. Participante de restaurante\n-- mora em tabela do plugin, chaveada pelo pk da linha da espinha \u2014 a mesma\n-- conven\u00E7\u00E3o que `plg_tables_order_extensions` j\u00E1 usa.\n--\n-- E o que a espinha J\u00C1 tem n\u00E3o se recria: `items.discount`, `items.cancelled_at`\n-- e `items.cancel_reason` s\u00E3o colunas do baseline.\n--\n-- Idempotente.\n\n-- ---------------------------------------------------------------------------\n-- A casa\n-- ---------------------------------------------------------------------------\n\ncreate table if not exists public.plg_tables_settings (\n tenant_id uuid primary key references public.tenants(id) on delete cascade,\n service_charge_percent numeric(5,2) not null default 0\n check (service_charge_percent >= 0 and service_charge_percent <= 100),\n -- O terminal do sal\u00E3o fica logado a noite inteira, e quem cancela nem sempre\n -- \u00E9 quem est\u00E1 logado. Desligado por padr\u00E3o: o restaurante de um dono s\u00F3 nunca\n -- v\u00EA a segunda tela, e a rede que precisa dela liga em um clique \u2014 em vez de\n -- descobrir a exig\u00EAncia na sexta \u00E0 noite, como no V1.\n cancel_requires_pin boolean not null default false,\n -- O dia do restaurante n\u00E3o \u00E9 o dia do calend\u00E1rio: come\u00E7ar \u00E0s 06:00 mant\u00E9m a\n -- virada da madrugada no turno a que ela pertence.\n operational_day_start time not null default '06:00',\n created_at timestamptz not null default now(),\n updated_at timestamptz not null default now()\n);\n\n-- A taxa desta mesa. Nulo = a da casa.\nalter table public.plg_tables_order_extensions\n add column if not exists service_charge_percent numeric(5,2)\n check (service_charge_percent is null\n or (service_charge_percent >= 0 and service_charge_percent <= 100));\n\n-- ---------------------------------------------------------------------------\n-- O participante \u2014 a pe\u00E7a de que caem a transfer\u00EAncia e a taxa por pessoa\n-- ---------------------------------------------------------------------------\n\ncreate table if not exists public.plg_tables_order_guests (\n id uuid primary key default gen_random_uuid(),\n tenant_id uuid not null references public.tenants(id) on delete cascade,\n order_id uuid not null references public.orders(id) on delete cascade,\n seat_no integer not null check (seat_no > 0),\n label text,\n -- Nulo = a da mesa, que por sua vez cai para a da casa. \u00C9 a regra que o V1\n -- escreve na tela (\"Deixe em branco para usar a taxa geral\"), declarada uma\n -- vez no formato de dado em vez de reimplementada em cada di\u00E1logo.\n service_charge_percent numeric(5,2)\n check (service_charge_percent is null\n or (service_charge_percent >= 0 and service_charge_percent <= 100)),\n created_at timestamptz not null default now(),\n updated_at timestamptz not null default now(),\n unique (order_id, seat_no)\n);\n\n-- De quem \u00E9 a linha. Uma linha por item atribu\u00EDdo; item sem linha \u00E9 DA MESA.\ncreate table if not exists public.plg_tables_item_guests (\n item_id uuid primary key references public.items(id) on delete cascade,\n tenant_id uuid not null references public.tenants(id) on delete cascade,\n guest_id uuid not null references public.plg_tables_order_guests(id) on delete cascade,\n created_at timestamptz not null default now()\n);\n\n-- ---------------------------------------------------------------------------\n-- Cancelamento e transfer\u00EAncia\n-- ---------------------------------------------------------------------------\n\ncreate table if not exists public.plg_tables_cancel_reasons (\n id uuid primary key default gen_random_uuid(),\n tenant_id uuid not null references public.tenants(id) on delete cascade,\n label text not null,\n is_active boolean not null default true,\n sort_order integer not null default 0,\n created_at timestamptz not null default now(),\n updated_at timestamptz not null default now()\n);\n\n-- O hist\u00F3rico que o V1 mostra (\"Transfer\u00EAncias realizadas nesta comanda\") e que\n-- ningu\u00E9m consegue reconstruir depois, porque l\u00E1 a transfer\u00EAncia s\u00F3 reescreve o\n-- destino e n\u00E3o deixa rastro.\ncreate table if not exists public.plg_tables_order_transfers (\n id uuid primary key default gen_random_uuid(),\n tenant_id uuid not null references public.tenants(id) on delete cascade,\n order_id uuid not null references public.orders(id) on delete cascade,\n kind text not null check (kind in ('table','guest','items')),\n from_table_id uuid references public.plg_tables_tables(id) on delete set null,\n to_table_id uuid references public.plg_tables_tables(id) on delete set null,\n target_order_id uuid references public.orders(id) on delete set null,\n guest_id uuid,\n item_ids uuid[] not null default '{}',\n note text,\n performed_by uuid,\n created_at timestamptz not null default now()\n);\n\ncreate index if not exists plg_tables_order_guests_order_idx on public.plg_tables_order_guests (order_id, seat_no);\ncreate index if not exists plg_tables_item_guests_guest_idx on public.plg_tables_item_guests (guest_id);\ncreate index if not exists plg_tables_cancel_reasons_tenant_idx on public.plg_tables_cancel_reasons (tenant_id, sort_order);\ncreate index if not exists plg_tables_order_transfers_order_idx on public.plg_tables_order_transfers (order_id, created_at desc);\n\ndo $$ begin\n create trigger plg_tables_settings_updated_at before update on public.plg_tables_settings\n for each row execute function public.handle_updated_at();\nexception when duplicate_object then null; end $$;\ndo $$ begin\n create trigger plg_tables_order_guests_updated_at before update on public.plg_tables_order_guests\n for each row execute function public.handle_updated_at();\nexception when duplicate_object then null; end $$;\ndo $$ begin\n create trigger plg_tables_cancel_reasons_updated_at before update on public.plg_tables_cancel_reasons\n for each row execute function public.handle_updated_at();\nexception when duplicate_object then null; end $$;\n\n-- ---------------------------------------------------------------------------\n-- RLS \u2014 a conta ATIVA, nunca a uni\u00E3o das contas do usu\u00E1rio.\n-- Mesmo argumento (e mesma cicatriz) da 001: `user_tenant_ids()` honra s\u00F3 um\n-- claim do JWT e ignora a troca de workspace pelo header, ent\u00E3o responde com a\n-- UNI\u00C3O. Foi assim que Artorius desenhou as mesas do Papa L\u00E9guas.\n-- ---------------------------------------------------------------------------\n\n-- Escrito tabela a tabela, e n\u00E3o num `foreach` sobre um array de nomes.\n-- O la\u00E7o dizia a mesma coisa em menos linhas e escondia QUAIS tabelas ficam\n-- protegidas atr\u00E1s de um `execute format()` \u2014 invis\u00EDvel para quem l\u00EA o\n-- arquivo e para o `check-plugin-review`, que grada exatamente isto. Numa\n-- migra\u00E7\u00E3o de RLS, a repeti\u00E7\u00E3o \u00E9 a documenta\u00E7\u00E3o.\n\nalter table public.plg_tables_settings enable row level security;\ndrop policy if exists plg_tables_settings_select on public.plg_tables_settings;\ncreate policy plg_tables_settings_select on public.plg_tables_settings\n for select using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_settings_insert on public.plg_tables_settings;\ncreate policy plg_tables_settings_insert on public.plg_tables_settings\n for insert with check (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_settings_update on public.plg_tables_settings;\ncreate policy plg_tables_settings_update on public.plg_tables_settings\n for update using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_settings_delete on public.plg_tables_settings;\ncreate policy plg_tables_settings_delete on public.plg_tables_settings\n for delete using (tenant_id = (select app.current_tenant_id()));\ngrant select, insert, update, delete on public.plg_tables_settings to authenticated;\n\nalter table public.plg_tables_order_guests enable row level security;\ndrop policy if exists plg_tables_order_guests_select on public.plg_tables_order_guests;\ncreate policy plg_tables_order_guests_select on public.plg_tables_order_guests\n for select using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_order_guests_insert on public.plg_tables_order_guests;\ncreate policy plg_tables_order_guests_insert on public.plg_tables_order_guests\n for insert with check (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_order_guests_update on public.plg_tables_order_guests;\ncreate policy plg_tables_order_guests_update on public.plg_tables_order_guests\n for update using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_order_guests_delete on public.plg_tables_order_guests;\ncreate policy plg_tables_order_guests_delete on public.plg_tables_order_guests\n for delete using (tenant_id = (select app.current_tenant_id()));\ngrant select, insert, update, delete on public.plg_tables_order_guests to authenticated;\n\nalter table public.plg_tables_item_guests enable row level security;\ndrop policy if exists plg_tables_item_guests_select on public.plg_tables_item_guests;\ncreate policy plg_tables_item_guests_select on public.plg_tables_item_guests\n for select using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_item_guests_insert on public.plg_tables_item_guests;\ncreate policy plg_tables_item_guests_insert on public.plg_tables_item_guests\n for insert with check (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_item_guests_update on public.plg_tables_item_guests;\ncreate policy plg_tables_item_guests_update on public.plg_tables_item_guests\n for update using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_item_guests_delete on public.plg_tables_item_guests;\ncreate policy plg_tables_item_guests_delete on public.plg_tables_item_guests\n for delete using (tenant_id = (select app.current_tenant_id()));\ngrant select, insert, update, delete on public.plg_tables_item_guests to authenticated;\n\nalter table public.plg_tables_cancel_reasons enable row level security;\ndrop policy if exists plg_tables_cancel_reasons_select on public.plg_tables_cancel_reasons;\ncreate policy plg_tables_cancel_reasons_select on public.plg_tables_cancel_reasons\n for select using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_cancel_reasons_insert on public.plg_tables_cancel_reasons;\ncreate policy plg_tables_cancel_reasons_insert on public.plg_tables_cancel_reasons\n for insert with check (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_cancel_reasons_update on public.plg_tables_cancel_reasons;\ncreate policy plg_tables_cancel_reasons_update on public.plg_tables_cancel_reasons\n for update using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_cancel_reasons_delete on public.plg_tables_cancel_reasons;\ncreate policy plg_tables_cancel_reasons_delete on public.plg_tables_cancel_reasons\n for delete using (tenant_id = (select app.current_tenant_id()));\ngrant select, insert, update, delete on public.plg_tables_cancel_reasons to authenticated;\n\nalter table public.plg_tables_order_transfers enable row level security;\ndrop policy if exists plg_tables_order_transfers_select on public.plg_tables_order_transfers;\ncreate policy plg_tables_order_transfers_select on public.plg_tables_order_transfers\n for select using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_order_transfers_insert on public.plg_tables_order_transfers;\ncreate policy plg_tables_order_transfers_insert on public.plg_tables_order_transfers\n for insert with check (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_order_transfers_update on public.plg_tables_order_transfers;\ncreate policy plg_tables_order_transfers_update on public.plg_tables_order_transfers\n for update using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_order_transfers_delete on public.plg_tables_order_transfers;\ncreate policy plg_tables_order_transfers_delete on public.plg_tables_order_transfers\n for delete using (tenant_id = (select app.current_tenant_id()));\ngrant select, insert, update, delete on public.plg_tables_order_transfers to authenticated;\n\n-- ---------------------------------------------------------------------------\n-- A conta, calculada NUM lugar s\u00F3\n-- ---------------------------------------------------------------------------\n--\n-- O painel de Opera\u00E7\u00E3o do V1 tem seis blocos que se contradizem na mesma tela\n-- (V1-046: \"Sa\u00EDdas R$ 4.552,41\" logo acima de \"Nenhuma sa\u00EDda registrada\"),\n-- porque cada bloco faz a pr\u00F3pria consulta. A comanda do V1 tem o mesmo defeito\n-- em escala menor: o rodap\u00E9 soma de um jeito e a fatura levanta de outro, e \u00E9\n-- da\u00ED que sai o Resumo Financeiro que n\u00E3o fecha (V1-044).\n--\n-- Aqui a soma \u00E9 uma fun\u00E7\u00E3o. O rodap\u00E9 l\u00EA o que ela gravou; a fatura levantada no\n-- fechamento l\u00EA a mesma linha. N\u00E3o h\u00E1 segundo c\u00E1lculo com que discordar.\n\ncreate or replace function public.comanda_effective_service_percent(p_order_id uuid, p_guest_id uuid)\nreturns numeric\nlanguage sql stable\nas $$\n select coalesce(\n (select g.service_charge_percent from public.plg_tables_order_guests g where g.id = p_guest_id),\n (select x.service_charge_percent from public.plg_tables_order_extensions x where x.order_id = p_order_id),\n (select s.service_charge_percent from public.plg_tables_settings s\n where s.tenant_id = (select o.tenant_id from public.orders o where o.id = p_order_id)),\n 0\n );\n$$;\n\ncreate or replace function public.comanda_recalc(p_order_id uuid)\nreturns void\nlanguage plpgsql\nas $$\ndeclare\n v_subtotal numeric := 0;\n v_service numeric := 0;\n v_discount numeric := 0;\nbegin\n -- Item cancelado sai da soma, mas N\u00C3O sai da comanda: ele continua na tela,\n -- riscado, porque \"o que foi cancelado\" \u00E9 a pergunta que o painel de turno\n -- responde e a \u00FAnica que o V1 responde bem (Top Itens Cancelados).\n select\n coalesce(sum(i.total), 0),\n coalesce(sum(i.total * public.comanda_effective_service_percent(p_order_id, ig.guest_id) / 100), 0)\n into v_subtotal, v_service\n from public.items i\n left join public.plg_tables_item_guests ig on ig.item_id = i.id\n where i.order_id = p_order_id\n and i.cancelled_at is null;\n\n select coalesce(o.discount, 0) into v_discount from public.orders o where o.id = p_order_id;\n\n update public.orders\n set subtotal = v_subtotal,\n tax = round(v_service, 2),\n total = v_subtotal - v_discount + round(v_service, 2)\n where id = p_order_id;\nend;\n$$;\n\ngrant execute on function public.comanda_effective_service_percent(uuid, uuid) to authenticated;\ngrant execute on function public.comanda_recalc(uuid) to authenticated;\n\n-- Cada participante com o que consumiu e o que deve \u2014 a leitura que no V1 s\u00F3\n-- existe no app do gar\u00E7om (`J\u00E1 pago / Saldo devedor`), e que a tela\n-- administrativa nunca oferece.\ncreate or replace view public.v_comanda_guests with (security_invoker = true) as\nselect\n g.id, g.tenant_id, g.order_id, g.seat_no, g.label,\n g.service_charge_percent as own_service_charge_percent,\n public.comanda_effective_service_percent(g.order_id, g.id) as service_charge_percent,\n coalesce(sum(i.total) filter (where i.cancelled_at is null), 0) as subtotal,\n round(coalesce(sum(i.total) filter (where i.cancelled_at is null), 0)\n * public.comanda_effective_service_percent(g.order_id, g.id) / 100, 2) as service_charge,\n coalesce(sum(i.total) filter (where i.cancelled_at is not null), 0) as cancelled_total,\n count(i.id) filter (where i.cancelled_at is null) as item_count\nfrom public.plg_tables_order_guests g\nleft join public.plg_tables_item_guests ig on ig.guest_id = g.id\nleft join public.items i on i.id = ig.item_id\ngroup by g.id, g.tenant_id, g.order_id, g.seat_no, g.label, g.service_charge_percent;\n\ngrant select on public.v_comanda_guests to authenticated;\n";
|
|
3
|
+
export declare const MIGRATION_003_A_TAXA_E_UM_CONJUNTO_COM_ISENCOES = "-- plugin-tables \u2014 a taxa de servi\u00E7o deixa de ser UM n\u00FAmero.\n--\n-- A 002 trouxe a taxa da casa (`plg_tables_settings.service_charge_percent`),\n-- com override por mesa e por pessoa. \u00C9 o motor certo, e ele fica.\n--\n-- O que o V1 tem e n\u00E3o cabia num n\u00FAmero s\u00F3 (v1-guide/financeiro/taxa-servico):\n--\n-- 1. A taxa \u00E9 ESCOLHIDA na hora, dentro de um CONJUNTO. A tela do V1 lista\n-- 5% \u00B7 10% \u00B7 13% com uma marcada como padr\u00E3o, e o operador aplica outra\n-- sem editar cadastro. Um campo de texto obriga a redigitar o n\u00FAmero toda\n-- vez e n\u00E3o guarda quais s\u00E3o as op\u00E7\u00F5es da casa.\n-- 2. A taxa N\u00C3O incide sobre tudo. H\u00E1 isen\u00E7\u00E3o por produto e por categoria \u2014\n-- a categoria existe para n\u00E3o marcar item a item. No V1 \u00E9 lista de\n-- EXCE\u00C7\u00D5ES: por padr\u00E3o tudo entra na taxa.\n--\n-- O padr\u00E3o do conjunto \u00C9 a taxa da casa. N\u00E3o h\u00E1 segunda fonte de verdade: o\n-- gatilho abaixo escreve `plg_tables_settings.service_charge_percent` quando o\n-- padr\u00E3o muda, e `comanda_effective_service_percent` continua sendo a \u00FAnica\n-- fun\u00E7\u00E3o que responde \"qual \u00E9 a taxa desta linha\". Duas somas discordando \u00E9\n-- exatamente o defeito do V1 que o Resumo Financeiro dele exp\u00F5e (V1-044).\n--\n-- Idempotente.\n\n-- ---------------------------------------------------------------------------\n-- O conjunto\n-- ---------------------------------------------------------------------------\n\ncreate table if not exists public.plg_tables_service_charge_presets (\n id uuid primary key default gen_random_uuid(),\n tenant_id uuid not null references public.tenants(id) on delete cascade,\n name text not null,\n percent numeric(5,2) not null check (percent >= 0 and percent <= 100),\n -- Um s\u00F3 por tenant, garantido pelo \u00EDndice parcial abaixo. Zero \u00E9 valor\n -- v\u00E1lido: a casa que n\u00E3o cobra taxa ainda quer a op\u00E7\u00E3o nomeada na lista.\n is_default boolean not null default false,\n position integer not null default 0,\n created_at timestamptz not null default now(),\n updated_at timestamptz not null default now(),\n unique (tenant_id, name)\n);\n\ncreate unique index if not exists plg_tables_service_charge_presets_one_default\n on public.plg_tables_service_charge_presets (tenant_id)\n where is_default;\n\n-- ---------------------------------------------------------------------------\n-- As exce\u00E7\u00F5es\n-- ---------------------------------------------------------------------------\n--\n-- Uma tabela para as duas listas da tela do V1 (Categorias de Produto e\n-- Produtos Espec\u00EDficos), porque a pergunta que elas respondem \u00E9 a mesma: \"esta\n-- linha entra na base da taxa?\". Duas tabelas exigiriam dois `not exists` na\n-- soma e \u00E9 onde uma delas seria esquecida.\n\ncreate table if not exists public.plg_tables_service_charge_exemptions (\n id uuid primary key default gen_random_uuid(),\n tenant_id uuid not null references public.tenants(id) on delete cascade,\n target_kind text not null check (target_kind in ('product', 'category')),\n target_id uuid not null,\n created_at timestamptz not null default now(),\n unique (tenant_id, target_kind, target_id)\n);\n\ncreate index if not exists plg_tables_service_charge_exemptions_lookup\n on public.plg_tables_service_charge_exemptions (tenant_id, target_kind, target_id);\n\n-- ---------------------------------------------------------------------------\n-- O padr\u00E3o do conjunto \u00E9 a taxa da casa\n-- ---------------------------------------------------------------------------\n\ncreate or replace function public.plg_tables_sync_default_service_preset()\nreturns trigger\nlanguage plpgsql\nsecurity definer\nset search_path = public\nas $$\nbegin\n if new.is_default then\n -- Um padr\u00E3o por casa. Feito aqui e n\u00E3o s\u00F3 pelo \u00EDndice parcial: o \u00EDndice\n -- RECUSA o segundo padr\u00E3o, e o operador que clica \"Definir padr\u00E3o\" numa\n -- linha nova espera que a antiga ceda, n\u00E3o que o clique falhe.\n update public.plg_tables_service_charge_presets\n set is_default = false, updated_at = now()\n where tenant_id = new.tenant_id and id <> new.id and is_default;\n\n insert into public.plg_tables_settings (tenant_id, service_charge_percent)\n values (new.tenant_id, new.percent)\n on conflict (tenant_id) do update\n set service_charge_percent = excluded.service_charge_percent,\n updated_at = now();\n end if;\n return new;\nend;\n$$;\n\ndrop trigger if exists plg_tables_service_preset_sync on public.plg_tables_service_charge_presets;\ncreate trigger plg_tables_service_preset_sync\n after insert or update of is_default, percent on public.plg_tables_service_charge_presets\n for each row execute function public.plg_tables_sync_default_service_preset();\n\n-- ---------------------------------------------------------------------------\n-- A pergunta da isen\u00E7\u00E3o, escrita uma vez\n-- ---------------------------------------------------------------------------\n--\n-- `stable`, e n\u00E3o `immutable`: l\u00EA tabela. Chamada uma vez por linha da comanda\n-- dentro do `filter` da soma \u2014 o \u00EDndice de lookup acima \u00E9 o que a mant\u00E9m\n-- barata numa comanda de trinta itens.\n\ncreate or replace function public.comanda_item_is_service_exempt(p_item_id uuid)\nreturns boolean\nlanguage sql stable\nas $$\n select exists (\n select 1\n from public.items i\n join public.products p on p.id = i.product_id\n join public.plg_tables_service_charge_exemptions e\n on e.tenant_id = i.tenant_id\n and ( (e.target_kind = 'product' and e.target_id = p.id)\n or (e.target_kind = 'category' and e.target_id = p.category_id) )\n where i.id = p_item_id\n );\n$$;\n\n-- ---------------------------------------------------------------------------\n-- A soma passa a respeitar a exce\u00E7\u00E3o\n-- ---------------------------------------------------------------------------\n--\n-- O item isento continua no SUBTOTAL: ele foi consumido e \u00E9 cobrado. O que ele\n-- deixa de fazer \u00E9 entrar na BASE da taxa. Trocar a base pelo subtotal aqui \u00E9\n-- o erro que faria a bebida isenta sumir da conta.\n\ncreate or replace function public.comanda_recalc(p_order_id uuid)\nreturns void\nlanguage plpgsql\nas $$\ndeclare\n v_subtotal numeric := 0;\n v_service numeric := 0;\n v_discount numeric := 0;\nbegin\n -- Item cancelado sai da soma, mas N\u00C3O sai da comanda: ele continua na tela,\n -- riscado, porque \"o que foi cancelado\" \u00E9 a pergunta que o painel de turno\n -- responde e a \u00FAnica que o V1 responde bem (Top Itens Cancelados).\n select\n coalesce(sum(i.total), 0),\n coalesce(sum(i.total * public.comanda_effective_service_percent(p_order_id, ig.guest_id) / 100)\n filter (where not public.comanda_item_is_service_exempt(i.id)), 0)\n into v_subtotal, v_service\n from public.items i\n left join public.plg_tables_item_guests ig on ig.item_id = i.id\n where i.order_id = p_order_id\n and i.cancelled_at is null;\n\n select coalesce(o.discount, 0) into v_discount from public.orders o where o.id = p_order_id;\n\n update public.orders\n set subtotal = v_subtotal,\n tax = round(v_service, 2),\n total = v_subtotal - v_discount + round(v_service, 2)\n where id = p_order_id;\nend;\n$$;\n\n-- A leitura por participante l\u00EA a MESMA regra. Uma view que somasse a taxa\n-- sobre tudo enquanto o rodap\u00E9 isenta \u00E9 o Resumo Financeiro que n\u00E3o fecha.\ncreate or replace view public.v_comanda_guests with (security_invoker = true) as\nselect\n g.id, g.tenant_id, g.order_id, g.seat_no, g.label,\n g.service_charge_percent as own_service_charge_percent,\n public.comanda_effective_service_percent(g.order_id, g.id) as service_charge_percent,\n coalesce(sum(i.total) filter (where i.cancelled_at is null), 0) as subtotal,\n round(coalesce(sum(i.total) filter (where i.cancelled_at is null\n and not public.comanda_item_is_service_exempt(i.id)), 0)\n * public.comanda_effective_service_percent(g.order_id, g.id) / 100, 2) as service_charge,\n coalesce(sum(i.total) filter (where i.cancelled_at is not null), 0) as cancelled_total,\n count(i.id) filter (where i.cancelled_at is null) as item_count\nfrom public.plg_tables_order_guests g\nleft join public.plg_tables_item_guests ig on ig.guest_id = g.id\nleft join public.items i on i.id = ig.item_id\ngroup by g.id, g.tenant_id, g.order_id, g.seat_no, g.label, g.service_charge_percent;\n\ngrant select on public.v_comanda_guests to authenticated;\ngrant execute on function public.comanda_item_is_service_exempt(uuid) to authenticated;\n\n-- ---------------------------------------------------------------------------\n-- Authz\n-- ---------------------------------------------------------------------------\n--\n-- Tabela a tabela, sem la\u00E7o: numa migra\u00E7\u00E3o de RLS a repeti\u00E7\u00E3o \u00E9 a documenta\u00E7\u00E3o\n-- (ver o cabe\u00E7alho da 002).\n\nalter table public.plg_tables_service_charge_presets enable row level security;\ndrop policy if exists plg_tables_service_charge_presets_select on public.plg_tables_service_charge_presets;\ncreate policy plg_tables_service_charge_presets_select on public.plg_tables_service_charge_presets\n for select using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_service_charge_presets_insert on public.plg_tables_service_charge_presets;\ncreate policy plg_tables_service_charge_presets_insert on public.plg_tables_service_charge_presets\n for insert with check (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_service_charge_presets_update on public.plg_tables_service_charge_presets;\ncreate policy plg_tables_service_charge_presets_update on public.plg_tables_service_charge_presets\n for update using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_service_charge_presets_delete on public.plg_tables_service_charge_presets;\ncreate policy plg_tables_service_charge_presets_delete on public.plg_tables_service_charge_presets\n for delete using (tenant_id = (select app.current_tenant_id()));\ngrant select, insert, update, delete on public.plg_tables_service_charge_presets to authenticated;\ngrant all on public.plg_tables_service_charge_presets to service_role;\n\nalter table public.plg_tables_service_charge_exemptions enable row level security;\ndrop policy if exists plg_tables_service_charge_exemptions_select on public.plg_tables_service_charge_exemptions;\ncreate policy plg_tables_service_charge_exemptions_select on public.plg_tables_service_charge_exemptions\n for select using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_service_charge_exemptions_insert on public.plg_tables_service_charge_exemptions;\ncreate policy plg_tables_service_charge_exemptions_insert on public.plg_tables_service_charge_exemptions\n for insert with check (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_service_charge_exemptions_update on public.plg_tables_service_charge_exemptions;\ncreate policy plg_tables_service_charge_exemptions_update on public.plg_tables_service_charge_exemptions\n for update using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_service_charge_exemptions_delete on public.plg_tables_service_charge_exemptions;\ncreate policy plg_tables_service_charge_exemptions_delete on public.plg_tables_service_charge_exemptions\n for delete using (tenant_id = (select app.current_tenant_id()));\ngrant select, insert, update, delete on public.plg_tables_service_charge_exemptions to authenticated;\ngrant all on public.plg_tables_service_charge_exemptions to service_role;\n\n-- Toda tabela `plg_*` nova declara a sua authz no template, em modo `enforce` \u2014\n-- a su\u00EDte pgTAP 004 recusa a que ficar de fora.\ninsert into app.scaffold_registry\n (table_schema, table_name, resource_type, plugin, owner_scoping, mode, previous_policies, audit_hook, scope, distributable)\nvalues\n ('public', 'plg_tables_service_charge_presets', 'tables.service_charge_preset', 'tables', false, 'enforce', array[]::text[], false, 'tenant', false),\n ('public', 'plg_tables_service_charge_exemptions', 'tables.service_charge_exemption', 'tables', false, 'enforce', array[]::text[], false, 'tenant', false)\non conflict do nothing;\n\n-- ---------------------------------------------------------------------------\n-- A casa que j\u00E1 tinha uma taxa entra no conjunto sem mudar de comportamento\n-- ---------------------------------------------------------------------------\n--\n-- Sem isto, quem j\u00E1 cobrava 10% abriria a tela nova com a lista vazia e leria\n-- \"esta casa n\u00E3o cobra taxa\" \u2014 o n\u00FAmero continuaria em `plg_tables_settings`,\n-- invis\u00EDvel. O preset nasce com o valor que j\u00E1 vigora, marcado como padr\u00E3o.\n\ninsert into public.plg_tables_service_charge_presets (tenant_id, name, percent, is_default, position)\nselect s.tenant_id, 'Taxa da casa', s.service_charge_percent, true, 0\n from public.plg_tables_settings s\n where not exists (\n select 1 from public.plg_tables_service_charge_presets p where p.tenant_id = s.tenant_id\n )\non conflict do nothing;\n";
|
|
4
|
+
export declare const MIGRATION_004_O_COUVERT_E_COBRADO_POR_PESSOA = "-- plugin-tables \u2014 a taxa de ingresso: couvert, entrada, VIP.\n--\n-- Portada de v1-guide/financeiro/taxas-ingresso. A diferen\u00E7a que muda o\n-- desenho inteiro: **a cobran\u00E7a \u00E9 por PESSOA, n\u00E3o por mesa**. Da\u00ED, no V1, o\n-- interruptor \"perguntar n\u00FAmero de pessoas ao abrir mesa\" \u2014 sem esse n\u00FAmero\n-- n\u00E3o h\u00E1 o que multiplicar \u2014, e o \"confirmar ao fechar\", porque quem chegou\n-- depois entra na conta.\n--\n-- Quatro regras que a tela do V1 enuncia e que viram esquema aqui:\n--\n-- 1. Por pessoa, com quantidade DIFERENTE para cliente identificado e n\u00E3o\n-- identificado. `0x` em identificado \u00E9 a cortesia de quem \u00E9 cadastrado \u2014\n-- zero \u00E9 valor v\u00E1lido, n\u00E3o \"desligado\".\n-- 2. Escopo de LOCAL: a taxa pode valer s\u00F3 em certas pra\u00E7as. Nenhuma linha\n-- de escopo = todos os locais (o V1 escreve \"Todos os locais\").\n-- 3. Escopo de HOR\u00C1RIO: couvert de sexta \u00E0 noite \u00E9 configura\u00E7\u00E3o, n\u00E3o exce\u00E7\u00E3o\n-- manual. Nenhuma linha de hor\u00E1rio = sempre.\n-- 4. \u00C9 RECALCUL\u00C1VEL. Confirmar o n\u00FAmero no fechamento tem de refazer a\n-- cobran\u00E7a, e refazer n\u00E3o pode duplicar: a linha do couvert \u00E9\n-- identificada pelo `metadata->>'cover_charge_id'` e substitu\u00EDda, nunca\n-- somada de novo.\n--\n-- E uma decis\u00E3o que o V1 n\u00E3o toma explicitamente: **o couvert n\u00E3o sofre taxa\n-- de servi\u00E7o**. A taxa incide sobre produto; couvert n\u00E3o \u00E9 produto, \u00E9 entrada.\n-- Cobrar 10% sobre o couvert seria uma segunda taxa sobre a mesma entrada.\n--\n-- Idempotente.\n\n-- ---------------------------------------------------------------------------\n-- Os dois interruptores de opera\u00E7\u00E3o\n-- ---------------------------------------------------------------------------\n\nalter table public.plg_tables_settings\n add column if not exists ask_guest_count_on_open boolean not null default false;\nalter table public.plg_tables_settings\n add column if not exists confirm_guest_count_on_close boolean not null default false;\n\n-- ---------------------------------------------------------------------------\n-- Quem \u00E9 identificado\n-- ---------------------------------------------------------------------------\n--\n-- \"Identificado\" no V1 quer dizer cliente CADASTRADO. Sem um v\u00EDnculo com a\n-- pessoa, \"Qtd Identificado\" seria uma coluna que nunca se aplica \u2014 que \u00E9\n-- exatamente como um campo portado morre.\n\nalter table public.plg_tables_order_guests\n add column if not exists person_id uuid references public.people(id) on delete set null;\n\ncreate index if not exists plg_tables_order_guests_person_idx\n on public.plg_tables_order_guests (person_id) where person_id is not null;\n\n-- ---------------------------------------------------------------------------\n-- A taxa\n-- ---------------------------------------------------------------------------\n\ncreate table if not exists public.plg_tables_cover_charges (\n id uuid primary key default gen_random_uuid(),\n tenant_id uuid not null references public.tenants(id) on delete cascade,\n name text not null,\n amount numeric(14,2) not null check (amount >= 0),\n -- Quantas unidades por pessoa. Zero = cortesia; \u00E9 o caso que o V1 prev\u00EA para\n -- cliente cadastrado e o motivo de as duas colunas existirem.\n qty_identified integer not null default 1 check (qty_identified >= 0),\n qty_unidentified integer not null default 1 check (qty_unidentified >= 0),\n is_active boolean not null default true,\n created_at timestamptz not null default now(),\n updated_at timestamptz not null default now(),\n unique (tenant_id, name)\n);\n\n-- Escopo de local. AUS\u00CANCIA de linhas = todos os locais; \u00E9 a leitura que o V1\n-- imprime na lista e o padr\u00E3o que n\u00E3o obriga a marcar 20 pra\u00E7as para dizer\n-- \"em toda a casa\".\ncreate table if not exists public.plg_tables_cover_charge_zones (\n cover_charge_id uuid not null references public.plg_tables_cover_charges(id) on delete cascade,\n zone_id uuid not null references public.plg_tables_zones(id) on delete cascade,\n tenant_id uuid not null references public.tenants(id) on delete cascade,\n primary key (cover_charge_id, zone_id)\n);\n\n-- Escopo de hor\u00E1rio, por dia da semana. AUS\u00CANCIA de linhas = sempre.\n-- `starts_at > ends_at` \u00E9 a faixa que atravessa a meia-noite (22:00\u201302:00), e\n-- ela \u00E9 a regra e n\u00E3o a exce\u00E7\u00E3o num restaurante \u2014 a compara\u00E7\u00E3o abaixo trata\n-- as duas.\ncreate table if not exists public.plg_tables_cover_charge_schedules (\n id uuid primary key default gen_random_uuid(),\n cover_charge_id uuid not null references public.plg_tables_cover_charges(id) on delete cascade,\n tenant_id uuid not null references public.tenants(id) on delete cascade,\n -- 0 = domingo, como `extract(dow)`.\n weekday integer not null check (weekday between 0 and 6),\n starts_at time not null,\n ends_at time not null,\n unique (cover_charge_id, weekday, starts_at, ends_at)\n);\n\ncreate index if not exists plg_tables_cover_charge_zones_charge_idx\n on public.plg_tables_cover_charge_zones (cover_charge_id);\ncreate index if not exists plg_tables_cover_charge_schedules_charge_idx\n on public.plg_tables_cover_charge_schedules (cover_charge_id);\n\ndo $$ begin\n create trigger plg_tables_cover_charges_updated_at before update on public.plg_tables_cover_charges\n for each row execute function public.handle_updated_at();\nexception when duplicate_object then null; end $$;\n\n-- ---------------------------------------------------------------------------\n-- Quais taxas valem para esta comanda, agora\n-- ---------------------------------------------------------------------------\n\ncreate or replace function public.comanda_cover_charges_for(p_order_id uuid, p_at timestamptz default now())\nreturns table (cover_charge_id uuid, name text, amount numeric, qty_identified integer, qty_unidentified integer)\nlanguage sql stable\nas $$\n with ctx as (\n select o.tenant_id,\n t.zone_id,\n extract(dow from p_at)::int as dow,\n p_at::time as clock\n from public.orders o\n left join public.plg_tables_order_extensions x on x.order_id = o.id\n left join public.plg_tables_tables t on t.id = x.table_id\n where o.id = p_order_id\n )\n select c.id, c.name, c.amount, c.qty_identified, c.qty_unidentified\n from public.plg_tables_cover_charges c, ctx\n where c.tenant_id = ctx.tenant_id\n and c.is_active\n -- Sem linha de local, vale em todos. Com linhas, s\u00F3 nos listados \u2014 e uma\n -- comanda sem mesa (balc\u00E3o) n\u00E3o casa com escopo de pra\u00E7a.\n and (\n not exists (select 1 from public.plg_tables_cover_charge_zones z where z.cover_charge_id = c.id)\n or exists (\n select 1 from public.plg_tables_cover_charge_zones z\n where z.cover_charge_id = c.id and z.zone_id = ctx.zone_id\n )\n )\n -- Sem linha de hor\u00E1rio, vale sempre.\n and (\n not exists (select 1 from public.plg_tables_cover_charge_schedules s where s.cover_charge_id = c.id)\n or exists (\n select 1 from public.plg_tables_cover_charge_schedules s\n where s.cover_charge_id = c.id\n and s.weekday = ctx.dow\n and (\n (s.starts_at <= s.ends_at and ctx.clock >= s.starts_at and ctx.clock < s.ends_at)\n -- A faixa que vira a meia-noite.\n or (s.starts_at > s.ends_at and (ctx.clock >= s.starts_at or ctx.clock < s.ends_at))\n )\n )\n );\n$$;\n\n-- ---------------------------------------------------------------------------\n-- Aplicar (e reaplicar) o couvert\n-- ---------------------------------------------------------------------------\n--\n-- SUBSTITUI, n\u00E3o soma. Confirmar o n\u00FAmero de pessoas no fechamento chama esta\n-- fun\u00E7\u00E3o de novo, e o V1 \u00E9 justamente onde recalcular duas vezes cobra duas\n-- vezes. A linha antiga \u00E9 apagada pelo `cover_charge_id` no metadata antes de\n-- a nova entrar.\n\ncreate or replace function public.comanda_apply_cover_charges(p_order_id uuid)\nreturns void\nlanguage plpgsql\nas $$\ndeclare\n v_tenant uuid;\n v_unit uuid;\n v_people integer;\n v_identified integer;\n v_units integer;\n r record;\nbegin\n select o.tenant_id, o.unit_id into v_tenant, v_unit from public.orders o where o.id = p_order_id;\n if v_tenant is null then return; end if;\n\n -- O n\u00FAmero DECLARADO \u00E9 a autoridade: \u00E9 o que a casa perguntou ao abrir a\n -- mesa. Sem ele n\u00E3o h\u00E1 por quantas pessoas multiplicar, e cobrar por n\u00FAmero\n -- de assentos criados seria cobrar por quem o gar\u00E7om teve trabalho de\n -- cadastrar.\n select coalesce(x.guests, 0) into v_people\n from public.plg_tables_order_extensions x where x.order_id = p_order_id;\n\n select count(*) into v_identified\n from public.plg_tables_order_guests g\n where g.order_id = p_order_id and g.person_id is not null;\n\n if v_identified > v_people then v_identified := v_people; end if;\n\n -- Apaga o que esta fun\u00E7\u00E3o p\u00F4s antes. S\u00F3 o que ela p\u00F4s: a chave \u00E9 o\n -- `cover_charge_id`, ent\u00E3o uma linha lan\u00E7ada \u00E0 m\u00E3o pelo gar\u00E7om sobrevive.\n delete from public.items i\n where i.order_id = p_order_id\n and (i.metadata ->> 'cover_charge_id') is not null;\n\n if v_people <= 0 then\n perform public.comanda_recalc(p_order_id);\n return;\n end if;\n\n for r in select * from public.comanda_cover_charges_for(p_order_id) loop\n v_units := v_identified * r.qty_identified\n + (v_people - v_identified) * r.qty_unidentified;\n -- Zero unidades n\u00E3o vira linha de R$ 0,00 na conta do cliente. Cortesia\n -- para todo mundo \u00E9 a taxa n\u00E3o aparecer, n\u00E3o aparecer valendo nada.\n if v_units > 0 then\n insert into public.items (tenant_id, unit_id, order_id, name, quantity, unit_price, total, metadata)\n values (\n v_tenant, v_unit, p_order_id, r.name, v_units, r.amount, round(v_units * r.amount, 2),\n jsonb_build_object('cover_charge_id', r.cover_charge_id, 'people', v_people, 'identified', v_identified)\n );\n end if;\n end loop;\n\n perform public.comanda_recalc(p_order_id);\nend;\n$$;\n\ngrant execute on function public.comanda_cover_charges_for(uuid, timestamptz) to authenticated;\ngrant execute on function public.comanda_apply_cover_charges(uuid) to authenticated;\n\n-- ---------------------------------------------------------------------------\n-- O couvert n\u00E3o sofre taxa de servi\u00E7o\n-- ---------------------------------------------------------------------------\n--\n-- A taxa incide sobre PRODUTO. Couvert \u00E9 entrada, n\u00E3o produto \u2014 e a linha dele\n-- nem tem `product_id`, ent\u00E3o o `exists` da 003 j\u00E1 responderia \"n\u00E3o isento\"\n-- por falta de jun\u00E7\u00E3o. Dizer isso de prop\u00F3sito vale mais que depender de um\n-- join que falha: no dia em que o couvert virar um produto do cat\u00E1logo, a\n-- regra continua valendo.\n\ncreate or replace function public.comanda_item_is_service_exempt(p_item_id uuid)\nreturns boolean\nlanguage sql stable\nas $$\n select\n exists (\n select 1 from public.items i\n where i.id = p_item_id and (i.metadata ->> 'cover_charge_id') is not null\n )\n or exists (\n select 1\n from public.items i\n join public.products p on p.id = i.product_id\n join public.plg_tables_service_charge_exemptions e\n on e.tenant_id = i.tenant_id\n and ( (e.target_kind = 'product' and e.target_id = p.id)\n or (e.target_kind = 'category' and e.target_id = p.category_id) )\n where i.id = p_item_id\n );\n$$;\n\n-- ---------------------------------------------------------------------------\n-- Authz\n-- ---------------------------------------------------------------------------\n\nalter table public.plg_tables_cover_charges enable row level security;\ndrop policy if exists plg_tables_cover_charges_select on public.plg_tables_cover_charges;\ncreate policy plg_tables_cover_charges_select on public.plg_tables_cover_charges\n for select using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_cover_charges_insert on public.plg_tables_cover_charges;\ncreate policy plg_tables_cover_charges_insert on public.plg_tables_cover_charges\n for insert with check (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_cover_charges_update on public.plg_tables_cover_charges;\ncreate policy plg_tables_cover_charges_update on public.plg_tables_cover_charges\n for update using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_cover_charges_delete on public.plg_tables_cover_charges;\ncreate policy plg_tables_cover_charges_delete on public.plg_tables_cover_charges\n for delete using (tenant_id = (select app.current_tenant_id()));\ngrant select, insert, update, delete on public.plg_tables_cover_charges to authenticated;\ngrant all on public.plg_tables_cover_charges to service_role;\n\nalter table public.plg_tables_cover_charge_zones enable row level security;\ndrop policy if exists plg_tables_cover_charge_zones_select on public.plg_tables_cover_charge_zones;\ncreate policy plg_tables_cover_charge_zones_select on public.plg_tables_cover_charge_zones\n for select using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_cover_charge_zones_insert on public.plg_tables_cover_charge_zones;\ncreate policy plg_tables_cover_charge_zones_insert on public.plg_tables_cover_charge_zones\n for insert with check (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_cover_charge_zones_update on public.plg_tables_cover_charge_zones;\ncreate policy plg_tables_cover_charge_zones_update on public.plg_tables_cover_charge_zones\n for update using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_cover_charge_zones_delete on public.plg_tables_cover_charge_zones;\ncreate policy plg_tables_cover_charge_zones_delete on public.plg_tables_cover_charge_zones\n for delete using (tenant_id = (select app.current_tenant_id()));\ngrant select, insert, update, delete on public.plg_tables_cover_charge_zones to authenticated;\ngrant all on public.plg_tables_cover_charge_zones to service_role;\n\nalter table public.plg_tables_cover_charge_schedules enable row level security;\ndrop policy if exists plg_tables_cover_charge_schedules_select on public.plg_tables_cover_charge_schedules;\ncreate policy plg_tables_cover_charge_schedules_select on public.plg_tables_cover_charge_schedules\n for select using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_cover_charge_schedules_insert on public.plg_tables_cover_charge_schedules;\ncreate policy plg_tables_cover_charge_schedules_insert on public.plg_tables_cover_charge_schedules\n for insert with check (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_cover_charge_schedules_update on public.plg_tables_cover_charge_schedules;\ncreate policy plg_tables_cover_charge_schedules_update on public.plg_tables_cover_charge_schedules\n for update using (tenant_id = (select app.current_tenant_id()));\ndrop policy if exists plg_tables_cover_charge_schedules_delete on public.plg_tables_cover_charge_schedules;\ncreate policy plg_tables_cover_charge_schedules_delete on public.plg_tables_cover_charge_schedules\n for delete using (tenant_id = (select app.current_tenant_id()));\ngrant select, insert, update, delete on public.plg_tables_cover_charge_schedules to authenticated;\ngrant all on public.plg_tables_cover_charge_schedules to service_role;\n\ninsert into app.scaffold_registry\n (table_schema, table_name, resource_type, plugin, owner_scoping, mode, previous_policies, audit_hook, scope, distributable)\nvalues\n ('public', 'plg_tables_cover_charges', 'tables.cover_charge', 'tables', false, 'enforce', array[]::text[], false, 'tenant', false),\n ('public', 'plg_tables_cover_charge_zones', 'tables.cover_charge_zone', 'tables', false, 'enforce', array[]::text[], false, 'tenant', false),\n ('public', 'plg_tables_cover_charge_schedules', 'tables.cover_charge_schedule', 'tables', false, 'enforce', array[]::text[], false, 'tenant', false)\non conflict do nothing;\n";
|
|
5
|
+
export declare const MIGRATION_005_O_PADRAO_CEDE_ANTES_DO_NOVO_ENTRAR = "-- plugin-tables \u2014 trocar o padr\u00E3o da taxa parava de funcionar no SEGUNDO preset.\n--\n-- Sintoma na tela: clicar \"Definir padr\u00E3o\" numa segunda taxa devolvia\n--\n-- duplicate key value violates unique constraint\n-- \"plg_tables_service_charge_presets_one_default\"\n--\n-- e o selo Padr\u00E3o n\u00E3o sa\u00EDa do lugar. S\u00F3 aparece com DUAS op\u00E7\u00F5es cadastradas \u2014\n-- por isso a verifica\u00E7\u00E3o em SQL da 003, feita num tenant com um preset s\u00F3,\n-- passou. Andar na tela \u00E9 que achou.\n--\n-- Causa: ordem. O \u00EDndice parcial `... (tenant_id) where is_default` \u00E9 checado\n-- durante o pr\u00F3prio UPDATE, e o gatilho que derruba o padr\u00E3o anterior era\n-- `AFTER` \u2014 ele s\u00F3 rodaria depois de a linha nova j\u00E1 ter tentado entrar no\n-- \u00EDndice, com a antiga ainda l\u00E1. \u00CDndice \u00FAnico n\u00E3o \u00E9 adi\u00E1vel (s\u00F3 CONSTRAINT\n-- deferrable seria, e um \u00EDndice parcial n\u00E3o pode ser constraint), ent\u00E3o a\n-- ordem tem de mudar, n\u00E3o a checagem.\n--\n-- Conserto: quem derruba o irm\u00E3o passa a rodar `BEFORE`. A\u00ED o UPDATE do\n-- gatilho apaga o padr\u00E3o antigo enquanto a linha nova ainda nem foi escrita, e\n-- o \u00EDndice nunca v\u00EA dois. A sincronia com `plg_tables_settings` continua\n-- `AFTER`: escrever a taxa vigente antes de a linha existir seria afirmar um\n-- padr\u00E3o que ainda pode falhar.\n--\n-- Idempotente.\n\n-- O gatilho antigo fazia as duas coisas; agora s\u00E3o duas fun\u00E7\u00F5es com um dono\n-- claro cada. `drop` primeiro porque o `create or replace` da fun\u00E7\u00E3o n\u00E3o muda\n-- o momento em que o gatilho dispara.\ndrop trigger if exists plg_tables_service_preset_sync on public.plg_tables_service_charge_presets;\n\ncreate or replace function public.plg_tables_yield_default_service_preset()\nreturns trigger\nlanguage plpgsql\nsecurity definer\nset search_path = public\nas $$\nbegin\n if new.is_default then\n -- O UPDATE abaixo entra aqui de novo, mas com `is_default = false`, ent\u00E3o\n -- n\u00E3o reentra neste ramo. Sem recurs\u00E3o e sem guarda extra para manter.\n update public.plg_tables_service_charge_presets\n set is_default = false, updated_at = now()\n where tenant_id = new.tenant_id and id <> new.id and is_default;\n end if;\n return new;\nend;\n$$;\n\ndrop trigger if exists plg_tables_service_preset_yield on public.plg_tables_service_charge_presets;\ncreate trigger plg_tables_service_preset_yield\n before insert or update of is_default on public.plg_tables_service_charge_presets\n for each row execute function public.plg_tables_yield_default_service_preset();\n\n-- A taxa vigente da casa \u00E9 o padr\u00E3o do conjunto. Continua havendo um n\u00FAmero s\u00F3\n-- em `plg_tables_settings`, e \u00E9 este gatilho que o mant\u00E9m honesto.\ncreate or replace function public.plg_tables_sync_default_service_preset()\nreturns trigger\nlanguage plpgsql\nsecurity definer\nset search_path = public\nas $$\nbegin\n if new.is_default then\n insert into public.plg_tables_settings (tenant_id, service_charge_percent)\n values (new.tenant_id, new.percent)\n on conflict (tenant_id) do update\n set service_charge_percent = excluded.service_charge_percent,\n updated_at = now();\n end if;\n return new;\nend;\n$$;\n\ncreate trigger plg_tables_service_preset_sync\n after insert or update of is_default, percent on public.plg_tables_service_charge_presets\n for each row execute function public.plg_tables_sync_default_service_preset();\n";
|
|
3
6
|
export declare const MIGRATIONS: Array<{
|
|
4
7
|
id: string;
|
|
5
8
|
sql: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,wBAAwB,40QAuJpC,CAAA;AAED,eAAO,MAAM,qBAAqB,83hBAkSjC,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,wBAAwB,40QAuJpC,CAAA;AAED,eAAO,MAAM,qBAAqB,83hBAkSjC,CAAA;AAED,eAAO,MAAM,+CAA+C,kzaAwP3D,CAAA;AAED,eAAO,MAAM,4CAA4C,g/gBAuTxD,CAAA;AAED,eAAO,MAAM,gDAAgD,ihHA6E5D,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAMzD,CAAA"}
|
package/dist/store.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type StoreApi } from 'zustand/vanilla';
|
|
2
2
|
import type { TablesDataProvider } from './data/types';
|
|
3
|
-
import type { RestaurantTable, TableSession, Zone, CreateTableInput, SeatGuestsInput, UpdateTableStatusInput, TableQuery, TablesSummary, TableOrder, TableMenuCategory, AddTableOrderLineInput, ComandaSettings, CancelReason, OrderTransfer, DiscountLineInput, CancelLineInput, TransferInput } from './types';
|
|
3
|
+
import type { RestaurantTable, TableSession, Zone, CreateTableInput, SeatGuestsInput, UpdateTableStatusInput, TableQuery, TablesSummary, TableOrder, TableMenuCategory, AddTableOrderLineInput, ComandaSettings, CancelReason, OrderTransfer, DiscountLineInput, CancelLineInput, TransferInput, ServiceChargePreset, ServiceChargeExemption, ServiceChargeTargets, CoverCharge, CreateCoverChargeInput } from './types';
|
|
4
4
|
export interface TablesUIState {
|
|
5
5
|
tables: RestaurantTable[];
|
|
6
6
|
tablesLoading: boolean;
|
|
@@ -31,6 +31,13 @@ export interface TablesUIState {
|
|
|
31
31
|
settings: ComandaSettings | null;
|
|
32
32
|
cancelReasons: CancelReason[];
|
|
33
33
|
transfers: OrderTransfer[];
|
|
34
|
+
/** O conjunto de taxas da casa e as exceções. Null enquanto não foi lido —
|
|
35
|
+
* lista vazia quer dizer "esta casa não cadastrou nenhuma", que é diferente. */
|
|
36
|
+
servicePresets: ServiceChargePreset[] | null;
|
|
37
|
+
serviceExemptions: ServiceChargeExemption[] | null;
|
|
38
|
+
serviceTargets: ServiceChargeTargets | null;
|
|
39
|
+
/** As taxas de ingresso. Null enquanto não foi lido. */
|
|
40
|
+
coverCharges: CoverCharge[] | null;
|
|
34
41
|
fetchTables(query?: TableQuery): Promise<void>;
|
|
35
42
|
fetchZones(): Promise<void>;
|
|
36
43
|
fetchActiveSessions(): Promise<void>;
|
|
@@ -45,6 +52,23 @@ export interface TablesUIState {
|
|
|
45
52
|
selectGuest(guestId: string | null): void;
|
|
46
53
|
fetchSettings(): Promise<void>;
|
|
47
54
|
saveSettings(patch: Partial<ComandaSettings>): Promise<void>;
|
|
55
|
+
/** A política da taxa: o conjunto e as exceções. */
|
|
56
|
+
fetchServiceChargePolicy(): Promise<void>;
|
|
57
|
+
addServicePreset(input: {
|
|
58
|
+
name: string;
|
|
59
|
+
percent: number;
|
|
60
|
+
}): Promise<void>;
|
|
61
|
+
deleteServicePreset(id: string): Promise<void>;
|
|
62
|
+
setDefaultServicePreset(id: string): Promise<void>;
|
|
63
|
+
addServiceExemption(kind: ServiceChargeExemption['kind'], targetId: string): Promise<void>;
|
|
64
|
+
removeServiceExemption(id: string): Promise<void>;
|
|
65
|
+
/** As taxas de ingresso (couvert). */
|
|
66
|
+
fetchCoverCharges(): Promise<void>;
|
|
67
|
+
addCoverCharge(input: CreateCoverChargeInput): Promise<void>;
|
|
68
|
+
updateCoverCharge(id: string, patch: Partial<CreateCoverChargeInput> & {
|
|
69
|
+
isActive?: boolean;
|
|
70
|
+
}): Promise<void>;
|
|
71
|
+
deleteCoverCharge(id: string): Promise<void>;
|
|
48
72
|
addGuest(label?: string): Promise<void>;
|
|
49
73
|
removeGuest(guestId: string): Promise<void>;
|
|
50
74
|
setGuestServiceCharge(guestId: string, percent: number | null): Promise<void>;
|
package/dist/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAG5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,KAAK,EACV,eAAe,EAAE,YAAY,EAAE,IAAI,EACnC,gBAAgB,EAAE,eAAe,EAAE,sBAAsB,EACzD,UAAU,EAAE,aAAa,EACzB,UAAU,EAAE,iBAAiB,EAAE,sBAAsB,EACrD,eAAe,EAAE,YAAY,EAAE,aAAa,EAC5C,iBAAiB,EAAE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
|
|
145
145
|
cancelRequiresPin: boolean;
|
|
146
146
|
operationalDayStart: string;
|
|
147
|
+
/** Pergunta quantas pessoas ANTES de abrir a comanda. Sem esse número não há
|
|
148
|
+
* por quantas pessoas multiplicar o couvert. */
|
|
149
|
+
askGuestCountOnOpen: boolean;
|
|
150
|
+
/** Reconfere no fechamento e RECALCULA — quem chegou depois entra na conta. */
|
|
151
|
+
confirmGuestCountOnClose: boolean;
|
|
152
|
+
}
|
|
153
|
+
/** Uma faixa de horário em que a taxa de ingresso vale. */
|
|
154
|
+
export interface CoverChargeSchedule {
|
|
155
|
+
id: string;
|
|
156
|
+
/** 0 = domingo, como `extract(dow)`. */
|
|
157
|
+
weekday: number;
|
|
158
|
+
startsAt: string;
|
|
159
|
+
endsAt: string;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Couvert, entrada, VIP — cobrança por PESSOA. As duas quantidades existem
|
|
163
|
+
* porque o V1 prevê cortesia para cliente cadastrado: `0x` em identificado.
|
|
164
|
+
*
|
|
165
|
+
* `zoneIds` vazio = todos os locais. `schedules` vazio = sempre. A ausência é
|
|
166
|
+
* o padrão, e é o que evita marcar vinte praças para dizer "em toda a casa".
|
|
167
|
+
*/
|
|
168
|
+
export interface CoverCharge {
|
|
169
|
+
id: string;
|
|
170
|
+
name: string;
|
|
171
|
+
amount: number;
|
|
172
|
+
qtyIdentified: number;
|
|
173
|
+
qtyUnidentified: number;
|
|
174
|
+
isActive: boolean;
|
|
175
|
+
zoneIds: string[];
|
|
176
|
+
schedules: CoverChargeSchedule[];
|
|
177
|
+
}
|
|
178
|
+
export interface CreateCoverChargeInput {
|
|
179
|
+
name: string;
|
|
180
|
+
amount: number;
|
|
181
|
+
qtyIdentified?: number;
|
|
182
|
+
qtyUnidentified?: number;
|
|
183
|
+
zoneIds?: string[];
|
|
184
|
+
schedules?: Array<Omit<CoverChargeSchedule, 'id'>>;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Uma das opções de taxa da casa. O V1 lista 5% · 10% · 13% com uma marcada
|
|
188
|
+
* como padrão, e o operador aplica outra na hora sem editar cadastro — por isso
|
|
189
|
+
* é conjunto, não campo.
|
|
190
|
+
*/
|
|
191
|
+
export interface ServiceChargePreset {
|
|
192
|
+
id: string;
|
|
193
|
+
name: string;
|
|
194
|
+
percent: number;
|
|
195
|
+
isDefault: boolean;
|
|
196
|
+
sortOrder: number;
|
|
197
|
+
}
|
|
198
|
+
export type ServiceChargeExemptionKind = 'product' | 'category';
|
|
199
|
+
/**
|
|
200
|
+
* Uma exceção à taxa. Lista de exceções, não regra: por padrão tudo entra na
|
|
201
|
+
* taxa. `targetName` é resolvido na leitura para a tela não ter de casar ids.
|
|
202
|
+
*/
|
|
203
|
+
export interface ServiceChargeExemption {
|
|
204
|
+
id: string;
|
|
205
|
+
kind: ServiceChargeExemptionKind;
|
|
206
|
+
targetId: string;
|
|
207
|
+
targetName?: string;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* O catálogo de onde a tela de isenções escolhe. `productCount` existe porque
|
|
211
|
+
* isentar uma categoria tem raio de ação invisível: "Bebidas" pode ser 3 itens
|
|
212
|
+
* ou 40, e quem marca precisa saber o que acabou de tirar da taxa.
|
|
213
|
+
*/
|
|
214
|
+
export interface ServiceChargeTargets {
|
|
215
|
+
products: Array<{
|
|
216
|
+
id: string;
|
|
217
|
+
name: string;
|
|
218
|
+
categoryName?: string;
|
|
219
|
+
}>;
|
|
220
|
+
categories: Array<{
|
|
221
|
+
id: string;
|
|
222
|
+
name: string;
|
|
223
|
+
productCount: number;
|
|
224
|
+
}>;
|
|
147
225
|
}
|
|
148
226
|
export interface TableOrder {
|
|
149
227
|
id: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU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M,CAAA;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC1B,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,YAAY,CAAA;IAClB,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComandaSettingsView.d.ts","sourceRoot":"","sources":["../../src/views/ComandaSettingsView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAmCzB,wBAAgB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"ComandaSettingsView.d.ts","sourceRoot":"","sources":["../../src/views/ComandaSettingsView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAmCzB,wBAAgB,mBAAmB,sBA4IlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoverChargePolicyView.d.ts","sourceRoot":"","sources":["../../src/views/CoverChargePolicyView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AA8EzB,wBAAgB,qBAAqB,sBA8PpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServiceChargePolicyView.d.ts","sourceRoot":"","sources":["../../src/views/ServiceChargePolicyView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAgFzB,wBAAgB,uBAAuB,sBAkPtC"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"status": "beta",
|
|
5
5
|
"dependencies": []
|
|
6
6
|
},
|
|
7
|
-
"version": "0.10.
|
|
7
|
+
"version": "0.10.8",
|
|
8
8
|
"description": "Fayz SDK — plugin-tables plugin",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"sideEffects": false,
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"sonner": "^2.0.7"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@fayz-ai/core": "^0.
|
|
31
|
+
"@fayz-ai/core": "^0.22.0",
|
|
32
32
|
"@fayz-ai/sdk": "^0.19.1",
|
|
33
|
-
"@fayz-ai/admin": "^0.
|
|
34
|
-
"@fayz-ai/ui": "^0.
|
|
33
|
+
"@fayz-ai/admin": "^0.22.0",
|
|
34
|
+
"@fayz-ai/ui": "^0.22.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/react": "^18.3.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/views/ComandaSettingsView.tsx"],"names":[],"mappings":";;;;;;AAqBA,SAAS,OAAA,CAAQ,EAAE,KAAA,EAAO,WAAA,EAAa,UAAS,EAI7C;AACD,EAAA,uBACE,IAAA,CAAC,IAAA,EAAA,EAAK,SAAA,EAAU,KAAA,EACd,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,IAAA,EAAA,EAAG,SAAA,EAAU,uBAAA,EAAyB,QAAA,EAAA,KAAA,EAAM,CAAA;AAAA,IAC5C,WAAA,oBAAe,GAAA,CAAC,GAAA,EAAA,EAAE,SAAA,EAAU,wCAAwC,QAAA,EAAA,WAAA,EAAY,CAAA;AAAA,oBACjF,GAAA,CAAC,KAAA,EAAA,EAAI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,KAAW,CAAA,wBACjB,IAAA,EAAA,EAAG,SAAA,EAAU,sCAAqC,QAAA,EAAA,gFAAA,EAEnD;AAAA,WAAA,EAEJ;AAAA;AAAA;AAAA,KACF;AAAA,oBAEA,GAAA;AAAA,MAAC,OAAA;AAAA,MAAA;AAAA,QACC,KAAA,EAAM,iBAAA;AAAA,QACN,WAAA,EAAY,kIAAA;AAAA,QAEZ,QAAA,kBAAA,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,mBAAA,EACd,QAAA,kBAAA,GAAA;AAAA,UAAC,KAAA;AAAA,UAAA;AAAA,YAAM,IAAA,EAAK,MAAA;AAAA,YAAO,KAAA,EAAO,QAAA;AAAA,YAAU,UAAU,CAAC,CAAA,KAAM,WAAA,CAAY,CAAA,CAAE,OAAO,KAAK,CAAA;AAAA,YAC7E,YAAA,EAAW;AAAA;AAAA,SAA4B,EAC3C;AAAA;AAAA,KACF;AAAA,wBAEC,KAAA,EAAA,EAAI,SAAA,EAAU,kBAAA,EACb,QAAA,kBAAA,GAAA,CAAC,UAAO,OAAA,EAAS,IAAA,EAAM,QAAA,EAAU,CAAC,SAAS,CAAC,KAAA,IAAS,QAClD,QAAA,EAAA,MAAA,GAAS,gBAAA,GAAc,UAC1B,CAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ","file":"ComandaSettingsView-ZB5RK7TP.js","sourcesContent":["import React from 'react'\nimport { Plus, Trash2 } from 'lucide-react'\nimport { Button, Input, Switch, Card } from '@fayz-ai/ui'\nimport { useTablesStore } from '../context'\n\n// ---------------------------------------------------------------------------\n// Configurações da comanda.\n//\n// Três lições do V1 que esta tela não repete:\n//\n// 1. TEM Salvar, e ele aparece. As \"Chamadas de Garçom\" do V1 gravam ao\n// mudar, sem nenhum aviso — numa tela de configuração é o oposto do que o\n// resto do produto faz, e a pessoa que muda o número e fecha a aba não\n// sabe se gravou.\n// 2. Entrar pela URL funciona. As \"Regras de Cancelamento\" abertas por link\n// direto vêm com a lista PERMANENTEMENTE vazia (V1-048), com 103 pessoas\n// no banco.\n// 3. O selo é botão ou não é selo. O \"Ativa\" do Salão é decorativo (V1-037)\n// e o de Chamadas alterna de verdade; um dos dois ensina errado.\n// ---------------------------------------------------------------------------\n\nfunction Section({ title, description, children }: {\n title: string\n description?: string\n children: React.ReactNode\n}) {\n return (\n <Card className=\"p-4\">\n <h3 className=\"text-sm font-semibold\">{title}</h3>\n {description && <p className=\"mt-0.5 text-xs text-muted-foreground\">{description}</p>}\n <div className=\"mt-3\">{children}</div>\n </Card>\n )\n}\n\nexport function ComandaSettingsView() {\n const settings = useTablesStore((s) => s.settings)\n const fetchSettings = useTablesStore((s) => s.fetchSettings)\n const saveSettings = useTablesStore((s) => s.saveSettings)\n const reasons = useTablesStore((s) => s.cancelReasons)\n const fetchCancelReasons = useTablesStore((s) => s.fetchCancelReasons)\n const addCancelReason = useTablesStore((s) => s.addCancelReason)\n const updateCancelReason = useTablesStore((s) => s.updateCancelReason)\n const deleteCancelReason = useTablesStore((s) => s.deleteCancelReason)\n\n const [percent, setPercent] = React.useState('')\n const [pin, setPin] = React.useState(false)\n const [dayStart, setDayStart] = React.useState('06:00')\n const [newReason, setNewReason] = React.useState('')\n const [saving, setSaving] = React.useState(false)\n\n React.useEffect(() => {\n void fetchSettings()\n void fetchCancelReasons()\n }, [fetchSettings, fetchCancelReasons])\n\n React.useEffect(() => {\n if (!settings) return\n setPercent(String(settings.serviceChargePercent))\n setPin(settings.cancelRequiresPin)\n setDayStart(settings.operationalDayStart.slice(0, 5))\n }, [settings])\n\n const parsed = Number(percent.replace(',', '.'))\n const valid = Number.isFinite(parsed) && parsed >= 0 && parsed <= 100\n const dirty = settings != null && (\n parsed !== settings.serviceChargePercent\n || pin !== settings.cancelRequiresPin\n || dayStart !== settings.operationalDayStart.slice(0, 5)\n )\n\n async function save() {\n setSaving(true)\n try {\n await saveSettings({\n serviceChargePercent: parsed,\n cancelRequiresPin: pin,\n operationalDayStart: dayStart,\n })\n } finally { setSaving(false) }\n }\n\n return (\n <div className=\"space-y-4\">\n <Section\n title=\"Taxa de serviço\"\n description=\"A taxa da casa. Cada mesa e cada participante podem ter a sua, e o que estiver em branco herda desta.\"\n >\n <div className=\"flex items-center gap-2\">\n {/* Largura no INVÓLUCRO: o `Input` se desenha dentro de um `div.w-full`\n próprio, e sem isto o \"%\" era empurrado para o outro lado da tela. */}\n <span className=\"w-28 shrink-0\">\n <Input value={percent} onChange={(e) => setPercent(e.target.value)}\n inputMode=\"decimal\" aria-label=\"Taxa de serviço da casa\" />\n </span>\n <span className=\"text-sm text-muted-foreground\">%</span>\n </div>\n {!valid && percent !== '' && (\n <p className=\"mt-1.5 text-xs text-destructive\">Informe um número entre 0 e 100.</p>\n )}\n {/* O porquê de isto existir: até aqui a taxa era uma constante no código\n do app, desenhada só no rodapé do painel — a fatura levantada no\n fechamento não a via. */}\n <p className=\"mt-2 text-xs text-muted-foreground\">\n Entra na comanda e na fatura levantada no fechamento.\n </p>\n </Section>\n\n <Section\n title=\"Cancelamento\"\n description=\"Quem pode cancelar item vem do perfil de acesso. Aqui fica o que a tela pergunta na hora.\"\n >\n <label className=\"flex items-start gap-3\">\n <Switch checked={pin} onCheckedChange={setPin} aria-label=\"Exigir PIN para cancelar\" />\n <span className=\"min-w-0\">\n <span className=\"block text-sm\">Exigir PIN para cancelar</span>\n {/* Desligado por padrão de propósito: o V1 exige senha de 6 dígitos\n sempre, criada em OUTRA tela por OUTRA pessoa, e quem esquece\n descobre no meio do serviço. */}\n <span className=\"block text-xs text-muted-foreground\">\n O terminal do salão fica logado a noite inteira, e nem sempre quem\n cancela é quem está logado. Ligado, o cancelamento pede o PIN de\n alguém com permissão.\n </span>\n </span>\n </label>\n </Section>\n\n <Section\n title=\"Motivos de cancelamento\"\n description=\"O que aparece na hora de tirar um item da comanda — e o que alimenta o ranking do que a cozinha mais devolveu.\"\n >\n <div className=\"flex gap-2\">\n <Input\n value={newReason}\n onChange={(e) => setNewReason(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter' && newReason.trim()) {\n void addCancelReason(newReason.trim()); setNewReason('')\n }\n }}\n placeholder=\"Ex.: saiu errado da cozinha, cliente trocou o pedido…\"\n />\n <Button variant=\"outline\" disabled={!newReason.trim()}\n onClick={() => { void addCancelReason(newReason.trim()); setNewReason('') }}>\n <Plus className=\"h-4 w-4\" />\n </Button>\n </div>\n\n <ul className=\"mt-3 space-y-1\">\n {reasons.map((r) => (\n <li key={r.id} className=\"flex items-center gap-2 rounded px-2 py-1.5 hover:bg-muted/50\">\n <span className=\"min-w-0 flex-1 truncate text-sm\">{r.label}</span>\n {/* O selo É botão. Desativar preserva o histórico e tira o motivo\n da vista; a lixeira apaga. */}\n <button\n type=\"button\"\n onClick={() => void updateCancelReason(r.id, { isActive: !r.isActive })}\n className={`rounded-full border px-2 py-0.5 text-xs transition-colors ${\n r.isActive\n ? 'border-success/40 bg-success/10 text-success'\n : 'border-border text-muted-foreground'\n }`}\n >\n {r.isActive ? 'Ativo' : 'Inativo'}\n </button>\n <Button variant=\"ghost\" size=\"icon\" className=\"h-7 w-7\"\n aria-label={`Excluir ${r.label}`} onClick={() => void deleteCancelReason(r.id)}>\n <Trash2 className=\"h-3.5 w-3.5 text-destructive\" />\n </Button>\n </li>\n ))}\n {reasons.length === 0 && (\n <li className=\"py-3 text-sm text-muted-foreground\">\n Nenhum motivo cadastrado. Sem eles, quem cancela escreve o motivo à mão.\n </li>\n )}\n </ul>\n </Section>\n\n <Section\n title=\"Dia operacional\"\n description=\"O dia do restaurante não é o dia do calendário: começar de madrugada mantém a virada no turno a que ela pertence.\"\n >\n <span className=\"inline-block w-32\">\n <Input type=\"time\" value={dayStart} onChange={(e) => setDayStart(e.target.value)}\n aria-label=\"Início do dia operacional\" />\n </span>\n </Section>\n\n <div className=\"flex justify-end\">\n <Button onClick={save} disabled={!dirty || !valid || saving}>\n {saving ? 'Salvando…' : 'Salvar'}\n </Button>\n </div>\n </div>\n )\n}\n"]}
|