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