import{a7 as H,u as R,v as M,au as z,L as J,M as O,F as V,a5 as L,r as o,o as p,m as g,w as e,l,a as s,Q as f,p as T,t as S,K as P,E as K,av as Q,f as Y,k as N,a6 as $,J as q,c as G}from"./main-B9dpPbRR.js";import{_ as W}from"./TaxTypeModal-jyzjEMpe.js";const Z={__name:"TaxTypeIndexDropdown",props:{row:{type:Object,default:null},table:{type:Object,default:null},loadData:{type:Function,default:null}},setup(B){const t=B,b=H();R();const{t:r}=M.useI18n(),v=z(),C=J(),m=O(),E=V();L("utils");async function i(c){await v.fetchTaxType(c),E.openModal({title:r("settings.tax_types.edit_tax"),componentName:"TaxTypeModal",size:"sm",refreshData:t.loadData&&t.loadData})}function h(c){b.openDialog({title:r("general.are_you_sure"),message:r("settings.tax_types.confirm_delete"),yesLabel:r("general.ok"),noLabel:r("general.cancel"),variant:"danger",hideNoButton:!1,size:"lg"}).then(async d=>{if(d){if((await v.deleteTaxType(c)).data.success)return t.loadData&&t.loadData(),!0;t.loadData&&t.loadData()}})}return(c,d)=>{const u=o("BaseIcon"),w=o("BaseButton"),D=o("BaseDropdownItem"),k=o("BaseDropdown");return p(),g(k,null,{activator:e(()=>[l(C).name==="tax-types.view"?(p(),g(w,{key:0,variant:"primary"},{default:e(()=>[s(u,{name:"DotsHorizontalIcon",class:"h-5 text-white"})]),_:1})):(p(),g(u,{key:1,name:"DotsHorizontalIcon",class:"h-5 text-gray-500"}))]),default:e(()=>[l(m).hasAbilities(l(f).EDIT_TAX_TYPE)?(p(),g(D,{key:0,onClick:d[0]||(d[0]=I=>i(B.row.id))},{default:e(()=>[s(u,{name:"PencilIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),T(" "+S(c.$t("general.edit")),1)]),_:1})):P("",!0),l(m).hasAbilities(l(f).DELETE_TAX_TYPE)?(p(),g(D,{key:1,onClick:d[1]||(d[1]=I=>h(B.row.id))},{default:e(()=>[s(u,{name:"TrashIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),T(" "+S(c.$t("general.delete")),1)]),_:1})):P("",!0)]),_:1})}}},ee={key:0},se={__name:"TaxTypesSetting",setup(B){const{t}=M.useI18n(),b=L("utils"),r=K(),v=z(),C=V(),m=O(),E=Q(),i=Y(null),h=Y(r.selectedCompanySettings.tax_per_item),c=N(()=>[{key:"name",label:t("settings.tax_types.tax_name"),thClass:"extra",tdClass:"font-medium text-gray-900"},{key:"compound_tax",label:t("settings.tax_types.compound_tax"),tdClass:"font-medium text-gray-900"},{key:"percent",label:t("settings.tax_types.percent"),thClass:"extra",tdClass:"font-medium text-gray-900"},{key:"actions",label:"",tdClass:"text-right text-sm font-medium",sortable:!1}]),d=N(()=>r.selectedCompanySettings.sales_tax_us_enabled==="YES"&&E.salesTaxUSEnabled),u=N({get:()=>h.value==="YES",set:async n=>{const _=n?"YES":"NO";let y={settings:{tax_per_item:_}};h.value=_,await r.updateCompanySettings({data:y,message:"general.setting_updated"})}});function w(){return m.hasAbilities([f.DELETE_TAX_TYPE,f.EDIT_TAX_TYPE])}async function D({page:n,filter:_,sort:y}){let A={orderByField:y.fieldName||"created_at",orderBy:y.order||"desc",page:n},x=await v.fetchTaxTypes(A);return{data:x.data.data,pagination:{totalPages:x.data.meta.last_page,currentPage:n,totalCount:x.data.meta.total,limit:5}}}async function k(){i.value&&i.value.refresh()}function I(){C.openModal({title:t("settings.tax_types.add_tax"),componentName:"TaxTypeModal",size:"sm",refreshData:i.value&&i.value.refresh})}return(n,_)=>{const y=o("BaseIcon"),A=o("BaseButton"),x=o("BaseBadge"),X=o("BaseTable"),j=o("BaseDivider"),F=o("BaseSwitchSection"),U=o("BaseSettingCard");return p(),g(U,{title:n.$t("settings.tax_types.title"),description:n.$t("settings.tax_types.description")},$({default:e(()=>[s(W),s(X,{ref_key:"table",ref:i,class:"mt-16",data:D,columns:c.value},$({"cell-compound_tax":e(({row:a})=>[s(x,{"bg-color":l(b).getBadgeStatusColor(a.data.compound_tax?"YES":"NO").bgColor,color:l(b).getBadgeStatusColor(a.data.compound_tax?"YES":"NO").color},{default:e(()=>[T(S(a.data.compound_tax?"Yes":"No".replace("_"," ")),1)]),_:2},1032,["bg-color","color"])]),"cell-percent":e(({row:a})=>[T(S(a.data.percent)+" % ",1)]),_:2},[w()?{name:"cell-actions",fn:e(({row:a})=>[s(Z,{row:a.data,table:i.value,"load-data":k},null,8,["row","table"])]),key:"0"}:void 0]),1032,["columns"]),l(m).currentUser.is_owner?(p(),G("div",ee,[s(j,{class:"mt-8 mb-2"}),s(F,{modelValue:u.value,"onUpdate:modelValue":_[0]||(_[0]=a=>u.value=a),disabled:d.value,title:n.$t("settings.tax_types.tax_per_item"),description:n.$t("settings.tax_types.tax_setting_description")},null,8,["modelValue","disabled","title","description"])])):P("",!0)]),_:2},[l(m).hasAbilities(l(f).CREATE_TAX_TYPE)?{name:"action",fn:e(()=>[s(A,{type:"submit",variant:"primary-outline",onClick:I},{left:e(a=>[s(y,{class:q(a.class),name:"PlusIcon"},null,8,["class"])]),default:e(()=>[T(" "+S(n.$t("settings.tax_types.add_new_tax")),1)]),_:1})]),key:"0"}:void 0]),1032,["title","description"])}}};export{se as default};
