1import{d4 as $a,ax as _a,aJ as Va,az as Wa,c$ as Ha,r as c,d7 as Ka,e6 as za,I as Qa,db as Ja,dc as Ya,dd as Xa,dY as Za,d5 as et,d6 as at,di as tt,e7 as st,dI as rt,e8 as nt,e9 as lt,d9 as dt,d_ as it,j as e,L as ot,K as xe,b5 as ct,aI as N,a as ue,a0 as pe,cS as mt,cT as xt,cU as be,cV as he,e3 as We,as as v,ea as G,S as ut,cf as ae,cg as te,ch as se,ci as re,cj as E,b8 as He,b7 as S,bC as pt,N as Ke,J as bt,cB as ht,V as ze,bD as gt,bE as ft,bH as yt,X as Qe,O as kt,cI as jt,b as Nt,cc as vt,bv as Ct,bw as wt,bx as Pt,by as St,bz as At,bB as Et,e2 as aa,aH as Tt}from"./index-CpeGhXo5.js";import{a as k}from"./currency-CACMzR5Q.js";import{P as ye,V as ke,g as Mt,l as Dt,s as Je,n as Ye,E as It,S as Rt,R as Lt,C as Ft,A as Bt,c as Ot}from"./expenseDraft-DqR0Jp71.js";import{u as Ut}from"./useFinanceApprovers-CPJ_P1-k.js";import{e as Gt,m as Xe,f as Ze}from"./financeMappers-CUv1G2pV.js";import{u as qt}from"./companySettingsMockApi-D8Uh5efq.js";import{a as ge,f as $t}from"./financeEmployeeDisplay-CYwTzdnu.js";import{L as fe}from"./lock-open-Cmtyk41m.js";const ea={Fixed:["Salaries & Wages","Rent & Utilities","Insurance","Software & Subscriptions","Retainer Fees","Debt Servicing & Interest"],Variable:["Travel & Conveyance","Marketing & Advertising","Office Supplies","Raw Materials & Supplies","Utilities & Overages","Sales Commissions"],Direct:["IT & Software","Subcontractor Fees","Client Cloud & Hosting","Project Freight & Shipping","Direct Labor Costs"],Indirect:["Maintenance & Repairs","Taxes & Compliance","Legal & Accounting","Bank Charges","General Administrative"],Operational:["Office Supplies","Pantry & Amenities","Equipment Rental","Utilities & Facility","Security & Cleaning Services"],"Capital Expenditure (CapEx)":["Hardware & Workstations","Office Infrastructure","Property & Renovation","Long-term Software Licenses"]},_t={"Salaries & Wages":["Base Payroll","Performance Bonuses","Health Insurance Stipends","Contractor Payroll","Provident Fund / ESI Match"],"Rent & Utilities":["Office Rent","Electricity Bill","Water & Sewage","High-Speed Internet","Generator Fuel"],Insurance:["Corporate Health Insurance","Keyman Insurance","Property Insurance","Cyber Liability Insurance"],"Software & Subscriptions":["SaaS Software","Dev Tools & Licenses","Design & Productivity Apps","Cloud Storage"],"Retainer Fees":["Legal Retainer","CA & Audit Retainer","PR & Branding Agency"],"Debt Servicing & Interest":["Loan Interest","Credit Line Charges","EMI Payment"],"Travel & Conveyance":["Airfare & Flights","Hotel & Lodging","Local Cab / Taxi","Client Meal Expenses","Fuel Allowance"],"Marketing & Advertising":["Google & Meta Ads","Event Sponsorships","Content & Copywriting","Print & Merchandise"],"Office Supplies":["Stationery & Paper","Printer Ink & Toners","Desks & Chairs","Breakroom Supplies"],"IT & Software":["AWS / GCP Cloud Servers","Third-Party APIs","SSL Certificates & Domains","Hardware Upgrades"],"Subcontractor Fees":["External Consultants","Freelance Developers","QA Testing Contractors"],"Maintenance & Repairs":["AC Servicing","Hardware Repairs","Building Maintenance","Furniture Repairs"],"Taxes & Compliance":["GST Payment","TDS / Income Tax","ROC Filings & Legal Stamp","Professional Tax"],"Pantry & Amenities":["Tea & Coffee Service","Snacks & Groceries","Filtered Water Supply","Team Lunch"],"Hardware & Workstations":["Laptops & MacBooks","Dual Monitors","Server Racks","Uninterruptible Power Supply (UPS)"],"Office Infrastructure":["Interior Fit-outs","CCTV & Biometric Access","Networking Switch & Wiring"]},Vt=()=>({date:aa(!0),expenseType:"",category:"",subCategory:"",referenceNo:"",recurring:!1,recurringFrequency:"Monthly",recurringEndDate:"",vendorName:"",vendorType:ke[0],vendorGstPan:"",vendorContact:"",department:"",team:"",employee:"",approver:"",company:"Tekki Web Solutions Pvt. Ltd.",companyId:"comp-primary-1",project:"",costCenter:"",gross:0,currency:"INR",taxApplicable:!0,taxRate:18,paymentMode:ye[0],paymentStatus:"Pending",paymentDate:"",bankAccount:"",amountPaid:0,paidPercentage:0,balanceDue:0,balanceDueDate:"",advanceReference:"",clearsLiability:!1,linkedLiability:"",emiNo:"",description:"",tags:""});function Zt(){const q=$a(),$=_a(),[_]=Va(),h=Wa().id||_.get("editId")||_.get("id"),{activeCurrency:y}=Ha(),[t,j]=c.useState(Vt),[je,T]=c.useState("classification"),[ta,sa]=c.useState(null),[x,A]=c.useState({}),[ra,na]=c.useState(!1),[M,Ne]=c.useState(!1),[ve,Ce]=c.useState(!1),[V,we]=c.useState(""),W=c.useRef(null),Pe=c.useRef(null),la=async a=>{if(!a)return;const s=a.name.toLowerCase(),r=s.includes(".")?s.slice(s.lastIndexOf(".")):"";if([".exe",".bat",".cmd",".sh",".js",".vbs",".msi",".scr",".com",".ps1",".dll",".jar",".py",".php"].includes(r)){N.error(`Security Alert: Executable (${r}) files are strictly prohibited for security reasons.`);return}if(![".pdf",".png",".jpg",".jpeg",".webp"].includes(r)){N.error(`Invalid file format (${r}). Allowed formats: PDF, PNG, JPG, JPEG, WEBP.`);return}if(a.size>
125*1024*1024){N.error("File size exceeds the 25MB limit.");return}try{Ce(!0);const n=new FormData;n.append("file",a);const o=(await Tt.post("/storage/upload/single?folder=expense-bills",n,{headers:{"Content-Type":"multipart/form-data"}})).data,g=o.url||o.path||"",w=o.originalName||a.name;j(U=>({...U,attachmentUrl:g,attachmentName:w})),N.success("Bill attachment uploaded successfully!")}catch(n){N.error(n?.response?.data?.message||n?.message||"Failed to upload bill attachment")}finally{Ce(!1)}},{data:Se}=Ka({limit:2e3}),{data:C}=za(h||"",{skip:!h}),H=Qa(a=>a.auth?.user),{data:Ae}=Ja(),D=!!(Ae?.role==="SUPER_ADMIN"||Ae?.role==="FINANCE_HEAD"||H?.role==="Super Admin"||H?.email?.toLowerCase().includes("cfo")||H?.name?.toLowerCase().includes("pawandeep")||H?.fullName?.toLowerCase().includes("pawandeep")),I=Ut(),[da,{isLoading:Ee}]=Ya(),[ia,{isLoading:Te}]=Xa(),[oa,R]=c.useState(!1),[K,ca]=c.useState(""),ma=async()=>{if(h)try{await da({id:h,isLocked:!1}).unwrap(),N.success("Entry unlocked by CFO Pawandeep Kaur. You can now edit and save changes.")}catch(a){N.error(a?.data?.message||"Failed to unlock entry")}},xa=async()=>{if(h){if(!K.trim()){N.error("Please provide a reason for the unlock request.");return}try{await ia({id:h,reason:K.trim()}).unwrap(),N.success("Unlock request submitted to CFO Pawandeep Kaur."),R(!1)}catch(a){N.error(a?.data?.message||"Failed to submit unlock request")}}},{data:Me=[]}=Za(),{data:De=[]}=qt(),{data:L=[]}=et(),{data:F=[]}=at(),{data:Ie}=tt({limit:500,status:"Active"}),{data:z}=st({limit:500},{refetchOnMountOrArgChange:!0}),Re=c.useMemo(()=>(z?.items||(Array.isArray(z)?z:[])).map(Gt),[z]),Le=c.useMemo(()=>{const a=(t.company||"Tekki Web Solutions Pvt. Ltd.").trim().toLowerCase();return Re.filter(s=>{const r=(s.company||"").trim().toLowerCase();return!r||r===a||(a==="tekki web solutions pvt. ltd."||a==="tekki web solutions"||a==="tws")&&(r==="tekki web solutions pvt. ltd."||r==="tekki web solutions"||r==="tws")?!0:r.includes(a)||a.includes(r)})},[Re,t.company]),B=c.useMemo(()=>{const a=Le.map(s=>{const r=s.accountNo?s.accountNo.slice(-4):"",l=r?`${s.bank} â¢â¢ ${r} (${s.type||"Current"})`:`${s.bank} (${s.type||"Current"})`;return{value:l,label:l,sub:`${s.company||"Tekki Web Solutions Pvt. Ltd."} · Acc: ${s.accountNo?`â¢â¢â¢â¢ ${s.accountNo.slice(-4)}`:"â"}`}});return t.bankAccount&&!a.some(s=>s.value===t.bankAccount)&&(["4521","8830","1209","7766"].some(l=>t.bankAccount.includes(l))||a.unshift({value:t.bankAccount,label:t.bankAccount,sub:t.company||"Tekki Web Solutions Pvt. Ltd."})),a},[Le,t.bankAccount,t.company]);c.useEffect(()=>{if(B.length>0){const a=["4521","8830","1209","7766"];(!t.bankAccount||a.some(r=>t.bankAccount.includes(r))||!B.some(r=>r.value===t.bankAccount))&&j(r=>({...r,bankAccount:B[0].value}))}},[B,t.bankAccount]);const{isFinanceHead:ua,isExecutiveBoard:pa}=rt(),Fe=D||ua||pa,Q=c.useMemo(()=>Mt(t.bankAccount),[t.bankAccount]),ba=c.useMemo(()=>t.paymentMode==="Credit Card"||t.paymentMode==="Debit Card"||!!t.bankAccount&&Q.length>0,[t.paymentMode,t.bankAccount,Q.length]),{data:Be}=nt({status:"won",limit:500,offset:0,sortBy:"title",sortOrder:"asc"}),[ha]=lt(),[ga]=dt(),J=c.useMemo(()=>(Se?.items??[]).map(Xe),[Se]),Y=c.useMemo(()=>Ie?.items??[],[Ie]);c.useMemo(()=>Be?.items??[],[Be]);const[le,fa]=c.useState([]);c.useEffect(()=>{let a=!0;return it.getProjects().then(s=>{a&&Array.isArray(s)&&fa(s.map(r=>({id:r.id,name:r.name,projectCode:r.projectCode})))}).catch(s=>{console.warn("Could not load PMS projects for expenses:",s)}),()=>{a=!1}},[]);const X=c.useMemo(()=>{const a=[],s=new Set;return(Me||[]).forEach(r=>{r.name&&!s.has(r.name)&&(a.push({value:r.id,label:r.name,sub:r.code||"ENT-001"}),s.add(r.name))}),(De||[]).forEach(r=>{r.name&&!s.has(r.name)&&(a.push({value:r.id,label:r.name,sub:r.code||r.isPrimary?"ENT-001":"SUB-001"}),s.add(r.name))}),s.has("Tekki Web Solutions Pvt. Ltd.")||a.unshift({value:"comp-primary-1",label:"Tekki Web Solutions Pvt. Ltd.",sub:"ENT-001"}),a.sort((r,l)=>r.label.localeCompare(l.label))},[Me,De]),ya=c.useMemo(()=>{let a=L;
1const s=(t.company||"").toLowerCase().trim(),r=t.companyId;(s||r)&&(a=a.filter(d=>{const n=d.companyId||d.legalEntityId||d.company_id,i=(d.companyName||d.company||d.company_name||"").toLowerCase().trim();return r&&n&&n===r||s&&i&&(i===s||s.includes(i)||i.includes(s))?!0:n||i?!1:!!(s.includes("tekki web solutions")||r==="comp-primary-1")}));const l=new Map;for(const d of a)d.name&&!l.has(d.name.trim())&&l.set(d.name.trim(),{value:d.id||d.name,label:d.name.trim()});return Array.from(l.values()).sort((d,n)=>d.label.localeCompare(n.label))},[L,t.companyId,t.company]),de=c.useMemo(()=>{if(!t.departmentId&&!t.department)return[];let a=F;const s=t.departmentId,r=(t.department||"").toLowerCase().trim();return a=a.filter(l=>!!(s&&l.departmentId===s||r&&(l.departmentName?.toLowerCase().trim()===r||l.department?.name?.toLowerCase().trim()===r))),a},[t.departmentId,t.department,F]),ka=c.useMemo(()=>de.map(a=>({value:a.id||a.name,label:a.name})),[de]),ie=c.useMemo(()=>{let a=Y;const s=t.departmentId,r=(t.department||"").toLowerCase().trim(),l=t.teamId,d=(t.team||"").toLowerCase().trim();return s||r?a=a.filter(n=>{let i=!1;if(s&&(n.departments?.some(o=>o.departmentId===s)||n.departmentId===s)&&(i=!0),r&&(n.departmentName?.toLowerCase().trim()===r||n.department?.toLowerCase().trim()===r)&&(i=!0),!i)return!1;if(l||d){let o=!1;return l&&(n.teams?.some(g=>g.teamId===l)||n.teamId===l)&&(o=!0),d&&(n.teamName?.toLowerCase().trim()===d||n.team?.toLowerCase().trim()===d)&&(o=!0),o}return!0}):(l||d)&&(a=a.filter(n=>{let i=!1;return l&&(n.teams?.some(o=>o.teamId===l)||n.teamId===l)&&(i=!0),d&&(n.teamName?.toLowerCase().trim()===d||n.team?.toLowerCase().trim()===d)&&(i=!0),i})),a.map(n=>({id:n.id,name:$t(n),plainName:ge(n)}))},[t.departmentId,t.department,t.teamId,t.team,Y]),ja=c.useMemo(()=>ie.map(a=>({value:a.id,label:a.name})),[ie]),Oe=c.useMemo(()=>{const a=[],s=new Set,r=(l,d)=>{const n=l.projectCode||l.project_code||l.upperId||l.upper_id;return n&&!/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(n)?n.startsWith("#")?n:`#${n}`:`#PRJ-${1001+d}`};return le.length>0&&le.forEach((l,d)=>{if(l.name&&!s.has(l.name.trim().toLowerCase())){const n=r(l,d);a.push({value:l.id||l.name,label:l.name,sub:`PMS Code: ${n}`,name:l.name}),s.add(l.name.trim().toLowerCase())}}),s.has("visionx")||a.unshift({value:"pms-visionx",label:"VisionX",sub:"PMS Code: #PRJ-1001",name:"VisionX"}),a.sort((l,d)=>l.name.localeCompare(d.name))},[le]);c.useMemo(()=>Array.from(new Set(J.map(s=>s.vendor).filter(Boolean))).map(s=>({value:s,label:s})),[J]);const O=c.useRef(null),Z=c.useRef(!1);c.useEffect(()=>{if(h){if(O.current===h&&Z.current)return;const a=C?Xe(C):J.find(s=>s.id===h);if(a&&(O.current!==h||C&&!Z.current)){O.current=h,C&&(Z.current=!0);const s=a,r=s.gross||0,l=s.tax||0,d=s.net||r+l,n=r>0?Math.round(l/r*100):18,i=L.find(f=>f.id===s.departmentId||f.name.toLowerCase()===(s.department||"").toLowerCase()),o=i?.id||s.departmentId||"",g=i?.name||s.department||"",w=F.find(f=>f.id===s.teamId||f.name.toLowerCase()===(s.team||"").toLowerCase()),U=w?.id||s.teamId||"",Ba=w?.name||s.team||"",$e=X.find(f=>f.value===s.companyId||f.label.toLowerCase()===(s.company||"").toLowerCase()),Oa=$e?.value||s.companyId||"comp-primary-1",Ua=$e?.label||s.company||"Tekki Web Solutions Pvt. Ltd.",P=Y.find(f=>f.id===s.employeeId||ge(f).toLowerCase()===(s.employee||"").toLowerCase()),Ga=P?.id||s.employeeId||"",qa=P?ge(P):s.employee||"";let ce=o,_e=g;if(!ce&&P){const f=P.departments?.[0]||P.department;f&&(ce=f.departmentId||f.id||"",_e=f.departmentName||f.name||"")}let me=U,Ve=Ba;if(!me&&P){const f=P.teams?.[0]||P.team;f&&(me=f.teamId||f.id||"",Ve=f.teamName||f.name||"")}j({date:s.date||new Date().toISOString().slice(0,10),expenseType:s.expenseType||"Operational",category:s.category||"General Expense",subCategory:s.subCategory||"",referenceNo:s.voucherNo||"",recurring:!1,recurringFrequency:"Monthly",recurringEndDate:"",vendorName:s.vendor||"",vendorType:ke[0],vendorGstPan:"",vendorContact:"",department:_e,departmentId:ce,team:Ve,teamId:me,employee:qa,employeeId:Ga,approver:s.approver||"",company:Ua,companyId:Oa,project:s.project||"",projectId:s.projectId||"",costCenter:"CC-001",gross:r,currency:"INR",taxApplicable:!0,taxRate:n,paymentMode:s.paymentMethod||ye[0],paymentStatus:s.status||"Pending",paymentDate:s.date||"",bankAccount:s.bankAccount||s.bank_account||"",amountPaid:s.amountPaid!==void 0?Number(s.amountPaid):s.status==="Approved"||s.status==="Reimbursed"||s.status==="Paid"?d:0,paidPercentage:s.paidPercentage!==void 0?Number(s.paidPercentage):s.status==="Paid"?100:0,balanceDue:s.balanceDue!==void 0?Number(s.balanceDue):s.status==="Paid"?0:d,balanceDueDate:s.balanceDueDate||"",advanceReference:s.advanceReference||"",clearsLiability:!1,linkedLiability:"",emiNo:"",description:s.description||"",tags:""})}}else if(O.current!==null){O.current=null,Z.current=!1;const a=Dt();a&&j(a)}},[h,C,J,L,F,X,Y]),c.useEffect(()=>{if(!h){const a=setTimeout(()=>{Je(t),Pe.current=`Draft saved ${new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`,sa(Pe.current)},1500);return()=>clearTimeout(a)}},[t,h]),c.useEffect(()=>{if(!h&&!t.referenceNo){const a=Ye();j(s=>({...s,referenceNo:a}))}},[h]),c.useEffect(()=>{!t.approver&&I.length>0&&j(a=>a.approver?a:{...a,approver:I[0].value})},[I,t.approver]);const u=(a,s)=>{j(r=>({...r,[a]:s})),x[a]&&A(r=>({...r,[a]:""}))},p=c.useMemo(()=>{const a=Number(t.gross)||0,s=t.taxApplicable&&Number(t.taxRate)||0,r=Math.round(a*s/100),l=a+r,d=Number(t.amountPaid)||0,n=Math.max(0,l-d
1),i=l>0?Math.min(100,Math.round(d/l*100*100)/100):0,o=l>0?Math.round(r*d/l*100)/100:0,g=Math.max(0,Math.round((d-o)*100)/100),w=Math.max(0,Math.round((r-o)*100)/100),U=Math.max(0,Math.round((a-g)*100)/100);return{gross:a,tax:r,net:l,paid:d,outstanding:n,paidPct:i,proportionalTaxPaid:o,proportionalBasePaid:g,balanceTaxDue:w,balanceBaseDue:U}},[t.gross,t.taxApplicable,t.taxRate,t.amountPaid]),Na=a=>{j(s=>{const r=Number(s.gross)||0,l=s.taxApplicable&&Number(s.taxRate)||0,d=Math.round(r*l/100),n=r+d;if(a==="Paid")return{...s,paymentStatus:a,amountPaid:n,paidPercentage:100,balanceDue:0,paymentDate:s.paymentDate||aa(!0)};if(a==="Pending")return{...s,paymentStatus:a,amountPaid:0,paidPercentage:0,balanceDue:n};if(a==="Partial"){const i=Number(s.amountPaid)||0,o=i>0&&i<n?i:Math.round(n*.5*100)/100,g=n>0?Math.round(o/n*100*100)/100:50,w=Math.max(0,Math.round((n-o)*100)/100);return{...s,paymentStatus:a,amountPaid:o,paidPercentage:g,balanceDue:w}}if(a==="Advance"){const i=Number(s.amountPaid)||0,o=i>0&&i<n?i:Math.round(n*.3*100)/100,g=n>0?Math.round(o/n*100*100)/100:30,w=Math.max(0,Math.round((n-o)*100)/100);return{...s,paymentStatus:a,amountPaid:o,paidPercentage:g,balanceDue:w}}return{...s,paymentStatus:a}}),x.paymentStatus&&A(s=>({...s,paymentStatus:""}))},va=a=>{if(a===""||/^\d*\.?\d*$/.test(a)){const s=a===""?0:Number(a);if(s>100)return;const r=p.net,l=Math.round(r*s/100*100)/100,d=Math.max(0,Math.round((r-l)*100)/100);j(n=>({...n,paidPercentage:a===""?0:a,amountPaid:l,balanceDue:d}))}},Ca=a=>{if(a===""||/^\d*\.?\d*$/.test(a)){const s=a===""?0:Number(a),r=p.net,l=r>0?Math.min(100,Math.round(s/r*100*100)/100):0,d=Math.max(0,Math.round((r-s)*100)/100);j(n=>({...n,amountPaid:a===""?0:a,paidPercentage:l,balanceDue:d}))}},wa=a=>{const s=p.net,r=Math.round(s*a/100*100)/100,l=Math.max(0,Math.round((s-r)*100)/100);j(d=>({...d,paidPercentage:a,amountPaid:r,balanceDue:l}))},Pa=a=>{if(a===""||/^\d*\.?\d*$/.test(a)){const s=a===""?0:Number(a);j(r=>{const l=r.taxApplicable&&Number(r.taxRate)||0,d=Math.round(s*l/100),n=s+d;let i=Number(r.amountPaid)||0,o=Number(r.paidPercentage)||0,g=Number(r.balanceDue)||0;return r.paymentStatus==="Paid"?(i=n,o=100,g=0):r.paymentStatus==="Pending"?(i=0,o=0,g=n):(r.paymentStatus==="Partial"||r.paymentStatus==="Advance")&&(o>0&&(i=Math.round(n*o/100*100)/100),g=Math.max(0,Math.round((n-i)*100)/100)),{...r,gross:a===""?0:a,amountPaid:i,paidPercentage:o,balanceDue:g}}),x.gross&&A(r=>({...r,gross:""}))}},Ue=a=>{if(a===""||/^\d*\.?\d*$/.test(a)){const s=a===""?0:Number(a);j(r=>{const l=Number(r.gross)||0,d=r.taxApplicable?Math.round(l*s/100):0,n=l+d;let i=Number(r.amountPaid)||0,o=Number(r.paidPercentage)||0,g=Number(r.balanceDue)||0;return r.paymentStatus==="Paid"?(i=n,o=100,g=0):r.paymentStatus==="Pending"?(i=0,o=0,g=n):(r.paymentStatus==="Partial"||r.paymentStatus==="Advance")&&(o>0&&(i=Math.round(n*o/100*100)/100),g=Math.max(0,Math.round((n-i)*100)/100)),{...r,taxRate:a===""?0:a,amountPaid:i,paidPercentage:o,balanceDue:g}}),x.taxRate&&A(r=>({...r,taxRate:""}))}},Sa=a=>{j(s=>{const r=Number(s.gross)||0,l=a?Math.round(r*(Number(s.taxRate)||0)/100):0,d=r+l;let n=Number(s.amountPaid)||0,i=Number(s.paidPercentage)||0,o=Number(s.balanceDue)||0;return s.paymentStatus==="Paid"?(n=d,i=100,o=0):s.paymentStatus==="Pending"?(n=0,i=0,o=d):(s.paymentStatus==="Partial"||s.paymentStatus==="Advance")&&(i>0&&(n=Math.round(d*i/100*100)/100),o=Math.max(0,Math.round((d-n)*100)/100)),{...s,taxApplicable:a,amountPaid:n,paidPercentage:i,balanceDue:o}})},Aa=c.useMemo(()=>t.expenseType&&ea[t.expenseType]?ea[t.expenseType]:It,[t.expenseType]),Ea=c.useMemo(()=>t.expenseType?`finance_categories_${t.expenseType.replace(/[^a-zA-Z0-9]/g,"_")}`:"finance_categories_all",[t.expenseType]),Ta=c.useMemo(()=>t.category?_t[t.category]||Rt[t.category]||[]:[],[t.category]),Ma=c.useMemo(()=>t.category?`finance_subcategories_${t.category.replace(/[^a-zA-Z0-9]/g,"_")}`:"finance_subcategories_all",[t.category]),Ge=()=>{const a={};return t.date||(a.date="Expense date is required"),t.expenseType||(a.expenseType="Expense type is required"),t.category||(a.category="Category is required"),!t.companyId&&!t.company&&(a.company="Company selection is required"),t.recurring&&!t.re
1curringEndDate&&(a.recurringEndDate="End date is required"),A(s=>({...s,...a})),Object.keys(a).length>0?(N.error("Please fill all required fields in Tab 1 before proceeding"),!1):!0},Da=a=>{a==="amount"&&je==="classification"&&!Ge()||T(a)},Ia=()=>{Ge()&&T("amount")},Ra=()=>{const a={};return t.date||(a.date="Expense date is required"),t.expenseType||(a.expenseType="Expense type is required"),t.category||(a.category="Category is required"),!t.companyId&&!t.company&&(a.company="Company selection is required"),t.recurring&&!t.recurringEndDate&&(a.recurringEndDate="End date is required"),(!t.gross||Number(t.gross)<=0)&&(a.gross="Enter a valid amount (> 0)"),t.paymentMode||(a.paymentMode="Payment mode is required"),t.paymentStatus||(a.paymentStatus="Payment status is required"),t.paymentStatus==="Paid"&&t.paymentMode!=="Cash"&&!t.bankAccount&&(a.bankAccount="Please select the Bank Account disbursed from"),t.taxApplicable&&(t.taxRate===void 0||t.taxRate<0)&&(a.taxRate="Enter a valid tax rate"),t.amountPaid<0&&(a.amountPaid="Amount paid cannot be negative"),t.clearsLiability&&!t.linkedLiability&&(a.linkedLiability="Linked liability is required"),A(a),(a.date||a.expenseType||a.category||a.company||a.team||a.recurringEndDate)&&T("classification"),Object.keys(a).length===0},La=async a=>{if(a.preventDefault(),na(!0),!Ra()){N.error("Please fix errors before submitting");return}if(C?.isLocked&&!D){N.error("This expense entry has been finalized and locked by CFO Pawandeep Kaur. It cannot be modified without CFO unlock approval."),R(!0);return}Ne(!0);const s={...t,approvalStatus:Fe?"Approved":"Pending_CFO_Approval"};try{h?(await ga({id:h,body:Ze(s)}).unwrap(),N.success(`Expense ${t.referenceNo} updated successfully!`)):(await ha(Ze(s)).unwrap(),N.success(Fe?`Expense ${t.referenceNo} approved & posted to ledger!`:`Expense ${t.referenceNo} submitted for CFO Pawandeep Kaur's approval.`),Ot()),$(`${q}/expenses`)}catch(r){N.error(r?.data?.message||r?.message||"Failed to save expense entry")}finally{Ne(!1)}},ee=c.useMemo(()=>t.tags.split(",").map(a=>a.trim()).filter(Boolean),[t.tags]),qe=()=>{if(!V.trim())return;const a=ee;if(!a.includes(V.trim())){const s=[...a,V.trim()].join(", ");u("tags",s)}we("")},Fa=a=>{const s=ee.filter(r=>r!==a).join(", ");u("tags",s)},oe=(a,s)=>{W.current&&(document.execCommand(a,!1,s),u("description",W.current.innerHTML))},b="h-9 w-full rounded-md border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 px-3 text-xs focus:outline-none focus:ring-1 focus:ring-primary shadow-2xs text-slate-800 dark:text-slate-100 placeholder:text-slate-400";return e.jsxs("form",{onSubmit:La,className:"w-full flex-1 flex flex-col font-sans bg-white dark:bg-slate-900",children:[e.jsxs("div",{className:"flex items-center justify-between py-3 px-6 border-b border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"w-1.5 h-6 rounded-full bg-emerald-500 shrink-0"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-[16px] font-bold text-slate-800 dark:text-slate-100 leading-tight",children:h?`Edit Expense Entry: ${t.referenceNo}`:"New Expense Entry"}),e.jsx("div",{className:"text-[11px] font-medium text-slate-500 dark:text-slate-400 mt-0.5",children:ta||"Draft auto-saved every 30s ⢠HRMS Synchronized"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(ot,{to:`${q}/expenses`,className:"h-8 px-3 rounded-lg border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 text-xs font-medium text-slate-700 dark:text-slate-200 inline-flex items-center gap-1.5 transition-colors shadow-2xs",children:[e.jsx(xe,{className:"w-3.5 h-3.5"})," Back to Expenses"]}),e.jsxs("button",{type:"button",disabled:C?.isLocked&&!D,onClick:()=>{Je(t),N.success("Draft saved")},className:"h-8 px-3 rounded-lg border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 text-xs font-medium text-slate-700 dark:text-slate-200 inline-flex items-center gap-1.5 transition-colors shadow-2xs disabled:opacity-50",children:[e.jsx(ct,{className:"w-3.5 h-3.5 text-slate-500"})," Save Draft"]}),C?.isLocked&&!D?e.jsxs("button",{type:"button",onClick:()=>
1R(!0),className:"h-8 px-4 rounded-lg bg-amber-600 hover:bg-amber-700 text-white text-xs font-semibold inline-flex items-center gap-1.5 shadow-2xs transition-colors cursor-pointer",children:[e.jsx(ue,{className:"w-3.5 h-3.5"})," Request CFO Unlock"]}):e.jsxs("button",{type:"submit",disabled:M,className:"h-8 px-4 rounded-lg bg-blue-600 hover:bg-blue-700 text-white text-xs font-semibold inline-flex items-center gap-1.5 shadow-2xs transition-colors disabled:opacity-50",children:[e.jsx(pe,{className:"w-3.5 h-3.5"})," ",M?"Saving...":h?"Update Entry":"Submit Expense"]})]})]}),C?.isLocked&&e.jsxs("div",{className:"mx-6 mt-3 p-3 rounded-lg border border-amber-300 bg-amber-50/90 dark:bg-amber-950/40 dark:border-amber-800 text-amber-900 dark:text-amber-200 flex items-center justify-between gap-3 shadow-2xs",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-7 h-7 rounded-md bg-amber-100 dark:bg-amber-900/60 border border-amber-300 dark:border-amber-700 flex items-center justify-center shrink-0",children:e.jsx(ue,{className:"w-3.5 h-3.5 text-amber-700 dark:text-amber-300"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-xs font-bold flex items-center gap-2",children:[e.jsxs("span",{children:["Final Locked Entry by CFO ",C.lockedByName||"Pawandeep Kaur"]}),e.jsx("span",{className:"text-[10px] font-semibold px-1.5 py-0.2 rounded bg-amber-200/70 dark:bg-amber-900/70 text-amber-800 dark:text-amber-200",children:D?"CFO Authority Active":"Read Only"})]}),e.jsxs("p",{className:"text-[11px] text-amber-700 dark:text-amber-300 mt-0.5",children:["This expense entry has been finalized. It cannot be modified or deleted without CFO unlock approval.",C.lockReason?` Note: "${C.lockReason}"`:""]})]})]}),e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:D?e.jsxs("button",{type:"button",disabled:Ee,onClick:ma,className:"h-7 px-3 rounded-md bg-amber-600 hover:bg-amber-700 text-white text-xs font-semibold shadow-2xs transition-colors inline-flex items-center gap-1.5 cursor-pointer",children:[e.jsx(fe,{className:"w-3 h-3"})," ",Ee?"Unlocking...":"Unlock Entry"]}):e.jsxs("button",{type:"button",onClick:()=>R(!0),className:"h-7 px-3 rounded-md bg-white dark:bg-slate-800 border border-amber-300 dark:border-amber-700 text-amber-800 dark:text-amber-200 text-xs font-semibold hover:bg-amber-100 dark:hover:bg-slate-700 transition-colors shadow-2xs inline-flex items-center gap-1.5 cursor-pointer",children:[e.jsx(fe,{className:"w-3 h-3"})," Request CFO Unlock"]})})]}),e.jsxs(mt,{value:je,onValueChange:Da,className:"w-full flex-1 flex flex-col space-y-0",children:[e.jsx("div",{className:"border-b border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 px-6",children:e.jsxs(xt,{className:"w-full justify-start h-auto bg-transparent p-0 border-none rounded-none gap-8 -mb-px",children:[e.jsx(be,{value:"classification",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-blue-600 dark:data-[state=active]:border-blue-400 data-[state=active]:bg-transparent data-[state=active]:text-blue-600 dark:data-[state=active]:text-blue-400 text-slate-600 dark:text-slate-400 hover:text-slate-900 dark:hover:text-slate-200 text-xs font-semibold px-0 py-3 shadow-none transition-all",children:"1. Classification & HRMS Allocation"}),e.jsx(be,{value:"amount",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-blue-600 dark:data-[state=active]:border-blue-400 data-[state=active]:bg-transparent data-[state=active]:text-blue-600 dark:data-[state=active]:text-blue-400 text-slate-600 dark:text-slate-400 hover:text-slate-900 dark:hover:text-slate-200 text-xs font-semibold px-0 py-3 shadow-none transition-all",children:"2. Amount, Payment & Remarks"}),e.jsx(be,{value:"review",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-blue-600 dark:data-[state=active]:border-blue-400 data-[state=active]:bg-transparent data-[state=active]:text-blue-600 dark:data-[state=active]:text-blue-400 text-slate-600 dark:text-slate-400 hover:text-slate-900 dark:hover:text-slate-200 text-xs font-semibold px-0 py-3 shadow-none transition-all",children:"3. Audit Trail & Executive Approvals"})]})}),e.jsxs("div",{className:"w-full flex-1 grid grid-cols-1 lg:grid-cols-12 gap-0 bg-white dark:bg-slate-900",children:[e.jsxs("div",{className:"lg:col-span-9 p-6 border-b lg:border-b-0 lg:border-r border-slate-200 dark:border-slate-800 space-y-6 flex flex-col justify-between",children:[e.jsxs(he,{value:"classification",className:"space-y-6 mt-0",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-1.5 border-b border-slate-100 dar
1k:border-slate-800/80",children:[e.jsx("span",{className:"w-1.5 h-3.5 rounded-full bg-blue-600 dark:bg-blue-400 shrink-0"}),e.jsx("h3",{className:"text-xs font-bold text-slate-800 dark:text-slate-200 uppercase tracking-wider",children:"Expense Classification"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3.5 pt-1",children:[e.jsx(m,{label:"Expense Date & Time",required:!0,error:x.date,hint:"PMS-style selector",children:e.jsx(We,{value:t.date,onChange:a=>u("date",a),showTime:!0,placeholder:"Select Date & Time",className:v("h-9 text-xs font-semibold",x.date&&"border-red-500 ring-1 ring-red-500")})}),e.jsx(m,{label:"Expense Type",required:!0,error:x.expenseType,children:e.jsx(G,{value:t.expenseType,onChange:a=>u("expenseType",a),defaultOptions:["Fixed","Variable","Direct","Indirect","Operational","Capital Expenditure (CapEx)"],storageKey:"finance_expense_types",placeholder:"Select or add Expense Type...",searchPlaceholder:"Search or add type...",className:v(b,x.expenseType&&"border-red-500 focus:ring-red-500 ring-1 ring-red-500")})}),e.jsx(m,{label:"Reference Number",hint:"Auto-generated",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("input",{value:t.referenceNo,onChange:a=>u("referenceNo",a.target.value),className:b}),e.jsx("button",{type:"button",onClick:()=>u("referenceNo",Ye()),className:"h-9 px-2.5 rounded-md border border-slate-200 dark:border-slate-800 bg-slate-50 dark:bg-slate-800 hover:bg-slate-100 text-xs inline-flex items-center gap-1 shrink-0",children:e.jsx(ut,{className:"w-3.5 h-3.5 text-blue-600"})})]})}),e.jsx(m,{label:"Expense Category",required:!0,error:x.category,children:e.jsx(G,{value:t.category,onChange:a=>{u("category",a),u("subCategory","")},defaultOptions:Aa,storageKey:Ea,placeholder:t.expenseType?`Select or add Category for ${t.expenseType}...`:"Select or add Category...",searchPlaceholder:"Search or add category...",className:v(b,x.category&&"border-red-500 focus:ring-red-500 ring-1 ring-red-500")})}),e.jsx(m,{label:"Sub-Category",hint:t.category?"":"Pick category first",children:e.jsx(G,{value:t.subCategory,onChange:a=>u("subCategory",a),defaultOptions:Ta,storageKey:Ma,placeholder:t.category?`Select or add Sub-Category for ${t.category}...`:"Pick category first...",searchPlaceholder:"Search or add sub-category...",disabled:!t.category,className:b})}),e.jsx(m,{label:"Recurring Expense?",children:e.jsxs("label",{className:"h-9 inline-flex items-center gap-2 text-xs font-medium text-slate-700 dark:text-slate-300",children:[e.jsx("input",{type:"checkbox",checked:t.recurring,onChange:a=>u("recurring",a.target.checked),className:"rounded border-slate-300 text-blue-600 focus:ring-blue-500"}),t.recurring?"Yes (Recurring)":"No (One-time)"]})}),t.recurring&&e.jsxs(e.Fragment,{children:[e.jsx(m,{label:"Recurring Frequency",required:!0,children:e.jsxs(ae,{value:t.recurringFrequency,onValueChange:a=>u("recurringFrequency",a),children:[e.jsx(te,{className:b,children:e.jsx(se,{placeholder:"Select Frequency"})}),e.jsx(re,{children:Lt.map(a=>e.jsx(E,{value:a,children:a},a))})]})}),e.jsx(m,{label:"Recurring End Date",error:x.recurringEndDate,children:e.jsx(He,{value:t.recurringEndDate,onChange:a=>u("recurringEndDate",a),className:"h-9 text-xs",hasError:!!x.recurringEndDate})})]})]})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-1.5 border-b border-slate-100 dark:border-slate-800/80",children:[e.jsx("span",{className:"w-1.5 h-3.5 rounded-full bg-emerald-600 dark:bg-emerald-400 shrink-0"}),e.jsx("h3",{className:"text-xs font-bold text-slate-800 dark:text-slate-200 uppercase tracking-wider",children:"Vendor / Payee Details"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3.5 pt-1",children:[e.jsx(m,{label:"Vendor / Payee Name",error:x.vendorName,children:e.jsx(G,{value:t.vendorName,onChange:a=>u("vendorName",a),defaultOptions:["Pawan","Sarbjit","Jatinder Kumar","harsh","AWS Cloud Services","Google Cloud","Microsoft Azure","Stationery Vendor","Office Rent Owner"],storageKey:"finance_vendor_payees",placeholder:"Search or add vend
1or...",searchPlaceholder:"Search or add vendor...",className:v(b,x.vendorName&&"border-red-500 focus:ring-red-500 ring-1 ring-red-500")})}),e.jsx(m,{label:"Vendor Type",children:e.jsx(G,{value:t.vendorType,onChange:a=>u("vendorType",a),defaultOptions:ke,storageKey:"finance_vendor_types",placeholder:"Select or add Vendor Type...",searchPlaceholder:"Search or add type...",className:b})}),e.jsx(m,{label:"Vendor GST / PAN",children:e.jsx("input",{value:t.vendorGstPan,onChange:a=>u("vendorGstPan",a.target.value),placeholder:"22AAAAA0000A1Z5",className:b})}),e.jsx(m,{label:"Vendor Contact",children:e.jsx("input",{value:t.vendorContact,onChange:a=>u("vendorContact",a.target.value),placeholder:"+91 98xxxxxxxx",className:b})})]})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-1.5 border-b border-slate-100 dark:border-slate-800/80",children:[e.jsx("span",{className:"w-1.5 h-3.5 rounded-full bg-purple-600 dark:bg-purple-400 shrink-0"}),e.jsx("h3",{className:"text-xs font-bold text-slate-800 dark:text-slate-200 uppercase tracking-wider",children:"Department & HRMS Allocation"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3.5 pt-1",children:[e.jsx(m,{label:"Company",required:!0,error:x.company,children:e.jsx(S,{options:X,value:t.companyId||"comp-primary-1",onChange:a=>{const s=X.find(r=>r.value===a)||{label:"Tekki Web Solutions Pvt. Ltd."};j(r=>({...r,company:s.label,companyId:a,department:"",departmentId:"",team:"",teamId:"",employee:"",employeeId:"",bankAccount:"",connectedCardId:"",connectedCardName:""}))},placeholder:"Select Company...",allowCustom:!1,triggerClassName:v(b,x.company&&"border-red-500 focus:ring-red-500 ring-1 ring-red-500")})}),e.jsx(m,{label:"Department",error:x.department,children:e.jsx(S,{options:ya,value:t.departmentId||"",onChange:a=>{const s=L.find(l=>l.id===a),r=s?F.find(l=>l.departmentId===s.id):void 0;j(l=>({...l,department:s?.name??"",departmentId:s?.id,team:r?.name??"",teamId:r?.id??"",employee:"",employeeId:""}))},placeholder:"Select Department...",allowCustom:!1,triggerClassName:b})}),e.jsx(m,{label:"Team",error:x.team,children:e.jsx(S,{options:ka,value:t.teamId||"",onChange:a=>{const s=de.find(r=>r.id===a);j(r=>({...r,team:s?.name??"",teamId:s?.id??"",employee:"",employeeId:""}))},placeholder:"Select Team...",allowCustom:!1,triggerClassName:b})}),e.jsx(m,{label:"Allocated To (Employee)",children:e.jsx(S,{options:ja,value:t.employeeId||"",onChange:a=>{const s=ie.find(r=>r.id===a);j(r=>({...r,employee:s?.plainName??"",employeeId:s?.id??""}))},placeholder:"Select Employee...",allowCustom:!1,triggerClassName:b})}),e.jsx(m,{label:"Project Name",children:e.jsx(S,{options:Oe,value:t.projectId||t.project||"",onChange:a=>{const s=Oe.find(r=>r.value===a||r.name===a||r.label===a);j(r=>({...r,project:s?.name??a,projectId:s?.value??a}))},placeholder:"Select Project...",allowCustom:!0,triggerClassName:b})}),e.jsx(m,{label:"Cost Center",children:e.jsx("input",{value:t.costCenter,onChange:a=>u("costCenter",a.target.value),placeholder:"CC-001",className:b})}),e.jsxs("div",{className:"col-span-full mt-1 p-2.5 rounded-lg border border-blue-100 bg-blue-50/50 dark:bg-blue-950/20 dark:border-blue-900/40 flex items-center gap-2",children:[e.jsx(pt,{className:"w-4 h-4 text-blue-600 dark:text-blue-400 shrink-0"}),e.jsxs("div",{className:"text-[11px] text-slate-600 dark:text-slate-300 leading-tight",children:[e.jsx("span",{className:"font-semibold text-slate-800 dark:text-slate-100",children:"HRMS Master Entities: "}),"Company, Department, Team, and Employee options are managed via HRMS Settings."]})]})]})]}),e.jsx("div",{className:"flex justify-end pt-3",children:e.jsxs("button",{type:"button",onClick:Ia,className:"h-9 px-5 rounded-lg bg-blue-600 hover:bg-blue-700 text-white text-xs font-semibold inline-flex items-center gap-1.5 shadow-2xs transition-colors",children:["Next: Amount, Payment & Remarks ",e.jsx(Ke,{className:"w-3.5 h-3.5"})]})})]}),e.jsxs(he,{value:"amount",className:"space-y-6 mt-0",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between pb-1.5 border-b border-slate-100 dar
1k:border-slate-800/80",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1.5 h-3.5 rounded-full bg-emerald-600 dark:bg-emerald-400 shrink-0"}),e.jsx("h3",{className:"text-xs font-bold text-slate-800 dark:text-slate-200 uppercase tracking-wider",children:"Invoice & Tax Details"})]}),e.jsx("span",{className:"text-[11px] text-slate-400 font-medium",children:"Invoice Value & Tax Computation"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3.5 pt-1",children:[e.jsx(m,{label:"Gross Amount (Base)",required:!0,error:x.gross,children:e.jsx("div",{className:"relative",children:e.jsx("input",{type:"text",inputMode:"decimal",placeholder:"0.00",value:t.gross===0||t.gross==="0"?"":t.gross,onChange:a=>Pa(a.target.value),className:v(b,x.gross&&"border-red-500 focus:ring-red-500 ring-1 ring-red-500")})})}),e.jsx(m,{label:"Currency",required:!0,children:e.jsxs(ae,{value:t.currency,onValueChange:a=>u("currency",a),children:[e.jsx(te,{className:b,children:e.jsx(se,{placeholder:"Select Currency"})}),e.jsx(re,{children:Ft.map(a=>e.jsx(E,{value:a,children:a},a))})]})}),e.jsx(m,{label:"Tax / GST Applicable?",children:e.jsxs("label",{className:"h-9 inline-flex items-center gap-2 text-xs font-medium text-slate-700 dark:text-slate-300 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.taxApplicable,onChange:a=>Sa(a.target.checked),className:"rounded border-slate-300 text-blue-600 focus:ring-blue-500"}),t.taxApplicable?e.jsx("span",{className:"px-2 py-0.5 rounded text-[11px] font-semibold bg-emerald-50 text-emerald-700 dark:bg-emerald-950/50 dark:text-emerald-300 border border-emerald-200 dark:border-emerald-800",children:"Yes (Taxable)"}):e.jsx("span",{className:"px-2 py-0.5 rounded text-[11px] font-semibold bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-400 border border-slate-200 dark:border-slate-700",children:"No (Exempt)"})]})}),t.taxApplicable&&e.jsx(m,{label:"Tax Rate (%)",error:x.taxRate,children:e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",inputMode:"decimal",placeholder:"18",value:t.taxRate===0||t.taxRate==="0"?"":t.taxRate,onChange:a=>Ue(a.target.value),className:b}),e.jsx("span",{className:"absolute right-3 top-2 text-xs font-bold text-slate-400",children:"%"})]}),e.jsx("div",{className:"flex items-center gap-1",children:[0,5,12,18,28].map(a=>e.jsxs("button",{type:"button",onClick:()=>Ue(String(a)),className:v("px-1.5 py-0.5 rounded text-[10px] font-semibold border transition-all cursor-pointer",Number(t.taxRate)===a?"bg-blue-50 text-blue-700 border-blue-300 dark:bg-blue-950 dark:border-blue-700 dark:text-blue-300":"bg-slate-50 text-slate-600 border-slate-200 dark:bg-slate-800 dark:text-slate-400 hover:border-slate-300"),children:[a,"%"]},a))})]})}),e.jsxs("div",{className:"col-span-full py-2.5 px-3.5 rounded-lg bg-slate-50/80 dark:bg-slate-800/50 border border-slate-200/80 dark:border-slate-800 flex flex-wrap items-center justify-between gap-3 text-xs",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("span",{className:"text-slate-500 font-medium",children:"Invoice Value Breakdown:"}),e.jsxs("span",{className:"font-semibold text-slate-800 dark:text-slate-100",children:["Gross Base: ",k(p.gross,y)]}),e.jsx("span",{className:"text-slate-400",children:"+"}),e.jsxs("span",{className:"font-semibold text-slate-800 dark:text-slate-100",children:["Tax (",t.taxApplicable?`${t.taxRate}%`:"0%","): ",k(p.tax,y)]}),e.jsx("span",{className:"text-slate-400",children:"="}),e.jsxs("span",{className:"font-extrabold text-blue-700 dark:text-blue-400 text-sm",children:["Total Invoice Net: ",k(p.net,y)]})]}),e.jsx("span",{className:"text-[11px] font-medium text-slate-400",children:"Standard Invoice Net"})]})]})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsxs("div",{className:"flex items-center justify-between pb-1.5 border-b border-slate-100 dark:border-slate-800/80",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1.5 h-3.5 rounded-full bg-blue-600 dar
1k:bg-blue-400 shrink-0"}),e.jsx("h3",{className:"text-xs font-bold text-slate-800 dark:text-slate-200 uppercase tracking-wider",children:"Payment & Settlement Terms"})]}),e.jsx("span",{className:"text-[11px] text-slate-400 font-medium",children:"Settlement Status, Modes & Accounts"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3.5 pt-1",children:[e.jsx(m,{label:"Payment Status",required:!0,error:x.paymentStatus,hint:"Controls partial/advance breakdown",children:e.jsxs(ae,{value:t.paymentStatus,onValueChange:Na,children:[e.jsx(te,{className:v(b,"font-semibold",x.paymentStatus&&"border-red-500 focus:ring-red-500 ring-1 ring-red-500"),children:e.jsx(se,{placeholder:"Select Status"})}),e.jsxs(re,{children:[e.jsx(E,{value:"Paid",className:"font-medium text-emerald-600",children:"Paid (Disbursed via Bank/Cash)"}),e.jsx(E,{value:"Pending",className:"font-medium text-amber-600",children:"Mark as Payable (Accounts / Salaries Payable)"}),e.jsx(E,{value:"Partial",className:"font-medium text-blue-600",children:"Partial Payment (Split Paid & Payable)"}),e.jsx(E,{value:"Advance",className:"font-medium text-indigo-600",children:"Advance Amount (Upfront & Balance Due)"})]})]})}),e.jsx(m,{label:"Payment Mode",required:!0,error:x.paymentMode,children:e.jsx(S,{value:t.paymentMode,onChange:a=>u("paymentMode",a),options:ye.map(a=>({value:a,label:a})),placeholder:"Select Mode...",searchPlaceholder:"Search payment mode...",triggerClassName:v(b,x.paymentMode&&"border-red-500 focus:ring-red-500 ring-1 ring-red-500"),enableEditDeleteAdd:!1})}),e.jsx(m,{label:"Bank Account",error:x.bankAccount,hint:t.company?`Filtered for ${t.company}`:void 0,children:e.jsx(S,{value:t.bankAccount,onChange:a=>{u("bankAccount",a),x.bankAccount&&A(s=>({...s,bankAccount:""}))},options:B,placeholder:"Select Bank Account...",searchPlaceholder:"Search bank accounts...",triggerClassName:b,enableEditDeleteAdd:!1})}),ba&&e.jsx(m,{label:"Connected Corporate Card",hint:"Debit / Credit card identifier",children:e.jsx(S,{value:t.connectedCardId||"",onChange:a=>{const s=Q.find(r=>r.id===a);u("connectedCardId",a),s&&u("connectedCardName",`${s.cardNickname} (â¢â¢${s.last4})`)},options:Q.map(a=>({value:a.id,label:`${a.cardNickname} â¢â¢ ${a.last4} (${a.cardType.replace("Corporate ","").replace("Business ","")}) - ${a.custodianName.split(" ")[0]}`})),placeholder:"Select Connected Card...",searchPlaceholder:"Search corporate cards...",triggerClassName:v(b,"bg-blue-50/20 dark:bg-blue-950/20 font-medium"),enableEditDeleteAdd:!1})}),e.jsx(m,{label:"Payment Date & Time",error:x.paymentDate,hint:"Settlement timestamp",children:e.jsx(We,{value:t.paymentDate,onChange:a=>u("paymentDate",a),showTime:!0,placeholder:"Select Date & Time",className:v("h-9 text-xs",x.paymentDate&&"border-red-500 ring-1 ring-red-500")})})]}),t.paymentStatus==="Paid"&&e.jsxs("div",{className:"p-3 rounded-lg bg-emerald-50/80 dark:bg-emerald-950/30 border border-emerald-200 dark:border-emerald-900/50 flex items-center justify-between text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bt,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-400 shrink-0"}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-bold text-emerald-800 dark:text-emerald-300",children:["100% Fully Paid (",k(p.net,y),")"]}),e.jsx("span",{className:"text-emerald-700 dark:text-emerald-400 ml-2",children:"â No balance due on this voucher."})]})]}),e.jsxs("span",{className:"text-[11px] font-semibold px-2 py-0.5 rounded bg-emerald-100 dark:bg-emerald-900/60 text-emerald-800 dark:text-emerald-200",children:["Balance Due: ",k(0,y)]})]}),t.paymentStatus==="Pending"&&e.jsxs("div",{className:"p-3 rounded-lg bg-amber-50/80 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-900/50 flex items-center justify-between text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ht,{className:"w-4 h-4 text-amber-600 dark:text-amber-400 shrink-0"}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-bold text-amber-800 dark:text-amber-300",children:["Payment Pending (",k(p.net,y),")"]}),e.jsx("span",{className:"text-amber-700 dark:text-amber-400 ml-2",children:"â Expense entry booked with full liability outstanding."})]})]}),e.jsxs("span",{className:"text-[11px] font-semibold px-2 py-0.5 rounded bg-amber-100 dar
1k:bg-amber-900/60 text-amber-800 dark:text-amber-200",children:["Paid: ",k(0,y)]})]}),(t.paymentStatus==="Partial"||t.paymentStatus==="Advance")&&e.jsxs("div",{className:v("p-4 rounded-xl border transition-all space-y-4 shadow-2xs mt-2",t.paymentStatus==="Advance"?"bg-indigo-50/40 border-indigo-200 dark:bg-indigo-950/20 dark:border-indigo-900/60":"bg-amber-50/40 border-amber-200 dark:bg-amber-950/20 dark:border-amber-900/60"),children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pb-2 border-b border-dashed border-slate-200 dark:border-slate-800",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:v("px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",t.paymentStatus==="Advance"?"bg-indigo-100 text-indigo-700 dark:bg-indigo-900/60 dark:text-indigo-300":"bg-amber-100 text-amber-800 dark:bg-amber-900/60 dark:text-amber-300"),children:t.paymentStatus==="Advance"?"Advance Payment Terms":"Partial Payment Breakdown"}),e.jsx("span",{className:"text-xs font-semibold text-slate-700 dark:text-slate-300",children:t.paymentStatus==="Advance"?"Mobilization / Upfront Deposit with Milestone Tracking":"Bi-directional Percentage & Proportional Tax Allocation"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[11px] text-slate-500 font-medium",children:"Quick %:"}),[10,20,25,30,50,70,75].map(a=>e.jsxs("button",{type:"button",onClick:()=>wa(a),className:v("px-2 py-0.5 rounded text-[11px] font-semibold border transition-all cursor-pointer",Number(t.paidPercentage)===a?"bg-blue-600 text-white border-blue-600 shadow-2xs":"bg-white dark:bg-slate-800 text-slate-700 dark:text-slate-300 border-slate-200 dark:border-slate-700 hover:border-blue-400"),children:[a,"%"]},a))]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3.5 pt-1",children:[e.jsx(m,{label:"Paid Percentage (%)",hint:"Updates Amount Paid automatically",children:e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",inputMode:"decimal",placeholder:"0",value:t.paidPercentage===0||t.paidPercentage==="0"?"":t.paidPercentage,onChange:a=>va(a.target.value),className:v(b,"pr-8 font-semibold text-blue-700 dark:text-blue-300")}),e.jsx("span",{className:"absolute right-3 top-2 text-xs font-bold text-slate-400",children:"%"})]})}),e.jsx(m,{label:"Amount Paid",error:x.amountPaid,hint:"Updates % automatically",children:e.jsx("div",{className:"relative",children:e.jsx("input",{type:"text",inputMode:"decimal",placeholder:"0.00",value:t.amountPaid===0||t.amountPaid==="0"?"":t.amountPaid,onChange:a=>Ca(a.target.value),className:v(b,"font-semibold text-emerald-700 dark:text-emerald-400")})})}),e.jsx(m,{label:"Remaining Balance Due",children:e.jsxs("div",{className:"h-9 w-full rounded-md border border-slate-200 dark:border-slate-800 bg-slate-100/70 dark:bg-slate-800/70 px-3 flex items-center justify-between text-xs font-bold text-amber-700 dark:text-amber-400",children:[e.jsx("span",{children:k(p.outstanding,y)}),e.jsxs("span",{className:"text-[10px] font-medium text-slate-400",children:["(",Math.max(0,100-Number(p.paidPct)).toFixed(1),"% pending)"]})]})}),e.jsx(m,{label:t.paymentStatus==="Advance"?"Milestone / Delivery Date":"Balance Due Date",hint:"Next payment schedule",children:e.jsx(He,{value:t.balanceDueDate||"",onChange:a=>u("balanceDueDate",a),className:"h-9 text-xs"})}),t.paymentStatus==="Advance"&&e.jsx("div",{className:"col-span-full",children:e.jsx(m,{label:"Advance PO / Work Order / Contract Milestone Reference",hint:"e.g. PO-2026-089 or 30% Mobilization Advance",children:e.jsx("input",{type:"text",value:t.advanceReference||"",onChange:a=>u("advanceReference",a.target.value),placeholder:"e.g. Work Order #WO-409 / Advance Payment Voucher #AP-01 / Vendor Milestone #1",className:b})})})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-white/90 dark:bg-slate-900/90 border border-slate-200 dark:border-slate-800 space-y-2 text-xs shadow-2xs",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-1 pb-1.5 border-b border-slate-100 dar
1k:border-slate-800",children:[e.jsxs("span",{className:"font-semibold text-slate-700 dark:text-slate-300 flex items-center gap-1.5",children:[e.jsx(ze,{className:"w-3.5 h-3.5 text-blue-600"}),"Proportional Tax & Base Allocation (",p.paidPct,"% Ratio)"]}),e.jsx("span",{className:"text-[11px] text-slate-400 font-medium",children:"GST Accounting Rule: Tax invoice ITC & liability apportioned based on payment ratio"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 pt-1",children:[e.jsxs("div",{className:"p-2.5 rounded-md bg-emerald-50/60 dark:bg-emerald-950/20 border border-emerald-200/70 dark:border-emerald-900/40",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10px] font-bold uppercase text-emerald-800 dark:text-emerald-400",children:["Disbursed / Paid Portion (",p.paidPct,"%)"]}),e.jsx("span",{className:"text-[10px] font-semibold text-emerald-600",children:"Settled Now"})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs mt-1.5",children:[e.jsx("span",{className:"text-slate-500",children:"Gross Base Paid:"}),e.jsx("span",{className:"font-semibold text-slate-800 dark:text-slate-200",children:k(p.proportionalBasePaid,y)})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs mt-0.5",children:[e.jsx("span",{className:"text-slate-500",children:"Tax Element Paid:"}),e.jsx("span",{className:"font-semibold text-emerald-600 dark:text-emerald-400",children:k(p.proportionalTaxPaid,y)})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs font-bold text-slate-900 dark:text-slate-100 mt-1 pt-1 border-t border-emerald-200 dark:border-emerald-800/60",children:[e.jsx("span",{children:"Total Disbursed:"}),e.jsx("span",{className:"text-emerald-700 dark:text-emerald-400 font-extrabold",children:k(p.paid,y)})]})]}),e.jsxs("div",{className:"p-2.5 rounded-md bg-amber-50/60 dark:bg-amber-950/20 border border-amber-200/70 dark:border-amber-900/40",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10px] font-bold uppercase text-amber-800 dark:text-amber-400",children:["Balance Remaining (",(100-Number(p.paidPct)).toFixed(1),"%)"]}),e.jsx("span",{className:"text-[10px] font-semibold text-amber-600",children:"Payable Later"})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs mt-1.5",children:[e.jsx("span",{className:"text-slate-500",children:"Gross Base Balance:"}),e.jsx("span",{className:"font-semibold text-slate-800 dark:text-slate-200",children:k(p.balanceBaseDue,y)})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs mt-0.5",children:[e.jsx("span",{className:"text-slate-500",children:"Tax Balance Due:"}),e.jsx("span",{className:"font-semibold text-amber-600 dark:text-amber-400",children:k(p.balanceTaxDue,y)})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs font-bold text-slate-900 dark:text-slate-100 mt-1 pt-1 border-t border-amber-200 dark:border-amber-800/60",children:[e.jsx("span",{children:"Remaining Balance:"}),e.jsx("span",{className:"text-amber-700 dark:text-amber-400 font-extrabold",children:k(p.outstanding,y)})]})]})]})]})]})]}),e.jsxs("div",{className:"border-t border-slate-100 dark:border-slate-800/80 pt-3 space-y-2",children:[e.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium text-slate-700 dark:text-slate-300 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.clearsLiability,onChange:a=>u("clearsLiability",a.target.checked),className:"rounded border-slate-300 text-blue-600 focus:ring-blue-500"}),"Is this expense clearing an existing Liability?"]}),t.clearsLiability&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3.5 pt-1",children:[e.jsx(m,{label:"Linked Liability",required:!0,error:x.linkedLiability,children:e.jsxs(ae,{value:t.linkedLiability,onValueChange:a=>u("linkedLiability",a),children:[e.jsx(te,{className:v(b,x.linkedLiability&&"border-red-500 focus:ring-red-500 ring-1 ring-red-500"),children:e.jsx(se,{placeholder:"Select Liability..."})}),e.jsx(re,{children:Bt.map(a=>e.jsx(E,{value:a,children:a},a))})]})}),e.jsx(m,{label:"EMI / Installment No.",children:e.jsx("input",{type:"text",inputMode:"numeric",placeholder:"1",value:t.emiNo==="0"?"":t.emiNo,onChange:a=>{const s=a.target.value;(s===""||/^\d*$/.test(s))&&u("emiNo",s)},className:b})})]})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-1.5 border-b border-slate-100 dar
1k:border-slate-800/80",children:[e.jsx("span",{className:"w-1.5 h-3.5 rounded-full bg-blue-600 dark:bg-blue-400 shrink-0"}),e.jsx("h3",{className:"text-xs font-bold text-slate-800 dark:text-slate-200 uppercase tracking-wider",children:"Additional Information & Remarks"})]}),e.jsxs("div",{className:"p-1 space-y-4",children:[e.jsx(m,{label:"Description & Notes",children:e.jsxs("div",{className:"border border-slate-200 dark:border-slate-800 rounded-lg overflow-hidden bg-white dark:bg-slate-900 shadow-2xs",children:[e.jsxs("div",{className:"flex items-center gap-1 border-b border-slate-100 dark:border-slate-800 bg-slate-50 dark:bg-slate-800/50 p-1.5",children:[e.jsx("button",{type:"button",onClick:()=>oe("bold"),className:"p-1.5 hover:bg-slate-200 dark:hover:bg-slate-700 rounded text-slate-600 dark:text-slate-300",children:e.jsx(gt,{className:"w-3.5 h-3.5"})}),e.jsx("button",{type:"button",onClick:()=>oe("italic"),className:"p-1.5 hover:bg-slate-200 dark:hover:bg-slate-700 rounded text-slate-600 dark:text-slate-300",children:e.jsx(ft,{className:"w-3.5 h-3.5"})}),e.jsx("button",{type:"button",onClick:()=>oe("insertUnorderedList"),className:"p-1.5 hover:bg-slate-200 dark:hover:bg-slate-700 rounded text-slate-600 dark:text-slate-300",children:e.jsx(yt,{className:"w-3.5 h-3.5"})})]}),e.jsx("div",{ref:W,contentEditable:!0,onInput:()=>u("description",W.current?.innerHTML||""),className:"min-h-[90px] p-3 text-xs focus:outline-none custom-scrollbar",dangerouslySetInnerHTML:{__html:t.description}})]})}),e.jsx(m,{label:"Tags",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:V,onChange:a=>we(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),qe())},placeholder:"Add tag and press enter...",className:b}),e.jsx("button",{type:"button",onClick:qe,className:"h-9 px-3.5 rounded-md bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 dark:hover:bg-slate-700 text-xs font-semibold text-slate-700 dark:text-slate-200 shrink-0",children:"Add"})]}),ee.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:ee.map(a=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-50 text-blue-700 dark:bg-blue-950/50 dark:text-blue-300 border border-blue-200 dark:border-blue-800",children:[a,e.jsx("button",{type:"button",onClick:()=>Fa(a),className:"hover:text-blue-900 dark:hover:text-blue-100",children:e.jsx(Qe,{className:"w-3 h-3"})})]},a))})]})}),e.jsx(m,{label:"Bill / Invoice Attachment (PDF, PNG, JPG, Screenshot)",hint:"Max 25MB (PDF, PNG, JPG, WEBP)",children:t.attachmentUrl?e.jsxs("div",{className:"flex items-center justify-between p-3 border border-slate-200 dark:border-slate-800 rounded-lg bg-slate-50 dark:bg-slate-800/50",children:[e.jsxs("div",{className:"flex items-center gap-2.5 overflow-hidden",children:[e.jsx(kt,{className:"w-5 h-5 text-blue-600 dark:text-blue-400 shrink-0"}),e.jsxs("div",{className:"truncate",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-800 dark:text-slate-200 truncate",children:t.attachmentName||"Attached_Bill.pdf"}),e.jsx("a",{href:t.attachmentUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[11px] text-blue-600 dark:text-blue-400 hover:underline inline-flex items-center gap-1 font-medium",children:"View / Download Attached Bill"})]})]}),e.jsx("button",{type:"button",onClick:()=>j(a=>({...a,attachmentUrl:"",attachmentName:""})),className:"p-1.5 hover:bg-slate-200 dark:hover:bg-slate-700 text-slate-500 rounded-md transition-colors",title:"Remove attachment",children:e.jsx(Qe,{className:"w-4 h-4 text-red-500"})})]}):e.jsxs("div",{className:"relative border-2 border-dashed border-slate-200 dark:border-slate-800 hover:border-blue-400 dark:hover:border-blue-500 rounded-lg p-4 text-center bg-slate-50/50 dark:bg-slate-900/50 transition-colors",children:[e.jsx("input",{type:"file",accept:".pdf,.png,.jpg,.jpeg,.webp",onChange:a=>{const s=a.target.files?.[0];s&&la(s)},disabled:ve,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer disabled:cursor-not-allowed"}),e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-1",children:[e.jsx(jt,{className:"w-6 h-6 text-slate-400 dark:text-slate-500 mb-1"}),e.jsx("p",{className:"text-xs font-semibold text-slate-700 dark:text-slate-300",children:ve?"Uploading Bill Attachment...":"Click or drag bill attachment here"}),e.jsx("p",{className:"text-[10px] text-slate-500 font-mono",children:"Supported: PDF, PNG, JPG, JPEG, WEBP (Executable files strictly blocked)"})]})]})})]})]}),e.jsxs("div",{className:"flex justify-between pt-3",children:[e.jsxs("button",{type:"button",onClick:()=>T("classification"),className:"h-9 px-3.5 rounded-lg border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 text-xs font-medium text-slate-700 dark:text-slate-200 inline-flex items-center gap-1.5 transition-colors",children:[e.jsx(xe,{className:"w-3.5 h-3.5"})," Back: Classification & HRMS"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>
1T("review"),className:"h-9 px-4 rounded-lg bg-blue-600 hover:bg-blue-700 text-white text-xs font-semibold inline-flex items-center gap-1.5 shadow-2xs transition-colors",children:["Next: Audit Trail & Approvals ",e.jsx(Ke,{className:"w-3.5 h-3.5"})]}),e.jsxs("button",{type:"submit",disabled:M,className:"h-9 px-5 rounded-lg bg-emerald-600 hover:bg-emerald-700 text-white text-xs font-semibold inline-flex items-center gap-1.5 shadow-2xs transition-colors disabled:opacity-50",children:[e.jsx(pe,{className:"w-3.5 h-3.5"})," ",M?"Saving...":h?"Update Expense Entry":"Submit Expense Entry"]})]})]})]}),e.jsxs(he,{value:"review",className:"space-y-6 mt-0",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-1.5 border-b border-slate-100 dark:border-slate-800/80",children:[e.jsx("div",{className:"w-5 h-5 rounded-md bg-purple-50 dark:bg-purple-900/40 text-purple-600 dark:text-purple-400 flex items-center justify-center shrink-0",children:e.jsx(Nt,{className:"w-3.5 h-3.5"})}),e.jsx("h3",{className:"text-xs font-bold text-slate-800 dark:text-slate-200 uppercase tracking-wider",children:"Executive Clearance & Final Approvals"})]}),e.jsxs("div",{className:"p-4 bg-slate-50/50 dark:bg-slate-900/50 rounded-xl border border-slate-200 dark:border-slate-800 space-y-3",children:[e.jsx("span",{className:"text-[11px] font-bold text-slate-500 uppercase tracking-wider block",children:"1. Entry Lifecycle Timeline"}),e.jsxs("div",{className:"relative pl-6 space-y-4 before:absolute before:left-2 before:top-2 before:bottom-2 before:w-0.5 before:bg-slate-200 dark:before:bg-slate-800",children:[e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute -left-6 top-0 w-4 h-4 rounded-full bg-emerald-500 text-white flex items-center justify-center text-[10px] font-bold",children:"â"}),e.jsx("div",{className:"text-xs font-bold text-slate-900 dark:text-slate-100",children:"Draft Initialized & Recorded"}),e.jsx("div",{className:"text-[11px] text-slate-500",children:"Created by Data Entry Team (Sarbjit Singh) ⢠Today"}),e.jsxs("p",{className:"text-[11px] text-slate-400 mt-0.5 italic",children:["Ref ",t.referenceNo," registered in finance ledger draft store."]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute -left-6 top-0 w-4 h-4 rounded-full bg-blue-500 text-white flex items-center justify-center text-[10px] font-bold",children:"i"}),e.jsx("div",{className:"text-xs font-bold text-slate-900 dark:text-slate-100",children:"HRMS Allocation Verified"}),e.jsxs("div",{className:"text-[11px] text-slate-500",children:["Department: ",t.department||"Engineering"," | Company: ",t.company||"Tekki Web Solutions"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute -left-6 top-0 w-4 h-4 rounded-full bg-amber-500 text-white flex items-center justify-center text-[10px] font-bold",children:"!"}),e.jsx("div",{className:"text-xs font-bold text-slate-900 dark:text-slate-100",children:"Executive Approval Pending"}),e.jsxs("div",{className:"text-[11px] text-slate-500",children:["Assigned Approver: ",t.approver||I[0]?.label||"Pawandeep Kaur Grewal (CFO)"]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"p-3 bg-emerald-50/60 dark:bg-emerald-950/40 border border-emerald-200 dark:border-emerald-800/60 rounded-xl space-y-1",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase text-emerald-700 dark:text-emerald-300 block",children:"1. Categorization"}),e.jsx("p",{className:"text-xs text-slate-700 dark:text-slate-300 font-medium",children:"Verified Tax & Vendor GST"})]}),e.jsxs("div",{className:"p-3 bg-blue-50/60 dark:bg-blue-950/40 border border-blue-200 dark:border-blue-800/60 rounded-xl space-y-1",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase text-blue-700 dark:text-blue-300 block",children:"2. HRMS Mapping"}),e.jsx("p",{className:"text-xs text-slate-700 dark:text-slate-300 font-medium",children:"Company & Dept Confirmed"})]}),e.jsxs("div",{className:"p-3 bg-purple-50/60 dark:bg-purple-950/40 border border-purple-200 dark:border-purple-800/60 rounded-xl space-y-1",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase text-purple-700 dark:text-purple-300 block",children:"3. Final Sign-off"}),e.jsx("p",{className:"text-xs text-slate-700 dark:text-slate-300 font-medium",children:"Ready for CFO Sign-off"})]})]}),e.jsx(m,{label:"Assign Final Approver",required:!0,children:e.jsx(S,{options:I,value:t.approver||(I[0]?.value??""),onChange:a=>u("approver",a),placeholder:"Select CFO or Finance Approver",searchPlaceholder:"Search f
1inance approver by name or role...",triggerClassName:"h-9 text-xs font-medium bg-white dark:bg-slate-900 border-slate-200 dark:border-slate-800",enableEditDeleteAdd:!1})})]}),e.jsxs("div",{className:"flex justify-between pt-3 border-t border-slate-200 dark:border-slate-800",children:[e.jsxs("button",{type:"button",onClick:()=>T("amount"),className:"h-9 px-3.5 rounded-lg border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 text-xs font-medium text-slate-700 dark:text-slate-200 inline-flex items-center gap-1.5 transition-colors",children:[e.jsx(xe,{className:"w-3.5 h-3.5"})," Back: Amount & Payment"]}),e.jsxs("button",{type:"submit",disabled:M,className:"h-9 px-5 rounded-lg bg-emerald-600 hover:bg-emerald-700 text-white text-xs font-semibold inline-flex items-center gap-1.5 shadow-2xs transition-colors disabled:opacity-50",children:[e.jsx(pe,{className:"w-3.5 h-3.5"})," ",M?"Saving...":h?"Update Entry":"Final Approval & Submit"]})]})]})]}),e.jsxs("div",{className:"lg:col-span-3 bg-slate-50/60 dark:bg-slate-900/60 p-6 space-y-5 flex flex-col justify-between h-full",children:[e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-slate-200 dark:border-slate-800 pb-3.5",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"p-2 rounded-xl bg-blue-50 dark:bg-blue-950/60 text-blue-600 dark:text-blue-400 border border-blue-100 dark:border-blue-900/40",children:e.jsx(ze,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-bold text-slate-800 dark:text-slate-100 uppercase tracking-wider",children:"Live Summary"}),e.jsx("span",{className:"text-[11px] text-slate-400 font-medium",children:"Real-time Financial Breakdown"})]})]}),e.jsx("span",{className:"text-[11px] font-bold px-2.5 py-1 rounded-full bg-blue-50 text-blue-700 dark:bg-blue-950/70 dark:text-blue-300 border border-blue-200/60 dark:border-blue-900/60",children:t.currency})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"p-3.5 rounded-xl bg-white dark:bg-slate-900/80 border border-slate-200/80 dark:border-slate-800/80 space-y-2 text-xs shadow-2xs",children:[e.jsxs("div",{className:"flex justify-between items-center text-slate-600 dark:text-slate-400",children:[e.jsx("span",{className:"font-medium",children:"Gross Amount"}),e.jsx("span",{className:"font-semibold text-slate-900 dark:text-slate-100",children:k(p.gross,y)})]}),e.jsxs("div",{className:"flex justify-between items-center text-slate-600 dark:text-slate-400",children:[e.jsx("span",{className:"font-medium",children:"Tax Rate"}),e.jsx("span",{className:"font-medium text-slate-700 dark:text-slate-300",children:t.taxApplicable?`${t.taxRate}%`:"Exempt"})]}),e.jsxs("div",{className:"flex justify-between items-center text-slate-600 dark:text-slate-400",children:[e.jsx("span",{className:"font-medium",children:"Tax Amount"}),e.jsxs("span",{className:"font-semibold text-slate-700 dark:text-slate-300",children:["+ ",k(p.tax,y)]})]})]}),e.jsxs("div",{className:"p-3.5 rounded-xl bg-blue-50 dark:bg-blue-950/40 border border-blue-200/70 dark:border-blue-900/60 flex justify-between items-center text-xs",children:[e.jsx("span",{className:"font-bold text-blue-700 dark:text-blue-300",children:"Net Amount"}),e.jsx("span",{className:"font-extrabold text-blue-700 dark:text-blue-300 text-sm",children:k(p.net,y)})]}),e.jsxs("div",{className:"p-3.5 rounded-xl bg-white dark:bg-slate-900/80 border border-slate-200/80 dark:border-slate-800/80 flex justify-between items-center text-xs text-emerald-600 dark:text-emerald-400 shadow-2xs",children:[e.jsx("span",{className:"font-medium",children:t.paymentStatus==="Advance"?"Advance Paid":t.paymentStatus==="Partial"?`Paid (${p.paidPct}%)`:"Amount Paid"}),e.jsxs("span",{className:"font-semibold",children:["â ",k(p.paid,y)]})]}),e.jsxs("div",{className:"p-3.5 rounded-xl bg-amber-50 dark:bg-amber-950/40 border border-amber-200/70 dark:border-amber-900/60 flex justify-between items-center text-xs",children:[e.jsx("span",{className:"font-bold text-amber-700 dark:text-amber-300",children:t.paymentStatus==="Advance"?"Milestone Balance":"Outstanding Due"}),e.jsx("span",{className:"font-extrabold text-amber-700 dark:text-amber-300 text-sm",children:k(p.outstanding,y)})]}
1),(t.paymentStatus==="Partial"||t.paymentStatus==="Advance")&&e.jsxs("div",{className:"p-2.5 rounded-lg bg-blue-50/60 dark:bg-blue-950/30 border border-blue-100 dark:border-blue-900/50 text-[11px] space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-blue-800 dark:text-blue-300 font-semibold",children:[e.jsxs("span",{children:["Tax Paid (",p.paidPct,"%):"]}),e.jsx("span",{children:k(p.proportionalTaxPaid,y)})]}),e.jsxs("div",{className:"flex justify-between text-slate-500",children:[e.jsx("span",{children:"Balance Tax Due:"}),e.jsx("span",{children:k(p.balanceTaxDue,y)})]})]})]}),e.jsxs("div",{className:"border-t border-slate-200 dark:border-slate-800 pt-4 space-y-3 text-xs",children:[e.jsx("h4",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Entry Context"}),e.jsxs("div",{className:"space-y-2 text-xs",children:[e.jsxs("div",{className:"flex justify-between items-center py-1 border-b border-slate-200/60 dark:border-slate-800/60",children:[e.jsx("span",{className:"text-slate-500 font-medium shrink-0",children:"Reference"}),e.jsx("span",{className:"font-mono font-semibold px-2 py-0.5 rounded bg-white dark:bg-slate-800 text-slate-800 dark:text-slate-200 border border-slate-200/60 dark:border-slate-700",children:t.referenceNo||"Auto"})]}),e.jsxs("div",{className:"flex justify-between items-center py-1 border-b border-slate-200/60 dark:border-slate-800/60",children:[e.jsx("span",{className:"text-slate-500 font-medium shrink-0",children:"Expense Type"}),e.jsx("span",{className:"font-semibold text-slate-800 dark:text-slate-200 text-right",children:t.expenseType||"Unassigned"})]}),e.jsxs("div",{className:"flex justify-between items-center py-1 border-b border-slate-200/60 dark:border-slate-800/60",children:[e.jsx("span",{className:"text-slate-500 font-medium shrink-0",children:"Category"}),e.jsx("span",{className:"font-semibold text-slate-800 dark:text-slate-200 text-right",children:t.category||"Unassigned"})]}),e.jsxs("div",{className:"flex justify-between items-center py-1 border-b border-slate-200/60 dark:border-slate-800/60",children:[e.jsx("span",{className:"text-slate-500 font-medium shrink-0",children:"Vendor"}),e.jsx("span",{className:"font-semibold text-slate-800 dark:text-slate-200 text-right",children:t.vendorName||"Not specified"})]}),e.jsxs("div",{className:"flex justify-between items-center py-1 border-b border-slate-200/60 dark:border-slate-800/60",children:[e.jsx("span",{className:"text-slate-500 font-medium shrink-0",children:"Company"}),e.jsx("span",{className:"font-semibold text-slate-800 dark:text-slate-200 text-right",children:t.company||"Tekki Web Solutions"})]}),e.jsxs("div",{className:"flex justify-between items-center py-1 border-b border-slate-200/60 dark:border-slate-800/60",children:[e.jsx("span",{className:"text-slate-500 font-medium shrink-0",children:"Dept / Team"}),e.jsx("span",{className:"font-semibold text-slate-800 dark:text-slate-200 text-right",children:[t.department,t.team].filter(Boolean).join(" / ")||"Unallocated"})]}),e.jsxs("div",{className:"flex justify-between items-center py-1",children:[e.jsx("span",{className:"text-slate-500 font-medium shrink-0",children:"Employee"}),e.jsx("span",{className:"font-semibold text-slate-800 dark:text-slate-200 text-right",children:t.employee||"Unallocated"})]})]})]})]}),ra&&Object.keys(x).length>0&&e.jsxs("div",{className:"p-3.5 rounded-xl bg-red-50 dark:bg-red-950/40 border border-red-200 dark:border-red-900/60 text-xs text-red-600 dark:text-red-400 space-y-1.5 mt-4",children:[e.jsxs("div",{className:"font-semibold flex items-center gap-1.5",children:[e.jsx(vt,{className:"w-4 h-4 shrink-0"})," ",Object.keys(x).length," Required Field(s) Missing"]}),e.jsx("ul",{className:"list-disc list-inside text-[11px] text-red-500 space-y-0.5 pl-1",children:Object.entries(x).map(([a,s])=>e.jsx("li",{children:s},a))})]})]})]})]}),e.jsx(Ct,{open:oa,onOpenChange:R,children:e.jsxs(wt,{className:"max-w-md",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-9 h-9 rounded-full bg-purple-100 text-purple-700 dark:bg-purple-900/50 dark:text-purple-300 flex items-center justify-center shrink-0",children:e.jsx(ue,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx(St,{className:"text-base font-bold",children:"Request CFO Unlock Approval"}),e.jsxs(At,{className:"text-xs text-slate-500 dark:text-slate-400",children:["Voucher: ",e.jsx("span",{className:"font-semibold text-slate-800 dark:text-slate-200",children:t.referenceNo})]})]})]})}),e.jsxs("div",{className:"space-y-3 py-2 text-xs",children:[e.jsxs("div",{className:"p-3 bg-slate-50 dark:bg-slate-800/80 border border-slate-200 dark:border-slate-700 rounded-lg space-y-1",children:[e.jsxs("div",{className:"font-semibold text-slate-800 dark:text-slate-200 text-xs",children:["ð Locked by CFO ",C?.lockedByName||"Pawandeep Kaur"]}),e.jsx("p",{className:"text-[11px] text-slate-500 dark:text-slate-400 leading-relaxed",children:"This entry is finalized. To edit this record, please submit an unlock justification to CFO Pawandeep Kaur for review."})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-xs font-semibold text-slate-700 dark:text-slate-300",children:["Reason for Modification ",e.jsx("span",{className:"text-rose-500",children:"*"})]}),e.jsx("textarea",{rows:3,value:K,onChange:a=>ca(a.target.value),placeholder:"Explain why this locked expense needs adjustment (e.g. vendor sent revised invoice, incorrect tax classification, etc.)",className:"w-full p-2 rounded-md border border-slate-200 dark:border-slate-800 text-xs bg-white dark:bg-slate-900 outline-none focus:border-purple-500 resize-none"})]})]}),e.jsxs(Et,{className:"gap-2 sm:gap-0",children:[e.jsx("button",{type:"button",onClick:()=>R(!1),className:"px-3 py-1.5 rounded-md border border-slate-200 dark:border-slate-800 text-xs font-medium hover:bg-slate-50 dark:hover:bg-slate-800 transition-colors",children:"Cancel"}),e.jsxs("button",{type:"button",disabled:Te||!K.trim(),onClick:xa,className:"px-3.5 py-1.5 rounded-md bg-purple-600 hover:bg-purple-700 text-white text-xs font-semibold inline-flex items-center gap-1.5 shadow-2xs transition-colors disabled:opacity-50",children:[e.jsx(fe,{className:"w-3.5 h-3.5"}),Te?"Submitting...":"Submit to CFO Pawandeep Kaur"]})]})]})})]})}function m({label:q,hint:$,required:_,error:ne,children:h}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("label",{className:"text-[11px] font-semibold text-slate-700 dark:text-slate-300 tracking-tight",children:[q," ",_&&e.jsx("span",{className:"text-red-500",children:"*"})]}),$&&e.jsx("span",{className:"text-[10px] text-slate-400 font-normal",children:$})]}),h,ne&&e.jsx("p",{className:"text-[10px] text-red-500 mt-0.5",children:ne})]})}
1export{_t as CATEGORY_SUB_CATEGORIES,ea as EXPENSE_TYPE_CATEGORIES,Zt as NewExpensePage};
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.