@fayz-ai/plugin-tables 0.10.6 → 0.10.7
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
package/dist/index.js
CHANGED
|
@@ -376,6 +376,10 @@ function createTablesStore(provider) {
|
|
|
376
376
|
activeGuestId: null,
|
|
377
377
|
settings: null,
|
|
378
378
|
cancelReasons: [],
|
|
379
|
+
servicePresets: null,
|
|
380
|
+
serviceExemptions: null,
|
|
381
|
+
serviceTargets: null,
|
|
382
|
+
coverCharges: null,
|
|
379
383
|
transfers: [],
|
|
380
384
|
comandaSupported: typeof provider.getTableOrder === "function",
|
|
381
385
|
menuCategories: [],
|
|
@@ -495,6 +499,113 @@ function createTablesStore(provider) {
|
|
|
495
499
|
toast.error("N\xE3o foi poss\xEDvel salvar", { description: err?.message });
|
|
496
500
|
}
|
|
497
501
|
},
|
|
502
|
+
// -- A política da taxa ---------------------------------------------------
|
|
503
|
+
//
|
|
504
|
+
// Uma leitura só para as três listas: quem abre a tela precisa das opções,
|
|
505
|
+
// das exceções e do catálogo de onde escolher, e três `fetch` separados
|
|
506
|
+
// fariam a tela nascer em três tempos.
|
|
507
|
+
async fetchServiceChargePolicy() {
|
|
508
|
+
if (!provider.getServiceChargePresets) return;
|
|
509
|
+
try {
|
|
510
|
+
const [presets, exemptions, targets] = await Promise.all([
|
|
511
|
+
provider.getServiceChargePresets(),
|
|
512
|
+
provider.getServiceChargeExemptions?.() ?? Promise.resolve([]),
|
|
513
|
+
provider.getServiceChargeTargets?.() ?? Promise.resolve({ products: [], categories: [] })
|
|
514
|
+
]);
|
|
515
|
+
set({ servicePresets: presets, serviceExemptions: exemptions, serviceTargets: targets });
|
|
516
|
+
} catch {
|
|
517
|
+
set({ servicePresets: [], serviceExemptions: [], serviceTargets: { products: [], categories: [] } });
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
async addServicePreset(input) {
|
|
521
|
+
if (!provider.addServiceChargePreset) return;
|
|
522
|
+
try {
|
|
523
|
+
await provider.addServiceChargePreset(input);
|
|
524
|
+
await get().fetchServiceChargePolicy();
|
|
525
|
+
await get().fetchSettings();
|
|
526
|
+
toast.success(`Taxa de ${input.percent}% cadastrada`);
|
|
527
|
+
} catch (err) {
|
|
528
|
+
toast.error("N\xE3o foi poss\xEDvel criar a taxa", { description: err?.message });
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
async deleteServicePreset(id) {
|
|
532
|
+
if (!provider.deleteServiceChargePreset) return;
|
|
533
|
+
try {
|
|
534
|
+
await provider.deleteServiceChargePreset(id);
|
|
535
|
+
await get().fetchServiceChargePolicy();
|
|
536
|
+
} catch (err) {
|
|
537
|
+
toast.error("N\xE3o foi poss\xEDvel excluir a taxa", { description: err?.message });
|
|
538
|
+
}
|
|
539
|
+
},
|
|
540
|
+
async setDefaultServicePreset(id) {
|
|
541
|
+
if (!provider.setDefaultServiceChargePreset) return;
|
|
542
|
+
try {
|
|
543
|
+
await provider.setDefaultServiceChargePreset(id);
|
|
544
|
+
await get().fetchServiceChargePolicy();
|
|
545
|
+
await get().fetchSettings();
|
|
546
|
+
await get().refreshAfterWrite();
|
|
547
|
+
toast.success("Taxa padr\xE3o atualizada");
|
|
548
|
+
} catch (err) {
|
|
549
|
+
toast.error("N\xE3o foi poss\xEDvel definir o padr\xE3o", { description: err?.message });
|
|
550
|
+
}
|
|
551
|
+
},
|
|
552
|
+
async addServiceExemption(kind, targetId) {
|
|
553
|
+
if (!provider.addServiceChargeExemption) return;
|
|
554
|
+
try {
|
|
555
|
+
await provider.addServiceChargeExemption(kind, targetId);
|
|
556
|
+
await get().fetchServiceChargePolicy();
|
|
557
|
+
await get().refreshAfterWrite();
|
|
558
|
+
} catch (err) {
|
|
559
|
+
toast.error("N\xE3o foi poss\xEDvel isentar", { description: err?.message });
|
|
560
|
+
}
|
|
561
|
+
},
|
|
562
|
+
async removeServiceExemption(id) {
|
|
563
|
+
if (!provider.removeServiceChargeExemption) return;
|
|
564
|
+
try {
|
|
565
|
+
await provider.removeServiceChargeExemption(id);
|
|
566
|
+
await get().fetchServiceChargePolicy();
|
|
567
|
+
await get().refreshAfterWrite();
|
|
568
|
+
} catch (err) {
|
|
569
|
+
toast.error("N\xE3o foi poss\xEDvel remover a isen\xE7\xE3o", { description: err?.message });
|
|
570
|
+
}
|
|
571
|
+
},
|
|
572
|
+
// -- Taxas de ingresso ----------------------------------------------------
|
|
573
|
+
async fetchCoverCharges() {
|
|
574
|
+
if (!provider.getCoverCharges) return;
|
|
575
|
+
try {
|
|
576
|
+
set({ coverCharges: await provider.getCoverCharges() });
|
|
577
|
+
} catch {
|
|
578
|
+
set({ coverCharges: [] });
|
|
579
|
+
}
|
|
580
|
+
},
|
|
581
|
+
async addCoverCharge(input) {
|
|
582
|
+
if (!provider.createCoverCharge) return;
|
|
583
|
+
try {
|
|
584
|
+
await provider.createCoverCharge(input);
|
|
585
|
+
await get().fetchCoverCharges();
|
|
586
|
+
toast.success(`${input.name} passa a ser cobrado por pessoa`);
|
|
587
|
+
} catch (err) {
|
|
588
|
+
toast.error("N\xE3o foi poss\xEDvel criar a taxa", { description: err?.message });
|
|
589
|
+
}
|
|
590
|
+
},
|
|
591
|
+
async updateCoverCharge(id, patch) {
|
|
592
|
+
if (!provider.updateCoverCharge) return;
|
|
593
|
+
try {
|
|
594
|
+
await provider.updateCoverCharge(id, patch);
|
|
595
|
+
await get().fetchCoverCharges();
|
|
596
|
+
} catch (err) {
|
|
597
|
+
toast.error("N\xE3o foi poss\xEDvel alterar a taxa", { description: err?.message });
|
|
598
|
+
}
|
|
599
|
+
},
|
|
600
|
+
async deleteCoverCharge(id) {
|
|
601
|
+
if (!provider.deleteCoverCharge) return;
|
|
602
|
+
try {
|
|
603
|
+
await provider.deleteCoverCharge(id);
|
|
604
|
+
await get().fetchCoverCharges();
|
|
605
|
+
} catch (err) {
|
|
606
|
+
toast.error("N\xE3o foi poss\xEDvel excluir a taxa", { description: err?.message });
|
|
607
|
+
}
|
|
608
|
+
},
|
|
498
609
|
async addGuest(label) {
|
|
499
610
|
const order = get().openOrder;
|
|
500
611
|
if (!order || !provider.addGuest) return;
|
|
@@ -1250,6 +1361,12 @@ var SETTINGS = "plg_tables_settings";
|
|
|
1250
1361
|
var GUESTS = "plg_tables_order_guests";
|
|
1251
1362
|
var ITEM_GUESTS = "plg_tables_item_guests";
|
|
1252
1363
|
var CANCEL_REASONS = "plg_tables_cancel_reasons";
|
|
1364
|
+
var SERVICE_PRESETS = "plg_tables_service_charge_presets";
|
|
1365
|
+
var SERVICE_EXEMPTIONS = "plg_tables_service_charge_exemptions";
|
|
1366
|
+
var COVER_CHARGES = "plg_tables_cover_charges";
|
|
1367
|
+
var COVER_ZONES = "plg_tables_cover_charge_zones";
|
|
1368
|
+
var COVER_SCHEDULES = "plg_tables_cover_charge_schedules";
|
|
1369
|
+
var SPINE_CATEGORIES = "categories";
|
|
1253
1370
|
var TRANSFERS = "plg_tables_order_transfers";
|
|
1254
1371
|
var GUESTS_VIEW = "v_comanda_guests";
|
|
1255
1372
|
var BALANCES = "v_invoice_balances";
|
|
@@ -1293,6 +1410,41 @@ function createCoreTablesProvider(options) {
|
|
|
1293
1410
|
function num(value) {
|
|
1294
1411
|
return Number(value) || 0;
|
|
1295
1412
|
}
|
|
1413
|
+
async function writeCoverScope(chargeId, tenantId, input) {
|
|
1414
|
+
if (input.zoneIds) {
|
|
1415
|
+
await db().from(COVER_ZONES).delete().eq("cover_charge_id", chargeId);
|
|
1416
|
+
if (input.zoneIds.length) {
|
|
1417
|
+
const { error } = await db().from(COVER_ZONES).insert(
|
|
1418
|
+
input.zoneIds.map((zoneId) => ({ cover_charge_id: chargeId, zone_id: zoneId, tenant_id: tenantId }))
|
|
1419
|
+
);
|
|
1420
|
+
if (error) throw new Error(error.message);
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
if (input.schedules) {
|
|
1424
|
+
await db().from(COVER_SCHEDULES).delete().eq("cover_charge_id", chargeId);
|
|
1425
|
+
if (input.schedules.length) {
|
|
1426
|
+
const { error } = await db().from(COVER_SCHEDULES).insert(
|
|
1427
|
+
input.schedules.map((sc) => ({
|
|
1428
|
+
cover_charge_id: chargeId,
|
|
1429
|
+
tenant_id: tenantId,
|
|
1430
|
+
weekday: sc.weekday,
|
|
1431
|
+
starts_at: sc.startsAt,
|
|
1432
|
+
ends_at: sc.endsAt
|
|
1433
|
+
}))
|
|
1434
|
+
);
|
|
1435
|
+
if (error) throw new Error(error.message);
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
function rowToPreset(r) {
|
|
1440
|
+
return {
|
|
1441
|
+
id: r.id,
|
|
1442
|
+
name: r.name,
|
|
1443
|
+
percent: num(r.percent),
|
|
1444
|
+
isDefault: r.is_default === true,
|
|
1445
|
+
sortOrder: Number(r.position) || 0
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1296
1448
|
function rowToLine(r) {
|
|
1297
1449
|
const meta = r.metadata ?? {};
|
|
1298
1450
|
return {
|
|
@@ -1725,12 +1877,14 @@ function createCoreTablesProvider(options) {
|
|
|
1725
1877
|
},
|
|
1726
1878
|
// -- A política da casa ---------------------------------------------------
|
|
1727
1879
|
async getSettings() {
|
|
1728
|
-
const { data, error } = await db().from(SETTINGS).select("service_charge_percent, cancel_requires_pin, operational_day_start").maybeSingle();
|
|
1880
|
+
const { data, error } = await db().from(SETTINGS).select("service_charge_percent, cancel_requires_pin, operational_day_start, ask_guest_count_on_open, confirm_guest_count_on_close").maybeSingle();
|
|
1729
1881
|
if (error) throw new Error(error.message);
|
|
1730
1882
|
return {
|
|
1731
1883
|
serviceChargePercent: num(data?.service_charge_percent),
|
|
1732
1884
|
cancelRequiresPin: data?.cancel_requires_pin === true,
|
|
1733
|
-
operationalDayStart: data?.operational_day_start ?? "06:00"
|
|
1885
|
+
operationalDayStart: data?.operational_day_start ?? "06:00",
|
|
1886
|
+
askGuestCountOnOpen: data?.ask_guest_count_on_open === true,
|
|
1887
|
+
confirmGuestCountOnClose: data?.confirm_guest_count_on_close === true
|
|
1734
1888
|
};
|
|
1735
1889
|
},
|
|
1736
1890
|
async saveSettings(patch) {
|
|
@@ -1739,6 +1893,8 @@ function createCoreTablesProvider(options) {
|
|
|
1739
1893
|
if (patch.serviceChargePercent != null) row.service_charge_percent = patch.serviceChargePercent;
|
|
1740
1894
|
if (patch.cancelRequiresPin != null) row.cancel_requires_pin = patch.cancelRequiresPin;
|
|
1741
1895
|
if (patch.operationalDayStart != null) row.operational_day_start = patch.operationalDayStart;
|
|
1896
|
+
if (patch.askGuestCountOnOpen != null) row.ask_guest_count_on_open = patch.askGuestCountOnOpen;
|
|
1897
|
+
if (patch.confirmGuestCountOnClose != null) row.confirm_guest_count_on_close = patch.confirmGuestCountOnClose;
|
|
1742
1898
|
const { error } = await db().from(SETTINGS).upsert(row, { onConflict: "tenant_id" });
|
|
1743
1899
|
if (error) throw new Error(error.message);
|
|
1744
1900
|
},
|
|
@@ -1803,6 +1959,172 @@ function createCoreTablesProvider(options) {
|
|
|
1803
1959
|
await recalc(orderId);
|
|
1804
1960
|
},
|
|
1805
1961
|
// -- Cancelamento ---------------------------------------------------------
|
|
1962
|
+
// -- A política da taxa ---------------------------------------------------
|
|
1963
|
+
async getServiceChargePresets() {
|
|
1964
|
+
const { data, error } = await db().from(SERVICE_PRESETS).select("id, name, percent, is_default, position").order("position").order("percent");
|
|
1965
|
+
if (error) throw new Error(error.message);
|
|
1966
|
+
return (data ?? []).map(rowToPreset);
|
|
1967
|
+
},
|
|
1968
|
+
async addServiceChargePreset(input) {
|
|
1969
|
+
const tenantId = tenant();
|
|
1970
|
+
const { count } = await db().from(SERVICE_PRESETS).select("id", { count: "exact", head: true });
|
|
1971
|
+
const isFirst = (count ?? 0) === 0;
|
|
1972
|
+
const { data, error } = await db().from(SERVICE_PRESETS).insert({ tenant_id: tenantId, name: input.name, percent: input.percent, position: count ?? 0, is_default: isFirst }).select("id, name, percent, is_default, position").single();
|
|
1973
|
+
if (error) throw new Error(error.message);
|
|
1974
|
+
return rowToPreset(data);
|
|
1975
|
+
},
|
|
1976
|
+
async updateServiceChargePreset(id, patch) {
|
|
1977
|
+
requireWrites();
|
|
1978
|
+
const row = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
1979
|
+
if (patch.name != null) row.name = patch.name;
|
|
1980
|
+
if (patch.percent != null) row.percent = patch.percent;
|
|
1981
|
+
const { error } = await db().from(SERVICE_PRESETS).update(row).eq("id", id);
|
|
1982
|
+
if (error) throw new Error(error.message);
|
|
1983
|
+
},
|
|
1984
|
+
async deleteServiceChargePreset(id) {
|
|
1985
|
+
requireWrites();
|
|
1986
|
+
const { error } = await db().from(SERVICE_PRESETS).delete().eq("id", id);
|
|
1987
|
+
if (error) throw new Error(error.message);
|
|
1988
|
+
},
|
|
1989
|
+
async setDefaultServiceChargePreset(id) {
|
|
1990
|
+
requireWrites();
|
|
1991
|
+
const { error } = await db().from(SERVICE_PRESETS).update({ is_default: true, updated_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("id", id);
|
|
1992
|
+
if (error) throw new Error(error.message);
|
|
1993
|
+
},
|
|
1994
|
+
async getServiceChargeExemptions() {
|
|
1995
|
+
const { data, error } = await db().from(SERVICE_EXEMPTIONS).select("id, target_kind, target_id");
|
|
1996
|
+
if (error) throw new Error(error.message);
|
|
1997
|
+
const rows = data ?? [];
|
|
1998
|
+
if (rows.length === 0) return [];
|
|
1999
|
+
const productIds = rows.filter((r) => r.target_kind === "product").map((r) => r.target_id);
|
|
2000
|
+
const categoryIds = rows.filter((r) => r.target_kind === "category").map((r) => r.target_id);
|
|
2001
|
+
const names = /* @__PURE__ */ new Map();
|
|
2002
|
+
if (productIds.length) {
|
|
2003
|
+
const { data: ps } = await db().from(CATALOG).select("id, name").in("id", productIds);
|
|
2004
|
+
for (const p of ps ?? []) names.set(p.id, p.name);
|
|
2005
|
+
}
|
|
2006
|
+
if (categoryIds.length) {
|
|
2007
|
+
const { data: cs } = await db().from(SPINE_CATEGORIES).select("id, name").in("id", categoryIds);
|
|
2008
|
+
for (const c of cs ?? []) names.set(c.id, c.name);
|
|
2009
|
+
}
|
|
2010
|
+
return rows.map((r) => ({
|
|
2011
|
+
id: r.id,
|
|
2012
|
+
kind: r.target_kind,
|
|
2013
|
+
targetId: r.target_id,
|
|
2014
|
+
targetName: names.get(r.target_id)
|
|
2015
|
+
}));
|
|
2016
|
+
},
|
|
2017
|
+
async addServiceChargeExemption(kind, targetId) {
|
|
2018
|
+
const tenantId = tenant();
|
|
2019
|
+
const { data, error } = await db().from(SERVICE_EXEMPTIONS).insert({ tenant_id: tenantId, target_kind: kind, target_id: targetId }).select("id, target_kind, target_id").single();
|
|
2020
|
+
if (error) throw new Error(error.message);
|
|
2021
|
+
return { id: data.id, kind: data.target_kind, targetId: data.target_id };
|
|
2022
|
+
},
|
|
2023
|
+
async removeServiceChargeExemption(id) {
|
|
2024
|
+
requireWrites();
|
|
2025
|
+
const { error } = await db().from(SERVICE_EXEMPTIONS).delete().eq("id", id);
|
|
2026
|
+
if (error) throw new Error(error.message);
|
|
2027
|
+
},
|
|
2028
|
+
async getServiceChargeTargets() {
|
|
2029
|
+
const [{ data: products }, { data: categories }] = await Promise.all([
|
|
2030
|
+
db().from(CATALOG).select("id, name, category_id").eq("is_active", true).order("name").limit(500),
|
|
2031
|
+
db().from(SPINE_CATEGORIES).select("id, name").eq("is_active", true).order("name")
|
|
2032
|
+
]);
|
|
2033
|
+
const categoryName = new Map((categories ?? []).map((c) => [c.id, c.name]));
|
|
2034
|
+
const counts = /* @__PURE__ */ new Map();
|
|
2035
|
+
for (const row of products ?? []) {
|
|
2036
|
+
if (row.category_id) counts.set(row.category_id, (counts.get(row.category_id) ?? 0) + 1);
|
|
2037
|
+
}
|
|
2038
|
+
return {
|
|
2039
|
+
products: (products ?? []).map((p) => ({
|
|
2040
|
+
id: p.id,
|
|
2041
|
+
name: p.name,
|
|
2042
|
+
categoryName: p.category_id ? categoryName.get(p.category_id) : void 0
|
|
2043
|
+
})),
|
|
2044
|
+
categories: (categories ?? []).map((c) => ({
|
|
2045
|
+
id: c.id,
|
|
2046
|
+
name: c.name,
|
|
2047
|
+
productCount: counts.get(c.id) ?? 0
|
|
2048
|
+
}))
|
|
2049
|
+
};
|
|
2050
|
+
},
|
|
2051
|
+
// -- Taxas de ingresso (couvert) ------------------------------------------
|
|
2052
|
+
async getCoverCharges() {
|
|
2053
|
+
const { data, error } = await db().from(COVER_CHARGES).select("id, name, amount, qty_identified, qty_unidentified, is_active").order("name");
|
|
2054
|
+
if (error) throw new Error(error.message);
|
|
2055
|
+
const rows = data ?? [];
|
|
2056
|
+
if (rows.length === 0) return [];
|
|
2057
|
+
const ids = rows.map((r) => r.id);
|
|
2058
|
+
const [{ data: zones }, { data: schedules }] = await Promise.all([
|
|
2059
|
+
db().from(COVER_ZONES).select("cover_charge_id, zone_id").in("cover_charge_id", ids),
|
|
2060
|
+
db().from(COVER_SCHEDULES).select("id, cover_charge_id, weekday, starts_at, ends_at").in("cover_charge_id", ids).order("weekday").order("starts_at")
|
|
2061
|
+
]);
|
|
2062
|
+
const zoneBy = /* @__PURE__ */ new Map();
|
|
2063
|
+
for (const z of zones ?? []) {
|
|
2064
|
+
zoneBy.set(z.cover_charge_id, [...zoneBy.get(z.cover_charge_id) ?? [], z.zone_id]);
|
|
2065
|
+
}
|
|
2066
|
+
const schedBy = /* @__PURE__ */ new Map();
|
|
2067
|
+
for (const sc of schedules ?? []) {
|
|
2068
|
+
const entry = { id: sc.id, weekday: Number(sc.weekday), startsAt: sc.starts_at, endsAt: sc.ends_at };
|
|
2069
|
+
schedBy.set(sc.cover_charge_id, [...schedBy.get(sc.cover_charge_id) ?? [], entry]);
|
|
2070
|
+
}
|
|
2071
|
+
return rows.map((r) => ({
|
|
2072
|
+
id: r.id,
|
|
2073
|
+
name: r.name,
|
|
2074
|
+
amount: num(r.amount),
|
|
2075
|
+
qtyIdentified: Number(r.qty_identified) || 0,
|
|
2076
|
+
qtyUnidentified: Number(r.qty_unidentified) || 0,
|
|
2077
|
+
isActive: r.is_active !== false,
|
|
2078
|
+
zoneIds: zoneBy.get(r.id) ?? [],
|
|
2079
|
+
schedules: schedBy.get(r.id) ?? []
|
|
2080
|
+
}));
|
|
2081
|
+
},
|
|
2082
|
+
async createCoverCharge(input) {
|
|
2083
|
+
const tenantId = tenant();
|
|
2084
|
+
const { data, error } = await db().from(COVER_CHARGES).insert({
|
|
2085
|
+
tenant_id: tenantId,
|
|
2086
|
+
name: input.name,
|
|
2087
|
+
amount: input.amount,
|
|
2088
|
+
// `?? 1` e não `|| 1`: zero é a cortesia do cliente cadastrado, e um
|
|
2089
|
+
// `||` a transformaria silenciosamente em cobrança cheia.
|
|
2090
|
+
qty_identified: input.qtyIdentified ?? 1,
|
|
2091
|
+
qty_unidentified: input.qtyUnidentified ?? 1
|
|
2092
|
+
}).select("id, name, amount, qty_identified, qty_unidentified, is_active").single();
|
|
2093
|
+
if (error) throw new Error(error.message);
|
|
2094
|
+
await writeCoverScope(data.id, tenantId, input);
|
|
2095
|
+
return {
|
|
2096
|
+
id: data.id,
|
|
2097
|
+
name: data.name,
|
|
2098
|
+
amount: num(data.amount),
|
|
2099
|
+
qtyIdentified: Number(data.qty_identified) || 0,
|
|
2100
|
+
qtyUnidentified: Number(data.qty_unidentified) || 0,
|
|
2101
|
+
isActive: data.is_active !== false,
|
|
2102
|
+
zoneIds: input.zoneIds ?? [],
|
|
2103
|
+
schedules: []
|
|
2104
|
+
};
|
|
2105
|
+
},
|
|
2106
|
+
async updateCoverCharge(id, patch) {
|
|
2107
|
+
const tenantId = tenant();
|
|
2108
|
+
const row = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2109
|
+
if (patch.name != null) row.name = patch.name;
|
|
2110
|
+
if (patch.amount != null) row.amount = patch.amount;
|
|
2111
|
+
if (patch.qtyIdentified != null) row.qty_identified = patch.qtyIdentified;
|
|
2112
|
+
if (patch.qtyUnidentified != null) row.qty_unidentified = patch.qtyUnidentified;
|
|
2113
|
+
if (patch.isActive != null) row.is_active = patch.isActive;
|
|
2114
|
+
const { error } = await db().from(COVER_CHARGES).update(row).eq("id", id);
|
|
2115
|
+
if (error) throw new Error(error.message);
|
|
2116
|
+
if (patch.zoneIds || patch.schedules) await writeCoverScope(id, tenantId, patch);
|
|
2117
|
+
},
|
|
2118
|
+
async deleteCoverCharge(id) {
|
|
2119
|
+
requireWrites();
|
|
2120
|
+
const { error } = await db().from(COVER_CHARGES).delete().eq("id", id);
|
|
2121
|
+
if (error) throw new Error(error.message);
|
|
2122
|
+
},
|
|
2123
|
+
async applyCoverCharges(orderId) {
|
|
2124
|
+
requireWrites();
|
|
2125
|
+
const { error } = await db().rpc("comanda_apply_cover_charges", { p_order_id: orderId });
|
|
2126
|
+
if (error) throw new Error(error.message);
|
|
2127
|
+
},
|
|
1806
2128
|
async getCancelReasons() {
|
|
1807
2129
|
const { data, error } = await db().from(CANCEL_REASONS).select("id, label, is_active, sort_order").order("sort_order");
|
|
1808
2130
|
if (error) throw new Error(error.message);
|
|
@@ -1935,7 +2257,9 @@ function createCoreTablesProvider(options) {
|
|
|
1935
2257
|
|
|
1936
2258
|
// src/index.ts
|
|
1937
2259
|
var TablesPage = React.lazy(() => import('./TablesPage-VVDNK3GN.js').then((m) => ({ default: m.TablesPage })));
|
|
1938
|
-
var ComandaSettingsView = React.lazy(() => import('./ComandaSettingsView-
|
|
2260
|
+
var ComandaSettingsView = React.lazy(() => import('./ComandaSettingsView-66M6MS6M.js').then((m) => ({ default: m.ComandaSettingsView })));
|
|
2261
|
+
var ServiceChargePolicyView = React.lazy(() => import('./ServiceChargePolicyView-CMG2OHRQ.js').then((m) => ({ default: m.ServiceChargePolicyView })));
|
|
2262
|
+
var CoverChargePolicyView = React.lazy(() => import('./CoverChargePolicyView-6UWTMPM7.js').then((m) => ({ default: m.CoverChargePolicyView })));
|
|
1939
2263
|
var DEFAULT_LABELS = {
|
|
1940
2264
|
pageTitle: "Tables",
|
|
1941
2265
|
floorPlan: "Floor Plan",
|
|
@@ -2061,6 +2385,37 @@ function createTablesPlugin(options) {
|
|
|
2061
2385
|
// POLÍTICA da comanda (taxa, cancelamento, dia operacional — decisões do
|
|
2062
2386
|
// dono). Juntá-las daria uma tela em que quem vem mudar a taxa passa
|
|
2063
2387
|
// primeiro pelas mesas.
|
|
2388
|
+
// O que a casa COBRA por cima do consumo. No V1 são dois cartões de
|
|
2389
|
+
// Configurações (`/configuracoes/taxa-servico` e `/configuracoes/taxas-ingresso`),
|
|
2390
|
+
// e é onde pertencem: são política que se acerta uma vez, não trabalho de
|
|
2391
|
+
// rotina. Tinham ido parar no rail do Financeiro — errado por semântica e
|
|
2392
|
+
// contra a própria referência.
|
|
2393
|
+
{
|
|
2394
|
+
id: "taxas",
|
|
2395
|
+
label: "Taxas",
|
|
2396
|
+
icon: "Percent",
|
|
2397
|
+
component: (() => {
|
|
2398
|
+
const FeesSettingsTab = () => React.createElement(
|
|
2399
|
+
ContextBoundary,
|
|
2400
|
+
null,
|
|
2401
|
+
React.createElement(
|
|
2402
|
+
React.Suspense,
|
|
2403
|
+
{ fallback: null },
|
|
2404
|
+
React.createElement(
|
|
2405
|
+
"div",
|
|
2406
|
+
{ className: "space-y-6" },
|
|
2407
|
+
React.createElement(ServiceChargePolicyView, { key: "service" }),
|
|
2408
|
+
React.createElement(CoverChargePolicyView, { key: "cover" })
|
|
2409
|
+
)
|
|
2410
|
+
)
|
|
2411
|
+
);
|
|
2412
|
+
FeesSettingsTab.displayName = "FeesSettingsTab";
|
|
2413
|
+
return FeesSettingsTab;
|
|
2414
|
+
})(),
|
|
2415
|
+
order: 22,
|
|
2416
|
+
// Quanto a casa cobra é decisão do dono, não do garçom.
|
|
2417
|
+
permission: { feature: "tables", action: "edit" }
|
|
2418
|
+
},
|
|
2064
2419
|
{
|
|
2065
2420
|
id: "comanda",
|
|
2066
2421
|
label: "Comanda",
|
|
@@ -2078,7 +2433,7 @@ function createTablesPlugin(options) {
|
|
|
2078
2433
|
ComandaSettingsTab.displayName = "ComandaSettingsTab";
|
|
2079
2434
|
return ComandaSettingsTab;
|
|
2080
2435
|
})(),
|
|
2081
|
-
order:
|
|
2436
|
+
order: 23,
|
|
2082
2437
|
// A política é do dono, não do garçom: quem só atende mesa não decide a
|
|
2083
2438
|
// taxa da casa nem apaga motivo de cancelamento.
|
|
2084
2439
|
permission: { feature: "tables", action: "edit" }
|