dealpos 25.35.2 → 25.35.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 (79) hide show
  1. package/browser/{chunk-FY4JABYL.js → chunk-2XMIL3M5.js} +1 -1
  2. package/browser/{chunk-LKZE2HD4.js → chunk-32XPQS72.js} +1 -1
  3. package/browser/{chunk-ZYTLUHOS.js → chunk-3BF3LB6Z.js} +1 -1
  4. package/browser/{chunk-VMIXOKE7.js → chunk-3T3RRVKX.js} +1 -1
  5. package/browser/{chunk-BBRBME3A.js → chunk-3Z3TRQBS.js} +1 -1
  6. package/browser/{chunk-ETHIPTBJ.js → chunk-4E4L6WXO.js} +1 -1
  7. package/browser/{chunk-45Q3TR52.js → chunk-5LVF3GQO.js} +1 -1
  8. package/browser/{chunk-M2DBAY4P.js → chunk-6DJNKKNB.js} +1 -1
  9. package/browser/{chunk-LHGABVF6.js → chunk-7AAAKDTU.js} +2 -2
  10. package/browser/{chunk-LYOMQKFY.js → chunk-7BDVBLHM.js} +1 -1
  11. package/browser/{chunk-2BRCOLHG.js → chunk-7IVZ7O4B.js} +1 -1
  12. package/browser/{chunk-LFRQUM6J.js → chunk-7J6JNI44.js} +1 -1
  13. package/browser/{chunk-4DIUJNZF.js → chunk-AAVH5EBY.js} +1 -1
  14. package/browser/{chunk-FBTUV7TY.js → chunk-AK6EELSP.js} +1 -1
  15. package/browser/{chunk-SVW3DCFV.js → chunk-BGQQUPTZ.js} +1 -1
  16. package/browser/{chunk-A477JKU4.js → chunk-BN2DUB4S.js} +1 -1
  17. package/browser/{chunk-XGQGO4PE.js → chunk-BUFUGEKP.js} +1 -1
  18. package/browser/{chunk-U7VNF37P.js → chunk-BXFKD2CO.js} +1 -1
  19. package/browser/{chunk-ZCKT34V7.js → chunk-BZAN6DNV.js} +1 -1
  20. package/browser/{chunk-AYEQLVMX.js → chunk-CESIM7I2.js} +1 -1
  21. package/browser/{chunk-EXCJNRRJ.js → chunk-CUD4PHJT.js} +1 -1
  22. package/browser/{chunk-E5UK2WMM.js → chunk-DDSUKJHT.js} +1 -1
  23. package/browser/{chunk-M7KP6PSY.js → chunk-DHQUQTIV.js} +1 -1
  24. package/browser/{chunk-GK45LVUY.js → chunk-DKX7YVH4.js} +1 -1
  25. package/browser/{chunk-OZOAAIBM.js → chunk-DO6W6BG2.js} +1 -1
  26. package/browser/{chunk-73ESQDPI.js → chunk-DU2U47CB.js} +1 -1
  27. package/browser/{chunk-5IY3H7NG.js → chunk-E7SOAHON.js} +1 -1
  28. package/browser/{chunk-6CUC5ZVY.js → chunk-EIPWN4ZG.js} +1 -1
  29. package/browser/{chunk-J4SLL7XI.js → chunk-F3QKO3WX.js} +1 -1
  30. package/browser/{chunk-WDIJOVDQ.js → chunk-FQSQUAUB.js} +1 -1
  31. package/browser/{chunk-NT4HXAUQ.js → chunk-GIMMGWIY.js} +1 -1
  32. package/browser/chunk-GLXNXL3M.js +1 -0
  33. package/browser/chunk-GWY532ZF.js +3 -0
  34. package/browser/{chunk-2ULGMZHE.js → chunk-H24HNIUV.js} +1 -1
  35. package/browser/{chunk-6E4UKP3I.js → chunk-H5EACBML.js} +2 -2
  36. package/browser/chunk-H7DCK5WJ.js +1 -0
  37. package/browser/{chunk-RXY2UMNO.js → chunk-HJZUPJW2.js} +1 -1
  38. package/browser/{chunk-GFFJDDRS.js → chunk-HKACPPVL.js} +1 -1
  39. package/browser/{chunk-HV7GI3KE.js → chunk-HSQKKFE6.js} +1 -1
  40. package/browser/{chunk-66WXWMUG.js → chunk-IWQEXFGO.js} +1 -1
  41. package/browser/{chunk-XXGDZ22Y.js → chunk-JRMGNV6W.js} +1 -1
  42. package/browser/chunk-JUDTCQVV.js +1 -0
  43. package/browser/{chunk-W64M5WBH.js → chunk-K4YUTEMS.js} +1 -1
  44. package/browser/{chunk-3GB5DSK3.js → chunk-KHHM6IFR.js} +1 -1
  45. package/browser/{chunk-33JZH2UR.js → chunk-KM4YGIPJ.js} +1 -1
  46. package/browser/{chunk-CNY7II6H.js → chunk-KQLFNIFZ.js} +1 -1
  47. package/browser/{chunk-7NMXZ55P.js → chunk-LS4LCNAF.js} +2 -2
  48. package/browser/{chunk-SO3WWYN3.js → chunk-MERQX2AF.js} +1 -1
  49. package/browser/{chunk-4YPJAUSY.js → chunk-MLMSIZGP.js} +1 -1
  50. package/browser/{chunk-FOVCORMR.js → chunk-MUFGLBTW.js} +1 -1
  51. package/browser/{chunk-WDS6MTSX.js → chunk-MXRJZC7D.js} +2 -2
  52. package/browser/{chunk-V4OYKDE2.js → chunk-NHVQ6BHI.js} +1 -1
  53. package/browser/{chunk-LXZS75G2.js → chunk-NLWPMDWU.js} +1 -1
  54. package/browser/{chunk-WOBW4V44.js → chunk-NMGT5PYX.js} +1 -1
  55. package/browser/{chunk-CZTNOFUC.js → chunk-NQPOGM3H.js} +1 -1
  56. package/browser/{chunk-Q76KX5JJ.js → chunk-NY4SVPPU.js} +1 -1
  57. package/browser/{chunk-Q5YFG526.js → chunk-O3IGBF5Z.js} +1 -1
  58. package/browser/{chunk-F3ZJVCRK.js → chunk-OFNXPEBH.js} +1 -1
  59. package/browser/{chunk-P5KSSZK7.js → chunk-P4TUOMJ4.js} +1 -1
  60. package/browser/{chunk-7B7ON5E6.js → chunk-QZFGYG5J.js} +1 -1
  61. package/browser/{chunk-K76G23WC.js → chunk-RJSPJ6CG.js} +1 -1
  62. package/browser/{chunk-Z7WYC46Q.js → chunk-RYONOB6O.js} +1 -1
  63. package/browser/{chunk-VDKUDQZO.js → chunk-S7QH3NMD.js} +1 -1
  64. package/browser/{chunk-NPHAQCON.js → chunk-SJ7OFVH5.js} +1 -1
  65. package/browser/{chunk-5MGHIIE6.js → chunk-SKFIRYCU.js} +2 -2
  66. package/browser/{chunk-HNBLWEAJ.js → chunk-TYIDA4YO.js} +1 -1
  67. package/browser/{chunk-VJWRLXE4.js → chunk-W2TSDYEA.js} +1 -1
  68. package/browser/{chunk-4YAMWP7V.js → chunk-W7HVLC6V.js} +1 -1
  69. package/browser/{chunk-O7H6QE5A.js → chunk-XEKUUP6Y.js} +1 -1
  70. package/browser/{chunk-X4VB4DKS.js → chunk-YCPSIUQ3.js} +1 -1
  71. package/browser/{chunk-7VKHUEU6.js → chunk-YGUNDEOT.js} +1 -1
  72. package/browser/{chunk-LYGTJSME.js → chunk-ZFMK7BOT.js} +1 -1
  73. package/browser/index.html +2 -2
  74. package/browser/{main-WYOICQDK.js → main-XQZCWN5T.js} +2 -2
  75. package/package.json +1 -1
  76. package/browser/chunk-INDKSR3O.js +0 -3
  77. package/browser/chunk-LI3MYO4W.js +0 -1
  78. package/browser/chunk-PDHJSRKI.js +0 -1
  79. package/browser/chunk-R3IC3THI.js +0 -1
@@ -1,4 +1,4 @@
1
- import{a as Ht,b as jt}from"./chunk-NPJ272AZ.js";import{a as Do}from"./chunk-UX2MPDGZ.js";import{a as uo}from"./chunk-TK5H65DN.js";import{a as Ci}from"./chunk-6L6CIH5M.js";import{e as Co}from"./chunk-QMPKHU2W.js";import{a as ze}from"./chunk-3PXI2XBC.js";import{a as hi,b as Se}from"./chunk-THRGCK26.js";import{a as so}from"./chunk-DYCGOJEI.js";import{b as bo}from"./chunk-KVPIGIZJ.js";import{d as yo}from"./chunk-5VFKAJV6.js";import{a as _o}from"./chunk-W2UCLTBY.js";import{a as go}from"./chunk-UU5RJKWG.js";import{a as de,b as Te,e as Oo}from"./chunk-GE53XQ2Q.js";import{b as ho}from"./chunk-7BU64MD2.js";import{a as mo,b as So,c as Po}from"./chunk-SZKR6UME.js";import{a as po}from"./chunk-QLFKPTZA.js";import{a as Io}from"./chunk-5VAXIJEW.js";import{g as lo}from"./chunk-4L4E5MG3.js";import{d as fi}from"./chunk-3VKLFFAF.js";import{b as un,c as co}from"./chunk-H2VTVYZY.js";import{a as pn,b as Bt,c as dn}from"./chunk-VOU4625O.js";import{b as ao}from"./chunk-MUCQWTKH.js";import{a as Jn}from"./chunk-O7MCO2N7.js";import{a as Pt}from"./chunk-UZKYLAUE.js";import{a as vi,b as _i,c as yi}from"./chunk-47MDCKEY.js";import{a as fo}from"./chunk-FIS6Q5OG.js";import{p as Yn}from"./chunk-GEWY5VWO.js";import{d as zn}from"./chunk-GOQ3ZCDK.js";import{a as vo}from"./chunk-TGAOY65D.js";import{a as Mo}from"./chunk-IVP3GL2V.js";import{a as it,b as st,c as pe}from"./chunk-HT35KHLT.js";import{h as Kn}from"./chunk-6ZOGADBZ.js";import{a as Xn,b as bt}from"./chunk-7ENHJR7R.js";import{B as oo,C as ee,D as ye,G as ro,u as Z,v as X,w as yt}from"./chunk-677WPFLK.js";import{b as di,c as Lt}from"./chunk-CIBQBSM6.js";import{G as St,O as gi,P as Q,g as eo,n as ui,o as to,q as io,u as no}from"./chunk-L2RZWAX3.js";import{a as tt}from"./chunk-ZT4RBJMM.js";import{a as Fn,c as Ln}from"./chunk-GIKR6Y2K.js";import{e as _t,f as Zn}from"./chunk-VMY3JQDA.js";import{a as se,b as $n,e as K,f as me,g as xe}from"./chunk-D35OBUDE.js";import{a as le}from"./chunk-2FWFPV5I.js";import{D as mi,c as De,e as ci,h as _e,i as Bn,k as Hn,l as Ke,n as jn,o as Me,p as Qn,s as vt,v as Un,w as Wn,y as Gn,z as qn}from"./chunk-P7HKWFZT.js";import{a as h,d as pi}from"./chunk-AHCRE4GP.js";import{a as Vn}from"./chunk-4YAMWP7V.js";import{$ as ti,$a as l,$b as Ft,$c as xn,Ac as M,Bc as ie,Cc as Ct,Db as R,E as re,Eb as gt,Fc as Oe,Gb as ft,Hb as ht,I as et,Ia as ni,Ib as a,Ja as mn,Jb as s,Kb as _,Lb as H,M as dt,Ma as q,Mb as j,N as Be,Nb as si,Ob as I,Pc as qe,Q as ke,Qb as b,Qd as Nn,Rb as d,Rd as An,Td as kn,Va as Ge,Vd as B,Wa as ut,Wc as Fe,Xa as Pn,Y as Ve,Yc as ve,Yd as Ie,Zb as kt,Zc as oe,_b as Vt,_c as In,aa as Y,ad as Tn,b as Zt,bd as wn,cd as $e,d as Ae,da as Pe,db as S,dc as W,e as Ce,ec as m,ed as Je,fa as ae,fc as D,gc as O,gd as z,hc as li,ib as oi,ic as Dn,ja as x,jc as k,jd as ce,k as mt,ka as ii,kb as E,kc as N,lb as ri,lc as V,ma as g,n as bn,na as w,o as Ee,p as pt,q as Xt,qb as f,r as ei,rc as F,sc as He,t as $,td as Rn,u as We,ub as On,uc as Mn,v as Sn,va as C,vb as p,wa as v,xd as En,zb as ai,zc as y}from"./chunk-DZT5XHBQ.js";import{a as Yt,h as Xe,j as Kt}from"./chunk-7DCB7DB2.js";var je=class{constructor(e){this.roleService=e;e&&this.setRole()}_Retrieve;_DateEditor;_NumberEditor;_PriceVisible;_UnitPriceEditor;_PricebookSelector;_Cost;_Return;_Discount;_SalesPerson;_PriceMinimum;_Payment;_CreditSalesLock;_CustomerInputLock;_PaymentCodeLock;_Shipping;_Tax;_DeleteItem;_BundlingPrice;_EmailRestriction;_ParkedDeletionAuthorized;_SellEditor;_ContactCreate;_PrepaidPackageCreate;_Order;_Reprint;_Contacts;_ContactsCreate;_InventoryView;_DebtView;_ClearCart;_SellDelete;_DeliveryEditor;_CouponInputLock;_Park;_Commission;setRole(){this._Retrieve=this.roleService.sell.RetrieveR,this._DateEditor=this.roleService.global.Date,this._NumberEditor=this.roleService.sell.Number,this._PriceVisible=this.roleService.sell.PriceVisible,this._SalesPerson=this.roleService.sell.SalesPerson,this._UnitPriceEditor=this.roleService.sell.UnitPriceEditor,this._PricebookSelector=this.roleService.sell.PricebookSelector,this._Cost=this.roleService.product.Cost,this._Return=this.roleService.sell.Return,this._Discount=this.roleService.sell.Discount,this._PriceMinimum=this.roleService.sell.PriceMinimum,this._Payment=this.roleService.sell.Payment,this._CreditSalesLock=this.roleService.sell.CreditSalesLock,this._CustomerInputLock=this.roleService.sell.CustomerInputLock,this._PaymentCodeLock=this.roleService.sell.PaymentCodeLock,this._Shipping=this.roleService.sell.Shipping,this._Tax=this.roleService.sell.Tax,this._DeleteItem=this.roleService.sell.DeleteItem,this._BundlingPrice=this.roleService.sell.BundlingPrice,this._EmailRestriction=this.roleService.sell.Email,this._SellEditor=this.roleService.sell.Edit,this._ContactCreate=this.roleService.contact.Create,this._PrepaidPackageCreate=this.roleService.prepaidPackage.Create,this._Order=this.roleService.order.View,this._Contacts=this.roleService.contact.View,this._ContactsCreate=this.roleService.contact.Create,this._InventoryView=this.roleService.inventory.View,this._DebtView=this.roleService.debt.View,this._ClearCart=this.roleService.sell.DeleteItem,this._SellDelete=this.roleService.sell.Delete,this._DeliveryEditor=this.roleService.logistic.Edit,this._Reprint=this.roleService.order.Print,this._CouponInputLock=this.roleService.sell.CouponInputLock,this._Park=this.roleService.sell.Park,this._Commission=this.roleService.product.CommissionView}get Park(){return this._Park}get CouponInputLock(){return this._CouponInputLock}set CouponInputLock(e){this._CouponInputLock=e}get Retrieve(){return this._Retrieve}get DateEditor(){return this._DateEditor}set DateEditor(e){this._DateEditor=e}get NumberEditor(){return this._NumberEditor}set NumberEditor(e){this._NumberEditor=e}get PriceVisible(){return this._PriceVisible}get UnitPriceEditor(){return this._UnitPriceEditor}set UnitPriceEditor(e){this._UnitPriceEditor=e}get PricebookSelector(){return this._PricebookSelector}set PricebookSelector(e){this._PricebookSelector=e}get Cost(){return this._Cost}get Return(){return this._Return}set Return(e){this._Return=e}get Discount(){return this._Discount}set Discount(e){this._Discount=e}get SalesPerson(){return this._SalesPerson}get PriceMinimum(){return this._PriceMinimum}get Payment(){return this._Payment}get CreditSalesLock(){return this._CreditSalesLock}get CustomerInputLock(){return this._CustomerInputLock}get PaymentCodeLock(){return this._PaymentCodeLock}get Shipping(){return this._Shipping}get Tax(){return this._Tax}set Tax(e){this._Tax=e}get DeleteItem(){return this._DeleteItem}set DeleteItem(e){this._DeleteItem=e}get BundlingPrice(){return this._BundlingPrice}get Email(){return this._EmailRestriction}get ParkedDeletionAuthorized(){return this._ParkedDeletionAuthorized}set ParkedDeletionAuthorized(e){this._ParkedDeletionAuthorized=e}get SellEditor(){return this._SellEditor}get PrepaidPackageCreate(){return this._PrepaidPackageCreate}get Order(){return this._Order}get Reprint(){return this._Reprint}get Contacts(){return this._Contacts}get ContactsCreate(){return this._ContactsCreate}get InventoryView(){return this._InventoryView}get DebtView(){return this._DebtView}get ClearCartRestriction(){return this._ClearCart}get SellDelete(){return this._SellDelete}get DeliveryEditor(){return this._DeliveryEditor}get Commission(){return this._Commission}};var Qt=class{DeliveryEntityID;Type;NewOrderID;constructor(){this.DeliveryEntityID="",this.Type=3}};var G=class{Order;Invoice;Shipping;Action;Payments;Items;CartItems;ContactName;SplitParkLabel;get cartQuantity(){let e=0;for(let t of this.CartItems)e+=t.Quantity;return e}constructor(){this.Order=new un,this.Invoice=new Bt,this.Shipping=new dn,this.Action=new Qt,this.Payments=Array(),this.Items=Array(),this.CartItems=Array(),this.ContactName=""}get TotalPaidAmount(){let e=0;return this.Payments.forEach(t=>{e+=t.PaidAmount}),e}get RedeemableAmount(){let e=this.CartItems.filter(t=>t.Variant.PaymentTypeID!=1);return this.GetAmountByCart(e)}get TotalQuantity(){let e=0;return this.CartItems.forEach(t=>{t.PromotionGift||(e+=t.Quantity)}),e}get CashOnlyAmount(){let e=this.CartItems.filter(t=>t.Variant.PaymentTypeID==1);return this.GetAmountByCart(e)}get PointOnlyAmount(){let e=this.CartItems.filter(t=>t.Variant.PaymentTypeID==2);return this.GetAmountByCart(e)}get PrepaidPackageItem(){return this.CartItems.filter(t=>t.Variant.TypeID==10)}GetAmountByCart(e){let t=0;return e.forEach(i=>{t+=i.Total}),t=t*(100-this.Order.Discount)/100,t=t*(100-this.Order.Discount2)/100,t}getRewards(){return this.CartItems.filter(t=>t.PromotionGift)}};Xe([it(()=>un)],G.prototype,"Order",2),Xe([it(()=>Bt)],G.prototype,"Invoice",2),Xe([it(()=>dn)],G.prototype,"Shipping",2),Xe([it(()=>Qt)],G.prototype,"Action",2),Xe([it(()=>ze)],G.prototype,"Payments",2),Xe([it(()=>hi)],G.prototype,"Items",2),Xe([it(()=>Se)],G.prototype,"CartItems",2);var bi=class{Success;Message;message;ObjectID;SalesOrderID;OutDeliveryID;Contact;LoyaltyPoint;InvoiceNumber;Creator;OrderTimeString;PrintMode;PaymentStateID;PaymentStateLabel;Final;constructor(){this.Success=!0,this.Message="",this.ObjectID="",this.SalesOrderID="",this.OutDeliveryID="",this.Contact=null,this.LoyaltyPoint="",this.InvoiceNumber="",this.Creator="",this.OrderTimeString="",this.PrintMode=0,this.PaymentStateID=0,this.PaymentStateLabel="",this.Final=0}};var Ot=class n{constructor(e,t,i,o){this.httpService=e;this._localDataService=t;this._onlineStatusService=i;this._toastrService=o;this._onlineStatusService.getOnlineStatus$().subscribe(r=>{this.isOnline=r})}_Data=new Ce(null);Data$=this._Data.pipe(ke(),re(e=>e!==null));isOnline;get Data(){return this._Data.value}pushNewValue(e){this._Data.next(e)}getSalesOrderPrint(e){return this.httpService.post("/API/POS/GetSalesOrderPrint",{TemplateID:e})}submitOrder(e,t){let i=this.generatePOSDataForSubmission(e,this.isOnline);if(this.isOnline)return this.submitOnline(i).pipe(this.handleTimeOutError(i));if(t.ModuleSell.EnableOfflineTransaction)return this._localDataService.syncOrder(i).pipe($(()=>this.generateCompleteData(i)));this._toastrService.warning("Offline order is not Supported!","Info!")}uploadOfflineOrder(e){return this._localDataService.uploadSingleOrder(e).pipe(et(t=>t?.message?.includes("objectStore does not exists")?this.submitOnline(e):pt(()=>t)))}submitOnline(e){return this.httpService.post(Q.SubmitOrder,e,Vn.pos.submitOrderTimeout)}handleTimeOutError(e){return Zt(et(t=>{if(t instanceof ei||t?.name=="TimeoutError"){let i=this.generateCompleteData(e);this.pushNewValue(i)}throw t}))}generatePOSDataForSubmission(e,t=!0){let i=Object.assign(new G,e);i.Items=[],i.Order.CustomerID==null&&(i.Order.CustomerID=h.GuidEmpty),i.Order.SalesID==null&&(i.Order.SalesID=h.GuidEmpty);let o=1;i.Payments=i.Payments.map(c=>(c.Date=i.Order.Date,c.Index=o,o++,delete c.TypeID,c));let r=1;for(let c of i.CartItems){let u=new hi;u.ID=c.ID,u.VariantID=c.VariantID,u.Quantity=c.Quantity,u.Cost=c.Cost,u.Price=c.Price,u.Discount=c.Discount,u.DiscountAmount=c.DiscountAmount,u.Note=c.Note,u.Taxable=c.Variant.Taxable,u.LoyaltyPoint=c.LoyaltyPoint,u.UnitCost=c.Cost,u.UnitPrice=c.Price,u.UnitPriceOriginal=c.UnitPriceOriginal,u.UnitExpense=c.UnitExpense,u.EntityID=c.EntityID,u.Index=r,u.UnitQuantity=c.UnitQuantity,u.PriceTypeID=c.PriceTypeID,u.PriceNote=c.PriceNote,u.Splited=c.SplitQuantity>0,u.SplitQuantity=c.SplitQuantity,u.InventoryTypeID=c.Variant.TypeID,u.SalesID="",u.Serial=c.Serial,c.SalesID&&(u.SalesID=c.SalesID),delete c.CouponDiscount,i.Items.push(u),r++}return t?(delete i.CartItems,delete i.Order.ClientTimestamp):i.Order.ClientTimestamp=new Date,i}generateCompleteData(e){let t=new bi;return t.InvoiceNumber=e.Order.Number,t.OrderTimeString=new Date().toString(),t.PaymentStateID=e.Action?.Type,t.PaymentStateLabel="Offline",t.Success=!0,t.OutDeliveryID=e.Action.DeliveryEntityID,t}GetReturnInvoice(e,t){return this.httpService.get(Q.ReturInvoice,[{key:"EntityID",value:t},{key:"Number",value:e}])}GetInvoiceBySoID(e){return this.httpService.get(Q.GetPOSDataByID,[{key:"ID",value:e}])}UploadCSV(e,t){let i={CartItems:e,EntityID:t};return this.httpService.post(Q.UploadCsv,i)}sendEmail(e,t){return new Promise((i,o)=>{this._localDataService.isProductFromServer().subscribe(r=>{if(r){let c={invoiceID:t,email:e};this.httpService.post(Q.SendInvoiceEmail,c).subscribe({next:u=>{i(u)},error:u=>{o(u)}})}else o(ee.wrongOfflineAction)})})}sendWhatsaap(e,t){let i={InvoiceID:e,PhoneNumber:t};return this.httpService.post(Q.SendInvoiceWhatsapp,i)}createCustomerByInvoice(e,t){let i={InvoiceID:e,Mobile:t};return this.httpService.post(Q.CreateCustomerInvoice,i)}saveCommission(e,t){let i={SOID:e,commission:t};return this.httpService.POSText("/API/Transaction/SetCommission",i)}generateReceiptA4(e){let t={ID:e};return this.httpService.post(Q.InvoiceA4,t)}getVacant(e){return this.httpService.get(Q.GetVacant,[{key:"EntityID",value:e}])}static \u0275fac=function(t){return new(t||n)(g(Ie),g(ye),g(de),g(B))};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var J=class n{constructor(e,t,i){this._localDataService=e;this._onlineStatusService=t;this._httpService=i;this._onlineStatusService.getOnlineStatus$().subscribe(o=>{this.isOnline=o})}_Data=new Ce(null);Data$=this._Data.asObservable().pipe(re(e=>e!==null),ke());isOnline;get Data(){return this._Data.value}pushNewValue(e){this._Data.next(e)}requestObservable(){return this.isOnline?this._httpService.get(Q.GetPOSStorage).pipe($(e=>({data:e,type:"Online"}))):this._localDataService.getPOSStorage().pipe(re(e=>e!=null),$(e=>({data:e,type:"Offline"})))}getOutletName(e){return this.Data.Entities.find(i=>i.ID==e)?.Name}static \u0275fac=function(t){return new(t||n)(g(ye),g(de),g(Ie))};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var be=class n{constructor(e){this.roleService=e;this.pushNewValue(new je(e))}_Data=new Ce(new je(null));get Data(){return this._Data.value}Data$=this._Data.asObservable();pushNewValue(e){this._Data.next(e)}static \u0275fac=function(t){return new(t||n)(g(pi))};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var Gt=class{ID;Code;EntityID;Name;Description;Start;StartDisplay;State;Open;CashierID;OpeningCash;EntityName;LoginID;Active;CustomerDisplayEnabled;OvoConfigurationID;CustomerDisplayID;ListImage;Suspended};var Go=n=>({active:n}),qo=n=>({gray:n});function $o(n,e){if(n&1){let t=I();a(0,"span",17),b("click",function(o){C(t);let r=d().$implicit;return d().closeRegister(r),v(o.stopPropagation())}),s()}}function Jo(n,e){n&1&&(a(0,"div")(1,"span",18),m(2,"VACANT"),s()())}function zo(n,e){if(n&1&&(a(0,"div")(1,"span",19),_(2,"i",20),a(3,"font"),m(4),s()(),a(5,"span",21),_(6,"i",22),a(7,"font"),m(8),s()()()),n&2){let t=d().$implicit;l(4),D(t.LoginID),l(4),O("",t.StartDisplay.split(" ")[3]," - Now")}}function Yo(n,e){if(n&1){let t=I();a(0,"div",9)(1,"div",10)(2,"div",11)(3,"h5",12),b("click",function(){let o=C(t).$implicit,r=d();return v(r.select(o))}),a(4,"span"),_(5,"i",13),m(6),y(7,"limitTo"),s(),f(8,$o,1,0,"span",14),s(),a(9,"div",15),b("click",function(){let o=C(t).$implicit,r=d();return v(r.select(o))}),f(10,Jo,3,0,"div",16)(11,zo,9,2,"div",16),s()()()()}if(n&2){let t=e.$implicit,i=d();l(),p("ngClass",t.Active?"active":""),l(),p("ngClass",F(11,Go,(t==null?null:t.ID)==(i.selectedRegister==null?null:i.selectedRegister.ID))),l(),p("ngClass",F(13,qo,t!=i.selectedRegister)),l(3),D(ie(7,8,t.Name,15)),l(2),p("ngIf",t.State!="Close"),l(),p("ngSwitch",t.State),l(),p("ngSwitchCase","Close"),l(),p("ngSwitchCase","Open")}}var Si=class n{constructor(e,t,i,o,r){this._dialogRef=e;this._outletService=t;this._posService=i;this._userRoleService=o;this.router=r}originalSelectedRegister=null;registers;searchInput="";selectedRegister=new Gt;modalConfig=new Z;role;get AppConfigJSON(){return this._posService.Data.AppConfigJSON}destroy$=new Ae;ngOnInit(){this.subscribeToObsChanges(),this.initModalConfig()}subscribeToObsChanges(){this._posService.Data$.pipe(Pe(this.destroy$)).subscribe(e=>{this.registers=e.Registers}),this._outletService.Data$.pipe(Pe(this.destroy$)).subscribe(e=>{this.selectedRegister=this.findOutletRegisterById(e.RegisterID),this.originalSelectedRegister=this.selectedRegister?Yt({},this.selectedRegister):null}),this._userRoleService.Data$.pipe(Pe(this.destroy$)).subscribe(e=>{this.role=e})}findOutletRegisterById(e){let t=this.registers.find(i=>i.ID===e);return t||new Gt}initModalConfig(){this.modalConfig.hideClose=!1,this.modalConfig.hideCancel=!1,this.modalConfig.bodyScrollable=!0,this.modalConfig.title="Choose an outlet"}ngOnDestroy(){this.destroy$.next(!0),this.destroy$.complete()}close(){this._dialogRef.close()}onOk(){if(this.selectedRegister.ID==null){alert("Please select a register first!");return}this._outletService.pushNewRegister(this.selectedRegister),this._dialogRef.close({selectedRegister:this.selectedRegister,openStartingCashDialog:this.selectedRegister.ID!=this.originalSelectedRegister?.ID})}select(e){if(this.AppConfigJSON.ModuleShift.Closure.Enabled)if(this.selectedRegister.ID!=null&&this.selectedRegister.Open&&e.CashierID==null)confirm("You already have an active register with "+this.selectedRegister.Name+`!
1
+ import{a as Ht,b as jt}from"./chunk-NPJ272AZ.js";import{a as Do}from"./chunk-UX2MPDGZ.js";import{a as uo}from"./chunk-TK5H65DN.js";import{a as Ci}from"./chunk-6L6CIH5M.js";import{e as Co}from"./chunk-QMPKHU2W.js";import{a as ze}from"./chunk-3PXI2XBC.js";import{a as hi,b as Se}from"./chunk-THRGCK26.js";import{a as so}from"./chunk-DYCGOJEI.js";import{b as bo}from"./chunk-KVPIGIZJ.js";import{d as yo}from"./chunk-5VFKAJV6.js";import{a as _o}from"./chunk-W2UCLTBY.js";import{a as go}from"./chunk-UU5RJKWG.js";import{a as de,b as Te,e as Oo}from"./chunk-GE53XQ2Q.js";import{b as ho}from"./chunk-7BU64MD2.js";import{a as mo,b as So,c as Po}from"./chunk-SZKR6UME.js";import{a as po}from"./chunk-QLFKPTZA.js";import{a as Io}from"./chunk-5VAXIJEW.js";import{g as lo}from"./chunk-4L4E5MG3.js";import{d as fi}from"./chunk-3VKLFFAF.js";import{b as un,c as co}from"./chunk-H2VTVYZY.js";import{a as pn,b as Bt,c as dn}from"./chunk-VOU4625O.js";import{b as ao}from"./chunk-MUCQWTKH.js";import{a as Jn}from"./chunk-O7MCO2N7.js";import{a as Pt}from"./chunk-UZKYLAUE.js";import{a as vi,b as _i,c as yi}from"./chunk-47MDCKEY.js";import{a as fo}from"./chunk-FIS6Q5OG.js";import{p as Yn}from"./chunk-GEWY5VWO.js";import{d as zn}from"./chunk-GOQ3ZCDK.js";import{a as vo}from"./chunk-TGAOY65D.js";import{a as Mo}from"./chunk-IVP3GL2V.js";import{a as it,b as st,c as pe}from"./chunk-HT35KHLT.js";import{h as Kn}from"./chunk-6ZOGADBZ.js";import{a as Xn,b as bt}from"./chunk-7ENHJR7R.js";import{B as oo,C as ee,D as ye,G as ro,u as Z,v as X,w as yt}from"./chunk-677WPFLK.js";import{b as di,c as Lt}from"./chunk-CIBQBSM6.js";import{G as St,O as gi,P as Q,g as eo,n as ui,o as to,q as io,u as no}from"./chunk-L2RZWAX3.js";import{a as tt}from"./chunk-ZT4RBJMM.js";import{a as Fn,c as Ln}from"./chunk-GIKR6Y2K.js";import{e as _t,f as Zn}from"./chunk-VMY3JQDA.js";import{a as se,b as $n,e as K,f as me,g as xe}from"./chunk-D35OBUDE.js";import{a as le}from"./chunk-2FWFPV5I.js";import{D as mi,c as De,e as ci,h as _e,i as Bn,k as Hn,l as Ke,n as jn,o as Me,p as Qn,s as vt,v as Un,w as Wn,y as Gn,z as qn}from"./chunk-P7HKWFZT.js";import{a as h,d as pi}from"./chunk-AHCRE4GP.js";import{a as Vn}from"./chunk-W7HVLC6V.js";import{$ as ti,$a as l,$b as Ft,$c as xn,Ac as M,Bc as ie,Cc as Ct,Db as R,E as re,Eb as gt,Fc as Oe,Gb as ft,Hb as ht,I as et,Ia as ni,Ib as a,Ja as mn,Jb as s,Kb as _,Lb as H,M as dt,Ma as q,Mb as j,N as Be,Nb as si,Ob as I,Pc as qe,Q as ke,Qb as b,Qd as Nn,Rb as d,Rd as An,Td as kn,Va as Ge,Vd as B,Wa as ut,Wc as Fe,Xa as Pn,Y as Ve,Yc as ve,Yd as Ie,Zb as kt,Zc as oe,_b as Vt,_c as In,aa as Y,ad as Tn,b as Zt,bd as wn,cd as $e,d as Ae,da as Pe,db as S,dc as W,e as Ce,ec as m,ed as Je,fa as ae,fc as D,gc as O,gd as z,hc as li,ib as oi,ic as Dn,ja as x,jc as k,jd as ce,k as mt,ka as ii,kb as E,kc as N,lb as ri,lc as V,ma as g,n as bn,na as w,o as Ee,p as pt,q as Xt,qb as f,r as ei,rc as F,sc as He,t as $,td as Rn,u as We,ub as On,uc as Mn,v as Sn,va as C,vb as p,wa as v,xd as En,zb as ai,zc as y}from"./chunk-DZT5XHBQ.js";import{a as Yt,h as Xe,j as Kt}from"./chunk-7DCB7DB2.js";var je=class{constructor(e){this.roleService=e;e&&this.setRole()}_Retrieve;_DateEditor;_NumberEditor;_PriceVisible;_UnitPriceEditor;_PricebookSelector;_Cost;_Return;_Discount;_SalesPerson;_PriceMinimum;_Payment;_CreditSalesLock;_CustomerInputLock;_PaymentCodeLock;_Shipping;_Tax;_DeleteItem;_BundlingPrice;_EmailRestriction;_ParkedDeletionAuthorized;_SellEditor;_ContactCreate;_PrepaidPackageCreate;_Order;_Reprint;_Contacts;_ContactsCreate;_InventoryView;_DebtView;_ClearCart;_SellDelete;_DeliveryEditor;_CouponInputLock;_Park;_Commission;setRole(){this._Retrieve=this.roleService.sell.RetrieveR,this._DateEditor=this.roleService.global.Date,this._NumberEditor=this.roleService.sell.Number,this._PriceVisible=this.roleService.sell.PriceVisible,this._SalesPerson=this.roleService.sell.SalesPerson,this._UnitPriceEditor=this.roleService.sell.UnitPriceEditor,this._PricebookSelector=this.roleService.sell.PricebookSelector,this._Cost=this.roleService.product.Cost,this._Return=this.roleService.sell.Return,this._Discount=this.roleService.sell.Discount,this._PriceMinimum=this.roleService.sell.PriceMinimum,this._Payment=this.roleService.sell.Payment,this._CreditSalesLock=this.roleService.sell.CreditSalesLock,this._CustomerInputLock=this.roleService.sell.CustomerInputLock,this._PaymentCodeLock=this.roleService.sell.PaymentCodeLock,this._Shipping=this.roleService.sell.Shipping,this._Tax=this.roleService.sell.Tax,this._DeleteItem=this.roleService.sell.DeleteItem,this._BundlingPrice=this.roleService.sell.BundlingPrice,this._EmailRestriction=this.roleService.sell.Email,this._SellEditor=this.roleService.sell.Edit,this._ContactCreate=this.roleService.contact.Create,this._PrepaidPackageCreate=this.roleService.prepaidPackage.Create,this._Order=this.roleService.order.View,this._Contacts=this.roleService.contact.View,this._ContactsCreate=this.roleService.contact.Create,this._InventoryView=this.roleService.inventory.View,this._DebtView=this.roleService.debt.View,this._ClearCart=this.roleService.sell.DeleteItem,this._SellDelete=this.roleService.sell.Delete,this._DeliveryEditor=this.roleService.logistic.Edit,this._Reprint=this.roleService.order.Print,this._CouponInputLock=this.roleService.sell.CouponInputLock,this._Park=this.roleService.sell.Park,this._Commission=this.roleService.product.CommissionView}get Park(){return this._Park}get CouponInputLock(){return this._CouponInputLock}set CouponInputLock(e){this._CouponInputLock=e}get Retrieve(){return this._Retrieve}get DateEditor(){return this._DateEditor}set DateEditor(e){this._DateEditor=e}get NumberEditor(){return this._NumberEditor}set NumberEditor(e){this._NumberEditor=e}get PriceVisible(){return this._PriceVisible}get UnitPriceEditor(){return this._UnitPriceEditor}set UnitPriceEditor(e){this._UnitPriceEditor=e}get PricebookSelector(){return this._PricebookSelector}set PricebookSelector(e){this._PricebookSelector=e}get Cost(){return this._Cost}get Return(){return this._Return}set Return(e){this._Return=e}get Discount(){return this._Discount}set Discount(e){this._Discount=e}get SalesPerson(){return this._SalesPerson}get PriceMinimum(){return this._PriceMinimum}get Payment(){return this._Payment}get CreditSalesLock(){return this._CreditSalesLock}get CustomerInputLock(){return this._CustomerInputLock}get PaymentCodeLock(){return this._PaymentCodeLock}get Shipping(){return this._Shipping}get Tax(){return this._Tax}set Tax(e){this._Tax=e}get DeleteItem(){return this._DeleteItem}set DeleteItem(e){this._DeleteItem=e}get BundlingPrice(){return this._BundlingPrice}get Email(){return this._EmailRestriction}get ParkedDeletionAuthorized(){return this._ParkedDeletionAuthorized}set ParkedDeletionAuthorized(e){this._ParkedDeletionAuthorized=e}get SellEditor(){return this._SellEditor}get PrepaidPackageCreate(){return this._PrepaidPackageCreate}get Order(){return this._Order}get Reprint(){return this._Reprint}get Contacts(){return this._Contacts}get ContactsCreate(){return this._ContactsCreate}get InventoryView(){return this._InventoryView}get DebtView(){return this._DebtView}get ClearCartRestriction(){return this._ClearCart}get SellDelete(){return this._SellDelete}get DeliveryEditor(){return this._DeliveryEditor}get Commission(){return this._Commission}};var Qt=class{DeliveryEntityID;Type;NewOrderID;constructor(){this.DeliveryEntityID="",this.Type=3}};var G=class{Order;Invoice;Shipping;Action;Payments;Items;CartItems;ContactName;SplitParkLabel;get cartQuantity(){let e=0;for(let t of this.CartItems)e+=t.Quantity;return e}constructor(){this.Order=new un,this.Invoice=new Bt,this.Shipping=new dn,this.Action=new Qt,this.Payments=Array(),this.Items=Array(),this.CartItems=Array(),this.ContactName=""}get TotalPaidAmount(){let e=0;return this.Payments.forEach(t=>{e+=t.PaidAmount}),e}get RedeemableAmount(){let e=this.CartItems.filter(t=>t.Variant.PaymentTypeID!=1);return this.GetAmountByCart(e)}get TotalQuantity(){let e=0;return this.CartItems.forEach(t=>{t.PromotionGift||(e+=t.Quantity)}),e}get CashOnlyAmount(){let e=this.CartItems.filter(t=>t.Variant.PaymentTypeID==1);return this.GetAmountByCart(e)}get PointOnlyAmount(){let e=this.CartItems.filter(t=>t.Variant.PaymentTypeID==2);return this.GetAmountByCart(e)}get PrepaidPackageItem(){return this.CartItems.filter(t=>t.Variant.TypeID==10)}GetAmountByCart(e){let t=0;return e.forEach(i=>{t+=i.Total}),t=t*(100-this.Order.Discount)/100,t=t*(100-this.Order.Discount2)/100,t}getRewards(){return this.CartItems.filter(t=>t.PromotionGift)}};Xe([it(()=>un)],G.prototype,"Order",2),Xe([it(()=>Bt)],G.prototype,"Invoice",2),Xe([it(()=>dn)],G.prototype,"Shipping",2),Xe([it(()=>Qt)],G.prototype,"Action",2),Xe([it(()=>ze)],G.prototype,"Payments",2),Xe([it(()=>hi)],G.prototype,"Items",2),Xe([it(()=>Se)],G.prototype,"CartItems",2);var bi=class{Success;Message;message;ObjectID;SalesOrderID;OutDeliveryID;Contact;LoyaltyPoint;InvoiceNumber;Creator;OrderTimeString;PrintMode;PaymentStateID;PaymentStateLabel;Final;constructor(){this.Success=!0,this.Message="",this.ObjectID="",this.SalesOrderID="",this.OutDeliveryID="",this.Contact=null,this.LoyaltyPoint="",this.InvoiceNumber="",this.Creator="",this.OrderTimeString="",this.PrintMode=0,this.PaymentStateID=0,this.PaymentStateLabel="",this.Final=0}};var Ot=class n{constructor(e,t,i,o){this.httpService=e;this._localDataService=t;this._onlineStatusService=i;this._toastrService=o;this._onlineStatusService.getOnlineStatus$().subscribe(r=>{this.isOnline=r})}_Data=new Ce(null);Data$=this._Data.pipe(ke(),re(e=>e!==null));isOnline;get Data(){return this._Data.value}pushNewValue(e){this._Data.next(e)}getSalesOrderPrint(e){return this.httpService.post("/API/POS/GetSalesOrderPrint",{TemplateID:e})}submitOrder(e,t){let i=this.generatePOSDataForSubmission(e,this.isOnline);if(this.isOnline)return this.submitOnline(i).pipe(this.handleTimeOutError(i));if(t.ModuleSell.EnableOfflineTransaction)return this._localDataService.syncOrder(i).pipe($(()=>this.generateCompleteData(i)));this._toastrService.warning("Offline order is not Supported!","Info!")}uploadOfflineOrder(e){return this._localDataService.uploadSingleOrder(e).pipe(et(t=>t?.message?.includes("objectStore does not exists")?this.submitOnline(e):pt(()=>t)))}submitOnline(e){return this.httpService.post(Q.SubmitOrder,e,Vn.pos.submitOrderTimeout)}handleTimeOutError(e){return Zt(et(t=>{if(t instanceof ei||t?.name=="TimeoutError"){let i=this.generateCompleteData(e);this.pushNewValue(i)}throw t}))}generatePOSDataForSubmission(e,t=!0){let i=Object.assign(new G,e);i.Items=[],i.Order.CustomerID==null&&(i.Order.CustomerID=h.GuidEmpty),i.Order.SalesID==null&&(i.Order.SalesID=h.GuidEmpty);let o=1;i.Payments=i.Payments.map(c=>(c.Date=i.Order.Date,c.Index=o,o++,delete c.TypeID,c));let r=1;for(let c of i.CartItems){let u=new hi;u.ID=c.ID,u.VariantID=c.VariantID,u.Quantity=c.Quantity,u.Cost=c.Cost,u.Price=c.Price,u.Discount=c.Discount,u.DiscountAmount=c.DiscountAmount,u.Note=c.Note,u.Taxable=c.Variant.Taxable,u.LoyaltyPoint=c.LoyaltyPoint,u.UnitCost=c.Cost,u.UnitPrice=c.Price,u.UnitPriceOriginal=c.UnitPriceOriginal,u.UnitExpense=c.UnitExpense,u.EntityID=c.EntityID,u.Index=r,u.UnitQuantity=c.UnitQuantity,u.PriceTypeID=c.PriceTypeID,u.PriceNote=c.PriceNote,u.Splited=c.SplitQuantity>0,u.SplitQuantity=c.SplitQuantity,u.InventoryTypeID=c.Variant.TypeID,u.SalesID="",u.Serial=c.Serial,c.SalesID&&(u.SalesID=c.SalesID),delete c.CouponDiscount,i.Items.push(u),r++}return t?(delete i.CartItems,delete i.Order.ClientTimestamp):i.Order.ClientTimestamp=new Date,i}generateCompleteData(e){let t=new bi;return t.InvoiceNumber=e.Order.Number,t.OrderTimeString=new Date().toString(),t.PaymentStateID=e.Action?.Type,t.PaymentStateLabel="Offline",t.Success=!0,t.OutDeliveryID=e.Action.DeliveryEntityID,t}GetReturnInvoice(e,t){return this.httpService.get(Q.ReturInvoice,[{key:"EntityID",value:t},{key:"Number",value:e}])}GetInvoiceBySoID(e){return this.httpService.get(Q.GetPOSDataByID,[{key:"ID",value:e}])}UploadCSV(e,t){let i={CartItems:e,EntityID:t};return this.httpService.post(Q.UploadCsv,i)}sendEmail(e,t){return new Promise((i,o)=>{this._localDataService.isProductFromServer().subscribe(r=>{if(r){let c={invoiceID:t,email:e};this.httpService.post(Q.SendInvoiceEmail,c).subscribe({next:u=>{i(u)},error:u=>{o(u)}})}else o(ee.wrongOfflineAction)})})}sendWhatsaap(e,t){let i={InvoiceID:e,PhoneNumber:t};return this.httpService.post(Q.SendInvoiceWhatsapp,i)}createCustomerByInvoice(e,t){let i={InvoiceID:e,Mobile:t};return this.httpService.post(Q.CreateCustomerInvoice,i)}saveCommission(e,t){let i={SOID:e,commission:t};return this.httpService.POSText("/API/Transaction/SetCommission",i)}generateReceiptA4(e){let t={ID:e};return this.httpService.post(Q.InvoiceA4,t)}getVacant(e){return this.httpService.get(Q.GetVacant,[{key:"EntityID",value:e}])}static \u0275fac=function(t){return new(t||n)(g(Ie),g(ye),g(de),g(B))};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var J=class n{constructor(e,t,i){this._localDataService=e;this._onlineStatusService=t;this._httpService=i;this._onlineStatusService.getOnlineStatus$().subscribe(o=>{this.isOnline=o})}_Data=new Ce(null);Data$=this._Data.asObservable().pipe(re(e=>e!==null),ke());isOnline;get Data(){return this._Data.value}pushNewValue(e){this._Data.next(e)}requestObservable(){return this.isOnline?this._httpService.get(Q.GetPOSStorage).pipe($(e=>({data:e,type:"Online"}))):this._localDataService.getPOSStorage().pipe(re(e=>e!=null),$(e=>({data:e,type:"Offline"})))}getOutletName(e){return this.Data.Entities.find(i=>i.ID==e)?.Name}static \u0275fac=function(t){return new(t||n)(g(ye),g(de),g(Ie))};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var be=class n{constructor(e){this.roleService=e;this.pushNewValue(new je(e))}_Data=new Ce(new je(null));get Data(){return this._Data.value}Data$=this._Data.asObservable();pushNewValue(e){this._Data.next(e)}static \u0275fac=function(t){return new(t||n)(g(pi))};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var Gt=class{ID;Code;EntityID;Name;Description;Start;StartDisplay;State;Open;CashierID;OpeningCash;EntityName;LoginID;Active;CustomerDisplayEnabled;OvoConfigurationID;CustomerDisplayID;ListImage;Suspended};var Go=n=>({active:n}),qo=n=>({gray:n});function $o(n,e){if(n&1){let t=I();a(0,"span",17),b("click",function(o){C(t);let r=d().$implicit;return d().closeRegister(r),v(o.stopPropagation())}),s()}}function Jo(n,e){n&1&&(a(0,"div")(1,"span",18),m(2,"VACANT"),s()())}function zo(n,e){if(n&1&&(a(0,"div")(1,"span",19),_(2,"i",20),a(3,"font"),m(4),s()(),a(5,"span",21),_(6,"i",22),a(7,"font"),m(8),s()()()),n&2){let t=d().$implicit;l(4),D(t.LoginID),l(4),O("",t.StartDisplay.split(" ")[3]," - Now")}}function Yo(n,e){if(n&1){let t=I();a(0,"div",9)(1,"div",10)(2,"div",11)(3,"h5",12),b("click",function(){let o=C(t).$implicit,r=d();return v(r.select(o))}),a(4,"span"),_(5,"i",13),m(6),y(7,"limitTo"),s(),f(8,$o,1,0,"span",14),s(),a(9,"div",15),b("click",function(){let o=C(t).$implicit,r=d();return v(r.select(o))}),f(10,Jo,3,0,"div",16)(11,zo,9,2,"div",16),s()()()()}if(n&2){let t=e.$implicit,i=d();l(),p("ngClass",t.Active?"active":""),l(),p("ngClass",F(11,Go,(t==null?null:t.ID)==(i.selectedRegister==null?null:i.selectedRegister.ID))),l(),p("ngClass",F(13,qo,t!=i.selectedRegister)),l(3),D(ie(7,8,t.Name,15)),l(2),p("ngIf",t.State!="Close"),l(),p("ngSwitch",t.State),l(),p("ngSwitchCase","Close"),l(),p("ngSwitchCase","Open")}}var Si=class n{constructor(e,t,i,o,r){this._dialogRef=e;this._outletService=t;this._posService=i;this._userRoleService=o;this.router=r}originalSelectedRegister=null;registers;searchInput="";selectedRegister=new Gt;modalConfig=new Z;role;get AppConfigJSON(){return this._posService.Data.AppConfigJSON}destroy$=new Ae;ngOnInit(){this.subscribeToObsChanges(),this.initModalConfig()}subscribeToObsChanges(){this._posService.Data$.pipe(Pe(this.destroy$)).subscribe(e=>{this.registers=e.Registers}),this._outletService.Data$.pipe(Pe(this.destroy$)).subscribe(e=>{this.selectedRegister=this.findOutletRegisterById(e.RegisterID),this.originalSelectedRegister=this.selectedRegister?Yt({},this.selectedRegister):null}),this._userRoleService.Data$.pipe(Pe(this.destroy$)).subscribe(e=>{this.role=e})}findOutletRegisterById(e){let t=this.registers.find(i=>i.ID===e);return t||new Gt}initModalConfig(){this.modalConfig.hideClose=!1,this.modalConfig.hideCancel=!1,this.modalConfig.bodyScrollable=!0,this.modalConfig.title="Choose an outlet"}ngOnDestroy(){this.destroy$.next(!0),this.destroy$.complete()}close(){this._dialogRef.close()}onOk(){if(this.selectedRegister.ID==null){alert("Please select a register first!");return}this._outletService.pushNewRegister(this.selectedRegister),this._dialogRef.close({selectedRegister:this.selectedRegister,openStartingCashDialog:this.selectedRegister.ID!=this.originalSelectedRegister?.ID})}select(e){if(this.AppConfigJSON.ModuleShift.Closure.Enabled)if(this.selectedRegister.ID!=null&&this.selectedRegister.Open&&e.CashierID==null)confirm("You already have an active register with "+this.selectedRegister.Name+`!
2
2
  Do you want to end your session?`)&&(this.close(),this.router.navigate(["menu/Shift/Main/My_Shift"],{queryParams:{RegisterID:e.ID}}));else if(!e.Open||this.selectedRegister.ID==e.ID)this.selectedRegister=e;else{if(this.role.SellEditor==!1){alert("You cannot end shift for Register "+e.Name+" - Unauthorized Access");return}alert("This Register has already active register, Are you sure you want to end this register?"),this.close(),this.router.navigate(["/menu/Shift/Main/My_Shift"],{queryParams:{RegisterID:e.ID}})}else this.selectedRegister=e}closeRegister(e){let t=this.selectedRegister.ID;if(this.role.SellEditor==!1){alert("You cannot end shift for Register "+e.Name+" - Unauthorized Access");return}t==e.ID?this.router.navigate(["/menu/Shift/Main/My_Shift"]):this.router.navigate(["/menu/Shift/Main/My_Shift"],{queryParams:{RegisterID:e.ID}}),this.close()}static \u0275fac=function(t){return new(t||n)(S(K),S(te),S(J),S(be),S(Nn))};static \u0275cmp=E({type:n,selectors:[["pos-modal-register"]],standalone:!1,decls:11,vars:7,consts:[[3,"onOk","onCancel","onClose","config"],[1,"ms-0","mb-8",2,"width","200px",3,"hidden"],[1,"input-group","mb-3"],[1,"input-group-text","txtFilter"],["aria-hidden","true",1,"fa","fa-magnifying-glass"],["data-cy","SearchOutlet","type","text","placeholder","Filter by Name","aria-label","Search",1,"txtFilter","form-control","border-start-0",3,"ngModelChange","ngModel"],[1,"container"],[1,"row",2,"width","600px"],["class","col-4","data-cy","registers",4,"ngFor","ngForOf"],["data-cy","registers",1,"col-4"],[1,"card","border-0",3,"ngClass"],[1,"card-body","p-0",3,"ngClass"],[1,"card-title","mb-0",3,"click","ngClass"],[1,"fa-solid","fa-house","pe-1","fs-6"],["class","fa fa-xmark-circle fa-lg position-absolute","style","text-shadow: 0 1px 0 #afafaf; right: 5px; top: 16px",3,"click",4,"ngIf"],[1,"card-text","px-0","py-2",3,"click","ngSwitch"],[4,"ngSwitchCase"],[1,"fa","fa-xmark-circle","fa-lg","position-absolute",2,"text-shadow","0 1px 0 #afafaf","right","5px","top","16px",3,"click"],[1,"idle"],[1,"cashier"],["aria-hidden","true",1,"fa","fa-user","pe-2"],[1,"open"],["aria-hidden","true",1,"fa-regular","fa-clock","pe-2"]],template:function(t,i){t&1&&(a(0,"modal-material",0),b("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,"span",3),_(5,"i",4),s(),a(6,"input",5),V("ngModelChange",function(r){return N(i.searchInput,r)||(i.searchInput=r),r}),s()()(),a(7,"div",6)(8,"div",7),f(9,Yo,12,15,"div",8),y(10,"FilterByName"),s()()()()),t&2&&(p("config",i.modalConfig),l(2),p("hidden",i.registers.length<=6),l(4),k("ngModel",i.searchInput),l(3),p("ngForOf",ie(10,4,i.registers,i.searchInput)))},dependencies:[Fe,ve,oe,In,xn,De,_e,Me,X,ui,no],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}.col-4[_ngcontent-%COMP%]{list-style:none;margin:0;padding:0;display:flex;flex-wrap:wrap!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%]{width:180px;min-height:95px;margin-right:17px;margin-bottom:17px;position:relative}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%]{display:block;outline:0;border:1px solid #B1AAAA;border-radius:5px;cursor:pointer}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] h5[_ngcontent-%COMP%]{height:30px;border-radius:4px;padding:5px 10px;color:#fff;background:#b1aaaa;overflow:hidden}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] h5[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{margin-right:5px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%]:hover, .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.active[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.vacant[_ngcontent-%COMP%]{background:#ffffe1;border:1px solid #89b03e}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%]:hover > h5[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.active[_ngcontent-%COMP%] > h5[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.vacant[_ngcontent-%COMP%] > h5[_ngcontent-%COMP%]{background:#89b03e}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%]:hover{border:1px solid #c9302c}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%] > h6[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%]:hover > h6[_ngcontent-%COMP%]{background:#c9302c!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%] span.alias[_ngcontent-%COMP%]{background:#c9302c}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%]:hover{background:#fff}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%]{border:1px solid #f6a828}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%] > h6[_ngcontent-%COMP%]{background:#f6a828!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%]:hover{border:1px solid #f6a828;background:#fff}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%]:hover > strong[_ngcontent-%COMP%]{background:#f6a828!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%] span.alias[_ngcontent-%COMP%]{background:#f6a828}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%] div[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{font-size:.75rem!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%]{height:80px;padding:15px 10px;position:relative}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{display:block;font-weight:400;font-size:.875rem;width:100%;margin-bottom:5px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span[_ngcontent-%COMP%]:first-child{margin-top:-10px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span[_ngcontent-%COMP%]:last-child{margin-bottom:0}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span.alias[_ngcontent-%COMP%]{text-align:center;position:absolute;bottom:0;right:0;width:auto;background-color:#b1aaaa;border-radius:3px;padding:2px 5px;color:#fff;display:none!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span.idle[_ngcontent-%COMP%]{display:block;font-size:1.25rem;text-align:center}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{position:absolute;width:27px;height:28px;cursor:pointer;top:5px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > span[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{color:#000}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]:last-of-type{right:-5px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]:nth-last-of-type(2){right:15px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{bottom:20px;right:5px;position:absolute}.col-4[_ngcontent-%COMP%] .duration[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{border:1px solid!important;position:absolute;bottom:-3px;left:58px;background:#fff;border-radius:5px}"]})};var Ko=["inputCash"],Pi=class n{constructor(e,t){this.dialogRef=e;this.data=t;this.generateModalTitle$.subscribe()}registerService=w(te);loadPOSService=w(J);register=this.registerService.Data;username=this.loadPOSService?.Data?.UserName;amount=q(0);config=new Z;currentRegisterName;generateModalTitle$=this.registerService.Data$.pipe(re(e=>h.IsNotEmpty(e)),ae(()=>{let e=this.registerService.getOutletRegister(),t=e?.Name?.length>18?`${e?.Name?.substring(0,18)}...`:e?.Name;this.config.title="Open Shift",this.currentRegisterName=t}),se());today=new Date;inputCashEl;ngOnInit(){this.config.customWidth="350px",this.config.hideCancel=!0}ngAfterViewInit(){this.inputCashEl?.nativeElement?.focus()}onOk(){this.dialogRef.close({amount:this.amount()})}static \u0275fac=function(t){return new(t||n)(S(K),S(me))};static \u0275cmp=E({type:n,selectors:[["POS-modal-opening-cash"]],viewQuery:function(t,i){if(t&1&&kt(Ko,5),t&2){let o;Vt(o=Ft())&&(i.inputCashEl=o.first)}},standalone:!1,decls:25,vars:8,consts:[["inputCash",""],[3,"onOk","onCancel","onClose","config"],[1,"table","fs-5","text"],[1,"py-3"],[1,"text-end","pe-3"],[1,"py-4"],[1,"text-end"],["data-cy","InputCash","autoNum","",1,"border","form-control-lg","text-end","w-100",3,"ngModelChange","ngModel"]],template:function(t,i){if(t&1){let o=I();a(0,"modal-material",1),b("onOk",function(){return C(o),v(i.onOk())})("onCancel",function(){return C(o),v(i.dialogRef.close())})("onClose",function(){return C(o),v(i.dialogRef.close())}),a(1,"content")(2,"table",2)(3,"tr")(4,"td",3),m(5,"Outlet Register"),s(),a(6,"td",4),m(7),s()(),a(8,"tr")(9,"td",5),m(10,"Current User"),s(),a(11,"td",4),m(12),s()(),a(13,"tr")(14,"td",5),m(15,"Starting Time"),s(),a(16,"td",4),m(17),y(18,"date"),s()(),a(19,"tr")(20,"td",3),m(21,"Starting Cash"),s(),a(22,"td",6)(23,"input",7,0),V("ngModelChange",function(c){return C(o),N(i.amount,c)||(i.amount=c),v(c)}),s()()()()()()}t&2&&(p("config",i.config),l(7),D(i.currentRegisterName),l(5),D(i.username),l(5),D(ie(18,5,i.today,"EEEE, HH:mm")),l(6),k("ngModel",i.amount))},dependencies:[De,_e,Me,X,bt,Je],styles:[".table-title-width[_ngcontent-%COMP%]{width:120px}"]})};var Oi=class{OrderNumberElement;InvoiceNumberElement;NewOrderID};var Dt=class n{constructor(e,t,i){this._httpService=e;this._onlineStatusService=t;this._localDataService=i;this._onlineStatusService.getOnlineStatus$().subscribe(o=>{this.isOnline=o})}isOnline;GenerateNumber(e,t){if(this.isOnline)return this._httpService.get(Q.GenerateNumber,[{key:"EntityID",value:e},{key:"TypeID",value:1}]);{let i=new Oi;return h.IsNotEmpty(t.NumberElement)&&(t.NumberElement.Seed+=1),h.IsNotEmpty(t.InvoiceNumberElement)&&(t.InvoiceNumberElement.Seed+=1),i.InvoiceNumberElement=t.InvoiceNumberElement,i.OrderNumberElement=t.NumberElement,i.NewOrderID=h.Guid_NewGuid(),Ee(i)}}findRegisterById(e){return new Promise(t=>{this._localDataService.isConfigFromServer().subscribe(i=>{i?this._httpService.get(Q.GetRegisterInfo,[{key:"RegisterID",value:e}]).subscribe(o=>{t(o)}):this._localDataService.findRegisterByID(e).subscribe(o=>{t(o)})})})}recordOpeningCash(e){return Xt(this._httpService.post("/API/POS/RecordOpeningCash",e))}static \u0275fac=function(t){return new(t||n)(g(Ie),g(de),g(ye))};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var te=class n{constructor(e,t,i,o,r,c){this._signalRClientService=e;this._matDialog=t;this._posHttpResponseService=i;this._CoreHttpService=o;this._toastrService=r;this._roleService=c}datePipe=w(Je);_Data=new Ce(null);Data$=this._Data.asObservable().pipe(re(e=>e!==null),ke());get Data(){return this._Data.value}getSalesname(e){return this.Data&&this.Data.ListSales?this._Data.value.ListSales.find(t=>t.ID==e)?.Name:""}setActiveRegisterFromOptions(e,t){let o=this._posHttpResponseService.Data.AppConfigJSON.ModuleShift.Closure.Enabled;if(e.length>1){let r=e.find(c=>c.LoginID==t);if(r)this.pushNewRegister(r);else{let c=this.getOutletRegisterFromLocalStorage(),u=this.Data?.RegisterID?this.Data.RegisterID:c?.ID;e.some(A=>A.ID==u)?o?this.openChooseRegisterModal():this.initRegisterFromLocalStorage():this.openChooseRegisterModal()}}e.length==1&&(this.pushNewRegister(e[0]),h.IsEmpty(e[0].LoginID)&&h.IsEmpty(e[0].CashierID)&&this.openOpeningCashModal(e[0].ID)),e.length==0&&this._toastrService.warning("You do not have access to any OUTLET","Warning")}openChooseRegisterModal(){this._matDialog.open(Si,{id:"registerModal",disableClose:!0}).afterClosed().pipe(re(e=>h.IsNotEmpty(e?.selectedRegister))).subscribe(e=>{e.selectedRegister&&this.openOpeningCashModal(e.selectedRegister.ID)})}openOpeningCashModal(e){this._posHttpResponseService.Data.AppConfigJSON.ModuleShift.Closure.Enabled&&this._matDialog.open(Pi,{disableClose:!0}).afterClosed().pipe(re(o=>h.IsNotEmpty(o))).subscribe(o=>{let r={RegisterID:e,OpAmount:o.amount};this._CoreHttpService.recordOpeningCash(r).then(()=>{this.updateRegisterList(r)})})}updateRegisterList(e){let i=this._posHttpResponseService.Data.Registers.map(r=>r.ID==e.RegisterID?this.mapRegisterAsActiveRegister(r,e):r),o=this._posHttpResponseService.Data;o.Registers=i,this._posHttpResponseService.pushNewValue(o)}mapRegisterAsActiveRegister(e,t){let i=localStorage.getItem("AccountInfo");if(i){let r=JSON.parse(i);e.LoginID=r.UserName}e.OpeningCash=t.OpAmount,e.Open=!0,e.State="Open";let o=this.datePipe.transform(new Date,"dd MM yyyy HH:mm");return e.StartDisplay=o,e}initRegisterFromLocalStorage(){if(this._roleService.Data.DeleteItem==!1){let t=this.getOutletRegisterFromLocalStorage();t&&this.pushNewRegister(t)}}pushNewRegister(e){let t=this._Data.value,i=t?t.RegisterID:null;i!=e.ID&&this._CoreHttpService.findRegisterById(e.ID).then(o=>{o.RegisterCode=e.Code,o.DefaultPrintTemplate=o.PrintTemplate,this._signalRClientService.SubscribeGroup(o.RegisterID,i),this.saveOutletRegisterToLocalStorage(e),this.pushNewValue(o)})}getOutletRegister(){let e=this.Data.RegisterID;return this._posHttpResponseService.Data.Registers.find(o=>o.ID==e)}pushNewValue(e){this._Data.next(e)}saveOutletRegisterToLocalStorage(e){if(this._roleService.Data.DeleteItem==!1){let i=JSON.stringify(e);localStorage.setItem("outlet_register",i)}}getOutletRegisterFromLocalStorage(){let e=this._roleService.Data.DeleteItem,t=localStorage.getItem("outlet_register"),i=null;return t&&(e?localStorage.removeItem("outlet_register"):i=JSON.parse(t)),i}findOutletRegisterById(e){return this._posHttpResponseService.Data.Registers.find(o=>o.ID===e)}static \u0275fac=function(t){return new(t||n)(g(tt),g(xe),g(J),g(Dt),g(B),g(be))};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};function Zo(n,e){if(n&1&&(a(0,"span",5),m(1),y(2,"number"),s()),n&2){let t=d(3);l(),O("-",M(2,1,t.coupon.Amount),"%")}}function Xo(n,e){if(n&1&&(a(0,"span",5),m(1),y(2,"number"),s()),n&2){let t=d(3);l(),O(" -",M(2,1,t.coupon.Amount)," ")}}function er(n,e){if(n&1){let t=I();a(0,"button",9),b("click",function(){C(t);let o=d().$implicit,r=d(2);return v(r.onRemoveCouponDiscount(o))}),m(1," Remove "),s()}}function tr(n,e){if(n&1){let t=I();a(0,"button",10),b("click",function(){C(t);let o=d().$implicit,r=d(2);return v(r.onApplyCouponDiscount(o))}),m(1," Apply "),s()}if(n&2){let t=d(3);p("disabled",t.hasAppliedCouponDiscount())}}function ir(n,e){if(n&1&&(a(0,"tr")(1,"td"),m(2),s(),a(3,"td"),m(4),s(),a(5,"td",4),m(6),y(7,"number"),s(),a(8,"td",4),f(9,Zo,3,3,"span",5)(10,Xo,3,3,"span",5),s(),a(11,"td",6),f(12,er,2,0,"button",7)(13,tr,2,1,"button",8),s()()),n&2){let t=e.$implicit,i=d(2);l(2),D(t==null||t.Variant==null?null:t.Variant.Name),l(2),D(t==null||t.Variant==null?null:t.Variant.Code),l(2),D(M(7,5,t.UnitPrice)),l(3),R((i.coupon==null||i.coupon.Requirement==null?null:i.coupon.Requirement.Type)==i.couponType.DiscountPercentage?9:10),l(3),R((t==null?null:t.CouponDiscount)>0?12:13)}}function nr(n,e){if(n&1&&ft(0,ir,14,7,"tr",null,gt),n&2){let t=d();ht(t.eligibleItems())}}function or(n,e){n&1&&(a(0,"tr")(1,"td",11),_(2,"app-empty-state",12),s()())}var Di=class n{constructor(e){this.data=e;this.coupon=this.data.coupon,this.initModalConfig(),this.initEligibleItems()}dialogRef=w(K);config;eligibleItems=q([]);coupon;couponType=Ht;hasAppliedCouponDiscount=q(!1);initModalConfig(){this.config=new Z,this.config.title="Choose Item to Apply Discount",this.config.hideFooter=!0}initEligibleItems(){let e=this.data.coupon?.ApplyToProduct.map(t=>t.ID);e&&(this.eligibleItems.update(()=>this.data.cartItems.filter(i=>e.includes(i.VariantID))),this.hasAppliedCouponDiscount.update(()=>this.eligibleItems().some(t=>t.CouponDiscount>0)))}onApplyCouponDiscount(e){let t=[e];this.hasAppliedCouponDiscount.update(()=>!0),this.dialogRef.close(t)}onRemoveCouponDiscount(e){this.eligibleItems.update(t=>{let i=t.findIndex(o=>o.VariantID===e.VariantID);return i>-1&&(t[i].Discount=0,t[i].CouponDiscount=0),t}),this.hasAppliedCouponDiscount.update(()=>!1)}onClose(){this.dialogRef.close()}static \u0275fac=function(t){return new(t||n)(S(me))};static \u0275cmp=E({type:n,selectors:[["app-modal-coupon-selected-item"]],decls:17,vars:2,consts:[[3,"onCancel","onClose","config"],[1,"table","table-bordered"],[1,"thead-light"],["scope","col"],[1,"text-end"],[1,"text-danger"],[1,"text-center"],[1,"btn","btn-sm","btn-danger"],[1,"btn","btn-sm","btn-success",3,"disabled"],[1,"btn","btn-sm","btn-danger",3,"click"],[1,"btn","btn-sm","btn-success",3,"click","disabled"],["colspan","5"],["title","No eligible products","message","No products in the cart qualify for coupon use"]],template:function(t,i){t&1&&(a(0,"modal-material",0),b("onCancel",function(){return i.onClose()})("onClose",function(){return i.onClose()}),a(1,"content")(2,"table",1)(3,"thead",2)(4,"tr")(5,"th",3),m(6,"Name"),s(),a(7,"th",3),m(8,"Code"),s(),a(9,"th",3),m(10,"Price"),s(),a(11,"th",3),m(12,"Discount"),s(),_(13,"th",3),s()(),a(14,"tbody"),f(15,nr,2,0)(16,or,3,0,"tr"),s()()()()),t&2&&(p("config",i.config),l(15),R(i.eligibleItems().length!==0?15:16))},dependencies:[ce,z,yt,X,so],encapsulation:2})};var $t=(r=>(r[r.cash=1]="cash",r[r.card=2]="card",r[r.emoney=3]="emoney",r[r.other=4]="other",r[r.ECR=99]="ECR",r))($t||{});var L=class n{constructor(e,t,i){this._OrderHttpService=e;this._customerHttpService=t;this._toastrService=i}_Data=new Ce(new G);transaction_id;Data$=this._Data.asObservable();get Data(){return this._Data.value}pushNewValue(e){if(e)this._Data.next(e);else{let t=this.Data;this._Data.next(t)}}submitOrder(e){return new Promise((t,i)=>{this.checkTransactionId(),this._OrderHttpService.submitOrder(this.Data,e).subscribe({next:o=>{t(o)},error:o=>{this.Data.Items=[],i(o)}})})}uploadOfflineOrder(){return this.checkTransactionId(),this._OrderHttpService.uploadOfflineOrder(this.Data)}checkTransactionId(){let t=this.Data.Payments.find(i=>i.TypeID==3);h.IsNotEmpty(t)&&h.IsEmpty(this.transaction_id)&&this._toastrService.warning("Midtrans transaction_id is empty. Please verify manually!","Mobile Payment Failure")}updateCustomerID(e){return this.Data.Order.CustomerID=e,this.pushNewValue(this.Data),new Promise((t,i)=>{this._customerHttpService.GetPrivilegeByID(e,this.Data.Order.EntityID).subscribe({next:o=>{this._customerHttpService.Data=o,this.pushNewValue(this.Data),t(o)},error:o=>{this.Data.Order.CustomerID=null,this.Data.ContactName=null;let r=o.error?.Message;o.status==409?this._toastrService.warning(r,"Warning"):this._toastrService.error(r,`API Error - ${o.status}`),i(o)}})})}static \u0275fac=function(t){return new(t||n)(g(Ot),g(Te),g(B))};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var ot=class{ModuleSell;ApplicationLoyalty;ApplicationMath;CoreDefaults;ModuleDelivery;ApplicationParkAndRetrieve;ApplicationRegisterClosure;PaymentConfigGopay;PaymentConfigLink;PrintConfigInvoice;CorePrint;PaymentConfigEmpatKali;ApplicationSettings;PrintConfigGeneral;ModuleProducts;ModuleContact;ApplicationTransactionNumbering;ModuleOrders;ModuleShift;ModuleBuy;ModuleAdjustment;TadaCouponVisible;CouponRedemptionType;ProviderOption};var ne=class n{constructor(e,t,i,o){this._orderDataService=e;this._posService=t;this.POSMATH=i;this.decimalPipe=o;this._orderDataService.Data$.pipe(Y(r=>this._posService.Data$.pipe($(c=>({appConfig:c.AppConfigJSON,salesOrder:r}))))).subscribe(r=>{this.salesOrderData=r.salesOrder,this.appConfigJSON=r.appConfig,this.calculateDiscountAmount(),this.pushNewValue(this.grandTotal)})}_Data=new Ce(0);Data$=this._Data.asObservable().pipe(ke());tax=new uo;discountAfterTax=0;currencySymbol="Rp";get Data(){return this._Data.value}salesOrderData=new G;appConfigJSON=new ot;pushNewValue(e){this._Data.next(e)}get grandTotal(){let e=this.TotalAfterSurcharge;return isNaN(e)?0:e}setDecimalDigit(e){let t=this.decimalPipe.transform(e,"1.0-4");return e=parseFloat(t.split(",").join("")),e}get TotalAfterTax(){let e=this.TaxAmount,t=this.TotalBeforeTax+e;return t=this.POSMATH.Round(t,this.appConfigJSON.ApplicationMath.RoundingDigit.DecimalPlaceValue,this.appConfigJSON.ApplicationMath.RoundingDigit.RoundAlgorithm),t}get TotalBeforeTax(){let e=this.tax?.CalculationTypeID===1,t=0;return e?t=this.DiscountTotal-this.TaxAmount:t=this.DiscountTotal,t}get TotalAfterSurcharge(){let e=this.TotalAfterTax+this.SurchargeAmount;return this.POSMATH.Round(e,this.appConfigJSON.ApplicationMath.RoundingDigit.DecimalPlaceValue,this.appConfigJSON.ApplicationMath.RoundingDigit.RoundAlgorithm)}get TotalAfterDiscountTaxable(){return this.GrossTotalTaxable-this.DiscountTotal}get TaxAmount(){if(this.tax!=null){let e=0,t=this.appConfigJSON.ApplicationMath.RoundingTaxDigit.DecimalPlaceValue,i=this.appConfigJSON.ApplicationMath.RoundingTaxDigit.RoundAlgorithm,o=this.GrossTotalTaxable;return this.tax.CalculationTypeID==1?e=this.tax.Rate/(100+this.tax.Rate)*o:e=this.tax.Rate/100*o,e=this.POSMATH.Round(e,t,i),e}else return 0}get SurchargeAmount(){return this.TotalAfterTax*this.salesOrderData.Invoice.SurchargePcg/100}get Discount1Amount(){return this.GrossTotal*this.salesOrderData.Order.Discount/100}get AfterDiscount1Amount(){return this.GrossTotal-this.Discount1Amount}get Discount2Amount(){return this.AfterDiscount1Amount*this.salesOrderData.Order.Discount2/100}get AfterDiscount2Amount(){return this.AfterDiscount1Amount-this.Discount2Amount}get DiscountTotal(){return this.AfterDiscount2Amount-this.salesOrderData.Order.DiscountAmount}calculateDiscountAmount(){let e=this.salesOrderData.Order.DiscountAmount,t=0;this.AfterDiscount2Amount>=0&&e>0&&e>this.AfterDiscount2Amount&&(t=this.AfterDiscount2Amount),t!==0&&t<=e&&this.GrossTotal!==0&&(e=t),this.salesOrderData.Order.DiscountAmount=e}get GrossTotal(){return this.sum(this.salesOrderData.CartItems,"Total")}get GrossTotalTaxable(){let e=this.salesOrderData.CartItems.filter(i=>i.Taxable),t=this.sum(e,"Total");if(e.length!==0){let i=this.calculateDiscountTaxableItem(e);t=t*(100-this.salesOrderData.Order.Discount)/100,t=t*(100-this.salesOrderData.Order.Discount2)/100,t=t-i}return t}calculateDiscountTaxableItem(e){let t=this.GrossTotal,i=this.salesOrderData.Order.DiscountAmount,o=0,r=0,c=0,u=0;for(let P of e)o=P.getItemAfterDiscount/t,r=o*i,u=r*P.Quantity,c+=u;return c}get GrossTotalNonTaxable(){let e=this.salesOrderData.CartItems.filter(i=>i.Taxable==!1),t=this.sum(e,"Total");return t=t*(100-this.salesOrderData.Order.Discount)/100,t=t*(100-this.salesOrderData.Order.Discount2)/100,t=t-this.salesOrderData.Order.DiscountAmount,t}sum(e,t){let i=e.reduce((o,r)=>o+r[t],0);return i=this.setDecimalDigit(i),i}GetPointOnlyAmount(){let e=this.salesOrderData.CartItems.filter(t=>t.Variant.PaymentTypeID==2);return this.GetAmountByCart(e)}GetCashOnlyAmount(){let e=this.salesOrderData.CartItems.filter(t=>t.Variant.PaymentTypeID==1);return this.GetAmountByCart(e)}GetCashAndPointAmountCart(){let e=this.salesOrderData.CartItems.filter(t=>t.Variant.PaymentTypeID!=1);return this.GetAmountByCart(e)}GetAmountByCart(e){let t=this.sum(e,"Total");return t=t*(100-this.salesOrderData.Order.Discount)/100,t=t*(100-this.salesOrderData.Order.Discount2)/100,t}calculateGrossTotal(e){return this.sum(e,"Total")}static \u0275fac=function(t){return new(t||n)(g(L),g(J),g(go),g(z))};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var Mi=class{Code;Provider;EntityID;Customer;ShoppingCart};var Ii=class n{salesOrderService=w(L);registerService=w(te);customerService=w(Te);orderCalculator=w(ne);generateRedeemCouponDto(e,t){let i=new Mi,o=this.registerService.Data?.EntityID;return i.Code=e,i.Provider=t,i.ShoppingCart={Amount:this.orderCalculator.Data,Items:this.generateItems()},i.EntityID=o,i.Customer=this.generateCustomer(t),i}generateItems(){return this.salesOrderService.Data.CartItems.map(i=>({Price:i.Price,Quantity:i.Quantity,VariantID:i.VariantID,Code:i?.Variant?.Code}))}generateCustomer(e){let t=this.customerService.Data,i=this.salesOrderService?.Data?.Order?.CustomerID,o=null;return h.IsNotEmpty(i)&&(o={Phone:t.Mobile,Email:t.Email},e==="Internal"&&(o=Yt({ID:i},o))),o}static \u0275fac=function(t){return new(t||n)};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var Mt=class n{constructor(e,t,i,o,r,c){this._httpService=e;this._orderDataService=t;this._userRoleService=i;this.toastr=o;this._invoiceCalculatorService=r;this.promotionCouponFactoryService=c;this.subscribeToObservable()}dialog=w(xe);role;originalRoleData;_coupon=q(null);salesOrderBeforePromotion=q(null);isShowToastrInApplyCoupon=q(!1);get coupon(){return this._coupon()}subscribeToObservable(){this._userRoleService.Data$.subscribe(e=>{this.role=e,h.IsEmpty(this.originalRoleData)&&(this.originalRoleData=pe(je,e))})}RedeemCoupon(e,t,i=!1){i||(this.isShowToastrInApplyCoupon.set(!0),this.copyOriginalSalesOrder());let o=this.promotionCouponFactoryService.generateRedeemCouponDto(e,"Internal");this._httpService.post(Q.ValidateInternalCoupon,o).subscribe({next:r=>{switch(this._orderDataService.Data.Order.PromotionCoupon=e,this._orderDataService.Data.Order.PromotionNote=t,this._orderDataService.Data.Order.CouponType=1,r.Requirement?.Type){case 1:this.HandleDiscountPercentage(r);break;case 2:this.HandleDiscountAmount(r);break;case 3:this.handleCouponReturnAccess(r);break;case 4:this.handleCouponParkedDeletionAccess();break;case 5:this.handleFullAccessCoupon();break;case 6:this.handleDeleteItemCoupon();break}this._coupon.set(r),this.isShowToastrInApplyCoupon.set(!1)},error:r=>{this.removeAppliedCoupon(!1),this.isShowToastrInApplyCoupon.set(!1)}})}copyOriginalSalesOrder(){let e=pe(G,this._orderDataService.Data);this.salesOrderBeforePromotion.set(e)}HandleDiscountPercentage(e,t=!1){e.Amount>0?e.Requirement?.MaximumDiscount>0?this.applyConfigMaxDiscount(e,t):e.Requirement?.FullPriceProductOnly?this.applyFullPriceDisc(e,t):this.applyDiscountPercentage(e,t):(this.role.Discount=t?this.originalRoleData.Discount:!0,this._userRoleService.pushNewValue(this.role))}applyFullPriceDisc(e,t=!1){let i=this._orderDataService.Data,o=this.filterItemWithDisc(i.CartItems),r=this.filterItemWithCouponDisc(i.CartItems);if(t)r.length>0?(i.CartItems=this.resetItemsDisc(i.CartItems),this._orderDataService.pushNewValue()):this.applyDiscountPercentage(e,t);else if(o.length>0){let c=this.filterItemWithoutDisc(i.CartItems);c.length>0?this.applyConfigItemsScope(e,c).subscribe(u=>{let P=this.applyItemsDisc(u,e);i.CartItems=this.updateCartItems(P,e),this._orderDataService.pushNewValue(i),this.showToastr(e)}):(this.removeAppliedCoupon(!1),this._orderDataService.pushNewValue(),this.toastr.error("No products in the cart qualify for coupon use","Coupon Not Applied"))}else this.applyDiscountPercentage(e,t)}updateCartItems(e,t){let o=this._orderDataService.Data.CartItems.map(r=>{let c=e.find(u=>u.VariantID==r.VariantID);return c||r});return o=this.applyOneOfFirstQuantity(o,t),o}applyOneOfFirstQuantity(e,t){if(t?.Requirement?.RequirementDiscountType==2){let i=e.findIndex(o=>o.CouponDiscount>0);if(e[i].Quantity>1){let o=st(Se,e[i]);o.Quantity=1,e[i].Quantity=e[i].Quantity-1,e[i].CouponDiscount=0,e[i].Discount=0,e[i].DiscountAmount=0,e.push(o)}}return e}filterItemWithDisc(e){return e.filter(i=>i.Discount>0||i.DiscountAmount>0||i.Price!=i?.Variant?.UnitPrice||h.IsNotEmpty(i.PriceBookID)||i.PriceTypeID==2)}filterItemWithoutDisc(e){return e.filter(i=>this.itemConditionFullPriceOnly(i))}filterItemWithCouponDisc(e){return e.filter(i=>i.CouponDiscount>0)}applyDiscountPercentage(e,t=!1){let i=this._orderDataService.Data.Order.CustomerDiscountRate,o=e.Amount;if(t){let r=this._orderDataService.Data;this._orderDataService.Data.Order.Discount=0,r.CartItems=this.resetItemsDisc(r.CartItems),this._orderDataService.pushNewValue(r)}else o>=i?e.ApplyToProduct?.length>0?this.applyDiscountRequiredItems(e):(this._orderDataService.Data.Order.Discount=e.Amount,this._orderDataService.pushNewValue(),this.showToastr(e)):(this.toastr.warning("Member discount is applied because member discount is greater than Coupon Discount","Warning"),this.removeAppliedDiscountOnCustomerChange())}applyDiscountRequiredItems(e){let i=this._orderDataService.Data.CartItems.filter(o=>e.ApplyToProduct.map(r=>r.ID)?.includes(o.VariantID));this.applyConfigItemsScope(e,i).subscribe(o=>{let r=o.map(u=>(u.Discount=e.Amount,u.CouponDiscount=e.Amount,u)),c=this.updateCartItems(r,e);this._orderDataService.Data.CartItems=c,this._orderDataService.pushNewValue(),this.showToastr(e)})}showToastr(e){let t=e?.Requirement?.Notify;h.IsNotEmpty(t)&&this.isShowToastrInApplyCoupon()&&this.toastr.success(t,"Coupon Applied")}applyConfigMaxDiscount(e,t=!1){let i=this._orderDataService.Data.CartItems;e.Requirement?.FullPriceProductOnly&&(i=i.filter(o=>this.itemConditionFullPriceOnly(o))),this.applyConfigItemsScope(e,i,t).subscribe(o=>{this.applyMaxDiscount(e,o,t)})}applyConfigItemsScope(e,t,i=!1){let o=e.Requirement?.RequirementDiscountType;return(o==1||o==2)&&i==!1?this.dialog.open(Di,{data:{coupon:e,cartItems:t},id:"modal-coupon-selected-item"}).afterClosed().pipe(ae(c=>{let A=this._orderDataService.Data.CartItems.some(U=>U.CouponDiscount>0);!c&&!A&&this.removeAppliedDiscountOnCustomerChange()}),re(c=>!!c)):Ee(t)}applyMaxDiscount(e,t,i=!1){let o=this._invoiceCalculatorService.calculateGrossTotal(t),r=this._orderDataService.Data,c=o*e.Amount/100,u=e.Requirement?.MaximumDiscount,P=t;c>=u?(r.Order.DiscountAmount=i?0:u,P=this.resetItemsDisc(t)):(r.Order.DiscountAmount=0,P=i?this.resetItemsDisc(t):this.applyItemsDisc(t,e)),r.CartItems=this.updateCartItems(P,e),this._orderDataService.pushNewValue(r),i||this.showToastr(e)}resetItemsDisc(e){return this.coupon?.Requirement?.RequirementDiscountType==2?e=this.resetConfigOneOfFirstQuantity(e):e=e.map(t=>(t.CouponDiscount>0&&(t.Discount=0,t.DiscountAmount=0,t.CouponDiscount=0),t)),e}resetConfigOneOfFirstQuantity(e){let t=e.findIndex(i=>i.CouponDiscount>0);if(t!==-1){let i=e.findIndex(o=>o.CouponDiscount==0&&e[t]?.VariantID==o?.VariantID);i!==-1?(e.splice(t,1),e[i].Quantity+=1):(e[t].CouponDiscount=0,e[t].Discount=0,e[t].DiscountAmount=0)}return e}applyItemsDisc(e,t){return t.ApplyToProduct?.length>0?e=this.applyDiscByVariant(e,t):e=e.map(i=>(i.Discount=t.Amount,i.CouponDiscount=t.Amount,i)),e}applyDiscByVariant(e,t){return e=e.map(i=>(t.ApplyToProduct.find(r=>r.ID==i.VariantID)&&this.itemConditionFullPriceOnly(i)&&(i.Discount=t.Amount,i.CouponDiscount=t.Amount),i)),e}itemConditionFullPriceOnly(e){return(e.Discount==0||e.CouponDiscount>0)&&e.DiscountAmount==0&&e.Price==e?.Variant?.UnitPrice&&h.IsEmpty(e.PriceBookID)}HandleDiscountAmount(e,t=!1){e.Amount>0?(e.ApplyToProduct?.length>0?this.applyDiscountInItem(e,t):(t?this._orderDataService.Data.Order.DiscountAmount=0:(this._orderDataService.Data.Order.DiscountAmount=e.Amount,this.showToastr(e)),this._orderDataService.pushNewValue()),this.resetCustomerPoint(t)):(this.role.Discount=t?this.originalRoleData.Discount:!0,this._userRoleService.pushNewValue(this.role))}applyDiscountInItem(e,t=!1){let i=this._orderDataService.Data;if(t)i.CartItems=this.resetItemsDisc(i.CartItems);else{let r=i.CartItems.filter(c=>e.ApplyToProduct.map(u=>u.ID)?.includes(c.VariantID));this.applyConfigItemsScope(e,r,t).subscribe(c=>{let u=c.map(P=>(P.DiscountAmount=e.Amount,P.CouponDiscount=e.Amount,P));i.CartItems=this.updateCartItems(u,e),this._orderDataService.pushNewValue(i),this.showToastr(e)})}}resetCustomerPoint(e){if(!e){let t=this._orderDataService.Data;t.Order.PointUsed=0}}handleCouponReturnAccess(e){let t=pe(je,this.role);t.Return=!0,this._userRoleService.pushNewValue(t),this.isShowToastrInApplyCoupon()&&this.toastr.success("You got access to return a sales transaction!","Coupon Applied")}handleCouponParkedDeletionAccess(){let e=pe(je,this.role);e.ParkedDeletionAuthorized=!0,this._userRoleService.pushNewValue(e),this.isShowToastrInApplyCoupon()&&this.toastr.success("You Have Access to delete park and delete item when retrieve!","Coupon Applied")}handleFullAccessCoupon(){let e=pe(je,this.role);e.UnitPriceEditor=!0,e.Discount=!0,e.Return=!0,e.Tax=!0,e.NumberEditor=!0,e.DateEditor=!0,e.PricebookSelector=!0,e.DeleteItem=!0,e.ParkedDeletionAuthorized=!0,this._userRoleService.pushNewValue(e),this.isShowToastrInApplyCoupon()&&this.toastr.success("You now have Full Access for this Order!","Coupon Applied")}handleDeleteItemCoupon(){let e=pe(je,this.role);e.DeleteItem=!0,this._userRoleService.pushNewValue(e),this.isShowToastrInApplyCoupon()&&this.toastr.success("You Have Access to delete item","Coupon Applied")}removeAppliedCoupon(e=!0){this._userRoleService.pushNewValue(this.originalRoleData),this._orderDataService.pushNewValue(this.salesOrderBeforePromotion()),this.salesOrderBeforePromotion.set(null),this._coupon.set(null),e&&this.toastr.warning("Coupon Cancelled","Warning")}resetCouponOnNewTransaction(){this._userRoleService.pushNewValue(this.originalRoleData),this._coupon.set(null)}removeAppliedDiscountOnCustomerChange(){if(this.coupon)switch(this.coupon.Requirement?.Type){case 1:this.HandleDiscountPercentage(this._coupon(),!0),this.removeAppliedCouponOnCustomerChange();break;case 2:this.HandleDiscountAmount(this._coupon(),!0),this.removeAppliedCouponOnCustomerChange();break}}removeAppliedCouponOnCustomerChange(){if(this.coupon){let e=this._orderDataService.Data;e.Order.PromotionCoupon=null,e.Order.PromotionNote=null,this._coupon.set(null),this._userRoleService.pushNewValue(this.originalRoleData),this._orderDataService.pushNewValue(e)}}static \u0275fac=function(t){return new(t||n)(g(Ie),g(L),g(be),g(B),g(ne),g(Ii))};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var xi=class{RegisterID;Number;Amount;TransactionID};var It=class{GroupID;Method;Data};var Ti=class{Status;InvoiceID;LoyaltyPoint;diff};var wi=class{GopayQr};var Ri=class{Name;Quantity;Discount;DiscountAmount;Price;UnitQuantity};var Ei=class{Items;AmountSummary;GopayQr;Number;Customer;SalesName;CurrencySymbol;FinalAmount};var Ni=class n{_state=q(this.initCustomerDisplayState());isEnabled=qe(()=>this._state()?.enabled);connect(){let t={enabled:!0,timestamp:new Date().toDateString()};localStorage.setItem("customerDisplay",JSON.stringify(t)),this._state.set(t)}initCustomerDisplayState(){let e=localStorage.getItem("customerDisplay"),t={enabled:!1,timestamp:""};return h.IsNotEmpty(e)&&(t=JSON.parse(e)),t}disconnect(){let t={enabled:!1,timestamp:new Date().toDateString()};localStorage.setItem("customerDisplay",JSON.stringify(t)),this._state.set(t)}static \u0275fac=function(t){return new(t||n)};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var fe=class{Amount;CurrencySymbol;Label;Type;constructor(e,t,i,o){this.Amount=e,this.CurrencySymbol=t,this.Label=i,this.Type=o}};var Ai=class n{constructor(e,t,i,o){this._invoiceCalculatorService=e;this._decimalPipe=t;this._poshttpResponseService=i;this._orderService=o;this._poshttpResponseService.Data$.pipe(se()).subscribe(r=>{this.appConfig=r.AppConfigJSON})}appConfig=new ot;generateAmountSummary(){let e=[];this.isUseTax()?e=this.generateSummaryTax():e=this.generateSummaryNonTax();let t=this.generateSurchargeSummary();return t&&e.push(...t),e}generateSummaryTax(){let e=this._invoiceCalculatorService.tax?.CalculationTypeID,t=[];return e==1?t=this.generateSummaryTaxInclude():t=this.generateSummaryTaxExclude(),t}generateSummaryNonTax(){let e=[],t=this.generateCartItemAmount();if(e.push(t),this.isDiscounted()){let i=this.generateDiscountSummary(),o=this.generateAmountTotal("Total");e.push(...i,o)}return e}generateSummaryTaxInclude(){let e=[];return this.isTaxReserveSequence()?e=this.generateTaxIncludeReserveSequence():e=this.generateTaxIncludeNormalSequence(),e}generateTaxIncludeReserveSequence(){let e=[];if(this.isTaxDetailVisible()==!1){let r=this._invoiceCalculatorService.TotalBeforeTax,c=this.isDiscounted()?"Amount":"Before Tax",u=this.isDiscounted()?this._invoiceCalculatorService.GrossTotal:r,P=new fe(u,this.currencySymbol,c,2);e.push(P)}if(this.isDiscounted()){let r=this.generateDiscountSummary(),c=this.generateBeforeTaxSummary();e.push(...r,c)}let i=this.generateTax(),o=this.generateAmountTotal();return e.push(...i,o),e}generateTaxIncludeNormalSequence(){let e=[],t=this.generateCartItemAmount();if(e.push(t),this.isDiscounted()){let o=this.generateDiscountSummary(),r=this.generateSummarySubTotal();e.push(...o,r)}let i=this.generateTax();if(e.push(...i),this.isTaxDetailVisible()==!1){let o=this.generateBeforeTaxSummary();e.push(o)}return e}generateSummaryTaxExclude(){let e=[],t=this.generateCartItemAmount(!0);if(e.push(t),this.isDiscounted()){let c=this.generateDiscountSummary(),u=this.generateSummarySubTotal();e.push(...c,u)}let i=this.generateTax(),o=this._invoiceCalculatorService.TotalAfterTax,r=new fe(o,this.currencySymbol,"Total",1);return e.push(...i,r),e}generateAmountTotal(e="Total Amount"){let t=this._invoiceCalculatorService.Data;return new fe(t,this.currencySymbol,e,1)}generateSummarySubTotal(){let e=this._invoiceCalculatorService.TotalAfterTax;return new fe(e,this.currencySymbol,"SubTotal",1)}generateBeforeTaxSummary(){let e=this._invoiceCalculatorService.TotalBeforeTax;return new fe(e,this.currencySymbol,"Before Tax",2)}isTaxDetailVisible(){return this.appConfig.PrintConfigInvoice?.Footer?.TaxDetailVisible}isUseTax(){let e=this._invoiceCalculatorService.tax;return e?.PrintVisible&&e?.Rate!=0}generateTax(){let e=[],t=this.isTaxDetailVisible(),i=t?2:1,o=this._invoiceCalculatorService.tax;if(t){let r=this.appConfig.PrintConfigInvoice.Footer.TaxableSales,c=this.calculateTaxableSales(),u=new fe(c,this.currencySymbol,r,i);e.push(u)}if(o.TypeID==2){let r=this.generateTaxTypeMultiple();e.push(...r)}else{let r=this.generateSingleTaxSummary(o.Label,this._invoiceCalculatorService.TaxAmount,i);e.push(r)}if(t){let r=this.appConfig.PrintConfigInvoice.Footer.TaxExemptSales,c=this._invoiceCalculatorService.GrossTotalNonTaxable,u=new fe(c,this.currencySymbol,r,i);e.push(u);let P=this.appConfig.PrintConfigInvoice.Footer.LabelWithZeroAmount;if(P){let A=new fe(0,this.currencySymbol,P,i);e.push(A)}}return e}generateCartItemAmount(e=!1){let t=this.isDiscounted()||e?this._invoiceCalculatorService.GrossTotal:this._invoiceCalculatorService.TotalAfterTax;return new fe(t,this.currencySymbol,"Amount",1)}get currencySymbol(){return this._invoiceCalculatorService.currencySymbol}generateDiscountSummary(){let e=[];if(this._invoiceCalculatorService.Discount1Amount!=0){let t=this._decimalPipe.transform(this._orderService.Data.Order.Discount),o=this.checkDiscountIgnoreDecimal(t)?"{0}":"{0} ({1}%)";e.push(new fe(this._invoiceCalculatorService.Discount1Amount*-1,this._invoiceCalculatorService.currencySymbol,h.StringFormat(o,this.appConfig.CorePrint.Alias.Discount1,t),1))}if(this._invoiceCalculatorService.Discount2Amount!=0){let t=this._decimalPipe.transform(this._orderService.Data.Order.Discount2),o=this.checkDiscountIgnoreDecimal(t)?"{0}":"{0} ({1}%)";e.push(new fe(this._invoiceCalculatorService.Discount2Amount*-1,this._invoiceCalculatorService.currencySymbol,h.StringFormat(o,this.appConfig.CorePrint.Alias.Discount2,t),1))}return this._orderService.Data.Order.DiscountAmount!=0&&this.appConfig.PrintConfigInvoice.ItemsFooter.DiscountAmountVisible&&e.push(new fe(this._orderService.Data.Order.DiscountAmount*-1,this._invoiceCalculatorService.currencySymbol,"Discount ("+this._invoiceCalculatorService.currencySymbol+")",1)),e}calculateTaxableSales(){let e=this._invoiceCalculatorService.tax,t=this._invoiceCalculatorService.TaxAmount,i=this._invoiceCalculatorService.GrossTotalTaxable;return e.Rate==0?0:e.CalculationTypeID==1?i-t:i}generateTaxTypeMultiple(){let e=this.appConfig.PrintConfigInvoice.Footer.TaxDetailVisible?2:1,t=[],i=this._invoiceCalculatorService.tax;var o=this._invoiceCalculatorService.TaxAmount;if(i.TypeID==2){let r=i?.Components?i?.Components:[],c=this._invoiceCalculatorService.GrossTotalTaxable,u=this.calculateTotalRate(r);r.forEach(P=>{if(i.CalculationTypeID==0){let A=P.Rate/100*c;t=[...t,this.generateSingleTaxSummary(P.Label,A,e)],i.MultipleTaxTypeID==1&&(c+=A)}else{let A=P.Rate/u*o;t=[...t,this.generateSingleTaxSummary(P.Label,A,e)]}})}else t=[...t,this.generateSingleTaxSummary(i.Label,o,e)];return t}calculateTotalRate(e){let t=0;return e&&e.length>0&&(t=e.map(i=>i.Rate).reduce((i,o)=>i+o)),t}generateSingleTaxSummary(e,t,i){let o=this._invoiceCalculatorService.currencySymbol;return new fe(t,o,e,i)}generateSurchargeSummary(){if(this._invoiceCalculatorService.SurchargeAmount==0)return;let e=[],t=this.appConfig.CorePrint,i=t&&t.Alias.SurchargePcg?t.Alias.SurchargePcg:"Surcharge";e.push(new fe(this._invoiceCalculatorService.SurchargeAmount,this._invoiceCalculatorService.currencySymbol,h.StringFormat("{0} ({1}%)",i,this._decimalPipe.transform(this._orderService.Data?.Invoice.SurchargePcg)),1));let o=this.generateAmountTotal();return e.push(o),e}checkDiscountIgnoreDecimal(e){let i=this.appConfig.PrintConfigInvoice.Footer.DiscountIgnoredDecimal,o=parseFloat(e)%1,r=!1;return o!==0&&i&&(r=!0),r}isDiscounted(){let e=this._invoiceCalculatorService.Discount1Amount,t=this._invoiceCalculatorService.Discount2Amount,i=this._orderService.Data.Order.DiscountAmount,o=!1;return(e!=0||t!=0||i!=0)&&(o=!0),o}isTaxReserveSequence(){let e=this._invoiceCalculatorService.tax,t=!!e,i=t?e.CalculationTypeID:null,o=this.appConfig.PrintConfigInvoice.ItemsFooter.TaxIncludeBeforeTotalAmount;return t&&i===1&&o}static \u0275fac=function(t){return new(t||n)(g(ne),g(z),g(J),g(L))};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var rt=class n{constructor(e,t,i,o){this._receiptCalculatorService=e;this._cashierCalculatorService=t;this._signal=i;this._customerHttpService=o;this.broadcastOrderUpdate$.subscribe()}_salesOrderDataModelService=w(L);_outletService=w(te);displayService=w(Ni);localdata=w(ye);orderDataModel;broadcastOrderUpdate$=We([this._salesOrderDataModelService.Data$,this.localdata.isStoreOrderInServer(),$n(this.displayService.isEnabled)]).pipe(Sn(([e,t,i])=>{let o=this._outletService?.Data?.RegisterID;if(t&&i&&o){this.orderDataModel=e;let r=this.ConstructCartModelForCustomerDisplay(),c=new It;return c.GroupID=o+"_Subscriber",c.Method="POSCartAmountUpdated",c.Data=r,this._signal.broadcast(c).pipe(et(u=>(console.log(u),mt)))}else return mt}),et(e=>(console.log(e),mt)),se());ConstructCartModelForCustomerDisplay(){let e=this._customerHttpService.Data,t=new Ei;t.Number=this.orderDataModel.Order.Number,t.Items=Array();for(let i of this.orderDataModel.CartItems){let o=new Ri;o.Name=i.Variant.Name,o.Discount=i.Discount,o.DiscountAmount=i.DiscountAmount,o.Price=i.Price,o.Quantity=i.Quantity,o.UnitQuantity=i.UnitQuantity,t.Items.push(o)}return h.IsNotEmpty(this.orderDataModel.Order.SalesID)?t.SalesName=this._outletService.getSalesname(this.orderDataModel.Order.SalesID):t.SalesName="",h.IsNotEmpty(this.orderDataModel.Order.CustomerID)&&h.IsNotEmpty(e)&&(t.Customer=new Pt,t.Customer.Email=e.Email,t.Customer.Mobile=e.Mobile,t.Customer.Name=this.orderDataModel.ContactName),t.CurrencySymbol=this._cashierCalculatorService.currencySymbol,t.FinalAmount=this._cashierCalculatorService.Data,t.AmountSummary=this._receiptCalculatorService.generateAmountSummary(),t}BroadcastStateToCustomerDisplay(e,t="",i="",o=0){let r=new Ti;r.Status=e,r.InvoiceID=t,r.LoyaltyPoint=i,r.diff=o;let c=new It;return c.GroupID=this._outletService.Data.RegisterID+"_Subscriber",c.Method="POSStateUpdated",c.Data=r,this.displayService.isEnabled()?this.localdata.isStoreOrderInServer().pipe(Y(u=>u?this._signal.broadcast(c):Ee(ee.offlineMode))):mt}BroadcastQRToCustomerDisplay(e){let t=new wi;t.GopayQr=e;let i=new It;return i.GroupID=this._outletService.Data.RegisterID+"_Subscriber",i.Method="POSQRPaymentActivated",i.Data=t,this.displayService.isEnabled()?this.localdata.isStoreOrderInServer().pipe(Y(o=>o?this._signal.broadcast(i):Ee(ee.offlineMode))):mt}static \u0275fac=function(t){return new(t||n)(g(Ai),g(ne),g(tt),g(Te))};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var ki=class n{constructor(e){this.httpService=e}VerifyPayment(e,t){let i=this.getVerifyPaymentUrl(t);return this.httpService.post(i,e)}getVerifyPaymentUrl(e){let t;switch(e){case 0:t=Q.GopayVerifyPayment;break;case 1:t=Q.BcaVerifyPayment;break}return t}generateLink(e){return this.httpService.post(Q.GenerateLink,e)}generateQRCode(e,t){return this.httpService.post(e,t)}static \u0275fac=function(t){return new(t||n)(g(Ie))};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var xt=class n{constructor(e,t,i,o,r){this._posHubService=e;this._orderDataService=t;this._PaymentHttpService=i;this._InvoicecashierCalculatorService=o;this._toastrService=r}transactionId;qrPaymentMethodID;QRCodeHttpResponse;_paymentMethod;get paymentMethod(){return this._paymentMethod}resetPaymentMethod(){this._paymentMethod=null}onQRPaymentComplete(e,t){return new Promise((i,o)=>{if(e.transaction_id!==this.transactionId){let c=`transaction_id: ${e.transaction_id} / gross_amount: ${e.gross_amount}`;o({header:"Invalid QR Payment",message:c});return}if(e.gross_amount!==this._InvoicecashierCalculatorService.Data){let c=`paid_amount: ${e.gross_amount} vs invoice_amount: ${this._InvoicecashierCalculatorService.Data}`;o({header:"Invalid QR Payment",message:c});return}let r=this._orderDataService.Data.Order.Number;if(e.order_id.includes(r)==!1){let c=`Order ID: ${e.order_id} vs Order Number: ${r}`;o({header:"Invalid QR Payment",message:c});return}if(e.transaction_status!=="settlement"){let c=`Transaction status is ${e.transaction_status}`;o({header:"Invalid QR Payment",message:c});return}this.validateEMoneyPayment(t).subscribe(c=>{i(c)})})}generateNewPayment(e,t){let i=this._orderDataService.Data;h.IsEmpty(this.qrPaymentMethodID)&&alert("QR PaymentMethod.ID is not available!");let o=new ze;return o.PaidAmount=t,o.Amount=t,o.Date=i.Order.Date,o.MethodID=this.qrPaymentMethodID,o.Code=e,h.IsEmpty(e)&&this._toastrService.warning("Midtrans transaction_id is empty. Please verify manually!","Mobile Payment Failure"),o}sendStateCompleteToCustomerDisplay(e){this._posHubService.BroadcastStateToCustomerDisplay(1,e.ObjectID,e.LoyaltyPoint,0).subscribe()}generateQR(e,t){this._paymentMethod=t,this.qrPaymentMethodID=t.ID;let i=this.getServiceUrl(t.EMoneyTypeID);return this._PaymentHttpService.generateQRCode(i,e).pipe($(c=>(c=this.manipulateBCAQrisImg(c,t.EMoneyTypeID),this.transactionId=c.Transaction_id,this.QRCodeHttpResponse=c,this._orderDataService.transaction_id=c.Transaction_id,this.sendQRToCustomerDisplay(c.Url),c)))}sendQRToCustomerDisplay(e){this._posHubService.BroadcastQRToCustomerDisplay(e).subscribe()}validateEMoneyPayment(e){if(h.IsNotEmpty(this.transactionId)){let t=this._InvoicecashierCalculatorService.Data,i=this._paymentMethod?.EMoneyTypeID,o=this.generatePaymentVerificationData(t,i);return this._PaymentHttpService.VerifyPayment(o,i).pipe(Y(r=>(this.updatePosDataForSubmission(t),bn(this._orderDataService.submitOrder(e)).pipe(ae(c=>{this.sendStateCompleteToCustomerDisplay(c)})))))}else{let t=new Error("Transaction ID is Empty");throw pt(()=>t)}}generatePaymentVerificationData(e,t){let i=this._orderDataService.Data,o=new xi;return o.Number=i.Order.Number,o.Amount=e,o.TransactionID=this.transactionId,o.RegisterID=i.Order.RegisterID,t==1&&(o.Number=this.QRCodeHttpResponse.Number),o}updatePosDataForSubmission(e){let t=this._orderDataService.Data,i=this.generateNewPayment(this.transactionId,e),o=[];o.push(i),t.Invoice.Due=null,t.Action.Type=3,t.Order.InvoicedStateID=3,t.Payments=o,this._orderDataService.pushNewValue(t)}getServiceUrl(e){let t;switch(e){case 0:t=Q.GenerateGopayQrCode;break;case 1:t=Q.GenerateBcaQrCode;break}return t}manipulateBCAQrisImg(e,t){return t==1&&(e.Url=`data:image/png;base64, ${e.Url}`),e}clearTransactionID(){this.transactionId=null,this._orderDataService.transaction_id=null,this.QRCodeHttpResponse=null}getTransactionId(){return this.transactionId}static \u0275fac=function(t){return new(t||n)(g(rt),g(L),g(ki),g(ne),g(B))};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};var Tt=class{CommissionID;ReturNumber;parkTemporaryItem;posState;InputTextValue;constructor(){this.posState=0,this.CommissionID="",this.ReturNumber="",this.parkTemporaryItem=[],this.InputTextValue=""}};var Vi=class n{constructor(e,t,i){this._promotionEventService=e;this._dialogRef=t;this.data=i;this.modalConfig=new Z,this.modalConfig.hideCancel=!0,this.modalConfig.hideClose=!0,this.modalConfig.headerType=le.Warning,this.modalConfig.title="Promotion Requirement unfulfilled!",this.modalConfig.customWidth="350px",this.modalConfig.okText="Ok",this.selectedPromotion=e.selectedPromotion}modalConfig;selectedPromotion;onOk(){this._promotionEventService.restoreOrder(),this._dialogRef.close()}static \u0275fac=function(t){return new(t||n)(S(Re),S(K),S(me))};static \u0275cmp=E({type:n,selectors:[["POS-modal-promotion-confirm"]],standalone:!1,decls:9,vars:4,consts:[[3,"onOk","config"],[1,"fst-italic","text-danger","mb-3"],[1,"mb-0"]],template:function(t,i){t&1&&(a(0,"modal-material",0),b("onOk",function(){return i.onOk()}),a(1,"content")(2,"div")(3,"h5"),m(4),s(),a(5,"p",1),m(6),s(),a(7,"p",2),m(8),s()()()()),t&2&&(p("config",i.modalConfig),l(4),D(i.selectedPromotion==null?null:i.selectedPromotion.Name),l(2),D(i.selectedPromotion==null?null:i.selectedPromotion.Description),l(2),D(i.data==null?null:i.data.message))},dependencies:[X],encapsulation:2})};var Fi=class extends Se{};var Rt=class n{constructor(e,t,i,o,r,c,u,P,A){this.variantService=e;this._posService=t;this._orderDataService=i;this.toastr=o;this._orderProcessorService=r;this._customerHttpService=c;this.promotionCouponService=u;this.userRoleService=P;this.decimalPipe=A;this.subscribeToObservable()}salesOrderData;appConfigJson;entityID;audio=new Audio;subscribeToObservable(){this._posService.Data$.pipe(se()).subscribe(e=>{this.appConfigJson=e.AppConfigJSON}),this._orderDataService.Data$.pipe(se()).subscribe(e=>{this.salesOrderData=e,this.entityID=e.Order.EntityID}),this._orderProcessorService.Data$.pipe(se()).subscribe(e=>{e.posState==3&&this.clearCartItemsInLocalStorage()})}addCartItemById(e,t,i=!0){return new Promise((o,r)=>{this.variantService.findVariantByID(e,this.entityID,i).then(c=>{this.createNewCartItem(c,t),o(c)}).catch(c=>{r(c)})})}addCartItemByCode(e){return new Promise((t,i)=>{let o=this.appConfigJson.ModuleSell.DigitalScale;o.Digit>0&&h.IsNotEmpty(o.Regex)&&e.length==o.Digit?this.parseDigitalScaleBarcodeWithRegex(e,o).then(c=>{c||(this.toastr.info("Matching Regex Rule to Barcode","Digital Scale"),this.findVariantByCode(e).then(u=>t(u)).catch(u=>i(u)))}):this.findVariantByCode(e).then(c=>t(c)).catch(c=>i(c))})}findVariantByCode(e){let t=this.appConfigJson.ModuleSell.BarcodeSerialEnabled;return new Promise((i,o)=>{this.variantService.findVariantByCode(e,this.entityID,t).then(r=>{i(r),this.createNewCartItem(r)}).catch(r=>{this.playBellRing(),o(r)})})}addItemBySerial(e){this.variantService.findVariantBySerial(e,this.entityID).subscribe(t=>{let i=this.salesOrderData.CartItems;if(i.length>0){let o,r=[],c=i.findIndex(u=>u.Variant.ID==t.ID);r=[],c!==-1?(o=i[c].Serial?.findIndex(u=>u.Number==e),r=[...i[c].Serial?i[c].Serial:[]],o==-1?(r.push({Number:e,Quantity:1}),i[c].Quantity=r.length):r.length>0?r[o].Quantity+=1:(r=[{Number:e,Quantity:1}],this.addNewSerials(t,e)),i[c].Serial=[...r],i[c].Quantity=i[c].calculateSerialQty(),this.updateCartItem(i[c],c)):this.addNewSerials(t,e)}else this.addNewSerials(t,e)})}addNewSerials(e,t){e.Serial=[{Number:t,Quantity:1}],this.createNewCartItem(e)}playBellRing(){this.audio.src="//res.cloudinary.com/pos/video/upload/v1659947782/POS/Music/bell_ring.mp3",this.audio.load(),this.audio.play()}updateCartItem(e,t){this.salesOrderData.CartItems[t]=e,this._orderDataService.pushNewValue(this.salesOrderData),this.applyCustomerPoint(),this.reApplyPromotionCoupon(),this.saveItemsToLocalStorage()}deleteCartItem(e){this.salesOrderData.CartItems=this.salesOrderData.CartItems.filter(t=>t!==e),this._orderDataService.pushNewValue(this.salesOrderData),this.applyCustomerPoint(),this.reApplyPromotionCoupon()}parseDigitalScaleBarcodeWithRegex(e,t){return new Promise(i=>{let o=this.appConfigJson.ModuleSell.BarcodeSerialEnabled,r=new RegExp(t.Regex),c=e.match(r);if(console.log(c),h.IsNotEmpty(c)){let u=c[1],P=parseFloat(c[2]);console.log(P,"productQuantity"),P=P/t.QuantityDivider,this.variantService.findVariantByCode(u,this.entityID,o).then(A=>{this.createNewCartItem(A,null,P),i(!0)}).catch(()=>{i(!1)})}else i(!1)})}createNewCartItem(e,t,i){let o=new Se,r=this.appConfigJson.ModuleSell.ProductNotes.CopyProductDescription,c=this.appConfigJson.ModuleSell.ProductNotes.CopyPromotionName;o.patchByVariant(e,r,c),o=this.applyReward(o,t),h.IsEmpty(t)&&(o=this.applyPriceBook(o)),this.validateCartItem(o)&&(o.Quantity=i||o.Quantity,t?.PromotionType==2?this.handlingPromotionQuantity(o):this.pushNewItemToArray(o,o.PromotionGift),this.applyCustomerPoint()),this.addAvailableComponent(o)}applyCustomerPoint(){let e=this.salesOrderData.Order.CustomerID,t=h.IsEmpty(e);this._orderProcessorService.reedemPointToDiscount(t)}handlingPromotionQuantity(e){let t=pe(Se,this.salesOrderData.CartItems),i=t.findIndex(o=>o.VariantID==e.VariantID&&o.PromotionGift);i!==-1?t[i].Quantity+=e.Quantity?e.Quantity:1:t=[...t,e],this.salesOrderData.CartItems=t,this._orderDataService.pushNewValue(this.salesOrderData)}applyPromotionProduct(e){let t=e.Variant.DiscountAmount;return t&&(e.Price=e.UnitPriceOriginal-t),e}applyReward(e,t){if(t){let i=this.appConfigJson.ModuleSell.ProductNotes.CopyPromotionName;e.Discount=t.Discount,e.Price=t.OriginalPrice;let o=t.OriginalPrice-t.UnitPrice;e.Price=e.UnitPriceOriginal-o,e.UnitPrice=e.UnitPriceOriginal-o,e.PromotionGift=!0,e.PromotionID=t.PromotionID,e.Quantity=t.Quantity?t.Quantity:1,e.PriceTypeID=3,e.Cost+=t.ExtraCost,e.UnitCost+=t.ExtraCost,e.PriceNote=t.PromotionName,i&&(e.Note=`${e.Note?e.Note:""} ${t.PromotionName} `)}return e}addAvailableComponent(e){let t=e.Price!=0,i=this.appConfigJson.ModuleSell.SellProductComponentDefaultPrice,o=e.Variant;if(o.Component!=null&&o.Component.length>0)for(let r of o.Component){let c=new Fi;c.patchByVariant(r),c.Quantity=e.Quantity*r.Quantity,t&&!i&&(r.UnitPrice=0),c.Price=r.UnitPrice,this.pushNewItemToArray(c)}}pushNewItemToArray(e,t=!1){let i=this.salesOrderData.CartItems.findIndex(o=>o.VariantID==e.VariantID);if(e=this.applyPromotionProduct(e),i==-1||t)this.salesOrderData.CartItems.push(e);else{let o=this.appConfigJson.ModuleSell.QuickKey.NewRowBehaviour;if(o==2)this.salesOrderData.CartItems.push(e);else if(o==1)this._orderProcessorService.Data.posState==4?this.salesOrderData.CartItems.push(e):this.addingQuantityItem(i,e);else{if(!this.validatePrepaidPackage(e,i)){this.toastr.error("This prepaid package is already in the cart while editing. Please remove it first before adding again.","Cannot Add Item");return}this.addingQuantityItem(i,e)}}this._orderDataService.pushNewValue(this.salesOrderData),this.saveItemsToLocalStorage(),this.reApplyPromotionCoupon()}saveItemsToLocalStorage(){let e=this.userRoleService.Data.DeleteItem,t=this._orderProcessorService.Data?.posState;if(!e&&t!==4){let o=this._orderDataService.Data.CartItems;try{localStorage.setItem("cart_items",JSON.stringify(o))}catch(r){console.error("Error saving cart items to localStorage:",r)}}}clearCartItemsInLocalStorage(){let e=this.promotionCouponService?.coupon;if(!this.userRoleService.Data?.DeleteItem||e.Requirement?.Type==5||e.Requirement?.Type==6)try{localStorage.removeItem("cart_items")}catch(i){console.error("Error clearing cart items from localStorage:",i)}}validatePrepaidPackage(e,t){let i=this.salesOrderData.CartItems[t],o=this._orderProcessorService.Data.posState,r=e.Variant.TypeID==10,c=h.IsNotEmpty(i.ID),u=!0;return o==2&&r&&c&&(u=!1),u}reApplyPromotionCoupon(){let e=this.salesOrderData.Order.CouponProvider,t=e=="Internal"||h.IsEmpty(e),i=this.salesOrderData.Order.PromotionCoupon,o=this.salesOrderData.Order.PromotionNote;h.IsNotEmpty(i)&&t&&this.promotionCouponService.RedeemCoupon(i,o,!0)}addingQuantityItem(e,t){let i=this.salesOrderData.CartItems.filter(u=>u.VariantID==t.VariantID),o=i.length,r=i.find(u=>!u.PromotionGift);this.salesOrderData.CartItems[e].PromotionGift&&o==1?this.salesOrderData.CartItems.push(t):(r.Quantity+=t.Quantity,r=this.applyPromotionProduct(r)),r&&(r=this.applyPriceBook(r))}validateCartItem(e){return e.Variant.CategoryTypeID==-1?(this.toastr.info(e.Variant.Name+" cannot be sold, check Category "+e.Variant.CategoryName+" settings","info"),!1):!(!this.validatePriceMinimum(e)||!this.validateSerialItem(e))}validatePriceMinimum(e){let t=!0,i=this.userRoleService.Data.PriceMinimum,o=this.appConfigJson.ModuleSell.ProductDialog.PriceMinimumTypeID;if(i){let r=0;switch(o){case 1:r=e.UnitPrice;break;case 2:r=e.UnitCost;break;case 3:r=e.UnitPriceMinimum;break}if(e.Price<r){t=!1;let c=h.StringFormat("You have no right to sell this item lower than {0}",this.decimalPipe.transform(r));alert(c)}}return t}validateSerialItem(e){let t=!0;if(e?.Serial?.length>0&&e.Variant.TypeID==4&&e.Quantity>0){let i=0;e?.Serial?.forEach(o=>{i+=o.Quantity}),i!=e.Quantity&&(this.toastr.error("Serial must be equal with the quantity","Error"),t=!1)}return t}applyPriceBook(e){let t=e.Variant.PriceBook!=null?e.Variant.PriceBook:[],i=this.findCustomerPricebook(t);if(t&&t.length!==0){let o=t.sort(function(r,c){return c.MinimumQuantity-r.MinimumQuantity}).filter(r=>e.Quantity>=r.MinimumQuantity&&r.MinimumQuantity!=0);o.length>0||h.IsNotEmpty(i)?h.IsNotEmpty(i)?e=this.applyPricebookToItem(e,i):e=this.applyPricebookToItem(e,o[0]):e=this.resetAppliedPricebook(e)}return e}resetAppliedPricebook(e){let i=(e?.Variant?.PriceBook).find(o=>o.ID==e.PriceBookID);return h.IsNotEmpty(i)&&(e.Discount=e.Variant.PriceDiscount,e.PriceBookID=h.GuidEmpty,e.Price=e.Variant.UnitPrice,e.UnitPrice=e.Variant.UnitPrice,e.PriceTypeID=0,e=this.applyPromotionProduct(e),e=this.removePromotionNote(e)),e}removePromotionNote(e){let t=this.appConfigJson.ModuleSell.ProductNotes;if(this.appConfigJson?.ModuleSell?.Pricebook?.PricebookVisible&&(e.Note=e.Note?.replace(e.PriceNote,""),e.PriceNote=""),t.CopyPromotionName){let o=e.Variant?.PriceNote;e.Note=`${o||""} ${e.Note?e.Note:""}`,e.PriceNote=o}return e}applyPricebookToItem(e,t){return e.Discount=t.PriceDiscount,e.UnitPrice=t.UnitPrice,e.PriceBookID=t.ID,e.Price=t.UnitPrice,e.PriceTypeID=2,e=this.assignItemNote(e,t),e}assignItemNote(e,t){return this.appConfigJson?.ModuleSell?.Pricebook?.PricebookVisible?(e.Note?.includes(e.PriceNote)?e.Note=e.Note?.replace(e.PriceNote,t.Name):e.Note=`${t.Name} ${e.Note?e.Note:""}`,e.PriceNote=t.Name):(e.Note="",e.PriceNote=""),e}findCustomerPricebook(e=[]){let t=this._customerHttpService.Data,i;return t&&(i=e.find(o=>o.ID==t.PricebookID)),i}static \u0275fac=function(t){return new(t||n)(g(po),g(J),g(L),g(B),g(Ye),g(Te),g(Mt),g(be),g(z))};static \u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"})};function dr(n,e){if(n&1&&(a(0,"div",9)(1,"div",4),_(2,"input",10),s()()),n&2){let t=d();l(2),p("formControl",t.searchControl)}}function ur(n,e){n&1&&(a(0,"span"),m(1,"Apply"),s())}function gr(n,e){n&1&&(a(0,"span"),m(1,"Applying..."),s())}function fr(n,e){if(n&1){let t=I();a(0,"tr")(1,"td"),m(2),s(),a(3,"td"),m(4),s(),a(5,"td",11),m(6),y(7,"number"),s(),a(8,"td",11),m(9),y(10,"number"),s(),a(11,"td",12)(12,"button",13),b("click",function(){let o=C(t).$implicit,r=d();return v(r.onSelectReward(o))}),f(13,ur,2,0,"span",14)(14,gr,2,0,"span",14),s()()()}if(n&2){let t=e.$implicit,i=d();l(2),D(t.VariantName),l(2),D(t.VariantCode),l(2),D(M(7,7,t.OriginalPrice)),l(3),D(M(10,9,t.UnitPrice)),l(3),p("disabled",i.isApplyingReward()),l(),p("ngIf",!i.isApplyingReward()),l(),p("ngIf",i.isApplyingReward())}}var Bi=class n{constructor(e,t,i,o,r,c){this._dialogRef=e;this._matDialog=t;this._shoppingCartService=i;this._promotionEventService=o;this._toastr=r;this.data=c;this.selectedPromotion=this._promotionEventService.selectedPromotion}modalConfig=new Z;selectedPromotion;rewards$;searchControl=new Ke;isApplyingReward=q(!1);ngOnInit(){this.modalConfig.title="Select a Reward",this.modalConfig.hideFooter=!0,this.initRewards(!0)}initRewards(e){this.rewards$=this.searchControl.valueChanges.pipe(ti(""),dt(e?0:500),ke(),Y(t=>{let i;return i=Ee(this.data.rewards).pipe($(o=>o.filter(r=>this.findKeywordInValue(t,r?.VariantCode)||this.findKeywordInValue(t,r?.VariantName)))),e=!0,i}))}findKeywordInValue(e,t){return t?.toUpperCase()?.indexOf(e?.toUpperCase())>-1}onSelectReward(e){return Kt(this,null,function*(){if(!this.isApplyingReward()){this.isApplyingReward.set(!0);try{e.PromotionType=this.data.promotion.TypeID,yield this._shoppingCartService.addCartItemById(e.VariantID,e,!0).then(()=>{this._matDialog.closeAll(),this._promotionEventService.pushNewValue(this._promotionEventService.Data),this.showToastAppliedPromo()})}finally{this.isApplyingReward.set(!1)}}})}showToastAppliedPromo(){this._toastr.success("Applied "+this.selectedPromotion.Name+" to order!","Applied successfully!")}close(){this._dialogRef.close()}static \u0275fac=function(t){return new(t||n)(S(K),S(xe),S(Rt),S(Re),S(B),S(me))};static \u0275cmp=E({type:n,selectors:[["POS-modal-select-item"]],standalone:!1,decls:22,vars:9,consts:[[3,"onCancel","onClose","config"],[1,"container"],["class","row mb-3",4,"ngIf"],[1,"row"],[1,"col-12"],[1,"table","table-bordered"],[1,"thead-light"],["scope","col"],[4,"ngFor","ngForOf"],[1,"row","mb-3"],["type","text","placeholder","Type to filter reward",1,"form-control",3,"formControl"],[1,"text-end"],[1,"text-center"],[1,"btn","btn-sm","btn-success",3,"click","disabled"],[4,"ngIf"]],template:function(t,i){t&1&&(a(0,"modal-material",0),b("onCancel",function(){return i.close()})("onClose",function(){return i.close()}),a(1,"content")(2,"div",1),f(3,dr,3,1,"div",2),a(4,"div",3)(5,"div",4)(6,"table",5)(7,"thead",6)(8,"tr")(9,"th",7),m(10,"Name"),s(),a(11,"th",7),m(12,"Code"),s(),a(13,"th",7),m(14,"Price"),s(),a(15,"th",7),m(16,"Promo"),s(),_(17,"th",7),s()(),a(18,"tbody"),f(19,fr,15,11,"tr",8),y(20,"async"),y(21,"sortBy"),s()()()()()()()),t&2&&(p("config",i.modalConfig),l(3),p("ngIf",(i.data==null||i.data.rewards==null?null:i.data.rewards.length)>5),l(16),p("ngForOf",Ct(21,5,M(20,3,i.rewards$),"desc","VariantCode")))},dependencies:[ve,oe,De,_e,vt,X,$e,z,St],styles:[".table-scroll[_ngcontent-%COMP%]{max-height:400px;overflow-y:auto}table[_ngcontent-%COMP%]{max-width:600px!important;overflow-x:hidden}"]})};function hr(n,e){if(n&1&&(H(0),a(1,"div",13)(2,"div",7),_(3,"input",14),s()(),j()),n&2){let t=d();l(3),p("formControl",t.searchCtrl)}}function Cr(n,e){n&1&&(H(0),a(1,"th",15),m(2,"Qty"),s(),j())}function vr(n,e){n&1&&_(0,"th",10)}function _r(n,e){if(n&1){let t=I();H(0),a(1,"td")(2,"input",17),V("ngModelChange",function(o){C(t);let r=d().$implicit;return N(r.Quantity,o)||(r.Quantity=o),v(o)}),s()(),j()}if(n&2){let t=d().$implicit;l(2),k("ngModel",t.Quantity)}}function yr(n,e){n&1&&(a(0,"span"),m(1,"Apply"),s())}function br(n,e){n&1&&(a(0,"span"),m(1,"Applying..."),s())}function Sr(n,e){if(n&1){let t=I();a(0,"td",18)(1,"button",19),b("click",function(){C(t);let o=d().$implicit,r=d();return v(r.onApplyReward(o))}),f(2,yr,2,0,"span",5)(3,br,2,0,"span",5),s()()}if(n&2){let t=d(2);l(),p("disabled",t.isApplyingReward()),l(),p("ngIf",!t.isApplyingReward()),l(),p("ngIf",t.isApplyingReward())}}function Pr(n,e){if(n&1&&(a(0,"tr")(1,"td"),m(2),s(),a(3,"td"),m(4),s(),a(5,"td",16),m(6),y(7,"number"),s(),a(8,"td",16),m(9),y(10,"number"),s(),f(11,_r,3,1,"ng-container",11)(12,Sr,4,3,"ng-template",null,1,Oe),s()),n&2){let t=e.$implicit,i=W(13),o=d();l(2),D(t.VariantName),l(2),D(t.VariantCode),l(2),D(M(7,6,t.OriginalPrice)),l(3),D(M(10,8,t.UnitPrice)),l(2),p("ngIf",o.rewardQuantity>1)("ngIfElse",i)}}var Hi=class n{constructor(e,t,i,o,r,c){this.data=e;this.shoppingCartService=t;this.promotionEventService=i;this.dialogRef=o;this.matDialog=r;this.toastr=c;this.searchCtrl=new Ke,this.rewardQuantity=e.rewardQuantity,this.sourceRewards=[...e.rewards]}modalConfig;rewards$;rewardQuantity;rewards;sourceRewards=[];searchCtrl;isApplyingReward=q(!1);ngOnInit(){this.initModalConfig(),this.initSearchCtrl(!0)}initModalConfig(){this.modalConfig=new Z,this.modalConfig.title="Select a Reward",this.rewardQuantity<2&&(this.modalConfig.hideFooter=!0)}initSearchCtrl(e){this.rewards$=this.searchCtrl.valueChanges.pipe(ti(""),dt(e?0:500),ke(),Y(t=>{let i;return i=Ee(this.sourceRewards).pipe($(o=>(o.length===1&&(o[0].Quantity=this.rewardQuantity),o)),$(o=>o.filter(r=>this.findKeywordInValue(t,r?.VariantCode)||this.findKeywordInValue(t,r?.VariantName)))),e=!1,i}),ae(t=>{this.rewards=t}))}findKeywordInValue(e,t){return t?.toUpperCase()?.indexOf(e.toUpperCase())>-1}onApplyReward(e){return Kt(this,null,function*(){if(!this.isApplyingReward()){this.isApplyingReward.set(!0);try{yield this.addRewardToShoppingCart(e)}finally{this.isApplyingReward.set(!1)}}})}onClose(){this.dialogRef.close()}onOk(){this.calculateRewardQty()>this.rewardQuantity?this.toastr.warning("Product reward exceeds the maximum amount earned","Warning"):[...this.rewards].filter(i=>i.Quantity>0).forEach(i=>{this.addRewardToShoppingCart(i)})}calculateRewardQty(){let e=0;return this.rewards.forEach(t=>{e+=t.Quantity?t.Quantity:0}),e}addRewardToShoppingCart(e){return e.PromotionType=this.data.promotion.TypeID,this.shoppingCartService.addCartItemById(e.VariantID,e,!0).then(()=>{this.matDialog.closeAll(),this.promotionEventService.pushNewValue(this.promotionEventService.Data)})}static \u0275fac=function(t){return new(t||n)(S(me),S(Rt),S(Re),S(K),S(xe),S(B))};static \u0275cmp=E({type:n,selectors:[["app-modal-quantity-reward"]],standalone:!1,decls:27,vars:12,consts:[["APPLY",""],["APPLY_BUTTON",""],[3,"onCancel","onOk","onClose","config"],[1,"ms-3"],[1,"container"],[4,"ngIf"],[1,"row","table-scroll"],[1,"col-12"],[1,"table","table-bordered"],[1,"thead-light"],["scope","col"],[4,"ngIf","ngIfElse"],[4,"ngFor","ngForOf"],[1,"row","mb-3"],["type","text","placeholder","Type to filter reward",1,"form-control",3,"formControl"],["scope","col",2,"width","66px"],[1,"text-end"],["type","text","autoNum","","min","0",1,"form-control",3,"ngModelChange","ngModel"],[1,"text-center"],[1,"btn","btn-sm","btn-success",3,"click","disabled"]],template:function(t,i){if(t&1){let o=I();a(0,"modal-material",2),b("onCancel",function(){return C(o),v(i.onClose())})("onOk",function(){return C(o),v(i.onOk())})("onClose",function(){return C(o),v(i.onClose())}),a(1,"header")(2,"small",3),m(3),s()(),a(4,"content")(5,"div",4),f(6,hr,4,1,"ng-container",5),a(7,"div",6)(8,"div",7)(9,"table",8)(10,"thead",9)(11,"tr")(12,"th",10),m(13,"Name"),s(),a(14,"th",10),m(15,"Code"),s(),a(16,"th",10),m(17,"Price"),s(),a(18,"th",10),m(19,"Promo"),s(),f(20,Cr,3,0,"ng-container",11)(21,vr,1,0,"ng-template",null,0,Oe),s()(),a(23,"tbody"),f(24,Pr,14,10,"tr",12),y(25,"async"),y(26,"sortBy"),s()()()()()()()}if(t&2){let o=W(22);p("config",i.modalConfig),l(3),O(" ( ",i.rewardQuantity," products reward ) "),l(3),p("ngIf",(i.sourceRewards==null?null:i.sourceRewards.length)>5),l(14),p("ngIf",i.rewardQuantity>1)("ngIfElse",o),l(4),p("ngForOf",Ct(26,8,M(25,6,i.rewards$),"desc","VariantCode"))}},dependencies:[ve,oe,De,_e,Me,vt,X,bt,$e,z,St],encapsulation:2})};var Re=class n{constructor(e,t,i,o,r,c,u,P,A){this._orderDataService=e;this._outletService=t;this._invoiceCalculatorService=i;this._dialog=o;this._httpService=r;this._posService=c;this._toastr=u;this._signalrService=P;this.decimalPipe=A;this.previousQuantity=0,this.previousTotalEligible=0,this.subscribeNotification(),this._posService.Data$.subscribe(U=>{this.taxes=U.Taxes}),this._outletService.Data$.subscribe(U=>{this.loadPromotions(U.Promotion)}),this._orderDataService.Data$.pipe(re(U=>{this.salesOrderData=U;let he=this.calculateOrderReward(U.getRewards()),sn=this.calculateOrderReward(this.previousRewards);return this.previousQuantity!=U.TotalQuantity||sn<he||this.isRestroreOrder}),dt(100)).subscribe(U=>{this.isRestroreOrder=!1,this.checkQtyPromotion(),this.applyQuantityPromotion(),this.previousRewards=[...U.getRewards()]}),this._invoiceCalculatorService.Data$.subscribe(U=>{this.checkEligiblePromotionWithMinSpend()})}_Data=new Ce([]);get Data(){return this._Data.getValue()}Data$=this._Data.asObservable();selectedPromotion=null;onClickToastPromo=new Ae;previousQuantity;salesOrderData;orderDataBeforePromotion;taxes=[];previousTotalEligible;previousRewards=[];isRestroreOrder=!1;calculateOrderReward(e){let t=0;return e.length>0&&(t=e.map(i=>i.Quantity).reduce((i,o)=>i+o)),t}checkQtyPromotion(){let e=this._orderDataService.Data;this.checkEligibleQtyPromotion(e.CartItems),this.checkEligibleTierPromotion(e.CartItems),this.previousQuantity=e.TotalQuantity}subscribeNotification(){this._signalrService.OnPromotionEventChange.pipe(se(),Y(()=>{let e=this._outletService.Data?.RegisterID;return this.getPromotions(e)})).subscribe(()=>{this._toastr.info("Promotion Event Updated","Promotion Update")})}getPromotions(e){return this._httpService.get(Q.GetListPromotion,[{key:"RegisterID",value:e}]).pipe(ae(t=>{this.loadPromotions(t)}))}loadPromotions(e){let t=this.getPromotionDesc(e);this.pushNewValue(t),this.checkQtyPromotion(),this.checkEligiblePromotionWithMinSpend()}pushNewValue(e){this.showToastEligiblePromotion(),this._Data.next(e)}checkSelectedPromotionRequirement(e){this.selectedPromotion!=null&&this.selectedPromotion.TypeID==e&&this.Data.find(i=>i.ID===this.selectedPromotion.ID)?.Eligible===!1&&(this._dialog.open(Vi,{id:"modal-promotion-confirm",data:{message:"Order will be restored to before the promotion is applied"},disableClose:!0}),this.isRestroreOrder=!0)}restoreOrder(){this._orderDataService.pushNewValue(this.orderDataBeforePromotion),this.selectedPromotion=null}getPromotionDesc(e=[]){return e?.map(i=>(i.Description=this.generatePromotionDesc(i),i))}checkEligiblePromotionWithMinSpend(){let e=this._invoiceCalculatorService.Data,t=this.Data?.filter(o=>(o.TypeID===1||o.TypeID==3)&&!this.checkExpiredPromotion(o)).map(o=>(e>=o.MinimumAmount?o.Eligible=!0:o.Eligible=!1,o)),i=this.mappingEligiblePromotion(t);this.pushNewValue(i),this.checkSelectedPromotionRequirement(1),this.checkSelectedPromotionRequirement(3)}checkEligibleQtyPromotion(e){let t=0,i=this.Data?.filter(r=>r.TypeID===2&&!this.checkExpiredPromotion(r)).map(r=>(r.Eligible=!1,r.ListVariant.length>0?(t=this.getQuantityByRequirementType(e,"variant",r.ListVariant),t>=r.MinimumAmount&&(r.Eligible=!0)):r.ListCategory.length>0?(t=this.getQuantityByRequirementType(e,"category",r.ListCategory),t>=r.MinimumAmount&&(r.Eligible=!0)):this.salesOrderData.TotalQuantity>=r.MinimumAmount&&(r.Eligible=!0),r)),o=this.mappingEligiblePromotion(i);this.pushNewValue(o)}checkEligibleTierPromotion(e){let t,i=this.Data?.filter(r=>r.TypeID===5&&!this.checkExpiredPromotion(r)).map(r=>(r.Eligible=!1,r.ListVariant.length>0?t=this.getQuantityByRequirementType(e,"variant",r.ListVariant):r.ListCategory.length>0?t=this.getQuantityByRequirementType(e,"category",r.ListCategory):t=this.salesOrderData.TotalQuantity,r.PromotionTieredQuantity.forEach(c=>{t>=c.Quantity&&(r.Eligible=!0)}),r)),o=this.mappingEligiblePromotion(i);this.pushNewValue(o)}getQuantityByRequirementType(e,t,i){let o=0,r;return t=="variant"?e.forEach(c=>{r=i.findIndex(u=>u.ID===c.VariantID),r!==-1&&(o+=c.Quantity)}):e.forEach(c=>{c.Variant&&(r=i.findIndex(u=>u.ID===c.Variant.CategoryID),r!==-1&&(o+=c.Quantity))}),o}mappingEligiblePromotion(e=[]){let t=this.Data;if(e?.length>0){let i;t=this.Data?.map(o=>(i=e.findIndex(r=>r.ID==o.ID),i!==-1&&(o=e[i]),o))}return t}checkExpiredPromotion(e){let t=new Date,i=new Date(e.StartDate),r=(h.IsEmpty(e.StartTime)?"00:00:00":e.StartTime).split(":").map(A=>parseInt(A));i.setHours(r[0],r[1],r[2]);let c=new Date(e.ExpirationDate),P=(h.IsEmpty(e.EndTime)?"23:59:59":e.EndTime).split(":").map(A=>parseInt(A));return c.setHours(P[0],P[1],P[2]),!(t.getTime()>=i.getTime()&&t.getTime()<=c.getTime())}showToastEligiblePromotion(){let e=this.getTotalEligiblePromotion(),t=h.IsNotEmpty(this.salesOrderData.Order.ID);this.previousTotalEligible!==e&&e>0&&!t&&this._toastr.info(e+" promotion(s) can be applied!","Promo available!",{timeOut:2e4}).onTap.pipe(Be(1)).subscribe(()=>{this.onClickToastPromo.next(!0)}),this.previousTotalEligible=e}getTotalEligiblePromotion(){return this.Data?.filter(t=>t.Eligible).length}generatePromotionDesc(e){let t="";switch(e.TypeID){case 2:t+="Minimum "+this.decimalPipe.transform(e.MinimumAmount)+" ",e.ListVariant.length>0?(t=t+" piece of ",t+=this.generateItemListDescription(e.ListVariant)):e.ListCategory.length>0?(t+="from category ",t+=this.generateItemListDescription(e.ListCategory)):t+="items";break;case 1:t+="Minimum spend Rp. "+this.decimalPipe.transform(e.MinimumAmount);break;case 3:t+=`Apply
3
3
  ${e.Discount1!==0?"discount1 = "+e.Discount1+"%":""}
4
4
  ${e.Discount1!==0&&e.Discount2!==0?" and ":""}
@@ -1 +1 @@
1
- import{a as P}from"./chunk-2ULGMZHE.js";import{a as C}from"./chunk-6ZOGADBZ.js";import{a as w}from"./chunk-SO3WWYN3.js";import{a as A}from"./chunk-M7KP6PSY.js";import{a as I}from"./chunk-D35OBUDE.js";import{a as l}from"./chunk-2FWFPV5I.js";import{a as c}from"./chunk-AHCRE4GP.js";import{fa as y,na as f,t as L,z as S}from"./chunk-DZT5XHBQ.js";import{a as F}from"./chunk-7DCB7DB2.js";var g=class{enabledDragItem;constructor(){this.enabledDragItem=!1}drop(o,t){C(t.Data,o.previousIndex,o.currentIndex)}toggleEnabledDragItem(){}onSaveDragAndDrop(o,t){this.enabledDragItem=!this.enabledDragItem,this.enabledDragItem||t.postListID(o,t.data.Data)}onPutSaveDragAndDrop(o,t){this.enabledDragItem=!this.enabledDragItem,this.enabledDragItem||t.putListID(o,t.data.Data)}};var u=class{constructor(o){this.httpService=o}exportCSV(o,t,e,i){e.pageData.Filter.Export=!0,e.pageData.Filter.FormatType=0,i=i||"export.csv",this.httpService.post(`/api/${t}`,e.pageData.Filter).subscribe(r=>{o.convertToCSV(r,i),e.pageData.Filter.Export=!1})}convertToCSV(o,t=!1,e){let i=this.ExportDataFromUI2(t);o.convertToCSV(i,e)}ExportDataFromUI2(o=!1){let t=document.getElementById("tableGrid"),e=[];return c.IsNotEmpty(t)&&t.querySelectorAll("tr").forEach(r=>{let a=new Object,s=0;r.querySelectorAll("th, td").forEach(n=>{s++;let b=parseInt(n.getAttribute("colspan"));for(let h=1;h<b;h++)a["column"+s]="",s++;let m=n.innerText,v=m.toString().split("");if(o&&v[0]==="0"&&v.length>1){let h="'"+m.trim();a["column"+s]=h}else a["column"+s]=m.trim()}),e.push(a)}),e}};var d=class{listTotal;pageSize;show;constructor(){this.listTotal=0,this.pageSize=0,this.show=!1}changePaginationData(o){this.pageSize=o.pageData.Filter.RowCount,this.listTotal=o.data?.ListTotal??o.data?.Data?.total?.value,this.show=this.pageSize<=this.listTotal}changePage(o,t,e){t.Filter.PageNumber=o.pageIndex+1,e.getListData()}};var x=class extends A{constructor(t,e,i,r,a,s,p){super(t);this.httpService=e;this.dataAPI=i;this.pageAPI=r;this.toastrService=a;this.route=s;this.initOpenDialog=p;this.exportHandler=new u(e),r?(s&&(this.loaderPayload=F({ListIDs:this.reportFilterService?.initOutletFilter()},s.snapshot.queryParams)),this.preInitLoader(),S([this.menuData$,this.httpService.post("/api/"+this.pageAPI,this.loaderPayload)]).pipe(L(([n,b])=>b)).pipe(I()).subscribe(n=>{this.pageData=n,this.pageData.Filter||(this.pageData.Filter={},this.pageData.Filter.RowCount=20),this.pageData.Filter.PageNumber=1,this.pageData.Filter.ID=this.loaderPayload.ID,this.preInitList(),p?this.openDialogFilter.openDialog():this.getListData()})):(this.pageData.Filter.RowCount=20,this.pageData.Filter.PageNumber=1,this.preInitList(),S({menuData:this.menuData$,listData:this.getListData$()}).pipe(I()).subscribe())}openDialogFilter=f(w);reportFilterService=f(P);pageData={Filter:{},Options:{},Roles:{},Config:{}};data;pagination=new d;dragDrop=new g;exportHandler;comparation=0;loaderPayload={};preInitLoader(){}preInitList(){}getListData(t){this.preGetList(),this.dataAPI&&this.httpService.post("/api/"+this.dataAPI,this.pageData.Filter).subscribe(e=>{this.data=e,this.postInit(e),this.pagination.changePaginationData(this),t&&(this.pageData.HideStoreApiCount=!1)})}getListData$(t){return this.preGetList(),this.httpService.post("/api/"+this.dataAPI,this.pageData.Filter).pipe(y(e=>{this.data=e,this.postInit(e),this.pagination.changePaginationData(this),t&&(this.pageData.HideStoreApiCount=!1)}))}searchFromPageOne(){this.preSearchFromPageOne(),this.pageData.Filter.PageNumber=1,this.getListData("filterMode")}postInit(t){t.PageTitle!=null&&(this.menuData.H=t.PageTitle)}preGetList(){this.pageData.Filter.From==null&&(this.pageData.Filter.From=c.MinDate),this.pageData.Filter.To==null&&(this.pageData.Filter.To=c.MinDate)}preSearchFromPageOne(){}onPaginationChange(t){this.pagination.changePage(t,this.pageData,this)}onSelectAllData(t){this.data.Data=this.data.Data.map(e=>(e.selected=t,e))}getSelectedData(){let t=[];return this.data&&(t=this.data.Data.filter(e=>e.selected)),t}httpPostListID(t,e,i){if(e||(e="Are you sure you want to selected record/s?"),confirm(e)==!1)return;let r=this.getSelectedData();r.length>0&&this.postListID(t,r,i)}httpPutListID(t,e,i){if(e||(e="Are you sure you want to selected record/s?"),confirm(e)==!1)return;let r=this.getSelectedData();r.length>0&&this.putListID(t,r,i)}httpDeleteListID(t,e,i){if(e||(e="Are you sure you want to delete selected record/s?"),confirm(e)==!1)return;let r=this.getSelectedData();r.length>0&&this.DeleteListID(t,r,i)}onSaveDragAndDrop(t){this.dragDrop.onSaveDragAndDrop(t,this)}onPutSaveDragAndDrop(t){this.dragDrop.onPutSaveDragAndDrop(t,this)}postListID(t,e,i){let r=e.map(a=>i?a[i]:a.ID);this.httpService.post(`/api/${t}`,r,1e6,!0).subscribe(a=>{this.toastrService.success(a.Message?a.Message:a,l.Success),this.getListData()},a=>{let s=a.status+" "+a.statusText;this.toastrService.error(a.error.Message!=""?a.error.Message:"An unknown error has occured!",s,{enableHtml:!0})})}putListID(t,e,i){let r=e.map(a=>i?a[i]:a.ID);this.httpService.put(`/api/${t}`,r).subscribe(a=>{this.toastrService.success(a.Message?a.Message:a,l.Success),this.afterPutListSuccess(),this.getListData()})}afterPutListSuccess(){}DeleteListID(t,e,i){let r=e.map(a=>i?a[i]:a.ID);this.httpService.delete(`/api/${t}`,{body:r}).subscribe(a=>{this.toastrService.success(a.Message?a.Message:a,l.Success),this.getListData()})}postData(t,e){this.httpService.post("/API/"+t,e).subscribe(i=>{this.getListData(),this.toastrService.success(i.Message?i.Message:i,l.Success)})}compare(t,e,i){return(t<e?-1:1)*(i?1:-1)}exportCSV(t,e,i){this.exportHandler.exportCSV(t,e,this,i)}s2ab(t){for(var e=new ArrayBuffer(t.length),i=new Uint8Array(e),r=0;r!=t.length;++r)i[r]=t.charCodeAt(r)&255;return e}exportXlsx(t,e){this.pageData.Filter.FormatType=1,this.pageData.Filter.Export=!0,this.httpService.post(`/api/${t}`,this.pageData.Filter).subscribe(i=>{e=decodeURI(e);let r=window.URL.createObjectURL(new Blob([this.s2ab(atob(i))],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,"})),a=document.createElement("a");a.href=r,a.setAttribute("download",e),document.body.appendChild(a),a.click(),window.URL.revokeObjectURL(r),a.remove()})}convertToCSV(t,e=!1,i){let r=this.exportHandler.ExportDataFromUI2(e);t.convertToCSV(r,i)}OnCompare(t){let e=t?this.data[t]:this.data;if(e.length<1)return;let i=Object.assign({},this.pageData.Filter);i.From=new Date(new Date(this.pageData.Filter.From).getFullYear(),new Date(this.pageData.Filter.From).getMonth()-1,1),i.To=new Date(new Date(this.pageData.Filter.To).getFullYear(),new Date(this.pageData.Filter.To).getMonth(),0).toDateString(),this.httpService.post("/API/"+this.dataAPI,i).subscribe(r=>{let a=t?r[t]:r;this.comparation=0,e.forEach(s=>{s.PrevIndex="-",s.CurrentIndex="-",s.Increase="-";let p=a.filter(n=>n.EntityID==s.EntityID);if(s.CurrentIndex=s.Rank,p.length>0){let n=p[0];s.PrevIndex=n.Rank,n.SalesNet?s.Increase=(s.SalesNet-n.SalesNet)/n.SalesNet*100:n.Sales&&(s.Increase=(s.Sales-n.Sales)/n.Sales*100),s.IsPositive=s.Increase>0,s.IsNegative=s.Increase<0,this.comparation+=s.Increase}})})}};export{x as a};
1
+ import{a as P}from"./chunk-H24HNIUV.js";import{a as C}from"./chunk-6ZOGADBZ.js";import{a as w}from"./chunk-MERQX2AF.js";import{a as A}from"./chunk-DHQUQTIV.js";import{a as I}from"./chunk-D35OBUDE.js";import{a as l}from"./chunk-2FWFPV5I.js";import{a as c}from"./chunk-AHCRE4GP.js";import{fa as y,na as f,t as L,z as S}from"./chunk-DZT5XHBQ.js";import{a as F}from"./chunk-7DCB7DB2.js";var g=class{enabledDragItem;constructor(){this.enabledDragItem=!1}drop(o,t){C(t.Data,o.previousIndex,o.currentIndex)}toggleEnabledDragItem(){}onSaveDragAndDrop(o,t){this.enabledDragItem=!this.enabledDragItem,this.enabledDragItem||t.postListID(o,t.data.Data)}onPutSaveDragAndDrop(o,t){this.enabledDragItem=!this.enabledDragItem,this.enabledDragItem||t.putListID(o,t.data.Data)}};var u=class{constructor(o){this.httpService=o}exportCSV(o,t,e,i){e.pageData.Filter.Export=!0,e.pageData.Filter.FormatType=0,i=i||"export.csv",this.httpService.post(`/api/${t}`,e.pageData.Filter).subscribe(r=>{o.convertToCSV(r,i),e.pageData.Filter.Export=!1})}convertToCSV(o,t=!1,e){let i=this.ExportDataFromUI2(t);o.convertToCSV(i,e)}ExportDataFromUI2(o=!1){let t=document.getElementById("tableGrid"),e=[];return c.IsNotEmpty(t)&&t.querySelectorAll("tr").forEach(r=>{let a=new Object,s=0;r.querySelectorAll("th, td").forEach(n=>{s++;let b=parseInt(n.getAttribute("colspan"));for(let h=1;h<b;h++)a["column"+s]="",s++;let m=n.innerText,v=m.toString().split("");if(o&&v[0]==="0"&&v.length>1){let h="'"+m.trim();a["column"+s]=h}else a["column"+s]=m.trim()}),e.push(a)}),e}};var d=class{listTotal;pageSize;show;constructor(){this.listTotal=0,this.pageSize=0,this.show=!1}changePaginationData(o){this.pageSize=o.pageData.Filter.RowCount,this.listTotal=o.data?.ListTotal??o.data?.Data?.total?.value,this.show=this.pageSize<=this.listTotal}changePage(o,t,e){t.Filter.PageNumber=o.pageIndex+1,e.getListData()}};var x=class extends A{constructor(t,e,i,r,a,s,p){super(t);this.httpService=e;this.dataAPI=i;this.pageAPI=r;this.toastrService=a;this.route=s;this.initOpenDialog=p;this.exportHandler=new u(e),r?(s&&(this.loaderPayload=F({ListIDs:this.reportFilterService?.initOutletFilter()},s.snapshot.queryParams)),this.preInitLoader(),S([this.menuData$,this.httpService.post("/api/"+this.pageAPI,this.loaderPayload)]).pipe(L(([n,b])=>b)).pipe(I()).subscribe(n=>{this.pageData=n,this.pageData.Filter||(this.pageData.Filter={},this.pageData.Filter.RowCount=20),this.pageData.Filter.PageNumber=1,this.pageData.Filter.ID=this.loaderPayload.ID,this.preInitList(),p?this.openDialogFilter.openDialog():this.getListData()})):(this.pageData.Filter.RowCount=20,this.pageData.Filter.PageNumber=1,this.preInitList(),S({menuData:this.menuData$,listData:this.getListData$()}).pipe(I()).subscribe())}openDialogFilter=f(w);reportFilterService=f(P);pageData={Filter:{},Options:{},Roles:{},Config:{}};data;pagination=new d;dragDrop=new g;exportHandler;comparation=0;loaderPayload={};preInitLoader(){}preInitList(){}getListData(t){this.preGetList(),this.dataAPI&&this.httpService.post("/api/"+this.dataAPI,this.pageData.Filter).subscribe(e=>{this.data=e,this.postInit(e),this.pagination.changePaginationData(this),t&&(this.pageData.HideStoreApiCount=!1)})}getListData$(t){return this.preGetList(),this.httpService.post("/api/"+this.dataAPI,this.pageData.Filter).pipe(y(e=>{this.data=e,this.postInit(e),this.pagination.changePaginationData(this),t&&(this.pageData.HideStoreApiCount=!1)}))}searchFromPageOne(){this.preSearchFromPageOne(),this.pageData.Filter.PageNumber=1,this.getListData("filterMode")}postInit(t){t.PageTitle!=null&&(this.menuData.H=t.PageTitle)}preGetList(){this.pageData.Filter.From==null&&(this.pageData.Filter.From=c.MinDate),this.pageData.Filter.To==null&&(this.pageData.Filter.To=c.MinDate)}preSearchFromPageOne(){}onPaginationChange(t){this.pagination.changePage(t,this.pageData,this)}onSelectAllData(t){this.data.Data=this.data.Data.map(e=>(e.selected=t,e))}getSelectedData(){let t=[];return this.data&&(t=this.data.Data.filter(e=>e.selected)),t}httpPostListID(t,e,i){if(e||(e="Are you sure you want to selected record/s?"),confirm(e)==!1)return;let r=this.getSelectedData();r.length>0&&this.postListID(t,r,i)}httpPutListID(t,e,i){if(e||(e="Are you sure you want to selected record/s?"),confirm(e)==!1)return;let r=this.getSelectedData();r.length>0&&this.putListID(t,r,i)}httpDeleteListID(t,e,i){if(e||(e="Are you sure you want to delete selected record/s?"),confirm(e)==!1)return;let r=this.getSelectedData();r.length>0&&this.DeleteListID(t,r,i)}onSaveDragAndDrop(t){this.dragDrop.onSaveDragAndDrop(t,this)}onPutSaveDragAndDrop(t){this.dragDrop.onPutSaveDragAndDrop(t,this)}postListID(t,e,i){let r=e.map(a=>i?a[i]:a.ID);this.httpService.post(`/api/${t}`,r,1e6,!0).subscribe(a=>{this.toastrService.success(a.Message?a.Message:a,l.Success),this.getListData()},a=>{let s=a.status+" "+a.statusText;this.toastrService.error(a.error.Message!=""?a.error.Message:"An unknown error has occured!",s,{enableHtml:!0})})}putListID(t,e,i){let r=e.map(a=>i?a[i]:a.ID);this.httpService.put(`/api/${t}`,r).subscribe(a=>{this.toastrService.success(a.Message?a.Message:a,l.Success),this.afterPutListSuccess(),this.getListData()})}afterPutListSuccess(){}DeleteListID(t,e,i){let r=e.map(a=>i?a[i]:a.ID);this.httpService.delete(`/api/${t}`,{body:r}).subscribe(a=>{this.toastrService.success(a.Message?a.Message:a,l.Success),this.getListData()})}postData(t,e){this.httpService.post("/API/"+t,e).subscribe(i=>{this.getListData(),this.toastrService.success(i.Message?i.Message:i,l.Success)})}compare(t,e,i){return(t<e?-1:1)*(i?1:-1)}exportCSV(t,e,i){this.exportHandler.exportCSV(t,e,this,i)}s2ab(t){for(var e=new ArrayBuffer(t.length),i=new Uint8Array(e),r=0;r!=t.length;++r)i[r]=t.charCodeAt(r)&255;return e}exportXlsx(t,e){this.pageData.Filter.FormatType=1,this.pageData.Filter.Export=!0,this.httpService.post(`/api/${t}`,this.pageData.Filter).subscribe(i=>{e=decodeURI(e);let r=window.URL.createObjectURL(new Blob([this.s2ab(atob(i))],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,"})),a=document.createElement("a");a.href=r,a.setAttribute("download",e),document.body.appendChild(a),a.click(),window.URL.revokeObjectURL(r),a.remove()})}convertToCSV(t,e=!1,i){let r=this.exportHandler.ExportDataFromUI2(e);t.convertToCSV(r,i)}OnCompare(t){let e=t?this.data[t]:this.data;if(e.length<1)return;let i=Object.assign({},this.pageData.Filter);i.From=new Date(new Date(this.pageData.Filter.From).getFullYear(),new Date(this.pageData.Filter.From).getMonth()-1,1),i.To=new Date(new Date(this.pageData.Filter.To).getFullYear(),new Date(this.pageData.Filter.To).getMonth(),0).toDateString(),this.httpService.post("/API/"+this.dataAPI,i).subscribe(r=>{let a=t?r[t]:r;this.comparation=0,e.forEach(s=>{s.PrevIndex="-",s.CurrentIndex="-",s.Increase="-";let p=a.filter(n=>n.EntityID==s.EntityID);if(s.CurrentIndex=s.Rank,p.length>0){let n=p[0];s.PrevIndex=n.Rank,n.SalesNet?s.Increase=(s.SalesNet-n.SalesNet)/n.SalesNet*100:n.Sales&&(s.Increase=(s.Sales-n.Sales)/n.Sales*100),s.IsPositive=s.Increase>0,s.IsNegative=s.Increase<0,this.comparation+=s.Increase}})})}};export{x as a};
@@ -1 +1 @@
1
- import{a as e}from"./chunk-VJWRLXE4.js";import{a as t}from"./chunk-7DCB7DB2.js";var i=class extends e{constructor(r,a,o,l,s,p,F){super(r,a,o,l,s,p,F)}preInitLoader(){this.loaderPayload=t({ListIDs:this.reportFilterService.initOutletFilter([])},this.loaderPayload)}preInitList(){this.pageData.Filter.ListIDs=this.loaderPayload.ListIDs,this.pageData.Filter.From=this.reportFilterService.initDateFromFilter(this.pageData?.Filter?.From),this.pageData.Filter.To=this.reportFilterService.initDateToFilter(this.pageData?.Filter?.To)}onFilterOutlets(){this.reportFilterService.setOutletFilter(this.pageData.Filter.ListIDs)}onFilterFromDate(){this.reportFilterService.setDateFromFilter(this.pageData?.Filter?.From)}onFilterToDate(){this.reportFilterService.setDateToFilter(this.pageData?.Filter?.To)}};export{i as a};
1
+ import{a as e}from"./chunk-W2TSDYEA.js";import{a as t}from"./chunk-7DCB7DB2.js";var i=class extends e{constructor(r,a,o,l,s,p,F){super(r,a,o,l,s,p,F)}preInitLoader(){this.loaderPayload=t({ListIDs:this.reportFilterService.initOutletFilter([])},this.loaderPayload)}preInitList(){this.pageData.Filter.ListIDs=this.loaderPayload.ListIDs,this.pageData.Filter.From=this.reportFilterService.initDateFromFilter(this.pageData?.Filter?.From),this.pageData.Filter.To=this.reportFilterService.initDateToFilter(this.pageData?.Filter?.To)}onFilterOutlets(){this.reportFilterService.setOutletFilter(this.pageData.Filter.ListIDs)}onFilterFromDate(){this.reportFilterService.setDateFromFilter(this.pageData?.Filter?.From)}onFilterToDate(){this.reportFilterService.setDateToFilter(this.pageData?.Filter?.To)}};export{i as a};
@@ -1 +1 @@
1
- import{a as ee}from"./chunk-Z7WYC46Q.js";import{a as K,b as Q}from"./chunk-XP2OIGWH.js";import{a as J}from"./chunk-L2EDFSBR.js";import{a as U,b as X}from"./chunk-7ENHJR7R.js";import{h as Z,i as $}from"./chunk-SO3WWYN3.js";import{b as Y}from"./chunk-M7KP6PSY.js";import{h as q,m as z,q as G}from"./chunk-677WPFLK.js";import{b as j,c as H}from"./chunk-CIBQBSM6.js";import{a as D}from"./chunk-2FWFPV5I.js";import{D as b,c as A,h as v,o as k}from"./chunk-P7HKWFZT.js";import{$a as l,Eb as w,Fa as C,Gb as P,Hb as F,Ib as o,Ja as g,Jb as a,Ob as N,Od as L,Qb as c,Rb as d,Vd as B,Yd as R,Zc as W,db as S,ec as r,fc as T,jc as E,jd as h,kb as M,kc as _,lc as V,ob as I,qb as O,va as u,vb as p,wa as f}from"./chunk-DZT5XHBQ.js";var x=class s{stringPrefixMask=g();stringSuffixMask=g();stringPrefixMaskChange=new C;stringSuffixMaskChange=new C;onStringPrefixMaskChange(m){this.stringPrefixMaskChange.emit(m)}onStringSuffixMaskChange(m){this.stringSuffixMaskChange.emit(m)}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=M({type:s,selectors:[["masking-config"]],inputs:{stringPrefixMask:[1,"stringPrefixMask"],stringSuffixMask:[1,"stringSuffixMask"]},outputs:{stringPrefixMaskChange:"stringPrefixMaskChange",stringSuffixMaskChange:"stringSuffixMaskChange"},decls:18,vars:2,consts:[[1,"row","my-10","ms-2"],[1,"col-md-2"],[1,"notes","text-muted"],[1,"col-md-10"],[1,"row"],[1,"col-6"],["matTooltipPosition","above","matTooltip","Sets the number of characters at the beginning of the sensitive field that remain visible",1,"form-floating-outline"],["type","text","id","name","placeholder","Max Visible Prefix","autoNum","",1,"form-control",3,"ngModelChange","ngModel"],["matTooltipPosition","above","matTooltip","Sets the number of characters at the end of the sensitive field that remain visible",1,"form-floating-outline"],["type","text","id","name","placeholder","Max Visible Suffix","autoNum","",1,"form-control",3,"ngModelChange","ngModel"]],template:function(e,i){e&1&&(o(0,"div",0)(1,"div",1)(2,"h5"),r(3,"Visible Masking Settings"),a(),o(4,"i",2),r(5," Configure how many characters at the beginning and end of sensitive fields remain visible. "),a()(),o(6,"div",3)(7,"div",4)(8,"div",5)(9,"div",6)(10,"input",7),c("ngModelChange",function(n){return i.onStringPrefixMaskChange(n)}),a(),o(11,"label"),r(12,"Max Visible Prefix"),a()()(),o(13,"div",5)(14,"div",8)(15,"input",9),c("ngModelChange",function(n){return i.onStringSuffixMaskChange(n)}),a(),o(16,"label"),r(17,"Max Visible Suffix"),a()()()()()()),e&2&&(l(10),p("ngModel",i.stringPrefixMask()),l(5),p("ngModel",i.stringSuffixMask()))},dependencies:[h,b,A,v,k,U,X,H,j],encapsulation:2})};function ae(s,m){if(s&1&&(o(0,"mat-option",10),r(1),a()),s&2){let e=m.$implicit;p("value",e),l(),T(e)}}function re(s,m){if(s&1&&(o(0,"mat-option",10),r(1),a()),s&2){let e=m.$implicit;p("value",e),l(),T(e)}}var y=class s{options=g();contacts=g([]);products=g([]);contactsChange=new C;productsChange=new C;onContactsChange(m){this.contactsChange.emit(m)}onProductsChange(m){this.productsChange.emit(m)}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=M({type:s,selectors:[["masking-options"]],inputs:{options:[1,"options"],contacts:[1,"contacts"],products:[1,"products"]},outputs:{contactsChange:"contactsChange",productsChange:"productsChange"},decls:27,vars:2,consts:[[1,"row","my-10","ms-2"],[1,"col-md-2"],[1,"notes","text-muted"],["href","https://support.dealpos.com/en/articles/8278008-sensitive-field-roles-configuration-for-contacts","target","_blank"],[1,"col-md-10"],[1,"row"],[1,"col-6"],["appearance","outline",1,"w-100"],[1,"fs-4"],["placeholder","Product","multiple","",3,"ngModelChange","ngModel"],[3,"value"],["placeholder","Contact","multiple","",3,"ngModelChange","ngModel"]],template:function(e,i){if(e&1&&(o(0,"div",0)(1,"div",1)(2,"h5"),r(3,"Sensitive Field"),a(),o(4,"i",2),r(5,"When you mark a property as sensitive, the property value cannot be viewed to users without 'sensitive field' role. Please refer this "),o(6,"a",3),r(7,"Article"),a(),r(8," for more information"),a()(),o(9,"div",4)(10,"div",5)(11,"div",6)(12,"mat-form-field",7)(13,"mat-label")(14,"span",8),r(15,"Product"),a()(),o(16,"mat-select",9),c("ngModelChange",function(n){return i.onProductsChange(n)}),P(17,ae,2,2,"mat-option",10,w),a()()(),o(19,"div",6)(20,"mat-form-field",7)(21,"mat-label")(22,"span",8),r(23,"Contact"),a()(),o(24,"mat-select",11),c("ngModelChange",function(n){return i.onContactsChange(n)}),P(25,re,2,2,"mat-option",10,w),a()()()()()()),e&2){let t,n;l(16),p("ngModel",i.products()),l(),F((t=i.options())==null?null:t.Product),l(7),p("ngModel",i.contacts()),l(),F((n=i.options())==null?null:n.Customer)}},dependencies:[h,Q,z,q,K,G,J,b,v,k],encapsulation:2})};function se(s,m){if(s&1){let e=N();o(0,"mainpanel-cmp",1)(1,"actions")(2,"button",2),c("click",function(){u(e);let t=d();return f(t.onSubmit("Setup/Configuration/SubmitSensitiveFieldConfigurationV2"))}),r(3," Save "),a()(),o(4,"content")(5,"div",3)(6,"ul",4)(7,"li",5)(8,"button",6),r(9," Objects "),a()(),o(10,"li",5)(11,"button",7),r(12," Masking "),a()()(),o(13,"div",8)(14,"div",9)(15,"masking-options",10),V("productsChange",function(t){u(e);let n=d();return _(n.data.Form.Product,t)||(n.data.Form.Product=t),f(t)})("contactsChange",function(t){u(e);let n=d();return _(n.data.Form.Customer,t)||(n.data.Form.Customer=t),f(t)}),a()(),o(16,"div",11)(17,"masking-config",12),V("stringPrefixMaskChange",function(t){u(e);let n=d();return _(n.data.Form.Masking.StringPrefixMaskVisibleCharacterLength,t)||(n.data.Form.Masking.StringPrefixMaskVisibleCharacterLength=t),f(t)})("stringSuffixMaskChange",function(t){u(e);let n=d();return _(n.data.Form.Masking.StringSuffixMaskVisibleCharacterLength,t)||(n.data.Form.Masking.StringSuffixMaskVisibleCharacterLength=t),f(t)}),a()()()()()()}if(s&2){let e=d();p("pageData",e.menuData)("hideSearchDropdown",!0)("hideSearchBox",!0),l(15),p("options",e.data.Options),E("products",e.data.Form.Product)("contacts",e.data.Form.Customer),l(2),E("stringPrefixMask",e.data.Form.Masking.StringPrefixMaskVisibleCharacterLength)("stringSuffixMask",e.data.Form.Masking.StringSuffixMaskVisibleCharacterLength)}}var ne=class s extends ee{constructor(e,i,t,n){super(e,i,"Setup/ConfigurationLoader/SensitiveFieldConfigurationV2",t);this.httpService=i;this.activatedRoute=t;this.toaster=n}onSubmitSuccess(e){e?.MessageWarning?this.toaster.warning(e.MessageWarning,D.Warning):this.toaster.success("Config has been updated succesfully!",D.Success)}static \u0275fac=function(i){return new(i||s)(S(Y),S(R),S(L),S(B))};static \u0275cmp=M({type:s,selectors:[["app-sensitive-field"]],features:[I],decls:1,vars:1,consts:[[3,"pageData","hideSearchDropdown","hideSearchBox",4,"ngIf"],[3,"pageData","hideSearchDropdown","hideSearchBox"],["type","button","role","button",1,"btn","btn-success",3,"click"],[1,"container-fluid","py-5","bg-light-white"],["id","myTab","role","tablist",1,"nav","nav-tabs"],[1,"nav-item"],["id","masking-options-tab","data-bs-toggle","tab","data-bs-target","#masking-options","role","tab","aria-controls","masking-options","aria-selected","true",1,"nav-link","active"],["id","masking-tab","data-bs-toggle","tab","data-bs-target","#masking","role","tab","aria-controls","masking","aria-selected","false",1,"nav-link"],["id","myTabContent",1,"tab-content","border-top-0","bg-white"],["id","masking-options","aria-labelledby","masking-options-tab","role","tabpanel",1,"tab-pane","fade","mt-0","p-7","show","active"],[3,"productsChange","contactsChange","options","products","contacts"],["id","masking","aria-labelledby","masking-tab","role","tabpanel",1,"tab-pane","fade","mt-0","p-7"],[3,"stringPrefixMaskChange","stringSuffixMaskChange","stringPrefixMask","stringSuffixMask"]],template:function(i,t){i&1&&O(0,se,18,8,"mainpanel-cmp",0),i&2&&p("ngIf",t.formData)},dependencies:[h,W,$,Z,x,y],encapsulation:2})};export{ne as a};
1
+ import{a as ee}from"./chunk-RYONOB6O.js";import{a as K,b as Q}from"./chunk-XP2OIGWH.js";import{a as J}from"./chunk-L2EDFSBR.js";import{a as U,b as X}from"./chunk-7ENHJR7R.js";import{h as Z,i as $}from"./chunk-MERQX2AF.js";import{b as Y}from"./chunk-DHQUQTIV.js";import{h as q,m as z,q as G}from"./chunk-677WPFLK.js";import{b as j,c as H}from"./chunk-CIBQBSM6.js";import{a as D}from"./chunk-2FWFPV5I.js";import{D as b,c as A,h as v,o as k}from"./chunk-P7HKWFZT.js";import{$a as l,Eb as w,Fa as C,Gb as P,Hb as F,Ib as o,Ja as g,Jb as a,Ob as N,Od as L,Qb as c,Rb as d,Vd as B,Yd as R,Zc as W,db as S,ec as r,fc as T,jc as E,jd as h,kb as M,kc as _,lc as V,ob as I,qb as O,va as u,vb as p,wa as f}from"./chunk-DZT5XHBQ.js";var x=class s{stringPrefixMask=g();stringSuffixMask=g();stringPrefixMaskChange=new C;stringSuffixMaskChange=new C;onStringPrefixMaskChange(m){this.stringPrefixMaskChange.emit(m)}onStringSuffixMaskChange(m){this.stringSuffixMaskChange.emit(m)}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=M({type:s,selectors:[["masking-config"]],inputs:{stringPrefixMask:[1,"stringPrefixMask"],stringSuffixMask:[1,"stringSuffixMask"]},outputs:{stringPrefixMaskChange:"stringPrefixMaskChange",stringSuffixMaskChange:"stringSuffixMaskChange"},decls:18,vars:2,consts:[[1,"row","my-10","ms-2"],[1,"col-md-2"],[1,"notes","text-muted"],[1,"col-md-10"],[1,"row"],[1,"col-6"],["matTooltipPosition","above","matTooltip","Sets the number of characters at the beginning of the sensitive field that remain visible",1,"form-floating-outline"],["type","text","id","name","placeholder","Max Visible Prefix","autoNum","",1,"form-control",3,"ngModelChange","ngModel"],["matTooltipPosition","above","matTooltip","Sets the number of characters at the end of the sensitive field that remain visible",1,"form-floating-outline"],["type","text","id","name","placeholder","Max Visible Suffix","autoNum","",1,"form-control",3,"ngModelChange","ngModel"]],template:function(e,i){e&1&&(o(0,"div",0)(1,"div",1)(2,"h5"),r(3,"Visible Masking Settings"),a(),o(4,"i",2),r(5," Configure how many characters at the beginning and end of sensitive fields remain visible. "),a()(),o(6,"div",3)(7,"div",4)(8,"div",5)(9,"div",6)(10,"input",7),c("ngModelChange",function(n){return i.onStringPrefixMaskChange(n)}),a(),o(11,"label"),r(12,"Max Visible Prefix"),a()()(),o(13,"div",5)(14,"div",8)(15,"input",9),c("ngModelChange",function(n){return i.onStringSuffixMaskChange(n)}),a(),o(16,"label"),r(17,"Max Visible Suffix"),a()()()()()()),e&2&&(l(10),p("ngModel",i.stringPrefixMask()),l(5),p("ngModel",i.stringSuffixMask()))},dependencies:[h,b,A,v,k,U,X,H,j],encapsulation:2})};function ae(s,m){if(s&1&&(o(0,"mat-option",10),r(1),a()),s&2){let e=m.$implicit;p("value",e),l(),T(e)}}function re(s,m){if(s&1&&(o(0,"mat-option",10),r(1),a()),s&2){let e=m.$implicit;p("value",e),l(),T(e)}}var y=class s{options=g();contacts=g([]);products=g([]);contactsChange=new C;productsChange=new C;onContactsChange(m){this.contactsChange.emit(m)}onProductsChange(m){this.productsChange.emit(m)}static \u0275fac=function(e){return new(e||s)};static \u0275cmp=M({type:s,selectors:[["masking-options"]],inputs:{options:[1,"options"],contacts:[1,"contacts"],products:[1,"products"]},outputs:{contactsChange:"contactsChange",productsChange:"productsChange"},decls:27,vars:2,consts:[[1,"row","my-10","ms-2"],[1,"col-md-2"],[1,"notes","text-muted"],["href","https://support.dealpos.com/en/articles/8278008-sensitive-field-roles-configuration-for-contacts","target","_blank"],[1,"col-md-10"],[1,"row"],[1,"col-6"],["appearance","outline",1,"w-100"],[1,"fs-4"],["placeholder","Product","multiple","",3,"ngModelChange","ngModel"],[3,"value"],["placeholder","Contact","multiple","",3,"ngModelChange","ngModel"]],template:function(e,i){if(e&1&&(o(0,"div",0)(1,"div",1)(2,"h5"),r(3,"Sensitive Field"),a(),o(4,"i",2),r(5,"When you mark a property as sensitive, the property value cannot be viewed to users without 'sensitive field' role. Please refer this "),o(6,"a",3),r(7,"Article"),a(),r(8," for more information"),a()(),o(9,"div",4)(10,"div",5)(11,"div",6)(12,"mat-form-field",7)(13,"mat-label")(14,"span",8),r(15,"Product"),a()(),o(16,"mat-select",9),c("ngModelChange",function(n){return i.onProductsChange(n)}),P(17,ae,2,2,"mat-option",10,w),a()()(),o(19,"div",6)(20,"mat-form-field",7)(21,"mat-label")(22,"span",8),r(23,"Contact"),a()(),o(24,"mat-select",11),c("ngModelChange",function(n){return i.onContactsChange(n)}),P(25,re,2,2,"mat-option",10,w),a()()()()()()),e&2){let t,n;l(16),p("ngModel",i.products()),l(),F((t=i.options())==null?null:t.Product),l(7),p("ngModel",i.contacts()),l(),F((n=i.options())==null?null:n.Customer)}},dependencies:[h,Q,z,q,K,G,J,b,v,k],encapsulation:2})};function se(s,m){if(s&1){let e=N();o(0,"mainpanel-cmp",1)(1,"actions")(2,"button",2),c("click",function(){u(e);let t=d();return f(t.onSubmit("Setup/Configuration/SubmitSensitiveFieldConfigurationV2"))}),r(3," Save "),a()(),o(4,"content")(5,"div",3)(6,"ul",4)(7,"li",5)(8,"button",6),r(9," Objects "),a()(),o(10,"li",5)(11,"button",7),r(12," Masking "),a()()(),o(13,"div",8)(14,"div",9)(15,"masking-options",10),V("productsChange",function(t){u(e);let n=d();return _(n.data.Form.Product,t)||(n.data.Form.Product=t),f(t)})("contactsChange",function(t){u(e);let n=d();return _(n.data.Form.Customer,t)||(n.data.Form.Customer=t),f(t)}),a()(),o(16,"div",11)(17,"masking-config",12),V("stringPrefixMaskChange",function(t){u(e);let n=d();return _(n.data.Form.Masking.StringPrefixMaskVisibleCharacterLength,t)||(n.data.Form.Masking.StringPrefixMaskVisibleCharacterLength=t),f(t)})("stringSuffixMaskChange",function(t){u(e);let n=d();return _(n.data.Form.Masking.StringSuffixMaskVisibleCharacterLength,t)||(n.data.Form.Masking.StringSuffixMaskVisibleCharacterLength=t),f(t)}),a()()()()()()}if(s&2){let e=d();p("pageData",e.menuData)("hideSearchDropdown",!0)("hideSearchBox",!0),l(15),p("options",e.data.Options),E("products",e.data.Form.Product)("contacts",e.data.Form.Customer),l(2),E("stringPrefixMask",e.data.Form.Masking.StringPrefixMaskVisibleCharacterLength)("stringSuffixMask",e.data.Form.Masking.StringSuffixMaskVisibleCharacterLength)}}var ne=class s extends ee{constructor(e,i,t,n){super(e,i,"Setup/ConfigurationLoader/SensitiveFieldConfigurationV2",t);this.httpService=i;this.activatedRoute=t;this.toaster=n}onSubmitSuccess(e){e?.MessageWarning?this.toaster.warning(e.MessageWarning,D.Warning):this.toaster.success("Config has been updated succesfully!",D.Success)}static \u0275fac=function(i){return new(i||s)(S(Y),S(R),S(L),S(B))};static \u0275cmp=M({type:s,selectors:[["app-sensitive-field"]],features:[I],decls:1,vars:1,consts:[[3,"pageData","hideSearchDropdown","hideSearchBox",4,"ngIf"],[3,"pageData","hideSearchDropdown","hideSearchBox"],["type","button","role","button",1,"btn","btn-success",3,"click"],[1,"container-fluid","py-5","bg-light-white"],["id","myTab","role","tablist",1,"nav","nav-tabs"],[1,"nav-item"],["id","masking-options-tab","data-bs-toggle","tab","data-bs-target","#masking-options","role","tab","aria-controls","masking-options","aria-selected","true",1,"nav-link","active"],["id","masking-tab","data-bs-toggle","tab","data-bs-target","#masking","role","tab","aria-controls","masking","aria-selected","false",1,"nav-link"],["id","myTabContent",1,"tab-content","border-top-0","bg-white"],["id","masking-options","aria-labelledby","masking-options-tab","role","tabpanel",1,"tab-pane","fade","mt-0","p-7","show","active"],[3,"productsChange","contactsChange","options","products","contacts"],["id","masking","aria-labelledby","masking-tab","role","tabpanel",1,"tab-pane","fade","mt-0","p-7"],[3,"stringPrefixMaskChange","stringSuffixMaskChange","stringPrefixMask","stringSuffixMask"]],template:function(i,t){i&1&&O(0,se,18,8,"mainpanel-cmp",0),i&2&&p("ngIf",t.formData)},dependencies:[h,W,$,Z,x,y],encapsulation:2})};export{ne as a};
@@ -1,2 +1,2 @@
1
- import{P as b}from"./chunk-L2RZWAX3.js";import{a as m}from"./chunk-2FWFPV5I.js";import{a as u}from"./chunk-4YAMWP7V.js";import{Vd as d,Yd as h,ja as n,na as c}from"./chunk-DZT5XHBQ.js";import{j as l}from"./chunk-7DCB7DB2.js";var p=class a{constructor(){}copy(t){return new Promise((o,r)=>{try{if(navigator.clipboard)navigator.clipboard.writeText(t).then(o,r);else{let e=document.createElement("textarea");e.value=t,e.style.position="fixed",document.body.appendChild(e),e.focus(),e.select();try{document.execCommand("copy")?o():r(new Error("Failed to copy with execCommand"))}catch(i){r(i)}finally{document.body.removeChild(e)}}}catch(e){r(e)}})}static \u0275fac=function(o){return new(o||a)};static \u0275prov=n({token:a,factory:a.\u0275fac,providedIn:"root"})};var y=class a{toastr=c(d);httpService=c(h);copyToClipBoard=c(p);createCustomerFromNewNumberAndSendReceipt(t,o,r,e,i){r==0?this.httpService.post(b.CreateCustomerInvoice,{InvoiceID:e.ObjectID,Mobile:t}).subscribe(s=>l(this,null,function*(){this.toastr.success(s.Message,m.Success),yield this.sendReceiptToWhatsapp(t,e,o,i)})):this.toastr.info("WABA is not supported yet",m.Info)}createWhatsappReceipt(t,o,r){let e=I=>new Intl.NumberFormat("id-ID",{style:"currency",currency:"IDR"}).format(I).replace("Rp","").trim().split(",00")?.[0],i=JSON.parse(localStorage.getItem("AccountInfo"))?.BrandName,{ObjectID:s,Final:g,InvoiceNumber:f}=t,v=window.location.host,w=`https://receipt.dealpos.app/s?Data=${window.btoa(`${s}_${v}`)}`;return this.convertWhatsappTemplateMessage({Amount:e(g),Brand:i,Currency:o,Number:f,ReceiptLink:w},r)}convertWhatsappTemplateMessage(t,o){let r=o||u?.whatsappTemplateMessage,e=["Brand","Number","Currency","Amount","ReceiptLink"],i=r;return e.forEach(s=>i=i.replace(`{${s}}`,t[s])),i}redirectToWhatsapp(t,o){let r=t;r=r[0]==="0"?`62${r.slice(1)}`:r;let e=`whatsapp://send?phone=${r}&text=${encodeURIComponent(o)}`;window.location.href=e,this.showToastrWhatsappNoInstalled()}showToastrWhatsappNoInstalled(){let t=!1;window.onblur=function(){t=!0},setTimeout(()=>{t||this.toastr.warning(`Currently, sending an e-receipt automatically opens WhatsApp Desktop, provided the device has the app installed
1
+ import{P as b}from"./chunk-L2RZWAX3.js";import{a as m}from"./chunk-2FWFPV5I.js";import{a as u}from"./chunk-W7HVLC6V.js";import{Vd as d,Yd as h,ja as n,na as c}from"./chunk-DZT5XHBQ.js";import{j as l}from"./chunk-7DCB7DB2.js";var p=class a{constructor(){}copy(t){return new Promise((o,r)=>{try{if(navigator.clipboard)navigator.clipboard.writeText(t).then(o,r);else{let e=document.createElement("textarea");e.value=t,e.style.position="fixed",document.body.appendChild(e),e.focus(),e.select();try{document.execCommand("copy")?o():r(new Error("Failed to copy with execCommand"))}catch(i){r(i)}finally{document.body.removeChild(e)}}}catch(e){r(e)}})}static \u0275fac=function(o){return new(o||a)};static \u0275prov=n({token:a,factory:a.\u0275fac,providedIn:"root"})};var y=class a{toastr=c(d);httpService=c(h);copyToClipBoard=c(p);createCustomerFromNewNumberAndSendReceipt(t,o,r,e,i){r==0?this.httpService.post(b.CreateCustomerInvoice,{InvoiceID:e.ObjectID,Mobile:t}).subscribe(s=>l(this,null,function*(){this.toastr.success(s.Message,m.Success),yield this.sendReceiptToWhatsapp(t,e,o,i)})):this.toastr.info("WABA is not supported yet",m.Info)}createWhatsappReceipt(t,o,r){let e=I=>new Intl.NumberFormat("id-ID",{style:"currency",currency:"IDR"}).format(I).replace("Rp","").trim().split(",00")?.[0],i=JSON.parse(localStorage.getItem("AccountInfo"))?.BrandName,{ObjectID:s,Final:g,InvoiceNumber:f}=t,v=window.location.host,w=`https://receipt.dealpos.app/s?Data=${window.btoa(`${s}_${v}`)}`;return this.convertWhatsappTemplateMessage({Amount:e(g),Brand:i,Currency:o,Number:f,ReceiptLink:w},r)}convertWhatsappTemplateMessage(t,o){let r=o||u?.whatsappTemplateMessage,e=["Brand","Number","Currency","Amount","ReceiptLink"],i=r;return e.forEach(s=>i=i.replace(`{${s}}`,t[s])),i}redirectToWhatsapp(t,o){let r=t;r=r[0]==="0"?`62${r.slice(1)}`:r;let e=`whatsapp://send?phone=${r}&text=${encodeURIComponent(o)}`;window.location.href=e,this.showToastrWhatsappNoInstalled()}showToastrWhatsappNoInstalled(){let t=!1;window.onblur=function(){t=!0},setTimeout(()=>{t||this.toastr.warning(`Currently, sending an e-receipt automatically opens WhatsApp Desktop, provided the device has the app installed
2
2
  `,"WhatsApp not installed")},2e3)}copyToClipboard(t){return new Promise((o,r)=>this.copyToClipBoard.copy(t).then(()=>{this.toastr.info("Message copied to clipboard. If WhatsApp doesn't show the message, please paste it manually.","Receipt Ready",{timeOut:8e3}),o("Copied to clipboard")}).catch(e=>{console.log(e),this.toastr.warning("Could not copy message to clipboard","Clipboard Error",{timeOut:8e3}),r(e)}))}sendReceiptToWhatsapp(t,o,r,e){return l(this,null,function*(){try{let i=this.createWhatsappReceipt(o,r,e);try{yield this.copyToClipboard(i)}finally{this.redirectToWhatsapp(t,i)}}catch(i){console.warn(i),this.toastr.error("Failed to send receipt")}})}static \u0275fac=function(o){return new(o||a)};static \u0275prov=n({token:a,factory:a.\u0275fac})};export{y as a};
@@ -1 +1 @@
1
- import{a as de}from"./chunk-Z7WYC46Q.js";import{h as me,i as se}from"./chunk-SO3WWYN3.js";import"./chunk-ETHIPTBJ.js";import{b as le}from"./chunk-M7KP6PSY.js";import"./chunk-AZT6QE56.js";import"./chunk-5UL73W4S.js";import{u as ae,v as ne,w as re}from"./chunk-677WPFLK.js";import"./chunk-CIBQBSM6.js";import"./chunk-L2RZWAX3.js";import{e as te,f as ie,g as oe}from"./chunk-D35OBUDE.js";import"./chunk-567HXZXC.js";import"./chunk-AAJJTF33.js";import{a as ee}from"./chunk-2FWFPV5I.js";import"./chunk-3PYW74LR.js";import{C as X,D as Z,c as G,h as z,o as J,y as Q}from"./chunk-P7HKWFZT.js";import"./chunk-HV7GI3KE.js";import"./chunk-LYOMQKFY.js";import{a as W}from"./chunk-AHCRE4GP.js";import"./chunk-4YAMWP7V.js";import{$a as m,Ac as B,Db as F,E as A,Ib as o,Jb as a,Kb as w,Lb as T,Ma as Y,Mb as g,Ob as y,Od as H,Qb as _,Rb as u,Vd as q,Wc as U,Yc as j,Yd as $,Zc as v,db as f,dc as O,ec as r,fc as R,gc as x,gd as K,jc as E,jd as h,kb as b,kc as M,lc as P,ob as L,qb as S,rc as D,va as d,vb as c,wa as p,zc as k}from"./chunk-DZT5XHBQ.js";import"./chunk-7DCB7DB2.js";var I=(s=>(s.TRANSACTIONS="TRANSACTIONS",s.PRODUCTS="PRODUCTS",s.CONTACTS="CONTACTS",s.LOYALTY_POINTS="LOYALTY_POINTS",s.RECYCLE_BIN="RECYCLE_BIN",s.INVENTORY="INVENTORY",s))(I||{});function _e(n,l){if(n&1&&(T(0),o(1,"div",4)(2,"div",5)(3,"div",16),w(4,"i",17),o(5,"span"),r(6),a()()()(),g()),n&2){let i=u();m(6),x(" ",i.selectedClearData.message," ")}}function Se(n,l){n&1&&(T(0),o(1,"small",18),r(2," *Subdomain is required "),a(),g())}function Te(n,l){n&1&&(T(0),o(1,"small",18),r(2," *Password is required "),a(),g())}function ge(n,l){n&1&&w(0,"i",14)}function be(n,l){n&1&&w(0,"i",15)}var N=class n{constructor(l,i,t){this.data=l;this.dialogRef=i;this.fb=t;this.modalConfig.title=this.modalTitle[this.data.type],this.subdomain="",this.subdomainPlaceholder=l.subDomain}clearData=[{type:"TRANSACTIONS",api:"Setup/Data/ClearTransaction",message:"Your Invoice, Bill, Adjustment, TransferOrder will be deleted"},{type:"PRODUCTS",api:"Setup/Data/ClearProduct",message:"Your Category, Product and Variant will be deleted"},{type:"LOYALTY_POINTS",api:"Setup/Data/ClearLoyaltyPoint"},{type:"RECYCLE_BIN",api:"Setup/Data/ClearRecycleBin"},{type:"INVENTORY",api:"Setup/Data/ClearInventory",message:"Your Product Inventory will be set to 0"},{type:"CONTACTS",api:"Setup/Data/ClearContact",message:"Your Customer, Supplier and Sales Person will be deleted"}];selectedClearData;modalConfig=new ae;modalTitle={TRANSACTIONS:"Clear Transactions",PRODUCTS:"Clear Products",LOYALTY_POINTS:"Clear Loyalty Points",RECYCLE_BIN:"Clear Recycle Bin",CONTACTS:"Clear Contacts",INVENTORY:"Clear Inventory"};subdomain;subdomainPlaceholder;password;form;passwordVisibility=Y(!1);ngOnInit(){this.initSelectedClearData(),this.form=this.fb.group({subdomain:[""],password:[""]})}initSelectedClearData(){this.selectedClearData=this.clearData.find(l=>l.type===this.data.type)}onSubmit(){let l={password:this.password,subdomain:this.subdomain,apiUrl:this.selectedClearData.api};this.dialogRef.close(l)}static \u0275fac=function(i){return new(i||n)(f(ie),f(te),f(X))};static \u0275cmp=b({type:n,selectors:[["app-confirmation-modal"]],decls:24,vars:10,consts:[["subdomainCtrl","ngModel"],["passwordCtrl","ngModel"],[3,"onOk","onClose","onCancel","config","dynamicValidated"],[4,"ngIf"],[1,"row"],[1,"col-12"],[1,"form-floating-outline","mt-5"],["type","text","id","subdomain","placeholder","Subdomain","name","subdomain","autofocus","","required","",1,"form-control",3,"ngModelChange","ngModel"],["for","subdomain"],[1,"form-floating-outline"],["id","pass","placeholder","Password","name","password","required","",1,"form-control",3,"ngModelChange","type","ngModel"],["for","pass"],[1,"password-visibility"],["type","button",1,"btn","btn-link",3,"click"],[1,"fa-solid","fa-eye"],[1,"fa-solid","fa-eye-slash"],[1,"alert","alert-warning","cursor","w-100"],[1,"fa-solid","fa-circle-exclamation","me-2"],[1,"control-label","text-danger"]],template:function(i,t){if(i&1){let e=y();o(0,"modal-material",2),_("onOk",function(){return d(e),p(t.onSubmit())})("onClose",function(){return d(e),p(t.dialogRef.close())})("onCancel",function(){return d(e),p(t.dialogRef.close())}),o(1,"content"),S(2,_e,7,1,"ng-container",3),o(3,"div",4)(4,"div",5)(5,"strong"),r(6),a(),o(7,"div",6)(8,"input",7,0),P("ngModelChange",function(s){return d(e),M(t.subdomain,s)||(t.subdomain=s),p(s)}),a(),o(10,"label",8),r(11,"Subdomain"),a(),S(12,Se,3,0,"ng-container",3),a()(),o(13,"div",5)(14,"div",9)(15,"input",10,1),P("ngModelChange",function(s){return d(e),M(t.password,s)||(t.password=s),p(s)}),a(),o(17,"label",11),r(18,"Password"),a(),S(19,Te,3,0,"ng-container",3),o(20,"div",12)(21,"button",13),_("click",function(){return d(e),p(t.passwordVisibility.set(!t.passwordVisibility()))}),S(22,ge,1,0,"i",14)(23,be,1,0,"i",15),a()()()()()()()}if(i&2){let e=O(9),C=O(16);c("config",t.modalConfig)("dynamicValidated",t.password&&t.subdomain),m(2),c("ngIf",t.selectedClearData.message),m(4),x("Enter the following subdomain to confirm: ",t.subdomainPlaceholder,""),m(2),E("ngModel",t.subdomain),m(4),c("ngIf",e.invalid&&(e.dirty||e.touched)),m(3),c("type",t.passwordVisibility()?"text":"password"),E("ngModel",t.password),m(4),c("ngIf",C.invalid&&(C.dirty||C.touched)),m(3),F(t.passwordVisibility()?22:23)}},dependencies:[h,v,re,ne,Z,G,z,Q,J],styles:[".password-visibility[_ngcontent-%COMP%]{position:absolute;right:0;top:50%;transform:translateY(-50%);cursor:pointer;font-size:1.5rem}"]})};var V=n=>({"border border-0":n});function we(n,l){if(n&1&&(T(0),o(1,"tr",23)(2,"td",23),r(3),a(),o(4,"td",24),r(5),k(6,"number"),a()(),g()),n&2){let i=l.$implicit,t=l.index,e=u(2);m(),c("ngClass",D(7,V,t==e.data.Data.length-1)),m(),c("ngClass",D(9,V,t==e.data.Data.length-1)),m(),R(i.Key),m(),c("ngClass",D(11,V,t==e.data.Data.length-1)),m(),R(B(6,5,i.Value))}}function ye(n,l){if(n&1){let i=y();o(0,"mainpanel-cmp",1)(1,"actions")(2,"div",2)(3,"div",3)(4,"button",4),r(5," Format Data "),a(),o(6,"ul",5)(7,"li")(8,"a",6),_("click",function(){d(i);let e=u();return p(e.onClearRecord(e.clearDataType.TRANSACTIONS))}),r(9," 1. Clear Transactions "),a()(),o(10,"li")(11,"a",7),_("click",function(){d(i);let e=u();return p(e.onClearRecord(e.clearDataType.INVENTORY))}),r(12," 2. Clear Inventory "),a()(),o(13,"li")(14,"a",8),_("click",function(){d(i);let e=u();return p(e.onClearRecord(e.clearDataType.PRODUCTS))}),r(15," 3. Clear Products "),a()(),o(16,"li")(17,"a",9),_("click",function(){d(i);let e=u();return p(e.onClearRecord(e.clearDataType.CONTACTS))}),r(18," 4. Clear Contacts "),a()(),o(19,"li")(20,"a",10),_("click",function(){d(i);let e=u();return p(e.onClearRecord(e.clearDataType.LOYALTY_POINTS))}),r(21," 5. Clear Loyalty Point "),a()(),o(22,"li")(23,"a",11),_("click",function(){d(i);let e=u();return p(e.onClearRecord(e.clearDataType.RECYCLE_BIN))}),r(24," 6. Clear Recycle Bin "),a()()()()()(),o(25,"content")(26,"div",12)(27,"div",13)(28,"div",14)(29,"h5"),r(30,"Database Records"),a(),o(31,"i"),r(32,"Current data count"),a()(),o(33,"div",15)(34,"div",16)(35,"div",17)(36,"table",18)(37,"thead",19)(38,"tr",20)(39,"th"),r(40,"Table"),a(),o(41,"th",21),r(42,"Rows"),a()()(),o(43,"tbody"),S(44,we,7,13,"ng-container",22),a()()()()()()()()()}if(n&2){let i=u();c("pageData",i.menuData)("hideSearchDropdown",!0)("hideSearchBox",!0),m(44),c("ngForOf",i.data.Data)}}var pe=class n extends de{constructor(i,t,e,C,s){super(i,t,"Setup/DataLoader/clearformatdata",e);this.httpService=t;this.activatedRoute=e;this.toaster=C;this.dialog=s}clearDataType=I;onClearRecord(i){this.dialog.open(N,{data:{type:i,subDomain:this.data.SubDomain}}).afterClosed().pipe(A(t=>W.IsNotEmpty(t))).subscribe(t=>{this.formData={Subdomain:t.subdomain,Password:t.password},this.onSubmit(t.apiUrl),i=="PRODUCTS"?this.data.Data.find(e=>e.Key=="Product").Value=0:i=="CONTACTS"?this.data.Data.find(e=>e.Key=="Customer").Value=0:i=="INVENTORY"?this.data.Data.find(e=>e.Key=="ItemTransfer").Value=0:i=="LOYALTY_POINTS"?this.data.Data.find(e=>e.Key=="JournalHeader").Value=0:i=="RECYCLE_BIN"?this.data.Data.find(e=>e.Key=="Recycle Bin").Value=0:i=="TRANSACTIONS"&&(this.data.Data.find(e=>e.Key=="SalesOrder").Value=0)})}onSubmitSuccess(i){this.toaster.success(i.Message,ee.Success)}static \u0275fac=function(t){return new(t||n)(f(le),f($),f(H),f(q),f(oe))};static \u0275cmp=b({type:n,selectors:[["POS-format-data"]],features:[L],decls:1,vars:1,consts:[[3,"pageData","hideSearchDropdown","hideSearchBox",4,"ngIf"],[3,"pageData","hideSearchDropdown","hideSearchBox"],[1,"d-flex"],[1,"dropdown"],["type","button","data-bs-toggle","dropdown","aria-expanded","false","confirm-message","Are you sure you want to clear the record?",1,"btn","btn-outline-secondary","dropdown-toggle"],[1,"dropdown-menu","dropdown-menu-end"],["role","button","matTooltipPosition","above","matTooltip","Clear Transaction",1,"dropdown-item",3,"click"],["role","button","matTooltipPosition","above","matTooltip","Clear Inventory",1,"dropdown-item",3,"click"],["role","button","matTooltipPosition","above","matTooltip","Clear Products",1,"dropdown-item",3,"click"],["role","button","matTooltipPosition","above","matTooltip","Clear Contacts",1,"dropdown-item",3,"click"],["role","button","matTooltipPosition","above","matTooltip","Clear Loyalty Point",1,"dropdown-item",3,"click"],["role","button","matTooltipPosition","above","matTooltip","Clear Recycle Bin",1,"dropdown-item",3,"click"],[1,"container","pt-3"],[1,"row","border-bottom","mt-10","ms-2"],[1,"col-sm-2"],[1,"col-sm-10"],[1,"row"],[1,"col-md-12"],["id","tableGrid",1,"table",2,"width","250px"],[1,"thead-light","sticky-top-thead"],[1,"header"],[1,"text-end"],[4,"ngFor","ngForOf"],[3,"ngClass"],[1,"text-end",3,"ngClass"]],template:function(t,e){t&1&&S(0,ye,45,4,"mainpanel-cmp",0),t&2&&c("ngIf",e.formData)},dependencies:[h,U,j,v,K,se,me],encapsulation:2})};export{pe as FormatDataComponent};
1
+ import{a as de}from"./chunk-RYONOB6O.js";import{h as me,i as se}from"./chunk-MERQX2AF.js";import"./chunk-4E4L6WXO.js";import{b as le}from"./chunk-DHQUQTIV.js";import"./chunk-AZT6QE56.js";import"./chunk-5UL73W4S.js";import{u as ae,v as ne,w as re}from"./chunk-677WPFLK.js";import"./chunk-CIBQBSM6.js";import"./chunk-L2RZWAX3.js";import{e as te,f as ie,g as oe}from"./chunk-D35OBUDE.js";import"./chunk-567HXZXC.js";import"./chunk-AAJJTF33.js";import{a as ee}from"./chunk-2FWFPV5I.js";import"./chunk-3PYW74LR.js";import{C as X,D as Z,c as G,h as z,o as J,y as Q}from"./chunk-P7HKWFZT.js";import"./chunk-HSQKKFE6.js";import"./chunk-7BDVBLHM.js";import{a as W}from"./chunk-AHCRE4GP.js";import"./chunk-W7HVLC6V.js";import{$a as m,Ac as B,Db as F,E as A,Ib as o,Jb as a,Kb as w,Lb as T,Ma as Y,Mb as g,Ob as y,Od as H,Qb as _,Rb as u,Vd as q,Wc as U,Yc as j,Yd as $,Zc as v,db as f,dc as O,ec as r,fc as R,gc as x,gd as K,jc as E,jd as h,kb as b,kc as M,lc as P,ob as L,qb as S,rc as D,va as d,vb as c,wa as p,zc as k}from"./chunk-DZT5XHBQ.js";import"./chunk-7DCB7DB2.js";var I=(s=>(s.TRANSACTIONS="TRANSACTIONS",s.PRODUCTS="PRODUCTS",s.CONTACTS="CONTACTS",s.LOYALTY_POINTS="LOYALTY_POINTS",s.RECYCLE_BIN="RECYCLE_BIN",s.INVENTORY="INVENTORY",s))(I||{});function _e(n,l){if(n&1&&(T(0),o(1,"div",4)(2,"div",5)(3,"div",16),w(4,"i",17),o(5,"span"),r(6),a()()()(),g()),n&2){let i=u();m(6),x(" ",i.selectedClearData.message," ")}}function Se(n,l){n&1&&(T(0),o(1,"small",18),r(2," *Subdomain is required "),a(),g())}function Te(n,l){n&1&&(T(0),o(1,"small",18),r(2," *Password is required "),a(),g())}function ge(n,l){n&1&&w(0,"i",14)}function be(n,l){n&1&&w(0,"i",15)}var N=class n{constructor(l,i,t){this.data=l;this.dialogRef=i;this.fb=t;this.modalConfig.title=this.modalTitle[this.data.type],this.subdomain="",this.subdomainPlaceholder=l.subDomain}clearData=[{type:"TRANSACTIONS",api:"Setup/Data/ClearTransaction",message:"Your Invoice, Bill, Adjustment, TransferOrder will be deleted"},{type:"PRODUCTS",api:"Setup/Data/ClearProduct",message:"Your Category, Product and Variant will be deleted"},{type:"LOYALTY_POINTS",api:"Setup/Data/ClearLoyaltyPoint"},{type:"RECYCLE_BIN",api:"Setup/Data/ClearRecycleBin"},{type:"INVENTORY",api:"Setup/Data/ClearInventory",message:"Your Product Inventory will be set to 0"},{type:"CONTACTS",api:"Setup/Data/ClearContact",message:"Your Customer, Supplier and Sales Person will be deleted"}];selectedClearData;modalConfig=new ae;modalTitle={TRANSACTIONS:"Clear Transactions",PRODUCTS:"Clear Products",LOYALTY_POINTS:"Clear Loyalty Points",RECYCLE_BIN:"Clear Recycle Bin",CONTACTS:"Clear Contacts",INVENTORY:"Clear Inventory"};subdomain;subdomainPlaceholder;password;form;passwordVisibility=Y(!1);ngOnInit(){this.initSelectedClearData(),this.form=this.fb.group({subdomain:[""],password:[""]})}initSelectedClearData(){this.selectedClearData=this.clearData.find(l=>l.type===this.data.type)}onSubmit(){let l={password:this.password,subdomain:this.subdomain,apiUrl:this.selectedClearData.api};this.dialogRef.close(l)}static \u0275fac=function(i){return new(i||n)(f(ie),f(te),f(X))};static \u0275cmp=b({type:n,selectors:[["app-confirmation-modal"]],decls:24,vars:10,consts:[["subdomainCtrl","ngModel"],["passwordCtrl","ngModel"],[3,"onOk","onClose","onCancel","config","dynamicValidated"],[4,"ngIf"],[1,"row"],[1,"col-12"],[1,"form-floating-outline","mt-5"],["type","text","id","subdomain","placeholder","Subdomain","name","subdomain","autofocus","","required","",1,"form-control",3,"ngModelChange","ngModel"],["for","subdomain"],[1,"form-floating-outline"],["id","pass","placeholder","Password","name","password","required","",1,"form-control",3,"ngModelChange","type","ngModel"],["for","pass"],[1,"password-visibility"],["type","button",1,"btn","btn-link",3,"click"],[1,"fa-solid","fa-eye"],[1,"fa-solid","fa-eye-slash"],[1,"alert","alert-warning","cursor","w-100"],[1,"fa-solid","fa-circle-exclamation","me-2"],[1,"control-label","text-danger"]],template:function(i,t){if(i&1){let e=y();o(0,"modal-material",2),_("onOk",function(){return d(e),p(t.onSubmit())})("onClose",function(){return d(e),p(t.dialogRef.close())})("onCancel",function(){return d(e),p(t.dialogRef.close())}),o(1,"content"),S(2,_e,7,1,"ng-container",3),o(3,"div",4)(4,"div",5)(5,"strong"),r(6),a(),o(7,"div",6)(8,"input",7,0),P("ngModelChange",function(s){return d(e),M(t.subdomain,s)||(t.subdomain=s),p(s)}),a(),o(10,"label",8),r(11,"Subdomain"),a(),S(12,Se,3,0,"ng-container",3),a()(),o(13,"div",5)(14,"div",9)(15,"input",10,1),P("ngModelChange",function(s){return d(e),M(t.password,s)||(t.password=s),p(s)}),a(),o(17,"label",11),r(18,"Password"),a(),S(19,Te,3,0,"ng-container",3),o(20,"div",12)(21,"button",13),_("click",function(){return d(e),p(t.passwordVisibility.set(!t.passwordVisibility()))}),S(22,ge,1,0,"i",14)(23,be,1,0,"i",15),a()()()()()()()}if(i&2){let e=O(9),C=O(16);c("config",t.modalConfig)("dynamicValidated",t.password&&t.subdomain),m(2),c("ngIf",t.selectedClearData.message),m(4),x("Enter the following subdomain to confirm: ",t.subdomainPlaceholder,""),m(2),E("ngModel",t.subdomain),m(4),c("ngIf",e.invalid&&(e.dirty||e.touched)),m(3),c("type",t.passwordVisibility()?"text":"password"),E("ngModel",t.password),m(4),c("ngIf",C.invalid&&(C.dirty||C.touched)),m(3),F(t.passwordVisibility()?22:23)}},dependencies:[h,v,re,ne,Z,G,z,Q,J],styles:[".password-visibility[_ngcontent-%COMP%]{position:absolute;right:0;top:50%;transform:translateY(-50%);cursor:pointer;font-size:1.5rem}"]})};var V=n=>({"border border-0":n});function we(n,l){if(n&1&&(T(0),o(1,"tr",23)(2,"td",23),r(3),a(),o(4,"td",24),r(5),k(6,"number"),a()(),g()),n&2){let i=l.$implicit,t=l.index,e=u(2);m(),c("ngClass",D(7,V,t==e.data.Data.length-1)),m(),c("ngClass",D(9,V,t==e.data.Data.length-1)),m(),R(i.Key),m(),c("ngClass",D(11,V,t==e.data.Data.length-1)),m(),R(B(6,5,i.Value))}}function ye(n,l){if(n&1){let i=y();o(0,"mainpanel-cmp",1)(1,"actions")(2,"div",2)(3,"div",3)(4,"button",4),r(5," Format Data "),a(),o(6,"ul",5)(7,"li")(8,"a",6),_("click",function(){d(i);let e=u();return p(e.onClearRecord(e.clearDataType.TRANSACTIONS))}),r(9," 1. Clear Transactions "),a()(),o(10,"li")(11,"a",7),_("click",function(){d(i);let e=u();return p(e.onClearRecord(e.clearDataType.INVENTORY))}),r(12," 2. Clear Inventory "),a()(),o(13,"li")(14,"a",8),_("click",function(){d(i);let e=u();return p(e.onClearRecord(e.clearDataType.PRODUCTS))}),r(15," 3. Clear Products "),a()(),o(16,"li")(17,"a",9),_("click",function(){d(i);let e=u();return p(e.onClearRecord(e.clearDataType.CONTACTS))}),r(18," 4. Clear Contacts "),a()(),o(19,"li")(20,"a",10),_("click",function(){d(i);let e=u();return p(e.onClearRecord(e.clearDataType.LOYALTY_POINTS))}),r(21," 5. Clear Loyalty Point "),a()(),o(22,"li")(23,"a",11),_("click",function(){d(i);let e=u();return p(e.onClearRecord(e.clearDataType.RECYCLE_BIN))}),r(24," 6. Clear Recycle Bin "),a()()()()()(),o(25,"content")(26,"div",12)(27,"div",13)(28,"div",14)(29,"h5"),r(30,"Database Records"),a(),o(31,"i"),r(32,"Current data count"),a()(),o(33,"div",15)(34,"div",16)(35,"div",17)(36,"table",18)(37,"thead",19)(38,"tr",20)(39,"th"),r(40,"Table"),a(),o(41,"th",21),r(42,"Rows"),a()()(),o(43,"tbody"),S(44,we,7,13,"ng-container",22),a()()()()()()()()()}if(n&2){let i=u();c("pageData",i.menuData)("hideSearchDropdown",!0)("hideSearchBox",!0),m(44),c("ngForOf",i.data.Data)}}var pe=class n extends de{constructor(i,t,e,C,s){super(i,t,"Setup/DataLoader/clearformatdata",e);this.httpService=t;this.activatedRoute=e;this.toaster=C;this.dialog=s}clearDataType=I;onClearRecord(i){this.dialog.open(N,{data:{type:i,subDomain:this.data.SubDomain}}).afterClosed().pipe(A(t=>W.IsNotEmpty(t))).subscribe(t=>{this.formData={Subdomain:t.subdomain,Password:t.password},this.onSubmit(t.apiUrl),i=="PRODUCTS"?this.data.Data.find(e=>e.Key=="Product").Value=0:i=="CONTACTS"?this.data.Data.find(e=>e.Key=="Customer").Value=0:i=="INVENTORY"?this.data.Data.find(e=>e.Key=="ItemTransfer").Value=0:i=="LOYALTY_POINTS"?this.data.Data.find(e=>e.Key=="JournalHeader").Value=0:i=="RECYCLE_BIN"?this.data.Data.find(e=>e.Key=="Recycle Bin").Value=0:i=="TRANSACTIONS"&&(this.data.Data.find(e=>e.Key=="SalesOrder").Value=0)})}onSubmitSuccess(i){this.toaster.success(i.Message,ee.Success)}static \u0275fac=function(t){return new(t||n)(f(le),f($),f(H),f(q),f(oe))};static \u0275cmp=b({type:n,selectors:[["POS-format-data"]],features:[L],decls:1,vars:1,consts:[[3,"pageData","hideSearchDropdown","hideSearchBox",4,"ngIf"],[3,"pageData","hideSearchDropdown","hideSearchBox"],[1,"d-flex"],[1,"dropdown"],["type","button","data-bs-toggle","dropdown","aria-expanded","false","confirm-message","Are you sure you want to clear the record?",1,"btn","btn-outline-secondary","dropdown-toggle"],[1,"dropdown-menu","dropdown-menu-end"],["role","button","matTooltipPosition","above","matTooltip","Clear Transaction",1,"dropdown-item",3,"click"],["role","button","matTooltipPosition","above","matTooltip","Clear Inventory",1,"dropdown-item",3,"click"],["role","button","matTooltipPosition","above","matTooltip","Clear Products",1,"dropdown-item",3,"click"],["role","button","matTooltipPosition","above","matTooltip","Clear Contacts",1,"dropdown-item",3,"click"],["role","button","matTooltipPosition","above","matTooltip","Clear Loyalty Point",1,"dropdown-item",3,"click"],["role","button","matTooltipPosition","above","matTooltip","Clear Recycle Bin",1,"dropdown-item",3,"click"],[1,"container","pt-3"],[1,"row","border-bottom","mt-10","ms-2"],[1,"col-sm-2"],[1,"col-sm-10"],[1,"row"],[1,"col-md-12"],["id","tableGrid",1,"table",2,"width","250px"],[1,"thead-light","sticky-top-thead"],[1,"header"],[1,"text-end"],[4,"ngFor","ngForOf"],[3,"ngClass"],[1,"text-end",3,"ngClass"]],template:function(t,e){t&1&&S(0,ye,45,4,"mainpanel-cmp",0),t&2&&c("ngIf",e.formData)},dependencies:[h,U,j,v,K,se,me],encapsulation:2})};export{pe as FormatDataComponent};