PageSourceSearch

https://vizops360.ai/assets/expenses.import-hmS7OjjL.js

js vizops360.ai collected 2026-10-05 13:53:10 UTC 12,250 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/expenseExcelTemplates-CuEjT3WL.js","assets/excelUtils-B6c4w-tr.js","assets/index-CpeGhXo5.js","assets/index-DPKYDu8W.css","assets/expenseDraft-DqR0Jp71.js","assets/financeImportParse-DTb6d-yn.js","assets/employeeImportParse-C0zECibb.js"])))=>i.map(i=>d[i]);
2import{d4 as W,ax as z,e4 as K,dj as Q,r,j as e,S as Y,aI as m,bQ as R,dh as I,df as L,L as Z,K as M,J as V,as as b,cI as ee,cf as se,cg as te,ch as re,ci as ae,cj as oe,N as le,av as de}from"./index-CpeGhXo5.js";import{a as ne,P as y}from"./Panel-Cf_wAUzv.js";import{mapExpenseRows as ce,EXPENSE_IMPORT_FIELDS as D,parseCSV as A,autoMapExpenseHeaders as ie,EXPENSE_SAMPLE_CSV as xe}from"./financeImportParse-DTb6d-yn.js";import{F as pe,S as me}from"./FinanceEmployeeReferenceButton-BGuo0qvJ.js";import{E as be}from"./ExpenseImportReviewDrawer-BqnN2k-S.js";import{getExpenseAiPrompt as he}from"./expenseExcelTemplates-CuEjT3WL.js";import{a as ue}from"./employeeImportParse-C0zECibb.js";import"./excelUtils-B6c4w-tr.js";import"./financeEmployeeDisplay-CYwTzdnu.js";import"./expenseDraft-DqR0Jp71.js";function Ce(){const d=W(),h=z(),u=K(s=>s.addJob),[j,{isLoading:E}]=Q(),[l,c]=r.useState(1),[g,k]=r.useState("file"),[N,F]=r.useState([]),[i,T]=r.useState([]),[f,U]=r.useState(""),[v,X]=r.useState(""),[x,C]=r.useState({}),[O,P]=r.useState(!1),_=r.useRef(null),w=(s,t,a)=>{F(s),T(t),U(a),C(ie(s))},B=async s=>{if(!s)return;const t=s.name.split(".").pop()?.toLowerCase();if(t==="csv"){const{headers:a,rows:o}=A(await s.text());w(a,o,s.name),c(2);return}if(t==="xlsx"||t==="xls"){const o=ue(await s.arrayBuffer())[0];if(!o?.headers.length){m.error("No data found in workbook");return}w(o.headers,o.rows,s.name),c(2);return}m.error("Use CSV, XLSX, or XLS")},q=()=>{if(!v)return;const{headers:s,rows:t}=A(xe);w(s,t,"Google Sheet · Expenses"),c(2)},{valid:n,invalid:p}=r.useMemo(()=>ce(N,i,x),[N,i,x]),H=r.useMemo(()=>n.slice(0,5),[n]),J=r.useMemo(()=>D.filter(s=>s.required).every(s=>x[s.key]),[x]),$=async()=>{try{const s=await j({rows:n,fileName:f||"Expense import"}).unwrap();u({id:s.jobId,type:"finance-expense-import",title:f||"Expense import",status:"queued",progress:0,total:s.total,importPath:`${d}/expenses/import`}),m.success("Import started in background. Track progress in the panel at bottom right."),h(`${d}/expenses`)}catch(s){m.error(s?.data?.message||s?.message||"Import failed")}};return e.jsxs("div",{className:"p-3 flex flex-col gap-3 min-h-full overflow-auto",children:[e.jsx(ne,{title:"Import Expenses",subtitle:"Download the sample template — employee rows need both Name and Employee ID (HRMS code)",accent:"mod-expense",actions:e.jsxs(e.Fragment,{children:[e.jsx(pe,{variant:"compact"}),e.jsxs("button",{onClick:()=>{navigator.clipboard.writeText(he()),m.success("Copied AI Prompt to clipboard!")},className:"h-7 px-2.5 rounded-[4px] border border-primary/30 bg-primary/5 hover:bg-primary/10 text-primary text-[11px] font-medium inline-flex items-center gap-1.5",children:[e.jsx(Y,{className:"w-3.5 h-3.5 text-primary"})," Copy AI Prompt"]}),e.jsxs("button",{onClick:async()=>{const{downloadExpenseExcelTemplate:s}=await I(async()=>{const{downloadExpenseExcelTemplate:t}=await import("./expenseExcelTemplates-CuEjT3WL.js");return{downloadExpenseExcelTemplate:t}},__vite__mapDeps([0,1,2,3,4]));await s()},className:"h-7 px-2.5 rounded-[4px] border border-border bg-card hover:bg-accent text-[11px] font-medium inline-flex items-center gap-1.5",children:[e.jsx(R,{className:"w-3.5 h-3.5 text-emerald-600"})," Master Template (.xlsx)"]}),e.jsxs("button",{onClick:async()=>{const{EXPENSE_SAMPLE_CSV:s}=await I(async()=>{const{EXPENSE_SAMPLE_CSV:G}=await import("./financeImportParse-DTb6d-yn.js");return{EXPENSE_SAMPLE_CSV:G}},__vite__mapDeps([5,2,3,6,1])),t=new Blob([s],{type:"text/csv;charset=utf-8;"}),a=URL.createObjectURL(t),o=document.createElement("a");o.href=a,o.download="Expenses_Master_Import_Template_41cols.csv",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},className:"h-7 px-2.5 rounded-[4px] border border-border bg-card hover:bg-accent text-[11px] font-medium inline-flex items-center gap-1.5",children:[e.jsx(R,{className:"w-3.5 h-3.5 text-blue-600"})," Sample CSV (.csv)"]}),e.jsxs("button",{onClick:()=>P(!0),className:"h-7 px-2.5 rounded-[4px] border border-border bg-card hover:bg-accent text-[11px] font-medium inline-flex items-center gap-1.5 text-primary",children:[e.jsx(L,{className:"w-3.5 h-3.5"})," Full Review Drawer"]}),e.jsxs(Z,{to:`${d}/expenses`,className:"h-7 px-2.5 rounded-[4px] border border-border bg-card hover:bg-accent text-[11px] font-medium inline-flex items-center gap-1.5",children:[e.jsx(M,{className:"w-3.5 h-3.5"})," Back"]})]})}),e.jsx("div",{className:"flex items-center gap-2 bg-card border border-border rounded-[6px] px-4 py-3",children:[{n:1,label:"Source"},{n:2,label:"Map columns"},{n:3,label:"Review"}].map(({n:s,label:t},a)=>e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("div",{className:b("w-7 h-7 rounded-full grid place-items-center text-[12px] font-bold",l>=s?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:l>
2s?e.jsx(V,{className:"w-4 h-4"}):s}),e.jsx("span",{className:b("text-[12px] font-semibold",l===s?"":"text-muted-foreground opacity-60"),children:t}),a<2&&e.jsx("div",{className:"flex-1 h-px bg-border mx-2"})]},s))}),l===1&&e.jsxs(y,{title:"Step 1 · Choose your source",accent:"mod-expense",children:[e.jsxs("p",{className:"text-[11px] text-muted-foreground px-1 mb-3",children:["Download ",e.jsx("strong",{children:"Employee reference"})," for Employee ID and exact names from HRMS. Employee and Approver columns need both values when used — leave blank otherwise."]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 p-1",children:[e.jsxs("button",{onClick:()=>k("file"),className:b("rounded-xl border p-5 text-left",g==="file"?"border-primary bg-primary/5 ring-2 ring-primary/20":"border-border hover:bg-accent"),children:[e.jsx(L,{className:"w-6 h-6 text-primary mb-2"}),e.jsx("div",{className:"text-[14px] font-bold",children:"CSV / Excel"}),e.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:"Use the downloaded template"})]}),e.jsxs("button",{onClick:()=>k("sheets"),className:b("rounded-xl border p-5 text-left",g==="sheets"?"border-emerald-500 bg-emerald-500/5":"border-border hover:bg-accent"),children:[e.jsx(me,{className:"w-6 h-6 text-emerald-600 mb-2"}),e.jsx("div",{className:"text-[14px] font-bold",children:"Google Sheets"}),e.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:"Paste a shared URL"})]})]}),g==="file"&&e.jsxs("div",{className:"mt-4 p-1",children:[e.jsx("input",{ref:_,type:"file",accept:".csv,.xlsx,.xls,text/csv",className:"hidden",onChange:s=>B(s.target.files?.[0])}),e.jsxs("div",{onClick:()=>_.current?.click(),className:"cursor-pointer border-2 border-dashed border-border rounded-xl p-10 text-center hover:bg-accent/40",children:[e.jsx(ee,{className:"w-6 h-6 mx-auto text-muted-foreground mb-2"}),e.jsx("div",{className:"text-[13px] font-bold",children:"Drop file or click to browse"})]}),f&&e.jsxs("div",{className:"mt-2 text-[11px] text-emerald-600",children:[f," · ",i.length," rows"]})]}),g==="sheets"&&e.jsxs("div",{className:"mt-4 p-1 space-y-3",children:[e.jsx("input",{value:v,onChange:s=>X(s.target.value),placeholder:"https://docs.google.com/spreadsheets/d/…",className:"h-10 px-4 w-full rounded-lg border border-border text-[12px]"}),e.jsx("button",{onClick:q,disabled:!v,className:"h-9 px-5 rounded-lg bg-emerald-600 text-white text-[12px] font-bold disabled:opacity-40",children:"Connect & Fetch"})]})]}),l===2&&e.jsx(y,{title:"Step 2 · Map columns",accent:"mod-expense",children:e.jsx("div",{className:"grid gap-2 p-1 max-h-[420px] overflow-y-auto",children:D.map(s=>e.jsxs("div",{className:"grid grid-cols-[1fr,1fr] gap-2 items-center",children:[e.jsxs("span",{className:"text-[11px] font-medium",children:[s.label.split(" (")[0],s.required&&e.jsx("span",{className:"text-destructive ml-0.5",children:"*"})]}),e.jsxs(se,{value:x[s.key]??"",onValueChange:t=>C(a=>({...a,[s.key]:t})),children:[e.jsx(te,{className:"h-8 text-[11px]",children:e.jsx(re,{placeholder:"Select column"})}),e.jsx(ae,{children:N.map(t=>e.jsx(oe,{value:t,className:"text-[11px]",children:t},t))})]})]},s.key))})}),l===3&&e.jsxs(y,{title:"Step 3 · Final Review",accent:"mod-expense",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3 p-1",children:[e.jsx(S,{label:"Total Records",value:i.length}),e.jsx(S,{label:"Ready to Import",value:n.length,tone:"positive"}),e.jsx(S,{label:"Validation Issues",value:p.length,tone:p.length?"warning":"neutral"})]}),n.length>0&&e.jsxs("div",{className:"mt-4 overflow-auto border border-border rounded-xl",children:[e.jsx("div",{className:"px-4 py-2 text-[12px] font-bold text-emerald-600 bg-emerald-500/10 border-b border-border",children:"Valid Records (Preview)"}),e.jsxs("table",{className:"w-full text-[11px]",children:[e.jsx("thead",{className:"bg-muted",children:e.jsx("tr",{children:["Date","Voucher","Vendor","Employee","Emp ID","Net"].map(s=>e.jsx("th",{className:"text-left px-4 py-2 font-bold text-[10px] uppercase text-muted-foreground",children:s},s))})}),e.jsx("tbody",{children:H.map((s,t)=>e.jsxs("tr",{className:"border-t border-border/50",children:[e.jsx("td",{className:"px-4 py-2",children:s.entryDate}),e.jsx("td",{className:"px-4 py-2",children:s.voucherNo}),e.jsx("td",{className:"px-4 py-2",children:s.vendor}),e.jsx("td",{className:"px-4 py-2",children:s.employeeName||"—"}),e.jsx("td",{className:"px-4 py-2 font-mono",children:s.employeeEmpCode||"—"}),e.jsx("td",{className:"px-4 py-2",children:s.net})]},t))})]})]}),p.length>0&&e.jsxs("div",{className:"mt-4 overflow-auto border border-red-500/30 rounded-xl",children:[e.jsxs("div",{className:"px-4 py-2 text-[12px] font-bold text-red-600 bg-red-500/10 border-b border-red-500/30",children:["Validation Issues (",p.length,")"]}),e.jsxs("table",{className:"w-full text-[11px]",children:[e.jsx("thead",{className:"bg-red-500/5",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-2 font-bold text-[10px] uppercase text-red-600/70",children:"Row (Excel)"}),e.jsx("th",{className:"text-left px-4 py-2 font-bold text-[10px] uppercase text-red-600/70",children:"Issue / Reason"})]})}),e.jsx("tbody",{children:p.slice(0,50).map((s,t)=>e.jsxs("tr",{className:"border-t border-red-500/20",children:[e.jsxs("td",{className:"px-4 py-2 font-bold text-red-700",children:["Row ",s.row]}),e.jsx("td",{className:"px-4 py-2 text-red-600",children:s.reason})]},t))})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between bg-card border border-border rounded-[8px] px-4 py-3",children:[e.jsxs("button",{disabled:l===1,onClick:()=>c(s=>s>
21?s-1:s),className:"h-9 px-4 rounded-lg border border-border text-[12px] font-bold inline-flex items-center gap-2 disabled:opacity-30",children:[e.jsx(M,{className:"w-4 h-4"})," Previous"]}),l<3?e.jsxs("button",{onClick:()=>c(s=>s+1),disabled:l===1&&i.length===0||l===2&&!J,className:"h-9 px-6 rounded-lg bg-primary text-primary-foreground text-[12px] font-bold inline-flex items-center gap-2 disabled:opacity-40",children:["Next Step ",e.jsx(le,{className:"w-4 h-4"})]}):e.jsxs("button",{disabled:n.length===0||E,onClick:$,className:"h-9 px-6 rounded-lg bg-emerald-600 text-white text-[12px] font-bold inline-flex items-center gap-2 disabled:opacity-40",children:[E?e.jsx(de,{className:"w-4 h-4 animate-spin"}):e.jsx(V,{className:"w-4 h-4"}),"Start background import"]})]}),e.jsx(be,{open:O,onOpenChange:P,onSuccess:()=>{h(`${d}/expenses`)}})]})}function S({label:d,value:h,tone:u}){const j=u==="positive"?"text-emerald-600 border-emerald-500/20 bg-emerald-500/5":u==="warning"?"text-amber-600 border-amber-500/20 bg-amber-500/5":"text-foreground border-border bg-muted/20";return e.jsxs("div",{className:b("rounded-xl border p-4",j),children:[e.jsx("div",{className:"text-[10px] font-black uppercase tracking-widest opacity-70",children:d}),e.jsx("div",{className:"text-2xl font-black font-data tabular-nums",children:h})]})}export{Ce as ExpenseImportWizardPage};

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.