import{$ as e,A as t,C as n,G as r,S as i,Wt as a,_ as o,c as s,dt as c,et as l,g as u,h as d,ut as f,v as p,vt as m,z as h,zt as g}from"./vue.runtime.esm-bundler-DAWRyTnP.js";import{i as _}from"./vue-router-Bna4o8ws.js";import{n as v}from"./vue-i18n-C4HYJWrq.js";import{S as y,v as b,y as x}from"./main-Gn9UsJwa.js";import{t as S}from"./CapsuleIcon-BkM0jIKH.js";import{t as C}from"./BaseTable-a2xauH32.js";import{t as w}from"./global-BGcIadxV.js";import{t as T}from"./payment-C9fhAq2w.js";var E={class:`relative table-container`},D=[`innerHTML`],O={__name:`Index`,setup(O){let{tm:k,t:A}=v(),j=c(!1);c(`created_at`);let M=c(!0),N=c(null),P=f({payment_mode:``,payment_number:``}),F=t(`utils`);_();let I=T(),L=w(),R=d(()=>!I.totalPayments&&!M.value),z=d(()=>L.currency),B=d(()=>[{key:`payment_date`,label:A(`payments.date`),thClass:`extra`,tdClass:`font-medium text-gray-900`},{key:`payment_number`,label:A(`payments.payment_number`)},{key:`payment_mode`,label:A(`payments.payment_mode`)},{key:`invoice_number`,label:A(`invoices.invoice_number`)},{key:`amount`,label:A(`payments.amount`)},{key:`actions`,label:``,tdClass:`text-right text-sm font-medium`,sortable:!1}]);y(P,()=>{W()},{debounce:500});async function V(e){return(await I.fetchPaymentModes(e,L.companySlug)).data.data}async function H({page:e,filter:t,sort:n}){let r={payment_method_id:P.payment_mode===null?``:P.payment_mode,payment_number:P.payment_number,orderByField:n.fieldName||`created_at`,orderBy:n.order||`desc`,page:e};M.value=!0;let i=await I.fetchPayments(r,L.companySlug);return M.value=!1,{data:i.data.data,pagination:{totalPages:i.data.meta.last_page,currentPage:e,totalCount:i.data.meta.total,limit:10}}}function U(){N.value.refresh()}function W(){U()}function G(){P.customer=``,P.payment_mode=``,P.payment_number=``}function K(){j.value&&G(),j.value=!j.value}return(t,c)=>{let d=r(`BaseBreadcrumbItem`),f=r(`BaseBreadcrumb`),_=r(`BaseIcon`),v=r(`BaseButton`),y=r(`BasePageHeader`),w=r(`BaseInput`),T=r(`BaseInputGroup`),O=r(`BaseMultiselect`),k=r(`BaseFilterWrapper`),A=r(`BaseEmptyPlaceholder`),M=r(`router-link`),U=r(`BasePage`);return h(),o(U,null,{default:e(()=>[n(y,{title:t.$t(`payments.title`)},{breadcrumbs:e(()=>[n(f,null,{default:e(()=>[n(d,{title:t.$t(`general.home`),to:`/${m(L).companySlug}/customer/dashboard`},null,8,[`title`,`to`]),n(d,{title:t.$t(`payments.payment`,2),to:`#`,active:``},null,8,[`title`])]),_:1})]),actions:e(()=>[l(n(v,{variant:`primary-outline`,onClick:K},{right:e(e=>[m(j)?(h(),o(_,{key:1,class:g(e.class),name:`XMarkIcon`},null,8,[`class`])):(h(),o(_,{key:0,class:g(e.class),name:`FunnelIcon`},null,8,[`class`]))]),default:e(()=>[i(a(t.$t(`general.filter`))+` `,1)]),_:1},512),[[s,m(I).totalPayments]])]),_:1},8,[`title`]),l(n(k,{onClear:G},{default:e(()=>[n(T,{label:t.$t(`payments.payment_number`),class:`px-3`},{default:e(()=>[n(w,{modelValue:P.payment_number,"onUpdate:modelValue":c[0]||=e=>P.payment_number=e,placeholder:t.$t(`payments.payment_number`)},null,8,[`modelValue`,`placeholder`])]),_:1},8,[`label`]),n(T,{label:t.$t(`payments.payment_mode`),class:`px-3`},{default:e(()=>[n(O,{modelValue:P.payment_mode,"onUpdate:modelValue":c[1]||=e=>P.payment_mode=e,"value-prop":`id`,"track-by":`name`,"filter-results":!1,label:`name`,"resolve-on-load":``,delay:100,searchable:``,options:V,placeholder:t.$t(`payments.payment_mode`)},null,8,[`modelValue`,`placeholder`])]),_:1},8,[`label`])]),_:1},512),[[s,m(j)]]),R.value?(h(),o(A,{key:0,title:t.$t(`payments.no_payments`),description:t.$t(`payments.list_of_payments`)},{default:e(()=>[n(S,{class:`mt-5 mb-4`})]),_:1},8,[`title`,`description`])):p(``,!0),l(u(`div`,E,[n(C,{ref_key:`table`,ref:N,data:H,columns:B.value,"placeholder-count":m(I).totalPayments>=20?10:5,class:`mt-10`},{"cell-payment_date":e(({row:e})=>[i(a(e.data.formatted_payment_date),1)]),"cell-payment_number":e(({row:t})=>[n(M,{to:{path:`payments/${t.data.id}/view`},class:`font-medium text-primary-500`},{default:e(()=>[i(a(t.data.payment_number),1)]),_:2},1032,[`to`])]),"cell-payment_mode":e(({row:e})=>[u(`span`,null,a(e.data.payment_method?e.data.payment_method.name:t.$t(`payments.not_selected`)),1)]),"cell-invoice_number":e(({row:e})=>[u(`span`,null,a(e.data.invoice?.invoice_number?e.data.invoice?.invoice_number:t.$t(`payments.no_invoice`)),1)]),"cell-amount":e(({row:e})=>[u(`div`,{innerHTML:m(F).formatMoney(e.data.amount,z.value)},null,8,D)]),"cell-actions":e(({row:r})=>[n(x,null,{activator:e(()=>[n(_,{name:`EllipsisHorizontalIcon`,class:`w-5 text-gray-500`})]),default:e(()=>[n(M,{to:`payments/${r.data.id}/view`},{default:e(()=>[n(b,null,{default:e(()=>[n(_,{name:`EyeIcon`,class:`h-5 mr-3 text-gray-600`}),i(` `+a(t.$t(`general.view`)),1)]),_:1})]),_:1},8,[`to`])]),_:2},1024)]),_:1},8,[`columns`,`placeholder-count`])],512),[[s,!R.value]])]),_:1})}}};export{O as default};