dealpos 26.12.1 → 26.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/{chunk-HGGJDPBU.js → chunk-2ATVU2LS.js} +1 -1
- package/browser/{chunk-NDLDHUMQ.js → chunk-2FCXPO2Z.js} +1 -1
- package/browser/{chunk-6KT53KXM.js → chunk-2XNQOXAP.js} +1 -1
- package/browser/{chunk-7JLY4LEX.js → chunk-2ZKJQBMC.js} +1 -1
- package/browser/{chunk-5NCYSWBP.js → chunk-32ECPU4G.js} +1 -1
- package/browser/{chunk-ZT6CJWZM.js → chunk-34YZZMTN.js} +1 -1
- package/browser/{chunk-5DSUPWQZ.js → chunk-3DPYFMXH.js} +1 -1
- package/browser/{chunk-LVIR4LX6.js → chunk-3EZJMNC3.js} +1 -1
- package/browser/{chunk-ATKO5GSC.js → chunk-3WJZND3M.js} +1 -1
- package/browser/{chunk-XOEPHVYN.js → chunk-42N7BYEU.js} +1 -1
- package/browser/{chunk-ZYL7QVAV.js → chunk-4VMSABNQ.js} +1 -1
- package/browser/{chunk-MDE636TM.js → chunk-5QBETGEA.js} +1 -1
- package/browser/{chunk-KJJBVMWF.js → chunk-6AEVG6F2.js} +1 -1
- package/browser/{chunk-2YYWPJMC.js → chunk-6H7CNWPW.js} +1 -1
- package/browser/{chunk-PTSXTDXU.js → chunk-6HZMEK74.js} +1 -1
- package/browser/{chunk-L2B3DVQ5.js → chunk-6YYAKTZY.js} +1 -1
- package/browser/{chunk-RHUMPZ6L.js → chunk-7UX6XI3Y.js} +1 -1
- package/browser/{chunk-WUFQ4KMJ.js → chunk-7ZTHTB2M.js} +1 -1
- package/browser/{chunk-C3JKYQFI.js → chunk-ABTH24W5.js} +1 -1
- package/browser/{chunk-3M7WIKOQ.js → chunk-AHFOVFN3.js} +1 -1
- package/browser/{chunk-HPBQ7Q2P.js → chunk-AOGVXESL.js} +1 -1
- package/browser/{chunk-6RPIZHB5.js → chunk-B7HZHRWB.js} +1 -1
- package/browser/{chunk-YQ37KZCH.js → chunk-CAJWZ4H4.js} +1 -1
- package/browser/{chunk-EFLFSF5P.js → chunk-CANSCI2Y.js} +1 -1
- package/browser/{chunk-O4UPM3ML.js → chunk-CB5UFVUU.js} +1 -1
- package/browser/{chunk-73WVLQD5.js → chunk-CKYW3E77.js} +2 -2
- package/browser/{chunk-LJYAG2UM.js → chunk-CR2K72VD.js} +1 -1
- package/browser/{chunk-4K45N4VD.js → chunk-CSQSB346.js} +2 -2
- package/browser/{chunk-BVJVHCHW.js → chunk-CU2X7CKE.js} +1 -1
- package/browser/{chunk-KKIDIJD2.js → chunk-D5HCFSWS.js} +1 -1
- package/browser/{chunk-RXDKVW2Q.js → chunk-DWMN27SR.js} +1 -1
- package/browser/{chunk-WXIWCGEU.js → chunk-EEDPTIYL.js} +2 -2
- package/browser/{chunk-FRSR4BOK.js → chunk-EJ2CRXN3.js} +1 -1
- package/browser/{chunk-5AH54HFS.js → chunk-EMMZGE4I.js} +1 -1
- package/browser/{chunk-NWGAXJFI.js → chunk-EU2SBJNN.js} +1 -1
- package/browser/{chunk-2ZUBWZ2U.js → chunk-GYF7UVGY.js} +1 -1
- package/browser/{chunk-WODOZ5W3.js → chunk-HIEGBHTP.js} +1 -1
- package/browser/{chunk-AK3LM2FA.js → chunk-HK7XFFOV.js} +1 -1
- package/browser/{chunk-J4AJXVSA.js → chunk-IEMVQTIV.js} +1 -1
- package/browser/{chunk-OOS7T62T.js → chunk-IGVPV4V6.js} +1 -1
- package/browser/{chunk-IAN6IR7T.js → chunk-IHAWGBSI.js} +1 -1
- package/browser/{chunk-L7MMQ2AP.js → chunk-IOAU2JFO.js} +1 -1
- package/browser/{chunk-IEETW4DJ.js → chunk-IOG6M27K.js} +1 -1
- package/browser/{chunk-CX7C3CG4.js → chunk-IQL325R5.js} +2 -2
- package/browser/{chunk-EKQL4M6M.js → chunk-IQSLTOL4.js} +1 -1
- package/browser/{chunk-B33EYO2J.js → chunk-IZ7IIWHG.js} +1 -1
- package/browser/{chunk-H7HXN5CN.js → chunk-JOXDKNGZ.js} +1 -1
- package/browser/{chunk-IPLEKTHT.js → chunk-K5X7M7KK.js} +1 -1
- package/browser/{chunk-5TMT4TK5.js → chunk-K76AQWWL.js} +1 -1
- package/browser/{chunk-NTA7B3V4.js → chunk-KKPV6OZ3.js} +1 -1
- package/browser/{chunk-EJISK6KI.js → chunk-KPHTKLHN.js} +1 -1
- package/browser/{chunk-S2WCUC4L.js → chunk-KRKXJWC5.js} +1 -1
- package/browser/{chunk-POHSMEST.js → chunk-MOE6R6MK.js} +1 -1
- package/browser/{chunk-UP5ZLVIB.js → chunk-MX2X5SUN.js} +1 -1
- package/browser/{chunk-LLK4R5UK.js → chunk-NBCO5HTZ.js} +1 -1
- package/browser/{chunk-L6BCCKZV.js → chunk-NKIX5CLA.js} +1 -1
- package/browser/{chunk-QU7W4NFX.js → chunk-NPFUXMNS.js} +1 -1
- package/browser/{chunk-TK4ZZU4Q.js → chunk-O3RPW4YN.js} +1 -1
- package/browser/{chunk-PQDTFO7J.js → chunk-OCOQQU4T.js} +1 -1
- package/browser/{chunk-OTHA6H2J.js → chunk-OGP7GX7M.js} +1 -1
- package/browser/{chunk-NE7O7GIE.js → chunk-P4YVDYKG.js} +1 -1
- package/browser/{chunk-PPZYIQLS.js → chunk-P4ZUQJV5.js} +1 -1
- package/browser/{chunk-TQDGSRUU.js → chunk-QAP45ND6.js} +2 -2
- package/browser/{chunk-L6QGGJGR.js → chunk-QDQAJ3OH.js} +1 -1
- package/browser/{chunk-IOZYCSVG.js → chunk-QKBAWXK5.js} +1 -1
- package/browser/{chunk-IUNGNZLW.js → chunk-QQ3CM3SY.js} +1 -1
- package/browser/{chunk-3EHYXOTF.js → chunk-QTQJ3UQX.js} +1 -1
- package/browser/{chunk-726EDMUB.js → chunk-RFAX7VKZ.js} +2 -2
- package/browser/{chunk-PHUSSOP3.js → chunk-RX6KOSKS.js} +1 -1
- package/browser/{chunk-SCES34K4.js → chunk-S4GDE7Y2.js} +1 -1
- package/browser/{chunk-TH3YCOJS.js → chunk-SMPVGFCL.js} +1 -1
- package/browser/{chunk-BEX7XZLC.js → chunk-UEDBMWMK.js} +1 -1
- package/browser/{chunk-7V4IK65K.js → chunk-UMGUBAQV.js} +1 -1
- package/browser/{chunk-HL3Z5XP3.js → chunk-UQCVXTZE.js} +2 -2
- package/browser/{chunk-65LVDOIS.js → chunk-URV4PLHU.js} +1 -1
- package/browser/{chunk-G74QSSNS.js → chunk-UT3P5CZB.js} +1 -1
- package/browser/{chunk-QHCAVNJM.js → chunk-VJ3CCTAP.js} +1 -1
- package/browser/{chunk-ADKHKA3S.js → chunk-VRMFIBBS.js} +1 -1
- package/browser/{chunk-OKY3A32Z.js → chunk-VT5WBIUC.js} +1 -1
- package/browser/{chunk-WKKU6S7F.js → chunk-VXS2KWZU.js} +1 -1
- package/browser/{chunk-CAPICNTS.js → chunk-W54UUUPR.js} +1 -1
- package/browser/{chunk-YU2DT6A5.js → chunk-WMJ7NW7H.js} +1 -1
- package/browser/{chunk-BZ73RG7P.js → chunk-X22STB6L.js} +1 -1
- package/browser/{chunk-TEFBJOLV.js → chunk-X3WRWK2P.js} +1 -1
- package/browser/{chunk-KV7VCWNV.js → chunk-XMQF23EU.js} +1 -1
- package/browser/{chunk-4VCG3U5W.js → chunk-YG3EKSAA.js} +1 -1
- package/browser/{chunk-CWZEFFCN.js → chunk-YNCVE5XY.js} +1 -1
- package/browser/{chunk-KJCVEEBK.js → chunk-ZZIFHSBN.js} +1 -1
- package/browser/index.html +2 -2
- package/browser/{main-VWR7P7M2.js → main-LMI6IVYC.js} +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Zt}from"./chunk-ZOBPTHDY.js";import{a as At,b as Ne,c as Bo}from"./chunk-2OOAFLWG.js";import{a as zo}from"./chunk-ANBDI5MB.js";import{e as jo}from"./chunk-BXHFFVVV.js";import{a as Ti}from"./chunk-GGDW5WFA.js";import{b as Go}from"./chunk-MFCDS575.js";import{d as Wo}from"./chunk-2F3Z5UVP.js";import{a as Uo}from"./chunk-COD2FOFZ.js";import{a as Lo}from"./chunk-V46FIBS7.js";import{a as Ii}from"./chunk-2PUTNW54.js";import{a as Yo}from"./chunk-4VGCD2S7.js";import{a as be,b as Re,e as Jo}from"./chunk-C3DQQRQ2.js";import{b as Ho}from"./chunk-O55DD6CT.js";import{a as So}from"./chunk-CZWUCHB4.js";import{a as $o,b as qo}from"./chunk-KIH7ZE6M.js";import{a as Fo}from"./chunk-2XCPI5BA.js";import{a as wi}from"./chunk-HNS7KWHX.js";import{a as Ei,b as Ri,c as Ni}from"./chunk-OKL7T7RK.js";import{a as kt}from"./chunk-Q3UN4JZJ.js";import{a as Qo}from"./chunk-4WL57CXW.js";import{a as Ko}from"./chunk-VLSANGOZ.js";import{a as Yt,b as En,c as Ye}from"./chunk-L3CQDLDO.js";import{a as xi,b as Te}from"./chunk-NEUUD5VB.js";import{a as Nt}from"./chunk-32EIT4L7.js";import{a as tt,b as Kt,c as fe}from"./chunk-NSNUUKNK.js";import{a as Vo}from"./chunk-7GRHNPNY.js";import{g as ko}from"./chunk-MTMTZLMY.js";import{a as Ao}from"./chunk-JEJGTRFJ.js";import{d as Di}from"./chunk-6C7NKVRP.js";import{m as Pi}from"./chunk-6TWTQLKB.js";import{d as Oo}from"./chunk-SASYAFMF.js";import{c as Po}from"./chunk-STYLBZL4.js";import{a as Et}from"./chunk-VIKIXIX5.js";import{g as Mo}from"./chunk-IFLLAVLK.js";import{b as No}from"./chunk-3GZUX2TV.js";import{a as Eo,b as ae,c as De,f as Ro}from"./chunk-YWAAVL5W.js";import{a as Si,b as zt}from"./chunk-JFS6EFNT.js";import{F as Rt,N as Mi,O as U,g as xo,n as Oi,o as Io,q as To,t as wo}from"./chunk-WZVFFBZM.js";import{a as at}from"./chunk-QU45SEX2.js";import{a as yi,b as so,c as bi}from"./chunk-QYSFCWV7.js";import{d as wt,e as Do}from"./chunk-ZRBKLF75.js";import{a as Z,b as pe,c as ye}from"./chunk-CPHICIOL.js";import{a as oe,b as yo}from"./chunk-GCPQTFRO.js";import{o as bo}from"./chunk-NFVNHSX5.js";import{a as de,b as Y,c as ie}from"./chunk-N4STXFCX.js";import{A as Co,E as lt,F as vo,c as ve,e as Tt,h as ge,i as lo,k as co,l as Ge,n as mo,o as Me,p as po,q as uo,s as st,x as go,y as fo,z as ho}from"./chunk-DHBFOXIN.js";import{b as _o}from"./chunk-WXT6UMYF.js";import{a as u}from"./chunk-3DEA4WWC.js";import{a as ao}from"./chunk-QHCAVNJM.js";import{n as L,q as _e}from"./chunk-2WBWJI4D.js";import{Bb as h,Cb as Tn,Db as C,Dc as k,Eb as Le,Ec as We,F as ne,Fa as T,Fb as Se,Gb as z,Gc as zn,Hb as K,Ib as m,J as nt,Jb as a,Kb as s,Kc as v,Kd as to,Lb as y,Lc as D,Mb as A,Mc as re,N as Pt,Nb as F,Nc as xt,O as Ue,Ob as Xe,Od as io,Pb as Ot,Qb as Mt,Qc as Kn,R as Fe,Rb as _i,Sa as ze,Tc as J,Td as no,Ua as Ct,Ub as E,Ud as oo,Va as Wn,Vb as Gn,Wd as ro,Xb as _,Xc as It,Yb as $n,Yc as ot,Z as Be,Za as l,Zb as p,aa as fi,ad as rt,b as pi,ba as te,bc as Dt,cc as vt,d as xe,dc as _t,e as we,ea as Ie,eb as M,ga as ce,hc as Ce,ib as N,ic as qn,jb as Ci,k as bt,lc as et,mc as d,md as Ee,n as Qn,na as w,nc as P,o as Qe,oa as hi,ob as ee,oc as I,od as Yn,p as St,pc as yt,pd as Zn,q as ui,qa as f,qc as Jn,qd as Xn,ra as O,rc as j,rd as eo,s as gi,sc as B,sd as He,tc as Q,u as W,uc as wn,ud as Ke,v as Je,va as b,w as Un,wa as S,wd as G,xb as vi,zd as me}from"./chunk-2ERDZXCS.js";import{a as di,i as Ze,k as mi}from"./chunk-SNAKHGZS.js";var Xt=class{ID;EntityID;RegisterID;TypeID;Date;Number;CustomerID;SalesID;Discount=0;Discount2=0;DiscountAmount=0;CustomerDiscountRate=0;Note="";DeliveryOutletID;TaxTypeID;CurrencyID;CurrencyRate;PointUsed;InvoicedStateID;ReferenceNumber="";LogisticsServiceID;ParkLabel="";NumberOfPerson;ClientTimestamp;Created;PromotionCoupon="";CouponType=1;PromotionNote="";DeliveryStateID;CouponProvider="Internal";CurrencySymbol;constructor(){this.ID=u.GuidEmpty,this.EntityID=u.GuidEmpty,this.RegisterID=u.GuidEmpty,this.Number="",this.CustomerID=null,this.SalesID=null,this.Discount=0,this.Discount2=0,this.DiscountAmount=0,this.Note="",this.TaxTypeID=u.GuidEmpty,this.CurrencyID=1,this.CurrencyRate=1,this.DeliveryStateID=3,this.PointUsed=0,this.NumberOfPerson=1,this.Date=new Date}removeEnterNote(){this.Note&&(this.Note=this.Note.replace(/\n/g,""))}};var ei=class{DeliveryEntityID;Type;NewOrderID;constructor(){this.DeliveryEntityID="",this.Type=3}};var Ai=class{Amount;ApplyToProduct;Code;Type;TypeDescription;Coupon;Notification;MaxDiscount;Note};var $=class{Order;Invoice;Shipping;Action;Payments;Items;CartItems;Promotion;ContactName;SplitParkLabel;get cartQuantity(){let t=0;for(let e of this.CartItems)t+=e.Quantity;return t}constructor(){this.Order=new Xt,this.Invoice=new Yt,this.Shipping=new En,this.Action=new ei,this.Payments=Array(),this.Items=Array(),this.CartItems=Array(),this.ContactName=""}get TotalPaidAmount(){let t=0;return this.Payments.forEach(e=>{t+=e.PaidAmount}),t}get RedeemableAmount(){let t=this.CartItems.filter(e=>e.Variant.PaymentTypeID!=1);return this.GetAmountByCart(t)}get TotalQuantity(){let t=0;return this.CartItems.forEach(e=>{e.PromotionGift||(t+=e.Quantity)}),t}get CashOnlyAmount(){let t=this.CartItems.filter(e=>e.Variant.PaymentTypeID==1);return this.GetAmountByCart(t)}get PointOnlyAmount(){let t=this.CartItems.filter(e=>e.Variant.PaymentTypeID==2);return this.GetAmountByCart(t)}get PrepaidPackageItem(){return this.CartItems.filter(e=>e.Variant.TypeID==10)}GetAmountByCart(t){let e=0;return t.forEach(i=>{e+=i.Total}),e=e*(100-this.Order.Discount)/100,e=e*(100-this.Order.Discount2)/100,e}getRewards(){return this.CartItems.filter(e=>e.PromotionGift)}};Ze([tt(()=>Xt)],$.prototype,"Order",2),Ze([tt(()=>Yt)],$.prototype,"Invoice",2),Ze([tt(()=>En)],$.prototype,"Shipping",2),Ze([tt(()=>ei)],$.prototype,"Action",2),Ze([tt(()=>Ye)],$.prototype,"Payments",2),Ze([tt(()=>xi)],$.prototype,"Items",2),Ze([tt(()=>Te)],$.prototype,"CartItems",2),Ze([tt(()=>Ai)],$.prototype,"Promotion",2);var ki=class{Success;Message;message;ObjectID;SalesOrderID;OutDeliveryID;Contact;LoyaltyPoint;InvoiceNumber;Creator;OrderTimeString;PrintMode;PaymentStateID;PaymentStateLabel;Final;InvoiceNumberResult;constructor(){this.Success=!0,this.Message="",this.ObjectID="",this.SalesOrderID="",this.OutDeliveryID="",this.Contact=null,this.LoyaltyPoint="",this.InvoiceNumber="",this.Creator="",this.OrderTimeString="",this.PrintMode=0,this.PaymentStateID=0,this.PaymentStateLabel="",this.Final=0}};var Vt=class n{constructor(t,e,i,o){this.httpService=t;this._localDataService=e;this._onlineStatusService=i;this._toastrService=o;this._onlineStatusService.getOnlineStatus$().subscribe(r=>{this.isOnline=r})}_Data=new we(null);Data$=this._Data.pipe(Fe(),ne(t=>t!==null));isOnline;get Data(){return this._Data.value}pushNewValue(t){this._Data.next(t)}getSalesOrderPrint(t){return this.httpService.post("/API/POS/GetSalesOrderPrint",{TemplateID:t})}submitOrder(t,e){let i=this.generatePOSDataForSubmission(t,this.isOnline);if(this.isOnline)return this.submitOnline(i).pipe(this.handleTimeOutError(i));if(e.ModuleSell.EnableOfflineTransaction)return this._localDataService.syncOrder(i).pipe(W(()=>this.generateCompleteData(i)));this._toastrService.warning("Offline order is not Supported!","Info!")}uploadOfflineOrder(t){return this._localDataService.uploadSingleOrder(t).pipe(nt(e=>e?.message?.includes("objectStore does not exists")?this.submitOnline(t):St(()=>e)))}submitOnline(t){return this.httpService.post(U.SubmitOrder,t,ao.pos.submitOrderTimeout)}handleTimeOutError(t){return pi(nt(e=>{if(e instanceof gi||e?.name=="TimeoutError"){let i=this.generateCompleteData(t);this.pushNewValue(i)}throw e}))}generatePOSDataForSubmission(t,e=!0){let i=Object.assign(new $,t);i.Items=[],i.Order.CustomerID==null&&(i.Order.CustomerID=u.GuidEmpty),i.Order.SalesID==null&&(i.Order.SalesID=u.GuidEmpty);let o=1;i.Payments=i.Payments.map(c=>(c.Date=i.Order.Date,c.Index=o,o++,delete c.TypeID,c));let r=1;for(let c of i.CartItems){let g=new xi;g.ID=c.ID,g.VariantID=c.VariantID,g.Quantity=c.Quantity,g.Cost=c.Cost,g.Price=c.Price,g.Discount=c.Discount,g.DiscountAmount=c.DiscountAmount,g.Note=c.Note,g.Taxable=c.Variant.Taxable,g.LoyaltyPoint=c.LoyaltyPoint,g.UnitCost=c.Cost,g.UnitPrice=c.Price,g.UnitPriceOriginal=c.UnitPriceOriginal,g.UnitExpense=c.UnitExpense,g.EntityID=c.EntityID,g.Index=r,g.UnitQuantity=c.UnitQuantity,g.PriceTypeID=c.PriceTypeID,g.PriceNote=c.PriceNote,g.Splited=c.SplitQuantity>0,g.SplitQuantity=c.SplitQuantity,g.InventoryTypeID=c.Variant.TypeID,g.SalesID="",g.Serial=c.Serial,c.SalesID&&(g.SalesID=c.SalesID),delete c.CouponDiscount,i.Items.push(g),r++}return e?(delete i.CartItems,delete i.Order.ClientTimestamp):i.Order.ClientTimestamp=new Date,i}generateCompleteData(t){let e=new ki;return e.InvoiceNumber=t.Order.Number,e.OrderTimeString=new Date().toString(),e.PaymentStateID=t.Action?.Type,e.PaymentStateLabel="Offline",e.Success=!0,e.OutDeliveryID=t.Action.DeliveryEntityID,e}GetReturnInvoice(t,e){return this.httpService.get(U.ReturInvoice,[{key:"EntityID",value:e},{key:"Number",value:t}])}GetInvoiceBySoID(t){return this.httpService.get(U.GetPOSDataByID,[{key:"ID",value:t}])}UploadCSV(t,e){let i={CartItems:t,EntityID:e};return this.httpService.post(U.UploadCsv,i)}sendEmail(t,e){return new Promise((i,o)=>{this._localDataService.isProductFromServer().subscribe(r=>{if(r){let c={invoiceID:e,email:t};this.httpService.post(U.SendInvoiceEmail,c).subscribe({next:g=>{i(g)},error:g=>{o(g)}})}else o(ae.wrongOfflineAction)})})}sendWhatsaap(t,e){let i={InvoiceID:t,PhoneNumber:e};return this.httpService.post(U.SendInvoiceWhatsapp,i)}createCustomerByInvoice(t,e){let i={InvoiceID:t,Mobile:e};return this.httpService.post(U.CreateCustomerInvoice,i)}saveCommission(t,e){let i={SOID:t,commission:e};return this.httpService.POSText("/API/Transaction/SetCommission",i)}generateReceiptA4(t){let e={ID:t};return this.httpService.post(U.InvoiceA4,e)}getVacant(t){return this.httpService.get(U.GetVacant,[{key:"EntityID",value:t}])}static \u0275fac=function(e){return new(e||n)(f(_e),f(De),f(be),f(L))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var ni=(r=>(r[r.cash=1]="cash",r[r.card=2]="card",r[r.emoney=3]="emoney",r[r.other=4]="other",r[r.ECR=99]="ECR",r))(ni||{});var H=class n{constructor(t,e,i){this._OrderHttpService=t;this._customerHttpService=e;this._toastrService=i}_Data=new we(new $);transaction_id;Data$=this._Data.asObservable();get Data(){return this._Data.value}pushNewValue(t){if(t)this._Data.next(t);else{let e=this.Data;this._Data.next(e)}}submitOrder(t){return new Promise((e,i)=>{this.checkTransactionId(),this._OrderHttpService.submitOrder(this.Data,t).subscribe({next:o=>{e(o)},error:o=>{this.Data.Items=[],i(o)}})})}uploadOfflineOrder(){return this.checkTransactionId(),this._OrderHttpService.uploadOfflineOrder(this.Data)}checkTransactionId(){let e=this.Data.Payments.find(i=>i.TypeID==3);u.IsNotEmpty(e)&&u.IsEmpty(this.transaction_id)&&this._toastrService.warning("Midtrans transaction_id is empty. Please verify manually!","Mobile Payment Failure")}updateCustomerID(t){return this.Data.Order.CustomerID=t,this.pushNewValue(this.Data),new Promise((e,i)=>{this._customerHttpService.GetPrivilegeByID(t,this.Data.Order.EntityID).subscribe({next:o=>{this._customerHttpService.Data=o,this.pushNewValue(this.Data),e(o)},error:o=>{this.Data.Order.CustomerID=null,this.Data.ContactName=null;let r=o.error?.Message;o.status==409?this._toastrService.warning(r,"Warning"):this._toastrService.error(r,`API Error - ${o.status}`),i(o)}})})}static \u0275fac=function(e){return new(e||n)(f(Vt),f(Re),f(L))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var X=class n{constructor(t,e,i){this._localDataService=t;this._onlineStatusService=e;this._httpService=i;this._onlineStatusService.getOnlineStatus$().subscribe(o=>{this.isOnline=o})}_Data=new we(null);Data$=this._Data.asObservable().pipe(ne(t=>t!==null),Fe());isOnline;get Data(){return this._Data.value}pushNewValue(t){this._Data.next(t)}requestObservable(){return this.isOnline?this._httpService.get(U.GetPOSStorage).pipe(W(t=>({data:t,type:"Online"}))):this._localDataService.getPOSStorage().pipe(ne(t=>t!=null),W(t=>({data:t,type:"Offline"})))}getOutletName(t){return this.Data.Entities.find(i=>i.ID==t)?.Name}static \u0275fac=function(e){return new(e||n)(f(De),f(be),f(_e))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var ri=class{ID;Code;EntityID;Name;Description;Start;StartDisplay;State;Open;CashierID;OpeningCash;EntityName;LoginID;Active;CustomerDisplayEnabled;OvoConfigurationID;CustomerDisplayID;ListImage;Suspended};var Vi=class n{odsConfigType=T(0);setODSConfig(t){this.odsConfigType.set(t)}isEnabled(){return this.odsConfigType()>0}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var _r=["searchInputRef"],yr=n=>({active:n}),br=n=>({gray:n});function Sr(n,t){if(n&1){let e=E();a(0,"span",16),_("click",function(o){b(e);let r=p().$implicit;return p().closeRegister(r),S(o.stopPropagation())}),s()}}function Pr(n,t){n&1&&(a(0,"div")(1,"span",17),d(2,"VACANT"),s()())}function Or(n,t){if(n&1&&(a(0,"div")(1,"span",18),y(2,"i",19),a(3,"span",20),d(4),s()(),a(5,"span",21),y(6,"i",22),a(7,"span",20),d(8),s()()()),n&2){let e=p().$implicit;l(4),P(e.LoginID),l(4),I("",e.StartDisplay.split(" ")[3]," - Now")}}function Mr(n,t){if(n&1){let e=E();a(0,"div",9)(1,"div",10)(2,"div",11)(3,"h5",12),_("click",function(){let o=b(e).$implicit,r=p();return S(r.select(o))}),a(4,"span"),y(5,"i",13),d(6),v(7,"limitTo"),s(),h(8,Sr,1,0,"span",14),s(),a(9,"div",15),_("click",function(){let o=b(e).$implicit,r=p();return S(r.select(o))}),h(10,Pr,3,0,"div")(11,Or,9,2,"div"),s()()()()}if(n&2){let e,i=t.$implicit,o=p();l(),m("ngClass",i.Active?"active":""),l(),m("ngClass",k(9,yr,(i==null?null:i.ID)==(o.selectedRegister==null?null:o.selectedRegister.ID))),l(),m("ngClass",k(11,br,i!=o.selectedRegister)),l(3),P(re(7,6,i.Name,15)),l(2),C(i.State!="Close"?8:-1),l(2),C((e=i.State)==="Close"?10:e==="Open"?11:-1)}}var Fi=class n{constructor(t,e,i,o,r,c,g){this._dialogRef=t;this._outletService=e;this._posService=i;this._userRoleService=o;this.router=r;this.httpService=c;this._odsService=g}searchInputRef;originalSelectedRegister=null;registers;searchInput="";selectedRegister=new ri;modalConfig=T(new Y);role;get AppConfigJSON(){return this._posService.Data.AppConfigJSON}destroy$=new xe;ngOnInit(){this.initModalConfig(),this.subscribeToObsChanges()}ngAfterViewInit(){this.searchInputRef&&this._dialogRef.afterOpened().subscribe(()=>{setTimeout(()=>{this.searchInputRef.nativeElement.focus()},200)})}subscribeToObsChanges(){this._posService.Data$.pipe(Ie(this.destroy$)).subscribe(t=>{this.registers=t.Registers}),this._outletService.Data$.pipe(Ie(this.destroy$)).subscribe(t=>{this.selectedRegister=this.findOutletRegisterById(t.RegisterID),this.originalSelectedRegister=this.selectedRegister?di({},this.selectedRegister):null,this.initModalConfig(!1)}),this._userRoleService.Data$.pipe(Ie(this.destroy$)).subscribe(t=>{this.role=t})}findOutletRegisterById(t){let e=this.registers.find(i=>i.ID===t);return e||new ri}initModalConfig(t=!0){this.modalConfig.update(e=>(e.hideFooter=!0,e.hideScrollbar=!0,e.hideClose=t,e.title="Choose an outlet",e))}ngOnDestroy(){this.destroy$.next(!0),this.destroy$.complete()}onClose(){this._dialogRef.close()}select(t){if(this.AppConfigJSON.ModuleShift.Closure.Enabled)if(this.selectedRegister.ID!=null&&this.selectedRegister.Open&&t.CashierID==null)confirm("You already have an active register with "+this.selectedRegister.Name+`!
|
|
1
|
+
import{a as Zt}from"./chunk-ZOBPTHDY.js";import{a as At,b as Ne,c as Bo}from"./chunk-2OOAFLWG.js";import{a as zo}from"./chunk-ANBDI5MB.js";import{e as jo}from"./chunk-BXHFFVVV.js";import{a as Ti}from"./chunk-GGDW5WFA.js";import{b as Go}from"./chunk-MFCDS575.js";import{d as Wo}from"./chunk-2F3Z5UVP.js";import{a as Uo}from"./chunk-COD2FOFZ.js";import{a as Lo}from"./chunk-V46FIBS7.js";import{a as Ii}from"./chunk-2PUTNW54.js";import{a as Yo}from"./chunk-4VGCD2S7.js";import{a as be,b as Re,e as Jo}from"./chunk-C3DQQRQ2.js";import{b as Ho}from"./chunk-O55DD6CT.js";import{a as So}from"./chunk-CZWUCHB4.js";import{a as $o,b as qo}from"./chunk-KIH7ZE6M.js";import{a as Fo}from"./chunk-2XCPI5BA.js";import{a as wi}from"./chunk-HNS7KWHX.js";import{a as Ei,b as Ri,c as Ni}from"./chunk-OKL7T7RK.js";import{a as kt}from"./chunk-Q3UN4JZJ.js";import{a as Qo}from"./chunk-4WL57CXW.js";import{a as Ko}from"./chunk-VLSANGOZ.js";import{a as Yt,b as En,c as Ye}from"./chunk-L3CQDLDO.js";import{a as xi,b as Te}from"./chunk-NEUUD5VB.js";import{a as Nt}from"./chunk-32EIT4L7.js";import{a as tt,b as Kt,c as fe}from"./chunk-NSNUUKNK.js";import{a as Vo}from"./chunk-7GRHNPNY.js";import{g as ko}from"./chunk-MTMTZLMY.js";import{a as Ao}from"./chunk-JEJGTRFJ.js";import{d as Di}from"./chunk-6C7NKVRP.js";import{m as Pi}from"./chunk-6TWTQLKB.js";import{d as Oo}from"./chunk-SASYAFMF.js";import{c as Po}from"./chunk-STYLBZL4.js";import{a as Et}from"./chunk-VIKIXIX5.js";import{g as Mo}from"./chunk-IFLLAVLK.js";import{b as No}from"./chunk-3GZUX2TV.js";import{a as Eo,b as ae,c as De,f as Ro}from"./chunk-YWAAVL5W.js";import{a as Si,b as zt}from"./chunk-JFS6EFNT.js";import{F as Rt,N as Mi,O as U,g as xo,n as Oi,o as Io,q as To,t as wo}from"./chunk-WZVFFBZM.js";import{a as at}from"./chunk-QU45SEX2.js";import{a as yi,b as so,c as bi}from"./chunk-QYSFCWV7.js";import{d as wt,e as Do}from"./chunk-ZRBKLF75.js";import{a as Z,b as pe,c as ye}from"./chunk-CPHICIOL.js";import{a as oe,b as yo}from"./chunk-GCPQTFRO.js";import{o as bo}from"./chunk-NFVNHSX5.js";import{a as de,b as Y,c as ie}from"./chunk-N4STXFCX.js";import{A as Co,E as lt,F as vo,c as ve,e as Tt,h as ge,i as lo,k as co,l as Ge,n as mo,o as Me,p as po,q as uo,s as st,x as go,y as fo,z as ho}from"./chunk-DHBFOXIN.js";import{b as _o}from"./chunk-WXT6UMYF.js";import{a as u}from"./chunk-3DEA4WWC.js";import{a as ao}from"./chunk-VJ3CCTAP.js";import{n as L,q as _e}from"./chunk-2WBWJI4D.js";import{Bb as h,Cb as Tn,Db as C,Dc as k,Eb as Le,Ec as We,F as ne,Fa as T,Fb as Se,Gb as z,Gc as zn,Hb as K,Ib as m,J as nt,Jb as a,Kb as s,Kc as v,Kd as to,Lb as y,Lc as D,Mb as A,Mc as re,N as Pt,Nb as F,Nc as xt,O as Ue,Ob as Xe,Od as io,Pb as Ot,Qb as Mt,Qc as Kn,R as Fe,Rb as _i,Sa as ze,Tc as J,Td as no,Ua as Ct,Ub as E,Ud as oo,Va as Wn,Vb as Gn,Wd as ro,Xb as _,Xc as It,Yb as $n,Yc as ot,Z as Be,Za as l,Zb as p,aa as fi,ad as rt,b as pi,ba as te,bc as Dt,cc as vt,d as xe,dc as _t,e as we,ea as Ie,eb as M,ga as ce,hc as Ce,ib as N,ic as qn,jb as Ci,k as bt,lc as et,mc as d,md as Ee,n as Qn,na as w,nc as P,o as Qe,oa as hi,ob as ee,oc as I,od as Yn,p as St,pc as yt,pd as Zn,q as ui,qa as f,qc as Jn,qd as Xn,ra as O,rc as j,rd as eo,s as gi,sc as B,sd as He,tc as Q,u as W,uc as wn,ud as Ke,v as Je,va as b,w as Un,wa as S,wd as G,xb as vi,zd as me}from"./chunk-2ERDZXCS.js";import{a as di,i as Ze,k as mi}from"./chunk-SNAKHGZS.js";var Xt=class{ID;EntityID;RegisterID;TypeID;Date;Number;CustomerID;SalesID;Discount=0;Discount2=0;DiscountAmount=0;CustomerDiscountRate=0;Note="";DeliveryOutletID;TaxTypeID;CurrencyID;CurrencyRate;PointUsed;InvoicedStateID;ReferenceNumber="";LogisticsServiceID;ParkLabel="";NumberOfPerson;ClientTimestamp;Created;PromotionCoupon="";CouponType=1;PromotionNote="";DeliveryStateID;CouponProvider="Internal";CurrencySymbol;constructor(){this.ID=u.GuidEmpty,this.EntityID=u.GuidEmpty,this.RegisterID=u.GuidEmpty,this.Number="",this.CustomerID=null,this.SalesID=null,this.Discount=0,this.Discount2=0,this.DiscountAmount=0,this.Note="",this.TaxTypeID=u.GuidEmpty,this.CurrencyID=1,this.CurrencyRate=1,this.DeliveryStateID=3,this.PointUsed=0,this.NumberOfPerson=1,this.Date=new Date}removeEnterNote(){this.Note&&(this.Note=this.Note.replace(/\n/g,""))}};var ei=class{DeliveryEntityID;Type;NewOrderID;constructor(){this.DeliveryEntityID="",this.Type=3}};var Ai=class{Amount;ApplyToProduct;Code;Type;TypeDescription;Coupon;Notification;MaxDiscount;Note};var $=class{Order;Invoice;Shipping;Action;Payments;Items;CartItems;Promotion;ContactName;SplitParkLabel;get cartQuantity(){let t=0;for(let e of this.CartItems)t+=e.Quantity;return t}constructor(){this.Order=new Xt,this.Invoice=new Yt,this.Shipping=new En,this.Action=new ei,this.Payments=Array(),this.Items=Array(),this.CartItems=Array(),this.ContactName=""}get TotalPaidAmount(){let t=0;return this.Payments.forEach(e=>{t+=e.PaidAmount}),t}get RedeemableAmount(){let t=this.CartItems.filter(e=>e.Variant.PaymentTypeID!=1);return this.GetAmountByCart(t)}get TotalQuantity(){let t=0;return this.CartItems.forEach(e=>{e.PromotionGift||(t+=e.Quantity)}),t}get CashOnlyAmount(){let t=this.CartItems.filter(e=>e.Variant.PaymentTypeID==1);return this.GetAmountByCart(t)}get PointOnlyAmount(){let t=this.CartItems.filter(e=>e.Variant.PaymentTypeID==2);return this.GetAmountByCart(t)}get PrepaidPackageItem(){return this.CartItems.filter(e=>e.Variant.TypeID==10)}GetAmountByCart(t){let e=0;return t.forEach(i=>{e+=i.Total}),e=e*(100-this.Order.Discount)/100,e=e*(100-this.Order.Discount2)/100,e}getRewards(){return this.CartItems.filter(e=>e.PromotionGift)}};Ze([tt(()=>Xt)],$.prototype,"Order",2),Ze([tt(()=>Yt)],$.prototype,"Invoice",2),Ze([tt(()=>En)],$.prototype,"Shipping",2),Ze([tt(()=>ei)],$.prototype,"Action",2),Ze([tt(()=>Ye)],$.prototype,"Payments",2),Ze([tt(()=>xi)],$.prototype,"Items",2),Ze([tt(()=>Te)],$.prototype,"CartItems",2),Ze([tt(()=>Ai)],$.prototype,"Promotion",2);var ki=class{Success;Message;message;ObjectID;SalesOrderID;OutDeliveryID;Contact;LoyaltyPoint;InvoiceNumber;Creator;OrderTimeString;PrintMode;PaymentStateID;PaymentStateLabel;Final;InvoiceNumberResult;constructor(){this.Success=!0,this.Message="",this.ObjectID="",this.SalesOrderID="",this.OutDeliveryID="",this.Contact=null,this.LoyaltyPoint="",this.InvoiceNumber="",this.Creator="",this.OrderTimeString="",this.PrintMode=0,this.PaymentStateID=0,this.PaymentStateLabel="",this.Final=0}};var Vt=class n{constructor(t,e,i,o){this.httpService=t;this._localDataService=e;this._onlineStatusService=i;this._toastrService=o;this._onlineStatusService.getOnlineStatus$().subscribe(r=>{this.isOnline=r})}_Data=new we(null);Data$=this._Data.pipe(Fe(),ne(t=>t!==null));isOnline;get Data(){return this._Data.value}pushNewValue(t){this._Data.next(t)}getSalesOrderPrint(t){return this.httpService.post("/API/POS/GetSalesOrderPrint",{TemplateID:t})}submitOrder(t,e){let i=this.generatePOSDataForSubmission(t,this.isOnline);if(this.isOnline)return this.submitOnline(i).pipe(this.handleTimeOutError(i));if(e.ModuleSell.EnableOfflineTransaction)return this._localDataService.syncOrder(i).pipe(W(()=>this.generateCompleteData(i)));this._toastrService.warning("Offline order is not Supported!","Info!")}uploadOfflineOrder(t){return this._localDataService.uploadSingleOrder(t).pipe(nt(e=>e?.message?.includes("objectStore does not exists")?this.submitOnline(t):St(()=>e)))}submitOnline(t){return this.httpService.post(U.SubmitOrder,t,ao.pos.submitOrderTimeout)}handleTimeOutError(t){return pi(nt(e=>{if(e instanceof gi||e?.name=="TimeoutError"){let i=this.generateCompleteData(t);this.pushNewValue(i)}throw e}))}generatePOSDataForSubmission(t,e=!0){let i=Object.assign(new $,t);i.Items=[],i.Order.CustomerID==null&&(i.Order.CustomerID=u.GuidEmpty),i.Order.SalesID==null&&(i.Order.SalesID=u.GuidEmpty);let o=1;i.Payments=i.Payments.map(c=>(c.Date=i.Order.Date,c.Index=o,o++,delete c.TypeID,c));let r=1;for(let c of i.CartItems){let g=new xi;g.ID=c.ID,g.VariantID=c.VariantID,g.Quantity=c.Quantity,g.Cost=c.Cost,g.Price=c.Price,g.Discount=c.Discount,g.DiscountAmount=c.DiscountAmount,g.Note=c.Note,g.Taxable=c.Variant.Taxable,g.LoyaltyPoint=c.LoyaltyPoint,g.UnitCost=c.Cost,g.UnitPrice=c.Price,g.UnitPriceOriginal=c.UnitPriceOriginal,g.UnitExpense=c.UnitExpense,g.EntityID=c.EntityID,g.Index=r,g.UnitQuantity=c.UnitQuantity,g.PriceTypeID=c.PriceTypeID,g.PriceNote=c.PriceNote,g.Splited=c.SplitQuantity>0,g.SplitQuantity=c.SplitQuantity,g.InventoryTypeID=c.Variant.TypeID,g.SalesID="",g.Serial=c.Serial,c.SalesID&&(g.SalesID=c.SalesID),delete c.CouponDiscount,i.Items.push(g),r++}return e?(delete i.CartItems,delete i.Order.ClientTimestamp):i.Order.ClientTimestamp=new Date,i}generateCompleteData(t){let e=new ki;return e.InvoiceNumber=t.Order.Number,e.OrderTimeString=new Date().toString(),e.PaymentStateID=t.Action?.Type,e.PaymentStateLabel="Offline",e.Success=!0,e.OutDeliveryID=t.Action.DeliveryEntityID,e}GetReturnInvoice(t,e){return this.httpService.get(U.ReturInvoice,[{key:"EntityID",value:e},{key:"Number",value:t}])}GetInvoiceBySoID(t){return this.httpService.get(U.GetPOSDataByID,[{key:"ID",value:t}])}UploadCSV(t,e){let i={CartItems:t,EntityID:e};return this.httpService.post(U.UploadCsv,i)}sendEmail(t,e){return new Promise((i,o)=>{this._localDataService.isProductFromServer().subscribe(r=>{if(r){let c={invoiceID:e,email:t};this.httpService.post(U.SendInvoiceEmail,c).subscribe({next:g=>{i(g)},error:g=>{o(g)}})}else o(ae.wrongOfflineAction)})})}sendWhatsaap(t,e){let i={InvoiceID:t,PhoneNumber:e};return this.httpService.post(U.SendInvoiceWhatsapp,i)}createCustomerByInvoice(t,e){let i={InvoiceID:t,Mobile:e};return this.httpService.post(U.CreateCustomerInvoice,i)}saveCommission(t,e){let i={SOID:t,commission:e};return this.httpService.POSText("/API/Transaction/SetCommission",i)}generateReceiptA4(t){let e={ID:t};return this.httpService.post(U.InvoiceA4,e)}getVacant(t){return this.httpService.get(U.GetVacant,[{key:"EntityID",value:t}])}static \u0275fac=function(e){return new(e||n)(f(_e),f(De),f(be),f(L))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var ni=(r=>(r[r.cash=1]="cash",r[r.card=2]="card",r[r.emoney=3]="emoney",r[r.other=4]="other",r[r.ECR=99]="ECR",r))(ni||{});var H=class n{constructor(t,e,i){this._OrderHttpService=t;this._customerHttpService=e;this._toastrService=i}_Data=new we(new $);transaction_id;Data$=this._Data.asObservable();get Data(){return this._Data.value}pushNewValue(t){if(t)this._Data.next(t);else{let e=this.Data;this._Data.next(e)}}submitOrder(t){return new Promise((e,i)=>{this.checkTransactionId(),this._OrderHttpService.submitOrder(this.Data,t).subscribe({next:o=>{e(o)},error:o=>{this.Data.Items=[],i(o)}})})}uploadOfflineOrder(){return this.checkTransactionId(),this._OrderHttpService.uploadOfflineOrder(this.Data)}checkTransactionId(){let e=this.Data.Payments.find(i=>i.TypeID==3);u.IsNotEmpty(e)&&u.IsEmpty(this.transaction_id)&&this._toastrService.warning("Midtrans transaction_id is empty. Please verify manually!","Mobile Payment Failure")}updateCustomerID(t){return this.Data.Order.CustomerID=t,this.pushNewValue(this.Data),new Promise((e,i)=>{this._customerHttpService.GetPrivilegeByID(t,this.Data.Order.EntityID).subscribe({next:o=>{this._customerHttpService.Data=o,this.pushNewValue(this.Data),e(o)},error:o=>{this.Data.Order.CustomerID=null,this.Data.ContactName=null;let r=o.error?.Message;o.status==409?this._toastrService.warning(r,"Warning"):this._toastrService.error(r,`API Error - ${o.status}`),i(o)}})})}static \u0275fac=function(e){return new(e||n)(f(Vt),f(Re),f(L))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var X=class n{constructor(t,e,i){this._localDataService=t;this._onlineStatusService=e;this._httpService=i;this._onlineStatusService.getOnlineStatus$().subscribe(o=>{this.isOnline=o})}_Data=new we(null);Data$=this._Data.asObservable().pipe(ne(t=>t!==null),Fe());isOnline;get Data(){return this._Data.value}pushNewValue(t){this._Data.next(t)}requestObservable(){return this.isOnline?this._httpService.get(U.GetPOSStorage).pipe(W(t=>({data:t,type:"Online"}))):this._localDataService.getPOSStorage().pipe(ne(t=>t!=null),W(t=>({data:t,type:"Offline"})))}getOutletName(t){return this.Data.Entities.find(i=>i.ID==t)?.Name}static \u0275fac=function(e){return new(e||n)(f(De),f(be),f(_e))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var ri=class{ID;Code;EntityID;Name;Description;Start;StartDisplay;State;Open;CashierID;OpeningCash;EntityName;LoginID;Active;CustomerDisplayEnabled;OvoConfigurationID;CustomerDisplayID;ListImage;Suspended};var Vi=class n{odsConfigType=T(0);setODSConfig(t){this.odsConfigType.set(t)}isEnabled(){return this.odsConfigType()>0}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var _r=["searchInputRef"],yr=n=>({active:n}),br=n=>({gray:n});function Sr(n,t){if(n&1){let e=E();a(0,"span",16),_("click",function(o){b(e);let r=p().$implicit;return p().closeRegister(r),S(o.stopPropagation())}),s()}}function Pr(n,t){n&1&&(a(0,"div")(1,"span",17),d(2,"VACANT"),s()())}function Or(n,t){if(n&1&&(a(0,"div")(1,"span",18),y(2,"i",19),a(3,"span",20),d(4),s()(),a(5,"span",21),y(6,"i",22),a(7,"span",20),d(8),s()()()),n&2){let e=p().$implicit;l(4),P(e.LoginID),l(4),I("",e.StartDisplay.split(" ")[3]," - Now")}}function Mr(n,t){if(n&1){let e=E();a(0,"div",9)(1,"div",10)(2,"div",11)(3,"h5",12),_("click",function(){let o=b(e).$implicit,r=p();return S(r.select(o))}),a(4,"span"),y(5,"i",13),d(6),v(7,"limitTo"),s(),h(8,Sr,1,0,"span",14),s(),a(9,"div",15),_("click",function(){let o=b(e).$implicit,r=p();return S(r.select(o))}),h(10,Pr,3,0,"div")(11,Or,9,2,"div"),s()()()()}if(n&2){let e,i=t.$implicit,o=p();l(),m("ngClass",i.Active?"active":""),l(),m("ngClass",k(9,yr,(i==null?null:i.ID)==(o.selectedRegister==null?null:o.selectedRegister.ID))),l(),m("ngClass",k(11,br,i!=o.selectedRegister)),l(3),P(re(7,6,i.Name,15)),l(2),C(i.State!="Close"?8:-1),l(2),C((e=i.State)==="Close"?10:e==="Open"?11:-1)}}var Fi=class n{constructor(t,e,i,o,r,c,g){this._dialogRef=t;this._outletService=e;this._posService=i;this._userRoleService=o;this.router=r;this.httpService=c;this._odsService=g}searchInputRef;originalSelectedRegister=null;registers;searchInput="";selectedRegister=new ri;modalConfig=T(new Y);role;get AppConfigJSON(){return this._posService.Data.AppConfigJSON}destroy$=new xe;ngOnInit(){this.initModalConfig(),this.subscribeToObsChanges()}ngAfterViewInit(){this.searchInputRef&&this._dialogRef.afterOpened().subscribe(()=>{setTimeout(()=>{this.searchInputRef.nativeElement.focus()},200)})}subscribeToObsChanges(){this._posService.Data$.pipe(Ie(this.destroy$)).subscribe(t=>{this.registers=t.Registers}),this._outletService.Data$.pipe(Ie(this.destroy$)).subscribe(t=>{this.selectedRegister=this.findOutletRegisterById(t.RegisterID),this.originalSelectedRegister=this.selectedRegister?di({},this.selectedRegister):null,this.initModalConfig(!1)}),this._userRoleService.Data$.pipe(Ie(this.destroy$)).subscribe(t=>{this.role=t})}findOutletRegisterById(t){let e=this.registers.find(i=>i.ID===t);return e||new ri}initModalConfig(t=!0){this.modalConfig.update(e=>(e.hideFooter=!0,e.hideScrollbar=!0,e.hideClose=t,e.title="Choose an outlet",e))}ngOnDestroy(){this.destroy$.next(!0),this.destroy$.complete()}onClose(){this._dialogRef.close()}select(t){if(this.AppConfigJSON.ModuleShift.Closure.Enabled)if(this.selectedRegister.ID!=null&&this.selectedRegister.Open&&t.CashierID==null)confirm("You already have an active register with "+this.selectedRegister.Name+`!
|
|
2
2
|
Do you want to end your session?`)&&(this.onClose(),this.router.navigate(["menu/Shift/Main/My_Shift"],{queryParams:{RegisterID:t.ID}}));else if(!t.Open||this.selectedRegister.ID==t.ID)this.selectedRegister=t,this.onSubmitSelectedRegister();else{if(this.role.SellEditor==!1){alert("You cannot end shift for Register "+t.Name+" - Unauthorized Access");return}alert("This Register has already active register, Are you sure you want to end this register?"),this.onClose(),this.router.navigate(["/menu/Shift/Main/My_Shift"],{queryParams:{RegisterID:t.ID}})}else this.selectedRegister=t,this.onSubmitSelectedRegister()}onSubmitSelectedRegister(){if(this.selectedRegister.ID==null){alert("Please select a register first!");return}this._outletService.pushNewRegister(this.selectedRegister),this.loadOdsConfig(this.selectedRegister.EntityID),this._dialogRef.close({selectedRegister:this.selectedRegister,openStartingCashDialog:this.selectedRegister.ID!=this.originalSelectedRegister?.ID})}closeRegister(t){let e=this.selectedRegister.ID;if(this.role.SellEditor==!1){alert("You cannot end shift for Register "+t.Name+" - Unauthorized Access");return}e==t.ID?this.router.navigate(["/menu/Shift/Main/My_Shift"]):this.router.navigate(["/menu/Shift/Main/My_Shift"],{queryParams:{RegisterID:t.ID}}),this.onClose()}loadOdsConfig(t){this.httpService.get(`/api/outlet/GetOrderDisplayBroadcastMode?EntityID=${t}`).pipe(ce(e=>{this._odsService.setODSConfig(e.form.OrderDisplayBroadcastMode)})).subscribe()}static \u0275fac=function(e){return new(e||n)(M(Z),M(se),M(X),M(Ne),M(no),M(_e),M(Vi))};static \u0275cmp=N({type:n,selectors:[["pos-modal-register"]],viewQuery:function(e,i){if(e&1&&Dt(_r,5),e&2){let o;vt(o=_t())&&(i.searchInputRef=o.first)}},standalone:!1,decls:13,vars:6,consts:[["searchInputRef",""],[3,"onClose","config"],[1,"ms-0","mb-8","search-container",3,"hidden"],[1,"input-group","mb-3","rounded-start-1"],[1,"input-group-text","txtFilter","rounded-end-0"],["aria-hidden","true",1,"fa","fa-magnifying-glass"],["data-cy","SearchOutlet","type","text","placeholder","Filter by Name","aria-label","Search",1,"txtFilter","form-control","border-start-0","rounded-1","rounded-start-0",3,"ngModelChange","ngModel"],[1,"container","custom-scroll"],[1,"row",2,"width","600px"],["data-cy","registers",1,"col-4"],[1,"card","border-0",3,"ngClass"],[1,"card-body","p-0",3,"ngClass"],[1,"card-title","mb-0",3,"click","ngClass"],[1,"fa-solid","fa-house","pe-1","fs-6"],[1,"fa","fa-xmark-circle","fa-lg","position-absolute",2,"text-shadow","0 1px 0 #afafaf","right","5px","top","16px"],[1,"card-text","px-0","py-2",3,"click"],[1,"fa","fa-xmark-circle","fa-lg","position-absolute",2,"text-shadow","0 1px 0 #afafaf","right","5px","top","16px",3,"click"],[1,"idle"],[1,"cashier"],["aria-hidden","true",1,"fa","fa-user","pe-2"],[1,"d-inline"],[1,"open"],["aria-hidden","true",1,"fa-regular","fa-clock","pe-2"]],template:function(e,i){if(e&1){let o=E();a(0,"modal-material",1),_("onClose",function(){return i.onClose()}),a(1,"content")(2,"div",2)(3,"div",3)(4,"span",4),y(5,"i",5),s(),a(6,"input",6,0),Q("ngModelChange",function(c){return b(o),B(i.searchInput,c)||(i.searchInput=c),S(c)}),s()()(),a(8,"div",7)(9,"div",8),z(10,Mr,12,13,"div",9,Se),v(12,"FilterByName"),s()()()()}e&2&&(m("config",i.modalConfig()),l(2),m("hidden",i.registers.length<=6),l(4),j("ngModel",i.searchInput),l(4),K(re(12,3,i.registers,i.searchInput)))},dependencies:[Ee,ve,ge,Me,ie,Oi,wo],styles:[".text-warning[_ngcontent-%COMP%]{color:var(--bs-warning)!important}.bg-light-gray[_ngcontent-%COMP%]{background-color:var(--bs-light-gray);--bs-bg-opacity: .15 !important}.bg-gradient-danger[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#f8d7da,#f8d7da 15px,#f5c6cb 15px 30px)!important}.bg-gradient-success[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#beeebb,#beeebb 15px,#afeba8 15px 30px)!important}.bg-gradient-warning[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#fcf3cf,#fcf3cf 15px,#f9e79f 15px 30px)!important}.bg-light-orange[_ngcontent-%COMP%]{background-color:var(--bs-light-orange);--bs-bg-opacity: .15 !important}.text-danger[_ngcontent-%COMP%]{color:#fb404b!important}.text-dark[_ngcontent-%COMP%]{color:#5e5e5e!important}.text-success[_ngcontent-%COMP%]{color:#87cb16!important}.text-black[_ngcontent-%COMP%]{color:#000!important}.text-white[_ngcontent-%COMP%]{color:var(--bs-white)!important}.btn-light-blue[_ngcontent-%COMP%]{color:#212529;background-color:#dfeffc!important;border-color:#dfeffc}.btn-light-blue[_ngcontent-%COMP%]:hover{color:#212529;background-color:#bcdef9;border-color:#b0d8f8}.btn-light-blue[_ngcontent-%COMP%]:focus, .btn-light-blue.focus[_ngcontent-%COMP%]{color:#212529;background-color:#bcdef9;border-color:#b0d8f8;box-shadow:0 0 0 .2rem #c3d1dc80}.btn-light-blue.disabled[_ngcontent-%COMP%], .btn-light-blue[_ngcontent-%COMP%]:disabled{color:#212529;background-color:#dfeffc;border-color:#dfeffc}.btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active, .btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active, .show[_ngcontent-%COMP%] > .btn-light-blue.dropdown-toggle[_ngcontent-%COMP%]{color:#212529;background-color:#b0d8f8;border-color:#a5d2f7}.btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active:focus, .btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active:focus, .show[_ngcontent-%COMP%] > .btn-light-blue.dropdown-toggle[_ngcontent-%COMP%]:focus{box-shadow:0 0 0 .2rem #c3d1dc80}.btn-light-danger[_ngcontent-%COMP%]{color:#212529;background-color:#f8d7da!important;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:hover{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5}.btn-light-danger[_ngcontent-%COMP%]:focus, .btn-light-danger.focus[_ngcontent-%COMP%]{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5;box-shadow:0 0 0 .2rem #dc354540}.btn-light-danger.disabled[_ngcontent-%COMP%], .btn-light-danger[_ngcontent-%COMP%]:disabled{color:#212529;background-color:#f8d7da;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]{color:#212529;background-color:#f1aeb5;border-color:#ea868f}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active:focus, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active:focus, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]:focus{box-shadow:0 0 0 .2rem #dc354540}.search-container[_ngcontent-%COMP%]{transition:all .3s ease;width:97%}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]{position:relative;transition:all .3s ease;height:2.3rem}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:hover, .search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:focus-within{box-shadow:0 0 0 2px #89b03e4d,0 0 8px 4px #89b03e33;border-radius:4px}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%] .txtFilter.form-control[_ngcontent-%COMP%]{transition:all .3s ease;border-left:none!important}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%] .txtFilter.form-control[_ngcontent-%COMP%]:focus{box-shadow:none!important;border-color:#ced4da!important}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%] .input-group-text[_ngcontent-%COMP%]{transition:all .3s ease;background-color:#fff;border-right:none!important}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:hover .input-group-text[_ngcontent-%COMP%], .search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:focus-within .input-group-text[_ngcontent-%COMP%]{background-color:#89b03e1a;border-color:#84cc16!important}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%] .fa-magnifying-glass[_ngcontent-%COMP%]{transition:all .3s ease}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:hover .fa-magnifying-glass[_ngcontent-%COMP%], .search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:focus-within .fa-magnifying-glass[_ngcontent-%COMP%]{color:#84cc16!important}.search-container[_ngcontent-%COMP%] .input-group[_ngcontent-%COMP%]:focus-within{box-shadow:0 0 0 2px #89b03e66,0 0 12px 6px #89b03e40!important}.custom-scroll[_ngcontent-%COMP%]::-webkit-scrollbar{width:6px}.custom-scroll[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:#f1f1f1;border-radius:3px}.custom-scroll[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:#89b03e;border-radius:3px}.custom-scroll[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:#7a9e37}.container[_ngcontent-%COMP%]{overflow-y:auto;overflow-x:hidden;max-height:260px;min-height:150px}.col-4[_ngcontent-%COMP%]{list-style:none;margin:0;padding:0;display:flex;flex-wrap:wrap!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%]{width:180px;min-height:95px;margin-right:17px;margin-bottom:17px;position:relative}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%]{display:block;outline:0;border:1px solid #B1AAAA;border-radius:5px;cursor:pointer}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] h5[_ngcontent-%COMP%]{height:30px;border-radius:4px;padding:5px 10px;color:#fff;background:#b1aaaa;overflow:hidden}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] h5[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{margin-right:5px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%]:hover, .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.active[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.vacant[_ngcontent-%COMP%]{background:#ffffe1;border:1px solid #89b03e}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%]:hover > h5[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.active[_ngcontent-%COMP%] > h5[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.vacant[_ngcontent-%COMP%] > h5[_ngcontent-%COMP%]{background:#89b03e}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%]:hover{border:1px solid #c9302c}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%] > h6[_ngcontent-%COMP%], .col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%]:hover > h6[_ngcontent-%COMP%]{background:#c9302c!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%] span.alias[_ngcontent-%COMP%]{background:#c9302c}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.occupied[_ngcontent-%COMP%]:hover{background:#fff}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%]{border:1px solid #f6a828}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%] > h6[_ngcontent-%COMP%]{background:#f6a828!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%]:hover{border:1px solid #f6a828;background:#fff}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%]:hover > strong[_ngcontent-%COMP%]{background:#f6a828!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%] span.alias[_ngcontent-%COMP%]{background:#f6a828}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body.preparing[_ngcontent-%COMP%] div[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{font-size:.75rem!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%]{height:80px;padding:15px 10px;position:relative}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{display:block;font-weight:400;font-size:.875rem;width:100%;margin-bottom:5px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span[_ngcontent-%COMP%]:first-child{margin-top:-10px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span[_ngcontent-%COMP%]:last-child{margin-bottom:0}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span.alias[_ngcontent-%COMP%]{text-align:center;position:absolute;bottom:0;right:0;width:auto;background-color:#b1aaaa;border-radius:3px;padding:2px 5px;color:#fff;display:none!important}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > .card-body[_ngcontent-%COMP%] div[_ngcontent-%COMP%] span.idle[_ngcontent-%COMP%]{display:block;font-size:1.25rem;text-align:center}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{position:absolute;width:27px;height:28px;cursor:pointer;top:5px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > span[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{color:#000}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]:last-of-type{right:-5px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]:nth-last-of-type(2){right:15px}.col-4[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{bottom:20px;right:5px;position:absolute}.col-4[_ngcontent-%COMP%] .duration[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{border:1px solid!important;position:absolute;bottom:-3px;left:58px;background:#fff;border-radius:5px}"]})};var Dr=["inputCash"],Bi=class n{constructor(t,e,i){this.dialogRef=t;this.data=e;this.focusMonitor=i;this.generateModalTitle$.subscribe()}registerService=O(se);loadPOSService=O(X);register=this.registerService.Data;username=this.loadPOSService?.Data?.UserName;amount=T(0);config=new Y;currentRegisterName;generateModalTitle$=this.registerService.Data$.pipe(ne(t=>u.IsNotEmpty(t)),ce(()=>{let t=this.registerService.getOutletRegister(),e=t?.Name?.length>18?`${t?.Name?.substring(0,18)}...`:t?.Name;this.config.title="Open Shift",this.currentRegisterName=e}),oe());today=new Date;inputCashEl;ngOnInit(){this.config.customWidth="350px",this.config.hideCancel=!0}ngAfterViewInit(){this.focusInput(),this.dialogRef.afterOpened().subscribe(()=>{this.focusInput()})}focusInput(){let t=this.inputCashEl?.nativeElement;t&&(this.focusMonitor.focusVia(t,"program"),t.addEventListener("blur",()=>{this.dialogRef.getState()===0&&this.focusMonitor.focusVia(t,"program")}))}onOk(){this.dialogRef.close({amount:this.amount()})}static \u0275fac=function(e){return new(e||n)(M(Z),M(pe),M(bo))};static \u0275cmp=N({type:n,selectors:[["POS-modal-opening-cash"]],viewQuery:function(e,i){if(e&1&&Dt(Dr,5),e&2){let o;vt(o=_t())&&(i.inputCashEl=o.first)}},standalone:!1,decls:25,vars:8,consts:[["inputCash",""],[3,"onOk","onCancel","onClose","config"],[1,"table","fs-5","text"],[1,"py-3"],[1,"text-end","pe-3"],[1,"py-4"],[1,"text-end"],["data-cy","InputCash","autoNum","",1,"border","form-control-lg","text-end","w-100",3,"ngModelChange","ngModel"]],template:function(e,i){if(e&1){let o=E();a(0,"modal-material",1),_("onOk",function(){return i.onOk()})("onCancel",function(){return i.dialogRef.close()})("onClose",function(){return i.dialogRef.close()}),a(1,"content")(2,"table",2)(3,"tr")(4,"td",3),d(5,"Outlet Register"),s(),a(6,"td",4),d(7),s()(),a(8,"tr")(9,"td",5),d(10,"Current User"),s(),a(11,"td",4),d(12),s()(),a(13,"tr")(14,"td",5),d(15,"Starting Time"),s(),a(16,"td",4),d(17),v(18,"date"),s()(),a(19,"tr")(20,"td",3),d(21,"Starting Cash"),s(),a(22,"td",6)(23,"input",7,0),Q("ngModelChange",function(c){return b(o),B(i.amount,c)||(i.amount=c),S(c)}),s()()()()()()}e&2&&(m("config",i.config),l(7),P(i.currentRegisterName),l(5),P(i.username),l(5),P(re(18,5,i.today,"EEEE, HH:mm")),l(6),j("ngModel",i.amount))},dependencies:[ve,ge,Me,ie,Et,Ke],styles:[".table-title-width[_ngcontent-%COMP%]{width:120px}"]})};var Li=class{OrderNumberElement;InvoiceNumberElement;NewOrderID};var Ft=class n{constructor(t,e,i){this._httpService=t;this._onlineStatusService=e;this._localDataService=i;this._onlineStatusService.getOnlineStatus$().subscribe(o=>{this.isOnline=o})}isOnline;GenerateNumber(t,e){if(this.isOnline)return this._httpService.get(U.GenerateNumber,[{key:"EntityID",value:t},{key:"TypeID",value:1}]);{let i=new Li;return u.IsNotEmpty(e.NumberElement)&&(e.NumberElement.Seed+=1),u.IsNotEmpty(e.InvoiceNumberElement)&&(e.InvoiceNumberElement.Seed+=1),i.InvoiceNumberElement=e.InvoiceNumberElement,i.OrderNumberElement=e.NumberElement,i.NewOrderID=u.Guid_NewGuid(),Qe(i)}}findRegisterById(t){return new Promise(e=>{this._localDataService.isConfigFromServer().subscribe(i=>{i?this._httpService.get(U.GetRegisterInfo,[{key:"RegisterID",value:t}]).subscribe(o=>{e(o)}):this._localDataService.findRegisterByID(t).subscribe(o=>{e(o)})})})}recordOpeningCash(t){return ui(this._httpService.post("/API/POS/RecordOpeningCash",t))}static \u0275fac=function(e){return new(e||n)(f(_e),f(be),f(De))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var se=class n{constructor(t,e,i,o,r,c){this._signalRClientService=t;this._matDialog=e;this._posHttpResponseService=i;this._CoreHttpService=o;this._toastrService=r;this._roleService=c}datePipe=O(Ke);_Data=new we(null);Data$=this._Data.asObservable().pipe(ne(t=>t!==null),Fe());get Data(){return this._Data.value}getSalesname(t){return this.Data&&this.Data.ListSales?this._Data.value.ListSales.find(e=>e.ID==t)?.Name:""}setActiveRegisterFromOptions(t,e){let o=this._posHttpResponseService.Data.AppConfigJSON.ModuleShift.Closure.Enabled;if(t.length>1){let r=t.find(c=>c.LoginID==e);if(r)this.pushNewRegister(r);else{let c=this.getOutletRegisterFromLocalStorage(),g=this.Data?.RegisterID?this.Data.RegisterID:c?.ID;t.some(V=>V.ID==g)?o?this.openChooseRegisterModal():this.initRegisterFromLocalStorage():this.openChooseRegisterModal()}}t.length==1&&(this.pushNewRegister(t[0]),u.IsEmpty(t[0].LoginID)&&u.IsEmpty(t[0].CashierID)&&this.openOpeningCashModal(t[0].ID)),t.length==0&&this._toastrService.warning("You do not have access to any OUTLET","Warning")}openChooseRegisterModal(){this._matDialog.open(Fi,{id:"registerModal",disableClose:!0}).afterClosed().pipe(ne(t=>u.IsNotEmpty(t?.selectedRegister))).subscribe(t=>{t.selectedRegister&&this.openOpeningCashModal(t.selectedRegister.ID)})}openOpeningCashModal(t){this._posHttpResponseService.Data.AppConfigJSON.ModuleShift.Closure.Enabled&&this._matDialog.open(Bi,{disableClose:!0}).afterClosed().pipe(ne(o=>u.IsNotEmpty(o))).subscribe(o=>{let r={RegisterID:t,OpAmount:o.amount};this._CoreHttpService.recordOpeningCash(r).then(()=>{this.updateRegisterList(r),this.initCursorFocus(t)})})}updateRegisterList(t){let i=this._posHttpResponseService.Data.Registers.map(r=>r.ID==t.RegisterID?this.mapRegisterAsActiveRegister(r,t):r),o=this._posHttpResponseService.Data;o.Registers=i,this._posHttpResponseService.pushNewValue(o)}mapRegisterAsActiveRegister(t,e){let i=localStorage.getItem("AccountInfo");if(i){let r=JSON.parse(i);t.LoginID=r.UserName}t.OpeningCash=e.OpAmount,t.Open=!0,t.State="Open";let o=this.datePipe.transform(new Date,"dd MM yyyy HH:mm");return t.StartDisplay=o,t}initRegisterFromLocalStorage(){if(this._roleService.Data.DeleteItem==!1){let e=this.getOutletRegisterFromLocalStorage();e&&this.pushNewRegister(e)}}pushNewRegister(t){let e=this._Data.value,i=e?e.RegisterID:null;i!=t.ID&&this._CoreHttpService.findRegisterById(t.ID).then(o=>{o.RegisterCode=t.Code,o.DefaultPrintTemplate=o.PrintTemplate,o.SplitPaymentEnabled=this.findSplitPaymentConfig(o.EntityID),this._signalRClientService.SubscribeGroup(o.RegisterID,i),this.saveOutletRegisterToLocalStorage(t),this.pushNewValue(o)})}getOutletRegister(){let t=this.Data.RegisterID;return this._posHttpResponseService.Data.Registers.find(o=>o.ID==t)}pushNewValue(t){this._Data.next(t)}saveOutletRegisterToLocalStorage(t){if(this._roleService.Data.DeleteItem==!1){let i=JSON.stringify(t);localStorage.setItem("outlet_register",i)}}getOutletRegisterFromLocalStorage(){let t=this._roleService.Data.DeleteItem,e=localStorage.getItem("outlet_register"),i=null;return e&&(t?localStorage.removeItem("outlet_register"):i=JSON.parse(e)),i}findOutletRegisterById(t){return this._posHttpResponseService.Data.Registers.find(o=>o.ID===t)}findSplitPaymentConfig(t){let i=this._posHttpResponseService.Data.Entities.find(o=>o.ID===t);return i?i.SplitPaymentEnabled:!1}initCursorFocus(t){let e=document.getElementById("product");e&&u.IsNotEmpty(t)&&e.focus()}static \u0275fac=function(e){return new(e||n)(f(at),f(ye),f(X),f(Ft),f(L),f(Ne))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var Bt=class{CommissionID;ReturNumber;parkTemporaryItem;posState;InputTextValue;constructor(){this.posState=0,this.CommissionID="",this.ReturNumber="",this.parkTemporaryItem=[],this.InputTextValue=""}};var Hi=class{RegisterID;RegisterCode;EntityID;EntityName;NumberElement;InvoiceNumberElement;ListSales;QuickKeyPack;PrintTemplate;DefaultSalesOrderTag;DefaultTaxType;DefaultWarehouse;MemberPoint;ParkLayoutPack;Promotion;DefaultPrintTemplate;NewOrderID;Payments;SplitPaymentEnabled;constructor(){this.RegisterID=null,this.RegisterCode=null,this.EntityID=null,this.EntityName=null,this.NumberElement=new Nt,this.InvoiceNumberElement=new Nt,this.Promotion=[],this.SplitPaymentEnabled=!0}};var Ht=(c=>(c.Amount="Amount",c.Percentage="Percentage",c.Return="Return",c.ParkedDeletion="ParkedDeletion",c.DeleteItem="DeleteItem",c.FullAccess="FullAccess",c))(Ht||{});var ji=class n{constructor(t,e,i){this._promotionEventService=t;this._dialogRef=e;this.data=i;this.modalConfig=new Y,this.modalConfig.hideCancel=!0,this.modalConfig.hideClose=!0,this.modalConfig.headerType=de.Warning,this.modalConfig.title="Promotion Requirement unfulfilled!",this.modalConfig.customWidth="350px",this.modalConfig.okText="Ok",this.selectedPromotion=t.selectedPromotion}modalConfig;selectedPromotion;onOk(){this._promotionEventService.restoreOrder(),this._dialogRef.close()}static \u0275fac=function(e){return new(e||n)(M(ke),M(Z),M(pe))};static \u0275cmp=N({type:n,selectors:[["POS-modal-promotion-confirm"]],standalone:!1,decls:9,vars:4,consts:[[3,"onOk","config"],[1,"fst-italic","text-danger","mb-3"],[1,"mb-0"]],template:function(e,i){e&1&&(a(0,"modal-material",0),_("onOk",function(){return i.onOk()}),a(1,"content")(2,"div")(3,"h5"),d(4),s(),a(5,"p",1),d(6),s(),a(7,"p",2),d(8),s()()()()),e&2&&(m("config",i.modalConfig),l(4),P(i.selectedPromotion==null?null:i.selectedPromotion.Name),l(2),P(i.selectedPromotion==null?null:i.selectedPromotion.Description),l(2),P(i.data==null?null:i.data.message))},dependencies:[ie],encapsulation:2})};var Qi=class extends Te{};var mt=class{ModuleSell;ApplicationLoyalty;ApplicationMath;CoreDefaults;ModuleDelivery;ApplicationParkAndRetrieve;ApplicationRegisterClosure;PaymentConfigGopay;PaymentConfigLink;PrintConfigInvoice;CorePrint;PaymentConfigEmpatKali;ApplicationSettings;PrintConfigGeneral;ModuleProducts;ModuleContact;ApplicationTransactionNumbering;ModuleOrders;ModuleShift;ModuleBuy;ModuleAdjustment;TadaCouponVisible;CouponRedemptionType;ProviderOption};var le=class n{constructor(t,e,i,o){this._orderDataService=t;this._posService=e;this.POSMATH=i;this.decimalPipe=o;this._orderDataService.Data$.pipe(te(r=>this._posService.Data$.pipe(W(c=>({appConfig:c.AppConfigJSON,salesOrder:r}))))).subscribe(r=>{this.salesOrderData=r.salesOrder,this.appConfigJSON=r.appConfig,this.calculateDiscountAmount(),this.pushNewValue(this.grandTotal)})}_Data=new we(0);Data$=this._Data.asObservable().pipe(Fe());tax=new Bo;discountAfterTax=0;currencySymbol="Rp";get Data(){return this._Data.value}salesOrderData=new $;appConfigJSON=new mt;pushNewValue(t){this._Data.next(t)}get grandTotal(){let t=this.TotalAfterSurcharge;return isNaN(t)?0:t}setDecimalDigit(t){let e=this.decimalPipe.transform(t,"1.0-4");return t=parseFloat(e.split(",").join("")),t}get TotalAfterTax(){let t=this.TaxAmount,e=this.TotalBeforeTax+t;return e=this.POSMATH.Round(e,this.appConfigJSON.ApplicationMath.RoundingDigit.DecimalPlaceValue,this.appConfigJSON.ApplicationMath.RoundingDigit.RoundAlgorithm),e}get TotalBeforeTax(){let t=this.tax?.CalculationTypeID===1,e=0;return t?e=this.DiscountTotal-this.TaxAmount:e=this.DiscountTotal,e}get TotalAfterSurcharge(){let t=this.TotalAfterTax+this.SurchargeAmount;return this.POSMATH.Round(t,this.appConfigJSON.ApplicationMath.RoundingDigit.DecimalPlaceValue,this.appConfigJSON.ApplicationMath.RoundingDigit.RoundAlgorithm)}get TotalAfterDiscountTaxable(){return this.GrossTotalTaxable-this.DiscountTotal}get TaxAmount(){if(this.tax!=null){let t=0,e=this.appConfigJSON.ApplicationMath.RoundingTaxDigit.DecimalPlaceValue,i=this.appConfigJSON.ApplicationMath.RoundingTaxDigit.RoundAlgorithm,o=this.GrossTotalTaxable;return this.tax.CalculationTypeID==1?t=this.tax.Rate/(100+this.tax.Rate)*o:t=this.tax.Rate/100*o,t=this.POSMATH.Round(t,e,i),t}else return 0}get SurchargeAmount(){return this.TotalAfterTax*this.salesOrderData.Invoice.SurchargePcg/100}get Discount1Amount(){return this.GrossTotal*this.salesOrderData.Order.Discount/100}get AfterDiscount1Amount(){return this.GrossTotal-this.Discount1Amount}get Discount2Amount(){return this.AfterDiscount1Amount*this.salesOrderData.Order.Discount2/100}get AfterDiscount2Amount(){return this.AfterDiscount1Amount-this.Discount2Amount}get DiscountTotal(){return this.AfterDiscount2Amount-this.salesOrderData.Order.DiscountAmount}calculateDiscountAmount(){let t=this.salesOrderData.Order.DiscountAmount,e=0;this.AfterDiscount2Amount>=0&&t>0&&t>this.AfterDiscount2Amount&&(e=this.AfterDiscount2Amount),e!==0&&e<=t&&this.GrossTotal!==0&&(t=e),this.salesOrderData.Order.DiscountAmount=t}get GrossTotal(){return this.sum(this.salesOrderData.CartItems,"Total")}get GrossTotalTaxable(){let t=this.salesOrderData.CartItems.filter(i=>i.Taxable),e=this.sum(t,"Total");if(t.length!==0){let i=this.calculateDiscountTaxableItem(t);e=e*(100-this.salesOrderData.Order.Discount)/100,e=e*(100-this.salesOrderData.Order.Discount2)/100,e=e-i}return e}calculateDiscountTaxableItem(t){let e=this.GrossTotal,i=this.salesOrderData.Order.DiscountAmount,o=0,r=0,c=0,g=0;for(let x of t)o=x.getItemAfterDiscount/e,r=o*i,g=r*x.Quantity,c+=g;return c}get GrossTotalNonTaxable(){let t=this.salesOrderData.CartItems.filter(i=>i.Taxable==!1),e=this.sum(t,"Total");return e=e*(100-this.salesOrderData.Order.Discount)/100,e=e*(100-this.salesOrderData.Order.Discount2)/100,e=e-this.salesOrderData.Order.DiscountAmount,e}sum(t,e){let i=t.reduce((o,r)=>o+r[e],0);return i=this.setDecimalDigit(i),i}GetPointOnlyAmount(){let t=this.salesOrderData.CartItems.filter(e=>e.Variant.PaymentTypeID==2);return this.GetAmountByCart(t)}GetCashOnlyAmount(){let t=this.salesOrderData.CartItems.filter(e=>e.Variant.PaymentTypeID==1);return this.GetAmountByCart(t)}GetCashAndPointAmountCart(){let t=this.salesOrderData.CartItems.filter(e=>e.Variant.PaymentTypeID!=1);return this.GetAmountByCart(t)}GetAmountByCart(t){let e=this.sum(t,"Total");return e=e*(100-this.salesOrderData.Order.Discount)/100,e=e*(100-this.salesOrderData.Order.Discount2)/100,e}calculateGrossTotal(t){return this.sum(t,"Total")}static \u0275fac=function(e){return new(e||n)(f(H),f(X),f(Lo),f(G))};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var Ui=class{Code;Provider;OutletID;Customer;ShoppingCart};var Qt=class n{salesOrderService=O(H);registerService=O(se);customerService=O(Re);orderCalculator=O(le);generateRedeemCouponDto(t,e){let i=new Ui,o=this.registerService.Data?.EntityID;return i.Code=t,i.Provider=e,i.ShoppingCart={Amount:this.orderCalculator.Data,Items:this.generateItems()},i.OutletID=o,i.Customer=this.generateCustomer(e),i}generateItems(){return this.salesOrderService.Data.CartItems.map(i=>({ItemTemporaryID:i.ItemTemporaryID,Price:i.Price,Quantity:i.Quantity,VariantID:i.VariantID,Code:i?.Variant?.Code,Discount:i.Discount,DiscountAmount:i.DiscountAmount,PriceBookID:i.PriceBookID,UnitPriceOriginal:i.UnitPriceOriginal,UnitPrice:i.UnitPrice,CategoryID:i?.Variant?.CategoryID}))}generateCustomer(t){let e=this.customerService.Data,i=this.salesOrderService?.Data?.Order?.CustomerID,o=null;return u.IsNotEmpty(i)&&(o={Phone:e.Mobile,Email:e.Email},t==="Internal"&&(o=di({ID:i},o))),o}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};function Ir(n,t){if(n&1&&(a(0,"span",5),d(1),v(2,"number"),s()),n&2){let e=p().$implicit;l(),I("",D(2,1,e.Amount),"%")}}function Tr(n,t){if(n&1&&(a(0,"span",5),d(1),v(2,"number"),s()),n&2){let e=p().$implicit;l(),I(" -",D(2,1,e.Amount)," ")}}function wr(n,t){}function Er(n,t){if(n&1){let e=E();a(0,"button",8),_("click",function(){b(e);let o=p().$implicit,r=p();return S(r.onApplyCouponDiscount(o))}),d(1," Apply "),s()}}function Rr(n,t){if(n&1&&(a(0,"tr")(1,"td"),d(2),s(),a(3,"td"),d(4),s(),a(5,"td",4),d(6),v(7,"number"),s(),a(8,"td",4),h(9,Ir,3,3,"span",5)(10,Tr,3,3,"span",5),s(),a(11,"td",6),h(12,wr,0,0)(13,Er,2,0,"button",7),s()()),n&2){let e=t.$implicit,i=p();l(2),P(e==null?null:e.Name),l(2),P(e==null?null:e.Code),l(2),P(D(7,5,e==null?null:e.Price)),l(3),C((i.coupon==null?null:i.coupon.Type)==i.couponType.Percentage?9:10),l(3),C((e==null?null:e.CouponDiscount)>0?12:13)}}var Wi=class n{dialogRef=O(Z);coupon=O(pe);salesOrderModelService=O(H);config;couponType=Ht;itemsOptions=J(()=>{let t=this.salesOrderModelService?.Data?.CartItems,e=this.coupon?.ApplyToProduct??[];return e=e.filter(o=>o.UserOption),e.map(o=>{let r=t.find(c=>c.Variant.ID===o.ID);return r&&(o.Name=r.Variant?.Name,o.Price=r.Variant?.UnitPrice),o})});ngOnInit(){this.initModalConfig()}initModalConfig(){this.config=new Y,this.config.title="Choose Item to Apply Discount",this.config.hideFooter=!0}onApplyCouponDiscount(t){this.dialogRef.close(t)}onClose(){this.dialogRef.close()}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=N({type:n,selectors:[["app-modal-selected-coupon-item-v2"]],decls:17,vars:1,consts:[[3,"onCancel","onClose","config"],[1,"table","table-bordered"],[1,"thead-light"],["scope","col"],[1,"text-end"],[1,"text-danger"],[1,"text-center"],[1,"btn","btn-sm","btn-success"],[1,"btn","btn-sm","btn-success",3,"click"]],template:function(e,i){e&1&&(a(0,"modal-material",0),_("onCancel",function(){return i.onClose()})("onClose",function(){return i.onClose()}),a(1,"content")(2,"table",1)(3,"thead",2)(4,"tr")(5,"th",3),d(6,"Name"),s(),a(7,"th",3),d(8,"Code"),s(),a(9,"th",3),d(10,"Price"),s(),a(11,"th",3),d(12,"Discount"),s(),y(13,"th",3),s()(),a(14,"tbody"),z(15,Rr,14,7,"tr",null,Le),s()()()()),e&2&&(m("config",i.config),l(15),K(i.itemsOptions()))},dependencies:[me,No,G],encapsulation:2})};var Ut=class n{httpService=O(_e);promotionCouponFactoryService=O(Qt);salesOrderService=O(H);userRoleService=O(Ne);dialog=O(ye);posConfig=O(X);calculatorService=O(le);toastr=O(L);separateQuantityToNewRow=J(()=>this.posConfig.Data?.AppConfigJSON?.ModuleSell?.PromotionCouponSeparateQuantityToNewRow);_appliedCoupon=T(null);appliedCoupon=J(()=>this._appliedCoupon());salesOrderBeforePromotion=T(null);originalRoleData=J(()=>fe(At,this.userRoleService.Data));redeemCoupon(t,e){t=this.trimInputCoupon(t);let i=this.promotionCouponFactoryService.generateRedeemCouponDto(t,"Internal");return this.httpService.post(U.ValidateInternalCouponV2,i).pipe(ce(o=>{o.Note=e||"",o.Code=t,this.copyOriginalSalesOrder(),this.applyCoupon(o)}))}trimInputCoupon(t){return u.IsNotEmpty(t)&&(t=t.trim()),t}applyCoupon(t){switch(t.Type){case"Percentage":this.applyDiscountPercentage(t);break;case"Amount":this.applyDiscountAmount(t);break;case"Return":this.handleCouponReturnAccess(t);break;case"DeleteItem":this.handleDeleteItemAccess(t);break;case"ParkedDeletion":this.handleCouponParkedDeletionAccess(t);break;case"FullAccess":this.handleFullAccess(t);break}this._appliedCoupon.set(t)}applyDiscountPercentage(t){let e=t.ApplyToProduct??[];e.some(o=>u.IsNotEmpty(o.UserOption))?this.openDialogSelectItem(t):e.length>0?this.applyDiscountToProduct(t,e):this.applyDiscountToOrder(t)}applyDiscountAmount(t){let e=t.ApplyToProduct??[];e.some(o=>u.IsNotEmpty(o.UserOption))?this.openDialogSelectItem(t):e.length>0?this.applyDiscountToProduct(t,e):this.applyDiscountToOrder(t)}openDialogSelectItem(t){this.dialog.open(Wi,{data:t}).afterClosed().pipe(ne(e=>u.IsNotEmpty(e))).subscribe(e=>{this.applyDiscountToSelectedItem(t,e)})}applyDiscountToSelectedItem(t,e){this._appliedCoupon.update(i=>(i.ApplyToProduct=i.ApplyToProduct.map(o=>(e.ID==o.ID&&(o.SelectedItem=!0),o)),i)),this.applyDiscountToProduct(t,[e])}applyDiscountToOrder(t){let e=this.salesOrderService.Data;switch(t.Type){case"Amount":e.Order.DiscountAmount=t.Amount;break;case"Percentage":let i=this.calculateMaxDiscountInvoice(t);i.type=="amount"?e.Order.DiscountAmount=i.discount:e.Order.Discount=i.discount;break}e.Order.PromotionCoupon=t.Code,e.Order.PromotionNote=t.Note,e.Order.CouponType=1,this.salesOrderService.pushNewValue(e),this.showToastrAppliedCoupon(t)}calculateMaxDiscountInvoice(t){if(t.MaxDiscount>0){let e=t.Amount;return this.calculatorService.Data*e/100>t.MaxDiscount?{discount:t.MaxDiscount,type:"amount"}:{discount:t.Amount,type:"percentage"}}else return{discount:t.Amount,type:"percentage"}}applyDiscountToProduct(t,e){let i=this.salesOrderService.Data,o=i.CartItems,r=[];o=o.map(c=>{let g=this.findPromotionItemByVariantID(c,e);if(g.isMatch){let x=e[g.index];if(this.separateQuantityToNewRow()&&c.Quantity>1&&x.OneFirstOption){let V=this.separateItemQuantityToNewRow(x,c,t);c=V.originalItem,V.separatedItem&&r.push(V.separatedItem)}else{let V=this.calculateOneOfFirstDisc(x,c.Quantity);x.Amount=V,c=this.applyDiscountToItem(c,x,t)}}return c}),o=o.concat(r),i.CartItems=o,i.Order.PromotionCoupon=t.Code,i.Order.PromotionNote=t.Note,i.Order.CouponType=1,this.salesOrderService.pushNewValue(i),this.showToastrAppliedCoupon(t)}separateItemQuantityToNewRow(t,e,i){let o=e.Quantity,r=fe(Te,e);return o>1?(e.Quantity=o-1,r.Quantity=1,r=this.applyDiscountToItem(r,t,i)):e=this.applyDiscountToItem(e,t,i),{originalItem:e,separatedItem:r}}calculateOneOfFirstDisc(t,e){let i=t.Amount;return t.OneFirstOption&&(i=t.Amount/e),i}applyDiscountToItem(t,e,i){switch(i.Type){case"Amount":t.DiscountAmount=e.Amount;break;case"Percentage":if(i.MaxDiscount>0)if(this.calculateDiscountItem(t,e.Amount)>i.MaxDiscount){let r=i.MaxDiscount/t.Quantity;t.DiscountAmount=r}else t.Discount=e.Amount;else t.Discount=e.Amount;break}return t}calculateDiscountItem(t,e){return t.Price*t.Quantity*e/100}findPromotionItemByVariantID(t,e){let i=e.findIndex(o=>o.ID==t.VariantID&&o.ItemTemporaryID==t.ItemTemporaryID);return{isMatch:i>-1,index:i}}handleCouponReturnAccess(t){let e=fe(At,this.originalRoleData());e.Return=!0,this.userRoleService.pushNewValue(e),this.applyCouponToSalesOrder(t)}handleDeleteItemAccess(t){let e=fe(At,this.originalRoleData());e.DeleteItem=!0,this.userRoleService.pushNewValue(e),this.applyCouponToSalesOrder(t)}handleCouponParkedDeletionAccess(t){let e=fe(At,this.originalRoleData());e.ParkedDeletionAuthorized=!0,this.userRoleService.pushNewValue(e),this.applyCouponToSalesOrder(t)}handleFullAccess(t){let e=fe(At,this.originalRoleData());e.UnitPriceEditor=!0,e.Discount=!0,e.Return=!0,e.Tax=!0,e.NumberEditor=!0,e.DateEditor=!0,e.PricebookSelector=!0,e.DeleteItem=!0,e.ParkedDeletionAuthorized=!0,this.userRoleService.pushNewValue(e),this.applyCouponToSalesOrder(t)}resetCouponOnNewTransaction(){this.userRoleService.pushNewValue(this.originalRoleData()),this._appliedCoupon.set(null)}setCouponOnEdit(t){t&&u.IsNotEmpty(t?.Type)&&(this._appliedCoupon.set(t),this.generateOriginalSalesOrderOnEdit())}generateOriginalSalesOrderOnEdit(){let t=fe($,this.salesOrderService.Data);t.Order.PromotionCoupon=null,t.Order.PromotionNote=null,t.Order.Discount=0,t.Order.DiscountAmount=0,this.salesOrderBeforePromotion.set(t)}removeAppliedCoupon(){this.salesOrderService.pushNewValue(this.salesOrderBeforePromotion()),this.appliedCoupon().Type!="Amount"&&this.appliedCoupon().Type!="Percentage"&&this.userRoleService.pushNewValue(this.originalRoleData()),this._appliedCoupon.set(null),this.salesOrderBeforePromotion.set(null)}copyOriginalSalesOrder(){let t=fe($,this.salesOrderService.Data);this.salesOrderBeforePromotion.set(t)}applyCouponToSalesOrder(t){let e=this.salesOrderService.Data;e.Order.PromotionCoupon=t.Code,e.Order.PromotionNote=t.Note,e.Order.CouponType=1,this.salesOrderService.pushNewValue(e),this.showToastrAppliedCoupon(t)}showToastrAppliedCoupon(t){t.Notification?this.toastr.success(t.Notification,"Coupon Applied"):this.toastr.success("Coupon applied successfully!","Coupon Applied")}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var ut=class n{constructor(t,e,i,o,r,c,g,x,V,q){this.variantService=t;this._posService=e;this._orderDataService=i;this.toastr=o;this._orderProcessorService=r;this._customerHttpService=c;this.promotionCouponServiceV2=g;this.promotionCouponExternalService=x;this.userRoleService=V;this.decimalPipe=q;this.subscribeToObservable()}dialog=O(ye);salesOrderData;appConfigJson;entityID;audio=new Audio;priceMinimumRestrictionWarning=T("");subscribeToObservable(){this._posService.Data$.pipe(oe()).subscribe(t=>{this.appConfigJson=t.AppConfigJSON}),this._orderDataService.Data$.pipe(oe()).subscribe(t=>{this.salesOrderData=t,this.entityID=t.Order.EntityID}),this._orderProcessorService.Data$.pipe(oe()).subscribe(t=>{t.posState==3&&this.clearCartItemsInLocalStorage()})}addCartItemById(t,e,i=!0){return new Promise((o,r)=>{this.variantService.findVariantByID(t,this.entityID,i).then(c=>{this.isShoppingCartLockedByPromotionCoupon()==!1&&this.createNewCartItem(c,e),o(c)}).catch(c=>{r(c)})})}addCartItemByCode(t){return new Promise((e,i)=>{let o=this.appConfigJson.ModuleSell.DigitalScale;o.Digit>0&&u.IsNotEmpty(o.Regex)&&t.length==o.Digit?this.parseDigitalScaleBarcodeWithRegex(t,o).then(c=>{c||(this.toastr.info("Matching Regex Rule to Barcode","Digital Scale"),this.findVariantByCode(t).then(g=>e(g)).catch(g=>i(g)))}):this.findVariantByCode(t).then(c=>e(c)).catch(c=>i(c))})}findVariantByCode(t){let e=this.appConfigJson.ModuleSell.BarcodeSerialEnabled;return new Promise((i,o)=>{this.variantService.findVariantByCode(t,this.entityID,e).then(r=>{i(r),this.isShoppingCartLockedByPromotionCoupon()==!1&&this.createNewCartItem(r)}).catch(r=>{this.playBellRing(),o(r)})})}addItemBySerial(t){this.variantService.findVariantBySerial(t,this.entityID).subscribe(e=>{let i=this.salesOrderData.CartItems;if(i.length>0){let o,r=[],c=i.findIndex(g=>g.Variant.ID==e.ID);r=[],c!==-1?(o=i[c].Serial?.findIndex(g=>g.Number==t),r=[...i[c].Serial?i[c].Serial:[]],o==-1?(r.push({Number:t,Quantity:1}),i[c].Quantity=r.length):r.length>0?r[o].Quantity+=1:(r=[{Number:t,Quantity:1}],this.addNewSerials(e,t)),i[c].Serial=[...r],i[c].Quantity=i[c].calculateSerialQty(),this.updateCartItem(i[c],c)):this.addNewSerials(e,t)}else this.addNewSerials(e,t)})}addNewSerials(t,e){t.Serial=[{Number:e,Quantity:1}],this.createNewCartItem(t)}playBellRing(){this.audio.src="https://cdn.dealpos.xyz/web-audio/bell_ring.mp3",this.audio.load(),this.audio.play()}updateCartItem(t,e){this.isShoppingCartLockedByPromotionCoupon()==!1&&(this.salesOrderData.CartItems[e]=t,this._orderDataService.pushNewValue(this.salesOrderData),this.applyCustomerPoint(),this.saveItemsToLocalStorage())}deleteCartItem(t){this.isShoppingCartLockedByPromotionCoupon()==!1&&(this.salesOrderData.CartItems=this.salesOrderData.CartItems.filter(e=>e!==t),this._orderDataService.pushNewValue(this.salesOrderData),this.applyCustomerPoint())}parseDigitalScaleBarcodeWithRegex(t,e){return new Promise(i=>{let o=this.appConfigJson.ModuleSell.BarcodeSerialEnabled,r=new RegExp(e.Regex),c=t.match(r);if(console.log(c),u.IsNotEmpty(c)){let g=c[1],x=parseFloat(c[2]);console.log(x,"productQuantity"),x=x/e.QuantityDivider,this.variantService.findVariantByCode(g,this.entityID,o).then(V=>{this.createNewCartItem(V,null,x),i(!0)}).catch(()=>{i(!1)})}else i(!1)})}createNewCartItem(t,e,i){let o=new Te,r=this.appConfigJson.ModuleSell.ProductNotes.CopyProductDescription,c=this.appConfigJson.ModuleSell.ProductNotes.CopyPromotionName;o.patchByVariant(t,r,c),o=this.applyReward(o,e),u.IsEmpty(e)&&(o=this.applyPriceBook(o)),this.validateCartItem(o)&&(o.Quantity=i||o.Quantity,e?.PromotionType==2?this.handlingPromotionQuantity(o):this.pushNewItemToArray(o,o.PromotionGift),this.applyCustomerPoint()),this.addAvailableComponent(o)}applyCustomerPoint(){let t=this.salesOrderData.Order.CustomerID,e=u.IsEmpty(t);this._orderProcessorService.reedemPointToDiscount(e)}handlingPromotionQuantity(t){let e=fe(Te,this.salesOrderData.CartItems),i=e.findIndex(o=>o.VariantID==t.VariantID&&o.PromotionGift);i!==-1?e[i].Quantity+=t.Quantity?t.Quantity:1:e=[...e,t],this.salesOrderData.CartItems=e,this._orderDataService.pushNewValue(this.salesOrderData)}applyPromotionProduct(t){let e=t.Variant.DiscountAmount;return e&&(t.Price=t.UnitPriceOriginal-e),t}applyReward(t,e){if(e){let i=this.appConfigJson.ModuleSell.ProductNotes.CopyPromotionName;t.Discount=e.Discount,t.Price=e.OriginalPrice;let o=e.OriginalPrice-e.UnitPrice;t.Price=t.UnitPriceOriginal-o,t.UnitPrice=t.UnitPriceOriginal-o,t.PromotionGift=!0,t.PromotionID=e.PromotionID,t.Quantity=e.Quantity?e.Quantity:1,t.PriceTypeID=3,t.Cost+=e.ExtraCost,t.UnitCost+=e.ExtraCost,t.PriceNote=e.PromotionName,i&&(t.Note=`${t.Note?t.Note:""} ${e.PromotionName} `)}return t}addAvailableComponent(t){let e=t.Price!=0,i=this.appConfigJson.ModuleSell.SellProductComponentDefaultPrice,o=t.Variant;if(o.Component!=null&&o.Component.length>0)for(let r of o.Component){let c=new Qi;c.patchByVariant(r),c.Quantity=t.Quantity*r.Quantity,e&&!i&&(r.UnitPrice=0),c.Price=r.UnitPrice,this.pushNewItemToArray(c)}}pushNewItemToArray(t,e=!1){if(this.isShoppingCartLockedByPromotionCoupon()==!1){let i=this.salesOrderData.CartItems.findIndex(o=>o.VariantID==t.VariantID);if(t=this.applyPromotionProduct(t),i==-1||e){let o=this.salesOrderData.CartItems.length;t.ItemTemporaryID=o,this.salesOrderData.CartItems.push(t)}else{let o=this.appConfigJson.ModuleSell.QuickKey.NewRowBehaviour;if(o==2){let r=this.salesOrderData.CartItems.length;t.ItemTemporaryID=r,this.salesOrderData.CartItems.push(t)}else if(o==1)this._orderProcessorService.Data.posState==4?this.salesOrderData.CartItems.push(t):this.addingQuantityItem(i,t);else{if(!this.validatePrepaidPackage(t,i)){this.toastr.error("This prepaid package is already in the cart while editing. Please remove it first before adding again.","Cannot Add Item");return}this.addingQuantityItem(i,t)}}this._orderDataService.pushNewValue(this.salesOrderData),this.saveItemsToLocalStorage()}}saveItemsToLocalStorage(){let t=this.userRoleService.Data.DeleteItem,e=this._orderProcessorService.Data?.posState;if(!t&&e!==4){let i=this._orderDataService.Data,o=i?.Order?.Number,r=i.CartItems,c={Number:o,CartItems:r};try{localStorage.setItem("cart_items",JSON.stringify(c))}catch(g){console.error("Error saving cart items to localStorage:",g)}}}clearCartItemsInLocalStorage(){localStorage.getItem("cart_items")&&(this.userRoleService.Data?.DeleteItem?this.clearCartItemsBasedOnCoupon():this.clearCartItemsStorage())}clearCartItemsBasedOnCoupon(){let t=this.promotionCouponServiceV2?.appliedCoupon();t&&(t?.Type=="FullAccess"||t?.Type=="DeleteItem")&&this.clearCartItemsStorage()}clearCartItemsStorage(){try{localStorage.removeItem("cart_items")}catch(t){console.error("Error clearing cart items from localStorage:",t)}}validatePrepaidPackage(t,e){let i=this.salesOrderData.CartItems[e],o=this._orderProcessorService.Data.posState,r=t.Variant.TypeID==10,c=u.IsNotEmpty(i.ID),g=!0;return o==2&&r&&c&&(g=!1),g}addingQuantityItem(t,e){let i=this.salesOrderData.CartItems.filter(g=>g.VariantID==e.VariantID),o=i.length,r=i.find(g=>!g.PromotionGift);this.salesOrderData.CartItems[t].PromotionGift&&o==1?this.salesOrderData.CartItems.push(e):(r.Quantity+=e.Quantity,r=this.applyPromotionProduct(r)),r&&(r=this.applyPriceBook(r))}validateCartItem(t){return t.Variant.CategoryTypeID==-1?(this.toastr.info(t.Variant.Name+" cannot be sold, check Category "+t.Variant.CategoryName+" settings","info"),!1):!!this.validateSerialItem(t)}validatePriceMinimum(t){let e=this.checkPriceMinimumRestriction(t);if(e)this.priceMinimumRestrictionWarning.set("");else{let i=this.appConfigJson.ModuleSell?.ProductDialog?.MinimumPriceIncludeDiscount,o=this.getPriceMinimum(t),r=this.generateMinimumPriceWarningMessage(i,o,t);this.priceMinimumRestrictionWarning.set(r)}return e}checkPriceMinimumRestriction(t){let e=!0,i=this.userRoleService.Data.PriceMinimum,r=this.appConfigJson.ModuleSell?.ProductDialog?.MinimumPriceIncludeDiscount?t.TotalAfterDiscountPerQuantity:t.Price;if(i){let c=this.getPriceMinimum(t);r<c?e=!1:e=!0}return e}getPriceMinimum(t){let e=this.appConfigJson.ModuleSell.ProductDialog?.PriceMinimumTypeID,i=0;switch(e){case 1:i=t.Variant?.UnitPrice;break;case 2:i=t.Variant?.UnitCost;break;case 3:i=t.Variant?.UnitPriceMinimum;break}return i}generateMinimumPriceWarningMessage(t,e,i){let o="",r=i.Discount,c=i.DiscountAmount;return t&&(r>0||c>0)?o=u.StringFormat(`<span><i class='fa-solid fa-triangle-exclamation me-2 d-inline'></i>Item net price is <h5 class='d-inline m-0'>{0}</h5></span>
|
|
3
3
|
after item discount, you cannot sell lower than <h5 class='d-inline m-0'>{1}</h5></span>`,this.decimalPipe.transform(i.TotalAfterDiscountPerQuantity),this.decimalPipe.transform(e)):o=u.StringFormat("<span><i class='fa-solid fa-triangle-exclamation me-2 d-inline'></i>Cannot sell lower than <h5 class='d-inline m-0'>{0}</h5></span>",this.decimalPipe.transform(e)),o}validateSerialItem(t){let e=!0;if(t?.Serial?.length>0&&t.Variant.TypeID==4&&t.Quantity>0){let i=0;t?.Serial?.forEach(o=>{i+=o.Quantity}),i!=t.Quantity&&(this.toastr.error("Serial must be equal with the quantity","Error"),e=!1)}return e}isShoppingCartLockedByPromotionCoupon(){let t=this.promotionCouponServiceV2.appliedCoupon(),e=this.promotionCouponExternalService.coupon,i=!1;if((u.IsNotEmpty(t)||u.IsNotEmpty(e))&&this.isNonAuthorizedCouponType){i=!0;let r=this._orderDataService.Data.Order.PromotionCoupon;this.dialog.open(Ii,{id:"ShoppingCartLocked",data:{title:"Shopping Cart Locked",message:`
|
|
4
4
|
<div class="d-flex justify-content-center my-4">
|