dealpos 12.56.2 → 12.56.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/POS/{chunk-NR5YGKS4.js → chunk-245BOOYR.js} +1 -1
- package/POS/{chunk-WEY4WTET.js → chunk-2DDZYMVU.js} +1 -1
- package/POS/{chunk-UXOT3BFW.js → chunk-2KXSDIL6.js} +1 -1
- package/POS/{chunk-GDZIOQMQ.js → chunk-4ECZ3YZK.js} +1 -1
- package/POS/{chunk-JVDBV7WJ.js → chunk-5PRTNLW4.js} +1 -1
- package/POS/{chunk-UZ3OOBYK.js → chunk-64BNPKEL.js} +1 -1
- package/POS/{chunk-H5T3CLXP.js → chunk-6TCQI6OW.js} +1 -1
- package/POS/{chunk-XN7RYYVF.js → chunk-7B7DAEE4.js} +1 -1
- package/POS/{chunk-AIGFWM5D.js → chunk-7IKIN2RK.js} +2 -2
- package/POS/{chunk-ARL3DTLR.js → chunk-A4WVTPKJ.js} +1 -1
- package/POS/{chunk-L3J4STUC.js → chunk-APAKUF4G.js} +1 -1
- package/POS/{chunk-4LK2MGPJ.js → chunk-CHVNPH6H.js} +1 -1
- package/POS/{chunk-CBK6ZOIN.js → chunk-CZNEYN3M.js} +1 -1
- package/POS/{chunk-V2QRPV7V.js → chunk-FC576RG2.js} +1 -1
- package/POS/{chunk-2ZPJLBIL.js → chunk-FMIGBC5X.js} +1 -1
- package/POS/{chunk-IERZSGMV.js → chunk-G35I3BRN.js} +1 -1
- package/POS/{chunk-XCMEEOEN.js → chunk-GGLBD22E.js} +1 -1
- package/POS/chunk-GXVWB6BP.js +1 -0
- package/POS/{chunk-4AF4634N.js → chunk-HL7PVVUT.js} +1 -1
- package/POS/{chunk-XCTQE46P.js → chunk-HMIU6YP5.js} +1 -1
- package/POS/{chunk-4WMEL55V.js → chunk-I64Z2JJM.js} +1 -1
- package/POS/{chunk-SHXKBDS2.js → chunk-ID3QQPGB.js} +1 -1
- package/POS/chunk-JNM76OTN.js +1 -0
- package/POS/{chunk-XXAHPRRR.js → chunk-K5YWHHDD.js} +1 -1
- package/POS/{chunk-EA4XZWAS.js → chunk-KNOT7DSU.js} +1 -1
- package/POS/{chunk-H4XNZXXZ.js → chunk-LVJ2FXLZ.js} +1 -1
- package/POS/{chunk-NEGPOUPL.js → chunk-MJH3KOMG.js} +1 -1
- package/POS/{chunk-OSTMGQKL.js → chunk-MW2L6DSK.js} +1 -1
- package/POS/{chunk-3X6OI364.js → chunk-MYEH6P67.js} +1 -1
- package/POS/{chunk-AAYMAIXG.js → chunk-NCA63DSU.js} +1 -1
- package/POS/{chunk-MHQGVRX4.js → chunk-OOEFSDB7.js} +1 -1
- package/POS/chunk-OY56AWLB.js +1 -0
- package/POS/{chunk-E5DJGNWC.js → chunk-OY5P25CH.js} +1 -1
- package/POS/{chunk-GACF24IP.js → chunk-OYQZ72KK.js} +1 -1
- package/POS/{chunk-CBLLFUKP.js → chunk-P66FZ6MB.js} +1 -1
- package/POS/{chunk-2JCJ4HT2.js → chunk-PXL4AV4L.js} +2 -2
- package/POS/{chunk-66MQRRWB.js → chunk-QBNW7DNI.js} +1 -1
- package/POS/{chunk-HZB57RQA.js → chunk-QEHMBSQS.js} +1 -1
- package/POS/{chunk-43RW7O7Z.js → chunk-R4WN6XV7.js} +1 -1
- package/POS/{chunk-Q43FP75D.js → chunk-RA5IW24I.js} +1 -1
- package/POS/{chunk-TFBM6L76.js → chunk-RJEKFX64.js} +1 -1
- package/POS/{chunk-RABWE56U.js → chunk-RJJOQ7UP.js} +1 -1
- package/POS/{chunk-PIJKR7KW.js → chunk-RSNQU4HN.js} +1 -1
- package/POS/{chunk-CWH3DSE2.js → chunk-T4V2VALE.js} +1 -1
- package/POS/{chunk-K72RQ7L6.js → chunk-TBVKU2NS.js} +1 -1
- package/POS/{chunk-6E2WZMZV.js → chunk-TT5OFF6R.js} +1 -1
- package/POS/{chunk-GAIGAKMK.js → chunk-TWJFM24E.js} +1 -1
- package/POS/{chunk-RNXFZDYI.js → chunk-TXRZRGDO.js} +1 -1
- package/POS/{chunk-47F77QQ5.js → chunk-TYHEP5ME.js} +1 -1
- package/POS/{chunk-XDWYZU7R.js → chunk-UDNCMQN6.js} +1 -1
- package/POS/{chunk-7YBM3F3N.js → chunk-ULALNCD5.js} +1 -1
- package/POS/{chunk-4B6SOLU5.js → chunk-UVG7ZRWW.js} +1 -1
- package/POS/{chunk-D6JYOG34.js → chunk-W5EVKAD3.js} +1 -1
- package/POS/{chunk-RVKH2GKL.js → chunk-WQCPSI46.js} +1 -1
- package/POS/{chunk-7NQUHBOF.js → chunk-XOYCMHQX.js} +1 -1
- package/POS/{chunk-KQ3VU5PB.js → chunk-XULAEY2T.js} +1 -1
- package/POS/{chunk-WULYCGRV.js → chunk-YKFOT6QK.js} +1 -1
- package/POS/{chunk-AFBUOWT2.js → chunk-YZ7S5WUV.js} +1 -1
- package/POS/{chunk-EEFFWXLP.js → chunk-ZBJ6Z3RC.js} +1 -1
- package/POS/{chunk-QZ3JP6YZ.js → chunk-ZNVAELC4.js} +1 -1
- package/POS/index.html +2 -2
- package/POS/{main-5D7Y5FU5.js → main-QY2R3EXQ.js} +2 -2
- package/package.json +1 -1
- package/POS/chunk-4PFIRQ6Z.js +0 -1
- package/POS/chunk-B2LHBO77.js +0 -1
- package/POS/chunk-DGYWCT5M.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as s}from"./chunk-
|
|
1
|
+
import{b as s}from"./chunk-MYEH6P67.js";import{fa as r,ja as a}from"./chunk-ZCFRJGRH.js";var i=class{to;from;constructor(){this.to=new Date,this.from=new Date}};var c=class o{cookiesService=a(s);_cookiesName="PaymentDate";dateFilter={from:new Date,to:new Date};set(e){this.saveFilterToCookie(e),this.dateFilter=e}initFilterDate(e){let t=this.get();return e.From=t.from,e.To=t.to,e}get(){return this.cookiesService.check(this._cookiesName)?this.dateFilter=JSON.parse(this.cookiesService.get(this._cookiesName)):this.dateFilter=new i,this.dateFilter}saveFilterToCookie(e){this.cookiesService.set(this._cookiesName,JSON.stringify(e),this.getExpiredDate(),"/")}clear(){this.cookiesService.delete(this._cookiesName,"/"),this.dateFilter=new i}getExpiredDate(){let e=new Date,n=1*60*60*1e3;return e.setTime(e.getTime()+n),e}ngOnDestroy(){console.log("DESTROY PAYMENT DATE SERVICE")}static \u0275fac=function(t){return new(t||o)};static \u0275prov=r({token:o,factory:o.\u0275fac,providedIn:"root"})};export{c as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Vn}from"./chunk-2Q3IVDEZ.js";import"./chunk-YJY6KPSM.js";import{a as En}from"./chunk-KTGBECZM.js";import{a as fn}from"./chunk-TK5H65DN.js";import{a as ot}from"./chunk-B5FODXLM.js";import{a as In,b as Dn}from"./chunk-PMOAIDAQ.js";import{a as _n,b as bn,c as vn,d as rt,e as yn}from"./chunk-2PZYB6LT.js";import{a as wn,e as kn,f as Nn}from"./chunk-RA5QFXG4.js";import{a as mt}from"./chunk-GJT6AXWW.js";import{a as Tn}from"./chunk-773CYXAP.js";import"./chunk-M7GZQQXL.js";import{a as lt,b as ct,c as st}from"./chunk-WVVQJ47P.js";import{b as xn,c as at}from"./chunk-YTXHEGOU.js";import{a as Sn}from"./chunk-DQ6V5VPA.js";import"./chunk-SE7OFLAL.js";import"./chunk-X4G74GI2.js";import"./chunk-TSKFNB7J.js";import{a as Mn,b as Pn}from"./chunk-WC6HLOBJ.js";import"./chunk-ZT4UZXP6.js";import"./chunk-GWNB6CTG.js";import"./chunk-MIJSOT4W.js";import"./chunk-OWK2XW4L.js";import{a as hn}from"./chunk-DKZYNKLJ.js";import{a as An}from"./chunk-CVIX55UC.js";import{a as dn,b as gn}from"./chunk-QSD2GDAR.js";import{b as On}from"./chunk-GGVPDLR2.js";import"./chunk-TDFBRYNF.js";import{b as Cn}from"./chunk-2SKKVXLC.js";import"./chunk-RQPAYSJS.js";import"./chunk-C4SDGOBF.js";import{a as G}from"./chunk-Q7CBBXN2.js";import{a as en,c as tn,e as nn,f as on}from"./chunk-RGIAK7TL.js";import{a as _e,b as he}from"./chunk-SIEUNTYO.js";import{c as un}from"./chunk-GDZIOQMQ.js";import"./chunk-GAIGAKMK.js";import{a as rn,b as ln}from"./chunk-PIJKR7KW.js";import"./chunk-VUGL7GL5.js";import"./chunk-MV3BEGPX.js";import{i as fe,j as Ce,k as oe,l as an,m as be,n as ve,o as ye,p as cn,r as sn,s as mn}from"./chunk-P3UEOU3P.js";import{Aa as nt,Ba as it,ua as Zt}from"./chunk-R5NLMT6O.js";import{a as R,b as U,o as pn}from"./chunk-ZNTHS7QL.js";import{e as Ae,f as Ve}from"./chunk-53ZY7AX4.js";import"./chunk-5ZJO3PQ6.js";import{a as Ee}from"./chunk-2FWFPV5I.js";import{C as ie,D as Ne,a as tt,c as te,h as Y,l as we,n as ne,q as Yt,r as ke}from"./chunk-7UM6XERA.js";import"./chunk-3X6OI364.js";import{a as Xt}from"./chunk-2ZPJLBIL.js";import{a as g,d as ge}from"./chunk-EQXS7YQT.js";import"./chunk-L3J4STUC.js";import{a as X}from"./chunk-A3H65TBP.js";import{$a as F,$b as L,B as Bt,Bb as A,C as O,Ca as V,Dc as H,Eb as d,G as Ut,Gb as p,Hd as Kt,J as jt,Jb as Tt,Jd as Ye,Kd as Xe,Lc as ue,Md as Ze,N as Qt,Na as He,Nc as de,Oa as ze,Ob as zt,Oc as z,Od as et,P as Lt,Pb as Gt,Qa as Ge,Qb as Jt,S as Wt,Sa as c,Ta as Q,Tc as Oe,U as $e,Ub as K,Vb as s,Wb as j,Xb as S,Xc as ee,Y as Z,Yb as Pe,Za as qt,_c as T,ac as W,ba as k,bc as q,c as Vt,cb as $t,cc as Te,dc as P,eb as v,ec as Ke,fa as N,fc as $,ib as m,j as Ft,ja as u,jb as Ht,n as Rt,na as M,nc as _,oc as b,pc as Ot,qb as Je,r as pe,tc as ce,ua as f,va as C,vb as r,wb as a,xb as y,yb as h,zb as x}from"./chunk-ZCFRJGRH.js";import{a as B,b as Et}from"./chunk-LHUGHE24.js";var pt=class{AppConfigJSON;Currencies;CustomerPOTypes;Entities;Payments;Taxes;SalesPOTypes;EstimateOptions;Data};var Fe=class{CurrencyID;CustomerID;Date;Discount;DiscountAmount;EntityID;ID;Note;Number;SalesID;TaxTypeID;TypeID;constructor(){this.CustomerID=g.GuidEmpty,this.EntityID=g.GuidEmpty,this.ID=g.GuidEmpty,this.TaxTypeID=g.GuidEmpty,this.Discount=0,this.DiscountAmount=0,this.Date=new Date().toDateString()}};var re=class{Email;Key;Mobile;Name;Phone;Value;PricebookID};var ut=class{ID;Index;Symbol;Name;ExchangeRate;ConversionSuggestion;ExchangeRateDate;ExchangeRateDateDisplay};var dt=class{ID;Name;DueDays;BlockDays;Description;PrintTemplateID;AccountID};var gt=class{DeliveryID;InvoiceID;InvoiceNumber;Message;OrderID;PaymentStateID;PaymentStateLabel;PrintMode;Success};var E=class o{estimateState=An({loadForm:new pt,outlet:{Name:"",ID:g.GuidEmpty},order:new Fe,cartItems:[],customer:new re,tax:new fn,currency:new ut,tag:new dt,discount:{discountAmount:0,discount:0},state:0,complete:new gt});loadForm=this.estimateState.select(e=>Object.freeze(e.loadForm()));order=this.estimateState.select(e=>Object.freeze(e.order()));outlet=this.estimateState.select(e=>Object.freeze(e.outlet()));cartItems=this.estimateState.select(e=>Object.freeze(e.cartItems()));customer=this.estimateState.select(e=>Object.freeze(e.customer()));tax=this.estimateState.select(e=>Object.freeze(e.tax()));currency=this.estimateState.select(e=>Object.freeze(e.currency()));tag=this.estimateState.select(e=>Object.freeze(e.tag()));discount=this.estimateState.select(e=>Object.freeze(e.discount()));state=this.estimateState.select(e=>Object.freeze(e.state()));complete=this.estimateState.select(e=>Object.freeze(e.complete()));updateLoadForm(e){this.estimateState.update("loadForm",e)}updateOutlet(e){this.estimateState.update("outlet",e)}updateOrder(e){this.estimateState.update("order",e)}updateCartItems(e){this.estimateState.update("cartItems",e)}updateCustomer(e){this.estimateState.update("customer",e)}updateTax(e){this.estimateState.update("tax",e)}updateCurrency(e){this.estimateState.update("currency",e)}updateTag(e){this.estimateState.update("tag",e)}updateDiscount(e){this.estimateState.update("discount",e)}updateState(e){this.estimateState.update("state",e)}updateComplete(e){this.estimateState.update("complete",e)}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};var xe=class{ID;Name;Code;Cost;ThumbnailUrl;CouponDiscount;Discount;DiscountAmount;EntityID;Expense;InventoryTypeID;LoyaltyPoint;Note;PromotionGift;Quantity;UnitQuantity;SalesID;VariantID;VariantUnitQuantity;isMaxInventory;UOM;UOMName;UnitCost;UnitPrice;TypeID;Storage;Taxable;Price;Serial;PriceBookID;Variant;PriceTypeID;PriceNote;get Total(){return this.Price*(this.Quantity*this.UnitQuantity)*((100-this.Discount)/100)}get getItemAfterDiscount(){let e=this.getDiscPercentagePerItem();return this.DiscountAmount<e?e-this.DiscountAmount:0}getDiscPercentagePerItem(){let e=this.UnitPrice;return this.Discount>0&&(e=(100-this.Discount)/100*this.UnitPrice),e}};var Se=class o{constructor(){}generateCartItem(e){let t=new xe;return t.Name=e.Name,t.ThumbnailUrl=e.ThumbnailUrl,t.Price=e.UnitPrice,t.UnitPrice=e.UnitPrice,t.UnitCost=e.UnitCost,t.UnitQuantity=e.UnitQuantity,t.Quantity=1,t.Code=e.Code,t.TypeID=e.TypeID,t.Discount=e.PriceDiscount,t.VariantUnitQuantity=e.VariantUnitQuantity,t.Storage=e.Storage,t.UOM=e.UOM,t.UOMName=e.UOMName,t.VariantID=e.ID,t.Taxable=e.Taxable,t.InventoryTypeID=e.TypeID,t.PriceTypeID=e.PriceTypeID,t.PriceNote=e.PriceNote,t.Variant=e,t}generateCartItemOnEdit(e){let t=new xe;return t.ID=e.ID,t.Name=e.Variant?.Name,t.ThumbnailUrl=e.Variant?.ThumbnailUrl,t.Price=e.Price,t.UnitPrice=e.Price,t.UnitCost=e.Cost,t.UnitQuantity=e.Variant?.UnitQuantity,t.Quantity=e.Quantity,t.Code=e.Variant?.Code,t.TypeID=e.Variant?.TypeID,t.Discount=e.Discount,t.VariantUnitQuantity=e.Variant?.VariantUnitQuantity,t.Storage=e.Variant?.Storage,t.UOM=e.Variant?.UOM,t.UOMName=e.Variant?.UOMName,t.VariantID=e.VariantID,t.Taxable=e.Taxable,t.Note=e.Note,t.Serial=e.Serial,t.InventoryTypeID=e.InventoryTypeID,t.PriceTypeID=e.PriceTypeID,t.Variant=e.Variant,t.PriceNote=e.PriceNote,t}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};var Ue=class o{httpService=u(X);storeService=u(E);factoryService=u(Se);activatedRoute=u(Kt);getLoadForm$=this.activatedRoute.queryParams.pipe(Z(e=>this.httpService.post("/API/estimate/LoadForm",e)),k(e=>this.storeService.updateLoadForm(e)),k(e=>{g.IsNotEmpty(e.Data)?this.onEditOrder(e):(this.initDefaultCurrency(),this.initTag(),this.initTax())}),R());constructor(){this.getLoadForm$.subscribe()}onEditOrder(e){let t=e.Data,n=this.findTaxById(t.Order.TaxTypeID),i=this.findCurrencyById(t.Order.CurrencyID),l=this.findOutletById(t.Order.EntityID),I=this.findTagById(t.Order.TypeID),D=this.getCartItemsOnEdit(e);this.storeService.updateState(1),this.storeService.updateOrder(t.Order),this.storeService.updateCartItems(D),this.storeService.updateCustomer({Key:t.Order.CustomerID,Value:t.ContactName}),this.storeService.updateTax(n),this.storeService.updateCurrency(i),this.storeService.updateOutlet(l),this.storeService.updateDiscount({discount:t.Order.Discount,discountAmount:t.Order.DiscountAmount}),this.storeService.updateTag(I)}getCartItemsOnEdit(e){return e.Data.Items.map(i=>this.factoryService.generateCartItemOnEdit(i))}initDefaultCurrency(){let e=this.storeService.loadForm()?.AppConfigJSON?.CoreDefaults?.CurrencyID,t=this.storeService.loadForm()?.Currencies.find(n=>n.ID===e);this.storeService.updateCurrency(t)}initTag(){let e=this.storeService.loadForm()?.CustomerPOTypes;this.storeService.updateTag(e[0])}initTax(){let e=this.storeService.loadForm()?.Taxes;this.storeService.updateTax(e[0])}findTaxById(e){return(this.storeService.loadForm()?.Taxes).find(i=>i.ID===e)}findCurrencyById(e){return(this.storeService.loadForm()?.Currencies).find(i=>i.ID===e)}findOutletById(e){return(this.storeService.loadForm()?.Entities).find(i=>i.ID===e)}findTagById(e){return(this.storeService.loadForm()?.CustomerPOTypes).find(i=>i.ID===e)}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};var je=class o{storeService=u(E);isOpenDialog$=U(this.storeService.loadForm).pipe(O(e=>g.IsNotEmpty(e.Entities)),pe(()=>{let e=!1,t=this.storeService.state(),n=this.storeService.outlet();return(t==0||t==1)&&(e=g.IsEmpty(n.ID)),e}));updateOutlet(e){this.storeService.updateOutlet(e)}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac,providedIn:"root"})};var se=class o{storeService=u(E);httpService=u(X);router=u(Ye);orderNumber$=U(this.storeService.outlet).pipe(O(e=>g.IsNotEmpty(e.ID)),Z(e=>{if(this.storeService.state()==0)return this.httpService.post(G.EstimateGenerateNumber,{ID:e.ID}).pipe(pe(t=>t.Number));{let t=this.storeService.order().Number;return Rt(t)}}),k(e=>{this.storeService.state()==0&&this.updateOrderNumber(e)}),R());updateTagOrder$=U(this.storeService.tag).pipe(k(e=>{let t=B({},this.storeService.order());t.TypeID=e.ID,this.storeService.updateOrder(t)}),R());updateCurrencyOrder$=U(this.storeService.currency).pipe(k(e=>{let t=B({},this.storeService.order());t.CurrencyID=e.ID,this.storeService.updateOrder(t)}),R());updateTaxOrder$=U(this.storeService.tax).pipe(k(e=>{let t=B({},this.storeService.order());t.TaxTypeID=e.ID,this.storeService.updateOrder(t)}),R());updateDiscountOrder$=U(this.storeService.discount).pipe(k(e=>{let t=B({},this.storeService.order());t.Discount=e.discount,t.DiscountAmount=e.discountAmount,this.storeService.updateOrder(t)}),R());updateCustomerOrder$=U(this.storeService.customer).pipe(k(e=>{let t=B({},this.storeService.order());t.CustomerID=e.Key,this.storeService.updateOrder(t)}),R());updateEntityId$=U(this.storeService.outlet).pipe(O(e=>g.IsNotEmpty(e.ID)),k(e=>{let t=B({},this.storeService.order());t.EntityID=e.ID,this.storeService.updateOrder(t)}),R());constructor(){this.updateTagOrder$.subscribe(),this.updateCurrencyOrder$.subscribe(),this.updateTaxOrder$.subscribe(),this.updateDiscountOrder$.subscribe(),this.updateCustomerOrder$.subscribe(),this.updateEntityId$.subscribe()}newOrder(){let e=this.storeService.loadForm(),t=this.getDefaultCurrency(),n=this.storeService.outlet();this.storeService.updateOrder(new Fe),this.storeService.updateCartItems([]),this.storeService.updateCustomer(new re),this.storeService.updateTax(B({},e.Taxes[0])),this.storeService.updateCurrency(B({},t)),this.storeService.updateTag(B({},e.CustomerPOTypes[0])),this.storeService.updateDiscount({discountAmount:0,discount:0}),this.storeService.updateOutlet(B({},n)),this.router.navigate([],{queryParams:{}}),this.storeService.updateState(0)}getDefaultCurrency(){let e=this.storeService.loadForm()?.AppConfigJSON?.CoreDefaults?.CurrencyID;return this.storeService.loadForm()?.Currencies.find(n=>n.ID===e)}updateOrderNumber(e){g.IsNotEmpty(e)&&this.storeService.order().Number!==e&&this.storeService.updateOrder(Et(B({},this.storeService.order()),{Number:e}))}updateOrderDate(e){g.IsNotEmpty(e)&&this.storeService.order().Date!==e&&this.storeService.updateOrder(Et(B({},this.storeService.order()),{Date:e}))}updateSalesPersonId(e){let t=B({},this.storeService.order());t.SalesID=e,this.storeService.updateOrder(t)}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};var Qe=class o{storeService=u(E);httpService=u(X);quickkeys$=U(this.storeService.outlet).pipe(O(e=>g.IsNotEmpty(e.ID)),Qt((e,t)=>e.ID===t.ID),Z(e=>this.httpService.get(G.GetQuickKeyByEntityID,[{key:"ID",value:e.ID}])),$e(1));static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};var Fn=o=>({"qtyBtn-disabled":o}),ft=class o{disabled=!1;decimalPlaces=4;max=1e15;min=-1e15;quantity;constructor(){}ngOnInit(){}incrementQty(){this.quantity<this.max&&(this.quantity++,this.onChange(this.quantity))}decrementQty(){this.quantity>this.min&&(this.quantity--,this.onChange(this.quantity))}quantityChange(){this.onChange(this.quantity)}onChange=e=>{};onTouched=()=>{};writeValue(e){g.IsEmpty(e)?this.quantity=0:this.quantity=e}registerOnChange(e){this.onChange=e}registerOnTouched(e){this.onTouched=e}setDisabledState(e){}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["POS-input-quantity"]],inputs:{disabled:"disabled",decimalPlaces:"decimalPlaces",max:"max",min:"min"},standalone:!0,features:[Te([{provide:tt,multi:!0,useExisting:o}]),P],decls:6,vars:11,consts:[[1,"input-group"],["type","button","id","button-addon1",1,"btn","btn-outline-secondary","fw-bold","rounded-0","fs-2","border-end-0","py-4","qty-input","d-flex","align-items-center","qty_btn","justify-content-center",3,"click","ngClass","disabled"],["id","txtCartQuantity","type","text","autoNum","",1,"form-control","input-numpad","qty-input","text-center",3,"ngModelChange","ngModel","disabled","decimalPlaces"],["type","button","id","button-addon2",1,"btn","btn-outline-secondary","fw-bold","rounded-0","fs-5","border-start-0","py-4","qty-input","d-flex","align-items-center","qty_btn","justify-content-center",3,"click","ngClass","disabled"]],template:function(t,n){t&1&&(r(0,"div",0)(1,"button",1),d("click",function(){return n.decrementQty()}),s(2,"-"),a(),r(3,"input",2),q("ngModelChange",function(l){return W(n.quantity,l)||(n.quantity=l),l}),d("ngModelChange",function(){return n.quantityChange()}),a(),r(4,"button",3),d("click",function(){return n.incrementQty()}),s(5,"+"),a()()),t&2&&(c(),m("ngClass",$(7,Fn,n.disabled))("disabled",n.disabled),c(2),L("ngModel",n.quantity),m("disabled",n.disabled)("decimalPlaces",n.decimalPlaces),c(),m("ngClass",$(9,Fn,n.disabled))("disabled",n.disabled))},dependencies:[T,ue,ie,te,Y,ne,_e,he],styles:[".qtyBtn-disabled[_ngcontent-%COMP%]{background-color:#e9ecef;color:#000!important}button.qty_btn[_ngcontent-%COMP%]{background:#eee;border:1px solid #ddd;width:36px}.qty-input[_ngcontent-%COMP%]{height:36px!important}"]})};var De=class o{storeService=u(E);autoApplyPricebook(e){let t=e?.Variant?.PriceBook?e?.Variant?.PriceBook:[],n=this.storeService.customer(),i=this.findCustomerPricebook(t,n),l=this.sortAppliedPricebooks(t,e.Quantity);return l.length>0||g.IsNotEmpty(i)?g.IsNotEmpty(i)?e=this.applyPricebook(e,i):e=this.applyPricebook(e,l[0]):e.PriceTypeID===2&&(e=this.removePricebook(e)),e}findCustomerPricebook(e=[],t){let n;return g.IsNotEmpty(t)&&g.IsNotEmpty(t?.Key)&&(n=e.find(i=>i.ID==t.PricebookID)),n}applyCustomerPricebook(){let e=[],t=this.storeService.customer(),n=this.storeService.cartItems();return g.IsNotEmpty(t.PricebookID)&&n.forEach(i=>{let l=this.findCustomerPricebook(i.Variant.PriceBook,t);l&&(i=this.applyPricebook(i,l),e.push(i))}),e}removeCustomerPricebook(e){let t=[];return this.storeService.cartItems().forEach(i=>{this.findCustomerPricebook(i.Variant.PriceBook,e)&&(i=this.removePricebook(i),t.push(i))}),t}sortAppliedPricebooks(e=[],t){return e.sort((n,i)=>i.MinimumQuantity-n.MinimumQuantity).filter(n=>t>=n.MinimumQuantity&&n.MinimumQuantity!=0)}applyPricebook(e,t){let n=this.storeService.loadForm()?.AppConfigJSON?.ModuleSell?.Pricebook?.PricebookVisible;return e.Discount=t.PriceDiscount,e.UnitPrice=t.UnitPrice,e.PriceBookID=t.ID,e.Price=t.UnitPrice,e.PriceTypeID=2,e.PriceNote=t.Name,n?e.Note=t.Name:e.Note="",e}removePricebook(e){return e.Discount=e.Variant.PriceDiscount,e.UnitPrice=e.Variant.UnitPrice,e.PriceBookID=null,e.Price=e.Variant.UnitPrice,e.PriceTypeID=0,e.Note="",e.PriceNote="",e}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};var At=o=>({selected:o}),Qn=()=>["/menu/Products/Catalog/Variants/Info"],Ln=o=>({ID:o});function Wn(o,e){if(o&1){let t=A();h(0),r(1,"a",10),d("click",function(){f(t);let i=p();return C(i.tabState="PRODUCT")}),s(2," Product "),a(),x()}if(o&2){let t=p();c(),m("ngClass",$(1,At,t.tabState=="PRODUCT"))}}function qn(o,e){if(o&1){let t=A();h(0),r(1,"a",11),d("click",function(){f(t);let i=p();return C(i.tabState="SERIAL")}),s(2," Serial "),a(),x()}if(o&2){let t=p();c(),m("ngClass",$(1,At,t.tabState=="SERIAL"))}}function $n(o,e){if(o&1&&(h(0),r(1,"div",12)(2,"div",21),y(3,"POS-variant-autocomplete",22),a()(),x()),o&2){let t=p(2);c(3),m("formControl",t.variantSearchCtrl)}}function Hn(o,e){if(o&1&&(r(0,"span"),s(1),a()),o&2){let t=p(2);c(),S("(",t.cartItem().UOMName,")")}}function zn(o,e){if(o&1){let t=A();r(0,"div",15)(1,"h6"),s(2,"Pricebook"),a(),r(3,"ng-select",23),q("ngModelChange",function(i){f(t);let l=p(2);return W(l.cartItem().PriceBookID,i)||(l.cartItem().PriceBookID=i),C(i)}),d("ngModelChange",function(i){f(t);let l=p(2);return C(l.onSelectPricebook(i))}),a()()}if(o&2){let t,n=p(2);c(3),m("items",(t=n.cartItem())==null||t.Variant==null?null:t.Variant.PriceBook),L("ngModel",n.cartItem().PriceBookID)}}function Gn(o,e){if(o&1){let t=A();h(0),v(1,$n,4,1,"ng-container",8),r(2,"div",12)(3,"div",13)(4,"h6"),s(5," Qty "),v(6,Hn,2,1,"span",8),a(),r(7,"POS-input-quantity",14,0),q("ngModelChange",function(i){f(t);let l=p();return W(l.cartItem().Quantity,i)||(l.cartItem().Quantity=i),C(i)}),d("ngModelChange",function(){f(t);let i=p();return C(i.onQtyChange())}),a()(),r(9,"div",15)(10,"h6"),s(11,"Discount (%)"),a(),r(12,"input",16),q("ngModelChange",function(i){f(t);let l=p();return W(l.cartItem().Discount,i)||(l.cartItem().Discount=i),C(i)}),a()(),r(13,"div",15)(14,"h6"),s(15,"Price"),a(),r(16,"input",17,1),q("ngModelChange",function(i){f(t);let l=p();return W(l.cartItem().Price,i)||(l.cartItem().Price=i),C(i)}),a()(),v(18,zn,4,2,"div",15),a(),r(19,"div",18)(20,"div",19)(21,"POS-tinymce-editor",20),q("valueChange",function(i){f(t);let l=p();return W(l.cartItem().Note,i)||(l.cartItem().Note=i),C(i)}),a()()(),x()}if(o&2){let t,n=p();c(),m("ngIf",n.isEditState()==!1),c(5),m("ngIf",n.cartItem().UOMName),c(),L("ngModel",n.cartItem().Quantity),m("decimalPlaces",n.isSerialItem?0:4),c(5),L("ngModel",n.cartItem().Discount),c(4),L("ngModel",n.cartItem().Price),m("disabled",!(!(n.roleService==null||n.roleService.sell==null)&&n.roleService.sell.UnitPriceEditor)),c(2),Je(((t=n.cartItem().Variant)==null||t.PriceBook==null?null:t.PriceBook.length)>0?18:-1),c(3),L("value",n.cartItem().Note)}}function Jn(o,e){o&1&&(h(0),y(1,"i",42),r(2,"h6"),s(3,"No Image"),a(),x())}function Kn(o,e){if(o&1&&y(0,"img",43),o&2){let t=p(2);m("src",t.cartItem().ThumbnailUrl,ze)}}function Yn(o,e){if(o&1&&(h(0),r(1,"tr")(2,"td",44),s(3),_(4,"number"),a(),r(5,"td",44),s(6),_(7,"number"),a(),r(8,"td",44),s(9),_(10,"number"),a()(),x()),o&2){let t=e.ngIf;c(3),S(" ",b(4,3,t==null?null:t.OnHand)," "),c(3),S(" ",b(7,5,t==null?null:t.Allocated)," "),c(3),S(" ",b(10,7,(t==null?null:t.OnHand)-(t==null?null:t.Allocated))," ")}}function Xn(o,e){if(o&1){let t=A();r(0,"tr")(1,"th",39),s(2,"Cost"),a(),r(3,"td",45)(4,"input",46),q("ngModelChange",function(i){f(t);let l=p(2);return W(l.cartItem().UnitCost,i)||(l.cartItem().UnitCost=i),C(i)}),a()()()}if(o&2){let t,n=p(2);c(4),L("ngModel",n.cartItem().UnitCost),m("readonly",!(!((t=n.appConfig())==null||t.ModuleSell==null)&&t.ModuleSell.Cost.Enabled))}}function Zn(o,e){if(o&1&&(r(0,"tr")(1,"th",39),s(2,"Content"),a(),r(3,"td",40)(4,"div",47),s(5),_(6,"number"),a()()()),o&2){let t,n=p(2);c(5),Pe(" ",(t=n.cartItem())==null?null:t.VariantUnitQuantity," (@",b(6,2,n.cartItem().Price/((t=n.cartItem())==null?null:t.VariantUnitQuantity)),")")}}function ei(o,e){if(o&1&&(r(0,"div",37)(1,"table",48)(2,"thead")(3,"tr")(4,"th",49),s(5,"Storage Location"),a()()(),r(6,"tbody")(7,"tr")(8,"td"),s(9),a()()()()()),o&2){let t=p(2);c(9),S(" ",t.cartItem().Storage," ")}}function ti(o,e){if(o&1&&(h(0),r(1,"div",24)(2,"div",25)(3,"a",26),v(4,Jn,4,0,"ng-container",27)(5,Kn,1,1,"ng-template",null,2,ce),a()(),r(7,"div",28)(8,"div",29)(9,"div",19)(10,"div",30),y(11,"i",31),r(12,"div",32),s(13,"Inventory"),a()(),r(14,"table",33)(15,"thead")(16,"tr")(17,"th",34),s(18,"On Hand"),a(),r(19,"th",34),s(20,"Allocated"),a(),r(21,"th",35),s(22,"Available"),a()()(),r(23,"tbody"),v(24,Yn,11,9,"ng-container",8),_(25,"async"),a()()()(),r(26,"div",36)(27,"div",37)(28,"table",38)(29,"thead"),v(30,Xn,5,2,"tr",8),r(31,"tr")(32,"th",39),s(33,"Price"),a(),r(34,"td",40),s(35),_(36,"number"),a()(),v(37,Zn,7,4,"tr",8),a()()(),v(38,ei,10,1,"div",41),a()()(),x()),o&2){let t,n,i,l,I,D,ae=K(6),le=p();c(3),m("routerLink",Ke(13,Qn))("queryParams",$(14,Ln,(t=le.cartItem())==null?null:t.ID)),c(),m("ngIf",((n=le.cartItem())==null?null:n.ThumbnailUrl)==null)("ngIfElse",ae),c(20),m("ngIf",b(25,9,le.variantInventory$)),c(6),m("ngIf",((i=le.appConfig())==null||i.ModuleSell==null?null:i.ModuleSell.Cost.Visible)&&le.roleService.product.Cost),c(5),S(" ",b(36,11,(l=le.cartItem())==null?null:l.Price)," "),c(2),m("ngIf",((I=le.cartItem())==null?null:I.VariantUnitQuantity)>1),c(),m("ngIf",((D=le.appConfig())==null||D.ModuleSell==null||D.ModuleSell.Grid==null?null:D.ModuleSell.Grid.StorageVisible)&&((D=le.cartItem())==null?null:D.Storage))}}function ni(o,e){if(o&1){let t=A();h(0),r(1,"app-item-serial",50),d("cartItemChange",function(i){f(t);let l=p();return C(l.onSerialChanges(i))}),a(),x()}if(o&2){let t=p();c(),m("entityId",t.storeService.outlet().ID)("cartItem",t.cartItem())}}var We=class o{constructor(e,t){this.data=e;this.dialogRef=t;this.cartItem=F(e),this.initVariantInventory(),this.initIsSerialItem(),this.initModalConfig(),this.initDialogState()}storeService=u(E);cartItemService=u(me);roleService=u(ge);toastr=u(et);pricebookService=u(De);modalConfig=new be;tabState="CART";cartItem;appConfig=F(this.storeService.loadForm()?.AppConfigJSON);isSerialItem=F(!1);variantInventory$;isEditState=F(!1);showProductTab=F(!1);variantSearchCtrl=new we;getItemFromSearch$=this.variantSearchCtrl.valueChanges.pipe(O(e=>g.IsNotEmpty(e)),Z(e=>{if(e.type==="ID")return this.cartItemService.getItemByVariantId(e.str);if(e.type==="Code")return this.cartItemService.getItemByVariantByCode(e.str)}),k(e=>{this.cartItem.set(e),this.initModalTitle(),this.initProductTab(),this.initIsSerialItem(),this.initVariantInventory()}),R());ngOnInit(){this.isEditState()||this.getItemFromSearch$.subscribe()}initDialogState(){this.isEditState.set(g.IsNotEmpty(this.cartItem().VariantID)),this.initProductTab()}initVariantInventory(){this.variantInventory$=this.cartItemService.getVariantInventory(this.cartItem().VariantID).pipe($e(1))}initProductTab(){this.showProductTab.set(g.IsNotEmpty(this.cartItem().VariantID))}initIsSerialItem(){this.isSerialItem.set(this.cartItem().TypeID==4)}initModalConfig(){this.initModalTitle(),this.modalConfig.customWidth="680px",this.modalConfig.noPadding=!0,this.modalConfig.bodyScrollable=!0}initModalTitle(){this.modalConfig.title=this.cartItem()?.Name??"Add Variant"}onSerialChanges(e){this.cartItem.set(e)}onQtyChange(){let e=this.pricebookService.autoApplyPricebook(this.cartItem());this.cartItem.set(e)}onSelectPricebook(e){let t;if(g.IsNotEmpty(e)){let i=this.cartItem().Variant.PriceBook.find(l=>l.ID===e);t=this.pricebookService.applyPricebook(this.cartItem(),i)}else t=this.pricebookService.removePricebook(this.cartItem());this.cartItem.set(t)}onCancel(){this.dialogRef.close()}onSave(){g.IsNotEmpty(this.cartItem().VariantID)&&g.IsNotEmpty(this.cartItem().Name)?this.dialogRef.close(this.cartItem()):this.toastr.warning("Please select a product","Warning")}static \u0275fac=function(t){return new(t||o)(Q(Ce),Q(fe))};static \u0275cmp=M({type:o,selectors:[["app-dialog-item"]],standalone:!0,features:[P],decls:13,vars:9,consts:[["quantity",""],["price",""],["SHOW_IMAGE",""],[3,"onOk","onCancel","onClose","config"],[1,"mb-5"],[1,"container","w-100","h-100","mt-8"],[1,"row","border-bottom","mx-5"],["data-cy","input_sell",1,"btn","btn-link",3,"click","ngClass"],[4,"ngIf"],[1,"mx-8"],["data-cy","product",1,"btn","btn-link",3,"click","ngClass"],["data-cy","serial",1,"btn","btn-link",3,"click","ngClass"],[1,"row","mt-8"],[1,"col-auto","pe-0",2,"width","145px"],[3,"ngModelChange","ngModel","decimalPlaces"],[1,"col-auto","pe-0"],["type","text","percentage","","autoNum","",1,"form-control","input-cart",2,"width","100px",3,"ngModelChange","ngModel"],["id","inputPrice","type","text","autoNum","",1,"form-control","input-cart",2,"width","112px",3,"ngModelChange","ngModel","disabled"],[1,"row","my-6"],[1,"col-12"],["height","220px",3,"valueChange","value"],[1,"col-12","px-0"],[3,"formControl"],["bindLabel","Name","bindValue","ID","placeholder","Pricebook","appendTo","body",2,"width","170px",3,"ngModelChange","items","ngModel"],[1,"row","my-8"],[1,"col-sm-4","d-flex","justify-content-center","flex-column","align-items-center","text-body-secondary"],["target","_blank",2,"color","inherit",3,"routerLink","queryParams"],[4,"ngIf","ngIfElse"],[1,"col-sm-8","inventory"],[1,"row","mb-8"],[1,"d-flex"],["aria-hidden","true",1,"fa-archive","fa-solid","fa-1x","pt-3","pe-2"],[2,"font-size","15px","font-family","'Roboto Slab'"],[1,"table","table-bordered","text-center","inventory-table"],[1,"table-light","py-6","border-end",2,"text-transform","none"],[1,"table-light","py-6",2,"text-transform","none"],[1,"row"],[1,"col-6"],[1,"table","table-bordered",2,"width","171px"],[1,"table-light",2,"text-transform","none"],[1,"pe-6","text-end"],["class","col-6",4,"ngIf"],["aria-hidden","true",1,"fa-solid","fa-image","fa-5x"],[1,"border","rounded",3,"src"],[1,"py-6"],[1,"p-0"],["type","text","autoNum","",1,"form-control","border-0","bg-white","text-end",3,"ngModelChange","ngModel","readonly"],["ngClass","ms-3"],[1,"table","table-bordered","text-center"],[1,"table-light"],[3,"cartItemChange","entityId","cartItem"]],template:function(t,n){t&1&&(r(0,"modal-material",3),d("onOk",function(){return n.onSave()})("onCancel",function(){return n.onCancel()})("onClose",function(){return n.onCancel()}),r(1,"content",4)(2,"div",5)(3,"div",6)(4,"div")(5,"a",7),d("click",function(){return n.tabState="CART"}),s(6," Cart "),a(),v(7,Wn,3,3,"ng-container",8)(8,qn,3,3,"ng-container",8),a()(),r(9,"div",9),v(10,Gn,22,9,"ng-container",8)(11,ti,39,16,"ng-container",8)(12,ni,2,2,"ng-container",8),a()()()()),t&2&&(m("config",n.modalConfig),c(5),m("ngClass",$(7,At,n.tabState=="CART")),c(2),m("ngIf",n.showProductTab()),c(),m("ngIf",n.isSerialItem()),c(2),m("ngIf",n.tabState=="CART"),c(),m("ngIf",n.tabState=="PRODUCT"),c(),m("ngIf",n.tabState=="SERIAL"))},dependencies:[T,ue,z,Oe,ee,ye,ve,Sn,ie,te,Y,ne,_e,he,Pn,Mn,Ze,Xe,mt,Ne,ke,Dn,In,ft,Ve,Ae],styles:[".bg-light-gray[_ngcontent-%COMP%]{background-color:var(--bs-light-gray);--bs-bg-opacity: .15 !important}.bg-gradient-danger[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#f8d7da,#f8d7da 15px,#f5c6cb 15px 30px)!important}.bg-gradient-success[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#beeebb,#beeebb 15px,#afeba8 15px 30px)!important}.bg-gradient-warning[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#fcf3cf,#fcf3cf 15px,#f9e79f 15px 30px)!important}.bg-light-orange[_ngcontent-%COMP%]{background-color:var(--bs-light-orange);--bs-bg-opacity: .15 !important}.text-danger[_ngcontent-%COMP%]{color:#fb404b!important}.text-dark[_ngcontent-%COMP%]{color:#5e5e5e!important}.text-success[_ngcontent-%COMP%]{color:#87cb16!important}.text-black[_ngcontent-%COMP%]{color:#000!important}.text-white[_ngcontent-%COMP%]{color:var(--bs-white)!important}.btn-light-blue[_ngcontent-%COMP%]{color:#212529;background-color:#dfeffc!important;border-color:#dfeffc}.btn-light-blue[_ngcontent-%COMP%]:hover{color:#212529;background-color:#bcdef9;border-color:#b0d8f8}.btn-light-blue[_ngcontent-%COMP%]:focus, .btn-light-blue.focus[_ngcontent-%COMP%]{color:#212529;background-color:#bcdef9;border-color:#b0d8f8;box-shadow:0 0 0 .2rem #c3d1dc80}.btn-light-blue.disabled[_ngcontent-%COMP%], .btn-light-blue[_ngcontent-%COMP%]:disabled{color:#212529;background-color:#dfeffc;border-color:#dfeffc}.btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active, .btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active, .show[_ngcontent-%COMP%] > .btn-light-blue.dropdown-toggle[_ngcontent-%COMP%]{color:#212529;background-color:#b0d8f8;border-color:#a5d2f7}.btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active:focus, .btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active:focus, .show[_ngcontent-%COMP%] > .btn-light-blue.dropdown-toggle[_ngcontent-%COMP%]:focus{box-shadow:0 0 0 .2rem #c3d1dc80}.inventory-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%], .inventory-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{line-height:6px!important}.btn-link[_ngcontent-%COMP%]{padding-top:0;color:#868686;padding-bottom:8px;border-radius:unset;font-family:Roboto Slab,serif}.btn-link.selected[_ngcontent-%COMP%]{color:#3b3b3b;border-bottom:4px solid #07a519}.input-cart[_ngcontent-%COMP%]{height:36px!important}"]})};var Ct=class o{constructor(e,t){this.data=e;this.dialogRef=t;this.modalConfig=new be,this.modalConfig.title=e.title,this.modalConfig.headerType=e.headerType}modalConfig;onOk(){this.dialogRef.close(!0)}onClose(){this.dialogRef.close(!1)}static \u0275fac=function(t){return new(t||o)(Q(Ce),Q(fe))};static \u0275cmp=M({type:o,selectors:[["app-confirmation-modal"]],standalone:!0,features:[P],decls:4,vars:2,consts:[[3,"onClose","onCancel","onOk","config"],[1,"container-fluid","modal-info"],[3,"innerHTML"]],template:function(t,n){t&1&&(r(0,"modal-material",0),d("onClose",function(){return n.onClose()})("onCancel",function(){return n.onClose()})("onOk",function(){return n.onOk()}),r(1,"content")(2,"div",1),y(3,"div",2),a()()()),t&2&&(m("config",n.modalConfig),c(3),m("innerHTML",n.data==null?null:n.data.message,He))},dependencies:[an,T,ye,ve],styles:[".modal-info[_ngcontent-%COMP%] .empty-state-img[_ngcontent-%COMP%]{width:100px}.modal-info[_ngcontent-%COMP%] .img-1x[_ngcontent-%COMP%]{width:12rem}.modal-info[_ngcontent-%COMP%] .img-2x[_ngcontent-%COMP%]{width:10rem}.modal-info[_ngcontent-%COMP%] .img-3x[_ngcontent-%COMP%]{width:8rem}"]})};var me=class o{httpService=u(X);storeService=u(E);factoryService=u(Se);pricebookService=u(De);dialog=u(oe);variantSearchCtrl=new we;viewContainerRef=u(qt);selectedCustomer;cartItemEvent=new Vt;onEditCartItems$=U(this.storeService.cartItems).pipe(O(()=>this.storeService.state()==1),pe(e=>({action:"INIT",items:e})),Lt());applyCustomerPricebook$=U(this.storeService.customer).pipe(k(e=>{this.onApplyCustomerPricebook(e)}),R());cartItems$=Bt(this.onEditCartItems$,this.cartItemEvent.asObservable()).pipe(Wt((e,t)=>{let n=[];switch(t.action){case"INIT":n=t.items;break;case"ADD":n=this.addNewItem(e,t);break;case"UPDATE":n=this.updateItems(e,t);break;case"REMOVE":n=e.filter((i,l)=>t.index!==l);break;case"CLEAR":n=[];break;case"PURCHASE":n=this.updateItems(e,t);break;case"RETURN":n=this.updateItems(e,t);break;case"DROP":n=t.items;break}return this.storeService.updateCartItems(n),n},this.storeService.cartItems()));addCartItemBySearch$=this.variantSearchCtrl.valueChanges.pipe(O(e=>g.IsNotEmpty(e)),k(e=>{e.type==="ID"?this.addItemByVariantId(e.str):e.type==="Code"&&this.addItemByVariantCode(e.str)}),R());constructor(){this.addCartItemBySearch$.subscribe(),this.applyCustomerPricebook$.subscribe()}onApplyCustomerPricebook(e){let t=[],n=this.storeService.cartItems();g.IsNotEmpty(e.PricebookID)?(this.selectedCustomer=e,t=this.pricebookService.applyCustomerPricebook()):g.IsNotEmpty(this.selectedCustomer)&&(t=this.pricebookService.removeCustomerPricebook(this.selectedCustomer),this.selectedCustomer=null),n.forEach((i,l)=>{let I=t.find(D=>D.VariantID===i.VariantID);I&&this.updateCartItem({cartItem:I,index:l})})}onApplyPricebook(e){return this.pricebookService.autoApplyPricebook(e)}onOpenAddDialog(){this.dialog.open(We,{data:new xe,viewContainerRef:this.viewContainerRef}).afterClosed().pipe(O(e=>g.IsNotEmpty(e))).subscribe(e=>{this.cartItemEvent.next({item:e,action:"ADD",newRow:!0})})}onOpenEditDialog(e){this.dialog.open(We,{data:B({},e.cartItem),viewContainerRef:this.viewContainerRef}).afterClosed().pipe(O(t=>g.IsNotEmpty(t))).subscribe(t=>{this.cartItemEvent.next({item:t,action:"UPDATE",index:e.index})})}onSelectQuickkeyItem(e){this.addItemByVariantId(e)}addNewItem(e,t){let n=[],i=e.find(l=>l.VariantID===t.item?.VariantID);return i?t.newRow?(t.item=this.onApplyPricebook(t.item),n=[...e,t.item]):(i.Quantity+=1,i=this.onApplyPricebook(i),n=[...e]):(t.item=this.onApplyPricebook(t.item),n=[...e,t.item]),n}updateItems(e,t){return e.map((i,l)=>l===t.index?pn(xe,t.item):i)}onDropItems(e){this.cartItemEvent.next({action:"DROP",items:e})}addItemByVariantId(e){this.getItemByVariantId(e).pipe(k(t=>{this.cartItemEvent.next({item:t,action:"ADD",newRow:!1})})).subscribe()}addItemByVariantCode(e){this.getItemByVariantByCode(e).pipe(k(t=>{this.cartItemEvent.next({item:t,action:"ADD",newRow:!1})})).subscribe()}removeCartItem(e){this.cartItemEvent.next({action:"REMOVE",index:e.index})}updateCartItem(e){this.cartItemEvent.next({action:"UPDATE",item:e.cartItem,index:e.index})}clearCart(){this.dialog.open(Ct,{data:{title:"Clear Order Items",message:'<p class="h4">Are you sure you want to clear all order items?</p>',headerType:Ee.Warning}}).afterClosed().pipe(O(e=>e)).subscribe(()=>{this.cartItemEvent.next({action:"CLEAR"})})}onPurchaseItem(e){this.cartItemEvent.next({action:"PURCHASE",item:e.cartItem,index:e.index})}onReturnItem(e){this.cartItemEvent.next({action:"RETURN",item:e.cartItem,index:e.index})}getItemByVariantId(e){return this.httpService.get(G.GetVariantByID,[{key:"ID",value:e},{key:"EntityID",value:this.storeService.outlet().ID}]).pipe(pe(t=>this.factoryService.generateCartItem(t)))}getItemByVariantByCode(e){return this.httpService.get(G.GetVariantByCode,[{key:"Code",value:e},{key:"EntityID",value:this.storeService.outlet().ID},{key:"Promotion",value:!0}]).pipe(pe(t=>this.factoryService.generateCartItem(t)))}getVariantInventory(e){return this.httpService.get(G.GetVariantStockByID,[{key:"EntityID",value:this.storeService.outlet().ID},{key:"ID",value:e}])}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};function ii(o,e){if(o&1&&(r(0,"td",29),s(1),a()),o&2){let t=p().index;c(),S(" ",t+1,". ")}}function oi(o,e){if(o&1&&(h(0),r(1,"div",30),y(2,"img",31),a(),x()),o&2){let t=p().$implicit;c(2),m("src",t.ThumbnailUrl,ze)}}function ri(o,e){o&1&&(r(0,"div",32),y(1,"i",33),a())}function ai(o,e){if(o&1&&y(0,"small",16),o&2){let t=p().$implicit;m("innerHtml",t.Note,He)}}function li(o,e){if(o&1&&(h(0),r(1,"span",24),s(2),_(3,"number"),a(),x()),o&2){let t=p().$implicit;c(2),j(Ot(3,1,t.Quantity,"1.0-4"))}}function ci(o,e){if(o&1&&(h(0),r(1,"span",34),s(2,"x"),a(),r(3,"div",35)(4,"span",36),s(5),_(6,"number"),a()(),x()),o&2){let t=p().$implicit;c(5),j(b(6,1,t.UnitQuantity))}}function si(o,e){if(o&1&&(h(0),r(1,"span",37),s(2),_(3,"number"),a(),x()),o&2){let t=p().$implicit;c(2),S("@",b(3,1,t.VariantUnitQuantity),"")}}function mi(o,e){if(o&1&&(h(0),r(1,"small",38),s(2),a(),x()),o&2){let t=p().$implicit;c(2),j(t.UOM?t==null?null:t.UOMName:"")}}function pi(o,e){if(o&1&&(h(0),r(1,"div",39),s(2),_(3,"number"),a(),x()),o&2){let t=p().$implicit;c(2),S(" ",Ot(3,1,t.Price,"1.0-4")," ")}}function ui(o,e){if(o&1){let t=A();h(0),r(1,"tr",9),d("contextmenu",function(i){let l=f(t),I=l.$implicit,D=l.index,ae=p(2);return C(ae.onContextMenu(i,I,D))}),v(2,ii,2,1,"td",10),r(3,"td",11),d("click",function(){let i=f(t),l=i.$implicit,I=i.index,D=p(2);return C(D.onEdit(l,I))}),r(4,"div",12),v(5,oi,3,1,"ng-container",3)(6,ri,2,0,"ng-template",null,2,ce),r(8,"div",13)(9,"div"),s(10),a(),r(11,"span",14),s(12),a(),r(13,"div"),y(14,"app-serial-note",15),a(),v(15,ai,1,1,"small",16),a()()(),r(16,"td",17),d("click",function(){let i=f(t),l=i.$implicit,I=i.index,D=p(2);return C(D.onEdit(l,I))}),r(17,"div",18)(18,"div",19),v(19,li,4,4,"ng-container",20)(20,ci,7,3,"ng-container",20)(21,si,4,3,"ng-container",20)(22,mi,3,1,"ng-container",20),a()()(),r(23,"td",21),d("click",function(){let i=f(t),l=i.$implicit,I=i.index,D=p(2);return C(D.onEdit(l,I))}),v(24,pi,4,4,"ng-container",20),a(),r(25,"td",21),d("click",function(){let i=f(t),l=i.$implicit,I=i.index,D=p(2);return C(D.onEdit(l,I))}),r(26,"div",22),s(27),_(28,"number"),a()(),r(29,"td",23),d("click",function(){let i=f(t),l=i.$implicit,I=i.index,D=p(2);return C(D.onEdit(l,I))}),r(30,"div",18)(31,"div",24),s(32),_(33,"number"),a()()(),r(34,"td",25)(35,"div",26)(36,"span",27),d("click",function(){let i=f(t),l=i.$implicit,I=i.index,D=p(2);return C(D.onRemove(l,I))}),y(37,"i",28),a()()()(),x()}if(o&2){let t=e.$implicit,n=K(7),i=p(2);c(2),m("ngIf",i.appConfig==null?null:i.appConfig.ModuleSell.Grid.RowNumberVisible),c(3),m("ngIf",t.ThumbnailUrl)("ngIfElse",n),c(5),j(t.Name),c(2),j(t.Code),c(2),m("serials",t==null?null:t.Serial),c(),Je(t.Note?15:-1),c(4),m("ngIf",t.Quantity!==1&&t.Quantity!==0||t.UnitQuantity>1||t.VariantUnitQuantity>1),c(),m("ngIf",t.UnitQuantity>1),c(),m("ngIf",t.VariantUnitQuantity>1),c(),m("ngIf",t.UOM&&(i.appConfig==null||i.appConfig.ModuleSell==null?null:i.appConfig.ModuleSell.Grid.UOMVisible)),c(2),m("ngIf",t.Price!==t.Total),c(3),S(" ",t.Discount?b(28,14,t.Discount*-1)+"%":""," "),c(5),S(" ",i.roleService.product!=null&&i.roleService.product.Price?b(33,16,t.Total):" - "," ")}}function di(o,e){if(o&1){let t=A();h(0),r(1,"table",6)(2,"tbody",7),d("cdkDropListDropped",function(i){f(t);let l=p();return C(l.onDrop(i))}),v(3,ui,38,18,"ng-container",8),a()(),x()}if(o&2){let t=p();c(3),m("ngForOf",t.cartItems)}}function gi(o,e){o&1&&(r(0,"div",40)(1,"div",41)(2,"div",42)(3,"div",43)(4,"div",44),y(5,"i",45),a(),r(6,"div",46)(7,"span"),s(8,"Empty Cart"),a(),y(9,"br"),r(10,"span"),s(11,"Add products to the cart"),a(),y(12,"br"),r(13,"span"),s(14,"or scan barcode"),a()()()()()())}function fi(o,e){if(o&1){let t=A();r(0,"button",47),d("click",function(){let i=f(t).item,l=p();return C(l.onReverse(i,!0))}),s(1,"Return"),a(),r(2,"button",47),d("click",function(){let i=f(t).item,l=p();return C(l.onReverse(i,!1))}),s(3,"Purchase"),a()}}var _t=class o{roleService=u(ge);appConfig;cartItems=[];set _cartItems(e){e&&(this.cartItems=[...e])}onRemoveEvent=new V;onEditEvent=new V;onDropItems=new V;onReturnEvent=new V;onPurchaseEvent=new V;contextMenu;contextMenuPosition={x:"0px",y:"0px"};onContextMenu(e,t,n){e.preventDefault(),this.contextMenuPosition.x=e.clientX+"px",this.contextMenuPosition.y=e.clientY+"px",t.Index=n,this.contextMenu.menuData={item:t},this.contextMenu.openMenu()}onDrop(e){en(this.cartItems,e.previousIndex,e.currentIndex),this.onDropItems.emit(this.cartItems)}onEdit(e,t){this.onEditEvent.emit({cartItem:e,index:t})}onRemove(e,t){this.onRemoveEvent.emit({cartItem:e,index:t})}onReverse(e,t){let n=e.Index;t?(e.Quantity>0&&(e.Quantity=e.Quantity*-1),this.onReturnEvent.emit({cartItem:e,index:n})):(e.Quantity<0&&(e.Quantity=e.Quantity*-1),this.onPurchaseEvent.emit({cartItem:e,index:n}))}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["POS-cart-display"]],viewQuery:function(t,n){if(t&1&&zt(rt,7),t&2){let i;Gt(i=Jt())&&(n.contextMenu=i.first)}},inputs:{appConfig:"appConfig",_cartItems:[0,"cartItems","_cartItems"]},outputs:{onRemoveEvent:"onRemove",onEditEvent:"onEdit",onDropItems:"onDropItems",onReturnEvent:"onReturn",onPurchaseEvent:"onPurchase"},standalone:!0,features:[P],decls:7,vars:7,consts:[["EMPTY_CART",""],["contextMenu","matMenu"],["NO_IMAGE",""],[4,"ngIf","ngIfElse"],[2,"visibility","hidden","position","fixed",3,"matMenuTriggerFor"],["matMenuContent",""],[1,"table","table-borderless"],["cdkDropList","",3,"cdkDropListDropped"],[4,"ngFor","ngForOf"],["cdkDrag","",1,"border-bottom",3,"contextmenu"],["style","width: 10px",4,"ngIf"],[1,"pe-0",2,"width","50%",3,"click"],[1,"d-flex","align-items-center"],[1,"d-block","ms-4",2,"line-height","18px"],[1,"fw-normal","fs-6","text-muted"],[3,"serials"],["title","Note",1,"special-TinyMCE","m-0","fst-italic","d-block",3,"innerHtml"],[1,"px-0","text-end",2,"width","15%",3,"click"],[1,"d-flex","align-items-center","justify-content-end"],[1,"d-flex","text-end","fw-normal","align-items-center",2,"line-height","20px"],[4,"ngIf"],[3,"click"],[1,"fw-normal","fs-5","text-danger"],[1,"pe-0",3,"click"],[1,"fs-5"],[1,"mt-6","ps-0"],[1,"d-flex","justify-content-end","align-items-center"],["role","button","title","Delete Item",1,"fs-3","cursor-pointer",3,"click"],[1,"fa","fa-trash","text-danger","fs-4"],[2,"width","10px"],[1,"ratio","ratio-1x1",2,"width","55px"],[1,"item-image",3,"src"],[1,"item-image","d-flex","justify-content-center","align-items-center","text-center","fs-1"],[1,"fa-solid","fa-image",2,"color","#b4b4b4c2"],[1,"fs-6","me-1","ms-1"],[1,"d-flex","algin-items-center"],["title","Unit Quantity",1,"fs-5","me-1"],["title","Variant Unit Quantity",1,"fs-5"],["title","UOM",1,"ps-1","fs-5"],[1,"fs-5","text-end"],[1,"row","g-0","h-100"],[1,"col-12"],[1,"d-flex","justify-content-center","align-items-center","h-100"],[1,"row"],[1,"col-12","d-flex","justify-content-center"],[1,"fa-regular","fa-cart-arrow-up","text-secondary",2,"font-size","110px"],[1,"col-12","justify-content-center","text-center","mt-5","empty-cart-description","text-secondary","headings-font-family"],["mat-menu-item","",3,"click"]],template:function(t,n){if(t&1&&(v(0,di,4,1,"ng-container",3)(1,gi,15,0,"ng-template",null,0,ce),y(3,"div",4),r(4,"mat-menu",null,1),v(6,fi,4,0,"ng-template",5),a()),t&2){let i=K(2),l=K(5);m("ngIf",n.cartItems.length>0)("ngIfElse",i),c(3),Ht("left",n.contextMenuPosition.x)("top",n.contextMenuPosition.y),m("matMenuTriggerFor",l)}},dependencies:[T,de,z,ee,on,nn,tn,kn,hn,yn,vn,_n,bn,rt],styles:[".item-image[_ngcontent-%COMP%]{height:50px;width:56px;display:block;border:solid 1px #dddddd;border-radius:5px;object-fit:contain}.example-menu[_ngcontent-%COMP%]{display:inline-flex;flex-direction:column;min-width:180px;max-width:280px;background-color:#fff;padding:6px 0}.example-menu-item[_ngcontent-%COMP%]{background-color:transparent;cursor:pointer;border:none;-webkit-user-select:none;user-select:none;min-width:64px;line-height:36px;padding:0 16px;display:flex;align-items:center;flex-direction:row;flex:1}.example-menu-item[_ngcontent-%COMP%]:hover{background-color:#f5f5f5}.example-menu-item[_ngcontent-%COMP%]:active{background-color:#dcdcdc}.table[_ngcontent-%COMP%] > [_ngcontent-%COMP%]:not(caption) > *[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]{padding:12px 10px} .cdk-menu.cdk-menu-group.example-menu{box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.empty-cart-description[_ngcontent-%COMP%]{font-size:14px;font-weight:500;color:#c7c7c7}"]})};function _i(o,e){if(o&1&&(r(0,"mat-option",6),s(1),a()),o&2){let t=e.$implicit;m("value",t),c(),S(" ",t.Value," ")}}var bt=class o{httpService=u(X);customerCtrl=new we;customerFiltered$=this.customerCtrl.valueChanges.pipe(O(e=>typeof e=="string"&&e.length>=3),jt(300),Z(e=>this.getCustomerSuggestion(e)));customerSelected$=this.customerCtrl.valueChanges.pipe(O(e=>typeof e!="string"),k(e=>{this.onChange(e)}));createNewCustomer=new V;clickInput=new V;constructor(){this.customerSelected$.pipe(R()).subscribe()}getCustomerSuggestion(e){return this.httpService.get(G.GetCustomerSuggestions,[{key:"count",value:100},{key:"prefix",value:e}])}displayFn(e){return e?.Value}onCreateCustomer(){this.createNewCustomer.emit()}onClickInputValue(){this.clickInput.emit()}onChange=e=>{};onTouched=()=>{};writeValue(e){this.customerCtrl.patchValue(e,{onlySelf:!0,emitEvent:!1})}registerOnChange(e){this.onChange=e}registerOnTouched(e){this.onTouched=e}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["POS-customer-autocomplete"]],outputs:{createNewCustomer:"onCreateNewCustomer",clickInput:"onClickInput"},standalone:!0,features:[Te([{provide:tt,multi:!0,useExisting:o}]),P],decls:7,vars:6,consts:[["auto","matAutocomplete"],[1,"d-flex","align-items-center","position-relative"],["matTooltipPosition","above","matTooltip","New Customer","role","button",1,"fa-light","fa-user-plus","position-absolute","cursor-pointer",2,"font-size","12px",3,"click"],["type","text","placeholder","Assign Customer",3,"click","formControl","matAutocomplete"],[3,"displayWith"],[3,"value",4,"ngFor","ngForOf"],[3,"value"]],template:function(t,n){if(t&1){let i=A();r(0,"div",1)(1,"i",2),d("click",function(){return f(i),C(n.onCreateCustomer())}),a(),r(2,"input",3),d("click",function(){return f(i),C(n.onClickInputValue())}),a(),r(3,"mat-autocomplete",4,0),v(5,_i,2,2,"mat-option",5),_(6,"async"),a()()}if(t&2){let i=K(4);c(2),m("formControl",n.customerCtrl)("matAutocomplete",i),c(),m("displayWith",n.displayFn),c(2),m("ngForOf",b(6,4,n.customerFiltered$))}},dependencies:[T,de,Oe,mn,cn,Zt,sn,Ne,te,Y,ke,it,nt,at],styles:["input[_ngcontent-%COMP%]{width:100%;height:38px!important;border-radius:.375rem;border:1px solid #ced4da;padding-left:32px}input[_ngcontent-%COMP%]::placeholder{color:#ced4da}i[_ngcontent-%COMP%]{font-size:16px;top:12px;left:11px}"]})};var qe=class o{storeService=u(E);dialog=u(oe);httpService=u(X);createNewCustomer(){this.dialog.open(xn,{data:{options:this.storeService.loadForm()?.EstimateOptions,config:this.storeService.loadForm()?.AppConfigJSON?.ModuleContact,type:"customer",title:"New Customer Form"}}).afterClosed().pipe(O(e=>g.IsNotEmpty(e))).subscribe(e=>{let t=new re;t.Key=e.CustomerID,t.Value=e.ContactName,this.storeService.updateCustomer(t)})}onSelectCustomer(e){let t=this.storeService.outlet();this.httpService.get(G.GetCustomerPrivilegeByID,[{key:"ID",value:e.Key},{key:"EntityID",value:t.ID}]).pipe(Ut(()=>{let n=new re;return this.storeService.updateCustomer(n),Ft})).subscribe(n=>{let i=JSON.parse(JSON.stringify(e));i.PricebookID=n.PricebookID,this.storeService.updateCustomer(i)})}onDeleteCustomer(){g.IsNotEmpty(this.storeService?.customer()?.Key)&&this.dialog.open(En,{data:{title:"Re-assign customer",message:"Are you sure to re-assign the customer?"}}).afterClosed().pipe(O(e=>e)).subscribe(()=>{let e=new re;this.storeService.updateCustomer(e)})}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};var vt=class o{clickEvent=new V;onClick(){this.clickEvent.emit()}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["app-note-button"]],outputs:{clickEvent:"onClickEvent"},standalone:!0,features:[P],decls:2,vars:0,consts:[["type","button",1,"btn","btn-gray","w-100","fs-3","px-0","py-6","headings-font-family",3,"click"],[1,"fa-regular","fa-note-sticky","fa-xl"]],template:function(t,n){t&1&&(r(0,"button",0),d("click",function(){return n.onClick()}),y(1,"i",1),a())},dependencies:[T],styles:[".btn-gray[_ngcontent-%COMP%]{border:1px solid #d6d6d6;color:#545454!important;background:linear-gradient(to bottom,#fff,#eee)}"]})};function bi(o,e){if(o&1&&(r(0,"div"),s(1),_(2,"number"),a()),o&2){let t=p();c(),S(" ",b(2,1,t.totalAmount)," ")}}function vi(o,e){o&1&&s(0," - ")}var yt=class o{payEvent=new V;totalItems=0;totalQuantity=0;totalAmount=0;rolePrice=!0;constructor(){}ngOnInit(){}onPay(){this.payEvent.emit()}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["app-pay-button"]],inputs:{totalItems:"totalItems",totalQuantity:"totalQuantity",totalAmount:"totalAmount",rolePrice:"rolePrice"},outputs:{payEvent:"onPayEvent"},standalone:!0,features:[P],decls:11,vars:6,consts:[["HIDDENCOST",""],["type","button",1,"btn","btn-success","fs-1","py-4","w-100",3,"click"],[1,"d-flex","align-items-center","justify-content-between"],[1,"fs-6"],[4,"ngIf","ngIfElse"]],template:function(t,n){if(t&1){let i=A();r(0,"button",1),d("click",function(){return f(i),C(n.onPay())}),r(1,"div",2)(2,"div")(3,"span"),s(4,"Submit"),a(),r(5,"small",3),s(6),_(7,"number"),a()(),v(8,bi,3,3,"div",4)(9,vi,1,0,"ng-template",null,0,ce),a()()}if(t&2){let i=K(10);c(6),Pe(" (",b(7,4,n.totalItems)," Items & ",n.totalQuantity," Qty) "),c(2),m("ngIf",n.rolePrice)("ngIfElse",i)}},dependencies:[T,z,ee],styles:["button[_ngcontent-%COMP%]{border-right:.1px solid #fff;margin-left:-1px;border-top-left-radius:0;border-bottom-left-radius:0;position:relative;flex:1 1 auto;border-left:.1px solid #fff}"]})};var ht=class o{clickEvent=new V;onClick(){this.clickEvent.emit()}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["app-discount-button"]],outputs:{clickEvent:"onClickEvent"},standalone:!0,features:[P],decls:2,vars:0,consts:[["type","button","matTooltip","Discount / Tax","matTooltipPosition","above",1,"btn","btn-success","fs-5",3,"click"],[1,"fa-light","fa-percent"]],template:function(t,n){t&1&&(r(0,"button",0),d("click",function(){return n.onClick()}),y(1,"i",1),a())},dependencies:[T,it,nt],styles:["button[_ngcontent-%COMP%]{border-right:.1px solid #fff;border-top-right-radius:0;border-bottom-right-radius:0;position:relative;flex:1 1 auto}"]})};var Be=class o{store=u(E);toastr=u(et);dialog=u(oe);updateState$=U(this.store.complete).pipe(O(e=>e.Success),k(()=>this.store.updateState(3)),R());constructor(){this.updateState$.subscribe()}onPay(){if(this.validatePayOrder()==!1)return;let t={Items:this.cartItemPreSubmission(),Order:B({},this.store.order())};this.dialog.open(Vn,{data:{transactionData:t,api:G.SubmitEstimate}}).afterClosed().pipe(O(n=>g.IsNotEmpty(n))).subscribe(n=>{this.store.updateComplete(n)})}cartItemPreSubmission(){let e=JSON.parse(JSON.stringify(this.store.cartItems()));return e=e.map(t=>(delete t.Variant,t)),e}validatePayOrder(){let e=!0;return g.IsEmpty(this.store.outlet().ID)&&(this.toastr.error("Please select outlet before proceeding..",Ee.Error),e=!1),g.IsEmpty(this.store.customer().Key)&&(this.toastr.warning("Please select a customer!",Ee.Warning),e=!1),this.store.cartItems().length==0&&(this.toastr.error("You must have at least one item.",Ee.Error),e=!1),g.IsEmpty(this.store.order().Number)&&(this.toastr.error("Number cannot be empty.",Ee.Error),e=!1),e}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};var xt=class o{constructor(e,t){this.dialogRef=t;this.discountAmount.set(e.discountAmount),this.discount.set(e.discount),this.tax=F(e.tax),this.currency=F(e.currency),this.taxes.set(e.taxes),this.initModalConfig()}modalConfig=new be;discountAmount=F(0);discount=F(0);tax;discounts=F([0,0,0]);currency;taxes=F([]);initModalConfig(){this.modalConfig.title="Discount and Tax",this.modalConfig.customWidth="400px"}onClose(){this.dialogRef.close()}onSave(){this.dialogRef.close({discountAmount:this.discountAmount(),discount:this.discount(),tax:this.tax()})}onSelectTax(e){this.tax.set(e)}onDiscountCalculatorChange(e,t){let n=this.discounts();n[t]=e,this.discounts.set(n),this.calculateDiscountCalculator()}calculateDiscountCalculator(){let e=this.discounts(),t=100;e.forEach(i=>{i&&i>0&&(t=t*(100-i)/100)});let n=100-t;this.discount.set(n)}static \u0275fac=function(t){return new(t||o)(Q(Ce),Q(fe))};static \u0275cmp=M({type:o,selectors:[["app-dialog-discount"]],standalone:!0,features:[P],decls:48,vars:10,consts:[[3,"keydown.F2","onOk","onCancel","onClose","config"],[1,"container"],["matTooltipPosition","above","matTooltip","Discount","tabTitle","Discount"],[1,"row","d-flex","align-items-center","justify-content-start"],[1,"col-3"],[1,"fw-bold","d-block"],[1,"col-9"],["type","text","data-cy","discount1","autoNum","","percentage","","decimalPlaces","2",1,"form-control","d-inline-block",2,"width","100px",3,"ngModelChange","ngModel"],[1,"ms-1"],[1,"row","d-flex","align-items-center","justify-content-start","mt-6"],["type","text","data-cy","discountamount","autoNum","",1,"form-control","d-inline-block",2,"width","100px",3,"ngModelChange","ngModel"],["matTooltipPosition","above","matTooltip","Tax","tabTitle","Tax"],["bindLabel","Label","appendTo","body","bindValue","ID","placeholder","Tax","data-cy","Tax",2,"width","150px",3,"change","clearable","ngModel","items"],["matTooltipPosition","above","matTooltip","Calculation","tabTitle","Calculator"],[1,"row","mt-6","g-0","d-flex","align-items-center","justify-content-start"],[1,"col-4"],[1,"col-8","ps-4"],["type","text","data-cy","discountCal1","autoNum","","percentage","",1,"form-control","d-inline-block",2,"width","47px",3,"ngModelChange","ngModel"],[1,"mx-2"],["type","text","data-cy","discountCal2","autoNum","","percentage","",1,"form-control","d-inline-block",2,"width","47px",3,"ngModelChange","ngModel"],["type","text","data-cy","discountCal3","autoNum","","percentage","",1,"form-control","d-inline-block",2,"width","47px",3,"ngModelChange","ngModel"]],template:function(t,n){if(t&1&&(r(0,"modal-material",0),d("keydown.F2",function(){return n.onSave()})("onOk",function(){return n.onSave()})("onCancel",function(){return n.onClose()})("onClose",function(){return n.onClose()}),r(1,"content")(2,"div",1)(3,"custom-tabs"),h(4),r(5,"tab",2)(6,"div",3)(7,"div",4)(8,"label",5),s(9,"Discount %"),a()(),r(10,"div",6)(11,"input",7),q("ngModelChange",function(l){return W(n.discount,l)||(n.discount=l),l}),a(),r(12,"span",8),s(13,"%"),a()()(),r(14,"div",9)(15,"div",4)(16,"label",5),s(17),a()(),r(18,"div",6)(19,"input",10),q("ngModelChange",function(l){return W(n.discountAmount,l)||(n.discountAmount=l),l}),a()()()(),x(),h(20),r(21,"tab",11)(22,"div",3)(23,"div",4)(24,"label",5),s(25,"Tax"),a()(),r(26,"div",6)(27,"ng-select",12),d("change",function(l){return n.onSelectTax(l)}),a()()()(),x(),h(28),r(29,"tab",13)(30,"div",14)(31,"div",15)(32,"label",5),s(33,"Discount Calculator"),a()(),r(34,"div",16)(35,"input",17),d("ngModelChange",function(l){return n.onDiscountCalculatorChange(l,0)}),a(),r(36,"span"),s(37," %"),a(),r(38,"span",18),s(39,"+"),a(),r(40,"input",19),d("ngModelChange",function(l){return n.onDiscountCalculatorChange(l,1)}),a(),r(41,"span"),s(42," %"),a(),r(43,"span",18),s(44,"+"),a(),r(45,"input",20),d("ngModelChange",function(l){return n.onDiscountCalculatorChange(l,2)}),a(),r(46,"span"),s(47," %"),a()()()(),x(),a()()()()),t&2){let i;m("config",n.modalConfig),c(11),L("ngModel",n.discount),c(6),S("Discount ",(i=n.currency())==null?null:i.Symbol,""),c(2),L("ngModel",n.discountAmount),c(8),m("clearable",!1)("ngModel",n.tax().ID)("items",n.taxes()),c(8),m("ngModel",n.discounts[0]),c(5),m("ngModel",n.discounts[1]),c(5),m("ngModel",n.discounts[2])}},dependencies:[T,ye,ve,lt,st,ct,ie,te,Y,ne,Ve,Ae,_e,he]})};var Me=class o{storeService=u(E);totalItemsQty=H(()=>this.storeService.cartItems().reduce((n,i)=>n+i.Quantity,0));totalItemsAmount=H(()=>this.storeService.cartItems().reduce((n,i)=>n+i.Total,0));taxAmount=H(()=>{let e=this.storeService.tax(),t=0;return e.Rate>0&&(e.CalculationTypeID==1?t=this.calculateTaxInclude(e):t=this.calculateTaxAdd(e)),t});totalAmount=H(()=>{let e=this.storeService.tax(),t=this.storeService.order().DiscountAmount,n=this.storeService.order().Discount,i=this.totalItemsAmount(),l=this.calculatePercentagDisc(n,i),I=i-t-l;return e.CalculationTypeID==0&&(I=I+this.taxAmount()),I});discountPercentageAmount=H(()=>{let e=this.storeService.order().Discount,t=this.totalItemsAmount();return this.calculatePercentagDisc(e,t)});calculateTaxInclude(e){let t=this.grossTotalTaxable();return e.Rate/(100+e.Rate)*t}calculateTaxAdd(e){let t=this.grossTotalTaxable();return e.Rate/100*t}grossTotalTaxable(){let e=this.taxableItems(),t=this.calculateTaxableItemsPrice(),n=this.storeService.discount();if(e.length!==0){let i=this.calculateDiscountTaxableItem();t=t*(100-n.discount)/100,t=t-i}return t}calculateDiscountTaxableItem(){let e=this.taxableItems(),t=this.totalItemsAmount(),n=this.storeService.discount().discountAmount,i=0,l=0,I=0,D=0;for(let ae of e)i=ae.getItemAfterDiscount/t,l=i*n,D=l*ae.Quantity,I+=D;return I}calculatePercentagDisc(e,t){return e/100*t}calculateTaxableItemsPrice(){return this.taxableItems().filter(n=>n.Taxable).reduce((n,i)=>n+i.Total,0)}taxableItems(){return this.storeService.cartItems().filter(t=>t.Taxable)}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};var xi=o=>({selected:o});function Si(o,e){if(o&1){let t=A();r(0,"div",12)(1,"span",13),s(2,"@"),a(),r(3,"input",14),q("ngModelChange",function(i){f(t);let l=p();return W(l.currency().ExchangeRate,i)||(l.currency().ExchangeRate=i),C(i)}),a()()}if(o&2){let t=p();c(3),L("ngModel",t.currency().ExchangeRate)}}function Ii(o,e){if(o&1){let t=A();r(0,"div",15)(1,"label",16)(2,"input",17),d("ngModelChange",function(){let i=f(t).$implicit,l=p();return C(l.onChangeTag(i.ID))}),a(),s(3),a()()}if(o&2){let t,n=e.$implicit,i=e.index,l=p();c(),Tt("for","potype-"+i),m("ngClass",$(5,xi,((t=l.tag())==null?null:t.ID)==n.ID)),c(),Tt("id","potype-"+i),m("ngModel",l.tag().ID),c(),S(" ",n.Name," ")}}var St=class o{constructor(e,t){this.dialogRef=t;this.initModalConfig(),this.currencies.set(e.currencies),this.tags.set(e.tags),this.tag=F(e.tag),this.currency=F(e.currency),this.defaultCurrencyId=F(e.defaultCurrencyId)}modalConfig=new be;currencies=F([]);tags=F([]);tag;currency;defaultCurrencyId;initModalConfig(){this.modalConfig.title="Order Note",this.modalConfig.customWidth="700px"}onChangeCurrency(e){let t=this.currencies()?.find(n=>n.ID===e);this.currency.set(t)}onChangeTag(e){let t=this.tags()?.find(n=>n.ID===e);this.tag.set(t)}onClose(){this.dialogRef.close()}onSave(){this.dialogRef.close({currency:this.currency(),tag:this.tag()})}static \u0275fac=function(t){return new(t||o)(Q(Ce),Q(fe))};static \u0275cmp=M({type:o,selectors:[["app-dialog-note"]],standalone:!0,features:[P],decls:16,vars:6,consts:[[3,"keydown.F2","onOk","onCancel","onClose","config"],[1,"container"],["matTooltipPosition","above","matTooltip","Currency","tabTitle","Currency"],[1,"row","d-flex","align-items-center","justify-content-start","mt-6"],[1,"row","ms-4"],[1,"ps-0","col-sm-4"],["bindLabel","Name","bindValue","ID","placeholder","Currency","appendTo","body",3,"ngModelChange","items","clearable","ngModel"],["class","col-sm-4 d-flex",4,"ngIf"],["matTooltipPosition","above","matTooltip","Tag","tabTitle","Tag"],[1,"row"],[1,"col-12"],["class","rad-btn",4,"ngFor","ngForOf"],[1,"col-sm-4","d-flex"],[1,"pt-4"],["type","text","autoNum","",1,"border","border-light",3,"ngModelChange","ngModel"],[1,"rad-btn"],[3,"for","ngClass"],["type","radio",3,"ngModelChange","ngModel","id"]],template:function(t,n){if(t&1&&(r(0,"modal-material",0),d("keydown.F2",function(){return n.onSave()})("onOk",function(){return n.onSave()})("onCancel",function(){return n.onClose()})("onClose",function(){return n.onClose()}),r(1,"content")(2,"div",1)(3,"custom-tabs"),h(4),r(5,"tab",2)(6,"div",3)(7,"div",4)(8,"div",5)(9,"ng-select",6),d("ngModelChange",function(l){return n.onChangeCurrency(l)}),a()(),v(10,Si,4,1,"div",7),a()()(),x(),h(11),r(12,"tab",8)(13,"div",9)(14,"div",10),v(15,Ii,4,7,"div",11),a()()(),x(),a()()()()),t&2){let i;m("config",n.modalConfig),c(9),m("items",n.currencies())("clearable",!1)("ngModel",n.currency().ID),c(),m("ngIf",((i=n.currency())==null?null:i.ID)!=n.defaultCurrencyId()),c(5),m("ngForOf",n.tags())}},dependencies:[T,ue,de,z,ye,ve,lt,st,ct,ie,te,Yt,Y,ne,Ve,Ae,_e,he],styles:[".bg-light-gray[_ngcontent-%COMP%]{background-color:var(--bs-light-gray);--bs-bg-opacity: .15 !important}.bg-gradient-danger[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#f8d7da,#f8d7da 15px,#f5c6cb 15px 30px)!important}.bg-gradient-success[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#beeebb,#beeebb 15px,#afeba8 15px 30px)!important}.bg-gradient-warning[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#fcf3cf,#fcf3cf 15px,#f9e79f 15px 30px)!important}.bg-light-orange[_ngcontent-%COMP%]{background-color:var(--bs-light-orange);--bs-bg-opacity: .15 !important}.text-danger[_ngcontent-%COMP%]{color:#fb404b!important}.text-dark[_ngcontent-%COMP%]{color:#5e5e5e!important}.text-success[_ngcontent-%COMP%]{color:#87cb16!important}.text-black[_ngcontent-%COMP%]{color:#000!important}.text-white[_ngcontent-%COMP%]{color:var(--bs-white)!important}.btn-light-blue[_ngcontent-%COMP%]{color:#212529;background-color:#dfeffc!important;border-color:#dfeffc}.btn-light-blue[_ngcontent-%COMP%]:hover{color:#212529;background-color:#bcdef9;border-color:#b0d8f8}.btn-light-blue[_ngcontent-%COMP%]:focus, .btn-light-blue.focus[_ngcontent-%COMP%]{color:#212529;background-color:#bcdef9;border-color:#b0d8f8;box-shadow:0 0 0 .2rem #c3d1dc80}.btn-light-blue.disabled[_ngcontent-%COMP%], .btn-light-blue[_ngcontent-%COMP%]:disabled{color:#212529;background-color:#dfeffc;border-color:#dfeffc}.btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active, .btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active, .show[_ngcontent-%COMP%] > .btn-light-blue.dropdown-toggle[_ngcontent-%COMP%]{color:#212529;background-color:#b0d8f8;border-color:#a5d2f7}.btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active:focus, .btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active:focus, .show[_ngcontent-%COMP%] > .btn-light-blue.dropdown-toggle[_ngcontent-%COMP%]:focus{box-shadow:0 0 0 .2rem #c3d1dc80}.rad-btn[_ngcontent-%COMP%]{position:relative;display:inline-block}.rad-btn[_ngcontent-%COMP%] label[_ngcontent-%COMP%]{border:1px solid #dddddd;border-radius:3px;margin-right:10px;cursor:pointer;padding:10px;margin-bottom:10px;color:#000}.rad-btn[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{visibility:hidden;position:absolute;left:0;top:0}.rad-btn[_ngcontent-%COMP%] label.selected[_ngcontent-%COMP%]{background:#dcdcdc;border:1px solid #dcdcdc}"]})};var It=class o{onClickEvent=new V;constructor(){}ngOnInit(){}onClick(){this.onClickEvent.emit()}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["app-clear-button"]],outputs:{onClickEvent:"onClickEvent"},standalone:!0,features:[P],decls:3,vars:0,consts:[["type","button",1,"btn","btn-gray","w-100","fs-3","px-0","py-6","headings-font-family",3,"click"]],template:function(t,n){t&1&&(r(0,"button",0),d("click",function(){return n.onClick()}),r(1,"span"),s(2,"Clear"),a()())},styles:[".btn-gray[_ngcontent-%COMP%]{border:1px solid #d6d6d6;color:#545454!important;background:linear-gradient(to bottom,#fff,#eee)}"]})};function Di(o,e){if(o&1&&(h(0),r(1,"tr")(2,"th",12),s(3,"Amount"),a(),r(4,"td",13),s(5),_(6,"number"),a()(),x()),o&2){let t=p();c(5),j(b(6,1,t.calculationService==null?null:t.calculationService.totalItemsAmount()))}}function Mi(o,e){if(o&1&&(r(0,"tr")(1,"th",12),s(2),a(),r(3,"td",14),s(4),_(5,"number"),a()()),o&2){let t=p(2);c(2),S("Discount ",t.storeService==null?null:t.storeService.discount().discount,"%"),c(2),S(" ",b(5,2,t.calculationService.discountPercentageAmount()*-1),"")}}function Pi(o,e){if(o&1&&(r(0,"tr")(1,"th",12),s(2),a(),r(3,"td",14),s(4),_(5,"number"),a()()),o&2){let t,n,i=p(2);c(2),S("Discount ",(t=i.storeService.currency())==null?null:t.Symbol,""),c(2),S(" ",b(5,2,((n=i.storeService.discount())==null?null:n.discountAmount)*-1),"")}}function Ei(o,e){if(o&1&&(r(0,"tr")(1,"th",12),s(2),a(),r(3,"td",13),s(4),_(5,"number"),a()()),o&2){let t,n=p(2);c(2),j((t=n.storeService.tax())==null?null:t.Label),c(2),j(b(5,2,n.calculationService.taxAmount()))}}function Ti(o,e){if(o&1&&(h(0),v(1,Mi,6,4,"tr",3)(2,Pi,6,4,"tr",3)(3,Ei,6,4,"tr",3),x()),o&2){let t,n,i=p();c(),m("ngIf",i.storeService.discount().discount!=0),c(),m("ngIf",((t=i.storeService.discount())==null?null:t.discountAmount)!=0),c(),m("ngIf",((n=i.storeService.tax())==null?null:n.Rate)!=0)}}var Dt=class o{storeService=u(E);orderService=u(se);roleService=u(ge);payService=u(Be);calculationService=u(Me);cartService=u(me);dialog=u(oe);taxCalculationType=ot;totalItemsQty=H(()=>this.storeService.cartItems()?.length);isShowAmount=H(()=>this.storeService?.tax()?.CalculationTypeID==0&&this.storeService?.tax()?.Rate||this.storeService.discount()?.discount!=0||this.storeService.discount()?.discountAmount!=0);onOpenDialogNote(){this.dialog.open(St,{data:{tags:this.storeService.loadForm().CustomerPOTypes,currencies:this.storeService.loadForm().Currencies,currency:this.storeService.currency(),tag:this.storeService.tag(),defaultCurrencyId:this.storeService.loadForm()?.AppConfigJSON?.CoreDefaults?.CurrencyID}}).afterClosed().pipe(O(e=>g.IsNotEmpty(e))).subscribe(e=>{this.storeService.updateCurrency(e.currency),this.storeService.updateTag(e.tag)})}onOpenDialogDiscount(){this.dialog.open(xt,{data:{discountAmount:this.storeService.order().DiscountAmount,discount:this.storeService.order().Discount,tax:this.storeService.tax(),currency:this.storeService.currency(),taxes:this.storeService.loadForm().Taxes}}).afterClosed().pipe(O(e=>g.IsNotEmpty(e))).subscribe(e=>{this.storeService.updateDiscount({discountAmount:e.discountAmount,discount:e.discount}),this.storeService.updateTax(e.tax)})}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["POS-cart-action"]],standalone:!0,features:[P],decls:13,vars:6,consts:[[1,"row","g-0","px-5","justify-content-end"],[1,"col-6",2,"padding-right","15px"],[1,"table","table-borderless"],[4,"ngIf"],[1,"row","g-0","pb-6","px-5"],[1,"col-5","d-flex","justify-content-between","pe-5",2,"column-gap","12px"],[2,"flex-grow","1",3,"onClickEvent"],[2,"flex-grow","3",3,"onClickEvent"],[1,"col-7"],[1,"btn-group","w-100"],[1,"d-inline-flex",3,"onClickEvent"],[1,"d-inline-flex","w-100",3,"onPayEvent","rolePrice","totalQuantity","totalItems","totalAmount"],[1,"text-start"],[1,"text-end","fs-5"],[1,"text-end","fs-5","text-danger"]],template:function(t,n){t&1&&(r(0,"div",0)(1,"div",1)(2,"table",2),v(3,Di,7,3,"ng-container",3)(4,Ti,4,3,"ng-container",3),a()()(),r(5,"div",4)(6,"div",5)(7,"app-note-button",6),d("onClickEvent",function(){return n.onOpenDialogNote()}),a(),r(8,"app-clear-button",7),d("onClickEvent",function(){return n.cartService.clearCart()}),a()(),r(9,"div",8)(10,"div",9)(11,"app-discount-button",10),d("onClickEvent",function(){return n.onOpenDialogDiscount()}),a(),r(12,"app-pay-button",11),d("onPayEvent",function(){return n.payService.onPay()}),a()()()()),t&2&&(c(3),m("ngIf",n.isShowAmount()),c(),m("ngIf",n.calculationService.totalItemsQty()>0),c(8),m("rolePrice",n.roleService.product.Price)("totalQuantity",n.calculationService.totalItemsQty())("totalItems",n.totalItemsQty())("totalAmount",n.calculationService.totalAmount()))},dependencies:[T,z,ee,ht,vt,yt,It]})};var Bn=o=>({ID:o}),Oi=()=>["/menu/Orders/Orders/Estimate/Info"],wi=o=>({"border-top":o});function ki(o,e){if(o&1&&(h(0),r(1,"div",28)(2,"div",29),s(3),a(),r(4,"div",29),s(5),_(6,"number"),a()(),x()),o&2){let t=e.$implicit;c(3),j(t.Name),c(2),S("",b(6,2,t.Total)," ")}}function Ni(o,e){if(o&1&&(h(0),r(1,"div",30)(2,"div",31),s(3),a(),r(4,"div",31),s(5),_(6,"number"),a()(),x()),o&2){let t,n=p();c(3),S("Amount: ",(t=n.storeService.currency())==null?null:t.Symbol,""),c(2),j(b(6,2,n.calculationService.totalItemsAmount()))}}function Ai(o,e){if(o&1&&(r(0,"div",32)(1,"div",31),s(2),_(3,"number"),a(),r(4,"div",33),s(5),_(6,"number"),a()()),o&2){let t,n=p();c(2),Pe("","Discount "+b(3,3,(t=n.storeService.discount())==null?null:t.discount)+" %",": ",(t=n.storeService.currency())==null?null:t.Symbol,""),c(3),j(b(6,5,n.calculationService.discountPercentageAmount()*-1))}}function Vi(o,e){if(o&1&&(r(0,"div",32)(1,"div",31),s(2),a(),r(3,"div",33),s(4),_(5,"number"),a()()),o&2){let t,n,i=p();c(2),S("Discount: ",(t=i.storeService.currency())==null?null:t.Symbol,""),c(2),S("",b(5,2,((n=i.storeService.discount())==null?null:n.discountAmount)*-1)," ")}}function Fi(o,e){if(o&1&&(r(0,"div",32)(1,"div",31),s(2),a(),r(3,"div",31),s(4),_(5,"number"),a()()),o&2){let t,n=p();c(2),Pe("",(t=n.storeService.tax())==null?null:t.Label,": ",(t=n.storeService.currency())==null?null:t.Symbol,""),c(2),j(b(5,3,n.calculationService.taxAmount()))}}var Mt=class o{orderService=u(se);calculationService=u(Me);storeService=u(E);isShowAmount=H(()=>this.storeService?.tax()?.CalculationTypeID==0&&this.storeService?.tax()?.Rate||this.storeService.discount()?.discount!=0||this.storeService.discount()?.discountAmount!=0);handleF8(){this.orderService.newOrder()}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["POS-complete"]],hostBindings:function(t,n){t&1&&d("keydown.F8",function(l){return n.handleF8(l)},!1,Ge)},standalone:!0,features:[P],decls:40,vars:21,consts:[[1,"pt-7",2,"border-bottom","1px solid rgba(0, 0, 0, 0.1)"],[1,"ps-7","fw-normal","pb-9"],[1,"order-complete"],[1,"container-fluid","pt-8"],[1,"row"],[1,"col-8"],[1,"card"],[1,"card-header",2,"padding-bottom","15px"],[1,"fw-normal",2,"font-size","32px"],[1,"fa-solid","fa-check","me-3"],[1,"card-body"],[1,"row",2,"height","115px"],[1,"col","text-center","my-auto"],[1,"btn","btn-success","w-50",2,"font-size","20px",3,"click"],[1,"card-footer"],[1,"d-flex","justify-content-between","my-6"],["target","_blank","routerLink","/print/Estimate",1,"btn","bg-light-gray","btn-secondary",3,"queryParams"],[1,"fa-solid","fa-print","me-2"],[1,"col-4"],[1,"card-header","bg-light-gray",2,"padding-bottom","15px"],[1,"fst-italic"],["target","_blank",3,"routerLink","queryParams"],[1,"card-body","py-4"],[4,"ngFor","ngForOf"],[4,"ngIf"],["class","row justify-content-end pb-2",4,"ngIf"],[1,"row","justify-content-end","pt-4",3,"ngClass"],[1,"col-4","text-end","h5"],[1,"row","justify-content-between","border-bottom","py-2"],[1,"col","text-end"],[1,"row","justify-content-end","mt-2","pb-2"],[1,"col-4","text-end"],[1,"row","justify-content-end","pb-2"],[1,"col-4","text-end","text-danger"]],template:function(t,n){if(t&1&&(r(0,"div",0)(1,"h1",1),s(2,"Estimate"),a()(),r(3,"section",2)(4,"div",3)(5,"div",4)(6,"div",5)(7,"div",6)(8,"div",7)(9,"h1",8),y(10,"i",9),s(11,"Order Complete "),a()(),r(12,"div",10)(13,"div",11)(14,"div",12)(15,"a",13),d("click",function(){return n.orderService.newOrder()}),s(16,"New Order (F8)"),a()()()(),r(17,"div",14)(18,"div",15)(19,"a",16),y(20,"i",17),s(21,"Print Receipt"),a()()()()(),r(22,"div",18)(23,"div",6)(24,"div",19)(25,"h3",20)(26,"a",21),s(27),a()()(),r(28,"div",22),v(29,ki,7,4,"ng-container",23)(30,Ni,7,4,"ng-container",24)(31,Ai,7,7,"div",25)(32,Vi,6,4,"div",25)(33,Fi,6,5,"div",25),r(34,"div",26)(35,"div",27),s(36),a(),r(37,"div",27),s(38),_(39,"number"),a()()()()()()()()),t&2){let i,l,I,D,ae;c(19),m("queryParams",$(14,Bn,n.storeService.complete().OrderID)),c(7),m("routerLink",Ke(16,Oi))("queryParams",$(17,Bn,n.storeService.complete().OrderID)),c(),S("Estimate #",(i=n.storeService.complete())==null?null:i.InvoiceNumber,""),c(2),m("ngForOf",n.storeService.cartItems()),c(),m("ngIf",n.isShowAmount()),c(),m("ngIf",((l=n.storeService.discount())==null?null:l.discount)>0),c(),m("ngIf",((I=n.storeService.discount())==null?null:I.discountAmount)>0),c(),m("ngIf",((D=n.storeService.tax())==null?null:D.Rate)>0),c(),m("ngClass",$(19,wi,n.isShowAmount())),c(2),S("Total: ",(ae=n.storeService.currency())==null?null:ae.Symbol,""),c(2),j(b(39,12,n.calculationService.totalAmount()))}},dependencies:[T,ue,de,z,ee,Ze,Xe,un],styles:[".order-complete[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] .card-header[_ngcontent-%COMP%]{border-bottom:1px solid rgba(0,0,0,.125);padding-bottom:.9375rem}.order-complete[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] .card-header[_ngcontent-%COMP%] h2[_ngcontent-%COMP%]{font-size:2rem}.order-complete[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] .card-body[_ngcontent-%COMP%] .container[_ngcontent-%COMP%]{max-width:500px;margin-top:30px;margin-bottom:30px}"]})};var Pt=class o{route=u(Ye);dialog=u(oe);addItem=new V;handleF8(){this.dialog.openDialogs&&this.dialog.openDialogs.length>0||this.onAddItem()}onAddItem(){this.addItem.emit()}redirectToPrevious(){this.route.navigate(["/menu/Estimate/V1"])}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["POS-more-action"]],hostBindings:function(t,n){t&1&&d("keydown.F4",function(l){return n.handleF8(l)},!1,Ge)},outputs:{addItem:"onAddItem"},standalone:!0,features:[P],decls:16,vars:0,consts:[["id","moreMenu","data-bs-toggle","dropdown",1,"d-flex","align-items-center","cursor-pointer"],[1,"me-2"],[1,"fa-solid","fa-caret-down","fa-lg"],[1,"fs-6","headings-font-family","pb-1"],[1,"h-100","d-flex","align-items-center","justify-content-between"],["aria-labelledby","moreMenu",1,"dropdown-menu","more-actions"],[1,"d-flex"],[1,"dropdown-header","text-dark","col"],[1,"h5","mb-4"],[1,"dropdown-divider","m-0"],[1,"cursor-pointer",3,"click"],["icon","fa-circle-plus fa-solid","label","Add New"],["icon","fa-solid fa-arrow-left","label","Estimate V1"]],template:function(t,n){t&1&&(r(0,"span",0)(1,"span",1),y(2,"i",2),a(),r(3,"span",3),s(4,"More Actions"),a()(),r(5,"div",4)(6,"div",5)(7,"div",6)(8,"div",7)(9,"div",8),s(10,"Item"),a(),y(11,"div",9),r(12,"li",10),d("click",function(){return n.onAddItem()}),y(13,"POS-dropdown-item-more-action",11),a(),r(14,"li",10),d("click",function(){return n.redirectToPrevious()}),y(15,"POS-dropdown-item-more-action",12),a()()()()())},dependencies:[T,Nn]})};function Ri(o,e){o&1&&(h(0),y(1,"POS-complete"),x())}function Bi(o,e){if(o&1){let t=A();r(0,"div",3)(1,"div",4)(2,"div",5)(3,"div",6)(4,"div",7)(5,"POS-select-outlet-form",8),_(6,"async"),d("ngModelChange",function(i){f(t);let l=p();return C(l.outletService.updateOutlet(i))}),a()(),r(7,"POS-invoice-number-form",9),_(8,"async"),d("ngModelChange",function(i){f(t);let l=p();return C(l.orderService.updateOrderNumber(i))}),a(),r(9,"POS-invoice-date",10),d("ngModelChange",function(i){f(t);let l=p();return C(l.orderService.updateOrderDate(i))}),a()()(),r(10,"div",11)(11,"div",12)(12,"div",13)(13,"POS-more-action",14),d("onAddItem",function(){f(t);let i=p();return C(i.cartItemService.onOpenAddDialog())}),a()(),r(14,"div",15)(15,"ng-select-infinite",16,1),d("selectedChange",function(i){f(t);let l=p();return C(l.orderService.updateSalesPersonId(i))}),a()()()()(),r(17,"div",17)(18,"div",18)(19,"POS-quick-key",19),_(20,"async"),d("onSelectVariant",function(i){f(t);let l=p();return C(l.cartItemService.onSelectQuickkeyItem(i))}),a()(),r(21,"div",20)(22,"div",21)(23,"div",22),y(24,"POS-variant-autocomplete",23),a(),r(25,"div",15)(26,"POS-customer-autocomplete",24),d("onCreateNewCustomer",function(){f(t);let i=p();return C(i.customerService.createNewCustomer())})("ngModelChange",function(i){f(t);let l=p();return C(l.customerService.onSelectCustomer(i))})("onClickInput",function(){f(t);let i=p();return C(i.customerService.onDeleteCustomer())}),a()()(),r(27,"POS-cart-display",25),_(28,"async"),d("onRemove",function(i){f(t);let l=p();return C(l.cartItemService.removeCartItem(i))})("onEdit",function(i){f(t);let l=p();return C(l.cartItemService.onOpenEditDialog(i))})("onDropItems",function(i){f(t);let l=p();return C(l.cartItemService.onDropItems(i))})("onPurchase",function(i){f(t);let l=p();return C(l.cartItemService.onPurchaseItem(i))})("onReturn",function(i){f(t);let l=p();return C(l.cartItemService.onReturnItem(i))}),a(),y(29,"POS-cart-action"),a()()()}if(o&2){let t,n=p();c(5),m("ngModel",n.storeService.outlet())("outlets",n.storeService.loadForm().Entities)("isOpenAfterLoad",b(6,18,n.outletService.isOpenDialog$)),c(2),m("ngModel",b(8,20,n.orderService.orderNumber$))("isEdit",n.isEditOrder()),c(2),m("ngModel",n.storeService.order().Date)("disabled",!(!(n.role==null||n.role.global==null)&&n.role.global.Date))("tooltip",!(n.role==null||n.role.global==null)&&n.role.global.Date?"":"Date role is required"),c(6),m("clearable",!0)("optionTitle",!0)("items",n.storeService.loadForm().SalesPOTypes)("selected",n.storeService.order().SalesID),c(4),m("quickKey",b(20,22,n.quickkeyService.quickkeys$))("outletID",n.storeService.outlet().ID),c(5),m("formControl",n.cartItemService.variantSearchCtrl),c(2),m("ngModel",n.storeService.customer()),c(),m("cartItems",b(28,24,n.cartItemService.cartItems$))("appConfig",(t=n.storeService.loadForm())==null?null:t.AppConfigJSON)}}var Un=class o extends rn{loadFormService=u(Ue);storeService=u(E);role=u(ge);outletService=u(je);orderService=u(se);quickkeyService=u(Qe);cartItemService=u(me);customerService=u(qe);intercomService=u(Xt);isCompleteOrder=H(()=>this.storeService.state()==3);isEditOrder=H(()=>this.storeService.state()==1);constructor(e){super(e),this.menuData$.subscribe(),this.intercomService.hideLauncher()}ngOnDestroy(){this.intercomService.showLauncher()}static \u0275fac=function(t){return new(t||o)(Q(ln))};static \u0275cmp=M({type:o,selectors:[["POS-estimate-v2"]],standalone:!0,features:[Te([E,Ue,je,se,Qe,me,qe,Be,Me,Se,De]),$t,P],decls:3,vars:2,consts:[["NOT_COMPLETE",""],["ngSelectInfinite",""],[4,"ngIf","ngIfElse"],[1,"container-fluid"],[1,"row","header","border-bottom"],[1,"col-5","border-end"],[1,"left-toolbar-container","h-100","d-flex","align-items-center","justify-content-between"],[1,"d-flex"],[3,"ngModelChange","ngModel","outlets","isOpenAfterLoad"],["transactionType","Estimate",3,"ngModelChange","ngModel","isEdit"],[3,"ngModelChange","ngModel","disabled","tooltip"],[1,"col-7","d-flex","align-items-center"],[1,"row","flex-grow-1"],[1,"col-lg-7","col-5","d-flex","align-items-center"],[3,"onAddItem"],[1,"col-5","ps-0"],["bindValue","ID","bindLabel","Name","placeholder","Assign Sales Person",1,"sales-person","select-max-width",3,"selectedChange","clearable","optionTitle","items","selected"],[1,"row","content"],[1,"col-5","border-end","pt-1"],[3,"onSelectVariant","quickKey","outletID"],[1,"col-7","pt-5","px-0","d-flex","flex-column"],[1,"row","w-100","ms-0"],[1,"col-7","px-0"],[3,"formControl"],[3,"onCreateNewCustomer","ngModelChange","onClickInput","ngModel"],[1,"cart-display",3,"onRemove","onEdit","onDropItems","onPurchase","onReturn","cartItems","appConfig"]],template:function(t,n){if(t&1&&v(0,Ri,2,0,"ng-container",2)(1,Bi,30,26,"ng-template",null,0,ce),t&2){let i=K(2);m("ngIf",n.isCompleteOrder())("ngIfElse",i)}},dependencies:[T,z,Oe,Tn,Ne,Y,ke,On,ie,ne,Cn,gn,dn,wn,_t,bt,at,mt,Dt,Mt,Pt],styles:["ng-select-infinite.sales-person.select-max-width>ng-select{padding-right:10px;height:38px} ng-select-infinite.sales-person.select-max-width>.ng-select.ng-select-single .ng-select-container{font-size:.75rem;border:.5px solid #d7d7d7;padding-right:6px} ng-select-infinite.sales-person.select-max-width>.ng-select.ng-select-single .ng-select-container>.ng-arrow-wrapper{width:12px;padding-bottom:2px} ng-select-infinite.sales-person.select-max-width>.ng-select.ng-select-single .ng-select-container>.ng-value-container{padding-left:6px} ng-select-infinite.sales-person.select-max-width>.ng-select.ng-select-single .ng-select-container{min-height:38px!important;height:38px!important;border:none} ng-select-infinite.sales-person.select-max-width.offline>.ng-select.ng-select-single .ng-select-container{background:repeating-linear-gradient(-60deg,#f8d7da,#f8d7da 15px,#f5c6cb 15px 30px)!important} ng-select-infinite.sales-person.select-max-width>.ng-select.ng-select-single .ng-select-container .ng-input{padding-left:5px!important} ng-select-infinite.sales-person.select-max-width>.ng-select.ng-select-single .ng-select-container .ng-input>input{padding-top:5px} ng-select-infinite.sales-person.select-max-width>.ng-select.ng-select-single>ng-dropdown-panel.ng-dropdown-panel{font-size:.75rem;width:95%!important} ng-select-infinite.sales-person.select-max-width>.ng-select.ng-select-focused .ng-select-container{box-shadow:none!important;border-color:transparent!important}.left-toolbar-container[_ngcontent-%COMP%]{position:relative}.left-toolbar-container[_ngcontent-%COMP%] POS-invoice-number-form[_ngcontent-%COMP%]{position:absolute;top:34px;left:28px}.header[_ngcontent-%COMP%]{min-height:60px}.content[_ngcontent-%COMP%]{min-height:calc(100vh - 60px)}.supplier-more-menu[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center}.cart-display[_ngcontent-%COMP%]{flex-grow:1;height:0px;overflow-y:auto}input[_ngcontent-%COMP%]{width:100%;height:38px!important;border:0;border-bottom:1px solid #ced4da;padding-left:32px}input[_ngcontent-%COMP%]::placeholder{color:#ced4da}i[_ngcontent-%COMP%]{font-size:16px;top:10.6px;left:13px}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]{transition:.4s}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]:nth-child(1){-webkit-transform:rotate(-45deg) translate(-8px,4px);transform:rotate(-45deg) translate(-8px,4px)}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]:nth-child(2){opacity:0}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]:nth-child(3){-webkit-transform:rotate(45deg) translate(-5px,0px);transform:rotate(45deg) translate(-5px)}.mobile-button[_ngcontent-%COMP%]{display:none}@media (max-width: 990px){.mobile-button[_ngcontent-%COMP%]{display:block}}.navbar-toggler[_ngcontent-%COMP%]:focus{box-shadow:none!important}.more-actions[_ngcontent-%COMP%] div.d-flex[_ngcontent-%COMP%]{width:30rem}"]})};export{Un as EstimateV2Component};
|
|
1
|
+
import{a as Vn}from"./chunk-2Q3IVDEZ.js";import"./chunk-YJY6KPSM.js";import{a as En}from"./chunk-KTGBECZM.js";import{a as fn}from"./chunk-TK5H65DN.js";import{a as ot}from"./chunk-B5FODXLM.js";import{a as In,b as Dn}from"./chunk-PMOAIDAQ.js";import{a as _n,b as bn,c as vn,d as rt,e as yn}from"./chunk-2PZYB6LT.js";import{a as wn,e as kn,f as Nn}from"./chunk-RA5QFXG4.js";import{a as mt}from"./chunk-GJT6AXWW.js";import{a as Tn}from"./chunk-773CYXAP.js";import"./chunk-M7GZQQXL.js";import{a as lt,b as ct,c as st}from"./chunk-WVVQJ47P.js";import{b as xn,c as at}from"./chunk-YTXHEGOU.js";import{a as Sn}from"./chunk-DQ6V5VPA.js";import"./chunk-SE7OFLAL.js";import"./chunk-X4G74GI2.js";import"./chunk-TSKFNB7J.js";import{a as Mn,b as Pn}from"./chunk-WC6HLOBJ.js";import"./chunk-ZT4UZXP6.js";import"./chunk-GWNB6CTG.js";import"./chunk-MIJSOT4W.js";import"./chunk-OWK2XW4L.js";import{a as hn}from"./chunk-DKZYNKLJ.js";import{a as An}from"./chunk-CVIX55UC.js";import{a as dn,b as gn}from"./chunk-QSD2GDAR.js";import{b as On}from"./chunk-GGVPDLR2.js";import"./chunk-TDFBRYNF.js";import{b as Cn}from"./chunk-2SKKVXLC.js";import"./chunk-RQPAYSJS.js";import"./chunk-C4SDGOBF.js";import{a as G}from"./chunk-Q7CBBXN2.js";import{a as en,c as tn,e as nn,f as on}from"./chunk-RGIAK7TL.js";import{a as _e,b as he}from"./chunk-SIEUNTYO.js";import{c as un}from"./chunk-4ECZ3YZK.js";import"./chunk-TWJFM24E.js";import{a as rn,b as ln}from"./chunk-RSNQU4HN.js";import"./chunk-VUGL7GL5.js";import"./chunk-MV3BEGPX.js";import{i as fe,j as Ce,k as oe,l as an,m as be,n as ve,o as ye,p as cn,r as sn,s as mn}from"./chunk-P3UEOU3P.js";import{Aa as nt,Ba as it,ua as Zt}from"./chunk-R5NLMT6O.js";import{a as R,b as U,o as pn}from"./chunk-ZNTHS7QL.js";import{e as Ae,f as Ve}from"./chunk-53ZY7AX4.js";import"./chunk-5ZJO3PQ6.js";import{a as Ee}from"./chunk-2FWFPV5I.js";import{C as ie,D as Ne,a as tt,c as te,h as Y,l as we,n as ne,q as Yt,r as ke}from"./chunk-7UM6XERA.js";import"./chunk-MYEH6P67.js";import{a as Xt}from"./chunk-FMIGBC5X.js";import{a as g,d as ge}from"./chunk-EQXS7YQT.js";import"./chunk-APAKUF4G.js";import{a as X}from"./chunk-A3H65TBP.js";import{$a as F,$b as L,B as Bt,Bb as A,C as O,Ca as V,Dc as H,Eb as d,G as Ut,Gb as p,Hd as Kt,J as jt,Jb as Tt,Jd as Ye,Kd as Xe,Lc as ue,Md as Ze,N as Qt,Na as He,Nc as de,Oa as ze,Ob as zt,Oc as z,Od as et,P as Lt,Pb as Gt,Qa as Ge,Qb as Jt,S as Wt,Sa as c,Ta as Q,Tc as Oe,U as $e,Ub as K,Vb as s,Wb as j,Xb as S,Xc as ee,Y as Z,Yb as Pe,Za as qt,_c as T,ac as W,ba as k,bc as q,c as Vt,cb as $t,cc as Te,dc as P,eb as v,ec as Ke,fa as N,fc as $,ib as m,j as Ft,ja as u,jb as Ht,n as Rt,na as M,nc as _,oc as b,pc as Ot,qb as Je,r as pe,tc as ce,ua as f,va as C,vb as r,wb as a,xb as y,yb as h,zb as x}from"./chunk-ZCFRJGRH.js";import{a as B,b as Et}from"./chunk-LHUGHE24.js";var pt=class{AppConfigJSON;Currencies;CustomerPOTypes;Entities;Payments;Taxes;SalesPOTypes;EstimateOptions;Data};var Fe=class{CurrencyID;CustomerID;Date;Discount;DiscountAmount;EntityID;ID;Note;Number;SalesID;TaxTypeID;TypeID;constructor(){this.CustomerID=g.GuidEmpty,this.EntityID=g.GuidEmpty,this.ID=g.GuidEmpty,this.TaxTypeID=g.GuidEmpty,this.Discount=0,this.DiscountAmount=0,this.Date=new Date().toDateString()}};var re=class{Email;Key;Mobile;Name;Phone;Value;PricebookID};var ut=class{ID;Index;Symbol;Name;ExchangeRate;ConversionSuggestion;ExchangeRateDate;ExchangeRateDateDisplay};var dt=class{ID;Name;DueDays;BlockDays;Description;PrintTemplateID;AccountID};var gt=class{DeliveryID;InvoiceID;InvoiceNumber;Message;OrderID;PaymentStateID;PaymentStateLabel;PrintMode;Success};var E=class o{estimateState=An({loadForm:new pt,outlet:{Name:"",ID:g.GuidEmpty},order:new Fe,cartItems:[],customer:new re,tax:new fn,currency:new ut,tag:new dt,discount:{discountAmount:0,discount:0},state:0,complete:new gt});loadForm=this.estimateState.select(e=>Object.freeze(e.loadForm()));order=this.estimateState.select(e=>Object.freeze(e.order()));outlet=this.estimateState.select(e=>Object.freeze(e.outlet()));cartItems=this.estimateState.select(e=>Object.freeze(e.cartItems()));customer=this.estimateState.select(e=>Object.freeze(e.customer()));tax=this.estimateState.select(e=>Object.freeze(e.tax()));currency=this.estimateState.select(e=>Object.freeze(e.currency()));tag=this.estimateState.select(e=>Object.freeze(e.tag()));discount=this.estimateState.select(e=>Object.freeze(e.discount()));state=this.estimateState.select(e=>Object.freeze(e.state()));complete=this.estimateState.select(e=>Object.freeze(e.complete()));updateLoadForm(e){this.estimateState.update("loadForm",e)}updateOutlet(e){this.estimateState.update("outlet",e)}updateOrder(e){this.estimateState.update("order",e)}updateCartItems(e){this.estimateState.update("cartItems",e)}updateCustomer(e){this.estimateState.update("customer",e)}updateTax(e){this.estimateState.update("tax",e)}updateCurrency(e){this.estimateState.update("currency",e)}updateTag(e){this.estimateState.update("tag",e)}updateDiscount(e){this.estimateState.update("discount",e)}updateState(e){this.estimateState.update("state",e)}updateComplete(e){this.estimateState.update("complete",e)}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};var xe=class{ID;Name;Code;Cost;ThumbnailUrl;CouponDiscount;Discount;DiscountAmount;EntityID;Expense;InventoryTypeID;LoyaltyPoint;Note;PromotionGift;Quantity;UnitQuantity;SalesID;VariantID;VariantUnitQuantity;isMaxInventory;UOM;UOMName;UnitCost;UnitPrice;TypeID;Storage;Taxable;Price;Serial;PriceBookID;Variant;PriceTypeID;PriceNote;get Total(){return this.Price*(this.Quantity*this.UnitQuantity)*((100-this.Discount)/100)}get getItemAfterDiscount(){let e=this.getDiscPercentagePerItem();return this.DiscountAmount<e?e-this.DiscountAmount:0}getDiscPercentagePerItem(){let e=this.UnitPrice;return this.Discount>0&&(e=(100-this.Discount)/100*this.UnitPrice),e}};var Se=class o{constructor(){}generateCartItem(e){let t=new xe;return t.Name=e.Name,t.ThumbnailUrl=e.ThumbnailUrl,t.Price=e.UnitPrice,t.UnitPrice=e.UnitPrice,t.UnitCost=e.UnitCost,t.UnitQuantity=e.UnitQuantity,t.Quantity=1,t.Code=e.Code,t.TypeID=e.TypeID,t.Discount=e.PriceDiscount,t.VariantUnitQuantity=e.VariantUnitQuantity,t.Storage=e.Storage,t.UOM=e.UOM,t.UOMName=e.UOMName,t.VariantID=e.ID,t.Taxable=e.Taxable,t.InventoryTypeID=e.TypeID,t.PriceTypeID=e.PriceTypeID,t.PriceNote=e.PriceNote,t.Variant=e,t}generateCartItemOnEdit(e){let t=new xe;return t.ID=e.ID,t.Name=e.Variant?.Name,t.ThumbnailUrl=e.Variant?.ThumbnailUrl,t.Price=e.Price,t.UnitPrice=e.Price,t.UnitCost=e.Cost,t.UnitQuantity=e.Variant?.UnitQuantity,t.Quantity=e.Quantity,t.Code=e.Variant?.Code,t.TypeID=e.Variant?.TypeID,t.Discount=e.Discount,t.VariantUnitQuantity=e.Variant?.VariantUnitQuantity,t.Storage=e.Variant?.Storage,t.UOM=e.Variant?.UOM,t.UOMName=e.Variant?.UOMName,t.VariantID=e.VariantID,t.Taxable=e.Taxable,t.Note=e.Note,t.Serial=e.Serial,t.InventoryTypeID=e.InventoryTypeID,t.PriceTypeID=e.PriceTypeID,t.Variant=e.Variant,t.PriceNote=e.PriceNote,t}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};var Ue=class o{httpService=u(X);storeService=u(E);factoryService=u(Se);activatedRoute=u(Kt);getLoadForm$=this.activatedRoute.queryParams.pipe(Z(e=>this.httpService.post("/API/estimate/LoadForm",e)),k(e=>this.storeService.updateLoadForm(e)),k(e=>{g.IsNotEmpty(e.Data)?this.onEditOrder(e):(this.initDefaultCurrency(),this.initTag(),this.initTax())}),R());constructor(){this.getLoadForm$.subscribe()}onEditOrder(e){let t=e.Data,n=this.findTaxById(t.Order.TaxTypeID),i=this.findCurrencyById(t.Order.CurrencyID),l=this.findOutletById(t.Order.EntityID),I=this.findTagById(t.Order.TypeID),D=this.getCartItemsOnEdit(e);this.storeService.updateState(1),this.storeService.updateOrder(t.Order),this.storeService.updateCartItems(D),this.storeService.updateCustomer({Key:t.Order.CustomerID,Value:t.ContactName}),this.storeService.updateTax(n),this.storeService.updateCurrency(i),this.storeService.updateOutlet(l),this.storeService.updateDiscount({discount:t.Order.Discount,discountAmount:t.Order.DiscountAmount}),this.storeService.updateTag(I)}getCartItemsOnEdit(e){return e.Data.Items.map(i=>this.factoryService.generateCartItemOnEdit(i))}initDefaultCurrency(){let e=this.storeService.loadForm()?.AppConfigJSON?.CoreDefaults?.CurrencyID,t=this.storeService.loadForm()?.Currencies.find(n=>n.ID===e);this.storeService.updateCurrency(t)}initTag(){let e=this.storeService.loadForm()?.CustomerPOTypes;this.storeService.updateTag(e[0])}initTax(){let e=this.storeService.loadForm()?.Taxes;this.storeService.updateTax(e[0])}findTaxById(e){return(this.storeService.loadForm()?.Taxes).find(i=>i.ID===e)}findCurrencyById(e){return(this.storeService.loadForm()?.Currencies).find(i=>i.ID===e)}findOutletById(e){return(this.storeService.loadForm()?.Entities).find(i=>i.ID===e)}findTagById(e){return(this.storeService.loadForm()?.CustomerPOTypes).find(i=>i.ID===e)}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};var je=class o{storeService=u(E);isOpenDialog$=U(this.storeService.loadForm).pipe(O(e=>g.IsNotEmpty(e.Entities)),pe(()=>{let e=!1,t=this.storeService.state(),n=this.storeService.outlet();return(t==0||t==1)&&(e=g.IsEmpty(n.ID)),e}));updateOutlet(e){this.storeService.updateOutlet(e)}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac,providedIn:"root"})};var se=class o{storeService=u(E);httpService=u(X);router=u(Ye);orderNumber$=U(this.storeService.outlet).pipe(O(e=>g.IsNotEmpty(e.ID)),Z(e=>{if(this.storeService.state()==0)return this.httpService.post(G.EstimateGenerateNumber,{ID:e.ID}).pipe(pe(t=>t.Number));{let t=this.storeService.order().Number;return Rt(t)}}),k(e=>{this.storeService.state()==0&&this.updateOrderNumber(e)}),R());updateTagOrder$=U(this.storeService.tag).pipe(k(e=>{let t=B({},this.storeService.order());t.TypeID=e.ID,this.storeService.updateOrder(t)}),R());updateCurrencyOrder$=U(this.storeService.currency).pipe(k(e=>{let t=B({},this.storeService.order());t.CurrencyID=e.ID,this.storeService.updateOrder(t)}),R());updateTaxOrder$=U(this.storeService.tax).pipe(k(e=>{let t=B({},this.storeService.order());t.TaxTypeID=e.ID,this.storeService.updateOrder(t)}),R());updateDiscountOrder$=U(this.storeService.discount).pipe(k(e=>{let t=B({},this.storeService.order());t.Discount=e.discount,t.DiscountAmount=e.discountAmount,this.storeService.updateOrder(t)}),R());updateCustomerOrder$=U(this.storeService.customer).pipe(k(e=>{let t=B({},this.storeService.order());t.CustomerID=e.Key,this.storeService.updateOrder(t)}),R());updateEntityId$=U(this.storeService.outlet).pipe(O(e=>g.IsNotEmpty(e.ID)),k(e=>{let t=B({},this.storeService.order());t.EntityID=e.ID,this.storeService.updateOrder(t)}),R());constructor(){this.updateTagOrder$.subscribe(),this.updateCurrencyOrder$.subscribe(),this.updateTaxOrder$.subscribe(),this.updateDiscountOrder$.subscribe(),this.updateCustomerOrder$.subscribe(),this.updateEntityId$.subscribe()}newOrder(){let e=this.storeService.loadForm(),t=this.getDefaultCurrency(),n=this.storeService.outlet();this.storeService.updateOrder(new Fe),this.storeService.updateCartItems([]),this.storeService.updateCustomer(new re),this.storeService.updateTax(B({},e.Taxes[0])),this.storeService.updateCurrency(B({},t)),this.storeService.updateTag(B({},e.CustomerPOTypes[0])),this.storeService.updateDiscount({discountAmount:0,discount:0}),this.storeService.updateOutlet(B({},n)),this.router.navigate([],{queryParams:{}}),this.storeService.updateState(0)}getDefaultCurrency(){let e=this.storeService.loadForm()?.AppConfigJSON?.CoreDefaults?.CurrencyID;return this.storeService.loadForm()?.Currencies.find(n=>n.ID===e)}updateOrderNumber(e){g.IsNotEmpty(e)&&this.storeService.order().Number!==e&&this.storeService.updateOrder(Et(B({},this.storeService.order()),{Number:e}))}updateOrderDate(e){g.IsNotEmpty(e)&&this.storeService.order().Date!==e&&this.storeService.updateOrder(Et(B({},this.storeService.order()),{Date:e}))}updateSalesPersonId(e){let t=B({},this.storeService.order());t.SalesID=e,this.storeService.updateOrder(t)}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};var Qe=class o{storeService=u(E);httpService=u(X);quickkeys$=U(this.storeService.outlet).pipe(O(e=>g.IsNotEmpty(e.ID)),Qt((e,t)=>e.ID===t.ID),Z(e=>this.httpService.get(G.GetQuickKeyByEntityID,[{key:"ID",value:e.ID}])),$e(1));static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};var Fn=o=>({"qtyBtn-disabled":o}),ft=class o{disabled=!1;decimalPlaces=4;max=1e15;min=-1e15;quantity;constructor(){}ngOnInit(){}incrementQty(){this.quantity<this.max&&(this.quantity++,this.onChange(this.quantity))}decrementQty(){this.quantity>this.min&&(this.quantity--,this.onChange(this.quantity))}quantityChange(){this.onChange(this.quantity)}onChange=e=>{};onTouched=()=>{};writeValue(e){g.IsEmpty(e)?this.quantity=0:this.quantity=e}registerOnChange(e){this.onChange=e}registerOnTouched(e){this.onTouched=e}setDisabledState(e){}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["POS-input-quantity"]],inputs:{disabled:"disabled",decimalPlaces:"decimalPlaces",max:"max",min:"min"},standalone:!0,features:[Te([{provide:tt,multi:!0,useExisting:o}]),P],decls:6,vars:11,consts:[[1,"input-group"],["type","button","id","button-addon1",1,"btn","btn-outline-secondary","fw-bold","rounded-0","fs-2","border-end-0","py-4","qty-input","d-flex","align-items-center","qty_btn","justify-content-center",3,"click","ngClass","disabled"],["id","txtCartQuantity","type","text","autoNum","",1,"form-control","input-numpad","qty-input","text-center",3,"ngModelChange","ngModel","disabled","decimalPlaces"],["type","button","id","button-addon2",1,"btn","btn-outline-secondary","fw-bold","rounded-0","fs-5","border-start-0","py-4","qty-input","d-flex","align-items-center","qty_btn","justify-content-center",3,"click","ngClass","disabled"]],template:function(t,n){t&1&&(r(0,"div",0)(1,"button",1),d("click",function(){return n.decrementQty()}),s(2,"-"),a(),r(3,"input",2),q("ngModelChange",function(l){return W(n.quantity,l)||(n.quantity=l),l}),d("ngModelChange",function(){return n.quantityChange()}),a(),r(4,"button",3),d("click",function(){return n.incrementQty()}),s(5,"+"),a()()),t&2&&(c(),m("ngClass",$(7,Fn,n.disabled))("disabled",n.disabled),c(2),L("ngModel",n.quantity),m("disabled",n.disabled)("decimalPlaces",n.decimalPlaces),c(),m("ngClass",$(9,Fn,n.disabled))("disabled",n.disabled))},dependencies:[T,ue,ie,te,Y,ne,_e,he],styles:[".qtyBtn-disabled[_ngcontent-%COMP%]{background-color:#e9ecef;color:#000!important}button.qty_btn[_ngcontent-%COMP%]{background:#eee;border:1px solid #ddd;width:36px}.qty-input[_ngcontent-%COMP%]{height:36px!important}"]})};var De=class o{storeService=u(E);autoApplyPricebook(e){let t=e?.Variant?.PriceBook?e?.Variant?.PriceBook:[],n=this.storeService.customer(),i=this.findCustomerPricebook(t,n),l=this.sortAppliedPricebooks(t,e.Quantity);return l.length>0||g.IsNotEmpty(i)?g.IsNotEmpty(i)?e=this.applyPricebook(e,i):e=this.applyPricebook(e,l[0]):e.PriceTypeID===2&&(e=this.removePricebook(e)),e}findCustomerPricebook(e=[],t){let n;return g.IsNotEmpty(t)&&g.IsNotEmpty(t?.Key)&&(n=e.find(i=>i.ID==t.PricebookID)),n}applyCustomerPricebook(){let e=[],t=this.storeService.customer(),n=this.storeService.cartItems();return g.IsNotEmpty(t.PricebookID)&&n.forEach(i=>{let l=this.findCustomerPricebook(i.Variant.PriceBook,t);l&&(i=this.applyPricebook(i,l),e.push(i))}),e}removeCustomerPricebook(e){let t=[];return this.storeService.cartItems().forEach(i=>{this.findCustomerPricebook(i.Variant.PriceBook,e)&&(i=this.removePricebook(i),t.push(i))}),t}sortAppliedPricebooks(e=[],t){return e.sort((n,i)=>i.MinimumQuantity-n.MinimumQuantity).filter(n=>t>=n.MinimumQuantity&&n.MinimumQuantity!=0)}applyPricebook(e,t){let n=this.storeService.loadForm()?.AppConfigJSON?.ModuleSell?.Pricebook?.PricebookVisible;return e.Discount=t.PriceDiscount,e.UnitPrice=t.UnitPrice,e.PriceBookID=t.ID,e.Price=t.UnitPrice,e.PriceTypeID=2,e.PriceNote=t.Name,n?e.Note=t.Name:e.Note="",e}removePricebook(e){return e.Discount=e.Variant.PriceDiscount,e.UnitPrice=e.Variant.UnitPrice,e.PriceBookID=null,e.Price=e.Variant.UnitPrice,e.PriceTypeID=0,e.Note="",e.PriceNote="",e}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};var At=o=>({selected:o}),Qn=()=>["/menu/Products/Catalog/Variants/Info"],Ln=o=>({ID:o});function Wn(o,e){if(o&1){let t=A();h(0),r(1,"a",10),d("click",function(){f(t);let i=p();return C(i.tabState="PRODUCT")}),s(2," Product "),a(),x()}if(o&2){let t=p();c(),m("ngClass",$(1,At,t.tabState=="PRODUCT"))}}function qn(o,e){if(o&1){let t=A();h(0),r(1,"a",11),d("click",function(){f(t);let i=p();return C(i.tabState="SERIAL")}),s(2," Serial "),a(),x()}if(o&2){let t=p();c(),m("ngClass",$(1,At,t.tabState=="SERIAL"))}}function $n(o,e){if(o&1&&(h(0),r(1,"div",12)(2,"div",21),y(3,"POS-variant-autocomplete",22),a()(),x()),o&2){let t=p(2);c(3),m("formControl",t.variantSearchCtrl)}}function Hn(o,e){if(o&1&&(r(0,"span"),s(1),a()),o&2){let t=p(2);c(),S("(",t.cartItem().UOMName,")")}}function zn(o,e){if(o&1){let t=A();r(0,"div",15)(1,"h6"),s(2,"Pricebook"),a(),r(3,"ng-select",23),q("ngModelChange",function(i){f(t);let l=p(2);return W(l.cartItem().PriceBookID,i)||(l.cartItem().PriceBookID=i),C(i)}),d("ngModelChange",function(i){f(t);let l=p(2);return C(l.onSelectPricebook(i))}),a()()}if(o&2){let t,n=p(2);c(3),m("items",(t=n.cartItem())==null||t.Variant==null?null:t.Variant.PriceBook),L("ngModel",n.cartItem().PriceBookID)}}function Gn(o,e){if(o&1){let t=A();h(0),v(1,$n,4,1,"ng-container",8),r(2,"div",12)(3,"div",13)(4,"h6"),s(5," Qty "),v(6,Hn,2,1,"span",8),a(),r(7,"POS-input-quantity",14,0),q("ngModelChange",function(i){f(t);let l=p();return W(l.cartItem().Quantity,i)||(l.cartItem().Quantity=i),C(i)}),d("ngModelChange",function(){f(t);let i=p();return C(i.onQtyChange())}),a()(),r(9,"div",15)(10,"h6"),s(11,"Discount (%)"),a(),r(12,"input",16),q("ngModelChange",function(i){f(t);let l=p();return W(l.cartItem().Discount,i)||(l.cartItem().Discount=i),C(i)}),a()(),r(13,"div",15)(14,"h6"),s(15,"Price"),a(),r(16,"input",17,1),q("ngModelChange",function(i){f(t);let l=p();return W(l.cartItem().Price,i)||(l.cartItem().Price=i),C(i)}),a()(),v(18,zn,4,2,"div",15),a(),r(19,"div",18)(20,"div",19)(21,"POS-tinymce-editor",20),q("valueChange",function(i){f(t);let l=p();return W(l.cartItem().Note,i)||(l.cartItem().Note=i),C(i)}),a()()(),x()}if(o&2){let t,n=p();c(),m("ngIf",n.isEditState()==!1),c(5),m("ngIf",n.cartItem().UOMName),c(),L("ngModel",n.cartItem().Quantity),m("decimalPlaces",n.isSerialItem?0:4),c(5),L("ngModel",n.cartItem().Discount),c(4),L("ngModel",n.cartItem().Price),m("disabled",!(!(n.roleService==null||n.roleService.sell==null)&&n.roleService.sell.UnitPriceEditor)),c(2),Je(((t=n.cartItem().Variant)==null||t.PriceBook==null?null:t.PriceBook.length)>0?18:-1),c(3),L("value",n.cartItem().Note)}}function Jn(o,e){o&1&&(h(0),y(1,"i",42),r(2,"h6"),s(3,"No Image"),a(),x())}function Kn(o,e){if(o&1&&y(0,"img",43),o&2){let t=p(2);m("src",t.cartItem().ThumbnailUrl,ze)}}function Yn(o,e){if(o&1&&(h(0),r(1,"tr")(2,"td",44),s(3),_(4,"number"),a(),r(5,"td",44),s(6),_(7,"number"),a(),r(8,"td",44),s(9),_(10,"number"),a()(),x()),o&2){let t=e.ngIf;c(3),S(" ",b(4,3,t==null?null:t.OnHand)," "),c(3),S(" ",b(7,5,t==null?null:t.Allocated)," "),c(3),S(" ",b(10,7,(t==null?null:t.OnHand)-(t==null?null:t.Allocated))," ")}}function Xn(o,e){if(o&1){let t=A();r(0,"tr")(1,"th",39),s(2,"Cost"),a(),r(3,"td",45)(4,"input",46),q("ngModelChange",function(i){f(t);let l=p(2);return W(l.cartItem().UnitCost,i)||(l.cartItem().UnitCost=i),C(i)}),a()()()}if(o&2){let t,n=p(2);c(4),L("ngModel",n.cartItem().UnitCost),m("readonly",!(!((t=n.appConfig())==null||t.ModuleSell==null)&&t.ModuleSell.Cost.Enabled))}}function Zn(o,e){if(o&1&&(r(0,"tr")(1,"th",39),s(2,"Content"),a(),r(3,"td",40)(4,"div",47),s(5),_(6,"number"),a()()()),o&2){let t,n=p(2);c(5),Pe(" ",(t=n.cartItem())==null?null:t.VariantUnitQuantity," (@",b(6,2,n.cartItem().Price/((t=n.cartItem())==null?null:t.VariantUnitQuantity)),")")}}function ei(o,e){if(o&1&&(r(0,"div",37)(1,"table",48)(2,"thead")(3,"tr")(4,"th",49),s(5,"Storage Location"),a()()(),r(6,"tbody")(7,"tr")(8,"td"),s(9),a()()()()()),o&2){let t=p(2);c(9),S(" ",t.cartItem().Storage," ")}}function ti(o,e){if(o&1&&(h(0),r(1,"div",24)(2,"div",25)(3,"a",26),v(4,Jn,4,0,"ng-container",27)(5,Kn,1,1,"ng-template",null,2,ce),a()(),r(7,"div",28)(8,"div",29)(9,"div",19)(10,"div",30),y(11,"i",31),r(12,"div",32),s(13,"Inventory"),a()(),r(14,"table",33)(15,"thead")(16,"tr")(17,"th",34),s(18,"On Hand"),a(),r(19,"th",34),s(20,"Allocated"),a(),r(21,"th",35),s(22,"Available"),a()()(),r(23,"tbody"),v(24,Yn,11,9,"ng-container",8),_(25,"async"),a()()()(),r(26,"div",36)(27,"div",37)(28,"table",38)(29,"thead"),v(30,Xn,5,2,"tr",8),r(31,"tr")(32,"th",39),s(33,"Price"),a(),r(34,"td",40),s(35),_(36,"number"),a()(),v(37,Zn,7,4,"tr",8),a()()(),v(38,ei,10,1,"div",41),a()()(),x()),o&2){let t,n,i,l,I,D,ae=K(6),le=p();c(3),m("routerLink",Ke(13,Qn))("queryParams",$(14,Ln,(t=le.cartItem())==null?null:t.ID)),c(),m("ngIf",((n=le.cartItem())==null?null:n.ThumbnailUrl)==null)("ngIfElse",ae),c(20),m("ngIf",b(25,9,le.variantInventory$)),c(6),m("ngIf",((i=le.appConfig())==null||i.ModuleSell==null?null:i.ModuleSell.Cost.Visible)&&le.roleService.product.Cost),c(5),S(" ",b(36,11,(l=le.cartItem())==null?null:l.Price)," "),c(2),m("ngIf",((I=le.cartItem())==null?null:I.VariantUnitQuantity)>1),c(),m("ngIf",((D=le.appConfig())==null||D.ModuleSell==null||D.ModuleSell.Grid==null?null:D.ModuleSell.Grid.StorageVisible)&&((D=le.cartItem())==null?null:D.Storage))}}function ni(o,e){if(o&1){let t=A();h(0),r(1,"app-item-serial",50),d("cartItemChange",function(i){f(t);let l=p();return C(l.onSerialChanges(i))}),a(),x()}if(o&2){let t=p();c(),m("entityId",t.storeService.outlet().ID)("cartItem",t.cartItem())}}var We=class o{constructor(e,t){this.data=e;this.dialogRef=t;this.cartItem=F(e),this.initVariantInventory(),this.initIsSerialItem(),this.initModalConfig(),this.initDialogState()}storeService=u(E);cartItemService=u(me);roleService=u(ge);toastr=u(et);pricebookService=u(De);modalConfig=new be;tabState="CART";cartItem;appConfig=F(this.storeService.loadForm()?.AppConfigJSON);isSerialItem=F(!1);variantInventory$;isEditState=F(!1);showProductTab=F(!1);variantSearchCtrl=new we;getItemFromSearch$=this.variantSearchCtrl.valueChanges.pipe(O(e=>g.IsNotEmpty(e)),Z(e=>{if(e.type==="ID")return this.cartItemService.getItemByVariantId(e.str);if(e.type==="Code")return this.cartItemService.getItemByVariantByCode(e.str)}),k(e=>{this.cartItem.set(e),this.initModalTitle(),this.initProductTab(),this.initIsSerialItem(),this.initVariantInventory()}),R());ngOnInit(){this.isEditState()||this.getItemFromSearch$.subscribe()}initDialogState(){this.isEditState.set(g.IsNotEmpty(this.cartItem().VariantID)),this.initProductTab()}initVariantInventory(){this.variantInventory$=this.cartItemService.getVariantInventory(this.cartItem().VariantID).pipe($e(1))}initProductTab(){this.showProductTab.set(g.IsNotEmpty(this.cartItem().VariantID))}initIsSerialItem(){this.isSerialItem.set(this.cartItem().TypeID==4)}initModalConfig(){this.initModalTitle(),this.modalConfig.customWidth="680px",this.modalConfig.noPadding=!0,this.modalConfig.bodyScrollable=!0}initModalTitle(){this.modalConfig.title=this.cartItem()?.Name??"Add Variant"}onSerialChanges(e){this.cartItem.set(e)}onQtyChange(){let e=this.pricebookService.autoApplyPricebook(this.cartItem());this.cartItem.set(e)}onSelectPricebook(e){let t;if(g.IsNotEmpty(e)){let i=this.cartItem().Variant.PriceBook.find(l=>l.ID===e);t=this.pricebookService.applyPricebook(this.cartItem(),i)}else t=this.pricebookService.removePricebook(this.cartItem());this.cartItem.set(t)}onCancel(){this.dialogRef.close()}onSave(){g.IsNotEmpty(this.cartItem().VariantID)&&g.IsNotEmpty(this.cartItem().Name)?this.dialogRef.close(this.cartItem()):this.toastr.warning("Please select a product","Warning")}static \u0275fac=function(t){return new(t||o)(Q(Ce),Q(fe))};static \u0275cmp=M({type:o,selectors:[["app-dialog-item"]],standalone:!0,features:[P],decls:13,vars:9,consts:[["quantity",""],["price",""],["SHOW_IMAGE",""],[3,"onOk","onCancel","onClose","config"],[1,"mb-5"],[1,"container","w-100","h-100","mt-8"],[1,"row","border-bottom","mx-5"],["data-cy","input_sell",1,"btn","btn-link",3,"click","ngClass"],[4,"ngIf"],[1,"mx-8"],["data-cy","product",1,"btn","btn-link",3,"click","ngClass"],["data-cy","serial",1,"btn","btn-link",3,"click","ngClass"],[1,"row","mt-8"],[1,"col-auto","pe-0",2,"width","145px"],[3,"ngModelChange","ngModel","decimalPlaces"],[1,"col-auto","pe-0"],["type","text","percentage","","autoNum","",1,"form-control","input-cart",2,"width","100px",3,"ngModelChange","ngModel"],["id","inputPrice","type","text","autoNum","",1,"form-control","input-cart",2,"width","112px",3,"ngModelChange","ngModel","disabled"],[1,"row","my-6"],[1,"col-12"],["height","220px",3,"valueChange","value"],[1,"col-12","px-0"],[3,"formControl"],["bindLabel","Name","bindValue","ID","placeholder","Pricebook","appendTo","body",2,"width","170px",3,"ngModelChange","items","ngModel"],[1,"row","my-8"],[1,"col-sm-4","d-flex","justify-content-center","flex-column","align-items-center","text-body-secondary"],["target","_blank",2,"color","inherit",3,"routerLink","queryParams"],[4,"ngIf","ngIfElse"],[1,"col-sm-8","inventory"],[1,"row","mb-8"],[1,"d-flex"],["aria-hidden","true",1,"fa-archive","fa-solid","fa-1x","pt-3","pe-2"],[2,"font-size","15px","font-family","'Roboto Slab'"],[1,"table","table-bordered","text-center","inventory-table"],[1,"table-light","py-6","border-end",2,"text-transform","none"],[1,"table-light","py-6",2,"text-transform","none"],[1,"row"],[1,"col-6"],[1,"table","table-bordered",2,"width","171px"],[1,"table-light",2,"text-transform","none"],[1,"pe-6","text-end"],["class","col-6",4,"ngIf"],["aria-hidden","true",1,"fa-solid","fa-image","fa-5x"],[1,"border","rounded",3,"src"],[1,"py-6"],[1,"p-0"],["type","text","autoNum","",1,"form-control","border-0","bg-white","text-end",3,"ngModelChange","ngModel","readonly"],["ngClass","ms-3"],[1,"table","table-bordered","text-center"],[1,"table-light"],[3,"cartItemChange","entityId","cartItem"]],template:function(t,n){t&1&&(r(0,"modal-material",3),d("onOk",function(){return n.onSave()})("onCancel",function(){return n.onCancel()})("onClose",function(){return n.onCancel()}),r(1,"content",4)(2,"div",5)(3,"div",6)(4,"div")(5,"a",7),d("click",function(){return n.tabState="CART"}),s(6," Cart "),a(),v(7,Wn,3,3,"ng-container",8)(8,qn,3,3,"ng-container",8),a()(),r(9,"div",9),v(10,Gn,22,9,"ng-container",8)(11,ti,39,16,"ng-container",8)(12,ni,2,2,"ng-container",8),a()()()()),t&2&&(m("config",n.modalConfig),c(5),m("ngClass",$(7,At,n.tabState=="CART")),c(2),m("ngIf",n.showProductTab()),c(),m("ngIf",n.isSerialItem()),c(2),m("ngIf",n.tabState=="CART"),c(),m("ngIf",n.tabState=="PRODUCT"),c(),m("ngIf",n.tabState=="SERIAL"))},dependencies:[T,ue,z,Oe,ee,ye,ve,Sn,ie,te,Y,ne,_e,he,Pn,Mn,Ze,Xe,mt,Ne,ke,Dn,In,ft,Ve,Ae],styles:[".bg-light-gray[_ngcontent-%COMP%]{background-color:var(--bs-light-gray);--bs-bg-opacity: .15 !important}.bg-gradient-danger[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#f8d7da,#f8d7da 15px,#f5c6cb 15px 30px)!important}.bg-gradient-success[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#beeebb,#beeebb 15px,#afeba8 15px 30px)!important}.bg-gradient-warning[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#fcf3cf,#fcf3cf 15px,#f9e79f 15px 30px)!important}.bg-light-orange[_ngcontent-%COMP%]{background-color:var(--bs-light-orange);--bs-bg-opacity: .15 !important}.text-danger[_ngcontent-%COMP%]{color:#fb404b!important}.text-dark[_ngcontent-%COMP%]{color:#5e5e5e!important}.text-success[_ngcontent-%COMP%]{color:#87cb16!important}.text-black[_ngcontent-%COMP%]{color:#000!important}.text-white[_ngcontent-%COMP%]{color:var(--bs-white)!important}.btn-light-blue[_ngcontent-%COMP%]{color:#212529;background-color:#dfeffc!important;border-color:#dfeffc}.btn-light-blue[_ngcontent-%COMP%]:hover{color:#212529;background-color:#bcdef9;border-color:#b0d8f8}.btn-light-blue[_ngcontent-%COMP%]:focus, .btn-light-blue.focus[_ngcontent-%COMP%]{color:#212529;background-color:#bcdef9;border-color:#b0d8f8;box-shadow:0 0 0 .2rem #c3d1dc80}.btn-light-blue.disabled[_ngcontent-%COMP%], .btn-light-blue[_ngcontent-%COMP%]:disabled{color:#212529;background-color:#dfeffc;border-color:#dfeffc}.btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active, .btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active, .show[_ngcontent-%COMP%] > .btn-light-blue.dropdown-toggle[_ngcontent-%COMP%]{color:#212529;background-color:#b0d8f8;border-color:#a5d2f7}.btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active:focus, .btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active:focus, .show[_ngcontent-%COMP%] > .btn-light-blue.dropdown-toggle[_ngcontent-%COMP%]:focus{box-shadow:0 0 0 .2rem #c3d1dc80}.inventory-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%], .inventory-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{line-height:6px!important}.btn-link[_ngcontent-%COMP%]{padding-top:0;color:#868686;padding-bottom:8px;border-radius:unset;font-family:Roboto Slab,serif}.btn-link.selected[_ngcontent-%COMP%]{color:#3b3b3b;border-bottom:4px solid #07a519}.input-cart[_ngcontent-%COMP%]{height:36px!important}"]})};var Ct=class o{constructor(e,t){this.data=e;this.dialogRef=t;this.modalConfig=new be,this.modalConfig.title=e.title,this.modalConfig.headerType=e.headerType}modalConfig;onOk(){this.dialogRef.close(!0)}onClose(){this.dialogRef.close(!1)}static \u0275fac=function(t){return new(t||o)(Q(Ce),Q(fe))};static \u0275cmp=M({type:o,selectors:[["app-confirmation-modal"]],standalone:!0,features:[P],decls:4,vars:2,consts:[[3,"onClose","onCancel","onOk","config"],[1,"container-fluid","modal-info"],[3,"innerHTML"]],template:function(t,n){t&1&&(r(0,"modal-material",0),d("onClose",function(){return n.onClose()})("onCancel",function(){return n.onClose()})("onOk",function(){return n.onOk()}),r(1,"content")(2,"div",1),y(3,"div",2),a()()()),t&2&&(m("config",n.modalConfig),c(3),m("innerHTML",n.data==null?null:n.data.message,He))},dependencies:[an,T,ye,ve],styles:[".modal-info[_ngcontent-%COMP%] .empty-state-img[_ngcontent-%COMP%]{width:100px}.modal-info[_ngcontent-%COMP%] .img-1x[_ngcontent-%COMP%]{width:12rem}.modal-info[_ngcontent-%COMP%] .img-2x[_ngcontent-%COMP%]{width:10rem}.modal-info[_ngcontent-%COMP%] .img-3x[_ngcontent-%COMP%]{width:8rem}"]})};var me=class o{httpService=u(X);storeService=u(E);factoryService=u(Se);pricebookService=u(De);dialog=u(oe);variantSearchCtrl=new we;viewContainerRef=u(qt);selectedCustomer;cartItemEvent=new Vt;onEditCartItems$=U(this.storeService.cartItems).pipe(O(()=>this.storeService.state()==1),pe(e=>({action:"INIT",items:e})),Lt());applyCustomerPricebook$=U(this.storeService.customer).pipe(k(e=>{this.onApplyCustomerPricebook(e)}),R());cartItems$=Bt(this.onEditCartItems$,this.cartItemEvent.asObservable()).pipe(Wt((e,t)=>{let n=[];switch(t.action){case"INIT":n=t.items;break;case"ADD":n=this.addNewItem(e,t);break;case"UPDATE":n=this.updateItems(e,t);break;case"REMOVE":n=e.filter((i,l)=>t.index!==l);break;case"CLEAR":n=[];break;case"PURCHASE":n=this.updateItems(e,t);break;case"RETURN":n=this.updateItems(e,t);break;case"DROP":n=t.items;break}return this.storeService.updateCartItems(n),n},this.storeService.cartItems()));addCartItemBySearch$=this.variantSearchCtrl.valueChanges.pipe(O(e=>g.IsNotEmpty(e)),k(e=>{e.type==="ID"?this.addItemByVariantId(e.str):e.type==="Code"&&this.addItemByVariantCode(e.str)}),R());constructor(){this.addCartItemBySearch$.subscribe(),this.applyCustomerPricebook$.subscribe()}onApplyCustomerPricebook(e){let t=[],n=this.storeService.cartItems();g.IsNotEmpty(e.PricebookID)?(this.selectedCustomer=e,t=this.pricebookService.applyCustomerPricebook()):g.IsNotEmpty(this.selectedCustomer)&&(t=this.pricebookService.removeCustomerPricebook(this.selectedCustomer),this.selectedCustomer=null),n.forEach((i,l)=>{let I=t.find(D=>D.VariantID===i.VariantID);I&&this.updateCartItem({cartItem:I,index:l})})}onApplyPricebook(e){return this.pricebookService.autoApplyPricebook(e)}onOpenAddDialog(){this.dialog.open(We,{data:new xe,viewContainerRef:this.viewContainerRef}).afterClosed().pipe(O(e=>g.IsNotEmpty(e))).subscribe(e=>{this.cartItemEvent.next({item:e,action:"ADD",newRow:!0})})}onOpenEditDialog(e){this.dialog.open(We,{data:B({},e.cartItem),viewContainerRef:this.viewContainerRef}).afterClosed().pipe(O(t=>g.IsNotEmpty(t))).subscribe(t=>{this.cartItemEvent.next({item:t,action:"UPDATE",index:e.index})})}onSelectQuickkeyItem(e){this.addItemByVariantId(e)}addNewItem(e,t){let n=[],i=e.find(l=>l.VariantID===t.item?.VariantID);return i?t.newRow?(t.item=this.onApplyPricebook(t.item),n=[...e,t.item]):(i.Quantity+=1,i=this.onApplyPricebook(i),n=[...e]):(t.item=this.onApplyPricebook(t.item),n=[...e,t.item]),n}updateItems(e,t){return e.map((i,l)=>l===t.index?pn(xe,t.item):i)}onDropItems(e){this.cartItemEvent.next({action:"DROP",items:e})}addItemByVariantId(e){this.getItemByVariantId(e).pipe(k(t=>{this.cartItemEvent.next({item:t,action:"ADD",newRow:!1})})).subscribe()}addItemByVariantCode(e){this.getItemByVariantByCode(e).pipe(k(t=>{this.cartItemEvent.next({item:t,action:"ADD",newRow:!1})})).subscribe()}removeCartItem(e){this.cartItemEvent.next({action:"REMOVE",index:e.index})}updateCartItem(e){this.cartItemEvent.next({action:"UPDATE",item:e.cartItem,index:e.index})}clearCart(){this.dialog.open(Ct,{data:{title:"Clear Order Items",message:'<p class="h4">Are you sure you want to clear all order items?</p>',headerType:Ee.Warning}}).afterClosed().pipe(O(e=>e)).subscribe(()=>{this.cartItemEvent.next({action:"CLEAR"})})}onPurchaseItem(e){this.cartItemEvent.next({action:"PURCHASE",item:e.cartItem,index:e.index})}onReturnItem(e){this.cartItemEvent.next({action:"RETURN",item:e.cartItem,index:e.index})}getItemByVariantId(e){return this.httpService.get(G.GetVariantByID,[{key:"ID",value:e},{key:"EntityID",value:this.storeService.outlet().ID}]).pipe(pe(t=>this.factoryService.generateCartItem(t)))}getItemByVariantByCode(e){return this.httpService.get(G.GetVariantByCode,[{key:"Code",value:e},{key:"EntityID",value:this.storeService.outlet().ID},{key:"Promotion",value:!0}]).pipe(pe(t=>this.factoryService.generateCartItem(t)))}getVariantInventory(e){return this.httpService.get(G.GetVariantStockByID,[{key:"EntityID",value:this.storeService.outlet().ID},{key:"ID",value:e}])}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};function ii(o,e){if(o&1&&(r(0,"td",29),s(1),a()),o&2){let t=p().index;c(),S(" ",t+1,". ")}}function oi(o,e){if(o&1&&(h(0),r(1,"div",30),y(2,"img",31),a(),x()),o&2){let t=p().$implicit;c(2),m("src",t.ThumbnailUrl,ze)}}function ri(o,e){o&1&&(r(0,"div",32),y(1,"i",33),a())}function ai(o,e){if(o&1&&y(0,"small",16),o&2){let t=p().$implicit;m("innerHtml",t.Note,He)}}function li(o,e){if(o&1&&(h(0),r(1,"span",24),s(2),_(3,"number"),a(),x()),o&2){let t=p().$implicit;c(2),j(Ot(3,1,t.Quantity,"1.0-4"))}}function ci(o,e){if(o&1&&(h(0),r(1,"span",34),s(2,"x"),a(),r(3,"div",35)(4,"span",36),s(5),_(6,"number"),a()(),x()),o&2){let t=p().$implicit;c(5),j(b(6,1,t.UnitQuantity))}}function si(o,e){if(o&1&&(h(0),r(1,"span",37),s(2),_(3,"number"),a(),x()),o&2){let t=p().$implicit;c(2),S("@",b(3,1,t.VariantUnitQuantity),"")}}function mi(o,e){if(o&1&&(h(0),r(1,"small",38),s(2),a(),x()),o&2){let t=p().$implicit;c(2),j(t.UOM?t==null?null:t.UOMName:"")}}function pi(o,e){if(o&1&&(h(0),r(1,"div",39),s(2),_(3,"number"),a(),x()),o&2){let t=p().$implicit;c(2),S(" ",Ot(3,1,t.Price,"1.0-4")," ")}}function ui(o,e){if(o&1){let t=A();h(0),r(1,"tr",9),d("contextmenu",function(i){let l=f(t),I=l.$implicit,D=l.index,ae=p(2);return C(ae.onContextMenu(i,I,D))}),v(2,ii,2,1,"td",10),r(3,"td",11),d("click",function(){let i=f(t),l=i.$implicit,I=i.index,D=p(2);return C(D.onEdit(l,I))}),r(4,"div",12),v(5,oi,3,1,"ng-container",3)(6,ri,2,0,"ng-template",null,2,ce),r(8,"div",13)(9,"div"),s(10),a(),r(11,"span",14),s(12),a(),r(13,"div"),y(14,"app-serial-note",15),a(),v(15,ai,1,1,"small",16),a()()(),r(16,"td",17),d("click",function(){let i=f(t),l=i.$implicit,I=i.index,D=p(2);return C(D.onEdit(l,I))}),r(17,"div",18)(18,"div",19),v(19,li,4,4,"ng-container",20)(20,ci,7,3,"ng-container",20)(21,si,4,3,"ng-container",20)(22,mi,3,1,"ng-container",20),a()()(),r(23,"td",21),d("click",function(){let i=f(t),l=i.$implicit,I=i.index,D=p(2);return C(D.onEdit(l,I))}),v(24,pi,4,4,"ng-container",20),a(),r(25,"td",21),d("click",function(){let i=f(t),l=i.$implicit,I=i.index,D=p(2);return C(D.onEdit(l,I))}),r(26,"div",22),s(27),_(28,"number"),a()(),r(29,"td",23),d("click",function(){let i=f(t),l=i.$implicit,I=i.index,D=p(2);return C(D.onEdit(l,I))}),r(30,"div",18)(31,"div",24),s(32),_(33,"number"),a()()(),r(34,"td",25)(35,"div",26)(36,"span",27),d("click",function(){let i=f(t),l=i.$implicit,I=i.index,D=p(2);return C(D.onRemove(l,I))}),y(37,"i",28),a()()()(),x()}if(o&2){let t=e.$implicit,n=K(7),i=p(2);c(2),m("ngIf",i.appConfig==null?null:i.appConfig.ModuleSell.Grid.RowNumberVisible),c(3),m("ngIf",t.ThumbnailUrl)("ngIfElse",n),c(5),j(t.Name),c(2),j(t.Code),c(2),m("serials",t==null?null:t.Serial),c(),Je(t.Note?15:-1),c(4),m("ngIf",t.Quantity!==1&&t.Quantity!==0||t.UnitQuantity>1||t.VariantUnitQuantity>1),c(),m("ngIf",t.UnitQuantity>1),c(),m("ngIf",t.VariantUnitQuantity>1),c(),m("ngIf",t.UOM&&(i.appConfig==null||i.appConfig.ModuleSell==null?null:i.appConfig.ModuleSell.Grid.UOMVisible)),c(2),m("ngIf",t.Price!==t.Total),c(3),S(" ",t.Discount?b(28,14,t.Discount*-1)+"%":""," "),c(5),S(" ",i.roleService.product!=null&&i.roleService.product.Price?b(33,16,t.Total):" - "," ")}}function di(o,e){if(o&1){let t=A();h(0),r(1,"table",6)(2,"tbody",7),d("cdkDropListDropped",function(i){f(t);let l=p();return C(l.onDrop(i))}),v(3,ui,38,18,"ng-container",8),a()(),x()}if(o&2){let t=p();c(3),m("ngForOf",t.cartItems)}}function gi(o,e){o&1&&(r(0,"div",40)(1,"div",41)(2,"div",42)(3,"div",43)(4,"div",44),y(5,"i",45),a(),r(6,"div",46)(7,"span"),s(8,"Empty Cart"),a(),y(9,"br"),r(10,"span"),s(11,"Add products to the cart"),a(),y(12,"br"),r(13,"span"),s(14,"or scan barcode"),a()()()()()())}function fi(o,e){if(o&1){let t=A();r(0,"button",47),d("click",function(){let i=f(t).item,l=p();return C(l.onReverse(i,!0))}),s(1,"Return"),a(),r(2,"button",47),d("click",function(){let i=f(t).item,l=p();return C(l.onReverse(i,!1))}),s(3,"Purchase"),a()}}var _t=class o{roleService=u(ge);appConfig;cartItems=[];set _cartItems(e){e&&(this.cartItems=[...e])}onRemoveEvent=new V;onEditEvent=new V;onDropItems=new V;onReturnEvent=new V;onPurchaseEvent=new V;contextMenu;contextMenuPosition={x:"0px",y:"0px"};onContextMenu(e,t,n){e.preventDefault(),this.contextMenuPosition.x=e.clientX+"px",this.contextMenuPosition.y=e.clientY+"px",t.Index=n,this.contextMenu.menuData={item:t},this.contextMenu.openMenu()}onDrop(e){en(this.cartItems,e.previousIndex,e.currentIndex),this.onDropItems.emit(this.cartItems)}onEdit(e,t){this.onEditEvent.emit({cartItem:e,index:t})}onRemove(e,t){this.onRemoveEvent.emit({cartItem:e,index:t})}onReverse(e,t){let n=e.Index;t?(e.Quantity>0&&(e.Quantity=e.Quantity*-1),this.onReturnEvent.emit({cartItem:e,index:n})):(e.Quantity<0&&(e.Quantity=e.Quantity*-1),this.onPurchaseEvent.emit({cartItem:e,index:n}))}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["POS-cart-display"]],viewQuery:function(t,n){if(t&1&&zt(rt,7),t&2){let i;Gt(i=Jt())&&(n.contextMenu=i.first)}},inputs:{appConfig:"appConfig",_cartItems:[0,"cartItems","_cartItems"]},outputs:{onRemoveEvent:"onRemove",onEditEvent:"onEdit",onDropItems:"onDropItems",onReturnEvent:"onReturn",onPurchaseEvent:"onPurchase"},standalone:!0,features:[P],decls:7,vars:7,consts:[["EMPTY_CART",""],["contextMenu","matMenu"],["NO_IMAGE",""],[4,"ngIf","ngIfElse"],[2,"visibility","hidden","position","fixed",3,"matMenuTriggerFor"],["matMenuContent",""],[1,"table","table-borderless"],["cdkDropList","",3,"cdkDropListDropped"],[4,"ngFor","ngForOf"],["cdkDrag","",1,"border-bottom",3,"contextmenu"],["style","width: 10px",4,"ngIf"],[1,"pe-0",2,"width","50%",3,"click"],[1,"d-flex","align-items-center"],[1,"d-block","ms-4",2,"line-height","18px"],[1,"fw-normal","fs-6","text-muted"],[3,"serials"],["title","Note",1,"special-TinyMCE","m-0","fst-italic","d-block",3,"innerHtml"],[1,"px-0","text-end",2,"width","15%",3,"click"],[1,"d-flex","align-items-center","justify-content-end"],[1,"d-flex","text-end","fw-normal","align-items-center",2,"line-height","20px"],[4,"ngIf"],[3,"click"],[1,"fw-normal","fs-5","text-danger"],[1,"pe-0",3,"click"],[1,"fs-5"],[1,"mt-6","ps-0"],[1,"d-flex","justify-content-end","align-items-center"],["role","button","title","Delete Item",1,"fs-3","cursor-pointer",3,"click"],[1,"fa","fa-trash","text-danger","fs-4"],[2,"width","10px"],[1,"ratio","ratio-1x1",2,"width","55px"],[1,"item-image",3,"src"],[1,"item-image","d-flex","justify-content-center","align-items-center","text-center","fs-1"],[1,"fa-solid","fa-image",2,"color","#b4b4b4c2"],[1,"fs-6","me-1","ms-1"],[1,"d-flex","algin-items-center"],["title","Unit Quantity",1,"fs-5","me-1"],["title","Variant Unit Quantity",1,"fs-5"],["title","UOM",1,"ps-1","fs-5"],[1,"fs-5","text-end"],[1,"row","g-0","h-100"],[1,"col-12"],[1,"d-flex","justify-content-center","align-items-center","h-100"],[1,"row"],[1,"col-12","d-flex","justify-content-center"],[1,"fa-regular","fa-cart-arrow-up","text-secondary",2,"font-size","110px"],[1,"col-12","justify-content-center","text-center","mt-5","empty-cart-description","text-secondary","headings-font-family"],["mat-menu-item","",3,"click"]],template:function(t,n){if(t&1&&(v(0,di,4,1,"ng-container",3)(1,gi,15,0,"ng-template",null,0,ce),y(3,"div",4),r(4,"mat-menu",null,1),v(6,fi,4,0,"ng-template",5),a()),t&2){let i=K(2),l=K(5);m("ngIf",n.cartItems.length>0)("ngIfElse",i),c(3),Ht("left",n.contextMenuPosition.x)("top",n.contextMenuPosition.y),m("matMenuTriggerFor",l)}},dependencies:[T,de,z,ee,on,nn,tn,kn,hn,yn,vn,_n,bn,rt],styles:[".item-image[_ngcontent-%COMP%]{height:50px;width:56px;display:block;border:solid 1px #dddddd;border-radius:5px;object-fit:contain}.example-menu[_ngcontent-%COMP%]{display:inline-flex;flex-direction:column;min-width:180px;max-width:280px;background-color:#fff;padding:6px 0}.example-menu-item[_ngcontent-%COMP%]{background-color:transparent;cursor:pointer;border:none;-webkit-user-select:none;user-select:none;min-width:64px;line-height:36px;padding:0 16px;display:flex;align-items:center;flex-direction:row;flex:1}.example-menu-item[_ngcontent-%COMP%]:hover{background-color:#f5f5f5}.example-menu-item[_ngcontent-%COMP%]:active{background-color:#dcdcdc}.table[_ngcontent-%COMP%] > [_ngcontent-%COMP%]:not(caption) > *[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]{padding:12px 10px} .cdk-menu.cdk-menu-group.example-menu{box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.empty-cart-description[_ngcontent-%COMP%]{font-size:14px;font-weight:500;color:#c7c7c7}"]})};function _i(o,e){if(o&1&&(r(0,"mat-option",6),s(1),a()),o&2){let t=e.$implicit;m("value",t),c(),S(" ",t.Value," ")}}var bt=class o{httpService=u(X);customerCtrl=new we;customerFiltered$=this.customerCtrl.valueChanges.pipe(O(e=>typeof e=="string"&&e.length>=3),jt(300),Z(e=>this.getCustomerSuggestion(e)));customerSelected$=this.customerCtrl.valueChanges.pipe(O(e=>typeof e!="string"),k(e=>{this.onChange(e)}));createNewCustomer=new V;clickInput=new V;constructor(){this.customerSelected$.pipe(R()).subscribe()}getCustomerSuggestion(e){return this.httpService.get(G.GetCustomerSuggestions,[{key:"count",value:100},{key:"prefix",value:e}])}displayFn(e){return e?.Value}onCreateCustomer(){this.createNewCustomer.emit()}onClickInputValue(){this.clickInput.emit()}onChange=e=>{};onTouched=()=>{};writeValue(e){this.customerCtrl.patchValue(e,{onlySelf:!0,emitEvent:!1})}registerOnChange(e){this.onChange=e}registerOnTouched(e){this.onTouched=e}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["POS-customer-autocomplete"]],outputs:{createNewCustomer:"onCreateNewCustomer",clickInput:"onClickInput"},standalone:!0,features:[Te([{provide:tt,multi:!0,useExisting:o}]),P],decls:7,vars:6,consts:[["auto","matAutocomplete"],[1,"d-flex","align-items-center","position-relative"],["matTooltipPosition","above","matTooltip","New Customer","role","button",1,"fa-light","fa-user-plus","position-absolute","cursor-pointer",2,"font-size","12px",3,"click"],["type","text","placeholder","Assign Customer",3,"click","formControl","matAutocomplete"],[3,"displayWith"],[3,"value",4,"ngFor","ngForOf"],[3,"value"]],template:function(t,n){if(t&1){let i=A();r(0,"div",1)(1,"i",2),d("click",function(){return f(i),C(n.onCreateCustomer())}),a(),r(2,"input",3),d("click",function(){return f(i),C(n.onClickInputValue())}),a(),r(3,"mat-autocomplete",4,0),v(5,_i,2,2,"mat-option",5),_(6,"async"),a()()}if(t&2){let i=K(4);c(2),m("formControl",n.customerCtrl)("matAutocomplete",i),c(),m("displayWith",n.displayFn),c(2),m("ngForOf",b(6,4,n.customerFiltered$))}},dependencies:[T,de,Oe,mn,cn,Zt,sn,Ne,te,Y,ke,it,nt,at],styles:["input[_ngcontent-%COMP%]{width:100%;height:38px!important;border-radius:.375rem;border:1px solid #ced4da;padding-left:32px}input[_ngcontent-%COMP%]::placeholder{color:#ced4da}i[_ngcontent-%COMP%]{font-size:16px;top:12px;left:11px}"]})};var qe=class o{storeService=u(E);dialog=u(oe);httpService=u(X);createNewCustomer(){this.dialog.open(xn,{data:{options:this.storeService.loadForm()?.EstimateOptions,config:this.storeService.loadForm()?.AppConfigJSON?.ModuleContact,type:"customer",title:"New Customer Form"}}).afterClosed().pipe(O(e=>g.IsNotEmpty(e))).subscribe(e=>{let t=new re;t.Key=e.CustomerID,t.Value=e.ContactName,this.storeService.updateCustomer(t)})}onSelectCustomer(e){let t=this.storeService.outlet();this.httpService.get(G.GetCustomerPrivilegeByID,[{key:"ID",value:e.Key},{key:"EntityID",value:t.ID}]).pipe(Ut(()=>{let n=new re;return this.storeService.updateCustomer(n),Ft})).subscribe(n=>{let i=JSON.parse(JSON.stringify(e));i.PricebookID=n.PricebookID,this.storeService.updateCustomer(i)})}onDeleteCustomer(){g.IsNotEmpty(this.storeService?.customer()?.Key)&&this.dialog.open(En,{data:{title:"Re-assign customer",message:"Are you sure to re-assign the customer?"}}).afterClosed().pipe(O(e=>e)).subscribe(()=>{let e=new re;this.storeService.updateCustomer(e)})}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};var vt=class o{clickEvent=new V;onClick(){this.clickEvent.emit()}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["app-note-button"]],outputs:{clickEvent:"onClickEvent"},standalone:!0,features:[P],decls:2,vars:0,consts:[["type","button",1,"btn","btn-gray","w-100","fs-3","px-0","py-6","headings-font-family",3,"click"],[1,"fa-regular","fa-note-sticky","fa-xl"]],template:function(t,n){t&1&&(r(0,"button",0),d("click",function(){return n.onClick()}),y(1,"i",1),a())},dependencies:[T],styles:[".btn-gray[_ngcontent-%COMP%]{border:1px solid #d6d6d6;color:#545454!important;background:linear-gradient(to bottom,#fff,#eee)}"]})};function bi(o,e){if(o&1&&(r(0,"div"),s(1),_(2,"number"),a()),o&2){let t=p();c(),S(" ",b(2,1,t.totalAmount)," ")}}function vi(o,e){o&1&&s(0," - ")}var yt=class o{payEvent=new V;totalItems=0;totalQuantity=0;totalAmount=0;rolePrice=!0;constructor(){}ngOnInit(){}onPay(){this.payEvent.emit()}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["app-pay-button"]],inputs:{totalItems:"totalItems",totalQuantity:"totalQuantity",totalAmount:"totalAmount",rolePrice:"rolePrice"},outputs:{payEvent:"onPayEvent"},standalone:!0,features:[P],decls:11,vars:6,consts:[["HIDDENCOST",""],["type","button",1,"btn","btn-success","fs-1","py-4","w-100",3,"click"],[1,"d-flex","align-items-center","justify-content-between"],[1,"fs-6"],[4,"ngIf","ngIfElse"]],template:function(t,n){if(t&1){let i=A();r(0,"button",1),d("click",function(){return f(i),C(n.onPay())}),r(1,"div",2)(2,"div")(3,"span"),s(4,"Submit"),a(),r(5,"small",3),s(6),_(7,"number"),a()(),v(8,bi,3,3,"div",4)(9,vi,1,0,"ng-template",null,0,ce),a()()}if(t&2){let i=K(10);c(6),Pe(" (",b(7,4,n.totalItems)," Items & ",n.totalQuantity," Qty) "),c(2),m("ngIf",n.rolePrice)("ngIfElse",i)}},dependencies:[T,z,ee],styles:["button[_ngcontent-%COMP%]{border-right:.1px solid #fff;margin-left:-1px;border-top-left-radius:0;border-bottom-left-radius:0;position:relative;flex:1 1 auto;border-left:.1px solid #fff}"]})};var ht=class o{clickEvent=new V;onClick(){this.clickEvent.emit()}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["app-discount-button"]],outputs:{clickEvent:"onClickEvent"},standalone:!0,features:[P],decls:2,vars:0,consts:[["type","button","matTooltip","Discount / Tax","matTooltipPosition","above",1,"btn","btn-success","fs-5",3,"click"],[1,"fa-light","fa-percent"]],template:function(t,n){t&1&&(r(0,"button",0),d("click",function(){return n.onClick()}),y(1,"i",1),a())},dependencies:[T,it,nt],styles:["button[_ngcontent-%COMP%]{border-right:.1px solid #fff;border-top-right-radius:0;border-bottom-right-radius:0;position:relative;flex:1 1 auto}"]})};var Be=class o{store=u(E);toastr=u(et);dialog=u(oe);updateState$=U(this.store.complete).pipe(O(e=>e.Success),k(()=>this.store.updateState(3)),R());constructor(){this.updateState$.subscribe()}onPay(){if(this.validatePayOrder()==!1)return;let t={Items:this.cartItemPreSubmission(),Order:B({},this.store.order())};this.dialog.open(Vn,{data:{transactionData:t,api:G.SubmitEstimate}}).afterClosed().pipe(O(n=>g.IsNotEmpty(n))).subscribe(n=>{this.store.updateComplete(n)})}cartItemPreSubmission(){let e=JSON.parse(JSON.stringify(this.store.cartItems()));return e=e.map(t=>(delete t.Variant,t)),e}validatePayOrder(){let e=!0;return g.IsEmpty(this.store.outlet().ID)&&(this.toastr.error("Please select outlet before proceeding..",Ee.Error),e=!1),g.IsEmpty(this.store.customer().Key)&&(this.toastr.warning("Please select a customer!",Ee.Warning),e=!1),this.store.cartItems().length==0&&(this.toastr.error("You must have at least one item.",Ee.Error),e=!1),g.IsEmpty(this.store.order().Number)&&(this.toastr.error("Number cannot be empty.",Ee.Error),e=!1),e}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};var xt=class o{constructor(e,t){this.dialogRef=t;this.discountAmount.set(e.discountAmount),this.discount.set(e.discount),this.tax=F(e.tax),this.currency=F(e.currency),this.taxes.set(e.taxes),this.initModalConfig()}modalConfig=new be;discountAmount=F(0);discount=F(0);tax;discounts=F([0,0,0]);currency;taxes=F([]);initModalConfig(){this.modalConfig.title="Discount and Tax",this.modalConfig.customWidth="400px"}onClose(){this.dialogRef.close()}onSave(){this.dialogRef.close({discountAmount:this.discountAmount(),discount:this.discount(),tax:this.tax()})}onSelectTax(e){this.tax.set(e)}onDiscountCalculatorChange(e,t){let n=this.discounts();n[t]=e,this.discounts.set(n),this.calculateDiscountCalculator()}calculateDiscountCalculator(){let e=this.discounts(),t=100;e.forEach(i=>{i&&i>0&&(t=t*(100-i)/100)});let n=100-t;this.discount.set(n)}static \u0275fac=function(t){return new(t||o)(Q(Ce),Q(fe))};static \u0275cmp=M({type:o,selectors:[["app-dialog-discount"]],standalone:!0,features:[P],decls:48,vars:10,consts:[[3,"keydown.F2","onOk","onCancel","onClose","config"],[1,"container"],["matTooltipPosition","above","matTooltip","Discount","tabTitle","Discount"],[1,"row","d-flex","align-items-center","justify-content-start"],[1,"col-3"],[1,"fw-bold","d-block"],[1,"col-9"],["type","text","data-cy","discount1","autoNum","","percentage","","decimalPlaces","2",1,"form-control","d-inline-block",2,"width","100px",3,"ngModelChange","ngModel"],[1,"ms-1"],[1,"row","d-flex","align-items-center","justify-content-start","mt-6"],["type","text","data-cy","discountamount","autoNum","",1,"form-control","d-inline-block",2,"width","100px",3,"ngModelChange","ngModel"],["matTooltipPosition","above","matTooltip","Tax","tabTitle","Tax"],["bindLabel","Label","appendTo","body","bindValue","ID","placeholder","Tax","data-cy","Tax",2,"width","150px",3,"change","clearable","ngModel","items"],["matTooltipPosition","above","matTooltip","Calculation","tabTitle","Calculator"],[1,"row","mt-6","g-0","d-flex","align-items-center","justify-content-start"],[1,"col-4"],[1,"col-8","ps-4"],["type","text","data-cy","discountCal1","autoNum","","percentage","",1,"form-control","d-inline-block",2,"width","47px",3,"ngModelChange","ngModel"],[1,"mx-2"],["type","text","data-cy","discountCal2","autoNum","","percentage","",1,"form-control","d-inline-block",2,"width","47px",3,"ngModelChange","ngModel"],["type","text","data-cy","discountCal3","autoNum","","percentage","",1,"form-control","d-inline-block",2,"width","47px",3,"ngModelChange","ngModel"]],template:function(t,n){if(t&1&&(r(0,"modal-material",0),d("keydown.F2",function(){return n.onSave()})("onOk",function(){return n.onSave()})("onCancel",function(){return n.onClose()})("onClose",function(){return n.onClose()}),r(1,"content")(2,"div",1)(3,"custom-tabs"),h(4),r(5,"tab",2)(6,"div",3)(7,"div",4)(8,"label",5),s(9,"Discount %"),a()(),r(10,"div",6)(11,"input",7),q("ngModelChange",function(l){return W(n.discount,l)||(n.discount=l),l}),a(),r(12,"span",8),s(13,"%"),a()()(),r(14,"div",9)(15,"div",4)(16,"label",5),s(17),a()(),r(18,"div",6)(19,"input",10),q("ngModelChange",function(l){return W(n.discountAmount,l)||(n.discountAmount=l),l}),a()()()(),x(),h(20),r(21,"tab",11)(22,"div",3)(23,"div",4)(24,"label",5),s(25,"Tax"),a()(),r(26,"div",6)(27,"ng-select",12),d("change",function(l){return n.onSelectTax(l)}),a()()()(),x(),h(28),r(29,"tab",13)(30,"div",14)(31,"div",15)(32,"label",5),s(33,"Discount Calculator"),a()(),r(34,"div",16)(35,"input",17),d("ngModelChange",function(l){return n.onDiscountCalculatorChange(l,0)}),a(),r(36,"span"),s(37," %"),a(),r(38,"span",18),s(39,"+"),a(),r(40,"input",19),d("ngModelChange",function(l){return n.onDiscountCalculatorChange(l,1)}),a(),r(41,"span"),s(42," %"),a(),r(43,"span",18),s(44,"+"),a(),r(45,"input",20),d("ngModelChange",function(l){return n.onDiscountCalculatorChange(l,2)}),a(),r(46,"span"),s(47," %"),a()()()(),x(),a()()()()),t&2){let i;m("config",n.modalConfig),c(11),L("ngModel",n.discount),c(6),S("Discount ",(i=n.currency())==null?null:i.Symbol,""),c(2),L("ngModel",n.discountAmount),c(8),m("clearable",!1)("ngModel",n.tax().ID)("items",n.taxes()),c(8),m("ngModel",n.discounts[0]),c(5),m("ngModel",n.discounts[1]),c(5),m("ngModel",n.discounts[2])}},dependencies:[T,ye,ve,lt,st,ct,ie,te,Y,ne,Ve,Ae,_e,he]})};var Me=class o{storeService=u(E);totalItemsQty=H(()=>this.storeService.cartItems().reduce((n,i)=>n+i.Quantity,0));totalItemsAmount=H(()=>this.storeService.cartItems().reduce((n,i)=>n+i.Total,0));taxAmount=H(()=>{let e=this.storeService.tax(),t=0;return e.Rate>0&&(e.CalculationTypeID==1?t=this.calculateTaxInclude(e):t=this.calculateTaxAdd(e)),t});totalAmount=H(()=>{let e=this.storeService.tax(),t=this.storeService.order().DiscountAmount,n=this.storeService.order().Discount,i=this.totalItemsAmount(),l=this.calculatePercentagDisc(n,i),I=i-t-l;return e.CalculationTypeID==0&&(I=I+this.taxAmount()),I});discountPercentageAmount=H(()=>{let e=this.storeService.order().Discount,t=this.totalItemsAmount();return this.calculatePercentagDisc(e,t)});calculateTaxInclude(e){let t=this.grossTotalTaxable();return e.Rate/(100+e.Rate)*t}calculateTaxAdd(e){let t=this.grossTotalTaxable();return e.Rate/100*t}grossTotalTaxable(){let e=this.taxableItems(),t=this.calculateTaxableItemsPrice(),n=this.storeService.discount();if(e.length!==0){let i=this.calculateDiscountTaxableItem();t=t*(100-n.discount)/100,t=t-i}return t}calculateDiscountTaxableItem(){let e=this.taxableItems(),t=this.totalItemsAmount(),n=this.storeService.discount().discountAmount,i=0,l=0,I=0,D=0;for(let ae of e)i=ae.getItemAfterDiscount/t,l=i*n,D=l*ae.Quantity,I+=D;return I}calculatePercentagDisc(e,t){return e/100*t}calculateTaxableItemsPrice(){return this.taxableItems().filter(n=>n.Taxable).reduce((n,i)=>n+i.Total,0)}taxableItems(){return this.storeService.cartItems().filter(t=>t.Taxable)}static \u0275fac=function(t){return new(t||o)};static \u0275prov=N({token:o,factory:o.\u0275fac})};var xi=o=>({selected:o});function Si(o,e){if(o&1){let t=A();r(0,"div",12)(1,"span",13),s(2,"@"),a(),r(3,"input",14),q("ngModelChange",function(i){f(t);let l=p();return W(l.currency().ExchangeRate,i)||(l.currency().ExchangeRate=i),C(i)}),a()()}if(o&2){let t=p();c(3),L("ngModel",t.currency().ExchangeRate)}}function Ii(o,e){if(o&1){let t=A();r(0,"div",15)(1,"label",16)(2,"input",17),d("ngModelChange",function(){let i=f(t).$implicit,l=p();return C(l.onChangeTag(i.ID))}),a(),s(3),a()()}if(o&2){let t,n=e.$implicit,i=e.index,l=p();c(),Tt("for","potype-"+i),m("ngClass",$(5,xi,((t=l.tag())==null?null:t.ID)==n.ID)),c(),Tt("id","potype-"+i),m("ngModel",l.tag().ID),c(),S(" ",n.Name," ")}}var St=class o{constructor(e,t){this.dialogRef=t;this.initModalConfig(),this.currencies.set(e.currencies),this.tags.set(e.tags),this.tag=F(e.tag),this.currency=F(e.currency),this.defaultCurrencyId=F(e.defaultCurrencyId)}modalConfig=new be;currencies=F([]);tags=F([]);tag;currency;defaultCurrencyId;initModalConfig(){this.modalConfig.title="Order Note",this.modalConfig.customWidth="700px"}onChangeCurrency(e){let t=this.currencies()?.find(n=>n.ID===e);this.currency.set(t)}onChangeTag(e){let t=this.tags()?.find(n=>n.ID===e);this.tag.set(t)}onClose(){this.dialogRef.close()}onSave(){this.dialogRef.close({currency:this.currency(),tag:this.tag()})}static \u0275fac=function(t){return new(t||o)(Q(Ce),Q(fe))};static \u0275cmp=M({type:o,selectors:[["app-dialog-note"]],standalone:!0,features:[P],decls:16,vars:6,consts:[[3,"keydown.F2","onOk","onCancel","onClose","config"],[1,"container"],["matTooltipPosition","above","matTooltip","Currency","tabTitle","Currency"],[1,"row","d-flex","align-items-center","justify-content-start","mt-6"],[1,"row","ms-4"],[1,"ps-0","col-sm-4"],["bindLabel","Name","bindValue","ID","placeholder","Currency","appendTo","body",3,"ngModelChange","items","clearable","ngModel"],["class","col-sm-4 d-flex",4,"ngIf"],["matTooltipPosition","above","matTooltip","Tag","tabTitle","Tag"],[1,"row"],[1,"col-12"],["class","rad-btn",4,"ngFor","ngForOf"],[1,"col-sm-4","d-flex"],[1,"pt-4"],["type","text","autoNum","",1,"border","border-light",3,"ngModelChange","ngModel"],[1,"rad-btn"],[3,"for","ngClass"],["type","radio",3,"ngModelChange","ngModel","id"]],template:function(t,n){if(t&1&&(r(0,"modal-material",0),d("keydown.F2",function(){return n.onSave()})("onOk",function(){return n.onSave()})("onCancel",function(){return n.onClose()})("onClose",function(){return n.onClose()}),r(1,"content")(2,"div",1)(3,"custom-tabs"),h(4),r(5,"tab",2)(6,"div",3)(7,"div",4)(8,"div",5)(9,"ng-select",6),d("ngModelChange",function(l){return n.onChangeCurrency(l)}),a()(),v(10,Si,4,1,"div",7),a()()(),x(),h(11),r(12,"tab",8)(13,"div",9)(14,"div",10),v(15,Ii,4,7,"div",11),a()()(),x(),a()()()()),t&2){let i;m("config",n.modalConfig),c(9),m("items",n.currencies())("clearable",!1)("ngModel",n.currency().ID),c(),m("ngIf",((i=n.currency())==null?null:i.ID)!=n.defaultCurrencyId()),c(5),m("ngForOf",n.tags())}},dependencies:[T,ue,de,z,ye,ve,lt,st,ct,ie,te,Yt,Y,ne,Ve,Ae,_e,he],styles:[".bg-light-gray[_ngcontent-%COMP%]{background-color:var(--bs-light-gray);--bs-bg-opacity: .15 !important}.bg-gradient-danger[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#f8d7da,#f8d7da 15px,#f5c6cb 15px 30px)!important}.bg-gradient-success[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#beeebb,#beeebb 15px,#afeba8 15px 30px)!important}.bg-gradient-warning[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#fcf3cf,#fcf3cf 15px,#f9e79f 15px 30px)!important}.bg-light-orange[_ngcontent-%COMP%]{background-color:var(--bs-light-orange);--bs-bg-opacity: .15 !important}.text-danger[_ngcontent-%COMP%]{color:#fb404b!important}.text-dark[_ngcontent-%COMP%]{color:#5e5e5e!important}.text-success[_ngcontent-%COMP%]{color:#87cb16!important}.text-black[_ngcontent-%COMP%]{color:#000!important}.text-white[_ngcontent-%COMP%]{color:var(--bs-white)!important}.btn-light-blue[_ngcontent-%COMP%]{color:#212529;background-color:#dfeffc!important;border-color:#dfeffc}.btn-light-blue[_ngcontent-%COMP%]:hover{color:#212529;background-color:#bcdef9;border-color:#b0d8f8}.btn-light-blue[_ngcontent-%COMP%]:focus, .btn-light-blue.focus[_ngcontent-%COMP%]{color:#212529;background-color:#bcdef9;border-color:#b0d8f8;box-shadow:0 0 0 .2rem #c3d1dc80}.btn-light-blue.disabled[_ngcontent-%COMP%], .btn-light-blue[_ngcontent-%COMP%]:disabled{color:#212529;background-color:#dfeffc;border-color:#dfeffc}.btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active, .btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active, .show[_ngcontent-%COMP%] > .btn-light-blue.dropdown-toggle[_ngcontent-%COMP%]{color:#212529;background-color:#b0d8f8;border-color:#a5d2f7}.btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active:focus, .btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active:focus, .show[_ngcontent-%COMP%] > .btn-light-blue.dropdown-toggle[_ngcontent-%COMP%]:focus{box-shadow:0 0 0 .2rem #c3d1dc80}.rad-btn[_ngcontent-%COMP%]{position:relative;display:inline-block}.rad-btn[_ngcontent-%COMP%] label[_ngcontent-%COMP%]{border:1px solid #dddddd;border-radius:3px;margin-right:10px;cursor:pointer;padding:10px;margin-bottom:10px;color:#000}.rad-btn[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{visibility:hidden;position:absolute;left:0;top:0}.rad-btn[_ngcontent-%COMP%] label.selected[_ngcontent-%COMP%]{background:#dcdcdc;border:1px solid #dcdcdc}"]})};var It=class o{onClickEvent=new V;constructor(){}ngOnInit(){}onClick(){this.onClickEvent.emit()}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["app-clear-button"]],outputs:{onClickEvent:"onClickEvent"},standalone:!0,features:[P],decls:3,vars:0,consts:[["type","button",1,"btn","btn-gray","w-100","fs-3","px-0","py-6","headings-font-family",3,"click"]],template:function(t,n){t&1&&(r(0,"button",0),d("click",function(){return n.onClick()}),r(1,"span"),s(2,"Clear"),a()())},styles:[".btn-gray[_ngcontent-%COMP%]{border:1px solid #d6d6d6;color:#545454!important;background:linear-gradient(to bottom,#fff,#eee)}"]})};function Di(o,e){if(o&1&&(h(0),r(1,"tr")(2,"th",12),s(3,"Amount"),a(),r(4,"td",13),s(5),_(6,"number"),a()(),x()),o&2){let t=p();c(5),j(b(6,1,t.calculationService==null?null:t.calculationService.totalItemsAmount()))}}function Mi(o,e){if(o&1&&(r(0,"tr")(1,"th",12),s(2),a(),r(3,"td",14),s(4),_(5,"number"),a()()),o&2){let t=p(2);c(2),S("Discount ",t.storeService==null?null:t.storeService.discount().discount,"%"),c(2),S(" ",b(5,2,t.calculationService.discountPercentageAmount()*-1),"")}}function Pi(o,e){if(o&1&&(r(0,"tr")(1,"th",12),s(2),a(),r(3,"td",14),s(4),_(5,"number"),a()()),o&2){let t,n,i=p(2);c(2),S("Discount ",(t=i.storeService.currency())==null?null:t.Symbol,""),c(2),S(" ",b(5,2,((n=i.storeService.discount())==null?null:n.discountAmount)*-1),"")}}function Ei(o,e){if(o&1&&(r(0,"tr")(1,"th",12),s(2),a(),r(3,"td",13),s(4),_(5,"number"),a()()),o&2){let t,n=p(2);c(2),j((t=n.storeService.tax())==null?null:t.Label),c(2),j(b(5,2,n.calculationService.taxAmount()))}}function Ti(o,e){if(o&1&&(h(0),v(1,Mi,6,4,"tr",3)(2,Pi,6,4,"tr",3)(3,Ei,6,4,"tr",3),x()),o&2){let t,n,i=p();c(),m("ngIf",i.storeService.discount().discount!=0),c(),m("ngIf",((t=i.storeService.discount())==null?null:t.discountAmount)!=0),c(),m("ngIf",((n=i.storeService.tax())==null?null:n.Rate)!=0)}}var Dt=class o{storeService=u(E);orderService=u(se);roleService=u(ge);payService=u(Be);calculationService=u(Me);cartService=u(me);dialog=u(oe);taxCalculationType=ot;totalItemsQty=H(()=>this.storeService.cartItems()?.length);isShowAmount=H(()=>this.storeService?.tax()?.CalculationTypeID==0&&this.storeService?.tax()?.Rate||this.storeService.discount()?.discount!=0||this.storeService.discount()?.discountAmount!=0);onOpenDialogNote(){this.dialog.open(St,{data:{tags:this.storeService.loadForm().CustomerPOTypes,currencies:this.storeService.loadForm().Currencies,currency:this.storeService.currency(),tag:this.storeService.tag(),defaultCurrencyId:this.storeService.loadForm()?.AppConfigJSON?.CoreDefaults?.CurrencyID}}).afterClosed().pipe(O(e=>g.IsNotEmpty(e))).subscribe(e=>{this.storeService.updateCurrency(e.currency),this.storeService.updateTag(e.tag)})}onOpenDialogDiscount(){this.dialog.open(xt,{data:{discountAmount:this.storeService.order().DiscountAmount,discount:this.storeService.order().Discount,tax:this.storeService.tax(),currency:this.storeService.currency(),taxes:this.storeService.loadForm().Taxes}}).afterClosed().pipe(O(e=>g.IsNotEmpty(e))).subscribe(e=>{this.storeService.updateDiscount({discountAmount:e.discountAmount,discount:e.discount}),this.storeService.updateTax(e.tax)})}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["POS-cart-action"]],standalone:!0,features:[P],decls:13,vars:6,consts:[[1,"row","g-0","px-5","justify-content-end"],[1,"col-6",2,"padding-right","15px"],[1,"table","table-borderless"],[4,"ngIf"],[1,"row","g-0","pb-6","px-5"],[1,"col-5","d-flex","justify-content-between","pe-5",2,"column-gap","12px"],[2,"flex-grow","1",3,"onClickEvent"],[2,"flex-grow","3",3,"onClickEvent"],[1,"col-7"],[1,"btn-group","w-100"],[1,"d-inline-flex",3,"onClickEvent"],[1,"d-inline-flex","w-100",3,"onPayEvent","rolePrice","totalQuantity","totalItems","totalAmount"],[1,"text-start"],[1,"text-end","fs-5"],[1,"text-end","fs-5","text-danger"]],template:function(t,n){t&1&&(r(0,"div",0)(1,"div",1)(2,"table",2),v(3,Di,7,3,"ng-container",3)(4,Ti,4,3,"ng-container",3),a()()(),r(5,"div",4)(6,"div",5)(7,"app-note-button",6),d("onClickEvent",function(){return n.onOpenDialogNote()}),a(),r(8,"app-clear-button",7),d("onClickEvent",function(){return n.cartService.clearCart()}),a()(),r(9,"div",8)(10,"div",9)(11,"app-discount-button",10),d("onClickEvent",function(){return n.onOpenDialogDiscount()}),a(),r(12,"app-pay-button",11),d("onPayEvent",function(){return n.payService.onPay()}),a()()()()),t&2&&(c(3),m("ngIf",n.isShowAmount()),c(),m("ngIf",n.calculationService.totalItemsQty()>0),c(8),m("rolePrice",n.roleService.product.Price)("totalQuantity",n.calculationService.totalItemsQty())("totalItems",n.totalItemsQty())("totalAmount",n.calculationService.totalAmount()))},dependencies:[T,z,ee,ht,vt,yt,It]})};var Bn=o=>({ID:o}),Oi=()=>["/menu/Orders/Orders/Estimate/Info"],wi=o=>({"border-top":o});function ki(o,e){if(o&1&&(h(0),r(1,"div",28)(2,"div",29),s(3),a(),r(4,"div",29),s(5),_(6,"number"),a()(),x()),o&2){let t=e.$implicit;c(3),j(t.Name),c(2),S("",b(6,2,t.Total)," ")}}function Ni(o,e){if(o&1&&(h(0),r(1,"div",30)(2,"div",31),s(3),a(),r(4,"div",31),s(5),_(6,"number"),a()(),x()),o&2){let t,n=p();c(3),S("Amount: ",(t=n.storeService.currency())==null?null:t.Symbol,""),c(2),j(b(6,2,n.calculationService.totalItemsAmount()))}}function Ai(o,e){if(o&1&&(r(0,"div",32)(1,"div",31),s(2),_(3,"number"),a(),r(4,"div",33),s(5),_(6,"number"),a()()),o&2){let t,n=p();c(2),Pe("","Discount "+b(3,3,(t=n.storeService.discount())==null?null:t.discount)+" %",": ",(t=n.storeService.currency())==null?null:t.Symbol,""),c(3),j(b(6,5,n.calculationService.discountPercentageAmount()*-1))}}function Vi(o,e){if(o&1&&(r(0,"div",32)(1,"div",31),s(2),a(),r(3,"div",33),s(4),_(5,"number"),a()()),o&2){let t,n,i=p();c(2),S("Discount: ",(t=i.storeService.currency())==null?null:t.Symbol,""),c(2),S("",b(5,2,((n=i.storeService.discount())==null?null:n.discountAmount)*-1)," ")}}function Fi(o,e){if(o&1&&(r(0,"div",32)(1,"div",31),s(2),a(),r(3,"div",31),s(4),_(5,"number"),a()()),o&2){let t,n=p();c(2),Pe("",(t=n.storeService.tax())==null?null:t.Label,": ",(t=n.storeService.currency())==null?null:t.Symbol,""),c(2),j(b(5,3,n.calculationService.taxAmount()))}}var Mt=class o{orderService=u(se);calculationService=u(Me);storeService=u(E);isShowAmount=H(()=>this.storeService?.tax()?.CalculationTypeID==0&&this.storeService?.tax()?.Rate||this.storeService.discount()?.discount!=0||this.storeService.discount()?.discountAmount!=0);handleF8(){this.orderService.newOrder()}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["POS-complete"]],hostBindings:function(t,n){t&1&&d("keydown.F8",function(l){return n.handleF8(l)},!1,Ge)},standalone:!0,features:[P],decls:40,vars:21,consts:[[1,"pt-7",2,"border-bottom","1px solid rgba(0, 0, 0, 0.1)"],[1,"ps-7","fw-normal","pb-9"],[1,"order-complete"],[1,"container-fluid","pt-8"],[1,"row"],[1,"col-8"],[1,"card"],[1,"card-header",2,"padding-bottom","15px"],[1,"fw-normal",2,"font-size","32px"],[1,"fa-solid","fa-check","me-3"],[1,"card-body"],[1,"row",2,"height","115px"],[1,"col","text-center","my-auto"],[1,"btn","btn-success","w-50",2,"font-size","20px",3,"click"],[1,"card-footer"],[1,"d-flex","justify-content-between","my-6"],["target","_blank","routerLink","/print/Estimate",1,"btn","bg-light-gray","btn-secondary",3,"queryParams"],[1,"fa-solid","fa-print","me-2"],[1,"col-4"],[1,"card-header","bg-light-gray",2,"padding-bottom","15px"],[1,"fst-italic"],["target","_blank",3,"routerLink","queryParams"],[1,"card-body","py-4"],[4,"ngFor","ngForOf"],[4,"ngIf"],["class","row justify-content-end pb-2",4,"ngIf"],[1,"row","justify-content-end","pt-4",3,"ngClass"],[1,"col-4","text-end","h5"],[1,"row","justify-content-between","border-bottom","py-2"],[1,"col","text-end"],[1,"row","justify-content-end","mt-2","pb-2"],[1,"col-4","text-end"],[1,"row","justify-content-end","pb-2"],[1,"col-4","text-end","text-danger"]],template:function(t,n){if(t&1&&(r(0,"div",0)(1,"h1",1),s(2,"Estimate"),a()(),r(3,"section",2)(4,"div",3)(5,"div",4)(6,"div",5)(7,"div",6)(8,"div",7)(9,"h1",8),y(10,"i",9),s(11,"Order Complete "),a()(),r(12,"div",10)(13,"div",11)(14,"div",12)(15,"a",13),d("click",function(){return n.orderService.newOrder()}),s(16,"New Order (F8)"),a()()()(),r(17,"div",14)(18,"div",15)(19,"a",16),y(20,"i",17),s(21,"Print Receipt"),a()()()()(),r(22,"div",18)(23,"div",6)(24,"div",19)(25,"h3",20)(26,"a",21),s(27),a()()(),r(28,"div",22),v(29,ki,7,4,"ng-container",23)(30,Ni,7,4,"ng-container",24)(31,Ai,7,7,"div",25)(32,Vi,6,4,"div",25)(33,Fi,6,5,"div",25),r(34,"div",26)(35,"div",27),s(36),a(),r(37,"div",27),s(38),_(39,"number"),a()()()()()()()()),t&2){let i,l,I,D,ae;c(19),m("queryParams",$(14,Bn,n.storeService.complete().OrderID)),c(7),m("routerLink",Ke(16,Oi))("queryParams",$(17,Bn,n.storeService.complete().OrderID)),c(),S("Estimate #",(i=n.storeService.complete())==null?null:i.InvoiceNumber,""),c(2),m("ngForOf",n.storeService.cartItems()),c(),m("ngIf",n.isShowAmount()),c(),m("ngIf",((l=n.storeService.discount())==null?null:l.discount)>0),c(),m("ngIf",((I=n.storeService.discount())==null?null:I.discountAmount)>0),c(),m("ngIf",((D=n.storeService.tax())==null?null:D.Rate)>0),c(),m("ngClass",$(19,wi,n.isShowAmount())),c(2),S("Total: ",(ae=n.storeService.currency())==null?null:ae.Symbol,""),c(2),j(b(39,12,n.calculationService.totalAmount()))}},dependencies:[T,ue,de,z,ee,Ze,Xe,un],styles:[".order-complete[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] .card-header[_ngcontent-%COMP%]{border-bottom:1px solid rgba(0,0,0,.125);padding-bottom:.9375rem}.order-complete[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] .card-header[_ngcontent-%COMP%] h2[_ngcontent-%COMP%]{font-size:2rem}.order-complete[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] .card-body[_ngcontent-%COMP%] .container[_ngcontent-%COMP%]{max-width:500px;margin-top:30px;margin-bottom:30px}"]})};var Pt=class o{route=u(Ye);dialog=u(oe);addItem=new V;handleF8(){this.dialog.openDialogs&&this.dialog.openDialogs.length>0||this.onAddItem()}onAddItem(){this.addItem.emit()}redirectToPrevious(){this.route.navigate(["/menu/Estimate/V1"])}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=M({type:o,selectors:[["POS-more-action"]],hostBindings:function(t,n){t&1&&d("keydown.F4",function(l){return n.handleF8(l)},!1,Ge)},outputs:{addItem:"onAddItem"},standalone:!0,features:[P],decls:16,vars:0,consts:[["id","moreMenu","data-bs-toggle","dropdown",1,"d-flex","align-items-center","cursor-pointer"],[1,"me-2"],[1,"fa-solid","fa-caret-down","fa-lg"],[1,"fs-6","headings-font-family","pb-1"],[1,"h-100","d-flex","align-items-center","justify-content-between"],["aria-labelledby","moreMenu",1,"dropdown-menu","more-actions"],[1,"d-flex"],[1,"dropdown-header","text-dark","col"],[1,"h5","mb-4"],[1,"dropdown-divider","m-0"],[1,"cursor-pointer",3,"click"],["icon","fa-circle-plus fa-solid","label","Add New"],["icon","fa-solid fa-arrow-left","label","Estimate V1"]],template:function(t,n){t&1&&(r(0,"span",0)(1,"span",1),y(2,"i",2),a(),r(3,"span",3),s(4,"More Actions"),a()(),r(5,"div",4)(6,"div",5)(7,"div",6)(8,"div",7)(9,"div",8),s(10,"Item"),a(),y(11,"div",9),r(12,"li",10),d("click",function(){return n.onAddItem()}),y(13,"POS-dropdown-item-more-action",11),a(),r(14,"li",10),d("click",function(){return n.redirectToPrevious()}),y(15,"POS-dropdown-item-more-action",12),a()()()()())},dependencies:[T,Nn]})};function Ri(o,e){o&1&&(h(0),y(1,"POS-complete"),x())}function Bi(o,e){if(o&1){let t=A();r(0,"div",3)(1,"div",4)(2,"div",5)(3,"div",6)(4,"div",7)(5,"POS-select-outlet-form",8),_(6,"async"),d("ngModelChange",function(i){f(t);let l=p();return C(l.outletService.updateOutlet(i))}),a()(),r(7,"POS-invoice-number-form",9),_(8,"async"),d("ngModelChange",function(i){f(t);let l=p();return C(l.orderService.updateOrderNumber(i))}),a(),r(9,"POS-invoice-date",10),d("ngModelChange",function(i){f(t);let l=p();return C(l.orderService.updateOrderDate(i))}),a()()(),r(10,"div",11)(11,"div",12)(12,"div",13)(13,"POS-more-action",14),d("onAddItem",function(){f(t);let i=p();return C(i.cartItemService.onOpenAddDialog())}),a()(),r(14,"div",15)(15,"ng-select-infinite",16,1),d("selectedChange",function(i){f(t);let l=p();return C(l.orderService.updateSalesPersonId(i))}),a()()()()(),r(17,"div",17)(18,"div",18)(19,"POS-quick-key",19),_(20,"async"),d("onSelectVariant",function(i){f(t);let l=p();return C(l.cartItemService.onSelectQuickkeyItem(i))}),a()(),r(21,"div",20)(22,"div",21)(23,"div",22),y(24,"POS-variant-autocomplete",23),a(),r(25,"div",15)(26,"POS-customer-autocomplete",24),d("onCreateNewCustomer",function(){f(t);let i=p();return C(i.customerService.createNewCustomer())})("ngModelChange",function(i){f(t);let l=p();return C(l.customerService.onSelectCustomer(i))})("onClickInput",function(){f(t);let i=p();return C(i.customerService.onDeleteCustomer())}),a()()(),r(27,"POS-cart-display",25),_(28,"async"),d("onRemove",function(i){f(t);let l=p();return C(l.cartItemService.removeCartItem(i))})("onEdit",function(i){f(t);let l=p();return C(l.cartItemService.onOpenEditDialog(i))})("onDropItems",function(i){f(t);let l=p();return C(l.cartItemService.onDropItems(i))})("onPurchase",function(i){f(t);let l=p();return C(l.cartItemService.onPurchaseItem(i))})("onReturn",function(i){f(t);let l=p();return C(l.cartItemService.onReturnItem(i))}),a(),y(29,"POS-cart-action"),a()()()}if(o&2){let t,n=p();c(5),m("ngModel",n.storeService.outlet())("outlets",n.storeService.loadForm().Entities)("isOpenAfterLoad",b(6,18,n.outletService.isOpenDialog$)),c(2),m("ngModel",b(8,20,n.orderService.orderNumber$))("isEdit",n.isEditOrder()),c(2),m("ngModel",n.storeService.order().Date)("disabled",!(!(n.role==null||n.role.global==null)&&n.role.global.Date))("tooltip",!(n.role==null||n.role.global==null)&&n.role.global.Date?"":"Date role is required"),c(6),m("clearable",!0)("optionTitle",!0)("items",n.storeService.loadForm().SalesPOTypes)("selected",n.storeService.order().SalesID),c(4),m("quickKey",b(20,22,n.quickkeyService.quickkeys$))("outletID",n.storeService.outlet().ID),c(5),m("formControl",n.cartItemService.variantSearchCtrl),c(2),m("ngModel",n.storeService.customer()),c(),m("cartItems",b(28,24,n.cartItemService.cartItems$))("appConfig",(t=n.storeService.loadForm())==null?null:t.AppConfigJSON)}}var Un=class o extends rn{loadFormService=u(Ue);storeService=u(E);role=u(ge);outletService=u(je);orderService=u(se);quickkeyService=u(Qe);cartItemService=u(me);customerService=u(qe);intercomService=u(Xt);isCompleteOrder=H(()=>this.storeService.state()==3);isEditOrder=H(()=>this.storeService.state()==1);constructor(e){super(e),this.menuData$.subscribe(),this.intercomService.hideLauncher()}ngOnDestroy(){this.intercomService.showLauncher()}static \u0275fac=function(t){return new(t||o)(Q(ln))};static \u0275cmp=M({type:o,selectors:[["POS-estimate-v2"]],standalone:!0,features:[Te([E,Ue,je,se,Qe,me,qe,Be,Me,Se,De]),$t,P],decls:3,vars:2,consts:[["NOT_COMPLETE",""],["ngSelectInfinite",""],[4,"ngIf","ngIfElse"],[1,"container-fluid"],[1,"row","header","border-bottom"],[1,"col-5","border-end"],[1,"left-toolbar-container","h-100","d-flex","align-items-center","justify-content-between"],[1,"d-flex"],[3,"ngModelChange","ngModel","outlets","isOpenAfterLoad"],["transactionType","Estimate",3,"ngModelChange","ngModel","isEdit"],[3,"ngModelChange","ngModel","disabled","tooltip"],[1,"col-7","d-flex","align-items-center"],[1,"row","flex-grow-1"],[1,"col-lg-7","col-5","d-flex","align-items-center"],[3,"onAddItem"],[1,"col-5","ps-0"],["bindValue","ID","bindLabel","Name","placeholder","Assign Sales Person",1,"sales-person","select-max-width",3,"selectedChange","clearable","optionTitle","items","selected"],[1,"row","content"],[1,"col-5","border-end","pt-1"],[3,"onSelectVariant","quickKey","outletID"],[1,"col-7","pt-5","px-0","d-flex","flex-column"],[1,"row","w-100","ms-0"],[1,"col-7","px-0"],[3,"formControl"],[3,"onCreateNewCustomer","ngModelChange","onClickInput","ngModel"],[1,"cart-display",3,"onRemove","onEdit","onDropItems","onPurchase","onReturn","cartItems","appConfig"]],template:function(t,n){if(t&1&&v(0,Ri,2,0,"ng-container",2)(1,Bi,30,26,"ng-template",null,0,ce),t&2){let i=K(2);m("ngIf",n.isCompleteOrder())("ngIfElse",i)}},dependencies:[T,z,Oe,Tn,Ne,Y,ke,On,ie,ne,Cn,gn,dn,wn,_t,bt,at,mt,Dt,Mt,Pt],styles:["ng-select-infinite.sales-person.select-max-width>ng-select{padding-right:10px;height:38px} ng-select-infinite.sales-person.select-max-width>.ng-select.ng-select-single .ng-select-container{font-size:.75rem;border:.5px solid #d7d7d7;padding-right:6px} ng-select-infinite.sales-person.select-max-width>.ng-select.ng-select-single .ng-select-container>.ng-arrow-wrapper{width:12px;padding-bottom:2px} ng-select-infinite.sales-person.select-max-width>.ng-select.ng-select-single .ng-select-container>.ng-value-container{padding-left:6px} ng-select-infinite.sales-person.select-max-width>.ng-select.ng-select-single .ng-select-container{min-height:38px!important;height:38px!important;border:none} ng-select-infinite.sales-person.select-max-width.offline>.ng-select.ng-select-single .ng-select-container{background:repeating-linear-gradient(-60deg,#f8d7da,#f8d7da 15px,#f5c6cb 15px 30px)!important} ng-select-infinite.sales-person.select-max-width>.ng-select.ng-select-single .ng-select-container .ng-input{padding-left:5px!important} ng-select-infinite.sales-person.select-max-width>.ng-select.ng-select-single .ng-select-container .ng-input>input{padding-top:5px} ng-select-infinite.sales-person.select-max-width>.ng-select.ng-select-single>ng-dropdown-panel.ng-dropdown-panel{font-size:.75rem;width:95%!important} ng-select-infinite.sales-person.select-max-width>.ng-select.ng-select-focused .ng-select-container{box-shadow:none!important;border-color:transparent!important}.left-toolbar-container[_ngcontent-%COMP%]{position:relative}.left-toolbar-container[_ngcontent-%COMP%] POS-invoice-number-form[_ngcontent-%COMP%]{position:absolute;top:34px;left:28px}.header[_ngcontent-%COMP%]{min-height:60px}.content[_ngcontent-%COMP%]{min-height:calc(100vh - 60px)}.supplier-more-menu[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center}.cart-display[_ngcontent-%COMP%]{flex-grow:1;height:0px;overflow-y:auto}input[_ngcontent-%COMP%]{width:100%;height:38px!important;border:0;border-bottom:1px solid #ced4da;padding-left:32px}input[_ngcontent-%COMP%]::placeholder{color:#ced4da}i[_ngcontent-%COMP%]{font-size:16px;top:10.6px;left:13px}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]{transition:.4s}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]:nth-child(1){-webkit-transform:rotate(-45deg) translate(-8px,4px);transform:rotate(-45deg) translate(-8px,4px)}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]:nth-child(2){opacity:0}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]:nth-child(3){-webkit-transform:rotate(45deg) translate(-5px,0px);transform:rotate(45deg) translate(-5px)}.mobile-button[_ngcontent-%COMP%]{display:none}@media (max-width: 990px){.mobile-button[_ngcontent-%COMP%]{display:block}}.navbar-toggler[_ngcontent-%COMP%]:focus{box-shadow:none!important}.more-actions[_ngcontent-%COMP%] div.d-flex[_ngcontent-%COMP%]{width:30rem}"]})};export{Un as EstimateV2Component};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Fi}from"./chunk-R7MNJHG3.js";import{a as ki,c as Ai}from"./chunk-UMM22E77.js";import{a as Pi,b as Ti,c as wi,d as Ni,e as Ei,f as Be}from"./chunk-RA5QFXG4.js";import{a as Wt}from"./chunk-GJT6AXWW.js";import"./chunk-Y6WXQQCF.js";import{a as Mi}from"./chunk-773CYXAP.js";import{a as jt}from"./chunk-VW4SD2AJ.js";import{a as fi}from"./chunk-M7GZQQXL.js";import{a as hi,b as Di,c as xi}from"./chunk-WVVQJ47P.js";import{a as Cn}from"./chunk-UU2VZEN6.js";import{b as Ci,c as _i}from"./chunk-YTXHEGOU.js";import"./chunk-Q7FLYTMQ.js";import{a as Si}from"./chunk-DQ6V5VPA.js";import{a as Ii}from"./chunk-DULGEYES.js";import"./chunk-JDTVHKRM.js";import"./chunk-SE7OFLAL.js";import"./chunk-JD3LIVDP.js";import"./chunk-WLRXTHLM.js";import{a as Lt,b as vi,c as bi}from"./chunk-3Q22R3MV.js";import"./chunk-X4G74GI2.js";import{a as Ot}from"./chunk-TSKFNB7J.js";import{a as Ut,b as Qt}from"./chunk-WC6HLOBJ.js";import"./chunk-ZT4UZXP6.js";import{b as ui}from"./chunk-ODWOG6HT.js";import"./chunk-746JNXMK.js";import{d as bt}from"./chunk-GWNB6CTG.js";import"./chunk-MFKUC5BJ.js";import{d as di,e as Bt}from"./chunk-MIJSOT4W.js";import"./chunk-OWK2XW4L.js";import{a as yi}from"./chunk-DKZYNKLJ.js";import{a as Xn}from"./chunk-UDC33BP5.js";import{b as Oi}from"./chunk-GGVPDLR2.js";import"./chunk-TDFBRYNF.js";import{b as gi}from"./chunk-2SKKVXLC.js";import"./chunk-RQPAYSJS.js";import"./chunk-C4SDGOBF.js";import"./chunk-BYXBJQAS.js";import{a as qe}from"./chunk-Q7CBBXN2.js";import"./chunk-WMU7MFFB.js";import"./chunk-ZEVKXLP2.js";import{a as Rt}from"./chunk-QZ3JP6YZ.js";import"./chunk-DNE54I3O.js";import{a as Zn,b as ei,c as ti}from"./chunk-GBJA64EK.js";import{a as ni,c as ii,e as oi,f as ri}from"./chunk-RGIAK7TL.js";import"./chunk-LH34DZDB.js";import"./chunk-ZH3LHPKO.js";import{a as rt,b as at}from"./chunk-SIEUNTYO.js";import{a as ai,b as li}from"./chunk-PIJKR7KW.js";import{a as zn}from"./chunk-VUGL7GL5.js";import"./chunk-MV3BEGPX.js";import{i as Me,j as Re,k as ne,l as $t,m as Oe,n as Pe,o as Te,p as si,r as ci,s as pi,v as mi}from"./chunk-P3UEOU3P.js";import{Aa as yt,Ba as vt,ua as Yn}from"./chunk-R5NLMT6O.js";import{a as Z}from"./chunk-ZNTHS7QL.js";import{a as Wn,b as Jn,c as Hn}from"./chunk-UJBDZYC5.js";import{e as Ct,f as _t}from"./chunk-53ZY7AX4.js";import"./chunk-5ZJO3PQ6.js";import"./chunk-44LJSYN6.js";import"./chunk-66WVYR24.js";import{a as Ne}from"./chunk-2FWFPV5I.js";import{B as Kn,C as Ie,D as Ke,a as He,c as _e,h as se,l as me,n as Se,q as Gn,r as Ge}from"./chunk-7UM6XERA.js";import{a as qn}from"./chunk-2ZPJLBIL.js";import{a as T,d as he}from"./chunk-EQXS7YQT.js";import"./chunk-L3J4STUC.js";import{a as ce}from"./chunk-A3H65TBP.js";import{$a as $n,$b as H,B as tt,Bb as j,C as A,Eb as h,F as Tn,G as we,Gb as u,Hd as Un,J as wn,Jb as vn,Jd as Qn,K as yn,Kd as At,Lc as it,Md as Vt,N as Nn,Na as kn,Nc as Je,Oa as nt,Ob as wt,Oc as pe,Od as ot,Pb as Nt,Q as En,Qb as Et,Ra as An,S as Mt,Sa as l,Ta as f,Tc as Ve,U as ee,Ub as de,Vb as m,Vc as jn,Wb as X,X as pt,Xb as oe,Xc as $e,Y as te,Yb as We,Za as Vn,_ as Fn,_c as F,ac as L,ba as V,bc as G,c as Ce,ca as fe,cb as Rn,cc as Ae,d as Xe,dc as E,e as Mn,eb as S,ec as Ft,ed as Ln,fa as re,fc as le,gc as kt,ia as Q,ib as p,j as ke,ja as ve,kb as gt,m as On,mb as Bn,n as Ze,na as N,nc as y,o as Pn,oc as v,pc as bn,r as d,s as xe,t as gn,tc as be,ua as M,va as O,vb as r,w as ct,wb as a,xb as D,yb as z,zb as Y}from"./chunk-ZCFRJGRH.js";import{a as P,b as R,d as In,j as ft}from"./chunk-LHUGHE24.js";var W=class i{constructor(t,e){this.http=e;this.buyForm=t.group({NewOrderID:[""],Order:t.group({Att:[""],SupplierID:[""],Number:[""],Date:[new Date],ID:[T.GuidEmpty]}),Invoice:t.group({ID:[T.GuidEmpty],Due:[new Date],Tax:[0]}),Payment:t.group({Amount:[0],MethodID:[0],Code:[""],Note:[""]})})}outlet=new me({ID:"",Name:"Choose an Outlet"});dueDays=new me(0);deliveryEntityID=new me(T.GuidEmpty);noteForm=new me({Note:"",TagID:"",Currency:{ID:"",ExchangeRate:0,Symbol:""},InvoiceNumber:""});discountAndTaxForm=new me({Discount:{Amount:0,Percentage:0},Tax:{ID:"",CalculationTypeName:"",Rate:0,Label:"",Discontinue:!1}});buyForm;setPONumber(t){let e="";if(t.Seed){let n=t.Seed+"";for(;n.length<t.Digit;)n="0"+n;e=T.StringFormat(t.Prefix,n)}this.buyForm.controls.Order.controls.Number.setValue(e)}setDueDateBasedOnDaysDue(t){let e=this.invoiceDate,n=new Date(T.cloneObject(e));n.setDate(n.getDate()+t),this.buyForm.controls.Invoice.controls.Due.setValue(n)}get dueDate(){return this.buyForm.controls.Invoice.controls.Due.value}get invoiceDate(){return this.buyForm.controls.Order.controls.Date.value}setAmount(t){this.buyForm.controls.Payment.controls.Amount.setValue(t)}setPaymentMethodID(t){this.buyForm.controls.Payment.controls.MethodID.setValue(t)}setTaxAmount(t){this.buyForm.controls.Invoice.controls.Tax.setValue(t)}setNewOrderID(t){this.buyForm.controls.NewOrderID.setValue(t)}setTax(t){let e=P({},this.discountAndTaxForm.value.Discount);this.discountAndTaxForm.setValue({Discount:e,Tax:t})}setCurrency(t){let e=this.noteForm.value;this.noteForm.setValue(R(P({},e),{Currency:t}))}setDeliveryEntityID(t){this.deliveryEntityID.setValue(t)}setdueDays(t){this.dueDays.setValue(t)}setBulkOrderForm(t){this.buyForm.controls.Order.setValue(t)}setBulkNoteForm(t){this.noteForm.setValue(t)}setBulkDiscountAndTaxForm(t){this.discountAndTaxForm.setValue(t)}setOutletForm(t){this.outlet.setValue(t)}setBulkInvoice(t){this.buyForm.controls.Invoice.setValue(t)}setBulkPayment(t){this.buyForm.controls.Payment.setValue(t)}resetOutletForm(){this.outlet.setValue({ID:"",Name:"Choose an Outlet"})}resetDueDaysForm(){this.dueDays.setValue(0)}resetDeliveryEntityID(){this.deliveryEntityID.setValue(T.GuidEmpty)}resetNoteForm(){this.noteForm.setValue(R(P({},this.noteForm.value),{Note:"",TagID:"",InvoiceNumber:""}))}resetDiscountAndTaxForm(){let t=this.discountAndTaxForm.value;this.discountAndTaxForm.setValue(R(P({},t),{Discount:{Amount:0,Percentage:0}}))}resetBuyForm(){this.buyForm.reset(),this.buyForm.controls.Invoice.controls.ID.setValue(T.GuidEmpty),this.buyForm.controls.Invoice.controls.Due.setValue(new Date),this.buyForm.controls.Order.controls.Date.setValue(new Date),this.buyForm.controls.Order.controls.ID.setValue(T.GuidEmpty),this.generateNumberOnNewTransaction()}generateNumberOnNewTransaction(){this.http.post("/API/Buy/GenerateNumber",{ID:this.outlet.value.ID}).subscribe(t=>{this.setNewOrderID(T.Guid_NewGuid()),this.buyForm.controls.Order.controls.Number.setValue(t.Number)})}static \u0275fac=function(e){return new(e||i)(Q(Kn),Q(ce))};static \u0275prov=re({token:i,factory:i.\u0275fac,providedIn:"root"})};var ge=class i{entities$;appConfigJSON$;taxes$;currencies$;supplierPOTypes$;predefinedNotes$;denomination$;defaultDueDays$;constructor(t,e){let n=t.get("/API/Buy2/Load").pipe(V(o=>e.setCurrency(o.Currencies.find(s=>s.ID==o.AppConfigJSON.CoreDefaults.CurrencyID))),ee(1));this.denomination$=n.pipe(d(o=>o.Denomination)),this.entities$=n.pipe(d(o=>o.Entities)),this.appConfigJSON$=n.pipe(d(o=>o.AppConfigJSON)),this.taxes$=n.pipe(d(o=>o.Taxes),ee(1)),this.currencies$=n.pipe(d(o=>o.Currencies),ee(1)),this.supplierPOTypes$=n.pipe(d(o=>o.SupplierPOTypes)),this.predefinedNotes$=n.pipe(d(o=>o.PredefinedNotes)),this.defaultDueDays$=n.pipe(d(o=>o.AppConfigJSON.ModuleBuy.PaymentDialog.DefaultDueDays),V(o=>e.setdueDays(o)),V(o=>e.setDueDateBasedOnDaysDue(o)))}updateDueDays(){this.defaultDueDays$.subscribe()}static \u0275fac=function(e){return new(e||i)(Q(ce),Q(W))};static \u0275prov=re({token:i,factory:i.\u0275fac,providedIn:"root"})};var lt=class i{returnInvoiceNumber=new me("");invoiceInfo$;constructor(t,e,n){let o=e.outlet.valueChanges.pipe(d(c=>c.ID),Z());this.invoiceInfo$=this.returnInvoiceNumber.valueChanges.pipe(A(c=>!!c),fe(o),te(([c,x])=>t.post("/API/Buy/GetSupplierInvoiceRetur2",{EntityID:x,Number:c}).pipe(we(()=>ke))),ee(1),Z());let s=this.invoiceInfo$.pipe(d(c=>P({},c.Order)),V(c=>{let x={Att:c.Att,SupplierID:{Key:c.SupplierID,Value:c.SupplierName,OnSet:!0},Date:new Date,Number:e.buyForm.controls.Order.controls.Number.value,ID:T.GuidEmpty};e.setBulkOrderForm(x)}),Z()),I=this.invoiceInfo$.pipe(d(c=>c.Order),V(c=>{let x={Note:`Return #${c.Number}`,TagID:c.TypeID,Currency:{ID:c.CurrencyID,ExchangeRate:c.CurrencyRate,Symbol:c.CurrencySymbol??"$"},InvoiceNumber:c.Number};e.setBulkNoteForm(x)}),Z()),C=this.invoiceInfo$.pipe(d(c=>c.Order),fe(n.taxes$),d(([c,x])=>R(P({},c),{Tax:x.find(U=>U.ID===c.TaxTypeID)})),V(c=>{let x={Discount:{Amount:c.DiscountAmount,Percentage:c.Discount},Tax:{ID:c.TaxTypeID,Rate:c.Tax?.Rate,CalculationTypeName:c.Tax?.CalculationTypeName,Label:c.Tax?.Label,Discontinue:!c.Tax?.Label}};e.setBulkDiscountAndTaxForm(x)}),Z()),B=this.invoiceInfo$.pipe(d(c=>c.DeliveryEntityID),V(c=>e.setDeliveryEntityID(c)),Z()),J=this.invoiceInfo$.pipe(d(c=>c.Invoice),V(c=>{let x={ID:c.ID,Due:c.Due,Tax:c.Tax};e.setBulkInvoice(x)}),Z()),_=this.invoiceInfo$.pipe(d(c=>c.Payment),V(c=>{let x={Amount:c.Amount,MethodID:c.MethodID,Note:c.Note,Code:c.Code};e.setBulkPayment(x)}),Z());xe(s,I,C,B,J,_).pipe(Z()).subscribe()}static \u0275fac=function(e){return new(e||i)(Q(ce),Q(W),Q(ge))};static \u0275prov=re({token:i,factory:i.\u0275fac,providedIn:"root"})};var ie=class i{constructor(t,e,n,o){this.matDialog=o;let s=e.outlet.valueChanges.pipe(d(c=>c.ID));this.addVariantThroughSerial$=this._addVariantThroughSerial.asObservable().pipe(fe(s),te(([c,x])=>t.get(qe.GetVariantBySerial,[{key:"Serial",value:c},{key:"EntityID",value:x}]).pipe(we(()=>ke))),d(c=>this.setUnitPrice(c)),d(c=>R(P({},c),{Quantity:1,Total:c.UnitPrice,VariantID:c.ID})),d(c=>({action:"addAsSerial",variant:c})));let I=this.variantAutocomplete.valueChanges.pipe(A(c=>T.IsNotEmpty(c)&&c.type=="Code"),d(c=>c.str),fe(s),te(([c,x])=>t.get(qe.GetVariantByCode,[{key:"Code",value:c},{key:"EntityID",value:x},{key:"Promotion",value:!0}]).pipe(we(()=>ke))),d(c=>this.setUnitPrice(c)),d(c=>R(P({},c),{Quantity:1,Total:c.UnitPrice,Discount:c.PriceDiscount,VariantID:c.ID}))),C=this.variantAutocomplete.valueChanges.pipe(A(c=>T.IsNotEmpty(c)&&c.type=="ID"),d(c=>c.str)),B=this.variantQuickKey.valueChanges,J=tt(C,B).pipe(fe(s),te(([c,x])=>t.get(qe.GetVariantByID,[{key:"ID",value:c},{key:"EntityID",value:x}]).pipe(we(()=>ke))),d(c=>this.setUnitPrice(c)),d(c=>R(P({},c),{Quantity:1,Total:c.UnitPrice,Discount:c.OrderPriceDiscount,VariantID:c.ID}))),_=tt(J,I).pipe(d(c=>({action:"add",variant:c}))),k=n.invoiceInfo$.pipe(d(c=>({action:"returnInvoice",variants:c.Items.map(x=>R(P({},x.Variant),{Quantity:x.Quantity,Total:x.Total,UnitPrice:x.UnitPrice,Discount:x.Discount,Serial:x.Serial,ID:x.ID,VariantID:x.VariantID,UnitQuantity:x.UnitQuantity}))})));this.cart$=tt(_,k,this.deleteVariant$,this.dragDropCart$,this.returnCart$,this.updateVariant$,this.returnVariant$,this.purchaseVariant$,this.clearCart$,this.onEditForm$,this.addVariantThroughSerial$,this.addVariant$,this.onUploadCart$,this.listenRFID$).pipe(Mt((c,x)=>{let U=[...c],q=[],g=x.action;if(g=="add"){let b=x.variant;q=!!U.find($=>$.VariantID==b.ID)?U.map($=>$.VariantID==b.ID?R(P({},$),{Quantity:$.Quantity+1,Total:$.Total+$.UnitPrice}):$):[...U,b]}else if(g=="returnInvoice"||g=="onEditForm")q=x.variants;else if(g=="delete"){let b=x.index;q=U.filter((w,$)=>$!=b)}else if(g=="sort"){let b=x.ev;q=U,ni(q,b.previousIndex,b.currentIndex)}else if(g=="returnCart")q=U.map(b=>R(P({},b),{Quantity:-Math.abs(b.Quantity),Total:-Math.abs(b.Total)}));else if(g=="update"){let b=x.index;q=U.map((w,$)=>$==b?x.variant:w)}else if(g=="returnVariant"){let b=x.index;q=U.map((w,$)=>$==b?R(P({},w),{Quantity:-Math.abs(w.Quantity),Total:-Math.abs(w.Total)}):w)}else if(g=="purchaseVariant"){let b=x.index;q=U.map((w,$)=>$==b?R(P({},w),{Quantity:Math.abs(w.Quantity),Total:Math.abs(w.Total)}):w)}else if(g=="clearCart")q=[];else if(g=="addAsSerial"){let b=R(P({},x.variant),{Serial:[{Number:x.variant.Serial.Number,Quantity:1,ExpiryDate:x.variant.Serial.ExpiryDate}]});if(!!U.find($=>$.ID==b.ID)){let $=b.Serial[0],Fe=U.find(ue=>ue.ID==b.ID),Tt=!!Fe.Serial.find(ue=>ue.Number==$.Number)?[...Fe.Serial].map(ue=>ue.Number==$.Number?R(P({},ue),{Quantity:ue.Quantity+1}):ue):[...Fe.Serial,$];q=U.map(ue=>ue.ID==b.ID?R(P({},ue),{Quantity:ue.Quantity+1,Total:ue.Total+ue.UnitPrice,Serial:Tt}):ue)}else q=[...U,R(P({},b),{Quantity:1,Total:b.UnitPrice})]}else if(g=="uploadCart")q=[...U,...x.variants];else if(g=="addNewRow"){let b=x.variant;q=[...U,b]}else if(g=="rfid"){let b=x.variants;Object.keys(b).forEach(w=>{if(b.hasOwnProperty(w)){let $=b[w];if($&&Object.keys($.variant).length>0){let Fe=U.findIndex(ut=>ut.Code.toLowerCase()===w.toLowerCase());if(Fe!==-1){let ut=Number($.count);U[Fe].Quantity+=ut,U[Fe].Total=+U[Fe].UnitPrice*+U[Fe].Quantity,delete b[w],q=[...U]}else{let ut=$.variant,Tt=Number($.count),ue=this.setUnitPrice(ut),Qi=this.formatItemObject(R(P({},ue),{Quantity:Tt,Total:+ue.UnitPrice*+Tt}));delete b[w],q=[...U,Qi]}}}})}return q},[]),pt([]),ee(1)),this.totalVariantOrdered$=this.cart$.pipe(d(c=>c.map(x=>x.Quantity)),d(c=>c.reduce((x,U)=>x+U,0)),pt(0))}variantAutocomplete=new me;variantQuickKey=new me;_listenRFID=new Ce;listenRFID$=this._listenRFID.asObservable().pipe(d(t=>({action:"rfid",variants:t})));_deleteVariant=new Ce;deleteVariant$=this._deleteVariant.asObservable().pipe(d(t=>({action:"delete",index:t})));_dragDropCart=new Ce;dragDropCart$=this._dragDropCart.asObservable().pipe(d(t=>({action:"sort",ev:t})));_returnCart=new Ce;returnCart$=this._returnCart.asObservable().pipe(d(()=>({action:"returnCart"})));_onEditForm=new Xe(null);onEditForm$=this._onEditForm.asObservable().pipe(A(t=>!!t),d(t=>({action:"onEditForm",variants:t})));_clearCart=new Ce;clearCart$=this._clearCart.asObservable().pipe(d(()=>({action:"clearCart"})));_updateVariant=new Ce;updateVariant$=this._updateVariant.asObservable().pipe(d(t=>({action:"update",variant:t.variant,index:t.index})));_returnVariant=new Ce;returnVariant$=this._returnVariant.asObservable().pipe(d(t=>({action:"returnVariant",index:t})));_purchaseVariant=new Ce;purchaseVariant$=this._purchaseVariant.asObservable().pipe(d(t=>({action:"purchaseVariant",index:t})));_addVariant=new Ce;addVariant$=this._addVariant.asObservable().pipe(d(t=>({action:"addNewRow",variant:t})));_onUploadCart=new Ce;onUploadCart$=this._onUploadCart.asObservable().pipe(d(t=>({action:"uploadCart",variants:t})));cart$;totalVariantOrdered$;_addVariantThroughSerial=new Ce;addVariantThroughSerial$;deleteVariant(t){this._deleteVariant.next(t)}dragDropCart(t){this._dragDropCart.next(t)}returnCart(){this._returnCart.next()}updateVariant(t,e){this._updateVariant.next({variant:t,index:e})}returnVariant(t){this._returnVariant.next(t)}purchaseVariant(t){this._purchaseVariant.next(t)}clearCart(){this._clearCart.next()}editForm(t){this._onEditForm.next(t)}addVariant(t){this._addVariant.next(t)}addVariantThroughSerial(t){this._addVariantThroughSerial.next(t)}uploadCart(t){this._onUploadCart.next(t)}setUnitPrice(t){let e=P({},t);return T.IsNotEmpty(t.OrderPrice)?e.UnitPrice=t.OrderPrice:e.UnitPrice=t.UnitCost,e}formatItemObject=t=>{let o=t,{ID:e}=o,n=In(o,["ID"]);return R(P({},n),{Quantity:n.Quantity??1,Total:n.Total??n.UnitPrice,VariantID:e})};addCartRFID(t){this._listenRFID.next(t)}static \u0275fac=function(e){return new(e||i)(Q(ce),Q(W),Q(lt),Q(ne))};static \u0275prov=re({token:i,factory:i.\u0275fac,providedIn:"root"})};var je=class i{_isEdit=new Ce;isEdit$;id$;isUnpaid$;dialog=ve(ne);constructor(t,e,n,o,s){let I=Ze(t.snapshot.queryParams);this.isEdit$=tt(I.pipe(d(g=>!!g.ID)),this._isEdit.asObservable()).pipe(ee(1)),this.id$=I.pipe(A(g=>g.ID),d(g=>g.ID));let C=this.id$.pipe(te(g=>e.post("/api/Buy2/GetDataByID2",{ID:g})),ee(1)),B=ct(()=>o.entities$).pipe(te(g=>C.pipe(d(b=>[b.Order,g]))),V(([g,b])=>{let w={Att:g.Att,SupplierID:{Key:g.SupplierID,Value:g.SupplierName,OnSet:!0},Date:g.Date,Number:g.Number,ID:g.ID};n.setBulkOrderForm(w)}),V(([g,b])=>{let w=b.find($=>$.ID==g.EntityID);n.setOutletForm(w)})),J=C.pipe(d(g=>g.Items),d(g=>g.map(b=>R(P({},b.Variant),{Quantity:b.Quantity,Total:b.Total,Note:b.Note,UnitPrice:b.UnitPrice,Discount:b.Discount,Serial:b.Serial,ID:b.ID,VariantID:b.VariantID,UnitQuantity:b.UnitQuantity,QtyRequested:b.QtyRequested}))),V(g=>s.editForm(g))),_=ct(()=>o.currencies$).pipe(te(g=>C.pipe(d(b=>[b.Order,g]))),d(([g,b])=>R(P({},g),{Currency:b.find(w=>w.ID===g.CurrencyID)})),V(g=>{let b={Note:g.Note,TagID:g.TypeID,Currency:P({},g.Currency),InvoiceNumber:g.Number};n.setBulkNoteForm(b)})),k=C.pipe(d(g=>g.DeliveryEntityID),V(g=>n.setDeliveryEntityID(g))),c=ct(()=>o.taxes$).pipe(te(g=>C.pipe(d(b=>[b.Order,g]))),d(([g,b])=>R(P({},g),{Taxes:b})),V(g=>{let b=g.Taxes.find($=>$.ID===g.TaxTypeID);b?.Bin&&this.dialog.open(Lt,{id:"ModalInfo",data:{title:"Default Tax Discontinued",message:`
|
|
1
|
+
import{a as Fi}from"./chunk-R7MNJHG3.js";import{a as ki,c as Ai}from"./chunk-UMM22E77.js";import{a as Pi,b as Ti,c as wi,d as Ni,e as Ei,f as Be}from"./chunk-RA5QFXG4.js";import{a as Wt}from"./chunk-GJT6AXWW.js";import"./chunk-Y6WXQQCF.js";import{a as Mi}from"./chunk-773CYXAP.js";import{a as jt}from"./chunk-VW4SD2AJ.js";import{a as fi}from"./chunk-M7GZQQXL.js";import{a as hi,b as Di,c as xi}from"./chunk-WVVQJ47P.js";import{a as Cn}from"./chunk-UU2VZEN6.js";import{b as Ci,c as _i}from"./chunk-YTXHEGOU.js";import"./chunk-Q7FLYTMQ.js";import{a as Si}from"./chunk-DQ6V5VPA.js";import{a as Ii}from"./chunk-DULGEYES.js";import"./chunk-JDTVHKRM.js";import"./chunk-SE7OFLAL.js";import"./chunk-JD3LIVDP.js";import"./chunk-WLRXTHLM.js";import{a as Lt,b as vi,c as bi}from"./chunk-3Q22R3MV.js";import"./chunk-X4G74GI2.js";import{a as Ot}from"./chunk-TSKFNB7J.js";import{a as Ut,b as Qt}from"./chunk-WC6HLOBJ.js";import"./chunk-ZT4UZXP6.js";import{b as ui}from"./chunk-ODWOG6HT.js";import"./chunk-746JNXMK.js";import{d as bt}from"./chunk-GWNB6CTG.js";import"./chunk-MFKUC5BJ.js";import{d as di,e as Bt}from"./chunk-MIJSOT4W.js";import"./chunk-OWK2XW4L.js";import{a as yi}from"./chunk-DKZYNKLJ.js";import{a as Xn}from"./chunk-UDC33BP5.js";import{b as Oi}from"./chunk-GGVPDLR2.js";import"./chunk-TDFBRYNF.js";import{b as gi}from"./chunk-2SKKVXLC.js";import"./chunk-RQPAYSJS.js";import"./chunk-C4SDGOBF.js";import"./chunk-BYXBJQAS.js";import{a as qe}from"./chunk-Q7CBBXN2.js";import"./chunk-WMU7MFFB.js";import"./chunk-ZEVKXLP2.js";import{a as Rt}from"./chunk-ZNVAELC4.js";import"./chunk-DNE54I3O.js";import{a as Zn,b as ei,c as ti}from"./chunk-GBJA64EK.js";import{a as ni,c as ii,e as oi,f as ri}from"./chunk-RGIAK7TL.js";import"./chunk-LH34DZDB.js";import"./chunk-ZH3LHPKO.js";import{a as rt,b as at}from"./chunk-SIEUNTYO.js";import{a as ai,b as li}from"./chunk-RSNQU4HN.js";import{a as zn}from"./chunk-VUGL7GL5.js";import"./chunk-MV3BEGPX.js";import{i as Me,j as Re,k as ne,l as $t,m as Oe,n as Pe,o as Te,p as si,r as ci,s as pi,v as mi}from"./chunk-P3UEOU3P.js";import{Aa as yt,Ba as vt,ua as Yn}from"./chunk-R5NLMT6O.js";import{a as Z}from"./chunk-ZNTHS7QL.js";import{a as Wn,b as Jn,c as Hn}from"./chunk-UJBDZYC5.js";import{e as Ct,f as _t}from"./chunk-53ZY7AX4.js";import"./chunk-5ZJO3PQ6.js";import"./chunk-44LJSYN6.js";import"./chunk-66WVYR24.js";import{a as Ne}from"./chunk-2FWFPV5I.js";import{B as Kn,C as Ie,D as Ke,a as He,c as _e,h as se,l as me,n as Se,q as Gn,r as Ge}from"./chunk-7UM6XERA.js";import{a as qn}from"./chunk-FMIGBC5X.js";import{a as T,d as he}from"./chunk-EQXS7YQT.js";import"./chunk-APAKUF4G.js";import{a as ce}from"./chunk-A3H65TBP.js";import{$a as $n,$b as H,B as tt,Bb as j,C as A,Eb as h,F as Tn,G as we,Gb as u,Hd as Un,J as wn,Jb as vn,Jd as Qn,K as yn,Kd as At,Lc as it,Md as Vt,N as Nn,Na as kn,Nc as Je,Oa as nt,Ob as wt,Oc as pe,Od as ot,Pb as Nt,Q as En,Qb as Et,Ra as An,S as Mt,Sa as l,Ta as f,Tc as Ve,U as ee,Ub as de,Vb as m,Vc as jn,Wb as X,X as pt,Xb as oe,Xc as $e,Y as te,Yb as We,Za as Vn,_ as Fn,_c as F,ac as L,ba as V,bc as G,c as Ce,ca as fe,cb as Rn,cc as Ae,d as Xe,dc as E,e as Mn,eb as S,ec as Ft,ed as Ln,fa as re,fc as le,gc as kt,ia as Q,ib as p,j as ke,ja as ve,kb as gt,m as On,mb as Bn,n as Ze,na as N,nc as y,o as Pn,oc as v,pc as bn,r as d,s as xe,t as gn,tc as be,ua as M,va as O,vb as r,w as ct,wb as a,xb as D,yb as z,zb as Y}from"./chunk-ZCFRJGRH.js";import{a as P,b as R,d as In,j as ft}from"./chunk-LHUGHE24.js";var W=class i{constructor(t,e){this.http=e;this.buyForm=t.group({NewOrderID:[""],Order:t.group({Att:[""],SupplierID:[""],Number:[""],Date:[new Date],ID:[T.GuidEmpty]}),Invoice:t.group({ID:[T.GuidEmpty],Due:[new Date],Tax:[0]}),Payment:t.group({Amount:[0],MethodID:[0],Code:[""],Note:[""]})})}outlet=new me({ID:"",Name:"Choose an Outlet"});dueDays=new me(0);deliveryEntityID=new me(T.GuidEmpty);noteForm=new me({Note:"",TagID:"",Currency:{ID:"",ExchangeRate:0,Symbol:""},InvoiceNumber:""});discountAndTaxForm=new me({Discount:{Amount:0,Percentage:0},Tax:{ID:"",CalculationTypeName:"",Rate:0,Label:"",Discontinue:!1}});buyForm;setPONumber(t){let e="";if(t.Seed){let n=t.Seed+"";for(;n.length<t.Digit;)n="0"+n;e=T.StringFormat(t.Prefix,n)}this.buyForm.controls.Order.controls.Number.setValue(e)}setDueDateBasedOnDaysDue(t){let e=this.invoiceDate,n=new Date(T.cloneObject(e));n.setDate(n.getDate()+t),this.buyForm.controls.Invoice.controls.Due.setValue(n)}get dueDate(){return this.buyForm.controls.Invoice.controls.Due.value}get invoiceDate(){return this.buyForm.controls.Order.controls.Date.value}setAmount(t){this.buyForm.controls.Payment.controls.Amount.setValue(t)}setPaymentMethodID(t){this.buyForm.controls.Payment.controls.MethodID.setValue(t)}setTaxAmount(t){this.buyForm.controls.Invoice.controls.Tax.setValue(t)}setNewOrderID(t){this.buyForm.controls.NewOrderID.setValue(t)}setTax(t){let e=P({},this.discountAndTaxForm.value.Discount);this.discountAndTaxForm.setValue({Discount:e,Tax:t})}setCurrency(t){let e=this.noteForm.value;this.noteForm.setValue(R(P({},e),{Currency:t}))}setDeliveryEntityID(t){this.deliveryEntityID.setValue(t)}setdueDays(t){this.dueDays.setValue(t)}setBulkOrderForm(t){this.buyForm.controls.Order.setValue(t)}setBulkNoteForm(t){this.noteForm.setValue(t)}setBulkDiscountAndTaxForm(t){this.discountAndTaxForm.setValue(t)}setOutletForm(t){this.outlet.setValue(t)}setBulkInvoice(t){this.buyForm.controls.Invoice.setValue(t)}setBulkPayment(t){this.buyForm.controls.Payment.setValue(t)}resetOutletForm(){this.outlet.setValue({ID:"",Name:"Choose an Outlet"})}resetDueDaysForm(){this.dueDays.setValue(0)}resetDeliveryEntityID(){this.deliveryEntityID.setValue(T.GuidEmpty)}resetNoteForm(){this.noteForm.setValue(R(P({},this.noteForm.value),{Note:"",TagID:"",InvoiceNumber:""}))}resetDiscountAndTaxForm(){let t=this.discountAndTaxForm.value;this.discountAndTaxForm.setValue(R(P({},t),{Discount:{Amount:0,Percentage:0}}))}resetBuyForm(){this.buyForm.reset(),this.buyForm.controls.Invoice.controls.ID.setValue(T.GuidEmpty),this.buyForm.controls.Invoice.controls.Due.setValue(new Date),this.buyForm.controls.Order.controls.Date.setValue(new Date),this.buyForm.controls.Order.controls.ID.setValue(T.GuidEmpty),this.generateNumberOnNewTransaction()}generateNumberOnNewTransaction(){this.http.post("/API/Buy/GenerateNumber",{ID:this.outlet.value.ID}).subscribe(t=>{this.setNewOrderID(T.Guid_NewGuid()),this.buyForm.controls.Order.controls.Number.setValue(t.Number)})}static \u0275fac=function(e){return new(e||i)(Q(Kn),Q(ce))};static \u0275prov=re({token:i,factory:i.\u0275fac,providedIn:"root"})};var ge=class i{entities$;appConfigJSON$;taxes$;currencies$;supplierPOTypes$;predefinedNotes$;denomination$;defaultDueDays$;constructor(t,e){let n=t.get("/API/Buy2/Load").pipe(V(o=>e.setCurrency(o.Currencies.find(s=>s.ID==o.AppConfigJSON.CoreDefaults.CurrencyID))),ee(1));this.denomination$=n.pipe(d(o=>o.Denomination)),this.entities$=n.pipe(d(o=>o.Entities)),this.appConfigJSON$=n.pipe(d(o=>o.AppConfigJSON)),this.taxes$=n.pipe(d(o=>o.Taxes),ee(1)),this.currencies$=n.pipe(d(o=>o.Currencies),ee(1)),this.supplierPOTypes$=n.pipe(d(o=>o.SupplierPOTypes)),this.predefinedNotes$=n.pipe(d(o=>o.PredefinedNotes)),this.defaultDueDays$=n.pipe(d(o=>o.AppConfigJSON.ModuleBuy.PaymentDialog.DefaultDueDays),V(o=>e.setdueDays(o)),V(o=>e.setDueDateBasedOnDaysDue(o)))}updateDueDays(){this.defaultDueDays$.subscribe()}static \u0275fac=function(e){return new(e||i)(Q(ce),Q(W))};static \u0275prov=re({token:i,factory:i.\u0275fac,providedIn:"root"})};var lt=class i{returnInvoiceNumber=new me("");invoiceInfo$;constructor(t,e,n){let o=e.outlet.valueChanges.pipe(d(c=>c.ID),Z());this.invoiceInfo$=this.returnInvoiceNumber.valueChanges.pipe(A(c=>!!c),fe(o),te(([c,x])=>t.post("/API/Buy/GetSupplierInvoiceRetur2",{EntityID:x,Number:c}).pipe(we(()=>ke))),ee(1),Z());let s=this.invoiceInfo$.pipe(d(c=>P({},c.Order)),V(c=>{let x={Att:c.Att,SupplierID:{Key:c.SupplierID,Value:c.SupplierName,OnSet:!0},Date:new Date,Number:e.buyForm.controls.Order.controls.Number.value,ID:T.GuidEmpty};e.setBulkOrderForm(x)}),Z()),I=this.invoiceInfo$.pipe(d(c=>c.Order),V(c=>{let x={Note:`Return #${c.Number}`,TagID:c.TypeID,Currency:{ID:c.CurrencyID,ExchangeRate:c.CurrencyRate,Symbol:c.CurrencySymbol??"$"},InvoiceNumber:c.Number};e.setBulkNoteForm(x)}),Z()),C=this.invoiceInfo$.pipe(d(c=>c.Order),fe(n.taxes$),d(([c,x])=>R(P({},c),{Tax:x.find(U=>U.ID===c.TaxTypeID)})),V(c=>{let x={Discount:{Amount:c.DiscountAmount,Percentage:c.Discount},Tax:{ID:c.TaxTypeID,Rate:c.Tax?.Rate,CalculationTypeName:c.Tax?.CalculationTypeName,Label:c.Tax?.Label,Discontinue:!c.Tax?.Label}};e.setBulkDiscountAndTaxForm(x)}),Z()),B=this.invoiceInfo$.pipe(d(c=>c.DeliveryEntityID),V(c=>e.setDeliveryEntityID(c)),Z()),J=this.invoiceInfo$.pipe(d(c=>c.Invoice),V(c=>{let x={ID:c.ID,Due:c.Due,Tax:c.Tax};e.setBulkInvoice(x)}),Z()),_=this.invoiceInfo$.pipe(d(c=>c.Payment),V(c=>{let x={Amount:c.Amount,MethodID:c.MethodID,Note:c.Note,Code:c.Code};e.setBulkPayment(x)}),Z());xe(s,I,C,B,J,_).pipe(Z()).subscribe()}static \u0275fac=function(e){return new(e||i)(Q(ce),Q(W),Q(ge))};static \u0275prov=re({token:i,factory:i.\u0275fac,providedIn:"root"})};var ie=class i{constructor(t,e,n,o){this.matDialog=o;let s=e.outlet.valueChanges.pipe(d(c=>c.ID));this.addVariantThroughSerial$=this._addVariantThroughSerial.asObservable().pipe(fe(s),te(([c,x])=>t.get(qe.GetVariantBySerial,[{key:"Serial",value:c},{key:"EntityID",value:x}]).pipe(we(()=>ke))),d(c=>this.setUnitPrice(c)),d(c=>R(P({},c),{Quantity:1,Total:c.UnitPrice,VariantID:c.ID})),d(c=>({action:"addAsSerial",variant:c})));let I=this.variantAutocomplete.valueChanges.pipe(A(c=>T.IsNotEmpty(c)&&c.type=="Code"),d(c=>c.str),fe(s),te(([c,x])=>t.get(qe.GetVariantByCode,[{key:"Code",value:c},{key:"EntityID",value:x},{key:"Promotion",value:!0}]).pipe(we(()=>ke))),d(c=>this.setUnitPrice(c)),d(c=>R(P({},c),{Quantity:1,Total:c.UnitPrice,Discount:c.PriceDiscount,VariantID:c.ID}))),C=this.variantAutocomplete.valueChanges.pipe(A(c=>T.IsNotEmpty(c)&&c.type=="ID"),d(c=>c.str)),B=this.variantQuickKey.valueChanges,J=tt(C,B).pipe(fe(s),te(([c,x])=>t.get(qe.GetVariantByID,[{key:"ID",value:c},{key:"EntityID",value:x}]).pipe(we(()=>ke))),d(c=>this.setUnitPrice(c)),d(c=>R(P({},c),{Quantity:1,Total:c.UnitPrice,Discount:c.OrderPriceDiscount,VariantID:c.ID}))),_=tt(J,I).pipe(d(c=>({action:"add",variant:c}))),k=n.invoiceInfo$.pipe(d(c=>({action:"returnInvoice",variants:c.Items.map(x=>R(P({},x.Variant),{Quantity:x.Quantity,Total:x.Total,UnitPrice:x.UnitPrice,Discount:x.Discount,Serial:x.Serial,ID:x.ID,VariantID:x.VariantID,UnitQuantity:x.UnitQuantity}))})));this.cart$=tt(_,k,this.deleteVariant$,this.dragDropCart$,this.returnCart$,this.updateVariant$,this.returnVariant$,this.purchaseVariant$,this.clearCart$,this.onEditForm$,this.addVariantThroughSerial$,this.addVariant$,this.onUploadCart$,this.listenRFID$).pipe(Mt((c,x)=>{let U=[...c],q=[],g=x.action;if(g=="add"){let b=x.variant;q=!!U.find($=>$.VariantID==b.ID)?U.map($=>$.VariantID==b.ID?R(P({},$),{Quantity:$.Quantity+1,Total:$.Total+$.UnitPrice}):$):[...U,b]}else if(g=="returnInvoice"||g=="onEditForm")q=x.variants;else if(g=="delete"){let b=x.index;q=U.filter((w,$)=>$!=b)}else if(g=="sort"){let b=x.ev;q=U,ni(q,b.previousIndex,b.currentIndex)}else if(g=="returnCart")q=U.map(b=>R(P({},b),{Quantity:-Math.abs(b.Quantity),Total:-Math.abs(b.Total)}));else if(g=="update"){let b=x.index;q=U.map((w,$)=>$==b?x.variant:w)}else if(g=="returnVariant"){let b=x.index;q=U.map((w,$)=>$==b?R(P({},w),{Quantity:-Math.abs(w.Quantity),Total:-Math.abs(w.Total)}):w)}else if(g=="purchaseVariant"){let b=x.index;q=U.map((w,$)=>$==b?R(P({},w),{Quantity:Math.abs(w.Quantity),Total:Math.abs(w.Total)}):w)}else if(g=="clearCart")q=[];else if(g=="addAsSerial"){let b=R(P({},x.variant),{Serial:[{Number:x.variant.Serial.Number,Quantity:1,ExpiryDate:x.variant.Serial.ExpiryDate}]});if(!!U.find($=>$.ID==b.ID)){let $=b.Serial[0],Fe=U.find(ue=>ue.ID==b.ID),Tt=!!Fe.Serial.find(ue=>ue.Number==$.Number)?[...Fe.Serial].map(ue=>ue.Number==$.Number?R(P({},ue),{Quantity:ue.Quantity+1}):ue):[...Fe.Serial,$];q=U.map(ue=>ue.ID==b.ID?R(P({},ue),{Quantity:ue.Quantity+1,Total:ue.Total+ue.UnitPrice,Serial:Tt}):ue)}else q=[...U,R(P({},b),{Quantity:1,Total:b.UnitPrice})]}else if(g=="uploadCart")q=[...U,...x.variants];else if(g=="addNewRow"){let b=x.variant;q=[...U,b]}else if(g=="rfid"){let b=x.variants;Object.keys(b).forEach(w=>{if(b.hasOwnProperty(w)){let $=b[w];if($&&Object.keys($.variant).length>0){let Fe=U.findIndex(ut=>ut.Code.toLowerCase()===w.toLowerCase());if(Fe!==-1){let ut=Number($.count);U[Fe].Quantity+=ut,U[Fe].Total=+U[Fe].UnitPrice*+U[Fe].Quantity,delete b[w],q=[...U]}else{let ut=$.variant,Tt=Number($.count),ue=this.setUnitPrice(ut),Qi=this.formatItemObject(R(P({},ue),{Quantity:Tt,Total:+ue.UnitPrice*+Tt}));delete b[w],q=[...U,Qi]}}}})}return q},[]),pt([]),ee(1)),this.totalVariantOrdered$=this.cart$.pipe(d(c=>c.map(x=>x.Quantity)),d(c=>c.reduce((x,U)=>x+U,0)),pt(0))}variantAutocomplete=new me;variantQuickKey=new me;_listenRFID=new Ce;listenRFID$=this._listenRFID.asObservable().pipe(d(t=>({action:"rfid",variants:t})));_deleteVariant=new Ce;deleteVariant$=this._deleteVariant.asObservable().pipe(d(t=>({action:"delete",index:t})));_dragDropCart=new Ce;dragDropCart$=this._dragDropCart.asObservable().pipe(d(t=>({action:"sort",ev:t})));_returnCart=new Ce;returnCart$=this._returnCart.asObservable().pipe(d(()=>({action:"returnCart"})));_onEditForm=new Xe(null);onEditForm$=this._onEditForm.asObservable().pipe(A(t=>!!t),d(t=>({action:"onEditForm",variants:t})));_clearCart=new Ce;clearCart$=this._clearCart.asObservable().pipe(d(()=>({action:"clearCart"})));_updateVariant=new Ce;updateVariant$=this._updateVariant.asObservable().pipe(d(t=>({action:"update",variant:t.variant,index:t.index})));_returnVariant=new Ce;returnVariant$=this._returnVariant.asObservable().pipe(d(t=>({action:"returnVariant",index:t})));_purchaseVariant=new Ce;purchaseVariant$=this._purchaseVariant.asObservable().pipe(d(t=>({action:"purchaseVariant",index:t})));_addVariant=new Ce;addVariant$=this._addVariant.asObservable().pipe(d(t=>({action:"addNewRow",variant:t})));_onUploadCart=new Ce;onUploadCart$=this._onUploadCart.asObservable().pipe(d(t=>({action:"uploadCart",variants:t})));cart$;totalVariantOrdered$;_addVariantThroughSerial=new Ce;addVariantThroughSerial$;deleteVariant(t){this._deleteVariant.next(t)}dragDropCart(t){this._dragDropCart.next(t)}returnCart(){this._returnCart.next()}updateVariant(t,e){this._updateVariant.next({variant:t,index:e})}returnVariant(t){this._returnVariant.next(t)}purchaseVariant(t){this._purchaseVariant.next(t)}clearCart(){this._clearCart.next()}editForm(t){this._onEditForm.next(t)}addVariant(t){this._addVariant.next(t)}addVariantThroughSerial(t){this._addVariantThroughSerial.next(t)}uploadCart(t){this._onUploadCart.next(t)}setUnitPrice(t){let e=P({},t);return T.IsNotEmpty(t.OrderPrice)?e.UnitPrice=t.OrderPrice:e.UnitPrice=t.UnitCost,e}formatItemObject=t=>{let o=t,{ID:e}=o,n=In(o,["ID"]);return R(P({},n),{Quantity:n.Quantity??1,Total:n.Total??n.UnitPrice,VariantID:e})};addCartRFID(t){this._listenRFID.next(t)}static \u0275fac=function(e){return new(e||i)(Q(ce),Q(W),Q(lt),Q(ne))};static \u0275prov=re({token:i,factory:i.\u0275fac,providedIn:"root"})};var je=class i{_isEdit=new Ce;isEdit$;id$;isUnpaid$;dialog=ve(ne);constructor(t,e,n,o,s){let I=Ze(t.snapshot.queryParams);this.isEdit$=tt(I.pipe(d(g=>!!g.ID)),this._isEdit.asObservable()).pipe(ee(1)),this.id$=I.pipe(A(g=>g.ID),d(g=>g.ID));let C=this.id$.pipe(te(g=>e.post("/api/Buy2/GetDataByID2",{ID:g})),ee(1)),B=ct(()=>o.entities$).pipe(te(g=>C.pipe(d(b=>[b.Order,g]))),V(([g,b])=>{let w={Att:g.Att,SupplierID:{Key:g.SupplierID,Value:g.SupplierName,OnSet:!0},Date:g.Date,Number:g.Number,ID:g.ID};n.setBulkOrderForm(w)}),V(([g,b])=>{let w=b.find($=>$.ID==g.EntityID);n.setOutletForm(w)})),J=C.pipe(d(g=>g.Items),d(g=>g.map(b=>R(P({},b.Variant),{Quantity:b.Quantity,Total:b.Total,Note:b.Note,UnitPrice:b.UnitPrice,Discount:b.Discount,Serial:b.Serial,ID:b.ID,VariantID:b.VariantID,UnitQuantity:b.UnitQuantity,QtyRequested:b.QtyRequested}))),V(g=>s.editForm(g))),_=ct(()=>o.currencies$).pipe(te(g=>C.pipe(d(b=>[b.Order,g]))),d(([g,b])=>R(P({},g),{Currency:b.find(w=>w.ID===g.CurrencyID)})),V(g=>{let b={Note:g.Note,TagID:g.TypeID,Currency:P({},g.Currency),InvoiceNumber:g.Number};n.setBulkNoteForm(b)})),k=C.pipe(d(g=>g.DeliveryEntityID),V(g=>n.setDeliveryEntityID(g))),c=ct(()=>o.taxes$).pipe(te(g=>C.pipe(d(b=>[b.Order,g]))),d(([g,b])=>R(P({},g),{Taxes:b})),V(g=>{let b=g.Taxes.find($=>$.ID===g.TaxTypeID);b?.Bin&&this.dialog.open(Lt,{id:"ModalInfo",data:{title:"Default Tax Discontinued",message:`
|
|
2
2
|
<div class="d-flex justify-content-center my-4">
|
|
3
3
|
<img class="img-2x" src="https://res.cloudinary.com/pos/image/upload/v1705387550/POS/Images/Cashier/globalerror.svg"
|
|
4
4
|
alt="Empty Sales Order Tag" />
|