@fayz-ai/plugin-tables 0.14.13 → 0.14.14
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/data/core-supabase.d.ts.map +1 -1
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-supabase.d.ts","sourceRoot":"","sources":["../../src/data/core-supabase.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AA2FjD,MAAM,WAAW,sBAAsB;IACrC,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,MAAM,GAAG,SAAS,GAAG,IAAI,CAAA;IACzC;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,EAAE;QACV,YAAY,EAAE,MAAM,CAAA;QACpB,uEAAuE;QACvE,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,mDAAmD;QACnD,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,yCAAyC;QACzC,GAAG,CAAC,EAAE,MAAM,CAAA;KACb,CAAA;CACF;AAED,MAAM,WAAW,yBAAyB;IACxC,8EAA8E;IAC9E,MAAM,CAAC,EAAE,sBAAsB,CAAA;CAChC;AAID,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,kBAAkB,
|
|
1
|
+
{"version":3,"file":"core-supabase.d.ts","sourceRoot":"","sources":["../../src/data/core-supabase.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AA2FjD,MAAM,WAAW,sBAAsB;IACrC,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,MAAM,GAAG,SAAS,GAAG,IAAI,CAAA;IACzC;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,EAAE;QACV,YAAY,EAAE,MAAM,CAAA;QACpB,uEAAuE;QACvE,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,mDAAmD;QACnD,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,yCAAyC;QACzC,GAAG,CAAC,EAAE,MAAM,CAAA;KACb,CAAA;CACF;AAED,MAAM,WAAW,yBAAyB;IACxC,8EAA8E;IAC9E,MAAM,CAAC,EAAE,sBAAsB,CAAA;CAChC;AAID,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,kBAAkB,CAs/FhG"}
|
package/dist/index.js
CHANGED
|
@@ -2660,11 +2660,14 @@ function createCoreTablesProvider(options) {
|
|
|
2660
2660
|
external_totals:metadata->external->totals, external_payment:metadata->external->payment,
|
|
2661
2661
|
external_customer:metadata->external->customer->>name, external_due:metadata->external->fulfillment->>deliveryAt,
|
|
2662
2662
|
external_address:metadata->external->fulfillment->address->>formatted,
|
|
2663
|
+
site:metadata->pdv,
|
|
2663
2664
|
${ORDER_EXT}!inner ( table_id, unit_id, seated_at, delivery_source, customer_name )`).eq("tenant_id", tenant()).not("status", "in", '("completed","cancelled")');
|
|
2664
|
-
|
|
2665
|
+
const site = `and(channel.eq.shop,metadata->pdv->>channel.eq.${channel})`;
|
|
2666
|
+
q = especie ? q.or(`channel.eq.${channel},and(channel.is.null,kind.eq.${especie}),${site}`) : q.or(`channel.eq.${channel},${site}`);
|
|
2665
2667
|
const { data, error } = await q;
|
|
2666
2668
|
if (error) throw new Error(error.message);
|
|
2667
2669
|
return (data ?? []).map((r) => {
|
|
2670
|
+
const site2 = r.site ?? null;
|
|
2668
2671
|
const ext = Array.isArray(r[ORDER_EXT]) ? r[ORDER_EXT][0] : r[ORDER_EXT];
|
|
2669
2672
|
return {
|
|
2670
2673
|
id: r.id,
|
|
@@ -2678,17 +2681,21 @@ function createCoreTablesProvider(options) {
|
|
|
2678
2681
|
// A unidade da COMANDA e a do ext podem divergir em linha antiga; a
|
|
2679
2682
|
// do ext é a que o V1 grava ao abrir, então ela ganha.
|
|
2680
2683
|
unitId: ext?.unit_id ?? r.unit_id ?? null,
|
|
2681
|
-
status: r.status ?? "new",
|
|
2684
|
+
status: site2?.dispatch ?? r.status ?? "new",
|
|
2682
2685
|
// Reais → centavos. A regra da retirada compara com ZERO e um
|
|
2683
2686
|
// arredondamento de float faria `0.004` deixar de ser conta vazia.
|
|
2684
2687
|
totalCents: Math.round(Number(r.total ?? 0) * 100),
|
|
2685
2688
|
openedAt: ext?.seated_at ?? r.created_at ?? "",
|
|
2686
|
-
...
|
|
2689
|
+
...site2 ? {
|
|
2690
|
+
...typeof site2.feesCents === "number" ? { feesCents: site2.feesCents } : {},
|
|
2691
|
+
...typeof site2.paidOnlineCents === "number" ? { paidOnlineCents: site2.paidOnlineCents } : {},
|
|
2692
|
+
...site2.prepaid === true ? { prepaid: true } : {}
|
|
2693
|
+
} : marketplaceMoney(r),
|
|
2687
2694
|
// Who ordered, where it goes and when it is promised, as the
|
|
2688
2695
|
// marketplace sent them: the delivery card shows them under the number.
|
|
2689
2696
|
// The marketplace's customer; otherwise the name the house typed on the ticket.
|
|
2690
2697
|
...typeof r.external_customer === "string" && r.external_customer.trim() ? { customerName: r.external_customer.trim() } : typeof ext?.customer_name === "string" && ext.customer_name.trim() ? { customerName: ext.customer_name.trim() } : {},
|
|
2691
|
-
...typeof r.external_address === "string" && r.external_address.trim() ? { address: r.external_address.trim() } : {},
|
|
2698
|
+
...typeof r.external_address === "string" && r.external_address.trim() ? { address: r.external_address.trim() } : site2?.address ? { address: site2.address } : {},
|
|
2692
2699
|
...typeof r.external_due === "string" && r.external_due ? { dueAt: r.external_due } : {}
|
|
2693
2700
|
};
|
|
2694
2701
|
});
|