mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
2 lines
6.4 KiB
JavaScript
2 lines
6.4 KiB
JavaScript
import{G as Q,J as W,a0 as P,B as y,ah as X,k as B,C as Y,A as Z,r as d,o as u,l as b,w as n,f as a,u as s,m as z,i as V,t as m,j as k,h as i,e as F,y as ee,F as te}from"./vendor.d12b5734.js";import{u as oe,w as S,x as ae}from"./main.a7fcb8c6.js";import{u as se}from"./invoice.e20d2377.js";import{u as ne}from"./global.28a39e9d.js";import"./auth.5b562db7.js";const re={class:"fixed top-0 left-0 hidden h-full pt-16 pb-4 bg-white w-88 xl:block"},ie={class:"flex items-center justify-between px-4 pt-8 pb-6 border border-gray-200 border-solid"},le={class:"flex ml-3",role:"group","aria-label":"First group"},de={class:"px-4 py-1 pb-2 mb-2 text-sm border-b border-gray-200 border-solid"},ce={class:"px-2"},ue={class:"px-2"},me={class:"px-2"},pe={class:"h-full pb-32 overflow-y-scroll border-l border-gray-200 border-solid sw-scroll"},fe={class:"flex-2"},_e={class:"mb-1 not-italic font-medium leading-5 text-gray-500 capitalize text-md"},ve={class:"flex-1 whitespace-nowrap right"},ye={class:"text-sm text-right text-gray-500 non-italic"},be={key:0,class:"flex justify-center px-4 mt-5 text-sm text-gray-600"},he={class:"flex flex-col min-h-0 mt-8 overflow-hidden",style:{height:"75vh"}},ge=["src"],Fe={setup(Be){const p=Q(),l=se(),_=ne(),{tm:$}=W();let h=P({}),o=P({orderBy:"",orderByField:"",invoice_number:""});y(null),y(null);let w=y(!1),N=y(!1);y(!1),X("utils"),oe();const R=B(()=>l.selectedViewInvoice),j=B(()=>o.orderBy==="asc"||o.orderBy==null);B(()=>j.value?$("general.ascending"):$("general.descending"));const C=B(()=>h.unique_hash?`/invoices/pdf/${h.unique_hash}`:!1);Y(p,()=>{D()}),A(),D(),c=Z.exports.debounce(c,500);function U(e){return p.params.id==e}async function A(){await l.fetchInvoices({limit:"all"},_.companySlug),setTimeout(()=>{G()},500)}async function D(){if(p&&p.params.id){let e=await l.fetchViewInvoice({id:p.params.id},_.companySlug);e.data&&Object.assign(h,e.data.data)}}function G(){const e=document.getElementById(`invoice-${p.params.id}`);e&&(e.scrollIntoView({behavior:"smooth"}),e.classList.add("shake"))}async function c(){let e={};o.invoice_number!==""&&o.invoice_number!==null&&o.invoice_number!==void 0&&(e.invoice_number=o.invoice_number),o.orderBy!==null&&o.orderBy!==void 0&&(e.orderBy=o.orderBy),o.orderByField!==null&&o.orderByField!==void 0&&(e.orderByField=o.orderByField),w.value=!0;try{let r=await l.searchInvoice(e,_.companySlug);w.value=!1,r.data.data&&(l.invoices=r.data.data)}catch{w.value=!1}}function T(){return o.orderBy==="asc"?(o.orderBy="desc",c(),!0):(o.orderBy="asc",c(),!0)}function q(){router.push({name:"invoice.portal.payment",params:{id:l.selectedViewInvoice.id,company:l.selectedViewInvoice.company.slug}})}return(e,r)=>{const v=d("BaseIcon"),g=d("BaseButton"),E=d("BasePageHeader"),L=d("BaseInput"),I=d("BaseRadio"),x=d("BaseInputGroup"),M=d("BaseInvoiceStatusBadge"),H=d("BaseFormatMoney"),O=d("router-link"),J=d("BasePage");return u(),b(J,{class:"xl:pl-96"},{default:n(()=>[a(E,{title:s(R).invoice_number},{actions:n(()=>{var t,f;return[a(g,{disabled:s(N),variant:"primary-outline",class:"mr-2",tag:"a",href:`/invoices/pdf/${s(h).unique_hash}`,download:""},{left:n(K=>[a(v,{name:"DownloadIcon",class:z(K.class)},null,8,["class"]),V(" "+m(e.$t("invoices.download")),1)]),_:1},8,["disabled","href"]),((f=(t=s(l))==null?void 0:t.selectedViewInvoice)==null?void 0:f.paid_status)!=="PAID"&&s(_).enabledModules.includes("Payments")?(u(),b(g,{key:0,variant:"primary",onClick:q},{default:n(()=>[V(m(e.$t("invoices.pay_invoice")),1)]),_:1})):k("",!0)]}),_:1},8,["title"]),i("div",re,[i("div",ie,[a(L,{modelValue:s(o).invoice_number,"onUpdate:modelValue":r[0]||(r[0]=t=>s(o).invoice_number=t),placeholder:e.$t("general.search"),type:"text",variant:"gray",onInput:c},{right:n(()=>[a(v,{name:"SearchIcon",class:"h-5 text-gray-400"})]),_:1},8,["modelValue","placeholder"]),i("div",le,[a(ae,{position:"bottom-start","width-class":"w-50","position-class":"left-0"},{activator:n(()=>[a(g,{variant:"gray"},{default:n(()=>[a(v,{name:"FilterIcon",class:"h-5"})]),_:1})]),default:n(()=>[i("div",de,m(e.$t("general.sort_by")),1),i("div",ce,[a(S,{class:"pt-3 rounded-md hover:rounded-md"},{default:n(()=>[a(x,{class:"-mt-3 font-normal"},{default:n(()=>[a(I,{id:"filter_invoice_date",modelValue:s(o).orderByField,"onUpdate:modelValue":[r[1]||(r[1]=t=>s(o).orderByField=t),c],label:e.$t("invoices.invoice_date"),name:"filter",size:"sm",value:"invoice_date"},null,8,["modelValue","label"])]),_:1})]),_:1})]),i("div",ue,[a(S,{class:"pt-3 rounded-md hover:rounded-md"},{default:n(()=>[a(x,{class:"-mt-3 font-normal"},{default:n(()=>[a(I,{id:"filter_due_date",modelValue:s(o).orderByField,"onUpdate:modelValue":[r[2]||(r[2]=t=>s(o).orderByField=t),c],label:e.$t("invoices.due_date"),name:"filter",size:"sm",value:"due_date"},null,8,["modelValue","label"])]),_:1})]),_:1})]),i("div",me,[a(S,{class:"pt-3 rounded-md hover:rounded-md"},{default:n(()=>[a(x,{class:"-mt-3 font-normal"},{default:n(()=>[a(I,{id:"filter_invoice_number",modelValue:s(o).orderByField,"onUpdate:modelValue":[r[3]||(r[3]=t=>s(o).orderByField=t),c],label:e.$t("invoices.invoice_number"),size:"sm",name:"filter",value:"invoice_number"},null,8,["modelValue","label"])]),_:1})]),_:1})])]),_:1}),a(g,{class:"ml-1",variant:"white",onClick:T},{default:n(()=>[s(j)?(u(),b(v,{key:0,name:"SortAscendingIcon",class:"h-5"})):(u(),b(v,{key:1,name:"SortDescendingIcon",class:"h-5"}))]),_:1})])]),i("div",pe,[(u(!0),F(te,null,ee(s(l).invoices,(t,f)=>(u(),b(O,{id:"invoice-"+t.id,key:f,to:`/${s(_).companySlug}/customer/invoices/${t.id}/view`,class:z(["flex justify-between p-4 items-center cursor-pointer hover:bg-gray-100 border-l-4 border-transparent",{"bg-gray-100 border-l-4 border-primary-500 border-solid":U(t.id)}]),style:{"border-bottom":"1px solid rgba(185, 193, 209, 0.41)"}},{default:n(()=>[i("div",fe,[i("div",_e,m(t.invoice_number),1),a(M,{status:t.status},{default:n(()=>[V(m(t.status),1)]),_:2},1032,["status"])]),i("div",ve,[a(H,{class:"mb-2 text-xl not-italic font-semibold leading-8 text-right text-gray-900 block",amount:t.total,currency:t.currency},null,8,["amount","currency"]),i("div",ye,m(t.formatted_invoice_date),1)])]),_:2},1032,["id","to","class"]))),128)),s(l).invoices.length?k("",!0):(u(),F("p",be,m(e.$t("invoices.no_matching_invoices")),1))])]),i("div",he,[s(C)?(u(),F("iframe",{key:0,ref:(t,f)=>{f.report=t},src:s(C),class:"flex-1 border border-gray-400 border-solid rounded-md",onClick:r[4]||(r[4]=(...t)=>e.ViewReportsPDF&&e.ViewReportsPDF(...t))},null,8,ge)):k("",!0)])]),_:1})}}};export{Fe as default};
|