From 1559d8e351a7ab61189c4f5f84479ceec9df86cf Mon Sep 17 00:00:00 2001 From: blair2004 Date: Tue, 1 Oct 2024 03:35:55 +0100 Subject: [PATCH] WIP --- .../{app-d6800ea6.js => app-b2022351.js} | 2 +- .../build/assets/manage-products-cca5b591.js | 1 - .../build/assets/manage-products-cecb7581.js | 1 + public/build/assets/ns-pos-7cc83bf8.js | 1 + public/build/assets/ns-pos-a91ba1d6.js | 1 - public/build/assets/ns-pos-cart-32f5a2e0.js | 1 - public/build/assets/ns-pos-cart-a5bf23af.js | 1 + .../ns-pos-customers-button-00b4326b.js | 1 + .../ns-pos-customers-button-4d5fee4f.js | 1 - .../assets/ns-pos-layaway-popup-0b54a3bc.js | 1 - .../ns-pos-order-type-button-409712b0.js | 1 + .../ns-pos-order-type-button-9db68cc6.js | 1 - .../ns-pos-order-type-popup-14f46b3a.js | 1 - .../assets/ns-pos-shipping-popup-5ba7ac6e.js | 1 - .../assets/ns-pos-shipping-popup-dffc98ef.js | 1 + ...88be6afa.js => ns-procurement-8fc7cbf3.js} | 2 +- public/build/assets/pos-5aaef736.js | 1 - public/build/assets/pos-dc1f5e8e.js | 1 + public/build/assets/pos-init-6f22442c.js | 1 - public/build/assets/pos-init-bacdc802.js | 1 + public/build/manifest.json | 64 ++++++------------- 21 files changed, 28 insertions(+), 58 deletions(-) rename public/build/assets/{app-d6800ea6.js => app-b2022351.js} (97%) delete mode 100644 public/build/assets/manage-products-cca5b591.js create mode 100644 public/build/assets/manage-products-cecb7581.js create mode 100644 public/build/assets/ns-pos-7cc83bf8.js delete mode 100644 public/build/assets/ns-pos-a91ba1d6.js delete mode 100644 public/build/assets/ns-pos-cart-32f5a2e0.js create mode 100644 public/build/assets/ns-pos-cart-a5bf23af.js create mode 100644 public/build/assets/ns-pos-customers-button-00b4326b.js delete mode 100644 public/build/assets/ns-pos-customers-button-4d5fee4f.js delete mode 100644 public/build/assets/ns-pos-layaway-popup-0b54a3bc.js create mode 100644 public/build/assets/ns-pos-order-type-button-409712b0.js delete mode 100644 public/build/assets/ns-pos-order-type-button-9db68cc6.js delete mode 100644 public/build/assets/ns-pos-order-type-popup-14f46b3a.js delete mode 100644 public/build/assets/ns-pos-shipping-popup-5ba7ac6e.js create mode 100644 public/build/assets/ns-pos-shipping-popup-dffc98ef.js rename public/build/assets/{ns-procurement-88be6afa.js => ns-procurement-8fc7cbf3.js} (99%) delete mode 100644 public/build/assets/pos-5aaef736.js create mode 100644 public/build/assets/pos-dc1f5e8e.js delete mode 100644 public/build/assets/pos-init-6f22442c.js create mode 100644 public/build/assets/pos-init-bacdc802.js diff --git a/public/build/assets/app-d6800ea6.js b/public/build/assets/app-b2022351.js similarity index 97% rename from public/build/assets/app-d6800ea6.js rename to public/build/assets/app-b2022351.js index eb2f9cb53..f0d3875c7 100644 --- a/public/build/assets/app-d6800ea6.js +++ b/public/build/assets/app-b2022351.js @@ -7,4 +7,4 @@ import{_ as e}from"./preload-helper-41c905a7.js";import"./time-01d30542.js";impo ${l.innerHTML} - `),O(s,p),setTimeout(()=>{s.document.close(),s.focus(),s.print(),s.close(),D()},1e3),!0}}},g=t(()=>e(()=>import("./rewards-system-4b189a2b.js"),["./rewards-system-4b189a2b.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./_plugin-vue_export-helper-c27b6911.js"],import.meta.url)),C=t(()=>e(()=>import("./create-coupons-b9536b41.js"),["./create-coupons-b9536b41.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./_plugin-vue_export-helper-c27b6911.js"],import.meta.url)),k=t(()=>e(()=>import("./ns-settings-7a7c049e.js"),["./ns-settings-7a7c049e.js","./currency-feccde3d.js","./bootstrap-ffaf6d09.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js"],import.meta.url)),H=t(()=>e(()=>import("./reset-41e487ac.js"),["./reset-41e487ac.js","./currency-feccde3d.js","./bootstrap-ffaf6d09.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./_plugin-vue_export-helper-c27b6911.js"],import.meta.url)),M=t(()=>e(()=>import("./modules-de0ac09b.js"),["./modules-de0ac09b.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./index.es-25aa42ee.js"],import.meta.url)),j=t(()=>e(()=>import("./ns-permissions-18ba2e29.js"),["./ns-permissions-18ba2e29.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./_plugin-vue_export-helper-c27b6911.js"],import.meta.url)),N=t(()=>e(()=>import("./ns-procurement-88be6afa.js"),["./ns-procurement-88be6afa.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./manage-products-cca5b591.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./select-api-entities-3523a486.js","./join-array-28744963.js","./index.es-25aa42ee.js"],import.meta.url)),q=t(()=>e(()=>import("./manage-products-cca5b591.js"),["./manage-products-cca5b591.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css"],import.meta.url)),x=t(()=>e(()=>import("./ns-procurement-invoice-b9a1ca34.js"),[],import.meta.url)),$=t(()=>e(()=>import("./ns-notifications-40bad0ea.js"),["./ns-notifications-40bad0ea.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./components-07a97223.js","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js"],import.meta.url)),B=t(()=>e(()=>import("./components-07a97223.js").then(o=>o.i),["./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./currency-feccde3d.js","./_plugin-vue_export-helper-c27b6911.js","./runtime-core.esm-bundler-414a078a.js","./bootstrap-ffaf6d09.js","./chart-2ccf8ff7.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js"],import.meta.url)),F=t(()=>e(()=>import("./ns-transaction-75ac3b3e.js"),["./ns-transaction-75ac3b3e.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./index.es-25aa42ee.js"],import.meta.url)),Y=t(()=>e(()=>import("./ns-dashboard-934c1bb8.js"),["./ns-dashboard-934c1bb8.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./_plugin-vue_export-helper-c27b6911.js"],import.meta.url)),z=t(()=>e(()=>import("./ns-low-stock-report-07721e09.js"),["./ns-low-stock-report-07721e09.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js","./join-array-28744963.js"],import.meta.url)),G=t(()=>e(()=>import("./ns-sale-report-b5bd41c2.js"),["./ns-sale-report-b5bd41c2.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js","./join-array-28744963.js"],import.meta.url)),J=t(()=>e(()=>import("./ns-sold-stock-report-a4333726.js"),["./ns-sold-stock-report-a4333726.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js","./select-api-entities-3523a486.js","./join-array-28744963.js"],import.meta.url)),K=t(()=>e(()=>import("./ns-profit-report-28339c2e.js"),["./ns-profit-report-28339c2e.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js","./select-api-entities-3523a486.js","./join-array-28744963.js"],import.meta.url)),Q=t(()=>e(()=>import("./ns-stock-combined-report-336851aa.js"),["./ns-stock-combined-report-336851aa.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./select-api-entities-3523a486.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./join-array-28744963.js"],import.meta.url)),U=t(()=>e(()=>import("./ns-cash-flow-report-4f713261.js"),["./ns-cash-flow-report-4f713261.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js"],import.meta.url)),W=t(()=>e(()=>import("./ns-yearly-report-fd1ef191.js"),["./ns-yearly-report-fd1ef191.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js"],import.meta.url)),X=t(()=>e(()=>import("./ns-best-products-report-4c3e0699.js"),["./ns-best-products-report-4c3e0699.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js"],import.meta.url)),Z=t(()=>e(()=>import("./ns-payment-types-report-7c74b45d.js"),["./ns-payment-types-report-7c74b45d.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js"],import.meta.url)),ee=t(()=>e(()=>import("./ns-customers-statement-report-b8e1dc49.js"),["./ns-customers-statement-report-b8e1dc49.js","./currency-feccde3d.js","./_plugin-vue_export-helper-c27b6911.js","./runtime-core.esm-bundler-414a078a.js"],import.meta.url)),te=t(()=>e(()=>import("./ns-stock-adjustment-68e4d55c.js"),["./ns-stock-adjustment-68e4d55c.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-procurement-quantity-3c887b71.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-24cc8d6f.js","./ns-prompt-popup-6013118d.css"],import.meta.url)),oe=t(()=>e(()=>import("./ns-order-invoice-0167d283.js"),["./ns-order-invoice-0167d283.js","./currency-feccde3d.js","./_plugin-vue_export-helper-c27b6911.js","./runtime-core.esm-bundler-414a078a.js"],import.meta.url)),re=t(()=>e(()=>import("./ns-print-label-4f70b385.js"),["./ns-print-label-4f70b385.js","./currency-feccde3d.js","./runtime-core.esm-bundler-414a078a.js","./bootstrap-ffaf6d09.js","./chart-2ccf8ff7.js","./_plugin-vue_export-helper-c27b6911.js"],import.meta.url)),n=window.nsState,se=window.nsScreen;nsExtraComponents.nsToken=t(()=>e(()=>import("./ns-token-0a02eefb.js"),["./ns-token-0a02eefb.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./_plugin-vue_export-helper-c27b6911.js","./index.es-25aa42ee.js","./ns-prompt-popup-24cc8d6f.js","./ns-prompt-popup-6013118d.css"],import.meta.url));window.nsHotPress=new V;const d=Object.assign({nsModules:M,nsRewardsSystem:g,nsCreateCoupons:C,nsManageProducts:q,nsSettings:k,nsReset:H,nsPermissions:j,nsProcurement:N,nsProcurementInvoice:x,nsMedia:B,nsTransaction:F,nsDashboard:Y,nsPrintLabel:re,nsNotifications:$,nsSaleReport:G,nsSoldStockReport:J,nsProfitReport:K,nsStockCombinedReport:Q,nsCashFlowReport:U,nsYearlyReport:W,nsPaymentTypesReport:Z,nsBestProductsReport:X,nsLowStockReport:z,nsCustomersStatementReport:ee,nsStockAdjustment:te,nsOrderInvoice:oe,...w},nsExtraComponents);window.nsDashboardAside=m({data(){return{sidebar:"visible",popups:[]}},components:{nsMenu:I,nsSubmenu:L},mounted(){n.subscribe(o=>{o.sidebar&&(this.sidebar=o.sidebar)})}});window.nsDashboardOverlay=m({data(){return{sidebar:null,popups:[]}},components:d,mounted(){n.subscribe(o=>{o.sidebar&&(this.sidebar=o.sidebar)})},methods:{closeMenu(){n.setState({sidebar:this.sidebar==="hidden"?"visible":"hidden"})}}});window.nsDashboardHeader=m({data(){return{menuToggled:!1,sidebar:null}},components:d,methods:{toggleMenu(){this.menuToggled=!this.menuToggled},toggleSideMenu(){["lg","xl"].includes(se.breakpoint)?n.setState({sidebar:this.sidebar==="hidden"?"visible":"hidden"}):n.setState({sidebar:this.sidebar==="hidden"?"visible":"hidden"})}},mounted(){n.subscribe(o=>{o.sidebar&&(this.sidebar=o.sidebar)})}});window.nsDashboardContent=m({});for(let o in d)window.nsDashboardContent.component(o,d[o]);window.nsDashboardContent.use(S,{styles:Object.values(window.ns.cssFiles)});window.nsComponents=Object.assign(d,w);y.doAction("ns-before-mount");const c=document.querySelector("#dashboard-aside");window.nsDashboardAside&&c&&window.nsDashboardAside.mount(c);const b=document.querySelector("#dashboard-overlay");window.nsDashboardOverlay&&b&&window.nsDashboardOverlay.mount(b);const E=document.querySelector("#dashboard-header");window.nsDashboardHeader&&E&&window.nsDashboardHeader.mount(E);const h=document.querySelector("#dashboard-content");window.nsDashboardContent&&h&&window.nsDashboardContent.mount(h); + `),O(s,p),setTimeout(()=>{s.document.close(),s.focus(),s.print(),s.close(),D()},1e3),!0}}},g=t(()=>e(()=>import("./rewards-system-4b189a2b.js"),["./rewards-system-4b189a2b.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./_plugin-vue_export-helper-c27b6911.js"],import.meta.url)),C=t(()=>e(()=>import("./create-coupons-b9536b41.js"),["./create-coupons-b9536b41.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./_plugin-vue_export-helper-c27b6911.js"],import.meta.url)),k=t(()=>e(()=>import("./ns-settings-7a7c049e.js"),["./ns-settings-7a7c049e.js","./currency-feccde3d.js","./bootstrap-ffaf6d09.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js"],import.meta.url)),H=t(()=>e(()=>import("./reset-41e487ac.js"),["./reset-41e487ac.js","./currency-feccde3d.js","./bootstrap-ffaf6d09.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./_plugin-vue_export-helper-c27b6911.js"],import.meta.url)),M=t(()=>e(()=>import("./modules-de0ac09b.js"),["./modules-de0ac09b.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./index.es-25aa42ee.js"],import.meta.url)),j=t(()=>e(()=>import("./ns-permissions-18ba2e29.js"),["./ns-permissions-18ba2e29.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./_plugin-vue_export-helper-c27b6911.js"],import.meta.url)),N=t(()=>e(()=>import("./ns-procurement-8fc7cbf3.js"),["./ns-procurement-8fc7cbf3.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./manage-products-cecb7581.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./select-api-entities-3523a486.js","./join-array-28744963.js","./index.es-25aa42ee.js"],import.meta.url)),q=t(()=>e(()=>import("./manage-products-cecb7581.js"),["./manage-products-cecb7581.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css"],import.meta.url)),x=t(()=>e(()=>import("./ns-procurement-invoice-b9a1ca34.js"),[],import.meta.url)),$=t(()=>e(()=>import("./ns-notifications-40bad0ea.js"),["./ns-notifications-40bad0ea.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./components-07a97223.js","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js"],import.meta.url)),B=t(()=>e(()=>import("./components-07a97223.js").then(o=>o.i),["./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./currency-feccde3d.js","./_plugin-vue_export-helper-c27b6911.js","./runtime-core.esm-bundler-414a078a.js","./bootstrap-ffaf6d09.js","./chart-2ccf8ff7.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js"],import.meta.url)),F=t(()=>e(()=>import("./ns-transaction-75ac3b3e.js"),["./ns-transaction-75ac3b3e.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./index.es-25aa42ee.js"],import.meta.url)),Y=t(()=>e(()=>import("./ns-dashboard-934c1bb8.js"),["./ns-dashboard-934c1bb8.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./_plugin-vue_export-helper-c27b6911.js"],import.meta.url)),z=t(()=>e(()=>import("./ns-low-stock-report-07721e09.js"),["./ns-low-stock-report-07721e09.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js","./join-array-28744963.js"],import.meta.url)),G=t(()=>e(()=>import("./ns-sale-report-b5bd41c2.js"),["./ns-sale-report-b5bd41c2.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js","./join-array-28744963.js"],import.meta.url)),J=t(()=>e(()=>import("./ns-sold-stock-report-a4333726.js"),["./ns-sold-stock-report-a4333726.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js","./select-api-entities-3523a486.js","./join-array-28744963.js"],import.meta.url)),K=t(()=>e(()=>import("./ns-profit-report-28339c2e.js"),["./ns-profit-report-28339c2e.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js","./select-api-entities-3523a486.js","./join-array-28744963.js"],import.meta.url)),Q=t(()=>e(()=>import("./ns-stock-combined-report-336851aa.js"),["./ns-stock-combined-report-336851aa.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./select-api-entities-3523a486.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./join-array-28744963.js"],import.meta.url)),U=t(()=>e(()=>import("./ns-cash-flow-report-4f713261.js"),["./ns-cash-flow-report-4f713261.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js"],import.meta.url)),W=t(()=>e(()=>import("./ns-yearly-report-fd1ef191.js"),["./ns-yearly-report-fd1ef191.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js"],import.meta.url)),X=t(()=>e(()=>import("./ns-best-products-report-4c3e0699.js"),["./ns-best-products-report-4c3e0699.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js"],import.meta.url)),Z=t(()=>e(()=>import("./ns-payment-types-report-7c74b45d.js"),["./ns-payment-types-report-7c74b45d.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./components-07a97223.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-avatar-image-1a727bdf.js","./index.es-25aa42ee.js"],import.meta.url)),ee=t(()=>e(()=>import("./ns-customers-statement-report-b8e1dc49.js"),["./ns-customers-statement-report-b8e1dc49.js","./currency-feccde3d.js","./_plugin-vue_export-helper-c27b6911.js","./runtime-core.esm-bundler-414a078a.js"],import.meta.url)),te=t(()=>e(()=>import("./ns-stock-adjustment-68e4d55c.js"),["./ns-stock-adjustment-68e4d55c.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-procurement-quantity-3c887b71.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-24cc8d6f.js","./ns-prompt-popup-6013118d.css"],import.meta.url)),oe=t(()=>e(()=>import("./ns-order-invoice-0167d283.js"),["./ns-order-invoice-0167d283.js","./currency-feccde3d.js","./_plugin-vue_export-helper-c27b6911.js","./runtime-core.esm-bundler-414a078a.js"],import.meta.url)),re=t(()=>e(()=>import("./ns-print-label-4f70b385.js"),["./ns-print-label-4f70b385.js","./currency-feccde3d.js","./runtime-core.esm-bundler-414a078a.js","./bootstrap-ffaf6d09.js","./chart-2ccf8ff7.js","./_plugin-vue_export-helper-c27b6911.js"],import.meta.url)),n=window.nsState,se=window.nsScreen;nsExtraComponents.nsToken=t(()=>e(()=>import("./ns-token-0a02eefb.js"),["./ns-token-0a02eefb.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./_plugin-vue_export-helper-c27b6911.js","./index.es-25aa42ee.js","./ns-prompt-popup-24cc8d6f.js","./ns-prompt-popup-6013118d.css"],import.meta.url));window.nsHotPress=new V;const d=Object.assign({nsModules:M,nsRewardsSystem:g,nsCreateCoupons:C,nsManageProducts:q,nsSettings:k,nsReset:H,nsPermissions:j,nsProcurement:N,nsProcurementInvoice:x,nsMedia:B,nsTransaction:F,nsDashboard:Y,nsPrintLabel:re,nsNotifications:$,nsSaleReport:G,nsSoldStockReport:J,nsProfitReport:K,nsStockCombinedReport:Q,nsCashFlowReport:U,nsYearlyReport:W,nsPaymentTypesReport:Z,nsBestProductsReport:X,nsLowStockReport:z,nsCustomersStatementReport:ee,nsStockAdjustment:te,nsOrderInvoice:oe,...w},nsExtraComponents);window.nsDashboardAside=m({data(){return{sidebar:"visible",popups:[]}},components:{nsMenu:I,nsSubmenu:L},mounted(){n.subscribe(o=>{o.sidebar&&(this.sidebar=o.sidebar)})}});window.nsDashboardOverlay=m({data(){return{sidebar:null,popups:[]}},components:d,mounted(){n.subscribe(o=>{o.sidebar&&(this.sidebar=o.sidebar)})},methods:{closeMenu(){n.setState({sidebar:this.sidebar==="hidden"?"visible":"hidden"})}}});window.nsDashboardHeader=m({data(){return{menuToggled:!1,sidebar:null}},components:d,methods:{toggleMenu(){this.menuToggled=!this.menuToggled},toggleSideMenu(){["lg","xl"].includes(se.breakpoint)?n.setState({sidebar:this.sidebar==="hidden"?"visible":"hidden"}):n.setState({sidebar:this.sidebar==="hidden"?"visible":"hidden"})}},mounted(){n.subscribe(o=>{o.sidebar&&(this.sidebar=o.sidebar)})}});window.nsDashboardContent=m({});for(let o in d)window.nsDashboardContent.component(o,d[o]);window.nsDashboardContent.use(S,{styles:Object.values(window.ns.cssFiles)});window.nsComponents=Object.assign(d,w);y.doAction("ns-before-mount");const c=document.querySelector("#dashboard-aside");window.nsDashboardAside&&c&&window.nsDashboardAside.mount(c);const b=document.querySelector("#dashboard-overlay");window.nsDashboardOverlay&&b&&window.nsDashboardOverlay.mount(b);const E=document.querySelector("#dashboard-header");window.nsDashboardHeader&&E&&window.nsDashboardHeader.mount(E);const h=document.querySelector("#dashboard-content");window.nsDashboardContent&&h&&window.nsDashboardContent.mount(h); diff --git a/public/build/assets/manage-products-cca5b591.js b/public/build/assets/manage-products-cca5b591.js deleted file mode 100644 index 99c0e5f6c..000000000 --- a/public/build/assets/manage-products-cca5b591.js +++ /dev/null @@ -1 +0,0 @@ -import{P as G,d as y,b as U,v as q,i as Q,F as J}from"./bootstrap-ffaf6d09.js";import{n as L,b as K}from"./ns-prompt-popup-24cc8d6f.js";import{_ as p,n as I}from"./currency-feccde3d.js";import{_ as M}from"./_plugin-vue_export-helper-c27b6911.js";import{o as l,c as a,a as i,B as V,t as c,F as b,b as v,e as m,p as N,r as w,f as k,w as S,i as P,n as F,A as $,g as T}from"./runtime-core.esm-bundler-414a078a.js";import"./chart-2ccf8ff7.js";const W={name:"ns-product-group",props:["fields"],watch:{searchValue(){clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout(()=>{this.searchProducts(this.searchValue)},1e3)},products:{deep:!0,handler(){this.$forceUpdate()}}},computed:{totalProducts(){return this.products.length>0?(this.$emit("update",this.products),this.products.map(e=>parseFloat(e.sale_price)*parseFloat(e.quantity)).reduce((e,t)=>e+t)):0}},mounted(){const e=this.fields.filter(t=>t.name==="product_subitems");e.length>0&&e[0].value!==void 0&&e[0].value.length>0&&(this.products=e[0].value)},data(){return{searchValue:"",searchTimeout:null,results:[],products:[]}},methods:{__:p,nsCurrency:I,setSalePrice(){this.$emit("updateSalePrice",this.totalProducts)},removeProduct(e){G.show(L,{title:p("Delete Sub item"),message:p("Would you like to delete this sub item?"),onAction:t=>{t&&this.products.splice(e,1)}})},toggleUnitField(e){e._unit_toggled||(e._unit_toggled=!e._unit_toggled),setTimeout(()=>{e._unit_toggled&&this.$refs.unitField[0].addEventListener("blur",()=>{e._unit_toggled=!1,this.$forceUpdate()})},200)},toggleQuantityField(e){e._quantity_toggled=!e._quantity_toggled,setTimeout(()=>{e._quantity_toggled&&(this.$refs.quantityField[0].select(),this.$refs.quantityField[0].addEventListener("blur",()=>{this.toggleQuantityField(e),this.$forceUpdate()}))},200)},togglePriceField(e){e._price_toggled=!e._price_toggled,setTimeout(()=>{e._price_toggled&&(this.$refs.priceField[0].select(),this.$refs.priceField[0].addEventListener("blur",()=>{this.togglePriceField(e),this.$forceUpdate()}))},200)},redefineUnit(e){const t=e.unit_quantities.filter(n=>n.id===e.unit_quantity_id);t.length>0&&(e.unit_quantity=t[0],e.unit_id=t[0].unit.id,e.unit=t[0].unit,e.sale_price=t[0].sale_price)},async addResult(e){if(this.searchValue="",e.type==="grouped")return y.error(p("Unable to add a grouped product.")).subscribe();try{const t=await new Promise((d,r)=>{G.show(K,{label:p("Choose The Unit"),options:e.unit_quantities.map(s=>({label:s.unit.name,value:s.id})),resolve:d,reject:r})}),n=e.unit_quantities.filter(d=>parseInt(d.id)===parseInt(t[0].value));this.products.push({name:e.name,unit_quantity_id:t[0].value,unit_quantity:n[0],unit_id:n[0].unit.id,unit:n[0].unit,product_id:n[0].product_id,quantity:1,_price_toggled:!1,_quantity_toggled:!1,_unit_toggled:!1,unit_quantities:e.unit_quantities,sale_price:n[0].sale_price}),this.$emit("update",this.products)}catch(t){console.log(t)}},searchProducts(e){if(e.length===0)return null;U.post("/api/products/search",{search:e,arguments:{type:{comparison:"<>",value:"grouped"},searchable:{comparison:"in",value:[0,1]}}}).subscribe({next:t=>{this.results=t},error:t=>{y.error(t.message||p("An unexpected error occurred"),p("Ok"),{duration:3e3}).subscribe()}})}}},z={class:"flex flex-col px-4 w-full"},H={class:"md:-mx-4 flex flex-col md:flex-row"},Y={class:"md:px-4 w-full"},X={class:"input-group border-2 rounded info flex w-full"},Z=["placeholder"],ee={key:0,class:"h-0 relative"},te={class:"ns-vertical-menu absolute w-full"},se=["onClick"],ie={class:"my-2"},re={class:"ns-table"},ne={colspan:"2",class:"border"},le={colspan:"2",class:"border p-2"},ae={class:"flex justify-between"},oe={class:"font-bold"},de=["onClick"],ue=["onClick"],ce={class:"input-group"},fe=["onChange","onUpdate:modelValue"],he=["value"],me=["onClick"],pe={key:0,class:"cursor-pointer border-b border-dashed border-info-secondary"},be=["onUpdate:modelValue"],_e=["onClick"],ge={key:0,class:"cursor-pointer border-b border-dashed border-info-secondary"},ve=["onUpdate:modelValue"],ye={key:0},xe={colspan:"2",class:"border p-2 text-center"},we={key:0},ke={class:"w-1/2 border p-2 text-left"},Ue={class:"w-1/2 border p-2 text-right"};function Fe(e,t,n,d,r,s){return l(),a("div",z,[i("div",H,[i("div",Y,[i("div",X,[V(i("input",{placeholder:s.__("Search products..."),"onUpdate:modelValue":t[0]||(t[0]=o=>r.searchValue=o),type:"text",class:"flex-auto p-2 outline-none"},null,8,Z),[[q,r.searchValue]]),i("button",{onClick:t[1]||(t[1]=o=>s.setSalePrice()),class:"px-2"},c(s.__("Set Sale Price")),1)]),r.results.length>0&&r.searchValue.length>0?(l(),a("div",ee,[i("ul",te,[(l(!0),a(b,null,v(r.results,o=>(l(),a("li",{key:o.id,onClick:g=>s.addResult(o),class:"p-2 border-b cursor-pointer"},c(o.name),9,se))),128))])])):m("",!0),i("div",ie,[i("table",re,[i("thead",null,[i("tr",null,[i("th",ne,c(s.__("Products")),1)])]),i("tbody",null,[(l(!0),a(b,null,v(r.products,(o,g)=>(l(),a("tr",{key:g},[i("td",le,[i("div",ae,[i("h3",oe,c(o.name),1),i("span",{onClick:f=>s.removeProduct(g),class:"hover:underline text-error-secondary cursor-pointer"},c(s.__("Remove")),9,de)]),i("ul",null,[i("li",{onClick:f=>s.toggleUnitField(o),class:"flex justify-between p-1 hover:bg-box-elevation-hover"},[i("span",null,c(s.__("Unit"))+":",1),i("div",ce,[V(i("select",{onChange:f=>s.redefineUnit(o),ref_for:!0,ref:"unitField",type:"text","onUpdate:modelValue":f=>o.unit_quantity_id=f},[(l(!0),a(b,null,v(o.unit_quantities,f=>(l(),a("option",{key:f.id,value:f.id},c(f.unit.name)+" ("+c(f.quantity)+")",9,he))),128))],40,fe),[[Q,o.unit_quantity_id]])])],8,ue),i("li",{onClick:f=>s.toggleQuantityField(o),class:"flex justify-between p-1 hover:bg-box-elevation-hover"},[i("span",null,c(s.__("Quantity"))+":",1),o._quantity_toggled?m("",!0):(l(),a("span",pe,c(o.quantity),1)),o._quantity_toggled?V((l(),a("input",{key:1,ref_for:!0,ref:"quantityField",type:"text","onUpdate:modelValue":f=>o.quantity=f},null,8,be)),[[q,o.quantity]]):m("",!0)],8,me),i("li",{onClick:f=>s.togglePriceField(o),class:"flex justify-between p-1 hover:bg-box-elevation-hover"},[i("span",null,c(s.__("Price"))+":",1),o._price_toggled?m("",!0):(l(),a("span",ge,c(s.nsCurrency(o.sale_price)),1)),o._price_toggled?V((l(),a("input",{key:1,ref_for:!0,ref:"priceField",type:"text","onUpdate:modelValue":f=>o.sale_price=f},null,8,ve)),[[q,o.sale_price]]):m("",!0)],8,_e)])])]))),128)),r.products.length===0?(l(),a("tr",ye,[i("td",xe,c(s.__("No product are added to this group.")),1)])):m("",!0)]),r.products.length>0?(l(),a("tfoot",we,[i("tr",null,[i("td",ke,c(s.__("Total")),1),i("td",Ue,c(s.nsCurrency(s.totalProducts)),1)])])):m("",!0)])])])])])}const Ve=M(W,[["render",Fe]]),Ce={components:{nsProductGroup:Ve},data:()=>({formValidation:new J,nsSnackBar:y,nsHttpClient:U,_sampleVariation:null,unitLoaded:!1,unitLoadError:!1,form:N({}),hasLoaded:!1,hasError:!1}),watch:{form:{deep:!0,handler(e){this.form.variations.forEach(t=>{if(this.formValidation.extractFields(t.tabs.identification.fields).type==="grouped"){for(let d in t.tabs)["identification","groups","taxes","units"].includes(d)||(t.tabs[d].visible=!1);t.tabs.groups&&(t.tabs.groups.visible=!0)}else{for(let d in t.tabs)["identification","groups","taxes","units"].includes(d)||(t.tabs[d].visible=!0);t.tabs.groups&&(t.tabs.groups.visible=!1)}})}}},computed:{defaultVariation(){const e=new Object;for(let t in this._sampleVariation.tabs)e[t]=new Object,e[t].label=this._sampleVariation.tabs[t].label,e[t].active=this._sampleVariation.tabs[t].active,e[t].fields=this._sampleVariation.tabs[t].fields.filter(n=>!["category_id","product_type","stock_management","expires"].includes(n.name)).map(n=>((typeof n.value=="string"&&n.value.length===0||n.value===null)&&(n.value=""),n));return{id:"",tabs:e}}},props:["submitMethod","submitUrl","returnUrl","src","units-url"],methods:{__:p,nsCurrency:I,handleUnitGroupFieldChanged(e,t){e.name==="unit_id"&&(t.label=this.getFirstSelectedUnit(t.fields))},async handleSaved(e,t,n,d){e.data.entry&&(await this.loadForm()).form.variations[n].tabs[t].fields.forEach(s=>{s.name===d.name&&(s.value=e.data.entry.id)})},getGroupProducts(e){if(e.groups){const t=e.groups.fields.filter(n=>n.name==="products_subitems");if(t.length>0)return t[0].value}return[]},setProducts(e,t){t.groups.fields.forEach(n=>{n.name==="product_subitems"&&(n.value=e)})},triggerRecompute(e){},getUnitQuantity(e){const t=e.filter(n=>n.name==="quantity").map(n=>n.value);return t.length>0?t[0]:0},removeUnitPriceGroup(e,t){const n=e.fields.filter(d=>d.name==="id"&&d.value!==void 0);Popup.show(L,{title:p("Confirm Your Action"),message:p("Would you like to delete this group ?"),onAction:d=>{if(d)if(n.length>0)this.confirmUnitQuantityDeletion({group:e,groups:t});else{const r=t.indexOf(e);t.splice(r,1)}}})},confirmUnitQuantityDeletion({group:e,groups:t}){Popup.show(L,{title:p("Your Attention Is Required"),size:"w-3/4-screen h-2/5-screen",message:p("The current unit you're about to delete has a reference on the database and it might have already procured stock. Deleting that reference will remove procured stock. Would you proceed ?"),onAction:n=>{if(n){const d=e.fields.filter(r=>r.name==="id").map(r=>r.value)[0];U.delete(`/api/products/units/quantity/${d}`).subscribe({next:r=>{const s=t.indexOf(e);t.splice(s,1),y.success(r.message).subscribe()},error:r=>{nsSnackbar.error(r.message).subscribe()}})}}})},addUnitGroup(e){if(e.options.length===0)return y.error(p("Please select at least one unit group before you proceed.")).subscribe();if(e.options.length>e.groups.length){const t=e.groups;e.groups=[],setTimeout(()=>{e.groups=[...t,{label:this.getFirstSelectedUnit(e.fields),fields:JSON.parse(JSON.stringify(e.fields))}]},1)}else y.error(p("There shoulnd't be more option than there are units.")).subscribe()},handleSaveEvent(e,t){t.options.push({label:e.data.entry[t.props.optionAttributes.label],value:e.data.entry[t.props.optionAttributes.value]}),t.value=e.data.entry[t.props.optionAttributes.value]},loadAvailableUnits(e,t){if(t.name!=="unit_group")return;this.unitLoaded=!1,this.unitLoadError=!1;const n=e.fields.filter(d=>d.name==="unit_group")[0].value;U.get(this.unitsUrl.replace("{id}",n)).subscribe({next:d=>{e.fields.forEach(r=>{r.type==="group"&&(r.options=d,r.fields.forEach(s=>{["unit_id","convert_unit_id"].includes(s.name)&&(s.options=d.map(o=>({label:o.name,value:o.id})))}))}),this.unitLoaded=!0},error:d=>{this.unitLoadError=!0}})},submit(){if(this.formValidation.validateFields([this.form.main]),this.form.variations.map(r=>this.formValidation.validateForm(r)).filter(r=>r.length>0).length>0||Object.values(this.form.main.errors).length>0)return y.error(p("Unable to proceed the form is not valid.")).subscribe();const t=this.form.variations.map((r,s)=>r.tabs.images.groups.filter(o=>o.filter(g=>g.name==="featured"&&g.value===1).length>0));if(t[0]&&t[0].length>1)return y.error(p("Unable to proceed, more than one product is set as featured")).subscribe();const n=[];if(this.form.variations.map((r,s)=>r.tabs.units.fields.filter(o=>o.type==="group").forEach(o=>{o.groups.forEach(g=>{n.push(this.formValidation.validateFields(g.fields))})})),n.length===0)return y.error(p("Either Selling or Purchase unit isn't defined. Unable to proceed.")).subscribe();if(n.filter(r=>r===!1).length>0)return this.$forceUpdate(),y.error(p("Unable to proceed as one of the unit group field is invalid")).subscribe();const d={...this.formValidation.extractForm(this.form),variations:this.form.variations.map((r,s)=>{const o=this.formValidation.extractForm(r);s===0&&(o.$primary=!0),o.images=r.tabs.images.groups.map(f=>this.formValidation.extractFields(f));const g=new Object;return r.tabs.units.fields.filter(f=>f.type==="group").forEach(f=>{g[f.name]=f.groups.map(A=>this.formValidation.extractFields(A.fields))}),o.units={...o.units,...g},o})};this.formValidation.disableForm(this.form),U[this.submitMethod?this.submitMethod.toLowerCase():"post"](this.submitUrl,d).subscribe(r=>{if(r.status==="success"){if(this.submitMethod==="POST"&&this.returnUrl!==!1)return document.location=r.data.editUrl||this.returnUrl;y.info(r.message,p("Okay"),{duration:3e3}).subscribe(),this.$emit("saved")}this.formValidation.enableForm(this.form)},r=>{y.error(r.message,void 0,{duration:5e3}).subscribe(),this.formValidation.enableForm(this.form),r.response&&this.formValidation.triggerError(this.form,r.response.data)})},deleteVariation(e){confirm(p("Would you like to delete this variation ?"))&&this.form.variations.splice(e,1)},setTabActive(e,t){for(let n in t)n!==e&&(t[n].active=!1);if(t[e].active=!0,e==="units"){const n=t[e].fields.filter(d=>d.name==="unit_group");n.length>0&&this.loadAvailableUnits(t[e],n[0])}},duplicate(e){this.form.variations.push(Object.assign({},e))},newVariation(){this.form.variations.push(this.defaultVariation)},getActiveTab(e){for(let t in e)if(e[t].active)return e[t];return!1},getActiveTabKey(e){for(let t in e)if(e[t].active)return t;return!1},parseForm(e){return e.main.value=e.main.value===void 0?"":e.main.value,e.main=this.formValidation.createFields([e.main])[0],e.variations.forEach((t,n)=>{let d=0;for(let r in t.tabs)d===0&&t.tabs[r].active===void 0?(t.tabs[r].active=!0,this._sampleVariation=JSON.parse(JSON.stringify(t)),t.tabs[r].fields&&(t.tabs[r].fields=this.formValidation.createFields(t.tabs[r].fields.filter(s=>s.name!=="name")))):t.tabs[r].fields&&(t.tabs[r].fields=this.formValidation.createFields(t.tabs[r].fields)),t.tabs[r].active=t.tabs[r].active===void 0?!1:t.tabs[r].active,t.tabs[r].visible=t.tabs[r].visible===void 0?!0:t.tabs[r].visible,d++}),e},loadForm(){return new Promise((e,t)=>{const n=U.get(`${this.src}`);this.hasLoaded=!1,this.hasError=!1,n.subscribe({next:d=>{e(d),this.hasLoaded=!0,this.form=N(this.parseForm(d.form))},error:d=>{t(d),this.hasError=!0}})})},addImage(e){e.tabs.images.groups.push(this.formValidation.createFields(JSON.parse(JSON.stringify(e.tabs.images.fields))))},removeImage(e,t){const n=e.tabs.images.groups.indexOf(t);e.tabs.images.groups.splice(n,1)},handleSavedUnitGroupFields(e,t){e.data&&(t.options.push({label:e.data.entry.name,value:e.data.entry.id}),t.value=e.data.entry.id)},getGroupId(e){const t=e.filter(n=>n.name==="id");return t.length>0?t[0].value:!1},getFirstSelectedUnit(e){const t=e.filter(n=>n.name==="unit_id");if(t.length>0){const n=t[0].options.filter(d=>d.value===t[0].value);if(n.length>0)return n[0].label}return p("No Unit Selected")}},async mounted(){await this.loadForm()},name:"ns-manage-products"},Se={class:"form flex-auto",id:"crud-form"},Pe={key:0,class:"flex items-center h-full justify-center flex-auto"},Te={key:1},qe={class:"flex flex-col"},Ae={class:"flex justify-between items-center"},Ee={for:"title",class:"font-bold my-2 text-primary"},je={for:"title",class:"text-sm my-2 text-primary"},Oe=["href"],Le=["disabled"],Ge=["disabled"],Ne={key:0,class:"text-xs text-primary py-1"},$e={id:"form-container",class:"-mx-4 flex flex-wrap mt-4"},Ie={class:"px-4 w-full"},Me={id:"card-header",class:"flex flex-wrap justify-between ns-tab ml-4"},Re={class:"flex flex-wrap"},Be=["onClick"],De={key:0,class:"rounded-full bg-error-secondary text-white h-6 w-6 flex font-semibold items-center justify-center"},Qe=i("div",{class:"flex items-center justify-center -mx-1"},null,-1),Je={class:"card-body ns-tab-item"},Ke={class:"rounded shadow p-2"},We={key:0,class:"-mx-4 flex flex-wrap"},ze={key:1,class:"-mx-4 flex flex-wrap text-primary"},He={class:"flex flex-col px-4 w-full md:w-1/2 lg:w-1/3"},Ye={class:"rounded border border-box-elevation-edge bg-box-elevation-background flex justify-between p-2 items-center"},Xe=["onClick"],Ze=i("i",{class:"las la-plus-circle"},null,-1),et=[Ze],tt={class:"rounded border border-box-elevation-edge flex flex-col overflow-hidden"},st={class:"p-2"},it=["onClick"],rt={key:2,class:"-mx-4 flex flex-wrap text-primary"},nt={key:3,class:"-mx-4 flex flex-wrap"},lt={class:"px-4 w-full md:w-1/2 lg:w-1/3"},at={class:"mb-2"},ot={class:"font-medium text-primary"},dt={class:"py-1 text-sm text-primary"},ut={class:"mb-2"},ct=["onClick"],ft=i("span",{class:"rounded-full border-2 ns-inset-button info h-8 w-8 flex items-center justify-center"},[i("i",{class:"las la-plus-circle"})],-1),ht={class:"shadow rounded overflow-hidden bg-box-elevation-background text-primary"},mt={class:"border-b text-sm p-2 flex justify-between text-primary border-box-elevation-edge"},pt={class:"p-2 mb-2"},bt={class:"md:-mx-2 flex flex-wrap"},_t=["onClick"],gt={key:1,class:"px-4 w-full lg:w-2/3 flex justify-center items-center"},vt={key:2,class:"px-4 w-full md:w-1/2 lg:w-2/3 flex flex-col justify-center items-center"},yt=i("i",{class:"las la-frown text-7xl"},null,-1),xt={class:"w-full md:w-1/3 py-3 text-center text-sm text-primary"};function wt(e,t,n,d,r,s){const o=w("ns-spinner"),g=w("ns-notice"),f=w("ns-field"),A=w("ns-product-group"),R=w("ns-tabs-item"),B=w("ns-tabs");return l(),a("div",Se,[Object.values(e.form).length===0&&e.hasLoaded?(l(),a("div",Pe,[k(o)])):m("",!0),Object.values(e.form).length===0&&e.hasError?(l(),a("div",Te,[k(g,{color:"error"},{title:S(()=>[P(c(s.__("An Error Has Occured")),1)]),description:S(()=>[P(c(s.__("An unexpected error has occured while loading the form. Please check the log or contact the support.")),1)]),_:1})])):m("",!0),Object.values(e.form).length>0?(l(),a(b,{key:2},[i("div",qe,[i("div",Ae,[i("label",Ee,c(e.form.main.label),1),i("div",je,[n.returnUrl?(l(),a("a",{key:0,href:n.returnUrl,class:"rounded-full border ns-inset-button error hover:bg-error-tertiary px-2 py-1"},c(s.__("Return")),9,Oe)):m("",!0)])]),i("div",{class:F([e.form.main.disabled?"":e.form.main.errors.length>0?"border-error-tertiary":"","input-group info flex border-2 rounded overflow-hidden"])},[V(i("input",{"onUpdate:modelValue":t[0]||(t[0]=h=>e.form.main.value=h),onBlur:t[1]||(t[1]=h=>e.formValidation.checkField(e.form.main)),onChange:t[2]||(t[2]=h=>e.formValidation.checkField(e.form.main)),disabled:e.form.main.disabled,type:"text",class:F([(e.form.main.disabled,""),"flex-auto text-primary outline-none h-10 px-2"])},null,42,Le),[[q,e.form.main.value]]),i("button",{disabled:e.form.main.disabled,class:F([e.form.main.disabled?"":e.form.main.errors.length>0?"bg-error-tertiary":"","outline-none px-4 h-10 rounded-none"]),onClick:t[3]||(t[3]=h=>s.submit())},[$(e.$slots,"save",{},()=>[P(c(s.__("Save")),1)])],10,Ge)],2),e.form.main.description&&e.form.main.errors.length===0?(l(),a("p",Ne,c(e.form.main.description),1)):m("",!0),(l(!0),a(b,null,v(e.form.main.errors,(h,C)=>(l(),a("p",{class:"text-xs py-1 text-error-tertiary",key:C},[i("span",null,[$(e.$slots,"error-required",{},()=>[P(c(h.identifier),1)])])]))),128))]),i("div",$e,[i("div",Ie,[(l(!0),a(b,null,v(e.form.variations,(h,C)=>(l(),a("div",{id:"tabbed-card",class:"mb-8",key:C},[i("div",Me,[i("div",Re,[(l(!0),a(b,null,v(h.tabs,(u,x)=>(l(),a(b,null,[u.visible?(l(),a("div",{onClick:_=>s.setTabActive(x,h.tabs),class:F([u.active?"active":"inactive","tab cursor-pointer text-primary px-4 py-2 rounded-tl-lg rounded-tr-lg flex justify-between"]),key:x},[i("span",{class:F(["block",u.errors&&u.errors.length>0?"mr-2":""])},c(u.label),3),u.errors&&u.errors.length>0?(l(),a("span",De,c(u.errors.length),1)):m("",!0)],10,Be)):m("",!0)],64))),256))]),Qe]),i("div",Je,[i("div",Ke,[["images","units","groups"].includes(s.getActiveTabKey(h.tabs))?m("",!0):(l(),a("div",We,[(l(!0),a(b,null,v(s.getActiveTab(h.tabs).fields,(u,x)=>(l(),a("div",{key:x,class:"flex flex-col px-4 w-full md:w-1/2 lg:w-1/3"},[k(f,{onSaved:_=>s.handleSaved(_,s.getActiveTabKey(h.tabs),C,u),field:u},null,8,["onSaved","field"])]))),128))])),s.getActiveTabKey(h.tabs)==="images"?(l(),a("div",ze,[i("div",He,[i("div",Ye,[i("span",null,c(s.__("Add Images")),1),i("button",{onClick:u=>s.addImage(h),class:"outline-none rounded-full border flex items-center justify-center w-8 h-8 ns-inset-button info"},et,8,Xe)])]),(l(!0),a(b,null,v(s.getActiveTab(h.tabs).groups,(u,x)=>(l(),a("div",{key:x,class:"flex flex-col px-4 w-full md:w-1/2 lg:w-1/3 mb-4"},[i("div",tt,[i("div",st,[(l(!0),a(b,null,v(u,(_,E)=>(l(),T(f,{key:E,field:_},null,8,["field"]))),128))]),i("div",{onClick:_=>s.removeImage(h,u),class:"text-center py-2 border-t border-box-elevation-edge text-sm cursor-pointer"},c(s.__("Remove Image")),9,it)])]))),128))])):m("",!0),s.getActiveTabKey(h.tabs)==="groups"?(l(),a("div",rt,[k(A,{onUpdate:u=>s.setProducts(u,h.tabs),onUpdateSalePrice:u=>s.triggerRecompute(u,h.tabs),fields:s.getActiveTab(h.tabs).fields},null,8,["onUpdate","onUpdateSalePrice","fields"])])):m("",!0),s.getActiveTabKey(h.tabs)==="units"?(l(),a("div",nt,[i("div",lt,[(l(!0),a(b,null,v(s.getActiveTab(h.tabs).fields.filter(u=>u.name!=="selling_group"),u=>(l(),T(f,{onSaved:x=>s.handleSaveEvent(x,u),onChange:x=>s.loadAvailableUnits(s.getActiveTab(h.tabs),u),field:u},null,8,["onSaved","onChange","field"]))),256))]),e.unitLoaded?(l(!0),a(b,{key:0},v(s.getActiveTab(h.tabs).fields,(u,x)=>(l(),a(b,null,[u.type==="group"?(l(),a("div",{class:"px-4 w-full lg:w-2/3",key:x},[i("div",at,[i("label",ot,c(u.label),1),i("p",dt,c(u.description),1)]),i("div",ut,[i("div",{onClick:_=>s.addUnitGroup(u),class:"border-dashed border-2 p-1 bg-box-elevation-background border-box-elevation-edge flex justify-between items-center text-primary cursor-pointer rounded-lg"},[ft,i("span",null,c(s.__("New Group")),1)],8,ct)]),u.groups.length>0?(l(),T(B,{key:0,onChangeTab:_=>h.activeUnitTab=_,active:h.activeUnitTab||"tab-0"},{default:S(()=>[(l(!0),a(b,null,v(u.groups,(_,E)=>(l(),T(R,{padding:"p-2",identifier:"tab-"+E,label:_.label},{default:S(()=>[i("div",ht,[i("div",mt,[i("span",null,c(s.__("Available Quantity")),1),i("span",null,c(s.getUnitQuantity(_.fields)),1)]),i("div",pt,[i("div",bt,[(l(!0),a(b,null,v(_.fields,(j,D)=>(l(),a("div",{class:"w-full md:w-1/2 p-2",key:D},[k(f,{onChange:O=>s.handleUnitGroupFieldChanged(O,_),onSaved:O=>s.handleSavedUnitGroupFields(O,j),field:j},null,8,["onChange","onSaved","field"])]))),128))])]),i("div",{onClick:j=>s.removeUnitPriceGroup(_,u.groups),class:"p-1 hover:bg-error-primary border-t border-box-elevation-edge flex items-center justify-center cursor-pointer font-medium"},c(s.__("Delete")),9,_t)])]),_:2},1032,["identifier","label"]))),256))]),_:2},1032,["onChangeTab","active"])):m("",!0)])):m("",!0)],64))),256)):m("",!0),!e.unitLoaded&&!e.unitLoadError?(l(),a("div",gt,[k(o)])):m("",!0),e.unitLoadError&&!e.unitLoaded?(l(),a("div",vt,[yt,i("p",xt,c(s.__("We were not able to load the units. Make sure there are units attached on the unit group selected.")),1)])):m("",!0)])):m("",!0)])])]))),128))])])],64)):m("",!0)])}const Pt=M(Ce,[["render",wt]]);export{Pt as default}; diff --git a/public/build/assets/manage-products-cecb7581.js b/public/build/assets/manage-products-cecb7581.js new file mode 100644 index 000000000..b64e2a9a0 --- /dev/null +++ b/public/build/assets/manage-products-cecb7581.js @@ -0,0 +1 @@ +import{P as G,d as y,b as U,v as q,i as D,F as J}from"./bootstrap-ffaf6d09.js";import{n as L,b as K}from"./ns-prompt-popup-24cc8d6f.js";import{_ as p,n as I}from"./currency-feccde3d.js";import{_ as M}from"./_plugin-vue_export-helper-c27b6911.js";import{o as l,c as a,a as i,B as V,t as c,F as b,b as v,e as m,p as N,r as w,f as k,w as S,i as P,n as F,A as $,g as T}from"./runtime-core.esm-bundler-414a078a.js";import"./chart-2ccf8ff7.js";const W={name:"ns-product-group",props:["fields"],watch:{searchValue(){clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout(()=>{this.searchProducts(this.searchValue)},1e3)},products:{deep:!0,handler(){this.$forceUpdate()}}},computed:{totalProducts(){return this.products.length>0?(this.$emit("update",this.products),this.products.map(e=>parseFloat(e.sale_price)*parseFloat(e.quantity)).reduce((e,t)=>e+t)):0}},mounted(){const e=this.fields.filter(t=>t.name==="product_subitems");e.length>0&&e[0].value!==void 0&&e[0].value.length>0&&(this.products=e[0].value)},data(){return{searchValue:"",searchTimeout:null,results:[],products:[]}},methods:{__:p,nsCurrency:I,setSalePrice(){this.$emit("updateSalePrice",this.totalProducts)},removeProduct(e){G.show(L,{title:p("Delete Sub item"),message:p("Would you like to delete this sub item?"),onAction:t=>{t&&this.products.splice(e,1)}})},toggleUnitField(e){e._unit_toggled||(e._unit_toggled=!e._unit_toggled),setTimeout(()=>{e._unit_toggled&&this.$refs.unitField[0].addEventListener("blur",()=>{e._unit_toggled=!1,this.$forceUpdate()})},200)},toggleQuantityField(e){e._quantity_toggled=!e._quantity_toggled,setTimeout(()=>{e._quantity_toggled&&(this.$refs.quantityField[0].select(),this.$refs.quantityField[0].addEventListener("blur",()=>{this.toggleQuantityField(e),this.$forceUpdate()}))},200)},togglePriceField(e){e._price_toggled=!e._price_toggled,setTimeout(()=>{e._price_toggled&&(this.$refs.priceField[0].select(),this.$refs.priceField[0].addEventListener("blur",()=>{this.togglePriceField(e),this.$forceUpdate()}))},200)},redefineUnit(e){const t=e.unit_quantities.filter(n=>n.id===e.unit_quantity_id);t.length>0&&(e.unit_quantity=t[0],e.unit_id=t[0].unit.id,e.unit=t[0].unit,e.sale_price=t[0].sale_price)},async addResult(e){if(this.searchValue="",e.type==="grouped")return y.error(p("Unable to add a grouped product.")).subscribe();try{const t=await new Promise((d,r)=>{G.show(K,{label:p("Choose The Unit"),options:e.unit_quantities.map(s=>({label:s.unit.name,value:s.id})),resolve:d,reject:r})}),n=e.unit_quantities.filter(d=>parseInt(d.id)===parseInt(t));this.products.push({name:e.name,unit_quantity_id:t,unit_quantity:n[0],unit_id:n[0].unit.id,unit:n[0].unit,product_id:n[0].product_id,quantity:1,_price_toggled:!1,_quantity_toggled:!1,_unit_toggled:!1,unit_quantities:e.unit_quantities,sale_price:n[0].sale_price}),this.$emit("update",this.products)}catch(t){console.log(t)}},searchProducts(e){if(e.length===0)return null;U.post("/api/products/search",{search:e,arguments:{type:{comparison:"<>",value:"grouped"},searchable:{comparison:"in",value:[0,1]}}}).subscribe({next:t=>{this.results=t},error:t=>{y.error(t.message||p("An unexpected error occurred"),p("Ok"),{duration:3e3}).subscribe()}})}}},z={class:"flex flex-col px-4 w-full"},H={class:"md:-mx-4 flex flex-col md:flex-row"},Y={class:"md:px-4 w-full"},X={class:"input-group border-2 rounded info flex w-full"},Z=["placeholder"],ee={key:0,class:"h-0 relative"},te={class:"ns-vertical-menu absolute w-full"},se=["onClick"],ie={class:"my-2"},re={class:"ns-table"},ne={colspan:"2",class:"border"},le={colspan:"2",class:"border p-2"},ae={class:"flex justify-between"},oe={class:"font-bold"},de=["onClick"],ue=["onClick"],ce={class:"input-group"},fe=["onChange","onUpdate:modelValue"],he=["value"],me=["onClick"],pe={key:0,class:"cursor-pointer border-b border-dashed border-info-secondary"},be=["onUpdate:modelValue"],_e=["onClick"],ge={key:0,class:"cursor-pointer border-b border-dashed border-info-secondary"},ve=["onUpdate:modelValue"],ye={key:0},xe={colspan:"2",class:"border p-2 text-center"},we={key:0},ke={class:"w-1/2 border p-2 text-left"},Ue={class:"w-1/2 border p-2 text-right"};function Fe(e,t,n,d,r,s){return l(),a("div",z,[i("div",H,[i("div",Y,[i("div",X,[V(i("input",{placeholder:s.__("Search products..."),"onUpdate:modelValue":t[0]||(t[0]=o=>r.searchValue=o),type:"text",class:"flex-auto p-2 outline-none"},null,8,Z),[[q,r.searchValue]]),i("button",{onClick:t[1]||(t[1]=o=>s.setSalePrice()),class:"px-2"},c(s.__("Set Sale Price")),1)]),r.results.length>0&&r.searchValue.length>0?(l(),a("div",ee,[i("ul",te,[(l(!0),a(b,null,v(r.results,o=>(l(),a("li",{key:o.id,onClick:g=>s.addResult(o),class:"p-2 border-b cursor-pointer"},c(o.name),9,se))),128))])])):m("",!0),i("div",ie,[i("table",re,[i("thead",null,[i("tr",null,[i("th",ne,c(s.__("Products")),1)])]),i("tbody",null,[(l(!0),a(b,null,v(r.products,(o,g)=>(l(),a("tr",{key:g},[i("td",le,[i("div",ae,[i("h3",oe,c(o.name),1),i("span",{onClick:f=>s.removeProduct(g),class:"hover:underline text-error-secondary cursor-pointer"},c(s.__("Remove")),9,de)]),i("ul",null,[i("li",{onClick:f=>s.toggleUnitField(o),class:"flex justify-between p-1 hover:bg-box-elevation-hover"},[i("span",null,c(s.__("Unit"))+":",1),i("div",ce,[V(i("select",{onChange:f=>s.redefineUnit(o),ref_for:!0,ref:"unitField",type:"text","onUpdate:modelValue":f=>o.unit_quantity_id=f},[(l(!0),a(b,null,v(o.unit_quantities,f=>(l(),a("option",{key:f.id,value:f.id},c(f.unit.name)+" ("+c(f.quantity)+")",9,he))),128))],40,fe),[[D,o.unit_quantity_id]])])],8,ue),i("li",{onClick:f=>s.toggleQuantityField(o),class:"flex justify-between p-1 hover:bg-box-elevation-hover"},[i("span",null,c(s.__("Quantity"))+":",1),o._quantity_toggled?m("",!0):(l(),a("span",pe,c(o.quantity),1)),o._quantity_toggled?V((l(),a("input",{key:1,ref_for:!0,ref:"quantityField",type:"text","onUpdate:modelValue":f=>o.quantity=f},null,8,be)),[[q,o.quantity]]):m("",!0)],8,me),i("li",{onClick:f=>s.togglePriceField(o),class:"flex justify-between p-1 hover:bg-box-elevation-hover"},[i("span",null,c(s.__("Price"))+":",1),o._price_toggled?m("",!0):(l(),a("span",ge,c(s.nsCurrency(o.sale_price)),1)),o._price_toggled?V((l(),a("input",{key:1,ref_for:!0,ref:"priceField",type:"text","onUpdate:modelValue":f=>o.sale_price=f},null,8,ve)),[[q,o.sale_price]]):m("",!0)],8,_e)])])]))),128)),r.products.length===0?(l(),a("tr",ye,[i("td",xe,c(s.__("No product are added to this group.")),1)])):m("",!0)]),r.products.length>0?(l(),a("tfoot",we,[i("tr",null,[i("td",ke,c(s.__("Total")),1),i("td",Ue,c(s.nsCurrency(s.totalProducts)),1)])])):m("",!0)])])])])])}const Ve=M(W,[["render",Fe]]),Ce={components:{nsProductGroup:Ve},data:()=>({formValidation:new J,nsSnackBar:y,nsHttpClient:U,_sampleVariation:null,unitLoaded:!1,unitLoadError:!1,form:N({}),hasLoaded:!1,hasError:!1}),watch:{form:{deep:!0,handler(e){this.form.variations.forEach(t=>{if(this.formValidation.extractFields(t.tabs.identification.fields).type==="grouped"){for(let d in t.tabs)["identification","groups","taxes","units"].includes(d)||(t.tabs[d].visible=!1);t.tabs.groups&&(t.tabs.groups.visible=!0)}else{for(let d in t.tabs)["identification","groups","taxes","units"].includes(d)||(t.tabs[d].visible=!0);t.tabs.groups&&(t.tabs.groups.visible=!1)}})}}},computed:{defaultVariation(){const e=new Object;for(let t in this._sampleVariation.tabs)e[t]=new Object,e[t].label=this._sampleVariation.tabs[t].label,e[t].active=this._sampleVariation.tabs[t].active,e[t].fields=this._sampleVariation.tabs[t].fields.filter(n=>!["category_id","product_type","stock_management","expires"].includes(n.name)).map(n=>((typeof n.value=="string"&&n.value.length===0||n.value===null)&&(n.value=""),n));return{id:"",tabs:e}}},props:["submitMethod","submitUrl","returnUrl","src","units-url"],methods:{__:p,nsCurrency:I,handleUnitGroupFieldChanged(e,t){e.name==="unit_id"&&(t.label=this.getFirstSelectedUnit(t.fields))},async handleSaved(e,t,n,d){e.data.entry&&(await this.loadForm()).form.variations[n].tabs[t].fields.forEach(s=>{s.name===d.name&&(s.value=e.data.entry.id)})},getGroupProducts(e){if(e.groups){const t=e.groups.fields.filter(n=>n.name==="products_subitems");if(t.length>0)return t[0].value}return[]},setProducts(e,t){t.groups.fields.forEach(n=>{n.name==="product_subitems"&&(n.value=e)})},triggerRecompute(e){},getUnitQuantity(e){const t=e.filter(n=>n.name==="quantity").map(n=>n.value);return t.length>0?t[0]:0},removeUnitPriceGroup(e,t){const n=e.fields.filter(d=>d.name==="id"&&d.value!==void 0);Popup.show(L,{title:p("Confirm Your Action"),message:p("Would you like to delete this group ?"),onAction:d=>{if(d)if(n.length>0)this.confirmUnitQuantityDeletion({group:e,groups:t});else{const r=t.indexOf(e);t.splice(r,1)}}})},confirmUnitQuantityDeletion({group:e,groups:t}){Popup.show(L,{title:p("Your Attention Is Required"),size:"w-3/4-screen h-2/5-screen",message:p("The current unit you're about to delete has a reference on the database and it might have already procured stock. Deleting that reference will remove procured stock. Would you proceed ?"),onAction:n=>{if(n){const d=e.fields.filter(r=>r.name==="id").map(r=>r.value)[0];U.delete(`/api/products/units/quantity/${d}`).subscribe({next:r=>{const s=t.indexOf(e);t.splice(s,1),y.success(r.message).subscribe()},error:r=>{nsSnackbar.error(r.message).subscribe()}})}}})},addUnitGroup(e){if(e.options.length===0)return y.error(p("Please select at least one unit group before you proceed.")).subscribe();if(e.options.length>e.groups.length){const t=e.groups;e.groups=[],setTimeout(()=>{e.groups=[...t,{label:this.getFirstSelectedUnit(e.fields),fields:JSON.parse(JSON.stringify(e.fields))}]},1)}else y.error(p("There shoulnd't be more option than there are units.")).subscribe()},handleSaveEvent(e,t){t.options.push({label:e.data.entry[t.props.optionAttributes.label],value:e.data.entry[t.props.optionAttributes.value]}),t.value=e.data.entry[t.props.optionAttributes.value]},loadAvailableUnits(e,t){if(t.name!=="unit_group")return;this.unitLoaded=!1,this.unitLoadError=!1;const n=e.fields.filter(d=>d.name==="unit_group")[0].value;U.get(this.unitsUrl.replace("{id}",n)).subscribe({next:d=>{e.fields.forEach(r=>{r.type==="group"&&(r.options=d,r.fields.forEach(s=>{["unit_id","convert_unit_id"].includes(s.name)&&(s.options=d.map(o=>({label:o.name,value:o.id})))}))}),this.unitLoaded=!0},error:d=>{this.unitLoadError=!0}})},submit(){if(this.formValidation.validateFields([this.form.main]),this.form.variations.map(r=>this.formValidation.validateForm(r)).filter(r=>r.length>0).length>0||Object.values(this.form.main.errors).length>0)return y.error(p("Unable to proceed the form is not valid.")).subscribe();const t=this.form.variations.map((r,s)=>r.tabs.images.groups.filter(o=>o.filter(g=>g.name==="featured"&&g.value===1).length>0));if(t[0]&&t[0].length>1)return y.error(p("Unable to proceed, more than one product is set as featured")).subscribe();const n=[];if(this.form.variations.map((r,s)=>r.tabs.units.fields.filter(o=>o.type==="group").forEach(o=>{o.groups.forEach(g=>{n.push(this.formValidation.validateFields(g.fields))})})),n.length===0)return y.error(p("Either Selling or Purchase unit isn't defined. Unable to proceed.")).subscribe();if(n.filter(r=>r===!1).length>0)return this.$forceUpdate(),y.error(p("Unable to proceed as one of the unit group field is invalid")).subscribe();const d={...this.formValidation.extractForm(this.form),variations:this.form.variations.map((r,s)=>{const o=this.formValidation.extractForm(r);s===0&&(o.$primary=!0),o.images=r.tabs.images.groups.map(f=>this.formValidation.extractFields(f));const g=new Object;return r.tabs.units.fields.filter(f=>f.type==="group").forEach(f=>{g[f.name]=f.groups.map(A=>this.formValidation.extractFields(A.fields))}),o.units={...o.units,...g},o})};this.formValidation.disableForm(this.form),U[this.submitMethod?this.submitMethod.toLowerCase():"post"](this.submitUrl,d).subscribe(r=>{if(r.status==="success"){if(this.submitMethod==="POST"&&this.returnUrl!==!1)return document.location=r.data.editUrl||this.returnUrl;y.info(r.message,p("Okay"),{duration:3e3}).subscribe(),this.$emit("saved")}this.formValidation.enableForm(this.form)},r=>{y.error(r.message,void 0,{duration:5e3}).subscribe(),this.formValidation.enableForm(this.form),r.response&&this.formValidation.triggerError(this.form,r.response.data)})},deleteVariation(e){confirm(p("Would you like to delete this variation ?"))&&this.form.variations.splice(e,1)},setTabActive(e,t){for(let n in t)n!==e&&(t[n].active=!1);if(t[e].active=!0,e==="units"){const n=t[e].fields.filter(d=>d.name==="unit_group");n.length>0&&this.loadAvailableUnits(t[e],n[0])}},duplicate(e){this.form.variations.push(Object.assign({},e))},newVariation(){this.form.variations.push(this.defaultVariation)},getActiveTab(e){for(let t in e)if(e[t].active)return e[t];return!1},getActiveTabKey(e){for(let t in e)if(e[t].active)return t;return!1},parseForm(e){return e.main.value=e.main.value===void 0?"":e.main.value,e.main=this.formValidation.createFields([e.main])[0],e.variations.forEach((t,n)=>{let d=0;for(let r in t.tabs)d===0&&t.tabs[r].active===void 0?(t.tabs[r].active=!0,this._sampleVariation=JSON.parse(JSON.stringify(t)),t.tabs[r].fields&&(t.tabs[r].fields=this.formValidation.createFields(t.tabs[r].fields.filter(s=>s.name!=="name")))):t.tabs[r].fields&&(t.tabs[r].fields=this.formValidation.createFields(t.tabs[r].fields)),t.tabs[r].active=t.tabs[r].active===void 0?!1:t.tabs[r].active,t.tabs[r].visible=t.tabs[r].visible===void 0?!0:t.tabs[r].visible,d++}),e},loadForm(){return new Promise((e,t)=>{const n=U.get(`${this.src}`);this.hasLoaded=!1,this.hasError=!1,n.subscribe({next:d=>{e(d),this.hasLoaded=!0,this.form=N(this.parseForm(d.form))},error:d=>{t(d),this.hasError=!0}})})},addImage(e){e.tabs.images.groups.push(this.formValidation.createFields(JSON.parse(JSON.stringify(e.tabs.images.fields))))},removeImage(e,t){const n=e.tabs.images.groups.indexOf(t);e.tabs.images.groups.splice(n,1)},handleSavedUnitGroupFields(e,t){e.data&&(t.options.push({label:e.data.entry.name,value:e.data.entry.id}),t.value=e.data.entry.id)},getGroupId(e){const t=e.filter(n=>n.name==="id");return t.length>0?t[0].value:!1},getFirstSelectedUnit(e){const t=e.filter(n=>n.name==="unit_id");if(t.length>0){const n=t[0].options.filter(d=>d.value===t[0].value);if(n.length>0)return n[0].label}return p("No Unit Selected")}},async mounted(){await this.loadForm()},name:"ns-manage-products"},Se={class:"form flex-auto",id:"crud-form"},Pe={key:0,class:"flex items-center h-full justify-center flex-auto"},Te={key:1},qe={class:"flex flex-col"},Ae={class:"flex justify-between items-center"},Ee={for:"title",class:"font-bold my-2 text-primary"},je={for:"title",class:"text-sm my-2 text-primary"},Oe=["href"],Le=["disabled"],Ge=["disabled"],Ne={key:0,class:"text-xs text-primary py-1"},$e={id:"form-container",class:"-mx-4 flex flex-wrap mt-4"},Ie={class:"px-4 w-full"},Me={id:"card-header",class:"flex flex-wrap justify-between ns-tab ml-4"},Qe={class:"flex flex-wrap"},Re=["onClick"],Be={key:0,class:"rounded-full bg-error-secondary text-white h-6 w-6 flex font-semibold items-center justify-center"},De=i("div",{class:"flex items-center justify-center -mx-1"},null,-1),Je={class:"card-body ns-tab-item"},Ke={class:"rounded shadow p-2"},We={key:0,class:"-mx-4 flex flex-wrap"},ze={key:1,class:"-mx-4 flex flex-wrap text-primary"},He={class:"flex flex-col px-4 w-full md:w-1/2 lg:w-1/3"},Ye={class:"rounded border border-box-elevation-edge bg-box-elevation-background flex justify-between p-2 items-center"},Xe=["onClick"],Ze=i("i",{class:"las la-plus-circle"},null,-1),et=[Ze],tt={class:"rounded border border-box-elevation-edge flex flex-col overflow-hidden"},st={class:"p-2"},it=["onClick"],rt={key:2,class:"-mx-4 flex flex-wrap text-primary"},nt={key:3,class:"-mx-4 flex flex-wrap"},lt={class:"px-4 w-full md:w-1/2 lg:w-1/3"},at={class:"mb-2"},ot={class:"font-medium text-primary"},dt={class:"py-1 text-sm text-primary"},ut={class:"mb-2"},ct=["onClick"],ft=i("span",{class:"rounded-full border-2 ns-inset-button info h-8 w-8 flex items-center justify-center"},[i("i",{class:"las la-plus-circle"})],-1),ht={class:"shadow rounded overflow-hidden bg-box-elevation-background text-primary"},mt={class:"border-b text-sm p-2 flex justify-between text-primary border-box-elevation-edge"},pt={class:"p-2 mb-2"},bt={class:"md:-mx-2 flex flex-wrap"},_t=["onClick"],gt={key:1,class:"px-4 w-full lg:w-2/3 flex justify-center items-center"},vt={key:2,class:"px-4 w-full md:w-1/2 lg:w-2/3 flex flex-col justify-center items-center"},yt=i("i",{class:"las la-frown text-7xl"},null,-1),xt={class:"w-full md:w-1/3 py-3 text-center text-sm text-primary"};function wt(e,t,n,d,r,s){const o=w("ns-spinner"),g=w("ns-notice"),f=w("ns-field"),A=w("ns-product-group"),Q=w("ns-tabs-item"),R=w("ns-tabs");return l(),a("div",Se,[Object.values(e.form).length===0&&e.hasLoaded?(l(),a("div",Pe,[k(o)])):m("",!0),Object.values(e.form).length===0&&e.hasError?(l(),a("div",Te,[k(g,{color:"error"},{title:S(()=>[P(c(s.__("An Error Has Occured")),1)]),description:S(()=>[P(c(s.__("An unexpected error has occured while loading the form. Please check the log or contact the support.")),1)]),_:1})])):m("",!0),Object.values(e.form).length>0?(l(),a(b,{key:2},[i("div",qe,[i("div",Ae,[i("label",Ee,c(e.form.main.label),1),i("div",je,[n.returnUrl?(l(),a("a",{key:0,href:n.returnUrl,class:"rounded-full border ns-inset-button error hover:bg-error-tertiary px-2 py-1"},c(s.__("Return")),9,Oe)):m("",!0)])]),i("div",{class:F([e.form.main.disabled?"":e.form.main.errors.length>0?"border-error-tertiary":"","input-group info flex border-2 rounded overflow-hidden"])},[V(i("input",{"onUpdate:modelValue":t[0]||(t[0]=h=>e.form.main.value=h),onBlur:t[1]||(t[1]=h=>e.formValidation.checkField(e.form.main)),onChange:t[2]||(t[2]=h=>e.formValidation.checkField(e.form.main)),disabled:e.form.main.disabled,type:"text",class:F([(e.form.main.disabled,""),"flex-auto text-primary outline-none h-10 px-2"])},null,42,Le),[[q,e.form.main.value]]),i("button",{disabled:e.form.main.disabled,class:F([e.form.main.disabled?"":e.form.main.errors.length>0?"bg-error-tertiary":"","outline-none px-4 h-10 rounded-none"]),onClick:t[3]||(t[3]=h=>s.submit())},[$(e.$slots,"save",{},()=>[P(c(s.__("Save")),1)])],10,Ge)],2),e.form.main.description&&e.form.main.errors.length===0?(l(),a("p",Ne,c(e.form.main.description),1)):m("",!0),(l(!0),a(b,null,v(e.form.main.errors,(h,C)=>(l(),a("p",{class:"text-xs py-1 text-error-tertiary",key:C},[i("span",null,[$(e.$slots,"error-required",{},()=>[P(c(h.identifier),1)])])]))),128))]),i("div",$e,[i("div",Ie,[(l(!0),a(b,null,v(e.form.variations,(h,C)=>(l(),a("div",{id:"tabbed-card",class:"mb-8",key:C},[i("div",Me,[i("div",Qe,[(l(!0),a(b,null,v(h.tabs,(u,x)=>(l(),a(b,null,[u.visible?(l(),a("div",{onClick:_=>s.setTabActive(x,h.tabs),class:F([u.active?"active":"inactive","tab cursor-pointer text-primary px-4 py-2 rounded-tl-lg rounded-tr-lg flex justify-between"]),key:x},[i("span",{class:F(["block",u.errors&&u.errors.length>0?"mr-2":""])},c(u.label),3),u.errors&&u.errors.length>0?(l(),a("span",Be,c(u.errors.length),1)):m("",!0)],10,Re)):m("",!0)],64))),256))]),De]),i("div",Je,[i("div",Ke,[["images","units","groups"].includes(s.getActiveTabKey(h.tabs))?m("",!0):(l(),a("div",We,[(l(!0),a(b,null,v(s.getActiveTab(h.tabs).fields,(u,x)=>(l(),a("div",{key:x,class:"flex flex-col px-4 w-full md:w-1/2 lg:w-1/3"},[k(f,{onSaved:_=>s.handleSaved(_,s.getActiveTabKey(h.tabs),C,u),field:u},null,8,["onSaved","field"])]))),128))])),s.getActiveTabKey(h.tabs)==="images"?(l(),a("div",ze,[i("div",He,[i("div",Ye,[i("span",null,c(s.__("Add Images")),1),i("button",{onClick:u=>s.addImage(h),class:"outline-none rounded-full border flex items-center justify-center w-8 h-8 ns-inset-button info"},et,8,Xe)])]),(l(!0),a(b,null,v(s.getActiveTab(h.tabs).groups,(u,x)=>(l(),a("div",{key:x,class:"flex flex-col px-4 w-full md:w-1/2 lg:w-1/3 mb-4"},[i("div",tt,[i("div",st,[(l(!0),a(b,null,v(u,(_,E)=>(l(),T(f,{key:E,field:_},null,8,["field"]))),128))]),i("div",{onClick:_=>s.removeImage(h,u),class:"text-center py-2 border-t border-box-elevation-edge text-sm cursor-pointer"},c(s.__("Remove Image")),9,it)])]))),128))])):m("",!0),s.getActiveTabKey(h.tabs)==="groups"?(l(),a("div",rt,[k(A,{onUpdate:u=>s.setProducts(u,h.tabs),onUpdateSalePrice:u=>s.triggerRecompute(u,h.tabs),fields:s.getActiveTab(h.tabs).fields},null,8,["onUpdate","onUpdateSalePrice","fields"])])):m("",!0),s.getActiveTabKey(h.tabs)==="units"?(l(),a("div",nt,[i("div",lt,[(l(!0),a(b,null,v(s.getActiveTab(h.tabs).fields.filter(u=>u.name!=="selling_group"),u=>(l(),T(f,{onSaved:x=>s.handleSaveEvent(x,u),onChange:x=>s.loadAvailableUnits(s.getActiveTab(h.tabs),u),field:u},null,8,["onSaved","onChange","field"]))),256))]),e.unitLoaded?(l(!0),a(b,{key:0},v(s.getActiveTab(h.tabs).fields,(u,x)=>(l(),a(b,null,[u.type==="group"?(l(),a("div",{class:"px-4 w-full lg:w-2/3",key:x},[i("div",at,[i("label",ot,c(u.label),1),i("p",dt,c(u.description),1)]),i("div",ut,[i("div",{onClick:_=>s.addUnitGroup(u),class:"border-dashed border-2 p-1 bg-box-elevation-background border-box-elevation-edge flex justify-between items-center text-primary cursor-pointer rounded-lg"},[ft,i("span",null,c(s.__("New Group")),1)],8,ct)]),u.groups.length>0?(l(),T(R,{key:0,onChangeTab:_=>h.activeUnitTab=_,active:h.activeUnitTab||"tab-0"},{default:S(()=>[(l(!0),a(b,null,v(u.groups,(_,E)=>(l(),T(Q,{padding:"p-2",identifier:"tab-"+E,label:_.label},{default:S(()=>[i("div",ht,[i("div",mt,[i("span",null,c(s.__("Available Quantity")),1),i("span",null,c(s.getUnitQuantity(_.fields)),1)]),i("div",pt,[i("div",bt,[(l(!0),a(b,null,v(_.fields,(j,B)=>(l(),a("div",{class:"w-full md:w-1/2 p-2",key:B},[k(f,{onChange:O=>s.handleUnitGroupFieldChanged(O,_),onSaved:O=>s.handleSavedUnitGroupFields(O,j),field:j},null,8,["onChange","onSaved","field"])]))),128))])]),i("div",{onClick:j=>s.removeUnitPriceGroup(_,u.groups),class:"p-1 hover:bg-error-primary border-t border-box-elevation-edge flex items-center justify-center cursor-pointer font-medium"},c(s.__("Delete")),9,_t)])]),_:2},1032,["identifier","label"]))),256))]),_:2},1032,["onChangeTab","active"])):m("",!0)])):m("",!0)],64))),256)):m("",!0),!e.unitLoaded&&!e.unitLoadError?(l(),a("div",gt,[k(o)])):m("",!0),e.unitLoadError&&!e.unitLoaded?(l(),a("div",vt,[yt,i("p",xt,c(s.__("We were not able to load the units. Make sure there are units attached on the unit group selected.")),1)])):m("",!0)])):m("",!0)])])]))),128))])])],64)):m("",!0)])}const Pt=M(Ce,[["render",wt]]);export{Pt as default}; diff --git a/public/build/assets/ns-pos-7cc83bf8.js b/public/build/assets/ns-pos-7cc83bf8.js new file mode 100644 index 000000000..5a69eb93c --- /dev/null +++ b/public/build/assets/ns-pos-7cc83bf8.js @@ -0,0 +1 @@ +import b from"./ns-pos-cart-a5bf23af.js";import v from"./ns-pos-grid-32143241.js";import{_}from"./_plugin-vue_export-helper-c27b6911.js";import{r,o as e,c as o,a as i,F as h,b as x,g as S,j as w,n as l,f as c,e as a}from"./runtime-core.esm-bundler-414a078a.js";import"./bootstrap-ffaf6d09.js";import"./currency-feccde3d.js";import"./chart-2ccf8ff7.js";import"./pos-section-switch-0869c4e1.js";import"./ns-pos-shipping-popup-dffc98ef.js";import"./ns-prompt-popup-24cc8d6f.js";import"./ns-orders-preview-popup-3c654295.js";import"./index.es-25aa42ee.js";const k={name:"ns-pos",computed:{buttons(){return POS.header.buttons}},mounted(){this.visibleSectionSubscriber=POS.visibleSection.subscribe(n=>{this.visibleSection=n});const s=document.getElementById("loader");s.classList.remove("fade-in-entrance"),s.classList.add("fade-out-exit"),setTimeout(()=>{s.remove(),POS.reset()},500)},unmounted(){this.visibleSectionSubscriber.unsubscribe()},data(){return{visibleSection:null,visibleSectionSubscriber:null}},components:{nsPosCart:b,nsPosGrid:v}},g={class:"h-full flex-auto flex flex-col",id:"pos-container"},P={class:"flex overflow-hidden flex-shrink-0 px-2 pt-2"},y={class:"-mx-2 flex overflow-x-auto pb-1"},B={class:"flex-auto overflow-hidden flex p-2"},C={class:"flex flex-auto overflow-hidden -m-2"};function L(s,n,N,O,t,d){const m=r("ns-pos-cart"),u=r("ns-pos-grid");return e(),o("div",g,[i("div",P,[i("div",y,[(e(!0),o(h,null,x(d.buttons,(p,f)=>(e(),o("div",{class:"header-buttons flex px-2 flex-shrink-0",key:f},[(e(),S(w(p)))]))),128))])]),i("div",B,[i("div",C,[["both","cart"].includes(t.visibleSection)?(e(),o("div",{key:0,class:l([t.visibleSection==="both"?"w-1/2":"w-full","flex overflow-hidden p-2"])},[c(m)],2)):a("",!0),["both","grid"].includes(t.visibleSection)?(e(),o("div",{key:1,class:l([t.visibleSection==="both"?"w-1/2":"w-full","p-2 flex overflow-hidden"])},[c(u)],2)):a("",!0)])])])}const J=_(k,[["render",L]]);export{J as default}; diff --git a/public/build/assets/ns-pos-a91ba1d6.js b/public/build/assets/ns-pos-a91ba1d6.js deleted file mode 100644 index b5d757fe3..000000000 --- a/public/build/assets/ns-pos-a91ba1d6.js +++ /dev/null @@ -1 +0,0 @@ -import b from"./ns-pos-cart-32f5a2e0.js";import v from"./ns-pos-grid-32143241.js";import{_}from"./_plugin-vue_export-helper-c27b6911.js";import{r,o as e,c as o,a as i,F as h,b as x,g as S,j as w,n as l,f as c,e as a}from"./runtime-core.esm-bundler-414a078a.js";import"./bootstrap-ffaf6d09.js";import"./currency-feccde3d.js";import"./chart-2ccf8ff7.js";import"./pos-section-switch-0869c4e1.js";import"./ns-pos-order-type-popup-14f46b3a.js";import"./ns-prompt-popup-24cc8d6f.js";import"./ns-orders-preview-popup-3c654295.js";import"./index.es-25aa42ee.js";import"./ns-pos-shipping-popup-5ba7ac6e.js";const k={name:"ns-pos",computed:{buttons(){return POS.header.buttons}},mounted(){this.visibleSectionSubscriber=POS.visibleSection.subscribe(n=>{this.visibleSection=n});const s=document.getElementById("loader");s.classList.remove("fade-in-entrance"),s.classList.add("fade-out-exit"),setTimeout(()=>{s.remove(),POS.reset()},500)},unmounted(){this.visibleSectionSubscriber.unsubscribe()},data(){return{visibleSection:null,visibleSectionSubscriber:null}},components:{nsPosCart:b,nsPosGrid:v}},g={class:"h-full flex-auto flex flex-col",id:"pos-container"},P={class:"flex overflow-hidden flex-shrink-0 px-2 pt-2"},y={class:"-mx-2 flex overflow-x-auto pb-1"},B={class:"flex-auto overflow-hidden flex p-2"},C={class:"flex flex-auto overflow-hidden -m-2"};function L(s,n,N,O,t,d){const m=r("ns-pos-cart"),u=r("ns-pos-grid");return e(),o("div",g,[i("div",P,[i("div",y,[(e(!0),o(h,null,x(d.buttons,(p,f)=>(e(),o("div",{class:"header-buttons flex px-2 flex-shrink-0",key:f},[(e(),S(w(p)))]))),128))])]),i("div",B,[i("div",C,[["both","cart"].includes(t.visibleSection)?(e(),o("div",{key:0,class:l([t.visibleSection==="both"?"w-1/2":"w-full","flex overflow-hidden p-2"])},[c(m)],2)):a("",!0),["both","grid"].includes(t.visibleSection)?(e(),o("div",{key:1,class:l([t.visibleSection==="both"?"w-1/2":"w-full","p-2 flex overflow-hidden"])},[c(u)],2)):a("",!0)])])])}const K=_(k,[["render",L]]);export{K as default}; diff --git a/public/build/assets/ns-pos-cart-32f5a2e0.js b/public/build/assets/ns-pos-cart-32f5a2e0.js deleted file mode 100644 index 654f7b658..000000000 --- a/public/build/assets/ns-pos-cart-32f5a2e0.js +++ /dev/null @@ -1 +0,0 @@ -import{p as q,v as R,w as A,F as D,a as V,d as v,b as U,G as E,n as I,P as y}from"./bootstrap-ffaf6d09.js";import{_ as a,n as B}from"./currency-feccde3d.js";import{s as M}from"./pos-section-switch-0869c4e1.js";import{a as H,c as Y,n as G,b as $,P as W}from"./ns-pos-order-type-popup-14f46b3a.js";import{_ as P}from"./_plugin-vue_export-helper-c27b6911.js";import{o as i,c as d,a as o,t as r,r as b,f,B as z,F as x,b as C,g as S,w as k,i as O,e as p,h as T,ay as j,n as N,j as L}from"./runtime-core.esm-bundler-414a078a.js";import{c as K,a as J,k as X,n as F}from"./ns-prompt-popup-24cc8d6f.js";import Z from"./ns-pos-shipping-popup-5ba7ac6e.js";import"./index.es-25aa42ee.js";import"./chart-2ccf8ff7.js";import"./ns-orders-preview-popup-3c654295.js";const ee={props:["order"],methods:{__,async payOrder(){const e=nsHooks.applyFilters("ns-pay-queue",[ProductsQueue,CustomerQueue,TypeQueue,PaymentQueue]);for(let t in e)try{const l=await new e[t](this.order).run()}catch(u){return console.log(u),!1}}},mounted(){for(let e in nsShortcuts)["ns_pos_keyboard_payment"].includes(e)&&nsHotPress.create("ns_pos_keyboard_payment").whenNotVisible([".is-popup"]).whenPressed(nsShortcuts[e]!==null?nsShortcuts[e].join("+"):null,t=>{t.preventDefault(),this.payOrder()})},unmounted(){nsHotPress.destroy("ns_pos_keyboard_payment")}},te=o("i",{class:"mr-2 text-2xl lg:text-xl las la-cash-register"},null,-1),se={class:"text-lg hidden md:inline lg:text-2xl"};function oe(e,t,u,l,c,s){return i(),d("div",{onClick:t[0]||(t[0]=n=>s.payOrder()),id:"pay-button",class:"flex-shrink-0 w-1/4 flex items-center font-bold cursor-pointer justify-center bg-green-500 text-white hover:bg-green-600 border-r border-green-600 flex-auto"},[te,o("span",se,r(s.__("Pay")),1)])}const re=P(ee,[["render",oe]]),ne={name:"ns-pos-hold-orders",props:["popup"],data(){return{order:{},title:"",show:!0}},mounted(){this.popupCloser(),this.show=POS.getHoldPopupEnabled(),this.show||this.popup.params.resolve({title:this.title}),this.$refs.reference.focus(),this.$refs.reference.select(),this.order=this.popup.params.order,this.title=this.popup.params.order.title||""},methods:{__:a,nsCurrency:B,popupCloser:q,submitHold(){this.popup.close(),this.popup.params.resolve({title:this.title})}}},ie={class:"ns-box shadow-lg w-6/7-screen md:w-3/7-screen lg:w-2/6-screen"},de={class:"p-2 flex ns-box-header justify-between border-b items-center"},le={class:"font-semibold"},ae={class:"flex-auto ns-box-body"},ue={class:"border-b h-16 flex items-center justify-center"},ce={class:"text-5xl text-primary"},pe={class:"p-2"},_e={class:"input-group border-2 info"},he=["placeholder"],be={class:"p-2"},me={class:"text-secondary"},fe={class:"flex ns-box-footer"};function ye(e,t,u,l,c,s){const n=b("ns-close-button");return i(),d("div",ie,[o("div",de,[o("h3",le,r(s.__("Hold Order")),1),o("div",null,[f(n,{onClick:t[0]||(t[0]=_=>u.popup.close())})])]),o("div",ae,[o("div",ue,[o("span",ce,r(s.nsCurrency(c.order.total)),1)]),o("div",pe,[o("div",_e,[z(o("input",{onKeyup:t[1]||(t[1]=A(_=>s.submitHold(),["enter"])),"onUpdate:modelValue":t[2]||(t[2]=_=>c.title=_),ref:"reference",type:"text",placeholder:s.__("Order Reference"),class:"outline-none rounded border-2 p-2 w-full"},null,40,he),[[R,c.title]])])]),o("div",be,[o("p",me,r(s.__("The current order will be set on hold. You can retrieve this order from the pending order button. Providing a reference to it might help you to identify the order more quickly.")),1)])]),o("div",fe,[o("div",{onClick:t[3]||(t[3]=_=>s.submitHold()),class:"cursor-pointer w-1/2 py-3 flex justify-center items-center bg-green-500 text-white font-semibold"},r(s.__("Confirm")),1),o("div",{onClick:t[4]||(t[4]=_=>u.popup.close()),class:"cursor-pointer w-1/2 py-3 flex justify-center items-center bg-error-secondary text-white font-semibold"},r(s.__("Cancel")),1)])])}const ve=P(ne,[["render",ye]]),xe={props:["order"],methods:{__,async holdOrder(){if(this.order.payment_status!=="hold"&&this.order.payments.length>0)return nsSnackBar.error(__("Unable to hold an order which payment status has been updated already.")).subscribe();const e=nsHooks.applyFilters("ns-hold-queue",[ProductsQueue,CustomerQueue,TypeQueue]);for(let u in e)try{const c=await new e[u](this.order).run()}catch{return!1}nsHooks.applyFilters("ns-override-hold-popup",()=>{new Promise((l,c)=>{Popup.show(ve,{resolve:l,reject:c,order:this.order})}).then(l=>{this.order.title=l.title,this.order.payment_status="hold",POS.order.next(this.order);const c=Popup.show(K);POS.submitOrder().then(s=>{c.close(),nsSnackBar.success(s.message).subscribe()},s=>{c.close(),nsSnackBar.error(s.message).subscribe()})}).catch(l=>{console.log(l)})})()}},mounted(){for(let e in nsShortcuts)["ns_pos_keyboard_hold_order"].includes(e)&&nsHotPress.create("ns_pos_keyboard_hold_order").whenNotVisible([".is-popup"]).whenPressed(nsShortcuts[e]!==null?nsShortcuts[e].join("+"):null,t=>{t.preventDefault(),this.holdOrder()})},unmounted(){nsHotPress.destroy("ns_pos_keyboard_hold_order")}},we=o("i",{class:"mr-2 text-2xl lg:text-xl las la-pause"},null,-1),ge={class:"text-lg hidden md:inline lg:text-2xl"};function Pe(e,t,u,l,c,s){return i(),d("div",{onClick:t[0]||(t[0]=n=>s.holdOrder()),id:"hold-button",class:"flex-shrink-0 w-1/4 flex items-center font-bold cursor-pointer justify-center bg-blue-500 text-white border-r hover:bg-blue-600 border-blue-600 flex-auto"},[we,o("span",ge,r(s.__("Hold")),1)])}const ke=P(xe,[["render",Pe]]),Ce={props:["order","settings"],methods:{__,openDiscountPopup(e,t,u=null){if(!this.settings.products_discount&&t==="product")return nsSnackBar.error(__("You're not allowed to add a discount on the product.")).subscribe();if(!this.settings.cart_discount&&t==="cart")return nsSnackBar.error(__("You're not allowed to add a discount on the cart.")).subscribe();Popup.show(H,{reference:e,type:t,onSubmit(l){t==="product"?POS.updateProduct(e,l,u):t==="cart"&&POS.updateCart(e,l)}},{popupClass:"bg-white h:2/3 shadow-lg xl:w-1/4 lg:w-2/5 md:w-2/3 w-full"})}}},Se=o("i",{class:"mr-2 text-2xl lg:text-xl las la-percent"},null,-1),Te={class:"text-lg hidden md:inline lg:text-2xl"};function Oe(e,t,u,l,c,s){return i(),d("div",{onClick:t[0]||(t[0]=n=>s.openDiscountPopup(u.order,"cart")),id:"discount-button",class:"flex-shrink-0 w-1/4 flex items-center font-bold cursor-pointer justify-center border-r border-box-edge flex-auto"},[Se,o("span",Te,r(s.__("Discount")),1)])}const je=P(Ce,[["render",Oe]]),Ne={props:["order","settings"],methods:{__,voidOngoingOrder(){POS.voidOrder(this.order)}}},qe=o("i",{class:"mr-2 text-2xl lg:text-xl las la-trash"},null,-1),De={class:"text-lg hidden md:inline lg:text-2xl"};function Be(e,t,u,l,c,s){return i(),d("div",{onClick:t[0]||(t[0]=n=>s.voidOngoingOrder(u.order)),id:"void-button",class:"flex-shrink-0 w-1/4 flex items-center font-bold cursor-pointer justify-center bg-red-500 text-white border-box-edge hover:bg-red-600 flex-auto"},[qe,o("span",De,r(s.__("Void")),1)])}const Fe=P(Ne,[["render",Be]]),Ve={name:"ns-pos-note-popup",props:["popup"],data(){return{validation:new D,fields:[{label:a("Note"),name:"note",value:"",description:a("More details about this order"),type:"textarea"},{label:a("Display On Receipt"),name:"note_visibility",value:"",options:[{label:a("Yes"),value:"visible"},{label:a("No"),value:"hidden"}],description:a("Will display the note on the receipt"),type:"switch"}]}},mounted(){this.popupCloser(),this.fields.forEach(e=>{e.name==="note"?e.value=this.popup.params.note:e.name==="note_visibility"&&(e.value=this.popup.params.note_visibility)})},methods:{__:a,popupResolver:V,popupCloser:q,closePopup(){this.popupResolver(!1)},saveNote(){if(!this.validation.validateFields(this.fields)){const e=this.validation.validateFieldsErrors(this.fields);return this.validation.triggerFieldsErrors(this.fields,e),this.$forceUpdate(),v.error(a("Unable to proceed the form is not valid.")).subscribe()}return this.popupResolver(this.validation.extractFields(this.fields))}}},He={class:"shadow-lg ns-box w-95vw md:w-3/5-screen lg:w-2/5-screen"},Qe={class:"p-2 flex justify-between items-center border-b ns-box-header"},Re={class:"font-bold"},Ae={class:"p-2"},Ue={class:"p-2 flex justify-end border-t ns-box-footer"};function Ee(e,t,u,l,c,s){const n=b("ns-close-button"),_=b("ns-field"),m=b("ns-button");return i(),d("div",He,[o("div",Qe,[o("h3",Re,r(s.__("Order Note")),1),o("div",null,[f(n,{onClick:t[0]||(t[0]=h=>s.closePopup())})])]),o("div",Ae,[(i(!0),d(x,null,C(c.fields,(h,w)=>(i(),S(_,{key:w,field:h},null,8,["field"]))),128))]),o("div",Ue,[f(m,{type:"info",onClick:t[1]||(t[1]=h=>s.saveNote())},{default:k(()=>[O(r(s.__("Save")),1)]),_:1})])])}const Ie=P(Ve,[["render",Ee]]),Me={name:"ns-pos-tax-popup",props:["popup"],data(){return{validation:new D,tax_group:[],order:null,orderSubscriber:null,optionsSubscriber:null,options:{},tax_groups:[],activeTab:"",group_fields:[{label:a("Select Tax"),name:"tax_group_id",description:a("Define the tax that apply to the sale."),type:"select",disabled:!0,value:"",validation:"required",options:[]},{label:a("Type"),name:"tax_type",disabled:!0,value:"",description:a("Define how the tax is computed"),type:"select",validation:"required",options:[{label:a("Exclusive"),value:"exclusive"},{label:a("Inclusive"),value:"inclusive"}]}]}},mounted(){this.loadGroups(),this.popupCloser(),this.activeTab=this.popup.params.activeTab||"settings",this.group_fields.forEach(e=>{e.value=this.popup.params[e.name]||void 0}),this.orderSubscriber=POS.order.subscribe(e=>{this.order=e}),this.optionsSubscriber=POS.options.subscribe(e=>{this.options=e,["variable_vat","products_variable_vat"].includes(this.options.ns_pos_vat)&&this.group_fields.forEach(t=>t.disabled=!1)})},unmounted(){this.orderSubscriber.unsubscribe(),this.optionsSubscriber.unsubscribe()},methods:{__:a,nsCurrency:B,popupCloser:q,popupResolver:V,changeActive(e){this.activeTab=e},closePopup(){this.popupResolver(!1)},saveTax(){if(!this.validation.validateFields(this.group_fields))return v.error(a("Unable to proceed the form is not valid.")).subscribe();const e=this.validation.extractFields(this.group_fields);e.tax_groups=[],this.popupResolver(e)},loadGroups(){U.get("/api/taxes/groups").subscribe(e=>{this.groups=e,this.group_fields.forEach(t=>{t.name==="tax_group_id"&&(t.options=this.groups.map(u=>({label:u.name,value:u.id})))})})}}},Ye={class:"ns-box shadow-lg w-95vw md:w-3/5-screen lg:w-2/5-screen"},Ge={class:"p-2 flex justify-between items-center border-b ns-box-header"},$e={class:"text-blog"},We={class:"p-2 ns-box-body"},ze={class:"p-2 border-b ns-box-body"},Le={class:"flex justify-end p-2"},Ke={key:0,class:"p-2"},Je={key:0,class:"p-2 text-center text-primary"},Xe={key:0,class:"p-2"},Ze={class:"border shadow p-2 w-full flex justify-between items-center elevation-surface"};function et(e,t,u,l,c,s){const n=b("ns-close-button"),_=b("ns-field"),m=b("ns-button"),h=b("ns-tabs-item"),w=b("ns-tabs");return i(),d("div",Ye,[o("div",Ge,[o("h3",$e,r(s.__("Tax & Summary")),1),o("div",null,[f(n,{onClick:t[0]||(t[0]=g=>s.closePopup())})])]),o("div",We,[f(w,{active:c.activeTab,onChangeTab:t[2]||(t[2]=g=>s.changeActive(g))},{default:k(()=>[f(h,{padding:"0",label:s.__("Settings"),identifier:"settings",active:!0},{default:k(()=>[o("div",ze,[(i(!0),d(x,null,C(c.group_fields,(g,Q)=>(i(),S(_,{field:g,key:Q},null,8,["field"]))),128))]),o("div",Le,[f(m,{onClick:t[1]||(t[1]=g=>s.saveTax()),type:"info"},{default:k(()=>[O(r(s.__("Save")),1)]),_:1})])]),_:1},8,["label"]),f(h,{padding:"0",label:s.__("Summary"),identifier:"summary",active:!1},{default:k(()=>[c.order?(i(),d("div",Ke,[(i(!0),d(x,null,C(c.order.taxes,g=>(i(),d("div",{key:g.id,class:"mb-2 border shadow p-2 w-full flex justify-between items-center elevation-surface"},[o("span",null,r(g.name),1),o("span",null,r(s.nsCurrency(g.tax_value)),1)]))),128)),c.order.taxes.length===0?(i(),d("div",Je,r(s.__("No tax is active")),1)):p("",!0)])):p("",!0)]),_:1},8,["label"]),f(h,{padding:"0",label:s.__("Product Taxes"),identifier:"product_taxes",active:!1},{default:k(()=>[c.order?(i(),d("div",Xe,[o("div",Ze,[o("span",null,r(s.__("Product Taxes")),1),o("span",null,r(s.nsCurrency(c.order.products_tax_value)),1)])])):p("",!0)]),_:1},8,["label"])]),_:1},8,["active"])])])}const tt=P(Me,[["render",et]]),st={name:"ns-pos-order-settings",props:["popup"],mounted(){nsHttpClient.get("/api/fields/ns.pos-order-settings").subscribe(e=>{e.forEach(t=>{t.value=this.popup.params.order[t.name]||""}),this.fields=this.validation.createFields(e)},e=>{}),this.popupCloser()},data(){return{fields:[],validation:new D}},methods:{__,popupCloser,popupResolver,closePopup(){this.popupResolver(!1)},saveSettings(){const e=this.validation.extractFields(this.fields);this.popupResolver(e)}}},ot={class:"shadow-lg flex flex-col ns-box w-95vw h-95vh md:w-3/5-screen md:h-3/5-screen lg:w-2/5-screen"},rt={class:"p-2 border-b ns-box-header items-center flex justify-between"},nt={class:"text-semibold"},it={class:"p-2 flex-auto border-b ns-box-body overflow-y-auto"},dt={class:"p-2 flex justify-end ns-box-footer"};function lt(e,t,u,l,c,s){const n=b("ns-close-button"),_=b("ns-field"),m=b("ns-button");return i(),d("div",ot,[o("div",rt,[o("h3",nt,r(s.__("Order Settings")),1),o("div",null,[f(n,{onClick:t[0]||(t[0]=h=>s.closePopup())})])]),o("div",it,[(i(!0),d(x,null,C(c.fields,(h,w)=>(i(),S(_,{field:h,key:w},null,8,["field"]))),128))]),o("div",dt,[f(m,{onClick:t[1]||(t[1]=h=>s.saveSettings()),type:"info"},{default:k(()=>[O(r(s.__("Save")),1)]),_:1})])])}const at=P(st,[["render",lt]]),ut={name:"ns-pos-product-price-product",props:["popup"],components:{nsNumpad:J,nsNumpadPlus:X},computed:{},data(){return{product:{},optionsSubscription:null,options:{},price:0}},mounted(){this.popupCloser(),this.product=this.popup.params.product,this.optionsSubscription=POS.options.subscribe(e=>{this.options=T(e)})},beforeDestroy(){this.optionsSubscription.unsubscribe()},methods:{popupResolver,popupCloser,nsCurrency:B,__,updateProductPrice(e){this.product.unit_price=e},resolveProductPrice(e){this.popupResolver(this.product.unit_price)}}},ct={class:"ns-box shadow-lg w-95vw md:w-3/5-screen lg:w-2/5-screen"},pt={class:"popup-heading ns-box-header"},_t={class:"flex flex-col ns-box-body"},ht={class:"h-16 flex items-center justify-center elevation-surface info font-bold"},bt={class:"text-2xl"};function mt(e,t,u,l,c,s){const n=b("ns-close-button"),_=b("ns-numpad"),m=b("ns-numpad-plus");return i(),d("div",ct,[o("div",pt,[o("h3",null,r(s.__("Product Price")),1),o("div",null,[f(n,{onClick:t[0]||(t[0]=h=>s.popupResolver(!1))})])]),o("div",_t,[o("div",ht,[o("h2",bt,r(s.nsCurrency(c.product.unit_price)),1)]),c.options.ns_pos_numpad==="default"?(i(),S(_,{key:0,floating:c.options.ns_pos_allow_decimal_quantities,onChanged:t[1]||(t[1]=h=>s.updateProductPrice(h)),onNext:t[2]||(t[2]=h=>s.resolveProductPrice(h)),value:c.product.unit_price},null,8,["floating","value"])):p("",!0),c.options.ns_pos_numpad==="advanced"?(i(),S(m,{key:1,onChanged:t[3]||(t[3]=h=>s.updateProductPrice(h)),onNext:t[4]||(t[4]=h=>s.resolveProductPrice(h)),value:c.product.unit_price},null,8,["value"])):p("",!0)])])}const ft=P(ut,[["render",mt]]),yt={name:"ns-pos-quick-product-popup",props:["popup"],methods:{__:a,popupCloser:q,popupResolver:V,close(){this.popupResolver(!1)},async addProduct(){const e=this.validation.extractFields(this.fields),t=this.fields.filter(s=>typeof s.show>"u"||typeof s.show=="function"&&s.show(e));if(!this.validation.validateFields(t))return v.error(a("Unable to proceed. The form is not valid.")).subscribe();let l=this.validation.extractFields(t);l.$original=()=>({stock_management:"disabled",category_id:0,tax_group:this.tax_groups.filter(s=>parseInt(s.id)===parseInt(l.tax_group_id))[0],tax_group_id:l.tax_group_id,tax_type:l.tax_type}),l.product_type==="product"?(l.unit_name=this.units.filter(s=>s.id===l.unit_id)[0].name,l.quantity=parseFloat(l.quantity),l.unit_price=parseFloat(l.unit_price),l.mode="custom",l.price_with_tax=l.unit_price,l.price_without_tax=l.unit_price,l.tax_value=0):(l.unit_name=a("N/A"),l.unit_price=0,l.quantity=1);const c=await POS.defineQuantities(l,this.units);l.$quantities=()=>c,l=POS.computeProductTax(l),POS.addToCart(l),this.close()},loadData(){this.loaded=!1,E(nsHttpClient.get("/api/units"),nsHttpClient.get("/api/taxes/groups")).subscribe({next:e=>{this.units=e[0],this.tax_groups=e[1],this.fields.filter(t=>{t.name==="tax_group_id"&&(t.options=e[1].map(u=>({label:u.name,value:u.id})),e[1].length>0&&e[1][0].id!==void 0&&(t.value=e[1][0].id||this.options.ns_pos_tax_group)),t.name==="tax_type"&&(t.value=this.options.tax_type||"inclusive"),t.name==="unit_id"&&(t.value=this.options.ns_pos_quick_product_default_unit,t.options=e[0].map(u=>({label:u.name,value:u.id})))}),this.buildForm()},error:e=>{}})},buildForm(){this.fields=this.validation.createFields(this.fields),this.loaded=!0,setTimeout(()=>{this.$el.querySelector("#name").select()},100)}},computed:{form(){return this.validation.extractFields(this.fields)}},data(){return{units:[],options:POS.options.getValue(),tax_groups:[],loaded:!1,validation:new D,fields:[{label:a("Name"),name:"name",type:"text",description:a("Provide a unique name for the product."),validation:"required"},{label:a("Product Type"),name:"product_type",type:"select",description:a("Define the product type."),options:[{label:a("Normal"),value:"product"},{label:a("Dynamic"),value:"dynamic"}],value:"product",validation:"required"},{label:a("Rate"),name:"rate",type:"text",description:a("In case the product is computed based on a percentage, define the rate here."),validation:"required",show(e){return e.product_type==="dynamic"}},{label:a("Unit Price"),name:"unit_price",type:"text",description:a("Define what is the sale price of the item."),validation:"",value:0,show(e){return e.product_type==="product"}},{label:a("Quantity"),name:"quantity",type:"text",value:1,description:a("Set the quantity of the product."),validation:"",show(e){return e.product_type==="product"}},{label:a("Unit"),name:"unit_id",type:"select",options:[],description:a("Assign a unit to the product."),validation:"",show(e){return e.product_type==="product"}},{label:a("Tax Type"),name:"tax_type",type:"select",options:[{label:a("Disabled"),value:""},{label:a("Inclusive"),value:"inclusive"},{label:a("Exclusive"),value:"exclusive"}],description:a("Define what is tax type of the item."),show(e){return e.product_type==="product"}},{label:a("Tax Group"),name:"tax_group_id",type:"select",options:[],description:a("Choose the tax group that should apply to the item."),show(e){return e.product_type==="product"}}]}},mounted(){this.popupCloser(),this.loadData()}},vt={class:"w-95vw flex flex-col h-95vh shadow-lg md:w-3/5-screen lg:w-2/5-screen md:h-3/5-screen ns-box"},xt={class:"header ns-box-header border-b flex justify-between p-2 items-center"},wt={class:"ns-box-body p-2 flex-auto overflow-y-auto"},gt={key:0,class:"h-full w-full flex justify-center items-center"},Pt={class:"ns-box-footer border-t flex justify-between p-2"},kt=o("div",null,null,-1);function Ct(e,t,u,l,c,s){const n=b("ns-close-button"),_=b("ns-spinner"),m=b("ns-field"),h=b("ns-button");return i(),d("div",vt,[o("div",xt,[o("h3",null,r(s.__("Product / Service")),1),o("div",null,[f(n,{onClick:t[0]||(t[0]=w=>s.close())})])]),o("div",wt,[c.loaded?p("",!0):(i(),d("div",gt,[f(_)])),c.loaded?(i(!0),d(x,{key:1},C(c.fields,(w,g)=>(i(),d(x,null,[w.show&&w.show(s.form)||!w.show?(i(),S(m,{key:g,field:w},null,8,["field"])):p("",!0)],64))),256)):p("",!0)]),o("div",Pt,[kt,o("div",null,[f(h,{onClick:t[1]||(t[1]=w=>s.addProduct()),type:"info"},{default:k(()=>[O(r(s.__("Create")),1)]),_:1})])])])}const St=P(yt,[["render",Ct]]),Tt={name:"ns-pos-cart",data:()=>({popup:null,cartButtons:{},products:[],defaultCartButtons:{nsPosPayButton:j(re),nsPosHoldButton:j(ke),nsPosDiscountButton:j(je),nsPosVoidButton:j(Fe)},visibleSection:null,visibleSectionSubscriber:null,cartButtonsSubscriber:null,optionsSubscriber:null,options:{},typeSubscribe:null,orderSubscribe:null,productSubscribe:null,settingsSubscribe:null,settings:{},types:[],order:T({})}),computed:{selectedType(){return this.order.type?this.order.type.label:"N/A"},isVisible(){return this.visibleSection==="cart"},customerName(){return this.order.customer?`${this.order.customer.first_name||this.order.customer.last_name?this.getFirstName():this.getUserName()}`:"N/A"},couponName(){return a("Apply Coupon")}},mounted(){this.cartButtonsSubscriber=POS.cartButtons.subscribe(e=>{this.cartButtons=e}),this.optionsSubscriber=POS.options.subscribe(e=>{this.options=e}),this.typeSubscribe=POS.types.subscribe(e=>this.types=e),this.orderSubscribe=POS.order.subscribe(e=>{this.order=T(e)}),this.productSubscribe=POS.products.subscribe(e=>{this.products=T(e)}),this.settingsSubscribe=POS.settings.subscribe(e=>{this.settings=T(e)}),this.visibleSectionSubscriber=POS.visibleSection.subscribe(e=>{this.visibleSection=T(e)}),I.addAction("ns-before-cart-reset","ns-pos-cart-buttons",()=>{POS.cartButtons.next(this.defaultCartButtons)});for(let e in nsShortcuts)["ns_pos_keyboard_shipping"].includes(e)&&nsHotPress.create("ns_pos_keyboard_shipping").whenNotVisible([".is-popup"]).whenPressed(nsShortcuts[e]!==null?nsShortcuts[e].join("+"):null,t=>{t.preventDefault(),this.openShippingPopup()}),["ns_pos_keyboard_note"].includes(e)&&nsHotPress.create("ns_pos_keyboard_note").whenNotVisible([".is-popup"]).whenPressed(nsShortcuts[e]!==null?nsShortcuts[e].join("+"):null,t=>{t.preventDefault(),this.openNotePopup()})},unmounted(){this.visibleSectionSubscriber.unsubscribe(),this.typeSubscribe.unsubscribe(),this.orderSubscribe.unsubscribe(),this.productSubscribe.unsubscribe(),this.settingsSubscribe.unsubscribe(),this.optionsSubscriber.unsubscribe(),this.cartButtonsSubscriber.unsubscribe(),nsHotPress.destroy("ns_pos_keyboard_shipping"),nsHotPress.destroy("ns_pos_keyboard_note")},methods:{__:a,nsCurrency:B,switchTo:M,getFirstName(){return`${this.order.customer.first_name||""} ${this.order.customer.last_name||""}`},getUserName(){return this.order.customer.username},takeRandomClass(){return"border-gray-500 bg-gray-400 text-white hover:bg-gray-500"},openAddQuickProduct(){new Promise((t,u)=>{y.show(St,{resolve:t,reject:u})}).then(t=>{}).catch(t=>{})},summarizeCoupons(){const e=this.order.coupons.map(t=>t.value);return e.length>0?e.reduce((t,u)=>t+u):0},async changeProductPrice(e){if(!this.settings.edit_purchase_price)return v.error(a("You don't have the right to edit the purchase price.")).subscribe();if(e.product_type==="dynamic")return v.error(a("Dynamic product can't have their price updated.")).subscribe();if(this.settings.unit_price_editable)try{const t=await new Promise((l,c)=>y.show(ft,{product:Object.assign({},e),resolve:l,reject:c})),u={...e.$quantities(),custom_price_edit:t};return e.$quantities=()=>u,e.mode="custom",e=POS.computeProductTax(e),POS.recomputeProducts(POS.products.getValue()),POS.refreshCart(),v.success(a("The product price has been updated.")).subscribe()}catch(t){if(t!==!1)throw v.error(t).subscribe(),t}else return v.error(a("The editable price feature is disabled.")).subscribe()},async selectCoupon(){try{const e=await new Promise((t,u)=>{y.show(Y,{resolve:t,reject:u})})}catch{}},async defineOrderSettings(){if(!this.settings.edit_settings)return v.error(a("You're not allowed to edit the order settings.")).subscribe();try{const e=await new Promise((t,u)=>{y.show(at,{resolve:t,reject:u,order:this.order})});POS.order.next({...this.order,...e})}catch{}},async openNotePopup(){try{const e=await new Promise((u,l)=>{const c=this.order.note,s=this.order.note_visibility;y.show(Ie,{resolve:u,reject:l,note:c,note_visibility:s})}),t={...this.order,...e};POS.order.next(t)}catch(e){e!==!1&&v.error(e.message).subscribe()}},async selectTaxGroup(e="settings"){try{const t=await new Promise((l,c)=>{const s=this.order.taxes,n=this.order.tax_group_id,_=this.order.tax_type;y.show(tt,{resolve:l,reject:c,taxes:s,tax_group_id:n,tax_type:_,activeTab:e})}),u={...this.order,...t};POS.order.next(u),POS.refreshCart()}catch{}},openTaxSummary(){this.selectTaxGroup("summary")},selectCustomer(){y.show(G)},async openDiscountPopup(e,t,u=null){if(!this.settings.products_discount&&t==="product")return v.error(a("You're not allowed to add a discount on the product.")).subscribe();if(!this.settings.cart_discount&&t==="cart")return v.error(a("You're not allowed to add a discount on the cart.")).subscribe();try{const l=await new Promise((c,s)=>{y.show(H,{reference:e,resolve:c,reject:s,type:t,onSubmit(n){t==="product"?POS.updateProduct(e,n,u):t==="cart"&&POS.updateCart(e,n)}},{popupClass:"bg-white h:2/3 shadow-lg xl:w-1/4 lg:w-2/5 md:w-2/3 w-full"})})}catch{}},toggleMode(e,t){if(!this.options.ns_pos_allow_wholesale_price)return v.error(a("Unable to change the price mode. This feature has been disabled.")).subscribe();e.mode==="normal"?y.show(F,{title:a("Enable WholeSale Price"),message:a("Would you like to switch to wholesale price ?"),onAction(u){u&&POS.updateProduct(e,{mode:"wholesale"},t)}}):y.show(F,{title:a("Enable Normal Price"),message:a("Would you like to switch to normal price ?"),onAction(u){u&&POS.updateProduct(e,{mode:"normal"},t)}})},removeUsingIndex(e){y.show(F,{title:a("Confirm Your Action"),message:a("Would you like to delete this product ?"),onAction(t){t&&POS.removeProductUsingIndex(e)}})},allowQuantityModification(e){return e.product_type==="product"},changeQuantity(e,t){this.allowQuantityModification(e)&&new W(e).run({unit_quantity_id:e.unit_quantity_id,unit_name:e.unit_name,$quantities:e.$quantities}).then(l=>{POS.updateProduct(e,l,t)})},openOrderType(){y.show($)},openShippingPopup(){y.show(Z)}}},Ot={id:"pos-cart",class:"flex-auto flex flex-col"},jt={key:0,id:"tools",class:"flex pl-2 ns-tab"},Nt={key:0,class:"flex items-center justify-center text-sm rounded-full h-6 w-6 bg-green-500 text-white ml-1"},qt={class:"rounded shadow ns-tab-item flex-auto flex overflow-hidden"},Dt={class:"cart-table flex flex-auto flex-col overflow-hidden"},Bt={id:"cart-toolbox",class:"w-full p-2 border-b"},Ft={class:"border rounded overflow-hidden"},Vt={class:"flex flex-wrap"},Ht={class:"ns-button"},Qt=o("i",{class:"las la-comment"},null,-1),Rt={class:"ml-1 hidden md:inline-block"},At=o("hr",{class:"h-10",style:{width:"1px"}},null,-1),Ut={class:"ns-button"},Et=o("i",{class:"las la-balance-scale-left"},null,-1),It={class:"ml-1 hidden md:inline-block"},Mt={key:0,class:"ml-1 rounded-full flex items-center justify-center h-6 w-6 bg-info-secondary text-white"},Yt=o("hr",{class:"h-10",style:{width:"1px"}},null,-1),Gt={class:"ns-button"},$t=o("i",{class:"las la-tags"},null,-1),Wt={class:"ml-1 hidden md:inline-block"},zt={key:0,class:"ml-1 rounded-full flex items-center justify-center h-6 w-6 bg-info-secondary text-white"},Lt=o("hr",{class:"h-10",style:{width:"1px"}},null,-1),Kt={class:"ns-button"},Jt=o("i",{class:"las la-tools"},null,-1),Xt={class:"ml-1 hidden md:inline-block"},Zt=o("hr",{class:"h-10",style:{width:"1px"}},null,-1),es={key:0,class:"ns-button"},ts=o("i",{class:"las la-plus"},null,-1),ss={class:"ml-1 hidden md:inline-block"},os=o("hr",{class:"h-10",style:{width:"1px"}},null,-1),rs={id:"cart-table-header",class:"w-full text-primary font-semibold flex"},ns={class:"w-full lg:w-4/6 p-2 border border-l-0 border-t-0"},is={class:"hidden lg:flex lg:w-1/6 p-2 border-b border-t-0"},ds={class:"hidden lg:flex lg:w-1/6 p-2 border border-r-0 border-t-0"},ls={id:"cart-products-table",class:"flex flex-auto flex-col overflow-auto"},as={key:0,class:"text-primary flex"},us={class:"w-full text-center py-4 border-b"},cs=["product-index"],ps={class:"w-full lg:w-4/6 p-2 border border-l-0 border-t-0"},_s={class:"flex justify-between product-details mb-1"},hs={class:"font-semibold"},bs={class:"-mx-1 flex product-options"},ms={class:"px-1"},fs=["onClick"],ys=o("i",{class:"las la-trash text-xl"},null,-1),vs=[ys],xs={key:0,class:"px-1"},ws=["onClick"],gs=o("i",{class:"las la-award text-xl"},null,-1),Ps=[gs],ks={class:"flex justify-between product-controls"},Cs={class:"-mx-1 flex flex-wrap"},Ss={class:"px-1 w-1/2 md:w-auto mb-1"},Ts=["onClick"],Os={class:"px-1 w-1/2 md:w-auto mb-1"},js=["onClick"],Ns={key:0},qs={class:"px-1 w-1/2 md:w-auto mb-1 lg:hidden"},Ds=["onClick"],Bs={class:"px-1 w-1/2 md:w-auto mb-1 lg:hidden"},Fs={class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},Vs=["onClick"],Hs={key:0,class:"border-b border-dashed border-info-primary p-2"},Qs={class:"hidden lg:flex w-1/6 p-2 border border-r-0 border-t-0 items-center justify-center"},Rs={id:"cart-products-summary",class:"flex"},As={key:0,class:"table ns-table w-full text-sm"},Us={width:"200",class:"border p-2"},Es={width:"200",class:"border p-2"},Is={width:"200",class:"border p-2 text-right"},Ms={key:0},Ys=o("td",{width:"200",class:"border p-2"},null,-1),Gs={width:"200",class:"border p-2"},$s={width:"200",class:"border p-2 text-right"},Ws={width:"200",class:"border p-2"},zs={width:"200",class:"border p-2"},Ls={key:0},Ks={key:1},Js={width:"200",class:"border p-2 text-right"},Xs={key:1},Zs=o("td",{width:"200",class:"border p-2"},null,-1),eo={width:"200",class:"border p-2"},to={width:"200",class:"border p-2 text-right"},so={class:"success"},oo={width:"200",class:"border p-2"},ro={width:"200",class:"border p-2"},no={width:"200",class:"border p-2 text-right"},io={key:1,class:"table ns-table w-full text-sm"},lo={width:"200",class:"border p-2"},ao={width:"200",class:"border p-2"},uo={class:"flex justify-between"},co={key:0},po=o("td",{width:"200",class:"border p-2"},null,-1),_o={width:"200",class:"border p-2"},ho={width:"200",class:"border p-2 text-right"},bo={width:"200",class:"border p-2"},mo={width:"200",class:"border p-2"},fo={class:"flex justify-between items-center"},yo={key:0},vo={key:1},xo={key:1},wo=o("td",{width:"200",class:"border p-2"},null,-1),go={width:"200",class:"border p-2"},Po=o("span",null,null,-1),ko={class:"success"},Co={width:"200",class:"border p-2"},So={width:"200",class:"border p-2"},To={class:"flex justify-between w-full"},Oo={class:"h-16 flex flex-shrink-0 border-t border-box-edge",id:"cart-bottom-buttons"},jo=o("i",{class:"mx-4 rounded-full bg-slate-300 h-5 w-5"},null,-1),No=o("div",{class:"text-lg mr-4 hidden md:flex md:flex-auto lg:text-2xl"},[o("div",{class:"h-2 flex-auto bg-slate-200 rounded"})],-1),qo=[jo,No];function Do(e,t,u,l,c,s){return i(),d("div",Ot,[e.visibleSection==="cart"?(i(),d("div",jt,[o("div",{onClick:t[0]||(t[0]=n=>s.switchTo("cart")),class:"flex cursor-pointer rounded-tl-lg rounded-tr-lg px-3 py-2 font-semibold active tab"},[o("span",null,r(s.__("Cart")),1),e.order?(i(),d("span",Nt,r(e.order.products.length),1)):p("",!0)]),o("div",{onClick:t[1]||(t[1]=n=>s.switchTo("grid")),class:"cursor-pointer rounded-tl-lg rounded-tr-lg px-3 py-2 border-t border-r border-l inactive tab"},r(s.__("Products")),1)])):p("",!0),o("div",qt,[o("div",Dt,[o("div",Bt,[o("div",Ft,[o("div",Vt,[o("div",Ht,[o("button",{onClick:t[2]||(t[2]=n=>s.openNotePopup()),class:"w-full h-10 px-3 outline-none"},[Qt,o("span",Rt,r(s.__("Comments")),1)])]),At,o("div",Ut,[o("button",{onClick:t[3]||(t[3]=n=>s.selectTaxGroup()),class:"w-full h-10 px-3 outline-none flex items-center"},[Et,o("span",It,r(s.__("Taxes")),1),e.order.taxes&&e.order.taxes.length>0?(i(),d("span",Mt,r(e.order.taxes.length),1)):p("",!0)])]),Yt,o("div",Gt,[o("button",{onClick:t[4]||(t[4]=n=>s.selectCoupon()),class:"w-full h-10 px-3 outline-none flex items-center"},[$t,o("span",Wt,r(s.__("Coupons")),1),e.order.coupons&&e.order.coupons.length>0?(i(),d("span",zt,r(e.order.coupons.length),1)):p("",!0)])]),Lt,o("div",Kt,[o("button",{onClick:t[5]||(t[5]=n=>s.defineOrderSettings()),class:"w-full h-10 px-3 outline-none flex items-center"},[Jt,o("span",Xt,r(s.__("Settings")),1)])]),Zt,e.options.ns_pos_quick_product==="yes"?(i(),d("div",es,[o("button",{onClick:t[6]||(t[6]=n=>s.openAddQuickProduct()),class:"w-full h-10 px-3 outline-none flex items-center"},[ts,o("span",ss,r(s.__("Product")),1)])])):p("",!0),os])])]),o("div",rs,[o("div",ns,r(s.__("Product")),1),o("div",is,r(s.__("Quantity")),1),o("div",ds,r(s.__("Total")),1)]),o("div",ls,[e.products.length===0?(i(),d("div",as,[o("div",us,[o("h3",null,r(s.__("No products added...")),1)])])):p("",!0),(i(!0),d(x,null,C(e.products,(n,_)=>(i(),d("div",{"product-index":_,key:n.barcode,class:"product-item flex"},[o("div",ps,[o("div",_s,[o("h3",hs,r(n.name)+" — "+r(n.unit_name),1),o("div",bs,[o("div",ms,[o("a",{onClick:m=>s.removeUsingIndex(_),class:"hover:text-error-secondary cursor-pointer outline-none border-dashed py-1 border-b border-error-secondary text-sm"},vs,8,fs)]),e.options.ns_pos_allow_wholesale_price&&s.allowQuantityModification(n)?(i(),d("div",xs,[o("a",{class:N([n.mode==="wholesale"?"text-success-secondary border-success-secondary":"border-info-primary","cursor-pointer outline-none border-dashed py-1 border-b text-sm"]),onClick:m=>s.toggleMode(n,_)},Ps,10,ws)])):p("",!0)])]),o("div",ks,[o("div",Cs,[o("div",Ss,[o("a",{onClick:m=>s.changeProductPrice(n),class:N([n.mode==="wholesale"?"text-success-secondary hover:text-success-secondary border-success-secondary":"border-info-primary","cursor-pointer outline-none border-dashed py-1 border-b text-sm"])},r(s.__("Price"))+" : "+r(s.nsCurrency(n.unit_price)),11,Ts)]),o("div",Os,[s.allowQuantityModification(n)?(i(),d("a",{key:0,onClick:m=>s.openDiscountPopup(n,"product",_),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},[O(r(s.__("Discount"))+" ",1),n.discount_type==="percentage"?(i(),d("span",Ns,r(n.discount_percentage)+"%",1)):p("",!0),O(" : "+r(s.nsCurrency(n.discount)),1)],8,js)):p("",!0)]),o("div",qs,[s.allowQuantityModification(n)?(i(),d("a",{key:0,onClick:m=>s.changeQuantity(n,_),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Quantity"))+": "+r(n.quantity),9,Ds)):p("",!0)]),o("div",Bs,[o("span",Fs,r(s.__("Total :"))+" "+r(s.nsCurrency(n.total_price)),1)])])])]),o("div",{onClick:m=>s.changeQuantity(n,_),class:N([s.allowQuantityModification(n)?"cursor-pointer ns-numpad-key":"","hidden lg:flex w-1/6 p-2 border-b items-center justify-center"])},[s.allowQuantityModification(n)?(i(),d("span",Hs,r(n.quantity),1)):p("",!0)],10,Vs),o("div",Qs,r(s.nsCurrency(n.total_price)),1)],8,cs))),128))]),o("div",Rs,[e.visibleSection==="both"?(i(),d("table",As,[o("tr",null,[o("td",Us,[o("a",{onClick:t[7]||(t[7]=n=>s.selectCustomer()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Customer"))+": "+r(s.customerName),1)]),o("td",Es,r(s.__("Sub Total")),1),o("td",Is,r(s.nsCurrency(e.order.subtotal)),1)]),e.order.coupons.length>0?(i(),d("tr",Ms,[Ys,o("td",Gs,[o("a",{onClick:t[8]||(t[8]=n=>s.selectCoupon()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Coupons")),1)]),o("td",$s,r(s.nsCurrency(s.summarizeCoupons())),1)])):p("",!0),o("tr",null,[o("td",Ws,[o("a",{onClick:t[9]||(t[9]=n=>s.openOrderType()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Type"))+": "+r(s.selectedType),1)]),o("td",zs,[o("span",null,r(s.__("Discount")),1),e.order.discount_type==="percentage"?(i(),d("span",Ls,"("+r(e.order.discount_percentage)+"%)",1)):p("",!0),e.order.discount_type==="flat"?(i(),d("span",Ks,"("+r(s.__("Flat"))+")",1)):p("",!0)]),o("td",Js,[o("a",{onClick:t[10]||(t[10]=n=>s.openDiscountPopup(e.order,"cart")),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.nsCurrency(e.order.discount)),1)])]),e.order.type&&e.order.type.identifier==="delivery"?(i(),d("tr",Xs,[Zs,o("td",eo,[o("a",{onClick:t[11]||(t[11]=n=>s.openShippingPopup()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Shipping")),1)]),o("td",to,r(s.nsCurrency(e.order.shipping)),1)])):p("",!0),o("tr",so,[o("td",oo,[e.order&&e.options.ns_pos_tax_type==="exclusive"?(i(),d(x,{key:0},[e.options.ns_pos_price_with_tax==="yes"?(i(),d("a",{key:0,onClick:t[12]||(t[12]=n=>s.openTaxSummary()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Tax Included"))+": "+r(s.nsCurrency(e.order.total_tax_value+e.order.products_tax_value)),1)):e.options.ns_pos_price_with_tax==="no"?(i(),d("a",{key:1,onClick:t[13]||(t[13]=n=>s.openTaxSummary()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Tax"))+": "+r(s.nsCurrency(e.order.total_tax_value)),1)):p("",!0)],64)):e.order&&e.options.ns_pos_tax_type==="inclusive"?(i(),d(x,{key:1},[e.options.ns_pos_price_with_tax==="yes"?(i(),d("a",{key:0,onClick:t[14]||(t[14]=n=>s.openTaxSummary()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Tax Included"))+": "+r(s.nsCurrency(e.order.total_tax_value+(e.order.products_exclusive_tax_value+e.order.products_inclusive_tax_value))),1)):e.options.ns_pos_price_with_tax==="no"?(i(),d("a",{key:1,onClick:t[15]||(t[15]=n=>s.openTaxSummary()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Tax"))+": "+r(s.nsCurrency(e.order.total_tax_value)),1)):p("",!0)],64)):p("",!0)]),o("td",ro,r(s.__("Total")),1),o("td",no,r(s.nsCurrency(e.order.total)),1)])])):p("",!0),e.visibleSection==="cart"?(i(),d("table",io,[o("tr",null,[o("td",lo,[o("a",{onClick:t[16]||(t[16]=n=>s.selectCustomer()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Customer"))+": "+r(s.customerName),1)]),o("td",ao,[o("div",uo,[o("span",null,r(s.__("Sub Total")),1),o("span",null,r(s.nsCurrency(e.order.subtotal)),1)])])]),e.order.coupons.length>0?(i(),d("tr",co,[po,o("td",_o,[o("a",{onClick:t[17]||(t[17]=n=>s.selectCoupon()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Coupons")),1)]),o("td",ho,r(s.nsCurrency(s.summarizeCoupons())),1)])):p("",!0),o("tr",null,[o("td",bo,[o("a",{onClick:t[18]||(t[18]=n=>s.openOrderType()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Type"))+": "+r(s.selectedType),1)]),o("td",mo,[o("div",fo,[o("p",null,[o("span",null,r(s.__("Discount")),1),e.order.discount_type==="percentage"?(i(),d("span",yo,"("+r(e.order.discount_percentage)+"%)",1)):p("",!0),e.order.discount_type==="flat"?(i(),d("span",vo,"("+r(s.__("Flat"))+")",1)):p("",!0)]),o("a",{onClick:t[19]||(t[19]=n=>s.openDiscountPopup(e.order,"cart")),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.nsCurrency(e.order.discount)),1)])])]),e.order.type&&e.order.type.identifier==="delivery"?(i(),d("tr",xo,[wo,o("td",go,[o("a",{onClick:t[20]||(t[20]=n=>s.openShippingPopup()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Shipping")),1),Po])])):p("",!0),o("tr",ko,[o("td",Co,[e.order&&e.options.ns_pos_tax_type==="exclusive"?(i(),d(x,{key:0},[e.options.ns_pos_price_with_tax==="yes"?(i(),d("a",{key:0,onClick:t[21]||(t[21]=n=>s.openTaxSummary()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Tax"))+": "+r(s.nsCurrency(e.order.total_tax_value)),1)):e.options.ns_pos_price_with_tax==="no"?(i(),d("a",{key:1,onClick:t[22]||(t[22]=n=>s.openTaxSummary()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Tax Inclusive"))+": "+r(s.nsCurrency(e.order.total_tax_value+e.order.products_tax_value)),1)):p("",!0)],64)):e.order&&e.options.ns_pos_tax_type==="inclusive"?(i(),d(x,{key:1},[e.options.ns_pos_price_with_tax==="yes"?(i(),d("a",{key:0,onClick:t[23]||(t[23]=n=>s.openTaxSummary()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Tax Included"))+": "+r(s.nsCurrency(e.order.total_tax_value)),1)):e.options.ns_pos_price_with_tax==="no"?(i(),d("a",{key:1,onClick:t[24]||(t[24]=n=>s.openTaxSummary()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Tax Included"))+": "+r(s.nsCurrency(e.order.total_tax_value+e.order.products_tax_value)),1)):p("",!0)],64)):p("",!0)]),o("td",So,[o("div",To,[o("span",null,r(s.__("Total")),1),o("span",null,r(s.nsCurrency(e.order.total)),1)])])])])):p("",!0)]),o("div",Oo,[Object.keys(e.cartButtons).length===0?(i(!0),d(x,{key:0},C(new Array(4).fill(),n=>(i(),d("div",{class:N([s.takeRandomClass(),"animate-pulse flex-shrink-0 w-1/4 flex items-center font-bold cursor-pointer justify-center border-r flex-auto"])},qo,2))),256)):p("",!0),(i(!0),d(x,null,C(e.cartButtons,n=>(i(),S(L(n),{order:e.order,settings:e.settings},null,8,["order","settings"]))),256))])])])])}const Yo=P(Tt,[["render",Do]]);export{Yo as default}; diff --git a/public/build/assets/ns-pos-cart-a5bf23af.js b/public/build/assets/ns-pos-cart-a5bf23af.js new file mode 100644 index 000000000..4e1c7e7ba --- /dev/null +++ b/public/build/assets/ns-pos-cart-a5bf23af.js @@ -0,0 +1 @@ +import{p as q,v as R,w as A,F as D,a as V,d as v,b as U,G as E,n as I,P as y}from"./bootstrap-ffaf6d09.js";import{_ as a,n as B}from"./currency-feccde3d.js";import{s as M}from"./pos-section-switch-0869c4e1.js";import{a as H,d as Y,n as G,b as $,c as W,P as z}from"./ns-pos-shipping-popup-dffc98ef.js";import{_ as P}from"./_plugin-vue_export-helper-c27b6911.js";import{o as i,c as d,a as o,t as r,r as b,f,B as L,F as x,b as C,g as S,w as k,i as O,e as p,h as T,ay as j,n as N,j as K}from"./runtime-core.esm-bundler-414a078a.js";import{c as J,a as X,k as Z,n as F}from"./ns-prompt-popup-24cc8d6f.js";import"./index.es-25aa42ee.js";import"./chart-2ccf8ff7.js";import"./ns-orders-preview-popup-3c654295.js";const ee={props:["order"],methods:{__,async payOrder(){const e=nsHooks.applyFilters("ns-pay-queue",[ProductsQueue,CustomerQueue,TypeQueue,PaymentQueue]);for(let t in e)try{const l=await new e[t](this.order).run()}catch(u){return console.log(u),!1}}},mounted(){for(let e in nsShortcuts)["ns_pos_keyboard_payment"].includes(e)&&nsHotPress.create("ns_pos_keyboard_payment").whenNotVisible([".is-popup"]).whenPressed(nsShortcuts[e]!==null?nsShortcuts[e].join("+"):null,t=>{t.preventDefault(),this.payOrder()})},unmounted(){nsHotPress.destroy("ns_pos_keyboard_payment")}},te=o("i",{class:"mr-2 text-2xl lg:text-xl las la-cash-register"},null,-1),se={class:"text-lg hidden md:inline lg:text-2xl"};function oe(e,t,u,l,c,s){return i(),d("div",{onClick:t[0]||(t[0]=n=>s.payOrder()),id:"pay-button",class:"flex-shrink-0 w-1/4 flex items-center font-bold cursor-pointer justify-center bg-green-500 text-white hover:bg-green-600 border-r border-green-600 flex-auto"},[te,o("span",se,r(s.__("Pay")),1)])}const re=P(ee,[["render",oe]]),ne={name:"ns-pos-hold-orders",props:["popup"],data(){return{order:{},title:"",show:!0}},mounted(){this.popupCloser(),this.show=POS.getHoldPopupEnabled(),this.show||this.popup.params.resolve({title:this.title}),this.$refs.reference.focus(),this.$refs.reference.select(),this.order=this.popup.params.order,this.title=this.popup.params.order.title||""},methods:{__:a,nsCurrency:B,popupCloser:q,submitHold(){this.popup.close(),this.popup.params.resolve({title:this.title})}}},ie={class:"ns-box shadow-lg w-6/7-screen md:w-3/7-screen lg:w-2/6-screen"},de={class:"p-2 flex ns-box-header justify-between border-b items-center"},le={class:"font-semibold"},ae={class:"flex-auto ns-box-body"},ue={class:"border-b h-16 flex items-center justify-center"},ce={class:"text-5xl text-primary"},pe={class:"p-2"},_e={class:"input-group border-2 info"},he=["placeholder"],be={class:"p-2"},me={class:"text-secondary"},fe={class:"flex ns-box-footer"};function ye(e,t,u,l,c,s){const n=b("ns-close-button");return i(),d("div",ie,[o("div",de,[o("h3",le,r(s.__("Hold Order")),1),o("div",null,[f(n,{onClick:t[0]||(t[0]=_=>u.popup.close())})])]),o("div",ae,[o("div",ue,[o("span",ce,r(s.nsCurrency(c.order.total)),1)]),o("div",pe,[o("div",_e,[L(o("input",{onKeyup:t[1]||(t[1]=A(_=>s.submitHold(),["enter"])),"onUpdate:modelValue":t[2]||(t[2]=_=>c.title=_),ref:"reference",type:"text",placeholder:s.__("Order Reference"),class:"outline-none rounded border-2 p-2 w-full"},null,40,he),[[R,c.title]])])]),o("div",be,[o("p",me,r(s.__("The current order will be set on hold. You can retrieve this order from the pending order button. Providing a reference to it might help you to identify the order more quickly.")),1)])]),o("div",fe,[o("div",{onClick:t[3]||(t[3]=_=>s.submitHold()),class:"cursor-pointer w-1/2 py-3 flex justify-center items-center bg-green-500 text-white font-semibold"},r(s.__("Confirm")),1),o("div",{onClick:t[4]||(t[4]=_=>u.popup.close()),class:"cursor-pointer w-1/2 py-3 flex justify-center items-center bg-error-secondary text-white font-semibold"},r(s.__("Cancel")),1)])])}const ve=P(ne,[["render",ye]]),xe={props:["order"],methods:{__,async holdOrder(){if(this.order.payment_status!=="hold"&&this.order.payments.length>0)return nsSnackBar.error(__("Unable to hold an order which payment status has been updated already.")).subscribe();const e=nsHooks.applyFilters("ns-hold-queue",[ProductsQueue,CustomerQueue,TypeQueue]);for(let u in e)try{const c=await new e[u](this.order).run()}catch{return!1}nsHooks.applyFilters("ns-override-hold-popup",()=>{new Promise((l,c)=>{Popup.show(ve,{resolve:l,reject:c,order:this.order})}).then(l=>{this.order.title=l.title,this.order.payment_status="hold",POS.order.next(this.order);const c=Popup.show(J);POS.submitOrder().then(s=>{c.close(),nsSnackBar.success(s.message).subscribe()},s=>{c.close(),nsSnackBar.error(s.message).subscribe()})}).catch(l=>{console.log(l)})})()}},mounted(){for(let e in nsShortcuts)["ns_pos_keyboard_hold_order"].includes(e)&&nsHotPress.create("ns_pos_keyboard_hold_order").whenNotVisible([".is-popup"]).whenPressed(nsShortcuts[e]!==null?nsShortcuts[e].join("+"):null,t=>{t.preventDefault(),this.holdOrder()})},unmounted(){nsHotPress.destroy("ns_pos_keyboard_hold_order")}},we=o("i",{class:"mr-2 text-2xl lg:text-xl las la-pause"},null,-1),ge={class:"text-lg hidden md:inline lg:text-2xl"};function Pe(e,t,u,l,c,s){return i(),d("div",{onClick:t[0]||(t[0]=n=>s.holdOrder()),id:"hold-button",class:"flex-shrink-0 w-1/4 flex items-center font-bold cursor-pointer justify-center bg-blue-500 text-white border-r hover:bg-blue-600 border-blue-600 flex-auto"},[we,o("span",ge,r(s.__("Hold")),1)])}const ke=P(xe,[["render",Pe]]),Ce={props:["order","settings"],methods:{__,openDiscountPopup(e,t,u=null){if(!this.settings.products_discount&&t==="product")return nsSnackBar.error(__("You're not allowed to add a discount on the product.")).subscribe();if(!this.settings.cart_discount&&t==="cart")return nsSnackBar.error(__("You're not allowed to add a discount on the cart.")).subscribe();Popup.show(H,{reference:e,type:t,onSubmit(l){t==="product"?POS.updateProduct(e,l,u):t==="cart"&&POS.updateCart(e,l)}},{popupClass:"bg-white h:2/3 shadow-lg xl:w-1/4 lg:w-2/5 md:w-2/3 w-full"})}}},Se=o("i",{class:"mr-2 text-2xl lg:text-xl las la-percent"},null,-1),Te={class:"text-lg hidden md:inline lg:text-2xl"};function Oe(e,t,u,l,c,s){return i(),d("div",{onClick:t[0]||(t[0]=n=>s.openDiscountPopup(u.order,"cart")),id:"discount-button",class:"flex-shrink-0 w-1/4 flex items-center font-bold cursor-pointer justify-center border-r border-box-edge flex-auto"},[Se,o("span",Te,r(s.__("Discount")),1)])}const je=P(Ce,[["render",Oe]]),Ne={props:["order","settings"],methods:{__,voidOngoingOrder(){POS.voidOrder(this.order)}}},qe=o("i",{class:"mr-2 text-2xl lg:text-xl las la-trash"},null,-1),De={class:"text-lg hidden md:inline lg:text-2xl"};function Be(e,t,u,l,c,s){return i(),d("div",{onClick:t[0]||(t[0]=n=>s.voidOngoingOrder(u.order)),id:"void-button",class:"flex-shrink-0 w-1/4 flex items-center font-bold cursor-pointer justify-center bg-red-500 text-white border-box-edge hover:bg-red-600 flex-auto"},[qe,o("span",De,r(s.__("Void")),1)])}const Fe=P(Ne,[["render",Be]]),Ve={name:"ns-pos-note-popup",props:["popup"],data(){return{validation:new D,fields:[{label:a("Note"),name:"note",value:"",description:a("More details about this order"),type:"textarea"},{label:a("Display On Receipt"),name:"note_visibility",value:"",options:[{label:a("Yes"),value:"visible"},{label:a("No"),value:"hidden"}],description:a("Will display the note on the receipt"),type:"switch"}]}},mounted(){this.popupCloser(),this.fields.forEach(e=>{e.name==="note"?e.value=this.popup.params.note:e.name==="note_visibility"&&(e.value=this.popup.params.note_visibility)})},methods:{__:a,popupResolver:V,popupCloser:q,closePopup(){this.popupResolver(!1)},saveNote(){if(!this.validation.validateFields(this.fields)){const e=this.validation.validateFieldsErrors(this.fields);return this.validation.triggerFieldsErrors(this.fields,e),this.$forceUpdate(),v.error(a("Unable to proceed the form is not valid.")).subscribe()}return this.popupResolver(this.validation.extractFields(this.fields))}}},He={class:"shadow-lg ns-box w-95vw md:w-3/5-screen lg:w-2/5-screen"},Qe={class:"p-2 flex justify-between items-center border-b ns-box-header"},Re={class:"font-bold"},Ae={class:"p-2"},Ue={class:"p-2 flex justify-end border-t ns-box-footer"};function Ee(e,t,u,l,c,s){const n=b("ns-close-button"),_=b("ns-field"),m=b("ns-button");return i(),d("div",He,[o("div",Qe,[o("h3",Re,r(s.__("Order Note")),1),o("div",null,[f(n,{onClick:t[0]||(t[0]=h=>s.closePopup())})])]),o("div",Ae,[(i(!0),d(x,null,C(c.fields,(h,w)=>(i(),S(_,{key:w,field:h},null,8,["field"]))),128))]),o("div",Ue,[f(m,{type:"info",onClick:t[1]||(t[1]=h=>s.saveNote())},{default:k(()=>[O(r(s.__("Save")),1)]),_:1})])])}const Ie=P(Ve,[["render",Ee]]),Me={name:"ns-pos-tax-popup",props:["popup"],data(){return{validation:new D,tax_group:[],order:null,orderSubscriber:null,optionsSubscriber:null,options:{},tax_groups:[],activeTab:"",group_fields:[{label:a("Select Tax"),name:"tax_group_id",description:a("Define the tax that apply to the sale."),type:"select",disabled:!0,value:"",validation:"required",options:[]},{label:a("Type"),name:"tax_type",disabled:!0,value:"",description:a("Define how the tax is computed"),type:"select",validation:"required",options:[{label:a("Exclusive"),value:"exclusive"},{label:a("Inclusive"),value:"inclusive"}]}]}},mounted(){this.loadGroups(),this.popupCloser(),this.activeTab=this.popup.params.activeTab||"settings",this.group_fields.forEach(e=>{e.value=this.popup.params[e.name]||void 0}),this.orderSubscriber=POS.order.subscribe(e=>{this.order=e}),this.optionsSubscriber=POS.options.subscribe(e=>{this.options=e,["variable_vat","products_variable_vat"].includes(this.options.ns_pos_vat)&&this.group_fields.forEach(t=>t.disabled=!1)})},unmounted(){this.orderSubscriber.unsubscribe(),this.optionsSubscriber.unsubscribe()},methods:{__:a,nsCurrency:B,popupCloser:q,popupResolver:V,changeActive(e){this.activeTab=e},closePopup(){this.popupResolver(!1)},saveTax(){if(!this.validation.validateFields(this.group_fields))return v.error(a("Unable to proceed the form is not valid.")).subscribe();const e=this.validation.extractFields(this.group_fields);e.tax_groups=[],this.popupResolver(e)},loadGroups(){U.get("/api/taxes/groups").subscribe(e=>{this.groups=e,this.group_fields.forEach(t=>{t.name==="tax_group_id"&&(t.options=this.groups.map(u=>({label:u.name,value:u.id})))})})}}},Ye={class:"ns-box shadow-lg w-95vw md:w-3/5-screen lg:w-2/5-screen"},Ge={class:"p-2 flex justify-between items-center border-b ns-box-header"},$e={class:"text-blog"},We={class:"p-2 ns-box-body"},ze={class:"p-2 border-b ns-box-body"},Le={class:"flex justify-end p-2"},Ke={key:0,class:"p-2"},Je={key:0,class:"p-2 text-center text-primary"},Xe={key:0,class:"p-2"},Ze={class:"border shadow p-2 w-full flex justify-between items-center elevation-surface"};function et(e,t,u,l,c,s){const n=b("ns-close-button"),_=b("ns-field"),m=b("ns-button"),h=b("ns-tabs-item"),w=b("ns-tabs");return i(),d("div",Ye,[o("div",Ge,[o("h3",$e,r(s.__("Tax & Summary")),1),o("div",null,[f(n,{onClick:t[0]||(t[0]=g=>s.closePopup())})])]),o("div",We,[f(w,{active:c.activeTab,onChangeTab:t[2]||(t[2]=g=>s.changeActive(g))},{default:k(()=>[f(h,{padding:"0",label:s.__("Settings"),identifier:"settings",active:!0},{default:k(()=>[o("div",ze,[(i(!0),d(x,null,C(c.group_fields,(g,Q)=>(i(),S(_,{field:g,key:Q},null,8,["field"]))),128))]),o("div",Le,[f(m,{onClick:t[1]||(t[1]=g=>s.saveTax()),type:"info"},{default:k(()=>[O(r(s.__("Save")),1)]),_:1})])]),_:1},8,["label"]),f(h,{padding:"0",label:s.__("Summary"),identifier:"summary",active:!1},{default:k(()=>[c.order?(i(),d("div",Ke,[(i(!0),d(x,null,C(c.order.taxes,g=>(i(),d("div",{key:g.id,class:"mb-2 border shadow p-2 w-full flex justify-between items-center elevation-surface"},[o("span",null,r(g.name),1),o("span",null,r(s.nsCurrency(g.tax_value)),1)]))),128)),c.order.taxes.length===0?(i(),d("div",Je,r(s.__("No tax is active")),1)):p("",!0)])):p("",!0)]),_:1},8,["label"]),f(h,{padding:"0",label:s.__("Product Taxes"),identifier:"product_taxes",active:!1},{default:k(()=>[c.order?(i(),d("div",Xe,[o("div",Ze,[o("span",null,r(s.__("Product Taxes")),1),o("span",null,r(s.nsCurrency(c.order.products_tax_value)),1)])])):p("",!0)]),_:1},8,["label"])]),_:1},8,["active"])])])}const tt=P(Me,[["render",et]]),st={name:"ns-pos-order-settings",props:["popup"],mounted(){nsHttpClient.get("/api/fields/ns.pos-order-settings").subscribe(e=>{e.forEach(t=>{t.value=this.popup.params.order[t.name]||""}),this.fields=this.validation.createFields(e)},e=>{}),this.popupCloser()},data(){return{fields:[],validation:new D}},methods:{__,popupCloser,popupResolver,closePopup(){this.popupResolver(!1)},saveSettings(){const e=this.validation.extractFields(this.fields);this.popupResolver(e)}}},ot={class:"shadow-lg flex flex-col ns-box w-95vw h-95vh md:w-3/5-screen md:h-3/5-screen lg:w-2/5-screen"},rt={class:"p-2 border-b ns-box-header items-center flex justify-between"},nt={class:"text-semibold"},it={class:"p-2 flex-auto border-b ns-box-body overflow-y-auto"},dt={class:"p-2 flex justify-end ns-box-footer"};function lt(e,t,u,l,c,s){const n=b("ns-close-button"),_=b("ns-field"),m=b("ns-button");return i(),d("div",ot,[o("div",rt,[o("h3",nt,r(s.__("Order Settings")),1),o("div",null,[f(n,{onClick:t[0]||(t[0]=h=>s.closePopup())})])]),o("div",it,[(i(!0),d(x,null,C(c.fields,(h,w)=>(i(),S(_,{field:h,key:w},null,8,["field"]))),128))]),o("div",dt,[f(m,{onClick:t[1]||(t[1]=h=>s.saveSettings()),type:"info"},{default:k(()=>[O(r(s.__("Save")),1)]),_:1})])])}const at=P(st,[["render",lt]]),ut={name:"ns-pos-product-price-product",props:["popup"],components:{nsNumpad:X,nsNumpadPlus:Z},computed:{},data(){return{product:{},optionsSubscription:null,options:{},price:0}},mounted(){this.popupCloser(),this.product=this.popup.params.product,this.optionsSubscription=POS.options.subscribe(e=>{this.options=T(e)})},beforeDestroy(){this.optionsSubscription.unsubscribe()},methods:{popupResolver,popupCloser,nsCurrency:B,__,updateProductPrice(e){this.product.unit_price=e},resolveProductPrice(e){this.popupResolver(this.product.unit_price)}}},ct={class:"ns-box shadow-lg w-95vw md:w-3/5-screen lg:w-2/5-screen"},pt={class:"popup-heading ns-box-header"},_t={class:"flex flex-col ns-box-body"},ht={class:"h-16 flex items-center justify-center elevation-surface info font-bold"},bt={class:"text-2xl"};function mt(e,t,u,l,c,s){const n=b("ns-close-button"),_=b("ns-numpad"),m=b("ns-numpad-plus");return i(),d("div",ct,[o("div",pt,[o("h3",null,r(s.__("Product Price")),1),o("div",null,[f(n,{onClick:t[0]||(t[0]=h=>s.popupResolver(!1))})])]),o("div",_t,[o("div",ht,[o("h2",bt,r(s.nsCurrency(c.product.unit_price)),1)]),c.options.ns_pos_numpad==="default"?(i(),S(_,{key:0,floating:c.options.ns_pos_allow_decimal_quantities,onChanged:t[1]||(t[1]=h=>s.updateProductPrice(h)),onNext:t[2]||(t[2]=h=>s.resolveProductPrice(h)),value:c.product.unit_price},null,8,["floating","value"])):p("",!0),c.options.ns_pos_numpad==="advanced"?(i(),S(m,{key:1,onChanged:t[3]||(t[3]=h=>s.updateProductPrice(h)),onNext:t[4]||(t[4]=h=>s.resolveProductPrice(h)),value:c.product.unit_price},null,8,["value"])):p("",!0)])])}const ft=P(ut,[["render",mt]]),yt={name:"ns-pos-quick-product-popup",props:["popup"],methods:{__:a,popupCloser:q,popupResolver:V,close(){this.popupResolver(!1)},async addProduct(){const e=this.validation.extractFields(this.fields),t=this.fields.filter(s=>typeof s.show>"u"||typeof s.show=="function"&&s.show(e));if(!this.validation.validateFields(t))return v.error(a("Unable to proceed. The form is not valid.")).subscribe();let l=this.validation.extractFields(t);l.$original=()=>({stock_management:"disabled",category_id:0,tax_group:this.tax_groups.filter(s=>parseInt(s.id)===parseInt(l.tax_group_id))[0],tax_group_id:l.tax_group_id,tax_type:l.tax_type}),l.product_type==="product"?(l.unit_name=this.units.filter(s=>s.id===l.unit_id)[0].name,l.quantity=parseFloat(l.quantity),l.unit_price=parseFloat(l.unit_price),l.mode="custom",l.price_with_tax=l.unit_price,l.price_without_tax=l.unit_price,l.tax_value=0):(l.unit_name=a("N/A"),l.unit_price=0,l.quantity=1);const c=await POS.defineQuantities(l,this.units);l.$quantities=()=>c,l=POS.computeProductTax(l),POS.addToCart(l),this.close()},loadData(){this.loaded=!1,E(nsHttpClient.get("/api/units"),nsHttpClient.get("/api/taxes/groups")).subscribe({next:e=>{this.units=e[0],this.tax_groups=e[1],this.fields.filter(t=>{t.name==="tax_group_id"&&(t.options=e[1].map(u=>({label:u.name,value:u.id})),e[1].length>0&&e[1][0].id!==void 0&&(t.value=e[1][0].id||this.options.ns_pos_tax_group)),t.name==="tax_type"&&(t.value=this.options.tax_type||"inclusive"),t.name==="unit_id"&&(t.value=this.options.ns_pos_quick_product_default_unit,t.options=e[0].map(u=>({label:u.name,value:u.id})))}),this.buildForm()},error:e=>{}})},buildForm(){this.fields=this.validation.createFields(this.fields),this.loaded=!0,setTimeout(()=>{this.$el.querySelector("#name").select()},100)}},computed:{form(){return this.validation.extractFields(this.fields)}},data(){return{units:[],options:POS.options.getValue(),tax_groups:[],loaded:!1,validation:new D,fields:[{label:a("Name"),name:"name",type:"text",description:a("Provide a unique name for the product."),validation:"required"},{label:a("Product Type"),name:"product_type",type:"select",description:a("Define the product type."),options:[{label:a("Normal"),value:"product"},{label:a("Dynamic"),value:"dynamic"}],value:"product",validation:"required"},{label:a("Rate"),name:"rate",type:"text",description:a("In case the product is computed based on a percentage, define the rate here."),validation:"required",show(e){return e.product_type==="dynamic"}},{label:a("Unit Price"),name:"unit_price",type:"text",description:a("Define what is the sale price of the item."),validation:"",value:0,show(e){return e.product_type==="product"}},{label:a("Quantity"),name:"quantity",type:"text",value:1,description:a("Set the quantity of the product."),validation:"",show(e){return e.product_type==="product"}},{label:a("Unit"),name:"unit_id",type:"select",options:[],description:a("Assign a unit to the product."),validation:"",show(e){return e.product_type==="product"}},{label:a("Tax Type"),name:"tax_type",type:"select",options:[{label:a("Disabled"),value:""},{label:a("Inclusive"),value:"inclusive"},{label:a("Exclusive"),value:"exclusive"}],description:a("Define what is tax type of the item."),show(e){return e.product_type==="product"}},{label:a("Tax Group"),name:"tax_group_id",type:"select",options:[],description:a("Choose the tax group that should apply to the item."),show(e){return e.product_type==="product"}}]}},mounted(){this.popupCloser(),this.loadData()}},vt={class:"w-95vw flex flex-col h-95vh shadow-lg md:w-3/5-screen lg:w-2/5-screen md:h-3/5-screen ns-box"},xt={class:"header ns-box-header border-b flex justify-between p-2 items-center"},wt={class:"ns-box-body p-2 flex-auto overflow-y-auto"},gt={key:0,class:"h-full w-full flex justify-center items-center"},Pt={class:"ns-box-footer border-t flex justify-between p-2"},kt=o("div",null,null,-1);function Ct(e,t,u,l,c,s){const n=b("ns-close-button"),_=b("ns-spinner"),m=b("ns-field"),h=b("ns-button");return i(),d("div",vt,[o("div",xt,[o("h3",null,r(s.__("Product / Service")),1),o("div",null,[f(n,{onClick:t[0]||(t[0]=w=>s.close())})])]),o("div",wt,[c.loaded?p("",!0):(i(),d("div",gt,[f(_)])),c.loaded?(i(!0),d(x,{key:1},C(c.fields,(w,g)=>(i(),d(x,null,[w.show&&w.show(s.form)||!w.show?(i(),S(m,{key:g,field:w},null,8,["field"])):p("",!0)],64))),256)):p("",!0)]),o("div",Pt,[kt,o("div",null,[f(h,{onClick:t[1]||(t[1]=w=>s.addProduct()),type:"info"},{default:k(()=>[O(r(s.__("Create")),1)]),_:1})])])])}const St=P(yt,[["render",Ct]]),Tt={name:"ns-pos-cart",data:()=>({popup:null,cartButtons:{},products:[],defaultCartButtons:{nsPosPayButton:j(re),nsPosHoldButton:j(ke),nsPosDiscountButton:j(je),nsPosVoidButton:j(Fe)},visibleSection:null,visibleSectionSubscriber:null,cartButtonsSubscriber:null,optionsSubscriber:null,options:{},typeSubscribe:null,orderSubscribe:null,productSubscribe:null,settingsSubscribe:null,settings:{},types:[],order:T({})}),computed:{selectedType(){return this.order.type?this.order.type.label:"N/A"},isVisible(){return this.visibleSection==="cart"},customerName(){return this.order.customer?`${this.order.customer.first_name||this.order.customer.last_name?this.getFirstName():this.getUserName()}`:"N/A"},couponName(){return a("Apply Coupon")}},mounted(){this.cartButtonsSubscriber=POS.cartButtons.subscribe(e=>{this.cartButtons=e}),this.optionsSubscriber=POS.options.subscribe(e=>{this.options=e}),this.typeSubscribe=POS.types.subscribe(e=>this.types=e),this.orderSubscribe=POS.order.subscribe(e=>{this.order=T(e)}),this.productSubscribe=POS.products.subscribe(e=>{this.products=T(e)}),this.settingsSubscribe=POS.settings.subscribe(e=>{this.settings=T(e)}),this.visibleSectionSubscriber=POS.visibleSection.subscribe(e=>{this.visibleSection=T(e)}),I.addAction("ns-before-cart-reset","ns-pos-cart-buttons",()=>{POS.cartButtons.next(this.defaultCartButtons)});for(let e in nsShortcuts)["ns_pos_keyboard_shipping"].includes(e)&&nsHotPress.create("ns_pos_keyboard_shipping").whenNotVisible([".is-popup"]).whenPressed(nsShortcuts[e]!==null?nsShortcuts[e].join("+"):null,t=>{t.preventDefault(),this.openShippingPopup()}),["ns_pos_keyboard_note"].includes(e)&&nsHotPress.create("ns_pos_keyboard_note").whenNotVisible([".is-popup"]).whenPressed(nsShortcuts[e]!==null?nsShortcuts[e].join("+"):null,t=>{t.preventDefault(),this.openNotePopup()})},unmounted(){this.visibleSectionSubscriber.unsubscribe(),this.typeSubscribe.unsubscribe(),this.orderSubscribe.unsubscribe(),this.productSubscribe.unsubscribe(),this.settingsSubscribe.unsubscribe(),this.optionsSubscriber.unsubscribe(),this.cartButtonsSubscriber.unsubscribe(),nsHotPress.destroy("ns_pos_keyboard_shipping"),nsHotPress.destroy("ns_pos_keyboard_note")},methods:{__:a,nsCurrency:B,switchTo:M,getFirstName(){return`${this.order.customer.first_name||""} ${this.order.customer.last_name||""}`},getUserName(){return this.order.customer.username},takeRandomClass(){return"border-gray-500 bg-gray-400 text-white hover:bg-gray-500"},openAddQuickProduct(){new Promise((t,u)=>{y.show(St,{resolve:t,reject:u})}).then(t=>{}).catch(t=>{})},summarizeCoupons(){const e=this.order.coupons.map(t=>t.value);return e.length>0?e.reduce((t,u)=>t+u):0},async changeProductPrice(e){if(!this.settings.edit_purchase_price)return v.error(a("You don't have the right to edit the purchase price.")).subscribe();if(e.product_type==="dynamic")return v.error(a("Dynamic product can't have their price updated.")).subscribe();if(this.settings.unit_price_editable)try{const t=await new Promise((l,c)=>y.show(ft,{product:Object.assign({},e),resolve:l,reject:c})),u={...e.$quantities(),custom_price_edit:t};return e.$quantities=()=>u,e.mode="custom",e=POS.computeProductTax(e),POS.recomputeProducts(POS.products.getValue()),POS.refreshCart(),v.success(a("The product price has been updated.")).subscribe()}catch(t){if(t!==!1)throw v.error(t).subscribe(),t}else return v.error(a("The editable price feature is disabled.")).subscribe()},async selectCoupon(){try{const e=await new Promise((t,u)=>{y.show(Y,{resolve:t,reject:u})})}catch{}},async defineOrderSettings(){if(!this.settings.edit_settings)return v.error(a("You're not allowed to edit the order settings.")).subscribe();try{const e=await new Promise((t,u)=>{y.show(at,{resolve:t,reject:u,order:this.order})});POS.order.next({...this.order,...e})}catch{}},async openNotePopup(){try{const e=await new Promise((u,l)=>{const c=this.order.note,s=this.order.note_visibility;y.show(Ie,{resolve:u,reject:l,note:c,note_visibility:s})}),t={...this.order,...e};POS.order.next(t)}catch(e){e!==!1&&v.error(e.message).subscribe()}},async selectTaxGroup(e="settings"){try{const t=await new Promise((l,c)=>{const s=this.order.taxes,n=this.order.tax_group_id,_=this.order.tax_type;y.show(tt,{resolve:l,reject:c,taxes:s,tax_group_id:n,tax_type:_,activeTab:e})}),u={...this.order,...t};POS.order.next(u),POS.refreshCart()}catch{}},openTaxSummary(){this.selectTaxGroup("summary")},selectCustomer(){y.show(G)},async openDiscountPopup(e,t,u=null){if(!this.settings.products_discount&&t==="product")return v.error(a("You're not allowed to add a discount on the product.")).subscribe();if(!this.settings.cart_discount&&t==="cart")return v.error(a("You're not allowed to add a discount on the cart.")).subscribe();try{const l=await new Promise((c,s)=>{y.show(H,{reference:e,resolve:c,reject:s,type:t,onSubmit(n){t==="product"?POS.updateProduct(e,n,u):t==="cart"&&POS.updateCart(e,n)}},{popupClass:"bg-white h:2/3 shadow-lg xl:w-1/4 lg:w-2/5 md:w-2/3 w-full"})})}catch{}},toggleMode(e,t){if(!this.options.ns_pos_allow_wholesale_price)return v.error(a("Unable to change the price mode. This feature has been disabled.")).subscribe();e.mode==="normal"?y.show(F,{title:a("Enable WholeSale Price"),message:a("Would you like to switch to wholesale price ?"),onAction(u){u&&POS.updateProduct(e,{mode:"wholesale"},t)}}):y.show(F,{title:a("Enable Normal Price"),message:a("Would you like to switch to normal price ?"),onAction(u){u&&POS.updateProduct(e,{mode:"normal"},t)}})},removeUsingIndex(e){y.show(F,{title:a("Confirm Your Action"),message:a("Would you like to delete this product ?"),onAction(t){t&&POS.removeProductUsingIndex(e)}})},allowQuantityModification(e){return e.product_type==="product"},changeQuantity(e,t){this.allowQuantityModification(e)&&new z(e).run({unit_quantity_id:e.unit_quantity_id,unit_name:e.unit_name,$quantities:e.$quantities}).then(l=>{POS.updateProduct(e,l,t)})},openOrderType(){y.show($)},openShippingPopup(){y.show(W)}}},Ot={id:"pos-cart",class:"flex-auto flex flex-col"},jt={key:0,id:"tools",class:"flex pl-2 ns-tab"},Nt={key:0,class:"flex items-center justify-center text-sm rounded-full h-6 w-6 bg-green-500 text-white ml-1"},qt={class:"rounded shadow ns-tab-item flex-auto flex overflow-hidden"},Dt={class:"cart-table flex flex-auto flex-col overflow-hidden"},Bt={id:"cart-toolbox",class:"w-full p-2 border-b"},Ft={class:"border rounded overflow-hidden"},Vt={class:"flex flex-wrap"},Ht={class:"ns-button"},Qt=o("i",{class:"las la-comment"},null,-1),Rt={class:"ml-1 hidden md:inline-block"},At=o("hr",{class:"h-10",style:{width:"1px"}},null,-1),Ut={class:"ns-button"},Et=o("i",{class:"las la-balance-scale-left"},null,-1),It={class:"ml-1 hidden md:inline-block"},Mt={key:0,class:"ml-1 rounded-full flex items-center justify-center h-6 w-6 bg-info-secondary text-white"},Yt=o("hr",{class:"h-10",style:{width:"1px"}},null,-1),Gt={class:"ns-button"},$t=o("i",{class:"las la-tags"},null,-1),Wt={class:"ml-1 hidden md:inline-block"},zt={key:0,class:"ml-1 rounded-full flex items-center justify-center h-6 w-6 bg-info-secondary text-white"},Lt=o("hr",{class:"h-10",style:{width:"1px"}},null,-1),Kt={class:"ns-button"},Jt=o("i",{class:"las la-tools"},null,-1),Xt={class:"ml-1 hidden md:inline-block"},Zt=o("hr",{class:"h-10",style:{width:"1px"}},null,-1),es={key:0,class:"ns-button"},ts=o("i",{class:"las la-plus"},null,-1),ss={class:"ml-1 hidden md:inline-block"},os=o("hr",{class:"h-10",style:{width:"1px"}},null,-1),rs={id:"cart-table-header",class:"w-full text-primary font-semibold flex"},ns={class:"w-full lg:w-4/6 p-2 border border-l-0 border-t-0"},is={class:"hidden lg:flex lg:w-1/6 p-2 border-b border-t-0"},ds={class:"hidden lg:flex lg:w-1/6 p-2 border border-r-0 border-t-0"},ls={id:"cart-products-table",class:"flex flex-auto flex-col overflow-auto"},as={key:0,class:"text-primary flex"},us={class:"w-full text-center py-4 border-b"},cs=["product-index"],ps={class:"w-full lg:w-4/6 p-2 border border-l-0 border-t-0"},_s={class:"flex justify-between product-details mb-1"},hs={class:"font-semibold"},bs={class:"-mx-1 flex product-options"},ms={class:"px-1"},fs=["onClick"],ys=o("i",{class:"las la-trash text-xl"},null,-1),vs=[ys],xs={key:0,class:"px-1"},ws=["onClick"],gs=o("i",{class:"las la-award text-xl"},null,-1),Ps=[gs],ks={class:"flex justify-between product-controls"},Cs={class:"-mx-1 flex flex-wrap"},Ss={class:"px-1 w-1/2 md:w-auto mb-1"},Ts=["onClick"],Os={class:"px-1 w-1/2 md:w-auto mb-1"},js=["onClick"],Ns={key:0},qs={class:"px-1 w-1/2 md:w-auto mb-1 lg:hidden"},Ds=["onClick"],Bs={class:"px-1 w-1/2 md:w-auto mb-1 lg:hidden"},Fs={class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},Vs=["onClick"],Hs={key:0,class:"border-b border-dashed border-info-primary p-2"},Qs={class:"hidden lg:flex w-1/6 p-2 border border-r-0 border-t-0 items-center justify-center"},Rs={id:"cart-products-summary",class:"flex"},As={key:0,class:"table ns-table w-full text-sm"},Us={width:"200",class:"border p-2"},Es={width:"200",class:"border p-2"},Is={width:"200",class:"border p-2 text-right"},Ms={key:0},Ys=o("td",{width:"200",class:"border p-2"},null,-1),Gs={width:"200",class:"border p-2"},$s={width:"200",class:"border p-2 text-right"},Ws={width:"200",class:"border p-2"},zs={width:"200",class:"border p-2"},Ls={key:0},Ks={key:1},Js={width:"200",class:"border p-2 text-right"},Xs={key:1},Zs=o("td",{width:"200",class:"border p-2"},null,-1),eo={width:"200",class:"border p-2"},to={width:"200",class:"border p-2 text-right"},so={class:"success"},oo={width:"200",class:"border p-2"},ro={width:"200",class:"border p-2"},no={width:"200",class:"border p-2 text-right"},io={key:1,class:"table ns-table w-full text-sm"},lo={width:"200",class:"border p-2"},ao={width:"200",class:"border p-2"},uo={class:"flex justify-between"},co={key:0},po=o("td",{width:"200",class:"border p-2"},null,-1),_o={width:"200",class:"border p-2"},ho={width:"200",class:"border p-2 text-right"},bo={width:"200",class:"border p-2"},mo={width:"200",class:"border p-2"},fo={class:"flex justify-between items-center"},yo={key:0},vo={key:1},xo={key:1},wo=o("td",{width:"200",class:"border p-2"},null,-1),go={width:"200",class:"border p-2"},Po=o("span",null,null,-1),ko={class:"success"},Co={width:"200",class:"border p-2"},So={width:"200",class:"border p-2"},To={class:"flex justify-between w-full"},Oo={class:"h-16 flex flex-shrink-0 border-t border-box-edge",id:"cart-bottom-buttons"},jo=o("i",{class:"mx-4 rounded-full bg-slate-300 h-5 w-5"},null,-1),No=o("div",{class:"text-lg mr-4 hidden md:flex md:flex-auto lg:text-2xl"},[o("div",{class:"h-2 flex-auto bg-slate-200 rounded"})],-1),qo=[jo,No];function Do(e,t,u,l,c,s){return i(),d("div",Ot,[e.visibleSection==="cart"?(i(),d("div",jt,[o("div",{onClick:t[0]||(t[0]=n=>s.switchTo("cart")),class:"flex cursor-pointer rounded-tl-lg rounded-tr-lg px-3 py-2 font-semibold active tab"},[o("span",null,r(s.__("Cart")),1),e.order?(i(),d("span",Nt,r(e.order.products.length),1)):p("",!0)]),o("div",{onClick:t[1]||(t[1]=n=>s.switchTo("grid")),class:"cursor-pointer rounded-tl-lg rounded-tr-lg px-3 py-2 border-t border-r border-l inactive tab"},r(s.__("Products")),1)])):p("",!0),o("div",qt,[o("div",Dt,[o("div",Bt,[o("div",Ft,[o("div",Vt,[o("div",Ht,[o("button",{onClick:t[2]||(t[2]=n=>s.openNotePopup()),class:"w-full h-10 px-3 outline-none"},[Qt,o("span",Rt,r(s.__("Comments")),1)])]),At,o("div",Ut,[o("button",{onClick:t[3]||(t[3]=n=>s.selectTaxGroup()),class:"w-full h-10 px-3 outline-none flex items-center"},[Et,o("span",It,r(s.__("Taxes")),1),e.order.taxes&&e.order.taxes.length>0?(i(),d("span",Mt,r(e.order.taxes.length),1)):p("",!0)])]),Yt,o("div",Gt,[o("button",{onClick:t[4]||(t[4]=n=>s.selectCoupon()),class:"w-full h-10 px-3 outline-none flex items-center"},[$t,o("span",Wt,r(s.__("Coupons")),1),e.order.coupons&&e.order.coupons.length>0?(i(),d("span",zt,r(e.order.coupons.length),1)):p("",!0)])]),Lt,o("div",Kt,[o("button",{onClick:t[5]||(t[5]=n=>s.defineOrderSettings()),class:"w-full h-10 px-3 outline-none flex items-center"},[Jt,o("span",Xt,r(s.__("Settings")),1)])]),Zt,e.options.ns_pos_quick_product==="yes"?(i(),d("div",es,[o("button",{onClick:t[6]||(t[6]=n=>s.openAddQuickProduct()),class:"w-full h-10 px-3 outline-none flex items-center"},[ts,o("span",ss,r(s.__("Product")),1)])])):p("",!0),os])])]),o("div",rs,[o("div",ns,r(s.__("Product")),1),o("div",is,r(s.__("Quantity")),1),o("div",ds,r(s.__("Total")),1)]),o("div",ls,[e.products.length===0?(i(),d("div",as,[o("div",us,[o("h3",null,r(s.__("No products added...")),1)])])):p("",!0),(i(!0),d(x,null,C(e.products,(n,_)=>(i(),d("div",{"product-index":_,key:n.barcode,class:"product-item flex"},[o("div",ps,[o("div",_s,[o("h3",hs,r(n.name)+" — "+r(n.unit_name),1),o("div",bs,[o("div",ms,[o("a",{onClick:m=>s.removeUsingIndex(_),class:"hover:text-error-secondary cursor-pointer outline-none border-dashed py-1 border-b border-error-secondary text-sm"},vs,8,fs)]),e.options.ns_pos_allow_wholesale_price&&s.allowQuantityModification(n)?(i(),d("div",xs,[o("a",{class:N([n.mode==="wholesale"?"text-success-secondary border-success-secondary":"border-info-primary","cursor-pointer outline-none border-dashed py-1 border-b text-sm"]),onClick:m=>s.toggleMode(n,_)},Ps,10,ws)])):p("",!0)])]),o("div",ks,[o("div",Cs,[o("div",Ss,[o("a",{onClick:m=>s.changeProductPrice(n),class:N([n.mode==="wholesale"?"text-success-secondary hover:text-success-secondary border-success-secondary":"border-info-primary","cursor-pointer outline-none border-dashed py-1 border-b text-sm"])},r(s.__("Price"))+" : "+r(s.nsCurrency(n.unit_price)),11,Ts)]),o("div",Os,[s.allowQuantityModification(n)?(i(),d("a",{key:0,onClick:m=>s.openDiscountPopup(n,"product",_),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},[O(r(s.__("Discount"))+" ",1),n.discount_type==="percentage"?(i(),d("span",Ns,r(n.discount_percentage)+"%",1)):p("",!0),O(" : "+r(s.nsCurrency(n.discount)),1)],8,js)):p("",!0)]),o("div",qs,[s.allowQuantityModification(n)?(i(),d("a",{key:0,onClick:m=>s.changeQuantity(n,_),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Quantity"))+": "+r(n.quantity),9,Ds)):p("",!0)]),o("div",Bs,[o("span",Fs,r(s.__("Total :"))+" "+r(s.nsCurrency(n.total_price)),1)])])])]),o("div",{onClick:m=>s.changeQuantity(n,_),class:N([s.allowQuantityModification(n)?"cursor-pointer ns-numpad-key":"","hidden lg:flex w-1/6 p-2 border-b items-center justify-center"])},[s.allowQuantityModification(n)?(i(),d("span",Hs,r(n.quantity),1)):p("",!0)],10,Vs),o("div",Qs,r(s.nsCurrency(n.total_price)),1)],8,cs))),128))]),o("div",Rs,[e.visibleSection==="both"?(i(),d("table",As,[o("tr",null,[o("td",Us,[o("a",{onClick:t[7]||(t[7]=n=>s.selectCustomer()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Customer"))+": "+r(s.customerName),1)]),o("td",Es,r(s.__("Sub Total")),1),o("td",Is,r(s.nsCurrency(e.order.subtotal)),1)]),e.order.coupons.length>0?(i(),d("tr",Ms,[Ys,o("td",Gs,[o("a",{onClick:t[8]||(t[8]=n=>s.selectCoupon()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Coupons")),1)]),o("td",$s,r(s.nsCurrency(s.summarizeCoupons())),1)])):p("",!0),o("tr",null,[o("td",Ws,[o("a",{onClick:t[9]||(t[9]=n=>s.openOrderType()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Type"))+": "+r(s.selectedType),1)]),o("td",zs,[o("span",null,r(s.__("Discount")),1),e.order.discount_type==="percentage"?(i(),d("span",Ls,"("+r(e.order.discount_percentage)+"%)",1)):p("",!0),e.order.discount_type==="flat"?(i(),d("span",Ks,"("+r(s.__("Flat"))+")",1)):p("",!0)]),o("td",Js,[o("a",{onClick:t[10]||(t[10]=n=>s.openDiscountPopup(e.order,"cart")),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.nsCurrency(e.order.discount)),1)])]),e.order.type&&e.order.type.identifier==="delivery"?(i(),d("tr",Xs,[Zs,o("td",eo,[o("a",{onClick:t[11]||(t[11]=n=>s.openShippingPopup()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Shipping")),1)]),o("td",to,r(s.nsCurrency(e.order.shipping)),1)])):p("",!0),o("tr",so,[o("td",oo,[e.order&&e.options.ns_pos_tax_type==="exclusive"?(i(),d(x,{key:0},[e.options.ns_pos_price_with_tax==="yes"?(i(),d("a",{key:0,onClick:t[12]||(t[12]=n=>s.openTaxSummary()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Tax Included"))+": "+r(s.nsCurrency(e.order.total_tax_value+e.order.products_tax_value)),1)):e.options.ns_pos_price_with_tax==="no"?(i(),d("a",{key:1,onClick:t[13]||(t[13]=n=>s.openTaxSummary()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Tax"))+": "+r(s.nsCurrency(e.order.total_tax_value)),1)):p("",!0)],64)):e.order&&e.options.ns_pos_tax_type==="inclusive"?(i(),d(x,{key:1},[e.options.ns_pos_price_with_tax==="yes"?(i(),d("a",{key:0,onClick:t[14]||(t[14]=n=>s.openTaxSummary()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Tax Included"))+": "+r(s.nsCurrency(e.order.total_tax_value+(e.order.products_exclusive_tax_value+e.order.products_inclusive_tax_value))),1)):e.options.ns_pos_price_with_tax==="no"?(i(),d("a",{key:1,onClick:t[15]||(t[15]=n=>s.openTaxSummary()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Tax"))+": "+r(s.nsCurrency(e.order.total_tax_value)),1)):p("",!0)],64)):p("",!0)]),o("td",ro,r(s.__("Total")),1),o("td",no,r(s.nsCurrency(e.order.total)),1)])])):p("",!0),e.visibleSection==="cart"?(i(),d("table",io,[o("tr",null,[o("td",lo,[o("a",{onClick:t[16]||(t[16]=n=>s.selectCustomer()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Customer"))+": "+r(s.customerName),1)]),o("td",ao,[o("div",uo,[o("span",null,r(s.__("Sub Total")),1),o("span",null,r(s.nsCurrency(e.order.subtotal)),1)])])]),e.order.coupons.length>0?(i(),d("tr",co,[po,o("td",_o,[o("a",{onClick:t[17]||(t[17]=n=>s.selectCoupon()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Coupons")),1)]),o("td",ho,r(s.nsCurrency(s.summarizeCoupons())),1)])):p("",!0),o("tr",null,[o("td",bo,[o("a",{onClick:t[18]||(t[18]=n=>s.openOrderType()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Type"))+": "+r(s.selectedType),1)]),o("td",mo,[o("div",fo,[o("p",null,[o("span",null,r(s.__("Discount")),1),e.order.discount_type==="percentage"?(i(),d("span",yo,"("+r(e.order.discount_percentage)+"%)",1)):p("",!0),e.order.discount_type==="flat"?(i(),d("span",vo,"("+r(s.__("Flat"))+")",1)):p("",!0)]),o("a",{onClick:t[19]||(t[19]=n=>s.openDiscountPopup(e.order,"cart")),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.nsCurrency(e.order.discount)),1)])])]),e.order.type&&e.order.type.identifier==="delivery"?(i(),d("tr",xo,[wo,o("td",go,[o("a",{onClick:t[20]||(t[20]=n=>s.openShippingPopup()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Shipping")),1),Po])])):p("",!0),o("tr",ko,[o("td",Co,[e.order&&e.options.ns_pos_tax_type==="exclusive"?(i(),d(x,{key:0},[e.options.ns_pos_price_with_tax==="yes"?(i(),d("a",{key:0,onClick:t[21]||(t[21]=n=>s.openTaxSummary()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Tax"))+": "+r(s.nsCurrency(e.order.total_tax_value)),1)):e.options.ns_pos_price_with_tax==="no"?(i(),d("a",{key:1,onClick:t[22]||(t[22]=n=>s.openTaxSummary()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Tax Inclusive"))+": "+r(s.nsCurrency(e.order.total_tax_value+e.order.products_tax_value)),1)):p("",!0)],64)):e.order&&e.options.ns_pos_tax_type==="inclusive"?(i(),d(x,{key:1},[e.options.ns_pos_price_with_tax==="yes"?(i(),d("a",{key:0,onClick:t[23]||(t[23]=n=>s.openTaxSummary()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Tax Included"))+": "+r(s.nsCurrency(e.order.total_tax_value)),1)):e.options.ns_pos_price_with_tax==="no"?(i(),d("a",{key:1,onClick:t[24]||(t[24]=n=>s.openTaxSummary()),class:"cursor-pointer outline-none border-dashed py-1 border-b border-info-primary text-sm"},r(s.__("Tax Included"))+": "+r(s.nsCurrency(e.order.total_tax_value+e.order.products_tax_value)),1)):p("",!0)],64)):p("",!0)]),o("td",So,[o("div",To,[o("span",null,r(s.__("Total")),1),o("span",null,r(s.nsCurrency(e.order.total)),1)])])])])):p("",!0)]),o("div",Oo,[Object.keys(e.cartButtons).length===0?(i(!0),d(x,{key:0},C(new Array(4).fill(),n=>(i(),d("div",{class:N([s.takeRandomClass(),"animate-pulse flex-shrink-0 w-1/4 flex items-center font-bold cursor-pointer justify-center border-r flex-auto"])},qo,2))),256)):p("",!0),(i(!0),d(x,null,C(e.cartButtons,n=>(i(),S(K(n),{order:e.order,settings:e.settings},null,8,["order","settings"]))),256))])])])])}const Mo=P(Tt,[["render",Do]]);export{Mo as default}; diff --git a/public/build/assets/ns-pos-customers-button-00b4326b.js b/public/build/assets/ns-pos-customers-button-00b4326b.js new file mode 100644 index 000000000..f9012e848 --- /dev/null +++ b/public/build/assets/ns-pos-customers-button-00b4326b.js @@ -0,0 +1 @@ +import{_ as r}from"./preload-helper-41c905a7.js";import{P as n}from"./bootstrap-ffaf6d09.js";import{_ as a}from"./currency-feccde3d.js";import{_ as u}from"./_plugin-vue_export-helper-c27b6911.js";import{d as p,o as _,c,a as t,t as m}from"./runtime-core.esm-bundler-414a078a.js";import"./chart-2ccf8ff7.js";const l={name:"ns-pos-customers-button",methods:{__:a,openCustomerPopup(){n.show(p({loader:()=>r(()=>import("./ns-pos-shipping-popup-dffc98ef.js").then(e=>e.e),["./ns-pos-shipping-popup-dffc98ef.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-orders-preview-popup-3c654295.js","./index.es-25aa42ee.js"],import.meta.url)}))}},beforeDestroy(){nsHotPress.destroy("ns_pos_keyboard_create_customer")},mounted(){for(let e in nsShortcuts)["ns_pos_keyboard_create_customer"].includes(e)&&nsHotPress.create("ns_pos_keyboard_create_customer").whenNotVisible([".is-popup"]).whenPressed(nsShortcuts[e]!==null?nsShortcuts[e].join("+"):null,s=>{s.preventDefault(),this.openCustomerPopup()})}},i={class:"ns-button default"},d=t("i",{class:"mr-1 text-xl lar la-user-circle"},null,-1);function f(e,s,h,P,x,o){return _(),c("div",i,[t("button",{onClick:s[0]||(s[0]=b=>o.openCustomerPopup()),class:"rounded shadow flex-shrink-0 h-12 flex items-center px-2 py-1 text-sm"},[d,t("span",null,m(o.__("Customers")),1)])])}const D=u(l,[["render",f]]);export{D as default}; diff --git a/public/build/assets/ns-pos-customers-button-4d5fee4f.js b/public/build/assets/ns-pos-customers-button-4d5fee4f.js deleted file mode 100644 index ad33feec3..000000000 --- a/public/build/assets/ns-pos-customers-button-4d5fee4f.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as r}from"./preload-helper-41c905a7.js";import{P as n}from"./bootstrap-ffaf6d09.js";import{_ as a}from"./currency-feccde3d.js";import{_ as u}from"./_plugin-vue_export-helper-c27b6911.js";import{d as p,o as _,c,a as t,t as m}from"./runtime-core.esm-bundler-414a078a.js";import"./chart-2ccf8ff7.js";const l={name:"ns-pos-customers-button",methods:{__:a,openCustomerPopup(){n.show(p({loader:()=>r(()=>import("./ns-pos-order-type-popup-14f46b3a.js").then(e=>e.d),["./ns-pos-order-type-popup-14f46b3a.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-orders-preview-popup-3c654295.js","./index.es-25aa42ee.js"],import.meta.url)}))}},beforeDestroy(){nsHotPress.destroy("ns_pos_keyboard_create_customer")},mounted(){for(let e in nsShortcuts)["ns_pos_keyboard_create_customer"].includes(e)&&nsHotPress.create("ns_pos_keyboard_create_customer").whenNotVisible([".is-popup"]).whenPressed(nsShortcuts[e]!==null?nsShortcuts[e].join("+"):null,s=>{s.preventDefault(),this.openCustomerPopup()})}},i={class:"ns-button default"},d=t("i",{class:"mr-1 text-xl lar la-user-circle"},null,-1);function f(e,s,h,P,x,o){return _(),c("div",i,[t("button",{onClick:s[0]||(s[0]=b=>o.openCustomerPopup()),class:"rounded shadow flex-shrink-0 h-12 flex items-center px-2 py-1 text-sm"},[d,t("span",null,m(o.__("Customers")),1)])])}const D=u(l,[["render",f]]);export{D as default}; diff --git a/public/build/assets/ns-pos-layaway-popup-0b54a3bc.js b/public/build/assets/ns-pos-layaway-popup-0b54a3bc.js deleted file mode 100644 index 85b1b8438..000000000 --- a/public/build/assets/ns-pos-layaway-popup-0b54a3bc.js +++ /dev/null @@ -1 +0,0 @@ -import{F,d as c,b as T}from"./bootstrap-ffaf6d09.js";import{_ as l,n as V}from"./currency-feccde3d.js";import{_ as j}from"./_plugin-vue_export-helper-c27b6911.js";import{r as _,o as u,c as h,a as s,t as i,f,e as g,F as C,b as k,g as I,w as b,i as v}from"./runtime-core.esm-bundler-414a078a.js";import"./chart-2ccf8ff7.js";const O={name:"ns-pos-layaway-popup",props:["popup"],data(){return{fields:[],instalments:[],formValidation:new F,subscription:null,totalPayments:0}},mounted(){this.loadFields()},updated(){setTimeout(()=>{document.querySelector(".is-popup #total_instalments").addEventListener("change",()=>{const e=this.formValidation.extractFields(this.fields).total_instalments;this.generatePaymentFields(e)}),document.querySelector(".is-popup #total_instalments").addEventListener("focus",()=>{document.querySelector(".is-popup #total_instalments").select()})},200)},computed:{expectedPayment(){const e=this.order.customer.group.minimal_credit_payment;return nsRawCurrency(this.order.total*e/100)},order(){return this.popup.params.order.instalments=this.popup.params.order.instalments.map(e=>{for(let t in e)if(typeof e[t]!="object"){if(t==="date"){const r={type:"date",name:t,label:l("Date"),disabled:e.paid===1,value:moment(e.date).format("YYYY-MM-DD")};e[t]=r}else if(t==="amount"){const r={type:"number",name:t,label:l("Amount"),disabled:e.paid===1,value:e.amount};e[t]=r}else if(!["paid","id"].includes(t)){const r={type:"hidden",name:t,value:e[t]};e[t]=r}}return e}),this.popup.params.order}},unmounted(){},methods:{__:l,nsCurrency:V,refreshTotalPayments(){if(this.order.instalments.length>0){const e=nsRawCurrency(this.order.instalments.map(t=>parseFloat(t.amount.value)||0).reduce((t,r)=>parseFloat(t)+parseFloat(r)));this.totalPayments=this.order.total-e}else this.totalPayments=0},removeInstalment(e){const t=this.order.instalments.indexOf(e);this.order.instalments.splice(t,1),this.$forceUpdate()},generatePaymentFields(e){this.order.instalments=new Array(parseInt(e)).fill("").map((t,r)=>({date:{type:"date",name:"date",label:"Date",value:r===0?ns.date.moment.format("YYYY-MM-DD"):""},amount:{type:"number",name:"amount",label:"Amount",value:r===0?this.expectedPayment:0},readonly:{type:"hidden",name:"readonly",value:this.expectedPayment>0&&r===0}})),this.$forceUpdate(),this.refreshTotalPayments()},close(){this.popup.params.reject({status:"error",message:l("You must define layaway settings before proceeding.")}),this.popup.close()},skipInstalments(){this.expectedPayment>0?(this.order.instalments=[{amount:this.expectedPayment,date:ns.date.current}],this.order.final_payment_date=this.order.instalments.reverse()[0].date,this.order.total_instalments=this.order.instalments.length,this.order.support_instalments=!1):(this.order.final_payment_date=ns.date.current,this.order.total_instalments=0,this.order.support_instalments=!1),this.popup.close(),POS.order.next(this.order);const{resolve:e,reject:t}=this.popup.params;return e({order:this.order,skip_layaway:!0})},updateOrder(){if(this.order.instalments.length===0)return c.error(l("Please provide instalments before proceeding.")).subscribe();if(this.fields.forEach(n=>this.formValidation.validateField(n)),!this.formValidation.fieldsValid(this.fields))return c.error(l("Unable to process, the form is not valid")).subscribe();this.$forceUpdate();const e=this.order.instalments.map(n=>({amount:parseFloat(n.amount.value),date:n.date.value})),t=nsRawCurrency(e.map(n=>n.amount).reduce((n,m)=>parseFloat(n)+parseFloat(m)));if(e.filter(n=>n.date===void 0||n.date==="").length>0)return c.error(l("One or more instalments has an invalid date.")).subscribe();if(e.filter(n=>!(n.amount>0)).length>0)return c.error(l("One or more instalments has an invalid amount.")).subscribe();if(e.filter(n=>moment(n.date).isBefore(ns.date.moment.startOf("day"))).length>0)return c.error(l("One or more instalments has a date prior to the current date.")).subscribe();const r=e.filter(n=>moment(n.date).isSame(ns.date.moment.startOf("day"),"day"));let y=0;if(r.forEach(n=>{y+=parseFloat(n.amount)}),y{const o=moment(n.date),p=moment(m.date);return o.isBefore(p)?-1:o.isAfter(p)?1:0});const d=this.formValidation.extractFields(this.fields);d.final_payment_date=e.reverse()[0].date,d.total_instalments=e.length;const a={...this.popup.params.order,...d,instalments:e},{resolve:x,reject:w}=this.popup.params;return this.popup.close(),POS.order.next(a),x({order:a,skip_layaway:!1})},loadFields(){T.get("/api/fields/ns.layaway").subscribe(e=>{this.fields=this.formValidation.createFields(e),this.fields.forEach(t=>{t.name==="total_instalments"&&(t.value=this.order.total_instalments||0)})})}}},S={class:"shadow-lg h-95vh md:h-5/6-screen lg:h-5/6-screen w-95vw md:w-4/6-screen lg:w-3/6-screen ns-box flex flex-col"},Y={class:"p-2 border-b ns-box-header flex justify-between items-center"},B={class:"font-semibold"},D={class:"p-2 flex-auto flex flex-col relative overflow-y-auto"},M={key:0,class:"absolute h-full w-full flex items-center justify-center"},E={class:"p-2 elevation-surface info mb-2 text-center text-2xl font-bold flex justify-between"},L={class:"flex flex-col flex-auto overflow-hidden"},q={class:"border-b ns-box-body"},A={class:"text-2xl flex justify-between py-2 text-primary"},N={class:"text-sm"},R={class:"p-2 mb-2 text-center bg-green-200 text-green-700"},U={class:"flex-auto overflow-y-auto"},H={class:"flex flex-auto"},z={class:"px-1 w-full md:w-1/2"},G={class:"px-1 w-full md:w-1/2"},J={class:"flex items-center"},K=["onClick"],Q=s("i",{class:"las la-times"},null,-1),W=[Q],X={key:0,class:"my-2"},Z={class:"p-2 elevation-surface border text-primary text-center"},$={class:"p-2 flex border-t ns-box-footer justify-between flex-shrink-0"},ee={class:"md:-mx-1 flex flex-col md:flex-row"},te={class:"md:px-1"},se={class:"md:-mx-1 flex flex-col md:flex-row"},ne={class:"md:px-1"},ae={class:"md:px-1"};function re(e,t,r,y,d,a){const x=_("ns-close-button"),w=_("ns-spinner"),n=_("ns-field"),m=_("ns-button");return u(),h("div",S,[s("div",Y,[s("h3",B,i(a.__("Layaway Parameters")),1),s("div",null,[f(x,{onClick:t[0]||(t[0]=o=>a.close())})])]),s("div",D,[d.fields.length===0?(u(),h("div",M,[f(w)])):g("",!0),s("div",E,[s("span",null,i(a.__("Minimum Payment")),1),s("span",null,i(a.nsCurrency(a.expectedPayment)),1)]),s("div",null,[(u(!0),h(C,null,k(d.fields,(o,p)=>(u(),I(n,{field:o,key:p},null,8,["field"]))),128))]),s("div",L,[s("div",q,[s("h3",A,[s("span",null,i(a.__("Instalments & Payments")),1),s("p",null,[s("span",N,"("+i(a.nsCurrency(d.totalPayments))+")",1),s("span",null,i(a.nsCurrency(e.total)),1)])]),s("p",R,i(a.__("The final payment date must be the last within the instalments.")),1)]),s("div",U,[(u(!0),h(C,null,k(a.order.instalments,(o,p)=>(u(),h("div",{class:"flex w-full -mx-1 py-2",key:p},[s("div",H,[s("div",z,[f(n,{onChange:t[1]||(t[1]=P=>a.refreshTotalPayments()),field:o.date},null,8,["field"])]),s("div",G,[f(n,{onChange:t[2]||(t[2]=P=>a.refreshTotalPayments()),field:o.amount},null,8,["field"])])]),s("div",J,[s("button",{onClick:P=>a.removeInstalment(o),class:"items-center flex justify-center h-8 w-8 rounded border text-primary ns-inset-button error"},W,8,K)])]))),128)),a.order.instalments.length===0?(u(),h("div",X,[s("p",Z,i(a.__("There is no instalment defined. Please set how many instalments are allowed for this order")),1)])):g("",!0)])])]),s("div",$,[s("div",ee,[s("div",te,[f(m,{onClick:t[3]||(t[3]=o=>a.skipInstalments()),type:"info"},{default:b(()=>[v(i(a.__("Skip Instalments")),1)]),_:1})])]),s("div",se,[s("div",ne,[f(m,{onClick:t[4]||(t[4]=o=>a.close()),type:"error"},{default:b(()=>[v(i(a.__("Cancel")),1)]),_:1})]),s("div",ae,[f(m,{onClick:t[5]||(t[5]=o=>a.updateOrder()),type:"info"},{default:b(()=>[v(i(a.__("Proceed")),1)]),_:1})])])])])}const ce=j(O,[["render",re]]);export{ce as default}; diff --git a/public/build/assets/ns-pos-order-type-button-409712b0.js b/public/build/assets/ns-pos-order-type-button-409712b0.js new file mode 100644 index 000000000..80d79b674 --- /dev/null +++ b/public/build/assets/ns-pos-order-type-button-409712b0.js @@ -0,0 +1 @@ +import{P as r}from"./bootstrap-ffaf6d09.js";import{b as n}from"./ns-pos-shipping-popup-dffc98ef.js";import{_ as p}from"./currency-feccde3d.js";import{_ as a}from"./_plugin-vue_export-helper-c27b6911.js";import{o as i,c as l,a as t,t as d}from"./runtime-core.esm-bundler-414a078a.js";import"./chart-2ccf8ff7.js";import"./ns-prompt-popup-24cc8d6f.js";import"./ns-orders-preview-popup-3c654295.js";import"./index.es-25aa42ee.js";const _={name:"ns-pos-delivery-button",methods:{__:p,openOrderTypeSelection(){r.show(n)}},beforeDestroy(){nsHotPress.destroy("ns_pos_keyboard_order_type")},mounted(){for(let e in nsShortcuts)["ns_pos_keyboard_order_type"].includes(e)&&nsHotPress.create("ns_pos_keyboard_order_type").whenNotVisible([".is-popup"]).whenPressed(nsShortcuts[e]!==null?nsShortcuts[e].join("+"):null,o=>{o.preventDefault(),this.openOrderTypeSelection()})}},c={class:"ns-button default"},u=t("i",{class:"mr-1 text-xl las la-truck"},null,-1);function m(e,o,f,y,h,s){return i(),l("div",c,[t("button",{onClick:o[0]||(o[0]=b=>s.openOrderTypeSelection()),class:"rounded shadow flex-shrink-0 h-12 flex items-center px-2 py-1 text-sm"},[u,t("span",null,d(s.__("Order Type")),1)])])}const D=a(_,[["render",m]]);export{D as default}; diff --git a/public/build/assets/ns-pos-order-type-button-9db68cc6.js b/public/build/assets/ns-pos-order-type-button-9db68cc6.js deleted file mode 100644 index d2eeca4a0..000000000 --- a/public/build/assets/ns-pos-order-type-button-9db68cc6.js +++ /dev/null @@ -1 +0,0 @@ -import{P as r}from"./bootstrap-ffaf6d09.js";import{b as n}from"./ns-pos-order-type-popup-14f46b3a.js";import{_ as p}from"./currency-feccde3d.js";import{_ as a}from"./_plugin-vue_export-helper-c27b6911.js";import{o as i,c as l,a as t,t as d}from"./runtime-core.esm-bundler-414a078a.js";import"./chart-2ccf8ff7.js";import"./ns-prompt-popup-24cc8d6f.js";import"./ns-orders-preview-popup-3c654295.js";import"./index.es-25aa42ee.js";const _={name:"ns-pos-delivery-button",methods:{__:p,openOrderTypeSelection(){r.show(n)}},beforeDestroy(){nsHotPress.destroy("ns_pos_keyboard_order_type")},mounted(){for(let e in nsShortcuts)["ns_pos_keyboard_order_type"].includes(e)&&nsHotPress.create("ns_pos_keyboard_order_type").whenNotVisible([".is-popup"]).whenPressed(nsShortcuts[e]!==null?nsShortcuts[e].join("+"):null,o=>{o.preventDefault(),this.openOrderTypeSelection()})}},c={class:"ns-button default"},u=t("i",{class:"mr-1 text-xl las la-truck"},null,-1);function m(e,o,f,y,h,s){return i(),l("div",c,[t("button",{onClick:o[0]||(o[0]=b=>s.openOrderTypeSelection()),class:"rounded shadow flex-shrink-0 h-12 flex items-center px-2 py-1 text-sm"},[u,t("span",null,d(s.__("Order Type")),1)])])}const D=a(_,[["render",m]]);export{D as default}; diff --git a/public/build/assets/ns-pos-order-type-popup-14f46b3a.js b/public/build/assets/ns-pos-order-type-popup-14f46b3a.js deleted file mode 100644 index d411b9055..000000000 --- a/public/build/assets/ns-pos-order-type-popup-14f46b3a.js +++ /dev/null @@ -1 +0,0 @@ -import{p as T,d as v,P,F as z,b as S,a as j,v as F,w as Q}from"./bootstrap-ffaf6d09.js";import{_ as h,n as R}from"./currency-feccde3d.js";import{a as I,k as B,j as E,l as M,n as H}from"./ns-prompt-popup-24cc8d6f.js";import{_ as O}from"./_plugin-vue_export-helper-c27b6911.js";import{r as m,o as i,c as l,f as p,e as c,a as e,t as o,g as N,F as g,b as k,w as f,i as w,h as K,B as D,n as L}from"./runtime-core.esm-bundler-414a078a.js";import{n as G}from"./ns-orders-preview-popup-3c654295.js";const Y={name:"ns-pos-quantity-popup",props:["popup"],components:{nsNumpad:I,nsNumpadPlus:B},data(){return{finalValue:1,virtualStock:null,options:{},optionsSubscription:null,allSelected:!0,isLoading:!1}},beforeDestroy(){this.optionsSubscription.unsubscribe()},mounted(){this.optionsSubscription=POS.options.subscribe(t=>{this.options=t}),this.popup.params.product.quantity&&(this.finalValue=this.popup.params.product.quantity),this.popupCloser()},unmounted(){nsHotPress.destroy("pos-quantity-numpad"),nsHotPress.destroy("pos-quantity-backspace"),nsHotPress.destroy("pos-quantity-enter")},methods:{__:h,popupCloser:T,closePopup(){this.popup.params.reject(!1),this.popup.close()},updateQuantity(t){this.finalValue=t},defineQuantity(t){const{product:n,data:a}=this.popup.params;if(t===0)return v.error(h("Please provide a quantity")).subscribe();if(n.$original().stock_management==="enabled"&&n.$original().type==="materialized"){const b=POS.getStockUsage(n.$original().id,a.unit_quantity_id)-(n.quantity||0);if(t>parseFloat(a.$quantities().quantity)-b)return v.error(h("Unable to add the product, there is not enough stock. Remaining %s").replace("%s",a.$quantities().quantity-b)).subscribe()}this.resolve({quantity:t})},resolve(t){this.popup.params.resolve(t),this.popup.close()}}},J={class:"ns-box shadow min-h-2/5-screen w-3/4-screen md:w-3/5-screen lg:w-2/5-screen xl:w-2/5-screen relative"},X={key:0,id:"loading-overlay",style:{background:"rgb(202 202 202 / 49%)"},class:"flex w-full h-full absolute top-O left-0 items-center justify-center"},Z={class:"flex-shrink-0 flex justify-between items-center p-2 border-b ns-box-header"},$={class:"text-xl font-bold text-primary text-center"},ee={id:"screen",class:"h-24 primary ns-box-body flex items-center justify-center"},se={class:"font-bold text-3xl"};function te(t,n,a,b,r,s){const x=m("ns-spinner"),u=m("ns-close-button"),y=m("ns-numpad"),C=m("ns-numpad-plus");return i(),l("div",J,[r.isLoading?(i(),l("div",X,[p(x)])):c("",!0),e("div",Z,[e("div",null,[e("h1",$,o(s.__("Define Quantity")),1)]),e("div",null,[p(u,{onClick:n[0]||(n[0]=_=>s.closePopup())})])]),e("div",ee,[e("h1",se,o(r.finalValue),1)]),r.options.ns_pos_numpad==="default"?(i(),N(y,{key:1,floating:r.options.ns_pos_allow_decimal_quantities,onChanged:n[1]||(n[1]=_=>s.updateQuantity(_)),onNext:n[2]||(n[2]=_=>s.defineQuantity(_)),value:r.finalValue},null,8,["floating","value"])):c("",!0),r.options.ns_pos_numpad==="advanced"?(i(),N(C,{key:2,onChanged:n[3]||(n[3]=_=>s.updateQuantity(_)),onNext:n[4]||(n[4]=_=>s.defineQuantity(_)),value:r.finalValue},null,8,["value"])):c("",!0)])}const oe=O(Y,[["render",te]]);class Nn{constructor(n){this.product=n}run(n){return new Promise((a,b)=>{const r=this.product;if(POS.options.getValue().ns_pos_show_quantity!==!1||!POS.processingAddQueue)P.show(oe,{resolve:a,reject:b,product:r,data:n});else{if(r.$original().stock_management==="enabled"&&r.$original().type==="materialized"){const u=POS.getStockUsage(r.$original().id,n.unit_quantity_id)-(r.quantity||0);if(1>parseFloat(n.$quantities().quantity)-u)return v.error(h("Unable to add the product, there is not enough stock. Remaining %s").replace("%s",(n.$quantities().quantity-u).toString())).subscribe()}a({quantity:1})}})}}const ne={mounted(){this.closeWithOverlayClicked(),this.loadTransactionFields()},props:["popup"],data(){return{fields:[],isSubmiting:!1,formValidation:new z}},methods:{__:h,closeWithOverlayClicked:T,proceed(){const t=this.popup.params.customer,n=this.formValidation.extractFields(this.fields);this.isSubmiting=!0,S.post(`/api/customers/${t.id}/account-history`,n).subscribe({next:a=>{this.isSubmiting=!1,v.success(a.message).subscribe(),this.popup.params.resolve(a),this.popup.close()},error:a=>{this.isSubmiting=!1,v.error(a.message).subscribe(),this.popup.params.reject(a)}})},close(){this.popup.close(),this.popup.params.reject(!1)},loadTransactionFields(){S.get("/api/fields/ns.customers-account").subscribe({next:t=>{this.fields=this.formValidation.createFields(t)}})}}},re={class:"w-6/7-screen md:w-5/7-screen lg:w-4/7-screen h-6/7-screen md:h-5/7-screen lg:h-5/7-screen overflow-hidden shadow-lg ns-box flex flex-col relative"},ie={class:"p-2 border-b ns-box-header flex justify-between items-center"},le={class:"font-semibold"},ce={class:"flex-auto overflow-y-auto"},ue={key:0,class:"h-full w-full flex items-center justify-center"},ae={key:1,class:"p-2"},de={class:"p-2 ns-box-footer justify-between border-t flex"},_e=e("div",null,null,-1),pe={class:"px-1"},he={class:"-mx-2 flex flex-wrap"},fe={class:"px-1"},me={class:"px-1"},be={key:0,class:"h-full w-full absolute flex items-center justify-center",style:{background:"rgb(0 98 171 / 45%)"}};function ye(t,n,a,b,r,s){const x=m("ns-close-button"),u=m("ns-spinner"),y=m("ns-field"),C=m("ns-button");return i(),l("div",re,[e("div",ie,[e("h2",le,o(s.__("New Transaction")),1),e("div",null,[p(x,{onClick:n[0]||(n[0]=_=>s.close())})])]),e("div",ce,[r.fields.length===0?(i(),l("div",ue,[p(u)])):c("",!0),r.fields.length>0?(i(),l("div",ae,[(i(!0),l(g,null,k(r.fields,(_,V)=>(i(),N(y,{field:_,key:V},null,8,["field"]))),128))])):c("",!0)]),e("div",de,[_e,e("div",pe,[e("div",he,[e("div",fe,[p(C,{type:"error",onClick:n[1]||(n[1]=_=>s.close())},{default:f(()=>[w(o(s.__("Close")),1)]),_:1})]),e("div",me,[p(C,{type:"info",onClick:n[2]||(n[2]=_=>s.proceed())},{default:f(()=>[w(o(s.__("Proceed")),1)]),_:1})])])])]),r.isSubmiting===0?(i(),l("div",be,[p(u)])):c("",!0)])}const xe=O(ne,[["render",ye]]),ve={name:"ns-pos-coupons-load-popup",props:["popup"],components:{nsNotice:E},data(){return{placeHolder:h("Coupon Code"),couponCode:null,order:null,activeTab:"apply-coupon",orderSubscriber:null,coupon:null}},mounted(){this.popupCloser(),this.orderSubscriber=POS.order.subscribe(t=>{this.order=K(t),this.order.coupons.length>0&&(this.activeTab="active-coupons")}),this.popup.params&&this.popup.params.apply_coupon&&(this.couponCode=this.popup.params.apply_coupon,this.getCoupon(this.couponCode).subscribe({next:t=>{this.coupon=t,this.apply()}}))},unmounted(){this.orderSubscriber.unsubscribe()},methods:{__:h,popupCloser:T,popupResolver:j,selectCustomer(){Popup.show(U)},cancel(){this.coupon=null,this.couponCode=null},removeCoupon(t){this.order.coupons.splice(t,1),POS.refreshCart()},apply(){try{if(this.coupon.valid_hours_start!==null&&!ns.date.moment.isAfter(this.coupon.valid_hours_start)&&this.coupon.valid_hours_start.length>0)return v.error(h("The coupon is out from validity date range.")).subscribe();if(this.coupon.valid_hours_end!==null&&!ns.date.moment.isBefore(this.coupon.valid_hours_end)&&this.coupon.valid_hours_end.length>0)return v.error(h("The coupon is out from validity date range.")).subscribe();const t=this.coupon.products;if(t.length>0){const b=t.map(r=>r.product_id);if(this.order.products.filter(r=>b.includes(r.product_id)).length===0)return v.error(h("This coupon requires products that aren't available on the cart at the moment.")).subscribe()}const n=this.coupon.categories;if(n.length>0){const b=n.map(r=>r.category_id);if(this.order.products.filter(r=>b.includes(r.$original().category_id)).length===0)return v.error(h("This coupon requires products that belongs to specific categories that aren't included at the moment.").replace("%s")).subscribe()}let a={customer_coupon_id:this.coupon.customer_coupon.length>0?this.coupon.customer_coupon[0].id:0,minimum_cart_value:this.coupon.minimum_cart_value,maximum_cart_value:this.coupon.maximum_cart_value,name:this.coupon.name,type:this.coupon.type,value:0,coupon_id:this.coupon.id,limit_usage:this.coupon.limit_usage,code:this.coupon.code,discount_value:this.coupon.discount_value,categories:this.coupon.categories,products:this.coupon.products};this.cancel(),POS.pushCoupon(a),this.activeTab="active-coupons",setTimeout(()=>{this.popupResolver(a)},500),v.success(h("The coupon has applied to the cart.")).subscribe()}catch(t){console.log(t)}},getCouponType(t){switch(t){case"percentage_discount":return h("Percentage");case"flat_discount":return h("Flat");default:return h("Unknown Type")}},getDiscountValue(t){switch(t.type){case"percentage_discount":return t.discount_value+"%";case"flat_discount":return this.$options.filters.currency(t.discount_value)}},closePopup(){this.popupResolver(!1)},setActiveTab(t){this.activeTab=t,t==="apply-coupon"&&setTimeout(()=>{document.querySelector(".coupon-field").select()},10)},getCoupon(t){return!this.order.customer_id>0?v.error(h("You must select a customer before applying a coupon.")):S.post(`/api/customers/coupons/${t}`,{customer_id:this.order.customer_id})},loadCoupon(){const t=this.couponCode;this.getCoupon(t).subscribe({next:n=>{this.coupon=n,v.success(h("The coupon has been loaded.")).subscribe()},error:n=>{v.error(n.message||h("An unexpected error occurred.")).subscribe()}})}}},ge={class:"shadow-lg ns-box w-95vw md:w-3/6-screen lg:w-2/6-screen"},we={class:"border-b ns-box-header p-2 flex justify-between items-center"},Ce={class:"font-bold"},ke={class:"p-1 ns-box-body"},Pe={class:"border-2 input-group info rounded flex"},Se=["placeholder"],Te={class:"pt-2"},Oe={key:0,class:"pt-2 flex"},Ve={key:1,class:"pt-2"},je={class:"overflow-hidden"},Le={key:0,class:"pt-2 fade-in-entrance anim-duration-500 overflow-y-auto ns-scrollbar h-64"},Ne={class:"w-full ns-table"},Ae={class:"p-2 w-1/2 border"},qe={class:"p-2 w-1/2 border"},Re={class:"p-2 w-1/2 border"},He={class:"p-2 w-1/2 border"},Fe={class:"p-2 w-1/2 border"},Qe={class:"p-2 w-1/2 border"},De={class:"p-2 w-1/2 border"},Ue={class:"p-2 w-1/2 border"},We={class:"p-2 w-1/2 border"},ze={class:"p-2 w-1/2 border"},Ie={class:"p-2 w-1/2 border"},Be={class:"p-2 w-1/2 border"},Ee={key:0},Me={class:"p-2 w-1/2 border"},Ke={class:"p-2 w-1/2 border"},Ge={key:0},Ye={key:0},Je={class:"flex-auto"},Xe={class:"font-semibold text-primary p-2 flex justify-between"},Ze={key:0,class:"flex justify-between elevation-surface border items-center p-2"},$e={key:0,class:"flex"};function es(t,n,a,b,r,s){const x=m("ns-close-button"),u=m("ns-notice"),y=m("ns-tabs-item"),C=m("ns-tabs");return i(),l("div",ge,[e("div",we,[e("h3",Ce,o(s.__("Load Coupon")),1),e("div",null,[p(x,{onClick:n[0]||(n[0]=_=>s.closePopup())})])]),e("div",ke,[p(C,{onActive:n[5]||(n[5]=_=>s.setActiveTab(_)),active:r.activeTab},{default:f(()=>[p(y,{label:s.__("Apply A Coupon"),padding:"p-2",identifier:"apply-coupon"},{default:f(()=>[e("div",Pe,[D(e("input",{ref:"coupon",onKeyup:n[1]||(n[1]=Q(_=>s.loadCoupon(),["enter"])),"onUpdate:modelValue":n[2]||(n[2]=_=>r.couponCode=_),type:"text",class:"coupon-field w-full text-primary p-2 outline-none",placeholder:r.placeHolder},null,40,Se),[[F,r.couponCode]]),e("button",{onClick:n[3]||(n[3]=_=>s.loadCoupon()),class:"px-3 py-2"},o(s.__("Load")),1)]),e("div",Te,[p(u,{color:"info"},{description:f(()=>[w(o(s.__("Input the coupon code that should apply to the POS. If a coupon is issued for a customer, that customer must be selected priorly.")),1)]),_:1})]),r.order&&r.order.customer_id===void 0?(i(),l("div",Oe,[e("button",{onClick:n[4]||(n[4]=_=>s.selectCustomer()),class:"w-full border p-2 outline-none ns-numpad-key info cursor-pointer text-center"},o(s.__("Click here to choose a customer.")),1)])):c("",!0),r.order&&r.order.customer_id!==void 0?(i(),l("div",Ve,[p(u,{color:"success"},{description:f(()=>[w(o(s.__("Loading Coupon For : ")+`${r.order.customer.first_name} ${r.order.customer.last_name}`),1)]),_:1})])):c("",!0),e("div",je,[r.coupon?(i(),l("div",Le,[e("table",Ne,[e("tbody",null,[e("tr",null,[e("td",Ae,o(s.__("Coupon Name")),1),e("td",qe,o(r.coupon.name),1)]),e("tr",null,[e("td",Re,o(s.__("Discount"))+" ("+o(s.getCouponType(r.coupon.type))+")",1),e("td",He,o(s.getDiscountValue(r.coupon)),1)]),e("tr",null,[e("td",Fe,o(s.__("Usage")),1),e("td",Qe,o((r.coupon.customer_coupon.length>0?r.coupon.customer_coupon[0].usage:0)+"/"+(r.coupon.limit_usage||s.__("Unlimited"))),1)]),e("tr",null,[e("td",De,o(s.__("Valid From")),1),e("td",Ue,o(r.coupon.valid_hours_start||s.__("N/A")),1)]),e("tr",null,[e("td",We,o(s.__("Valid Till")),1),e("td",ze,o(r.coupon.valid_hours_end||s.__("N/A")),1)]),e("tr",null,[e("td",Ie,o(s.__("Categories")),1),e("td",Be,[e("ul",null,[(i(!0),l(g,null,k(r.coupon.categories,_=>(i(),l("li",{class:"rounded-full px-3 py-1 border",key:_.id},o(_.category.name),1))),128)),r.coupon.categories.length===0?(i(),l("li",Ee,o(s.__("Not applicable")),1)):c("",!0)])])]),e("tr",null,[e("td",Me,o(s.__("Products")),1),e("td",Ke,[e("ul",null,[(i(!0),l(g,null,k(r.coupon.products,_=>(i(),l("li",{class:"rounded-full px-3 py-1 border",key:_.id},o(_.product.name),1))),128)),r.coupon.products.length===0?(i(),l("li",Ge,o(s.__("Not applicable")),1)):c("",!0)])])])])])])):c("",!0)])]),_:1},8,["label"]),p(y,{label:s.__("Active Coupons"),padding:"p-1",identifier:"active-coupons"},{default:f(()=>[r.order?(i(),l("ul",Ye,[(i(!0),l(g,null,k(r.order.coupons,(_,V)=>(i(),l("li",{key:V,class:"flex justify-between elevation-surface border items-center px-2 py-1"},[e("div",Je,[e("h3",Xe,[e("span",null,o(_.name),1),e("span",null,o(s.getDiscountValue(_)),1)])]),e("div",null,[p(x,{onClick:A=>s.removeCoupon(V)},null,8,["onClick"])])]))),128)),r.order.coupons.length===0?(i(),l("li",Ze,o(s.__("No coupons applies to the cart.")),1)):c("",!0)])):c("",!0)]),_:1},8,["label"])]),_:1},8,["active"])]),r.coupon?(i(),l("div",$e,[e("button",{onClick:n[6]||(n[6]=_=>s.apply()),class:"w-1/2 px-3 py-2 bg-success-tertiary text-white font-bold"},o(s.__("Apply")),1),e("button",{onClick:n[7]||(n[7]=_=>s.cancel()),class:"w-1/2 px-3 py-2 bg-error-tertiary text-white font-bold"},o(s.__("Cancel")),1)])):c("",!0)])}const ss=O(ve,[["render",es]]),ts={name:"ns-pos-customers",props:["popup"],data(){return{activeTab:"create-customers",customer:null,subscription:null,orders:[],options:{},optionsSubscriber:null,selectedTab:"orders",isLoadingCoupons:!1,isLoadingRewards:!1,isLoadingHistory:!1,isLoadingOrders:!1,coupons:[],userCan:t=>POS.userCan(t),rewardsResponse:[],order:null,walletHistories:[]}},components:{nsPaginate:M},unmounted(){this.subscription.unsubscribe(),this.optionsSubscriber.unsubscribe()},mounted(){this.closeWithOverlayClicked(),this.optionsSubscriber=POS.options.subscribe(t=>{this.options=t}),this.subscription=POS.order.subscribe(t=>{this.order=t,this.popup.params.customer!==void 0?(this.activeTab="account-payment",this.customer=this.popup.params.customer,this.loadCustomerOrders()):t.customer!==void 0&&(this.activeTab="account-payment",this.customer=t.customer,this.loadCustomerOrders())}),this.popupCloser()},methods:{__:h,nsCurrency:R,reload(){this.loadCustomerOrders()},popupResolver:j,popupCloser:T,getWalletHistoryLabel(t){switch(t){case"add":return h("Crediting");case"deduct":return h("Removing");case"refund":return h("Refunding");case"payment":return h("Payment");default:return h("Unknow")}},getType(t){switch(t){case"percentage_discount":return h("Percentage Discount");case"flat_discount":return h("Flat Discount")}},closeWithOverlayClicked:T,async openOrderOptions(t){try{const n=await new Promise((a,b)=>{P.show(G,{order:t,resolve:a,reject:b})});this.reload()}catch{v.error(h("An error occurred while opening the order options")).subscribe()}},doChangeTab(t){this.selectedTab=t,t==="coupons"&&this.loadCoupons(),t==="rewards"&&this.loadRewards(),t==="wallet-history"&&this.loadAccounHistory(),t==="orders"&&this.loadCustomerOrders()},loadAccounHistory(){this.isLoadingHistory=!0,S.get(`/api/customers/${this.customer.id}/account-history`).subscribe({next:t=>{this.walletHistories=t.data,this.isLoadingHistory=!1},error:t=>{this.isLoadingHistory=!1}})},loadCoupons(){this.isLoadingCoupons=!0,S.get(`/api/customers/${this.customer.id}/coupons`).subscribe({next:t=>{this.coupons=t,this.isLoadingCoupons=!1},error:t=>{this.isLoadingCoupons=!1}})},loadRewards(t=`/api/customers/${this.customer.id}/rewards`){this.isLoadingRewards=!0,S.get(t).subscribe({next:n=>{this.rewardsResponse=n,this.isLoadingRewards=!1},error:n=>{this.isLoadingRewards=!1}})},prefillForm(t){this.popup.params.name!==void 0&&(t.main.value=this.popup.params.name)},openCustomerSelection(){this.popup.close(t=>{P.show(U)})},loadCustomerOrders(){this.isLoadingOrders=!0,S.get(`/api/customers/${this.customer.id}/orders`).subscribe({next:t=>{this.orders=t,this.isLoadingOrders=!1},error:t=>{this.isLoadingOrders=!1}})},newTransaction(t){new Promise((a,b)=>{P.show(xe,{customer:t,resolve:a,reject:b})}).then(a=>{POS.loadCustomer(t.id).subscribe(b=>{POS.selectCustomer(b)})})},applyCoupon(t){this.order.customer===void 0?P.show(H,{title:h("Use Customer ?"),message:h("No customer is selected. Would you like to proceed with this customer ?"),onAction:n=>{n&&POS.selectCustomer(this.customer).then(a=>{this.proceedApplyingCoupon(t)})}}):this.order.customer.id===this.customer.id?this.proceedApplyingCoupon(t):this.order.customer.id!==this.customer.id&&P.show(H,{title:h("Change Customer ?"),message:h("Would you like to assign this customer to the ongoing order ?"),onAction:n=>{n&&POS.selectCustomer(this.customer).then(a=>{this.proceedApplyingCoupon(t)})}})},proceedApplyingCoupon(t){new Promise((n,a)=>{P.show(ss,{apply_coupon:t.code,resolve:n,reject:a})}).then(n=>{this.popupResolver(!1)}).catch(n=>{})},handleSavedCustomer(t){v.success(t.message).subscribe(),POS.selectCustomer(t.data.entry),this.popup.close()}}},os={id:"ns-pos-customers",class:"shadow-lg rounded w-95vw h-95vh lg:w-3/5-screen flex flex-col overflow-hidden"},rs={class:"ns-header p-2 flex justify-between items-center border-b"},is={class:"font-semibold"},ls={class:"ns-body flex-auto flex p-2 overflow-y-auto"},cs={key:1,class:"h-full flex-col w-full flex items-center justify-center text-primary"},us=e("i",{class:"lar la-hand-paper ns-icon text-6xl"},null,-1),as={class:"font-medium text-2xl"},ds={key:0,class:"flex-auto w-full flex items-center justify-center flex-col p-4"},_s=e("i",{class:"lar la-frown text-6xl"},null,-1),ps={class:"font-medium text-2xl"},hs={class:"my-2"},fs={key:1,class:"flex flex-col flex-auto"},ms={class:"flex-auto p-2 flex flex-col"},bs={class:"flex flex-wrap"},ys={class:"px-4 mb-4 w-full"},xs={class:"font-semibold"},vs={class:"flex flex-wrap ns-tab-cards -mx-2 w-full"},gs={class:"px-2 mb-4 w-full md:w-1/4 flex"},ws={class:"rounded-lg shadow w-full bg-transparent bg-gradient-to-br from-success-secondary to-green-700 p-2 flex flex-col text-white"},Cs={class:"font-medium text-lg"},ks={class:"w-full flex justify-end"},Ps={class:"font-bold"},Ss={class:"px-2 mb-4 w-full md:w-1/4 flex"},Ts={class:"rounded-lg shadow w-full bg-transparent bg-gradient-to-br from-error-secondary to-red-700 p-2 text-white"},Os={class:"font-medium text-lg"},Vs={class:"w-full flex justify-end"},js={class:"font-bold"},Ls={class:"px-2 mb-4 w-full md:w-1/4 flex"},Ns={class:"rounded-lg shadow w-full bg-transparent bg-gradient-to-br from-blue-500 to-blue-700 p-2 text-white"},As={class:"font-medium text-lg"},qs={class:"w-full flex justify-end"},Rs={class:"font-bold"},Hs={class:"px-2 mb-4 w-full md:w-1/4 flex"},Fs={class:"rounded-lg shadow w-full bg-transparent bg-gradient-to-br from-teal-500 to-teal-700 p-2 text-white"},Qs={class:"font-medium text-lg"},Ds={class:"w-full flex justify-end"},Us={class:"font-bold"},Ws={class:"flex flex-auto flex-col overflow-hidden"},zs={key:0,class:"flex-auto h-full justify-center flex items-center"},Is={class:"py-2 w-full"},Bs={class:"font-semibold text-primary"},Es={class:"flex-auto flex-col flex overflow-hidden"},Ms={class:"flex-auto overflow-y-auto"},Ks={class:"table ns-table w-full"},Gs={class:"text-primary"},Ys={colspan:"3",width:"150",class:"p-2 border font-semibold"},Js={width:"50",class:"p-2 border font-semibold"},Xs={class:"text-primary"},Zs={key:0},$s={class:"border p-2 text-center",colspan:"4"},et={colspan:"3",class:"border p-2 text-center"},st={class:"flex flex-col items-start"},tt={class:"font-bold"},ot={class:"md:-mx-2 w-full flex flex-col md:flex-row"},nt={class:"md:px-2 flex items-start w-full md:w-1/4"},rt={class:"md:px-2 flex items-start w-full md:w-1/4"},it={class:"md:px-2 flex items-start w-full md:w-1/4"},lt={class:"border p-2 text-center"},ct=["onClick"],ut=e("i",{class:"las la-wallet"},null,-1),at={class:"ml-1"},dt={key:0,class:"flex-auto h-full justify-center flex items-center"},_t={class:"py-2 w-full"},pt={class:"font-semibold text-primary"},ht={class:"flex-auto flex-col flex overflow-hidden"},ft={class:"flex-auto overflow-y-auto"},mt={class:"table ns-table w-full"},bt={class:"text-primary"},yt={colspan:"3",width:"150",class:"p-2 border font-semibold"},xt={class:"text-primary"},vt={key:0},gt={class:"border p-2 text-center",colspan:"3"},wt={colspan:"3",class:"border p-2 text-center"},Ct={class:"flex flex-col items-start"},kt={class:"font-bold"},Pt={class:"md:-mx-2 w-full flex flex-col md:flex-row"},St={class:"md:px-2 flex items-start w-full md:w-1/3"},Tt={class:"md:px-2 flex items-start w-full md:w-1/3"},Ot={key:0,class:"flex-auto h-full justify-center flex items-center"},Vt={class:"py-2 w-full"},jt={class:"font-semibold text-primary"},Lt={class:"flex-auto flex-col flex overflow-hidden"},Nt={class:"flex-auto overflow-y-auto"},At={class:"table ns-table w-full"},qt={class:"text-primary"},Rt={width:"150",class:"p-2 border font-semibold"},Ht={class:"p-2 border font-semibold"},Ft=e("th",{class:"p-2 border font-semibold"},null,-1),Qt={class:"text-primary text-sm"},Dt={key:0},Ut={class:"border p-2 text-center",colspan:"4"},Wt={width:"300",class:"border p-2"},zt={class:""},It={class:"-mx-2 flex"},Bt={class:"text-xs text-primary px-2"},Et={class:"text-xs text-primary px-2"},Mt={class:"border p-2 text-center"},Kt={key:0},Gt={key:1},Yt={class:"border p-2 text-right"},Jt={key:0,class:"flex-auto h-full justify-center flex items-center"},Xt={class:"py-2 w-full"},Zt={class:"font-semibold text-primary"},$t={class:"flex-auto flex-col flex overflow-hidden"},eo={class:"flex-auto overflow-y-auto"},so={class:"table ns-table w-full"},to={class:"text-primary"},oo={width:"150",class:"p-2 border font-semibold"},no={class:"p-2 border font-semibold"},ro={class:"p-2 border font-semibold"},io={key:0,class:"text-primary text-sm"},lo={key:0},co={class:"border p-2 text-center",colspan:"4"},uo={width:"300",class:"border p-2"},ao={class:"text-center"},_o={width:"300",class:"border p-2"},po={class:"text-center"},ho={width:"300",class:"border p-2"},fo={class:"text-center"},mo={class:"py-1 flex justify-end"},bo={class:"p-2 border-t border-box-edge flex justify-between"},yo=e("div",null,null,-1);function xo(t,n,a,b,r,s){const x=m("ns-close-button"),u=m("ns-crud-form"),y=m("ns-tabs-item"),C=m("ns-button"),_=m("ns-spinner"),V=m("ns-paginate"),A=m("ns-tabs");return i(),l("div",os,[e("div",rs,[e("h3",is,o(s.__("Customers")),1),e("div",null,[p(x,{onClick:n[0]||(n[0]=d=>a.popup.close())})])]),e("div",ls,[p(A,{active:r.activeTab,onActive:n[7]||(n[7]=d=>r.activeTab=d)},{default:f(()=>[p(y,{identifier:"create-customers",label:s.__("New Customer")},{default:f(()=>[r.userCan("nexopos.create.customers")?(i(),N(u,{key:0,onUpdated:n[1]||(n[1]=d=>s.prefillForm(d)),onSave:n[2]||(n[2]=d=>s.handleSavedCustomer(d)),"submit-url":"/api/crud/ns.customers",src:"/api/crud/ns.customers/form-config"},{title:f(()=>[w(o(s.__("Customer Name")),1)]),save:f(()=>[w(o(s.__("Save Customer")),1)]),_:1})):c("",!0),r.userCan("nexopos.create.customers")?c("",!0):(i(),l("div",cs,[us,e("h3",as,o(s.__("Not Authorized")),1),e("p",null,o(s.__("Creating customers has been explicitly disabled from the settings.")),1)]))]),_:1},8,["label"]),p(y,{identifier:"account-payment",label:s.__("Customer Account"),class:"flex",padding:"p-0 flex"},{default:f(()=>[r.customer===null?(i(),l("div",ds,[_s,e("h3",ps,o(s.__("No Customer Selected")),1),e("p",null,o(s.__("In order to see a customer account, you need to select one customer.")),1),e("div",hs,[p(C,{onClick:n[3]||(n[3]=d=>s.openCustomerSelection()),type:"info"},{default:f(()=>[w(o(s.__("Select Customer")),1)]),_:1})])])):c("",!0),r.customer?(i(),l("div",fs,[e("div",ms,[e("div",bs,[e("div",ys,[e("h2",xs,o(s.__("Summary For"))+" : "+o(r.customer.first_name),1)]),e("div",vs,[e("div",gs,[e("div",ws,[e("h3",Cs,o(s.__("Purchases")),1),e("div",ks,[e("h2",Ps,o(s.nsCurrency(r.customer.purchases_amount)),1)])])]),e("div",Ss,[e("div",Ts,[e("h3",Os,o(s.__("Owed")),1),e("div",Vs,[e("h2",js,o(s.nsCurrency(r.customer.owed_amount)),1)])])]),e("div",Ls,[e("div",Ns,[e("h3",As,o(s.__("Wallet Amount")),1),e("div",qs,[e("h2",Rs,o(s.nsCurrency(r.customer.account_amount)),1)])])]),e("div",Hs,[e("div",Fs,[e("h3",Qs,o(s.__("Credit Limit")),1),e("div",Ds,[e("h2",Us,o(s.nsCurrency(r.customer.credit_limit_amount)),1)])])])])]),e("div",Ws,[p(A,{active:r.selectedTab,onChangeTab:n[5]||(n[5]=d=>s.doChangeTab(d))},{default:f(()=>[p(y,{identifier:"orders",label:s.__("Orders")},{default:f(()=>[r.isLoadingOrders?(i(),l("div",zs,[p(_,{size:"36"})])):c("",!0),r.isLoadingOrders?c("",!0):(i(),l(g,{key:1},[e("div",Is,[e("h2",Bs,o(s.__("Last Purchases")),1)]),e("div",Es,[e("div",Ms,[e("table",Ks,[e("thead",null,[e("tr",Gs,[e("th",Ys,o(s.__("Order")),1),e("th",Js,o(s.__("Options")),1)])]),e("tbody",Xs,[r.orders.length===0?(i(),l("tr",Zs,[e("td",$s,o(s.__("No orders...")),1)])):c("",!0),(i(!0),l(g,null,k(r.orders,d=>(i(),l("tr",{key:d.id},[e("td",et,[e("div",st,[e("h3",tt,o(s.__("Code"))+": "+o(d.code),1),e("div",ot,[e("div",nt,[e("small",null,o(s.__("Total"))+": "+o(s.nsCurrency(d.total)),1)]),e("div",rt,[e("small",null,o(s.__("Status"))+": "+o(d.human_status),1)]),e("div",it,[e("small",null,o(s.__("Delivery"))+": "+o(d.human_delivery_status),1)])])])]),e("td",lt,[e("button",{onClick:W=>s.openOrderOptions(d),class:"rounded-full h-8 px-2 flex items-center justify-center border border-gray ns-inset-button success"},[ut,e("span",at,o(s.__("Options")),1)],8,ct)])]))),128))])])])])],64))]),_:1},8,["label"]),p(y,{identifier:"wallet-history",label:s.__("Wallet History")},{default:f(()=>[r.isLoadingHistory?(i(),l("div",dt,[p(_,{size:"36"})])):c("",!0),r.isLoadingHistory?c("",!0):(i(),l(g,{key:1},[e("div",_t,[e("h2",pt,o(s.__("Wallet History")),1)]),e("div",ht,[e("div",ft,[e("table",mt,[e("thead",null,[e("tr",bt,[e("th",yt,o(s.__("Transaction")),1)])]),e("tbody",xt,[r.walletHistories.length===0?(i(),l("tr",vt,[e("td",gt,o(s.__("No History...")),1)])):c("",!0),(i(!0),l(g,null,k(r.walletHistories,d=>(i(),l("tr",{key:d.id},[e("td",wt,[e("div",Ct,[e("h3",kt,o(s.__("Transaction"))+": "+o(s.getWalletHistoryLabel(d.operation)),1),e("div",Pt,[e("div",St,[e("small",null,o(s.__("Amount"))+": "+o(s.nsCurrency(t.amount)),1)]),e("div",Tt,[e("small",null,o(s.__("Date"))+": "+o(d.created_at),1)])])])])]))),128))])])])])],64))]),_:1},8,["label"]),p(y,{identifier:"coupons",label:s.__("Coupons")},{default:f(()=>[r.isLoadingCoupons?(i(),l("div",Ot,[p(_,{size:"36"})])):c("",!0),r.isLoadingCoupons?c("",!0):(i(),l(g,{key:1},[e("div",Vt,[e("h2",jt,o(s.__("Coupons")),1)]),e("div",Lt,[e("div",Nt,[e("table",At,[e("thead",null,[e("tr",qt,[e("th",Rt,o(s.__("Name")),1),e("th",Ht,o(s.__("Type")),1),Ft])]),e("tbody",Qt,[r.coupons.length===0?(i(),l("tr",Dt,[e("td",Ut,o(s.__("No coupons for the selected customer...")),1)])):c("",!0),(i(!0),l(g,null,k(r.coupons,d=>(i(),l("tr",{key:d.id},[e("td",Wt,[e("h3",null,o(d.name),1),e("div",zt,[e("ul",It,[e("li",Bt,o(s.__("Usage :"))+" "+o(d.usage)+"/"+o(d.limit_usage),1),e("li",Et,o(s.__("Code :"))+" "+o(d.code),1)])])]),e("td",Mt,[w(o(s.getType(d.coupon.type))+" ",1),d.coupon.type==="percentage_discount"?(i(),l("span",Kt," ("+o(d.coupon.discount_value)+"%) ",1)):c("",!0),d.coupon.type==="flat_discount"?(i(),l("span",Gt," ("+o(s.nsCurrency(t.value))+") ",1)):c("",!0)]),e("td",Yt,[p(C,{onClick:W=>s.applyCoupon(d),type:"info"},{default:f(()=>[w(o(s.__("Use Coupon")),1)]),_:2},1032,["onClick"])])]))),128))])])])])],64))]),_:1},8,["label"]),p(y,{identifier:"rewards",label:s.__("Rewards")},{default:f(()=>[r.isLoadingRewards?(i(),l("div",Jt,[p(_,{size:"36"})])):c("",!0),r.isLoadingRewards?c("",!0):(i(),l(g,{key:1},[e("div",Xt,[e("h2",Zt,o(s.__("Rewards")),1)]),e("div",$t,[e("div",eo,[e("table",so,[e("thead",null,[e("tr",to,[e("th",oo,o(s.__("Name")),1),e("th",no,o(s.__("Points")),1),e("th",ro,o(s.__("Target")),1)])]),r.rewardsResponse.data?(i(),l("tbody",io,[r.rewardsResponse.data.length===0?(i(),l("tr",lo,[e("td",co,o(s.__("No rewards available the selected customer...")),1)])):c("",!0),(i(!0),l(g,null,k(r.rewardsResponse.data,d=>(i(),l("tr",{key:d.id},[e("td",uo,[e("h3",ao,o(d.reward_name),1)]),e("td",_o,[e("h3",po,o(d.points),1)]),e("td",ho,[e("h3",fo,o(d.target),1)])]))),128))])):c("",!0)])])]),e("div",mo,[p(V,{pagination:r.rewardsResponse,onLoad:n[4]||(n[4]=d=>s.loadRewards(d))},null,8,["pagination"])])],64))]),_:1},8,["label"])]),_:1},8,["active"])])]),e("div",bo,[yo,e("div",null,[p(C,{onClick:n[6]||(n[6]=d=>s.newTransaction(r.customer)),type:"info"},{default:f(()=>[w(o(s.__("Account Transaction")),1)]),_:1})])])])):c("",!0)]),_:1},8,["label"])]),_:1},8,["active"])])])}const q=O(ts,[["render",xo]]),An=Object.freeze(Object.defineProperty({__proto__:null,default:q},Symbol.toStringTag,{value:"Module"})),vo={props:["popup"],data(){return{searchCustomerValue:"",orderSubscription:null,order:{},debounceSearch:null,customers:[],isLoading:!1}},computed:{customerSelected(){return!1}},watch:{searchCustomerValue(t){clearTimeout(this.debounceSearch),this.debounceSearch=setTimeout(()=>{this.searchCustomer(t)},500)}},mounted(){this.orderSubscription=POS.order.subscribe(t=>{this.order=t}),this.getRecentCustomers(),this.$refs.searchField.focus(),this.popupCloser()},unmounted(){this.orderSubscription.unsubscribe()},methods:{__:h,popupCloser:T,nsCurrency:R,resolveIfQueued:j,attemptToChoose(){if(this.customers.length===1)return this.selectCustomer(this.customers[0]);v.info(h("Too many results.")).subscribe()},openCustomerHistory(t,n){n.stopImmediatePropagation(),this.popup.close(),P.show(q,{customer:t,activeTab:"account-payment"})},selectCustomer(t){this.customers.forEach(n=>n.selected=!1),t.selected=!0,this.isLoading=!0,POS.selectCustomer(t).then(n=>{this.isLoading=!1,this.resolveIfQueued(t)}).catch(n=>{this.isLoading=!1})},searchCustomer(t){S.post("/api/customers/search",{search:t}).subscribe(n=>{n.forEach(a=>a.selected=!1),this.customers=n})},createCustomerWithMatch(t){this.resolveIfQueued(!1),P.show(q,{name:t})},getRecentCustomers(){this.isLoading=!0,S.get("/api/customers/recently-active").subscribe({next:t=>{this.isLoading=!1,t.forEach(n=>n.selected=!1),this.customers=t},error:t=>{this.isLoading=!1}})}}},go={id:"ns-pos-customer-select-popup",class:"ns-box shadow-xl w-4/5-screen md:w-2/5-screen xl:w-108"},wo={id:"header",class:"border-b ns-box-header text-center font-semibold text-2xl py-2"},Co={class:"relative"},ko={class:"p-2 border-b ns-box-body items-center flex justify-between"},Po={class:"flex items-center justify-between"},So=e("i",{class:"las la-eye"},null,-1),To=[So],Oo={class:"p-2 border-b ns-box-body flex justify-between text-primary"},Vo={class:"input-group flex-auto border-2 rounded"},jo={class:"h-3/5-screen xl:h-2/5-screen overflow-y-auto ns-scrollbar"},Lo={class:"ns-vertical-menu"},No={key:0,class:"p-2 text-center text-primary"},Ao={class:"border-b border-dashed border-info-primary"},qo=["onClick"],Ro={class:"flex flex-col"},Ho={key:0,class:"text-xs text-secondary"},Fo={key:1,class:"text-xs text-secondary"},Qo={class:"flex items-center"},Do={key:0,class:"text-error-primary"},Uo={key:1},Wo={class:"purchase-amount"},zo=["onClick"],Io=e("i",{class:"las la-eye"},null,-1),Bo=[Io],Eo={key:0,class:"z-10 top-0 absolute w-full h-full flex items-center justify-center"};function Mo(t,n,a,b,r,s){const x=m("ns-spinner");return i(),l("div",go,[e("div",wo,[e("h2",null,o(s.__("Select Customer")),1)]),e("div",Co,[e("div",ko,[e("span",null,o(s.__("Selected"))+" : ",1),e("div",Po,[e("span",null,o(r.order.customer?`${r.order.customer.first_name} ${r.order.customer.last_name}`:"N/A"),1),r.order.customer?(i(),l("button",{key:0,onClick:n[0]||(n[0]=u=>s.openCustomerHistory(r.order.customer,u)),class:"mx-2 rounded-full h-8 w-8 flex items-center justify-center border ns-inset-button hover:border-transparent"},To)):c("",!0)])]),e("div",Oo,[e("div",Vo,[D(e("input",{ref:"searchField",onKeydown:n[1]||(n[1]=Q(u=>s.attemptToChoose(),["enter"])),"onUpdate:modelValue":n[2]||(n[2]=u=>r.searchCustomerValue=u),placeholder:"Search Customer",type:"text",class:"outline-none w-full p-2"},null,544),[[F,r.searchCustomerValue]])])]),e("div",jo,[e("ul",Lo,[r.customers&&r.customers.length===0?(i(),l("li",No,o(s.__("No customer match your query...")),1)):c("",!0),r.customers&&r.customers.length===0?(i(),l("li",{key:1,onClick:n[3]||(n[3]=u=>s.createCustomerWithMatch(r.searchCustomerValue)),class:"p-2 cursor-pointer text-center text-primary"},[e("span",Ao,o(s.__("Create a customer")),1)])):c("",!0),(i(!0),l(g,null,k(r.customers,u=>(i(),l("li",{onClick:y=>s.selectCustomer(u),key:u.id,class:"cursor-pointer p-2 border-b text-primary flex justify-between items-center"},[e("div",Ro,[e("span",null,o(u.first_name)+" "+o(u.last_name),1),u.group?(i(),l("small",Ho,o(u.group.name),1)):(i(),l("small",Fo,o(s.__("No Group Assigned")),1))]),e("p",Qo,[u.owe_amount>0?(i(),l("span",Do,"-"+o(s.nsCurrency(u.owe_amount)),1)):c("",!0),u.owe_amount>0?(i(),l("span",Uo,"/")):c("",!0),e("span",Wo,o(s.nsCurrency(u.purchases_amount)),1),e("button",{onClick:y=>s.openCustomerHistory(u,y),class:"mx-2 rounded-full h-8 w-8 flex items-center justify-center border ns-inset-button info"},Bo,8,zo)])],8,qo))),128))])]),r.isLoading?(i(),l("div",Eo,[p(x,{size:"24",border:"8"})])):c("",!0)])])}const U=O(vo,[["render",Mo]]),Ko={name:"ns-pos-discount-popup",props:["popup"],data(){return{finalValue:1,virtualStock:null,popupSubscription:null,mode:"",type:"",allSelected:!0,isLoading:!1,keys:[...[7,8,9].map(t=>({identifier:t,value:t})),...[4,5,6].map(t=>({identifier:t,value:t})),...[1,2,3].map(t=>({identifier:t,value:t})),{identifier:"backspace",icon:"la-backspace"},{identifier:0,value:0},{identifier:"next",icon:"la-share"}]}},mounted(){this.mode=this.popup.params.reference.discount_type||"percentage",this.type=this.popup.params.type,this.mode==="percentage"?this.finalValue=this.popup.params.reference.discount_percentage||1:this.finalValue=this.popup.params.reference.discount||1,this.popupCloser()},methods:{__:h,nsCurrency:R,popupResolver:j,popupCloser:T,setPercentageType(t){this.mode=t},closePopup(){this.popup.close()},inputValue(t){t.identifier==="next"?(this.popup.params.onSubmit({discount_type:this.mode,discount_percentage:this.mode==="percentage"?this.finalValue:void 0,discount:this.mode==="flat"?this.finalValue:void 0}),this.popup.close()):t.identifier==="backspace"?this.allSelected?(this.finalValue=0,this.allSelected=!1):(this.finalValue=this.finalValue.toString(),this.finalValue=this.finalValue.substr(0,this.finalValue.length-1)||0):this.allSelected?(this.finalValue=t.value,this.finalValue=parseFloat(this.finalValue),this.allSelected=!1):(this.finalValue+=""+t.value,this.finalValue=parseFloat(this.finalValue),this.mode==="percentage"&&(this.finalValue=this.finalValue>100?100:this.finalValue))}}},Go={id:"discount-popup",class:"ns-box shadow min-h-2/5-screen w-6/7-screen md:w-3/5-screen lg:w-3/5-screen xl:w-2/5-screen relative"},Yo={class:"flex-shrink-0 flex justify-between items-center p-2 border-b ns-box-header"},Jo={key:0,class:"text-xl font-bold text-primary text-center"},Xo={key:1,class:"text-xl font-bold text-primary text-center"},Zo={id:"screen",class:"h-16 ns-box-body text-white flex items-center justify-center"},$o={class:"font-bold text-3xl"},en={key:0},sn={key:1},tn={id:"switch-mode",class:"flex"},on=e("hr",{class:"border-r border-box-edge"},null,-1),nn={id:"numpad",class:"grid grid-flow-row grid-cols-3 grid-rows-3"},rn=["onClick"],ln={key:0};function cn(t,n,a,b,r,s){const x=m("ns-close-button");return i(),l("div",Go,[e("div",Yo,[e("div",null,[r.type==="product"?(i(),l("h1",Jo,o(s.__("Product Discount")),1)):c("",!0),r.type==="cart"?(i(),l("h1",Xo,o(s.__("Cart Discount")),1)):c("",!0)]),e("div",null,[p(x,{onClick:n[0]||(n[0]=u=>s.closePopup())})])]),e("div",Zo,[e("h1",$o,[r.mode==="flat"?(i(),l("span",en,o(s.nsCurrency(r.finalValue)),1)):c("",!0),r.mode==="percentage"?(i(),l("span",sn,o(r.finalValue)+"%",1)):c("",!0)])]),e("div",tn,[e("button",{onClick:n[1]||(n[1]=u=>s.setPercentageType("flat")),class:L([r.mode==="flat"?"bg-tab-active":"bg-tab-inactive text-tertiary","outline-none w-1/2 py-2 flex items-center justify-center"])},o(s.__("Flat")),3),on,e("button",{onClick:n[2]||(n[2]=u=>s.setPercentageType("percentage")),class:L([r.mode==="percentage"?"bg-tab-active":"bg-tab-inactive text-tertiary","outline-none w-1/2 py-2 flex items-center justify-center"])},o(s.__("Percentage")),3)]),e("div",nn,[(i(!0),l(g,null,k(r.keys,(u,y)=>(i(),l("div",{onClick:C=>s.inputValue(u),key:y,class:"text-primary ns-numpad-key info text-xl font-bold border h-24 flex items-center justify-center cursor-pointer"},[u.value!==void 0?(i(),l("span",ln,o(u.value),1)):c("",!0),u.icon?(i(),l("i",{key:1,class:L(["las",u.icon])},null,2)):c("",!0)],8,rn))),128))])])}const qn=O(Ko,[["render",cn]]),un={data(){return{types:[],settingsSubscription:null,urls:{}}},props:["popup"],mounted(){this.settingsSubscription=POS.settings.subscribe(t=>{this.urls=t.urls}),this.types=POS.types.getValue(),Object.values(this.types).length===1&&this.select(Object.keys(this.types)[0]),this.popupCloser()},methods:{__:h,popupCloser:T,popupResolver:j,resolveIfQueued:j,async select(t){Object.values(this.types).forEach(a=>a.selected=!1),this.types[t].selected=!0;const n=this.types[t];try{const a=await POS.triggerOrderTypeSelection(n);POS.types.next(this.types),this.resolveIfQueued(n)}catch(a){throw a}}}},an={id:"ns-order-type",class:"h-full w-4/5-screen md:w-2/5-screen lg:w-2/5-screen xl:w-2/6-screen shadow-lg"},dn={id:"header",class:"h-16 flex justify-center items-center"},_n={class:"font-bold"},pn={key:0,class:"ns-box-body grid grid-flow-row grid-cols-1 grid-rows-1"},hn={class:"h-full w-full flex items-center justify-center flex-col"},fn=e("i",{class:"las la-frown text-7xl text-error-tertiary"},null,-1),mn={class:"p-4 md:w-2/3"},bn={class:"text-center"},yn={class:"flex justify-center mt-4 mb-2 -mx-2"},xn={class:"px-2"},vn={class:"px-2"},gn={key:1,class:"ns-box-body grid grid-flow-row grid-cols-2 grid-rows-2"},wn=["onClick"],Cn=["src"],kn={class:"font-semibold text-xl my-2"};function Pn(t,n,a,b,r,s){const x=m("ns-link");return i(),l("div",an,[e("div",dn,[e("h3",_n,o(s.__("Define The Order Type")),1)]),Object.values(r.types).length===0?(i(),l("div",pn,[e("div",hn,[fn,e("div",mn,[e("p",bn,o(s.__("No payment type has been selected on the settings. Please check your POS features and choose the supported order type")),1),e("div",yn,[e("div",xn,[p(x,{target:"_blank",type:"info",href:"https://my.nexopos.com/en/documentation/components/order-types"},{default:f(()=>[w(o(s.__("Read More")),1)]),_:1})]),e("div",vn,[p(x,{target:"_blank",type:"info",href:r.urls.order_type_url},{default:f(()=>[w(o(s.__("Configure")),1)]),_:1},8,["href"])])])])])])):c("",!0),Object.values(r.types).length>0?(i(),l("div",gn,[(i(!0),l(g,null,k(r.types,u=>(i(),l("div",{onClick:y=>s.select(u.identifier),key:u.identifier,class:L([u.selected?"active":"","ns-numpad-key info h-56 flex items-center justify-center flex-col cursor-pointer border"])},[e("img",{src:u.icon,alt:"",class:"w-32 h-32"},null,8,Cn),e("h4",kn,o(u.label),1)],10,wn))),128))])):c("",!0)])}const Rn=O(un,[["render",Pn]]);export{Nn as P,qn as a,Rn as b,ss as c,An as d,U as n}; diff --git a/public/build/assets/ns-pos-shipping-popup-5ba7ac6e.js b/public/build/assets/ns-pos-shipping-popup-5ba7ac6e.js deleted file mode 100644 index afaf5c0e1..000000000 --- a/public/build/assets/ns-pos-shipping-popup-5ba7ac6e.js +++ /dev/null @@ -1 +0,0 @@ -import{F as v,p as x,a as w,b as y}from"./bootstrap-ffaf6d09.js";import{_ as C}from"./_plugin-vue_export-helper-c27b6911.js";import{r as p,o as n,c as l,a as t,t as u,F as h,b,n as f,f as m,w as F,i as S}from"./runtime-core.esm-bundler-414a078a.js";import"./currency-feccde3d.js";import"./chart-2ccf8ff7.js";const k={name:"ns-pos-shipping-popup",props:["popup"],computed:{activeTabFields(){if(this.tabs!==null){for(let s in this.tabs)if(this.tabs[s].active)return this.tabs[s].fields}return[]},useBillingInfo(){return this.tabs!==null?this.tabs.billing.fields[0].value:new Object},useShippingInfo(){return this.tabs!==null?this.tabs.shipping.fields[0].value:new Object}},unmounted(){this.orderSubscription.unsubscribe()},mounted(){this.orderSubscription=POS.order.subscribe(s=>this.order=s),this.popupCloser(),this.loadForm()},data(){return{tabs:null,orderSubscription:null,order:null,formValidation:new v}},watch:{useBillingInfo(s){s===1&&this.tabs.billing.fields.forEach(e=>{e.name!=="_use_customer_billing"&&(e.value=this.order.customer.billing?this.order.customer.billing[e.name]:e.value)})},useShippingInfo(s){s===1&&this.tabs.shipping.fields.forEach(e=>{e.name!=="_use_customer_shipping"&&(e.value=this.order.customer.shipping?this.order.customer.shipping[e.name]:e.value)})}},methods:{__,popupCloser:x,resolveIfQueued:w,submitInformations(){const s=this.formValidation.extractForm({tabs:this.tabs});for(let e in s.general)["shipping","shipping_rate"].includes(e)&&(s.general[e]=parseFloat(s.general[e]));this.order={...this.order,...s.general},delete s.general,delete s.shipping._use_customer_shipping,delete s.billing._use_customer_billing,this.order.addresses=s,POS.order.next(this.order),POS.refreshCart(),this.resolveIfQueued(!0)},closePopup(){this.resolveIfQueued(!1)},toggle(s){for(let e in this.tabs)this.tabs[e].active=!1;this.tabs[s].active=!0},loadForm(){y.get("/api/forms/ns.pos-addresses").subscribe(({tabs:s})=>{for(let e in s)e==="general"?s[e].fields.forEach(o=>{o.value=this.order[o.name]||""}):s[e].fields.forEach(o=>{o.value=this.order.addresses[e]?this.order.addresses[e][o.name]:""});this.tabs=this.formValidation.initializeTabs(s)})}}},V={class:"ns-box w-6/7-screen md:w-4/5-screen lg:w-3/5-screen h-6/7-screen md:h-4/5-screen shadow-lg flex flex-col overflow-hidden"},I={class:"p-2 border-b ns-box-header flex justify-between items-center"},B={class:"font-bold text-primary"},P={class:"tools"},j=t("i",{class:"las la-times"},null,-1),E=[j],O={class:"flex-auto ns-box-body p-2 overflow-y-auto ns-tab"},T={id:"tabs-container"},N={class:"header flex",style:{"margin-bottom":"-1px"}},Q=["onClick"],z={class:"border ns-tab-item"},D={class:"px-4"},H={class:"-mx-4 flex flex-wrap"},L={class:"p-2 flex justify-between border-t ns-box-footer"},R=t("div",null,null,-1);function q(s,e,o,A,d,r){const _=p("ns-field"),g=p("ns-button");return n(),l("div",V,[t("div",I,[t("h3",B,u(r.__("Shipping & Billing")),1),t("div",P,[t("button",{onClick:e[0]||(e[0]=i=>r.closePopup()),class:"ns-close-button rounded-full h-8 w-8 border items-center justify-center"},E)])]),t("div",O,[t("div",T,[t("div",N,[(n(!0),l(h,null,b(d.tabs,(i,a)=>(n(),l("div",{key:a,onClick:c=>r.toggle(a),class:f([i.active?"border-b-0 active":"inactive","tab rounded-tl rounded-tr border tab px-3 py-2 text-primary cursor-pointer"]),style:{"margin-right":"-1px"}},u(i.label),11,Q))),128))]),t("div",z,[t("div",D,[t("div",H,[(n(!0),l(h,null,b(r.activeTabFields,(i,a)=>(n(),l("div",{key:a,class:f("p-4 w-full md:w-1/2 lg:w-1/3")},[m(_,{onBlur:c=>d.formValidation.checkField(i),onChange:c=>d.formValidation.checkField(i),field:i},null,8,["onBlur","onChange","field"])]))),128))])])])])]),t("div",L,[R,t("div",null,[m(g,{onClick:e[1]||(e[1]=i=>r.submitInformations()),type:"info"},{default:F(()=>[S(u(r.__("Save")),1)]),_:1})])])])}const W=C(k,[["render",q]]);export{W as default}; diff --git a/public/build/assets/ns-pos-shipping-popup-dffc98ef.js b/public/build/assets/ns-pos-shipping-popup-dffc98ef.js new file mode 100644 index 000000000..91d797b2f --- /dev/null +++ b/public/build/assets/ns-pos-shipping-popup-dffc98ef.js @@ -0,0 +1 @@ +import{p as O,d as w,P,F as H,b as S,a as T,v as I,w as Q}from"./bootstrap-ffaf6d09.js";import{_ as h,n as q}from"./currency-feccde3d.js";import{a as z,k as B,j as E,l as M,n as R}from"./ns-prompt-popup-24cc8d6f.js";import{_ as V}from"./_plugin-vue_export-helper-c27b6911.js";import{r as m,o as i,c as l,f as p,e as u,a as e,t as n,g as N,F as v,b as k,w as b,i as C,h as K,B as D,n as L}from"./runtime-core.esm-bundler-414a078a.js";import{n as G}from"./ns-orders-preview-popup-3c654295.js";const Y={name:"ns-pos-quantity-popup",props:["popup"],components:{nsNumpad:z,nsNumpadPlus:B},data(){return{finalValue:1,virtualStock:null,options:{},optionsSubscription:null,allSelected:!0,isLoading:!1}},beforeDestroy(){this.optionsSubscription.unsubscribe()},mounted(){this.optionsSubscription=POS.options.subscribe(s=>{this.options=s}),this.popup.params.product.quantity&&(this.finalValue=this.popup.params.product.quantity),this.popupCloser()},unmounted(){nsHotPress.destroy("pos-quantity-numpad"),nsHotPress.destroy("pos-quantity-backspace"),nsHotPress.destroy("pos-quantity-enter")},methods:{__:h,popupCloser:O,closePopup(){this.popup.params.reject(!1),this.popup.close()},updateQuantity(s){this.finalValue=s},defineQuantity(s){const{product:o,data:a}=this.popup.params;if(s===0)return w.error(h("Please provide a quantity")).subscribe();if(o.$original().stock_management==="enabled"&&o.$original().type==="materialized"){const y=POS.getStockUsage(o.$original().id,a.unit_quantity_id)-(o.quantity||0);if(s>parseFloat(a.$quantities().quantity)-y)return w.error(h("Unable to add the product, there is not enough stock. Remaining %s").replace("%s",a.$quantities().quantity-y)).subscribe()}this.resolve({quantity:s})},resolve(s){this.popup.params.resolve(s),this.popup.close()}}},J={class:"ns-box shadow min-h-2/5-screen w-3/4-screen md:w-3/5-screen lg:w-2/5-screen xl:w-2/5-screen relative"},X={key:0,id:"loading-overlay",style:{background:"rgb(202 202 202 / 49%)"},class:"flex w-full h-full absolute top-O left-0 items-center justify-center"},Z={class:"flex-shrink-0 flex justify-between items-center p-2 border-b ns-box-header"},$={class:"text-xl font-bold text-primary text-center"},ee={id:"screen",class:"h-24 primary ns-box-body flex items-center justify-center"},se={class:"font-bold text-3xl"};function te(s,o,a,y,r,t){const x=m("ns-spinner"),c=m("ns-close-button"),f=m("ns-numpad"),g=m("ns-numpad-plus");return i(),l("div",J,[r.isLoading?(i(),l("div",X,[p(x)])):u("",!0),e("div",Z,[e("div",null,[e("h1",$,n(t.__("Define Quantity")),1)]),e("div",null,[p(c,{onClick:o[0]||(o[0]=d=>t.closePopup())})])]),e("div",ee,[e("h1",se,n(r.finalValue),1)]),r.options.ns_pos_numpad==="default"?(i(),N(f,{key:1,floating:r.options.ns_pos_allow_decimal_quantities,onChanged:o[1]||(o[1]=d=>t.updateQuantity(d)),onNext:o[2]||(o[2]=d=>t.defineQuantity(d)),value:r.finalValue},null,8,["floating","value"])):u("",!0),r.options.ns_pos_numpad==="advanced"?(i(),N(g,{key:2,onChanged:o[3]||(o[3]=d=>t.updateQuantity(d)),onNext:o[4]||(o[4]=d=>t.defineQuantity(d)),value:r.finalValue},null,8,["value"])):u("",!0)])}const oe=V(Y,[["render",te]]);class Yn{constructor(o){this.product=o}run(o){return new Promise((a,y)=>{const r=this.product;if(POS.options.getValue().ns_pos_show_quantity!==!1||!POS.processingAddQueue)P.show(oe,{resolve:a,reject:y,product:r,data:o});else{if(r.$original().stock_management==="enabled"&&r.$original().type==="materialized"){const c=POS.getStockUsage(r.$original().id,o.unit_quantity_id)-(r.quantity||0);if(1>parseFloat(o.$quantities().quantity)-c)return w.error(h("Unable to add the product, there is not enough stock. Remaining %s").replace("%s",(o.$quantities().quantity-c).toString())).subscribe()}a({quantity:1})}})}}const ne={mounted(){this.closeWithOverlayClicked(),this.loadTransactionFields()},props:["popup"],data(){return{fields:[],isSubmiting:!1,formValidation:new H}},methods:{__:h,closeWithOverlayClicked:O,proceed(){const s=this.popup.params.customer,o=this.formValidation.extractFields(this.fields);this.isSubmiting=!0,S.post(`/api/customers/${s.id}/account-history`,o).subscribe({next:a=>{this.isSubmiting=!1,w.success(a.message).subscribe(),this.popup.params.resolve(a),this.popup.close()},error:a=>{this.isSubmiting=!1,w.error(a.message).subscribe(),this.popup.params.reject(a)}})},close(){this.popup.close(),this.popup.params.reject(!1)},loadTransactionFields(){S.get("/api/fields/ns.customers-account").subscribe({next:s=>{this.fields=this.formValidation.createFields(s)}})}}},re={class:"w-6/7-screen md:w-5/7-screen lg:w-4/7-screen h-6/7-screen md:h-5/7-screen lg:h-5/7-screen overflow-hidden shadow-lg ns-box flex flex-col relative"},ie={class:"p-2 border-b ns-box-header flex justify-between items-center"},le={class:"font-semibold"},ce={class:"flex-auto overflow-y-auto"},ue={key:0,class:"h-full w-full flex items-center justify-center"},ae={key:1,class:"p-2"},de={class:"p-2 ns-box-footer justify-between border-t flex"},_e=e("div",null,null,-1),pe={class:"px-1"},he={class:"-mx-2 flex flex-wrap"},fe={class:"px-1"},me={class:"px-1"},be={key:0,class:"h-full w-full absolute flex items-center justify-center",style:{background:"rgb(0 98 171 / 45%)"}};function ye(s,o,a,y,r,t){const x=m("ns-close-button"),c=m("ns-spinner"),f=m("ns-field"),g=m("ns-button");return i(),l("div",re,[e("div",ie,[e("h2",le,n(t.__("New Transaction")),1),e("div",null,[p(x,{onClick:o[0]||(o[0]=d=>t.close())})])]),e("div",ce,[r.fields.length===0?(i(),l("div",ue,[p(c)])):u("",!0),r.fields.length>0?(i(),l("div",ae,[(i(!0),l(v,null,k(r.fields,(d,j)=>(i(),N(f,{field:d,key:j},null,8,["field"]))),128))])):u("",!0)]),e("div",de,[_e,e("div",pe,[e("div",he,[e("div",fe,[p(g,{type:"error",onClick:o[1]||(o[1]=d=>t.close())},{default:b(()=>[C(n(t.__("Close")),1)]),_:1})]),e("div",me,[p(g,{type:"info",onClick:o[2]||(o[2]=d=>t.proceed())},{default:b(()=>[C(n(t.__("Proceed")),1)]),_:1})])])])]),r.isSubmiting===0?(i(),l("div",be,[p(c)])):u("",!0)])}const xe=V(ne,[["render",ye]]),ve={name:"ns-pos-coupons-load-popup",props:["popup"],components:{nsNotice:E},data(){return{placeHolder:h("Coupon Code"),couponCode:null,order:null,activeTab:"apply-coupon",orderSubscriber:null,coupon:null}},mounted(){this.popupCloser(),this.orderSubscriber=POS.order.subscribe(s=>{this.order=K(s),this.order.coupons.length>0&&(this.activeTab="active-coupons")}),this.popup.params&&this.popup.params.apply_coupon&&(this.couponCode=this.popup.params.apply_coupon,this.getCoupon(this.couponCode).subscribe({next:s=>{this.coupon=s,this.apply()}}))},unmounted(){this.orderSubscriber.unsubscribe()},methods:{__:h,popupCloser:O,popupResolver:T,selectCustomer(){Popup.show(U)},cancel(){this.coupon=null,this.couponCode=null},removeCoupon(s){this.order.coupons.splice(s,1),POS.refreshCart()},apply(){try{if(this.coupon.valid_hours_start!==null&&!ns.date.moment.isAfter(this.coupon.valid_hours_start)&&this.coupon.valid_hours_start.length>0)return w.error(h("The coupon is out from validity date range.")).subscribe();if(this.coupon.valid_hours_end!==null&&!ns.date.moment.isBefore(this.coupon.valid_hours_end)&&this.coupon.valid_hours_end.length>0)return w.error(h("The coupon is out from validity date range.")).subscribe();const s=this.coupon.products;if(s.length>0){const y=s.map(r=>r.product_id);if(this.order.products.filter(r=>y.includes(r.product_id)).length===0)return w.error(h("This coupon requires products that aren't available on the cart at the moment.")).subscribe()}const o=this.coupon.categories;if(o.length>0){const y=o.map(r=>r.category_id);if(this.order.products.filter(r=>y.includes(r.$original().category_id)).length===0)return w.error(h("This coupon requires products that belongs to specific categories that aren't included at the moment.").replace("%s")).subscribe()}let a={customer_coupon_id:this.coupon.customer_coupon.length>0?this.coupon.customer_coupon[0].id:0,minimum_cart_value:this.coupon.minimum_cart_value,maximum_cart_value:this.coupon.maximum_cart_value,name:this.coupon.name,type:this.coupon.type,value:0,coupon_id:this.coupon.id,limit_usage:this.coupon.limit_usage,code:this.coupon.code,discount_value:this.coupon.discount_value,categories:this.coupon.categories,products:this.coupon.products};this.cancel(),POS.pushCoupon(a),this.activeTab="active-coupons",setTimeout(()=>{this.popupResolver(a)},500),w.success(h("The coupon has applied to the cart.")).subscribe()}catch(s){console.log(s)}},getCouponType(s){switch(s){case"percentage_discount":return h("Percentage");case"flat_discount":return h("Flat");default:return h("Unknown Type")}},getDiscountValue(s){switch(s.type){case"percentage_discount":return s.discount_value+"%";case"flat_discount":return this.$options.filters.currency(s.discount_value)}},closePopup(){this.popupResolver(!1)},setActiveTab(s){this.activeTab=s,s==="apply-coupon"&&setTimeout(()=>{document.querySelector(".coupon-field").select()},10)},getCoupon(s){return!this.order.customer_id>0?w.error(h("You must select a customer before applying a coupon.")):S.post(`/api/customers/coupons/${s}`,{customer_id:this.order.customer_id})},loadCoupon(){const s=this.couponCode;this.getCoupon(s).subscribe({next:o=>{this.coupon=o,w.success(h("The coupon has been loaded.")).subscribe()},error:o=>{w.error(o.message||h("An unexpected error occurred.")).subscribe()}})}}},ge={class:"shadow-lg ns-box w-95vw md:w-3/6-screen lg:w-2/6-screen"},we={class:"border-b ns-box-header p-2 flex justify-between items-center"},Ce={class:"font-bold"},ke={class:"p-1 ns-box-body"},Se={class:"border-2 input-group info rounded flex"},Pe=["placeholder"],Oe={class:"pt-2"},Ve={key:0,class:"pt-2 flex"},Te={key:1,class:"pt-2"},je={class:"overflow-hidden"},Le={key:0,class:"pt-2 fade-in-entrance anim-duration-500 overflow-y-auto ns-scrollbar h-64"},Ne={class:"w-full ns-table"},Fe={class:"p-2 w-1/2 border"},Ae={class:"p-2 w-1/2 border"},qe={class:"p-2 w-1/2 border"},Re={class:"p-2 w-1/2 border"},He={class:"p-2 w-1/2 border"},Ie={class:"p-2 w-1/2 border"},Qe={class:"p-2 w-1/2 border"},De={class:"p-2 w-1/2 border"},Ue={class:"p-2 w-1/2 border"},We={class:"p-2 w-1/2 border"},ze={class:"p-2 w-1/2 border"},Be={class:"p-2 w-1/2 border"},Ee={key:0},Me={class:"p-2 w-1/2 border"},Ke={class:"p-2 w-1/2 border"},Ge={key:0},Ye={key:0},Je={class:"flex-auto"},Xe={class:"font-semibold text-primary p-2 flex justify-between"},Ze={key:0,class:"flex justify-between elevation-surface border items-center p-2"},$e={key:0,class:"flex"};function es(s,o,a,y,r,t){const x=m("ns-close-button"),c=m("ns-notice"),f=m("ns-tabs-item"),g=m("ns-tabs");return i(),l("div",ge,[e("div",we,[e("h3",Ce,n(t.__("Load Coupon")),1),e("div",null,[p(x,{onClick:o[0]||(o[0]=d=>t.closePopup())})])]),e("div",ke,[p(g,{onActive:o[5]||(o[5]=d=>t.setActiveTab(d)),active:r.activeTab},{default:b(()=>[p(f,{label:t.__("Apply A Coupon"),padding:"p-2",identifier:"apply-coupon"},{default:b(()=>[e("div",Se,[D(e("input",{ref:"coupon",onKeyup:o[1]||(o[1]=Q(d=>t.loadCoupon(),["enter"])),"onUpdate:modelValue":o[2]||(o[2]=d=>r.couponCode=d),type:"text",class:"coupon-field w-full text-primary p-2 outline-none",placeholder:r.placeHolder},null,40,Pe),[[I,r.couponCode]]),e("button",{onClick:o[3]||(o[3]=d=>t.loadCoupon()),class:"px-3 py-2"},n(t.__("Load")),1)]),e("div",Oe,[p(c,{color:"info"},{description:b(()=>[C(n(t.__("Input the coupon code that should apply to the POS. If a coupon is issued for a customer, that customer must be selected priorly.")),1)]),_:1})]),r.order&&r.order.customer_id===void 0?(i(),l("div",Ve,[e("button",{onClick:o[4]||(o[4]=d=>t.selectCustomer()),class:"w-full border p-2 outline-none ns-numpad-key info cursor-pointer text-center"},n(t.__("Click here to choose a customer.")),1)])):u("",!0),r.order&&r.order.customer_id!==void 0?(i(),l("div",Te,[p(c,{color:"success"},{description:b(()=>[C(n(t.__("Loading Coupon For : ")+`${r.order.customer.first_name} ${r.order.customer.last_name}`),1)]),_:1})])):u("",!0),e("div",je,[r.coupon?(i(),l("div",Le,[e("table",Ne,[e("tbody",null,[e("tr",null,[e("td",Fe,n(t.__("Coupon Name")),1),e("td",Ae,n(r.coupon.name),1)]),e("tr",null,[e("td",qe,n(t.__("Discount"))+" ("+n(t.getCouponType(r.coupon.type))+")",1),e("td",Re,n(t.getDiscountValue(r.coupon)),1)]),e("tr",null,[e("td",He,n(t.__("Usage")),1),e("td",Ie,n((r.coupon.customer_coupon.length>0?r.coupon.customer_coupon[0].usage:0)+"/"+(r.coupon.limit_usage||t.__("Unlimited"))),1)]),e("tr",null,[e("td",Qe,n(t.__("Valid From")),1),e("td",De,n(r.coupon.valid_hours_start||t.__("N/A")),1)]),e("tr",null,[e("td",Ue,n(t.__("Valid Till")),1),e("td",We,n(r.coupon.valid_hours_end||t.__("N/A")),1)]),e("tr",null,[e("td",ze,n(t.__("Categories")),1),e("td",Be,[e("ul",null,[(i(!0),l(v,null,k(r.coupon.categories,d=>(i(),l("li",{class:"rounded-full px-3 py-1 border",key:d.id},n(d.category.name),1))),128)),r.coupon.categories.length===0?(i(),l("li",Ee,n(t.__("Not applicable")),1)):u("",!0)])])]),e("tr",null,[e("td",Me,n(t.__("Products")),1),e("td",Ke,[e("ul",null,[(i(!0),l(v,null,k(r.coupon.products,d=>(i(),l("li",{class:"rounded-full px-3 py-1 border",key:d.id},n(d.product.name),1))),128)),r.coupon.products.length===0?(i(),l("li",Ge,n(t.__("Not applicable")),1)):u("",!0)])])])])])])):u("",!0)])]),_:1},8,["label"]),p(f,{label:t.__("Active Coupons"),padding:"p-1",identifier:"active-coupons"},{default:b(()=>[r.order?(i(),l("ul",Ye,[(i(!0),l(v,null,k(r.order.coupons,(d,j)=>(i(),l("li",{key:j,class:"flex justify-between elevation-surface border items-center px-2 py-1"},[e("div",Je,[e("h3",Xe,[e("span",null,n(d.name),1),e("span",null,n(t.getDiscountValue(d)),1)])]),e("div",null,[p(x,{onClick:F=>t.removeCoupon(j)},null,8,["onClick"])])]))),128)),r.order.coupons.length===0?(i(),l("li",Ze,n(t.__("No coupons applies to the cart.")),1)):u("",!0)])):u("",!0)]),_:1},8,["label"])]),_:1},8,["active"])]),r.coupon?(i(),l("div",$e,[e("button",{onClick:o[6]||(o[6]=d=>t.apply()),class:"w-1/2 px-3 py-2 bg-success-tertiary text-white font-bold"},n(t.__("Apply")),1),e("button",{onClick:o[7]||(o[7]=d=>t.cancel()),class:"w-1/2 px-3 py-2 bg-error-tertiary text-white font-bold"},n(t.__("Cancel")),1)])):u("",!0)])}const ss=V(ve,[["render",es]]),ts={name:"ns-pos-customers",props:["popup"],data(){return{activeTab:"create-customers",customer:null,subscription:null,orders:[],options:{},optionsSubscriber:null,selectedTab:"orders",isLoadingCoupons:!1,isLoadingRewards:!1,isLoadingHistory:!1,isLoadingOrders:!1,coupons:[],userCan:s=>POS.userCan(s),rewardsResponse:[],order:null,walletHistories:[]}},components:{nsPaginate:M},unmounted(){this.subscription.unsubscribe(),this.optionsSubscriber.unsubscribe()},mounted(){this.closeWithOverlayClicked(),this.optionsSubscriber=POS.options.subscribe(s=>{this.options=s}),this.subscription=POS.order.subscribe(s=>{this.order=s,this.popup.params.customer!==void 0?(this.activeTab="account-payment",this.customer=this.popup.params.customer,this.loadCustomerOrders()):s.customer!==void 0&&(this.activeTab="account-payment",this.customer=s.customer,this.loadCustomerOrders())}),this.popupCloser()},methods:{__:h,nsCurrency:q,reload(){this.loadCustomerOrders()},popupResolver:T,popupCloser:O,getWalletHistoryLabel(s){switch(s){case"add":return h("Crediting");case"deduct":return h("Removing");case"refund":return h("Refunding");case"payment":return h("Payment");default:return h("Unknow")}},getType(s){switch(s){case"percentage_discount":return h("Percentage Discount");case"flat_discount":return h("Flat Discount")}},closeWithOverlayClicked:O,async openOrderOptions(s){try{const o=await new Promise((a,y)=>{P.show(G,{order:s,resolve:a,reject:y})});this.reload()}catch{w.error(h("An error occurred while opening the order options")).subscribe()}},doChangeTab(s){this.selectedTab=s,s==="coupons"&&this.loadCoupons(),s==="rewards"&&this.loadRewards(),s==="wallet-history"&&this.loadAccounHistory(),s==="orders"&&this.loadCustomerOrders()},loadAccounHistory(){this.isLoadingHistory=!0,S.get(`/api/customers/${this.customer.id}/account-history`).subscribe({next:s=>{this.walletHistories=s.data,this.isLoadingHistory=!1},error:s=>{this.isLoadingHistory=!1}})},loadCoupons(){this.isLoadingCoupons=!0,S.get(`/api/customers/${this.customer.id}/coupons`).subscribe({next:s=>{this.coupons=s,this.isLoadingCoupons=!1},error:s=>{this.isLoadingCoupons=!1}})},loadRewards(s=`/api/customers/${this.customer.id}/rewards`){this.isLoadingRewards=!0,S.get(s).subscribe({next:o=>{this.rewardsResponse=o,this.isLoadingRewards=!1},error:o=>{this.isLoadingRewards=!1}})},prefillForm(s){this.popup.params.name!==void 0&&(s.main.value=this.popup.params.name)},openCustomerSelection(){this.popup.close(s=>{P.show(U)})},loadCustomerOrders(){this.isLoadingOrders=!0,S.get(`/api/customers/${this.customer.id}/orders`).subscribe({next:s=>{this.orders=s,this.isLoadingOrders=!1},error:s=>{this.isLoadingOrders=!1}})},newTransaction(s){new Promise((a,y)=>{P.show(xe,{customer:s,resolve:a,reject:y})}).then(a=>{POS.loadCustomer(s.id).subscribe(y=>{POS.selectCustomer(y)})})},applyCoupon(s){this.order.customer===void 0?P.show(R,{title:h("Use Customer ?"),message:h("No customer is selected. Would you like to proceed with this customer ?"),onAction:o=>{o&&POS.selectCustomer(this.customer).then(a=>{this.proceedApplyingCoupon(s)})}}):this.order.customer.id===this.customer.id?this.proceedApplyingCoupon(s):this.order.customer.id!==this.customer.id&&P.show(R,{title:h("Change Customer ?"),message:h("Would you like to assign this customer to the ongoing order ?"),onAction:o=>{o&&POS.selectCustomer(this.customer).then(a=>{this.proceedApplyingCoupon(s)})}})},proceedApplyingCoupon(s){new Promise((o,a)=>{P.show(ss,{apply_coupon:s.code,resolve:o,reject:a})}).then(o=>{this.popupResolver(!1)}).catch(o=>{})},handleSavedCustomer(s){w.success(s.message).subscribe(),POS.selectCustomer(s.data.entry),this.popup.close()}}},os={id:"ns-pos-customers",class:"shadow-lg rounded w-95vw h-95vh lg:w-3/5-screen flex flex-col overflow-hidden"},rs={class:"ns-header p-2 flex justify-between items-center border-b"},is={class:"font-semibold"},ls={class:"ns-body flex-auto flex p-2 overflow-y-auto"},cs={key:1,class:"h-full flex-col w-full flex items-center justify-center text-primary"},us=e("i",{class:"lar la-hand-paper ns-icon text-6xl"},null,-1),as={class:"font-medium text-2xl"},ds={key:0,class:"flex-auto w-full flex items-center justify-center flex-col p-4"},_s=e("i",{class:"lar la-frown text-6xl"},null,-1),ps={class:"font-medium text-2xl"},hs={class:"my-2"},fs={key:1,class:"flex flex-col flex-auto"},ms={class:"flex-auto p-2 flex flex-col"},bs={class:"flex flex-wrap"},ys={class:"px-4 mb-4 w-full"},xs={class:"font-semibold"},vs={class:"flex flex-wrap ns-tab-cards -mx-2 w-full"},gs={class:"px-2 mb-4 w-full md:w-1/4 flex"},ws={class:"rounded-lg shadow w-full bg-transparent bg-gradient-to-br from-success-secondary to-green-700 p-2 flex flex-col text-white"},Cs={class:"font-medium text-lg"},ks={class:"w-full flex justify-end"},Ss={class:"font-bold"},Ps={class:"px-2 mb-4 w-full md:w-1/4 flex"},Os={class:"rounded-lg shadow w-full bg-transparent bg-gradient-to-br from-error-secondary to-red-700 p-2 text-white"},Vs={class:"font-medium text-lg"},Ts={class:"w-full flex justify-end"},js={class:"font-bold"},Ls={class:"px-2 mb-4 w-full md:w-1/4 flex"},Ns={class:"rounded-lg shadow w-full bg-transparent bg-gradient-to-br from-blue-500 to-blue-700 p-2 text-white"},Fs={class:"font-medium text-lg"},As={class:"w-full flex justify-end"},qs={class:"font-bold"},Rs={class:"px-2 mb-4 w-full md:w-1/4 flex"},Hs={class:"rounded-lg shadow w-full bg-transparent bg-gradient-to-br from-teal-500 to-teal-700 p-2 text-white"},Is={class:"font-medium text-lg"},Qs={class:"w-full flex justify-end"},Ds={class:"font-bold"},Us={class:"flex flex-auto flex-col overflow-hidden"},Ws={key:0,class:"flex-auto h-full justify-center flex items-center"},zs={class:"py-2 w-full"},Bs={class:"font-semibold text-primary"},Es={class:"flex-auto flex-col flex overflow-hidden"},Ms={class:"flex-auto overflow-y-auto"},Ks={class:"table ns-table w-full"},Gs={class:"text-primary"},Ys={colspan:"3",width:"150",class:"p-2 border font-semibold"},Js={width:"50",class:"p-2 border font-semibold"},Xs={class:"text-primary"},Zs={key:0},$s={class:"border p-2 text-center",colspan:"4"},et={colspan:"3",class:"border p-2 text-center"},st={class:"flex flex-col items-start"},tt={class:"font-bold"},ot={class:"md:-mx-2 w-full flex flex-col md:flex-row"},nt={class:"md:px-2 flex items-start w-full md:w-1/4"},rt={class:"md:px-2 flex items-start w-full md:w-1/4"},it={class:"md:px-2 flex items-start w-full md:w-1/4"},lt={class:"border p-2 text-center"},ct=["onClick"],ut=e("i",{class:"las la-wallet"},null,-1),at={class:"ml-1"},dt={key:0,class:"flex-auto h-full justify-center flex items-center"},_t={class:"py-2 w-full"},pt={class:"font-semibold text-primary"},ht={class:"flex-auto flex-col flex overflow-hidden"},ft={class:"flex-auto overflow-y-auto"},mt={class:"table ns-table w-full"},bt={class:"text-primary"},yt={colspan:"3",width:"150",class:"p-2 border font-semibold"},xt={class:"text-primary"},vt={key:0},gt={class:"border p-2 text-center",colspan:"3"},wt={colspan:"3",class:"border p-2 text-center"},Ct={class:"flex flex-col items-start"},kt={class:"font-bold"},St={class:"md:-mx-2 w-full flex flex-col md:flex-row"},Pt={class:"md:px-2 flex items-start w-full md:w-1/3"},Ot={class:"md:px-2 flex items-start w-full md:w-1/3"},Vt={key:0,class:"flex-auto h-full justify-center flex items-center"},Tt={class:"py-2 w-full"},jt={class:"font-semibold text-primary"},Lt={class:"flex-auto flex-col flex overflow-hidden"},Nt={class:"flex-auto overflow-y-auto"},Ft={class:"table ns-table w-full"},At={class:"text-primary"},qt={width:"150",class:"p-2 border font-semibold"},Rt={class:"p-2 border font-semibold"},Ht=e("th",{class:"p-2 border font-semibold"},null,-1),It={class:"text-primary text-sm"},Qt={key:0},Dt={class:"border p-2 text-center",colspan:"4"},Ut={width:"300",class:"border p-2"},Wt={class:""},zt={class:"-mx-2 flex"},Bt={class:"text-xs text-primary px-2"},Et={class:"text-xs text-primary px-2"},Mt={class:"border p-2 text-center"},Kt={key:0},Gt={key:1},Yt={class:"border p-2 text-right"},Jt={key:0,class:"flex-auto h-full justify-center flex items-center"},Xt={class:"py-2 w-full"},Zt={class:"font-semibold text-primary"},$t={class:"flex-auto flex-col flex overflow-hidden"},eo={class:"flex-auto overflow-y-auto"},so={class:"table ns-table w-full"},to={class:"text-primary"},oo={width:"150",class:"p-2 border font-semibold"},no={class:"p-2 border font-semibold"},ro={class:"p-2 border font-semibold"},io={key:0,class:"text-primary text-sm"},lo={key:0},co={class:"border p-2 text-center",colspan:"4"},uo={width:"300",class:"border p-2"},ao={class:"text-center"},_o={width:"300",class:"border p-2"},po={class:"text-center"},ho={width:"300",class:"border p-2"},fo={class:"text-center"},mo={class:"py-1 flex justify-end"},bo={class:"p-2 border-t border-box-edge flex justify-between"},yo=e("div",null,null,-1);function xo(s,o,a,y,r,t){const x=m("ns-close-button"),c=m("ns-crud-form"),f=m("ns-tabs-item"),g=m("ns-button"),d=m("ns-spinner"),j=m("ns-paginate"),F=m("ns-tabs");return i(),l("div",os,[e("div",rs,[e("h3",is,n(t.__("Customers")),1),e("div",null,[p(x,{onClick:o[0]||(o[0]=_=>a.popup.close())})])]),e("div",ls,[p(F,{active:r.activeTab,onActive:o[7]||(o[7]=_=>r.activeTab=_)},{default:b(()=>[p(f,{identifier:"create-customers",label:t.__("New Customer")},{default:b(()=>[r.userCan("nexopos.create.customers")?(i(),N(c,{key:0,onUpdated:o[1]||(o[1]=_=>t.prefillForm(_)),onSave:o[2]||(o[2]=_=>t.handleSavedCustomer(_)),"submit-url":"/api/crud/ns.customers",src:"/api/crud/ns.customers/form-config"},{title:b(()=>[C(n(t.__("Customer Name")),1)]),save:b(()=>[C(n(t.__("Save Customer")),1)]),_:1})):u("",!0),r.userCan("nexopos.create.customers")?u("",!0):(i(),l("div",cs,[us,e("h3",as,n(t.__("Not Authorized")),1),e("p",null,n(t.__("Creating customers has been explicitly disabled from the settings.")),1)]))]),_:1},8,["label"]),p(f,{identifier:"account-payment",label:t.__("Customer Account"),class:"flex",padding:"p-0 flex"},{default:b(()=>[r.customer===null?(i(),l("div",ds,[_s,e("h3",ps,n(t.__("No Customer Selected")),1),e("p",null,n(t.__("In order to see a customer account, you need to select one customer.")),1),e("div",hs,[p(g,{onClick:o[3]||(o[3]=_=>t.openCustomerSelection()),type:"info"},{default:b(()=>[C(n(t.__("Select Customer")),1)]),_:1})])])):u("",!0),r.customer?(i(),l("div",fs,[e("div",ms,[e("div",bs,[e("div",ys,[e("h2",xs,n(t.__("Summary For"))+" : "+n(r.customer.first_name),1)]),e("div",vs,[e("div",gs,[e("div",ws,[e("h3",Cs,n(t.__("Purchases")),1),e("div",ks,[e("h2",Ss,n(t.nsCurrency(r.customer.purchases_amount)),1)])])]),e("div",Ps,[e("div",Os,[e("h3",Vs,n(t.__("Owed")),1),e("div",Ts,[e("h2",js,n(t.nsCurrency(r.customer.owed_amount)),1)])])]),e("div",Ls,[e("div",Ns,[e("h3",Fs,n(t.__("Wallet Amount")),1),e("div",As,[e("h2",qs,n(t.nsCurrency(r.customer.account_amount)),1)])])]),e("div",Rs,[e("div",Hs,[e("h3",Is,n(t.__("Credit Limit")),1),e("div",Qs,[e("h2",Ds,n(t.nsCurrency(r.customer.credit_limit_amount)),1)])])])])]),e("div",Us,[p(F,{active:r.selectedTab,onChangeTab:o[5]||(o[5]=_=>t.doChangeTab(_))},{default:b(()=>[p(f,{identifier:"orders",label:t.__("Orders")},{default:b(()=>[r.isLoadingOrders?(i(),l("div",Ws,[p(d,{size:"36"})])):u("",!0),r.isLoadingOrders?u("",!0):(i(),l(v,{key:1},[e("div",zs,[e("h2",Bs,n(t.__("Last Purchases")),1)]),e("div",Es,[e("div",Ms,[e("table",Ks,[e("thead",null,[e("tr",Gs,[e("th",Ys,n(t.__("Order")),1),e("th",Js,n(t.__("Options")),1)])]),e("tbody",Xs,[r.orders.length===0?(i(),l("tr",Zs,[e("td",$s,n(t.__("No orders...")),1)])):u("",!0),(i(!0),l(v,null,k(r.orders,_=>(i(),l("tr",{key:_.id},[e("td",et,[e("div",st,[e("h3",tt,n(t.__("Code"))+": "+n(_.code),1),e("div",ot,[e("div",nt,[e("small",null,n(t.__("Total"))+": "+n(t.nsCurrency(_.total)),1)]),e("div",rt,[e("small",null,n(t.__("Status"))+": "+n(_.human_status),1)]),e("div",it,[e("small",null,n(t.__("Delivery"))+": "+n(_.human_delivery_status),1)])])])]),e("td",lt,[e("button",{onClick:W=>t.openOrderOptions(_),class:"rounded-full h-8 px-2 flex items-center justify-center border border-gray ns-inset-button success"},[ut,e("span",at,n(t.__("Options")),1)],8,ct)])]))),128))])])])])],64))]),_:1},8,["label"]),p(f,{identifier:"wallet-history",label:t.__("Wallet History")},{default:b(()=>[r.isLoadingHistory?(i(),l("div",dt,[p(d,{size:"36"})])):u("",!0),r.isLoadingHistory?u("",!0):(i(),l(v,{key:1},[e("div",_t,[e("h2",pt,n(t.__("Wallet History")),1)]),e("div",ht,[e("div",ft,[e("table",mt,[e("thead",null,[e("tr",bt,[e("th",yt,n(t.__("Transaction")),1)])]),e("tbody",xt,[r.walletHistories.length===0?(i(),l("tr",vt,[e("td",gt,n(t.__("No History...")),1)])):u("",!0),(i(!0),l(v,null,k(r.walletHistories,_=>(i(),l("tr",{key:_.id},[e("td",wt,[e("div",Ct,[e("h3",kt,n(t.__("Transaction"))+": "+n(t.getWalletHistoryLabel(_.operation)),1),e("div",St,[e("div",Pt,[e("small",null,n(t.__("Amount"))+": "+n(t.nsCurrency(s.amount)),1)]),e("div",Ot,[e("small",null,n(t.__("Date"))+": "+n(_.created_at),1)])])])])]))),128))])])])])],64))]),_:1},8,["label"]),p(f,{identifier:"coupons",label:t.__("Coupons")},{default:b(()=>[r.isLoadingCoupons?(i(),l("div",Vt,[p(d,{size:"36"})])):u("",!0),r.isLoadingCoupons?u("",!0):(i(),l(v,{key:1},[e("div",Tt,[e("h2",jt,n(t.__("Coupons")),1)]),e("div",Lt,[e("div",Nt,[e("table",Ft,[e("thead",null,[e("tr",At,[e("th",qt,n(t.__("Name")),1),e("th",Rt,n(t.__("Type")),1),Ht])]),e("tbody",It,[r.coupons.length===0?(i(),l("tr",Qt,[e("td",Dt,n(t.__("No coupons for the selected customer...")),1)])):u("",!0),(i(!0),l(v,null,k(r.coupons,_=>(i(),l("tr",{key:_.id},[e("td",Ut,[e("h3",null,n(_.name),1),e("div",Wt,[e("ul",zt,[e("li",Bt,n(t.__("Usage :"))+" "+n(_.usage)+"/"+n(_.limit_usage),1),e("li",Et,n(t.__("Code :"))+" "+n(_.code),1)])])]),e("td",Mt,[C(n(t.getType(_.coupon.type))+" ",1),_.coupon.type==="percentage_discount"?(i(),l("span",Kt," ("+n(_.coupon.discount_value)+"%) ",1)):u("",!0),_.coupon.type==="flat_discount"?(i(),l("span",Gt," ("+n(t.nsCurrency(s.value))+") ",1)):u("",!0)]),e("td",Yt,[p(g,{onClick:W=>t.applyCoupon(_),type:"info"},{default:b(()=>[C(n(t.__("Use Coupon")),1)]),_:2},1032,["onClick"])])]))),128))])])])])],64))]),_:1},8,["label"]),p(f,{identifier:"rewards",label:t.__("Rewards")},{default:b(()=>[r.isLoadingRewards?(i(),l("div",Jt,[p(d,{size:"36"})])):u("",!0),r.isLoadingRewards?u("",!0):(i(),l(v,{key:1},[e("div",Xt,[e("h2",Zt,n(t.__("Rewards")),1)]),e("div",$t,[e("div",eo,[e("table",so,[e("thead",null,[e("tr",to,[e("th",oo,n(t.__("Name")),1),e("th",no,n(t.__("Points")),1),e("th",ro,n(t.__("Target")),1)])]),r.rewardsResponse.data?(i(),l("tbody",io,[r.rewardsResponse.data.length===0?(i(),l("tr",lo,[e("td",co,n(t.__("No rewards available the selected customer...")),1)])):u("",!0),(i(!0),l(v,null,k(r.rewardsResponse.data,_=>(i(),l("tr",{key:_.id},[e("td",uo,[e("h3",ao,n(_.reward_name),1)]),e("td",_o,[e("h3",po,n(_.points),1)]),e("td",ho,[e("h3",fo,n(_.target),1)])]))),128))])):u("",!0)])])]),e("div",mo,[p(j,{pagination:r.rewardsResponse,onLoad:o[4]||(o[4]=_=>t.loadRewards(_))},null,8,["pagination"])])],64))]),_:1},8,["label"])]),_:1},8,["active"])])]),e("div",bo,[yo,e("div",null,[p(g,{onClick:o[6]||(o[6]=_=>t.newTransaction(r.customer)),type:"info"},{default:b(()=>[C(n(t.__("Account Transaction")),1)]),_:1})])])])):u("",!0)]),_:1},8,["label"])]),_:1},8,["active"])])])}const A=V(ts,[["render",xo]]),Jn=Object.freeze(Object.defineProperty({__proto__:null,default:A},Symbol.toStringTag,{value:"Module"})),vo={props:["popup"],data(){return{searchCustomerValue:"",orderSubscription:null,order:{},debounceSearch:null,customers:[],isLoading:!1}},computed:{customerSelected(){return!1}},watch:{searchCustomerValue(s){clearTimeout(this.debounceSearch),this.debounceSearch=setTimeout(()=>{this.searchCustomer(s)},500)}},mounted(){this.orderSubscription=POS.order.subscribe(s=>{this.order=s}),this.getRecentCustomers(),this.$refs.searchField.focus(),this.popupCloser()},unmounted(){this.orderSubscription.unsubscribe()},methods:{__:h,popupCloser:O,nsCurrency:q,resolveIfQueued:T,attemptToChoose(){if(this.customers.length===1)return this.selectCustomer(this.customers[0]);w.info(h("Too many results.")).subscribe()},openCustomerHistory(s,o){o.stopImmediatePropagation(),this.popup.close(),P.show(A,{customer:s,activeTab:"account-payment"})},selectCustomer(s){this.customers.forEach(o=>o.selected=!1),s.selected=!0,this.isLoading=!0,POS.selectCustomer(s).then(o=>{this.isLoading=!1,this.resolveIfQueued(s)}).catch(o=>{this.isLoading=!1})},searchCustomer(s){S.post("/api/customers/search",{search:s}).subscribe(o=>{o.forEach(a=>a.selected=!1),this.customers=o})},createCustomerWithMatch(s){this.resolveIfQueued(!1),P.show(A,{name:s})},getRecentCustomers(){this.isLoading=!0,S.get("/api/customers/recently-active").subscribe({next:s=>{this.isLoading=!1,s.forEach(o=>o.selected=!1),this.customers=s},error:s=>{this.isLoading=!1}})}}},go={id:"ns-pos-customer-select-popup",class:"ns-box shadow-xl w-4/5-screen md:w-2/5-screen xl:w-108"},wo={id:"header",class:"border-b ns-box-header text-center font-semibold text-2xl py-2"},Co={class:"relative"},ko={class:"p-2 border-b ns-box-body items-center flex justify-between"},So={class:"flex items-center justify-between"},Po=e("i",{class:"las la-eye"},null,-1),Oo=[Po],Vo={class:"p-2 border-b ns-box-body flex justify-between text-primary"},To={class:"input-group flex-auto border-2 rounded"},jo={class:"h-3/5-screen xl:h-2/5-screen overflow-y-auto ns-scrollbar"},Lo={class:"ns-vertical-menu"},No={key:0,class:"p-2 text-center text-primary"},Fo={class:"border-b border-dashed border-info-primary"},Ao=["onClick"],qo={class:"flex flex-col"},Ro={key:0,class:"text-xs text-secondary"},Ho={key:1,class:"text-xs text-secondary"},Io={class:"flex items-center"},Qo={key:0,class:"text-error-primary"},Do={key:1},Uo={class:"purchase-amount"},Wo=["onClick"],zo=e("i",{class:"las la-eye"},null,-1),Bo=[zo],Eo={key:0,class:"z-10 top-0 absolute w-full h-full flex items-center justify-center"};function Mo(s,o,a,y,r,t){const x=m("ns-spinner");return i(),l("div",go,[e("div",wo,[e("h2",null,n(t.__("Select Customer")),1)]),e("div",Co,[e("div",ko,[e("span",null,n(t.__("Selected"))+" : ",1),e("div",So,[e("span",null,n(r.order.customer?`${r.order.customer.first_name} ${r.order.customer.last_name}`:"N/A"),1),r.order.customer?(i(),l("button",{key:0,onClick:o[0]||(o[0]=c=>t.openCustomerHistory(r.order.customer,c)),class:"mx-2 rounded-full h-8 w-8 flex items-center justify-center border ns-inset-button hover:border-transparent"},Oo)):u("",!0)])]),e("div",Vo,[e("div",To,[D(e("input",{ref:"searchField",onKeydown:o[1]||(o[1]=Q(c=>t.attemptToChoose(),["enter"])),"onUpdate:modelValue":o[2]||(o[2]=c=>r.searchCustomerValue=c),placeholder:"Search Customer",type:"text",class:"outline-none w-full p-2"},null,544),[[I,r.searchCustomerValue]])])]),e("div",jo,[e("ul",Lo,[r.customers&&r.customers.length===0?(i(),l("li",No,n(t.__("No customer match your query...")),1)):u("",!0),r.customers&&r.customers.length===0?(i(),l("li",{key:1,onClick:o[3]||(o[3]=c=>t.createCustomerWithMatch(r.searchCustomerValue)),class:"p-2 cursor-pointer text-center text-primary"},[e("span",Fo,n(t.__("Create a customer")),1)])):u("",!0),(i(!0),l(v,null,k(r.customers,c=>(i(),l("li",{onClick:f=>t.selectCustomer(c),key:c.id,class:"cursor-pointer p-2 border-b text-primary flex justify-between items-center"},[e("div",qo,[e("span",null,n(c.first_name)+" "+n(c.last_name),1),c.group?(i(),l("small",Ro,n(c.group.name),1)):(i(),l("small",Ho,n(t.__("No Group Assigned")),1))]),e("p",Io,[c.owe_amount>0?(i(),l("span",Qo,"-"+n(t.nsCurrency(c.owe_amount)),1)):u("",!0),c.owe_amount>0?(i(),l("span",Do,"/")):u("",!0),e("span",Uo,n(t.nsCurrency(c.purchases_amount)),1),e("button",{onClick:f=>t.openCustomerHistory(c,f),class:"mx-2 rounded-full h-8 w-8 flex items-center justify-center border ns-inset-button info"},Bo,8,Wo)])],8,Ao))),128))])]),r.isLoading?(i(),l("div",Eo,[p(x,{size:"24",border:"8"})])):u("",!0)])])}const U=V(vo,[["render",Mo]]),Ko={name:"ns-pos-discount-popup",props:["popup"],data(){return{finalValue:1,virtualStock:null,popupSubscription:null,mode:"",type:"",allSelected:!0,isLoading:!1,keys:[...[7,8,9].map(s=>({identifier:s,value:s})),...[4,5,6].map(s=>({identifier:s,value:s})),...[1,2,3].map(s=>({identifier:s,value:s})),{identifier:"backspace",icon:"la-backspace"},{identifier:0,value:0},{identifier:"next",icon:"la-share"}]}},mounted(){this.mode=this.popup.params.reference.discount_type||"percentage",this.type=this.popup.params.type,this.mode==="percentage"?this.finalValue=this.popup.params.reference.discount_percentage||1:this.finalValue=this.popup.params.reference.discount||1,this.popupCloser()},methods:{__:h,nsCurrency:q,popupResolver:T,popupCloser:O,setPercentageType(s){this.mode=s},closePopup(){this.popup.close()},inputValue(s){s.identifier==="next"?(this.popup.params.onSubmit({discount_type:this.mode,discount_percentage:this.mode==="percentage"?this.finalValue:void 0,discount:this.mode==="flat"?this.finalValue:void 0}),this.popup.close()):s.identifier==="backspace"?this.allSelected?(this.finalValue=0,this.allSelected=!1):(this.finalValue=this.finalValue.toString(),this.finalValue=this.finalValue.substr(0,this.finalValue.length-1)||0):this.allSelected?(this.finalValue=s.value,this.finalValue=parseFloat(this.finalValue),this.allSelected=!1):(this.finalValue+=""+s.value,this.finalValue=parseFloat(this.finalValue),this.mode==="percentage"&&(this.finalValue=this.finalValue>100?100:this.finalValue))}}},Go={id:"discount-popup",class:"ns-box shadow min-h-2/5-screen w-6/7-screen md:w-3/5-screen lg:w-3/5-screen xl:w-2/5-screen relative"},Yo={class:"flex-shrink-0 flex justify-between items-center p-2 border-b ns-box-header"},Jo={key:0,class:"text-xl font-bold text-primary text-center"},Xo={key:1,class:"text-xl font-bold text-primary text-center"},Zo={id:"screen",class:"h-16 ns-box-body text-white flex items-center justify-center"},$o={class:"font-bold text-3xl"},en={key:0},sn={key:1},tn={id:"switch-mode",class:"flex"},on=e("hr",{class:"border-r border-box-edge"},null,-1),nn={id:"numpad",class:"grid grid-flow-row grid-cols-3 grid-rows-3"},rn=["onClick"],ln={key:0};function cn(s,o,a,y,r,t){const x=m("ns-close-button");return i(),l("div",Go,[e("div",Yo,[e("div",null,[r.type==="product"?(i(),l("h1",Jo,n(t.__("Product Discount")),1)):u("",!0),r.type==="cart"?(i(),l("h1",Xo,n(t.__("Cart Discount")),1)):u("",!0)]),e("div",null,[p(x,{onClick:o[0]||(o[0]=c=>t.closePopup())})])]),e("div",Zo,[e("h1",$o,[r.mode==="flat"?(i(),l("span",en,n(t.nsCurrency(r.finalValue)),1)):u("",!0),r.mode==="percentage"?(i(),l("span",sn,n(r.finalValue)+"%",1)):u("",!0)])]),e("div",tn,[e("button",{onClick:o[1]||(o[1]=c=>t.setPercentageType("flat")),class:L([r.mode==="flat"?"bg-tab-active":"bg-tab-inactive text-tertiary","outline-none w-1/2 py-2 flex items-center justify-center"])},n(t.__("Flat")),3),on,e("button",{onClick:o[2]||(o[2]=c=>t.setPercentageType("percentage")),class:L([r.mode==="percentage"?"bg-tab-active":"bg-tab-inactive text-tertiary","outline-none w-1/2 py-2 flex items-center justify-center"])},n(t.__("Percentage")),3)]),e("div",nn,[(i(!0),l(v,null,k(r.keys,(c,f)=>(i(),l("div",{onClick:g=>t.inputValue(c),key:f,class:"text-primary ns-numpad-key info text-xl font-bold border h-24 flex items-center justify-center cursor-pointer"},[c.value!==void 0?(i(),l("span",ln,n(c.value),1)):u("",!0),c.icon?(i(),l("i",{key:1,class:L(["las",c.icon])},null,2)):u("",!0)],8,rn))),128))])])}const Xn=V(Ko,[["render",cn]]),un={data(){return{types:[],settingsSubscription:null,urls:{}}},props:["popup"],mounted(){this.settingsSubscription=POS.settings.subscribe(s=>{this.urls=s.urls}),this.types=POS.types.getValue(),Object.values(this.types).length===1&&this.select(Object.keys(this.types)[0]),this.popupCloser()},methods:{__:h,popupCloser:O,popupResolver:T,resolveIfQueued:T,async select(s){Object.values(this.types).forEach(a=>a.selected=!1),this.types[s].selected=!0;const o=this.types[s];try{const a=await POS.triggerOrderTypeSelection(o);POS.types.next(this.types),this.resolveIfQueued(o)}catch(a){throw a}}}},an={id:"ns-order-type",class:"h-full w-4/5-screen md:w-2/5-screen lg:w-2/5-screen xl:w-2/6-screen shadow-lg"},dn={id:"header",class:"h-16 flex justify-center items-center"},_n={class:"font-bold"},pn={key:0,class:"ns-box-body grid grid-flow-row grid-cols-1 grid-rows-1"},hn={class:"h-full w-full flex items-center justify-center flex-col"},fn=e("i",{class:"las la-frown text-7xl text-error-tertiary"},null,-1),mn={class:"p-4 md:w-2/3"},bn={class:"text-center"},yn={class:"flex justify-center mt-4 mb-2 -mx-2"},xn={class:"px-2"},vn={class:"px-2"},gn={key:1,class:"ns-box-body grid grid-flow-row grid-cols-2 grid-rows-2"},wn=["onClick"],Cn=["src"],kn={class:"font-semibold text-xl my-2"};function Sn(s,o,a,y,r,t){const x=m("ns-link");return i(),l("div",an,[e("div",dn,[e("h3",_n,n(t.__("Define The Order Type")),1)]),Object.values(r.types).length===0?(i(),l("div",pn,[e("div",hn,[fn,e("div",mn,[e("p",bn,n(t.__("No payment type has been selected on the settings. Please check your POS features and choose the supported order type")),1),e("div",yn,[e("div",xn,[p(x,{target:"_blank",type:"info",href:"https://my.nexopos.com/en/documentation/components/order-types"},{default:b(()=>[C(n(t.__("Read More")),1)]),_:1})]),e("div",vn,[p(x,{target:"_blank",type:"info",href:r.urls.order_type_url},{default:b(()=>[C(n(t.__("Configure")),1)]),_:1},8,["href"])])])])])])):u("",!0),Object.values(r.types).length>0?(i(),l("div",gn,[(i(!0),l(v,null,k(r.types,c=>(i(),l("div",{onClick:f=>t.select(c.identifier),key:c.identifier,class:L([c.selected?"active":"","ns-numpad-key info h-56 flex items-center justify-center flex-col cursor-pointer border"])},[e("img",{src:c.icon,alt:"",class:"w-32 h-32"},null,8,Cn),e("h4",kn,n(c.label),1)],10,wn))),128))])):u("",!0)])}const Zn=V(un,[["render",Sn]]),Pn={name:"ns-pos-shipping-popup",props:["popup"],computed:{activeTabFields(){if(this.tabs!==null){for(let s in this.tabs)if(this.tabs[s].active)return this.tabs[s].fields}return[]},useBillingInfo(){return this.tabs!==null?this.tabs.billing.fields[0].value:new Object},useShippingInfo(){return this.tabs!==null?this.tabs.shipping.fields[0].value:new Object}},unmounted(){this.orderSubscription.unsubscribe()},mounted(){this.orderSubscription=POS.order.subscribe(s=>this.order=s),this.popupCloser(),this.loadForm()},data(){return{tabs:null,orderSubscription:null,order:null,formValidation:new H}},watch:{useBillingInfo(s){s===1&&this.tabs.billing.fields.forEach(o=>{o.name!=="_use_customer_billing"&&(o.value=this.order.customer.billing?this.order.customer.billing[o.name]:o.value)})},useShippingInfo(s){s===1&&this.tabs.shipping.fields.forEach(o=>{o.name!=="_use_customer_shipping"&&(o.value=this.order.customer.shipping?this.order.customer.shipping[o.name]:o.value)})}},methods:{__,popupCloser:O,resolveIfQueued:T,submitInformations(){const s=this.formValidation.extractForm({tabs:this.tabs});for(let o in s.general)["shipping","shipping_rate"].includes(o)&&(s.general[o]=parseFloat(s.general[o]));this.order={...this.order,...s.general},delete s.general,delete s.shipping._use_customer_shipping,delete s.billing._use_customer_billing,this.order.addresses=s,POS.order.next(this.order),POS.refreshCart(),this.resolveIfQueued(!0)},closePopup(){this.resolveIfQueued(!1)},toggle(s){for(let o in this.tabs)this.tabs[o].active=!1;this.tabs[s].active=!0},loadForm(){S.get("/api/forms/ns.pos-addresses").subscribe(({tabs:s})=>{for(let o in s)o==="general"?s[o].fields.forEach(a=>{a.value=this.order[a.name]||""}):s[o].fields.forEach(a=>{a.value=this.order.addresses[o]?this.order.addresses[o][a.name]:""});this.tabs=this.formValidation.initializeTabs(s)})}}},On={class:"ns-box w-6/7-screen md:w-4/5-screen lg:w-3/5-screen h-6/7-screen md:h-4/5-screen shadow-lg flex flex-col overflow-hidden"},Vn={class:"p-2 border-b ns-box-header flex justify-between items-center"},Tn={class:"font-bold text-primary"},jn={class:"tools"},Ln=e("i",{class:"las la-times"},null,-1),Nn=[Ln],Fn={class:"flex-auto ns-box-body p-2 overflow-y-auto ns-tab"},An={id:"tabs-container"},qn={class:"header flex",style:{"margin-bottom":"-1px"}},Rn=["onClick"],Hn={class:"border ns-tab-item"},In={class:"px-4"},Qn={class:"-mx-4 flex flex-wrap"},Dn={class:"p-2 flex justify-between border-t ns-box-footer"},Un=e("div",null,null,-1);function Wn(s,o,a,y,r,t){const x=m("ns-field"),c=m("ns-button");return i(),l("div",On,[e("div",Vn,[e("h3",Tn,n(t.__("Shipping & Billing")),1),e("div",jn,[e("button",{onClick:o[0]||(o[0]=f=>t.closePopup()),class:"ns-close-button rounded-full h-8 w-8 border items-center justify-center"},Nn)])]),e("div",Fn,[e("div",An,[e("div",qn,[(i(!0),l(v,null,k(r.tabs,(f,g)=>(i(),l("div",{key:g,onClick:d=>t.toggle(g),class:L([f.active?"border-b-0 active":"inactive","tab rounded-tl rounded-tr border tab px-3 py-2 text-primary cursor-pointer"]),style:{"margin-right":"-1px"}},n(f.label),11,Rn))),128))]),e("div",Hn,[e("div",In,[e("div",Qn,[(i(!0),l(v,null,k(t.activeTabFields,(f,g)=>(i(),l("div",{key:g,class:L("p-4 w-full md:w-1/2 lg:w-1/3")},[p(x,{onBlur:d=>r.formValidation.checkField(f),onChange:d=>r.formValidation.checkField(f),field:f},null,8,["onBlur","onChange","field"])]))),128))])])])])]),e("div",Dn,[Un,e("div",null,[p(c,{onClick:o[1]||(o[1]=f=>t.submitInformations()),type:"info"},{default:b(()=>[C(n(t.__("Save")),1)]),_:1})])])])}const $n=V(Pn,[["render",Wn]]);export{Yn as P,Xn as a,Zn as b,$n as c,ss as d,Jn as e,U as n}; diff --git a/public/build/assets/ns-procurement-88be6afa.js b/public/build/assets/ns-procurement-8fc7cbf3.js similarity index 99% rename from public/build/assets/ns-procurement-88be6afa.js rename to public/build/assets/ns-procurement-8fc7cbf3.js index 6d9ea01f4..38d333cce 100644 --- a/public/build/assets/ns-procurement-88be6afa.js +++ b/public/build/assets/ns-procurement-8fc7cbf3.js @@ -1 +1 @@ -import{F as L,d as x,b as g,B as q,f as E,T as N,G as j,P as w,v as U,i as B}from"./bootstrap-ffaf6d09.js";import R from"./manage-products-cca5b591.js";import{_ as c,n as D}from"./currency-feccde3d.js";import{_ as O}from"./_plugin-vue_export-helper-c27b6911.js";import{r as C,o as l,c as u,a as r,t as d,F as v,b as y,g as I,f as F,w as M,i as T,m as K,h as G,J,u as V,e as m,n as k,B as P,A as S}from"./runtime-core.esm-bundler-414a078a.js";import{c as z,b as A}from"./ns-prompt-popup-24cc8d6f.js";import{s as H}from"./select-api-entities-3523a486.js";import"./index.es-25aa42ee.js";import"./chart-2ccf8ff7.js";import"./join-array-28744963.js";const Q={name:"ns-procurement-product-options",props:["popup"],data(){return{validation:new L,fields:[],rawFields:[{label:c("Expiration Date"),name:"expiration_date",description:c("Define when that specific product should expire."),type:"datetimepicker"},{label:c("Barcode"),name:"barcode",description:c("Renders the automatically generated barcode."),type:"text",disabled:!0},{label:c("Tax Type"),name:"tax_type",description:c("Adjust how tax is calculated on the item."),type:"select",options:[{label:c("Inclusive"),value:"inclusive"},{label:c("Exclusive"),value:"exclusive"}]}]}},methods:{__:c,applyChanges(){if(this.validation.validateFields(this.fields)){const e=this.validation.extractFields(this.fields);return this.popup.params.resolve(e),this.popup.close()}return x.error(c("Unable to proceed. The form is not valid.")).subscribe()}},mounted(){const t=this.rawFields.map(e=>(e.name==="expiration_date"&&(e.value=this.popup.params.product.procurement.expiration_date),e.name==="tax_type"&&(e.value=this.popup.params.product.procurement.tax_type),e.name==="barcode"&&(e.value=this.popup.params.product.procurement.barcode),e));this.fields=this.validation.createFields(t)}},W={class:"ns-box shadow-lg w-6/7-screen md:w-5/7-screen lg:w-3/7-screen"},X={class:"p-2 border-b ns-box-header"},Y={class:"font-semibold"},Z={class:"p-2 border-b ns-box-body"},$={class:"p-2 flex justify-end ns-box-body"};function ee(t,e,n,o,s,i){const h=C("ns-field"),a=C("ns-button");return l(),u("div",W,[r("div",X,[r("h5",Y,d(i.__("Options")),1)]),r("div",Z,[(l(!0),u(v,null,y(s.fields,(p,b)=>(l(),I(h,{class:"w-full",field:p,key:b},null,8,["field"]))),128))]),r("div",$,[F(a,{onClick:e[0]||(e[0]=p=>i.applyChanges()),type:"info"},{default:M(()=>[T(d(i.__("Save")),1)]),_:1})])])}const te=O(Q,[["render",ee]]),re={class:"w-6/7-screen md:w-4/7-screen lg:w-3/7-screen flex flex-col shadow-lg bg-popup-surface"},se={class:"flex flex-col"},ie={class:"h-24 font-bold text-4xl text-primary flex justify-center items-center"},oe=K({__name:"ns-numpad-popup",props:["popup"],setup(t){let e=G("");const n=t,o=i=>{e.value=i},s=()=>{n.popup.params.resolve(e.value),n.popup.close()};return J(()=>{e.value=n.popup.params.value}),(i,h)=>{const a=C("ns-numpad-plus");return l(),u("div",re,[r("div",se,[r("div",ie,d(V(e)),1),F(a,{onChanged:h[0]||(h[0]=p=>o(p)),onNext:h[1]||(h[1]=p=>s()),value:V(e)},null,8,["value"])])])}}}),ne={name:"ns-procurement",mounted(){this.reloadEntities(),this.shouldPreventAccidentlRefreshSubscriber=this.shouldPreventAccidentalRefresh.subscribe({next:t=>{t?window.addEventListener("beforeunload",this.addAccidentalCloseListener):window.removeEventListener("beforeunload",this.addAccidentalCloseListener)}})},computed:{activeTab(){return this.validTabs.filter(t=>t.active).length>0?this.validTabs.filter(t=>t.active)[0]:!1}},data(){return{totalTaxValues:0,totalPurchasePrice:0,formValidation:new L,form:{},nsSnackBar:x,fields:[],searchResult:[],searchValue:"",debounceSearch:null,nsHttpClient:g,taxes:[],validTabs:[{label:c("Details"),identifier:"details",active:!0},{label:c("Products"),identifier:"products",active:!1}],reloading:!1,shouldPreventAccidentalRefresh:new q(!1),shouldPreventAccidentlRefreshSubscriber:null,showInfo:!1}},watch:{form:{handler(){this.formValidation.isFormUntouched(this.form)?this.shouldPreventAccidentalRefresh.next(!1):this.shouldPreventAccidentalRefresh.next(!0)},deep:!0},searchValue(t){t&&(clearTimeout(this.debounceSearch),this.debounceSearch=setTimeout(()=>{this.doSearch(t)},500))}},components:{nsManageProducts:R},props:["submitMethod","submitUrl","returnUrl","src","rules"],methods:{__:c,nsCurrency:D,addAccidentalCloseListener(t){return t.preventDefault(),!0},async defineConversionOption(t){try{const e=this.form.products[t];if(e.procurement.unit_id===void 0)return E.error(c("An error has occured"),c("Select the procured unit first before selecting the conversion unit."),{actions:{learnMore:{label:c("Learn More"),onClick:o=>{console.log(o)}},close:{label:c("Close"),onClick:o=>{o.close()}}},duration:5e3});const n=await H(`/api/units/${e.procurement.unit_id}/siblings`,c("Convert to unit"),e.procurement.convert_unit_id||null,"select");e.procurement.convert_unit_id=n.values[0],e.procurement.convert_unit_label=n.labels[0]}catch(e){if(e!==!1)return x.error(e.message||c("An unexpected error has occured")).subscribe()}},computeTotal(){this.totalTaxValues=0,this.form.products.length>0&&(this.totalTaxValues=this.form.products.map(t=>t.procurement.tax_value).reduce((t,e)=>t+e)),this.totalPurchasePrice=0,this.form.products.length>0&&(this.totalPurchasePrice=this.form.products.map(t=>parseFloat(t.procurement.total_purchase_price)).reduce((t,e)=>t+e))},updateLine(t){const e=this.form.products[t],n=this.taxes.filter(o=>o.id===e.procurement.tax_group_id);if(parseFloat(e.procurement.purchase_price_edit)>0&&parseFloat(e.procurement.quantity)>0){if(n.length>0){const o=n[0].taxes.map(s=>N.getTaxValue(e.procurement.tax_type,e.procurement.purchase_price_edit,parseFloat(s.rate)));e.procurement.tax_value=o.reduce((s,i)=>s+i),e.procurement.tax_type==="inclusive"?(e.procurement.net_purchase_price=parseFloat(e.procurement.purchase_price_edit)-e.procurement.tax_value,e.procurement.gross_purchase_price=parseFloat(e.procurement.purchase_price_edit),e.procurement.purchase_price=parseFloat(e.procurement.gross_purchase_price)):(e.procurement.gross_purchase_price=parseFloat(e.procurement.purchase_price_edit)+e.procurement.tax_value,e.procurement.net_purchase_price=parseFloat(e.procurement.purchase_price_edit),e.procurement.purchase_price=parseFloat(e.procurement.gross_purchase_price))}else e.procurement.gross_purchase_price=parseFloat(e.procurement.purchase_price_edit),e.procurement.purchase_price=parseFloat(e.procurement.purchase_price_edit),e.procurement.net_purchase_price=parseFloat(e.procurement.purchase_price_edit),e.procurement.tax_value=0;e.procurement.tax_value=e.procurement.tax_value*parseFloat(e.procurement.quantity),e.procurement.total_purchase_price=e.procurement.purchase_price*parseFloat(e.procurement.quantity)}this.computeTotal(),this.$forceUpdate()},fetchLastPurchasePrice(t){const e=this.form.products[t],n=e.unit_quantities.filter(o=>e.procurement.unit_id===o.unit_id);n.length>0&&(e.procurement.purchase_price_edit=n[0].last_purchase_price||0),this.updateLine(t)},switchTaxType(t,e){t.procurement.tax_type=t.procurement.tax_type==="inclusive"?"exclusive":"inclusive",this.updateLine(e)},doSearch(t){g.post("/api/procurements/products/search-product",{search:t}).subscribe(e=>{e.length===1?this.addProductList(e[0]):e.length>1?this.searchResult=e:x.error(c("No result match your query.")).subscribe()})},reloadEntities(){this.reloading=!0,j([g.get("/api/categories"),g.get("/api/products"),g.get(this.src),g.get("/api/taxes/groups")]).subscribe(t=>{this.reloading=!1,this.categories=t[0],this.products=t[1],this.taxes=t[3],this.form.general&&t[2].tabs.general.fieds.forEach((e,n)=>{e.value=this.form.tabs.general.fields[n].value||""}),this.form=Object.assign(JSON.parse(JSON.stringify(t[2])),this.form),this.form=this.formValidation.createForm(this.form),this.form.tabs&&this.form.tabs.general.fields.forEach((e,n)=>{e.options&&(e.options=t[2].tabs.general.fields[n].options)}),this.form.products.length===0&&(this.form.products=this.form.products.map(e=>(["gross_purchase_price","purchase_price_edit","tax_value","net_purchase_price","purchase_price","total_price","total_purchase_price","quantity","tax_group_id"].forEach(n=>{e[n]===void 0&&(e[n]=e[n]===void 0?0:e[n])}),e.$invalid=e.$invalid||!1,e.purchase_price_edit=e.purchase_price,{name:e.name,purchase_units:e.purchase_units,procurement:e,unit_quantities:e.unit_quantities||[]}))),this.$forceUpdate()})},setTabActive(t){this.validTabs.forEach(e=>e.active=!1),this.$forceUpdate(),this.$nextTick().then(()=>{t.active=!0})},addProductList(t){if(t.unit_quantities===void 0)return x.error(c("Unable to add product which doesn't unit quantities defined.")).subscribe();t.procurement=new Object,t.procurement.gross_purchase_price=0,t.procurement.purchase_price_edit=0,t.procurement.tax_value=0,t.procurement.net_purchase_price=0,t.procurement.purchase_price=0,t.procurement.total_price=0,t.procurement.total_purchase_price=0,t.procurement.quantity=1,t.procurement.expiration_date=null,t.procurement.tax_group_id=t.tax_group_id,t.procurement.tax_type=t.tax_type||"inclusive",t.procurement.unit_id=t.unit_quantities[0].unit_id,t.procurement.product_id=t.id,t.procurement.convert_unit_id=t.unit_quantities[0].convert_unit_id,t.procurement.procurement_id=null,t.procurement.$invalid=!1,this.searchResult=[],this.searchValue="",this.form.products.push(t)},submit(){if(this.form.products.length===0)return x.error(c("Unable to proceed, no product were provided."),c("OK")).subscribe();if(this.form.products.forEach(o=>{parseFloat(o.procurement.quantity)>=1?o.procurement.unit_id===0?o.procurement.$invalid=!0:o.procurement.$invalid=!1:o.procurement.$invalid=!0}),this.form.products.filter(o=>o.procurement.$invalid).length>0)return x.error(c("Unable to proceed, one or more product has incorrect values."),c("OK")).subscribe();if(this.formValidation.validateForm(this.form).length>0)return this.setTabActive(this.activeTab),x.error(c("Unable to proceed, the procurement form is not valid."),c("OK")).subscribe();if(this.submitUrl===void 0)return x.error(c("Unable to submit, no valid submit URL were provided."),c("OK")).subscribe();this.formValidation.disableForm(this.form);const e={...this.formValidation.extractForm(this.form),products:this.form.products.map(o=>o.procurement)},n=w.show(z);g[this.submitMethod?this.submitMethod.toLowerCase():"post"](this.submitUrl,e).subscribe({next:o=>{if(o.status==="success")return this.shouldPreventAccidentalRefresh.next(!1),document.location=this.returnUrl;n.close(),this.formValidation.enableForm(this.form)},error:o=>{n.close(),x.error(o.message,void 0,{duration:5e3}).subscribe(),this.formValidation.enableForm(this.form),o.errors&&this.formValidation.triggerError(this.form,o.errors)}})},deleteProduct(t){this.form.products.splice(t,1),this.$forceUpdate()},handleGlobalChange(t){this.globallyChecked=t,this.rows.forEach(e=>e.$checked=t)},setProductOptions(t){new Promise((n,o)=>{w.show(te,{product:this.form.products[t],resolve:n,reject:o})}).then(n=>{for(let o in n)this.form.products[t].procurement[o]=n[o];this.updateLine(t)})},async selectUnitForProduct(t){try{const e=this.form.products[t],n=await new Promise((s,i)=>{w.show(A,{label:c("{product}: Purchase Unit").replace("{product}",e.name),description:c("The product will be procured on that unit."),value:e.unit_id,resolve:s,reject:i,options:e.unit_quantities.map(h=>({label:h.unit.name,value:h.unit.id}))})});e.procurement.unit_id=n;const o=e.unit_quantities.filter(s=>parseInt(s.unit_id)===+n);e.procurement.convert_unit_id=o[0].convert_unit_id||void 0,e.procurement.convert_unit_label=await new Promise((s,i)=>{e.procurement.convert_unit_id!==void 0?g.get(`/api/units/${e.procurement.convert_unit_id}`).subscribe({next:h=>{s(h.name)},error:h=>{s(c("Unkown Unit"))}}):s(c("N/A"))}),this.fetchLastPurchasePrice(t)}catch(e){console.log(e)}},async selectTax(t){try{const e=this.form.products[t],n=await new Promise((o,s)=>{w.show(A,{label:c("Choose Tax"),description:c("The tax will be assigned to the procured product."),resolve:o,reject:s,options:this.taxes.map(i=>({label:i.name,value:i.id}))})});e.procurement.tax_group_id=n,this.updateLine(t)}catch{}},async triggerKeyboard(t,e,n){try{const o=await new Promise((s,i)=>{w.show(oe,{value:t[e],resolve:s,reject:i})});t[e]=o,this.updateLine(n)}catch(o){console.log({exception:o})}},getSelectedTax(t){const e=this.form.products[t],n=this.taxes.filter(o=>!!(e.procurement.tax_group_id&&e.procurement.tax_group_id===o.id));return n.length===1?n[0].name:c("N/A")},getSelectedUnit(t){const e=this.form.products[t],o=e.unit_quantities.map(s=>s.unit).filter(s=>e.procurement.unit_id!==void 0?s.id===e.procurement.unit_id:!1);return o.length===1?o[0].name:c("N/A")},handleSavedEvent(t,e){t.data&&(e.options.push({label:t.data.entry.first_name,value:t.data.entry.id}),e.value=t.data.entry.id)}}},ae={class:"form flex-auto flex flex-col",id:"crud-form"},ce={class:"flex flex-col"},le={class:"flex justify-between items-center"},ue={for:"title",class:"font-bold my-2 text-primary"},de={for:"title",class:"text-sm my-2 -mx-1 flex text-primary"},pe={key:0,class:"cursor-pointer rounded-full ns-inset-button border px-2 py-1"},me={key:1,class:"cursor-pointer rounded-full ns-inset-button border px-2 py-1"},he={class:"px-1"},_e=["href"],fe=["disabled"],be=["disabled"],ve={key:0,class:"text-xs text-primary py-1"},xe={key:0,class:"rounded border-2 bg-info-primary border-info-tertiary flex"},ye=r("div",{class:"icon w-16 flex py-4 justify-center"},[r("i",{class:"las la-info-circle text-4xl"})],-1),ge={class:"text flex-auto py-4"},we={class:"font-bold text-lg"},ke=r("i",{class:"las la-hand-point-right"}," ",-1),Ce=r("i",{class:"las la-hand-point-right"}," ",-1),Pe={id:"form-container",class:"-mx-4 flex flex-wrap mt-4"},Te={class:"px-4 w-full"},Fe={id:"tabbed-card",class:"ns-tab"},Ue={id:"card-header",class:"flex flex-wrap"},Ve=["onClick"],Se={key:0,class:"ns-tab-item"},Ae={class:"card-body rounded-br-lg rounded-bl-lg shadow p-2"},Le={key:0,class:"-mx-4 flex flex-wrap"},Oe={key:1,class:"ns-tab-item"},qe={class:"card-body rounded-br-lg rounded-bl-lg shadow p-2"},Ee={class:"mb-2"},Ne={class:"input-group info flex border-2 rounded overflow-hidden"},je=["placeholder"],Be={class:"h-0"},Re={class:"shadow bg-floating-menu relative z-10"},De=["onClick"],Ie={class:"block font-bold text-primary"},Me={class:"block text-sm text-priamry"},Ke={class:"block text-sm text-primary"},Ge={class:"overflow-x-auto"},Je={class:"w-full ns-table"},ze={class:""},He={class:"flex"},Qe={class:"flex md:flex-row flex-col md:-mx-1"},We={class:"md:px-1"},Xe=["onClick"],Ye={class:"md:px-1"},Ze=["onClick"],$e={class:"md:px-1"},et=["onClick"],tt={class:"md:px-1"},rt=["onClick"],st={class:"md:px-1"},it=["onClick"],ot=["onClick"],nt={class:"flex justify-center"},at={key:0,class:"outline-none border-dashed py-1 border-b border-info-primary text-sm"},ct={key:1,class:"outline-none border-dashed py-1 border-b border-info-primary text-sm"},lt={class:"flex items-start"},ut={class:"input-group rounded border-2"},dt=["onChange","onUpdate:modelValue"],pt=["value"],mt={class:"flex items-start flex-col justify-end"},ht={class:"text-sm text-primary"},_t={class:"text-primary"},ft=["colspan"],bt={class:"p-2 border"},vt=["colspan"],xt={class:"p-2 border"};function yt(t,e,n,o,s,i){const h=C("ns-field");return l(),u("div",ae,[s.form.main?(l(),u(v,{key:0},[r("div",ce,[r("div",le,[r("label",ue,d(s.form.main.label||i.__("No title is provided")),1),r("div",de,[r("div",{class:"px-1",onClick:e[0]||(e[0]=a=>s.showInfo=!s.showInfo)},[s.showInfo?m("",!0):(l(),u("span",pe,d(i.__("Show Details")),1)),s.showInfo?(l(),u("span",me,d(i.__("Hide Details")),1)):m("",!0)]),r("div",he,[n.returnUrl?(l(),u("a",{key:0,href:n.returnUrl,class:"rounded-full ns-inset-button border px-2 py-1"},d(i.__("Go Back")),9,_e)):m("",!0)])])]),r("div",{class:k([s.form.main.disabled?"disabled":s.form.main.errors.length>0?"error":"","flex border-2 rounded input-group info overflow-hidden"])},[P(r("input",{"onUpdate:modelValue":e[1]||(e[1]=a=>s.form.main.value=a),onKeypress:e[2]||(e[2]=a=>s.formValidation.checkField(s.form.main)),onBlur:e[3]||(e[3]=a=>s.formValidation.checkField(s.form.main)),onChange:e[4]||(e[4]=a=>s.formValidation.checkField(s.form.main)),disabled:s.form.main.disabled,type:"text",class:k([(s.form.main.disabled,""),"flex-auto outline-none h-10 px-2"])},null,42,fe),[[U,s.form.main.value]]),r("button",{disabled:s.form.main.disabled,onClick:e[5]||(e[5]=a=>i.submit()),class:"outline-none px-4 h-10 border-l"},[S(t.$slots,"save",{},()=>[T(d(i.__("Save")),1)])],8,be),r("button",{onClick:e[6]||(e[6]=a=>i.reloadEntities()),class:"outline-none px-4 h-10"},[r("i",{class:k([s.reloading?"animate animate-spin":"","las la-sync"])},null,2)])],2),s.form.main.description&&s.form.main.errors.length===0?(l(),u("p",ve,d(s.form.main.description),1)):m("",!0),(l(!0),u(v,null,y(s.form.main.errors,(a,p)=>(l(),u("p",{class:"text-xs py-1 text-error-primary",key:p},[r("span",null,[S(t.$slots,"error-required",{},()=>[T(d(a.identifier),1)])])]))),128))]),s.showInfo?(l(),u("div",xe,[ye,r("div",ge,[r("h3",we,d(i.__("Important Notes")),1),r("ul",null,[r("li",null,[ke,r("span",null,d(i.__("Stock Management Products.")),1)]),r("li",null,[Ce,r("span",null,d(i.__("Doesn't work with Grouped Product.")),1)])])])])):m("",!0),r("div",Pe,[r("div",Te,[r("div",Fe,[r("div",Ue,[(l(!0),u(v,null,y(s.validTabs,(a,p)=>(l(),u("div",{onClick:b=>i.setTabActive(a),class:k([a.active?"active":"inactive","tab cursor-pointer px-4 py-2 rounded-tl-lg rounded-tr-lg text-primary"]),key:p},d(a.label),11,Ve))),128))]),i.activeTab.identifier==="details"?(l(),u("div",Se,[r("div",Ae,[s.form.tabs?(l(),u("div",Le,[(l(!0),u(v,null,y(s.form.tabs.general.fields,(a,p)=>(l(),u("div",{class:"flex px-4 w-full md:w-1/2 lg:w-1/3",key:p},[F(h,{onSaved:b=>i.handleSavedEvent(b,a),field:a},null,8,["onSaved","field"])]))),128))])):m("",!0)])])):m("",!0),i.activeTab.identifier==="products"?(l(),u("div",Oe,[r("div",qe,[r("div",Ee,[r("div",Ne,[P(r("input",{"onUpdate:modelValue":e[7]||(e[7]=a=>s.searchValue=a),type:"text",placeholder:i.__("SKU, Barcode, Name"),class:"flex-auto text-primary outline-none h-10 px-2"},null,8,je),[[U,s.searchValue]])]),r("div",Be,[r("div",Re,[(l(!0),u(v,null,y(s.searchResult,(a,p)=>(l(),u("div",{onClick:b=>i.addProductList(a),key:p,class:"cursor-pointer border border-b hover:bg-floating-menu-hover border-floating-menu-edge p-2 text-primary"},[r("span",Ie,d(a.name),1),r("span",Me,d(i.__("SKU"))+" : "+d(a.sku),1),r("span",Ke,d(i.__("Barcode"))+" : "+d(a.barcode),1)],8,De))),128))])])]),r("div",Ge,[r("table",Je,[r("thead",null,[r("tr",null,[(l(!0),u(v,null,y(s.form.columns,(a,p)=>(l(),u("td",{width:"200",key:p,class:"text-primary p-2 border"},d(a.label),1))),128))])]),r("tbody",null,[(l(!0),u(v,null,y(s.form.products,(a,p)=>(l(),u("tr",{key:p,class:k(a.procurement.$invalid?"error border-2 border-error-primary":"")},[(l(!0),u(v,null,y(s.form.columns,(b,_)=>(l(),u(v,null,[b.type==="name"?(l(),u("td",{key:_,width:"500",class:"p-2 text-primary border"},[r("span",ze,d(a.name),1),r("div",He,[r("div",Qe,[r("div",We,[r("span",{class:"text-xs text-info-tertiary cursor-pointer underline",onClick:f=>i.deleteProduct(p)},d(i.__("Delete")),9,Xe)]),r("div",Ye,[r("span",{class:"text-xs text-info-tertiary cursor-pointer underline",onClick:f=>i.setProductOptions(p)},d(i.__("Options")),9,Ze)]),r("div",$e,[r("span",{class:"text-xs text-info-tertiary cursor-pointer underline",onClick:f=>i.selectUnitForProduct(p)},d(i.__("Unit"))+": "+d(i.getSelectedUnit(p)),9,et)]),r("div",tt,[r("span",{class:"text-xs text-info-tertiary cursor-pointer underline",onClick:f=>i.selectTax(p)},d(i.__("Tax"))+": "+d(i.getSelectedTax(p)),9,rt)]),r("div",st,[r("span",{class:"text-xs text-info-tertiary cursor-pointer underline",onClick:f=>i.defineConversionOption(p)},d(i.__("Convert"))+": "+d(a.procurement.convert_unit_id?a.procurement.convert_unit_label:i.__("N/A")),9,it)])])])])):m("",!0),b.type==="text"?(l(),u("td",{key:_,onClick:f=>i.triggerKeyboard(a.procurement,_,p),class:"text-primary border cursor-pointer"},[r("div",nt,[["purchase_price_edit"].includes(_)?(l(),u("span",at,d(i.nsCurrency(a.procurement[_])),1)):m("",!0),["purchase_price_edit"].includes(_)?m("",!0):(l(),u("span",ct,d(a.procurement[_]),1))])],8,ot)):m("",!0),b.type==="custom_select"?(l(),u("td",{key:_,class:"p-2 text-primary border"},[r("div",lt,[r("div",ut,[P(r("select",{onChange:f=>i.updateLine(p),"onUpdate:modelValue":f=>a.procurement[_]=f,class:"p-2"},[(l(!0),u(v,null,y(b.options,f=>(l(),u("option",{key:f.value,value:f.value},d(f.label),9,pt))),128))],40,dt),[[B,a.procurement[_]]])])])])):m("",!0),b.type==="currency"?(l(),u("td",{key:_,class:"p-2 text-primary border"},[r("div",mt,[r("span",ht,d(i.nsCurrency(a.procurement[_])),1)])])):m("",!0)],64))),256))],2))),128)),r("tr",_t,[r("td",{class:"p-2 border",colspan:Object.keys(s.form.columns).indexOf("tax_value")},null,8,ft),r("td",bt,d(i.nsCurrency(s.totalTaxValues)),1),r("td",{class:"p-2 border",colspan:Object.keys(s.form.columns).indexOf("total_purchase_price")-(Object.keys(s.form.columns).indexOf("tax_value")+1)},null,8,vt),r("td",xt,d(i.nsCurrency(s.totalPurchasePrice)),1)])])])])])])):m("",!0)])])])],64)):m("",!0)])}const At=O(ne,[["render",yt]]);export{At as default}; +import{F as L,d as x,b as g,B as q,f as E,T as N,G as j,P as w,v as U,i as B}from"./bootstrap-ffaf6d09.js";import R from"./manage-products-cecb7581.js";import{_ as c,n as D}from"./currency-feccde3d.js";import{_ as O}from"./_plugin-vue_export-helper-c27b6911.js";import{r as C,o as l,c as u,a as r,t as d,F as v,b as y,g as I,f as F,w as M,i as T,m as K,h as G,J,u as V,e as m,n as k,B as P,A as S}from"./runtime-core.esm-bundler-414a078a.js";import{c as z,b as A}from"./ns-prompt-popup-24cc8d6f.js";import{s as H}from"./select-api-entities-3523a486.js";import"./index.es-25aa42ee.js";import"./chart-2ccf8ff7.js";import"./join-array-28744963.js";const Q={name:"ns-procurement-product-options",props:["popup"],data(){return{validation:new L,fields:[],rawFields:[{label:c("Expiration Date"),name:"expiration_date",description:c("Define when that specific product should expire."),type:"datetimepicker"},{label:c("Barcode"),name:"barcode",description:c("Renders the automatically generated barcode."),type:"text",disabled:!0},{label:c("Tax Type"),name:"tax_type",description:c("Adjust how tax is calculated on the item."),type:"select",options:[{label:c("Inclusive"),value:"inclusive"},{label:c("Exclusive"),value:"exclusive"}]}]}},methods:{__:c,applyChanges(){if(this.validation.validateFields(this.fields)){const e=this.validation.extractFields(this.fields);return this.popup.params.resolve(e),this.popup.close()}return x.error(c("Unable to proceed. The form is not valid.")).subscribe()}},mounted(){const t=this.rawFields.map(e=>(e.name==="expiration_date"&&(e.value=this.popup.params.product.procurement.expiration_date),e.name==="tax_type"&&(e.value=this.popup.params.product.procurement.tax_type),e.name==="barcode"&&(e.value=this.popup.params.product.procurement.barcode),e));this.fields=this.validation.createFields(t)}},W={class:"ns-box shadow-lg w-6/7-screen md:w-5/7-screen lg:w-3/7-screen"},X={class:"p-2 border-b ns-box-header"},Y={class:"font-semibold"},Z={class:"p-2 border-b ns-box-body"},$={class:"p-2 flex justify-end ns-box-body"};function ee(t,e,n,o,s,i){const h=C("ns-field"),a=C("ns-button");return l(),u("div",W,[r("div",X,[r("h5",Y,d(i.__("Options")),1)]),r("div",Z,[(l(!0),u(v,null,y(s.fields,(p,b)=>(l(),I(h,{class:"w-full",field:p,key:b},null,8,["field"]))),128))]),r("div",$,[F(a,{onClick:e[0]||(e[0]=p=>i.applyChanges()),type:"info"},{default:M(()=>[T(d(i.__("Save")),1)]),_:1})])])}const te=O(Q,[["render",ee]]),re={class:"w-6/7-screen md:w-4/7-screen lg:w-3/7-screen flex flex-col shadow-lg bg-popup-surface"},se={class:"flex flex-col"},ie={class:"h-24 font-bold text-4xl text-primary flex justify-center items-center"},oe=K({__name:"ns-numpad-popup",props:["popup"],setup(t){let e=G("");const n=t,o=i=>{e.value=i},s=()=>{n.popup.params.resolve(e.value),n.popup.close()};return J(()=>{e.value=n.popup.params.value}),(i,h)=>{const a=C("ns-numpad-plus");return l(),u("div",re,[r("div",se,[r("div",ie,d(V(e)),1),F(a,{onChanged:h[0]||(h[0]=p=>o(p)),onNext:h[1]||(h[1]=p=>s()),value:V(e)},null,8,["value"])])])}}}),ne={name:"ns-procurement",mounted(){this.reloadEntities(),this.shouldPreventAccidentlRefreshSubscriber=this.shouldPreventAccidentalRefresh.subscribe({next:t=>{t?window.addEventListener("beforeunload",this.addAccidentalCloseListener):window.removeEventListener("beforeunload",this.addAccidentalCloseListener)}})},computed:{activeTab(){return this.validTabs.filter(t=>t.active).length>0?this.validTabs.filter(t=>t.active)[0]:!1}},data(){return{totalTaxValues:0,totalPurchasePrice:0,formValidation:new L,form:{},nsSnackBar:x,fields:[],searchResult:[],searchValue:"",debounceSearch:null,nsHttpClient:g,taxes:[],validTabs:[{label:c("Details"),identifier:"details",active:!0},{label:c("Products"),identifier:"products",active:!1}],reloading:!1,shouldPreventAccidentalRefresh:new q(!1),shouldPreventAccidentlRefreshSubscriber:null,showInfo:!1}},watch:{form:{handler(){this.formValidation.isFormUntouched(this.form)?this.shouldPreventAccidentalRefresh.next(!1):this.shouldPreventAccidentalRefresh.next(!0)},deep:!0},searchValue(t){t&&(clearTimeout(this.debounceSearch),this.debounceSearch=setTimeout(()=>{this.doSearch(t)},500))}},components:{nsManageProducts:R},props:["submitMethod","submitUrl","returnUrl","src","rules"],methods:{__:c,nsCurrency:D,addAccidentalCloseListener(t){return t.preventDefault(),!0},async defineConversionOption(t){try{const e=this.form.products[t];if(e.procurement.unit_id===void 0)return E.error(c("An error has occured"),c("Select the procured unit first before selecting the conversion unit."),{actions:{learnMore:{label:c("Learn More"),onClick:o=>{console.log(o)}},close:{label:c("Close"),onClick:o=>{o.close()}}},duration:5e3});const n=await H(`/api/units/${e.procurement.unit_id}/siblings`,c("Convert to unit"),e.procurement.convert_unit_id||null,"select");e.procurement.convert_unit_id=n.values[0],e.procurement.convert_unit_label=n.labels[0]}catch(e){if(e!==!1)return x.error(e.message||c("An unexpected error has occured")).subscribe()}},computeTotal(){this.totalTaxValues=0,this.form.products.length>0&&(this.totalTaxValues=this.form.products.map(t=>t.procurement.tax_value).reduce((t,e)=>t+e)),this.totalPurchasePrice=0,this.form.products.length>0&&(this.totalPurchasePrice=this.form.products.map(t=>parseFloat(t.procurement.total_purchase_price)).reduce((t,e)=>t+e))},updateLine(t){const e=this.form.products[t],n=this.taxes.filter(o=>o.id===e.procurement.tax_group_id);if(parseFloat(e.procurement.purchase_price_edit)>0&&parseFloat(e.procurement.quantity)>0){if(n.length>0){const o=n[0].taxes.map(s=>N.getTaxValue(e.procurement.tax_type,e.procurement.purchase_price_edit,parseFloat(s.rate)));e.procurement.tax_value=o.reduce((s,i)=>s+i),e.procurement.tax_type==="inclusive"?(e.procurement.net_purchase_price=parseFloat(e.procurement.purchase_price_edit)-e.procurement.tax_value,e.procurement.gross_purchase_price=parseFloat(e.procurement.purchase_price_edit),e.procurement.purchase_price=parseFloat(e.procurement.gross_purchase_price)):(e.procurement.gross_purchase_price=parseFloat(e.procurement.purchase_price_edit)+e.procurement.tax_value,e.procurement.net_purchase_price=parseFloat(e.procurement.purchase_price_edit),e.procurement.purchase_price=parseFloat(e.procurement.gross_purchase_price))}else e.procurement.gross_purchase_price=parseFloat(e.procurement.purchase_price_edit),e.procurement.purchase_price=parseFloat(e.procurement.purchase_price_edit),e.procurement.net_purchase_price=parseFloat(e.procurement.purchase_price_edit),e.procurement.tax_value=0;e.procurement.tax_value=e.procurement.tax_value*parseFloat(e.procurement.quantity),e.procurement.total_purchase_price=e.procurement.purchase_price*parseFloat(e.procurement.quantity)}this.computeTotal(),this.$forceUpdate()},fetchLastPurchasePrice(t){const e=this.form.products[t],n=e.unit_quantities.filter(o=>e.procurement.unit_id===o.unit_id);n.length>0&&(e.procurement.purchase_price_edit=n[0].last_purchase_price||0),this.updateLine(t)},switchTaxType(t,e){t.procurement.tax_type=t.procurement.tax_type==="inclusive"?"exclusive":"inclusive",this.updateLine(e)},doSearch(t){g.post("/api/procurements/products/search-product",{search:t}).subscribe(e=>{e.length===1?this.addProductList(e[0]):e.length>1?this.searchResult=e:x.error(c("No result match your query.")).subscribe()})},reloadEntities(){this.reloading=!0,j([g.get("/api/categories"),g.get("/api/products"),g.get(this.src),g.get("/api/taxes/groups")]).subscribe(t=>{this.reloading=!1,this.categories=t[0],this.products=t[1],this.taxes=t[3],this.form.general&&t[2].tabs.general.fieds.forEach((e,n)=>{e.value=this.form.tabs.general.fields[n].value||""}),this.form=Object.assign(JSON.parse(JSON.stringify(t[2])),this.form),this.form=this.formValidation.createForm(this.form),this.form.tabs&&this.form.tabs.general.fields.forEach((e,n)=>{e.options&&(e.options=t[2].tabs.general.fields[n].options)}),this.form.products.length===0&&(this.form.products=this.form.products.map(e=>(["gross_purchase_price","purchase_price_edit","tax_value","net_purchase_price","purchase_price","total_price","total_purchase_price","quantity","tax_group_id"].forEach(n=>{e[n]===void 0&&(e[n]=e[n]===void 0?0:e[n])}),e.$invalid=e.$invalid||!1,e.purchase_price_edit=e.purchase_price,{name:e.name,purchase_units:e.purchase_units,procurement:e,unit_quantities:e.unit_quantities||[]}))),this.$forceUpdate()})},setTabActive(t){this.validTabs.forEach(e=>e.active=!1),this.$forceUpdate(),this.$nextTick().then(()=>{t.active=!0})},addProductList(t){if(t.unit_quantities===void 0)return x.error(c("Unable to add product which doesn't unit quantities defined.")).subscribe();t.procurement=new Object,t.procurement.gross_purchase_price=0,t.procurement.purchase_price_edit=0,t.procurement.tax_value=0,t.procurement.net_purchase_price=0,t.procurement.purchase_price=0,t.procurement.total_price=0,t.procurement.total_purchase_price=0,t.procurement.quantity=1,t.procurement.expiration_date=null,t.procurement.tax_group_id=t.tax_group_id,t.procurement.tax_type=t.tax_type||"inclusive",t.procurement.unit_id=t.unit_quantities[0].unit_id,t.procurement.product_id=t.id,t.procurement.convert_unit_id=t.unit_quantities[0].convert_unit_id,t.procurement.procurement_id=null,t.procurement.$invalid=!1,this.searchResult=[],this.searchValue="",this.form.products.push(t)},submit(){if(this.form.products.length===0)return x.error(c("Unable to proceed, no product were provided."),c("OK")).subscribe();if(this.form.products.forEach(o=>{parseFloat(o.procurement.quantity)>=1?o.procurement.unit_id===0?o.procurement.$invalid=!0:o.procurement.$invalid=!1:o.procurement.$invalid=!0}),this.form.products.filter(o=>o.procurement.$invalid).length>0)return x.error(c("Unable to proceed, one or more product has incorrect values."),c("OK")).subscribe();if(this.formValidation.validateForm(this.form).length>0)return this.setTabActive(this.activeTab),x.error(c("Unable to proceed, the procurement form is not valid."),c("OK")).subscribe();if(this.submitUrl===void 0)return x.error(c("Unable to submit, no valid submit URL were provided."),c("OK")).subscribe();this.formValidation.disableForm(this.form);const e={...this.formValidation.extractForm(this.form),products:this.form.products.map(o=>o.procurement)},n=w.show(z);g[this.submitMethod?this.submitMethod.toLowerCase():"post"](this.submitUrl,e).subscribe({next:o=>{if(o.status==="success")return this.shouldPreventAccidentalRefresh.next(!1),document.location=this.returnUrl;n.close(),this.formValidation.enableForm(this.form)},error:o=>{n.close(),x.error(o.message,void 0,{duration:5e3}).subscribe(),this.formValidation.enableForm(this.form),o.errors&&this.formValidation.triggerError(this.form,o.errors)}})},deleteProduct(t){this.form.products.splice(t,1),this.$forceUpdate()},handleGlobalChange(t){this.globallyChecked=t,this.rows.forEach(e=>e.$checked=t)},setProductOptions(t){new Promise((n,o)=>{w.show(te,{product:this.form.products[t],resolve:n,reject:o})}).then(n=>{for(let o in n)this.form.products[t].procurement[o]=n[o];this.updateLine(t)})},async selectUnitForProduct(t){try{const e=this.form.products[t],n=await new Promise((s,i)=>{w.show(A,{label:c("{product}: Purchase Unit").replace("{product}",e.name),description:c("The product will be procured on that unit."),value:e.unit_id,resolve:s,reject:i,options:e.unit_quantities.map(h=>({label:h.unit.name,value:h.unit.id}))})});e.procurement.unit_id=n;const o=e.unit_quantities.filter(s=>parseInt(s.unit_id)===+n);e.procurement.convert_unit_id=o[0].convert_unit_id||void 0,e.procurement.convert_unit_label=await new Promise((s,i)=>{e.procurement.convert_unit_id!==void 0?g.get(`/api/units/${e.procurement.convert_unit_id}`).subscribe({next:h=>{s(h.name)},error:h=>{s(c("Unkown Unit"))}}):s(c("N/A"))}),this.fetchLastPurchasePrice(t)}catch(e){console.log(e)}},async selectTax(t){try{const e=this.form.products[t],n=await new Promise((o,s)=>{w.show(A,{label:c("Choose Tax"),description:c("The tax will be assigned to the procured product."),resolve:o,reject:s,options:this.taxes.map(i=>({label:i.name,value:i.id}))})});e.procurement.tax_group_id=n,this.updateLine(t)}catch{}},async triggerKeyboard(t,e,n){try{const o=await new Promise((s,i)=>{w.show(oe,{value:t[e],resolve:s,reject:i})});t[e]=o,this.updateLine(n)}catch(o){console.log({exception:o})}},getSelectedTax(t){const e=this.form.products[t],n=this.taxes.filter(o=>!!(e.procurement.tax_group_id&&e.procurement.tax_group_id===o.id));return n.length===1?n[0].name:c("N/A")},getSelectedUnit(t){const e=this.form.products[t],o=e.unit_quantities.map(s=>s.unit).filter(s=>e.procurement.unit_id!==void 0?s.id===e.procurement.unit_id:!1);return o.length===1?o[0].name:c("N/A")},handleSavedEvent(t,e){t.data&&(e.options.push({label:t.data.entry.first_name,value:t.data.entry.id}),e.value=t.data.entry.id)}}},ae={class:"form flex-auto flex flex-col",id:"crud-form"},ce={class:"flex flex-col"},le={class:"flex justify-between items-center"},ue={for:"title",class:"font-bold my-2 text-primary"},de={for:"title",class:"text-sm my-2 -mx-1 flex text-primary"},pe={key:0,class:"cursor-pointer rounded-full ns-inset-button border px-2 py-1"},me={key:1,class:"cursor-pointer rounded-full ns-inset-button border px-2 py-1"},he={class:"px-1"},_e=["href"],fe=["disabled"],be=["disabled"],ve={key:0,class:"text-xs text-primary py-1"},xe={key:0,class:"rounded border-2 bg-info-primary border-info-tertiary flex"},ye=r("div",{class:"icon w-16 flex py-4 justify-center"},[r("i",{class:"las la-info-circle text-4xl"})],-1),ge={class:"text flex-auto py-4"},we={class:"font-bold text-lg"},ke=r("i",{class:"las la-hand-point-right"}," ",-1),Ce=r("i",{class:"las la-hand-point-right"}," ",-1),Pe={id:"form-container",class:"-mx-4 flex flex-wrap mt-4"},Te={class:"px-4 w-full"},Fe={id:"tabbed-card",class:"ns-tab"},Ue={id:"card-header",class:"flex flex-wrap"},Ve=["onClick"],Se={key:0,class:"ns-tab-item"},Ae={class:"card-body rounded-br-lg rounded-bl-lg shadow p-2"},Le={key:0,class:"-mx-4 flex flex-wrap"},Oe={key:1,class:"ns-tab-item"},qe={class:"card-body rounded-br-lg rounded-bl-lg shadow p-2"},Ee={class:"mb-2"},Ne={class:"input-group info flex border-2 rounded overflow-hidden"},je=["placeholder"],Be={class:"h-0"},Re={class:"shadow bg-floating-menu relative z-10"},De=["onClick"],Ie={class:"block font-bold text-primary"},Me={class:"block text-sm text-priamry"},Ke={class:"block text-sm text-primary"},Ge={class:"overflow-x-auto"},Je={class:"w-full ns-table"},ze={class:""},He={class:"flex"},Qe={class:"flex md:flex-row flex-col md:-mx-1"},We={class:"md:px-1"},Xe=["onClick"],Ye={class:"md:px-1"},Ze=["onClick"],$e={class:"md:px-1"},et=["onClick"],tt={class:"md:px-1"},rt=["onClick"],st={class:"md:px-1"},it=["onClick"],ot=["onClick"],nt={class:"flex justify-center"},at={key:0,class:"outline-none border-dashed py-1 border-b border-info-primary text-sm"},ct={key:1,class:"outline-none border-dashed py-1 border-b border-info-primary text-sm"},lt={class:"flex items-start"},ut={class:"input-group rounded border-2"},dt=["onChange","onUpdate:modelValue"],pt=["value"],mt={class:"flex items-start flex-col justify-end"},ht={class:"text-sm text-primary"},_t={class:"text-primary"},ft=["colspan"],bt={class:"p-2 border"},vt=["colspan"],xt={class:"p-2 border"};function yt(t,e,n,o,s,i){const h=C("ns-field");return l(),u("div",ae,[s.form.main?(l(),u(v,{key:0},[r("div",ce,[r("div",le,[r("label",ue,d(s.form.main.label||i.__("No title is provided")),1),r("div",de,[r("div",{class:"px-1",onClick:e[0]||(e[0]=a=>s.showInfo=!s.showInfo)},[s.showInfo?m("",!0):(l(),u("span",pe,d(i.__("Show Details")),1)),s.showInfo?(l(),u("span",me,d(i.__("Hide Details")),1)):m("",!0)]),r("div",he,[n.returnUrl?(l(),u("a",{key:0,href:n.returnUrl,class:"rounded-full ns-inset-button border px-2 py-1"},d(i.__("Go Back")),9,_e)):m("",!0)])])]),r("div",{class:k([s.form.main.disabled?"disabled":s.form.main.errors.length>0?"error":"","flex border-2 rounded input-group info overflow-hidden"])},[P(r("input",{"onUpdate:modelValue":e[1]||(e[1]=a=>s.form.main.value=a),onKeypress:e[2]||(e[2]=a=>s.formValidation.checkField(s.form.main)),onBlur:e[3]||(e[3]=a=>s.formValidation.checkField(s.form.main)),onChange:e[4]||(e[4]=a=>s.formValidation.checkField(s.form.main)),disabled:s.form.main.disabled,type:"text",class:k([(s.form.main.disabled,""),"flex-auto outline-none h-10 px-2"])},null,42,fe),[[U,s.form.main.value]]),r("button",{disabled:s.form.main.disabled,onClick:e[5]||(e[5]=a=>i.submit()),class:"outline-none px-4 h-10 border-l"},[S(t.$slots,"save",{},()=>[T(d(i.__("Save")),1)])],8,be),r("button",{onClick:e[6]||(e[6]=a=>i.reloadEntities()),class:"outline-none px-4 h-10"},[r("i",{class:k([s.reloading?"animate animate-spin":"","las la-sync"])},null,2)])],2),s.form.main.description&&s.form.main.errors.length===0?(l(),u("p",ve,d(s.form.main.description),1)):m("",!0),(l(!0),u(v,null,y(s.form.main.errors,(a,p)=>(l(),u("p",{class:"text-xs py-1 text-error-primary",key:p},[r("span",null,[S(t.$slots,"error-required",{},()=>[T(d(a.identifier),1)])])]))),128))]),s.showInfo?(l(),u("div",xe,[ye,r("div",ge,[r("h3",we,d(i.__("Important Notes")),1),r("ul",null,[r("li",null,[ke,r("span",null,d(i.__("Stock Management Products.")),1)]),r("li",null,[Ce,r("span",null,d(i.__("Doesn't work with Grouped Product.")),1)])])])])):m("",!0),r("div",Pe,[r("div",Te,[r("div",Fe,[r("div",Ue,[(l(!0),u(v,null,y(s.validTabs,(a,p)=>(l(),u("div",{onClick:b=>i.setTabActive(a),class:k([a.active?"active":"inactive","tab cursor-pointer px-4 py-2 rounded-tl-lg rounded-tr-lg text-primary"]),key:p},d(a.label),11,Ve))),128))]),i.activeTab.identifier==="details"?(l(),u("div",Se,[r("div",Ae,[s.form.tabs?(l(),u("div",Le,[(l(!0),u(v,null,y(s.form.tabs.general.fields,(a,p)=>(l(),u("div",{class:"flex px-4 w-full md:w-1/2 lg:w-1/3",key:p},[F(h,{onSaved:b=>i.handleSavedEvent(b,a),field:a},null,8,["onSaved","field"])]))),128))])):m("",!0)])])):m("",!0),i.activeTab.identifier==="products"?(l(),u("div",Oe,[r("div",qe,[r("div",Ee,[r("div",Ne,[P(r("input",{"onUpdate:modelValue":e[7]||(e[7]=a=>s.searchValue=a),type:"text",placeholder:i.__("SKU, Barcode, Name"),class:"flex-auto text-primary outline-none h-10 px-2"},null,8,je),[[U,s.searchValue]])]),r("div",Be,[r("div",Re,[(l(!0),u(v,null,y(s.searchResult,(a,p)=>(l(),u("div",{onClick:b=>i.addProductList(a),key:p,class:"cursor-pointer border border-b hover:bg-floating-menu-hover border-floating-menu-edge p-2 text-primary"},[r("span",Ie,d(a.name),1),r("span",Me,d(i.__("SKU"))+" : "+d(a.sku),1),r("span",Ke,d(i.__("Barcode"))+" : "+d(a.barcode),1)],8,De))),128))])])]),r("div",Ge,[r("table",Je,[r("thead",null,[r("tr",null,[(l(!0),u(v,null,y(s.form.columns,(a,p)=>(l(),u("td",{width:"200",key:p,class:"text-primary p-2 border"},d(a.label),1))),128))])]),r("tbody",null,[(l(!0),u(v,null,y(s.form.products,(a,p)=>(l(),u("tr",{key:p,class:k(a.procurement.$invalid?"error border-2 border-error-primary":"")},[(l(!0),u(v,null,y(s.form.columns,(b,_)=>(l(),u(v,null,[b.type==="name"?(l(),u("td",{key:_,width:"500",class:"p-2 text-primary border"},[r("span",ze,d(a.name),1),r("div",He,[r("div",Qe,[r("div",We,[r("span",{class:"text-xs text-info-tertiary cursor-pointer underline",onClick:f=>i.deleteProduct(p)},d(i.__("Delete")),9,Xe)]),r("div",Ye,[r("span",{class:"text-xs text-info-tertiary cursor-pointer underline",onClick:f=>i.setProductOptions(p)},d(i.__("Options")),9,Ze)]),r("div",$e,[r("span",{class:"text-xs text-info-tertiary cursor-pointer underline",onClick:f=>i.selectUnitForProduct(p)},d(i.__("Unit"))+": "+d(i.getSelectedUnit(p)),9,et)]),r("div",tt,[r("span",{class:"text-xs text-info-tertiary cursor-pointer underline",onClick:f=>i.selectTax(p)},d(i.__("Tax"))+": "+d(i.getSelectedTax(p)),9,rt)]),r("div",st,[r("span",{class:"text-xs text-info-tertiary cursor-pointer underline",onClick:f=>i.defineConversionOption(p)},d(i.__("Convert"))+": "+d(a.procurement.convert_unit_id?a.procurement.convert_unit_label:i.__("N/A")),9,it)])])])])):m("",!0),b.type==="text"?(l(),u("td",{key:_,onClick:f=>i.triggerKeyboard(a.procurement,_,p),class:"text-primary border cursor-pointer"},[r("div",nt,[["purchase_price_edit"].includes(_)?(l(),u("span",at,d(i.nsCurrency(a.procurement[_])),1)):m("",!0),["purchase_price_edit"].includes(_)?m("",!0):(l(),u("span",ct,d(a.procurement[_]),1))])],8,ot)):m("",!0),b.type==="custom_select"?(l(),u("td",{key:_,class:"p-2 text-primary border"},[r("div",lt,[r("div",ut,[P(r("select",{onChange:f=>i.updateLine(p),"onUpdate:modelValue":f=>a.procurement[_]=f,class:"p-2"},[(l(!0),u(v,null,y(b.options,f=>(l(),u("option",{key:f.value,value:f.value},d(f.label),9,pt))),128))],40,dt),[[B,a.procurement[_]]])])])])):m("",!0),b.type==="currency"?(l(),u("td",{key:_,class:"p-2 text-primary border"},[r("div",mt,[r("span",ht,d(i.nsCurrency(a.procurement[_])),1)])])):m("",!0)],64))),256))],2))),128)),r("tr",_t,[r("td",{class:"p-2 border",colspan:Object.keys(s.form.columns).indexOf("tax_value")},null,8,ft),r("td",bt,d(i.nsCurrency(s.totalTaxValues)),1),r("td",{class:"p-2 border",colspan:Object.keys(s.form.columns).indexOf("total_purchase_price")-(Object.keys(s.form.columns).indexOf("tax_value")+1)},null,8,vt),r("td",xt,d(i.nsCurrency(s.totalPurchasePrice)),1)])])])])])])):m("",!0)])])])],64)):m("",!0)])}const At=O(ne,[["render",yt]]);export{At as default}; diff --git a/public/build/assets/pos-5aaef736.js b/public/build/assets/pos-5aaef736.js deleted file mode 100644 index d23fca204..000000000 --- a/public/build/assets/pos-5aaef736.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as m}from"./preload-helper-41c905a7.js";import"./time-01d30542.js";import{b as t}from"./components-07a97223.js";import{c as n}from"./bootstrap-ffaf6d09.js";import{N as i}from"./ns-hotpress-fbaed768.js";import{d as p}from"./runtime-core.esm-bundler-414a078a.js";import"./ns-prompt-popup-24cc8d6f.js";import"./currency-feccde3d.js";import"./_plugin-vue_export-helper-c27b6911.js";import"./ns-avatar-image-1a727bdf.js";import"./index.es-25aa42ee.js";import"./chart-2ccf8ff7.js";window.nsComponents={...t};window.nsHotPress=new i;const o=n({mounted(){}});o.component("nsPos",p(()=>m(()=>import("./ns-pos-a91ba1d6.js"),["./ns-pos-a91ba1d6.js","./ns-pos-cart-32f5a2e0.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./pos-section-switch-0869c4e1.js","./ns-pos-order-type-popup-14f46b3a.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-orders-preview-popup-3c654295.js","./index.es-25aa42ee.js","./ns-pos-shipping-popup-5ba7ac6e.js","./ns-pos-grid-32143241.js"],import.meta.url)));o.component("nsPosCart",p(()=>m(()=>import("./ns-pos-cart-32f5a2e0.js"),["./ns-pos-cart-32f5a2e0.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./pos-section-switch-0869c4e1.js","./ns-pos-order-type-popup-14f46b3a.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-orders-preview-popup-3c654295.js","./index.es-25aa42ee.js","./ns-pos-shipping-popup-5ba7ac6e.js"],import.meta.url)));o.component("nsPosGrid",p(()=>m(()=>import("./ns-pos-grid-32143241.js"),["./ns-pos-grid-32143241.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./pos-section-switch-0869c4e1.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css"],import.meta.url)));for(let r in t)o.component(r,t[r]);o.mount("#pos-app");window.posApp=o; diff --git a/public/build/assets/pos-dc1f5e8e.js b/public/build/assets/pos-dc1f5e8e.js new file mode 100644 index 000000000..3714cc32f --- /dev/null +++ b/public/build/assets/pos-dc1f5e8e.js @@ -0,0 +1 @@ +import{_ as m}from"./preload-helper-41c905a7.js";import"./time-01d30542.js";import{b as t}from"./components-07a97223.js";import{c as n}from"./bootstrap-ffaf6d09.js";import{N as i}from"./ns-hotpress-fbaed768.js";import{d as p}from"./runtime-core.esm-bundler-414a078a.js";import"./ns-prompt-popup-24cc8d6f.js";import"./currency-feccde3d.js";import"./_plugin-vue_export-helper-c27b6911.js";import"./ns-avatar-image-1a727bdf.js";import"./index.es-25aa42ee.js";import"./chart-2ccf8ff7.js";window.nsComponents={...t};window.nsHotPress=new i;const o=n({mounted(){}});o.component("nsPos",p(()=>m(()=>import("./ns-pos-7cc83bf8.js"),["./ns-pos-7cc83bf8.js","./ns-pos-cart-a5bf23af.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./pos-section-switch-0869c4e1.js","./ns-pos-shipping-popup-dffc98ef.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-orders-preview-popup-3c654295.js","./index.es-25aa42ee.js","./ns-pos-grid-32143241.js"],import.meta.url)));o.component("nsPosCart",p(()=>m(()=>import("./ns-pos-cart-a5bf23af.js"),["./ns-pos-cart-a5bf23af.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./pos-section-switch-0869c4e1.js","./ns-pos-shipping-popup-dffc98ef.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-orders-preview-popup-3c654295.js","./index.es-25aa42ee.js"],import.meta.url)));o.component("nsPosGrid",p(()=>m(()=>import("./ns-pos-grid-32143241.js"),["./ns-pos-grid-32143241.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./pos-section-switch-0869c4e1.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css"],import.meta.url)));for(let r in t)o.component(r,t[r]);o.mount("#pos-app");window.posApp=o; diff --git a/public/build/assets/pos-init-6f22442c.js b/public/build/assets/pos-init-6f22442c.js deleted file mode 100644 index 0ddd375a6..000000000 --- a/public/build/assets/pos-init-6f22442c.js +++ /dev/null @@ -1 +0,0 @@ -var X=Object.defineProperty;var Z=(a,e,t)=>e in a?X(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var g=(a,e,t)=>(Z(a,typeof e!="symbol"?e+"":e,t),t);import{_ as V}from"./preload-helper-41c905a7.js";import{n as ee,a as te,b as se,P as ie}from"./ns-pos-order-type-popup-14f46b3a.js";import{p as re,a as z,b as C,d as x,P as b,e as ne,n as v,B as P,f as N,T as H,g as m,h as oe}from"./bootstrap-ffaf6d09.js";import{_ as d,n as S,a as A}from"./currency-feccde3d.js";import{_ as O}from"./_plugin-vue_export-helper-c27b6911.js";import{r as Q,o as p,c as h,a as n,t as c,F as U,b as R,e as f,f as I,n as L,g as j,w as E,h as ae,i as q,j as ue,d as T}from"./runtime-core.esm-bundler-414a078a.js";import{n as $,a as le,b as ce,c as W,d as de,e as pe}from"./ns-prompt-popup-24cc8d6f.js";import"./index.es-25aa42ee.js";import"./ns-orders-preview-popup-3c654295.js";import"./chart-2ccf8ff7.js";const _e={props:["popup"],data(){return{unitsQuantities:[],loadsUnits:!1,options:null,optionsSubscriber:null}},beforeDestroy(){this.optionsSubscriber.unsubscribe()},mounted(){this.optionsSubscriber=POS.options.subscribe(a=>{this.options=a}),this.popup.params.product.$original().selectedUnitQuantity!==void 0?this.selectUnit(this.popup.params.product.$original().selectedUnitQuantity):this.popup.params.product.$original().unit_quantities!==void 0&&this.popup.params.product.$original().unit_quantities.length===1?this.selectUnit(this.popup.params.product.$original().unit_quantities[0]):(this.loadsUnits=!0,this.loadUnits()),this.popupCloser()},computed:{productName(){return this.popup.params.product.$original().name}},methods:{__:d,nsCurrency:S,popupCloser:re,popupResolver:z,displayRightPrice(a){return POS.getSalePrice(a,this.popup.params.product.$original())},loadUnits(){C.get(`/api/products/${this.popup.params.product.$original().id}/units/quantities`).subscribe(a=>{if(a.length===0)return this.popup.close(),x.error(d("This product doesn't have any unit defined for selling. Make sure to mark at least one unit as visible.")).subscribe();this.unitsQuantities=a,this.unitsQuantities.length===1&&this.selectUnit(this.unitsQuantities[0])})},selectUnit(a){if(a.unit===null)return x.error(d('The unit attached to this product is missing or not assigned. Please review the "Unit" tab for this product.')).subscribe(),this.popup.close();this.popup.params.resolve({unit_quantity_id:a.id,unit_name:a.unit.name,$quantities:()=>a}),this.popup.close()}}},he={class:"h-full w-full flex items-center justify-center",id:"ns-units-selector"},me={key:0,class:"ns-box w-4/5-screen lg:w-1/3-screen overflow-hidden flex flex-col"},fe={id:"header",class:"h-16 flex justify-center items-center flex-shrink-0"},ye={class:"font-bold text-primary"},xe={key:0,class:"grid grid-flow-row grid-cols-2 overflow-y-auto"},ge=["onClick"],be={class:"h-40 w-full flex items-center justify-center overflow-hidden"},ve=["src","alt"],we={key:1,class:"h-40 flex items-center justify-center"},Pe=n("i",{class:"las la-image text-primary text-6xl"},null,-1),ke=[Pe],Ce={class:"h-0 w-full"},Ve={class:"relative w-full flex items-center justify-center -top-10 h-20 py-2 flex-col overlay"},Te={class:"font-bold text-primary py-2 text-center"},Se={class:"text-sm font-medium text-primary"},Oe={key:1,class:"h-56 flex items-center justify-center"};function Ae(a,e,t,s,i,r){const o=Q("ns-spinner");return p(),h("div",he,[i.unitsQuantities.length>0?(p(),h("div",me,[n("div",fe,[n("h3",ye,c(r.__("{product} : Units").replace("{product}",r.productName)),1)]),i.unitsQuantities.length>0?(p(),h("div",xe,[(p(!0),h(U,null,R(i.unitsQuantities,u=>(p(),h("div",{onClick:l=>r.selectUnit(u),key:u.id,class:"ns-numpad-key info cursor-pointer border flex-shrink-0 flex flex-col items-center justify-center"},[n("div",be,[u.preview_url?(p(),h("img",{key:0,src:u.preview_url,class:"object-cover h-full",alt:u.unit.name},null,8,ve)):f("",!0),u.preview_url?f("",!0):(p(),h("div",we,ke))]),n("div",Ce,[n("div",Ve,[n("h3",Te,c(u.unit.name)+" ("+c(u.quantity)+")",1),n("p",Se,c(r.nsCurrency(r.displayRightPrice(u))),1)])])],8,ge))),128))])):f("",!0)])):f("",!0),i.unitsQuantities.length===0?(p(),h("div",Oe,[I(o)])):f("",!0)])}const qe=O(_e,[["render",Ae]]);class je{constructor(e){this.product=e}run(){return new Promise((e,t)=>{const s=this.product;b.show(qe,{resolve:e,reject:t,product:s})})}}class G{constructor(e){this.order=e}run(){return new Promise((e,t)=>this.order.customer===void 0?b.show(ee,{resolve:e,reject:t}):e(!0))}}window.CustomerQueue=G;const Qe={name:"sample-payment",props:["label","identifier"],data(){return{backValue:"0",number:parseInt(1+new Array(parseInt(ns.currency.ns_currency_precision)).fill("").map(a=>0).join("")),order:null,settings:{},settingsSubscription:null,cursor:parseInt(ns.currency.ns_currency_precision),orderSubscription:null,allSelected:!0,keys:[...[7,8,9].map(a=>({identifier:a,value:a})),...[4,5,6].map(a=>({identifier:a,value:a})),...[1,2,3].map(a=>({identifier:a,value:a})),{identifier:"backspace",icon:"la-backspace"},{identifier:0,value:0},{identifier:"next",icon:"la-share"}]}},computed:{amountShortcuts(){return nsShortcuts.ns_pos_amount_shortcut!==null?nsShortcuts.ns_pos_amount_shortcut.split("|"):[]}},mounted(){this.orderSubscription=POS.order.subscribe(e=>{this.order=e}),this.settingsSubscription=POS.settings.subscribe(e=>{this.settings=e});const a=new Array(10).fill("").map((e,t)=>t);nsHotPress.create("numpad-keys").whenVisible([".is-popup"]).whenPressed(a,(e,t)=>{this.inputValue({value:t})}),nsHotPress.create("numpad-backspace").whenVisible([".is-popup"]).whenPressed("backspace",()=>this.inputValue({identifier:"backspace"})),nsHotPress.create("numpad-save").whenVisible([".is-popup"]).whenPressed("enter",()=>{this.backValue===""?(this.$emit("submit"),this.backValue=0):this.inputValue({identifier:"next"})})},beforeDestroy(){nsHotPress.destroy("numpad-keys"),nsHotPress.destroy("numpad-backspace"),nsHotPress.destroy("numpad-save")},unmounted(){this.orderSubscription.unsubscribe()},methods:{__:d,nsCurrency:S,toggleDiscount(){if(this.settings.cart_discount!==void 0&&this.settings.cart_discount===!0)b.show(te,{reference:this.order,type:"cart",onSubmit:a=>{POS.updateCart(this.order,a)}});else return x.error(d("You're not allowed to add a discount on the cart.")).subscribe()},makeFullPayment(){POS.order.getValue(),b.show($,{title:d("Confirm Full Payment"),message:d("A full payment will be made using {paymentType} for {total}").replace("{paymentType}",this.label).replace("{total}",S(this.order.total)),onAction:a=>{if(a){const e=POS.order.getValue();e.tendered0).join(""));this.backValue=(parseFloat(a.value)*e+(parseFloat(this.backValue)||0)).toString(),this.allSelected=!1},inputValue(a){a.identifier==="next"?(POS.addPayment({value:parseFloat(this.backValue/this.number),identifier:this.identifier,selected:!1,label:this.label,readonly:!1}),this.backValue="0"):a.identifier==="backspace"?this.allSelected?(this.backValue="0",this.allSelected=!1):this.backValue=this.backValue.slice(0,-1):a.value.toString().match(/^\d+$/)&&(this.allSelected?(this.backValue=a.value.toString(),this.allSelected=!1):(this.backValue+=a.value.toString(),this.mode==="percentage"&&(this.backValue=this.backValue>100?100:this.backValue))),this.backValue==="0"&&(this.backValue="")}}},Ee={class:"h-full w-full py-2"},Ie={key:0,class:"px-2 pb-2"},Ue={class:"grid grid-cols-2 gap-2"},Re={id:"details",class:"h-16 flex justify-between items-center border elevation-surface info text-xl md:text-3xl p-2"},$e={id:"paid",class:"h-16 flex justify-between items-center border elevation-surface success text-xl md:text-3xl p-2"},Fe={id:"change",class:"h-16 flex justify-between items-center border elevation-surface warning text-xl md:text-3xl p-2"},Be={id:"change",class:"col-span-2 h-16 flex justify-between items-center elevation-surface border text-xl md:text-3xl p-2"},Le={class:"px-2 pb-2"},We={class:"-mx-2 flex flex-wrap"},De={class:"pl-2 pr-1 flex-auto"},Ne={id:"numpad",class:"grid grid-flow-row grid-cols-3 gap-2 grid-rows-3",style:{padding:"1px"}},He=["onClick"],ze={key:0},Ge={class:"w-1/2 md:w-72 pr-2 pl-1"},Ye={class:"grid grid-flow-row grid-rows-1 gap-2"},Me=["onClick"];function Ke(a,e,t,s,i,r){return p(),h("div",Ee,[i.order?(p(),h("div",Ie,[n("div",Ue,[n("div",Re,[n("span",null,c(r.__("Total"))+" : ",1),n("span",null,c(r.nsCurrency(i.order.total)),1)]),n("div",{id:"discount",onClick:e[0]||(e[0]=o=>r.toggleDiscount()),class:"cursor-pointer h-16 flex justify-between items-center border elevation-surface error text-xl md:text-3xl p-2"},[n("span",null,c(r.__("Discount"))+" : ",1),n("span",null,c(r.nsCurrency(i.order.discount)),1)]),n("div",$e,[n("span",null,c(r.__("Paid"))+" : ",1),n("span",null,c(r.nsCurrency(i.order.tendered)),1)]),n("div",Fe,[n("span",null,c(r.__("Change"))+" : ",1),n("span",null,c(r.nsCurrency(i.order.change)),1)]),n("div",Be,[n("span",null,c(r.__("Screen"))+" : ",1),n("span",null,c(r.nsCurrency(i.backValue/i.number)),1)])])])):f("",!0),n("div",Le,[n("div",We,[n("div",De,[n("div",Ne,[(p(!0),h(U,null,R(i.keys,(o,u)=>(p(),h("div",{onClick:l=>r.inputValue(o),key:u,style:{margin:"-1px"},class:"ns-numpad-key text-2xl border h-16 flex items-center justify-center cursor-pointer"},[o.value!==void 0?(p(),h("span",ze,c(o.value),1)):f("",!0),o.icon?(p(),h("i",{key:1,class:L(["las",o.icon])},null,2)):f("",!0)],8,He))),128)),n("div",{onClick:e[1]||(e[1]=o=>r.makeFullPayment()),class:"hover:bg-green-500 col-span-3 bg-success-secondary border-success-tertiary text-2xl text-white border h-16 flex items-center justify-center cursor-pointer"},c(r.__("Full Payment")),1)])]),n("div",Ge,[n("div",Ye,[(p(!0),h(U,null,R(r.amountShortcuts,(o,u)=>(p(),h("div",{key:u,onClick:l=>r.increaseBy({value:o}),class:"ns-numpad-key text-2xl border h-16 flex items-center justify-center cursor-pointer"},[n("span",null,c(r.nsCurrency(o)),1)],8,Me))),128))])])])])])}const D=O(Qe,[["render",Ke]]),Je={name:"cash-payment",props:["identifier","label"],components:{samplePayment:D}};function Xe(a,e,t,s,i,r){const o=Q("sample-payment");return p(),j(o,{identifier:t.identifier,label:t.label},null,8,["identifier","label"])}const Ze=O(Je,[["render",Xe]]),et={name:"creditcart-payment",props:["identifier"]};function tt(a,e,t,s,i,r){return p(),h("h1",null,"Credit Card")}const st=O(et,[["render",tt]]),it={name:"bank-payment",props:["identifier","label"],components:{samplePayment:D}};function rt(a,e,t,s,i,r){const o=Q("sample-payment");return p(),j(o,{identifier:t.identifier,label:t.label},null,8,["identifier","label"])}const nt=O(it,[["render",rt]]),ot={name:"ns-account-payment",components:{nsNumpad:le},props:["identifier","label"],data(){return{subscription:null,screenValue:0,order:null}},methods:{__:d,nsCurrency:S,handleChange(a){this.screenValue=a},proceedAddingPayment(a){const e=parseFloat(a),t=this.order.payments;if(e<=0)return x.error(d("Please provide a valid payment amount.")).subscribe();if(t.filter(s=>s.identifier==="account-payment").length>0)return x.error(d("The customer account can only be used once per order. Consider deleting the previously used payment.")).subscribe();if(e>this.order.customer.account_amount)return x.error(d("Not enough funds to add {amount} as a payment. Available balance {balance}.").replace("{amount}",this.$options.filters.currency(e)).replace("{balance}",this.$options.filters.currency(this.order.customer.account_amount))).subscribe();POS.addPayment({value:e,identifier:"account-payment",selected:!1,label:this.label,readonly:!1}),this.order.customer.account_amount-=e,POS.selectCustomer(this.order.customer),this.$emit("submit")},proceedFullPayment(){this.proceedAddingPayment(this.order.total)},makeFullPayment(){Popup.show($,{title:d("Confirm Full Payment"),message:d("You're about to use {amount} from the customer account to make a payment. Would you like to proceed ?").replace("{amount}",this.$options.filters.currency(this.order.total)),onAction:a=>{a&&this.proceedFullPayment()}})}},mounted(){this.subscription=POS.order.subscribe(a=>this.order=a)},unmounted(){this.subscription.unsubscribe()}},at={class:"h-full w-full py-2"},ut={key:0,class:"px-2 pb-2"},lt={class:"grid grid-cols-2 gap-2"},ct={id:"details",class:"h-16 flex justify-between items-center elevation-surface border info text-xl md:text-3xl p-2"},dt={id:"paid",class:"h-16 flex justify-between items-center elevation-surface success border text-xl md:text-3xl p-2"},pt={id:"change",class:"h-16 flex justify-between items-center elevation-surface warning border text-xl md:text-3xl p-2"},_t={id:"change",class:"col-span-2 h-16 flex justify-between items-center elevation-surface border success text-xl md:text-3xl p-2"},ht={id:"change",class:"col-span-2 h-16 flex justify-between items-center elevation-surface border text-primary text-xl md:text-3xl p-2"},mt={class:"px-2 pb-2"},ft={class:"-mx-2 flex flex-wrap"},yt={class:"pl-2 pr-1 flex-auto"},xt={class:"w-1/2 md:w-72 pr-2 pl-1"},gt={class:"grid grid-flow-row grid-rows-1 gap-2"};function bt(a,e,t,s,i,r){const o=Q("ns-numpad");return p(),h("div",at,[i.order?(p(),h("div",ut,[n("div",lt,[n("div",ct,[n("span",null,c(r.__("Total"))+" : ",1),n("span",null,c(r.nsCurrency(i.order.total)),1)]),n("div",{id:"discount",onClick:e[0]||(e[0]=u=>a.toggleDiscount()),class:"cursor-pointer h-16 flex justify-between items-center elevation-surface error border text-xl md:text-3xl p-2"},[n("span",null,c(r.__("Discount"))+" : ",1),n("span",null,c(r.nsCurrency(i.order.discount)),1)]),n("div",dt,[n("span",null,c(r.__("Paid"))+" : ",1),n("span",null,c(r.nsCurrency(i.order.tendered)),1)]),n("div",pt,[n("span",null,c(r.__("Change"))+" : ",1),n("span",null,c(r.nsCurrency(i.order.change)),1)]),n("div",_t,[n("span",null,c(r.__("Current Balance"))+" : ",1),n("span",null,c(r.nsCurrency(i.order.customer.account_amount)),1)]),n("div",ht,[n("span",null,c(r.__("Screen"))+" : ",1),n("span",null,c(r.nsCurrency(i.screenValue)),1)])])])):f("",!0),n("div",mt,[n("div",ft,[n("div",yt,[I(o,{floating:!0,onChanged:e[2]||(e[2]=u=>r.handleChange(u)),onNext:e[3]||(e[3]=u=>r.proceedAddingPayment(u))},{"numpad-footer":E(()=>[n("div",{onClick:e[1]||(e[1]=u=>r.makeFullPayment()),class:"hover:bg-success-tertiary col-span-3 bg-success-secondary text-2xl text-white border border-success-secondary h-16 flex items-center justify-center cursor-pointer"},c(r.__("Full Payment")),1)]),_:1})]),n("div",xt,[n("div",gt,[n("div",{onClick:e[4]||(e[4]=u=>a.increaseBy({value:100})),class:"elevation-surface border hoverable text-2xl text-primary h-16 flex items-center justify-center cursor-pointer"},[n("span",null,c(r.nsCurrency(100)),1)]),n("div",{onClick:e[5]||(e[5]=u=>a.increaseBy({value:500})),class:"elevation-surface border hoverable text-2xl text-primary h-16 flex items-center justify-center cursor-pointer"},[n("span",null,c(r.nsCurrency(500)),1)]),n("div",{onClick:e[6]||(e[6]=u=>a.increaseBy({value:1e3})),class:"elevation-surface border hoverable text-2xl text-primary h-16 flex items-center justify-center cursor-pointer"},[n("span",null,c(r.nsCurrency(1e3)),1)])])])])])])}const vt=O(ot,[["render",bt]]),wt={name:"ns-pos-payment",props:["popup"],data(){return{paymentTypesSubscription:null,paymentsType:[],activePayment:null,order:null,showPayment:!1,orderSubscription:null,currentPaymentComponent:null,activePaymentSubscription:null}},computed:{expectedPayment(){const a=this.order.customer.group.minimal_credit_payment;return this.order.total*a/100}},mounted(){this.orderSubscription=POS.order.subscribe(a=>{this.order=ae(a)}),this.activePaymentSubscription=POS.selectedPaymentType.subscribe(a=>{this.activePayment=a,a!==null&&this.loadPaymentComponent(a)}),this.paymentTypesSubscription=POS.paymentsType.subscribe(a=>{this.paymentsType=a,a.filter(e=>{e.selected&&POS.selectedPaymentType.next(e)})}),nsHooks.doAction("ns-pos-payment-mounted",this)},unmounted(){this.activePaymentSubscription.unsubscribe(),this.paymentTypesSubscription.unsubscribe(),this.orderSubscription.unsubscribe(),nsHooks.doAction("ns-pos-payment-destroyed",this)},methods:{__:d,nsCurrency:S,resolveIfQueued:z,loadPaymentComponent(a){switch(a.identifier){case"cash-payment":this.currentPaymentComponent=shallowRef(Ze);break;case"creditcard-payment":this.currentPaymentComponent=shallowRef(st);break;case"bank-payment":this.currentPaymentComponent=shallowRef(nt);break;case"account-payment":this.currentPaymentComponent=shallowRef(vt);break;default:this.currentPaymentComponent=shallowRef(D);break}},async selectPayment(){try{const a=await new Promise((e,t)=>{b.show(ce,{label:d("Select Payment Gateway"),options:this.paymentsType.map(s=>({label:s.label,value:s.identifier})),value:this.activePayment.identifier,resolve:e,reject:t})});this.select(this.paymentsType.filter(e=>e.identifier===a[0].value)[0])}catch{}},select(a){this.showPayment=!1,POS.setPaymentActive(a)},closePopup(){this.popup.close(),POS.selectedPaymentType.next(null)},deletePayment(a){POS.removePayment(a)},selectPaymentAsActive(a){this.select(this.paymentsType.filter(e=>e.identifier===a.target.value)[0])},async submiAsUnpaid(){let a;try{a=await new Promise(t=>{const s=b.show($,{title:d("Save As Unpaid"),message:d("Are you sure you want to save this order as unpaid?"),onAction:i=>{t(i)}})})}catch(t){x.error(t.message||d("An unexpected error occured while saving the order as unpaid.")).subscribe(),console.log(t)}if(!a)return!1;const e=b.show(W);try{POS.order.next({...POS.order.getValue(),payments:[]}),POS.refreshCart();const t=await new Promise((s,i)=>{POS.proceedSubmitting(POS.order.getValue(),s,i)});e.close(),this.popup.close(),x.success(t.message).subscribe(),POS.printOrderReceipt(t.data.order,"silent")}catch(t){e.close(),x.error(t.message||d("An error occured while saving the order as unpaid.")).subscribe()}},getPaymentLabel(a){const e=this.paymentsType.filter(t=>t.identifier===a.identifier)[0];return e?e.label:a.identifier},submitOrder(a={}){const e=b.show(W);try{const t={...POS.order.getValue(),...a};POS.submitOrder(t).then(s=>{e.close(),x.success(s.message).subscribe(),POS.printOrderReceipt(s.data.order,"silent"),this.popup.close()},s=>{e.close(),x.error(s.message).subscribe()})}catch(t){e.close(),x.error(t.message||d("An unexpected error occured while submitting the order.")).subscribe(),console.log(t)}}}},Pt={key:0,id:"ns-payment-popup",class:"w-screen h-screen p-8 flex overflow-hidden"},kt={class:"flex flex-col flex-auto lg:flex-row shadow-xl"},Ct={class:"w-full lg:w-56 lg:h-full flex justify-between px-2 lg:px-0 lg:block items-center lg:items-start"},Vt={class:"lg:hidden text-xl text-center my-4 font-bold lg:my-8"},Tt={key:0},St=n("div",{class:"h-16 hidden lg:block"},null,-1),Ot={class:"hidden lg:block"},At=["onClick"],qt={class:"px-2 rounded-full h-8 w-8 flex items-center justify-center ns-label"},jt={class:"overflow-hidden flex flex-col flex-auto"},Qt={class:"flex flex-col flex-auto overflow-hidden"},Et={class:"h-12 hidden items-center justify-between lg:flex"},It={class:"text-xl hidden lg:block text-center my-4 font-bold lg:my-8"},Ut={key:0,class:"hidden-md"},Rt={class:"px-2"},$t={key:0,class:"flex flex-auto ns-payment-wrapper overflow-y-auto"},Ft={key:1,class:"flex flex-auto items-center justify-center bg-white"},Bt={class:"font-bold text-center text-3xl"},Lt={class:"text-center"},Wt={key:2,class:"flex flex-auto ns-payment-wrapper overflow-y-auto p-2 flex-col"},Dt={class:"text-center font-bold py-2"},Nt={class:"flex-auto"},Ht={key:0,class:"p-2 flex justify-center mb-2 items-center"},zt={class:"font-semibold"},Gt={class:"flex items-center"},Yt=["onClick"],Mt=n("i",{class:"las la-trash-alt"},null,-1),Kt=[Mt],Jt={key:1,class:"default rounded-full h-8 w-8 flex items-center justify-center ml-2"},Xt=n("i",{class:"las la-lock"},null,-1),Zt=[Xt],es={key:0,class:"flex lg:hidden ns-payment-buttons"},ts={class:"text-sm"},ss={class:"text-sm"},is={class:"text-sm"},rs={class:"text-sm mr-1"},os={class:"px-2 rounded-full h-6 w-6 text-xs flex items-center justify-center ns-label"},as={key:1,class:"flex-col sm:flex-row w-full ns-payment-footer justify-end p-2 hidden lg:flex"},us={class:"flex justify-end"},ls=n("i",{class:"las la-cash-register"},null,-1),cs={key:1,class:"flex -mx-2"},ds={class:"px-2"},ps=n("i",{class:"las la-bookmark"},null,-1),_s=n("i",{class:"las la-save"},null,-1),hs={key:0,class:"px-2"},ms=n("i",{class:"las la-hands-helping"},null,-1);function fs(a,e,t,s,i,r){const o=Q("ns-close-button"),u=Q("ns-button");return i.order?(p(),h("div",Pt,[n("div",kt,[n("div",Ct,[n("h3",Vt,[q(c(r.__("Gateway"))+" ",1),i.activePayment?(p(),h("span",Tt,": "+c(i.activePayment.label),1)):f("",!0)]),St,n("ul",Ot,[(p(!0),h(U,null,R(i.paymentsType,l=>(p(),h("li",{onClick:y=>r.select(l),class:L([l.selected&&!i.showPayment?"ns-visible":"","cursor-pointer ns-payment-gateway py-2 px-3"]),key:l.identifier},c(l.label),11,At))),128)),i.paymentsType.length>0?(p(),h("li",{key:0,onClick:e[0]||(e[0]=l=>i.showPayment=!0),class:L([i.showPayment?"ns-visible":"","cursor-pointer py-2 px-3 ns-payment-list border-t mt-4 flex items-center justify-between"])},[n("span",null,c(r.__("Payment List")),1),n("span",qt,c(i.order.payments.length),1)],2)):f("",!0)]),I(o,{class:"lg:hidden",onClick:e[1]||(e[1]=l=>r.closePopup())})]),n("div",jt,[n("div",Qt,[n("div",Et,[n("div",null,[n("h3",It,[q(c(r.__("Gateway"))+" ",1),i.activePayment?(p(),h("span",Ut,": "+c(i.activePayment.label),1)):f("",!0)])]),n("div",Rt,[I(o,{onClick:e[2]||(e[2]=l=>r.closePopup())})])]),!i.showPayment&&i.activePayment?(p(),h("div",$t,[(p(),j(ue(i.currentPaymentComponent),{onSubmit:e[3]||(e[3]=l=>r.submitOrder()),label:i.activePayment.label,identifier:i.activePayment.identifier},null,40,["label","identifier"]))])):f("",!0),i.activePayment?f("",!0):(p(),h("div",Ft,[n("div",null,[n("h3",Bt,c(r.__("Unable to Proceed")),1),n("p",Lt,c(r.__("Your system doesn't have any valid Payment Type. Consider creating one and try again.")),1)])])),i.showPayment?(p(),h("div",Wt,[n("h3",Dt,c(r.__("List Of Payments")),1),n("ul",Nt,[i.order.payments.length===0?(p(),h("li",Ht,[n("h3",zt,c(r.__("No Payment added.")),1)])):f("",!0),(p(!0),h(U,null,R(i.order.payments,(l,y)=>(p(),h("li",{key:y,class:"p-2 flex justify-between mb-2 items-center"},[n("span",null,c(r.getPaymentLabel(l)),1),n("div",Gt,[n("span",null,c(r.nsCurrency(l.value)),1),l.id?f("",!0):(p(),h("button",{key:0,onClick:_=>r.deletePayment(l),class:"error rounded-full h-8 w-8 flex items-center justify-center ml-2"},Kt,8,Yt)),l.id?(p(),h("button",Jt,Zt)):f("",!0)])]))),128))])])):f("",!0)]),i.activePayment?(p(),h("div",es,[n("button",{onClick:e[4]||(e[4]=l=>r.selectPayment()),class:"flex items-center justify-center w-1/3 text-2xl flex-auto h-12 font-bold ns-payment-type-button"},[n("span",ts,c(r.__("Payment Type")),1)]),i.order.tendered>=i.order.total?(p(),h("button",{key:0,onClick:e[5]||(e[5]=l=>r.submitOrder()),class:"flex items-center justify-center w-1/3 text-2xl flex-auto h-12 ns-submit-button font-bold"},[n("span",ss,c(r.__("Submit Payment")),1)])):f("",!0),i.order.tenderedr.submitOrder({payment_status:"unpaid"})),class:"flex items-center justify-center w-1/3 text-2xl flex-auto h-12 ns-layaway-button font-bold"},[n("span",is,c(r.__("Layaway")),1)])):f("",!0),n("button",{onClick:e[7]||(e[7]=l=>i.showPayment=!0),class:"w-1/3 flex ns-payment-button text-2xl flex-auto h-12 items-center justify-center font-bold"},[n("span",rs,c(r.__("Payment List")),1),n("span",os,c(i.order.payments.length),1)])])):f("",!0),i.activePayment?(p(),h("div",as,[n("div",us,[i.order.tendered>=i.order.total?(p(),j(u,{key:0,onClick:e[8]||(e[8]=l=>r.submitOrder()),type:i.order.tendered>=i.order.total?"success":"info"},{default:E(()=>[n("span",null,[ls,q(" "+c(r.__("Submit Payment")),1)])]),_:1},8,["type"])):f("",!0),i.order.tenderedr.submitOrder({payment_status:"unpaid"})),type:i.order.tendered>=i.order.total?"success":"info"},{default:E(()=>[n("span",null,[ps,q(" "+c(r.__("Layaway"))+" — "+c(r.nsCurrency(r.expectedPayment)),1)])]),_:1},8,["type"])):f("",!0),i.order.tendered>0?(p(),j(u,{key:1,onClick:e[10]||(e[10]=l=>r.submitOrder({payment_status:"unpaid"})),type:"info"},{default:E(()=>[n("span",null,[_s,q(" "+c(r.__("Update")),1)])]),_:1})):f("",!0)]),i.order.tendered===0?(p(),h("div",hs,[I(u,{onClick:e[11]||(e[11]=l=>r.submiAsUnpaid()),type:"info"},{default:E(()=>[n("span",null,[ms,q(" "+c(r.__("Save As Unpaid")),1)])]),_:1})])):f("",!0)])):f("",!0)])])):f("",!0)])])])):f("",!0)}const ys=O(wt,[["render",fs]]);class Y{constructor(e){this.order=e}run(){return new Promise((e,t)=>{b.show(ys,{resolve:e,reject:t,order:this.order})})}}window.PaymentQueue=Y;class M{constructor(e){this.order=e}run(){return new Promise((e,t)=>this.order.products.length===0?(x.error(d("You need to provide some products before proceeding.")).subscribe(),t(!1)):e(!0))}}window.ProductsQueue=M;class K{constructor(e){this.order=e}run(){return new Promise((e,t)=>{if(this.order.type===void 0)return b.show(se,{resolve:e,reject:t});e(!0)})}}window.TypeQueue=K;class xs{constructor(){g(this,"screenIs");this.detect()}detect(){window.innerWidth<544?this.screenIs="xs":window.innerWidth>=544&&window.innerWidth<768?this.screenIs="sm":window.innerWidth>=768&&window.innerWidth<992?this.screenIs="md":window.innerWidth>=992&&window.innerWidth<1200?this.screenIs="lg":window.innerWidth>=1200&&(this.screenIs="xl")}is(e){return e===void 0?this.screenIs:this.screenIs===e}}const gs=window.nsPosDashboardButton=T(()=>V(()=>import("./ns-pos-dashboard-button-ad57275c.js"),["./ns-pos-dashboard-button-ad57275c.js","./currency-feccde3d.js","./_plugin-vue_export-helper-c27b6911.js","./runtime-core.esm-bundler-414a078a.js"],import.meta.url)),bs=window.nsPosPendingOrderButton=T(()=>V(()=>import("./ns-pos-pending-orders-button-4960c118.js"),["./ns-pos-pending-orders-button-4960c118.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css"],import.meta.url)),vs=window.nsPosOrderTypeButton=T(()=>V(()=>import("./ns-pos-order-type-button-9db68cc6.js"),["./ns-pos-order-type-button-9db68cc6.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-pos-order-type-popup-14f46b3a.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-orders-preview-popup-3c654295.js","./index.es-25aa42ee.js"],import.meta.url)),ws=window.nsPosCustomersButton=T(()=>V(()=>import("./ns-pos-customers-button-4d5fee4f.js"),["./ns-pos-customers-button-4d5fee4f.js","./preload-helper-41c905a7.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./_plugin-vue_export-helper-c27b6911.js"],import.meta.url)),Ps=window.nsPosResetButton=T(()=>V(()=>import("./ns-pos-reset-button-32b971e5.js"),["./ns-pos-reset-button-32b971e5.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css"],import.meta.url)),ks=window.nsPosCashRegister=T(()=>V(()=>import("./ns-pos-registers-button-0ba2bc51.js"),["./ns-pos-registers-button-0ba2bc51.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css"],import.meta.url)),Cs=window.nsLayawayPopup=T(()=>V(()=>import("./ns-pos-layaway-popup-0b54a3bc.js"),["./ns-pos-layaway-popup-0b54a3bc.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./_plugin-vue_export-helper-c27b6911.js"],import.meta.url)),Vs=window.nsPosShippingPopup=T(()=>V(()=>import("./ns-pos-shipping-popup-5ba7ac6e.js"),["./ns-pos-shipping-popup-5ba7ac6e.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./_plugin-vue_export-helper-c27b6911.js"],import.meta.url));window.CustomerQueue=G;window.PaymentQueue=Y;window.ProductsQueue=M;window.TypeQueue=K;let J=class{constructor(){g(this,"_cartButtons");g(this,"_products");g(this,"_breadcrumbs");g(this,"_customers");g(this,"_settings");g(this,"_types");g(this,"_orderTypeProcessQueue",[]);g(this,"_paymentsType");g(this,"_order");g(this,"_screen");g(this,"_holdPopupEnabled",!0);g(this,"_initialQueue",[]);g(this,"_options");g(this,"_responsive",new xs);g(this,"_visibleSection");g(this,"_isSubmitting",!1);g(this,"_processingAddQueue",!1);g(this,"_selectedPaymentType");g(this,"_userPermissions");g(this,"print");g(this,"defaultOrder",()=>({discount_type:null,title:"",discount:0,register_id:this.get("register")?this.get("register").id:void 0,discount_percentage:0,subtotal:0,total:0,coupons:[],total_coupons:0,tendered:0,note:"",note_visibility:"hidden",tax_group_id:void 0,tax_type:void 0,taxes:[],tax_groups:[],payment_status:void 0,customer_id:void 0,change:0,total_products:0,shipping:0,tax_value:0,products_exclusive_tax_value:0,products_inclusive_tax_value:0,total_tax_value:0,shipping_rate:0,shipping_type:void 0,customer:void 0,type:void 0,products:[],instalments:[],payments:[],addresses:{shipping:void 0,billing:void 0}}));g(this,"addToCartQueue",[je,ie]);this.initialize(),this.print=new ne({urls:systemUrls,options:systemOptions})}get screen(){return this._screen}get visibleSection(){return this._visibleSection}get paymentsType(){return this._paymentsType}get selectedPaymentType(){return this._selectedPaymentType}get order(){return this._order}get types(){return this._types}get products(){return this._products}get customers(){return this._customers}get options(){return this._options}get orderTypeQueue(){return this._orderTypeProcessQueue}get settings(){return this._settings}get breadcrumbs(){return this._breadcrumbs}get initialQueue(){return this._initialQueue}get responsive(){return this._responsive}get processingAddQueue(){return this._processingAddQueue}get cartButtons(){return this._cartButtons}async reset(){return new Promise(async(e,t)=>{try{this._isSubmitting=!1,this.order.next(this.defaultOrder()),this.products.next([]),this._customers.next([]),this._breadcrumbs.next([]),this._cartButtons.next({}),this.defineCurrentScreen(),this.setHoldPopupEnabled(!0),v.doAction("ns-before-cart-reset"),await this.processInitialQueue(),v.doAction("ns-after-cart-changed"),v.doAction("ns-after-cart-reset"),e(!0)}catch(s){t(s)}})}initialize(){this._userPermissions=new P([]),this._products=new P([]),this._customers=new P([]),this._types=new P([]),this._breadcrumbs=new P([]),this._screen=new P(""),this._paymentsType=new P([]),this._visibleSection=new P("both"),this._options=new P({}),this._settings=new P({}),this._order=new P(this.defaultOrder()),this._selectedPaymentType=new P(null),this._cartButtons=new P({}),this._orderTypeProcessQueue=[{identifier:"handle.delivery-order",promise:e=>new Promise((t,s)=>e&&e.identifier==="delivery"?b.show(Vs,{resolve:t,reject:s}):t({status:"success",message:"Proceed"}))}],this.initialQueue.push(()=>new Promise((e,t)=>{C.get("/api/users/permissions/").subscribe({next:s=>{this._userPermissions.next(s),e(s)},error:s=>{t(s)}})})),this.initialQueue.push(()=>new Promise((e,t)=>{const s=this.options.getValue(),i=this.order.getValue();return i.tax_type=s.ns_pos_tax_type,s.ns_pos_tax_group!==!1&&(i.tax_group_id=s.ns_pos_tax_group,this.order.next(i)),e({status:"success",message:"tax group assignated"})})),this.initialQueue.push(()=>new Promise((e,t)=>{const s=this.options.getValue();return this.order.getValue(),s.ns_customers_default!==!1&&C.get(`/api/customers/${s.ns_customers_default}`).subscribe({next:i=>{this.selectCustomer(i),e({status:"success",message:d("The customer has been loaded")})},error:i=>{N.error(d("An error has occured"),d("Unable to select the default customer. Looks like the customer no longer exists. Consider changing the default customer on the settings."),{actions:{readMore:{label:d("Read More"),onClick:r=>{r.close(),window.open("https://my.nexopos.com/en/documentation/troubleshooting/no-default-customer","_blank")}},close:{label:d("Close")}}}),t(i)}}),e({status:"success",message:"no default customer is selected."})})),v.addAction("ns-after-cart-changed","listen-add-to-cart",()=>this.refreshCart()),this.types.subscribe(e=>{const t=Object.values(e).filter(s=>s.selected);if(t.length>0){const s=this.order.getValue();s.type=t[0],this.order.next(s)}}),window.addEventListener("resize",()=>{this._responsive.detect(),this.defineCurrentScreen()}),window.onbeforeunload=()=>{if(this.products.getValue().length>0)return d("Some products has been added to the cart. Would youl ike to discard this order ?")}}getSalePrice(e,t){return this.options.getValue().ns_pos_price_with_tax==="yes"?A(e.sale_price_with_tax):A(e.sale_price_without_tax)}getCustomPrice(e,t){return this.options.getValue().ns_pos_price_with_tax==="yes"?A(e.custom_price_with_tax):A(e.custom_price_without_tax)}getWholesalePrice(e,t){return this.options.getValue().ns_pos_price_with_tax==="yes"?A(e.wholesale_price_with_tax):A(e.wholesale_price_without_tax)}setHoldPopupEnabled(e=!0){this._holdPopupEnabled=e}getHoldPopupEnabled(){return this._holdPopupEnabled}async processInitialQueue(){return new Promise(async(e,t)=>{for(let s in this._initialQueue)try{const i=await Promise.race([this._initialQueue[s](),new Promise((r,o)=>setTimeout(()=>o(new Error("Timeout")),6e4))])}catch(i){t(i),x.error(i.message).subscribe()}e(!0)})}removeCoupon(e){const t=this.order.getValue(),s=t.coupons,i=s.indexOf(e);s.splice(i,1),t.coupons=s,this.order.next(t)}pushCoupon(e){const t=this.order.getValue();t.coupons.forEach(s=>{if(s.code===e.code){const i=d("This coupon is already added to the cart");throw x.error(i).subscribe(),i}}),t.coupons.push(e),this.order.next(t),this.refreshCart()}get header(){const e={buttons:{nsPosDashboardButton:gs,nsPosPendingOrderButton:bs,nsPosOrderTypeButton:vs,nsPosCustomersButton:ws,nsPosResetButton:Ps}};return this.options.getValue().ns_pos_registers_enabled==="yes"&&(e.buttons.nsPosCashRegister=ks),v.doAction("ns-pos-header",e),e}defineOptions(e){this._options.next(e)}defineCurrentScreen(){this._visibleSection.next(["xs","sm"].includes(this._responsive.is())?"grid":"both"),this._screen.next(this._responsive.is())}changeVisibleSection(e){["both","cart","grid"].includes(e)&&(["cart","both"].includes(e)&&this.refreshCart(),this._visibleSection.next(e))}addPayment(e){if(e.value>0){const t=this._order.getValue();return t.payments.push(e),this._order.next(t),this.computePaid()}return x.error("Invalid amount.").subscribe()}removePayment(e){if(e.id!==void 0)return x.error(d("Unable to delete a payment attached to the order.")).subscribe();const t=this._order.getValue(),s=t.payments.indexOf(e);t.payments.splice(s,1),this._order.next(t),nsEvent.emit({identifier:"ns.pos.remove-payment",value:e}),this.updateCustomerAccount(e),this.computePaid()}updateCustomerAccount(e){if(e.identifier==="account-payment"){const t=this.order.getValue().customer;t.account_amount+=e.value,this.selectCustomer(t)}}getPriceWithoutTax(e,t,s){if(s==="inclusive")return H.computeInclusive(e,t);if(s==="exclusive")return e}getPriceWithTax(e,t,s){if(s==="inclusive")return e;if(s==="exclusive")return H.computeExclusive(e,t)}getVatValue(e,t,s){return s==="inclusive"?e-this.getPriceWithoutTax(e,t,s):s==="exclusive"?this.getPriceWithTax(e,t,s)-e:0}computeTaxes(){return new Promise((e,t)=>{let s=this.order.getValue();if(s=this.computeProductsTaxes(s),s.tax_group_id===void 0||s.tax_group_id===null)return this.computeOrderTaxes(s),e({data:{order:s},status:"success"});const i=s.tax_groups;if(Object.values(i).length>0)return i[s.tax_group_id]!==void 0&&(s=this.computeOrderTaxGroup(s,i[s.tax_group_id])),e({status:"success",data:{tax:i[s.tax_group_id],order:s}});if(s.tax_group_id!==void 0&&s.tax_group_id.toString().length>0)C.get(`/api/taxes/groups/${s.tax_group_id}`).subscribe({next:r=>(s=this.computeOrderTaxGroup(s,r),e({status:"success",data:{tax:r,order:s}})),error:r=>t(r)});else return t({status:"error",message:d("No tax group assigned to the order")})})}computeOrderTaxGroup(e,t){const s=t.taxes.map(r=>parseFloat(r.rate)).reduce((r,o)=>r+o),i=this.getVatValue(e.subtotal-e.discount,s,e.tax_type);if(t.taxes=t.taxes.map(r=>{const o=m(m(r.rate).divide(s).done()).multiply(100).done();return{id:r.id,tax_id:r.tax_id,name:r.name,rate:parseFloat(r.rate),tax_value:m(m(i).multiply(o).done()).divide(100).done()}}),t.taxes.length===0){x.error(d("The selected tax group doesn't have any assigned sub taxes. This might cause wrong figures."),d("Proceed"),{duration:!1}).subscribe();return}return e.tax_groups=e.tax_groups||[],e.taxes=t.taxes,e.tax_groups[t.id]=t,this.computeOrderTaxes(e)}computeOrderTaxes(e){const t=this.options.getValue().ns_pos_vat,s=this.options.getValue().ns_pos_price_with_tax==="yes";return["flat_vat","variable_vat","products_variable_vat","products_flat_vat"].includes(t)&&e.taxes&&e.taxes.length>0&&(e.tax_value+=e.taxes.map(i=>i.tax_value).reduce((i,r)=>i+r)),e.total_tax_value=e.tax_value,["products_variable_vat","products_flat_vat","products_vat"].includes(t)&&!s&&(e.total_tax_value=e.products_exclusive_tax_value+e.tax_value),e}computeProductsTaxes(e){const t=this.products.getValue(),s=t.filter(o=>o.tax_type==="inclusive").map(o=>o.tax_value),i=t.filter(o=>o.tax_type==="exclusive").map(o=>o.tax_value);e.products_exclusive_tax_value=0,e.products_inclusive_tax_value=0;const r=this.options.getValue().ns_pos_vat;return["products_flat_vat","products_variable_vat","products_vat"].includes(r)&&i.length>0&&(e.products_exclusive_tax_value+=i.reduce((o,u)=>o+u)),["products_flat_vat","products_variable_vat","products_vat"].includes(r)&&s.length>0&&(e.products_inclusive_tax_value+=s.reduce((o,u)=>o+u)),e.products=t,e.total_products=t.length,e}canProceedAsLaidAway(e){return new Promise(async(t,s)=>{const i=e.customer.group.minimal_credit_payment,r=m(e.total).multiply(i).done();let o=m(r).divide(100).done();o=parseFloat(o);try{const u=await new Promise((l,y)=>{b.show(Cs,{order:e,reject:y,resolve:l})});if(u.order.instalments.length===0&&u.order.tenderedw.amount>=o&&oe(w.date).isSame(ns.date.moment.startOf("day"),"day"));if(y.length===0)return t({status:"success",message:d("Layaway defined"),data:{order:u.order}});const _=y[0].amount;_>0?b.show($,{title:d("Initial Payment"),message:d('In order to proceed, an initial payment of {amount} is required for the selected payment type "{paymentType}". Would you like to proceed ?').replace("{amount}",S(_)).replace("{paymentType}",l.label),onAction:w=>{if(w){const F={identifier:l.identifier,label:l.label,value:_,readonly:!1,selected:!0};this.addPayment(F),y[0].paid=!0,t({status:"success",message:d("Layaway defined"),data:{order:u.order}})}else s({status:"error",message:d("The request was canceled")})}}):t({status:"success",message:d("Layaway defined"),data:{order:u.order}})}}catch(u){return s(u)}})}submitOrder(e={}){return new Promise(async(t,s)=>{var i={...this.order.getValue(),...e};const r=i.customer.group.minimal_credit_payment;if(i.payment_status!=="hold"&&i.payments.length===0&&i.total>0&&i.total>i.tendered){if(this.options.getValue().ns_orders_allow_partial==="no"){const o=d("Partially paid orders are disabled.");return s({status:"error",message:o})}else if(r>=0)try{i=(await this.canProceedAsLaidAway(i)).data.order}catch(o){return s(o)}}return this._isSubmitting?s({status:"error",message:d("An order is currently being processed.")}):(this._isSubmitting=!0,this.proceedSubmitting(i,t,s))})}proceedSubmitting(e,t,s){const i=e.id!==void 0?"put":"post";return v.doAction("ns-order-before-submit",e),C[i](`/api/orders${e.id!==void 0?"/"+e.id:""}`,e).subscribe({next:r=>{t(r),this.reset(),v.doAction("ns-order-submit-successful",r),this._isSubmitting=!1;const o=this.options.getValue().ns_pos_complete_sale_audio;o.length>0&&new Audio(o).play()},error:r=>{this._isSubmitting=!1,s(r),v.doAction("ns-order-submit-failed",r)}})}defineQuantities(e,t=[]){return new Promise((s,i)=>{const o={unit:t.filter(l=>l.id===e.unit_id)[0]||{},sale_price_with_tax:e.mode==="normal"?parseFloat(e.price_with_tax):0,sale_price_without_tax:e.mode==="normal"?parseFloat(e.price_without_tax):0,sale_price:e.mode==="normal"?parseFloat(e.unit_price):0,sale_price_tax:e.mode==="normal"?e.tax_value:0,sale_price_edit:0,wholesale_price_with_tax:e.mode==="wholesale"?parseFloat(e.price_with_tax):0,wholesale_price_without_tax:e.mode==="wholesale"?parseFloat(e.price_without_tax):0,wholesale_price:e.mode==="wholesale"?parseFloat(e.unit_price):0,wholesale_price_tax:e.mode==="wholesale"?e.tax_value:0,wholesale_price_edit:0,custom_price_with_tax:e.mode==="custom"?parseFloat(e.price_with_tax):0,custom_price_without_tax:e.mode==="custom"?parseFloat(e.price_without_tax):0,custom_price:e.mode==="custom"?parseFloat(e.unit_price):0,custom_price_tax:e.mode==="custom"?e.tax_value:0,custom_price_edit:e.mode==="custom"?parseFloat(e.unit_price):0};let u;if(["inclusive","exclusive"].includes(e.tax_type))try{if(e.tax_group_id)C.get(`/api/taxes/groups/${e.tax_group_id}`).subscribe({next:l=>(["sale","wholesale","custom"].forEach(y=>{o[y+"_price_tax"]=l.taxes.map(_=>this.getVatValue(o[y+"_price"],_.rate,e.tax_type)).reduce((_,w)=>_+w),o["gross_"+y+"_price"]=o[y+"_price"]+o[y+"_price_tax"],o["net_"+y+"_price"]=o[y+"_price"]-o[y+"_price_tax"]}),u=l,s(o)),error:l=>{i(!1)}});else return o.sale_price_tax=0,o.wholesale_price_tax=0,o.sale_price_without_tax=e.unit_price,s(o)}catch{return x.error(d("An error has occurred while computing the product.")).subscribe()}return s(o)})}loadOrder(e){return new Promise((t,s)=>{C.get(`/api/orders/${e}/pos`).subscribe({next:async i=>{try{v.doAction("ns-before-load-order",{order:i})}catch(o){return s(o)}this.options.getValue(),i={...this.defaultOrder(),...i};const r=[];for(let o=0;ou.product,u.$quantities=()=>{let l=u.product.unit_quantities.filter(y=>+y.id==+u.unit_quantity_id||y.id===void 0)[0];return u.mode==="custom"&&(l.custom_price_edit=u.unit_price,l.custom_price_with_tax=u.price_with_tax,l.custom_price_without_tax=u.price_without_tax,l.custom_price_tax=u.tax_value),l},r.push(u)}i.type=Object.values(this.types.getValue()).filter(o=>o.identifier===i.type)[0],i.addresses={shipping:i.shipping_address,billing:i.billing_address},delete i.shipping_address,delete i.billing_address,this.buildOrder(i),this.buildProducts(r),await this.selectCustomer(i.customer),t(i)},error:i=>s(i)})})}buildOrder(e){this.order.next(e)}buildProducts(e){this.recomputeProducts(e),this.products.next(e),v.doAction("ns-after-cart-changed")}printOrderReceipt(e,t){const s=this.options.getValue();if(s.ns_pos_printing_enabled_for==="disabled")return!1;if(s.ns_pos_printing_enabled_for==="all_orders"||s.ns_pos_printing_enabled_for==="partially_paid_orders"&&["paid","partially_paid"].includes(e.payment_status)||s.ns_pos_printing_enabled_for==="only_paid_orders"&&["paid"].includes(e.payment_status))this.print.process(e.id,"sale",t);else return!1}computePaid(){const e=this._order.getValue();e.tendered=0,e.payments.length>0&&(e.tendered=e.payments.map(t=>t.value).reduce((t,s)=>s+t)),e.tendered>=e.total?e.payment_status="paid":e.tendered>0&&e.tendered{s.identifier===e.identifier?s.selected=!0:s.selected=!1}),this._paymentsType.next(t)}definedPaymentsType(e){this._paymentsType.next(e)}selectCustomer(e){return new Promise((t,s)=>{const i=this.order.getValue(),r=Object.assign(e.billing||{},{});if(r.id!==void 0&&delete r.id,i.customer=e,i.customer_id=e.id,i.addresses.billing=r,this.order.next(i),e.group===void 0||e.group===null)C.get(`/api/customers/${e.id}/group`).subscribe({next:o=>{i.customer.group=o,this.order.next(i),t(i)},error:o=>{s(o)}});else return t(i)})}updateCart(e,t){for(let s in t)t[s]!==void 0&&(e[s]=t[s]);this.order.next(e),this.refreshCart()}checkCart(){const e=this.order.getValue(),t=[];e.coupons.forEach(s=>{let i=!0;s.products.length>0&&(i=e.products.filter(o=>s.products.map(u=>u.product_id).includes(o.product_id)).length>0,!i&&t.indexOf(s)===-1&&t.push(s));let r=!0;s.categories.length>0&&(r=e.products.filter(o=>s.categories.map(u=>u.category_id).includes(o.$original().category_id)).length>0,!r&&t.indexOf(s)===-1&&t.push(s))}),t.forEach(s=>{x.error(d(`The coupons "%s" has been removed from the cart, as it's required conditions are no more meet.`).replace("%s",s.name),d("Okay"),{duration:6e3}).subscribe(),this.removeCoupon(s)})}async refreshCart(){this.checkCart();const e=this.products.getValue();let t=this.order.getValue(),s=this.options.getValue().ns_pos_price_with_tax;const i=e.filter(_=>_.product_type!=="dynamic").map(_=>s==="yes"?_.total_price_with_tax:_.total_price_without_tax);if(i.length>0){let _=i.reduce((k,B)=>k+B),w=0,F=e.filter(k=>k.product_type==="dynamic").map(k=>(k.unit_price=_*k.rate/100,k.total_price=k.unit_price*k.quantity,k.total_price));F.length>0&&(w=F.reduce((k,B)=>k+B)),t.subtotal=_+w}else t.subtotal=0;const r=t.coupons.map(_=>_.type==="percentage_discount"?(_.value=t.subtotal*_.discount_value/100,_.value):(_.value=_.discount_value,_.value));t.total_coupons=0,r.length>0&&(t.total_coupons=r.reduce((_,w)=>_+w)),t.discount_type==="percentage"&&(t.discount=t.discount_percentage*t.subtotal/100),t.discount>t.subtotal&&t.total_coupons===0&&(t.discount=t.subtotal,x.info(d("The discount has been set to the cart subtotal.")).subscribe()),t.tax_value=0,t.total_tax_value=0,this.order.next(t);try{t=(await this.computeTaxes()).data.order}catch(_){_!==!1&&_.message!==void 0&&x.error(_.message||d("An unexpected error has occurred while fecthing taxes."),d("OKAY"),{duration:0}).subscribe()}const o=e.map(_=>_.tax_type==="inclusive"?_.tax_value:0);o.length>0&&o.reduce((_,w)=>_+w);const u=t.tax_type,l=this.options.getValue().ns_pos_vat;let y=0;if(["flat_vat","variable_vat","products_vat","products_flat_vat","products_variable_vat"].includes(l)&&(y=t.total_tax_value),u==="exclusive"){const _=m(t.subtotal).add(t.shipping||0).add(y).done();t.total=m(_).subtract(t.discount).subtract(t.total_coupons).done()}else{const _=m(t.subtotal).add(t.shipping||0).done();t.total=m(_).subtract(t.discount).subtract(t.total_coupons).done()}this.order.next(t),v.doAction("ns-cart-after-refreshed",t)}getStockUsage(e,t){const s=this._products.getValue().filter(i=>i.product_id===e&&i.unit_quantity_id===t).map(i=>i.quantity);return s.length>0?s.reduce((i,r)=>i+r):0}async addToCart(e){let t=new Object,s={product_id:e.id||0,name:e.name,discount_type:"percentage",discount:0,discount_percentage:0,product_type:e.product_type||"product",rate:e.rate||0,quantity:e.quantity||0,tax_group_id:e.tax_group_id,tax_type:e.tax_type||void 0,tax_value:0,unit_id:e.unit_id||0,unit_price:e.unit_price||0,price_with_tax:e.price_with_tax||0,price_without_tax:e.price_without_tax||0,unit_name:e.unit_name||"",total_price:0,total_price_without_tax:0,total_price_with_tax:0,mode:e.mode||"normal",$original:e.$original||(()=>e),$quantities:e.$quantities||void 0};if(this._processingAddQueue=!0,s.product_id!==0)for(let o in this.addToCartQueue)try{const l=await new this.addToCartQueue[o](s).run(t);t={...t,...l}}catch(u){if(u===!1)return this._processingAddQueue=!1,!1}this._processingAddQueue=!1,s={...s,...t};const i=this._products.getValue();if(this.settings.getValue().ns_pos_items_merge){const o=i.filter(u=>u.product_id===s.product_id&&u.tax_group_id===s.tax_group_id&&u.unit_id===s.unit_id&&u.unit_quantity_id===s.unit_quantity_id);o.length>0?o[0].quantity+=s.quantity:i.unshift(s)}else i.unshift(s);this.recomputeProducts(i),this.products.next(i);const r=this.options.getValue().ns_pos_new_item_audio;r.length>0&&new Audio(r).play(),v.doAction("ns-after-cart-changed")}defineTypes(e){this._types.next(e)}userCan(e){return this._userPermissions.getValue().filter(i=>i.namespace===e).length>0}async removeProductUsingIndex(e){const t=this._products.getValue();if(t[e].id)try{await new Promise((i,r)=>{const o=b.show(W);C.post("/api/users/check-permission/",{permission:"nexopos.pos.delete-order-product"}).subscribe({next:u=>{o.close(),i(u)},error:u=>{o.close(),r(u)}})}),this.resumeRemovingProductUsingIndex(e,t)}catch{N.error(d("Forbidden Action"),d("You are not allowed to remove this product."))}else this.resumeRemovingProductUsingIndex(e,t)}resumeRemovingProductUsingIndex(e,t){t.splice(e,1),this.products.next(t),v.doAction("ns-after-cart-changed")}removeProduct(e){const t=this._products.getValue(),s=t.indexOf(e);t.splice(s,1),this.products.next(t),v.doAction("ns-after-cart-changed")}updateProduct(e,t,s=null){const i=this._products.getValue();s=s===null?i.indexOf(e):s,s=s===-1?0:s,i[s]={...e,...t},this.recomputeProducts(i),this.products.next(i),v.doAction("ns-after-cart-changed")}recomputeProducts(e=null){e.forEach(t=>{this.computeProduct(t)})}getProductUnitPrice(e,t){switch(e){case"custom":return t.custom_price_edit;case"normal":return t.sale_price_edit;case"wholesale":return t.wholesale_price_edit}}computeProductTax(e){switch(e.mode){case"custom":return this.computeCustomProductTax(e);case"normal":return this.computeNormalProductTax(e);case"wholesale":return this.computeWholesaleProductTax(e);default:return e}}proceedProductTaxComputation(e,t){const s=e.$original(),i=s.tax_group;let r=this.getProductUnitPrice(e.mode,e.$quantities()),o=0,u=this.getProductUnitPrice(e.mode,e.$quantities());if(i!=null&&i.taxes!==void 0){let l=0;switch(i.taxes.length>0&&(l=i.taxes.map(y=>y.rate).reduce((y,_)=>y+_)),s.tax_type){case"inclusive":r=this.getPriceWithoutTax(t,l,s.tax_type),u=t;break;case"exclusive":r=t,u=this.getPriceWithTax(t,l,s.tax_type);break}o=this.getVatValue(t,l,s.tax_type)}return{price_without_tax:r,tax_value:o,price_with_tax:u}}computeCustomProductTax(e){e.$original();const t=e.$quantities(),s=this.proceedProductTaxComputation(e,t.custom_price_edit);return t.custom_price_without_tax=s.price_without_tax,t.custom_price_with_tax=s.price_with_tax,t.custom_price_tax=s.tax_value,e.$quantities=()=>t,e}computeNormalProductTax(e){const t=e.$quantities(),s=this.proceedProductTaxComputation(e,t.sale_price_edit);return t.sale_price_without_tax=s.price_without_tax,t.sale_price_with_tax=s.price_with_tax,t.sale_price_tax=s.tax_value,e.$quantities=()=>t,e}computeWholesaleProductTax(e){const t=e.$quantities(),s=this.proceedProductTaxComputation(e,t.wholesale_price_edit);return t.wholesale_price_without_tax=s.price_without_tax,t.wholesale_price_with_tax=s.price_with_tax,t.wholesale_price_tax=s.tax_value,e.$quantities=()=>t,e}getPrice(e,t,s){switch(t){case"normal":return e["sale_price_"+s];case"wholesale":return e["wholesale_price_"+s];case"custom":return e["custom_price_"+s]}}computeProduct(e){e.product_type==="product"&&(e.mode==="normal"?(e.unit_price=this.getSalePrice(e.$quantities(),e.$original()),e.tax_value=m(e.$quantities().sale_price_tax).multiply(e.quantity).done()):e.mode==="wholesale"&&(e.unit_price=this.getWholesalePrice(e.$quantities(),e.$original()),e.tax_value=m(e.$quantities().wholesale_price_tax).multiply(e.quantity).done()),e.mode==="custom"&&(e.unit_price=this.getCustomPrice(e.$quantities(),e.$original()),e.tax_value=m(e.$quantities().custom_price_tax).multiply(e.quantity).done()));let t=0,s=0,i=this.getPrice(e.$quantities(),e.mode,"with_tax"),r=this.getPrice(e.$quantities(),e.mode,"without_tax");["flat","percentage"].includes(e.discount_type)&&(e.discount_type==="percentage"?(e.discount=m(m(m(e.unit_price).multiply(e.discount_percentage).done()).divide(100).done()).multiply(e.quantity).done(),t=m(m(m(r).multiply(e.discount_percentage).done()).divide(100).done()).multiply(e.quantity).done(),s=m(m(m(i).multiply(e.discount_percentage).done()).divide(100).done()).multiply(e.quantity).done()):(t=e.discount,s=e.discount)),e.price_with_tax=i,e.price_without_tax=r,e.total_price=m(m(e.unit_price).multiply(e.quantity).done()).subtract(e.discount).done(),e.total_price_with_tax=m(m(i).multiply(e.quantity).done()).subtract(s).done(),e.total_price_without_tax=m(m(r).multiply(e.quantity).done()).subtract(t).done(),v.doAction("ns-after-product-computed",e)}loadCustomer(e){return C.get(`/api/customers/${e}`)}defineSettings(e){this._settings.next(e)}voidOrder(e){e.id!==void 0?["hold"].includes(e.payment_status)?b.show($,{title:d("Order Deletion"),message:d("The current order will be deleted as no payment has been made so far."),onAction:t=>{t&&C.delete(`/api/orders/${e.id}`).subscribe({next:s=>{x.success(s.message).subscribe(),this.reset()},error:s=>x.error(s.message).subscribe()})}}):b.show(pe,{title:d("Void The Order"),message:d("The current order will be void. This will cancel the transaction, but the order won't be deleted. Further details about the operation will be tracked on the report. Consider providing the reason of this operation."),onAction:t=>{t!==!1&&C.post(`/api/orders/${e.id}/void`,{reason:t}).subscribe({next:s=>{x.success(s.message).subscribe(),this.reset()},error:s=>x.error(s.message).subscribe()})}}):x.error(d("Unable to void an unpaid order.")).subscribe()}async triggerOrderTypeSelection(e){for(let t=0;te in r?ee(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var b=(r,e,t)=>(te(r,typeof e!="symbol"?e+"":e,t),t);import{_ as U}from"./preload-helper-41c905a7.js";import{n as se,a as ie,b as ne,c as H,P as re}from"./ns-pos-shipping-popup-dffc98ef.js";import{p as oe,a as M,b as k,d as f,P as v,F as ae,e as le,n as w,B as P,f as Y,T as N,g as x,h as ue}from"./bootstrap-ffaf6d09.js";import{_ as d,n as A,a as Q}from"./currency-feccde3d.js";import{_ as j}from"./_plugin-vue_export-helper-c27b6911.js";import{r as T,o as _,c as m,a as o,t as c,F,b as I,e as y,f as V,n as L,g as $,w as O,h as ce,i as S,j as de,d as E}from"./runtime-core.esm-bundler-414a078a.js";import{n as R,a as pe,b as _e,c as D,d as me,e as he}from"./ns-prompt-popup-24cc8d6f.js";import"./index.es-25aa42ee.js";import"./ns-orders-preview-popup-3c654295.js";import"./chart-2ccf8ff7.js";const fe={props:["popup"],data(){return{unitsQuantities:[],loadsUnits:!1,options:null,optionsSubscriber:null}},beforeDestroy(){this.optionsSubscriber.unsubscribe()},mounted(){this.optionsSubscriber=POS.options.subscribe(r=>{this.options=r}),this.popup.params.product.$original().selectedUnitQuantity!==void 0?this.selectUnit(this.popup.params.product.$original().selectedUnitQuantity):this.popup.params.product.$original().unit_quantities!==void 0&&this.popup.params.product.$original().unit_quantities.length===1?this.selectUnit(this.popup.params.product.$original().unit_quantities[0]):(this.loadsUnits=!0,this.loadUnits()),this.popupCloser()},computed:{productName(){return this.popup.params.product.$original().name}},methods:{__:d,nsCurrency:A,popupCloser:oe,popupResolver:M,displayRightPrice(r){return POS.getSalePrice(r,this.popup.params.product.$original())},loadUnits(){k.get(`/api/products/${this.popup.params.product.$original().id}/units/quantities`).subscribe(r=>{if(r.length===0)return this.popup.close(),f.error(d("This product doesn't have any unit defined for selling. Make sure to mark at least one unit as visible.")).subscribe();this.unitsQuantities=r,this.unitsQuantities.length===1&&this.selectUnit(this.unitsQuantities[0])})},selectUnit(r){if(r.unit===null)return f.error(d('The unit attached to this product is missing or not assigned. Please review the "Unit" tab for this product.')).subscribe(),this.popup.close();this.popup.params.resolve({unit_quantity_id:r.id,unit_name:r.unit.name,$quantities:()=>r}),this.popup.close()}}},ye={class:"h-full w-full flex items-center justify-center",id:"ns-units-selector"},xe={key:0,class:"ns-box w-4/5-screen lg:w-1/3-screen overflow-hidden flex flex-col"},be={id:"header",class:"h-16 flex justify-center items-center flex-shrink-0"},ge={class:"font-bold text-primary"},ve={key:0,class:"grid grid-flow-row grid-cols-2 overflow-y-auto"},we=["onClick"],Pe={class:"h-40 w-full flex items-center justify-center overflow-hidden"},ke=["src","alt"],Ce={key:1,class:"h-40 flex items-center justify-center"},Ve=o("i",{class:"las la-image text-primary text-6xl"},null,-1),Te=[Ve],Se={class:"h-0 w-full"},Oe={class:"relative w-full flex items-center justify-center -top-10 h-20 py-2 flex-col overlay"},Ae={class:"font-bold text-primary py-2 text-center"},je={class:"text-sm font-medium text-primary"},qe={key:1,class:"h-56 flex items-center justify-center"};function $e(r,e,t,s,i,n){const a=T("ns-spinner");return _(),m("div",ye,[i.unitsQuantities.length>0?(_(),m("div",xe,[o("div",be,[o("h3",ge,c(n.__("{product} : Units").replace("{product}",n.productName)),1)]),i.unitsQuantities.length>0?(_(),m("div",ve,[(_(!0),m(F,null,I(i.unitsQuantities,l=>(_(),m("div",{onClick:u=>n.selectUnit(l),key:l.id,class:"ns-numpad-key info cursor-pointer border flex-shrink-0 flex flex-col items-center justify-center"},[o("div",Pe,[l.preview_url?(_(),m("img",{key:0,src:l.preview_url,class:"object-cover h-full",alt:l.unit.name},null,8,ke)):y("",!0),l.preview_url?y("",!0):(_(),m("div",Ce,Te))]),o("div",Se,[o("div",Oe,[o("h3",Ae,c(l.unit.name)+" ("+c(l.quantity)+")",1),o("p",je,c(n.nsCurrency(n.displayRightPrice(l))),1)])])],8,we))),128))])):y("",!0)])):y("",!0),i.unitsQuantities.length===0?(_(),m("div",qe,[V(a)])):y("",!0)])}const Fe=j(fe,[["render",$e]]);class Ie{constructor(e){this.product=e}run(){return new Promise((e,t)=>{const s=this.product;v.show(Fe,{resolve:e,reject:t,product:s})})}}class z{constructor(e){this.order=e}run(){return new Promise((e,t)=>this.order.customer===void 0?v.show(se,{resolve:e,reject:t}):e(!0))}}window.CustomerQueue=z;const Qe={name:"sample-payment",props:["label","identifier"],data(){return{backValue:"0",number:parseInt(1+new Array(parseInt(ns.currency.ns_currency_precision)).fill("").map(r=>0).join("")),order:null,settings:{},settingsSubscription:null,cursor:parseInt(ns.currency.ns_currency_precision),orderSubscription:null,allSelected:!0,keys:[...[7,8,9].map(r=>({identifier:r,value:r})),...[4,5,6].map(r=>({identifier:r,value:r})),...[1,2,3].map(r=>({identifier:r,value:r})),{identifier:"backspace",icon:"la-backspace"},{identifier:0,value:0},{identifier:"next",icon:"la-share"}]}},computed:{amountShortcuts(){return nsShortcuts.ns_pos_amount_shortcut!==null?nsShortcuts.ns_pos_amount_shortcut.split("|"):[]}},mounted(){this.orderSubscription=POS.order.subscribe(e=>{this.order=e}),this.settingsSubscription=POS.settings.subscribe(e=>{this.settings=e});const r=new Array(10).fill("").map((e,t)=>t);nsHotPress.create("numpad-keys").whenVisible([".is-popup"]).whenPressed(r,(e,t)=>{this.inputValue({value:t})}),nsHotPress.create("numpad-backspace").whenVisible([".is-popup"]).whenPressed("backspace",()=>this.inputValue({identifier:"backspace"})),nsHotPress.create("numpad-save").whenVisible([".is-popup"]).whenPressed("enter",()=>{this.backValue===""?(this.$emit("submit"),this.backValue=0):this.inputValue({identifier:"next"})})},beforeDestroy(){nsHotPress.destroy("numpad-keys"),nsHotPress.destroy("numpad-backspace"),nsHotPress.destroy("numpad-save")},unmounted(){this.orderSubscription.unsubscribe()},methods:{__:d,nsCurrency:A,toggleDiscount(){if(this.settings.cart_discount!==void 0&&this.settings.cart_discount===!0)v.show(ie,{reference:this.order,type:"cart",onSubmit:r=>{POS.updateCart(this.order,r)}});else return f.error(d("You're not allowed to add a discount on the cart.")).subscribe()},makeFullPayment(){POS.order.getValue(),v.show(R,{title:d("Confirm Full Payment"),message:d("A full payment will be made using {paymentType} for {total}").replace("{paymentType}",this.label).replace("{total}",A(this.order.total)),onAction:r=>{if(r){const e=POS.order.getValue();e.tendered0).join(""));this.backValue=(parseFloat(r.value)*e+(parseFloat(this.backValue)||0)).toString(),this.allSelected=!1},inputValue(r){r.identifier==="next"?(POS.addPayment({value:parseFloat(this.backValue/this.number),identifier:this.identifier,selected:!1,label:this.label,readonly:!1}),this.backValue="0"):r.identifier==="backspace"?this.allSelected?(this.backValue="0",this.allSelected=!1):this.backValue=this.backValue.slice(0,-1):r.value.toString().match(/^\d+$/)&&(this.allSelected?(this.backValue=r.value.toString(),this.allSelected=!1):(this.backValue+=r.value.toString(),this.mode==="percentage"&&(this.backValue=this.backValue>100?100:this.backValue))),this.backValue==="0"&&(this.backValue="")}}},Ue={class:"h-full w-full py-2"},Ee={key:0,class:"px-2 pb-2"},Re={class:"grid grid-cols-2 gap-2"},Be={id:"details",class:"h-16 flex justify-between items-center border elevation-surface info text-xl md:text-3xl p-2"},Le={id:"paid",class:"h-16 flex justify-between items-center border elevation-surface success text-xl md:text-3xl p-2"},De={id:"change",class:"h-16 flex justify-between items-center border elevation-surface warning text-xl md:text-3xl p-2"},We={id:"change",class:"col-span-2 h-16 flex justify-between items-center elevation-surface border text-xl md:text-3xl p-2"},Ye={class:"px-2 pb-2"},Ne={class:"-mx-2 flex flex-wrap"},He={class:"pl-2 pr-1 flex-auto"},Me={id:"numpad",class:"grid grid-flow-row grid-cols-3 gap-2 grid-rows-3",style:{padding:"1px"}},ze=["onClick"],Ge={key:0},Ke={class:"w-1/2 md:w-72 pr-2 pl-1"},Je={class:"grid grid-flow-row grid-rows-1 gap-2"},Xe=["onClick"];function Ze(r,e,t,s,i,n){return _(),m("div",Ue,[i.order?(_(),m("div",Ee,[o("div",Re,[o("div",Be,[o("span",null,c(n.__("Total"))+" : ",1),o("span",null,c(n.nsCurrency(i.order.total)),1)]),o("div",{id:"discount",onClick:e[0]||(e[0]=a=>n.toggleDiscount()),class:"cursor-pointer h-16 flex justify-between items-center border elevation-surface error text-xl md:text-3xl p-2"},[o("span",null,c(n.__("Discount"))+" : ",1),o("span",null,c(n.nsCurrency(i.order.discount)),1)]),o("div",Le,[o("span",null,c(n.__("Paid"))+" : ",1),o("span",null,c(n.nsCurrency(i.order.tendered)),1)]),o("div",De,[o("span",null,c(n.__("Change"))+" : ",1),o("span",null,c(n.nsCurrency(i.order.change)),1)]),o("div",We,[o("span",null,c(n.__("Screen"))+" : ",1),o("span",null,c(n.nsCurrency(i.backValue/i.number)),1)])])])):y("",!0),o("div",Ye,[o("div",Ne,[o("div",He,[o("div",Me,[(_(!0),m(F,null,I(i.keys,(a,l)=>(_(),m("div",{onClick:u=>n.inputValue(a),key:l,style:{margin:"-1px"},class:"ns-numpad-key text-2xl border h-16 flex items-center justify-center cursor-pointer"},[a.value!==void 0?(_(),m("span",Ge,c(a.value),1)):y("",!0),a.icon?(_(),m("i",{key:1,class:L(["las",a.icon])},null,2)):y("",!0)],8,ze))),128)),o("div",{onClick:e[1]||(e[1]=a=>n.makeFullPayment()),class:"hover:bg-green-500 col-span-3 bg-success-secondary border-success-tertiary text-2xl text-white border h-16 flex items-center justify-center cursor-pointer"},c(n.__("Full Payment")),1)])]),o("div",Ke,[o("div",Je,[(_(!0),m(F,null,I(n.amountShortcuts,(a,l)=>(_(),m("div",{key:l,onClick:u=>n.increaseBy({value:a}),class:"ns-numpad-key text-2xl border h-16 flex items-center justify-center cursor-pointer"},[o("span",null,c(n.nsCurrency(a)),1)],8,Xe))),128))])])])])])}const W=j(Qe,[["render",Ze]]),et={name:"cash-payment",props:["identifier","label"],components:{samplePayment:W}};function tt(r,e,t,s,i,n){const a=T("sample-payment");return _(),$(a,{identifier:t.identifier,label:t.label},null,8,["identifier","label"])}const st=j(et,[["render",tt]]),it={name:"creditcart-payment",props:["identifier"]};function nt(r,e,t,s,i,n){return _(),m("h1",null,"Credit Card")}const rt=j(it,[["render",nt]]),ot={name:"bank-payment",props:["identifier","label"],components:{samplePayment:W}};function at(r,e,t,s,i,n){const a=T("sample-payment");return _(),$(a,{identifier:t.identifier,label:t.label},null,8,["identifier","label"])}const lt=j(ot,[["render",at]]),ut={name:"ns-account-payment",components:{nsNumpad:pe},props:["identifier","label"],data(){return{subscription:null,screenValue:0,order:null}},methods:{__:d,nsCurrency:A,handleChange(r){this.screenValue=r},proceedAddingPayment(r){const e=parseFloat(r),t=this.order.payments;if(e<=0)return f.error(d("Please provide a valid payment amount.")).subscribe();if(t.filter(s=>s.identifier==="account-payment").length>0)return f.error(d("The customer account can only be used once per order. Consider deleting the previously used payment.")).subscribe();if(e>this.order.customer.account_amount)return f.error(d("Not enough funds to add {amount} as a payment. Available balance {balance}.").replace("{amount}",this.$options.filters.currency(e)).replace("{balance}",this.$options.filters.currency(this.order.customer.account_amount))).subscribe();POS.addPayment({value:e,identifier:"account-payment",selected:!1,label:this.label,readonly:!1}),this.order.customer.account_amount-=e,POS.selectCustomer(this.order.customer),this.$emit("submit")},proceedFullPayment(){this.proceedAddingPayment(this.order.total)},makeFullPayment(){Popup.show(R,{title:d("Confirm Full Payment"),message:d("You're about to use {amount} from the customer account to make a payment. Would you like to proceed ?").replace("{amount}",this.$options.filters.currency(this.order.total)),onAction:r=>{r&&this.proceedFullPayment()}})}},mounted(){this.subscription=POS.order.subscribe(r=>this.order=r)},unmounted(){this.subscription.unsubscribe()}},ct={class:"h-full w-full py-2"},dt={key:0,class:"px-2 pb-2"},pt={class:"grid grid-cols-2 gap-2"},_t={id:"details",class:"h-16 flex justify-between items-center elevation-surface border info text-xl md:text-3xl p-2"},mt={id:"paid",class:"h-16 flex justify-between items-center elevation-surface success border text-xl md:text-3xl p-2"},ht={id:"change",class:"h-16 flex justify-between items-center elevation-surface warning border text-xl md:text-3xl p-2"},ft={id:"change",class:"col-span-2 h-16 flex justify-between items-center elevation-surface border success text-xl md:text-3xl p-2"},yt={id:"change",class:"col-span-2 h-16 flex justify-between items-center elevation-surface border text-primary text-xl md:text-3xl p-2"},xt={class:"px-2 pb-2"},bt={class:"-mx-2 flex flex-wrap"},gt={class:"pl-2 pr-1 flex-auto"},vt={class:"w-1/2 md:w-72 pr-2 pl-1"},wt={class:"grid grid-flow-row grid-rows-1 gap-2"};function Pt(r,e,t,s,i,n){const a=T("ns-numpad");return _(),m("div",ct,[i.order?(_(),m("div",dt,[o("div",pt,[o("div",_t,[o("span",null,c(n.__("Total"))+" : ",1),o("span",null,c(n.nsCurrency(i.order.total)),1)]),o("div",{id:"discount",onClick:e[0]||(e[0]=l=>r.toggleDiscount()),class:"cursor-pointer h-16 flex justify-between items-center elevation-surface error border text-xl md:text-3xl p-2"},[o("span",null,c(n.__("Discount"))+" : ",1),o("span",null,c(n.nsCurrency(i.order.discount)),1)]),o("div",mt,[o("span",null,c(n.__("Paid"))+" : ",1),o("span",null,c(n.nsCurrency(i.order.tendered)),1)]),o("div",ht,[o("span",null,c(n.__("Change"))+" : ",1),o("span",null,c(n.nsCurrency(i.order.change)),1)]),o("div",ft,[o("span",null,c(n.__("Current Balance"))+" : ",1),o("span",null,c(n.nsCurrency(i.order.customer.account_amount)),1)]),o("div",yt,[o("span",null,c(n.__("Screen"))+" : ",1),o("span",null,c(n.nsCurrency(i.screenValue)),1)])])])):y("",!0),o("div",xt,[o("div",bt,[o("div",gt,[V(a,{floating:!0,onChanged:e[2]||(e[2]=l=>n.handleChange(l)),onNext:e[3]||(e[3]=l=>n.proceedAddingPayment(l))},{"numpad-footer":O(()=>[o("div",{onClick:e[1]||(e[1]=l=>n.makeFullPayment()),class:"hover:bg-success-tertiary col-span-3 bg-success-secondary text-2xl text-white border border-success-secondary h-16 flex items-center justify-center cursor-pointer"},c(n.__("Full Payment")),1)]),_:1})]),o("div",vt,[o("div",wt,[o("div",{onClick:e[4]||(e[4]=l=>r.increaseBy({value:100})),class:"elevation-surface border hoverable text-2xl text-primary h-16 flex items-center justify-center cursor-pointer"},[o("span",null,c(n.nsCurrency(100)),1)]),o("div",{onClick:e[5]||(e[5]=l=>r.increaseBy({value:500})),class:"elevation-surface border hoverable text-2xl text-primary h-16 flex items-center justify-center cursor-pointer"},[o("span",null,c(n.nsCurrency(500)),1)]),o("div",{onClick:e[6]||(e[6]=l=>r.increaseBy({value:1e3})),class:"elevation-surface border hoverable text-2xl text-primary h-16 flex items-center justify-center cursor-pointer"},[o("span",null,c(n.nsCurrency(1e3)),1)])])])])])])}const kt=j(ut,[["render",Pt]]),Ct={name:"ns-pos-payment",props:["popup"],data(){return{paymentTypesSubscription:null,paymentsType:[],activePayment:null,order:null,showPayment:!1,orderSubscription:null,currentPaymentComponent:null,activePaymentSubscription:null}},computed:{expectedPayment(){const r=this.order.customer.group.minimal_credit_payment;return this.order.total*r/100}},mounted(){this.orderSubscription=POS.order.subscribe(r=>{this.order=ce(r)}),this.activePaymentSubscription=POS.selectedPaymentType.subscribe(r=>{this.activePayment=r,r!==null&&this.loadPaymentComponent(r)}),this.paymentTypesSubscription=POS.paymentsType.subscribe(r=>{this.paymentsType=r,r.filter(e=>{e.selected&&POS.selectedPaymentType.next(e)})}),nsHooks.doAction("ns-pos-payment-mounted",this)},unmounted(){this.activePaymentSubscription.unsubscribe(),this.paymentTypesSubscription.unsubscribe(),this.orderSubscription.unsubscribe(),nsHooks.doAction("ns-pos-payment-destroyed",this)},methods:{__:d,nsCurrency:A,resolveIfQueued:M,loadPaymentComponent(r){switch(r.identifier){case"cash-payment":this.currentPaymentComponent=shallowRef(st);break;case"creditcard-payment":this.currentPaymentComponent=shallowRef(rt);break;case"bank-payment":this.currentPaymentComponent=shallowRef(lt);break;case"account-payment":this.currentPaymentComponent=shallowRef(kt);break;default:this.currentPaymentComponent=shallowRef(W);break}},async selectPayment(){try{const r=await new Promise((e,t)=>{v.show(_e,{label:d("Select Payment Gateway"),options:this.paymentsType.map(s=>({label:s.label,value:s.identifier})),value:this.activePayment.identifier,resolve:e,reject:t})});this.select(this.paymentsType.filter(e=>e.identifier===r[0].value)[0])}catch{}},select(r){this.showPayment=!1,POS.setPaymentActive(r)},closePopup(){this.popup.close(),POS.selectedPaymentType.next(null)},deletePayment(r){POS.removePayment(r)},selectPaymentAsActive(r){this.select(this.paymentsType.filter(e=>e.identifier===r.target.value)[0])},async submiAsUnpaid(){let r;try{r=await new Promise(t=>{const s=v.show(R,{title:d("Save As Unpaid"),message:d("Are you sure you want to save this order as unpaid?"),onAction:i=>{t(i)}})})}catch(t){f.error(t.message||d("An unexpected error occured while saving the order as unpaid.")).subscribe(),console.log(t)}if(!r)return!1;const e=v.show(D);try{POS.order.next({...POS.order.getValue(),payments:[]}),POS.refreshCart();const t=await new Promise((s,i)=>{POS.proceedSubmitting(POS.order.getValue(),s,i)});e.close(),this.popup.close(),f.success(t.message).subscribe(),POS.printOrderReceipt(t.data.order,"silent")}catch(t){e.close(),f.error(t.message||d("An error occured while saving the order as unpaid.")).subscribe()}},getPaymentLabel(r){const e=this.paymentsType.filter(t=>t.identifier===r.identifier)[0];return e?e.label:r.identifier},submitOrder(r={}){const e=v.show(D);try{const t={...POS.order.getValue(),...r};POS.submitOrder(t).then(s=>{e.close(),f.success(s.message).subscribe(),POS.printOrderReceipt(s.data.order,"silent"),this.popup.close()},s=>{e.close(),f.error(s.message).subscribe()})}catch(t){e.close(),f.error(t.message||d("An unexpected error occured while submitting the order.")).subscribe(),console.log(t)}}}},Vt={key:0,id:"ns-payment-popup",class:"w-screen h-screen p-8 flex overflow-hidden"},Tt={class:"flex flex-col flex-auto lg:flex-row shadow-xl"},St={class:"w-full lg:w-56 lg:h-full flex justify-between px-2 lg:px-0 lg:block items-center lg:items-start"},Ot={class:"lg:hidden text-xl text-center my-4 font-bold lg:my-8"},At={key:0},jt=o("div",{class:"h-16 hidden lg:block"},null,-1),qt={class:"hidden lg:block"},$t=["onClick"],Ft={class:"px-2 rounded-full h-8 w-8 flex items-center justify-center ns-label"},It={class:"overflow-hidden flex flex-col flex-auto"},Qt={class:"flex flex-col flex-auto overflow-hidden"},Ut={class:"h-12 hidden items-center justify-between lg:flex"},Et={class:"text-xl hidden lg:block text-center my-4 font-bold lg:my-8"},Rt={key:0,class:"hidden-md"},Bt={class:"px-2"},Lt={key:0,class:"flex flex-auto ns-payment-wrapper overflow-y-auto"},Dt={key:1,class:"flex flex-auto items-center justify-center bg-white"},Wt={class:"font-bold text-center text-3xl"},Yt={class:"text-center"},Nt={key:2,class:"flex flex-auto ns-payment-wrapper overflow-y-auto p-2 flex-col"},Ht={class:"text-center font-bold py-2"},Mt={class:"flex-auto"},zt={key:0,class:"p-2 flex justify-center mb-2 items-center"},Gt={class:"font-semibold"},Kt={class:"flex items-center"},Jt=["onClick"],Xt=o("i",{class:"las la-trash-alt"},null,-1),Zt=[Xt],es={key:1,class:"default rounded-full h-8 w-8 flex items-center justify-center ml-2"},ts=o("i",{class:"las la-lock"},null,-1),ss=[ts],is={key:0,class:"flex lg:hidden ns-payment-buttons"},rs={class:"text-sm"},os={class:"text-sm"},as={class:"text-sm"},ls={class:"text-sm mr-1"},us={class:"px-2 rounded-full h-6 w-6 text-xs flex items-center justify-center ns-label"},cs={key:1,class:"flex-col sm:flex-row w-full ns-payment-footer justify-end p-2 hidden lg:flex"},ds={class:"flex justify-end"},ps=o("i",{class:"las la-cash-register"},null,-1),_s={key:1,class:"flex -mx-2"},ms={class:"px-2"},hs=o("i",{class:"las la-bookmark"},null,-1),fs=o("i",{class:"las la-save"},null,-1),ys={key:0,class:"px-2"},xs=o("i",{class:"las la-hands-helping"},null,-1);function bs(r,e,t,s,i,n){const a=T("ns-close-button"),l=T("ns-button");return i.order?(_(),m("div",Vt,[o("div",Tt,[o("div",St,[o("h3",Ot,[S(c(n.__("Gateway"))+" ",1),i.activePayment?(_(),m("span",At,": "+c(i.activePayment.label),1)):y("",!0)]),jt,o("ul",qt,[(_(!0),m(F,null,I(i.paymentsType,u=>(_(),m("li",{onClick:h=>n.select(u),class:L([u.selected&&!i.showPayment?"ns-visible":"","cursor-pointer ns-payment-gateway py-2 px-3"]),key:u.identifier},c(u.label),11,$t))),128)),i.paymentsType.length>0?(_(),m("li",{key:0,onClick:e[0]||(e[0]=u=>i.showPayment=!0),class:L([i.showPayment?"ns-visible":"","cursor-pointer py-2 px-3 ns-payment-list border-t mt-4 flex items-center justify-between"])},[o("span",null,c(n.__("Payment List")),1),o("span",Ft,c(i.order.payments.length),1)],2)):y("",!0)]),V(a,{class:"lg:hidden",onClick:e[1]||(e[1]=u=>n.closePopup())})]),o("div",It,[o("div",Qt,[o("div",Ut,[o("div",null,[o("h3",Et,[S(c(n.__("Gateway"))+" ",1),i.activePayment?(_(),m("span",Rt,": "+c(i.activePayment.label),1)):y("",!0)])]),o("div",Bt,[V(a,{onClick:e[2]||(e[2]=u=>n.closePopup())})])]),!i.showPayment&&i.activePayment?(_(),m("div",Lt,[(_(),$(de(i.currentPaymentComponent),{onSubmit:e[3]||(e[3]=u=>n.submitOrder()),label:i.activePayment.label,identifier:i.activePayment.identifier},null,40,["label","identifier"]))])):y("",!0),i.activePayment?y("",!0):(_(),m("div",Dt,[o("div",null,[o("h3",Wt,c(n.__("Unable to Proceed")),1),o("p",Yt,c(n.__("Your system doesn't have any valid Payment Type. Consider creating one and try again.")),1)])])),i.showPayment?(_(),m("div",Nt,[o("h3",Ht,c(n.__("List Of Payments")),1),o("ul",Mt,[i.order.payments.length===0?(_(),m("li",zt,[o("h3",Gt,c(n.__("No Payment added.")),1)])):y("",!0),(_(!0),m(F,null,I(i.order.payments,(u,h)=>(_(),m("li",{key:h,class:"p-2 flex justify-between mb-2 items-center"},[o("span",null,c(n.getPaymentLabel(u)),1),o("div",Kt,[o("span",null,c(n.nsCurrency(u.value)),1),u.id?y("",!0):(_(),m("button",{key:0,onClick:p=>n.deletePayment(u),class:"error rounded-full h-8 w-8 flex items-center justify-center ml-2"},Zt,8,Jt)),u.id?(_(),m("button",es,ss)):y("",!0)])]))),128))])])):y("",!0)]),i.activePayment?(_(),m("div",is,[o("button",{onClick:e[4]||(e[4]=u=>n.selectPayment()),class:"flex items-center justify-center w-1/3 text-2xl flex-auto h-12 font-bold ns-payment-type-button"},[o("span",rs,c(n.__("Payment Type")),1)]),i.order.tendered>=i.order.total?(_(),m("button",{key:0,onClick:e[5]||(e[5]=u=>n.submitOrder()),class:"flex items-center justify-center w-1/3 text-2xl flex-auto h-12 ns-submit-button font-bold"},[o("span",os,c(n.__("Submit Payment")),1)])):y("",!0),i.order.tenderedn.submitOrder({payment_status:"unpaid"})),class:"flex items-center justify-center w-1/3 text-2xl flex-auto h-12 ns-layaway-button font-bold"},[o("span",as,c(n.__("Layaway")),1)])):y("",!0),o("button",{onClick:e[7]||(e[7]=u=>i.showPayment=!0),class:"w-1/3 flex ns-payment-button text-2xl flex-auto h-12 items-center justify-center font-bold"},[o("span",ls,c(n.__("Payment List")),1),o("span",us,c(i.order.payments.length),1)])])):y("",!0),i.activePayment?(_(),m("div",cs,[o("div",ds,[i.order.tendered>=i.order.total?(_(),$(l,{key:0,onClick:e[8]||(e[8]=u=>n.submitOrder()),type:i.order.tendered>=i.order.total?"success":"info"},{default:O(()=>[o("span",null,[ps,S(" "+c(n.__("Submit Payment")),1)])]),_:1},8,["type"])):y("",!0),i.order.tenderedn.submitOrder({payment_status:"unpaid"})),type:i.order.tendered>=i.order.total?"success":"info"},{default:O(()=>[o("span",null,[hs,S(" "+c(n.__("Layaway"))+" — "+c(n.nsCurrency(n.expectedPayment)),1)])]),_:1},8,["type"])):y("",!0),i.order.tendered>0?(_(),$(l,{key:1,onClick:e[10]||(e[10]=u=>n.submitOrder({payment_status:"unpaid"})),type:"info"},{default:O(()=>[o("span",null,[fs,S(" "+c(n.__("Update")),1)])]),_:1})):y("",!0)]),i.order.tendered===0?(_(),m("div",ys,[V(l,{onClick:e[11]||(e[11]=u=>n.submiAsUnpaid()),type:"info"},{default:O(()=>[o("span",null,[xs,S(" "+c(n.__("Save As Unpaid")),1)])]),_:1})])):y("",!0)])):y("",!0)])])):y("",!0)])])])):y("",!0)}const gs=j(Ct,[["render",bs]]);class G{constructor(e){this.order=e}run(){return new Promise((e,t)=>{v.show(gs,{resolve:e,reject:t,order:this.order})})}}window.PaymentQueue=G;class K{constructor(e){this.order=e}run(){return new Promise((e,t)=>this.order.products.length===0?(f.error(d("You need to provide some products before proceeding.")).subscribe(),t(!1)):e(!0))}}window.ProductsQueue=K;class J{constructor(e){this.order=e}run(){return new Promise((e,t)=>{if(this.order.type===void 0)return v.show(ne,{resolve:e,reject:t});e(!0)})}}window.TypeQueue=J;class vs{constructor(){b(this,"screenIs");this.detect()}detect(){window.innerWidth<544?this.screenIs="xs":window.innerWidth>=544&&window.innerWidth<768?this.screenIs="sm":window.innerWidth>=768&&window.innerWidth<992?this.screenIs="md":window.innerWidth>=992&&window.innerWidth<1200?this.screenIs="lg":window.innerWidth>=1200&&(this.screenIs="xl")}is(e){return e===void 0?this.screenIs:this.screenIs===e}}const ws={name:"ns-pos-layaway-popup",props:["popup"],data(){return{fields:[],instalments:[],formValidation:new ae,subscription:null,totalPayments:0}},mounted(){this.loadFields()},updated(){setTimeout(()=>{document.querySelector(".is-popup #total_instalments").addEventListener("change",()=>{const r=this.formValidation.extractFields(this.fields).total_instalments;this.generatePaymentFields(r)}),document.querySelector(".is-popup #total_instalments").addEventListener("focus",()=>{document.querySelector(".is-popup #total_instalments").select()})},200)},computed:{expectedPayment(){const r=this.order.customer.group.minimal_credit_payment;return nsRawCurrency(this.order.total*r/100)},order(){return this.popup.params.order.instalments=this.popup.params.order.instalments.map(r=>{for(let e in r)if(typeof r[e]!="object"){if(e==="date"){const t={type:"date",name:e,label:d("Date"),disabled:r.paid===1,value:moment(r.date).format("YYYY-MM-DD")};r[e]=t}else if(e==="amount"){const t={type:"number",name:e,label:d("Amount"),disabled:r.paid===1,value:r.amount};r[e]=t}else if(!["paid","id"].includes(e)){const t={type:"hidden",name:e,value:r[e]};r[e]=t}}return r}),this.popup.params.order}},unmounted(){},methods:{__:d,nsCurrency:A,refreshTotalPayments(){if(this.order.instalments.length>0){const r=nsRawCurrency(this.order.instalments.map(e=>parseFloat(e.amount.value)||0).reduce((e,t)=>parseFloat(e)+parseFloat(t)));this.totalPayments=this.order.total-r}else this.totalPayments=0},removeInstalment(r){const e=this.order.instalments.indexOf(r);this.order.instalments.splice(e,1),this.$forceUpdate()},generatePaymentFields(r){this.order.instalments=new Array(parseInt(r)).fill("").map((e,t)=>({date:{type:"date",name:"date",label:"Date",value:t===0?ns.date.moment.format("YYYY-MM-DD"):""},amount:{type:"number",name:"amount",label:"Amount",value:t===0?this.expectedPayment:0},readonly:{type:"hidden",name:"readonly",value:this.expectedPayment>0&&t===0}})),this.$forceUpdate(),this.refreshTotalPayments()},close(){this.popup.params.reject({status:"error",message:d("You must define layaway settings before proceeding.")}),this.popup.close()},skipInstalments(){this.expectedPayment>0?(this.order.instalments=[{amount:this.expectedPayment,date:ns.date.current}],this.order.final_payment_date=this.order.instalments.reverse()[0].date,this.order.total_instalments=this.order.instalments.length,this.order.support_instalments=!1):(this.order.final_payment_date=ns.date.current,this.order.total_instalments=0,this.order.support_instalments=!1),this.popup.close(),POS.order.next(this.order);const{resolve:r,reject:e}=this.popup.params;return r({order:this.order,skip_layaway:!0})},updateOrder(){if(this.order.instalments.length===0)return f.error(d("Please provide instalments before proceeding.")).subscribe();if(this.fields.forEach(u=>this.formValidation.validateField(u)),!this.formValidation.fieldsValid(this.fields))return f.error(d("Unable to process, the form is not valid")).subscribe();this.$forceUpdate();const r=this.order.instalments.map(u=>({amount:parseFloat(u.amount.value),date:u.date.value})),e=nsRawCurrency(r.map(u=>u.amount).reduce((u,h)=>parseFloat(u)+parseFloat(h)));if(r.filter(u=>u.date===void 0||u.date==="").length>0)return f.error(d("One or more instalments has an invalid date.")).subscribe();if(r.filter(u=>!(u.amount>0)).length>0)return f.error(d("One or more instalments has an invalid amount.")).subscribe();if(r.filter(u=>moment(u.date).isBefore(ns.date.moment.startOf("day"))).length>0)return f.error(d("One or more instalments has a date prior to the current date.")).subscribe();const t=r.filter(u=>moment(u.date).isSame(ns.date.moment.startOf("day"),"day"));let s=0;if(t.forEach(u=>{s+=parseFloat(u.amount)}),s{const p=moment(u.date),g=moment(h.date);return p.isBefore(g)?-1:p.isAfter(g)?1:0});const i=this.formValidation.extractFields(this.fields);i.final_payment_date=r.reverse()[0].date,i.total_instalments=r.length;const n={...this.popup.params.order,...i,instalments:r},{resolve:a,reject:l}=this.popup.params;return this.popup.close(),POS.order.next(n),a({order:n,skip_layaway:!1})},loadFields(){k.get("/api/fields/ns.layaway").subscribe(r=>{this.fields=this.formValidation.createFields(r),this.fields.forEach(e=>{e.name==="total_instalments"&&(e.value=this.order.total_instalments||0)})})}}},Ps={class:"shadow-lg h-95vh md:h-5/6-screen lg:h-5/6-screen w-95vw md:w-4/6-screen lg:w-3/6-screen ns-box flex flex-col"},ks={class:"p-2 border-b ns-box-header flex justify-between items-center"},Cs={class:"font-semibold"},Vs={class:"p-2 flex-auto flex flex-col relative overflow-y-auto"},Ts={key:0,class:"absolute h-full w-full flex items-center justify-center"},Ss={class:"p-2 elevation-surface info mb-2 text-center text-2xl font-bold flex justify-between"},Os={class:"flex flex-col flex-auto overflow-hidden"},As={class:"border-b ns-box-body"},js={class:"text-2xl flex justify-between py-2 text-primary"},qs={class:"text-sm"},$s={class:"p-2 mb-2 text-center bg-green-200 text-green-700"},Fs={class:"flex-auto overflow-y-auto"},Is={class:"flex flex-auto"},Qs={class:"px-1 w-full md:w-1/2"},Us={class:"px-1 w-full md:w-1/2"},Es={class:"flex items-center"},Rs=["onClick"],Bs=o("i",{class:"las la-times"},null,-1),Ls=[Bs],Ds={key:0,class:"my-2"},Ws={class:"p-2 elevation-surface border text-primary text-center"},Ys={class:"p-2 flex border-t ns-box-footer justify-between flex-shrink-0"},Ns={class:"md:-mx-1 flex flex-col md:flex-row"},Hs={class:"md:px-1"},Ms={class:"md:-mx-1 flex flex-col md:flex-row"},zs={class:"md:px-1"},Gs={class:"md:px-1"};function Ks(r,e,t,s,i,n){const a=T("ns-close-button"),l=T("ns-spinner"),u=T("ns-field"),h=T("ns-button");return _(),m("div",Ps,[o("div",ks,[o("h3",Cs,c(n.__("Layaway Parameters")),1),o("div",null,[V(a,{onClick:e[0]||(e[0]=p=>n.close())})])]),o("div",Vs,[i.fields.length===0?(_(),m("div",Ts,[V(l)])):y("",!0),o("div",Ss,[o("span",null,c(n.__("Minimum Payment")),1),o("span",null,c(n.nsCurrency(n.expectedPayment)),1)]),o("div",null,[(_(!0),m(F,null,I(i.fields,(p,g)=>(_(),$(u,{field:p,key:g},null,8,["field"]))),128))]),o("div",Os,[o("div",As,[o("h3",js,[o("span",null,c(n.__("Instalments & Payments")),1),o("p",null,[o("span",qs,"("+c(n.nsCurrency(i.totalPayments))+")",1),o("span",null,c(n.nsCurrency(r.total)),1)])]),o("p",$s,c(n.__("The final payment date must be the last within the instalments.")),1)]),o("div",Fs,[(_(!0),m(F,null,I(n.order.instalments,(p,g)=>(_(),m("div",{class:"flex w-full -mx-1 py-2",key:g},[o("div",Is,[o("div",Qs,[V(u,{onChange:e[1]||(e[1]=q=>n.refreshTotalPayments()),field:p.date},null,8,["field"])]),o("div",Us,[V(u,{onChange:e[2]||(e[2]=q=>n.refreshTotalPayments()),field:p.amount},null,8,["field"])])]),o("div",Es,[o("button",{onClick:q=>n.removeInstalment(p),class:"items-center flex justify-center h-8 w-8 rounded border text-primary ns-inset-button error"},Ls,8,Rs)])]))),128)),n.order.instalments.length===0?(_(),m("div",Ds,[o("p",Ws,c(n.__("There is no instalment defined. Please set how many instalments are allowed for this order")),1)])):y("",!0)])])]),o("div",Ys,[o("div",Ns,[o("div",Hs,[V(h,{onClick:e[3]||(e[3]=p=>n.skipInstalments()),type:"info"},{default:O(()=>[S(c(n.__("Skip Instalments")),1)]),_:1})])]),o("div",Ms,[o("div",zs,[V(h,{onClick:e[4]||(e[4]=p=>n.close()),type:"error"},{default:O(()=>[S(c(n.__("Cancel")),1)]),_:1})]),o("div",Gs,[V(h,{onClick:e[5]||(e[5]=p=>n.updateOrder()),type:"info"},{default:O(()=>[S(c(n.__("Proceed")),1)]),_:1})])])])])}const X=j(ws,[["render",Ks]]),Js=window.nsPosDashboardButton=E(()=>U(()=>import("./ns-pos-dashboard-button-ad57275c.js"),["./ns-pos-dashboard-button-ad57275c.js","./currency-feccde3d.js","./_plugin-vue_export-helper-c27b6911.js","./runtime-core.esm-bundler-414a078a.js"],import.meta.url)),Xs=window.nsPosPendingOrderButton=E(()=>U(()=>import("./ns-pos-pending-orders-button-4960c118.js"),["./ns-pos-pending-orders-button-4960c118.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css"],import.meta.url)),Zs=window.nsPosOrderTypeButton=E(()=>U(()=>import("./ns-pos-order-type-button-409712b0.js"),["./ns-pos-order-type-button-409712b0.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-pos-shipping-popup-dffc98ef.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css","./ns-orders-preview-popup-3c654295.js","./index.es-25aa42ee.js"],import.meta.url)),ei=window.nsPosCustomersButton=E(()=>U(()=>import("./ns-pos-customers-button-00b4326b.js"),["./ns-pos-customers-button-00b4326b.js","./preload-helper-41c905a7.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./_plugin-vue_export-helper-c27b6911.js"],import.meta.url)),ti=window.nsPosResetButton=E(()=>U(()=>import("./ns-pos-reset-button-32b971e5.js"),["./ns-pos-reset-button-32b971e5.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css"],import.meta.url)),si=window.nsPosCashRegister=E(()=>U(()=>import("./ns-pos-registers-button-0ba2bc51.js"),["./ns-pos-registers-button-0ba2bc51.js","./bootstrap-ffaf6d09.js","./currency-feccde3d.js","./chart-2ccf8ff7.js","./runtime-core.esm-bundler-414a078a.js","./ns-prompt-popup-24cc8d6f.js","./_plugin-vue_export-helper-c27b6911.js","./ns-prompt-popup-6013118d.css"],import.meta.url));window.nsLayawayPopup=X;window.nsPosShippingPopup=H;window.CustomerQueue=z;window.PaymentQueue=G;window.ProductsQueue=K;window.TypeQueue=J;let Z=class{constructor(){b(this,"_cartButtons");b(this,"_products");b(this,"_breadcrumbs");b(this,"_customers");b(this,"_settings");b(this,"_types");b(this,"_orderTypeProcessQueue",[]);b(this,"_paymentsType");b(this,"_order");b(this,"_screen");b(this,"_holdPopupEnabled",!0);b(this,"_initialQueue",[]);b(this,"_options");b(this,"_responsive",new vs);b(this,"_visibleSection");b(this,"_isSubmitting",!1);b(this,"_processingAddQueue",!1);b(this,"_selectedPaymentType");b(this,"_userPermissions");b(this,"print");b(this,"defaultOrder",()=>({discount_type:null,title:"",discount:0,register_id:this.get("register")?this.get("register").id:void 0,discount_percentage:0,subtotal:0,total:0,coupons:[],total_coupons:0,tendered:0,note:"",note_visibility:"hidden",tax_group_id:void 0,tax_type:void 0,taxes:[],tax_groups:[],payment_status:void 0,customer_id:void 0,change:0,total_products:0,shipping:0,tax_value:0,products_exclusive_tax_value:0,products_inclusive_tax_value:0,total_tax_value:0,shipping_rate:0,shipping_type:void 0,customer:void 0,type:void 0,products:[],instalments:[],payments:[],addresses:{shipping:void 0,billing:void 0}}));b(this,"addToCartQueue",[Ie,re]);this.initialize(),this.print=new le({urls:systemUrls,options:systemOptions})}get screen(){return this._screen}get visibleSection(){return this._visibleSection}get paymentsType(){return this._paymentsType}get selectedPaymentType(){return this._selectedPaymentType}get order(){return this._order}get types(){return this._types}get products(){return this._products}get customers(){return this._customers}get options(){return this._options}get orderTypeQueue(){return this._orderTypeProcessQueue}get settings(){return this._settings}get breadcrumbs(){return this._breadcrumbs}get initialQueue(){return this._initialQueue}get responsive(){return this._responsive}get processingAddQueue(){return this._processingAddQueue}get cartButtons(){return this._cartButtons}async reset(){return new Promise(async(e,t)=>{try{this._isSubmitting=!1,this.order.next(this.defaultOrder()),this.products.next([]),this._customers.next([]),this._breadcrumbs.next([]),this._cartButtons.next({}),this.defineCurrentScreen(),this.setHoldPopupEnabled(!0),w.doAction("ns-before-cart-reset"),await this.processInitialQueue(),w.doAction("ns-after-cart-changed"),w.doAction("ns-after-cart-reset"),e(!0)}catch(s){t(s)}})}initialize(){this._userPermissions=new P([]),this._products=new P([]),this._customers=new P([]),this._types=new P([]),this._breadcrumbs=new P([]),this._screen=new P(""),this._paymentsType=new P([]),this._visibleSection=new P("both"),this._options=new P({}),this._settings=new P({}),this._order=new P(this.defaultOrder()),this._selectedPaymentType=new P(null),this._cartButtons=new P({}),this._orderTypeProcessQueue=[{identifier:"handle.delivery-order",promise:e=>new Promise((t,s)=>e&&e.identifier==="delivery"?v.show(H,{resolve:t,reject:s}):t({status:"success",message:"Proceed"}))}],this.initialQueue.push(()=>new Promise((e,t)=>{k.get("/api/users/permissions/").subscribe({next:s=>{this._userPermissions.next(s),e(s)},error:s=>{t(s)}})})),this.initialQueue.push(()=>new Promise((e,t)=>{const s=this.options.getValue(),i=this.order.getValue();return i.tax_type=s.ns_pos_tax_type,s.ns_pos_tax_group!==!1&&(i.tax_group_id=s.ns_pos_tax_group,this.order.next(i)),e({status:"success",message:"tax group assignated"})})),this.initialQueue.push(()=>new Promise((e,t)=>{const s=this.options.getValue();return this.order.getValue(),s.ns_customers_default!==!1&&k.get(`/api/customers/${s.ns_customers_default}`).subscribe({next:i=>{this.selectCustomer(i),e({status:"success",message:d("The customer has been loaded")})},error:i=>{Y.error(d("An error has occured"),d("Unable to select the default customer. Looks like the customer no longer exists. Consider changing the default customer on the settings."),{actions:{readMore:{label:d("Read More"),onClick:n=>{n.close(),window.open("https://my.nexopos.com/en/documentation/troubleshooting/no-default-customer","_blank")}},close:{label:d("Close")}}}),t(i)}}),e({status:"success",message:"no default customer is selected."})})),w.addAction("ns-after-cart-changed","listen-add-to-cart",()=>this.refreshCart()),this.types.subscribe(e=>{const t=Object.values(e).filter(s=>s.selected);if(t.length>0){const s=this.order.getValue();s.type=t[0],this.order.next(s)}}),window.addEventListener("resize",()=>{this._responsive.detect(),this.defineCurrentScreen()}),window.onbeforeunload=()=>{if(this.products.getValue().length>0)return d("Some products has been added to the cart. Would youl ike to discard this order ?")}}getSalePrice(e,t){return this.options.getValue().ns_pos_price_with_tax==="yes"?Q(e.sale_price_with_tax):Q(e.sale_price_without_tax)}getCustomPrice(e,t){return this.options.getValue().ns_pos_price_with_tax==="yes"?Q(e.custom_price_with_tax):Q(e.custom_price_without_tax)}getWholesalePrice(e,t){return this.options.getValue().ns_pos_price_with_tax==="yes"?Q(e.wholesale_price_with_tax):Q(e.wholesale_price_without_tax)}setHoldPopupEnabled(e=!0){this._holdPopupEnabled=e}getHoldPopupEnabled(){return this._holdPopupEnabled}async processInitialQueue(){return new Promise(async(e,t)=>{for(let s in this._initialQueue)try{const i=await Promise.race([this._initialQueue[s](),new Promise((n,a)=>setTimeout(()=>a(new Error("Timeout")),6e4))])}catch(i){t(i),f.error(i.message).subscribe()}e(!0)})}removeCoupon(e){const t=this.order.getValue(),s=t.coupons,i=s.indexOf(e);s.splice(i,1),t.coupons=s,this.order.next(t)}pushCoupon(e){const t=this.order.getValue();t.coupons.forEach(s=>{if(s.code===e.code){const i=d("This coupon is already added to the cart");throw f.error(i).subscribe(),i}}),t.coupons.push(e),this.order.next(t),this.refreshCart()}get header(){const e={buttons:{nsPosDashboardButton:Js,nsPosPendingOrderButton:Xs,nsPosOrderTypeButton:Zs,nsPosCustomersButton:ei,nsPosResetButton:ti}};return this.options.getValue().ns_pos_registers_enabled==="yes"&&(e.buttons.nsPosCashRegister=si),w.doAction("ns-pos-header",e),e}defineOptions(e){this._options.next(e)}defineCurrentScreen(){this._visibleSection.next(["xs","sm"].includes(this._responsive.is())?"grid":"both"),this._screen.next(this._responsive.is())}changeVisibleSection(e){["both","cart","grid"].includes(e)&&(["cart","both"].includes(e)&&this.refreshCart(),this._visibleSection.next(e))}addPayment(e){if(e.value>0){const t=this._order.getValue();return t.payments.push(e),this._order.next(t),this.computePaid()}return f.error("Invalid amount.").subscribe()}removePayment(e){if(e.id!==void 0)return f.error(d("Unable to delete a payment attached to the order.")).subscribe();const t=this._order.getValue(),s=t.payments.indexOf(e);t.payments.splice(s,1),this._order.next(t),nsEvent.emit({identifier:"ns.pos.remove-payment",value:e}),this.updateCustomerAccount(e),this.computePaid()}updateCustomerAccount(e){if(e.identifier==="account-payment"){const t=this.order.getValue().customer;t.account_amount+=e.value,this.selectCustomer(t)}}getPriceWithoutTax(e,t,s){if(s==="inclusive")return N.computeInclusive(e,t);if(s==="exclusive")return e}getPriceWithTax(e,t,s){if(s==="inclusive")return e;if(s==="exclusive")return N.computeExclusive(e,t)}getVatValue(e,t,s){return s==="inclusive"?e-this.getPriceWithoutTax(e,t,s):s==="exclusive"?this.getPriceWithTax(e,t,s)-e:0}computeTaxes(){return new Promise((e,t)=>{let s=this.order.getValue();if(s=this.computeProductsTaxes(s),s.tax_group_id===void 0||s.tax_group_id===null)return this.computeOrderTaxes(s),e({data:{order:s},status:"success"});const i=s.tax_groups;if(Object.values(i).length>0)return i[s.tax_group_id]!==void 0&&(s=this.computeOrderTaxGroup(s,i[s.tax_group_id])),e({status:"success",data:{tax:i[s.tax_group_id],order:s}});if(s.tax_group_id!==void 0&&s.tax_group_id.toString().length>0)k.get(`/api/taxes/groups/${s.tax_group_id}`).subscribe({next:n=>(s=this.computeOrderTaxGroup(s,n),e({status:"success",data:{tax:n,order:s}})),error:n=>t(n)});else return t({status:"error",message:d("No tax group assigned to the order")})})}computeOrderTaxGroup(e,t){const s=t.taxes.map(n=>parseFloat(n.rate)).reduce((n,a)=>n+a),i=this.getVatValue(e.subtotal-e.discount,s,e.tax_type);if(t.taxes=t.taxes.map(n=>{const a=x(x(n.rate).divide(s).done()).multiply(100).done();return{id:n.id,tax_id:n.tax_id,name:n.name,rate:parseFloat(n.rate),tax_value:x(x(i).multiply(a).done()).divide(100).done()}}),t.taxes.length===0){f.error(d("The selected tax group doesn't have any assigned sub taxes. This might cause wrong figures."),d("Proceed"),{duration:!1}).subscribe();return}return e.tax_groups=e.tax_groups||[],e.taxes=t.taxes,e.tax_groups[t.id]=t,this.computeOrderTaxes(e)}computeOrderTaxes(e){const t=this.options.getValue().ns_pos_vat,s=this.options.getValue().ns_pos_price_with_tax==="yes";return["flat_vat","variable_vat","products_variable_vat","products_flat_vat"].includes(t)&&e.taxes&&e.taxes.length>0&&(e.tax_value+=e.taxes.map(i=>i.tax_value).reduce((i,n)=>i+n)),e.total_tax_value=e.tax_value,["products_variable_vat","products_flat_vat","products_vat"].includes(t)&&!s&&(e.total_tax_value=e.products_exclusive_tax_value+e.tax_value),e}computeProductsTaxes(e){const t=this.products.getValue(),s=t.filter(a=>a.tax_type==="inclusive").map(a=>a.tax_value),i=t.filter(a=>a.tax_type==="exclusive").map(a=>a.tax_value);e.products_exclusive_tax_value=0,e.products_inclusive_tax_value=0;const n=this.options.getValue().ns_pos_vat;return["products_flat_vat","products_variable_vat","products_vat"].includes(n)&&i.length>0&&(e.products_exclusive_tax_value+=i.reduce((a,l)=>a+l)),["products_flat_vat","products_variable_vat","products_vat"].includes(n)&&s.length>0&&(e.products_inclusive_tax_value+=s.reduce((a,l)=>a+l)),e.products=t,e.total_products=t.length,e}canProceedAsLaidAway(e){return new Promise(async(t,s)=>{const i=e.customer.group.minimal_credit_payment,n=x(e.total).multiply(i).done();let a=x(n).divide(100).done();a=parseFloat(a);try{const l=await new Promise((u,h)=>{v.show(X,{order:e,reject:h,resolve:u})});if(l.order.instalments.length===0&&l.order.tenderedg.amount>=a&&ue(g.date).isSame(ns.date.moment.startOf("day"),"day"));if(h.length===0)return t({status:"success",message:d("Layaway defined"),data:{order:l.order}});const p=h[0].amount;p>0?v.show(R,{title:d("Initial Payment"),message:d('In order to proceed, an initial payment of {amount} is required for the selected payment type "{paymentType}". Would you like to proceed ?').replace("{amount}",A(p)).replace("{paymentType}",u.label),onAction:g=>{if(g){const q={identifier:u.identifier,label:u.label,value:p,readonly:!1,selected:!0};this.addPayment(q),h[0].paid=!0,t({status:"success",message:d("Layaway defined"),data:{order:l.order}})}else s({status:"error",message:d("The request was canceled")})}}):t({status:"success",message:d("Layaway defined"),data:{order:l.order}})}}catch(l){return s(l)}})}submitOrder(e={}){return new Promise(async(t,s)=>{var i={...this.order.getValue(),...e};const n=i.customer.group.minimal_credit_payment;if(i.payment_status!=="hold"&&i.payments.length===0&&i.total>0&&i.total>i.tendered){if(this.options.getValue().ns_orders_allow_partial==="no"){const a=d("Partially paid orders are disabled.");return s({status:"error",message:a})}else if(n>=0)try{i=(await this.canProceedAsLaidAway(i)).data.order}catch(a){return s(a)}}return this._isSubmitting?s({status:"error",message:d("An order is currently being processed.")}):(this._isSubmitting=!0,this.proceedSubmitting(i,t,s))})}proceedSubmitting(e,t,s){const i=e.id!==void 0?"put":"post";return w.doAction("ns-order-before-submit",e),k[i](`/api/orders${e.id!==void 0?"/"+e.id:""}`,e).subscribe({next:n=>{t(n),this.reset(),w.doAction("ns-order-submit-successful",n),this._isSubmitting=!1;const a=this.options.getValue().ns_pos_complete_sale_audio;a.length>0&&new Audio(a).play()},error:n=>{this._isSubmitting=!1,s(n),w.doAction("ns-order-submit-failed",n)}})}defineQuantities(e,t=[]){return new Promise((s,i)=>{const a={unit:t.filter(u=>u.id===e.unit_id)[0]||{},sale_price_with_tax:e.mode==="normal"?parseFloat(e.price_with_tax):0,sale_price_without_tax:e.mode==="normal"?parseFloat(e.price_without_tax):0,sale_price:e.mode==="normal"?parseFloat(e.unit_price):0,sale_price_tax:e.mode==="normal"?e.tax_value:0,sale_price_edit:0,wholesale_price_with_tax:e.mode==="wholesale"?parseFloat(e.price_with_tax):0,wholesale_price_without_tax:e.mode==="wholesale"?parseFloat(e.price_without_tax):0,wholesale_price:e.mode==="wholesale"?parseFloat(e.unit_price):0,wholesale_price_tax:e.mode==="wholesale"?e.tax_value:0,wholesale_price_edit:0,custom_price_with_tax:e.mode==="custom"?parseFloat(e.price_with_tax):0,custom_price_without_tax:e.mode==="custom"?parseFloat(e.price_without_tax):0,custom_price:e.mode==="custom"?parseFloat(e.unit_price):0,custom_price_tax:e.mode==="custom"?e.tax_value:0,custom_price_edit:e.mode==="custom"?parseFloat(e.unit_price):0};let l;if(["inclusive","exclusive"].includes(e.tax_type))try{if(e.tax_group_id)k.get(`/api/taxes/groups/${e.tax_group_id}`).subscribe({next:u=>(["sale","wholesale","custom"].forEach(h=>{a[h+"_price_tax"]=u.taxes.map(p=>this.getVatValue(a[h+"_price"],p.rate,e.tax_type)).reduce((p,g)=>p+g),a["gross_"+h+"_price"]=a[h+"_price"]+a[h+"_price_tax"],a["net_"+h+"_price"]=a[h+"_price"]-a[h+"_price_tax"]}),l=u,s(a)),error:u=>{i(!1)}});else return a.sale_price_tax=0,a.wholesale_price_tax=0,a.sale_price_without_tax=e.unit_price,s(a)}catch{return f.error(d("An error has occurred while computing the product.")).subscribe()}return s(a)})}loadOrder(e){return new Promise((t,s)=>{k.get(`/api/orders/${e}/pos`).subscribe({next:async i=>{try{w.doAction("ns-before-load-order",{order:i})}catch(a){return s(a)}this.options.getValue(),i={...this.defaultOrder(),...i};const n=[];for(let a=0;al.product,l.$quantities=()=>{let u=l.product.unit_quantities.filter(h=>+h.id==+l.unit_quantity_id||h.id===void 0)[0];return l.mode==="custom"&&(u.custom_price_edit=l.unit_price,u.custom_price_with_tax=l.price_with_tax,u.custom_price_without_tax=l.price_without_tax,u.custom_price_tax=l.tax_value),u},n.push(l)}i.type=Object.values(this.types.getValue()).filter(a=>a.identifier===i.type)[0],i.addresses={shipping:i.shipping_address,billing:i.billing_address},delete i.shipping_address,delete i.billing_address,this.buildOrder(i),this.buildProducts(n),await this.selectCustomer(i.customer),t(i)},error:i=>s(i)})})}buildOrder(e){this.order.next(e)}buildProducts(e){this.recomputeProducts(e),this.products.next(e),w.doAction("ns-after-cart-changed")}printOrderReceipt(e,t){const s=this.options.getValue();if(s.ns_pos_printing_enabled_for==="disabled")return!1;if(s.ns_pos_printing_enabled_for==="all_orders"||s.ns_pos_printing_enabled_for==="partially_paid_orders"&&["paid","partially_paid"].includes(e.payment_status)||s.ns_pos_printing_enabled_for==="only_paid_orders"&&["paid"].includes(e.payment_status))this.print.process(e.id,"sale",t);else return!1}computePaid(){const e=this._order.getValue();e.tendered=0,e.payments.length>0&&(e.tendered=e.payments.map(t=>t.value).reduce((t,s)=>s+t)),e.tendered>=e.total?e.payment_status="paid":e.tendered>0&&e.tendered{s.identifier===e.identifier?s.selected=!0:s.selected=!1}),this._paymentsType.next(t)}definedPaymentsType(e){this._paymentsType.next(e)}selectCustomer(e){return new Promise((t,s)=>{const i=this.order.getValue(),n=Object.assign(e.billing||{},{});if(n.id!==void 0&&delete n.id,i.customer=e,i.customer_id=e.id,i.addresses.billing=n,this.order.next(i),e.group===void 0||e.group===null)k.get(`/api/customers/${e.id}/group`).subscribe({next:a=>{i.customer.group=a,this.order.next(i),t(i)},error:a=>{s(a)}});else return t(i)})}updateCart(e,t){for(let s in t)t[s]!==void 0&&(e[s]=t[s]);this.order.next(e),this.refreshCart()}checkCart(){const e=this.order.getValue(),t=[];e.coupons.forEach(s=>{let i=!0;s.products.length>0&&(i=e.products.filter(a=>s.products.map(l=>l.product_id).includes(a.product_id)).length>0,!i&&t.indexOf(s)===-1&&t.push(s));let n=!0;s.categories.length>0&&(n=e.products.filter(a=>s.categories.map(l=>l.category_id).includes(a.$original().category_id)).length>0,!n&&t.indexOf(s)===-1&&t.push(s))}),t.forEach(s=>{f.error(d(`The coupons "%s" has been removed from the cart, as it's required conditions are no more meet.`).replace("%s",s.name),d("Okay"),{duration:6e3}).subscribe(),this.removeCoupon(s)})}async refreshCart(){this.checkCart();const e=this.products.getValue();let t=this.order.getValue(),s=this.options.getValue().ns_pos_price_with_tax;const i=e.filter(p=>p.product_type!=="dynamic").map(p=>s==="yes"?p.total_price_with_tax:p.total_price_without_tax);if(i.length>0){let p=i.reduce((C,B)=>C+B),g=0,q=e.filter(C=>C.product_type==="dynamic").map(C=>(C.unit_price=p*C.rate/100,C.total_price=C.unit_price*C.quantity,C.total_price));q.length>0&&(g=q.reduce((C,B)=>C+B)),t.subtotal=p+g}else t.subtotal=0;const n=t.coupons.map(p=>p.type==="percentage_discount"?(p.value=t.subtotal*p.discount_value/100,p.value):(p.value=p.discount_value,p.value));t.total_coupons=0,n.length>0&&(t.total_coupons=n.reduce((p,g)=>p+g)),t.discount_type==="percentage"&&(t.discount=t.discount_percentage*t.subtotal/100),t.discount>t.subtotal&&t.total_coupons===0&&(t.discount=t.subtotal,f.info(d("The discount has been set to the cart subtotal.")).subscribe()),t.tax_value=0,t.total_tax_value=0,this.order.next(t);try{t=(await this.computeTaxes()).data.order}catch(p){p!==!1&&p.message!==void 0&&f.error(p.message||d("An unexpected error has occurred while fecthing taxes."),d("OKAY"),{duration:0}).subscribe()}const a=e.map(p=>p.tax_type==="inclusive"?p.tax_value:0);a.length>0&&a.reduce((p,g)=>p+g);const l=t.tax_type,u=this.options.getValue().ns_pos_vat;let h=0;if(["flat_vat","variable_vat","products_vat","products_flat_vat","products_variable_vat"].includes(u)&&(h=t.total_tax_value),l==="exclusive"){const p=x(t.subtotal).add(t.shipping||0).add(h).done();t.total=x(p).subtract(t.discount).subtract(t.total_coupons).done()}else{const p=x(t.subtotal).add(t.shipping||0).done();t.total=x(p).subtract(t.discount).subtract(t.total_coupons).done()}this.order.next(t),w.doAction("ns-cart-after-refreshed",t)}getStockUsage(e,t){const s=this._products.getValue().filter(i=>i.product_id===e&&i.unit_quantity_id===t).map(i=>i.quantity);return s.length>0?s.reduce((i,n)=>i+n):0}async addToCart(e){let t=new Object,s={product_id:e.id||0,name:e.name,discount_type:"percentage",discount:0,discount_percentage:0,product_type:e.product_type||"product",rate:e.rate||0,quantity:e.quantity||0,tax_group_id:e.tax_group_id,tax_type:e.tax_type||void 0,tax_value:0,unit_id:e.unit_id||0,unit_price:e.unit_price||0,price_with_tax:e.price_with_tax||0,price_without_tax:e.price_without_tax||0,unit_name:e.unit_name||"",total_price:0,total_price_without_tax:0,total_price_with_tax:0,mode:e.mode||"normal",$original:e.$original||(()=>e),$quantities:e.$quantities||void 0};if(this._processingAddQueue=!0,s.product_id!==0)for(let a in this.addToCartQueue)try{const u=await new this.addToCartQueue[a](s).run(t);t={...t,...u}}catch(l){if(l===!1)return this._processingAddQueue=!1,!1}this._processingAddQueue=!1,s={...s,...t};const i=this._products.getValue();if(this.settings.getValue().ns_pos_items_merge){const a=i.filter(l=>l.product_id===s.product_id&&l.tax_group_id===s.tax_group_id&&l.unit_id===s.unit_id&&l.unit_quantity_id===s.unit_quantity_id);a.length>0?a[0].quantity+=s.quantity:i.unshift(s)}else i.unshift(s);this.recomputeProducts(i),this.products.next(i);const n=this.options.getValue().ns_pos_new_item_audio;n.length>0&&new Audio(n).play(),w.doAction("ns-after-cart-changed")}defineTypes(e){this._types.next(e)}userCan(e){return this._userPermissions.getValue().filter(i=>i.namespace===e).length>0}async removeProductUsingIndex(e){const t=this._products.getValue();if(t[e].id)try{await new Promise((i,n)=>{const a=v.show(D);k.post("/api/users/check-permission/",{permission:"nexopos.pos.delete-order-product"}).subscribe({next:l=>{a.close(),i(l)},error:l=>{a.close(),n(l)}})}),this.resumeRemovingProductUsingIndex(e,t)}catch{Y.error(d("Forbidden Action"),d("You are not allowed to remove this product."))}else this.resumeRemovingProductUsingIndex(e,t)}resumeRemovingProductUsingIndex(e,t){t.splice(e,1),this.products.next(t),w.doAction("ns-after-cart-changed")}removeProduct(e){const t=this._products.getValue(),s=t.indexOf(e);t.splice(s,1),this.products.next(t),w.doAction("ns-after-cart-changed")}updateProduct(e,t,s=null){const i=this._products.getValue();s=s===null?i.indexOf(e):s,s=s===-1?0:s,i[s]={...e,...t},this.recomputeProducts(i),this.products.next(i),w.doAction("ns-after-cart-changed")}recomputeProducts(e=null){e.forEach(t=>{this.computeProduct(t)})}getProductUnitPrice(e,t){switch(e){case"custom":return t.custom_price_edit;case"normal":return t.sale_price_edit;case"wholesale":return t.wholesale_price_edit}}computeProductTax(e){switch(e.mode){case"custom":return this.computeCustomProductTax(e);case"normal":return this.computeNormalProductTax(e);case"wholesale":return this.computeWholesaleProductTax(e);default:return e}}proceedProductTaxComputation(e,t){const s=e.$original(),i=s.tax_group;let n=this.getProductUnitPrice(e.mode,e.$quantities()),a=0,l=this.getProductUnitPrice(e.mode,e.$quantities());if(i!=null&&i.taxes!==void 0){let u=0;switch(i.taxes.length>0&&(u=i.taxes.map(h=>h.rate).reduce((h,p)=>h+p)),s.tax_type){case"inclusive":n=this.getPriceWithoutTax(t,u,s.tax_type),l=t;break;case"exclusive":n=t,l=this.getPriceWithTax(t,u,s.tax_type);break}a=this.getVatValue(t,u,s.tax_type)}return{price_without_tax:n,tax_value:a,price_with_tax:l}}computeCustomProductTax(e){e.$original();const t=e.$quantities(),s=this.proceedProductTaxComputation(e,t.custom_price_edit);return t.custom_price_without_tax=s.price_without_tax,t.custom_price_with_tax=s.price_with_tax,t.custom_price_tax=s.tax_value,e.$quantities=()=>t,e}computeNormalProductTax(e){const t=e.$quantities(),s=this.proceedProductTaxComputation(e,t.sale_price_edit);return t.sale_price_without_tax=s.price_without_tax,t.sale_price_with_tax=s.price_with_tax,t.sale_price_tax=s.tax_value,e.$quantities=()=>t,e}computeWholesaleProductTax(e){const t=e.$quantities(),s=this.proceedProductTaxComputation(e,t.wholesale_price_edit);return t.wholesale_price_without_tax=s.price_without_tax,t.wholesale_price_with_tax=s.price_with_tax,t.wholesale_price_tax=s.tax_value,e.$quantities=()=>t,e}getPrice(e,t,s){switch(t){case"normal":return e["sale_price_"+s];case"wholesale":return e["wholesale_price_"+s];case"custom":return e["custom_price_"+s]}}computeProduct(e){e.product_type==="product"&&(e.mode==="normal"?(e.unit_price=this.getSalePrice(e.$quantities(),e.$original()),e.tax_value=x(e.$quantities().sale_price_tax).multiply(e.quantity).done()):e.mode==="wholesale"&&(e.unit_price=this.getWholesalePrice(e.$quantities(),e.$original()),e.tax_value=x(e.$quantities().wholesale_price_tax).multiply(e.quantity).done()),e.mode==="custom"&&(e.unit_price=this.getCustomPrice(e.$quantities(),e.$original()),e.tax_value=x(e.$quantities().custom_price_tax).multiply(e.quantity).done()));let t=0,s=0,i=this.getPrice(e.$quantities(),e.mode,"with_tax"),n=this.getPrice(e.$quantities(),e.mode,"without_tax");["flat","percentage"].includes(e.discount_type)&&(e.discount_type==="percentage"?(e.discount=x(x(x(e.unit_price).multiply(e.discount_percentage).done()).divide(100).done()).multiply(e.quantity).done(),t=x(x(x(n).multiply(e.discount_percentage).done()).divide(100).done()).multiply(e.quantity).done(),s=x(x(x(i).multiply(e.discount_percentage).done()).divide(100).done()).multiply(e.quantity).done()):(t=e.discount,s=e.discount)),e.price_with_tax=i,e.price_without_tax=n,e.total_price=x(x(e.unit_price).multiply(e.quantity).done()).subtract(e.discount).done(),e.total_price_with_tax=x(x(i).multiply(e.quantity).done()).subtract(s).done(),e.total_price_without_tax=x(x(n).multiply(e.quantity).done()).subtract(t).done(),w.doAction("ns-after-product-computed",e)}loadCustomer(e){return k.get(`/api/customers/${e}`)}defineSettings(e){this._settings.next(e)}voidOrder(e){e.id!==void 0?["hold"].includes(e.payment_status)?v.show(R,{title:d("Order Deletion"),message:d("The current order will be deleted as no payment has been made so far."),onAction:t=>{t&&k.delete(`/api/orders/${e.id}`).subscribe({next:s=>{f.success(s.message).subscribe(),this.reset()},error:s=>f.error(s.message).subscribe()})}}):v.show(he,{title:d("Void The Order"),message:d("The current order will be void. This will cancel the transaction, but the order won't be deleted. Further details about the operation will be tracked on the report. Consider providing the reason of this operation."),onAction:t=>{t!==!1&&k.post(`/api/orders/${e.id}/void`,{reason:t}).subscribe({next:s=>{f.success(s.message).subscribe(),this.reset()},error:s=>f.error(s.message).subscribe()})}}):f.error(d("Unable to void an unpaid order.")).subscribe()}async triggerOrderTypeSelection(e){for(let t=0;t