PageSourceSearch

https://alinhafood.com.br/_next/static/chunks/74008.227bd283b5f7f50f.js

js alinhafood.com.br collected 2026-10-02 01:20:29 UTC 14,283 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[74008],{67840:(e,a,t)=>{t.d(a,{A:()=>r});let r=(0,t(71847).A)("arrow-down-right",[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]])},74008:(e,a,t)=>{t.r(a),t.d(a,{default:()=>k});var r=t(95155),n=t(12115),o=t(14272),s=t(78384),i=t(67592),l=t(28394),c=t(73482),d=t(21786),x=t(89559);let m=(0,t(71847).A)("file-spreadsheet",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]);var p=t(7013),h=t(67840),u=t(61362),b=t(6132),f=t(77588),g=t(71360);let j=e=>Number(null!=e?e:0).toLocaleString("pt-BR",{style:"currency",currency:"BRL"}),v=e=>{let a=(0,c.H)(e);return a?a.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"2-digit"}):"—"};async function y(){var e,a;let{data:t}=await (0,o.U)("admin").auth.getSession();return null!=(a=null==(e=t.session)?void 0:e.access_token)?a:""}function N(e,a){let t=[],r="",n=!1;for(let o=0;o<e.length;o++){let s=e[o];n?'"'===s?'"'===e[o+1]?(r+='"',o++):n=!1:r+=s:'"'===s?n=!0:s===a?(t.push(r),r=""):r+=s}return t.push(r),t.map(e=>e.trim())}function w(e,a){let t=e.findIndex(e=>a.includes(e));return -1!==t?t:e.findIndex(e=>a.some(a=>e.includes(a)))}function k(){let{restaurantId:e}=(0,s.p)(),{showToast:a}=(0,i.d)(),[t,o]=(0,n.useState)([]),[c,k]=(0,n.useState)([]),[C,z]=(0,n.useState)([]),[_,A]=(0,n.useState)(!0),[M,B]=(0,n.useState)("false"),[D,H]=(0,n.useState)(""),[Y,V]=(0,n.useState)(null),L=(0,n.useRef)(null),O=(0,n.useCallback)(async()=>{if(!e)return void A(!1);A(!0);let t=await y(),r={};"all"!==M&&(r.conciliado=M);let n=(0,l.H)("/api/admin/financeiro/reconciliacao-bancaria",e,{...r,modo:"linhas"}),s=(0,l.H)("/api/admin/financeiro/reconciliacao-bancaria",e,{modo:"sugestoes"}),i=(0,l.H)("/api/admin/financeiro/reconciliacao-bancaria",e,{modo:"resumo"}),c=(0,l.H)("/api/admin/financeiro/contas-bancarias",e);if(!n||!s||!i||!c)return void A(!1);try{var d,x,m;let[e,a,r,l]=await Promise.all([fetch(n,{headers:{authorization:"Bearer ".concat(t)}}),fetch(s,{headers:{authorization:"Bearer ".concat(t)}}),fetch(i,{headers:{authorization:"Bearer ".concat(t)}}),fetch(c,{headers:{authorization:"Bearer ".concat(t)}})]);if(e.ok){let a=await e.json();o(null!=(d=a.rows)?d:[])}if(a.ok){let e=await a.json();k(null!=(x=e.rows)?x:[])}if(r.ok&&V(await r.json()),l.ok){let e=await l.json(),a=(Array.isArray(e)?e:null!=(m=e.data)?m:[]).map(e=>({id:e.id,nome:e.nome}));z(a),!D&&a[0]&&H(a[0].id)}}catch(e){a("Erro ao carregar: "+e.message,"error")}finally{A(!1)}},[e,M,D,a]);(0,n.useEffect)(()=>{O()},[O]);let R=async t=>{if(!e)return;if(!D)return void a("Selecione uma conta banc\xe1ria antes de importar.","error");let{rows:r,error:n}=function(e){let a=e.replace(/^/,"").split(/\r?\n/).filter(e=>e.trim());if(a.length<2)return{rows:[],error:"O arquivo precisa de um cabe\xe7alho e ao menos uma linha de dados."};let t=a[0],r=t.includes(";")?";":t.includes("	")?"	":",",n=N(t,r).map(e=>e.toLowerCase()),o={data:w(n,["data","date","data lan\xe7amento","data lancamento","data mov"]),descricao:w(n,["descricao","descri\xe7\xe3o","description","historico","hist\xf3rico","lan\xe7amento","lancamento","memo"]),valor:w(n,["valor","amount","value","vlr","valor (r$)"]),tipo:w(n,["tipo","type"]),documento:w(n,["documento","doc","numero","n\xfamero","nro"])};if(-1===o.data||-1===o.valor)return{rows:[],error:'N\xe3o encontrei as colunas obrigat\xf3rias "data" e "valor". Cabe\xe7alho lido: ['.concat(n.join(", "),"].")};let s=[];for(let e=1;e<a.length;e++){var i,l,c,d;let t=N(a[e],r);s.push({data:function(e){let a=e.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(a))return a;let t=/^(\d{1,2})[\/\-.](\d{1,2})[\/\-.](\d{4})$/.exec(a);return t?"".concat(t[3],"-").concat(t[2].padStart(2,"0"),"-").concat(t[1].padStart(2,"0")):(t=/^(\d{1,2})[\/\-.](\d{1,2})[\/\-.](\d{2})$/.exec(a))?"20".concat(t[3],"-").concat(t[2].padStart(2,"0"),"-").concat(t[1].padStart(2,"0")):(t=/^(\d{4})[\/\-.](\d{1,2})[\/\-.](\d{1,2})$/.exec(a))?"".concat(t[1],"-").concat(t[2].padStart(2,"0"),"-").concat(t[3].padStart(2,"0")):a}(null!=(i=t[o.data])?i:""),descricao:null!=(l=t[o.descricao])?l:"",valor:null!=(c=t[o.valor])?c:"",tipo:-1!==o.tipo?(null!=(d=t[o.tipo])?d:"").toLowerCase():void 0,documento:-1!==o.documento?t[o.documento]:void 0})}return{rows:s}}(await t.text());if(0===r.length)return void a(null!=n?n:"CSV vazio ou inv\xe1lido. Esperado: cabe\xe7alho com colunas data, descricao, valor, tipo (opcional).","error");let o=await y(),s=(0,l.H)("/api/admin/financeiro/reconciliacao-bancaria",e);if(!s)return;let i=await fetch(s,{method:"POST",headers:{"content-type":"application/json",authorization:"Bearer ".concat(o)},body:JSON.stringify({acao:"upload_csv",conta_bancaria_id:D,linhas:r})}),c=await i.json();if(!i.ok){var d;let e=Array.isArray(c.detalhes)&&c.detalhes.length?" (".concat(c.detalhes.slice(0,3).join("; ")).concat(c.detalhes.length>3?"…":"",")"):"";a("Falha ao importar: "+(null!=(d=c.error)?d:"erro")+e,"error");return}a("".concat(c.inseridas," linhas importadas (").concat(c.ignoradas," ignoradas)."),"success"),O(),L.current&&(L.current.value="")},E=async(t,r,n)=>{if(!e)return;let o=await y(),s=(0,l.H)("/api/admin/financeiro/reconciliacao-bancaria",e);if(!s)return;let i=await fetch(s,{method:"POST",headers:{"content-type":"application/json",authorization:"Bearer ".concat(o)},body:JSON.stringify({acao:t,bank_line_id:r,lancamento_id:n})}),c=await i.json();if(!i.ok||!1===c.ok){var d,x;a("Falha: "+(null!=(x=null!=(d=c.error)?d:c.message)?x:"erro"),"error");return}a("OK","success"),O()},I=c.reduce((e,a)=>{var t;return(e[a.bank_line_id]=null!=(t=e[a.bank_line_id])?t:[]).push(a),e},{});return(0,r.jsxs)("div",{className:"flex flex-col h-full bg-bg-base",children:[(0,r.jsx)("div",{className:"border-b border-border-brand bg-white px-6 max-md:px-3 py-5",children:(0,r.jsx)("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-2xl font-black text-text-main font-[family-name:var
1(--font-heading)]",children:"Reconcilia\xe7\xe3o Banc\xe1ria"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-text-sec",children:"Importe seu extrato (CSV) e bata cada linha do banco com um lan\xe7amento do sistema."})]})})}),Y&&(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 px-6 max-md:px-3 py-3 max-md:grid-cols-3 max-md:gap-2",children:[(0,r.jsx)(S,{label:"Total importado",value:Y.total.toString(),tone:"slate"}),(0,r.jsx)(S,{label:"Conciliados",value:Y.conciliados.toString(),tone:"green"}),(0,r.jsx)(S,{label:"Pendentes",value:Y.pendentes.toString(),tone:Y.pendentes?"amber":"green"})]}),(0,r.jsxs)("div",{className:"px-6 max-md:px-3 pb-2",children:[(0,r.jsxs)("div",{className:"rounded-2xl border border-border-brand bg-white p-3 flex flex-wrap items-center gap-2",children:[(0,r.jsxs)("select",{value:D,onChange:e=>H(e.target.value),className:"rounded-xl border border-border-brand bg-white px-3 py-2 text-sm font-bold",children:[0===C.length&&(0,r.jsx)("option",{value:"",children:"Sem contas banc\xe1rias cadastradas"}),C.map(e=>(0,r.jsx)("option",{value:e.id,children:e.nome},e.id))]}),(0,r.jsx)("input",{ref:L,type:"file",accept:".csv",className:"hidden",onChange:e=>{var a;let t=null==(a=e.target.files)?void 0:a[0];t&&R(t)}}),(0,r.jsxs)("button",{onClick:()=>{var e;return null==(e=L.current)?void 0:e.click()},disabled:!D,title:D?void 0:"Cadastre uma conta banc\xe1ria em Financeiro › Contas Banc\xe1rias antes de importar.",className:"inline-flex items-center gap-2 rounded-xl bg-primary px-4 py-2 text-sm font-bold text-white hover:bg-primary-dark disabled:opacity-40",children:[(0,r.jsx)(d.A,{size:14})," Importar extrato CSV"]}),0===C.length&&(0,r.jsx)("span",{className:"text-xs font-bold text-amber-600",children:"Cadastre uma conta banc\xe1ria antes de importar."}),(0,r.jsx)("div",{className:"inline-flex rounded-xl border border-border-brand bg-bg-base p-1 gap-1 ml-auto",children:[["false","Pendentes"],["true","Conciliados"],["all","Todos"]].map(e=>{let[a,t]=e;return(0,r.jsx)("button",{onClick:()=>B(a),className:"rounded-lg px-3 py-1.5 text-sm font-bold transition ".concat(M===a?"bg-white text-primary shadow-sm":"text-text-sec"),children:t},a)})}),(0,r.jsx)("button",{onClick:O,disabled:_,className:"inline-flex items-center gap-2 rounded-xl border border-border-brand bg-white px-3 py-2 text-sm font-bold hover:bg-bg-base disabled:opacity-50",children:(0,r.jsx)(x.A,{size:14,className:_?"animate-spin":""})})]}),(0,r.jsxs)("div",{className:"mt-2 rounded-xl border border-blue-100 bg-primary-light/40 p-3 text-xs text-text-sec",children:[(0,r.jsx)("strong",{className:"text-text-main",children:"Formato do CSV:"})," cabe\xe7alho com colunas ",(0,r.jsx)("code",{className:"font-bold",children:"data;descricao;valor;tipo;documento"})," (separador ; ou ,). Data em ",(0,r.jsx)("code",{children:"YYYY-MM-DD"})," ou ",(0,r.jsx)("code",{children:"DD/MM/YYYY"}),". Tipo opcional (",(0,r.jsx)("code",{children:"credito"}),"/",(0,r.jsx)("code",{children:"debito"}),"); se omitido, valor positivo = cr\xe9dito."]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-hidden px-6 max-md:px-3 pb-4",children:(0,r.jsx)("div",{className:"h-full overflow-auto rounded-2xl border border-border-brand bg-white cel-tabela-fixa",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"bg-bg-base sticky top-0 z-10",children:(0,r.jsxs)("tr",{className:"text-left text-[11px] uppercase tracking-wide text-text-sec font-black border-b border-border-brand",children:[(0,r.jsx)("th",{className:"px-3 py-2 whitespace-nowrap",children:"Data"}),(0,r.jsx)("th",{className:"px-3 py-2",children:"Descri\xe7\xe3o"}),(0,r.jsx)("th",{className:"px-3 py-2 whitespace-nowrap text-right",children:"Valor"}),(0,r.jsx)("th",{className:"px-3 py-2 whitespace-nowrap",children:"Status"}),(0,r.jsx)("th",{className:"px-3 py-2",children:"Lan\xe7amento / Sugest\xe3o"}),(0,r.jsx)("th",{className:"px-3 py-2 text-right",children:"A\xe7\xf5es"})]})}),(0,r.jsxs)("tbody",{children:[_&&0===t.length&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:6,className:"px-3 py-12 text-center text-text-sec",children:"Carregando…"})}),!_&&0===t.length&&(0,r.jsx)("tr",{children:(0,r.jsxs)("td",{colSpan:6,className:"px-3 py-12 text-center",children:[(0,r.jsx)(m,{size:28,className:"mx-auto text-text-sec mb-2"}),(0,r.jsx)("p",{className:"text-sm font-bold",children:"Nenhuma linha de extrato importada ainda"}),(0,r.jsx)("p",{className:"text-xs text-text-sec mt-1",children:'Selecione uma conta acima e clique em "Importar extrato CSV".'})]})}),t.map(e=>{var a,t;let n=null!=(a=I[e.id])?a:[];return(0,r.jsxs)("tr",{className:"border-b border-border-brand last:border-b-0 hover:bg-bg-base align-top",children:[(0,r.jsx)("td",{className:"px-3 py-2 whitespace-nowrap text-text-sec",children:v(e.data)}),(0,r.jsxs)("td",{className:"px-3 py-2 text-text-main",children:[(0,r.jsx)("div",{className:"font-bold",children:null!=(t=e.descricao)?t:"—"}),e.documento&&(0,r.jsxs)("div",{className:"text-xs text-text-sec",children:["doc: ",e.documento]})]}),(0,r.jsxs)("td",{className:"px-3 py-2 whitespace-nowrap text-right font-black ".concat("credito"===e.tipo?"text-emerald-700":"text-rose-700"),children:["credito"===e.tipo?(0,r.jsx)(p.A,{size:12,className:"inline mr-0.5"}):(0,r.jsx)(h.A,{size:12,className:"inline mr-0.5"}),j(Number(e.valor))]}),(0,r.jsx)("td",{className:"px-3 py-2",children:e.conciliado?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border bg-emerald-50 text-emerald-700 border-emerald-200 px-2 py-0.5 text-[11px] font-bold",children:[(0,r.jsx)(u.A,{size:10})," conciliado"]}):(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border bg-amber-50 text-amber-700 border-amber-200 px-2 py-0.5 text-[11px] font-bold",children:[(0,r.jsx)(b.A,{size:10})," pendente"]})}),(0,r.jsxs)("td",{className:"px-3 py-2",children:[e.conciliado&&e.lancamento&&(0,r.jsxs)("div",{className:"text-xs",children:[(0,r.jsx)("div",{className:"font-bold text-text-main",children:e.lancamento.descricao}),(0,r.jsx)("div",{className:"text-text-sec",children:j(Number(e.lancamento.valor))})]}),!e.conciliado&&0===n.length&&(0,r.jsx)("span",{className:"text-xs text-text-sec",children:"Nenhuma sugest\xe3o autom\xe1tica."}),!e.conciliado&&n.length>0&&(0,r.jsx)("div",{className:"space-y-1",children:n.slice(0,3).map(a=>(0,r.jsxs)("button",{onClick:()=>E("conciliar",e.id,a.lancamento_id),className:"block w-full text-left rounded-lg border border-primary/30 bg-primary-light/30 hover:bg-primary-light/60 px-2 py-1 text-xs transition",children:[(0,r.jsx)("div",{className:"font-bold text-primary-dark",children:a.lanc_descricao}),(0,r.jsxs)("div",{className:"text-text-sec",children:[v(a.lanc_data)," \xb7 ",j(Number(a.lanc_valor))," \xb7 ",Math.abs(Number(a.dias_diferenca)),"d de diferen\xe7a"]})]},a.lancamento_id))})]}),(0,r.jsx)("td",{className:"px-3 py-2 text-right whitespace-nowrap",children:e.conciliado?(0,r.jsxs)("button",{onClick:()=>E("desconciliar",e.id),className:"inline-flex items-center gap-1 rounded-lg border border-border-brand bg-white px-2 py-1 text-xs font-bold text-text-sec hover:bg-bg-base",children:[(0,r.jsx)(f.A,{size:12})," Desfazer"]}):(0,r.jsxs)("button",{onClick:()=>E("deletar",e.id),className:"inline-flex items-center gap-1 rounded-lg border border-border-brand bg-white px-2 py-1 text-xs font-bold text-text-sec hover:bg-bg-base",children:[(0,r.jsx)(g.A,{size:12})," Remover"]})})]},e.id)})]})]})})})]})}function S(e){let{label:a,value:t,tone:n}=e;return(0,r.jsxs)("div",{className:"rounded-2xl border border-border-brand bg-white p-3",children:[(0,r.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-text-sec font-bold max-md:text-[0.72rem] max-md:normal-case max-md:tracking-normal max-md:leading-tight",children:a}),(0,r.jsx)("p",{className:"mt-1 text-xl font-black ".concat({green:"text-emerald-700",amber:"text-amber-700",slate:"text-text-main"}[n]),children:t})]})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.