1import{u as ee,r as f,e as b,j as e,L as I}from"./vendor-CjDHlqhy.js";import{P as se}from"./page-template-DZDekKmP.js";import{I as te}from"./InvoiceProSubNav-dPLcKvUp.js";/* empty css */import{aj as ae}from"./ui-CNs-pDNo.js";import"./utils-nrJLb57x.js";import"./app-layout-VqcNefif.js";import"./app-shared-BRksQZ7A.js";import"./app-D7gEHbXj.js";/* empty css *//* empty css */import"./language-switcher-DIr2GLrQ.js";import"./language-DZ9KMQZW.js";import"./motion-Bvx8bI_5.js";import"./CompanySupportChatWidget-DjUg0DKq.js";import"./recharts-B3sRJ26l.js";import"./input-error-CB2dSVrq.js";import"./theme-DClJHNB7.js";import"./WatilySiteWebPushProvider-D_666GSH.js";import"./WebPushOptIn-CHvvL7UY.js";import"./watily-ui-shell-CFP-EonI.js";const o=c=>new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(c)||0),F=(c,n)=>{const[h,u]=c.split("-").map(Number),j=new Date(h,u-1+n,1);return"".concat(j.getFullYear(),"-").concat(String(j.getMonth()+1).padStart(2,"0"))},O=(c,n)=>{const[h,u,j]=c.split("-").map(Number),m=new Date(h,(u||1)-1,j+n);return"".concat(m.getFullYear(),"-").concat(String(m.getMonth()+1).padStart(2,"0"),"-").concat(String(m.getDate()).padStart(2,"0"))},ne={issued:{count:0,total:0,unpaid_count:0,unpaid_total:0},collected:{total:0,count:0,by_method:[]},expenses:{total:0,count:0},net_cash:0};function Se({selectedMonth:c,invoices:n,selectedDay:h,dailyClosing:u,isSuperAdmin:j=!1}){const m=h!=null?h:new Date().toISOString().slice(0,10),l=u!=null?u:ne,{t}=ee(),[r,k]=f.useState("all"),[_,P]=f.useState(""),[x,C]=f.useState([]),[y,D]=f.useState(!1),[R,T]=f.useState("bank"),[v,w]=f.useState(null),i=j?"admin.invoice-pro":"invoice-pro",N=s=>s==="unpaid"||s==="overdue",[V,U]=c.split("-").map(Number),A=new Date(V,(U||1)-1,1).toLocaleDateString("en-US",{month:"long",year:"numeric"}),L=s=>b.get(route("".concat(i,".invoices")),{month:s}),$=s=>b.get(route("".concat(i,".invoices")),{month:c,day:s},{only:["dailyClosing","selectedDay"],preserveState:!0,preserveScroll:!0}),z=s=>{var g;return(g={cash:t("Cash"),card:t("Card"),transfer:t("Bank transfer"),other:t("Other")}[s])!=null?g:s},d={all:n.length,paid:n.filter(s=>s.status==="paid").length,unpaid:n.filter(s=>N(s.status)).length,nowa:n.filter(s=>s.whatsapp_sent_count===0).length,pos:n.filter(s=>s.invoice_type==="pos").length},E=n.filter(s=>s.status!=="draft"&&s.status!=="cancelled").reduce((s,a)=>s+Number(a.total),0),H=n.filter(s=>s.status==="paid").reduce((s,a)=>s+Number(a.total),0),Y=n.filter(s=>N(s.status)).reduce((s,a)=>s+Number(a.total),0),p=n.filter(s=>{if(r==="paid"&&s.status!=="paid"||r==="unpaid"&&!N(s.status)||r==="nowa"&&s.whatsapp_sent_count>0||r==="pos"&&s.invoice_type!=="pos")return!1;if(_){const a=_.toLowerCase();if(!s.invoice_number.toLowerCase().includes(a)&&!s.customer_name.toLowerCase().includes(a))return!1}return!0}),q=(s,a)=>{w({id:s,status:a})},S=s=>{v&&b.post(route("".concat(i,".send-whatsapp"),v.id),{template:s},{preserveScroll:!0,onFinish:()=>w(null)})},G=s=>{confirm(t("Are you sure you want to delete this invoice?"))&&b.delete(route("".concat(i,".destroy"),s))},M=p.map(s=>s.id),Z=x.filter(s=>M.includes(s)).length,W=p.length>0&&Z===p.length,J=Z>0&&!W,K=()=>{C(W?s=>s.filter(a=>!M.includes(a)):s=>Array.from(new Set([...s,...M])))},Q=s=>{C(a=>a.includes(s)?a.filter(g=>g!==s):[...a,s])},B=s=>{const a=x.length;if(!a)return;const g={delete:t("Delete {{count}} selected invoices?",{count:a}),cancel:t("Cancel {{count}} selected invoices?",{count:a}),"mark-paid":t("Mark {{count}} selected invoices as paid?",{count:a})};confirm(g[s])&&(D(!0),b.post(route("".concat(i,".invoices.bulk")),{action:s,ids:x,account_type:s==="mark-paid"?R:void 0},{preserveScroll:!0,onFinish:()=>{D(!1),C([])}}))},X=[{label:t("Create New Invoice"),icon:e.jsx(ae,{className:"h-4 w-4"}),variant:"default",onClick:()=>b.visit(route("".concat(i,".create")))}];return e.jsxs(se,{title:t("Invoices"),description:t("List of all invoices"),url:route("".concat(i,".invoices")),actions:X,breadcrumbs:[{title:t("Dashboard"),href:route("dashboard")},{title:t("Invoice Pro"),href:route("".concat(i,".index"))},{title:t("Invoices"),href:route("".concat(i,".invoices"))}],children:[e.jsx(te,{section:"invoices",active:"all"}),e.jsxs("div",{className:"ipa",dir:"ltr","data-accent":"classic",children:[e.jsxs("div",{className:"grid kpi-mini-grid",children:[e.jsxs("div",{className:"card kpi kpi-mini",children:[e.jsx("div",{className:"top",children:e.jsx("span",{children:t("Month total")})}),e.jsxs("div",{className:"val",children:[o(E),e.jsx("span",{className:"unit",children:"SAR"})]})]}),e.jsxs("div",{className:"card kpi kpi-mini tone-green",children:[e.jsx("div",{className:"top",children:e.jsx("span",{children:t("Collected")})}),e.jsxs("div",{className:"val",children:[o(H),e.jsx("span",{className:"unit",children:"SAR"})]})]}),e.jsxs("div",{className:"card kpi kpi-mini tone-red",children:[e.jsx("div",{className:"top",children:e.jsx("span",{children:t("Outstanding")})}),e.jsxs("div",{className:"val",children:[o(Y),e.jsx("span",{className:"unit",children:"SAR"})]})]}),e.jsxs("div",{className:"card kpi kpi-mini",children:[e.jsx("div",{className:"top",children:e.jsx("span",{children:t("Invoices")})}),e.jsx("div",{className:"val",children:d.all}),e.jsx("div",{className:"sub",children:t("{{count}} without WhatsApp",{count:d.nowa})})]})]}),e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"card-head",children:[e.jsxs("h3",{children:[e.jsx("span",{className:"ico",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"
1currentColor",children:e.jsx("path",{d:"M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2Zm1 15h-2v-2h2Zm0-4h-2V7h2Z"})})}),t("Daily closing")]}),e.jsxs("div",{className:"month-nav day-nav",children:[e.jsx("button",{title:t("Previous day"),onClick:()=>$(O(m,-1)),children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("path",{d:"M15 6 9 12l6 6"})})}),e.jsx("input",{type:"date",className:"v day-input",value:m,onChange:s=>s.target.value&&$(s.target.value)}),e.jsx("button",{title:t("Next day"),onClick:()=>$(O(m,1)),children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("path",{d:"M9 6l6 6-6 6"})})})]})]}),l.issued.count===0&&l.collected.count===0&&l.expenses.count===0?e.jsx("div",{className:"empty",children:e.jsx("div",{className:"et",children:t("No activity on this day")})}):e.jsxs("div",{className:"stat-strip",children:[e.jsxs("div",{children:[e.jsx("div",{className:"lbl",children:t("Issued today")}),e.jsxs("div",{className:"big",children:[o(l.issued.total),e.jsx("span",{className:"u",children:"SAR"})]}),e.jsx("div",{className:"sub",children:t("{{count}} invoices",{count:l.issued.count})})]}),e.jsx("div",{className:"div"}),e.jsxs("div",{children:[e.jsx("div",{className:"lbl",children:t("Collected today")}),e.jsxs("div",{className:"big",children:[o(l.collected.total),e.jsx("span",{className:"u",children:"SAR"})]}),l.collected.by_method.length>0&&e.jsx("div",{className:"filter-row",style:{marginTop:6},children:l.collected.by_method.map(s=>e.jsxs("span",{className:"chip",children:[z(s.method)," ",e.jsx("span",{className:"count",children:o(s.total)})]},s.method))})]}),e.jsx("div",{className:"div"}),e.jsxs("div",{children:[e.jsx("div",{className:"lbl",children:t("Outstanding")}),e.jsxs("div",{className:"big",children:[o(l.issued.unpaid_total),e.jsx("span",{className:"u",children:"SAR"})]}),e.jsx("div",{className:"sub",children:t("{{count}} invoices",{count:l.issued.unpaid_count})})]}),e.jsx("div",{className:"div"}),e.jsxs("div",{children:[e.jsx("div",{className:"lbl",children:t("Today's expenses")}),e.jsxs("div",{className:"big",children:[o(l.expenses.total),e.jsx("span",{className:"u",children:"SAR"})]})]}),e.jsx("div",{className:"div"}),e.jsxs("div",{children:[e.jsx("div",{className:"lbl",children:t("Net cash today")}),e.jsxs("div",{className:"big ".concat(l.net_cash<0?"tone-red-text":"tone-green-text"),children:[o(l.net_cash),e.jsx("span",{className:"u",children:"SAR"})]})]})]})]}),e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"card-head",children:[e.jsxs("h3",{children:[e.jsx("span",{className:"ico",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M5 2h11l4 4v15a1 1 0 0 1-1.5.9L17 21l-2 1-2-1-2 1-2-1-2 1-1.5-.1A1 1 0 0 1 4 21V3a1 1 0 0 1 1-1Zm2 6h8v2H7V8Zm0 4h10v2H7v-2Zm0 4h6v2H7v-2Z"})})}),t("Invoices")," · ",A]}),e.jsxs("div",{className:"month-nav",children:[e.jsx("button",{title:t("Previous month"),onClick:()=>L(F(c,-1)),children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("path",{d:"M15 6 9 12l6 6"})})}),e.jsx("div",{className:"v",children:A.toUpperCase()}),e.jsx("button",{title:t("Next month"),onClick:()=>L(F(c,1)),children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("path",{d:"M9 6l6 6-6 6"})})})]})]}),e.jsxs("div",{className:"filter-row",children:[e.jsxs("button",{className:"chip".concat(r==="all"?" on":""),onClick:()=>k("all"),children:[t("All")," ",e.jsx("span",{className:"count",children:d.all})]}),e.jsxs("button",{className:"chip".concat(r==="paid"?" on":""),onClick:()=>k("paid"),children:[t("Paid")," ",e.jsx("span",{className:"count",children:d.paid})]}),e.jsxs("button",{className:"chip".concat(r==="unpaid"?" on":""),onClick:()=>k("unpaid"),children:[t("Unpaid")," ",e.jsx("span",{className:"count",children:d.unpaid})]}),e.jsxs("button",{className:"chip".concat(r==="nowa"?" on":""),onClick:()=>k("nowa"),children:[t("No WhatsApp")," ",e.jsx("span",{className:"count",children:d.nowa})]}),d.pos>0&&e.jsxs("button",{className:"chip".concat(r==="pos"?" on":""),onClick:()=>
1k("pos"),children:[t("Cashier (POS)")," ",e.jsx("span",{className:"count",children:d.pos})]}),e.jsxs("div",{className:"filter-search",children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("path",{d:"m20 20-3.5-3.5"})]}),e.jsx("input",{value:_,onChange:s=>P(s.target.value),placeholder:t("Search invoice number or customerâ¦")})]})]}),x.length>0&&e.jsxs("div",{className:"bulk-bar",children:[e.jsx("span",{className:"bulk-count",children:t("{{count}} selected",{count:x.length})}),e.jsxs("div",{className:"bulk-acts",children:[e.jsxs("select",{className:"ctl",style:{width:"auto"},value:R,disabled:y,onChange:s=>T(s.target.value),"aria-label":t("Collection account"),children:[e.jsx("option",{value:"bank",children:t("Bank")}),e.jsx("option",{value:"cash",children:t("Cashbox")})]}),e.jsx("button",{className:"btn ghost",disabled:y,onClick:()=>B("mark-paid"),children:t("Mark as Paid")}),e.jsx("button",{className:"btn ghost",disabled:y,onClick:()=>B("cancel"),children:t("Cancel")}),e.jsx("button",{className:"btn ghost danger",disabled:y,onClick:()=>B("delete"),children:t("Delete")})]}),e.jsx("button",{className:"bulk-clear",disabled:y,onClick:()=>C([]),children:t("Clear selection")})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"chk-col",children:e.jsx("input",{type:"checkbox","aria-label":t("Select all"),checked:W,ref:s=>{s&&(s.indeterminate=J)},onChange:K})}),e.jsx("th",{children:t("Invoice no.")}),e.jsx("th",{children:t("Date")}),e.jsx("th",{children:t("Customer")}),e.jsx("th",{style:{textAlign:"right"},children:t("Amount")}),e.jsx("th",{children:t("Status")}),e.jsx("th",{children:t("WhatsApp")}),e.jsx("th",{style:{textAlign:"right"},children:t("Actions")})]})}),e.jsx("tbody",{children:p.map(s=>{const a=s.status==="paid"?"paid":N(s.status)?"unpaid":"";return e.jsxs("tr",{className:x.includes(s.id)?"row-selected":"",children:[e.jsx("td",{className:"chk-col",children:e.jsx("input",{type:"checkbox","aria-label":t("Select invoice"),checked:x.includes(s.id),onChange:()=>Q(s.id)})}),e.jsxs("td",{children:[e.jsx(I,{className:"inv-no",href:route("".concat(i,".show"),s.id),children:s.invoice_number}),s.invoice_type==="pos"&&e.jsx("span",{className:"badge",style:{marginInlineStart:6,fontSize:10,padding:"1px 7px"},children:"POS"})]}),e.jsx("td",{className:"date",children:s.date}),e.jsxs("td",{children:[e.jsx("div",{className:"cname",children:s.customer_name}),s.customer_phone&&e.jsx("div",{className:"cphone",children:s.customer_phone})]}),e.jsxs("td",{className:"amount",style:{textAlign:"right"},children:[o(s.total),e.jsx("span",{className:"unit",children:"SAR"})]}),e.jsx("td",{children:e.jsxs("span",{className:"badge ".concat(a),children:[e.jsx("span",{className:"dot"}),s.status_label]})}),e.jsx("td",{children:s.whatsapp_sent_count>0?e.jsxs("span",{className:"wa-status",children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"m9 16-4-4 1.4-1.4L9 13.2l8.6-8.6L19 6l-10 10Z"})}),s.whatsapp_sent_count]}):e.jsx("span",{className:"wa-status muted",children:"â"})}),e.jsx("td",{children:e.jsxs("div",{className:"actions-cell",children:[s.has_pdf&&e.jsx("a",{className:"icon-mini",title:t("Download PDF"),href:route("".concat(i,".pdf"),s.id),children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6Z"}),e.jsx("path",{d:"M14 2v6h6"})]})}),s.customer_phone&&e.jsx("button",{className:"icon-mini wa",title:t("Send WhatsApp"),onClick:()=>q(s.id,s.status),children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M20 4a10 10 0 0 0-16 12L2 22l6-2a10 10 0 0 0 12-16Z"})})}),e.jsx(I,{className:"icon-mini",title:t("View"),href:route("".concat(i,".show"),s.id),children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M2 12s3.5-
17 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),e.jsx(I,{className:"icon-mini",title:t("Edit"),href:route("".concat(i,".edit"),s.id),children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M12 20h9"}),e.jsx("path",{d:"M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z"})]})}),e.jsx("button",{className:"icon-mini del",title:t("Delete"),onClick:()=>G(s.id),children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2m-3 5v6m-4-6v6M5 6l1 14a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2l1-14"})})})]})})]},s.id)})})]})}),p.length===0&&e.jsxs("div",{className:"empty",children:[e.jsx("div",{className:"ei",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M5 2h11l4 4v15a1 1 0 0 1-1.5.9L17 21l-2 1-2-1-2 1-2-1-2 1-1.5-.1A1 1 0 0 1 4 21V3a1 1 0 0 1 1-1Z"})})}),e.jsx("div",{className:"et",children:t("No invoices found")}),e.jsx("div",{className:"es",children:t("Try a different month or filter.")})]}),p.length>0&&e.jsx("div",{className:"table-foot",children:e.jsxs("div",{children:[t("Showing")," ",e.jsx("b",{children:p.length})," ",t("of")," ",e.jsx("b",{children:n.length})," ",t("invoices")," · ",A]})})]})]}),v&&e.jsx("div",{onClick:()=>w(null),style:{position:"fixed",inset:0,background:"rgba(15,23,42,.55)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999},children:e.jsxs("div",{onClick:s=>s.stopPropagation(),style:{background:"#fff",borderRadius:14,width:"min(420px, 92vw)",padding:22,boxShadow:"0 20px 60px rgba(0,0,0,.25)"},children:[e.jsx("div",{style:{fontSize:17,fontWeight:600,marginBottom:6},children:t("Send WhatsApp")}),e.jsx("div",{style:{color:"#64748b",fontSize:13,marginBottom:16},children:t("Choose which message to send to the customer.")}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[N(v.status)&&e.jsx("button",{className:"btn",style:{background:"#0f172a",color:"#fff",padding:"10px 14px",borderRadius:10,fontWeight:500},onClick:()=>S("unpaid"),children:t("New invoice")}),N(v.status)&&e.jsx("button",{className:"btn",style:{background:"#f59e0b",color:"#fff",padding:"10px 14px",borderRadius:10,fontWeight:500},onClick:()=>S("reminder"),children:t("Payment reminder")}),v.status==="paid"&&e.jsx("button",{className:"btn",style:{background:"#16a34a",color:"#fff",padding:"10px 14px",borderRadius:10,fontWeight:500},onClick:()=>S("paid"),children:t("Payment confirmation")}),e.jsx("button",{className:"btn",style:{background:"#dc2626",color:"#fff",padding:"10px 14px",borderRadius:10,fontWeight:500},onClick:()=>S("cancelled"),children:t("Cancellation notice")}),e.jsx("button",{className:"btn ghost",style:{background:"transparent",color:"#64748b",padding:"8px 14px",borderRadius:10,marginTop:4},onClick:()=>w(null),children:t("Cancel")})]})]})})]})}export{Se as default};
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.