import{r,j as e,H as g,a as y}from"./app-BQEFzdw6.js";import{A as N}from"./AppLayout-kozc03ce.js";import{P as v}from"./PageHeader-Bj1OQnqr.js";import{f as s,a as b}from"./formatters-ClI693-F.js";import"./useThemeColor-qPCpc713.js";import"./dayjs.min-BDUBcDj6.js";function _({transactions:n,accountHeads:i,filters:t,openingBalance:c,closingBalance:m}){const[l,o]=r.useState((t==null?void 0:t.account_head_id)??""),[d,p]=r.useState((t==null?void 0:t.from)??""),[x,h]=r.useState((t==null?void 0:t.to)??"");function u(a){a.preventDefault(),y.get(route("accounts.reports.cash-bank"),{account_head_id:l,from:d,to:x},{preserveState:!0,replace:!0})}return e.jsxs(N,{children:[e.jsx(g,{title:"Cash & Bank Statement"}),e.jsx(v,{title:"Cash & Bank Statement",back:route("accounts.reports.index")}),e.jsxs("div",{className:"p-4 sm:p-6",children:[e.jsxs("form",{onSubmit:u,className:"flex gap-3 mb-4 items-end flex-wrap",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{className:"text-xs text-gray-500",children:"Account"}),e.jsxs("select",{className:"form-input text-sm",value:l,onChange:a=>o(a.target.value),children:[e.jsx("option",{value:"",children:"All Cash/Bank"}),(i??[]).map(a=>e.jsxs("option",{value:a.id,children:[a.code," - ",a.name]},a.id))]})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{className:"text-xs text-gray-500",children:"From"}),e.jsx("input",{type:"date",className:"form-input text-sm",value:d,onChange:a=>p(a.target.value)})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{className:"text-xs text-gray-500",children:"To"}),e.jsx("input",{type:"date",className:"form-input text-sm",value:x,onChange:a=>h(a.target.value)})]}),e.jsx("button",{type:"submit",className:"btn btn-primary text-sm",children:"Generate"})]}),c!==void 0&&e.jsxs("div",{className:"flex gap-6 mb-4 text-sm",children:[e.jsxs("div",{className:"bg-gray-50 rounded p-3",children:[e.jsx("span",{className:"text-gray-500",children:"Opening Balance: "}),e.jsx("strong",{children:s(c)})]}),e.jsxs("div",{className:"bg-primary-50 rounded p-3",children:[e.jsx("span",{className:"text-gray-500",children:"Closing Balance: "}),e.jsx("strong",{className:"text-primary-700",children:s(m)})]})]}),e.jsx("div",{className:"card overflow-hidden",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsx("tr",{children:["Date","Description","Reference","Debit (In)","Credit (Out)","Balance"].map(a=>e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:a},a))})}),e.jsxs("tbody",{className:"divide-y divide-gray-100",children:[(n??[]).map((a,j)=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-4 py-3 text-sm",children:b(a.date)}),e.jsx("td",{className:"px-4 py-3 text-sm",children:a.description}),e.jsx("td",{className:"px-4 py-3 text-sm font-mono text-primary-600",children:a.reference}),e.jsx("td",{className:"px-4 py-3 text-sm text-green-700",children:a.debit>0?s(a.debit):"—"}),e.jsx("td",{className:"px-4 py-3 text-sm text-red-600",children:a.credit>0?s(a.credit):"—"}),e.jsx("td",{className:"px-4 py-3 text-sm font-semibold",children:s(a.running_balance)})]},j)),(n??[]).length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-4 py-8 text-center text-gray-400",children:"No transactions for the selected period."})})]})]})})]})]})}export{_ as default};
