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