dealpos 26.28.1 → 26.28.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/browser/{chunk-R5TR4QVA.js → chunk-2GO57ZFO.js} +4 -4
  2. package/browser/{chunk-PORO4RUV.js → chunk-34Z4FOCK.js} +1 -1
  3. package/browser/{chunk-EWRXBE3I.js → chunk-3B2DOKSF.js} +1 -1
  4. package/browser/{chunk-JYIHX4AQ.js → chunk-3NDCJ7IG.js} +1 -1
  5. package/browser/{chunk-X44ZWGRG.js → chunk-3OFOONKN.js} +1 -1
  6. package/browser/{chunk-G2WIR7CS.js → chunk-3T4XDPD6.js} +1 -1
  7. package/browser/{chunk-3JJUFLJM.js → chunk-4CV2PN64.js} +8 -8
  8. package/browser/{chunk-KC5WGF2P.js → chunk-4CXI2MSW.js} +1 -1
  9. package/browser/{chunk-MNNM6IOI.js → chunk-4RKSLDVD.js} +1 -1
  10. package/browser/{chunk-RH5QBEME.js → chunk-4UFFIUCD.js} +1 -1
  11. package/browser/{chunk-ZPAT4WUM.js → chunk-5J334O5P.js} +1 -1
  12. package/browser/{chunk-CWT5ZMB7.js → chunk-5MG2NRXP.js} +1 -1
  13. package/browser/{chunk-CBGA6I7A.js → chunk-5PYNSYG5.js} +1 -1
  14. package/browser/{chunk-LZVFVGHO.js → chunk-6AXHUFLO.js} +2 -2
  15. package/browser/{chunk-ERTXBVY4.js → chunk-6KZNNVDQ.js} +1 -1
  16. package/browser/{chunk-5OC7EMM6.js → chunk-6TH3LZN5.js} +1 -1
  17. package/browser/{chunk-IH6MKS5E.js → chunk-73PREEIG.js} +1 -1
  18. package/browser/{chunk-RE3NBLIJ.js → chunk-7DZLZBYK.js} +1 -1
  19. package/browser/{chunk-JAAW3FBF.js → chunk-7FK4MRYP.js} +1 -1
  20. package/browser/{chunk-LANQ6YUO.js → chunk-7HWW5HHI.js} +1 -1
  21. package/browser/{chunk-FTCHDS57.js → chunk-7KUD2LTF.js} +2 -2
  22. package/browser/{chunk-UVSDRJK7.js → chunk-7OKGB4ZG.js} +1 -1
  23. package/browser/{chunk-3FRSVJJ7.js → chunk-AM4B4GSB.js} +2 -2
  24. package/browser/{chunk-RTNM34UG.js → chunk-B6DKOD32.js} +1 -1
  25. package/browser/{chunk-ADHPMALJ.js → chunk-BEQVAUO2.js} +2 -2
  26. package/browser/{chunk-IGKVJG7A.js → chunk-BGKTICFT.js} +1 -1
  27. package/browser/{chunk-6RNDU62J.js → chunk-C4JBYSA5.js} +1 -1
  28. package/browser/{chunk-FE2QSG4D.js → chunk-CJZJBLHF.js} +4 -4
  29. package/browser/{chunk-CWAWIUWN.js → chunk-CVWVAUPE.js} +1 -1
  30. package/browser/{chunk-D7653MEY.js → chunk-DD4F55YZ.js} +1 -1
  31. package/browser/{chunk-6AGOAMVL.js → chunk-DEK5AZSB.js} +1 -1
  32. package/browser/{chunk-IEDC4XOD.js → chunk-DK5ABAZB.js} +1 -1
  33. package/browser/{chunk-3BL7CUTN.js → chunk-DRQUTH2O.js} +1 -1
  34. package/browser/{chunk-QCKULX4E.js → chunk-DVEKZYQR.js} +1 -1
  35. package/browser/{chunk-SKGL4FZS.js → chunk-E5DIZQCI.js} +1 -1
  36. package/browser/{chunk-UM3P65CR.js → chunk-E7LCO5UK.js} +1 -1
  37. package/browser/{chunk-DBEN6KKV.js → chunk-EKMNY2BG.js} +1 -1
  38. package/browser/{chunk-FUGRAGUR.js → chunk-EO5X3R3T.js} +7 -7
  39. package/browser/{chunk-HXB2MZXO.js → chunk-EUQSCMV3.js} +3 -3
  40. package/browser/{chunk-TRHQ4FSE.js → chunk-F6PRCCED.js} +4 -4
  41. package/browser/{chunk-MNEHXZNC.js → chunk-FGBVNJY4.js} +1 -1
  42. package/browser/{chunk-RFKPCS4S.js → chunk-FGZW6FMH.js} +1 -1
  43. package/browser/{chunk-WOYUNUGJ.js → chunk-FMXCM3TT.js} +1 -1
  44. package/browser/{chunk-GEXHG4TA.js → chunk-FNQZZ5XA.js} +1 -1
  45. package/browser/{chunk-SVACMPDM.js → chunk-FPOUNLBB.js} +1 -1
  46. package/browser/{chunk-XCCYKZ5U.js → chunk-GGILTIJ3.js} +1 -1
  47. package/browser/{chunk-5YS5VY7A.js → chunk-GSA5HQVF.js} +1 -1
  48. package/browser/{chunk-3AA3DHH7.js → chunk-GSO64ETI.js} +1 -1
  49. package/browser/{chunk-VJORBDSM.js → chunk-GUUIOZFF.js} +12 -12
  50. package/browser/{chunk-UQZHWFMW.js → chunk-H5H65SMS.js} +1 -1
  51. package/browser/{chunk-V4GFMYOL.js → chunk-I4YKTEID.js} +1 -1
  52. package/browser/{chunk-SQ52KMEN.js → chunk-IALZBSAM.js} +1 -1
  53. package/browser/{chunk-EOPSQQQW.js → chunk-JPDHRLXU.js} +2 -2
  54. package/browser/{chunk-3I5Z7ZH4.js → chunk-KVCXTXZ7.js} +1 -1
  55. package/browser/{chunk-TR4OQR6N.js → chunk-KZJC6TNE.js} +1 -1
  56. package/browser/{chunk-YP7FNCN4.js → chunk-LBBZUW47.js} +1 -1
  57. package/browser/{chunk-P37LRPAP.js → chunk-LC2I6TZM.js} +1 -1
  58. package/browser/{chunk-M6GCTCNF.js → chunk-LFVY5RNR.js} +1 -1
  59. package/browser/{chunk-T4G2GDOZ.js → chunk-LRBIJIKU.js} +1 -1
  60. package/browser/{chunk-2I5UUMDJ.js → chunk-MGDCCCPS.js} +1 -1
  61. package/browser/{chunk-WHF4RFVG.js → chunk-MODSMDR6.js} +2 -2
  62. package/browser/chunk-NISWOUWO.js +1 -0
  63. package/browser/{chunk-FXOYVOVN.js → chunk-NVXDRBTS.js} +1 -1
  64. package/browser/{chunk-ICUWWFKN.js → chunk-O3NVMGWX.js} +1 -1
  65. package/browser/{chunk-J3AUT7P7.js → chunk-OKGJXGDP.js} +1 -1
  66. package/browser/{chunk-POCPZAKF.js → chunk-PNXMB7OY.js} +1 -1
  67. package/browser/{chunk-L3PP32LV.js → chunk-PUOXPE2D.js} +1 -1
  68. package/browser/chunk-PXMHU3QB.js +1 -0
  69. package/browser/{chunk-HQ6FN675.js → chunk-QHY3VMLN.js} +1 -1
  70. package/browser/{chunk-RTVRQ26X.js → chunk-QJJ7LEGD.js} +1 -1
  71. package/browser/{chunk-46Y4TGIE.js → chunk-QLQCTQY4.js} +1 -1
  72. package/browser/{chunk-67AH74YH.js → chunk-QQXRWE5M.js} +4 -4
  73. package/browser/{chunk-QZ3FFFFG.js → chunk-R2MVBKL2.js} +1 -1
  74. package/browser/{chunk-TV3MPMPX.js → chunk-R644XGAI.js} +1 -1
  75. package/browser/{chunk-LJQ6RWLC.js → chunk-RCGJWDJZ.js} +6 -6
  76. package/browser/{chunk-ALBKTU2C.js → chunk-RMWJBIUI.js} +1 -1
  77. package/browser/{chunk-A6IF36DS.js → chunk-ROBODF25.js} +1 -1
  78. package/browser/{chunk-IIAIW2LO.js → chunk-RSJPNTBK.js} +1 -1
  79. package/browser/{chunk-JEBZQVDC.js → chunk-RVMW2OTG.js} +1 -1
  80. package/browser/{chunk-XCFJ777N.js → chunk-RXPZNYC6.js} +1 -1
  81. package/browser/{chunk-TBLYWPU4.js → chunk-SCRDWTH5.js} +1 -1
  82. package/browser/{chunk-KS6RPDTZ.js → chunk-SGEXBJJV.js} +1 -1
  83. package/browser/{chunk-LILVQOBI.js → chunk-SVCYQXBG.js} +1 -1
  84. package/browser/{chunk-UBMJFCG5.js → chunk-SX3PN3Z4.js} +1 -1
  85. package/browser/{chunk-LBCCTXF2.js → chunk-TFJ3ZHT5.js} +1 -1
  86. package/browser/{chunk-XOGT4BRU.js → chunk-TZGU7QFO.js} +1 -1
  87. package/browser/{chunk-OTA7JWE7.js → chunk-VFFGVTI4.js} +1 -1
  88. package/browser/{chunk-IIWRQLLK.js → chunk-VYCYL6TZ.js} +1 -1
  89. package/browser/{chunk-C3BIKM3S.js → chunk-WKYUUF3A.js} +1 -1
  90. package/browser/{chunk-XON5IJ3T.js → chunk-WNLQSQ7L.js} +3 -3
  91. package/browser/{chunk-6DNXB4ZE.js → chunk-WVFPP6S6.js} +1 -1
  92. package/browser/chunk-X2NBBAC7.js +1 -0
  93. package/browser/{chunk-5PTIWA7U.js → chunk-X3RQXP4U.js} +1 -1
  94. package/browser/{chunk-I36KID5F.js → chunk-XHTGHTJR.js} +3 -3
  95. package/browser/{chunk-4J2ID2MU.js → chunk-XL7TON7D.js} +1 -1
  96. package/browser/{chunk-DBGV7UE7.js → chunk-XP2S4XAG.js} +1 -1
  97. package/browser/{chunk-RVCOS3S6.js → chunk-XTGTPLBH.js} +1 -1
  98. package/browser/{chunk-QLQ37H7W.js → chunk-Y2THOLNV.js} +1 -1
  99. package/browser/{chunk-FXPNQ2F7.js → chunk-YBXERY7Z.js} +1 -1
  100. package/browser/{chunk-GOIMBO6M.js → chunk-YT2PXPMR.js} +1 -1
  101. package/browser/{chunk-Z5ZUEWMA.js → chunk-YXG2OW6V.js} +1 -1
  102. package/browser/{chunk-ACTIKDRX.js → chunk-ZBXOGMEW.js} +1 -1
  103. package/browser/{chunk-JIWJJRGS.js → chunk-ZBZGM3JN.js} +1 -1
  104. package/browser/index.html +3 -3
  105. package/browser/{main-OBGKN3VT.js → main-HAYOCAP6.js} +1 -1
  106. package/package.json +1 -1
  107. package/browser/chunk-5TDNJSOY.js +0 -1
  108. package/browser/chunk-AE23N5CE.js +0 -1
  109. package/browser/chunk-GZPQS275.js +0 -1
  110. package/browser/chunk-JMWII6JS.js +0 -1
  111. package/browser/chunk-SVFZD5CX.js +0 -1
@@ -1,4 +1,4 @@
1
- import{a as Zn,b as eo}from"./chunk-PORO4RUV.js";import{a as oi}from"./chunk-LBXXGAZP.js";import{a as Zt}from"./chunk-FLCL42EG.js";import{a as ni}from"./chunk-EQ3P3ATJ.js";import{a as Xn}from"./chunk-JYIHX4AQ.js";import"./chunk-TDQF4LF7.js";import"./chunk-T5UW3VZA.js";import{a as An}from"./chunk-IEFU4ZWW.js";import{a as Qn}from"./chunk-GEXHG4TA.js";import{a as Ln,b as Wn,c as Jn,d as Hn,e as Gn,f as Qe}from"./chunk-3VSKC2C4.js";import{a as ei}from"./chunk-ICUWWFKN.js";import{a as jn}from"./chunk-RRHZOE3Y.js";import"./chunk-DVLNWQL2.js";import"./chunk-GHWVU235.js";import{a as Vt}from"./chunk-UYAE2KWZ.js";import{b as zn,c as Yn}from"./chunk-LILVQOBI.js";import"./chunk-JCUDUZIE.js";import"./chunk-NQX7EX5A.js";import{a as ii,b as qn,c as Kn}from"./chunk-IJDQTDWM.js";import"./chunk-P37LRPAP.js";import{b as $n}from"./chunk-W7M5YJPL.js";import{a as Vn,b as Rn,c as Bn}from"./chunk-RDCWSC4B.js";import{a as Kt}from"./chunk-X7RPL3PD.js";import"./chunk-P3KIIKY4.js";import"./chunk-RJIB64GS.js";import{a as ti}from"./chunk-CAYJHOZ3.js";import{a as Un}from"./chunk-UVAFCFHT.js";import"./chunk-BYXBJQAS.js";import"./chunk-VXKPVJSE.js";import{a as Ai}from"./chunk-LZAV46F7.js";import"./chunk-WOYUNUGJ.js";import"./chunk-DDLXGCOB.js";import"./chunk-6ZKW6NGS.js";import{e as wt}from"./chunk-A3XPLCMP.js";import"./chunk-22VMH5K4.js";import{p as kn}from"./chunk-VQQIQFUB.js";import"./chunk-HKSUQNKJ.js";import"./chunk-DLBX5RSU.js";import"./chunk-YHKX3K56.js";import"./chunk-O3LZKJY2.js";import"./chunk-WLNLF7ZT.js";import"./chunk-MPGXQK5L.js";import{a as Xt}from"./chunk-LZ4LJZAV.js";import"./chunk-IDHUYY2U.js";import{c as wn,d as Nn}from"./chunk-A75ZS57D.js";import"./chunk-HSGXXXIK.js";import{a as Sn}from"./chunk-6KJTU3AF.js";import"./chunk-TQ2YP2CL.js";import{c as hn}from"./chunk-LIMLIVTQ.js";import"./chunk-WYKVRUIW.js";import"./chunk-LVIGLDQ4.js";import{a as ft}from"./chunk-KR74ZZ6U.js";import"./chunk-FSAQ7W4Y.js";import"./chunk-DA33S43F.js";import{b as En,c as Fn}from"./chunk-BSOZMEUZ.js";import"./chunk-KLLRDRG7.js";import"./chunk-GFPR5PLO.js";import"./chunk-7K5H76G7.js";import"./chunk-BXQZZ4SS.js";import"./chunk-J7XZRRKK.js";import"./chunk-FOEAOA4G.js";import"./chunk-DZAEKVKZ.js";import{a as vn,d as _n,f as Dn,h as xn}from"./chunk-5OLVUC6J.js";import{a as Mn}from"./chunk-SQ52KMEN.js";import{a as yn}from"./chunk-5E52ZWKI.js";import{f as Tn}from"./chunk-3AA3DHH7.js";import"./chunk-Q6MS4QZ6.js";import"./chunk-GMF3SGSZ.js";import{k as bn,o as In,q as Pn,r as On}from"./chunk-5NWJYNJO.js";import"./chunk-36TOKQZQ.js";import"./chunk-XS4UTUMZ.js";import"./chunk-D3PKFTVO.js";import{a as it,b as nt}from"./chunk-V25UXFNL.js";import"./chunk-YNQPX5G6.js";import"./chunk-VAJAIBT3.js";import{a as mn,b as dn,c as pn}from"./chunk-DCS4THVW.js";import{d as Yt}from"./chunk-RBBEZN3D.js";import"./chunk-UBMJFCG5.js";import{a as Oe,b as ke,c as ie,h as zt}from"./chunk-R2YNXAPB.js";import{a as X,b as ki}from"./chunk-MMKYHF6F.js";import"./chunk-LJWHBKHI.js";import{a as Ue}from"./chunk-SY5NNN4M.js";import"./chunk-KYGIDMGO.js";import"./chunk-R2UNPOYE.js";import"./chunk-RXZDFS3M.js";import{a as be,b as Ie,c as Pe}from"./chunk-3UB7PEG5.js";import"./chunk-DVI52XSU.js";import"./chunk-6HNYSYBG.js";import"./chunk-WIUSOID5.js";import"./chunk-K7ICHNI3.js";import{D as gn,E as Fe,F as tt,a as Ze,b as un,c as Me,h as de,l as ge,o as Ee,r as fn,s as et}from"./chunk-POUQHZWU.js";import{a as Cn}from"./chunk-GZPQS275.js";import"./chunk-MNXZMQRB.js";import{b as Ce}from"./chunk-WYAHUX6O.js";import{a as I}from"./chunk-PTRS3UA6.js";import{a as cn}from"./chunk-D7653MEY.js";import{n as Le,q as pe}from"./chunk-D3E5UKKJ.js";import{$ as qi,$b as It,Aa as Ki,Ab as y,B as mt,Bb as a,C as A,Cb as r,Cc as u,Cd as ln,Da as Ei,Db as x,Dc as C,Eb as vt,Ec as pt,F as Wi,Fb as _t,G as ve,Gb as nn,Hb as jt,Ib as Lt,Ic as Wt,Jb as on,K as Ji,Ka as $t,Kd as sn,L as ht,Lc as Jt,Ma as dt,Mb as U,Md as Ht,Nd as Gt,O as Hi,Pb as D,Pd as qt,Qa as zi,Qb as Ut,Qc as N,R as Gi,Ra as l,Rb as d,Rc as ut,U as Ft,W as ae,Xa as Yi,Ya as g,Z as Ye,Zb as St,_ as Y,_a as Xi,_b as Mt,ab as V,bc as Pt,ca as k,d as De,dc as At,e as at,ea as fe,ec as m,f as ji,fb as Zi,fc as ee,fd as Xe,gb as kt,gc as E,ha as me,hc as $e,i as Re,jc as W,k as Li,ka as q,kc as Q,kd as an,l as Ke,la as G,lc as J,ld as Se,m as Ui,mc as rt,nc as Ot,nd as rn,o as Qi,oc as Tt,pa as O,pc as Fi,pd as ye,qa as T,r as p,s as xe,sd as te,t as Ni,tb as v,tc as je,ub as en,uc as Qt,vb as _,vc as le,w as bt,wb as tn,wc as lt,xb as Be,yb as we,za as se,zb as Ne}from"./chunk-M3O2GJ3M.js";import{a as P,b as B,e as $i,j as oe}from"./chunk-KMHZKFQS.js";var to=()=>({deliveryEntityID:I.GuidEmpty,fulfillmentDate:null,fulfillmentTime:null,fulfillmentDateTime:null});var z=class n{constructor(t,e){this.http=e;this.buyForm=t.group({NewOrderID:[""],Order:t.group({Att:[""],SupplierID:[""],Number:[""],Date:[new Date],ID:[I.GuidEmpty]}),Invoice:t.group({ID:[I.GuidEmpty],Due:[new Date],Tax:[0]}),Payment:t.group({ID:[I.GuidEmpty],Amount:[0],MethodID:[0],Code:[""],Note:[""],ImageUrl:[""]})})}outlet=new ge({ID:"",Name:"Choose an Outlet"});dueDays=new ge(0);fulfillmentResult=new ge(to());noteForm=new ge({Note:"",TagID:"",Currency:{ID:"",ExchangeRate:0,Symbol:""},InvoiceNumber:""});discountAndTaxForm=new ge({Discount:{Amount:0,Percentage:0},Tax:{ID:"",CalculationTypeName:"",Rate:0,Label:"",Discontinue:!1}});buyForm;setPONumber(t){let e="";if(t.Seed){let i=t.Seed+"";for(;i.length<t.Digit;)i="0"+i;e=I.StringFormat(t.Prefix,i)}this.buyForm.controls.Order.controls.Number.setValue(e)}setDueDateBasedOnDaysDue(t){console.log(t);let e=this.invoiceDate,i=new Date(I.cloneObject(e));i.setDate(i.getDate()+t),this.buyForm.controls.Invoice.controls.Due.setValue(i)}get dueDate(){return this.buyForm.controls.Invoice.controls.Due.value}get invoiceDate(){return this.buyForm.controls.Order.controls.Date.value}setAmount(t){this.buyForm.controls.Payment.controls.Amount.setValue(t)}setPaymentMethodID(t){this.buyForm.controls.Payment.controls.MethodID.setValue(t)}setTaxAmount(t){this.buyForm.controls.Invoice.controls.Tax.setValue(t)}setNewOrderID(t){this.buyForm.controls.NewOrderID.setValue(t)}setTax(t){let e=P({},this.discountAndTaxForm.value.Discount);this.discountAndTaxForm.setValue({Discount:e,Tax:t})}setCurrency(t){let e=this.noteForm.value;this.noteForm.setValue(B(P({},e),{Currency:t}))}setDeliveryEntityID(t){this.fulfillmentResult.setValue(B(P({},this.fulfillmentResult.value),{deliveryEntityID:t}))}setdueDays(t){this.dueDays.setValue(t)}setBulkOrderForm(t){this.buyForm.controls.Order.setValue(t)}setBulkNoteForm(t){this.noteForm.setValue(t)}setBulkDiscountAndTaxForm(t){this.discountAndTaxForm.setValue(t)}setOutletForm(t){this.outlet.setValue(t)}setBulkInvoice(t){this.buyForm.controls.Invoice.setValue(P(P({},this.buyForm.controls.Invoice.value),t))}setBulkPayment(t){this.buyForm.controls.Payment.setValue(t)}resetOutletForm(){this.outlet.setValue({ID:"",Name:"Choose an Outlet"})}resetFulfillmentDate(){this.fulfillmentResult.setValue(B(P({},this.fulfillmentResult.value),{fulfillmentDate:null,fulfillmentTime:null,fulfillmentDateTime:null}))}resetDueDaysForm(){this.dueDays.setValue(0)}resetNoteForm(){this.noteForm.setValue(B(P({},this.noteForm.value),{Note:"",TagID:"",InvoiceNumber:""}))}resetDiscountAndTaxForm(){let t=this.discountAndTaxForm.value;this.discountAndTaxForm.setValue(B(P({},t),{Discount:{Amount:0,Percentage:0}}))}resetBuyForm(){this.buyForm.reset(),this.buyForm.controls.Invoice.controls.ID.setValue(I.GuidEmpty),this.buyForm.controls.Invoice.controls.Due.setValue(new Date),this.buyForm.controls.Order.controls.Date.setValue(new Date),this.buyForm.controls.Order.controls.ID.setValue(I.GuidEmpty),this.generateNumberOnNewTransaction()}generateNumberOnNewTransaction(){this.http.post("/API/Buy/GenerateNumber",{ID:this.outlet.value.ID}).subscribe(t=>{this.buyForm.controls.Order.controls.Number.setValue(t.Number)})}static \u0275fac=function(e){return new(e||n)(q(gn),q(pe))};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};var ue=class n{entities$;appConfigJSON$;taxes$;currencies$;supplierPOTypes$;predefinedNotes$;denomination$;defaultDueDays$;constructor(t,e){let i=t.get("/API/Buy2/Load").pipe(k(o=>{e.setCurrency(o.Currencies.find(s=>s.ID==o.AppConfigJSON.CoreDefaults.CurrencyID)),e.setNewOrderID(o.NewOrderID)}),ae(1));this.denomination$=i.pipe(p(o=>o.Denomination)),this.entities$=i.pipe(p(o=>o.Entities)),this.appConfigJSON$=i.pipe(p(o=>o.AppConfigJSON)),this.taxes$=i.pipe(p(o=>o.Taxes),ae(1)),this.currencies$=i.pipe(p(o=>o.Currencies),ae(1)),this.supplierPOTypes$=i.pipe(p(o=>o.SupplierPOTypes)),this.predefinedNotes$=i.pipe(p(o=>o.PredefinedNotes)),this.defaultDueDays$=i.pipe(p(o=>o.AppConfigJSON.ModuleBuy.PaymentDialog.DefaultDueDays),k(o=>e.setdueDays(o)),k(o=>e.setDueDateBasedOnDaysDue(o)))}updateDueDays(){this.defaultDueDays$.subscribe()}static \u0275fac=function(e){return new(e||n)(q(pe),q(z))};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};var gt=class n extends Zn{connection;_Data=new ji(1);Data=this._Data.asObservable();httpService=G(pe);toastService=G(Le);_cache=new Map;previousCountByEpc={};_isConnected=new at(!1);isConnected=this._isConnected.asObservable();_bufferTime=new at(100);set bufferTime(t){this._bufferTime.next(t)}get bufferTime(){return this._bufferTime.getValue()}_baseUrl=se("https://localhost:5001/rfidhub");baseUrl=Jt(()=>this._baseUrl());intializeWebSocket(t="/"){return oe(this,null,function*(){if(t.length<=0){this.toastService.error("RFID URL cannot be empty",be.Error);return}if(!(this.connection&&this.connection.state===dn.Connected)){this.connection=new pn().withUrl(t).configureLogging(mn.Information).withAutomaticReconnect().build();try{yield this.connection.start(),yield this.initiateGroupSubscription(),this.onWebSocketMessageReceived(),this._isConnected.next(!0),this.toastService.success("RFID Connected",be.Success),this._baseUrl.set(t)}catch(e){throw this._isConnected.next(!1),this.toastService.error(JSON.stringify(e),be.Error),this._baseUrl.set(null),new Error(JSON.stringify(e))}}})}disconnectWebSocket(){this.connection&&(this.connection.stop(),this.connection=void 0,this._isConnected.next(!1),this._baseUrl.set(null),this.toastService.info("RFID Disconnected",be.Info))}initiateGroupSubscription(){return oe(this,null,function*(){try{yield this.connection.invoke("SubscribeGroup",{CurrentID:"Buy"})}catch(t){throw this.toastService.error(JSON.stringify(t),be.Error),new Error(JSON.stringify(t))}})}onWebSocketMessageReceived(){this.connection.on("ReceiveSignal",t=>{this._Data.next(t)})}getVariantByCode(t,e=I.GuidEmpty){let i=[{key:"Code",value:t},{key:"EntityID",value:e}];return this.httpService.get(Ue.GetVariantByCode,i).pipe(ve(o=>o instanceof ln?Ke(null):Ui(()=>new Error(o.message))))}processGroupedData(t=I.GuidEmpty){return this._Data.pipe(A(e=>e!==null&&e&&Object.keys(e).length>0),Wi(this._bufferTime.getValue()),Ni(e=>Li(e)),Gi(e=>e.epc),Ni(e=>e.pipe(Ft((i,o)=>[...i,o],[]),Y(i=>{let o=e.key;if(this._cache.has(o))return this._cache.get(o).pipe(p(s=>({epc:o,items:i,response:s})));{let s=this.getVariantByCode(o,t).pipe(A(F=>F),k(F=>this._cache.set(o,Ke(F))));return this._cache.set(o,s),s.pipe(p(F=>({epc:o,items:i,response:F})))}}))),Ft((e,i)=>{let o=this.previousCountByEpc&&this.previousCountByEpc[i.epc]||0,s=i.items.length,F=s-o;return e[i.epc]={data:i.items,count:F,variant:i.response},this.previousCountByEpc[i.epc]=s,e},{}),ae({bufferSize:1,refCount:!0}))}constructor(){super(),this.connection&&(this.connection.onclose=t=>oe(this,null,function*(){console.error("SignalR connection closed:",t)}),this.connection.onreconnecting=t=>oe(this,null,function*(){console.warn("SignalR reconnecting:",t)}),this.connection.onreconnected=t=>oe(this,null,function*(){console.log("SignalR reconnected:",t)}))}static \u0275fac=function(e){return new(e||n)};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};var Ct=class n{returnInvoiceNumber=new ge("");invoiceInfo$;constructor(t,e,i){let o=e.outlet.valueChanges.pipe(p(c=>c.ID),X());this.invoiceInfo$=this.returnInvoiceNumber.valueChanges.pipe(A(c=>!!c),fe(o),Y(([c,S])=>t.post("/API/Buy/GetSupplierInvoiceRetur2",{EntityID:S,Number:c}).pipe(ve(()=>Re))),ae(1),X());let s=this.invoiceInfo$.pipe(p(c=>P({},c.Order)),k(c=>{let S={Att:c.Att,SupplierID:{Key:c.SupplierID,Value:c.SupplierName,OnSet:!0},Date:new Date,Number:e.buyForm.controls.Order.controls.Number.value,ID:I.GuidEmpty};e.setBulkOrderForm(S)}),X()),F=this.invoiceInfo$.pipe(p(c=>c.Order),fe(i.currencies$,i.appConfigJSON$),k(([c,S,L])=>{let ne=L.CoreDefaults.CurrencyID,b=S.find($=>$.ID===ne)?.Symbol??"$",R={Note:`Return #${c.Number}`,TagID:c.TypeID,Currency:{ID:c.CurrencyID||ne,ExchangeRate:c.CurrencyRate,Symbol:c.CurrencySymbol||b},InvoiceNumber:c.Number};e.setBulkNoteForm(R)}),X()),f=this.invoiceInfo$.pipe(p(c=>c.Order),fe(i.taxes$),p(([c,S])=>B(P({},c),{Tax:S.find(L=>L.ID===c.TaxTypeID)})),k(c=>{let S={Discount:{Amount:c.DiscountAmount,Percentage:c.Discount},Tax:{ID:c.TaxTypeID,Rate:c.Tax?.Rate,CalculationTypeName:c.Tax?.CalculationTypeName,Label:c.Tax?.Label,Discontinue:!c.Tax?.Label}};e.setBulkDiscountAndTaxForm(S)}),X()),w=this.invoiceInfo$.pipe(p(c=>c.DeliveryEntityID),k(c=>e.setDeliveryEntityID(c)),X()),H=this.invoiceInfo$.pipe(p(c=>c.Invoice),k(c=>{let S={ID:c.ID,Tax:c.Tax};e.setBulkInvoice(S)}),X()),M=this.invoiceInfo$.pipe(p(c=>c.Payment),k(c=>{let S={ID:I.GuidEmpty,Amount:c.Amount,MethodID:c.MethodID,Note:c.Note,Code:c.Code,ImageUrl:c.ImageUrl};e.setBulkPayment(S)}),X());xe(s,F,f,w,H,M).pipe(X()).subscribe()}static \u0275fac=function(e){return new(e||n)(q(pe),q(z),q(ue))};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};var Z=class n{constructor(t,e,i,o){this.matDialog=o;let s=e.outlet.valueChanges.pipe(p(c=>c.ID));this.addVariantThroughSerial$=this._addVariantThroughSerial.asObservable().pipe(fe(s),Y(([c,S])=>t.get(Ue.GetVariantBySerial,[{key:"Serial",value:c},{key:"EntityID",value:S}]).pipe(ve(()=>Re))),p(c=>this.setUnitPrice(c)),p(c=>B(P({},c),{Quantity:1,Total:c.UnitPrice,VariantID:c.ID,InventoryTypeID:c.TypeID})),p(c=>({action:"addAsSerial",variant:c})));let F=this.variantAutocomplete.valueChanges.pipe(A(c=>I.IsNotEmpty(c)&&c.type=="Code"),p(c=>c.str),fe(s),A(([c,S])=>I.IsNotEmpty(S)),Y(([c,S])=>t.get(Ue.GetVariantByCode,[{key:"Code",value:c},{key:"EntityID",value:S},{key:"Promotion",value:!0}]).pipe(ve(()=>Re))),p(c=>this.setUnitPrice(c)),p(c=>B(P({},c),{Quantity:1,Total:c.UnitPrice*((100-c.PriceDiscount)/100),Discount:c.PriceDiscount,VariantID:c.ID,InventoryTypeID:c.TypeID}))),f=this.variantAutocomplete.valueChanges.pipe(A(c=>I.IsNotEmpty(c)&&c.type=="ID"),p(c=>c.str)),w=this.variantQuickKey.valueChanges,H=mt(f,w).pipe(fe(s),Y(([c,S])=>t.get(Ue.GetVariantByID,[{key:"ID",value:c},{key:"EntityID",value:S}]).pipe(ve(()=>Re))),p(c=>this.setUnitPrice(c)),p(c=>B(P({},c),{Quantity:1,Total:c.UnitPrice*((100-c.OrderPriceDiscount)/100),Discount:c.OrderPriceDiscount,VariantID:c.ID,InventoryTypeID:c.TypeID}))),M=mt(H,F).pipe(k(c=>{c.CategoryTypeID===1&&this.toastr.info(`${c.Name} is sellable only.`,be.Info)}),A(c=>c.CategoryTypeID!==1),p(c=>({action:"add",variant:c})),k(()=>{this.cartDisplayRef&&setTimeout(()=>{let c=this.cartDisplayRef.nativeElement.scrollHeight;this.cartDisplayRef.nativeElement.scrollTop=c},1)})),j=i.invoiceInfo$.pipe(k(c=>{this.isReturn.set(c.IsReturn)}),p(c=>({action:"returnInvoice",variants:c.Items.map(S=>B(P({},S.Variant),{Quantity:S.Quantity,Total:S.Total,UnitPrice:S.UnitPrice,Discount:S.Discount,Serial:S.Serial,ID:S.ID,DiscountAmount:S.DiscountAmount,VariantID:S.VariantID,UnitQuantity:S.UnitQuantity}))})));this.cart$=mt(M,j,this.deleteVariant$,this.dragDropCart$,this.returnCart$,this.updateVariant$,this.returnVariant$,this.purchaseVariant$,this.clearCart$,this.onEditForm$,this.addVariantThroughSerial$,this.addVariant$,this.onUploadCart$,this.listenRFID$).pipe(Ft((c,S)=>{let L=[...c],ne=[],h=S.action;if(h=="add"){let b=S.variant;ne=!!L.find($=>$.VariantID==b.ID)?L.map($=>$.VariantID==b.ID?B(P({},$),{Quantity:$.Quantity+1,Total:$.Total+$.UnitPrice}):$):[...L,b]}else if(h=="returnInvoice"||h=="onEditForm")ne=S.variants;else if(h=="delete"){let b=S.index;ne=L.filter((R,$)=>$!=b)}else if(h=="sort"){let b=S.ev;ne=L,vn(ne,b.previousIndex,b.currentIndex)}else if(h=="returnCart")ne=L.map(b=>B(P({},b),{Quantity:-Math.abs(b.Quantity),Total:-Math.abs(b.Total)}));else if(h=="update"){let b=S.index;ne=L.map((R,$)=>$==b?S.variant:R)}else if(h=="returnVariant"){let b=S.index;ne=L.map((R,$)=>$==b?B(P({},R),{Quantity:-Math.abs(R.Quantity),Total:-Math.abs(R.Total)}):R)}else if(h=="purchaseVariant"){let b=S.index;ne=L.map((R,$)=>$==b?B(P({},R),{Quantity:Math.abs(R.Quantity),Total:Math.abs(R.Total)}):R)}else if(h=="clearCart")ne=[];else if(h=="addAsSerial"){let b=B(P({},S.variant),{Serial:[{Number:S.variant.Serial.Number,Quantity:1,ExpiryDate:S.variant.Serial.ExpiryDate}]});if(!!L.find($=>$.ID==b.ID)){let $=b.Serial[0],Te=L.find(re=>re.ID==b.ID),_e=!!Te.Serial.find(re=>re.Number==$.Number)?[...Te.Serial].map(re=>re.Number==$.Number?B(P({},re),{Quantity:re.Quantity+1}):re):[...Te.Serial,$];ne=L.map(re=>re.ID==b.ID?B(P({},re),{Quantity:re.Quantity+1,Total:re.Total+re.UnitPrice,Serial:_e}):re)}else ne=[...L,B(P({},b),{Quantity:1,Total:b.UnitPrice})]}else if(h=="uploadCart")ne=[...L,...S.variants];else if(h=="addNewRow"){let b=S.variant;ne=[...L,b]}else if(h=="rfid"){let b=S.variants;Object.keys(b).forEach(R=>{if(b.hasOwnProperty(R)){let $=b[R];if($&&Object.keys($.variant).length>0){let Te=L.findIndex(Ve=>Ve.Code.toLowerCase()===R.toLowerCase());if(Te!==-1){let Ve=Number($.count);L[Te].Quantity+=Ve,L[Te].Total=+L[Te].UnitPrice*+L[Te].Quantity,delete b[R],ne=[...L]}else{let Ve=$.variant,_e=Number($.count),re=this.setUnitPrice(Ve),ct=this.formatItemObject(B(P({},re),{Quantity:_e,Total:+re.UnitPrice*+_e}));delete b[R],ne=[...L,ct]}}}})}return ne},[]),Ye([]),ae(1)),this.totalVariantOrdered$=this.cart$.pipe(p(c=>c.map(S=>S.Quantity)),p(c=>c.reduce((S,L)=>S+L,0)),Ye(0))}toastr=G(Le);roleService=G(Ce);decimalPipe=G(ye);cartDisplayRef;variantAutocomplete=new ge;variantQuickKey=new ge;priceMaximumRestrictionWarning=se("");_listenRFID=new De;listenRFID$=this._listenRFID.asObservable().pipe(p(t=>({action:"rfid",variants:t})));_deleteVariant=new De;deleteVariant$=this._deleteVariant.asObservable().pipe(p(t=>({action:"delete",index:t})));_dragDropCart=new De;dragDropCart$=this._dragDropCart.asObservable().pipe(p(t=>({action:"sort",ev:t})));_returnCart=new De;returnCart$=this._returnCart.asObservable().pipe(p(()=>({action:"returnCart"})));_onEditForm=new at(null);onEditForm$=this._onEditForm.asObservable().pipe(A(t=>!!t),p(t=>({action:"onEditForm",variants:t})));_clearCart=new De;clearCart$=this._clearCart.asObservable().pipe(p(()=>({action:"clearCart"})));_updateVariant=new De;updateVariant$=this._updateVariant.asObservable().pipe(p(t=>({action:"update",variant:t.variant,index:t.index})));_returnVariant=new De;returnVariant$=this._returnVariant.asObservable().pipe(p(t=>({action:"returnVariant",index:t})));_purchaseVariant=new De;purchaseVariant$=this._purchaseVariant.asObservable().pipe(p(t=>({action:"purchaseVariant",index:t})));_addVariant=new De;addVariant$=this._addVariant.asObservable().pipe(p(t=>({action:"addNewRow",variant:t})));_onUploadCart=new De;onUploadCart$=this._onUploadCart.asObservable().pipe(p(t=>({action:"uploadCart",variants:t})));cart$;totalVariantOrdered$;isReturn=se(!1);_addVariantThroughSerial=new De;addVariantThroughSerial$;deleteVariant(t){this._deleteVariant.next(t)}dragDropCart(t){this._dragDropCart.next(t)}returnCart(){this._returnCart.next()}updateVariant(t,e){this._updateVariant.next({variant:t,index:e})}returnVariant(t){this._returnVariant.next(t)}purchaseVariant(t){this._purchaseVariant.next(t)}clearCart(){this._clearCart.next()}editForm(t){this._onEditForm.next(t)}addVariant(t){this._addVariant.next(t)}addVariantThroughSerial(t){this._addVariantThroughSerial.next(t)}uploadCart(t){this._onUploadCart.next(t)}setUnitPrice(t){let e=P({},t);return I.IsNotEmpty(t.OrderPrice)?e.UnitPrice=t.OrderPrice:e.UnitPrice=t.UnitCost,e}formatItemObject=t=>{let o=t,{ID:e}=o,i=$i(o,["ID"]);return B(P({},i),{Quantity:i.Quantity??1,Total:i.Total??i.UnitPrice,VariantID:e})};addCartRFID(t){this._listenRFID.next(t)}validatePriceMaximum(t){let e=!0;if(this.roleService.buyRestriction.CostMax&&t.MaxOrderPrice>0)if(t.UnitPrice>t.MaxOrderPrice){e=!1;let o=I.StringFormat("<span><i class='fa-solid fa-triangle-exclamation me-2 d-inline'></i>Cannot buy more than <h5 class='d-inline m-0'>{0}</h5></span>",this.decimalPipe.transform(t.MaxOrderPrice));this.priceMaximumRestrictionWarning.set(o)}else e=!0,this.priceMaximumRestrictionWarning.set("");return e}static \u0275fac=function(e){return new(e||n)(q(pe),q(z),q(Ct),q(ie))};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};var Je=class n{_isEdit=new De;isEdit$;id$;isUnpaid$;dialog=G(ie);constructor(t,e,i,o,s){let F=Ke(t.snapshot.queryParams);this.isEdit$=mt(F.pipe(p(h=>!!h.ID)),this._isEdit.asObservable()).pipe(ae(1)),this.id$=F.pipe(A(h=>h.ID),p(h=>h.ID));let f=this.id$.pipe(Y(h=>e.post("/api/Buy2/GetDataByID2",{ID:h})),ae(1)),w=bt(()=>o.entities$).pipe(Y(h=>f.pipe(p(b=>[b.Order,h]))),k(([h,b])=>{let R={Att:h.Att,SupplierID:{Key:h.SupplierID,Value:h.SupplierName,OnSet:!0},Date:h.Date,Number:h.Number,ID:h.ID};i.setBulkOrderForm(R)}),k(([h,b])=>{let R=b.find($=>$.ID==h.EntityID);i.setOutletForm(R)})),H=f.pipe(p(h=>h.Items),p(h=>h.map(b=>B(P({},b.Variant),{Quantity:b.Quantity,Total:b.Total,Note:b.Note,UnitPrice:b.UnitPrice,Discount:b.Discount,Serial:b.Serial,ID:b.ID,VariantID:b.VariantID,UnitQuantity:b.UnitQuantity,QtyRequested:b.QtyRequested,DiscountAmount:b.DiscountAmount}))),k(h=>s.editForm(h))),M=bt(()=>o.currencies$).pipe(Y(h=>f.pipe(p(b=>[b.Order,h,b.Invoice]))),p(([h,b,R])=>B(P({},h),{Number:h.Number!=R.Number?R.Number:h.Number,Currency:b.find($=>$.ID===h.CurrencyID)})),k(h=>{let b={Note:h.Note,TagID:h.TypeID,Currency:P({},h.Currency),InvoiceNumber:h.Number};i.setBulkNoteForm(b)})),j=f.pipe(p(h=>h.DeliveryEntityID),k(h=>i.setDeliveryEntityID(h))),c=bt(()=>o.taxes$).pipe(Y(h=>f.pipe(p(b=>[b.Order,h]))),p(([h,b])=>B(P({},h),{Taxes:b})),k(h=>{let b=h.Taxes.find($=>$.ID===h.TaxTypeID);b?.Bin&&this.dialog.open(ii,{id:"ModalInfo",data:{title:"Default Tax Discontinued",message:`
1
+ import{a as Zn}from"./chunk-FNQZZ5XA.js";import{a as Gn,b as eo}from"./chunk-34Z4FOCK.js";import{a as qn,b as Kn,c as zn,d as Yn,e as Xn,f as Qe}from"./chunk-3VSKC2C4.js";import{a as oi}from"./chunk-LBXXGAZP.js";import{a as ni}from"./chunk-O3NVMGWX.js";import{a as Hn}from"./chunk-RRHZOE3Y.js";import"./chunk-DVLNWQL2.js";import{a as Zt}from"./chunk-FLCL42EG.js";import{a as Vt}from"./chunk-UYAE2KWZ.js";import{b as jn,c as Ln}from"./chunk-SVCYQXBG.js";import"./chunk-JCUDUZIE.js";import{a as ii}from"./chunk-EQ3P3ATJ.js";import{a as Jn}from"./chunk-3NDCJ7IG.js";import"./chunk-TDQF4LF7.js";import"./chunk-NQX7EX5A.js";import{a as ei,b as Bn,c as $n}from"./chunk-IJDQTDWM.js";import"./chunk-LC2I6TZM.js";import{b as Vn}from"./chunk-W7M5YJPL.js";import{a as Un,b as Qn,c as Wn}from"./chunk-RDCWSC4B.js";import{a as Kt}from"./chunk-X7RPL3PD.js";import"./chunk-T5UW3VZA.js";import"./chunk-P3KIIKY4.js";import"./chunk-RJIB64GS.js";import{a as ti}from"./chunk-CAYJHOZ3.js";import{a as Rn}from"./chunk-UVAFCFHT.js";import"./chunk-BYXBJQAS.js";import"./chunk-VXKPVJSE.js";import{a as Ai}from"./chunk-LZAV46F7.js";import"./chunk-FMXCM3TT.js";import"./chunk-DDLXGCOB.js";import"./chunk-6ZKW6NGS.js";import{a as An}from"./chunk-IEFU4ZWW.js";import{e as wt}from"./chunk-A3XPLCMP.js";import"./chunk-22VMH5K4.js";import{p as kn}from"./chunk-VQQIQFUB.js";import"./chunk-HKSUQNKJ.js";import"./chunk-DLBX5RSU.js";import"./chunk-YHKX3K56.js";import"./chunk-O3LZKJY2.js";import"./chunk-WLNLF7ZT.js";import"./chunk-MPGXQK5L.js";import"./chunk-GHWVU235.js";import{a as Xt}from"./chunk-LZ4LJZAV.js";import"./chunk-IDHUYY2U.js";import{c as wn,d as Nn}from"./chunk-A75ZS57D.js";import"./chunk-HSGXXXIK.js";import{a as Sn}from"./chunk-6KJTU3AF.js";import"./chunk-TQ2YP2CL.js";import{c as hn}from"./chunk-LIMLIVTQ.js";import"./chunk-WYKVRUIW.js";import"./chunk-LVIGLDQ4.js";import{a as ft}from"./chunk-KR74ZZ6U.js";import"./chunk-FSAQ7W4Y.js";import"./chunk-DA33S43F.js";import{b as En,c as Fn}from"./chunk-BSOZMEUZ.js";import"./chunk-KLLRDRG7.js";import"./chunk-GFPR5PLO.js";import"./chunk-7K5H76G7.js";import"./chunk-BXQZZ4SS.js";import"./chunk-J7XZRRKK.js";import"./chunk-FOEAOA4G.js";import"./chunk-DZAEKVKZ.js";import{a as vn,d as _n,f as Dn,h as xn}from"./chunk-5OLVUC6J.js";import{a as Mn}from"./chunk-IALZBSAM.js";import{a as yn}from"./chunk-5E52ZWKI.js";import{f as Tn}from"./chunk-GSO64ETI.js";import"./chunk-Q6MS4QZ6.js";import"./chunk-GMF3SGSZ.js";import{k as bn,o as In,q as Pn,r as On}from"./chunk-5NWJYNJO.js";import"./chunk-36TOKQZQ.js";import"./chunk-XS4UTUMZ.js";import"./chunk-D3PKFTVO.js";import{a as it,b as nt}from"./chunk-V25UXFNL.js";import"./chunk-YNQPX5G6.js";import"./chunk-VAJAIBT3.js";import{a as mn,b as dn,c as pn}from"./chunk-DCS4THVW.js";import{d as Yt}from"./chunk-RBBEZN3D.js";import"./chunk-SX3PN3Z4.js";import{a as Oe,b as ke,c as ie,h as zt}from"./chunk-R2YNXAPB.js";import{a as X,b as ki}from"./chunk-MMKYHF6F.js";import"./chunk-LJWHBKHI.js";import{a as Ue}from"./chunk-SY5NNN4M.js";import"./chunk-KYGIDMGO.js";import"./chunk-R2UNPOYE.js";import"./chunk-RXZDFS3M.js";import{a as be,b as Ie,c as Pe}from"./chunk-3UB7PEG5.js";import"./chunk-DVI52XSU.js";import"./chunk-6HNYSYBG.js";import"./chunk-WIUSOID5.js";import"./chunk-K7ICHNI3.js";import{D as gn,E as Fe,F as tt,a as Ze,b as un,c as Me,h as de,l as ge,o as Ee,r as fn,s as et}from"./chunk-POUQHZWU.js";import{a as Cn}from"./chunk-PXMHU3QB.js";import"./chunk-MNXZMQRB.js";import{b as Ce}from"./chunk-WYAHUX6O.js";import{a as I}from"./chunk-PTRS3UA6.js";import{a as cn}from"./chunk-DD4F55YZ.js";import{n as Le,q as pe}from"./chunk-D3E5UKKJ.js";import{$ as qi,$b as It,Aa as Ki,Ab as y,B as mt,Bb as a,C as A,Cb as r,Cc as u,Cd as ln,Da as Ei,Db as x,Dc as C,Eb as vt,Ec as pt,F as Wi,Fb as _t,G as ve,Gb as nn,Hb as jt,Ib as Lt,Ic as Wt,Jb as on,K as Ji,Ka as $t,Kd as sn,L as ht,Lc as Jt,Ma as dt,Mb as U,Md as Ht,Nd as Gt,O as Hi,Pb as D,Pd as qt,Qa as zi,Qb as Ut,Qc as N,R as Gi,Ra as l,Rb as d,Rc as ut,U as Ft,W as ae,Xa as Yi,Ya as g,Z as Ye,Zb as St,_ as Y,_a as Xi,_b as Mt,ab as V,bc as Pt,ca as k,d as De,dc as At,e as at,ea as fe,ec as m,f as ji,fb as Zi,fc as ee,fd as Xe,gb as kt,gc as E,ha as me,hc as $e,i as Re,jc as W,k as Li,ka as q,kc as Q,kd as an,l as Ke,la as G,lc as J,ld as Se,m as Ui,mc as rt,nc as Ot,nd as rn,o as Qi,oc as Tt,pa as O,pc as Fi,pd as ye,qa as T,r as p,s as xe,sd as te,t as Ni,tb as v,tc as je,ub as en,uc as Qt,vb as _,vc as le,w as bt,wb as tn,wc as lt,xb as Be,yb as we,za as se,zb as Ne}from"./chunk-M3O2GJ3M.js";import{a as P,b as B,e as $i,j as oe}from"./chunk-KMHZKFQS.js";var to=()=>({deliveryEntityID:I.GuidEmpty,fulfillmentDate:null,fulfillmentTime:null,fulfillmentDateTime:null});var z=class n{constructor(t,e){this.http=e;this.buyForm=t.group({NewOrderID:[""],Order:t.group({Att:[""],SupplierID:[""],Number:[""],Date:[new Date],ID:[I.GuidEmpty]}),Invoice:t.group({ID:[I.GuidEmpty],Due:[new Date],Tax:[0]}),Payment:t.group({ID:[I.GuidEmpty],Amount:[0],MethodID:[0],Code:[""],Note:[""],ImageUrl:[""]})})}outlet=new ge({ID:"",Name:"Choose an Outlet"});dueDays=new ge(0);fulfillmentResult=new ge(to());noteForm=new ge({Note:"",TagID:"",Currency:{ID:"",ExchangeRate:0,Symbol:""},InvoiceNumber:""});discountAndTaxForm=new ge({Discount:{Amount:0,Percentage:0},Tax:{ID:"",CalculationTypeName:"",Rate:0,Label:"",Discontinue:!1}});buyForm;setPONumber(t){let e="";if(t.Seed){let i=t.Seed+"";for(;i.length<t.Digit;)i="0"+i;e=I.StringFormat(t.Prefix,i)}this.buyForm.controls.Order.controls.Number.setValue(e)}setDueDateBasedOnDaysDue(t){console.log(t);let e=this.invoiceDate,i=new Date(I.cloneObject(e));i.setDate(i.getDate()+t),this.buyForm.controls.Invoice.controls.Due.setValue(i)}get dueDate(){return this.buyForm.controls.Invoice.controls.Due.value}get invoiceDate(){return this.buyForm.controls.Order.controls.Date.value}setAmount(t){this.buyForm.controls.Payment.controls.Amount.setValue(t)}setPaymentMethodID(t){this.buyForm.controls.Payment.controls.MethodID.setValue(t)}setTaxAmount(t){this.buyForm.controls.Invoice.controls.Tax.setValue(t)}setNewOrderID(t){this.buyForm.controls.NewOrderID.setValue(t)}setTax(t){let e=P({},this.discountAndTaxForm.value.Discount);this.discountAndTaxForm.setValue({Discount:e,Tax:t})}setCurrency(t){let e=this.noteForm.value;this.noteForm.setValue(B(P({},e),{Currency:t}))}setDeliveryEntityID(t){this.fulfillmentResult.setValue(B(P({},this.fulfillmentResult.value),{deliveryEntityID:t}))}setdueDays(t){this.dueDays.setValue(t)}setBulkOrderForm(t){this.buyForm.controls.Order.setValue(t)}setBulkNoteForm(t){this.noteForm.setValue(t)}setBulkDiscountAndTaxForm(t){this.discountAndTaxForm.setValue(t)}setOutletForm(t){this.outlet.setValue(t)}setBulkInvoice(t){this.buyForm.controls.Invoice.setValue(P(P({},this.buyForm.controls.Invoice.value),t))}setBulkPayment(t){this.buyForm.controls.Payment.setValue(t)}resetOutletForm(){this.outlet.setValue({ID:"",Name:"Choose an Outlet"})}resetFulfillmentDate(){this.fulfillmentResult.setValue(B(P({},this.fulfillmentResult.value),{fulfillmentDate:null,fulfillmentTime:null,fulfillmentDateTime:null}))}resetDueDaysForm(){this.dueDays.setValue(0)}resetNoteForm(){this.noteForm.setValue(B(P({},this.noteForm.value),{Note:"",TagID:"",InvoiceNumber:""}))}resetDiscountAndTaxForm(){let t=this.discountAndTaxForm.value;this.discountAndTaxForm.setValue(B(P({},t),{Discount:{Amount:0,Percentage:0}}))}resetBuyForm(){this.buyForm.reset(),this.buyForm.controls.Invoice.controls.ID.setValue(I.GuidEmpty),this.buyForm.controls.Invoice.controls.Due.setValue(new Date),this.buyForm.controls.Order.controls.Date.setValue(new Date),this.buyForm.controls.Order.controls.ID.setValue(I.GuidEmpty),this.generateNumberOnNewTransaction()}generateNumberOnNewTransaction(){this.http.post("/API/Buy/GenerateNumber",{ID:this.outlet.value.ID}).subscribe(t=>{this.buyForm.controls.Order.controls.Number.setValue(t.Number)})}static \u0275fac=function(e){return new(e||n)(q(gn),q(pe))};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};var ue=class n{entities$;appConfigJSON$;taxes$;currencies$;supplierPOTypes$;predefinedNotes$;denomination$;defaultDueDays$;constructor(t,e){let i=t.get("/API/Buy2/Load").pipe(k(o=>{e.setCurrency(o.Currencies.find(s=>s.ID==o.AppConfigJSON.CoreDefaults.CurrencyID)),e.setNewOrderID(o.NewOrderID)}),ae(1));this.denomination$=i.pipe(p(o=>o.Denomination)),this.entities$=i.pipe(p(o=>o.Entities)),this.appConfigJSON$=i.pipe(p(o=>o.AppConfigJSON)),this.taxes$=i.pipe(p(o=>o.Taxes),ae(1)),this.currencies$=i.pipe(p(o=>o.Currencies),ae(1)),this.supplierPOTypes$=i.pipe(p(o=>o.SupplierPOTypes)),this.predefinedNotes$=i.pipe(p(o=>o.PredefinedNotes)),this.defaultDueDays$=i.pipe(p(o=>o.AppConfigJSON.ModuleBuy.PaymentDialog.DefaultDueDays),k(o=>e.setdueDays(o)),k(o=>e.setDueDateBasedOnDaysDue(o)))}updateDueDays(){this.defaultDueDays$.subscribe()}static \u0275fac=function(e){return new(e||n)(q(pe),q(z))};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};var gt=class n extends Gn{connection;_Data=new ji(1);Data=this._Data.asObservable();httpService=G(pe);toastService=G(Le);_cache=new Map;previousCountByEpc={};_isConnected=new at(!1);isConnected=this._isConnected.asObservable();_bufferTime=new at(100);set bufferTime(t){this._bufferTime.next(t)}get bufferTime(){return this._bufferTime.getValue()}_baseUrl=se("https://localhost:5001/rfidhub");baseUrl=Jt(()=>this._baseUrl());intializeWebSocket(t="/"){return oe(this,null,function*(){if(t.length<=0){this.toastService.error("RFID URL cannot be empty",be.Error);return}if(!(this.connection&&this.connection.state===dn.Connected)){this.connection=new pn().withUrl(t).configureLogging(mn.Information).withAutomaticReconnect().build();try{yield this.connection.start(),yield this.initiateGroupSubscription(),this.onWebSocketMessageReceived(),this._isConnected.next(!0),this.toastService.success("RFID Connected",be.Success),this._baseUrl.set(t)}catch(e){throw this._isConnected.next(!1),this.toastService.error(JSON.stringify(e),be.Error),this._baseUrl.set(null),new Error(JSON.stringify(e))}}})}disconnectWebSocket(){this.connection&&(this.connection.stop(),this.connection=void 0,this._isConnected.next(!1),this._baseUrl.set(null),this.toastService.info("RFID Disconnected",be.Info))}initiateGroupSubscription(){return oe(this,null,function*(){try{yield this.connection.invoke("SubscribeGroup",{CurrentID:"Buy"})}catch(t){throw this.toastService.error(JSON.stringify(t),be.Error),new Error(JSON.stringify(t))}})}onWebSocketMessageReceived(){this.connection.on("ReceiveSignal",t=>{this._Data.next(t)})}getVariantByCode(t,e=I.GuidEmpty){let i=[{key:"Code",value:t},{key:"EntityID",value:e}];return this.httpService.get(Ue.GetVariantByCode,i).pipe(ve(o=>o instanceof ln?Ke(null):Ui(()=>new Error(o.message))))}processGroupedData(t=I.GuidEmpty){return this._Data.pipe(A(e=>e!==null&&e&&Object.keys(e).length>0),Wi(this._bufferTime.getValue()),Ni(e=>Li(e)),Gi(e=>e.epc),Ni(e=>e.pipe(Ft((i,o)=>[...i,o],[]),Y(i=>{let o=e.key;if(this._cache.has(o))return this._cache.get(o).pipe(p(s=>({epc:o,items:i,response:s})));{let s=this.getVariantByCode(o,t).pipe(A(F=>F),k(F=>this._cache.set(o,Ke(F))));return this._cache.set(o,s),s.pipe(p(F=>({epc:o,items:i,response:F})))}}))),Ft((e,i)=>{let o=this.previousCountByEpc&&this.previousCountByEpc[i.epc]||0,s=i.items.length,F=s-o;return e[i.epc]={data:i.items,count:F,variant:i.response},this.previousCountByEpc[i.epc]=s,e},{}),ae({bufferSize:1,refCount:!0}))}constructor(){super(),this.connection&&(this.connection.onclose=t=>oe(this,null,function*(){console.error("SignalR connection closed:",t)}),this.connection.onreconnecting=t=>oe(this,null,function*(){console.warn("SignalR reconnecting:",t)}),this.connection.onreconnected=t=>oe(this,null,function*(){console.log("SignalR reconnected:",t)}))}static \u0275fac=function(e){return new(e||n)};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};var Ct=class n{returnInvoiceNumber=new ge("");invoiceInfo$;constructor(t,e,i){let o=e.outlet.valueChanges.pipe(p(c=>c.ID),X());this.invoiceInfo$=this.returnInvoiceNumber.valueChanges.pipe(A(c=>!!c),fe(o),Y(([c,S])=>t.post("/API/Buy/GetSupplierInvoiceRetur2",{EntityID:S,Number:c}).pipe(ve(()=>Re))),ae(1),X());let s=this.invoiceInfo$.pipe(p(c=>P({},c.Order)),k(c=>{let S={Att:c.Att,SupplierID:{Key:c.SupplierID,Value:c.SupplierName,OnSet:!0},Date:new Date,Number:e.buyForm.controls.Order.controls.Number.value,ID:I.GuidEmpty};e.setBulkOrderForm(S)}),X()),F=this.invoiceInfo$.pipe(p(c=>c.Order),fe(i.currencies$,i.appConfigJSON$),k(([c,S,L])=>{let ne=L.CoreDefaults.CurrencyID,b=S.find($=>$.ID===ne)?.Symbol??"$",R={Note:`Return #${c.Number}`,TagID:c.TypeID,Currency:{ID:c.CurrencyID||ne,ExchangeRate:c.CurrencyRate,Symbol:c.CurrencySymbol||b},InvoiceNumber:c.Number};e.setBulkNoteForm(R)}),X()),f=this.invoiceInfo$.pipe(p(c=>c.Order),fe(i.taxes$),p(([c,S])=>B(P({},c),{Tax:S.find(L=>L.ID===c.TaxTypeID)})),k(c=>{let S={Discount:{Amount:c.DiscountAmount,Percentage:c.Discount},Tax:{ID:c.TaxTypeID,Rate:c.Tax?.Rate,CalculationTypeName:c.Tax?.CalculationTypeName,Label:c.Tax?.Label,Discontinue:!c.Tax?.Label}};e.setBulkDiscountAndTaxForm(S)}),X()),w=this.invoiceInfo$.pipe(p(c=>c.DeliveryEntityID),k(c=>e.setDeliveryEntityID(c)),X()),H=this.invoiceInfo$.pipe(p(c=>c.Invoice),k(c=>{let S={ID:c.ID,Tax:c.Tax};e.setBulkInvoice(S)}),X()),M=this.invoiceInfo$.pipe(p(c=>c.Payment),k(c=>{let S={ID:I.GuidEmpty,Amount:c.Amount,MethodID:c.MethodID,Note:c.Note,Code:c.Code,ImageUrl:c.ImageUrl};e.setBulkPayment(S)}),X());xe(s,F,f,w,H,M).pipe(X()).subscribe()}static \u0275fac=function(e){return new(e||n)(q(pe),q(z),q(ue))};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};var Z=class n{constructor(t,e,i,o){this.matDialog=o;let s=e.outlet.valueChanges.pipe(p(c=>c.ID));this.addVariantThroughSerial$=this._addVariantThroughSerial.asObservable().pipe(fe(s),Y(([c,S])=>t.get(Ue.GetVariantBySerial,[{key:"Serial",value:c},{key:"EntityID",value:S}]).pipe(ve(()=>Re))),p(c=>this.setUnitPrice(c)),p(c=>B(P({},c),{Quantity:1,Total:c.UnitPrice,VariantID:c.ID,InventoryTypeID:c.TypeID})),p(c=>({action:"addAsSerial",variant:c})));let F=this.variantAutocomplete.valueChanges.pipe(A(c=>I.IsNotEmpty(c)&&c.type=="Code"),p(c=>c.str),fe(s),A(([c,S])=>I.IsNotEmpty(S)),Y(([c,S])=>t.get(Ue.GetVariantByCode,[{key:"Code",value:c},{key:"EntityID",value:S},{key:"Promotion",value:!0}]).pipe(ve(()=>Re))),p(c=>this.setUnitPrice(c)),p(c=>B(P({},c),{Quantity:1,Total:c.UnitPrice*((100-c.PriceDiscount)/100),Discount:c.PriceDiscount,VariantID:c.ID,InventoryTypeID:c.TypeID}))),f=this.variantAutocomplete.valueChanges.pipe(A(c=>I.IsNotEmpty(c)&&c.type=="ID"),p(c=>c.str)),w=this.variantQuickKey.valueChanges,H=mt(f,w).pipe(fe(s),Y(([c,S])=>t.get(Ue.GetVariantByID,[{key:"ID",value:c},{key:"EntityID",value:S}]).pipe(ve(()=>Re))),p(c=>this.setUnitPrice(c)),p(c=>B(P({},c),{Quantity:1,Total:c.UnitPrice*((100-c.OrderPriceDiscount)/100),Discount:c.OrderPriceDiscount,VariantID:c.ID,InventoryTypeID:c.TypeID}))),M=mt(H,F).pipe(k(c=>{c.CategoryTypeID===1&&this.toastr.info(`${c.Name} is sellable only.`,be.Info)}),A(c=>c.CategoryTypeID!==1),p(c=>({action:"add",variant:c})),k(()=>{this.cartDisplayRef&&setTimeout(()=>{let c=this.cartDisplayRef.nativeElement.scrollHeight;this.cartDisplayRef.nativeElement.scrollTop=c},1)})),j=i.invoiceInfo$.pipe(k(c=>{this.isReturn.set(c.IsReturn)}),p(c=>({action:"returnInvoice",variants:c.Items.map(S=>B(P({},S.Variant),{Quantity:S.Quantity,Total:S.Total,UnitPrice:S.UnitPrice,Discount:S.Discount,Serial:S.Serial,ID:S.ID,DiscountAmount:S.DiscountAmount,VariantID:S.VariantID,UnitQuantity:S.UnitQuantity}))})));this.cart$=mt(M,j,this.deleteVariant$,this.dragDropCart$,this.returnCart$,this.updateVariant$,this.returnVariant$,this.purchaseVariant$,this.clearCart$,this.onEditForm$,this.addVariantThroughSerial$,this.addVariant$,this.onUploadCart$,this.listenRFID$).pipe(Ft((c,S)=>{let L=[...c],ne=[],h=S.action;if(h=="add"){let b=S.variant;ne=!!L.find($=>$.VariantID==b.ID)?L.map($=>$.VariantID==b.ID?B(P({},$),{Quantity:$.Quantity+1,Total:$.Total+$.UnitPrice}):$):[...L,b]}else if(h=="returnInvoice"||h=="onEditForm")ne=S.variants;else if(h=="delete"){let b=S.index;ne=L.filter((R,$)=>$!=b)}else if(h=="sort"){let b=S.ev;ne=L,vn(ne,b.previousIndex,b.currentIndex)}else if(h=="returnCart")ne=L.map(b=>B(P({},b),{Quantity:-Math.abs(b.Quantity),Total:-Math.abs(b.Total)}));else if(h=="update"){let b=S.index;ne=L.map((R,$)=>$==b?S.variant:R)}else if(h=="returnVariant"){let b=S.index;ne=L.map((R,$)=>$==b?B(P({},R),{Quantity:-Math.abs(R.Quantity),Total:-Math.abs(R.Total)}):R)}else if(h=="purchaseVariant"){let b=S.index;ne=L.map((R,$)=>$==b?B(P({},R),{Quantity:Math.abs(R.Quantity),Total:Math.abs(R.Total)}):R)}else if(h=="clearCart")ne=[];else if(h=="addAsSerial"){let b=B(P({},S.variant),{Serial:[{Number:S.variant.Serial.Number,Quantity:1,ExpiryDate:S.variant.Serial.ExpiryDate}]});if(!!L.find($=>$.ID==b.ID)){let $=b.Serial[0],Te=L.find(re=>re.ID==b.ID),_e=!!Te.Serial.find(re=>re.Number==$.Number)?[...Te.Serial].map(re=>re.Number==$.Number?B(P({},re),{Quantity:re.Quantity+1}):re):[...Te.Serial,$];ne=L.map(re=>re.ID==b.ID?B(P({},re),{Quantity:re.Quantity+1,Total:re.Total+re.UnitPrice,Serial:_e}):re)}else ne=[...L,B(P({},b),{Quantity:1,Total:b.UnitPrice})]}else if(h=="uploadCart")ne=[...L,...S.variants];else if(h=="addNewRow"){let b=S.variant;ne=[...L,b]}else if(h=="rfid"){let b=S.variants;Object.keys(b).forEach(R=>{if(b.hasOwnProperty(R)){let $=b[R];if($&&Object.keys($.variant).length>0){let Te=L.findIndex(Ve=>Ve.Code.toLowerCase()===R.toLowerCase());if(Te!==-1){let Ve=Number($.count);L[Te].Quantity+=Ve,L[Te].Total=+L[Te].UnitPrice*+L[Te].Quantity,delete b[R],ne=[...L]}else{let Ve=$.variant,_e=Number($.count),re=this.setUnitPrice(Ve),ct=this.formatItemObject(B(P({},re),{Quantity:_e,Total:+re.UnitPrice*+_e}));delete b[R],ne=[...L,ct]}}}})}return ne},[]),Ye([]),ae(1)),this.totalVariantOrdered$=this.cart$.pipe(p(c=>c.map(S=>S.Quantity)),p(c=>c.reduce((S,L)=>S+L,0)),Ye(0))}toastr=G(Le);roleService=G(Ce);decimalPipe=G(ye);cartDisplayRef;variantAutocomplete=new ge;variantQuickKey=new ge;priceMaximumRestrictionWarning=se("");_listenRFID=new De;listenRFID$=this._listenRFID.asObservable().pipe(p(t=>({action:"rfid",variants:t})));_deleteVariant=new De;deleteVariant$=this._deleteVariant.asObservable().pipe(p(t=>({action:"delete",index:t})));_dragDropCart=new De;dragDropCart$=this._dragDropCart.asObservable().pipe(p(t=>({action:"sort",ev:t})));_returnCart=new De;returnCart$=this._returnCart.asObservable().pipe(p(()=>({action:"returnCart"})));_onEditForm=new at(null);onEditForm$=this._onEditForm.asObservable().pipe(A(t=>!!t),p(t=>({action:"onEditForm",variants:t})));_clearCart=new De;clearCart$=this._clearCart.asObservable().pipe(p(()=>({action:"clearCart"})));_updateVariant=new De;updateVariant$=this._updateVariant.asObservable().pipe(p(t=>({action:"update",variant:t.variant,index:t.index})));_returnVariant=new De;returnVariant$=this._returnVariant.asObservable().pipe(p(t=>({action:"returnVariant",index:t})));_purchaseVariant=new De;purchaseVariant$=this._purchaseVariant.asObservable().pipe(p(t=>({action:"purchaseVariant",index:t})));_addVariant=new De;addVariant$=this._addVariant.asObservable().pipe(p(t=>({action:"addNewRow",variant:t})));_onUploadCart=new De;onUploadCart$=this._onUploadCart.asObservable().pipe(p(t=>({action:"uploadCart",variants:t})));cart$;totalVariantOrdered$;isReturn=se(!1);_addVariantThroughSerial=new De;addVariantThroughSerial$;deleteVariant(t){this._deleteVariant.next(t)}dragDropCart(t){this._dragDropCart.next(t)}returnCart(){this._returnCart.next()}updateVariant(t,e){this._updateVariant.next({variant:t,index:e})}returnVariant(t){this._returnVariant.next(t)}purchaseVariant(t){this._purchaseVariant.next(t)}clearCart(){this._clearCart.next()}editForm(t){this._onEditForm.next(t)}addVariant(t){this._addVariant.next(t)}addVariantThroughSerial(t){this._addVariantThroughSerial.next(t)}uploadCart(t){this._onUploadCart.next(t)}setUnitPrice(t){let e=P({},t);return I.IsNotEmpty(t.OrderPrice)?e.UnitPrice=t.OrderPrice:e.UnitPrice=t.UnitCost,e}formatItemObject=t=>{let o=t,{ID:e}=o,i=$i(o,["ID"]);return B(P({},i),{Quantity:i.Quantity??1,Total:i.Total??i.UnitPrice,VariantID:e})};addCartRFID(t){this._listenRFID.next(t)}validatePriceMaximum(t){let e=!0;if(this.roleService.buyRestriction.CostMax&&t.MaxOrderPrice>0)if(t.UnitPrice>t.MaxOrderPrice){e=!1;let o=I.StringFormat("<span><i class='fa-solid fa-triangle-exclamation me-2 d-inline'></i>Cannot buy more than <h5 class='d-inline m-0'>{0}</h5></span>",this.decimalPipe.transform(t.MaxOrderPrice));this.priceMaximumRestrictionWarning.set(o)}else e=!0,this.priceMaximumRestrictionWarning.set("");return e}static \u0275fac=function(e){return new(e||n)(q(pe),q(z),q(Ct),q(ie))};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};var Je=class n{_isEdit=new De;isEdit$;id$;isUnpaid$;dialog=G(ie);constructor(t,e,i,o,s){let F=Ke(t.snapshot.queryParams);this.isEdit$=mt(F.pipe(p(h=>!!h.ID)),this._isEdit.asObservable()).pipe(ae(1)),this.id$=F.pipe(A(h=>h.ID),p(h=>h.ID));let f=this.id$.pipe(Y(h=>e.post("/api/Buy2/GetDataByID2",{ID:h})),ae(1)),w=bt(()=>o.entities$).pipe(Y(h=>f.pipe(p(b=>[b.Order,h]))),k(([h,b])=>{let R={Att:h.Att,SupplierID:{Key:h.SupplierID,Value:h.SupplierName,OnSet:!0},Date:h.Date,Number:h.Number,ID:h.ID};i.setBulkOrderForm(R)}),k(([h,b])=>{let R=b.find($=>$.ID==h.EntityID);i.setOutletForm(R)})),H=f.pipe(p(h=>h.Items),p(h=>h.map(b=>B(P({},b.Variant),{Quantity:b.Quantity,Total:b.Total,Note:b.Note,UnitPrice:b.UnitPrice,Discount:b.Discount,Serial:b.Serial,ID:b.ID,VariantID:b.VariantID,UnitQuantity:b.UnitQuantity,QtyRequested:b.QtyRequested,DiscountAmount:b.DiscountAmount}))),k(h=>s.editForm(h))),M=bt(()=>o.currencies$).pipe(Y(h=>f.pipe(p(b=>[b.Order,h,b.Invoice]))),p(([h,b,R])=>B(P({},h),{Number:h.Number!=R.Number?R.Number:h.Number,Currency:b.find($=>$.ID===h.CurrencyID)})),k(h=>{let b={Note:h.Note,TagID:h.TypeID,Currency:P({},h.Currency),InvoiceNumber:h.Number};i.setBulkNoteForm(b)})),j=f.pipe(p(h=>h.DeliveryEntityID),k(h=>i.setDeliveryEntityID(h))),c=bt(()=>o.taxes$).pipe(Y(h=>f.pipe(p(b=>[b.Order,h]))),p(([h,b])=>B(P({},h),{Taxes:b})),k(h=>{let b=h.Taxes.find($=>$.ID===h.TaxTypeID);b?.Bin&&this.dialog.open(ei,{id:"ModalInfo",data:{title:"Default Tax Discontinued",message:`
2
2
  <div class="d-flex justify-content-center my-4">
3
3
  <img class="img-2x" src="https://cdn.dealpos.xyz/web-image/globalerror.svg"
4
4
  alt="Empty Sales Order Tag" />
@@ -9,7 +9,7 @@ import{a as Zn,b as eo}from"./chunk-PORO4RUV.js";import{a as oi}from"./chunk-LBX
9
9
  <p class="text-center">
10
10
  Please change the default tax or re-activate the tax <a href="/menu/Setup/Payment/Tax">here</a>.
11
11
  </p>
12
- `,headerType:be.Error},width:"31rem"}),(I.IsEmpty(b)||b?.Bin)&&(b=h.Taxes[0],h.TaxTypeID=b.ID);let R={Discount:{Amount:h.DiscountAmount,Percentage:h.Discount},Tax:{ID:h.TaxTypeID,Rate:b?.Rate,CalculationTypeName:b?.CalculationTypeName,Label:b?.Label??b?.Name,Discontinue:b?.Bin}};i.setBulkDiscountAndTaxForm(R)})),S=f.pipe(p(h=>h.Invoice),k(h=>{let b={ID:h.ID,Due:h.Due,Tax:h.Tax};i.setBulkInvoice(b)})),L=this.isEdit$.pipe(Y(h=>f.pipe(p(b=>b.Payment),k(b=>{let R={ID:h?b?.ID:I.GuidEmpty,Amount:h?b?.Amount:0,MethodID:b?.MethodID,Note:h?b?.Note:null,Code:b?.Code,ImageUrl:h?b?.ImageUrl:null};R.Amount!==void 0&&i.setBulkPayment(R)}))));this.isUnpaid$=L.pipe(p(h=>I.IsEmpty(h))),xe(w,H,M,j,c,S,L).subscribe()}onNewPurchase(){this._isEdit.next(!1)}static \u0275fac=function(e){return new(e||n)(q(sn),q(pe),q(z),q(ue),q(Z))};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};var He=class n{edit=G(Je);_paymentComplete=new De;paymentComplete$=this._paymentComplete.asObservable().pipe(ae(1));_createNewTransaction=new at(!1);createNewTransaction$=this._createNewTransaction.asObservable();constructor(){}paymentComplete(t){this._paymentComplete.next(t)}createNewTransaction(){this._createNewTransaction.next(!0),this.edit.onNewPurchase()}static \u0275fac=function(e){return new(e||n)};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};var ot=class n{rfidService=G(gt);quickKeyPack$;cardPayments$;cashPayments$;otherPayments$;updateDefaultTax$;isCashSuspended$;updatePaymentMethodID$;dialog=G(ie);constructor(t,e,i,o,s){let F=e.outlet.valueChanges.pipe(p(M=>M?.ID),X()),f=F.pipe(Hi(),A(M=>!!M),fe(i.isEdit$),Y(([M,j])=>t.get("/API/Buy2/GetOutletInfo",[{key:"EntityID",value:M},{key:"IsEdit",value:j}])),ae(1),X()),w=f.pipe(fe(i.isEdit$),A(([M,j])=>!j),p(([M,j])=>M),k(M=>e.setPONumber(M.NumberElement)),X());this.quickKeyPack$=f.pipe(p(M=>M.QuickKeyPack),X()),this.updateDefaultTax$=bt(()=>o.taxes$).pipe(Y(M=>f.pipe(p(j=>[M,j]))),fe(i.isEdit$),A(([[M,j],c])=>!c),p(([[M,j],c])=>[M,j]),k(([M,j])=>{let c=M.find(S=>S.ID==j.DefaultTaxType);c?.Bin&&this.showTaxDiscontinuedDialog(),(I.IsEmpty(c)||c.Bin)&&(c=M.find(S=>!S.Bin)),e.setTax(c)}),X()),this.updatePaymentMethodID$=f.pipe(fe(i.isEdit$),A(([M,j])=>!j),p(([M,j])=>M.Payments),p(M=>{let j=M.filter(c=>c.TypeID==1);return j.length?j:M.filter(c=>c.TypeID==2)}),k(M=>e.setPaymentMethodID(M[0].ID)),X()),this.cashPayments$=f.pipe(p(M=>M.Payments),p(M=>M.filter(j=>j.TypeID==1)),X()),this.cardPayments$=f.pipe(p(M=>M.Payments),p(M=>M.filter(j=>j.TypeID==2)),X()),this.otherPayments$=f.pipe(p(M=>M.Payments),p(M=>M.filter(j=>j.TypeID==4)),X()),this.isCashSuspended$=f.pipe(p(M=>M.Payments),p(M=>!!M.filter(c=>c.TypeID==1).length),X()),bt(()=>o.appConfigJSON$).pipe(fe(i.isEdit$),A(([M,j])=>!j&&M.ModuleBuy.Shipping.BuyShippingDefault==0),Y(()=>xe(F,s.createNewTransaction$)),k(([M,j])=>e.setDeliveryEntityID(M)),X()).subscribe(),w.subscribe(),this.updateDefaultTax$.subscribe(),this.updatePaymentMethodID$.subscribe()}showTaxDiscontinuedDialog(){this.dialog.open(ii,{id:"ModalInfo",data:{title:"Default Tax Discontinued",message:`
12
+ `,headerType:be.Error},width:"31rem"}),(I.IsEmpty(b)||b?.Bin)&&(b=h.Taxes[0],h.TaxTypeID=b.ID);let R={Discount:{Amount:h.DiscountAmount,Percentage:h.Discount},Tax:{ID:h.TaxTypeID,Rate:b?.Rate,CalculationTypeName:b?.CalculationTypeName,Label:b?.Label??b?.Name,Discontinue:b?.Bin}};i.setBulkDiscountAndTaxForm(R)})),S=f.pipe(p(h=>h.Invoice),k(h=>{let b={ID:h.ID,Due:h.Due,Tax:h.Tax};i.setBulkInvoice(b)})),L=this.isEdit$.pipe(Y(h=>f.pipe(p(b=>b.Payment),k(b=>{let R={ID:h?b?.ID:I.GuidEmpty,Amount:h?b?.Amount:0,MethodID:b?.MethodID,Note:h?b?.Note:null,Code:b?.Code,ImageUrl:h?b?.ImageUrl:null};R.Amount!==void 0&&i.setBulkPayment(R)}))));this.isUnpaid$=L.pipe(p(h=>I.IsEmpty(h))),xe(w,H,M,j,c,S,L).subscribe()}onNewPurchase(){this._isEdit.next(!1)}static \u0275fac=function(e){return new(e||n)(q(sn),q(pe),q(z),q(ue),q(Z))};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};var He=class n{edit=G(Je);_paymentComplete=new De;paymentComplete$=this._paymentComplete.asObservable().pipe(ae(1));_createNewTransaction=new at(!1);createNewTransaction$=this._createNewTransaction.asObservable();constructor(){}paymentComplete(t){this._paymentComplete.next(t)}createNewTransaction(){this._createNewTransaction.next(!0),this.edit.onNewPurchase()}static \u0275fac=function(e){return new(e||n)};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};var ot=class n{rfidService=G(gt);quickKeyPack$;cardPayments$;cashPayments$;otherPayments$;updateDefaultTax$;isCashSuspended$;updatePaymentMethodID$;dialog=G(ie);constructor(t,e,i,o,s){let F=e.outlet.valueChanges.pipe(p(M=>M?.ID),X()),f=F.pipe(Hi(),A(M=>!!M),fe(i.isEdit$),Y(([M,j])=>t.get("/API/Buy2/GetOutletInfo",[{key:"EntityID",value:M},{key:"IsEdit",value:j}])),ae(1),X()),w=f.pipe(fe(i.isEdit$),A(([M,j])=>!j),p(([M,j])=>M),k(M=>e.setPONumber(M.NumberElement)),X());this.quickKeyPack$=f.pipe(p(M=>M.QuickKeyPack),X()),this.updateDefaultTax$=bt(()=>o.taxes$).pipe(Y(M=>f.pipe(p(j=>[M,j]))),fe(i.isEdit$),A(([[M,j],c])=>!c),p(([[M,j],c])=>[M,j]),k(([M,j])=>{let c=M.find(S=>S.ID==j.DefaultTaxType);c?.Bin&&this.showTaxDiscontinuedDialog(),(I.IsEmpty(c)||c.Bin)&&(c=M.find(S=>!S.Bin)),e.setTax(c)}),X()),this.updatePaymentMethodID$=f.pipe(fe(i.isEdit$),A(([M,j])=>!j),p(([M,j])=>M.Payments),p(M=>{let j=M.filter(c=>c.TypeID==1);return j.length?j:M.filter(c=>c.TypeID==2)}),k(M=>e.setPaymentMethodID(M[0].ID)),X()),this.cashPayments$=f.pipe(p(M=>M.Payments),p(M=>M.filter(j=>j.TypeID==1)),X()),this.cardPayments$=f.pipe(p(M=>M.Payments),p(M=>M.filter(j=>j.TypeID==2)),X()),this.otherPayments$=f.pipe(p(M=>M.Payments),p(M=>M.filter(j=>j.TypeID==4)),X()),this.isCashSuspended$=f.pipe(p(M=>M.Payments),p(M=>!!M.filter(c=>c.TypeID==1).length),X()),bt(()=>o.appConfigJSON$).pipe(fe(i.isEdit$),A(([M,j])=>!j&&M.ModuleBuy.Shipping.BuyShippingDefault==0),Y(()=>xe(F,s.createNewTransaction$)),k(([M,j])=>e.setDeliveryEntityID(M)),X()).subscribe(),w.subscribe(),this.updateDefaultTax$.subscribe(),this.updatePaymentMethodID$.subscribe()}showTaxDiscontinuedDialog(){this.dialog.open(ei,{id:"ModalInfo",data:{title:"Default Tax Discontinued",message:`
13
13
  <div class="d-flex justify-content-center my-4">
14
14
  <img class="img-2x" src="https://cdn.dealpos.xyz/web-image/globalerror.svg"
15
15
  alt="Empty Sales Order Tag" />
@@ -20,5 +20,5 @@ import{a as Zn,b as eo}from"./chunk-PORO4RUV.js";import{a as oi}from"./chunk-LBX
20
20
  <p class="text-center">
21
21
  Please change the default tax or re-activate the tax <a href="/menu/Setup/Payment/Tax">here</a>.
22
22
  </p>
23
- `,headerType:be.Error},width:"31rem"})}updateTax(){this.updateDefaultTax$.pipe(ht(1)).subscribe()}updatePaymentMethodID(){this.updatePaymentMethodID$.pipe(ht(1)).subscribe()}static \u0275fac=function(e){return new(e||n)(q(pe),q(z),q(Je),q(ue),q(He))};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};function lo(n,t){if(n&1&&(a(0,"mat-option",5),m(1),r()),n&2){let e=t.$implicit;y("value",e),l(),E(" ",e.Value," ")}}function so(n,t){if(n&1){let e=U();a(0,"i",7),D("click",function(){O(e);let o=d();return T(o.openSupplierDetail())}),r()}}var ri=class n{constructor(t,e,i,o){this.http=t;this.form=e;this.matDialog=i;this.router=o}supplierPOTypes=N([]);appConfigJSON=N(void 0);filteredSuppliers$;supplier=new ge("");disabled=!1;onChange=t=>{};onTouched=()=>{};toastr=G(Le);searchSupplier(t){return this.http.get("/API/AC/GetSupplierSuggestion",[{key:"count",value:100},{key:"prefix",value:t}]).pipe(k(e=>{e.length===0&&this.toastr.warning(`No supplier with name starting with "${t}" found`,"Warning")}),ve(()=>(this.toastr.error(`Supplier with name starting with "${t}" cannot be loaded`),Ke([]))))}ngOnInit(){this.filteredSuppliers$=this.supplier.valueChanges.pipe(A(i=>typeof i=="string"&&i.length>=3),Ji(300),Y(i=>this.searchSupplier(i))),this.supplier.valueChanges.pipe(A(i=>typeof i!="string"),p(i=>i),k(i=>i?.Key!=I.GuidEmpty&&I.IsNotEmpty(i)?this.onChange(i.Key):this.onChange(null))).pipe(A(i=>I.IsNotEmpty(i)&&!i.OnSet),Y(i=>this.http.post("/API/Contact/GetSupplierDTO",{id:i.Key}).pipe(ve(()=>Re))),p(i=>i.DaysDue),A(i=>i!=0),k(i=>this.form.setdueDays(i)),k(i=>this.form.setDueDateBasedOnDaysDue(i))).subscribe()}writeValue(t){this.supplier.setValue(t)}registerOnChange(t){this.onChange=t}registerOnTouched(t){this.onTouched=t}setDisabledState(t){this.disabled=t}displaySupplierNameFn(t){return t?.Value}openNewSupplierModal(){return oe(this,null,function*(){this.matDialog.open(zn,{data:{options:this.supplierPOTypes(),config:this.appConfigJSON()?.ModuleContact,type:"supplier",title:"New Supplier Form"}}).afterClosed().pipe(A(t=>I.IsNotEmpty(t.supplier.Name)),Y(t=>{let e={contact:t.supplier,type:"supplier",groups:t.supplier.Group?t.supplier.Group:[]};return this.http.post("/API/Contact/Supplier/Create",e).pipe(p(i=>({Key:i.ID,Value:t.supplier.Name})))})).subscribe(t=>{this.writeValue(t),this.onChange(t.Key)})})}openSupplierDetail(){let t=this.supplier.value.Key;if(I.IsNotEmpty(t)){let e=this.router.serializeUrl(this.router.createUrlTree(["/menu/Contacts/Contact/Suppliers/Info/V2"],{queryParams:{ID:t}}));window.open(e,"_blank")}}static \u0275fac=function(e){return new(e||n)(g(pe),g(z),g(ie),g(Ht))};static \u0275cmp=V({type:n,selectors:[["POS-supplier-autocomplete"]],inputs:{supplierPOTypes:[1,"supplierPOTypes"],appConfigJSON:[1,"appConfigJSON"]},features:[je([{provide:Ze,multi:!0,useExisting:n}])],decls:9,vars:6,consts:[["auto","matAutocomplete"],[1,"d-flex","align-items-center","position-relative"],["matTooltipPosition","above","matTooltip","New Supplier Form",1,"fa-light","fa-user-plus","position-absolute",2,"font-size","12px",3,"click"],["type","text","placeholder","Assign Supplier",3,"formControl","matAutocomplete"],[3,"displayWith"],[3,"value"],["matTooltipPosition","left","matTooltip","Open Supplier Details",1,"fa-regular","fa-arrow-up-right-from-square","position-absolute",2,"font-size","12px","right","0","cursor","pointer"],["matTooltipPosition","left","matTooltip","Open Supplier Details",1,"fa-regular","fa-arrow-up-right-from-square","position-absolute",2,"font-size","12px","right","0","cursor","pointer",3,"click"]],template:function(e,i){if(e&1&&(a(0,"div",1)(1,"i",2),D("click",function(){return i.openNewSupplierModal()}),r(),x(2,"input",3),a(3,"mat-autocomplete",4,0),we(5,lo,2,2,"mat-option",5,Be),u(7,"async"),r(),v(8,so,1,0,"i",6),r()),e&2){let o=It(4);l(2),y("formControl",i.supplier)("matAutocomplete",o),l(),y("displayWith",i.displaySupplierNameFn),l(2),Ne(C(7,4,i.filteredSuppliers$)),l(3),_(i.supplier&&(i.supplier!=null&&i.supplier.value)&&(!(i.supplier==null||i.supplier.value==null)&&i.supplier.value.Key)?8:-1)}},dependencies:[te,On,In,bn,Pn,tt,Me,de,et,nt,it,Yn,Se],styles:["input[_ngcontent-%COMP%]{width:100%;height:38px!important;border-radius:.375rem;border:1px solid #ced4da;padding-left:32px;padding-right:32px}input[_ngcontent-%COMP%]::placeholder{color:#ced4da}i.fa-user-plus[_ngcontent-%COMP%]{font-size:16px;top:10.6px;left:13px}i.fa-arrow-up-right-from-square[_ngcontent-%COMP%]{transform:none;position:absolute;margin-right:13px;top:10.6px;font-size:12px}"],changeDetection:0})};var co=["quantity"],Rt=n=>({selected:n}),mo=()=>["/menu/Products/Catalog/Variants/Info"],po=n=>({ID:n}),uo=n=>({"table-light":n});function fo(n,t){if(n&1){let e=U();a(0,"a",17),D("click",function(){O(e);let o=d();return T(o.onTabChange("Discount"))}),m(1," Discount "),r()}if(n&2){let e=d();y("ngClass",le(1,Rt,e.tabState=="Discount"))}}function go(n,t){if(n&1){let e=U();a(0,"a",18),D("click",function(){O(e);let o=d();return T(o.onTabChange("Product"))}),m(1," Product "),r()}if(n&2){let e=d();y("ngClass",le(1,Rt,e.tabState=="Product"))}}function Co(n,t){if(n&1){let e=U();a(0,"a",19),D("click",function(){O(e);let o=d();return T(o.onTabChange("Serial"))}),m(1),r()}if(n&2){let e=d();y("ngClass",le(2,Rt,e.tabState=="Serial")),l(),E(" ",e.isBatchNumber()?"Batch Number":"Serial"," ")}}function yo(n,t){if(n&1&&(a(0,"div",20),x(1,"div",28),r()),n&2){let e=d(2);l(),y("innerHTML",e.cartService.priceMaximumRestrictionWarning(),$t)}}function bo(n,t){if(n&1&&(a(0,"div",12)(1,"div",29),x(2,"POS-variant-autocomplete",30),r()()),n&2){let e=d(2);l(2),y("formControl",e.variantAutocomplete)("isOnModalVariant",!0)}}function ho(n,t){if(n&1&&(a(0,"span"),m(1),r()),n&2){let e=d(2);l(),E("(",e.variant.UOMName,")")}}function vo(n,t){if(n&1){let e=U();a(0,"div",24)(1,"strong")(2,"span"),m(3),r()(),a(4,"input",31),J("ngModelChange",function(o){O(e);let s=d(2);return Q(s.variant.UnitQuantity,o)||(s.variant.UnitQuantity=o),T(o)}),D("ngModelChange",function(){O(e);let o=d(2);return T(o.onUnitQtyChange())}),r()()}if(n&2){let e=d(2);l(3),ee(e.unitQtyLabel),l(),y("preventNegative",!0)("decimalPlaces",e.isSerialItem||e.isBatchNumber()?0:4),W("ngModel",e.variant.UnitQuantity)}}function _o(n,t){if(n&1){let e=U();a(0,"div",25)(1,"strong"),m(2,"Cost"),r(),a(3,"input",32,1),J("ngModelChange",function(o){O(e);let s=d(2);return Q(s.variant.UnitPrice,o)||(s.variant.UnitPrice=o),T(o)}),D("ngModelChange",function(){O(e);let o=d(2);return T(o.onPriceChange())}),r()()}if(n&2){let e=d(2);l(3),y("simpleKeyboard",e.keyboard),W("ngModel",e.variant.UnitPrice)}}function Do(n,t){if(n&1){let e=U();v(0,yo,2,1,"div",20),a(1,"div",21),v(2,bo,3,2,"div",12),a(3,"div",12)(4,"div",22)(5,"strong"),m(6," Qty "),v(7,ho,2,1,"span"),r(),a(8,"input",23,0),J("ngModelChange",function(o){O(e);let s=d();return Q(s.variant.Quantity,o)||(s.variant.Quantity=o),T(o)}),D("ngModelChange",function(){O(e);let o=d();return T(o.onQtyChange())}),r()(),v(10,vo,5,4,"div",24),v(11,_o,5,2,"div",25),r(),a(12,"div",12)(13,"div",26)(14,"POS-tinymce-editor",27),J("ngModelChange",function(o){O(e);let s=d();return Q(s.variant.Note,o)||(s.variant.Note=o),T(o)}),r()()()()}if(n&2){let e=d();_(e.cartService.priceMaximumRestrictionWarning()&&e.cartService.priceMaximumRestrictionWarning().trim()!==""?0:-1),l(2),_(e.isCreate?2:-1),l(5),_(e.variant.UOMName?7:-1),l(),y("simpleKeyboard",e.keyboard)("decimalPlaces",e.isSerialItem||e.isBatchNumber()?0:4),W("ngModel",e.variant.Quantity),y("disabled",e.isEditBuyForm&&(e.isSerialItem||e.isBatchNumber())),l(2),_(e.unitQtyLabel?10:-1),l(),_(e.role.product.Cost?11:-1),l(3),W("ngModel",e.variant.Note)}}function xo(n,t){if(n&1&&(a(0,"div",46)(1,"div",35)(2,"strong"),m(3,"Discount Amount / Qty"),r()(),a(4,"div",36)(5,"div",48)(6,"p"),m(7),u(8,"number"),r()()()()),n&2){let e=d(2);l(7),ee(C(8,1,e.variant.DiscountAmount))}}function So(n,t){if(n&1&&(a(0,"div",54)(1,"h5",60),m(2),u(3,"number"),r()()),n&2){let e=d(3);l(2),E(" ",C(3,1,e.variant.Discount),"% ")}}function Mo(n,t){if(n&1&&(a(0,"div",55)(1,"h5"),m(2),u(3,"number"),r(),a(4,"span",53),m(5,"x"),r(),a(6,"h5"),m(7),u(8,"number"),r()()),n&2){let e=d(3);l(2),ee(C(3,2,e.variant.Quantity)),l(5),ee(C(8,4,e.variant.DiscountAmount))}}function Io(n,t){if(n&1&&(a(0,"h5",58),m(1),u(2,"number"),r()),n&2){let e=d(3);l(),$e(" ",e.totalBeforeDiscount()*(e.variant.Discount/100)<0?"":"-","",C(2,2,e.totalBeforeDiscount()*(e.variant.Discount/100))," ")}}function Po(n,t){if(n&1&&(a(0,"div",57)(1,"h5",58),m(2),u(3,"number"),r()()),n&2){let e=d(3);l(2),$e(" ",e.variant.Quantity*e.variant.DiscountAmount<0?"":"-","",C(3,2,e.variant.Quantity*e.variant.DiscountAmount)," ")}}function Oo(n,t){if(n&1&&(a(0,"div",59)(1,"div",61)(2,"h5"),m(3,"Grand Total"),r()(),a(4,"div",61)(5,"h5"),m(6),u(7,"number"),r()()()),n&2){let e=d(3);l(6),ee(C(7,1,e.totalAfterDiscount()))}}function To(n,t){if(n&1&&(a(0,"div",47)(1,"div",49)(2,"h4"),m(3,"Discount Simulation"),r(),a(4,"h4",50),m(5),r()(),a(6,"div",51)(7,"div",35)(8,"div",52)(9,"h5"),m(10),u(11,"number"),r(),a(12,"span",53),m(13,"x"),r(),a(14,"h5"),m(15),u(16,"number"),r()(),v(17,So,4,3,"div",54),v(18,Mo,9,6,"div",55),r(),a(19,"div",35)(20,"div",56)(21,"h5"),m(22),u(23,"number"),r()(),a(24,"div",57),v(25,Io,3,4,"h5",58),r(),v(26,Po,4,4,"div",57),r(),v(27,Oo,8,3,"div",59),r()()),n&2){let e=d(2);l(5),E(" ",e.variant==null?null:e.variant.Name," "),l(5),ee(C(11,9,e.variant.Quantity)),l(5),ee(C(16,11,e.variant.UnitPrice)),l(2),_(e.variant.Discount?17:-1),l(),_(e.variant.DiscountAmount>0?18:-1),l(4),ee(C(23,13,e.totalBeforeDiscount())),l(3),_(e.variant.Discount?25:-1),l(),_(e.variant.DiscountAmount>0?26:-1),l(),_(e.variant.DiscountAmount>0||e.variant.Discount>0?27:-1)}}function wo(n,t){if(n&1){let e=U();a(0,"div",12)(1,"div",33)(2,"div",34)(3,"div",35)(4,"strong"),m(5,"Discount %"),r()(),a(6,"div",36)(7,"input",37,2),J("ngModelChange",function(o){O(e);let s=d();return Q(s.variant.Discount,o)||(s.variant.Discount=o),T(o)}),D("ngModelChange",function(){O(e);let o=d();return T(o.onDiscountChange())}),r()()(),a(9,"div",38)(10,"div",35)(11,"strong"),m(12,"Discount Amount"),r()(),a(13,"div",36)(14,"input",39,2),J("ngModelChange",function(o){O(e);let s=d();return Q(s.inputedDiscountAmount,o)||(s.inputedDiscountAmount=o),T(o)}),D("ngModelChange",function(o){O(e);let s=d();return T(s.onDiscountAmountChange(o))}),r()()(),a(16,"div",40)(17,"div",41)(18,"input",42),J("ngModelChange",function(o){O(e);let s=d();return Q(s.isDiscMultipliciedQty,o)||(s.isDiscMultipliciedQty=o),T(o)}),D("ngModelChange",function(){O(e);let o=d();return T(o.onSwitchDiscountTypeChange())}),r()(),a(19,"div",43)(20,"strong"),m(21,"*Quantity"),r(),a(22,"span",44),x(23,"i",45),r()()(),v(24,xo,9,3,"div",46),r(),v(25,To,28,15,"div",47),r()}if(n&2){let e=d();l(7),y("simpleKeyboard",e.keyboard),W("ngModel",e.variant.Discount),y("min",0)("readonly",!e.role.sell.Discount),l(7),y("simpleKeyboard",e.keyboard),W("ngModel",e.inputedDiscountAmount),y("max",e.variant.UnitPrice*e.abs(e.variant.Quantity))("min",0)("readonly",!e.role.sell.Discount),l(4),W("ngModel",e.isDiscMultipliciedQty),l(6),_(e.isDiscMultipliciedQty()?-1:24),l(),_(e.role.product.Cost?25:-1)}}function No(n,t){n&1&&(x(0,"i",67),a(1,"h6"),m(2,"No Image"),r())}function Eo(n,t){if(n&1&&x(0,"img",64),n&2){let e=d(2);y("src",e.variant.ThumbnailUrl,dt)}}function Fo(n,t){if(n&1){let e=U();a(0,"button",80),D("click",function(){O(e);let o=d(),s=d(2);return T(s.setQuantityToMax(o))}),m(1," Place Order "),r()}}function ko(n,t){if(n&1&&(a(0,"tbody")(1,"tr")(2,"th",68),x(3,"i",69),m(4,"Inventory "),r(),a(5,"th",68),x(6,"i",70),m(7),r(),a(8,"th",68),x(9,"i",71),m(10," Diff "),r(),a(11,"th",68),x(12,"i",72),m(13," Action "),r()(),a(14,"tr")(15,"th",73),m(16,"On Hand"),r(),a(17,"td",74),m(18),u(19,"number"),r(),x(20,"td",75)(21,"td",76),r(),a(22,"tr")(23,"th",73),m(24,"Allocated"),r(),a(25,"td",74),m(26),u(27,"number"),r()(),a(28,"tr")(29,"th",73),m(30,"Available"),r(),a(31,"td",74),m(32),u(33,"number"),r()(),a(34,"tr")(35,"th",73),m(36,"ROP"),r(),a(37,"td",74),m(38),u(39,"number"),r(),a(40,"td",58),m(41),u(42,"number"),r()(),a(43,"tr")(44,"th",73),m(45,"Max"),r(),a(46,"td",74),m(47),u(48,"number"),r(),a(49,"td",77),m(50),u(51,"number"),r(),a(52,"td",78),v(53,Fo,2,0,"button",79),r()()()),n&2){let e=t,i=d(2);l(7),E("",i.outletName," "),l(11),E(" ",C(19,12,e.onHand)," "),l(8),E(" ",C(27,14,e.allocated)," "),l(6),E(" ",C(33,16,e.onHand-e.allocated)," "),l(6),E(" ",C(39,18,e.rop)," "),l(3),$e(" ",e.ropDiff>=0?"+":"","",C(42,20,e.ropDiff)," "),l(6),E(" ",C(48,22,e.max)," "),l(3),$e(" ",e.maxDiff>=0?"+":"","",C(51,24,e.maxDiff)," "),l(2),y("ngClass",le(26,uo,i.variant.Quantity==e.max-e.onHand-e.allocated)),l(),_(i.variant.Quantity!=e.max-e.onHand-e.allocated?53:-1)}}function Ao(n,t){if(n&1&&(a(0,"div",13)(1,"div",62)(2,"a",63),v(3,No,3,0)(4,Eo,1,1,"img",64),r()(),a(5,"div",65)(6,"table",66),v(7,ko,54,28,"tbody"),u(8,"async"),r()()()),n&2){let e,i=d();l(2),y("routerLink",Qt(6,mo))("queryParams",le(7,po,i.variant==null?null:i.variant.ID)),l(),_((i.variant==null?null:i.variant.ThumbnailUrl)==null?3:4),l(4),_((e=C(8,4,i.variantStock$))?7:-1,e)}}function Vo(n,t){if(n&1){let e=U();a(0,"POS-tab-serial",81),J("variantChange",function(o){O(e);let s=d();return Q(s.variant,o)||(s.variant=o),T(o)})("isFocusOnSerialInputChange",function(o){O(e);let s=d();return Q(s.isFocusOnSerialInput,o)||(s.isFocusOnSerialInput=o),T(o)})("serialsChange",function(o){O(e);let s=d();return Q(s.serials,o)||(s.serials=o),T(o)}),r()}if(n&2){let e=d();y("disabledEditQty",e.isEditBuyForm)("outletID",e.outletID),W("variant",e.variant)("isFocusOnSerialInput",e.isFocusOnSerialInput)("serials",e.serials),y("isBatchNumber",e.isBatchNumber())}}var yt=class n{constructor(t,e,i,o,s,F){this.dialogRef=t;this.http=i;this.role=o;this.toastr=F;this.config=new Ie,this.config.title=e.variant?.Name??"Add Variant",this.config.customWidth="700px",this.config.noPadding=!0,this.appConfigJSON=e.appConfigJSON,this.unitQtyLabel=this.appConfigJSON.ModuleSell.ProductDialog.UnitQtyLabel,this.numpadVisible=this.appConfigJSON.ModuleSell.NumPadVisible,this.numpadVisible&&(this.keyboard=s.keyboard),this.isEditBuyForm=e.isEdit,this.outletID=e.outletID,this.outletName=e.outletName,this.variant=e.variant?JSON.parse(JSON.stringify(e.variant)):null;let w=this.appConfigJSON?.ModuleSell?.ProductDialog?.QuantityToOneInDialog?1:null;if(this.variant)this.isSerialItem=this.variant.TypeID==9,this.isBatchNumber.set(this.variant.TypeID==4),this.variantStock$=this.getOnInventory(),this.inputedDiscountAmount.set(this.variant.DiscountAmount),this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount();else{this.isCreate=!0,this.variant={Name:"",Quantity:w,UnitQuantity:1,OrderPrice:0,Total:0,Note:"",UnitPrice:0,ThumbnailUrl:"",UOMName:"",TypeID:0,Discount:0,ID:"",DiscountAmount:0,Serial:[],UnitCost:0,MaxOrderPrice:0};let H=this.variantAutocomplete.valueChanges.pipe(A(c=>c.type=="Code"),p(c=>c.str),Y(c=>i.get(Ue.GetVariantByCode,[{key:"Code",value:c},{key:"EntityID",value:this.outletID},{key:"Promotion",value:!0}]).pipe(ve(()=>Re))),p(c=>this.setUnitPrice(c)),p(c=>B(P({},c),{Quantity:w,Total:c.UnitPrice,Discount:c.PriceDiscount}))),M=this.variantAutocomplete.valueChanges.pipe(A(c=>c.type=="ID"),p(c=>c.str),Y(c=>i.get(Ue.GetVariantByID,[{key:"ID",value:c},{key:"EntityID",value:this.outletID},{key:"Promotion",value:!1}]).pipe(ve(()=>Re))),p(c=>this.setUnitPrice(c)),p(c=>B(P({},c),{Quantity:w,Total:c.UnitPrice,Discount:c.PriceDiscount})));mt(H,M).pipe(k(c=>this.setFocusField("quantity")),ae(1)).subscribe(c=>{this.variant=c,this.isSerialItem=this.variant.TypeID==9,this.isBatchNumber.set(this.variant.TypeID==4),this.showInventory=!0,this.variantStock$=this.getOnInventory(),this.inputedDiscountAmount.set(this.variant.DiscountAmount),this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()})}}calculatorTab=ut(ni);cartService=G(Z);variantAutocomplete=new ge;_quantityElement=ut("quantity");variant;variantStock$=Re;isSerialItem=!1;isBatchNumber=se(!1);outletID;outletName;appConfigJSON;numpadVisible;keyboard;isEditBuyForm=!1;unitQtyLabel;config;tabState="Cart";isCreate=!1;showInventory=!1;serials=[];isFocusOnSerialInput=!1;_onGetInventory=new at(void 0);onGetInventory$=this._onGetInventory.asObservable();isDiscMultipliciedQty=se(!0);totalBeforeDiscount=se(0);totalAfterDiscount=se(0);inputedDiscountAmount=se(0);setFocusField(t){t==="quantity"&&this._quantityElement()?.nativeElement?.focus()}onPriceChange(){this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()}onQtyChange(){this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()}onUnitQtyChange(){this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()}onDiscountChange(){this.calculateTotalAfterDiscount(),this.calculateTotalAfterDiscount()}onDiscountAmountChange(t){this.calculateDiscountAmount(t),this.calculateTotalAfterDiscount()}onSwitchDiscountTypeChange(){this.calculateDiscAmountOnSwitch(),this.calculateTotalAfterDiscount()}calculateDiscountAmount(t){this.isDiscMultipliciedQty()?this.variant.DiscountAmount=t:this.variant.DiscountAmount=t/this.getQty()}calculateDiscAmountOnSwitch(){let t=this.variant.DiscountAmount,e=this.getQty();this.isDiscMultipliciedQty()?this.variant.DiscountAmount=t*e:this.variant.DiscountAmount=t/e}calculateTotalBeforeDiscount(){let t=this.variant.UnitPrice*this.getQty();this.totalBeforeDiscount.set(t)}calculateTotalAfterDiscount(){let t=this.totalBeforeDiscount()-this.getTotalDiscPercentage();this.validateDiscountAmount(t);let e=this.getTotalDiscAmount(),i=t-e;this.totalAfterDiscount.set(i)}validateDiscountAmount(t){let e=this.variant.Quantity%1===0;t>0&&this.variant.DiscountAmount>t&&e&&(this.variant.DiscountAmount=t)}getTotalDiscPercentage(){return this.variant.Discount?this.totalBeforeDiscount()*this.variant.Discount/100:0}getTotalDiscAmount(){return this.variant.DiscountAmount?this.variant.DiscountAmount*this.getQty():0}getQty(){return this.checkQuantityIsNull(),this.variant.Quantity*this.variant.UnitQuantity}onTabChange(t){this.tabState=t,t==="Calculator"&&(console.log(this.calculatorTab()?.priceInputNativeElement),setTimeout(()=>this.calculatorTab()?.priceInputNativeElement?.focus(),100))}onSave(){if(!this.isFocusOnSerialInput){if(this.checkQuantityIsNull(),this.isSerialItem||this.isBatchNumber()){if(this.serials.length){let o=this.serials.map(s=>({Quantity:1,Number:s}));this.variant.Serial=[...this.variant.Serial,...o]}let e=this.variant.Serial?.map(o=>o.Quantity).reduce((o,s)=>o+s,0)??0,i=this.variant.Quantity;e!=i&&this.toastr.warning("Serial Quantity must be equal to Variant Quantity","Warning"),this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()}if(!this.cartService.validatePriceMaximum(this.variant))return;this.dialogRef.close(B(P({},this.variant),{Total:this.totalAfterDiscount()}))}}close(){this.dialogRef.close()}checkQuantityIsNull(){(this.variant.Quantity==null||this.variant.Quantity==0)&&(this.variant.Quantity=1)}setQuantityToMax(t){let e=t.onHand-t.allocated;t.max>=e?(this.variant.Quantity=t.max-e,this.toastr.success("Qty adjusted to Max Inventory","Success"),this.onSave()):this.toastr.warning("Your Inventory Available is more than Max Inventory","Warning")}getOnInventory(){return this.onGetInventory$.pipe(qi((t,e)=>t?Ke(t):this.http.get(Ue.GetVariantStockByID,[{key:"ID",value:this.variant.ID},{key:"EntityID",value:this.outletID}]).pipe(p(i=>{let o=i.OnHand-i.Allocated;return{onHand:i.OnHand,allocated:i.Allocated,rop:i.ROP,max:i.Max,maxDiff:i.Max-i.OnHand-o,ropDiff:i.ROP-i.OnHand-o}})),null),p(t=>t),ae(1))}setUnitPrice(t){let e=P({},t);return I.IsNotEmpty(t.OrderPrice)?e.UnitPrice=t.OrderPrice:e.UnitPrice=t.UnitCost,e}abs(t){return Math.abs(t)}ngOnDestroy(){this.cartService.priceMaximumRestrictionWarning.set("")}static \u0275fac=function(e){return new(e||n)(g(Oe),g(ke),g(pe),g(Ce),g(qn),g(Le))};static \u0275cmp=V({type:n,selectors:[["POS-modal-variant"]],viewQuery:function(e,i){e&1&&St(i.calculatorTab,ni,5)(i._quantityElement,co,5),e&2&&Mt(2)},decls:19,vars:20,consts:[["quantity",""],["price",""],["discount",""],[3,"onOk","onCancel","onClose","config"],[1,"container","w-100","h-100"],[1,"row","border-bottom","mx-5","mt-8"],["data-cy","input_sell",1,"btn","btn-link",3,"click","ngClass"],["data-cy","discount",1,"btn","btn-link",3,"ngClass"],["data-cy","product",1,"btn","btn-link",3,"ngClass"],["data-cy","serial",1,"btn","btn-link",3,"ngClass"],["data-cy","calculator",1,"btn","btn-link",3,"click","ngClass"],[1,"mx-8"],[1,"row"],[1,"row","py-8"],[3,"disabledEditQty","outletID","variant","isFocusOnSerialInput","serials","isBatchNumber"],[3,"hidden"],["priceLabel","Cost",3,"discountTotal","priceTotal","qtyTotal","noteChanges","price","discount","quantity","notes","variantName"],["data-cy","discount",1,"btn","btn-link",3,"click","ngClass"],["data-cy","product",1,"btn","btn-link",3,"click","ngClass"],["data-cy","serial",1,"btn","btn-link",3,"click","ngClass"],[1,"bg-gradient-warning","p-4","justify-content-center","align-items-center","d-flex","gap-2",2,"margin-top","12px","border-radius","8px"],[1,"py-8"],[1,"col-auto","mb-4","pe-0",2,"width","82px"],["id","txtCartQuantity","keyboardType","number","type","text","autoNum","",1,"form-control","input-numpad",2,"height","38px",3,"ngModelChange","simpleKeyboard","decimalPlaces","ngModel","disabled"],[1,"col-auto","pe-0",2,"width","82px"],[1,"col-auto","pe-0",2,"width","112px"],[1,"col","tinymce"],["height","210px",3,"ngModelChange","ngModel"],[3,"innerHTML"],[1,"col"],[3,"formControl","isOnModalVariant"],["type","text","autoNum","",1,"form-control","input-numpad",2,"height","38px",3,"ngModelChange","preventNegative","decimalPlaces","ngModel"],["id","inputPrice","keyboardType","number","type","text","autoNum","",1,"form-control",2,"height","38px",3,"ngModelChange","simpleKeyboard","ngModel"],[1,"col-6","border-end","py-8"],[1,"row","d-flex","align-items-center"],[1,"col-6"],[1,"col-auto","ps-0"],["id","inputDiscount","keyboardType","number","type","text","autoNum","","percentage","","decimalPlaces","2",1,"form-control",2,"width","112px","height","38px",3,"ngModelChange","simpleKeyboard","ngModel","min","readonly"],[1,"row","d-flex","align-items-center","mt-6"],["id","inputDiscount","keyboardType","number","type","text","autoNum","",1,"form-control",2,"width","112px","height","38px",3,"ngModelChange","simpleKeyboard","ngModel","max","min","readonly"],[1,"d-flex","align-items-center","mt-4"],[1,"form-check","form-switch","form-switch-lg","ms-1","mt-1"],["type","checkbox","id","flexSwitchCheckDefault",1,"form-check-input",3,"ngModelChange","ngModel"],[1,"ms-4"],["matTooltipPosition","above","matTooltip",`Use the final discount amount if you want to discount the price of the total
24
- quantity of the product. The nominal will be calculated automatically and filled in the discount amount box.`,1,"pointer"],[1,"fa-solid","fa-info-circle","ms-2"],[1,"row","d-flex","align-items-center","justify-content-start","mt-4"],[1,"col-6","py-8"],[1,"border","ps-6",2,"height","38px","padding-top","10px","width","112px","background-color","#e9ecef"],[1,"w-100","text-center"],[1,"text-start","mt-12"],[1,"row","mt-12"],[1,"w-100","d-flex","align-items-center","justify-content-end"],[1,"mx-1","fw-bold"],[1,"d-flex","align-items-center","justify-content-end","mt-2"],[1,"d-flex","align-items-center","justify-content-end","mt-2","text-danger"],[1,"w-100","d-flex","justify-content-end"],[1,"w-100","d-flex","justify-content-end","mt-2"],[1,"text-danger"],[1,"row","border-top","mx-0","px-0","mt-4"],[1,"fw-bold","text-danger"],[1,"col-6","d-flex","justify-content-end","mt-4"],[1,"col-sm-4","d-flex","justify-content-center","flex-column","align-items-center","text-body-secondary"],["target","_blank",2,"color","inherit",3,"routerLink","queryParams"],[1,"border","rounded",3,"src"],[1,"col-sm-8"],[1,"table","table-bordered","text-center","inventory-table","w-auto"],["aria-hidden","true",1,"fa-solid","fa-image","fa-5x"],[1,"bg-light-orange"],["aria-hidden","true",1,"fa-box-archive","fa-solid","fa-1x","me-2"],["aria-hidden","true",1,"fa-solid","fa-house","fa-1x","me-2"],["aria-hidden","true",1,"fa-solid","fa-plus-minus","fa-1x","me-2"],["aria-hidden","true",1,"fa-solid","fa-sliders","fa-1x","me-2"],[1,"table-light","text-start"],[1,"text-end"],["rowspan","3",1,"table-light"],["rowspan","4",1,"table-light"],[1,"text-success"],[3,"ngClass"],["type","button","matTooltipPosition","above","matTooltip","Adjust Bought Qty to max Inventory",1,"btn","btn-success","btn-sm","me-2",2,"font-size","12px"],["type","button","matTooltipPosition","above","matTooltip","Adjust Bought Qty to max Inventory",1,"btn","btn-success","btn-sm","me-2",2,"font-size","12px",3,"click"],[3,"variantChange","isFocusOnSerialInputChange","serialsChange","disabledEditQty","outletID","variant","isFocusOnSerialInput","serials","isBatchNumber"]],template:function(e,i){e&1&&(a(0,"modal-material",3),D("onOk",function(){return i.onSave()})("onCancel",function(){return i.close()})("onClose",function(){return i.close()}),a(1,"content")(2,"div",4)(3,"div",5)(4,"div")(5,"a",6),D("click",function(){return i.onTabChange("Cart")}),m(6," Cart "),r(),v(7,fo,2,3,"a",7),v(8,go,2,3,"a",8),v(9,Co,2,4,"a",9),a(10,"a",10),D("click",function(){return i.onTabChange("Calculator")}),m(11," Calculator "),r()()(),a(12,"div",11),v(13,Do,15,10),v(14,wo,26,12,"div",12),v(15,Ao,9,9,"div",13),v(16,Vo,1,6,"POS-tab-serial",14),a(17,"div",15)(18,"item-calculator-tab",16),D("discountTotal",function(s){return i.variant.Discount=s,i.onDiscountChange()})("priceTotal",function(s){return i.variant.UnitPrice=s,i.onPriceChange()})("qtyTotal",function(s){return i.variant.Quantity=s,i.onQtyChange()})("noteChanges",function(s){return i.variant.Note=s}),r()()()()()()),e&2&&(y("config",i.config),l(5),y("ngClass",le(16,Rt,i.tabState=="Cart")),l(2),_(!i.isCreate||i.showInventory?7:-1),l(),_(!i.isCreate||i.showInventory?8:-1),l(),_(i.isSerialItem||i.isBatchNumber()?9:-1),l(),y("ngClass",le(18,Rt,i.tabState=="Calculator")),l(3),_(i.tabState=="Cart"?13:-1),l(),_(i.tabState=="Discount"?14:-1),l(),_(i.tabState=="Product"?15:-1),l(),_(i.tabState=="Serial"?16:-1),l(),y("hidden",i.tabState!="Calculator"),l(),y("price",i.variant.UnitPrice)("discount",i.variant.Discount)("quantity",i.variant.Quantity)("notes",i.variant.Note)("variantName",i.variant==null?null:i.variant.Name))},dependencies:[te,Xe,ti,Fe,Me,un,de,Ee,wt,Pe,ft,Tn,qt,Gt,Kn,oi,tt,et,Qn,ni,Se,ye],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}p-chips[_ngcontent-%COMP%] ul.p-inputtext{width:570px;max-width:570px;border:1px solid #C8D3DF}p-chips[_ngcontent-%COMP%] ul.p-inputtext li.p-chips-input-token>input[type=text]{border:none}p-chips[_ngcontent-%COMP%] .p-chips .p-chips-multiple-container:not(.p-disabled):hover{border:1px solid #C8D3DF}p-chips[_ngcontent-%COMP%] .p-chips-multiple-container{display:inline-block}p-chips[_ngcontent-%COMP%] .p-chips-multiple-container .p-chips-token{margin:2px;background:#96bf48}.inventory-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%], .inventory-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{line-height:6px!important}.btn-link[_ngcontent-%COMP%]{padding-top:0;color:#868686;padding-bottom:8px;border-radius:unset;font-family:Roboto Slab,serif}.btn-link.selected[_ngcontent-%COMP%]{color:#3b3b3b;border-bottom:4px solid #07a519}.form-check-input[_ngcontent-%COMP%]{clear:left}.form-switch.form-switch-lg[_ngcontent-%COMP%] .form-check-input[_ngcontent-%COMP%]{height:1.5rem;width:2.75rem;border-radius:3rem}.form-check-input[_ngcontent-%COMP%]:focus{border-color:#89b03e!important}.form-check-input[_ngcontent-%COMP%]:checked{border-color:#89b03e!important;background-color:#89b03e!important}"],changeDetection:0})};function Bo(n,t){if(n&1&&(a(0,"td",7),m(1),r()),n&2){let e=d().$index;l(),E("",e+1,".")}}function $o(n,t){if(n&1&&(a(0,"div",10),x(1,"img",28),r()),n&2){let e=d().$implicit;l(),y("src",e.ThumbnailUrl,dt)}}function jo(n,t){n&1&&(a(0,"div",11),x(1,"i",29),r())}function Lo(n,t){if(n&1&&(a(0,"span",20),m(1),u(2,"quantityFraction"),r()),n&2){let e=d().$implicit;l(),E(" ",C(2,1,e.Quantity)," ")}}function Uo(n,t){n&1&&(a(0,"span",21),m(1,"x"),r())}function Qo(n,t){if(n&1&&(a(0,"span",22),m(1),r()),n&2){let e=d().$implicit;l(),ee(e.UOMName)}}function Wo(n,t){if(n&1&&(a(0,"div",9)(1,"small",30),m(2," @ "),r(),a(3,"small",30),m(4),u(5,"number"),r()()),n&2){let e=d().$implicit;d();let i=Tt(2);l(4),E(" ",pt(5,1,e.VariantUnitQuantity,"1.0-"+i)," ")}}function Jo(n,t){if(n&1&&(a(0,"small",24),m(1),r()),n&2){let e=d().$implicit;l(),ee(e.Sub_UOMName)}}function Ho(n,t){if(n&1&&(a(0,"span",24),m(1),u(2,"number"),r()),n&2){let e=d().$implicit;l(),ee(C(2,1,e.UnitQuantity))}}function Go(n,t){if(n&1&&(a(0,"small",31),m(1),u(2,"number"),r()),n&2){let e=d(2).$implicit;l(),E(" @",C(2,1,e.UnitPrice/e.VariantUnitQuantity)," ")}}function qo(n,t){if(n&1&&(a(0,"div",18)(1,"span",20),m(2),u(3,"number"),r(),v(4,Go,3,3,"small",31),r()),n&2){let e=d().$implicit;l(2),E(" ",C(3,2,e.UnitPrice)," "),l(2),_(e.VariantUnitQuantity&&e.VariantUnitQuantity!=1?4:-1)}}function Ko(n,t){if(n&1&&(a(0,"div"),m(1),u(2,"number"),r()),n&2){let e=d().$implicit;l(),E("-",C(2,1,e.Discount),"%")}}function zo(n,t){if(n&1&&(a(0,"div"),m(1),u(2,"number"),r()),n&2){let e=d().$implicit;l(),E("-",C(2,1,e.DiscountAmount))}}function Yo(n,t){if(n&1&&(m(0),u(1,"number")),n&2){let e=d().$implicit;E(" ",pt(1,1,e.Total,"1.0-4")," ")}}function Xo(n,t){n&1&&m(0," - ")}function Zo(n,t){if(n&1){let e=U();a(0,"tr",6),D("contextmenu",function(o){let s=O(e).$index;return d(2).onContextMenu(s),T(o.preventDefault())})("click",function(o){let s=O(e),F=s.$implicit,f=s.$index;return d(2).update(F,f),T(o.stopPropagation())}),v(1,Bo,2,1,"td",7),a(2,"td",8)(3,"div",9),v(4,$o,2,1,"div",10)(5,jo,2,0,"div",11),a(6,"div",12)(7,"div"),m(8),r(),a(9,"span",13),m(10),r(),x(11,"app-serial-note",14)(12,"small",15),r()()(),a(13,"td",16)(14,"div",17)(15,"div",18)(16,"div",19),v(17,Lo,3,3,"span",20),v(18,Uo,2,0,"span",21),v(19,Qo,2,1,"span",22),r(),a(20,"div",23),v(21,Wo,6,4,"div",9),v(22,Jo,2,1,"small",24),r()(),v(23,Ho,3,3,"span",24),r()(),a(24,"td",16),v(25,qo,5,4,"div",18),r(),a(26,"td",25),v(27,Ko,3,3,"div"),v(28,zo,3,3,"div"),r(),a(29,"td",16),v(30,Yo,2,4)(31,Xo,1,0),r(),a(32,"td",26)(33,"i",27),D("click",function(o){let s=O(e).$index;return d(2).deleteVariant(s),T(o.stopPropagation())}),r()()()}if(n&2){let e,i,o=t.$implicit,s=d(2);y("cdkDragDisabled",!s.enabledDragDrop),l(),_((e=s.appConfigJSON())!=null&&e.ModuleBuy.Grid.RowNumberVisible?1:-1),l(),Pt("ps-0",(i=s.appConfigJSON())==null?null:i.ModuleBuy.Grid.RowNumberVisible),l(2),_(o.ThumbnailUrl?4:5),l(4),ee(o.Name),l(2),ee(o.Code),l(),y("serials",o.Serial),l(),y("innerHtml",o.Note,$t),l(5),_(s.shouldShowBaseQuantity(o)?17:-1),l(),_(s.shouldShowUnitMultiplier(o)?18:-1),l(),_(s.shouldShow("UOMVisible")?19:-1),l(2),_(s.shouldShowVariantQty(o)?21:-1),l(),_(s.shouldShow("SubUOMVisible")?22:-1),l(),_(s.shouldShowUnitMultiplier(o)?23:-1),l(2),_(s.shouldShowUnitPrice(o,s.role==null||s.role.product==null?null:s.role.product.Cost)?25:-1),l(2),_(o.Discount?27:-1),l(),_(o.DiscountAmount?28:-1),l(2),_(s.role.product.Cost?30:31)}}function ea(n,t){if(n&1){let e=U();rt(0),u(1,"async"),rt(2),a(3,"div",1)(4,"table",3)(5,"tbody",4),D("cdkDropListDropped",function(o){O(e);let s=d();return T(s.drop(o))}),we(6,Zo,34,19,"tr",5,Be),r()()()}if(n&2){let e=d(),i=It(3),o=C(1,1,e.appConfig$);l(2),Ot((o==null||o.ModuleSell==null||o.ModuleSell.ProductDialog==null?null:o.ModuleSell.ProductDialog.DecimalPlaceDigit)??3),l(),y("cdkContextMenuTriggerFor",i),l(3),Ne(e.cart())}}function ta(n,t){n&1&&(a(0,"div",2)(1,"div",32)(2,"div",33)(3,"div",34)(4,"div",35),x(5,"i",36),r(),a(6,"div",37)(7,"span"),m(8,"Empty Cart"),r(),x(9,"br"),a(10,"span"),m(11,"Add products to the cart"),r(),x(12,"br"),a(13,"span"),m(14,"or scan barcode"),r()()()()()())}function ia(n,t){if(n&1){let e=U();a(0,"button",40),D("click",function(){O(e);let o=d(2);return T(o.onReturn())}),x(1,"i",42),m(2," Return "),r()}if(n&2){let e=d(2);y("disabled",e.contextMenuQuantity<0)}}function na(n,t){if(n&1){let e=U();a(0,"div",38),v(1,ia,3,1,"button",39),a(2,"button",40),D("click",function(){O(e);let o=d();return T(o.onPurchase())}),x(3,"i",41),m(4," Purchase "),r()()}if(n&2){let e=d();l(),_(e.role.sell.Return?1:-1),l(),y("disabled",e.contextMenuQuantity>0)}}var si=class n{constructor(t,e,i,o,s,F){this.cartService=t;this.matDialog=e;this.role=i;this.form=o;this.sf=F;this.initDragDropEnabled()}cart=N([]);appConfigJSON=N(void 0);isEdit=N(!1);outletID=N("");outletName=N("");RFIDService=G(gt);outletService=G(z);loadService=G(ue);enabledDragDrop=!0;onOpenContextMenuIndex=-1;appConfig$=this.loadService.appConfigJSON$;ngOnInit(){this.outletService.outlet.valueChanges.pipe(Y(t=>this.RFIDService.processGroupedData(t.ID)),k(t=>this.cartService.addCartRFID(t))).subscribe()}initDragDropEnabled(){I.isMobileDevice&&(this.enabledDragDrop=!1)}isSignificantQty(t){return t>1||t<=-1}shouldShowBaseQuantity(t){return t.Quantity!=1||t.UnitQuantity>1||t.VariantUnitQuantity>1}shouldShowUnitMultiplier(t){return t.UnitQuantity>1}shouldShowPriceMultiplier(t,e){return this.isSignificantQty(t.Quantity)&&e}shouldShowUnitPrice(t,e){let i=t.Discount>0||t.DiscountAmount>0;return(this.isSignificantQty(t.Quantity)||i)&&e}shouldShowVariantQty(t){return t.VariantUnitQuantity>1}shouldShow(t){return!!this.appConfigJSON()?.ModuleBuy?.Grid?.[t]}deleteVariant(t){this.cartService.deleteVariant(t)}drop(t){this.cartService.dragDropCart(t)}onContextMenu(t){this.onOpenContextMenuIndex=t}get contextMenuQuantity(){return this.cart()?.[this.onOpenContextMenuIndex]?.Quantity??null}onReturn(){this.cartService.returnVariant(this.onOpenContextMenuIndex)}onPurchase(){this.cartService.purchaseVariant(this.onOpenContextMenuIndex)}update(t,e){let i=P({},t);this.matDialog.open(yt,{data:{variant:i,appConfigJSON:this.appConfigJSON(),isEdit:this.isEdit(),outletID:this.outletID(),outletName:this.outletName(),deliveryEntityID:this.form.fulfillmentResult.value.deliveryEntityID}}).afterClosed().pipe(A(o=>!!o)).subscribe(o=>{this.cartService.updateVariant(o,e),this.sf.searchFilterNativeEl.focus()})}static \u0275fac=function(e){return new(e||n)(g(Z),g(ie),g(Ce),g(z),g(Zt),g(Vt))};static \u0275cmp=V({type:n,selectors:[["POS-cart-display"]],inputs:{cart:[1,"cart"],appConfigJSON:[1,"appConfigJSON"],isEdit:[1,"isEdit"],outletID:[1,"outletID"],outletName:[1,"outletName"]},decls:4,vars:1,consts:[["context_menu",""],[3,"cdkContextMenuTriggerFor"],[1,"row","g-0","h-100"],[1,"table","table-borderless"],["cdkDropList","",3,"cdkDropListDropped"],["cdkDrag","",1,"border-bottom",3,"cdkDragDisabled"],["cdkDrag","",1,"border-bottom",3,"contextmenu","click","cdkDragDisabled"],[2,"width","10px"],[2,"width","50%"],[1,"d-flex"],[1,"ratio","ratio-1x1",2,"width","55px"],[1,"item-image","d-flex","justify-content-center","align-items-center","text-center","fs-1"],[1,"ms-4","d-flex","flex-column","justify-content-center",2,"line-height","18px"],[1,"fw-normal","fs-6","text-muted"],[3,"serials"],["title","Note",1,"special-TinyMCE","m-0","fst-italic","d-block",3,"innerHtml"],[1,"text-end"],[1,"d-flex","fw-normal","gap-2","align-items-center"],[1,"d-flex","flex-column"],[1,"d-flex","align-items-center"],[1,"fs-5","no-leading"],[1,"fs-6","ms-1","no-leading"],[1,"fs-5","ms-1","no-leading"],[1,"d-flex","gap-1"],[1,"fs-5"],[1,"text-end","text-danger"],[1,"text-end",2,"width","75px"],[1,"fa-solid","fa-trash","fs-4","text-danger","pointer",3,"click"],[1,"item-image",3,"src"],[1,"fa-solid","fa-image",2,"color","#b4b4b4c2"],["title","Variant Unit Quantity",1,"fs-5"],[2,"font-size","9px"],[1,"col-12"],[1,"d-flex","justify-content-center","align-items-center","h-100"],[1,"row"],[1,"col-12","d-flex","justify-content-center"],[1,"fa-regular","fa-cart-arrow-up","text-secondary",2,"font-size","110px"],[1,"col-12","justify-content-center","text-center","mt-5","empty-cart-description","text-secondary","headings-font-family"],["cdkMenu","",1,"example-menu"],["cdkMenuItem","",1,"example-menu-item",3,"disabled"],["cdkMenuItem","",1,"example-menu-item",3,"click","disabled"],[1,"fa-solid","fa-plus","me-3"],[1,"fa-solid","fa-minus","me-3"]],template:function(e,i){e&1&&(v(0,ea,8,4,"div",1)(1,ta,15,0,"div",2),kt(2,na,5,2,"ng-template",null,0,Wt)),e&2&&_(i.cart().length?0:1)},dependencies:[te,xn,Dn,_n,Gn,Jn,Wn,Hn,Un,Se,ye,Xt],styles:[".item-image[_ngcontent-%COMP%]{height:50px;width:56px;display:block;border:solid 1px #dddddd;border-radius:5px;object-fit:contain}.example-menu[_ngcontent-%COMP%]{display:inline-flex;flex-direction:column;min-width:180px;max-width:280px;background-color:#fff;padding:6px 0}.example-menu-item[_ngcontent-%COMP%]{background-color:transparent;cursor:pointer;border:none;-webkit-user-select:none;user-select:none;min-width:64px;line-height:36px;padding:0 16px;display:flex;align-items:center;flex-direction:row;flex:1}.example-menu-item[_ngcontent-%COMP%]:hover{background-color:#f5f5f5}.example-menu-item[_ngcontent-%COMP%]:active{background-color:#dcdcdc}.table[_ngcontent-%COMP%] > [_ngcontent-%COMP%]:not(caption) > *[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]{padding:12px 10px} .cdk-menu.cdk-menu-group.example-menu{box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.empty-cart-description[_ngcontent-%COMP%]{font-size:14px;font-weight:500;color:#c7c7c7}small[_ngcontent-%COMP%]{font-size:9px!important;margin:0}.no-leading[_ngcontent-%COMP%]{line-height:1}"],changeDetection:0})};var ci=class n{constructor(t,e){this.dialogRef=t;this.data=e;this.config.title="Return",this.invoiceNumber=e.invoiceNumber}config=new Ie;invoiceNumber;ok(){this.dialogRef.close(this.invoiceNumber)}static \u0275fac=function(e){return new(e||n)(g(Oe),g(ke))};static \u0275cmp=V({type:n,selectors:[["POS-modal-return-invoice"]],decls:6,vars:2,consts:[[3,"onOk","onCancel","onClose","config"],[1,"form-floating-outline","m-0"],["type","text","id","invoiceNumber","name","invoiceNumber",1,"form-control",3,"ngModelChange","ngModel"],["for","invoiceNumber"]],template:function(e,i){e&1&&(a(0,"modal-material",0),D("onOk",function(){return i.ok()})("onCancel",function(){return i.dialogRef.close()})("onClose",function(){return i.dialogRef.close()}),a(1,"content")(2,"div",1)(3,"input",2),J("ngModelChange",function(s){return Q(i.invoiceNumber,s)||(i.invoiceNumber=s),s}),r(),a(4,"label",3),m(5,"Supplier Bill"),r()()()()),e&2&&(y("config",i.config),l(3),W("ngModel",i.invoiceNumber))},dependencies:[te,Fe,Me,de,Ee,Pe],encapsulation:2})};var mi=class n{constructor(t){this.matDialog=t}invoiceNumber;disabled=!1;onChange=t=>{};onTouched=()=>{};writeValue(t){this.invoiceNumber=t}registerOnChange(t){this.onChange=t}registerOnTouched(t){this.onTouched=t}setDisabledState(t){this.disabled=t}openModalReturnInvoice(){return oe(this,null,function*(){this.matDialog.open(ci,{data:{invoiceNumber:this.invoiceNumber}}).afterClosed().pipe(A(t=>!!t)).subscribe(t=>{this.invoiceNumber=t,this.onChange(this.invoiceNumber)})})}static \u0275fac=function(e){return new(e||n)(g(ie))};static \u0275cmp=V({type:n,selectors:[["POS-return-invoice"]],features:[je([{provide:Ze,multi:!0,useExisting:n}])],decls:1,vars:0,consts:[["icon","fa-solid fa-file-invoice","label","Return Bill",3,"click"]],template:function(e,i){e&1&&(a(0,"POS-dropdown-item-more-action",0),D("click",function(){return i.openModalReturnInvoice()}),r())},dependencies:[zt,Qe],encapsulation:2})};var di=class n{constructor(t){this.cart=t}returnCart(){this.cart.returnCart()}static \u0275fac=function(e){return new(e||n)(g(Z))};static \u0275cmp=V({type:n,selectors:[["POS-return-cart"]],decls:1,vars:0,consts:[["icon","fa-cart-shopping fa-solid","label","Return Cart",3,"click"]],template:function(e,i){e&1&&(a(0,"POS-dropdown-item-more-action",0),D("click",function(){return i.returnCart()}),r())},dependencies:[Qe],encapsulation:2})};var pi=class n{constructor(t){this.cart=t}clearCart(){this.cart.clearCart()}static \u0275fac=function(e){return new(e||n)(g(Z))};static \u0275cmp=V({type:n,selectors:[["POS-clear-cart"]],decls:1,vars:0,consts:[["icon","fa-trash fa-solid","label","Clear",3,"click"]],template:function(e,i){e&1&&(a(0,"POS-dropdown-item-more-action",0),D("click",function(){return i.clearCart()}),r())},dependencies:[Qe],encapsulation:2})};var ui=class n{constructor(t,e){this.matDialog=t;this.cart=e}appConfigJSON=N(void 0);isEditBuyForm=N(!1);outletID=N("");outletName=N("");addVariant(){return oe(this,null,function*(){this.matDialog.open(yt,{data:{appConfigJSON:this.appConfigJSON(),isEdit:this.isEditBuyForm(),outletID:this.outletID(),outletName:this.outletName()}}).afterClosed().pipe(A(t=>!!t)).subscribe(t=>this.cart.addVariant(t))})}static \u0275fac=function(e){return new(e||n)(g(ie),g(Z))};static \u0275cmp=V({type:n,selectors:[["POS-add-variant"]],inputs:{appConfigJSON:[1,"appConfigJSON"],isEditBuyForm:[1,"isEditBuyForm"],outletID:[1,"outletID"],outletName:[1,"outletName"]},decls:1,vars:0,consts:[["icon","fa-circle-plus fa-solid","label","Add",3,"click"]],template:function(e,i){e&1&&(a(0,"POS-dropdown-item-more-action",0),D("click",function(){return i.addVariant()}),r())},dependencies:[Qe],encapsulation:2,changeDetection:0})};var fi=class n{constructor(t,e){this.matDialog=t;this.cart=e}outletID=N("");uploadCart(){return oe(this,null,function*(){this.matDialog.open(Xn,{data:{sampleUrl:cn.files.csv.buy_import,outletID:this.outletID(),fileEndpoint:"/API/Buy/UploadCsvV2",useUppy:!0}}).afterClosed().pipe(A(t=>!!t),p(t=>t.map(e=>B(P({},e.Variant),{UnitPrice:e.Cost,Total:e.Cost*e.Quantity*(1-e.Discount/100)-e.DiscountAmount,Quantity:e.Quantity,Serial:e.Serial,Note:e.Note,Discount:e.Discount,DiscountAmount:e.DiscountAmount})))).subscribe(t=>this.cart.uploadCart(t))})}static \u0275fac=function(e){return new(e||n)(g(ie),g(Z))};static \u0275cmp=V({type:n,selectors:[["POS-upload-cart"]],inputs:{outletID:[1,"outletID"]},decls:1,vars:0,consts:[["icon","fa-upload fa-solid","label","Upload",3,"click"]],template:function(e,i){e&1&&(a(0,"POS-dropdown-item-more-action",0),D("click",function(){return i.uploadCart()}),r())},dependencies:[Qe],encapsulation:2,changeDetection:0})};var oa=["serialInput"],gi=class n{constructor(t,e,i){this.dialogRef=t;this.toastr=e;this.cart=i;this.modalConfig.title="Scan Serial",this.modalConfig.customWidth="350px",this.modalConfig.hideOk=!0,this.modalConfig.hideCancel=!0}serialInputEl=ut("serialInput");modalConfig=new Ie;serial;ngOnInit(){}onKeyDown(t){t.key=="Enter"&&(I.IsNotEmpty(this.serial)?(this.cart.addVariantThroughSerial(this.serial),this.serial=null):this.toastr.warning("Serial Can`t be empty","Warning!"),this.setFocusInput())}setFocusInput(){let t=this.serialInputEl();t&&setTimeout(()=>{t?.nativeElement?.focus()},500)}static \u0275fac=function(e){return new(e||n)(g(Oe),g(Le),g(Z))};static \u0275cmp=V({type:n,selectors:[["POS-modal-scan-serial"]],viewQuery:function(e,i){e&1&&St(i.serialInputEl,oa,5),e&2&&Mt()},decls:7,vars:2,consts:[["serialInput",""],[3,"onClose","config"],[1,"input-group","mt-3"],["type","text","placeholder","Input Product By Serial","aria-label","Serial",1,"form-control",3,"ngModelChange","keydown","ngModel"],[1,"input-group-text"],[1,"fa-solid","fa-barcode","fs-4"]],template:function(e,i){if(e&1){let o=U();a(0,"modal-material",1),D("onClose",function(){return i.dialogRef.close()}),a(1,"content")(2,"div",2)(3,"input",3,0),J("ngModelChange",function(F){return O(o),Q(i.serial,F)||(i.serial=F),T(F)}),D("keydown",function(F){return i.onKeyDown(F)}),r(),a(5,"span",4),x(6,"i",5),r()()()()}e&2&&(y("config",i.modalConfig),l(3),W("ngModel",i.serial))},dependencies:[te,Fe,Me,de,Ee,Pe],styles:["input[_ngcontent-%COMP%]{height:55px;border-bottom-left-radius:4px;border-top-left-radius:4px}span.input-group-text[_ngcontent-%COMP%]{border-bottom-right-radius:4px;border-top-right-radius:4px}"],changeDetection:0})};var Ci=class n{constructor(t,e){this.matDialog=t;this.viewContainerRef=e}scanSerial(){return oe(this,null,function*(){this.matDialog.open(gi,{viewContainerRef:this.viewContainerRef})})}static \u0275fac=function(e){return new(e||n)(g(ie),g(Xi))};static \u0275cmp=V({type:n,selectors:[["POS-scan-serial"]],decls:1,vars:0,consts:[["icon","fa-barcode-read fa-solid","label","Serial",3,"click"]],template:function(e,i){e&1&&(a(0,"POS-dropdown-item-more-action",0),D("click",function(){return i.scanSerial()}),r())},dependencies:[Qe],encapsulation:2})};var aa=(n,t)=>({red:n,green:t}),yi=class n{RFIDService=G(gt);matDialog=G(ie);onOpenModal(){return oe(this,null,function*(){let t=this.RFIDService.baseUrl(),e=this.RFIDService.bufferTime;this.RFIDService.isConnected.pipe(ht(1),Y(i=>this.matDialog.open(eo,{data:{url:t,bufferTime:e,isConnected:i}}).afterClosed()),A(i=>!!i)).subscribe(i=>{"url"in i&&i.url?(this.RFIDService.bufferTime=i.bufferTime,this.RFIDService.intializeWebSocket(i.url)):"disconnect"in i&&i.disconnect&&this.RFIDService.disconnectWebSocket()})})}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=V({type:n,selectors:[["pos-rfid-buy-action"]],decls:7,vars:8,consts:[[1,"dropdown-item","px-1","d-flex",3,"click"],["aria-hidden","true",1,"fa-solid","fa-wifi","fs-2"],[1,"pe-0","ps-4","fs-6","cursor-pointer"],[1,"blob",2,"position","absolute","top","0","right","0",3,"ngClass"]],template:function(e,i){e&1&&(a(0,"div",0),D("click",function(){return i.onOpenModal()}),x(1,"i",1),a(2,"label",2),m(3,"Connect RFID"),r(),x(4,"div",3),u(5,"async"),u(6,"async"),r()),e&2&&(l(4),y("ngClass",lt(5,aa,!C(5,1,i.RFIDService.isConnected),C(6,3,i.RFIDService.isConnected))))},dependencies:[te,Xe,Se],styles:[".disabled[_ngcontent-%COMP%]{color:gray;pointer-events:none;cursor:not-allowed}.blob[_ngcontent-%COMP%]{background:#000;border-radius:50%;box-shadow:0 0 #000;height:15px;width:15px;transform:scale(1);animation:_ngcontent-%COMP%_pulse-black 2s infinite}@keyframes _ngcontent-%COMP%_pulse-black{0%{transform:scale(.95);box-shadow:0 0 #000000b3}70%{transform:scale(1);box-shadow:0 0 0 10px #0000}to{transform:scale(.95);box-shadow:0 0 #0000}}.blob.white[_ngcontent-%COMP%]{background:#fff;box-shadow:0 0 #fff;animation:_ngcontent-%COMP%_pulse-white 2s infinite}@keyframes _ngcontent-%COMP%_pulse-white{0%{transform:scale(.95);box-shadow:0 0 #ffffffb3}70%{transform:scale(1);box-shadow:0 0 0 10px #fff0}to{transform:scale(.95);box-shadow:0 0 #fff0}}.blob.red[_ngcontent-%COMP%]{background:#ff5252;box-shadow:0 0 #ff5252;animation:_ngcontent-%COMP%_pulse-red 2s infinite}@keyframes _ngcontent-%COMP%_pulse-red{0%{transform:scale(.95);box-shadow:0 0 #ff5252b3}70%{transform:scale(1);box-shadow:0 0 0 10px #ff525200}to{transform:scale(.95);box-shadow:0 0 #ff525200}}.blob.orange[_ngcontent-%COMP%]{background:#ff793f;box-shadow:0 0 #ff793f;animation:_ngcontent-%COMP%_pulse-orange 2s infinite}@keyframes _ngcontent-%COMP%_pulse-orange{0%{transform:scale(.95);box-shadow:0 0 #ff793fb3}70%{transform:scale(1);box-shadow:0 0 0 10px #ff793f00}to{transform:scale(.95);box-shadow:0 0 #ff793f00}}.blob.yellow[_ngcontent-%COMP%]{background:#ffb142;box-shadow:0 0 #ffb142;animation:_ngcontent-%COMP%_pulse-yellow 2s infinite}@keyframes _ngcontent-%COMP%_pulse-yellow{0%{transform:scale(.95);box-shadow:0 0 #ffb142b3}70%{transform:scale(1);box-shadow:0 0 0 10px #ffb14200}to{transform:scale(.95);box-shadow:0 0 #ffb14200}}.blob.blue[_ngcontent-%COMP%]{background:#34ace0;box-shadow:0 0 #34ace0;animation:_ngcontent-%COMP%_pulse-blue 2s infinite}@keyframes _ngcontent-%COMP%_pulse-blue{0%{transform:scale(.95);box-shadow:0 0 #34ace0b3}70%{transform:scale(1);box-shadow:0 0 0 10px #34ace000}to{transform:scale(.95);box-shadow:0 0 #34ace000}}.blob.green[_ngcontent-%COMP%]{background:#77d933;box-shadow:0 0 #77d933;animation:_ngcontent-%COMP%_pulse-green 2s infinite}@keyframes _ngcontent-%COMP%_pulse-green{0%{transform:scale(.95);box-shadow:0 0 #33d938b3}70%{transform:scale(1);box-shadow:0 0 0 10px #33d9b200}to{transform:scale(.95);box-shadow:0 0 #33d9b200}}.blob.purple[_ngcontent-%COMP%]{background:#8e44ad;box-shadow:0 0 #8e44ad;animation:_ngcontent-%COMP%_pulse-purple 2s infinite}@keyframes _ngcontent-%COMP%_pulse-purple{0%{transform:scale(.95);box-shadow:0 0 #8e44adb3}70%{transform:scale(1);box-shadow:0 0 0 10px #8e44ad00}to{transform:scale(.95);box-shadow:0 0 #8e44ad00}}"],changeDetection:0})};function ra(n,t){n&1&&(a(0,"li",10),x(1,"POS-return-cart"),r())}function la(n,t){if(n&1&&(a(0,"li",10),x(1,"POS-return-invoice",14),r()),n&2){let e=d(2);l(),y("formControl",e.returnInvoiceNumber())}}function sa(n,t){if(n&1&&(a(0,"div",7)(1,"div",8),m(2,"Order"),r(),x(3,"div",9),v(4,ra,2,0,"li",10),v(5,la,2,1,"li",10),r()),n&2){let e=d();l(4),_(e.role.sell.Return?4:-1),l(),_(e.role.sell.Return?5:-1)}}var bi=class n{constructor(t,e,i){this.role=t;this.matDialog=e;this.cart=i}returnInvoiceNumber=N(new ge(""));appConfigJSON=N(void 0);isEditBuyForm=N(!1);outletID=N("");outletName=N("");handleKeyboardEvent(t){t.key==="F4"&&this.matDialog.openDialogs.length===0&&this.addVariant()}addVariant(){this.matDialog.open(yt,{data:{appConfigJSON:this.appConfigJSON(),isEdit:this.isEditBuyForm(),outletID:this.outletID(),outletName:this.outletName()}}).afterClosed().pipe(A(t=>!!t)).subscribe(t=>this.cart.addVariant(t))}static \u0275fac=function(e){return new(e||n)(g(Ce),g(ie),g(Z))};static \u0275cmp=V({type:n,selectors:[["POS-more-actions"]],hostBindings:function(e,i){e&1&&D("keydown",function(s){return i.handleKeyboardEvent(s)},zi)},inputs:{returnInvoiceNumber:[1,"returnInvoiceNumber"],appConfigJSON:[1,"appConfigJSON"],isEditBuyForm:[1,"isEditBuyForm"],outletID:[1,"outletID"],outletName:[1,"outletName"]},decls:27,vars:6,consts:[["id","moreMenu","data-bs-toggle","dropdown",1,"d-flex","align-items-center","cursor-pointer"],[1,"me-2"],[1,"fa-solid","fa-caret-down","fa-lg"],[1,"fs-6","headings-font-family","pb-1"],[1,"h-100","d-flex","align-items-center","justify-content-between"],["aria-labelledby","moreMenu",1,"dropdown-menu","more-actions"],[1,"d-flex",2,"width","30rem"],[1,"dropdown-header","text-dark","col"],[1,"h5","mb-4"],[1,"dropdown-divider","m-0"],[1,"cursor-pointer"],[3,"appConfigJSON","isEditBuyForm","outletID","outletName"],[3,"outletID"],[1,"cursor-pointer","position-relative"],[3,"formControl"]],template:function(e,i){e&1&&(a(0,"span",0)(1,"span",1),x(2,"i",2),r(),a(3,"span",3),m(4,"More Actions"),r()(),a(5,"div",4)(6,"div",5)(7,"div",6),v(8,sa,6,2,"div",7),a(9,"div",7)(10,"div",8),m(11,"Item"),r(),x(12,"div",9),a(13,"li",10),x(14,"POS-add-variant",11),r(),a(15,"li",10),x(16,"POS-scan-serial"),r(),a(17,"li",10),x(18,"POS-upload-cart",12),r(),a(19,"li",10),x(20,"POS-clear-cart"),r()(),a(21,"div",7)(22,"div",8),m(23,"Advanced"),r(),x(24,"div",9),a(25,"li",13),x(26,"pos-rfid-buy-action"),r()()()()()),e&2&&(l(8),_(i.role.sell.Return?8:-1),l(6),y("appConfigJSON",i.appConfigJSON())("isEditBuyForm",i.isEditBuyForm())("outletID",i.outletID())("outletName",i.outletName()),l(4),y("outletID",i.outletID()))},dependencies:[tt,de,et,mi,di,pi,ui,fi,Ci,yi],encapsulation:2,changeDetection:0})};var hi=class n{constructor(t,e){this.dialogRef=t;this.config.title="Discount and Tax",this.config.customWidth="400px";let i=e.discount;this.discountAmount=i.Amount,this.discountPercentage=i.Percentage;let o=e.tax;this.taxID=o.ID,this.taxRate=o.Rate,this.taxType=o.CalculationTypeName,this.taxLabel=o.Label,this.taxes=e.taxes.filter(s=>!s.Bin),this.currencySymbol=e.currencySymbol}config=new Ie;tabIndexActive;discountAmount=0;discountPercentage=0;taxes=[];taxID="";taxRate=0;taxType="";taxLabel="";discounts=[];currencySymbol="";ok(){this.dialogRef.close({Discount:{Amount:this.discountAmount,Percentage:this.discountPercentage},Tax:{ID:this.taxID,Rate:this.taxRate,CalculationTypeName:this.taxType,Label:this.taxLabel,Discontinue:!1}})}close(){this.dialogRef.close()}calculateDiscountCalculator(){let t=100;this.discounts.forEach(e=>{t=t*(100-e)/100}),this.discountPercentage=100-t}updateTax(t){this.taxID=t.ID,this.taxRate=t.Rate,this.taxType=t.CalculationTypeName,this.taxLabel=t.Label}static \u0275fac=function(e){return new(e||n)(g(Oe),g(ke))};static \u0275cmp=V({type:n,selectors:[["POS-modal-discount-and-tax"]],decls:48,vars:10,consts:[[3,"keydown.F2","onOk","onCancel","onClose","config"],[1,"container"],["matTooltipPosition","above","matTooltip","Discount","tabTitle","Discount"],[1,"row","d-flex","align-items-center","justify-content-start"],[1,"col-3"],[1,"fw-bold","d-block"],[1,"col-9"],["type","text","data-cy","discount1","autoNum","","percentage","","decimalPlaces","2",1,"form-control","d-inline-block",2,"width","100px",3,"ngModelChange","ngModel"],[1,"ms-1"],[1,"row","d-flex","align-items-center","justify-content-start","mt-6"],["type","text","data-cy","discountamount","autoNum","",1,"form-control","d-inline-block",2,"width","100px",3,"ngModelChange","ngModel"],["matTooltipPosition","above","matTooltip","Tax","tabTitle","Tax"],["bindLabel","Label","appendTo","body","bindValue","ID","placeholder","Tax","data-cy","Tax",2,"width","150px",3,"change","clearable","ngModel","items"],["matTooltipPosition","above","matTooltip","Calculation","tabTitle","Calculator"],[1,"row","mt-6","g-0","d-flex","align-items-center","justify-content-start"],[1,"col-4"],[1,"col-8","ps-4"],["type","text","data-cy","discountCal1","autoNum","","percentage","","decimalPlaces","2",1,"form-control","d-inline-block",2,"width","47px",3,"ngModelChange","ngModel"],[1,"mx-2"],["type","text","data-cy","discountCal2","autoNum","","percentage","","decimalPlaces","2",1,"form-control","d-inline-block",2,"width","47px",3,"ngModelChange","ngModel"],["type","text","data-cy","discountCal3","autoNum","","percentage","","decimalPlaces","2",1,"form-control","d-inline-block",2,"width","47px",3,"ngModelChange","ngModel"]],template:function(e,i){e&1&&(a(0,"modal-material",0),D("keydown.F2",function(){return i.ok()})("onOk",function(){return i.ok()})("onCancel",function(){return i.close()})("onClose",function(){return i.close()}),a(1,"content")(2,"div",1)(3,"custom-tabs"),jt(4),a(5,"tab",2)(6,"div",3)(7,"div",4)(8,"label",5),m(9,"Discount %"),r()(),a(10,"div",6)(11,"input",7),J("ngModelChange",function(s){return Q(i.discountPercentage,s)||(i.discountPercentage=s),s}),r(),a(12,"span",8),m(13,"%"),r()()(),a(14,"div",9)(15,"div",4)(16,"label",5),m(17),r()(),a(18,"div",6)(19,"input",10),J("ngModelChange",function(s){return Q(i.discountAmount,s)||(i.discountAmount=s),s}),r()()()(),Lt(),jt(20),a(21,"tab",11)(22,"div",3)(23,"div",4)(24,"label",5),m(25,"Tax"),r()(),a(26,"div",6)(27,"ng-select",12),D("change",function(s){return i.updateTax(s)}),r()()()(),Lt(),jt(28),a(29,"tab",13)(30,"div",14)(31,"div",15)(32,"label",5),m(33,"Discount Calculator"),r()(),a(34,"div",16)(35,"input",17),J("ngModelChange",function(s){return Q(i.discounts[0],s)||(i.discounts[0]=s),s}),D("ngModelChange",function(){return i.calculateDiscountCalculator()}),r(),a(36,"span"),m(37," %"),r(),a(38,"span",18),m(39,"+"),r(),a(40,"input",19),J("ngModelChange",function(s){return Q(i.discounts[1],s)||(i.discounts[1]=s),s}),D("ngModelChange",function(){return i.calculateDiscountCalculator()}),r(),a(41,"span"),m(42," %"),r(),a(43,"span",18),m(44,"+"),r(),a(45,"input",20),J("ngModelChange",function(s){return Q(i.discounts[2],s)||(i.discounts[2]=s),s}),D("ngModelChange",function(){return i.calculateDiscountCalculator()}),r(),a(46,"span"),m(47," %"),r()()()(),Lt(),r()()()()),e&2&&(y("config",i.config),l(11),W("ngModel",i.discountPercentage),l(6),E("Discount ",i.currencySymbol),l(2),W("ngModel",i.discountAmount),l(8),y("clearable",!1)("ngModel",i.taxID)("items",i.taxes),l(8),W("ngModel",i.discounts[0]),l(5),W("ngModel",i.discounts[1]),l(5),W("ngModel",i.discounts[2]))},dependencies:[te,Fe,Me,de,Ee,wt,Pe,Vn,Bn,Rn,ft,nt,it,Yt],encapsulation:2})};var qe=class n{constructor(t,e,i){this.form=e;this.decimalPipe=i;let o=e.discountAndTaxForm.valueChanges;this.currency$=e.noteForm.valueChanges.pipe(p(f=>f.Currency),ae(1),X()),this.currencySymbol$=this.currency$.pipe(p(f=>f.Symbol),X());let s=t.cart$.pipe(k(console.log),p(f=>f.map(w=>w.Total)),p(f=>f.reduce((w,H)=>w+H,0)),p(f=>this.setDecimalDigit(f)),ae(1),X()),F=t.cart$.pipe(p(f=>f.filter(w=>w.Taxable).map(w=>w.Total)),p(f=>f.reduce((w,H)=>w+H,0)),p(f=>this.setDecimalDigit(f)),ae(1),X());this.displayedAmount$=s,this.displayedDiscountPercentage$=xe(this.displayedAmount$,o.pipe(p(f=>f.Discount.Percentage))).pipe(p(([f,w])=>({label:`Discount ${w}%`,value:f*(w/100)})),Ye({label:"",value:0}),ae(1),X()),this.displayedDiscountAmount$=xe(this.currencySymbol$,o.pipe(p(f=>f.Discount.Amount))).pipe(p(([f,w])=>({label:`Discount ${f}`,value:w})),Ye({label:"",value:0}),ae(1),X()),this.displayedTax$=xe(F,this.displayedDiscountPercentage$.pipe(p(f=>f.value)),this.displayedDiscountAmount$.pipe(p(f=>f.value)),o.pipe(p(f=>f.Tax)),ki(t.isReturn)).pipe(A(([,,,f])=>!!f.Label),p(([f,w,H,M,j])=>({amountAfterDiscount:f-w-(j?-H:H),tax:M})),p(f=>{let w=f.amountAfterDiscount,H=f.tax;return{label:H.Label,tax:{id:H.ID,value:H.CalculationTypeName=="Add"?w*(H.Rate/100):H.Rate/(100+H.Rate)*w,type:H.CalculationTypeName,rate:H.Rate}}}),k(f=>e.setTaxAmount(f.tax.value)),Ye({label:"",tax:{id:"",value:0,type:"",rate:0}}),ae(1),X()),this.amountAfterDiscountAndTax$=xe(this.displayedAmount$,this.displayedDiscountPercentage$.pipe(p(f=>f.value)),this.displayedDiscountAmount$.pipe(p(f=>f.value)),this.displayedTax$.pipe(p(f=>f.tax)),t.cart$.pipe(p(f=>f.length)),ki(t.isReturn)).pipe(p(([f,w,H,M,j,c])=>{let S=w+(c?-H:H);return j?f-S+(M.type=="Add"?M.value:0):0}),X()).pipe(ae(1)),this.amountAfterDiscountAndTax$.subscribe()}paymentMethodName=se("Cash");displayedAmount$;displayedDiscountPercentage$;displayedDiscountAmount$;displayedTax$;currency$;currencySymbol$;amountAfterDiscountAndTax$;get amountToPay(){return this.form.buyForm.controls.Payment.controls.Amount.value}get methodID(){return this.form.buyForm.controls.Payment.controls.MethodID.value}get code(){return this.form.buyForm.controls.Payment.controls.Code.value}get note(){return this.form.buyForm.controls.Payment.controls.Note.value}setDecimalDigit(t){let e=this.decimalPipe.transform(t,"1.0-4");return t=parseFloat(e.split(",").join("")),t}static \u0275fac=function(e){return new(e||n)(q(Z),q(z),q(ye))};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};var _i=class n{constructor(t,e){this.matDialog=t;this.payment=e}taxes=N([]);currencySymbol=N("");isReturn=N(!1);discTax;disabled=!1;onChange=t=>{};onTouched=()=>{};writeValue(t){this.discTax=t}registerOnChange(t){this.onChange=t}registerOnTouched(t){this.onTouched=t}setDisabledState(t){this.disabled=t}openModalDiscountAndTax(){return oe(this,null,function*(){this.payment.displayedAmount$.pipe(ht(1)).subscribe(t=>{let e={Amount:this.discTax.Discount.Amount,Percentage:this.discTax.Discount.Percentage};this.matDialog.open(hi,{data:{discount:P({},e),tax:P({},this.discTax.Tax),taxes:this.taxes(),currencySymbol:this.currencySymbol(),displayedAmount:t,isReturn:this.isReturn()}}).afterClosed().pipe(A(i=>!!i)).subscribe(i=>{this.discTax.Discount=P({},i.Discount),this.discTax.Tax=P({},i.Tax),this.onChange(this.discTax)})})})}static \u0275fac=function(e){return new(e||n)(g(ie),g(qe))};static \u0275cmp=V({type:n,selectors:[["POS-discount-and-tax-form"]],inputs:{taxes:[1,"taxes"],currencySymbol:[1,"currencySymbol"],isReturn:[1,"isReturn"]},features:[je([{provide:Ze,multi:!0,useExisting:n}])],decls:2,vars:0,consts:[["type","button","matTooltip","Discount / Tax","matTooltipPosition","above",1,"btn","btn-success","fs-5",2,"border-right","0.1px solid #fff",3,"click"],[1,"fa-light","fa-percent"]],template:function(e,i){e&1&&(a(0,"button",0),D("click",function(){return i.openModalDiscountAndTax()}),x(1,"i",1),r())},dependencies:[nt,it,zt],styles:["button[_ngcontent-%COMP%]{border-right:.1px solid #fff;border-top-right-radius:0;border-bottom-right-radius:0;position:relative;flex:1 1 auto}"],changeDetection:0})};var Bt=n=>({selected:n}),ca=(n,t)=>({"col-sm-3":n,"col-sm-7":t});function ma(n,t){if(n&1){let e=U();a(0,"a",10),D("click",function(){O(e);let o=d();return T(o.onTabChange("Number"))}),m(1," Number "),r()}if(n&2){let e=d();y("ngClass",le(1,Bt,e.tabState=="Number"))}}function da(n,t){if(n&1){let e=U();a(0,"div",11)(1,"label",12)(2,"input",13),J("ngModelChange",function(o){O(e);let s=d(2);return Q(s.tagID,o)||(s.tagID=o),T(o)}),r(),m(3),r()()}if(n&2){let e=t.$implicit,i=t.$index,o=d(2);l(),y("for",Fi("potype-"+i))("ngClass",le(8,Bt,o.tagID==e.ID)),l(),y("id",Fi("potype-"+i)),W("ngModel",o.tagID),y("value",e.ID),l(),E(" ",e.Name," ")}}function pa(n,t){if(n&1&&(a(0,"div",8),we(1,da,4,10,"div",11,Be),r()),n&2){let e=d();l(),Ne(e.supplierPOTypes)}}function ua(n,t){if(n&1){let e=U();a(0,"strong",14),m(1,"Supplier Bill Number"),r(),a(2,"input",15),J("ngModelChange",function(o){O(e);let s=d();return Q(s.invoiceNumber,o)||(s.invoiceNumber=o),T(o)}),r()}if(n&2){let e=d();l(2),W("ngModel",e.invoiceNumber)}}function fa(n,t){if(n&1){let e=U();a(0,"div",9)(1,"POS-tinymce-editor",16),J("ngModelChange",function(o){O(e);let s=d();return Q(s.note,o)||(s.note=o),T(o)}),r()()}if(n&2){let e=d();l(),W("ngModel",e.note)}}function ga(n,t){if(n&1){let e=U();a(0,"div",22)(1,"span",27),m(2,"@"),r(),a(3,"input",28),J("ngModelChange",function(o){O(e);let s=d(2);return Q(s.exchangeRate,o)||(s.exchangeRate=o),T(o)}),r()()}if(n&2){let e=d(2);l(3),W("ngModel",e.exchangeRate)}}function Ca(n,t){if(n&1){let e=U();a(0,"div",17)(1,"div",18)(2,"div",19),m(3,"Currency :"),r(),a(4,"div",20)(5,"ng-select",21),J("ngModelChange",function(o){O(e);let s=d();return Q(s.currencyID,o)||(s.currencyID=o),T(o)}),r()(),v(6,ga,4,1,"div",22),r()(),a(7,"div",23)(8,"div",24),m(9,"Term :"),r(),a(10,"div",25)(11,"ng-select",26),J("ngModelChange",function(o){O(e);let s=d();return Q(s.note,o)||(s.note=o),T(o)}),r()()()}if(n&2){let e=d();l(4),y("ngClass",lt(8,ca,e.currencyID!=e.defaultCurrencyID,e.currencyID==e.defaultCurrencyID)),l(),y("items",e.currencies),W("ngModel",e.currencyID),y("clearable",!1),l(),_(e.currencyID!=e.defaultCurrencyID?6:-1),l(5),y("items",e.predefinedNotes),W("ngModel",e.note),y("clearable",!1)}}var Di=class n{constructor(t,e){this.dialogRef=t;this.config=new Ie,this.config.title="Purchase Order Note",this.config.customWidth="700px",this.note=e.note,this.tagID=e.tagID,this.currencyID=e.currencyID,this.exchangeRate=e.currencies.find(i=>i.ID==this.currencyID).ExchangeRate,this.supplierPOTypes=e.supplierPOTypes,this.predefinedNotes=e.predefinedNotes,this.currencies=e.currencies,this.defaultCurrencyID=e.defaultCurrencyID,this.invoiceNumber=e.invoiceNumber,I.IsEmpty(this.tagID)&&(this.tagID=this.supplierPOTypes[0]?.ID)}loadService=G(ue);config$=this.loadService.appConfigJSON$;supplierPOTypes;predefinedNotes;currencies;currencyID;note;tagID;defaultCurrencyID;exchangeRate=0;invoiceNumber;tabState="Note";config;ok(){this.dialogRef.close({Note:this.note,TagID:this.tagID,Currency:B(P({},this.currencies.find(t=>t.ID==this.currencyID)),{ExchangeRate:this.exchangeRate}),InvoiceNumber:this.invoiceNumber})}close(){this.dialogRef.close()}onTabChange(t){this.tabState=t}static \u0275fac=function(e){return new(e||n)(g(Oe),g(ke))};static \u0275cmp=V({type:n,selectors:[["POS-modal-note"]],decls:19,vars:17,consts:[[3,"onCancel","onClose","onOk","config"],[1,"container-fluid"],[1,"row","border-bottom"],["data-cy","note",1,"btn","btn-link",3,"click","ngClass"],["data-cy","type",1,"btn","btn-link",3,"click","ngClass"],["data-cy","number",1,"btn","btn-link",3,"ngClass"],["data-cy","other",1,"btn","btn-link",3,"click","ngClass"],[1,"row","mt-8"],[1,"col-12"],[1,"col-12","tinymce"],["data-cy","number",1,"btn","btn-link",3,"click","ngClass"],[1,"rad-btn"],[3,"for","ngClass"],["type","radio",3,"ngModelChange","ngModel","value","id"],[1,"mb-2","ps-0"],["type","text","placeholder","Same as Purchase Order Number when blank",1,"form-control","w-50",3,"ngModelChange","ngModel"],[3,"ngModelChange","ngModel"],[1,"col-7","pe-0"],[1,"row"],[1,"col-sm-3","d-flex","align-items-center"],[1,"ps-0",3,"ngClass"],["bindLabel","Name","bindValue","ID","placeholder","Outlet","appendTo","body",3,"ngModelChange","items","ngModel","clearable"],[1,"col-sm-4","d-flex"],[1,"col-5","d-flex","align-items-center","ps-0"],[1,"col-sm-2"],[1,"col-sm-10"],["bindLabel","Label","bindValue","Description","placeholder","Term","appendTo","body",3,"ngModelChange","items","ngModel","clearable"],[1,"pt-4"],["type","text","autoNum","",1,"border","border-light",2,"width","100px",3,"ngModelChange","ngModel"]],template:function(e,i){if(e&1&&(rt(0),u(1,"async"),a(2,"modal-material",0),D("onCancel",function(){return i.close()})("onClose",function(){return i.close()})("onOk",function(){return i.ok()}),a(3,"content")(4,"div",1)(5,"div",2)(6,"div")(7,"a",3),D("click",function(){return i.onTabChange("Note")}),m(8," Note "),r(),a(9,"a",4),D("click",function(){return i.onTabChange("Tag")}),m(10," Tag "),r(),v(11,ma,2,3,"a",5),a(12,"a",6),D("click",function(){return i.onTabChange("Other")}),m(13," Other "),r()()(),a(14,"div",7),v(15,pa,3,0,"div",8),v(16,ua,3,1),v(17,fa,2,1,"div",9),v(18,Ca,12,11),r()()()()),e&2){let o=C(1,9,i.config$),s=o==null||o.ModuleBuy==null||o.ModuleBuy.Numbering==null?null:o.ModuleBuy.Numbering.EnableCustomBillNumber;l(2),y("config",i.config),l(5),y("ngClass",le(11,Bt,i.tabState=="Note")),l(2),y("ngClass",le(13,Bt,i.tabState=="Tag")),l(2),_(s?11:-1),l(),y("ngClass",le(15,Bt,i.tabState=="Other")),l(3),_(i.tabState=="Tag"?15:-1),l(),_(i.tabState=="Number"?16:-1),l(),_(i.tabState=="Note"?17:-1),l(),_(i.tabState=="Other"?18:-1)}},dependencies:[te,Xe,Fe,Me,fn,de,Ee,wt,Yt,ti,ft,Pe,Se],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}content[_ngcontent-%COMP%] > div.container-fluid[_ngcontent-%COMP%]{min-height:200px}.tinymce[_ngcontent-%COMP%] a[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{z-index:2;position:absolute;right:15px;bottom:19px}.tinymce[_ngcontent-%COMP%] editor[_ngcontent-%COMP%]{height:max-content;z-index:1}.rad-btn[_ngcontent-%COMP%]{position:relative;display:inline-block}.rad-btn[_ngcontent-%COMP%] label[_ngcontent-%COMP%]{border:1px solid #dddddd;border-radius:3px;margin-right:10px;cursor:pointer;padding:10px;margin-bottom:10px;color:#000}.rad-btn[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{visibility:hidden;position:absolute;left:0;top:0}.rad-btn[_ngcontent-%COMP%] label.selected[_ngcontent-%COMP%]{background:#dcdcdc;border:1px solid #dcdcdc}.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}a.btn.btn-link[_ngcontent-%COMP%]{color:inherit}"]})};var xi=class n{constructor(t){this.matDialog=t}supplierPOTypes=N([]);predefinedNotes=N([]);defaultCurrencyID=N("");currencies=N([]);note;disabled=!1;onChange=t=>{};onTouched=()=>{};writeValue(t){this.note=t}registerOnChange(t){this.onChange=t}registerOnTouched(t){this.onTouched=t}setDisabledState(t){this.disabled=t}openModalNote(){return oe(this,null,function*(){this.matDialog.open(Di,{data:{note:this.note.Note,tagID:this.note.TagID,exchangeRate:this.note.Currency.ExchangeRate,currencyID:this.note.Currency.ID,supplierPOTypes:this.supplierPOTypes(),predefinedNotes:this.predefinedNotes(),currencies:this.currencies(),defaultCurrencyID:this.defaultCurrencyID(),invoiceNumber:this.note.InvoiceNumber}}).afterClosed().pipe(A(t=>!!t)).subscribe(t=>{this.note=t,this.onChange(t)})})}static \u0275fac=function(e){return new(e||n)(g(ie))};static \u0275cmp=V({type:n,selectors:[["POS-note-form"]],inputs:{supplierPOTypes:[1,"supplierPOTypes"],predefinedNotes:[1,"predefinedNotes"],defaultCurrencyID:[1,"defaultCurrencyID"],currencies:[1,"currencies"]},features:[je([{provide:Ze,multi:!0,useExisting:n}])],decls:2,vars:0,consts:[["type","button",1,"btn","btn-gray","w-100","h-100","fs-3","px-0","py-6","headings-font-family",3,"click"],[1,"fa-regular","fa-note-sticky","fa-xl"]],template:function(e,i){e&1&&(vt(0,"button",0),Ut("click",function(){return i.openModalNote()}),nn(1,"i",1),_t())},styles:[".btn-gray[_ngcontent-%COMP%]{border:1px solid #d6d6d6;color:#545454!important;background:linear-gradient(to bottom,#fff,#eee)}"],changeDetection:0})};var ya=(n,t)=>({"btn-secondary":n,"btn-outline-secondary":t}),ba=(n,t)=>({"btn-outline-secondary":n,"btn-secondary":t});function ha(n,t){if(n&1){let e=U();a(0,"div")(1,"label",13),x(2,"i",14),a(3,"span"),m(4,"Add inventory to outlet :"),r()(),a(5,"p-select",15),J("ngModelChange",function(o){O(e);let s=d();return Q(s.deliveryEntityIDValue,o)||(s.deliveryEntityIDValue=o),T(o)}),r()()}if(n&2){let e=d();l(5),y("options",e.outlets),W("ngModel",e.deliveryEntityIDValue),y("filter",!0)("showClear",!1)("disabled",e.isEdit)}}function va(n,t){if(n&1){let e=U();a(0,"div",12)(1,"div",16)(2,"label",17),x(3,"i",18),a(4,"span"),m(5),r()(),a(6,"div",16)(7,"p-datepicker",19),J("ngModelChange",function(o){O(e);let s=d();return Q(s.fulfillmentDateValue,o)||(s.fulfillmentDateValue=o),T(o)}),r()()(),a(8,"div",16)(9,"label",20),x(10,"i",21),a(11,"span"),m(12,"Time"),r()(),a(13,"div",16)(14,"app-timepicker",22),J("timeChange",function(o){O(e);let s=d();return Q(s.fulfillmentTimeValue,o)||(s.fulfillmentTimeValue=o),T(o)}),r()()()()}if(n&2){let e=d();l(5),ee(e.shippingDateLabel),l(2),W("ngModel",e.fulfillmentDateValue),y("baseZIndex",1e4)("showClear",!0),l(7),W("time",e.fulfillmentTimeValue),y("showIcon",!0)("showCloseBtn",!1)("fullWidth",!0)("showClear",!0)}}var Si=class n{constructor(t,e,i){this.dialogRef=t;this.datePipe=e;this.data=i;this.config=new Ie,this.config.title="Purchase Order Fulfillment",this.config.customWidth="650px",this.isEdit=i.isEdit,this.deliveryEntityID.set(i.deliveryEntityID),this.outlets=i.outlets,this.fulfillmentDate.set(i.fulfillmentDate??null),this.fulfillmentTime.set(i.fulfillmentTime??null),this.fulfillmentDateTime.set(i.fulfillmentDateTime??null),this.appConfigJSON=i.appConfigJSON,I.IsNotEmpty(i.deliveryEntityID)?this.tabState.set("Now"):this.tabState.set("Later")}isEdit=!1;outlets;deliveryEntityID=se(I.GuidEmpty);tabState=se("Now");config;fulfillmentDate=se(null);fulfillmentTime=se(null);fulfillmentDateTime=se(null);shippingDateLabel="Fulfillment Date";appConfigJSON;get deliveryEntityIDValue(){return this.deliveryEntityID()}set deliveryEntityIDValue(t){this.deliveryEntityID.set(t??I.GuidEmpty)}get fulfillmentDateValue(){return this.fulfillmentDate()}set fulfillmentDateValue(t){this.fulfillmentDate.set(t)}get fulfillmentTimeValue(){return this.fulfillmentTime()}set fulfillmentTimeValue(t){this.fulfillmentTime.set(t)}get tabStateValue(){return this.tabState()}onOk(){this.tabState()=="Later"&&this.setCustomDateField(),this.dialogRef.close({deliveryEntityID:this.deliveryEntityID(),fulfillmentDate:this.fulfillmentDate(),fulfillmentTime:this.fulfillmentTime(),fulfillmentDateTime:this.fulfillmentDateTime()})}close(){this.dialogRef.close()}setCustomDateField(){let t=this.fulfillmentDate()?this.fulfillmentDate():new Date,e=this.fulfillmentTime(),i;e?typeof e=="string"?i=e:i=this.datePipe.transform(e,"HH:mm")??"00:00":i="00:00";let o=this.datePipe.transform(t,"d MMM y");this.fulfillmentDateTime.set(`${o} ${i}`)}onChangeTab(t){this.tabState.set(t),t=="Now"?(this.fulfillmentDate.set(null),this.deliveryEntityID.set(I.IsNotEmpty(this.data.deliveryEntityID)?this.data.deliveryEntityID:this.data.outletID??I.GuidEmpty)):(this.deliveryEntityID.set(I.GuidEmpty),this.fulfillmentDate.set(new Date))}static \u0275fac=function(e){return new(e||n)(g(Oe),g(rn),g(ke))};static \u0275cmp=V({type:n,selectors:[["POS-modal-fulfillment"]],decls:23,vars:12,consts:[[3,"onOk","onCancel","onClose","config"],[1,"container"],[1,"row"],[1,"btn-group","col-12"],["type","button",1,"btn","btn-secondary","position-relative","btn-custom-size","col-5",3,"click"],[1,"fa-solid","fa-bolt"],[1,"ms-2"],[1,"ms-1"],["type","button",1,"btn","position-relative","btn-custom-size","col-7",3,"click"],[1,"fa-solid","fa-clock"],[1,"row","mt-12"],[1,"col-12"],[1,"d-flex","align-items-center","gap-3"],[1,"mb-2"],[1,"fa","fa-store","me-1"],["optionLabel","Name","optionValue","ID","filterBy","Name","placeholder","Select an Outlet","appendTo","body","data-cy","DeductInventory",1,"w-100",2,"--p-select-padding-y","0.8rem",3,"ngModelChange","options","ngModel","filter","showClear","disabled"],[1,"w-100"],["for","shippingDate",1,"mb-2"],[1,"fa-solid","fa-calendar","me-1"],["placeholder","Select Date","showIcon","","iconDisplay","input","appendTo","body","dateFormat","dd M yy",1,"w-100","date-custom",3,"ngModelChange","ngModel","baseZIndex","showClear"],["for","shippingTime",1,"mb-2"],[1,"fa","fa-clock","me-1"],["placeholder","Select Time",1,"date-custom",3,"timeChange","time","showIcon","showCloseBtn","fullWidth","showClear"]],template:function(e,i){e&1&&(a(0,"modal-material",0),D("onOk",function(){return i.onOk()})("onCancel",function(){return i.close()})("onClose",function(){return i.close()}),a(1,"content")(2,"div",1)(3,"div",2)(4,"div",3)(5,"button",4),D("click",function(){return i.onChangeTab("Now")}),x(6,"i",5),a(7,"span",6),m(8," Now "),a(9,"small",7)(10,"em"),m(11,"(in store purchase)"),r()()()(),a(12,"button",8),D("click",function(){return i.onChangeTab("Later")}),x(13,"i",9),a(14,"span",6),m(15," Later "),a(16,"small",7)(17,"em"),m(18,"(shipped to customer address)"),r()()()()()(),a(19,"div",10)(20,"div",11),v(21,ha,6,5,"div")(22,va,15,9,"div",12),r()()()()()),e&2&&(y("config",i.config),l(5),At(lt(6,ya,i.tabStateValue=="Now",i.tabStateValue!="Now")),l(7),At(lt(9,ba,i.tabStateValue=="Now",i.tabStateValue=="Later")),l(9),_(i.tabStateValue=="Now"?21:22))},dependencies:[te,Pe,hn,Fe,de,Ee,Nn,wn,An,Fn,En],styles:[".container[_ngcontent-%COMP%]{min-height:150px} .p-datepicker.p-component.p-datepicker-timeonly{z-index:99999!important}.tabDesc[_ngcontent-%COMP%]{font-size:80%;font-weight:400} mat-button-toggle-group.fulfillment-tab mat-pseudo-checkbox{display:none} p-datepicker.date-custom>span>input{padding-top:10px;padding-bottom:10px} app-timepicker.date-custom p-datepicker>span>input{padding-top:10px;padding-bottom:10px}.custom-checkbox-style[_ngcontent-%COMP%]{--p-checkbox-checked-background: #89b03e;--p-checkbox-hover-border-color: #89b03e;--p-checkbox-checked-border-color: #89b03e;--p-checkbox-checked-hover-border-color: #89b03e;--p-checkbox-hover-border-color-background: #7c9b44;--p-checkbox-checked-hover-background: #89b03e}.custom-input-size[_ngcontent-%COMP%]{height:2.625rem;padding:.75rem!important;color:#343434;font-size:.75rem;border-radius:.25rem!important}.btn-custom-size[_ngcontent-%COMP%]{--bs-btn-padding-y: 1rem;--bs-btn-padding-x: 1rem;--bs-btn-font-size: 3.5rem;font-family:Roboto Slab,serif}.btn-custom-size[_ngcontent-%COMP%]:hover{background-color:var(--bs-light)!important;border-color:var(--bs-light)!important;color:#000!important}.container[_ngcontent-%COMP%]{padding-left:.75rem;padding-right:.75rem}"],changeDetection:0})};var Mi=class n{constructor(t){this.matDialog=t}role=G(Ce);outlets=N([]);outletID=N("");appConfigJSON=N(void 0);isEdit=N(!1);fulfillmentResult={};get deliveryEntityID(){return this.fulfillmentResult.deliveryEntityID}disabled=!1;onChange=t=>{};onTouched=()=>{};writeValue(t){t!=null&&(this.fulfillmentResult=t)}registerOnChange(t){this.onChange=t}registerOnTouched(t){this.onTouched=t}setDisabledState(t){this.disabled=t}openModalFulfillment(){return oe(this,null,function*(){this.matDialog.open(Si,{data:{deliveryEntityID:this.deliveryEntityID,outlets:this.outlets(),outletID:this.outletID(),appConfigJSON:this.appConfigJSON(),isEdit:this.isEdit(),fulfillmentDate:this.fulfillmentResult.fulfillmentDate,fulfillmentTime:this.fulfillmentResult.fulfillmentTime,fulfillmentDateTime:this.fulfillmentResult.fulfillmentDateTime}}).afterClosed().pipe(A(t=>!!t)).subscribe(t=>{this.fulfillmentResult=t,this.onChange(t)})})}isDeliveryEntityIDEmpty(){return I.IsEmpty(this.deliveryEntityID)&&I.IsNotEmpty(this.outletID())}static \u0275fac=function(e){return new(e||n)(g(ie))};static \u0275cmp=V({type:n,selectors:[["POS-fulfillment-form"]],inputs:{outlets:[1,"outlets"],outletID:[1,"outletID"],appConfigJSON:[1,"appConfigJSON"],isEdit:[1,"isEdit"]},features:[je([{provide:Ze,multi:!0,useExisting:n}])],decls:5,vars:4,consts:[[3,"matTooltip"],["type","button",1,"btn","btn-gray","w-100","h-100","fs-3","px-0","py-6","headings-font-family",3,"click","disabled"],[1,"fa-solid","fa-dolly","me-3"]],template:function(e,i){e&1&&(a(0,"span",0)(1,"button",1),D("click",function(){return i.openModalFulfillment()}),x(2,"i",2),a(3,"span"),m(4,"Fulfillment"),r()()()),e&2&&(y("matTooltip",i.role.buyRestriction!=null&&i.role.buyRestriction.ShippingRestriction?"Fulfillment option is restricted by role!":""),l(),Pt("bg-gradient-warning",i.isDeliveryEntityIDEmpty()),y("disabled",i.role.buyRestriction==null?null:i.role.buyRestriction.ShippingRestriction))},dependencies:[nt,it],styles:[".btn-gray[_ngcontent-%COMP%]{border:1px solid #d6d6d6;color:#545454!important;background:linear-gradient(to bottom,#fff,#eee)}"],changeDetection:0})};var oo=n=>({selected:n}),_a=n=>({active:n});function Da(n,t){if(n&1){let e=U();a(0,"a",4),D("click",function(){O(e);let o=d();return T(o.isPayNow=!1)}),m(1," Later "),a(2,"span",7),m(3,"Take Credit"),r()()}if(n&2){let e=d();y("ngClass",le(1,oo,!e.isPayNow))}}function xa(n,t){if(n&1){let e=U();a(0,"div",16)(1,"a",17),D("click",function(){let o=O(e).$implicit,s=d(4);return T(s.inputAmount=o)}),m(2),u(3,"number"),r()()}if(n&2){let e=t.$implicit,i=d(4);l(),y("ngClass",le(5,_a,i.paymentMethodID==i.cashPaymentID&&i.inputAmount==e)),l(),$e("",i.currencySymbol," ",C(3,3,e))}}function Sa(n,t){if(n&1&&(a(0,"div",14),we(1,xa,4,7,"div",16,Be),r()),n&2){let e=d(3);l(),Ne(e.suggestedCash)}}function Ma(n,t){if(n&1&&(a(0,"div",19),m(1),u(2,"number"),r()),n&2){let e=d(4);y("ngClass",e.inputAmount>e.amountToPay?"success":"danger"),l(),$e(" ",e.currencySymbol," ",C(2,3,e.inputAmount-e.amountToPay)," ")}}function Ia(n,t){if(n&1){let e=U();a(0,"input",18),J("ngModelChange",function(o){O(e);let s=d(3);return Q(s.inputAmount,o)||(s.inputAmount=o),T(o)}),D("click",function(){O(e);let o=d(3);return o.paymentMethodID=o.cashPaymentID,o.paymentMethodState="Cash",T(o.paymentMethodName="Cash")}),r(),v(1,Ma,3,5,"div",19)}if(n&2){let e=d(3);W("ngModel",e.inputAmount),l(),_(e.inputAmount!=e.amountToPay?1:-1)}}function Pa(n,t){if(n&1){let e=U();a(0,"div",20),D("click",function(){O(e);let o=d(3);return o.paymentMethodID=o.cashPaymentID,T(o.paymentMethodState="Cash")}),x(1,"input",21),r()}if(n&2){let e=d(3);l(),y("value",e.currencySymbol+" -")}}function Oa(n,t){if(n&1&&(a(0,"div",8)(1,"div",10),x(2,"i",11),m(3," Cash "),r(),a(4,"div",12)(5,"div",13),v(6,Sa,3,0,"div",14),a(7,"div",15),v(8,Ia,2,2)(9,Pa,2,1,"div"),r()()()()),n&2){let e=d(2);l(6),_(e.role.product.Cost?6:-1),l(2),_(e.role.product.Cost?8:9)}}function Ta(n,t){if(n&1){let e=U();a(0,"div",23)(1,"a",25),D("click",function(){let o=O(e).$implicit,s=d(3);return T(s.onSelectPaymentMethod(o.ID,"Card",o.Name))}),a(2,"span",26),x(3,"img",27),r(),a(4,"span",26),m(5),u(6,"limitText"),r()()()}if(n&2){let e=t.$implicit,i=d(3);l(),y("ngClass",i.paymentMethodID===e.ID?"active":""),l(),y("hidden",e.ImageUrl==null),l(),y("src",e.ImageUrl,dt),l(),y("hidden",e.ImageUrl!=null),l(),E(" ",pt(6,5,e.Name,20)," ")}}function wa(n,t){if(n&1){let e=U();a(0,"div",24)(1,"div",28)(2,"input",29),J("ngModelChange",function(o){O(e);let s=d(3);return Q(s.paymentNote,o)||(s.paymentNote=o),T(o)}),r(),a(3,"input",30),J("ngModelChange",function(o){O(e);let s=d(3);return Q(s.paymentCode,o)||(s.paymentCode=o),T(o)}),r()()()}if(n&2){let e=d(3);l(2),W("ngModel",e.paymentNote),l(),W("ngModel",e.paymentCode)}}function Na(n,t){if(n&1&&(a(0,"div",8)(1,"div",10),x(2,"i",22),m(3," Card "),r(),a(4,"div",12)(5,"div",13),we(6,Ta,7,8,"div",23,Be),r(),v(8,wa,4,2,"div",24),r()()),n&2){let e=d(2);l(6),Ne(e.cardPayments),l(2),_(e.paymentMethodState=="Card"?8:-1)}}function Ea(n,t){if(n&1){let e=U();a(0,"div",23)(1,"a",25),D("click",function(){let o=O(e).$implicit,s=d(3);return T(s.onSelectPaymentMethod(o.ID,"Other",o.Name))}),m(2),u(3,"limitText"),r()()}if(n&2){let e=t.$implicit,i=d(3);l(),y("ngClass",i.paymentMethodID===e.ID?"active":""),l(),E(" ",pt(3,2,e.Name,20)," ")}}function Fa(n,t){if(n&1){let e=U();a(0,"div",24)(1,"div",28)(2,"input",29),J("ngModelChange",function(o){O(e);let s=d(3);return Q(s.paymentNote,o)||(s.paymentNote=o),T(o)}),r(),a(3,"input",30),J("ngModelChange",function(o){O(e);let s=d(3);return Q(s.paymentCode,o)||(s.paymentCode=o),T(o)}),r()()()}if(n&2){let e=d(3);l(2),W("ngModel",e.paymentNote),l(),W("ngModel",e.paymentCode)}}function ka(n,t){if(n&1&&(a(0,"div",9)(1,"div",10),m(2,"Others"),r(),a(3,"div",12)(4,"div",13),we(5,Ea,4,5,"div",23,Be),r(),v(7,Fa,4,2,"div",24),r()()),n&2){let e=d(2);l(5),Ne(e.otherPayments),l(2),_(e.paymentMethodState=="Other"?7:-1)}}function Aa(n,t){if(n&1&&(a(0,"div"),v(1,Oa,10,2,"div",8),v(2,Na,9,1,"div",8),v(3,ka,8,1,"div",9),r()),n&2){let e=d();l(),_(e.isCashSuspended?1:-1),l(),_(e.cardPayments.length>0?2:-1),l(),_(e.otherPayments.length>0?3:-1)}}function Va(n,t){if(n&1){let e=U();a(0,"div",6)(1,"div",31)(2,"h5",32),m(3,"Due"),r(),a(4,"datepicker",33),J("dateChange",function(o){O(e);let s=d();return Q(s.dueDate,o)||(s.dueDate=o),T(o)}),D("dateChange",function(){O(e);let o=d();return T(o.onChangeDueDate())}),r()(),a(5,"div",34)(6,"h5",32),m(7,"Days Due"),r(),a(8,"div",12)(9,"input",35),J("ngModelChange",function(o){O(e);let s=d();return Q(s.dueDays,o)||(s.dueDays=o),T(o)}),D("ngModelChange",function(){O(e);let o=d();return T(o.onChangeDueDay())}),r()()()()}if(n&2){let e=d();l(4),y("displayToggle",!1),W("date",e.dueDate),l(5),W("ngModel",e.dueDays)}}var Ii=class n{constructor(t,e,i){this.dialogRef=t;this.role=i;this.isDefaultTabPayLater=e.payDefaultState==!1,this.config=new Ie,this.config.title="Amount to Pay:",this.config.customWidth="650px",this.amountToPay=e.displayedAmountToPay,this.inputAmount=this.amountToPay,this.currencySymbol=e.currencySymbol,this.dueDate=e.dueDate,this.invoiceDate=e.invoiceDate,this.cashPaymentID=e.cashPaymentMethodID,this.cardPayments=e.cardPayments,this.otherPayments=e.otherPayments,this.paymentMethodID=e.paymentMethodID;let o=this.cardPayments.find(F=>F.ID==this.paymentMethodID);I.IsNotEmpty(o)&&(this.paymentMethodState="Card",this.paymentMethodName=o.Name);let s=this.otherPayments.find(F=>F.ID==this.paymentMethodID);I.IsNotEmpty(s)&&(this.paymentMethodState="Other",this.paymentMethodName=s.Name),this.paymentNote=e.paymentNote,this.paymentCode=e.paymentCode,this.isPayNow=e.payDefaultState,e.isEdit&&(this.isPayNow=!e.isUnpaidOnEdit),this.onChangeDueDate(),this.dueDays=e.dueDays,this.isCashSuspended=e.isCashSuspended,this.denomination=e.denomination,this.suggestedCash[0]=this.inputAmount,this.denomination.filter(F=>F>this.inputAmount).forEach(F=>{this.suggestedCash.length<3&&this.suggestedCash.push(F)}),console.log(this.suggestedCash)}config;isPayNow=!0;paymentMethodName="Cash";amountToPay=0;inputAmount=0;currencySymbol="";dueDate;dueDays;invoiceDate;cardPayments;otherPayments;cashPaymentID;paymentMethodID;paymentMethodState="Cash";paymentNote;paymentCode;displayedAmountToPay;denomination;suggestedCash=[];isCashSuspended;isDefaultTabPayLater=!1;ok(){let t={};this.isPayNow?(t.amount=this.inputAmount,t.paymentMethodID=this.paymentMethodID,t.paymentNote=this.paymentNote,t.paymentCode=this.paymentCode,t.payState="Now",t.paymentMethodName=this.paymentMethodName):(t.dueDate=this.dueDate,t.payState="Later"),this.dialogRef.close(t)}close(){this.dialogRef.close()}onSelectPaymentMethod(t,e,i){this.paymentMethodName=i,this.paymentMethodID==t?(this.paymentMethodID=this.cashPaymentID,this.paymentMethodState="Cash"):(this.paymentMethodID=t,this.paymentMethodState=e)}onChangeDueDay(){let t=new Date(I.cloneObject(this.invoiceDate));t.setDate(t.getDate()+this.dueDays),t.setHours(0,0,0,0),this.dueDate=t}onChangeDueDate(){this.dueDays=I.differentInDays(typeof this.invoiceDate=="string"?new Date(this.invoiceDate):this.invoiceDate,typeof this.dueDate=="string"?new Date(this.dueDate):this.dueDate)+1}static \u0275fac=function(e){return new(e||n)(g(Oe),g(ke),g(Ce))};static \u0275cmp=V({type:n,selectors:[["POS-modal-pay"]],decls:14,vars:10,consts:[[3,"onOk","onCancel","onClose","config"],[1,"mt-1","ms-2"],[1,"container","w-100","h-100"],[1,"row","border-bottom"],[1,"btn","btn-link",3,"click","ngClass"],[1,"btn","btn-link",3,"ngClass"],[1,"py-4"],[1,"fst-italic",2,"font-size","10px"],[1,"row","border-bottom","py-5"],[1,"row","py-5"],[1,"col-3","h5","pt-5"],[1,"fa-solid","fa-money-bill-wave"],[1,"col-9"],[1,"row"],[1,"row","mb-5"],[1,"col","pe-0","me-10","position-relative"],[1,"col-4","pe-0","ps-4"],[1,"btn","btn-outline-info","px-1","py-6","w-100",3,"click","ngClass"],["id","cashInput","type","text","placeholder","Custom Cash Amount","autoNum","",1,"form-control","form-control-lg","py-3","mb-3","px-6",3,"ngModelChange","click","ngModel"],[1,"change",3,"ngClass"],[3,"click"],["id","cashInput","type","text","placeholder","Custom Cash Amount","disabled","",1,"form-control","form-control-lg","py-3","mb-3","px-6",3,"value"],[1,"fa-regular","fa-credit-card"],[1,"col-auto","pe-0"],[1,"position-relative","row"],[1,"btn","btn-outline-info","mb-3","px-6",3,"click","ngClass"],[3,"hidden"],[2,"width","40px",3,"src"],[1,"paymentNote","col","row","g-0","pt-2","ms-6"],["type","text","placeholder","Payment Note",1,"form-control","w-50","border-end-0","py-6","col-6",3,"ngModelChange","ngModel"],["type","text","placeholder","Payment Code",1,"form-control","w-50","border-start-0","py-6","paymentCode","col-6",3,"ngModelChange","ngModel"],[1,"row","d-flex","align-items-center","g-0","later-payment"],[1,"col-3","fw-normal"],["appearance","fill","readOnly","true","name","orderDate",1,"col-9",3,"dateChange","displayToggle","date"],[1,"row","d-flex","align-items-center","g-0","later-payment","mt-10"],["type","text","autofocus","","autoNum","",1,"py-8","ps-8","form-control",3,"ngModelChange","ngModel"]],template:function(e,i){e&1&&(a(0,"modal-material",0),D("onOk",function(){return i.ok()})("onCancel",function(){return i.close()})("onClose",function(){return i.close()}),a(1,"header")(2,"div",1),m(3),u(4,"number"),r()(),a(5,"content")(6,"div",2)(7,"div",3)(8,"div")(9,"a",4),D("click",function(){return i.isPayNow=!0}),m(10," Now "),r(),v(11,Da,4,3,"a",5),r()()(),v(12,Aa,4,3,"div"),v(13,Va,10,3,"div",6),r()()),e&2&&(y("config",i.config),l(3),E(" ",i.currencySymbol+" "+C(4,6,i.amountToPay)," "),l(6),y("ngClass",le(8,oo,i.isPayNow)),l(2),_(i.amountToPay!=0||i.isDefaultTabPayLater?11:-1),l(),_(i.isPayNow?12:-1),l(),_(i.isPayNow?-1:13))},dependencies:[te,Xe,Fe,Me,de,Ee,kn,Pe,ft,ye,Kt],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}.change[_ngcontent-%COMP%]{position:absolute;top:0;height:40px;background:#89b03e;color:#fff;right:0;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:90%;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)}.btn-link[_ngcontent-%COMP%]{padding-top:0;color:#868686;padding-bottom:8px;border-radius:unset;font-family:Roboto Slab,serif}.btn-link.selected[_ngcontent-%COMP%]{color:#3b3b3b;border-bottom:4px solid #07a519} .later-payment.date-picker .mat-mdc-form-field{font-size:4px}.ng-select.ng-select-width[_ngcontent-%COMP%] .ng-select-container{width:160px;max-width:160px}input[type=text][_ngcontent-%COMP%]:disabled{background:#dadada}.later-payment[_ngcontent-%COMP%] strong{font-size:20px}.later-payment[_ngcontent-%COMP%] input{font-size:20px}.later-payment[_ngcontent-%COMP%] .mat-mdc-form-field{width:100%;font-size:20px;border:1px solid #c8d3df}.later-payment[_ngcontent-%COMP%] .mat-mdc-form-field .mat-mdc-icon-button, .later-payment[_ngcontent-%COMP%] .mat-mdc-form-field .mat-mdc-button-persistent-ripple, .later-payment[_ngcontent-%COMP%] .mat-mdc-form-field .mat-mdc-form-field-icon-suffix{outline:none!important}']})};function Ra(n,t){if(n&1&&(a(0,"tr")(1,"td")(2,"a",7),m(3),r()(),a(4,"td"),m(5),u(6,"number"),r(),a(7,"td",6),m(8),u(9,"number"),r()()),n&2){let e=t.$implicit;l(3),ee(e.Name),l(2),ee(C(6,3,e.UnitPrice)),l(3),E(" ",C(9,5,e.MaxOrderPrice)," ")}}var Pi=class n{config=new Ie;data=G(ke);hasExceededMaxPrice=se(!1);dialogRef=G(Oe);constructor(){this.config.title="Cost Maximum Warning",this.config.customWidth="400px",this.config.bodyScrollable=!0,this.config.hideCancel=!0,this.config.okText="Close",this.config.headerType=be.Warning,this.hasExceededMaxPrice.set(this.data.some(t=>t.MaxOrderPrice>0&&t.UnitPrice>t.MaxOrderPrice))}close(){this.dialogRef.close()}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=V({type:n,selectors:[["POS-modal-exceeded-cost"]],decls:17,vars:1,consts:[[3,"onOk","onClose","config"],[1,"container-fluid"],[1,"row"],[1,"col-12"],["id","tableGrid",1,"table","table-bordered"],[1,"thead-light"],[1,"text-end"],["target","_blank"]],template:function(e,i){e&1&&(a(0,"modal-material",0),D("onOk",function(){return i.close()})("onClose",function(){return i.close()}),a(1,"content")(2,"div",1)(3,"div",2)(4,"div",3)(5,"table",4)(6,"thead",5)(7,"tr")(8,"th"),m(9,"Name"),r(),a(10,"th"),m(11,"Cost"),r(),a(12,"th",6),m(13,"Max"),r()()(),a(14,"tbody"),we(15,Ra,10,7,"tr",null,tn),r()()()()()()()),e&2&&(y("config",i.config),l(15),Ne(i.data))},dependencies:[Pe,te,ye],encapsulation:2})};function Ba(n,t){if(n&1&&(vt(0,"div"),m(1),u(2,"number"),_t()),n&2){let e=d();l(),E(" ",C(2,1,e.amountToPayRounded)," ")}}function $a(n,t){n&1&&m(0," - ")}var Oi=class n{constructor(t,e,i,o,s,F,f,w,H,M,j){this.matDialog=t;this.toastr=e;this.form=i;this.cart=o;this.http=s;this.complete=F;this.role=f;this.load=w;this.posMath=H;this.math=M;this.paymentService=j}cartLength=N(0);amountToPay=N(0);currencySymbol=N("");dueDate=N(null);cashPayments=N([]);cardPayments=N([]);otherPayments=N([]);paymentMethodID=N(0);paymentNote=N("");paymentCode=N("");defaultDueDays=N(null);invoiceDate=N(null);dueDays=N(0);appConfigJSON=N(void 0);isUnpaidOnEdit=N(!1);isEditBuyForm=N(!1);totalVariantOrdered=N(0);isCashSuspended=N(!1);denomination=N([]);isReturn=N(!1);pay(){return oe(this,null,function*(){if(this.cartLength()==0){this.toastr.info("You must have at least one item",be.Info);return}if(this.form.discountAndTaxForm.value.Tax.Discontinue){this.toastr.info(`Cannot find the ${this.form.discountAndTaxForm.value.Tax.Label}, Set the tax discontinue status to \u201CNo\u201D to use tax or choose another tax type`,be.Info);return}let t=I.IsEmpty(this.form.buyForm.controls.Order.controls.SupplierID.value);if(this.appConfigJSON()?.ModuleBuy.Header.SupplierRequired&&t){this.toastr.info("Supplier is required",be.Info);return}let e=yield Qi(this.cart.cart$);if(e.some(f=>{let w=f.MaxOrderPrice;return w>0&&f.UnitPrice>w})&&this.role.buyRestriction?.CostMax){this.matDialog.open(Pi,{data:e});return}this.matDialog.open(Ii,{data:{displayedAmountToPay:this.posMath.Round(this.amountToPay(),this.appConfigJSON()?.ApplicationMath.RoundingPurchaseDigit?.DecimalPlaceValue,this.appConfigJSON()?.ApplicationMath.RoundingPurchaseDigit?.RoundAlgorithm),amountToPay:this.posMath.Round(this.form.buyForm.controls.Payment.controls.Amount.value,this.appConfigJSON()?.ApplicationMath.RoundingPurchaseDigit?.DecimalPlaceValue,this.appConfigJSON()?.ApplicationMath.RoundingPurchaseDigit?.RoundAlgorithm),currencySymbol:this.currencySymbol(),dueDate:I.cloneObject(this.dueDate()),dueDays:I.cloneObject(this.dueDays()),cardPayments:this.cardPayments(),otherPayments:this.otherPayments(),cashPaymentMethodID:this.cashPayments()[0]?.ID,paymentMethodID:this.paymentMethodID(),paymentNote:this.paymentNote(),paymentCode:this.paymentCode(),invoiceDate:this.invoiceDate(),payDefaultState:this.appConfigJSON()?.ModuleBuy?.PaymentDialog?.DefaultOption!=1,isUnpaidOnEdit:this.isUnpaidOnEdit(),isEdit:this.isEditBuyForm(),isCashSuspended:this.isCashSuspended(),denomination:this.denomination()}}).afterClosed().pipe(A(f=>!!f),p(f=>f)).pipe(k(f=>this.paymentService.paymentMethodName.set(f.paymentMethodName)),fe(this.cart.cart$),p(([f,w])=>B(P({},f),{cart:w})),fe(this.load.entities$),p(([f,w])=>B(P({},f),{entities:w})),fe(this.load.supplierPOTypes$),p(([f,w])=>B(P({},f),{supplierPOTypes:w})),Y(f=>{I.IsEmpty(this.form.noteForm.value.TagID)&&this.form.setBulkNoteForm(B(P({},this.form.noteForm.value),{TagID:f.supplierPOTypes[0]?.ID}));let w=this.form.buyForm.controls,H=w.Invoice.controls,M=w.Payment.controls,j=this.form.outlet.value,c=w.Order.controls,S=this.form.noteForm.value,L=this.form.discountAndTaxForm.value,ne=M.Amount.value,h=w.NewOrderID?.value,{deliveryEntityID:b,fulfillmentDateTime:R}=this.form.fulfillmentResult.value,$={ID:H.ID.value,Due:f.payState=="Now"?void 0:H.Due.value,Tax:H.Tax.value,Sales:ne??0,PaymentStateID:f.payState=="Now"?3:1,Number:S.InvoiceNumber?S.InvoiceNumber:c.Number.value},Te=f.cart.map(_e=>B(P({},_e),{VariantID:I.IsEmpty(_e.VariantID)?_e.ID:_e.VariantID}));this.isEditBuyForm()&&(Te=Te.map(_e=>B(P({},_e),{QtyRequested:_e.Quantity})));let Ve={EntityID:j.ID,SupplierID:c.SupplierID.value,Date:c.Date.value,CurrencyID:S.Currency.ID,CurrencyRate:S.Currency.ExchangeRate,Discount:L.Discount.Percentage,DiscountAmount:this.isReturn()?L.Discount.Amount*-1:L.Discount.Amount,Note:S.Note,Att:c.Att.value,TaxTypeID:L.Tax.ID,TypeID:S.TagID,Number:c.Number.value,ID:c.ID.value};if(f.payState=="Now"){let _e={ID:M.ID?.value??I.GuidEmpty,MethodID:f.paymentMethodID,Code:f.paymentCode??"",Note:f.paymentNote??"",Amount:this.posMath.Round(f.amount,this.appConfigJSON()?.ApplicationMath.RoundingPurchaseDigit.DecimalPlaceValue,this.appConfigJSON()?.ApplicationMath.RoundingPurchaseDigit.RoundAlgorithm),Date:Ve.Date,ImageUrl:M.ImageUrl?.value};f.amount<ne?$.PaymentStateID=2:f.amount>ne&&($.PaymentStateID=5);let re={DeliveryEntityID:b,NewOrderID:this.isEditBuyForm?null:h,Invoice:B(P({},$),{CustomDateField:R}),Order:Ve,Items:Te,Payment:_e};return this.http.post("/API/Buy/SubmitOrder2",re,1e4,!0).pipe(p(ct=>B(P({},ct),{differentNumber:ct.InvoiceNumber!=Ve.Number})),ve(ct=>{throw ct.error&&this.toastr.error(ct.error.Message,"Order Submission Failed"),new Error(ct)}))}else{let _e={DeliveryEntityID:b,NewOrderID:this.isEditBuyForm?null:I.Guid_NewGuid(),Invoice:B(P({},$),{Due:f.dueDate,CustomDateField:R}),Order:Ve,Items:Te};return this.http.post("/API/Buy/SubmitOrder2",_e,1e4,!0).pipe(p(re=>B(P({},re),{differentNumber:re.InvoiceNumber!=Ve.Number})),ve(re=>{throw re.error&&this.toastr.error(re.error.Message,"Order Submission Failed"),new Error(re)}))}})).subscribe(f=>{this.complete.paymentComplete(f),f.differentNumber&&this.toastr.info(`Bill number has been changed to ${f.InvoiceNumber}`,"Bill Number Changed!")})})}get amountToPayRounded(){return this.posMath.Round(this.amountToPay(),this.appConfigJSON()?.ApplicationMath?.RoundingPurchaseDigit?.DecimalPlaceValue,this.appConfigJSON()?.ApplicationMath?.RoundingPurchaseDigit?.RoundAlgorithm)}static \u0275fac=function(e){return new(e||n)(g(ie),g(Le),g(z),g(Z),g(pe),g(He),g(Ce),g(ue),g(Ai),g(Ai),g(qe))};static \u0275cmp=V({type:n,selectors:[["POS-pay-button"]],inputs:{cartLength:[1,"cartLength"],amountToPay:[1,"amountToPay"],currencySymbol:[1,"currencySymbol"],dueDate:[1,"dueDate"],cashPayments:[1,"cashPayments"],cardPayments:[1,"cardPayments"],otherPayments:[1,"otherPayments"],paymentMethodID:[1,"paymentMethodID"],paymentNote:[1,"paymentNote"],paymentCode:[1,"paymentCode"],defaultDueDays:[1,"defaultDueDays"],invoiceDate:[1,"invoiceDate"],dueDays:[1,"dueDays"],appConfigJSON:[1,"appConfigJSON"],isUnpaidOnEdit:[1,"isUnpaidOnEdit"],isEditBuyForm:[1,"isEditBuyForm"],totalVariantOrdered:[1,"totalVariantOrdered"],isCashSuspended:[1,"isCashSuspended"],denomination:[1,"denomination"],isReturn:[1,"isReturn"]},decls:11,vars:7,consts:[["type","button",1,"btn","btn-success","fs-1","py-4",2,"border-left","0.1px solid #fff",3,"click"],[1,"d-flex","align-items-center","justify-content-between"],[1,"fs-6"]],template:function(e,i){e&1&&(vt(0,"button",0),Ut("click",function(){return i.pay()}),vt(1,"div",1)(2,"div")(3,"span"),m(4,"Pay"),_t(),vt(5,"small",2),m(6),u(7,"number"),u(8,"quantityFraction"),_t()(),v(9,Ba,3,3,"div")(10,$a,1,0),_t()()),e&2&&(l(6),$e(" (",C(7,3,i.cartLength())," Items & ",C(8,5,i.totalVariantOrdered())," Qty) "),l(3),_(i.role.product.Cost?9:10))},dependencies:[te,ye,Xt],styles:["button[_ngcontent-%COMP%]{border-right:.1px solid #fff;margin-left:-1px;border-top-left-radius:0;border-bottom-left-radius:0;position:relative;flex:1 1 auto}"],changeDetection:0})};var Nt=class n{noteForm;constructor(t){this.noteForm=t.noteForm}static \u0275fac=function(e){return new(e||n)(q(z))};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};var Et=class n{dueDate$;dueDays$;constructor(t){let e=t.buyForm.controls.Invoice.controls.Due.valueChanges;this.dueDays$=t.dueDays.valueChanges,t.buyForm.controls.Order.controls.Date.valueChanges.pipe(k(console.log),fe(this.dueDays$),k(([s,F])=>t.setDueDateBasedOnDaysDue(F)),k(console.log)).subscribe(),this.dueDate$=e,this.dueDate$.subscribe(s=>console.log(s,"dueDate$"))}static \u0275fac=function(e){return new(e||n)(q(z))};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};function Ua(n,t){if(n&1&&(a(0,"tr")(1,"th",11),m(2,"Amount"),r(),a(3,"td",12),m(4),u(5,"number"),r()()),n&2){let e=d();l(4),ee(C(5,1,e.displayedAmount))}}function Qa(n,t){if(n&1&&(a(0,"td",13),m(1),u(2,"number"),r()),n&2){let e=d(3);l(),E(" ",C(2,1,e.displayedDiscountPercentage.value*-1)," ")}}function Wa(n,t){if(n&1&&(a(0,"tr")(1,"th",11),m(2),r(),v(3,Qa,3,3,"td",13),r()),n&2){let e=d(2),i=d();l(2),E(" ",e.displayedDiscountPercentage.label," "),l(),_(i.role.product.Cost?3:-1)}}function Ja(n,t){if(n&1&&(a(0,"td",13),m(1),u(2,"number"),r()),n&2){let e=d(3);l(),E(" ",C(2,1,e.displayedDiscountAmount.value)," ")}}function Ha(n,t){if(n&1&&(a(0,"tr")(1,"th",11),m(2),r(),v(3,Ja,3,3,"td",13),r()),n&2){let e=d(2),i=d();l(2),ee(e.displayedDiscountAmount.label),l(),_(i.role.product.Cost?3:-1)}}function Ga(n,t){if(n&1&&(a(0,"td",12),m(1),u(2,"number"),r()),n&2){let e=d(3);l(),E(" ",C(2,1,e.displayedTax.tax.value)," ")}}function qa(n,t){if(n&1&&(a(0,"tr")(1,"th",11),m(2),r(),v(3,Ga,3,3,"td",12),r()),n&2){let e=d(2),i=d();l(2),ee(e.displayedTax.label),l(),_(i.role.product.Cost?3:-1)}}function Ka(n,t){if(n&1&&(v(0,Wa,4,2,"tr"),v(1,Ha,4,2,"tr"),v(2,qa,4,2,"tr")),n&2){let e=d();_(e.displayedDiscountPercentage.value!=0?0:-1),l(),_(e.displayedDiscountAmount.value!=0?1:-1),l(),_(e.displayedTax.tax.value!=0?2:-1)}}function za(n,t){if(n&1&&(a(0,"div",0)(1,"div",9)(2,"table",10),v(3,Ua,6,3,"tr"),v(4,Ka,3,3),u(5,"async"),r()()()),n&2){let e=t,i=d();l(3),_(i.showAmountWhenDiscountOrTaxIsApplied(e)&&e.displayedAmount&&i.role.product.Cost?3:-1),l(),_(C(5,2,i.cartLength$)?4:-1)}}var Ti=class n{constructor(t,e,i,o,s,F,f,w){this.payment=t;this.form=i;this.role=F;this.taxes$=e.taxes$,this.defaultCurrencyID$=e.appConfigJSON$.pipe(p(S=>S.CoreDefaults.CurrencyID)),this.totalVariantOrdered$=this.cart.totalVariantOrdered$,this.cartLength$=this.cart.cart$.pipe(p(S=>S.length)),this.amountAfterDiscountAndTax$=t.amountAfterDiscountAndTax$,this.discountAndTaxForm=i.discountAndTaxForm;let H=t.displayedAmount$,M=t.displayedDiscountPercentage$,j=t.displayedDiscountAmount$,c=t.displayedTax$;this.displayedDiscountAndTax$=xe({displayedAmount:H,displayedDiscountPercentage:M,displayedDiscountAmount:j,displayedTax:c}),this.fulfillmentResult=i.fulfillmentResult,this.noteForm=o.noteForm,this.currencies$=e.currencies$,this.currencySymbol$=t.currencySymbol$,this.supplierPOTypes$=e.supplierPOTypes$,this.predefinedNotes$=e.predefinedNotes$,this.outlets$=e.entities$,this.cashPayments$=w.cashPayments$,this.cardPayments$=w.cardPayments$,this.otherPayments$=w.otherPayments$,this.defaultDueDays$=e.defaultDueDays$,this.dueDate$=s.dueDate$,this.dueDays$=s.dueDays$,this.appConfigJSON$=e.appConfigJSON$,this.isUnpaidOnEdit$=xe(f.isEdit$,f.isUnpaid$).pipe(p(([S,L])=>S&&L)),this.isEdit$=f.isEdit$,this.outlet=i.outlet,this.isCashSuspended$=w.isCashSuspended$,this.denomination$=e.denomination$}cart=G(Z);taxes$;totalVariantOrdered$;displayedDiscountAndTax$;discountAndTaxForm;fulfillmentResult;noteForm;amountAfterDiscountAndTax$;currencies$;currencySymbol$;supplierPOTypes$;predefinedNotes$;defaultCurrencyID$;outlets$;cashPayments$;cardPayments$;otherPayments$;defaultDueDays$;dueDate$;dueDays$;appConfigJSON$;isUnpaidOnEdit$;isEdit$;isCashSuspended$;outlet;cartLength$;denomination$;isReturn=Jt(()=>this.cart.isReturn());get amountToPay(){return this.payment.amountToPay}get invoiceDate(){return this.form.invoiceDate}get paymentMethodID(){return this.payment.methodID}get paymentNote(){return this.payment.note}get paymentCode(){return this.payment.code}showAmountWhenDiscountOrTaxIsApplied(t){return t.displayedDiscountPercentage.value!=0||t.displayedDiscountAmount.value!=0||t.displayedTax.tax.value!=0}ngOnDestroy(){this.cart.isReturn.set(!1)}static \u0275fac=function(e){return new(e||n)(g(qe),g(ue),g(z),g(Nt),g(Et),g(Ce),g(Je),g(ot))};static \u0275cmp=V({type:n,selectors:[["POS-cart-footer"]],decls:34,vars:85,consts:[[1,"row","g-0","px-5","justify-content-end"],[1,"row","g-0","pb-6","px-5"],[1,"col-5","d-flex","justify-content-between","pe-5",2,"column-gap","12px"],[2,"flex-grow","1",3,"supplierPOTypes","predefinedNotes","defaultCurrencyID","currencies","formControl"],[2,"flex-grow","3",3,"outlets","formControl","appConfigJSON","outletID","isEdit"],[1,"col-7"],[1,"btn-group","w-100"],[2,"display","inline-flex",3,"taxes","currencySymbol","formControl","isReturn"],[1,"w-100",2,"display","inline-flex",3,"amountToPay","currencySymbol","dueDate","dueDays","cardPayments","otherPayments","paymentMethodID","paymentCode","paymentNote","defaultDueDays","invoiceDate","appConfigJSON","cashPayments","isUnpaidOnEdit","isEditBuyForm","cartLength","totalVariantOrdered","isCashSuspended","denomination","isReturn"],[1,"col-6",2,"padding-right","15px"],[1,"table","table-borderless"],[1,"text-start"],[1,"text-end","fs-5"],[1,"text-end","fs-5","text-danger"]],template:function(e,i){if(e&1&&(v(0,za,6,4,"div",0),u(1,"async"),a(2,"div",1)(3,"div",2),x(4,"POS-note-form",3),u(5,"async"),u(6,"async"),u(7,"async"),u(8,"async"),x(9,"POS-fulfillment-form",4),u(10,"async"),u(11,"async"),u(12,"async"),r(),a(13,"div",5)(14,"div",6),x(15,"POS-discount-and-tax-form",7),u(16,"async"),u(17,"async"),x(18,"POS-pay-button",8),u(19,"async"),u(20,"async"),u(21,"async"),u(22,"async"),u(23,"async"),u(24,"async"),u(25,"async"),u(26,"async"),u(27,"async"),u(28,"async"),u(29,"async"),u(30,"async"),u(31,"async"),u(32,"async"),u(33,"async"),r()()()),e&2){let o;_((o=C(1,35,i.displayedDiscountAndTax$))?0:-1,o),l(4),y("supplierPOTypes",C(5,37,i.supplierPOTypes$))("predefinedNotes",C(6,39,i.predefinedNotes$))("defaultCurrencyID",C(7,41,i.defaultCurrencyID$))("currencies",C(8,43,i.currencies$))("formControl",i.noteForm),l(5),y("outlets",C(10,45,i.outlets$))("formControl",i.fulfillmentResult)("appConfigJSON",C(11,47,i.appConfigJSON$))("outletID",i.outlet.value.ID)("isEdit",C(12,49,i.isEdit$)),l(6),y("taxes",C(16,51,i.taxes$))("currencySymbol",C(17,53,i.currencySymbol$))("formControl",i.discountAndTaxForm)("isReturn",i.isReturn()),l(3),y("amountToPay",C(19,55,i.amountAfterDiscountAndTax$))("currencySymbol",C(20,57,i.currencySymbol$))("dueDate",C(21,59,i.dueDate$))("dueDays",C(22,61,i.dueDays$))("cardPayments",C(23,63,i.cardPayments$))("otherPayments",C(24,65,i.otherPayments$))("paymentMethodID",i.paymentMethodID)("paymentCode",i.paymentCode)("paymentNote",i.paymentNote)("defaultDueDays",C(25,67,i.defaultDueDays$))("invoiceDate",i.invoiceDate)("appConfigJSON",C(26,69,i.appConfigJSON$))("cashPayments",C(27,71,i.cashPayments$))("isUnpaidOnEdit",C(28,73,i.isUnpaidOnEdit$))("isEditBuyForm",C(29,75,i.isEdit$))("cartLength",C(30,77,i.cartLength$))("totalVariantOrdered",C(31,79,i.totalVariantOrdered$))("isCashSuspended",C(32,81,i.isCashSuspended$))("denomination",C(33,83,i.denomination$))("isReturn",i.isReturn())}},dependencies:[te,_i,tt,de,et,xi,Mi,Oi,Se,ye],encapsulation:2,changeDetection:0})};var Ya=n=>({"date-warning":n}),Xa=()=>["/menu/Orders/Orders/Supplier_Bill/Info"],Za=n=>({ID:n});function er(n,t){if(n&1&&(m(0),u(1,"async"),u(2,"number")),n&2){let e=d().$implicit,i=d();$e(" ",C(1,2,i.currencySymbol$)," ",C(2,4,e.Total)," ")}}function tr(n,t){n&1&&m(0," - ")}function ir(n,t){if(n&1&&(a(0,"div",25)(1,"div",27),m(2),r(),a(3,"div",28),v(4,er,3,6)(5,tr,1,0),r()()),n&2){let e=t.$implicit,i=d();l(2),ee(e.Name),l(2),_(i.role.product.Cost?4:5)}}function nr(n,t){if(n&1&&(a(0,"tr")(1,"td",31),m(2),r(),a(3,"td",32),m(4),u(5,"async"),r(),a(6,"td",31),m(7),u(8,"number"),r()()),n&2){d();let e=Tt(0),i=d();l(2),ee(e.label),l(2),E(" ",C(5,3,i.currencySymbol$)," "),l(3),E(" ",C(8,5,e.value)," ")}}function or(n,t){if(n&1&&(a(0,"tr")(1,"td",31),m(2,"Discount:"),r(),a(3,"td",32),m(4),u(5,"async"),r(),a(6,"td",31),m(7),u(8,"number"),r()()),n&2){d();let e=Tt(2),i=d();l(4),E(" ",C(5,2,i.currencySymbol$)," "),l(3),E(" ",C(8,4,e.value)," ")}}function ar(n,t){if(n&1&&(a(0,"tr")(1,"td",31),m(2),r(),a(3,"td",32),m(4),u(5,"async"),r(),a(6,"td",31),m(7),u(8,"number"),r()()),n&2){d();let e=Tt(4),i=d();l(2),ee(e.label),l(2),E(" ",C(5,3,i.currencySymbol$)," "),l(3),E(" ",C(8,5,e==null||e.tax==null?null:e.tax.value)," ")}}function rr(n,t){if(n&1&&(a(0,"tr",33)(1,"td",31),m(2),r(),a(3,"td",32),m(4),u(5,"async"),r(),a(6,"td",31),m(7),u(8,"async"),u(9,"number"),r()()),n&2){let e=d(2);l(2),E(" ",e.payment.paymentMethodName(),": "),l(2),E(" ",C(5,3,e.currencySymbol$)," "),l(3),E(" ",C(9,7,C(8,5,e.displayedAmount$))," ")}}function lr(n,t){if(n&1&&(rt(0),u(1,"async"),rt(2),u(3,"async"),rt(4),u(5,"async"),a(6,"div",26)(7,"div",29)(8,"table",30)(9,"tbody")(10,"tr")(11,"td",31),m(12,"Amount:"),r(),a(13,"td",32),m(14),u(15,"async"),r(),a(16,"td",31),m(17),u(18,"async"),u(19,"number"),r()(),v(20,nr,9,7,"tr"),v(21,or,9,6,"tr"),v(22,ar,9,7,"tr"),v(23,rr,10,9,"tr",33),r()()()()),n&2){let e=d(),i=Ot(C(1,6,e.displayedDiscountPercentage$));l(2);let o=Ot(C(3,9,e.displayedDiscountAmount$));l(2);let s=Ot(C(5,12,e.displayedTax$));l(10),E(" ",C(15,15,e.currencySymbol$)," "),l(3),E(" ",C(19,19,C(18,17,e.displayedAmount$))," "),l(3),_(i.value>0?20:-1),l(),_(o.value>0?21:-1),l(),_((s==null||s.tax==null?null:s.tax.value)>0?22:-1),l(),_(e.payment.paymentMethodName()?23:-1)}}var wi=class n{constructor(t,e,i,o,s,F,f,w){this.payment=t;this.form=e;this.cart=i;this.complete=o;this.load=s;this.router=F;this.outletInfo=f;this.role=w;this.displayedAmount$=t.displayedAmount$,this.displayedDiscountPercentage$=t.displayedDiscountPercentage$,this.displayedDiscountAmount$=t.displayedDiscountAmount$,this.displayedTax$=t.displayedTax$}data=N(void 0,{alias:"paymentComplete"});displayedAmount$;displayedDiscountPercentage$;displayedDiscountAmount$;displayedTax$;currencySymbol$;createNewTransaction(){this.clearCart(),this.resetBuyForm(),this.updateDueDays(),this.updateTax(),this.updatePaymentMethodID(),this.complete.paymentComplete(null),this.complete.createNewTransaction(),this.router.navigate([],{queryParams:{ID:null}})}get amountToPay(){return this.payment.amountToPay}resetBuyForm(){this.form.resetNoteForm(),this.form.resetDiscountAndTaxForm(),this.form.resetDueDaysForm(),this.form.resetBuyForm(),this.form.resetFulfillmentDate()}clearCart(){this.cart.clearCart()}updateDueDays(){this.load.updateDueDays()}updateTax(){this.outletInfo.updateTax()}updatePaymentMethodID(){this.outletInfo.updatePaymentMethodID()}static \u0275fac=function(e){return new(e||n)(g(qe),g(z),g(Z),g(He),g(ue),g(Ht),g(ot),g(Ce))};static \u0275cmp=V({type:n,selectors:[["POS-complete"]],inputs:{data:[1,"paymentComplete","data"]},decls:38,vars:15,consts:[[1,"pt-7",2,"border-bottom","1px solid rgba(0, 0, 0, 0.1)"],[1,"ps-7","fw-normal","pb-7"],[1,"buy-complete"],[1,"container-fluid","pt-8"],[1,"row"],[1,"col-md-8"],[1,"card"],[1,"card-header"],[1,"d-flex","justify-content-between"],[1,"fa-solid","fa-check","me-1"],[1,"fst-italic"],[1,"card-body"],[1,"container"],[1,"row","mt-9","justify-content-center","g-0","mb-9"],[1,"col-9","text-center"],["type","button",1,"btn","btn-success","btn-lg","w-100","fs-2",3,"click"],[1,"card-footer","bg-light-gray"],[1,"row","justify-content-between","py-5"],[1,"col-auto"],["target","_blank",1,"btn","btn-light-gray",3,"href"],[1,"fa-solid","fa-print","me-2"],[1,"col-md-4"],[1,"card-header","bg-light-gray"],[1,"text-dark"],["target","_blank",1,"text-dark","fst-italic",3,"routerLink","queryParams"],[1,"row","my-1","p-5"],[1,"card-footer","pe-0","bg-white"],[1,"col-8"],[1,"col-4","text-end"],[1,"ms-auto"],[1,"table","table-borderless","mb-0","table-sm"],[1,"text-end"],[1,"text-start"],[2,"border-top","1px solid rgba(0, 0, 0, 0.1)"]],template:function(e,i){e&1&&(a(0,"div",0)(1,"h1",1),m(2,"New Purchase Order"),r()(),a(3,"section",2)(4,"div")(5,"div",3)(6,"div",4)(7,"div",5)(8,"div",6)(9,"div",7)(10,"div",8)(11,"h2"),x(12,"i",9),m(13," Purchase Complete "),a(14,"small",10),m(15),r()()()(),a(16,"div",11)(17,"div",12)(18,"div",13)(19,"div",14)(20,"button",15),D("click",function(){return i.createNewTransaction()}),m(21," New Purchase (F8) "),r()()()()(),a(22,"div",16)(23,"div",17)(24,"div",18)(25,"a",19),x(26,"i",20),m(27,"Print Receipt "),r()()()()()(),a(28,"div",21)(29,"div",6)(30,"div",22)(31,"h3",23)(32,"a",24),m(33),r()()(),we(34,ir,6,2,"div",25,Be),u(36,"async"),v(37,lr,24,21,"div",26),r()()()()()()),e&2&&(l(9),At(le(10,Ya,i.data().PaymentStateID<3)),l(6),E(" (",i.data().PaymentStateLabel,") "),l(10),y("href",i.data().Message,dt),l(7),y("routerLink",Qt(12,Xa))("queryParams",le(13,Za,i.data().InvoiceID)),l(),E(" Supplier Bill #",i.data().InvoiceNumber," "),l(),Ne(C(36,8,i.cart.cart$)),l(3),_(i.role.product.Cost?37:-1))},dependencies:[te,qt,Gt,Se,ye],styles:[".print_containers[_ngcontent-%COMP%]{display:none}@media print{.print_containers[_ngcontent-%COMP%]{display:block;text-align:left}.buy-complete[_ngcontent-%COMP%]{display:none}}.table-sm[_ngcontent-%COMP%] th[_ngcontent-%COMP%], .table-sm[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:10px!important}.buy-complete[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] .card-header[_ngcontent-%COMP%]{border-bottom:1px solid rgba(0,0,0,.125);padding-bottom:.9375rem}.buy-complete[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] .card-header[_ngcontent-%COMP%] h2[_ngcontent-%COMP%]{font-size:2rem}.buy-complete[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] .card-body[_ngcontent-%COMP%] .container[_ngcontent-%COMP%]{max-width:500px;margin-top:30px;margin-bottom:30px}.table[_ngcontent-%COMP%] th[_ngcontent-%COMP%], .table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{vertical-align:middle;line-height:15px!important}"],changeDetection:0})};var sr=["cartDisplayRef"],cr=(n,t)=>({label:n,tooltip:t}),mr=n=>({data:n}),dr=n=>({"bg-gradient-warning px-2":n}),pr=n=>({"me-3":n});function ur(n,t){n&1&&x(0,"POS-complete",2),n&2&&y("paymentComplete",t)}function fr(n,t){n&1&&on(0)}function gr(n,t){if(n&1&&(a(0,"div",9),kt(1,fr,1,0,"ng-container",31),r()),n&2){let e=d(2),i=It(4);l(),y("ngTemplateOutlet",i)("ngTemplateOutletContext",le(5,mr,lt(2,cr,e.fulfillmentOutletName(),e.fulfillmentOutletName())))}}function Cr(n,t){if(n&1){let e=U();a(0,"div",3)(1,"div",4)(2,"div",5)(3,"div",6),x(4,"POS-select-outlet-form",7),u(5,"async"),u(6,"async"),u(7,"async"),x(8,"POS-invoice-number-form",8),u(9,"async"),a(10,"div"),v(11,gr,2,7,"div",9),x(12,"POS-invoice-date",10),r()()(),a(13,"div",11)(14,"div",12)(15,"div",13),x(16,"POS-more-actions",14),u(17,"async"),u(18,"async"),r(),a(19,"div",15)(20,"div",16),x(21,"i",17)(22,"input",18),r()(),a(23,"div",19)(24,"div",20)(25,"button",21),u(26,"async"),D("click",function(){O(e);let o=d();return T(o.collapseSidebar())}),x(27,"span",22)(28,"span",22)(29,"span",22),r()()()()()(),a(30,"div",23)(31,"div",5),x(32,"POS-quick-key",24),u(33,"async"),r(),a(34,"div",25)(35,"div",26)(36,"div",27),x(37,"POS-variant-autocomplete",28),r(),a(38,"div",15),x(39,"POS-supplier-autocomplete",29),u(40,"async"),u(41,"async"),r()(),x(42,"POS-cart-display",30,1),u(44,"async"),u(45,"async"),u(46,"async"),x(47,"POS-cart-footer"),r()()()}if(n&2){let e=d();l(4),y("outlets",C(5,32,e.outlets$))("isOpenAfterLoad",C(6,34,e.isOpenDialogOutlet$))("formControl",e.outlet)("disabled",C(7,36,e.isEdit$))("disableCloseDialog",!0),l(4),y("formControl",e.poNumber)("isEdit",C(9,38,e.isEdit$)),l(3),_(e.isFulfillmentDifferentOutlet()?11:-1),l(),y("formControl",e.date)("tooltip",e.role.global!=null&&e.role.global.Date?"":"Date role is required"),l(4),y("returnInvoiceNumber",e.returnInvoiceNumber)("appConfigJSON",C(17,40,e.appConfigJSON$))("isEditBuyForm",C(18,42,e.isEdit$))("outletID",e.outlet.value.ID)("outletName",e.outlet.value.Name),l(6),y("formControl",e.attention),l(3),Pt("change",C(26,44,e.toggleState$)),l(7),y("quickKey",C(33,46,e.quickKeyPack$))("outletID",e.outlet.value.ID)("formControl",e.variantQuickKey),l(5),y("formControl",e.variantAutocomplete)("autocompleteEndpoint",e.variantAutocompleteEndpoint)("outletID",e.outlet.value.ID),l(2),y("formControl",e.supplierID)("supplierPOTypes",C(40,48,e.supplierPOTypes$))("appConfigJSON",C(41,50,e.appConfigJSON$)),l(3),y("cart",C(44,52,e.cart$))("appConfigJSON",C(45,54,e.appConfigJSON$))("isEdit",C(46,56,e.isEdit$))("outletID",e.outlet.value.ID)("outletName",e.outlet.value.Name)}}function yr(n,t){if(n&1&&(a(0,"h5",36),m(1),u(2,"limitText"),r()),n&2){let e=d().data;l(),ee(pt(2,1,e==null?null:e.label,14))}}function br(n,t){if(n&1&&(a(0,"div",32)(1,"div",33)(2,"div",34),x(3,"i",35),r(),v(4,yr,3,4,"h5",36),r()()),n&2){let e=t.data;y("ngClass",le(4,dr,e.label))("matTooltip",e==null?null:e.tooltip),l(2),y("ngClass",le(6,pr,e.label)),l(2),_(e!=null&&e.label?4:-1)}}var ao=class n extends Sn{constructor(e,i,o,s,F,f,w,H,M,j,c,S,L){Ki(()=>{this.cartDisplayRef()&&(s.cartDisplayRef=this.cartDisplayRef())});super(S);this.form=i;this.intercom=f;this.role=M;this.toggle=j;this.lowOnStock=c;this.menuData$.subscribe();let ne=i.buyForm.controls.Order.controls;this.outlets$=e.entities$,this.outlet=i.outlet,this.isEdit$=w.isEdit$.pipe(k(h=>h?this.outlet.disable():this.outlet.enable())),this.date=ne.Date,M.global.Date==!1&&this.date.disable(),this.supplierID=ne.SupplierID,this.attention=ne.Att,this.poNumber=i.buyForm.controls.Order.controls.Number,this.role?.sell?.Number||this.poNumber.disable(),this.quickKeyPack$=o.quickKeyPack$,this.variantAutocomplete=s.variantAutocomplete,this.variantQuickKey=s.variantQuickKey,this.returnInvoiceNumber=F.returnInvoiceNumber,this.cart$=s.cart$,this.appConfigJSON$=e.appConfigJSON$,this.isOpenDialogOutlet$=c.selectedLowOnStockData.length==0?this.isEdit$.pipe(Y(h=>H.createNewTransaction$.pipe(p(b=>b||h))),p(h=>!h)):Ke(!1),c.selectedLowOnStockData.length&&(i.setOutletForm({ID:c.selectedLowOnStockData[0].EntityID,Name:c.selectedLowOnStockData[0].Outlet}),L.post("/API/catalog/variant/GetVariantByListID",{ListID:c.selectedLowOnStockData.map(h=>h.ID),EntityID:c.selectedLowOnStockData[0].EntityID}).pipe(p(h=>h.map(b=>this.setUnitPrice(b)).map(b=>({VariantID:b.ID,UnitPrice:b.UnitPrice})))).subscribe(h=>{i.setDeliveryEntityID(c.selectedLowOnStockData[0].EntityID);let b=c.selectedLowOnStockData.map(R=>({Quantity:R.Quantity,UnitQuantity:R.UnitQuantity,UnitPrice:h.find($=>$.VariantID==R.VariantID).UnitPrice,Code:R.Code,Name:R.Product,DiscountAmount:R.DiscountAmount,Discount:R.Discount,Total:R.Total*h.find($=>$.VariantID==R.VariantID).UnitPrice,VariantID:R.VariantID}));s.editForm(b)})),this.paymentComplete$=H.paymentComplete$,this.supplierPOTypes$=e.supplierPOTypes$,this.toggleState$=j.toggleState$,this.initFulfillmentDifferentOutlet()}selectOutletFormComponent=ut(ei);requireOutletSelected(){return oe(this,null,function*(){return this.outlet?.value?.ID?!0:(yield this.openOutletSelectorModal(),!!this.outlet?.value?.ID)})}openOutletSelectorModal(){return new Promise(e=>{let i=this.selectOutletFormComponent();if(i){i.openModalSelectOutlet();let o=i.onCloseDialog.subscribe(()=>{o.unsubscribe(),e()})}else e()})}cartDisplayRef=ut("cartDisplayRef",{read:Ei});variantAutocompleteEndpoint=Ue.GetVariantSuggestionsByEntityID;sf=G(Vt);outlets$;quickKeyPack$;outlet;poNumber;date;supplierID;variantAutocomplete=new ge;variantQuickKey=new ge;returnInvoiceNumber;cart$;appConfigJSON$;attention;isEdit$;paymentComplete$;supplierPOTypes$;isOpenDialogOutlet$;toggleState$;renderer=G(Yi);isFulfillmentDifferentOutlet=se(!1);fulfillmentOutletName=se("");ngAfterViewInit(){let e=document.querySelector("#full-container");this.renderer.addClass(e,"full-container"),this.intercom.hideLauncher()}initFulfillmentDifferentOutlet(){xe([this.form.outlet.valueChanges.pipe(Ye(this.form.outlet.value)),this.form.fulfillmentResult.valueChanges.pipe(Ye(this.form.fulfillmentResult.value),p(e=>e.deliveryEntityID)),this.outlets$]).pipe(X()).subscribe(([e,i,o])=>{let s=e??this.form.outlet.value,F=i??this.form.fulfillmentResult.value.deliveryEntityID;if(I.IsNotEmpty(F)&&F!=I.GuidEmpty&&s?.ID!=F){let f=o.find(w=>w.ID==F);this.fulfillmentOutletName.set(f?.Name??""),this.isFulfillmentDifferentOutlet.set(!0)}else this.isFulfillmentDifferentOutlet.set(!1)})}setUnitPrice(e){let i=P({},e);return I.IsNotEmpty(e.OrderPrice)?i.UnitPrice=e.OrderPrice:i.UnitPrice=e.UnitCost,i}ngOnDestroy(){this.lowOnStock.selectedLowOnStockData=[],this.intercom.showLauncher()}collapseSidebar(){this.toggle.toggleSidebar()}static \u0275fac=function(i){return new(i||n)(g(ue),g(z),g(ot),g(Z),g(Ct),g(Cn),g(Je),g(He),g(Ce),g(yn),g(Zt),g(Mn),g(pe))};static \u0275cmp=V({type:n,selectors:[["POS-buy-v2"]],viewQuery:function(i,o){i&1&&St(o.selectOutletFormComponent,ei,5)(o.cartDisplayRef,sr,5,Ei),i&2&&Mt(2)},features:[je([Z,He,Et,Je,z,ue,Nt,ot,qe,Ct,Vt]),Zi],decls:5,vars:3,consts:[["fulfillmentIndicator",""],["cartDisplayRef",""],[3,"paymentComplete"],[1,"container-fluid"],[1,"row","header","border-bottom"],[1,"col-5","border-end"],[1,"left-toolbar-container","h-100","d-flex","align-items-center","justify-content-between"],[3,"outlets","isOpenAfterLoad","formControl","disabled","disableCloseDialog"],["transactionType","Purchase Order",3,"formControl","isEdit"],[1,"d-inline-block","pt-1","px-2","w-100"],[3,"formControl","tooltip"],[1,"col-7","d-flex","align-items-center"],[1,"row","flex-grow-1"],[1,"col-lg-7","col-5","d-flex","align-items-center"],[3,"returnInvoiceNumber","appConfigJSON","isEditBuyForm","outletID","outletName"],[1,"col-5","ps-0"],[1,"d-flex","align-items-center","position-relative"],[1,"fa-light","fa-id-badge","position-absolute"],["type","text","placeholder","Assign Attention",1,"border-bottom-0",3,"formControl"],[1,"col-2"],[1,"navbar","mobile-button","border-bottom-0"],["type","button","aria-controls","navigation-index","aria-expanded","false","aria-label","Toggle navigation",1,"navbar-toggler","navbar-toggler-right","float-end","toggle-menu","ps-2","pe-0","border-0",2,"width","max-content","height","max-content",3,"click"],[1,"navbar-toggler-bar","burger-lines"],[1,"row","content"],[3,"quickKey","outletID","formControl"],[1,"col-7","pt-5","px-0","d-flex","flex-column"],[1,"row","w-100","ms-0"],[1,"col-7","px-0"],["amountProperty","VariantCost",3,"formControl","autocompleteEndpoint","outletID"],[3,"formControl","supplierPOTypes","appConfigJSON"],[1,"cart-display",3,"cart","appConfigJSON","isEdit","outletID","outletName"],[4,"ngTemplateOutlet","ngTemplateOutletContext"],[3,"ngClass","matTooltip"],["role","button",1,"d-flex","align-items-center","cursor-pointer","w-100"],[3,"ngClass"],[1,"fa-duotone","fa-light","fa-truck"],[1,"text--truncated"]],template:function(i,o){if(i&1&&(v(0,ur,1,1,"POS-complete",2),u(1,"async"),en(2,Cr,48,58,"div",3),kt(3,br,5,8,"ng-template",null,0,Wt)),i&2){let s;_((s=C(1,1,o.paymentComplete$))?0:2,s)}},dependencies:[te,Xe,an,tt,Me,de,et,ei,jn,$n,ri,oi,Ln,si,bi,Ti,wi,nt,it,Se,Kt],styles:[".left-toolbar-container[_ngcontent-%COMP%]{position:relative}.left-toolbar-container[_ngcontent-%COMP%] POS-invoice-number-form[_ngcontent-%COMP%]{position:absolute;top:34px;left:32px}.header[_ngcontent-%COMP%]{min-height:60px}.content[_ngcontent-%COMP%]{min-height:calc(100vh - 60px)}.supplier-more-menu[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center}.cart-display[_ngcontent-%COMP%]{flex-grow:1;height:0px;overflow-y:auto}input[_ngcontent-%COMP%]{width:100%;height:38px!important;border:0;border-bottom:1px solid #ced4da;padding-left:32px}input[_ngcontent-%COMP%]::placeholder{color:#ced4da}i.fa-id-badge[_ngcontent-%COMP%]{font-size:16px;top:10.6px;left:13px}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]{transition:.4s}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]:nth-child(1){-webkit-transform:rotate(-45deg) translate(-8px,4px);transform:rotate(-45deg) translate(-8px,4px)}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]:nth-child(2){opacity:0}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]:nth-child(3){-webkit-transform:rotate(45deg) translate(-5px,0px);transform:rotate(45deg) translate(-5px)}.mobile-button[_ngcontent-%COMP%]{display:none}@media(max-width:990px){.mobile-button[_ngcontent-%COMP%]{display:block}}.navbar-toggler[_ngcontent-%COMP%]:focus{box-shadow:none!important}.more-actions[_ngcontent-%COMP%] div.d-flex[_ngcontent-%COMP%]{width:30rem}.d-flex[_ngcontent-%COMP%] .text--truncated[_ngcontent-%COMP%]{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}"],changeDetection:0})};export{ao as BuyV2Component};
23
+ `,headerType:be.Error},width:"31rem"})}updateTax(){this.updateDefaultTax$.pipe(ht(1)).subscribe()}updatePaymentMethodID(){this.updatePaymentMethodID$.pipe(ht(1)).subscribe()}static \u0275fac=function(e){return new(e||n)(q(pe),q(z),q(Je),q(ue),q(He))};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};function lo(n,t){if(n&1&&(a(0,"mat-option",5),m(1),r()),n&2){let e=t.$implicit;y("value",e),l(),E(" ",e.Value," ")}}function so(n,t){if(n&1){let e=U();a(0,"i",7),D("click",function(){O(e);let o=d();return T(o.openSupplierDetail())}),r()}}var ri=class n{constructor(t,e,i,o){this.http=t;this.form=e;this.matDialog=i;this.router=o}supplierPOTypes=N([]);appConfigJSON=N(void 0);filteredSuppliers$;supplier=new ge("");disabled=!1;onChange=t=>{};onTouched=()=>{};toastr=G(Le);searchSupplier(t){return this.http.get("/API/AC/GetSupplierSuggestion",[{key:"count",value:100},{key:"prefix",value:t}]).pipe(k(e=>{e.length===0&&this.toastr.warning(`No supplier with name starting with "${t}" found`,"Warning")}),ve(()=>(this.toastr.error(`Supplier with name starting with "${t}" cannot be loaded`),Ke([]))))}ngOnInit(){this.filteredSuppliers$=this.supplier.valueChanges.pipe(A(i=>typeof i=="string"&&i.length>=3),Ji(300),Y(i=>this.searchSupplier(i))),this.supplier.valueChanges.pipe(A(i=>typeof i!="string"),p(i=>i),k(i=>i?.Key!=I.GuidEmpty&&I.IsNotEmpty(i)?this.onChange(i.Key):this.onChange(null))).pipe(A(i=>I.IsNotEmpty(i)&&!i.OnSet),Y(i=>this.http.post("/API/Contact/GetSupplierDTO",{id:i.Key}).pipe(ve(()=>Re))),p(i=>i.DaysDue),A(i=>i!=0),k(i=>this.form.setdueDays(i)),k(i=>this.form.setDueDateBasedOnDaysDue(i))).subscribe()}writeValue(t){this.supplier.setValue(t)}registerOnChange(t){this.onChange=t}registerOnTouched(t){this.onTouched=t}setDisabledState(t){this.disabled=t}displaySupplierNameFn(t){return t?.Value}openNewSupplierModal(){return oe(this,null,function*(){this.matDialog.open(jn,{data:{options:this.supplierPOTypes(),config:this.appConfigJSON()?.ModuleContact,type:"supplier",title:"New Supplier Form"}}).afterClosed().pipe(A(t=>I.IsNotEmpty(t.supplier.Name)),Y(t=>{let e={contact:t.supplier,type:"supplier",groups:t.supplier.Group?t.supplier.Group:[]};return this.http.post("/API/Contact/Supplier/Create",e).pipe(p(i=>({Key:i.ID,Value:t.supplier.Name})))})).subscribe(t=>{this.writeValue(t),this.onChange(t.Key)})})}openSupplierDetail(){let t=this.supplier.value.Key;if(I.IsNotEmpty(t)){let e=this.router.serializeUrl(this.router.createUrlTree(["/menu/Contacts/Contact/Suppliers/Info/V2"],{queryParams:{ID:t}}));window.open(e,"_blank")}}static \u0275fac=function(e){return new(e||n)(g(pe),g(z),g(ie),g(Ht))};static \u0275cmp=V({type:n,selectors:[["POS-supplier-autocomplete"]],inputs:{supplierPOTypes:[1,"supplierPOTypes"],appConfigJSON:[1,"appConfigJSON"]},features:[je([{provide:Ze,multi:!0,useExisting:n}])],decls:9,vars:6,consts:[["auto","matAutocomplete"],[1,"d-flex","align-items-center","position-relative"],["matTooltipPosition","above","matTooltip","New Supplier Form",1,"fa-light","fa-user-plus","position-absolute",2,"font-size","12px",3,"click"],["type","text","placeholder","Assign Supplier",3,"formControl","matAutocomplete"],[3,"displayWith"],[3,"value"],["matTooltipPosition","left","matTooltip","Open Supplier Details",1,"fa-regular","fa-arrow-up-right-from-square","position-absolute",2,"font-size","12px","right","0","cursor","pointer"],["matTooltipPosition","left","matTooltip","Open Supplier Details",1,"fa-regular","fa-arrow-up-right-from-square","position-absolute",2,"font-size","12px","right","0","cursor","pointer",3,"click"]],template:function(e,i){if(e&1&&(a(0,"div",1)(1,"i",2),D("click",function(){return i.openNewSupplierModal()}),r(),x(2,"input",3),a(3,"mat-autocomplete",4,0),we(5,lo,2,2,"mat-option",5,Be),u(7,"async"),r(),v(8,so,1,0,"i",6),r()),e&2){let o=It(4);l(2),y("formControl",i.supplier)("matAutocomplete",o),l(),y("displayWith",i.displaySupplierNameFn),l(2),Ne(C(7,4,i.filteredSuppliers$)),l(3),_(i.supplier&&(i.supplier!=null&&i.supplier.value)&&(!(i.supplier==null||i.supplier.value==null)&&i.supplier.value.Key)?8:-1)}},dependencies:[te,On,In,bn,Pn,tt,Me,de,et,nt,it,Ln,Se],styles:["input[_ngcontent-%COMP%]{width:100%;height:38px!important;border-radius:.375rem;border:1px solid #ced4da;padding-left:32px;padding-right:32px}input[_ngcontent-%COMP%]::placeholder{color:#ced4da}i.fa-user-plus[_ngcontent-%COMP%]{font-size:16px;top:10.6px;left:13px}i.fa-arrow-up-right-from-square[_ngcontent-%COMP%]{transform:none;position:absolute;margin-right:13px;top:10.6px;font-size:12px}"],changeDetection:0})};var co=["quantity"],Rt=n=>({selected:n}),mo=()=>["/menu/Products/Catalog/Variants/Info"],po=n=>({ID:n}),uo=n=>({"table-light":n});function fo(n,t){if(n&1){let e=U();a(0,"a",17),D("click",function(){O(e);let o=d();return T(o.onTabChange("Discount"))}),m(1," Discount "),r()}if(n&2){let e=d();y("ngClass",le(1,Rt,e.tabState=="Discount"))}}function go(n,t){if(n&1){let e=U();a(0,"a",18),D("click",function(){O(e);let o=d();return T(o.onTabChange("Product"))}),m(1," Product "),r()}if(n&2){let e=d();y("ngClass",le(1,Rt,e.tabState=="Product"))}}function Co(n,t){if(n&1){let e=U();a(0,"a",19),D("click",function(){O(e);let o=d();return T(o.onTabChange("Serial"))}),m(1),r()}if(n&2){let e=d();y("ngClass",le(2,Rt,e.tabState=="Serial")),l(),E(" ",e.isBatchNumber()?"Batch Number":"Serial"," ")}}function yo(n,t){if(n&1&&(a(0,"div",20),x(1,"div",28),r()),n&2){let e=d(2);l(),y("innerHTML",e.cartService.priceMaximumRestrictionWarning(),$t)}}function bo(n,t){if(n&1&&(a(0,"div",12)(1,"div",29),x(2,"POS-variant-autocomplete",30),r()()),n&2){let e=d(2);l(2),y("formControl",e.variantAutocomplete)("isOnModalVariant",!0)}}function ho(n,t){if(n&1&&(a(0,"span"),m(1),r()),n&2){let e=d(2);l(),E("(",e.variant.UOMName,")")}}function vo(n,t){if(n&1){let e=U();a(0,"div",24)(1,"strong")(2,"span"),m(3),r()(),a(4,"input",31),J("ngModelChange",function(o){O(e);let s=d(2);return Q(s.variant.UnitQuantity,o)||(s.variant.UnitQuantity=o),T(o)}),D("ngModelChange",function(){O(e);let o=d(2);return T(o.onUnitQtyChange())}),r()()}if(n&2){let e=d(2);l(3),ee(e.unitQtyLabel),l(),y("preventNegative",!0)("decimalPlaces",e.isSerialItem||e.isBatchNumber()?0:4),W("ngModel",e.variant.UnitQuantity)}}function _o(n,t){if(n&1){let e=U();a(0,"div",25)(1,"strong"),m(2,"Cost"),r(),a(3,"input",32,1),J("ngModelChange",function(o){O(e);let s=d(2);return Q(s.variant.UnitPrice,o)||(s.variant.UnitPrice=o),T(o)}),D("ngModelChange",function(){O(e);let o=d(2);return T(o.onPriceChange())}),r()()}if(n&2){let e=d(2);l(3),y("simpleKeyboard",e.keyboard),W("ngModel",e.variant.UnitPrice)}}function Do(n,t){if(n&1){let e=U();v(0,yo,2,1,"div",20),a(1,"div",21),v(2,bo,3,2,"div",12),a(3,"div",12)(4,"div",22)(5,"strong"),m(6," Qty "),v(7,ho,2,1,"span"),r(),a(8,"input",23,0),J("ngModelChange",function(o){O(e);let s=d();return Q(s.variant.Quantity,o)||(s.variant.Quantity=o),T(o)}),D("ngModelChange",function(){O(e);let o=d();return T(o.onQtyChange())}),r()(),v(10,vo,5,4,"div",24),v(11,_o,5,2,"div",25),r(),a(12,"div",12)(13,"div",26)(14,"POS-tinymce-editor",27),J("ngModelChange",function(o){O(e);let s=d();return Q(s.variant.Note,o)||(s.variant.Note=o),T(o)}),r()()()()}if(n&2){let e=d();_(e.cartService.priceMaximumRestrictionWarning()&&e.cartService.priceMaximumRestrictionWarning().trim()!==""?0:-1),l(2),_(e.isCreate?2:-1),l(5),_(e.variant.UOMName?7:-1),l(),y("simpleKeyboard",e.keyboard)("decimalPlaces",e.isSerialItem||e.isBatchNumber()?0:4),W("ngModel",e.variant.Quantity),y("disabled",e.isEditBuyForm&&(e.isSerialItem||e.isBatchNumber())),l(2),_(e.unitQtyLabel?10:-1),l(),_(e.role.product.Cost?11:-1),l(3),W("ngModel",e.variant.Note)}}function xo(n,t){if(n&1&&(a(0,"div",46)(1,"div",35)(2,"strong"),m(3,"Discount Amount / Qty"),r()(),a(4,"div",36)(5,"div",48)(6,"p"),m(7),u(8,"number"),r()()()()),n&2){let e=d(2);l(7),ee(C(8,1,e.variant.DiscountAmount))}}function So(n,t){if(n&1&&(a(0,"div",54)(1,"h5",60),m(2),u(3,"number"),r()()),n&2){let e=d(3);l(2),E(" ",C(3,1,e.variant.Discount),"% ")}}function Mo(n,t){if(n&1&&(a(0,"div",55)(1,"h5"),m(2),u(3,"number"),r(),a(4,"span",53),m(5,"x"),r(),a(6,"h5"),m(7),u(8,"number"),r()()),n&2){let e=d(3);l(2),ee(C(3,2,e.variant.Quantity)),l(5),ee(C(8,4,e.variant.DiscountAmount))}}function Io(n,t){if(n&1&&(a(0,"h5",58),m(1),u(2,"number"),r()),n&2){let e=d(3);l(),$e(" ",e.totalBeforeDiscount()*(e.variant.Discount/100)<0?"":"-","",C(2,2,e.totalBeforeDiscount()*(e.variant.Discount/100))," ")}}function Po(n,t){if(n&1&&(a(0,"div",57)(1,"h5",58),m(2),u(3,"number"),r()()),n&2){let e=d(3);l(2),$e(" ",e.variant.Quantity*e.variant.DiscountAmount<0?"":"-","",C(3,2,e.variant.Quantity*e.variant.DiscountAmount)," ")}}function Oo(n,t){if(n&1&&(a(0,"div",59)(1,"div",61)(2,"h5"),m(3,"Grand Total"),r()(),a(4,"div",61)(5,"h5"),m(6),u(7,"number"),r()()()),n&2){let e=d(3);l(6),ee(C(7,1,e.totalAfterDiscount()))}}function To(n,t){if(n&1&&(a(0,"div",47)(1,"div",49)(2,"h4"),m(3,"Discount Simulation"),r(),a(4,"h4",50),m(5),r()(),a(6,"div",51)(7,"div",35)(8,"div",52)(9,"h5"),m(10),u(11,"number"),r(),a(12,"span",53),m(13,"x"),r(),a(14,"h5"),m(15),u(16,"number"),r()(),v(17,So,4,3,"div",54),v(18,Mo,9,6,"div",55),r(),a(19,"div",35)(20,"div",56)(21,"h5"),m(22),u(23,"number"),r()(),a(24,"div",57),v(25,Io,3,4,"h5",58),r(),v(26,Po,4,4,"div",57),r(),v(27,Oo,8,3,"div",59),r()()),n&2){let e=d(2);l(5),E(" ",e.variant==null?null:e.variant.Name," "),l(5),ee(C(11,9,e.variant.Quantity)),l(5),ee(C(16,11,e.variant.UnitPrice)),l(2),_(e.variant.Discount?17:-1),l(),_(e.variant.DiscountAmount>0?18:-1),l(4),ee(C(23,13,e.totalBeforeDiscount())),l(3),_(e.variant.Discount?25:-1),l(),_(e.variant.DiscountAmount>0?26:-1),l(),_(e.variant.DiscountAmount>0||e.variant.Discount>0?27:-1)}}function wo(n,t){if(n&1){let e=U();a(0,"div",12)(1,"div",33)(2,"div",34)(3,"div",35)(4,"strong"),m(5,"Discount %"),r()(),a(6,"div",36)(7,"input",37,2),J("ngModelChange",function(o){O(e);let s=d();return Q(s.variant.Discount,o)||(s.variant.Discount=o),T(o)}),D("ngModelChange",function(){O(e);let o=d();return T(o.onDiscountChange())}),r()()(),a(9,"div",38)(10,"div",35)(11,"strong"),m(12,"Discount Amount"),r()(),a(13,"div",36)(14,"input",39,2),J("ngModelChange",function(o){O(e);let s=d();return Q(s.inputedDiscountAmount,o)||(s.inputedDiscountAmount=o),T(o)}),D("ngModelChange",function(o){O(e);let s=d();return T(s.onDiscountAmountChange(o))}),r()()(),a(16,"div",40)(17,"div",41)(18,"input",42),J("ngModelChange",function(o){O(e);let s=d();return Q(s.isDiscMultipliciedQty,o)||(s.isDiscMultipliciedQty=o),T(o)}),D("ngModelChange",function(){O(e);let o=d();return T(o.onSwitchDiscountTypeChange())}),r()(),a(19,"div",43)(20,"strong"),m(21,"*Quantity"),r(),a(22,"span",44),x(23,"i",45),r()()(),v(24,xo,9,3,"div",46),r(),v(25,To,28,15,"div",47),r()}if(n&2){let e=d();l(7),y("simpleKeyboard",e.keyboard),W("ngModel",e.variant.Discount),y("min",0)("readonly",!e.role.sell.Discount),l(7),y("simpleKeyboard",e.keyboard),W("ngModel",e.inputedDiscountAmount),y("max",e.variant.UnitPrice*e.abs(e.variant.Quantity))("min",0)("readonly",!e.role.sell.Discount),l(4),W("ngModel",e.isDiscMultipliciedQty),l(6),_(e.isDiscMultipliciedQty()?-1:24),l(),_(e.role.product.Cost?25:-1)}}function No(n,t){n&1&&(x(0,"i",67),a(1,"h6"),m(2,"No Image"),r())}function Eo(n,t){if(n&1&&x(0,"img",64),n&2){let e=d(2);y("src",e.variant.ThumbnailUrl,dt)}}function Fo(n,t){if(n&1){let e=U();a(0,"button",80),D("click",function(){O(e);let o=d(),s=d(2);return T(s.setQuantityToMax(o))}),m(1," Place Order "),r()}}function ko(n,t){if(n&1&&(a(0,"tbody")(1,"tr")(2,"th",68),x(3,"i",69),m(4,"Inventory "),r(),a(5,"th",68),x(6,"i",70),m(7),r(),a(8,"th",68),x(9,"i",71),m(10," Diff "),r(),a(11,"th",68),x(12,"i",72),m(13," Action "),r()(),a(14,"tr")(15,"th",73),m(16,"On Hand"),r(),a(17,"td",74),m(18),u(19,"number"),r(),x(20,"td",75)(21,"td",76),r(),a(22,"tr")(23,"th",73),m(24,"Allocated"),r(),a(25,"td",74),m(26),u(27,"number"),r()(),a(28,"tr")(29,"th",73),m(30,"Available"),r(),a(31,"td",74),m(32),u(33,"number"),r()(),a(34,"tr")(35,"th",73),m(36,"ROP"),r(),a(37,"td",74),m(38),u(39,"number"),r(),a(40,"td",58),m(41),u(42,"number"),r()(),a(43,"tr")(44,"th",73),m(45,"Max"),r(),a(46,"td",74),m(47),u(48,"number"),r(),a(49,"td",77),m(50),u(51,"number"),r(),a(52,"td",78),v(53,Fo,2,0,"button",79),r()()()),n&2){let e=t,i=d(2);l(7),E("",i.outletName," "),l(11),E(" ",C(19,12,e.onHand)," "),l(8),E(" ",C(27,14,e.allocated)," "),l(6),E(" ",C(33,16,e.onHand-e.allocated)," "),l(6),E(" ",C(39,18,e.rop)," "),l(3),$e(" ",e.ropDiff>=0?"+":"","",C(42,20,e.ropDiff)," "),l(6),E(" ",C(48,22,e.max)," "),l(3),$e(" ",e.maxDiff>=0?"+":"","",C(51,24,e.maxDiff)," "),l(2),y("ngClass",le(26,uo,i.variant.Quantity==e.max-e.onHand-e.allocated)),l(),_(i.variant.Quantity!=e.max-e.onHand-e.allocated?53:-1)}}function Ao(n,t){if(n&1&&(a(0,"div",13)(1,"div",62)(2,"a",63),v(3,No,3,0)(4,Eo,1,1,"img",64),r()(),a(5,"div",65)(6,"table",66),v(7,ko,54,28,"tbody"),u(8,"async"),r()()()),n&2){let e,i=d();l(2),y("routerLink",Qt(6,mo))("queryParams",le(7,po,i.variant==null?null:i.variant.ID)),l(),_((i.variant==null?null:i.variant.ThumbnailUrl)==null?3:4),l(4),_((e=C(8,4,i.variantStock$))?7:-1,e)}}function Vo(n,t){if(n&1){let e=U();a(0,"POS-tab-serial",81),J("variantChange",function(o){O(e);let s=d();return Q(s.variant,o)||(s.variant=o),T(o)})("isFocusOnSerialInputChange",function(o){O(e);let s=d();return Q(s.isFocusOnSerialInput,o)||(s.isFocusOnSerialInput=o),T(o)})("serialsChange",function(o){O(e);let s=d();return Q(s.serials,o)||(s.serials=o),T(o)}),r()}if(n&2){let e=d();y("disabledEditQty",e.isEditBuyForm)("outletID",e.outletID),W("variant",e.variant)("isFocusOnSerialInput",e.isFocusOnSerialInput)("serials",e.serials),y("isBatchNumber",e.isBatchNumber())}}var yt=class n{constructor(t,e,i,o,s,F){this.dialogRef=t;this.http=i;this.role=o;this.toastr=F;this.config=new Ie,this.config.title=e.variant?.Name??"Add Variant",this.config.customWidth="700px",this.config.noPadding=!0,this.appConfigJSON=e.appConfigJSON,this.unitQtyLabel=this.appConfigJSON.ModuleSell.ProductDialog.UnitQtyLabel,this.numpadVisible=this.appConfigJSON.ModuleSell.NumPadVisible,this.numpadVisible&&(this.keyboard=s.keyboard),this.isEditBuyForm=e.isEdit,this.outletID=e.outletID,this.outletName=e.outletName,this.variant=e.variant?JSON.parse(JSON.stringify(e.variant)):null;let w=this.appConfigJSON?.ModuleSell?.ProductDialog?.QuantityToOneInDialog?1:null;if(this.variant)this.isSerialItem=this.variant.TypeID==9,this.isBatchNumber.set(this.variant.TypeID==4),this.variantStock$=this.getOnInventory(),this.inputedDiscountAmount.set(this.variant.DiscountAmount),this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount();else{this.isCreate=!0,this.variant={Name:"",Quantity:w,UnitQuantity:1,OrderPrice:0,Total:0,Note:"",UnitPrice:0,ThumbnailUrl:"",UOMName:"",TypeID:0,Discount:0,ID:"",DiscountAmount:0,Serial:[],UnitCost:0,MaxOrderPrice:0};let H=this.variantAutocomplete.valueChanges.pipe(A(c=>c.type=="Code"),p(c=>c.str),Y(c=>i.get(Ue.GetVariantByCode,[{key:"Code",value:c},{key:"EntityID",value:this.outletID},{key:"Promotion",value:!0}]).pipe(ve(()=>Re))),p(c=>this.setUnitPrice(c)),p(c=>B(P({},c),{Quantity:w,Total:c.UnitPrice,Discount:c.PriceDiscount}))),M=this.variantAutocomplete.valueChanges.pipe(A(c=>c.type=="ID"),p(c=>c.str),Y(c=>i.get(Ue.GetVariantByID,[{key:"ID",value:c},{key:"EntityID",value:this.outletID},{key:"Promotion",value:!1}]).pipe(ve(()=>Re))),p(c=>this.setUnitPrice(c)),p(c=>B(P({},c),{Quantity:w,Total:c.UnitPrice,Discount:c.PriceDiscount})));mt(H,M).pipe(k(c=>this.setFocusField("quantity")),ae(1)).subscribe(c=>{this.variant=c,this.isSerialItem=this.variant.TypeID==9,this.isBatchNumber.set(this.variant.TypeID==4),this.showInventory=!0,this.variantStock$=this.getOnInventory(),this.inputedDiscountAmount.set(this.variant.DiscountAmount),this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()})}}calculatorTab=ut(ii);cartService=G(Z);variantAutocomplete=new ge;_quantityElement=ut("quantity");variant;variantStock$=Re;isSerialItem=!1;isBatchNumber=se(!1);outletID;outletName;appConfigJSON;numpadVisible;keyboard;isEditBuyForm=!1;unitQtyLabel;config;tabState="Cart";isCreate=!1;showInventory=!1;serials=[];isFocusOnSerialInput=!1;_onGetInventory=new at(void 0);onGetInventory$=this._onGetInventory.asObservable();isDiscMultipliciedQty=se(!0);totalBeforeDiscount=se(0);totalAfterDiscount=se(0);inputedDiscountAmount=se(0);setFocusField(t){t==="quantity"&&this._quantityElement()?.nativeElement?.focus()}onPriceChange(){this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()}onQtyChange(){this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()}onUnitQtyChange(){this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()}onDiscountChange(){this.calculateTotalAfterDiscount(),this.calculateTotalAfterDiscount()}onDiscountAmountChange(t){this.calculateDiscountAmount(t),this.calculateTotalAfterDiscount()}onSwitchDiscountTypeChange(){this.calculateDiscAmountOnSwitch(),this.calculateTotalAfterDiscount()}calculateDiscountAmount(t){this.isDiscMultipliciedQty()?this.variant.DiscountAmount=t:this.variant.DiscountAmount=t/this.getQty()}calculateDiscAmountOnSwitch(){let t=this.variant.DiscountAmount,e=this.getQty();this.isDiscMultipliciedQty()?this.variant.DiscountAmount=t*e:this.variant.DiscountAmount=t/e}calculateTotalBeforeDiscount(){let t=this.variant.UnitPrice*this.getQty();this.totalBeforeDiscount.set(t)}calculateTotalAfterDiscount(){let t=this.totalBeforeDiscount()-this.getTotalDiscPercentage();this.validateDiscountAmount(t);let e=this.getTotalDiscAmount(),i=t-e;this.totalAfterDiscount.set(i)}validateDiscountAmount(t){let e=this.variant.Quantity%1===0;t>0&&this.variant.DiscountAmount>t&&e&&(this.variant.DiscountAmount=t)}getTotalDiscPercentage(){return this.variant.Discount?this.totalBeforeDiscount()*this.variant.Discount/100:0}getTotalDiscAmount(){return this.variant.DiscountAmount?this.variant.DiscountAmount*this.getQty():0}getQty(){return this.checkQuantityIsNull(),this.variant.Quantity*this.variant.UnitQuantity}onTabChange(t){this.tabState=t,t==="Calculator"&&(console.log(this.calculatorTab()?.priceInputNativeElement),setTimeout(()=>this.calculatorTab()?.priceInputNativeElement?.focus(),100))}onSave(){if(!this.isFocusOnSerialInput){if(this.checkQuantityIsNull(),this.isSerialItem||this.isBatchNumber()){if(this.serials.length){let o=this.serials.map(s=>({Quantity:1,Number:s}));this.variant.Serial=[...this.variant.Serial,...o]}let e=this.variant.Serial?.map(o=>o.Quantity).reduce((o,s)=>o+s,0)??0,i=this.variant.Quantity;e!=i&&this.toastr.warning("Serial Quantity must be equal to Variant Quantity","Warning"),this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()}if(!this.cartService.validatePriceMaximum(this.variant))return;this.dialogRef.close(B(P({},this.variant),{Total:this.totalAfterDiscount()}))}}close(){this.dialogRef.close()}checkQuantityIsNull(){(this.variant.Quantity==null||this.variant.Quantity==0)&&(this.variant.Quantity=1)}setQuantityToMax(t){let e=t.onHand-t.allocated;t.max>=e?(this.variant.Quantity=t.max-e,this.toastr.success("Qty adjusted to Max Inventory","Success"),this.onSave()):this.toastr.warning("Your Inventory Available is more than Max Inventory","Warning")}getOnInventory(){return this.onGetInventory$.pipe(qi((t,e)=>t?Ke(t):this.http.get(Ue.GetVariantStockByID,[{key:"ID",value:this.variant.ID},{key:"EntityID",value:this.outletID}]).pipe(p(i=>{let o=i.OnHand-i.Allocated;return{onHand:i.OnHand,allocated:i.Allocated,rop:i.ROP,max:i.Max,maxDiff:i.Max-i.OnHand-o,ropDiff:i.ROP-i.OnHand-o}})),null),p(t=>t),ae(1))}setUnitPrice(t){let e=P({},t);return I.IsNotEmpty(t.OrderPrice)?e.UnitPrice=t.OrderPrice:e.UnitPrice=t.UnitCost,e}abs(t){return Math.abs(t)}ngOnDestroy(){this.cartService.priceMaximumRestrictionWarning.set("")}static \u0275fac=function(e){return new(e||n)(g(Oe),g(ke),g(pe),g(Ce),g(Bn),g(Le))};static \u0275cmp=V({type:n,selectors:[["POS-modal-variant"]],viewQuery:function(e,i){e&1&&St(i.calculatorTab,ii,5)(i._quantityElement,co,5),e&2&&Mt(2)},decls:19,vars:20,consts:[["quantity",""],["price",""],["discount",""],[3,"onOk","onCancel","onClose","config"],[1,"container","w-100","h-100"],[1,"row","border-bottom","mx-5","mt-8"],["data-cy","input_sell",1,"btn","btn-link",3,"click","ngClass"],["data-cy","discount",1,"btn","btn-link",3,"ngClass"],["data-cy","product",1,"btn","btn-link",3,"ngClass"],["data-cy","serial",1,"btn","btn-link",3,"ngClass"],["data-cy","calculator",1,"btn","btn-link",3,"click","ngClass"],[1,"mx-8"],[1,"row"],[1,"row","py-8"],[3,"disabledEditQty","outletID","variant","isFocusOnSerialInput","serials","isBatchNumber"],[3,"hidden"],["priceLabel","Cost",3,"discountTotal","priceTotal","qtyTotal","noteChanges","price","discount","quantity","notes","variantName"],["data-cy","discount",1,"btn","btn-link",3,"click","ngClass"],["data-cy","product",1,"btn","btn-link",3,"click","ngClass"],["data-cy","serial",1,"btn","btn-link",3,"click","ngClass"],[1,"bg-gradient-warning","p-4","justify-content-center","align-items-center","d-flex","gap-2",2,"margin-top","12px","border-radius","8px"],[1,"py-8"],[1,"col-auto","mb-4","pe-0",2,"width","82px"],["id","txtCartQuantity","keyboardType","number","type","text","autoNum","",1,"form-control","input-numpad",2,"height","38px",3,"ngModelChange","simpleKeyboard","decimalPlaces","ngModel","disabled"],[1,"col-auto","pe-0",2,"width","82px"],[1,"col-auto","pe-0",2,"width","112px"],[1,"col","tinymce"],["height","210px",3,"ngModelChange","ngModel"],[3,"innerHTML"],[1,"col"],[3,"formControl","isOnModalVariant"],["type","text","autoNum","",1,"form-control","input-numpad",2,"height","38px",3,"ngModelChange","preventNegative","decimalPlaces","ngModel"],["id","inputPrice","keyboardType","number","type","text","autoNum","",1,"form-control",2,"height","38px",3,"ngModelChange","simpleKeyboard","ngModel"],[1,"col-6","border-end","py-8"],[1,"row","d-flex","align-items-center"],[1,"col-6"],[1,"col-auto","ps-0"],["id","inputDiscount","keyboardType","number","type","text","autoNum","","percentage","","decimalPlaces","2",1,"form-control",2,"width","112px","height","38px",3,"ngModelChange","simpleKeyboard","ngModel","min","readonly"],[1,"row","d-flex","align-items-center","mt-6"],["id","inputDiscount","keyboardType","number","type","text","autoNum","",1,"form-control",2,"width","112px","height","38px",3,"ngModelChange","simpleKeyboard","ngModel","max","min","readonly"],[1,"d-flex","align-items-center","mt-4"],[1,"form-check","form-switch","form-switch-lg","ms-1","mt-1"],["type","checkbox","id","flexSwitchCheckDefault",1,"form-check-input",3,"ngModelChange","ngModel"],[1,"ms-4"],["matTooltipPosition","above","matTooltip",`Use the final discount amount if you want to discount the price of the total
24
+ quantity of the product. The nominal will be calculated automatically and filled in the discount amount box.`,1,"pointer"],[1,"fa-solid","fa-info-circle","ms-2"],[1,"row","d-flex","align-items-center","justify-content-start","mt-4"],[1,"col-6","py-8"],[1,"border","ps-6",2,"height","38px","padding-top","10px","width","112px","background-color","#e9ecef"],[1,"w-100","text-center"],[1,"text-start","mt-12"],[1,"row","mt-12"],[1,"w-100","d-flex","align-items-center","justify-content-end"],[1,"mx-1","fw-bold"],[1,"d-flex","align-items-center","justify-content-end","mt-2"],[1,"d-flex","align-items-center","justify-content-end","mt-2","text-danger"],[1,"w-100","d-flex","justify-content-end"],[1,"w-100","d-flex","justify-content-end","mt-2"],[1,"text-danger"],[1,"row","border-top","mx-0","px-0","mt-4"],[1,"fw-bold","text-danger"],[1,"col-6","d-flex","justify-content-end","mt-4"],[1,"col-sm-4","d-flex","justify-content-center","flex-column","align-items-center","text-body-secondary"],["target","_blank",2,"color","inherit",3,"routerLink","queryParams"],[1,"border","rounded",3,"src"],[1,"col-sm-8"],[1,"table","table-bordered","text-center","inventory-table","w-auto"],["aria-hidden","true",1,"fa-solid","fa-image","fa-5x"],[1,"bg-light-orange"],["aria-hidden","true",1,"fa-box-archive","fa-solid","fa-1x","me-2"],["aria-hidden","true",1,"fa-solid","fa-house","fa-1x","me-2"],["aria-hidden","true",1,"fa-solid","fa-plus-minus","fa-1x","me-2"],["aria-hidden","true",1,"fa-solid","fa-sliders","fa-1x","me-2"],[1,"table-light","text-start"],[1,"text-end"],["rowspan","3",1,"table-light"],["rowspan","4",1,"table-light"],[1,"text-success"],[3,"ngClass"],["type","button","matTooltipPosition","above","matTooltip","Adjust Bought Qty to max Inventory",1,"btn","btn-success","btn-sm","me-2",2,"font-size","12px"],["type","button","matTooltipPosition","above","matTooltip","Adjust Bought Qty to max Inventory",1,"btn","btn-success","btn-sm","me-2",2,"font-size","12px",3,"click"],[3,"variantChange","isFocusOnSerialInputChange","serialsChange","disabledEditQty","outletID","variant","isFocusOnSerialInput","serials","isBatchNumber"]],template:function(e,i){e&1&&(a(0,"modal-material",3),D("onOk",function(){return i.onSave()})("onCancel",function(){return i.close()})("onClose",function(){return i.close()}),a(1,"content")(2,"div",4)(3,"div",5)(4,"div")(5,"a",6),D("click",function(){return i.onTabChange("Cart")}),m(6," Cart "),r(),v(7,fo,2,3,"a",7),v(8,go,2,3,"a",8),v(9,Co,2,4,"a",9),a(10,"a",10),D("click",function(){return i.onTabChange("Calculator")}),m(11," Calculator "),r()()(),a(12,"div",11),v(13,Do,15,10),v(14,wo,26,12,"div",12),v(15,Ao,9,9,"div",13),v(16,Vo,1,6,"POS-tab-serial",14),a(17,"div",15)(18,"item-calculator-tab",16),D("discountTotal",function(s){return i.variant.Discount=s,i.onDiscountChange()})("priceTotal",function(s){return i.variant.UnitPrice=s,i.onPriceChange()})("qtyTotal",function(s){return i.variant.Quantity=s,i.onQtyChange()})("noteChanges",function(s){return i.variant.Note=s}),r()()()()()()),e&2&&(y("config",i.config),l(5),y("ngClass",le(16,Rt,i.tabState=="Cart")),l(2),_(!i.isCreate||i.showInventory?7:-1),l(),_(!i.isCreate||i.showInventory?8:-1),l(),_(i.isSerialItem||i.isBatchNumber()?9:-1),l(),y("ngClass",le(18,Rt,i.tabState=="Calculator")),l(3),_(i.tabState=="Cart"?13:-1),l(),_(i.tabState=="Discount"?14:-1),l(),_(i.tabState=="Product"?15:-1),l(),_(i.tabState=="Serial"?16:-1),l(),y("hidden",i.tabState!="Calculator"),l(),y("price",i.variant.UnitPrice)("discount",i.variant.Discount)("quantity",i.variant.Quantity)("notes",i.variant.Note)("variantName",i.variant==null?null:i.variant.Name))},dependencies:[te,Xe,ti,Fe,Me,un,de,Ee,wt,Pe,ft,Tn,qt,Gt,$n,oi,tt,et,Zn,ii,Se,ye],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}p-chips[_ngcontent-%COMP%] ul.p-inputtext{width:570px;max-width:570px;border:1px solid #C8D3DF}p-chips[_ngcontent-%COMP%] ul.p-inputtext li.p-chips-input-token>input[type=text]{border:none}p-chips[_ngcontent-%COMP%] .p-chips .p-chips-multiple-container:not(.p-disabled):hover{border:1px solid #C8D3DF}p-chips[_ngcontent-%COMP%] .p-chips-multiple-container{display:inline-block}p-chips[_ngcontent-%COMP%] .p-chips-multiple-container .p-chips-token{margin:2px;background:#96bf48}.inventory-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%], .inventory-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{line-height:6px!important}.btn-link[_ngcontent-%COMP%]{padding-top:0;color:#868686;padding-bottom:8px;border-radius:unset;font-family:Roboto Slab,serif}.btn-link.selected[_ngcontent-%COMP%]{color:#3b3b3b;border-bottom:4px solid #07a519}.form-check-input[_ngcontent-%COMP%]{clear:left}.form-switch.form-switch-lg[_ngcontent-%COMP%] .form-check-input[_ngcontent-%COMP%]{height:1.5rem;width:2.75rem;border-radius:3rem}.form-check-input[_ngcontent-%COMP%]:focus{border-color:#89b03e!important}.form-check-input[_ngcontent-%COMP%]:checked{border-color:#89b03e!important;background-color:#89b03e!important}"],changeDetection:0})};function Bo(n,t){if(n&1&&(a(0,"td",7),m(1),r()),n&2){let e=d().$index;l(),E("",e+1,".")}}function $o(n,t){if(n&1&&(a(0,"div",10),x(1,"img",28),r()),n&2){let e=d().$implicit;l(),y("src",e.ThumbnailUrl,dt)}}function jo(n,t){n&1&&(a(0,"div",11),x(1,"i",29),r())}function Lo(n,t){if(n&1&&(a(0,"span",20),m(1),u(2,"quantityFraction"),r()),n&2){let e=d().$implicit;l(),E(" ",C(2,1,e.Quantity)," ")}}function Uo(n,t){n&1&&(a(0,"span",21),m(1,"x"),r())}function Qo(n,t){if(n&1&&(a(0,"span",22),m(1),r()),n&2){let e=d().$implicit;l(),ee(e.UOMName)}}function Wo(n,t){if(n&1&&(a(0,"div",9)(1,"small",30),m(2," @ "),r(),a(3,"small",30),m(4),u(5,"number"),r()()),n&2){let e=d().$implicit;d();let i=Tt(2);l(4),E(" ",pt(5,1,e.VariantUnitQuantity,"1.0-"+i)," ")}}function Jo(n,t){if(n&1&&(a(0,"small",24),m(1),r()),n&2){let e=d().$implicit;l(),ee(e.Sub_UOMName)}}function Ho(n,t){if(n&1&&(a(0,"span",24),m(1),u(2,"number"),r()),n&2){let e=d().$implicit;l(),ee(C(2,1,e.UnitQuantity))}}function Go(n,t){if(n&1&&(a(0,"small",31),m(1),u(2,"number"),r()),n&2){let e=d(2).$implicit;l(),E(" @",C(2,1,e.UnitPrice/e.VariantUnitQuantity)," ")}}function qo(n,t){if(n&1&&(a(0,"div",18)(1,"span",20),m(2),u(3,"number"),r(),v(4,Go,3,3,"small",31),r()),n&2){let e=d().$implicit;l(2),E(" ",C(3,2,e.UnitPrice)," "),l(2),_(e.VariantUnitQuantity&&e.VariantUnitQuantity!=1?4:-1)}}function Ko(n,t){if(n&1&&(a(0,"div"),m(1),u(2,"number"),r()),n&2){let e=d().$implicit;l(),E("-",C(2,1,e.Discount),"%")}}function zo(n,t){if(n&1&&(a(0,"div"),m(1),u(2,"number"),r()),n&2){let e=d().$implicit;l(),E("-",C(2,1,e.DiscountAmount))}}function Yo(n,t){if(n&1&&(m(0),u(1,"number")),n&2){let e=d().$implicit;E(" ",pt(1,1,e.Total,"1.0-4")," ")}}function Xo(n,t){n&1&&m(0," - ")}function Zo(n,t){if(n&1){let e=U();a(0,"tr",6),D("contextmenu",function(o){let s=O(e).$index;return d(2).onContextMenu(s),T(o.preventDefault())})("click",function(o){let s=O(e),F=s.$implicit,f=s.$index;return d(2).update(F,f),T(o.stopPropagation())}),v(1,Bo,2,1,"td",7),a(2,"td",8)(3,"div",9),v(4,$o,2,1,"div",10)(5,jo,2,0,"div",11),a(6,"div",12)(7,"div"),m(8),r(),a(9,"span",13),m(10),r(),x(11,"app-serial-note",14)(12,"small",15),r()()(),a(13,"td",16)(14,"div",17)(15,"div",18)(16,"div",19),v(17,Lo,3,3,"span",20),v(18,Uo,2,0,"span",21),v(19,Qo,2,1,"span",22),r(),a(20,"div",23),v(21,Wo,6,4,"div",9),v(22,Jo,2,1,"small",24),r()(),v(23,Ho,3,3,"span",24),r()(),a(24,"td",16),v(25,qo,5,4,"div",18),r(),a(26,"td",25),v(27,Ko,3,3,"div"),v(28,zo,3,3,"div"),r(),a(29,"td",16),v(30,Yo,2,4)(31,Xo,1,0),r(),a(32,"td",26)(33,"i",27),D("click",function(o){let s=O(e).$index;return d(2).deleteVariant(s),T(o.stopPropagation())}),r()()()}if(n&2){let e,i,o=t.$implicit,s=d(2);y("cdkDragDisabled",!s.enabledDragDrop),l(),_((e=s.appConfigJSON())!=null&&e.ModuleBuy.Grid.RowNumberVisible?1:-1),l(),Pt("ps-0",(i=s.appConfigJSON())==null?null:i.ModuleBuy.Grid.RowNumberVisible),l(2),_(o.ThumbnailUrl?4:5),l(4),ee(o.Name),l(2),ee(o.Code),l(),y("serials",o.Serial),l(),y("innerHtml",o.Note,$t),l(5),_(s.shouldShowBaseQuantity(o)?17:-1),l(),_(s.shouldShowUnitMultiplier(o)?18:-1),l(),_(s.shouldShow("UOMVisible")?19:-1),l(2),_(s.shouldShowVariantQty(o)?21:-1),l(),_(s.shouldShow("SubUOMVisible")?22:-1),l(),_(s.shouldShowUnitMultiplier(o)?23:-1),l(2),_(s.shouldShowUnitPrice(o,s.role==null||s.role.product==null?null:s.role.product.Cost)?25:-1),l(2),_(o.Discount?27:-1),l(),_(o.DiscountAmount?28:-1),l(2),_(s.role.product.Cost?30:31)}}function ea(n,t){if(n&1){let e=U();rt(0),u(1,"async"),rt(2),a(3,"div",1)(4,"table",3)(5,"tbody",4),D("cdkDropListDropped",function(o){O(e);let s=d();return T(s.drop(o))}),we(6,Zo,34,19,"tr",5,Be),r()()()}if(n&2){let e=d(),i=It(3),o=C(1,1,e.appConfig$);l(2),Ot((o==null||o.ModuleSell==null||o.ModuleSell.ProductDialog==null?null:o.ModuleSell.ProductDialog.DecimalPlaceDigit)??3),l(),y("cdkContextMenuTriggerFor",i),l(3),Ne(e.cart())}}function ta(n,t){n&1&&(a(0,"div",2)(1,"div",32)(2,"div",33)(3,"div",34)(4,"div",35),x(5,"i",36),r(),a(6,"div",37)(7,"span"),m(8,"Empty Cart"),r(),x(9,"br"),a(10,"span"),m(11,"Add products to the cart"),r(),x(12,"br"),a(13,"span"),m(14,"or scan barcode"),r()()()()()())}function ia(n,t){if(n&1){let e=U();a(0,"button",40),D("click",function(){O(e);let o=d(2);return T(o.onReturn())}),x(1,"i",42),m(2," Return "),r()}if(n&2){let e=d(2);y("disabled",e.contextMenuQuantity<0)}}function na(n,t){if(n&1){let e=U();a(0,"div",38),v(1,ia,3,1,"button",39),a(2,"button",40),D("click",function(){O(e);let o=d();return T(o.onPurchase())}),x(3,"i",41),m(4," Purchase "),r()()}if(n&2){let e=d();l(),_(e.role.sell.Return?1:-1),l(),y("disabled",e.contextMenuQuantity>0)}}var si=class n{constructor(t,e,i,o,s,F){this.cartService=t;this.matDialog=e;this.role=i;this.form=o;this.sf=F;this.initDragDropEnabled()}cart=N([]);appConfigJSON=N(void 0);isEdit=N(!1);outletID=N("");outletName=N("");RFIDService=G(gt);outletService=G(z);loadService=G(ue);enabledDragDrop=!0;onOpenContextMenuIndex=-1;appConfig$=this.loadService.appConfigJSON$;ngOnInit(){this.outletService.outlet.valueChanges.pipe(Y(t=>this.RFIDService.processGroupedData(t.ID)),k(t=>this.cartService.addCartRFID(t))).subscribe()}initDragDropEnabled(){I.isMobileDevice&&(this.enabledDragDrop=!1)}isSignificantQty(t){return t>1||t<=-1}shouldShowBaseQuantity(t){return t.Quantity!=1||t.UnitQuantity>1||t.VariantUnitQuantity>1}shouldShowUnitMultiplier(t){return t.UnitQuantity>1}shouldShowPriceMultiplier(t,e){return this.isSignificantQty(t.Quantity)&&e}shouldShowUnitPrice(t,e){let i=t.Discount>0||t.DiscountAmount>0;return(this.isSignificantQty(t.Quantity)||i)&&e}shouldShowVariantQty(t){return t.VariantUnitQuantity>1}shouldShow(t){return!!this.appConfigJSON()?.ModuleBuy?.Grid?.[t]}deleteVariant(t){this.cartService.deleteVariant(t)}drop(t){this.cartService.dragDropCart(t)}onContextMenu(t){this.onOpenContextMenuIndex=t}get contextMenuQuantity(){return this.cart()?.[this.onOpenContextMenuIndex]?.Quantity??null}onReturn(){this.cartService.returnVariant(this.onOpenContextMenuIndex)}onPurchase(){this.cartService.purchaseVariant(this.onOpenContextMenuIndex)}update(t,e){let i=P({},t);this.matDialog.open(yt,{data:{variant:i,appConfigJSON:this.appConfigJSON(),isEdit:this.isEdit(),outletID:this.outletID(),outletName:this.outletName(),deliveryEntityID:this.form.fulfillmentResult.value.deliveryEntityID}}).afterClosed().pipe(A(o=>!!o)).subscribe(o=>{this.cartService.updateVariant(o,e),this.sf.searchFilterNativeEl.focus()})}static \u0275fac=function(e){return new(e||n)(g(Z),g(ie),g(Ce),g(z),g(Zt),g(Vt))};static \u0275cmp=V({type:n,selectors:[["POS-cart-display"]],inputs:{cart:[1,"cart"],appConfigJSON:[1,"appConfigJSON"],isEdit:[1,"isEdit"],outletID:[1,"outletID"],outletName:[1,"outletName"]},decls:4,vars:1,consts:[["context_menu",""],[3,"cdkContextMenuTriggerFor"],[1,"row","g-0","h-100"],[1,"table","table-borderless"],["cdkDropList","",3,"cdkDropListDropped"],["cdkDrag","",1,"border-bottom",3,"cdkDragDisabled"],["cdkDrag","",1,"border-bottom",3,"contextmenu","click","cdkDragDisabled"],[2,"width","10px"],[2,"width","50%"],[1,"d-flex"],[1,"ratio","ratio-1x1",2,"width","55px"],[1,"item-image","d-flex","justify-content-center","align-items-center","text-center","fs-1"],[1,"ms-4","d-flex","flex-column","justify-content-center",2,"line-height","18px"],[1,"fw-normal","fs-6","text-muted"],[3,"serials"],["title","Note",1,"special-TinyMCE","m-0","fst-italic","d-block",3,"innerHtml"],[1,"text-end"],[1,"d-flex","fw-normal","gap-2","align-items-center"],[1,"d-flex","flex-column"],[1,"d-flex","align-items-center"],[1,"fs-5","no-leading"],[1,"fs-6","ms-1","no-leading"],[1,"fs-5","ms-1","no-leading"],[1,"d-flex","gap-1"],[1,"fs-5"],[1,"text-end","text-danger"],[1,"text-end",2,"width","75px"],[1,"fa-solid","fa-trash","fs-4","text-danger","pointer",3,"click"],[1,"item-image",3,"src"],[1,"fa-solid","fa-image",2,"color","#b4b4b4c2"],["title","Variant Unit Quantity",1,"fs-5"],[2,"font-size","9px"],[1,"col-12"],[1,"d-flex","justify-content-center","align-items-center","h-100"],[1,"row"],[1,"col-12","d-flex","justify-content-center"],[1,"fa-regular","fa-cart-arrow-up","text-secondary",2,"font-size","110px"],[1,"col-12","justify-content-center","text-center","mt-5","empty-cart-description","text-secondary","headings-font-family"],["cdkMenu","",1,"example-menu"],["cdkMenuItem","",1,"example-menu-item",3,"disabled"],["cdkMenuItem","",1,"example-menu-item",3,"click","disabled"],[1,"fa-solid","fa-plus","me-3"],[1,"fa-solid","fa-minus","me-3"]],template:function(e,i){e&1&&(v(0,ea,8,4,"div",1)(1,ta,15,0,"div",2),kt(2,na,5,2,"ng-template",null,0,Wt)),e&2&&_(i.cart().length?0:1)},dependencies:[te,xn,Dn,_n,Xn,zn,Kn,Yn,Rn,Se,ye,Xt],styles:[".item-image[_ngcontent-%COMP%]{height:50px;width:56px;display:block;border:solid 1px #dddddd;border-radius:5px;object-fit:contain}.example-menu[_ngcontent-%COMP%]{display:inline-flex;flex-direction:column;min-width:180px;max-width:280px;background-color:#fff;padding:6px 0}.example-menu-item[_ngcontent-%COMP%]{background-color:transparent;cursor:pointer;border:none;-webkit-user-select:none;user-select:none;min-width:64px;line-height:36px;padding:0 16px;display:flex;align-items:center;flex-direction:row;flex:1}.example-menu-item[_ngcontent-%COMP%]:hover{background-color:#f5f5f5}.example-menu-item[_ngcontent-%COMP%]:active{background-color:#dcdcdc}.table[_ngcontent-%COMP%] > [_ngcontent-%COMP%]:not(caption) > *[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]{padding:12px 10px} .cdk-menu.cdk-menu-group.example-menu{box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.empty-cart-description[_ngcontent-%COMP%]{font-size:14px;font-weight:500;color:#c7c7c7}small[_ngcontent-%COMP%]{font-size:9px!important;margin:0}.no-leading[_ngcontent-%COMP%]{line-height:1}"],changeDetection:0})};var ci=class n{constructor(t,e){this.dialogRef=t;this.data=e;this.config.title="Return",this.invoiceNumber=e.invoiceNumber}config=new Ie;invoiceNumber;ok(){this.dialogRef.close(this.invoiceNumber)}static \u0275fac=function(e){return new(e||n)(g(Oe),g(ke))};static \u0275cmp=V({type:n,selectors:[["POS-modal-return-invoice"]],decls:6,vars:2,consts:[[3,"onOk","onCancel","onClose","config"],[1,"form-floating-outline","m-0"],["type","text","id","invoiceNumber","name","invoiceNumber",1,"form-control",3,"ngModelChange","ngModel"],["for","invoiceNumber"]],template:function(e,i){e&1&&(a(0,"modal-material",0),D("onOk",function(){return i.ok()})("onCancel",function(){return i.dialogRef.close()})("onClose",function(){return i.dialogRef.close()}),a(1,"content")(2,"div",1)(3,"input",2),J("ngModelChange",function(s){return Q(i.invoiceNumber,s)||(i.invoiceNumber=s),s}),r(),a(4,"label",3),m(5,"Supplier Bill"),r()()()()),e&2&&(y("config",i.config),l(3),W("ngModel",i.invoiceNumber))},dependencies:[te,Fe,Me,de,Ee,Pe],encapsulation:2})};var mi=class n{constructor(t){this.matDialog=t}invoiceNumber;disabled=!1;onChange=t=>{};onTouched=()=>{};writeValue(t){this.invoiceNumber=t}registerOnChange(t){this.onChange=t}registerOnTouched(t){this.onTouched=t}setDisabledState(t){this.disabled=t}openModalReturnInvoice(){return oe(this,null,function*(){this.matDialog.open(ci,{data:{invoiceNumber:this.invoiceNumber}}).afterClosed().pipe(A(t=>!!t)).subscribe(t=>{this.invoiceNumber=t,this.onChange(this.invoiceNumber)})})}static \u0275fac=function(e){return new(e||n)(g(ie))};static \u0275cmp=V({type:n,selectors:[["POS-return-invoice"]],features:[je([{provide:Ze,multi:!0,useExisting:n}])],decls:1,vars:0,consts:[["icon","fa-solid fa-file-invoice","label","Return Bill",3,"click"]],template:function(e,i){e&1&&(a(0,"POS-dropdown-item-more-action",0),D("click",function(){return i.openModalReturnInvoice()}),r())},dependencies:[zt,Qe],encapsulation:2})};var di=class n{constructor(t){this.cart=t}returnCart(){this.cart.returnCart()}static \u0275fac=function(e){return new(e||n)(g(Z))};static \u0275cmp=V({type:n,selectors:[["POS-return-cart"]],decls:1,vars:0,consts:[["icon","fa-cart-shopping fa-solid","label","Return Cart",3,"click"]],template:function(e,i){e&1&&(a(0,"POS-dropdown-item-more-action",0),D("click",function(){return i.returnCart()}),r())},dependencies:[Qe],encapsulation:2})};var pi=class n{constructor(t){this.cart=t}clearCart(){this.cart.clearCart()}static \u0275fac=function(e){return new(e||n)(g(Z))};static \u0275cmp=V({type:n,selectors:[["POS-clear-cart"]],decls:1,vars:0,consts:[["icon","fa-trash fa-solid","label","Clear",3,"click"]],template:function(e,i){e&1&&(a(0,"POS-dropdown-item-more-action",0),D("click",function(){return i.clearCart()}),r())},dependencies:[Qe],encapsulation:2})};var ui=class n{constructor(t,e){this.matDialog=t;this.cart=e}appConfigJSON=N(void 0);isEditBuyForm=N(!1);outletID=N("");outletName=N("");addVariant(){return oe(this,null,function*(){this.matDialog.open(yt,{data:{appConfigJSON:this.appConfigJSON(),isEdit:this.isEditBuyForm(),outletID:this.outletID(),outletName:this.outletName()}}).afterClosed().pipe(A(t=>!!t)).subscribe(t=>this.cart.addVariant(t))})}static \u0275fac=function(e){return new(e||n)(g(ie),g(Z))};static \u0275cmp=V({type:n,selectors:[["POS-add-variant"]],inputs:{appConfigJSON:[1,"appConfigJSON"],isEditBuyForm:[1,"isEditBuyForm"],outletID:[1,"outletID"],outletName:[1,"outletName"]},decls:1,vars:0,consts:[["icon","fa-circle-plus fa-solid","label","Add",3,"click"]],template:function(e,i){e&1&&(a(0,"POS-dropdown-item-more-action",0),D("click",function(){return i.addVariant()}),r())},dependencies:[Qe],encapsulation:2,changeDetection:0})};var fi=class n{constructor(t,e){this.matDialog=t;this.cart=e}outletID=N("");uploadCart(){return oe(this,null,function*(){this.matDialog.open(Jn,{data:{sampleUrl:cn.files.csv.buy_import,outletID:this.outletID(),fileEndpoint:"/API/Buy/UploadCsvV2",useUppy:!0}}).afterClosed().pipe(A(t=>!!t),p(t=>t.map(e=>B(P({},e.Variant),{UnitPrice:e.Cost,Total:e.Cost*e.Quantity*(1-e.Discount/100)-e.DiscountAmount,Quantity:e.Quantity,Serial:e.Serial,Note:e.Note,Discount:e.Discount,DiscountAmount:e.DiscountAmount})))).subscribe(t=>this.cart.uploadCart(t))})}static \u0275fac=function(e){return new(e||n)(g(ie),g(Z))};static \u0275cmp=V({type:n,selectors:[["POS-upload-cart"]],inputs:{outletID:[1,"outletID"]},decls:1,vars:0,consts:[["icon","fa-upload fa-solid","label","Upload",3,"click"]],template:function(e,i){e&1&&(a(0,"POS-dropdown-item-more-action",0),D("click",function(){return i.uploadCart()}),r())},dependencies:[Qe],encapsulation:2,changeDetection:0})};var oa=["serialInput"],gi=class n{constructor(t,e,i){this.dialogRef=t;this.toastr=e;this.cart=i;this.modalConfig.title="Scan Serial",this.modalConfig.customWidth="350px",this.modalConfig.hideOk=!0,this.modalConfig.hideCancel=!0}serialInputEl=ut("serialInput");modalConfig=new Ie;serial;ngOnInit(){}onKeyDown(t){t.key=="Enter"&&(I.IsNotEmpty(this.serial)?(this.cart.addVariantThroughSerial(this.serial),this.serial=null):this.toastr.warning("Serial Can`t be empty","Warning!"),this.setFocusInput())}setFocusInput(){let t=this.serialInputEl();t&&setTimeout(()=>{t?.nativeElement?.focus()},500)}static \u0275fac=function(e){return new(e||n)(g(Oe),g(Le),g(Z))};static \u0275cmp=V({type:n,selectors:[["POS-modal-scan-serial"]],viewQuery:function(e,i){e&1&&St(i.serialInputEl,oa,5),e&2&&Mt()},decls:7,vars:2,consts:[["serialInput",""],[3,"onClose","config"],[1,"input-group","mt-3"],["type","text","placeholder","Input Product By Serial","aria-label","Serial",1,"form-control",3,"ngModelChange","keydown","ngModel"],[1,"input-group-text"],[1,"fa-solid","fa-barcode","fs-4"]],template:function(e,i){if(e&1){let o=U();a(0,"modal-material",1),D("onClose",function(){return i.dialogRef.close()}),a(1,"content")(2,"div",2)(3,"input",3,0),J("ngModelChange",function(F){return O(o),Q(i.serial,F)||(i.serial=F),T(F)}),D("keydown",function(F){return i.onKeyDown(F)}),r(),a(5,"span",4),x(6,"i",5),r()()()()}e&2&&(y("config",i.modalConfig),l(3),W("ngModel",i.serial))},dependencies:[te,Fe,Me,de,Ee,Pe],styles:["input[_ngcontent-%COMP%]{height:55px;border-bottom-left-radius:4px;border-top-left-radius:4px}span.input-group-text[_ngcontent-%COMP%]{border-bottom-right-radius:4px;border-top-right-radius:4px}"],changeDetection:0})};var Ci=class n{constructor(t,e){this.matDialog=t;this.viewContainerRef=e}scanSerial(){return oe(this,null,function*(){this.matDialog.open(gi,{viewContainerRef:this.viewContainerRef})})}static \u0275fac=function(e){return new(e||n)(g(ie),g(Xi))};static \u0275cmp=V({type:n,selectors:[["POS-scan-serial"]],decls:1,vars:0,consts:[["icon","fa-barcode-read fa-solid","label","Serial",3,"click"]],template:function(e,i){e&1&&(a(0,"POS-dropdown-item-more-action",0),D("click",function(){return i.scanSerial()}),r())},dependencies:[Qe],encapsulation:2})};var aa=(n,t)=>({red:n,green:t}),yi=class n{RFIDService=G(gt);matDialog=G(ie);onOpenModal(){return oe(this,null,function*(){let t=this.RFIDService.baseUrl(),e=this.RFIDService.bufferTime;this.RFIDService.isConnected.pipe(ht(1),Y(i=>this.matDialog.open(eo,{data:{url:t,bufferTime:e,isConnected:i}}).afterClosed()),A(i=>!!i)).subscribe(i=>{"url"in i&&i.url?(this.RFIDService.bufferTime=i.bufferTime,this.RFIDService.intializeWebSocket(i.url)):"disconnect"in i&&i.disconnect&&this.RFIDService.disconnectWebSocket()})})}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=V({type:n,selectors:[["pos-rfid-buy-action"]],decls:7,vars:8,consts:[[1,"dropdown-item","px-1","d-flex",3,"click"],["aria-hidden","true",1,"fa-solid","fa-wifi","fs-2"],[1,"pe-0","ps-4","fs-6","cursor-pointer"],[1,"blob",2,"position","absolute","top","0","right","0",3,"ngClass"]],template:function(e,i){e&1&&(a(0,"div",0),D("click",function(){return i.onOpenModal()}),x(1,"i",1),a(2,"label",2),m(3,"Connect RFID"),r(),x(4,"div",3),u(5,"async"),u(6,"async"),r()),e&2&&(l(4),y("ngClass",lt(5,aa,!C(5,1,i.RFIDService.isConnected),C(6,3,i.RFIDService.isConnected))))},dependencies:[te,Xe,Se],styles:[".disabled[_ngcontent-%COMP%]{color:gray;pointer-events:none;cursor:not-allowed}.blob[_ngcontent-%COMP%]{background:#000;border-radius:50%;box-shadow:0 0 #000;height:15px;width:15px;transform:scale(1);animation:_ngcontent-%COMP%_pulse-black 2s infinite}@keyframes _ngcontent-%COMP%_pulse-black{0%{transform:scale(.95);box-shadow:0 0 #000000b3}70%{transform:scale(1);box-shadow:0 0 0 10px #0000}to{transform:scale(.95);box-shadow:0 0 #0000}}.blob.white[_ngcontent-%COMP%]{background:#fff;box-shadow:0 0 #fff;animation:_ngcontent-%COMP%_pulse-white 2s infinite}@keyframes _ngcontent-%COMP%_pulse-white{0%{transform:scale(.95);box-shadow:0 0 #ffffffb3}70%{transform:scale(1);box-shadow:0 0 0 10px #fff0}to{transform:scale(.95);box-shadow:0 0 #fff0}}.blob.red[_ngcontent-%COMP%]{background:#ff5252;box-shadow:0 0 #ff5252;animation:_ngcontent-%COMP%_pulse-red 2s infinite}@keyframes _ngcontent-%COMP%_pulse-red{0%{transform:scale(.95);box-shadow:0 0 #ff5252b3}70%{transform:scale(1);box-shadow:0 0 0 10px #ff525200}to{transform:scale(.95);box-shadow:0 0 #ff525200}}.blob.orange[_ngcontent-%COMP%]{background:#ff793f;box-shadow:0 0 #ff793f;animation:_ngcontent-%COMP%_pulse-orange 2s infinite}@keyframes _ngcontent-%COMP%_pulse-orange{0%{transform:scale(.95);box-shadow:0 0 #ff793fb3}70%{transform:scale(1);box-shadow:0 0 0 10px #ff793f00}to{transform:scale(.95);box-shadow:0 0 #ff793f00}}.blob.yellow[_ngcontent-%COMP%]{background:#ffb142;box-shadow:0 0 #ffb142;animation:_ngcontent-%COMP%_pulse-yellow 2s infinite}@keyframes _ngcontent-%COMP%_pulse-yellow{0%{transform:scale(.95);box-shadow:0 0 #ffb142b3}70%{transform:scale(1);box-shadow:0 0 0 10px #ffb14200}to{transform:scale(.95);box-shadow:0 0 #ffb14200}}.blob.blue[_ngcontent-%COMP%]{background:#34ace0;box-shadow:0 0 #34ace0;animation:_ngcontent-%COMP%_pulse-blue 2s infinite}@keyframes _ngcontent-%COMP%_pulse-blue{0%{transform:scale(.95);box-shadow:0 0 #34ace0b3}70%{transform:scale(1);box-shadow:0 0 0 10px #34ace000}to{transform:scale(.95);box-shadow:0 0 #34ace000}}.blob.green[_ngcontent-%COMP%]{background:#77d933;box-shadow:0 0 #77d933;animation:_ngcontent-%COMP%_pulse-green 2s infinite}@keyframes _ngcontent-%COMP%_pulse-green{0%{transform:scale(.95);box-shadow:0 0 #33d938b3}70%{transform:scale(1);box-shadow:0 0 0 10px #33d9b200}to{transform:scale(.95);box-shadow:0 0 #33d9b200}}.blob.purple[_ngcontent-%COMP%]{background:#8e44ad;box-shadow:0 0 #8e44ad;animation:_ngcontent-%COMP%_pulse-purple 2s infinite}@keyframes _ngcontent-%COMP%_pulse-purple{0%{transform:scale(.95);box-shadow:0 0 #8e44adb3}70%{transform:scale(1);box-shadow:0 0 0 10px #8e44ad00}to{transform:scale(.95);box-shadow:0 0 #8e44ad00}}"],changeDetection:0})};function ra(n,t){n&1&&(a(0,"li",10),x(1,"POS-return-cart"),r())}function la(n,t){if(n&1&&(a(0,"li",10),x(1,"POS-return-invoice",14),r()),n&2){let e=d(2);l(),y("formControl",e.returnInvoiceNumber())}}function sa(n,t){if(n&1&&(a(0,"div",7)(1,"div",8),m(2,"Order"),r(),x(3,"div",9),v(4,ra,2,0,"li",10),v(5,la,2,1,"li",10),r()),n&2){let e=d();l(4),_(e.role.sell.Return?4:-1),l(),_(e.role.sell.Return?5:-1)}}var bi=class n{constructor(t,e,i){this.role=t;this.matDialog=e;this.cart=i}returnInvoiceNumber=N(new ge(""));appConfigJSON=N(void 0);isEditBuyForm=N(!1);outletID=N("");outletName=N("");handleKeyboardEvent(t){t.key==="F4"&&this.matDialog.openDialogs.length===0&&this.addVariant()}addVariant(){this.matDialog.open(yt,{data:{appConfigJSON:this.appConfigJSON(),isEdit:this.isEditBuyForm(),outletID:this.outletID(),outletName:this.outletName()}}).afterClosed().pipe(A(t=>!!t)).subscribe(t=>this.cart.addVariant(t))}static \u0275fac=function(e){return new(e||n)(g(Ce),g(ie),g(Z))};static \u0275cmp=V({type:n,selectors:[["POS-more-actions"]],hostBindings:function(e,i){e&1&&D("keydown",function(s){return i.handleKeyboardEvent(s)},zi)},inputs:{returnInvoiceNumber:[1,"returnInvoiceNumber"],appConfigJSON:[1,"appConfigJSON"],isEditBuyForm:[1,"isEditBuyForm"],outletID:[1,"outletID"],outletName:[1,"outletName"]},decls:27,vars:6,consts:[["id","moreMenu","data-bs-toggle","dropdown",1,"d-flex","align-items-center","cursor-pointer"],[1,"me-2"],[1,"fa-solid","fa-caret-down","fa-lg"],[1,"fs-6","headings-font-family","pb-1"],[1,"h-100","d-flex","align-items-center","justify-content-between"],["aria-labelledby","moreMenu",1,"dropdown-menu","more-actions"],[1,"d-flex",2,"width","30rem"],[1,"dropdown-header","text-dark","col"],[1,"h5","mb-4"],[1,"dropdown-divider","m-0"],[1,"cursor-pointer"],[3,"appConfigJSON","isEditBuyForm","outletID","outletName"],[3,"outletID"],[1,"cursor-pointer","position-relative"],[3,"formControl"]],template:function(e,i){e&1&&(a(0,"span",0)(1,"span",1),x(2,"i",2),r(),a(3,"span",3),m(4,"More Actions"),r()(),a(5,"div",4)(6,"div",5)(7,"div",6),v(8,sa,6,2,"div",7),a(9,"div",7)(10,"div",8),m(11,"Item"),r(),x(12,"div",9),a(13,"li",10),x(14,"POS-add-variant",11),r(),a(15,"li",10),x(16,"POS-scan-serial"),r(),a(17,"li",10),x(18,"POS-upload-cart",12),r(),a(19,"li",10),x(20,"POS-clear-cart"),r()(),a(21,"div",7)(22,"div",8),m(23,"Advanced"),r(),x(24,"div",9),a(25,"li",13),x(26,"pos-rfid-buy-action"),r()()()()()),e&2&&(l(8),_(i.role.sell.Return?8:-1),l(6),y("appConfigJSON",i.appConfigJSON())("isEditBuyForm",i.isEditBuyForm())("outletID",i.outletID())("outletName",i.outletName()),l(4),y("outletID",i.outletID()))},dependencies:[tt,de,et,mi,di,pi,ui,fi,Ci,yi],encapsulation:2,changeDetection:0})};var hi=class n{constructor(t,e){this.dialogRef=t;this.config.title="Discount and Tax",this.config.customWidth="400px";let i=e.discount;this.discountAmount=i.Amount,this.discountPercentage=i.Percentage;let o=e.tax;this.taxID=o.ID,this.taxRate=o.Rate,this.taxType=o.CalculationTypeName,this.taxLabel=o.Label,this.taxes=e.taxes.filter(s=>!s.Bin),this.currencySymbol=e.currencySymbol}config=new Ie;tabIndexActive;discountAmount=0;discountPercentage=0;taxes=[];taxID="";taxRate=0;taxType="";taxLabel="";discounts=[];currencySymbol="";ok(){this.dialogRef.close({Discount:{Amount:this.discountAmount,Percentage:this.discountPercentage},Tax:{ID:this.taxID,Rate:this.taxRate,CalculationTypeName:this.taxType,Label:this.taxLabel,Discontinue:!1}})}close(){this.dialogRef.close()}calculateDiscountCalculator(){let t=100;this.discounts.forEach(e=>{t=t*(100-e)/100}),this.discountPercentage=100-t}updateTax(t){this.taxID=t.ID,this.taxRate=t.Rate,this.taxType=t.CalculationTypeName,this.taxLabel=t.Label}static \u0275fac=function(e){return new(e||n)(g(Oe),g(ke))};static \u0275cmp=V({type:n,selectors:[["POS-modal-discount-and-tax"]],decls:48,vars:10,consts:[[3,"keydown.F2","onOk","onCancel","onClose","config"],[1,"container"],["matTooltipPosition","above","matTooltip","Discount","tabTitle","Discount"],[1,"row","d-flex","align-items-center","justify-content-start"],[1,"col-3"],[1,"fw-bold","d-block"],[1,"col-9"],["type","text","data-cy","discount1","autoNum","","percentage","","decimalPlaces","2",1,"form-control","d-inline-block",2,"width","100px",3,"ngModelChange","ngModel"],[1,"ms-1"],[1,"row","d-flex","align-items-center","justify-content-start","mt-6"],["type","text","data-cy","discountamount","autoNum","",1,"form-control","d-inline-block",2,"width","100px",3,"ngModelChange","ngModel"],["matTooltipPosition","above","matTooltip","Tax","tabTitle","Tax"],["bindLabel","Label","appendTo","body","bindValue","ID","placeholder","Tax","data-cy","Tax",2,"width","150px",3,"change","clearable","ngModel","items"],["matTooltipPosition","above","matTooltip","Calculation","tabTitle","Calculator"],[1,"row","mt-6","g-0","d-flex","align-items-center","justify-content-start"],[1,"col-4"],[1,"col-8","ps-4"],["type","text","data-cy","discountCal1","autoNum","","percentage","","decimalPlaces","2",1,"form-control","d-inline-block",2,"width","47px",3,"ngModelChange","ngModel"],[1,"mx-2"],["type","text","data-cy","discountCal2","autoNum","","percentage","","decimalPlaces","2",1,"form-control","d-inline-block",2,"width","47px",3,"ngModelChange","ngModel"],["type","text","data-cy","discountCal3","autoNum","","percentage","","decimalPlaces","2",1,"form-control","d-inline-block",2,"width","47px",3,"ngModelChange","ngModel"]],template:function(e,i){e&1&&(a(0,"modal-material",0),D("keydown.F2",function(){return i.ok()})("onOk",function(){return i.ok()})("onCancel",function(){return i.close()})("onClose",function(){return i.close()}),a(1,"content")(2,"div",1)(3,"custom-tabs"),jt(4),a(5,"tab",2)(6,"div",3)(7,"div",4)(8,"label",5),m(9,"Discount %"),r()(),a(10,"div",6)(11,"input",7),J("ngModelChange",function(s){return Q(i.discountPercentage,s)||(i.discountPercentage=s),s}),r(),a(12,"span",8),m(13,"%"),r()()(),a(14,"div",9)(15,"div",4)(16,"label",5),m(17),r()(),a(18,"div",6)(19,"input",10),J("ngModelChange",function(s){return Q(i.discountAmount,s)||(i.discountAmount=s),s}),r()()()(),Lt(),jt(20),a(21,"tab",11)(22,"div",3)(23,"div",4)(24,"label",5),m(25,"Tax"),r()(),a(26,"div",6)(27,"ng-select",12),D("change",function(s){return i.updateTax(s)}),r()()()(),Lt(),jt(28),a(29,"tab",13)(30,"div",14)(31,"div",15)(32,"label",5),m(33,"Discount Calculator"),r()(),a(34,"div",16)(35,"input",17),J("ngModelChange",function(s){return Q(i.discounts[0],s)||(i.discounts[0]=s),s}),D("ngModelChange",function(){return i.calculateDiscountCalculator()}),r(),a(36,"span"),m(37," %"),r(),a(38,"span",18),m(39,"+"),r(),a(40,"input",19),J("ngModelChange",function(s){return Q(i.discounts[1],s)||(i.discounts[1]=s),s}),D("ngModelChange",function(){return i.calculateDiscountCalculator()}),r(),a(41,"span"),m(42," %"),r(),a(43,"span",18),m(44,"+"),r(),a(45,"input",20),J("ngModelChange",function(s){return Q(i.discounts[2],s)||(i.discounts[2]=s),s}),D("ngModelChange",function(){return i.calculateDiscountCalculator()}),r(),a(46,"span"),m(47," %"),r()()()(),Lt(),r()()()()),e&2&&(y("config",i.config),l(11),W("ngModel",i.discountPercentage),l(6),E("Discount ",i.currencySymbol),l(2),W("ngModel",i.discountAmount),l(8),y("clearable",!1)("ngModel",i.taxID)("items",i.taxes),l(8),W("ngModel",i.discounts[0]),l(5),W("ngModel",i.discounts[1]),l(5),W("ngModel",i.discounts[2]))},dependencies:[te,Fe,Me,de,Ee,wt,Pe,Un,Wn,Qn,ft,nt,it,Yt],encapsulation:2})};var qe=class n{constructor(t,e,i){this.form=e;this.decimalPipe=i;let o=e.discountAndTaxForm.valueChanges;this.currency$=e.noteForm.valueChanges.pipe(p(f=>f.Currency),ae(1),X()),this.currencySymbol$=this.currency$.pipe(p(f=>f.Symbol),X());let s=t.cart$.pipe(k(console.log),p(f=>f.map(w=>w.Total)),p(f=>f.reduce((w,H)=>w+H,0)),p(f=>this.setDecimalDigit(f)),ae(1),X()),F=t.cart$.pipe(p(f=>f.filter(w=>w.Taxable).map(w=>w.Total)),p(f=>f.reduce((w,H)=>w+H,0)),p(f=>this.setDecimalDigit(f)),ae(1),X());this.displayedAmount$=s,this.displayedDiscountPercentage$=xe(this.displayedAmount$,o.pipe(p(f=>f.Discount.Percentage))).pipe(p(([f,w])=>({label:`Discount ${w}%`,value:f*(w/100)})),Ye({label:"",value:0}),ae(1),X()),this.displayedDiscountAmount$=xe(this.currencySymbol$,o.pipe(p(f=>f.Discount.Amount))).pipe(p(([f,w])=>({label:`Discount ${f}`,value:w})),Ye({label:"",value:0}),ae(1),X()),this.displayedTax$=xe(F,this.displayedDiscountPercentage$.pipe(p(f=>f.value)),this.displayedDiscountAmount$.pipe(p(f=>f.value)),o.pipe(p(f=>f.Tax)),ki(t.isReturn)).pipe(A(([,,,f])=>!!f.Label),p(([f,w,H,M,j])=>({amountAfterDiscount:f-w-(j?-H:H),tax:M})),p(f=>{let w=f.amountAfterDiscount,H=f.tax;return{label:H.Label,tax:{id:H.ID,value:H.CalculationTypeName=="Add"?w*(H.Rate/100):H.Rate/(100+H.Rate)*w,type:H.CalculationTypeName,rate:H.Rate}}}),k(f=>e.setTaxAmount(f.tax.value)),Ye({label:"",tax:{id:"",value:0,type:"",rate:0}}),ae(1),X()),this.amountAfterDiscountAndTax$=xe(this.displayedAmount$,this.displayedDiscountPercentage$.pipe(p(f=>f.value)),this.displayedDiscountAmount$.pipe(p(f=>f.value)),this.displayedTax$.pipe(p(f=>f.tax)),t.cart$.pipe(p(f=>f.length)),ki(t.isReturn)).pipe(p(([f,w,H,M,j,c])=>{let S=w+(c?-H:H);return j?f-S+(M.type=="Add"?M.value:0):0}),X()).pipe(ae(1)),this.amountAfterDiscountAndTax$.subscribe()}paymentMethodName=se("Cash");displayedAmount$;displayedDiscountPercentage$;displayedDiscountAmount$;displayedTax$;currency$;currencySymbol$;amountAfterDiscountAndTax$;get amountToPay(){return this.form.buyForm.controls.Payment.controls.Amount.value}get methodID(){return this.form.buyForm.controls.Payment.controls.MethodID.value}get code(){return this.form.buyForm.controls.Payment.controls.Code.value}get note(){return this.form.buyForm.controls.Payment.controls.Note.value}setDecimalDigit(t){let e=this.decimalPipe.transform(t,"1.0-4");return t=parseFloat(e.split(",").join("")),t}static \u0275fac=function(e){return new(e||n)(q(Z),q(z),q(ye))};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};var _i=class n{constructor(t,e){this.matDialog=t;this.payment=e}taxes=N([]);currencySymbol=N("");isReturn=N(!1);discTax;disabled=!1;onChange=t=>{};onTouched=()=>{};writeValue(t){this.discTax=t}registerOnChange(t){this.onChange=t}registerOnTouched(t){this.onTouched=t}setDisabledState(t){this.disabled=t}openModalDiscountAndTax(){return oe(this,null,function*(){this.payment.displayedAmount$.pipe(ht(1)).subscribe(t=>{let e={Amount:this.discTax.Discount.Amount,Percentage:this.discTax.Discount.Percentage};this.matDialog.open(hi,{data:{discount:P({},e),tax:P({},this.discTax.Tax),taxes:this.taxes(),currencySymbol:this.currencySymbol(),displayedAmount:t,isReturn:this.isReturn()}}).afterClosed().pipe(A(i=>!!i)).subscribe(i=>{this.discTax.Discount=P({},i.Discount),this.discTax.Tax=P({},i.Tax),this.onChange(this.discTax)})})})}static \u0275fac=function(e){return new(e||n)(g(ie),g(qe))};static \u0275cmp=V({type:n,selectors:[["POS-discount-and-tax-form"]],inputs:{taxes:[1,"taxes"],currencySymbol:[1,"currencySymbol"],isReturn:[1,"isReturn"]},features:[je([{provide:Ze,multi:!0,useExisting:n}])],decls:2,vars:0,consts:[["type","button","matTooltip","Discount / Tax","matTooltipPosition","above",1,"btn","btn-success","fs-5",2,"border-right","0.1px solid #fff",3,"click"],[1,"fa-light","fa-percent"]],template:function(e,i){e&1&&(a(0,"button",0),D("click",function(){return i.openModalDiscountAndTax()}),x(1,"i",1),r())},dependencies:[nt,it,zt],styles:["button[_ngcontent-%COMP%]{border-right:.1px solid #fff;border-top-right-radius:0;border-bottom-right-radius:0;position:relative;flex:1 1 auto}"],changeDetection:0})};var Bt=n=>({selected:n}),ca=(n,t)=>({"col-sm-3":n,"col-sm-7":t});function ma(n,t){if(n&1){let e=U();a(0,"a",10),D("click",function(){O(e);let o=d();return T(o.onTabChange("Number"))}),m(1," Number "),r()}if(n&2){let e=d();y("ngClass",le(1,Bt,e.tabState=="Number"))}}function da(n,t){if(n&1){let e=U();a(0,"div",11)(1,"label",12)(2,"input",13),J("ngModelChange",function(o){O(e);let s=d(2);return Q(s.tagID,o)||(s.tagID=o),T(o)}),r(),m(3),r()()}if(n&2){let e=t.$implicit,i=t.$index,o=d(2);l(),y("for",Fi("potype-"+i))("ngClass",le(8,Bt,o.tagID==e.ID)),l(),y("id",Fi("potype-"+i)),W("ngModel",o.tagID),y("value",e.ID),l(),E(" ",e.Name," ")}}function pa(n,t){if(n&1&&(a(0,"div",8),we(1,da,4,10,"div",11,Be),r()),n&2){let e=d();l(),Ne(e.supplierPOTypes)}}function ua(n,t){if(n&1){let e=U();a(0,"strong",14),m(1,"Supplier Bill Number"),r(),a(2,"input",15),J("ngModelChange",function(o){O(e);let s=d();return Q(s.invoiceNumber,o)||(s.invoiceNumber=o),T(o)}),r()}if(n&2){let e=d();l(2),W("ngModel",e.invoiceNumber)}}function fa(n,t){if(n&1){let e=U();a(0,"div",9)(1,"POS-tinymce-editor",16),J("ngModelChange",function(o){O(e);let s=d();return Q(s.note,o)||(s.note=o),T(o)}),r()()}if(n&2){let e=d();l(),W("ngModel",e.note)}}function ga(n,t){if(n&1){let e=U();a(0,"div",22)(1,"span",27),m(2,"@"),r(),a(3,"input",28),J("ngModelChange",function(o){O(e);let s=d(2);return Q(s.exchangeRate,o)||(s.exchangeRate=o),T(o)}),r()()}if(n&2){let e=d(2);l(3),W("ngModel",e.exchangeRate)}}function Ca(n,t){if(n&1){let e=U();a(0,"div",17)(1,"div",18)(2,"div",19),m(3,"Currency :"),r(),a(4,"div",20)(5,"ng-select",21),J("ngModelChange",function(o){O(e);let s=d();return Q(s.currencyID,o)||(s.currencyID=o),T(o)}),r()(),v(6,ga,4,1,"div",22),r()(),a(7,"div",23)(8,"div",24),m(9,"Term :"),r(),a(10,"div",25)(11,"ng-select",26),J("ngModelChange",function(o){O(e);let s=d();return Q(s.note,o)||(s.note=o),T(o)}),r()()()}if(n&2){let e=d();l(4),y("ngClass",lt(8,ca,e.currencyID!=e.defaultCurrencyID,e.currencyID==e.defaultCurrencyID)),l(),y("items",e.currencies),W("ngModel",e.currencyID),y("clearable",!1),l(),_(e.currencyID!=e.defaultCurrencyID?6:-1),l(5),y("items",e.predefinedNotes),W("ngModel",e.note),y("clearable",!1)}}var Di=class n{constructor(t,e){this.dialogRef=t;this.config=new Ie,this.config.title="Purchase Order Note",this.config.customWidth="700px",this.note=e.note,this.tagID=e.tagID,this.currencyID=e.currencyID,this.exchangeRate=e.currencies.find(i=>i.ID==this.currencyID).ExchangeRate,this.supplierPOTypes=e.supplierPOTypes,this.predefinedNotes=e.predefinedNotes,this.currencies=e.currencies,this.defaultCurrencyID=e.defaultCurrencyID,this.invoiceNumber=e.invoiceNumber,I.IsEmpty(this.tagID)&&(this.tagID=this.supplierPOTypes[0]?.ID)}loadService=G(ue);config$=this.loadService.appConfigJSON$;supplierPOTypes;predefinedNotes;currencies;currencyID;note;tagID;defaultCurrencyID;exchangeRate=0;invoiceNumber;tabState="Note";config;ok(){this.dialogRef.close({Note:this.note,TagID:this.tagID,Currency:B(P({},this.currencies.find(t=>t.ID==this.currencyID)),{ExchangeRate:this.exchangeRate}),InvoiceNumber:this.invoiceNumber})}close(){this.dialogRef.close()}onTabChange(t){this.tabState=t}static \u0275fac=function(e){return new(e||n)(g(Oe),g(ke))};static \u0275cmp=V({type:n,selectors:[["POS-modal-note"]],decls:19,vars:17,consts:[[3,"onCancel","onClose","onOk","config"],[1,"container-fluid"],[1,"row","border-bottom"],["data-cy","note",1,"btn","btn-link",3,"click","ngClass"],["data-cy","type",1,"btn","btn-link",3,"click","ngClass"],["data-cy","number",1,"btn","btn-link",3,"ngClass"],["data-cy","other",1,"btn","btn-link",3,"click","ngClass"],[1,"row","mt-8"],[1,"col-12"],[1,"col-12","tinymce"],["data-cy","number",1,"btn","btn-link",3,"click","ngClass"],[1,"rad-btn"],[3,"for","ngClass"],["type","radio",3,"ngModelChange","ngModel","value","id"],[1,"mb-2","ps-0"],["type","text","placeholder","Same as Purchase Order Number when blank",1,"form-control","w-50",3,"ngModelChange","ngModel"],[3,"ngModelChange","ngModel"],[1,"col-7","pe-0"],[1,"row"],[1,"col-sm-3","d-flex","align-items-center"],[1,"ps-0",3,"ngClass"],["bindLabel","Name","bindValue","ID","placeholder","Outlet","appendTo","body",3,"ngModelChange","items","ngModel","clearable"],[1,"col-sm-4","d-flex"],[1,"col-5","d-flex","align-items-center","ps-0"],[1,"col-sm-2"],[1,"col-sm-10"],["bindLabel","Label","bindValue","Description","placeholder","Term","appendTo","body",3,"ngModelChange","items","ngModel","clearable"],[1,"pt-4"],["type","text","autoNum","",1,"border","border-light",2,"width","100px",3,"ngModelChange","ngModel"]],template:function(e,i){if(e&1&&(rt(0),u(1,"async"),a(2,"modal-material",0),D("onCancel",function(){return i.close()})("onClose",function(){return i.close()})("onOk",function(){return i.ok()}),a(3,"content")(4,"div",1)(5,"div",2)(6,"div")(7,"a",3),D("click",function(){return i.onTabChange("Note")}),m(8," Note "),r(),a(9,"a",4),D("click",function(){return i.onTabChange("Tag")}),m(10," Tag "),r(),v(11,ma,2,3,"a",5),a(12,"a",6),D("click",function(){return i.onTabChange("Other")}),m(13," Other "),r()()(),a(14,"div",7),v(15,pa,3,0,"div",8),v(16,ua,3,1),v(17,fa,2,1,"div",9),v(18,Ca,12,11),r()()()()),e&2){let o=C(1,9,i.config$),s=o==null||o.ModuleBuy==null||o.ModuleBuy.Numbering==null?null:o.ModuleBuy.Numbering.EnableCustomBillNumber;l(2),y("config",i.config),l(5),y("ngClass",le(11,Bt,i.tabState=="Note")),l(2),y("ngClass",le(13,Bt,i.tabState=="Tag")),l(2),_(s?11:-1),l(),y("ngClass",le(15,Bt,i.tabState=="Other")),l(3),_(i.tabState=="Tag"?15:-1),l(),_(i.tabState=="Number"?16:-1),l(),_(i.tabState=="Note"?17:-1),l(),_(i.tabState=="Other"?18:-1)}},dependencies:[te,Xe,Fe,Me,fn,de,Ee,wt,Yt,ti,ft,Pe,Se],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}content[_ngcontent-%COMP%] > div.container-fluid[_ngcontent-%COMP%]{min-height:200px}.tinymce[_ngcontent-%COMP%] a[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{z-index:2;position:absolute;right:15px;bottom:19px}.tinymce[_ngcontent-%COMP%] editor[_ngcontent-%COMP%]{height:max-content;z-index:1}.rad-btn[_ngcontent-%COMP%]{position:relative;display:inline-block}.rad-btn[_ngcontent-%COMP%] label[_ngcontent-%COMP%]{border:1px solid #dddddd;border-radius:3px;margin-right:10px;cursor:pointer;padding:10px;margin-bottom:10px;color:#000}.rad-btn[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{visibility:hidden;position:absolute;left:0;top:0}.rad-btn[_ngcontent-%COMP%] label.selected[_ngcontent-%COMP%]{background:#dcdcdc;border:1px solid #dcdcdc}.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}a.btn.btn-link[_ngcontent-%COMP%]{color:inherit}"]})};var xi=class n{constructor(t){this.matDialog=t}supplierPOTypes=N([]);predefinedNotes=N([]);defaultCurrencyID=N("");currencies=N([]);note;disabled=!1;onChange=t=>{};onTouched=()=>{};writeValue(t){this.note=t}registerOnChange(t){this.onChange=t}registerOnTouched(t){this.onTouched=t}setDisabledState(t){this.disabled=t}openModalNote(){return oe(this,null,function*(){this.matDialog.open(Di,{data:{note:this.note.Note,tagID:this.note.TagID,exchangeRate:this.note.Currency.ExchangeRate,currencyID:this.note.Currency.ID,supplierPOTypes:this.supplierPOTypes(),predefinedNotes:this.predefinedNotes(),currencies:this.currencies(),defaultCurrencyID:this.defaultCurrencyID(),invoiceNumber:this.note.InvoiceNumber}}).afterClosed().pipe(A(t=>!!t)).subscribe(t=>{this.note=t,this.onChange(t)})})}static \u0275fac=function(e){return new(e||n)(g(ie))};static \u0275cmp=V({type:n,selectors:[["POS-note-form"]],inputs:{supplierPOTypes:[1,"supplierPOTypes"],predefinedNotes:[1,"predefinedNotes"],defaultCurrencyID:[1,"defaultCurrencyID"],currencies:[1,"currencies"]},features:[je([{provide:Ze,multi:!0,useExisting:n}])],decls:2,vars:0,consts:[["type","button",1,"btn","btn-gray","w-100","h-100","fs-3","px-0","py-6","headings-font-family",3,"click"],[1,"fa-regular","fa-note-sticky","fa-xl"]],template:function(e,i){e&1&&(vt(0,"button",0),Ut("click",function(){return i.openModalNote()}),nn(1,"i",1),_t())},styles:[".btn-gray[_ngcontent-%COMP%]{border:1px solid #d6d6d6;color:#545454!important;background:linear-gradient(to bottom,#fff,#eee)}"],changeDetection:0})};var ya=(n,t)=>({"btn-secondary":n,"btn-outline-secondary":t}),ba=(n,t)=>({"btn-outline-secondary":n,"btn-secondary":t});function ha(n,t){if(n&1){let e=U();a(0,"div")(1,"label",13),x(2,"i",14),a(3,"span"),m(4,"Add inventory to outlet :"),r()(),a(5,"p-select",15),J("ngModelChange",function(o){O(e);let s=d();return Q(s.deliveryEntityIDValue,o)||(s.deliveryEntityIDValue=o),T(o)}),r()()}if(n&2){let e=d();l(5),y("options",e.outlets),W("ngModel",e.deliveryEntityIDValue),y("filter",!0)("showClear",!1)("disabled",e.isEdit)}}function va(n,t){if(n&1){let e=U();a(0,"div",12)(1,"div",16)(2,"label",17),x(3,"i",18),a(4,"span"),m(5),r()(),a(6,"div",16)(7,"p-datepicker",19),J("ngModelChange",function(o){O(e);let s=d();return Q(s.fulfillmentDateValue,o)||(s.fulfillmentDateValue=o),T(o)}),r()()(),a(8,"div",16)(9,"label",20),x(10,"i",21),a(11,"span"),m(12,"Time"),r()(),a(13,"div",16)(14,"app-timepicker",22),J("timeChange",function(o){O(e);let s=d();return Q(s.fulfillmentTimeValue,o)||(s.fulfillmentTimeValue=o),T(o)}),r()()()()}if(n&2){let e=d();l(5),ee(e.shippingDateLabel),l(2),W("ngModel",e.fulfillmentDateValue),y("baseZIndex",1e4)("showClear",!0),l(7),W("time",e.fulfillmentTimeValue),y("showIcon",!0)("showCloseBtn",!1)("fullWidth",!0)("showClear",!0)}}var Si=class n{constructor(t,e,i){this.dialogRef=t;this.datePipe=e;this.data=i;this.config=new Ie,this.config.title="Purchase Order Fulfillment",this.config.customWidth="650px",this.isEdit=i.isEdit,this.deliveryEntityID.set(i.deliveryEntityID),this.outlets=i.outlets,this.fulfillmentDate.set(i.fulfillmentDate??null),this.fulfillmentTime.set(i.fulfillmentTime??null),this.fulfillmentDateTime.set(i.fulfillmentDateTime??null),this.appConfigJSON=i.appConfigJSON,I.IsNotEmpty(i.deliveryEntityID)?this.tabState.set("Now"):this.tabState.set("Later")}isEdit=!1;outlets;deliveryEntityID=se(I.GuidEmpty);tabState=se("Now");config;fulfillmentDate=se(null);fulfillmentTime=se(null);fulfillmentDateTime=se(null);shippingDateLabel="Fulfillment Date";appConfigJSON;get deliveryEntityIDValue(){return this.deliveryEntityID()}set deliveryEntityIDValue(t){this.deliveryEntityID.set(t??I.GuidEmpty)}get fulfillmentDateValue(){return this.fulfillmentDate()}set fulfillmentDateValue(t){this.fulfillmentDate.set(t)}get fulfillmentTimeValue(){return this.fulfillmentTime()}set fulfillmentTimeValue(t){this.fulfillmentTime.set(t)}get tabStateValue(){return this.tabState()}onOk(){this.tabState()=="Later"&&this.setCustomDateField(),this.dialogRef.close({deliveryEntityID:this.deliveryEntityID(),fulfillmentDate:this.fulfillmentDate(),fulfillmentTime:this.fulfillmentTime(),fulfillmentDateTime:this.fulfillmentDateTime()})}close(){this.dialogRef.close()}setCustomDateField(){let t=this.fulfillmentDate()?this.fulfillmentDate():new Date,e=this.fulfillmentTime(),i;e?typeof e=="string"?i=e:i=this.datePipe.transform(e,"HH:mm")??"00:00":i="00:00";let o=this.datePipe.transform(t,"d MMM y");this.fulfillmentDateTime.set(`${o} ${i}`)}onChangeTab(t){this.tabState.set(t),t=="Now"?(this.fulfillmentDate.set(null),this.deliveryEntityID.set(I.IsNotEmpty(this.data.deliveryEntityID)?this.data.deliveryEntityID:this.data.outletID??I.GuidEmpty)):(this.deliveryEntityID.set(I.GuidEmpty),this.fulfillmentDate.set(new Date))}static \u0275fac=function(e){return new(e||n)(g(Oe),g(rn),g(ke))};static \u0275cmp=V({type:n,selectors:[["POS-modal-fulfillment"]],decls:23,vars:12,consts:[[3,"onOk","onCancel","onClose","config"],[1,"container"],[1,"row"],[1,"btn-group","col-12"],["type","button",1,"btn","btn-secondary","position-relative","btn-custom-size","col-5",3,"click"],[1,"fa-solid","fa-bolt"],[1,"ms-2"],[1,"ms-1"],["type","button",1,"btn","position-relative","btn-custom-size","col-7",3,"click"],[1,"fa-solid","fa-clock"],[1,"row","mt-12"],[1,"col-12"],[1,"d-flex","align-items-center","gap-3"],[1,"mb-2"],[1,"fa","fa-store","me-1"],["optionLabel","Name","optionValue","ID","filterBy","Name","placeholder","Select an Outlet","appendTo","body","data-cy","DeductInventory",1,"w-100",2,"--p-select-padding-y","0.8rem",3,"ngModelChange","options","ngModel","filter","showClear","disabled"],[1,"w-100"],["for","shippingDate",1,"mb-2"],[1,"fa-solid","fa-calendar","me-1"],["placeholder","Select Date","showIcon","","iconDisplay","input","appendTo","body","dateFormat","dd M yy",1,"w-100","date-custom",3,"ngModelChange","ngModel","baseZIndex","showClear"],["for","shippingTime",1,"mb-2"],[1,"fa","fa-clock","me-1"],["placeholder","Select Time",1,"date-custom",3,"timeChange","time","showIcon","showCloseBtn","fullWidth","showClear"]],template:function(e,i){e&1&&(a(0,"modal-material",0),D("onOk",function(){return i.onOk()})("onCancel",function(){return i.close()})("onClose",function(){return i.close()}),a(1,"content")(2,"div",1)(3,"div",2)(4,"div",3)(5,"button",4),D("click",function(){return i.onChangeTab("Now")}),x(6,"i",5),a(7,"span",6),m(8," Now "),a(9,"small",7)(10,"em"),m(11,"(in store purchase)"),r()()()(),a(12,"button",8),D("click",function(){return i.onChangeTab("Later")}),x(13,"i",9),a(14,"span",6),m(15," Later "),a(16,"small",7)(17,"em"),m(18,"(shipped to customer address)"),r()()()()()(),a(19,"div",10)(20,"div",11),v(21,ha,6,5,"div")(22,va,15,9,"div",12),r()()()()()),e&2&&(y("config",i.config),l(5),At(lt(6,ya,i.tabStateValue=="Now",i.tabStateValue!="Now")),l(7),At(lt(9,ba,i.tabStateValue=="Now",i.tabStateValue=="Later")),l(9),_(i.tabStateValue=="Now"?21:22))},dependencies:[te,Pe,hn,Fe,de,Ee,Nn,wn,An,Fn,En],styles:[".container[_ngcontent-%COMP%]{min-height:150px} .p-datepicker.p-component.p-datepicker-timeonly{z-index:99999!important}.tabDesc[_ngcontent-%COMP%]{font-size:80%;font-weight:400} mat-button-toggle-group.fulfillment-tab mat-pseudo-checkbox{display:none} p-datepicker.date-custom>span>input{padding-top:10px;padding-bottom:10px} app-timepicker.date-custom p-datepicker>span>input{padding-top:10px;padding-bottom:10px}.custom-checkbox-style[_ngcontent-%COMP%]{--p-checkbox-checked-background: #89b03e;--p-checkbox-hover-border-color: #89b03e;--p-checkbox-checked-border-color: #89b03e;--p-checkbox-checked-hover-border-color: #89b03e;--p-checkbox-hover-border-color-background: #7c9b44;--p-checkbox-checked-hover-background: #89b03e}.custom-input-size[_ngcontent-%COMP%]{height:2.625rem;padding:.75rem!important;color:#343434;font-size:.75rem;border-radius:.25rem!important}.btn-custom-size[_ngcontent-%COMP%]{--bs-btn-padding-y: 1rem;--bs-btn-padding-x: 1rem;--bs-btn-font-size: 3.5rem;font-family:Roboto Slab,serif}.btn-custom-size[_ngcontent-%COMP%]:hover{background-color:var(--bs-light)!important;border-color:var(--bs-light)!important;color:#000!important}.container[_ngcontent-%COMP%]{padding-left:.75rem;padding-right:.75rem}"],changeDetection:0})};var Mi=class n{constructor(t){this.matDialog=t}role=G(Ce);outlets=N([]);outletID=N("");appConfigJSON=N(void 0);isEdit=N(!1);fulfillmentResult={};get deliveryEntityID(){return this.fulfillmentResult.deliveryEntityID}disabled=!1;onChange=t=>{};onTouched=()=>{};writeValue(t){t!=null&&(this.fulfillmentResult=t)}registerOnChange(t){this.onChange=t}registerOnTouched(t){this.onTouched=t}setDisabledState(t){this.disabled=t}openModalFulfillment(){return oe(this,null,function*(){this.matDialog.open(Si,{data:{deliveryEntityID:this.deliveryEntityID,outlets:this.outlets(),outletID:this.outletID(),appConfigJSON:this.appConfigJSON(),isEdit:this.isEdit(),fulfillmentDate:this.fulfillmentResult.fulfillmentDate,fulfillmentTime:this.fulfillmentResult.fulfillmentTime,fulfillmentDateTime:this.fulfillmentResult.fulfillmentDateTime}}).afterClosed().pipe(A(t=>!!t)).subscribe(t=>{this.fulfillmentResult=t,this.onChange(t)})})}isDeliveryEntityIDEmpty(){return I.IsEmpty(this.deliveryEntityID)&&I.IsNotEmpty(this.outletID())}static \u0275fac=function(e){return new(e||n)(g(ie))};static \u0275cmp=V({type:n,selectors:[["POS-fulfillment-form"]],inputs:{outlets:[1,"outlets"],outletID:[1,"outletID"],appConfigJSON:[1,"appConfigJSON"],isEdit:[1,"isEdit"]},features:[je([{provide:Ze,multi:!0,useExisting:n}])],decls:5,vars:4,consts:[[3,"matTooltip"],["type","button",1,"btn","btn-gray","w-100","h-100","fs-3","px-0","py-6","headings-font-family",3,"click","disabled"],[1,"fa-solid","fa-dolly","me-3"]],template:function(e,i){e&1&&(a(0,"span",0)(1,"button",1),D("click",function(){return i.openModalFulfillment()}),x(2,"i",2),a(3,"span"),m(4,"Fulfillment"),r()()()),e&2&&(y("matTooltip",i.role.buyRestriction!=null&&i.role.buyRestriction.ShippingRestriction?"Fulfillment option is restricted by role!":""),l(),Pt("bg-gradient-warning",i.isDeliveryEntityIDEmpty()),y("disabled",i.role.buyRestriction==null?null:i.role.buyRestriction.ShippingRestriction))},dependencies:[nt,it],styles:[".btn-gray[_ngcontent-%COMP%]{border:1px solid #d6d6d6;color:#545454!important;background:linear-gradient(to bottom,#fff,#eee)}"],changeDetection:0})};var oo=n=>({selected:n}),_a=n=>({active:n});function Da(n,t){if(n&1){let e=U();a(0,"a",4),D("click",function(){O(e);let o=d();return T(o.isPayNow=!1)}),m(1," Later "),a(2,"span",7),m(3,"Take Credit"),r()()}if(n&2){let e=d();y("ngClass",le(1,oo,!e.isPayNow))}}function xa(n,t){if(n&1){let e=U();a(0,"div",16)(1,"a",17),D("click",function(){let o=O(e).$implicit,s=d(4);return T(s.inputAmount=o)}),m(2),u(3,"number"),r()()}if(n&2){let e=t.$implicit,i=d(4);l(),y("ngClass",le(5,_a,i.paymentMethodID==i.cashPaymentID&&i.inputAmount==e)),l(),$e("",i.currencySymbol," ",C(3,3,e))}}function Sa(n,t){if(n&1&&(a(0,"div",14),we(1,xa,4,7,"div",16,Be),r()),n&2){let e=d(3);l(),Ne(e.suggestedCash)}}function Ma(n,t){if(n&1&&(a(0,"div",19),m(1),u(2,"number"),r()),n&2){let e=d(4);y("ngClass",e.inputAmount>e.amountToPay?"success":"danger"),l(),$e(" ",e.currencySymbol," ",C(2,3,e.inputAmount-e.amountToPay)," ")}}function Ia(n,t){if(n&1){let e=U();a(0,"input",18),J("ngModelChange",function(o){O(e);let s=d(3);return Q(s.inputAmount,o)||(s.inputAmount=o),T(o)}),D("click",function(){O(e);let o=d(3);return o.paymentMethodID=o.cashPaymentID,o.paymentMethodState="Cash",T(o.paymentMethodName="Cash")}),r(),v(1,Ma,3,5,"div",19)}if(n&2){let e=d(3);W("ngModel",e.inputAmount),l(),_(e.inputAmount!=e.amountToPay?1:-1)}}function Pa(n,t){if(n&1){let e=U();a(0,"div",20),D("click",function(){O(e);let o=d(3);return o.paymentMethodID=o.cashPaymentID,T(o.paymentMethodState="Cash")}),x(1,"input",21),r()}if(n&2){let e=d(3);l(),y("value",e.currencySymbol+" -")}}function Oa(n,t){if(n&1&&(a(0,"div",8)(1,"div",10),x(2,"i",11),m(3," Cash "),r(),a(4,"div",12)(5,"div",13),v(6,Sa,3,0,"div",14),a(7,"div",15),v(8,Ia,2,2)(9,Pa,2,1,"div"),r()()()()),n&2){let e=d(2);l(6),_(e.role.product.Cost?6:-1),l(2),_(e.role.product.Cost?8:9)}}function Ta(n,t){if(n&1){let e=U();a(0,"div",23)(1,"a",25),D("click",function(){let o=O(e).$implicit,s=d(3);return T(s.onSelectPaymentMethod(o.ID,"Card",o.Name))}),a(2,"span",26),x(3,"img",27),r(),a(4,"span",26),m(5),u(6,"limitText"),r()()()}if(n&2){let e=t.$implicit,i=d(3);l(),y("ngClass",i.paymentMethodID===e.ID?"active":""),l(),y("hidden",e.ImageUrl==null),l(),y("src",e.ImageUrl,dt),l(),y("hidden",e.ImageUrl!=null),l(),E(" ",pt(6,5,e.Name,20)," ")}}function wa(n,t){if(n&1){let e=U();a(0,"div",24)(1,"div",28)(2,"input",29),J("ngModelChange",function(o){O(e);let s=d(3);return Q(s.paymentNote,o)||(s.paymentNote=o),T(o)}),r(),a(3,"input",30),J("ngModelChange",function(o){O(e);let s=d(3);return Q(s.paymentCode,o)||(s.paymentCode=o),T(o)}),r()()()}if(n&2){let e=d(3);l(2),W("ngModel",e.paymentNote),l(),W("ngModel",e.paymentCode)}}function Na(n,t){if(n&1&&(a(0,"div",8)(1,"div",10),x(2,"i",22),m(3," Card "),r(),a(4,"div",12)(5,"div",13),we(6,Ta,7,8,"div",23,Be),r(),v(8,wa,4,2,"div",24),r()()),n&2){let e=d(2);l(6),Ne(e.cardPayments),l(2),_(e.paymentMethodState=="Card"?8:-1)}}function Ea(n,t){if(n&1){let e=U();a(0,"div",23)(1,"a",25),D("click",function(){let o=O(e).$implicit,s=d(3);return T(s.onSelectPaymentMethod(o.ID,"Other",o.Name))}),m(2),u(3,"limitText"),r()()}if(n&2){let e=t.$implicit,i=d(3);l(),y("ngClass",i.paymentMethodID===e.ID?"active":""),l(),E(" ",pt(3,2,e.Name,20)," ")}}function Fa(n,t){if(n&1){let e=U();a(0,"div",24)(1,"div",28)(2,"input",29),J("ngModelChange",function(o){O(e);let s=d(3);return Q(s.paymentNote,o)||(s.paymentNote=o),T(o)}),r(),a(3,"input",30),J("ngModelChange",function(o){O(e);let s=d(3);return Q(s.paymentCode,o)||(s.paymentCode=o),T(o)}),r()()()}if(n&2){let e=d(3);l(2),W("ngModel",e.paymentNote),l(),W("ngModel",e.paymentCode)}}function ka(n,t){if(n&1&&(a(0,"div",9)(1,"div",10),m(2,"Others"),r(),a(3,"div",12)(4,"div",13),we(5,Ea,4,5,"div",23,Be),r(),v(7,Fa,4,2,"div",24),r()()),n&2){let e=d(2);l(5),Ne(e.otherPayments),l(2),_(e.paymentMethodState=="Other"?7:-1)}}function Aa(n,t){if(n&1&&(a(0,"div"),v(1,Oa,10,2,"div",8),v(2,Na,9,1,"div",8),v(3,ka,8,1,"div",9),r()),n&2){let e=d();l(),_(e.isCashSuspended?1:-1),l(),_(e.cardPayments.length>0?2:-1),l(),_(e.otherPayments.length>0?3:-1)}}function Va(n,t){if(n&1){let e=U();a(0,"div",6)(1,"div",31)(2,"h5",32),m(3,"Due"),r(),a(4,"datepicker",33),J("dateChange",function(o){O(e);let s=d();return Q(s.dueDate,o)||(s.dueDate=o),T(o)}),D("dateChange",function(){O(e);let o=d();return T(o.onChangeDueDate())}),r()(),a(5,"div",34)(6,"h5",32),m(7,"Days Due"),r(),a(8,"div",12)(9,"input",35),J("ngModelChange",function(o){O(e);let s=d();return Q(s.dueDays,o)||(s.dueDays=o),T(o)}),D("ngModelChange",function(){O(e);let o=d();return T(o.onChangeDueDay())}),r()()()()}if(n&2){let e=d();l(4),y("displayToggle",!1),W("date",e.dueDate),l(5),W("ngModel",e.dueDays)}}var Ii=class n{constructor(t,e,i){this.dialogRef=t;this.role=i;this.isDefaultTabPayLater=e.payDefaultState==!1,this.config=new Ie,this.config.title="Amount to Pay:",this.config.customWidth="650px",this.amountToPay=e.displayedAmountToPay,this.inputAmount=this.amountToPay,this.currencySymbol=e.currencySymbol,this.dueDate=e.dueDate,this.invoiceDate=e.invoiceDate,this.cashPaymentID=e.cashPaymentMethodID,this.cardPayments=e.cardPayments,this.otherPayments=e.otherPayments,this.paymentMethodID=e.paymentMethodID;let o=this.cardPayments.find(F=>F.ID==this.paymentMethodID);I.IsNotEmpty(o)&&(this.paymentMethodState="Card",this.paymentMethodName=o.Name);let s=this.otherPayments.find(F=>F.ID==this.paymentMethodID);I.IsNotEmpty(s)&&(this.paymentMethodState="Other",this.paymentMethodName=s.Name),this.paymentNote=e.paymentNote,this.paymentCode=e.paymentCode,this.isPayNow=e.payDefaultState,e.isEdit&&(this.isPayNow=!e.isUnpaidOnEdit),this.onChangeDueDate(),this.dueDays=e.dueDays,this.isCashSuspended=e.isCashSuspended,this.denomination=e.denomination,this.suggestedCash[0]=this.inputAmount,this.denomination.filter(F=>F>this.inputAmount).forEach(F=>{this.suggestedCash.length<3&&this.suggestedCash.push(F)}),console.log(this.suggestedCash)}config;isPayNow=!0;paymentMethodName="Cash";amountToPay=0;inputAmount=0;currencySymbol="";dueDate;dueDays;invoiceDate;cardPayments;otherPayments;cashPaymentID;paymentMethodID;paymentMethodState="Cash";paymentNote;paymentCode;displayedAmountToPay;denomination;suggestedCash=[];isCashSuspended;isDefaultTabPayLater=!1;ok(){let t={};this.isPayNow?(t.amount=this.inputAmount,t.paymentMethodID=this.paymentMethodID,t.paymentNote=this.paymentNote,t.paymentCode=this.paymentCode,t.payState="Now",t.paymentMethodName=this.paymentMethodName):(t.dueDate=this.dueDate,t.payState="Later"),this.dialogRef.close(t)}close(){this.dialogRef.close()}onSelectPaymentMethod(t,e,i){this.paymentMethodName=i,this.paymentMethodID==t?(this.paymentMethodID=this.cashPaymentID,this.paymentMethodState="Cash"):(this.paymentMethodID=t,this.paymentMethodState=e)}onChangeDueDay(){let t=new Date(I.cloneObject(this.invoiceDate));t.setDate(t.getDate()+this.dueDays),t.setHours(0,0,0,0),this.dueDate=t}onChangeDueDate(){this.dueDays=I.differentInDays(typeof this.invoiceDate=="string"?new Date(this.invoiceDate):this.invoiceDate,typeof this.dueDate=="string"?new Date(this.dueDate):this.dueDate)+1}static \u0275fac=function(e){return new(e||n)(g(Oe),g(ke),g(Ce))};static \u0275cmp=V({type:n,selectors:[["POS-modal-pay"]],decls:14,vars:10,consts:[[3,"onOk","onCancel","onClose","config"],[1,"mt-1","ms-2"],[1,"container","w-100","h-100"],[1,"row","border-bottom"],[1,"btn","btn-link",3,"click","ngClass"],[1,"btn","btn-link",3,"ngClass"],[1,"py-4"],[1,"fst-italic",2,"font-size","10px"],[1,"row","border-bottom","py-5"],[1,"row","py-5"],[1,"col-3","h5","pt-5"],[1,"fa-solid","fa-money-bill-wave"],[1,"col-9"],[1,"row"],[1,"row","mb-5"],[1,"col","pe-0","me-10","position-relative"],[1,"col-4","pe-0","ps-4"],[1,"btn","btn-outline-info","px-1","py-6","w-100",3,"click","ngClass"],["id","cashInput","type","text","placeholder","Custom Cash Amount","autoNum","",1,"form-control","form-control-lg","py-3","mb-3","px-6",3,"ngModelChange","click","ngModel"],[1,"change",3,"ngClass"],[3,"click"],["id","cashInput","type","text","placeholder","Custom Cash Amount","disabled","",1,"form-control","form-control-lg","py-3","mb-3","px-6",3,"value"],[1,"fa-regular","fa-credit-card"],[1,"col-auto","pe-0"],[1,"position-relative","row"],[1,"btn","btn-outline-info","mb-3","px-6",3,"click","ngClass"],[3,"hidden"],[2,"width","40px",3,"src"],[1,"paymentNote","col","row","g-0","pt-2","ms-6"],["type","text","placeholder","Payment Note",1,"form-control","w-50","border-end-0","py-6","col-6",3,"ngModelChange","ngModel"],["type","text","placeholder","Payment Code",1,"form-control","w-50","border-start-0","py-6","paymentCode","col-6",3,"ngModelChange","ngModel"],[1,"row","d-flex","align-items-center","g-0","later-payment"],[1,"col-3","fw-normal"],["appearance","fill","readOnly","true","name","orderDate",1,"col-9",3,"dateChange","displayToggle","date"],[1,"row","d-flex","align-items-center","g-0","later-payment","mt-10"],["type","text","autofocus","","autoNum","",1,"py-8","ps-8","form-control",3,"ngModelChange","ngModel"]],template:function(e,i){e&1&&(a(0,"modal-material",0),D("onOk",function(){return i.ok()})("onCancel",function(){return i.close()})("onClose",function(){return i.close()}),a(1,"header")(2,"div",1),m(3),u(4,"number"),r()(),a(5,"content")(6,"div",2)(7,"div",3)(8,"div")(9,"a",4),D("click",function(){return i.isPayNow=!0}),m(10," Now "),r(),v(11,Da,4,3,"a",5),r()()(),v(12,Aa,4,3,"div"),v(13,Va,10,3,"div",6),r()()),e&2&&(y("config",i.config),l(3),E(" ",i.currencySymbol+" "+C(4,6,i.amountToPay)," "),l(6),y("ngClass",le(8,oo,i.isPayNow)),l(2),_(i.amountToPay!=0||i.isDefaultTabPayLater?11:-1),l(),_(i.isPayNow?12:-1),l(),_(i.isPayNow?-1:13))},dependencies:[te,Xe,Fe,Me,de,Ee,kn,Pe,ft,ye,Kt],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}.change[_ngcontent-%COMP%]{position:absolute;top:0;height:40px;background:#89b03e;color:#fff;right:0;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:90%;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)}.btn-link[_ngcontent-%COMP%]{padding-top:0;color:#868686;padding-bottom:8px;border-radius:unset;font-family:Roboto Slab,serif}.btn-link.selected[_ngcontent-%COMP%]{color:#3b3b3b;border-bottom:4px solid #07a519} .later-payment.date-picker .mat-mdc-form-field{font-size:4px}.ng-select.ng-select-width[_ngcontent-%COMP%] .ng-select-container{width:160px;max-width:160px}input[type=text][_ngcontent-%COMP%]:disabled{background:#dadada}.later-payment[_ngcontent-%COMP%] strong{font-size:20px}.later-payment[_ngcontent-%COMP%] input{font-size:20px}.later-payment[_ngcontent-%COMP%] .mat-mdc-form-field{width:100%;font-size:20px;border:1px solid #c8d3df}.later-payment[_ngcontent-%COMP%] .mat-mdc-form-field .mat-mdc-icon-button, .later-payment[_ngcontent-%COMP%] .mat-mdc-form-field .mat-mdc-button-persistent-ripple, .later-payment[_ngcontent-%COMP%] .mat-mdc-form-field .mat-mdc-form-field-icon-suffix{outline:none!important}']})};function Ra(n,t){if(n&1&&(a(0,"tr")(1,"td")(2,"a",7),m(3),r()(),a(4,"td"),m(5),u(6,"number"),r(),a(7,"td",6),m(8),u(9,"number"),r()()),n&2){let e=t.$implicit;l(3),ee(e.Name),l(2),ee(C(6,3,e.UnitPrice)),l(3),E(" ",C(9,5,e.MaxOrderPrice)," ")}}var Pi=class n{config=new Ie;data=G(ke);hasExceededMaxPrice=se(!1);dialogRef=G(Oe);constructor(){this.config.title="Cost Maximum Warning",this.config.customWidth="400px",this.config.bodyScrollable=!0,this.config.hideCancel=!0,this.config.okText="Close",this.config.headerType=be.Warning,this.hasExceededMaxPrice.set(this.data.some(t=>t.MaxOrderPrice>0&&t.UnitPrice>t.MaxOrderPrice))}close(){this.dialogRef.close()}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=V({type:n,selectors:[["POS-modal-exceeded-cost"]],decls:17,vars:1,consts:[[3,"onOk","onClose","config"],[1,"container-fluid"],[1,"row"],[1,"col-12"],["id","tableGrid",1,"table","table-bordered"],[1,"thead-light"],[1,"text-end"],["target","_blank"]],template:function(e,i){e&1&&(a(0,"modal-material",0),D("onOk",function(){return i.close()})("onClose",function(){return i.close()}),a(1,"content")(2,"div",1)(3,"div",2)(4,"div",3)(5,"table",4)(6,"thead",5)(7,"tr")(8,"th"),m(9,"Name"),r(),a(10,"th"),m(11,"Cost"),r(),a(12,"th",6),m(13,"Max"),r()()(),a(14,"tbody"),we(15,Ra,10,7,"tr",null,tn),r()()()()()()()),e&2&&(y("config",i.config),l(15),Ne(i.data))},dependencies:[Pe,te,ye],encapsulation:2})};function Ba(n,t){if(n&1&&(vt(0,"div"),m(1),u(2,"number"),_t()),n&2){let e=d();l(),E(" ",C(2,1,e.amountToPayRounded)," ")}}function $a(n,t){n&1&&m(0," - ")}var Oi=class n{constructor(t,e,i,o,s,F,f,w,H,M,j){this.matDialog=t;this.toastr=e;this.form=i;this.cart=o;this.http=s;this.complete=F;this.role=f;this.load=w;this.posMath=H;this.math=M;this.paymentService=j}cartLength=N(0);amountToPay=N(0);currencySymbol=N("");dueDate=N(null);cashPayments=N([]);cardPayments=N([]);otherPayments=N([]);paymentMethodID=N(0);paymentNote=N("");paymentCode=N("");defaultDueDays=N(null);invoiceDate=N(null);dueDays=N(0);appConfigJSON=N(void 0);isUnpaidOnEdit=N(!1);isEditBuyForm=N(!1);totalVariantOrdered=N(0);isCashSuspended=N(!1);denomination=N([]);isReturn=N(!1);pay(){return oe(this,null,function*(){if(this.cartLength()==0){this.toastr.info("You must have at least one item",be.Info);return}if(this.form.discountAndTaxForm.value.Tax.Discontinue){this.toastr.info(`Cannot find the ${this.form.discountAndTaxForm.value.Tax.Label}, Set the tax discontinue status to \u201CNo\u201D to use tax or choose another tax type`,be.Info);return}let t=I.IsEmpty(this.form.buyForm.controls.Order.controls.SupplierID.value);if(this.appConfigJSON()?.ModuleBuy.Header.SupplierRequired&&t){this.toastr.info("Supplier is required",be.Info);return}let e=yield Qi(this.cart.cart$);if(e.some(f=>{let w=f.MaxOrderPrice;return w>0&&f.UnitPrice>w})&&this.role.buyRestriction?.CostMax){this.matDialog.open(Pi,{data:e});return}this.matDialog.open(Ii,{data:{displayedAmountToPay:this.posMath.Round(this.amountToPay(),this.appConfigJSON()?.ApplicationMath.RoundingPurchaseDigit?.DecimalPlaceValue,this.appConfigJSON()?.ApplicationMath.RoundingPurchaseDigit?.RoundAlgorithm),amountToPay:this.posMath.Round(this.form.buyForm.controls.Payment.controls.Amount.value,this.appConfigJSON()?.ApplicationMath.RoundingPurchaseDigit?.DecimalPlaceValue,this.appConfigJSON()?.ApplicationMath.RoundingPurchaseDigit?.RoundAlgorithm),currencySymbol:this.currencySymbol(),dueDate:I.cloneObject(this.dueDate()),dueDays:I.cloneObject(this.dueDays()),cardPayments:this.cardPayments(),otherPayments:this.otherPayments(),cashPaymentMethodID:this.cashPayments()[0]?.ID,paymentMethodID:this.paymentMethodID(),paymentNote:this.paymentNote(),paymentCode:this.paymentCode(),invoiceDate:this.invoiceDate(),payDefaultState:this.appConfigJSON()?.ModuleBuy?.PaymentDialog?.DefaultOption!=1,isUnpaidOnEdit:this.isUnpaidOnEdit(),isEdit:this.isEditBuyForm(),isCashSuspended:this.isCashSuspended(),denomination:this.denomination()}}).afterClosed().pipe(A(f=>!!f),p(f=>f)).pipe(k(f=>this.paymentService.paymentMethodName.set(f.paymentMethodName)),fe(this.cart.cart$),p(([f,w])=>B(P({},f),{cart:w})),fe(this.load.entities$),p(([f,w])=>B(P({},f),{entities:w})),fe(this.load.supplierPOTypes$),p(([f,w])=>B(P({},f),{supplierPOTypes:w})),Y(f=>{I.IsEmpty(this.form.noteForm.value.TagID)&&this.form.setBulkNoteForm(B(P({},this.form.noteForm.value),{TagID:f.supplierPOTypes[0]?.ID}));let w=this.form.buyForm.controls,H=w.Invoice.controls,M=w.Payment.controls,j=this.form.outlet.value,c=w.Order.controls,S=this.form.noteForm.value,L=this.form.discountAndTaxForm.value,ne=M.Amount.value,h=w.NewOrderID?.value,{deliveryEntityID:b,fulfillmentDateTime:R}=this.form.fulfillmentResult.value,$={ID:H.ID.value,Due:f.payState=="Now"?void 0:H.Due.value,Tax:H.Tax.value,Sales:ne??0,PaymentStateID:f.payState=="Now"?3:1,Number:S.InvoiceNumber?S.InvoiceNumber:c.Number.value},Te=f.cart.map(_e=>B(P({},_e),{VariantID:I.IsEmpty(_e.VariantID)?_e.ID:_e.VariantID}));this.isEditBuyForm()&&(Te=Te.map(_e=>B(P({},_e),{QtyRequested:_e.Quantity})));let Ve={EntityID:j.ID,SupplierID:c.SupplierID.value,Date:c.Date.value,CurrencyID:S.Currency.ID,CurrencyRate:S.Currency.ExchangeRate,Discount:L.Discount.Percentage,DiscountAmount:this.isReturn()?L.Discount.Amount*-1:L.Discount.Amount,Note:S.Note,Att:c.Att.value,TaxTypeID:L.Tax.ID,TypeID:S.TagID,Number:c.Number.value,ID:c.ID.value};if(f.payState=="Now"){let _e={ID:M.ID?.value??I.GuidEmpty,MethodID:f.paymentMethodID,Code:f.paymentCode??"",Note:f.paymentNote??"",Amount:this.posMath.Round(f.amount,this.appConfigJSON()?.ApplicationMath.RoundingPurchaseDigit.DecimalPlaceValue,this.appConfigJSON()?.ApplicationMath.RoundingPurchaseDigit.RoundAlgorithm),Date:Ve.Date,ImageUrl:M.ImageUrl?.value};f.amount<ne?$.PaymentStateID=2:f.amount>ne&&($.PaymentStateID=5);let re={DeliveryEntityID:b,NewOrderID:this.isEditBuyForm?null:h,Invoice:B(P({},$),{CustomDateField:R}),Order:Ve,Items:Te,Payment:_e};return this.http.post("/API/Buy/SubmitOrder2",re,1e4,!0).pipe(p(ct=>B(P({},ct),{differentNumber:ct.InvoiceNumber!=Ve.Number})),ve(ct=>{throw ct.error&&this.toastr.error(ct.error.Message,"Order Submission Failed"),new Error(ct)}))}else{let _e={DeliveryEntityID:b,NewOrderID:this.isEditBuyForm?null:I.Guid_NewGuid(),Invoice:B(P({},$),{Due:f.dueDate,CustomDateField:R}),Order:Ve,Items:Te};return this.http.post("/API/Buy/SubmitOrder2",_e,1e4,!0).pipe(p(re=>B(P({},re),{differentNumber:re.InvoiceNumber!=Ve.Number})),ve(re=>{throw re.error&&this.toastr.error(re.error.Message,"Order Submission Failed"),new Error(re)}))}})).subscribe(f=>{this.complete.paymentComplete(f),f.differentNumber&&this.toastr.info(`Bill number has been changed to ${f.InvoiceNumber}`,"Bill Number Changed!")})})}get amountToPayRounded(){return this.posMath.Round(this.amountToPay(),this.appConfigJSON()?.ApplicationMath?.RoundingPurchaseDigit?.DecimalPlaceValue,this.appConfigJSON()?.ApplicationMath?.RoundingPurchaseDigit?.RoundAlgorithm)}static \u0275fac=function(e){return new(e||n)(g(ie),g(Le),g(z),g(Z),g(pe),g(He),g(Ce),g(ue),g(Ai),g(Ai),g(qe))};static \u0275cmp=V({type:n,selectors:[["POS-pay-button"]],inputs:{cartLength:[1,"cartLength"],amountToPay:[1,"amountToPay"],currencySymbol:[1,"currencySymbol"],dueDate:[1,"dueDate"],cashPayments:[1,"cashPayments"],cardPayments:[1,"cardPayments"],otherPayments:[1,"otherPayments"],paymentMethodID:[1,"paymentMethodID"],paymentNote:[1,"paymentNote"],paymentCode:[1,"paymentCode"],defaultDueDays:[1,"defaultDueDays"],invoiceDate:[1,"invoiceDate"],dueDays:[1,"dueDays"],appConfigJSON:[1,"appConfigJSON"],isUnpaidOnEdit:[1,"isUnpaidOnEdit"],isEditBuyForm:[1,"isEditBuyForm"],totalVariantOrdered:[1,"totalVariantOrdered"],isCashSuspended:[1,"isCashSuspended"],denomination:[1,"denomination"],isReturn:[1,"isReturn"]},decls:11,vars:7,consts:[["type","button",1,"btn","btn-success","fs-1","py-4",2,"border-left","0.1px solid #fff",3,"click"],[1,"d-flex","align-items-center","justify-content-between"],[1,"fs-6"]],template:function(e,i){e&1&&(vt(0,"button",0),Ut("click",function(){return i.pay()}),vt(1,"div",1)(2,"div")(3,"span"),m(4,"Pay"),_t(),vt(5,"small",2),m(6),u(7,"number"),u(8,"quantityFraction"),_t()(),v(9,Ba,3,3,"div")(10,$a,1,0),_t()()),e&2&&(l(6),$e(" (",C(7,3,i.cartLength())," Items & ",C(8,5,i.totalVariantOrdered())," Qty) "),l(3),_(i.role.product.Cost?9:10))},dependencies:[te,ye,Xt],styles:["button[_ngcontent-%COMP%]{border-right:.1px solid #fff;margin-left:-1px;border-top-left-radius:0;border-bottom-left-radius:0;position:relative;flex:1 1 auto}"],changeDetection:0})};var Nt=class n{noteForm;constructor(t){this.noteForm=t.noteForm}static \u0275fac=function(e){return new(e||n)(q(z))};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};var Et=class n{dueDate$;dueDays$;constructor(t){let e=t.buyForm.controls.Invoice.controls.Due.valueChanges;this.dueDays$=t.dueDays.valueChanges,t.buyForm.controls.Order.controls.Date.valueChanges.pipe(k(console.log),fe(this.dueDays$),k(([s,F])=>t.setDueDateBasedOnDaysDue(F)),k(console.log)).subscribe(),this.dueDate$=e,this.dueDate$.subscribe(s=>console.log(s,"dueDate$"))}static \u0275fac=function(e){return new(e||n)(q(z))};static \u0275prov=me({token:n,factory:n.\u0275fac,providedIn:"root"})};function Ua(n,t){if(n&1&&(a(0,"tr")(1,"th",11),m(2,"Amount"),r(),a(3,"td",12),m(4),u(5,"number"),r()()),n&2){let e=d();l(4),ee(C(5,1,e.displayedAmount))}}function Qa(n,t){if(n&1&&(a(0,"td",13),m(1),u(2,"number"),r()),n&2){let e=d(3);l(),E(" ",C(2,1,e.displayedDiscountPercentage.value*-1)," ")}}function Wa(n,t){if(n&1&&(a(0,"tr")(1,"th",11),m(2),r(),v(3,Qa,3,3,"td",13),r()),n&2){let e=d(2),i=d();l(2),E(" ",e.displayedDiscountPercentage.label," "),l(),_(i.role.product.Cost?3:-1)}}function Ja(n,t){if(n&1&&(a(0,"td",13),m(1),u(2,"number"),r()),n&2){let e=d(3);l(),E(" ",C(2,1,e.displayedDiscountAmount.value)," ")}}function Ha(n,t){if(n&1&&(a(0,"tr")(1,"th",11),m(2),r(),v(3,Ja,3,3,"td",13),r()),n&2){let e=d(2),i=d();l(2),ee(e.displayedDiscountAmount.label),l(),_(i.role.product.Cost?3:-1)}}function Ga(n,t){if(n&1&&(a(0,"td",12),m(1),u(2,"number"),r()),n&2){let e=d(3);l(),E(" ",C(2,1,e.displayedTax.tax.value)," ")}}function qa(n,t){if(n&1&&(a(0,"tr")(1,"th",11),m(2),r(),v(3,Ga,3,3,"td",12),r()),n&2){let e=d(2),i=d();l(2),ee(e.displayedTax.label),l(),_(i.role.product.Cost?3:-1)}}function Ka(n,t){if(n&1&&(v(0,Wa,4,2,"tr"),v(1,Ha,4,2,"tr"),v(2,qa,4,2,"tr")),n&2){let e=d();_(e.displayedDiscountPercentage.value!=0?0:-1),l(),_(e.displayedDiscountAmount.value!=0?1:-1),l(),_(e.displayedTax.tax.value!=0?2:-1)}}function za(n,t){if(n&1&&(a(0,"div",0)(1,"div",9)(2,"table",10),v(3,Ua,6,3,"tr"),v(4,Ka,3,3),u(5,"async"),r()()()),n&2){let e=t,i=d();l(3),_(i.showAmountWhenDiscountOrTaxIsApplied(e)&&e.displayedAmount&&i.role.product.Cost?3:-1),l(),_(C(5,2,i.cartLength$)?4:-1)}}var Ti=class n{constructor(t,e,i,o,s,F,f,w){this.payment=t;this.form=i;this.role=F;this.taxes$=e.taxes$,this.defaultCurrencyID$=e.appConfigJSON$.pipe(p(S=>S.CoreDefaults.CurrencyID)),this.totalVariantOrdered$=this.cart.totalVariantOrdered$,this.cartLength$=this.cart.cart$.pipe(p(S=>S.length)),this.amountAfterDiscountAndTax$=t.amountAfterDiscountAndTax$,this.discountAndTaxForm=i.discountAndTaxForm;let H=t.displayedAmount$,M=t.displayedDiscountPercentage$,j=t.displayedDiscountAmount$,c=t.displayedTax$;this.displayedDiscountAndTax$=xe({displayedAmount:H,displayedDiscountPercentage:M,displayedDiscountAmount:j,displayedTax:c}),this.fulfillmentResult=i.fulfillmentResult,this.noteForm=o.noteForm,this.currencies$=e.currencies$,this.currencySymbol$=t.currencySymbol$,this.supplierPOTypes$=e.supplierPOTypes$,this.predefinedNotes$=e.predefinedNotes$,this.outlets$=e.entities$,this.cashPayments$=w.cashPayments$,this.cardPayments$=w.cardPayments$,this.otherPayments$=w.otherPayments$,this.defaultDueDays$=e.defaultDueDays$,this.dueDate$=s.dueDate$,this.dueDays$=s.dueDays$,this.appConfigJSON$=e.appConfigJSON$,this.isUnpaidOnEdit$=xe(f.isEdit$,f.isUnpaid$).pipe(p(([S,L])=>S&&L)),this.isEdit$=f.isEdit$,this.outlet=i.outlet,this.isCashSuspended$=w.isCashSuspended$,this.denomination$=e.denomination$}cart=G(Z);taxes$;totalVariantOrdered$;displayedDiscountAndTax$;discountAndTaxForm;fulfillmentResult;noteForm;amountAfterDiscountAndTax$;currencies$;currencySymbol$;supplierPOTypes$;predefinedNotes$;defaultCurrencyID$;outlets$;cashPayments$;cardPayments$;otherPayments$;defaultDueDays$;dueDate$;dueDays$;appConfigJSON$;isUnpaidOnEdit$;isEdit$;isCashSuspended$;outlet;cartLength$;denomination$;isReturn=Jt(()=>this.cart.isReturn());get amountToPay(){return this.payment.amountToPay}get invoiceDate(){return this.form.invoiceDate}get paymentMethodID(){return this.payment.methodID}get paymentNote(){return this.payment.note}get paymentCode(){return this.payment.code}showAmountWhenDiscountOrTaxIsApplied(t){return t.displayedDiscountPercentage.value!=0||t.displayedDiscountAmount.value!=0||t.displayedTax.tax.value!=0}ngOnDestroy(){this.cart.isReturn.set(!1)}static \u0275fac=function(e){return new(e||n)(g(qe),g(ue),g(z),g(Nt),g(Et),g(Ce),g(Je),g(ot))};static \u0275cmp=V({type:n,selectors:[["POS-cart-footer"]],decls:34,vars:85,consts:[[1,"row","g-0","px-5","justify-content-end"],[1,"row","g-0","pb-6","px-5"],[1,"col-5","d-flex","justify-content-between","pe-5",2,"column-gap","12px"],[2,"flex-grow","1",3,"supplierPOTypes","predefinedNotes","defaultCurrencyID","currencies","formControl"],[2,"flex-grow","3",3,"outlets","formControl","appConfigJSON","outletID","isEdit"],[1,"col-7"],[1,"btn-group","w-100"],[2,"display","inline-flex",3,"taxes","currencySymbol","formControl","isReturn"],[1,"w-100",2,"display","inline-flex",3,"amountToPay","currencySymbol","dueDate","dueDays","cardPayments","otherPayments","paymentMethodID","paymentCode","paymentNote","defaultDueDays","invoiceDate","appConfigJSON","cashPayments","isUnpaidOnEdit","isEditBuyForm","cartLength","totalVariantOrdered","isCashSuspended","denomination","isReturn"],[1,"col-6",2,"padding-right","15px"],[1,"table","table-borderless"],[1,"text-start"],[1,"text-end","fs-5"],[1,"text-end","fs-5","text-danger"]],template:function(e,i){if(e&1&&(v(0,za,6,4,"div",0),u(1,"async"),a(2,"div",1)(3,"div",2),x(4,"POS-note-form",3),u(5,"async"),u(6,"async"),u(7,"async"),u(8,"async"),x(9,"POS-fulfillment-form",4),u(10,"async"),u(11,"async"),u(12,"async"),r(),a(13,"div",5)(14,"div",6),x(15,"POS-discount-and-tax-form",7),u(16,"async"),u(17,"async"),x(18,"POS-pay-button",8),u(19,"async"),u(20,"async"),u(21,"async"),u(22,"async"),u(23,"async"),u(24,"async"),u(25,"async"),u(26,"async"),u(27,"async"),u(28,"async"),u(29,"async"),u(30,"async"),u(31,"async"),u(32,"async"),u(33,"async"),r()()()),e&2){let o;_((o=C(1,35,i.displayedDiscountAndTax$))?0:-1,o),l(4),y("supplierPOTypes",C(5,37,i.supplierPOTypes$))("predefinedNotes",C(6,39,i.predefinedNotes$))("defaultCurrencyID",C(7,41,i.defaultCurrencyID$))("currencies",C(8,43,i.currencies$))("formControl",i.noteForm),l(5),y("outlets",C(10,45,i.outlets$))("formControl",i.fulfillmentResult)("appConfigJSON",C(11,47,i.appConfigJSON$))("outletID",i.outlet.value.ID)("isEdit",C(12,49,i.isEdit$)),l(6),y("taxes",C(16,51,i.taxes$))("currencySymbol",C(17,53,i.currencySymbol$))("formControl",i.discountAndTaxForm)("isReturn",i.isReturn()),l(3),y("amountToPay",C(19,55,i.amountAfterDiscountAndTax$))("currencySymbol",C(20,57,i.currencySymbol$))("dueDate",C(21,59,i.dueDate$))("dueDays",C(22,61,i.dueDays$))("cardPayments",C(23,63,i.cardPayments$))("otherPayments",C(24,65,i.otherPayments$))("paymentMethodID",i.paymentMethodID)("paymentCode",i.paymentCode)("paymentNote",i.paymentNote)("defaultDueDays",C(25,67,i.defaultDueDays$))("invoiceDate",i.invoiceDate)("appConfigJSON",C(26,69,i.appConfigJSON$))("cashPayments",C(27,71,i.cashPayments$))("isUnpaidOnEdit",C(28,73,i.isUnpaidOnEdit$))("isEditBuyForm",C(29,75,i.isEdit$))("cartLength",C(30,77,i.cartLength$))("totalVariantOrdered",C(31,79,i.totalVariantOrdered$))("isCashSuspended",C(32,81,i.isCashSuspended$))("denomination",C(33,83,i.denomination$))("isReturn",i.isReturn())}},dependencies:[te,_i,tt,de,et,xi,Mi,Oi,Se,ye],encapsulation:2,changeDetection:0})};var Ya=n=>({"date-warning":n}),Xa=()=>["/menu/Orders/Orders/Supplier_Bill/Info"],Za=n=>({ID:n});function er(n,t){if(n&1&&(m(0),u(1,"async"),u(2,"number")),n&2){let e=d().$implicit,i=d();$e(" ",C(1,2,i.currencySymbol$)," ",C(2,4,e.Total)," ")}}function tr(n,t){n&1&&m(0," - ")}function ir(n,t){if(n&1&&(a(0,"div",25)(1,"div",27),m(2),r(),a(3,"div",28),v(4,er,3,6)(5,tr,1,0),r()()),n&2){let e=t.$implicit,i=d();l(2),ee(e.Name),l(2),_(i.role.product.Cost?4:5)}}function nr(n,t){if(n&1&&(a(0,"tr")(1,"td",31),m(2),r(),a(3,"td",32),m(4),u(5,"async"),r(),a(6,"td",31),m(7),u(8,"number"),r()()),n&2){d();let e=Tt(0),i=d();l(2),ee(e.label),l(2),E(" ",C(5,3,i.currencySymbol$)," "),l(3),E(" ",C(8,5,e.value)," ")}}function or(n,t){if(n&1&&(a(0,"tr")(1,"td",31),m(2,"Discount:"),r(),a(3,"td",32),m(4),u(5,"async"),r(),a(6,"td",31),m(7),u(8,"number"),r()()),n&2){d();let e=Tt(2),i=d();l(4),E(" ",C(5,2,i.currencySymbol$)," "),l(3),E(" ",C(8,4,e.value)," ")}}function ar(n,t){if(n&1&&(a(0,"tr")(1,"td",31),m(2),r(),a(3,"td",32),m(4),u(5,"async"),r(),a(6,"td",31),m(7),u(8,"number"),r()()),n&2){d();let e=Tt(4),i=d();l(2),ee(e.label),l(2),E(" ",C(5,3,i.currencySymbol$)," "),l(3),E(" ",C(8,5,e==null||e.tax==null?null:e.tax.value)," ")}}function rr(n,t){if(n&1&&(a(0,"tr",33)(1,"td",31),m(2),r(),a(3,"td",32),m(4),u(5,"async"),r(),a(6,"td",31),m(7),u(8,"async"),u(9,"number"),r()()),n&2){let e=d(2);l(2),E(" ",e.payment.paymentMethodName(),": "),l(2),E(" ",C(5,3,e.currencySymbol$)," "),l(3),E(" ",C(9,7,C(8,5,e.displayedAmount$))," ")}}function lr(n,t){if(n&1&&(rt(0),u(1,"async"),rt(2),u(3,"async"),rt(4),u(5,"async"),a(6,"div",26)(7,"div",29)(8,"table",30)(9,"tbody")(10,"tr")(11,"td",31),m(12,"Amount:"),r(),a(13,"td",32),m(14),u(15,"async"),r(),a(16,"td",31),m(17),u(18,"async"),u(19,"number"),r()(),v(20,nr,9,7,"tr"),v(21,or,9,6,"tr"),v(22,ar,9,7,"tr"),v(23,rr,10,9,"tr",33),r()()()()),n&2){let e=d(),i=Ot(C(1,6,e.displayedDiscountPercentage$));l(2);let o=Ot(C(3,9,e.displayedDiscountAmount$));l(2);let s=Ot(C(5,12,e.displayedTax$));l(10),E(" ",C(15,15,e.currencySymbol$)," "),l(3),E(" ",C(19,19,C(18,17,e.displayedAmount$))," "),l(3),_(i.value>0?20:-1),l(),_(o.value>0?21:-1),l(),_((s==null||s.tax==null?null:s.tax.value)>0?22:-1),l(),_(e.payment.paymentMethodName()?23:-1)}}var wi=class n{constructor(t,e,i,o,s,F,f,w){this.payment=t;this.form=e;this.cart=i;this.complete=o;this.load=s;this.router=F;this.outletInfo=f;this.role=w;this.displayedAmount$=t.displayedAmount$,this.displayedDiscountPercentage$=t.displayedDiscountPercentage$,this.displayedDiscountAmount$=t.displayedDiscountAmount$,this.displayedTax$=t.displayedTax$}data=N(void 0,{alias:"paymentComplete"});displayedAmount$;displayedDiscountPercentage$;displayedDiscountAmount$;displayedTax$;currencySymbol$;createNewTransaction(){this.clearCart(),this.resetBuyForm(),this.updateDueDays(),this.updateTax(),this.updatePaymentMethodID(),this.complete.paymentComplete(null),this.complete.createNewTransaction(),this.router.navigate([],{queryParams:{ID:null}})}get amountToPay(){return this.payment.amountToPay}resetBuyForm(){this.form.resetNoteForm(),this.form.resetDiscountAndTaxForm(),this.form.resetDueDaysForm(),this.form.resetBuyForm(),this.form.resetFulfillmentDate()}clearCart(){this.cart.clearCart()}updateDueDays(){this.load.updateDueDays()}updateTax(){this.outletInfo.updateTax()}updatePaymentMethodID(){this.outletInfo.updatePaymentMethodID()}static \u0275fac=function(e){return new(e||n)(g(qe),g(z),g(Z),g(He),g(ue),g(Ht),g(ot),g(Ce))};static \u0275cmp=V({type:n,selectors:[["POS-complete"]],inputs:{data:[1,"paymentComplete","data"]},decls:38,vars:15,consts:[[1,"pt-7",2,"border-bottom","1px solid rgba(0, 0, 0, 0.1)"],[1,"ps-7","fw-normal","pb-7"],[1,"buy-complete"],[1,"container-fluid","pt-8"],[1,"row"],[1,"col-md-8"],[1,"card"],[1,"card-header"],[1,"d-flex","justify-content-between"],[1,"fa-solid","fa-check","me-1"],[1,"fst-italic"],[1,"card-body"],[1,"container"],[1,"row","mt-9","justify-content-center","g-0","mb-9"],[1,"col-9","text-center"],["type","button",1,"btn","btn-success","btn-lg","w-100","fs-2",3,"click"],[1,"card-footer","bg-light-gray"],[1,"row","justify-content-between","py-5"],[1,"col-auto"],["target","_blank",1,"btn","btn-light-gray",3,"href"],[1,"fa-solid","fa-print","me-2"],[1,"col-md-4"],[1,"card-header","bg-light-gray"],[1,"text-dark"],["target","_blank",1,"text-dark","fst-italic",3,"routerLink","queryParams"],[1,"row","my-1","p-5"],[1,"card-footer","pe-0","bg-white"],[1,"col-8"],[1,"col-4","text-end"],[1,"ms-auto"],[1,"table","table-borderless","mb-0","table-sm"],[1,"text-end"],[1,"text-start"],[2,"border-top","1px solid rgba(0, 0, 0, 0.1)"]],template:function(e,i){e&1&&(a(0,"div",0)(1,"h1",1),m(2,"New Purchase Order"),r()(),a(3,"section",2)(4,"div")(5,"div",3)(6,"div",4)(7,"div",5)(8,"div",6)(9,"div",7)(10,"div",8)(11,"h2"),x(12,"i",9),m(13," Purchase Complete "),a(14,"small",10),m(15),r()()()(),a(16,"div",11)(17,"div",12)(18,"div",13)(19,"div",14)(20,"button",15),D("click",function(){return i.createNewTransaction()}),m(21," New Purchase (F8) "),r()()()()(),a(22,"div",16)(23,"div",17)(24,"div",18)(25,"a",19),x(26,"i",20),m(27,"Print Receipt "),r()()()()()(),a(28,"div",21)(29,"div",6)(30,"div",22)(31,"h3",23)(32,"a",24),m(33),r()()(),we(34,ir,6,2,"div",25,Be),u(36,"async"),v(37,lr,24,21,"div",26),r()()()()()()),e&2&&(l(9),At(le(10,Ya,i.data().PaymentStateID<3)),l(6),E(" (",i.data().PaymentStateLabel,") "),l(10),y("href",i.data().Message,dt),l(7),y("routerLink",Qt(12,Xa))("queryParams",le(13,Za,i.data().InvoiceID)),l(),E(" Supplier Bill #",i.data().InvoiceNumber," "),l(),Ne(C(36,8,i.cart.cart$)),l(3),_(i.role.product.Cost?37:-1))},dependencies:[te,qt,Gt,Se,ye],styles:[".print_containers[_ngcontent-%COMP%]{display:none}@media print{.print_containers[_ngcontent-%COMP%]{display:block;text-align:left}.buy-complete[_ngcontent-%COMP%]{display:none}}.table-sm[_ngcontent-%COMP%] th[_ngcontent-%COMP%], .table-sm[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:10px!important}.buy-complete[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] .card-header[_ngcontent-%COMP%]{border-bottom:1px solid rgba(0,0,0,.125);padding-bottom:.9375rem}.buy-complete[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] .card-header[_ngcontent-%COMP%] h2[_ngcontent-%COMP%]{font-size:2rem}.buy-complete[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] .card-body[_ngcontent-%COMP%] .container[_ngcontent-%COMP%]{max-width:500px;margin-top:30px;margin-bottom:30px}.table[_ngcontent-%COMP%] th[_ngcontent-%COMP%], .table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{vertical-align:middle;line-height:15px!important}"],changeDetection:0})};var sr=["cartDisplayRef"],cr=(n,t)=>({label:n,tooltip:t}),mr=n=>({data:n}),dr=n=>({"bg-gradient-warning px-2":n}),pr=n=>({"me-3":n});function ur(n,t){n&1&&x(0,"POS-complete",2),n&2&&y("paymentComplete",t)}function fr(n,t){n&1&&on(0)}function gr(n,t){if(n&1&&(a(0,"div",9),kt(1,fr,1,0,"ng-container",31),r()),n&2){let e=d(2),i=It(4);l(),y("ngTemplateOutlet",i)("ngTemplateOutletContext",le(5,mr,lt(2,cr,e.fulfillmentOutletName(),e.fulfillmentOutletName())))}}function Cr(n,t){if(n&1){let e=U();a(0,"div",3)(1,"div",4)(2,"div",5)(3,"div",6),x(4,"POS-select-outlet-form",7),u(5,"async"),u(6,"async"),u(7,"async"),x(8,"POS-invoice-number-form",8),u(9,"async"),a(10,"div"),v(11,gr,2,7,"div",9),x(12,"POS-invoice-date",10),r()()(),a(13,"div",11)(14,"div",12)(15,"div",13),x(16,"POS-more-actions",14),u(17,"async"),u(18,"async"),r(),a(19,"div",15)(20,"div",16),x(21,"i",17)(22,"input",18),r()(),a(23,"div",19)(24,"div",20)(25,"button",21),u(26,"async"),D("click",function(){O(e);let o=d();return T(o.collapseSidebar())}),x(27,"span",22)(28,"span",22)(29,"span",22),r()()()()()(),a(30,"div",23)(31,"div",5),x(32,"POS-quick-key",24),u(33,"async"),r(),a(34,"div",25)(35,"div",26)(36,"div",27),x(37,"POS-variant-autocomplete",28),r(),a(38,"div",15),x(39,"POS-supplier-autocomplete",29),u(40,"async"),u(41,"async"),r()(),x(42,"POS-cart-display",30,1),u(44,"async"),u(45,"async"),u(46,"async"),x(47,"POS-cart-footer"),r()()()}if(n&2){let e=d();l(4),y("outlets",C(5,32,e.outlets$))("isOpenAfterLoad",C(6,34,e.isOpenDialogOutlet$))("formControl",e.outlet)("disabled",C(7,36,e.isEdit$))("disableCloseDialog",!0),l(4),y("formControl",e.poNumber)("isEdit",C(9,38,e.isEdit$)),l(3),_(e.isFulfillmentDifferentOutlet()?11:-1),l(),y("formControl",e.date)("tooltip",e.role.global!=null&&e.role.global.Date?"":"Date role is required"),l(4),y("returnInvoiceNumber",e.returnInvoiceNumber)("appConfigJSON",C(17,40,e.appConfigJSON$))("isEditBuyForm",C(18,42,e.isEdit$))("outletID",e.outlet.value.ID)("outletName",e.outlet.value.Name),l(6),y("formControl",e.attention),l(3),Pt("change",C(26,44,e.toggleState$)),l(7),y("quickKey",C(33,46,e.quickKeyPack$))("outletID",e.outlet.value.ID)("formControl",e.variantQuickKey),l(5),y("formControl",e.variantAutocomplete)("autocompleteEndpoint",e.variantAutocompleteEndpoint)("outletID",e.outlet.value.ID),l(2),y("formControl",e.supplierID)("supplierPOTypes",C(40,48,e.supplierPOTypes$))("appConfigJSON",C(41,50,e.appConfigJSON$)),l(3),y("cart",C(44,52,e.cart$))("appConfigJSON",C(45,54,e.appConfigJSON$))("isEdit",C(46,56,e.isEdit$))("outletID",e.outlet.value.ID)("outletName",e.outlet.value.Name)}}function yr(n,t){if(n&1&&(a(0,"h5",36),m(1),u(2,"limitText"),r()),n&2){let e=d().data;l(),ee(pt(2,1,e==null?null:e.label,14))}}function br(n,t){if(n&1&&(a(0,"div",32)(1,"div",33)(2,"div",34),x(3,"i",35),r(),v(4,yr,3,4,"h5",36),r()()),n&2){let e=t.data;y("ngClass",le(4,dr,e.label))("matTooltip",e==null?null:e.tooltip),l(2),y("ngClass",le(6,pr,e.label)),l(2),_(e!=null&&e.label?4:-1)}}var ao=class n extends Sn{constructor(e,i,o,s,F,f,w,H,M,j,c,S,L){Ki(()=>{this.cartDisplayRef()&&(s.cartDisplayRef=this.cartDisplayRef())});super(S);this.form=i;this.intercom=f;this.role=M;this.toggle=j;this.lowOnStock=c;this.menuData$.subscribe();let ne=i.buyForm.controls.Order.controls;this.outlets$=e.entities$,this.outlet=i.outlet,this.isEdit$=w.isEdit$.pipe(k(h=>h?this.outlet.disable():this.outlet.enable())),this.date=ne.Date,M.global.Date==!1&&this.date.disable(),this.supplierID=ne.SupplierID,this.attention=ne.Att,this.poNumber=i.buyForm.controls.Order.controls.Number,this.role?.sell?.Number||this.poNumber.disable(),this.quickKeyPack$=o.quickKeyPack$,this.variantAutocomplete=s.variantAutocomplete,this.variantQuickKey=s.variantQuickKey,this.returnInvoiceNumber=F.returnInvoiceNumber,this.cart$=s.cart$,this.appConfigJSON$=e.appConfigJSON$,this.isOpenDialogOutlet$=c.selectedLowOnStockData.length==0?this.isEdit$.pipe(Y(h=>H.createNewTransaction$.pipe(p(b=>b||h))),p(h=>!h)):Ke(!1),c.selectedLowOnStockData.length&&(i.setOutletForm({ID:c.selectedLowOnStockData[0].EntityID,Name:c.selectedLowOnStockData[0].Outlet}),L.post("/API/catalog/variant/GetVariantByListID",{ListID:c.selectedLowOnStockData.map(h=>h.ID),EntityID:c.selectedLowOnStockData[0].EntityID}).pipe(p(h=>h.map(b=>this.setUnitPrice(b)).map(b=>({VariantID:b.ID,UnitPrice:b.UnitPrice})))).subscribe(h=>{i.setDeliveryEntityID(c.selectedLowOnStockData[0].EntityID);let b=c.selectedLowOnStockData.map(R=>({Quantity:R.Quantity,UnitQuantity:R.UnitQuantity,UnitPrice:h.find($=>$.VariantID==R.VariantID).UnitPrice,Code:R.Code,Name:R.Product,DiscountAmount:R.DiscountAmount,Discount:R.Discount,Total:R.Total*h.find($=>$.VariantID==R.VariantID).UnitPrice,VariantID:R.VariantID}));s.editForm(b)})),this.paymentComplete$=H.paymentComplete$,this.supplierPOTypes$=e.supplierPOTypes$,this.toggleState$=j.toggleState$,this.initFulfillmentDifferentOutlet()}selectOutletFormComponent=ut(ni);requireOutletSelected(){return oe(this,null,function*(){return this.outlet?.value?.ID?!0:(yield this.openOutletSelectorModal(),!!this.outlet?.value?.ID)})}openOutletSelectorModal(){return new Promise(e=>{let i=this.selectOutletFormComponent();if(i){i.openModalSelectOutlet();let o=i.onCloseDialog.subscribe(()=>{o.unsubscribe(),e()})}else e()})}cartDisplayRef=ut("cartDisplayRef",{read:Ei});variantAutocompleteEndpoint=Ue.GetVariantSuggestionsByEntityID;sf=G(Vt);outlets$;quickKeyPack$;outlet;poNumber;date;supplierID;variantAutocomplete=new ge;variantQuickKey=new ge;returnInvoiceNumber;cart$;appConfigJSON$;attention;isEdit$;paymentComplete$;supplierPOTypes$;isOpenDialogOutlet$;toggleState$;renderer=G(Yi);isFulfillmentDifferentOutlet=se(!1);fulfillmentOutletName=se("");ngAfterViewInit(){let e=document.querySelector("#full-container");this.renderer.addClass(e,"full-container"),this.intercom.hideLauncher()}initFulfillmentDifferentOutlet(){xe([this.form.outlet.valueChanges.pipe(Ye(this.form.outlet.value)),this.form.fulfillmentResult.valueChanges.pipe(Ye(this.form.fulfillmentResult.value),p(e=>e.deliveryEntityID)),this.outlets$]).pipe(X()).subscribe(([e,i,o])=>{let s=e??this.form.outlet.value,F=i??this.form.fulfillmentResult.value.deliveryEntityID;if(I.IsNotEmpty(F)&&F!=I.GuidEmpty&&s?.ID!=F){let f=o.find(w=>w.ID==F);this.fulfillmentOutletName.set(f?.Name??""),this.isFulfillmentDifferentOutlet.set(!0)}else this.isFulfillmentDifferentOutlet.set(!1)})}setUnitPrice(e){let i=P({},e);return I.IsNotEmpty(e.OrderPrice)?i.UnitPrice=e.OrderPrice:i.UnitPrice=e.UnitCost,i}ngOnDestroy(){this.lowOnStock.selectedLowOnStockData=[],this.intercom.showLauncher()}collapseSidebar(){this.toggle.toggleSidebar()}static \u0275fac=function(i){return new(i||n)(g(ue),g(z),g(ot),g(Z),g(Ct),g(Cn),g(Je),g(He),g(Ce),g(yn),g(Zt),g(Mn),g(pe))};static \u0275cmp=V({type:n,selectors:[["POS-buy-v2"]],viewQuery:function(i,o){i&1&&St(o.selectOutletFormComponent,ni,5)(o.cartDisplayRef,sr,5,Ei),i&2&&Mt(2)},features:[je([Z,He,Et,Je,z,ue,Nt,ot,qe,Ct,Vt]),Zi],decls:5,vars:3,consts:[["fulfillmentIndicator",""],["cartDisplayRef",""],[3,"paymentComplete"],[1,"container-fluid"],[1,"row","header","border-bottom"],[1,"col-5","border-end"],[1,"left-toolbar-container","h-100","d-flex","align-items-center","justify-content-between"],[3,"outlets","isOpenAfterLoad","formControl","disabled","disableCloseDialog"],["transactionType","Purchase Order",3,"formControl","isEdit"],[1,"d-inline-block","pt-1","px-2","w-100"],[3,"formControl","tooltip"],[1,"col-7","d-flex","align-items-center"],[1,"row","flex-grow-1"],[1,"col-lg-7","col-5","d-flex","align-items-center"],[3,"returnInvoiceNumber","appConfigJSON","isEditBuyForm","outletID","outletName"],[1,"col-5","ps-0"],[1,"d-flex","align-items-center","position-relative"],[1,"fa-light","fa-id-badge","position-absolute"],["type","text","placeholder","Assign Attention",1,"border-bottom-0",3,"formControl"],[1,"col-2"],[1,"navbar","mobile-button","border-bottom-0"],["type","button","aria-controls","navigation-index","aria-expanded","false","aria-label","Toggle navigation",1,"navbar-toggler","navbar-toggler-right","float-end","toggle-menu","ps-2","pe-0","border-0",2,"width","max-content","height","max-content",3,"click"],[1,"navbar-toggler-bar","burger-lines"],[1,"row","content"],[3,"quickKey","outletID","formControl"],[1,"col-7","pt-5","px-0","d-flex","flex-column"],[1,"row","w-100","ms-0"],[1,"col-7","px-0"],["amountProperty","VariantCost",3,"formControl","autocompleteEndpoint","outletID"],[3,"formControl","supplierPOTypes","appConfigJSON"],[1,"cart-display",3,"cart","appConfigJSON","isEdit","outletID","outletName"],[4,"ngTemplateOutlet","ngTemplateOutletContext"],[3,"ngClass","matTooltip"],["role","button",1,"d-flex","align-items-center","cursor-pointer","w-100"],[3,"ngClass"],[1,"fa-duotone","fa-light","fa-truck"],[1,"text--truncated"]],template:function(i,o){if(i&1&&(v(0,ur,1,1,"POS-complete",2),u(1,"async"),en(2,Cr,48,58,"div",3),kt(3,br,5,8,"ng-template",null,0,Wt)),i&2){let s;_((s=C(1,1,o.paymentComplete$))?0:2,s)}},dependencies:[te,Xe,an,tt,Me,de,et,ni,Hn,Vn,ri,oi,qn,si,bi,Ti,wi,nt,it,Se,Kt],styles:[".left-toolbar-container[_ngcontent-%COMP%]{position:relative}.left-toolbar-container[_ngcontent-%COMP%] POS-invoice-number-form[_ngcontent-%COMP%]{position:absolute;top:34px;left:32px}.header[_ngcontent-%COMP%]{min-height:60px}.content[_ngcontent-%COMP%]{min-height:calc(100vh - 60px)}.supplier-more-menu[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center}.cart-display[_ngcontent-%COMP%]{flex-grow:1;height:0px;overflow-y:auto}input[_ngcontent-%COMP%]{width:100%;height:38px!important;border:0;border-bottom:1px solid #ced4da;padding-left:32px}input[_ngcontent-%COMP%]::placeholder{color:#ced4da}i.fa-id-badge[_ngcontent-%COMP%]{font-size:16px;top:10.6px;left:13px}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]{transition:.4s}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]:nth-child(1){-webkit-transform:rotate(-45deg) translate(-8px,4px);transform:rotate(-45deg) translate(-8px,4px)}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]:nth-child(2){opacity:0}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]:nth-child(3){-webkit-transform:rotate(45deg) translate(-5px,0px);transform:rotate(45deg) translate(-5px)}.mobile-button[_ngcontent-%COMP%]{display:none}@media(max-width:990px){.mobile-button[_ngcontent-%COMP%]{display:block}}.navbar-toggler[_ngcontent-%COMP%]:focus{box-shadow:none!important}.more-actions[_ngcontent-%COMP%] div.d-flex[_ngcontent-%COMP%]{width:30rem}.d-flex[_ngcontent-%COMP%] .text--truncated[_ngcontent-%COMP%]{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}"],changeDetection:0})};export{ao as BuyV2Component};