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