import{r as n,j as e,H as p,a as o}from"./app-BQEFzdw6.js";import{A as h}from"./AppLayout-kozc03ce.js";import{P as u}from"./PageHeader-Bj1OQnqr.js";import{f as s}from"./formatters-ClI693-F.js";import"./useThemeColor-qPCpc713.js";import"./dayjs.min-BDUBcDj6.js";function v({balances:a,asOf:l}){const[i,x]=n.useState(l??new Date().toISOString().substring(0,10));function c(t){t.preventDefault(),o.get(route("accounts.reports.trial-balance"),{as_of:i},{preserveState:!0,replace:!0})}const d=(a??[]).reduce((t,r)=>t+parseFloat(r.debit??0),0),m=(a??[]).reduce((t,r)=>t+parseFloat(r.credit??0),0);return e.jsxs(h,{children:[e.jsx(p,{title:"Trial Balance"}),e.jsx(u,{title:"Trial Balance",back:route("accounts.reports.index")}),e.jsxs("div",{className:"p-4 sm:p-6",children:[e.jsxs("form",{onSubmit:c,className:"flex gap-3 mb-4 items-end",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{className:"text-xs text-gray-500",children:"As Of Date"}),e.jsx("input",{type:"date",className:"form-input text-sm",value:i,onChange:t=>x(t.target.value)})]}),e.jsx("button",{type:"submit",className:"btn btn-primary text-sm",children:"Generate"})]}),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.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Account Code"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Account Name"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase",children:"Debit (৳)"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase",children:"Credit (৳)"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:(a??[]).map(t=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-4 py-3 text-sm font-mono text-primary-600",children:t.code}),e.jsx("td",{className:"px-4 py-3 text-sm",children:t.name}),e.jsx("td",{className:"px-4 py-3 text-sm text-right",children:t.debit>0?s(t.debit):"—"}),e.jsx("td",{className:"px-4 py-3 text-sm text-right",children:t.credit>0?s(t.credit):"—"})]},t.id))}),e.jsx("tfoot",{className:"bg-gray-50 font-semibold",children:e.jsxs("tr",{children:[e.jsx("td",{colSpan:2,className:"px-4 py-3 text-sm",children:"Total"}),e.jsx("td",{className:"px-4 py-3 text-sm text-right",children:s(d)}),e.jsx("td",{className:"px-4 py-3 text-sm text-right",children:s(m)})]})})]})})]})]})}export{v as default};
