dealpos 26.12.0 → 26.12.2

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.
Files changed (97) hide show
  1. package/browser/{chunk-5IL7ABDA.js → chunk-2ATVU2LS.js} +3 -3
  2. package/browser/{chunk-ILT3IVEC.js → chunk-2FCXPO2Z.js} +1 -1
  3. package/browser/chunk-2XNQOXAP.js +1 -0
  4. package/browser/{chunk-Q2ZBKNUJ.js → chunk-2ZKJQBMC.js} +1 -1
  5. package/browser/{chunk-3GQGKC6R.js → chunk-32ECPU4G.js} +1 -1
  6. package/browser/{chunk-AXJFR5AK.js → chunk-34YZZMTN.js} +1 -1
  7. package/browser/{chunk-WQ6BE7SM.js → chunk-3DPYFMXH.js} +1 -1
  8. package/browser/{chunk-NX66O4OV.js → chunk-3EZJMNC3.js} +1 -1
  9. package/browser/{chunk-NK4RJ4O4.js → chunk-3WJZND3M.js} +1 -1
  10. package/browser/{chunk-CRP4C2DJ.js → chunk-42N7BYEU.js} +1 -1
  11. package/browser/{chunk-32HLH2WV.js → chunk-4VMSABNQ.js} +1 -1
  12. package/browser/{chunk-V4FPJ5VR.js → chunk-4ZDCYADT.js} +1 -1
  13. package/browser/{chunk-YSIUCDOT.js → chunk-5QBETGEA.js} +1 -1
  14. package/browser/{chunk-4IXXEMEG.js → chunk-6AEVG6F2.js} +1 -1
  15. package/browser/{chunk-VPFDGUBC.js → chunk-6H7CNWPW.js} +1 -1
  16. package/browser/{chunk-6NDNRWOL.js → chunk-6HZMEK74.js} +1 -1
  17. package/browser/{chunk-7EXZUXBG.js → chunk-6XECXOQL.js} +2 -2
  18. package/browser/{chunk-UA3TPMIJ.js → chunk-6YYAKTZY.js} +1 -1
  19. package/browser/{chunk-BCPXVLM6.js → chunk-7UX6XI3Y.js} +1 -1
  20. package/browser/{chunk-PN2B4PZM.js → chunk-7ZTHTB2M.js} +1 -1
  21. package/browser/{chunk-WHLQ72PG.js → chunk-ABTH24W5.js} +1 -1
  22. package/browser/{chunk-5R7HCQNN.js → chunk-AHFOVFN3.js} +1 -1
  23. package/browser/{chunk-NCCZ7JRZ.js → chunk-AOGVXESL.js} +1 -1
  24. package/browser/{chunk-SYBO6Q54.js → chunk-AQTXP2ZS.js} +1 -1
  25. package/browser/{chunk-OUM2WZQJ.js → chunk-B7HZHRWB.js} +1 -1
  26. package/browser/{chunk-IYHDYYUO.js → chunk-CAJWZ4H4.js} +1 -1
  27. package/browser/{chunk-SLCERZVR.js → chunk-CANSCI2Y.js} +1 -1
  28. package/browser/{chunk-J32A6JBX.js → chunk-CB5UFVUU.js} +1 -1
  29. package/browser/{chunk-KWXA5O4U.js → chunk-CKYW3E77.js} +2 -2
  30. package/browser/{chunk-L7FXJQ6S.js → chunk-CR2K72VD.js} +1 -1
  31. package/browser/{chunk-JHFHWXHV.js → chunk-CSQSB346.js} +2 -2
  32. package/browser/{chunk-4CHILPFV.js → chunk-CU2X7CKE.js} +1 -1
  33. package/browser/{chunk-ZAPQGZEA.js → chunk-D5HCFSWS.js} +1 -1
  34. package/browser/{chunk-2VD2BAFV.js → chunk-DWMN27SR.js} +1 -1
  35. package/browser/{chunk-HVO4CLXC.js → chunk-EEDPTIYL.js} +2 -2
  36. package/browser/{chunk-VCKNWHFB.js → chunk-EJ2CRXN3.js} +1 -1
  37. package/browser/{chunk-7S2HVOMP.js → chunk-EMMZGE4I.js} +1 -1
  38. package/browser/{chunk-CTDI4Y2H.js → chunk-EU2SBJNN.js} +1 -1
  39. package/browser/{chunk-XLUAL72H.js → chunk-GYF7UVGY.js} +1 -1
  40. package/browser/{chunk-OO6TP4TI.js → chunk-HIEGBHTP.js} +1 -1
  41. package/browser/{chunk-NDJDP35J.js → chunk-HK7XFFOV.js} +1 -1
  42. package/browser/{chunk-KTU7RS3D.js → chunk-IEMVQTIV.js} +1 -1
  43. package/browser/{chunk-ZJV2P4BH.js → chunk-IGVPV4V6.js} +1 -1
  44. package/browser/{chunk-3D5WIDB2.js → chunk-IHAWGBSI.js} +1 -1
  45. package/browser/{chunk-EMYSZ4NW.js → chunk-IOAU2JFO.js} +1 -1
  46. package/browser/{chunk-5CFLIOKI.js → chunk-IOG6M27K.js} +1 -1
  47. package/browser/{chunk-2Y4RH3RF.js → chunk-IQL325R5.js} +2 -2
  48. package/browser/{chunk-FVGGSFY6.js → chunk-IQSLTOL4.js} +1 -1
  49. package/browser/{chunk-JEERF75Z.js → chunk-IZ7IIWHG.js} +1 -1
  50. package/browser/{chunk-BHDNBMUZ.js → chunk-JOXDKNGZ.js} +1 -1
  51. package/browser/{chunk-52IRQ3W4.js → chunk-K5X7M7KK.js} +1 -1
  52. package/browser/{chunk-TK4JHGFA.js → chunk-K76AQWWL.js} +1 -1
  53. package/browser/{chunk-BBU7LR65.js → chunk-KKPV6OZ3.js} +1 -1
  54. package/browser/{chunk-HQVRVGSE.js → chunk-KPHTKLHN.js} +1 -1
  55. package/browser/{chunk-MO3CY3WA.js → chunk-KRKXJWC5.js} +1 -1
  56. package/browser/{chunk-CYBZMVWA.js → chunk-MOE6R6MK.js} +1 -1
  57. package/browser/{chunk-5NUWZ2DA.js → chunk-MX2X5SUN.js} +1 -1
  58. package/browser/{chunk-JGLCEXFN.js → chunk-NBCO5HTZ.js} +1 -1
  59. package/browser/{chunk-ZFW7KOWA.js → chunk-NKIX5CLA.js} +1 -1
  60. package/browser/chunk-NPFUXMNS.js +1 -0
  61. package/browser/{chunk-UDUBUWVS.js → chunk-O3RPW4YN.js} +1 -1
  62. package/browser/{chunk-LAYUOJ4E.js → chunk-OCOQQU4T.js} +1 -1
  63. package/browser/{chunk-ZR6VGAC7.js → chunk-OGP7GX7M.js} +1 -1
  64. package/browser/{chunk-JVWX4MBU.js → chunk-P4YVDYKG.js} +1 -1
  65. package/browser/{chunk-JQKDNPDL.js → chunk-P4ZUQJV5.js} +1 -1
  66. package/browser/{chunk-SEJDSOEF.js → chunk-QAP45ND6.js} +2 -2
  67. package/browser/{chunk-Y3OQ7O5C.js → chunk-QDQAJ3OH.js} +1 -1
  68. package/browser/{chunk-SYWL3HFD.js → chunk-QKBAWXK5.js} +1 -1
  69. package/browser/{chunk-KNAHEF3P.js → chunk-QQ3CM3SY.js} +1 -1
  70. package/browser/{chunk-NOT3CVTT.js → chunk-QTQJ3UQX.js} +1 -1
  71. package/browser/{chunk-NJE4DB6K.js → chunk-RFAX7VKZ.js} +2 -2
  72. package/browser/{chunk-PHIWPOR3.js → chunk-RX6KOSKS.js} +1 -1
  73. package/browser/{chunk-WX6FLFBO.js → chunk-S4GDE7Y2.js} +1 -1
  74. package/browser/{chunk-M7K6SZC5.js → chunk-SMPVGFCL.js} +1 -1
  75. package/browser/{chunk-EPZLV6N2.js → chunk-UEDBMWMK.js} +1 -1
  76. package/browser/{chunk-72Z4XZNR.js → chunk-UMGUBAQV.js} +1 -1
  77. package/browser/{chunk-5V6TQM7E.js → chunk-UQCVXTZE.js} +2 -2
  78. package/browser/{chunk-NO4ULFJ4.js → chunk-URV4PLHU.js} +1 -1
  79. package/browser/{chunk-ZZHNQPQJ.js → chunk-UT3P5CZB.js} +1 -1
  80. package/browser/{chunk-FMYD2SS5.js → chunk-VJ3CCTAP.js} +1 -1
  81. package/browser/{chunk-QACC7BH5.js → chunk-VRMFIBBS.js} +1 -1
  82. package/browser/{chunk-BIEMF3BN.js → chunk-VT5WBIUC.js} +1 -1
  83. package/browser/{chunk-FBTVKBCZ.js → chunk-VXS2KWZU.js} +1 -1
  84. package/browser/{chunk-CUQUMT3C.js → chunk-W54UUUPR.js} +1 -1
  85. package/browser/{chunk-KDZN6CLW.js → chunk-WMJ7NW7H.js} +1 -1
  86. package/browser/{chunk-6M4GRBHH.js → chunk-X22STB6L.js} +1 -1
  87. package/browser/{chunk-V54IMWPL.js → chunk-X3WRWK2P.js} +1 -1
  88. package/browser/{chunk-IEPOIJMJ.js → chunk-XMQF23EU.js} +1 -1
  89. package/browser/{chunk-XALV4MYN.js → chunk-YG3EKSAA.js} +1 -1
  90. package/browser/{chunk-PYZLA6NP.js → chunk-YNCVE5XY.js} +1 -1
  91. package/browser/chunk-ZZIFHSBN.js +1 -0
  92. package/browser/index.html +2 -2
  93. package/browser/{main-54LL7TYK.js → main-LMI6IVYC.js} +4 -4
  94. package/package.json +1 -1
  95. package/browser/chunk-BLMIYII7.js +0 -1
  96. package/browser/chunk-JDMJ5GIS.js +0 -1
  97. package/browser/chunk-RTLJPAFV.js +0 -1
@@ -1,4 +1,4 @@
1
- import{a as Zt}from"./chunk-ZOBPTHDY.js";import{a as At,b as Ne,c as Bo}from"./chunk-2OOAFLWG.js";import{a as zo}from"./chunk-ANBDI5MB.js";import{e as jo}from"./chunk-BXHFFVVV.js";import{a as Ti}from"./chunk-GGDW5WFA.js";import{b as Go}from"./chunk-MFCDS575.js";import{d as Wo}from"./chunk-2F3Z5UVP.js";import{a as Uo}from"./chunk-COD2FOFZ.js";import{a as Lo}from"./chunk-V46FIBS7.js";import{a as Ii}from"./chunk-2PUTNW54.js";import{a as Yo}from"./chunk-4VGCD2S7.js";import{a as be,b as Re,e as Jo}from"./chunk-C3DQQRQ2.js";import{b as Ho}from"./chunk-O55DD6CT.js";import{a as So}from"./chunk-CZWUCHB4.js";import{a as $o,b as qo}from"./chunk-KIH7ZE6M.js";import{a as Fo}from"./chunk-2XCPI5BA.js";import{a as wi}from"./chunk-HNS7KWHX.js";import{a as Ei,b as Ri,c as Ni}from"./chunk-OKL7T7RK.js";import{a as kt}from"./chunk-Q3UN4JZJ.js";import{a as Qo}from"./chunk-4WL57CXW.js";import{a as Ko}from"./chunk-VLSANGOZ.js";import{a as Yt,b as En,c as Ye}from"./chunk-L3CQDLDO.js";import{a as xi,b as Te}from"./chunk-NEUUD5VB.js";import{a as Nt}from"./chunk-32EIT4L7.js";import{a as tt,b as Kt,c as fe}from"./chunk-NSNUUKNK.js";import{a as Vo}from"./chunk-7GRHNPNY.js";import{g as ko}from"./chunk-MTMTZLMY.js";import{a as Ao}from"./chunk-JEJGTRFJ.js";import{d as Di}from"./chunk-6C7NKVRP.js";import{m as Pi}from"./chunk-6TWTQLKB.js";import{d as Oo}from"./chunk-SASYAFMF.js";import{c as Po}from"./chunk-STYLBZL4.js";import{a as Et}from"./chunk-VIKIXIX5.js";import{g as Mo}from"./chunk-IFLLAVLK.js";import{b as No}from"./chunk-3GZUX2TV.js";import{a as Eo,b as ae,c as De,f as Ro}from"./chunk-YWAAVL5W.js";import{a as Si,b as zt}from"./chunk-JFS6EFNT.js";import{F as Rt,N as Mi,O as U,g as xo,n as Oi,o as Io,q as To,t as wo}from"./chunk-WZVFFBZM.js";import{a as at}from"./chunk-QU45SEX2.js";import{a as yi,b as so,c as bi}from"./chunk-QYSFCWV7.js";import{d as wt,e as Do}from"./chunk-ZRBKLF75.js";import{a as Z,b as pe,c as ye}from"./chunk-CPHICIOL.js";import{a as oe,b as yo}from"./chunk-GCPQTFRO.js";import{o as bo}from"./chunk-NFVNHSX5.js";import{a as de,b as Y,c as ie}from"./chunk-N4STXFCX.js";import{A as Co,E as lt,F as vo,c as ve,e as Tt,h as ge,i as lo,k as co,l as Ge,n as mo,o as Me,p as po,q as uo,s as st,x as go,y as fo,z as ho}from"./chunk-DHBFOXIN.js";import{b as _o}from"./chunk-WXT6UMYF.js";import{a as u}from"./chunk-3DEA4WWC.js";import{a as ao}from"./chunk-FMYD2SS5.js";import{n as L,q as _e}from"./chunk-2WBWJI4D.js";import{Bb as h,Cb as Tn,Db as C,Dc as k,Eb as Le,Ec as We,F as ne,Fa as T,Fb as Se,Gb as z,Gc as zn,Hb as K,Ib as m,J as nt,Jb as a,Kb as s,Kc as v,Kd as to,Lb as y,Lc as D,Mb as A,Mc as re,N as Pt,Nb as F,Nc as xt,O as Ue,Ob as Xe,Od as io,Pb as Ot,Qb as Mt,Qc as Kn,R as Fe,Rb as _i,Sa as ze,Tc as J,Td as no,Ua as Ct,Ub as E,Ud as oo,Va as Wn,Vb as Gn,Wd as ro,Xb as _,Xc as It,Yb as $n,Yc as ot,Z as Be,Za as l,Zb as p,aa as fi,ad as rt,b as pi,ba as te,bc as Dt,cc as vt,d as xe,dc as _t,e as we,ea as Ie,eb as M,ga as ce,hc as Ce,ib as N,ic as qn,jb as Ci,k as bt,lc as et,mc as d,md as Ee,n as Qn,na as w,nc as P,o as Qe,oa as hi,ob as ee,oc as I,od as Yn,p as St,pc as yt,pd as Zn,q as ui,qa as f,qc as Jn,qd as Xn,ra as O,rc as j,rd as eo,s as gi,sc as B,sd as He,tc as Q,u as W,uc as wn,ud as Ke,v as Je,va as b,w as Un,wa as S,wd as G,xb as vi,zd as me}from"./chunk-2ERDZXCS.js";import{a as di,i as Ze,k as mi}from"./chunk-SNAKHGZS.js";var Xt=class{ID;EntityID;RegisterID;TypeID;Date;Number;CustomerID;SalesID;Discount=0;Discount2=0;DiscountAmount=0;CustomerDiscountRate=0;Note="";DeliveryOutletID;TaxTypeID;CurrencyID;CurrencyRate;PointUsed;InvoicedStateID;ReferenceNumber="";LogisticsServiceID;ParkLabel="";NumberOfPerson;ClientTimestamp;Created;PromotionCoupon="";CouponType=1;PromotionNote="";DeliveryStateID;CouponProvider="Internal";CurrencySymbol;constructor(){this.ID=u.GuidEmpty,this.EntityID=u.GuidEmpty,this.RegisterID=u.GuidEmpty,this.Number="",this.CustomerID=null,this.SalesID=null,this.Discount=0,this.Discount2=0,this.DiscountAmount=0,this.Note="",this.TaxTypeID=u.GuidEmpty,this.CurrencyID=1,this.CurrencyRate=1,this.DeliveryStateID=3,this.PointUsed=0,this.NumberOfPerson=1,this.Date=new Date}removeEnterNote(){this.Note&&(this.Note=this.Note.replace(/\n/g,""))}};var ei=class{DeliveryEntityID;Type;NewOrderID;constructor(){this.DeliveryEntityID="",this.Type=3}};var Ai=class{Amount;ApplyToProduct;Code;Type;TypeDescription;Coupon;Notification;MaxDiscount;Note};var $=class{Order;Invoice;Shipping;Action;Payments;Items;CartItems;Promotion;ContactName;SplitParkLabel;get cartQuantity(){let t=0;for(let e of this.CartItems)t+=e.Quantity;return t}constructor(){this.Order=new Xt,this.Invoice=new Yt,this.Shipping=new En,this.Action=new ei,this.Payments=Array(),this.Items=Array(),this.CartItems=Array(),this.ContactName=""}get TotalPaidAmount(){let t=0;return this.Payments.forEach(e=>{t+=e.PaidAmount}),t}get RedeemableAmount(){let t=this.CartItems.filter(e=>e.Variant.PaymentTypeID!=1);return this.GetAmountByCart(t)}get TotalQuantity(){let t=0;return this.CartItems.forEach(e=>{e.PromotionGift||(t+=e.Quantity)}),t}get CashOnlyAmount(){let t=this.CartItems.filter(e=>e.Variant.PaymentTypeID==1);return this.GetAmountByCart(t)}get PointOnlyAmount(){let t=this.CartItems.filter(e=>e.Variant.PaymentTypeID==2);return this.GetAmountByCart(t)}get PrepaidPackageItem(){return this.CartItems.filter(e=>e.Variant.TypeID==10)}GetAmountByCart(t){let e=0;return t.forEach(i=>{e+=i.Total}),e=e*(100-this.Order.Discount)/100,e=e*(100-this.Order.Discount2)/100,e}getRewards(){return this.CartItems.filter(e=>e.PromotionGift)}};Ze([tt(()=>Xt)],$.prototype,"Order",2),Ze([tt(()=>Yt)],$.prototype,"Invoice",2),Ze([tt(()=>En)],$.prototype,"Shipping",2),Ze([tt(()=>ei)],$.prototype,"Action",2),Ze([tt(()=>Ye)],$.prototype,"Payments",2),Ze([tt(()=>xi)],$.prototype,"Items",2),Ze([tt(()=>Te)],$.prototype,"CartItems",2),Ze([tt(()=>Ai)],$.prototype,"Promotion",2);var ki=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 Vt=class n{constructor(t,e,i,o){this.httpService=t;this._localDataService=e;this._onlineStatusService=i;this._toastrService=o;this._onlineStatusService.getOnlineStatus$().subscribe(r=>{this.isOnline=r})}_Data=new we(null);Data$=this._Data.pipe(Fe(),ne(t=>t!==null));isOnline;get Data(){return this._Data.value}pushNewValue(t){this._Data.next(t)}getSalesOrderPrint(t){return this.httpService.post("/API/POS/GetSalesOrderPrint",{TemplateID:t})}submitOrder(t,e){let i=this.generatePOSDataForSubmission(t,this.isOnline);if(this.isOnline)return this.submitOnline(i).pipe(this.handleTimeOutError(i));if(e.ModuleSell.EnableOfflineTransaction)return this._localDataService.syncOrder(i).pipe(W(()=>this.generateCompleteData(i)));this._toastrService.warning("Offline order is not Supported!","Info!")}uploadOfflineOrder(t){return this._localDataService.uploadSingleOrder(t).pipe(nt(e=>e?.message?.includes("objectStore does not exists")?this.submitOnline(t):St(()=>e)))}submitOnline(t){return this.httpService.post(U.SubmitOrder,t,ao.pos.submitOrderTimeout)}handleTimeOutError(t){return pi(nt(e=>{if(e instanceof gi||e?.name=="TimeoutError"){let i=this.generateCompleteData(t);this.pushNewValue(i)}throw e}))}generatePOSDataForSubmission(t,e=!0){let i=Object.assign(new $,t);i.Items=[],i.Order.CustomerID==null&&(i.Order.CustomerID=u.GuidEmpty),i.Order.SalesID==null&&(i.Order.SalesID=u.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 g=new xi;g.ID=c.ID,g.VariantID=c.VariantID,g.Quantity=c.Quantity,g.Cost=c.Cost,g.Price=c.Price,g.Discount=c.Discount,g.DiscountAmount=c.DiscountAmount,g.Note=c.Note,g.Taxable=c.Variant.Taxable,g.LoyaltyPoint=c.LoyaltyPoint,g.UnitCost=c.Cost,g.UnitPrice=c.Price,g.UnitPriceOriginal=c.UnitPriceOriginal,g.UnitExpense=c.UnitExpense,g.EntityID=c.EntityID,g.Index=r,g.UnitQuantity=c.UnitQuantity,g.PriceTypeID=c.PriceTypeID,g.PriceNote=c.PriceNote,g.Splited=c.SplitQuantity>0,g.SplitQuantity=c.SplitQuantity,g.InventoryTypeID=c.Variant.TypeID,g.SalesID="",g.Serial=c.Serial,c.SalesID&&(g.SalesID=c.SalesID),delete c.CouponDiscount,i.Items.push(g),r++}return e?(delete i.CartItems,delete i.Order.ClientTimestamp):i.Order.ClientTimestamp=new Date,i}generateCompleteData(t){let e=new ki;return e.InvoiceNumber=t.Order.Number,e.OrderTimeString=new Date().toString(),e.PaymentStateID=t.Action?.Type,e.PaymentStateLabel="Offline",e.Success=!0,e.OutDeliveryID=t.Action.DeliveryEntityID,e}GetReturnInvoice(t,e){return this.httpService.get(U.ReturInvoice,[{key:"EntityID",value:e},{key:"Number",value:t}])}GetInvoiceBySoID(t){return this.httpService.get(U.GetPOSDataByID,[{key:"ID",value:t}])}UploadCSV(t,e){let i={CartItems:t,EntityID:e};return this.httpService.post(U.UploadCsv,i)}sendEmail(t,e){return new Promise((i,o)=>{this._localDataService.isProductFromServer().subscribe(r=>{if(r){let c={invoiceID:e,email:t};this.httpService.post(U.SendInvoiceEmail,c).subscribe({next:g=>{i(g)},error:g=>{o(g)}})}else o(ae.wrongOfflineAction)})})}sendWhatsaap(t,e){let i={InvoiceID:t,PhoneNumber:e};return this.httpService.post(U.SendInvoiceWhatsapp,i)}createCustomerByInvoice(t,e){let i={InvoiceID:t,Mobile:e};return this.httpService.post(U.CreateCustomerInvoice,i)}saveCommission(t,e){let i={SOID:t,commission:e};return this.httpService.POSText("/API/Transaction/SetCommission",i)}generateReceiptA4(t){let e={ID:t};return this.httpService.post(U.InvoiceA4,e)}getVacant(t){return this.httpService.get(U.GetVacant,[{key:"EntityID",value:t}])}static \u0275fac=function(e){return new(e||n)(f(_e),f(De),f(be),f(L))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var ni=(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))(ni||{});var H=class n{constructor(t,e,i){this._OrderHttpService=t;this._customerHttpService=e;this._toastrService=i}_Data=new we(new $);transaction_id;Data$=this._Data.asObservable();get Data(){return this._Data.value}pushNewValue(t){if(t)this._Data.next(t);else{let e=this.Data;this._Data.next(e)}}submitOrder(t){return new Promise((e,i)=>{this.checkTransactionId(),this._OrderHttpService.submitOrder(this.Data,t).subscribe({next:o=>{e(o)},error:o=>{this.Data.Items=[],i(o)}})})}uploadOfflineOrder(){return this.checkTransactionId(),this._OrderHttpService.uploadOfflineOrder(this.Data)}checkTransactionId(){let e=this.Data.Payments.find(i=>i.TypeID==3);u.IsNotEmpty(e)&&u.IsEmpty(this.transaction_id)&&this._toastrService.warning("Midtrans transaction_id is empty. Please verify manually!","Mobile Payment Failure")}updateCustomerID(t){return this.Data.Order.CustomerID=t,this.pushNewValue(this.Data),new Promise((e,i)=>{this._customerHttpService.GetPrivilegeByID(t,this.Data.Order.EntityID).subscribe({next:o=>{this._customerHttpService.Data=o,this.pushNewValue(this.Data),e(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(e){return new(e||n)(f(Vt),f(Re),f(L))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var X=class n{constructor(t,e,i){this._localDataService=t;this._onlineStatusService=e;this._httpService=i;this._onlineStatusService.getOnlineStatus$().subscribe(o=>{this.isOnline=o})}_Data=new we(null);Data$=this._Data.asObservable().pipe(ne(t=>t!==null),Fe());isOnline;get Data(){return this._Data.value}pushNewValue(t){this._Data.next(t)}requestObservable(){return this.isOnline?this._httpService.get(U.GetPOSStorage).pipe(W(t=>({data:t,type:"Online"}))):this._localDataService.getPOSStorage().pipe(ne(t=>t!=null),W(t=>({data:t,type:"Offline"})))}getOutletName(t){return this.Data.Entities.find(i=>i.ID==t)?.Name}static \u0275fac=function(e){return new(e||n)(f(De),f(be),f(_e))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var ri=class{ID;Code;EntityID;Name;Description;Start;StartDisplay;State;Open;CashierID;OpeningCash;EntityName;LoginID;Active;CustomerDisplayEnabled;OvoConfigurationID;CustomerDisplayID;ListImage;Suspended};var Vi=class n{odsConfigType=T(0);setODSConfig(t){this.odsConfigType.set(t)}isEnabled(){return this.odsConfigType()>0}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var _r=["searchInputRef"],yr=n=>({active:n}),br=n=>({gray:n});function Sr(n,t){if(n&1){let e=E();a(0,"span",16),_("click",function(o){b(e);let r=p().$implicit;return p().closeRegister(r),S(o.stopPropagation())}),s()}}function Pr(n,t){n&1&&(a(0,"div")(1,"span",17),d(2,"VACANT"),s()())}function Or(n,t){if(n&1&&(a(0,"div")(1,"span",18),y(2,"i",19),a(3,"span",20),d(4),s()(),a(5,"span",21),y(6,"i",22),a(7,"span",20),d(8),s()()()),n&2){let e=p().$implicit;l(4),P(e.LoginID),l(4),I("",e.StartDisplay.split(" ")[3]," - Now")}}function Mr(n,t){if(n&1){let e=E();a(0,"div",9)(1,"div",10)(2,"div",11)(3,"h5",12),_("click",function(){let o=b(e).$implicit,r=p();return S(r.select(o))}),a(4,"span"),y(5,"i",13),d(6),v(7,"limitTo"),s(),h(8,Sr,1,0,"span",14),s(),a(9,"div",15),_("click",function(){let o=b(e).$implicit,r=p();return S(r.select(o))}),h(10,Pr,3,0,"div")(11,Or,9,2,"div"),s()()()()}if(n&2){let e,i=t.$implicit,o=p();l(),m("ngClass",i.Active?"active":""),l(),m("ngClass",k(9,yr,(i==null?null:i.ID)==(o.selectedRegister==null?null:o.selectedRegister.ID))),l(),m("ngClass",k(11,br,i!=o.selectedRegister)),l(3),P(re(7,6,i.Name,15)),l(2),C(i.State!="Close"?8:-1),l(2),C((e=i.State)==="Close"?10:e==="Open"?11:-1)}}var Fi=class n{constructor(t,e,i,o,r,c,g){this._dialogRef=t;this._outletService=e;this._posService=i;this._userRoleService=o;this.router=r;this.httpService=c;this._odsService=g}searchInputRef;originalSelectedRegister=null;registers;searchInput="";selectedRegister=new ri;modalConfig=T(new Y);role;get AppConfigJSON(){return this._posService.Data.AppConfigJSON}destroy$=new xe;ngOnInit(){this.initModalConfig(),this.subscribeToObsChanges()}ngAfterViewInit(){this.searchInputRef&&this._dialogRef.afterOpened().subscribe(()=>{setTimeout(()=>{this.searchInputRef.nativeElement.focus()},200)})}subscribeToObsChanges(){this._posService.Data$.pipe(Ie(this.destroy$)).subscribe(t=>{this.registers=t.Registers}),this._outletService.Data$.pipe(Ie(this.destroy$)).subscribe(t=>{this.selectedRegister=this.findOutletRegisterById(t.RegisterID),this.originalSelectedRegister=this.selectedRegister?di({},this.selectedRegister):null,this.initModalConfig(!1)}),this._userRoleService.Data$.pipe(Ie(this.destroy$)).subscribe(t=>{this.role=t})}findOutletRegisterById(t){let e=this.registers.find(i=>i.ID===t);return e||new ri}initModalConfig(t=!0){this.modalConfig.update(e=>(e.hideFooter=!0,e.hideScrollbar=!0,e.hideClose=t,e.title="Choose an outlet",e))}ngOnDestroy(){this.destroy$.next(!0),this.destroy$.complete()}onClose(){this._dialogRef.close()}select(t){if(this.AppConfigJSON.ModuleShift.Closure.Enabled)if(this.selectedRegister.ID!=null&&this.selectedRegister.Open&&t.CashierID==null)confirm("You already have an active register with "+this.selectedRegister.Name+`!
1
+ import{a as Zt}from"./chunk-ZOBPTHDY.js";import{a as At,b as Ne,c as Bo}from"./chunk-2OOAFLWG.js";import{a as zo}from"./chunk-ANBDI5MB.js";import{e as jo}from"./chunk-BXHFFVVV.js";import{a as Ti}from"./chunk-GGDW5WFA.js";import{b as Go}from"./chunk-MFCDS575.js";import{d as Wo}from"./chunk-2F3Z5UVP.js";import{a as Uo}from"./chunk-COD2FOFZ.js";import{a as Lo}from"./chunk-V46FIBS7.js";import{a as Ii}from"./chunk-2PUTNW54.js";import{a as Yo}from"./chunk-4VGCD2S7.js";import{a as be,b as Re,e as Jo}from"./chunk-C3DQQRQ2.js";import{b as Ho}from"./chunk-O55DD6CT.js";import{a as So}from"./chunk-CZWUCHB4.js";import{a as $o,b as qo}from"./chunk-KIH7ZE6M.js";import{a as Fo}from"./chunk-2XCPI5BA.js";import{a as wi}from"./chunk-HNS7KWHX.js";import{a as Ei,b as Ri,c as Ni}from"./chunk-OKL7T7RK.js";import{a as kt}from"./chunk-Q3UN4JZJ.js";import{a as Qo}from"./chunk-4WL57CXW.js";import{a as Ko}from"./chunk-VLSANGOZ.js";import{a as Yt,b as En,c as Ye}from"./chunk-L3CQDLDO.js";import{a as xi,b as Te}from"./chunk-NEUUD5VB.js";import{a as Nt}from"./chunk-32EIT4L7.js";import{a as tt,b as Kt,c as fe}from"./chunk-NSNUUKNK.js";import{a as Vo}from"./chunk-7GRHNPNY.js";import{g as ko}from"./chunk-MTMTZLMY.js";import{a as Ao}from"./chunk-JEJGTRFJ.js";import{d as Di}from"./chunk-6C7NKVRP.js";import{m as Pi}from"./chunk-6TWTQLKB.js";import{d as Oo}from"./chunk-SASYAFMF.js";import{c as Po}from"./chunk-STYLBZL4.js";import{a as Et}from"./chunk-VIKIXIX5.js";import{g as Mo}from"./chunk-IFLLAVLK.js";import{b as No}from"./chunk-3GZUX2TV.js";import{a as Eo,b as ae,c as De,f as Ro}from"./chunk-YWAAVL5W.js";import{a as Si,b as zt}from"./chunk-JFS6EFNT.js";import{F as Rt,N as Mi,O as U,g as xo,n as Oi,o as Io,q as To,t as wo}from"./chunk-WZVFFBZM.js";import{a as at}from"./chunk-QU45SEX2.js";import{a as yi,b as so,c as bi}from"./chunk-QYSFCWV7.js";import{d as wt,e as Do}from"./chunk-ZRBKLF75.js";import{a as Z,b as pe,c as ye}from"./chunk-CPHICIOL.js";import{a as oe,b as yo}from"./chunk-GCPQTFRO.js";import{o as bo}from"./chunk-NFVNHSX5.js";import{a as de,b as Y,c as ie}from"./chunk-N4STXFCX.js";import{A as Co,E as lt,F as vo,c as ve,e as Tt,h as ge,i as lo,k as co,l as Ge,n as mo,o as Me,p as po,q as uo,s as st,x as go,y as fo,z as ho}from"./chunk-DHBFOXIN.js";import{b as _o}from"./chunk-WXT6UMYF.js";import{a as u}from"./chunk-3DEA4WWC.js";import{a as ao}from"./chunk-VJ3CCTAP.js";import{n as L,q as _e}from"./chunk-2WBWJI4D.js";import{Bb as h,Cb as Tn,Db as C,Dc as k,Eb as Le,Ec as We,F as ne,Fa as T,Fb as Se,Gb as z,Gc as zn,Hb as K,Ib as m,J as nt,Jb as a,Kb as s,Kc as v,Kd as to,Lb as y,Lc as D,Mb as A,Mc as re,N as Pt,Nb as F,Nc as xt,O as Ue,Ob as Xe,Od as io,Pb as Ot,Qb as Mt,Qc as Kn,R as Fe,Rb as _i,Sa as ze,Tc as J,Td as no,Ua as Ct,Ub as E,Ud as oo,Va as Wn,Vb as Gn,Wd as ro,Xb as _,Xc as It,Yb as $n,Yc as ot,Z as Be,Za as l,Zb as p,aa as fi,ad as rt,b as pi,ba as te,bc as Dt,cc as vt,d as xe,dc as _t,e as we,ea as Ie,eb as M,ga as ce,hc as Ce,ib as N,ic as qn,jb as Ci,k as bt,lc as et,mc as d,md as Ee,n as Qn,na as w,nc as P,o as Qe,oa as hi,ob as ee,oc as I,od as Yn,p as St,pc as yt,pd as Zn,q as ui,qa as f,qc as Jn,qd as Xn,ra as O,rc as j,rd as eo,s as gi,sc as B,sd as He,tc as Q,u as W,uc as wn,ud as Ke,v as Je,va as b,w as Un,wa as S,wd as G,xb as vi,zd as me}from"./chunk-2ERDZXCS.js";import{a as di,i as Ze,k as mi}from"./chunk-SNAKHGZS.js";var Xt=class{ID;EntityID;RegisterID;TypeID;Date;Number;CustomerID;SalesID;Discount=0;Discount2=0;DiscountAmount=0;CustomerDiscountRate=0;Note="";DeliveryOutletID;TaxTypeID;CurrencyID;CurrencyRate;PointUsed;InvoicedStateID;ReferenceNumber="";LogisticsServiceID;ParkLabel="";NumberOfPerson;ClientTimestamp;Created;PromotionCoupon="";CouponType=1;PromotionNote="";DeliveryStateID;CouponProvider="Internal";CurrencySymbol;constructor(){this.ID=u.GuidEmpty,this.EntityID=u.GuidEmpty,this.RegisterID=u.GuidEmpty,this.Number="",this.CustomerID=null,this.SalesID=null,this.Discount=0,this.Discount2=0,this.DiscountAmount=0,this.Note="",this.TaxTypeID=u.GuidEmpty,this.CurrencyID=1,this.CurrencyRate=1,this.DeliveryStateID=3,this.PointUsed=0,this.NumberOfPerson=1,this.Date=new Date}removeEnterNote(){this.Note&&(this.Note=this.Note.replace(/\n/g,""))}};var ei=class{DeliveryEntityID;Type;NewOrderID;constructor(){this.DeliveryEntityID="",this.Type=3}};var Ai=class{Amount;ApplyToProduct;Code;Type;TypeDescription;Coupon;Notification;MaxDiscount;Note};var $=class{Order;Invoice;Shipping;Action;Payments;Items;CartItems;Promotion;ContactName;SplitParkLabel;get cartQuantity(){let t=0;for(let e of this.CartItems)t+=e.Quantity;return t}constructor(){this.Order=new Xt,this.Invoice=new Yt,this.Shipping=new En,this.Action=new ei,this.Payments=Array(),this.Items=Array(),this.CartItems=Array(),this.ContactName=""}get TotalPaidAmount(){let t=0;return this.Payments.forEach(e=>{t+=e.PaidAmount}),t}get RedeemableAmount(){let t=this.CartItems.filter(e=>e.Variant.PaymentTypeID!=1);return this.GetAmountByCart(t)}get TotalQuantity(){let t=0;return this.CartItems.forEach(e=>{e.PromotionGift||(t+=e.Quantity)}),t}get CashOnlyAmount(){let t=this.CartItems.filter(e=>e.Variant.PaymentTypeID==1);return this.GetAmountByCart(t)}get PointOnlyAmount(){let t=this.CartItems.filter(e=>e.Variant.PaymentTypeID==2);return this.GetAmountByCart(t)}get PrepaidPackageItem(){return this.CartItems.filter(e=>e.Variant.TypeID==10)}GetAmountByCart(t){let e=0;return t.forEach(i=>{e+=i.Total}),e=e*(100-this.Order.Discount)/100,e=e*(100-this.Order.Discount2)/100,e}getRewards(){return this.CartItems.filter(e=>e.PromotionGift)}};Ze([tt(()=>Xt)],$.prototype,"Order",2),Ze([tt(()=>Yt)],$.prototype,"Invoice",2),Ze([tt(()=>En)],$.prototype,"Shipping",2),Ze([tt(()=>ei)],$.prototype,"Action",2),Ze([tt(()=>Ye)],$.prototype,"Payments",2),Ze([tt(()=>xi)],$.prototype,"Items",2),Ze([tt(()=>Te)],$.prototype,"CartItems",2),Ze([tt(()=>Ai)],$.prototype,"Promotion",2);var ki=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 Vt=class n{constructor(t,e,i,o){this.httpService=t;this._localDataService=e;this._onlineStatusService=i;this._toastrService=o;this._onlineStatusService.getOnlineStatus$().subscribe(r=>{this.isOnline=r})}_Data=new we(null);Data$=this._Data.pipe(Fe(),ne(t=>t!==null));isOnline;get Data(){return this._Data.value}pushNewValue(t){this._Data.next(t)}getSalesOrderPrint(t){return this.httpService.post("/API/POS/GetSalesOrderPrint",{TemplateID:t})}submitOrder(t,e){let i=this.generatePOSDataForSubmission(t,this.isOnline);if(this.isOnline)return this.submitOnline(i).pipe(this.handleTimeOutError(i));if(e.ModuleSell.EnableOfflineTransaction)return this._localDataService.syncOrder(i).pipe(W(()=>this.generateCompleteData(i)));this._toastrService.warning("Offline order is not Supported!","Info!")}uploadOfflineOrder(t){return this._localDataService.uploadSingleOrder(t).pipe(nt(e=>e?.message?.includes("objectStore does not exists")?this.submitOnline(t):St(()=>e)))}submitOnline(t){return this.httpService.post(U.SubmitOrder,t,ao.pos.submitOrderTimeout)}handleTimeOutError(t){return pi(nt(e=>{if(e instanceof gi||e?.name=="TimeoutError"){let i=this.generateCompleteData(t);this.pushNewValue(i)}throw e}))}generatePOSDataForSubmission(t,e=!0){let i=Object.assign(new $,t);i.Items=[],i.Order.CustomerID==null&&(i.Order.CustomerID=u.GuidEmpty),i.Order.SalesID==null&&(i.Order.SalesID=u.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 g=new xi;g.ID=c.ID,g.VariantID=c.VariantID,g.Quantity=c.Quantity,g.Cost=c.Cost,g.Price=c.Price,g.Discount=c.Discount,g.DiscountAmount=c.DiscountAmount,g.Note=c.Note,g.Taxable=c.Variant.Taxable,g.LoyaltyPoint=c.LoyaltyPoint,g.UnitCost=c.Cost,g.UnitPrice=c.Price,g.UnitPriceOriginal=c.UnitPriceOriginal,g.UnitExpense=c.UnitExpense,g.EntityID=c.EntityID,g.Index=r,g.UnitQuantity=c.UnitQuantity,g.PriceTypeID=c.PriceTypeID,g.PriceNote=c.PriceNote,g.Splited=c.SplitQuantity>0,g.SplitQuantity=c.SplitQuantity,g.InventoryTypeID=c.Variant.TypeID,g.SalesID="",g.Serial=c.Serial,c.SalesID&&(g.SalesID=c.SalesID),delete c.CouponDiscount,i.Items.push(g),r++}return e?(delete i.CartItems,delete i.Order.ClientTimestamp):i.Order.ClientTimestamp=new Date,i}generateCompleteData(t){let e=new ki;return e.InvoiceNumber=t.Order.Number,e.OrderTimeString=new Date().toString(),e.PaymentStateID=t.Action?.Type,e.PaymentStateLabel="Offline",e.Success=!0,e.OutDeliveryID=t.Action.DeliveryEntityID,e}GetReturnInvoice(t,e){return this.httpService.get(U.ReturInvoice,[{key:"EntityID",value:e},{key:"Number",value:t}])}GetInvoiceBySoID(t){return this.httpService.get(U.GetPOSDataByID,[{key:"ID",value:t}])}UploadCSV(t,e){let i={CartItems:t,EntityID:e};return this.httpService.post(U.UploadCsv,i)}sendEmail(t,e){return new Promise((i,o)=>{this._localDataService.isProductFromServer().subscribe(r=>{if(r){let c={invoiceID:e,email:t};this.httpService.post(U.SendInvoiceEmail,c).subscribe({next:g=>{i(g)},error:g=>{o(g)}})}else o(ae.wrongOfflineAction)})})}sendWhatsaap(t,e){let i={InvoiceID:t,PhoneNumber:e};return this.httpService.post(U.SendInvoiceWhatsapp,i)}createCustomerByInvoice(t,e){let i={InvoiceID:t,Mobile:e};return this.httpService.post(U.CreateCustomerInvoice,i)}saveCommission(t,e){let i={SOID:t,commission:e};return this.httpService.POSText("/API/Transaction/SetCommission",i)}generateReceiptA4(t){let e={ID:t};return this.httpService.post(U.InvoiceA4,e)}getVacant(t){return this.httpService.get(U.GetVacant,[{key:"EntityID",value:t}])}static \u0275fac=function(e){return new(e||n)(f(_e),f(De),f(be),f(L))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var ni=(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))(ni||{});var H=class n{constructor(t,e,i){this._OrderHttpService=t;this._customerHttpService=e;this._toastrService=i}_Data=new we(new $);transaction_id;Data$=this._Data.asObservable();get Data(){return this._Data.value}pushNewValue(t){if(t)this._Data.next(t);else{let e=this.Data;this._Data.next(e)}}submitOrder(t){return new Promise((e,i)=>{this.checkTransactionId(),this._OrderHttpService.submitOrder(this.Data,t).subscribe({next:o=>{e(o)},error:o=>{this.Data.Items=[],i(o)}})})}uploadOfflineOrder(){return this.checkTransactionId(),this._OrderHttpService.uploadOfflineOrder(this.Data)}checkTransactionId(){let e=this.Data.Payments.find(i=>i.TypeID==3);u.IsNotEmpty(e)&&u.IsEmpty(this.transaction_id)&&this._toastrService.warning("Midtrans transaction_id is empty. Please verify manually!","Mobile Payment Failure")}updateCustomerID(t){return this.Data.Order.CustomerID=t,this.pushNewValue(this.Data),new Promise((e,i)=>{this._customerHttpService.GetPrivilegeByID(t,this.Data.Order.EntityID).subscribe({next:o=>{this._customerHttpService.Data=o,this.pushNewValue(this.Data),e(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(e){return new(e||n)(f(Vt),f(Re),f(L))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var X=class n{constructor(t,e,i){this._localDataService=t;this._onlineStatusService=e;this._httpService=i;this._onlineStatusService.getOnlineStatus$().subscribe(o=>{this.isOnline=o})}_Data=new we(null);Data$=this._Data.asObservable().pipe(ne(t=>t!==null),Fe());isOnline;get Data(){return this._Data.value}pushNewValue(t){this._Data.next(t)}requestObservable(){return this.isOnline?this._httpService.get(U.GetPOSStorage).pipe(W(t=>({data:t,type:"Online"}))):this._localDataService.getPOSStorage().pipe(ne(t=>t!=null),W(t=>({data:t,type:"Offline"})))}getOutletName(t){return this.Data.Entities.find(i=>i.ID==t)?.Name}static \u0275fac=function(e){return new(e||n)(f(De),f(be),f(_e))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var ri=class{ID;Code;EntityID;Name;Description;Start;StartDisplay;State;Open;CashierID;OpeningCash;EntityName;LoginID;Active;CustomerDisplayEnabled;OvoConfigurationID;CustomerDisplayID;ListImage;Suspended};var Vi=class n{odsConfigType=T(0);setODSConfig(t){this.odsConfigType.set(t)}isEnabled(){return this.odsConfigType()>0}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var _r=["searchInputRef"],yr=n=>({active:n}),br=n=>({gray:n});function Sr(n,t){if(n&1){let e=E();a(0,"span",16),_("click",function(o){b(e);let r=p().$implicit;return p().closeRegister(r),S(o.stopPropagation())}),s()}}function Pr(n,t){n&1&&(a(0,"div")(1,"span",17),d(2,"VACANT"),s()())}function Or(n,t){if(n&1&&(a(0,"div")(1,"span",18),y(2,"i",19),a(3,"span",20),d(4),s()(),a(5,"span",21),y(6,"i",22),a(7,"span",20),d(8),s()()()),n&2){let e=p().$implicit;l(4),P(e.LoginID),l(4),I("",e.StartDisplay.split(" ")[3]," - Now")}}function Mr(n,t){if(n&1){let e=E();a(0,"div",9)(1,"div",10)(2,"div",11)(3,"h5",12),_("click",function(){let o=b(e).$implicit,r=p();return S(r.select(o))}),a(4,"span"),y(5,"i",13),d(6),v(7,"limitTo"),s(),h(8,Sr,1,0,"span",14),s(),a(9,"div",15),_("click",function(){let o=b(e).$implicit,r=p();return S(r.select(o))}),h(10,Pr,3,0,"div")(11,Or,9,2,"div"),s()()()()}if(n&2){let e,i=t.$implicit,o=p();l(),m("ngClass",i.Active?"active":""),l(),m("ngClass",k(9,yr,(i==null?null:i.ID)==(o.selectedRegister==null?null:o.selectedRegister.ID))),l(),m("ngClass",k(11,br,i!=o.selectedRegister)),l(3),P(re(7,6,i.Name,15)),l(2),C(i.State!="Close"?8:-1),l(2),C((e=i.State)==="Close"?10:e==="Open"?11:-1)}}var Fi=class n{constructor(t,e,i,o,r,c,g){this._dialogRef=t;this._outletService=e;this._posService=i;this._userRoleService=o;this.router=r;this.httpService=c;this._odsService=g}searchInputRef;originalSelectedRegister=null;registers;searchInput="";selectedRegister=new ri;modalConfig=T(new Y);role;get AppConfigJSON(){return this._posService.Data.AppConfigJSON}destroy$=new xe;ngOnInit(){this.initModalConfig(),this.subscribeToObsChanges()}ngAfterViewInit(){this.searchInputRef&&this._dialogRef.afterOpened().subscribe(()=>{setTimeout(()=>{this.searchInputRef.nativeElement.focus()},200)})}subscribeToObsChanges(){this._posService.Data$.pipe(Ie(this.destroy$)).subscribe(t=>{this.registers=t.Registers}),this._outletService.Data$.pipe(Ie(this.destroy$)).subscribe(t=>{this.selectedRegister=this.findOutletRegisterById(t.RegisterID),this.originalSelectedRegister=this.selectedRegister?di({},this.selectedRegister):null,this.initModalConfig(!1)}),this._userRoleService.Data$.pipe(Ie(this.destroy$)).subscribe(t=>{this.role=t})}findOutletRegisterById(t){let e=this.registers.find(i=>i.ID===t);return e||new ri}initModalConfig(t=!0){this.modalConfig.update(e=>(e.hideFooter=!0,e.hideScrollbar=!0,e.hideClose=t,e.title="Choose an outlet",e))}ngOnDestroy(){this.destroy$.next(!0),this.destroy$.complete()}onClose(){this._dialogRef.close()}select(t){if(this.AppConfigJSON.ModuleShift.Closure.Enabled)if(this.selectedRegister.ID!=null&&this.selectedRegister.Open&&t.CashierID==null)confirm("You already have an active register with "+this.selectedRegister.Name+`!
2
2
  Do you want to end your session?`)&&(this.onClose(),this.router.navigate(["menu/Shift/Main/My_Shift"],{queryParams:{RegisterID:t.ID}}));else if(!t.Open||this.selectedRegister.ID==t.ID)this.selectedRegister=t,this.onSubmitSelectedRegister();else{if(this.role.SellEditor==!1){alert("You cannot end shift for Register "+t.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:t.ID}})}else this.selectedRegister=t,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(t){let e=this.selectedRegister.ID;if(this.role.SellEditor==!1){alert("You cannot end shift for Register "+t.Name+" - Unauthorized Access");return}e==t.ID?this.router.navigate(["/menu/Shift/Main/My_Shift"]):this.router.navigate(["/menu/Shift/Main/My_Shift"],{queryParams:{RegisterID:t.ID}}),this.onClose()}loadOdsConfig(t){this.httpService.get(`/api/outlet/GetOrderDisplayBroadcastMode?EntityID=${t}`).pipe(ce(e=>{this._odsService.setODSConfig(e.form.OrderDisplayBroadcastMode)})).subscribe()}static \u0275fac=function(e){return new(e||n)(M(Z),M(se),M(X),M(Ne),M(no),M(_e),M(Vi))};static \u0275cmp=N({type:n,selectors:[["pos-modal-register"]],viewQuery:function(e,i){if(e&1&&Dt(_r,5),e&2){let o;vt(o=_t())&&(i.searchInputRef=o.first)}},standalone:!1,decls:13,vars:6,consts:[["searchInputRef",""],[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(e,i){if(e&1){let o=E();a(0,"modal-material",1),_("onClose",function(){return i.onClose()}),a(1,"content")(2,"div",2)(3,"div",3)(4,"span",4),y(5,"i",5),s(),a(6,"input",6,0),Q("ngModelChange",function(c){return b(o),B(i.searchInput,c)||(i.searchInput=c),S(c)}),s()()(),a(8,"div",7)(9,"div",8),z(10,Mr,12,13,"div",9,Se),v(12,"FilterByName"),s()()()()}e&2&&(m("config",i.modalConfig()),l(2),m("hidden",i.registers.length<=6),l(4),j("ngModel",i.searchInput),l(4),K(re(12,3,i.registers,i.searchInput)))},dependencies:[Ee,ve,ge,Me,ie,Oi,wo],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 Dr=["inputCash"],Bi=class n{constructor(t,e,i){this.dialogRef=t;this.data=e;this.focusMonitor=i;this.generateModalTitle$.subscribe()}registerService=O(se);loadPOSService=O(X);register=this.registerService.Data;username=this.loadPOSService?.Data?.UserName;amount=T(0);config=new Y;currentRegisterName;generateModalTitle$=this.registerService.Data$.pipe(ne(t=>u.IsNotEmpty(t)),ce(()=>{let t=this.registerService.getOutletRegister(),e=t?.Name?.length>18?`${t?.Name?.substring(0,18)}...`:t?.Name;this.config.title="Open Shift",this.currentRegisterName=e}),oe());today=new Date;inputCashEl;ngOnInit(){this.config.customWidth="350px",this.config.hideCancel=!0}ngAfterViewInit(){this.focusInput(),this.dialogRef.afterOpened().subscribe(()=>{this.focusInput()})}focusInput(){let t=this.inputCashEl?.nativeElement;t&&(this.focusMonitor.focusVia(t,"program"),t.addEventListener("blur",()=>{this.dialogRef.getState()===0&&this.focusMonitor.focusVia(t,"program")}))}onOk(){this.dialogRef.close({amount:this.amount()})}static \u0275fac=function(e){return new(e||n)(M(Z),M(pe),M(bo))};static \u0275cmp=N({type:n,selectors:[["POS-modal-opening-cash"]],viewQuery:function(e,i){if(e&1&&Dt(Dr,5),e&2){let o;vt(o=_t())&&(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(e,i){if(e&1){let o=E();a(0,"modal-material",1),_("onOk",function(){return i.onOk()})("onCancel",function(){return i.dialogRef.close()})("onClose",function(){return 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),v(18,"date"),s()(),a(19,"tr")(20,"td",3),d(21,"Starting Cash"),s(),a(22,"td",6)(23,"input",7,0),Q("ngModelChange",function(c){return b(o),B(i.amount,c)||(i.amount=c),S(c)}),s()()()()()()}e&2&&(m("config",i.config),l(7),P(i.currentRegisterName),l(5),P(i.username),l(5),P(re(18,5,i.today,"EEEE, HH:mm")),l(6),j("ngModel",i.amount))},dependencies:[ve,ge,Me,ie,Et,Ke],styles:[".table-title-width[_ngcontent-%COMP%]{width:120px}"]})};var Li=class{OrderNumberElement;InvoiceNumberElement;NewOrderID};var Ft=class n{constructor(t,e,i){this._httpService=t;this._onlineStatusService=e;this._localDataService=i;this._onlineStatusService.getOnlineStatus$().subscribe(o=>{this.isOnline=o})}isOnline;GenerateNumber(t,e){if(this.isOnline)return this._httpService.get(U.GenerateNumber,[{key:"EntityID",value:t},{key:"TypeID",value:1}]);{let i=new Li;return u.IsNotEmpty(e.NumberElement)&&(e.NumberElement.Seed+=1),u.IsNotEmpty(e.InvoiceNumberElement)&&(e.InvoiceNumberElement.Seed+=1),i.InvoiceNumberElement=e.InvoiceNumberElement,i.OrderNumberElement=e.NumberElement,i.NewOrderID=u.Guid_NewGuid(),Qe(i)}}findRegisterById(t){return new Promise(e=>{this._localDataService.isConfigFromServer().subscribe(i=>{i?this._httpService.get(U.GetRegisterInfo,[{key:"RegisterID",value:t}]).subscribe(o=>{e(o)}):this._localDataService.findRegisterByID(t).subscribe(o=>{e(o)})})})}recordOpeningCash(t){return ui(this._httpService.post("/API/POS/RecordOpeningCash",t))}static \u0275fac=function(e){return new(e||n)(f(_e),f(be),f(De))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var se=class n{constructor(t,e,i,o,r,c){this._signalRClientService=t;this._matDialog=e;this._posHttpResponseService=i;this._CoreHttpService=o;this._toastrService=r;this._roleService=c}datePipe=O(Ke);_Data=new we(null);Data$=this._Data.asObservable().pipe(ne(t=>t!==null),Fe());get Data(){return this._Data.value}getSalesname(t){return this.Data&&this.Data.ListSales?this._Data.value.ListSales.find(e=>e.ID==t)?.Name:""}setActiveRegisterFromOptions(t,e){let o=this._posHttpResponseService.Data.AppConfigJSON.ModuleShift.Closure.Enabled;if(t.length>1){let r=t.find(c=>c.LoginID==e);if(r)this.pushNewRegister(r);else{let c=this.getOutletRegisterFromLocalStorage(),g=this.Data?.RegisterID?this.Data.RegisterID:c?.ID;t.some(V=>V.ID==g)?o?this.openChooseRegisterModal():this.initRegisterFromLocalStorage():this.openChooseRegisterModal()}}t.length==1&&(this.pushNewRegister(t[0]),u.IsEmpty(t[0].LoginID)&&u.IsEmpty(t[0].CashierID)&&this.openOpeningCashModal(t[0].ID)),t.length==0&&this._toastrService.warning("You do not have access to any OUTLET","Warning")}openChooseRegisterModal(){this._matDialog.open(Fi,{id:"registerModal",disableClose:!0}).afterClosed().pipe(ne(t=>u.IsNotEmpty(t?.selectedRegister))).subscribe(t=>{t.selectedRegister&&this.openOpeningCashModal(t.selectedRegister.ID)})}openOpeningCashModal(t){this._posHttpResponseService.Data.AppConfigJSON.ModuleShift.Closure.Enabled&&this._matDialog.open(Bi,{disableClose:!0}).afterClosed().pipe(ne(o=>u.IsNotEmpty(o))).subscribe(o=>{let r={RegisterID:t,OpAmount:o.amount};this._CoreHttpService.recordOpeningCash(r).then(()=>{this.updateRegisterList(r),this.initCursorFocus(t)})})}updateRegisterList(t){let i=this._posHttpResponseService.Data.Registers.map(r=>r.ID==t.RegisterID?this.mapRegisterAsActiveRegister(r,t):r),o=this._posHttpResponseService.Data;o.Registers=i,this._posHttpResponseService.pushNewValue(o)}mapRegisterAsActiveRegister(t,e){let i=localStorage.getItem("AccountInfo");if(i){let r=JSON.parse(i);t.LoginID=r.UserName}t.OpeningCash=e.OpAmount,t.Open=!0,t.State="Open";let o=this.datePipe.transform(new Date,"dd MM yyyy HH:mm");return t.StartDisplay=o,t}initRegisterFromLocalStorage(){if(this._roleService.Data.DeleteItem==!1){let e=this.getOutletRegisterFromLocalStorage();e&&this.pushNewRegister(e)}}pushNewRegister(t){let e=this._Data.value,i=e?e.RegisterID:null;i!=t.ID&&this._CoreHttpService.findRegisterById(t.ID).then(o=>{o.RegisterCode=t.Code,o.DefaultPrintTemplate=o.PrintTemplate,o.SplitPaymentEnabled=this.findSplitPaymentConfig(o.EntityID),this._signalRClientService.SubscribeGroup(o.RegisterID,i),this.saveOutletRegisterToLocalStorage(t),this.pushNewValue(o)})}getOutletRegister(){let t=this.Data.RegisterID;return this._posHttpResponseService.Data.Registers.find(o=>o.ID==t)}pushNewValue(t){this._Data.next(t)}saveOutletRegisterToLocalStorage(t){if(this._roleService.Data.DeleteItem==!1){let i=JSON.stringify(t);localStorage.setItem("outlet_register",i)}}getOutletRegisterFromLocalStorage(){let t=this._roleService.Data.DeleteItem,e=localStorage.getItem("outlet_register"),i=null;return e&&(t?localStorage.removeItem("outlet_register"):i=JSON.parse(e)),i}findOutletRegisterById(t){return this._posHttpResponseService.Data.Registers.find(o=>o.ID===t)}findSplitPaymentConfig(t){let i=this._posHttpResponseService.Data.Entities.find(o=>o.ID===t);return i?i.SplitPaymentEnabled:!1}initCursorFocus(t){let e=document.getElementById("product");e&&u.IsNotEmpty(t)&&e.focus()}static \u0275fac=function(e){return new(e||n)(f(at),f(ye),f(X),f(Ft),f(L),f(Ne))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var Bt=class{CommissionID;ReturNumber;parkTemporaryItem;posState;InputTextValue;constructor(){this.posState=0,this.CommissionID="",this.ReturNumber="",this.parkTemporaryItem=[],this.InputTextValue=""}};var Hi=class{RegisterID;RegisterCode;EntityID;EntityName;NumberElement;InvoiceNumberElement;ListSales;QuickKeyPack;PrintTemplate;DefaultSalesOrderTag;DefaultTaxType;DefaultWarehouse;MemberPoint;ParkLayoutPack;Promotion;DefaultPrintTemplate;NewOrderID;Payments;SplitPaymentEnabled;constructor(){this.RegisterID=null,this.RegisterCode=null,this.EntityID=null,this.EntityName=null,this.NumberElement=new Nt,this.InvoiceNumberElement=new Nt,this.Promotion=[],this.SplitPaymentEnabled=!0}};var Ht=(c=>(c.Amount="Amount",c.Percentage="Percentage",c.Return="Return",c.ParkedDeletion="ParkedDeletion",c.DeleteItem="DeleteItem",c.FullAccess="FullAccess",c))(Ht||{});var ji=class n{constructor(t,e,i){this._promotionEventService=t;this._dialogRef=e;this.data=i;this.modalConfig=new Y,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=t.selectedPromotion}modalConfig;selectedPromotion;onOk(){this._promotionEventService.restoreOrder(),this._dialogRef.close()}static \u0275fac=function(e){return new(e||n)(M(ke),M(Z),M(pe))};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(e,i){e&1&&(a(0,"modal-material",0),_("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()()()()),e&2&&(m("config",i.modalConfig),l(4),P(i.selectedPromotion==null?null:i.selectedPromotion.Name),l(2),P(i.selectedPromotion==null?null:i.selectedPromotion.Description),l(2),P(i.data==null?null:i.data.message))},dependencies:[ie],encapsulation:2})};var Qi=class extends Te{};var mt=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 le=class n{constructor(t,e,i,o){this._orderDataService=t;this._posService=e;this.POSMATH=i;this.decimalPipe=o;this._orderDataService.Data$.pipe(te(r=>this._posService.Data$.pipe(W(c=>({appConfig:c.AppConfigJSON,salesOrder:r}))))).subscribe(r=>{this.salesOrderData=r.salesOrder,this.appConfigJSON=r.appConfig,this.calculateDiscountAmount(),this.pushNewValue(this.grandTotal)})}_Data=new we(0);Data$=this._Data.asObservable().pipe(Fe());tax=new Bo;discountAfterTax=0;currencySymbol="Rp";get Data(){return this._Data.value}salesOrderData=new $;appConfigJSON=new mt;pushNewValue(t){this._Data.next(t)}get grandTotal(){let t=this.TotalAfterSurcharge;return isNaN(t)?0:t}setDecimalDigit(t){let e=this.decimalPipe.transform(t,"1.0-4");return t=parseFloat(e.split(",").join("")),t}get TotalAfterTax(){let t=this.TaxAmount,e=this.TotalBeforeTax+t;return e=this.POSMATH.Round(e,this.appConfigJSON.ApplicationMath.RoundingDigit.DecimalPlaceValue,this.appConfigJSON.ApplicationMath.RoundingDigit.RoundAlgorithm),e}get TotalBeforeTax(){let t=this.tax?.CalculationTypeID===1,e=0;return t?e=this.DiscountTotal-this.TaxAmount:e=this.DiscountTotal,e}get TotalAfterSurcharge(){let t=this.TotalAfterTax+this.SurchargeAmount;return this.POSMATH.Round(t,this.appConfigJSON.ApplicationMath.RoundingDigit.DecimalPlaceValue,this.appConfigJSON.ApplicationMath.RoundingDigit.RoundAlgorithm)}get TotalAfterDiscountTaxable(){return this.GrossTotalTaxable-this.DiscountTotal}get TaxAmount(){if(this.tax!=null){let t=0,e=this.appConfigJSON.ApplicationMath.RoundingTaxDigit.DecimalPlaceValue,i=this.appConfigJSON.ApplicationMath.RoundingTaxDigit.RoundAlgorithm,o=this.GrossTotalTaxable;return this.tax.CalculationTypeID==1?t=this.tax.Rate/(100+this.tax.Rate)*o:t=this.tax.Rate/100*o,t=this.POSMATH.Round(t,e,i),t}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 t=this.salesOrderData.Order.DiscountAmount,e=0;this.AfterDiscount2Amount>=0&&t>0&&t>this.AfterDiscount2Amount&&(e=this.AfterDiscount2Amount),e!==0&&e<=t&&this.GrossTotal!==0&&(t=e),this.salesOrderData.Order.DiscountAmount=t}get GrossTotal(){return this.sum(this.salesOrderData.CartItems,"Total")}get GrossTotalTaxable(){let t=this.salesOrderData.CartItems.filter(i=>i.Taxable),e=this.sum(t,"Total");if(t.length!==0){let i=this.calculateDiscountTaxableItem(t);e=e*(100-this.salesOrderData.Order.Discount)/100,e=e*(100-this.salesOrderData.Order.Discount2)/100,e=e-i}return e}calculateDiscountTaxableItem(t){let e=this.GrossTotal,i=this.salesOrderData.Order.DiscountAmount,o=0,r=0,c=0,g=0;for(let x of t)o=x.getItemAfterDiscount/e,r=o*i,g=r*x.Quantity,c+=g;return c}get GrossTotalNonTaxable(){let t=this.salesOrderData.CartItems.filter(i=>i.Taxable==!1),e=this.sum(t,"Total");return e=e*(100-this.salesOrderData.Order.Discount)/100,e=e*(100-this.salesOrderData.Order.Discount2)/100,e=e-this.salesOrderData.Order.DiscountAmount,e}sum(t,e){let i=t.reduce((o,r)=>o+r[e],0);return i=this.setDecimalDigit(i),i}GetPointOnlyAmount(){let t=this.salesOrderData.CartItems.filter(e=>e.Variant.PaymentTypeID==2);return this.GetAmountByCart(t)}GetCashOnlyAmount(){let t=this.salesOrderData.CartItems.filter(e=>e.Variant.PaymentTypeID==1);return this.GetAmountByCart(t)}GetCashAndPointAmountCart(){let t=this.salesOrderData.CartItems.filter(e=>e.Variant.PaymentTypeID!=1);return this.GetAmountByCart(t)}GetAmountByCart(t){let e=this.sum(t,"Total");return e=e*(100-this.salesOrderData.Order.Discount)/100,e=e*(100-this.salesOrderData.Order.Discount2)/100,e}calculateGrossTotal(t){return this.sum(t,"Total")}static \u0275fac=function(e){return new(e||n)(f(H),f(X),f(Lo),f(G))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var Ui=class{Code;Provider;OutletID;Customer;ShoppingCart};var Qt=class n{salesOrderService=O(H);registerService=O(se);customerService=O(Re);orderCalculator=O(le);generateRedeemCouponDto(t,e){let i=new Ui,o=this.registerService.Data?.EntityID;return i.Code=t,i.Provider=e,i.ShoppingCart={Amount:this.orderCalculator.Data,Items:this.generateItems()},i.OutletID=o,i.Customer=this.generateCustomer(e),i}generateItems(){return this.salesOrderService.Data.CartItems.map(i=>({ItemTemporaryID:i.ItemTemporaryID,Price:i.Price,Quantity:i.Quantity,VariantID:i.VariantID,Code:i?.Variant?.Code,Discount:i.Discount,DiscountAmount:i.DiscountAmount,PriceBookID:i.PriceBookID,UnitPriceOriginal:i.UnitPriceOriginal,UnitPrice:i.UnitPrice,CategoryID:i?.Variant?.CategoryID}))}generateCustomer(t){let e=this.customerService.Data,i=this.salesOrderService?.Data?.Order?.CustomerID,o=null;return u.IsNotEmpty(i)&&(o={Phone:e.Mobile,Email:e.Email},t==="Internal"&&(o=di({ID:i},o))),o}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};function Ir(n,t){if(n&1&&(a(0,"span",5),d(1),v(2,"number"),s()),n&2){let e=p().$implicit;l(),I("",D(2,1,e.Amount),"%")}}function Tr(n,t){if(n&1&&(a(0,"span",5),d(1),v(2,"number"),s()),n&2){let e=p().$implicit;l(),I(" -",D(2,1,e.Amount)," ")}}function wr(n,t){}function Er(n,t){if(n&1){let e=E();a(0,"button",8),_("click",function(){b(e);let o=p().$implicit,r=p();return S(r.onApplyCouponDiscount(o))}),d(1," Apply "),s()}}function Rr(n,t){if(n&1&&(a(0,"tr")(1,"td"),d(2),s(),a(3,"td"),d(4),s(),a(5,"td",4),d(6),v(7,"number"),s(),a(8,"td",4),h(9,Ir,3,3,"span",5)(10,Tr,3,3,"span",5),s(),a(11,"td",6),h(12,wr,0,0)(13,Er,2,0,"button",7),s()()),n&2){let e=t.$implicit,i=p();l(2),P(e==null?null:e.Name),l(2),P(e==null?null:e.Code),l(2),P(D(7,5,e==null?null:e.Price)),l(3),C((i.coupon==null?null:i.coupon.Type)==i.couponType.Percentage?9:10),l(3),C((e==null?null:e.CouponDiscount)>0?12:13)}}var Wi=class n{dialogRef=O(Z);coupon=O(pe);salesOrderModelService=O(H);config;couponType=Ht;itemsOptions=J(()=>{let t=this.salesOrderModelService?.Data?.CartItems,e=this.coupon?.ApplyToProduct??[];return e=e.filter(o=>o.UserOption),e.map(o=>{let r=t.find(c=>c.Variant.ID===o.ID);return r&&(o.Name=r.Variant?.Name,o.Price=r.Variant?.UnitPrice),o})});ngOnInit(){this.initModalConfig()}initModalConfig(){this.config=new Y,this.config.title="Choose Item to Apply Discount",this.config.hideFooter=!0}onApplyCouponDiscount(t){this.dialogRef.close(t)}onClose(){this.dialogRef.close()}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=N({type:n,selectors:[["app-modal-selected-coupon-item-v2"]],decls:17,vars:1,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-success"],[1,"btn","btn-sm","btn-success",3,"click"]],template:function(e,i){e&1&&(a(0,"modal-material",0),_("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(),y(13,"th",3),s()(),a(14,"tbody"),z(15,Rr,14,7,"tr",null,Le),s()()()()),e&2&&(m("config",i.config),l(15),K(i.itemsOptions()))},dependencies:[me,No,G],encapsulation:2})};var Ut=class n{httpService=O(_e);promotionCouponFactoryService=O(Qt);salesOrderService=O(H);userRoleService=O(Ne);dialog=O(ye);posConfig=O(X);calculatorService=O(le);toastr=O(L);separateQuantityToNewRow=J(()=>this.posConfig.Data?.AppConfigJSON?.ModuleSell?.PromotionCouponSeparateQuantityToNewRow);_appliedCoupon=T(null);appliedCoupon=J(()=>this._appliedCoupon());salesOrderBeforePromotion=T(null);originalRoleData=J(()=>fe(At,this.userRoleService.Data));redeemCoupon(t,e){t=this.trimInputCoupon(t);let i=this.promotionCouponFactoryService.generateRedeemCouponDto(t,"Internal");return this.httpService.post(U.ValidateInternalCouponV2,i).pipe(ce(o=>{o.Note=e||"",o.Code=t,this.copyOriginalSalesOrder(),this.applyCoupon(o)}))}trimInputCoupon(t){return u.IsNotEmpty(t)&&(t=t.trim()),t}applyCoupon(t){switch(t.Type){case"Percentage":this.applyDiscountPercentage(t);break;case"Amount":this.applyDiscountAmount(t);break;case"Return":this.handleCouponReturnAccess(t);break;case"DeleteItem":this.handleDeleteItemAccess(t);break;case"ParkedDeletion":this.handleCouponParkedDeletionAccess(t);break;case"FullAccess":this.handleFullAccess(t);break}this._appliedCoupon.set(t)}applyDiscountPercentage(t){let e=t.ApplyToProduct??[];e.some(o=>u.IsNotEmpty(o.UserOption))?this.openDialogSelectItem(t):e.length>0?this.applyDiscountToProduct(t,e):this.applyDiscountToOrder(t)}applyDiscountAmount(t){let e=t.ApplyToProduct??[];e.some(o=>u.IsNotEmpty(o.UserOption))?this.openDialogSelectItem(t):e.length>0?this.applyDiscountToProduct(t,e):this.applyDiscountToOrder(t)}openDialogSelectItem(t){this.dialog.open(Wi,{data:t}).afterClosed().pipe(ne(e=>u.IsNotEmpty(e))).subscribe(e=>{this.applyDiscountToSelectedItem(t,e)})}applyDiscountToSelectedItem(t,e){this._appliedCoupon.update(i=>(i.ApplyToProduct=i.ApplyToProduct.map(o=>(e.ID==o.ID&&(o.SelectedItem=!0),o)),i)),this.applyDiscountToProduct(t,[e])}applyDiscountToOrder(t){let e=this.salesOrderService.Data;switch(t.Type){case"Amount":e.Order.DiscountAmount=t.Amount;break;case"Percentage":let i=this.calculateMaxDiscountInvoice(t);i.type=="amount"?e.Order.DiscountAmount=i.discount:e.Order.Discount=i.discount;break}e.Order.PromotionCoupon=t.Code,e.Order.PromotionNote=t.Note,e.Order.CouponType=1,this.salesOrderService.pushNewValue(e),this.showToastrAppliedCoupon(t)}calculateMaxDiscountInvoice(t){if(t.MaxDiscount>0){let e=t.Amount;return this.calculatorService.Data*e/100>t.MaxDiscount?{discount:t.MaxDiscount,type:"amount"}:{discount:t.Amount,type:"percentage"}}else return{discount:t.Amount,type:"percentage"}}applyDiscountToProduct(t,e){let i=this.salesOrderService.Data,o=i.CartItems,r=[];o=o.map(c=>{let g=this.findPromotionItemByVariantID(c,e);if(g.isMatch){let x=e[g.index];if(this.separateQuantityToNewRow()&&c.Quantity>1&&x.OneFirstOption){let V=this.separateItemQuantityToNewRow(x,c,t);c=V.originalItem,V.separatedItem&&r.push(V.separatedItem)}else{let V=this.calculateOneOfFirstDisc(x,c.Quantity);x.Amount=V,c=this.applyDiscountToItem(c,x,t)}}return c}),o=o.concat(r),i.CartItems=o,i.Order.PromotionCoupon=t.Code,i.Order.PromotionNote=t.Note,i.Order.CouponType=1,this.salesOrderService.pushNewValue(i),this.showToastrAppliedCoupon(t)}separateItemQuantityToNewRow(t,e,i){let o=e.Quantity,r=fe(Te,e);return o>1?(e.Quantity=o-1,r.Quantity=1,r=this.applyDiscountToItem(r,t,i)):e=this.applyDiscountToItem(e,t,i),{originalItem:e,separatedItem:r}}calculateOneOfFirstDisc(t,e){let i=t.Amount;return t.OneFirstOption&&(i=t.Amount/e),i}applyDiscountToItem(t,e,i){switch(i.Type){case"Amount":t.DiscountAmount=e.Amount;break;case"Percentage":if(i.MaxDiscount>0)if(this.calculateDiscountItem(t,e.Amount)>i.MaxDiscount){let r=i.MaxDiscount/t.Quantity;t.DiscountAmount=r}else t.Discount=e.Amount;else t.Discount=e.Amount;break}return t}calculateDiscountItem(t,e){return t.Price*t.Quantity*e/100}findPromotionItemByVariantID(t,e){let i=e.findIndex(o=>o.ID==t.VariantID&&o.ItemTemporaryID==t.ItemTemporaryID);return{isMatch:i>-1,index:i}}handleCouponReturnAccess(t){let e=fe(At,this.originalRoleData());e.Return=!0,this.userRoleService.pushNewValue(e),this.applyCouponToSalesOrder(t)}handleDeleteItemAccess(t){let e=fe(At,this.originalRoleData());e.DeleteItem=!0,this.userRoleService.pushNewValue(e),this.applyCouponToSalesOrder(t)}handleCouponParkedDeletionAccess(t){let e=fe(At,this.originalRoleData());e.ParkedDeletionAuthorized=!0,this.userRoleService.pushNewValue(e),this.applyCouponToSalesOrder(t)}handleFullAccess(t){let e=fe(At,this.originalRoleData());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.applyCouponToSalesOrder(t)}resetCouponOnNewTransaction(){this.userRoleService.pushNewValue(this.originalRoleData()),this._appliedCoupon.set(null)}setCouponOnEdit(t){t&&u.IsNotEmpty(t?.Type)&&(this._appliedCoupon.set(t),this.generateOriginalSalesOrderOnEdit())}generateOriginalSalesOrderOnEdit(){let t=fe($,this.salesOrderService.Data);t.Order.PromotionCoupon=null,t.Order.PromotionNote=null,t.Order.Discount=0,t.Order.DiscountAmount=0,this.salesOrderBeforePromotion.set(t)}removeAppliedCoupon(){this.salesOrderService.pushNewValue(this.salesOrderBeforePromotion()),this.appliedCoupon().Type!="Amount"&&this.appliedCoupon().Type!="Percentage"&&this.userRoleService.pushNewValue(this.originalRoleData()),this._appliedCoupon.set(null),this.salesOrderBeforePromotion.set(null)}copyOriginalSalesOrder(){let t=fe($,this.salesOrderService.Data);this.salesOrderBeforePromotion.set(t)}applyCouponToSalesOrder(t){let e=this.salesOrderService.Data;e.Order.PromotionCoupon=t.Code,e.Order.PromotionNote=t.Note,e.Order.CouponType=1,this.salesOrderService.pushNewValue(e),this.showToastrAppliedCoupon(t)}showToastrAppliedCoupon(t){t.Notification?this.toastr.success(t.Notification,"Coupon Applied"):this.toastr.success("Coupon applied successfully!","Coupon Applied")}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var ut=class n{constructor(t,e,i,o,r,c,g,x,V,q){this.variantService=t;this._posService=e;this._orderDataService=i;this.toastr=o;this._orderProcessorService=r;this._customerHttpService=c;this.promotionCouponServiceV2=g;this.promotionCouponExternalService=x;this.userRoleService=V;this.decimalPipe=q;this.subscribeToObservable()}dialog=O(ye);salesOrderData;appConfigJson;entityID;audio=new Audio;priceMinimumRestrictionWarning=T("");subscribeToObservable(){this._posService.Data$.pipe(oe()).subscribe(t=>{this.appConfigJson=t.AppConfigJSON}),this._orderDataService.Data$.pipe(oe()).subscribe(t=>{this.salesOrderData=t,this.entityID=t.Order.EntityID}),this._orderProcessorService.Data$.pipe(oe()).subscribe(t=>{t.posState==3&&this.clearCartItemsInLocalStorage()})}addCartItemById(t,e,i=!0){return new Promise((o,r)=>{this.variantService.findVariantByID(t,this.entityID,i).then(c=>{this.isShoppingCartLockedByPromotionCoupon()==!1&&this.createNewCartItem(c,e),o(c)}).catch(c=>{r(c)})})}addCartItemByCode(t){return new Promise((e,i)=>{let o=this.appConfigJson.ModuleSell.DigitalScale;o.Digit>0&&u.IsNotEmpty(o.Regex)&&t.length==o.Digit?this.parseDigitalScaleBarcodeWithRegex(t,o).then(c=>{c||(this.toastr.info("Matching Regex Rule to Barcode","Digital Scale"),this.findVariantByCode(t).then(g=>e(g)).catch(g=>i(g)))}):this.findVariantByCode(t).then(c=>e(c)).catch(c=>i(c))})}findVariantByCode(t){let e=this.appConfigJson.ModuleSell.BarcodeSerialEnabled;return new Promise((i,o)=>{this.variantService.findVariantByCode(t,this.entityID,e).then(r=>{i(r),this.isShoppingCartLockedByPromotionCoupon()==!1&&this.createNewCartItem(r)}).catch(r=>{this.playBellRing(),o(r)})})}addItemBySerial(t){this.variantService.findVariantBySerial(t,this.entityID).subscribe(e=>{let i=this.salesOrderData.CartItems;if(i.length>0){let o,r=[],c=i.findIndex(g=>g.Variant.ID==e.ID);r=[],c!==-1?(o=i[c].Serial?.findIndex(g=>g.Number==t),r=[...i[c].Serial?i[c].Serial:[]],o==-1?(r.push({Number:t,Quantity:1}),i[c].Quantity=r.length):r.length>0?r[o].Quantity+=1:(r=[{Number:t,Quantity:1}],this.addNewSerials(e,t)),i[c].Serial=[...r],i[c].Quantity=i[c].calculateSerialQty(),this.updateCartItem(i[c],c)):this.addNewSerials(e,t)}else this.addNewSerials(e,t)})}addNewSerials(t,e){t.Serial=[{Number:e,Quantity:1}],this.createNewCartItem(t)}playBellRing(){this.audio.src="https://cdn.dealpos.xyz/web-audio/bell_ring.mp3",this.audio.load(),this.audio.play()}updateCartItem(t,e){this.isShoppingCartLockedByPromotionCoupon()==!1&&(this.salesOrderData.CartItems[e]=t,this._orderDataService.pushNewValue(this.salesOrderData),this.applyCustomerPoint(),this.saveItemsToLocalStorage())}deleteCartItem(t){this.isShoppingCartLockedByPromotionCoupon()==!1&&(this.salesOrderData.CartItems=this.salesOrderData.CartItems.filter(e=>e!==t),this._orderDataService.pushNewValue(this.salesOrderData),this.applyCustomerPoint())}parseDigitalScaleBarcodeWithRegex(t,e){return new Promise(i=>{let o=this.appConfigJson.ModuleSell.BarcodeSerialEnabled,r=new RegExp(e.Regex),c=t.match(r);if(console.log(c),u.IsNotEmpty(c)){let g=c[1],x=parseFloat(c[2]);console.log(x,"productQuantity"),x=x/e.QuantityDivider,this.variantService.findVariantByCode(g,this.entityID,o).then(V=>{this.createNewCartItem(V,null,x),i(!0)}).catch(()=>{i(!1)})}else i(!1)})}createNewCartItem(t,e,i){let o=new Te,r=this.appConfigJson.ModuleSell.ProductNotes.CopyProductDescription,c=this.appConfigJson.ModuleSell.ProductNotes.CopyPromotionName;o.patchByVariant(t,r,c),o=this.applyReward(o,e),u.IsEmpty(e)&&(o=this.applyPriceBook(o)),this.validateCartItem(o)&&(o.Quantity=i||o.Quantity,e?.PromotionType==2?this.handlingPromotionQuantity(o):this.pushNewItemToArray(o,o.PromotionGift),this.applyCustomerPoint()),this.addAvailableComponent(o)}applyCustomerPoint(){let t=this.salesOrderData.Order.CustomerID,e=u.IsEmpty(t);this._orderProcessorService.reedemPointToDiscount(e)}handlingPromotionQuantity(t){let e=fe(Te,this.salesOrderData.CartItems),i=e.findIndex(o=>o.VariantID==t.VariantID&&o.PromotionGift);i!==-1?e[i].Quantity+=t.Quantity?t.Quantity:1:e=[...e,t],this.salesOrderData.CartItems=e,this._orderDataService.pushNewValue(this.salesOrderData)}applyPromotionProduct(t){let e=t.Variant.DiscountAmount;return e&&(t.Price=t.UnitPriceOriginal-e),t}applyReward(t,e){if(e){let i=this.appConfigJson.ModuleSell.ProductNotes.CopyPromotionName;t.Discount=e.Discount,t.Price=e.OriginalPrice;let o=e.OriginalPrice-e.UnitPrice;t.Price=t.UnitPriceOriginal-o,t.UnitPrice=t.UnitPriceOriginal-o,t.PromotionGift=!0,t.PromotionID=e.PromotionID,t.Quantity=e.Quantity?e.Quantity:1,t.PriceTypeID=3,t.Cost+=e.ExtraCost,t.UnitCost+=e.ExtraCost,t.PriceNote=e.PromotionName,i&&(t.Note=`${t.Note?t.Note:""} ${e.PromotionName} `)}return t}addAvailableComponent(t){let e=t.Price!=0,i=this.appConfigJson.ModuleSell.SellProductComponentDefaultPrice,o=t.Variant;if(o.Component!=null&&o.Component.length>0)for(let r of o.Component){let c=new Qi;c.patchByVariant(r),c.Quantity=t.Quantity*r.Quantity,e&&!i&&(r.UnitPrice=0),c.Price=r.UnitPrice,this.pushNewItemToArray(c)}}pushNewItemToArray(t,e=!1){if(this.isShoppingCartLockedByPromotionCoupon()==!1){let i=this.salesOrderData.CartItems.findIndex(o=>o.VariantID==t.VariantID);if(t=this.applyPromotionProduct(t),i==-1||e){let o=this.salesOrderData.CartItems.length;t.ItemTemporaryID=o,this.salesOrderData.CartItems.push(t)}else{let o=this.appConfigJson.ModuleSell.QuickKey.NewRowBehaviour;if(o==2){let r=this.salesOrderData.CartItems.length;t.ItemTemporaryID=r,this.salesOrderData.CartItems.push(t)}else if(o==1)this._orderProcessorService.Data.posState==4?this.salesOrderData.CartItems.push(t):this.addingQuantityItem(i,t);else{if(!this.validatePrepaidPackage(t,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,t)}}this._orderDataService.pushNewValue(this.salesOrderData),this.saveItemsToLocalStorage()}}saveItemsToLocalStorage(){let t=this.userRoleService.Data.DeleteItem,e=this._orderProcessorService.Data?.posState;if(!t&&e!==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(g){console.error("Error saving cart items to localStorage:",g)}}}clearCartItemsInLocalStorage(){localStorage.getItem("cart_items")&&(this.userRoleService.Data?.DeleteItem?this.clearCartItemsBasedOnCoupon():this.clearCartItemsStorage())}clearCartItemsBasedOnCoupon(){let t=this.promotionCouponServiceV2?.appliedCoupon();t&&(t?.Type=="FullAccess"||t?.Type=="DeleteItem")&&this.clearCartItemsStorage()}clearCartItemsStorage(){try{localStorage.removeItem("cart_items")}catch(t){console.error("Error clearing cart items from localStorage:",t)}}validatePrepaidPackage(t,e){let i=this.salesOrderData.CartItems[e],o=this._orderProcessorService.Data.posState,r=t.Variant.TypeID==10,c=u.IsNotEmpty(i.ID),g=!0;return o==2&&r&&c&&(g=!1),g}addingQuantityItem(t,e){let i=this.salesOrderData.CartItems.filter(g=>g.VariantID==e.VariantID),o=i.length,r=i.find(g=>!g.PromotionGift);this.salesOrderData.CartItems[t].PromotionGift&&o==1?this.salesOrderData.CartItems.push(e):(r.Quantity+=e.Quantity,r=this.applyPromotionProduct(r)),r&&(r=this.applyPriceBook(r))}validateCartItem(t){return t.Variant.CategoryTypeID==-1?(this.toastr.info(t.Variant.Name+" cannot be sold, check Category "+t.Variant.CategoryName+" settings","info"),!1):!!this.validateSerialItem(t)}validatePriceMinimum(t){let e=this.checkPriceMinimumRestriction(t);if(e)this.priceMinimumRestrictionWarning.set("");else{let i=this.appConfigJson.ModuleSell?.ProductDialog?.MinimumPriceIncludeDiscount,o=this.getPriceMinimum(t),r=this.generateMinimumPriceWarningMessage(i,o,t);this.priceMinimumRestrictionWarning.set(r)}return e}checkPriceMinimumRestriction(t){let e=!0,i=this.userRoleService.Data.PriceMinimum,r=this.appConfigJson.ModuleSell?.ProductDialog?.MinimumPriceIncludeDiscount?t.TotalAfterDiscountPerQuantity:t.Price;if(i){let c=this.getPriceMinimum(t);r<c?e=!1:e=!0}return e}getPriceMinimum(t){let e=this.appConfigJson.ModuleSell.ProductDialog?.PriceMinimumTypeID,i=0;switch(e){case 1:i=t.Variant?.UnitPrice;break;case 2:i=t.Variant?.UnitCost;break;case 3:i=t.Variant?.UnitPriceMinimum;break}return i}generateMinimumPriceWarningMessage(t,e,i){let o="",r=i.Discount,c=i.DiscountAmount;return t&&(r>0||c>0)?o=u.StringFormat(`<span><i class='fa-solid fa-triangle-exclamation me-2 d-inline'></i>Item net price is <h5 class='d-inline m-0'>{0}</h5></span>
3
3
  after item discount, you cannot sell lower than <h5 class='d-inline m-0'>{1}</h5></span>`,this.decimalPipe.transform(i.TotalAfterDiscountPerQuantity),this.decimalPipe.transform(e)):o=u.StringFormat("<span><i class='fa-solid fa-triangle-exclamation me-2 d-inline'></i>Cannot sell lower than <h5 class='d-inline m-0'>{0}</h5></span>",this.decimalPipe.transform(e)),o}validateSerialItem(t){let e=!0;if(t?.Serial?.length>0&&t.Variant.TypeID==4&&t.Quantity>0){let i=0;t?.Serial?.forEach(o=>{i+=o.Quantity}),i!=t.Quantity&&(this.toastr.error("Serial must be equal with the quantity","Error"),e=!1)}return e}isShoppingCartLockedByPromotionCoupon(){let t=this.promotionCouponServiceV2.appliedCoupon(),e=this.promotionCouponExternalService.coupon,i=!1;if((u.IsNotEmpty(t)||u.IsNotEmpty(e))&&this.isNonAuthorizedCouponType){i=!0;let r=this._orderDataService.Data.Order.PromotionCoupon;this.dialog.open(Ii,{id:"ShoppingCartLocked",data:{title:"Shopping Cart Locked",message:`
4
4
  <div class="d-flex justify-content-center my-4">
@@ -14,7 +14,7 @@ Do you want to end your session?`)&&(this.onClose(),this.router.navigate(["menu/
14
14
  `,headerType:de.Warning},width:"31rem"})}return i}applyPriceBook(t){let e=t.Variant.PriceBook!=null?t.Variant.PriceBook:[],i=this.findCustomerPricebook(e);if(e&&e.length!==0){let o=e.sort(function(r,c){return c.MinimumQuantity-r.MinimumQuantity}).filter(r=>t.Quantity>=r.MinimumQuantity&&r.MinimumQuantity!=0);o.length>0||u.IsNotEmpty(i)?u.IsNotEmpty(i)?t=this.applyPricebookToItem(t,i):t=this.applyPricebookToItem(t,o[0]):t=this.resetAppliedPricebook(t)}return t}resetAppliedPricebook(t){let i=(t?.Variant?.PriceBook).find(o=>o.ID==t.PriceBookID);return u.IsNotEmpty(i)&&(t.Discount=t.Variant.PriceDiscount,t.PriceBookID=u.GuidEmpty,t.Price=t.Variant.UnitPrice,t.UnitPrice=t.Variant.UnitPrice,t.PriceTypeID=0,t=this.applyPromotionProduct(t),t=this.removePromotionNote(t)),t}removePromotionNote(t){let e=this.appConfigJson.ModuleSell.ProductNotes;if(this.appConfigJson?.ModuleSell?.Pricebook?.PricebookVisible&&(t.Note=t.Note?.replace(t.PriceNote,""),t.PriceNote=""),e.CopyPromotionName){let o=t.Variant?.PriceNote;t.Note=`${o||""} ${t.Note?t.Note:""}`,t.PriceNote=o}return t}applyPricebookToItem(t,e){return t.Discount=e.PriceDiscount,t.UnitPrice=e.UnitPrice,t.PriceBookID=e.ID,t.Price=e.UnitPrice,t.PriceTypeID=2,t=this.assignItemNote(t,e),t}assignItemNote(t,e){return this.appConfigJson?.ModuleSell?.Pricebook?.PricebookVisible?(t.Note?.includes(t.PriceNote)?t.Note=t.Note?.replace(t.PriceNote,e.Name):t.Note=`${e.Name} ${t.Note?t.Note:""}`,t.PriceNote=e.Name):(t.Note="",t.PriceNote=""),t}findCustomerPricebook(t=[]){let e=this._customerHttpService.Data,i;return e&&(i=t.find(o=>o.ID==e.PricebookID)),i}get isNonAuthorizedCouponType(){let t=this.promotionCouponExternalService.coupon||this.promotionCouponServiceV2?.appliedCoupon();return t?["Amount","Percentage"].some(o=>o===t.Type):!1}static \u0275fac=function(e){return new(e||n)(f(Fo),f(X),f(H),f(L),f(je),f(Re),f(Ut),f(Gi),f(Ne),f(G))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};function Vr(n,t){if(n&1&&(a(0,"div",2)(1,"div",4),y(2,"input",8),s()()),n&2){let e=p();l(2),m("formControl",e.searchControl)}}function Fr(n,t){n&1&&(a(0,"span"),d(1,"Apply"),s())}function Br(n,t){n&1&&(a(0,"span"),d(1,"Applying..."),s())}function Lr(n,t){if(n&1){let e=E();a(0,"tr")(1,"td"),d(2),s(),a(3,"td"),d(4),s(),a(5,"td",9),d(6),v(7,"number"),s(),a(8,"td",9),d(9),v(10,"number"),s(),a(11,"td",10)(12,"button",11),_("click",function(){let o=b(e).$implicit,r=p();return S(r.onSelectReward(o))}),h(13,Fr,2,0,"span"),h(14,Br,2,0,"span"),s()()()}if(n&2){let e=t.$implicit,i=p();l(2),P(e.VariantName),l(2),P(e.VariantCode),l(2),P(D(7,7,e.OriginalPrice)),l(3),P(D(10,9,e.UnitPrice)),l(3),m("disabled",i.isApplyingReward()),l(),C(i.isApplyingReward()?-1:13),l(),C(i.isApplyingReward()?14:-1)}}var qi=class n{constructor(t,e,i,o,r,c){this._dialogRef=t;this._matDialog=e;this._shoppingCartService=i;this._promotionEventService=o;this._toastr=r;this.data=c;this.selectedPromotion=this._promotionEventService.selectedPromotion}modalConfig=new Y;selectedPromotion;rewards$;searchControl=new Ge;isApplyingReward=T(!1);ngOnInit(){this.modalConfig.title="Select a Reward",this.modalConfig.hideFooter=!0,this.initRewards(!0)}initRewards(t){this.rewards$=this.searchControl.valueChanges.pipe(fi(""),Pt(t?0:500),Fe(),te(e=>{let i;return i=Qe(this.data.rewards).pipe(W(o=>o.filter(r=>this.findKeywordInValue(e,r?.VariantCode)||this.findKeywordInValue(e,r?.VariantName)))),t=!0,i}))}findKeywordInValue(t,e){return e?.toUpperCase()?.indexOf(t?.toUpperCase())>-1}onSelectReward(t){return mi(this,null,function*(){if(!this.isApplyingReward()){this.isApplyingReward.set(!0);try{t.PromotionType=this.data.promotion.TypeID,yield this._shoppingCartService.addCartItemById(t.VariantID,t,!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(e){return new(e||n)(M(Z),M(ye),M(ut),M(ke),M(L),M(pe))};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(e,i){e&1&&(a(0,"modal-material",0),_("onCancel",function(){return i.close()})("onClose",function(){return i.close()}),a(1,"content")(2,"div",1),h(3,Vr,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(),y(17,"th",7),s()(),a(18,"tbody"),z(19,Lr,15,11,"tr",null,Se),v(21,"async"),v(22,"sortBy"),s()()()()()()()),e&2&&(m("config",i.modalConfig),l(3),C((i.data==null||i.data.rewards==null?null:i.data.rewards.length)>5?3:-1),l(16),K(xt(22,4,D(21,2,i.rewards$),"desc","VariantCode")))},dependencies:[ve,ge,st,ie,He,G,Rt],styles:[".table-scroll[_ngcontent-%COMP%]{max-height:400px;overflow-y:auto}table[_ngcontent-%COMP%]{max-width:600px!important;overflow-x:hidden}"]})};function Hr(n,t){if(n&1&&(a(0,"div",3)(1,"div",5),y(2,"input",10),s()()),n&2){let e=p();l(2),m("formControl",e.searchCtrl)}}function jr(n,t){n&1&&(a(0,"th",9),d(1,"Qty"),s())}function Qr(n,t){n&1&&y(0,"th",8)}function Ur(n,t){if(n&1){let e=E();a(0,"td")(1,"input",13),Q("ngModelChange",function(o){b(e);let r=p().$implicit;return B(r.Quantity,o)||(r.Quantity=o),S(o)}),s()()}if(n&2){let e=p().$implicit;l(),j("ngModel",e.Quantity)}}function Wr(n,t){n&1&&(a(0,"span"),d(1,"Apply"),s())}function Gr(n,t){n&1&&(a(0,"span"),d(1,"Applying..."),s())}function $r(n,t){if(n&1){let e=E();a(0,"td",12)(1,"button",14),_("click",function(){b(e);let o=p().$implicit,r=p();return S(r.onApplyReward(o))}),h(2,Wr,2,0,"span"),h(3,Gr,2,0,"span"),s()()}if(n&2){let e=p(2);l(),m("disabled",e.isApplyingReward()),l(),C(e.isApplyingReward()?-1:2),l(),C(e.isApplyingReward()?3:-1)}}function qr(n,t){if(n&1&&(a(0,"tr")(1,"td"),d(2),s(),a(3,"td"),d(4),s(),a(5,"td",11),d(6),v(7,"number"),s(),a(8,"td",11),d(9),v(10,"number"),s(),h(11,Ur,2,1,"td")(12,$r,4,3,"td",12),s()),n&2){let e=t.$implicit,i=p();l(2),P(e.VariantName),l(2),P(e.VariantCode),l(2),P(D(7,5,e.OriginalPrice)),l(3),P(D(10,7,e.UnitPrice)),l(2),C(i.rewardQuantity>1?11:12)}}var Ji=class n{constructor(t,e,i,o,r,c){this.data=t;this.shoppingCartService=e;this.promotionEventService=i;this.dialogRef=o;this.matDialog=r;this.toastr=c;this.searchCtrl=new Ge,this.rewardQuantity=t.rewardQuantity,this.sourceRewards=[...t.rewards]}modalConfig;rewards$;rewardQuantity;rewards;sourceRewards=[];searchCtrl;isApplyingReward=T(!1);ngOnInit(){this.initModalConfig(),this.initSearchCtrl(!0)}initModalConfig(){this.modalConfig=new Y,this.modalConfig.title="Select a Reward",this.rewardQuantity<2&&(this.modalConfig.hideFooter=!0)}initSearchCtrl(t){this.rewards$=this.searchCtrl.valueChanges.pipe(fi(""),Pt(t?0:500),Fe(),te(e=>{let i;return i=Qe(this.sourceRewards).pipe(W(o=>(o.length===1&&(o[0].Quantity=this.rewardQuantity),o)),W(o=>o.filter(r=>this.findKeywordInValue(e,r?.VariantCode)||this.findKeywordInValue(e,r?.VariantName)))),t=!1,i}),ce(e=>{this.rewards=e}))}findKeywordInValue(t,e){return e?.toUpperCase()?.indexOf(t.toUpperCase())>-1}onApplyReward(t){return mi(this,null,function*(){if(!this.isApplyingReward()){this.isApplyingReward.set(!0);try{yield this.addRewardToShoppingCart(t)}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 t=0;return this.rewards.forEach(e=>{t+=e.Quantity?e.Quantity:0}),t}addRewardToShoppingCart(t){return t.PromotionType=this.data.promotion.TypeID,this.shoppingCartService.addCartItemById(t.VariantID,t,!0).then(()=>{this.matDialog.closeAll(),this.promotionEventService.pushNewValue(this.promotionEventService.Data)})}static \u0275fac=function(e){return new(e||n)(M(pe),M(ut),M(ke),M(Z),M(ye),M(L))};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(e,i){e&1&&(a(0,"modal-material",0),_("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,Hr,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,jr,2,0,"th",9)(21,Qr,1,0,"th",8),s()(),a(22,"tbody"),z(23,qr,13,9,"tr",null,Se),v(25,"async"),v(26,"sortBy"),s()()()()()()()),e&2&&(m("config",i.modalConfig),l(3),I(" ( ",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),K(xt(26,6,D(25,4,i.rewards$),"desc","VariantCode")))},dependencies:[ve,ge,Me,st,ie,Et,He,G,Rt],encapsulation:2})};var ke=class n{constructor(t,e,i,o,r,c,g,x,V){this._orderDataService=t;this._outletService=e;this._invoiceCalculatorService=i;this._dialog=o;this._httpService=r;this._posService=c;this._toastr=g;this._signalrService=x;this.decimalPipe=V;this.previousQuantity=0,this.previousTotalEligible=0,this.subscribeNotification(),this._posService.Data$.subscribe(q=>{this.taxes=q.Taxes}),this._outletService.Data$.subscribe(q=>{this.loadPromotions(q.Promotion)}),this._orderDataService.Data$.pipe(ne(q=>{this.salesOrderData=q;let Oe=this.calculateOrderReward(q.getRewards()),ci=this.calculateOrderReward(this.previousRewards);return this.previousQuantity!=q.TotalQuantity||ci<Oe||this.isRestroreOrder}),Pt(100)).subscribe(q=>{this.isRestroreOrder=!1,this.checkQtyPromotion(),this.applyQuantityPromotion(),this.previousRewards=[...q.getRewards()]}),this._invoiceCalculatorService.Data$.subscribe(q=>{this.checkEligiblePromotionWithMinSpend()})}_Data=new we([]);get Data(){return this._Data.getValue()}Data$=this._Data.asObservable();selectedPromotion=null;onClickToastPromo=new xe;previousQuantity;salesOrderData;orderDataBeforePromotion;taxes=[];previousTotalEligible;previousRewards=[];isRestroreOrder=!1;calculateOrderReward(t){let e=0;return t.length>0&&(e=t.map(i=>i.Quantity).reduce((i,o)=>i+o)),e}checkQtyPromotion(){let t=this._orderDataService.Data;this.checkEligibleQtyPromotion(t.CartItems),this.checkEligibleTierPromotion(t.CartItems),this.previousQuantity=t.TotalQuantity}subscribeNotification(){this._signalrService.OnPromotionEventChange.pipe(oe(),te(()=>{let t=this._outletService.Data?.RegisterID;return this.getPromotions(t)})).subscribe(()=>{this._toastr.info("Promotion Event Updated","Promotion Update")})}getPromotions(t){return this._httpService.get(U.GetListPromotion,[{key:"RegisterID",value:t}]).pipe(ce(e=>{this.loadPromotions(e)}))}loadPromotions(t){let e=this.getPromotionDesc(t);this.pushNewValue(e),this.checkQtyPromotion(),this.checkEligiblePromotionWithMinSpend()}pushNewValue(t){this.showToastEligiblePromotion(),this._Data.next(t)}checkSelectedPromotionRequirement(t){this.selectedPromotion!=null&&this.selectedPromotion.TypeID==t&&this.Data.find(i=>i.ID===this.selectedPromotion.ID)?.Eligible===!1&&(this._dialog.open(ji,{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(t=[]){return t?.map(i=>(i.Description=this.generatePromotionDesc(i),i))}checkEligiblePromotionWithMinSpend(){let t=this._invoiceCalculatorService.Data,e=this.Data?.filter(o=>(o.TypeID===1||o.TypeID==3)&&!this.checkExpiredPromotion(o)).map(o=>(t>=o.MinimumAmount?o.Eligible=!0:o.Eligible=!1,o)),i=this.mappingEligiblePromotion(e);this.pushNewValue(i),this.checkSelectedPromotionRequirement(1),this.checkSelectedPromotionRequirement(3)}checkEligibleQtyPromotion(t){let e=0,i=this.Data?.filter(r=>r.TypeID===2&&!this.checkExpiredPromotion(r)).map(r=>(r.Eligible=!1,r.ListVariant.length>0?(e=this.getQuantityByRequirementType(t,"variant",r.ListVariant),e>=r.MinimumAmount&&(r.Eligible=!0)):r.ListCategory.length>0?(e=this.getQuantityByRequirementType(t,"category",r.ListCategory),e>=r.MinimumAmount&&(r.Eligible=!0)):this.salesOrderData.TotalQuantity>=r.MinimumAmount&&(r.Eligible=!0),r)),o=this.mappingEligiblePromotion(i);this.pushNewValue(o)}checkEligibleTierPromotion(t){let e,i=this.Data?.filter(r=>r.TypeID===5&&!this.checkExpiredPromotion(r)).map(r=>(r.Eligible=!1,r.ListVariant.length>0?e=this.getQuantityByRequirementType(t,"variant",r.ListVariant):r.ListCategory.length>0?e=this.getQuantityByRequirementType(t,"category",r.ListCategory):e=this.salesOrderData.TotalQuantity,r.PromotionTieredQuantity.forEach(c=>{e>=c.Quantity&&(r.Eligible=!0)}),r)),o=this.mappingEligiblePromotion(i);this.pushNewValue(o)}getQuantityByRequirementType(t,e,i){let o=0,r;return e=="variant"?t.forEach(c=>{r=i.findIndex(g=>g.ID===c.VariantID),r!==-1&&(o+=c.Quantity)}):t.forEach(c=>{c.Variant&&(r=i.findIndex(g=>g.ID===c.Variant.CategoryID),r!==-1&&(o+=c.Quantity))}),o}mappingEligiblePromotion(t=[]){let e=this.Data;if(t?.length>0){let i;e=this.Data?.map(o=>(i=t.findIndex(r=>r.ID==o.ID),i!==-1&&(o=t[i]),o))}return e}checkExpiredPromotion(t){let e=new Date,i=new Date(t.StartDate),r=(u.IsEmpty(t.StartTime)?"00:00:00":t.StartTime).split(":").map(V=>parseInt(V));i.setHours(r[0],r[1],r[2]);let c=new Date(t.ExpirationDate),x=(u.IsEmpty(t.EndTime)?"23:59:59":t.EndTime).split(":").map(V=>parseInt(V));return c.setHours(x[0],x[1],x[2]),!(e.getTime()>=i.getTime()&&e.getTime()<=c.getTime())}showToastEligiblePromotion(){let t=this._orderDataService.Data.Order,e=this.getTotalEligiblePromotion(),i=u.IsNotEmpty(t.ID),o=this._orderDataService.Data.getRewards()?.length>0;this.previousTotalEligible!==e&&e>0&&(!i||!(i&&o))&&this._toastr.info(e+" promotion(s) can be applied!","Promo available!",{timeOut:2e4}).onTap.pipe(Ue(1)).subscribe(()=>{this.onClickToastPromo.next(!0)}),this.previousTotalEligible=e}getTotalEligiblePromotion(){return this.Data?.filter(e=>e.Eligible).length}generatePromotionDesc(t){let e="";switch(t.TypeID){case 2:e+="Minimum "+this.decimalPipe.transform(t.MinimumAmount)+" ",t.ListVariant.length>0?(e=e+" piece of ",e+=this.generateItemListDescription(t.ListVariant)):t.ListCategory.length>0?(e+="from category ",e+=this.generateItemListDescription(t.ListCategory)):e+="items";break;case 1:e+="Minimum spend Rp. "+this.decimalPipe.transform(t.MinimumAmount);break;case 3:e+=`Apply
15
15
  ${t.Discount1!==0?"discount1 = "+t.Discount1+"%":""}
16
16
  ${t.Discount1!==0&&t.Discount2!==0?" and ":""}
17
- ${t.Discount2!==0?"discount2 = "+t.Discount2+"%":""}`}return e}generateItemListDescription(t){let e="";for(let i of t)e+=e==""?"":" or ",e+=`[${i.Name}]`;return e=this.slicePromotionDesc(e),e}slicePromotionDesc(t){return t.length>200&&(t=t.slice(0,200),t+="..."),t}applyPromotion(t){switch(this.orderDataBeforePromotion=Kt($,this.salesOrderData),this.selectedPromotion,this.selectedPromotion=t,t.TypeID){case 1:this.applyProductReward(t);break;case 2:switch(t.RewardTypeID){case 1:this.applyQuantityPromotion();break;case 2:this.applyCheapestReward(t);break}break;case 3:this.applyDiscountReward(t);break;case 4:break;case 5:this.applyTierReward(t);break}}applyProductReward(t){this.getRewards$(t).subscribe(e=>{this.openDialogSelectReward(e)})}openDialogSelectReward(t){this._dialog.open(qi,{data:{rewards:t.rewards,promotion:t.promotion}})}applyCheapestReward(t){let e=this.salesOrderData.CartItems;if(e.length>0){let o=e.sort((c,g)=>c.Price-g.Price)[0],r=o.Total;o.Quantity>1&&(r=o.Total/o.Quantity,r=r/o.Quantity),o.DiscountAmount=r,o.Note=t.Name,e=e.map(c=>(c.VariantID==o.VariantID&&(c=o,c.PromotionGift=!0),c)),this.salesOrderData.CartItems=e,this._orderDataService.pushNewValue(this.salesOrderData),this.showToastAppliedPromo(this.selectedPromotion)}}applyDiscountReward(t){let i=this._posService.Data.AppConfigJSON.ModuleSell.ProductNotes.CopyPromotionName;if(this.salesOrderData.Order.Discount=t.Discount1,this.salesOrderData.Order.Discount2=t.Discount2,this.salesOrderData.Order.Discount>100&&(this.salesOrderData.Order.Discount=100),i==!0&&(this.salesOrderData.Order.Note=t.Name),u.IsNotEmpty(t.TaxTypeID)){let o=this.taxes.find(r=>r.ID==t.TaxTypeID);this._invoiceCalculatorService.tax=o,this.salesOrderData.Order.TaxTypeID=t.TaxTypeID}this._orderDataService.pushNewValue(this.salesOrderData),this.pushNewValue(this.Data),this.showToastAppliedPromo(this.selectedPromotion)}applyTierReward(t){let e=this.salesOrderData.CartItems,i=[];t.ListVariant.length>0?i=e.filter(o=>t.ListVariant.findIndex(r=>r.ID==o.VariantID)!==-1):i=e.filter(o=>t.ListCategory.findIndex(r=>r.ID==o.Variant.CategoryID)!==-1),i.length==0?e=this.tierPromotionBlankRequirement(t):e=this.tierPromotionWithRequirement(t,i),this.salesOrderData.CartItems=e,this._orderDataService.pushNewValue(this.salesOrderData)}tierPromotionBlankRequirement(t){let e=this.salesOrderData.CartItems,i=this.salesOrderData.TotalQuantity;return t.PromotionTieredQuantity.sort((o,r)=>o.Quantity-r.Quantity).forEach(o=>{i>=o.Quantity&&(e=e.map(r=>(r.Discount=o.Discount,r=this.copyPromotionNameToItem(t,r),r)))}),e}tierPromotionWithRequirement(t,e){let i=0,o=this.salesOrderData.CartItems;e.forEach(c=>{i+=c.Quantity}),t.PromotionTieredQuantity.sort((c,g)=>c.Quantity-g.Quantity).forEach(c=>{i>=c.Quantity&&(e=e.map(g=>(g.Discount=c.Discount,g)))});let r;return o=o.map(c=>(r=e.find(g=>g==c),r&&(c=r,c=this.copyPromotionNameToItem(t,c)),c)),o}copyPromotionNameToItem(t,e){return this._posService.Data.AppConfigJSON.ModuleSell.ProductNotes.CopyPromotionName==!0&&(e.Note=t.Name),e}removePromotion(){this._orderDataService.pushNewValue(this.orderDataBeforePromotion),this.showToastRemovePromo(this.selectedPromotion),this.selectedPromotion=null}showToastAppliedPromo(t){this._toastr.success("Applied "+t.Name+" to order!","Applied successfully!")}showToastRemovePromo(t){this._toastr.info("Removed "+t.Name+" from order!","Removed successfully!")}applyQuantityPromotion(){if(this.selectedPromotion){let t=this.salesOrderData.getRewards();switch(this.selectedPromotion.TypeID){case 2:this.selectedPromotion.MultipleApply?this.calculateQtyMultiplyPromotion([this.selectedPromotion],t):(t.length==0&&this.applyQuantityReward(this.selectedPromotion,1),this.checkSelectedPromotionRequirement(2));break;case 5:this.applyTierReward(this.selectedPromotion),this.checkSelectedPromotionRequirement(5);break}}}calculateQtyMultiplyPromotion(t,e){let i=fe(Te,this.salesOrderData.CartItems),o,r=[],c=0,g;t.forEach(x=>{r=i.filter(V=>(x.RequirementTypeID==0?o=x.ListVariant.findIndex(q=>q.ID==V.VariantID):o=x.ListCategory.findIndex(q=>q.ID==V.Variant.CategoryID),o!==-1)),g=e.filter(V=>V.PromotionID==x.ID),c=this.calculateQtyMultiply(r,x.MinimumAmount),this.showModalSelectReward(g,c,x)})}showModalSelectReward(t,e,i){let o=0;if(t.forEach(r=>o+=r.Quantity),e>o){let r=e-o;this.applyQuantityReward(i,r)}else if(e<o){this.selectedPromotion.Eligible=!1;let r=this.mappingEligiblePromotion([this.selectedPromotion]);this.pushNewValue(r),this.checkSelectedPromotionRequirement(2)}}applyQuantityReward(t,e){e>0&&this.getRewards$(t).subscribe(i=>{this._dialog.open(Ji,{data:{promotion:t,rewardQuantity:e,rewards:i.rewards}})})}calculateQtyMultiply(t,e){if(t.length>0){let o=t.filter(r=>r.PromotionGift==!1).map(r=>r.Quantity).reduce((r,c)=>r+c)/e;return this.getFirstNumber(o)}else return 0}getFirstNumber(t){let e=t.toString().split(".");return Number(e[0])}getRewards$(t){return this._httpService.get(U.GetRewardByPromotionID,[{key:"ID",value:t.ID}]).pipe(W(e=>({rewards:e.Rewards,promotion:t})))}static \u0275fac=function(e){return new(e||n)(f(H),f(se),f(le),f(ye),f(_e),f(X),f(L),f(at),f(G))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var zi=class{RegisterID;Number;Amount;TransactionID};var Wt=class{GroupID;Method;Data};var Ki=class{Status;InvoiceID;LoyaltyPoint;diff};var Yi=class{GopayQr};var Zi=class{Name;Quantity;Discount;DiscountAmount;Price;UnitQuantity};var Xi=class{Items;AmountSummary;GopayQr;Number;Customer;SalesName;CurrencySymbol;FinalAmount};var en=class n{_state=T(this.initCustomerDisplayState());isEnabled=J(()=>this._state()?.enabled);connect(){let e={enabled:!0,timestamp:new Date().toDateString()};localStorage.setItem("customerDisplay",JSON.stringify(e)),this._state.set(e)}initCustomerDisplayState(){let t=localStorage.getItem("customerDisplay"),e={enabled:!1,timestamp:""};return u.IsNotEmpty(t)&&(e=JSON.parse(t)),e}disconnect(){let e={enabled:!1,timestamp:new Date().toDateString()};localStorage.setItem("customerDisplay",JSON.stringify(e)),this._state.set(e)}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var Pe=class{Amount;CurrencySymbol;Label;Type;constructor(t,e,i,o){this.Amount=t,this.CurrencySymbol=e,this.Label=i,this.Type=o}};var tn=class n{constructor(t,e,i,o){this._invoiceCalculatorService=t;this._decimalPipe=e;this._poshttpResponseService=i;this._orderService=o;this._poshttpResponseService.Data$.pipe(oe()).subscribe(r=>{this.appConfig=r.AppConfigJSON})}appConfig=new mt;generateAmountSummary(){let t=[];this.isUseTax()?t=this.generateSummaryTax():t=this.generateSummaryNonTax();let e=this.generateSurchargeSummary();return e&&t.push(...e),t}generateSummaryTax(){let t=this._invoiceCalculatorService.tax?.CalculationTypeID,e=[];return t==1?e=this.generateSummaryTaxInclude():e=this.generateSummaryTaxExclude(),e}generateSummaryNonTax(){let t=[],e=this.generateCartItemAmount();if(t.push(e),this.isDiscounted()){let i=this.generateDiscountSummary(),o=this.generateAmountTotal("Total");t.push(...i,o)}return t}generateSummaryTaxInclude(){let t=[];return this.isTaxReserveSequence()?t=this.generateTaxIncludeReserveSequence():t=this.generateTaxIncludeNormalSequence(),t}generateTaxIncludeReserveSequence(){let t=[];if(this.isTaxDetailVisible()==!1){let r=this._invoiceCalculatorService.TotalBeforeTax,c=this.isDiscounted()?"Amount":"Before Tax",g=this.isDiscounted()?this._invoiceCalculatorService.GrossTotal:r,x=new Pe(g,this.currencySymbol,c,2);t.push(x)}if(this.isDiscounted()){let r=this.generateDiscountSummary(),c=this.generateBeforeTaxSummary();t.push(...r,c)}let i=this.generateTax(),o=this.generateAmountTotal();return t.push(...i,o),t}generateTaxIncludeNormalSequence(){let t=[],e=this.generateCartItemAmount();if(t.push(e),this.isDiscounted()){let o=this.generateDiscountSummary(),r=this.generateSummarySubTotal();t.push(...o,r)}let i=this.generateTax();if(t.push(...i),this.isTaxDetailVisible()==!1){let o=this.generateBeforeTaxSummary();t.push(o)}return t}generateSummaryTaxExclude(){let t=[],e=this.generateCartItemAmount(!0);if(t.push(e),this.isDiscounted()){let c=this.generateDiscountSummary(),g=this.generateSummarySubTotal();t.push(...c,g)}let i=this.generateTax(),o=this._invoiceCalculatorService.TotalAfterTax,r=new Pe(o,this.currencySymbol,"Total",1);return t.push(...i,r),t}generateAmountTotal(t="Total Amount"){let e=this._invoiceCalculatorService.Data;return new Pe(e,this.currencySymbol,t,1)}generateSummarySubTotal(){let t=this._invoiceCalculatorService.TotalAfterTax;return new Pe(t,this.currencySymbol,"SubTotal",1)}generateBeforeTaxSummary(){let t=this._invoiceCalculatorService.TotalBeforeTax;return new Pe(t,this.currencySymbol,"Before Tax",2)}isTaxDetailVisible(){return this.appConfig.PrintConfigInvoice?.Footer?.TaxDetailVisible}isUseTax(){let t=this._invoiceCalculatorService.tax;return t?.PrintVisible&&t?.Rate!=0}generateTax(){let t=[],e=this.isTaxDetailVisible(),i=e?2:1,o=this._invoiceCalculatorService.tax;if(e){let r=this.appConfig.PrintConfigInvoice.Footer.TaxableSales,c=this.calculateTaxableSales(),g=new Pe(c,this.currencySymbol,r,i);t.push(g)}if(o.TypeID==2){let r=this.generateTaxTypeMultiple();t.push(...r)}else{let r=this.generateSingleTaxSummary(o.Label,this._invoiceCalculatorService.TaxAmount,i);t.push(r)}if(e){let r=this.appConfig.PrintConfigInvoice.Footer.TaxExemptSales,c=this._invoiceCalculatorService.GrossTotalNonTaxable,g=new Pe(c,this.currencySymbol,r,i);t.push(g);let x=this.appConfig.PrintConfigInvoice.Footer.LabelWithZeroAmount;if(x){let V=new Pe(0,this.currencySymbol,x,i);t.push(V)}}return t}generateCartItemAmount(t=!1){let e=this.isDiscounted()||t?this._invoiceCalculatorService.GrossTotal:this._invoiceCalculatorService.TotalAfterTax;return new Pe(e,this.currencySymbol,"Amount",1)}get currencySymbol(){return this._invoiceCalculatorService.currencySymbol}generateDiscountSummary(){let t=[];if(this._invoiceCalculatorService.Discount1Amount!=0){let e=this._decimalPipe.transform(this._orderService.Data.Order.Discount),o=this.checkDiscountIgnoreDecimal(e)?"{0}":"{0} ({1}%)";t.push(new Pe(this._invoiceCalculatorService.Discount1Amount*-1,this._invoiceCalculatorService.currencySymbol,u.StringFormat(o,this.appConfig.CorePrint.Alias.Discount1,e),1))}if(this._invoiceCalculatorService.Discount2Amount!=0){let e=this._decimalPipe.transform(this._orderService.Data.Order.Discount2),o=this.checkDiscountIgnoreDecimal(e)?"{0}":"{0} ({1}%)";t.push(new Pe(this._invoiceCalculatorService.Discount2Amount*-1,this._invoiceCalculatorService.currencySymbol,u.StringFormat(o,this.appConfig.CorePrint.Alias.Discount2,e),1))}return this._orderService.Data.Order.DiscountAmount!=0&&this.appConfig.PrintConfigInvoice.ItemsFooter.DiscountAmountVisible&&t.push(new Pe(this._orderService.Data.Order.DiscountAmount*-1,this._invoiceCalculatorService.currencySymbol,"Discount ("+this._invoiceCalculatorService.currencySymbol+")",1)),t}calculateTaxableSales(){let t=this._invoiceCalculatorService.tax,e=this._invoiceCalculatorService.TaxAmount,i=this._invoiceCalculatorService.GrossTotalTaxable;return t.Rate==0?0:t.CalculationTypeID==1?i-e:i}generateTaxTypeMultiple(){let t=this.appConfig.PrintConfigInvoice.Footer.TaxDetailVisible?2:1,e=[],i=this._invoiceCalculatorService.tax;var o=this._invoiceCalculatorService.TaxAmount;if(i.TypeID==2){let r=i?.Components?i?.Components:[],c=this._invoiceCalculatorService.GrossTotalTaxable,g=this.calculateTotalRate(r);r.forEach(x=>{if(i.CalculationTypeID==0){let V=x.Rate/100*c;e=[...e,this.generateSingleTaxSummary(x.Label,V,t)],i.MultipleTaxTypeID==1&&(c+=V)}else{let V=x.Rate/g*o;e=[...e,this.generateSingleTaxSummary(x.Label,V,t)]}})}else e=[...e,this.generateSingleTaxSummary(i.Label,o,t)];return e}calculateTotalRate(t){let e=0;return t&&t.length>0&&(e=t.map(i=>i.Rate).reduce((i,o)=>i+o)),e}generateSingleTaxSummary(t,e,i){let o=this._invoiceCalculatorService.currencySymbol;return new Pe(e,o,t,i)}generateSurchargeSummary(){if(this._invoiceCalculatorService.SurchargeAmount==0)return;let t=[],e=this.appConfig.CorePrint,i=e&&e.Alias.SurchargePcg?e.Alias.SurchargePcg:"Surcharge";t.push(new Pe(this._invoiceCalculatorService.SurchargeAmount,this._invoiceCalculatorService.currencySymbol,u.StringFormat("{0} ({1}%)",i,this._decimalPipe.transform(this._orderService.Data?.Invoice.SurchargePcg)),1));let o=this.generateAmountTotal();return t.push(o),t}checkDiscountIgnoreDecimal(t){let i=this.appConfig.PrintConfigInvoice.Footer.DiscountIgnoredDecimal,o=parseFloat(t)%1,r=!1;return o!==0&&i&&(r=!0),r}isDiscounted(){let t=this._invoiceCalculatorService.Discount1Amount,e=this._invoiceCalculatorService.Discount2Amount,i=this._orderService.Data.Order.DiscountAmount,o=!1;return(t!=0||e!=0||i!=0)&&(o=!0),o}isTaxReserveSequence(){let t=this._invoiceCalculatorService.tax,e=!!t,i=e?t.CalculationTypeID:null,o=this.appConfig.PrintConfigInvoice.ItemsFooter.TaxIncludeBeforeTotalAmount;return e&&i===1&&o}static \u0275fac=function(e){return new(e||n)(f(le),f(G),f(X),f(H))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var gt=class n{constructor(t,e,i,o){this._receiptCalculatorService=t;this._cashierCalculatorService=e;this._signal=i;this._customerHttpService=o;this.broadcastOrderUpdate$.subscribe()}_salesOrderDataModelService=O(H);_outletService=O(se);displayService=O(en);localdata=O(De);orderDataModel;broadcastOrderUpdate$=Je([this._salesOrderDataModelService.Data$,this.localdata.isStoreOrderInServer(),yo(this.displayService.isEnabled)]).pipe(Un(([t,e,i])=>{let o=this._outletService?.Data?.RegisterID;if(e&&i&&o){this.orderDataModel=t;let r=this.ConstructCartModelForCustomerDisplay(),c=new Wt;return c.GroupID=o+"_Subscriber",c.Method="POSCartAmountUpdated",c.Data=r,this._signal.broadcast(c).pipe(nt(g=>(console.log(g),bt)))}else return bt}),nt(t=>(console.log(t),bt)),oe());ConstructCartModelForCustomerDisplay(){let t=this._customerHttpService.Data,e=new Xi;e.Number=this.orderDataModel.Order.Number,e.Items=Array();for(let i of this.orderDataModel.CartItems){let o=new Zi;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,e.Items.push(o)}return u.IsNotEmpty(this.orderDataModel.Order.SalesID)?e.SalesName=this._outletService.getSalesname(this.orderDataModel.Order.SalesID):e.SalesName="",u.IsNotEmpty(this.orderDataModel.Order.CustomerID)&&u.IsNotEmpty(t)&&(e.Customer=new kt,e.Customer.Email=t.Email,e.Customer.Mobile=t.Mobile,e.Customer.Name=this.orderDataModel.ContactName),e.CurrencySymbol=this._cashierCalculatorService.currencySymbol,e.FinalAmount=this._cashierCalculatorService.Data,e.AmountSummary=this._receiptCalculatorService.generateAmountSummary(),e}BroadcastStateToCustomerDisplay(t,e="",i="",o=0){let r=new Ki;r.Status=t,r.InvoiceID=e,r.LoyaltyPoint=i,r.diff=o;let c=new Wt;return c.GroupID=this._outletService.Data.RegisterID+"_Subscriber",c.Method="POSStateUpdated",c.Data=r,this.displayService.isEnabled()?this.localdata.isStoreOrderInServer().pipe(te(g=>g?this._signal.broadcast(c):Qe(ae.offlineMode))):bt}BroadcastQRToCustomerDisplay(t){let e=new Yi;e.GopayQr=t;let i=new Wt;return i.GroupID=this._outletService.Data.RegisterID+"_Subscriber",i.Method="POSQRPaymentActivated",i.Data=e,this.displayService.isEnabled()?this.localdata.isStoreOrderInServer().pipe(te(o=>o?this._signal.broadcast(i):Qe(ae.offlineMode))):bt}static \u0275fac=function(e){return new(e||n)(f(tn),f(le),f(at),f(Re))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var nn=class n{constructor(t){this.httpService=t}VerifyPayment(t,e){let i=this.getVerifyPaymentUrl(e);return this.httpService.post(i,t)}getVerifyPaymentUrl(t){let e;switch(t){case 0:e=U.GopayVerifyPayment;break;case 1:e=U.BcaVerifyPayment;break}return e}generateLink(t){return this.httpService.post(U.GenerateLink,t)}generateQRCode(t,e){return this.httpService.post(t,e)}static \u0275fac=function(e){return new(e||n)(f(_e))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var Gt=class n{constructor(t,e,i,o,r){this._posHubService=t;this._orderDataService=e;this._PaymentHttpService=i;this._InvoicecashierCalculatorService=o;this._toastrService=r}transactionId;qrPaymentMethodID;QRCodeHttpResponse;_paymentMethod;get paymentMethod(){return this._paymentMethod}resetPaymentMethod(){this._paymentMethod=null}onQRPaymentComplete(t,e){return new Promise((i,o)=>{if(t.transaction_id!==this.transactionId){let c=`transaction_id: ${t.transaction_id} / gross_amount: ${t.gross_amount}`;o({header:"Invalid QR Payment",message:c});return}if(t.gross_amount!==this._InvoicecashierCalculatorService.Data){let c=`paid_amount: ${t.gross_amount} vs invoice_amount: ${this._InvoicecashierCalculatorService.Data}`;o({header:"Invalid QR Payment",message:c});return}let r=this._orderDataService.Data.Order.Number;if(t.order_id.includes(r)==!1){let c=`Order ID: ${t.order_id} vs Order Number: ${r}`;o({header:"Invalid QR Payment",message:c});return}if(t.transaction_status!=="settlement"){let c=`Transaction status is ${t.transaction_status}`;o({header:"Invalid QR Payment",message:c});return}this.validateEMoneyPayment(e).subscribe(c=>{i(c)})})}generateNewPayment(t,e){let i=this._orderDataService.Data;u.IsEmpty(this.qrPaymentMethodID)&&alert("QR PaymentMethod.ID is not available!");let o=new Ye;return o.PaidAmount=e,o.Amount=e,o.Date=i.Order.Date,o.MethodID=this.qrPaymentMethodID,o.Code=t,u.IsEmpty(t)&&this._toastrService.warning("Midtrans transaction_id is empty. Please verify manually!","Mobile Payment Failure"),o}sendStateCompleteToCustomerDisplay(t){this._posHubService.BroadcastStateToCustomerDisplay(1,t.ObjectID,t.LoyaltyPoint,0).subscribe()}generateQR(t,e){this._paymentMethod=e,this.qrPaymentMethodID=e.ID;let i=this.getServiceUrl(e.EMoneyTypeID);return this._PaymentHttpService.generateQRCode(i,t).pipe(W(c=>(c=this.manipulateBCAQrisImg(c,e.EMoneyTypeID),this.transactionId=c.Transaction_id,this.QRCodeHttpResponse=c,this._orderDataService.transaction_id=c.Transaction_id,this.sendQRToCustomerDisplay(c.Url),c)))}sendQRToCustomerDisplay(t){this._posHubService.BroadcastQRToCustomerDisplay(t).subscribe()}validateEMoneyPayment(t){if(u.IsNotEmpty(this.transactionId)){let e=this._InvoicecashierCalculatorService.Data,i=this._paymentMethod?.EMoneyTypeID,o=this.generatePaymentVerificationData(e,i);return this._PaymentHttpService.VerifyPayment(o,i).pipe(te(r=>(this.updatePosDataForSubmission(e),Qn(this._orderDataService.submitOrder(t)).pipe(ce(c=>{this.sendStateCompleteToCustomerDisplay(c)})))))}else{let e=new Error("Transaction ID is Empty");throw St(()=>e)}}generatePaymentVerificationData(t,e){let i=this._orderDataService.Data,o=new zi;return o.Number=i.Order.Number,o.Amount=t,o.TransactionID=this.transactionId,o.RegisterID=i.Order.RegisterID,e==1&&(o.Number=this.QRCodeHttpResponse.Number),o}updatePosDataForSubmission(t){let e=this._orderDataService.Data,i=this.generateNewPayment(this.transactionId,t),o=[];o.push(i),e.Invoice.Due=null,e.Action.Type=3,e.Order.InvoicedStateID=3,e.Payments=o,this._orderDataService.pushNewValue(e)}getServiceUrl(t){let e;switch(t){case 0:e=U.GenerateGopayQrCode;break;case 1:e=U.GenerateBcaQrCode;break}return e}manipulateBCAQrisImg(t,e){return e==1&&(t.Url=`data:image/png;base64, ${t.Url}`),t}clearTransactionID(){this.transactionId=null,this._orderDataService.transaction_id=null,this.QRCodeHttpResponse=null}getTransactionId(){return this.transactionId}static \u0275fac=function(e){return new(e||n)(f(gt),f(H),f(nn),f(le),f(L))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var je=class n{constructor(t,e,i,o,r,c,g,x,V,q,Oe,ci,Hn,ur){this._orderDataService=t;this._posHttpResponseService=e;this._CoreHttpService=i;this._outletService=o;this._orderHttpService=r;this._signal=c;this._promotionEventService=g;this._promotionCouponService=x;this._customerHttpService=V;this._invoiceCalculatorService=q;this._dialog=Oe;this._toastr=ci;this._paymentGatewayService=Hn;this.roleService=ur;this.subscribeObservableChanges(),this._signal.OnContactReceive.subscribe(xn=>{if(!u.IsEmpty(xn)){let In=JSON.parse(xn);this._orderDataService.updateCustomerID(In.ID).then(jn=>{this.posData.ContactName=In.Name,this._customerHttpService.Data=jn,this.pushNewValue(this.Data)})}})}_Data=new we(new Bt);_clearOrder=new xe;get clearOrder$(){return this._clearOrder.asObservable()}get Data(){return this._Data.value}Data$=this._Data.asObservable();posData=new $;activeRegister=new Hi;subscribeObservableChanges(){this._orderDataService.Data$.pipe(oe()).subscribe(t=>{this.posData=t}),this._outletService.Data$.pipe(ne(t=>t?.RegisterID!==this.activeRegister?.RegisterID),oe()).subscribe(t=>{this.activeRegister=t,this.Data.posState!=2?this.createNewSalesOrderDataModel():this.setPrintTemplateToDefault(this.posData.Order.TypeID)})}pushNewValue(t){this._Data.next(t)}createNewTransactionInSameOutletRegister(t=!0){if(t){let e=this._orderDataService.Data.Order.EntityID;this._CoreHttpService.GenerateNumber(e,this.activeRegister).subscribe(i=>{this.activeRegister.NumberElement=i.OrderNumberElement,this.activeRegister.InvoiceNumberElement=i.InvoiceNumberElement,this.activeRegister.NewOrderID=i.NewOrderID,this.refreshLoader(),this.pushNewValue(new Bt),this.createNewSalesOrderDataModel()})}else this.pushNewValue(new Bt),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&&u.IsEmpty(i.LoginID)&&this._posHttpResponseService.requestObservable().subscribe()}}updatePosState(t,e){e&&this._orderHttpService.pushNewValue(e),this.Data.posState=t,this.pushNewValue(this.Data)}ReturnOrder(t){t&&(this.posData.CartItems=fe(Te,t.CartItems),this.posData.CartItems=this.posData.CartItems.map(e=>(e.Quantity=e.Quantity*-1,e.Variant.TypeID==4&&(e.Serial=e.Serial.map(i=>(i.Quantity=i.Quantity*-1,i))),e)),this.posData.Invoice.ReferenceInvoiceID=t.Invoice.ID,this.posData.Order.Discount=t.Order.Discount,this.posData.Order.Discount2=t.Order.Discount2,this.posData.Order.DiscountAmount=t.Order.DiscountAmount*-1,this.posData.Order.TaxTypeID=t.Order.TaxTypeID,this.posData.Order.SalesID=t.Order.SalesID,this.posData.Order.CustomerID=t.Order.CustomerID,this.posData.ContactName=t.ContactName,this.posData.Order.PointUsed=t.Order.PointUsed*-1,this.initSelectedTax(),this._orderDataService.pushNewValue(this.posData))}plainToClass(t,e){if(this.posData=Kt($,t),this.assignInvoice(t),this.assignCustomerData(t),this.initSelectedRegister(t,e),this.assignParkTemporaryItem(t),this.assignOrderCurrency(this.posData.Order.CurrencyID),this.initPromotionGift(),e==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 t=this.posData.CartItems;t=t.map(e=>(e.PromotionGift=e.PriceTypeID==3,e))}initSelectedTax(){let t=this.posData.Order.TaxTypeID;this._invoiceCalculatorService.tax=this.getTaxObjectByID(t);let e=this._invoiceCalculatorService.tax;u.IsEmpty(e)&&this.showModalSuspendedDefaultTax()}assignInvoice(t){if(t.Invoice){let e=t.Invoice.Due,i=t.Invoice.Date,o=e!=u.MinDate&&u.IsNotEmpty(e)?new Date(t.Invoice.Due):null,r=i!=u.MinDate&&u.IsNotEmpty(i)?new Date(t.Invoice.Date):new Date;t.Invoice.Due=o,t.Invoice.Date=r,this.posData.Invoice=t.Invoice,this.posData.Action.Type=3}else{let e=this.activeRegister;this.posData.Invoice=new Yt,u.IsNotEmpty(e.InvoiceNumberElement)&&(this.posData.Invoice.Number=Nt.Generate(e.InvoiceNumberElement))}}assignCustomerData(t){let e=t.Order.CustomerID,i=t.Order.EntityID;u.IsNotEmpty(e)&&u.IsNotEmpty(i)?ui(this._customerHttpService.GetPrivilegeByID(e,i)).then(o=>{let c=this._posHttpResponseService.Data.AppConfigJSON.ApplicationLoyalty.Label,g=o;g.Label=c,g.DebtCalculated=g.Debt,g=this.calculateCustomerDebt(t,g),this._customerHttpService.Data=g,this.pushNewValue(this.Data)}):this.Data.InputTextValue=null}calculateCustomerDebt(t,e){let i=t.Payments,o=u.IsNotEmpty(t.Invoice.ID);return i.length==0&&o&&(e.DebtCalculated=e.Debt-t.Invoice.Sales),e}initSelectedRegister(t,e){if(e!==4){let i=this._posHttpResponseService.Data.Registers;i.length>0?this.checkAccessOutletUser(t,i):this._toastr.warning("You do not have access to edit in this outlet","Warning")}else{let i=this.activeRegister.RegisterID;i!==t.Order.RegisterID&&(this.posData.Order.RegisterID=i,this._toastr.warning("You are processing order from different Register","Different Register"))}}checkAccessOutletUser(t,e){let i=t.Order.RegisterID,o=e.find(r=>r.ID==i);o?this._outletService.pushNewRegister(o):this._toastr.warning(`There is no Register with ID [${i}]`,"Warning")}assignParkTemporaryItem(t){this.Data.parkTemporaryItem=Kt(Te,t.CartItems),this.pushNewValue(this.Data)}getDefaultOrderType(t){if(u.IsNotEmpty(t.DefaultSalesOrderTag))return t.DefaultSalesOrderTag;{let e=this._posHttpResponseService.Data.PoTypes;return e.length>0?e[0].ID:null}}createNewSalesOrderDataModel(){this._promotionEventService.selectedPromotion=null,this._paymentGatewayService.clearTransactionID(),this._invoiceCalculatorService.discountAfterTax=0,this._promotionCouponService.resetCouponOnNewTransaction(),this._customerHttpService.Data=new kt;let t=this._posHttpResponseService.Data,e=this.activeRegister,i=new $;!u.IsEmpty(t.SalesID)&&e.ListSales!=null&&e.ListSales.find(c=>c.ID==t.SalesID)&&(i.Order.SalesID=t.SalesID),i.Action.NewOrderID=e.NewOrderID,u.IsNotEmpty(e.NumberElement)&&(i.Order.Number=Nt.Generate(e.NumberElement)),i.Order.CurrencyID=t.AppConfigJSON.CoreDefaults.CurrencyID,this.assignOrderCurrency(i.Order.CurrencyID),i=this.initDefaultTaxType(i),this._posHttpResponseService.Data.AppConfigJSON.ModuleSell.RememberOrderTypeFromPreviousTransaction?u.IsEmpty(this._orderHttpService.Data)?(i.Order.TypeID=this.getDefaultOrderType(e),this.setPrintTemplateToDefault(i.Order.TypeID)):i.Order.TypeID=this.posData.Order.TypeID:(i.Order.TypeID=this.getDefaultOrderType(e),this.setPrintTemplateToDefault(i.Order.TypeID)),u.IsNotEmpty(e.EntityID)&&(i.Order.EntityID=e.EntityID,i.Order.RegisterID=e.RegisterID),i.Order.CouponType=1;let o=this.getDeliveryEntityID(e);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(t){let e=localStorage.getItem("cart_items"),i=[];if(e){let o=this.roleService.Data?.DeleteItem,r=JSON.parse(e),c=t==r?.Number;o||!c?localStorage.removeItem("cart_items"):i=fe(Te,r.CartItems)}return i}initDefaultTaxType(t){let e=this._posHttpResponseService.Data;if(u.IsNotEmpty(this.activeRegister.DefaultTaxType)){let i=this.getTaxObjectByID(this.activeRegister.DefaultTaxType);u.IsNotEmpty(i)?(t.Order.TaxTypeID=this.activeRegister.DefaultTaxType,this._invoiceCalculatorService.tax=i):(this.showModalSuspendedDefaultTax(),t.Order.TaxTypeID=e.Taxes[0].ID,this._invoiceCalculatorService.tax=e.Taxes[0])}else t.Order.TaxTypeID=e.Taxes[0].ID,this._invoiceCalculatorService.tax=e.Taxes[0];return t}assignOrderCurrency(t){let e=this.findCurrencyById(t);this._invoiceCalculatorService.currencySymbol=e?.Symbol,this.posData.Order.CurrencyRate=e?.ExchangeRate}setPrintTemplateToDefault(t){let i=(this._posHttpResponseService?.Data?.PoTypes).find(o=>o.ID==t);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(t=1){return this._posHttpResponseService.Data.Currencies.find(o=>o.ID==t)}getTaxObjectByID(t){return this._posHttpResponseService.Data.Taxes.find(i=>i.ID==t)}getDeliveryEntityID(t){let e=this._posHttpResponseService.Data.AppConfigJSON,i={DeliveryStateID:3,DeliveryEntityID:u.GuidEmpty};if(e.ModuleSell.Shipping.DefaultOrderDelivery==0){let o=this._posHttpResponseService.Data.Entities.find(r=>r.ID==this._outletService.getOutletRegister().EntityID);u.IsNotEmpty(o.ID)&&o.FulfillmentOption==2&&(i.DeliveryEntityID=u.GuidEmpty,i.DeliveryStateID=0),u.IsEmpty(t.DefaultWarehouse)?i.DeliveryEntityID=t.EntityID:i.DeliveryEntityID=t.DefaultWarehouse}else i.DeliveryEntityID=u.GuidEmpty,i.DeliveryStateID=0;return i}reedemPointToDiscount(t=!1){let e=this._posHttpResponseService.Data.AppConfigJSON,i=e.ApplicationLoyalty.Rules.PrefferedPayment,o=e.ApplicationLoyalty.Enabled,r=this._customerHttpService.Data,c=this.Data.posState==2,g=r.Point?r.Point:0;if(i&&g>0&&o){if(u.IsNotEmpty(this.posData.Order.CustomerID)&&!c){let x=e.ApplicationLoyalty.LoyaltyPoint.RedeemPointValue,V=this._invoiceCalculatorService.GetCashAndPointAmountCart(),q=g*x,Oe=g;q>V&&(q=V),q>0&&x>0?Oe=Math.ceil(q/x):Oe=0,r.PointUsed=Oe,this.posData.Order.PointUsed=Oe,this.posData.Order.DiscountAmount=q,this.resetCouponDiscountAmount()}else t&&(r.PointUsed=0,this.posData.Order.PointUsed=0,this.posData.Order.DiscountAmount=0);this._orderDataService.pushNewValue()}}resetCouponDiscountAmount(){let t=this._promotionCouponService.appliedCoupon();t&&(t?.Type=="Amount"||t?.Type=="Percentage")&&(this._promotionCouponService.removeAppliedCoupon(),this._toastr.warning("Loyalty point is used, coupon will be cancelled","Coupon Cancelled"))}showModalSuspendedDefaultTax(){this._dialog.open(Ii,{id:"ModalInfo",data:{title:"Default Tax Discontinued",message:`
17
+ ${t.Discount2!==0?"discount2 = "+t.Discount2+"%":""}`}return e}generateItemListDescription(t){let e="";for(let i of t)e+=e==""?"":" or ",e+=`[${i.Name}]`;return e=this.slicePromotionDesc(e),e}slicePromotionDesc(t){return t.length>200&&(t=t.slice(0,200),t+="..."),t}applyPromotion(t){switch(this.orderDataBeforePromotion=Kt($,this.salesOrderData),this.selectedPromotion,this.selectedPromotion=t,t.TypeID){case 1:this.applyProductReward(t);break;case 2:switch(t.RewardTypeID){case 1:this.applyQuantityPromotion();break;case 2:this.applyCheapestReward(t);break}break;case 3:this.applyDiscountReward(t);break;case 4:break;case 5:this.applyTierReward(t);break}}applyProductReward(t){this.getRewards$(t).subscribe(e=>{this.openDialogSelectReward(e)})}openDialogSelectReward(t){this._dialog.open(qi,{data:{rewards:t.rewards,promotion:t.promotion}})}applyCheapestReward(t){let e=this.salesOrderData.CartItems;if(e.length>0){let o=e.sort((c,g)=>c.Price-g.Price)[0],r=o.Total;o.Quantity>1&&(r=o.Total/o.Quantity,r=r/o.Quantity),o.DiscountAmount=r,o.Note=t.Name,e=e.map(c=>(c.VariantID==o.VariantID&&(c=o,c.PromotionGift=!0),c)),this.salesOrderData.CartItems=e,this._orderDataService.pushNewValue(this.salesOrderData),this.showToastAppliedPromo(this.selectedPromotion)}}applyDiscountReward(t){let i=this._posService.Data.AppConfigJSON.ModuleSell.ProductNotes.CopyPromotionName;if(this.salesOrderData.Order.Discount=t.Discount1,this.salesOrderData.Order.Discount2=t.Discount2,this.salesOrderData.Order.Discount>100&&(this.salesOrderData.Order.Discount=100),i==!0&&(this.salesOrderData.Order.Note=t.Name),u.IsNotEmpty(t.TaxTypeID)){let o=this.taxes.find(r=>r.ID==t.TaxTypeID);this._invoiceCalculatorService.tax=o,this.salesOrderData.Order.TaxTypeID=t.TaxTypeID}this._orderDataService.pushNewValue(this.salesOrderData),this.pushNewValue(this.Data),this.showToastAppliedPromo(this.selectedPromotion)}applyTierReward(t){let e=this.salesOrderData.CartItems,i=[];t.ListVariant.length>0?i=e.filter(o=>t.ListVariant.findIndex(r=>r.ID==o.VariantID)!==-1):i=e.filter(o=>t.ListCategory.findIndex(r=>r.ID==o.Variant.CategoryID)!==-1),i.length==0?e=this.tierPromotionBlankRequirement(t):e=this.tierPromotionWithRequirement(t,i),this.salesOrderData.CartItems=e,this._orderDataService.pushNewValue(this.salesOrderData)}tierPromotionBlankRequirement(t){let e=this.salesOrderData.CartItems,i=this.salesOrderData.TotalQuantity;return t.PromotionTieredQuantity.sort((o,r)=>o.Quantity-r.Quantity).forEach(o=>{i>=o.Quantity&&(e=e.map(r=>(r.Discount=o.Discount,r=this.copyPromotionNameToItem(t,r),r)))}),e}tierPromotionWithRequirement(t,e){let i=0,o=this.salesOrderData.CartItems;e.forEach(c=>{i+=c.Quantity}),t.PromotionTieredQuantity.sort((c,g)=>c.Quantity-g.Quantity).forEach(c=>{i>=c.Quantity&&(e=e.map(g=>(g.Discount=c.Discount,g)))});let r;return o=o.map(c=>(r=e.find(g=>g==c),r&&(c=r,c=this.copyPromotionNameToItem(t,c)),c)),o}copyPromotionNameToItem(t,e){return this._posService.Data.AppConfigJSON.ModuleSell.ProductNotes.CopyPromotionName==!0&&(e.Note=t.Name),e}removePromotion(){this._orderDataService.pushNewValue(this.orderDataBeforePromotion),this.showToastRemovePromo(this.selectedPromotion),this.selectedPromotion=null}showToastAppliedPromo(t){this._toastr.success("Applied "+t.Name+" to order!","Applied successfully!")}showToastRemovePromo(t){this._toastr.info("Removed "+t.Name+" from order!","Removed successfully!")}applyQuantityPromotion(){if(this.selectedPromotion){let t=this.salesOrderData.getRewards();switch(this.selectedPromotion.TypeID){case 2:this.selectedPromotion.MultipleApply?this.calculateQtyMultiplyPromotion([this.selectedPromotion],t):(t.length==0&&this.applyQuantityReward(this.selectedPromotion,1),this.checkSelectedPromotionRequirement(2));break;case 5:this.applyTierReward(this.selectedPromotion),this.checkSelectedPromotionRequirement(5);break}}}calculateQtyMultiplyPromotion(t,e){let i=fe(Te,this.salesOrderData.CartItems),o,r=[],c=0,g;t.forEach(x=>{r=i.filter(V=>(x.RequirementTypeID==0?o=x.ListVariant.findIndex(q=>q.ID==V.VariantID):o=x.ListCategory.findIndex(q=>q.ID==V.Variant.CategoryID),o!==-1)),g=e.filter(V=>V.PromotionID==x.ID),c=this.calculateQtyMultiply(r,x.MinimumAmount),this.showModalSelectReward(g,c,x)})}showModalSelectReward(t,e,i){let o=0;if(t.forEach(r=>o+=r.Quantity),e>o){let r=e-o;this.applyQuantityReward(i,r)}else if(e<o){this.selectedPromotion.Eligible=!1;let r=this.mappingEligiblePromotion([this.selectedPromotion]);this.pushNewValue(r),this.checkSelectedPromotionRequirement(2)}}applyQuantityReward(t,e){e>0&&this.getRewards$(t).subscribe(i=>{this._dialog.open(Ji,{data:{promotion:t,rewardQuantity:e,rewards:i.rewards}})})}calculateQtyMultiply(t,e){if(t.length>0){let o=t.filter(r=>r.PromotionGift==!1).map(r=>r.Quantity).reduce((r,c)=>r+c)/e;return this.getFirstNumber(o)}else return 0}getFirstNumber(t){let e=t.toString().split(".");return Number(e[0])}getRewards$(t){return this._httpService.get(U.GetRewardByPromotionID,[{key:"ID",value:t.ID}]).pipe(W(e=>({rewards:e.Rewards,promotion:t})))}static \u0275fac=function(e){return new(e||n)(f(H),f(se),f(le),f(ye),f(_e),f(X),f(L),f(at),f(G))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var zi=class{RegisterID;Number;Amount;TransactionID};var Wt=class{GroupID;Method;Data};var Ki=class{Status;InvoiceID;LoyaltyPoint;diff};var Yi=class{GopayQr};var Zi=class{Name;Quantity;Discount;DiscountAmount;Price;UnitQuantity};var Xi=class{Items;AmountSummary;GopayQr;Number;Customer;SalesName;CurrencySymbol;FinalAmount};var en=class n{_state=T(this.initCustomerDisplayState());isEnabled=J(()=>this._state()?.enabled);connect(){let e={enabled:!0,timestamp:new Date().toDateString()};localStorage.setItem("customerDisplay",JSON.stringify(e)),this._state.set(e)}initCustomerDisplayState(){let t=localStorage.getItem("customerDisplay"),e={enabled:!1,timestamp:""};return u.IsNotEmpty(t)&&(e=JSON.parse(t)),e}disconnect(){let e={enabled:!1,timestamp:new Date().toDateString()};localStorage.setItem("customerDisplay",JSON.stringify(e)),this._state.set(e)}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var Pe=class{Amount;CurrencySymbol;Label;Type;constructor(t,e,i,o){this.Amount=t,this.CurrencySymbol=e,this.Label=i,this.Type=o}};var tn=class n{constructor(t,e,i,o){this._invoiceCalculatorService=t;this._decimalPipe=e;this._poshttpResponseService=i;this._orderService=o;this._poshttpResponseService.Data$.pipe(oe()).subscribe(r=>{this.appConfig=r.AppConfigJSON})}appConfig=new mt;generateAmountSummary(){let t=[];this.isUseTax()?t=this.generateSummaryTax():t=this.generateSummaryNonTax();let e=this.generateSurchargeSummary();return e&&t.push(...e),t}generateSummaryTax(){let t=this._invoiceCalculatorService.tax?.CalculationTypeID,e=[];return t==1?e=this.generateSummaryTaxInclude():e=this.generateSummaryTaxExclude(),e}generateSummaryNonTax(){let t=[],e=this.generateCartItemAmount();if(t.push(e),this.isDiscounted()){let i=this.generateDiscountSummary(),o=this.generateAmountTotal("Total");t.push(...i,o)}return t}generateSummaryTaxInclude(){let t=[];return this.isTaxReserveSequence()?t=this.generateTaxIncludeReserveSequence():t=this.generateTaxIncludeNormalSequence(),t}generateTaxIncludeReserveSequence(){let t=[];if(this.isTaxDetailVisible()==!1){let r=this._invoiceCalculatorService.TotalBeforeTax,c=this.isDiscounted()?"Amount":"Before Tax",g=this.isDiscounted()?this._invoiceCalculatorService.GrossTotal:r,x=new Pe(g,this.currencySymbol,c,2);t.push(x)}if(this.isDiscounted()){let r=this.generateDiscountSummary(),c=this.generateBeforeTaxSummary();t.push(...r,c)}let i=this.generateTax(),o=this.generateAmountTotal();return t.push(...i,o),t}generateTaxIncludeNormalSequence(){let t=[],e=this.generateCartItemAmount();if(t.push(e),this.isDiscounted()){let o=this.generateDiscountSummary(),r=this.generateSummarySubTotal();t.push(...o,r)}let i=this.generateTax();if(t.push(...i),this.isTaxDetailVisible()==!1){let o=this.generateBeforeTaxSummary();t.push(o)}return t}generateSummaryTaxExclude(){let t=[],e=this.generateCartItemAmount(!0);if(t.push(e),this.isDiscounted()){let c=this.generateDiscountSummary(),g=this.generateSummarySubTotal();t.push(...c,g)}let i=this.generateTax(),o=this._invoiceCalculatorService.TotalAfterTax,r=new Pe(o,this.currencySymbol,"Total",1);return t.push(...i,r),t}generateAmountTotal(t="Total Amount"){let e=this._invoiceCalculatorService.Data;return new Pe(e,this.currencySymbol,t,1)}generateSummarySubTotal(){let t=this._invoiceCalculatorService.TotalAfterTax;return new Pe(t,this.currencySymbol,"SubTotal",1)}generateBeforeTaxSummary(){let t=this._invoiceCalculatorService.TotalBeforeTax;return new Pe(t,this.currencySymbol,"Before Tax",2)}isTaxDetailVisible(){return this.appConfig.PrintConfigInvoice?.Footer?.TaxDetailVisible}isUseTax(){let t=this._invoiceCalculatorService.tax;return t?.PrintVisible&&t?.Rate!=0}generateTax(){let t=[],e=this.isTaxDetailVisible(),i=e?2:1,o=this._invoiceCalculatorService.tax;if(e){let r=this.appConfig.PrintConfigInvoice.Footer.TaxableSales,c=this.calculateTaxableSales(),g=new Pe(c,this.currencySymbol,r,i);t.push(g)}if(o.TypeID==2){let r=this.generateTaxTypeMultiple();t.push(...r)}else{let r=this.generateSingleTaxSummary(o.Label,this._invoiceCalculatorService.TaxAmount,i);t.push(r)}if(e){let r=this.appConfig.PrintConfigInvoice.Footer.TaxExemptSales,c=this._invoiceCalculatorService.GrossTotalNonTaxable,g=new Pe(c,this.currencySymbol,r,i);t.push(g);let x=this.appConfig.PrintConfigInvoice.Footer.LabelWithZeroAmount;if(x){let V=new Pe(0,this.currencySymbol,x,i);t.push(V)}}return t}generateCartItemAmount(t=!1){let e=this.isDiscounted()||t?this._invoiceCalculatorService.GrossTotal:this._invoiceCalculatorService.TotalAfterTax;return new Pe(e,this.currencySymbol,"Amount",1)}get currencySymbol(){return this._invoiceCalculatorService.currencySymbol}generateDiscountSummary(){let t=[];if(this._invoiceCalculatorService.Discount1Amount!=0){let e=this._decimalPipe.transform(this._orderService.Data.Order.Discount),o=this.checkDiscountIgnoreDecimal(e)?"{0}":"{0} ({1}%)";t.push(new Pe(this._invoiceCalculatorService.Discount1Amount*-1,this._invoiceCalculatorService.currencySymbol,u.StringFormat(o,this.appConfig.CorePrint.Alias.Discount1,e),1))}if(this._invoiceCalculatorService.Discount2Amount!=0){let e=this._decimalPipe.transform(this._orderService.Data.Order.Discount2),o=this.checkDiscountIgnoreDecimal(e)?"{0}":"{0} ({1}%)";t.push(new Pe(this._invoiceCalculatorService.Discount2Amount*-1,this._invoiceCalculatorService.currencySymbol,u.StringFormat(o,this.appConfig.CorePrint.Alias.Discount2,e),1))}return this._orderService.Data.Order.DiscountAmount!=0&&this.appConfig.PrintConfigInvoice.ItemsFooter.DiscountAmountVisible&&t.push(new Pe(this._orderService.Data.Order.DiscountAmount*-1,this._invoiceCalculatorService.currencySymbol,"Discount ("+this._invoiceCalculatorService.currencySymbol+")",1)),t}calculateTaxableSales(){let t=this._invoiceCalculatorService.tax,e=this._invoiceCalculatorService.TaxAmount,i=this._invoiceCalculatorService.GrossTotalTaxable;return t.Rate==0?0:t.CalculationTypeID==1?i-e:i}generateTaxTypeMultiple(){let t=this.appConfig.PrintConfigInvoice.Footer.TaxDetailVisible?2:1,e=[],i=this._invoiceCalculatorService.tax;var o=this._invoiceCalculatorService.TaxAmount;if(i.TypeID==2){let r=i?.Components?i?.Components:[],c=this._invoiceCalculatorService.GrossTotalTaxable,g=this.calculateTotalRate(r);r.forEach(x=>{if(i.CalculationTypeID==0){let V=x.Rate/100*c;e=[...e,this.generateSingleTaxSummary(x.Label,V,t)],i.MultipleTaxTypeID==1&&(c+=V)}else{let V=x.Rate/g*o;e=[...e,this.generateSingleTaxSummary(x.Label,V,t)]}})}else e=[...e,this.generateSingleTaxSummary(i.Label,o,t)];return e}calculateTotalRate(t){let e=0;return t&&t.length>0&&(e=t.map(i=>i.Rate).reduce((i,o)=>i+o)),e}generateSingleTaxSummary(t,e,i){let o=this._invoiceCalculatorService.currencySymbol;return new Pe(e,o,t,i)}generateSurchargeSummary(){if(this._invoiceCalculatorService.SurchargeAmount==0)return;let t=[],e=this.appConfig.CorePrint,i=e&&e.Alias.SurchargePcg?e.Alias.SurchargePcg:"Surcharge";t.push(new Pe(this._invoiceCalculatorService.SurchargeAmount,this._invoiceCalculatorService.currencySymbol,u.StringFormat("{0} ({1}%)",i,this._decimalPipe.transform(this._orderService.Data?.Invoice.SurchargePcg)),1));let o=this.generateAmountTotal();return t.push(o),t}checkDiscountIgnoreDecimal(t){let i=this.appConfig.PrintConfigInvoice.Footer.DiscountIgnoredDecimal,o=parseFloat(t)%1,r=!1;return o!==0&&i&&(r=!0),r}isDiscounted(){let t=this._invoiceCalculatorService.Discount1Amount,e=this._invoiceCalculatorService.Discount2Amount,i=this._orderService.Data.Order.DiscountAmount,o=!1;return(t!=0||e!=0||i!=0)&&(o=!0),o}isTaxReserveSequence(){let t=this._invoiceCalculatorService.tax,e=!!t,i=e?t.CalculationTypeID:null,o=this.appConfig.PrintConfigInvoice.ItemsFooter.TaxIncludeBeforeTotalAmount;return e&&i===1&&o}static \u0275fac=function(e){return new(e||n)(f(le),f(G),f(X),f(H))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var gt=class n{constructor(t,e,i,o){this._receiptCalculatorService=t;this._cashierCalculatorService=e;this._signal=i;this._customerHttpService=o;this.broadcastOrderUpdate$.subscribe()}_salesOrderDataModelService=O(H);_outletService=O(se);displayService=O(en);localdata=O(De);orderDataModel;broadcastOrderUpdate$=Je([this._salesOrderDataModelService.Data$,this.localdata.isStoreOrderInServer(),yo(this.displayService.isEnabled)]).pipe(Un(([t,e,i])=>{let o=this._outletService?.Data?.RegisterID;if(e&&i&&o){this.orderDataModel=t;let r=this.ConstructCartModelForCustomerDisplay(),c=new Wt;return c.GroupID=o+"_Subscriber",c.Method="POSCartAmountUpdated",c.Data=r,this._signal.broadcast(c).pipe(nt(g=>(console.log(g),bt)))}else return bt}),nt(t=>(console.log(t),bt)),oe());ConstructCartModelForCustomerDisplay(){let t=this._customerHttpService.Data,e=new Xi;e.Number=this.orderDataModel.Order.Number,e.Items=Array();for(let i of this.orderDataModel.CartItems){let o=new Zi;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,e.Items.push(o)}return u.IsNotEmpty(this.orderDataModel.Order.SalesID)?e.SalesName=this._outletService.getSalesname(this.orderDataModel.Order.SalesID):e.SalesName="",u.IsNotEmpty(this.orderDataModel.Order.CustomerID)&&u.IsNotEmpty(t)&&(e.Customer=new kt,e.Customer.Email=t.Email,e.Customer.Mobile=t.Mobile,e.Customer.Name=this.orderDataModel.ContactName),e.CurrencySymbol=this._cashierCalculatorService.currencySymbol,e.FinalAmount=this._cashierCalculatorService.Data,e.AmountSummary=this._receiptCalculatorService.generateAmountSummary(),e}BroadcastStateToCustomerDisplay(t,e="",i="",o=0){let r=new Ki;r.Status=t,r.InvoiceID=e,r.LoyaltyPoint=i,r.diff=o;let c=new Wt;return c.GroupID=this._outletService.Data.RegisterID+"_Subscriber",c.Method="POSStateUpdated",c.Data=r,this.displayService.isEnabled()?this.localdata.isStoreOrderInServer().pipe(te(g=>g?this._signal.broadcast(c):Qe(ae.offlineMode))):bt}BroadcastQRToCustomerDisplay(t){let e=new Yi;e.GopayQr=t;let i=new Wt;return i.GroupID=this._outletService.Data.RegisterID+"_Subscriber",i.Method="POSQRPaymentActivated",i.Data=e,this.displayService.isEnabled()?this.localdata.isStoreOrderInServer().pipe(te(o=>o?this._signal.broadcast(i):Qe(ae.offlineMode))):bt}static \u0275fac=function(e){return new(e||n)(f(tn),f(le),f(at),f(Re))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var nn=class n{constructor(t){this.httpService=t}VerifyPayment(t,e){let i=this.getVerifyPaymentUrl(e);return this.httpService.post(i,t)}getVerifyPaymentUrl(t){let e;switch(t){case 0:e=U.GopayVerifyPayment;break;case 1:e=U.BcaVerifyPayment;break}return e}generateLink(t){return this.httpService.post(U.GenerateLink,t)}generateQRCode(t,e){return this.httpService.post(t,e)}static \u0275fac=function(e){return new(e||n)(f(_e))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var Gt=class n{constructor(t,e,i,o,r){this._posHubService=t;this._orderDataService=e;this._PaymentHttpService=i;this._InvoicecashierCalculatorService=o;this._toastrService=r}transactionId;qrPaymentMethodID;QRCodeHttpResponse;_paymentMethod;get paymentMethod(){return this._paymentMethod}resetPaymentMethod(){this._paymentMethod=null}onQRPaymentComplete(t,e){return new Promise((i,o)=>{if(t.transaction_id!==this.transactionId){let c=`transaction_id: ${t.transaction_id} / gross_amount: ${t.gross_amount}`;o({header:"Invalid QR Payment",message:c});return}if(t.gross_amount!==this._InvoicecashierCalculatorService.Data){let c=`paid_amount: ${t.gross_amount} vs invoice_amount: ${this._InvoicecashierCalculatorService.Data}`;o({header:"Invalid QR Payment",message:c});return}let r=this._orderDataService.Data.Order.Number;if(t.order_id.includes(r)==!1){let c=`Order ID: ${t.order_id} vs Order Number: ${r}`;o({header:"Invalid QR Payment",message:c});return}if(t.transaction_status!=="settlement"){let c=`Transaction status is ${t.transaction_status}`;o({header:"Invalid QR Payment",message:c});return}this.validateEMoneyPayment(e).subscribe(c=>{i(c)})})}generateNewPayment(t,e){let i=this._orderDataService.Data;u.IsEmpty(this.qrPaymentMethodID)&&alert("QR PaymentMethod.ID is not available!");let o=new Ye;return o.PaidAmount=e,o.Amount=e,o.Date=i.Order.Date,o.MethodID=this.qrPaymentMethodID,o.Code=t,u.IsEmpty(t)&&this._toastrService.warning("Midtrans transaction_id is empty. Please verify manually!","Mobile Payment Failure"),o}sendStateCompleteToCustomerDisplay(t){this._posHubService.BroadcastStateToCustomerDisplay(1,t.ObjectID,t.LoyaltyPoint,0).subscribe()}generateQR(t,e){this._paymentMethod=e,this.qrPaymentMethodID=e.ID;let i=this.getServiceUrl(e.EMoneyTypeID);return this._PaymentHttpService.generateQRCode(i,t).pipe(W(c=>(c=this.manipulateBCAQrisImg(c,e.EMoneyTypeID),this.transactionId=c.Transaction_id,this.QRCodeHttpResponse=c,this._orderDataService.transaction_id=c.Transaction_id,this.sendQRToCustomerDisplay(c.Url),c)))}sendQRToCustomerDisplay(t){this._posHubService.BroadcastQRToCustomerDisplay(t).subscribe()}validateEMoneyPayment(t){if(u.IsNotEmpty(this.transactionId)){let e=this._InvoicecashierCalculatorService.Data,i=this._paymentMethod?.EMoneyTypeID,o=this.generatePaymentVerificationData(e,i);return this._PaymentHttpService.VerifyPayment(o,i).pipe(te(r=>(this.updatePosDataForSubmission(e),Qn(this._orderDataService.submitOrder(t)).pipe(ce(c=>{this.sendStateCompleteToCustomerDisplay(c)})))))}else{let e=new Error("Transaction ID is Empty");throw St(()=>e)}}generatePaymentVerificationData(t,e){let i=this._orderDataService.Data,o=new zi;return o.Number=i.Order.Number,o.Amount=t,o.TransactionID=this.transactionId,o.RegisterID=i.Order.RegisterID,e==1&&(o.Number=this.QRCodeHttpResponse.Number),o}updatePosDataForSubmission(t){let e=this._orderDataService.Data,i=this.generateNewPayment(this.transactionId,t),o=[];o.push(i),e.Invoice.Due=null,e.Action.Type=3,e.Order.InvoicedStateID=3,e.Payments=o,this._orderDataService.pushNewValue(e)}getServiceUrl(t){let e;switch(t){case 0:e=U.GenerateGopayQrCode;break;case 1:e=U.GenerateBcaQrCode;break}return e}manipulateBCAQrisImg(t,e){return e==1&&(t.Url=`data:image/png;base64, ${t.Url}`),t}clearTransactionID(){this.transactionId=null,this._orderDataService.transaction_id=null,this.QRCodeHttpResponse=null}getTransactionId(){return this.transactionId}static \u0275fac=function(e){return new(e||n)(f(gt),f(H),f(nn),f(le),f(L))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var je=class n{constructor(t,e,i,o,r,c,g,x,V,q,Oe,ci,Hn,gr){this._orderDataService=t;this._posHttpResponseService=e;this._CoreHttpService=i;this._outletService=o;this._orderHttpService=r;this._signal=c;this._promotionEventService=g;this._promotionCouponService=x;this._customerHttpService=V;this._invoiceCalculatorService=q;this._dialog=Oe;this._toastr=ci;this._paymentGatewayService=Hn;this.roleService=gr;this.subscribeObservableChanges(),this._signal.OnContactReceive.subscribe(xn=>{if(!u.IsEmpty(xn)){let In=JSON.parse(xn);this._orderDataService.updateCustomerID(In.ID).then(jn=>{this.posData.ContactName=In.Name,this._customerHttpService.Data=jn,this.pushNewValue(this.Data)})}})}_Data=new we(new Bt);_clearOrder=new xe;get clearOrder$(){return this._clearOrder.asObservable()}get Data(){return this._Data.value}Data$=this._Data.asObservable();posData=new $;activeRegister=new Hi;subscribeObservableChanges(){this._orderDataService.Data$.pipe(oe()).subscribe(t=>{this.posData=t}),this._outletService.Data$.pipe(ne(t=>t?.RegisterID!==this.activeRegister?.RegisterID),oe()).subscribe(t=>{this.activeRegister=t,this.Data.posState!=2?this.createNewSalesOrderDataModel():this.setPrintTemplateToDefault(this.posData.Order.TypeID)})}pushNewValue(t){this._Data.next(t)}createNewTransactionInSameOutletRegister(t=!0){if(t){let e=this._orderDataService.Data.Order.EntityID;this._CoreHttpService.GenerateNumber(e,this.activeRegister).subscribe(i=>{this.activeRegister.NumberElement=i.OrderNumberElement,this.activeRegister.InvoiceNumberElement=i.InvoiceNumberElement,this.activeRegister.NewOrderID=i.NewOrderID,this.refreshLoader(),this.pushNewValue(new Bt),this.createNewSalesOrderDataModel()})}else this.pushNewValue(new Bt),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&&u.IsEmpty(i.LoginID)&&this._posHttpResponseService.requestObservable().subscribe()}}updatePosState(t,e){e&&this._orderHttpService.pushNewValue(e),this.Data.posState=t,this.pushNewValue(this.Data)}ReturnOrder(t){t&&(this.posData.CartItems=fe(Te,t.CartItems),this.posData.CartItems=this.posData.CartItems.map(e=>(e.Quantity=e.Quantity*-1,e.Variant.TypeID==4&&(e.Serial=e.Serial.map(i=>(i.Quantity=i.Quantity*-1,i))),e)),this.posData.Invoice.ReferenceInvoiceID=t.Invoice.ID,this.posData.Order.Discount=t.Order.Discount,this.posData.Order.Discount2=t.Order.Discount2,this.posData.Order.DiscountAmount=t.Order.DiscountAmount*-1,this.posData.Order.TaxTypeID=t.Order.TaxTypeID,this.posData.Order.SalesID=t.Order.SalesID,this.posData.Order.CustomerID=t.Order.CustomerID,this.posData.ContactName=t.ContactName,this.posData.Order.PointUsed=t.Order.PointUsed*-1,this.initSelectedTax(),this._orderDataService.pushNewValue(this.posData))}plainToClass(t,e){if(this.posData=Kt($,t),this.assignInvoice(t),this.assignCustomerData(t),this.initSelectedRegister(t,e),this.assignParkTemporaryItem(t),this.assignOrderCurrency(this.posData.Order.CurrencyID),this.initPromotionGift(),e==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 t=this.posData.CartItems;t=t.map(e=>(e.PromotionGift=e.PriceTypeID==3,e))}initSelectedTax(){let t=this.posData.Order.TaxTypeID;this._invoiceCalculatorService.tax=this.getTaxObjectByID(t);let e=this._invoiceCalculatorService.tax;u.IsEmpty(e)&&this.showModalSuspendedDefaultTax()}assignInvoice(t){if(t.Invoice){let e=t.Invoice.Due,i=t.Invoice.Date,o=e!=u.MinDate&&u.IsNotEmpty(e)?new Date(t.Invoice.Due):null,r=i!=u.MinDate&&u.IsNotEmpty(i)?new Date(t.Invoice.Date):new Date;t.Invoice.Due=o,t.Invoice.Date=r,this.posData.Invoice=t.Invoice,this.posData.Action.Type=3}else{let e=this.activeRegister;this.posData.Invoice=new Yt,u.IsNotEmpty(e.InvoiceNumberElement)&&(this.posData.Invoice.Number=Nt.Generate(e.InvoiceNumberElement))}}assignCustomerData(t){let e=t.Order.CustomerID,i=t.Order.EntityID;u.IsNotEmpty(e)&&u.IsNotEmpty(i)?ui(this._customerHttpService.GetPrivilegeByID(e,i)).then(o=>{let c=this._posHttpResponseService.Data.AppConfigJSON.ApplicationLoyalty.Label,g=o;g.Label=c,g.DebtCalculated=g.Debt,g=this.calculateCustomerDebt(t,g),this._customerHttpService.Data=g,this.pushNewValue(this.Data)}):this.Data.InputTextValue=null}calculateCustomerDebt(t,e){let i=t.Payments,o=u.IsNotEmpty(t.Invoice.ID);return i.length==0&&o&&(e.DebtCalculated=e.Debt-t.Invoice.Sales),e}initSelectedRegister(t,e){if(e!==4){let i=this._posHttpResponseService.Data.Registers;i.length>0?this.checkAccessOutletUser(t,i):this._toastr.warning("You do not have access to edit in this outlet","Warning")}else{let i=this.activeRegister.RegisterID;i!==t.Order.RegisterID&&(this.posData.Order.RegisterID=i,this._toastr.warning("You are processing order from different Register","Different Register"))}}checkAccessOutletUser(t,e){let i=t.Order.RegisterID,o=e.find(r=>r.ID==i);o?this._outletService.pushNewRegister(o):this._toastr.warning(`There is no Register with ID [${i}]`,"Warning")}assignParkTemporaryItem(t){this.Data.parkTemporaryItem=Kt(Te,t.CartItems),this.pushNewValue(this.Data)}getDefaultOrderType(t){if(u.IsNotEmpty(t.DefaultSalesOrderTag))return t.DefaultSalesOrderTag;{let e=this._posHttpResponseService.Data.PoTypes;return e.length>0?e[0].ID:null}}createNewSalesOrderDataModel(){this._promotionEventService.selectedPromotion=null,this._paymentGatewayService.clearTransactionID(),this._invoiceCalculatorService.discountAfterTax=0,this._promotionCouponService.resetCouponOnNewTransaction(),this._customerHttpService.Data=new kt;let t=this._posHttpResponseService.Data,e=this.activeRegister,i=new $;!u.IsEmpty(t.SalesID)&&e.ListSales!=null&&e.ListSales.find(c=>c.ID==t.SalesID)&&(i.Order.SalesID=t.SalesID),i.Action.NewOrderID=e.NewOrderID,u.IsNotEmpty(e.NumberElement)&&(i.Order.Number=Nt.Generate(e.NumberElement)),i.Order.CurrencyID=t.AppConfigJSON.CoreDefaults.CurrencyID,this.assignOrderCurrency(i.Order.CurrencyID),i=this.initDefaultTaxType(i),this._posHttpResponseService.Data.AppConfigJSON.ModuleSell.RememberOrderTypeFromPreviousTransaction?u.IsEmpty(this._orderHttpService.Data)?(i.Order.TypeID=this.getDefaultOrderType(e),this.setPrintTemplateToDefault(i.Order.TypeID)):i.Order.TypeID=this.posData.Order.TypeID:(i.Order.TypeID=this.getDefaultOrderType(e),this.setPrintTemplateToDefault(i.Order.TypeID)),u.IsNotEmpty(e.EntityID)&&(i.Order.EntityID=e.EntityID,i.Order.RegisterID=e.RegisterID),i.Order.CouponType=1;let o=this.getDeliveryEntityID(e);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(t){let e=localStorage.getItem("cart_items"),i=[];if(e){let o=this.roleService.Data?.DeleteItem,r=JSON.parse(e),c=t==r?.Number;o||!c?localStorage.removeItem("cart_items"):i=fe(Te,r.CartItems)}return i}initDefaultTaxType(t){let e=this._posHttpResponseService.Data;if(u.IsNotEmpty(this.activeRegister.DefaultTaxType)){let i=this.getTaxObjectByID(this.activeRegister.DefaultTaxType);u.IsNotEmpty(i)?(t.Order.TaxTypeID=this.activeRegister.DefaultTaxType,this._invoiceCalculatorService.tax=i):(this.showModalSuspendedDefaultTax(),t.Order.TaxTypeID=e.Taxes[0].ID,this._invoiceCalculatorService.tax=e.Taxes[0])}else t.Order.TaxTypeID=e.Taxes[0].ID,this._invoiceCalculatorService.tax=e.Taxes[0];return t}assignOrderCurrency(t){let e=this.findCurrencyById(t);this._invoiceCalculatorService.currencySymbol=e?.Symbol,this.posData.Order.CurrencyRate=e?.ExchangeRate}setPrintTemplateToDefault(t){let i=(this._posHttpResponseService?.Data?.PoTypes).find(o=>o.ID==t);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(t=1){return this._posHttpResponseService.Data.Currencies.find(o=>o.ID==t)}getTaxObjectByID(t){return this._posHttpResponseService.Data.Taxes.find(i=>i.ID==t)}getDeliveryEntityID(t){let e=this._posHttpResponseService.Data.AppConfigJSON,i={DeliveryStateID:3,DeliveryEntityID:u.GuidEmpty};if(e.ModuleSell.Shipping.DefaultOrderDelivery==0){let o=this._posHttpResponseService.Data.Entities.find(r=>r.ID==this._outletService.getOutletRegister().EntityID);u.IsNotEmpty(o.ID)&&o.FulfillmentOption==2&&(i.DeliveryEntityID=u.GuidEmpty,i.DeliveryStateID=0),u.IsEmpty(t.DefaultWarehouse)?i.DeliveryEntityID=t.EntityID:i.DeliveryEntityID=t.DefaultWarehouse}else i.DeliveryEntityID=u.GuidEmpty,i.DeliveryStateID=0;return i}reedemPointToDiscount(t=!1){let e=this._posHttpResponseService.Data.AppConfigJSON,i=e.ApplicationLoyalty.Rules.PrefferedPayment,o=e.ApplicationLoyalty.Enabled,r=this._customerHttpService.Data,c=this.Data.posState==2,g=r.Point?r.Point:0;if(i&&g>0&&o){if(u.IsNotEmpty(this.posData.Order.CustomerID)&&!c){let x=e.ApplicationLoyalty.LoyaltyPoint.RedeemPointValue,V=this._invoiceCalculatorService.GetCashAndPointAmountCart(),q=g*x,Oe=g;q>V&&(q=V),q>0&&x>0?Oe=Math.ceil(q/x):Oe=0,r.PointUsed=Oe,this.posData.Order.PointUsed=Oe,this.posData.Order.DiscountAmount=q,this.resetCouponDiscountAmount()}else t&&(r.PointUsed=0,this.posData.Order.PointUsed=0,this.posData.Order.DiscountAmount=0);this._orderDataService.pushNewValue()}}resetCouponDiscountAmount(){let t=this._promotionCouponService.appliedCoupon();t&&(t?.Type=="Amount"||t?.Type=="Percentage")&&(this._promotionCouponService.removeAppliedCoupon(),this._toastr.warning("Loyalty point is used, coupon will be cancelled","Coupon Cancelled"))}showModalSuspendedDefaultTax(){this._dialog.open(Ii,{id:"ModalInfo",data:{title:"Default Tax Discontinued",message:`
18
18
  <div class="d-flex justify-content-center my-4">
19
19
  <img class="img-2x" src="https://cdn.dealpos.xyz/web-image/globalerror.svg"
20
20
  alt="Empty Sales Order Tag" />
@@ -25,4 +25,4 @@ Do you want to end your session?`)&&(this.onClose(),this.router.navigate(["menu/
25
25
  <p class="text-center">
26
26
  Please change the default tax or re-activate the tax <a href="/menu/Setup/Payment/Tax">here</a>.
27
27
  </p>
28
- `,headerType:de.Error},width:"31rem"})}emitClearOrder(){this._clearOrder.next(!0)}static \u0275fac=function(e){return new(e||n)(f(H),f(X),f(Ft),f(se),f(Vt),f(at),f(ke),f(Ut),f(Re),f(le),f(ye),f(L),f(Gt),f(Ne))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var Gi=class n{httpService=O(_e);salesOrderService=O(H);orderProcessorService=O(je);promotionCouponFactoryService=O(Qt);toastr=O(L);decimalPipe=O(G);couponCode;couponNote;_couponProvider;get couponProvider(){return this._couponProvider}_coupon;get coupon(){return this._coupon}countToastrNotification=0;constructor(){this.orderProcessorService.Data$.pipe(oe()).subscribe(t=>{t.posState==1&&(this._coupon=null,this._couponProvider=null)})}redeemCoupon(t,e,i){let o=this.promotionCouponFactoryService.generateRedeemCouponDto(t,e);this.httpService.post(U.validateExternalCoupon,o).subscribe({next:r=>{this.couponCode=t,this.couponNote=i,this._coupon=r,this._couponProvider=e,this.applyCoupon(r)},error:r=>{this.removeCoupon()}})}applyCoupon(t){let e=t.ApplyToProduct,i=t.Amount;e?.length>0&&i>0?(this.applyCouponToCartItems(t),this.applyCouponToOrder(t)):e?.length>0?this.applyCouponToCartItems(t):this.applyCouponToOrder(t)}applyCouponToOrder(t){let e=this.salesOrderService.Data;t.Type=="Percentage"?e.Order.Discount=t.Amount:e.Order.DiscountAmount=t.Amount,this.showToastrAppliedCoupon(t,"Order"),this.updateSalesOrder(e)}applyCouponToCartItems(t){let e=this.salesOrderService.Data,i=t.ApplyToProduct;if(!this.validateItemsForCoupon(t))return;let o=e.CartItems.map(r=>{let c=i.findIndex(g=>g.Code===r.Variant?.Code);return c!=-1&&(t.Type==="Percentage"?(r.Discount=i[c]?.Amount,r.CouponDiscount=i[c]?.Amount):(r.DiscountAmount=i[c]?.Amount,r.CouponDiscount=i[c]?.Amount)),r});e.CartItems=o,this.showToastrAppliedCoupon(t,"Product"),this.updateSalesOrder(e)}validateItemsForCoupon(t){let e=this.salesOrderService.Data,i=t.ApplyToProduct,o=0;e.CartItems.forEach(c=>{i.findIndex(x=>x.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(e,!0),r=!1),r}showToastrAppliedCoupon(t,e){if(u.IsNotEmpty(t.Notification))this.countToastrNotification==0&&this.toastr.success(t.Notification,"Coupon Applied"),this.countToastrNotification+=1;else if(e=="Product")this.toastr.success("Coupon applied to products","Coupon Applied");else if(t.Type==="Percentage")this.toastr.success(`${t.Amount}% Discount`,"Coupon Applied");else{let i=this.decimalPipe.transform(t.Amount,"1.0-2");this.toastr.success(`${i} Discount`,"Coupon Applied")}}removeCoupon(){let t=this._coupon.ApplyToProduct,e=this._coupon.Amount;this._couponProvider=null;let i=this.salesOrderService.Data;t?.length>0&&e>0?(i=this.removeCouponFromCartItems(),i=this.removeCouponFromOrder()):t?.length>0?i=this.removeCouponFromCartItems():i=this.removeCouponFromOrder(),this.updateSalesOrder(i,!0),this._coupon=null}removeCouponFromOrder(){let t=this.salesOrderService.Data;return this._coupon.Type=="Percentage"?t.Order.Discount=0:t.Order.DiscountAmount=0,t}removeCouponFromCartItems(){let t=this.salesOrderService.Data,e=this._coupon.ApplyToProduct,i=t.CartItems.map(o=>(e.findIndex(c=>c.Code===o.Variant?.Code)!=-1&&(o.Discount=0,o.CouponDiscount=0,o.DiscountAmount=0),o));return t.CartItems=i,t}updateSalesOrder(t,e=!1){t.Order.PromotionCoupon=e?null:this.couponCode,t.Order.PromotionNote=e?null:this.couponNote,t.Order.CouponProvider=e?null:this.couponProvider,t.Order.CouponType=e?1:2,this.salesOrderService.pushNewValue(t),this.couponCode=e?null:this.couponCode,this.couponNote=e?null:this.couponNote,this._coupon=e?null:this._coupon,this._couponProvider=e?null:this._couponProvider,this.countToastrNotification=e?0:this.countToastrNotification}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};function Yr(n,t){if(n&1&&y(0,"img",6),n&2){let e=p(2);m("src",e.printTemplate.Logo,Ct)}}function Zr(n,t){if(n&1&&(a(0,"span"),d(1),s()),n&2){let e=p(3);l(),I("(",e.data.Contact.MemberIdentification,")")}}function Xr(n,t){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,Zr,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"),y(16,"span",10),s(),a(17,"div")(18,"span"),d(19),s()()()()()),n&2){let e=p(2);l(3),P(e.appConfigJson.PrintConfigInvoice.DocumentLabel.Customer),l(3),P(e.data.ContactDisplay),l(),C(e.data.Contact.MemberIdentification?7:-1),l(4),P(e.data.Contact.Email),l(3),P(e.data.Contact.Phone?e.data.Contact.Phone:e.data.Contact.Mobile),l(2),m("innerHTML",e.data.Contact.Address,ze),l(3),P(e.data.City)}}function ea(n,t){if(n&1&&(a(0,"span"),d(1),s()),n&2){let e=p(3);l(),I(", ",e.data.Shipping.Phone)}}function ta(n,t){if(n&1&&(a(0,"div",14)(1,"h3"),d(2),s(),a(3,"div",37)(4,"div"),d(5),h(6,ea,2,1,"span"),s(),y(7,"div",10),a(8,"div"),d(9),s()()()),n&2){let e=p(2);l(2),I(" ",e.appConfigJson.PrintConfigInvoice.DocumentLabel.ShippingAddress," "),l(3),I(" ",e.data.Shipping.Name),l(),C(e.data.Shipping.Phone?6:-1),l(),m("innerHTML",e.data.Shipping.Street,ze),l(2),I(" ",e.data.Shipping.City," ")}}function ia(n,t){if(n&1&&y(0,"i",39),n&2){let e=p().$implicit;m("innerHTML",e.Note,ze)}}function na(n,t){if(n&1&&(a(0,"div"),d(1),s()),n&2){let e=p().$implicit;l(),I("-",e.Discount,"%")}}function oa(n,t){if(n&1&&(a(0,"div"),d(1),s()),n&2){let e=p().$implicit;l(),I(" -",e.DiscountAmount," ")}}function ra(n,t){if(n&1&&(a(0,"tr")(1,"td",11),d(2),s(),a(3,"td"),d(4),a(5,"div"),h(6,ia,1,1,"i",39),s()(),a(7,"td"),d(8),s(),a(9,"td",11),d(10),v(11,"number"),s(),a(12,"td"),d(13),s(),a(14,"td",11),d(15),v(16,"number"),s(),a(17,"td",40),h(18,na,2,1,"div"),h(19,oa,2,1,"div"),s(),a(20,"td",11),d(21),v(22,"TrailingZero"),s()()),n&2){let e=t.$implicit,i=t.$index,o=p(2);l(2),I("",i+1,"."),l(2),I(" ",e.Name," "),l(2),C(e.Note!=null?6:-1),l(2),P(e.Code),l(2),P(D(11,10,e.Quantity)),l(3),P(e.UOMName),l(2),P(D(16,12,e.UnitPrice)),l(3),C(e.Discount!=0?18:-1),l(),C(e.DiscountAmount!=0?19:-1),l(2),I(" ",re(22,14,e.Total,o.appConfigJson.PrintConfigGeneral.TrailingZero)," ")}}function aa(n,t){if(n&1&&(a(0,"span"),d(1),v(2,"sum"),s()),n&2){let e=p().$index,i=p(2);l(),I(" ",e==0&&(i.data==null?null:i.data.Items.length)>1?"Qty: "+re(2,1,i.data.Items,"Quantity"):"")}}function sa(n,t){if(n&1&&(a(0,"tr")(1,"th",41),h(2,aa,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),v(10,"TrailingZero"),s()()),n&2){let e=t.$implicit,i=t.$index,o=p(2);l(2),C(o.appConfigJson.PrintConfigInvoice.ItemsFooter.TotalQuantityVisible?2:-1),l(),I(" ",(o.data==null?null:o.data.Payments.length)>1&&i==(o.data==null?null:o.data.AmountSummary.length)-2?"Payment":e.Label," "),l(4),P(e.CurrencySymbol),l(2),I(" ",re(10,4,e.Amount,o.appConfigJson.PrintConfigGeneral.TrailingZero)," ")}}function la(n,t){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),v(9,"TrailingZero"),s()()),n&2){let e=t.$implicit,i=p(2);l(2),P(e.Label),l(4),P(e.CurrencySymbol),l(2),I(" ",re(9,3,e.Amount,i.appConfigJson.PrintConfigGeneral.TrailingZero)," ")}}function ca(n,t){if(n&1&&(a(0,"span")(1,"span",44),d(2),v(3,"date"),s(),d(4),v(5,"number"),y(6,"br"),s()),n&2){let e=t.$implicit,i=p(3);l(),m("hidden",i.data.Payments),l(),P(re(3,5,e.Date,"dd MMM yy")),l(2),Jn(" ",e.MethodName," ",e.Note?e.Note:""," ",D(5,8,e.Amount)," ")}}function da(n,t){if(n&1&&(a(0,"tr"),y(1,"th",10),a(2,"td"),d(3,":"),s(),a(4,"td"),z(5,ca,7,10,"span",null,Se),s()()),n&2){let e=p(2);l(),m("innerHTML",e.data.Invoice.PaymentStateID==2?"Down Payment":"Payment",ze),l(4),K(e.data.Payments)}}function ma(n,t){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 e=p(2);l(8),I(" ",e.data.CustomerTransaction==null?null:e.data.CustomerTransaction.SO.DeliveryStateString," ")}}function pa(n,t){if(n&1&&(a(0,"tr")(1,"th",46),d(2,"Remaining"),s(),a(3,"td"),d(4,":"),s(),y(5,"td",47),v(6,"sum"),v(7,"number"),s()),n&2){let e=p(2);l(5),m("innerHtml",D(7,4,(e.data==null?null:e.data.FinalAmount)-re(6,1,e.data==null?null:e.data.Payments,"Amount")),ze)}}function ua(n,t){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 e=p(2);l(8),I(" ",e.data.Invoice==null?null:e.data.Invoice.Note," ")}}function ga(n,t){if(n&1&&(a(0,"div",31)(1,"h5"),d(2),s(),a(3,"div",30),d(4,"\xA0"),s()()),n&2){let e=p(2);l(2),I(" ",e.appConfigJson.PrintConfigInvoice==null?null:e.appConfigJson.PrintConfigInvoice.FooterLabel.ApprovedBy," ")}}function fa(n,t){if(n&1&&(a(0,"div",32)(1,"h5"),d(2),s(),a(3,"div",30),d(4,"\xA0"),s()()),n&2){let e=p(2);l(2),I(" ",e.appConfigJson.PrintConfigDelivery==null?null:e.appConfigJson.PrintConfigDelivery.FooterLabel.DeliveredBy," ")}}function ha(n,t){if(n&1&&y(0,"div",36),n&2){let e=p(2);m("innerHTML",e.printTemplate.FooterRight,ze)}}function Ca(n,t){if(n&1&&(a(0,"div"),y(1,"link",0),v(2,"StylesheetSafeUrl"),a(3,"div",1)(4,"div",2)(5,"div",3)(6,"div",4)(7,"div",5),h(8,Yr,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),y(16,"span",10),v(17,"newlines"),s(),a(18,"div",11),y(19,"span",10),v(20,"newlines"),s()()()(),h(21,Xr,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),v(38,"date"),s()()()()(),h(39,ta,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"),z(62,ra,23,17,"tr",null,Se),s()(),a(64,"div",25)(65,"table",26)(66,"tbody"),z(67,sa,11,7,"tr",null,Se),s(),a(69,"tbody"),z(70,la,10,6,"tr",null,Se),s()()()()(),a(72,"table",27),h(73,da,7,1,"tr"),h(74,ma,9,1,"tr"),h(75,pa,8,6,"tr"),h(76,ua,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,ga,5,1,"div",31),h(86,fa,5,1,"div",32),a(87,"div",33)(88,"h5"),d(89),s(),a(90,"div",30),d(91),s()()()()(),a(92,"div",34),y(93,"div",35),h(94,ha,1,1,"div",36),s()()()),n&2){let e=p();l(),vi("href",e.stylesheet!=null&&e.stylesheet.SizeA4?D(2,25,e.stylesheet==null?null:e.stylesheet.SizeA4):null,Wn),l(7),C(e.printTemplate.Logo?8:-1),l(3),P(e.printTemplate.Title),l(2),P(e.printTemplate.Field),l(3),m("innerHTML",D(17,27,e.printTemplate.Address),ze),l(3),m("innerHTML",D(20,29,e.printTemplate.ContactInfo),ze),l(2),C(e.data.ContactDisplay?21:-1),l(4),P(e.data.Prefixed),l(2),I(" ",e.data.Invoice==null?null:e.data.Invoice.Number," "),l(10),P(re(38,31,e.data.Invoice==null?null:e.data.Invoice.Date,"dd MMM yyyy")),l(2),C(e.data.Shipping?39:-1),l(17),I(" Price(",e.data.CurrencySymbol,") "),l(4),I(" Total(",e.data.CurrencySymbol,") "),l(2),K(e.data.Items),l(5),K(e.data==null?null:e.data.AmountSummary),l(3),K(e.data==null?null:e.data.PaidAmountSummary),l(3),C(e.appConfigJson.PrintConfigInvoice!=null&&e.appConfigJson.PrintConfigInvoice.Footer.PaymentMethodVisible&&e.data.Payments.length>0?73:-1),l(),C((e.data.CustomerTransaction==null?null:e.data.CustomerTransaction.SO)!=null&&(e.data.CustomerTransaction==null?null:e.data.CustomerTransaction.SO.DeliveryStateID)!=3&&(e.appConfigJson.PrintConfigInvoice!=null&&e.appConfigJson.PrintConfigInvoice.Footer.DeliveryInfoVisible)?74:-1),l(),C(!(e.data==null||e.data.Invoice==null)&&e.data.Invoice.PaymentStateID&&(e.data==null||e.data.Invoice==null?null:e.data.Invoice.PaymentStateID)<3?75:-1),l(),C(e.data.Invoice!=null&&e.data.Invoice.Note?76:-1),l(6),I(" ",e.appConfigJson.PrintConfigInvoice==null?null:e.appConfigJson.PrintConfigInvoice.FooterLabel.ReceivedBy," "),l(3),C((e.appConfigJson.PrintConfigDelivery==null?null:e.appConfigJson.PrintConfigDelivery.Footer.SignatureCountType)==1||(e.appConfigJson.PrintConfigDelivery==null?null:e.appConfigJson.PrintConfigDelivery.Footer.SignatureCountType)==2?85:-1),l(),C((e.appConfigJson.PrintConfigDelivery==null?null:e.appConfigJson.PrintConfigDelivery.Footer.SignatureCountType)==2?86:-1),l(3),I(" ",e.appConfigJson.PrintConfigInvoice==null?null:e.appConfigJson.PrintConfigInvoice.FooterLabel.SignedBy," "),l(2),I(" ",e.data.ItemTransfer==null?null:e.data.ItemTransfer.Courier," "),l(2),m("ngClass",!e.printTemplate.FooterRight&&"single")("innerHTML",e.printTemplate.FooterLeft,ze),l(),C(e.printTemplate.FooterRight?94:-1)}}var ar=class n{data;outletInfo;appConfigJson;printTemplate;stylesheet;constructor(){}ngOnInit(){}static \u0275fac=function(e){return new(e||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(e,i){e&1&&h(0,Ca,95,34,"div"),e&2&&C(i.data?0:-1)},dependencies:[Ee,G,Ke,xo,Io,To,Uo],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}']})},on=class n{static \u0275fac=function(e){return new(e||n)};static \u0275mod=Ci({type:n});static \u0275inj=hi({imports:[me,Mi]})};var $t=class n{_state=T(this.getEcrConfig());isEnabled=J(()=>this._state()?.enabled);ecrUrl=J(()=>this._state()?.url);getEcrConfig(){let t=localStorage.getItem("ecrConfig"),e={enabled:!1,url:null,timestamp:""};return u.IsNotEmpty(t)&&(e=JSON.parse(t)),e}url=J(()=>{let t=this._state()?.url;if(t){let e=t.split("/");e.pop(),t=e.join("/")}return t});connect(t){let i={enabled:!0,url:t,timestamp:new Date().toDateString()};localStorage.setItem("ecrConfig",JSON.stringify(i)),this._state.set(i)}disconnect(){let e={enabled:!1,timestamp:new Date().toDateString(),url:null};localStorage.setItem("ecrConfig",JSON.stringify(e)),this._state.set(e)}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var qt=class n{ecrStorage=O($t);socketConnection;_ecrEvent=new xe;ecrEvent$=this._ecrEvent.asObservable();_isSignalRConnected=T(!1);isConnected=J(()=>this.ecrStorage.isEnabled()&&this._isSignalRConnected());toastr=O(L);initEcrOnStartup(){if(this.isConnected()){let e=this.ecrStorage.ecrUrl();this.initConnection(e)}}initConnection(t){this.socketConnection=new bi().withUrl(t).withAutomaticReconnect().configureLogging(yi.Information).build(),this.ecrStorage.connect(t),this.listenToConnectionEvents(),this.listenToEvents(),this.startConnection()}startConnection(){this.socketConnection.start().then(()=>{this._isSignalRConnected.set(!0),this.toastr.success("Successfully connected to ECR","Success")}).catch(t=>{this.toastr.error(t,"Failed connecting to ECR"),console.log(t)})}listenToEvents(){this.socketConnection.on("EcrEvent",t=>{this._ecrEvent.next(t)})}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(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var rn=class n{_state=T(this.getCashMachineConfig());isEnabled=J(()=>this._state()?.enabled);ecrUrl=J(()=>this._state()?.url);getCashMachineConfig(){let t=localStorage.getItem("CashkMachineConfig"),e={enabled:!1,url:null,timestamp:""};return u.IsNotEmpty(t)&&(e=JSON.parse(t)),e}url=J(()=>this._state()?.url);connect(t){let i={enabled:!0,url:t,timestamp:new Date().toDateString()};localStorage.setItem("CashkMachineConfig",JSON.stringify(i)),this._state.set(i)}disconnect(){let e={enabled:!1,timestamp:new Date().toDateString(),url:null};localStorage.setItem("CashkMachineConfig",JSON.stringify(e)),this._state.set(e)}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var ya=n=>({"is-invalid":n}),lr=n=>({expanded:n});function ba(n,t){if(n&1&&(a(0,"tr")(1,"td",21),d(2),v(3,"number"),s(),a(4,"td",19)(5,"span",22),d(6),v(7,"number"),s()(),a(8,"td",23),d(9),v(10,"number"),s()()),n&2){let e=t.$implicit;l(2),yt(" ",e.countryCode," ",D(3,4,e.value)," "),l(4),P(D(7,6,e.stored)),l(3),I(" ",D(10,8,e.value*e.stored)," ")}}function Sa(n,t){if(n&1){let e=E();wn(0),v(1,"async"),wn(2),v(3,"async"),a(4,"div",5)(5,"div",11)(6,"div",12),d(7,"TOTAL CASH IN MACHINE"),s()(),a(8,"div",13)(9,"div",14),d(10),v(11,"number"),s(),a(12,"div",15),_("click",function(){b(e);let o=p();return S(o.expandedTable.set(!o.expandedTable()))}),y(13,"i",16),s()(),a(14,"div",17)(15,"table",18)(16,"thead")(17,"tr")(18,"th"),d(19,"Denomination"),s(),a(20,"th",19),d(21,"Quantity"),s(),a(22,"th",20),d(23,"Total"),s()()(),a(24,"tbody"),z(25,ba,11,10,"tr",null,Le),s()()()()}if(n&2){let e=p(),i=D(1,4,e.cashMachineDenominations$),o=D(3,6,e.totalCashAmount$);l(10),yt(" ",i[0]==null?null:i[0].countryCode," ",D(11,8,o)," "),l(2),m("ngClass",k(10,lr,e.expandedTable())),l(2),m("ngClass",k(12,lr,e.expandedTable())),l(11),K(i)}}function Pa(n,t){n&1&&(a(0,"div",9)(1,"span"),d(2,"Host URL is required."),s()())}function Oa(n,t){n&1&&(a(0,"span",10),d(1,"Enter the port or device URL used by your Cash Machine."),s())}var an=class n{constructor(t){this.dialogRef=t;this.config.title="Cash Machine",this.config.customWidth="450px",this.config.hideCancel=!0,this.config.okText=this.cashMachineService.isConnected()?"Disconnect":"Connect Now"}config=new Y;urlCtrl=new Ge("https://localhost:7065/CashMachineHUB",[Tt.required]);cashMachineService=O(ft);totalCashAmount$=this.cashMachineService.getCashMachineTotalAmount();cashMachineDenominations$=this.cashMachineService.getCashMachineDenominations().pipe(W(t=>t.filter(e=>e.stored>0)));expandedTable=T(!1);onClose(){this.dialogRef.close()}onConnect(){this.urlCtrl.valid&&this.dialogRef.close(this.urlCtrl.value)}get modalContentWording(){let t="Cash Machine Connected",e="Your Cash Machine is now online. You can process cash-in payments immediately.",i="Cash Machine Not Connected",o="To enable cash-in payments using the Cash Machine, please connect the device through the port or URL below.",r=this.cashMachineService.isConnected()?t:i,c=this.cashMachineService.isConnected()?e:o;return{title:r,description:c}}static \u0275fac=function(e){return new(e||n)(M(Z))};static \u0275cmp=N({type:n,selectors:[["app-modal-connect-cash-machine"]],decls:16,vars:11,consts:[[3,"onCancel","onClose","onOk","config","dynamicValidated"],[1,"d-flex","flex-column",2,"row-gap","1.5rem"],[1,"text-center","d-flex","flex-column","align-items-center",2,"row-gap","0.8rem"],[1,"fa-solid","fa-money-from-bracket","fa-3x","d-flex","align-items-center","justify-content-center","bg-light",2,"border-radius","50%","width","80px","height","80px",3,"ngClass"],[1,"fw-normal"],[1,"cash-info-card"],[1,"card","d-flex","justify-content-center","p-8","bg-light-gray",2,"border-radius","12px","margin","0"],["for","floatingInput",1,"fw-semibold","mb-2"],["id","floatingInput","placeholder","Host URL","type","text",1,"form-control",2,"border-radius","8px","padding","12px 16px",3,"ngClass","formControl"],[1,"invalid-feedback","mt-4"],[1,"text-muted","mt-4"],[1,"cash-info-header","border-bottom"],[1,"cash-info-title"],[1,"cash-amount-row"],[1,"cash-amount","updated"],["role","button",1,"expand-chevron",3,"click","ngClass"],[1,"fas","fa-chevron-down"],[1,"expand-content","mt-6",3,"ngClass"],[1,"denomination-table"],[1,"quantity-cell"],[1,"total-cell",2,"text-align","right"],[1,"denomination-value"],[1,"quantity-badge"],[1,"total-cell"]],template:function(e,i){e&1&&(a(0,"modal-material",0),_("onCancel",function(){return i.onClose()})("onClose",function(){return i.onClose()})("onOk",function(){return i.onConnect()}),a(1,"content")(2,"div",1)(3,"div",2),y(4,"i",3),a(5,"h2"),d(6),s(),a(7,"span",4),d(8),s()(),h(9,Sa,27,14,"div",5),a(10,"div",6)(11,"label",7),d(12,"Port / URL"),s(),y(13,"input",8),h(14,Pa,3,0,"div",9)(15,Oa,2,0,"span",10),s()()()()),e&2&&(m("config",i.config)("dynamicValidated",i.urlCtrl.valid),l(4),m("ngClass",i.cashMachineService.isConnected()?"text-success":"text-danger"),l(2),P(i.modalContentWording.title),l(2),P(i.modalContentWording.description),l(),C(i.cashMachineService.isConnected()?9:-1),l(4),m("ngClass",k(9,ya,i.urlCtrl.invalid&&(i.urlCtrl.touched||i.urlCtrl.dirty)))("formControl",i.urlCtrl),l(),C(i.urlCtrl.invalid&&(i.urlCtrl.touched||i.urlCtrl.dirty)?14:15))},dependencies:[me,Ee,vo,ve,ge,st,ie,He,G],styles:["[_nghost-%COMP%] modal-material .modal-body::-webkit-scrollbar{width:4px}[_nghost-%COMP%] modal-material .modal-body::-webkit-scrollbar-track{background:#89b03e14;border-radius:10px}[_nghost-%COMP%] modal-material .modal-body::-webkit-scrollbar-thumb{background:#89b03e;border-radius:10px;transition:all .3s ease}[_nghost-%COMP%] modal-material .modal-body::-webkit-scrollbar-thumb:hover{background:#89b03ecc;box-shadow:0 0 5px #89b03e80}[_nghost-%COMP%] modal-material .modal-content{scrollbar-width:thin;scrollbar-color:#89b03e rgba(137,176,62,.08)}.cash-info-card[_ngcontent-%COMP%]{background-color:#fff;border-radius:12px;padding:1.5rem;margin-bottom:1.5rem;border:1px solid #f4f4f4;box-shadow:0 4px 12px #0000000d;padding-bottom:0}.cash-info-header[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;margin-bottom:1rem;padding-bottom:.75rem}.cash-info-title[_ngcontent-%COMP%]{font-weight:600;font-size:1rem;color:#212529;letter-spacing:.3px}.cash-amount-row[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between}.cash-amount[_ngcontent-%COMP%]{font-weight:700;font-size:2.2rem;color:#212529;letter-spacing:.5px;margin:0}.expand-chevron[_ngcontent-%COMP%]{width:40px;height:40px;display:flex;align-items:center;justify-content:center;border-radius:8px;background-color:#89b03e1a;color:#89b03e;font-size:1.2rem;cursor:pointer;transition:all .3s cubic-bezier(.4,0,.2,1);border:1px solid rgba(137,176,62,.2)}.expand-chevron[_ngcontent-%COMP%]:hover{background-color:#89b03e33;transform:translateY(-2px);box-shadow:0 4px 8px #89b03e26}.expand-chevron.expanded[_ngcontent-%COMP%]{transform:rotate(180deg);background-color:#89b03e;color:#fff}.expand-content[_ngcontent-%COMP%]{max-height:0;overflow:hidden;transition:max-height .4s cubic-bezier(.4,0,.2,1);margin-bottom:1rem}.expand-content.expanded[_ngcontent-%COMP%]{max-height:700px;overflow:visible}.denomination-table[_ngcontent-%COMP%]{width:100%;border-collapse:collapse;font-size:.9rem;margin-bottom:.5rem}.denomination-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{text-align:left;padding:.75rem 1rem;background-color:#7d847114;border-bottom:1px solid rgba(0,0,0,.3);color:#000;font-weight:600}.denomination-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:.75rem 1rem;border-bottom:1px solid var(--medium-gray)}.denomination-table[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:last-child td[_ngcontent-%COMP%]{border-bottom:none}.denomination-table[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:hover{background-color:#89b03e08}.denomination-value[_ngcontent-%COMP%]{font-weight:600;color:#212529}.quantity-cell[_ngcontent-%COMP%]{text-align:center}.quantity-badge[_ngcontent-%COMP%]{display:inline-block;padding:.25rem .5rem;color:#89b03e;border-radius:4px;font-weight:600;min-width:30px}.total-cell[_ngcontent-%COMP%]{text-align:right;font-weight:600;color:#89b03e}.zero-quantity[_ngcontent-%COMP%] .quantity-badge[_ngcontent-%COMP%], .zero-quantity[_ngcontent-%COMP%] .total-cell[_ngcontent-%COMP%]{color:#000}.last-updated[_ngcontent-%COMP%]{display:flex;justify-content:center;align-items:center;gap:.5rem;font-size:.85rem;color:var(--dark-gray);padding-top:.75rem;border-top:1px solid var(--medium-gray)}.last-updated[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{color:#89b03e}"]})};var ft=class n{httpService=O(Ao);cashMachineConfig=O(rn);socketConnection;_cashMachineEvent=new xe;_withdrawMoneyStatus=new xe;cashMachineEvent$=this._cashMachineEvent.asObservable();withdrawMoneyStatus$=this._withdrawMoneyStatus.asObservable();_isSignalRConnected=T(!1);isConnected=J(()=>this.cashMachineConfig.isEnabled()&&this._isSignalRConnected()&&this.isConnectedState());toastr=O(L);dialog=O(ye);totalAmountBeforePayment=T(0);initCashMachineOnStartup(){if(this.cashMachineConfig.isEnabled()){let e=this.cashMachineConfig.url();e&&this.initConnection(e)}}url=T("");originUrl=J(()=>{let t="";return this.url()&&(t=new URL(this.url()).origin),t});checkPaymentStatus(t){return this.getCashMachineTotalAmount().pipe(W(e=>{let i=this.totalAmountBeforePayment()+t;return e>=i}),ce(e=>{e||this.toastr.error("Payment has not been settled.","Payment Failed")}))}initConnection(t){this.url.set(t),this.socketConnection=new bi().withUrl(t).withAutomaticReconnect().configureLogging(yi.Information).build(),this.listenToConnectionEvents(),this.listenToEvents(),this.startConnection(t)}startConnection(t){this.socketConnection.start().then(()=>{this._isSignalRConnected.set(!0),this.toastr.success("Successfully connected to Cash Machine","Success"),this.cashMachineConfig.connect(t)}).catch(e=>{this.cashMachineConfig.disconnect(),this.toastr.error(e,"Failed connecting to Cash Machine"),console.log(e)})}sendWithdrawMoney(t){return this.socketConnection.send("WithdrawMoney",{Value:t}).catch(e=>console.error(e))}listenToEvents(){this.socketConnection.on("OnReceiveMoney",t=>{if(t){let e=JSON.parse(t);this._cashMachineEvent.next(e)}}),this.socketConnection.on("WithdrawMoneyStatus",t=>{t&&this._withdrawMoneyStatus.next(t?.status)})}stopConnection(){this.socketConnection.stop().then(()=>{console.info("SignalR for Cash Machine is Disconnected"),this.cashMachineConfig.disconnect()})}isConnectedState(){return this.socketConnection&&u.IsNotEmpty(this.socketConnection.connectionId)&&this.socketConnection.state===so.Connected}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(t=>{console.log(t),console.info("SignalR for Cash Machine is Closed"),this.dialog.closeAll(),this.openDialogConnectCashMachine(),this._isSignalRConnected.set(!1)})}openDialogConnectCashMachine(){this.dialog.open(an).afterClosed().pipe(ne(t=>!!t)).subscribe(t=>{this.initConnection(t)})}getCashMachineTotalAmount(){return this.httpService.get(`${this.originUrl()}${U.GetCashMachineTotal}`).pipe(W(t=>t.total))}getCashMachineDenominations(){return this.httpService.get(`${this.originUrl()}${U.GetCashMachineBreakdown}`)}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var Da=(n,t,e,i)=>({"unselected-online-card":n,"selected-online-card":t,"selected-offline-card":e,"unselected-offline-card":i}),xa=(n,t)=>({"selected-color":n,"unselected-online-card-color":t}),Ia=(n,t)=>({"selected-color":n,"unselected-offline-card-color":t});function Ta(n,t){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 e=p();m("ngClass",We(1,xa,e.selected(),!e.selected()))}}function wa(n,t){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 e=p();m("ngClass",We(1,Ia,e.selected(),!e.selected()))}}var sn=class n{statusType=ot("ONLINE");selected=ot(!1);clickCard=It({alias:"onClick"});onClick(){this.clickCard.emit()}static \u0275fac=function(e){return new(e||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(e,i){e&1&&(a(0,"div",0),_("click",function(){return i.onClick()}),a(1,"div",1)(2,"div",2),y(3,"i",3),a(4,"h4",4),d(5),s(),h(6,Ta,5,4,"p",5)(7,wa,5,4,"p",5),s()()()),e&2&&(m("ngClass",zn(3,Da,i.statusType()=="ONLINE"&&!i.selected(),i.statusType()=="ONLINE"&&i.selected(),i.statusType()=="OFFLINE"&&i.selected(),i.statusType()=="OFFLINE"&&!i.selected())),l(5),I(" ",i.statusType()," "),l(),C(i.statusType()=="ONLINE"?6:7))},dependencies:[me,Ee],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 ln=class n{configOptions=[{label:"Online",value:!1},{label:"Offline",value:!0}];orderHandling=rt(!1);productHandling=rt(!1);startConfig=rt(!1);isOffline=J(()=>this.orderHandling()&&this.productHandling()&&this.startConfig());onClickCard(t){this.orderHandling.set(t),this.productHandling.set(t),this.startConfig.set(t)}static \u0275fac=function(e){return new(e||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(e,i){e&1&&(a(0,"div",0)(1,"div")(2,"div"),y(3,"i",1),a(4,"span",2),d(5,"Connection Status"),s()(),a(6,"div",3)(7,"app-card-status",4),_("onClick",function(){return i.onClickCard(!1)}),s(),a(8,"app-card-status",5),_("onClick",function(){return i.onClickCard(!0)}),s()()(),a(9,"div",6)(10,"div",7),y(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),Q("ngModelChange",function(r){return B(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),Q("ngModelChange",function(r){return B(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),Q("ngModelChange",function(r){return B(i.startConfig,r)||(i.startConfig=r),r}),s()()()()()),e&2&&(l(7),m("selected",!i.isOffline()),l(),m("selected",i.isOffline()),l(10),m("items",i.configOptions)("clearable",!1),j("ngModel",i.orderHandling),l(4),m("items",i.configOptions)("clearable",!1),j("ngModel",i.productHandling),l(4),m("items",i.configOptions)("clearable",!1),j("ngModel",i.startConfig))},dependencies:[sn,Do,wt,lt,ge,Me],encapsulation:2})};var cn=class n{localDataService=O(De);httpService=O(_e);totalSyncProduct={totalOfflineProduct:0,totalOnlineProduct:0};getTotalProducts(t=!1){return this.totalSyncProduct.totalOfflineProduct==0||t?this.localDataService.findAllVariant().pipe(ne(e=>e.length>0),te(e=>{let i=this.calculateOfflineProducts(e);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(W(o=>{let r=o?JSON.parse(o)?.Count:0;return{totalOfflineProduct:i.length,totalOnlineProduct:r}}),ce(o=>{this.totalSyncProduct=o}))})):Qe(this.totalSyncProduct)}calculateOfflineProducts(t){let e=new Set,i=[];for(let o of t)e.has(o.ProductID)==!1&&(e.add(o.ProductID),i.push(o));return i}getSyncTime(){return this.localDataService.getSyncTime().pipe(W(t=>{let e={date:null,daysDiff:0};if(t){let i=new Date(t.time),o=this.calculateSyncDiff(i);e={date:new Date(t.time),daysDiff:o}}return e}))}calculateSyncDiff(t){let e=0;return t&&(e=Math.floor((new Date().getTime()-t?.getTime())/1e3/60/60/24)),e}syncToLocalDatabase(){return Je([this.syncOutlets(),this.syncProducts(),this.syncOutletPrices()]).pipe(te(()=>this.localDataService.updateSyncTime()))}syncOutlets(){return this.httpService.get(U.SynOutlet).pipe(te(t=>this.localDataService.syncRegisters(t)))}syncProducts(){return this.httpService.get(U.SyncProducts).pipe(te(t=>this.localDataService.syncVariants(t)))}syncOutletPrices(){return this.httpService.get(U.SynOutletPrice).pipe(te(t=>this.localDataService.syncOutletPrice(t)))}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};function Ea(n,t){n&1&&(d(0),v(1,"number")),n&2&&I(" ",D(1,1,t.totalOnlineProduct)," ")}function Ra(n,t){n&1&&d(0," 0 ")}function Na(n,t){n&1&&(d(0),v(1,"number")),n&2&&I(" ",D(1,1,t.totalOfflineProduct)," ")}function Aa(n,t){n&1&&d(0," 0 ")}function ka(n,t){if(n&1&&(d(0),v(1,"number")),n&2){let e=p();I(" Last Sync: ",D(1,1,e.daysDiff)," days ago! ")}}function Va(n,t){if(n&1&&(d(0),v(1,"date")),n&2){let e=p(2);I(" Last Sync: ",re(1,1,e.date,"dd MMM yyyy HH:mm")," ")}}function Fa(n,t){n&1&&d(0," Never been sync ")}function Ba(n,t){if(n&1&&h(0,Va,2,4)(1,Fa,1,0),n&2){let e=p();C(e.date?0:1)}}function La(n,t){n&1&&h(0,ka,2,3)(1,Ba,2,1),n&2&&C(t.daysDiff>14?0:1)}var dn=class n{productSyncService=O(cn);onlineStatusService=O(be);isOnline$=this.onlineStatusService.getOnlineStatus$();toastr=O(L);productCount$=this.productSyncService.getTotalProducts().pipe(Be(1));syncTime$=this.productSyncService.getSyncTime().pipe(Be(1));onSyncProduct(){this.productSyncService.syncToLocalDatabase().subscribe({next:()=>{this.productCount$=this.productSyncService.getTotalProducts(!0).pipe(Be(1)),this.syncTime$=this.productSyncService.getSyncTime().pipe(Be(1)),this.toastr.success("Sync Product Offline Successfully","Success!")},error:t=>{this.toastr.error("Error syncing products. Please try again.","Error"),console.error("Error syncing products:",t)}})}static \u0275fac=function(e){return new(e||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(e,i){if(e&1&&(A(0,"div")(1,"div"),Xe(2,"i",0),A(3,"span",1),d(4,"Product Sync"),F()(),A(5,"div",2)(6,"div",3)(7,"div")(8,"span",4),d(9,"Online Products"),F(),A(10,"h3",5),h(11,Ea,2,3),v(12,"async"),Tn(13,Ra,1,0),F()(),A(14,"div",6)(15,"span",4),d(16,"Offline Products"),F(),A(17,"h3",5),h(18,Na,2,3),v(19,"async"),Tn(20,Aa,1,0),F(),A(21,"small"),h(22,La,2,1),v(23,"async"),F()()(),A(24,"div")(25,"button",7),v(26,"async"),$n("click",function(){return i.onSyncProduct()}),Xe(27,"i",8),A(28,"span"),d(29,"Sync Now"),F()()()()(),A(30,"div",9)(31,"div"),Xe(32,"i",10),A(33,"span",1),d(34,"Product Details"),F()(),A(35,"div",11)(36,"div",12)(37,"div"),Xe(38,"img",13),F(),A(39,"h4",14),d(40,"Coming Soon"),F()()()()),e&2){let o,r,c;l(11),C((o=D(12,4,i.productCount$))?11:13,o),l(7),C((r=D(19,6,i.productCount$))?18:20,r),l(4),C((c=D(23,8,i.syncTime$))?22:-1,c),l(3),Gn("disabled",!D(26,10,i.isOnline$))}},dependencies:[me,He,G,Ke],encapsulation:2})};var Ua=n=>({data:n,type:"unsent"}),Wa=n=>({data:n,type:"success"}),Ga=n=>({data:n,type:"fail"}),$a=(n,t)=>({"table-height":n,"table-height-default":t}),qa=n=>({ID:n});function Ja(n,t){n&1&&_i(0)}function za(n,t){if(n&1){let e=E();a(0,"div",4)(1,"button",7),v(2,"async"),_("click",function(){b(e);let o=p();return S(o.uploadUnsentOrders())}),y(3,"i",8),a(4,"span"),d(5,"Upload"),s()()()}if(n&2){let e=p();l(),m("disabled",D(2,1,e.isOnline$)==!1)}}function Ka(n,t){n&1&&_i(0)}function Ya(n,t){if(n&1){let e=E();a(0,"div",4)(1,"button",9),_("click",function(){b(e);let o=p();return S(o.clearSuccessUploadedOrders())}),y(2,"i",10),a(3,"span"),d(4,"Clear"),s()()()}}function Za(n,t){n&1&&_i(0)}function Xa(n,t){if(n&1){let e=E();a(0,"div",4)(1,"button",11),_("click",function(){b(e);let o=p();return S(o.clearFailedOrders())}),y(2,"i",10),a(3,"span"),d(4,"Clear"),s()()()}}function es(n,t){n&1&&y(0,"th")}function ts(n,t){if(n&1&&(a(0,"a",18),d(1),s()),n&2){let e=p().$implicit;m("queryParams",k(2,qa,e.Invoice==null?null:e.Invoice.ID)),l(),I(" ",e.Order.Number," ")}}function is(n,t){if(n&1&&d(0),n&2){let e=p().$implicit;I(" ",e.Order.Number," ")}}function ns(n,t){if(n&1&&(a(0,"span",21),d(1),v(2,"limitText"),s()),n&2){let e=p().$implicit;m("matTooltip",(e==null||e.Variant==null?null:e.Variant.Name.length)>=30?e==null||e.Variant==null?null:e.Variant.Name:""),l(),P(re(2,2,e==null||e.Variant==null?null:e.Variant.Name,30))}}function os(n,t){if(n&1&&(a(0,"div",19),h(1,ns,3,5,"span",21),s()),n&2){let e=t.$implicit;l(),C(e?1:-1)}}function rs(n,t){if(n&1&&(a(0,"span"),d(1),v(2,"number"),s(),a(3,"span",22),d(4,"x"),s(),a(5,"span"),d(6),v(7,"number"),s()),n&2){let e=p().$implicit;l(),P(D(2,2,e==null?null:e.Quantity)),l(5),P(D(7,4,e==null?null:e.Price))}}function as(n,t){if(n&1&&(a(0,"div",20),h(1,rs,8,6),s()),n&2){let e=t.$implicit;l(),C(e?1:-1)}}function ss(n,t){if(n&1&&(a(0,"span"),d(1),v(2,"number"),s()),n&2){let e=p().$implicit;l(),P(D(2,1,(e==null?null:e.Price)*(e==null?null:e.Quantity)))}}function ls(n,t){if(n&1&&(a(0,"div",20),h(1,ss,3,3,"span"),s()),n&2){let e=t.$implicit;l(),C(e?1:-1)}}function cs(n,t){if(n&1){let e=E();a(0,"a",26),_("click",function(){b(e);let o=p(2).$implicit,r=p(3);return S(r.uploadFailedOrder(o))}),y(1,"i",27),s()}}function ds(n,t){if(n&1){let e=E();a(0,"a",28),_("click",function(){b(e);let o=p(2).$implicit,r=p(2).type,c=p();return S(r=="fail"?c.removeFailedOrder(o):c.removeUnsentOrder(o))}),y(1,"i",29),s()}}function ms(n,t){if(n&1&&(a(0,"td")(1,"div",23),h(2,cs,2,0,"a",24),v(3,"async"),h(4,ds,2,0,"a",25),s()()),n&2){let e=p(3).type,i=p();l(2),C(e=="fail"&&D(3,2,i.isOnline$)?2:-1),l(2),C(i.role.sell.Delete&&e!="success"?4:-1)}}function ps(n,t){if(n&1&&(a(0,"tr")(1,"td"),h(2,ts,2,4,"a",18)(3,is,1,1),s(),a(4,"td")(5,"div"),d(6),v(7,"date"),s(),a(8,"div"),d(9),v(10,"date"),s()(),a(11,"td"),z(12,os,2,1,"div",19,Le),s(),a(14,"td"),z(15,as,2,1,"div",20,Le),s(),a(17,"td"),z(18,ls,2,1,"div",20,Le),s(),h(20,ms,5,4,"td"),s()),n&2){let e=t.$implicit,i=p(2).data,o=p();l(2),C(o.activeFilter()==1?2:3),l(4),I(" ",re(7,4,e==null||e.Order==null?null:e.Order.ClientTimestamp,"dd MMM yyyy")," "),l(3),I(" ",re(10,7,e==null||e.Order==null?null:e.Order.ClientTimestamp,"HH:mm")," "),l(3),K(e.CartItems),l(3),K(e.CartItems),l(3),K(e.CartItems),l(2),C((i==null?null:i.length)>0?20:-1)}}function us(n,t){if(n&1&&z(0,ps,21,10,"tr",null,Se),n&2){let e=p().data;K(e)}}function gs(n,t){n&1&&(a(0,"tr",17)(1,"td",30),y(2,"empty-state-table"),s()())}function fs(n,t){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,es,1,0,"th"),s()(),a(15,"tbody"),h(16,us,2,0)(17,gs,3,0,"tr",17),s()()()),n&2){let e=t.data;et(We(4,$a,(e==null?null:e.length)>0,(e==null?null:e.length)===0)),l(14),C((e==null?null:e.length)>0?14:-1),l(2),C((e==null?null:e.length)>0?16:17)}}var mn=class n{localDataService=O(De);onlineService=O(be);role=O(_o);toastr=O(L);isOnline$=this.onlineService.getOnlineStatus$();unsentOrders$;failedOrders$;successUploadedOrders$;activeFilter=T(0);onEmptyOfflineOrder=It();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(),Be(1))}initSuccessUploadedOrders(){this.successUploadedOrders$=this.localDataService.successUploadedOrders$.pipe(this.pipeMap(),Be(1))}initUnsentOrders(){this.unsentOrders$=Je([this.localDataService.unsentOrders$,this.onlineService.getOnlineStatus$()]).pipe(W(([t,e])=>t),this.pipeMap(),Be(1))}pipeMap(){return pi(W(t=>t.map(e=>fe($,e))))}uploadUnsentOrders(){this.localDataService.uploadOrders().pipe(te(()=>this.localDataService.totalOfflineOrders$),ce(t=>{t===0&&this.onEmptyOfflineOrder.emit()}),Ue(1)).subscribe()}removeUnsentOrder(t){confirm("Are you sure you want to delete this offline order? This action cannot be undone.")&&this.localDataService.removeOrder(t.id).pipe(te(()=>this.localDataService.totalOfflineOrders$),ce(i=>{i===0&&this.onEmptyOfflineOrder.emit()}),Ue(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(t){this.localDataService.uploadFailedOrder(t).pipe(Ue(1)).subscribe()}removeFailedOrder(t){confirm("Are you sure you want to delete this offline order? This action cannot be undone.")&&this.localDataService.removeFailedOrder(t.id).pipe(Ue(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(Ue(1)).subscribe({next:()=>{this.toastr.success("Success to clear failed offline order","Success")},error:e=>{this.toastr.error("Failed to clear failed offline order","Error!")}})}clearSuccessUploadedOrders(){this.localDataService.clearSuccessUploadedOrder().pipe(Ue(1)).subscribe({next:()=>{this.toastr.success("Success to clear success uploaded offline order","Success")},error:t=>{this.toastr.error("Failed to clear success uploaded offline order","Error!")}})}static \u0275fac=function(e){return new(e||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(e,i){if(e&1&&(a(0,"div",1)(1,"custom-tabs")(2,"tab",2),ee(3,Ja,1,0,"ng-container",3),v(4,"async"),h(5,za,6,3,"div",4),v(6,"async"),s(),a(7,"tab",5),ee(8,Ka,1,0,"ng-container",3),v(9,"async"),h(10,Ya,5,0,"div",4),v(11,"async"),s(),a(12,"tab",6),ee(13,Za,1,0,"ng-container",3),v(14,"async"),h(15,Xa,5,0,"div",4),v(16,"async"),s()()(),ee(17,fs,18,7,"ng-template",null,0,Kn)),e&2){let o,r,c,g=Ce(18);l(3),m("ngTemplateOutlet",g)("ngTemplateOutletContext",k(21,Ua,D(4,9,i.unsentOrders$))),l(2),C(((o=D(6,11,i.unsentOrders$))==null?null:o.length)>0?5:-1),l(3),m("ngTemplateOutlet",g)("ngTemplateOutletContext",k(23,Wa,D(9,13,i.successUploadedOrders$))),l(2),C(((r=D(11,15,i.successUploadedOrders$))==null?null:r.length)>0&&(i.role.sell!=null&&i.role.sell.Delete)?10:-1),l(3),m("ngTemplateOutlet",g)("ngTemplateOutletContext",k(25,Ga,D(14,17,i.failedOrders$))),l(2),C(((c=D(16,19,i.failedOrders$))==null?null:c.length)>0&&(i.role.sell!=null&&i.role.sell.Delete)?15:-1)}},dependencies:[me,eo,Ei,Ni,Ri,ko,Ko,zt,Si,ro,oo,He,G,Ke,So],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 hs(n,t){if(n&1){let e=E();a(0,"app-setup",8),Q("orderHandlingChange",function(o){b(e);let r=p();return B(r.orderUsingLocal,o)||(r.orderUsingLocal=o),S(o)})("productHandlingChange",function(o){b(e);let r=p();return B(r.productUsingLocal,o)||(r.productUsingLocal=o),S(o)})("startConfigChange",function(o){b(e);let r=p();return B(r.configUsingLocal,o)||(r.configUsingLocal=o),S(o)}),s()}if(n&2){let e=p();j("orderHandling",e.orderUsingLocal)("productHandling",e.productUsingLocal)("startConfig",e.configUsingLocal)}}var pn=class n{constructor(t){this.data=t;this.initActiveTab()}modalConfig;dialog=O(Z);onlineStatusService=O(be);localDataService=O(De);orderUsingLocal=T(!1);productUsingLocal=T(!1);configUsingLocal=T(!1);offlineConfig$=this.onlineStatusService.offlineConfig$.pipe(ce(t=>{this.orderUsingLocal.set(t.orderUsingLocal),this.productUsingLocal.set(t.productUsingLocal),this.configUsingLocal.set(t.configUsingLocal)}),Be(1));activeTab=T("SETUP");totalOfflineOrders$=this.localDataService.totalOfflineOrders$.pipe(Be(1));initActiveTab(){this.activeTab.update(t=>(this.data?.activeTab&&(t=this.data.activeTab),t)),this.initModalConfig()}initModalConfig(){this.modalConfig=new Y,this.modalConfig.title="Offline Order Configuration",this.modalConfig.customWidth="600px",this.modalConfig.hideScrollbar=!0,Je([this.localDataService.unsentOrders$.pipe(W(t=>t?.length)),this.onlineStatusService.getOnlineStatus$()]).pipe(oe()).subscribe(([t,e])=>{this.data?.activeTab=="ORDER"&&t>0&&e?(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 t=new Eo(this.configUsingLocal(),this.productUsingLocal(),this.orderUsingLocal());this.onlineStatusService.updateOfflineConfigDB(t),this.dialog.close()}onClose(){this.dialog.close()}static \u0275fac=function(e){return new(e||n)(M(pe))};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(e,i){if(e&1&&(a(0,"modal-material",0),_("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,hs,1,3,"app-setup",4),v(6,"async"),s(),a(7,"tab",5),v(8,"async"),a(9,"app-order-management",6),_("onEmptyOfflineOrder",function(){return i.onEmptyOfflineOrder()}),s()(),a(10,"tab",7),y(11,"app-product-sync"),s()()()()()),e&2){let o;m("config",i.modalConfig),l(4),m("active",i.activeTab()=="SETUP"),l(),C((o=D(6,6,i.offlineConfig$))?5:-1,o),l(2),m("active",i.activeTab()=="ORDER")("badge",D(8,8,i.totalOfflineOrders$)),l(3),m("active",i.activeTab()=="PRODUCT")}},dependencies:[me,ie,ln,Ei,Ni,Ri,dn,mn,He],styles:[".dialog-offline-content[_ngcontent-%COMP%]{min-height:360px}"]})};var un=class{RegisterID;InvoiceNumber;Amount};var gn=class{modalConfig=new Y;viewState=4;paymentSuggestion;payLaterEnabled=!1;payNowEnabled=!1;payNowNLaterEnabled=!1;toleranceAmount=0;merchantName;payLaterDueDate;payLaterDueDays;numpadVisible=!1;config;uniquePaymentMethodOnSplit;isCancelEcrTransaction=!1;emoneyType=Ti;splitPaymentEnabled=!0;isCustomerAssigned=T(!1);isCashMachineProvideChange=T(!0);constructor(){this.modalConfig.title="Amount to Pay: ",this.modalConfig.disableKeyup=!0,this.modalConfig.customWidth="650px",this.modalConfig.bodyScrollable=!0}mapAppConfigJson(t){this.merchantName=t.PaymentConfigGopay.MerchantName,this.toleranceAmount=t.ModuleSell.ToleranceAmount,this.numpadVisible=t.ModuleSell.NumPadVisible;let e=t.ModuleSell.PaymentDialog;switch(this.config=e,this.uniquePaymentMethodOnSplit=e.UniquePaymentMethodOnSplit,e.EnabledOptions){case 0:this.viewState=0,this.payNowEnabled=!0;break;case 1:this.viewState=1,this.payLaterEnabled=!0;break;case 2:switch(e.DefaultOption){case 0:this.viewState=0;break;case 1:this.viewState=1;break}this.payNowNLaterEnabled=!0;break}}modalConfigQrisOnlyPayment(t=!0){this.modalConfig.hideOk=t}enableEMoneyModal(t){this.modalConfig.backButton=t,this.modalConfig.hideCancel=t,this.modalConfig.hideClose=t,this.modalConfig.hideOk=t}enableEmoneyConfirmModal(t){this.modalConfig.backButton=t,this.modalConfig.hideCancel=t,this.modalConfig.hideClose=t,this.modalConfig.hideOk=t,t?(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(t){this.modalConfig.hideCancel=t,this.modalConfig.hideClose=t,this.modalConfig.hideOk=t,this.isCancelEcrTransaction=!1,t?this.modalConfig.customWidth="550px":(this.modalConfig.customWidth="650px",this.modalConfig.headerType=de.Success,this.modalConfig.title="Amount to Pay: ")}enableModalCashMachine(t){this.modalConfig.hideCancel=t,this.modalConfig.hideOk=t,t?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 fn=class n{constructor(t,e,i,o,r,c,g,x){this._invoiceCalculatorService=t;this._posService=e;this._orderDataService=i;this._orderProcessorService=o;this._onlineStatusService=r;this._signalBroadCast=c;this.decimalPipe=g;this._registerService=x;this.subscribeToObservableChanges(),this.initPaymenyDefault()}defaultCashPaymentMethodID=0;isOnline=!0;salesOrderData=new $;toastr=O(L);_State;get State(){return this._State}set State(t){this._State=t}get denomination(){return this._posService.Data.Denomination}get appConfigJSON(){return this._posService.Data.AppConfigJSON}get toleranceAmount(){return this.appConfigJSON.ModuleSell.ToleranceAmount}get paymentList(){return u.IsNotEmpty(this._registerService.Data)?this._registerService.Data.Payments:Array()}initPaymenyDefault(){let t=u.GuidEmpty;if(this.paymentList.length>0){let e=this.paymentList.find(i=>i.TypeID!=3);if(e)return this.defaultCashPaymentMethodID=e.ID,e.ID}else this.toastr.error("No payment methods available.","Error");return t}subscribeToObservableChanges(){this._onlineStatusService.getOnlineStatus$().subscribe(t=>{this.isOnline=t}),this._orderDataService.Data$.subscribe(t=>{this.salesOrderData=t})}getPaymentList(){return this.paymentList}submitOrder(t){this.salesOrderData.Payments=fe(Ye,t),this.salesOrderData.Payments=this.removePayment(this.salesOrderData),this._orderDataService.pushNewValue(this.salesOrderData),this._orderDataService.submitOrder(this.appConfigJSON).then(e=>{this.updateBroadcastState(e),e=this.setFinalAmountOfflineOrder(e),this._orderProcessorService.updatePosState(1,e)},e=>{(e instanceof gi||e?.name=="TimeoutError")&&(this._orderDataService.pushNewValue(this.salesOrderData),this._orderProcessorService.updatePosState(9))})}updateBroadcastState(t){let e=this.salesOrderData.TotalPaidAmount-this._invoiceCalculatorService.Data;this._signalBroadCast.BroadcastStateToCustomerDisplay(1,t.ObjectID,t.LoyaltyPoint,e).subscribe()}removePayment(t){return t.Payments.filter(i=>i.Amount!==0)}setFinalAmountOfflineOrder(t){return this.isOnline==!1&&(t.Final=this._invoiceCalculatorService.Data),t}generateCashSuggestion(){let t=this.paymentList.filter(i=>i.TypeID==1),e=[];return t.length>0&&(e.push(this._invoiceCalculatorService.Data),this.defaultCashPaymentMethodID=t[0].ID,this.denomination.forEach(i=>{let o=this._invoiceCalculatorService.Data/i;o=Math.ceil(o);let r=o*i;r!=this._invoiceCalculatorService.Data&&e.indexOf(r)===-1&&e.length<3&&e.push(r)})),e}static \u0275fac=function(e){return new(e||n)(f(le),f(X),f(H),f(je),f(be),f(gt),f(G),f(se))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var hn=class n{constructor(t,e,i,o,r){this.httpService=t;this.orderDataService=e;this.ecrLocalstorageService=i;this.ecrSignalR=o;this.toastr=r}onPay(t){let e=this.orderDataService.Data?.Order?.Number,i={Transaction_Type:"01",Transaction_Amount:t,Invoice_Number:e,Expire_Date:2406},o=this.ecrLocalstorageService.url();return Je([this.httpService.post(`${o}/api/Payment/Send`,i),this.ecrSignalR.ecrEvent$]).pipe(W(([r,c])=>c),nt(r=>{let c=r?.message?r?.message:r?.Message;return this.toastr.error(c,"Error"),St(()=>r)}))}static \u0275fac=function(e){return new(e||n)(f(to),f(H),f($t),f(qt),f(L))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};function ys(n,t){if(n&1&&(A(0,"div",0)(1,"div",2)(2,"h3",3),d(3," Insert Cash into Machine "),F(),A(4,"p",4),d(5," Feed bills into the cash acceptor slot below the screen "),F(),A(6,"div",5)(7,"span",6)(8,"span",7),d(9,"\u23F3"),F(),d(10," Waiting for cash insertion "),F()(),A(11,"div",8)(12,"div",9)(13,"span",10),d(14,"Amount Received:"),F(),A(15,"span",11)(16,"span"),d(17),F(),A(18,"span"),d(19),v(20,"number"),F()()(),A(21,"div",12)(22,"span",10),d(23,"Remaining Balance:"),F(),A(24,"span",13)(25,"span"),d(26),F(),A(27,"span"),d(28),v(29,"number"),F()()()()(),A(30,"div",14)(31,"div",15)(32,"span",16),d(33,"Payment Progress"),F(),A(34,"span",17)(35,"span"),d(36),F(),A(37,"span"),d(38),v(39,"number"),F(),d(40," / "),A(41,"span"),d(42),F(),A(43,"span"),d(44),v(45,"number"),F()()(),A(46,"div",18),Xe(47,"div",19),F()()()),n&2){let e=p();l(17),P(e.currencySymbol()),l(2),P(D(20,11,e.receivedAmount())),l(7),P(e.currencySymbol()),l(2),P(D(29,13,e.remainingBalance())),l(8),P(e.currencySymbol()),l(2),P(D(39,15,e.receivedAmount())),l(4),P(e.currencySymbol()),l(2),P(D(45,17,e.totalAmount())),l(2),vi("aria-valuenow",e.progress()),l(),qn("width",e.progress(),"%")}}function bs(n,t){if(n&1&&(A(0,"div",23),d(1," Change: "),A(2,"span"),d(3),F(),A(4,"span"),d(5),v(6,"number"),F()()),n&2){let e=p(2);l(3),P(e.currencySymbol()),l(2),P(D(6,2,e.changeDue()))}}function Ss(n,t){n&1&&(A(0,"div",24),Xe(1,"i",25),A(2,"div",26),d(3,"Manual Change Required"),F(),A(4,"p",27)(5,"span",28),d(6,"Machine cannot dispense exact change."),F(),A(7,"span"),d(8,"Please collect change from the cashier."),F()()())}function Ps(n,t){n&1&&(A(0,"div",24),Xe(1,"i",25),A(2,"div",26),d(3,"Change Dispensed"),F(),A(4,"p",27)(5,"span",28),d(6,"The machine has provided your change."),F(),A(7,"span"),d(8,"Please ensure you have collected your change from the dispenser before closing this window."),F()()())}function Os(n,t){if(n&1&&h(0,Ps,9,0,"div",24),n&2){let e=p(2);C(e.changeDue()>0?0:-1)}}function Ms(n,t){if(n&1&&(A(0,"div",1)(1,"div",20)(2,"span",21),d(3,"\u2713"),F()(),A(4,"div",22),d(5," Payment Accepted! "),F(),h(6,bs,7,4,"div",23),h(7,Ss,9,0,"div",24)(8,Os,1,1),F()),n&2){let e=p();l(6),C(e.changeDue()>0?6:-1),l(),C(e.canProvideChange()==!1?7:e.canProvideChange()==!0?8:-1)}}var Cn=class n{cashMachineService=O(ft);calculatorService=O(le);currencySymbol=T(this.calculatorService.currencySymbol);totalAmount=ot(0);transactionComplete=It({alias:"onTransactionComplete"});receivedAmount=T(0);paymentState=T("paying");changeDue=T(0);canProvideChange=T(!0);remainingBalance=J(()=>Math.max(0,this.totalAmount()-this.receivedAmount()));progress=J(()=>{let t=this.totalAmount();return t===0?0:Math.min(100,this.receivedAmount()/t*100)});constructor(){this.initTotalCashMachineAmount(),this.initListenCashMachine(),this.initWithdrawStatus()}initTotalCashMachineAmount(){this.cashMachineService.getCashMachineTotalAmount().pipe(oe()).subscribe(t=>{this.cashMachineService.totalAmountBeforePayment.set(t)})}initWithdrawStatus(){this.cashMachineService.withdrawMoneyStatus$.pipe(oe()).subscribe(t=>{this.canProvideChange.set(t),this.changeDue()>0&&this.completeTransaction()})}initListenCashMachine(){this.cashMachineService.cashMachineEvent$.pipe(ne(t=>t&&t.length>0),W(t=>t.reduce((e,i)=>e+i.value,0)),te(t=>this.cashMachineService.getCashMachineTotalAmount().pipe(W(e=>({cashMachineTotal:e,insertedAmount:t})))),oe()).subscribe(({cashMachineTotal:t,insertedAmount:e})=>{this.validatePayment(t,e)})}validatePayment(t,e){this.receivedAmount.update(c=>c+e);let i=this.totalAmount(),o=this.cashMachineService.totalAmountBeforePayment(),r=t-i;o<=r&&setTimeout(()=>this.showSuccessState(),500)}showSuccessState(){let t=this.receivedAmount()-this.totalAmount();this.changeDue.set(t),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(e){return new(e||n)};static \u0275cmp=N({type:n,selectors:[["cash-machine-payment"]],inputs:{totalAmount:[1,"totalAmount"]},outputs:{transactionComplete:"onTransactionComplete"},decls:2,vars:1,consts:[[1,"mb-3"],[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(e,i){e&1&&h(0,ys,48,19,"div",0)(1,Ms,9,2,"div",1),e&2&&C(i.paymentState()==="paying"?0:1)},dependencies:[me,G],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}"]})};var dr=n=>({selected:n}),mr=n=>({checked:n});function xs(n,t){if(n&1){let e=E();a(0,"div",1),_("click",function(){b(e);let o=p();return S(o.isSelectDueDate.set(!0))}),a(1,"div",2),y(2,"div",3),a(3,"div",4)(4,"label",5),d(5,"Due Date"),s(),a(6,"datepicker",6),Q("dateChange",function(o){b(e);let r=p();return B(r.paylaterDueDate,o)||(r.paylaterDueDate=o),S(o)}),_("dateChange",function(){b(e);let o=p();return S(o.dueDateChange())}),s(),a(7,"p",7),d(8," Select a specific date for payment due "),s()()()(),a(9,"div",8),_("click",function(){b(e);let o=p();return S(o.isSelectDueDate.set(!1))}),a(10,"div",2),y(11,"div",3),a(12,"div",4)(13,"label",5),d(14,"Due Days"),s(),a(15,"div",9)(16,"input",10),Q("ngModelChange",function(o){b(e);let r=p();return B(r.paylaterDueDays,o)||(r.paylaterDueDays=o),S(o)}),_("ngModelChange",function(){b(e);let o=p();return S(o.dueDayChange())}),s()(),a(17,"p",7),d(18," Enter number of days until payment is due "),s()()()()}if(n&2){let e=p();et(k(13,dr,e.isSelectDueDate())),l(2),et(k(15,mr,e.isSelectDueDate())),l(4),m("displayToggle",!1),j("date",e.paylaterDueDate),m("disabled",!e.isSelectDueDate()),l(3),et(k(17,dr,!e.isSelectDueDate())),l(2),et(k(19,mr,!e.isSelectDueDate())),l(5),j("ngModel",e.paylaterDueDays),m("disabled",e.isSelectDueDate())}}function Is(n,t){n&1&&(a(0,"div",0)(1,"div",11)(2,"div",12),y(3,"i",13),s(),a(4,"h3",14),d(5," Customer Required "),s(),a(6,"p",15),d(7," Customer is required for credit transactions. "),s(),a(8,"p",16),d(9," Please assign a customer to enable 'Later' payment. "),s()()())}var vn=class n{isCustomerAssigned=ot(!1);orderDate=ot(new Date);dueDate=rt(null);paylaterDueDate=rt(null);paylaterDueDays=rt(0);isSelectDueDate=T(!0);dueDateChange(){let t=new Date(this.orderDate()),e=this.paylaterDueDate()?this.paylaterDueDate():new Date;t.setHours(0,0,0,0),this.paylaterDueDays.set(u.differentInDays(t,e)),this.dueDate.set(e)}dueDayChange(){let t=new Date(this.orderDate());t.setDate(t.getDate()+this.paylaterDueDays()),t.setHours(0,0,0,0),this.paylaterDueDate.set(t),this.dueDate.set(t)}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=N({type:n,selectors:[["app-paylater"]],inputs:{isCustomerAssigned:[1,"isCustomerAssigned"],orderDate:[1,"orderDate"],dueDate:[1,"dueDate"],paylaterDueDate:[1,"paylaterDueDate"],paylaterDueDays:[1,"paylaterDueDays"]},outputs:{dueDate:"dueDateChange",paylaterDueDate:"paylaterDueDateChange",paylaterDueDays:"paylaterDueDaysChange"},decls:2,vars:1,consts:[["id","no-customer-info"],["id","option-date-card",1,"option-card","mb-8","selected",3,"click"],[1,"d-flex","align-items-start","gap-4",2,"gap","1.5rem"],["id","radio-date",1,"custom-radio","checked"],[1,"flex-grow-1"],[1,"fw-semibold","text-dark","cursor-pointer","d-block","mb-5","fs-4",2,"cursor","pointer"],["name","orderDate",1,"sell-paylater",3,"dateChange","displayToggle","date","disabled"],[1,"small","text-muted","mt-2",2,"font-size","0.75rem","color","#64748b"],["id","option-date-card",1,"option-card","mb-4","selected",3,"click"],[1,"relative"],["type","number","id","due-days-input","placeholder","Enter days","type","number",1,"form-input","pe-16",3,"ngModelChange","ngModel","disabled"],[1,"paylater-warning-box"],[1,"paylater-warning-icon-bg"],[1,"fas","fa-exclamation-triangle","paylater-warning-icon"],["id","customer-required-title",1,"paylater-warning-title"],["id","customer-required-msg",1,"paylater-warning-msg"],[1,"paylater-warning-desc"]],template:function(e,i){e&1&&h(0,xs,19,21)(1,Is,10,0,"div",0),e&2&&C(i.isCustomerAssigned()?0:1)},dependencies:[lt,ve,uo,ge,Me,Pi,Oo,wi,Di],styles:['.form-input[_ngcontent-%COMP%]{width:100%;padding:14px 16px;border:1px solid #e2e8f0;border-radius:5px;font-size:15px;transition:all .3s ease;background:#fff}.form-input[_ngcontent-%COMP%]:focus{outline:none;border-color:#89b03e;box-shadow:0 0 0 4px #89b03e26}.form-input[_ngcontent-%COMP%]:disabled{background:#f8fafc;color:#94a3b8;cursor:not-allowed}.form-input.readonly[_ngcontent-%COMP%]{background:linear-gradient(135deg,#f0fdf4,#ecfccb);border-color:#89b03e;color:#365314;font-weight:500}.option-card[_ngcontent-%COMP%]{padding:20px;border:2px solid #e2e8f0;border-radius:16px;cursor:pointer;transition:all .3s ease;background:#fff}.option-card[_ngcontent-%COMP%]:hover{border-color:#cbd5e1;box-shadow:0 4px 12px #0000000d}.option-card.selected[_ngcontent-%COMP%]{border-color:#89b03e;background:linear-gradient(135deg,#fefefe,#f7fee7);box-shadow:0 4px 16px #89b03e26}.custom-radio[_ngcontent-%COMP%]{width:22px;height:22px;border:2px solid #cbd5e1;border-radius:50%;display:flex;align-items:center;justify-content:center;transition:all .3s ease}.custom-radio.checked[_ngcontent-%COMP%]{border-color:#89b03e;background:#89b03e}.custom-radio.checked[_ngcontent-%COMP%]:after{content:"";width:8px;height:8px;background:#fff;border-radius:50%}.paylater-warning-box[_ngcontent-%COMP%]{background:#fffbeb;border:2px solid #fde68a;border-radius:18px;padding:1.8rem 1.2rem 1.2rem;text-align:center;max-width:700px;margin:.5rem auto;color:#a16207;box-sizing:border-box}.paylater-warning-icon-bg[_ngcontent-%COMP%]{background:#fef3c7;border-radius:50%;width:90px;height:90px;display:flex;align-items:center;justify-content:center;margin:0 auto 1.5rem}.paylater-warning-icon[_ngcontent-%COMP%]{font-size:2.5rem;color:#d97706}.paylater-warning-title[_ngcontent-%COMP%]{font-size:1.4rem;font-weight:700;margin-bottom:.7rem;color:#b45309;font-family:inherit}.paylater-warning-msg[_ngcontent-%COMP%]{font-size:1rem;color:#b45309;margin-bottom:.2rem}.paylater-warning-desc[_ngcontent-%COMP%]{font-size:.875rem;color:#ca8a04}[_nghost-%COMP%] datepicker .mat-mdc-form-field .mdc-notched-outline, [_nghost-%COMP%] datepicker .mat-mdc-form-field .mdc-notched-outline__notch, [_nghost-%COMP%] datepicker .mat-mdc-form-field .mdc-notched-outline__leading, [_nghost-%COMP%] datepicker .mat-mdc-form-field .mdc-notched-outline__trailing{border-color:#e2e8f0!important;border-width:1px!important}[_nghost-%COMP%] datepicker.sell-paylater .mat-mdc-form-field.mat-focused .mdc-notched-outline{border:1px solid #89b03e!important;box-shadow:0 0 0 4px #89b03e26;border-radius:4px}[_nghost-%COMP%] datepicker.sell-paylater input{font-size:16px}[_nghost-%COMP%] datepicker.sell-paylater .mat-mdc-form-field{width:100%;font-size:16px;background:#fff}[_nghost-%COMP%] datepicker.sell-paylater .mat-mdc-form-field .mat-mdc-icon-button, [_nghost-%COMP%] datepicker.sell-paylater .mat-mdc-form-field .mat-mdc-button-persistent-ripple, [_nghost-%COMP%] datepicker.sell-paylater .mat-mdc-form-field .mat-mdc-form-field-icon-suffix{outline:none!important}']})};function ws(n,t){n&1&&(a(0,"div",0)(1,"div",1),y(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 Es(n,t){n&1&&(a(0,"div",0)(1,"div",5),y(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 _n=class n{isCancel=!1;constructor(){}ngOnInit(){}static \u0275fac=function(e){return new(e||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(e,i){e&1&&h(0,ws,7,0)(1,Es,9,0,"div",0),e&2&&C(i.isCancel?1:0)},encapsulation:2})};var yn=class n{constructor(){}ngOnInit(){}static \u0275fac=function(e){return new(e||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(e,i){e&1&&(a(0,"div",0)(1,"div",1),y(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 Bn=n=>({selected:n}),As=(n,t)=>({active:n,"font-12":t}),ks=n=>({"border-top py-5":n}),Vs=n=>({"d-print-none":n}),Fs=n=>({"qris-barcode":n}),Bs=n=>({bottom:n});function Ls(n,t){if(n&1&&(a(0,"span"),d(1),s()),n&2){let e=p(2);l(),I(" (+",e.posData==null?null:e.posData.Invoice.SurchargePcg,"%) ")}}function Hs(n,t){if(n&1&&(a(0,"span"),d(1),s(),a(2,"span"),d(3),v(4,"number"),s()),n&2){let e=p(2);l(),P(e.cashierCalculatorService==null?null:e.cashierCalculatorService.currencySymbol),l(2),P(D(4,2,e.totalAmount()))}}function js(n,t){if(n&1&&(a(0,"header")(1,"div",6),ee(2,Ls,2,1,"span",1),h(3,Hs,5,4),s()()),n&2){let e=p();l(2),m("ngIf",(e.posData==null?null:e.posData.Invoice.SurchargePcg)>0),l(),C(e.userRole.PriceVisible?3:-1)}}function Qs(n,t){if(n&1){let e=E();a(0,"a",14),_("click",function(){b(e);let o=p(4);return S(o.onSplitClick())}),d(1," Split "),a(2,"span",15),d(3,"Payment"),s()()}if(n&2){let e=p(4);m("ngClass",k(1,Bn,e.modalFields.isStateSplit))}}function Us(n,t){if(n&1){let e=E();a(0,"a",16),_("click",function(){b(e);let o=p(4);return S(o.onLaterClick())}),d(1," Later "),a(2,"span",15),d(3,"Take Credit"),s()()}if(n&2){let e=p(4);m("ngClass",k(1,Bn,e.modalFields.isStateLater))}}function Ws(n,t){if(n&1){let e=E();a(0,"div")(1,"a",11),_("click",function(){b(e);let o=p(3);return S(o.onNowClick())}),d(2," Now "),s(),ee(3,Qs,4,3,"a",12)(4,Us,4,3,"a",13),s()}if(n&2){let e=p(3);l(),m("ngClass",k(3,Bn,e.modalFields.isStateNow)),l(2),m("ngIf",((e.modalFields==null||e.modalFields.paymentSuggestion==null?null:e.modalFields.paymentSuggestion.length)==0||e.cashPaymentChange<0)&&e.modalFields.splitPaymentEnabled&&!e.isQRISOnlyPayment()),l(),m("ngIf",e.modalFields.payNowEnabled==!1&&!e.userRole.CreditSalesLock)}}function Gs(n,t){if(n&1&&(a(0,"div",10),ee(1,Ws,5,5,"div",1),s()),n&2){let e=p(2);l(),m("ngIf",e.modalFields.payNowNLaterEnabled||e.modalFields.payNowEnabled)}}function $s(n,t){if(n&1){let e=E();a(0,"div",31)(1,"a",32),_("click",function(){let o=b(e).$implicit,r=p(5);return S(r.updateCashPayment(o))}),d(2),v(3,"number"),s()()}if(n&2){let e=t.$implicit,i=p(5);l(),m("ngClass",We(5,As,(i.Payments[0]==null?null:i.Payments[0].MethodID)==i.defaultCashPaymentMethodID&&(i.Payments[0]==null?null:i.Payments[0].PaidAmount)==e,i.modalFields.paymentSuggestion[0].toString().length>8)),l(),yt("",i.cashierCalculatorService==null?null:i.cashierCalculatorService.currencySymbol," ",D(3,3,e))}}function qs(n,t){if(n&1&&(a(0,"div",29),ee(1,$s,4,8,"div",30),s()),n&2){let e=p(4);l(),m("ngForOf",e.modalFields.paymentSuggestion)}}function Js(n,t){if(n&1&&(a(0,"div",33),d(1),v(2,"number"),s()),n&2){let e=p(4);m("ngClass",e.cashPaymentChange>0?"success":"danger"),l(),yt(" ",e.cashierCalculatorService==null?null:e.cashierCalculatorService.currencySymbol," ",D(2,3,e.cashPaymentChange)," ")}}function zs(n,t){if(n&1){let e=E();Ot(0),a(1,"div",17)(2,"div",21),y(3,"i",22),d(4," Cash "),s(),a(5,"div",23),ee(6,qs,2,1,"div",24),a(7,"div",25)(8,"div",26)(9,"input",27),Q("ngModelChange",function(o){b(e);let r=p(3);return B(r.inputAmountString,o)||(r.inputAmountString=o),S(o)}),_("ngModelChange",function(){b(e);let o=p(3);return S(o.updateCashPayment(o.inputAmountString))}),s(),ee(10,Js,3,5,"div",28),s()()()(),Mt()}if(n&2){let e=p(3);l(6),m("ngIf",e.userRole.PriceVisible),l(3),m("simpleKeyboard",e.keyboard),j("ngModel",e.inputAmountString),l(),m("ngIf",e.cashPaymentChange!=0)}}function Ks(n,t){if(n&1){let e=E();a(0,"div",36)(1,"button",37),_("click",function(){let o=b(e).$implicit,r=p(4);return S(r.handlingCashMachinePayment(o))}),a(2,"span",38),y(3,"img",39),s(),a(4,"span",38),d(5),v(6,"limitTo"),s()()()}if(n&2){let e=t.$implicit;l(2),m("hidden",e.ImageUrl==null),l(),m("src",e.ImageUrl,Ct),l(),m("hidden",e.ImageUrl!=null),l(),I(" ",re(6,4,e.Name,20)," ")}}function Ys(n,t){if(n&1&&(a(0,"div",17)(1,"div",21),y(2,"i",34),d(3," Cash Machine "),s(),a(4,"div",23)(5,"div",35),z(6,Ks,7,7,"div",36,Le),s()()()),n&2){let e=p(3);l(6),K(e.cashMachineList())}}function Zs(n,t){if(n&1){let e=E();a(0,"div",36)(1,"button",37),_("click",function(){let o=b(e).$implicit,r=p(4);return r.onPaymentMethodChanged(o),S(r.payWithEmoney(o))}),a(2,"span",38),y(3,"img",39),s(),a(4,"span",38),d(5),v(6,"limitTo"),s()()()}if(n&2){let e=t.$implicit;l(2),m("hidden",e.ImageUrl==null),l(),m("src",e.ImageUrl,Ct),l(),m("hidden",e.ImageUrl!=null),l(),I(" ",re(6,4,e.Name,20)," ")}}function Xs(n,t){if(n&1&&(a(0,"div",17)(1,"div",21),y(2,"i",40),d(3," QRIS "),s(),a(4,"div",23)(5,"div",35),ee(6,Zs,7,7,"div",41),s()()()),n&2){let e=p(3);l(6),m("ngForOf",e.getTypePaymentList(3))}}function el(n,t){if(n&1&&(a(0,"span"),y(1,"img",39),s()),n&2){let e=p().$implicit;l(),m("src",e.ImageUrl,Ct)}}function tl(n,t){if(n&1&&(a(0,"span"),d(1),v(2,"limitTo"),s()),n&2){let e=p().$implicit;l(),I(" ",re(2,1,e.Name,20)," ")}}function il(n,t){if(n&1){let e=E();a(0,"div",36)(1,"button",37),_("click",function(){let o=b(e).$implicit,r=p(4);return S(r.handlingSubmitOrderWithEcr(o))}),ee(2,el,2,1,"span",1)(3,tl,3,4,"span",1),s()()}if(n&2){let e=t.$implicit;l(2),m("ngIf",e.ImageUrl!=null),l(),m("ngIf",e.ImageUrl==null)}}function nl(n,t){if(n&1&&(a(0,"div",42)(1,"div",21),y(2,"i",43),d(3," ECR / EDC "),s(),a(4,"div",23)(5,"div",25),ee(6,il,4,2,"div",41),s()()()),n&2){let e=p(3);l(6),m("ngForOf",e.getTypePaymentList(99))}}function ol(n,t){if(n&1&&(a(0,"div",21),y(1,"i"),d(2),s()),n&2){let e=p().$implicit;l(),et(e.Icon),l(),I(" ",e.Name," ")}}function rl(n,t){if(n&1){let e=E();a(0,"div",36)(1,"a",48),_("click",function(){let o=b(e).$implicit,r=p(5);return S(r.onPaymentMethodChanged(o))}),d(2),v(3,"limitTo"),s()()}if(n&2){let e=t.$implicit,i=p(5);l(),m("ngClass",i.Payments[0].MethodID===e.ID?"active":""),l(),I(" ",re(3,2,e.Name,20)," ")}}function al(n,t){n&1&&(a(0,"small",53),d(1," Payment Note is required "),s())}function sl(n,t){n&1&&(a(0,"small",53),d(1," Payment Code is required "),s())}function ll(n,t){n&1&&(a(0,"small",53),d(1," Please input maximum 1 characters "),s())}function cl(n,t){if(n&1&&(h(0,sl,2,0,"small",53),h(1,ll,2,0,"small",53)),n&2){let e=p(6);C(e.paymentCodeCtrl.hasError("required")?0:-1),l(),C(e.paymentCodeCtrl.hasError("maxlength")?1:-1)}}function dl(n,t){if(n&1&&(a(0,"div",49)(1,"div",50)(2,"div",51),y(3,"input",52),h(4,al,2,0,"small",53),s(),a(5,"div",51),y(6,"input",54),h(7,cl,2,2),s()()()),n&2){let e=p(5);l(3),m("formControl",e.paymentNoteCtrl),l(),C(e.paymentNoteCtrl.invalid&&(e.paymentNoteCtrl.dirty||e.paymentNoteCtrl.touched)?4:-1),l(2),m("formControl",e.paymentCodeCtrl),l(),C(e.paymentCodeCtrl.dirty||e.paymentCodeCtrl.touched?7:-1)}}function ml(n,t){if(n&1&&(a(0,"div",23)(1,"div",25),ee(2,rl,4,5,"div",41),s(),ee(3,dl,8,4,"div",47),s()),n&2){let e=p().$implicit,i=p(3);l(2),m("ngForOf",i.getTypePaymentList(e.ID)),l(),m("ngIf",i.isOtherPayment(e.ID))}}function pl(n,t){if(n&1&&(a(0,"div",44),ee(1,ol,3,3,"div",45)(2,ml,4,2,"div",46),s()),n&2){let e=t.$implicit,i=p(3);m("ngClass",k(3,ks,i.getTypePaymentList(e.ID).length>0)),l(),m("ngIf",i.getTypePaymentList(e.ID).length>0),l(),m("ngIf",i.getTypePaymentList(e.ID).length>0)}}function ul(n,t){if(n&1&&(a(0,"div"),ee(1,zs,11,4,"ng-container",1),h(2,Ys,8,0,"div",17),ee(3,Xs,7,1,"div",18)(4,nl,7,1,"div",19)(5,pl,3,5,"div",20),s()),n&2){let e,i=p(2);l(),m("ngIf",(i.modalFields==null||i.modalFields.paymentSuggestion==null?null:i.modalFields.paymentSuggestion.length)>0),l(),C(((e=i.cashMachineList())==null?null:e.length)>0?2:-1),l(),m("ngIf",i.getTypePaymentList(3).length>0&&i.isOnline),l(),m("ngIf",i.getTypePaymentList(99).length>0&&i.isOnline),l(),m("ngForOf",i.paymentTypes)}}function gl(n,t){if(n&1){let e=E();a(0,"div")(1,"div",55)(2,"app-paylater",56),_("dueDateChange",function(o){b(e);let r=p(2);return S(r.dueDateChange(o))}),s()()()}if(n&2){let e=p(2);l(2),m("paylaterDueDate",e.modalFields.payLaterDueDate)("paylaterDueDays",e.modalFields.payLaterDueDays)("orderDate",e.posData==null||e.posData.Order==null?null:e.posData.Order.Date)("isCustomerAssigned",e.modalFields.isCustomerAssigned())}}function fl(n,t){if(n&1){let e=E();Ot(0),a(1,"div",25)(2,"div",58)(3,"div",59)(4,"strong",60),d(5,"Payment 1:"),s()(),a(6,"div")(7,"ng-select",61),_("change",function(o){b(e);let r=p(3);return S(r.onPaymentMethodChanged(o))}),s()()(),a(8,"div",62)(9,"div",59)(10,"strong",63),d(11,"Amount 1:"),s()(),a(12,"div")(13,"input",64),_("ngModelChange",function(o){b(e);let r=p(3);return S(r.onFirstPaymentSplitChange(o))}),s()()()(),Mt()}if(n&2){let e=p(3);l(7),m("items",e.firstPaymentSplitOptions)("ngModel",e.firstPayment==null?null:e.firstPayment.MethodID)("clearable",!1),l(6),m("ngModel",e.firstPayment.PaidAmount)}}function hl(n,t){n&1&&(a(0,"small",53),d(1," Payment Note is required "),s())}function Cl(n,t){n&1&&(a(0,"small",53),d(1," Payment Code is required "),s())}function vl(n,t){n&1&&(a(0,"small",53),d(1," Please input maximum 1 characters "),s())}function _l(n,t){if(n&1&&(h(0,Cl,2,0,"small",53),h(1,vl,2,0,"small",53)),n&2){let e=p(5);C(e.paymentCodeCtrl2.hasError("required")?0:-1),l(),C(e.paymentCodeCtrl2.hasError("maxlength")?1:-1)}}function yl(n,t){if(n&1&&(a(0,"div",71)(1,"div",50)(2,"div",51),y(3,"input",52),h(4,hl,2,0,"small",53),s(),a(5,"div",51),y(6,"input",54),h(7,_l,2,2),s()()()),n&2){let e=p(4);l(3),m("formControl",e.paymentNoteCtrl2),l(),C(e.paymentNoteCtrl2.invalid&&(e.paymentNoteCtrl2.dirty||e.paymentNoteCtrl2.touched)?4:-1),l(2),m("formControl",e.paymentCodeCtrl2),l(),C(e.paymentCodeCtrl2.dirty||e.paymentCodeCtrl2.touched?7:-1)}}function bl(n,t){if(n&1){let e=E();Ot(0),a(1,"div",65)(2,"div",66)(3,"div",67)(4,"div",59)(5,"strong",60),d(6,"Payment 2:"),s()(),a(7,"div")(8,"ng-select",68),_("change",function(o){b(e);let r=p(3);return S(r.onSplitPaymentMethodAssigned(o))}),s()()(),a(9,"div",69)(10,"strong",63),d(11,"Amount 2:"),s(),a(12,"span",70),d(13),v(14,"number"),s()()()(),h(15,yl,8,4,"div",71),Mt()}if(n&2){let e=p(3);l(8),m("items",e.splitPaymentMethodList)("ngModel",e.Payments[1]==null?null:e.Payments[1].MethodID),l(5),P(D(14,4,e.paymentSplitDefaultVal)),l(2),C((e.Payments[1]==null?null:e.Payments[1].TypeID)!==e.paymentType.ECR&&(e.Payments[1]==null?null:e.Payments[1].TypeID)!==e.paymentType.emoney&&(e.Payments[1]==null?null:e.Payments[1].TypeID)!==e.paymentType.cash&&e.Payments[1]?15:-1)}}function Sl(n,t){if(n&1&&(a(0,"div",57),ee(1,fl,14,4,"ng-container",1)(2,bl,16,6,"ng-container",1),s()),n&2){let e=p(2);l(),m("ngIf",(e.modalFields==null||e.modalFields.paymentSuggestion==null?null:e.modalFields.paymentSuggestion.length)==0),l(),m("ngIf",e.cashPaymentChange<0)}}function Pl(n,t){if(n&1&&(a(0,"div",7),ee(1,Gs,2,1,"div",8)(2,ul,6,5,"div",1)(3,gl,3,4,"div",1)(4,Sl,3,2,"div",9),s()),n&2){let e=p();l(),m("ngIf",e.modalFields.payLaterEnabled==!1),l(),m("ngIf",e.modalFields.isStateNow),l(),m("ngIf",e.modalFields.isStateLater&&!e.userRole.CreditSalesLock),l(),m("ngIf",e.modalFields.isStateSplit)}}function Ol(n,t){if(n&1&&(Ot(0),a(1,"div",83),y(2,"img",84),s(),Mt()),n&2){let e=p(2);l(),m("ngStyle",k(1,Bs,e.modalFields.merchantName?"0px":"-25px"))}}function Ml(n,t){if(n&1&&(a(0,"h2",85),d(1),s()),n&2){let e=p(2);l(),I(" ",e.modalFields.merchantName," ")}}function Dl(n,t){if(n&1&&(a(0,"div",72)(1,"div",73)(2,"span",74),d(3),s(),a(4,"div",75)(5,"div",76)(6,"span",77),d(7,"Invoice"),s(),a(8,"span"),d(9,":"),s()(),a(10,"div",78)(11,"span",79),d(12),s()()(),a(13,"div",75)(14,"div",76)(15,"span"),d(16,"Amount"),s(),a(17,"span"),d(18,":"),s()(),a(19,"div",78)(20,"span",79),d(21),v(22,"number"),s()()()(),ee(23,Ol,3,3,"ng-container",1)(24,Ml,2,1,"h2",80),a(25,"div",81),y(26,"img",82),s()()),n&2){let e=p();l(2),m("ngClass",k(11,Vs,(e.selectedPaymentMethod==null?null:e.selectedPaymentMethod.EMoneyTypeID)!=(e.modalFields==null?null:e.modalFields.emoneyType.Gopay))),l(),P(e.modalFields==null?null:e.modalFields.merchantName),l(9),P(e.posData==null||e.posData.Order==null?null:e.posData.Order.Number),l(9),yt("",e.cashierCalculatorService.currencySymbol," ",D(22,9,e.totalAmount())),l(2),m("ngIf",(e.selectedPaymentMethod==null?null:e.selectedPaymentMethod.EMoneyTypeID)==(e.modalFields==null?null:e.modalFields.emoneyType.Gopay)),l(),m("ngIf",e.modalFields.merchantName&&(e.selectedPaymentMethod==null?null:e.selectedPaymentMethod.EMoneyTypeID)==(e.modalFields==null?null:e.modalFields.emoneyType.Gopay)),l(2),m("src",e.qrImage,Ct)("ngClass",k(13,Fs,(e.selectedPaymentMethod==null?null:e.selectedPaymentMethod.EMoneyTypeID)==(e.modalFields==null?null:e.modalFields.emoneyType.Gopay)))}}function xl(n,t){n&1&&y(0,"app-confirm-demo-qris")}function Il(n,t){if(n&1&&(Ot(0),y(1,"app-modal-ecr-info",86),Mt()),n&2){let e=p();l(),m("isCancel",e.modalFields.isCancelEcrTransaction)}}function Tl(n,t){if(n&1){let e=E();a(0,"cash-machine-payment",87),_("onTransactionComplete",function(o){b(e);let r=p();return S(r.onCashMachineTransactionComplete(o))}),s()}if(n&2){let e=p();m("totalAmount",e.totalAmount())}}function wl(n,t){if(n&1){let e=E();a(0,"button",90),_("click",function(){b(e);let o=p(2);return S(o.onCancelCashMachine())}),d(1," Cancel "),s()}}function El(n,t){if(n&1){let e=E();h(0,wl,2,0,"button",88),a(1,"button",89),_("click",function(){b(e);let o=p();return S(o.onRefreshCashMachineStatus())})("keyup.F2",function(){b(e);let o=p();return S(o.onRefreshCashMachineStatus())}),d(2," Refresh "),s()}if(n&2){let e=p();C(e.modalFields.isCashMachineProvideChange()?0:-1)}}function Rl(n,t){if(n&1){let e=E();a(0,"a",90),_("click",function(){b(e);let o=p();return S(o.onPrintQR())}),y(1,"i",91),d(2,"Print QR "),s()}}function Nl(n,t){if(n&1){let e=E();a(0,"a",90),_("click",function(){b(e);let o=p();return S(o.validateEMoneyPayment())}),d(1," Verify Payment Settlement "),s()}}function Al(n,t){if(n&1){let e=E();a(0,"a",90),_("click",function(){b(e);let o=p();return S(o.onCancelWaitingEcr())}),d(1),s()}if(n&2){let e=p();l(),I(" ",e.modalFields.isCancelEcrTransaction?"Close":"Cancel"," ")}}function kl(n,t){if(n&1){let e=E();a(0,"a",90),_("click",function(){b(e);let o=p();return S(o.onBack())}),d(1," Back "),s()}}function Vl(n,t){if(n&1){let e=E();a(0,"a",90),_("click",function(){b(e);let o=p();return S(o.onContinueDemoQr())}),d(1," Continue "),s()}}var bn=class n{constructor(t,e,i,o,r,c,g,x,V,q,Oe,ci,Hn,ur,xn,In,jn,uc,gc){this.dialogRef=t;this._orderDataService=e;this.cashierCalculatorService=i;this._paymentService=o;this._posHubService=r;this._posService=c;this._toastr=g;this._paymentGatewayService=x;this.decimalPipe=V;this.sanitizer=q;this._orderProcessorService=Oe;this._numpadService=ci;this._userRoleService=Hn;this._customerHttpService=ur;this._onlineStatusService=xn;this._ecrService=In;this.outletService=jn;this.ecrSignalService=uc;this.cashMachineService=gc;this.paymentSplitDefaultVal=0,this.defaultCashPaymentMethodID=0,this.destroy$=new xe,this.AppConfigJSON=this._posService.Data.AppConfigJSON,this.modalFields.mapAppConfigJson(this.AppConfigJSON),this.initializeDefaultValues(),this.subscribeToObservableChanges(),this.initIsQRISOnlyPayment()}modalFields=new gn;userRole;posData=new $;AppConfigJSON=new mt;keyboard;paymentType=ni;Payments=[];defaultCashPaymentMethodID;inputAmountString=null;qrImage;paymentMethodList;paymentTypes;paymentSplitDefaultVal;posState;splitPaymentMethodList;isOnline=!0;get firstPayment(){return this.Payments[0]}set firstPayment(t){this.Payments[0]=t}selectedPaymentMethod;get cashPaymentChange(){let t=this.cashierCalculatorService.Data;return(this.firstPayment?this.firstPayment.PaidAmount:0)-t}firstPaymentSplitOptions;destroy$;paymentNoteCtrl;paymentCodeCtrl;paymentNoteCtrl2;paymentCodeCtrl2;totalAmount=J(()=>this.cashierCalculatorService.Data);cashMachineList=J(()=>this.getTypePaymentList(1).filter(e=>e.SubTypeID==4));isQRISOnlyPayment=T(!1);subscribeToObservableChanges(){this._orderDataService.Data$.pipe(Ie(this.destroy$)).subscribe(t=>{this.posData=t}),this._orderProcessorService.Data$.pipe(Ie(this.destroy$)).subscribe(t=>{this.posState=t.posState,this.initializeInvoicePaymentsValue(this.posState),this.initTabState()}),this._onlineStatusService.getOnlineStatus$().pipe(Ie(this.destroy$)).subscribe(t=>{this.isOnline=t})}initCashFocus(){let t=document.getElementById("cashInput");if(t){t.focus();let e=t?.value?.length;setTimeout(()=>{t.setSelectionRange(e,e)},0)}}initIsQRISOnlyPayment(){let e=this._paymentService.paymentList.every(i=>i.TypeID==3||i.TypeID==1&&i.SubTypeID==4);this.isQRISOnlyPayment.set(e),this.modalFields.modalConfigQrisOnlyPayment(e)}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(t){t!==2?(this.firstPayment=new Ye,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 Ye,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 e=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=e?.TypeID}let t=this.firstPayment.PaidAmount;this.inputAmountString=t?t.toString():null}findPaymentMethodByID(t){return this._paymentService.getPaymentList()?.find(o=>o.ID==t)}initPaymentNoteAndCode(t){let e=this.getPaymentNoteAndCodeValidators(t);this.paymentCodeCtrl?(this.paymentCodeCtrl.setValue(t?.Code),this.paymentNoteCtrl.setValue(t?.Note),this.paymentCodeCtrl.setValidators(e.paymentCodeValidators),this.paymentNoteCtrl.setValidators(e.paymentNoteValidators),this.paymentCodeCtrl.updateValueAndValidity(),this.paymentNoteCtrl.updateValueAndValidity()):(this.paymentCodeCtrl=new Ge(t?.Code,e.paymentCodeValidators),this.paymentNoteCtrl=new Ge(t?.Note,e.paymentNoteValidators))}getPaymentNoteAndCodeValidators(t){let e=this.AppConfigJSON?.ModuleSell?.PaymentDialog,i=this.userRole.PaymentCodeLock,o=[],r=[];if(t&&t?.TypeID!=1&&t?.TypeID!=99&&t?.TypeID!=3){let c=i?[Tt.maxLength(1)]:[],g=e.PaymentCodeRequired?[Tt.required]:[];o=[...c,...g],r=e.PaymentNoteRequired?[Tt.required]:[]}return{paymentCodeValidators:o,paymentNoteValidators:r}}initSplitPayment(){let t=this.cashierCalculatorService.Data,e=this.Payments[1].PaidAmount,i=t-e;this.firstPayment.PaidAmount=i,this.firstPayment.Amount=i,this.paymentSplitDefaultVal=e,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(t=>{this.userRole=t,this.initPaylaterTab()}),this.initFirstPaymentSplitOptions()}initPaylaterTab(){this.userRole.CreditSalesLock&&(this.modalFields.viewState=0)}ngOnInit(){this.modalFields.numpadVisible&&!this.isQRISOnlyPayment()&&(this.keyboard=this._numpadService.keyboard),this.initDefaultDueDays()}initDefaultDueDays(){let t=this._customerHttpService.Data,e=t?t.DueDays:null,i=t?t.DueMonths:null,o=new Date;o.setHours(0,0,0,0);let r=new Date;r.setHours(0,0,0,0),u.IsNotEmpty(this.posData.Invoice.Due)?o=new Date(this.posData.Invoice.Due):(i&&o.setMonth(o.getMonth()+i),!e&&!i&&(e=this.modalFields.config.DefaultDueDays),o.setDate(o.getDate()+e)),this.modalFields.payLaterDueDate=o,this.modalFields.payLaterDueDays=u.differentInDays(r,o),this.posData.Invoice.Due=this.modalFields.payLaterDueDate;let c=this.posData?.Order?.CustomerID;this.modalFields.isCustomerAssigned.set(u.IsNotEmpty(c))}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(t,e,i){t&&t.TypeID!=1&&t.TypeID!=99&&t.TypeID!=3&&(t.Code=i,t.Note=e)}isPaymentLater(){let t=this.modalFields.viewState==1,e=this.cashPaymentChange<0&&this.Payments.length==1;return t||e}handlingSubmitOrderWithEcr(t){if(this.ecrSignalService.isConnected()==!1){this._toastr.error("ECR is not connected","Error");return}this.onPaymentMethodChanged(t),this.posData.Invoice.Due=null;let e=this.firstPayment.PaidAmount;this.modalFields.viewState=5,this.modalFields.enableModalWaitingEcr(!0),this._ecrService.onPay(e).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(t){this.cashMachineService.isConnected()?(this.onPaymentMethodChanged(t),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(t){t.changeDue==0?this.onSubmitOrder():t.canProvideChange?this.onSubmitOrder():this.modalFields.isCashMachineProvideChange.set(!1)}onRefreshCashMachineStatus(){this.cashMachineService.checkPaymentStatus(this.totalAmount()).pipe(ne(t=>t==!0),Ie(this.destroy$)).subscribe(()=>{this.onCashMachineNotProvideChange(),this.closeDialogAfterSubmit()})}onCashMachineNotProvideChange(){this._paymentService.submitOrder(this.Payments),this.closeDialogAfterSubmit()}isCustomerLimitDebt(){if(this.paymentSplitDefaultVal>0&&this.Payments.length==1){let t=this._customerHttpService.Data;if(t.DebtLimit>0){let e=t.Debt==0&&this.paymentSplitDefaultVal>t.DebtLimit,i=t.Debt+this.paymentSplitDefaultVal>t.DebtLimit;if(e||i)return this._toastr.warning(ae.debtLimit,"Warning!"),!0}}return!1}validateSerialItem(){let t=this.findItemWithoutSerial();return t.length>0?u.IsEmpty(this.posData.Action.DeliveryEntityID)?!0:(this._toastr.warning(`Serial can not Empty in ${t[0]?.Variant?.Name}`,"Warning"),!1):!0}findItemWithoutSerial(){let t;return this.posData.CartItems.filter(i=>(t=!1,i.Variant&&i.Variant.TypeID===4&&(t=i?.Serial?i?.Serial?.length===0:!0),t))}validatePaymentLater(t){if(this.posData?.Invoice?.SurchargePcg!==0)return this._toastr.warning(ae.surcharge,"Payment Method Not Allowed"),!1;if(this.IsCreditSales()&&t.CreditSalesLock)return alert(ae.creditLock),!1;let e=u.IsEmpty(this.posData.Order.CustomerID);return this.modalFields.viewState==1&&e?(alert(ae.emptyCustomerCredit),!1):this.IsCreditSales()&&e?(alert(ae.emptyCustomerCredit),!1):!!this.debtLimitValidation()}debtLimitValidation(){let t=this._customerHttpService.Data,e=!1,i=t.DebtLimit,o=t.DebtCalculated,r=this.cashierCalculatorService.Data,c=o==0&&r>i;if(this.posData.Invoice.PaymentStateID==1){let g=i-o;r>g&&(e=!0)}else e=o+r>i;return i!==0&&(c||e)?(this._toastr.warning(ae.debtLimit,"Warning!"),!1):!0}validatePaymentSplit(){let t=this.firstPayment.PaidAmount,e=this.Payments[1]?this.Payments[1].PaidAmount:0,i=this.cashierCalculatorService.Data,o=[];t+this.modalFields.toleranceAmount>=i?(o=this.Payments.slice(0,1),this.modalFields.toleranceAmount!==0&&t<i&&(this.firstPayment.Amount=i),this.Payments=o):(e+t===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 t=this.firstPayment.Amount+(this.Payments[1]?this.Payments[1].Amount:0);if(this.AppConfigJSON.ModuleSell.PaymentDialog.MinusPaymentAllowed==!1&&t<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(ae.payNowOnly,de.Warning),!1;if(this.IsDepositPayment()&&this.userRole.CreditSalesLock)return this._toastr.warning(ae.creditLock,de.Warning),!1;if(!this.AppConfigJSON.ApplicationLoyalty.Rules.MixCashAndPoint&&this.posData.Order.PointUsed>0&&this.cashierCalculatorService.Data>0)return this._toastr.info(ae.partialLoyaltyPointUnable,de.Info),!1;let e=this.posData.Order.PointUsed*this.AppConfigJSON.ApplicationLoyalty.LoyaltyPoint.RedeemPointValue,i=this.cashierCalculatorService.GetPointOnlyAmount();if(i>0&&i>e){let c=u.StringFormat(ae.pointOnly,this.decimalPipe.transform(this.posData.PointOnlyAmount));return this._toastr.info(c,de.Info),!1}let o=this.cashierCalculatorService.Data+this.posData.Order.DiscountAmount-e,r=this.cashierCalculatorService.GetCashOnlyAmount();if(r=this.posState==7?r*-1:r,r>0&&r>o&&Math.abs(r-o)>this.modalFields.toleranceAmount){let c=u.StringFormat(ae.cashOnly,this.decimalPipe.transform(this.posData.CashOnlyAmount));return this._toastr.info(c,de.Info),!1}return this.IsDepositPayment()&&u.IsEmpty(this.posData.Order.CustomerID)?(alert(ae.emptyCustomerDeposit),!1):this.posData.PrepaidPackageItem.length>0&&u.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(t,e,i){if(t?.TypeID!=1&&t?.TypeID!=99&&t?.TypeID!=3){if(e.markAsDirty(),i.markAsDirty(),e.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(e.hasError("maxlength"))return this._toastr.warning("Payment Code must be 1 character","Warning"),!1}else return!0}onNowClick(){this.initPaymentAfterLater(),this.modalFields.viewState=0,this.isQRISOnlyPayment()&&this.modalFields.modalConfigQrisOnlyPayment(!0)}onLaterClick(){this.modalFields.viewState=1,this.isQRISOnlyPayment()&&this.modalFields.modalConfigQrisOnlyPayment(!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&&u.IsEmpty(this.firstPayment.TypeID)&&(this.firstPayment.TypeID=1)}IsDepositPayment(){let t=!1,e=this.Payments.map(c=>c.PaidAmount).reduce((c,g)=>c+g),i=this.cashierCalculatorService.Data;return this.modalFields.toleranceAmount+e<i&&(t=!0),t}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(e=>{let i=this.findPaymentMethodByID(e.MethodID);return i&&i.ExtraCharge>0})&&this.updateSurcharge(0)}updateCashPayment(t){let e=this.cashierCalculatorService.Data;this.paymentSplitDefaultVal=0,this.firstPayment.MethodID=this.defaultCashPaymentMethodID,this.firstPayment.Amount=e,this.firstPayment.PaidAmount=t,this.firstPayment.TypeID=1,this.posData.Invoice.SurchargePcg!==0&&(this.updateSurcharge(0),this.initCashFocus()),this.calculateSplitPayment(t)}calculateSplitPayment(t){let e=this.cashierCalculatorService.Data;t<e?(this.firstPayment.Amount=t,this.paymentSplitDefaultVal=e-t,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(t){this.selectedPaymentMethod=t,this.updateSurcharge(t.ExtraCharge);let e=this.cashierCalculatorService.Data;this.firstPayment.Amount=e,this.firstPayment.PaidAmount=e,this.firstPayment.MethodID=t.ID,this.firstPayment.TypeID=t.TypeID,t.ExtraCharge>0&&this.paymentSplitDefaultVal>0?this._toastr.warning("Cannot apply Split Payment for Payment Method with Surcharge","Warning"):this.paymentSplitDefaultVal>0&&(this.firstPayment.Amount=e-this.paymentSplitDefaultVal,this.firstPayment.PaidAmount=e-this.paymentSplitDefaultVal),this.initPaymentNoteAndCode(this.firstPayment),this.filterSplitPaymentList()}filterSplitPaymentList(){this.modalFields.uniquePaymentMethodOnSplit?(this.splitPaymentMethodList=this.paymentMethodList.filter(t=>t.ExtraCharge==0).filter(t=>t.ID!==this.firstPayment.MethodID),this.resetSecondPaymentMethod()):this.splitPaymentMethodList=this.paymentMethodList.filter(t=>t.ExtraCharge==0)}resetSecondPaymentMethod(){let e=this.Payments[1]?.MethodID,i=this.firstPayment.MethodID;e==i&&delete this.Payments[1]}updateSurcharge(t){this.posData.Invoice.SurchargePcg=t,this.posData.Invoice.TempSurchargePcg=t,this._orderDataService.pushNewValue(this.posData)}onSplitPaymentMethodAssigned(t){t?(this.Payments[1]=this.Payments[1]?this.Payments[1]:new Ye,this.Payments[1].MethodID=t.ID,this.Payments[1].MethodName=t.Name,this.Payments[1].Amount=this.paymentSplitDefaultVal,this.Payments[1].PaidAmount=this.paymentSplitDefaultVal,this.Payments[1].TypeID=t.TypeID):(this.Payments[1].Amount=0,this.Payments[1].PaidAmount=0),this.initPaymentNoteAndCodeSplit(this.Payments[1])}initPaymentNoteAndCodeSplit(t){let e=this.getPaymentNoteAndCodeValidators(t);this.paymentCodeCtrl2?(this.paymentCodeCtrl2.setValidators(e.paymentCodeValidators),this.paymentNoteCtrl2.setValidators(e.paymentNoteValidators),this.paymentCodeCtrl2.updateValueAndValidity(),this.paymentNoteCtrl2.updateValueAndValidity()):(this.paymentCodeCtrl2=new Ge(t?.Code,e.paymentCodeValidators),this.paymentNoteCtrl2=new Ge(t?.Note,e.paymentNoteValidators))}onFirstPaymentSplitChange(t){let e=this.cashierCalculatorService.Data;this.firstPayment.Amount=e,this.firstPayment.PaidAmount=t,this.calculateSplitPayment(t)}initFirstPaymentSplitOptions(){this.firstPaymentSplitOptions=[...this.getTypePaymentList(2),...this.getTypePaymentList(4)]}isCardPayment(){return this.getTypePaymentList(2).findIndex(e=>e.ID==this.firstPayment.MethodID)>=0}isOtherPayment(t){return this.getTypePaymentList(t).findIndex(e=>e.ID==this.firstPayment.MethodID)>=0}getTypePaymentList(t){return this._paymentService.getPaymentList().filter(i=>i.TypeID==t)}payWithEmoney(t){let e=this.generateQrisRequest();this._paymentGatewayService.generateQR(e,t).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 t=new un;return t.InvoiceNumber=this.posData.Order.Number,t.Amount=this.cashierCalculatorService.Data,t.RegisterID=this.posData.Order.RegisterID,t}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(t){t.status==400?this.validateEMoneyPayment():this._toastr.error(ae.failGenerateQR,de.Error)}validateEMoneyPayment(){this._paymentGatewayService.validateEMoneyPayment(this.AppConfigJSON).pipe(Ie(this.destroy$)).subscribe({next:t=>{this.dialogRef.close();let i=`IDR ${this.decimalPipe.transform(t.Final)} received. Please verify in customer mobile app!`;this._toastr.success(i," QR Settlement"),this._orderProcessorService.updatePosState(1,t)}})}changeModalForEmoney(t){this.modalFields.enableEMoneyModal(t),t||this._posHubService.BroadcastQRToCustomerDisplay("").subscribe()}dueDateChange(t){this.posData.Invoice.Due=t}sanitize(t){return this.sanitizer.bypassSecurityTrustUrl(t)}onPrintQR(){window.print()}ngOnDestroy(){this.destroy$.next(!0),this.destroy$.complete(),this._numpadService.destroy()}static \u0275fac=function(e){return new(e||n)(M(Z),M(H),M(le),M(fn),M(gt),M(X),M(L),M(Gt),M(G),M(io),M(je),M($o),M(Ne),M(Re),M(be),M(hn),M(se),M(qt),M(ft))};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,"mt-10"],[3,"dueDateChange","paylaterDueDate","paylaterDueDays","orderDate","isCustomerAssigned"],[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",3,"click","keyup.F2"],[1,"btn","btn-light-blue","text-primary","btn-lg","fw-bold","me-5","py-8",3,"click"],[1,"fa-solid","fa-print","me-2"]],template:function(e,i){e&1&&(a(0,"modal-material",0),_("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()}),ee(1,js,4,2,"header",1),a(2,"content"),ee(3,Pl,5,4,"div",2)(4,Dl,27,15,"div",3),h(5,xl,1,0,"app-confirm-demo-qris"),ee(6,Il,2,1,"ng-container",1),h(7,Tl,1,1,"cash-machine-payment",4),s(),a(8,"footer"),h(9,El,3,1),ee(10,Rl,3,0,"a",5)(11,Nl,2,0,"a",5)(12,Al,2,1,"a",5)(13,kl,2,0,"a",5)(14,Vl,2,0,"a",5),s()()),e&2&&(m("config",i.modalFields.modalConfig),l(),m("ngIf",!i.modalFields.isQrisConfirm&&!i.modalFields.isCancelEcrTransaction),l(2),m("ngIf",!i.modalFields.isStateQR&&!i.modalFields.isQrisConfirm&&!i.modalFields.isWaitingPaymentEcr&&!i.modalFields.isCashMachine),l(),m("ngIf",i.modalFields.isStateQR),l(),C(i.modalFields.isQrisConfirm?5:-1),l(),m("ngIf",i.modalFields.isWaitingPaymentEcr),l(),C(i.modalFields.isCashMachine?7:-1),l(2),C(i.modalFields.isCashMachine?9:-1),l(),m("ngIf",i.modalFields.isStateQR),l(),m("ngIf",i.modalFields.isStateQR),l(),m("ngIf",i.modalFields.isWaitingPaymentEcr),l(),m("ngIf",i.modalFields.isQrisConfirm),l(),m("ngIf",i.modalFields.isQrisConfirm))},dependencies:[Ee,Yn,Zn,Xn,ve,ge,Me,st,ie,wt,Et,qo,Cn,vn,_n,yn,G,Oi],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}.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 Fl=n=>({"bg-light":n});function Bl(n,t){if(n&1){let e=E();a(0,"button",10),_("click",function(){b(e);let o=p(2).$implicit,r=p(2);return S(r.onApplyPromotion(o))}),d(1," APPLY "),s()}if(n&2){let e=p(4);m("disabled",e.selectedPromotion)}}function Ll(n,t){if(n&1){let e=E();a(0,"button",11),_("click",function(){b(e);let o=p(2).$implicit,r=p(2);return S(r.onRemovePromotion(o))}),d(1," REMOVE "),s()}}function Hl(n,t){if(n&1&&(h(0,Bl,2,1,"button",8),h(1,Ll,2,0,"button",9)),n&2){let e=p().$implicit,i=p(2);C((i.selectedPromotion==null?null:i.selectedPromotion.ID)!=e.ID?0:-1),l(),C((i.selectedPromotion==null?null:i.selectedPromotion.ID)==e.ID?1:-1)}}function jl(n,t){n&1&&(a(0,"p",7),d(1,"Not Eligible"),s())}function Ql(n,t){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,Hl,2,2)(8,jl,2,0,"p",7),s()()),n&2){let e=t.$implicit;m("ngClass",k(4,Fl,!e.Eligible)),l(3),P(e.Name),l(2),P(e.Description),l(2),C(e.Eligible?7:8)}}function Ul(n,t){if(n&1&&(z(0,Ql,9,6,"div",3,Se),v(2,"sortBy")),n&2){let e=p();K(xt(2,0,e.promotions,"desc","Eligible"))}}function Wl(n,t){n&1&&(a(0,"div",2)(1,"p",12)(2,"span"),d(3,"There is no active promotion right now"),s()()())}var li=class n{constructor(t,e,i,o){this._dialogRef=t;this._promotionEventService=e;this._outletRegisterService=i;this._salesOrderService=o;this.destroy$=new xe}data=O(pe);modalConfig=new Y;promotions=[];destroy$;promotionType=Zt;selectedPromotion;showSkipButton=T(this.data?.showSkipButton??!1);showRefreshButton=T(this.data?.showRefreshButton??!0);ngOnInit(){this.subscribePromotionService(),this.initModalConfig()}ngOnDestroy(){this.destroy$.next(!0),this.destroy$.complete()}subscribePromotionService(){this._promotionEventService.Data$.pipe(Ie(this.destroy$)).subscribe(t=>{this.promotions=t,this.checkValidSelectedPromotion()})}checkValidSelectedPromotion(){this.selectedPromotion=this._promotionEventService.selectedPromotion,this.selectedPromotion&&this.promotions.findIndex(e=>e.ID==this.selectedPromotion.ID&&e.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=!this.showSkipButton(),this.modalConfig.hideOk=!this.showRefreshButton(),this.modalConfig.cancelText="Skip Promotion",this.modalConfig.okText='<i class="fas fa-rotate fs-6 me-1"></i>Refresh'}onApplyPromotion(t){this._promotionEventService.applyPromotion(t),t.TypeID!=4&&this.close()}onSkipPromotion(){this.close(!0)}onRemovePromotion(t){this._promotionEventService.removePromotion(),this.selectedPromotion=null}onRefreshPromotion(){let t=this._outletRegisterService.Data.RegisterID;this._promotionEventService.getPromotions(t).subscribe(e=>{this._promotionEventService.loadPromotions(e),this._salesOrderService.Data.CartItems=[],this._salesOrderService.pushNewValue()})}close(t=!1){this._dialogRef.close({skipped:t})}static \u0275fac=function(e){return new(e||n)(M(Z),M(ke),M(se),M(H))};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(e,i){e&1&&(a(0,"modal-material",0),_("onCancel",function(){return i.onSkipPromotion()})("onOk",function(){return i.onRefreshPromotion()})("onClose",function(){return i.close()}),a(1,"content")(2,"div",1),h(3,Ul,3,4)(4,Wl,4,0,"div",2),s()()()),e&2&&(m("config",i.modalConfig),l(3),C(i.promotions.length>0?3:4))},dependencies:[Ee,ie,Rt],styles:[".description[_ngcontent-%COMP%]{word-wrap:break-word}"]})};var Gl=["firstNameAutoFocus"],$l=["customerForm"],Ln=(n,t)=>({selected:n,danger:t}),ht=n=>({"is-invalid":n}),Jt=n=>({selected:n}),ql=n=>({"invalid-feedback":n});function Jl(n,t){n&1&&y(0,"i",14)}function zl(n,t){n&1&&y(0,"i",14)}function Kl(n,t){n&1&&y(0,"i",14)}function Yl(n,t){if(n&1&&y(0,"option",22),n&2){let e=t.$implicit;m("value",e.Name)}}function Zl(n,t){if(n&1&&(a(0,"div",25),d(1," Name is mandatory "),s()),n&2){p();let e=Ce(30);m("ngClass",k(1,ql,e.touched&&e.invalid))}}function Xl(n,t){n&1&&(a(0,"div",44),d(1," Mobile Phone is mandatory "),s())}function ec(n,t){if(n&1&&(a(0,"div",44),d(1),s()),n&2){p(2);let e=Ce(42);l(),I(" ",e.errors==null||e.errors.minLength==null?null:e.errors.minLength.message," ")}}function tc(n,t){if(n&1&&(h(0,Xl,2,0,"div",44),h(1,ec,2,1,"div",44)),n&2){p();let e=Ce(42);C(e.getError("required")&&!e.getError("minLength")?0:-1),l(),C(e.getError("minLength")?1:-1)}}function ic(n,t){n&1&&(a(0,"div",44),d(1," Email must be a valid email address "),s())}function nc(n,t){n&1&&(a(0,"div",44),d(1,"Email is mandatory"),s())}function oc(n,t){if(n&1&&(h(0,ic,2,0,"div",44),h(1,nc,2,0,"div",44)),n&2){p();let e=Ce(49);C(e.errors!=null&&e.errors.email?0:-1),l(),C(e.errors!=null&&e.errors.required?1:-1)}}function rc(n,t){n&1&&(a(0,"div",44),d(1,"Birthdate is mandatory"),s())}function ac(n,t){if(n&1&&h(0,rc,2,0,"div",44),n&2){p();let e=Ce(56);C(e.errors!=null&&e.errors.required?0:-1)}}function sc(n,t){if(n&1&&y(0,"i",43),n&2){let e=p();m("matTooltip",e.estimatedCodeMessage)}}function lc(n,t){n&1&&(a(0,"div",44),d(1," Customer code is mandatory. "),s())}function cc(n,t){n&1&&(a(0,"div",44),d(1,"Address is mandatory."),s())}function dc(n,t){if(n&1&&(a(0,"div",44),d(1),s()),n&2){p();let e=Ce(93);l(),I(" ",e.errors==null||e.errors.minLength==null?null:e.errors.minLength.message," ")}}function mc(n,t){n&1&&(a(0,"div",66),d(1," Sign Up Outlet is mandatory. "),s())}var Sn=class n{constructor(t,e,i,o,r,c){this._dialogRef=t;this._posService=e;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 Y;customer;get options(){return this._posService.Data.CustomerOptions}get config(){return this._posService.Data.AppConfigJSON}customerData;tabState="general";guidEmpty=u.GuidEmpty;outlets=T([]);get isGeneralFormInvalid(){let t=this.customerForm?.controls?.generalForm;return this.checkDirtyForm(t)}get isDetailFormInvalid(){let t=this.customerForm?.controls?.detailForm;return this.checkDirtyForm(t)}get isIdFormInvalid(){let t=this.customerForm?.controls?.idForm;return this.checkDirtyForm(t)}checkDirtyForm(t){return t?Object.keys(t.controls).every(i=>t?.controls?.[i].touched||t?.controls?.[i].dirty)&&t.invalid:!1}isSaved=T(!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(e=>{this.fieldRequiredConfig[e]===!1&&(this.fieldRequiredConfig[e]=!0)})}initCustomer(){let t=this._posService.Data.AppConfigJSON;this.outlets.set(this._posService.Data?.Entities);let e=t.ModuleContact?.DefaultContactGroup?.ContactGroup;this.customer=new Jo,u.IsNotEmpty(this.data)&&(this.customer.FirstName=this.data.name),u.IsNotEmpty(e)&&(this.customer.Group=e),this.initCustomerCode(t?.ModuleContact?.CodeGenerator?.AutoGenerateEnabled),this.initCustomerSignUpOutlet()}initCustomerSignUpOutlet(){let t=this._registerService.Data;this.customer.CreatorEntityID=t?.EntityID}initCustomerCode(t=!1){t?this._CustomerHttpService.getCustomerSuggestionCode().pipe(oe()).subscribe(e=>{this.customer.Code=e}):this.estimatedCodeMessage=""}ngAfterViewInit(){this.setAutoFocus()}setAutoFocus(){this.firstNameRef.nativeElement.focus()}onKeyUpFirstName(){this.customer.FirstName?this.modalConfig.validated=!0:this.modalConfig.validated=!1}chooiceDetail(t){this.tabState=t}onOk(t){if(t.form.markAllAsTouched(),!t.form.invalid&&this.isSaved()==!1){this.isSaved.set(!0);let e=this._orderDataService.Data;this.customer.Name=this.getCustomerName(),this._CustomerHttpService.addCustomer(this.customer,this.options.DebtLimit).then(i=>{e.ContactName=this.customer.Name,this._orderDataService.pushNewValue(e),this.getCustomerData(i.ID),this.isSaved.set(!1)}).catch(i=>{this.isSaved.set(!1)})}}getCustomerData(t){this._orderDataService.updateCustomerID(t).then(e=>{this.customerData=e,this.close("ok")}).catch(e=>{this.customerData=new kt,this.close("ok")})}getCustomerName(){let t="";return t+=" "+(this.customer.FirstName?this.customer.FirstName:""),t+=" "+(this.customer.LastName?this.customer.LastName:""),t=t.trim(),t}close(t){t==="ok"?this._dialogRef.close(this.customerData):this._dialogRef.close(null)}isNotEmpty(t){return u.IsNotEmpty(t)||t==0}static \u0275fac=function(e){return new(e||n)(M(Z),M(X),M(H),M(Re),M(se),M(pe))};static \u0275cmp=N({type:n,selectors:[["POS-modal-customer"]],viewQuery:function(e,i){if(e&1&&Dt(Gl,5)($l,5),e&2){let o;vt(o=_t())&&(i.firstNameRef=o.first),vt(o=_t())&&(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(e,i){if(e&1){let o=E();a(0,"modal-material",9),_("onOk",function(){b(o);let c=Ce(4);return S(i.onOk(c))})("onCancel",function(){return i.close("cancel")})("onClose",function(){return i.close("close")}),a(1,"content")(2,"div",10)(3,"form",11,0)(5,"div",12)(6,"div")(7,"a",13),_("click",function(){return i.chooiceDetail("general")}),d(8," General "),h(9,Jl,1,0,"i",14),s(),a(10,"a",13),_("click",function(){return i.chooiceDetail("detail")}),d(11," Detail "),h(12,zl,1,0,"i",14),s(),a(13,"a",13),_("click",function(){return i.chooiceDetail("id")}),d(14," ID "),h(15,Kl,1,0,"i",14),s()()(),a(16,"div",15)(17,"div",16)(18,"div",17)(19,"div",18)(20,"input",19),Q("ngModelChange",function(c){return b(o),B(i.customer.Title,c)||(i.customer.Title=c),S(c)}),s(),a(21,"label",20),d(22,"Title"),s(),a(23,"datalist",21),z(24,Yl,1,1,"option",22,Se),s()()(),a(26,"div",23)(27,"div",18)(28,"input",24,1),_("keyup",function(){return i.onKeyUpFirstName()}),Q("ngModelChange",function(c){return b(o),B(i.customer.FirstName,c)||(i.customer.FirstName=c),S(c)}),s(),h(31,Zl,2,3,"div",25),a(32,"label",26),d(33,"First Name"),s()()(),a(34,"div",23)(35,"div",18)(36,"input",27),Q("ngModelChange",function(c){return b(o),B(i.customer.LastName,c)||(i.customer.LastName=c),S(c)}),s(),a(37,"label",28),d(38,"Last Name"),s()()(),a(39,"div",29)(40,"div",18)(41,"input",30,2),Q("ngModelChange",function(c){return b(o),B(i.customer.Mobile,c)||(i.customer.Mobile=c),S(c)}),s(),h(43,tc,2,2),a(44,"label",31),d(45,"Mobile"),s()()(),a(46,"div",29)(47,"div",18)(48,"input",32,3),Q("ngModelChange",function(c){return b(o),B(i.customer.Email,c)||(i.customer.Email=c),S(c)}),s(),a(50,"label",33),d(51,"Email"),s(),h(52,oc,2,2),s()(),a(53,"div",29)(54,"div",18)(55,"datepicker",34,4),Q("ngModelChange",function(c){return b(o),B(i.customer.Birthdate,c)||(i.customer.Birthdate=c),S(c)}),s(),h(57,ac,1,1),s()(),a(58,"div",35)(59,"div",36)(60,"ng-select",37),Q("ngModelChange",function(c){return b(o),B(i.customer.Gender,c)||(i.customer.Gender=c),S(c)}),s(),a(61,"label",38),d(62,"Gender"),s()()()(),a(63,"div",39)(64,"div",40)(65,"div",41)(66,"input",42,5),Q("ngModelChange",function(c){return b(o),B(i.customer.Code,c)||(i.customer.Code=c),S(c)}),s(),h(68,sc,1,1,"i",43),h(69,lc,2,0,"div",44),a(70,"label",45),d(71,"Customer Code"),s()()(),a(72,"div",46)(73,"div",36)(74,"ng-select",47),Q("ngModelChange",function(c){return b(o),B(i.customer.Group,c)||(i.customer.Group=c),S(c)}),s(),a(75,"label",48),d(76,"Group"),s()()(),a(77,"div",40)(78,"div",36)(79,"ng-select",49),Q("ngModelChange",function(c){return b(o),B(i.customer.City,c)||(i.customer.City=c),S(c)}),s(),a(80,"label",50),d(81,"City"),s()()(),a(82,"div",51)(83,"div",18)(84,"textarea",52,6),Q("ngModelChange",function(c){return b(o),B(i.customer.Address,c)||(i.customer.Address=c),S(c)}),s(),a(86,"label",53),d(87,"Address"),s(),h(88,cc,2,0,"div",44),s()()(),a(89,"div",54)(90,"div",55)(91,"div",18)(92,"input",56,7),Q("ngModelChange",function(c){return b(o),B(i.customer.NationalIDNumber,c)||(i.customer.NationalIDNumber=c),S(c)}),s(),h(94,dc,2,1,"div",44),a(95,"label",57),d(96,"National ID"),s()()(),a(97,"div",55)(98,"div",18)(99,"input",58),Q("ngModelChange",function(c){return b(o),B(i.customer.TaxIDNumber,c)||(i.customer.TaxIDNumber=c),S(c)}),s(),a(100,"label",59),d(101,"Tax ID"),s()()(),a(102,"div",35)(103,"div",36)(104,"ng-select",60),Q("ngModelChange",function(c){return b(o),B(i.customer.NationalityID,c)||(i.customer.NationalityID=c),S(c)}),s(),a(105,"label",61),d(106,"Nationality"),s()()(),a(107,"div",29)(108,"div",36)(109,"ng-select",62),Q("ngModelChange",function(c){return b(o),B(i.customer.RaceID,c)||(i.customer.RaceID=c),S(c)}),s(),a(110,"label",63),d(111,"Customer Racesas"),s()()(),a(112,"div",35)(113,"div",36)(114,"ng-select",64,8),Q("ngModelChange",function(c){return b(o),B(i.customer.CreatorEntityID,c)||(i.customer.CreatorEntityID=c),S(c)}),s(),a(116,"label",65),d(117,"Sign Up Outlet"),s(),h(118,mc,2,0,"div",66),s()()()()()()()()}if(e&2){let o=Ce(30),r=Ce(42),c=Ce(49),g=Ce(56),x=Ce(67),V=Ce(85),q=Ce(93),Oe=Ce(115);m("config",i.modalConfig),l(7),m("ngClass",We(63,Ln,i.tabState=="general",i.tabState!="general"&&i.isGeneralFormInvalid)),l(2),C(i.tabState!="general"&&i.isGeneralFormInvalid?9:-1),l(),m("ngClass",We(66,Ln,i.tabState=="detail",i.tabState!="detail"&&i.isDetailFormInvalid)),l(2),C(i.tabState!="detail"&&i.isDetailFormInvalid?12:-1),l(),m("ngClass",We(69,Ln,i.tabState=="id",i.tabState!="id"&&i.isIdFormInvalid)),l(2),C(i.tabState!="id"&&i.isIdFormInvalid?15:-1),l(2),m("hidden",i.tabState!="general"),l(3),j("ngModel",i.customer.Title),l(4),K(i.options==null?null:i.options.Titles),l(4),m("ngClass",k(72,ht,o.touched&&o.invalid)),j("ngModel",i.customer.FirstName),m("required",!0),l(3),C(o.touched&&o.invalid?31:-1),l(5),j("ngModel",i.customer.LastName),l(5),m("ngClass",k(74,ht,r.invalid&&(r.dirty||r.touched))),j("ngModel",i.customer.Mobile),m("required",i.fieldRequiredConfig.Mobile),l(2),C(r.invalid&&(r.dirty||r.touched)?43:-1),l(5),m("ngClass",k(76,ht,c.invalid&&(c.dirty||c.touched))),j("ngModel",i.customer.Email),m("required",i.fieldRequiredConfig.Email),l(4),C(c.invalid&&(c.dirty||c.touched)?52:-1),l(3),j("ngModel",i.customer.Birthdate),m("required",i.fieldRequiredConfig.Birthdate)("ngClass",k(78,ht,g.invalid&&(g.dirty||g.touched))),l(2),C(g.invalid&&(g.dirty||g.touched)?57:-1),l(2),m("ngClass",k(80,Jt,i.isNotEmpty(i.customer.Gender))),l(),j("ngModel",i.customer.Gender),m("items",i.options==null?null:i.options.Genders),l(3),m("hidden",i.tabState!="detail"),l(3),m("ngClass",k(82,ht,x.invalid&&(x.dirty||x.touched))),j("ngModel",i.customer.Code),m("required",i.fieldRequiredConfig.Code),l(2),C(i.estimatedCodeMessage?68:-1),l(),C(x.invalid&&(x.dirty||x.touched)?69:-1),l(4),m("ngClass",k(84,Jt,i.isNotEmpty(i.customer.Group))),l(),j("ngModel",i.customer.Group),m("items",i.options==null?null:i.options.Groups),l(4),m("ngClass",k(86,Jt,i.isNotEmpty(i.customer.City))),l(),j("ngModel",i.customer.City),m("items",i.options==null?null:i.options.Cities),l(5),m("rows",6)("ngClass",k(88,ht,V.invalid&&(V.dirty||V.touched))),j("ngModel",i.customer.Address),m("required",i.fieldRequiredConfig.Address),l(4),C(V.invalid&&(V.dirty||V.touched)?88:-1),l(),m("hidden",i.tabState!="id"),l(3),j("ngModel",i.customer.NationalIDNumber),m("ngClass",k(90,ht,q.invalid&&(q.dirty||q.touched))),l(2),C(q.getError("minLength")?94:-1),l(5),j("ngModel",i.customer.TaxIDNumber),l(4),m("ngClass",k(92,Jt,i.isNotEmpty(i.customer.NationalityID))),l(),j("ngModel",i.customer.NationalityID),m("items",i.options==null?null:i.options.Nationalities),l(4),m("ngClass",k(94,Jt,i.isNotEmpty(i.customer.RaceID))),l(),j("ngModel",i.customer.RaceID),m("items",i.options==null?null:i.options.Races),l(4),m("ngClass",k(96,Jt,i.isNotEmpty(i.customer.CreatorEntityID))),l(),j("ngModel",i.customer.CreatorEntityID),m("items",i.outlets())("required",i.fieldRequiredConfig.SignUpOutlet)("ngClass",k(98,ht,Oe.invalid&&(Oe.dirty||Oe.touched))),l(4),C(Oe.invalid&&(Oe.dirty||Oe.touched)?118:-1)}},dependencies:[Ee,po,go,fo,ve,ge,lo,ho,Co,Me,mo,co,ie,wt,Si,Di,zo],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 Pn=class n{constructor(t,e,i){this.data=t;this.dialogRef=e;this.salesOrderService=i;this.initModalConfig();let o=u.cloneObject(i.Data);this.orderNumber=o.Order.Number}config;orderNumber;initModalConfig(){this.config=new Y,this.config.hideClose=!0,this.config.title="Edit Number"}onOk(){this.updateSalesOrderNumber(),this.dialogRef.close()}updateSalesOrderNumber(){let t=this.salesOrderService.Data;t.Order.Number=this.orderNumber,this.salesOrderService.pushNewValue(t)}onClose(){this.dialogRef.close()}static \u0275fac=function(e){return new(e||n)(M(pe),M(Z),M(H))};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(e,i){e&1&&(a(0,"modal-material",0),_("onOk",function(){return i.onOk()})("onCancel",function(){return i.onClose()})("onClose",function(){return i.onClose()}),a(1,"content")(2,"div",1)(3,"input",2),Q("ngModelChange",function(r){return B(i.orderNumber,r)||(i.orderNumber=r),r}),s(),a(4,"label",3),d(5,"Order Number"),s()()()()),e&2&&(m("config",i.config),l(3),j("ngModel",i.orderNumber))},dependencies:[ve,ge,Me,ie],encapsulation:2})};var On=class n{constructor(t,e){this.data=t;this.dialogRef=e;this.modalConfig=new Y,this.modalConfig.title=t.title,this.modalConfig.headerType=t.headerType,this.modalConfig.hideFooter=!0}modalConfig;onClose(t){this.dialogRef.close(t)}static \u0275fac=function(e){return new(e||n)(M(pe),M(Z))};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(e,i){e&1&&(a(0,"modal-material",0),_("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. "),y(6,"br"),d(7," Do you want to input customer data? "),s(),a(8,"div",3)(9,"button",4),_("click",function(){return i.onClose("yes")}),d(10,"Yes"),s(),a(11,"button",5),_("click",function(){return i.onClose("no")}),d(12,"No"),s()()()()()()),e&2&&m("config",i.modalConfig)},dependencies:[me,ie],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}"]})};function pc(n,t){if(n&1&&(a(0,"tr")(1,"td"),d(2),s(),a(3,"td",7),d(4),v(5,"number"),s(),a(6,"td",7),d(7),v(8,"number"),s()()),n&2){let e=t.$implicit;l(2),P(e==null||e.Variant==null?null:e.Variant.Name),l(2),P(D(5,3,e.Price)),l(3),P(D(8,5,e.PriceMinimum))}}var Mn=class n{modalConfig=new Y;data=O(pe);items=T(this.data.items);dialogRef=O(Z);constructor(){this.modalConfig.title="Price Minimum Warning",this.modalConfig.headerType=de.Warning,this.modalConfig.customWidth="600px",this.modalConfig.bodyScrollable=!0,this.modalConfig.hideOk=!0,this.modalConfig.cancelText="Close"}onClose(){this.dialogRef.close()}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=N({type:n,selectors:[["app-modal-price-minum-warning"]],decls:17,vars:1,consts:[[3,"onOk","onCancel","onClose","config"],[1,"container-fluid"],[1,"row"],[1,"col-12"],["id","tableGrid",1,"table","table-bordered"],[1,"thead-light"],[1,"text-end",2,"width","100px"],[1,"text-end"]],template:function(e,i){e&1&&(a(0,"modal-material",0),_("onOk",function(){return i.onClose()})("onCancel",function(){return i.onClose()})("onClose",function(){return i.onClose()}),a(1,"content")(2,"div",1)(3,"div",2)(4,"div",3)(5,"table",4)(6,"thead",5)(7,"tr")(8,"th"),d(9,"Product"),s(),a(10,"th",6),d(11,"Price"),s(),a(12,"th",6),d(13,"Minimum"),s()()(),a(14,"tbody"),z(15,pc,9,7,"tr",null,Le),s()()()()()()()),e&2&&(m("config",i.modalConfig),l(15),K(i.items()))},dependencies:[me,lt,ie,G],encapsulation:2})};var Dn=class n{constructor(t,e,i,o,r,c,g,x,V,q,Oe,ci){this.salesOrderService=t;this.toastrService=e;this.pageInitialService=i;this.orderProcessorService=o;this.dialog=r;this.onlineStatusService=c;this.promotionEventService=g;this.outletService=x;this.invoiceCalculatorService=V;this.userRole=q;this.sf=Oe;this.shoppingCartService=ci;this.initSubscribeObservable()}appConfig;salesOrder;isOnline;localDataService=O(De);initSubscribeObservable(){this.salesOrderService.Data$.subscribe(t=>{this.salesOrder=t}),this.pageInitialService.Data$.subscribe(t=>{this.appConfig=t.AppConfigJSON}),this.onlineStatusService.getOnlineStatus$().subscribe(t=>{this.isOnline=t})}payOrder(){if(this.isCartNotEmpty()&&this.validateEmptyOrderNumber()&&this.validateNegativePayment()&&this.isSalesPersonValid()&&this.isCustomerRequired()&&this.validateCustomerID()&&this.validatePromotionDiscount()&&this.validateSelectedRegister()&&this.priceMinimumValidation()&&this.validateEligiblePromotionEvent())if(this.appConfig.ModuleSell.Header.CustomerNotAssignedReminder&&u.IsEmpty(this.salesOrder.Order.CustomerID)){this.dialog.open(On,{id:"ModalInfo",data:{title:"Customer Assign Reminder",headerType:de.Warning},width:"31rem"}).afterClosed().pipe(ce(t=>{t=="yes"?this.sf.searchFilterNativeEl.focus():t=="no"&&this.onOpenPaymentModal()})).subscribe();return}else this.onOpenPaymentModal()}priceMinimumValidation(){let t=!0,i=this.salesOrder.CartItems.filter(o=>!this.shoppingCartService.checkPriceMinimumRestriction(o));return i=i.map(o=>(o.PriceMinimum=this.shoppingCartService.getPriceMinimum(o),o)),t=i.length==0,t==!1&&this.dialog.open(Mn,{data:{items:i}}),t}validateEligiblePromotionEvent(){let t=this.appConfig.ModuleSell?.Promotion?.PromotionEventReminderVisible,i=this.outletService?.Data?.Promotion?.filter(x=>x.Eligible),o=this.promotionEventService.selectedPromotion,c=this.salesOrderService.Data?.getRewards()?.length>0,g=!0;if(t&&i?.length>0&&u.IsEmpty(o)&&!c){let x=this.dialog.getDialogById("promotion-event");u.IsEmpty(x)&&this.dialog.open(li,{id:"promotion-event",data:{showSkipButton:!0,showRefreshButton:!1}}).afterClosed().subscribe(V=>{V?.skipped&&this.onOpenPaymentModal()}),g=!1}return g}validateSelectedRegister(){let t=this.pageInitialService?.Data?.Registers,e=this.salesOrder?.Order?.RegisterID;return u.IsEmpty(e)?(this.toastrService.warning("No register selected","Warning!"),!1):t?.some(o=>o.ID==e)?!0:(this.toastrService.warning("No register selected","Warning!"),!1)}validateNegativePayment(){let t=!0,e=this.invoiceCalculatorService.Data;return this.appConfig.ModuleSell.PaymentDialog.MinusPaymentAllowed==!1&&e<0&&(t=!1,this.toastrService.warning("You are not allowed to process this transaction because the total amount is less than zero","Warning!")),t}validateEmptyOrderNumber(){return u.IsEmpty(this.salesOrder.Order.Number)?(this.toastrService.warning(ae.emptyOrderNumber,"Warning!"),this.openModalEditOrderNumber(),!1):!0}openModalEditOrderNumber(){this.userRole.Data.NumberEditor&&this.dialog.open(Pn,{width:"20%"})}isCartNotEmpty(){return this.salesOrderService.Data.CartItems.length<1?(this.toastrService.warning(ae.emptyPOItem,"Warning!"),!1):!0}isSalesPersonValid(){let t=this.pageInitialService.Data.AppConfigJSON,e=this.salesOrderService.Data;if(t.ModuleSell.Header.SalesPersonRequired){if(this.salesOrder.CartItems.every(i=>u.IsNotEmpty(i.SalesID)))return!0;if(e.Order.SalesID==u.GuidEmpty||e.Order.SalesID==null)return this.toastrService.warning(ae.emptySalesPerson,"Warning!"),!1}return!0}validateCustomerID(){let t=this.salesOrderService.Data.Order.CustomerID;if(u.IsEmpty(t)){let e=this.orderProcessorService.Data.InputTextValue;if(u.IsNotEmpty(e)){this.toastrService.warning("Customer is not Saved","Warning");let i=this.userRole?.Data?.ContactsCreate;if(this.appConfig?.ModuleSell?.Customer?.QuickAddEnabled&&i)return this.openCustomerModal(e),!1}}return!0}isCustomerRequired(){let t=this.appConfig.ModuleSell.Header.CustomerRequired,e=this.salesOrder.Order.CustomerID;return t&&this.isOnline&&u.IsEmpty(e)?(this.toastrService.warning(ae.emptyCustomer,"Warning!"),!1):!0}openCustomerModal(t){this.dialog.open(Sn,{data:{name:t},autoFocus:!1}).afterClosed().subscribe(e=>{e&&this.onOpenPaymentModal()})}validatePromotionDiscount(){let e=(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&&e&&(o?o.TypeID!=3&&(r=!1):r=!1),r==!1&&(this.dialog.open(li,{id:"promotion-event"}),this.toastrService.warning("You need to apply Discount promotion","Required Promotion")),r}onOpenPaymentModal(){this.localDataService.unsentOrders$.pipe(Ue(1),te(t=>t.length>0&&this.isOnline?this.offlineModal():this.paymentModal())).subscribe()}paymentModal(){return this.dialog.open(bn,{id:"ModalPayment",disableClose:!0}).afterClosed()}offlineModal(){return this.dialog.open(pn,{disableClose:!0,id:"ModalOfflineOrder",data:{activeTab:"ORDER"}}).afterClosed()}static \u0275fac=function(e){return new(e||n)(f(H),f(L),f(X),f(je),f(ye),f(be),f(ke),f(se),f(le),f(Ne),f(Yo),f(ut))};static \u0275prov=w({token:n,factory:n.\u0275fac})};var pr=class n{static \u0275fac=function(e){return new(e||n)};static \u0275mod=Ci({type:n});static \u0275inj=hi({providers:[Dn],imports:[me,Vo,wi,lt,Pi,Ro,Ho,Po,Mo,jo,Wo,on,Go,zt,Qo,Mi,zt]})};export{$ as a,Hi as b,ki as c,Vt as d,H as e,X as f,Ft as g,Vi as h,Fi as i,Bi as j,se as k,ji as l,mt as m,le as n,Qt as o,Ut as p,Gi as q,ut as r,ke as s,en as t,Pe as u,tn as v,gt as w,nn as x,Gt as y,je as z,ar as A,on as B,$t as C,qt as D,an as E,ft as F,Cn as G,vn as H,li as I,Sn as J,Pn as K,pn as L,Dn as M,pr as N};
28
+ `,headerType:de.Error},width:"31rem"})}emitClearOrder(){this._clearOrder.next(!0)}static \u0275fac=function(e){return new(e||n)(f(H),f(X),f(Ft),f(se),f(Vt),f(at),f(ke),f(Ut),f(Re),f(le),f(ye),f(L),f(Gt),f(Ne))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var Gi=class n{httpService=O(_e);salesOrderService=O(H);orderProcessorService=O(je);promotionCouponFactoryService=O(Qt);toastr=O(L);decimalPipe=O(G);couponCode;couponNote;_couponProvider;get couponProvider(){return this._couponProvider}_coupon;get coupon(){return this._coupon}countToastrNotification=0;constructor(){this.orderProcessorService.Data$.pipe(oe()).subscribe(t=>{t.posState==1&&(this._coupon=null,this._couponProvider=null)})}redeemCoupon(t,e,i){let o=this.promotionCouponFactoryService.generateRedeemCouponDto(t,e);this.httpService.post(U.validateExternalCoupon,o).subscribe({next:r=>{this.couponCode=t,this.couponNote=i,this._coupon=r,this._couponProvider=e,this.applyCoupon(r)},error:r=>{this.removeCoupon()}})}applyCoupon(t){let e=t.ApplyToProduct,i=t.Amount;e?.length>0&&i>0?(this.applyCouponToCartItems(t),this.applyCouponToOrder(t)):e?.length>0?this.applyCouponToCartItems(t):this.applyCouponToOrder(t)}applyCouponToOrder(t){let e=this.salesOrderService.Data;t.Type=="Percentage"?e.Order.Discount=t.Amount:e.Order.DiscountAmount=t.Amount,this.showToastrAppliedCoupon(t,"Order"),this.updateSalesOrder(e)}applyCouponToCartItems(t){let e=this.salesOrderService.Data,i=t.ApplyToProduct;if(!this.validateItemsForCoupon(t))return;let o=e.CartItems.map(r=>{let c=i.findIndex(g=>g.Code===r.Variant?.Code);return c!=-1&&(t.Type==="Percentage"?(r.Discount=i[c]?.Amount,r.CouponDiscount=i[c]?.Amount):(r.DiscountAmount=i[c]?.Amount,r.CouponDiscount=i[c]?.Amount)),r});e.CartItems=o,this.showToastrAppliedCoupon(t,"Product"),this.updateSalesOrder(e)}validateItemsForCoupon(t){let e=this.salesOrderService.Data,i=t.ApplyToProduct,o=0;e.CartItems.forEach(c=>{i.findIndex(x=>x.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(e,!0),r=!1),r}showToastrAppliedCoupon(t,e){if(u.IsNotEmpty(t.Notification))this.countToastrNotification==0&&this.toastr.success(t.Notification,"Coupon Applied"),this.countToastrNotification+=1;else if(e=="Product")this.toastr.success("Coupon applied to products","Coupon Applied");else if(t.Type==="Percentage")this.toastr.success(`${t.Amount}% Discount`,"Coupon Applied");else{let i=this.decimalPipe.transform(t.Amount,"1.0-2");this.toastr.success(`${i} Discount`,"Coupon Applied")}}removeCoupon(){let t=this._coupon.ApplyToProduct,e=this._coupon.Amount;this._couponProvider=null;let i=this.salesOrderService.Data;t?.length>0&&e>0?(i=this.removeCouponFromCartItems(),i=this.removeCouponFromOrder()):t?.length>0?i=this.removeCouponFromCartItems():i=this.removeCouponFromOrder(),this.updateSalesOrder(i,!0),this._coupon=null}removeCouponFromOrder(){let t=this.salesOrderService.Data;return this._coupon.Type=="Percentage"?t.Order.Discount=0:t.Order.DiscountAmount=0,t}removeCouponFromCartItems(){let t=this.salesOrderService.Data,e=this._coupon.ApplyToProduct,i=t.CartItems.map(o=>(e.findIndex(c=>c.Code===o.Variant?.Code)!=-1&&(o.Discount=0,o.CouponDiscount=0,o.DiscountAmount=0),o));return t.CartItems=i,t}updateSalesOrder(t,e=!1){t.Order.PromotionCoupon=e?null:this.couponCode,t.Order.PromotionNote=e?null:this.couponNote,t.Order.CouponProvider=e?null:this.couponProvider,t.Order.CouponType=e?1:2,this.salesOrderService.pushNewValue(t),this.couponCode=e?null:this.couponCode,this.couponNote=e?null:this.couponNote,this._coupon=e?null:this._coupon,this._couponProvider=e?null:this._couponProvider,this.countToastrNotification=e?0:this.countToastrNotification}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};function Yr(n,t){if(n&1&&y(0,"img",6),n&2){let e=p(2);m("src",e.printTemplate.Logo,Ct)}}function Zr(n,t){if(n&1&&(a(0,"span"),d(1),s()),n&2){let e=p(3);l(),I("(",e.data.Contact.MemberIdentification,")")}}function Xr(n,t){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,Zr,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"),y(16,"span",10),s(),a(17,"div")(18,"span"),d(19),s()()()()()),n&2){let e=p(2);l(3),P(e.appConfigJson.PrintConfigInvoice.DocumentLabel.Customer),l(3),P(e.data.ContactDisplay),l(),C(e.data.Contact.MemberIdentification?7:-1),l(4),P(e.data.Contact.Email),l(3),P(e.data.Contact.Phone?e.data.Contact.Phone:e.data.Contact.Mobile),l(2),m("innerHTML",e.data.Contact.Address,ze),l(3),P(e.data.City)}}function ea(n,t){if(n&1&&(a(0,"span"),d(1),s()),n&2){let e=p(3);l(),I(", ",e.data.Shipping.Phone)}}function ta(n,t){if(n&1&&(a(0,"div",14)(1,"h3"),d(2),s(),a(3,"div",37)(4,"div"),d(5),h(6,ea,2,1,"span"),s(),y(7,"div",10),a(8,"div"),d(9),s()()()),n&2){let e=p(2);l(2),I(" ",e.appConfigJson.PrintConfigInvoice.DocumentLabel.ShippingAddress," "),l(3),I(" ",e.data.Shipping.Name),l(),C(e.data.Shipping.Phone?6:-1),l(),m("innerHTML",e.data.Shipping.Street,ze),l(2),I(" ",e.data.Shipping.City," ")}}function ia(n,t){if(n&1&&y(0,"i",39),n&2){let e=p().$implicit;m("innerHTML",e.Note,ze)}}function na(n,t){if(n&1&&(a(0,"div"),d(1),s()),n&2){let e=p().$implicit;l(),I("-",e.Discount,"%")}}function oa(n,t){if(n&1&&(a(0,"div"),d(1),s()),n&2){let e=p().$implicit;l(),I(" -",e.DiscountAmount," ")}}function ra(n,t){if(n&1&&(a(0,"tr")(1,"td",11),d(2),s(),a(3,"td"),d(4),a(5,"div"),h(6,ia,1,1,"i",39),s()(),a(7,"td"),d(8),s(),a(9,"td",11),d(10),v(11,"number"),s(),a(12,"td"),d(13),s(),a(14,"td",11),d(15),v(16,"number"),s(),a(17,"td",40),h(18,na,2,1,"div"),h(19,oa,2,1,"div"),s(),a(20,"td",11),d(21),v(22,"TrailingZero"),s()()),n&2){let e=t.$implicit,i=t.$index,o=p(2);l(2),I("",i+1,"."),l(2),I(" ",e.Name," "),l(2),C(e.Note!=null?6:-1),l(2),P(e.Code),l(2),P(D(11,10,e.Quantity)),l(3),P(e.UOMName),l(2),P(D(16,12,e.UnitPrice)),l(3),C(e.Discount!=0?18:-1),l(),C(e.DiscountAmount!=0?19:-1),l(2),I(" ",re(22,14,e.Total,o.appConfigJson.PrintConfigGeneral.TrailingZero)," ")}}function aa(n,t){if(n&1&&(a(0,"span"),d(1),v(2,"sum"),s()),n&2){let e=p().$index,i=p(2);l(),I(" ",e==0&&(i.data==null?null:i.data.Items.length)>1?"Qty: "+re(2,1,i.data.Items,"Quantity"):"")}}function sa(n,t){if(n&1&&(a(0,"tr")(1,"th",41),h(2,aa,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),v(10,"TrailingZero"),s()()),n&2){let e=t.$implicit,i=t.$index,o=p(2);l(2),C(o.appConfigJson.PrintConfigInvoice.ItemsFooter.TotalQuantityVisible?2:-1),l(),I(" ",(o.data==null?null:o.data.Payments.length)>1&&i==(o.data==null?null:o.data.AmountSummary.length)-2?"Payment":e.Label," "),l(4),P(e.CurrencySymbol),l(2),I(" ",re(10,4,e.Amount,o.appConfigJson.PrintConfigGeneral.TrailingZero)," ")}}function la(n,t){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),v(9,"TrailingZero"),s()()),n&2){let e=t.$implicit,i=p(2);l(2),P(e.Label),l(4),P(e.CurrencySymbol),l(2),I(" ",re(9,3,e.Amount,i.appConfigJson.PrintConfigGeneral.TrailingZero)," ")}}function ca(n,t){if(n&1&&(a(0,"span")(1,"span",44),d(2),v(3,"date"),s(),d(4),v(5,"number"),y(6,"br"),s()),n&2){let e=t.$implicit,i=p(3);l(),m("hidden",i.data.Payments),l(),P(re(3,5,e.Date,"dd MMM yy")),l(2),Jn(" ",e.MethodName," ",e.Note?e.Note:""," ",D(5,8,e.Amount)," ")}}function da(n,t){if(n&1&&(a(0,"tr"),y(1,"th",10),a(2,"td"),d(3,":"),s(),a(4,"td"),z(5,ca,7,10,"span",null,Se),s()()),n&2){let e=p(2);l(),m("innerHTML",e.data.Invoice.PaymentStateID==2?"Down Payment":"Payment",ze),l(4),K(e.data.Payments)}}function ma(n,t){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 e=p(2);l(8),I(" ",e.data.CustomerTransaction==null?null:e.data.CustomerTransaction.SO.DeliveryStateString," ")}}function pa(n,t){if(n&1&&(a(0,"tr")(1,"th",46),d(2,"Remaining"),s(),a(3,"td"),d(4,":"),s(),y(5,"td",47),v(6,"sum"),v(7,"number"),s()),n&2){let e=p(2);l(5),m("innerHtml",D(7,4,(e.data==null?null:e.data.FinalAmount)-re(6,1,e.data==null?null:e.data.Payments,"Amount")),ze)}}function ua(n,t){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 e=p(2);l(8),I(" ",e.data.Invoice==null?null:e.data.Invoice.Note," ")}}function ga(n,t){if(n&1&&(a(0,"div",31)(1,"h5"),d(2),s(),a(3,"div",30),d(4,"\xA0"),s()()),n&2){let e=p(2);l(2),I(" ",e.appConfigJson.PrintConfigInvoice==null?null:e.appConfigJson.PrintConfigInvoice.FooterLabel.ApprovedBy," ")}}function fa(n,t){if(n&1&&(a(0,"div",32)(1,"h5"),d(2),s(),a(3,"div",30),d(4,"\xA0"),s()()),n&2){let e=p(2);l(2),I(" ",e.appConfigJson.PrintConfigDelivery==null?null:e.appConfigJson.PrintConfigDelivery.FooterLabel.DeliveredBy," ")}}function ha(n,t){if(n&1&&y(0,"div",36),n&2){let e=p(2);m("innerHTML",e.printTemplate.FooterRight,ze)}}function Ca(n,t){if(n&1&&(a(0,"div"),y(1,"link",0),v(2,"StylesheetSafeUrl"),a(3,"div",1)(4,"div",2)(5,"div",3)(6,"div",4)(7,"div",5),h(8,Yr,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),y(16,"span",10),v(17,"newlines"),s(),a(18,"div",11),y(19,"span",10),v(20,"newlines"),s()()()(),h(21,Xr,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),v(38,"date"),s()()()()(),h(39,ta,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"),z(62,ra,23,17,"tr",null,Se),s()(),a(64,"div",25)(65,"table",26)(66,"tbody"),z(67,sa,11,7,"tr",null,Se),s(),a(69,"tbody"),z(70,la,10,6,"tr",null,Se),s()()()()(),a(72,"table",27),h(73,da,7,1,"tr"),h(74,ma,9,1,"tr"),h(75,pa,8,6,"tr"),h(76,ua,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,ga,5,1,"div",31),h(86,fa,5,1,"div",32),a(87,"div",33)(88,"h5"),d(89),s(),a(90,"div",30),d(91),s()()()()(),a(92,"div",34),y(93,"div",35),h(94,ha,1,1,"div",36),s()()()),n&2){let e=p();l(),vi("href",e.stylesheet!=null&&e.stylesheet.SizeA4?D(2,25,e.stylesheet==null?null:e.stylesheet.SizeA4):null,Wn),l(7),C(e.printTemplate.Logo?8:-1),l(3),P(e.printTemplate.Title),l(2),P(e.printTemplate.Field),l(3),m("innerHTML",D(17,27,e.printTemplate.Address),ze),l(3),m("innerHTML",D(20,29,e.printTemplate.ContactInfo),ze),l(2),C(e.data.ContactDisplay?21:-1),l(4),P(e.data.Prefixed),l(2),I(" ",e.data.Invoice==null?null:e.data.Invoice.Number," "),l(10),P(re(38,31,e.data.Invoice==null?null:e.data.Invoice.Date,"dd MMM yyyy")),l(2),C(e.data.Shipping?39:-1),l(17),I(" Price(",e.data.CurrencySymbol,") "),l(4),I(" Total(",e.data.CurrencySymbol,") "),l(2),K(e.data.Items),l(5),K(e.data==null?null:e.data.AmountSummary),l(3),K(e.data==null?null:e.data.PaidAmountSummary),l(3),C(e.appConfigJson.PrintConfigInvoice!=null&&e.appConfigJson.PrintConfigInvoice.Footer.PaymentMethodVisible&&e.data.Payments.length>0?73:-1),l(),C((e.data.CustomerTransaction==null?null:e.data.CustomerTransaction.SO)!=null&&(e.data.CustomerTransaction==null?null:e.data.CustomerTransaction.SO.DeliveryStateID)!=3&&(e.appConfigJson.PrintConfigInvoice!=null&&e.appConfigJson.PrintConfigInvoice.Footer.DeliveryInfoVisible)?74:-1),l(),C(!(e.data==null||e.data.Invoice==null)&&e.data.Invoice.PaymentStateID&&(e.data==null||e.data.Invoice==null?null:e.data.Invoice.PaymentStateID)<3?75:-1),l(),C(e.data.Invoice!=null&&e.data.Invoice.Note?76:-1),l(6),I(" ",e.appConfigJson.PrintConfigInvoice==null?null:e.appConfigJson.PrintConfigInvoice.FooterLabel.ReceivedBy," "),l(3),C((e.appConfigJson.PrintConfigDelivery==null?null:e.appConfigJson.PrintConfigDelivery.Footer.SignatureCountType)==1||(e.appConfigJson.PrintConfigDelivery==null?null:e.appConfigJson.PrintConfigDelivery.Footer.SignatureCountType)==2?85:-1),l(),C((e.appConfigJson.PrintConfigDelivery==null?null:e.appConfigJson.PrintConfigDelivery.Footer.SignatureCountType)==2?86:-1),l(3),I(" ",e.appConfigJson.PrintConfigInvoice==null?null:e.appConfigJson.PrintConfigInvoice.FooterLabel.SignedBy," "),l(2),I(" ",e.data.ItemTransfer==null?null:e.data.ItemTransfer.Courier," "),l(2),m("ngClass",!e.printTemplate.FooterRight&&"single")("innerHTML",e.printTemplate.FooterLeft,ze),l(),C(e.printTemplate.FooterRight?94:-1)}}var sr=class n{data;outletInfo;appConfigJson;printTemplate;stylesheet;constructor(){}ngOnInit(){}static \u0275fac=function(e){return new(e||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(e,i){e&1&&h(0,Ca,95,34,"div"),e&2&&C(i.data?0:-1)},dependencies:[Ee,G,Ke,xo,Io,To,Uo],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}']})},on=class n{static \u0275fac=function(e){return new(e||n)};static \u0275mod=Ci({type:n});static \u0275inj=hi({imports:[me,Mi]})};var $t=class n{_state=T(this.getEcrConfig());isEnabled=J(()=>this._state()?.enabled);ecrUrl=J(()=>this._state()?.url);getEcrConfig(){let t=localStorage.getItem("ecrConfig"),e={enabled:!1,url:null,timestamp:""};return u.IsNotEmpty(t)&&(e=JSON.parse(t)),e}url=J(()=>{let t=this._state()?.url;if(t){let e=t.split("/");e.pop(),t=e.join("/")}return t});connect(t){let i={enabled:!0,url:t,timestamp:new Date().toDateString()};localStorage.setItem("ecrConfig",JSON.stringify(i)),this._state.set(i)}disconnect(){let e={enabled:!1,timestamp:new Date().toDateString(),url:null};localStorage.setItem("ecrConfig",JSON.stringify(e)),this._state.set(e)}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var qt=class n{ecrStorage=O($t);socketConnection;_ecrEvent=new xe;ecrEvent$=this._ecrEvent.asObservable();_isSignalRConnected=T(!1);isConnected=J(()=>this.ecrStorage.isEnabled()&&this._isSignalRConnected());toastr=O(L);initEcrOnStartup(){if(this.isConnected()){let e=this.ecrStorage.ecrUrl();this.initConnection(e)}}initConnection(t){this.socketConnection=new bi().withUrl(t).withAutomaticReconnect().configureLogging(yi.Information).build(),this.ecrStorage.connect(t),this.listenToConnectionEvents(),this.listenToEvents(),this.startConnection()}startConnection(){this.socketConnection.start().then(()=>{this._isSignalRConnected.set(!0),this.toastr.success("Successfully connected to ECR","Success")}).catch(t=>{this.toastr.error(t,"Failed connecting to ECR"),console.log(t)})}listenToEvents(){this.socketConnection.on("EcrEvent",t=>{this._ecrEvent.next(t)})}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(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var rn=class n{_state=T(this.getCashMachineConfig());isEnabled=J(()=>this._state()?.enabled);ecrUrl=J(()=>this._state()?.url);getCashMachineConfig(){let t=localStorage.getItem("CashkMachineConfig"),e={enabled:!1,url:null,timestamp:""};return u.IsNotEmpty(t)&&(e=JSON.parse(t)),e}url=J(()=>this._state()?.url);connect(t){let i={enabled:!0,url:t,timestamp:new Date().toDateString()};localStorage.setItem("CashkMachineConfig",JSON.stringify(i)),this._state.set(i)}disconnect(){let e={enabled:!1,timestamp:new Date().toDateString(),url:null};localStorage.setItem("CashkMachineConfig",JSON.stringify(e)),this._state.set(e)}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var ya=n=>({"is-invalid":n}),cr=n=>({expanded:n});function ba(n,t){if(n&1&&(a(0,"tr")(1,"td",21),d(2),v(3,"number"),s(),a(4,"td",19)(5,"span",22),d(6),v(7,"number"),s()(),a(8,"td",23),d(9),v(10,"number"),s()()),n&2){let e=t.$implicit;l(2),yt(" ",e.countryCode," ",D(3,4,e.value)," "),l(4),P(D(7,6,e.stored)),l(3),I(" ",D(10,8,e.value*e.stored)," ")}}function Sa(n,t){if(n&1){let e=E();wn(0),v(1,"async"),wn(2),v(3,"async"),a(4,"div",5)(5,"div",11)(6,"div",12),d(7,"TOTAL CASH IN MACHINE"),s()(),a(8,"div",13)(9,"div",14),d(10),v(11,"number"),s(),a(12,"div",15),_("click",function(){b(e);let o=p();return S(o.expandedTable.set(!o.expandedTable()))}),y(13,"i",16),s()(),a(14,"div",17)(15,"table",18)(16,"thead")(17,"tr")(18,"th"),d(19,"Denomination"),s(),a(20,"th",19),d(21,"Quantity"),s(),a(22,"th",20),d(23,"Total"),s()()(),a(24,"tbody"),z(25,ba,11,10,"tr",null,Le),s()()()()}if(n&2){let e=p(),i=D(1,4,e.cashMachineDenominations$),o=D(3,6,e.totalCashAmount$);l(10),yt(" ",i[0]==null?null:i[0].countryCode," ",D(11,8,o)," "),l(2),m("ngClass",k(10,cr,e.expandedTable())),l(2),m("ngClass",k(12,cr,e.expandedTable())),l(11),K(i)}}function Pa(n,t){n&1&&(a(0,"div",9)(1,"span"),d(2,"Host URL is required."),s()())}function Oa(n,t){n&1&&(a(0,"span",10),d(1,"Enter the port or device URL used by your Cash Machine."),s())}var an=class n{constructor(t){this.dialogRef=t;this.config.title="Cash Machine",this.config.customWidth="450px",this.config.hideCancel=!0,this.config.okText=this.cashMachineService.isConnected()?"Disconnect":"Connect Now"}config=new Y;urlCtrl=new Ge("https://localhost:7065/CashMachineHUB",[Tt.required]);cashMachineService=O(ft);totalCashAmount$=this.cashMachineService.getCashMachineTotalAmount();cashMachineDenominations$=this.cashMachineService.getCashMachineDenominations().pipe(W(t=>t.filter(e=>e.stored>0)));expandedTable=T(!1);onClose(){this.dialogRef.close()}onConnect(){this.urlCtrl.valid&&this.dialogRef.close(this.urlCtrl.value)}get modalContentWording(){let t="Cash Machine Connected",e="Your Cash Machine is now online. You can process cash-in payments immediately.",i="Cash Machine Not Connected",o="To enable cash-in payments using the Cash Machine, please connect the device through the port or URL below.",r=this.cashMachineService.isConnected()?t:i,c=this.cashMachineService.isConnected()?e:o;return{title:r,description:c}}static \u0275fac=function(e){return new(e||n)(M(Z))};static \u0275cmp=N({type:n,selectors:[["app-modal-connect-cash-machine"]],decls:16,vars:11,consts:[[3,"onCancel","onClose","onOk","config","dynamicValidated"],[1,"d-flex","flex-column",2,"row-gap","1.5rem"],[1,"text-center","d-flex","flex-column","align-items-center",2,"row-gap","0.8rem"],[1,"fa-solid","fa-money-from-bracket","fa-3x","d-flex","align-items-center","justify-content-center","bg-light",2,"border-radius","50%","width","80px","height","80px",3,"ngClass"],[1,"fw-normal"],[1,"cash-info-card"],[1,"card","d-flex","justify-content-center","p-8","bg-light-gray",2,"border-radius","12px","margin","0"],["for","floatingInput",1,"fw-semibold","mb-2"],["id","floatingInput","placeholder","Host URL","type","text",1,"form-control",2,"border-radius","8px","padding","12px 16px",3,"ngClass","formControl"],[1,"invalid-feedback","mt-4"],[1,"text-muted","mt-4"],[1,"cash-info-header","border-bottom"],[1,"cash-info-title"],[1,"cash-amount-row"],[1,"cash-amount","updated"],["role","button",1,"expand-chevron",3,"click","ngClass"],[1,"fas","fa-chevron-down"],[1,"expand-content","mt-6",3,"ngClass"],[1,"denomination-table"],[1,"quantity-cell"],[1,"total-cell",2,"text-align","right"],[1,"denomination-value"],[1,"quantity-badge"],[1,"total-cell"]],template:function(e,i){e&1&&(a(0,"modal-material",0),_("onCancel",function(){return i.onClose()})("onClose",function(){return i.onClose()})("onOk",function(){return i.onConnect()}),a(1,"content")(2,"div",1)(3,"div",2),y(4,"i",3),a(5,"h2"),d(6),s(),a(7,"span",4),d(8),s()(),h(9,Sa,27,14,"div",5),a(10,"div",6)(11,"label",7),d(12,"Port / URL"),s(),y(13,"input",8),h(14,Pa,3,0,"div",9)(15,Oa,2,0,"span",10),s()()()()),e&2&&(m("config",i.config)("dynamicValidated",i.urlCtrl.valid),l(4),m("ngClass",i.cashMachineService.isConnected()?"text-success":"text-danger"),l(2),P(i.modalContentWording.title),l(2),P(i.modalContentWording.description),l(),C(i.cashMachineService.isConnected()?9:-1),l(4),m("ngClass",k(9,ya,i.urlCtrl.invalid&&(i.urlCtrl.touched||i.urlCtrl.dirty)))("formControl",i.urlCtrl),l(),C(i.urlCtrl.invalid&&(i.urlCtrl.touched||i.urlCtrl.dirty)?14:15))},dependencies:[me,Ee,vo,ve,ge,st,ie,He,G],styles:["[_nghost-%COMP%] modal-material .modal-body::-webkit-scrollbar{width:4px}[_nghost-%COMP%] modal-material .modal-body::-webkit-scrollbar-track{background:#89b03e14;border-radius:10px}[_nghost-%COMP%] modal-material .modal-body::-webkit-scrollbar-thumb{background:#89b03e;border-radius:10px;transition:all .3s ease}[_nghost-%COMP%] modal-material .modal-body::-webkit-scrollbar-thumb:hover{background:#89b03ecc;box-shadow:0 0 5px #89b03e80}[_nghost-%COMP%] modal-material .modal-content{scrollbar-width:thin;scrollbar-color:#89b03e rgba(137,176,62,.08)}.cash-info-card[_ngcontent-%COMP%]{background-color:#fff;border-radius:12px;padding:1.5rem;margin-bottom:1.5rem;border:1px solid #f4f4f4;box-shadow:0 4px 12px #0000000d;padding-bottom:0}.cash-info-header[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;margin-bottom:1rem;padding-bottom:.75rem}.cash-info-title[_ngcontent-%COMP%]{font-weight:600;font-size:1rem;color:#212529;letter-spacing:.3px}.cash-amount-row[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between}.cash-amount[_ngcontent-%COMP%]{font-weight:700;font-size:2.2rem;color:#212529;letter-spacing:.5px;margin:0}.expand-chevron[_ngcontent-%COMP%]{width:40px;height:40px;display:flex;align-items:center;justify-content:center;border-radius:8px;background-color:#89b03e1a;color:#89b03e;font-size:1.2rem;cursor:pointer;transition:all .3s cubic-bezier(.4,0,.2,1);border:1px solid rgba(137,176,62,.2)}.expand-chevron[_ngcontent-%COMP%]:hover{background-color:#89b03e33;transform:translateY(-2px);box-shadow:0 4px 8px #89b03e26}.expand-chevron.expanded[_ngcontent-%COMP%]{transform:rotate(180deg);background-color:#89b03e;color:#fff}.expand-content[_ngcontent-%COMP%]{max-height:0;overflow:hidden;transition:max-height .4s cubic-bezier(.4,0,.2,1);margin-bottom:1rem}.expand-content.expanded[_ngcontent-%COMP%]{max-height:700px;overflow:visible}.denomination-table[_ngcontent-%COMP%]{width:100%;border-collapse:collapse;font-size:.9rem;margin-bottom:.5rem}.denomination-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{text-align:left;padding:.75rem 1rem;background-color:#7d847114;border-bottom:1px solid rgba(0,0,0,.3);color:#000;font-weight:600}.denomination-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:.75rem 1rem;border-bottom:1px solid var(--medium-gray)}.denomination-table[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:last-child td[_ngcontent-%COMP%]{border-bottom:none}.denomination-table[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:hover{background-color:#89b03e08}.denomination-value[_ngcontent-%COMP%]{font-weight:600;color:#212529}.quantity-cell[_ngcontent-%COMP%]{text-align:center}.quantity-badge[_ngcontent-%COMP%]{display:inline-block;padding:.25rem .5rem;color:#89b03e;border-radius:4px;font-weight:600;min-width:30px}.total-cell[_ngcontent-%COMP%]{text-align:right;font-weight:600;color:#89b03e}.zero-quantity[_ngcontent-%COMP%] .quantity-badge[_ngcontent-%COMP%], .zero-quantity[_ngcontent-%COMP%] .total-cell[_ngcontent-%COMP%]{color:#000}.last-updated[_ngcontent-%COMP%]{display:flex;justify-content:center;align-items:center;gap:.5rem;font-size:.85rem;color:var(--dark-gray);padding-top:.75rem;border-top:1px solid var(--medium-gray)}.last-updated[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{color:#89b03e}"]})};var ft=class n{httpService=O(Ao);cashMachineConfig=O(rn);socketConnection;_cashMachineEvent=new xe;_withdrawMoneyStatus=new xe;cashMachineEvent$=this._cashMachineEvent.asObservable();withdrawMoneyStatus$=this._withdrawMoneyStatus.asObservable();_isSignalRConnected=T(!1);isConnected=J(()=>this.cashMachineConfig.isEnabled()&&this._isSignalRConnected()&&this.isConnectedState());toastr=O(L);dialog=O(ye);totalAmountBeforePayment=T(0);initCashMachineOnStartup(){if(this.cashMachineConfig.isEnabled()){let e=this.cashMachineConfig.url();e&&this.initConnection(e)}}url=T("");originUrl=J(()=>{let t="";return this.url()&&(t=new URL(this.url()).origin),t});checkPaymentStatus(t){return this.getCashMachineTotalAmount().pipe(W(e=>{let i=this.totalAmountBeforePayment()+t;return e>=i}),ce(e=>{e||this.toastr.error("Payment has not been settled.","Payment Failed")}))}initConnection(t){this.url.set(t),this.socketConnection=new bi().withUrl(t).withAutomaticReconnect().configureLogging(yi.Information).build(),this.listenToConnectionEvents(),this.listenToEvents(),this.startConnection(t)}startConnection(t){this.socketConnection.start().then(()=>{this._isSignalRConnected.set(!0),this.toastr.success("Successfully connected to Cash Machine","Success"),this.cashMachineConfig.connect(t)}).catch(e=>{this.cashMachineConfig.disconnect(),this.toastr.error(e,"Failed connecting to Cash Machine"),console.log(e)})}sendWithdrawMoney(t){return this.socketConnection.send("WithdrawMoney",{Value:t}).catch(e=>console.error(e))}listenToEvents(){this.socketConnection.on("OnReceiveMoney",t=>{if(t){let e=JSON.parse(t);this._cashMachineEvent.next(e)}}),this.socketConnection.on("WithdrawMoneyStatus",t=>{t&&this._withdrawMoneyStatus.next(t?.status)})}stopConnection(){this.socketConnection.stop().then(()=>{console.info("SignalR for Cash Machine is Disconnected"),this.cashMachineConfig.disconnect()})}isConnectedState(){return this.socketConnection&&u.IsNotEmpty(this.socketConnection.connectionId)&&this.socketConnection.state===so.Connected}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(t=>{console.log(t),console.info("SignalR for Cash Machine is Closed"),this.dialog.closeAll(),this.openDialogConnectCashMachine(),this._isSignalRConnected.set(!1)})}openDialogConnectCashMachine(){this.dialog.open(an).afterClosed().pipe(ne(t=>!!t)).subscribe(t=>{this.initConnection(t)})}getCashMachineTotalAmount(){return this.httpService.get(`${this.originUrl()}${U.GetCashMachineTotal}`).pipe(W(t=>t.total))}getCashMachineDenominations(){return this.httpService.get(`${this.originUrl()}${U.GetCashMachineBreakdown}`)}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var Da=(n,t,e,i)=>({"unselected-online-card":n,"selected-online-card":t,"selected-offline-card":e,"unselected-offline-card":i}),xa=(n,t)=>({"selected-color":n,"unselected-online-card-color":t}),Ia=(n,t)=>({"selected-color":n,"unselected-offline-card-color":t});function Ta(n,t){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 e=p();m("ngClass",We(1,xa,e.selected(),!e.selected()))}}function wa(n,t){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 e=p();m("ngClass",We(1,Ia,e.selected(),!e.selected()))}}var sn=class n{statusType=ot("ONLINE");selected=ot(!1);clickCard=It({alias:"onClick"});onClick(){this.clickCard.emit()}static \u0275fac=function(e){return new(e||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(e,i){e&1&&(a(0,"div",0),_("click",function(){return i.onClick()}),a(1,"div",1)(2,"div",2),y(3,"i",3),a(4,"h4",4),d(5),s(),h(6,Ta,5,4,"p",5)(7,wa,5,4,"p",5),s()()()),e&2&&(m("ngClass",zn(3,Da,i.statusType()=="ONLINE"&&!i.selected(),i.statusType()=="ONLINE"&&i.selected(),i.statusType()=="OFFLINE"&&i.selected(),i.statusType()=="OFFLINE"&&!i.selected())),l(5),I(" ",i.statusType()," "),l(),C(i.statusType()=="ONLINE"?6:7))},dependencies:[me,Ee],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 ln=class n{configOptions=[{label:"Online",value:!1},{label:"Offline",value:!0}];orderHandling=rt(!1);productHandling=rt(!1);startConfig=rt(!1);isOffline=J(()=>this.orderHandling()&&this.productHandling()&&this.startConfig());onClickCard(t){this.orderHandling.set(t),this.productHandling.set(t),this.startConfig.set(t)}static \u0275fac=function(e){return new(e||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(e,i){e&1&&(a(0,"div",0)(1,"div")(2,"div"),y(3,"i",1),a(4,"span",2),d(5,"Connection Status"),s()(),a(6,"div",3)(7,"app-card-status",4),_("onClick",function(){return i.onClickCard(!1)}),s(),a(8,"app-card-status",5),_("onClick",function(){return i.onClickCard(!0)}),s()()(),a(9,"div",6)(10,"div",7),y(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),Q("ngModelChange",function(r){return B(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),Q("ngModelChange",function(r){return B(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),Q("ngModelChange",function(r){return B(i.startConfig,r)||(i.startConfig=r),r}),s()()()()()),e&2&&(l(7),m("selected",!i.isOffline()),l(),m("selected",i.isOffline()),l(10),m("items",i.configOptions)("clearable",!1),j("ngModel",i.orderHandling),l(4),m("items",i.configOptions)("clearable",!1),j("ngModel",i.productHandling),l(4),m("items",i.configOptions)("clearable",!1),j("ngModel",i.startConfig))},dependencies:[sn,Do,wt,lt,ge,Me],encapsulation:2})};var cn=class n{localDataService=O(De);httpService=O(_e);totalSyncProduct={totalOfflineProduct:0,totalOnlineProduct:0};getTotalProducts(t=!1){return this.totalSyncProduct.totalOfflineProduct==0||t?this.localDataService.findAllVariant().pipe(ne(e=>e.length>0),te(e=>{let i=this.calculateOfflineProducts(e);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(W(o=>{let r=o?JSON.parse(o)?.Count:0;return{totalOfflineProduct:i.length,totalOnlineProduct:r}}),ce(o=>{this.totalSyncProduct=o}))})):Qe(this.totalSyncProduct)}calculateOfflineProducts(t){let e=new Set,i=[];for(let o of t)e.has(o.ProductID)==!1&&(e.add(o.ProductID),i.push(o));return i}getSyncTime(){return this.localDataService.getSyncTime().pipe(W(t=>{let e={date:null,daysDiff:0};if(t){let i=new Date(t.time),o=this.calculateSyncDiff(i);e={date:new Date(t.time),daysDiff:o}}return e}))}calculateSyncDiff(t){let e=0;return t&&(e=Math.floor((new Date().getTime()-t?.getTime())/1e3/60/60/24)),e}syncToLocalDatabase(){return Je([this.syncOutlets(),this.syncProducts(),this.syncOutletPrices()]).pipe(te(()=>this.localDataService.updateSyncTime()))}syncOutlets(){return this.httpService.get(U.SynOutlet).pipe(te(t=>this.localDataService.syncRegisters(t)))}syncProducts(){return this.httpService.get(U.SyncProducts).pipe(te(t=>this.localDataService.syncVariants(t)))}syncOutletPrices(){return this.httpService.get(U.SynOutletPrice).pipe(te(t=>this.localDataService.syncOutletPrice(t)))}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};function Ea(n,t){n&1&&(d(0),v(1,"number")),n&2&&I(" ",D(1,1,t.totalOnlineProduct)," ")}function Ra(n,t){n&1&&d(0," 0 ")}function Na(n,t){n&1&&(d(0),v(1,"number")),n&2&&I(" ",D(1,1,t.totalOfflineProduct)," ")}function Aa(n,t){n&1&&d(0," 0 ")}function ka(n,t){if(n&1&&(d(0),v(1,"number")),n&2){let e=p();I(" Last Sync: ",D(1,1,e.daysDiff)," days ago! ")}}function Va(n,t){if(n&1&&(d(0),v(1,"date")),n&2){let e=p(2);I(" Last Sync: ",re(1,1,e.date,"dd MMM yyyy HH:mm")," ")}}function Fa(n,t){n&1&&d(0," Never been sync ")}function Ba(n,t){if(n&1&&h(0,Va,2,4)(1,Fa,1,0),n&2){let e=p();C(e.date?0:1)}}function La(n,t){n&1&&h(0,ka,2,3)(1,Ba,2,1),n&2&&C(t.daysDiff>14?0:1)}var dn=class n{productSyncService=O(cn);onlineStatusService=O(be);isOnline$=this.onlineStatusService.getOnlineStatus$();toastr=O(L);productCount$=this.productSyncService.getTotalProducts().pipe(Be(1));syncTime$=this.productSyncService.getSyncTime().pipe(Be(1));onSyncProduct(){this.productSyncService.syncToLocalDatabase().subscribe({next:()=>{this.productCount$=this.productSyncService.getTotalProducts(!0).pipe(Be(1)),this.syncTime$=this.productSyncService.getSyncTime().pipe(Be(1)),this.toastr.success("Sync Product Offline Successfully","Success!")},error:t=>{this.toastr.error("Error syncing products. Please try again.","Error"),console.error("Error syncing products:",t)}})}static \u0275fac=function(e){return new(e||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(e,i){if(e&1&&(A(0,"div")(1,"div"),Xe(2,"i",0),A(3,"span",1),d(4,"Product Sync"),F()(),A(5,"div",2)(6,"div",3)(7,"div")(8,"span",4),d(9,"Online Products"),F(),A(10,"h3",5),h(11,Ea,2,3),v(12,"async"),Tn(13,Ra,1,0),F()(),A(14,"div",6)(15,"span",4),d(16,"Offline Products"),F(),A(17,"h3",5),h(18,Na,2,3),v(19,"async"),Tn(20,Aa,1,0),F(),A(21,"small"),h(22,La,2,1),v(23,"async"),F()()(),A(24,"div")(25,"button",7),v(26,"async"),$n("click",function(){return i.onSyncProduct()}),Xe(27,"i",8),A(28,"span"),d(29,"Sync Now"),F()()()()(),A(30,"div",9)(31,"div"),Xe(32,"i",10),A(33,"span",1),d(34,"Product Details"),F()(),A(35,"div",11)(36,"div",12)(37,"div"),Xe(38,"img",13),F(),A(39,"h4",14),d(40,"Coming Soon"),F()()()()),e&2){let o,r,c;l(11),C((o=D(12,4,i.productCount$))?11:13,o),l(7),C((r=D(19,6,i.productCount$))?18:20,r),l(4),C((c=D(23,8,i.syncTime$))?22:-1,c),l(3),Gn("disabled",!D(26,10,i.isOnline$))}},dependencies:[me,He,G,Ke],encapsulation:2})};var Ua=n=>({data:n,type:"unsent"}),Wa=n=>({data:n,type:"success"}),Ga=n=>({data:n,type:"fail"}),$a=(n,t)=>({"table-height":n,"table-height-default":t}),qa=n=>({ID:n});function Ja(n,t){n&1&&_i(0)}function za(n,t){if(n&1){let e=E();a(0,"div",4)(1,"button",7),v(2,"async"),_("click",function(){b(e);let o=p();return S(o.uploadUnsentOrders())}),y(3,"i",8),a(4,"span"),d(5,"Upload"),s()()()}if(n&2){let e=p();l(),m("disabled",D(2,1,e.isOnline$)==!1)}}function Ka(n,t){n&1&&_i(0)}function Ya(n,t){if(n&1){let e=E();a(0,"div",4)(1,"button",9),_("click",function(){b(e);let o=p();return S(o.clearSuccessUploadedOrders())}),y(2,"i",10),a(3,"span"),d(4,"Clear"),s()()()}}function Za(n,t){n&1&&_i(0)}function Xa(n,t){if(n&1){let e=E();a(0,"div",4)(1,"button",11),_("click",function(){b(e);let o=p();return S(o.clearFailedOrders())}),y(2,"i",10),a(3,"span"),d(4,"Clear"),s()()()}}function es(n,t){n&1&&y(0,"th")}function ts(n,t){if(n&1&&(a(0,"a",18),d(1),s()),n&2){let e=p().$implicit;m("queryParams",k(2,qa,e.Invoice==null?null:e.Invoice.ID)),l(),I(" ",e.Order.Number," ")}}function is(n,t){if(n&1&&d(0),n&2){let e=p().$implicit;I(" ",e.Order.Number," ")}}function ns(n,t){if(n&1&&(a(0,"span",21),d(1),v(2,"limitText"),s()),n&2){let e=p().$implicit;m("matTooltip",(e==null||e.Variant==null?null:e.Variant.Name.length)>=30?e==null||e.Variant==null?null:e.Variant.Name:""),l(),P(re(2,2,e==null||e.Variant==null?null:e.Variant.Name,30))}}function os(n,t){if(n&1&&(a(0,"div",19),h(1,ns,3,5,"span",21),s()),n&2){let e=t.$implicit;l(),C(e?1:-1)}}function rs(n,t){if(n&1&&(a(0,"span"),d(1),v(2,"number"),s(),a(3,"span",22),d(4,"x"),s(),a(5,"span"),d(6),v(7,"number"),s()),n&2){let e=p().$implicit;l(),P(D(2,2,e==null?null:e.Quantity)),l(5),P(D(7,4,e==null?null:e.Price))}}function as(n,t){if(n&1&&(a(0,"div",20),h(1,rs,8,6),s()),n&2){let e=t.$implicit;l(),C(e?1:-1)}}function ss(n,t){if(n&1&&(a(0,"span"),d(1),v(2,"number"),s()),n&2){let e=p().$implicit;l(),P(D(2,1,(e==null?null:e.Price)*(e==null?null:e.Quantity)))}}function ls(n,t){if(n&1&&(a(0,"div",20),h(1,ss,3,3,"span"),s()),n&2){let e=t.$implicit;l(),C(e?1:-1)}}function cs(n,t){if(n&1){let e=E();a(0,"a",26),_("click",function(){b(e);let o=p(2).$implicit,r=p(3);return S(r.uploadFailedOrder(o))}),y(1,"i",27),s()}}function ds(n,t){if(n&1){let e=E();a(0,"a",28),_("click",function(){b(e);let o=p(2).$implicit,r=p(2).type,c=p();return S(r=="fail"?c.removeFailedOrder(o):c.removeUnsentOrder(o))}),y(1,"i",29),s()}}function ms(n,t){if(n&1&&(a(0,"td")(1,"div",23),h(2,cs,2,0,"a",24),v(3,"async"),h(4,ds,2,0,"a",25),s()()),n&2){let e=p(3).type,i=p();l(2),C(e=="fail"&&D(3,2,i.isOnline$)?2:-1),l(2),C(i.role.sell.Delete&&e!="success"?4:-1)}}function ps(n,t){if(n&1&&(a(0,"tr")(1,"td"),h(2,ts,2,4,"a",18)(3,is,1,1),s(),a(4,"td")(5,"div"),d(6),v(7,"date"),s(),a(8,"div"),d(9),v(10,"date"),s()(),a(11,"td"),z(12,os,2,1,"div",19,Le),s(),a(14,"td"),z(15,as,2,1,"div",20,Le),s(),a(17,"td"),z(18,ls,2,1,"div",20,Le),s(),h(20,ms,5,4,"td"),s()),n&2){let e=t.$implicit,i=p(2).data,o=p();l(2),C(o.activeFilter()==1?2:3),l(4),I(" ",re(7,4,e==null||e.Order==null?null:e.Order.ClientTimestamp,"dd MMM yyyy")," "),l(3),I(" ",re(10,7,e==null||e.Order==null?null:e.Order.ClientTimestamp,"HH:mm")," "),l(3),K(e.CartItems),l(3),K(e.CartItems),l(3),K(e.CartItems),l(2),C((i==null?null:i.length)>0?20:-1)}}function us(n,t){if(n&1&&z(0,ps,21,10,"tr",null,Se),n&2){let e=p().data;K(e)}}function gs(n,t){n&1&&(a(0,"tr",17)(1,"td",30),y(2,"empty-state-table"),s()())}function fs(n,t){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,es,1,0,"th"),s()(),a(15,"tbody"),h(16,us,2,0)(17,gs,3,0,"tr",17),s()()()),n&2){let e=t.data;et(We(4,$a,(e==null?null:e.length)>0,(e==null?null:e.length)===0)),l(14),C((e==null?null:e.length)>0?14:-1),l(2),C((e==null?null:e.length)>0?16:17)}}var mn=class n{localDataService=O(De);onlineService=O(be);role=O(_o);toastr=O(L);isOnline$=this.onlineService.getOnlineStatus$();unsentOrders$;failedOrders$;successUploadedOrders$;activeFilter=T(0);onEmptyOfflineOrder=It();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(),Be(1))}initSuccessUploadedOrders(){this.successUploadedOrders$=this.localDataService.successUploadedOrders$.pipe(this.pipeMap(),Be(1))}initUnsentOrders(){this.unsentOrders$=Je([this.localDataService.unsentOrders$,this.onlineService.getOnlineStatus$()]).pipe(W(([t,e])=>t),this.pipeMap(),Be(1))}pipeMap(){return pi(W(t=>t.map(e=>fe($,e))))}uploadUnsentOrders(){this.localDataService.uploadOrders().pipe(te(()=>this.localDataService.totalOfflineOrders$),ce(t=>{t===0&&this.onEmptyOfflineOrder.emit()}),Ue(1)).subscribe()}removeUnsentOrder(t){confirm("Are you sure you want to delete this offline order? This action cannot be undone.")&&this.localDataService.removeOrder(t.id).pipe(te(()=>this.localDataService.totalOfflineOrders$),ce(i=>{i===0&&this.onEmptyOfflineOrder.emit()}),Ue(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(t){this.localDataService.uploadFailedOrder(t).pipe(Ue(1)).subscribe()}removeFailedOrder(t){confirm("Are you sure you want to delete this offline order? This action cannot be undone.")&&this.localDataService.removeFailedOrder(t.id).pipe(Ue(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(Ue(1)).subscribe({next:()=>{this.toastr.success("Success to clear failed offline order","Success")},error:e=>{this.toastr.error("Failed to clear failed offline order","Error!")}})}clearSuccessUploadedOrders(){this.localDataService.clearSuccessUploadedOrder().pipe(Ue(1)).subscribe({next:()=>{this.toastr.success("Success to clear success uploaded offline order","Success")},error:t=>{this.toastr.error("Failed to clear success uploaded offline order","Error!")}})}static \u0275fac=function(e){return new(e||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(e,i){if(e&1&&(a(0,"div",1)(1,"custom-tabs")(2,"tab",2),ee(3,Ja,1,0,"ng-container",3),v(4,"async"),h(5,za,6,3,"div",4),v(6,"async"),s(),a(7,"tab",5),ee(8,Ka,1,0,"ng-container",3),v(9,"async"),h(10,Ya,5,0,"div",4),v(11,"async"),s(),a(12,"tab",6),ee(13,Za,1,0,"ng-container",3),v(14,"async"),h(15,Xa,5,0,"div",4),v(16,"async"),s()()(),ee(17,fs,18,7,"ng-template",null,0,Kn)),e&2){let o,r,c,g=Ce(18);l(3),m("ngTemplateOutlet",g)("ngTemplateOutletContext",k(21,Ua,D(4,9,i.unsentOrders$))),l(2),C(((o=D(6,11,i.unsentOrders$))==null?null:o.length)>0?5:-1),l(3),m("ngTemplateOutlet",g)("ngTemplateOutletContext",k(23,Wa,D(9,13,i.successUploadedOrders$))),l(2),C(((r=D(11,15,i.successUploadedOrders$))==null?null:r.length)>0&&(i.role.sell!=null&&i.role.sell.Delete)?10:-1),l(3),m("ngTemplateOutlet",g)("ngTemplateOutletContext",k(25,Ga,D(14,17,i.failedOrders$))),l(2),C(((c=D(16,19,i.failedOrders$))==null?null:c.length)>0&&(i.role.sell!=null&&i.role.sell.Delete)?15:-1)}},dependencies:[me,eo,Ei,Ni,Ri,ko,Ko,zt,Si,ro,oo,He,G,Ke,So],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 hs(n,t){if(n&1){let e=E();a(0,"app-setup",8),Q("orderHandlingChange",function(o){b(e);let r=p();return B(r.orderUsingLocal,o)||(r.orderUsingLocal=o),S(o)})("productHandlingChange",function(o){b(e);let r=p();return B(r.productUsingLocal,o)||(r.productUsingLocal=o),S(o)})("startConfigChange",function(o){b(e);let r=p();return B(r.configUsingLocal,o)||(r.configUsingLocal=o),S(o)}),s()}if(n&2){let e=p();j("orderHandling",e.orderUsingLocal)("productHandling",e.productUsingLocal)("startConfig",e.configUsingLocal)}}var pn=class n{constructor(t){this.data=t;this.initActiveTab()}modalConfig;dialog=O(Z);onlineStatusService=O(be);localDataService=O(De);orderUsingLocal=T(!1);productUsingLocal=T(!1);configUsingLocal=T(!1);offlineConfig$=this.onlineStatusService.offlineConfig$.pipe(ce(t=>{this.orderUsingLocal.set(t.orderUsingLocal),this.productUsingLocal.set(t.productUsingLocal),this.configUsingLocal.set(t.configUsingLocal)}),Be(1));activeTab=T("SETUP");totalOfflineOrders$=this.localDataService.totalOfflineOrders$.pipe(Be(1));initActiveTab(){this.activeTab.update(t=>(this.data?.activeTab&&(t=this.data.activeTab),t)),this.initModalConfig()}initModalConfig(){this.modalConfig=new Y,this.modalConfig.title="Offline Order Configuration",this.modalConfig.customWidth="600px",this.modalConfig.hideScrollbar=!0,Je([this.localDataService.unsentOrders$.pipe(W(t=>t?.length)),this.onlineStatusService.getOnlineStatus$()]).pipe(oe()).subscribe(([t,e])=>{this.data?.activeTab=="ORDER"&&t>0&&e?(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 t=new Eo(this.configUsingLocal(),this.productUsingLocal(),this.orderUsingLocal());this.onlineStatusService.updateOfflineConfigDB(t),this.dialog.close()}onClose(){this.dialog.close()}static \u0275fac=function(e){return new(e||n)(M(pe))};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(e,i){if(e&1&&(a(0,"modal-material",0),_("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,hs,1,3,"app-setup",4),v(6,"async"),s(),a(7,"tab",5),v(8,"async"),a(9,"app-order-management",6),_("onEmptyOfflineOrder",function(){return i.onEmptyOfflineOrder()}),s()(),a(10,"tab",7),y(11,"app-product-sync"),s()()()()()),e&2){let o;m("config",i.modalConfig),l(4),m("active",i.activeTab()=="SETUP"),l(),C((o=D(6,6,i.offlineConfig$))?5:-1,o),l(2),m("active",i.activeTab()=="ORDER")("badge",D(8,8,i.totalOfflineOrders$)),l(3),m("active",i.activeTab()=="PRODUCT")}},dependencies:[me,ie,ln,Ei,Ni,Ri,dn,mn,He],styles:[".dialog-offline-content[_ngcontent-%COMP%]{min-height:360px}"]})};var un=class{RegisterID;InvoiceNumber;Amount};var gn=class{modalConfig=new Y;viewState=4;paymentSuggestion;payLaterEnabled=!1;payNowEnabled=!1;payNowNLaterEnabled=!1;toleranceAmount=0;merchantName;payLaterDueDate;payLaterDueDays;numpadVisible=!1;config;uniquePaymentMethodOnSplit;isCancelEcrTransaction=!1;emoneyType=Ti;splitPaymentEnabled=!0;isCustomerAssigned=T(!1);isCashMachineProvideChange=T(!0);constructor(){this.modalConfig.title="Amount to Pay: ",this.modalConfig.disableKeyup=!0,this.modalConfig.customWidth="650px",this.modalConfig.bodyScrollable=!0}mapAppConfigJson(t){this.merchantName=t.PaymentConfigGopay.MerchantName,this.toleranceAmount=t.ModuleSell.ToleranceAmount,this.numpadVisible=t.ModuleSell.NumPadVisible;let e=t.ModuleSell.PaymentDialog;switch(this.config=e,this.uniquePaymentMethodOnSplit=e.UniquePaymentMethodOnSplit,e.EnabledOptions){case 0:this.viewState=0,this.payNowEnabled=!0;break;case 1:this.viewState=1,this.payLaterEnabled=!0;break;case 2:switch(e.DefaultOption){case 0:this.viewState=0;break;case 1:this.viewState=1;break}this.payNowNLaterEnabled=!0;break}}modalConfigQrisOnlyPayment(t=!0){this.modalConfig.hideOk=t}enableEMoneyModal(t){this.modalConfig.backButton=t,this.modalConfig.hideCancel=t,this.modalConfig.hideClose=t,this.modalConfig.hideOk=t}enableEmoneyConfirmModal(t){this.modalConfig.backButton=t,this.modalConfig.hideCancel=t,this.modalConfig.hideClose=t,this.modalConfig.hideOk=t,t?(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(t){this.modalConfig.hideCancel=t,this.modalConfig.hideClose=t,this.modalConfig.hideOk=t,this.isCancelEcrTransaction=!1,t?this.modalConfig.customWidth="550px":(this.modalConfig.customWidth="650px",this.modalConfig.headerType=de.Success,this.modalConfig.title="Amount to Pay: ")}enableModalCashMachine(t){this.modalConfig.hideCancel=t,this.modalConfig.hideOk=t,t?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 fn=class n{constructor(t,e,i,o,r,c,g,x){this._invoiceCalculatorService=t;this._posService=e;this._orderDataService=i;this._orderProcessorService=o;this._onlineStatusService=r;this._signalBroadCast=c;this.decimalPipe=g;this._registerService=x;this.subscribeToObservableChanges(),this.initPaymenyDefault()}defaultCashPaymentMethodID=0;isOnline=!0;salesOrderData=new $;toastr=O(L);_State;get State(){return this._State}set State(t){this._State=t}get denomination(){return this._posService.Data.Denomination}get appConfigJSON(){return this._posService.Data.AppConfigJSON}get toleranceAmount(){return this.appConfigJSON.ModuleSell.ToleranceAmount}get paymentList(){return u.IsNotEmpty(this._registerService.Data)?this._registerService.Data.Payments:Array()}initPaymenyDefault(){let t=u.GuidEmpty;if(this.paymentList.length>0){let e=this.paymentList.find(i=>i.TypeID!=3);if(e)return this.defaultCashPaymentMethodID=e.ID,e.ID}else this.toastr.error("No payment methods available.","Error");return t}subscribeToObservableChanges(){this._onlineStatusService.getOnlineStatus$().subscribe(t=>{this.isOnline=t}),this._orderDataService.Data$.subscribe(t=>{this.salesOrderData=t})}getPaymentList(){return this.paymentList}submitOrder(t){this.salesOrderData.Payments=fe(Ye,t),this.salesOrderData.Payments=this.removePayment(this.salesOrderData),this._orderDataService.pushNewValue(this.salesOrderData),this._orderDataService.submitOrder(this.appConfigJSON).then(e=>{this.updateBroadcastState(e),e=this.setFinalAmountOfflineOrder(e),this._orderProcessorService.updatePosState(1,e)},e=>{(e instanceof gi||e?.name=="TimeoutError")&&(this._orderDataService.pushNewValue(this.salesOrderData),this._orderProcessorService.updatePosState(9))})}updateBroadcastState(t){let e=this.salesOrderData.TotalPaidAmount-this._invoiceCalculatorService.Data;this._signalBroadCast.BroadcastStateToCustomerDisplay(1,t.ObjectID,t.LoyaltyPoint,e).subscribe()}removePayment(t){return t.Payments.filter(i=>i.Amount!==0)}setFinalAmountOfflineOrder(t){return this.isOnline==!1&&(t.Final=this._invoiceCalculatorService.Data),t}generateCashSuggestion(){let t=this.paymentList.filter(i=>i.TypeID==1),e=[];return t.length>0&&(e.push(this._invoiceCalculatorService.Data),this.defaultCashPaymentMethodID=t[0].ID,this.denomination.forEach(i=>{let o=this._invoiceCalculatorService.Data/i;o=Math.ceil(o);let r=o*i;r!=this._invoiceCalculatorService.Data&&e.indexOf(r)===-1&&e.length<3&&e.push(r)})),e}static \u0275fac=function(e){return new(e||n)(f(le),f(X),f(H),f(je),f(be),f(gt),f(G),f(se))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var hn=class n{constructor(t,e,i,o,r){this.httpService=t;this.orderDataService=e;this.ecrLocalstorageService=i;this.ecrSignalR=o;this.toastr=r}onPay(t){let e=this.orderDataService.Data?.Order?.Number,i={Transaction_Type:"01",Transaction_Amount:t,Invoice_Number:e,Expire_Date:2406},o=this.ecrLocalstorageService.url();return Je([this.httpService.post(`${o}/api/Payment/Send`,i),this.ecrSignalR.ecrEvent$]).pipe(W(([r,c])=>c),nt(r=>{let c=r?.message?r?.message:r?.Message;return this.toastr.error(c,"Error"),St(()=>r)}))}static \u0275fac=function(e){return new(e||n)(f(to),f(H),f($t),f(qt),f(L))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};function ys(n,t){if(n&1&&(A(0,"div",0)(1,"div",2)(2,"h3",3),d(3," Insert Cash into Machine "),F(),A(4,"p",4),d(5," Feed bills into the cash acceptor slot below the screen "),F(),A(6,"div",5)(7,"span",6)(8,"span",7),d(9,"\u23F3"),F(),d(10," Waiting for cash insertion "),F()(),A(11,"div",8)(12,"div",9)(13,"span",10),d(14,"Amount Received:"),F(),A(15,"span",11)(16,"span"),d(17),F(),A(18,"span"),d(19),v(20,"number"),F()()(),A(21,"div",12)(22,"span",10),d(23,"Remaining Balance:"),F(),A(24,"span",13)(25,"span"),d(26),F(),A(27,"span"),d(28),v(29,"number"),F()()()()(),A(30,"div",14)(31,"div",15)(32,"span",16),d(33,"Payment Progress"),F(),A(34,"span",17)(35,"span"),d(36),F(),A(37,"span"),d(38),v(39,"number"),F(),d(40," / "),A(41,"span"),d(42),F(),A(43,"span"),d(44),v(45,"number"),F()()(),A(46,"div",18),Xe(47,"div",19),F()()()),n&2){let e=p();l(17),P(e.currencySymbol()),l(2),P(D(20,11,e.receivedAmount())),l(7),P(e.currencySymbol()),l(2),P(D(29,13,e.remainingBalance())),l(8),P(e.currencySymbol()),l(2),P(D(39,15,e.receivedAmount())),l(4),P(e.currencySymbol()),l(2),P(D(45,17,e.totalAmount())),l(2),vi("aria-valuenow",e.progress()),l(),qn("width",e.progress(),"%")}}function bs(n,t){if(n&1&&(A(0,"div",23),d(1," Change: "),A(2,"span"),d(3),F(),A(4,"span"),d(5),v(6,"number"),F()()),n&2){let e=p(2);l(3),P(e.currencySymbol()),l(2),P(D(6,2,e.changeDue()))}}function Ss(n,t){n&1&&(A(0,"div",24),Xe(1,"i",25),A(2,"div",26),d(3,"Manual Change Required"),F(),A(4,"p",27)(5,"span",28),d(6,"Machine cannot dispense exact change."),F(),A(7,"span"),d(8,"Please collect change from the cashier."),F()()())}function Ps(n,t){n&1&&(A(0,"div",24),Xe(1,"i",25),A(2,"div",26),d(3,"Change Dispensed"),F(),A(4,"p",27)(5,"span",28),d(6,"The machine has provided your change."),F(),A(7,"span"),d(8,"Please ensure you have collected your change from the dispenser before closing this window."),F()()())}function Os(n,t){if(n&1&&h(0,Ps,9,0,"div",24),n&2){let e=p(2);C(e.changeDue()>0?0:-1)}}function Ms(n,t){if(n&1&&(A(0,"div",1)(1,"div",20)(2,"span",21),d(3,"\u2713"),F()(),A(4,"div",22),d(5," Payment Accepted! "),F(),h(6,bs,7,4,"div",23),h(7,Ss,9,0,"div",24)(8,Os,1,1),F()),n&2){let e=p();l(6),C(e.changeDue()>0?6:-1),l(),C(e.canProvideChange()==!1?7:e.canProvideChange()==!0?8:-1)}}var Cn=class n{cashMachineService=O(ft);calculatorService=O(le);currencySymbol=T(this.calculatorService.currencySymbol);totalAmount=ot(0);transactionComplete=It({alias:"onTransactionComplete"});receivedAmount=T(0);paymentState=T("paying");changeDue=T(0);canProvideChange=T(!0);remainingBalance=J(()=>Math.max(0,this.totalAmount()-this.receivedAmount()));progress=J(()=>{let t=this.totalAmount();return t===0?0:Math.min(100,this.receivedAmount()/t*100)});constructor(){this.initTotalCashMachineAmount(),this.initListenCashMachine(),this.initWithdrawStatus()}initTotalCashMachineAmount(){this.cashMachineService.getCashMachineTotalAmount().pipe(oe()).subscribe(t=>{this.cashMachineService.totalAmountBeforePayment.set(t)})}initWithdrawStatus(){this.cashMachineService.withdrawMoneyStatus$.pipe(oe()).subscribe(t=>{this.canProvideChange.set(t),this.changeDue()>0&&this.completeTransaction()})}initListenCashMachine(){this.cashMachineService.cashMachineEvent$.pipe(ne(t=>t&&t.length>0),W(t=>t.reduce((e,i)=>e+i.value,0)),te(t=>this.cashMachineService.getCashMachineTotalAmount().pipe(W(e=>({cashMachineTotal:e,insertedAmount:t})))),oe()).subscribe(({cashMachineTotal:t,insertedAmount:e})=>{this.validatePayment(t,e)})}validatePayment(t,e){this.receivedAmount.update(c=>c+e);let i=this.totalAmount(),o=this.cashMachineService.totalAmountBeforePayment(),r=t-i;o<=r&&setTimeout(()=>this.showSuccessState(),500)}showSuccessState(){let t=this.receivedAmount()-this.totalAmount();this.changeDue.set(t),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(e){return new(e||n)};static \u0275cmp=N({type:n,selectors:[["cash-machine-payment"]],inputs:{totalAmount:[1,"totalAmount"]},outputs:{transactionComplete:"onTransactionComplete"},decls:2,vars:1,consts:[[1,"mb-3"],[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(e,i){e&1&&h(0,ys,48,19,"div",0)(1,Ms,9,2,"div",1),e&2&&C(i.paymentState()==="paying"?0:1)},dependencies:[me,G],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}"]})};var mr=n=>({selected:n}),pr=n=>({checked:n});function xs(n,t){if(n&1){let e=E();a(0,"div",1),_("click",function(){b(e);let o=p();return S(o.isSelectDueDate.set(!0))}),a(1,"div",2),y(2,"div",3),a(3,"div",4)(4,"label",5),d(5,"Due Date"),s(),a(6,"datepicker",6),Q("dateChange",function(o){b(e);let r=p();return B(r.paylaterDueDate,o)||(r.paylaterDueDate=o),S(o)}),_("dateChange",function(){b(e);let o=p();return S(o.dueDateChange())}),s(),a(7,"p",7),d(8," Select a specific date for payment due "),s()()()(),a(9,"div",8),_("click",function(){b(e);let o=p();return S(o.isSelectDueDate.set(!1))}),a(10,"div",2),y(11,"div",3),a(12,"div",4)(13,"label",5),d(14,"Due Days"),s(),a(15,"div",9)(16,"input",10),Q("ngModelChange",function(o){b(e);let r=p();return B(r.paylaterDueDays,o)||(r.paylaterDueDays=o),S(o)}),_("ngModelChange",function(){b(e);let o=p();return S(o.dueDayChange())}),s()(),a(17,"p",7),d(18," Enter number of days until payment is due "),s()()()()}if(n&2){let e=p();et(k(13,mr,e.isSelectDueDate())),l(2),et(k(15,pr,e.isSelectDueDate())),l(4),m("displayToggle",!1),j("date",e.paylaterDueDate),m("disabled",!e.isSelectDueDate()),l(3),et(k(17,mr,!e.isSelectDueDate())),l(2),et(k(19,pr,!e.isSelectDueDate())),l(5),j("ngModel",e.paylaterDueDays),m("disabled",e.isSelectDueDate())}}function Is(n,t){n&1&&(a(0,"div",0)(1,"div",11)(2,"div",12),y(3,"i",13),s(),a(4,"h3",14),d(5," Customer Required "),s(),a(6,"p",15),d(7," Customer is required for credit transactions. "),s(),a(8,"p",16),d(9," Please assign a customer to enable 'Later' payment. "),s()()())}var vn=class n{isCustomerAssigned=ot(!1);orderDate=ot(new Date);dueDate=rt(null);paylaterDueDate=rt(null);paylaterDueDays=rt(0);isSelectDueDate=T(!0);dueDateChange(){let t=new Date(this.orderDate()),e=this.paylaterDueDate()?this.paylaterDueDate():new Date;t.setHours(0,0,0,0),this.paylaterDueDays.set(u.differentInDays(t,e)),this.dueDate.set(e)}dueDayChange(){let t=new Date(this.orderDate());t.setDate(t.getDate()+this.paylaterDueDays()),t.setHours(0,0,0,0),this.paylaterDueDate.set(t),this.dueDate.set(t)}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=N({type:n,selectors:[["app-paylater"]],inputs:{isCustomerAssigned:[1,"isCustomerAssigned"],orderDate:[1,"orderDate"],dueDate:[1,"dueDate"],paylaterDueDate:[1,"paylaterDueDate"],paylaterDueDays:[1,"paylaterDueDays"]},outputs:{dueDate:"dueDateChange",paylaterDueDate:"paylaterDueDateChange",paylaterDueDays:"paylaterDueDaysChange"},decls:2,vars:1,consts:[["id","no-customer-info"],["id","option-date-card",1,"option-card","mb-8","selected",3,"click"],[1,"d-flex","align-items-start","gap-4",2,"gap","1.5rem"],["id","radio-date",1,"custom-radio","checked"],[1,"flex-grow-1"],[1,"fw-semibold","text-dark","cursor-pointer","d-block","mb-5","fs-4",2,"cursor","pointer"],["name","orderDate",1,"sell-paylater",3,"dateChange","displayToggle","date","disabled"],[1,"small","text-muted","mt-2",2,"font-size","0.75rem","color","#64748b"],["id","option-date-card",1,"option-card","mb-4","selected",3,"click"],[1,"relative"],["type","number","id","due-days-input","placeholder","Enter days","type","number",1,"form-input","pe-16",3,"ngModelChange","ngModel","disabled"],[1,"paylater-warning-box"],[1,"paylater-warning-icon-bg"],[1,"fas","fa-exclamation-triangle","paylater-warning-icon"],["id","customer-required-title",1,"paylater-warning-title"],["id","customer-required-msg",1,"paylater-warning-msg"],[1,"paylater-warning-desc"]],template:function(e,i){e&1&&h(0,xs,19,21)(1,Is,10,0,"div",0),e&2&&C(i.isCustomerAssigned()?0:1)},dependencies:[lt,ve,uo,ge,Me,Pi,Oo,wi,Di],styles:['.form-input[_ngcontent-%COMP%]{width:100%;padding:14px 16px;border:1px solid #e2e8f0;border-radius:5px;font-size:15px;transition:all .3s ease;background:#fff}.form-input[_ngcontent-%COMP%]:focus{outline:none;border-color:#89b03e;box-shadow:0 0 0 4px #89b03e26}.form-input[_ngcontent-%COMP%]:disabled{background:#f8fafc;color:#94a3b8;cursor:not-allowed}.form-input.readonly[_ngcontent-%COMP%]{background:linear-gradient(135deg,#f0fdf4,#ecfccb);border-color:#89b03e;color:#365314;font-weight:500}.option-card[_ngcontent-%COMP%]{padding:20px;border:2px solid #e2e8f0;border-radius:16px;cursor:pointer;transition:all .3s ease;background:#fff}.option-card[_ngcontent-%COMP%]:hover{border-color:#cbd5e1;box-shadow:0 4px 12px #0000000d}.option-card.selected[_ngcontent-%COMP%]{border-color:#89b03e;background:linear-gradient(135deg,#fefefe,#f7fee7);box-shadow:0 4px 16px #89b03e26}.custom-radio[_ngcontent-%COMP%]{width:22px;height:22px;border:2px solid #cbd5e1;border-radius:50%;display:flex;align-items:center;justify-content:center;transition:all .3s ease}.custom-radio.checked[_ngcontent-%COMP%]{border-color:#89b03e;background:#89b03e}.custom-radio.checked[_ngcontent-%COMP%]:after{content:"";width:8px;height:8px;background:#fff;border-radius:50%}.paylater-warning-box[_ngcontent-%COMP%]{background:#fffbeb;border:2px solid #fde68a;border-radius:18px;padding:1.8rem 1.2rem 1.2rem;text-align:center;max-width:700px;margin:.5rem auto;color:#a16207;box-sizing:border-box}.paylater-warning-icon-bg[_ngcontent-%COMP%]{background:#fef3c7;border-radius:50%;width:90px;height:90px;display:flex;align-items:center;justify-content:center;margin:0 auto 1.5rem}.paylater-warning-icon[_ngcontent-%COMP%]{font-size:2.5rem;color:#d97706}.paylater-warning-title[_ngcontent-%COMP%]{font-size:1.4rem;font-weight:700;margin-bottom:.7rem;color:#b45309;font-family:inherit}.paylater-warning-msg[_ngcontent-%COMP%]{font-size:1rem;color:#b45309;margin-bottom:.2rem}.paylater-warning-desc[_ngcontent-%COMP%]{font-size:.875rem;color:#ca8a04}[_nghost-%COMP%] datepicker .mat-mdc-form-field .mdc-notched-outline, [_nghost-%COMP%] datepicker .mat-mdc-form-field .mdc-notched-outline__notch, [_nghost-%COMP%] datepicker .mat-mdc-form-field .mdc-notched-outline__leading, [_nghost-%COMP%] datepicker .mat-mdc-form-field .mdc-notched-outline__trailing{border-color:#e2e8f0!important;border-width:1px!important}[_nghost-%COMP%] datepicker.sell-paylater .mat-mdc-form-field.mat-focused .mdc-notched-outline{border:1px solid #89b03e!important;box-shadow:0 0 0 4px #89b03e26;border-radius:4px}[_nghost-%COMP%] datepicker.sell-paylater input{font-size:16px}[_nghost-%COMP%] datepicker.sell-paylater .mat-mdc-form-field{width:100%;font-size:16px;background:#fff}[_nghost-%COMP%] datepicker.sell-paylater .mat-mdc-form-field .mat-mdc-icon-button, [_nghost-%COMP%] datepicker.sell-paylater .mat-mdc-form-field .mat-mdc-button-persistent-ripple, [_nghost-%COMP%] datepicker.sell-paylater .mat-mdc-form-field .mat-mdc-form-field-icon-suffix{outline:none!important}']})};function ws(n,t){n&1&&(a(0,"div",0)(1,"div",1),y(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 Es(n,t){n&1&&(a(0,"div",0)(1,"div",5),y(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 _n=class n{isCancel=!1;constructor(){}ngOnInit(){}static \u0275fac=function(e){return new(e||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(e,i){e&1&&h(0,ws,7,0)(1,Es,9,0,"div",0),e&2&&C(i.isCancel?1:0)},encapsulation:2})};var yn=class n{constructor(){}ngOnInit(){}static \u0275fac=function(e){return new(e||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(e,i){e&1&&(a(0,"div",0)(1,"div",1),y(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 Bn=n=>({selected:n}),As=(n,t)=>({active:n,"font-12":t}),ks=n=>({"border-top py-5":n}),Vs=n=>({"d-print-none":n}),Fs=n=>({"qris-barcode":n}),Bs=n=>({bottom:n});function Ls(n,t){if(n&1&&(a(0,"span"),d(1),s()),n&2){let e=p(2);l(),I(" (+",e.posData==null?null:e.posData.Invoice.SurchargePcg,"%) ")}}function Hs(n,t){if(n&1&&(a(0,"span"),d(1),s(),a(2,"span"),d(3),v(4,"number"),s()),n&2){let e=p(2);l(),P(e.cashierCalculatorService==null?null:e.cashierCalculatorService.currencySymbol),l(2),P(D(4,2,e.totalAmount()))}}function js(n,t){if(n&1&&(a(0,"header")(1,"div",6),ee(2,Ls,2,1,"span",1),h(3,Hs,5,4),s()()),n&2){let e=p();l(2),m("ngIf",(e.posData==null?null:e.posData.Invoice.SurchargePcg)>0),l(),C(e.userRole.PriceVisible?3:-1)}}function Qs(n,t){if(n&1){let e=E();a(0,"a",14),_("click",function(){b(e);let o=p(4);return S(o.onSplitClick())}),d(1," Split "),a(2,"span",15),d(3,"Payment"),s()()}if(n&2){let e=p(4);m("ngClass",k(1,Bn,e.modalFields.isStateSplit))}}function Us(n,t){if(n&1){let e=E();a(0,"a",16),_("click",function(){b(e);let o=p(4);return S(o.onLaterClick())}),d(1," Later "),a(2,"span",15),d(3,"Take Credit"),s()()}if(n&2){let e=p(4);m("ngClass",k(1,Bn,e.modalFields.isStateLater))}}function Ws(n,t){if(n&1){let e=E();a(0,"div")(1,"a",11),_("click",function(){b(e);let o=p(3);return S(o.onNowClick())}),d(2," Now "),s(),ee(3,Qs,4,3,"a",12)(4,Us,4,3,"a",13),s()}if(n&2){let e=p(3);l(),m("ngClass",k(3,Bn,e.modalFields.isStateNow)),l(2),m("ngIf",((e.modalFields==null||e.modalFields.paymentSuggestion==null?null:e.modalFields.paymentSuggestion.length)==0||e.cashPaymentChange<0)&&e.modalFields.splitPaymentEnabled&&!e.isQRISOnlyPayment()),l(),m("ngIf",e.modalFields.payNowEnabled==!1&&!e.userRole.CreditSalesLock)}}function Gs(n,t){if(n&1&&(a(0,"div",10),ee(1,Ws,5,5,"div",1),s()),n&2){let e=p(2);l(),m("ngIf",e.modalFields.payNowNLaterEnabled||e.modalFields.payNowEnabled)}}function $s(n,t){if(n&1){let e=E();a(0,"div",31)(1,"a",32),_("click",function(){let o=b(e).$implicit,r=p(5);return S(r.updateCashPayment(o))}),d(2),v(3,"number"),s()()}if(n&2){let e=t.$implicit,i=p(5);l(),m("ngClass",We(5,As,(i.Payments[0]==null?null:i.Payments[0].MethodID)==i.defaultCashPaymentMethodID&&(i.Payments[0]==null?null:i.Payments[0].PaidAmount)==e,i.modalFields.paymentSuggestion[0].toString().length>8)),l(),yt("",i.cashierCalculatorService==null?null:i.cashierCalculatorService.currencySymbol," ",D(3,3,e))}}function qs(n,t){if(n&1&&(a(0,"div",29),ee(1,$s,4,8,"div",30),s()),n&2){let e=p(4);l(),m("ngForOf",e.modalFields.paymentSuggestion)}}function Js(n,t){if(n&1&&(a(0,"div",33),d(1),v(2,"number"),s()),n&2){let e=p(4);m("ngClass",e.cashPaymentChange>0?"success":"danger"),l(),yt(" ",e.cashierCalculatorService==null?null:e.cashierCalculatorService.currencySymbol," ",D(2,3,e.cashPaymentChange)," ")}}function zs(n,t){if(n&1){let e=E();Ot(0),a(1,"div",17)(2,"div",21),y(3,"i",22),d(4," Cash "),s(),a(5,"div",23),ee(6,qs,2,1,"div",24),a(7,"div",25)(8,"div",26)(9,"input",27),Q("ngModelChange",function(o){b(e);let r=p(3);return B(r.inputAmountString,o)||(r.inputAmountString=o),S(o)}),_("ngModelChange",function(){b(e);let o=p(3);return S(o.updateCashPayment(o.inputAmountString))}),s(),ee(10,Js,3,5,"div",28),s()()()(),Mt()}if(n&2){let e=p(3);l(6),m("ngIf",e.userRole.PriceVisible),l(3),m("simpleKeyboard",e.keyboard),j("ngModel",e.inputAmountString),l(),m("ngIf",e.cashPaymentChange!=0)}}function Ks(n,t){if(n&1){let e=E();a(0,"div",36)(1,"button",37),_("click",function(){let o=b(e).$implicit,r=p(4);return S(r.handlingCashMachinePayment(o))}),a(2,"span",38),y(3,"img",39),s(),a(4,"span",38),d(5),v(6,"limitTo"),s()()()}if(n&2){let e=t.$implicit;l(2),m("hidden",e.ImageUrl==null),l(),m("src",e.ImageUrl,Ct),l(),m("hidden",e.ImageUrl!=null),l(),I(" ",re(6,4,e.Name,20)," ")}}function Ys(n,t){if(n&1&&(a(0,"div",17)(1,"div",21),y(2,"i",34),d(3," Cash Machine "),s(),a(4,"div",23)(5,"div",35),z(6,Ks,7,7,"div",36,Le),s()()()),n&2){let e=p(3);l(6),K(e.cashMachineList())}}function Zs(n,t){if(n&1){let e=E();a(0,"div",36)(1,"button",37),_("click",function(){let o=b(e).$implicit,r=p(4);return r.onPaymentMethodChanged(o),S(r.payWithEmoney(o))}),a(2,"span",38),y(3,"img",39),s(),a(4,"span",38),d(5),v(6,"limitTo"),s()()()}if(n&2){let e=t.$implicit;l(2),m("hidden",e.ImageUrl==null),l(),m("src",e.ImageUrl,Ct),l(),m("hidden",e.ImageUrl!=null),l(),I(" ",re(6,4,e.Name,20)," ")}}function Xs(n,t){if(n&1&&(a(0,"div",17)(1,"div",21),y(2,"i",40),d(3," QRIS "),s(),a(4,"div",23)(5,"div",35),ee(6,Zs,7,7,"div",41),s()()()),n&2){let e=p(3);l(6),m("ngForOf",e.getTypePaymentList(3))}}function el(n,t){if(n&1&&(a(0,"span"),y(1,"img",39),s()),n&2){let e=p().$implicit;l(),m("src",e.ImageUrl,Ct)}}function tl(n,t){if(n&1&&(a(0,"span"),d(1),v(2,"limitTo"),s()),n&2){let e=p().$implicit;l(),I(" ",re(2,1,e.Name,20)," ")}}function il(n,t){if(n&1){let e=E();a(0,"div",36)(1,"button",37),_("click",function(){let o=b(e).$implicit,r=p(4);return S(r.handlingSubmitOrderWithEcr(o))}),ee(2,el,2,1,"span",1)(3,tl,3,4,"span",1),s()()}if(n&2){let e=t.$implicit;l(2),m("ngIf",e.ImageUrl!=null),l(),m("ngIf",e.ImageUrl==null)}}function nl(n,t){if(n&1&&(a(0,"div",42)(1,"div",21),y(2,"i",43),d(3," ECR / EDC "),s(),a(4,"div",23)(5,"div",25),ee(6,il,4,2,"div",41),s()()()),n&2){let e=p(3);l(6),m("ngForOf",e.getTypePaymentList(99))}}function ol(n,t){if(n&1&&(a(0,"div",21),y(1,"i"),d(2),s()),n&2){let e=p().$implicit;l(),et(e.Icon),l(),I(" ",e.Name," ")}}function rl(n,t){if(n&1){let e=E();a(0,"div",36)(1,"a",48),_("click",function(){let o=b(e).$implicit,r=p(5);return S(r.onPaymentMethodChanged(o))}),d(2),v(3,"limitTo"),s()()}if(n&2){let e=t.$implicit,i=p(5);l(),m("ngClass",i.Payments[0].MethodID===e.ID?"active":""),l(),I(" ",re(3,2,e.Name,20)," ")}}function al(n,t){n&1&&(a(0,"small",53),d(1," Payment Note is required "),s())}function sl(n,t){n&1&&(a(0,"small",53),d(1," Payment Code is required "),s())}function ll(n,t){n&1&&(a(0,"small",53),d(1," Please input maximum 1 characters "),s())}function cl(n,t){if(n&1&&(h(0,sl,2,0,"small",53),h(1,ll,2,0,"small",53)),n&2){let e=p(6);C(e.paymentCodeCtrl.hasError("required")?0:-1),l(),C(e.paymentCodeCtrl.hasError("maxlength")?1:-1)}}function dl(n,t){if(n&1&&(a(0,"div",49)(1,"div",50)(2,"div",51),y(3,"input",52),h(4,al,2,0,"small",53),s(),a(5,"div",51),y(6,"input",54),h(7,cl,2,2),s()()()),n&2){let e=p(5);l(3),m("formControl",e.paymentNoteCtrl),l(),C(e.paymentNoteCtrl.invalid&&(e.paymentNoteCtrl.dirty||e.paymentNoteCtrl.touched)?4:-1),l(2),m("formControl",e.paymentCodeCtrl),l(),C(e.paymentCodeCtrl.dirty||e.paymentCodeCtrl.touched?7:-1)}}function ml(n,t){if(n&1&&(a(0,"div",23)(1,"div",25),ee(2,rl,4,5,"div",41),s(),ee(3,dl,8,4,"div",47),s()),n&2){let e=p().$implicit,i=p(3);l(2),m("ngForOf",i.getTypePaymentList(e.ID)),l(),m("ngIf",i.isOtherPayment(e.ID))}}function pl(n,t){if(n&1&&(a(0,"div",44),ee(1,ol,3,3,"div",45)(2,ml,4,2,"div",46),s()),n&2){let e=t.$implicit,i=p(3);m("ngClass",k(3,ks,i.getTypePaymentList(e.ID).length>0)),l(),m("ngIf",i.getTypePaymentList(e.ID).length>0),l(),m("ngIf",i.getTypePaymentList(e.ID).length>0)}}function ul(n,t){if(n&1&&(a(0,"div"),ee(1,zs,11,4,"ng-container",1),h(2,Ys,8,0,"div",17),ee(3,Xs,7,1,"div",18)(4,nl,7,1,"div",19)(5,pl,3,5,"div",20),s()),n&2){let e,i=p(2);l(),m("ngIf",(i.modalFields==null||i.modalFields.paymentSuggestion==null?null:i.modalFields.paymentSuggestion.length)>0),l(),C(((e=i.cashMachineList())==null?null:e.length)>0?2:-1),l(),m("ngIf",i.getTypePaymentList(3).length>0&&i.isOnline),l(),m("ngIf",i.getTypePaymentList(99).length>0&&i.isOnline),l(),m("ngForOf",i.paymentTypes)}}function gl(n,t){if(n&1){let e=E();a(0,"div")(1,"div",55)(2,"app-paylater",56),_("dueDateChange",function(o){b(e);let r=p(2);return S(r.dueDateChange(o))}),s()()()}if(n&2){let e=p(2);l(2),m("paylaterDueDate",e.modalFields.payLaterDueDate)("paylaterDueDays",e.modalFields.payLaterDueDays)("orderDate",e.posData==null||e.posData.Order==null?null:e.posData.Order.Date)("isCustomerAssigned",e.modalFields.isCustomerAssigned())}}function fl(n,t){if(n&1){let e=E();Ot(0),a(1,"div",25)(2,"div",58)(3,"div",59)(4,"strong",60),d(5,"Payment 1:"),s()(),a(6,"div")(7,"ng-select",61),_("change",function(o){b(e);let r=p(3);return S(r.onPaymentMethodChanged(o))}),s()()(),a(8,"div",62)(9,"div",59)(10,"strong",63),d(11,"Amount 1:"),s()(),a(12,"div")(13,"input",64),_("ngModelChange",function(o){b(e);let r=p(3);return S(r.onFirstPaymentSplitChange(o))}),s()()()(),Mt()}if(n&2){let e=p(3);l(7),m("items",e.firstPaymentSplitOptions)("ngModel",e.firstPayment==null?null:e.firstPayment.MethodID)("clearable",!1),l(6),m("ngModel",e.firstPayment.PaidAmount)}}function hl(n,t){n&1&&(a(0,"small",53),d(1," Payment Note is required "),s())}function Cl(n,t){n&1&&(a(0,"small",53),d(1," Payment Code is required "),s())}function vl(n,t){n&1&&(a(0,"small",53),d(1," Please input maximum 1 characters "),s())}function _l(n,t){if(n&1&&(h(0,Cl,2,0,"small",53),h(1,vl,2,0,"small",53)),n&2){let e=p(5);C(e.paymentCodeCtrl2.hasError("required")?0:-1),l(),C(e.paymentCodeCtrl2.hasError("maxlength")?1:-1)}}function yl(n,t){if(n&1&&(a(0,"div",71)(1,"div",50)(2,"div",51),y(3,"input",52),h(4,hl,2,0,"small",53),s(),a(5,"div",51),y(6,"input",54),h(7,_l,2,2),s()()()),n&2){let e=p(4);l(3),m("formControl",e.paymentNoteCtrl2),l(),C(e.paymentNoteCtrl2.invalid&&(e.paymentNoteCtrl2.dirty||e.paymentNoteCtrl2.touched)?4:-1),l(2),m("formControl",e.paymentCodeCtrl2),l(),C(e.paymentCodeCtrl2.dirty||e.paymentCodeCtrl2.touched?7:-1)}}function bl(n,t){if(n&1){let e=E();Ot(0),a(1,"div",65)(2,"div",66)(3,"div",67)(4,"div",59)(5,"strong",60),d(6,"Payment 2:"),s()(),a(7,"div")(8,"ng-select",68),_("change",function(o){b(e);let r=p(3);return S(r.onSplitPaymentMethodAssigned(o))}),s()()(),a(9,"div",69)(10,"strong",63),d(11,"Amount 2:"),s(),a(12,"span",70),d(13),v(14,"number"),s()()()(),h(15,yl,8,4,"div",71),Mt()}if(n&2){let e=p(3);l(8),m("items",e.splitPaymentMethodList)("ngModel",e.Payments[1]==null?null:e.Payments[1].MethodID),l(5),P(D(14,4,e.paymentSplitDefaultVal)),l(2),C((e.Payments[1]==null?null:e.Payments[1].TypeID)!==e.paymentType.ECR&&(e.Payments[1]==null?null:e.Payments[1].TypeID)!==e.paymentType.emoney&&(e.Payments[1]==null?null:e.Payments[1].TypeID)!==e.paymentType.cash&&e.Payments[1]?15:-1)}}function Sl(n,t){if(n&1&&(a(0,"div",57),ee(1,fl,14,4,"ng-container",1)(2,bl,16,6,"ng-container",1),s()),n&2){let e=p(2);l(),m("ngIf",(e.modalFields==null||e.modalFields.paymentSuggestion==null?null:e.modalFields.paymentSuggestion.length)==0),l(),m("ngIf",e.cashPaymentChange<0)}}function Pl(n,t){if(n&1&&(a(0,"div",7),ee(1,Gs,2,1,"div",8)(2,ul,6,5,"div",1)(3,gl,3,4,"div",1)(4,Sl,3,2,"div",9),s()),n&2){let e=p();l(),m("ngIf",e.modalFields.payLaterEnabled==!1),l(),m("ngIf",e.modalFields.isStateNow),l(),m("ngIf",e.modalFields.isStateLater&&!e.userRole.CreditSalesLock),l(),m("ngIf",e.modalFields.isStateSplit)}}function Ol(n,t){if(n&1&&(Ot(0),a(1,"div",83),y(2,"img",84),s(),Mt()),n&2){let e=p(2);l(),m("ngStyle",k(1,Bs,e.modalFields.merchantName?"0px":"-25px"))}}function Ml(n,t){if(n&1&&(a(0,"h2",85),d(1),s()),n&2){let e=p(2);l(),I(" ",e.modalFields.merchantName," ")}}function Dl(n,t){if(n&1&&(a(0,"div",72)(1,"div",73)(2,"span",74),d(3),s(),a(4,"div",75)(5,"div",76)(6,"span",77),d(7,"Invoice"),s(),a(8,"span"),d(9,":"),s()(),a(10,"div",78)(11,"span",79),d(12),s()()(),a(13,"div",75)(14,"div",76)(15,"span"),d(16,"Amount"),s(),a(17,"span"),d(18,":"),s()(),a(19,"div",78)(20,"span",79),d(21),v(22,"number"),s()()()(),ee(23,Ol,3,3,"ng-container",1)(24,Ml,2,1,"h2",80),a(25,"div",81),y(26,"img",82),s()()),n&2){let e=p();l(2),m("ngClass",k(11,Vs,(e.selectedPaymentMethod==null?null:e.selectedPaymentMethod.EMoneyTypeID)!=(e.modalFields==null?null:e.modalFields.emoneyType.Gopay))),l(),P(e.modalFields==null?null:e.modalFields.merchantName),l(9),P(e.posData==null||e.posData.Order==null?null:e.posData.Order.Number),l(9),yt("",e.cashierCalculatorService.currencySymbol," ",D(22,9,e.totalAmount())),l(2),m("ngIf",(e.selectedPaymentMethod==null?null:e.selectedPaymentMethod.EMoneyTypeID)==(e.modalFields==null?null:e.modalFields.emoneyType.Gopay)),l(),m("ngIf",e.modalFields.merchantName&&(e.selectedPaymentMethod==null?null:e.selectedPaymentMethod.EMoneyTypeID)==(e.modalFields==null?null:e.modalFields.emoneyType.Gopay)),l(2),m("src",e.qrImage,Ct)("ngClass",k(13,Fs,(e.selectedPaymentMethod==null?null:e.selectedPaymentMethod.EMoneyTypeID)==(e.modalFields==null?null:e.modalFields.emoneyType.Gopay)))}}function xl(n,t){n&1&&y(0,"app-confirm-demo-qris")}function Il(n,t){if(n&1&&(Ot(0),y(1,"app-modal-ecr-info",86),Mt()),n&2){let e=p();l(),m("isCancel",e.modalFields.isCancelEcrTransaction)}}function Tl(n,t){if(n&1){let e=E();a(0,"cash-machine-payment",87),_("onTransactionComplete",function(o){b(e);let r=p();return S(r.onCashMachineTransactionComplete(o))}),s()}if(n&2){let e=p();m("totalAmount",e.totalAmount())}}function wl(n,t){if(n&1){let e=E();a(0,"button",90),_("click",function(){b(e);let o=p(2);return S(o.onCancelCashMachine())}),d(1," Cancel "),s()}}function El(n,t){if(n&1){let e=E();h(0,wl,2,0,"button",88),a(1,"button",89),_("click",function(){b(e);let o=p();return S(o.onRefreshCashMachineStatus())})("keyup.F2",function(){b(e);let o=p();return S(o.onRefreshCashMachineStatus())}),d(2," Refresh "),s()}if(n&2){let e=p();C(e.modalFields.isCashMachineProvideChange()?0:-1)}}function Rl(n,t){if(n&1){let e=E();a(0,"a",90),_("click",function(){b(e);let o=p();return S(o.onPrintQR())}),y(1,"i",91),d(2,"Print QR "),s()}}function Nl(n,t){if(n&1){let e=E();a(0,"a",90),_("click",function(){b(e);let o=p();return S(o.validateEMoneyPayment())}),d(1," Verify Payment Settlement "),s()}}function Al(n,t){if(n&1){let e=E();a(0,"a",90),_("click",function(){b(e);let o=p();return S(o.onCancelWaitingEcr())}),d(1),s()}if(n&2){let e=p();l(),I(" ",e.modalFields.isCancelEcrTransaction?"Close":"Cancel"," ")}}function kl(n,t){if(n&1){let e=E();a(0,"a",90),_("click",function(){b(e);let o=p();return S(o.onBack())}),d(1," Back "),s()}}function Vl(n,t){if(n&1){let e=E();a(0,"a",90),_("click",function(){b(e);let o=p();return S(o.onContinueDemoQr())}),d(1," Continue "),s()}}var bn=class n{constructor(t,e,i,o,r,c,g,x,V,q,Oe,ci,Hn,gr,xn,In,jn,uc,gc){this.dialogRef=t;this._orderDataService=e;this.cashierCalculatorService=i;this._paymentService=o;this._posHubService=r;this._posService=c;this._toastr=g;this._paymentGatewayService=x;this.decimalPipe=V;this.sanitizer=q;this._orderProcessorService=Oe;this._numpadService=ci;this._userRoleService=Hn;this._customerHttpService=gr;this._onlineStatusService=xn;this._ecrService=In;this.outletService=jn;this.ecrSignalService=uc;this.cashMachineService=gc;this.paymentSplitDefaultVal=0,this.defaultCashPaymentMethodID=0,this.destroy$=new xe,this.AppConfigJSON=this._posService.Data.AppConfigJSON,this.modalFields.mapAppConfigJson(this.AppConfigJSON),this.initializeDefaultValues(),this.subscribeToObservableChanges(),this.initIsQRISOnlyPayment()}modalFields=new gn;userRole;posData=new $;AppConfigJSON=new mt;keyboard;paymentType=ni;Payments=[];defaultCashPaymentMethodID;inputAmountString=null;qrImage;paymentMethodList;paymentTypes;paymentSplitDefaultVal;posState;splitPaymentMethodList;isOnline=!0;get firstPayment(){return this.Payments[0]}set firstPayment(t){this.Payments[0]=t}selectedPaymentMethod;get cashPaymentChange(){let t=this.cashierCalculatorService.Data;return(this.firstPayment?this.firstPayment.PaidAmount:0)-t}firstPaymentSplitOptions;destroy$;paymentNoteCtrl;paymentCodeCtrl;paymentNoteCtrl2;paymentCodeCtrl2;totalAmount=J(()=>this.cashierCalculatorService.Data);cashMachineList=J(()=>this.getTypePaymentList(1).filter(e=>e.SubTypeID==4));isQRISOnlyPayment=T(!1);subscribeToObservableChanges(){this._orderDataService.Data$.pipe(Ie(this.destroy$)).subscribe(t=>{this.posData=t}),this._orderProcessorService.Data$.pipe(Ie(this.destroy$)).subscribe(t=>{this.posState=t.posState,this.initializeInvoicePaymentsValue(this.posState),this.initTabState()}),this._onlineStatusService.getOnlineStatus$().pipe(Ie(this.destroy$)).subscribe(t=>{this.isOnline=t})}initCashFocus(){let t=document.getElementById("cashInput");if(t){t.focus();let e=t?.value?.length;setTimeout(()=>{t.setSelectionRange(e,e)},0)}}initIsQRISOnlyPayment(){let e=this._paymentService.paymentList.every(i=>i.TypeID==3||i.TypeID==1&&i.SubTypeID==4);this.isQRISOnlyPayment.set(e),this.modalFields.modalConfigQrisOnlyPayment(e)}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(t){t!==2?(this.firstPayment=new Ye,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 Ye,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 e=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=e?.TypeID}let t=this.firstPayment.PaidAmount;this.inputAmountString=t?t.toString():null}findPaymentMethodByID(t){return this._paymentService.getPaymentList()?.find(o=>o.ID==t)}initPaymentNoteAndCode(t){let e=this.getPaymentNoteAndCodeValidators(t);this.paymentCodeCtrl?(this.paymentCodeCtrl.setValue(t?.Code),this.paymentNoteCtrl.setValue(t?.Note),this.paymentCodeCtrl.setValidators(e.paymentCodeValidators),this.paymentNoteCtrl.setValidators(e.paymentNoteValidators),this.paymentCodeCtrl.updateValueAndValidity(),this.paymentNoteCtrl.updateValueAndValidity()):(this.paymentCodeCtrl=new Ge(t?.Code,e.paymentCodeValidators),this.paymentNoteCtrl=new Ge(t?.Note,e.paymentNoteValidators))}getPaymentNoteAndCodeValidators(t){let e=this.AppConfigJSON?.ModuleSell?.PaymentDialog,i=this.userRole.PaymentCodeLock,o=[],r=[];if(t&&t?.TypeID!=1&&t?.TypeID!=99&&t?.TypeID!=3){let c=i?[Tt.maxLength(1)]:[],g=e.PaymentCodeRequired?[Tt.required]:[];o=[...c,...g],r=e.PaymentNoteRequired?[Tt.required]:[]}return{paymentCodeValidators:o,paymentNoteValidators:r}}initSplitPayment(){let t=this.cashierCalculatorService.Data,e=this.Payments[1].PaidAmount,i=t-e;this.firstPayment.PaidAmount=i,this.firstPayment.Amount=i,this.paymentSplitDefaultVal=e,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(t=>{this.userRole=t,this.initPaylaterTab()}),this.initFirstPaymentSplitOptions()}initPaylaterTab(){this.userRole.CreditSalesLock&&(this.modalFields.viewState=0)}ngOnInit(){this.modalFields.numpadVisible&&!this.isQRISOnlyPayment()&&(this.keyboard=this._numpadService.keyboard),this.initDefaultDueDays()}initDefaultDueDays(){let t=this._customerHttpService.Data,e=t?t.DueDays:null,i=t?t.DueMonths:null,o=new Date;o.setHours(0,0,0,0);let r=new Date;r.setHours(0,0,0,0),u.IsNotEmpty(this.posData.Invoice.Due)?o=new Date(this.posData.Invoice.Due):(i&&o.setMonth(o.getMonth()+i),!e&&!i&&(e=this.modalFields.config.DefaultDueDays),o.setDate(o.getDate()+e)),this.modalFields.payLaterDueDate=o,this.modalFields.payLaterDueDays=u.differentInDays(r,o),this.posData.Invoice.Due=this.modalFields.payLaterDueDate;let c=this.posData?.Order?.CustomerID;this.modalFields.isCustomerAssigned.set(u.IsNotEmpty(c))}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(t,e,i){t&&t.TypeID!=1&&t.TypeID!=99&&t.TypeID!=3&&(t.Code=i,t.Note=e)}isPaymentLater(){let t=this.modalFields.viewState==1,e=this.cashPaymentChange<0&&this.Payments.length==1;return t||e}handlingSubmitOrderWithEcr(t){if(this.ecrSignalService.isConnected()==!1){this._toastr.error("ECR is not connected","Error");return}this.onPaymentMethodChanged(t),this.posData.Invoice.Due=null;let e=this.firstPayment.PaidAmount;this.modalFields.viewState=5,this.modalFields.enableModalWaitingEcr(!0),this._ecrService.onPay(e).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(t){this.cashMachineService.isConnected()?(this.onPaymentMethodChanged(t),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(t){t.changeDue==0?this.onSubmitOrder():t.canProvideChange?this.onSubmitOrder():this.modalFields.isCashMachineProvideChange.set(!1)}onRefreshCashMachineStatus(){this.cashMachineService.checkPaymentStatus(this.totalAmount()).pipe(ne(t=>t==!0),Ie(this.destroy$)).subscribe(()=>{this.onCashMachineNotProvideChange(),this.closeDialogAfterSubmit()})}onCashMachineNotProvideChange(){this._paymentService.submitOrder(this.Payments),this.closeDialogAfterSubmit()}isCustomerLimitDebt(){if(this.paymentSplitDefaultVal>0&&this.Payments.length==1){let t=this._customerHttpService.Data;if(t.DebtLimit>0){let e=t.Debt==0&&this.paymentSplitDefaultVal>t.DebtLimit,i=t.Debt+this.paymentSplitDefaultVal>t.DebtLimit;if(e||i)return this._toastr.warning(ae.debtLimit,"Warning!"),!0}}return!1}validateSerialItem(){let t=this.findItemWithoutSerial();return t.length>0?u.IsEmpty(this.posData.Action.DeliveryEntityID)?!0:(this._toastr.warning(`Serial can not Empty in ${t[0]?.Variant?.Name}`,"Warning"),!1):!0}findItemWithoutSerial(){let t;return this.posData.CartItems.filter(i=>(t=!1,i.Variant&&i.Variant.TypeID===4&&(t=i?.Serial?i?.Serial?.length===0:!0),t))}validatePaymentLater(t){if(this.posData?.Invoice?.SurchargePcg!==0)return this._toastr.warning(ae.surcharge,"Payment Method Not Allowed"),!1;if(this.IsCreditSales()&&t.CreditSalesLock)return alert(ae.creditLock),!1;let e=u.IsEmpty(this.posData.Order.CustomerID);return this.modalFields.viewState==1&&e?(alert(ae.emptyCustomerCredit),!1):this.IsCreditSales()&&e?(alert(ae.emptyCustomerCredit),!1):!!this.debtLimitValidation()}debtLimitValidation(){let t=this._customerHttpService.Data,e=!1,i=t.DebtLimit,o=t.DebtCalculated,r=this.cashierCalculatorService.Data,c=o==0&&r>i;if(this.posData.Invoice.PaymentStateID==1){let g=i-o;r>g&&(e=!0)}else e=o+r>i;return i!==0&&(c||e)?(this._toastr.warning(ae.debtLimit,"Warning!"),!1):!0}validatePaymentSplit(){let t=this.firstPayment.PaidAmount,e=this.Payments[1]?this.Payments[1].PaidAmount:0,i=this.cashierCalculatorService.Data,o=[];t+this.modalFields.toleranceAmount>=i?(o=this.Payments.slice(0,1),this.modalFields.toleranceAmount!==0&&t<i&&(this.firstPayment.Amount=i),this.Payments=o):(e+t===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 t=this.firstPayment.Amount+(this.Payments[1]?this.Payments[1].Amount:0);if(this.AppConfigJSON.ModuleSell.PaymentDialog.MinusPaymentAllowed==!1&&t<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(ae.payNowOnly,de.Warning),!1;if(this.IsDepositPayment()&&this.userRole.CreditSalesLock)return this._toastr.warning(ae.creditLock,de.Warning),!1;if(!this.AppConfigJSON.ApplicationLoyalty.Rules.MixCashAndPoint&&this.posData.Order.PointUsed>0&&this.cashierCalculatorService.Data>0)return this._toastr.info(ae.partialLoyaltyPointUnable,de.Info),!1;let e=this.posData.Order.PointUsed*this.AppConfigJSON.ApplicationLoyalty.LoyaltyPoint.RedeemPointValue,i=this.cashierCalculatorService.GetPointOnlyAmount();if(i>0&&i>e){let c=u.StringFormat(ae.pointOnly,this.decimalPipe.transform(this.posData.PointOnlyAmount));return this._toastr.info(c,de.Info),!1}let o=this.cashierCalculatorService.Data+this.posData.Order.DiscountAmount-e,r=this.cashierCalculatorService.GetCashOnlyAmount();if(r=this.posState==7?r*-1:r,r>0&&r>o&&Math.abs(r-o)>this.modalFields.toleranceAmount){let c=u.StringFormat(ae.cashOnly,this.decimalPipe.transform(this.posData.CashOnlyAmount));return this._toastr.info(c,de.Info),!1}return this.IsDepositPayment()&&u.IsEmpty(this.posData.Order.CustomerID)?(alert(ae.emptyCustomerDeposit),!1):this.posData.PrepaidPackageItem.length>0&&u.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(t,e,i){if(t?.TypeID!=1&&t?.TypeID!=99&&t?.TypeID!=3){if(e.markAsDirty(),i.markAsDirty(),e.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(e.hasError("maxlength"))return this._toastr.warning("Payment Code must be 1 character","Warning"),!1}else return!0}onNowClick(){this.initPaymentAfterLater(),this.modalFields.viewState=0,this.isQRISOnlyPayment()&&this.modalFields.modalConfigQrisOnlyPayment(!0)}onLaterClick(){this.modalFields.viewState=1,this.isQRISOnlyPayment()&&this.modalFields.modalConfigQrisOnlyPayment(!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&&u.IsEmpty(this.firstPayment.TypeID)&&(this.firstPayment.TypeID=1)}IsDepositPayment(){let t=!1,e=this.Payments.map(c=>c.PaidAmount).reduce((c,g)=>c+g),i=this.cashierCalculatorService.Data;return this.modalFields.toleranceAmount+e<i&&(t=!0),t}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(e=>{let i=this.findPaymentMethodByID(e.MethodID);return i&&i.ExtraCharge>0})&&this.updateSurcharge(0)}updateCashPayment(t){let e=this.cashierCalculatorService.Data;this.paymentSplitDefaultVal=0,this.firstPayment.MethodID=this.defaultCashPaymentMethodID,this.firstPayment.Amount=e,this.firstPayment.PaidAmount=t,this.firstPayment.TypeID=1,this.posData.Invoice.SurchargePcg!==0&&(this.updateSurcharge(0),this.initCashFocus()),this.calculateSplitPayment(t)}calculateSplitPayment(t){let e=this.cashierCalculatorService.Data;t<e?(this.firstPayment.Amount=t,this.paymentSplitDefaultVal=e-t,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(t){this.selectedPaymentMethod=t,this.updateSurcharge(t.ExtraCharge);let e=this.cashierCalculatorService.Data;this.firstPayment.Amount=e,this.firstPayment.PaidAmount=e,this.firstPayment.MethodID=t.ID,this.firstPayment.TypeID=t.TypeID,t.ExtraCharge>0&&this.paymentSplitDefaultVal>0?this._toastr.warning("Cannot apply Split Payment for Payment Method with Surcharge","Warning"):this.paymentSplitDefaultVal>0&&(this.firstPayment.Amount=e-this.paymentSplitDefaultVal,this.firstPayment.PaidAmount=e-this.paymentSplitDefaultVal),this.initPaymentNoteAndCode(this.firstPayment),this.filterSplitPaymentList()}filterSplitPaymentList(){this.modalFields.uniquePaymentMethodOnSplit?(this.splitPaymentMethodList=this.paymentMethodList.filter(t=>t.ExtraCharge==0).filter(t=>t.ID!==this.firstPayment.MethodID),this.resetSecondPaymentMethod()):this.splitPaymentMethodList=this.paymentMethodList.filter(t=>t.ExtraCharge==0)}resetSecondPaymentMethod(){let e=this.Payments[1]?.MethodID,i=this.firstPayment.MethodID;e==i&&delete this.Payments[1]}updateSurcharge(t){this.posData.Invoice.SurchargePcg=t,this.posData.Invoice.TempSurchargePcg=t,this._orderDataService.pushNewValue(this.posData)}onSplitPaymentMethodAssigned(t){t?(this.Payments[1]=this.Payments[1]?this.Payments[1]:new Ye,this.Payments[1].MethodID=t.ID,this.Payments[1].MethodName=t.Name,this.Payments[1].Amount=this.paymentSplitDefaultVal,this.Payments[1].PaidAmount=this.paymentSplitDefaultVal,this.Payments[1].TypeID=t.TypeID):(this.Payments[1].Amount=0,this.Payments[1].PaidAmount=0),this.initPaymentNoteAndCodeSplit(this.Payments[1])}initPaymentNoteAndCodeSplit(t){let e=this.getPaymentNoteAndCodeValidators(t);this.paymentCodeCtrl2?(this.paymentCodeCtrl2.setValidators(e.paymentCodeValidators),this.paymentNoteCtrl2.setValidators(e.paymentNoteValidators),this.paymentCodeCtrl2.updateValueAndValidity(),this.paymentNoteCtrl2.updateValueAndValidity()):(this.paymentCodeCtrl2=new Ge(t?.Code,e.paymentCodeValidators),this.paymentNoteCtrl2=new Ge(t?.Note,e.paymentNoteValidators))}onFirstPaymentSplitChange(t){let e=this.cashierCalculatorService.Data;this.firstPayment.Amount=e,this.firstPayment.PaidAmount=t,this.calculateSplitPayment(t)}initFirstPaymentSplitOptions(){this.firstPaymentSplitOptions=[...this.getTypePaymentList(2),...this.getTypePaymentList(4)]}isCardPayment(){return this.getTypePaymentList(2).findIndex(e=>e.ID==this.firstPayment.MethodID)>=0}isOtherPayment(t){return this.getTypePaymentList(t).findIndex(e=>e.ID==this.firstPayment.MethodID)>=0}getTypePaymentList(t){return this._paymentService.getPaymentList().filter(i=>i.TypeID==t)}payWithEmoney(t){let e=this.generateQrisRequest();this._paymentGatewayService.generateQR(e,t).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 t=new un;return t.InvoiceNumber=this.posData.Order.Number,t.Amount=this.cashierCalculatorService.Data,t.RegisterID=this.posData.Order.RegisterID,t}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(t){t.status==400?this.validateEMoneyPayment():this._toastr.error(ae.failGenerateQR,de.Error)}validateEMoneyPayment(){this._paymentGatewayService.validateEMoneyPayment(this.AppConfigJSON).pipe(Ie(this.destroy$)).subscribe({next:t=>{this.dialogRef.close();let i=`IDR ${this.decimalPipe.transform(t.Final)} received. Please verify in customer mobile app!`;this._toastr.success(i," QR Settlement"),this._orderProcessorService.updatePosState(1,t)}})}changeModalForEmoney(t){this.modalFields.enableEMoneyModal(t),t||this._posHubService.BroadcastQRToCustomerDisplay("").subscribe()}dueDateChange(t){this.posData.Invoice.Due=t}sanitize(t){return this.sanitizer.bypassSecurityTrustUrl(t)}onPrintQR(){window.print()}ngOnDestroy(){this.destroy$.next(!0),this.destroy$.complete(),this._numpadService.destroy()}static \u0275fac=function(e){return new(e||n)(M(Z),M(H),M(le),M(fn),M(gt),M(X),M(L),M(Gt),M(G),M(io),M(je),M($o),M(Ne),M(Re),M(be),M(hn),M(se),M(qt),M(ft))};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,"mt-10"],[3,"dueDateChange","paylaterDueDate","paylaterDueDays","orderDate","isCustomerAssigned"],[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",3,"click","keyup.F2"],[1,"btn","btn-light-blue","text-primary","btn-lg","fw-bold","me-5","py-8",3,"click"],[1,"fa-solid","fa-print","me-2"]],template:function(e,i){e&1&&(a(0,"modal-material",0),_("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()}),ee(1,js,4,2,"header",1),a(2,"content"),ee(3,Pl,5,4,"div",2)(4,Dl,27,15,"div",3),h(5,xl,1,0,"app-confirm-demo-qris"),ee(6,Il,2,1,"ng-container",1),h(7,Tl,1,1,"cash-machine-payment",4),s(),a(8,"footer"),h(9,El,3,1),ee(10,Rl,3,0,"a",5)(11,Nl,2,0,"a",5)(12,Al,2,1,"a",5)(13,kl,2,0,"a",5)(14,Vl,2,0,"a",5),s()()),e&2&&(m("config",i.modalFields.modalConfig),l(),m("ngIf",!i.modalFields.isQrisConfirm&&!i.modalFields.isCancelEcrTransaction),l(2),m("ngIf",!i.modalFields.isStateQR&&!i.modalFields.isQrisConfirm&&!i.modalFields.isWaitingPaymentEcr&&!i.modalFields.isCashMachine),l(),m("ngIf",i.modalFields.isStateQR),l(),C(i.modalFields.isQrisConfirm?5:-1),l(),m("ngIf",i.modalFields.isWaitingPaymentEcr),l(),C(i.modalFields.isCashMachine?7:-1),l(2),C(i.modalFields.isCashMachine?9:-1),l(),m("ngIf",i.modalFields.isStateQR),l(),m("ngIf",i.modalFields.isStateQR),l(),m("ngIf",i.modalFields.isWaitingPaymentEcr),l(),m("ngIf",i.modalFields.isQrisConfirm),l(),m("ngIf",i.modalFields.isQrisConfirm))},dependencies:[Ee,Yn,Zn,Xn,ve,ge,Me,st,ie,wt,Et,qo,Cn,vn,_n,yn,G,Oi],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}.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 Fl=n=>({"bg-light":n});function Bl(n,t){if(n&1){let e=E();a(0,"button",10),_("click",function(){b(e);let o=p(2).$implicit,r=p(2);return S(r.onApplyPromotion(o))}),d(1," APPLY "),s()}if(n&2){let e=p(4);m("disabled",e.selectedPromotion)}}function Ll(n,t){if(n&1){let e=E();a(0,"button",11),_("click",function(){b(e);let o=p(2).$implicit,r=p(2);return S(r.onRemovePromotion(o))}),d(1," REMOVE "),s()}}function Hl(n,t){if(n&1&&(h(0,Bl,2,1,"button",8),h(1,Ll,2,0,"button",9)),n&2){let e=p().$implicit,i=p(2);C((i.selectedPromotion==null?null:i.selectedPromotion.ID)!=e.ID?0:-1),l(),C((i.selectedPromotion==null?null:i.selectedPromotion.ID)==e.ID?1:-1)}}function jl(n,t){n&1&&(a(0,"p",7),d(1,"Not Eligible"),s())}function Ql(n,t){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,Hl,2,2)(8,jl,2,0,"p",7),s()()),n&2){let e=t.$implicit;m("ngClass",k(4,Fl,!e.Eligible)),l(3),P(e.Name),l(2),P(e.Description),l(2),C(e.Eligible?7:8)}}function Ul(n,t){if(n&1&&(z(0,Ql,9,6,"div",3,Se),v(2,"sortBy")),n&2){let e=p();K(xt(2,0,e.promotions,"desc","Eligible"))}}function Wl(n,t){n&1&&(a(0,"div",2)(1,"p",12)(2,"span"),d(3,"There is no active promotion right now"),s()()())}var li=class n{constructor(t,e,i,o){this._dialogRef=t;this._promotionEventService=e;this._outletRegisterService=i;this._salesOrderService=o;this.destroy$=new xe}data=O(pe);modalConfig=new Y;promotions=[];destroy$;promotionType=Zt;selectedPromotion;showSkipButton=T(this.data?.showSkipButton??!1);showRefreshButton=T(this.data?.showRefreshButton??!0);ngOnInit(){this.subscribePromotionService(),this.initModalConfig()}ngOnDestroy(){this.destroy$.next(!0),this.destroy$.complete()}subscribePromotionService(){this._promotionEventService.Data$.pipe(Ie(this.destroy$)).subscribe(t=>{this.promotions=t,this.checkValidSelectedPromotion()})}checkValidSelectedPromotion(){this.selectedPromotion=this._promotionEventService.selectedPromotion,this.selectedPromotion&&this.promotions.findIndex(e=>e.ID==this.selectedPromotion.ID&&e.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=!this.showSkipButton(),this.modalConfig.hideOk=!this.showRefreshButton(),this.modalConfig.cancelText="Skip Promotion",this.modalConfig.okText='<i class="fas fa-rotate fs-6 me-1"></i>Refresh'}onApplyPromotion(t){this._promotionEventService.applyPromotion(t),t.TypeID!=4&&this.close()}onSkipPromotion(){this.close(!0)}onRemovePromotion(t){this._promotionEventService.removePromotion(),this.selectedPromotion=null}onRefreshPromotion(){let t=this._outletRegisterService.Data.RegisterID;this._promotionEventService.getPromotions(t).subscribe(e=>{this._promotionEventService.loadPromotions(e),this._salesOrderService.Data.CartItems=[],this._salesOrderService.pushNewValue()})}close(t=!1){this._dialogRef.close({skipped:t})}static \u0275fac=function(e){return new(e||n)(M(Z),M(ke),M(se),M(H))};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(e,i){e&1&&(a(0,"modal-material",0),_("onCancel",function(){return i.onSkipPromotion()})("onOk",function(){return i.onRefreshPromotion()})("onClose",function(){return i.close()}),a(1,"content")(2,"div",1),h(3,Ul,3,4)(4,Wl,4,0,"div",2),s()()()),e&2&&(m("config",i.modalConfig),l(3),C(i.promotions.length>0?3:4))},dependencies:[Ee,ie,Rt],styles:[".description[_ngcontent-%COMP%]{word-wrap:break-word}"]})};var Gl=["firstNameAutoFocus"],$l=["customerForm"],Ln=(n,t)=>({selected:n,danger:t}),ht=n=>({"is-invalid":n}),Jt=n=>({selected:n}),ql=n=>({"invalid-feedback":n});function Jl(n,t){n&1&&y(0,"i",14)}function zl(n,t){n&1&&y(0,"i",14)}function Kl(n,t){n&1&&y(0,"i",14)}function Yl(n,t){if(n&1&&y(0,"option",22),n&2){let e=t.$implicit;m("value",e.Name)}}function Zl(n,t){if(n&1&&(a(0,"div",25),d(1," Name is mandatory "),s()),n&2){p();let e=Ce(30);m("ngClass",k(1,ql,e.touched&&e.invalid))}}function Xl(n,t){n&1&&(a(0,"div",44),d(1," Mobile Phone is mandatory "),s())}function ec(n,t){if(n&1&&(a(0,"div",44),d(1),s()),n&2){p(2);let e=Ce(42);l(),I(" ",e.errors==null||e.errors.minLength==null?null:e.errors.minLength.message," ")}}function tc(n,t){if(n&1&&(h(0,Xl,2,0,"div",44),h(1,ec,2,1,"div",44)),n&2){p();let e=Ce(42);C(e.getError("required")&&!e.getError("minLength")?0:-1),l(),C(e.getError("minLength")?1:-1)}}function ic(n,t){n&1&&(a(0,"div",44),d(1," Email must be a valid email address "),s())}function nc(n,t){n&1&&(a(0,"div",44),d(1,"Email is mandatory"),s())}function oc(n,t){if(n&1&&(h(0,ic,2,0,"div",44),h(1,nc,2,0,"div",44)),n&2){p();let e=Ce(49);C(e.errors!=null&&e.errors.email?0:-1),l(),C(e.errors!=null&&e.errors.required?1:-1)}}function rc(n,t){n&1&&(a(0,"div",44),d(1,"Birthdate is mandatory"),s())}function ac(n,t){if(n&1&&h(0,rc,2,0,"div",44),n&2){p();let e=Ce(56);C(e.errors!=null&&e.errors.required?0:-1)}}function sc(n,t){if(n&1&&y(0,"i",43),n&2){let e=p();m("matTooltip",e.estimatedCodeMessage)}}function lc(n,t){n&1&&(a(0,"div",44),d(1," Customer code is mandatory. "),s())}function cc(n,t){n&1&&(a(0,"div",44),d(1,"Address is mandatory."),s())}function dc(n,t){if(n&1&&(a(0,"div",44),d(1),s()),n&2){p();let e=Ce(93);l(),I(" ",e.errors==null||e.errors.minLength==null?null:e.errors.minLength.message," ")}}function mc(n,t){n&1&&(a(0,"div",66),d(1," Sign Up Outlet is mandatory. "),s())}var Sn=class n{constructor(t,e,i,o,r,c){this._dialogRef=t;this._posService=e;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 Y;customer;get options(){return this._posService.Data.CustomerOptions}get config(){return this._posService.Data.AppConfigJSON}customerData;tabState="general";guidEmpty=u.GuidEmpty;outlets=T([]);get isGeneralFormInvalid(){let t=this.customerForm?.controls?.generalForm;return this.checkDirtyForm(t)}get isDetailFormInvalid(){let t=this.customerForm?.controls?.detailForm;return this.checkDirtyForm(t)}get isIdFormInvalid(){let t=this.customerForm?.controls?.idForm;return this.checkDirtyForm(t)}checkDirtyForm(t){return t?Object.keys(t.controls).every(i=>t?.controls?.[i].touched||t?.controls?.[i].dirty)&&t.invalid:!1}isSaved=T(!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(e=>{this.fieldRequiredConfig[e]===!1&&(this.fieldRequiredConfig[e]=!0)})}initCustomer(){let t=this._posService.Data.AppConfigJSON;this.outlets.set(this._posService.Data?.Entities);let e=t.ModuleContact?.DefaultContactGroup?.ContactGroup;this.customer=new Jo,u.IsNotEmpty(this.data)&&(this.customer.FirstName=this.data.name),u.IsNotEmpty(e)&&(this.customer.Group=e),this.initCustomerCode(t?.ModuleContact?.CodeGenerator?.AutoGenerateEnabled),this.initCustomerSignUpOutlet()}initCustomerSignUpOutlet(){let t=this._registerService.Data;this.customer.CreatorEntityID=t?.EntityID}initCustomerCode(t=!1){t?this._CustomerHttpService.getCustomerSuggestionCode().pipe(oe()).subscribe(e=>{this.customer.Code=e}):this.estimatedCodeMessage=""}ngAfterViewInit(){this.setAutoFocus()}setAutoFocus(){this.firstNameRef.nativeElement.focus()}onKeyUpFirstName(){this.customer.FirstName?this.modalConfig.validated=!0:this.modalConfig.validated=!1}chooiceDetail(t){this.tabState=t}onOk(t){if(t.form.markAllAsTouched(),!t.form.invalid&&this.isSaved()==!1){this.isSaved.set(!0);let e=this._orderDataService.Data;this.customer.Name=this.getCustomerName(),this._CustomerHttpService.addCustomer(this.customer,this.options.DebtLimit).then(i=>{e.ContactName=this.customer.Name,this._orderDataService.pushNewValue(e),this.getCustomerData(i.ID),this.isSaved.set(!1)}).catch(i=>{this.isSaved.set(!1)})}}getCustomerData(t){this._orderDataService.updateCustomerID(t).then(e=>{this.customerData=e,this.close("ok")}).catch(e=>{this.customerData=new kt,this.close("ok")})}getCustomerName(){let t="";return t+=" "+(this.customer.FirstName?this.customer.FirstName:""),t+=" "+(this.customer.LastName?this.customer.LastName:""),t=t.trim(),t}close(t){t==="ok"?this._dialogRef.close(this.customerData):this._dialogRef.close(null)}isNotEmpty(t){return u.IsNotEmpty(t)||t==0}static \u0275fac=function(e){return new(e||n)(M(Z),M(X),M(H),M(Re),M(se),M(pe))};static \u0275cmp=N({type:n,selectors:[["POS-modal-customer"]],viewQuery:function(e,i){if(e&1&&Dt(Gl,5)($l,5),e&2){let o;vt(o=_t())&&(i.firstNameRef=o.first),vt(o=_t())&&(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(e,i){if(e&1){let o=E();a(0,"modal-material",9),_("onOk",function(){b(o);let c=Ce(4);return S(i.onOk(c))})("onCancel",function(){return i.close("cancel")})("onClose",function(){return i.close("close")}),a(1,"content")(2,"div",10)(3,"form",11,0)(5,"div",12)(6,"div")(7,"a",13),_("click",function(){return i.chooiceDetail("general")}),d(8," General "),h(9,Jl,1,0,"i",14),s(),a(10,"a",13),_("click",function(){return i.chooiceDetail("detail")}),d(11," Detail "),h(12,zl,1,0,"i",14),s(),a(13,"a",13),_("click",function(){return i.chooiceDetail("id")}),d(14," ID "),h(15,Kl,1,0,"i",14),s()()(),a(16,"div",15)(17,"div",16)(18,"div",17)(19,"div",18)(20,"input",19),Q("ngModelChange",function(c){return b(o),B(i.customer.Title,c)||(i.customer.Title=c),S(c)}),s(),a(21,"label",20),d(22,"Title"),s(),a(23,"datalist",21),z(24,Yl,1,1,"option",22,Se),s()()(),a(26,"div",23)(27,"div",18)(28,"input",24,1),_("keyup",function(){return i.onKeyUpFirstName()}),Q("ngModelChange",function(c){return b(o),B(i.customer.FirstName,c)||(i.customer.FirstName=c),S(c)}),s(),h(31,Zl,2,3,"div",25),a(32,"label",26),d(33,"First Name"),s()()(),a(34,"div",23)(35,"div",18)(36,"input",27),Q("ngModelChange",function(c){return b(o),B(i.customer.LastName,c)||(i.customer.LastName=c),S(c)}),s(),a(37,"label",28),d(38,"Last Name"),s()()(),a(39,"div",29)(40,"div",18)(41,"input",30,2),Q("ngModelChange",function(c){return b(o),B(i.customer.Mobile,c)||(i.customer.Mobile=c),S(c)}),s(),h(43,tc,2,2),a(44,"label",31),d(45,"Mobile"),s()()(),a(46,"div",29)(47,"div",18)(48,"input",32,3),Q("ngModelChange",function(c){return b(o),B(i.customer.Email,c)||(i.customer.Email=c),S(c)}),s(),a(50,"label",33),d(51,"Email"),s(),h(52,oc,2,2),s()(),a(53,"div",29)(54,"div",18)(55,"datepicker",34,4),Q("ngModelChange",function(c){return b(o),B(i.customer.Birthdate,c)||(i.customer.Birthdate=c),S(c)}),s(),h(57,ac,1,1),s()(),a(58,"div",35)(59,"div",36)(60,"ng-select",37),Q("ngModelChange",function(c){return b(o),B(i.customer.Gender,c)||(i.customer.Gender=c),S(c)}),s(),a(61,"label",38),d(62,"Gender"),s()()()(),a(63,"div",39)(64,"div",40)(65,"div",41)(66,"input",42,5),Q("ngModelChange",function(c){return b(o),B(i.customer.Code,c)||(i.customer.Code=c),S(c)}),s(),h(68,sc,1,1,"i",43),h(69,lc,2,0,"div",44),a(70,"label",45),d(71,"Customer Code"),s()()(),a(72,"div",46)(73,"div",36)(74,"ng-select",47),Q("ngModelChange",function(c){return b(o),B(i.customer.Group,c)||(i.customer.Group=c),S(c)}),s(),a(75,"label",48),d(76,"Group"),s()()(),a(77,"div",40)(78,"div",36)(79,"ng-select",49),Q("ngModelChange",function(c){return b(o),B(i.customer.City,c)||(i.customer.City=c),S(c)}),s(),a(80,"label",50),d(81,"City"),s()()(),a(82,"div",51)(83,"div",18)(84,"textarea",52,6),Q("ngModelChange",function(c){return b(o),B(i.customer.Address,c)||(i.customer.Address=c),S(c)}),s(),a(86,"label",53),d(87,"Address"),s(),h(88,cc,2,0,"div",44),s()()(),a(89,"div",54)(90,"div",55)(91,"div",18)(92,"input",56,7),Q("ngModelChange",function(c){return b(o),B(i.customer.NationalIDNumber,c)||(i.customer.NationalIDNumber=c),S(c)}),s(),h(94,dc,2,1,"div",44),a(95,"label",57),d(96,"National ID"),s()()(),a(97,"div",55)(98,"div",18)(99,"input",58),Q("ngModelChange",function(c){return b(o),B(i.customer.TaxIDNumber,c)||(i.customer.TaxIDNumber=c),S(c)}),s(),a(100,"label",59),d(101,"Tax ID"),s()()(),a(102,"div",35)(103,"div",36)(104,"ng-select",60),Q("ngModelChange",function(c){return b(o),B(i.customer.NationalityID,c)||(i.customer.NationalityID=c),S(c)}),s(),a(105,"label",61),d(106,"Nationality"),s()()(),a(107,"div",29)(108,"div",36)(109,"ng-select",62),Q("ngModelChange",function(c){return b(o),B(i.customer.RaceID,c)||(i.customer.RaceID=c),S(c)}),s(),a(110,"label",63),d(111,"Customer Racesas"),s()()(),a(112,"div",35)(113,"div",36)(114,"ng-select",64,8),Q("ngModelChange",function(c){return b(o),B(i.customer.CreatorEntityID,c)||(i.customer.CreatorEntityID=c),S(c)}),s(),a(116,"label",65),d(117,"Sign Up Outlet"),s(),h(118,mc,2,0,"div",66),s()()()()()()()()}if(e&2){let o=Ce(30),r=Ce(42),c=Ce(49),g=Ce(56),x=Ce(67),V=Ce(85),q=Ce(93),Oe=Ce(115);m("config",i.modalConfig),l(7),m("ngClass",We(63,Ln,i.tabState=="general",i.tabState!="general"&&i.isGeneralFormInvalid)),l(2),C(i.tabState!="general"&&i.isGeneralFormInvalid?9:-1),l(),m("ngClass",We(66,Ln,i.tabState=="detail",i.tabState!="detail"&&i.isDetailFormInvalid)),l(2),C(i.tabState!="detail"&&i.isDetailFormInvalid?12:-1),l(),m("ngClass",We(69,Ln,i.tabState=="id",i.tabState!="id"&&i.isIdFormInvalid)),l(2),C(i.tabState!="id"&&i.isIdFormInvalid?15:-1),l(2),m("hidden",i.tabState!="general"),l(3),j("ngModel",i.customer.Title),l(4),K(i.options==null?null:i.options.Titles),l(4),m("ngClass",k(72,ht,o.touched&&o.invalid)),j("ngModel",i.customer.FirstName),m("required",!0),l(3),C(o.touched&&o.invalid?31:-1),l(5),j("ngModel",i.customer.LastName),l(5),m("ngClass",k(74,ht,r.invalid&&(r.dirty||r.touched))),j("ngModel",i.customer.Mobile),m("required",i.fieldRequiredConfig.Mobile),l(2),C(r.invalid&&(r.dirty||r.touched)?43:-1),l(5),m("ngClass",k(76,ht,c.invalid&&(c.dirty||c.touched))),j("ngModel",i.customer.Email),m("required",i.fieldRequiredConfig.Email),l(4),C(c.invalid&&(c.dirty||c.touched)?52:-1),l(3),j("ngModel",i.customer.Birthdate),m("required",i.fieldRequiredConfig.Birthdate)("ngClass",k(78,ht,g.invalid&&(g.dirty||g.touched))),l(2),C(g.invalid&&(g.dirty||g.touched)?57:-1),l(2),m("ngClass",k(80,Jt,i.isNotEmpty(i.customer.Gender))),l(),j("ngModel",i.customer.Gender),m("items",i.options==null?null:i.options.Genders),l(3),m("hidden",i.tabState!="detail"),l(3),m("ngClass",k(82,ht,x.invalid&&(x.dirty||x.touched))),j("ngModel",i.customer.Code),m("required",i.fieldRequiredConfig.Code),l(2),C(i.estimatedCodeMessage?68:-1),l(),C(x.invalid&&(x.dirty||x.touched)?69:-1),l(4),m("ngClass",k(84,Jt,i.isNotEmpty(i.customer.Group))),l(),j("ngModel",i.customer.Group),m("items",i.options==null?null:i.options.Groups),l(4),m("ngClass",k(86,Jt,i.isNotEmpty(i.customer.City))),l(),j("ngModel",i.customer.City),m("items",i.options==null?null:i.options.Cities),l(5),m("rows",6)("ngClass",k(88,ht,V.invalid&&(V.dirty||V.touched))),j("ngModel",i.customer.Address),m("required",i.fieldRequiredConfig.Address),l(4),C(V.invalid&&(V.dirty||V.touched)?88:-1),l(),m("hidden",i.tabState!="id"),l(3),j("ngModel",i.customer.NationalIDNumber),m("ngClass",k(90,ht,q.invalid&&(q.dirty||q.touched))),l(2),C(q.getError("minLength")?94:-1),l(5),j("ngModel",i.customer.TaxIDNumber),l(4),m("ngClass",k(92,Jt,i.isNotEmpty(i.customer.NationalityID))),l(),j("ngModel",i.customer.NationalityID),m("items",i.options==null?null:i.options.Nationalities),l(4),m("ngClass",k(94,Jt,i.isNotEmpty(i.customer.RaceID))),l(),j("ngModel",i.customer.RaceID),m("items",i.options==null?null:i.options.Races),l(4),m("ngClass",k(96,Jt,i.isNotEmpty(i.customer.CreatorEntityID))),l(),j("ngModel",i.customer.CreatorEntityID),m("items",i.outlets())("required",i.fieldRequiredConfig.SignUpOutlet)("ngClass",k(98,ht,Oe.invalid&&(Oe.dirty||Oe.touched))),l(4),C(Oe.invalid&&(Oe.dirty||Oe.touched)?118:-1)}},dependencies:[Ee,po,go,fo,ve,ge,lo,ho,Co,Me,mo,co,ie,wt,Si,Di,zo],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 Pn=class n{constructor(t,e,i){this.data=t;this.dialogRef=e;this.salesOrderService=i;this.initModalConfig();let o=u.cloneObject(i.Data);this.orderNumber=o.Order.Number}config;orderNumber;initModalConfig(){this.config=new Y,this.config.hideClose=!0,this.config.title="Edit Number"}onOk(){this.updateSalesOrderNumber(),this.dialogRef.close()}updateSalesOrderNumber(){let t=this.salesOrderService.Data;t.Order.Number=this.orderNumber,this.salesOrderService.pushNewValue(t)}onClose(){this.dialogRef.close()}static \u0275fac=function(e){return new(e||n)(M(pe),M(Z),M(H))};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(e,i){e&1&&(a(0,"modal-material",0),_("onOk",function(){return i.onOk()})("onCancel",function(){return i.onClose()})("onClose",function(){return i.onClose()}),a(1,"content")(2,"div",1)(3,"input",2),Q("ngModelChange",function(r){return B(i.orderNumber,r)||(i.orderNumber=r),r}),s(),a(4,"label",3),d(5,"Order Number"),s()()()()),e&2&&(m("config",i.config),l(3),j("ngModel",i.orderNumber))},dependencies:[ve,ge,Me,ie],encapsulation:2})};var On=class n{constructor(t,e){this.data=t;this.dialogRef=e;this.modalConfig=new Y,this.modalConfig.title=t.title,this.modalConfig.headerType=t.headerType,this.modalConfig.hideFooter=!0}modalConfig;onClose(t){this.dialogRef.close(t)}static \u0275fac=function(e){return new(e||n)(M(pe),M(Z))};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(e,i){e&1&&(a(0,"modal-material",0),_("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. "),y(6,"br"),d(7," Do you want to input customer data? "),s(),a(8,"div",3)(9,"button",4),_("click",function(){return i.onClose("yes")}),d(10,"Yes"),s(),a(11,"button",5),_("click",function(){return i.onClose("no")}),d(12,"No"),s()()()()()()),e&2&&m("config",i.modalConfig)},dependencies:[me,ie],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}"]})};function pc(n,t){if(n&1&&(a(0,"tr")(1,"td"),d(2),s(),a(3,"td",7),d(4),v(5,"number"),s(),a(6,"td",7),d(7),v(8,"number"),s()()),n&2){let e=t.$implicit;l(2),P(e==null||e.Variant==null?null:e.Variant.Name),l(2),P(D(5,3,e.Price)),l(3),P(D(8,5,e.PriceMinimum))}}var Mn=class n{modalConfig=new Y;data=O(pe);items=T(this.data.items);dialogRef=O(Z);constructor(){this.modalConfig.title="Price Minimum Warning",this.modalConfig.headerType=de.Warning,this.modalConfig.customWidth="600px",this.modalConfig.bodyScrollable=!0,this.modalConfig.hideOk=!0,this.modalConfig.cancelText="Close"}onClose(){this.dialogRef.close()}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=N({type:n,selectors:[["app-modal-price-minum-warning"]],decls:17,vars:1,consts:[[3,"onOk","onCancel","onClose","config"],[1,"container-fluid"],[1,"row"],[1,"col-12"],["id","tableGrid",1,"table","table-bordered"],[1,"thead-light"],[1,"text-end",2,"width","100px"],[1,"text-end"]],template:function(e,i){e&1&&(a(0,"modal-material",0),_("onOk",function(){return i.onClose()})("onCancel",function(){return i.onClose()})("onClose",function(){return i.onClose()}),a(1,"content")(2,"div",1)(3,"div",2)(4,"div",3)(5,"table",4)(6,"thead",5)(7,"tr")(8,"th"),d(9,"Product"),s(),a(10,"th",6),d(11,"Price"),s(),a(12,"th",6),d(13,"Minimum"),s()()(),a(14,"tbody"),z(15,pc,9,7,"tr",null,Le),s()()()()()()()),e&2&&(m("config",i.modalConfig),l(15),K(i.items()))},dependencies:[me,lt,ie,G],encapsulation:2})};var Dn=class n{constructor(t,e,i,o,r,c,g,x,V,q,Oe,ci){this.salesOrderService=t;this.toastrService=e;this.pageInitialService=i;this.orderProcessorService=o;this.dialog=r;this.onlineStatusService=c;this.promotionEventService=g;this.outletService=x;this.invoiceCalculatorService=V;this.userRole=q;this.sf=Oe;this.shoppingCartService=ci;this.initSubscribeObservable()}appConfig;salesOrder;isOnline;localDataService=O(De);initSubscribeObservable(){this.salesOrderService.Data$.subscribe(t=>{this.salesOrder=t}),this.pageInitialService.Data$.subscribe(t=>{this.appConfig=t.AppConfigJSON}),this.onlineStatusService.getOnlineStatus$().subscribe(t=>{this.isOnline=t})}payOrder(){if(this.isCartNotEmpty()&&this.validateEmptyOrderNumber()&&this.validateNegativePayment()&&this.isSalesPersonValid()&&this.isCustomerRequired()&&this.validateCustomerID()&&this.validatePromotionDiscount()&&this.validateSelectedRegister()&&this.priceMinimumValidation()&&this.validateEligiblePromotionEvent())if(this.validateDeliveryEntityID(),this.appConfig.ModuleSell.Header.CustomerNotAssignedReminder&&u.IsEmpty(this.salesOrder.Order.CustomerID)){this.dialog.open(On,{id:"ModalInfo",data:{title:"Customer Assign Reminder",headerType:de.Warning},width:"31rem"}).afterClosed().pipe(ce(t=>{t=="yes"?this.sf.searchFilterNativeEl.focus():t=="no"&&this.onOpenPaymentModal()})).subscribe();return}else this.onOpenPaymentModal()}priceMinimumValidation(){let t=!0,i=this.salesOrder.CartItems.filter(o=>!this.shoppingCartService.checkPriceMinimumRestriction(o));return i=i.map(o=>(o.PriceMinimum=this.shoppingCartService.getPriceMinimum(o),o)),t=i.length==0,t==!1&&this.dialog.open(Mn,{data:{items:i}}),t}validateDeliveryEntityID(){let t=this.salesOrder.Order.DeliveryStateID===3,e=u.IsEmpty(this.salesOrder.Action.DeliveryEntityID);t&&e&&(this.salesOrder.Action.DeliveryEntityID=this.salesOrder.Order.EntityID,this.toastrService.info("Fulfillment is SENT but Fulfillment Outlet is not specified, we automatically assign Fulfillment Outlet == Order.Outlet","Info"))}validateEligiblePromotionEvent(){let t=this.appConfig.ModuleSell?.Promotion?.PromotionEventReminderVisible,i=this.outletService?.Data?.Promotion?.filter(x=>x.Eligible),o=this.promotionEventService.selectedPromotion,c=this.salesOrderService.Data?.getRewards()?.length>0,g=!0;if(t&&i?.length>0&&u.IsEmpty(o)&&!c){let x=this.dialog.getDialogById("promotion-event");u.IsEmpty(x)&&this.dialog.open(li,{id:"promotion-event",data:{showSkipButton:!0,showRefreshButton:!1}}).afterClosed().subscribe(V=>{V?.skipped&&this.onOpenPaymentModal()}),g=!1}return g}validateSelectedRegister(){let t=this.pageInitialService?.Data?.Registers,e=this.salesOrder?.Order?.RegisterID;return u.IsEmpty(e)?(this.toastrService.warning("No register selected","Warning!"),!1):t?.some(o=>o.ID==e)?!0:(this.toastrService.warning("No register selected","Warning!"),!1)}validateNegativePayment(){let t=!0,e=this.invoiceCalculatorService.Data;return this.appConfig.ModuleSell.PaymentDialog.MinusPaymentAllowed==!1&&e<0&&(t=!1,this.toastrService.warning("You are not allowed to process this transaction because the total amount is less than zero","Warning!")),t}validateEmptyOrderNumber(){return u.IsEmpty(this.salesOrder.Order.Number)?(this.toastrService.warning(ae.emptyOrderNumber,"Warning!"),this.openModalEditOrderNumber(),!1):!0}openModalEditOrderNumber(){this.userRole.Data.NumberEditor&&this.dialog.open(Pn,{width:"20%"})}isCartNotEmpty(){return this.salesOrderService.Data.CartItems.length<1?(this.toastrService.warning(ae.emptyPOItem,"Warning!"),!1):!0}isSalesPersonValid(){let t=this.pageInitialService.Data.AppConfigJSON,e=this.salesOrderService.Data;if(t.ModuleSell.Header.SalesPersonRequired){if(this.salesOrder.CartItems.every(i=>u.IsNotEmpty(i.SalesID)))return!0;if(e.Order.SalesID==u.GuidEmpty||e.Order.SalesID==null)return this.toastrService.warning(ae.emptySalesPerson,"Warning!"),!1}return!0}validateCustomerID(){let t=this.salesOrderService.Data.Order.CustomerID;if(u.IsEmpty(t)){let e=this.orderProcessorService.Data.InputTextValue;if(u.IsNotEmpty(e)){this.toastrService.warning("Customer is not Saved","Warning");let i=this.userRole?.Data?.ContactsCreate;if(this.appConfig?.ModuleSell?.Customer?.QuickAddEnabled&&i)return this.openCustomerModal(e),!1}}return!0}isCustomerRequired(){let t=this.appConfig.ModuleSell.Header.CustomerRequired,e=this.salesOrder.Order.CustomerID;return t&&this.isOnline&&u.IsEmpty(e)?(this.toastrService.warning(ae.emptyCustomer,"Warning!"),!1):!0}openCustomerModal(t){this.dialog.open(Sn,{data:{name:t},autoFocus:!1}).afterClosed().subscribe(e=>{e&&this.onOpenPaymentModal()})}validatePromotionDiscount(){let e=(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&&e&&(o?o.TypeID!=3&&(r=!1):r=!1),r==!1&&(this.dialog.open(li,{id:"promotion-event"}),this.toastrService.warning("You need to apply Discount promotion","Required Promotion")),r}onOpenPaymentModal(){this.localDataService.unsentOrders$.pipe(Ue(1),te(t=>t.length>0&&this.isOnline?this.offlineModal():this.paymentModal())).subscribe()}paymentModal(){return this.dialog.open(bn,{id:"ModalPayment",disableClose:!0}).afterClosed()}offlineModal(){return this.dialog.open(pn,{disableClose:!0,id:"ModalOfflineOrder",data:{activeTab:"ORDER"}}).afterClosed()}static \u0275fac=function(e){return new(e||n)(f(H),f(L),f(X),f(je),f(ye),f(be),f(ke),f(se),f(le),f(Ne),f(Yo),f(ut))};static \u0275prov=w({token:n,factory:n.\u0275fac})};var ur=class n{static \u0275fac=function(e){return new(e||n)};static \u0275mod=Ci({type:n});static \u0275inj=hi({providers:[Dn],imports:[me,Vo,wi,lt,Pi,Ro,Ho,Po,Mo,jo,Wo,on,Go,zt,Qo,Mi,zt]})};export{$ as a,Hi as b,ki as c,Vt as d,H as e,X as f,Ft as g,Vi as h,Fi as i,Bi as j,se as k,ji as l,mt as m,le as n,Qt as o,Ut as p,Gi as q,ut as r,ke as s,en as t,Pe as u,tn as v,gt as w,nn as x,Gt as y,je as z,sr as A,on as B,$t as C,qt as D,an as E,ft as F,Cn as G,vn as H,li as I,Sn as J,Pn as K,pn as L,Dn as M,ur as N};