@fayz-ai/plugin-financial 0.27.1 → 0.28.1
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/ProductPriceTablesTab-FKYRGSBI.js +128 -0
- package/dist/ProductPriceTablesTab-FKYRGSBI.js.map +1 -0
- package/dist/data/registries.d.ts.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +45 -8
- package/dist/index.js.map +1 -1
- package/dist/views/ProductPriceTablesTab.d.ts +13 -0
- package/dist/views/ProductPriceTablesTab.d.ts.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { useState, useCallback, useEffect, useMemo } from 'react';
|
|
2
|
+
import { Skeleton, Card, CardContent, Checkbox, Badge, CurrencyInput, Button, toast } from '@fayz-ai/ui';
|
|
3
|
+
import { errorMessage, appHref, tl, formatCurrency } from '@fayz-ai/core';
|
|
4
|
+
import { getProductTablePrices, setProductTablePrices } from '@fayz-ai/admin';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
// src/views/ProductPriceTablesTab.tsx
|
|
8
|
+
function ProductPriceTablesTab({ item, settingsHref = "/settings/financial/price-tables" }) {
|
|
9
|
+
const productId = item?.id;
|
|
10
|
+
const [tables, setTables] = useState(void 0);
|
|
11
|
+
const [draft, setDraft] = useState({});
|
|
12
|
+
const [error, setError] = useState(null);
|
|
13
|
+
const [saving, setSaving] = useState(false);
|
|
14
|
+
const load = useCallback(async () => {
|
|
15
|
+
if (!productId) return;
|
|
16
|
+
try {
|
|
17
|
+
const rows = (await getProductTablePrices(productId)).filter((r) => !r.channel?.startsWith("shop:"));
|
|
18
|
+
setTables(rows);
|
|
19
|
+
setDraft(Object.fromEntries(rows.map((r) => [r.priceTableId, r.price])));
|
|
20
|
+
setError(null);
|
|
21
|
+
} catch (e) {
|
|
22
|
+
setTables([]);
|
|
23
|
+
setError(errorMessage(e));
|
|
24
|
+
}
|
|
25
|
+
}, [productId]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
void load();
|
|
28
|
+
}, [load]);
|
|
29
|
+
const changes = useMemo(
|
|
30
|
+
() => (tables ?? []).filter((t) => (draft[t.priceTableId] ?? null) !== t.price).map((t) => ({ priceTableId: t.priceTableId, price: draft[t.priceTableId] ?? null })),
|
|
31
|
+
[tables, draft]
|
|
32
|
+
);
|
|
33
|
+
async function save() {
|
|
34
|
+
if (!productId || !changes.length) return;
|
|
35
|
+
setSaving(true);
|
|
36
|
+
try {
|
|
37
|
+
await setProductTablePrices(productId, changes);
|
|
38
|
+
toast.success(tl("Prices saved.", "Pre\xE7os salvos."));
|
|
39
|
+
await load();
|
|
40
|
+
} catch (e) {
|
|
41
|
+
toast.error(errorMessage(e));
|
|
42
|
+
} finally {
|
|
43
|
+
setSaving(false);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (tables === void 0) {
|
|
47
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-3", "aria-busy": "true", children: [
|
|
48
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-48" }),
|
|
49
|
+
[0, 1, 2].map((i) => /* @__PURE__ */ jsx(Skeleton, { className: "h-14 w-full" }, i))
|
|
50
|
+
] });
|
|
51
|
+
}
|
|
52
|
+
const basePrice = tables[0]?.basePrice ?? Number(item?.salePrice ?? item?.price ?? 0);
|
|
53
|
+
const href = appHref(settingsHref);
|
|
54
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
55
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-start justify-between gap-2", children: [
|
|
56
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
57
|
+
/* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold", children: tl("Price per table", "Pre\xE7o por tabela") }),
|
|
58
|
+
/* @__PURE__ */ jsx("p", { className: "mt-0.5 max-w-prose text-xs text-muted-foreground", children: tl(
|
|
59
|
+
"This product's price in each price table. Unticked = the product is not sold in that table. The table is picked on the sale.",
|
|
60
|
+
"O pre\xE7o deste produto em cada tabela. Desmarcado = o produto n\xE3o \xE9 vendido naquela tabela. A tabela \xE9 escolhida na venda."
|
|
61
|
+
) })
|
|
62
|
+
] }),
|
|
63
|
+
/* @__PURE__ */ jsxs("div", { className: "shrink-0 rounded-md border bg-muted/30 px-3 py-1.5 text-right", children: [
|
|
64
|
+
/* @__PURE__ */ jsx("p", { className: "text-[10px] uppercase tracking-wide text-muted-foreground", children: tl("Base price", "Pre\xE7o base") }),
|
|
65
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-semibold tabular-nums", children: formatCurrency(basePrice, "BRL") })
|
|
66
|
+
] })
|
|
67
|
+
] }),
|
|
68
|
+
error ? /* @__PURE__ */ jsx("p", { className: "rounded-lg border border-destructive/30 bg-destructive-soft px-3 py-2 text-xs text-destructive-soft-foreground", children: error }) : tables.length === 0 ? /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { className: "py-8 text-center", children: [
|
|
69
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: tl(
|
|
70
|
+
"No price table yet. Create one per way you sell (Resale, Restaurant, Retail) and set this product's price in each.",
|
|
71
|
+
"Nenhuma tabela de pre\xE7o ainda. Crie uma por forma de vender (Revenda, Restaurante, Consumidor) e d\xEA a este produto o pre\xE7o de cada uma."
|
|
72
|
+
) }),
|
|
73
|
+
/* @__PURE__ */ jsx("a", { href, className: "mt-3 inline-block text-sm font-medium text-primary underline underline-offset-2", children: tl("New table", "Nova tabela") })
|
|
74
|
+
] }) }) : /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(CardContent, { className: "p-0", children: /* @__PURE__ */ jsx("ul", { className: "divide-y", children: tables.map((t) => {
|
|
75
|
+
const value = draft[t.priceTableId] ?? null;
|
|
76
|
+
const listed = value !== null;
|
|
77
|
+
const id = `pt-${t.priceTableId}`;
|
|
78
|
+
return /* @__PURE__ */ jsxs("li", { className: "flex flex-wrap items-center gap-x-4 gap-y-2 px-4 py-3", children: [
|
|
79
|
+
/* @__PURE__ */ jsxs("label", { htmlFor: id, className: "flex min-w-[10rem] flex-1 cursor-pointer items-center gap-3", children: [
|
|
80
|
+
/* @__PURE__ */ jsx(
|
|
81
|
+
Checkbox,
|
|
82
|
+
{
|
|
83
|
+
id,
|
|
84
|
+
checked: listed,
|
|
85
|
+
"aria-label": tl(`In ${t.name}`, `Na tabela ${t.name}`),
|
|
86
|
+
onChange: (on) => setDraft((d) => ({ ...d, [t.priceTableId]: on ? t.price ?? basePrice : null }))
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0", children: [
|
|
90
|
+
/* @__PURE__ */ jsxs("span", { className: "flex flex-wrap items-center gap-1.5 text-sm font-medium", children: [
|
|
91
|
+
t.name,
|
|
92
|
+
t.isDefault && /* @__PURE__ */ jsx(Badge, { variant: "outline", children: tl("Default", "Padr\xE3o") })
|
|
93
|
+
] }),
|
|
94
|
+
/* @__PURE__ */ jsxs("span", { className: "block text-xs text-muted-foreground", children: [
|
|
95
|
+
listed ? tl("In the table", "Na tabela") : tl("Not in the table", "Fora da tabela"),
|
|
96
|
+
t.tiers > 0 && tl(
|
|
97
|
+
` \xB7 +${t.tiers} quantity tier(s), edited on the table`,
|
|
98
|
+
` \xB7 +${t.tiers} faixa(s) por quantidade, editadas na tabela`
|
|
99
|
+
)
|
|
100
|
+
] })
|
|
101
|
+
] })
|
|
102
|
+
] }),
|
|
103
|
+
/* @__PURE__ */ jsx("div", { className: "w-full sm:w-44", children: /* @__PURE__ */ jsx(
|
|
104
|
+
CurrencyInput,
|
|
105
|
+
{
|
|
106
|
+
value: value ?? 0,
|
|
107
|
+
disabled: !listed,
|
|
108
|
+
currencyCode: t.currency,
|
|
109
|
+
onChange: (n) => {
|
|
110
|
+
if (listed && n !== value) setDraft((d) => ({ ...d, [t.priceTableId]: n }));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
) })
|
|
114
|
+
] }, t.priceTableId);
|
|
115
|
+
}) }) }) }),
|
|
116
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
117
|
+
tables.length > 0 && /* @__PURE__ */ jsx(Button, { onClick: () => {
|
|
118
|
+
void save();
|
|
119
|
+
}, disabled: !changes.length || saving, children: saving ? tl("Saving\u2026", "Salvando\u2026") : tl("Save prices", "Salvar pre\xE7os") }),
|
|
120
|
+
changes.length > 0 && !saving && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: tl(`${changes.length} table(s) changed`, `${changes.length} tabela(s) alterada(s)`) }),
|
|
121
|
+
tables.length > 0 && /* @__PURE__ */ jsx("a", { href, className: "ml-auto text-xs text-muted-foreground underline underline-offset-2", children: tl("Manage tables", "Gerenciar tabelas") })
|
|
122
|
+
] })
|
|
123
|
+
] });
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export { ProductPriceTablesTab };
|
|
127
|
+
//# sourceMappingURL=ProductPriceTablesTab-FKYRGSBI.js.map
|
|
128
|
+
//# sourceMappingURL=ProductPriceTablesTab-FKYRGSBI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/views/ProductPriceTablesTab.tsx"],"names":[],"mappings":";;;;;;;AAaO,SAAS,qBAAA,CAAsB,EAAE,IAAA,EAAM,YAAA,GAAe,oCAAmC,EAG7F;AACD,EAAA,MAAM,YAAa,IAAA,EAAiC,EAAA;AACpD,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAI,SAA0C,MAAS,CAAA;AAC/E,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,QAAA,CAAwC,EAAE,CAAA;AACpE,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAwB,IAAI,C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GAAA,CAAC,MAAA,EAAA,EAAO,SAAS,MAAM;AAAE,QAAA,KAAK,IAAA,EAAK;AAAA,MAAE,CAAA,EAAG,QAAA,EAAU,CAAC,OAAA,CAAQ,UAAU,MAAA,EAClE,QAAA,EAAA,MAAA,GAAS,EAAA,CAAG,cAAA,EAAW,gBAAW,CAAA,GAAI,EAAA,CAAG,aAAA,EAAe,kBAAe,CAAA,EAC1E,CAAA;AAAA,MAED,QAAQ,MAAA,GAAS,CAAA,IAAK,CAAC,MAAA,oBACtB,GAAA,CAAC,UAAK,SAAA,EAAU,+BAAA,EACb,QAAA,EAAA,EAAA,CAAG,CAAA,EAAG,QAAQ,MAAM,CAAA,iBAAA,CAAA,EAAqB,GAAG,OAAA,CAAQ,MAAM,wBAAwB,CAAA,EACrF,CAAA;AAAA,MAED,MAAA,CAAO,MAAA,GAAS,CAAA,oBACf,GAAA,CAAC,GAAA,EAAA,EAAE,IAAA,EAAY,SAAA,EAAU,oEAAA,EACtB,QAAA,EAAA,EAAA,CAAG,eAAA,EAAiB,mBAAmB,CAAA,EAC1C;AAAA,KAAA,EAEJ;AAAA,GAAA,EACF,CAAA;AAEJ","file":"ProductPriceTablesTab-FKYRGSBI.js","sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from 'react'\nimport { Badge, Button, Card, CardContent, Checkbox, CurrencyInput, Skeleton, toast } from '@fayz-ai/ui'\nimport { appHref, errorMessage, formatCurrency, tl } from '@fayz-ai/core'\nimport { getProductTablePrices, setProductTablePrices } from '@fayz-ai/admin'\nimport type { ProductTablePrice } from '@fayz-ai/admin'\n\n/**\n * «Preço por tabela» on the product page: the product's price in every active\n * price table, edited in one place and saved in one transaction (spine 216).\n *\n * Market tables (`channel = 'shop:<code>'`) are left out: the shop's\n * «Preços por mercado» tab owns those rows.\n */\nexport function ProductPriceTablesTab({ item, settingsHref = '/settings/financial/price-tables' }: {\n item: unknown\n settingsHref?: string\n}) {\n const productId = (item as { id?: string } | null)?.id\n const [tables, setTables] = useState<ProductTablePrice[] | undefined>(undefined)\n const [draft, setDraft] = useState<Record<string, number | null>>({})\n const [error, setError] = useState<string | null>(null)\n const [saving, setSaving] = useState(false)\n\n const load = useCallback(async () => {\n if (!productId) return\n try {\n const rows = (await getProductTablePrices(productId)).filter((r) => !r.channel?.startsWith('shop:'))\n setTables(rows)\n setDraft(Object.fromEntries(rows.map((r) => [r.priceTableId, r.price])))\n setError(null)\n } catch (e) {\n setTables([])\n setError(errorMessage(e))\n }\n }, [productId])\n\n useEffect(() => { void load() }, [load])\n\n const changes = useMemo(\n () => (tables ?? [])\n .filter((t) => (draft[t.priceTableId] ?? null) !== t.price)\n .map((t) => ({ priceTableId: t.priceTableId, price: draft[t.priceTableId] ?? null })),\n [tables, draft],\n )\n\n async function save() {\n if (!productId || !changes.length) return\n setSaving(true)\n try {\n await setProductTablePrices(productId, changes)\n toast.success(tl('Prices saved.', 'Preços salvos.'))\n await load()\n } catch (e) {\n toast.error(errorMessage(e))\n } finally {\n setSaving(false)\n }\n }\n\n if (tables === undefined) {\n return (\n <div className=\"space-y-3\" aria-busy=\"true\">\n <Skeleton className=\"h-5 w-48\" />\n {[0, 1, 2].map((i) => <Skeleton key={i} className=\"h-14 w-full\" />)}\n </div>\n )\n }\n\n const basePrice = tables[0]?.basePrice\n ?? Number((item as { salePrice?: number; price?: number } | null)?.salePrice ?? (item as { price?: number } | null)?.price ?? 0)\n const href = appHref(settingsHref)\n\n return (\n <div className=\"space-y-4\">\n <div className=\"flex flex-wrap items-start justify-between gap-2\">\n <div className=\"min-w-0\">\n <h3 className=\"text-sm font-semibold\">{tl('Price per table', 'Preço por tabela')}</h3>\n <p className=\"mt-0.5 max-w-prose text-xs text-muted-foreground\">\n {tl(\n 'This product\\'s price in each price table. Unticked = the product is not sold in that table. The table is picked on the sale.',\n 'O preço deste produto em cada tabela. Desmarcado = o produto não é vendido naquela tabela. A tabela é escolhida na venda.',\n )}\n </p>\n </div>\n <div className=\"shrink-0 rounded-md border bg-muted/30 px-3 py-1.5 text-right\">\n <p className=\"text-[10px] uppercase tracking-wide text-muted-foreground\">{tl('Base price', 'Preço base')}</p>\n <p className=\"text-sm font-semibold tabular-nums\">{formatCurrency(basePrice, 'BRL')}</p>\n </div>\n </div>\n\n {error ? (\n <p className=\"rounded-lg border border-destructive/30 bg-destructive-soft px-3 py-2 text-xs text-destructive-soft-foreground\">{error}</p>\n ) : tables.length === 0 ? (\n <Card><CardContent className=\"py-8 text-center\">\n <p className=\"text-sm text-muted-foreground\">\n {tl(\n 'No price table yet. Create one per way you sell (Resale, Restaurant, Retail) and set this product\\'s price in each.',\n 'Nenhuma tabela de preço ainda. Crie uma por forma de vender (Revenda, Restaurante, Consumidor) e dê a este produto o preço de cada uma.',\n )}\n </p>\n <a href={href} className=\"mt-3 inline-block text-sm font-medium text-primary underline underline-offset-2\">\n {tl('New table', 'Nova tabela')}\n </a>\n </CardContent></Card>\n ) : (\n <Card><CardContent className=\"p-0\">\n <ul className=\"divide-y\">\n {tables.map((t) => {\n const value = draft[t.priceTableId] ?? null\n const listed = value !== null\n const id = `pt-${t.priceTableId}`\n return (\n <li key={t.priceTableId} className=\"flex flex-wrap items-center gap-x-4 gap-y-2 px-4 py-3\">\n <label htmlFor={id} className=\"flex min-w-[10rem] flex-1 cursor-pointer items-center gap-3\">\n <Checkbox\n id={id}\n checked={listed}\n aria-label={tl(`In ${t.name}`, `Na tabela ${t.name}`)}\n onChange={(on) => setDraft((d) => ({ ...d, [t.priceTableId]: on ? (t.price ?? basePrice) : null }))}\n />\n <span className=\"min-w-0\">\n <span className=\"flex flex-wrap items-center gap-1.5 text-sm font-medium\">\n {t.name}\n {t.isDefault && <Badge variant=\"outline\">{tl('Default', 'Padrão')}</Badge>}\n </span>\n <span className=\"block text-xs text-muted-foreground\">\n {listed ? tl('In the table', 'Na tabela') : tl('Not in the table', 'Fora da tabela')}\n {t.tiers > 0 && tl(\n ` · +${t.tiers} quantity tier(s), edited on the table`,\n ` · +${t.tiers} faixa(s) por quantidade, editadas na tabela`,\n )}\n </span>\n </span>\n </label>\n <div className=\"w-full sm:w-44\">\n <CurrencyInput\n value={value ?? 0}\n disabled={!listed}\n currencyCode={t.currency}\n onChange={(n) => { if (listed && n !== value) setDraft((d) => ({ ...d, [t.priceTableId]: n })) }}\n />\n </div>\n </li>\n )\n })}\n </ul>\n </CardContent></Card>\n )}\n\n <div className=\"flex flex-wrap items-center gap-3\">\n {tables.length > 0 && (\n <Button onClick={() => { void save() }} disabled={!changes.length || saving}>\n {saving ? tl('Saving…', 'Salvando…') : tl('Save prices', 'Salvar preços')}\n </Button>\n )}\n {changes.length > 0 && !saving && (\n <span className=\"text-xs text-muted-foreground\">\n {tl(`${changes.length} table(s) changed`, `${changes.length} tabela(s) alterada(s)`)}\n </span>\n )}\n {tables.length > 0 && (\n <a href={href} className=\"ml-auto text-xs text-muted-foreground underline underline-offset-2\">\n {tl('Manage tables', 'Gerenciar tabelas')}\n </a>\n )}\n </div>\n </div>\n )\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registries.d.ts","sourceRoot":"","sources":["../../src/data/registries.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAA2B,MAAM,eAAe,CAAA;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"registries.d.ts","sourceRoot":"","sources":["../../src/data/registries.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAA2B,MAAM,eAAe,CAAA;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAygB9C;mEACmE;AACnE,eAAO,MAAM,sBAAsB,oCAAoB,CAAA;AAEvD,eAAO,MAAM,mBAAmB,EAAE,iBAAiB,EA4GlD,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PluginManifest, PluginRegistryDef, PluginScope, VerticalId } from '@fayz-ai/core';
|
|
1
|
+
import type { DetailTab, PluginManifest, PluginRegistryDef, PluginScope, VerticalId } from '@fayz-ai/core';
|
|
2
2
|
import type { EntityLookupMap } from '@fayz-ai/admin';
|
|
3
3
|
import type { FinancialDataProvider } from '@fayz-ai/financial/data/provider';
|
|
4
4
|
import type { NotaFiscalModel } from '@fayz-ai/financial/domain/nota-fiscal';
|
|
@@ -159,4 +159,14 @@ export { createFinancialSettingsPlugin } from './lib/settings-only';
|
|
|
159
159
|
export type { FinancialSettingsPluginOptions } from './lib/settings-only';
|
|
160
160
|
export { ClientAccountModal, ClientAccountInline } from './components/ClientAccountModal';
|
|
161
161
|
export { ClientAccountPanel } from './views/ClientAccountPanel';
|
|
162
|
+
/**
|
|
163
|
+
* «Preço por tabela» for the inventory product page: the product's price in
|
|
164
|
+
* each price table, edited in one place. The app composes it through the
|
|
165
|
+
* inventory plugin's `productDetailTabs`.
|
|
166
|
+
*/
|
|
167
|
+
export declare function priceTablesProductTab(options?: {
|
|
168
|
+
/** Where the price tables registry lives in this app. */
|
|
169
|
+
settingsHref?: string;
|
|
170
|
+
label?: string;
|
|
171
|
+
}): DetailTab;
|
|
162
172
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,iBAAiB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAIrD,OAAO,KAAK,EAAE,qBAA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MAAM,sBAAsB,CAAA;AAMhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AAKtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAA;AACnE,YAAY,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAA;AAIzE,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAI/D;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE;IAC7C,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;CACV,GAAG,SAAS,CAQjB"}
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { renderCardChip, BankPicker, PaymentModal, InvoiceFormView, InvoiceDetailView,
|
|
1
|
+
import { renderCardChip, BankPicker, renderAccountAvatar, PaymentModal, InvoiceFormView, InvoiceDetailView, ACCOUNTS_ROUTE } from './chunk-IQHWMVUM.js';
|
|
2
2
|
export { FINANCIAL_INVOICE_ZONES } from './chunk-IQHWMVUM.js';
|
|
3
3
|
import './chunk-7VKJLBYY.js';
|
|
4
4
|
import { FINANCIAL_MODULE_DEFAULTS } from './chunk-POYZFEAN.js';
|
|
5
5
|
import { FinancialContextProvider, useFinancialProvider, formatCurrency, useFinancialConfig, useFinancialStore } from './chunk-CNXAVGSW.js';
|
|
6
6
|
import * as React5 from 'react';
|
|
7
7
|
import React5__default, { useEffect } from 'react';
|
|
8
|
-
import { CircleDollarSign, FileText, Search, X, ChevronsUpDown, ChevronsDownUp, Plus,
|
|
9
|
-
import { registerTranslations, tl, recordRailFields, RECORD_GROUP, activeFacet, lazyComponent, createConnectionStore, connectionSettings, connectionStatus, settingsStatus, connectionRuns,
|
|
10
|
-
import { Button, Badge, Input, ModalTask,
|
|
8
|
+
import { CircleDollarSign, FileText, Search, X, ChevronsUpDown, ChevronsDownUp, Plus, ChevronRight, FolderOpen, Folder, Pencil, Ban, RotateCcw, Trash2, Wallet, ArrowUpRight, ArrowDownRight, AlertTriangle, EyeOff, Eye, CreditCard } from 'lucide-react';
|
|
9
|
+
import { registerTranslations, tl, recordRailFields, RECORD_GROUP, activeFacet, lazyComponent, createConnectionStore, connectionSettings, connectionStatus, settingsStatus, connectionRuns, useTranslation, resolveDataProvider, emitDataChanged, registerMessageDefaults, countByTenant, onAppPathChange, resolveCurrency } from '@fayz-ai/core';
|
|
10
|
+
import { Button, Badge, Input, ModalTask, Skeleton, SegmentedControl, PageHeaderActions, Checkbox, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, SearchSelect, toast, defineKpiWidget, defineChartWidget, defineCustomWidget, defineTableWidget, Modal, ModalContent, ModalHeader, ModalTitle, ModalDescription, ModalBody, KpiCard, ChartWidget, Card, CardHeader, CardTitle, CardContent, TableWidget, useDashboardNavigate, GoldCard } from '@fayz-ai/ui';
|
|
11
11
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
12
12
|
import { createSafeFinancialProvider, createFinancialStore } from '@fayz-ai/financial/store';
|
|
13
13
|
export { createSafeFinancialProvider } from '@fayz-ai/financial/store';
|
|
14
14
|
import { FINANCIAL_ZONES } from '@fayz-ai/financial/views/zones';
|
|
15
|
-
import { addAllProductsToPriceTable, fayzConnectorOAuth, defineSettingsTab, RightRailPage, useConnectors, useConnectorsPanelAvailable, SettingsForm, ConnectorMark, StateChip, ConnectorDetail, openConnectorsPanel, createCrudPage, PluginSettingsPanel, useTenantPluginSettings
|
|
15
|
+
import { draftAllProductsForPriceTable, addAllProductsToPriceTable, fayzConnectorOAuth, defineSettingsTab, RightRailPage, useConnectors, useConnectorsPanelAvailable, SettingsForm, ConnectorMark, StateChip, ConnectorDetail, usePermissionOptional, openConnectorsPanel, createCrudPage, PluginSettingsPanel, useTenantPluginSettings } from '@fayz-ai/admin';
|
|
16
16
|
import { invoiceOpensForEditing } from '@fayz-ai/financial/domain/invoice';
|
|
17
17
|
import { T } from '@fayz-ai/financial/data/tables';
|
|
18
18
|
import { buildChartTree, rootIds, searchVisibleIds, isGroupNode, descendantIds, accountLabel, suggestNextCode, childIds } from '@fayz-ai/financial/domain/chart-of-accounts';
|
|
@@ -3911,7 +3911,15 @@ var priceTableItemEntity = {
|
|
|
3911
3911
|
showInTable: true,
|
|
3912
3912
|
fillFrom: { field: "productId", source: "price" }
|
|
3913
3913
|
},
|
|
3914
|
-
{
|
|
3914
|
+
{
|
|
3915
|
+
key: "minQty",
|
|
3916
|
+
label: tl("From qty", "A partir de (qtd)"),
|
|
3917
|
+
type: "number",
|
|
3918
|
+
min: 1,
|
|
3919
|
+
defaultValue: 1,
|
|
3920
|
+
showInTable: true,
|
|
3921
|
+
hint: tl("1 = any quantity", "1 = vale para qualquer quantidade")
|
|
3922
|
+
}
|
|
3915
3923
|
],
|
|
3916
3924
|
data: { table: "price_table_items", tenantScoped: true }
|
|
3917
3925
|
};
|
|
@@ -3981,6 +3989,10 @@ var priceTableEntity = {
|
|
|
3981
3989
|
icon: "ListChecks",
|
|
3982
3990
|
display: "grid",
|
|
3983
3991
|
pageSize: 1e3,
|
|
3992
|
+
description: tl(
|
|
3993
|
+
"One product, one price per table: create Resale, Restaurant and Retail and put the same product in each one at that table's price.",
|
|
3994
|
+
"Um produto, um pre\xE7o por tabela: crie Revenda, Restaurante e Consumidor e coloque o mesmo produto em cada uma com o pre\xE7o daquela tabela."
|
|
3995
|
+
),
|
|
3984
3996
|
emptyHint: tl(
|
|
3985
3997
|
"No item yet. Add them one by one, or add every for-sale product at its base price and adjust.",
|
|
3986
3998
|
"Nenhum item ainda. Adicione um a um, ou adicione todos os produtos \xE0 venda pelo pre\xE7o base e ajuste."
|
|
@@ -3992,6 +4004,16 @@ var priceTableEntity = {
|
|
|
3992
4004
|
run: async (tableId) => {
|
|
3993
4005
|
const added = await addAllProductsToPriceTable(tableId, ["good"]);
|
|
3994
4006
|
return added > 0 ? tl(`${added} product(s) added at the base price.`, `${added} produto(s) adicionado(s) pelo pre\xE7o base.`) : tl("Every for-sale product is already in this table.", "Todos os produtos \xE0 venda j\xE1 est\xE3o nesta tabela.");
|
|
4007
|
+
},
|
|
4008
|
+
// A new table fills its grid before the first save; the rows are
|
|
4009
|
+
// written with the table.
|
|
4010
|
+
draft: async (rows) => {
|
|
4011
|
+
const present = new Set(rows.map((r) => r.productId));
|
|
4012
|
+
const proposed = (await draftAllProductsForPriceTable(["good"])).filter((r) => !present.has(r.productId));
|
|
4013
|
+
return {
|
|
4014
|
+
rows: proposed,
|
|
4015
|
+
message: proposed.length > 0 ? tl(`${proposed.length} product(s) added at the base price. They are saved with the table.`, `${proposed.length} produto(s) adicionado(s) pelo pre\xE7o base. Eles s\xE3o gravados ao salvar a tabela.`) : tl("Every for-sale product is already in this table.", "Todos os produtos \xE0 venda j\xE1 est\xE3o nesta tabela.")
|
|
4016
|
+
};
|
|
3995
4017
|
}
|
|
3996
4018
|
}]
|
|
3997
4019
|
}
|
|
@@ -4076,7 +4098,12 @@ var financialRegistries = [
|
|
|
4076
4098
|
icon: "Tag",
|
|
4077
4099
|
description: "Sale price tables (restaurant, resale, retail\u2026), picked on a receivable after the customer",
|
|
4078
4100
|
agentHint: "Sale price TABLES: a named set of item prices picked on a receivable. Not a product price and not a discount reason.",
|
|
4079
|
-
display: "table"
|
|
4101
|
+
display: "table",
|
|
4102
|
+
emptyHint: tl(
|
|
4103
|
+
"A price table is one price list (Resale, Restaurant, Retail\u2026): the same product can sit in each one at a different price, picked on the sale.",
|
|
4104
|
+
"Uma tabela \xE9 uma lista de pre\xE7os (Revenda, Restaurante, Consumidor\u2026): o mesmo produto entra em cada uma com um pre\xE7o diferente, escolhido na venda."
|
|
4105
|
+
),
|
|
4106
|
+
addLabel: tl("New table", "Nova tabela")
|
|
4080
4107
|
},
|
|
4081
4108
|
{
|
|
4082
4109
|
id: "discount-reasons",
|
|
@@ -5791,7 +5818,17 @@ var FinancialGeneralSettings = lazyComponent(() => import('./FinancialGeneralSet
|
|
|
5791
5818
|
var CommissionRulesView = lazyComponent(() => import('./CommissionRulesView-2RW4ZCDT.js').then((m) => m.CommissionRulesView));
|
|
5792
5819
|
var PersonStatementWidget = lazyComponent(() => import('./PersonStatementWidget-ULXXXYZ4.js').then((m) => m.PersonStatementWidget));
|
|
5793
5820
|
var SupplierFinancialSettings = lazyComponent(() => import('./PersonStatementWidget-ULXXXYZ4.js').then((m) => m.SupplierFinancialSettings));
|
|
5821
|
+
var ProductPriceTablesTabView = lazyComponent(() => import('./ProductPriceTablesTab-FKYRGSBI.js').then((m) => m.ProductPriceTablesTab));
|
|
5822
|
+
function priceTablesProductTab(options = {}) {
|
|
5823
|
+
return {
|
|
5824
|
+
id: "price-tables",
|
|
5825
|
+
label: options.label ?? tl("Price per table", "Pre\xE7o por tabela"),
|
|
5826
|
+
icon: "Tag",
|
|
5827
|
+
component: ProductPriceTablesTabView,
|
|
5828
|
+
props: { settingsHref: options.settingsHref ?? "/settings/financial/price-tables" }
|
|
5829
|
+
};
|
|
5830
|
+
}
|
|
5794
5831
|
|
|
5795
|
-
export { ClientAccountInline, ClientAccountModal, ClientAccountPanel, FINANCIAL_NAV_FEATURES, ReceivePaymentModal, buildFinancialDomainEvents, buildFinancialMessageDefaults, createFinancialPlugin, createFinancialSettingsPlugin };
|
|
5832
|
+
export { ClientAccountInline, ClientAccountModal, ClientAccountPanel, FINANCIAL_NAV_FEATURES, ReceivePaymentModal, buildFinancialDomainEvents, buildFinancialMessageDefaults, createFinancialPlugin, createFinancialSettingsPlugin, priceTablesProductTab };
|
|
5796
5833
|
//# sourceMappingURL=index.js.map
|
|
5797
5834
|
//# sourceMappingURL=index.js.map
|