芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/public_html/invoicer.pulsehost.co.uk/public/build/assets/SalesTax-LST-awog.js
import{au as Z,F as W,M as oe,f as R,H as pe,a5 as ne,v as X,k as P,z as H,r as x,o as l,c as $,b as a,t as v,a as s,a6 as $e,l as m,w as c,p as q,m as C,K as O,E as ee,at as ye,L as we,P as K,g as z,h as G,aG as me,ai as te,aM as Ie,j as re,N as Q,O as J,Q as le,aP as Be,ao as fe,an as Pe,aQ as Se,J as Y,T as Te,aR as ke,aS as Me,as as Ce,u as De,I as Ve,X as xe,q as _e,G as je}from"./main-WS8l16KQ.js";import{D as Ee,d as qe}from"./DragIcon-Bhk7q250.js";import{_ as Ae}from"./SelectNotePopup-C-3WYDWX.js";const Le={class:"flex items-center justify-between mb-3"},Oe={class:"flex items-center text-base",style:{flex:"4"}},Ue={class:"pr-2 mb-0",align:"right"},ze={class:"absolute left-3.5"},Ne={class:"ml-2 text-sm leading-none cursor-pointer text-primary-400"},Fe=a("br",null,null,-1),Ge={class:"text-sm text-right",style:{flex:"3"}},Ye={class:"flex items-center justify-center w-6 h-10 mx-2 cursor-pointer"},Re={__name:"CreateItemRowTax",props:{ability:{type:String,default:""},store:{type:Object,default:null},storeProp:{type:String,default:""},itemIndex:{type:Number,required:!0},index:{type:Number,required:!0},taxData:{type:Object,required:!0},taxes:{type:Array,default:[]},total:{type:Number,default:0},totalTax:{type:Number,default:0},discountedTotal:{type:Number,default:0},currency:{type:[Object,String],required:!0},updateItems:{type:Function,default:()=>{}}},emits:["remove","update"],setup(t,{emit:_}){const e=t,r=_,w=Z(),b=W(),u=oe(),I=R(null),B=pe({...e.taxData});ne("utils");const{t:p}=X.useI18n(),V=P(()=>w.taxTypes.map(i=>({...i})).map(i=>(e.taxes.find(g=>g.tax_type_id===i.id)?i.disabled=!0:i.disabled=!1,i))),E=P(()=>{if(e.discountedTotal&&B.percent){const y=e.store[e.storeProp].tax_per_item==="YES",i=e.store[e.storeProp].discount_per_item==="YES";return y&&!i?d():e.discountedTotal*B.percent/100}return 0});H(()=>e.discountedTotal,()=>{S()}),H(()=>e.totalTax,()=>{S()}),H(()=>E.value,()=>{S()}),e.taxData.tax_type_id>0&&(I.value=w.taxTypes.find(y=>y.id===e.taxData.tax_type_id)),S();function A(y){B.percent=y.percent,B.tax_type_id=y.id,B.name=y.name,S()}function S(){B.tax_type_id!==0&&r("update",{index:e.index,item:{...B,amount:E.value}})}function o(){let y={itemIndex:e.itemIndex,taxIndex:e.index};b.openModal({title:p("settings.tax_types.add_tax"),componentName:"TaxTypeModal",data:y,size:"sm"})}function f(y){e.store.$patch(i=>{i[e.storeProp].items[e.itemIndex].taxes.splice(y,1),i[e.storeProp].items[e.itemIndex].tax=0,i[e.storeProp].items[e.itemIndex].totalTax=0})}function d(){let y=0,i=0;const n=e.discountedTotal,g=e.store[e.storeProp].discount?e.store[e.storeProp].discount:0,k=e.store[e.storeProp].discount_type;if(g>0){e.store[e.storeProp].items.forEach(h=>{y+=h.total});const M=(n/y).toFixed(2);i=k==="fixed"?g*100:y*g/100;const j=Math.round(i*M),D=n-j;return Math.round(D*B.percent/100)}return Math.round(e.discountedTotal*B.percent/100)}return(y,i)=>{const n=x("BaseIcon"),g=x("BaseMultiselect"),k=x("BaseFormatMoney");return l(),$("div",Le,[a("div",Oe,[a("label",Ue,v(y.$t("invoices.item.tax")),1),s(g,{modelValue:I.value,"onUpdate:modelValue":[i[0]||(i[0]=M=>I.value=M),i[1]||(i[1]=M=>A(M))],"value-prop":"id",options:V.value,placeholder:y.$t("general.select_a_tax"),"open-direction":"top","track-by":"name",searchable:"",object:"",label:"name"},$e({singlelabel:c(({value:M})=>[a("div",ze,v(M.name)+" - "+v(M.percent)+" % ",1)]),option:c(({option:M})=>[q(v(M.name)+" - "+v(M.percent)+" % ",1)]),_:2},[m(u).hasAbilities(t.ability)?{name:"action",fn:c(()=>[a("button",{type:"button",class:"flex items-center justify-center w-full px-2 py-2 bg-gray-200 border-none outline-none cursor-pointer",onClick:o},[s(n,{name:"CheckCircleIcon",class:"h-5 text-primary-400"}),a("label",Ne,v(y.$t("invoices.add_new_tax")),1)])]),key:"0"}:void 0]),1032,["modelValue","options","placeholder"]),Fe]),a("div",Ge,[s(k,{amount:E.value,currency:t.currency},null,8,["amount","currency"])]),a("div",Ye,[t.taxes.length&&t.index!==t.taxes.length-1?(l(),C(n,{key:0,name:"TrashIcon",class:"h-5 text-gray-700 cursor-pointer",onClick:i[2]||(i[2]=M=>f(t.index))})):O("",!0)])])}}},We={class:"box-border bg-white border border-gray-200 border-solid rounded-b"},Xe={colspan:"5",class:"p-0 text-left align-top"},Ke={class:"w-full"},Qe=a("col",{style:{width:"40%","min-width":"280px"}},null,-1),He=a("col",{style:{width:"10%","min-width":"120px"}},null,-1),Je=a("col",{style:{width:"15%","min-width":"120px"}},null,-1),Ze={key:0,style:{width:"15%","min-width":"160px"}},et=a("col",{style:{width:"15%","min-width":"120px"}},null,-1),tt={class:"px-5 py-4 text-left align-top"},st={class:"flex justify-start"},at={class:"flex items-center justify-center w-5 h-5 mt-2 mr-2 text-gray-300 cursor-move handle"},ot={class:"px-5 py-4 text-right align-top"},nt={class:"px-5 py-4 text-left align-top"},rt={class:"flex flex-col"},lt={class:"flex-auto flex-fill bd-highlight"},it={class:"relative w-full"},dt={key:0,class:"px-5 py-4 text-left align-top"},ct={class:"flex flex-col"},ut={class:"flex",style:{width:"120px"},role:"group"},mt={class:"flex items-center"},pt={class:"px-5 py-4 text-right align-top"},yt={class:"flex items-center justify-end text-sm"},ft={class:"flex items-center justify-center w-6 h-10 mx-2"},xt={key:0},_t=a("td",{class:"px-5 py-4 text-left align-top"},null,-1),gt={colspan:"4",class:"px-5 py-4 text-left align-top"},ht={__name:"CreateItemRow",props:{store:{type:Object,default:null},storeProp:{type:String,default:""},itemData:{type:Object,default:null},index:{type:Number,default:null},type:{type:String,default:""},loading:{type:Boolean,default:!1},currency:{type:[Object,String],required:!0},invoiceItems:{type:Array,required:!0},itemValidationScope:{type:String,default:""}},emits:["update","remove","itemValidate"],setup(t,{emit:_}){const e=t,r=ee(),w=ye();we();const{t:b}=X.useI18n(),u=P({get:()=>e.itemData.quantity,set:h=>{D("quantity",parseFloat(h))}}),I=P({get:()=>{const h=e.itemData.price;return parseFloat(h)>0?h/100:h},set:h=>{if(parseFloat(h)>0){let T=Math.round(h*100);D("price",T)}else D("price",h);i()}}),B=P(()=>Math.round(e.itemData.price*e.itemData.quantity)),p=P({get:()=>e.itemData.discount,set:h=>{D("discount",h),i()}}),V=P(()=>B.value-e.itemData.discount_val),E=P(()=>e.currency?e.currency:r.selectedCompanyCurrency),A=P(()=>e.store[e.storeProp].items.length!=1),S=P(()=>Math.round(K.sumBy(e.itemData.taxes,function(h){return h.amount?h.amount:0}))),o=P(()=>S.value),f={name:{required:z.withMessage(b("validation.required"),G)},quantity:{required:z.withMessage(b("validation.required"),G),minValue:z.withMessage(b("validation.qty_must_greater_than_zero"),me(0)),maxLength:z.withMessage(b("validation.amount_maxlength"),te(20))},price:{required:z.withMessage(b("validation.required"),G),minValue:z.withMessage(b("validation.number_length_minvalue"),me(1)),maxLength:z.withMessage(b("validation.price_maxlength"),te(20))},discount_val:{between:z.withMessage(b("validation.discount_maxlength"),Ie(0,P(()=>B.value)))},description:{maxLength:z.withMessage(b("validation.notes_maxlength"),te(65e3))}},d=re(f,P(()=>e.store[e.storeProp].items[e.index]),{$scope:e.itemValidationScope});function y(h){e.store.$patch(U=>{U[e.storeProp].items[e.index].taxes[h.index]=h.item});let T=e.itemData.taxes[e.itemData.taxes.length-1];(T==null?void 0:T.tax_type_id)!==0&&e.store.$patch(U=>{U[e.storeProp].items[e.index].taxes.push({...Be,id:fe.raw()})}),j()}function i(){const h=e.store[e.storeProp].items[e.index].discount;e.itemData.discount_type==="percentage"?D("discount_val",Math.round(B.value*h/100)):D("discount_val",Math.round(h*100))}function n(h){D("name",h)}function g(h){e.store.$patch(T=>{if(T[e.storeProp].items[e.index].name=h.name,T[e.storeProp].items[e.index].price=h.price,T[e.storeProp].items[e.index].item_id=h.id,T[e.storeProp].items[e.index].description=h.description,h.unit&&(T[e.storeProp].items[e.index].unit_name=h.unit.name),e.store[e.storeProp].tax_per_item==="YES"&&h.taxes){let U=0;h.taxes.forEach(F=>{y({index:U,item:{...F}}),U++})}T[e.storeProp].exchange_rate&&(T[e.storeProp].items[e.index].price/=T[e.storeProp].exchange_rate)}),w.fetchItems(),j()}function k(){e.itemData.discount_type!=="fixed"&&(D("discount_val",Math.round(e.itemData.discount*100)),D("discount_type","fixed"))}function M(){e.itemData.discount_type!=="percentage"&&(D("discount_val",B.value*e.itemData.discount/100),D("discount_type","percentage"))}function j(){var U,F;let h=(F=(U=e.store[e.storeProp])==null?void 0:U.items[e.index])==null?void 0:F.taxes;h||(h=[]);let T={...e.store[e.storeProp].items[e.index],index:e.index,total:V.value,sub_total:B.value,totalSimpleTax:S.value,totalTax:o.value,tax:o.value,taxes:[...h],tax_type_ids:h.flatMap(L=>L.tax_type_id?L.tax_type_id:[])};e.store.updateItem(T)}function D(h,T){e.store.$patch(U=>{U[e.storeProp].items[e.index][h]=T}),j()}return(h,T)=>{const U=x("BaseItemSelect"),F=x("BaseInput"),L=x("BaseMoney"),ie=x("BaseIcon"),ge=x("BaseButton"),de=x("BaseDropdownItem"),he=x("BaseDropdown"),ce=x("BaseContentPlaceholdersText"),ue=x("BaseContentPlaceholders"),ve=x("BaseFormatMoney");return l(),$("tr",We,[a("td",Xe,[a("table",Ke,[a("colgroup",null,[Qe,He,Je,t.store[t.storeProp].discount_per_item==="YES"?(l(),$("col",Ze)):O("",!0),et]),a("tbody",null,[a("tr",null,[a("td",tt,[a("div",st,[a("div",at,[s(Ee)]),s(U,{type:"Invoice",item:t.itemData,invalid:m(d).name.$error,"invalid-description":m(d).description.$error,taxes:t.itemData.taxes,index:t.index,"store-prop":t.storeProp,store:t.store,onSearch:n,onSelect:g},null,8,["item","invalid","invalid-description","taxes","index","store-prop","store"])])]),a("td",ot,[s(F,{modelValue:u.value,"onUpdate:modelValue":T[0]||(T[0]=N=>u.value=N),invalid:m(d).quantity.$error,"content-loading":t.loading,type:"number",small:"",min:"0",step:"any",onChange:T[1]||(T[1]=N=>j()),onInput:T[2]||(T[2]=N=>m(d).quantity.$touch())},null,8,["modelValue","invalid","content-loading"])]),a("td",nt,[a("div",rt,[a("div",lt,[a("div",it,[(l(),C(L,{key:E.value,modelValue:I.value,"onUpdate:modelValue":T[3]||(T[3]=N=>I.value=N),invalid:m(d).price.$error,"content-loading":t.loading,currency:E.value},null,8,["modelValue","invalid","content-loading","currency"]))])])])]),t.store[t.storeProp].discount_per_item==="YES"?(l(),$("td",dt,[a("div",ct,[a("div",ut,[s(F,{modelValue:p.value,"onUpdate:modelValue":T[4]||(T[4]=N=>p.value=N),invalid:m(d).discount_val.$error,"content-loading":t.loading,class:"border-r-0 focus:border-r-2 rounded-tr-sm rounded-br-sm h-[38px]"},null,8,["modelValue","invalid","content-loading"]),s(he,{position:"bottom-end"},{activator:c(()=>[s(ge,{"content-loading":t.loading,class:"rounded-tr-md rounded-br-md !p-2 rounded-none",type:"button",variant:"white"},{default:c(()=>[a("span",mt,[q(v(t.itemData.discount_type=="fixed"?t.currency.symbol:"%")+" ",1),s(ie,{name:"ChevronDownIcon",class:"w-4 h-4 ml-1 text-gray-500"})])]),_:1},8,["content-loading"])]),default:c(()=>[s(de,{onClick:k},{default:c(()=>[q(v(h.$t("general.fixed")),1)]),_:1}),s(de,{onClick:M},{default:c(()=>[q(v(h.$t("general.percentage")),1)]),_:1})]),_:1})])])])):O("",!0),a("td",pt,[a("div",yt,[a("span",null,[t.loading?(l(),C(ue,{key:0},{default:c(()=>[s(ce,{lines:1,class:"w-16 h-5"})]),_:1})):(l(),C(ve,{key:1,amount:V.value,currency:E.value},null,8,["amount","currency"]))]),a("div",ft,[A.value?(l(),C(ie,{key:0,class:"h-5 text-gray-700 cursor-pointer",name:"TrashIcon",onClick:T[5]||(T[5]=N=>t.store.removeItem(t.index))})):O("",!0)])])])]),t.store[t.storeProp].tax_per_item==="YES"?(l(),$("tr",xt,[_t,a("td",gt,[t.loading?(l(),C(ue,{key:0},{default:c(()=>[s(ce,{lines:1,class:"w-24 h-8 border rounded-md"})]),_:1})):(l(!0),$(Q,{key:1},J(t.itemData.taxes,(N,be)=>(l(),C(Re,{key:N.id,index:be,"item-index":t.index,"tax-data":N,taxes:t.itemData.taxes,"discounted-total":V.value,"total-tax":S.value,total:B.value,currency:t.currency,"update-items":j,ability:m(le).CREATE_INVOICE,store:t.store,"store-prop":t.storeProp,discount:p.value,onUpdate:y},null,8,["index","item-index","tax-data","taxes","discounted-total","total-tax","total","currency","ability","store","store-prop","discount"]))),128))])])):O("",!0)])])])])}}},vt={class:"text-center item-table min-w-full"},bt=a("col",{style:{width:"40%","min-width":"280px"}},null,-1),$t=a("col",{style:{width:"10%","min-width":"120px"}},null,-1),wt=a("col",{style:{width:"15%","min-width":"120px"}},null,-1),It={key:0,style:{width:"15%","min-width":"160px"}},Bt=a("col",{style:{width:"15%","min-width":"120px"}},null,-1),Pt={class:"bg-white border border-gray-200 border-solid"},St={class:"px-5 py-3 text-sm not-italic font-medium leading-5 text-left text-gray-700 border-t border-b border-gray-200 border-solid"},Tt={key:1,class:"pl-7"},kt={class:"px-5 py-3 text-sm not-italic font-medium leading-5 text-right text-gray-700 border-t border-b border-gray-200 border-solid"},Mt={key:1},Ct={class:"px-5 py-3 text-sm not-italic font-medium leading-5 text-left text-gray-700 border-t border-b border-gray-200 border-solid"},Dt={key:1},Vt={key:0,class:"px-5 py-3 text-sm not-italic font-medium leading-5 text-left text-gray-700 border-t border-b border-gray-200 border-solid"},jt={key:1},Et={class:"px-5 py-3 text-sm not-italic font-medium leading-5 text-right text-gray-700 border-t border-b border-gray-200 border-solid"},qt={key:1,class:"pr-10 column-heading"},zs={__name:"CreateItems",props:{store:{type:Object,default:null},storeProp:{type:String,default:""},currency:{type:[Object,String,null],required:!0},isLoading:{type:Boolean,default:!1},itemValidationScope:{type:String,default:""}},setup(t){const _=t,e=ee(),r=P(()=>_.currency?_.currency:e.selectedCompanyCurrency);return(w,b)=>{const u=x("BaseContentPlaceholdersText"),I=x("BaseContentPlaceholders"),B=x("BaseIcon");return l(),$(Q,null,[a("table",vt,[a("colgroup",null,[bt,$t,wt,t.store[t.storeProp].discount_per_item==="YES"?(l(),$("col",It)):O("",!0),Bt]),a("thead",Pt,[a("tr",null,[a("th",St,[t.isLoading?(l(),C(I,{key:0},{default:c(()=>[s(u,{lines:1,class:"w-16 h-5"})]),_:1})):(l(),$("span",Tt,v(w.$t("items.item",2)),1))]),a("th",kt,[t.isLoading?(l(),C(I,{key:0},{default:c(()=>[s(u,{lines:1,class:"w-16 h-5"})]),_:1})):(l(),$("span",Mt,v(w.$t("invoices.item.quantity")),1))]),a("th",Ct,[t.isLoading?(l(),C(I,{key:0},{default:c(()=>[s(u,{lines:1,class:"w-16 h-5"})]),_:1})):(l(),$("span",Dt,v(w.$t("invoices.item.price")),1))]),t.store[t.storeProp].discount_per_item==="YES"?(l(),$("th",Vt,[t.isLoading?(l(),C(I,{key:0},{default:c(()=>[s(u,{lines:1,class:"w-16 h-5"})]),_:1})):(l(),$("span",jt,v(w.$t("invoices.item.discount")),1))])):O("",!0),a("th",Et,[t.isLoading?(l(),C(I,{key:0},{default:c(()=>[s(u,{lines:1,class:"w-16 h-5"})]),_:1})):(l(),$("span",qt,v(w.$t("invoices.item.amount")),1))])])]),s(m(qe),{modelValue:t.store[t.storeProp].items,"onUpdate:modelValue":b[0]||(b[0]=p=>t.store[t.storeProp].items=p),"item-key":"id",tag:"tbody",handle:".handle"},{item:c(({element:p,index:V})=>[(l(),C(ht,{key:p.id,index:V,"item-data":p,loading:t.isLoading,currency:r.value,"item-validation-scope":t.itemValidationScope,"invoice-items":t.store[t.storeProp].items,store:t.store,"store-prop":t.storeProp},null,8,["index","item-data","loading","currency","item-validation-scope","invoice-items","store","store-prop"]))]),_:1},8,["modelValue"])]),a("div",{class:"flex items-center justify-center w-full px-6 py-3 text-base border border-t-0 border-gray-200 border-solid cursor-pointer text-primary-400 hover:bg-primary-100",onClick:b[1]||(b[1]=(...p)=>t.store.addItem&&t.store.addItem(...p))},[s(B,{name:"PlusCircleIcon",class:"mr-2"}),q(" "+v(w.$t("general.add_new_item")),1)])],64)}}},At={class:"flex items-center justify-between w-full mt-2 text-sm"},Lt={class:"font-semibold leading-5 text-gray-500 uppercase"},Ot={class:"flex items-center justify-center text-lg text-black"},Ut={__name:"CreateTotalTaxes",props:{index:{type:Number,required:!0},tax:{type:Object,required:!0},taxes:{type:Array,required:!0},currency:{type:[Object,String],required:!0},store:{type:Object,default:null},data:{type:String,default:""}},emits:["update","remove"],setup(t,{emit:_}){const e=t,r=_;ne("$utils");const w=P(()=>e.tax.compound_tax&&e.store.getSubtotalWithDiscount?Math.round((e.store.getSubtotalWithDiscount+e.store.getTotalSimpleTax)*e.tax.percent/100):e.store.getSubtotalWithDiscount&&e.tax.percent?Math.round(e.store.getSubtotalWithDiscount*e.tax.percent/100):0);Pe(()=>{e.store.getSubtotalWithDiscount&&b(),e.store.getTotalSimpleTax&&b()});function b(){r("update",{...e.tax,amount:w.value})}return(u,I)=>{const B=x("BaseFormatMoney"),p=x("BaseIcon");return l(),$("div",At,[a("label",Lt,v(t.tax.name)+" ("+v(t.tax.percent)+" %) ",1),a("label",Ot,[s(B,{amount:t.tax.amount,currency:t.currency},null,8,["amount","currency"]),s(p,{name:"TrashIcon",class:"h-5 ml-2 cursor-pointer",onClick:I[0]||(I[0]=V=>u.$emit("remove",t.tax.id))})])])}}},zt={class:"w-full mt-4 tax-select"},Nt={class:"relative w-full max-w-md px-4"},Ft={class:"overflow-hidden rounded-md shadow-lg ring-1 ring-black ring-opacity-5"},Gt={class:"relative bg-white"},Yt={class:"relative p-4"},Rt={key:0,class:"relative flex flex-col overflow-auto list max-h-36 border-t border-gray-200"},Wt=["onClick"],Xt={class:"flex justify-between px-2"},Kt={class:"m-0 text-base font-semibold leading-tight text-gray-700 cursor-pointer"},Qt={class:"m-0 text-base font-semibold text-gray-700 cursor-pointer"},Ht={key:1,class:"flex justify-center p-5 text-gray-400"},Jt={class:"text-base text-gray-500 cursor-pointer"},Zt={class:"m-0 ml-3 text-sm leading-none cursor-pointer font-base text-primary-400"},es={__name:"SelectTaxPopup",props:{type:{type:String,default:null},store:{type:Object,default:null},storeProp:{type:String,default:""}},emits:["select:taxType"],setup(t,{emit:_}){const e=t,r=_,w=W(),b=Z(),u=oe(),{t:I}=X.useI18n(),B=R(null),p=P(()=>B.value?b.taxTypes.filter(function(S){return S.name.toLowerCase().indexOf(B.value.toLowerCase())!==-1}):b.taxTypes),V=P(()=>e.store[e.storeProp].taxes);function E(S,o){r("select:taxType",{...S}),o()}function A(){w.openModal({title:I("settings.tax_types.add_tax"),componentName:"TaxTypeModal",size:"sm",refreshData:S=>r("select:taxType",S)})}return(S,o)=>{const f=x("BaseIcon"),d=x("BaseInput");return l(),$("div",zt,[s(m(Me),{class:"relative"},{default:c(({isOpen:y})=>[s(m(Se),{class:Y([y?"":"text-opacity-90","flex items-center text-sm font-medium text-primary-400 focus:outline-none focus:border-none"])},{default:c(()=>[s(f,{name:"PlusIcon",class:"w-4 h-4 font-medium text-primary-400"}),q(" "+v(S.$t("settings.tax_types.add_tax")),1)]),_:2},1032,["class"]),a("div",Nt,[s(Te,{"enter-active-class":"transition duration-200 ease-out","enter-from-class":"translate-y-1 opacity-0","enter-to-class":"translate-y-0 opacity-100","leave-active-class":"transition duration-150 ease-in","leave-from-class":"translate-y-0 opacity-100","leave-to-class":"translate-y-1 opacity-0"},{default:c(()=>[s(m(ke),{style:{"min-width":"350px","margin-left":"62px",top:"-28px"},class:"absolute z-10 px-4 py-2 -translate-x-full sm:px-0"},{default:c(({close:i})=>[a("div",Ft,[a("div",Gt,[a("div",Yt,[s(d,{modelValue:B.value,"onUpdate:modelValue":o[0]||(o[0]=n=>B.value=n),placeholder:S.$t("general.search"),type:"text",class:"text-black"},null,8,["modelValue","placeholder"])]),p.value.length>0?(l(),$("div",Rt,[(l(!0),$(Q,null,J(p.value,(n,g)=>(l(),$("div",{key:g,class:Y([{"bg-gray-100 cursor-not-allowed opacity-50 pointer-events-none":V.value.find(k=>k.tax_type_id===n.id)},"px-6 py-4 border-b border-gray-200 border-solid cursor-pointer hover:bg-gray-100 hover:cursor-pointer last:border-b-0"]),tabindex:"2",onClick:k=>E(n,i)},[a("div",Xt,[a("label",Kt,v(n.name),1),a("label",Qt,v(n.percent)+" % ",1)])],10,Wt))),128))])):(l(),$("div",Ht,[a("label",Jt,v(S.$t("general.no_tax_found")),1)]))]),m(u).hasAbilities(m(le).CREATE_TAX_TYPE)?(l(),$("button",{key:0,type:"button",class:"flex items-center justify-center w-full h-10 px-2 py-3 bg-gray-200 border-none outline-none",onClick:A},[s(f,{name:"CheckCircleIcon",class:"text-primary-400"}),a("label",Zt,v(S.$t("estimates.add_new_tax")),1)])):O("",!0)])]),_:1})]),_:1})])]),_:1})])}}},ts={class:"px-5 py-4 mt-6 bg-white border border-gray-200 border-solid rounded md:min-w-[390px] min-w-[300px] lg:mt-7"},ss={class:"flex items-center justify-between w-full"},as={key:1,class:"text-sm font-semibold leading-5 text-gray-400 uppercase"},os={key:3,class:"flex items-center justify-center m-0 text-lg text-black uppercase"},ns={key:1,class:"m-0 text-sm font-semibold leading-5 text-gray-500 uppercase"},rs={key:3,class:"flex items-center justify-center m-0 text-lg text-black uppercase"},ls={key:0,class:"flex items-center justify-between w-full mt-2"},is={key:1,class:"text-sm font-semibold leading-5 text-gray-400 uppercase"},ds={key:3,class:"flex",style:{width:"140px"},role:"group"},cs={class:"flex items-center"},us={key:1},ms={class:"flex items-center justify-between w-full pt-2 mt-5 border-t border-gray-200 border-solid"},ps={key:1,class:"m-0 text-sm font-semibold leading-5 text-gray-400 uppercase"},ys={key:3,class:"flex items-center justify-center text-lg uppercase text-primary-400"},Ns={__name:"CreateTotal",props:{store:{type:Object,default:null},storeProp:{type:String,default:""},taxPopupType:{type:String,default:""},currency:{type:[Object,String],default:""},isLoading:{type:Boolean,default:!1}},setup(t){const _=R(null),e=t;ne("$utils");const r=ee();H(()=>e.store[e.storeProp].items,o=>{B()},{deep:!0});const w=P({get:()=>e.store[e.storeProp].discount,set:o=>{e.store[e.storeProp].discount=o,B()}}),b=P({get:()=>e.store[e.storeProp].taxes,set:o=>{e.store.$patch(f=>{f[e.storeProp].taxes=o})}}),u=P(()=>{let o=[];return e.store[e.storeProp].items.forEach(f=>{f.taxes&&f.taxes.forEach(d=>{let y=o.find(i=>i.tax_type_id===d.tax_type_id);y?y.amount+=d.amount:d.tax_type_id&&o.push({tax_type_id:d.tax_type_id,amount:Math.round(d.amount),percent:d.percent,name:d.name})})}),o}),I=P(()=>e.currency?e.currency:r.selectedCompanyCurrency);function B(){const o=e.store[e.storeProp].discount;if(e.store[e.storeProp].discount_type==="percentage"){e.store[e.storeProp].discount_val=Math.round(e.store.getSubTotal*o/100);return}e.store[e.storeProp].discount_val=Math.round(o*100)}function p(){e.store[e.storeProp].discount_type!=="fixed"&&(e.store[e.storeProp].discount_val=Math.round(e.store[e.storeProp].discount*100),e.store[e.storeProp].discount_type="fixed")}function V(){if(e.store[e.storeProp].discount_type==="percentage")return;const o=Math.round(e.store[e.storeProp].discount*100)/100;e.store[e.storeProp].discount_val=Math.round(e.store.getSubTotal*o/100),e.store[e.storeProp].discount_type="percentage"}function E(o){let f=0;e.store.getSubtotalWithDiscount&&o.percent&&(f=Math.round(e.store.getSubtotalWithDiscount*o.percent/100));let d={...le,id:fe.raw(),name:o.name,percent:o.percent,tax_type_id:o.id,amount:f};e.store.$patch(y=>{y[e.storeProp].taxes.push({...d})})}function A(o){const f=e.store[e.storeProp].taxes.find(d=>d.id===o.id);f&&Object.assign(f,{...o})}function S(o){const f=e.store[e.storeProp].taxes.findIndex(d=>d.id===o);e.store.$patch(d=>{d[e.storeProp].taxes.splice(f,1)})}return(o,f)=>{const d=x("BaseContentPlaceholdersText"),y=x("BaseContentPlaceholders"),i=x("BaseFormatMoney"),n=x("BaseInput"),g=x("BaseIcon"),k=x("BaseButton"),M=x("BaseDropdownItem"),j=x("BaseDropdown");return l(),$("div",ts,[a("div",ss,[t.isLoading?(l(),C(y,{key:0},{default:c(()=>[s(d,{lines:1,class:"w-16 h-5"})]),_:1})):(l(),$("label",as,v(o.$t("estimates.sub_total")),1)),t.isLoading?(l(),C(y,{key:2},{default:c(()=>[s(d,{lines:1,class:"w-16 h-5"})]),_:1})):(l(),$("label",os,[s(i,{amount:t.store.getSubTotal,currency:I.value},null,8,["amount","currency"])]))]),(l(!0),$(Q,null,J(u.value,D=>(l(),$("div",{key:D.tax_type_id,class:"flex items-center justify-between w-full"},[t.isLoading?(l(),C(y,{key:0},{default:c(()=>[s(d,{lines:1,class:"w-16 h-5"})]),_:1})):t.store[t.storeProp].tax_per_item==="YES"?(l(),$("label",ns,v(D.name)+" - "+v(D.percent)+"% ",1)):O("",!0),t.isLoading?(l(),C(y,{key:2},{default:c(()=>[s(d,{lines:1,class:"w-16 h-5"})]),_:1})):t.store[t.storeProp].tax_per_item==="YES"?(l(),$("label",rs,[s(i,{amount:D.amount,currency:I.value},null,8,["amount","currency"])])):O("",!0)]))),128)),t.store[t.storeProp].discount_per_item==="NO"||t.store[t.storeProp].discount_per_item===null?(l(),$("div",ls,[t.isLoading?(l(),C(y,{key:0},{default:c(()=>[s(d,{lines:1,class:"w-16 h-5"})]),_:1})):(l(),$("label",is,v(o.$t("estimates.discount")),1)),t.isLoading?(l(),C(y,{key:2},{default:c(()=>[s(d,{lines:1,class:"w-24 h-8 border rounded-md"})]),_:1})):(l(),$("div",ds,[s(n,{modelValue:w.value,"onUpdate:modelValue":f[0]||(f[0]=D=>w.value=D),class:"border-r-0 focus:border-r-2 rounded-tr-sm rounded-br-sm h-[38px]"},null,8,["modelValue"]),s(j,{position:"bottom-end"},{activator:c(()=>[s(k,{class:"p-2 rounded-none rounded-tr-md rounded-br-md",type:"button",variant:"white"},{default:c(()=>[a("span",cs,[q(v(t.store[t.storeProp].discount_type=="fixed"?I.value.symbol:"%")+" ",1),s(g,{name:"ChevronDownIcon",class:"w-4 h-4 ml-1 text-gray-500"})])]),_:1})]),default:c(()=>[s(M,{onClick:p},{default:c(()=>[q(v(o.$t("general.fixed")),1)]),_:1}),s(M,{onClick:V},{default:c(()=>[q(v(o.$t("general.percentage")),1)]),_:1})]),_:1})]))])):O("",!0),t.store[t.storeProp].tax_per_item==="NO"||t.store[t.storeProp].tax_per_item===null?(l(),$("div",us,[(l(!0),$(Q,null,J(b.value,(D,h)=>(l(),C(Ut,{key:D.id,index:h,tax:D,taxes:b.value,currency:t.currency,store:t.store,onRemove:S,onUpdate:A},null,8,["index","tax","taxes","currency","store"]))),128))])):O("",!0),t.store[t.storeProp].tax_per_item==="NO"||t.store[t.storeProp].tax_per_item===null?(l(),$("div",{key:2,ref_key:"taxModal",ref:_,class:"float-right pt-2 pb-4"},[s(es,{"store-prop":t.storeProp,store:t.store,type:t.taxPopupType,"onSelect:taxType":E},null,8,["store-prop","store","type"])],512)):O("",!0),a("div",ms,[t.isLoading?(l(),C(y,{key:0},{default:c(()=>[s(d,{lines:1,class:"w-16 h-5"})]),_:1})):(l(),$("label",ps,v(o.$t("estimates.total"))+" "+v(o.$t("estimates.amount"))+":",1)),t.isLoading?(l(),C(y,{key:2},{default:c(()=>[s(d,{lines:1,class:"w-16 h-5"})]),_:1})):(l(),$("label",ys,[s(i,{amount:t.store.getTotal,currency:I.value},null,8,["amount","currency"])]))])])}}},fs={class:"flex text-gray-800 font-medium text-sm mb-2"},xs=a("span",{class:"text-sm text-red-500"}," *",-1),Fs={__name:"SelectTemplateButton",props:{store:{type:Object,default:null},storeProp:{type:String,default:""},isMarkAsDefault:{type:Boolean,default:!1}},setup(t){const _=t,e=W(),{t:r}=X.useI18n();function w(){let b="";_.storeProp=="newEstimate"?b=r("estimates.mark_as_default_estimate_template_description"):_.storeProp=="newInvoice"&&(b=r("invoices.mark_as_default_invoice_template_description")),e.openModal({title:r("general.choose_template"),componentName:"SelectTemplate",data:{templates:_.store.templates,store:_.store,storeProp:_.storeProp,isMarkAsDefault:_.isMarkAsDefault,markAsDefaultDescription:b}})}return(b,u)=>{const I=x("BaseIcon"),B=x("BaseButton");return l(),$("div",null,[a("label",fs,[q(v(b.$t("general.select_template"))+" ",1),xs]),s(B,{type:"button",class:"flex justify-center w-full text-sm lg:w-auto hover:bg-gray-200",variant:"gray",onClick:w},{right:c(p=>[s(I,{name:"PencilIcon",class:Y(p.class)},null,8,["class"])]),default:c(()=>[q(" "+v(t.store[t.storeProp].template_name),1)]),_:1})])}}},_s={class:"mb-6"},gs={class:"z-20 text-sm font-semibold leading-5 text-primary-400 float-right"},hs={class:"text-gray-800 font-medium mb-4 text-sm"},Gs={__name:"CreateNotesField",props:{store:{type:Object,default:null},storeProp:{type:String,default:""},fields:{type:Object,default:null},type:{type:String,default:null}},setup(t){const _=t;function e(r){_.store[_.storeProp].notes=""+r.notes}return(r,w)=>{const b=x("BaseCustomInput");return l(),$("div",_s,[a("div",gs,[s(Ae,{type:t.type,onSelect:e},null,8,["type"])]),a("label",hs,v(r.$t("invoices.notes")),1),s(b,{modelValue:t.store[t.storeProp].notes,"onUpdate:modelValue":w[0]||(w[0]=u=>t.store[t.storeProp].notes=u),"content-loading":t.store.isFetchingInitialSettings,fields:t.fields,class:"mt-1"},null,8,["modelValue","content-loading","fields"])])}}},vs={class:"flex justify-between w-full"},bs={class:"px-8 py-8 sm:p-6"},$s={key:0,class:"grid grid-cols-3 gap-2 p-1 overflow-x-auto"},ws=["onClick"],Is=["src","alt"],Bs=["alt","src"],Ps={key:1,class:"z-0 flex ml-3 pt-5"},Ss={class:"z-0 flex justify-end p-4 border-t border-gray-200 border-solid"},Ys={__name:"SelectTemplateModal",setup(t){const _=W(),e=oe(),r=R(""),w=P(()=>_.active&&_.componentName==="SelectTemplate"),b=P(()=>_.title);function u(){_.data.store[_.data.storeProp].template_name?r.value=_.data.store[_.data.storeProp].template_name:r.value=_.data.templates[0]}async function I(){await _.data.store.setTemplate(r.value),!_.data.store.isEdit&&_.data.isMarkAsDefault&&(_.data.storeProp=="newEstimate"?await e.updateUserSettings({settings:{default_estimate_template:r.value}}):_.data.storeProp=="newInvoice"&&await e.updateUserSettings({settings:{default_invoice_template:r.value}})),p()}function B(){return new URL("/build/assets/tick-BkKo8A3q.png",import.meta.url)}function p(){_.closeModal(),setTimeout(()=>{_.$reset()},300)}return(V,E)=>{const A=x("BaseIcon"),S=x("BaseCheckbox"),o=x("BaseButton"),f=x("BaseModal");return l(),C(f,{show:w.value,onClose:p,onOpen:u},{header:c(()=>[a("div",vs,[q(v(b.value)+" ",1),s(A,{name:"XIcon",class:"h-6 w-6 text-gray-500 cursor-pointer",onClick:p})])]),default:c(()=>[a("div",bs,[m(_).data?(l(),$("div",$s,[(l(!0),$(Q,null,J(m(_).data.templates,(d,y)=>(l(),$("div",{key:y,class:Y([{"border border-solid border-primary-500":r.value===d.name},"relative flex flex-col m-2 border border-gray-200 border-solid cursor-pointer hover:border-primary-300"]),onClick:i=>r.value=d.name},[a("img",{src:d.path,alt:d.name,class:"w-full min-h-[100px]"},null,8,Is),r.value===d.name?(l(),$("img",{key:0,alt:d.name,class:"absolute z-10 w-5 h-5 text-primary-500",style:{top:"-6px",right:"-5px"},src:B()},null,8,Bs)):O("",!0),a("span",{class:Y(["w-full p-1 bg-gray-200 text-sm text-center absolute bottom-0 left-0",{"text-primary-500 bg-primary-100":r.value===d.name,"text-gray-600":r.value!=d.name}])},v(d.name),3)],10,ws))),128))])):O("",!0),m(_).data.store.isEdit?O("",!0):(l(),$("div",Ps,[s(S,{modelValue:m(_).data.isMarkAsDefault,"onUpdate:modelValue":E[0]||(E[0]=d=>m(_).data.isMarkAsDefault=d),"set-initial-value":!1,variant:"primary",label:V.$t("general.mark_as_default"),description:m(_).data.markAsDefaultDescription},null,8,["modelValue","label","description"])]))]),a("div",Ss,[s(o,{class:"mr-3",variant:"primary-outline",onClick:p},{default:c(()=>[q(v(V.$t("general.cancel")),1)]),_:1}),s(o,{variant:"primary",onClick:E[1]||(E[1]=d=>I())},{left:c(d=>[s(A,{name:"SaveIcon",class:Y(d.class)},null,8,["class"])]),default:c(()=>[q(" "+v(V.$t("general.choose")),1)]),_:1})])]),_:1},8,["show"])}}},Ts={class:"flex justify-between w-full"},ks={class:"item-modal"},Ms={class:"px-8 py-8 sm:p-6"},Cs={class:"z-0 flex justify-end p-4 border-t border-gray-200 border-solid"},Rs={__name:"ItemModal",emits:["newItem"],setup(t,{emit:_}){const e=W(),r=ye(),w=ee(),b=Z();Ce(),De();const{t:u}=X.useI18n(),I=R(!1),B=R(w.selectedCompanySettings.tax_per_item),p=P(()=>e.active&&e.componentName==="ItemModal"),V=P({get:()=>r.currentItem.price/100,set:i=>{r.currentItem.price=Math.round(i*100)}}),E=P({get:()=>r.currentItem.taxes.map(i=>{if(i)return{...i,tax_type_id:i.id,tax_name:i.name+" ("+i.percent+"%)"}}),set:i=>{r.$patch(n=>{n.currentItem.taxes=i})}}),A=P(()=>B.value==="YES"),S={name:{required:z.withMessage(u("validation.required"),G),minLength:z.withMessage(u("validation.name_min_length",{count:3}),Ve(3))},description:{maxLength:z.withMessage(u("validation.description_maxlength",{count:255}),te(255))}},o=re(S,P(()=>r.currentItem)),f=P(()=>b.taxTypes.map(i=>({...i,tax_name:i.name+" ("+i.percent+"%)"})));xe(()=>{o.value.$reset(),r.fetchItemUnits({limit:"all"})});async function d(){if(o.value.$touch(),o.value.$invalid)return!0;let i={...r.currentItem,taxes:r.currentItem.taxes.map(g=>({tax_type_id:g.id,amount:V.value*g.percent/100,percent:g.percent,name:g.name,collective_tax:0}))};I.value=!0,await(r.isEdit?r.updateItem:r.addItem)(i).then(g=>{I.value=!1,g.data.data&&e.data&&e.refreshData(g.data.data),y()})}function y(){e.closeModal(),setTimeout(()=>{r.resetCurrentItem(),e.$reset(),o.value.$reset()},300)}return(i,n)=>{const g=x("BaseIcon"),k=x("BaseInput"),M=x("BaseInputGroup"),j=x("BaseMoney"),D=x("BaseMultiselect"),h=x("BaseTextarea"),T=x("BaseInputGrid"),U=x("BaseButton"),F=x("BaseModal");return l(),C(F,{show:p.value,onClose:y},{header:c(()=>[a("div",Ts,[q(v(m(e).title)+" ",1),s(g,{name:"XIcon",class:"h-6 w-6 text-gray-500 cursor-pointer",onClick:y})])]),default:c(()=>[a("div",ks,[a("form",{action:"",onSubmit:_e(d,["prevent"])},[a("div",Ms,[s(T,{layout:"one-column"},{default:c(()=>[s(M,{label:i.$t("items.name"),required:"",error:m(o).name.$error&&m(o).name.$errors[0].$message},{default:c(()=>[s(k,{modelValue:m(r).currentItem.name,"onUpdate:modelValue":n[0]||(n[0]=L=>m(r).currentItem.name=L),type:"text",invalid:m(o).name.$error,onInput:n[1]||(n[1]=L=>m(o).name.$touch())},null,8,["modelValue","invalid"])]),_:1},8,["label","error"]),s(M,{label:i.$t("items.price")},{default:c(()=>[(l(),C(j,{key:m(w).selectedCompanyCurrency,modelValue:V.value,"onUpdate:modelValue":n[2]||(n[2]=L=>V.value=L),currency:m(w).selectedCompanyCurrency,class:"relative w-full focus:border focus:border-solid focus:border-primary"},null,8,["modelValue","currency"]))]),_:1},8,["label"]),s(M,{label:i.$t("items.unit")},{default:c(()=>[s(D,{modelValue:m(r).currentItem.unit_id,"onUpdate:modelValue":n[3]||(n[3]=L=>m(r).currentItem.unit_id=L),label:"name",options:m(r).itemUnits,"value-prop":"id","can-deselect":!1,"can-clear":!1,placeholder:i.$t("items.select_a_unit"),searchable:"","track-by":"name"},null,8,["modelValue","options","placeholder"])]),_:1},8,["label"]),A.value?(l(),C(M,{key:0,label:i.$t("items.taxes")},{default:c(()=>[s(D,{modelValue:E.value,"onUpdate:modelValue":n[4]||(n[4]=L=>E.value=L),options:f.value,mode:"tags",label:"tax_name","value-prop":"id",class:"w-full","can-deselect":!1,"can-clear":!1,searchable:"","track-by":"tax_name",object:""},null,8,["modelValue","options"])]),_:1},8,["label"])):O("",!0),s(M,{label:i.$t("items.description"),error:m(o).description.$error&&m(o).description.$errors[0].$message},{default:c(()=>[s(h,{modelValue:m(r).currentItem.description,"onUpdate:modelValue":n[5]||(n[5]=L=>m(r).currentItem.description=L),rows:"4",cols:"50",invalid:m(o).description.$error,onInput:n[6]||(n[6]=L=>m(o).description.$touch())},null,8,["modelValue","invalid"])]),_:1},8,["label","error"])]),_:1})]),a("div",Cs,[s(U,{class:"mr-3",variant:"primary-outline",type:"button",onClick:y},{default:c(()=>[q(v(i.$t("general.cancel")),1)]),_:1}),s(U,{loading:I.value,disabled:I.value,variant:"primary",type:"submit"},{left:c(L=>[s(g,{name:"SaveIcon",class:Y(L.class)},null,8,["class"])]),default:c(()=>[q(" "+v(m(r).isEdit?i.$t("general.update"):i.$t("general.save")),1)]),_:1},8,["loading","disabled"])])],32)])]),_:1},8,["show"])}}},Ds={class:"flex justify-between w-full"},Vs={class:"flex flex-col"},js={class:"text-sm text-gray-500 mt-1"},Es={class:"p-4 sm:p-6"},qs={class:"z-0 flex justify-end p-4 border-t border-gray-200 border-solid"},As={__name:"TaxationAddressModal",emits:["addTax"],setup(t,{emit:_}){const e=W();je();const r=pe({state:"",city:"",address_street_1:"",zip:""}),w=R(!1),b=Z(),{t:u}=X.useI18n(),I=P(()=>e.active&&e.componentName==="TaxationAddressModal"),B=P(()=>({state:{required:z.withMessage(u("validation.required"),G)},city:{required:z.withMessage(u("validation.required"),G)},address_street_1:{required:z.withMessage(u("validation.required"),G)},zip:{required:z.withMessage(u("validation.required"),G)}})),p=re(B,P(()=>r));async function V(){if(p.value.$touch(),p.value.$invalid)return!0;let o={address:r};e.id&&(o.customer_id=e.id),r.address_street_1=r.address_street_1.replace(/(\r\n|\n|\r)/gm,""),w.value=!0,await b.fetchSalesTax(o).then(f=>{w.value=!1,E("addTax",f.data.data),S()}).catch(f=>{w.value=!1})}const E=_;function A(){var o,f,d,y;r.state=(o=e==null?void 0:e.data)==null?void 0:o.state,r.city=(f=e==null?void 0:e.data)==null?void 0:f.city,r.address_street_1=(d=e==null?void 0:e.data)==null?void 0:d.address_street_1,r.zip=(y=e==null?void 0:e.data)==null?void 0:y.zip}function S(){e.closeModal()}return(o,f)=>{const d=x("BaseIcon"),y=x("BaseInput"),i=x("BaseInputGroup"),n=x("BaseTextarea"),g=x("BaseInputGrid"),k=x("BaseButton"),M=x("BaseModal");return l(),C(M,{show:I.value,onClose:S,onOpen:A},{header:c(()=>[a("div",Ds,[a("div",Vs,[q(v(m(e).title)+" ",1),a("p",js,v(m(e).content),1)]),s(d,{name:"XIcon",class:"h-6 w-6 text-gray-500 cursor-pointer",onClick:S})])]),default:c(()=>[a("form",{onSubmit:_e(V,["prevent"])},[a("div",Es,[s(g,{layout:"one-column"},{default:c(()=>[s(i,{required:"",error:m(p).state.$error&&m(p).state.$errors[0].$message,label:o.$t("customers.state")},{default:c(()=>[s(y,{modelValue:r.state,"onUpdate:modelValue":f[0]||(f[0]=j=>r.state=j),type:"text",name:"shippingState",class:"mt-1 md:mt-0",invalid:m(p).state.$error,onInput:f[1]||(f[1]=j=>m(p).state.$touch()),placeholder:o.$t("settings.taxations.state_placeholder")},null,8,["modelValue","invalid","placeholder"])]),_:1},8,["error","label"]),s(i,{required:"",error:m(p).city.$error&&m(p).city.$errors[0].$message,label:o.$t("customers.city")},{default:c(()=>[s(y,{modelValue:r.city,"onUpdate:modelValue":f[2]||(f[2]=j=>r.city=j),type:"text",name:"shippingCity",class:"mt-1 md:mt-0",invalid:m(p).city.$error,onInput:f[3]||(f[3]=j=>m(p).city.$touch()),placeholder:o.$t("settings.taxations.city_placeholder")},null,8,["modelValue","invalid","placeholder"])]),_:1},8,["error","label"]),s(i,{required:"",error:m(p).address_street_1.$error&&m(p).address_street_1.$errors[0].$message,label:o.$t("customers.address")},{default:c(()=>[s(n,{modelValue:r.address_street_1,"onUpdate:modelValue":f[4]||(f[4]=j=>r.address_street_1=j),rows:"2",cols:"50",class:"mt-1 md:mt-0",invalid:m(p).address_street_1.$error,onInput:f[5]||(f[5]=j=>m(p).address_street_1.$touch()),placeholder:o.$t("settings.taxations.address_placeholder")},null,8,["modelValue","invalid","placeholder"])]),_:1},8,["error","label"]),s(i,{required:"",error:m(p).zip.$error&&m(p).zip.$errors[0].$message,label:o.$t("customers.zip_code")},{default:c(()=>[s(y,{modelValue:r.zip,"onUpdate:modelValue":f[6]||(f[6]=j=>r.zip=j),invalid:m(p).zip.$error,onInput:f[7]||(f[7]=j=>m(p).zip.$touch()),type:"text",class:"mt-1 md:mt-0",placeholder:o.$t("settings.taxations.zip_placeholder")},null,8,["modelValue","invalid","placeholder"])]),_:1},8,["error","label"])]),_:1})]),a("div",qs,[s(k,{class:"mr-3 text-sm",type:"button",variant:"primary-outline",onClick:S},{default:c(()=>[q(v(o.$t("general.cancel")),1)]),_:1}),s(k,{loading:w.value,variant:"primary",type:"submit"},{left:c(j=>[w.value?O("",!0):(l(),C(d,{key:0,name:"SaveIcon",class:Y(j.class)},null,8,["class"]))]),default:c(()=>[q(" "+v(o.$t("general.save")),1)]),_:1},8,["loading"])])],32)]),_:1},8,["show"])}}},se="Sales Tax",ae="MODULE",Ws={__name:"SalesTax",props:{isEdit:{type:Boolean,default:null},type:{type:String,default:null},customer:{type:[Object],default:null},store:{type:Object,default:null},storeProp:{type:String,default:null}},setup(t){const _=W(),e=ee(),r=Z(),{t:w}=X.useI18n(),b=R(!1),u=t,I=P(()=>u.isEdit?u.store[u.storeProp].sales_tax_address_type==="billing":e.selectedCompanySettings.sales_tax_address_type==="billing"),B=P(()=>e.selectedCompanySettings.sales_tax_us_enabled==="YES"),p=P(()=>u.isEdit?u.store[u.storeProp].sales_tax_type==="customer_level":e.selectedCompanySettings.sales_tax_type==="customer_level"),V=P(()=>u.isEdit?u.store[u.storeProp].sales_tax_type==="company_level":e.selectedCompanySettings.sales_tax_type==="company_level"),E=P(()=>{if(p.value&&A.value){let n=I.value?u.customer.billing:u.customer.shipping;return{address:K.pick(n,["address_street_1","city","state","zip"]),customer_id:u.customer.id}}else if(V.value&&A.value)return{address:K.pick(address,["address_street_1","city","state","zip"])}}),A=P(()=>{var n,g;if(p.value){let k=I.value?(n=u.customer)==null?void 0:n.billing:(g=u.customer)==null?void 0:g.shipping;return S(k)}else if(V.value)return S(e.selectedCompany.address);return!1});H(()=>u.customer,(n,g)=>{if(n&&g&&p.value){o(n,g);return}!A.value&&p.value&&n?setTimeout(()=>{f()},500):p.value&&n?d():p.value&&!n&&i()}),xe(()=>{V.value&&(A.value?d():f())});function S(n){return n?n.address_street_1&&n.city&&n.state&&n.zip:!1}function o(n,g){const k=I.value?n.billing:n.shipping,M=I.value?g.billing:g.shipping,j=K.pick(k,["address_street_1","city","state","zip"]),D=K.pick(M,["address_street_1","city","state","zip"]);K.isEqual(j,D)||d()}function f(){var k,M;if(!B.value)return;let n=null,g="";p.value?I.value?(n=(k=u.customer)==null?void 0:k.billing,g=w("settings.taxations.add_billing_address")):(n=(M=u.customer)==null?void 0:M.shipping,g=w("settings.taxations.add_shipping_address")):(n=e.selectedCompany.address,g=w("settings.taxations.add_company_address")),_.openModal({title:g,content:w("settings.taxations.modal_description"),componentName:"TaxationAddressModal",data:n,id:p.value?u.customer.id:""})}async function d(){B.value&&(b.value=!0,await r.fetchSalesTax(E.value).then(n=>{y(n.data.data),b.value=!1}).catch(n=>{n.response.data.error&&setTimeout(()=>{f()},500),b.value=!1}))}function y(n){n.tax_type_id=n.id;const g=u.store[u.storeProp].taxes.findIndex(k=>k.name===se&&k.type===ae);g>-1?Object.assign(u.store[u.storeProp].taxes[g],n):u.store[u.storeProp].taxes.push(n)}function i(){const n=u.store[u.storeProp].taxes.findIndex(k=>k.name===se&&k.type===ae);n>-1&&u.store[u.storeProp].taxes.splice(n,1);let g=r.taxTypes.findIndex(k=>k.name===se&&k.type===ae);g>-1&&r.taxTypes.splice(g,1)}return(n,g)=>(l(),C(As,{onAddTax:y}))}};export{Ys as _,Rs as a,Ws as b,zs as c,Gs as d,Fs as e,Ns as f};