"use strict";(self.webpackChunkNexoPOS_4x=self.webpackChunkNexoPOS_4x||[]).push([[9510],{9510:(e,t,s)=>{s.r(t),s.d(t,{default:()=>l});var i=s(9671),a=s(7266),r=s(8603),n=s(6386),o=s(7389);const u={name:"ns-pos-tax-popup",data:function(){return{validation:new a.Z,tax_group:[],order:null,orderSubscriber:null,optionsSubscriber:null,options:{},tax_groups:[],activeTab:"",group_fields:[{label:(0,o.__)("Select Tax"),name:"tax_group_id",description:(0,o.__)("Define the tax that apply to the sale."),type:"select",disabled:!0,value:"",options:[]},{label:(0,o.__)("Type"),name:"tax_type",disabled:!0,value:"",description:(0,o.__)("Define how the tax is computed"),type:"select",options:[{label:(0,o.__)("Exclusive"),value:"exclusive"},{label:(0,o.__)("Inclusive"),value:"inclusive"}]}]}},mounted:function(){var e=this;this.loadGroups(),this.popupCloser(),this.activeTab=this.$popupParams.activeTab||"settings",this.group_fields.forEach((function(t){t.value=e.$popupParams[t.name]||void 0})),this.orderSubscriber=POS.order.subscribe((function(t){e.order=t})),this.optionsSubscriber=POS.options.subscribe((function(t){e.options=t,["variable_vat","products_variable_vat"].includes(e.options.ns_pos_vat)&&e.group_fields.forEach((function(e){return e.disabled=!1}))}))},destroyed:function(){this.orderSubscriber.unsubscribe(),this.optionsSubscriber.unsubscribe()},methods:{__:o.__,popupCloser:r.Z,popupResolver:n.Z,changeActive:function(e){this.activeTab=e},closePopup:function(){this.popupResolver(!1)},saveTax:function(){var e=this.validation.extractFields(this.group_fields);this.popupResolver(e)},loadGroups:function(){var e=this;i.ih.get("/api/nexopos/v4/taxes/groups").subscribe((function(t){e.groups=t,e.group_fields.forEach((function(t){"tax_group_id"===t.name&&(t.options=e.groups.map((function(e){return{label:e.name,value:e.id}})))}))}))}}};const l=(0,s(1900).Z)(u,(function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{staticClass:"bg-surface-tertiary shadow-lg w-95vw md:w-3/5-screen lg:w-2/5-screen"},[s("div",{staticClass:"p-2 flex justify-between items-center border-b border-surface-secondary"},[s("h3",{staticClass:"text-blog"},[e._v(e._s(e.__("Tax & Summary")))]),e._v(" "),s("div",[s("ns-close-button",{on:{click:function(t){return e.closePopup()}}})],1)]),e._v(" "),s("div",{staticClass:"p-2"},[s("ns-tabs",{attrs:{active:e.activeTab},on:{changeTab:function(t){return e.changeActive(t)}}},[s("ns-tabs-item",{attrs:{padding:"0",label:e.__("Settings"),identifier:"settings",active:!0}},[s("div",{staticClass:"p-2 border-surface-tertiary border-b"},e._l(e.group_fields,(function(e,t){return s("ns-field",{key:t,attrs:{field:e}})})),1),e._v(" "),s("div",{staticClass:"flex justify-end p-2"},[s("ns-button",{attrs:{type:"info"},on:{click:function(t){return e.saveTax()}}},[e._v("Save")])],1)]),e._v(" "),s("ns-tabs-item",{attrs:{padding:"0",label:e.__("Summary"),identifier:"summary",active:!1}},[e.order?s("div",{staticClass:"p-2"},[e._l(e.order.taxes,(function(t){return s("div",{key:t.id,staticClass:"border-blue-200 mb-2 border bg-blue-100 shadow p-2 w-full flex justify-between items-center text-primary"},[s("span",[e._v(e._s(t.tax_name))]),e._v(" "),s("span",[e._v(e._s(e._f("currency")(t.tax_value)))])])})),e._v(" "),0===e.order.taxes.length?s("div",{staticClass:"p-2 text-center text-primary"},[e._v("No tax is active")]):e._e()],2):e._e()])],1)],1)])}),[],!1,null,null,null).exports}}]);