@fayz-ai/plugin-fiscal-br 0.12.1 → 0.13.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/index.js +50 -7
- package/dist/index.js.map +1 -1
- package/dist/lib/emitters.d.ts +4 -0
- package/dist/lib/emitters.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -87,7 +87,10 @@ var SENTENCES = {
|
|
|
87
87
|
not_base64: "N\xE3o foi poss\xEDvel ler o arquivo do certificado.",
|
|
88
88
|
invalid_setting: "Um dos valores n\xE3o \xE9 aceito.",
|
|
89
89
|
plugnotas_refused: "A PlugNotas recusou o envio.",
|
|
90
|
-
admin_only: "S\xF3 o suporte pode mudar isso."
|
|
90
|
+
admin_only: "S\xF3 o suporte pode mudar isso.",
|
|
91
|
+
series_taken: "Esta s\xE9rie j\xE1 \xE9 usada por outro sistema neste CNPJ. Escolha outra.",
|
|
92
|
+
not_registered: "A empresa ainda n\xE3o est\xE1 cadastrada na PlugNotas.",
|
|
93
|
+
no_series: "Escolha a s\xE9rie da NFC-e."
|
|
91
94
|
};
|
|
92
95
|
var FIELD_SENTENCES = {
|
|
93
96
|
"nfce.cscId": "O ID do CSC tem s\xF3 n\xFAmeros.",
|
|
@@ -134,7 +137,9 @@ var emitters = {
|
|
|
134
137
|
read: (legalEntityId) => request("GET", one(legalEntityId)),
|
|
135
138
|
save: (legalEntityId, settings) => request("PATCH", one(legalEntityId), settings),
|
|
136
139
|
certificate: async (legalEntityId, file, password) => request("PUT", one(legalEntityId, "/certificate"), { pfxBase64: await base64Of(file), password, fileName: file.name }),
|
|
137
|
-
register: (legalEntityId) => request("PUT", one(legalEntityId, "/registration"))
|
|
140
|
+
register: (legalEntityId) => request("PUT", one(legalEntityId, "/registration")),
|
|
141
|
+
/** Issue in parallel with the previous system: adds this app's own NFC-e series, nothing else. */
|
|
142
|
+
addOwnSeries: (legalEntityId) => request("PUT", one(legalEntityId, "/nfce-series"))
|
|
138
143
|
};
|
|
139
144
|
var TAX_REGIMES = [
|
|
140
145
|
{ value: 1, label: "Simples Nacional" },
|
|
@@ -224,7 +229,7 @@ function EmitterCard({ summary, open, onToggle }) {
|
|
|
224
229
|
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: read, children: "Tentar de novo" })
|
|
225
230
|
] }),
|
|
226
231
|
!emitter && !error && /* @__PURE__ */ jsx(Skeleton, { className: "h-24 w-full" }),
|
|
227
|
-
emitter && observed && /* @__PURE__ */ jsx(Observed, { emitter }),
|
|
232
|
+
emitter && observed && /* @__PURE__ */ jsx(Observed, { emitter, onChange: setEmitter }),
|
|
228
233
|
emitter && !observed && /* @__PURE__ */ jsx(Setup, { emitter, onChange: setEmitter })
|
|
229
234
|
] })
|
|
230
235
|
] });
|
|
@@ -239,18 +244,56 @@ function StatusBadge({ emitter }) {
|
|
|
239
244
|
if (emitter.ready === false) return /* @__PURE__ */ jsx(Badge, { variant: "outline", className: "text-muted-foreground", children: "Configura\xE7\xE3o incompleta" });
|
|
240
245
|
return null;
|
|
241
246
|
}
|
|
242
|
-
function Observed({ emitter }) {
|
|
247
|
+
function Observed({ emitter, onChange }) {
|
|
243
248
|
const p = emitter.provider;
|
|
244
249
|
const cert = p?.certificate;
|
|
245
|
-
|
|
246
|
-
|
|
250
|
+
const taken = p?.nfce?.series ?? [];
|
|
251
|
+
const [series, setSeries] = React.useState(() => String(emitter.ownSeries ?? (taken.length ? Math.max(...taken) + 1 : 1)));
|
|
252
|
+
const [start, setStart] = React.useState("1");
|
|
253
|
+
const [adding, setAdding] = React.useState(false);
|
|
254
|
+
const add = async () => {
|
|
255
|
+
setAdding(true);
|
|
256
|
+
try {
|
|
257
|
+
await emitters.save(emitter.legalEntityId, { nfce: { enabled: true, production: p?.nfce?.production ?? true, series: Number(series), nextNumber: Number(start) || 1 } });
|
|
258
|
+
onChange(await emitters.addOwnSeries(emitter.legalEntityId));
|
|
259
|
+
toast.success(`S\xE9rie ${series} cadastrada. Este app j\xE1 pode emitir NFC-e para esta empresa.`);
|
|
260
|
+
} catch (e) {
|
|
261
|
+
toast.error("N\xE3o foi poss\xEDvel cadastrar a s\xE9rie", { description: emitterErrorSentence(e) });
|
|
262
|
+
} finally {
|
|
263
|
+
setAdding(false);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-4 text-sm", children: [
|
|
267
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: "Esta empresa j\xE1 est\xE1 cadastrada na PlugNotas e \xE9 gerenciada pelo sistema anterior. Aqui ela fica s\xF3 para consulta, para os dois sistemas n\xE3o mudarem o mesmo cadastro." }),
|
|
247
268
|
/* @__PURE__ */ jsxs("dl", { className: "grid gap-x-6 gap-y-1", style: { gridTemplateColumns: "auto 1fr" }, children: [
|
|
248
269
|
/* @__PURE__ */ jsx("dt", { className: "text-muted-foreground", children: "NFC-e" }),
|
|
249
|
-
/* @__PURE__ */ jsx("dd", { children: p?.nfce?.active ? `Ligada \xB7 ${p.nfce.production ? "Produ\xE7\xE3o" : "Homologa\xE7\xE3o"}${
|
|
270
|
+
/* @__PURE__ */ jsx("dd", { children: p?.nfce?.active ? `Ligada \xB7 ${p.nfce.production ? "Produ\xE7\xE3o" : "Homologa\xE7\xE3o"}${taken.length ? ` \xB7 s\xE9rie ${taken.join(", ")}` : ""}` : "Desligada" }),
|
|
250
271
|
/* @__PURE__ */ jsx("dt", { className: "text-muted-foreground", children: "Notas recebidas (DF-e)" }),
|
|
251
272
|
/* @__PURE__ */ jsx("dd", { children: p?.nfe?.dfe ? "Ligado" : "Desligado" }),
|
|
252
273
|
/* @__PURE__ */ jsx("dt", { className: "text-muted-foreground", children: "Certificado A1" }),
|
|
253
274
|
/* @__PURE__ */ jsx("dd", { children: cert ? `${cert.expiresAt ? `v\xE1lido at\xE9 ${new Date(cert.expiresAt).toLocaleDateString("pt-BR")}` : "enviado"}` : "Nenhum" })
|
|
275
|
+
] }),
|
|
276
|
+
/* @__PURE__ */ jsxs("section", { className: "space-y-3 rounded-md border p-4", children: [
|
|
277
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium", children: "Emitir tamb\xE9m por aqui" }),
|
|
278
|
+
emitter.ownSeries ? /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground", children: [
|
|
279
|
+
"Este app emite NFC-e na ",
|
|
280
|
+
/* @__PURE__ */ jsxs("strong", { className: "text-foreground", children: [
|
|
281
|
+
"s\xE9rie ",
|
|
282
|
+
emitter.ownSeries
|
|
283
|
+
] }),
|
|
284
|
+
", ao mesmo tempo que o sistema anterior emite na sua. Cada s\xE9rie tem a sua numera\xE7\xE3o, ent\xE3o as notas nunca repetem n\xFAmero."
|
|
285
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
286
|
+
/* @__PURE__ */ jsxs("p", { className: "text-muted-foreground", children: [
|
|
287
|
+
"Os dois sistemas podem emitir ao mesmo tempo, cada um na sua s\xE9rie: a SEFAZ numera cada s\xE9rie separadamente. Escolha uma s\xE9rie que o sistema anterior n\xE3o usa",
|
|
288
|
+
taken.length ? ` (ele usa ${taken.join(", ")})` : "",
|
|
289
|
+
". S\xF3 a s\xE9rie \xE9 adicionada ao cadastro na PlugNotas; o resto fica como est\xE1."
|
|
290
|
+
] }),
|
|
291
|
+
/* @__PURE__ */ jsx("div", { className: "fz-container", children: /* @__PURE__ */ jsxs("div", { className: "fz-fields fz-fields-2 gap-4", children: [
|
|
292
|
+
/* @__PURE__ */ jsx(Field, { label: "S\xE9rie deste app", children: /* @__PURE__ */ jsx(Input, { inputMode: "numeric", value: series, onChange: (e) => setSeries(e.target.value.replace(/\D/g, "")) }) }),
|
|
293
|
+
/* @__PURE__ */ jsx(Field, { label: "Primeiro n\xFAmero", hint: "Em uma s\xE9rie nova, comece em 1.", children: /* @__PURE__ */ jsx(Input, { inputMode: "numeric", value: start, onChange: (e) => setStart(e.target.value.replace(/\D/g, "")) }) })
|
|
294
|
+
] }) }),
|
|
295
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { onClick: () => void add(), disabled: adding || !series, children: adding ? "Cadastrando\u2026" : `Cadastrar s\xE9rie ${series || ""}` }) })
|
|
296
|
+
] })
|
|
254
297
|
] })
|
|
255
298
|
] });
|
|
256
299
|
}
|