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