mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-24 05:34:08 +00:00
2 lines
15 KiB
JavaScript
2 lines
15 KiB
JavaScript
import{a8 as M,L as N,v as Y,f as P,H as R,P as ee,k as E,r as u,o as l,c as b,b as o,a as e,w as n,l as a,t as x,m,N as G,O as X,K as p,J as q,p as V,Z as te,E as se,a5 as J,z as ae,n as ne,a7 as le,M as oe,e as re,Q as S}from"./main-WMXHPsTs.js";import{L as ce}from"./LoadingIcon--U35iTrM.js";import{_ as ie}from"./LineChart-SqnrSwOJ.js";import{_ as ue}from"./CustomerIndexDropdown-yAJT5lg8.js";const de={class:"fixed top-0 left-0 hidden h-full pt-16 pb-[6.6rem] ml-56 bg-white xl:ml-64 w-88 xl:block"},me={class:"flex items-center justify-between px-4 pt-8 pb-2 border border-gray-200 border-solid height-full"},_e={class:"flex mb-6 ml-3",role:"group","aria-label":"First group"},pe={class:"px-4 py-3 pb-2 mb-2 text-sm border-b border-gray-200 border-solid"},fe={class:"px-2"},he={class:"px-2"},ye={class:"flex-1 font-bold text-right whitespace-nowrap"},ge={key:0,class:"flex justify-center p-4 items-center"},ve={key:1,class:"flex justify-center px-4 mt-5 text-sm text-gray-600"},xe={__name:"CustomerViewSidebar",setup(j){const k=M(),t=N(),{t:d}=Y.useI18n();let r=P(!1),s=R({orderBy:null,orderByField:null,searchText:null});const _=P(null),h=P(1),y=P(1),I=P(null);i=ee.debounce(i,500);const f=E(()=>s.orderBy==="asc"||s.orderBy==null);E(()=>f.value?d("general.ascending"):d("general.descending"));function B(c){return t.params.id==c}async function g(c,w=!1){if(r.value)return;let C={};s.searchText!==""&&s.searchText!==null&&s.searchText!==void 0&&(C.display_name=s.searchText),s.orderBy!==null&&s.orderBy!==void 0&&(C.orderBy=s.orderBy),s.orderByField!==null&&s.orderByField!==void 0&&(C.orderByField=s.orderByField),r.value=!0;let F=await k.fetchCustomers({page:c,...C,limit:15});r.value=!1,_.value=_.value?_.value:[],_.value=[..._.value,...F.data.data],h.value=c||1,y.value=F.data.meta.last_page;let A=_.value.find(L=>L.id==t.params.id);w==!1&&!A&&h.value<y.value&&Object.keys(C).length===0&&g(++h.value),A&&setTimeout(()=>{w==!1&&$()},500)}function $(){const c=document.getElementById(`customer-${t.params.id}`);c&&(c.scrollIntoView({behavior:"smooth"}),c.classList.add("shake"),D())}function D(){I.value.addEventListener("scroll",c=>{c.target.scrollTop>0&&c.target.scrollTop+c.target.clientHeight>c.target.scrollHeight-200&&h.value<y.value&&g(++h.value,!0)})}async function i(){_.value=[],g()}function T(){return s.orderBy==="asc"?(s.orderBy="desc",i(),!0):(s.orderBy="asc",i(),!0)}return g(),(c,w)=>{var H;const C=u("BaseIcon"),F=u("BaseInput"),A=u("BaseButton"),L=u("BaseRadio"),O=u("BaseInputGroup"),U=u("BaseDropdownItem"),K=u("BaseDropdown"),z=u("BaseText"),Q=u("BaseFormatMoney"),Z=u("router-link");return l(),b("div",de,[o("div",me,[e(F,{modelValue:a(s).searchText,"onUpdate:modelValue":w[0]||(w[0]=v=>a(s).searchText=v),placeholder:c.$t("general.search"),"container-class":"mb-6",type:"text",variant:"gray",onInput:w[1]||(w[1]=v=>i())},{default:n(()=>[e(C,{name:"SearchIcon",class:"text-gray-500"})]),_:1},8,["modelValue","placeholder"]),o("div",_e,[e(K,{"close-on-select":!1,position:"bottom-start","width-class":"w-40","position-class":"left-0"},{activator:n(()=>[e(A,{variant:"gray"},{default:n(()=>[e(C,{name:"FilterIcon"})]),_:1})]),default:n(()=>[o("div",pe,x(c.$t("general.sort_by")),1),o("div",fe,[e(U,{class:"flex px-1 py-2 mt-1 cursor-pointer hover:rounded-md"},{default:n(()=>[e(O,{class:"pt-2 -mt-4"},{default:n(()=>[e(L,{id:"filter_create_date",modelValue:a(s).orderByField,"onUpdate:modelValue":[w[2]||(w[2]=v=>a(s).orderByField=v),i],label:c.$t("customers.create_date"),size:"sm",name:"filter",value:"invoices.created_at"},null,8,["modelValue","label"])]),_:1})]),_:1})]),o("div",he,[e(U,{class:"flex px-1 cursor-pointer hover:rounded-md"},{default:n(()=>[e(O,{class:"pt-2 -mt-4"},{default:n(()=>[e(L,{id:"filter_display_name",modelValue:a(s).orderByField,"onUpdate:modelValue":[w[3]||(w[3]=v=>a(s).orderByField=v),i],label:c.$t("customers.display_name"),size:"sm",name:"filter",value:"name"},null,8,["modelValue","label"])]),_:1})]),_:1})])]),_:1}),e(A,{class:"ml-1",size:"md",variant:"gray",onClick:T},{default:n(()=>[f.value?(l(),m(C,{key:0,name:"SortAscendingIcon"})):(l(),m(C,{key:1,name:"SortDescendingIcon"}))]),_:1})])]),o("div",{ref_key:"customerListSection",ref:I,class:"h-full overflow-y-scroll border-l border-gray-200 border-solid sidebar base-scroll"},[(l(!0),b(G,null,X(_.value,(v,W)=>(l(),b("div",{key:W},[v?(l(),m(Z,{key:0,id:"customer-"+v.id,to:`/admin/customers/${v.id}/view`,class:q(["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":B(v.id)}]),style:{"border-top":"1px solid rgba(185, 193, 209, 0.41)"}},{default:n(()=>[o("div",null,[e(z,{text:v.name,length:30,class:"pr-2 text-sm not-italic font-normal leading-5 text-black capitalize truncate"},null,8,["text"]),v.contact_name?(l(),m(z,{key:0,text:v.contact_name,length:30,class:"mt-1 text-xs not-italic font-medium leading-5 text-gray-600"},null,8,["text"])):p("",!0)]),o("div",ye,[e(Q,{amount:v.due_amount!==null?v.due_amount:0,currency:v.currency},null,8,["amount","currency"])])]),_:2},1032,["id","to","class"])):p("",!0)]))),128)),a(r)?(l(),b("div",ge,[e(ce,{class:"h-6 m-1 animate-spin text-primary-400"})])):p("",!0),!((H=_.value)!=null&&H.length)&&!a(r)?(l(),b("p",ve,x(c.$t("customers.no_matching_customers")),1)):p("",!0)],512)])}}},be={class:"pt-6 mt-5 border-t border-solid lg:pt-8 md:pt-4 border-gray-200"},Be={key:0,class:"text-sm font-bold leading-5 text-black non-italic"},$e={key:0},we={key:1},Ce={key:1,class:"text-sm font-bold leading-5 text-black non-italic"},ke={__name:"CustomerInfo",setup(j){const k=M(),t=E(()=>k.selectedViewCustomer),d=E(()=>k.isFetchingViewData),r=E(()=>{var s,_;return(s=t==null?void 0:t.value)!=null&&s.fields?(_=t==null?void 0:t.value)==null?void 0:_.fields:[]});return(s,_)=>{const h=u("BaseHeading"),y=u("BaseDescriptionListItem"),I=u("BaseDescriptionList"),f=u("BaseCustomerAddressDisplay");return l(),b("div",be,[e(h,null,{default:n(()=>[V(x(s.$t("customers.basic_info")),1)]),_:1}),e(I,null,{default:n(()=>{var B,g,$;return[e(y,{"content-loading":d.value,label:s.$t("customers.display_name"),value:(B=t.value)==null?void 0:B.name},null,8,["content-loading","label","value"]),e(y,{"content-loading":d.value,label:s.$t("customers.primary_contact_name"),value:(g=t.value)==null?void 0:g.contact_name},null,8,["content-loading","label","value"]),e(y,{"content-loading":d.value,label:s.$t("customers.email"),value:($=t.value)==null?void 0:$.email},null,8,["content-loading","label","value"])]}),_:1}),e(I,{class:"mt-5"},{default:n(()=>{var B,g,$,D,i,T,c;return[e(y,{"content-loading":d.value,label:s.$t("wizard.currency"),value:(B=t.value)!=null&&B.currency?`${($=(g=t.value)==null?void 0:g.currency)==null?void 0:$.code} (${(i=(D=t.value)==null?void 0:D.currency)==null?void 0:i.symbol})`:""},null,8,["content-loading","label","value"]),e(y,{"content-loading":d.value,label:s.$t("customers.phone_number"),value:(T=t.value)==null?void 0:T.phone},null,8,["content-loading","label","value"]),e(y,{"content-loading":d.value,label:s.$t("customers.website"),value:(c=t.value)==null?void 0:c.website},null,8,["content-loading","label","value"])]}),_:1}),t.value.billing||t.value.shipping?(l(),m(h,{key:0,class:"mt-8"},{default:n(()=>[V(x(s.$t("customers.address")),1)]),_:1})):p("",!0),e(I,{class:"mt-5"},{default:n(()=>[t.value.billing?(l(),m(y,{key:0,"content-loading":d.value,label:s.$t("customers.billing_address")},{default:n(()=>[e(f,{address:t.value.billing},null,8,["address"])]),_:1},8,["content-loading","label"])):p("",!0),t.value.shipping?(l(),m(y,{key:1,"content-loading":d.value,label:s.$t("customers.shipping_address")},{default:n(()=>[e(f,{address:t.value.shipping},null,8,["address"])]),_:1},8,["content-loading","label"])):p("",!0)]),_:1}),r.value.length>0?(l(),m(h,{key:1,class:"mt-8"},{default:n(()=>[V(x(s.$t("settings.custom_fields.title")),1)]),_:1})):p("",!0),e(I,{class:"mt-5"},{default:n(()=>[(l(!0),b(G,null,X(r.value,(B,g)=>(l(),m(y,{key:g,"content-loading":d.value,label:B.custom_field.label},{default:n(()=>[B.type==="Switch"?(l(),b("p",Be,[B.default_answer===1?(l(),b("span",$e," Yes ")):(l(),b("span",we," No "))])):(l(),b("p",Ce,x(B.default_answer),1))]),_:2},1032,["content-loading","label"]))),128))]),_:1})])}}},Te={},Ee={class:"col-span-12 xl:col-span-9 xxl:col-span-10"},Ie={class:"flex justify-between mt-1 mb-6"},De={class:"grid col-span-12 mt-6 text-center xl:mt-0 sm:grid-cols-4 xl:text-right xl:col-span-3 xl:grid-cols-1 xxl:col-span-2"},Se={class:"flex flex-col items-center justify-center px-6 py-2 lg:justify-end lg:items-end"},Ve={class:"flex flex-col items-center justify-center px-6 py-2 lg:justify-end lg:items-end"},Ae={class:"flex flex-col items-center justify-center px-6 py-2 lg:justify-end lg:items-end"},Pe={class:"flex flex-col items-center justify-center px-6 py-2 lg:justify-end lg:items-end"};function Fe(j,k){const t=u("BaseContentPlaceholdersText"),d=u("BaseContentPlaceholdersBox"),r=u("BaseContentPlaceholders");return l(),m(r,{class:"grid grid-cols-12"},{default:n(()=>[o("div",Ee,[o("div",Ie,[e(t,{class:"h-10 w-36",lines:1}),e(t,{class:"h-10 w-40 !mt-0",lines:1})]),e(d,{class:"h-80 xl:h-72 sm:w-full"})]),o("div",De,[o("div",Se,[e(t,{class:"h-3 w-14 xl:h-4",lines:1}),e(t,{class:"w-20 h-5 xl:h-6",lines:1})]),o("div",Ve,[e(t,{class:"h-3 w-14 xl:h-4",lines:1}),e(t,{class:"w-20 h-5 xl:h-6",lines:1})]),o("div",Ae,[e(t,{class:"h-3 w-14 xl:h-4",lines:1}),e(t,{class:"w-20 h-5 xl:h-6",lines:1})]),o("div",Pe,[e(t,{class:"h-3 w-14 xl:h-4",lines:1}),e(t,{class:"w-20 h-5 xl:h-6",lines:1})])])]),_:1})}const je=te(Te,[["render",Fe]]),Le={key:1,class:"grid grid-cols-12"},Re={class:"col-span-12 xl:col-span-9 xxl:col-span-10"},Me={class:"flex justify-between mt-1 mb-6"},Ne={class:"flex items-center"},Oe={class:"w-40 h-10"},Ue={class:"grid col-span-12 mt-6 text-center xl:mt-0 sm:grid-cols-4 xl:text-right xl:col-span-3 xl:grid-cols-1 xxl:col-span-2"},ze={class:"px-6 py-2"},He={class:"text-xs leading-5 lg:text-sm"},Ye=o("br",null,null,-1),Ge={key:0,class:"block mt-1 text-xl font-semibold leading-8"},Xe={class:"px-6 py-2"},qe={class:"text-xs leading-5 lg:text-sm"},Je=o("br",null,null,-1),Ke={key:0,class:"block mt-1 text-xl font-semibold leading-8",style:{color:"#00c99c"}},Qe={class:"px-6 py-2"},Ze={class:"text-xs leading-5 lg:text-sm"},We=o("br",null,null,-1),et={key:0,class:"block mt-1 text-xl font-semibold leading-8",style:{color:"#fb7178"}},tt={class:"px-6 py-2"},st={class:"text-xs leading-5 lg:text-sm"},at=o("br",null,null,-1),nt={key:0,class:"block mt-1 text-xl font-semibold leading-8",style:{color:"#5851d8"}},lt={__name:"CustomerChart",setup(j){se();const k=M();J("utils");const t=N();let d=P(!1),r=R({}),s=R({}),_=R(["This year","Previous year"]),h=P("This year");const y=E(()=>r.expenseTotals?r.expenseTotals:[]),I=E(()=>r.netProfits?r.netProfits:[]),f=E(()=>r&&r.months?r.months:[]),B=E(()=>r.receiptTotals?r.receiptTotals:[]),g=E(()=>r.invoiceTotals?r.invoiceTotals:[]);ae(t,()=>{t.params.id&&$(),h.value="This year"},{immediate:!0});async function $(){d.value=!1;let i=await k.fetchViewCustomer({id:t.params.id});i.data&&(Object.assign(r,i.data.meta.chartData),Object.assign(s,i.data.data)),d.value=!0}async function D(i){let T={id:t.params.id};i==="Previous year"?T.previous_year=!0:T.this_year=!0;let c=await k.fetchViewCustomer(T);return c.data.meta.chartData&&Object.assign(r,c.data.meta.chartData),!0}return(i,T)=>{const c=u("BaseIcon"),w=u("BaseMultiselect"),C=u("BaseFormatMoney"),F=u("BaseCard");return l(),m(F,{class:"flex flex-col mt-6"},{default:n(()=>[a(k).isFetchingViewData?(l(),m(je,{key:0})):(l(),b("div",Le,[o("div",Re,[o("div",Me,[o("h6",Ne,[e(c,{name:"ChartSquareBarIcon",class:"h-5 text-primary-400"}),V(" "+x(i.$t("dashboard.monthly_chart.title")),1)]),o("div",Oe,[e(w,{modelValue:a(h),"onUpdate:modelValue":T[0]||(T[0]=A=>ne(h)?h.value=A:h=A),options:a(_),"allow-empty":!1,"show-labels":!1,placeholder:i.$t("dashboard.select_year"),"can-deselect":!1,onSelect:D},null,8,["modelValue","options","placeholder"])])]),a(d)?(l(),m(ie,{key:0,invoices:g.value,expenses:y.value,receipts:B.value,income:I.value,labels:f.value,class:"sm:w-full"},null,8,["invoices","expenses","receipts","income","labels"])):p("",!0)]),o("div",Ue,[o("div",ze,[o("span",He,x(i.$t("dashboard.chart_info.total_sales")),1),Ye,a(d)?(l(),b("span",Ge,[e(C,{amount:a(r).salesTotal,currency:a(s).currency},null,8,["amount","currency"])])):p("",!0)]),o("div",Xe,[o("span",qe,x(i.$t("dashboard.chart_info.total_receipts")),1),Je,a(d)?(l(),b("span",Ke,[e(C,{amount:a(r).totalExpenses,currency:a(s).currency},null,8,["amount","currency"])])):p("",!0)]),o("div",Qe,[o("span",Ze,x(i.$t("dashboard.chart_info.total_expense")),1),We,a(d)?(l(),b("span",et,[e(C,{amount:a(r).totalExpenses,currency:a(s).currency},null,8,["amount","currency"])])):p("",!0)]),o("div",tt,[o("span",st,x(i.$t("dashboard.chart_info.net_income")),1),at,a(d)?(l(),b("span",nt,[e(C,{amount:a(r).netProfit,currency:a(s).currency},null,8,["amount","currency"])])):p("",!0)])])])),e(ke)]),_:1})}}},ut={__name:"View",setup(j){J("utils"),le();const k=M(),t=oe();Y.useI18n();const d=re(),r=N();P(null);const s=E(()=>k.selectedViewCustomer.customer?k.selectedViewCustomer.customer.name:"");let _=E(()=>k.isFetchingViewData);function h(){return t.hasAbilities([S.CREATE_ESTIMATE,S.CREATE_INVOICE,S.CREATE_PAYMENT,S.CREATE_EXPENSE])}function y(){return t.hasAbilities([S.DELETE_CUSTOMER,S.EDIT_CUSTOMER])}function I(){d.push("/admin/customers")}return(f,B)=>{const g=u("BaseButton"),$=u("router-link"),D=u("BaseIcon"),i=u("BaseDropdownItem"),T=u("BaseDropdown"),c=u("BasePageHeader"),w=u("BasePage");return l(),m(w,{class:"xl:pl-96"},{default:n(()=>[e(c,{title:s.value},{actions:n(()=>[a(t).hasAbilities(a(S).EDIT_CUSTOMER)?(l(),m($,{key:0,to:`/admin/customers/${a(r).params.id}/edit`},{default:n(()=>[e(g,{class:"mr-3",variant:"primary-outline","content-loading":a(_)},{default:n(()=>[V(x(f.$t("general.edit")),1)]),_:1},8,["content-loading"])]),_:1},8,["to"])):p("",!0),h()?(l(),m(T,{key:1,position:"bottom-end","content-loading":a(_)},{activator:n(()=>[e(g,{class:"mr-3",variant:"primary","content-loading":a(_)},{default:n(()=>[V(x(f.$t("customers.new_transaction")),1)]),_:1},8,["content-loading"])]),default:n(()=>[a(t).hasAbilities(a(S).CREATE_ESTIMATE)?(l(),m($,{key:0,to:`/admin/estimates/create?customer=${f.$route.params.id}`},{default:n(()=>[e(i,{class:""},{default:n(()=>[e(D,{name:"DocumentIcon",class:"mr-3 text-gray-600"}),V(" "+x(f.$t("estimates.new_estimate")),1)]),_:1})]),_:1},8,["to"])):p("",!0),a(t).hasAbilities(a(S).CREATE_INVOICE)?(l(),m($,{key:1,to:`/admin/invoices/create?customer=${f.$route.params.id}`},{default:n(()=>[e(i,null,{default:n(()=>[e(D,{name:"DocumentTextIcon",class:"mr-3 text-gray-600"}),V(" "+x(f.$t("invoices.new_invoice")),1)]),_:1})]),_:1},8,["to"])):p("",!0),a(t).hasAbilities(a(S).CREATE_PAYMENT)?(l(),m($,{key:2,to:`/admin/payments/create?customer=${f.$route.params.id}`},{default:n(()=>[e(i,null,{default:n(()=>[e(D,{name:"CreditCardIcon",class:"mr-3 text-gray-600"}),V(" "+x(f.$t("payments.new_payment")),1)]),_:1})]),_:1},8,["to"])):p("",!0),a(t).hasAbilities(a(S).CREATE_EXPENSE)?(l(),m($,{key:3,to:`/admin/expenses/create?customer=${f.$route.params.id}`},{default:n(()=>[e(i,null,{default:n(()=>[e(D,{name:"CalculatorIcon",class:"mr-3 text-gray-600"}),V(" "+x(f.$t("expenses.new_expense")),1)]),_:1})]),_:1},8,["to"])):p("",!0)]),_:1},8,["content-loading"])):p("",!0),y()?(l(),m(ue,{key:2,class:q({"ml-3":a(_)}),row:a(k).selectedViewCustomer,"load-data":I},null,8,["class","row"])):p("",!0)]),_:1},8,["title"]),e(xe),e(lt)]),_:1})}}};export{ut as default};
|