dealpos 25.49.5 → 25.50.0
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/browser/{chunk-D3QY3EBZ.js → chunk-2ENLMKGR.js} +1 -1
- package/browser/{chunk-SMDHPNT7.js → chunk-2FJNMKCN.js} +1 -1
- package/browser/{chunk-OZLXHOG4.js → chunk-2ITJBRJU.js} +1 -1
- package/browser/{chunk-72YVHXTD.js → chunk-2KI73XNT.js} +1 -1
- package/browser/{chunk-YZCJFJZL.js → chunk-2SZZVWQD.js} +11 -11
- package/browser/{chunk-FXPNLU4X.js → chunk-3AZAILT2.js} +1 -1
- package/browser/{chunk-FQNL3TLZ.js → chunk-3CUT73ZP.js} +1 -1
- package/browser/{chunk-IK4DEQSO.js → chunk-3ZWJMFYL.js} +1 -1
- package/browser/{chunk-NPQFE4EO.js → chunk-4KYROBKJ.js} +1 -1
- package/browser/{chunk-6ESMI6WH.js → chunk-4MQZXTMM.js} +1 -1
- package/browser/{chunk-55DB5BOP.js → chunk-4YZVDERU.js} +1 -1
- package/browser/{chunk-PXFCSUBN.js → chunk-5SIEW7SH.js} +1 -1
- package/browser/{chunk-FHL5KFJX.js → chunk-7L5VMLEF.js} +1 -1
- package/browser/{chunk-MFNPIWGR.js → chunk-7MJWZXSK.js} +2 -2
- package/browser/{chunk-R546P6WC.js → chunk-A5CTHLE4.js} +1 -1
- package/browser/{chunk-BEIHC6NO.js → chunk-A6Z5ZHVO.js} +1 -1
- package/browser/{chunk-SRAJGU6Y.js → chunk-B7BVEOOI.js} +1 -1
- package/browser/{chunk-YVO66RJF.js → chunk-BFNGPKGX.js} +1 -1
- package/browser/{chunk-BGT22RIZ.js → chunk-BLEJLNEO.js} +1 -1
- package/browser/{chunk-GIPUEMTC.js → chunk-BQ7QT5RB.js} +1 -1
- package/browser/chunk-BZ3GMUQ7.js +14 -0
- package/browser/{chunk-G5NXVDID.js → chunk-CB6QEEJX.js} +1 -1
- package/browser/{chunk-63B7VXCP.js → chunk-CCJ6SHBL.js} +1 -1
- package/browser/{chunk-TXPKRCHR.js → chunk-COL56R4A.js} +1 -1
- package/browser/chunk-CXWICNFP.js +1 -0
- package/browser/{chunk-7MMDSCS7.js → chunk-CZHWPDAM.js} +1 -1
- package/browser/{chunk-WW4UBOYF.js → chunk-DYBRYTEM.js} +1 -1
- package/browser/chunk-EAEOJMTA.js +4 -0
- package/browser/{chunk-T6SZ4L7O.js → chunk-F765TCAS.js} +1 -1
- package/browser/{chunk-EV422BEJ.js → chunk-FMKY4THI.js} +1 -1
- package/browser/{chunk-MVJSAD2O.js → chunk-FSOHJLXB.js} +1 -1
- package/browser/{chunk-FBHH3WPM.js → chunk-FV4MYFQI.js} +1 -1
- package/browser/{chunk-5QMBTXFS.js → chunk-G3DZI5XK.js} +1 -1
- package/browser/{chunk-FBN34CVL.js → chunk-G5JGQBAG.js} +1 -1
- package/browser/{chunk-Q3FMCFAP.js → chunk-GBSRXCWH.js} +1 -1
- package/browser/{chunk-MOXEW4DH.js → chunk-GDQGP7DV.js} +1 -1
- package/browser/{chunk-NENPGICH.js → chunk-GESNWWTD.js} +2 -2
- package/browser/{chunk-BCGIIVLI.js → chunk-GRLVYPPM.js} +1 -1
- package/browser/{chunk-234VD4PN.js → chunk-HFDJ5XSI.js} +1 -1
- package/browser/{chunk-H6UWRJHQ.js → chunk-HFOJZ3B5.js} +1 -1
- package/browser/{chunk-WVMPGK5K.js → chunk-HFZ437GH.js} +1 -1
- package/browser/{chunk-Z3UTJURO.js → chunk-IPPIH4F4.js} +1 -1
- package/browser/{chunk-AGJ3GOR7.js → chunk-ISN5K6K2.js} +1 -1
- package/browser/{chunk-QHP7VC2R.js → chunk-ISQHQTAS.js} +1 -1
- package/browser/chunk-JCLYKROE.js +1 -0
- package/browser/chunk-KUF3JPB2.js +1 -0
- package/browser/{chunk-Y7D34HYN.js → chunk-KZBVWICA.js} +1 -1
- package/browser/{chunk-2M6MJMM7.js → chunk-LIX7XJ55.js} +1 -1
- package/browser/{chunk-DG6Y623Z.js → chunk-LIXEWT4U.js} +3 -3
- package/browser/{chunk-3ZZJHIUG.js → chunk-M2HEFQUY.js} +1 -1
- package/browser/{chunk-UNZLSKV5.js → chunk-MFJH22SW.js} +1 -1
- package/browser/{chunk-Y67EVUWI.js → chunk-MZSJCSUV.js} +2 -2
- package/browser/{chunk-VFQES62Q.js → chunk-O3ENARQZ.js} +1 -1
- package/browser/{chunk-PFF34SZG.js → chunk-OZ3MKU4C.js} +1 -1
- package/browser/chunk-PHYDJ3P5.js +1 -0
- package/browser/{chunk-N5IOOG55.js → chunk-PIAQ4TBN.js} +1 -1
- package/browser/{chunk-OUOI5WK2.js → chunk-PLR55YR2.js} +1 -1
- package/browser/chunk-PMDFKXZY.js +1 -0
- package/browser/{chunk-LJJMNCST.js → chunk-PV4YHZX5.js} +1 -1
- package/browser/chunk-PVBS6SYW.js +3 -0
- package/browser/{chunk-IDZHSRCH.js → chunk-PXIMA665.js} +2 -2
- package/browser/{chunk-P75DFAMB.js → chunk-Q3DS2RLM.js} +1 -1
- package/browser/chunk-QWB3USYP.js +3 -0
- package/browser/{chunk-QLMHWHUW.js → chunk-QZRMHLML.js} +1 -1
- package/browser/{chunk-Y7KMZ7BT.js → chunk-RE6SQEP6.js} +1 -1
- package/browser/{chunk-LSC2CYCL.js → chunk-S4D5UGSM.js} +1 -1
- package/browser/{chunk-CIJROL7R.js → chunk-S65MPEJS.js} +1 -1
- package/browser/{chunk-P6DRDJVZ.js → chunk-SBTTKQ4L.js} +1 -1
- package/browser/{chunk-3SIDOYEU.js → chunk-SK6Y77W4.js} +4 -4
- package/browser/{chunk-G6PEAZWA.js → chunk-SOW7VMSU.js} +1 -1
- package/browser/{chunk-OOKDKXRB.js → chunk-T3ZHKT2K.js} +1 -1
- package/browser/{chunk-6G74X2UP.js → chunk-T7PBUS2H.js} +1 -1
- package/browser/{chunk-NKQHQCUV.js → chunk-TTCSYFRX.js} +1 -1
- package/browser/{chunk-CNHLZU3Z.js → chunk-UZN4OKOJ.js} +2 -2
- package/browser/{chunk-DYI547BZ.js → chunk-WXYXGYFH.js} +1 -1
- package/browser/{chunk-IRQYLVRP.js → chunk-X2GHGFH2.js} +2 -2
- package/browser/{chunk-5YHDDJI4.js → chunk-XFAV2VZL.js} +1 -1
- package/browser/{chunk-U57PBUPN.js → chunk-XSZJISVJ.js} +1 -1
- package/browser/{chunk-7PVAZYM4.js → chunk-Y5DX5U5Q.js} +1 -1
- package/browser/{chunk-7SAEXKAX.js → chunk-Y7KCHRMM.js} +1 -1
- package/browser/{chunk-A4Y2ZLGW.js → chunk-YBUERVXV.js} +1 -1
- package/browser/{chunk-LC7GFFEX.js → chunk-YLEKN2EU.js} +1 -1
- package/browser/{chunk-RJNG3PZF.js → chunk-YUILNWDI.js} +1 -1
- package/browser/index.html +2 -2
- package/browser/{main-FS6A5G45.js → main-4PHVOJ3C.js} +2 -2
- package/package.json +1 -1
- package/browser/chunk-6UC76HYF.js +0 -4
- package/browser/chunk-CEVAKZDN.js +0 -3
- package/browser/chunk-CLWGVNBY.js +0 -14
- package/browser/chunk-D3KDSFJU.js +0 -1
- package/browser/chunk-DHKZDGY6.js +0 -1
- package/browser/chunk-GLOUVXOJ.js +0 -1
- package/browser/chunk-RXPEUS2G.js +0 -3
- package/browser/chunk-V3FPQMVB.js +0 -1
- package/browser/chunk-WXEEGAH5.js +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{a as xo}from"./chunk-YXCPHYC5.js";import{a as zt,b as Yt}from"./chunk-JFLT7NX3.js";import{a as Bo}from"./chunk-RACYAEOL.js";import{a as Di}from"./chunk-GGDW5WFA.js";import{e as wo}from"./chunk-QJUU75N6.js";import{b as ko}from"./chunk-D7DUI5NF.js";import{d as Ao}from"./chunk-TXJJUZ26.js";import{a as No}from"./chunk-BNNKSBQ6.js";import{a as Io}from"./chunk-IZLEZJ6U.js";import{a as he,b as Re,e as Lo}from"./chunk-4XJWQAS6.js";import{b as Eo}from"./chunk-DC3TCY6D.js";import{a as Do,b as Vo,c as Fo}from"./chunk-CQLZHUT4.js";import{a as Mo}from"./chunk-S27D5MBU.js";import{a as jo}from"./chunk-HGSF7LOB.js";import{c as Dn,d as Oo}from"./chunk-7BVPHIEF.js";import{a as xt}from"./chunk-25H27N7N.js";import{a as lo}from"./chunk-T7XU5W5A.js";import{a as To}from"./chunk-MNJSQKLX.js";import{a as Mi,b as xi,c as Ii}from"./chunk-OXWQ7ZZS.js";import{a as Ro}from"./chunk-4CPRMZL6.js";import{a as Ho}from"./chunk-ESDXMFGP.js";import{a as Ke}from"./chunk-J6U6UYNI.js";import{a as tt,b as mt,c as me}from"./chunk-NSNUUKNK.js";import{a as Oi,b as xe}from"./chunk-EN2Y56CS.js";import{a as Pn,b as Jt,c as On}from"./chunk-PXDS3HXW.js";import{b as Po}from"./chunk-WKM2QOAU.js";import{a as So}from"./chunk-ZMJLTU5O.js";import{g as bo}from"./chunk-PRVQ3NAP.js";import{d as Pi}from"./chunk-WMZLH4YK.js";import{p as mo}from"./chunk-6WATOQG3.js";import{d as co}from"./chunk-XTCEZONP.js";import{a as go,c as Dt}from"./chunk-D4FCXEV4.js";import{g as po}from"./chunk-6P2ASCNY.js";import{B as _o,C as oe,D as Oe,G as yo,u as ie,v as ne,w as Ot}from"./chunk-26YFRPR2.js";import{b as yi,c as $t}from"./chunk-JBS5UYZC.js";import{F as Mt,N as Si,O as U,g as fo,n as bi,o as ho,q as Co,t as vo}from"./chunk-TEGIL5RZ.js";import{a as rt}from"./chunk-B7AC4RMR.js";import{a as fi,c as hi}from"./chunk-EQLHPWVB.js";import{d as Pt,e as uo}from"./chunk-THT6CY5E.js";import{a as ee,b as so,e as te,f as fe,g as we}from"./chunk-ZTD4APMR.js";import{a as de}from"./chunk-2FWFPV5I.js";import{A as ro,B as ao,F as vi,c as Te,e as Ci,h as Pe,i as Xn,k as eo,l as et,n as to,o as Ee,p as io,s as St,x as no,y as oo}from"./chunk-DWZ5JTI2.js";import{b as _i}from"./chunk-WFQIMZGL.js";import{a as f}from"./chunk-WUV22SZ4.js";import{a as Zn}from"./chunk-6UC76HYF.js";import{p as F,s as ge}from"./chunk-LGOSIAUC.js";import{$ as li,Ab as C,Bb as ot,Bc as jn,Ca as R,Cb as ve,Db as K,E as ce,Eb as Z,Fb as p,Fc as y,Gb as a,Gc as x,Gd as $n,Hb as s,Hc as X,I as nt,Ib as b,Ic as yt,Jb as V,Kb as Q,Kd as Jn,Lb as Xe,Lc as Qn,M as ht,Mb as Ct,N as Qe,Nb as vt,Ob as pi,Oc as ae,Pb as E,Pd as zn,Q as Fe,Qa as Je,Qb as Fn,Qd as Yn,Sa as dt,Sb as S,Sc as bt,Sd as Kn,Ta as Vn,Tb as Ln,Tc as qt,Ub as m,Xa as l,Xc as gi,Y as Le,Yb as Ut,Zb as Wt,_b as Gt,aa as Y,b as ri,cc as ue,d as Me,da as Ie,dc as Bn,e as be,eb as P,fa as le,gc as ui,gd as Be,hc as d,ib as N,ic as M,id as Un,jb as di,jc as D,jd as Wn,k as gt,kc as _t,la as I,lc as Hn,ma as ci,mc as B,md as Gn,n as An,nc as A,nd as qn,o as ke,oa as g,ob as $,oc as H,od as ze,p as ft,pa as T,q as ai,qd as Ye,r as si,sd as q,t as J,ta as v,u as $e,ua as _,v as kn,vd as Se,wb as mi,yb as h,yc as j,zb as Sn,zc as Ue}from"./chunk-IEVGW2RT.js";import{a as ni,i as Ze,k as oi}from"./chunk-SNAKHGZS.js";var We=class{constructor(e){this.roleService=e;e&&this.setRole()}_Retrieve;_DateEditor;_NumberEditor;_PriceVisible;_UnitPriceEditor;_PricebookSelector;_Cost;_Return;_Discount;_SalesPerson;_PriceMinimum;_Payment;_CreditSalesLock;_CustomerInputLock;_PaymentCodeLock;_Shipping;_Tax;_DeleteItem;_BundlingPrice;_EmailRestriction;_ParkedDeletionAuthorized;_SellEditor;_ContactCreate;_PrepaidPackageCreate;_Order;_Reprint;_Contacts;_ContactsCreate;_InventoryView;_DebtView;_ClearCart;_SellDelete;_DeliveryEditor;_CouponInputLock;_Park;_Commission;setRole(){this._Retrieve=this.roleService.sell.RetrieveR,this._DateEditor=this.roleService.global.Date,this._NumberEditor=this.roleService.sell.Number,this._PriceVisible=this.roleService.sell.PriceVisible,this._SalesPerson=this.roleService.sell.SalesPerson,this._UnitPriceEditor=this.roleService.sell.UnitPriceEditor,this._PricebookSelector=this.roleService.sell.PricebookSelector,this._Cost=this.roleService.product.Cost,this._Return=this.roleService.sell.Return,this._Discount=this.roleService.sell.Discount,this._PriceMinimum=this.roleService.sell.PriceMinimum,this._Payment=this.roleService.sell.Payment,this._CreditSalesLock=this.roleService.sell.CreditSalesLock,this._CustomerInputLock=this.roleService.sell.CustomerInputLock,this._PaymentCodeLock=this.roleService.sell.PaymentCodeLock,this._Shipping=this.roleService.sell.Shipping,this._Tax=this.roleService.sell.Tax,this._DeleteItem=this.roleService.sell.DeleteItem,this._BundlingPrice=this.roleService.sell.BundlingPrice,this._EmailRestriction=this.roleService.sell.Email,this._SellEditor=this.roleService.sell.Edit,this._ContactCreate=this.roleService.contact.Create,this._PrepaidPackageCreate=this.roleService.prepaidPackage.Create,this._Order=this.roleService.order.View,this._Contacts=this.roleService.contact.View,this._ContactsCreate=this.roleService.contact.Create,this._InventoryView=this.roleService.inventory.View,this._DebtView=this.roleService.debt.View,this._ClearCart=this.roleService.sell.DeleteItem,this._SellDelete=this.roleService.sell.Delete,this._DeliveryEditor=this.roleService.logistic.Edit,this._Reprint=this.roleService.order.Print,this._CouponInputLock=this.roleService.sell.CouponInputLock,this._Park=this.roleService.sell.Park,this._Commission=this.roleService.product.CommissionView}get Park(){return this._Park}get CouponInputLock(){return this._CouponInputLock}set CouponInputLock(e){this._CouponInputLock=e}get Retrieve(){return this._Retrieve}get DateEditor(){return this._DateEditor}set DateEditor(e){this._DateEditor=e}get NumberEditor(){return this._NumberEditor}set NumberEditor(e){this._NumberEditor=e}get PriceVisible(){return this._PriceVisible}get UnitPriceEditor(){return this._UnitPriceEditor}set UnitPriceEditor(e){this._UnitPriceEditor=e}get PricebookSelector(){return this._PricebookSelector}set PricebookSelector(e){this._PricebookSelector=e}get Cost(){return this._Cost}get Return(){return this._Return}set Return(e){this._Return=e}get Discount(){return this._Discount}set Discount(e){this._Discount=e}get SalesPerson(){return this._SalesPerson}get PriceMinimum(){return this._PriceMinimum}get Payment(){return this._Payment}get CreditSalesLock(){return this._CreditSalesLock}get CustomerInputLock(){return this._CustomerInputLock}get PaymentCodeLock(){return this._PaymentCodeLock}get Shipping(){return this._Shipping}get Tax(){return this._Tax}set Tax(e){this._Tax=e}get DeleteItem(){return this._DeleteItem}set DeleteItem(e){this._DeleteItem=e}get BundlingPrice(){return this._BundlingPrice}get Email(){return this._EmailRestriction}get ParkedDeletionAuthorized(){return this._ParkedDeletionAuthorized}set ParkedDeletionAuthorized(e){this._ParkedDeletionAuthorized=e}get SellEditor(){return this._SellEditor}get PrepaidPackageCreate(){return this._PrepaidPackageCreate}get Order(){return this._Order}get Reprint(){return this._Reprint}get Contacts(){return this._Contacts}get ContactsCreate(){return this._ContactsCreate}get InventoryView(){return this._InventoryView}get DebtView(){return this._DebtView}get ClearCartRestriction(){return this._ClearCart}get SellDelete(){return this._SellDelete}get DeliveryEditor(){return this._DeliveryEditor}get Commission(){return this._Commission}};var Kt=class{DeliveryEntityID;Type;NewOrderID;constructor(){this.DeliveryEntityID="",this.Type=3}};var Ti=class{Type;Amount;Notification;ApplyToProduct;Requirement};var G=class{Order;Invoice;Shipping;Action;Payments;Items;CartItems;Promotion;ContactName;SplitParkLabel;get cartQuantity(){let e=0;for(let t of this.CartItems)e+=t.Quantity;return e}constructor(){this.Order=new Dn,this.Invoice=new Jt,this.Shipping=new On,this.Action=new Kt,this.Payments=Array(),this.Items=Array(),this.CartItems=Array(),this.ContactName=""}get TotalPaidAmount(){let e=0;return this.Payments.forEach(t=>{e+=t.PaidAmount}),e}get RedeemableAmount(){let e=this.CartItems.filter(t=>t.Variant.PaymentTypeID!=1);return this.GetAmountByCart(e)}get TotalQuantity(){let e=0;return this.CartItems.forEach(t=>{t.PromotionGift||(e+=t.Quantity)}),e}get CashOnlyAmount(){let e=this.CartItems.filter(t=>t.Variant.PaymentTypeID==1);return this.GetAmountByCart(e)}get PointOnlyAmount(){let e=this.CartItems.filter(t=>t.Variant.PaymentTypeID==2);return this.GetAmountByCart(e)}get PrepaidPackageItem(){return this.CartItems.filter(t=>t.Variant.TypeID==10)}GetAmountByCart(e){let t=0;return e.forEach(i=>{t+=i.Total}),t=t*(100-this.Order.Discount)/100,t=t*(100-this.Order.Discount2)/100,t}getRewards(){return this.CartItems.filter(t=>t.PromotionGift)}};Ze([tt(()=>Dn)],G.prototype,"Order",2),Ze([tt(()=>Jt)],G.prototype,"Invoice",2),Ze([tt(()=>On)],G.prototype,"Shipping",2),Ze([tt(()=>Kt)],G.prototype,"Action",2),Ze([tt(()=>Ke)],G.prototype,"Payments",2),Ze([tt(()=>Oi)],G.prototype,"Items",2),Ze([tt(()=>xe)],G.prototype,"CartItems",2),Ze([tt(()=>Ti)],G.prototype,"Promotion",2);var Ei=class{Success;Message;message;ObjectID;SalesOrderID;OutDeliveryID;Contact;LoyaltyPoint;InvoiceNumber;Creator;OrderTimeString;PrintMode;PaymentStateID;PaymentStateLabel;Final;InvoiceNumberResult;constructor(){this.Success=!0,this.Message="",this.ObjectID="",this.SalesOrderID="",this.OutDeliveryID="",this.Contact=null,this.LoyaltyPoint="",this.InvoiceNumber="",this.Creator="",this.OrderTimeString="",this.PrintMode=0,this.PaymentStateID=0,this.PaymentStateLabel="",this.Final=0}};var It=class n{constructor(e,t,i,o){this.httpService=e;this._localDataService=t;this._onlineStatusService=i;this._toastrService=o;this._onlineStatusService.getOnlineStatus$().subscribe(r=>{this.isOnline=r})}_Data=new be(null);Data$=this._Data.pipe(Fe(),ce(e=>e!==null));isOnline;get Data(){return this._Data.value}pushNewValue(e){this._Data.next(e)}getSalesOrderPrint(e){return this.httpService.post("/API/POS/GetSalesOrderPrint",{TemplateID:e})}submitOrder(e,t){let i=this.generatePOSDataForSubmission(e,this.isOnline);if(this.isOnline)return this.submitOnline(i).pipe(this.handleTimeOutError(i));if(t.ModuleSell.EnableOfflineTransaction)return this._localDataService.syncOrder(i).pipe(J(()=>this.generateCompleteData(i)));this._toastrService.warning("Offline order is not Supported!","Info!")}uploadOfflineOrder(e){return this._localDataService.uploadSingleOrder(e).pipe(nt(t=>t?.message?.includes("objectStore does not exists")?this.submitOnline(e):ft(()=>t)))}submitOnline(e){return this.httpService.post(U.SubmitOrder,e,Zn.pos.submitOrderTimeout)}handleTimeOutError(e){return ri(nt(t=>{if(t instanceof si||t?.name=="TimeoutError"){let i=this.generateCompleteData(e);this.pushNewValue(i)}throw t}))}generatePOSDataForSubmission(e,t=!0){let i=Object.assign(new G,e);i.Items=[],i.Order.CustomerID==null&&(i.Order.CustomerID=f.GuidEmpty),i.Order.SalesID==null&&(i.Order.SalesID=f.GuidEmpty);let o=1;i.Payments=i.Payments.map(c=>(c.Date=i.Order.Date,c.Index=o,o++,delete c.TypeID,c));let r=1;for(let c of i.CartItems){let u=new Oi;u.ID=c.ID,u.VariantID=c.VariantID,u.Quantity=c.Quantity,u.Cost=c.Cost,u.Price=c.Price,u.Discount=c.Discount,u.DiscountAmount=c.DiscountAmount,u.Note=c.Note,u.Taxable=c.Variant.Taxable,u.LoyaltyPoint=c.LoyaltyPoint,u.UnitCost=c.Cost,u.UnitPrice=c.Price,u.UnitPriceOriginal=c.UnitPriceOriginal,u.UnitExpense=c.UnitExpense,u.EntityID=c.EntityID,u.Index=r,u.UnitQuantity=c.UnitQuantity,u.PriceTypeID=c.PriceTypeID,u.PriceNote=c.PriceNote,u.Splited=c.SplitQuantity>0,u.SplitQuantity=c.SplitQuantity,u.InventoryTypeID=c.Variant.TypeID,u.SalesID="",u.Serial=c.Serial,c.SalesID&&(u.SalesID=c.SalesID),delete c.CouponDiscount,i.Items.push(u),r++}return t?(delete i.CartItems,delete i.Order.ClientTimestamp):i.Order.ClientTimestamp=new Date,i}generateCompleteData(e){let t=new Ei;return t.InvoiceNumber=e.Order.Number,t.OrderTimeString=new Date().toString(),t.PaymentStateID=e.Action?.Type,t.PaymentStateLabel="Offline",t.Success=!0,t.OutDeliveryID=e.Action.DeliveryEntityID,t}GetReturnInvoice(e,t){return this.httpService.get(U.ReturInvoice,[{key:"EntityID",value:t},{key:"Number",value:e}])}GetInvoiceBySoID(e){return this.httpService.get(U.GetPOSDataByID,[{key:"ID",value:e}])}UploadCSV(e,t){let i={CartItems:e,EntityID:t};return this.httpService.post(U.UploadCsv,i)}sendEmail(e,t){return new Promise((i,o)=>{this._localDataService.isProductFromServer().subscribe(r=>{if(r){let c={invoiceID:t,email:e};this.httpService.post(U.SendInvoiceEmail,c).subscribe({next:u=>{i(u)},error:u=>{o(u)}})}else o(oe.wrongOfflineAction)})})}sendWhatsaap(e,t){let i={InvoiceID:e,PhoneNumber:t};return this.httpService.post(U.SendInvoiceWhatsapp,i)}createCustomerByInvoice(e,t){let i={InvoiceID:e,Mobile:t};return this.httpService.post(U.CreateCustomerInvoice,i)}saveCommission(e,t){let i={SOID:e,commission:t};return this.httpService.POSText("/API/Transaction/SetCommission",i)}generateReceiptA4(e){let t={ID:e};return this.httpService.post(U.InvoiceA4,t)}getVacant(e){return this.httpService.get(U.GetVacant,[{key:"EntityID",value:e}])}static \u0275fac=function(t){return new(t||n)(g(ge),g(Oe),g(he),g(F))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Xt=(r=>(r[r.cash=1]="cash",r[r.card=2]="card",r[r.emoney=3]="emoney",r[r.other=4]="other",r[r.ECR=99]="ECR",r))(Xt||{});var L=class n{constructor(e,t,i){this._OrderHttpService=e;this._customerHttpService=t;this._toastrService=i}_Data=new be(new G);transaction_id;Data$=this._Data.asObservable();get Data(){return this._Data.value}pushNewValue(e){if(e)this._Data.next(e);else{let t=this.Data;this._Data.next(t)}}submitOrder(e){return new Promise((t,i)=>{this.checkTransactionId(),this._OrderHttpService.submitOrder(this.Data,e).subscribe({next:o=>{t(o)},error:o=>{this.Data.Items=[],i(o)}})})}uploadOfflineOrder(){return this.checkTransactionId(),this._OrderHttpService.uploadOfflineOrder(this.Data)}checkTransactionId(){let t=this.Data.Payments.find(i=>i.TypeID==3);f.IsNotEmpty(t)&&f.IsEmpty(this.transaction_id)&&this._toastrService.warning("Midtrans transaction_id is empty. Please verify manually!","Mobile Payment Failure")}updateCustomerID(e){return this.Data.Order.CustomerID=e,this.pushNewValue(this.Data),new Promise((t,i)=>{this._customerHttpService.GetPrivilegeByID(e,this.Data.Order.EntityID).subscribe({next:o=>{this._customerHttpService.Data=o,this.pushNewValue(this.Data),t(o)},error:o=>{this.Data.Order.CustomerID=null,this.Data.ContactName=null;let r=o.error?.Message;o.status==409?this._toastrService.warning(r,"Warning"):this._toastrService.error(r,`API Error - ${o.status}`),i(o)}})})}static \u0275fac=function(t){return new(t||n)(g(It),g(Re),g(F))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var z=class n{constructor(e,t,i){this._localDataService=e;this._onlineStatusService=t;this._httpService=i;this._onlineStatusService.getOnlineStatus$().subscribe(o=>{this.isOnline=o})}_Data=new be(null);Data$=this._Data.asObservable().pipe(ce(e=>e!==null),Fe());isOnline;get Data(){return this._Data.value}pushNewValue(e){this._Data.next(e)}requestObservable(){return this.isOnline?this._httpService.get(U.GetPOSStorage).pipe(J(e=>({data:e,type:"Online"}))):this._localDataService.getPOSStorage().pipe(ce(e=>e!=null),J(e=>({data:e,type:"Offline"})))}getOutletName(e){return this.Data.Entities.find(i=>i.ID==e)?.Name}static \u0275fac=function(t){return new(t||n)(g(Oe),g(he),g(ge))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var De=class n{constructor(e){this.roleService=e;this.pushNewValue(new We(e))}_Data=new be(new We(null));get Data(){return this._Data.value}Data$=this._Data.asObservable();pushNewValue(e){this._Data.next(e)}static \u0275fac=function(t){return new(t||n)(g(_i))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var ti=class{ID;Code;EntityID;Name;Description;Start;StartDisplay;State;Open;CashierID;OpeningCash;EntityName;LoginID;Active;CustomerDisplayEnabled;OvoConfigurationID;CustomerDisplayID;ListImage;Suspended};var wi=class n{odsConfigType=R(0);setODSConfig(e){this.odsConfigType.set(e)}isEnabled(){return this.odsConfigType()>0}static \u0275fac=function(t){return new(t||n)};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var sr=n=>({active:n}),lr=n=>({gray:n});function cr(n,e){if(n&1){let t=E();a(0,"span",15),S("click",function(o){v(t);let r=m().$implicit;return m().closeRegister(r),_(o.stopPropagation())}),s()}}function dr(n,e){n&1&&(a(0,"div")(1,"span",16),d(2,"VACANT"),s()())}function mr(n,e){if(n&1&&(a(0,"div")(1,"span",17),b(2,"i",18),a(3,"span",19),d(4),s()(),a(5,"span",20),b(6,"i",21),a(7,"span",19),d(8),s()()()),n&2){let t=m().$implicit;l(4),M(t.LoginID),l(4),D("",t.StartDisplay.split(" ")[3]," - Now")}}function pr(n,e){if(n&1){let t=E();a(0,"div",8)(1,"div",9)(2,"div",10)(3,"h5",11),S("click",function(){let o=v(t).$implicit,r=m();return _(r.select(o))}),a(4,"span"),b(5,"i",12),d(6),y(7,"limitTo"),s(),h(8,cr,1,0,"span",13),s(),a(9,"div",14),S("click",function(){let o=v(t).$implicit,r=m();return _(r.select(o))}),h(10,dr,3,0,"div")(11,mr,9,2,"div"),s()()()()}if(n&2){let t,i=e.$implicit,o=m();l(),p("ngClass",i.Active?"active":""),l(),p("ngClass",j(9,sr,(i==null?null:i.ID)==(o.selectedRegister==null?null:o.selectedRegister.ID))),l(),p("ngClass",j(11,lr,i!=o.selectedRegister)),l(3),M(X(7,6,i.Name,15)),l(2),C(i.State!="Close"?8:-1),l(2),C((t=i.State)==="Close"?10:t==="Open"?11:-1)}}var Ri=class n{constructor(e,t,i,o,r,c,u){this._dialogRef=e;this._outletService=t;this._posService=i;this._userRoleService=o;this.router=r;this.httpService=c;this._odsService=u}originalSelectedRegister=null;registers;searchInput="";selectedRegister=new ti;modalConfig=new ie;role;get AppConfigJSON(){return this._posService.Data.AppConfigJSON}destroy$=new Me;ngOnInit(){this.subscribeToObsChanges(),this.initModalConfig()}subscribeToObsChanges(){this._posService.Data$.pipe(Ie(this.destroy$)).subscribe(e=>{this.registers=e.Registers}),this._outletService.Data$.pipe(Ie(this.destroy$)).subscribe(e=>{this.selectedRegister=this.findOutletRegisterById(e.RegisterID),this.originalSelectedRegister=this.selectedRegister?ni({},this.selectedRegister):null}),this._userRoleService.Data$.pipe(Ie(this.destroy$)).subscribe(e=>{this.role=e})}findOutletRegisterById(e){let t=this.registers.find(i=>i.ID===e);return t||new ti}initModalConfig(){this.modalConfig.hideFooter=!0,this.modalConfig.hideScrollbar=!0,this.modalConfig.title="Choose an outlet"}ngOnDestroy(){this.destroy$.next(!0),this.destroy$.complete()}onClose(){this._dialogRef.close()}select(e){if(this.AppConfigJSON.ModuleShift.Closure.Enabled)if(this.selectedRegister.ID!=null&&this.selectedRegister.Open&&e.CashierID==null)confirm("You already have an active register with "+this.selectedRegister.Name+`!
|
|
2
|
-
Do you want to end your session?`)&&(this.onClose(),this.router.navigate(["menu/Shift/Main/My_Shift"],{queryParams:{RegisterID:e.ID}}));else if(!e.Open||this.selectedRegister.ID==e.ID)this.selectedRegister=e,this.onSubmitSelectedRegister();else{if(this.role.SellEditor==!1){alert("You cannot end shift for Register "+e.Name+" - Unauthorized Access");return}alert("This Register has already active register, Are you sure you want to end this register?"),this.onClose(),this.router.navigate(["/menu/Shift/Main/My_Shift"],{queryParams:{RegisterID:e.ID}})}else this.selectedRegister=e,this.onSubmitSelectedRegister()}onSubmitSelectedRegister(){if(this.selectedRegister.ID==null){alert("Please select a register first!");return}this._outletService.pushNewRegister(this.selectedRegister),this.loadOdsConfig(this.selectedRegister.EntityID),this._dialogRef.close({selectedRegister:this.selectedRegister,openStartingCashDialog:this.selectedRegister.ID!=this.originalSelectedRegister?.ID})}closeRegister(e){let t=this.selectedRegister.ID;if(this.role.SellEditor==!1){alert("You cannot end shift for Register "+e.Name+" - Unauthorized Access");return}t==e.ID?this.router.navigate(["/menu/Shift/Main/My_Shift"]):this.router.navigate(["/menu/Shift/Main/My_Shift"],{queryParams:{RegisterID:e.ID}}),this.onClose()}loadOdsConfig(e){this.httpService.get(`/api/outlet/GetOrderDisplayBroadcastMode?EntityID=${e}`).pipe(le(t=>{this._odsService.setODSConfig(t.form.OrderDisplayBroadcastMode)})).subscribe()}static \u0275fac=function(t){return new(t||n)(P(te),P(re),P(z),P(De),P(zn),P(ge),P(wi))};static \u0275cmp=N({type:n,selectors:[["pos-modal-register"]],standalone:!1,decls:12,vars:6,consts:[[3,"onClose","config"],[1,"ms-0","mb-8","search-container",3,"hidden"],[1,"input-group","mb-3","rounded-start-1"],[1,"input-group-text","txtFilter","rounded-end-0"],["aria-hidden","true",1,"fa","fa-magnifying-glass"],["data-cy","SearchOutlet","type","text","placeholder","Filter by Name","aria-label","Search",1,"txtFilter","form-control","border-start-0","rounded-1","rounded-start-0",3,"ngModelChange","ngModel"],[1,"container","custom-scroll"],[1,"row",2,"width","600px"],["data-cy","registers",1,"col-4"],[1,"card","border-0",3,"ngClass"],[1,"card-body","p-0",3,"ngClass"],[1,"card-title","mb-0",3,"click","ngClass"],[1,"fa-solid","fa-house","pe-1","fs-6"],[1,"fa","fa-xmark-circle","fa-lg","position-absolute",2,"text-shadow","0 1px 0 #afafaf","right","5px","top","16px"],[1,"card-text","px-0","py-2",3,"click"],[1,"fa","fa-xmark-circle","fa-lg","position-absolute",2,"text-shadow","0 1px 0 #afafaf","right","5px","top","16px",3,"click"],[1,"idle"],[1,"cashier"],["aria-hidden","true",1,"fa","fa-user","pe-2"],[1,"d-inline"],[1,"open"],["aria-hidden","true",1,"fa-regular","fa-clock","pe-2"]],template:function(t,i){t&1&&(a(0,"modal-material",0),S("onClose",function(){return i.onClose()}),a(1,"content")(2,"div",1)(3,"div",2)(4,"span",3),b(5,"i",4),s(),a(6,"input",5),H("ngModelChange",function(r){return A(i.searchInput,r)||(i.searchInput=r),r}),s()()(),a(7,"div",6)(8,"div",7),K(9,pr,12,13,"div",8,ve),y(11,"FilterByName"),s()()()()),t&2&&(p("config",i.modalConfig),l(2),p("hidden",i.registers.length<=6),l(4),B("ngModel",i.searchInput),l(3),Z(X(11,3,i.registers,i.searchInput)))},dependencies:[Be,Te,Pe,Ee,ne,bi,vo],styles:[".text-warning[_ngcontent-%COMP%]{color:var(--bs-warning)!important}.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}.btn-light-danger[_ngcontent-%COMP%]{color:#212529;background-color:#f8d7da!important;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:hover{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5}.btn-light-danger[_ngcontent-%COMP%]:focus, .btn-light-danger.focus[_ngcontent-%COMP%]{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5;box-shadow:0 0 0 .2rem #dc354540}.btn-light-danger.disabled[_ngcontent-%COMP%], .btn-light-danger[_ngcontent-%COMP%]:disabled{color:#212529;background-color:#f8d7da;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]{color:#212529;background-color:#f1aeb5;border-color:#ea868f}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active:focus, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active:focus, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]:focus{box-shadow:0 0 0 .2rem #dc354540}.search-container[_ngcontent-%COMP%]{transition:all .3s ease;width:97%}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]{position:relative;transition:all .3s ease;height:2.3rem}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:hover, .search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:focus-within{box-shadow:0 0 0 2px #89b03e4d,0 0 8px 4px #89b03e33;border-radius:4px}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%] .txtFilter.form-control[_ngcontent-%COMP%]{transition:all .3s ease;border-left:none!important}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%] .txtFilter.form-control[_ngcontent-%COMP%]:focus{box-shadow:none!important;border-color:#ced4da!important}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%] .input-group-text[_ngcontent-%COMP%]{transition:all .3s ease;background-color:#fff;border-right:none!important}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:hover .input-group-text[_ngcontent-%COMP%], .search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:focus-within .input-group-text[_ngcontent-%COMP%]{background-color:#89b03e1a;border-color:#84cc16!important}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%] .fa-magnifying-glass[_ngcontent-%COMP%]{transition:all .3s ease}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:hover .fa-magnifying-glass[_ngcontent-%COMP%], .search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:focus-within .fa-magnifying-glass[_ngcontent-%COMP%]{color:#84cc16!important}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:focus-within{box-shadow:0 0 0 2px #89b03e66,0 0 12px 6px #89b03e40!important}.custom-scroll[_ngcontent-%COMP%]::-webkit-scrollbar{width:6px}.custom-scroll[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:#f1f1f1;border-radius:3px}.custom-scroll[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:#89b03e;border-radius:3px}.custom-scroll[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:#7a9e37}.container[_ngcontent-%COMP%]{overflow-y:auto;overflow-x:hidden;max-height:260px;min-height:150px}.col-4[_ngcontent-%COMP%]{list-style:none;margin:0;padding:0;display:flex;flex-wrap:wrap!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%]{width:180px;min-height:95px;margin-right:17px;margin-bottom:17px;position:relative}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%]{display:block;outline:0;border:1px solid #B1AAAA;border-radius:5px;cursor:pointer}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] h5[_ngcontent-%COMP%]{height:30px;border-radius:4px;padding:5px 10px;color:#fff;background:#b1aaaa;overflow:hidden}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] h5[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{margin-right:5px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%]:hover, .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.active[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.vacant[_ngcontent-%COMP%]{background:#ffffe1;border:1px solid #89b03e}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%]:hover > h5[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.active[_ngcontent-%COMP%] > h5[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.vacant[_ngcontent-%COMP%] > h5[_ngcontent-%COMP%]{background:#89b03e}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%]:hover{border:1px solid #c9302c}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%] > h6[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%]:hover > h6[_ngcontent-%COMP%]{background:#c9302c!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%] span.alias[_ngcontent-%COMP%]{background:#c9302c}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%]:hover{background:#fff}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%]{border:1px solid #f6a828}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%] > h6[_ngcontent-%COMP%]{background:#f6a828!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%]:hover{border:1px solid #f6a828;background:#fff}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%]:hover > strong[_ngcontent-%COMP%]{background:#f6a828!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%] span.alias[_ngcontent-%COMP%]{background:#f6a828}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%] div[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{font-size:.75rem!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%]{height:80px;padding:15px 10px;position:relative}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{display:block;font-weight:400;font-size:.875rem;width:100%;margin-bottom:5px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span[_ngcontent-%COMP%]:first-child{margin-top:-10px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span[_ngcontent-%COMP%]:last-child{margin-bottom:0}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span.alias[_ngcontent-%COMP%]{text-align:center;position:absolute;bottom:0;right:0;width:auto;background-color:#b1aaaa;border-radius:3px;padding:2px 5px;color:#fff;display:none!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span.idle[_ngcontent-%COMP%]{display:block;font-size:1.25rem;text-align:center}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{position:absolute;width:27px;height:28px;cursor:pointer;top:5px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > span[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{color:#000}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]:last-of-type{right:-5px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]:nth-last-of-type(2){right:15px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{bottom:20px;right:5px;position:absolute}.col-4[_ngcontent-%COMP%] .duration[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{border:1px solid!important;position:absolute;bottom:-3px;left:58px;background:#fff;border-radius:5px}"]})};var ur=["inputCash"],Ni=class n{constructor(e,t){this.dialogRef=e;this.data=t;this.generateModalTitle$.subscribe()}registerService=T(re);loadPOSService=T(z);register=this.registerService.Data;username=this.loadPOSService?.Data?.UserName;amount=R(0);config=new ie;currentRegisterName;generateModalTitle$=this.registerService.Data$.pipe(ce(e=>f.IsNotEmpty(e)),le(()=>{let e=this.registerService.getOutletRegister(),t=e?.Name?.length>18?`${e?.Name?.substring(0,18)}...`:e?.Name;this.config.title="Open Shift",this.currentRegisterName=t}),ee());today=new Date;inputCashEl;ngOnInit(){this.config.customWidth="350px",this.config.hideCancel=!0}ngAfterViewInit(){this.inputCashEl?.nativeElement?.focus()}onOk(){this.dialogRef.close({amount:this.amount()})}static \u0275fac=function(t){return new(t||n)(P(te),P(fe))};static \u0275cmp=N({type:n,selectors:[["POS-modal-opening-cash"]],viewQuery:function(t,i){if(t&1&&Ut(ur,5),t&2){let o;Wt(o=Gt())&&(i.inputCashEl=o.first)}},standalone:!1,decls:25,vars:8,consts:[["inputCash",""],[3,"onOk","onCancel","onClose","config"],[1,"table","fs-5","text"],[1,"py-3"],[1,"text-end","pe-3"],[1,"py-4"],[1,"text-end"],["data-cy","InputCash","autoNum","",1,"border","form-control-lg","text-end","w-100",3,"ngModelChange","ngModel"]],template:function(t,i){if(t&1){let o=E();a(0,"modal-material",1),S("onOk",function(){return v(o),_(i.onOk())})("onCancel",function(){return v(o),_(i.dialogRef.close())})("onClose",function(){return v(o),_(i.dialogRef.close())}),a(1,"content")(2,"table",2)(3,"tr")(4,"td",3),d(5,"Outlet Register"),s(),a(6,"td",4),d(7),s()(),a(8,"tr")(9,"td",5),d(10,"Current User"),s(),a(11,"td",4),d(12),s()(),a(13,"tr")(14,"td",5),d(15,"Starting Time"),s(),a(16,"td",4),d(17),y(18,"date"),s()(),a(19,"tr")(20,"td",3),d(21,"Starting Cash"),s(),a(22,"td",6)(23,"input",7,0),H("ngModelChange",function(c){return v(o),A(i.amount,c)||(i.amount=c),_(c)}),s()()()()()()}t&2&&(p("config",i.config),l(7),M(i.currentRegisterName),l(5),M(i.username),l(5),M(X(18,5,i.today,"EEEE, HH:mm")),l(6),B("ngModel",i.amount))},dependencies:[Te,Pe,Ee,ne,Dt,Ye],styles:[".table-title-width[_ngcontent-%COMP%]{width:120px}"]})};var Ai=class{OrderNumberElement;InvoiceNumberElement;NewOrderID};var Et=class n{constructor(e,t,i){this._httpService=e;this._onlineStatusService=t;this._localDataService=i;this._onlineStatusService.getOnlineStatus$().subscribe(o=>{this.isOnline=o})}isOnline;GenerateNumber(e,t){if(this.isOnline)return this._httpService.get(U.GenerateNumber,[{key:"EntityID",value:e},{key:"TypeID",value:1}]);{let i=new Ai;return f.IsNotEmpty(t.NumberElement)&&(t.NumberElement.Seed+=1),f.IsNotEmpty(t.InvoiceNumberElement)&&(t.InvoiceNumberElement.Seed+=1),i.InvoiceNumberElement=t.InvoiceNumberElement,i.OrderNumberElement=t.NumberElement,i.NewOrderID=f.Guid_NewGuid(),ke(i)}}findRegisterById(e){return new Promise(t=>{this._localDataService.isConfigFromServer().subscribe(i=>{i?this._httpService.get(U.GetRegisterInfo,[{key:"RegisterID",value:e}]).subscribe(o=>{t(o)}):this._localDataService.findRegisterByID(e).subscribe(o=>{t(o)})})})}recordOpeningCash(e){return ai(this._httpService.post("/API/POS/RecordOpeningCash",e))}static \u0275fac=function(t){return new(t||n)(g(ge),g(he),g(Oe))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var re=class n{constructor(e,t,i,o,r,c){this._signalRClientService=e;this._matDialog=t;this._posHttpResponseService=i;this._CoreHttpService=o;this._toastrService=r;this._roleService=c}datePipe=T(Ye);_Data=new be(null);Data$=this._Data.asObservable().pipe(ce(e=>e!==null),Fe());get Data(){return this._Data.value}getSalesname(e){return this.Data&&this.Data.ListSales?this._Data.value.ListSales.find(t=>t.ID==e)?.Name:""}setActiveRegisterFromOptions(e,t){let o=this._posHttpResponseService.Data.AppConfigJSON.ModuleShift.Closure.Enabled;if(e.length>1){let r=e.find(c=>c.LoginID==t);if(r)this.pushNewRegister(r);else{let c=this.getOutletRegisterFromLocalStorage(),u=this.Data?.RegisterID?this.Data.RegisterID:c?.ID;e.some(k=>k.ID==u)?o?this.openChooseRegisterModal():this.initRegisterFromLocalStorage():this.openChooseRegisterModal()}}e.length==1&&(this.pushNewRegister(e[0]),f.IsEmpty(e[0].LoginID)&&f.IsEmpty(e[0].CashierID)&&this.openOpeningCashModal(e[0].ID)),e.length==0&&this._toastrService.warning("You do not have access to any OUTLET","Warning")}openChooseRegisterModal(){this._matDialog.open(Ri,{id:"registerModal",disableClose:!0}).afterClosed().pipe(ce(e=>f.IsNotEmpty(e?.selectedRegister))).subscribe(e=>{e.selectedRegister&&this.openOpeningCashModal(e.selectedRegister.ID)})}openOpeningCashModal(e){this._posHttpResponseService.Data.AppConfigJSON.ModuleShift.Closure.Enabled&&this._matDialog.open(Ni,{disableClose:!0}).afterClosed().pipe(ce(o=>f.IsNotEmpty(o))).subscribe(o=>{let r={RegisterID:e,OpAmount:o.amount};this._CoreHttpService.recordOpeningCash(r).then(()=>{this.updateRegisterList(r)})})}updateRegisterList(e){let i=this._posHttpResponseService.Data.Registers.map(r=>r.ID==e.RegisterID?this.mapRegisterAsActiveRegister(r,e):r),o=this._posHttpResponseService.Data;o.Registers=i,this._posHttpResponseService.pushNewValue(o)}mapRegisterAsActiveRegister(e,t){let i=localStorage.getItem("AccountInfo");if(i){let r=JSON.parse(i);e.LoginID=r.UserName}e.OpeningCash=t.OpAmount,e.Open=!0,e.State="Open";let o=this.datePipe.transform(new Date,"dd MM yyyy HH:mm");return e.StartDisplay=o,e}initRegisterFromLocalStorage(){if(this._roleService.Data.DeleteItem==!1){let t=this.getOutletRegisterFromLocalStorage();t&&this.pushNewRegister(t)}}pushNewRegister(e){let t=this._Data.value,i=t?t.RegisterID:null;i!=e.ID&&this._CoreHttpService.findRegisterById(e.ID).then(o=>{o.RegisterCode=e.Code,o.DefaultPrintTemplate=o.PrintTemplate,o.SplitPaymentEnabled=this.findSplitPaymentConfig(o.EntityID),this._signalRClientService.SubscribeGroup(o.RegisterID,i),this.saveOutletRegisterToLocalStorage(e),this.pushNewValue(o)})}getOutletRegister(){let e=this.Data.RegisterID;return this._posHttpResponseService.Data.Registers.find(o=>o.ID==e)}pushNewValue(e){this._Data.next(e)}saveOutletRegisterToLocalStorage(e){if(this._roleService.Data.DeleteItem==!1){let i=JSON.stringify(e);localStorage.setItem("outlet_register",i)}}getOutletRegisterFromLocalStorage(){let e=this._roleService.Data.DeleteItem,t=localStorage.getItem("outlet_register"),i=null;return t&&(e?localStorage.removeItem("outlet_register"):i=JSON.parse(t)),i}findOutletRegisterById(e){return this._posHttpResponseService.Data.Registers.find(o=>o.ID===e)}findSplitPaymentConfig(e){let i=this._posHttpResponseService.Data.Entities.find(o=>o.ID===e);return i?i.SplitPaymentEnabled:!1}static \u0275fac=function(t){return new(t||n)(g(rt),g(we),g(z),g(Et),g(F),g(De))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};function gr(n,e){if(n&1&&(a(0,"span",5),d(1),y(2,"number"),s()),n&2){let t=m(3);l(),D("-",x(2,1,t.coupon.Amount),"%")}}function fr(n,e){if(n&1&&(a(0,"span",5),d(1),y(2,"number"),s()),n&2){let t=m(3);l(),D(" -",x(2,1,t.coupon.Amount)," ")}}function hr(n,e){if(n&1){let t=E();a(0,"button",9),S("click",function(){v(t);let o=m().$implicit,r=m(2);return _(r.onRemoveCouponDiscount(o))}),d(1," Remove "),s()}}function Cr(n,e){if(n&1){let t=E();a(0,"button",10),S("click",function(){v(t);let o=m().$implicit,r=m(2);return _(r.onApplyCouponDiscount(o))}),d(1," Apply "),s()}if(n&2){let t=m(3);p("disabled",t.hasAppliedCouponDiscount())}}function vr(n,e){if(n&1&&(a(0,"tr")(1,"td"),d(2),s(),a(3,"td"),d(4),s(),a(5,"td",4),d(6),y(7,"number"),s(),a(8,"td",4),h(9,gr,3,3,"span",5)(10,fr,3,3,"span",5),s(),a(11,"td",6),h(12,hr,2,0,"button",7)(13,Cr,2,1,"button",8),s()()),n&2){let t=e.$implicit,i=m(2);l(2),M(t==null||t.Variant==null?null:t.Variant.Name),l(2),M(t==null||t.Variant==null?null:t.Variant.Code),l(2),M(x(7,5,t.UnitPrice)),l(3),C((i.coupon==null||i.coupon.Requirement==null?null:i.coupon.Requirement.Type)==i.couponType.DiscountPercentage?9:10),l(3),C((t==null?null:t.CouponDiscount)>0?12:13)}}function _r(n,e){if(n&1&&K(0,vr,14,7,"tr",null,ot),n&2){let t=m();Z(t.eligibleItems())}}function yr(n,e){n&1&&(a(0,"tr")(1,"td",11),b(2,"app-empty-state",12),s()())}var ki=class n{constructor(e){this.data=e;this.coupon=this.data.coupon,this.initModalConfig(),this.initEligibleItems()}dialogRef=T(te);config;eligibleItems=R([]);coupon;couponType=zt;hasAppliedCouponDiscount=R(!1);initModalConfig(){this.config=new ie,this.config.title="Choose Item to Apply Discount",this.config.hideFooter=!0}initEligibleItems(){let e=this.data.coupon?.ApplyToProduct.map(t=>t.ID);e&&(this.eligibleItems.update(()=>this.data.cartItems.filter(i=>e.includes(i.VariantID))),this.hasAppliedCouponDiscount.update(()=>this.eligibleItems().some(t=>t.CouponDiscount>0)))}onApplyCouponDiscount(e){let t=[e];this.hasAppliedCouponDiscount.update(()=>!0),this.dialogRef.close(t)}onRemoveCouponDiscount(e){this.eligibleItems.update(t=>{let i=t.findIndex(o=>o.VariantID===e.VariantID);return i>-1&&(t[i].Discount=0,t[i].CouponDiscount=0),t}),this.hasAppliedCouponDiscount.update(()=>!1)}onClose(){this.dialogRef.close()}static \u0275fac=function(t){return new(t||n)(P(fe))};static \u0275cmp=N({type:n,selectors:[["app-modal-coupon-selected-item"]],decls:17,vars:2,consts:[[3,"onCancel","onClose","config"],[1,"table","table-bordered"],[1,"thead-light"],["scope","col"],[1,"text-end"],[1,"text-danger"],[1,"text-center"],[1,"btn","btn-sm","btn-danger"],[1,"btn","btn-sm","btn-success",3,"disabled"],[1,"btn","btn-sm","btn-danger",3,"click"],[1,"btn","btn-sm","btn-success",3,"click","disabled"],["colspan","5"],["title","No eligible products","message","No products in the cart qualify for coupon use"]],template:function(t,i){t&1&&(a(0,"modal-material",0),S("onCancel",function(){return i.onClose()})("onClose",function(){return i.onClose()}),a(1,"content")(2,"table",1)(3,"thead",2)(4,"tr")(5,"th",3),d(6,"Name"),s(),a(7,"th",3),d(8,"Code"),s(),a(9,"th",3),d(10,"Price"),s(),a(11,"th",3),d(12,"Discount"),s(),b(13,"th",3),s()(),a(14,"tbody"),h(15,_r,2,0)(16,yr,3,0,"tr"),s()()()()),t&2&&(p("config",i.config),l(15),C(i.eligibleItems().length!==0?15:16))},dependencies:[Se,Ot,ne,So,q],encapsulation:2})};var st=class{ModuleSell;ApplicationLoyalty;ApplicationMath;CoreDefaults;ModuleDelivery;ApplicationParkAndRetrieve;ApplicationRegisterClosure;PaymentConfigGopay;PaymentConfigLink;PrintConfigInvoice;CorePrint;PaymentConfigEmpatKali;ApplicationSettings;PrintConfigGeneral;ModuleProducts;ModuleContact;ApplicationTransactionNumbering;ModuleOrders;ModuleShift;ModuleBuy;ModuleAdjustment;TadaCouponVisible;CouponRedemptionType;ProviderOption};var se=class n{constructor(e,t,i,o){this._orderDataService=e;this._posService=t;this.POSMATH=i;this.decimalPipe=o;this._orderDataService.Data$.pipe(Y(r=>this._posService.Data$.pipe(J(c=>({appConfig:c.AppConfigJSON,salesOrder:r}))))).subscribe(r=>{this.salesOrderData=r.salesOrder,this.appConfigJSON=r.appConfig,this.calculateDiscountAmount(),this.pushNewValue(this.grandTotal)})}_Data=new be(0);Data$=this._Data.asObservable().pipe(Fe());tax=new xo;discountAfterTax=0;currencySymbol="Rp";get Data(){return this._Data.value}salesOrderData=new G;appConfigJSON=new st;pushNewValue(e){this._Data.next(e)}get grandTotal(){let e=this.TotalAfterSurcharge;return isNaN(e)?0:e}setDecimalDigit(e){let t=this.decimalPipe.transform(e,"1.0-4");return e=parseFloat(t.split(",").join("")),e}get TotalAfterTax(){let e=this.TaxAmount,t=this.TotalBeforeTax+e;return t=this.POSMATH.Round(t,this.appConfigJSON.ApplicationMath.RoundingDigit.DecimalPlaceValue,this.appConfigJSON.ApplicationMath.RoundingDigit.RoundAlgorithm),t}get TotalBeforeTax(){let e=this.tax?.CalculationTypeID===1,t=0;return e?t=this.DiscountTotal-this.TaxAmount:t=this.DiscountTotal,t}get TotalAfterSurcharge(){let e=this.TotalAfterTax+this.SurchargeAmount;return this.POSMATH.Round(e,this.appConfigJSON.ApplicationMath.RoundingDigit.DecimalPlaceValue,this.appConfigJSON.ApplicationMath.RoundingDigit.RoundAlgorithm)}get TotalAfterDiscountTaxable(){return this.GrossTotalTaxable-this.DiscountTotal}get TaxAmount(){if(this.tax!=null){let e=0,t=this.appConfigJSON.ApplicationMath.RoundingTaxDigit.DecimalPlaceValue,i=this.appConfigJSON.ApplicationMath.RoundingTaxDigit.RoundAlgorithm,o=this.GrossTotalTaxable;return this.tax.CalculationTypeID==1?e=this.tax.Rate/(100+this.tax.Rate)*o:e=this.tax.Rate/100*o,e=this.POSMATH.Round(e,t,i),e}else return 0}get SurchargeAmount(){return this.TotalAfterTax*this.salesOrderData.Invoice.SurchargePcg/100}get Discount1Amount(){return this.GrossTotal*this.salesOrderData.Order.Discount/100}get AfterDiscount1Amount(){return this.GrossTotal-this.Discount1Amount}get Discount2Amount(){return this.AfterDiscount1Amount*this.salesOrderData.Order.Discount2/100}get AfterDiscount2Amount(){return this.AfterDiscount1Amount-this.Discount2Amount}get DiscountTotal(){return this.AfterDiscount2Amount-this.salesOrderData.Order.DiscountAmount}calculateDiscountAmount(){let e=this.salesOrderData.Order.DiscountAmount,t=0;this.AfterDiscount2Amount>=0&&e>0&&e>this.AfterDiscount2Amount&&(t=this.AfterDiscount2Amount),t!==0&&t<=e&&this.GrossTotal!==0&&(e=t),this.salesOrderData.Order.DiscountAmount=e}get GrossTotal(){return this.sum(this.salesOrderData.CartItems,"Total")}get GrossTotalTaxable(){let e=this.salesOrderData.CartItems.filter(i=>i.Taxable),t=this.sum(e,"Total");if(e.length!==0){let i=this.calculateDiscountTaxableItem(e);t=t*(100-this.salesOrderData.Order.Discount)/100,t=t*(100-this.salesOrderData.Order.Discount2)/100,t=t-i}return t}calculateDiscountTaxableItem(e){let t=this.GrossTotal,i=this.salesOrderData.Order.DiscountAmount,o=0,r=0,c=0,u=0;for(let O of e)o=O.getItemAfterDiscount/t,r=o*i,u=r*O.Quantity,c+=u;return c}get GrossTotalNonTaxable(){let e=this.salesOrderData.CartItems.filter(i=>i.Taxable==!1),t=this.sum(e,"Total");return t=t*(100-this.salesOrderData.Order.Discount)/100,t=t*(100-this.salesOrderData.Order.Discount2)/100,t=t-this.salesOrderData.Order.DiscountAmount,t}sum(e,t){let i=e.reduce((o,r)=>o+r[t],0);return i=this.setDecimalDigit(i),i}GetPointOnlyAmount(){let e=this.salesOrderData.CartItems.filter(t=>t.Variant.PaymentTypeID==2);return this.GetAmountByCart(e)}GetCashOnlyAmount(){let e=this.salesOrderData.CartItems.filter(t=>t.Variant.PaymentTypeID==1);return this.GetAmountByCart(e)}GetCashAndPointAmountCart(){let e=this.salesOrderData.CartItems.filter(t=>t.Variant.PaymentTypeID!=1);return this.GetAmountByCart(e)}GetAmountByCart(e){let t=this.sum(e,"Total");return t=t*(100-this.salesOrderData.Order.Discount)/100,t=t*(100-this.salesOrderData.Order.Discount2)/100,t}calculateGrossTotal(e){return this.sum(e,"Total")}static \u0275fac=function(t){return new(t||n)(g(L),g(z),g(Io),g(q))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Vi=class{Code;Provider;EntityID;Customer;ShoppingCart};var wt=class n{salesOrderService=T(L);registerService=T(re);customerService=T(Re);orderCalculator=T(se);generateRedeemCouponDto(e,t){let i=new Vi,o=this.registerService.Data?.EntityID;return i.Code=e,i.Provider=t,i.ShoppingCart={Amount:this.orderCalculator.Data,Items:this.generateItems()},i.EntityID=o,i.Customer=this.generateCustomer(t),i}generateItems(){return this.salesOrderService.Data.CartItems.map(i=>({Price:i.Price,Quantity:i.Quantity,VariantID:i.VariantID,Code:i?.Variant?.Code}))}generateCustomer(e){let t=this.customerService.Data,i=this.salesOrderService?.Data?.Order?.CustomerID,o=null;return f.IsNotEmpty(i)&&(o={Phone:t.Mobile,Email:t.Email},e==="Internal"&&(o=ni({ID:i},o))),o}static \u0275fac=function(t){return new(t||n)};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Rt=class n{constructor(e,t,i,o,r,c){this._httpService=e;this._orderDataService=t;this._userRoleService=i;this.toastr=o;this._invoiceCalculatorService=r;this.promotionCouponFactoryService=c;this.subscribeToObservable()}dialog=T(we);role;originalRoleData;_coupon=R(null);salesOrderBeforePromotion=R(null);isShowToastrInApplyCoupon=R(!1);get coupon(){return this._coupon()}subscribeToObservable(){this._userRoleService.Data$.subscribe(e=>{this.role=e,f.IsEmpty(this.originalRoleData)&&(this.originalRoleData=me(We,e))})}RedeemCoupon(e,t,i=!1){i||(this.isShowToastrInApplyCoupon.set(!0),this.copyOriginalSalesOrder());let o=this.promotionCouponFactoryService.generateRedeemCouponDto(e,"Internal");this._httpService.post(U.ValidateInternalCoupon,o).subscribe({next:r=>{switch(this._orderDataService.Data.Order.PromotionCoupon=e,this._orderDataService.Data.Order.PromotionNote=t,this._orderDataService.Data.Order.CouponType=1,r.Requirement?.Type){case 1:this.HandleDiscountPercentage(r);break;case 2:this.HandleDiscountAmount(r);break;case 3:this.handleCouponReturnAccess(r);break;case 4:this.handleCouponParkedDeletionAccess();break;case 5:this.handleFullAccessCoupon();break;case 6:this.handleDeleteItemCoupon();break}this._coupon.set(r),this.isShowToastrInApplyCoupon.set(!1)},error:r=>{this.removeAppliedCoupon(!1),this.isShowToastrInApplyCoupon.set(!1)}})}setCouponOnEdit(e){this._coupon.set(e),this.generateOriginalSalesOrderOnEdit()}generateOriginalSalesOrderOnEdit(){let e=me(G,this._orderDataService.Data);e.Order.PromotionCoupon=null,e.Order.PromotionNote=null,e.Order.Discount=0,e.Order.DiscountAmount=0,this.salesOrderBeforePromotion.set(e)}copyOriginalSalesOrder(){let e=me(G,this._orderDataService.Data);this.salesOrderBeforePromotion.set(e)}HandleDiscountPercentage(e,t=!1){e.Amount>0?e.Requirement?.MaximumDiscount>0?this.applyConfigMaxDiscount(e,t):e.Requirement?.FullPriceProductOnly?this.applyFullPriceDisc(e,t):this.applyDiscountPercentage(e,t):(this.role.Discount=t?this.originalRoleData.Discount:!0,this._userRoleService.pushNewValue(this.role))}applyFullPriceDisc(e,t=!1){let i=this._orderDataService.Data,o=this.filterItemWithDisc(i.CartItems),r=this.filterItemWithCouponDisc(i.CartItems);if(t)r.length>0?(i.CartItems=this.resetItemsDisc(i.CartItems),this._orderDataService.pushNewValue()):this.applyDiscountPercentage(e,t);else if(o.length>0){let c=this.filterItemWithoutDisc(i.CartItems);c.length>0?this.applyConfigItemsScope(e,c).subscribe(u=>{let O=this.applyItemsDisc(u,e);i.CartItems=this.updateCartItems(O,e),this._orderDataService.pushNewValue(i),this.showToastr(e)}):(this.removeAppliedCoupon(!1),this._orderDataService.pushNewValue(),this.toastr.error("No products in the cart qualify for coupon use","Coupon Not Applied"))}else this.applyDiscountPercentage(e,t)}updateCartItems(e,t){let o=this._orderDataService.Data.CartItems.map((r,c)=>{let u=e.find(O=>this.isSameCartItem(O,r));return u||r});return o=this.applyOneOfFirstQuantity(o,t),o}applyOneOfFirstQuantity(e,t){if(t?.Requirement?.RequirementDiscountType==2){let i=e.findIndex(o=>o.CouponDiscount>0);if(e[i]?.Quantity>1){let o=mt(xe,e[i]);o.Quantity=1,o.ID=f.GuidEmpty,e[i].Quantity=e[i].Quantity-1,e[i].CouponDiscount=0,e[i].Discount=0,e[i].DiscountAmount=0,e.push(o)}}return e}filterItemWithDisc(e){return e.filter(i=>i.Discount>0||i.DiscountAmount>0||i.Price!=i?.Variant?.UnitPrice||f.IsNotEmpty(i.PriceBookID)||i.PriceTypeID==2)}filterItemWithoutDisc(e){return e.filter(i=>this.itemConditionFullPriceOnly(i))}filterItemWithCouponDisc(e){return e.filter(i=>i.CouponDiscount>0)}applyDiscountPercentage(e,t=!1){let i=this._orderDataService.Data.Order.CustomerDiscountRate,o=e.Amount;if(t){let r=this._orderDataService.Data;this._orderDataService.Data.Order.Discount=0,r.CartItems=this.resetItemsDisc(r.CartItems),this._orderDataService.pushNewValue(r)}else o>=i?e.ApplyToProduct?.length>0?this.applyDiscountRequiredItems(e):(this._orderDataService.Data.Order.Discount=e.Amount,this._orderDataService.pushNewValue(),this.showToastr(e)):(this.toastr.warning("Member discount is applied because member discount is greater than Coupon Discount","Warning"),this.removeAppliedDiscountOnCustomerChange())}applyDiscountRequiredItems(e){let i=this._orderDataService.Data.CartItems.filter(o=>e.ApplyToProduct.map(r=>r.ID)?.includes(o.VariantID));this.applyConfigItemsScope(e,i).subscribe(o=>{let r=o.map(u=>(u.Discount=e.Amount,u.CouponDiscount=e.Amount,u)),c=this.updateCartItems(r,e);this._orderDataService.Data.CartItems=c,this._orderDataService.pushNewValue(),this.showToastr(e)})}showToastr(e){let t=e?.Requirement?.Notify;f.IsNotEmpty(t)&&this.isShowToastrInApplyCoupon()&&this.toastr.success(t,"Coupon Applied")}applyConfigMaxDiscount(e,t=!1){let i=this._orderDataService.Data.CartItems;e.Requirement?.FullPriceProductOnly&&(i=i.filter(o=>this.itemConditionFullPriceOnly(o))),this.applyConfigItemsScope(e,i,t).subscribe(o=>{this.applyMaxDiscount(e,o,t)})}applyConfigItemsScope(e,t,i=!1){let o=e.Requirement?.RequirementDiscountType;return(o==1||o==2)&&i==!1?this.dialog.open(ki,{data:{coupon:e,cartItems:t},id:"modal-coupon-selected-item"}).afterClosed().pipe(le(c=>{let k=this._orderDataService.Data.CartItems.some(W=>W.CouponDiscount>0);!c&&!k&&this.removeAppliedDiscountOnCustomerChange()}),ce(c=>!!c)):ke(t)}applyMaxDiscount(e,t,i=!1){let o=this._invoiceCalculatorService.calculateGrossTotal(t),r=this._orderDataService.Data,c=o*e.Amount/100,u=e.Requirement?.MaximumDiscount,O=t;c>=u?(r.Order.DiscountAmount=i?0:u,O=this.resetItemsDisc(t)):(r.Order.DiscountAmount=0,O=i?this.resetItemsDisc(t):this.applyItemsDisc(t,e)),r.CartItems=this.updateCartItems(O,e),this._orderDataService.pushNewValue(r),i||this.showToastr(e)}resetItemsDisc(e){return this.coupon?.Requirement?.RequirementDiscountType==2?e=this.resetConfigOneOfFirstQuantity(e):e=e.map(t=>(t.CouponDiscount>0&&(t.Discount=0,t.DiscountAmount=0,t.CouponDiscount=0),t)),e}resetConfigOneOfFirstQuantity(e){let t=e.findIndex(i=>i.CouponDiscount>0);if(t!==-1){let i=e.findIndex(o=>o.CouponDiscount==0&&e[t]?.VariantID==o?.VariantID);i!==-1?(e.splice(t,1),e[i].Quantity+=1):(e[t].CouponDiscount=0,e[t].Discount=0,e[t].DiscountAmount=0)}return e}applyItemsDisc(e,t){return t.ApplyToProduct?.length>0?e=this.applyDiscByVariant(e,t):e=e.map(i=>(i.Discount=t.Amount,i.CouponDiscount=t.Amount,i)),e}applyDiscByVariant(e,t){return e=e.map(i=>(t.ApplyToProduct.find(r=>r.ID==i.VariantID)&&this.itemConditionFullPriceOnly(i)&&(i.Discount=t.Amount,i.CouponDiscount=t.Amount),i)),e}itemConditionFullPriceOnly(e){return(e.Discount==0||e.CouponDiscount>0)&&e.DiscountAmount==0&&e.Price==e?.Variant?.UnitPrice&&f.IsEmpty(e.PriceBookID)}HandleDiscountAmount(e,t=!1){e.Amount>0?(e.ApplyToProduct?.length>0?this.applyDiscountInItem(e,t):(t?this._orderDataService.Data.Order.DiscountAmount=0:(this._orderDataService.Data.Order.DiscountAmount=e.Amount,this.showToastr(e)),this._orderDataService.pushNewValue()),this.resetCustomerPoint(t)):(this.role.Discount=t?this.originalRoleData.Discount:!0,this._userRoleService.pushNewValue(this.role))}applyDiscountInItem(e,t=!1){let i=this._orderDataService.Data;if(t)i.CartItems=this.resetItemsDisc(i.CartItems);else{let r=i.CartItems.filter(c=>e.ApplyToProduct.map(u=>u.ID)?.includes(c.VariantID));this.applyConfigItemsScope(e,r,t).subscribe(c=>{let u=c.map(O=>(O.DiscountAmount=e.Amount,O.CouponDiscount=e.Amount,O));i.CartItems=this.updateCartItems(u,e),this._orderDataService.pushNewValue(i),this.showToastr(e)})}}resetCustomerPoint(e){if(!e){let t=this._orderDataService.Data;t.Order.PointUsed=0}}handleCouponReturnAccess(e){let t=me(We,this.role);t.Return=!0,this._userRoleService.pushNewValue(t),this.isShowToastrInApplyCoupon()&&this.toastr.success("You got access to return a sales transaction!","Coupon Applied")}handleCouponParkedDeletionAccess(){let e=me(We,this.role);e.ParkedDeletionAuthorized=!0,this._userRoleService.pushNewValue(e),this.isShowToastrInApplyCoupon()&&this.toastr.success("You Have Access to delete park and delete item when retrieve!","Coupon Applied")}handleFullAccessCoupon(){let e=me(We,this.role);e.UnitPriceEditor=!0,e.Discount=!0,e.Return=!0,e.Tax=!0,e.NumberEditor=!0,e.DateEditor=!0,e.PricebookSelector=!0,e.DeleteItem=!0,e.ParkedDeletionAuthorized=!0,this._userRoleService.pushNewValue(e),this.isShowToastrInApplyCoupon()&&this.toastr.success("You now have Full Access for this Order!","Coupon Applied")}handleDeleteItemCoupon(){let e=me(We,this.role);e.DeleteItem=!0,this._userRoleService.pushNewValue(e),this.isShowToastrInApplyCoupon()&&this.toastr.success("You Have Access to delete item","Coupon Applied")}removeAppliedCoupon(e=!0){this._userRoleService.pushNewValue(this.originalRoleData),this._orderDataService.pushNewValue(this.salesOrderBeforePromotion()),this.salesOrderBeforePromotion.set(null),this._coupon.set(null),e&&this.toastr.warning("Coupon Cancelled","Warning")}resetCouponOnNewTransaction(){this._userRoleService.pushNewValue(this.originalRoleData),this._coupon.set(null)}removeAppliedDiscountOnCustomerChange(){if(this.coupon)switch(this.coupon.Requirement?.Type){case 1:this.HandleDiscountPercentage(this._coupon(),!0),this.removeAppliedCouponOnCustomerChange();break;case 2:this.HandleDiscountAmount(this._coupon(),!0),this.removeAppliedCouponOnCustomerChange();break}}removeAppliedCouponOnCustomerChange(){if(this.coupon){let e=this._orderDataService.Data;e.Order.PromotionCoupon=null,e.Order.PromotionNote=null,this._coupon.set(null),this._userRoleService.pushNewValue(this.originalRoleData),this._orderDataService.pushNewValue(e)}}isSameCartItem(e,t){return e.VariantID===t.VariantID&&e.Quantity===t.Quantity&&e.Price===t.Price&&e.Discount===t.Discount&&e.PriceBookID===t.PriceBookID}static \u0275fac=function(t){return new(t||n)(g(ge),g(L),g(De),g(F),g(se),g(wt))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Nt=class{CommissionID;ReturNumber;parkTemporaryItem;posState;InputTextValue;constructor(){this.posState=0,this.CommissionID="",this.ReturNumber="",this.parkTemporaryItem=[],this.InputTextValue=""}};var Fi=class n{constructor(e,t,i){this._promotionEventService=e;this._dialogRef=t;this.data=i;this.modalConfig=new ie,this.modalConfig.hideCancel=!0,this.modalConfig.hideClose=!0,this.modalConfig.headerType=de.Warning,this.modalConfig.title="Promotion Requirement unfulfilled!",this.modalConfig.customWidth="350px",this.modalConfig.okText="Ok",this.selectedPromotion=e.selectedPromotion}modalConfig;selectedPromotion;onOk(){this._promotionEventService.restoreOrder(),this._dialogRef.close()}static \u0275fac=function(t){return new(t||n)(P(Ae),P(te),P(fe))};static \u0275cmp=N({type:n,selectors:[["POS-modal-promotion-confirm"]],standalone:!1,decls:9,vars:4,consts:[[3,"onOk","config"],[1,"fst-italic","text-danger","mb-3"],[1,"mb-0"]],template:function(t,i){t&1&&(a(0,"modal-material",0),S("onOk",function(){return i.onOk()}),a(1,"content")(2,"div")(3,"h5"),d(4),s(),a(5,"p",1),d(6),s(),a(7,"p",2),d(8),s()()()()),t&2&&(p("config",i.modalConfig),l(4),M(i.selectedPromotion==null?null:i.selectedPromotion.Name),l(2),M(i.selectedPromotion==null?null:i.selectedPromotion.Description),l(2),M(i.data==null?null:i.data.message))},dependencies:[ne],encapsulation:2})};var Li=class extends xe{};var Vt=class n{constructor(e,t,i,o,r,c,u,O,k,W){this.variantService=e;this._posService=t;this._orderDataService=i;this.toastr=o;this._orderProcessorService=r;this._customerHttpService=c;this.promotionCouponService=u;this.promotionCouponExternalService=O;this.userRoleService=k;this.decimalPipe=W;this.subscribeToObservable()}salesOrderData;appConfigJson;entityID;audio=new Audio;subscribeToObservable(){this._posService.Data$.pipe(ee()).subscribe(e=>{this.appConfigJson=e.AppConfigJSON}),this._orderDataService.Data$.pipe(ee()).subscribe(e=>{this.salesOrderData=e,this.entityID=e.Order.EntityID}),this._orderProcessorService.Data$.pipe(ee()).subscribe(e=>{e.posState==3&&this.clearCartItemsInLocalStorage()})}addCartItemById(e,t,i=!0){return new Promise((o,r)=>{this.variantService.findVariantByID(e,this.entityID,i).then(c=>{this.createNewCartItem(c,t),o(c)}).catch(c=>{r(c)})})}addCartItemByCode(e){return new Promise((t,i)=>{let o=this.appConfigJson.ModuleSell.DigitalScale;o.Digit>0&&f.IsNotEmpty(o.Regex)&&e.length==o.Digit?this.parseDigitalScaleBarcodeWithRegex(e,o).then(c=>{c||(this.toastr.info("Matching Regex Rule to Barcode","Digital Scale"),this.findVariantByCode(e).then(u=>t(u)).catch(u=>i(u)))}):this.findVariantByCode(e).then(c=>t(c)).catch(c=>i(c))})}findVariantByCode(e){let t=this.appConfigJson.ModuleSell.BarcodeSerialEnabled;return new Promise((i,o)=>{this.variantService.findVariantByCode(e,this.entityID,t).then(r=>{i(r),this.createNewCartItem(r)}).catch(r=>{this.playBellRing(),o(r)})})}addItemBySerial(e){this.variantService.findVariantBySerial(e,this.entityID).subscribe(t=>{let i=this.salesOrderData.CartItems;if(i.length>0){let o,r=[],c=i.findIndex(u=>u.Variant.ID==t.ID);r=[],c!==-1?(o=i[c].Serial?.findIndex(u=>u.Number==e),r=[...i[c].Serial?i[c].Serial:[]],o==-1?(r.push({Number:e,Quantity:1}),i[c].Quantity=r.length):r.length>0?r[o].Quantity+=1:(r=[{Number:e,Quantity:1}],this.addNewSerials(t,e)),i[c].Serial=[...r],i[c].Quantity=i[c].calculateSerialQty(),this.updateCartItem(i[c],c)):this.addNewSerials(t,e)}else this.addNewSerials(t,e)})}addNewSerials(e,t){e.Serial=[{Number:t,Quantity:1}],this.createNewCartItem(e)}playBellRing(){this.audio.src="https://cdn.dealpos.xyz/web-audio/bell_ring.mp3",this.audio.load(),this.audio.play()}updateCartItem(e,t){this.salesOrderData.CartItems[t]=e,this._orderDataService.pushNewValue(this.salesOrderData),this.applyCustomerPoint(),this.reApplyPromotionCoupon(),this.saveItemsToLocalStorage()}deleteCartItem(e){this.salesOrderData.CartItems=this.salesOrderData.CartItems.filter(t=>t!==e),this._orderDataService.pushNewValue(this.salesOrderData),this.applyCustomerPoint(),this.isRemoveItemRequirement(e)&&this.reApplyPromotionCoupon()}parseDigitalScaleBarcodeWithRegex(e,t){return new Promise(i=>{let o=this.appConfigJson.ModuleSell.BarcodeSerialEnabled,r=new RegExp(t.Regex),c=e.match(r);if(console.log(c),f.IsNotEmpty(c)){let u=c[1],O=parseFloat(c[2]);console.log(O,"productQuantity"),O=O/t.QuantityDivider,this.variantService.findVariantByCode(u,this.entityID,o).then(k=>{this.createNewCartItem(k,null,O),i(!0)}).catch(()=>{i(!1)})}else i(!1)})}createNewCartItem(e,t,i){let o=new xe,r=this.appConfigJson.ModuleSell.ProductNotes.CopyProductDescription,c=this.appConfigJson.ModuleSell.ProductNotes.CopyPromotionName;o.patchByVariant(e,r,c),o=this.applyReward(o,t),f.IsEmpty(t)&&(o=this.applyPriceBook(o)),this.validateCartItem(o)&&(o.Quantity=i||o.Quantity,t?.PromotionType==2?this.handlingPromotionQuantity(o):this.pushNewItemToArray(o,o.PromotionGift),this.applyCustomerPoint()),this.addAvailableComponent(o)}applyCustomerPoint(){let e=this.salesOrderData.Order.CustomerID,t=f.IsEmpty(e);this._orderProcessorService.reedemPointToDiscount(t)}handlingPromotionQuantity(e){let t=me(xe,this.salesOrderData.CartItems),i=t.findIndex(o=>o.VariantID==e.VariantID&&o.PromotionGift);i!==-1?t[i].Quantity+=e.Quantity?e.Quantity:1:t=[...t,e],this.salesOrderData.CartItems=t,this._orderDataService.pushNewValue(this.salesOrderData)}applyPromotionProduct(e){let t=e.Variant.DiscountAmount;return t&&(e.Price=e.UnitPriceOriginal-t),e}applyReward(e,t){if(t){let i=this.appConfigJson.ModuleSell.ProductNotes.CopyPromotionName;e.Discount=t.Discount,e.Price=t.OriginalPrice;let o=t.OriginalPrice-t.UnitPrice;e.Price=e.UnitPriceOriginal-o,e.UnitPrice=e.UnitPriceOriginal-o,e.PromotionGift=!0,e.PromotionID=t.PromotionID,e.Quantity=t.Quantity?t.Quantity:1,e.PriceTypeID=3,e.Cost+=t.ExtraCost,e.UnitCost+=t.ExtraCost,e.PriceNote=t.PromotionName,i&&(e.Note=`${e.Note?e.Note:""} ${t.PromotionName} `)}return e}addAvailableComponent(e){let t=e.Price!=0,i=this.appConfigJson.ModuleSell.SellProductComponentDefaultPrice,o=e.Variant;if(o.Component!=null&&o.Component.length>0)for(let r of o.Component){let c=new Li;c.patchByVariant(r),c.Quantity=e.Quantity*r.Quantity,t&&!i&&(r.UnitPrice=0),c.Price=r.UnitPrice,this.pushNewItemToArray(c)}}pushNewItemToArray(e,t=!1){let i=this.salesOrderData.CartItems.findIndex(o=>o.VariantID==e.VariantID);if(e=this.applyPromotionProduct(e),i==-1||t)this.salesOrderData.CartItems.push(e);else{let o=this.appConfigJson.ModuleSell.QuickKey.NewRowBehaviour;if(o==2)this.salesOrderData.CartItems.push(e);else if(o==1)this._orderProcessorService.Data.posState==4?this.salesOrderData.CartItems.push(e):this.addingQuantityItem(i,e);else{if(!this.validatePrepaidPackage(e,i)){this.toastr.error("This prepaid package is already in the cart while editing. Please remove it first before adding again.","Cannot Add Item");return}this.addingQuantityItem(i,e)}}this._orderDataService.pushNewValue(this.salesOrderData),this.saveItemsToLocalStorage(),this.reApplyPromotionCoupon()}saveItemsToLocalStorage(){let e=this.userRoleService.Data.DeleteItem,t=this._orderProcessorService.Data?.posState;if(!e&&t!==4){let i=this._orderDataService.Data,o=i?.Order?.Number,r=i.CartItems,c={Number:o,CartItems:r};try{localStorage.setItem("cart_items",JSON.stringify(c))}catch(u){console.error("Error saving cart items to localStorage:",u)}}}clearCartItemsInLocalStorage(){localStorage.getItem("cart_items")&&(this.userRoleService.Data?.DeleteItem?this.clearCartItemsBasedOnCoupon():this.clearCartItemsStorage())}clearCartItemsBasedOnCoupon(){let e=this.promotionCouponService?.coupon;e&&(e.Requirement?.Type==5||e.Requirement?.Type==6)&&this.clearCartItemsStorage()}clearCartItemsStorage(){try{localStorage.removeItem("cart_items")}catch(e){console.error("Error clearing cart items from localStorage:",e)}}validatePrepaidPackage(e,t){let i=this.salesOrderData.CartItems[t],o=this._orderProcessorService.Data.posState,r=e.Variant.TypeID==10,c=f.IsNotEmpty(i.ID),u=!0;return o==2&&r&&c&&(u=!1),u}reApplyPromotionCoupon(){let e=this.salesOrderData.Order.CouponProvider,t=e=="Internal"||f.IsEmpty(e),i=this.salesOrderData.Order.PromotionCoupon,o=this.salesOrderData.Order.PromotionNote;f.IsNotEmpty(i)&&(t?this.promotionCouponService.RedeemCoupon(i,o,!0):this.promotionCouponExternalService.redeemCoupon(i,"External",o))}isRemoveItemRequirement(e){let t=this.promotionCouponService?.coupon,i=t?.ApplyToProduct,o=!0;return f.IsNotEmpty(t)&&i?.length>0&&(o=i.some(r=>r.ID==e.VariantID)),o}addingQuantityItem(e,t){let i=this.salesOrderData.CartItems.filter(u=>u.VariantID==t.VariantID),o=i.length,r=i.find(u=>!u.PromotionGift);this.salesOrderData.CartItems[e].PromotionGift&&o==1?this.salesOrderData.CartItems.push(t):(r.Quantity+=t.Quantity,r=this.applyPromotionProduct(r)),r&&(r=this.applyPriceBook(r))}validateCartItem(e){return e.Variant.CategoryTypeID==-1?(this.toastr.info(e.Variant.Name+" cannot be sold, check Category "+e.Variant.CategoryName+" settings","info"),!1):!(!this.validatePriceMinimum(e)||!this.validateSerialItem(e))}validatePriceMinimum(e){let t=!0,i=this.userRoleService.Data.PriceMinimum,o=this.appConfigJson.ModuleSell.ProductDialog.PriceMinimumTypeID;if(i){let r=0;switch(o){case 1:r=e.UnitPrice;break;case 2:r=e.UnitCost;break;case 3:r=e.UnitPriceMinimum;break}if(e.Price<r){t=!1;let c=f.StringFormat("You have no right to sell this item lower than {0}",this.decimalPipe.transform(r));alert(c)}}return t}validateSerialItem(e){let t=!0;if(e?.Serial?.length>0&&e.Variant.TypeID==4&&e.Quantity>0){let i=0;e?.Serial?.forEach(o=>{i+=o.Quantity}),i!=e.Quantity&&(this.toastr.error("Serial must be equal with the quantity","Error"),t=!1)}return t}applyPriceBook(e){let t=e.Variant.PriceBook!=null?e.Variant.PriceBook:[],i=this.findCustomerPricebook(t);if(t&&t.length!==0){let o=t.sort(function(r,c){return c.MinimumQuantity-r.MinimumQuantity}).filter(r=>e.Quantity>=r.MinimumQuantity&&r.MinimumQuantity!=0);o.length>0||f.IsNotEmpty(i)?f.IsNotEmpty(i)?e=this.applyPricebookToItem(e,i):e=this.applyPricebookToItem(e,o[0]):e=this.resetAppliedPricebook(e)}return e}resetAppliedPricebook(e){let i=(e?.Variant?.PriceBook).find(o=>o.ID==e.PriceBookID);return f.IsNotEmpty(i)&&(e.Discount=e.Variant.PriceDiscount,e.PriceBookID=f.GuidEmpty,e.Price=e.Variant.UnitPrice,e.UnitPrice=e.Variant.UnitPrice,e.PriceTypeID=0,e=this.applyPromotionProduct(e),e=this.removePromotionNote(e)),e}removePromotionNote(e){let t=this.appConfigJson.ModuleSell.ProductNotes;if(this.appConfigJson?.ModuleSell?.Pricebook?.PricebookVisible&&(e.Note=e.Note?.replace(e.PriceNote,""),e.PriceNote=""),t.CopyPromotionName){let o=e.Variant?.PriceNote;e.Note=`${o||""} ${e.Note?e.Note:""}`,e.PriceNote=o}return e}applyPricebookToItem(e,t){return e.Discount=t.PriceDiscount,e.UnitPrice=t.UnitPrice,e.PriceBookID=t.ID,e.Price=t.UnitPrice,e.PriceTypeID=2,e=this.assignItemNote(e,t),e}assignItemNote(e,t){return this.appConfigJson?.ModuleSell?.Pricebook?.PricebookVisible?(e.Note?.includes(e.PriceNote)?e.Note=e.Note?.replace(e.PriceNote,t.Name):e.Note=`${t.Name} ${e.Note?e.Note:""}`,e.PriceNote=t.Name):(e.Note="",e.PriceNote=""),e}findCustomerPricebook(e=[]){let t=this._customerHttpService.Data,i;return t&&(i=e.find(o=>o.ID==t.PricebookID)),i}static \u0275fac=function(t){return new(t||n)(g(Mo),g(z),g(L),g(F),g(je),g(Re),g(Rt),g(Bi),g(De),g(q))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};function Or(n,e){if(n&1&&(a(0,"div",2)(1,"div",4),b(2,"input",8),s()()),n&2){let t=m();l(2),p("formControl",t.searchControl)}}function Dr(n,e){n&1&&(a(0,"span"),d(1,"Apply"),s())}function Mr(n,e){n&1&&(a(0,"span"),d(1,"Applying..."),s())}function xr(n,e){if(n&1){let t=E();a(0,"tr")(1,"td"),d(2),s(),a(3,"td"),d(4),s(),a(5,"td",9),d(6),y(7,"number"),s(),a(8,"td",9),d(9),y(10,"number"),s(),a(11,"td",10)(12,"button",11),S("click",function(){let o=v(t).$implicit,r=m();return _(r.onSelectReward(o))}),h(13,Dr,2,0,"span"),h(14,Mr,2,0,"span"),s()()()}if(n&2){let t=e.$implicit,i=m();l(2),M(t.VariantName),l(2),M(t.VariantCode),l(2),M(x(7,7,t.OriginalPrice)),l(3),M(x(10,9,t.UnitPrice)),l(3),p("disabled",i.isApplyingReward()),l(),C(i.isApplyingReward()?-1:13),l(),C(i.isApplyingReward()?14:-1)}}var ji=class n{constructor(e,t,i,o,r,c){this._dialogRef=e;this._matDialog=t;this._shoppingCartService=i;this._promotionEventService=o;this._toastr=r;this.data=c;this.selectedPromotion=this._promotionEventService.selectedPromotion}modalConfig=new ie;selectedPromotion;rewards$;searchControl=new et;isApplyingReward=R(!1);ngOnInit(){this.modalConfig.title="Select a Reward",this.modalConfig.hideFooter=!0,this.initRewards(!0)}initRewards(e){this.rewards$=this.searchControl.valueChanges.pipe(li(""),ht(e?0:500),Fe(),Y(t=>{let i;return i=ke(this.data.rewards).pipe(J(o=>o.filter(r=>this.findKeywordInValue(t,r?.VariantCode)||this.findKeywordInValue(t,r?.VariantName)))),e=!0,i}))}findKeywordInValue(e,t){return t?.toUpperCase()?.indexOf(e?.toUpperCase())>-1}onSelectReward(e){return oi(this,null,function*(){if(!this.isApplyingReward()){this.isApplyingReward.set(!0);try{e.PromotionType=this.data.promotion.TypeID,yield this._shoppingCartService.addCartItemById(e.VariantID,e,!0).then(()=>{this._matDialog.closeAll(),this._promotionEventService.pushNewValue(this._promotionEventService.Data),this.showToastAppliedPromo()})}finally{this.isApplyingReward.set(!1)}}})}showToastAppliedPromo(){this._toastr.success("Applied "+this.selectedPromotion.Name+" to order!","Applied successfully!")}close(){this._dialogRef.close()}static \u0275fac=function(t){return new(t||n)(P(te),P(we),P(Vt),P(Ae),P(F),P(fe))};static \u0275cmp=N({type:n,selectors:[["POS-modal-select-item"]],standalone:!1,decls:23,vars:8,consts:[[3,"onCancel","onClose","config"],[1,"container"],[1,"row","mb-3"],[1,"row"],[1,"col-12"],[1,"table","table-bordered"],[1,"thead-light"],["scope","col"],["type","text","placeholder","Type to filter reward",1,"form-control",3,"formControl"],[1,"text-end"],[1,"text-center"],[1,"btn","btn-sm","btn-success",3,"click","disabled"]],template:function(t,i){t&1&&(a(0,"modal-material",0),S("onCancel",function(){return i.close()})("onClose",function(){return i.close()}),a(1,"content")(2,"div",1),h(3,Or,3,1,"div",2),a(4,"div",3)(5,"div",4)(6,"table",5)(7,"thead",6)(8,"tr")(9,"th",7),d(10,"Name"),s(),a(11,"th",7),d(12,"Code"),s(),a(13,"th",7),d(14,"Price"),s(),a(15,"th",7),d(16,"Promo"),s(),b(17,"th",7),s()(),a(18,"tbody"),K(19,xr,15,11,"tr",null,ve),y(21,"async"),y(22,"sortBy"),s()()()()()()()),t&2&&(p("config",i.modalConfig),l(3),C((i.data==null||i.data.rewards==null?null:i.data.rewards.length)>5?3:-1),l(16),Z(yt(22,4,x(21,2,i.rewards$),"desc","VariantCode")))},dependencies:[Te,Pe,St,ne,ze,q,Mt],styles:[".table-scroll[_ngcontent-%COMP%]{max-height:400px;overflow-y:auto}table[_ngcontent-%COMP%]{max-width:600px!important;overflow-x:hidden}"]})};function Ir(n,e){if(n&1&&(a(0,"div",3)(1,"div",5),b(2,"input",10),s()()),n&2){let t=m();l(2),p("formControl",t.searchCtrl)}}function Tr(n,e){n&1&&(a(0,"th",9),d(1,"Qty"),s())}function Er(n,e){n&1&&b(0,"th",8)}function wr(n,e){if(n&1){let t=E();a(0,"td")(1,"input",13),H("ngModelChange",function(o){v(t);let r=m().$implicit;return A(r.Quantity,o)||(r.Quantity=o),_(o)}),s()()}if(n&2){let t=m().$implicit;l(),B("ngModel",t.Quantity)}}function Rr(n,e){n&1&&(a(0,"span"),d(1,"Apply"),s())}function Nr(n,e){n&1&&(a(0,"span"),d(1,"Applying..."),s())}function Ar(n,e){if(n&1){let t=E();a(0,"td",12)(1,"button",14),S("click",function(){v(t);let o=m().$implicit,r=m();return _(r.onApplyReward(o))}),h(2,Rr,2,0,"span"),h(3,Nr,2,0,"span"),s()()}if(n&2){let t=m(2);l(),p("disabled",t.isApplyingReward()),l(),C(t.isApplyingReward()?-1:2),l(),C(t.isApplyingReward()?3:-1)}}function kr(n,e){if(n&1&&(a(0,"tr")(1,"td"),d(2),s(),a(3,"td"),d(4),s(),a(5,"td",11),d(6),y(7,"number"),s(),a(8,"td",11),d(9),y(10,"number"),s(),h(11,wr,2,1,"td")(12,Ar,4,3,"td",12),s()),n&2){let t=e.$implicit,i=m();l(2),M(t.VariantName),l(2),M(t.VariantCode),l(2),M(x(7,5,t.OriginalPrice)),l(3),M(x(10,7,t.UnitPrice)),l(2),C(i.rewardQuantity>1?11:12)}}var Qi=class n{constructor(e,t,i,o,r,c){this.data=e;this.shoppingCartService=t;this.promotionEventService=i;this.dialogRef=o;this.matDialog=r;this.toastr=c;this.searchCtrl=new et,this.rewardQuantity=e.rewardQuantity,this.sourceRewards=[...e.rewards]}modalConfig;rewards$;rewardQuantity;rewards;sourceRewards=[];searchCtrl;isApplyingReward=R(!1);ngOnInit(){this.initModalConfig(),this.initSearchCtrl(!0)}initModalConfig(){this.modalConfig=new ie,this.modalConfig.title="Select a Reward",this.rewardQuantity<2&&(this.modalConfig.hideFooter=!0)}initSearchCtrl(e){this.rewards$=this.searchCtrl.valueChanges.pipe(li(""),ht(e?0:500),Fe(),Y(t=>{let i;return i=ke(this.sourceRewards).pipe(J(o=>(o.length===1&&(o[0].Quantity=this.rewardQuantity),o)),J(o=>o.filter(r=>this.findKeywordInValue(t,r?.VariantCode)||this.findKeywordInValue(t,r?.VariantName)))),e=!1,i}),le(t=>{this.rewards=t}))}findKeywordInValue(e,t){return t?.toUpperCase()?.indexOf(e.toUpperCase())>-1}onApplyReward(e){return oi(this,null,function*(){if(!this.isApplyingReward()){this.isApplyingReward.set(!0);try{yield this.addRewardToShoppingCart(e)}finally{this.isApplyingReward.set(!1)}}})}onClose(){this.dialogRef.close()}onOk(){this.calculateRewardQty()>this.rewardQuantity?this.toastr.warning("Product reward exceeds the maximum amount earned","Warning"):[...this.rewards].filter(i=>i.Quantity>0).forEach(i=>{this.addRewardToShoppingCart(i)})}calculateRewardQty(){let e=0;return this.rewards.forEach(t=>{e+=t.Quantity?t.Quantity:0}),e}addRewardToShoppingCart(e){return e.PromotionType=this.data.promotion.TypeID,this.shoppingCartService.addCartItemById(e.VariantID,e,!0).then(()=>{this.matDialog.closeAll(),this.promotionEventService.pushNewValue(this.promotionEventService.Data)})}static \u0275fac=function(t){return new(t||n)(P(fe),P(Vt),P(Ae),P(te),P(we),P(F))};static \u0275cmp=N({type:n,selectors:[["app-modal-quantity-reward"]],standalone:!1,decls:27,vars:10,consts:[[3,"onCancel","onOk","onClose","config"],[1,"ms-3"],[1,"container"],[1,"row","mb-3"],[1,"row","table-scroll"],[1,"col-12"],[1,"table","table-bordered"],[1,"thead-light"],["scope","col"],["scope","col",2,"width","66px"],["type","text","placeholder","Type to filter reward",1,"form-control",3,"formControl"],[1,"text-end"],[1,"text-center"],["type","text","autoNum","","min","0",1,"form-control",3,"ngModelChange","ngModel"],[1,"btn","btn-sm","btn-success",3,"click","disabled"]],template:function(t,i){t&1&&(a(0,"modal-material",0),S("onCancel",function(){return i.onClose()})("onOk",function(){return i.onOk()})("onClose",function(){return i.onClose()}),a(1,"header")(2,"small",1),d(3),s()(),a(4,"content")(5,"div",2),h(6,Ir,3,1,"div",3),a(7,"div",4)(8,"div",5)(9,"table",6)(10,"thead",7)(11,"tr")(12,"th",8),d(13,"Name"),s(),a(14,"th",8),d(15,"Code"),s(),a(16,"th",8),d(17,"Price"),s(),a(18,"th",8),d(19,"Promo"),s(),h(20,Tr,2,0,"th",9)(21,Er,1,0,"th",8),s()(),a(22,"tbody"),K(23,kr,13,9,"tr",null,ve),y(25,"async"),y(26,"sortBy"),s()()()()()()()),t&2&&(p("config",i.modalConfig),l(3),D(" ( ",i.rewardQuantity," products reward ) "),l(3),C((i.sourceRewards==null?null:i.sourceRewards.length)>5?6:-1),l(14),C(i.rewardQuantity>1?20:21),l(3),Z(yt(26,6,x(25,4,i.rewards$),"desc","VariantCode")))},dependencies:[Te,Pe,Ee,St,ne,Dt,ze,q,Mt],encapsulation:2})};var Ae=class n{constructor(e,t,i,o,r,c,u,O,k){this._orderDataService=e;this._outletService=t;this._invoiceCalculatorService=i;this._dialog=o;this._httpService=r;this._posService=c;this._toastr=u;this._signalrService=O;this.decimalPipe=k;this.previousQuantity=0,this.previousTotalEligible=0,this.subscribeNotification(),this._posService.Data$.subscribe(W=>{this.taxes=W.Taxes}),this._outletService.Data$.subscribe(W=>{this.loadPromotions(W.Promotion)}),this._orderDataService.Data$.pipe(ce(W=>{this.salesOrderData=W;let ye=this.calculateOrderReward(W.getRewards()),_n=this.calculateOrderReward(this.previousRewards);return this.previousQuantity!=W.TotalQuantity||_n<ye||this.isRestroreOrder}),ht(100)).subscribe(W=>{this.isRestroreOrder=!1,this.checkQtyPromotion(),this.applyQuantityPromotion(),this.previousRewards=[...W.getRewards()]}),this._invoiceCalculatorService.Data$.subscribe(W=>{this.checkEligiblePromotionWithMinSpend()})}_Data=new be([]);get Data(){return this._Data.getValue()}Data$=this._Data.asObservable();selectedPromotion=null;onClickToastPromo=new Me;previousQuantity;salesOrderData;orderDataBeforePromotion;taxes=[];previousTotalEligible;previousRewards=[];isRestroreOrder=!1;calculateOrderReward(e){let t=0;return e.length>0&&(t=e.map(i=>i.Quantity).reduce((i,o)=>i+o)),t}checkQtyPromotion(){let e=this._orderDataService.Data;this.checkEligibleQtyPromotion(e.CartItems),this.checkEligibleTierPromotion(e.CartItems),this.previousQuantity=e.TotalQuantity}subscribeNotification(){this._signalrService.OnPromotionEventChange.pipe(ee(),Y(()=>{let e=this._outletService.Data?.RegisterID;return this.getPromotions(e)})).subscribe(()=>{this._toastr.info("Promotion Event Updated","Promotion Update")})}getPromotions(e){return this._httpService.get(U.GetListPromotion,[{key:"RegisterID",value:e}]).pipe(le(t=>{this.loadPromotions(t)}))}loadPromotions(e){let t=this.getPromotionDesc(e);this.pushNewValue(t),this.checkQtyPromotion(),this.checkEligiblePromotionWithMinSpend()}pushNewValue(e){this.showToastEligiblePromotion(),this._Data.next(e)}checkSelectedPromotionRequirement(e){this.selectedPromotion!=null&&this.selectedPromotion.TypeID==e&&this.Data.find(i=>i.ID===this.selectedPromotion.ID)?.Eligible===!1&&(this._dialog.open(Fi,{id:"modal-promotion-confirm",data:{message:"Order will be restored to before the promotion is applied"},disableClose:!0}),this.isRestroreOrder=!0)}restoreOrder(){this._orderDataService.pushNewValue(this.orderDataBeforePromotion),this.selectedPromotion=null}getPromotionDesc(e=[]){return e?.map(i=>(i.Description=this.generatePromotionDesc(i),i))}checkEligiblePromotionWithMinSpend(){let e=this._invoiceCalculatorService.Data,t=this.Data?.filter(o=>(o.TypeID===1||o.TypeID==3)&&!this.checkExpiredPromotion(o)).map(o=>(e>=o.MinimumAmount?o.Eligible=!0:o.Eligible=!1,o)),i=this.mappingEligiblePromotion(t);this.pushNewValue(i),this.checkSelectedPromotionRequirement(1),this.checkSelectedPromotionRequirement(3)}checkEligibleQtyPromotion(e){let t=0,i=this.Data?.filter(r=>r.TypeID===2&&!this.checkExpiredPromotion(r)).map(r=>(r.Eligible=!1,r.ListVariant.length>0?(t=this.getQuantityByRequirementType(e,"variant",r.ListVariant),t>=r.MinimumAmount&&(r.Eligible=!0)):r.ListCategory.length>0?(t=this.getQuantityByRequirementType(e,"category",r.ListCategory),t>=r.MinimumAmount&&(r.Eligible=!0)):this.salesOrderData.TotalQuantity>=r.MinimumAmount&&(r.Eligible=!0),r)),o=this.mappingEligiblePromotion(i);this.pushNewValue(o)}checkEligibleTierPromotion(e){let t,i=this.Data?.filter(r=>r.TypeID===5&&!this.checkExpiredPromotion(r)).map(r=>(r.Eligible=!1,r.ListVariant.length>0?t=this.getQuantityByRequirementType(e,"variant",r.ListVariant):r.ListCategory.length>0?t=this.getQuantityByRequirementType(e,"category",r.ListCategory):t=this.salesOrderData.TotalQuantity,r.PromotionTieredQuantity.forEach(c=>{t>=c.Quantity&&(r.Eligible=!0)}),r)),o=this.mappingEligiblePromotion(i);this.pushNewValue(o)}getQuantityByRequirementType(e,t,i){let o=0,r;return t=="variant"?e.forEach(c=>{r=i.findIndex(u=>u.ID===c.VariantID),r!==-1&&(o+=c.Quantity)}):e.forEach(c=>{c.Variant&&(r=i.findIndex(u=>u.ID===c.Variant.CategoryID),r!==-1&&(o+=c.Quantity))}),o}mappingEligiblePromotion(e=[]){let t=this.Data;if(e?.length>0){let i;t=this.Data?.map(o=>(i=e.findIndex(r=>r.ID==o.ID),i!==-1&&(o=e[i]),o))}return t}checkExpiredPromotion(e){let t=new Date,i=new Date(e.StartDate),r=(f.IsEmpty(e.StartTime)?"00:00:00":e.StartTime).split(":").map(k=>parseInt(k));i.setHours(r[0],r[1],r[2]);let c=new Date(e.ExpirationDate),O=(f.IsEmpty(e.EndTime)?"23:59:59":e.EndTime).split(":").map(k=>parseInt(k));return c.setHours(O[0],O[1],O[2]),!(t.getTime()>=i.getTime()&&t.getTime()<=c.getTime())}showToastEligiblePromotion(){let e=this.getTotalEligiblePromotion(),t=f.IsNotEmpty(this.salesOrderData.Order.ID);this.previousTotalEligible!==e&&e>0&&!t&&this._toastr.info(e+" promotion(s) can be applied!","Promo available!",{timeOut:2e4}).onTap.pipe(Qe(1)).subscribe(()=>{this.onClickToastPromo.next(!0)}),this.previousTotalEligible=e}getTotalEligiblePromotion(){return this.Data?.filter(t=>t.Eligible).length}generatePromotionDesc(e){let t="";switch(e.TypeID){case 2:t+="Minimum "+this.decimalPipe.transform(e.MinimumAmount)+" ",e.ListVariant.length>0?(t=t+" piece of ",t+=this.generateItemListDescription(e.ListVariant)):e.ListCategory.length>0?(t+="from category ",t+=this.generateItemListDescription(e.ListCategory)):t+="items";break;case 1:t+="Minimum spend Rp. "+this.decimalPipe.transform(e.MinimumAmount);break;case 3:t+=`Apply
|
|
1
|
+
import{a as xo}from"./chunk-YXCPHYC5.js";import{a as Jt,b as zt}from"./chunk-JFLT7NX3.js";import{a as Bo}from"./chunk-RACYAEOL.js";import{a as Di}from"./chunk-GGDW5WFA.js";import{e as wo}from"./chunk-QJUU75N6.js";import{b as ko}from"./chunk-D7DUI5NF.js";import{d as Ao}from"./chunk-TXJJUZ26.js";import{a as No}from"./chunk-BNNKSBQ6.js";import{a as Io}from"./chunk-IZLEZJ6U.js";import{a as he,b as Re,e as Lo}from"./chunk-4XJWQAS6.js";import{b as Eo}from"./chunk-DC3TCY6D.js";import{a as Do,b as Vo,c as Fo}from"./chunk-CQLZHUT4.js";import{a as Mo}from"./chunk-S27D5MBU.js";import{a as jo}from"./chunk-HGSF7LOB.js";import{c as Dn,d as Oo}from"./chunk-7BVPHIEF.js";import{a as lo}from"./chunk-T7XU5W5A.js";import{a as Mt}from"./chunk-25H27N7N.js";import{a as To}from"./chunk-MNJSQKLX.js";import{a as Mi,b as xi,c as Ii}from"./chunk-OXWQ7ZZS.js";import{a as Ro}from"./chunk-4CPRMZL6.js";import{a as Ho}from"./chunk-ESDXMFGP.js";import{a as Ke}from"./chunk-J6U6UYNI.js";import{a as tt,b as dt,c as de}from"./chunk-NSNUUKNK.js";import{a as Oi,b as xe}from"./chunk-EN2Y56CS.js";import{a as Pn,b as $t,c as On}from"./chunk-PXDS3HXW.js";import{b as Po}from"./chunk-WKM2QOAU.js";import{a as So}from"./chunk-ZMJLTU5O.js";import{g as bo}from"./chunk-PRVQ3NAP.js";import{d as Pi}from"./chunk-WMZLH4YK.js";import{p as mo}from"./chunk-6WATOQG3.js";import{d as co}from"./chunk-XTCEZONP.js";import{a as go,c as Ot}from"./chunk-D4FCXEV4.js";import{g as po}from"./chunk-6P2ASCNY.js";import{B as _o,C as oe,D as Oe,G as yo,u as ie,v as ne,w as Pt}from"./chunk-26YFRPR2.js";import{b as yi,c as qt}from"./chunk-JBS5UYZC.js";import{F as Dt,N as Si,O as U,g as fo,n as bi,o as ho,q as Co,t as vo}from"./chunk-TEGIL5RZ.js";import{a as rt}from"./chunk-B7AC4RMR.js";import{a as fi,c as hi}from"./chunk-EQLHPWVB.js";import{d as St,e as uo}from"./chunk-THT6CY5E.js";import{a as ee,b as so,e as te,f as fe,g as we}from"./chunk-ZTD4APMR.js";import{a as me}from"./chunk-2FWFPV5I.js";import{A as ro,B as ao,F as vi,c as Te,e as Ci,h as Pe,i as Xn,k as eo,l as et,n as to,o as Ee,p as io,s as bt,x as no,y as oo}from"./chunk-DWZ5JTI2.js";import{b as _i}from"./chunk-WFQIMZGL.js";import{a as f}from"./chunk-WUV22SZ4.js";import{a as Zn}from"./chunk-EAEOJMTA.js";import{p as L,s as ge}from"./chunk-LGOSIAUC.js";import{$ as si,Ab as C,Bb as ot,Bc as jn,Ca as R,Cb as ve,Db as K,E as ce,Eb as Z,Fb as p,Fc as y,Gb as a,Gc as x,Gd as $n,Hb as s,Hc as X,I as nt,Ib as b,Ic as _t,Jb as N,Kb as k,Kd as Jn,Lb as Xe,Lc as Qn,M as ht,Mb as Ct,N as Qe,Nb as vt,Ob as di,Oc as se,Pb as E,Pd as zn,Q as Fe,Qa as Je,Qb as Fn,Qd as Yn,Sa as mt,Sb as S,Sc as yt,Sd as Kn,Ta as Vn,Tb as Ln,Tc as Gt,Ub as d,Xa as l,Xc as gi,Y as Le,Yb as Qt,Zb as Ut,_b as Wt,aa as Y,b as oi,cc as ue,d as Me,da as Ie,dc as Bn,e as be,eb as P,fa as le,gc as pi,gd as Be,hc as m,ib as A,ic as O,id as Un,jb as ci,jc as M,jd as Wn,k as gt,kc as ui,la as I,lc as Hn,ma as li,mc as H,md as Gn,n as An,nc as V,nd as qn,o as ke,oa as g,ob as $,oc as j,od as ze,p as ft,pa as T,q as ri,qd as Ye,r as ai,sd as q,t as J,ta as v,u as $e,ua as _,v as kn,vd as Se,wb as mi,yb as h,yc as Q,zb as Sn,zc as Ue}from"./chunk-IEVGW2RT.js";import{a as ii,i as Ze,k as ni}from"./chunk-SNAKHGZS.js";var We=class{constructor(e){this.roleService=e;e&&this.setRole()}_Retrieve;_DateEditor;_NumberEditor;_PriceVisible;_UnitPriceEditor;_PricebookSelector;_Cost;_Return;_Discount;_SalesPerson;_PriceMinimum;_Payment;_CreditSalesLock;_CustomerInputLock;_PaymentCodeLock;_Shipping;_Tax;_DeleteItem;_BundlingPrice;_EmailRestriction;_ParkedDeletionAuthorized;_SellEditor;_ContactCreate;_PrepaidPackageCreate;_Order;_Reprint;_Contacts;_ContactsCreate;_InventoryView;_DebtView;_ClearCart;_SellDelete;_DeliveryEditor;_CouponInputLock;_Park;_Commission;setRole(){this._Retrieve=this.roleService.sell.RetrieveR,this._DateEditor=this.roleService.global.Date,this._NumberEditor=this.roleService.sell.Number,this._PriceVisible=this.roleService.sell.PriceVisible,this._SalesPerson=this.roleService.sell.SalesPerson,this._UnitPriceEditor=this.roleService.sell.UnitPriceEditor,this._PricebookSelector=this.roleService.sell.PricebookSelector,this._Cost=this.roleService.product.Cost,this._Return=this.roleService.sell.Return,this._Discount=this.roleService.sell.Discount,this._PriceMinimum=this.roleService.sell.PriceMinimum,this._Payment=this.roleService.sell.Payment,this._CreditSalesLock=this.roleService.sell.CreditSalesLock,this._CustomerInputLock=this.roleService.sell.CustomerInputLock,this._PaymentCodeLock=this.roleService.sell.PaymentCodeLock,this._Shipping=this.roleService.sell.Shipping,this._Tax=this.roleService.sell.Tax,this._DeleteItem=this.roleService.sell.DeleteItem,this._BundlingPrice=this.roleService.sell.BundlingPrice,this._EmailRestriction=this.roleService.sell.Email,this._SellEditor=this.roleService.sell.Edit,this._ContactCreate=this.roleService.contact.Create,this._PrepaidPackageCreate=this.roleService.prepaidPackage.Create,this._Order=this.roleService.order.View,this._Contacts=this.roleService.contact.View,this._ContactsCreate=this.roleService.contact.Create,this._InventoryView=this.roleService.inventory.View,this._DebtView=this.roleService.debt.View,this._ClearCart=this.roleService.sell.DeleteItem,this._SellDelete=this.roleService.sell.Delete,this._DeliveryEditor=this.roleService.logistic.Edit,this._Reprint=this.roleService.order.Print,this._CouponInputLock=this.roleService.sell.CouponInputLock,this._Park=this.roleService.sell.Park,this._Commission=this.roleService.product.CommissionView}get Park(){return this._Park}get CouponInputLock(){return this._CouponInputLock}set CouponInputLock(e){this._CouponInputLock=e}get Retrieve(){return this._Retrieve}get DateEditor(){return this._DateEditor}set DateEditor(e){this._DateEditor=e}get NumberEditor(){return this._NumberEditor}set NumberEditor(e){this._NumberEditor=e}get PriceVisible(){return this._PriceVisible}get UnitPriceEditor(){return this._UnitPriceEditor}set UnitPriceEditor(e){this._UnitPriceEditor=e}get PricebookSelector(){return this._PricebookSelector}set PricebookSelector(e){this._PricebookSelector=e}get Cost(){return this._Cost}get Return(){return this._Return}set Return(e){this._Return=e}get Discount(){return this._Discount}set Discount(e){this._Discount=e}get SalesPerson(){return this._SalesPerson}get PriceMinimum(){return this._PriceMinimum}get Payment(){return this._Payment}get CreditSalesLock(){return this._CreditSalesLock}get CustomerInputLock(){return this._CustomerInputLock}get PaymentCodeLock(){return this._PaymentCodeLock}get Shipping(){return this._Shipping}get Tax(){return this._Tax}set Tax(e){this._Tax=e}get DeleteItem(){return this._DeleteItem}set DeleteItem(e){this._DeleteItem=e}get BundlingPrice(){return this._BundlingPrice}get Email(){return this._EmailRestriction}get ParkedDeletionAuthorized(){return this._ParkedDeletionAuthorized}set ParkedDeletionAuthorized(e){this._ParkedDeletionAuthorized=e}get SellEditor(){return this._SellEditor}get PrepaidPackageCreate(){return this._PrepaidPackageCreate}get Order(){return this._Order}get Reprint(){return this._Reprint}get Contacts(){return this._Contacts}get ContactsCreate(){return this._ContactsCreate}get InventoryView(){return this._InventoryView}get DebtView(){return this._DebtView}get ClearCartRestriction(){return this._ClearCart}get SellDelete(){return this._SellDelete}get DeliveryEditor(){return this._DeliveryEditor}get Commission(){return this._Commission}};var Yt=class{DeliveryEntityID;Type;NewOrderID;constructor(){this.DeliveryEntityID="",this.Type=3}};var Ti=class{Type;Amount;Notification;ApplyToProduct;Requirement};var G=class{Order;Invoice;Shipping;Action;Payments;Items;CartItems;Promotion;ContactName;SplitParkLabel;get cartQuantity(){let e=0;for(let t of this.CartItems)e+=t.Quantity;return e}constructor(){this.Order=new Dn,this.Invoice=new $t,this.Shipping=new On,this.Action=new Yt,this.Payments=Array(),this.Items=Array(),this.CartItems=Array(),this.ContactName=""}get TotalPaidAmount(){let e=0;return this.Payments.forEach(t=>{e+=t.PaidAmount}),e}get RedeemableAmount(){let e=this.CartItems.filter(t=>t.Variant.PaymentTypeID!=1);return this.GetAmountByCart(e)}get TotalQuantity(){let e=0;return this.CartItems.forEach(t=>{t.PromotionGift||(e+=t.Quantity)}),e}get CashOnlyAmount(){let e=this.CartItems.filter(t=>t.Variant.PaymentTypeID==1);return this.GetAmountByCart(e)}get PointOnlyAmount(){let e=this.CartItems.filter(t=>t.Variant.PaymentTypeID==2);return this.GetAmountByCart(e)}get PrepaidPackageItem(){return this.CartItems.filter(t=>t.Variant.TypeID==10)}GetAmountByCart(e){let t=0;return e.forEach(i=>{t+=i.Total}),t=t*(100-this.Order.Discount)/100,t=t*(100-this.Order.Discount2)/100,t}getRewards(){return this.CartItems.filter(t=>t.PromotionGift)}};Ze([tt(()=>Dn)],G.prototype,"Order",2),Ze([tt(()=>$t)],G.prototype,"Invoice",2),Ze([tt(()=>On)],G.prototype,"Shipping",2),Ze([tt(()=>Yt)],G.prototype,"Action",2),Ze([tt(()=>Ke)],G.prototype,"Payments",2),Ze([tt(()=>Oi)],G.prototype,"Items",2),Ze([tt(()=>xe)],G.prototype,"CartItems",2),Ze([tt(()=>Ti)],G.prototype,"Promotion",2);var Ei=class{Success;Message;message;ObjectID;SalesOrderID;OutDeliveryID;Contact;LoyaltyPoint;InvoiceNumber;Creator;OrderTimeString;PrintMode;PaymentStateID;PaymentStateLabel;Final;InvoiceNumberResult;constructor(){this.Success=!0,this.Message="",this.ObjectID="",this.SalesOrderID="",this.OutDeliveryID="",this.Contact=null,this.LoyaltyPoint="",this.InvoiceNumber="",this.Creator="",this.OrderTimeString="",this.PrintMode=0,this.PaymentStateID=0,this.PaymentStateLabel="",this.Final=0}};var xt=class n{constructor(e,t,i,o){this.httpService=e;this._localDataService=t;this._onlineStatusService=i;this._toastrService=o;this._onlineStatusService.getOnlineStatus$().subscribe(r=>{this.isOnline=r})}_Data=new be(null);Data$=this._Data.pipe(Fe(),ce(e=>e!==null));isOnline;get Data(){return this._Data.value}pushNewValue(e){this._Data.next(e)}getSalesOrderPrint(e){return this.httpService.post("/API/POS/GetSalesOrderPrint",{TemplateID:e})}submitOrder(e,t){let i=this.generatePOSDataForSubmission(e,this.isOnline);if(this.isOnline)return this.submitOnline(i).pipe(this.handleTimeOutError(i));if(t.ModuleSell.EnableOfflineTransaction)return this._localDataService.syncOrder(i).pipe(J(()=>this.generateCompleteData(i)));this._toastrService.warning("Offline order is not Supported!","Info!")}uploadOfflineOrder(e){return this._localDataService.uploadSingleOrder(e).pipe(nt(t=>t?.message?.includes("objectStore does not exists")?this.submitOnline(e):ft(()=>t)))}submitOnline(e){return this.httpService.post(U.SubmitOrder,e,Zn.pos.submitOrderTimeout)}handleTimeOutError(e){return oi(nt(t=>{if(t instanceof ai||t?.name=="TimeoutError"){let i=this.generateCompleteData(e);this.pushNewValue(i)}throw t}))}generatePOSDataForSubmission(e,t=!0){let i=Object.assign(new G,e);i.Items=[],i.Order.CustomerID==null&&(i.Order.CustomerID=f.GuidEmpty),i.Order.SalesID==null&&(i.Order.SalesID=f.GuidEmpty);let o=1;i.Payments=i.Payments.map(c=>(c.Date=i.Order.Date,c.Index=o,o++,delete c.TypeID,c));let r=1;for(let c of i.CartItems){let u=new Oi;u.ID=c.ID,u.VariantID=c.VariantID,u.Quantity=c.Quantity,u.Cost=c.Cost,u.Price=c.Price,u.Discount=c.Discount,u.DiscountAmount=c.DiscountAmount,u.Note=c.Note,u.Taxable=c.Variant.Taxable,u.LoyaltyPoint=c.LoyaltyPoint,u.UnitCost=c.Cost,u.UnitPrice=c.Price,u.UnitPriceOriginal=c.UnitPriceOriginal,u.UnitExpense=c.UnitExpense,u.EntityID=c.EntityID,u.Index=r,u.UnitQuantity=c.UnitQuantity,u.PriceTypeID=c.PriceTypeID,u.PriceNote=c.PriceNote,u.Splited=c.SplitQuantity>0,u.SplitQuantity=c.SplitQuantity,u.InventoryTypeID=c.Variant.TypeID,u.SalesID="",u.Serial=c.Serial,c.SalesID&&(u.SalesID=c.SalesID),delete c.CouponDiscount,i.Items.push(u),r++}return t?(delete i.CartItems,delete i.Order.ClientTimestamp):i.Order.ClientTimestamp=new Date,i}generateCompleteData(e){let t=new Ei;return t.InvoiceNumber=e.Order.Number,t.OrderTimeString=new Date().toString(),t.PaymentStateID=e.Action?.Type,t.PaymentStateLabel="Offline",t.Success=!0,t.OutDeliveryID=e.Action.DeliveryEntityID,t}GetReturnInvoice(e,t){return this.httpService.get(U.ReturInvoice,[{key:"EntityID",value:t},{key:"Number",value:e}])}GetInvoiceBySoID(e){return this.httpService.get(U.GetPOSDataByID,[{key:"ID",value:e}])}UploadCSV(e,t){let i={CartItems:e,EntityID:t};return this.httpService.post(U.UploadCsv,i)}sendEmail(e,t){return new Promise((i,o)=>{this._localDataService.isProductFromServer().subscribe(r=>{if(r){let c={invoiceID:t,email:e};this.httpService.post(U.SendInvoiceEmail,c).subscribe({next:u=>{i(u)},error:u=>{o(u)}})}else o(oe.wrongOfflineAction)})})}sendWhatsaap(e,t){let i={InvoiceID:e,PhoneNumber:t};return this.httpService.post(U.SendInvoiceWhatsapp,i)}createCustomerByInvoice(e,t){let i={InvoiceID:e,Mobile:t};return this.httpService.post(U.CreateCustomerInvoice,i)}saveCommission(e,t){let i={SOID:e,commission:t};return this.httpService.POSText("/API/Transaction/SetCommission",i)}generateReceiptA4(e){let t={ID:e};return this.httpService.post(U.InvoiceA4,t)}getVacant(e){return this.httpService.get(U.GetVacant,[{key:"EntityID",value:e}])}static \u0275fac=function(t){return new(t||n)(g(ge),g(Oe),g(he),g(L))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Zt=(r=>(r[r.cash=1]="cash",r[r.card=2]="card",r[r.emoney=3]="emoney",r[r.other=4]="other",r[r.ECR=99]="ECR",r))(Zt||{});var B=class n{constructor(e,t,i){this._OrderHttpService=e;this._customerHttpService=t;this._toastrService=i}_Data=new be(new G);transaction_id;Data$=this._Data.asObservable();get Data(){return this._Data.value}pushNewValue(e){if(e)this._Data.next(e);else{let t=this.Data;this._Data.next(t)}}submitOrder(e){return new Promise((t,i)=>{this.checkTransactionId(),this._OrderHttpService.submitOrder(this.Data,e).subscribe({next:o=>{t(o)},error:o=>{this.Data.Items=[],i(o)}})})}uploadOfflineOrder(){return this.checkTransactionId(),this._OrderHttpService.uploadOfflineOrder(this.Data)}checkTransactionId(){let t=this.Data.Payments.find(i=>i.TypeID==3);f.IsNotEmpty(t)&&f.IsEmpty(this.transaction_id)&&this._toastrService.warning("Midtrans transaction_id is empty. Please verify manually!","Mobile Payment Failure")}updateCustomerID(e){return this.Data.Order.CustomerID=e,this.pushNewValue(this.Data),new Promise((t,i)=>{this._customerHttpService.GetPrivilegeByID(e,this.Data.Order.EntityID).subscribe({next:o=>{this._customerHttpService.Data=o,this.pushNewValue(this.Data),t(o)},error:o=>{this.Data.Order.CustomerID=null,this.Data.ContactName=null;let r=o.error?.Message;o.status==409?this._toastrService.warning(r,"Warning"):this._toastrService.error(r,`API Error - ${o.status}`),i(o)}})})}static \u0275fac=function(t){return new(t||n)(g(xt),g(Re),g(L))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var z=class n{constructor(e,t,i){this._localDataService=e;this._onlineStatusService=t;this._httpService=i;this._onlineStatusService.getOnlineStatus$().subscribe(o=>{this.isOnline=o})}_Data=new be(null);Data$=this._Data.asObservable().pipe(ce(e=>e!==null),Fe());isOnline;get Data(){return this._Data.value}pushNewValue(e){this._Data.next(e)}requestObservable(){return this.isOnline?this._httpService.get(U.GetPOSStorage).pipe(J(e=>({data:e,type:"Online"}))):this._localDataService.getPOSStorage().pipe(ce(e=>e!=null),J(e=>({data:e,type:"Offline"})))}getOutletName(e){return this.Data.Entities.find(i=>i.ID==e)?.Name}static \u0275fac=function(t){return new(t||n)(g(Oe),g(he),g(ge))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var De=class n{constructor(e){this.roleService=e;this.pushNewValue(new We(e))}_Data=new be(new We(null));get Data(){return this._Data.value}Data$=this._Data.asObservable();pushNewValue(e){this._Data.next(e)}static \u0275fac=function(t){return new(t||n)(g(_i))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var ei=class{ID;Code;EntityID;Name;Description;Start;StartDisplay;State;Open;CashierID;OpeningCash;EntityName;LoginID;Active;CustomerDisplayEnabled;OvoConfigurationID;CustomerDisplayID;ListImage;Suspended};var wi=class n{odsConfigType=R(0);setODSConfig(e){this.odsConfigType.set(e)}isEnabled(){return this.odsConfigType()>0}static \u0275fac=function(t){return new(t||n)};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var sr=n=>({active:n}),lr=n=>({gray:n});function cr(n,e){if(n&1){let t=E();a(0,"span",15),S("click",function(o){v(t);let r=d().$implicit;return d().closeRegister(r),_(o.stopPropagation())}),s()}}function mr(n,e){n&1&&(a(0,"div")(1,"span",16),m(2,"VACANT"),s()())}function dr(n,e){if(n&1&&(a(0,"div")(1,"span",17),b(2,"i",18),a(3,"span",19),m(4),s()(),a(5,"span",20),b(6,"i",21),a(7,"span",19),m(8),s()()()),n&2){let t=d().$implicit;l(4),O(t.LoginID),l(4),M("",t.StartDisplay.split(" ")[3]," - Now")}}function pr(n,e){if(n&1){let t=E();a(0,"div",8)(1,"div",9)(2,"div",10)(3,"h5",11),S("click",function(){let o=v(t).$implicit,r=d();return _(r.select(o))}),a(4,"span"),b(5,"i",12),m(6),y(7,"limitTo"),s(),h(8,cr,1,0,"span",13),s(),a(9,"div",14),S("click",function(){let o=v(t).$implicit,r=d();return _(r.select(o))}),h(10,mr,3,0,"div")(11,dr,9,2,"div"),s()()()()}if(n&2){let t,i=e.$implicit,o=d();l(),p("ngClass",i.Active?"active":""),l(),p("ngClass",Q(9,sr,(i==null?null:i.ID)==(o.selectedRegister==null?null:o.selectedRegister.ID))),l(),p("ngClass",Q(11,lr,i!=o.selectedRegister)),l(3),O(X(7,6,i.Name,15)),l(2),C(i.State!="Close"?8:-1),l(2),C((t=i.State)==="Close"?10:t==="Open"?11:-1)}}var Ri=class n{constructor(e,t,i,o,r,c,u){this._dialogRef=e;this._outletService=t;this._posService=i;this._userRoleService=o;this.router=r;this.httpService=c;this._odsService=u}originalSelectedRegister=null;registers;searchInput="";selectedRegister=new ei;modalConfig=new ie;role;get AppConfigJSON(){return this._posService.Data.AppConfigJSON}destroy$=new Me;ngOnInit(){this.subscribeToObsChanges(),this.initModalConfig()}subscribeToObsChanges(){this._posService.Data$.pipe(Ie(this.destroy$)).subscribe(e=>{this.registers=e.Registers}),this._outletService.Data$.pipe(Ie(this.destroy$)).subscribe(e=>{this.selectedRegister=this.findOutletRegisterById(e.RegisterID),this.originalSelectedRegister=this.selectedRegister?ii({},this.selectedRegister):null}),this._userRoleService.Data$.pipe(Ie(this.destroy$)).subscribe(e=>{this.role=e})}findOutletRegisterById(e){let t=this.registers.find(i=>i.ID===e);return t||new ei}initModalConfig(){this.modalConfig.hideFooter=!0,this.modalConfig.hideScrollbar=!0,this.modalConfig.title="Choose an outlet"}ngOnDestroy(){this.destroy$.next(!0),this.destroy$.complete()}onClose(){this._dialogRef.close()}select(e){if(this.AppConfigJSON.ModuleShift.Closure.Enabled)if(this.selectedRegister.ID!=null&&this.selectedRegister.Open&&e.CashierID==null)confirm("You already have an active register with "+this.selectedRegister.Name+`!
|
|
2
|
+
Do you want to end your session?`)&&(this.onClose(),this.router.navigate(["menu/Shift/Main/My_Shift"],{queryParams:{RegisterID:e.ID}}));else if(!e.Open||this.selectedRegister.ID==e.ID)this.selectedRegister=e,this.onSubmitSelectedRegister();else{if(this.role.SellEditor==!1){alert("You cannot end shift for Register "+e.Name+" - Unauthorized Access");return}alert("This Register has already active register, Are you sure you want to end this register?"),this.onClose(),this.router.navigate(["/menu/Shift/Main/My_Shift"],{queryParams:{RegisterID:e.ID}})}else this.selectedRegister=e,this.onSubmitSelectedRegister()}onSubmitSelectedRegister(){if(this.selectedRegister.ID==null){alert("Please select a register first!");return}this._outletService.pushNewRegister(this.selectedRegister),this.loadOdsConfig(this.selectedRegister.EntityID),this._dialogRef.close({selectedRegister:this.selectedRegister,openStartingCashDialog:this.selectedRegister.ID!=this.originalSelectedRegister?.ID})}closeRegister(e){let t=this.selectedRegister.ID;if(this.role.SellEditor==!1){alert("You cannot end shift for Register "+e.Name+" - Unauthorized Access");return}t==e.ID?this.router.navigate(["/menu/Shift/Main/My_Shift"]):this.router.navigate(["/menu/Shift/Main/My_Shift"],{queryParams:{RegisterID:e.ID}}),this.onClose()}loadOdsConfig(e){this.httpService.get(`/api/outlet/GetOrderDisplayBroadcastMode?EntityID=${e}`).pipe(le(t=>{this._odsService.setODSConfig(t.form.OrderDisplayBroadcastMode)})).subscribe()}static \u0275fac=function(t){return new(t||n)(P(te),P(re),P(z),P(De),P(zn),P(ge),P(wi))};static \u0275cmp=A({type:n,selectors:[["pos-modal-register"]],standalone:!1,decls:12,vars:6,consts:[[3,"onClose","config"],[1,"ms-0","mb-8","search-container",3,"hidden"],[1,"input-group","mb-3","rounded-start-1"],[1,"input-group-text","txtFilter","rounded-end-0"],["aria-hidden","true",1,"fa","fa-magnifying-glass"],["data-cy","SearchOutlet","type","text","placeholder","Filter by Name","aria-label","Search",1,"txtFilter","form-control","border-start-0","rounded-1","rounded-start-0",3,"ngModelChange","ngModel"],[1,"container","custom-scroll"],[1,"row",2,"width","600px"],["data-cy","registers",1,"col-4"],[1,"card","border-0",3,"ngClass"],[1,"card-body","p-0",3,"ngClass"],[1,"card-title","mb-0",3,"click","ngClass"],[1,"fa-solid","fa-house","pe-1","fs-6"],[1,"fa","fa-xmark-circle","fa-lg","position-absolute",2,"text-shadow","0 1px 0 #afafaf","right","5px","top","16px"],[1,"card-text","px-0","py-2",3,"click"],[1,"fa","fa-xmark-circle","fa-lg","position-absolute",2,"text-shadow","0 1px 0 #afafaf","right","5px","top","16px",3,"click"],[1,"idle"],[1,"cashier"],["aria-hidden","true",1,"fa","fa-user","pe-2"],[1,"d-inline"],[1,"open"],["aria-hidden","true",1,"fa-regular","fa-clock","pe-2"]],template:function(t,i){t&1&&(a(0,"modal-material",0),S("onClose",function(){return i.onClose()}),a(1,"content")(2,"div",1)(3,"div",2)(4,"span",3),b(5,"i",4),s(),a(6,"input",5),j("ngModelChange",function(r){return V(i.searchInput,r)||(i.searchInput=r),r}),s()()(),a(7,"div",6)(8,"div",7),K(9,pr,12,13,"div",8,ve),y(11,"FilterByName"),s()()()()),t&2&&(p("config",i.modalConfig),l(2),p("hidden",i.registers.length<=6),l(4),H("ngModel",i.searchInput),l(3),Z(X(11,3,i.registers,i.searchInput)))},dependencies:[Be,Te,Pe,Ee,ne,bi,vo],styles:[".text-warning[_ngcontent-%COMP%]{color:var(--bs-warning)!important}.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}.btn-light-danger[_ngcontent-%COMP%]{color:#212529;background-color:#f8d7da!important;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:hover{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5}.btn-light-danger[_ngcontent-%COMP%]:focus, .btn-light-danger.focus[_ngcontent-%COMP%]{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5;box-shadow:0 0 0 .2rem #dc354540}.btn-light-danger.disabled[_ngcontent-%COMP%], .btn-light-danger[_ngcontent-%COMP%]:disabled{color:#212529;background-color:#f8d7da;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]{color:#212529;background-color:#f1aeb5;border-color:#ea868f}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active:focus, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active:focus, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]:focus{box-shadow:0 0 0 .2rem #dc354540}.search-container[_ngcontent-%COMP%]{transition:all .3s ease;width:97%}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]{position:relative;transition:all .3s ease;height:2.3rem}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:hover, .search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:focus-within{box-shadow:0 0 0 2px #89b03e4d,0 0 8px 4px #89b03e33;border-radius:4px}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%] .txtFilter.form-control[_ngcontent-%COMP%]{transition:all .3s ease;border-left:none!important}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%] .txtFilter.form-control[_ngcontent-%COMP%]:focus{box-shadow:none!important;border-color:#ced4da!important}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%] .input-group-text[_ngcontent-%COMP%]{transition:all .3s ease;background-color:#fff;border-right:none!important}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:hover .input-group-text[_ngcontent-%COMP%], .search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:focus-within .input-group-text[_ngcontent-%COMP%]{background-color:#89b03e1a;border-color:#84cc16!important}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%] .fa-magnifying-glass[_ngcontent-%COMP%]{transition:all .3s ease}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:hover .fa-magnifying-glass[_ngcontent-%COMP%], .search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:focus-within .fa-magnifying-glass[_ngcontent-%COMP%]{color:#84cc16!important}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:focus-within{box-shadow:0 0 0 2px #89b03e66,0 0 12px 6px #89b03e40!important}.custom-scroll[_ngcontent-%COMP%]::-webkit-scrollbar{width:6px}.custom-scroll[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:#f1f1f1;border-radius:3px}.custom-scroll[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:#89b03e;border-radius:3px}.custom-scroll[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:#7a9e37}.container[_ngcontent-%COMP%]{overflow-y:auto;overflow-x:hidden;max-height:260px;min-height:150px}.col-4[_ngcontent-%COMP%]{list-style:none;margin:0;padding:0;display:flex;flex-wrap:wrap!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%]{width:180px;min-height:95px;margin-right:17px;margin-bottom:17px;position:relative}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%]{display:block;outline:0;border:1px solid #B1AAAA;border-radius:5px;cursor:pointer}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] h5[_ngcontent-%COMP%]{height:30px;border-radius:4px;padding:5px 10px;color:#fff;background:#b1aaaa;overflow:hidden}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] h5[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{margin-right:5px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%]:hover, .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.active[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.vacant[_ngcontent-%COMP%]{background:#ffffe1;border:1px solid #89b03e}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%]:hover > h5[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.active[_ngcontent-%COMP%] > h5[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.vacant[_ngcontent-%COMP%] > h5[_ngcontent-%COMP%]{background:#89b03e}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%]:hover{border:1px solid #c9302c}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%] > h6[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%]:hover > h6[_ngcontent-%COMP%]{background:#c9302c!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%] span.alias[_ngcontent-%COMP%]{background:#c9302c}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%]:hover{background:#fff}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%]{border:1px solid #f6a828}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%] > h6[_ngcontent-%COMP%]{background:#f6a828!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%]:hover{border:1px solid #f6a828;background:#fff}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%]:hover > strong[_ngcontent-%COMP%]{background:#f6a828!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%] span.alias[_ngcontent-%COMP%]{background:#f6a828}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%] div[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{font-size:.75rem!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%]{height:80px;padding:15px 10px;position:relative}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{display:block;font-weight:400;font-size:.875rem;width:100%;margin-bottom:5px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span[_ngcontent-%COMP%]:first-child{margin-top:-10px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span[_ngcontent-%COMP%]:last-child{margin-bottom:0}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span.alias[_ngcontent-%COMP%]{text-align:center;position:absolute;bottom:0;right:0;width:auto;background-color:#b1aaaa;border-radius:3px;padding:2px 5px;color:#fff;display:none!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span.idle[_ngcontent-%COMP%]{display:block;font-size:1.25rem;text-align:center}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{position:absolute;width:27px;height:28px;cursor:pointer;top:5px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > span[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{color:#000}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]:last-of-type{right:-5px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]:nth-last-of-type(2){right:15px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{bottom:20px;right:5px;position:absolute}.col-4[_ngcontent-%COMP%] .duration[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{border:1px solid!important;position:absolute;bottom:-3px;left:58px;background:#fff;border-radius:5px}"]})};var ur=["inputCash"],Ni=class n{constructor(e,t){this.dialogRef=e;this.data=t;this.generateModalTitle$.subscribe()}registerService=T(re);loadPOSService=T(z);register=this.registerService.Data;username=this.loadPOSService?.Data?.UserName;amount=R(0);config=new ie;currentRegisterName;generateModalTitle$=this.registerService.Data$.pipe(ce(e=>f.IsNotEmpty(e)),le(()=>{let e=this.registerService.getOutletRegister(),t=e?.Name?.length>18?`${e?.Name?.substring(0,18)}...`:e?.Name;this.config.title="Open Shift",this.currentRegisterName=t}),ee());today=new Date;inputCashEl;ngOnInit(){this.config.customWidth="350px",this.config.hideCancel=!0}ngAfterViewInit(){this.inputCashEl?.nativeElement?.focus()}onOk(){this.dialogRef.close({amount:this.amount()})}static \u0275fac=function(t){return new(t||n)(P(te),P(fe))};static \u0275cmp=A({type:n,selectors:[["POS-modal-opening-cash"]],viewQuery:function(t,i){if(t&1&&Qt(ur,5),t&2){let o;Ut(o=Wt())&&(i.inputCashEl=o.first)}},standalone:!1,decls:25,vars:8,consts:[["inputCash",""],[3,"onOk","onCancel","onClose","config"],[1,"table","fs-5","text"],[1,"py-3"],[1,"text-end","pe-3"],[1,"py-4"],[1,"text-end"],["data-cy","InputCash","autoNum","",1,"border","form-control-lg","text-end","w-100",3,"ngModelChange","ngModel"]],template:function(t,i){if(t&1){let o=E();a(0,"modal-material",1),S("onOk",function(){return v(o),_(i.onOk())})("onCancel",function(){return v(o),_(i.dialogRef.close())})("onClose",function(){return v(o),_(i.dialogRef.close())}),a(1,"content")(2,"table",2)(3,"tr")(4,"td",3),m(5,"Outlet Register"),s(),a(6,"td",4),m(7),s()(),a(8,"tr")(9,"td",5),m(10,"Current User"),s(),a(11,"td",4),m(12),s()(),a(13,"tr")(14,"td",5),m(15,"Starting Time"),s(),a(16,"td",4),m(17),y(18,"date"),s()(),a(19,"tr")(20,"td",3),m(21,"Starting Cash"),s(),a(22,"td",6)(23,"input",7,0),j("ngModelChange",function(c){return v(o),V(i.amount,c)||(i.amount=c),_(c)}),s()()()()()()}t&2&&(p("config",i.config),l(7),O(i.currentRegisterName),l(5),O(i.username),l(5),O(X(18,5,i.today,"EEEE, HH:mm")),l(6),H("ngModel",i.amount))},dependencies:[Te,Pe,Ee,ne,Ot,Ye],styles:[".table-title-width[_ngcontent-%COMP%]{width:120px}"]})};var Ai=class{OrderNumberElement;InvoiceNumberElement;NewOrderID};var Tt=class n{constructor(e,t,i){this._httpService=e;this._onlineStatusService=t;this._localDataService=i;this._onlineStatusService.getOnlineStatus$().subscribe(o=>{this.isOnline=o})}isOnline;GenerateNumber(e,t){if(this.isOnline)return this._httpService.get(U.GenerateNumber,[{key:"EntityID",value:e},{key:"TypeID",value:1}]);{let i=new Ai;return f.IsNotEmpty(t.NumberElement)&&(t.NumberElement.Seed+=1),f.IsNotEmpty(t.InvoiceNumberElement)&&(t.InvoiceNumberElement.Seed+=1),i.InvoiceNumberElement=t.InvoiceNumberElement,i.OrderNumberElement=t.NumberElement,i.NewOrderID=f.Guid_NewGuid(),ke(i)}}findRegisterById(e){return new Promise(t=>{this._localDataService.isConfigFromServer().subscribe(i=>{i?this._httpService.get(U.GetRegisterInfo,[{key:"RegisterID",value:e}]).subscribe(o=>{t(o)}):this._localDataService.findRegisterByID(e).subscribe(o=>{t(o)})})})}recordOpeningCash(e){return ri(this._httpService.post("/API/POS/RecordOpeningCash",e))}static \u0275fac=function(t){return new(t||n)(g(ge),g(he),g(Oe))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var re=class n{constructor(e,t,i,o,r,c){this._signalRClientService=e;this._matDialog=t;this._posHttpResponseService=i;this._CoreHttpService=o;this._toastrService=r;this._roleService=c}datePipe=T(Ye);_Data=new be(null);Data$=this._Data.asObservable().pipe(ce(e=>e!==null),Fe());get Data(){return this._Data.value}getSalesname(e){return this.Data&&this.Data.ListSales?this._Data.value.ListSales.find(t=>t.ID==e)?.Name:""}setActiveRegisterFromOptions(e,t){let o=this._posHttpResponseService.Data.AppConfigJSON.ModuleShift.Closure.Enabled;if(e.length>1){let r=e.find(c=>c.LoginID==t);if(r)this.pushNewRegister(r);else{let c=this.getOutletRegisterFromLocalStorage(),u=this.Data?.RegisterID?this.Data.RegisterID:c?.ID;e.some(F=>F.ID==u)?o?this.openChooseRegisterModal():this.initRegisterFromLocalStorage():this.openChooseRegisterModal()}}e.length==1&&(this.pushNewRegister(e[0]),f.IsEmpty(e[0].LoginID)&&f.IsEmpty(e[0].CashierID)&&this.openOpeningCashModal(e[0].ID)),e.length==0&&this._toastrService.warning("You do not have access to any OUTLET","Warning")}openChooseRegisterModal(){this._matDialog.open(Ri,{id:"registerModal",disableClose:!0}).afterClosed().pipe(ce(e=>f.IsNotEmpty(e?.selectedRegister))).subscribe(e=>{e.selectedRegister&&this.openOpeningCashModal(e.selectedRegister.ID)})}openOpeningCashModal(e){this._posHttpResponseService.Data.AppConfigJSON.ModuleShift.Closure.Enabled&&this._matDialog.open(Ni,{disableClose:!0}).afterClosed().pipe(ce(o=>f.IsNotEmpty(o))).subscribe(o=>{let r={RegisterID:e,OpAmount:o.amount};this._CoreHttpService.recordOpeningCash(r).then(()=>{this.updateRegisterList(r)})})}updateRegisterList(e){let i=this._posHttpResponseService.Data.Registers.map(r=>r.ID==e.RegisterID?this.mapRegisterAsActiveRegister(r,e):r),o=this._posHttpResponseService.Data;o.Registers=i,this._posHttpResponseService.pushNewValue(o)}mapRegisterAsActiveRegister(e,t){let i=localStorage.getItem("AccountInfo");if(i){let r=JSON.parse(i);e.LoginID=r.UserName}e.OpeningCash=t.OpAmount,e.Open=!0,e.State="Open";let o=this.datePipe.transform(new Date,"dd MM yyyy HH:mm");return e.StartDisplay=o,e}initRegisterFromLocalStorage(){if(this._roleService.Data.DeleteItem==!1){let t=this.getOutletRegisterFromLocalStorage();t&&this.pushNewRegister(t)}}pushNewRegister(e){let t=this._Data.value,i=t?t.RegisterID:null;i!=e.ID&&this._CoreHttpService.findRegisterById(e.ID).then(o=>{o.RegisterCode=e.Code,o.DefaultPrintTemplate=o.PrintTemplate,o.SplitPaymentEnabled=this.findSplitPaymentConfig(o.EntityID),this._signalRClientService.SubscribeGroup(o.RegisterID,i),this.saveOutletRegisterToLocalStorage(e),this.pushNewValue(o)})}getOutletRegister(){let e=this.Data.RegisterID;return this._posHttpResponseService.Data.Registers.find(o=>o.ID==e)}pushNewValue(e){this._Data.next(e)}saveOutletRegisterToLocalStorage(e){if(this._roleService.Data.DeleteItem==!1){let i=JSON.stringify(e);localStorage.setItem("outlet_register",i)}}getOutletRegisterFromLocalStorage(){let e=this._roleService.Data.DeleteItem,t=localStorage.getItem("outlet_register"),i=null;return t&&(e?localStorage.removeItem("outlet_register"):i=JSON.parse(t)),i}findOutletRegisterById(e){return this._posHttpResponseService.Data.Registers.find(o=>o.ID===e)}findSplitPaymentConfig(e){let i=this._posHttpResponseService.Data.Entities.find(o=>o.ID===e);return i?i.SplitPaymentEnabled:!1}static \u0275fac=function(t){return new(t||n)(g(rt),g(we),g(z),g(Tt),g(L),g(De))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};function gr(n,e){if(n&1&&(a(0,"span",5),m(1),y(2,"number"),s()),n&2){let t=d(3);l(),M("-",x(2,1,t.coupon.Amount),"%")}}function fr(n,e){if(n&1&&(a(0,"span",5),m(1),y(2,"number"),s()),n&2){let t=d(3);l(),M(" -",x(2,1,t.coupon.Amount)," ")}}function hr(n,e){if(n&1){let t=E();a(0,"button",9),S("click",function(){v(t);let o=d().$implicit,r=d(2);return _(r.onRemoveCouponDiscount(o))}),m(1," Remove "),s()}}function Cr(n,e){if(n&1){let t=E();a(0,"button",10),S("click",function(){v(t);let o=d().$implicit,r=d(2);return _(r.onApplyCouponDiscount(o))}),m(1," Apply "),s()}if(n&2){let t=d(3);p("disabled",t.hasAppliedCouponDiscount())}}function vr(n,e){if(n&1&&(a(0,"tr")(1,"td"),m(2),s(),a(3,"td"),m(4),s(),a(5,"td",4),m(6),y(7,"number"),s(),a(8,"td",4),h(9,gr,3,3,"span",5)(10,fr,3,3,"span",5),s(),a(11,"td",6),h(12,hr,2,0,"button",7)(13,Cr,2,1,"button",8),s()()),n&2){let t=e.$implicit,i=d(2);l(2),O(t==null||t.Variant==null?null:t.Variant.Name),l(2),O(t==null||t.Variant==null?null:t.Variant.Code),l(2),O(x(7,5,t.UnitPrice)),l(3),C((i.coupon==null||i.coupon.Requirement==null?null:i.coupon.Requirement.Type)==i.couponType.DiscountPercentage?9:10),l(3),C((t==null?null:t.CouponDiscount)>0?12:13)}}function _r(n,e){if(n&1&&K(0,vr,14,7,"tr",null,ot),n&2){let t=d();Z(t.eligibleItems())}}function yr(n,e){n&1&&(a(0,"tr")(1,"td",11),b(2,"app-empty-state",12),s()())}var ki=class n{constructor(e){this.data=e;this.coupon=this.data.coupon,this.initModalConfig(),this.initEligibleItems()}dialogRef=T(te);config;eligibleItems=R([]);coupon;couponType=Jt;hasAppliedCouponDiscount=R(!1);initModalConfig(){this.config=new ie,this.config.title="Choose Item to Apply Discount",this.config.hideFooter=!0}initEligibleItems(){let e=this.data.coupon?.ApplyToProduct.map(t=>t.ID);e&&(this.eligibleItems.update(()=>this.data.cartItems.filter(i=>e.includes(i.VariantID))),this.hasAppliedCouponDiscount.update(()=>this.eligibleItems().some(t=>t.CouponDiscount>0)))}onApplyCouponDiscount(e){let t=[e];this.hasAppliedCouponDiscount.update(()=>!0),this.dialogRef.close(t)}onRemoveCouponDiscount(e){this.eligibleItems.update(t=>{let i=t.findIndex(o=>o.VariantID===e.VariantID);return i>-1&&(t[i].Discount=0,t[i].CouponDiscount=0),t}),this.hasAppliedCouponDiscount.update(()=>!1)}onClose(){this.dialogRef.close()}static \u0275fac=function(t){return new(t||n)(P(fe))};static \u0275cmp=A({type:n,selectors:[["app-modal-coupon-selected-item"]],decls:17,vars:2,consts:[[3,"onCancel","onClose","config"],[1,"table","table-bordered"],[1,"thead-light"],["scope","col"],[1,"text-end"],[1,"text-danger"],[1,"text-center"],[1,"btn","btn-sm","btn-danger"],[1,"btn","btn-sm","btn-success",3,"disabled"],[1,"btn","btn-sm","btn-danger",3,"click"],[1,"btn","btn-sm","btn-success",3,"click","disabled"],["colspan","5"],["title","No eligible products","message","No products in the cart qualify for coupon use"]],template:function(t,i){t&1&&(a(0,"modal-material",0),S("onCancel",function(){return i.onClose()})("onClose",function(){return i.onClose()}),a(1,"content")(2,"table",1)(3,"thead",2)(4,"tr")(5,"th",3),m(6,"Name"),s(),a(7,"th",3),m(8,"Code"),s(),a(9,"th",3),m(10,"Price"),s(),a(11,"th",3),m(12,"Discount"),s(),b(13,"th",3),s()(),a(14,"tbody"),h(15,_r,2,0)(16,yr,3,0,"tr"),s()()()()),t&2&&(p("config",i.config),l(15),C(i.eligibleItems().length!==0?15:16))},dependencies:[Se,Pt,ne,So,q],encapsulation:2})};var st=class{ModuleSell;ApplicationLoyalty;ApplicationMath;CoreDefaults;ModuleDelivery;ApplicationParkAndRetrieve;ApplicationRegisterClosure;PaymentConfigGopay;PaymentConfigLink;PrintConfigInvoice;CorePrint;PaymentConfigEmpatKali;ApplicationSettings;PrintConfigGeneral;ModuleProducts;ModuleContact;ApplicationTransactionNumbering;ModuleOrders;ModuleShift;ModuleBuy;ModuleAdjustment;TadaCouponVisible;CouponRedemptionType;ProviderOption};var ae=class n{constructor(e,t,i,o){this._orderDataService=e;this._posService=t;this.POSMATH=i;this.decimalPipe=o;this._orderDataService.Data$.pipe(Y(r=>this._posService.Data$.pipe(J(c=>({appConfig:c.AppConfigJSON,salesOrder:r}))))).subscribe(r=>{this.salesOrderData=r.salesOrder,this.appConfigJSON=r.appConfig,this.calculateDiscountAmount(),this.pushNewValue(this.grandTotal)})}_Data=new be(0);Data$=this._Data.asObservable().pipe(Fe());tax=new xo;discountAfterTax=0;currencySymbol="Rp";get Data(){return this._Data.value}salesOrderData=new G;appConfigJSON=new st;pushNewValue(e){this._Data.next(e)}get grandTotal(){let e=this.TotalAfterSurcharge;return isNaN(e)?0:e}setDecimalDigit(e){let t=this.decimalPipe.transform(e,"1.0-4");return e=parseFloat(t.split(",").join("")),e}get TotalAfterTax(){let e=this.TaxAmount,t=this.TotalBeforeTax+e;return t=this.POSMATH.Round(t,this.appConfigJSON.ApplicationMath.RoundingDigit.DecimalPlaceValue,this.appConfigJSON.ApplicationMath.RoundingDigit.RoundAlgorithm),t}get TotalBeforeTax(){let e=this.tax?.CalculationTypeID===1,t=0;return e?t=this.DiscountTotal-this.TaxAmount:t=this.DiscountTotal,t}get TotalAfterSurcharge(){let e=this.TotalAfterTax+this.SurchargeAmount;return this.POSMATH.Round(e,this.appConfigJSON.ApplicationMath.RoundingDigit.DecimalPlaceValue,this.appConfigJSON.ApplicationMath.RoundingDigit.RoundAlgorithm)}get TotalAfterDiscountTaxable(){return this.GrossTotalTaxable-this.DiscountTotal}get TaxAmount(){if(this.tax!=null){let e=0,t=this.appConfigJSON.ApplicationMath.RoundingTaxDigit.DecimalPlaceValue,i=this.appConfigJSON.ApplicationMath.RoundingTaxDigit.RoundAlgorithm,o=this.GrossTotalTaxable;return this.tax.CalculationTypeID==1?e=this.tax.Rate/(100+this.tax.Rate)*o:e=this.tax.Rate/100*o,e=this.POSMATH.Round(e,t,i),e}else return 0}get SurchargeAmount(){return this.TotalAfterTax*this.salesOrderData.Invoice.SurchargePcg/100}get Discount1Amount(){return this.GrossTotal*this.salesOrderData.Order.Discount/100}get AfterDiscount1Amount(){return this.GrossTotal-this.Discount1Amount}get Discount2Amount(){return this.AfterDiscount1Amount*this.salesOrderData.Order.Discount2/100}get AfterDiscount2Amount(){return this.AfterDiscount1Amount-this.Discount2Amount}get DiscountTotal(){return this.AfterDiscount2Amount-this.salesOrderData.Order.DiscountAmount}calculateDiscountAmount(){let e=this.salesOrderData.Order.DiscountAmount,t=0;this.AfterDiscount2Amount>=0&&e>0&&e>this.AfterDiscount2Amount&&(t=this.AfterDiscount2Amount),t!==0&&t<=e&&this.GrossTotal!==0&&(e=t),this.salesOrderData.Order.DiscountAmount=e}get GrossTotal(){return this.sum(this.salesOrderData.CartItems,"Total")}get GrossTotalTaxable(){let e=this.salesOrderData.CartItems.filter(i=>i.Taxable),t=this.sum(e,"Total");if(e.length!==0){let i=this.calculateDiscountTaxableItem(e);t=t*(100-this.salesOrderData.Order.Discount)/100,t=t*(100-this.salesOrderData.Order.Discount2)/100,t=t-i}return t}calculateDiscountTaxableItem(e){let t=this.GrossTotal,i=this.salesOrderData.Order.DiscountAmount,o=0,r=0,c=0,u=0;for(let D of e)o=D.getItemAfterDiscount/t,r=o*i,u=r*D.Quantity,c+=u;return c}get GrossTotalNonTaxable(){let e=this.salesOrderData.CartItems.filter(i=>i.Taxable==!1),t=this.sum(e,"Total");return t=t*(100-this.salesOrderData.Order.Discount)/100,t=t*(100-this.salesOrderData.Order.Discount2)/100,t=t-this.salesOrderData.Order.DiscountAmount,t}sum(e,t){let i=e.reduce((o,r)=>o+r[t],0);return i=this.setDecimalDigit(i),i}GetPointOnlyAmount(){let e=this.salesOrderData.CartItems.filter(t=>t.Variant.PaymentTypeID==2);return this.GetAmountByCart(e)}GetCashOnlyAmount(){let e=this.salesOrderData.CartItems.filter(t=>t.Variant.PaymentTypeID==1);return this.GetAmountByCart(e)}GetCashAndPointAmountCart(){let e=this.salesOrderData.CartItems.filter(t=>t.Variant.PaymentTypeID!=1);return this.GetAmountByCart(e)}GetAmountByCart(e){let t=this.sum(e,"Total");return t=t*(100-this.salesOrderData.Order.Discount)/100,t=t*(100-this.salesOrderData.Order.Discount2)/100,t}calculateGrossTotal(e){return this.sum(e,"Total")}static \u0275fac=function(t){return new(t||n)(g(B),g(z),g(Io),g(q))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Vi=class{Code;Provider;EntityID;Customer;ShoppingCart};var Et=class n{salesOrderService=T(B);registerService=T(re);customerService=T(Re);orderCalculator=T(ae);generateRedeemCouponDto(e,t){let i=new Vi,o=this.registerService.Data?.EntityID;return i.Code=e,i.Provider=t,i.ShoppingCart={Amount:this.orderCalculator.Data,Items:this.generateItems()},i.EntityID=o,i.Customer=this.generateCustomer(t),i}generateItems(){return this.salesOrderService.Data.CartItems.map(i=>({Price:i.Price,Quantity:i.Quantity,VariantID:i.VariantID,Code:i?.Variant?.Code}))}generateCustomer(e){let t=this.customerService.Data,i=this.salesOrderService?.Data?.Order?.CustomerID,o=null;return f.IsNotEmpty(i)&&(o={Phone:t.Mobile,Email:t.Email},e==="Internal"&&(o=ii({ID:i},o))),o}static \u0275fac=function(t){return new(t||n)};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var wt=class n{constructor(e,t,i,o,r,c){this._httpService=e;this._orderDataService=t;this._userRoleService=i;this.toastr=o;this._invoiceCalculatorService=r;this.promotionCouponFactoryService=c;this.subscribeToObservable()}dialog=T(we);role;originalRoleData;_coupon=R(null);salesOrderBeforePromotion=R(null);isShowToastrInApplyCoupon=R(!1);get coupon(){return this._coupon()}subscribeToObservable(){this._userRoleService.Data$.subscribe(e=>{this.role=e,f.IsEmpty(this.originalRoleData)&&(this.originalRoleData=de(We,e))})}RedeemCoupon(e,t,i=!1){i||(this.isShowToastrInApplyCoupon.set(!0),this.copyOriginalSalesOrder());let o=this.promotionCouponFactoryService.generateRedeemCouponDto(e,"Internal");this._httpService.post(U.ValidateInternalCoupon,o).subscribe({next:r=>{switch(this._orderDataService.Data.Order.PromotionCoupon=e,this._orderDataService.Data.Order.PromotionNote=t,this._orderDataService.Data.Order.CouponType=1,r.Requirement?.Type){case 1:this.HandleDiscountPercentage(r);break;case 2:this.HandleDiscountAmount(r);break;case 3:this.handleCouponReturnAccess(r);break;case 4:this.handleCouponParkedDeletionAccess();break;case 5:this.handleFullAccessCoupon();break;case 6:this.handleDeleteItemCoupon();break}this._coupon.set(r),this.isShowToastrInApplyCoupon.set(!1)},error:r=>{this.removeAppliedCoupon(!1),this.isShowToastrInApplyCoupon.set(!1)}})}setCouponOnEdit(e){this._coupon.set(e),this.generateOriginalSalesOrderOnEdit()}generateOriginalSalesOrderOnEdit(){let e=de(G,this._orderDataService.Data);e.Order.PromotionCoupon=null,e.Order.PromotionNote=null,e.Order.Discount=0,e.Order.DiscountAmount=0,this.salesOrderBeforePromotion.set(e)}copyOriginalSalesOrder(){let e=de(G,this._orderDataService.Data);this.salesOrderBeforePromotion.set(e)}HandleDiscountPercentage(e,t=!1){e.Amount>0?e.Requirement?.MaximumDiscount>0?this.applyConfigMaxDiscount(e,t):e.Requirement?.FullPriceProductOnly?this.applyFullPriceDisc(e,t):this.applyDiscountPercentage(e,t):(this.role.Discount=t?this.originalRoleData.Discount:!0,this._userRoleService.pushNewValue(this.role))}applyFullPriceDisc(e,t=!1){let i=this._orderDataService.Data,o=this.filterItemWithDisc(i.CartItems),r=this.filterItemWithCouponDisc(i.CartItems);if(t)r.length>0?(i.CartItems=this.resetItemsDisc(i.CartItems),this._orderDataService.pushNewValue()):this.applyDiscountPercentage(e,t);else if(o.length>0){let c=this.filterItemWithoutDisc(i.CartItems);c.length>0?this.applyConfigItemsScope(e,c).subscribe(u=>{let D=this.applyItemsDisc(u,e);i.CartItems=this.updateCartItems(D,e),this._orderDataService.pushNewValue(i),this.showToastr(e)}):(this.removeAppliedCoupon(!1),this._orderDataService.pushNewValue(),this.toastr.error("No products in the cart qualify for coupon use","Coupon Not Applied"))}else this.applyDiscountPercentage(e,t)}updateCartItems(e,t){let o=this._orderDataService.Data.CartItems.map((r,c)=>{let u=e.find(D=>this.isSameCartItem(D,r));return u||r});return o=this.applyOneOfFirstQuantity(o,t),o}applyOneOfFirstQuantity(e,t){if(t?.Requirement?.RequirementDiscountType==2){let i=e.findIndex(o=>o.CouponDiscount>0);if(e[i]?.Quantity>1){let o=dt(xe,e[i]);o.Quantity=1,o.ID=f.GuidEmpty,e[i].Quantity=e[i].Quantity-1,e[i].CouponDiscount=0,e[i].Discount=0,e[i].DiscountAmount=0,e.push(o)}}return e}filterItemWithDisc(e){return e.filter(i=>i.Discount>0||i.DiscountAmount>0||i.Price!=i?.Variant?.UnitPrice||f.IsNotEmpty(i.PriceBookID)||i.PriceTypeID==2)}filterItemWithoutDisc(e){return e.filter(i=>this.itemConditionFullPriceOnly(i))}filterItemWithCouponDisc(e){return e.filter(i=>i.CouponDiscount>0)}applyDiscountPercentage(e,t=!1){let i=this._orderDataService.Data.Order.CustomerDiscountRate,o=e.Amount;if(t){let r=this._orderDataService.Data;this._orderDataService.Data.Order.Discount=0,r.CartItems=this.resetItemsDisc(r.CartItems),this._orderDataService.pushNewValue(r)}else o>=i?e.ApplyToProduct?.length>0?this.applyDiscountRequiredItems(e):(this._orderDataService.Data.Order.Discount=e.Amount,this._orderDataService.pushNewValue(),this.showToastr(e)):(this.toastr.warning("Member discount is applied because member discount is greater than Coupon Discount","Warning"),this.removeAppliedDiscountOnCustomerChange())}applyDiscountRequiredItems(e){let i=this._orderDataService.Data.CartItems.filter(o=>e.ApplyToProduct.map(r=>r.ID)?.includes(o.VariantID));this.applyConfigItemsScope(e,i).subscribe(o=>{let r=o.map(u=>(u.Discount=e.Amount,u.CouponDiscount=e.Amount,u)),c=this.updateCartItems(r,e);this._orderDataService.Data.CartItems=c,this._orderDataService.pushNewValue(),this.showToastr(e)})}showToastr(e){let t=e?.Requirement?.Notify;f.IsNotEmpty(t)&&this.isShowToastrInApplyCoupon()&&this.toastr.success(t,"Coupon Applied")}applyConfigMaxDiscount(e,t=!1){let i=this._orderDataService.Data.CartItems;e.Requirement?.FullPriceProductOnly&&(i=i.filter(o=>this.itemConditionFullPriceOnly(o))),this.applyConfigItemsScope(e,i,t).subscribe(o=>{this.applyMaxDiscount(e,o,t)})}applyConfigItemsScope(e,t,i=!1){let o=e.Requirement?.RequirementDiscountType;return(o==1||o==2)&&i==!1?this.dialog.open(ki,{data:{coupon:e,cartItems:t},id:"modal-coupon-selected-item"}).afterClosed().pipe(le(c=>{let F=this._orderDataService.Data.CartItems.some(W=>W.CouponDiscount>0);!c&&!F&&this.removeAppliedDiscountOnCustomerChange()}),ce(c=>!!c)):ke(t)}applyMaxDiscount(e,t,i=!1){let o=this._invoiceCalculatorService.calculateGrossTotal(t),r=this._orderDataService.Data,c=o*e.Amount/100,u=e.Requirement?.MaximumDiscount,D=t;c>=u?(r.Order.DiscountAmount=i?0:u,D=this.resetItemsDisc(t)):(r.Order.DiscountAmount=0,D=i?this.resetItemsDisc(t):this.applyItemsDisc(t,e)),r.CartItems=this.updateCartItems(D,e),this._orderDataService.pushNewValue(r),i||this.showToastr(e)}resetItemsDisc(e){return this.coupon?.Requirement?.RequirementDiscountType==2?e=this.resetConfigOneOfFirstQuantity(e):e=e.map(t=>(t.CouponDiscount>0&&(t.Discount=0,t.DiscountAmount=0,t.CouponDiscount=0),t)),e}resetConfigOneOfFirstQuantity(e){let t=e.findIndex(i=>i.CouponDiscount>0);if(t!==-1){let i=e.findIndex(o=>o.CouponDiscount==0&&e[t]?.VariantID==o?.VariantID);i!==-1?(e.splice(t,1),e[i].Quantity+=1):(e[t].CouponDiscount=0,e[t].Discount=0,e[t].DiscountAmount=0)}return e}applyItemsDisc(e,t){return t.ApplyToProduct?.length>0?e=this.applyDiscByVariant(e,t):e=e.map(i=>(i.Discount=t.Amount,i.CouponDiscount=t.Amount,i)),e}applyDiscByVariant(e,t){return e=e.map(i=>(t.ApplyToProduct.find(r=>r.ID==i.VariantID)&&this.itemConditionFullPriceOnly(i)&&(i.Discount=t.Amount,i.CouponDiscount=t.Amount),i)),e}itemConditionFullPriceOnly(e){return(e.Discount==0||e.CouponDiscount>0)&&e.DiscountAmount==0&&e.Price==e?.Variant?.UnitPrice&&f.IsEmpty(e.PriceBookID)}HandleDiscountAmount(e,t=!1){e.Amount>0?(e.ApplyToProduct?.length>0?this.applyDiscountInItem(e,t):(t?this._orderDataService.Data.Order.DiscountAmount=0:(this._orderDataService.Data.Order.DiscountAmount=e.Amount,this.showToastr(e)),this._orderDataService.pushNewValue()),this.resetCustomerPoint(t)):(this.role.Discount=t?this.originalRoleData.Discount:!0,this._userRoleService.pushNewValue(this.role))}applyDiscountInItem(e,t=!1){let i=this._orderDataService.Data;if(t)i.CartItems=this.resetItemsDisc(i.CartItems);else{let r=i.CartItems.filter(c=>e.ApplyToProduct.map(u=>u.ID)?.includes(c.VariantID));this.applyConfigItemsScope(e,r,t).subscribe(c=>{let u=c.map(D=>(D.DiscountAmount=e.Amount,D.CouponDiscount=e.Amount,D));i.CartItems=this.updateCartItems(u,e),this._orderDataService.pushNewValue(i),this.showToastr(e)})}}resetCustomerPoint(e){if(!e){let t=this._orderDataService.Data;t.Order.PointUsed=0}}handleCouponReturnAccess(e){let t=de(We,this.role);t.Return=!0,this._userRoleService.pushNewValue(t),this.isShowToastrInApplyCoupon()&&this.toastr.success("You got access to return a sales transaction!","Coupon Applied")}handleCouponParkedDeletionAccess(){let e=de(We,this.role);e.ParkedDeletionAuthorized=!0,this._userRoleService.pushNewValue(e),this.isShowToastrInApplyCoupon()&&this.toastr.success("You Have Access to delete park and delete item when retrieve!","Coupon Applied")}handleFullAccessCoupon(){let e=de(We,this.role);e.UnitPriceEditor=!0,e.Discount=!0,e.Return=!0,e.Tax=!0,e.NumberEditor=!0,e.DateEditor=!0,e.PricebookSelector=!0,e.DeleteItem=!0,e.ParkedDeletionAuthorized=!0,this._userRoleService.pushNewValue(e),this.isShowToastrInApplyCoupon()&&this.toastr.success("You now have Full Access for this Order!","Coupon Applied")}handleDeleteItemCoupon(){let e=de(We,this.role);e.DeleteItem=!0,this._userRoleService.pushNewValue(e),this.isShowToastrInApplyCoupon()&&this.toastr.success("You Have Access to delete item","Coupon Applied")}removeAppliedCoupon(e=!0){this._userRoleService.pushNewValue(this.originalRoleData),this._orderDataService.pushNewValue(this.salesOrderBeforePromotion()),this.salesOrderBeforePromotion.set(null),this._coupon.set(null),e&&this.toastr.warning("Coupon Cancelled","Warning")}resetCouponOnNewTransaction(){this._userRoleService.pushNewValue(this.originalRoleData),this._coupon.set(null)}removeAppliedDiscountOnCustomerChange(){if(this.coupon)switch(this.coupon.Requirement?.Type){case 1:this.HandleDiscountPercentage(this._coupon(),!0),this.removeAppliedCouponOnCustomerChange();break;case 2:this.HandleDiscountAmount(this._coupon(),!0),this.removeAppliedCouponOnCustomerChange();break}}removeAppliedCouponOnCustomerChange(){if(this.coupon){let e=this._orderDataService.Data;e.Order.PromotionCoupon=null,e.Order.PromotionNote=null,this._coupon.set(null),this._userRoleService.pushNewValue(this.originalRoleData),this._orderDataService.pushNewValue(e)}}isSameCartItem(e,t){return e.VariantID===t.VariantID&&e.Quantity===t.Quantity&&e.Price===t.Price&&e.Discount===t.Discount&&e.PriceBookID===t.PriceBookID}static \u0275fac=function(t){return new(t||n)(g(ge),g(B),g(De),g(L),g(ae),g(Et))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Rt=class{CommissionID;ReturNumber;parkTemporaryItem;posState;InputTextValue;constructor(){this.posState=0,this.CommissionID="",this.ReturNumber="",this.parkTemporaryItem=[],this.InputTextValue=""}};var Fi=class n{constructor(e,t,i){this._promotionEventService=e;this._dialogRef=t;this.data=i;this.modalConfig=new ie,this.modalConfig.hideCancel=!0,this.modalConfig.hideClose=!0,this.modalConfig.headerType=me.Warning,this.modalConfig.title="Promotion Requirement unfulfilled!",this.modalConfig.customWidth="350px",this.modalConfig.okText="Ok",this.selectedPromotion=e.selectedPromotion}modalConfig;selectedPromotion;onOk(){this._promotionEventService.restoreOrder(),this._dialogRef.close()}static \u0275fac=function(t){return new(t||n)(P(Ae),P(te),P(fe))};static \u0275cmp=A({type:n,selectors:[["POS-modal-promotion-confirm"]],standalone:!1,decls:9,vars:4,consts:[[3,"onOk","config"],[1,"fst-italic","text-danger","mb-3"],[1,"mb-0"]],template:function(t,i){t&1&&(a(0,"modal-material",0),S("onOk",function(){return i.onOk()}),a(1,"content")(2,"div")(3,"h5"),m(4),s(),a(5,"p",1),m(6),s(),a(7,"p",2),m(8),s()()()()),t&2&&(p("config",i.modalConfig),l(4),O(i.selectedPromotion==null?null:i.selectedPromotion.Name),l(2),O(i.selectedPromotion==null?null:i.selectedPromotion.Description),l(2),O(i.data==null?null:i.data.message))},dependencies:[ne],encapsulation:2})};var Li=class extends xe{};var kt=class n{constructor(e,t,i,o,r,c,u,D,F,W){this.variantService=e;this._posService=t;this._orderDataService=i;this.toastr=o;this._orderProcessorService=r;this._customerHttpService=c;this.promotionCouponService=u;this.promotionCouponExternalService=D;this.userRoleService=F;this.decimalPipe=W;this.subscribeToObservable()}salesOrderData;appConfigJson;entityID;audio=new Audio;subscribeToObservable(){this._posService.Data$.pipe(ee()).subscribe(e=>{this.appConfigJson=e.AppConfigJSON}),this._orderDataService.Data$.pipe(ee()).subscribe(e=>{this.salesOrderData=e,this.entityID=e.Order.EntityID}),this._orderProcessorService.Data$.pipe(ee()).subscribe(e=>{e.posState==3&&this.clearCartItemsInLocalStorage()})}addCartItemById(e,t,i=!0){return new Promise((o,r)=>{this.variantService.findVariantByID(e,this.entityID,i).then(c=>{this.createNewCartItem(c,t),o(c)}).catch(c=>{r(c)})})}addCartItemByCode(e){return new Promise((t,i)=>{let o=this.appConfigJson.ModuleSell.DigitalScale;o.Digit>0&&f.IsNotEmpty(o.Regex)&&e.length==o.Digit?this.parseDigitalScaleBarcodeWithRegex(e,o).then(c=>{c||(this.toastr.info("Matching Regex Rule to Barcode","Digital Scale"),this.findVariantByCode(e).then(u=>t(u)).catch(u=>i(u)))}):this.findVariantByCode(e).then(c=>t(c)).catch(c=>i(c))})}findVariantByCode(e){let t=this.appConfigJson.ModuleSell.BarcodeSerialEnabled;return new Promise((i,o)=>{this.variantService.findVariantByCode(e,this.entityID,t).then(r=>{i(r),this.createNewCartItem(r)}).catch(r=>{this.playBellRing(),o(r)})})}addItemBySerial(e){this.variantService.findVariantBySerial(e,this.entityID).subscribe(t=>{let i=this.salesOrderData.CartItems;if(i.length>0){let o,r=[],c=i.findIndex(u=>u.Variant.ID==t.ID);r=[],c!==-1?(o=i[c].Serial?.findIndex(u=>u.Number==e),r=[...i[c].Serial?i[c].Serial:[]],o==-1?(r.push({Number:e,Quantity:1}),i[c].Quantity=r.length):r.length>0?r[o].Quantity+=1:(r=[{Number:e,Quantity:1}],this.addNewSerials(t,e)),i[c].Serial=[...r],i[c].Quantity=i[c].calculateSerialQty(),this.updateCartItem(i[c],c)):this.addNewSerials(t,e)}else this.addNewSerials(t,e)})}addNewSerials(e,t){e.Serial=[{Number:t,Quantity:1}],this.createNewCartItem(e)}playBellRing(){this.audio.src="https://cdn.dealpos.xyz/web-audio/bell_ring.mp3",this.audio.load(),this.audio.play()}updateCartItem(e,t){this.salesOrderData.CartItems[t]=e,this._orderDataService.pushNewValue(this.salesOrderData),this.applyCustomerPoint(),this.reApplyPromotionCoupon(),this.saveItemsToLocalStorage()}deleteCartItem(e){this.salesOrderData.CartItems=this.salesOrderData.CartItems.filter(t=>t!==e),this._orderDataService.pushNewValue(this.salesOrderData),this.applyCustomerPoint(),this.isRemoveItemRequirement(e)&&this.reApplyPromotionCoupon()}parseDigitalScaleBarcodeWithRegex(e,t){return new Promise(i=>{let o=this.appConfigJson.ModuleSell.BarcodeSerialEnabled,r=new RegExp(t.Regex),c=e.match(r);if(console.log(c),f.IsNotEmpty(c)){let u=c[1],D=parseFloat(c[2]);console.log(D,"productQuantity"),D=D/t.QuantityDivider,this.variantService.findVariantByCode(u,this.entityID,o).then(F=>{this.createNewCartItem(F,null,D),i(!0)}).catch(()=>{i(!1)})}else i(!1)})}createNewCartItem(e,t,i){let o=new xe,r=this.appConfigJson.ModuleSell.ProductNotes.CopyProductDescription,c=this.appConfigJson.ModuleSell.ProductNotes.CopyPromotionName;o.patchByVariant(e,r,c),o=this.applyReward(o,t),f.IsEmpty(t)&&(o=this.applyPriceBook(o)),this.validateCartItem(o)&&(o.Quantity=i||o.Quantity,t?.PromotionType==2?this.handlingPromotionQuantity(o):this.pushNewItemToArray(o,o.PromotionGift),this.applyCustomerPoint()),this.addAvailableComponent(o)}applyCustomerPoint(){let e=this.salesOrderData.Order.CustomerID,t=f.IsEmpty(e);this._orderProcessorService.reedemPointToDiscount(t)}handlingPromotionQuantity(e){let t=de(xe,this.salesOrderData.CartItems),i=t.findIndex(o=>o.VariantID==e.VariantID&&o.PromotionGift);i!==-1?t[i].Quantity+=e.Quantity?e.Quantity:1:t=[...t,e],this.salesOrderData.CartItems=t,this._orderDataService.pushNewValue(this.salesOrderData)}applyPromotionProduct(e){let t=e.Variant.DiscountAmount;return t&&(e.Price=e.UnitPriceOriginal-t),e}applyReward(e,t){if(t){let i=this.appConfigJson.ModuleSell.ProductNotes.CopyPromotionName;e.Discount=t.Discount,e.Price=t.OriginalPrice;let o=t.OriginalPrice-t.UnitPrice;e.Price=e.UnitPriceOriginal-o,e.UnitPrice=e.UnitPriceOriginal-o,e.PromotionGift=!0,e.PromotionID=t.PromotionID,e.Quantity=t.Quantity?t.Quantity:1,e.PriceTypeID=3,e.Cost+=t.ExtraCost,e.UnitCost+=t.ExtraCost,e.PriceNote=t.PromotionName,i&&(e.Note=`${e.Note?e.Note:""} ${t.PromotionName} `)}return e}addAvailableComponent(e){let t=e.Price!=0,i=this.appConfigJson.ModuleSell.SellProductComponentDefaultPrice,o=e.Variant;if(o.Component!=null&&o.Component.length>0)for(let r of o.Component){let c=new Li;c.patchByVariant(r),c.Quantity=e.Quantity*r.Quantity,t&&!i&&(r.UnitPrice=0),c.Price=r.UnitPrice,this.pushNewItemToArray(c)}}pushNewItemToArray(e,t=!1){let i=this.salesOrderData.CartItems.findIndex(o=>o.VariantID==e.VariantID);if(e=this.applyPromotionProduct(e),i==-1||t)this.salesOrderData.CartItems.push(e);else{let o=this.appConfigJson.ModuleSell.QuickKey.NewRowBehaviour;if(o==2)this.salesOrderData.CartItems.push(e);else if(o==1)this._orderProcessorService.Data.posState==4?this.salesOrderData.CartItems.push(e):this.addingQuantityItem(i,e);else{if(!this.validatePrepaidPackage(e,i)){this.toastr.error("This prepaid package is already in the cart while editing. Please remove it first before adding again.","Cannot Add Item");return}this.addingQuantityItem(i,e)}}this._orderDataService.pushNewValue(this.salesOrderData),this.saveItemsToLocalStorage(),this.reApplyPromotionCoupon()}saveItemsToLocalStorage(){let e=this.userRoleService.Data.DeleteItem,t=this._orderProcessorService.Data?.posState;if(!e&&t!==4){let i=this._orderDataService.Data,o=i?.Order?.Number,r=i.CartItems,c={Number:o,CartItems:r};try{localStorage.setItem("cart_items",JSON.stringify(c))}catch(u){console.error("Error saving cart items to localStorage:",u)}}}clearCartItemsInLocalStorage(){localStorage.getItem("cart_items")&&(this.userRoleService.Data?.DeleteItem?this.clearCartItemsBasedOnCoupon():this.clearCartItemsStorage())}clearCartItemsBasedOnCoupon(){let e=this.promotionCouponService?.coupon;e&&(e.Requirement?.Type==5||e.Requirement?.Type==6)&&this.clearCartItemsStorage()}clearCartItemsStorage(){try{localStorage.removeItem("cart_items")}catch(e){console.error("Error clearing cart items from localStorage:",e)}}validatePrepaidPackage(e,t){let i=this.salesOrderData.CartItems[t],o=this._orderProcessorService.Data.posState,r=e.Variant.TypeID==10,c=f.IsNotEmpty(i.ID),u=!0;return o==2&&r&&c&&(u=!1),u}reApplyPromotionCoupon(){let e=this.salesOrderData.Order.CouponProvider,t=e=="Internal"||f.IsEmpty(e),i=this.salesOrderData.Order.PromotionCoupon,o=this.salesOrderData.Order.PromotionNote;f.IsNotEmpty(i)&&(t?this.promotionCouponService.RedeemCoupon(i,o,!0):this.promotionCouponExternalService.redeemCoupon(i,"External",o))}isRemoveItemRequirement(e){let t=this.promotionCouponService?.coupon,i=t?.ApplyToProduct,o=!0;return f.IsNotEmpty(t)&&i?.length>0&&(o=i.some(r=>r.ID==e.VariantID)),o}addingQuantityItem(e,t){let i=this.salesOrderData.CartItems.filter(u=>u.VariantID==t.VariantID),o=i.length,r=i.find(u=>!u.PromotionGift);this.salesOrderData.CartItems[e].PromotionGift&&o==1?this.salesOrderData.CartItems.push(t):(r.Quantity+=t.Quantity,r=this.applyPromotionProduct(r)),r&&(r=this.applyPriceBook(r))}validateCartItem(e){return e.Variant.CategoryTypeID==-1?(this.toastr.info(e.Variant.Name+" cannot be sold, check Category "+e.Variant.CategoryName+" settings","info"),!1):!(!this.validatePriceMinimum(e)||!this.validateSerialItem(e))}validatePriceMinimum(e){let t=!0,i=this.userRoleService.Data.PriceMinimum,o=this.appConfigJson.ModuleSell.ProductDialog.PriceMinimumTypeID;if(i){let r=0;switch(o){case 1:r=e.UnitPrice;break;case 2:r=e.UnitCost;break;case 3:r=e.UnitPriceMinimum;break}if(e.Price<r){t=!1;let c=f.StringFormat("You have no right to sell this item lower than {0}",this.decimalPipe.transform(r));alert(c)}}return t}validateSerialItem(e){let t=!0;if(e?.Serial?.length>0&&e.Variant.TypeID==4&&e.Quantity>0){let i=0;e?.Serial?.forEach(o=>{i+=o.Quantity}),i!=e.Quantity&&(this.toastr.error("Serial must be equal with the quantity","Error"),t=!1)}return t}applyPriceBook(e){let t=e.Variant.PriceBook!=null?e.Variant.PriceBook:[],i=this.findCustomerPricebook(t);if(t&&t.length!==0){let o=t.sort(function(r,c){return c.MinimumQuantity-r.MinimumQuantity}).filter(r=>e.Quantity>=r.MinimumQuantity&&r.MinimumQuantity!=0);o.length>0||f.IsNotEmpty(i)?f.IsNotEmpty(i)?e=this.applyPricebookToItem(e,i):e=this.applyPricebookToItem(e,o[0]):e=this.resetAppliedPricebook(e)}return e}resetAppliedPricebook(e){let i=(e?.Variant?.PriceBook).find(o=>o.ID==e.PriceBookID);return f.IsNotEmpty(i)&&(e.Discount=e.Variant.PriceDiscount,e.PriceBookID=f.GuidEmpty,e.Price=e.Variant.UnitPrice,e.UnitPrice=e.Variant.UnitPrice,e.PriceTypeID=0,e=this.applyPromotionProduct(e),e=this.removePromotionNote(e)),e}removePromotionNote(e){let t=this.appConfigJson.ModuleSell.ProductNotes;if(this.appConfigJson?.ModuleSell?.Pricebook?.PricebookVisible&&(e.Note=e.Note?.replace(e.PriceNote,""),e.PriceNote=""),t.CopyPromotionName){let o=e.Variant?.PriceNote;e.Note=`${o||""} ${e.Note?e.Note:""}`,e.PriceNote=o}return e}applyPricebookToItem(e,t){return e.Discount=t.PriceDiscount,e.UnitPrice=t.UnitPrice,e.PriceBookID=t.ID,e.Price=t.UnitPrice,e.PriceTypeID=2,e=this.assignItemNote(e,t),e}assignItemNote(e,t){return this.appConfigJson?.ModuleSell?.Pricebook?.PricebookVisible?(e.Note?.includes(e.PriceNote)?e.Note=e.Note?.replace(e.PriceNote,t.Name):e.Note=`${t.Name} ${e.Note?e.Note:""}`,e.PriceNote=t.Name):(e.Note="",e.PriceNote=""),e}findCustomerPricebook(e=[]){let t=this._customerHttpService.Data,i;return t&&(i=e.find(o=>o.ID==t.PricebookID)),i}static \u0275fac=function(t){return new(t||n)(g(Mo),g(z),g(B),g(L),g(je),g(Re),g(wt),g(Bi),g(De),g(q))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};function Or(n,e){if(n&1&&(a(0,"div",2)(1,"div",4),b(2,"input",8),s()()),n&2){let t=d();l(2),p("formControl",t.searchControl)}}function Dr(n,e){n&1&&(a(0,"span"),m(1,"Apply"),s())}function Mr(n,e){n&1&&(a(0,"span"),m(1,"Applying..."),s())}function xr(n,e){if(n&1){let t=E();a(0,"tr")(1,"td"),m(2),s(),a(3,"td"),m(4),s(),a(5,"td",9),m(6),y(7,"number"),s(),a(8,"td",9),m(9),y(10,"number"),s(),a(11,"td",10)(12,"button",11),S("click",function(){let o=v(t).$implicit,r=d();return _(r.onSelectReward(o))}),h(13,Dr,2,0,"span"),h(14,Mr,2,0,"span"),s()()()}if(n&2){let t=e.$implicit,i=d();l(2),O(t.VariantName),l(2),O(t.VariantCode),l(2),O(x(7,7,t.OriginalPrice)),l(3),O(x(10,9,t.UnitPrice)),l(3),p("disabled",i.isApplyingReward()),l(),C(i.isApplyingReward()?-1:13),l(),C(i.isApplyingReward()?14:-1)}}var ji=class n{constructor(e,t,i,o,r,c){this._dialogRef=e;this._matDialog=t;this._shoppingCartService=i;this._promotionEventService=o;this._toastr=r;this.data=c;this.selectedPromotion=this._promotionEventService.selectedPromotion}modalConfig=new ie;selectedPromotion;rewards$;searchControl=new et;isApplyingReward=R(!1);ngOnInit(){this.modalConfig.title="Select a Reward",this.modalConfig.hideFooter=!0,this.initRewards(!0)}initRewards(e){this.rewards$=this.searchControl.valueChanges.pipe(si(""),ht(e?0:500),Fe(),Y(t=>{let i;return i=ke(this.data.rewards).pipe(J(o=>o.filter(r=>this.findKeywordInValue(t,r?.VariantCode)||this.findKeywordInValue(t,r?.VariantName)))),e=!0,i}))}findKeywordInValue(e,t){return t?.toUpperCase()?.indexOf(e?.toUpperCase())>-1}onSelectReward(e){return ni(this,null,function*(){if(!this.isApplyingReward()){this.isApplyingReward.set(!0);try{e.PromotionType=this.data.promotion.TypeID,yield this._shoppingCartService.addCartItemById(e.VariantID,e,!0).then(()=>{this._matDialog.closeAll(),this._promotionEventService.pushNewValue(this._promotionEventService.Data),this.showToastAppliedPromo()})}finally{this.isApplyingReward.set(!1)}}})}showToastAppliedPromo(){this._toastr.success("Applied "+this.selectedPromotion.Name+" to order!","Applied successfully!")}close(){this._dialogRef.close()}static \u0275fac=function(t){return new(t||n)(P(te),P(we),P(kt),P(Ae),P(L),P(fe))};static \u0275cmp=A({type:n,selectors:[["POS-modal-select-item"]],standalone:!1,decls:23,vars:8,consts:[[3,"onCancel","onClose","config"],[1,"container"],[1,"row","mb-3"],[1,"row"],[1,"col-12"],[1,"table","table-bordered"],[1,"thead-light"],["scope","col"],["type","text","placeholder","Type to filter reward",1,"form-control",3,"formControl"],[1,"text-end"],[1,"text-center"],[1,"btn","btn-sm","btn-success",3,"click","disabled"]],template:function(t,i){t&1&&(a(0,"modal-material",0),S("onCancel",function(){return i.close()})("onClose",function(){return i.close()}),a(1,"content")(2,"div",1),h(3,Or,3,1,"div",2),a(4,"div",3)(5,"div",4)(6,"table",5)(7,"thead",6)(8,"tr")(9,"th",7),m(10,"Name"),s(),a(11,"th",7),m(12,"Code"),s(),a(13,"th",7),m(14,"Price"),s(),a(15,"th",7),m(16,"Promo"),s(),b(17,"th",7),s()(),a(18,"tbody"),K(19,xr,15,11,"tr",null,ve),y(21,"async"),y(22,"sortBy"),s()()()()()()()),t&2&&(p("config",i.modalConfig),l(3),C((i.data==null||i.data.rewards==null?null:i.data.rewards.length)>5?3:-1),l(16),Z(_t(22,4,x(21,2,i.rewards$),"desc","VariantCode")))},dependencies:[Te,Pe,bt,ne,ze,q,Dt],styles:[".table-scroll[_ngcontent-%COMP%]{max-height:400px;overflow-y:auto}table[_ngcontent-%COMP%]{max-width:600px!important;overflow-x:hidden}"]})};function Ir(n,e){if(n&1&&(a(0,"div",3)(1,"div",5),b(2,"input",10),s()()),n&2){let t=d();l(2),p("formControl",t.searchCtrl)}}function Tr(n,e){n&1&&(a(0,"th",9),m(1,"Qty"),s())}function Er(n,e){n&1&&b(0,"th",8)}function wr(n,e){if(n&1){let t=E();a(0,"td")(1,"input",13),j("ngModelChange",function(o){v(t);let r=d().$implicit;return V(r.Quantity,o)||(r.Quantity=o),_(o)}),s()()}if(n&2){let t=d().$implicit;l(),H("ngModel",t.Quantity)}}function Rr(n,e){n&1&&(a(0,"span"),m(1,"Apply"),s())}function Nr(n,e){n&1&&(a(0,"span"),m(1,"Applying..."),s())}function Ar(n,e){if(n&1){let t=E();a(0,"td",12)(1,"button",14),S("click",function(){v(t);let o=d().$implicit,r=d();return _(r.onApplyReward(o))}),h(2,Rr,2,0,"span"),h(3,Nr,2,0,"span"),s()()}if(n&2){let t=d(2);l(),p("disabled",t.isApplyingReward()),l(),C(t.isApplyingReward()?-1:2),l(),C(t.isApplyingReward()?3:-1)}}function kr(n,e){if(n&1&&(a(0,"tr")(1,"td"),m(2),s(),a(3,"td"),m(4),s(),a(5,"td",11),m(6),y(7,"number"),s(),a(8,"td",11),m(9),y(10,"number"),s(),h(11,wr,2,1,"td")(12,Ar,4,3,"td",12),s()),n&2){let t=e.$implicit,i=d();l(2),O(t.VariantName),l(2),O(t.VariantCode),l(2),O(x(7,5,t.OriginalPrice)),l(3),O(x(10,7,t.UnitPrice)),l(2),C(i.rewardQuantity>1?11:12)}}var Qi=class n{constructor(e,t,i,o,r,c){this.data=e;this.shoppingCartService=t;this.promotionEventService=i;this.dialogRef=o;this.matDialog=r;this.toastr=c;this.searchCtrl=new et,this.rewardQuantity=e.rewardQuantity,this.sourceRewards=[...e.rewards]}modalConfig;rewards$;rewardQuantity;rewards;sourceRewards=[];searchCtrl;isApplyingReward=R(!1);ngOnInit(){this.initModalConfig(),this.initSearchCtrl(!0)}initModalConfig(){this.modalConfig=new ie,this.modalConfig.title="Select a Reward",this.rewardQuantity<2&&(this.modalConfig.hideFooter=!0)}initSearchCtrl(e){this.rewards$=this.searchCtrl.valueChanges.pipe(si(""),ht(e?0:500),Fe(),Y(t=>{let i;return i=ke(this.sourceRewards).pipe(J(o=>(o.length===1&&(o[0].Quantity=this.rewardQuantity),o)),J(o=>o.filter(r=>this.findKeywordInValue(t,r?.VariantCode)||this.findKeywordInValue(t,r?.VariantName)))),e=!1,i}),le(t=>{this.rewards=t}))}findKeywordInValue(e,t){return t?.toUpperCase()?.indexOf(e.toUpperCase())>-1}onApplyReward(e){return ni(this,null,function*(){if(!this.isApplyingReward()){this.isApplyingReward.set(!0);try{yield this.addRewardToShoppingCart(e)}finally{this.isApplyingReward.set(!1)}}})}onClose(){this.dialogRef.close()}onOk(){this.calculateRewardQty()>this.rewardQuantity?this.toastr.warning("Product reward exceeds the maximum amount earned","Warning"):[...this.rewards].filter(i=>i.Quantity>0).forEach(i=>{this.addRewardToShoppingCart(i)})}calculateRewardQty(){let e=0;return this.rewards.forEach(t=>{e+=t.Quantity?t.Quantity:0}),e}addRewardToShoppingCart(e){return e.PromotionType=this.data.promotion.TypeID,this.shoppingCartService.addCartItemById(e.VariantID,e,!0).then(()=>{this.matDialog.closeAll(),this.promotionEventService.pushNewValue(this.promotionEventService.Data)})}static \u0275fac=function(t){return new(t||n)(P(fe),P(kt),P(Ae),P(te),P(we),P(L))};static \u0275cmp=A({type:n,selectors:[["app-modal-quantity-reward"]],standalone:!1,decls:27,vars:10,consts:[[3,"onCancel","onOk","onClose","config"],[1,"ms-3"],[1,"container"],[1,"row","mb-3"],[1,"row","table-scroll"],[1,"col-12"],[1,"table","table-bordered"],[1,"thead-light"],["scope","col"],["scope","col",2,"width","66px"],["type","text","placeholder","Type to filter reward",1,"form-control",3,"formControl"],[1,"text-end"],[1,"text-center"],["type","text","autoNum","","min","0",1,"form-control",3,"ngModelChange","ngModel"],[1,"btn","btn-sm","btn-success",3,"click","disabled"]],template:function(t,i){t&1&&(a(0,"modal-material",0),S("onCancel",function(){return i.onClose()})("onOk",function(){return i.onOk()})("onClose",function(){return i.onClose()}),a(1,"header")(2,"small",1),m(3),s()(),a(4,"content")(5,"div",2),h(6,Ir,3,1,"div",3),a(7,"div",4)(8,"div",5)(9,"table",6)(10,"thead",7)(11,"tr")(12,"th",8),m(13,"Name"),s(),a(14,"th",8),m(15,"Code"),s(),a(16,"th",8),m(17,"Price"),s(),a(18,"th",8),m(19,"Promo"),s(),h(20,Tr,2,0,"th",9)(21,Er,1,0,"th",8),s()(),a(22,"tbody"),K(23,kr,13,9,"tr",null,ve),y(25,"async"),y(26,"sortBy"),s()()()()()()()),t&2&&(p("config",i.modalConfig),l(3),M(" ( ",i.rewardQuantity," products reward ) "),l(3),C((i.sourceRewards==null?null:i.sourceRewards.length)>5?6:-1),l(14),C(i.rewardQuantity>1?20:21),l(3),Z(_t(26,6,x(25,4,i.rewards$),"desc","VariantCode")))},dependencies:[Te,Pe,Ee,bt,ne,Ot,ze,q,Dt],encapsulation:2})};var Ae=class n{constructor(e,t,i,o,r,c,u,D,F){this._orderDataService=e;this._outletService=t;this._invoiceCalculatorService=i;this._dialog=o;this._httpService=r;this._posService=c;this._toastr=u;this._signalrService=D;this.decimalPipe=F;this.previousQuantity=0,this.previousTotalEligible=0,this.subscribeNotification(),this._posService.Data$.subscribe(W=>{this.taxes=W.Taxes}),this._outletService.Data$.subscribe(W=>{this.loadPromotions(W.Promotion)}),this._orderDataService.Data$.pipe(ce(W=>{this.salesOrderData=W;let ye=this.calculateOrderReward(W.getRewards()),_n=this.calculateOrderReward(this.previousRewards);return this.previousQuantity!=W.TotalQuantity||_n<ye||this.isRestroreOrder}),ht(100)).subscribe(W=>{this.isRestroreOrder=!1,this.checkQtyPromotion(),this.applyQuantityPromotion(),this.previousRewards=[...W.getRewards()]}),this._invoiceCalculatorService.Data$.subscribe(W=>{this.checkEligiblePromotionWithMinSpend()})}_Data=new be([]);get Data(){return this._Data.getValue()}Data$=this._Data.asObservable();selectedPromotion=null;onClickToastPromo=new Me;previousQuantity;salesOrderData;orderDataBeforePromotion;taxes=[];previousTotalEligible;previousRewards=[];isRestroreOrder=!1;calculateOrderReward(e){let t=0;return e.length>0&&(t=e.map(i=>i.Quantity).reduce((i,o)=>i+o)),t}checkQtyPromotion(){let e=this._orderDataService.Data;this.checkEligibleQtyPromotion(e.CartItems),this.checkEligibleTierPromotion(e.CartItems),this.previousQuantity=e.TotalQuantity}subscribeNotification(){this._signalrService.OnPromotionEventChange.pipe(ee(),Y(()=>{let e=this._outletService.Data?.RegisterID;return this.getPromotions(e)})).subscribe(()=>{this._toastr.info("Promotion Event Updated","Promotion Update")})}getPromotions(e){return this._httpService.get(U.GetListPromotion,[{key:"RegisterID",value:e}]).pipe(le(t=>{this.loadPromotions(t)}))}loadPromotions(e){let t=this.getPromotionDesc(e);this.pushNewValue(t),this.checkQtyPromotion(),this.checkEligiblePromotionWithMinSpend()}pushNewValue(e){this.showToastEligiblePromotion(),this._Data.next(e)}checkSelectedPromotionRequirement(e){this.selectedPromotion!=null&&this.selectedPromotion.TypeID==e&&this.Data.find(i=>i.ID===this.selectedPromotion.ID)?.Eligible===!1&&(this._dialog.open(Fi,{id:"modal-promotion-confirm",data:{message:"Order will be restored to before the promotion is applied"},disableClose:!0}),this.isRestroreOrder=!0)}restoreOrder(){this._orderDataService.pushNewValue(this.orderDataBeforePromotion),this.selectedPromotion=null}getPromotionDesc(e=[]){return e?.map(i=>(i.Description=this.generatePromotionDesc(i),i))}checkEligiblePromotionWithMinSpend(){let e=this._invoiceCalculatorService.Data,t=this.Data?.filter(o=>(o.TypeID===1||o.TypeID==3)&&!this.checkExpiredPromotion(o)).map(o=>(e>=o.MinimumAmount?o.Eligible=!0:o.Eligible=!1,o)),i=this.mappingEligiblePromotion(t);this.pushNewValue(i),this.checkSelectedPromotionRequirement(1),this.checkSelectedPromotionRequirement(3)}checkEligibleQtyPromotion(e){let t=0,i=this.Data?.filter(r=>r.TypeID===2&&!this.checkExpiredPromotion(r)).map(r=>(r.Eligible=!1,r.ListVariant.length>0?(t=this.getQuantityByRequirementType(e,"variant",r.ListVariant),t>=r.MinimumAmount&&(r.Eligible=!0)):r.ListCategory.length>0?(t=this.getQuantityByRequirementType(e,"category",r.ListCategory),t>=r.MinimumAmount&&(r.Eligible=!0)):this.salesOrderData.TotalQuantity>=r.MinimumAmount&&(r.Eligible=!0),r)),o=this.mappingEligiblePromotion(i);this.pushNewValue(o)}checkEligibleTierPromotion(e){let t,i=this.Data?.filter(r=>r.TypeID===5&&!this.checkExpiredPromotion(r)).map(r=>(r.Eligible=!1,r.ListVariant.length>0?t=this.getQuantityByRequirementType(e,"variant",r.ListVariant):r.ListCategory.length>0?t=this.getQuantityByRequirementType(e,"category",r.ListCategory):t=this.salesOrderData.TotalQuantity,r.PromotionTieredQuantity.forEach(c=>{t>=c.Quantity&&(r.Eligible=!0)}),r)),o=this.mappingEligiblePromotion(i);this.pushNewValue(o)}getQuantityByRequirementType(e,t,i){let o=0,r;return t=="variant"?e.forEach(c=>{r=i.findIndex(u=>u.ID===c.VariantID),r!==-1&&(o+=c.Quantity)}):e.forEach(c=>{c.Variant&&(r=i.findIndex(u=>u.ID===c.Variant.CategoryID),r!==-1&&(o+=c.Quantity))}),o}mappingEligiblePromotion(e=[]){let t=this.Data;if(e?.length>0){let i;t=this.Data?.map(o=>(i=e.findIndex(r=>r.ID==o.ID),i!==-1&&(o=e[i]),o))}return t}checkExpiredPromotion(e){let t=new Date,i=new Date(e.StartDate),r=(f.IsEmpty(e.StartTime)?"00:00:00":e.StartTime).split(":").map(F=>parseInt(F));i.setHours(r[0],r[1],r[2]);let c=new Date(e.ExpirationDate),D=(f.IsEmpty(e.EndTime)?"23:59:59":e.EndTime).split(":").map(F=>parseInt(F));return c.setHours(D[0],D[1],D[2]),!(t.getTime()>=i.getTime()&&t.getTime()<=c.getTime())}showToastEligiblePromotion(){let e=this.getTotalEligiblePromotion(),t=f.IsNotEmpty(this.salesOrderData.Order.ID);this.previousTotalEligible!==e&&e>0&&!t&&this._toastr.info(e+" promotion(s) can be applied!","Promo available!",{timeOut:2e4}).onTap.pipe(Qe(1)).subscribe(()=>{this.onClickToastPromo.next(!0)}),this.previousTotalEligible=e}getTotalEligiblePromotion(){return this.Data?.filter(t=>t.Eligible).length}generatePromotionDesc(e){let t="";switch(e.TypeID){case 2:t+="Minimum "+this.decimalPipe.transform(e.MinimumAmount)+" ",e.ListVariant.length>0?(t=t+" piece of ",t+=this.generateItemListDescription(e.ListVariant)):e.ListCategory.length>0?(t+="from category ",t+=this.generateItemListDescription(e.ListCategory)):t+="items";break;case 1:t+="Minimum spend Rp. "+this.decimalPipe.transform(e.MinimumAmount);break;case 3:t+=`Apply
|
|
3
3
|
${e.Discount1!==0?"discount1 = "+e.Discount1+"%":""}
|
|
4
4
|
${e.Discount1!==0&&e.Discount2!==0?" and ":""}
|
|
5
|
-
${e.Discount2!==0?"discount2 = "+e.Discount2+"%":""}`}return t}generateItemListDescription(e){let t="";for(let i of e)t+=t==""?"":" or ",t+=`[${i.Name}]`;return t=this.slicePromotionDesc(t),t}slicePromotionDesc(e){return e.length>200&&(e=e.slice(0,200),e+="..."),e}applyPromotion(e){switch(this.orderDataBeforePromotion=mt(G,this.salesOrderData),this.selectedPromotion,this.selectedPromotion=e,e.TypeID){case 1:this.applyProductReward(e);break;case 2:switch(e.RewardTypeID){case 1:this.applyQuantityPromotion();break;case 2:this.applyCheapestReward(e);break}break;case 3:this.applyDiscountReward(e);break;case 4:break;case 5:this.applyTierReward(e);break}}applyProductReward(e){this.getRewards$(e).subscribe(t=>{this.openDialogSelectReward(t)})}openDialogSelectReward(e){this._dialog.open(ji,{data:{rewards:e.rewards,promotion:e.promotion}})}applyCheapestReward(e){let t=this.salesOrderData.CartItems;if(t.length>0){let o=t.sort((c,u)=>c.Price-u.Price)[0],r=o.Total;o.Quantity>1&&(r=o.Total/o.Quantity,r=r/o.Quantity),o.DiscountAmount=r,o.Note=e.Name,t=t.map(c=>(c.VariantID==o.VariantID&&(c=o,c.PromotionGift=!0),c)),this.salesOrderData.CartItems=t,this._orderDataService.pushNewValue(this.salesOrderData),this.showToastAppliedPromo(this.selectedPromotion)}}applyDiscountReward(e){let i=this._posService.Data.AppConfigJSON.ModuleSell.ProductNotes.CopyPromotionName;if(this.salesOrderData.Order.Discount=e.Discount1,this.salesOrderData.Order.Discount2=e.Discount2,this.salesOrderData.Order.Discount>100&&(this.salesOrderData.Order.Discount=100),i==!0&&(this.salesOrderData.Order.Note=e.Name),f.IsNotEmpty(e.TaxTypeID)){let o=this.taxes.find(r=>r.ID==e.TaxTypeID);this._invoiceCalculatorService.tax=o,this.salesOrderData.Order.TaxTypeID=e.TaxTypeID}this._orderDataService.pushNewValue(this.salesOrderData),this.pushNewValue(this.Data),this.showToastAppliedPromo(this.selectedPromotion)}applyTierReward(e){let t=this.salesOrderData.CartItems,i=[];e.ListVariant.length>0?i=t.filter(o=>e.ListVariant.findIndex(r=>r.ID==o.VariantID)!==-1):i=t.filter(o=>e.ListCategory.findIndex(r=>r.ID==o.Variant.CategoryID)!==-1),i.length==0?t=this.tierPromotionBlankRequirement(e):t=this.tierPromotionWithRequirement(e,i),this.salesOrderData.CartItems=t,this._orderDataService.pushNewValue(this.salesOrderData)}tierPromotionBlankRequirement(e){let t=this.salesOrderData.CartItems,i=this.salesOrderData.TotalQuantity;return e.PromotionTieredQuantity.sort((o,r)=>o.Quantity-r.Quantity).forEach(o=>{i>=o.Quantity&&(t=t.map(r=>(r.Discount=o.Discount,r=this.copyPromotionNameToItem(e,r),r)))}),t}tierPromotionWithRequirement(e,t){let i=0,o=this.salesOrderData.CartItems;t.forEach(c=>{i+=c.Quantity}),e.PromotionTieredQuantity.sort((c,u)=>c.Quantity-u.Quantity).forEach(c=>{i>=c.Quantity&&(t=t.map(u=>(u.Discount=c.Discount,u)))});let r;return o=o.map(c=>(r=t.find(u=>u==c),r&&(c=r,c=this.copyPromotionNameToItem(e,c)),c)),o}copyPromotionNameToItem(e,t){return this._posService.Data.AppConfigJSON.ModuleSell.ProductNotes.CopyPromotionName==!0&&(t.Note=e.Name),t}removePromotion(){this._orderDataService.pushNewValue(this.orderDataBeforePromotion),this.showToastRemovePromo(this.selectedPromotion),this.selectedPromotion=null}showToastAppliedPromo(e){this._toastr.success("Applied "+e.Name+" to order!","Applied successfully!")}showToastRemovePromo(e){this._toastr.info("Removed "+e.Name+" from order!","Removed successfully!")}applyQuantityPromotion(){if(this.selectedPromotion){let e=this.salesOrderData.getRewards();switch(this.selectedPromotion.TypeID){case 2:this.selectedPromotion.MultipleApply?this.calculateQtyMultiplyPromotion([this.selectedPromotion],e):(e.length==0&&this.applyQuantityReward(this.selectedPromotion,1),this.checkSelectedPromotionRequirement(2));break;case 5:this.applyTierReward(this.selectedPromotion),this.checkSelectedPromotionRequirement(5);break}}}calculateQtyMultiplyPromotion(e,t){let i=me(xe,this.salesOrderData.CartItems),o,r=[],c=0,u;e.forEach(O=>{r=i.filter(k=>(O.RequirementTypeID==0?o=O.ListVariant.findIndex(W=>W.ID==k.VariantID):o=O.ListCategory.findIndex(W=>W.ID==k.Variant.CategoryID),o!==-1)),u=t.filter(k=>k.PromotionID==O.ID),c=this.calculateQtyMultiply(r,O.MinimumAmount),this.showModalSelectReward(u,c,O)})}showModalSelectReward(e,t,i){let o=0;if(e.forEach(r=>o+=r.Quantity),t>o){let r=t-o;this.applyQuantityReward(i,r)}else if(t<o){this.selectedPromotion.Eligible=!1;let r=this.mappingEligiblePromotion([this.selectedPromotion]);this.pushNewValue(r),this.checkSelectedPromotionRequirement(2)}}applyQuantityReward(e,t){t>0&&this.getRewards$(e).subscribe(i=>{this._dialog.open(Qi,{data:{promotion:e,rewardQuantity:t,rewards:i.rewards}})})}calculateQtyMultiply(e,t){if(e.length>0){let o=e.filter(r=>r.PromotionGift==!1).map(r=>r.Quantity).reduce((r,c)=>r+c)/t;return this.getFirstNumber(o)}else return 0}getFirstNumber(e){let t=e.toString().split(".");return Number(t[0])}getRewards$(e){return this._httpService.get(U.GetRewardByPromotionID,[{key:"ID",value:e.ID}]).pipe(J(t=>({rewards:t.Rewards,promotion:e})))}static \u0275fac=function(t){return new(t||n)(g(L),g(re),g(se),g(we),g(ge),g(z),g(F),g(rt),g(q))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Ui=class{RegisterID;Number;Amount;TransactionID};var Ft=class{GroupID;Method;Data};var Wi=class{Status;InvoiceID;LoyaltyPoint;diff};var Gi=class{GopayQr};var qi=class{Name;Quantity;Discount;DiscountAmount;Price;UnitQuantity};var $i=class{Items;AmountSummary;GopayQr;Number;Customer;SalesName;CurrencySymbol;FinalAmount};var Ji=class n{_state=R(this.initCustomerDisplayState());isEnabled=ae(()=>this._state()?.enabled);connect(){let t={enabled:!0,timestamp:new Date().toDateString()};localStorage.setItem("customerDisplay",JSON.stringify(t)),this._state.set(t)}initCustomerDisplayState(){let e=localStorage.getItem("customerDisplay"),t={enabled:!1,timestamp:""};return f.IsNotEmpty(e)&&(t=JSON.parse(e)),t}disconnect(){let t={enabled:!1,timestamp:new Date().toDateString()};localStorage.setItem("customerDisplay",JSON.stringify(t)),this._state.set(t)}static \u0275fac=function(t){return new(t||n)};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var _e=class{Amount;CurrencySymbol;Label;Type;constructor(e,t,i,o){this.Amount=e,this.CurrencySymbol=t,this.Label=i,this.Type=o}};var zi=class n{constructor(e,t,i,o){this._invoiceCalculatorService=e;this._decimalPipe=t;this._poshttpResponseService=i;this._orderService=o;this._poshttpResponseService.Data$.pipe(ee()).subscribe(r=>{this.appConfig=r.AppConfigJSON})}appConfig=new st;generateAmountSummary(){let e=[];this.isUseTax()?e=this.generateSummaryTax():e=this.generateSummaryNonTax();let t=this.generateSurchargeSummary();return t&&e.push(...t),e}generateSummaryTax(){let e=this._invoiceCalculatorService.tax?.CalculationTypeID,t=[];return e==1?t=this.generateSummaryTaxInclude():t=this.generateSummaryTaxExclude(),t}generateSummaryNonTax(){let e=[],t=this.generateCartItemAmount();if(e.push(t),this.isDiscounted()){let i=this.generateDiscountSummary(),o=this.generateAmountTotal("Total");e.push(...i,o)}return e}generateSummaryTaxInclude(){let e=[];return this.isTaxReserveSequence()?e=this.generateTaxIncludeReserveSequence():e=this.generateTaxIncludeNormalSequence(),e}generateTaxIncludeReserveSequence(){let e=[];if(this.isTaxDetailVisible()==!1){let r=this._invoiceCalculatorService.TotalBeforeTax,c=this.isDiscounted()?"Amount":"Before Tax",u=this.isDiscounted()?this._invoiceCalculatorService.GrossTotal:r,O=new _e(u,this.currencySymbol,c,2);e.push(O)}if(this.isDiscounted()){let r=this.generateDiscountSummary(),c=this.generateBeforeTaxSummary();e.push(...r,c)}let i=this.generateTax(),o=this.generateAmountTotal();return e.push(...i,o),e}generateTaxIncludeNormalSequence(){let e=[],t=this.generateCartItemAmount();if(e.push(t),this.isDiscounted()){let o=this.generateDiscountSummary(),r=this.generateSummarySubTotal();e.push(...o,r)}let i=this.generateTax();if(e.push(...i),this.isTaxDetailVisible()==!1){let o=this.generateBeforeTaxSummary();e.push(o)}return e}generateSummaryTaxExclude(){let e=[],t=this.generateCartItemAmount(!0);if(e.push(t),this.isDiscounted()){let c=this.generateDiscountSummary(),u=this.generateSummarySubTotal();e.push(...c,u)}let i=this.generateTax(),o=this._invoiceCalculatorService.TotalAfterTax,r=new _e(o,this.currencySymbol,"Total",1);return e.push(...i,r),e}generateAmountTotal(e="Total Amount"){let t=this._invoiceCalculatorService.Data;return new _e(t,this.currencySymbol,e,1)}generateSummarySubTotal(){let e=this._invoiceCalculatorService.TotalAfterTax;return new _e(e,this.currencySymbol,"SubTotal",1)}generateBeforeTaxSummary(){let e=this._invoiceCalculatorService.TotalBeforeTax;return new _e(e,this.currencySymbol,"Before Tax",2)}isTaxDetailVisible(){return this.appConfig.PrintConfigInvoice?.Footer?.TaxDetailVisible}isUseTax(){let e=this._invoiceCalculatorService.tax;return e?.PrintVisible&&e?.Rate!=0}generateTax(){let e=[],t=this.isTaxDetailVisible(),i=t?2:1,o=this._invoiceCalculatorService.tax;if(t){let r=this.appConfig.PrintConfigInvoice.Footer.TaxableSales,c=this.calculateTaxableSales(),u=new _e(c,this.currencySymbol,r,i);e.push(u)}if(o.TypeID==2){let r=this.generateTaxTypeMultiple();e.push(...r)}else{let r=this.generateSingleTaxSummary(o.Label,this._invoiceCalculatorService.TaxAmount,i);e.push(r)}if(t){let r=this.appConfig.PrintConfigInvoice.Footer.TaxExemptSales,c=this._invoiceCalculatorService.GrossTotalNonTaxable,u=new _e(c,this.currencySymbol,r,i);e.push(u);let O=this.appConfig.PrintConfigInvoice.Footer.LabelWithZeroAmount;if(O){let k=new _e(0,this.currencySymbol,O,i);e.push(k)}}return e}generateCartItemAmount(e=!1){let t=this.isDiscounted()||e?this._invoiceCalculatorService.GrossTotal:this._invoiceCalculatorService.TotalAfterTax;return new _e(t,this.currencySymbol,"Amount",1)}get currencySymbol(){return this._invoiceCalculatorService.currencySymbol}generateDiscountSummary(){let e=[];if(this._invoiceCalculatorService.Discount1Amount!=0){let t=this._decimalPipe.transform(this._orderService.Data.Order.Discount),o=this.checkDiscountIgnoreDecimal(t)?"{0}":"{0} ({1}%)";e.push(new _e(this._invoiceCalculatorService.Discount1Amount*-1,this._invoiceCalculatorService.currencySymbol,f.StringFormat(o,this.appConfig.CorePrint.Alias.Discount1,t),1))}if(this._invoiceCalculatorService.Discount2Amount!=0){let t=this._decimalPipe.transform(this._orderService.Data.Order.Discount2),o=this.checkDiscountIgnoreDecimal(t)?"{0}":"{0} ({1}%)";e.push(new _e(this._invoiceCalculatorService.Discount2Amount*-1,this._invoiceCalculatorService.currencySymbol,f.StringFormat(o,this.appConfig.CorePrint.Alias.Discount2,t),1))}return this._orderService.Data.Order.DiscountAmount!=0&&this.appConfig.PrintConfigInvoice.ItemsFooter.DiscountAmountVisible&&e.push(new _e(this._orderService.Data.Order.DiscountAmount*-1,this._invoiceCalculatorService.currencySymbol,"Discount ("+this._invoiceCalculatorService.currencySymbol+")",1)),e}calculateTaxableSales(){let e=this._invoiceCalculatorService.tax,t=this._invoiceCalculatorService.TaxAmount,i=this._invoiceCalculatorService.GrossTotalTaxable;return e.Rate==0?0:e.CalculationTypeID==1?i-t:i}generateTaxTypeMultiple(){let e=this.appConfig.PrintConfigInvoice.Footer.TaxDetailVisible?2:1,t=[],i=this._invoiceCalculatorService.tax;var o=this._invoiceCalculatorService.TaxAmount;if(i.TypeID==2){let r=i?.Components?i?.Components:[],c=this._invoiceCalculatorService.GrossTotalTaxable,u=this.calculateTotalRate(r);r.forEach(O=>{if(i.CalculationTypeID==0){let k=O.Rate/100*c;t=[...t,this.generateSingleTaxSummary(O.Label,k,e)],i.MultipleTaxTypeID==1&&(c+=k)}else{let k=O.Rate/u*o;t=[...t,this.generateSingleTaxSummary(O.Label,k,e)]}})}else t=[...t,this.generateSingleTaxSummary(i.Label,o,e)];return t}calculateTotalRate(e){let t=0;return e&&e.length>0&&(t=e.map(i=>i.Rate).reduce((i,o)=>i+o)),t}generateSingleTaxSummary(e,t,i){let o=this._invoiceCalculatorService.currencySymbol;return new _e(t,o,e,i)}generateSurchargeSummary(){if(this._invoiceCalculatorService.SurchargeAmount==0)return;let e=[],t=this.appConfig.CorePrint,i=t&&t.Alias.SurchargePcg?t.Alias.SurchargePcg:"Surcharge";e.push(new _e(this._invoiceCalculatorService.SurchargeAmount,this._invoiceCalculatorService.currencySymbol,f.StringFormat("{0} ({1}%)",i,this._decimalPipe.transform(this._orderService.Data?.Invoice.SurchargePcg)),1));let o=this.generateAmountTotal();return e.push(o),e}checkDiscountIgnoreDecimal(e){let i=this.appConfig.PrintConfigInvoice.Footer.DiscountIgnoredDecimal,o=parseFloat(e)%1,r=!1;return o!==0&&i&&(r=!0),r}isDiscounted(){let e=this._invoiceCalculatorService.Discount1Amount,t=this._invoiceCalculatorService.Discount2Amount,i=this._orderService.Data.Order.DiscountAmount,o=!1;return(e!=0||t!=0||i!=0)&&(o=!0),o}isTaxReserveSequence(){let e=this._invoiceCalculatorService.tax,t=!!e,i=t?e.CalculationTypeID:null,o=this.appConfig.PrintConfigInvoice.ItemsFooter.TaxIncludeBeforeTotalAmount;return t&&i===1&&o}static \u0275fac=function(t){return new(t||n)(g(se),g(q),g(z),g(L))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var lt=class n{constructor(e,t,i,o){this._receiptCalculatorService=e;this._cashierCalculatorService=t;this._signal=i;this._customerHttpService=o;this.broadcastOrderUpdate$.subscribe()}_salesOrderDataModelService=T(L);_outletService=T(re);displayService=T(Ji);localdata=T(Oe);orderDataModel;broadcastOrderUpdate$=$e([this._salesOrderDataModelService.Data$,this.localdata.isStoreOrderInServer(),so(this.displayService.isEnabled)]).pipe(kn(([e,t,i])=>{let o=this._outletService?.Data?.RegisterID;if(t&&i&&o){this.orderDataModel=e;let r=this.ConstructCartModelForCustomerDisplay(),c=new Ft;return c.GroupID=o+"_Subscriber",c.Method="POSCartAmountUpdated",c.Data=r,this._signal.broadcast(c).pipe(nt(u=>(console.log(u),gt)))}else return gt}),nt(e=>(console.log(e),gt)),ee());ConstructCartModelForCustomerDisplay(){let e=this._customerHttpService.Data,t=new $i;t.Number=this.orderDataModel.Order.Number,t.Items=Array();for(let i of this.orderDataModel.CartItems){let o=new qi;o.Name=i.Variant.Name,o.Discount=i.Discount,o.DiscountAmount=i.DiscountAmount,o.Price=i.Price,o.Quantity=i.Quantity,o.UnitQuantity=i.UnitQuantity,t.Items.push(o)}return f.IsNotEmpty(this.orderDataModel.Order.SalesID)?t.SalesName=this._outletService.getSalesname(this.orderDataModel.Order.SalesID):t.SalesName="",f.IsNotEmpty(this.orderDataModel.Order.CustomerID)&&f.IsNotEmpty(e)&&(t.Customer=new xt,t.Customer.Email=e.Email,t.Customer.Mobile=e.Mobile,t.Customer.Name=this.orderDataModel.ContactName),t.CurrencySymbol=this._cashierCalculatorService.currencySymbol,t.FinalAmount=this._cashierCalculatorService.Data,t.AmountSummary=this._receiptCalculatorService.generateAmountSummary(),t}BroadcastStateToCustomerDisplay(e,t="",i="",o=0){let r=new Wi;r.Status=e,r.InvoiceID=t,r.LoyaltyPoint=i,r.diff=o;let c=new Ft;return c.GroupID=this._outletService.Data.RegisterID+"_Subscriber",c.Method="POSStateUpdated",c.Data=r,this.displayService.isEnabled()?this.localdata.isStoreOrderInServer().pipe(Y(u=>u?this._signal.broadcast(c):ke(oe.offlineMode))):gt}BroadcastQRToCustomerDisplay(e){let t=new Gi;t.GopayQr=e;let i=new Ft;return i.GroupID=this._outletService.Data.RegisterID+"_Subscriber",i.Method="POSQRPaymentActivated",i.Data=t,this.displayService.isEnabled()?this.localdata.isStoreOrderInServer().pipe(Y(o=>o?this._signal.broadcast(i):ke(oe.offlineMode))):gt}static \u0275fac=function(t){return new(t||n)(g(zi),g(se),g(rt),g(Re))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Yi=class n{constructor(e){this.httpService=e}VerifyPayment(e,t){let i=this.getVerifyPaymentUrl(t);return this.httpService.post(i,e)}getVerifyPaymentUrl(e){let t;switch(e){case 0:t=U.GopayVerifyPayment;break;case 1:t=U.BcaVerifyPayment;break}return t}generateLink(e){return this.httpService.post(U.GenerateLink,e)}generateQRCode(e,t){return this.httpService.post(e,t)}static \u0275fac=function(t){return new(t||n)(g(ge))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Lt=class n{constructor(e,t,i,o,r){this._posHubService=e;this._orderDataService=t;this._PaymentHttpService=i;this._InvoicecashierCalculatorService=o;this._toastrService=r}transactionId;qrPaymentMethodID;QRCodeHttpResponse;_paymentMethod;get paymentMethod(){return this._paymentMethod}resetPaymentMethod(){this._paymentMethod=null}onQRPaymentComplete(e,t){return new Promise((i,o)=>{if(e.transaction_id!==this.transactionId){let c=`transaction_id: ${e.transaction_id} / gross_amount: ${e.gross_amount}`;o({header:"Invalid QR Payment",message:c});return}if(e.gross_amount!==this._InvoicecashierCalculatorService.Data){let c=`paid_amount: ${e.gross_amount} vs invoice_amount: ${this._InvoicecashierCalculatorService.Data}`;o({header:"Invalid QR Payment",message:c});return}let r=this._orderDataService.Data.Order.Number;if(e.order_id.includes(r)==!1){let c=`Order ID: ${e.order_id} vs Order Number: ${r}`;o({header:"Invalid QR Payment",message:c});return}if(e.transaction_status!=="settlement"){let c=`Transaction status is ${e.transaction_status}`;o({header:"Invalid QR Payment",message:c});return}this.validateEMoneyPayment(t).subscribe(c=>{i(c)})})}generateNewPayment(e,t){let i=this._orderDataService.Data;f.IsEmpty(this.qrPaymentMethodID)&&alert("QR PaymentMethod.ID is not available!");let o=new Ke;return o.PaidAmount=t,o.Amount=t,o.Date=i.Order.Date,o.MethodID=this.qrPaymentMethodID,o.Code=e,f.IsEmpty(e)&&this._toastrService.warning("Midtrans transaction_id is empty. Please verify manually!","Mobile Payment Failure"),o}sendStateCompleteToCustomerDisplay(e){this._posHubService.BroadcastStateToCustomerDisplay(1,e.ObjectID,e.LoyaltyPoint,0).subscribe()}generateQR(e,t){this._paymentMethod=t,this.qrPaymentMethodID=t.ID;let i=this.getServiceUrl(t.EMoneyTypeID);return this._PaymentHttpService.generateQRCode(i,e).pipe(J(c=>(c=this.manipulateBCAQrisImg(c,t.EMoneyTypeID),this.transactionId=c.Transaction_id,this.QRCodeHttpResponse=c,this._orderDataService.transaction_id=c.Transaction_id,this.sendQRToCustomerDisplay(c.Url),c)))}sendQRToCustomerDisplay(e){this._posHubService.BroadcastQRToCustomerDisplay(e).subscribe()}validateEMoneyPayment(e){if(f.IsNotEmpty(this.transactionId)){let t=this._InvoicecashierCalculatorService.Data,i=this._paymentMethod?.EMoneyTypeID,o=this.generatePaymentVerificationData(t,i);return this._PaymentHttpService.VerifyPayment(o,i).pipe(Y(r=>(this.updatePosDataForSubmission(t),An(this._orderDataService.submitOrder(e)).pipe(le(c=>{this.sendStateCompleteToCustomerDisplay(c)})))))}else{let t=new Error("Transaction ID is Empty");throw ft(()=>t)}}generatePaymentVerificationData(e,t){let i=this._orderDataService.Data,o=new Ui;return o.Number=i.Order.Number,o.Amount=e,o.TransactionID=this.transactionId,o.RegisterID=i.Order.RegisterID,t==1&&(o.Number=this.QRCodeHttpResponse.Number),o}updatePosDataForSubmission(e){let t=this._orderDataService.Data,i=this.generateNewPayment(this.transactionId,e),o=[];o.push(i),t.Invoice.Due=null,t.Action.Type=3,t.Order.InvoicedStateID=3,t.Payments=o,this._orderDataService.pushNewValue(t)}getServiceUrl(e){let t;switch(e){case 0:t=U.GenerateGopayQrCode;break;case 1:t=U.GenerateBcaQrCode;break}return t}manipulateBCAQrisImg(e,t){return t==1&&(e.Url=`data:image/png;base64, ${e.Url}`),e}clearTransactionID(){this.transactionId=null,this._orderDataService.transaction_id=null,this.QRCodeHttpResponse=null}getTransactionId(){return this.transactionId}static \u0275fac=function(t){return new(t||n)(g(lt),g(L),g(Yi),g(se),g(F))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var je=class n{constructor(e,t,i,o,r,c,u,O,k,W,ye,_n,Rn,nr){this._orderDataService=e;this._posHttpResponseService=t;this._CoreHttpService=i;this._outletService=o;this._orderHttpService=r;this._signal=c;this._promotionEventService=u;this._promotionCouponService=O;this._customerHttpService=k;this._invoiceCalculatorService=W;this._dialog=ye;this._toastr=_n;this._paymentGatewayService=Rn;this.roleService=nr;this.subscribeObservableChanges(),this._signal.OnContactReceive.subscribe(yn=>{if(!f.IsEmpty(yn)){let bn=JSON.parse(yn);this._orderDataService.updateCustomerID(bn.ID).then(Nn=>{this.posData.ContactName=bn.Name,this._customerHttpService.Data=Nn,this.pushNewValue(this.Data)})}})}_Data=new be(new Nt);_clearOrder=new Me;get clearOrder$(){return this._clearOrder.asObservable()}get Data(){return this._Data.value}Data$=this._Data.asObservable();posData=new G;activeRegister=new Oo;subscribeObservableChanges(){this._orderDataService.Data$.pipe(ee()).subscribe(e=>{this.posData=e}),this._outletService.Data$.pipe(ce(e=>e?.RegisterID!==this.activeRegister?.RegisterID),ee()).subscribe(e=>{this.activeRegister=e,this.Data.posState!=2?this.createNewSalesOrderDataModel():this.setPrintTemplateToDefault(this.posData.Order.TypeID)})}pushNewValue(e){this._Data.next(e)}createNewTransactionInSameOutletRegister(e=!0){if(e){let t=this._orderDataService.Data.Order.EntityID;this._CoreHttpService.GenerateNumber(t,this.activeRegister).subscribe(i=>{this.activeRegister.NumberElement=i.OrderNumberElement,this.activeRegister.InvoiceNumberElement=i.InvoiceNumberElement,this.activeRegister.NewOrderID=i.NewOrderID,this.refreshLoader(),this.pushNewValue(new Nt),this.createNewSalesOrderDataModel()})}else this.pushNewValue(new Nt),this.createNewSalesOrderDataModel()}refreshLoader(){if(this._posHttpResponseService.Data.AppConfigJSON.ModuleShift?.Closure?.Enabled){let i=this._posHttpResponseService.Data.Registers.find(o=>o.ID==this.activeRegister?.RegisterID);i&&f.IsEmpty(i.LoginID)&&this._posHttpResponseService.requestObservable().subscribe()}}updatePosState(e,t){t&&this._orderHttpService.pushNewValue(t),this.Data.posState=e,this.pushNewValue(this.Data)}ReturnOrder(e){e&&(this.posData.CartItems=me(xe,e.CartItems),this.posData.CartItems=this.posData.CartItems.map(t=>(t.Quantity=t.Quantity*-1,t.Variant.TypeID==4&&(t.Serial=t.Serial.map(i=>(i.Quantity=i.Quantity*-1,i))),t)),this.posData.Invoice.ReferenceInvoiceID=e.Invoice.ID,this.posData.Order.Discount=e.Order.Discount,this.posData.Order.Discount2=e.Order.Discount2,this.posData.Order.DiscountAmount=e.Order.DiscountAmount*-1,this.posData.Order.TaxTypeID=e.Order.TaxTypeID,this.posData.Order.SalesID=e.Order.SalesID,this.posData.Order.CustomerID=e.Order.CustomerID,this.posData.ContactName=e.ContactName,this.posData.Order.PointUsed=e.Order.PointUsed*-1,this.initSelectedTax(),this._orderDataService.pushNewValue(this.posData))}plainToClass(e,t){if(this.posData=mt(G,e),this.assignInvoice(e),this.assignCustomerData(e),this.initSelectedRegister(e,t),this.assignParkTemporaryItem(e),this.assignOrderCurrency(this.posData.Order.CurrencyID),this.initPromotionGift(),t==4){this.posData.Order.Date=new Date;let i=this.getDeliveryEntityID(this.activeRegister);this.posData.Action.DeliveryEntityID=i.DeliveryEntityID,this.posData.Order.DeliveryStateID=i.DeliveryStateID,this.copySalesOrderNoteToInvoice()}this.initSelectedTax(),this._orderDataService.pushNewValue(this.posData),this._promotionCouponService.setCouponOnEdit(this.posData.Promotion)}copySalesOrderNoteToInvoice(){this._posHttpResponseService.Data.AppConfigJSON?.ApplicationParkAndRetrieve?.Advance?.CopyOrderNoteToInvoice&&(this.posData.Invoice.Note=this.posData.Order.Note)}initPromotionGift(){let e=this.posData.CartItems;e=e.map(t=>(t.PromotionGift=t.PriceTypeID==3,t))}initSelectedTax(){let e=this.posData.Order.TaxTypeID;this._invoiceCalculatorService.tax=this.getTaxObjectByID(e);let t=this._invoiceCalculatorService.tax;f.IsEmpty(t)&&this.showModalSuspendedDefaultTax()}assignInvoice(e){if(e.Invoice){let t=e.Invoice.Due,i=e.Invoice.Date,o=t!=f.MinDate&&f.IsNotEmpty(t)?new Date(e.Invoice.Due):null,r=i!=f.MinDate&&f.IsNotEmpty(i)?new Date(e.Invoice.Date):new Date;e.Invoice.Due=o,e.Invoice.Date=r,this.posData.Invoice=e.Invoice,this.posData.Action.Type=3}else{let t=this.activeRegister;this.posData.Invoice=new Jt,f.IsNotEmpty(t.InvoiceNumberElement)&&(this.posData.Invoice.Number=Pn.Generate(t.InvoiceNumberElement))}}assignCustomerData(e){let t=e.Order.CustomerID,i=e.Order.EntityID;f.IsNotEmpty(t)&&f.IsNotEmpty(i)?ai(this._customerHttpService.GetPrivilegeByID(t,i)).then(o=>{let c=this._posHttpResponseService.Data.AppConfigJSON.ApplicationLoyalty.Label,u=o;u.Label=c,u.DebtCalculated=u.Debt,u=this.calculateCustomerDebt(e,u),this._customerHttpService.Data=u,this.pushNewValue(this.Data)}):this.Data.InputTextValue=null}calculateCustomerDebt(e,t){let i=e.Payments,o=f.IsNotEmpty(e.Invoice.ID);return i.length==0&&o&&(t.DebtCalculated=t.Debt-e.Invoice.Sales),t}initSelectedRegister(e,t){if(t!==4){let i=this._posHttpResponseService.Data.Registers;i.length>0?this.checkAccessOutletUser(e,i):this._toastr.warning("You do not have access to edit in this outlet","Warning")}else{let i=this.activeRegister.RegisterID;i!==e.Order.RegisterID&&(this.posData.Order.RegisterID=i,this._toastr.warning("You are processing order from different Register","Different Register"))}}checkAccessOutletUser(e,t){let i=e.Order.RegisterID,o=t.find(r=>r.ID==i);o?this._outletService.pushNewRegister(o):this._toastr.warning(`There is no Register with ID [${i}]`,"Warning")}assignParkTemporaryItem(e){this.Data.parkTemporaryItem=mt(xe,e.CartItems),this.pushNewValue(this.Data)}getDefaultOrderType(e){if(f.IsNotEmpty(e.DefaultSalesOrderTag))return e.DefaultSalesOrderTag;{let t=this._posHttpResponseService.Data.PoTypes;return t.length>0?t[0].ID:null}}createNewSalesOrderDataModel(){this._promotionEventService.selectedPromotion=null,this._paymentGatewayService.clearTransactionID(),this._invoiceCalculatorService.discountAfterTax=0,this._promotionCouponService.resetCouponOnNewTransaction(),this._customerHttpService.Data=new xt;let e=this._posHttpResponseService.Data,t=this.activeRegister,i=new G;!f.IsEmpty(e.SalesID)&&t.ListSales!=null&&t.ListSales.find(c=>c.ID==e.SalesID)&&(i.Order.SalesID=e.SalesID),i.Action.NewOrderID=t.NewOrderID,f.IsNotEmpty(t.NumberElement)&&(i.Order.Number=Pn.Generate(t.NumberElement)),i.Order.CurrencyID=e.AppConfigJSON.CoreDefaults.CurrencyID,this.assignOrderCurrency(i.Order.CurrencyID),i=this.initDefaultTaxType(i),this._posHttpResponseService.Data.AppConfigJSON.ModuleSell.RememberOrderTypeFromPreviousTransaction?f.IsEmpty(this._orderHttpService.Data)?(i.Order.TypeID=this.getDefaultOrderType(t),this.setPrintTemplateToDefault(i.Order.TypeID)):i.Order.TypeID=this.posData.Order.TypeID:(i.Order.TypeID=this.getDefaultOrderType(t),this.setPrintTemplateToDefault(i.Order.TypeID)),f.IsNotEmpty(t.EntityID)&&(i.Order.EntityID=t.EntityID,i.Order.RegisterID=t.RegisterID),i.Order.CouponType=1;let o=this.getDeliveryEntityID(t);i.Action.DeliveryEntityID=o.DeliveryEntityID,i.Order.DeliveryStateID=o.DeliveryStateID,i.CartItems=this.getItemsFromLocalStorage(i.Order?.Number),this.Data.posState=0,this._orderDataService.pushNewValue(i)}getItemsFromLocalStorage(e){let t=localStorage.getItem("cart_items"),i=[];if(t){let o=this.roleService.Data?.DeleteItem,r=JSON.parse(t),c=e==r?.Number;o||!c?localStorage.removeItem("cart_items"):i=me(xe,r.CartItems)}return i}initDefaultTaxType(e){let t=this._posHttpResponseService.Data;if(f.IsNotEmpty(this.activeRegister.DefaultTaxType)){let i=this.getTaxObjectByID(this.activeRegister.DefaultTaxType);f.IsNotEmpty(i)?(e.Order.TaxTypeID=this.activeRegister.DefaultTaxType,this._invoiceCalculatorService.tax=i):(this.showModalSuspendedDefaultTax(),e.Order.TaxTypeID=t.Taxes[0].ID,this._invoiceCalculatorService.tax=t.Taxes[0])}else e.Order.TaxTypeID=t.Taxes[0].ID,this._invoiceCalculatorService.tax=t.Taxes[0];return e}assignOrderCurrency(e){let t=this.findCurrencyById(e);this._invoiceCalculatorService.currencySymbol=t?.Symbol,this.posData.Order.CurrencyRate=t?.ExchangeRate}setPrintTemplateToDefault(e){let i=(this._posHttpResponseService?.Data?.PoTypes).find(o=>o.ID==e);i?.PrintTemplateID==0?(this.activeRegister.PrintTemplate=this.activeRegister.DefaultPrintTemplate,this._outletService.pushNewValue(this.activeRegister)):this.activeRegister?.PrintTemplate?.ID!==i?.PrintTemplateID&&this._orderHttpService.getSalesOrderPrint(i?.PrintTemplateID).subscribe(o=>{this.activeRegister.PrintTemplate=o.Template,this._outletService.pushNewValue(this.activeRegister)})}findCurrencyById(e=1){return this._posHttpResponseService.Data.Currencies.find(o=>o.ID==e)}getTaxObjectByID(e){return this._posHttpResponseService.Data.Taxes.find(i=>i.ID==e)}getDeliveryEntityID(e){let t=this._posHttpResponseService.Data.AppConfigJSON,i={DeliveryStateID:3,DeliveryEntityID:f.GuidEmpty};if(t.ModuleSell.Shipping.DefaultOrderDelivery==0){let o=this._posHttpResponseService.Data.Entities.find(r=>r.ID==this._outletService.getOutletRegister().EntityID);f.IsNotEmpty(o.ID)&&o.FulfillmentOption==2&&(i.DeliveryEntityID=f.GuidEmpty,i.DeliveryStateID=0),f.IsEmpty(e.DefaultWarehouse)?i.DeliveryEntityID=e.EntityID:i.DeliveryEntityID=e.DefaultWarehouse}else i.DeliveryEntityID=f.GuidEmpty,i.DeliveryStateID=0;return i}reedemPointToDiscount(e=!1){let t=this._posHttpResponseService.Data.AppConfigJSON,i=t.ApplicationLoyalty.Rules.PrefferedPayment,o=t.ApplicationLoyalty.Enabled,r=this._customerHttpService.Data,c=this.Data.posState==2,u=r.Point?r.Point:0;if(i&&u>0&&o){if(f.IsNotEmpty(this.posData.Order.CustomerID)&&!c){let O=t.ApplicationLoyalty.LoyaltyPoint.RedeemPointValue,k=this._invoiceCalculatorService.GetCashAndPointAmountCart(),W=u*O,ye=u;W>k&&(W=k),W>0&&O>0?ye=Math.ceil(W/O):ye=0,r.PointUsed=ye,this.posData.Order.PointUsed=ye,this.posData.Order.DiscountAmount=W,this.resetCouponDiscountAmount()}else e&&(r.PointUsed=0,this.posData.Order.PointUsed=0,this.posData.Order.DiscountAmount=0);this._orderDataService.pushNewValue()}}resetCouponDiscountAmount(){let e=this._promotionCouponService.coupon;e&&(e.Requirement?.Type==2||e.Requirement?.Type==1&&e.Requirement?.MaximumDiscount>0&&!e.Requirement?.FullPriceProductOnly)&&(this._promotionCouponService.removeAppliedCoupon(),this._toastr.warning("Loyalty point is used, coupon will be cancelled","Coupon Cancelled"))}showModalSuspendedDefaultTax(){this._dialog.open(Do,{id:"ModalInfo",data:{title:"Default Tax Discontinued",message:`
|
|
5
|
+
${e.Discount2!==0?"discount2 = "+e.Discount2+"%":""}`}return t}generateItemListDescription(e){let t="";for(let i of e)t+=t==""?"":" or ",t+=`[${i.Name}]`;return t=this.slicePromotionDesc(t),t}slicePromotionDesc(e){return e.length>200&&(e=e.slice(0,200),e+="..."),e}applyPromotion(e){switch(this.orderDataBeforePromotion=dt(G,this.salesOrderData),this.selectedPromotion,this.selectedPromotion=e,e.TypeID){case 1:this.applyProductReward(e);break;case 2:switch(e.RewardTypeID){case 1:this.applyQuantityPromotion();break;case 2:this.applyCheapestReward(e);break}break;case 3:this.applyDiscountReward(e);break;case 4:break;case 5:this.applyTierReward(e);break}}applyProductReward(e){this.getRewards$(e).subscribe(t=>{this.openDialogSelectReward(t)})}openDialogSelectReward(e){this._dialog.open(ji,{data:{rewards:e.rewards,promotion:e.promotion}})}applyCheapestReward(e){let t=this.salesOrderData.CartItems;if(t.length>0){let o=t.sort((c,u)=>c.Price-u.Price)[0],r=o.Total;o.Quantity>1&&(r=o.Total/o.Quantity,r=r/o.Quantity),o.DiscountAmount=r,o.Note=e.Name,t=t.map(c=>(c.VariantID==o.VariantID&&(c=o,c.PromotionGift=!0),c)),this.salesOrderData.CartItems=t,this._orderDataService.pushNewValue(this.salesOrderData),this.showToastAppliedPromo(this.selectedPromotion)}}applyDiscountReward(e){let i=this._posService.Data.AppConfigJSON.ModuleSell.ProductNotes.CopyPromotionName;if(this.salesOrderData.Order.Discount=e.Discount1,this.salesOrderData.Order.Discount2=e.Discount2,this.salesOrderData.Order.Discount>100&&(this.salesOrderData.Order.Discount=100),i==!0&&(this.salesOrderData.Order.Note=e.Name),f.IsNotEmpty(e.TaxTypeID)){let o=this.taxes.find(r=>r.ID==e.TaxTypeID);this._invoiceCalculatorService.tax=o,this.salesOrderData.Order.TaxTypeID=e.TaxTypeID}this._orderDataService.pushNewValue(this.salesOrderData),this.pushNewValue(this.Data),this.showToastAppliedPromo(this.selectedPromotion)}applyTierReward(e){let t=this.salesOrderData.CartItems,i=[];e.ListVariant.length>0?i=t.filter(o=>e.ListVariant.findIndex(r=>r.ID==o.VariantID)!==-1):i=t.filter(o=>e.ListCategory.findIndex(r=>r.ID==o.Variant.CategoryID)!==-1),i.length==0?t=this.tierPromotionBlankRequirement(e):t=this.tierPromotionWithRequirement(e,i),this.salesOrderData.CartItems=t,this._orderDataService.pushNewValue(this.salesOrderData)}tierPromotionBlankRequirement(e){let t=this.salesOrderData.CartItems,i=this.salesOrderData.TotalQuantity;return e.PromotionTieredQuantity.sort((o,r)=>o.Quantity-r.Quantity).forEach(o=>{i>=o.Quantity&&(t=t.map(r=>(r.Discount=o.Discount,r=this.copyPromotionNameToItem(e,r),r)))}),t}tierPromotionWithRequirement(e,t){let i=0,o=this.salesOrderData.CartItems;t.forEach(c=>{i+=c.Quantity}),e.PromotionTieredQuantity.sort((c,u)=>c.Quantity-u.Quantity).forEach(c=>{i>=c.Quantity&&(t=t.map(u=>(u.Discount=c.Discount,u)))});let r;return o=o.map(c=>(r=t.find(u=>u==c),r&&(c=r,c=this.copyPromotionNameToItem(e,c)),c)),o}copyPromotionNameToItem(e,t){return this._posService.Data.AppConfigJSON.ModuleSell.ProductNotes.CopyPromotionName==!0&&(t.Note=e.Name),t}removePromotion(){this._orderDataService.pushNewValue(this.orderDataBeforePromotion),this.showToastRemovePromo(this.selectedPromotion),this.selectedPromotion=null}showToastAppliedPromo(e){this._toastr.success("Applied "+e.Name+" to order!","Applied successfully!")}showToastRemovePromo(e){this._toastr.info("Removed "+e.Name+" from order!","Removed successfully!")}applyQuantityPromotion(){if(this.selectedPromotion){let e=this.salesOrderData.getRewards();switch(this.selectedPromotion.TypeID){case 2:this.selectedPromotion.MultipleApply?this.calculateQtyMultiplyPromotion([this.selectedPromotion],e):(e.length==0&&this.applyQuantityReward(this.selectedPromotion,1),this.checkSelectedPromotionRequirement(2));break;case 5:this.applyTierReward(this.selectedPromotion),this.checkSelectedPromotionRequirement(5);break}}}calculateQtyMultiplyPromotion(e,t){let i=de(xe,this.salesOrderData.CartItems),o,r=[],c=0,u;e.forEach(D=>{r=i.filter(F=>(D.RequirementTypeID==0?o=D.ListVariant.findIndex(W=>W.ID==F.VariantID):o=D.ListCategory.findIndex(W=>W.ID==F.Variant.CategoryID),o!==-1)),u=t.filter(F=>F.PromotionID==D.ID),c=this.calculateQtyMultiply(r,D.MinimumAmount),this.showModalSelectReward(u,c,D)})}showModalSelectReward(e,t,i){let o=0;if(e.forEach(r=>o+=r.Quantity),t>o){let r=t-o;this.applyQuantityReward(i,r)}else if(t<o){this.selectedPromotion.Eligible=!1;let r=this.mappingEligiblePromotion([this.selectedPromotion]);this.pushNewValue(r),this.checkSelectedPromotionRequirement(2)}}applyQuantityReward(e,t){t>0&&this.getRewards$(e).subscribe(i=>{this._dialog.open(Qi,{data:{promotion:e,rewardQuantity:t,rewards:i.rewards}})})}calculateQtyMultiply(e,t){if(e.length>0){let o=e.filter(r=>r.PromotionGift==!1).map(r=>r.Quantity).reduce((r,c)=>r+c)/t;return this.getFirstNumber(o)}else return 0}getFirstNumber(e){let t=e.toString().split(".");return Number(t[0])}getRewards$(e){return this._httpService.get(U.GetRewardByPromotionID,[{key:"ID",value:e.ID}]).pipe(J(t=>({rewards:t.Rewards,promotion:e})))}static \u0275fac=function(t){return new(t||n)(g(B),g(re),g(ae),g(we),g(ge),g(z),g(L),g(rt),g(q))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Ui=class{RegisterID;Number;Amount;TransactionID};var Vt=class{GroupID;Method;Data};var Wi=class{Status;InvoiceID;LoyaltyPoint;diff};var Gi=class{GopayQr};var qi=class{Name;Quantity;Discount;DiscountAmount;Price;UnitQuantity};var $i=class{Items;AmountSummary;GopayQr;Number;Customer;SalesName;CurrencySymbol;FinalAmount};var Ji=class n{_state=R(this.initCustomerDisplayState());isEnabled=se(()=>this._state()?.enabled);connect(){let t={enabled:!0,timestamp:new Date().toDateString()};localStorage.setItem("customerDisplay",JSON.stringify(t)),this._state.set(t)}initCustomerDisplayState(){let e=localStorage.getItem("customerDisplay"),t={enabled:!1,timestamp:""};return f.IsNotEmpty(e)&&(t=JSON.parse(e)),t}disconnect(){let t={enabled:!1,timestamp:new Date().toDateString()};localStorage.setItem("customerDisplay",JSON.stringify(t)),this._state.set(t)}static \u0275fac=function(t){return new(t||n)};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var _e=class{Amount;CurrencySymbol;Label;Type;constructor(e,t,i,o){this.Amount=e,this.CurrencySymbol=t,this.Label=i,this.Type=o}};var zi=class n{constructor(e,t,i,o){this._invoiceCalculatorService=e;this._decimalPipe=t;this._poshttpResponseService=i;this._orderService=o;this._poshttpResponseService.Data$.pipe(ee()).subscribe(r=>{this.appConfig=r.AppConfigJSON})}appConfig=new st;generateAmountSummary(){let e=[];this.isUseTax()?e=this.generateSummaryTax():e=this.generateSummaryNonTax();let t=this.generateSurchargeSummary();return t&&e.push(...t),e}generateSummaryTax(){let e=this._invoiceCalculatorService.tax?.CalculationTypeID,t=[];return e==1?t=this.generateSummaryTaxInclude():t=this.generateSummaryTaxExclude(),t}generateSummaryNonTax(){let e=[],t=this.generateCartItemAmount();if(e.push(t),this.isDiscounted()){let i=this.generateDiscountSummary(),o=this.generateAmountTotal("Total");e.push(...i,o)}return e}generateSummaryTaxInclude(){let e=[];return this.isTaxReserveSequence()?e=this.generateTaxIncludeReserveSequence():e=this.generateTaxIncludeNormalSequence(),e}generateTaxIncludeReserveSequence(){let e=[];if(this.isTaxDetailVisible()==!1){let r=this._invoiceCalculatorService.TotalBeforeTax,c=this.isDiscounted()?"Amount":"Before Tax",u=this.isDiscounted()?this._invoiceCalculatorService.GrossTotal:r,D=new _e(u,this.currencySymbol,c,2);e.push(D)}if(this.isDiscounted()){let r=this.generateDiscountSummary(),c=this.generateBeforeTaxSummary();e.push(...r,c)}let i=this.generateTax(),o=this.generateAmountTotal();return e.push(...i,o),e}generateTaxIncludeNormalSequence(){let e=[],t=this.generateCartItemAmount();if(e.push(t),this.isDiscounted()){let o=this.generateDiscountSummary(),r=this.generateSummarySubTotal();e.push(...o,r)}let i=this.generateTax();if(e.push(...i),this.isTaxDetailVisible()==!1){let o=this.generateBeforeTaxSummary();e.push(o)}return e}generateSummaryTaxExclude(){let e=[],t=this.generateCartItemAmount(!0);if(e.push(t),this.isDiscounted()){let c=this.generateDiscountSummary(),u=this.generateSummarySubTotal();e.push(...c,u)}let i=this.generateTax(),o=this._invoiceCalculatorService.TotalAfterTax,r=new _e(o,this.currencySymbol,"Total",1);return e.push(...i,r),e}generateAmountTotal(e="Total Amount"){let t=this._invoiceCalculatorService.Data;return new _e(t,this.currencySymbol,e,1)}generateSummarySubTotal(){let e=this._invoiceCalculatorService.TotalAfterTax;return new _e(e,this.currencySymbol,"SubTotal",1)}generateBeforeTaxSummary(){let e=this._invoiceCalculatorService.TotalBeforeTax;return new _e(e,this.currencySymbol,"Before Tax",2)}isTaxDetailVisible(){return this.appConfig.PrintConfigInvoice?.Footer?.TaxDetailVisible}isUseTax(){let e=this._invoiceCalculatorService.tax;return e?.PrintVisible&&e?.Rate!=0}generateTax(){let e=[],t=this.isTaxDetailVisible(),i=t?2:1,o=this._invoiceCalculatorService.tax;if(t){let r=this.appConfig.PrintConfigInvoice.Footer.TaxableSales,c=this.calculateTaxableSales(),u=new _e(c,this.currencySymbol,r,i);e.push(u)}if(o.TypeID==2){let r=this.generateTaxTypeMultiple();e.push(...r)}else{let r=this.generateSingleTaxSummary(o.Label,this._invoiceCalculatorService.TaxAmount,i);e.push(r)}if(t){let r=this.appConfig.PrintConfigInvoice.Footer.TaxExemptSales,c=this._invoiceCalculatorService.GrossTotalNonTaxable,u=new _e(c,this.currencySymbol,r,i);e.push(u);let D=this.appConfig.PrintConfigInvoice.Footer.LabelWithZeroAmount;if(D){let F=new _e(0,this.currencySymbol,D,i);e.push(F)}}return e}generateCartItemAmount(e=!1){let t=this.isDiscounted()||e?this._invoiceCalculatorService.GrossTotal:this._invoiceCalculatorService.TotalAfterTax;return new _e(t,this.currencySymbol,"Amount",1)}get currencySymbol(){return this._invoiceCalculatorService.currencySymbol}generateDiscountSummary(){let e=[];if(this._invoiceCalculatorService.Discount1Amount!=0){let t=this._decimalPipe.transform(this._orderService.Data.Order.Discount),o=this.checkDiscountIgnoreDecimal(t)?"{0}":"{0} ({1}%)";e.push(new _e(this._invoiceCalculatorService.Discount1Amount*-1,this._invoiceCalculatorService.currencySymbol,f.StringFormat(o,this.appConfig.CorePrint.Alias.Discount1,t),1))}if(this._invoiceCalculatorService.Discount2Amount!=0){let t=this._decimalPipe.transform(this._orderService.Data.Order.Discount2),o=this.checkDiscountIgnoreDecimal(t)?"{0}":"{0} ({1}%)";e.push(new _e(this._invoiceCalculatorService.Discount2Amount*-1,this._invoiceCalculatorService.currencySymbol,f.StringFormat(o,this.appConfig.CorePrint.Alias.Discount2,t),1))}return this._orderService.Data.Order.DiscountAmount!=0&&this.appConfig.PrintConfigInvoice.ItemsFooter.DiscountAmountVisible&&e.push(new _e(this._orderService.Data.Order.DiscountAmount*-1,this._invoiceCalculatorService.currencySymbol,"Discount ("+this._invoiceCalculatorService.currencySymbol+")",1)),e}calculateTaxableSales(){let e=this._invoiceCalculatorService.tax,t=this._invoiceCalculatorService.TaxAmount,i=this._invoiceCalculatorService.GrossTotalTaxable;return e.Rate==0?0:e.CalculationTypeID==1?i-t:i}generateTaxTypeMultiple(){let e=this.appConfig.PrintConfigInvoice.Footer.TaxDetailVisible?2:1,t=[],i=this._invoiceCalculatorService.tax;var o=this._invoiceCalculatorService.TaxAmount;if(i.TypeID==2){let r=i?.Components?i?.Components:[],c=this._invoiceCalculatorService.GrossTotalTaxable,u=this.calculateTotalRate(r);r.forEach(D=>{if(i.CalculationTypeID==0){let F=D.Rate/100*c;t=[...t,this.generateSingleTaxSummary(D.Label,F,e)],i.MultipleTaxTypeID==1&&(c+=F)}else{let F=D.Rate/u*o;t=[...t,this.generateSingleTaxSummary(D.Label,F,e)]}})}else t=[...t,this.generateSingleTaxSummary(i.Label,o,e)];return t}calculateTotalRate(e){let t=0;return e&&e.length>0&&(t=e.map(i=>i.Rate).reduce((i,o)=>i+o)),t}generateSingleTaxSummary(e,t,i){let o=this._invoiceCalculatorService.currencySymbol;return new _e(t,o,e,i)}generateSurchargeSummary(){if(this._invoiceCalculatorService.SurchargeAmount==0)return;let e=[],t=this.appConfig.CorePrint,i=t&&t.Alias.SurchargePcg?t.Alias.SurchargePcg:"Surcharge";e.push(new _e(this._invoiceCalculatorService.SurchargeAmount,this._invoiceCalculatorService.currencySymbol,f.StringFormat("{0} ({1}%)",i,this._decimalPipe.transform(this._orderService.Data?.Invoice.SurchargePcg)),1));let o=this.generateAmountTotal();return e.push(o),e}checkDiscountIgnoreDecimal(e){let i=this.appConfig.PrintConfigInvoice.Footer.DiscountIgnoredDecimal,o=parseFloat(e)%1,r=!1;return o!==0&&i&&(r=!0),r}isDiscounted(){let e=this._invoiceCalculatorService.Discount1Amount,t=this._invoiceCalculatorService.Discount2Amount,i=this._orderService.Data.Order.DiscountAmount,o=!1;return(e!=0||t!=0||i!=0)&&(o=!0),o}isTaxReserveSequence(){let e=this._invoiceCalculatorService.tax,t=!!e,i=t?e.CalculationTypeID:null,o=this.appConfig.PrintConfigInvoice.ItemsFooter.TaxIncludeBeforeTotalAmount;return t&&i===1&&o}static \u0275fac=function(t){return new(t||n)(g(ae),g(q),g(z),g(B))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var lt=class n{constructor(e,t,i,o){this._receiptCalculatorService=e;this._cashierCalculatorService=t;this._signal=i;this._customerHttpService=o;this.broadcastOrderUpdate$.subscribe()}_salesOrderDataModelService=T(B);_outletService=T(re);displayService=T(Ji);localdata=T(Oe);orderDataModel;broadcastOrderUpdate$=$e([this._salesOrderDataModelService.Data$,this.localdata.isStoreOrderInServer(),so(this.displayService.isEnabled)]).pipe(kn(([e,t,i])=>{let o=this._outletService?.Data?.RegisterID;if(t&&i&&o){this.orderDataModel=e;let r=this.ConstructCartModelForCustomerDisplay(),c=new Vt;return c.GroupID=o+"_Subscriber",c.Method="POSCartAmountUpdated",c.Data=r,this._signal.broadcast(c).pipe(nt(u=>(console.log(u),gt)))}else return gt}),nt(e=>(console.log(e),gt)),ee());ConstructCartModelForCustomerDisplay(){let e=this._customerHttpService.Data,t=new $i;t.Number=this.orderDataModel.Order.Number,t.Items=Array();for(let i of this.orderDataModel.CartItems){let o=new qi;o.Name=i.Variant.Name,o.Discount=i.Discount,o.DiscountAmount=i.DiscountAmount,o.Price=i.Price,o.Quantity=i.Quantity,o.UnitQuantity=i.UnitQuantity,t.Items.push(o)}return f.IsNotEmpty(this.orderDataModel.Order.SalesID)?t.SalesName=this._outletService.getSalesname(this.orderDataModel.Order.SalesID):t.SalesName="",f.IsNotEmpty(this.orderDataModel.Order.CustomerID)&&f.IsNotEmpty(e)&&(t.Customer=new Mt,t.Customer.Email=e.Email,t.Customer.Mobile=e.Mobile,t.Customer.Name=this.orderDataModel.ContactName),t.CurrencySymbol=this._cashierCalculatorService.currencySymbol,t.FinalAmount=this._cashierCalculatorService.Data,t.AmountSummary=this._receiptCalculatorService.generateAmountSummary(),t}BroadcastStateToCustomerDisplay(e,t="",i="",o=0){let r=new Wi;r.Status=e,r.InvoiceID=t,r.LoyaltyPoint=i,r.diff=o;let c=new Vt;return c.GroupID=this._outletService.Data.RegisterID+"_Subscriber",c.Method="POSStateUpdated",c.Data=r,this.displayService.isEnabled()?this.localdata.isStoreOrderInServer().pipe(Y(u=>u?this._signal.broadcast(c):ke(oe.offlineMode))):gt}BroadcastQRToCustomerDisplay(e){let t=new Gi;t.GopayQr=e;let i=new Vt;return i.GroupID=this._outletService.Data.RegisterID+"_Subscriber",i.Method="POSQRPaymentActivated",i.Data=t,this.displayService.isEnabled()?this.localdata.isStoreOrderInServer().pipe(Y(o=>o?this._signal.broadcast(i):ke(oe.offlineMode))):gt}static \u0275fac=function(t){return new(t||n)(g(zi),g(ae),g(rt),g(Re))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Yi=class n{constructor(e){this.httpService=e}VerifyPayment(e,t){let i=this.getVerifyPaymentUrl(t);return this.httpService.post(i,e)}getVerifyPaymentUrl(e){let t;switch(e){case 0:t=U.GopayVerifyPayment;break;case 1:t=U.BcaVerifyPayment;break}return t}generateLink(e){return this.httpService.post(U.GenerateLink,e)}generateQRCode(e,t){return this.httpService.post(e,t)}static \u0275fac=function(t){return new(t||n)(g(ge))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Ft=class n{constructor(e,t,i,o,r){this._posHubService=e;this._orderDataService=t;this._PaymentHttpService=i;this._InvoicecashierCalculatorService=o;this._toastrService=r}transactionId;qrPaymentMethodID;QRCodeHttpResponse;_paymentMethod;get paymentMethod(){return this._paymentMethod}resetPaymentMethod(){this._paymentMethod=null}onQRPaymentComplete(e,t){return new Promise((i,o)=>{if(e.transaction_id!==this.transactionId){let c=`transaction_id: ${e.transaction_id} / gross_amount: ${e.gross_amount}`;o({header:"Invalid QR Payment",message:c});return}if(e.gross_amount!==this._InvoicecashierCalculatorService.Data){let c=`paid_amount: ${e.gross_amount} vs invoice_amount: ${this._InvoicecashierCalculatorService.Data}`;o({header:"Invalid QR Payment",message:c});return}let r=this._orderDataService.Data.Order.Number;if(e.order_id.includes(r)==!1){let c=`Order ID: ${e.order_id} vs Order Number: ${r}`;o({header:"Invalid QR Payment",message:c});return}if(e.transaction_status!=="settlement"){let c=`Transaction status is ${e.transaction_status}`;o({header:"Invalid QR Payment",message:c});return}this.validateEMoneyPayment(t).subscribe(c=>{i(c)})})}generateNewPayment(e,t){let i=this._orderDataService.Data;f.IsEmpty(this.qrPaymentMethodID)&&alert("QR PaymentMethod.ID is not available!");let o=new Ke;return o.PaidAmount=t,o.Amount=t,o.Date=i.Order.Date,o.MethodID=this.qrPaymentMethodID,o.Code=e,f.IsEmpty(e)&&this._toastrService.warning("Midtrans transaction_id is empty. Please verify manually!","Mobile Payment Failure"),o}sendStateCompleteToCustomerDisplay(e){this._posHubService.BroadcastStateToCustomerDisplay(1,e.ObjectID,e.LoyaltyPoint,0).subscribe()}generateQR(e,t){this._paymentMethod=t,this.qrPaymentMethodID=t.ID;let i=this.getServiceUrl(t.EMoneyTypeID);return this._PaymentHttpService.generateQRCode(i,e).pipe(J(c=>(c=this.manipulateBCAQrisImg(c,t.EMoneyTypeID),this.transactionId=c.Transaction_id,this.QRCodeHttpResponse=c,this._orderDataService.transaction_id=c.Transaction_id,this.sendQRToCustomerDisplay(c.Url),c)))}sendQRToCustomerDisplay(e){this._posHubService.BroadcastQRToCustomerDisplay(e).subscribe()}validateEMoneyPayment(e){if(f.IsNotEmpty(this.transactionId)){let t=this._InvoicecashierCalculatorService.Data,i=this._paymentMethod?.EMoneyTypeID,o=this.generatePaymentVerificationData(t,i);return this._PaymentHttpService.VerifyPayment(o,i).pipe(Y(r=>(this.updatePosDataForSubmission(t),An(this._orderDataService.submitOrder(e)).pipe(le(c=>{this.sendStateCompleteToCustomerDisplay(c)})))))}else{let t=new Error("Transaction ID is Empty");throw ft(()=>t)}}generatePaymentVerificationData(e,t){let i=this._orderDataService.Data,o=new Ui;return o.Number=i.Order.Number,o.Amount=e,o.TransactionID=this.transactionId,o.RegisterID=i.Order.RegisterID,t==1&&(o.Number=this.QRCodeHttpResponse.Number),o}updatePosDataForSubmission(e){let t=this._orderDataService.Data,i=this.generateNewPayment(this.transactionId,e),o=[];o.push(i),t.Invoice.Due=null,t.Action.Type=3,t.Order.InvoicedStateID=3,t.Payments=o,this._orderDataService.pushNewValue(t)}getServiceUrl(e){let t;switch(e){case 0:t=U.GenerateGopayQrCode;break;case 1:t=U.GenerateBcaQrCode;break}return t}manipulateBCAQrisImg(e,t){return t==1&&(e.Url=`data:image/png;base64, ${e.Url}`),e}clearTransactionID(){this.transactionId=null,this._orderDataService.transaction_id=null,this.QRCodeHttpResponse=null}getTransactionId(){return this.transactionId}static \u0275fac=function(t){return new(t||n)(g(lt),g(B),g(Yi),g(ae),g(L))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var je=class n{constructor(e,t,i,o,r,c,u,D,F,W,ye,_n,Rn,nr){this._orderDataService=e;this._posHttpResponseService=t;this._CoreHttpService=i;this._outletService=o;this._orderHttpService=r;this._signal=c;this._promotionEventService=u;this._promotionCouponService=D;this._customerHttpService=F;this._invoiceCalculatorService=W;this._dialog=ye;this._toastr=_n;this._paymentGatewayService=Rn;this.roleService=nr;this.subscribeObservableChanges(),this._signal.OnContactReceive.subscribe(yn=>{if(!f.IsEmpty(yn)){let bn=JSON.parse(yn);this._orderDataService.updateCustomerID(bn.ID).then(Nn=>{this.posData.ContactName=bn.Name,this._customerHttpService.Data=Nn,this.pushNewValue(this.Data)})}})}_Data=new be(new Rt);_clearOrder=new Me;get clearOrder$(){return this._clearOrder.asObservable()}get Data(){return this._Data.value}Data$=this._Data.asObservable();posData=new G;activeRegister=new Oo;subscribeObservableChanges(){this._orderDataService.Data$.pipe(ee()).subscribe(e=>{this.posData=e}),this._outletService.Data$.pipe(ce(e=>e?.RegisterID!==this.activeRegister?.RegisterID),ee()).subscribe(e=>{this.activeRegister=e,this.Data.posState!=2?this.createNewSalesOrderDataModel():this.setPrintTemplateToDefault(this.posData.Order.TypeID)})}pushNewValue(e){this._Data.next(e)}createNewTransactionInSameOutletRegister(e=!0){if(e){let t=this._orderDataService.Data.Order.EntityID;this._CoreHttpService.GenerateNumber(t,this.activeRegister).subscribe(i=>{this.activeRegister.NumberElement=i.OrderNumberElement,this.activeRegister.InvoiceNumberElement=i.InvoiceNumberElement,this.activeRegister.NewOrderID=i.NewOrderID,this.refreshLoader(),this.pushNewValue(new Rt),this.createNewSalesOrderDataModel()})}else this.pushNewValue(new Rt),this.createNewSalesOrderDataModel()}refreshLoader(){if(this._posHttpResponseService.Data.AppConfigJSON.ModuleShift?.Closure?.Enabled){let i=this._posHttpResponseService.Data.Registers.find(o=>o.ID==this.activeRegister?.RegisterID);i&&f.IsEmpty(i.LoginID)&&this._posHttpResponseService.requestObservable().subscribe()}}updatePosState(e,t){t&&this._orderHttpService.pushNewValue(t),this.Data.posState=e,this.pushNewValue(this.Data)}ReturnOrder(e){e&&(this.posData.CartItems=de(xe,e.CartItems),this.posData.CartItems=this.posData.CartItems.map(t=>(t.Quantity=t.Quantity*-1,t.Variant.TypeID==4&&(t.Serial=t.Serial.map(i=>(i.Quantity=i.Quantity*-1,i))),t)),this.posData.Invoice.ReferenceInvoiceID=e.Invoice.ID,this.posData.Order.Discount=e.Order.Discount,this.posData.Order.Discount2=e.Order.Discount2,this.posData.Order.DiscountAmount=e.Order.DiscountAmount*-1,this.posData.Order.TaxTypeID=e.Order.TaxTypeID,this.posData.Order.SalesID=e.Order.SalesID,this.posData.Order.CustomerID=e.Order.CustomerID,this.posData.ContactName=e.ContactName,this.posData.Order.PointUsed=e.Order.PointUsed*-1,this.initSelectedTax(),this._orderDataService.pushNewValue(this.posData))}plainToClass(e,t){if(this.posData=dt(G,e),this.assignInvoice(e),this.assignCustomerData(e),this.initSelectedRegister(e,t),this.assignParkTemporaryItem(e),this.assignOrderCurrency(this.posData.Order.CurrencyID),this.initPromotionGift(),t==4){this.posData.Order.Date=new Date;let i=this.getDeliveryEntityID(this.activeRegister);this.posData.Action.DeliveryEntityID=i.DeliveryEntityID,this.posData.Order.DeliveryStateID=i.DeliveryStateID,this.copySalesOrderNoteToInvoice()}this.initSelectedTax(),this._orderDataService.pushNewValue(this.posData),this._promotionCouponService.setCouponOnEdit(this.posData.Promotion)}copySalesOrderNoteToInvoice(){this._posHttpResponseService.Data.AppConfigJSON?.ApplicationParkAndRetrieve?.Advance?.CopyOrderNoteToInvoice&&(this.posData.Invoice.Note=this.posData.Order.Note)}initPromotionGift(){let e=this.posData.CartItems;e=e.map(t=>(t.PromotionGift=t.PriceTypeID==3,t))}initSelectedTax(){let e=this.posData.Order.TaxTypeID;this._invoiceCalculatorService.tax=this.getTaxObjectByID(e);let t=this._invoiceCalculatorService.tax;f.IsEmpty(t)&&this.showModalSuspendedDefaultTax()}assignInvoice(e){if(e.Invoice){let t=e.Invoice.Due,i=e.Invoice.Date,o=t!=f.MinDate&&f.IsNotEmpty(t)?new Date(e.Invoice.Due):null,r=i!=f.MinDate&&f.IsNotEmpty(i)?new Date(e.Invoice.Date):new Date;e.Invoice.Due=o,e.Invoice.Date=r,this.posData.Invoice=e.Invoice,this.posData.Action.Type=3}else{let t=this.activeRegister;this.posData.Invoice=new $t,f.IsNotEmpty(t.InvoiceNumberElement)&&(this.posData.Invoice.Number=Pn.Generate(t.InvoiceNumberElement))}}assignCustomerData(e){let t=e.Order.CustomerID,i=e.Order.EntityID;f.IsNotEmpty(t)&&f.IsNotEmpty(i)?ri(this._customerHttpService.GetPrivilegeByID(t,i)).then(o=>{let c=this._posHttpResponseService.Data.AppConfigJSON.ApplicationLoyalty.Label,u=o;u.Label=c,u.DebtCalculated=u.Debt,u=this.calculateCustomerDebt(e,u),this._customerHttpService.Data=u,this.pushNewValue(this.Data)}):this.Data.InputTextValue=null}calculateCustomerDebt(e,t){let i=e.Payments,o=f.IsNotEmpty(e.Invoice.ID);return i.length==0&&o&&(t.DebtCalculated=t.Debt-e.Invoice.Sales),t}initSelectedRegister(e,t){if(t!==4){let i=this._posHttpResponseService.Data.Registers;i.length>0?this.checkAccessOutletUser(e,i):this._toastr.warning("You do not have access to edit in this outlet","Warning")}else{let i=this.activeRegister.RegisterID;i!==e.Order.RegisterID&&(this.posData.Order.RegisterID=i,this._toastr.warning("You are processing order from different Register","Different Register"))}}checkAccessOutletUser(e,t){let i=e.Order.RegisterID,o=t.find(r=>r.ID==i);o?this._outletService.pushNewRegister(o):this._toastr.warning(`There is no Register with ID [${i}]`,"Warning")}assignParkTemporaryItem(e){this.Data.parkTemporaryItem=dt(xe,e.CartItems),this.pushNewValue(this.Data)}getDefaultOrderType(e){if(f.IsNotEmpty(e.DefaultSalesOrderTag))return e.DefaultSalesOrderTag;{let t=this._posHttpResponseService.Data.PoTypes;return t.length>0?t[0].ID:null}}createNewSalesOrderDataModel(){this._promotionEventService.selectedPromotion=null,this._paymentGatewayService.clearTransactionID(),this._invoiceCalculatorService.discountAfterTax=0,this._promotionCouponService.resetCouponOnNewTransaction(),this._customerHttpService.Data=new Mt;let e=this._posHttpResponseService.Data,t=this.activeRegister,i=new G;!f.IsEmpty(e.SalesID)&&t.ListSales!=null&&t.ListSales.find(c=>c.ID==e.SalesID)&&(i.Order.SalesID=e.SalesID),i.Action.NewOrderID=t.NewOrderID,f.IsNotEmpty(t.NumberElement)&&(i.Order.Number=Pn.Generate(t.NumberElement)),i.Order.CurrencyID=e.AppConfigJSON.CoreDefaults.CurrencyID,this.assignOrderCurrency(i.Order.CurrencyID),i=this.initDefaultTaxType(i),this._posHttpResponseService.Data.AppConfigJSON.ModuleSell.RememberOrderTypeFromPreviousTransaction?f.IsEmpty(this._orderHttpService.Data)?(i.Order.TypeID=this.getDefaultOrderType(t),this.setPrintTemplateToDefault(i.Order.TypeID)):i.Order.TypeID=this.posData.Order.TypeID:(i.Order.TypeID=this.getDefaultOrderType(t),this.setPrintTemplateToDefault(i.Order.TypeID)),f.IsNotEmpty(t.EntityID)&&(i.Order.EntityID=t.EntityID,i.Order.RegisterID=t.RegisterID),i.Order.CouponType=1;let o=this.getDeliveryEntityID(t);i.Action.DeliveryEntityID=o.DeliveryEntityID,i.Order.DeliveryStateID=o.DeliveryStateID,i.CartItems=this.getItemsFromLocalStorage(i.Order?.Number),this.Data.posState=0,this._orderDataService.pushNewValue(i)}getItemsFromLocalStorage(e){let t=localStorage.getItem("cart_items"),i=[];if(t){let o=this.roleService.Data?.DeleteItem,r=JSON.parse(t),c=e==r?.Number;o||!c?localStorage.removeItem("cart_items"):i=de(xe,r.CartItems)}return i}initDefaultTaxType(e){let t=this._posHttpResponseService.Data;if(f.IsNotEmpty(this.activeRegister.DefaultTaxType)){let i=this.getTaxObjectByID(this.activeRegister.DefaultTaxType);f.IsNotEmpty(i)?(e.Order.TaxTypeID=this.activeRegister.DefaultTaxType,this._invoiceCalculatorService.tax=i):(this.showModalSuspendedDefaultTax(),e.Order.TaxTypeID=t.Taxes[0].ID,this._invoiceCalculatorService.tax=t.Taxes[0])}else e.Order.TaxTypeID=t.Taxes[0].ID,this._invoiceCalculatorService.tax=t.Taxes[0];return e}assignOrderCurrency(e){let t=this.findCurrencyById(e);this._invoiceCalculatorService.currencySymbol=t?.Symbol,this.posData.Order.CurrencyRate=t?.ExchangeRate}setPrintTemplateToDefault(e){let i=(this._posHttpResponseService?.Data?.PoTypes).find(o=>o.ID==e);i?.PrintTemplateID==0?(this.activeRegister.PrintTemplate=this.activeRegister.DefaultPrintTemplate,this._outletService.pushNewValue(this.activeRegister)):this.activeRegister?.PrintTemplate?.ID!==i?.PrintTemplateID&&this._orderHttpService.getSalesOrderPrint(i?.PrintTemplateID).subscribe(o=>{this.activeRegister.PrintTemplate=o.Template,this._outletService.pushNewValue(this.activeRegister)})}findCurrencyById(e=1){return this._posHttpResponseService.Data.Currencies.find(o=>o.ID==e)}getTaxObjectByID(e){return this._posHttpResponseService.Data.Taxes.find(i=>i.ID==e)}getDeliveryEntityID(e){let t=this._posHttpResponseService.Data.AppConfigJSON,i={DeliveryStateID:3,DeliveryEntityID:f.GuidEmpty};if(t.ModuleSell.Shipping.DefaultOrderDelivery==0){let o=this._posHttpResponseService.Data.Entities.find(r=>r.ID==this._outletService.getOutletRegister().EntityID);f.IsNotEmpty(o.ID)&&o.FulfillmentOption==2&&(i.DeliveryEntityID=f.GuidEmpty,i.DeliveryStateID=0),f.IsEmpty(e.DefaultWarehouse)?i.DeliveryEntityID=e.EntityID:i.DeliveryEntityID=e.DefaultWarehouse}else i.DeliveryEntityID=f.GuidEmpty,i.DeliveryStateID=0;return i}reedemPointToDiscount(e=!1){let t=this._posHttpResponseService.Data.AppConfigJSON,i=t.ApplicationLoyalty.Rules.PrefferedPayment,o=t.ApplicationLoyalty.Enabled,r=this._customerHttpService.Data,c=this.Data.posState==2,u=r.Point?r.Point:0;if(i&&u>0&&o){if(f.IsNotEmpty(this.posData.Order.CustomerID)&&!c){let D=t.ApplicationLoyalty.LoyaltyPoint.RedeemPointValue,F=this._invoiceCalculatorService.GetCashAndPointAmountCart(),W=u*D,ye=u;W>F&&(W=F),W>0&&D>0?ye=Math.ceil(W/D):ye=0,r.PointUsed=ye,this.posData.Order.PointUsed=ye,this.posData.Order.DiscountAmount=W,this.resetCouponDiscountAmount()}else e&&(r.PointUsed=0,this.posData.Order.PointUsed=0,this.posData.Order.DiscountAmount=0);this._orderDataService.pushNewValue()}}resetCouponDiscountAmount(){let e=this._promotionCouponService.coupon;e&&(e.Requirement?.Type==2||e.Requirement?.Type==1&&e.Requirement?.MaximumDiscount>0&&!e.Requirement?.FullPriceProductOnly)&&(this._promotionCouponService.removeAppliedCoupon(),this._toastr.warning("Loyalty point is used, coupon will be cancelled","Coupon Cancelled"))}showModalSuspendedDefaultTax(){this._dialog.open(Do,{id:"ModalInfo",data:{title:"Default Tax Discontinued",message:`
|
|
6
6
|
<div class="d-flex justify-content-center my-4">
|
|
7
7
|
<img class="img-2x" src="https://cdn.dealpos.xyz/web-image/globalerror.svg"
|
|
8
8
|
alt="Empty Sales Order Tag" />
|
|
@@ -13,4 +13,4 @@ Do you want to end your session?`)&&(this.onClose(),this.router.navigate(["menu/
|
|
|
13
13
|
<p class="text-center">
|
|
14
14
|
Please change the default tax or re-activate the tax <a href="/menu/Setup/Payment/Tax">here</a>.
|
|
15
15
|
</p>
|
|
16
|
-
`,headerType:de.Error},width:"31rem"})}emitClearOrder(){this._clearOrder.next(!0)}static \u0275fac=function(t){return new(t||n)(g(L),g(z),g(Et),g(re),g(It),g(rt),g(Ae),g(Rt),g(Re),g(se),g(we),g(F),g(Lt),g(De))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Bi=class n{httpService=T(ge);salesOrderService=T(L);orderProcessorService=T(je);promotionCouponFactoryService=T(wt);toastr=T(F);decimalPipe=T(q);couponCode;couponNote;_couponProvider;get couponProvider(){return this._couponProvider}_coupon;get coupon(){return this._coupon}countToastrNotification=0;constructor(){this.orderProcessorService.Data$.pipe(ee()).subscribe(e=>{e.posState==1&&(this._coupon=null,this._couponProvider=null)})}redeemCoupon(e,t,i){let o=this.promotionCouponFactoryService.generateRedeemCouponDto(e,t);this.httpService.post(U.validateExternalCoupon,o).subscribe({next:r=>{this.couponCode=e,this.couponNote=i,this._coupon=r,this._couponProvider=t,this.applyCoupon(r)},error:r=>{this.removeCoupon()}})}applyCoupon(e){let t=e.ApplyToProduct,i=e.Amount;t?.length>0&&i>0?(this.applyCouponToCartItems(e),this.applyCouponToOrder(e)):t?.length>0?this.applyCouponToCartItems(e):this.applyCouponToOrder(e)}applyCouponToOrder(e){let t=this.salesOrderService.Data;e.Type=="Percentage"?t.Order.Discount=e.Amount:t.Order.DiscountAmount=e.Amount,this.showToastrAppliedCoupon(e,"Order"),this.updateSalesOrder(t)}applyCouponToCartItems(e){let t=this.salesOrderService.Data,i=e.ApplyToProduct;if(!this.validateItemsForCoupon(e))return;let o=t.CartItems.map(r=>{let c=i.findIndex(u=>u.Code===r.Variant?.Code);return c!=-1&&(e.Type==="Percentage"?(r.Discount=i[c]?.Amount,r.CouponDiscount=i[c]?.Amount):(r.DiscountAmount=i[c]?.Amount,r.CouponDiscount=i[c]?.Amount)),r});t.CartItems=o,this.showToastrAppliedCoupon(e,"Product"),this.updateSalesOrder(t)}validateItemsForCoupon(e){let t=this.salesOrderService.Data,i=e.ApplyToProduct,o=0;t.CartItems.forEach(c=>{i.findIndex(O=>O.Code===c.Variant?.Code)!=-1&&o++});let r=!0;return o===0&&(this.toastr.error("No products in the cart qualify for coupon use.","Coupon Not Applicable"),this.updateSalesOrder(t,!0),r=!1),r}showToastrAppliedCoupon(e,t){if(f.IsNotEmpty(e.Notification))this.countToastrNotification==0&&this.toastr.success(e.Notification,"Coupon Applied"),this.countToastrNotification+=1;else if(t=="Product")this.toastr.success("Coupon applied to products","Coupon Applied");else if(e.Type==="Percentage")this.toastr.success(`${e.Amount}% Discount`,"Coupon Applied");else{let i=this.decimalPipe.transform(e.Amount,"1.0-2");this.toastr.success(`${i} Discount`,"Coupon Applied")}}removeCoupon(){let e=this._coupon.ApplyToProduct,t=this._coupon.Amount;this._couponProvider=null;let i=this.salesOrderService.Data;e?.length>0&&t>0?(i=this.removeCouponFromCartItems(),i=this.removeCouponFromOrder()):e?.length>0?i=this.removeCouponFromCartItems():i=this.removeCouponFromOrder(),this.updateSalesOrder(i,!0),this._coupon=null}removeCouponFromOrder(){let e=this.salesOrderService.Data;return this._coupon.Type=="Percentage"?e.Order.Discount=0:e.Order.DiscountAmount=0,e}removeCouponFromCartItems(){let e=this.salesOrderService.Data,t=this._coupon.ApplyToProduct,i=e.CartItems.map(o=>(t.findIndex(c=>c.Code===o.Variant?.Code)!=-1&&(o.Discount=0,o.CouponDiscount=0,o.DiscountAmount=0),o));return e.CartItems=i,e}updateSalesOrder(e,t=!1){e.Order.PromotionCoupon=t?null:this.couponCode,e.Order.PromotionNote=t?null:this.couponNote,e.Order.CouponProvider=t?null:this.couponProvider,e.Order.CouponType=t?1:2,this.salesOrderService.pushNewValue(e),this.couponCode=t?null:this.couponCode,this.couponNote=t?null:this.couponNote,this._coupon=t?null:this._coupon,this._couponProvider=t?null:this._couponProvider,this.countToastrNotification=t?0:this.countToastrNotification}static \u0275fac=function(t){return new(t||n)};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};function Br(n,e){if(n&1&&b(0,"img",6),n&2){let t=m(2);p("src",t.printTemplate.Logo,dt)}}function Hr(n,e){if(n&1&&(a(0,"span"),d(1),s()),n&2){let t=m(3);l(),D("(",t.data.Contact.MemberIdentification,")")}}function jr(n,e){if(n&1&&(a(0,"div",12)(1,"h3")(2,"span"),d(3),s()(),a(4,"div",37)(5,"strong"),d(6),s(),h(7,Hr,2,1,"span"),a(8,"div",38)(9,"div")(10,"span"),d(11),s()(),a(12,"div")(13,"span"),d(14),s()(),a(15,"div"),b(16,"span",10),s(),a(17,"div")(18,"span"),d(19),s()()()()()),n&2){let t=m(2);l(3),M(t.appConfigJson.PrintConfigInvoice.DocumentLabel.Customer),l(3),M(t.data.ContactDisplay),l(),C(t.data.Contact.MemberIdentification?7:-1),l(4),M(t.data.Contact.Email),l(3),M(t.data.Contact.Phone?t.data.Contact.Phone:t.data.Contact.Mobile),l(2),p("innerHTML",t.data.Contact.Address,Je),l(3),M(t.data.City)}}function Qr(n,e){if(n&1&&(a(0,"span"),d(1),s()),n&2){let t=m(3);l(),D(", ",t.data.Shipping.Phone)}}function Ur(n,e){if(n&1&&(a(0,"div",14)(1,"h3"),d(2),s(),a(3,"div",37)(4,"div"),d(5),h(6,Qr,2,1,"span"),s(),b(7,"div",10),a(8,"div"),d(9),s()()()),n&2){let t=m(2);l(2),D(" ",t.appConfigJson.PrintConfigInvoice.DocumentLabel.ShippingAddress," "),l(3),D(" ",t.data.Shipping.Name),l(),C(t.data.Shipping.Phone?6:-1),l(),p("innerHTML",t.data.Shipping.Street,Je),l(2),D(" ",t.data.Shipping.City," ")}}function Wr(n,e){if(n&1&&b(0,"i",39),n&2){let t=m().$implicit;p("innerHTML",t.Note,Je)}}function Gr(n,e){if(n&1&&(a(0,"div"),d(1),s()),n&2){let t=m().$implicit;l(),D("-",t.Discount,"%")}}function qr(n,e){if(n&1&&(a(0,"div"),d(1),s()),n&2){let t=m().$implicit;l(),D(" -",t.DiscountAmount," ")}}function $r(n,e){if(n&1&&(a(0,"tr")(1,"td",11),d(2),s(),a(3,"td"),d(4),a(5,"div"),h(6,Wr,1,1,"i",39),s()(),a(7,"td"),d(8),s(),a(9,"td",11),d(10),y(11,"number"),s(),a(12,"td"),d(13),s(),a(14,"td",11),d(15),y(16,"number"),s(),a(17,"td",40),h(18,Gr,2,1,"div"),h(19,qr,2,1,"div"),s(),a(20,"td",11),d(21),y(22,"TrailingZero"),s()()),n&2){let t=e.$implicit,i=e.$index,o=m(2);l(2),D("",i+1,"."),l(2),D(" ",t.Name," "),l(2),C(t.Note!=null?6:-1),l(2),M(t.Code),l(2),M(x(11,10,t.Quantity)),l(3),M(t.UOMName),l(2),M(x(16,12,t.UnitPrice)),l(3),C(t.Discount!=0?18:-1),l(),C(t.DiscountAmount!=0?19:-1),l(2),D(" ",X(22,14,t.Total,o.appConfigJson.PrintConfigGeneral.TrailingZero)," ")}}function Jr(n,e){if(n&1&&(a(0,"span"),d(1),y(2,"sum"),s()),n&2){let t=m().$index,i=m(2);l(),D(" ",t==0&&(i.data==null?null:i.data.Items.length)>1?"Qty: "+X(2,1,i.data.Items,"Quantity"):"")}}function zr(n,e){if(n&1&&(a(0,"tr")(1,"th",41),h(2,Jr,3,4,"span"),d(3),s(),a(4,"th"),d(5,":"),s(),a(6,"th",42),d(7),s(),a(8,"th",43),d(9),y(10,"TrailingZero"),s()()),n&2){let t=e.$implicit,i=e.$index,o=m(2);l(2),C(o.appConfigJson.PrintConfigInvoice.ItemsFooter.TotalQuantityVisible?2:-1),l(),D(" ",(o.data==null?null:o.data.Payments.length)>1&&i==(o.data==null?null:o.data.AmountSummary.length)-2?"Payment":t.Label," "),l(4),M(t.CurrencySymbol),l(2),D(" ",X(10,4,t.Amount,o.appConfigJson.PrintConfigGeneral.TrailingZero)," ")}}function Yr(n,e){if(n&1&&(a(0,"tr")(1,"th"),d(2),s(),a(3,"td"),d(4,":"),s(),a(5,"td",42),d(6),s(),a(7,"td",22),d(8),y(9,"TrailingZero"),s()()),n&2){let t=e.$implicit,i=m(2);l(2),M(t.Label),l(4),M(t.CurrencySymbol),l(2),D(" ",X(9,3,t.Amount,i.appConfigJson.PrintConfigGeneral.TrailingZero)," ")}}function Kr(n,e){if(n&1&&(a(0,"span")(1,"span",44),d(2),y(3,"date"),s(),d(4),y(5,"number"),b(6,"br"),s()),n&2){let t=e.$implicit,i=m(3);l(),p("hidden",i.data.Payments),l(),M(X(3,5,t.Date,"dd MMM yy")),l(2),Hn(" ",t.MethodName," ",t.Note?t.Note:""," ",x(5,8,t.Amount)," ")}}function Zr(n,e){if(n&1&&(a(0,"tr"),b(1,"th",10),a(2,"td"),d(3,":"),s(),a(4,"td"),K(5,Kr,7,10,"span",null,ve),s()()),n&2){let t=m(2);l(),p("innerHTML",t.data.Invoice.PaymentStateID==2?"Down Payment":"Payment",Je),l(4),Z(t.data.Payments)}}function Xr(n,e){if(n&1&&(a(0,"tr")(1,"th"),d(2,"Delivery"),s(),a(3,"td"),d(4,":"),s(),a(5,"td")(6,"ul",45)(7,"li"),d(8),s()()()()),n&2){let t=m(2);l(8),D(" ",t.data.CustomerTransaction==null?null:t.data.CustomerTransaction.SO.DeliveryStateString," ")}}function ea(n,e){if(n&1&&(a(0,"tr")(1,"th",46),d(2,"Remaining"),s(),a(3,"td"),d(4,":"),s(),b(5,"td",47),y(6,"sum"),y(7,"number"),s()),n&2){let t=m(2);l(5),p("innerHtml",x(7,4,(t.data==null?null:t.data.FinalAmount)-X(6,1,t.data==null?null:t.data.Payments,"Amount")),Je)}}function ta(n,e){if(n&1&&(a(0,"tr")(1,"th"),d(2,"Note"),s(),a(3,"td"),d(4,":"),s(),a(5,"td")(6,"ul",45)(7,"li"),d(8),s()()()()),n&2){let t=m(2);l(8),D(" ",t.data.Invoice==null?null:t.data.Invoice.Note," ")}}function ia(n,e){if(n&1&&(a(0,"div",31)(1,"h5"),d(2),s(),a(3,"div",30),d(4,"\xA0"),s()()),n&2){let t=m(2);l(2),D(" ",t.appConfigJson.PrintConfigInvoice==null?null:t.appConfigJson.PrintConfigInvoice.FooterLabel.ApprovedBy," ")}}function na(n,e){if(n&1&&(a(0,"div",32)(1,"h5"),d(2),s(),a(3,"div",30),d(4,"\xA0"),s()()),n&2){let t=m(2);l(2),D(" ",t.appConfigJson.PrintConfigDelivery==null?null:t.appConfigJson.PrintConfigDelivery.FooterLabel.DeliveredBy," ")}}function oa(n,e){if(n&1&&b(0,"div",36),n&2){let t=m(2);p("innerHTML",t.printTemplate.FooterRight,Je)}}function ra(n,e){if(n&1&&(a(0,"div"),b(1,"link",0),y(2,"StylesheetSafeUrl"),a(3,"div",1)(4,"div",2)(5,"div",3)(6,"div",4)(7,"div",5),h(8,Br,1,1,"img",6),a(9,"div",7)(10,"h2"),d(11),s(),a(12,"small"),d(13),s(),a(14,"div",8)(15,"div",9),b(16,"span",10),y(17,"newlines"),s(),a(18,"div",11),b(19,"span",10),y(20,"newlines"),s()()()(),h(21,jr,20,7,"div",12),s(),a(22,"div",13)(23,"h1")(24,"strong"),d(25),s(),a(26,"span"),d(27),s()(),a(28,"div")(29,"table")(30,"thead")(31,"tr")(32,"th"),d(33,"Date"),s()()(),a(34,"tbody")(35,"tr")(36,"td"),d(37),y(38,"date"),s()()()()(),h(39,Ur,10,5,"div",14),s()()(),a(40,"section",15)(41,"div",16)(42,"table",17)(43,"thead",18)(44,"tr")(45,"th",19),d(46,"No"),s(),a(47,"th"),d(48,"Name"),s(),a(49,"th",20),d(50,"Code"),s(),a(51,"th",21),d(52,"Qty"),s(),a(53,"th",22),d(54,"UOM"),s(),a(55,"th",23),d(56),s(),a(57,"th",24),d(58,"Disc"),s(),a(59,"th",23),d(60),s()()(),a(61,"tbody"),K(62,$r,23,17,"tr",null,ve),s()(),a(64,"div",25)(65,"table",26)(66,"tbody"),K(67,zr,11,7,"tr",null,ve),s(),a(69,"tbody"),K(70,Yr,10,6,"tr",null,ve),s()()()()(),a(72,"table",27),h(73,Zr,7,1,"tr"),h(74,Xr,9,1,"tr"),h(75,ea,8,6,"tr"),h(76,ta,9,1,"tr"),s(),a(77,"div")(78,"div")(79,"div",28)(80,"div",29)(81,"h5"),d(82),s(),a(83,"div",30),d(84,"\xA0"),s()(),h(85,ia,5,1,"div",31),h(86,na,5,1,"div",32),a(87,"div",33)(88,"h5"),d(89),s(),a(90,"div",30),d(91),s()()()()(),a(92,"div",34),b(93,"div",35),h(94,oa,1,1,"div",36),s()()()),n&2){let t=m();l(),mi("href",t.stylesheet!=null&&t.stylesheet.SizeA4?x(2,25,t.stylesheet==null?null:t.stylesheet.SizeA4):null,Vn),l(7),C(t.printTemplate.Logo?8:-1),l(3),M(t.printTemplate.Title),l(2),M(t.printTemplate.Field),l(3),p("innerHTML",x(17,27,t.printTemplate.Address),Je),l(3),p("innerHTML",x(20,29,t.printTemplate.ContactInfo),Je),l(2),C(t.data.ContactDisplay?21:-1),l(4),M(t.data.Prefixed),l(2),D(" ",t.data.Invoice==null?null:t.data.Invoice.Number," "),l(10),M(X(38,31,t.data.Invoice==null?null:t.data.Invoice.Date,"dd MMM yyyy")),l(2),C(t.data.Shipping?39:-1),l(17),D(" Price(",t.data.CurrencySymbol,") "),l(4),D(" Total(",t.data.CurrencySymbol,") "),l(2),Z(t.data.Items),l(5),Z(t.data==null?null:t.data.AmountSummary),l(3),Z(t.data==null?null:t.data.PaidAmountSummary),l(3),C(t.appConfigJson.PrintConfigInvoice!=null&&t.appConfigJson.PrintConfigInvoice.Footer.PaymentMethodVisible&&t.data.Payments.length>0?73:-1),l(),C((t.data.CustomerTransaction==null?null:t.data.CustomerTransaction.SO)!=null&&(t.data.CustomerTransaction==null?null:t.data.CustomerTransaction.SO.DeliveryStateID)!=3&&(t.appConfigJson.PrintConfigInvoice!=null&&t.appConfigJson.PrintConfigInvoice.Footer.DeliveryInfoVisible)?74:-1),l(),C(!(t.data==null||t.data.Invoice==null)&&t.data.Invoice.PaymentStateID&&(t.data==null||t.data.Invoice==null?null:t.data.Invoice.PaymentStateID)<3?75:-1),l(),C(t.data.Invoice!=null&&t.data.Invoice.Note?76:-1),l(6),D(" ",t.appConfigJson.PrintConfigInvoice==null?null:t.appConfigJson.PrintConfigInvoice.FooterLabel.ReceivedBy," "),l(3),C((t.appConfigJson.PrintConfigDelivery==null?null:t.appConfigJson.PrintConfigDelivery.Footer.SignatureCountType)==1||(t.appConfigJson.PrintConfigDelivery==null?null:t.appConfigJson.PrintConfigDelivery.Footer.SignatureCountType)==2?85:-1),l(),C((t.appConfigJson.PrintConfigDelivery==null?null:t.appConfigJson.PrintConfigDelivery.Footer.SignatureCountType)==2?86:-1),l(3),D(" ",t.appConfigJson.PrintConfigInvoice==null?null:t.appConfigJson.PrintConfigInvoice.FooterLabel.SignedBy," "),l(2),D(" ",t.data.ItemTransfer==null?null:t.data.ItemTransfer.Courier," "),l(2),p("ngClass",!t.printTemplate.FooterRight&&"single")("innerHTML",t.printTemplate.FooterLeft,Je),l(),C(t.printTemplate.FooterRight?94:-1)}}var Xo=class n{data;outletInfo;appConfigJson;printTemplate;stylesheet;constructor(){}ngOnInit(){}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=N({type:n,selectors:[["POS-bill-receipt-A4"]],inputs:{data:"data",outletInfo:"outletInfo",appConfigJson:[0,"config","appConfigJson"],printTemplate:"printTemplate",stylesheet:"stylesheet"},standalone:!1,decls:1,vars:1,consts:[["rel","stylesheet"],[1,"print_container"],[1,"sales_order_A4"],[1,"header","clearfix"],[1,"header_left"],[1,"company"],[1,"float",3,"src"],[1,"companyBody"],[1,"contact_info","clearfix"],[1,"address"],[3,"innerHTML"],[1,"number"],[1,"contact",2,"min-width","400px"],[1,"header_right"],[1,"contact","shippingAddress","mt-3"],[1,"cart-mini-items"],[1,"cartItems"],[1,"w-100","table","table-sm","table-bordered","plain"],[2,"background","#fdf3c6"],[1,"number",2,"width","20px"],[2,"width","100px"],[1,"number",2,"width","50px"],[2,"width","50px"],[1,"number",2,"width","100px"],[1,"number","text-end",2,"width","20px"],[1,"col-12"],[1,"table","table-sm","table-borderless","d-flex","justify-content-end"],[1,"info"],[1,"signature"],[1,"left"],[1,"name"],[1,"left","leftSmall"],[1,"left","rightSmall"],[1,"right"],[1,"note"],[1,"left",3,"ngClass","innerHTML"],[1,"right",3,"innerHTML"],[1,"box"],[1,"customer_info"],[1,"special-TinyMCE",2,"word-break","break-all",3,"innerHTML"],[1,"number","red","text-end"],["colspan","3"],[1,"currency"],[1,"text-end",2,"width","50px"],[3,"hidden"],[1,"float"],[1,"bg-light-gray"],[3,"innerHtml"]],template:function(t,i){t&1&&h(0,ra,95,34,"div"),t&2&&C(i.data?0:-1)},dependencies:[Be,q,Ye,fo,ho,Co,No],styles:['a.linkMini[_ngcontent-%COMP%]{left:130px;position:absolute;top:.5px;text-decoration:none;color:#3b5998}div.print_container[_ngcontent-%COMP%]{margin:0 auto;width:900px;text-align:left;color:#000;position:relative}div.print_container[_ngcontent-%COMP%], div.print_container[_ngcontent-%COMP%] h1[_ngcontent-%COMP%], div.print_container[_ngcontent-%COMP%] h2[_ngcontent-%COMP%], div.print_container[_ngcontent-%COMP%] h3[_ngcontent-%COMP%], div.print_container[_ngcontent-%COMP%] h4[_ngcontent-%COMP%], div.print_container[_ngcontent-%COMP%] h5[_ngcontent-%COMP%], div.print_container[_ngcontent-%COMP%] h6[_ngcontent-%COMP%]{font-family:Arial!important;background-color:#fff}div.mode[_ngcontent-%COMP%]{color:gray;font-size:11px;text-align:right;height:20px;padding-top:2px}div.mode[_ngcontent-%COMP%] span[_ngcontent-%COMP%], div.mode[_ngcontent-%COMP%] ul[_ngcontent-%COMP%], div.mode[_ngcontent-%COMP%] ul[_ngcontent-%COMP%] li[_ngcontent-%COMP%]{float:left;display:block;margin:0;padding:0}div.mode[_ngcontent-%COMP%] ul[_ngcontent-%COMP%] li[_ngcontent-%COMP%]:first-child{padding-right:5px;margin-right:5px;border-right:solid 1px gray}div.mode[_ngcontent-%COMP%] div.printer[_ngcontent-%COMP%]{float:left}div.mode[_ngcontent-%COMP%] div.template[_ngcontent-%COMP%]{float:right}div.mode[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{margin:0 5px}div.header[_ngcontent-%COMP%] div.contact[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{font-size:12px;margin:0 5px 0 0;padding:0;font-weight:700;float:left}div.copy[_ngcontent-%COMP%]{background-image:url(/Images/Print/copy_bg.png);background-repeat:no-repeat;background-position:50% 70px}div.note[_ngcontent-%COMP%] div.left[_ngcontent-%COMP%]{float:left;margin-left:5px;width:440px}div.note-info[_ngcontent-%COMP%]{margin:auto;width:23%}table.info[_ngcontent-%COMP%]{border-collapse:collapse;margin-top:5px;margin-left:5px}table.info[_ngcontent-%COMP%] th[_ngcontent-%COMP%], table.info[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:5px 7px;border:solid 1px #d8d8d8}table.info[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{background-color:#f6f6f6}div.fullContainer[_ngcontent-%COMP%] div.print_container[_ngcontent-%COMP%]{min-height:970px;position:relative}.clearfix[_ngcontent-%COMP%]{zoom:1}div.reportMargin[_ngcontent-%COMP%]{margin:20px 0 0}@media print{div.mode[_ngcontent-%COMP%], .linkMini[_ngcontent-%COMP%]{display:none;visibility:hidden;height:0px}thead[_ngcontent-%COMP%]{display:table-header-group}}small.creator[_ngcontent-%COMP%]{padding:2px 0 20px;font-style:normal}span.titleJB[_ngcontent-%COMP%]{font-weight:700;padding:10px 0 7px 8px;display:block}.topHolder[_ngcontent-%COMP%]{margin-top:15px!important}h1.jobOrderHeader[_ngcontent-%COMP%]{text-align:center}body[_ngcontent-%COMP%]{padding:0;font-size:12px}div.print_container[_ngcontent-%COMP%]{margin:0 auto!important;text-align:left;color:#000;position:relative}div.mode[_ngcontent-%COMP%]{color:gray;text-align:right;height:20px;padding-top:2px;font-size:10px}div.mode[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{float:left;display:block;margin:0 5px 0 0;padding:0}div.mode[_ngcontent-%COMP%] ul[_ngcontent-%COMP%]{float:left;display:block;margin:0;padding:0}div.mode[_ngcontent-%COMP%] ul[_ngcontent-%COMP%] li[_ngcontent-%COMP%]{float:left;display:block;margin:0 5px 0 0;padding:0 5px 0 0;border-right:solid 1px gray}div.mode[_ngcontent-%COMP%] ul[_ngcontent-%COMP%] li[_ngcontent-%COMP%]:last-child{border-right:none}div.mode[_ngcontent-%COMP%] a[_ngcontent-%COMP%]{color:#3b5998;text-decoration:none}div.mode[_ngcontent-%COMP%] a[_ngcontent-%COMP%]:hover{text-decoration:underline}div.mode[_ngcontent-%COMP%] a.active[_ngcontent-%COMP%]{color:gray}div.mode[_ngcontent-%COMP%] a.active[_ngcontent-%COMP%]:hover{text-decoration:none}div.header[_ngcontent-%COMP%]{width:100%;overflow:auto}div.header_left[_ngcontent-%COMP%]{float:left;padding:5px 0 0 5px}div.header_left[_ngcontent-%COMP%] h1[_ngcontent-%COMP%]{margin:5px 0 0;padding:0;font-size:18px}div.header_right[_ngcontent-%COMP%]{float:right;padding:0 5px 0 0;max-width:425px}div.header_right[_ngcontent-%COMP%] h1[_ngcontent-%COMP%]{margin:0;padding:0;text-align:right}div.header_right[_ngcontent-%COMP%] h1[_ngcontent-%COMP%] strong[_ngcontent-%COMP%]{font-size:16px;font-weight:700;margin:0 5px 0 0;text-transform:uppercase}div.header_right[_ngcontent-%COMP%] h1[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{font-size:18px;font-weight:400}div.header_right[_ngcontent-%COMP%] table[_ngcontent-%COMP%]{float:right;border-collapse:collapse}div.header_right[_ngcontent-%COMP%] table[_ngcontent-%COMP%] th[_ngcontent-%COMP%], div.header_right[_ngcontent-%COMP%] table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{border:solid 1px #9E9E9E;padding:4px}div.header_right[_ngcontent-%COMP%] table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{background:#f6f6f6}div.header_right[_ngcontent-%COMP%] table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding-bottom:6px}div.header[_ngcontent-%COMP%] img.float[_ngcontent-%COMP%]{margin:5px 0 0 5px;float:left}div.header[_ngcontent-%COMP%] div.company[_ngcontent-%COMP%]{width:100%;overflow:auto;margin:0 0 8px}div.header[_ngcontent-%COMP%] div.companyBody[_ngcontent-%COMP%]{float:left}div.header[_ngcontent-%COMP%] div.companyBody[_ngcontent-%COMP%] h2[_ngcontent-%COMP%]{font-size:18px;font-weight:700;margin:0;padding:0}div.header[_ngcontent-%COMP%] div.companyBody[_ngcontent-%COMP%] small[_ngcontent-%COMP%]{font-size:11px;text-align:left;font-weight:400}div.header[_ngcontent-%COMP%] div.companyBody[_ngcontent-%COMP%] div.contact_info[_ngcontent-%COMP%]{margin-top:3px}div.header[_ngcontent-%COMP%] div.companyBody[_ngcontent-%COMP%] div.contact_info[_ngcontent-%COMP%] div.address[_ngcontent-%COMP%]{float:left;min-width:125px}div.header[_ngcontent-%COMP%] div.companyBody[_ngcontent-%COMP%] div.contact_info[_ngcontent-%COMP%] div.number[_ngcontent-%COMP%]{margin-right:5px;min-width:160px}div.header[_ngcontent-%COMP%] div.contact[_ngcontent-%COMP%]{width:max-content;overflow:auto;border:solid 1px #9E9E9E;padding:5px}div.header[_ngcontent-%COMP%] div.contact[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{font-size:12px;margin:0 5px 0 0;padding:0;font-weight:700}div.cartItems[_ngcontent-%COMP%]{padding:10px 3px 2px 5px}div.copy[_ngcontent-%COMP%]{background-image:url(/Images/Print/copy_bg.png);background-repeat:no-repeat;background-position:50% 70px}div.topNote[_ngcontent-%COMP%]{clear:both;text-align:right}div.invoiceNote[_ngcontent-%COMP%]{padding:10px 0 0 7px}div.note[_ngcontent-%COMP%]{position:relative}div.note[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{font-weight:700;font-size:12px;margin:0 0 3px;padding:0}div.note[_ngcontent-%COMP%] div.single[_ngcontent-%COMP%]{width:895px!important}div.note[_ngcontent-%COMP%] div.left[_ngcontent-%COMP%]{float:left;margin-left:5px;width:440px;text-align:left}div.note[_ngcontent-%COMP%] div.left[_ngcontent-%COMP%] ol[_ngcontent-%COMP%]{margin:5px 0 0;padding:0 0 0 20px}div.note[_ngcontent-%COMP%] div.left[_ngcontent-%COMP%] ol[_ngcontent-%COMP%] li[_ngcontent-%COMP%]{margin:0 0 2px}div.note[_ngcontent-%COMP%] div.left[_ngcontent-%COMP%] ul[_ngcontent-%COMP%]{margin:2px 0 5px;padding:0 0 0 20px}div.note[_ngcontent-%COMP%] div.left[_ngcontent-%COMP%] ul[_ngcontent-%COMP%] li[_ngcontent-%COMP%]{margin:0 0 2px}div.note[_ngcontent-%COMP%] div.right[_ngcontent-%COMP%]{float:right;width:440px;border-left:solid 1px #CACACA;padding-left:8px;margin-right:5px}div.note[_ngcontent-%COMP%] div.right[_ngcontent-%COMP%] ul[_ngcontent-%COMP%]{margin:0;padding:0;list-style:none}div.note[_ngcontent-%COMP%] div.right[_ngcontent-%COMP%] h3.closing[_ngcontent-%COMP%]{margin-top:10px;text-align:right}.clearfix[_ngcontent-%COMP%]:before, .clearfix[_ngcontent-%COMP%]:after{content:"";display:table}.clearfix[_ngcontent-%COMP%]:after{clear:both}small.timestamp[_ngcontent-%COMP%], small.creator[_ngcontent-%COMP%], small.printed[_ngcontent-%COMP%]{font-size:12px;text-align:center;display:block;font-style:italic;padding:2px 0}.shippingAddress[_ngcontent-%COMP%]{text-align:right;min-width:240px;clear:both}.shippingAddress[_ngcontent-%COMP%] div.box[_ngcontent-%COMP%] div[_ngcontent-%COMP%]:first-child{text-align:left;font-weight:700}.packingSlip[_ngcontent-%COMP%]{min-width:150px}.customer_info[_ngcontent-%COMP%]{min-width:310px}.special-TinyMCE[_ngcontent-%COMP%]{padding-top:10px!important}@media print{body[_ngcontent-%COMP%]{font-family:Arial;color:#000}}@-moz-document url-prefix(){}div.signature[_ngcontent-%COMP%], div.signature-b[_ngcontent-%COMP%]{clear:both;height:111px;margin-top:25px}div.signature[_ngcontent-%COMP%] h5[_ngcontent-%COMP%]{margin:0 0 80px;padding:0;font-size:12px;font-weight:700}div.signature[_ngcontent-%COMP%] div.name[_ngcontent-%COMP%]{border-top:solid 1px Gray;height:15px;text-align:center}div.signature[_ngcontent-%COMP%] div.left[_ngcontent-%COMP%]{float:left;margin-left:70px;width:150px}div.signature[_ngcontent-%COMP%] div.center[_ngcontent-%COMP%]{float:left;margin-left:155px;width:150px}div.signature[_ngcontent-%COMP%] div.noLeftMargin[_ngcontent-%COMP%]{margin-left:0!important}div.signature[_ngcontent-%COMP%] div.leftSmall[_ngcontent-%COMP%]{margin-left:120px!important}div.signature[_ngcontent-%COMP%] div.left[_ngcontent-%COMP%] h5[_ngcontent-%COMP%], div.signature[_ngcontent-%COMP%] div.center[_ngcontent-%COMP%] h5[_ngcontent-%COMP%]{text-align:center}div.signature[_ngcontent-%COMP%] div.right[_ngcontent-%COMP%]{float:right;width:150px;margin-right:5px}div.print_container[_ngcontent-%COMP%] div.footerNote[_ngcontent-%COMP%]{padding-left:5px;width:150px}div.signature[_ngcontent-%COMP%] div.right[_ngcontent-%COMP%] h5[_ngcontent-%COMP%]{text-align:center}div.fullSignatureNote[_ngcontent-%COMP%]{position:absolute;bottom:0;width:100%}table[_ngcontent-%COMP%] tfoot[_ngcontent-%COMP%]{display:table-row-group}table.plain[_ngcontent-%COMP%]{border-collapse:collapse}table.plain[_ngcontent-%COMP%] thead[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{text-shadow:0 -1px 0 rgba(0,0,0,.4);height:28px;line-height:16px;padding:2px 7px;color:#fff;font-weight:700}table.plain[_ngcontent-%COMP%] thead[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]{background-color:#fceca3!important;background-image:none!important}table.plain[_ngcontent-%COMP%] thead[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{color:#000;text-shadow:none}table.plain[_ngcontent-%COMP%] th[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:5px 7px}table.plain[_ngcontent-%COMP%] tr.thick[_ngcontent-%COMP%] th[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] tr.thick[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{border-bottom:3px solid black}table.plain[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:nth-child(2n){background-color:#f6f6f6}table.plain[_ngcontent-%COMP%] a.thumb[_ngcontent-%COMP%]{margin:0 5px 0 0;padding:0;float:left;display:block}table.plain[_ngcontent-%COMP%] a.thumb[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{width:40px;height:40px;background-color:#fff;display:block;background-color:#d8dfea;border:1px solid #bbb;-webkit-border-radius:3px;border-radius:3px}table.plain[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{color:#2b4e75;font-style:italic;margin:0;padding:0}table.plain[_ngcontent-%COMP%] div.text[_ngcontent-%COMP%]{padding:2px 0 0}table.plain[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] td[_ngcontent-%COMP%] a[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] td[_ngcontent-%COMP%] a[_ngcontent-%COMP%]:visited{display:block;color:#00f;text-decoration:none}table.plain[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(-n+3) a[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(-n+3) a[_ngcontent-%COMP%]:visited{font-weight:700}table.plain[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] td[_ngcontent-%COMP%] a[_ngcontent-%COMP%]:hover{text-decoration:underline}table.plain[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{margin:0;padding:0;display:block}table.plain[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] input.txtPrice[_ngcontent-%COMP%]{border:solid 1px #C8D3DF;padding:3px;text-align:right}table.plain[_ngcontent-%COMP%] tr.group[_ngcontent-%COMP%]{background-color:#fdf3c6!important}table.plain[_ngcontent-%COMP%] tr.group[_ngcontent-%COMP%] a[_ngcontent-%COMP%]{color:#000!important}table.plain[_ngcontent-%COMP%] thead[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] th[_ngcontent-%COMP%] a[_ngcontent-%COMP%]{color:#fff}table.plain[_ngcontent-%COMP%] th.borderLRB0[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] td.borderLRB0[_ngcontent-%COMP%]{border-left-width:0px!important;border-right-width:0px!important;border-bottom-width:0px!important;background-color:#fff!important}table.plain[_ngcontent-%COMP%] th.number[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] td.number[_ngcontent-%COMP%]{text-align:right}table.plain[_ngcontent-%COMP%] th.numberCenter[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] td.numberCenter[_ngcontent-%COMP%]{text-align:center}table.plain[_ngcontent-%COMP%] th.red[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] td.red[_ngcontent-%COMP%]{color:red;text-align:right}table.plain[_ngcontent-%COMP%] td.top[_ngcontent-%COMP%]{vertical-align:top}table.plain[_ngcontent-%COMP%] td.noTopPad[_ngcontent-%COMP%]{padding-top:0}table.plain[_ngcontent-%COMP%] td.small[_ngcontent-%COMP%]{font-size:11px}table.plain[_ngcontent-%COMP%] tr.grid_footer[_ngcontent-%COMP%] th[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] tr.grid_footer[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{border-width:0px;background-color:#fff}table.plain[_ngcontent-%COMP%] span.serial[_ngcontent-%COMP%]{display:inline-block;margin-left:10px}table.plain[_ngcontent-%COMP%] tr.grid_footer[_ngcontent-%COMP%] table[_ngcontent-%COMP%] th[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] tr.grid_footer[_ngcontent-%COMP%] table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:5px 0 5px 5px;background-color:#fff}table.plain[_ngcontent-%COMP%] td[_ngcontent-%COMP%] .inlineMarginLeft[_ngcontent-%COMP%]{display:inline-block;margin-left:10px}table.rightAuto[_ngcontent-%COMP%]{margin:0 0 0 auto}table[_ngcontent-%COMP%] ul.float[_ngcontent-%COMP%]{margin:0;padding:0;list-style-type:circle;list-style-position:inside}table[_ngcontent-%COMP%] ul.float[_ngcontent-%COMP%] li[_ngcontent-%COMP%]{margin:0 20px 0 0;padding:0;float:left;display:block}table[_ngcontent-%COMP%] ul.float[_ngcontent-%COMP%] li[_ngcontent-%COMP%] a[_ngcontent-%COMP%]{text-decoration:none}table[_ngcontent-%COMP%] ul.float[_ngcontent-%COMP%] li[_ngcontent-%COMP%] a[_ngcontent-%COMP%]:hover{text-decoration:underline}div.scroll[_ngcontent-%COMP%]{width:100%;overflow:auto;padding:0 0 2px}table.fixed[_ngcontent-%COMP%]{table-layout:fixed}table.footer_row[_ngcontent-%COMP%]{margin:5px 8px 0 auto}table.footer_row[_ngcontent-%COMP%] td.currency[_ngcontent-%COMP%], table.footer_row[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:last-child{padding:5px 0 5px 5px;text-align:right}table.footer_row[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{padding:5px;text-align:right;float:left}table.footer_adjust[_ngcontent-%COMP%]{margin:-10px 18px 0 auto}table.footer_adjust[_ngcontent-%COMP%] td.currency[_ngcontent-%COMP%], table.footer_adjust[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:last-child{padding:5px 0 5px 5px;text-align:right}table.footer_adjust[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{padding:5px 23px 5px 5px;text-align:right;float:left}table.total-all-grid[_ngcontent-%COMP%]{width:100%!important;border-collapse:collapse;margin-top:10px}table.manufacture[_ngcontent-%COMP%]{width:100%;border-collapse:collapse}table.manufacture[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{background-color:#fceca3!important}table.manufacture[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{border:1px solid #BBBBBB!important}table.accounting[_ngcontent-%COMP%]{max-width:1000px;border-collapse:collapse}table.accounting[_ngcontent-%COMP%] thead[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{border-top:1px solid #999;border-bottom:1px solid #999;height:28px;line-height:16px;color:#444;background-color:#fceca3!important}table.accounting[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:nth-child(2n){background-color:#f6f6f6}table.accounting[_ngcontent-%COMP%] th[_ngcontent-%COMP%], table.accounting[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:7px;border-bottom:1px solid black}table.accounting[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] td[_ngcontent-%COMP%] a[_ngcontent-%COMP%], table.accounting[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] td[_ngcontent-%COMP%] a[_ngcontent-%COMP%]:visited{color:#00f;text-decoration:none}table.accounting[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] td[_ngcontent-%COMP%] a[_ngcontent-%COMP%]:hover{text-decoration:underline}table.accounting[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] input.txtPrice[_ngcontent-%COMP%]{border:solid 1px #C8D3DF;padding:3px;text-align:right}table.accounting[_ngcontent-%COMP%] th.number[_ngcontent-%COMP%], table.accounting[_ngcontent-%COMP%] td.number[_ngcontent-%COMP%]{text-align:right}table.accounting[_ngcontent-%COMP%] th.red[_ngcontent-%COMP%], table.accounting[_ngcontent-%COMP%] td.red[_ngcontent-%COMP%]{color:red;text-align:right}table.accounting[_ngcontent-%COMP%] th.bordertop[_ngcontent-%COMP%], table.accounting[_ngcontent-%COMP%] td.bordertop[_ngcontent-%COMP%]{border-top:1px #999 solid}table.accounting[_ngcontent-%COMP%] tfoot[_ngcontent-%COMP%] td[_ngcontent-%COMP%], table.accounting[_ngcontent-%COMP%] tfoot[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{padding-bottom:20px}table.main[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr.main[_ngcontent-%COMP%]:nth-child(2n){background-color:#fff}table.main[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr.main[_ngcontent-%COMP%]:nth-child(4n-1){background-color:#f6f6f6}table.main[_ngcontent-%COMP%] table[_ngcontent-%COMP%] thead[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]{background-color:#fceca3!important;background-image:none!important}table.main[_ngcontent-%COMP%] table[_ngcontent-%COMP%] thead[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{border:1px solid #9e9e9e;color:#000;text-shadow:none}.cartItems[_ngcontent-%COMP%] .flow[_ngcontent-%COMP%]{width:100%;padding:0;margin:0}.cartItems[_ngcontent-%COMP%] .flow[_ngcontent-%COMP%] > li[_ngcontent-%COMP%]{width:calc(33% - 17px);float:left;list-style:none;padding:5px 7px;border:solid 1px #d8d8d8}.cartItems[_ngcontent-%COMP%] .flow[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{width:calc(33% - 17px);float:left;list-style:none;padding:5px 7px;border:solid 1px #d8d8d8;display:table-cell}.cartItems[_ngcontent-%COMP%] .flow[_ngcontent-%COMP%] td[_ngcontent-%COMP%] > p[_ngcontent-%COMP%]{color:#2b4e75;font-style:italic;margin:0;padding:0}.listReturn[_ngcontent-%COMP%] tr.item[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(2){width:10%!important}.listReturn[_ngcontent-%COMP%] tr.item[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(3){width:10%!important}.listReturn[_ngcontent-%COMP%] tr.item[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(5){width:10%!important}.listReturn[_ngcontent-%COMP%] tr.item[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(6){width:5%!important}.listReturn[_ngcontent-%COMP%] tr.item[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(7){width:10%!important}.listReturn[_ngcontent-%COMP%] a.head[_ngcontent-%COMP%]{padding:10px 0 10px 10px;display:block;width:50%}.listReturn[_ngcontent-%COMP%] td.numberCenter[_ngcontent-%COMP%]{text-align:right!important}.listReturn[_ngcontent-%COMP%] table.summary[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%]{padding-top:20px!important;display:block}table.paidAmount[_ngcontent-%COMP%]{float:right;margin-top:-10px;text-align:right;padding-right:7px}table.paidAmount[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{padding:0 0 1px}table.paidAmount[_ngcontent-%COMP%] td.currency[_ngcontent-%COMP%]{width:20px;text-align:left}table.paidAmount[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(2){padding:0 5px}div.zebra[_ngcontent-%COMP%]{display:table;border-collapse:collapse}div.zebra[_ngcontent-%COMP%] > div[_ngcontent-%COMP%]{display:table-cell}div.zebra[_ngcontent-%COMP%] > div[_ngcontent-%COMP%] > strong[_ngcontent-%COMP%]{display:block;border:1px solid #525252;background-color:#545454;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(0%,#888),color-stop(100%,#545454));background-image:-webkit-linear-gradient(#888,#545454);background-image:-moz-linear-gradient(#888,#545454);background-image:-o-linear-gradient(#888,#545454);background-image:linear-gradient(#888,#545454);-webkit-box-shadow:inset 0 2px 0 -1px rgba(255,255,255,.2);-moz-box-shadow:inset 0 2px 0 -1px rgba(255,255,255,.2);box-shadow:inset 0 2px 0 -1px #fff3;text-shadow:0 -1px 0 rgba(0,0,0,.4);height:28px;line-height:24px;border-bottom:1px solid #333;padding:2px 7px;color:#fff;font-weight:700}div.zebra[_ngcontent-%COMP%] > div[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{display:block;padding:5px 7px;border:solid 1px #d8d8d8;font-weight:700}div.zebra[_ngcontent-%COMP%] > div[_ngcontent-%COMP%] > span.number[_ngcontent-%COMP%]{text-align:right}']})},Ki=class n{static \u0275fac=function(t){return new(t||n)};static \u0275mod=di({type:n});static \u0275inj=ci({imports:[Se,Si]})};var Bt=class n{_state=R(this.getEcrConfig());isEnabled=ae(()=>this._state()?.enabled);ecrUrl=ae(()=>this._state()?.url);getEcrConfig(){let e=localStorage.getItem("ecrConfig"),t={enabled:!1,url:null,timestamp:""};return f.IsNotEmpty(e)&&(t=JSON.parse(e)),t}url=ae(()=>{let e=this._state()?.url;if(e){let t=e.split("/");t.pop(),e=t.join("/")}return e});connect(e){let i={enabled:!0,url:e,timestamp:new Date().toDateString()};localStorage.setItem("ecrConfig",JSON.stringify(i)),this._state.set(i)}disconnect(){let t={enabled:!1,timestamp:new Date().toDateString(),url:null};localStorage.setItem("ecrConfig",JSON.stringify(t)),this._state.set(t)}static \u0275fac=function(t){return new(t||n)};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Ht=class n{ecrStorage=T(Bt);socketConnection;_ecrEvent=new Me;ecrEvent$=this._ecrEvent.asObservable();_isSignalRConnected=R(!1);isConnected=ae(()=>this.ecrStorage.isEnabled()&&this._isSignalRConnected());toastr=T(F);initEcrOnStartup(){if(this.isConnected()){let t=this.ecrStorage.ecrUrl();this.initConnection(t)}}initConnection(e){this.socketConnection=new hi().withUrl(e).withAutomaticReconnect().configureLogging(fi.Information).build(),this.ecrStorage.connect(e),this.listenToConnectionEvents(),this.listenToEvents(),this.startConnection()}startConnection(){this.socketConnection.start().then(()=>{this._isSignalRConnected.set(!0),this.toastr.success("Successfully connected to ECR","Success")}).catch(e=>{this.toastr.error(e,"Failed connecting to ECR"),console.log(e)})}listenToEvents(){this.socketConnection.on("EcrEvent",e=>{this._ecrEvent.next(e)})}stopConnection(){this.socketConnection.stop().then(()=>{console.info("SignalR for ECR is Disconnected")})}listenToConnectionEvents(){this.socketConnection.onreconnecting(()=>{console.info("SignalR for ECR is Reconnecting")}),this.socketConnection.onreconnected(()=>{console.info("SignalR for ECR is Reconnected"),this._isSignalRConnected.set(!0)}),this.socketConnection.onclose(()=>{console.info("SignalR for ECR is Closed"),this._isSignalRConnected.set(!1)})}static \u0275fac=function(t){return new(t||n)};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Zi=class n{_state=R(this.getCashMachineConfig());isEnabled=ae(()=>this._state()?.enabled);ecrUrl=ae(()=>this._state()?.url);getCashMachineConfig(){let e=localStorage.getItem("CashkMachineConfig"),t={enabled:!1,url:null,timestamp:""};return f.IsNotEmpty(e)&&(t=JSON.parse(e)),t}url=ae(()=>this._state()?.url);connect(e){let i={enabled:!0,url:e,timestamp:new Date().toDateString()};localStorage.setItem("CashkMachineConfig",JSON.stringify(i)),this._state.set(i)}disconnect(){let t={enabled:!1,timestamp:new Date().toDateString(),url:null};localStorage.setItem("CashkMachineConfig",JSON.stringify(t)),this._state.set(t)}static \u0275fac=function(t){return new(t||n)};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var jt=class n{cashMachineConfig=T(Zi);socketConnection;_cashMachineEvent=new Me;_withdrawMoneyStatus=new Me;cashMachineEvent$=this._cashMachineEvent.asObservable();withdrawMoneyStatus$=this._withdrawMoneyStatus.asObservable();_isSignalRConnected=R(!1);isConnected=ae(()=>this.cashMachineConfig.isEnabled()&&this._isSignalRConnected());toastr=T(F);initCashMachineOnStartup(){if(this.cashMachineConfig.isEnabled()){let t=this.cashMachineConfig.url();this.initConnection(t)}}initConnection(e){this.socketConnection=new hi().withUrl(e).withAutomaticReconnect().configureLogging(fi.Information).build(),this.listenToConnectionEvents(),this.listenToEvents(),this.startConnection(e)}startConnection(e){this.socketConnection.start().then(()=>{this._isSignalRConnected.set(!0),this.toastr.success("Successfully connected to Cash Machine","Success"),this.cashMachineConfig.connect(e)}).catch(t=>{this.toastr.error(t,"Failed connecting to Cash Machine"),console.log(t)})}sendWithdrawMoney(e){return this.socketConnection.send("WithdrawMoney",{Value:e}).catch(t=>console.error(t))}listenToEvents(){this.socketConnection.on("OnReceiveMoney",e=>{if(e){let t=JSON.parse(e);this._cashMachineEvent.next(t)}}),this.socketConnection.on("WithdrawMoneyStatus",e=>{e&&this._withdrawMoneyStatus.next(e?.status)})}stopConnection(){this.socketConnection.stop().then(()=>{console.info("SignalR for Cash Machine is Disconnected"),this.cashMachineConfig.disconnect()})}listenToConnectionEvents(){this.socketConnection.onreconnecting(()=>{console.info("SignalR for Cash Machine is Reconnecting")}),this.socketConnection.onreconnected(()=>{console.info("SignalR for Cash Machine is Reconnected"),this._isSignalRConnected.set(!0)}),this.socketConnection.onclose(()=>{console.info("SignalR for Cash Machine is Closed"),this._isSignalRConnected.set(!1)})}static \u0275fac=function(t){return new(t||n)};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var ca=(n,e,t,i)=>({"unselected-online-card":n,"selected-online-card":e,"selected-offline-card":t,"unselected-offline-card":i}),da=(n,e)=>({"selected-color":n,"unselected-online-card-color":e}),ma=(n,e)=>({"selected-color":n,"unselected-offline-card-color":e});function pa(n,e){if(n&1&&(a(0,"p",5),d(1," Order is "),a(2,"b"),d(3,"sync"),s(),d(4," to server realtime "),s()),n&2){let t=m();p("ngClass",Ue(1,da,t.selected(),!t.selected()))}}function ua(n,e){if(n&1&&(a(0,"p",5),d(1," Order is "),a(2,"b"),d(3,"saved"),s(),d(4," to your browser storage "),s()),n&2){let t=m();p("ngClass",Ue(1,ma,t.selected(),!t.selected()))}}var Xi=class n{statusType=qt("ONLINE");selected=qt(!1);clickCard=bt({alias:"onClick"});onClick(){this.clickCard.emit()}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=N({type:n,selectors:[["app-card-status"]],inputs:{statusType:[1,"statusType"],selected:[1,"selected"]},outputs:{clickCard:"onClick"},decls:8,vars:8,consts:[[1,"card","selected-online-card","mb-0","cursor-pointer",2,"width","150px",3,"click","ngClass"],[1,"card-body"],[1,"text-center"],[1,"fa","fa-wifi","fs-1"],[1,"fw-bold","pt-5"],[1,"mb-0","mt-4",3,"ngClass"]],template:function(t,i){t&1&&(a(0,"div",0),S("click",function(){return i.onClick()}),a(1,"div",1)(2,"div",2),b(3,"i",3),a(4,"h4",4),d(5),s(),h(6,pa,5,4,"p",5)(7,ua,5,4,"p",5),s()()()),t&2&&(p("ngClass",jn(3,ca,i.statusType()=="ONLINE"&&!i.selected(),i.statusType()=="ONLINE"&&i.selected(),i.statusType()=="OFFLINE"&&i.selected(),i.statusType()=="OFFLINE"&&!i.selected())),l(5),D(" ",i.statusType()," "),l(),C(i.statusType()=="ONLINE"?6:7))},dependencies:[Se,Be],styles:[".selected-color[_ngcontent-%COMP%], .selected-offline-card[_ngcontent-%COMP%], .selected-online-card[_ngcontent-%COMP%]{color:#fff}.unselected-online-card-color[_ngcontent-%COMP%], .unselected-online-card[_ngcontent-%COMP%]{color:#89b03e}.unselected-offline-card-color[_ngcontent-%COMP%], .unselected-offline-card[_ngcontent-%COMP%]{color:#c9302c}.selected-online-card[_ngcontent-%COMP%]{border:1px solid #89b03e;background-color:#89b03e}.unselected-online-card[_ngcontent-%COMP%]{border:1px solid #89b03e;background-color:#f7fdf7}.selected-offline-card[_ngcontent-%COMP%]{border:1px solid #c9302c;background-color:#c9302c}.unselected-offline-card[_ngcontent-%COMP%]{border:1px solid #c9302c;background-color:#fdf7f7}"]})};var en=class n{configOptions=[{label:"Online",value:!1},{label:"Offline",value:!0}];orderHandling=gi(!1);productHandling=gi(!1);startConfig=gi(!1);isOffline=ae(()=>this.orderHandling()&&this.productHandling()&&this.startConfig());onClickCard(e){this.orderHandling.set(e),this.productHandling.set(e),this.startConfig.set(e)}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=N({type:n,selectors:[["app-setup"]],inputs:{orderHandling:[1,"orderHandling"],productHandling:[1,"productHandling"],startConfig:[1,"startConfig"]},outputs:{orderHandling:"orderHandlingChange",productHandling:"productHandlingChange",startConfig:"startConfigChange"},decls:27,vars:11,consts:[[1,"px-4"],[1,"fa","fa-wifi","text-success"],[1,"ms-3","fs-5"],[1,"d-flex","justify-content-center","align-items-center","gap-6","mt-6"],["statusType","ONLINE",3,"onClick","selected"],["statusType","OFFLINE",3,"onClick","selected"],[1,"mt-12"],[1,"d-flex","align-items-center"],[1,"fa-solid","fa-gear","text-success"],[1,"d-flex","align-items-center","justify-content-center","gap-10","mt-8"],[2,"width","150px"],[1,"mb-2"],["bindLabel","label","bindValue","value","appendTo","body",3,"ngModelChange","items","clearable","ngModel"],[1,"mx-5",2,"width","150px"]],template:function(t,i){t&1&&(a(0,"div",0)(1,"div")(2,"div"),b(3,"i",1),a(4,"span",2),d(5,"Connection Status"),s()(),a(6,"div",3)(7,"app-card-status",4),S("onClick",function(){return i.onClickCard(!1)}),s(),a(8,"app-card-status",5),S("onClick",function(){return i.onClickCard(!0)}),s()()(),a(9,"div",6)(10,"div",7),b(11,"i",8),a(12,"span",2),d(13,"System Configuration"),s()(),a(14,"div",9)(15,"div",10)(16,"label",11),d(17,"Orders handling"),s(),a(18,"ng-select",12),H("ngModelChange",function(r){return A(i.orderHandling,r)||(i.orderHandling=r),r}),s()(),a(19,"div",13)(20,"label",11),d(21,"Products management"),s(),a(22,"ng-select",12),H("ngModelChange",function(r){return A(i.productHandling,r)||(i.productHandling=r),r}),s()(),a(23,"div",10)(24,"label",11),d(25,"Start Config"),s(),a(26,"ng-select",12),H("ngModelChange",function(r){return A(i.startConfig,r)||(i.startConfig=r),r}),s()()()()()),t&2&&(l(7),p("selected",!i.isOffline()),l(),p("selected",i.isOffline()),l(10),p("items",i.configOptions)("clearable",!1),B("ngModel",i.orderHandling),l(4),p("items",i.configOptions)("clearable",!1),B("ngModel",i.productHandling),l(4),p("items",i.configOptions)("clearable",!1),B("ngModel",i.startConfig))},dependencies:[Xi,uo,Pt,vi,Pe,Ee],encapsulation:2})};var tn=class n{localDataService=T(Oe);httpService=T(ge);totalSyncProduct={totalOfflineProduct:0,totalOnlineProduct:0};getTotalProducts(e=!1){return this.totalSyncProduct.totalOfflineProduct==0||e?this.localDataService.findAllVariant().pipe(ce(t=>t.length>0),Y(t=>{let i=this.calculateOfflineProducts(t);return this.httpService.POSText("/api/POSSync/ProductCount",'{"ProductDiscontinued":0,"VariantDiscontinued":0,"CategoryDiscontinued":0,"From":"0001-01-01T00:00:00","To":"0001-01-01T00:00:00"}').pipe(J(o=>{let r=o?JSON.parse(o)?.Count:0;return{totalOfflineProduct:i.length,totalOnlineProduct:r}}),le(o=>{this.totalSyncProduct=o}))})):ke(this.totalSyncProduct)}calculateOfflineProducts(e){let t=new Set,i=[];for(let o of e)t.has(o.ProductID)==!1&&(t.add(o.ProductID),i.push(o));return i}getSyncTime(){return this.localDataService.getSyncTime().pipe(J(e=>{let t={date:null,daysDiff:0};if(e){let i=new Date(e.time),o=this.calculateSyncDiff(i);t={date:new Date(e.time),daysDiff:o}}return t}))}calculateSyncDiff(e){let t=0;return e&&(t=Math.floor((new Date().getTime()-e?.getTime())/1e3/60/60/24)),t}syncToLocalDatabase(){return $e([this.syncOutlets(),this.syncProducts(),this.syncOutletPrices()]).pipe(Y(()=>this.localDataService.updateSyncTime()))}syncOutlets(){return this.httpService.get(U.SynOutlet).pipe(Y(e=>this.localDataService.syncRegisters(e)))}syncProducts(){return this.httpService.get(U.SyncProducts).pipe(Y(e=>this.localDataService.syncVariants(e)))}syncOutletPrices(){return this.httpService.get(U.SynOutletPrice).pipe(Y(e=>this.localDataService.syncOutletPrice(e)))}static \u0275fac=function(t){return new(t||n)};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};function ga(n,e){n&1&&(d(0),y(1,"number")),n&2&&D(" ",x(1,1,e.totalOnlineProduct)," ")}function fa(n,e){n&1&&d(0," 0 ")}function ha(n,e){n&1&&(d(0),y(1,"number")),n&2&&D(" ",x(1,1,e.totalOfflineProduct)," ")}function Ca(n,e){n&1&&d(0," 0 ")}function va(n,e){if(n&1&&(d(0),y(1,"number")),n&2){let t=m();D(" Last Sync: ",x(1,1,t.daysDiff)," days ago! ")}}function _a(n,e){if(n&1&&(d(0),y(1,"date")),n&2){let t=m(2);D(" Last Sync: ",X(1,1,t.date,"dd MMM yyyy HH:mm")," ")}}function ya(n,e){n&1&&d(0," Never been sync ")}function ba(n,e){if(n&1&&h(0,_a,2,4)(1,ya,1,0),n&2){let t=m();C(t.date?0:1)}}function Sa(n,e){n&1&&h(0,va,2,3)(1,ba,2,1),n&2&&C(e.daysDiff>14?0:1)}var nn=class n{productSyncService=T(tn);onlineStatusService=T(he);isOnline$=this.onlineStatusService.getOnlineStatus$();toastr=T(F);productCount$=this.productSyncService.getTotalProducts().pipe(Le(1));syncTime$=this.productSyncService.getSyncTime().pipe(Le(1));onSyncProduct(){this.productSyncService.syncToLocalDatabase().subscribe({next:()=>{this.productCount$=this.productSyncService.getTotalProducts(!0).pipe(Le(1)),this.syncTime$=this.productSyncService.getSyncTime().pipe(Le(1)),this.toastr.success("Sync Product Offline Successfully","Success!")},error:e=>{this.toastr.error("Error syncing products. Please try again.","Error"),console.error("Error syncing products:",e)}})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=N({type:n,selectors:[["app-product-sync"]],decls:41,vars:12,consts:[[1,"fa-solid","fa-sync-alt","text-success","fs-5"],[1,"ms-3","fs-5"],[1,"d-flex","align-items-center","mt-2","justify-content-between","bg-secondary-subtle","px-8","py-6","rounded-3"],[1,"d-flex","align-items-top"],[1,"fs-5"],[1,"fw-normal","mt-1"],[1,"ms-8"],[1,"btn","btn-success","btn-sm",3,"click","disabled"],[1,"fa-solid","fa-sync-alt","me-2","pe-2"],[1,"mt-8"],[1,"fa-solid","fa-circle-info","text-success","fs-5"],[1,"border","rounded-3","mt-2"],[1,"text-center","my-8"],["src","https://cdn.dealpos.xyz/web-image/globalnodata.svg",2,"width","100px"],[1,"fw-normal","mt-6","opacity-25"]],template:function(t,i){if(t&1&&(V(0,"div")(1,"div"),Xe(2,"i",0),V(3,"span",1),d(4,"Product Sync"),Q()(),V(5,"div",2)(6,"div",3)(7,"div")(8,"span",4),d(9,"Online Products"),Q(),V(10,"h3",5),h(11,ga,2,3),y(12,"async"),Sn(13,fa,1,0),Q()(),V(14,"div",6)(15,"span",4),d(16,"Offline Products"),Q(),V(17,"h3",5),h(18,ha,2,3),y(19,"async"),Sn(20,Ca,1,0),Q(),V(21,"small"),h(22,Sa,2,1),y(23,"async"),Q()()(),V(24,"div")(25,"button",7),y(26,"async"),Ln("click",function(){return i.onSyncProduct()}),Xe(27,"i",8),V(28,"span"),d(29,"Sync Now"),Q()()()()(),V(30,"div",9)(31,"div"),Xe(32,"i",10),V(33,"span",1),d(34,"Product Details"),Q()(),V(35,"div",11)(36,"div",12)(37,"div"),Xe(38,"img",13),Q(),V(39,"h4",14),d(40,"Coming Soon"),Q()()()()),t&2){let o,r,c;l(11),C((o=x(12,4,i.productCount$))?11:13,o),l(7),C((r=x(19,6,i.productCount$))?18:20,r),l(4),C((c=x(23,8,i.syncTime$))?22:-1,c),l(3),Fn("disabled",!x(26,10,i.isOnline$))}},dependencies:[Se,ze,q,Ye],encapsulation:2})};var Ma=n=>({data:n,type:"unsent"}),xa=n=>({data:n,type:"success"}),Ia=n=>({data:n,type:"fail"}),Ta=(n,e)=>({"table-height":n,"table-height-default":e}),Ea=n=>({ID:n});function wa(n,e){n&1&&pi(0)}function Ra(n,e){if(n&1){let t=E();a(0,"div",4)(1,"button",7),y(2,"async"),S("click",function(){v(t);let o=m();return _(o.uploadUnsentOrders())}),b(3,"i",8),a(4,"span"),d(5,"Upload"),s()()()}if(n&2){let t=m();l(),p("disabled",x(2,1,t.isOnline$)==!1)}}function Na(n,e){n&1&&pi(0)}function Aa(n,e){if(n&1){let t=E();a(0,"div",4)(1,"button",9),S("click",function(){v(t);let o=m();return _(o.clearSuccessUploadedOrders())}),b(2,"i",10),a(3,"span"),d(4,"Clear"),s()()()}}function ka(n,e){n&1&&pi(0)}function Va(n,e){if(n&1){let t=E();a(0,"div",4)(1,"button",11),S("click",function(){v(t);let o=m();return _(o.clearFailedOrders())}),b(2,"i",10),a(3,"span"),d(4,"Clear"),s()()()}}function Fa(n,e){n&1&&b(0,"th")}function La(n,e){if(n&1&&(a(0,"a",18),d(1),s()),n&2){let t=m().$implicit;p("queryParams",j(2,Ea,t.Invoice==null?null:t.Invoice.ID)),l(),D(" ",t.Order.Number," ")}}function Ba(n,e){if(n&1&&d(0),n&2){let t=m().$implicit;D(" ",t.Order.Number," ")}}function Ha(n,e){if(n&1&&(a(0,"span",21),d(1),y(2,"limitText"),s()),n&2){let t=m().$implicit;p("matTooltip",(t==null||t.Variant==null?null:t.Variant.Name.length)>=30?t==null||t.Variant==null?null:t.Variant.Name:""),l(),M(X(2,2,t==null||t.Variant==null?null:t.Variant.Name,30))}}function ja(n,e){if(n&1&&(a(0,"div",19),h(1,Ha,3,5,"span",21),s()),n&2){let t=e.$implicit;l(),C(t?1:-1)}}function Qa(n,e){if(n&1&&(a(0,"span"),d(1),y(2,"number"),s(),a(3,"span",22),d(4,"x"),s(),a(5,"span"),d(6),y(7,"number"),s()),n&2){let t=m().$implicit;l(),M(x(2,2,t==null?null:t.Quantity)),l(5),M(x(7,4,t==null?null:t.Price))}}function Ua(n,e){if(n&1&&(a(0,"div",20),h(1,Qa,8,6),s()),n&2){let t=e.$implicit;l(),C(t?1:-1)}}function Wa(n,e){if(n&1&&(a(0,"span"),d(1),y(2,"number"),s()),n&2){let t=m().$implicit;l(),M(x(2,1,(t==null?null:t.Price)*(t==null?null:t.Quantity)))}}function Ga(n,e){if(n&1&&(a(0,"div",20),h(1,Wa,3,3,"span"),s()),n&2){let t=e.$implicit;l(),C(t?1:-1)}}function qa(n,e){if(n&1){let t=E();a(0,"a",26),S("click",function(){v(t);let o=m(2).$implicit,r=m(3);return _(r.uploadFailedOrder(o))}),b(1,"i",27),s()}}function $a(n,e){if(n&1){let t=E();a(0,"a",28),S("click",function(){v(t);let o=m(2).$implicit,r=m(2).type,c=m();return _(r=="fail"?c.removeFailedOrder(o):c.removeUnsentOrder(o))}),b(1,"i",29),s()}}function Ja(n,e){if(n&1&&(a(0,"td")(1,"div",23),h(2,qa,2,0,"a",24),y(3,"async"),h(4,$a,2,0,"a",25),s()()),n&2){let t=m(3).type,i=m();l(2),C(t=="fail"&&x(3,2,i.isOnline$)?2:-1),l(2),C(i.role.sell.Delete&&t!="success"?4:-1)}}function za(n,e){if(n&1&&(a(0,"tr")(1,"td"),h(2,La,2,4,"a",18)(3,Ba,1,1),s(),a(4,"td")(5,"div"),d(6),y(7,"date"),s(),a(8,"div"),d(9),y(10,"date"),s()(),a(11,"td"),K(12,ja,2,1,"div",19,ot),s(),a(14,"td"),K(15,Ua,2,1,"div",20,ot),s(),a(17,"td"),K(18,Ga,2,1,"div",20,ot),s(),h(20,Ja,5,4,"td"),s()),n&2){let t=e.$implicit,i=m(2).data,o=m();l(2),C(o.activeFilter()==1?2:3),l(4),D(" ",X(7,4,t==null||t.Order==null?null:t.Order.ClientTimestamp,"dd MMM yyyy")," "),l(3),D(" ",X(10,7,t==null||t.Order==null?null:t.Order.ClientTimestamp,"HH:mm")," "),l(3),Z(t.CartItems),l(3),Z(t.CartItems),l(3),Z(t.CartItems),l(2),C((i==null?null:i.length)>0?20:-1)}}function Ya(n,e){if(n&1&&K(0,za,21,10,"tr",null,ve),n&2){let t=m().data;Z(t)}}function Ka(n,e){n&1&&(a(0,"tr",17)(1,"td",30),b(2,"empty-state-table"),s()())}function Za(n,e){if(n&1&&(a(0,"div",12)(1,"table",13)(2,"thead",14)(3,"tr")(4,"th"),d(5,"Number"),s(),a(6,"th"),d(7,"Date"),s(),a(8,"th",15),d(9,"Product"),s(),a(10,"th",16),d(11,"Price"),s(),a(12,"th",16),d(13,"Total"),s(),h(14,Fa,1,0,"th"),s()(),a(15,"tbody"),h(16,Ya,2,0)(17,Ka,3,0,"tr",17),s()()()),n&2){let t=e.data;ui(Ue(4,Ta,(t==null?null:t.length)>0,(t==null?null:t.length)===0)),l(14),C((t==null?null:t.length)>0?14:-1),l(2),C((t==null?null:t.length)>0?16:17)}}var on=class n{localDataService=T(Oe);onlineService=T(he);role=T(_i);toastr=T(F);isOnline$=this.onlineService.getOnlineStatus$();unsentOrders$;failedOrders$;successUploadedOrders$;activeFilter=R(0);onEmptyOfflineOrder=bt();filters=[{label:"Unsent",value:0},{label:"Success",value:1},{label:"Fail",value:2}];constructor(){this.initFailedOrders(),this.initUnsentOrders(),this.initSuccessUploadedOrders()}initFailedOrders(){this.failedOrders$=this.localDataService.failedOrders$.pipe(this.pipeMap(),Le(1))}initSuccessUploadedOrders(){this.successUploadedOrders$=this.localDataService.successUploadedOrders$.pipe(this.pipeMap(),Le(1))}initUnsentOrders(){this.unsentOrders$=$e([this.localDataService.unsentOrders$,this.onlineService.getOnlineStatus$()]).pipe(J(([e,t])=>e),this.pipeMap(),Le(1))}pipeMap(){return ri(J(e=>e.map(t=>me(G,t))))}uploadUnsentOrders(){this.localDataService.uploadOrders().pipe(Y(()=>this.localDataService.totalOfflineOrders$),le(e=>{e===0&&this.onEmptyOfflineOrder.emit()}),Qe(1)).subscribe()}removeUnsentOrder(e){confirm("Are you sure you want to delete this offline order? This action cannot be undone.")&&this.localDataService.removeOrder(e.id).pipe(Y(()=>this.localDataService.totalOfflineOrders$),le(i=>{i===0&&this.onEmptyOfflineOrder.emit()}),Qe(1)).subscribe({next:()=>{this.toastr.success("Success to remove unsent offline order","Success")},error:i=>{this.toastr.error("Failed to remove unsent offline order","Error!")}})}uploadFailedOrder(e){this.localDataService.uploadFailedOrder(e).pipe(Qe(1)).subscribe()}removeFailedOrder(e){confirm("Are you sure you want to delete this offline order? This action cannot be undone.")&&this.localDataService.removeFailedOrder(e.id).pipe(Qe(1)).subscribe({next:()=>{this.toastr.success("Success to remove failed offline order","Success")},error:i=>{this.toastr.error("Failed to remove failed offline order","Error!")}})}clearFailedOrders(){confirm("Are you sure you want to clear all failed offline order? This action cannot be undone.")&&this.localDataService.clearFailedOrders().pipe(Qe(1)).subscribe({next:()=>{this.toastr.success("Success to clear failed offline order","Success")},error:t=>{this.toastr.error("Failed to clear failed offline order","Error!")}})}clearSuccessUploadedOrders(){this.localDataService.clearSuccessUploadedOrder().pipe(Qe(1)).subscribe({next:()=>{this.toastr.success("Success to clear success uploaded offline order","Success")},error:e=>{this.toastr.error("Failed to clear success uploaded offline order","Error!")}})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=N({type:n,selectors:[["app-order-management"]],outputs:{onEmptyOfflineOrder:"onEmptyOfflineOrder"},decls:19,vars:27,consts:[["ORDERS_TABLE",""],[1,"container-fluid"],["tabTitle","Unsent","icon","fa-solid fa-file-invoice"],[4,"ngTemplateOutlet","ngTemplateOutletContext"],[1,"d-flex","justify-content-center","mb-3"],["tabTitle","Success","icon","fa-solid fa-cloud-check","iconColor","#4caf50"],["tabTitle","Failed","icon","fa-regular fa-circle-xmark","iconColor","#f44336"],["matTooltip","Upload all unsent orders to server",1,"btn","btn-success","btn-sm","position-absolute",2,"bottom","10px",3,"click","disabled"],["aria-hidden","true",1,"fa-solid","fa-upload","me-2"],["matTooltip","Clear success uploaded orders",1,"btn","btn-danger","btn-sm","position-absolute",2,"bottom","10px",3,"click"],["aria-hidden","true",1,"fa-solid","fa-trash","me-2"],["matTooltip","Clear failed uploaded orders",1,"btn","btn-danger","btn-sm","position-absolute",2,"bottom","10px",3,"click"],[1,"table-responsive","mb-4","mx-0"],[1,"table"],[1,"thead-light"],[1,"text-start"],[1,"text-end"],[1,"border-bottom-0"],["routerLink","/menu/Orders/Orders/Customer_Invoice/Info","target","_blank",3,"queryParams"],[1,"list-unstyled","text-start"],[1,"list-unstyled","text-end"],[3,"matTooltip"],[1,"mx-3"],[1,"d-flex","justify-content-center"],["matTooltipPosition","above","matTooltip","Sync failed order to server",1,"ms-2","me-2","cursor-pointer"],["matTooltipPosition","above","matTooltip","Remove order from local browser",1,"ms-5","cursor-pointer"],["matTooltipPosition","above","matTooltip","Sync failed order to server",1,"ms-2","me-2","cursor-pointer",3,"click"],["aria-hidden","true",1,"fa-solid","fa-cloud-arrow-up","text-primary","fa-2x"],["matTooltipPosition","above","matTooltip","Remove order from local browser",1,"ms-5","cursor-pointer",3,"click"],["aria-hidden","true",1,"fa-regular","fa-xmark-circle","text-danger","fa-2x"],["colspan","5",1,"border-bottom-0"]],template:function(t,i){if(t&1&&(a(0,"div",1)(1,"custom-tabs")(2,"tab",2),$(3,wa,1,0,"ng-container",3),y(4,"async"),h(5,Ra,6,3,"div",4),y(6,"async"),s(),a(7,"tab",5),$(8,Na,1,0,"ng-container",3),y(9,"async"),h(10,Aa,5,0,"div",4),y(11,"async"),s(),a(12,"tab",6),$(13,ka,1,0,"ng-container",3),y(14,"async"),h(15,Va,5,0,"div",4),y(16,"async"),s()()(),$(17,Za,18,7,"ng-template",null,0,Qn)),t&2){let o,r,c,u=ue(18);l(3),p("ngTemplateOutlet",u)("ngTemplateOutletContext",j(21,Ma,x(4,9,i.unsentOrders$))),l(2),C(((o=x(6,11,i.unsentOrders$))==null?null:o.length)>0?5:-1),l(3),p("ngTemplateOutlet",u)("ngTemplateOutletContext",j(23,xa,x(9,13,i.successUploadedOrders$))),l(2),C(((r=x(11,15,i.successUploadedOrders$))==null?null:r.length)>0&&(i.role.sell!=null&&i.role.sell.Delete)?10:-1),l(3),p("ngTemplateOutlet",u)("ngTemplateOutletContext",j(25,Ia,x(14,17,i.failedOrders$))),l(2),C(((c=x(16,19,i.failedOrders$))==null?null:c.length)>0&&(i.role.sell!=null&&i.role.sell.Delete)?15:-1)}},dependencies:[Se,qn,Mi,Ii,xi,bo,Ho,$t,yi,Kn,Yn,ze,q,Ye,lo],styles:[".table-overflow[_ngcontent-%COMP%], .table-height-default[_ngcontent-%COMP%], .table-height[_ngcontent-%COMP%]{overflow-x:hidden;overflow-y:auto}.table-height[_ngcontent-%COMP%]{max-height:33vh}.table-height-default[_ngcontent-%COMP%]{max-height:37.3vh}@media screen and (min-width: 1280px) and (max-width: 1440px){.table-height[_ngcontent-%COMP%]{max-height:41vh}.table-height-default[_ngcontent-%COMP%]{max-height:50vh}}"]})};function Xa(n,e){if(n&1){let t=E();a(0,"app-setup",8),H("orderHandlingChange",function(o){v(t);let r=m();return A(r.orderUsingLocal,o)||(r.orderUsingLocal=o),_(o)})("productHandlingChange",function(o){v(t);let r=m();return A(r.productUsingLocal,o)||(r.productUsingLocal=o),_(o)})("startConfigChange",function(o){v(t);let r=m();return A(r.configUsingLocal,o)||(r.configUsingLocal=o),_(o)}),s()}if(n&2){let t=m();B("orderHandling",t.orderUsingLocal)("productHandling",t.productUsingLocal)("startConfig",t.configUsingLocal)}}var rn=class n{constructor(e){this.data=e;this.initActiveTab()}modalConfig;dialog=T(te);onlineStatusService=T(he);localDataService=T(Oe);orderUsingLocal=R(!1);productUsingLocal=R(!1);configUsingLocal=R(!1);offlineConfig$=this.onlineStatusService.offlineConfig$.pipe(le(e=>{this.orderUsingLocal.set(e.orderUsingLocal),this.productUsingLocal.set(e.productUsingLocal),this.configUsingLocal.set(e.configUsingLocal)}),Le(1));activeTab=R("SETUP");totalOfflineOrders$=this.localDataService.totalOfflineOrders$.pipe(Le(1));initActiveTab(){this.activeTab.update(e=>(this.data?.activeTab&&(e=this.data.activeTab),e)),this.initModalConfig()}initModalConfig(){this.modalConfig=new ie,this.modalConfig.title="Offline Order Configuration",this.modalConfig.customWidth="600px",this.modalConfig.hideScrollbar=!0,$e([this.localDataService.unsentOrders$.pipe(J(e=>e?.length)),this.onlineStatusService.getOnlineStatus$()]).pipe(ee()).subscribe(([e,t])=>{this.data?.activeTab=="ORDER"&&e>0&&t?(this.modalConfig.hideClose=!0,this.modalConfig.hideFooter=!0):(this.modalConfig.hideClose=!1,this.modalConfig.hideFooter=!1)})}onEmptyOfflineOrder(){this.modalConfig.hideFooter=!1,this.modalConfig.hideClose=!1}onSave(){let e=new _o(this.configUsingLocal(),this.productUsingLocal(),this.orderUsingLocal());this.onlineStatusService.updateOfflineConfigDB(e),this.dialog.close()}onClose(){this.dialog.close()}static \u0275fac=function(t){return new(t||n)(P(fe))};static \u0275cmp=N({type:n,selectors:[["app-modal-offline"]],decls:12,vars:10,consts:[[3,"onCancel","onClose","onOk","config"],[1,"dialog-offline-content"],[1,"dialog-offline-tabs"],["tabTitle","Mode","icon","fa-solid fa-cog",3,"active"],[3,"orderHandling","productHandling","startConfig"],["tabTitle","Orders","icon","fa-solid fa-cart-shopping",3,"active","badge"],[3,"onEmptyOfflineOrder"],["tabTitle","Products","icon","fa-solid fa-box",3,"active"],[3,"orderHandlingChange","productHandlingChange","startConfigChange","orderHandling","productHandling","startConfig"]],template:function(t,i){if(t&1&&(a(0,"modal-material",0),S("onCancel",function(){return i.onClose()})("onClose",function(){return i.onClose()})("onOk",function(){return i.onSave()}),a(1,"content")(2,"div",1)(3,"custom-tabs",2)(4,"tab",3),h(5,Xa,1,3,"app-setup",4),y(6,"async"),s(),a(7,"tab",5),y(8,"async"),a(9,"app-order-management",6),S("onEmptyOfflineOrder",function(){return i.onEmptyOfflineOrder()}),s()(),a(10,"tab",7),b(11,"app-product-sync"),s()()()()()),t&2){let o;p("config",i.modalConfig),l(4),p("active",i.activeTab()=="SETUP"),l(),C((o=x(6,6,i.offlineConfig$))?5:-1,o),l(2),p("active",i.activeTab()=="ORDER")("badge",x(8,8,i.totalOfflineOrders$)),l(3),p("active",i.activeTab()=="PRODUCT")}},dependencies:[Se,Ot,ne,en,Mi,Ii,xi,nn,on,ze],styles:[".dialog-offline-content[_ngcontent-%COMP%]{min-height:360px}"]})};var an=class{RegisterID;InvoiceNumber;Amount};var sn=class{modalConfig=new ie;viewState=4;paymentSuggestion;payLaterEnabled=!1;payNowEnabled=!1;payNowNLaterEnabled=!1;toleranceAmount=0;merchantName;payLaterDueDate;payLaterDueDays;numpadVisible=!1;config;uniquePaymentMethodOnSplit;isCancelEcrTransaction=!1;emoneyType=Di;splitPaymentEnabled=!0;isCashMachineProvideChange=R(!0);constructor(){this.modalConfig.title="Amount to Pay: ",this.modalConfig.disableKeyup=!0,this.modalConfig.customWidth="650px",this.modalConfig.bodyScrollable=!0}mapAppConfigJson(e){this.merchantName=e.PaymentConfigGopay.MerchantName,this.toleranceAmount=e.ModuleSell.ToleranceAmount,this.numpadVisible=e.ModuleSell.NumPadVisible;let t=e.ModuleSell.PaymentDialog;switch(this.config=t,this.uniquePaymentMethodOnSplit=t.UniquePaymentMethodOnSplit,t.EnabledOptions){case 0:this.viewState=0,this.payNowEnabled=!0;break;case 1:this.viewState=1,this.payLaterEnabled=!0;break;case 2:switch(t.DefaultOption){case 0:this.viewState=0;break;case 1:this.viewState=1;break}this.payNowNLaterEnabled=!0;break}}enableEMoneyModal(e){this.modalConfig.backButton=e,this.modalConfig.hideCancel=e,this.modalConfig.hideClose=e,this.modalConfig.hideOk=e}enableEmoneyConfirmModal(e){this.modalConfig.backButton=e,this.modalConfig.hideCancel=e,this.modalConfig.hideClose=e,this.modalConfig.hideOk=e,e?(this.modalConfig.headerType=de.Warning,this.modalConfig.title="Warning! This is QRIS for Testing"):(this.modalConfig.headerType=de.Success,this.modalConfig.title="Amount to Pay: ")}enableModalWaitingEcr(e){this.modalConfig.hideCancel=e,this.modalConfig.hideClose=e,this.modalConfig.hideOk=e,this.isCancelEcrTransaction=!1,e?this.modalConfig.customWidth="550px":(this.modalConfig.customWidth="650px",this.modalConfig.headerType=de.Success,this.modalConfig.title="Amount to Pay: ")}enableModalCashMachine(e){this.modalConfig.hideCancel=e,this.modalConfig.hideOk=e,e?this.modalConfig.customWidth="450px":this.modalConfig.customWidth="650px"}cancelEcrTransaction(){this.modalConfig.title="Waiting Cancel from EDC Machine",this.modalConfig.headerType=de.Warning,this.isCancelEcrTransaction=!0}get isStateNow(){return this.viewState==0}get isStateLater(){return this.viewState==1}get isStateSplit(){return this.viewState==3}get isStateQR(){return this.viewState==2}get isQrisConfirm(){return this.viewState==4}get isWaitingPaymentEcr(){return this.viewState==5}get isCashMachine(){return this.viewState==6}};var ln=class n{constructor(e,t,i,o,r,c,u,O){this._invoiceCalculatorService=e;this._posService=t;this._orderDataService=i;this._orderProcessorService=o;this._onlineStatusService=r;this._signalBroadCast=c;this.decimalPipe=u;this._registerService=O;this.subscribeToObservableChanges(),this.defaultCashPaymentMethodID=this.paymentList[0].ID}defaultCashPaymentMethodID=0;isOnline=!0;salesOrderData=new G;_State;get State(){return this._State}set State(e){this._State=e}get denomination(){return this._posService.Data.Denomination}get appConfigJSON(){return this._posService.Data.AppConfigJSON}get toleranceAmount(){return this.appConfigJSON.ModuleSell.ToleranceAmount}get paymentList(){return f.IsNotEmpty(this._registerService.Data)?this._registerService.Data.Payments:Array()}subscribeToObservableChanges(){this._onlineStatusService.getOnlineStatus$().subscribe(e=>{this.isOnline=e}),this._orderDataService.Data$.subscribe(e=>{this.salesOrderData=e})}getPaymentList(){return this.paymentList}submitOrder(e){this.salesOrderData.Payments=me(Ke,e),this.salesOrderData.Payments=this.removePayment(this.salesOrderData),this._orderDataService.pushNewValue(this.salesOrderData),this._orderDataService.submitOrder(this.appConfigJSON).then(t=>{this.updateBroadcastState(t),t=this.setFinalAmountOfflineOrder(t),this._orderProcessorService.updatePosState(1,t)},t=>{(t instanceof si||t?.name=="TimeoutError")&&(this._orderDataService.pushNewValue(this.salesOrderData),this._orderProcessorService.updatePosState(9))})}updateBroadcastState(e){let t=this.salesOrderData.TotalPaidAmount-this._invoiceCalculatorService.Data;this._signalBroadCast.BroadcastStateToCustomerDisplay(1,e.ObjectID,e.LoyaltyPoint,t).subscribe()}removePayment(e){return e.Payments.filter(i=>i.Amount!==0)}setFinalAmountOfflineOrder(e){return this.isOnline==!1&&(e.Final=this._invoiceCalculatorService.Data),e}generateCashSuggestion(){let e=this.paymentList.filter(i=>i.TypeID==1),t=[];return e.length>0&&(t.push(this._invoiceCalculatorService.Data),this.defaultCashPaymentMethodID=e[0].ID,this.denomination.forEach(i=>{let o=this._invoiceCalculatorService.Data/i;o=Math.ceil(o);let r=o*i;r!=this._invoiceCalculatorService.Data&&t.indexOf(r)===-1&&t.length<3&&t.push(r)})),t}static \u0275fac=function(t){return new(t||n)(g(se),g(z),g(L),g(je),g(he),g(lt),g(q),g(re))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var cn=class n{constructor(e,t,i,o,r){this.httpService=e;this.orderDataService=t;this.ecrLocalstorageService=i;this.ecrSignalR=o;this.toastr=r}onPay(e){let t=this.orderDataService.Data?.Order?.Number,i={Transaction_Type:"01",Transaction_Amount:e,Invoice_Number:t,Expire_Date:2406},o=this.ecrLocalstorageService.url();return $e([this.httpService.post(`${o}/api/Payment/Send`,i),this.ecrSignalR.ecrEvent$]).pipe(J(([r,c])=>c),nt(r=>{let c=r?.message?r?.message:r?.Message;return this.toastr.error(c,"Error"),ft(()=>r)}))}static \u0275fac=function(t){return new(t||n)(g($n),g(L),g(Bt),g(Ht),g(F))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};function ns(n,e){if(n&1&&(V(0,"div",0)(1,"div",2)(2,"h3",3),d(3," Insert Cash into Machine "),Q(),V(4,"p",4),d(5," Feed bills into the cash acceptor slot below the screen "),Q(),V(6,"div",5)(7,"span",6)(8,"span",7),d(9,"\u23F3"),Q(),d(10," Waiting for cash insertion "),Q()(),V(11,"div",8)(12,"div",9)(13,"span",10),d(14,"Amount Received:"),Q(),V(15,"span",11),d(16),y(17,"number"),Q()(),V(18,"div",12)(19,"span",10),d(20,"Remaining Balance:"),Q(),V(21,"span",13),d(22),y(23,"number"),Q()()()(),V(24,"div",14)(25,"div",15)(26,"span",16),d(27,"Payment Progress"),Q(),V(28,"span",17),d(29),y(30,"number"),y(31,"number"),Q()(),V(32,"div",18),Xe(33,"div",19),Q()()()),n&2){let t=m();l(16),D("Rp",x(17,7,t.receivedAmount())),l(6),D("Rp",x(23,9,t.remainingBalance())),l(7),_t("Rp",x(30,11,t.receivedAmount())," / Rp",x(31,13,t.totalAmount())),l(3),mi("aria-valuenow",t.progress()),l(),Bn("width",t.progress(),"%")}}function os(n,e){if(n&1&&(V(0,"div",23),d(1),y(2,"number"),Q()),n&2){let t=m(2);l(),D(" Change: Rp",x(2,1,t.changeDue())," ")}}function rs(n,e){n&1&&(V(0,"div",24),Xe(1,"i",25),V(2,"div",26),d(3,"Manual Change Required"),Q(),V(4,"p",27)(5,"span",28),d(6,"Machine cannot dispense exact change."),Q(),V(7,"span"),d(8,"Please collect change from the cashier."),Q()()())}function as(n,e){n&1&&(V(0,"div",24),Xe(1,"i",25),V(2,"div",26),d(3,"Change Dispensed"),Q(),V(4,"p",27)(5,"span",28),d(6,"The machine has provided your change."),Q(),V(7,"span"),d(8,"Please ensure you have collected your change from the dispenser before closing this window."),Q()()())}function ss(n,e){if(n&1&&h(0,as,9,0,"div",24),n&2){let t=m(2);C(t.changeDue()>0?0:-1)}}function ls(n,e){if(n&1&&(V(0,"div",1)(1,"div",20)(2,"span",21),d(3,"\u2713"),Q()(),V(4,"div",22),d(5," Payment Accepted! "),Q(),h(6,os,3,3,"div",23),h(7,rs,9,0,"div",24)(8,ss,1,1),Q()),n&2){let t=m();l(6),C(t.changeDue()>0?6:-1),l(),C(t.canProvideChange()==!1?7:t.canProvideChange()==!0?8:-1)}}var dn=class n{cashMachineService=T(jt);totalAmount=qt(0);transactionComplete=bt({alias:"onTransactionComplete"});receivedAmount=R(0);paymentState=R("paying");changeDue=R(0);canProvideChange=R(!0);isProcessing=R(!1);remainingBalance=ae(()=>Math.max(0,this.totalAmount()-this.receivedAmount()));progress=ae(()=>{let e=this.totalAmount();return e===0?0:Math.min(100,this.receivedAmount()/e*100)});constructor(){this.initListenCashMachine(),this.initWithdrawStatus()}initListenCashMachine(){this.cashMachineService.cashMachineEvent$.pipe(ee()).subscribe(e=>{if(!e||e.length===0)return;let t=e.map(i=>i.value).reduce((i,o)=>i+o,0);this.insertCash(t)})}initWithdrawStatus(){this.cashMachineService.withdrawMoneyStatus$.pipe(ee()).subscribe(e=>{this.canProvideChange.set(e),this.changeDue()>0&&this.completeTransaction()})}insertCash(e){this.isProcessing()||(this.receivedAmount.update(t=>t+e),this.receivedAmount()>=this.totalAmount()&&setTimeout(()=>this.showSuccessState(),500))}showSuccessState(){this.isProcessing.set(!0);let e=this.receivedAmount()-this.totalAmount();this.changeDue.set(e),this.paymentState.set("success"),this.checkCanProvideChange()}checkCanProvideChange(){this.changeDue()===0?this.completeTransaction():this.cashMachineService.sendWithdrawMoney(this.changeDue())}completeTransaction(){this.transactionComplete.emit({changeDue:this.changeDue(),canProvideChange:this.canProvideChange()})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=N({type:n,selectors:[["cash-machine-payment"]],inputs:{totalAmount:[1,"totalAmount"]},outputs:{transactionComplete:"onTransactionComplete"},decls:2,vars:1,consts:[["id","paymentContent"],["id","successState",1,"animate-successPulse","py-3"],[1,"instruction-card"],[1,"text-body-emphasis","fw-bold","mb-2","text-center"],[1,"text-secondary-emphasis","fw-medium","mb-3","text-center"],[1,"text-center","mt-6"],[1,"badge","rounded-pill","fs-6","bg-warning-subtle","text-warning-emphasis","fw-medium","py-4","px-4","border","border-warning-subtle"],[1,"animate-pulse-opacity","me-1"],[1,"payment-info-card"],[1,"d-flex","justify-content-between","align-items-center","mb-2","fs-5"],[1,"info-label","fw-medium"],[1,"info-value","fw-bold","text-success"],[1,"d-flex","justify-content-between","align-items-center","fs-5"],[1,"info-value","fw-bold","text-danger"],[1,"progress-container","px-2"],[1,"d-flex","justify-content-between","align-items-center","mb-1"],[1,"small","fw-semibold","text-body-secondary","fs-6"],[1,"small","fw-bold","text-success","fs-6"],["role","progressbar","aria-label","Payment Progress","aria-valuemin","0","aria-valuemax","100",1,"progress",2,"height","8px"],[1,"progress-bar","bg-success"],[1,"success-icon"],[1,"fw-bold"],[1,"h1","fw-semibold","text-success","mb-6","text-center"],[1,"h1","fw-bold","text-body-emphasis","mb-8","text-center"],[1,"alert","alert-warning","d-flex","flex-column","align-items-center","p-5","border","border-warning","border-1"],[1,"fas","fa-exclamation-triangle","text-warning",2,"font-size","24px"],[1,"h4","fw-bold","mt-2"],[1,"small","text-warning-emphasis","mb-2","fs-6","mt-2","text-center"],[1,"me-1"]],template:function(t,i){t&1&&h(0,ns,34,15,"div",0)(1,ls,9,2,"div",1),t&2&&C(i.paymentState()==="paying"?0:1)},dependencies:[Se,q],styles:[".instruction-card[_ngcontent-%COMP%]{background:linear-gradient(135deg,#f8f9fa,#e9ecef);border:2px solid var(--bs-success);border-radius:1rem;padding:1.5rem;margin-bottom:2rem;position:relative;box-shadow:0 .5rem 1rem #19875426}.payment-info-card[_ngcontent-%COMP%]{background-color:#1987540d;border-radius:.75rem;padding:1rem;margin-top:1rem;border:1px solid rgba(25,135,84,.2)}.success-icon[_ngcontent-%COMP%]{width:5rem;height:5rem;background-color:var(--bs-success);border-radius:50%;display:flex;align-items:center;justify-content:center;margin:0 auto 1.25rem;color:#fff;font-size:3rem;box-shadow:0 .5rem 1.5rem #1987544d}.progress-bar[_ngcontent-%COMP%]{background:linear-gradient(90deg,#198754,#28a745);transition:width .5s ease}@keyframes _ngcontent-%COMP%_shimmer{0%,to{transform:rotate(0) scale(2);opacity:0}50%{transform:rotate(180deg) scale(2);opacity:.1}}@keyframes _ngcontent-%COMP%_glow{0%{box-shadow:0 0 5px #198754}to{box-shadow:0 0 15px #1eac67,0 0 25px #1eac67}}@keyframes _ngcontent-%COMP%_pulse-opacity{0%,to{opacity:1}50%{opacity:.5}}@keyframes _ngcontent-%COMP%_successPulse{0%{transform:scale(0)}50%{transform:scale(1.1)}to{transform:scale(1)}}@keyframes _ngcontent-%COMP%_attention{0%,to{transform:scale(1)}50%{transform:scale(1.1)}}.animate-shimmer[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_shimmer 3s ease-in-out infinite}.animate-glow[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_glow 2s ease-in-out infinite alternate}.animate-pulse-opacity[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_pulse-opacity 2s infinite}.animate-successPulse[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_successPulse .6s ease-out}.animate-attention[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_attention 2s ease-in-out infinite}"]})};function ds(n,e){n&1&&(a(0,"div",0)(1,"div",1),b(2,"img",2),s()(),a(3,"div",0)(4,"div",3)(5,"p",4),d(6," Please insert or swipe Debit/Credit Card for complete this transaction "),s()()())}function ms(n,e){n&1&&(a(0,"div",0)(1,"div",5),b(2,"i",6),s(),a(3,"div",7)(4,"p",8),d(5," Please cancel the order at EDC machine by pressing the Cancel button "),a(6,"span",9),d(7,"(RED)"),s(),d(8," for clear currently amount "),s()()())}var mn=class n{isCancel=!1;constructor(){}ngOnInit(){}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=N({type:n,selectors:[["app-modal-ecr-info"]],inputs:{isCancel:"isCancel"},standalone:!1,decls:2,vars:1,consts:[[1,"row"],[1,"col-12","d-flex","align-items-center","justify-content-center","pe-12","ps-0"],["src","https://cdn.dealpos.xyz/web-image/EDC-Biru.png","alt",""],[1,"col-12","ps-0","d-flex","align-items-center","justify-content-center"],[1,"mb-2","fs-5","text-body-secondary"],[1,"col-2","d-flex","align-items-center","justify-content-center","pe-0"],[1,"fa-regular","fa-circle-xmark","text-danger",2,"font-size","40px"],[1,"col-10","d-flex","align-items-center","justify-content-center"],[1,"mb-2","px-3","fs-5","text-body-secondary"],[1,"text-danger","fw-bold"]],template:function(t,i){t&1&&h(0,ds,7,0)(1,ms,9,0,"div",0),t&2&&C(i.isCancel?1:0)},encapsulation:2})};var pn=class n{constructor(){}ngOnInit(){}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=N({type:n,selectors:[["app-confirm-demo-qris"]],standalone:!1,decls:22,vars:0,consts:[[1,"row"],[1,"col-4","d-flex","align-items-center","justify-content-center","pe-0"],["src","https://cdn.dealpos.xyz/web-image/QR_Test.png","width","115px","alt",""],[1,"col-8","ps-0"],[1,"mt-10"],["href","https://www.dealpos.co.id/tour/mobile-payment","target","_blank"],[1,"fw-bold"]],template:function(t,i){t&1&&(a(0,"div",0)(1,"div",1),b(2,"img",2),s(),a(3,"div",3)(4,"h4"),d(5,"WARNING"),s(),a(6,"p",4),d(7," You need to complete "),a(8,"a",5),d(9,"Regristration"),s(),d(10," with our payment Partner - "),a(11,"span",6),d(12,"Midtrans"),s(),d(13," before you can start accpeting "),a(14,"span",6),d(15,"QRIS Payment"),s(),d(16," and receive Pay Out at your Bank Account. "),s(),a(17,"p"),d(18," If you wish to test how this functionality works, we have provided a Sandbox account for "),a(19,"span",6),d(20,"Testing"),s(),d(21," purpose. "),s()()())},encapsulation:2})};var En=n=>({selected:n}),fs=(n,e)=>({active:n,"font-12":e}),hs=n=>({"border-top py-5":n}),Cs=n=>({"d-print-none":n}),vs=n=>({"qris-barcode":n}),_s=n=>({bottom:n});function ys(n,e){if(n&1&&(a(0,"span"),d(1),s()),n&2){let t=m(2);l(),D(" (+",t.posData==null?null:t.posData.Invoice.SurchargePcg,"%) ")}}function bs(n,e){if(n&1&&(a(0,"header")(1,"div",6),$(2,ys,2,1,"span",1),d(3),y(4,"number"),s()()),n&2){let t=m();l(2),p("ngIf",(t.posData==null?null:t.posData.Invoice.SurchargePcg)>0),l(),D(" ",t.userRole.PriceVisible?x(4,2,t.totalAmount()):"-"," ")}}function Ss(n,e){if(n&1){let t=E();a(0,"a",14),S("click",function(){v(t);let o=m(4);return _(o.onSplitClick())}),d(1," Split "),a(2,"span",15),d(3,"Payment"),s()()}if(n&2){let t=m(4);p("ngClass",j(1,En,t.modalFields.isStateSplit))}}function Ps(n,e){if(n&1){let t=E();a(0,"a",16),S("click",function(){v(t);let o=m(4);return _(o.onLaterClick())}),d(1," Later "),a(2,"span",15),d(3,"Take Credit"),s()()}if(n&2){let t=m(4);p("ngClass",j(1,En,t.modalFields.isStateLater))}}function Os(n,e){if(n&1){let t=E();a(0,"div")(1,"a",11),S("click",function(){v(t);let o=m(3);return _(o.onNowClick())}),d(2," Now "),s(),$(3,Ss,4,3,"a",12)(4,Ps,4,3,"a",13),s()}if(n&2){let t=m(3);l(),p("ngClass",j(3,En,t.modalFields.isStateNow)),l(2),p("ngIf",((t.modalFields==null||t.modalFields.paymentSuggestion==null?null:t.modalFields.paymentSuggestion.length)==0||t.cashPaymentChange<0)&&t.modalFields.splitPaymentEnabled),l(),p("ngIf",t.modalFields.payNowEnabled==!1&&!t.userRole.CreditSalesLock)}}function Ds(n,e){if(n&1&&(a(0,"div",10),$(1,Os,5,5,"div",1),s()),n&2){let t=m(2);l(),p("ngIf",t.modalFields.payNowNLaterEnabled||t.modalFields.payNowEnabled)}}function Ms(n,e){if(n&1){let t=E();a(0,"div",31)(1,"a",32),S("click",function(){let o=v(t).$implicit,r=m(5);return _(r.updateCashPayment(o))}),d(2),y(3,"number"),s()()}if(n&2){let t=e.$implicit,i=m(5);l(),p("ngClass",Ue(5,fs,(i.Payments[0]==null?null:i.Payments[0].MethodID)==i.defaultCashPaymentMethodID&&(i.Payments[0]==null?null:i.Payments[0].PaidAmount)==t,i.modalFields.paymentSuggestion[0].toString().length>8)),l(),_t("",i.cashierCalculatorService==null?null:i.cashierCalculatorService.currencySymbol," ",x(3,3,t))}}function xs(n,e){if(n&1&&(a(0,"div",29),$(1,Ms,4,8,"div",30),s()),n&2){let t=m(4);l(),p("ngForOf",t.modalFields.paymentSuggestion)}}function Is(n,e){if(n&1&&(a(0,"div",33),d(1),y(2,"number"),s()),n&2){let t=m(4);p("ngClass",t.cashPaymentChange>0?"success":"danger"),l(),_t(" ",t.cashierCalculatorService==null?null:t.cashierCalculatorService.currencySymbol," ",x(2,3,t.cashPaymentChange)," ")}}function Ts(n,e){if(n&1){let t=E();Ct(0),a(1,"div",17)(2,"div",21),b(3,"i",22),d(4," Cash "),s(),a(5,"div",23),$(6,xs,2,1,"div",24),a(7,"div",25)(8,"div",26)(9,"input",27),H("ngModelChange",function(o){v(t);let r=m(3);return A(r.inputAmountString,o)||(r.inputAmountString=o),_(o)}),S("ngModelChange",function(){v(t);let o=m(3);return _(o.updateCashPayment(o.inputAmountString))}),s(),$(10,Is,3,5,"div",28),s()()()(),vt()}if(n&2){let t=m(3);l(6),p("ngIf",t.userRole.PriceVisible),l(3),p("simpleKeyboard",t.keyboard),B("ngModel",t.inputAmountString),l(),p("ngIf",t.cashPaymentChange!=0)}}function Es(n,e){if(n&1){let t=E();a(0,"div",36)(1,"button",37),S("click",function(){let o=v(t).$implicit,r=m(4);return _(r.handlingCashMachinePayment(o))}),a(2,"span",38),b(3,"img",39),s(),a(4,"span",38),d(5),y(6,"limitTo"),s()()()}if(n&2){let t=e.$implicit;l(2),p("hidden",t.ImageUrl==null),l(),p("src",t.ImageUrl,dt),l(),p("hidden",t.ImageUrl!=null),l(),D(" ",X(6,4,t.Name,20)," ")}}function ws(n,e){if(n&1&&(a(0,"div",17)(1,"div",21),b(2,"i",34),d(3," Cash Machine "),s(),a(4,"div",23)(5,"div",35),K(6,Es,7,7,"div",36,ot),s()()()),n&2){let t=m(3);l(6),Z(t.cashMachineList())}}function Rs(n,e){if(n&1){let t=E();a(0,"div",36)(1,"button",37),S("click",function(){let o=v(t).$implicit,r=m(4);return r.onPaymentMethodChanged(o),_(r.payWithEmoney(o))}),a(2,"span",38),b(3,"img",39),s(),a(4,"span",38),d(5),y(6,"limitTo"),s()()()}if(n&2){let t=e.$implicit;l(2),p("hidden",t.ImageUrl==null),l(),p("src",t.ImageUrl,dt),l(),p("hidden",t.ImageUrl!=null),l(),D(" ",X(6,4,t.Name,20)," ")}}function Ns(n,e){if(n&1&&(a(0,"div",17)(1,"div",21),b(2,"i",40),d(3," QRIS "),s(),a(4,"div",23)(5,"div",35),$(6,Rs,7,7,"div",41),s()()()),n&2){let t=m(3);l(6),p("ngForOf",t.getTypePaymentList(3))}}function As(n,e){if(n&1&&(a(0,"span"),b(1,"img",39),s()),n&2){let t=m().$implicit;l(),p("src",t.ImageUrl,dt)}}function ks(n,e){if(n&1&&(a(0,"span"),d(1),y(2,"limitTo"),s()),n&2){let t=m().$implicit;l(),D(" ",X(2,1,t.Name,20)," ")}}function Vs(n,e){if(n&1){let t=E();a(0,"div",36)(1,"button",37),S("click",function(){let o=v(t).$implicit,r=m(4);return _(r.handlingSubmitOrderWithEcr(o))}),$(2,As,2,1,"span",1)(3,ks,3,4,"span",1),s()()}if(n&2){let t=e.$implicit;l(2),p("ngIf",t.ImageUrl!=null),l(),p("ngIf",t.ImageUrl==null)}}function Fs(n,e){if(n&1&&(a(0,"div",42)(1,"div",21),b(2,"i",43),d(3," ECR / EDC "),s(),a(4,"div",23)(5,"div",25),$(6,Vs,4,2,"div",41),s()()()),n&2){let t=m(3);l(6),p("ngForOf",t.getTypePaymentList(99))}}function Ls(n,e){if(n&1&&(a(0,"div",21),b(1,"i"),d(2),s()),n&2){let t=m().$implicit;l(),ui(t.Icon),l(),D(" ",t.Name," ")}}function Bs(n,e){if(n&1){let t=E();a(0,"div",36)(1,"a",48),S("click",function(){let o=v(t).$implicit,r=m(5);return _(r.onPaymentMethodChanged(o))}),d(2),y(3,"limitTo"),s()()}if(n&2){let t=e.$implicit,i=m(5);l(),p("ngClass",i.Payments[0].MethodID===t.ID?"active":""),l(),D(" ",X(3,2,t.Name,20)," ")}}function Hs(n,e){n&1&&(a(0,"small",53),d(1," Payment Note is required "),s())}function js(n,e){n&1&&(a(0,"small",53),d(1," Payment Code is required "),s())}function Qs(n,e){n&1&&(a(0,"small",53),d(1," Please input maximum 1 characters "),s())}function Us(n,e){if(n&1&&(h(0,js,2,0,"small",53),h(1,Qs,2,0,"small",53)),n&2){let t=m(6);C(t.paymentCodeCtrl.hasError("required")?0:-1),l(),C(t.paymentCodeCtrl.hasError("maxlength")?1:-1)}}function Ws(n,e){if(n&1&&(a(0,"div",49)(1,"div",50)(2,"div",51),b(3,"input",52),h(4,Hs,2,0,"small",53),s(),a(5,"div",51),b(6,"input",54),h(7,Us,2,2),s()()()),n&2){let t=m(5);l(3),p("formControl",t.paymentNoteCtrl),l(),C(t.paymentNoteCtrl.invalid&&(t.paymentNoteCtrl.dirty||t.paymentNoteCtrl.touched)?4:-1),l(2),p("formControl",t.paymentCodeCtrl),l(),C(t.paymentCodeCtrl.dirty||t.paymentCodeCtrl.touched?7:-1)}}function Gs(n,e){if(n&1&&(a(0,"div",23)(1,"div",25),$(2,Bs,4,5,"div",41),s(),$(3,Ws,8,4,"div",47),s()),n&2){let t=m().$implicit,i=m(3);l(2),p("ngForOf",i.getTypePaymentList(t.ID)),l(),p("ngIf",i.isOtherPayment(t.ID))}}function qs(n,e){if(n&1&&(a(0,"div",44),$(1,Ls,3,3,"div",45)(2,Gs,4,2,"div",46),s()),n&2){let t=e.$implicit,i=m(3);p("ngClass",j(3,hs,i.getTypePaymentList(t.ID).length>0)),l(),p("ngIf",i.getTypePaymentList(t.ID).length>0),l(),p("ngIf",i.getTypePaymentList(t.ID).length>0)}}function $s(n,e){if(n&1&&(a(0,"div"),$(1,Ts,11,4,"ng-container",1),h(2,ws,8,0,"div",17),$(3,Ns,7,1,"div",18)(4,Fs,7,1,"div",19)(5,qs,3,5,"div",20),s()),n&2){let t,i=m(2);l(),p("ngIf",(i.modalFields==null||i.modalFields.paymentSuggestion==null?null:i.modalFields.paymentSuggestion.length)>0),l(),C(((t=i.cashMachineList())==null?null:t.length)>0?2:-1),l(),p("ngIf",i.getTypePaymentList(3).length>0&&i.isOnline),l(),p("ngIf",i.getTypePaymentList(99).length>0&&i.isOnline),l(),p("ngForOf",i.paymentTypes)}}function Js(n,e){if(n&1){let t=E();a(0,"div")(1,"div",55)(2,"strong",56),d(3,"Due"),s(),a(4,"datepicker",57),H("dateChange",function(o){v(t);let r=m(2);return A(r.modalFields.payLaterDueDate,o)||(r.modalFields.payLaterDueDate=o),_(o)}),S("dateChange",function(){v(t);let o=m(2);return _(o.dueDateChange())}),s()(),a(5,"div",58)(6,"strong",59),d(7,"Days Due"),s(),a(8,"input",60),H("ngModelChange",function(o){v(t);let r=m(2);return A(r.modalFields.payLaterDueDays,o)||(r.modalFields.payLaterDueDays=o),_(o)}),S("ngModelChange",function(){v(t);let o=m(2);return _(o.dueDayChange())}),s()()()}if(n&2){let t=m(2);l(4),B("date",t.modalFields.payLaterDueDate),p("displayToggle",!1),l(4),p("simpleKeyboard",t.keyboard),B("ngModel",t.modalFields.payLaterDueDays)}}function zs(n,e){if(n&1){let t=E();Ct(0),a(1,"div",25)(2,"div",62)(3,"div",63)(4,"strong",64),d(5,"Payment 1:"),s()(),a(6,"div")(7,"ng-select",65),S("change",function(o){v(t);let r=m(3);return _(r.onPaymentMethodChanged(o))}),s()()(),a(8,"div",66)(9,"div",63)(10,"strong",67),d(11,"Amount 1:"),s()(),a(12,"div")(13,"input",68),S("ngModelChange",function(o){v(t);let r=m(3);return _(r.onFirstPaymentSplitChange(o))}),s()()()(),vt()}if(n&2){let t=m(3);l(7),p("items",t.firstPaymentSplitOptions)("ngModel",t.firstPayment==null?null:t.firstPayment.MethodID)("clearable",!1),l(6),p("ngModel",t.firstPayment.PaidAmount)}}function Ys(n,e){n&1&&(a(0,"small",53),d(1," Payment Note is required "),s())}function Ks(n,e){n&1&&(a(0,"small",53),d(1," Payment Code is required "),s())}function Zs(n,e){n&1&&(a(0,"small",53),d(1," Please input maximum 1 characters "),s())}function Xs(n,e){if(n&1&&(h(0,Ks,2,0,"small",53),h(1,Zs,2,0,"small",53)),n&2){let t=m(5);C(t.paymentCodeCtrl2.hasError("required")?0:-1),l(),C(t.paymentCodeCtrl2.hasError("maxlength")?1:-1)}}function el(n,e){if(n&1&&(a(0,"div",75)(1,"div",50)(2,"div",51),b(3,"input",52),h(4,Ys,2,0,"small",53),s(),a(5,"div",51),b(6,"input",54),h(7,Xs,2,2),s()()()),n&2){let t=m(4);l(3),p("formControl",t.paymentNoteCtrl2),l(),C(t.paymentNoteCtrl2.invalid&&(t.paymentNoteCtrl2.dirty||t.paymentNoteCtrl2.touched)?4:-1),l(2),p("formControl",t.paymentCodeCtrl2),l(),C(t.paymentCodeCtrl2.dirty||t.paymentCodeCtrl2.touched?7:-1)}}function tl(n,e){if(n&1){let t=E();Ct(0),a(1,"div",69)(2,"div",70)(3,"div",71)(4,"div",63)(5,"strong",64),d(6,"Payment 2:"),s()(),a(7,"div")(8,"ng-select",72),S("change",function(o){v(t);let r=m(3);return _(r.onSplitPaymentMethodAssigned(o))}),s()()(),a(9,"div",73)(10,"strong",67),d(11,"Amount 2:"),s(),a(12,"span",74),d(13),y(14,"number"),s()()()(),h(15,el,8,4,"div",75),vt()}if(n&2){let t=m(3);l(8),p("items",t.splitPaymentMethodList)("ngModel",t.Payments[1]==null?null:t.Payments[1].MethodID),l(5),M(x(14,4,t.paymentSplitDefaultVal)),l(2),C((t.Payments[1]==null?null:t.Payments[1].TypeID)!==t.paymentType.ECR&&(t.Payments[1]==null?null:t.Payments[1].TypeID)!==t.paymentType.emoney&&(t.Payments[1]==null?null:t.Payments[1].TypeID)!==t.paymentType.cash&&t.Payments[1]?15:-1)}}function il(n,e){if(n&1&&(a(0,"div",61),$(1,zs,14,4,"ng-container",1)(2,tl,16,6,"ng-container",1),s()),n&2){let t=m(2);l(),p("ngIf",(t.modalFields==null||t.modalFields.paymentSuggestion==null?null:t.modalFields.paymentSuggestion.length)==0),l(),p("ngIf",t.cashPaymentChange<0)}}function nl(n,e){if(n&1&&(a(0,"div",7),$(1,Ds,2,1,"div",8)(2,$s,6,5,"div",1)(3,Js,9,4,"div",1)(4,il,3,2,"div",9),s()),n&2){let t=m();l(),p("ngIf",t.modalFields.payLaterEnabled==!1),l(),p("ngIf",t.modalFields.isStateNow),l(),p("ngIf",t.modalFields.isStateLater&&!t.userRole.CreditSalesLock),l(),p("ngIf",t.modalFields.isStateSplit)}}function ol(n,e){if(n&1&&(Ct(0),a(1,"div",87),b(2,"img",88),s(),vt()),n&2){let t=m(2);l(),p("ngStyle",j(1,_s,t.modalFields.merchantName?"0px":"-25px"))}}function rl(n,e){if(n&1&&(a(0,"h2",89),d(1),s()),n&2){let t=m(2);l(),D(" ",t.modalFields.merchantName," ")}}function al(n,e){if(n&1&&(a(0,"div",76)(1,"div",77)(2,"span",78),d(3),s(),a(4,"div",79)(5,"div",80)(6,"span",81),d(7,"Invoice"),s(),a(8,"span"),d(9,":"),s()(),a(10,"div",82)(11,"span",83),d(12),s()()(),a(13,"div",79)(14,"div",80)(15,"span"),d(16,"Amount"),s(),a(17,"span"),d(18,":"),s()(),a(19,"div",82)(20,"span",83),d(21),y(22,"number"),s()()()(),$(23,ol,3,3,"ng-container",1)(24,rl,2,1,"h2",84),a(25,"div",85),b(26,"img",86),s()()),n&2){let t=m();l(2),p("ngClass",j(11,Cs,(t.selectedPaymentMethod==null?null:t.selectedPaymentMethod.EMoneyTypeID)!=(t.modalFields==null?null:t.modalFields.emoneyType.Gopay))),l(),M(t.modalFields==null?null:t.modalFields.merchantName),l(9),M(t.posData==null||t.posData.Order==null?null:t.posData.Order.Number),l(9),_t("",t.cashierCalculatorService.currencySymbol," ",x(22,9,t.totalAmount())),l(2),p("ngIf",(t.selectedPaymentMethod==null?null:t.selectedPaymentMethod.EMoneyTypeID)==(t.modalFields==null?null:t.modalFields.emoneyType.Gopay)),l(),p("ngIf",t.modalFields.merchantName&&(t.selectedPaymentMethod==null?null:t.selectedPaymentMethod.EMoneyTypeID)==(t.modalFields==null?null:t.modalFields.emoneyType.Gopay)),l(2),p("src",t.qrImage,dt)("ngClass",j(13,vs,(t.selectedPaymentMethod==null?null:t.selectedPaymentMethod.EMoneyTypeID)==(t.modalFields==null?null:t.modalFields.emoneyType.Gopay)))}}function sl(n,e){n&1&&b(0,"app-confirm-demo-qris")}function ll(n,e){if(n&1&&(Ct(0),b(1,"app-modal-ecr-info",90),vt()),n&2){let t=m();l(),p("isCancel",t.modalFields.isCancelEcrTransaction)}}function cl(n,e){if(n&1){let t=E();a(0,"cash-machine-payment",91),S("onTransactionComplete",function(o){v(t);let r=m();return _(r.onCashMachineTransactionComplete(o))}),s()}if(n&2){let t=m();p("totalAmount",t.totalAmount())}}function dl(n,e){if(n&1){let t=E();a(0,"button",94),S("click",function(){v(t);let o=m(2);return _(o.onCancelCashMachine())}),d(1," Cancel "),s()}}function ml(n,e){if(n&1){let t=E();a(0,"button",95),S("click",function(){v(t);let o=m(2);return _(o.onCashMachineNotProvideChange())})("keyup.F2",function(){v(t);let o=m(2);return _(o.onCashMachineNotProvideChange())}),d(1," Ok "),s()}}function pl(n,e){if(n&1&&h(0,dl,2,0,"button",92)(1,ml,2,0,"button",93),n&2){let t=m();C(t.modalFields.isCashMachineProvideChange()?0:1)}}function ul(n,e){if(n&1){let t=E();a(0,"a",94),S("click",function(){v(t);let o=m();return _(o.onPrintQR())}),b(1,"i",96),d(2,"Print QR "),s()}}function gl(n,e){if(n&1){let t=E();a(0,"a",94),S("click",function(){v(t);let o=m();return _(o.validateEMoneyPayment())}),d(1," Verify Payment Settlement "),s()}}function fl(n,e){if(n&1){let t=E();a(0,"a",94),S("click",function(){v(t);let o=m();return _(o.onCancelWaitingEcr())}),d(1),s()}if(n&2){let t=m();l(),D(" ",t.modalFields.isCancelEcrTransaction?"Close":"Cancel"," ")}}function hl(n,e){if(n&1){let t=E();a(0,"a",94),S("click",function(){v(t);let o=m();return _(o.onBack())}),d(1," Back "),s()}}function Cl(n,e){if(n&1){let t=E();a(0,"a",94),S("click",function(){v(t);let o=m();return _(o.onContinueDemoQr())}),d(1," Continue "),s()}}var un=class n{constructor(e,t,i,o,r,c,u,O,k,W,ye,_n,Rn,nr,yn,bn,Nn,$l,Jl){this.dialogRef=e;this._orderDataService=t;this.cashierCalculatorService=i;this._paymentService=o;this._posHubService=r;this._posService=c;this._toastr=u;this._paymentGatewayService=O;this.decimalPipe=k;this.sanitizer=W;this._orderProcessorService=ye;this._numpadService=_n;this._userRoleService=Rn;this._customerHttpService=nr;this._onlineStatusService=yn;this._ecrService=bn;this.outletService=Nn;this.ecrSignalService=$l;this.cashMachineService=Jl;this.paymentSplitDefaultVal=0,this.defaultCashPaymentMethodID=0,this.destroy$=new Me,this.AppConfigJSON=this._posService.Data.AppConfigJSON,this.modalFields.mapAppConfigJson(this.AppConfigJSON),this.initializeDefaultValues(),this.subscribeToObservableChanges()}modalFields=new sn;userRole;posData=new G;AppConfigJSON=new st;keyboard;paymentType=Xt;Payments=[];defaultCashPaymentMethodID;inputAmountString=null;qrImage;paymentMethodList;paymentTypes;paymentSplitDefaultVal;posState;splitPaymentMethodList;isOnline=!0;get firstPayment(){return this.Payments[0]}set firstPayment(e){this.Payments[0]=e}selectedPaymentMethod;get cashPaymentChange(){let e=this.cashierCalculatorService.Data;return(this.firstPayment?this.firstPayment.PaidAmount:0)-e}firstPaymentSplitOptions;destroy$;paymentNoteCtrl;paymentCodeCtrl;paymentNoteCtrl2;paymentCodeCtrl2;totalAmount=ae(()=>this.cashierCalculatorService.Data);cashMachineList=ae(()=>this.getTypePaymentList(1).filter(t=>t.SubTypeID==4));subscribeToObservableChanges(){this._orderDataService.Data$.pipe(Ie(this.destroy$)).subscribe(e=>{this.posData=e}),this._orderProcessorService.Data$.pipe(Ie(this.destroy$)).subscribe(e=>{this.posState=e.posState,this.initializeInvoicePaymentsValue(this.posState),this.initTabState()}),this._onlineStatusService.getOnlineStatus$().pipe(Ie(this.destroy$)).subscribe(e=>{this.isOnline=e})}initCashFocus(){let e=document.getElementById("cashInput");if(e){e.focus();let t=e?.value?.length;setTimeout(()=>{e.setSelectionRange(t,t)},0)}}initTabState(){if(this.posState==2)switch(this.posData.Invoice.PaymentStateID){case 3:this.modalFields.viewState=0;break;case 1:this.modalFields.viewState=1;break}}initializeInvoicePaymentsValue(e){e!==2?(this.firstPayment=new Ke,this.firstPayment.Amount=this.cashierCalculatorService.Data,this.firstPayment.PaidAmount=this.cashierCalculatorService.Data,this.firstPayment.MethodID=this.defaultCashPaymentMethodID,this.firstPayment.TypeID=1):(this.Payments=this.posData.Payments,this.initFirstPayment()),this.initPaymentNoteAndCode(this.firstPayment)}initFirstPayment(){if(!this.firstPayment)this.firstPayment=new Ke,this.firstPayment.Amount=this.cashierCalculatorService.Data,this.firstPayment.PaidAmount=this.cashierCalculatorService.Data,this.firstPayment.MethodID=this.defaultCashPaymentMethodID,this.modalFields.viewState=1;else if(this.posData.Invoice.PaymentStateID==3)if(this.Payments.length>1)this.initSplitPayment(),this.initPaymentNoteAndCodeSplit(this.Payments[1]);else{let t=this.findPaymentMethodByID(this.firstPayment.MethodID);this.firstPayment.PaidAmount=this.cashierCalculatorService.Data,this.firstPayment.Amount=this.cashierCalculatorService.Data,this.firstPayment.MethodID=this.Payments[0].MethodID,this.firstPayment.TypeID=t?.TypeID}let e=this.firstPayment.PaidAmount;this.inputAmountString=e?e.toString():null}findPaymentMethodByID(e){return this._paymentService.getPaymentList()?.find(o=>o.ID==e)}initPaymentNoteAndCode(e){let t=this.getPaymentNoteAndCodeValidators(e);this.paymentCodeCtrl?(this.paymentCodeCtrl.setValue(e?.Code),this.paymentNoteCtrl.setValue(e?.Note),this.paymentCodeCtrl.setValidators(t.paymentCodeValidators),this.paymentNoteCtrl.setValidators(t.paymentNoteValidators),this.paymentCodeCtrl.updateValueAndValidity(),this.paymentNoteCtrl.updateValueAndValidity()):(this.paymentCodeCtrl=new et(e?.Code,t.paymentCodeValidators),this.paymentNoteCtrl=new et(e?.Note,t.paymentNoteValidators))}getPaymentNoteAndCodeValidators(e){let t=this.AppConfigJSON?.ModuleSell?.PaymentDialog,i=this.userRole.PaymentCodeLock,o=[],r=[];if(e&&e?.TypeID!=1&&e?.TypeID!=99&&e?.TypeID!=3){let c=i?[Ci.maxLength(1)]:[],u=t.PaymentCodeRequired?[Ci.required]:[];o=[...c,...u],r=t.PaymentNoteRequired?[Ci.required]:[]}return{paymentCodeValidators:o,paymentNoteValidators:r}}initSplitPayment(){let e=this.cashierCalculatorService.Data,t=this.Payments[1].PaidAmount,i=e-t;this.firstPayment.PaidAmount=i,this.firstPayment.Amount=i,this.paymentSplitDefaultVal=t,this.filterSplitPaymentList()}initializeDefaultValues(){this.modalFields.paymentSuggestion=this._paymentService.generateCashSuggestion(),this.paymentMethodList=this.outletService.Data.Payments,this.paymentTypes=this._posService.Data.PaymentTypes,this.defaultCashPaymentMethodID=this._paymentService.defaultCashPaymentMethodID,this.modalFields.splitPaymentEnabled=this.outletService.Data.SplitPaymentEnabled,this._userRoleService.Data$.pipe(Ie(this.destroy$)).subscribe(e=>{this.userRole=e,this.initPaylaterTab()}),this.initFirstPaymentSplitOptions()}initPaylaterTab(){this.userRole.CreditSalesLock&&(this.modalFields.viewState=0)}ngOnInit(){this.modalFields.numpadVisible&&(this.keyboard=this._numpadService.keyboard),this.initDefaultDueDays()}initDefaultDueDays(){let e=this._customerHttpService.Data,t=e?e.DueDays:null,i=e?e.DueMonths:null,o=new Date;o.setHours(0,0,0,0);let r=new Date;r.setHours(0,0,0,0),f.IsNotEmpty(this.posData.Invoice.Due)?o=new Date(this.posData.Invoice.Due):(i&&o.setMonth(o.getMonth()+i),!t&&!i&&(t=this.modalFields.config.DefaultDueDays),o.setDate(o.getDate()+t)),this.modalFields.payLaterDueDate=o,this.modalFields.payLaterDueDays=f.differentInDays(r,o),this.posData.Invoice.Due=this.modalFields.payLaterDueDate}onBack(){this.modalFields.viewState=0,this.changeModalForEmoney(!1),this.modalFields.enableEmoneyConfirmModal(!1),this.setToCashPayment(),this._paymentGatewayService.clearTransactionID()}onCancelWaitingEcr(){this.modalFields.isCancelEcrTransaction?(this.modalFields.viewState=0,this.modalFields.enableModalWaitingEcr(!1),this.setToCashPayment()):this.modalFields.cancelEcrTransaction()}onOk(){this.validateSerialItem()&&this.onSubmitOrder()}onSubmitOrder(){if(this.posData.Action.Type=3,this.posData.Order.InvoicedStateID=3,this.isPaymentLater())this.validatePaymentLater(this.userRole)&&(this.modalFields.viewState==1?this.Payments=[]:this.setPaymentNoteAndCode(this.firstPayment,this.paymentNoteCtrl.value,this.paymentCodeCtrl.value),this._paymentService.submitOrder(this.Payments),this.closeDialogAfterSubmit());else if(this.posData.Invoice.Due=null,this.validatePay()){if(this.validatePaymentSplit(),this.isCustomerLimitDebt())return;this.setPaymentNoteAndCode(this.firstPayment,this.paymentNoteCtrl.value,this.paymentCodeCtrl.value),this._paymentService.submitOrder(this.Payments),this.closeDialogAfterSubmit()}}setPaymentNoteAndCode(e,t,i){e&&e.TypeID!=1&&e.TypeID!=99&&e.TypeID!=3&&(e.Code=i,e.Note=t)}isPaymentLater(){let e=this.modalFields.viewState==1,t=this.cashPaymentChange<0&&this.Payments.length==1;return e||t}handlingSubmitOrderWithEcr(e){if(this.ecrSignalService.isConnected()==!1){this._toastr.error("ECR is not connected","Error");return}this.onPaymentMethodChanged(e),this.posData.Invoice.Due=null;let t=this.firstPayment.PaidAmount;this.modalFields.viewState=5,this.modalFields.enableModalWaitingEcr(!0),this._ecrService.onPay(t).pipe(Ie(this.destroy$)).subscribe({next:i=>{i.IsSuccess?(this.firstPayment.Code=i.Trace_No,this.firstPayment.Note=`${i.CardType} ${i.CardNumer}`,this._paymentService.submitOrder(this.Payments),this.onCloseDialog()):this.handlingEcrOnError()},error:i=>{this.handlingEcrOnError(),console.error(i)}})}handlingEcrOnError(){this._toastr.error("Transaction Canceled. Try Again","Error"),this.modalFields.viewState=0,this.modalFields.enableModalWaitingEcr(!1),this.setToCashPayment()}handlingCashMachinePayment(e){this.cashMachineService.isConnected()?(this.onPaymentMethodChanged(e),this.posData.Invoice.Due=null,this.modalFields.viewState=6,this.modalFields.enableModalCashMachine(!0)):this._toastr.error("Cash Machine is not connected, You need to connect it first","Error")}onCancelCashMachine(){this.modalFields.viewState=0,this.modalFields.enableModalCashMachine(!1),this.setToCashPayment()}onCashMachineTransactionComplete(e){e.changeDue==0?this.onSubmitOrder():e.canProvideChange?this.onSubmitOrder():this.modalFields.isCashMachineProvideChange.set(!1)}onCashMachineNotProvideChange(){this._paymentService.submitOrder(this.Payments),this.closeDialogAfterSubmit()}isCustomerLimitDebt(){if(this.paymentSplitDefaultVal>0&&this.Payments.length==1){let e=this._customerHttpService.Data;if(e.DebtLimit>0){let t=e.Debt==0&&this.paymentSplitDefaultVal>e.DebtLimit,i=e.Debt+this.paymentSplitDefaultVal>e.DebtLimit;if(t||i)return this._toastr.warning(oe.debtLimit,"Warning!"),!0}}return!1}validateSerialItem(){let e=this.findItemWithoutSerial();return e.length>0?f.IsEmpty(this.posData.Action.DeliveryEntityID)?!0:(this._toastr.warning(`Serial can not Empty in ${e[0]?.Variant?.Name}`,"Warning"),!1):!0}findItemWithoutSerial(){let e;return this.posData.CartItems.filter(i=>(e=!1,i.Variant&&i.Variant.TypeID===4&&(e=i?.Serial?i?.Serial?.length===0:!0),e))}validatePaymentLater(e){if(this.posData?.Invoice?.SurchargePcg!==0)return this._toastr.warning(oe.surcharge,"Payment Method Not Allowed"),!1;if(this.IsCreditSales()&&e.CreditSalesLock)return alert(oe.creditLock),!1;let t=f.IsEmpty(this.posData.Order.CustomerID);return this.modalFields.viewState==1&&t?(alert(oe.emptyCustomerCredit),!1):this.IsCreditSales()&&t?(alert(oe.emptyCustomerCredit),!1):!!this.debtLimitValidation()}debtLimitValidation(){let e=this._customerHttpService.Data,t=!1,i=e.DebtLimit,o=e.DebtCalculated,r=this.cashierCalculatorService.Data,c=o==0&&r>i;if(this.posData.Invoice.PaymentStateID==1){let u=i-o;r>u&&(t=!0)}else t=o+r>i;return i!==0&&(c||t)?(this._toastr.warning(oe.debtLimit,"Warning!"),!1):!0}validatePaymentSplit(){let e=this.firstPayment.PaidAmount,t=this.Payments[1]?this.Payments[1].PaidAmount:0,i=this.cashierCalculatorService.Data,o=[];e+this.modalFields.toleranceAmount>=i?(o=this.Payments.slice(0,1),this.modalFields.toleranceAmount!==0&&e<i&&(this.firstPayment.Amount=i),this.Payments=o):(t+e===i?o=this.Payments.slice(0,2):o=this.Payments,this.setPaymentNoteAndCode(this.Payments[1],this.paymentNoteCtrl2.value,this.paymentCodeCtrl2.value)),this.Payments=o}validatePay(){let e=this.firstPayment.Amount+(this.Payments[1]?this.Payments[1].Amount:0);if(this.AppConfigJSON.ModuleSell.PaymentDialog.MinusPaymentAllowed==!1&&e<0)return this._toastr.warning("You are not allowed to process this transaction because the total amount is less than zero","Warning!"),!1;if(this.modalFields.payNowEnabled&&this.paymentSplitDefaultVal>0&&this.firstPayment.Amount==0)return this._toastr.warning(oe.payNowOnly,de.Warning),!1;if(this.IsDepositPayment()&&this.userRole.CreditSalesLock)return this._toastr.warning(oe.creditLock,de.Warning),!1;if(!this.AppConfigJSON.ApplicationLoyalty.Rules.MixCashAndPoint&&this.posData.Order.PointUsed>0&&this.cashierCalculatorService.Data>0)return this._toastr.info(oe.partialLoyaltyPointUnable,de.Info),!1;let t=this.posData.Order.PointUsed*this.AppConfigJSON.ApplicationLoyalty.LoyaltyPoint.RedeemPointValue;if(this.cashierCalculatorService.GetPointOnlyAmount()>0&&this.cashierCalculatorService.GetPointOnlyAmount()>t){let o=f.StringFormat(oe.pointOnly,this.decimalPipe.transform(this.posData.PointOnlyAmount));return this._toastr.info(o,de.Info),!1}let i=this.cashierCalculatorService.Data+this.posData.Order.DiscountAmount-t;if(this.cashierCalculatorService.GetCashOnlyAmount()>0&&this.cashierCalculatorService.GetCashOnlyAmount()>i&&Math.abs(this.cashierCalculatorService.GetCashOnlyAmount()-i)>this.modalFields.toleranceAmount){let o=f.StringFormat(oe.cashOnly,this.decimalPipe.transform(this.posData.CashOnlyAmount));return this._toastr.info(o,de.Info),!1}return this.IsDepositPayment()&&f.IsEmpty(this.posData.Order.CustomerID)?(alert(oe.emptyCustomerDeposit),!1):this.posData.PrepaidPackageItem.length>0&&f.IsEmpty(this.posData.Order.CustomerID)?(this._toastr.info("Products with prepaid package type must use the customer",de.Info),!1):!(this.validatePaymentNoteAndCode(this.firstPayment,this.paymentCodeCtrl,this.paymentNoteCtrl)==!1||this.Payments[1]&&this.validatePaymentNoteAndCode(this.Payments[1],this.paymentCodeCtrl2,this.paymentNoteCtrl2)==!1)}validatePaymentNoteAndCode(e,t,i){if(e?.TypeID!=1&&e?.TypeID!=99&&e?.TypeID!=3){if(t.markAsDirty(),i.markAsDirty(),t.hasError("required"))return this._toastr.warning("Payment Code is required","Warning"),!1;if(i.hasError("required"))return this._toastr.warning("Payment Note is required","Warning"),!1;if(t.hasError("maxlength"))return this._toastr.warning("Payment Code must be 1 character","Warning"),!1}else return!0}onNowClick(){this.initPaymentAfterLater(),this.modalFields.viewState=0}onLaterClick(){this.modalFields.viewState=1}onSplitClick(){this.modalFields.viewState=3,this.initPaymentNoteAndCodeSplit(this.Payments[1])}IsCreditSales(){return this.modalFields.viewState!=1||this.IsDepositPayment()}initPaymentAfterLater(){this.modalFields.viewState==1&&this.posState==2&&f.IsEmpty(this.firstPayment.TypeID)&&(this.firstPayment.TypeID=1)}IsDepositPayment(){let e=!1,t=this.Payments.map(c=>c.PaidAmount).reduce((c,u)=>c+u),i=this.cashierCalculatorService.Data;return this.modalFields.toleranceAmount+t<i&&(e=!0),e}closeDialogAfterSubmit(){this.initializeDefaultValues(),this.dialogRef.close()}onCloseDialog(){this.modalFields.isCashMachineProvideChange()==!1?this.onCashMachineNotProvideChange():(this.initializeDefaultValues(),this.removeSurchargeOnCancel(),this.dialogRef.close())}removeSurchargeOnCancel(){this.posData.Invoice.SurchargePcg!==0&&this.Payments.some(t=>{let i=this.findPaymentMethodByID(t.MethodID);return i&&i.ExtraCharge>0})&&this.updateSurcharge(0)}updateCashPayment(e){let t=this.cashierCalculatorService.Data;this.paymentSplitDefaultVal=0,this.firstPayment.MethodID=this.defaultCashPaymentMethodID,this.firstPayment.Amount=t,this.firstPayment.PaidAmount=e,this.firstPayment.TypeID=1,this.posData.Invoice.SurchargePcg!==0&&(this.updateSurcharge(0),this.initCashFocus()),this.calculateSplitPayment(e)}calculateSplitPayment(e){let t=this.cashierCalculatorService.Data;e<t?(this.firstPayment.Amount=e,this.paymentSplitDefaultVal=t-e,this.filterSplitPaymentList(),this.changePaymentSplitValue()):(this.paymentSplitDefaultVal=0,this.changePaymentSplitValue())}changePaymentSplitValue(){this.Payments[1]&&(this.Payments[1].Amount=this.paymentSplitDefaultVal,this.Payments[1].PaidAmount=this.paymentSplitDefaultVal)}onPaymentMethodChanged(e){this.selectedPaymentMethod=e,this.updateSurcharge(e.ExtraCharge);let t=this.cashierCalculatorService.Data;this.firstPayment.Amount=t,this.firstPayment.PaidAmount=t,this.firstPayment.MethodID=e.ID,this.firstPayment.TypeID=e.TypeID,e.ExtraCharge>0&&this.paymentSplitDefaultVal>0?this._toastr.warning("Cannot apply Split Payment for Payment Method with Surcharge","Warning"):this.paymentSplitDefaultVal>0&&(this.firstPayment.Amount=t-this.paymentSplitDefaultVal,this.firstPayment.PaidAmount=t-this.paymentSplitDefaultVal),this.initPaymentNoteAndCode(this.firstPayment),this.filterSplitPaymentList()}filterSplitPaymentList(){this.modalFields.uniquePaymentMethodOnSplit?(this.splitPaymentMethodList=this.paymentMethodList.filter(e=>e.ExtraCharge==0).filter(e=>e.ID!==this.firstPayment.MethodID),this.resetSecondPaymentMethod()):this.splitPaymentMethodList=this.paymentMethodList.filter(e=>e.ExtraCharge==0)}resetSecondPaymentMethod(){let t=this.Payments[1]?.MethodID,i=this.firstPayment.MethodID;t==i&&delete this.Payments[1]}updateSurcharge(e){this.posData.Invoice.SurchargePcg=e,this.posData.Invoice.TempSurchargePcg=e,this._orderDataService.pushNewValue(this.posData)}onSplitPaymentMethodAssigned(e){e?(this.Payments[1]=this.Payments[1]?this.Payments[1]:new Ke,this.Payments[1].MethodID=e.ID,this.Payments[1].MethodName=e.Name,this.Payments[1].Amount=this.paymentSplitDefaultVal,this.Payments[1].PaidAmount=this.paymentSplitDefaultVal,this.Payments[1].TypeID=e.TypeID):(this.Payments[1].Amount=0,this.Payments[1].PaidAmount=0),this.initPaymentNoteAndCodeSplit(this.Payments[1])}initPaymentNoteAndCodeSplit(e){let t=this.getPaymentNoteAndCodeValidators(e);this.paymentCodeCtrl2?(this.paymentCodeCtrl2.setValidators(t.paymentCodeValidators),this.paymentNoteCtrl2.setValidators(t.paymentNoteValidators),this.paymentCodeCtrl2.updateValueAndValidity(),this.paymentNoteCtrl2.updateValueAndValidity()):(this.paymentCodeCtrl2=new et(e?.Code,t.paymentCodeValidators),this.paymentNoteCtrl2=new et(e?.Note,t.paymentNoteValidators))}onFirstPaymentSplitChange(e){let t=this.cashierCalculatorService.Data;this.firstPayment.Amount=t,this.firstPayment.PaidAmount=e,this.calculateSplitPayment(e)}initFirstPaymentSplitOptions(){this.firstPaymentSplitOptions=[...this.getTypePaymentList(2),...this.getTypePaymentList(4)]}isCardPayment(){return this.getTypePaymentList(2).findIndex(t=>t.ID==this.firstPayment.MethodID)>=0}isOtherPayment(e){return this.getTypePaymentList(e).findIndex(t=>t.ID==this.firstPayment.MethodID)>=0}getTypePaymentList(e){return this._paymentService.getPaymentList().filter(i=>i.TypeID==e)}payWithEmoney(e){let t=this.generateQrisRequest();this._paymentGatewayService.generateQR(t,e).pipe(Ie(this.destroy$)).subscribe({next:i=>{this.qrImage=i.Url,i.IsDemoKey?this.showModalConfirmDemoQris():this.showModalQRIS()},error:i=>{this.setToCashPayment(),this.onErrorGenerateQR(i)}})}generateQrisRequest(){let e=new an;return e.InvoiceNumber=this.posData.Order.Number,e.Amount=this.cashierCalculatorService.Data,e.RegisterID=this.posData.Order.RegisterID,e}setToCashPayment(){this.firstPayment.MethodID=this.defaultCashPaymentMethodID,this.firstPayment.TypeID=1}showModalConfirmDemoQris(){this.modalFields.viewState=4,this.modalFields.enableEmoneyConfirmModal(!0)}onContinueDemoQr(){this.modalFields.enableEmoneyConfirmModal(!1),this.modalFields.viewState=2,this.changeModalForEmoney(!0)}showModalQRIS(){this.modalFields.viewState=2,this.changeModalForEmoney(!0)}onErrorGenerateQR(e){e.status==400?this.validateEMoneyPayment():this._toastr.error(oe.failGenerateQR,de.Error)}validateEMoneyPayment(){this._paymentGatewayService.validateEMoneyPayment(this.AppConfigJSON).pipe(Ie(this.destroy$)).subscribe({next:e=>{this.dialogRef.close();let i=`IDR ${this.decimalPipe.transform(e.Final)} received. Please verify in customer mobile app!`;this._toastr.success(i," QR Settlement"),this._orderProcessorService.updatePosState(1,e)}})}changeModalForEmoney(e){this.modalFields.enableEMoneyModal(e),e||this._posHubService.BroadcastQRToCustomerDisplay("").subscribe()}dueDateChange(){let e=new Date(this.posData.Order.Date),t=this.modalFields.payLaterDueDate?this.modalFields.payLaterDueDate:new Date;e.setHours(0,0,0,0),this.modalFields.payLaterDueDays=f.differentInDays(e,t),this.posData.Invoice.Due=t}dueDayChange(){let e=new Date(this.posData.Order.Date);e.setDate(e.getDate()+this.modalFields.payLaterDueDays),e.setHours(0,0,0,0),this.modalFields.payLaterDueDate=e,this.posData.Invoice.Due=e}sanitize(e){return this.sanitizer.bypassSecurityTrustUrl(e)}onPrintQR(){window.print()}ngOnDestroy(){this.destroy$.next(!0),this.destroy$.complete()}static \u0275fac=function(t){return new(t||n)(P(te),P(L),P(se),P(ln),P(lt),P(z),P(F),P(Lt),P(q),P(Jn),P(je),P(Vo),P(De),P(Re),P(he),P(cn),P(re),P(Ht),P(jt))};static \u0275cmp=N({type:n,selectors:[["POS-modal-payment"]],standalone:!1,decls:15,vars:13,consts:[[3,"keydown.NumpedEnter","keydown.Enter","keydown.F2","onOk","onCancel","onClose","onBack","keydown.Escape","config"],[4,"ngIf"],["class","container w-100 h-100",4,"ngIf"],["class","text-center position-relative w-100",4,"ngIf"],[3,"totalAmount"],["class","btn btn-light-blue text-primary btn-lg fw-bold me-5 py-8",3,"click",4,"ngIf"],[1,"ms-3","fs-4"],[1,"container","w-100","h-100"],["class","row border-bottom",4,"ngIf"],["style","margin-bottom: 80px","class","py-5",4,"ngIf"],[1,"row","border-bottom"],["data-cy","tab-now",1,"btn","btn-link",3,"click","ngClass"],["class","btn btn-link","data-cy","tab-split",3,"ngClass","click",4,"ngIf"],["data-cy","tab-later","class","btn btn-link",3,"ngClass","click",4,"ngIf"],["data-cy","tab-split",1,"btn","btn-link",3,"click","ngClass"],[1,"fst-italic",2,"font-size","10px"],["data-cy","tab-later",1,"btn","btn-link",3,"click","ngClass"],[1,"row","py-5","border-bottom"],["class","row py-5 border-bottom",4,"ngIf"],["class","row py-5",4,"ngIf"],["class","row",3,"ngClass",4,"ngFor","ngForOf"],[1,"col-3","h5","pt-5"],[1,"fa-solid","fa-money-bill-wave"],[1,"col-9"],["class","row mb-5",4,"ngIf"],[1,"row"],[1,"col","pe-0","ps-4"],["id","cashInput","type","text","keyboardType","number","placeholder","Custom Cash Amount","data-cy","txt-amount","autoNum","",1,"form-control","form-control-lg","py-3",3,"ngModelChange","simpleKeyboard","ngModel"],["class","change",3,"ngClass",4,"ngIf"],[1,"row","mb-5"],["class","col-4 pe-0 ps-4",4,"ngFor","ngForOf"],[1,"col-4","pe-0","ps-4"],[1,"btn","btn-outline-info","px-1","py-6","w-100",3,"click","ngClass"],[1,"change",3,"ngClass"],[1,"fa-solid","fa-money-from-bracket"],[1,"row","d-flex","align-items-center"],[1,"col-auto","pb-3","ps-4","pe-0"],[1,"btn","btn-outline-info",3,"click"],[3,"hidden"],[1,"emoney-logo",3,"src"],[1,"fa-solid","fa-qrcode"],["class","col-auto pb-3 ps-4 pe-0",4,"ngFor","ngForOf"],[1,"row","py-5"],[1,"fa-credit-card","fas"],[1,"row",3,"ngClass"],["class","col-3 h5 pt-5",4,"ngIf"],["class","col-9",4,"ngIf"],["class","position-relative row",4,"ngIf"],[1,"btn","btn-outline-info",3,"click","ngClass"],[1,"position-relative","row"],[1,"paymentNote","col","row","g-0","pt-2","ms-4"],[1,"col-6"],["type","text","placeholder","Payment Note",1,"form-control","border-end-0","py-6",3,"formControl"],[1,"text-danger","d-inline"],["type","text","placeholder","Payment Code",1,"form-control","border-start-0","py-6","paymentCode",3,"formControl"],[1,"row","d-flex","align-items-center","g-0","later-payment","date-picker","mt-4"],[1,"col-3"],["appearance","fill","name","orderDate",1,"col-9",3,"dateChange","date","displayToggle"],[1,"row","d-flex","align-items-center","g-0","later-payment","mt-10"],["id","daysInput",1,"col-3"],["id","day","type","text","keyboardType","number","autoNum","",1,"col-9","form-control",2,"width","75%",3,"ngModelChange","simpleKeyboard","ngModel"],[1,"py-5",2,"margin-bottom","80px"],[1,"col-6","d-flex","align-items-center"],[1,"px-0"],[1,"me-2"],["bindLabel","Name","bindValue","ID","placeholder","Payment","appendTo","body","data-cy","Payment1",1,"ng-select-width","category-select",3,"change","items","ngModel","clearable"],[1,"col-6","col-6","d-flex","justify-content-start","align-items-center"],[1,"me-3"],["type","text","autoNum","",1,"form-control",3,"ngModelChange","ngModel"],[1,"row","mt-6"],[1,"col-12","d-flex","justify-content-start"],[1,"d-flex","align-items-center"],["bindLabel","Name","bindValue","ID","placeholder","Payment","appendTo","body","data-cy","Payment2",1,"ng-select-width","category-select",3,"change","items","ngModel"],[1,"d-flex","justify-content-start","align-items-center","ms-8"],[1,"fs-6"],[1,"position-relative","row","mt-6","px-2"],[1,"text-center","position-relative","w-100"],[1,"d-none","d-print-flex","flex-column","justify-content-center","title-pay","position-relative","mb-3"],[1,"fw-bold","fs-3",3,"ngClass"],[1,"row","d-flex","justify-content-center","me-5","fs-6"],[1,"col-3","text-end","pe-3","ms-13"],[1,"me-1"],[1,"col-6","text-start","ps-0"],[1,"fw-normal"],["class","position-relative d-print-none","style","top: 8px",4,"ngIf"],[1,"d-flex","justify-content-center","qris-container"],["alt","Gopay QR",1,"d-block","border-0",3,"src","ngClass"],[1,"position-relative",3,"ngStyle"],["src","https://cdn.dealpos.xyz/web-image/gpn.png","alt",""],[1,"position-relative","d-print-none",2,"top","8px"],[3,"isCancel"],[3,"onTransactionComplete","totalAmount"],[1,"btn","btn-light-blue","text-primary","btn-lg","fw-bold","me-5","py-8"],[1,"btn","btn-light-blue","text-primary","btn-lg","fw-bold","me-5","py-8","px-12"],[1,"btn","btn-light-blue","text-primary","btn-lg","fw-bold","me-5","py-8",3,"click"],[1,"btn","btn-light-blue","text-primary","btn-lg","fw-bold","me-5","py-8","px-12",3,"click","keyup.F2"],[1,"fa-solid","fa-print","me-2"]],template:function(t,i){t&1&&(a(0,"modal-material",0),S("keydown.NumpedEnter",function(){return i.onOk()})("keydown.Enter",function(){return i.onOk()})("keydown.F2",function(){return i.onOk()})("onOk",function(){return i.onOk()})("onCancel",function(){return i.onCloseDialog()})("onClose",function(){return i.onCloseDialog()})("onBack",function(){return i.onBack()})("keydown.Escape",function(){return i.onCloseDialog()}),$(1,bs,5,4,"header",1),a(2,"content"),$(3,nl,5,4,"div",2)(4,al,27,15,"div",3),h(5,sl,1,0,"app-confirm-demo-qris"),$(6,ll,2,1,"ng-container",1),h(7,cl,1,1,"cash-machine-payment",4),s(),a(8,"footer"),h(9,pl,2,1),$(10,ul,3,0,"a",5)(11,gl,2,0,"a",5)(12,fl,2,1,"a",5)(13,hl,2,0,"a",5)(14,Cl,2,0,"a",5),s()()),t&2&&(p("config",i.modalFields.modalConfig),l(),p("ngIf",!i.modalFields.isQrisConfirm&&!i.modalFields.isCancelEcrTransaction),l(2),p("ngIf",!i.modalFields.isStateQR&&!i.modalFields.isQrisConfirm&&!i.modalFields.isWaitingPaymentEcr&&!i.modalFields.isCashMachine),l(),p("ngIf",i.modalFields.isStateQR),l(),C(i.modalFields.isQrisConfirm?5:-1),l(),p("ngIf",i.modalFields.isWaitingPaymentEcr),l(),C(i.modalFields.isCashMachine?7:-1),l(2),C(i.modalFields.isCashMachine?9:-1),l(),p("ngIf",i.modalFields.isStateQR),l(),p("ngIf",i.modalFields.isStateQR),l(),p("ngIf",i.modalFields.isWaitingPaymentEcr),l(),p("ngIf",i.modalFields.isQrisConfirm),l(),p("ngIf",i.modalFields.isQrisConfirm))},dependencies:[Be,Un,Wn,Gn,Te,Pe,Ee,St,ne,Pt,Dt,Pi,Fo,dn,mn,pn,q,bi],styles:['.text-warning[_ngcontent-%COMP%]{color:var(--bs-warning)!important}.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}.btn-light-danger[_ngcontent-%COMP%]{color:#212529;background-color:#f8d7da!important;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:hover{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5}.btn-light-danger[_ngcontent-%COMP%]:focus, .btn-light-danger.focus[_ngcontent-%COMP%]{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5;box-shadow:0 0 0 .2rem #dc354540}.btn-light-danger.disabled[_ngcontent-%COMP%], .btn-light-danger[_ngcontent-%COMP%]:disabled{color:#212529;background-color:#f8d7da;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]{color:#212529;background-color:#f1aeb5;border-color:#ea868f}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active:focus, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active:focus, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]:focus{box-shadow:0 0 0 .2rem #dc354540}.margin-note[_ngcontent-%COMP%]{margin-left:-7px!important}.quickKeyTabs[_ngcontent-%COMP%]{margin-right:-15px;margin-left:-7px}.change[_ngcontent-%COMP%]{position:absolute;top:119px;height:40px;background:#89b03e;color:#fff;right:17px;padding:0 10px;line-height:40px;font-size:16px}.change[_ngcontent-%COMP%]:before{content:"\\a";border-style:solid;border-width:40px 24px 0 0;border-color:transparent #89b03e transparent transparent;position:absolute;left:-24px}.change.danger[_ngcontent-%COMP%]{background:#c9302c}.change.danger[_ngcontent-%COMP%]:before{border-color:transparent #c9302c transparent transparent}.paymentNote[_ngcontent-%COMP%]:before{z-index:10;content:"";position:absolute;top:4px;left:calc(50% - 10px);height:43px;width:10px;background-color:inherit;border-right:1px solid lightgray;-webkit-transform:skewX(-10deg);-moz-transform:skewX(-10deg);-ms-transform:skewX(-10deg);transform:skew(-10deg)}.height-input[_ngcontent-%COMP%]{height:37px}.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}.later-payment[_ngcontent-%COMP%] strong{font-size:20px}.later-payment[_ngcontent-%COMP%] input{font-size:20px;padding:20px 10px!important}.later-payment[_ngcontent-%COMP%] .mat-mdc-form-field{width:100%;font-size:20px;border:1px solid #c8d3df;padding-left:10px}.later-payment[_ngcontent-%COMP%] .mat-mdc-form-field .mat-mdc-icon-button, .later-payment[_ngcontent-%COMP%] .mat-mdc-form-field .mat-mdc-button-persistent-ripple, .later-payment[_ngcontent-%COMP%] .mat-mdc-form-field .mat-mdc-form-field-icon-suffix{outline:none!important} .later-payment.date-picker .mat-mdc-form-field{font-size:4px}.phone[_ngcontent-%COMP%] div[_ngcontent-%COMP%]{height:50px;width:50px;padding-top:11px;background-color:#f5f5f5;border:1px solid gray!important}.phone[_ngcontent-%COMP%] input[_ngcontent-%COMP%]{padding-left:65px!important;border:1px solid gray!important;font-size:25px;height:50px}.phone[_ngcontent-%COMP%] .form-control[_ngcontent-%COMP%]:focus{border-color:#8bb8df!important}.qris[_ngcontent-%COMP%] div[_ngcontent-%COMP%]{font-size:.75rem}.ng-select.ng-select-width[_ngcontent-%COMP%] .ng-select-container{width:160px;max-width:160px}.qrDemo[_ngcontent-%COMP%]{position:relative;top:-10px}.qrDemo[_ngcontent-%COMP%] > p[_ngcontent-%COMP%]{margin-bottom:0}input[type=text][_ngcontent-%COMP%]:disabled{background:#e5e5e5} ng-dropdown-panel.category-select{z-index:1100}.row[_ngcontent-%COMP%] > div.tab-button[_ngcontent-%COMP%]{padding-left:0}.qris-barcode[_ngcontent-%COMP%]{height:300px;line-height:50px}@media print{.qris-barcode[_ngcontent-%COMP%]{height:200px;margin-bottom:20px}.title-pay[_ngcontent-%COMP%]{font-size:10px;font-weight:400;top:10px}.title-pay[_ngcontent-%COMP%] div.ms-13[_ngcontent-%COMP%]{margin-left:1.7rem}.qris-container[_ngcontent-%COMP%]{margin-bottom:20px}}.emoney-logo[_ngcontent-%COMP%]{max-width:180px;max-height:40px;height:30px}']})};var vl=n=>({"bg-light":n});function _l(n,e){if(n&1){let t=E();a(0,"button",10),S("click",function(){v(t);let o=m(2).$implicit,r=m(2);return _(r.onApplyPromotion(o))}),d(1," APPLY "),s()}if(n&2){let t=m(4);p("disabled",t.selectedPromotion)}}function yl(n,e){if(n&1){let t=E();a(0,"button",11),S("click",function(){v(t);let o=m(2).$implicit,r=m(2);return _(r.onRemovePromotion(o))}),d(1," REMOVE "),s()}}function bl(n,e){if(n&1&&(h(0,_l,2,1,"button",8),h(1,yl,2,0,"button",9)),n&2){let t=m().$implicit,i=m(2);C((i.selectedPromotion==null?null:i.selectedPromotion.ID)!=t.ID?0:-1),l(),C((i.selectedPromotion==null?null:i.selectedPromotion.ID)==t.ID?1:-1)}}function Sl(n,e){n&1&&(a(0,"p",7),d(1,"Not Eligible"),s())}function Pl(n,e){if(n&1&&(a(0,"div",3)(1,"div",4)(2,"h5"),d(3),s(),a(4,"p",5),d(5),s()(),a(6,"div",6),h(7,bl,2,2)(8,Sl,2,0,"p",7),s()()),n&2){let t=e.$implicit;p("ngClass",j(4,vl,!t.Eligible)),l(3),M(t.Name),l(2),M(t.Description),l(2),C(t.Eligible?7:8)}}function Ol(n,e){if(n&1&&(K(0,Pl,9,6,"div",3,ve),y(2,"sortBy")),n&2){let t=m();Z(yt(2,0,t.promotions,"desc","Eligible"))}}function Dl(n,e){n&1&&(a(0,"div",2)(1,"p",12)(2,"span"),d(3,"There is no active promotion right now"),s()()())}var gn=class n{constructor(e,t,i,o){this._dialogRef=e;this._promotionEventService=t;this._outletRegisterService=i;this._salesOrderService=o;this.destroy$=new Me}modalConfig=new ie;promotions=[];destroy$;promotionType=Yt;selectedPromotion;ngOnInit(){this.subscribePromotionService(),this.initModalConfig()}ngOnDestroy(){this.destroy$.next(!0),this.destroy$.complete()}subscribePromotionService(){this._promotionEventService.Data$.pipe(Ie(this.destroy$)).subscribe(e=>{this.promotions=e,this.checkValidSelectedPromotion()})}checkValidSelectedPromotion(){this.selectedPromotion=this._promotionEventService.selectedPromotion,this.selectedPromotion&&this.promotions.findIndex(t=>t.ID==this.selectedPromotion.ID&&t.Eligible)===-1&&(this.selectedPromotion=null,this._promotionEventService.selectedPromotion=null)}initModalConfig(){this.modalConfig.title="Promotions",this.modalConfig.customWidth="500px",this.modalConfig.bodyScrollable=!0,this.modalConfig.hideCancel=!0,this.modalConfig.okText='<i class="fas fa-rotate fs-6 me-1"></i>Refresh'}onApplyPromotion(e){this._promotionEventService.applyPromotion(e),e.TypeID!=4&&this.close()}onRemovePromotion(e){this._promotionEventService.removePromotion(),this.selectedPromotion=null}onRefreshPromotion(){let e=this._outletRegisterService.Data.RegisterID;this._promotionEventService.getPromotions(e).subscribe(t=>{this._promotionEventService.loadPromotions(t),this._salesOrderService.Data.CartItems=[],this._salesOrderService.pushNewValue()})}close(){this._dialogRef.close()}static \u0275fac=function(t){return new(t||n)(P(te),P(Ae),P(re),P(L))};static \u0275cmp=N({type:n,selectors:[["POS-modal-promotion"]],standalone:!1,decls:5,vars:2,consts:[[3,"onCancel","onOk","onClose","config"],[1,"container"],[1,"d-flex","align-items-center","justify-content-center"],[1,"row","border","mt-3","py-2","justify-content-between",3,"ngClass"],[1,"col","mt-3"],[1,"description"],[1,"col-auto","my-auto"],[1,"text-danger","my-auto"],[1,"btn","btn-success","my-auto",3,"disabled"],[1,"btn","btn-danger","my-auto"],[1,"btn","btn-success","my-auto",3,"click","disabled"],[1,"btn","btn-danger","my-auto",3,"click"],[1,"mb-0","fs-3","text-body-secondary"]],template:function(t,i){t&1&&(a(0,"modal-material",0),S("onCancel",function(){return i.close()})("onOk",function(){return i.onRefreshPromotion()})("onClose",function(){return i.close()}),a(1,"content")(2,"div",1),h(3,Ol,3,4)(4,Dl,4,0,"div",2),s()()()),t&2&&(p("config",i.modalConfig),l(3),C(i.promotions.length>0?3:4))},dependencies:[Be,ne,Mt],styles:[".description[_ngcontent-%COMP%]{word-wrap:break-word}"]})};var Ml=["firstNameAutoFocus"],xl=["customerForm"],wn=(n,e)=>({selected:n,danger:e}),ct=n=>({"is-invalid":n}),Qt=n=>({selected:n}),Il=n=>({"invalid-feedback":n});function Tl(n,e){n&1&&b(0,"i",14)}function El(n,e){n&1&&b(0,"i",14)}function wl(n,e){n&1&&b(0,"i",14)}function Rl(n,e){if(n&1&&b(0,"option",22),n&2){let t=e.$implicit;p("value",t.Name)}}function Nl(n,e){if(n&1&&(a(0,"div",25),d(1," Name is mandatory "),s()),n&2){m();let t=ue(30);p("ngClass",j(1,Il,t.touched&&t.invalid))}}function Al(n,e){n&1&&(a(0,"div",44),d(1," Mobile Phone is mandatory "),s())}function kl(n,e){if(n&1&&(a(0,"div",44),d(1),s()),n&2){m(2);let t=ue(42);l(),D(" ",t.errors==null||t.errors.minLength==null?null:t.errors.minLength.message," ")}}function Vl(n,e){if(n&1&&(h(0,Al,2,0,"div",44),h(1,kl,2,1,"div",44)),n&2){m();let t=ue(42);C(t.getError("required")&&!t.getError("minLength")?0:-1),l(),C(t.getError("minLength")?1:-1)}}function Fl(n,e){n&1&&(a(0,"div",44),d(1," Email must be a valid email address "),s())}function Ll(n,e){n&1&&(a(0,"div",44),d(1,"Email is mandatory"),s())}function Bl(n,e){if(n&1&&(h(0,Fl,2,0,"div",44),h(1,Ll,2,0,"div",44)),n&2){m();let t=ue(49);C(t.errors!=null&&t.errors.email?0:-1),l(),C(t.errors!=null&&t.errors.required?1:-1)}}function Hl(n,e){n&1&&(a(0,"div",44),d(1,"Birthdate is mandatory"),s())}function jl(n,e){if(n&1&&h(0,Hl,2,0,"div",44),n&2){m();let t=ue(56);C(t.errors!=null&&t.errors.required?0:-1)}}function Ql(n,e){if(n&1&&b(0,"i",43),n&2){let t=m();p("matTooltip",t.estimatedCodeMessage)}}function Ul(n,e){n&1&&(a(0,"div",44),d(1," Customer code is mandatory. "),s())}function Wl(n,e){n&1&&(a(0,"div",44),d(1,"Address is mandatory."),s())}function Gl(n,e){if(n&1&&(a(0,"div",44),d(1),s()),n&2){m();let t=ue(93);l(),D(" ",t.errors==null||t.errors.minLength==null?null:t.errors.minLength.message," ")}}function ql(n,e){n&1&&(a(0,"div",66),d(1," Sign Up Outlet is mandatory. "),s())}var fn=class n{constructor(e,t,i,o,r,c){this._dialogRef=e;this._posService=t;this._orderDataService=i;this._CustomerHttpService=o;this._registerService=r;this.data=c;this.initCustomer(),this.initRequiredConfig()}estimatedCodeMessage="Customer code below is just an estimation, it could change in the final result";fieldRequiredConfig={Mobile:!1,Email:!1,Birthdate:!1,Code:!1,Address:!1,SignUpOutlet:!1};firstNameRef;customerForm;modalConfig=new ie;customer;get options(){return this._posService.Data.CustomerOptions}get config(){return this._posService.Data.AppConfigJSON}customerData;tabState="general";guidEmpty=f.GuidEmpty;outlets=R([]);get isGeneralFormInvalid(){let e=this.customerForm?.controls?.generalForm;return this.checkDirtyForm(e)}get isDetailFormInvalid(){let e=this.customerForm?.controls?.detailForm;return this.checkDirtyForm(e)}get isIdFormInvalid(){let e=this.customerForm?.controls?.idForm;return this.checkDirtyForm(e)}checkDirtyForm(e){return e?Object.keys(e.controls).every(i=>e?.controls?.[i].touched||e?.controls?.[i].dirty)&&e.invalid:!1}isSaved=R(!1);ngOnInit(){this.modalConfig.customWidth="650px",this.modalConfig.title="New Customer",this.modalConfig.bodyScrollable=!0,this.modalConfig.hideScrollbar=!0}initRequiredConfig(){this.config?.ModuleContact?.Advance.RequiredFields?.forEach(t=>{this.fieldRequiredConfig[t]===!1&&(this.fieldRequiredConfig[t]=!0)})}initCustomer(){let e=this._posService.Data.AppConfigJSON;this.outlets.set(this._posService.Data?.Entities);let t=e.ModuleContact?.DefaultContactGroup?.ContactGroup;this.customer=new Lo,f.IsNotEmpty(this.data)&&(this.customer.FirstName=this.data.name),f.IsNotEmpty(t)&&(this.customer.Group=t),this.initCustomerCode(e?.ModuleContact?.CodeGenerator?.AutoGenerateEnabled),this.initCustomerSignUpOutlet()}initCustomerSignUpOutlet(){let e=this._registerService.Data;this.customer.CreatorEntityID=e?.EntityID}initCustomerCode(e=!1){e?this._CustomerHttpService.getCustomerSuggestionCode().pipe(ee()).subscribe(t=>{this.customer.Code=t}):this.estimatedCodeMessage=""}ngAfterViewInit(){this.setAutoFocus()}setAutoFocus(){this.firstNameRef.nativeElement.focus()}onKeyUpFirstName(){this.customer.FirstName?this.modalConfig.validated=!0:this.modalConfig.validated=!1}chooiceDetail(e){this.tabState=e}onOk(e){if(e.form.markAllAsTouched(),!e.form.invalid&&this.isSaved()==!1){this.isSaved.set(!0);let t=this._orderDataService.Data;this.customer.Name=this.getCustomerName(),this._CustomerHttpService.addCustomer(this.customer,this.options.DebtLimit).then(i=>{t.ContactName=this.customer.Name,this._orderDataService.pushNewValue(t),this.getCustomerData(i.ID),this.isSaved.set(!1)}).catch(i=>{this.isSaved.set(!1)})}}getCustomerData(e){this._orderDataService.updateCustomerID(e).then(t=>{this.customerData=t,this.close("ok")}).catch(t=>{this.customerData=new xt,this.close("ok")})}getCustomerName(){let e="";return e+=" "+(this.customer.FirstName?this.customer.FirstName:""),e+=" "+(this.customer.LastName?this.customer.LastName:""),e=e.trim(),e}close(e){e==="ok"?this._dialogRef.close(this.customerData):this._dialogRef.close(null)}isNotEmpty(e){return f.IsNotEmpty(e)||e==0}static \u0275fac=function(t){return new(t||n)(P(te),P(z),P(L),P(Re),P(re),P(fe))};static \u0275cmp=N({type:n,selectors:[["POS-modal-customer"]],viewQuery:function(t,i){if(t&1&&(Ut(Ml,5),Ut(xl,5)),t&2){let o;Wt(o=Gt())&&(i.firstNameRef=o.first),Wt(o=Gt())&&(i.customerForm=o.first)}},standalone:!1,decls:119,vars:100,consts:[["customerForm","ngForm"],["firstNameAutoFocus","","FirstName","ngModel"],["phoneNumber","ngModel"],["Email","ngModel"],["birthdateCtrl","ngModel"],["customerCode","ngModel"],["address","ngModel"],["nationalId","ngModel"],["signUpOutletCtrl","ngModel"],[3,"onOk","onCancel","onClose","config"],[1,"container",2,"height","270px"],["name","form"],[1,"row","align-items-center","border-bottom"],[1,"btn","btn-link",3,"click","ngClass"],[1,"fa-regular","fa-circle-exclamation","text-danger"],[1,"mt-6"],["ngModelGroup","generalForm",1,"row",3,"hidden"],[1,"col-2","mt-3"],[1,"form-floating-outline"],["list","cust-title","id","Title","name","Title","placeholder","Title",1,"form-control",3,"ngModelChange","ngModel"],["for","Title"],["id","cust-title"],[3,"value"],[1,"col-5","mt-3"],["type","text","data-cy","FirstName","id","FirstName","name","FirstName","placeholder","First Name",1,"form-control",3,"keyup","ngModelChange","ngClass","ngModel","required"],[3,"ngClass"],["for","FirstName"],["type","text","data-cy","LastName","id","LastName","name","LastName","placeholder","Last Name",1,"form-control",3,"ngModelChange","ngModel"],["for","LastName"],[1,"col-6","mt-4"],["type","text","numericInputOnly","phone","id","Phone","name","Phone","placeholder","Mobile Phone",1,"form-control",3,"ngModelChange","ngClass","ngModel","required"],["for","Phone"],["type","email","id","email","name","Email","placeholder","Email","email","",1,"form-control",3,"ngModelChange","ngClass","ngModel","required"],["for","email"],["placeholder","Birthdate","appearance","outline","name","orderDate",3,"ngModelChange","ngModel","required","ngClass"],[1,"col-md-6","mt-4"],[1,"form-floating-outline","flexRow",3,"ngClass"],["id","customerGender","bindLabel","Value","bindValue","Key","name","customerGender","appendTo","body",1,"productform","tall",3,"ngModelChange","ngModel","items"],["for","customerGender",1,"ng-select"],["ngModelGroup","detailForm",1,"row","mt-2",3,"hidden"],[1,"col-md-4","mt-4"],[1,"form-floating-outline","position-relative"],["type","text","name","code","id","code","placeholder","Customer Code",1,"form-control",2,"padding-right","30px !important",3,"ngModelChange","ngClass","ngModel","required"],["matTooltipPosition","above",1,"fa-solid","fa-circle-info","text-secondary","position-absolute",2,"top","21px","right","9px","font-size","16px",3,"matTooltip"],[1,"invalid-feedback"],["for","code"],[1,"col-4","mt-4"],["id","customerGroup","bindLabel","Name","bindValue","ID","name","customerGroup","appendTo","body",1,"productform","tall",3,"ngModelChange","ngModel","items"],["for","customerGroup",1,"ng-select"],["id","city","bindLabel","Name","bindValue","ID","name","city","appendTo","body",1,"productform","tall",3,"ngModelChange","ngModel","items"],["for","city",1,"ng-select"],[1,"col-md-12","mt-4"],["id","address","name","address","placeholder","Address",1,"form-control",3,"ngModelChange","rows","ngClass","ngModel","required"],["for","address"],["ngModelGroup","idForm",1,"row","mt-2",3,"hidden"],[1,"col-md-6","mt-3"],["type","text","id","Identification","name","Identification","placeholder","NationalID","numericInputOnly","nationalId",1,"form-control",3,"ngModelChange","ngModel","ngClass"],["for","Identification"],["type","text","id","TaxId","name","TaxId","placeholder","TaxID",1,"form-control",3,"ngModelChange","ngModel"],["for","TaxId"],["id","nationality","bindLabel","Name","bindValue","ID","name","nationality","appendTo","body",1,"productform","tall",3,"ngModelChange","ngModel","items"],["for","nationality",1,"ng-select"],["id","customerRace","bindLabel","Name","bindValue","ID","name","customerRace","appendTo","body",1,"productform","tall",3,"ngModelChange","ngModel","items"],["for","customerRace",1,"ng-select"],["id","signUpOutlet","bindLabel","Name","bindValue","ID","name","signUpOutlet","appendTo","body",1,"productform","tall",3,"ngModelChange","ngModel","items","required","ngClass"],["for","signUpOutlet",1,"ng-select"],[1,"invalid-feedback","fst-italic"]],template:function(t,i){if(t&1){let o=E();a(0,"modal-material",9),S("onOk",function(){v(o);let c=ue(4);return _(i.onOk(c))})("onCancel",function(){return v(o),_(i.close("cancel"))})("onClose",function(){return v(o),_(i.close("close"))}),a(1,"content")(2,"div",10)(3,"form",11,0)(5,"div",12)(6,"div")(7,"a",13),S("click",function(){return v(o),_(i.chooiceDetail("general"))}),d(8," General "),h(9,Tl,1,0,"i",14),s(),a(10,"a",13),S("click",function(){return v(o),_(i.chooiceDetail("detail"))}),d(11," Detail "),h(12,El,1,0,"i",14),s(),a(13,"a",13),S("click",function(){return v(o),_(i.chooiceDetail("id"))}),d(14," ID "),h(15,wl,1,0,"i",14),s()()(),a(16,"div",15)(17,"div",16)(18,"div",17)(19,"div",18)(20,"input",19),H("ngModelChange",function(c){return v(o),A(i.customer.Title,c)||(i.customer.Title=c),_(c)}),s(),a(21,"label",20),d(22,"Title"),s(),a(23,"datalist",21),K(24,Rl,1,1,"option",22,ve),s()()(),a(26,"div",23)(27,"div",18)(28,"input",24,1),S("keyup",function(){return v(o),_(i.onKeyUpFirstName())}),H("ngModelChange",function(c){return v(o),A(i.customer.FirstName,c)||(i.customer.FirstName=c),_(c)}),s(),h(31,Nl,2,3,"div",25),a(32,"label",26),d(33,"First Name"),s()()(),a(34,"div",23)(35,"div",18)(36,"input",27),H("ngModelChange",function(c){return v(o),A(i.customer.LastName,c)||(i.customer.LastName=c),_(c)}),s(),a(37,"label",28),d(38,"Last Name"),s()()(),a(39,"div",29)(40,"div",18)(41,"input",30,2),H("ngModelChange",function(c){return v(o),A(i.customer.Mobile,c)||(i.customer.Mobile=c),_(c)}),s(),h(43,Vl,2,2),a(44,"label",31),d(45,"Mobile"),s()()(),a(46,"div",29)(47,"div",18)(48,"input",32,3),H("ngModelChange",function(c){return v(o),A(i.customer.Email,c)||(i.customer.Email=c),_(c)}),s(),a(50,"label",33),d(51,"Email"),s(),h(52,Bl,2,2),s()(),a(53,"div",29)(54,"div",18)(55,"datepicker",34,4),H("ngModelChange",function(c){return v(o),A(i.customer.Birthdate,c)||(i.customer.Birthdate=c),_(c)}),s(),h(57,jl,1,1),s()(),a(58,"div",35)(59,"div",36)(60,"ng-select",37),H("ngModelChange",function(c){return v(o),A(i.customer.Gender,c)||(i.customer.Gender=c),_(c)}),s(),a(61,"label",38),d(62,"Gender"),s()()()(),a(63,"div",39)(64,"div",40)(65,"div",41)(66,"input",42,5),H("ngModelChange",function(c){return v(o),A(i.customer.Code,c)||(i.customer.Code=c),_(c)}),s(),h(68,Ql,1,1,"i",43),h(69,Ul,2,0,"div",44),a(70,"label",45),d(71,"Customer Code"),s()()(),a(72,"div",46)(73,"div",36)(74,"ng-select",47),H("ngModelChange",function(c){return v(o),A(i.customer.Group,c)||(i.customer.Group=c),_(c)}),s(),a(75,"label",48),d(76,"Group"),s()()(),a(77,"div",40)(78,"div",36)(79,"ng-select",49),H("ngModelChange",function(c){return v(o),A(i.customer.City,c)||(i.customer.City=c),_(c)}),s(),a(80,"label",50),d(81,"City"),s()()(),a(82,"div",51)(83,"div",18)(84,"textarea",52,6),H("ngModelChange",function(c){return v(o),A(i.customer.Address,c)||(i.customer.Address=c),_(c)}),s(),a(86,"label",53),d(87,"Address"),s(),h(88,Wl,2,0,"div",44),s()()(),a(89,"div",54)(90,"div",55)(91,"div",18)(92,"input",56,7),H("ngModelChange",function(c){return v(o),A(i.customer.NationalIDNumber,c)||(i.customer.NationalIDNumber=c),_(c)}),s(),h(94,Gl,2,1,"div",44),a(95,"label",57),d(96,"National ID"),s()()(),a(97,"div",55)(98,"div",18)(99,"input",58),H("ngModelChange",function(c){return v(o),A(i.customer.TaxIDNumber,c)||(i.customer.TaxIDNumber=c),_(c)}),s(),a(100,"label",59),d(101,"Tax ID"),s()()(),a(102,"div",35)(103,"div",36)(104,"ng-select",60),H("ngModelChange",function(c){return v(o),A(i.customer.NationalityID,c)||(i.customer.NationalityID=c),_(c)}),s(),a(105,"label",61),d(106,"Nationality"),s()()(),a(107,"div",29)(108,"div",36)(109,"ng-select",62),H("ngModelChange",function(c){return v(o),A(i.customer.RaceID,c)||(i.customer.RaceID=c),_(c)}),s(),a(110,"label",63),d(111,"Customer Racesas"),s()()(),a(112,"div",35)(113,"div",36)(114,"ng-select",64,8),H("ngModelChange",function(c){return v(o),A(i.customer.CreatorEntityID,c)||(i.customer.CreatorEntityID=c),_(c)}),s(),a(116,"label",65),d(117,"Sign Up Outlet"),s(),h(118,ql,2,0,"div",66),s()()()()()()()()}if(t&2){let o=ue(30),r=ue(42),c=ue(49),u=ue(56),O=ue(67),k=ue(85),W=ue(93),ye=ue(115);p("config",i.modalConfig),l(7),p("ngClass",Ue(63,wn,i.tabState=="general",i.tabState!="general"&&i.isGeneralFormInvalid)),l(2),C(i.tabState!="general"&&i.isGeneralFormInvalid?9:-1),l(),p("ngClass",Ue(66,wn,i.tabState=="detail",i.tabState!="detail"&&i.isDetailFormInvalid)),l(2),C(i.tabState!="detail"&&i.isDetailFormInvalid?12:-1),l(),p("ngClass",Ue(69,wn,i.tabState=="id",i.tabState!="id"&&i.isIdFormInvalid)),l(2),C(i.tabState!="id"&&i.isIdFormInvalid?15:-1),l(2),p("hidden",i.tabState!="general"),l(3),B("ngModel",i.customer.Title),l(4),Z(i.options==null?null:i.options.Titles),l(4),p("ngClass",j(72,ct,o.touched&&o.invalid)),B("ngModel",i.customer.FirstName),p("required",!0),l(3),C(o.touched&&o.invalid?31:-1),l(5),B("ngModel",i.customer.LastName),l(5),p("ngClass",j(74,ct,r.invalid&&(r.dirty||r.touched))),B("ngModel",i.customer.Mobile),p("required",i.fieldRequiredConfig.Mobile),l(2),C(r.invalid&&(r.dirty||r.touched)?43:-1),l(5),p("ngClass",j(76,ct,c.invalid&&(c.dirty||c.touched))),B("ngModel",i.customer.Email),p("required",i.fieldRequiredConfig.Email),l(4),C(c.invalid&&(c.dirty||c.touched)?52:-1),l(3),B("ngModel",i.customer.Birthdate),p("required",i.fieldRequiredConfig.Birthdate)("ngClass",j(78,ct,u.invalid&&(u.dirty||u.touched))),l(2),C(u.invalid&&(u.dirty||u.touched)?57:-1),l(2),p("ngClass",j(80,Qt,i.isNotEmpty(i.customer.Gender))),l(),B("ngModel",i.customer.Gender),p("items",i.options==null?null:i.options.Genders),l(3),p("hidden",i.tabState!="detail"),l(3),p("ngClass",j(82,ct,O.invalid&&(O.dirty||O.touched))),B("ngModel",i.customer.Code),p("required",i.fieldRequiredConfig.Code),l(2),C(i.estimatedCodeMessage?68:-1),l(),C(O.invalid&&(O.dirty||O.touched)?69:-1),l(4),p("ngClass",j(84,Qt,i.isNotEmpty(i.customer.Group))),l(),B("ngModel",i.customer.Group),p("items",i.options==null?null:i.options.Groups),l(4),p("ngClass",j(86,Qt,i.isNotEmpty(i.customer.City))),l(),B("ngModel",i.customer.City),p("items",i.options==null?null:i.options.Cities),l(5),p("rows",6)("ngClass",j(88,ct,k.invalid&&(k.dirty||k.touched))),B("ngModel",i.customer.Address),p("required",i.fieldRequiredConfig.Address),l(4),C(k.invalid&&(k.dirty||k.touched)?88:-1),l(),p("hidden",i.tabState!="id"),l(3),B("ngModel",i.customer.NationalIDNumber),p("ngClass",j(90,ct,W.invalid&&(W.dirty||W.touched))),l(2),C(W.getError("minLength")?94:-1),l(5),B("ngModel",i.customer.TaxIDNumber),l(4),p("ngClass",j(92,Qt,i.isNotEmpty(i.customer.NationalityID))),l(),B("ngModel",i.customer.NationalityID),p("items",i.options==null?null:i.options.Nationalities),l(4),p("ngClass",j(94,Qt,i.isNotEmpty(i.customer.RaceID))),l(),B("ngModel",i.customer.RaceID),p("items",i.options==null?null:i.options.Races),l(4),p("ngClass",j(96,Qt,i.isNotEmpty(i.customer.CreatorEntityID))),l(),B("ngModel",i.customer.CreatorEntityID),p("items",i.outlets())("required",i.fieldRequiredConfig.SignUpOutlet)("ngClass",j(98,ct,ye.invalid&&(ye.dirty||ye.touched))),l(4),C(ye.invalid&&(ye.dirty||ye.touched)?118:-1)}},dependencies:[Be,io,no,oo,Te,Pe,Xn,ro,ao,Ee,to,eo,ne,Pt,yi,Pi,Bo],styles:[".text-warning[_ngcontent-%COMP%]{color:var(--bs-warning)!important}.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}.btn-light-danger[_ngcontent-%COMP%]{color:#212529;background-color:#f8d7da!important;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:hover{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5}.btn-light-danger[_ngcontent-%COMP%]:focus, .btn-light-danger.focus[_ngcontent-%COMP%]{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5;box-shadow:0 0 0 .2rem #dc354540}.btn-light-danger.disabled[_ngcontent-%COMP%], .btn-light-danger[_ngcontent-%COMP%]:disabled{color:#212529;background-color:#f8d7da;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]{color:#212529;background-color:#f1aeb5;border-color:#ea868f}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active:focus, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active:focus, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]:focus{box-shadow:0 0 0 .2rem #dc354540}.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:2px solid #07a519}.btn-link.danger[_ngcontent-%COMP%]{color:#c9302c}.form-floating-outline[_ngcontent-%COMP%]{margin-bottom:.2rem!important}"]})};var hn=class n{constructor(e,t,i){this.data=e;this.dialogRef=t;this.salesOrderService=i;this.initModalConfig();let o=f.cloneObject(i.Data);this.orderNumber=o.Order.Number}config;orderNumber;initModalConfig(){this.config=new ie,this.config.hideClose=!0,this.config.title="Edit Number"}onOk(){this.updateSalesOrderNumber(),this.dialogRef.close()}updateSalesOrderNumber(){let e=this.salesOrderService.Data;e.Order.Number=this.orderNumber,this.salesOrderService.pushNewValue(e)}onClose(){this.dialogRef.close()}static \u0275fac=function(t){return new(t||n)(P(fe),P(te),P(L))};static \u0275cmp=N({type:n,selectors:[["POS-modal-number-editor"]],standalone:!1,decls:6,vars:2,consts:[[3,"onOk","onCancel","onClose","config"],[1,"form-floating-outline","mb-0"],["type","text","data-cy","orderNumber","id","orderNumber","name","orderNumber",1,"form-control",3,"ngModelChange","ngModel"],["for","orderNumber"]],template:function(t,i){t&1&&(a(0,"modal-material",0),S("onOk",function(){return i.onOk()})("onCancel",function(){return i.onClose()})("onClose",function(){return i.onClose()}),a(1,"content")(2,"div",1)(3,"input",2),H("ngModelChange",function(r){return A(i.orderNumber,r)||(i.orderNumber=r),r}),s(),a(4,"label",3),d(5,"Order Number"),s()()()()),t&2&&(p("config",i.config),l(3),B("ngModel",i.orderNumber))},dependencies:[Te,Pe,Ee,ne],encapsulation:2})};var Cn=class n{constructor(e,t){this.data=e;this.dialogRef=t;this.modalConfig=new ie,this.modalConfig.title=e.title,this.modalConfig.headerType=e.headerType,this.modalConfig.hideFooter=!0}modalConfig;onClose(e){this.dialogRef.close(e)}static \u0275fac=function(t){return new(t||n)(P(fe),P(te))};static \u0275cmp=N({type:n,selectors:[["POS-modal-customer-reminder"]],decls:13,vars:1,consts:[[3,"onClose","config"],[1,"container-fluid","modal-info"],[1,"text-center","mb-4"],[1,"d-flex","justify-content-center","gap-3","mt-8"],[1,"btn","btn-success",3,"click"],[1,"btn","btn-danger",3,"click"]],template:function(t,i){t&1&&(a(0,"modal-material",0),S("onClose",function(){return i.onClose()}),a(1,"content")(2,"div",1)(3,"div")(4,"h4",2),d(5," No customer has been assigned for this Order. "),b(6,"br"),d(7," Do you want to input customer data? "),s(),a(8,"div",3)(9,"button",4),S("click",function(){return i.onClose("yes")}),d(10,"Yes"),s(),a(11,"button",5),S("click",function(){return i.onClose("no")}),d(12,"No"),s()()()()()()),t&2&&p("config",i.modalConfig)},dependencies:[Ot,ne],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 vn=class n{constructor(e,t,i,o,r,c,u,O,k,W,ye){this.salesOrderService=e;this.toastrService=t;this.pageInitialService=i;this.orderProcessorService=o;this.dialog=r;this.onlineStatusService=c;this.promotionEventService=u;this.outletService=O;this.invoiceCalculatorService=k;this.userRole=W;this.sf=ye;this.initSubscribeObservable()}appConfig;salesOrder;isOnline;localDataService=T(Oe);initSubscribeObservable(){this.salesOrderService.Data$.subscribe(e=>{this.salesOrder=e}),this.pageInitialService.Data$.subscribe(e=>{this.appConfig=e.AppConfigJSON}),this.onlineStatusService.getOnlineStatus$().subscribe(e=>{this.isOnline=e})}payOrder(){if(this.isCartNotEmpty()&&this.validateEmptyOrderNumber()&&this.validateNegativePayment()&&this.isSalesPersonValid()&&this.isCustomerRequired()&&this.validateCustomerID()&&this.validatePromotionDiscount()&&this.validateSelectedRegister())if(this.appConfig.ModuleSell.Header.CustomerNotAssignedReminder&&f.IsEmpty(this.salesOrder.Order.CustomerID)){this.dialog.open(Cn,{id:"ModalInfo",data:{title:"Customer Assign Reminder",headerType:de.Warning},width:"31rem"}).afterClosed().pipe(le(e=>{e=="yes"?this.sf.searchFilterNativeEl.focus():e=="no"&&this.onOpenPaymentModal()})).subscribe();return}else this.onOpenPaymentModal()}validateSelectedRegister(){let e=this.pageInitialService?.Data?.Registers,t=this.salesOrder?.Order?.RegisterID;return f.IsEmpty(t)?(this.toastrService.warning("No register selected","Warning!"),!1):e?.some(o=>o.ID==t)?!0:(this.toastrService.warning("No register selected","Warning!"),!1)}validateNegativePayment(){let e=!0,t=this.invoiceCalculatorService.Data;return this.appConfig.ModuleSell.PaymentDialog.MinusPaymentAllowed==!1&&t<0&&(e=!1,this.toastrService.warning("You are not allowed to process this transaction because the total amount is less than zero","Warning!")),e}validateEmptyOrderNumber(){return f.IsEmpty(this.salesOrder.Order.Number)?(this.toastrService.warning(oe.emptyOrderNumber,"Warning!"),this.openModalEditOrderNumber(),!1):!0}openModalEditOrderNumber(){this.userRole.Data.NumberEditor&&this.dialog.open(hn,{width:"20%"})}isCartNotEmpty(){return this.salesOrderService.Data.CartItems.length<1?(this.toastrService.warning(oe.emptyPOItem,"Warning!"),!1):!0}isSalesPersonValid(){let e=this.pageInitialService.Data.AppConfigJSON,t=this.salesOrderService.Data;if(e.ModuleSell.Header.SalesPersonRequired){if(this.salesOrder.CartItems.every(i=>f.IsNotEmpty(i.SalesID)))return!0;if(t.Order.SalesID==f.GuidEmpty||t.Order.SalesID==null)return this.toastrService.warning(oe.emptySalesPerson,"Warning!"),!1}return!0}validateCustomerID(){let e=this.salesOrderService.Data.Order.CustomerID;if(f.IsEmpty(e)){let t=this.orderProcessorService.Data.InputTextValue;if(f.IsNotEmpty(t)){this.toastrService.warning("Customer is not Saved","Warning");let i=this.userRole?.Data?.ContactsCreate;if(this.appConfig?.ModuleSell?.Customer?.QuickAddEnabled&&i)return this.openCustomerModal(t),!1}}return!0}isCustomerRequired(){let e=this.appConfig.ModuleSell.Header.CustomerRequired,t=this.salesOrder.Order.CustomerID;return e&&this.isOnline&&f.IsEmpty(t)?(this.toastrService.warning(oe.emptyCustomer,"Warning!"),!1):!0}openCustomerModal(e){this.dialog.open(fn,{data:{name:e},autoFocus:!1}).afterClosed().subscribe(t=>{t&&this.onOpenPaymentModal()})}validatePromotionDiscount(){let t=(this.outletService?.Data?.Promotion?this.outletService?.Data?.Promotion:[]).find(c=>c.TypeID===3),i=this.appConfig.ModuleSell.MandatoryActiveDiscount,o=this.promotionEventService.selectedPromotion,r=!0;return i&&t&&(o?o.TypeID!=3&&(r=!1):r=!1),r==!1&&(this.dialog.open(gn,{id:"promotion-event"}),this.toastrService.warning("You need to apply Discount promotion","Required Promotion")),r}onOpenPaymentModal(){this.localDataService.unsentOrders$.pipe(Qe(1),Y(e=>e.length>0&&this.isOnline?this.offlineModal():this.paymentModal())).subscribe()}paymentModal(){return this.dialog.open(un,{id:"ModalPayment",disableClose:!0}).afterClosed()}offlineModal(){return this.dialog.open(rn,{disableClose:!0,id:"ModalOfflineOrder",data:{activeTab:"ORDER"}}).afterClosed()}static \u0275fac=function(t){return new(t||n)(g(L),g(F),g(z),g(je),g(we),g(he),g(Ae),g(re),g(se),g(De),g(jo))};static \u0275prov=I({token:n,factory:n.\u0275fac})};var ir=class n{static \u0275fac=function(t){return new(t||n)};static \u0275mod=di({type:n});static \u0275inj=ci({providers:[vn],imports:[Se,Po,To,vi,mo,yo,Eo,co,po,wo,Ao,Ki,ko,go,$t,Ro,Si,$t]})};export{We as a,G as b,Ei as c,It as d,L as e,z as f,Et as g,De as h,wi as i,Ri as j,Ni as k,re as l,Fi as m,st as n,se as o,Rt as p,Bi as q,Vt as r,Ae as s,Ji as t,_e as u,zi as v,lt as w,Yi as x,Lt as y,je as z,Xo as A,Ki as B,Bt as C,Ht as D,jt as E,dn as F,gn as G,fn as H,hn as I,rn as J,vn as K,ir as L};
|
|
16
|
+
`,headerType:me.Error},width:"31rem"})}emitClearOrder(){this._clearOrder.next(!0)}static \u0275fac=function(t){return new(t||n)(g(B),g(z),g(Tt),g(re),g(xt),g(rt),g(Ae),g(wt),g(Re),g(ae),g(we),g(L),g(Ft),g(De))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Bi=class n{httpService=T(ge);salesOrderService=T(B);orderProcessorService=T(je);promotionCouponFactoryService=T(Et);toastr=T(L);decimalPipe=T(q);couponCode;couponNote;_couponProvider;get couponProvider(){return this._couponProvider}_coupon;get coupon(){return this._coupon}countToastrNotification=0;constructor(){this.orderProcessorService.Data$.pipe(ee()).subscribe(e=>{e.posState==1&&(this._coupon=null,this._couponProvider=null)})}redeemCoupon(e,t,i){let o=this.promotionCouponFactoryService.generateRedeemCouponDto(e,t);this.httpService.post(U.validateExternalCoupon,o).subscribe({next:r=>{this.couponCode=e,this.couponNote=i,this._coupon=r,this._couponProvider=t,this.applyCoupon(r)},error:r=>{this.removeCoupon()}})}applyCoupon(e){let t=e.ApplyToProduct,i=e.Amount;t?.length>0&&i>0?(this.applyCouponToCartItems(e),this.applyCouponToOrder(e)):t?.length>0?this.applyCouponToCartItems(e):this.applyCouponToOrder(e)}applyCouponToOrder(e){let t=this.salesOrderService.Data;e.Type=="Percentage"?t.Order.Discount=e.Amount:t.Order.DiscountAmount=e.Amount,this.showToastrAppliedCoupon(e,"Order"),this.updateSalesOrder(t)}applyCouponToCartItems(e){let t=this.salesOrderService.Data,i=e.ApplyToProduct;if(!this.validateItemsForCoupon(e))return;let o=t.CartItems.map(r=>{let c=i.findIndex(u=>u.Code===r.Variant?.Code);return c!=-1&&(e.Type==="Percentage"?(r.Discount=i[c]?.Amount,r.CouponDiscount=i[c]?.Amount):(r.DiscountAmount=i[c]?.Amount,r.CouponDiscount=i[c]?.Amount)),r});t.CartItems=o,this.showToastrAppliedCoupon(e,"Product"),this.updateSalesOrder(t)}validateItemsForCoupon(e){let t=this.salesOrderService.Data,i=e.ApplyToProduct,o=0;t.CartItems.forEach(c=>{i.findIndex(D=>D.Code===c.Variant?.Code)!=-1&&o++});let r=!0;return o===0&&(this.toastr.error("No products in the cart qualify for coupon use.","Coupon Not Applicable"),this.updateSalesOrder(t,!0),r=!1),r}showToastrAppliedCoupon(e,t){if(f.IsNotEmpty(e.Notification))this.countToastrNotification==0&&this.toastr.success(e.Notification,"Coupon Applied"),this.countToastrNotification+=1;else if(t=="Product")this.toastr.success("Coupon applied to products","Coupon Applied");else if(e.Type==="Percentage")this.toastr.success(`${e.Amount}% Discount`,"Coupon Applied");else{let i=this.decimalPipe.transform(e.Amount,"1.0-2");this.toastr.success(`${i} Discount`,"Coupon Applied")}}removeCoupon(){let e=this._coupon.ApplyToProduct,t=this._coupon.Amount;this._couponProvider=null;let i=this.salesOrderService.Data;e?.length>0&&t>0?(i=this.removeCouponFromCartItems(),i=this.removeCouponFromOrder()):e?.length>0?i=this.removeCouponFromCartItems():i=this.removeCouponFromOrder(),this.updateSalesOrder(i,!0),this._coupon=null}removeCouponFromOrder(){let e=this.salesOrderService.Data;return this._coupon.Type=="Percentage"?e.Order.Discount=0:e.Order.DiscountAmount=0,e}removeCouponFromCartItems(){let e=this.salesOrderService.Data,t=this._coupon.ApplyToProduct,i=e.CartItems.map(o=>(t.findIndex(c=>c.Code===o.Variant?.Code)!=-1&&(o.Discount=0,o.CouponDiscount=0,o.DiscountAmount=0),o));return e.CartItems=i,e}updateSalesOrder(e,t=!1){e.Order.PromotionCoupon=t?null:this.couponCode,e.Order.PromotionNote=t?null:this.couponNote,e.Order.CouponProvider=t?null:this.couponProvider,e.Order.CouponType=t?1:2,this.salesOrderService.pushNewValue(e),this.couponCode=t?null:this.couponCode,this.couponNote=t?null:this.couponNote,this._coupon=t?null:this._coupon,this._couponProvider=t?null:this._couponProvider,this.countToastrNotification=t?0:this.countToastrNotification}static \u0275fac=function(t){return new(t||n)};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};function Br(n,e){if(n&1&&b(0,"img",6),n&2){let t=d(2);p("src",t.printTemplate.Logo,mt)}}function Hr(n,e){if(n&1&&(a(0,"span"),m(1),s()),n&2){let t=d(3);l(),M("(",t.data.Contact.MemberIdentification,")")}}function jr(n,e){if(n&1&&(a(0,"div",12)(1,"h3")(2,"span"),m(3),s()(),a(4,"div",37)(5,"strong"),m(6),s(),h(7,Hr,2,1,"span"),a(8,"div",38)(9,"div")(10,"span"),m(11),s()(),a(12,"div")(13,"span"),m(14),s()(),a(15,"div"),b(16,"span",10),s(),a(17,"div")(18,"span"),m(19),s()()()()()),n&2){let t=d(2);l(3),O(t.appConfigJson.PrintConfigInvoice.DocumentLabel.Customer),l(3),O(t.data.ContactDisplay),l(),C(t.data.Contact.MemberIdentification?7:-1),l(4),O(t.data.Contact.Email),l(3),O(t.data.Contact.Phone?t.data.Contact.Phone:t.data.Contact.Mobile),l(2),p("innerHTML",t.data.Contact.Address,Je),l(3),O(t.data.City)}}function Qr(n,e){if(n&1&&(a(0,"span"),m(1),s()),n&2){let t=d(3);l(),M(", ",t.data.Shipping.Phone)}}function Ur(n,e){if(n&1&&(a(0,"div",14)(1,"h3"),m(2),s(),a(3,"div",37)(4,"div"),m(5),h(6,Qr,2,1,"span"),s(),b(7,"div",10),a(8,"div"),m(9),s()()()),n&2){let t=d(2);l(2),M(" ",t.appConfigJson.PrintConfigInvoice.DocumentLabel.ShippingAddress," "),l(3),M(" ",t.data.Shipping.Name),l(),C(t.data.Shipping.Phone?6:-1),l(),p("innerHTML",t.data.Shipping.Street,Je),l(2),M(" ",t.data.Shipping.City," ")}}function Wr(n,e){if(n&1&&b(0,"i",39),n&2){let t=d().$implicit;p("innerHTML",t.Note,Je)}}function Gr(n,e){if(n&1&&(a(0,"div"),m(1),s()),n&2){let t=d().$implicit;l(),M("-",t.Discount,"%")}}function qr(n,e){if(n&1&&(a(0,"div"),m(1),s()),n&2){let t=d().$implicit;l(),M(" -",t.DiscountAmount," ")}}function $r(n,e){if(n&1&&(a(0,"tr")(1,"td",11),m(2),s(),a(3,"td"),m(4),a(5,"div"),h(6,Wr,1,1,"i",39),s()(),a(7,"td"),m(8),s(),a(9,"td",11),m(10),y(11,"number"),s(),a(12,"td"),m(13),s(),a(14,"td",11),m(15),y(16,"number"),s(),a(17,"td",40),h(18,Gr,2,1,"div"),h(19,qr,2,1,"div"),s(),a(20,"td",11),m(21),y(22,"TrailingZero"),s()()),n&2){let t=e.$implicit,i=e.$index,o=d(2);l(2),M("",i+1,"."),l(2),M(" ",t.Name," "),l(2),C(t.Note!=null?6:-1),l(2),O(t.Code),l(2),O(x(11,10,t.Quantity)),l(3),O(t.UOMName),l(2),O(x(16,12,t.UnitPrice)),l(3),C(t.Discount!=0?18:-1),l(),C(t.DiscountAmount!=0?19:-1),l(2),M(" ",X(22,14,t.Total,o.appConfigJson.PrintConfigGeneral.TrailingZero)," ")}}function Jr(n,e){if(n&1&&(a(0,"span"),m(1),y(2,"sum"),s()),n&2){let t=d().$index,i=d(2);l(),M(" ",t==0&&(i.data==null?null:i.data.Items.length)>1?"Qty: "+X(2,1,i.data.Items,"Quantity"):"")}}function zr(n,e){if(n&1&&(a(0,"tr")(1,"th",41),h(2,Jr,3,4,"span"),m(3),s(),a(4,"th"),m(5,":"),s(),a(6,"th",42),m(7),s(),a(8,"th",43),m(9),y(10,"TrailingZero"),s()()),n&2){let t=e.$implicit,i=e.$index,o=d(2);l(2),C(o.appConfigJson.PrintConfigInvoice.ItemsFooter.TotalQuantityVisible?2:-1),l(),M(" ",(o.data==null?null:o.data.Payments.length)>1&&i==(o.data==null?null:o.data.AmountSummary.length)-2?"Payment":t.Label," "),l(4),O(t.CurrencySymbol),l(2),M(" ",X(10,4,t.Amount,o.appConfigJson.PrintConfigGeneral.TrailingZero)," ")}}function Yr(n,e){if(n&1&&(a(0,"tr")(1,"th"),m(2),s(),a(3,"td"),m(4,":"),s(),a(5,"td",42),m(6),s(),a(7,"td",22),m(8),y(9,"TrailingZero"),s()()),n&2){let t=e.$implicit,i=d(2);l(2),O(t.Label),l(4),O(t.CurrencySymbol),l(2),M(" ",X(9,3,t.Amount,i.appConfigJson.PrintConfigGeneral.TrailingZero)," ")}}function Kr(n,e){if(n&1&&(a(0,"span")(1,"span",44),m(2),y(3,"date"),s(),m(4),y(5,"number"),b(6,"br"),s()),n&2){let t=e.$implicit,i=d(3);l(),p("hidden",i.data.Payments),l(),O(X(3,5,t.Date,"dd MMM yy")),l(2),Hn(" ",t.MethodName," ",t.Note?t.Note:""," ",x(5,8,t.Amount)," ")}}function Zr(n,e){if(n&1&&(a(0,"tr"),b(1,"th",10),a(2,"td"),m(3,":"),s(),a(4,"td"),K(5,Kr,7,10,"span",null,ve),s()()),n&2){let t=d(2);l(),p("innerHTML",t.data.Invoice.PaymentStateID==2?"Down Payment":"Payment",Je),l(4),Z(t.data.Payments)}}function Xr(n,e){if(n&1&&(a(0,"tr")(1,"th"),m(2,"Delivery"),s(),a(3,"td"),m(4,":"),s(),a(5,"td")(6,"ul",45)(7,"li"),m(8),s()()()()),n&2){let t=d(2);l(8),M(" ",t.data.CustomerTransaction==null?null:t.data.CustomerTransaction.SO.DeliveryStateString," ")}}function ea(n,e){if(n&1&&(a(0,"tr")(1,"th",46),m(2,"Remaining"),s(),a(3,"td"),m(4,":"),s(),b(5,"td",47),y(6,"sum"),y(7,"number"),s()),n&2){let t=d(2);l(5),p("innerHtml",x(7,4,(t.data==null?null:t.data.FinalAmount)-X(6,1,t.data==null?null:t.data.Payments,"Amount")),Je)}}function ta(n,e){if(n&1&&(a(0,"tr")(1,"th"),m(2,"Note"),s(),a(3,"td"),m(4,":"),s(),a(5,"td")(6,"ul",45)(7,"li"),m(8),s()()()()),n&2){let t=d(2);l(8),M(" ",t.data.Invoice==null?null:t.data.Invoice.Note," ")}}function ia(n,e){if(n&1&&(a(0,"div",31)(1,"h5"),m(2),s(),a(3,"div",30),m(4,"\xA0"),s()()),n&2){let t=d(2);l(2),M(" ",t.appConfigJson.PrintConfigInvoice==null?null:t.appConfigJson.PrintConfigInvoice.FooterLabel.ApprovedBy," ")}}function na(n,e){if(n&1&&(a(0,"div",32)(1,"h5"),m(2),s(),a(3,"div",30),m(4,"\xA0"),s()()),n&2){let t=d(2);l(2),M(" ",t.appConfigJson.PrintConfigDelivery==null?null:t.appConfigJson.PrintConfigDelivery.FooterLabel.DeliveredBy," ")}}function oa(n,e){if(n&1&&b(0,"div",36),n&2){let t=d(2);p("innerHTML",t.printTemplate.FooterRight,Je)}}function ra(n,e){if(n&1&&(a(0,"div"),b(1,"link",0),y(2,"StylesheetSafeUrl"),a(3,"div",1)(4,"div",2)(5,"div",3)(6,"div",4)(7,"div",5),h(8,Br,1,1,"img",6),a(9,"div",7)(10,"h2"),m(11),s(),a(12,"small"),m(13),s(),a(14,"div",8)(15,"div",9),b(16,"span",10),y(17,"newlines"),s(),a(18,"div",11),b(19,"span",10),y(20,"newlines"),s()()()(),h(21,jr,20,7,"div",12),s(),a(22,"div",13)(23,"h1")(24,"strong"),m(25),s(),a(26,"span"),m(27),s()(),a(28,"div")(29,"table")(30,"thead")(31,"tr")(32,"th"),m(33,"Date"),s()()(),a(34,"tbody")(35,"tr")(36,"td"),m(37),y(38,"date"),s()()()()(),h(39,Ur,10,5,"div",14),s()()(),a(40,"section",15)(41,"div",16)(42,"table",17)(43,"thead",18)(44,"tr")(45,"th",19),m(46,"No"),s(),a(47,"th"),m(48,"Name"),s(),a(49,"th",20),m(50,"Code"),s(),a(51,"th",21),m(52,"Qty"),s(),a(53,"th",22),m(54,"UOM"),s(),a(55,"th",23),m(56),s(),a(57,"th",24),m(58,"Disc"),s(),a(59,"th",23),m(60),s()()(),a(61,"tbody"),K(62,$r,23,17,"tr",null,ve),s()(),a(64,"div",25)(65,"table",26)(66,"tbody"),K(67,zr,11,7,"tr",null,ve),s(),a(69,"tbody"),K(70,Yr,10,6,"tr",null,ve),s()()()()(),a(72,"table",27),h(73,Zr,7,1,"tr"),h(74,Xr,9,1,"tr"),h(75,ea,8,6,"tr"),h(76,ta,9,1,"tr"),s(),a(77,"div")(78,"div")(79,"div",28)(80,"div",29)(81,"h5"),m(82),s(),a(83,"div",30),m(84,"\xA0"),s()(),h(85,ia,5,1,"div",31),h(86,na,5,1,"div",32),a(87,"div",33)(88,"h5"),m(89),s(),a(90,"div",30),m(91),s()()()()(),a(92,"div",34),b(93,"div",35),h(94,oa,1,1,"div",36),s()()()),n&2){let t=d();l(),mi("href",t.stylesheet!=null&&t.stylesheet.SizeA4?x(2,25,t.stylesheet==null?null:t.stylesheet.SizeA4):null,Vn),l(7),C(t.printTemplate.Logo?8:-1),l(3),O(t.printTemplate.Title),l(2),O(t.printTemplate.Field),l(3),p("innerHTML",x(17,27,t.printTemplate.Address),Je),l(3),p("innerHTML",x(20,29,t.printTemplate.ContactInfo),Je),l(2),C(t.data.ContactDisplay?21:-1),l(4),O(t.data.Prefixed),l(2),M(" ",t.data.Invoice==null?null:t.data.Invoice.Number," "),l(10),O(X(38,31,t.data.Invoice==null?null:t.data.Invoice.Date,"dd MMM yyyy")),l(2),C(t.data.Shipping?39:-1),l(17),M(" Price(",t.data.CurrencySymbol,") "),l(4),M(" Total(",t.data.CurrencySymbol,") "),l(2),Z(t.data.Items),l(5),Z(t.data==null?null:t.data.AmountSummary),l(3),Z(t.data==null?null:t.data.PaidAmountSummary),l(3),C(t.appConfigJson.PrintConfigInvoice!=null&&t.appConfigJson.PrintConfigInvoice.Footer.PaymentMethodVisible&&t.data.Payments.length>0?73:-1),l(),C((t.data.CustomerTransaction==null?null:t.data.CustomerTransaction.SO)!=null&&(t.data.CustomerTransaction==null?null:t.data.CustomerTransaction.SO.DeliveryStateID)!=3&&(t.appConfigJson.PrintConfigInvoice!=null&&t.appConfigJson.PrintConfigInvoice.Footer.DeliveryInfoVisible)?74:-1),l(),C(!(t.data==null||t.data.Invoice==null)&&t.data.Invoice.PaymentStateID&&(t.data==null||t.data.Invoice==null?null:t.data.Invoice.PaymentStateID)<3?75:-1),l(),C(t.data.Invoice!=null&&t.data.Invoice.Note?76:-1),l(6),M(" ",t.appConfigJson.PrintConfigInvoice==null?null:t.appConfigJson.PrintConfigInvoice.FooterLabel.ReceivedBy," "),l(3),C((t.appConfigJson.PrintConfigDelivery==null?null:t.appConfigJson.PrintConfigDelivery.Footer.SignatureCountType)==1||(t.appConfigJson.PrintConfigDelivery==null?null:t.appConfigJson.PrintConfigDelivery.Footer.SignatureCountType)==2?85:-1),l(),C((t.appConfigJson.PrintConfigDelivery==null?null:t.appConfigJson.PrintConfigDelivery.Footer.SignatureCountType)==2?86:-1),l(3),M(" ",t.appConfigJson.PrintConfigInvoice==null?null:t.appConfigJson.PrintConfigInvoice.FooterLabel.SignedBy," "),l(2),M(" ",t.data.ItemTransfer==null?null:t.data.ItemTransfer.Courier," "),l(2),p("ngClass",!t.printTemplate.FooterRight&&"single")("innerHTML",t.printTemplate.FooterLeft,Je),l(),C(t.printTemplate.FooterRight?94:-1)}}var Xo=class n{data;outletInfo;appConfigJson;printTemplate;stylesheet;constructor(){}ngOnInit(){}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=A({type:n,selectors:[["POS-bill-receipt-A4"]],inputs:{data:"data",outletInfo:"outletInfo",appConfigJson:[0,"config","appConfigJson"],printTemplate:"printTemplate",stylesheet:"stylesheet"},standalone:!1,decls:1,vars:1,consts:[["rel","stylesheet"],[1,"print_container"],[1,"sales_order_A4"],[1,"header","clearfix"],[1,"header_left"],[1,"company"],[1,"float",3,"src"],[1,"companyBody"],[1,"contact_info","clearfix"],[1,"address"],[3,"innerHTML"],[1,"number"],[1,"contact",2,"min-width","400px"],[1,"header_right"],[1,"contact","shippingAddress","mt-3"],[1,"cart-mini-items"],[1,"cartItems"],[1,"w-100","table","table-sm","table-bordered","plain"],[2,"background","#fdf3c6"],[1,"number",2,"width","20px"],[2,"width","100px"],[1,"number",2,"width","50px"],[2,"width","50px"],[1,"number",2,"width","100px"],[1,"number","text-end",2,"width","20px"],[1,"col-12"],[1,"table","table-sm","table-borderless","d-flex","justify-content-end"],[1,"info"],[1,"signature"],[1,"left"],[1,"name"],[1,"left","leftSmall"],[1,"left","rightSmall"],[1,"right"],[1,"note"],[1,"left",3,"ngClass","innerHTML"],[1,"right",3,"innerHTML"],[1,"box"],[1,"customer_info"],[1,"special-TinyMCE",2,"word-break","break-all",3,"innerHTML"],[1,"number","red","text-end"],["colspan","3"],[1,"currency"],[1,"text-end",2,"width","50px"],[3,"hidden"],[1,"float"],[1,"bg-light-gray"],[3,"innerHtml"]],template:function(t,i){t&1&&h(0,ra,95,34,"div"),t&2&&C(i.data?0:-1)},dependencies:[Be,q,Ye,fo,ho,Co,No],styles:['a.linkMini[_ngcontent-%COMP%]{left:130px;position:absolute;top:.5px;text-decoration:none;color:#3b5998}div.print_container[_ngcontent-%COMP%]{margin:0 auto;width:900px;text-align:left;color:#000;position:relative}div.print_container[_ngcontent-%COMP%], div.print_container[_ngcontent-%COMP%] h1[_ngcontent-%COMP%], div.print_container[_ngcontent-%COMP%] h2[_ngcontent-%COMP%], div.print_container[_ngcontent-%COMP%] h3[_ngcontent-%COMP%], div.print_container[_ngcontent-%COMP%] h4[_ngcontent-%COMP%], div.print_container[_ngcontent-%COMP%] h5[_ngcontent-%COMP%], div.print_container[_ngcontent-%COMP%] h6[_ngcontent-%COMP%]{font-family:Arial!important;background-color:#fff}div.mode[_ngcontent-%COMP%]{color:gray;font-size:11px;text-align:right;height:20px;padding-top:2px}div.mode[_ngcontent-%COMP%] span[_ngcontent-%COMP%], div.mode[_ngcontent-%COMP%] ul[_ngcontent-%COMP%], div.mode[_ngcontent-%COMP%] ul[_ngcontent-%COMP%] li[_ngcontent-%COMP%]{float:left;display:block;margin:0;padding:0}div.mode[_ngcontent-%COMP%] ul[_ngcontent-%COMP%] li[_ngcontent-%COMP%]:first-child{padding-right:5px;margin-right:5px;border-right:solid 1px gray}div.mode[_ngcontent-%COMP%] div.printer[_ngcontent-%COMP%]{float:left}div.mode[_ngcontent-%COMP%] div.template[_ngcontent-%COMP%]{float:right}div.mode[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{margin:0 5px}div.header[_ngcontent-%COMP%] div.contact[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{font-size:12px;margin:0 5px 0 0;padding:0;font-weight:700;float:left}div.copy[_ngcontent-%COMP%]{background-image:url(/Images/Print/copy_bg.png);background-repeat:no-repeat;background-position:50% 70px}div.note[_ngcontent-%COMP%] div.left[_ngcontent-%COMP%]{float:left;margin-left:5px;width:440px}div.note-info[_ngcontent-%COMP%]{margin:auto;width:23%}table.info[_ngcontent-%COMP%]{border-collapse:collapse;margin-top:5px;margin-left:5px}table.info[_ngcontent-%COMP%] th[_ngcontent-%COMP%], table.info[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:5px 7px;border:solid 1px #d8d8d8}table.info[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{background-color:#f6f6f6}div.fullContainer[_ngcontent-%COMP%] div.print_container[_ngcontent-%COMP%]{min-height:970px;position:relative}.clearfix[_ngcontent-%COMP%]{zoom:1}div.reportMargin[_ngcontent-%COMP%]{margin:20px 0 0}@media print{div.mode[_ngcontent-%COMP%], .linkMini[_ngcontent-%COMP%]{display:none;visibility:hidden;height:0px}thead[_ngcontent-%COMP%]{display:table-header-group}}small.creator[_ngcontent-%COMP%]{padding:2px 0 20px;font-style:normal}span.titleJB[_ngcontent-%COMP%]{font-weight:700;padding:10px 0 7px 8px;display:block}.topHolder[_ngcontent-%COMP%]{margin-top:15px!important}h1.jobOrderHeader[_ngcontent-%COMP%]{text-align:center}body[_ngcontent-%COMP%]{padding:0;font-size:12px}div.print_container[_ngcontent-%COMP%]{margin:0 auto!important;text-align:left;color:#000;position:relative}div.mode[_ngcontent-%COMP%]{color:gray;text-align:right;height:20px;padding-top:2px;font-size:10px}div.mode[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{float:left;display:block;margin:0 5px 0 0;padding:0}div.mode[_ngcontent-%COMP%] ul[_ngcontent-%COMP%]{float:left;display:block;margin:0;padding:0}div.mode[_ngcontent-%COMP%] ul[_ngcontent-%COMP%] li[_ngcontent-%COMP%]{float:left;display:block;margin:0 5px 0 0;padding:0 5px 0 0;border-right:solid 1px gray}div.mode[_ngcontent-%COMP%] ul[_ngcontent-%COMP%] li[_ngcontent-%COMP%]:last-child{border-right:none}div.mode[_ngcontent-%COMP%] a[_ngcontent-%COMP%]{color:#3b5998;text-decoration:none}div.mode[_ngcontent-%COMP%] a[_ngcontent-%COMP%]:hover{text-decoration:underline}div.mode[_ngcontent-%COMP%] a.active[_ngcontent-%COMP%]{color:gray}div.mode[_ngcontent-%COMP%] a.active[_ngcontent-%COMP%]:hover{text-decoration:none}div.header[_ngcontent-%COMP%]{width:100%;overflow:auto}div.header_left[_ngcontent-%COMP%]{float:left;padding:5px 0 0 5px}div.header_left[_ngcontent-%COMP%] h1[_ngcontent-%COMP%]{margin:5px 0 0;padding:0;font-size:18px}div.header_right[_ngcontent-%COMP%]{float:right;padding:0 5px 0 0;max-width:425px}div.header_right[_ngcontent-%COMP%] h1[_ngcontent-%COMP%]{margin:0;padding:0;text-align:right}div.header_right[_ngcontent-%COMP%] h1[_ngcontent-%COMP%] strong[_ngcontent-%COMP%]{font-size:16px;font-weight:700;margin:0 5px 0 0;text-transform:uppercase}div.header_right[_ngcontent-%COMP%] h1[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{font-size:18px;font-weight:400}div.header_right[_ngcontent-%COMP%] table[_ngcontent-%COMP%]{float:right;border-collapse:collapse}div.header_right[_ngcontent-%COMP%] table[_ngcontent-%COMP%] th[_ngcontent-%COMP%], div.header_right[_ngcontent-%COMP%] table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{border:solid 1px #9E9E9E;padding:4px}div.header_right[_ngcontent-%COMP%] table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{background:#f6f6f6}div.header_right[_ngcontent-%COMP%] table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding-bottom:6px}div.header[_ngcontent-%COMP%] img.float[_ngcontent-%COMP%]{margin:5px 0 0 5px;float:left}div.header[_ngcontent-%COMP%] div.company[_ngcontent-%COMP%]{width:100%;overflow:auto;margin:0 0 8px}div.header[_ngcontent-%COMP%] div.companyBody[_ngcontent-%COMP%]{float:left}div.header[_ngcontent-%COMP%] div.companyBody[_ngcontent-%COMP%] h2[_ngcontent-%COMP%]{font-size:18px;font-weight:700;margin:0;padding:0}div.header[_ngcontent-%COMP%] div.companyBody[_ngcontent-%COMP%] small[_ngcontent-%COMP%]{font-size:11px;text-align:left;font-weight:400}div.header[_ngcontent-%COMP%] div.companyBody[_ngcontent-%COMP%] div.contact_info[_ngcontent-%COMP%]{margin-top:3px}div.header[_ngcontent-%COMP%] div.companyBody[_ngcontent-%COMP%] div.contact_info[_ngcontent-%COMP%] div.address[_ngcontent-%COMP%]{float:left;min-width:125px}div.header[_ngcontent-%COMP%] div.companyBody[_ngcontent-%COMP%] div.contact_info[_ngcontent-%COMP%] div.number[_ngcontent-%COMP%]{margin-right:5px;min-width:160px}div.header[_ngcontent-%COMP%] div.contact[_ngcontent-%COMP%]{width:max-content;overflow:auto;border:solid 1px #9E9E9E;padding:5px}div.header[_ngcontent-%COMP%] div.contact[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{font-size:12px;margin:0 5px 0 0;padding:0;font-weight:700}div.cartItems[_ngcontent-%COMP%]{padding:10px 3px 2px 5px}div.copy[_ngcontent-%COMP%]{background-image:url(/Images/Print/copy_bg.png);background-repeat:no-repeat;background-position:50% 70px}div.topNote[_ngcontent-%COMP%]{clear:both;text-align:right}div.invoiceNote[_ngcontent-%COMP%]{padding:10px 0 0 7px}div.note[_ngcontent-%COMP%]{position:relative}div.note[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{font-weight:700;font-size:12px;margin:0 0 3px;padding:0}div.note[_ngcontent-%COMP%] div.single[_ngcontent-%COMP%]{width:895px!important}div.note[_ngcontent-%COMP%] div.left[_ngcontent-%COMP%]{float:left;margin-left:5px;width:440px;text-align:left}div.note[_ngcontent-%COMP%] div.left[_ngcontent-%COMP%] ol[_ngcontent-%COMP%]{margin:5px 0 0;padding:0 0 0 20px}div.note[_ngcontent-%COMP%] div.left[_ngcontent-%COMP%] ol[_ngcontent-%COMP%] li[_ngcontent-%COMP%]{margin:0 0 2px}div.note[_ngcontent-%COMP%] div.left[_ngcontent-%COMP%] ul[_ngcontent-%COMP%]{margin:2px 0 5px;padding:0 0 0 20px}div.note[_ngcontent-%COMP%] div.left[_ngcontent-%COMP%] ul[_ngcontent-%COMP%] li[_ngcontent-%COMP%]{margin:0 0 2px}div.note[_ngcontent-%COMP%] div.right[_ngcontent-%COMP%]{float:right;width:440px;border-left:solid 1px #CACACA;padding-left:8px;margin-right:5px}div.note[_ngcontent-%COMP%] div.right[_ngcontent-%COMP%] ul[_ngcontent-%COMP%]{margin:0;padding:0;list-style:none}div.note[_ngcontent-%COMP%] div.right[_ngcontent-%COMP%] h3.closing[_ngcontent-%COMP%]{margin-top:10px;text-align:right}.clearfix[_ngcontent-%COMP%]:before, .clearfix[_ngcontent-%COMP%]:after{content:"";display:table}.clearfix[_ngcontent-%COMP%]:after{clear:both}small.timestamp[_ngcontent-%COMP%], small.creator[_ngcontent-%COMP%], small.printed[_ngcontent-%COMP%]{font-size:12px;text-align:center;display:block;font-style:italic;padding:2px 0}.shippingAddress[_ngcontent-%COMP%]{text-align:right;min-width:240px;clear:both}.shippingAddress[_ngcontent-%COMP%] div.box[_ngcontent-%COMP%] div[_ngcontent-%COMP%]:first-child{text-align:left;font-weight:700}.packingSlip[_ngcontent-%COMP%]{min-width:150px}.customer_info[_ngcontent-%COMP%]{min-width:310px}.special-TinyMCE[_ngcontent-%COMP%]{padding-top:10px!important}@media print{body[_ngcontent-%COMP%]{font-family:Arial;color:#000}}@-moz-document url-prefix(){}div.signature[_ngcontent-%COMP%], div.signature-b[_ngcontent-%COMP%]{clear:both;height:111px;margin-top:25px}div.signature[_ngcontent-%COMP%] h5[_ngcontent-%COMP%]{margin:0 0 80px;padding:0;font-size:12px;font-weight:700}div.signature[_ngcontent-%COMP%] div.name[_ngcontent-%COMP%]{border-top:solid 1px Gray;height:15px;text-align:center}div.signature[_ngcontent-%COMP%] div.left[_ngcontent-%COMP%]{float:left;margin-left:70px;width:150px}div.signature[_ngcontent-%COMP%] div.center[_ngcontent-%COMP%]{float:left;margin-left:155px;width:150px}div.signature[_ngcontent-%COMP%] div.noLeftMargin[_ngcontent-%COMP%]{margin-left:0!important}div.signature[_ngcontent-%COMP%] div.leftSmall[_ngcontent-%COMP%]{margin-left:120px!important}div.signature[_ngcontent-%COMP%] div.left[_ngcontent-%COMP%] h5[_ngcontent-%COMP%], div.signature[_ngcontent-%COMP%] div.center[_ngcontent-%COMP%] h5[_ngcontent-%COMP%]{text-align:center}div.signature[_ngcontent-%COMP%] div.right[_ngcontent-%COMP%]{float:right;width:150px;margin-right:5px}div.print_container[_ngcontent-%COMP%] div.footerNote[_ngcontent-%COMP%]{padding-left:5px;width:150px}div.signature[_ngcontent-%COMP%] div.right[_ngcontent-%COMP%] h5[_ngcontent-%COMP%]{text-align:center}div.fullSignatureNote[_ngcontent-%COMP%]{position:absolute;bottom:0;width:100%}table[_ngcontent-%COMP%] tfoot[_ngcontent-%COMP%]{display:table-row-group}table.plain[_ngcontent-%COMP%]{border-collapse:collapse}table.plain[_ngcontent-%COMP%] thead[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{text-shadow:0 -1px 0 rgba(0,0,0,.4);height:28px;line-height:16px;padding:2px 7px;color:#fff;font-weight:700}table.plain[_ngcontent-%COMP%] thead[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]{background-color:#fceca3!important;background-image:none!important}table.plain[_ngcontent-%COMP%] thead[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{color:#000;text-shadow:none}table.plain[_ngcontent-%COMP%] th[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:5px 7px}table.plain[_ngcontent-%COMP%] tr.thick[_ngcontent-%COMP%] th[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] tr.thick[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{border-bottom:3px solid black}table.plain[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:nth-child(2n){background-color:#f6f6f6}table.plain[_ngcontent-%COMP%] a.thumb[_ngcontent-%COMP%]{margin:0 5px 0 0;padding:0;float:left;display:block}table.plain[_ngcontent-%COMP%] a.thumb[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{width:40px;height:40px;background-color:#fff;display:block;background-color:#d8dfea;border:1px solid #bbb;-webkit-border-radius:3px;border-radius:3px}table.plain[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{color:#2b4e75;font-style:italic;margin:0;padding:0}table.plain[_ngcontent-%COMP%] div.text[_ngcontent-%COMP%]{padding:2px 0 0}table.plain[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] td[_ngcontent-%COMP%] a[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] td[_ngcontent-%COMP%] a[_ngcontent-%COMP%]:visited{display:block;color:#00f;text-decoration:none}table.plain[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(-n+3) a[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(-n+3) a[_ngcontent-%COMP%]:visited{font-weight:700}table.plain[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] td[_ngcontent-%COMP%] a[_ngcontent-%COMP%]:hover{text-decoration:underline}table.plain[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{margin:0;padding:0;display:block}table.plain[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] input.txtPrice[_ngcontent-%COMP%]{border:solid 1px #C8D3DF;padding:3px;text-align:right}table.plain[_ngcontent-%COMP%] tr.group[_ngcontent-%COMP%]{background-color:#fdf3c6!important}table.plain[_ngcontent-%COMP%] tr.group[_ngcontent-%COMP%] a[_ngcontent-%COMP%]{color:#000!important}table.plain[_ngcontent-%COMP%] thead[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] th[_ngcontent-%COMP%] a[_ngcontent-%COMP%]{color:#fff}table.plain[_ngcontent-%COMP%] th.borderLRB0[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] td.borderLRB0[_ngcontent-%COMP%]{border-left-width:0px!important;border-right-width:0px!important;border-bottom-width:0px!important;background-color:#fff!important}table.plain[_ngcontent-%COMP%] th.number[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] td.number[_ngcontent-%COMP%]{text-align:right}table.plain[_ngcontent-%COMP%] th.numberCenter[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] td.numberCenter[_ngcontent-%COMP%]{text-align:center}table.plain[_ngcontent-%COMP%] th.red[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] td.red[_ngcontent-%COMP%]{color:red;text-align:right}table.plain[_ngcontent-%COMP%] td.top[_ngcontent-%COMP%]{vertical-align:top}table.plain[_ngcontent-%COMP%] td.noTopPad[_ngcontent-%COMP%]{padding-top:0}table.plain[_ngcontent-%COMP%] td.small[_ngcontent-%COMP%]{font-size:11px}table.plain[_ngcontent-%COMP%] tr.grid_footer[_ngcontent-%COMP%] th[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] tr.grid_footer[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{border-width:0px;background-color:#fff}table.plain[_ngcontent-%COMP%] span.serial[_ngcontent-%COMP%]{display:inline-block;margin-left:10px}table.plain[_ngcontent-%COMP%] tr.grid_footer[_ngcontent-%COMP%] table[_ngcontent-%COMP%] th[_ngcontent-%COMP%], table.plain[_ngcontent-%COMP%] tr.grid_footer[_ngcontent-%COMP%] table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:5px 0 5px 5px;background-color:#fff}table.plain[_ngcontent-%COMP%] td[_ngcontent-%COMP%] .inlineMarginLeft[_ngcontent-%COMP%]{display:inline-block;margin-left:10px}table.rightAuto[_ngcontent-%COMP%]{margin:0 0 0 auto}table[_ngcontent-%COMP%] ul.float[_ngcontent-%COMP%]{margin:0;padding:0;list-style-type:circle;list-style-position:inside}table[_ngcontent-%COMP%] ul.float[_ngcontent-%COMP%] li[_ngcontent-%COMP%]{margin:0 20px 0 0;padding:0;float:left;display:block}table[_ngcontent-%COMP%] ul.float[_ngcontent-%COMP%] li[_ngcontent-%COMP%] a[_ngcontent-%COMP%]{text-decoration:none}table[_ngcontent-%COMP%] ul.float[_ngcontent-%COMP%] li[_ngcontent-%COMP%] a[_ngcontent-%COMP%]:hover{text-decoration:underline}div.scroll[_ngcontent-%COMP%]{width:100%;overflow:auto;padding:0 0 2px}table.fixed[_ngcontent-%COMP%]{table-layout:fixed}table.footer_row[_ngcontent-%COMP%]{margin:5px 8px 0 auto}table.footer_row[_ngcontent-%COMP%] td.currency[_ngcontent-%COMP%], table.footer_row[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:last-child{padding:5px 0 5px 5px;text-align:right}table.footer_row[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{padding:5px;text-align:right;float:left}table.footer_adjust[_ngcontent-%COMP%]{margin:-10px 18px 0 auto}table.footer_adjust[_ngcontent-%COMP%] td.currency[_ngcontent-%COMP%], table.footer_adjust[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:last-child{padding:5px 0 5px 5px;text-align:right}table.footer_adjust[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{padding:5px 23px 5px 5px;text-align:right;float:left}table.total-all-grid[_ngcontent-%COMP%]{width:100%!important;border-collapse:collapse;margin-top:10px}table.manufacture[_ngcontent-%COMP%]{width:100%;border-collapse:collapse}table.manufacture[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{background-color:#fceca3!important}table.manufacture[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{border:1px solid #BBBBBB!important}table.accounting[_ngcontent-%COMP%]{max-width:1000px;border-collapse:collapse}table.accounting[_ngcontent-%COMP%] thead[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{border-top:1px solid #999;border-bottom:1px solid #999;height:28px;line-height:16px;color:#444;background-color:#fceca3!important}table.accounting[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:nth-child(2n){background-color:#f6f6f6}table.accounting[_ngcontent-%COMP%] th[_ngcontent-%COMP%], table.accounting[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:7px;border-bottom:1px solid black}table.accounting[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] td[_ngcontent-%COMP%] a[_ngcontent-%COMP%], table.accounting[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] td[_ngcontent-%COMP%] a[_ngcontent-%COMP%]:visited{color:#00f;text-decoration:none}table.accounting[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] td[_ngcontent-%COMP%] a[_ngcontent-%COMP%]:hover{text-decoration:underline}table.accounting[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] input.txtPrice[_ngcontent-%COMP%]{border:solid 1px #C8D3DF;padding:3px;text-align:right}table.accounting[_ngcontent-%COMP%] th.number[_ngcontent-%COMP%], table.accounting[_ngcontent-%COMP%] td.number[_ngcontent-%COMP%]{text-align:right}table.accounting[_ngcontent-%COMP%] th.red[_ngcontent-%COMP%], table.accounting[_ngcontent-%COMP%] td.red[_ngcontent-%COMP%]{color:red;text-align:right}table.accounting[_ngcontent-%COMP%] th.bordertop[_ngcontent-%COMP%], table.accounting[_ngcontent-%COMP%] td.bordertop[_ngcontent-%COMP%]{border-top:1px #999 solid}table.accounting[_ngcontent-%COMP%] tfoot[_ngcontent-%COMP%] td[_ngcontent-%COMP%], table.accounting[_ngcontent-%COMP%] tfoot[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{padding-bottom:20px}table.main[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr.main[_ngcontent-%COMP%]:nth-child(2n){background-color:#fff}table.main[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr.main[_ngcontent-%COMP%]:nth-child(4n-1){background-color:#f6f6f6}table.main[_ngcontent-%COMP%] table[_ngcontent-%COMP%] thead[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]{background-color:#fceca3!important;background-image:none!important}table.main[_ngcontent-%COMP%] table[_ngcontent-%COMP%] thead[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{border:1px solid #9e9e9e;color:#000;text-shadow:none}.cartItems[_ngcontent-%COMP%] .flow[_ngcontent-%COMP%]{width:100%;padding:0;margin:0}.cartItems[_ngcontent-%COMP%] .flow[_ngcontent-%COMP%] > li[_ngcontent-%COMP%]{width:calc(33% - 17px);float:left;list-style:none;padding:5px 7px;border:solid 1px #d8d8d8}.cartItems[_ngcontent-%COMP%] .flow[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{width:calc(33% - 17px);float:left;list-style:none;padding:5px 7px;border:solid 1px #d8d8d8;display:table-cell}.cartItems[_ngcontent-%COMP%] .flow[_ngcontent-%COMP%] td[_ngcontent-%COMP%] > p[_ngcontent-%COMP%]{color:#2b4e75;font-style:italic;margin:0;padding:0}.listReturn[_ngcontent-%COMP%] tr.item[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(2){width:10%!important}.listReturn[_ngcontent-%COMP%] tr.item[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(3){width:10%!important}.listReturn[_ngcontent-%COMP%] tr.item[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(5){width:10%!important}.listReturn[_ngcontent-%COMP%] tr.item[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(6){width:5%!important}.listReturn[_ngcontent-%COMP%] tr.item[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(7){width:10%!important}.listReturn[_ngcontent-%COMP%] a.head[_ngcontent-%COMP%]{padding:10px 0 10px 10px;display:block;width:50%}.listReturn[_ngcontent-%COMP%] td.numberCenter[_ngcontent-%COMP%]{text-align:right!important}.listReturn[_ngcontent-%COMP%] table.summary[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%]{padding-top:20px!important;display:block}table.paidAmount[_ngcontent-%COMP%]{float:right;margin-top:-10px;text-align:right;padding-right:7px}table.paidAmount[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{padding:0 0 1px}table.paidAmount[_ngcontent-%COMP%] td.currency[_ngcontent-%COMP%]{width:20px;text-align:left}table.paidAmount[_ngcontent-%COMP%] tr[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(2){padding:0 5px}div.zebra[_ngcontent-%COMP%]{display:table;border-collapse:collapse}div.zebra[_ngcontent-%COMP%] > div[_ngcontent-%COMP%]{display:table-cell}div.zebra[_ngcontent-%COMP%] > div[_ngcontent-%COMP%] > strong[_ngcontent-%COMP%]{display:block;border:1px solid #525252;background-color:#545454;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(0%,#888),color-stop(100%,#545454));background-image:-webkit-linear-gradient(#888,#545454);background-image:-moz-linear-gradient(#888,#545454);background-image:-o-linear-gradient(#888,#545454);background-image:linear-gradient(#888,#545454);-webkit-box-shadow:inset 0 2px 0 -1px rgba(255,255,255,.2);-moz-box-shadow:inset 0 2px 0 -1px rgba(255,255,255,.2);box-shadow:inset 0 2px 0 -1px #fff3;text-shadow:0 -1px 0 rgba(0,0,0,.4);height:28px;line-height:24px;border-bottom:1px solid #333;padding:2px 7px;color:#fff;font-weight:700}div.zebra[_ngcontent-%COMP%] > div[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{display:block;padding:5px 7px;border:solid 1px #d8d8d8;font-weight:700}div.zebra[_ngcontent-%COMP%] > div[_ngcontent-%COMP%] > span.number[_ngcontent-%COMP%]{text-align:right}']})},Ki=class n{static \u0275fac=function(t){return new(t||n)};static \u0275mod=ci({type:n});static \u0275inj=li({imports:[Se,Si]})};var Lt=class n{_state=R(this.getEcrConfig());isEnabled=se(()=>this._state()?.enabled);ecrUrl=se(()=>this._state()?.url);getEcrConfig(){let e=localStorage.getItem("ecrConfig"),t={enabled:!1,url:null,timestamp:""};return f.IsNotEmpty(e)&&(t=JSON.parse(e)),t}url=se(()=>{let e=this._state()?.url;if(e){let t=e.split("/");t.pop(),e=t.join("/")}return e});connect(e){let i={enabled:!0,url:e,timestamp:new Date().toDateString()};localStorage.setItem("ecrConfig",JSON.stringify(i)),this._state.set(i)}disconnect(){let t={enabled:!1,timestamp:new Date().toDateString(),url:null};localStorage.setItem("ecrConfig",JSON.stringify(t)),this._state.set(t)}static \u0275fac=function(t){return new(t||n)};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Bt=class n{ecrStorage=T(Lt);socketConnection;_ecrEvent=new Me;ecrEvent$=this._ecrEvent.asObservable();_isSignalRConnected=R(!1);isConnected=se(()=>this.ecrStorage.isEnabled()&&this._isSignalRConnected());toastr=T(L);initEcrOnStartup(){if(this.isConnected()){let t=this.ecrStorage.ecrUrl();this.initConnection(t)}}initConnection(e){this.socketConnection=new hi().withUrl(e).withAutomaticReconnect().configureLogging(fi.Information).build(),this.ecrStorage.connect(e),this.listenToConnectionEvents(),this.listenToEvents(),this.startConnection()}startConnection(){this.socketConnection.start().then(()=>{this._isSignalRConnected.set(!0),this.toastr.success("Successfully connected to ECR","Success")}).catch(e=>{this.toastr.error(e,"Failed connecting to ECR"),console.log(e)})}listenToEvents(){this.socketConnection.on("EcrEvent",e=>{this._ecrEvent.next(e)})}stopConnection(){this.socketConnection.stop().then(()=>{console.info("SignalR for ECR is Disconnected")})}listenToConnectionEvents(){this.socketConnection.onreconnecting(()=>{console.info("SignalR for ECR is Reconnecting")}),this.socketConnection.onreconnected(()=>{console.info("SignalR for ECR is Reconnected"),this._isSignalRConnected.set(!0)}),this.socketConnection.onclose(()=>{console.info("SignalR for ECR is Closed"),this._isSignalRConnected.set(!1)})}static \u0275fac=function(t){return new(t||n)};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Zi=class n{_state=R(this.getCashMachineConfig());isEnabled=se(()=>this._state()?.enabled);ecrUrl=se(()=>this._state()?.url);getCashMachineConfig(){let e=localStorage.getItem("CashkMachineConfig"),t={enabled:!1,url:null,timestamp:""};return f.IsNotEmpty(e)&&(t=JSON.parse(e)),t}url=se(()=>this._state()?.url);connect(e){let i={enabled:!0,url:e,timestamp:new Date().toDateString()};localStorage.setItem("CashkMachineConfig",JSON.stringify(i)),this._state.set(i)}disconnect(){let t={enabled:!1,timestamp:new Date().toDateString(),url:null};localStorage.setItem("CashkMachineConfig",JSON.stringify(t)),this._state.set(t)}static \u0275fac=function(t){return new(t||n)};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var Ht=class n{cashMachineConfig=T(Zi);socketConnection;_cashMachineEvent=new Me;_withdrawMoneyStatus=new Me;cashMachineEvent$=this._cashMachineEvent.asObservable();withdrawMoneyStatus$=this._withdrawMoneyStatus.asObservable();_isSignalRConnected=R(!1);isConnected=se(()=>this.cashMachineConfig.isEnabled()&&this._isSignalRConnected());toastr=T(L);initCashMachineOnStartup(){if(this.cashMachineConfig.isEnabled()){let t=this.cashMachineConfig.url();this.initConnection(t)}}initConnection(e){this.socketConnection=new hi().withUrl(e).withAutomaticReconnect().configureLogging(fi.Information).build(),this.listenToConnectionEvents(),this.listenToEvents(),this.startConnection(e)}startConnection(e){this.socketConnection.start().then(()=>{this._isSignalRConnected.set(!0),this.toastr.success("Successfully connected to Cash Machine","Success"),this.cashMachineConfig.connect(e)}).catch(t=>{this.toastr.error(t,"Failed connecting to Cash Machine"),console.log(t)})}sendWithdrawMoney(e){return this.socketConnection.send("WithdrawMoney",{Value:e}).catch(t=>console.error(t))}listenToEvents(){this.socketConnection.on("OnReceiveMoney",e=>{if(e){let t=JSON.parse(e);this._cashMachineEvent.next(t)}}),this.socketConnection.on("WithdrawMoneyStatus",e=>{e&&this._withdrawMoneyStatus.next(e?.status)})}stopConnection(){this.socketConnection.stop().then(()=>{console.info("SignalR for Cash Machine is Disconnected"),this.cashMachineConfig.disconnect()})}listenToConnectionEvents(){this.socketConnection.onreconnecting(()=>{console.info("SignalR for Cash Machine is Reconnecting")}),this.socketConnection.onreconnected(()=>{console.info("SignalR for Cash Machine is Reconnected"),this._isSignalRConnected.set(!0)}),this.socketConnection.onclose(()=>{console.info("SignalR for Cash Machine is Closed"),this._isSignalRConnected.set(!1)})}static \u0275fac=function(t){return new(t||n)};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var ca=(n,e,t,i)=>({"unselected-online-card":n,"selected-online-card":e,"selected-offline-card":t,"unselected-offline-card":i}),ma=(n,e)=>({"selected-color":n,"unselected-online-card-color":e}),da=(n,e)=>({"selected-color":n,"unselected-offline-card-color":e});function pa(n,e){if(n&1&&(a(0,"p",5),m(1," Order is "),a(2,"b"),m(3,"sync"),s(),m(4," to server realtime "),s()),n&2){let t=d();p("ngClass",Ue(1,ma,t.selected(),!t.selected()))}}function ua(n,e){if(n&1&&(a(0,"p",5),m(1," Order is "),a(2,"b"),m(3,"saved"),s(),m(4," to your browser storage "),s()),n&2){let t=d();p("ngClass",Ue(1,da,t.selected(),!t.selected()))}}var Xi=class n{statusType=Gt("ONLINE");selected=Gt(!1);clickCard=yt({alias:"onClick"});onClick(){this.clickCard.emit()}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=A({type:n,selectors:[["app-card-status"]],inputs:{statusType:[1,"statusType"],selected:[1,"selected"]},outputs:{clickCard:"onClick"},decls:8,vars:8,consts:[[1,"card","selected-online-card","mb-0","cursor-pointer",2,"width","150px",3,"click","ngClass"],[1,"card-body"],[1,"text-center"],[1,"fa","fa-wifi","fs-1"],[1,"fw-bold","pt-5"],[1,"mb-0","mt-4",3,"ngClass"]],template:function(t,i){t&1&&(a(0,"div",0),S("click",function(){return i.onClick()}),a(1,"div",1)(2,"div",2),b(3,"i",3),a(4,"h4",4),m(5),s(),h(6,pa,5,4,"p",5)(7,ua,5,4,"p",5),s()()()),t&2&&(p("ngClass",jn(3,ca,i.statusType()=="ONLINE"&&!i.selected(),i.statusType()=="ONLINE"&&i.selected(),i.statusType()=="OFFLINE"&&i.selected(),i.statusType()=="OFFLINE"&&!i.selected())),l(5),M(" ",i.statusType()," "),l(),C(i.statusType()=="ONLINE"?6:7))},dependencies:[Se,Be],styles:[".selected-color[_ngcontent-%COMP%], .selected-offline-card[_ngcontent-%COMP%], .selected-online-card[_ngcontent-%COMP%]{color:#fff}.unselected-online-card-color[_ngcontent-%COMP%], .unselected-online-card[_ngcontent-%COMP%]{color:#89b03e}.unselected-offline-card-color[_ngcontent-%COMP%], .unselected-offline-card[_ngcontent-%COMP%]{color:#c9302c}.selected-online-card[_ngcontent-%COMP%]{border:1px solid #89b03e;background-color:#89b03e}.unselected-online-card[_ngcontent-%COMP%]{border:1px solid #89b03e;background-color:#f7fdf7}.selected-offline-card[_ngcontent-%COMP%]{border:1px solid #c9302c;background-color:#c9302c}.unselected-offline-card[_ngcontent-%COMP%]{border:1px solid #c9302c;background-color:#fdf7f7}"]})};var en=class n{configOptions=[{label:"Online",value:!1},{label:"Offline",value:!0}];orderHandling=gi(!1);productHandling=gi(!1);startConfig=gi(!1);isOffline=se(()=>this.orderHandling()&&this.productHandling()&&this.startConfig());onClickCard(e){this.orderHandling.set(e),this.productHandling.set(e),this.startConfig.set(e)}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=A({type:n,selectors:[["app-setup"]],inputs:{orderHandling:[1,"orderHandling"],productHandling:[1,"productHandling"],startConfig:[1,"startConfig"]},outputs:{orderHandling:"orderHandlingChange",productHandling:"productHandlingChange",startConfig:"startConfigChange"},decls:27,vars:11,consts:[[1,"px-4"],[1,"fa","fa-wifi","text-success"],[1,"ms-3","fs-5"],[1,"d-flex","justify-content-center","align-items-center","gap-6","mt-6"],["statusType","ONLINE",3,"onClick","selected"],["statusType","OFFLINE",3,"onClick","selected"],[1,"mt-12"],[1,"d-flex","align-items-center"],[1,"fa-solid","fa-gear","text-success"],[1,"d-flex","align-items-center","justify-content-center","gap-10","mt-8"],[2,"width","150px"],[1,"mb-2"],["bindLabel","label","bindValue","value","appendTo","body",3,"ngModelChange","items","clearable","ngModel"],[1,"mx-5",2,"width","150px"]],template:function(t,i){t&1&&(a(0,"div",0)(1,"div")(2,"div"),b(3,"i",1),a(4,"span",2),m(5,"Connection Status"),s()(),a(6,"div",3)(7,"app-card-status",4),S("onClick",function(){return i.onClickCard(!1)}),s(),a(8,"app-card-status",5),S("onClick",function(){return i.onClickCard(!0)}),s()()(),a(9,"div",6)(10,"div",7),b(11,"i",8),a(12,"span",2),m(13,"System Configuration"),s()(),a(14,"div",9)(15,"div",10)(16,"label",11),m(17,"Orders handling"),s(),a(18,"ng-select",12),j("ngModelChange",function(r){return V(i.orderHandling,r)||(i.orderHandling=r),r}),s()(),a(19,"div",13)(20,"label",11),m(21,"Products management"),s(),a(22,"ng-select",12),j("ngModelChange",function(r){return V(i.productHandling,r)||(i.productHandling=r),r}),s()(),a(23,"div",10)(24,"label",11),m(25,"Start Config"),s(),a(26,"ng-select",12),j("ngModelChange",function(r){return V(i.startConfig,r)||(i.startConfig=r),r}),s()()()()()),t&2&&(l(7),p("selected",!i.isOffline()),l(),p("selected",i.isOffline()),l(10),p("items",i.configOptions)("clearable",!1),H("ngModel",i.orderHandling),l(4),p("items",i.configOptions)("clearable",!1),H("ngModel",i.productHandling),l(4),p("items",i.configOptions)("clearable",!1),H("ngModel",i.startConfig))},dependencies:[Xi,uo,St,vi,Pe,Ee],encapsulation:2})};var tn=class n{localDataService=T(Oe);httpService=T(ge);totalSyncProduct={totalOfflineProduct:0,totalOnlineProduct:0};getTotalProducts(e=!1){return this.totalSyncProduct.totalOfflineProduct==0||e?this.localDataService.findAllVariant().pipe(ce(t=>t.length>0),Y(t=>{let i=this.calculateOfflineProducts(t);return this.httpService.POSText("/api/POSSync/ProductCount",'{"ProductDiscontinued":0,"VariantDiscontinued":0,"CategoryDiscontinued":0,"From":"0001-01-01T00:00:00","To":"0001-01-01T00:00:00"}').pipe(J(o=>{let r=o?JSON.parse(o)?.Count:0;return{totalOfflineProduct:i.length,totalOnlineProduct:r}}),le(o=>{this.totalSyncProduct=o}))})):ke(this.totalSyncProduct)}calculateOfflineProducts(e){let t=new Set,i=[];for(let o of e)t.has(o.ProductID)==!1&&(t.add(o.ProductID),i.push(o));return i}getSyncTime(){return this.localDataService.getSyncTime().pipe(J(e=>{let t={date:null,daysDiff:0};if(e){let i=new Date(e.time),o=this.calculateSyncDiff(i);t={date:new Date(e.time),daysDiff:o}}return t}))}calculateSyncDiff(e){let t=0;return e&&(t=Math.floor((new Date().getTime()-e?.getTime())/1e3/60/60/24)),t}syncToLocalDatabase(){return $e([this.syncOutlets(),this.syncProducts(),this.syncOutletPrices()]).pipe(Y(()=>this.localDataService.updateSyncTime()))}syncOutlets(){return this.httpService.get(U.SynOutlet).pipe(Y(e=>this.localDataService.syncRegisters(e)))}syncProducts(){return this.httpService.get(U.SyncProducts).pipe(Y(e=>this.localDataService.syncVariants(e)))}syncOutletPrices(){return this.httpService.get(U.SynOutletPrice).pipe(Y(e=>this.localDataService.syncOutletPrice(e)))}static \u0275fac=function(t){return new(t||n)};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};function ga(n,e){n&1&&(m(0),y(1,"number")),n&2&&M(" ",x(1,1,e.totalOnlineProduct)," ")}function fa(n,e){n&1&&m(0," 0 ")}function ha(n,e){n&1&&(m(0),y(1,"number")),n&2&&M(" ",x(1,1,e.totalOfflineProduct)," ")}function Ca(n,e){n&1&&m(0," 0 ")}function va(n,e){if(n&1&&(m(0),y(1,"number")),n&2){let t=d();M(" Last Sync: ",x(1,1,t.daysDiff)," days ago! ")}}function _a(n,e){if(n&1&&(m(0),y(1,"date")),n&2){let t=d(2);M(" Last Sync: ",X(1,1,t.date,"dd MMM yyyy HH:mm")," ")}}function ya(n,e){n&1&&m(0," Never been sync ")}function ba(n,e){if(n&1&&h(0,_a,2,4)(1,ya,1,0),n&2){let t=d();C(t.date?0:1)}}function Sa(n,e){n&1&&h(0,va,2,3)(1,ba,2,1),n&2&&C(e.daysDiff>14?0:1)}var nn=class n{productSyncService=T(tn);onlineStatusService=T(he);isOnline$=this.onlineStatusService.getOnlineStatus$();toastr=T(L);productCount$=this.productSyncService.getTotalProducts().pipe(Le(1));syncTime$=this.productSyncService.getSyncTime().pipe(Le(1));onSyncProduct(){this.productSyncService.syncToLocalDatabase().subscribe({next:()=>{this.productCount$=this.productSyncService.getTotalProducts(!0).pipe(Le(1)),this.syncTime$=this.productSyncService.getSyncTime().pipe(Le(1)),this.toastr.success("Sync Product Offline Successfully","Success!")},error:e=>{this.toastr.error("Error syncing products. Please try again.","Error"),console.error("Error syncing products:",e)}})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=A({type:n,selectors:[["app-product-sync"]],decls:41,vars:12,consts:[[1,"fa-solid","fa-sync-alt","text-success","fs-5"],[1,"ms-3","fs-5"],[1,"d-flex","align-items-center","mt-2","justify-content-between","bg-secondary-subtle","px-8","py-6","rounded-3"],[1,"d-flex","align-items-top"],[1,"fs-5"],[1,"fw-normal","mt-1"],[1,"ms-8"],[1,"btn","btn-success","btn-sm",3,"click","disabled"],[1,"fa-solid","fa-sync-alt","me-2","pe-2"],[1,"mt-8"],[1,"fa-solid","fa-circle-info","text-success","fs-5"],[1,"border","rounded-3","mt-2"],[1,"text-center","my-8"],["src","https://cdn.dealpos.xyz/web-image/globalnodata.svg",2,"width","100px"],[1,"fw-normal","mt-6","opacity-25"]],template:function(t,i){if(t&1&&(N(0,"div")(1,"div"),Xe(2,"i",0),N(3,"span",1),m(4,"Product Sync"),k()(),N(5,"div",2)(6,"div",3)(7,"div")(8,"span",4),m(9,"Online Products"),k(),N(10,"h3",5),h(11,ga,2,3),y(12,"async"),Sn(13,fa,1,0),k()(),N(14,"div",6)(15,"span",4),m(16,"Offline Products"),k(),N(17,"h3",5),h(18,ha,2,3),y(19,"async"),Sn(20,Ca,1,0),k(),N(21,"small"),h(22,Sa,2,1),y(23,"async"),k()()(),N(24,"div")(25,"button",7),y(26,"async"),Ln("click",function(){return i.onSyncProduct()}),Xe(27,"i",8),N(28,"span"),m(29,"Sync Now"),k()()()()(),N(30,"div",9)(31,"div"),Xe(32,"i",10),N(33,"span",1),m(34,"Product Details"),k()(),N(35,"div",11)(36,"div",12)(37,"div"),Xe(38,"img",13),k(),N(39,"h4",14),m(40,"Coming Soon"),k()()()()),t&2){let o,r,c;l(11),C((o=x(12,4,i.productCount$))?11:13,o),l(7),C((r=x(19,6,i.productCount$))?18:20,r),l(4),C((c=x(23,8,i.syncTime$))?22:-1,c),l(3),Fn("disabled",!x(26,10,i.isOnline$))}},dependencies:[Se,ze,q,Ye],encapsulation:2})};var Ma=n=>({data:n,type:"unsent"}),xa=n=>({data:n,type:"success"}),Ia=n=>({data:n,type:"fail"}),Ta=(n,e)=>({"table-height":n,"table-height-default":e}),Ea=n=>({ID:n});function wa(n,e){n&1&&di(0)}function Ra(n,e){if(n&1){let t=E();a(0,"div",4)(1,"button",7),y(2,"async"),S("click",function(){v(t);let o=d();return _(o.uploadUnsentOrders())}),b(3,"i",8),a(4,"span"),m(5,"Upload"),s()()()}if(n&2){let t=d();l(),p("disabled",x(2,1,t.isOnline$)==!1)}}function Na(n,e){n&1&&di(0)}function Aa(n,e){if(n&1){let t=E();a(0,"div",4)(1,"button",9),S("click",function(){v(t);let o=d();return _(o.clearSuccessUploadedOrders())}),b(2,"i",10),a(3,"span"),m(4,"Clear"),s()()()}}function ka(n,e){n&1&&di(0)}function Va(n,e){if(n&1){let t=E();a(0,"div",4)(1,"button",11),S("click",function(){v(t);let o=d();return _(o.clearFailedOrders())}),b(2,"i",10),a(3,"span"),m(4,"Clear"),s()()()}}function Fa(n,e){n&1&&b(0,"th")}function La(n,e){if(n&1&&(a(0,"a",18),m(1),s()),n&2){let t=d().$implicit;p("queryParams",Q(2,Ea,t.Invoice==null?null:t.Invoice.ID)),l(),M(" ",t.Order.Number," ")}}function Ba(n,e){if(n&1&&m(0),n&2){let t=d().$implicit;M(" ",t.Order.Number," ")}}function Ha(n,e){if(n&1&&(a(0,"span",21),m(1),y(2,"limitText"),s()),n&2){let t=d().$implicit;p("matTooltip",(t==null||t.Variant==null?null:t.Variant.Name.length)>=30?t==null||t.Variant==null?null:t.Variant.Name:""),l(),O(X(2,2,t==null||t.Variant==null?null:t.Variant.Name,30))}}function ja(n,e){if(n&1&&(a(0,"div",19),h(1,Ha,3,5,"span",21),s()),n&2){let t=e.$implicit;l(),C(t?1:-1)}}function Qa(n,e){if(n&1&&(a(0,"span"),m(1),y(2,"number"),s(),a(3,"span",22),m(4,"x"),s(),a(5,"span"),m(6),y(7,"number"),s()),n&2){let t=d().$implicit;l(),O(x(2,2,t==null?null:t.Quantity)),l(5),O(x(7,4,t==null?null:t.Price))}}function Ua(n,e){if(n&1&&(a(0,"div",20),h(1,Qa,8,6),s()),n&2){let t=e.$implicit;l(),C(t?1:-1)}}function Wa(n,e){if(n&1&&(a(0,"span"),m(1),y(2,"number"),s()),n&2){let t=d().$implicit;l(),O(x(2,1,(t==null?null:t.Price)*(t==null?null:t.Quantity)))}}function Ga(n,e){if(n&1&&(a(0,"div",20),h(1,Wa,3,3,"span"),s()),n&2){let t=e.$implicit;l(),C(t?1:-1)}}function qa(n,e){if(n&1){let t=E();a(0,"a",26),S("click",function(){v(t);let o=d(2).$implicit,r=d(3);return _(r.uploadFailedOrder(o))}),b(1,"i",27),s()}}function $a(n,e){if(n&1){let t=E();a(0,"a",28),S("click",function(){v(t);let o=d(2).$implicit,r=d(2).type,c=d();return _(r=="fail"?c.removeFailedOrder(o):c.removeUnsentOrder(o))}),b(1,"i",29),s()}}function Ja(n,e){if(n&1&&(a(0,"td")(1,"div",23),h(2,qa,2,0,"a",24),y(3,"async"),h(4,$a,2,0,"a",25),s()()),n&2){let t=d(3).type,i=d();l(2),C(t=="fail"&&x(3,2,i.isOnline$)?2:-1),l(2),C(i.role.sell.Delete&&t!="success"?4:-1)}}function za(n,e){if(n&1&&(a(0,"tr")(1,"td"),h(2,La,2,4,"a",18)(3,Ba,1,1),s(),a(4,"td")(5,"div"),m(6),y(7,"date"),s(),a(8,"div"),m(9),y(10,"date"),s()(),a(11,"td"),K(12,ja,2,1,"div",19,ot),s(),a(14,"td"),K(15,Ua,2,1,"div",20,ot),s(),a(17,"td"),K(18,Ga,2,1,"div",20,ot),s(),h(20,Ja,5,4,"td"),s()),n&2){let t=e.$implicit,i=d(2).data,o=d();l(2),C(o.activeFilter()==1?2:3),l(4),M(" ",X(7,4,t==null||t.Order==null?null:t.Order.ClientTimestamp,"dd MMM yyyy")," "),l(3),M(" ",X(10,7,t==null||t.Order==null?null:t.Order.ClientTimestamp,"HH:mm")," "),l(3),Z(t.CartItems),l(3),Z(t.CartItems),l(3),Z(t.CartItems),l(2),C((i==null?null:i.length)>0?20:-1)}}function Ya(n,e){if(n&1&&K(0,za,21,10,"tr",null,ve),n&2){let t=d().data;Z(t)}}function Ka(n,e){n&1&&(a(0,"tr",17)(1,"td",30),b(2,"empty-state-table"),s()())}function Za(n,e){if(n&1&&(a(0,"div",12)(1,"table",13)(2,"thead",14)(3,"tr")(4,"th"),m(5,"Number"),s(),a(6,"th"),m(7,"Date"),s(),a(8,"th",15),m(9,"Product"),s(),a(10,"th",16),m(11,"Price"),s(),a(12,"th",16),m(13,"Total"),s(),h(14,Fa,1,0,"th"),s()(),a(15,"tbody"),h(16,Ya,2,0)(17,Ka,3,0,"tr",17),s()()()),n&2){let t=e.data;pi(Ue(4,Ta,(t==null?null:t.length)>0,(t==null?null:t.length)===0)),l(14),C((t==null?null:t.length)>0?14:-1),l(2),C((t==null?null:t.length)>0?16:17)}}var on=class n{localDataService=T(Oe);onlineService=T(he);role=T(_i);toastr=T(L);isOnline$=this.onlineService.getOnlineStatus$();unsentOrders$;failedOrders$;successUploadedOrders$;activeFilter=R(0);onEmptyOfflineOrder=yt();filters=[{label:"Unsent",value:0},{label:"Success",value:1},{label:"Fail",value:2}];constructor(){this.initFailedOrders(),this.initUnsentOrders(),this.initSuccessUploadedOrders()}initFailedOrders(){this.failedOrders$=this.localDataService.failedOrders$.pipe(this.pipeMap(),Le(1))}initSuccessUploadedOrders(){this.successUploadedOrders$=this.localDataService.successUploadedOrders$.pipe(this.pipeMap(),Le(1))}initUnsentOrders(){this.unsentOrders$=$e([this.localDataService.unsentOrders$,this.onlineService.getOnlineStatus$()]).pipe(J(([e,t])=>e),this.pipeMap(),Le(1))}pipeMap(){return oi(J(e=>e.map(t=>de(G,t))))}uploadUnsentOrders(){this.localDataService.uploadOrders().pipe(Y(()=>this.localDataService.totalOfflineOrders$),le(e=>{e===0&&this.onEmptyOfflineOrder.emit()}),Qe(1)).subscribe()}removeUnsentOrder(e){confirm("Are you sure you want to delete this offline order? This action cannot be undone.")&&this.localDataService.removeOrder(e.id).pipe(Y(()=>this.localDataService.totalOfflineOrders$),le(i=>{i===0&&this.onEmptyOfflineOrder.emit()}),Qe(1)).subscribe({next:()=>{this.toastr.success("Success to remove unsent offline order","Success")},error:i=>{this.toastr.error("Failed to remove unsent offline order","Error!")}})}uploadFailedOrder(e){this.localDataService.uploadFailedOrder(e).pipe(Qe(1)).subscribe()}removeFailedOrder(e){confirm("Are you sure you want to delete this offline order? This action cannot be undone.")&&this.localDataService.removeFailedOrder(e.id).pipe(Qe(1)).subscribe({next:()=>{this.toastr.success("Success to remove failed offline order","Success")},error:i=>{this.toastr.error("Failed to remove failed offline order","Error!")}})}clearFailedOrders(){confirm("Are you sure you want to clear all failed offline order? This action cannot be undone.")&&this.localDataService.clearFailedOrders().pipe(Qe(1)).subscribe({next:()=>{this.toastr.success("Success to clear failed offline order","Success")},error:t=>{this.toastr.error("Failed to clear failed offline order","Error!")}})}clearSuccessUploadedOrders(){this.localDataService.clearSuccessUploadedOrder().pipe(Qe(1)).subscribe({next:()=>{this.toastr.success("Success to clear success uploaded offline order","Success")},error:e=>{this.toastr.error("Failed to clear success uploaded offline order","Error!")}})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=A({type:n,selectors:[["app-order-management"]],outputs:{onEmptyOfflineOrder:"onEmptyOfflineOrder"},decls:19,vars:27,consts:[["ORDERS_TABLE",""],[1,"container-fluid"],["tabTitle","Unsent","icon","fa-solid fa-file-invoice"],[4,"ngTemplateOutlet","ngTemplateOutletContext"],[1,"d-flex","justify-content-center","mb-3"],["tabTitle","Success","icon","fa-solid fa-cloud-check","iconColor","#4caf50"],["tabTitle","Failed","icon","fa-regular fa-circle-xmark","iconColor","#f44336"],["matTooltip","Upload all unsent orders to server",1,"btn","btn-success","btn-sm","position-absolute",2,"bottom","10px",3,"click","disabled"],["aria-hidden","true",1,"fa-solid","fa-upload","me-2"],["matTooltip","Clear success uploaded orders",1,"btn","btn-danger","btn-sm","position-absolute",2,"bottom","10px",3,"click"],["aria-hidden","true",1,"fa-solid","fa-trash","me-2"],["matTooltip","Clear failed uploaded orders",1,"btn","btn-danger","btn-sm","position-absolute",2,"bottom","10px",3,"click"],[1,"table-responsive","mb-4","mx-0"],[1,"table"],[1,"thead-light"],[1,"text-start"],[1,"text-end"],[1,"border-bottom-0"],["routerLink","/menu/Orders/Orders/Customer_Invoice/Info","target","_blank",3,"queryParams"],[1,"list-unstyled","text-start"],[1,"list-unstyled","text-end"],[3,"matTooltip"],[1,"mx-3"],[1,"d-flex","justify-content-center"],["matTooltipPosition","above","matTooltip","Sync failed order to server",1,"ms-2","me-2","cursor-pointer"],["matTooltipPosition","above","matTooltip","Remove order from local browser",1,"ms-5","cursor-pointer"],["matTooltipPosition","above","matTooltip","Sync failed order to server",1,"ms-2","me-2","cursor-pointer",3,"click"],["aria-hidden","true",1,"fa-solid","fa-cloud-arrow-up","text-primary","fa-2x"],["matTooltipPosition","above","matTooltip","Remove order from local browser",1,"ms-5","cursor-pointer",3,"click"],["aria-hidden","true",1,"fa-regular","fa-xmark-circle","text-danger","fa-2x"],["colspan","5",1,"border-bottom-0"]],template:function(t,i){if(t&1&&(a(0,"div",1)(1,"custom-tabs")(2,"tab",2),$(3,wa,1,0,"ng-container",3),y(4,"async"),h(5,Ra,6,3,"div",4),y(6,"async"),s(),a(7,"tab",5),$(8,Na,1,0,"ng-container",3),y(9,"async"),h(10,Aa,5,0,"div",4),y(11,"async"),s(),a(12,"tab",6),$(13,ka,1,0,"ng-container",3),y(14,"async"),h(15,Va,5,0,"div",4),y(16,"async"),s()()(),$(17,Za,18,7,"ng-template",null,0,Qn)),t&2){let o,r,c,u=ue(18);l(3),p("ngTemplateOutlet",u)("ngTemplateOutletContext",Q(21,Ma,x(4,9,i.unsentOrders$))),l(2),C(((o=x(6,11,i.unsentOrders$))==null?null:o.length)>0?5:-1),l(3),p("ngTemplateOutlet",u)("ngTemplateOutletContext",Q(23,xa,x(9,13,i.successUploadedOrders$))),l(2),C(((r=x(11,15,i.successUploadedOrders$))==null?null:r.length)>0&&(i.role.sell!=null&&i.role.sell.Delete)?10:-1),l(3),p("ngTemplateOutlet",u)("ngTemplateOutletContext",Q(25,Ia,x(14,17,i.failedOrders$))),l(2),C(((c=x(16,19,i.failedOrders$))==null?null:c.length)>0&&(i.role.sell!=null&&i.role.sell.Delete)?15:-1)}},dependencies:[Se,qn,Mi,Ii,xi,bo,Ho,qt,yi,Kn,Yn,ze,q,Ye,lo],styles:[".table-overflow[_ngcontent-%COMP%], .table-height-default[_ngcontent-%COMP%], .table-height[_ngcontent-%COMP%]{overflow-x:hidden;overflow-y:auto}.table-height[_ngcontent-%COMP%]{max-height:33vh}.table-height-default[_ngcontent-%COMP%]{max-height:37.3vh}@media screen and (min-width: 1280px) and (max-width: 1440px){.table-height[_ngcontent-%COMP%]{max-height:41vh}.table-height-default[_ngcontent-%COMP%]{max-height:50vh}}"]})};function Xa(n,e){if(n&1){let t=E();a(0,"app-setup",8),j("orderHandlingChange",function(o){v(t);let r=d();return V(r.orderUsingLocal,o)||(r.orderUsingLocal=o),_(o)})("productHandlingChange",function(o){v(t);let r=d();return V(r.productUsingLocal,o)||(r.productUsingLocal=o),_(o)})("startConfigChange",function(o){v(t);let r=d();return V(r.configUsingLocal,o)||(r.configUsingLocal=o),_(o)}),s()}if(n&2){let t=d();H("orderHandling",t.orderUsingLocal)("productHandling",t.productUsingLocal)("startConfig",t.configUsingLocal)}}var rn=class n{constructor(e){this.data=e;this.initActiveTab()}modalConfig;dialog=T(te);onlineStatusService=T(he);localDataService=T(Oe);orderUsingLocal=R(!1);productUsingLocal=R(!1);configUsingLocal=R(!1);offlineConfig$=this.onlineStatusService.offlineConfig$.pipe(le(e=>{this.orderUsingLocal.set(e.orderUsingLocal),this.productUsingLocal.set(e.productUsingLocal),this.configUsingLocal.set(e.configUsingLocal)}),Le(1));activeTab=R("SETUP");totalOfflineOrders$=this.localDataService.totalOfflineOrders$.pipe(Le(1));initActiveTab(){this.activeTab.update(e=>(this.data?.activeTab&&(e=this.data.activeTab),e)),this.initModalConfig()}initModalConfig(){this.modalConfig=new ie,this.modalConfig.title="Offline Order Configuration",this.modalConfig.customWidth="600px",this.modalConfig.hideScrollbar=!0,$e([this.localDataService.unsentOrders$.pipe(J(e=>e?.length)),this.onlineStatusService.getOnlineStatus$()]).pipe(ee()).subscribe(([e,t])=>{this.data?.activeTab=="ORDER"&&e>0&&t?(this.modalConfig.hideClose=!0,this.modalConfig.hideFooter=!0):(this.modalConfig.hideClose=!1,this.modalConfig.hideFooter=!1)})}onEmptyOfflineOrder(){this.modalConfig.hideFooter=!1,this.modalConfig.hideClose=!1}onSave(){let e=new _o(this.configUsingLocal(),this.productUsingLocal(),this.orderUsingLocal());this.onlineStatusService.updateOfflineConfigDB(e),this.dialog.close()}onClose(){this.dialog.close()}static \u0275fac=function(t){return new(t||n)(P(fe))};static \u0275cmp=A({type:n,selectors:[["app-modal-offline"]],decls:12,vars:10,consts:[[3,"onCancel","onClose","onOk","config"],[1,"dialog-offline-content"],[1,"dialog-offline-tabs"],["tabTitle","Mode","icon","fa-solid fa-cog",3,"active"],[3,"orderHandling","productHandling","startConfig"],["tabTitle","Orders","icon","fa-solid fa-cart-shopping",3,"active","badge"],[3,"onEmptyOfflineOrder"],["tabTitle","Products","icon","fa-solid fa-box",3,"active"],[3,"orderHandlingChange","productHandlingChange","startConfigChange","orderHandling","productHandling","startConfig"]],template:function(t,i){if(t&1&&(a(0,"modal-material",0),S("onCancel",function(){return i.onClose()})("onClose",function(){return i.onClose()})("onOk",function(){return i.onSave()}),a(1,"content")(2,"div",1)(3,"custom-tabs",2)(4,"tab",3),h(5,Xa,1,3,"app-setup",4),y(6,"async"),s(),a(7,"tab",5),y(8,"async"),a(9,"app-order-management",6),S("onEmptyOfflineOrder",function(){return i.onEmptyOfflineOrder()}),s()(),a(10,"tab",7),b(11,"app-product-sync"),s()()()()()),t&2){let o;p("config",i.modalConfig),l(4),p("active",i.activeTab()=="SETUP"),l(),C((o=x(6,6,i.offlineConfig$))?5:-1,o),l(2),p("active",i.activeTab()=="ORDER")("badge",x(8,8,i.totalOfflineOrders$)),l(3),p("active",i.activeTab()=="PRODUCT")}},dependencies:[Se,Pt,ne,en,Mi,Ii,xi,nn,on,ze],styles:[".dialog-offline-content[_ngcontent-%COMP%]{min-height:360px}"]})};var an=class{RegisterID;InvoiceNumber;Amount};var sn=class{modalConfig=new ie;viewState=4;paymentSuggestion;payLaterEnabled=!1;payNowEnabled=!1;payNowNLaterEnabled=!1;toleranceAmount=0;merchantName;payLaterDueDate;payLaterDueDays;numpadVisible=!1;config;uniquePaymentMethodOnSplit;isCancelEcrTransaction=!1;emoneyType=Di;splitPaymentEnabled=!0;isCashMachineProvideChange=R(!0);constructor(){this.modalConfig.title="Amount to Pay: ",this.modalConfig.disableKeyup=!0,this.modalConfig.customWidth="650px",this.modalConfig.bodyScrollable=!0}mapAppConfigJson(e){this.merchantName=e.PaymentConfigGopay.MerchantName,this.toleranceAmount=e.ModuleSell.ToleranceAmount,this.numpadVisible=e.ModuleSell.NumPadVisible;let t=e.ModuleSell.PaymentDialog;switch(this.config=t,this.uniquePaymentMethodOnSplit=t.UniquePaymentMethodOnSplit,t.EnabledOptions){case 0:this.viewState=0,this.payNowEnabled=!0;break;case 1:this.viewState=1,this.payLaterEnabled=!0;break;case 2:switch(t.DefaultOption){case 0:this.viewState=0;break;case 1:this.viewState=1;break}this.payNowNLaterEnabled=!0;break}}enableEMoneyModal(e){this.modalConfig.backButton=e,this.modalConfig.hideCancel=e,this.modalConfig.hideClose=e,this.modalConfig.hideOk=e}enableEmoneyConfirmModal(e){this.modalConfig.backButton=e,this.modalConfig.hideCancel=e,this.modalConfig.hideClose=e,this.modalConfig.hideOk=e,e?(this.modalConfig.headerType=me.Warning,this.modalConfig.title="Warning! This is QRIS for Testing"):(this.modalConfig.headerType=me.Success,this.modalConfig.title="Amount to Pay: ")}enableModalWaitingEcr(e){this.modalConfig.hideCancel=e,this.modalConfig.hideClose=e,this.modalConfig.hideOk=e,this.isCancelEcrTransaction=!1,e?this.modalConfig.customWidth="550px":(this.modalConfig.customWidth="650px",this.modalConfig.headerType=me.Success,this.modalConfig.title="Amount to Pay: ")}enableModalCashMachine(e){this.modalConfig.hideCancel=e,this.modalConfig.hideOk=e,e?this.modalConfig.customWidth="450px":this.modalConfig.customWidth="650px"}cancelEcrTransaction(){this.modalConfig.title="Waiting Cancel from EDC Machine",this.modalConfig.headerType=me.Warning,this.isCancelEcrTransaction=!0}get isStateNow(){return this.viewState==0}get isStateLater(){return this.viewState==1}get isStateSplit(){return this.viewState==3}get isStateQR(){return this.viewState==2}get isQrisConfirm(){return this.viewState==4}get isWaitingPaymentEcr(){return this.viewState==5}get isCashMachine(){return this.viewState==6}};var ln=class n{constructor(e,t,i,o,r,c,u,D){this._invoiceCalculatorService=e;this._posService=t;this._orderDataService=i;this._orderProcessorService=o;this._onlineStatusService=r;this._signalBroadCast=c;this.decimalPipe=u;this._registerService=D;this.subscribeToObservableChanges(),this.defaultCashPaymentMethodID=this.paymentList[0].ID}defaultCashPaymentMethodID=0;isOnline=!0;salesOrderData=new G;_State;get State(){return this._State}set State(e){this._State=e}get denomination(){return this._posService.Data.Denomination}get appConfigJSON(){return this._posService.Data.AppConfigJSON}get toleranceAmount(){return this.appConfigJSON.ModuleSell.ToleranceAmount}get paymentList(){return f.IsNotEmpty(this._registerService.Data)?this._registerService.Data.Payments:Array()}subscribeToObservableChanges(){this._onlineStatusService.getOnlineStatus$().subscribe(e=>{this.isOnline=e}),this._orderDataService.Data$.subscribe(e=>{this.salesOrderData=e})}getPaymentList(){return this.paymentList}submitOrder(e){this.salesOrderData.Payments=de(Ke,e),this.salesOrderData.Payments=this.removePayment(this.salesOrderData),this._orderDataService.pushNewValue(this.salesOrderData),this._orderDataService.submitOrder(this.appConfigJSON).then(t=>{this.updateBroadcastState(t),t=this.setFinalAmountOfflineOrder(t),this._orderProcessorService.updatePosState(1,t)},t=>{(t instanceof ai||t?.name=="TimeoutError")&&(this._orderDataService.pushNewValue(this.salesOrderData),this._orderProcessorService.updatePosState(9))})}updateBroadcastState(e){let t=this.salesOrderData.TotalPaidAmount-this._invoiceCalculatorService.Data;this._signalBroadCast.BroadcastStateToCustomerDisplay(1,e.ObjectID,e.LoyaltyPoint,t).subscribe()}removePayment(e){return e.Payments.filter(i=>i.Amount!==0)}setFinalAmountOfflineOrder(e){return this.isOnline==!1&&(e.Final=this._invoiceCalculatorService.Data),e}generateCashSuggestion(){let e=this.paymentList.filter(i=>i.TypeID==1),t=[];return e.length>0&&(t.push(this._invoiceCalculatorService.Data),this.defaultCashPaymentMethodID=e[0].ID,this.denomination.forEach(i=>{let o=this._invoiceCalculatorService.Data/i;o=Math.ceil(o);let r=o*i;r!=this._invoiceCalculatorService.Data&&t.indexOf(r)===-1&&t.length<3&&t.push(r)})),t}static \u0275fac=function(t){return new(t||n)(g(ae),g(z),g(B),g(je),g(he),g(lt),g(q),g(re))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};var cn=class n{constructor(e,t,i,o,r){this.httpService=e;this.orderDataService=t;this.ecrLocalstorageService=i;this.ecrSignalR=o;this.toastr=r}onPay(e){let t=this.orderDataService.Data?.Order?.Number,i={Transaction_Type:"01",Transaction_Amount:e,Invoice_Number:t,Expire_Date:2406},o=this.ecrLocalstorageService.url();return $e([this.httpService.post(`${o}/api/Payment/Send`,i),this.ecrSignalR.ecrEvent$]).pipe(J(([r,c])=>c),nt(r=>{let c=r?.message?r?.message:r?.Message;return this.toastr.error(c,"Error"),ft(()=>r)}))}static \u0275fac=function(t){return new(t||n)(g($n),g(B),g(Lt),g(Bt),g(L))};static \u0275prov=I({token:n,factory:n.\u0275fac,providedIn:"root"})};function ns(n,e){if(n&1&&(N(0,"div",0)(1,"div",2)(2,"h3",3),m(3," Insert Cash into Machine "),k(),N(4,"p",4),m(5," Feed bills into the cash acceptor slot below the screen "),k(),N(6,"div",5)(7,"span",6)(8,"span",7),m(9,"\u23F3"),k(),m(10," Waiting for cash insertion "),k()(),N(11,"div",8)(12,"div",9)(13,"span",10),m(14,"Amount Received:"),k(),N(15,"span",11)(16,"span"),m(17),k(),N(18,"span"),m(19),y(20,"number"),k()()(),N(21,"div",12)(22,"span",10),m(23,"Remaining Balance:"),k(),N(24,"span",13)(25,"span"),m(26),k(),N(27,"span"),m(28),y(29,"number"),k()()()()(),N(30,"div",14)(31,"div",15)(32,"span",16),m(33,"Payment Progress"),k(),N(34,"span",17)(35,"span"),m(36),k(),N(37,"span"),m(38),y(39,"number"),k(),m(40," / "),N(41,"span"),m(42),k(),N(43,"span"),m(44),y(45,"number"),k()()(),N(46,"div",18),Xe(47,"div",19),k()()()),n&2){let t=d();l(17),O(t.currencySymbol()),l(2),O(x(20,11,t.receivedAmount())),l(7),O(t.currencySymbol()),l(2),O(x(29,13,t.remainingBalance())),l(8),O(t.currencySymbol()),l(2),O(x(39,15,t.receivedAmount())),l(4),O(t.currencySymbol()),l(2),O(x(45,17,t.totalAmount())),l(2),mi("aria-valuenow",t.progress()),l(),Bn("width",t.progress(),"%")}}function os(n,e){if(n&1&&(N(0,"div",23),m(1," Change: "),N(2,"span"),m(3),k(),N(4,"span"),m(5),y(6,"number"),k()()),n&2){let t=d(2);l(3),O(t.currencySymbol()),l(2),O(x(6,2,t.changeDue()))}}function rs(n,e){n&1&&(N(0,"div",24),Xe(1,"i",25),N(2,"div",26),m(3,"Manual Change Required"),k(),N(4,"p",27)(5,"span",28),m(6,"Machine cannot dispense exact change."),k(),N(7,"span"),m(8,"Please collect change from the cashier."),k()()())}function as(n,e){n&1&&(N(0,"div",24),Xe(1,"i",25),N(2,"div",26),m(3,"Change Dispensed"),k(),N(4,"p",27)(5,"span",28),m(6,"The machine has provided your change."),k(),N(7,"span"),m(8,"Please ensure you have collected your change from the dispenser before closing this window."),k()()())}function ss(n,e){if(n&1&&h(0,as,9,0,"div",24),n&2){let t=d(2);C(t.changeDue()>0?0:-1)}}function ls(n,e){if(n&1&&(N(0,"div",1)(1,"div",20)(2,"span",21),m(3,"\u2713"),k()(),N(4,"div",22),m(5," Payment Accepted! "),k(),h(6,os,7,4,"div",23),h(7,rs,9,0,"div",24)(8,ss,1,1),k()),n&2){let t=d();l(6),C(t.changeDue()>0?6:-1),l(),C(t.canProvideChange()==!1?7:t.canProvideChange()==!0?8:-1)}}var mn=class n{cashMachineService=T(Ht);calculatorService=T(ae);currencySymbol=R(this.calculatorService.currencySymbol);totalAmount=Gt(0);transactionComplete=yt({alias:"onTransactionComplete"});receivedAmount=R(0);paymentState=R("paying");changeDue=R(0);canProvideChange=R(!0);isProcessing=R(!1);remainingBalance=se(()=>Math.max(0,this.totalAmount()-this.receivedAmount()));progress=se(()=>{let e=this.totalAmount();return e===0?0:Math.min(100,this.receivedAmount()/e*100)});constructor(){this.initListenCashMachine(),this.initWithdrawStatus()}initListenCashMachine(){this.cashMachineService.cashMachineEvent$.pipe(ee()).subscribe(e=>{if(!e||e.length===0)return;let t=e.map(i=>i.value).reduce((i,o)=>i+o,0);this.insertCash(t)})}initWithdrawStatus(){this.cashMachineService.withdrawMoneyStatus$.pipe(ee()).subscribe(e=>{this.canProvideChange.set(e),this.changeDue()>0&&this.completeTransaction()})}insertCash(e){this.isProcessing()||(this.receivedAmount.update(t=>t+e),this.receivedAmount()>=this.totalAmount()&&setTimeout(()=>this.showSuccessState(),500))}showSuccessState(){this.isProcessing.set(!0);let e=this.receivedAmount()-this.totalAmount();this.changeDue.set(e),this.paymentState.set("success"),this.checkCanProvideChange()}checkCanProvideChange(){this.changeDue()===0?this.completeTransaction():this.cashMachineService.sendWithdrawMoney(this.changeDue())}completeTransaction(){this.transactionComplete.emit({changeDue:this.changeDue(),canProvideChange:this.canProvideChange()})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=A({type:n,selectors:[["cash-machine-payment"]],inputs:{totalAmount:[1,"totalAmount"]},outputs:{transactionComplete:"onTransactionComplete"},decls:2,vars:1,consts:[["id","paymentContent"],["id","successState",1,"animate-successPulse","py-3"],[1,"instruction-card"],[1,"text-body-emphasis","fw-bold","mb-2","text-center"],[1,"text-secondary-emphasis","fw-medium","mb-3","text-center"],[1,"text-center","mt-6"],[1,"badge","rounded-pill","fs-6","bg-warning-subtle","text-warning-emphasis","fw-medium","py-4","px-4","border","border-warning-subtle"],[1,"animate-pulse-opacity","me-1"],[1,"payment-info-card"],[1,"d-flex","justify-content-between","align-items-center","mb-2","fs-5"],[1,"info-label","fw-medium"],[1,"info-value","fw-bold","text-success"],[1,"d-flex","justify-content-between","align-items-center","fs-5"],[1,"info-value","fw-bold","text-danger"],[1,"progress-container","px-2"],[1,"d-flex","justify-content-between","align-items-center","mb-1"],[1,"small","fw-semibold","text-body-secondary","fs-6"],[1,"small","fw-bold","text-success","fs-6"],["role","progressbar","aria-label","Payment Progress","aria-valuemin","0","aria-valuemax","100",1,"progress",2,"height","8px"],[1,"progress-bar","bg-success"],[1,"success-icon"],[1,"fw-bold"],[1,"h1","fw-semibold","text-success","mb-6","text-center"],[1,"h1","fw-bold","text-body-emphasis","mb-8","text-center"],[1,"alert","alert-warning","d-flex","flex-column","align-items-center","p-5","border","border-warning","border-1"],[1,"fas","fa-exclamation-triangle","text-warning",2,"font-size","24px"],[1,"h4","fw-bold","mt-2"],[1,"small","text-warning-emphasis","mb-2","fs-6","mt-2","text-center"],[1,"me-1"]],template:function(t,i){t&1&&h(0,ns,48,19,"div",0)(1,ls,9,2,"div",1),t&2&&C(i.paymentState()==="paying"?0:1)},dependencies:[Se,q],styles:[".instruction-card[_ngcontent-%COMP%]{background:linear-gradient(135deg,#f8f9fa,#e9ecef);border:2px solid var(--bs-success);border-radius:1rem;padding:1.5rem;margin-bottom:2rem;position:relative;box-shadow:0 .5rem 1rem #19875426}.payment-info-card[_ngcontent-%COMP%]{background-color:#1987540d;border-radius:.75rem;padding:1rem;margin-top:1rem;border:1px solid rgba(25,135,84,.2)}.success-icon[_ngcontent-%COMP%]{width:5rem;height:5rem;background-color:var(--bs-success);border-radius:50%;display:flex;align-items:center;justify-content:center;margin:0 auto 1.25rem;color:#fff;font-size:3rem;box-shadow:0 .5rem 1.5rem #1987544d}.progress-bar[_ngcontent-%COMP%]{background:linear-gradient(90deg,#198754,#28a745);transition:width .5s ease}@keyframes _ngcontent-%COMP%_shimmer{0%,to{transform:rotate(0) scale(2);opacity:0}50%{transform:rotate(180deg) scale(2);opacity:.1}}@keyframes _ngcontent-%COMP%_glow{0%{box-shadow:0 0 5px #198754}to{box-shadow:0 0 15px #1eac67,0 0 25px #1eac67}}@keyframes _ngcontent-%COMP%_pulse-opacity{0%,to{opacity:1}50%{opacity:.5}}@keyframes _ngcontent-%COMP%_successPulse{0%{transform:scale(0)}50%{transform:scale(1.1)}to{transform:scale(1)}}@keyframes _ngcontent-%COMP%_attention{0%,to{transform:scale(1)}50%{transform:scale(1.1)}}.animate-shimmer[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_shimmer 3s ease-in-out infinite}.animate-glow[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_glow 2s ease-in-out infinite alternate}.animate-pulse-opacity[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_pulse-opacity 2s infinite}.animate-successPulse[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_successPulse .6s ease-out}.animate-attention[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_attention 2s ease-in-out infinite}"]})};function ms(n,e){n&1&&(a(0,"div",0)(1,"div",1),b(2,"img",2),s()(),a(3,"div",0)(4,"div",3)(5,"p",4),m(6," Please insert or swipe Debit/Credit Card for complete this transaction "),s()()())}function ds(n,e){n&1&&(a(0,"div",0)(1,"div",5),b(2,"i",6),s(),a(3,"div",7)(4,"p",8),m(5," Please cancel the order at EDC machine by pressing the Cancel button "),a(6,"span",9),m(7,"(RED)"),s(),m(8," for clear currently amount "),s()()())}var dn=class n{isCancel=!1;constructor(){}ngOnInit(){}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=A({type:n,selectors:[["app-modal-ecr-info"]],inputs:{isCancel:"isCancel"},standalone:!1,decls:2,vars:1,consts:[[1,"row"],[1,"col-12","d-flex","align-items-center","justify-content-center","pe-12","ps-0"],["src","https://cdn.dealpos.xyz/web-image/EDC-Biru.png","alt",""],[1,"col-12","ps-0","d-flex","align-items-center","justify-content-center"],[1,"mb-2","fs-5","text-body-secondary"],[1,"col-2","d-flex","align-items-center","justify-content-center","pe-0"],[1,"fa-regular","fa-circle-xmark","text-danger",2,"font-size","40px"],[1,"col-10","d-flex","align-items-center","justify-content-center"],[1,"mb-2","px-3","fs-5","text-body-secondary"],[1,"text-danger","fw-bold"]],template:function(t,i){t&1&&h(0,ms,7,0)(1,ds,9,0,"div",0),t&2&&C(i.isCancel?1:0)},encapsulation:2})};var pn=class n{constructor(){}ngOnInit(){}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=A({type:n,selectors:[["app-confirm-demo-qris"]],standalone:!1,decls:22,vars:0,consts:[[1,"row"],[1,"col-4","d-flex","align-items-center","justify-content-center","pe-0"],["src","https://cdn.dealpos.xyz/web-image/QR_Test.png","width","115px","alt",""],[1,"col-8","ps-0"],[1,"mt-10"],["href","https://www.dealpos.co.id/tour/mobile-payment","target","_blank"],[1,"fw-bold"]],template:function(t,i){t&1&&(a(0,"div",0)(1,"div",1),b(2,"img",2),s(),a(3,"div",3)(4,"h4"),m(5,"WARNING"),s(),a(6,"p",4),m(7," You need to complete "),a(8,"a",5),m(9,"Regristration"),s(),m(10," with our payment Partner - "),a(11,"span",6),m(12,"Midtrans"),s(),m(13," before you can start accpeting "),a(14,"span",6),m(15,"QRIS Payment"),s(),m(16," and receive Pay Out at your Bank Account. "),s(),a(17,"p"),m(18," If you wish to test how this functionality works, we have provided a Sandbox account for "),a(19,"span",6),m(20,"Testing"),s(),m(21," purpose. "),s()()())},encapsulation:2})};var En=n=>({selected:n}),fs=(n,e)=>({active:n,"font-12":e}),hs=n=>({"border-top py-5":n}),Cs=n=>({"d-print-none":n}),vs=n=>({"qris-barcode":n}),_s=n=>({bottom:n});function ys(n,e){if(n&1&&(a(0,"span"),m(1),s()),n&2){let t=d(2);l(),M(" (+",t.posData==null?null:t.posData.Invoice.SurchargePcg,"%) ")}}function bs(n,e){if(n&1&&(a(0,"span"),m(1),s(),a(2,"span"),m(3),y(4,"number"),s()),n&2){let t=d(2);l(),O(t.cashierCalculatorService==null?null:t.cashierCalculatorService.currencySymbol),l(2),O(x(4,2,t.totalAmount()))}}function Ss(n,e){if(n&1&&(a(0,"header")(1,"div",6),$(2,ys,2,1,"span",1),h(3,bs,5,4),s()()),n&2){let t=d();l(2),p("ngIf",(t.posData==null?null:t.posData.Invoice.SurchargePcg)>0),l(),C(t.userRole.PriceVisible?3:-1)}}function Ps(n,e){if(n&1){let t=E();a(0,"a",14),S("click",function(){v(t);let o=d(4);return _(o.onSplitClick())}),m(1," Split "),a(2,"span",15),m(3,"Payment"),s()()}if(n&2){let t=d(4);p("ngClass",Q(1,En,t.modalFields.isStateSplit))}}function Os(n,e){if(n&1){let t=E();a(0,"a",16),S("click",function(){v(t);let o=d(4);return _(o.onLaterClick())}),m(1," Later "),a(2,"span",15),m(3,"Take Credit"),s()()}if(n&2){let t=d(4);p("ngClass",Q(1,En,t.modalFields.isStateLater))}}function Ds(n,e){if(n&1){let t=E();a(0,"div")(1,"a",11),S("click",function(){v(t);let o=d(3);return _(o.onNowClick())}),m(2," Now "),s(),$(3,Ps,4,3,"a",12)(4,Os,4,3,"a",13),s()}if(n&2){let t=d(3);l(),p("ngClass",Q(3,En,t.modalFields.isStateNow)),l(2),p("ngIf",((t.modalFields==null||t.modalFields.paymentSuggestion==null?null:t.modalFields.paymentSuggestion.length)==0||t.cashPaymentChange<0)&&t.modalFields.splitPaymentEnabled),l(),p("ngIf",t.modalFields.payNowEnabled==!1&&!t.userRole.CreditSalesLock)}}function Ms(n,e){if(n&1&&(a(0,"div",10),$(1,Ds,5,5,"div",1),s()),n&2){let t=d(2);l(),p("ngIf",t.modalFields.payNowNLaterEnabled||t.modalFields.payNowEnabled)}}function xs(n,e){if(n&1){let t=E();a(0,"div",31)(1,"a",32),S("click",function(){let o=v(t).$implicit,r=d(5);return _(r.updateCashPayment(o))}),m(2),y(3,"number"),s()()}if(n&2){let t=e.$implicit,i=d(5);l(),p("ngClass",Ue(5,fs,(i.Payments[0]==null?null:i.Payments[0].MethodID)==i.defaultCashPaymentMethodID&&(i.Payments[0]==null?null:i.Payments[0].PaidAmount)==t,i.modalFields.paymentSuggestion[0].toString().length>8)),l(),ui("",i.cashierCalculatorService==null?null:i.cashierCalculatorService.currencySymbol," ",x(3,3,t))}}function Is(n,e){if(n&1&&(a(0,"div",29),$(1,xs,4,8,"div",30),s()),n&2){let t=d(4);l(),p("ngForOf",t.modalFields.paymentSuggestion)}}function Ts(n,e){if(n&1&&(a(0,"div",33),m(1),y(2,"number"),s()),n&2){let t=d(4);p("ngClass",t.cashPaymentChange>0?"success":"danger"),l(),ui(" ",t.cashierCalculatorService==null?null:t.cashierCalculatorService.currencySymbol," ",x(2,3,t.cashPaymentChange)," ")}}function Es(n,e){if(n&1){let t=E();Ct(0),a(1,"div",17)(2,"div",21),b(3,"i",22),m(4," Cash "),s(),a(5,"div",23),$(6,Is,2,1,"div",24),a(7,"div",25)(8,"div",26)(9,"input",27),j("ngModelChange",function(o){v(t);let r=d(3);return V(r.inputAmountString,o)||(r.inputAmountString=o),_(o)}),S("ngModelChange",function(){v(t);let o=d(3);return _(o.updateCashPayment(o.inputAmountString))}),s(),$(10,Ts,3,5,"div",28),s()()()(),vt()}if(n&2){let t=d(3);l(6),p("ngIf",t.userRole.PriceVisible),l(3),p("simpleKeyboard",t.keyboard),H("ngModel",t.inputAmountString),l(),p("ngIf",t.cashPaymentChange!=0)}}function ws(n,e){if(n&1){let t=E();a(0,"div",36)(1,"button",37),S("click",function(){let o=v(t).$implicit,r=d(4);return _(r.handlingCashMachinePayment(o))}),a(2,"span",38),b(3,"img",39),s(),a(4,"span",38),m(5),y(6,"limitTo"),s()()()}if(n&2){let t=e.$implicit;l(2),p("hidden",t.ImageUrl==null),l(),p("src",t.ImageUrl,mt),l(),p("hidden",t.ImageUrl!=null),l(),M(" ",X(6,4,t.Name,20)," ")}}function Rs(n,e){if(n&1&&(a(0,"div",17)(1,"div",21),b(2,"i",34),m(3," Cash Machine "),s(),a(4,"div",23)(5,"div",35),K(6,ws,7,7,"div",36,ot),s()()()),n&2){let t=d(3);l(6),Z(t.cashMachineList())}}function Ns(n,e){if(n&1){let t=E();a(0,"div",36)(1,"button",37),S("click",function(){let o=v(t).$implicit,r=d(4);return r.onPaymentMethodChanged(o),_(r.payWithEmoney(o))}),a(2,"span",38),b(3,"img",39),s(),a(4,"span",38),m(5),y(6,"limitTo"),s()()()}if(n&2){let t=e.$implicit;l(2),p("hidden",t.ImageUrl==null),l(),p("src",t.ImageUrl,mt),l(),p("hidden",t.ImageUrl!=null),l(),M(" ",X(6,4,t.Name,20)," ")}}function As(n,e){if(n&1&&(a(0,"div",17)(1,"div",21),b(2,"i",40),m(3," QRIS "),s(),a(4,"div",23)(5,"div",35),$(6,Ns,7,7,"div",41),s()()()),n&2){let t=d(3);l(6),p("ngForOf",t.getTypePaymentList(3))}}function ks(n,e){if(n&1&&(a(0,"span"),b(1,"img",39),s()),n&2){let t=d().$implicit;l(),p("src",t.ImageUrl,mt)}}function Vs(n,e){if(n&1&&(a(0,"span"),m(1),y(2,"limitTo"),s()),n&2){let t=d().$implicit;l(),M(" ",X(2,1,t.Name,20)," ")}}function Fs(n,e){if(n&1){let t=E();a(0,"div",36)(1,"button",37),S("click",function(){let o=v(t).$implicit,r=d(4);return _(r.handlingSubmitOrderWithEcr(o))}),$(2,ks,2,1,"span",1)(3,Vs,3,4,"span",1),s()()}if(n&2){let t=e.$implicit;l(2),p("ngIf",t.ImageUrl!=null),l(),p("ngIf",t.ImageUrl==null)}}function Ls(n,e){if(n&1&&(a(0,"div",42)(1,"div",21),b(2,"i",43),m(3," ECR / EDC "),s(),a(4,"div",23)(5,"div",25),$(6,Fs,4,2,"div",41),s()()()),n&2){let t=d(3);l(6),p("ngForOf",t.getTypePaymentList(99))}}function Bs(n,e){if(n&1&&(a(0,"div",21),b(1,"i"),m(2),s()),n&2){let t=d().$implicit;l(),pi(t.Icon),l(),M(" ",t.Name," ")}}function Hs(n,e){if(n&1){let t=E();a(0,"div",36)(1,"a",48),S("click",function(){let o=v(t).$implicit,r=d(5);return _(r.onPaymentMethodChanged(o))}),m(2),y(3,"limitTo"),s()()}if(n&2){let t=e.$implicit,i=d(5);l(),p("ngClass",i.Payments[0].MethodID===t.ID?"active":""),l(),M(" ",X(3,2,t.Name,20)," ")}}function js(n,e){n&1&&(a(0,"small",53),m(1," Payment Note is required "),s())}function Qs(n,e){n&1&&(a(0,"small",53),m(1," Payment Code is required "),s())}function Us(n,e){n&1&&(a(0,"small",53),m(1," Please input maximum 1 characters "),s())}function Ws(n,e){if(n&1&&(h(0,Qs,2,0,"small",53),h(1,Us,2,0,"small",53)),n&2){let t=d(6);C(t.paymentCodeCtrl.hasError("required")?0:-1),l(),C(t.paymentCodeCtrl.hasError("maxlength")?1:-1)}}function Gs(n,e){if(n&1&&(a(0,"div",49)(1,"div",50)(2,"div",51),b(3,"input",52),h(4,js,2,0,"small",53),s(),a(5,"div",51),b(6,"input",54),h(7,Ws,2,2),s()()()),n&2){let t=d(5);l(3),p("formControl",t.paymentNoteCtrl),l(),C(t.paymentNoteCtrl.invalid&&(t.paymentNoteCtrl.dirty||t.paymentNoteCtrl.touched)?4:-1),l(2),p("formControl",t.paymentCodeCtrl),l(),C(t.paymentCodeCtrl.dirty||t.paymentCodeCtrl.touched?7:-1)}}function qs(n,e){if(n&1&&(a(0,"div",23)(1,"div",25),$(2,Hs,4,5,"div",41),s(),$(3,Gs,8,4,"div",47),s()),n&2){let t=d().$implicit,i=d(3);l(2),p("ngForOf",i.getTypePaymentList(t.ID)),l(),p("ngIf",i.isOtherPayment(t.ID))}}function $s(n,e){if(n&1&&(a(0,"div",44),$(1,Bs,3,3,"div",45)(2,qs,4,2,"div",46),s()),n&2){let t=e.$implicit,i=d(3);p("ngClass",Q(3,hs,i.getTypePaymentList(t.ID).length>0)),l(),p("ngIf",i.getTypePaymentList(t.ID).length>0),l(),p("ngIf",i.getTypePaymentList(t.ID).length>0)}}function Js(n,e){if(n&1&&(a(0,"div"),$(1,Es,11,4,"ng-container",1),h(2,Rs,8,0,"div",17),$(3,As,7,1,"div",18)(4,Ls,7,1,"div",19)(5,$s,3,5,"div",20),s()),n&2){let t,i=d(2);l(),p("ngIf",(i.modalFields==null||i.modalFields.paymentSuggestion==null?null:i.modalFields.paymentSuggestion.length)>0),l(),C(((t=i.cashMachineList())==null?null:t.length)>0?2:-1),l(),p("ngIf",i.getTypePaymentList(3).length>0&&i.isOnline),l(),p("ngIf",i.getTypePaymentList(99).length>0&&i.isOnline),l(),p("ngForOf",i.paymentTypes)}}function zs(n,e){if(n&1){let t=E();a(0,"div")(1,"div",55)(2,"strong",56),m(3,"Due"),s(),a(4,"datepicker",57),j("dateChange",function(o){v(t);let r=d(2);return V(r.modalFields.payLaterDueDate,o)||(r.modalFields.payLaterDueDate=o),_(o)}),S("dateChange",function(){v(t);let o=d(2);return _(o.dueDateChange())}),s()(),a(5,"div",58)(6,"strong",59),m(7,"Days Due"),s(),a(8,"input",60),j("ngModelChange",function(o){v(t);let r=d(2);return V(r.modalFields.payLaterDueDays,o)||(r.modalFields.payLaterDueDays=o),_(o)}),S("ngModelChange",function(){v(t);let o=d(2);return _(o.dueDayChange())}),s()()()}if(n&2){let t=d(2);l(4),H("date",t.modalFields.payLaterDueDate),p("displayToggle",!1),l(4),p("simpleKeyboard",t.keyboard),H("ngModel",t.modalFields.payLaterDueDays)}}function Ys(n,e){if(n&1){let t=E();Ct(0),a(1,"div",25)(2,"div",62)(3,"div",63)(4,"strong",64),m(5,"Payment 1:"),s()(),a(6,"div")(7,"ng-select",65),S("change",function(o){v(t);let r=d(3);return _(r.onPaymentMethodChanged(o))}),s()()(),a(8,"div",66)(9,"div",63)(10,"strong",67),m(11,"Amount 1:"),s()(),a(12,"div")(13,"input",68),S("ngModelChange",function(o){v(t);let r=d(3);return _(r.onFirstPaymentSplitChange(o))}),s()()()(),vt()}if(n&2){let t=d(3);l(7),p("items",t.firstPaymentSplitOptions)("ngModel",t.firstPayment==null?null:t.firstPayment.MethodID)("clearable",!1),l(6),p("ngModel",t.firstPayment.PaidAmount)}}function Ks(n,e){n&1&&(a(0,"small",53),m(1," Payment Note is required "),s())}function Zs(n,e){n&1&&(a(0,"small",53),m(1," Payment Code is required "),s())}function Xs(n,e){n&1&&(a(0,"small",53),m(1," Please input maximum 1 characters "),s())}function el(n,e){if(n&1&&(h(0,Zs,2,0,"small",53),h(1,Xs,2,0,"small",53)),n&2){let t=d(5);C(t.paymentCodeCtrl2.hasError("required")?0:-1),l(),C(t.paymentCodeCtrl2.hasError("maxlength")?1:-1)}}function tl(n,e){if(n&1&&(a(0,"div",75)(1,"div",50)(2,"div",51),b(3,"input",52),h(4,Ks,2,0,"small",53),s(),a(5,"div",51),b(6,"input",54),h(7,el,2,2),s()()()),n&2){let t=d(4);l(3),p("formControl",t.paymentNoteCtrl2),l(),C(t.paymentNoteCtrl2.invalid&&(t.paymentNoteCtrl2.dirty||t.paymentNoteCtrl2.touched)?4:-1),l(2),p("formControl",t.paymentCodeCtrl2),l(),C(t.paymentCodeCtrl2.dirty||t.paymentCodeCtrl2.touched?7:-1)}}function il(n,e){if(n&1){let t=E();Ct(0),a(1,"div",69)(2,"div",70)(3,"div",71)(4,"div",63)(5,"strong",64),m(6,"Payment 2:"),s()(),a(7,"div")(8,"ng-select",72),S("change",function(o){v(t);let r=d(3);return _(r.onSplitPaymentMethodAssigned(o))}),s()()(),a(9,"div",73)(10,"strong",67),m(11,"Amount 2:"),s(),a(12,"span",74),m(13),y(14,"number"),s()()()(),h(15,tl,8,4,"div",75),vt()}if(n&2){let t=d(3);l(8),p("items",t.splitPaymentMethodList)("ngModel",t.Payments[1]==null?null:t.Payments[1].MethodID),l(5),O(x(14,4,t.paymentSplitDefaultVal)),l(2),C((t.Payments[1]==null?null:t.Payments[1].TypeID)!==t.paymentType.ECR&&(t.Payments[1]==null?null:t.Payments[1].TypeID)!==t.paymentType.emoney&&(t.Payments[1]==null?null:t.Payments[1].TypeID)!==t.paymentType.cash&&t.Payments[1]?15:-1)}}function nl(n,e){if(n&1&&(a(0,"div",61),$(1,Ys,14,4,"ng-container",1)(2,il,16,6,"ng-container",1),s()),n&2){let t=d(2);l(),p("ngIf",(t.modalFields==null||t.modalFields.paymentSuggestion==null?null:t.modalFields.paymentSuggestion.length)==0),l(),p("ngIf",t.cashPaymentChange<0)}}function ol(n,e){if(n&1&&(a(0,"div",7),$(1,Ms,2,1,"div",8)(2,Js,6,5,"div",1)(3,zs,9,4,"div",1)(4,nl,3,2,"div",9),s()),n&2){let t=d();l(),p("ngIf",t.modalFields.payLaterEnabled==!1),l(),p("ngIf",t.modalFields.isStateNow),l(),p("ngIf",t.modalFields.isStateLater&&!t.userRole.CreditSalesLock),l(),p("ngIf",t.modalFields.isStateSplit)}}function rl(n,e){if(n&1&&(Ct(0),a(1,"div",87),b(2,"img",88),s(),vt()),n&2){let t=d(2);l(),p("ngStyle",Q(1,_s,t.modalFields.merchantName?"0px":"-25px"))}}function al(n,e){if(n&1&&(a(0,"h2",89),m(1),s()),n&2){let t=d(2);l(),M(" ",t.modalFields.merchantName," ")}}function sl(n,e){if(n&1&&(a(0,"div",76)(1,"div",77)(2,"span",78),m(3),s(),a(4,"div",79)(5,"div",80)(6,"span",81),m(7,"Invoice"),s(),a(8,"span"),m(9,":"),s()(),a(10,"div",82)(11,"span",83),m(12),s()()(),a(13,"div",79)(14,"div",80)(15,"span"),m(16,"Amount"),s(),a(17,"span"),m(18,":"),s()(),a(19,"div",82)(20,"span",83),m(21),y(22,"number"),s()()()(),$(23,rl,3,3,"ng-container",1)(24,al,2,1,"h2",84),a(25,"div",85),b(26,"img",86),s()()),n&2){let t=d();l(2),p("ngClass",Q(11,Cs,(t.selectedPaymentMethod==null?null:t.selectedPaymentMethod.EMoneyTypeID)!=(t.modalFields==null?null:t.modalFields.emoneyType.Gopay))),l(),O(t.modalFields==null?null:t.modalFields.merchantName),l(9),O(t.posData==null||t.posData.Order==null?null:t.posData.Order.Number),l(9),ui("",t.cashierCalculatorService.currencySymbol," ",x(22,9,t.totalAmount())),l(2),p("ngIf",(t.selectedPaymentMethod==null?null:t.selectedPaymentMethod.EMoneyTypeID)==(t.modalFields==null?null:t.modalFields.emoneyType.Gopay)),l(),p("ngIf",t.modalFields.merchantName&&(t.selectedPaymentMethod==null?null:t.selectedPaymentMethod.EMoneyTypeID)==(t.modalFields==null?null:t.modalFields.emoneyType.Gopay)),l(2),p("src",t.qrImage,mt)("ngClass",Q(13,vs,(t.selectedPaymentMethod==null?null:t.selectedPaymentMethod.EMoneyTypeID)==(t.modalFields==null?null:t.modalFields.emoneyType.Gopay)))}}function ll(n,e){n&1&&b(0,"app-confirm-demo-qris")}function cl(n,e){if(n&1&&(Ct(0),b(1,"app-modal-ecr-info",90),vt()),n&2){let t=d();l(),p("isCancel",t.modalFields.isCancelEcrTransaction)}}function ml(n,e){if(n&1){let t=E();a(0,"cash-machine-payment",91),S("onTransactionComplete",function(o){v(t);let r=d();return _(r.onCashMachineTransactionComplete(o))}),s()}if(n&2){let t=d();p("totalAmount",t.totalAmount())}}function dl(n,e){if(n&1){let t=E();a(0,"button",94),S("click",function(){v(t);let o=d(2);return _(o.onCancelCashMachine())}),m(1," Cancel "),s()}}function pl(n,e){if(n&1){let t=E();a(0,"button",95),S("click",function(){v(t);let o=d(2);return _(o.onCashMachineNotProvideChange())})("keyup.F2",function(){v(t);let o=d(2);return _(o.onCashMachineNotProvideChange())}),m(1," Ok "),s()}}function ul(n,e){if(n&1&&h(0,dl,2,0,"button",92)(1,pl,2,0,"button",93),n&2){let t=d();C(t.modalFields.isCashMachineProvideChange()?0:1)}}function gl(n,e){if(n&1){let t=E();a(0,"a",94),S("click",function(){v(t);let o=d();return _(o.onPrintQR())}),b(1,"i",96),m(2,"Print QR "),s()}}function fl(n,e){if(n&1){let t=E();a(0,"a",94),S("click",function(){v(t);let o=d();return _(o.validateEMoneyPayment())}),m(1," Verify Payment Settlement "),s()}}function hl(n,e){if(n&1){let t=E();a(0,"a",94),S("click",function(){v(t);let o=d();return _(o.onCancelWaitingEcr())}),m(1),s()}if(n&2){let t=d();l(),M(" ",t.modalFields.isCancelEcrTransaction?"Close":"Cancel"," ")}}function Cl(n,e){if(n&1){let t=E();a(0,"a",94),S("click",function(){v(t);let o=d();return _(o.onBack())}),m(1," Back "),s()}}function vl(n,e){if(n&1){let t=E();a(0,"a",94),S("click",function(){v(t);let o=d();return _(o.onContinueDemoQr())}),m(1," Continue "),s()}}var un=class n{constructor(e,t,i,o,r,c,u,D,F,W,ye,_n,Rn,nr,yn,bn,Nn,Jl,zl){this.dialogRef=e;this._orderDataService=t;this.cashierCalculatorService=i;this._paymentService=o;this._posHubService=r;this._posService=c;this._toastr=u;this._paymentGatewayService=D;this.decimalPipe=F;this.sanitizer=W;this._orderProcessorService=ye;this._numpadService=_n;this._userRoleService=Rn;this._customerHttpService=nr;this._onlineStatusService=yn;this._ecrService=bn;this.outletService=Nn;this.ecrSignalService=Jl;this.cashMachineService=zl;this.paymentSplitDefaultVal=0,this.defaultCashPaymentMethodID=0,this.destroy$=new Me,this.AppConfigJSON=this._posService.Data.AppConfigJSON,this.modalFields.mapAppConfigJson(this.AppConfigJSON),this.initializeDefaultValues(),this.subscribeToObservableChanges()}modalFields=new sn;userRole;posData=new G;AppConfigJSON=new st;keyboard;paymentType=Zt;Payments=[];defaultCashPaymentMethodID;inputAmountString=null;qrImage;paymentMethodList;paymentTypes;paymentSplitDefaultVal;posState;splitPaymentMethodList;isOnline=!0;get firstPayment(){return this.Payments[0]}set firstPayment(e){this.Payments[0]=e}selectedPaymentMethod;get cashPaymentChange(){let e=this.cashierCalculatorService.Data;return(this.firstPayment?this.firstPayment.PaidAmount:0)-e}firstPaymentSplitOptions;destroy$;paymentNoteCtrl;paymentCodeCtrl;paymentNoteCtrl2;paymentCodeCtrl2;totalAmount=se(()=>this.cashierCalculatorService.Data);cashMachineList=se(()=>this.getTypePaymentList(1).filter(t=>t.SubTypeID==4));subscribeToObservableChanges(){this._orderDataService.Data$.pipe(Ie(this.destroy$)).subscribe(e=>{this.posData=e}),this._orderProcessorService.Data$.pipe(Ie(this.destroy$)).subscribe(e=>{this.posState=e.posState,this.initializeInvoicePaymentsValue(this.posState),this.initTabState()}),this._onlineStatusService.getOnlineStatus$().pipe(Ie(this.destroy$)).subscribe(e=>{this.isOnline=e})}initCashFocus(){let e=document.getElementById("cashInput");if(e){e.focus();let t=e?.value?.length;setTimeout(()=>{e.setSelectionRange(t,t)},0)}}initTabState(){if(this.posState==2)switch(this.posData.Invoice.PaymentStateID){case 3:this.modalFields.viewState=0;break;case 1:this.modalFields.viewState=1;break}}initializeInvoicePaymentsValue(e){e!==2?(this.firstPayment=new Ke,this.firstPayment.Amount=this.cashierCalculatorService.Data,this.firstPayment.PaidAmount=this.cashierCalculatorService.Data,this.firstPayment.MethodID=this.defaultCashPaymentMethodID,this.firstPayment.TypeID=1):(this.Payments=this.posData.Payments,this.initFirstPayment()),this.initPaymentNoteAndCode(this.firstPayment)}initFirstPayment(){if(!this.firstPayment)this.firstPayment=new Ke,this.firstPayment.Amount=this.cashierCalculatorService.Data,this.firstPayment.PaidAmount=this.cashierCalculatorService.Data,this.firstPayment.MethodID=this.defaultCashPaymentMethodID,this.modalFields.viewState=1;else if(this.posData.Invoice.PaymentStateID==3)if(this.Payments.length>1)this.initSplitPayment(),this.initPaymentNoteAndCodeSplit(this.Payments[1]);else{let t=this.findPaymentMethodByID(this.firstPayment.MethodID);this.firstPayment.PaidAmount=this.cashierCalculatorService.Data,this.firstPayment.Amount=this.cashierCalculatorService.Data,this.firstPayment.MethodID=this.Payments[0].MethodID,this.firstPayment.TypeID=t?.TypeID}let e=this.firstPayment.PaidAmount;this.inputAmountString=e?e.toString():null}findPaymentMethodByID(e){return this._paymentService.getPaymentList()?.find(o=>o.ID==e)}initPaymentNoteAndCode(e){let t=this.getPaymentNoteAndCodeValidators(e);this.paymentCodeCtrl?(this.paymentCodeCtrl.setValue(e?.Code),this.paymentNoteCtrl.setValue(e?.Note),this.paymentCodeCtrl.setValidators(t.paymentCodeValidators),this.paymentNoteCtrl.setValidators(t.paymentNoteValidators),this.paymentCodeCtrl.updateValueAndValidity(),this.paymentNoteCtrl.updateValueAndValidity()):(this.paymentCodeCtrl=new et(e?.Code,t.paymentCodeValidators),this.paymentNoteCtrl=new et(e?.Note,t.paymentNoteValidators))}getPaymentNoteAndCodeValidators(e){let t=this.AppConfigJSON?.ModuleSell?.PaymentDialog,i=this.userRole.PaymentCodeLock,o=[],r=[];if(e&&e?.TypeID!=1&&e?.TypeID!=99&&e?.TypeID!=3){let c=i?[Ci.maxLength(1)]:[],u=t.PaymentCodeRequired?[Ci.required]:[];o=[...c,...u],r=t.PaymentNoteRequired?[Ci.required]:[]}return{paymentCodeValidators:o,paymentNoteValidators:r}}initSplitPayment(){let e=this.cashierCalculatorService.Data,t=this.Payments[1].PaidAmount,i=e-t;this.firstPayment.PaidAmount=i,this.firstPayment.Amount=i,this.paymentSplitDefaultVal=t,this.filterSplitPaymentList()}initializeDefaultValues(){this.modalFields.paymentSuggestion=this._paymentService.generateCashSuggestion(),this.paymentMethodList=this.outletService.Data.Payments,this.paymentTypes=this._posService.Data.PaymentTypes,this.defaultCashPaymentMethodID=this._paymentService.defaultCashPaymentMethodID,this.modalFields.splitPaymentEnabled=this.outletService.Data.SplitPaymentEnabled,this._userRoleService.Data$.pipe(Ie(this.destroy$)).subscribe(e=>{this.userRole=e,this.initPaylaterTab()}),this.initFirstPaymentSplitOptions()}initPaylaterTab(){this.userRole.CreditSalesLock&&(this.modalFields.viewState=0)}ngOnInit(){this.modalFields.numpadVisible&&(this.keyboard=this._numpadService.keyboard),this.initDefaultDueDays()}initDefaultDueDays(){let e=this._customerHttpService.Data,t=e?e.DueDays:null,i=e?e.DueMonths:null,o=new Date;o.setHours(0,0,0,0);let r=new Date;r.setHours(0,0,0,0),f.IsNotEmpty(this.posData.Invoice.Due)?o=new Date(this.posData.Invoice.Due):(i&&o.setMonth(o.getMonth()+i),!t&&!i&&(t=this.modalFields.config.DefaultDueDays),o.setDate(o.getDate()+t)),this.modalFields.payLaterDueDate=o,this.modalFields.payLaterDueDays=f.differentInDays(r,o),this.posData.Invoice.Due=this.modalFields.payLaterDueDate}onBack(){this.modalFields.viewState=0,this.changeModalForEmoney(!1),this.modalFields.enableEmoneyConfirmModal(!1),this.setToCashPayment(),this._paymentGatewayService.clearTransactionID()}onCancelWaitingEcr(){this.modalFields.isCancelEcrTransaction?(this.modalFields.viewState=0,this.modalFields.enableModalWaitingEcr(!1),this.setToCashPayment()):this.modalFields.cancelEcrTransaction()}onOk(){this.validateSerialItem()&&this.onSubmitOrder()}onSubmitOrder(){if(this.posData.Action.Type=3,this.posData.Order.InvoicedStateID=3,this.isPaymentLater())this.validatePaymentLater(this.userRole)&&(this.modalFields.viewState==1?this.Payments=[]:this.setPaymentNoteAndCode(this.firstPayment,this.paymentNoteCtrl.value,this.paymentCodeCtrl.value),this._paymentService.submitOrder(this.Payments),this.closeDialogAfterSubmit());else if(this.posData.Invoice.Due=null,this.validatePay()){if(this.validatePaymentSplit(),this.isCustomerLimitDebt())return;this.setPaymentNoteAndCode(this.firstPayment,this.paymentNoteCtrl.value,this.paymentCodeCtrl.value),this._paymentService.submitOrder(this.Payments),this.closeDialogAfterSubmit()}}setPaymentNoteAndCode(e,t,i){e&&e.TypeID!=1&&e.TypeID!=99&&e.TypeID!=3&&(e.Code=i,e.Note=t)}isPaymentLater(){let e=this.modalFields.viewState==1,t=this.cashPaymentChange<0&&this.Payments.length==1;return e||t}handlingSubmitOrderWithEcr(e){if(this.ecrSignalService.isConnected()==!1){this._toastr.error("ECR is not connected","Error");return}this.onPaymentMethodChanged(e),this.posData.Invoice.Due=null;let t=this.firstPayment.PaidAmount;this.modalFields.viewState=5,this.modalFields.enableModalWaitingEcr(!0),this._ecrService.onPay(t).pipe(Ie(this.destroy$)).subscribe({next:i=>{i.IsSuccess?(this.firstPayment.Code=i.Trace_No,this.firstPayment.Note=`${i.CardType} ${i.CardNumer}`,this._paymentService.submitOrder(this.Payments),this.onCloseDialog()):this.handlingEcrOnError()},error:i=>{this.handlingEcrOnError(),console.error(i)}})}handlingEcrOnError(){this._toastr.error("Transaction Canceled. Try Again","Error"),this.modalFields.viewState=0,this.modalFields.enableModalWaitingEcr(!1),this.setToCashPayment()}handlingCashMachinePayment(e){this.cashMachineService.isConnected()?(this.onPaymentMethodChanged(e),this.posData.Invoice.Due=null,this.modalFields.viewState=6,this.modalFields.enableModalCashMachine(!0)):this._toastr.error("Cash Machine is not connected, You need to connect it first","Error")}onCancelCashMachine(){this.modalFields.viewState=0,this.modalFields.enableModalCashMachine(!1),this.setToCashPayment()}onCashMachineTransactionComplete(e){e.changeDue==0?this.onSubmitOrder():e.canProvideChange?this.onSubmitOrder():this.modalFields.isCashMachineProvideChange.set(!1)}onCashMachineNotProvideChange(){this._paymentService.submitOrder(this.Payments),this.closeDialogAfterSubmit()}isCustomerLimitDebt(){if(this.paymentSplitDefaultVal>0&&this.Payments.length==1){let e=this._customerHttpService.Data;if(e.DebtLimit>0){let t=e.Debt==0&&this.paymentSplitDefaultVal>e.DebtLimit,i=e.Debt+this.paymentSplitDefaultVal>e.DebtLimit;if(t||i)return this._toastr.warning(oe.debtLimit,"Warning!"),!0}}return!1}validateSerialItem(){let e=this.findItemWithoutSerial();return e.length>0?f.IsEmpty(this.posData.Action.DeliveryEntityID)?!0:(this._toastr.warning(`Serial can not Empty in ${e[0]?.Variant?.Name}`,"Warning"),!1):!0}findItemWithoutSerial(){let e;return this.posData.CartItems.filter(i=>(e=!1,i.Variant&&i.Variant.TypeID===4&&(e=i?.Serial?i?.Serial?.length===0:!0),e))}validatePaymentLater(e){if(this.posData?.Invoice?.SurchargePcg!==0)return this._toastr.warning(oe.surcharge,"Payment Method Not Allowed"),!1;if(this.IsCreditSales()&&e.CreditSalesLock)return alert(oe.creditLock),!1;let t=f.IsEmpty(this.posData.Order.CustomerID);return this.modalFields.viewState==1&&t?(alert(oe.emptyCustomerCredit),!1):this.IsCreditSales()&&t?(alert(oe.emptyCustomerCredit),!1):!!this.debtLimitValidation()}debtLimitValidation(){let e=this._customerHttpService.Data,t=!1,i=e.DebtLimit,o=e.DebtCalculated,r=this.cashierCalculatorService.Data,c=o==0&&r>i;if(this.posData.Invoice.PaymentStateID==1){let u=i-o;r>u&&(t=!0)}else t=o+r>i;return i!==0&&(c||t)?(this._toastr.warning(oe.debtLimit,"Warning!"),!1):!0}validatePaymentSplit(){let e=this.firstPayment.PaidAmount,t=this.Payments[1]?this.Payments[1].PaidAmount:0,i=this.cashierCalculatorService.Data,o=[];e+this.modalFields.toleranceAmount>=i?(o=this.Payments.slice(0,1),this.modalFields.toleranceAmount!==0&&e<i&&(this.firstPayment.Amount=i),this.Payments=o):(t+e===i?o=this.Payments.slice(0,2):o=this.Payments,this.setPaymentNoteAndCode(this.Payments[1],this.paymentNoteCtrl2.value,this.paymentCodeCtrl2.value)),this.Payments=o}validatePay(){let e=this.firstPayment.Amount+(this.Payments[1]?this.Payments[1].Amount:0);if(this.AppConfigJSON.ModuleSell.PaymentDialog.MinusPaymentAllowed==!1&&e<0)return this._toastr.warning("You are not allowed to process this transaction because the total amount is less than zero","Warning!"),!1;if(this.modalFields.payNowEnabled&&this.paymentSplitDefaultVal>0&&this.firstPayment.Amount==0)return this._toastr.warning(oe.payNowOnly,me.Warning),!1;if(this.IsDepositPayment()&&this.userRole.CreditSalesLock)return this._toastr.warning(oe.creditLock,me.Warning),!1;if(!this.AppConfigJSON.ApplicationLoyalty.Rules.MixCashAndPoint&&this.posData.Order.PointUsed>0&&this.cashierCalculatorService.Data>0)return this._toastr.info(oe.partialLoyaltyPointUnable,me.Info),!1;let t=this.posData.Order.PointUsed*this.AppConfigJSON.ApplicationLoyalty.LoyaltyPoint.RedeemPointValue;if(this.cashierCalculatorService.GetPointOnlyAmount()>0&&this.cashierCalculatorService.GetPointOnlyAmount()>t){let o=f.StringFormat(oe.pointOnly,this.decimalPipe.transform(this.posData.PointOnlyAmount));return this._toastr.info(o,me.Info),!1}let i=this.cashierCalculatorService.Data+this.posData.Order.DiscountAmount-t;if(this.cashierCalculatorService.GetCashOnlyAmount()>0&&this.cashierCalculatorService.GetCashOnlyAmount()>i&&Math.abs(this.cashierCalculatorService.GetCashOnlyAmount()-i)>this.modalFields.toleranceAmount){let o=f.StringFormat(oe.cashOnly,this.decimalPipe.transform(this.posData.CashOnlyAmount));return this._toastr.info(o,me.Info),!1}return this.IsDepositPayment()&&f.IsEmpty(this.posData.Order.CustomerID)?(alert(oe.emptyCustomerDeposit),!1):this.posData.PrepaidPackageItem.length>0&&f.IsEmpty(this.posData.Order.CustomerID)?(this._toastr.info("Products with prepaid package type must use the customer",me.Info),!1):!(this.validatePaymentNoteAndCode(this.firstPayment,this.paymentCodeCtrl,this.paymentNoteCtrl)==!1||this.Payments[1]&&this.validatePaymentNoteAndCode(this.Payments[1],this.paymentCodeCtrl2,this.paymentNoteCtrl2)==!1)}validatePaymentNoteAndCode(e,t,i){if(e?.TypeID!=1&&e?.TypeID!=99&&e?.TypeID!=3){if(t.markAsDirty(),i.markAsDirty(),t.hasError("required"))return this._toastr.warning("Payment Code is required","Warning"),!1;if(i.hasError("required"))return this._toastr.warning("Payment Note is required","Warning"),!1;if(t.hasError("maxlength"))return this._toastr.warning("Payment Code must be 1 character","Warning"),!1}else return!0}onNowClick(){this.initPaymentAfterLater(),this.modalFields.viewState=0}onLaterClick(){this.modalFields.viewState=1}onSplitClick(){this.modalFields.viewState=3,this.initPaymentNoteAndCodeSplit(this.Payments[1])}IsCreditSales(){return this.modalFields.viewState!=1||this.IsDepositPayment()}initPaymentAfterLater(){this.modalFields.viewState==1&&this.posState==2&&f.IsEmpty(this.firstPayment.TypeID)&&(this.firstPayment.TypeID=1)}IsDepositPayment(){let e=!1,t=this.Payments.map(c=>c.PaidAmount).reduce((c,u)=>c+u),i=this.cashierCalculatorService.Data;return this.modalFields.toleranceAmount+t<i&&(e=!0),e}closeDialogAfterSubmit(){this.initializeDefaultValues(),this.dialogRef.close()}onCloseDialog(){this.modalFields.isCashMachineProvideChange()==!1?this.onCashMachineNotProvideChange():(this.initializeDefaultValues(),this.removeSurchargeOnCancel(),this.dialogRef.close())}removeSurchargeOnCancel(){this.posData.Invoice.SurchargePcg!==0&&this.Payments.some(t=>{let i=this.findPaymentMethodByID(t.MethodID);return i&&i.ExtraCharge>0})&&this.updateSurcharge(0)}updateCashPayment(e){let t=this.cashierCalculatorService.Data;this.paymentSplitDefaultVal=0,this.firstPayment.MethodID=this.defaultCashPaymentMethodID,this.firstPayment.Amount=t,this.firstPayment.PaidAmount=e,this.firstPayment.TypeID=1,this.posData.Invoice.SurchargePcg!==0&&(this.updateSurcharge(0),this.initCashFocus()),this.calculateSplitPayment(e)}calculateSplitPayment(e){let t=this.cashierCalculatorService.Data;e<t?(this.firstPayment.Amount=e,this.paymentSplitDefaultVal=t-e,this.filterSplitPaymentList(),this.changePaymentSplitValue()):(this.paymentSplitDefaultVal=0,this.changePaymentSplitValue())}changePaymentSplitValue(){this.Payments[1]&&(this.Payments[1].Amount=this.paymentSplitDefaultVal,this.Payments[1].PaidAmount=this.paymentSplitDefaultVal)}onPaymentMethodChanged(e){this.selectedPaymentMethod=e,this.updateSurcharge(e.ExtraCharge);let t=this.cashierCalculatorService.Data;this.firstPayment.Amount=t,this.firstPayment.PaidAmount=t,this.firstPayment.MethodID=e.ID,this.firstPayment.TypeID=e.TypeID,e.ExtraCharge>0&&this.paymentSplitDefaultVal>0?this._toastr.warning("Cannot apply Split Payment for Payment Method with Surcharge","Warning"):this.paymentSplitDefaultVal>0&&(this.firstPayment.Amount=t-this.paymentSplitDefaultVal,this.firstPayment.PaidAmount=t-this.paymentSplitDefaultVal),this.initPaymentNoteAndCode(this.firstPayment),this.filterSplitPaymentList()}filterSplitPaymentList(){this.modalFields.uniquePaymentMethodOnSplit?(this.splitPaymentMethodList=this.paymentMethodList.filter(e=>e.ExtraCharge==0).filter(e=>e.ID!==this.firstPayment.MethodID),this.resetSecondPaymentMethod()):this.splitPaymentMethodList=this.paymentMethodList.filter(e=>e.ExtraCharge==0)}resetSecondPaymentMethod(){let t=this.Payments[1]?.MethodID,i=this.firstPayment.MethodID;t==i&&delete this.Payments[1]}updateSurcharge(e){this.posData.Invoice.SurchargePcg=e,this.posData.Invoice.TempSurchargePcg=e,this._orderDataService.pushNewValue(this.posData)}onSplitPaymentMethodAssigned(e){e?(this.Payments[1]=this.Payments[1]?this.Payments[1]:new Ke,this.Payments[1].MethodID=e.ID,this.Payments[1].MethodName=e.Name,this.Payments[1].Amount=this.paymentSplitDefaultVal,this.Payments[1].PaidAmount=this.paymentSplitDefaultVal,this.Payments[1].TypeID=e.TypeID):(this.Payments[1].Amount=0,this.Payments[1].PaidAmount=0),this.initPaymentNoteAndCodeSplit(this.Payments[1])}initPaymentNoteAndCodeSplit(e){let t=this.getPaymentNoteAndCodeValidators(e);this.paymentCodeCtrl2?(this.paymentCodeCtrl2.setValidators(t.paymentCodeValidators),this.paymentNoteCtrl2.setValidators(t.paymentNoteValidators),this.paymentCodeCtrl2.updateValueAndValidity(),this.paymentNoteCtrl2.updateValueAndValidity()):(this.paymentCodeCtrl2=new et(e?.Code,t.paymentCodeValidators),this.paymentNoteCtrl2=new et(e?.Note,t.paymentNoteValidators))}onFirstPaymentSplitChange(e){let t=this.cashierCalculatorService.Data;this.firstPayment.Amount=t,this.firstPayment.PaidAmount=e,this.calculateSplitPayment(e)}initFirstPaymentSplitOptions(){this.firstPaymentSplitOptions=[...this.getTypePaymentList(2),...this.getTypePaymentList(4)]}isCardPayment(){return this.getTypePaymentList(2).findIndex(t=>t.ID==this.firstPayment.MethodID)>=0}isOtherPayment(e){return this.getTypePaymentList(e).findIndex(t=>t.ID==this.firstPayment.MethodID)>=0}getTypePaymentList(e){return this._paymentService.getPaymentList().filter(i=>i.TypeID==e)}payWithEmoney(e){let t=this.generateQrisRequest();this._paymentGatewayService.generateQR(t,e).pipe(Ie(this.destroy$)).subscribe({next:i=>{this.qrImage=i.Url,i.IsDemoKey?this.showModalConfirmDemoQris():this.showModalQRIS()},error:i=>{this.setToCashPayment(),this.onErrorGenerateQR(i)}})}generateQrisRequest(){let e=new an;return e.InvoiceNumber=this.posData.Order.Number,e.Amount=this.cashierCalculatorService.Data,e.RegisterID=this.posData.Order.RegisterID,e}setToCashPayment(){this.firstPayment.MethodID=this.defaultCashPaymentMethodID,this.firstPayment.TypeID=1}showModalConfirmDemoQris(){this.modalFields.viewState=4,this.modalFields.enableEmoneyConfirmModal(!0)}onContinueDemoQr(){this.modalFields.enableEmoneyConfirmModal(!1),this.modalFields.viewState=2,this.changeModalForEmoney(!0)}showModalQRIS(){this.modalFields.viewState=2,this.changeModalForEmoney(!0)}onErrorGenerateQR(e){e.status==400?this.validateEMoneyPayment():this._toastr.error(oe.failGenerateQR,me.Error)}validateEMoneyPayment(){this._paymentGatewayService.validateEMoneyPayment(this.AppConfigJSON).pipe(Ie(this.destroy$)).subscribe({next:e=>{this.dialogRef.close();let i=`IDR ${this.decimalPipe.transform(e.Final)} received. Please verify in customer mobile app!`;this._toastr.success(i," QR Settlement"),this._orderProcessorService.updatePosState(1,e)}})}changeModalForEmoney(e){this.modalFields.enableEMoneyModal(e),e||this._posHubService.BroadcastQRToCustomerDisplay("").subscribe()}dueDateChange(){let e=new Date(this.posData.Order.Date),t=this.modalFields.payLaterDueDate?this.modalFields.payLaterDueDate:new Date;e.setHours(0,0,0,0),this.modalFields.payLaterDueDays=f.differentInDays(e,t),this.posData.Invoice.Due=t}dueDayChange(){let e=new Date(this.posData.Order.Date);e.setDate(e.getDate()+this.modalFields.payLaterDueDays),e.setHours(0,0,0,0),this.modalFields.payLaterDueDate=e,this.posData.Invoice.Due=e}sanitize(e){return this.sanitizer.bypassSecurityTrustUrl(e)}onPrintQR(){window.print()}ngOnDestroy(){this.destroy$.next(!0),this.destroy$.complete()}static \u0275fac=function(t){return new(t||n)(P(te),P(B),P(ae),P(ln),P(lt),P(z),P(L),P(Ft),P(q),P(Jn),P(je),P(Vo),P(De),P(Re),P(he),P(cn),P(re),P(Bt),P(Ht))};static \u0275cmp=A({type:n,selectors:[["POS-modal-payment"]],standalone:!1,decls:15,vars:13,consts:[[3,"keydown.NumpedEnter","keydown.Enter","keydown.F2","onOk","onCancel","onClose","onBack","keydown.Escape","config"],[4,"ngIf"],["class","container w-100 h-100",4,"ngIf"],["class","text-center position-relative w-100",4,"ngIf"],[3,"totalAmount"],["class","btn btn-light-blue text-primary btn-lg fw-bold me-5 py-8",3,"click",4,"ngIf"],[1,"ms-3","fs-4"],[1,"container","w-100","h-100"],["class","row border-bottom",4,"ngIf"],["style","margin-bottom: 80px","class","py-5",4,"ngIf"],[1,"row","border-bottom"],["data-cy","tab-now",1,"btn","btn-link",3,"click","ngClass"],["class","btn btn-link","data-cy","tab-split",3,"ngClass","click",4,"ngIf"],["data-cy","tab-later","class","btn btn-link",3,"ngClass","click",4,"ngIf"],["data-cy","tab-split",1,"btn","btn-link",3,"click","ngClass"],[1,"fst-italic",2,"font-size","10px"],["data-cy","tab-later",1,"btn","btn-link",3,"click","ngClass"],[1,"row","py-5","border-bottom"],["class","row py-5 border-bottom",4,"ngIf"],["class","row py-5",4,"ngIf"],["class","row",3,"ngClass",4,"ngFor","ngForOf"],[1,"col-3","h5","pt-5"],[1,"fa-solid","fa-money-bill-wave"],[1,"col-9"],["class","row mb-5",4,"ngIf"],[1,"row"],[1,"col","pe-0","ps-4"],["id","cashInput","type","text","keyboardType","number","placeholder","Custom Cash Amount","data-cy","txt-amount","autoNum","",1,"form-control","form-control-lg","py-3",3,"ngModelChange","simpleKeyboard","ngModel"],["class","change",3,"ngClass",4,"ngIf"],[1,"row","mb-5"],["class","col-4 pe-0 ps-4",4,"ngFor","ngForOf"],[1,"col-4","pe-0","ps-4"],[1,"btn","btn-outline-info","px-1","py-6","w-100",3,"click","ngClass"],[1,"change",3,"ngClass"],[1,"fa-solid","fa-money-from-bracket"],[1,"row","d-flex","align-items-center"],[1,"col-auto","pb-3","ps-4","pe-0"],[1,"btn","btn-outline-info",3,"click"],[3,"hidden"],[1,"emoney-logo",3,"src"],[1,"fa-solid","fa-qrcode"],["class","col-auto pb-3 ps-4 pe-0",4,"ngFor","ngForOf"],[1,"row","py-5"],[1,"fa-credit-card","fas"],[1,"row",3,"ngClass"],["class","col-3 h5 pt-5",4,"ngIf"],["class","col-9",4,"ngIf"],["class","position-relative row",4,"ngIf"],[1,"btn","btn-outline-info",3,"click","ngClass"],[1,"position-relative","row"],[1,"paymentNote","col","row","g-0","pt-2","ms-4"],[1,"col-6"],["type","text","placeholder","Payment Note",1,"form-control","border-end-0","py-6",3,"formControl"],[1,"text-danger","d-inline"],["type","text","placeholder","Payment Code",1,"form-control","border-start-0","py-6","paymentCode",3,"formControl"],[1,"row","d-flex","align-items-center","g-0","later-payment","date-picker","mt-4"],[1,"col-3"],["appearance","fill","name","orderDate",1,"col-9",3,"dateChange","date","displayToggle"],[1,"row","d-flex","align-items-center","g-0","later-payment","mt-10"],["id","daysInput",1,"col-3"],["id","day","type","text","keyboardType","number","autoNum","",1,"col-9","form-control",2,"width","75%",3,"ngModelChange","simpleKeyboard","ngModel"],[1,"py-5",2,"margin-bottom","80px"],[1,"col-6","d-flex","align-items-center"],[1,"px-0"],[1,"me-2"],["bindLabel","Name","bindValue","ID","placeholder","Payment","appendTo","body","data-cy","Payment1",1,"ng-select-width","category-select",3,"change","items","ngModel","clearable"],[1,"col-6","col-6","d-flex","justify-content-start","align-items-center"],[1,"me-3"],["type","text","autoNum","",1,"form-control",3,"ngModelChange","ngModel"],[1,"row","mt-6"],[1,"col-12","d-flex","justify-content-start"],[1,"d-flex","align-items-center"],["bindLabel","Name","bindValue","ID","placeholder","Payment","appendTo","body","data-cy","Payment2",1,"ng-select-width","category-select",3,"change","items","ngModel"],[1,"d-flex","justify-content-start","align-items-center","ms-8"],[1,"fs-6"],[1,"position-relative","row","mt-6","px-2"],[1,"text-center","position-relative","w-100"],[1,"d-none","d-print-flex","flex-column","justify-content-center","title-pay","position-relative","mb-3"],[1,"fw-bold","fs-3",3,"ngClass"],[1,"row","d-flex","justify-content-center","me-5","fs-6"],[1,"col-3","text-end","pe-3","ms-13"],[1,"me-1"],[1,"col-6","text-start","ps-0"],[1,"fw-normal"],["class","position-relative d-print-none","style","top: 8px",4,"ngIf"],[1,"d-flex","justify-content-center","qris-container"],["alt","Gopay QR",1,"d-block","border-0",3,"src","ngClass"],[1,"position-relative",3,"ngStyle"],["src","https://cdn.dealpos.xyz/web-image/gpn.png","alt",""],[1,"position-relative","d-print-none",2,"top","8px"],[3,"isCancel"],[3,"onTransactionComplete","totalAmount"],[1,"btn","btn-light-blue","text-primary","btn-lg","fw-bold","me-5","py-8"],[1,"btn","btn-light-blue","text-primary","btn-lg","fw-bold","me-5","py-8","px-12"],[1,"btn","btn-light-blue","text-primary","btn-lg","fw-bold","me-5","py-8",3,"click"],[1,"btn","btn-light-blue","text-primary","btn-lg","fw-bold","me-5","py-8","px-12",3,"click","keyup.F2"],[1,"fa-solid","fa-print","me-2"]],template:function(t,i){t&1&&(a(0,"modal-material",0),S("keydown.NumpedEnter",function(){return i.onOk()})("keydown.Enter",function(){return i.onOk()})("keydown.F2",function(){return i.onOk()})("onOk",function(){return i.onOk()})("onCancel",function(){return i.onCloseDialog()})("onClose",function(){return i.onCloseDialog()})("onBack",function(){return i.onBack()})("keydown.Escape",function(){return i.onCloseDialog()}),$(1,Ss,4,2,"header",1),a(2,"content"),$(3,ol,5,4,"div",2)(4,sl,27,15,"div",3),h(5,ll,1,0,"app-confirm-demo-qris"),$(6,cl,2,1,"ng-container",1),h(7,ml,1,1,"cash-machine-payment",4),s(),a(8,"footer"),h(9,ul,2,1),$(10,gl,3,0,"a",5)(11,fl,2,0,"a",5)(12,hl,2,1,"a",5)(13,Cl,2,0,"a",5)(14,vl,2,0,"a",5),s()()),t&2&&(p("config",i.modalFields.modalConfig),l(),p("ngIf",!i.modalFields.isQrisConfirm&&!i.modalFields.isCancelEcrTransaction),l(2),p("ngIf",!i.modalFields.isStateQR&&!i.modalFields.isQrisConfirm&&!i.modalFields.isWaitingPaymentEcr&&!i.modalFields.isCashMachine),l(),p("ngIf",i.modalFields.isStateQR),l(),C(i.modalFields.isQrisConfirm?5:-1),l(),p("ngIf",i.modalFields.isWaitingPaymentEcr),l(),C(i.modalFields.isCashMachine?7:-1),l(2),C(i.modalFields.isCashMachine?9:-1),l(),p("ngIf",i.modalFields.isStateQR),l(),p("ngIf",i.modalFields.isStateQR),l(),p("ngIf",i.modalFields.isWaitingPaymentEcr),l(),p("ngIf",i.modalFields.isQrisConfirm),l(),p("ngIf",i.modalFields.isQrisConfirm))},dependencies:[Be,Un,Wn,Gn,Te,Pe,Ee,bt,ne,St,Ot,Pi,Fo,mn,dn,pn,q,bi],styles:['.text-warning[_ngcontent-%COMP%]{color:var(--bs-warning)!important}.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}.btn-light-danger[_ngcontent-%COMP%]{color:#212529;background-color:#f8d7da!important;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:hover{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5}.btn-light-danger[_ngcontent-%COMP%]:focus, .btn-light-danger.focus[_ngcontent-%COMP%]{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5;box-shadow:0 0 0 .2rem #dc354540}.btn-light-danger.disabled[_ngcontent-%COMP%], .btn-light-danger[_ngcontent-%COMP%]:disabled{color:#212529;background-color:#f8d7da;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]{color:#212529;background-color:#f1aeb5;border-color:#ea868f}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active:focus, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active:focus, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]:focus{box-shadow:0 0 0 .2rem #dc354540}.margin-note[_ngcontent-%COMP%]{margin-left:-7px!important}.quickKeyTabs[_ngcontent-%COMP%]{margin-right:-15px;margin-left:-7px}.change[_ngcontent-%COMP%]{position:absolute;top:119px;height:40px;background:#89b03e;color:#fff;right:17px;padding:0 10px;line-height:40px;font-size:16px}.change[_ngcontent-%COMP%]:before{content:"\\a";border-style:solid;border-width:40px 24px 0 0;border-color:transparent #89b03e transparent transparent;position:absolute;left:-24px}.change.danger[_ngcontent-%COMP%]{background:#c9302c}.change.danger[_ngcontent-%COMP%]:before{border-color:transparent #c9302c transparent transparent}.paymentNote[_ngcontent-%COMP%]:before{z-index:10;content:"";position:absolute;top:4px;left:calc(50% - 10px);height:43px;width:10px;background-color:inherit;border-right:1px solid lightgray;-webkit-transform:skewX(-10deg);-moz-transform:skewX(-10deg);-ms-transform:skewX(-10deg);transform:skew(-10deg)}.height-input[_ngcontent-%COMP%]{height:37px}.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}.later-payment[_ngcontent-%COMP%] strong{font-size:20px}.later-payment[_ngcontent-%COMP%] input{font-size:20px;padding:20px 10px!important}.later-payment[_ngcontent-%COMP%] .mat-mdc-form-field{width:100%;font-size:20px;border:1px solid #c8d3df;padding-left:10px}.later-payment[_ngcontent-%COMP%] .mat-mdc-form-field .mat-mdc-icon-button, .later-payment[_ngcontent-%COMP%] .mat-mdc-form-field .mat-mdc-button-persistent-ripple, .later-payment[_ngcontent-%COMP%] .mat-mdc-form-field .mat-mdc-form-field-icon-suffix{outline:none!important} .later-payment.date-picker .mat-mdc-form-field{font-size:4px}.phone[_ngcontent-%COMP%] div[_ngcontent-%COMP%]{height:50px;width:50px;padding-top:11px;background-color:#f5f5f5;border:1px solid gray!important}.phone[_ngcontent-%COMP%] input[_ngcontent-%COMP%]{padding-left:65px!important;border:1px solid gray!important;font-size:25px;height:50px}.phone[_ngcontent-%COMP%] .form-control[_ngcontent-%COMP%]:focus{border-color:#8bb8df!important}.qris[_ngcontent-%COMP%] div[_ngcontent-%COMP%]{font-size:.75rem}.ng-select.ng-select-width[_ngcontent-%COMP%] .ng-select-container{width:160px;max-width:160px}.qrDemo[_ngcontent-%COMP%]{position:relative;top:-10px}.qrDemo[_ngcontent-%COMP%] > p[_ngcontent-%COMP%]{margin-bottom:0}input[type=text][_ngcontent-%COMP%]:disabled{background:#e5e5e5} ng-dropdown-panel.category-select{z-index:1100}.row[_ngcontent-%COMP%] > div.tab-button[_ngcontent-%COMP%]{padding-left:0}.qris-barcode[_ngcontent-%COMP%]{height:300px;line-height:50px}@media print{.qris-barcode[_ngcontent-%COMP%]{height:200px;margin-bottom:20px}.title-pay[_ngcontent-%COMP%]{font-size:10px;font-weight:400;top:10px}.title-pay[_ngcontent-%COMP%] div.ms-13[_ngcontent-%COMP%]{margin-left:1.7rem}.qris-container[_ngcontent-%COMP%]{margin-bottom:20px}}.emoney-logo[_ngcontent-%COMP%]{max-width:180px;max-height:40px;height:30px}']})};var _l=n=>({"bg-light":n});function yl(n,e){if(n&1){let t=E();a(0,"button",10),S("click",function(){v(t);let o=d(2).$implicit,r=d(2);return _(r.onApplyPromotion(o))}),m(1," APPLY "),s()}if(n&2){let t=d(4);p("disabled",t.selectedPromotion)}}function bl(n,e){if(n&1){let t=E();a(0,"button",11),S("click",function(){v(t);let o=d(2).$implicit,r=d(2);return _(r.onRemovePromotion(o))}),m(1," REMOVE "),s()}}function Sl(n,e){if(n&1&&(h(0,yl,2,1,"button",8),h(1,bl,2,0,"button",9)),n&2){let t=d().$implicit,i=d(2);C((i.selectedPromotion==null?null:i.selectedPromotion.ID)!=t.ID?0:-1),l(),C((i.selectedPromotion==null?null:i.selectedPromotion.ID)==t.ID?1:-1)}}function Pl(n,e){n&1&&(a(0,"p",7),m(1,"Not Eligible"),s())}function Ol(n,e){if(n&1&&(a(0,"div",3)(1,"div",4)(2,"h5"),m(3),s(),a(4,"p",5),m(5),s()(),a(6,"div",6),h(7,Sl,2,2)(8,Pl,2,0,"p",7),s()()),n&2){let t=e.$implicit;p("ngClass",Q(4,_l,!t.Eligible)),l(3),O(t.Name),l(2),O(t.Description),l(2),C(t.Eligible?7:8)}}function Dl(n,e){if(n&1&&(K(0,Ol,9,6,"div",3,ve),y(2,"sortBy")),n&2){let t=d();Z(_t(2,0,t.promotions,"desc","Eligible"))}}function Ml(n,e){n&1&&(a(0,"div",2)(1,"p",12)(2,"span"),m(3,"There is no active promotion right now"),s()()())}var gn=class n{constructor(e,t,i,o){this._dialogRef=e;this._promotionEventService=t;this._outletRegisterService=i;this._salesOrderService=o;this.destroy$=new Me}modalConfig=new ie;promotions=[];destroy$;promotionType=zt;selectedPromotion;ngOnInit(){this.subscribePromotionService(),this.initModalConfig()}ngOnDestroy(){this.destroy$.next(!0),this.destroy$.complete()}subscribePromotionService(){this._promotionEventService.Data$.pipe(Ie(this.destroy$)).subscribe(e=>{this.promotions=e,this.checkValidSelectedPromotion()})}checkValidSelectedPromotion(){this.selectedPromotion=this._promotionEventService.selectedPromotion,this.selectedPromotion&&this.promotions.findIndex(t=>t.ID==this.selectedPromotion.ID&&t.Eligible)===-1&&(this.selectedPromotion=null,this._promotionEventService.selectedPromotion=null)}initModalConfig(){this.modalConfig.title="Promotions",this.modalConfig.customWidth="500px",this.modalConfig.bodyScrollable=!0,this.modalConfig.hideCancel=!0,this.modalConfig.okText='<i class="fas fa-rotate fs-6 me-1"></i>Refresh'}onApplyPromotion(e){this._promotionEventService.applyPromotion(e),e.TypeID!=4&&this.close()}onRemovePromotion(e){this._promotionEventService.removePromotion(),this.selectedPromotion=null}onRefreshPromotion(){let e=this._outletRegisterService.Data.RegisterID;this._promotionEventService.getPromotions(e).subscribe(t=>{this._promotionEventService.loadPromotions(t),this._salesOrderService.Data.CartItems=[],this._salesOrderService.pushNewValue()})}close(){this._dialogRef.close()}static \u0275fac=function(t){return new(t||n)(P(te),P(Ae),P(re),P(B))};static \u0275cmp=A({type:n,selectors:[["POS-modal-promotion"]],standalone:!1,decls:5,vars:2,consts:[[3,"onCancel","onOk","onClose","config"],[1,"container"],[1,"d-flex","align-items-center","justify-content-center"],[1,"row","border","mt-3","py-2","justify-content-between",3,"ngClass"],[1,"col","mt-3"],[1,"description"],[1,"col-auto","my-auto"],[1,"text-danger","my-auto"],[1,"btn","btn-success","my-auto",3,"disabled"],[1,"btn","btn-danger","my-auto"],[1,"btn","btn-success","my-auto",3,"click","disabled"],[1,"btn","btn-danger","my-auto",3,"click"],[1,"mb-0","fs-3","text-body-secondary"]],template:function(t,i){t&1&&(a(0,"modal-material",0),S("onCancel",function(){return i.close()})("onOk",function(){return i.onRefreshPromotion()})("onClose",function(){return i.close()}),a(1,"content")(2,"div",1),h(3,Dl,3,4)(4,Ml,4,0,"div",2),s()()()),t&2&&(p("config",i.modalConfig),l(3),C(i.promotions.length>0?3:4))},dependencies:[Be,ne,Dt],styles:[".description[_ngcontent-%COMP%]{word-wrap:break-word}"]})};var xl=["firstNameAutoFocus"],Il=["customerForm"],wn=(n,e)=>({selected:n,danger:e}),ct=n=>({"is-invalid":n}),jt=n=>({selected:n}),Tl=n=>({"invalid-feedback":n});function El(n,e){n&1&&b(0,"i",14)}function wl(n,e){n&1&&b(0,"i",14)}function Rl(n,e){n&1&&b(0,"i",14)}function Nl(n,e){if(n&1&&b(0,"option",22),n&2){let t=e.$implicit;p("value",t.Name)}}function Al(n,e){if(n&1&&(a(0,"div",25),m(1," Name is mandatory "),s()),n&2){d();let t=ue(30);p("ngClass",Q(1,Tl,t.touched&&t.invalid))}}function kl(n,e){n&1&&(a(0,"div",44),m(1," Mobile Phone is mandatory "),s())}function Vl(n,e){if(n&1&&(a(0,"div",44),m(1),s()),n&2){d(2);let t=ue(42);l(),M(" ",t.errors==null||t.errors.minLength==null?null:t.errors.minLength.message," ")}}function Fl(n,e){if(n&1&&(h(0,kl,2,0,"div",44),h(1,Vl,2,1,"div",44)),n&2){d();let t=ue(42);C(t.getError("required")&&!t.getError("minLength")?0:-1),l(),C(t.getError("minLength")?1:-1)}}function Ll(n,e){n&1&&(a(0,"div",44),m(1," Email must be a valid email address "),s())}function Bl(n,e){n&1&&(a(0,"div",44),m(1,"Email is mandatory"),s())}function Hl(n,e){if(n&1&&(h(0,Ll,2,0,"div",44),h(1,Bl,2,0,"div",44)),n&2){d();let t=ue(49);C(t.errors!=null&&t.errors.email?0:-1),l(),C(t.errors!=null&&t.errors.required?1:-1)}}function jl(n,e){n&1&&(a(0,"div",44),m(1,"Birthdate is mandatory"),s())}function Ql(n,e){if(n&1&&h(0,jl,2,0,"div",44),n&2){d();let t=ue(56);C(t.errors!=null&&t.errors.required?0:-1)}}function Ul(n,e){if(n&1&&b(0,"i",43),n&2){let t=d();p("matTooltip",t.estimatedCodeMessage)}}function Wl(n,e){n&1&&(a(0,"div",44),m(1," Customer code is mandatory. "),s())}function Gl(n,e){n&1&&(a(0,"div",44),m(1,"Address is mandatory."),s())}function ql(n,e){if(n&1&&(a(0,"div",44),m(1),s()),n&2){d();let t=ue(93);l(),M(" ",t.errors==null||t.errors.minLength==null?null:t.errors.minLength.message," ")}}function $l(n,e){n&1&&(a(0,"div",66),m(1," Sign Up Outlet is mandatory. "),s())}var fn=class n{constructor(e,t,i,o,r,c){this._dialogRef=e;this._posService=t;this._orderDataService=i;this._CustomerHttpService=o;this._registerService=r;this.data=c;this.initCustomer(),this.initRequiredConfig()}estimatedCodeMessage="Customer code below is just an estimation, it could change in the final result";fieldRequiredConfig={Mobile:!1,Email:!1,Birthdate:!1,Code:!1,Address:!1,SignUpOutlet:!1};firstNameRef;customerForm;modalConfig=new ie;customer;get options(){return this._posService.Data.CustomerOptions}get config(){return this._posService.Data.AppConfigJSON}customerData;tabState="general";guidEmpty=f.GuidEmpty;outlets=R([]);get isGeneralFormInvalid(){let e=this.customerForm?.controls?.generalForm;return this.checkDirtyForm(e)}get isDetailFormInvalid(){let e=this.customerForm?.controls?.detailForm;return this.checkDirtyForm(e)}get isIdFormInvalid(){let e=this.customerForm?.controls?.idForm;return this.checkDirtyForm(e)}checkDirtyForm(e){return e?Object.keys(e.controls).every(i=>e?.controls?.[i].touched||e?.controls?.[i].dirty)&&e.invalid:!1}isSaved=R(!1);ngOnInit(){this.modalConfig.customWidth="650px",this.modalConfig.title="New Customer",this.modalConfig.bodyScrollable=!0,this.modalConfig.hideScrollbar=!0}initRequiredConfig(){this.config?.ModuleContact?.Advance.RequiredFields?.forEach(t=>{this.fieldRequiredConfig[t]===!1&&(this.fieldRequiredConfig[t]=!0)})}initCustomer(){let e=this._posService.Data.AppConfigJSON;this.outlets.set(this._posService.Data?.Entities);let t=e.ModuleContact?.DefaultContactGroup?.ContactGroup;this.customer=new Lo,f.IsNotEmpty(this.data)&&(this.customer.FirstName=this.data.name),f.IsNotEmpty(t)&&(this.customer.Group=t),this.initCustomerCode(e?.ModuleContact?.CodeGenerator?.AutoGenerateEnabled),this.initCustomerSignUpOutlet()}initCustomerSignUpOutlet(){let e=this._registerService.Data;this.customer.CreatorEntityID=e?.EntityID}initCustomerCode(e=!1){e?this._CustomerHttpService.getCustomerSuggestionCode().pipe(ee()).subscribe(t=>{this.customer.Code=t}):this.estimatedCodeMessage=""}ngAfterViewInit(){this.setAutoFocus()}setAutoFocus(){this.firstNameRef.nativeElement.focus()}onKeyUpFirstName(){this.customer.FirstName?this.modalConfig.validated=!0:this.modalConfig.validated=!1}chooiceDetail(e){this.tabState=e}onOk(e){if(e.form.markAllAsTouched(),!e.form.invalid&&this.isSaved()==!1){this.isSaved.set(!0);let t=this._orderDataService.Data;this.customer.Name=this.getCustomerName(),this._CustomerHttpService.addCustomer(this.customer,this.options.DebtLimit).then(i=>{t.ContactName=this.customer.Name,this._orderDataService.pushNewValue(t),this.getCustomerData(i.ID),this.isSaved.set(!1)}).catch(i=>{this.isSaved.set(!1)})}}getCustomerData(e){this._orderDataService.updateCustomerID(e).then(t=>{this.customerData=t,this.close("ok")}).catch(t=>{this.customerData=new Mt,this.close("ok")})}getCustomerName(){let e="";return e+=" "+(this.customer.FirstName?this.customer.FirstName:""),e+=" "+(this.customer.LastName?this.customer.LastName:""),e=e.trim(),e}close(e){e==="ok"?this._dialogRef.close(this.customerData):this._dialogRef.close(null)}isNotEmpty(e){return f.IsNotEmpty(e)||e==0}static \u0275fac=function(t){return new(t||n)(P(te),P(z),P(B),P(Re),P(re),P(fe))};static \u0275cmp=A({type:n,selectors:[["POS-modal-customer"]],viewQuery:function(t,i){if(t&1&&(Qt(xl,5),Qt(Il,5)),t&2){let o;Ut(o=Wt())&&(i.firstNameRef=o.first),Ut(o=Wt())&&(i.customerForm=o.first)}},standalone:!1,decls:119,vars:100,consts:[["customerForm","ngForm"],["firstNameAutoFocus","","FirstName","ngModel"],["phoneNumber","ngModel"],["Email","ngModel"],["birthdateCtrl","ngModel"],["customerCode","ngModel"],["address","ngModel"],["nationalId","ngModel"],["signUpOutletCtrl","ngModel"],[3,"onOk","onCancel","onClose","config"],[1,"container",2,"height","270px"],["name","form"],[1,"row","align-items-center","border-bottom"],[1,"btn","btn-link",3,"click","ngClass"],[1,"fa-regular","fa-circle-exclamation","text-danger"],[1,"mt-6"],["ngModelGroup","generalForm",1,"row",3,"hidden"],[1,"col-2","mt-3"],[1,"form-floating-outline"],["list","cust-title","id","Title","name","Title","placeholder","Title",1,"form-control",3,"ngModelChange","ngModel"],["for","Title"],["id","cust-title"],[3,"value"],[1,"col-5","mt-3"],["type","text","data-cy","FirstName","id","FirstName","name","FirstName","placeholder","First Name",1,"form-control",3,"keyup","ngModelChange","ngClass","ngModel","required"],[3,"ngClass"],["for","FirstName"],["type","text","data-cy","LastName","id","LastName","name","LastName","placeholder","Last Name",1,"form-control",3,"ngModelChange","ngModel"],["for","LastName"],[1,"col-6","mt-4"],["type","text","numericInputOnly","phone","id","Phone","name","Phone","placeholder","Mobile Phone",1,"form-control",3,"ngModelChange","ngClass","ngModel","required"],["for","Phone"],["type","email","id","email","name","Email","placeholder","Email","email","",1,"form-control",3,"ngModelChange","ngClass","ngModel","required"],["for","email"],["placeholder","Birthdate","appearance","outline","name","orderDate",3,"ngModelChange","ngModel","required","ngClass"],[1,"col-md-6","mt-4"],[1,"form-floating-outline","flexRow",3,"ngClass"],["id","customerGender","bindLabel","Value","bindValue","Key","name","customerGender","appendTo","body",1,"productform","tall",3,"ngModelChange","ngModel","items"],["for","customerGender",1,"ng-select"],["ngModelGroup","detailForm",1,"row","mt-2",3,"hidden"],[1,"col-md-4","mt-4"],[1,"form-floating-outline","position-relative"],["type","text","name","code","id","code","placeholder","Customer Code",1,"form-control",2,"padding-right","30px !important",3,"ngModelChange","ngClass","ngModel","required"],["matTooltipPosition","above",1,"fa-solid","fa-circle-info","text-secondary","position-absolute",2,"top","21px","right","9px","font-size","16px",3,"matTooltip"],[1,"invalid-feedback"],["for","code"],[1,"col-4","mt-4"],["id","customerGroup","bindLabel","Name","bindValue","ID","name","customerGroup","appendTo","body",1,"productform","tall",3,"ngModelChange","ngModel","items"],["for","customerGroup",1,"ng-select"],["id","city","bindLabel","Name","bindValue","ID","name","city","appendTo","body",1,"productform","tall",3,"ngModelChange","ngModel","items"],["for","city",1,"ng-select"],[1,"col-md-12","mt-4"],["id","address","name","address","placeholder","Address",1,"form-control",3,"ngModelChange","rows","ngClass","ngModel","required"],["for","address"],["ngModelGroup","idForm",1,"row","mt-2",3,"hidden"],[1,"col-md-6","mt-3"],["type","text","id","Identification","name","Identification","placeholder","NationalID","numericInputOnly","nationalId",1,"form-control",3,"ngModelChange","ngModel","ngClass"],["for","Identification"],["type","text","id","TaxId","name","TaxId","placeholder","TaxID",1,"form-control",3,"ngModelChange","ngModel"],["for","TaxId"],["id","nationality","bindLabel","Name","bindValue","ID","name","nationality","appendTo","body",1,"productform","tall",3,"ngModelChange","ngModel","items"],["for","nationality",1,"ng-select"],["id","customerRace","bindLabel","Name","bindValue","ID","name","customerRace","appendTo","body",1,"productform","tall",3,"ngModelChange","ngModel","items"],["for","customerRace",1,"ng-select"],["id","signUpOutlet","bindLabel","Name","bindValue","ID","name","signUpOutlet","appendTo","body",1,"productform","tall",3,"ngModelChange","ngModel","items","required","ngClass"],["for","signUpOutlet",1,"ng-select"],[1,"invalid-feedback","fst-italic"]],template:function(t,i){if(t&1){let o=E();a(0,"modal-material",9),S("onOk",function(){v(o);let c=ue(4);return _(i.onOk(c))})("onCancel",function(){return v(o),_(i.close("cancel"))})("onClose",function(){return v(o),_(i.close("close"))}),a(1,"content")(2,"div",10)(3,"form",11,0)(5,"div",12)(6,"div")(7,"a",13),S("click",function(){return v(o),_(i.chooiceDetail("general"))}),m(8," General "),h(9,El,1,0,"i",14),s(),a(10,"a",13),S("click",function(){return v(o),_(i.chooiceDetail("detail"))}),m(11," Detail "),h(12,wl,1,0,"i",14),s(),a(13,"a",13),S("click",function(){return v(o),_(i.chooiceDetail("id"))}),m(14," ID "),h(15,Rl,1,0,"i",14),s()()(),a(16,"div",15)(17,"div",16)(18,"div",17)(19,"div",18)(20,"input",19),j("ngModelChange",function(c){return v(o),V(i.customer.Title,c)||(i.customer.Title=c),_(c)}),s(),a(21,"label",20),m(22,"Title"),s(),a(23,"datalist",21),K(24,Nl,1,1,"option",22,ve),s()()(),a(26,"div",23)(27,"div",18)(28,"input",24,1),S("keyup",function(){return v(o),_(i.onKeyUpFirstName())}),j("ngModelChange",function(c){return v(o),V(i.customer.FirstName,c)||(i.customer.FirstName=c),_(c)}),s(),h(31,Al,2,3,"div",25),a(32,"label",26),m(33,"First Name"),s()()(),a(34,"div",23)(35,"div",18)(36,"input",27),j("ngModelChange",function(c){return v(o),V(i.customer.LastName,c)||(i.customer.LastName=c),_(c)}),s(),a(37,"label",28),m(38,"Last Name"),s()()(),a(39,"div",29)(40,"div",18)(41,"input",30,2),j("ngModelChange",function(c){return v(o),V(i.customer.Mobile,c)||(i.customer.Mobile=c),_(c)}),s(),h(43,Fl,2,2),a(44,"label",31),m(45,"Mobile"),s()()(),a(46,"div",29)(47,"div",18)(48,"input",32,3),j("ngModelChange",function(c){return v(o),V(i.customer.Email,c)||(i.customer.Email=c),_(c)}),s(),a(50,"label",33),m(51,"Email"),s(),h(52,Hl,2,2),s()(),a(53,"div",29)(54,"div",18)(55,"datepicker",34,4),j("ngModelChange",function(c){return v(o),V(i.customer.Birthdate,c)||(i.customer.Birthdate=c),_(c)}),s(),h(57,Ql,1,1),s()(),a(58,"div",35)(59,"div",36)(60,"ng-select",37),j("ngModelChange",function(c){return v(o),V(i.customer.Gender,c)||(i.customer.Gender=c),_(c)}),s(),a(61,"label",38),m(62,"Gender"),s()()()(),a(63,"div",39)(64,"div",40)(65,"div",41)(66,"input",42,5),j("ngModelChange",function(c){return v(o),V(i.customer.Code,c)||(i.customer.Code=c),_(c)}),s(),h(68,Ul,1,1,"i",43),h(69,Wl,2,0,"div",44),a(70,"label",45),m(71,"Customer Code"),s()()(),a(72,"div",46)(73,"div",36)(74,"ng-select",47),j("ngModelChange",function(c){return v(o),V(i.customer.Group,c)||(i.customer.Group=c),_(c)}),s(),a(75,"label",48),m(76,"Group"),s()()(),a(77,"div",40)(78,"div",36)(79,"ng-select",49),j("ngModelChange",function(c){return v(o),V(i.customer.City,c)||(i.customer.City=c),_(c)}),s(),a(80,"label",50),m(81,"City"),s()()(),a(82,"div",51)(83,"div",18)(84,"textarea",52,6),j("ngModelChange",function(c){return v(o),V(i.customer.Address,c)||(i.customer.Address=c),_(c)}),s(),a(86,"label",53),m(87,"Address"),s(),h(88,Gl,2,0,"div",44),s()()(),a(89,"div",54)(90,"div",55)(91,"div",18)(92,"input",56,7),j("ngModelChange",function(c){return v(o),V(i.customer.NationalIDNumber,c)||(i.customer.NationalIDNumber=c),_(c)}),s(),h(94,ql,2,1,"div",44),a(95,"label",57),m(96,"National ID"),s()()(),a(97,"div",55)(98,"div",18)(99,"input",58),j("ngModelChange",function(c){return v(o),V(i.customer.TaxIDNumber,c)||(i.customer.TaxIDNumber=c),_(c)}),s(),a(100,"label",59),m(101,"Tax ID"),s()()(),a(102,"div",35)(103,"div",36)(104,"ng-select",60),j("ngModelChange",function(c){return v(o),V(i.customer.NationalityID,c)||(i.customer.NationalityID=c),_(c)}),s(),a(105,"label",61),m(106,"Nationality"),s()()(),a(107,"div",29)(108,"div",36)(109,"ng-select",62),j("ngModelChange",function(c){return v(o),V(i.customer.RaceID,c)||(i.customer.RaceID=c),_(c)}),s(),a(110,"label",63),m(111,"Customer Racesas"),s()()(),a(112,"div",35)(113,"div",36)(114,"ng-select",64,8),j("ngModelChange",function(c){return v(o),V(i.customer.CreatorEntityID,c)||(i.customer.CreatorEntityID=c),_(c)}),s(),a(116,"label",65),m(117,"Sign Up Outlet"),s(),h(118,$l,2,0,"div",66),s()()()()()()()()}if(t&2){let o=ue(30),r=ue(42),c=ue(49),u=ue(56),D=ue(67),F=ue(85),W=ue(93),ye=ue(115);p("config",i.modalConfig),l(7),p("ngClass",Ue(63,wn,i.tabState=="general",i.tabState!="general"&&i.isGeneralFormInvalid)),l(2),C(i.tabState!="general"&&i.isGeneralFormInvalid?9:-1),l(),p("ngClass",Ue(66,wn,i.tabState=="detail",i.tabState!="detail"&&i.isDetailFormInvalid)),l(2),C(i.tabState!="detail"&&i.isDetailFormInvalid?12:-1),l(),p("ngClass",Ue(69,wn,i.tabState=="id",i.tabState!="id"&&i.isIdFormInvalid)),l(2),C(i.tabState!="id"&&i.isIdFormInvalid?15:-1),l(2),p("hidden",i.tabState!="general"),l(3),H("ngModel",i.customer.Title),l(4),Z(i.options==null?null:i.options.Titles),l(4),p("ngClass",Q(72,ct,o.touched&&o.invalid)),H("ngModel",i.customer.FirstName),p("required",!0),l(3),C(o.touched&&o.invalid?31:-1),l(5),H("ngModel",i.customer.LastName),l(5),p("ngClass",Q(74,ct,r.invalid&&(r.dirty||r.touched))),H("ngModel",i.customer.Mobile),p("required",i.fieldRequiredConfig.Mobile),l(2),C(r.invalid&&(r.dirty||r.touched)?43:-1),l(5),p("ngClass",Q(76,ct,c.invalid&&(c.dirty||c.touched))),H("ngModel",i.customer.Email),p("required",i.fieldRequiredConfig.Email),l(4),C(c.invalid&&(c.dirty||c.touched)?52:-1),l(3),H("ngModel",i.customer.Birthdate),p("required",i.fieldRequiredConfig.Birthdate)("ngClass",Q(78,ct,u.invalid&&(u.dirty||u.touched))),l(2),C(u.invalid&&(u.dirty||u.touched)?57:-1),l(2),p("ngClass",Q(80,jt,i.isNotEmpty(i.customer.Gender))),l(),H("ngModel",i.customer.Gender),p("items",i.options==null?null:i.options.Genders),l(3),p("hidden",i.tabState!="detail"),l(3),p("ngClass",Q(82,ct,D.invalid&&(D.dirty||D.touched))),H("ngModel",i.customer.Code),p("required",i.fieldRequiredConfig.Code),l(2),C(i.estimatedCodeMessage?68:-1),l(),C(D.invalid&&(D.dirty||D.touched)?69:-1),l(4),p("ngClass",Q(84,jt,i.isNotEmpty(i.customer.Group))),l(),H("ngModel",i.customer.Group),p("items",i.options==null?null:i.options.Groups),l(4),p("ngClass",Q(86,jt,i.isNotEmpty(i.customer.City))),l(),H("ngModel",i.customer.City),p("items",i.options==null?null:i.options.Cities),l(5),p("rows",6)("ngClass",Q(88,ct,F.invalid&&(F.dirty||F.touched))),H("ngModel",i.customer.Address),p("required",i.fieldRequiredConfig.Address),l(4),C(F.invalid&&(F.dirty||F.touched)?88:-1),l(),p("hidden",i.tabState!="id"),l(3),H("ngModel",i.customer.NationalIDNumber),p("ngClass",Q(90,ct,W.invalid&&(W.dirty||W.touched))),l(2),C(W.getError("minLength")?94:-1),l(5),H("ngModel",i.customer.TaxIDNumber),l(4),p("ngClass",Q(92,jt,i.isNotEmpty(i.customer.NationalityID))),l(),H("ngModel",i.customer.NationalityID),p("items",i.options==null?null:i.options.Nationalities),l(4),p("ngClass",Q(94,jt,i.isNotEmpty(i.customer.RaceID))),l(),H("ngModel",i.customer.RaceID),p("items",i.options==null?null:i.options.Races),l(4),p("ngClass",Q(96,jt,i.isNotEmpty(i.customer.CreatorEntityID))),l(),H("ngModel",i.customer.CreatorEntityID),p("items",i.outlets())("required",i.fieldRequiredConfig.SignUpOutlet)("ngClass",Q(98,ct,ye.invalid&&(ye.dirty||ye.touched))),l(4),C(ye.invalid&&(ye.dirty||ye.touched)?118:-1)}},dependencies:[Be,io,no,oo,Te,Pe,Xn,ro,ao,Ee,to,eo,ne,St,yi,Pi,Bo],styles:[".text-warning[_ngcontent-%COMP%]{color:var(--bs-warning)!important}.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}.btn-light-danger[_ngcontent-%COMP%]{color:#212529;background-color:#f8d7da!important;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:hover{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5}.btn-light-danger[_ngcontent-%COMP%]:focus, .btn-light-danger.focus[_ngcontent-%COMP%]{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5;box-shadow:0 0 0 .2rem #dc354540}.btn-light-danger.disabled[_ngcontent-%COMP%], .btn-light-danger[_ngcontent-%COMP%]:disabled{color:#212529;background-color:#f8d7da;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]{color:#212529;background-color:#f1aeb5;border-color:#ea868f}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active:focus, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active:focus, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]:focus{box-shadow:0 0 0 .2rem #dc354540}.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:2px solid #07a519}.btn-link.danger[_ngcontent-%COMP%]{color:#c9302c}.form-floating-outline[_ngcontent-%COMP%]{margin-bottom:.2rem!important}"]})};var hn=class n{constructor(e,t,i){this.data=e;this.dialogRef=t;this.salesOrderService=i;this.initModalConfig();let o=f.cloneObject(i.Data);this.orderNumber=o.Order.Number}config;orderNumber;initModalConfig(){this.config=new ie,this.config.hideClose=!0,this.config.title="Edit Number"}onOk(){this.updateSalesOrderNumber(),this.dialogRef.close()}updateSalesOrderNumber(){let e=this.salesOrderService.Data;e.Order.Number=this.orderNumber,this.salesOrderService.pushNewValue(e)}onClose(){this.dialogRef.close()}static \u0275fac=function(t){return new(t||n)(P(fe),P(te),P(B))};static \u0275cmp=A({type:n,selectors:[["POS-modal-number-editor"]],standalone:!1,decls:6,vars:2,consts:[[3,"onOk","onCancel","onClose","config"],[1,"form-floating-outline","mb-0"],["type","text","data-cy","orderNumber","id","orderNumber","name","orderNumber",1,"form-control",3,"ngModelChange","ngModel"],["for","orderNumber"]],template:function(t,i){t&1&&(a(0,"modal-material",0),S("onOk",function(){return i.onOk()})("onCancel",function(){return i.onClose()})("onClose",function(){return i.onClose()}),a(1,"content")(2,"div",1)(3,"input",2),j("ngModelChange",function(r){return V(i.orderNumber,r)||(i.orderNumber=r),r}),s(),a(4,"label",3),m(5,"Order Number"),s()()()()),t&2&&(p("config",i.config),l(3),H("ngModel",i.orderNumber))},dependencies:[Te,Pe,Ee,ne],encapsulation:2})};var Cn=class n{constructor(e,t){this.data=e;this.dialogRef=t;this.modalConfig=new ie,this.modalConfig.title=e.title,this.modalConfig.headerType=e.headerType,this.modalConfig.hideFooter=!0}modalConfig;onClose(e){this.dialogRef.close(e)}static \u0275fac=function(t){return new(t||n)(P(fe),P(te))};static \u0275cmp=A({type:n,selectors:[["POS-modal-customer-reminder"]],decls:13,vars:1,consts:[[3,"onClose","config"],[1,"container-fluid","modal-info"],[1,"text-center","mb-4"],[1,"d-flex","justify-content-center","gap-3","mt-8"],[1,"btn","btn-success",3,"click"],[1,"btn","btn-danger",3,"click"]],template:function(t,i){t&1&&(a(0,"modal-material",0),S("onClose",function(){return i.onClose()}),a(1,"content")(2,"div",1)(3,"div")(4,"h4",2),m(5," No customer has been assigned for this Order. "),b(6,"br"),m(7," Do you want to input customer data? "),s(),a(8,"div",3)(9,"button",4),S("click",function(){return i.onClose("yes")}),m(10,"Yes"),s(),a(11,"button",5),S("click",function(){return i.onClose("no")}),m(12,"No"),s()()()()()()),t&2&&p("config",i.modalConfig)},dependencies:[Pt,ne],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 vn=class n{constructor(e,t,i,o,r,c,u,D,F,W,ye){this.salesOrderService=e;this.toastrService=t;this.pageInitialService=i;this.orderProcessorService=o;this.dialog=r;this.onlineStatusService=c;this.promotionEventService=u;this.outletService=D;this.invoiceCalculatorService=F;this.userRole=W;this.sf=ye;this.initSubscribeObservable()}appConfig;salesOrder;isOnline;localDataService=T(Oe);initSubscribeObservable(){this.salesOrderService.Data$.subscribe(e=>{this.salesOrder=e}),this.pageInitialService.Data$.subscribe(e=>{this.appConfig=e.AppConfigJSON}),this.onlineStatusService.getOnlineStatus$().subscribe(e=>{this.isOnline=e})}payOrder(){if(this.isCartNotEmpty()&&this.validateEmptyOrderNumber()&&this.validateNegativePayment()&&this.isSalesPersonValid()&&this.isCustomerRequired()&&this.validateCustomerID()&&this.validatePromotionDiscount()&&this.validateSelectedRegister())if(this.appConfig.ModuleSell.Header.CustomerNotAssignedReminder&&f.IsEmpty(this.salesOrder.Order.CustomerID)){this.dialog.open(Cn,{id:"ModalInfo",data:{title:"Customer Assign Reminder",headerType:me.Warning},width:"31rem"}).afterClosed().pipe(le(e=>{e=="yes"?this.sf.searchFilterNativeEl.focus():e=="no"&&this.onOpenPaymentModal()})).subscribe();return}else this.onOpenPaymentModal()}validateSelectedRegister(){let e=this.pageInitialService?.Data?.Registers,t=this.salesOrder?.Order?.RegisterID;return f.IsEmpty(t)?(this.toastrService.warning("No register selected","Warning!"),!1):e?.some(o=>o.ID==t)?!0:(this.toastrService.warning("No register selected","Warning!"),!1)}validateNegativePayment(){let e=!0,t=this.invoiceCalculatorService.Data;return this.appConfig.ModuleSell.PaymentDialog.MinusPaymentAllowed==!1&&t<0&&(e=!1,this.toastrService.warning("You are not allowed to process this transaction because the total amount is less than zero","Warning!")),e}validateEmptyOrderNumber(){return f.IsEmpty(this.salesOrder.Order.Number)?(this.toastrService.warning(oe.emptyOrderNumber,"Warning!"),this.openModalEditOrderNumber(),!1):!0}openModalEditOrderNumber(){this.userRole.Data.NumberEditor&&this.dialog.open(hn,{width:"20%"})}isCartNotEmpty(){return this.salesOrderService.Data.CartItems.length<1?(this.toastrService.warning(oe.emptyPOItem,"Warning!"),!1):!0}isSalesPersonValid(){let e=this.pageInitialService.Data.AppConfigJSON,t=this.salesOrderService.Data;if(e.ModuleSell.Header.SalesPersonRequired){if(this.salesOrder.CartItems.every(i=>f.IsNotEmpty(i.SalesID)))return!0;if(t.Order.SalesID==f.GuidEmpty||t.Order.SalesID==null)return this.toastrService.warning(oe.emptySalesPerson,"Warning!"),!1}return!0}validateCustomerID(){let e=this.salesOrderService.Data.Order.CustomerID;if(f.IsEmpty(e)){let t=this.orderProcessorService.Data.InputTextValue;if(f.IsNotEmpty(t)){this.toastrService.warning("Customer is not Saved","Warning");let i=this.userRole?.Data?.ContactsCreate;if(this.appConfig?.ModuleSell?.Customer?.QuickAddEnabled&&i)return this.openCustomerModal(t),!1}}return!0}isCustomerRequired(){let e=this.appConfig.ModuleSell.Header.CustomerRequired,t=this.salesOrder.Order.CustomerID;return e&&this.isOnline&&f.IsEmpty(t)?(this.toastrService.warning(oe.emptyCustomer,"Warning!"),!1):!0}openCustomerModal(e){this.dialog.open(fn,{data:{name:e},autoFocus:!1}).afterClosed().subscribe(t=>{t&&this.onOpenPaymentModal()})}validatePromotionDiscount(){let t=(this.outletService?.Data?.Promotion?this.outletService?.Data?.Promotion:[]).find(c=>c.TypeID===3),i=this.appConfig.ModuleSell.MandatoryActiveDiscount,o=this.promotionEventService.selectedPromotion,r=!0;return i&&t&&(o?o.TypeID!=3&&(r=!1):r=!1),r==!1&&(this.dialog.open(gn,{id:"promotion-event"}),this.toastrService.warning("You need to apply Discount promotion","Required Promotion")),r}onOpenPaymentModal(){this.localDataService.unsentOrders$.pipe(Qe(1),Y(e=>e.length>0&&this.isOnline?this.offlineModal():this.paymentModal())).subscribe()}paymentModal(){return this.dialog.open(un,{id:"ModalPayment",disableClose:!0}).afterClosed()}offlineModal(){return this.dialog.open(rn,{disableClose:!0,id:"ModalOfflineOrder",data:{activeTab:"ORDER"}}).afterClosed()}static \u0275fac=function(t){return new(t||n)(g(B),g(L),g(z),g(je),g(we),g(he),g(Ae),g(re),g(ae),g(De),g(jo))};static \u0275prov=I({token:n,factory:n.\u0275fac})};var ir=class n{static \u0275fac=function(t){return new(t||n)};static \u0275mod=ci({type:n});static \u0275inj=li({providers:[vn],imports:[Se,Po,To,vi,mo,yo,Eo,co,po,wo,Ao,Ki,ko,go,qt,Ro,Si,qt]})};export{We as a,G as b,Ei as c,xt as d,B as e,z as f,Tt as g,De as h,wi as i,Ri as j,Ni as k,re as l,Fi as m,st as n,ae as o,wt as p,Bi as q,kt as r,Ae as s,Ji as t,_e as u,zi as v,lt as w,Yi as x,Ft as y,je as z,Xo as A,Ki as B,Lt as C,Bt as D,Ht as E,mn as F,gn as G,fn as H,hn as I,rn as J,vn as K,ir as L};
|