import{r as y,j as e,H as j,L as f,b as w}from"./app-CAqQVdqj.js";import{A as N}from"./AuthenticatedLayout-CQEcc2iz.js";import{f as s}from"./utils-f31lc4sE.js";function C({invoices:a,month:x,totalExpected:i,totalCollected:c,pending:m}){const[o,p]=y.useState(x||new Date().toISOString().slice(0,7)),h=t=>{p(t),w.get(route("reports.collection"),{month:t},{preserveState:!0,replace:!0})};return e.jsxs(N,{header:e.jsx("h2",{className:"text-xl font-semibold leading-tight text-gray-800",children:"Monthly Collection"}),children:[e.jsx(j,{title:"Monthly Collection"}),e.jsx("div",{className:"py-12",children:e.jsxs("div",{className:"mx-auto max-w-7xl sm:px-6 lg:px-8 space-y-6",children:[e.jsx("div",{className:"bg-white shadow-sm sm:rounded-lg p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Month:"}),e.jsx("input",{type:"month",value:o,onChange:t=>h(t.target.value),className:"rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"})]}),e.jsx(f,{href:route("reports.index"),className:"inline-flex items-center rounded-md bg-gray-200 px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-300",children:"Back to Reports"})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"bg-white shadow-sm sm:rounded-lg p-6 border-l-4 border-blue-500",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Expected"}),e.jsx("p",{className:"text-2xl font-bold text-blue-700",children:s(i)})]}),e.jsxs("div",{className:"bg-white shadow-sm sm:rounded-lg p-6 border-l-4 border-green-500",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Collected"}),e.jsx("p",{className:"text-2xl font-bold text-green-700",children:s(c)})]}),e.jsxs("div",{className:"bg-white shadow-sm sm:rounded-lg p-6 border-l-4 border-yellow-500",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500",children:"Pending"}),e.jsx("p",{className:"text-2xl font-bold text-yellow-700",children:s(m)})]})]}),e.jsx("div",{className:"bg-white shadow-sm sm:rounded-lg overflow-hidden",children:e.jsx("div",{className:"p-6 text-gray-900",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500",children:"Invoice#"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500",children:"Shop#"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500",children:"Tenant"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium uppercase tracking-wider text-gray-500",children:"Total"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium uppercase tracking-wider text-gray-500",children:"Paid"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium uppercase tracking-wider text-gray-500",children:"Balance"}),e.jsx("th",{className:"px-4 py-3 text-center text-xs font-medium uppercase tracking-wider text-gray-500",children:"Status"})]})}),e.jsxs("tbody",{className:"divide-y divide-gray-200 bg-white",children:[a.map(t=>{const r=(t.payments||[]).reduce((g,u)=>g+parseFloat(u.amount_paid||0),0),l=parseFloat(t.total_amount||0),d=l-r,n=d<=0?"paid":"pending";return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"whitespace-nowrap px-4 py-4 text-sm font-medium text-gray-900",children:t.invoice_number}),e.jsx("td",{className:"whitespace-nowrap px-4 py-4 text-sm text-gray-900",children:t.lease?.shop?.shop_number||"—"}),e.jsx("td",{className:"whitespace-nowrap px-4 py-4 text-sm text-gray-900",children:t.lease?.tenant?.name||"—"}),e.jsx("td",{className:"whitespace-nowrap px-4 py-4 text-sm text-right text-gray-900",children:s(l)}),e.jsx("td",{className:"whitespace-nowrap px-4 py-4 text-sm text-right text-green-700",children:s(r)}),e.jsx("td",{className:"whitespace-nowrap px-4 py-4 text-sm text-right font-medium text-gray-900",children:s(d)}),e.jsx("td",{className:"whitespace-nowrap px-4 py-4 text-sm text-center",children:e.jsx("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${n==="paid"?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:n==="paid"?"Paid":"Pending"})})]},t.id)}),a.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:"7",className:"px-4 py-4 text-center text-sm text-gray-500",children:"No invoices found for this month."})})]})]})})})})]})})]})}export{C as default};
