@fayz-ai/plugin-fiscal-br 0.6.0 → 0.7.0

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 CHANGED
@@ -3884,6 +3884,51 @@ UPDATE public.plg_financial_invoices i
3884
3884
  AND d.supplier_party_id IS NOT NULL
3885
3885
  AND i.counterparty_person_id IS NULL;
3886
3886
  `;
3887
+ var MIGRATION_021_USO_E_CONSUMO_ENTRA_NO_ESTOQUE = `-- "Materiais de Uso e Consumo" vira um tipo de registro da nota recebida.
3888
+ --
3889
+ -- \xC9 o que a casa gasta sem vender nem transformar \u2014 luva, descart\xE1vel, material
3890
+ -- de limpeza \u2014 e que ainda assim se conta no estoque. Entra no estoque como o
3891
+ -- insumo: precisa de produto vinculado e gera movimento ao aceitar.
3892
+ --
3893
+ -- Aditivo e idempotente. A fun\xE7\xE3o de aceite \xE9 REMENDADA, n\xE3o reescrita (mesmo
3894
+ -- padr\xE3o da 015): copiar o corpo da 010 apagaria o \`reason\` que a 015 enxertou.
3895
+
3896
+ ALTER TABLE public.plg_fiscalbr_inbox_items
3897
+ DROP CONSTRAINT IF EXISTS plg_fiscalbr_inbox_items_entry_type_chk;
3898
+ ALTER TABLE public.plg_fiscalbr_inbox_items
3899
+ ADD CONSTRAINT plg_fiscalbr_inbox_items_entry_type_chk
3900
+ CHECK (entry_type IS NULL OR entry_type IN ('insumo','revenda','patrimonio','uso_consumo','despesa','servico'));
3901
+
3902
+ ALTER TABLE public.plg_fiscalbr_supplier_product_map
3903
+ DROP CONSTRAINT IF EXISTS plg_fiscalbr_supplier_product_map_entry_type_chk;
3904
+ ALTER TABLE public.plg_fiscalbr_supplier_product_map
3905
+ ADD CONSTRAINT plg_fiscalbr_supplier_product_map_entry_type_chk
3906
+ CHECK (entry_type IS NULL OR entry_type IN ('insumo','revenda','patrimonio','uso_consumo','despesa','servico'));
3907
+
3908
+ DO $m$
3909
+ DECLARE
3910
+ v_def text;
3911
+ v_antes text := $q$entry_type IN ('insumo','revenda','patrimonio')$q$;
3912
+ v_depois text := $q$entry_type IN ('insumo','revenda','patrimonio','uso_consumo')$q$;
3913
+ BEGIN
3914
+ SELECT pg_get_functiondef(p.oid) INTO v_def
3915
+ FROM pg_proc p JOIN pg_namespace n ON n.oid = p.pronamespace
3916
+ WHERE n.nspname = 'public' AND p.proname = 'fiscalbr_accept_inbox_document';
3917
+
3918
+ IF v_def IS NULL THEN
3919
+ RAISE EXCEPTION 'fiscalbr/021: fiscalbr_accept_inbox_document n\xE3o existe \u2014 aplicar 009/010 antes';
3920
+ END IF;
3921
+
3922
+ IF position('uso_consumo' in v_def) > 0 THEN RETURN; END IF;
3923
+
3924
+ IF position(v_antes in v_def) = 0 THEN
3925
+ RAISE EXCEPTION 'fiscalbr/021: o corpo de fiscalbr_accept_inbox_document n\xE3o \xE9 o esperado \u2014 confira \xE0 m\xE3o em vez de deixar passar calado';
3926
+ END IF;
3927
+
3928
+ EXECUTE replace(v_def, v_antes, v_depois);
3929
+ END
3930
+ $m$;
3931
+ `;
3887
3932
  var MIGRATIONS = [
3888
3933
  { id: "000_baseline", sql: MIGRATION_000_BASELINE },
3889
3934
  { id: "001_preserve_terminal_results_and_recover_leases", sql: MIGRATION_001_PRESERVE_TERMINAL_RESULTS_AND_RECOVER_LEASES },
@@ -3905,7 +3950,8 @@ var MIGRATIONS = [
3905
3950
  { id: "017_quem_emite_e_o_cnpj_nao_a_loja", sql: MIGRATION_017_QUEM_EMITE_E_O_CNPJ_NAO_A_LOJA },
3906
3951
  { id: "018_a_nota_do_v1_alcanca_a_conta", sql: MIGRATION_018_A_NOTA_DO_V1_ALCANCA_A_CONTA },
3907
3952
  { id: "019_a_nota_emitida_se_cancela_pelo_v2", sql: MIGRATION_019_A_NOTA_EMITIDA_SE_CANCELA_PELO_V2 },
3908
- { id: "020_a_nota_acha_o_fornecedor_pelo_cnpj", sql: MIGRATION_020_A_NOTA_ACHA_O_FORNECEDOR_PELO_CNPJ }
3953
+ { id: "020_a_nota_acha_o_fornecedor_pelo_cnpj", sql: MIGRATION_020_A_NOTA_ACHA_O_FORNECEDOR_PELO_CNPJ },
3954
+ { id: "021_uso_e_consumo_entra_no_estoque", sql: MIGRATION_021_USO_E_CONSUMO_ENTRA_NO_ESTOQUE }
3909
3955
  ];
3910
3956
  var taxGroupEntity = {
3911
3957
  name: "Grupo fiscal",
@@ -5497,7 +5543,7 @@ function NoteAttachmentsCard({ noteId, invoiceId, readOnly, instalments, onInsta
5497
5543
  }
5498
5544
 
5499
5545
  // src/types.ts
5500
- var STOCK_BEARING_ENTRY_TYPES = ["insumo", "revenda", "patrimonio"];
5546
+ var STOCK_BEARING_ENTRY_TYPES = ["insumo", "revenda", "patrimonio", "uso_consumo"];
5501
5547
  var isStockBearing = (type) => STOCK_BEARING_ENTRY_TYPES.includes(type);
5502
5548
 
5503
5549
  // src/lib/note-suggestion.ts
@@ -5524,6 +5570,7 @@ var ENTRY_TYPES = [
5524
5570
  { value: "insumo", label: "Insumo" },
5525
5571
  { value: "revenda", label: "Produto Revenda" },
5526
5572
  { value: "patrimonio", label: "Patrim\xF4nio" },
5573
+ { value: "uso_consumo", label: "Uso e Consumo", hint: "com estoque" },
5527
5574
  { value: "despesa", label: "Despesa", hint: "n\xE3o vira estoque" },
5528
5575
  { value: "servico", label: "Servi\xE7o", hint: "n\xE3o vira estoque" }
5529
5576
  ];
@@ -5757,13 +5804,16 @@ function NoteReconcileView({ noteId, onBack, onOpenInvoice, chrome = "page" }) {
5757
5804
  ] })
5758
5805
  ] }),
5759
5806
  /* @__PURE__ */ jsx(ModalBody, { className: "px-6 py-4", children: node }),
5760
- rodape2 && /* @__PURE__ */ jsx(ModalFooter, { className: "shrink-0 flex-row items-center justify-between gap-3 space-x-0 border-t px-6 py-3 pr-16", children: rodape2 })
5807
+ rodape2 && /* @__PURE__ */ jsx(ModalFooter, { variant: "bar", start: rodape2.start, children: rodape2.end })
5761
5808
  ] }) : (
5762
5809
  // Em tela cheia não há moldura onde pendurar o rodapé: ele volta para dentro
5763
5810
  // do conteúdo, grudado na base da janela enquanto a página rola.
5764
5811
  /* @__PURE__ */ jsxs(Fragment, { children: [
5765
5812
  node,
5766
- rodape2 && /* @__PURE__ */ jsx("div", { className: `sticky bottom-0 ${sangria} flex items-center justify-between gap-3 border-t bg-card/95 py-3 pr-16 backdrop-blur`, children: rodape2 })
5813
+ rodape2 && /* @__PURE__ */ jsxs("div", { className: `sticky bottom-0 ${sangria} flex items-center justify-between gap-3 border-t bg-card/95 py-3 pr-16 backdrop-blur`, children: [
5814
+ /* @__PURE__ */ jsx("div", { className: "flex min-w-0 items-center gap-3", children: rodape2.start }),
5815
+ /* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center gap-2", children: rodape2.end })
5816
+ ] })
5767
5817
  ] })
5768
5818
  );
5769
5819
  const [cadastrando, setCadastrando] = useState(false);
@@ -5923,51 +5973,55 @@ function NoteReconcileView({ noteId, onBack, onOpenInvoice, chrome = "page" }) {
5923
5973
  ] }) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Nota n\xE3o encontrada." }) })
5924
5974
  ] }), "Concilia\xE7\xE3o");
5925
5975
  }
5926
- const rodape = readOnly ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
5927
- /* @__PURE__ */ jsxs(
5928
- Button,
5929
- {
5930
- variant: "ghost",
5931
- onClick: async () => {
5932
- await rejectNote(note.id);
5933
- onBack();
5934
- },
5935
- disabled: saving || accepting,
5936
- children: [
5937
- /* @__PURE__ */ jsx(X, { className: "mr-1.5 h-4 w-4" }),
5938
- "Rejeitar"
5939
- ]
5940
- }
5941
- ),
5942
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
5943
- (missingType > 0 || missingProduct > 0) && /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
5944
- unverifiedFactor > 0 && `${unverifiedFactor} com fator por conferir`,
5945
- unverifiedFactor > 0 && (missingType > 0 || missingProduct > 0) && " \xB7 ",
5946
- missingType > 0 && `${missingType} sem tipo`,
5947
- missingType > 0 && missingProduct > 0 && " \xB7 ",
5948
- missingProduct > 0 && `${missingProduct} sem produto`
5949
- ] }),
5950
- /* @__PURE__ */ jsxs(Button, { variant: "outline", onClick: () => {
5976
+ const pendencias = [
5977
+ unverifiedFactor > 0 && `${unverifiedFactor} com fator por conferir`,
5978
+ missingType > 0 && `${missingType} sem tipo`,
5979
+ missingProduct > 0 && `${missingProduct} sem produto`
5980
+ ].filter(Boolean).join(" \xB7 ");
5981
+ const rodape = readOnly ? null : {
5982
+ start: /* @__PURE__ */ jsxs(Fragment, { children: [
5983
+ /* @__PURE__ */ jsxs(
5984
+ Button,
5985
+ {
5986
+ variant: "ghost",
5987
+ size: "sm",
5988
+ className: "text-destructive hover:bg-destructive/10 hover:text-destructive",
5989
+ onClick: async () => {
5990
+ await rejectNote(note.id);
5991
+ onBack();
5992
+ },
5993
+ disabled: saving || accepting,
5994
+ children: [
5995
+ /* @__PURE__ */ jsx(X, { className: "mr-1.5 h-3.5 w-3.5" }),
5996
+ "Rejeitar"
5997
+ ]
5998
+ }
5999
+ ),
6000
+ pendencias && /* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: pendencias })
6001
+ ] }),
6002
+ end: /* @__PURE__ */ jsxs(Fragment, { children: [
6003
+ /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", onClick: () => {
5951
6004
  void save();
5952
6005
  }, disabled: saving || accepting, children: [
5953
- saving && /* @__PURE__ */ jsx(Loader2, { className: "mr-1.5 h-4 w-4 animate-spin" }),
6006
+ saving && /* @__PURE__ */ jsx(Loader2, { className: "mr-1.5 h-3.5 w-3.5 animate-spin" }),
5954
6007
  "Salvar concilia\xE7\xE3o"
5955
6008
  ] }),
5956
6009
  /* @__PURE__ */ jsxs(
5957
6010
  Button,
5958
6011
  {
6012
+ size: "sm",
5959
6013
  onClick: () => {
5960
6014
  void accept();
5961
6015
  },
5962
6016
  disabled: accepting || saving || missingType > 0 || missingProduct > 0 || unverifiedFactor > 0,
5963
6017
  children: [
5964
- accepting ? /* @__PURE__ */ jsx(Loader2, { className: "mr-1.5 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Check, { className: "mr-1.5 h-4 w-4" }),
6018
+ accepting ? /* @__PURE__ */ jsx(Loader2, { className: "mr-1.5 h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ jsx(Check, { className: "mr-1.5 h-3.5 w-3.5" }),
5965
6019
  "Aceitar"
5966
6020
  ]
5967
6021
  }
5968
6022
  )
5969
6023
  ] })
5970
- ] });
6024
+ };
5971
6025
  return moldura(/* @__PURE__ */ jsxs("div", { className: `space-y-4 ${emModal ? "" : "pb-24"}`, children: [
5972
6026
  cabecalho(`Concilia\xE7\xE3o \xB7 NF-e ${note.number}`),
5973
6027
  accepted && /* @__PURE__ */ jsxs(Card, { className: "border-success bg-success-soft p-4", children: [