1import{_ as R,I as v,gK as O,z as Y,P as q,J as A,s as G,ab as y,N as Q,a4 as h,r as I,o as c,c as m,a as b,g as l,w as s,t as f,F as H,l as J,d as V,a9 as n,B as _,i as w,n as K,q as x,O as Z,ac as B,ad as F}from"./index-5a064f15.js";import{D as P}from"./index-3f52c995.js";import{S as W}from"./index-8ef67533.js";import X from"./TableContainer-a50c5b90.js";import{a as ee,b as te,c as ae}from"./billing-b99a2421.js";import S from"./SimpleTooltip-ca3b7445.js";import{S as oe}from"./SelectItem-29395459.js";import"./useBaseTable-2363a108.js";import"./index-6fc24ca3.js";import"./BaseTable-7edb7ec3.js";import"./index-c9b9eddb.js";import"./Status-c1855a8c.js";import"./BasePagination-020ae90c.js";import"./index-39bd4154.js";const se={class:"flex flex-col"},ne={class:"flex flex-col lg:flex-row justify-between"},le={key:0,class:"text-base leading-6"},re={key:1,class:"text-base leading-6"},ce={key:0},ie={key:1},de={class:"flex flex-col sm:flex-row gap-3 items-start mt-3 mb-3 lg:mt-0"},me=["href"],ue={key:1,class:"text-gray-900"},fe={class:"flex gap-3"},_e={__name:"BillingInvoices",setup(pe){const{accounts:g,accountsLoading:k}=v("accounts"),L=O(),{router:C}=v("$core"),M={invoice_name:"Invoice Name",billing_cycle_start_date:{label:"Billing Cycle Start Date",type:"datetime"},billing_cycle_end_date:{label:"Billing Cycle End Date",type:"datetime"},invoice_date:{label:"Invoice Date",type:"datetime"},status:{type:"status",label:"Status"},payment:"Payment",action:{label:"Action",sortable:!1}},p=Y(!1),D=Y([]),z=q(E,1e3),a=A({form:{account:null,from_date:null,to_date:null}}),$=G(()=>p.value||Object.keys(a.form).some(t=>!a.form[t]));async function E(){if(!$.value)try{p.value=!0;const{account:t,from_date:o,to_date:r}=a.form,u=y(o).format("YYYY-MM-DD"),e=y(r).format("YYYY-MM-DD"),d=await ee(t.account_uuid,{start_date:u,end_date:e});D.value=d.data.filter(i=>i.status==="closed"||i.status==="finalized").map(i=>({...i,status:T(i)})),Q(C,{account_uuid:t.account_uuid,from_date:u,to_date:e})}finally{p.value=!1}}h(g,t=>{t!=null&&t.length&&N(t)},{immediate:!0}),h(a.form,z);function N(t){const o=t||g.value;let r=o[0];const{account_uuid:u,from_date:e,to_date:d}=Z(C);u&&(r=o.find(i=>i.account_uuid===u)),a.form.account=r,a.form.from_date=e||"2017-01-01",a.form.to_date=d||y().format("YYYY-MM-DD")}function T(t){return t?t.status.toLowerCase()==="closed"?"CLOSED":t.status.toLowerCase()==="finalized"&&t.is_overdue?"OVERDUE":t.status.toLowerCase()==="finalized"&&!t.is_overdue?"FINALIZED":"":""}async function U(t){try{t.downloading=!0;const o=await te(a.form.account.account_uuid,t.invoice_id),r=B(o.data,"text/csv");F(r,t.invoice_id)}finally{t.downloading=!1}}async function j(t){try{t.downloading=!0;const o=await ae(a.form.account.account_uuid,t.invoice_id),r=B(o.data,"application/pdf");F(r,`invoice-${t.invoice_id}`)}finally{t.downloading=!1}}return(t,o)=>{const r=I("IconExcel"),u=I("IconDownload");return c(),m("div",se,[b("div",ne,[l(n(W),{modelValue:a.form.account,"onUpdate:modelValue":o[0]||(o[0]=e=>a.form.account=e),label:"Billing account",placeholder:n(k)?"Loading...":"Select billing account",disabled:n(k),class:"flex-1 max-w-xs mr-2"},{value:s(({value:e})=>[e.first_name?(c(),m("span",le,f(e.first_name)+" "+f(e.last_name?e.last_name:""),1)):(c(),m("span",re,f(e.po_number),1))]),default:s(()=>[(c(!0),m(H,null,J(n(g),e=>(c(),V(n(oe),{key:e.account_uuid,value:e},{default:s(()=>[e.first_name?(c(),m("span",ce,f(e.first_name)+" "+f(e.last_name?e.last_name:""),1)):(c(),m("span",ie,f(e.po_number),1))]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue","placeholder","disabled"]),b("div",de,[l(n(P),{class:"flex-1 max-w-64 min-w-64 text-gray-400",modelValue:a.form.from_date,"onUpdate:modelValue":o[1]||(o[1]=e=>a.form.from_date=e),label:"From",placeholder:"From",format:"MM/DD/YYYY"},{actions:s(({relative:e,select:d})=>[l(n(_),{secondary:"",size:"sm",onClick:i=>d(2017,0,1),class:"mr-2"},{default:s(()=>[w("Beginning")]),_:2},1032,["onClick"]),l(n(_),{secondary:"",size:"sm",onClick:i=>e(0),class:"mr-2"},{default:s(()=>[w("Today")]),_:2},1032,["onClick"])]),_:1},8,["modelValue"]),l(n(P),{class:"flex-1 max-w-64 min-w-64 text-gray-400",modelValue:a.form.to_date,"onUpdate:modelValue":o[2]||(o[2]=e=>a.form.to_date=e),label:"To",placeholder:"To",format:"MM/DD/YYYY"},{actions:s(({relative:e})=>[l(n(_),{secondary:"",size:"sm",onClick:d=>e(0),class:"mr-2"},{default:s(()=>[w("Today")]),_:2},1032,["onClick"])]),_:1},8,["modelValue"])])]),l(X,{class:"flex-1 mt-3",columns:M,data:D.value,loading:p.value,emptyText:"No invoices found",idProp:"invoice_id"},{"column-payment":s(({row:e})=>[e.stripe_url&&e.status.toLowerCase()==="finalized"?(c(),m("a",{key:0,class:K({"text-red-500":e.is_overdue}),href:e.stripe_url,target:"_blank"}," Make Payment ",10,me)):x("",!0),e.status.toLowerCase()==="closed"?(c(),m("span",ue,"Payment Received")):x("",!0)]),"column-action":s(({row:e})=>[b("div",fe,[n(L)?(c(),V(S,{key:0,content:"Download CSV"},{default:s(()=>[l(n(_),{disabled:e.downloading,text:"",onClick:d=>U(e)},{default:s(()=>
1[l(r,{class:"text-primary cursor-pointer"})]),_:2},1032,["disabled","onClick"])]),_:2},1024)):x("",!0),l(S,{content:"Download PDF"},{default:s(()=>[l(n(_),{disabled:e.downloading,text:"",onClick:d=>j(e)},{default:s(()=>[l(u,{class:"text-primary cursor-pointer"})]),_:2},1032,["disabled","onClick"])]),_:2},1024)])]),_:1},8,["data","loading"])])}}},Fe=R(_e,[["__file","/home/jenkins/agent/workspace/PFGH_portal_main/node_modules/.pnpm/git+github.com+PacketFabric+core_ui@4f8c2c6c9c07c4d2bd5c00ac544234262725a95b_@packetfabric+ic_jvvagurvh5klwsd5tqjm5l3rie/node_modules/@packetfabric/core_ui/src/components/billing/BillingInvoices.vue"]]);export{Fe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.