dealpos 12.68.1 → 12.68.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/POS/{chunk-PQKIHP3D.js → chunk-233W73MU.js} +1 -1
- package/POS/{chunk-W7KRXXWK.js → chunk-26MOEY4S.js} +1 -1
- package/POS/{chunk-XCXDYI3M.js → chunk-27WNCAVY.js} +1 -1
- package/POS/{chunk-HXQZWK5O.js → chunk-2PKIUZYT.js} +1 -1
- package/POS/{chunk-7PFRBLMR.js → chunk-3GORFRIS.js} +2 -2
- package/POS/{chunk-W5VU4KMV.js → chunk-3H667UXU.js} +1 -1
- package/POS/{chunk-MQROPCSQ.js → chunk-3QE4EQJI.js} +1 -1
- package/POS/{chunk-G7CUTDNL.js → chunk-4PEHPBEW.js} +1 -1
- package/POS/chunk-5ED63HA3.js +1 -0
- package/POS/{chunk-CQ2MY6H4.js → chunk-5RUWKQJI.js} +1 -1
- package/POS/{chunk-UMIJRGGQ.js → chunk-64AWMLDO.js} +1 -1
- package/POS/{chunk-FZH3IS34.js → chunk-6EDPOXM4.js} +1 -1
- package/POS/{chunk-ZBGAUBZ4.js → chunk-6XK6PTG5.js} +1 -1
- package/POS/{chunk-MC7ELI3L.js → chunk-7JFX26ER.js} +1 -1
- package/POS/{chunk-RTIQ3IIW.js → chunk-A2E65QAK.js} +1 -1
- package/POS/{chunk-XV44DEPG.js → chunk-AJO4GDY5.js} +1 -1
- package/POS/{chunk-5GEAGUYY.js → chunk-ANNAK2YM.js} +1 -1
- package/POS/{chunk-SQY6K24B.js → chunk-DQBGON2V.js} +1 -1
- package/POS/{chunk-ON7PQMJ2.js → chunk-DXJC35ZL.js} +1 -1
- package/POS/{chunk-PT5MBKSK.js → chunk-EUCAH2ZT.js} +1 -1
- package/POS/{chunk-W5JXRO22.js → chunk-EY4ZJR4I.js} +1 -1
- package/POS/{chunk-VPTVKRUO.js → chunk-F4QBJUFN.js} +1 -1
- package/POS/{chunk-Q2UUN2BC.js → chunk-FOYJA2FY.js} +1 -1
- package/POS/{chunk-KUXMXAQC.js → chunk-FWL5MIP7.js} +1 -1
- package/POS/{chunk-DAKVDVHI.js → chunk-FZEMX3RT.js} +1 -1
- package/POS/{chunk-B6H5O7QG.js → chunk-H7QFUS4T.js} +1 -1
- package/POS/{chunk-ZLVNR2SF.js → chunk-HKLFJUQS.js} +1 -1
- package/POS/{chunk-T7R46GGS.js → chunk-HPI5BBKT.js} +1 -1
- package/POS/{chunk-ZXJMLWH5.js → chunk-I7E43JXT.js} +1 -1
- package/POS/{chunk-O4FLAMHO.js → chunk-IAAEFCVW.js} +1 -1
- package/POS/{chunk-NJBTOXIP.js → chunk-IQA4B35X.js} +2 -2
- package/POS/{chunk-7C3UD3XD.js → chunk-J2RWOLTV.js} +1 -1
- package/POS/{chunk-TJGQJK3Z.js → chunk-JBLNMANI.js} +1 -1
- package/POS/{chunk-XEDKK2DL.js → chunk-JGCK2TNE.js} +1 -1
- package/POS/{chunk-OCAZLESA.js → chunk-JK7PBA4W.js} +1 -1
- package/POS/{chunk-RDT5WXH4.js → chunk-KC5ANQG4.js} +1 -1
- package/POS/{chunk-65UUQWRU.js → chunk-KXV57ZXV.js} +1 -1
- package/POS/{chunk-OY6O7RV6.js → chunk-L4Y4GMGF.js} +1 -1
- package/POS/{chunk-NL437YCL.js → chunk-LJ4YACUT.js} +1 -1
- package/POS/{chunk-55FCY2YE.js → chunk-LKPPVLDK.js} +1 -1
- package/POS/{chunk-4HJFPJTJ.js → chunk-LNUZKDRI.js} +1 -1
- package/POS/{chunk-6RGF33CZ.js → chunk-LOMZ6RLP.js} +1 -1
- package/POS/{chunk-WG5LGN4T.js → chunk-LRK2SE54.js} +1 -1
- package/POS/{chunk-BRRVMLNV.js → chunk-M26LBVX4.js} +1 -1
- package/POS/{chunk-M3VMFOLX.js → chunk-NMVQB2U3.js} +1 -1
- package/POS/{chunk-DWAPC7QH.js → chunk-NPRF4WCF.js} +1 -1
- package/POS/{chunk-6SLEZOL6.js → chunk-OCJ63X2M.js} +1 -1
- package/POS/{chunk-HN2MBXIR.js → chunk-OFHBGUX5.js} +1 -1
- package/POS/{chunk-C7LTGPS6.js → chunk-OR72OB6Z.js} +1 -1
- package/POS/{chunk-Y7FTE6MJ.js → chunk-PAZ6GY6O.js} +1 -1
- package/POS/{chunk-NLEPFZIF.js → chunk-QDY5WFP2.js} +1 -1
- package/POS/{chunk-NT6YU3UY.js → chunk-RDBBCDMX.js} +1 -1
- package/POS/{chunk-HEQ4ULJC.js → chunk-U7R7Q5LB.js} +2 -2
- package/POS/{chunk-UHCJVRA2.js → chunk-UEDSO25C.js} +1 -1
- package/POS/{chunk-CIFYYCXG.js → chunk-VMW2VAVB.js} +1 -1
- package/POS/{chunk-4DA5TEPI.js → chunk-WJYDUALF.js} +1 -1
- package/POS/{chunk-XC333XHZ.js → chunk-WWBF4CFR.js} +1 -1
- package/POS/{chunk-WTMZ32O3.js → chunk-WYF3IJ4M.js} +1 -1
- package/POS/{chunk-3OD5QAWA.js → chunk-XJUR65C2.js} +1 -1
- package/POS/{chunk-Q7REEZ5O.js → chunk-ZA7IBPDE.js} +1 -1
- package/POS/{chunk-GIBKWHS5.js → chunk-ZPRT52I6.js} +1 -1
- package/POS/{chunk-M45XWUUS.js → chunk-ZQAJ3JGT.js} +1 -1
- package/POS/{chunk-WMVF5VPX.js → chunk-ZSKLJHKD.js} +1 -1
- package/POS/index.html +2 -2
- package/POS/{main-PGDB6QZN.js → main-TCNOMPUS.js} +2 -2
- package/package.json +1 -1
- package/POS/chunk-RCV74PPJ.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Fn}from"./chunk-TK5H65DN.js";import{b as Tt}from"./chunk-F6GAPEFT.js";import{a as ai}from"./chunk-6L6CIH5M.js";import{a as Jn}from"./chunk-JTIEIGAH.js";import{e as jn}from"./chunk-GOUID3CK.js";import{b as Gn}from"./chunk-EPRMV63Q.js";import{d as Un}from"./chunk-44EGYWOM.js";import{a as Hn}from"./chunk-3KRMLU6Y.js";import{a as ue,b as we,e as $n}from"./chunk-UNSCASKK.js";import{b as Ln}from"./chunk-THKVMHAC.js";import{a as kn,b as Wn,c as qn}from"./chunk-B73BPWFF.js";import{a as Vn}from"./chunk-LQDFXJL3.js";import{a as Kn}from"./chunk-7WQKC72Q.js";import{b as En,d as Rn,g as Nn}from"./chunk-62NIEYCN.js";import{d as ri}from"./chunk-SJAZWKD4.js";import{b as An}from"./chunk-NHTN2EUV.js";import{a as Qi}from"./chunk-ELFHCLTI.js";import{b as wn}from"./chunk-BUQWIDEH.js";import{a as ut}from"./chunk-FD7OC3LV.js";import{a as Cn}from"./chunk-5PKE5WBY.js";import{a as Bn}from"./chunk-SHZID3U7.js";import{o as _n}from"./chunk-7ADXBAZD.js";import{c as vn}from"./chunk-BV33OXYS.js";import{a as Qn}from"./chunk-NAMDTKS3.js";import{a as zn}from"./chunk-F46IEM3W.js";import{g as yn}from"./chunk-VHPQEU2H.js";import{a as Sn,b as pt}from"./chunk-VZAOS2Y6.js";import{A as xn,C as Je,G as In,H as Be,K as It,L as ve,M as ne,N as U,O as L,P as Te,S as Tn,i as Ce,j as bn,k as q,l as de,m as Ie,s as $,t as J,u as ii}from"./chunk-EDEWZ527.js";import{Aa as ei,Ba as xt}from"./chunk-2IGDDP6G.js";import{G as dt,O as oi,g as Pn,n as ni,o as On,q as Dn,u as Mn}from"./chunk-DK73RB3E.js";import{a as $e}from"./chunk-H777QSO4.js";import{a as sn,c as ln}from"./chunk-DXF4M3Z6.js";import{e as ti}from"./chunk-UXPWDNHV.js";import{a as te}from"./chunk-2FWFPV5I.js";import{C as hn,c as me,e as Zt,h as pe,i as cn,k as mn,l as Ue,n as Me,o as pn,r as mt,u as dn,v as un,x as gn,y as fn}from"./chunk-JLTWVSJC.js";import{a as g,d as Xt}from"./chunk-A63FOA5B.js";import{a as an}from"./chunk-RDT5WXH4.js";import{a as xe}from"./chunk-65NUOJSE.js";import{$b as P,Ab as a,Bb as s,Cb as b,Db as G,E as le,Eb as W,Fb as Wt,Gb as x,I as ke,Ic as We,Jb as S,L as rt,Lb as d,M as Ae,Od as rn,P as Pe,Pa as Ve,Qa as at,Qc as De,Ra as ji,Sc as ae,Tb as qt,Tc as se,Td as A,Ua as l,Ub as $t,Uc as Zi,Va as _,Vb as Jt,Vc as Xi,W as jt,Wc as en,Xc as tn,Yc as lt,Z as Qt,Zb as Q,_ as ie,_b as m,_c as ct,ac as O,ad as Y,b as Ht,ba as ce,bb as Fe,bc as zt,cc as Yi,d as be,da as Oe,dc as F,dd as qe,e as re,ec as H,fc as B,ha as M,hb as h,hc as Kt,ia as Ut,jc as R,k as it,ka as u,kc as Yt,la as ee,ld as nn,n as Ji,nb as p,o as Se,p as nt,pa as V,q as Bt,qa as Gt,r as Lt,rb as Ki,rc as y,sc as T,sd as on,t as z,tc as K,u as ot,uc as st,v as zi,vb as E,wa as C,wb as Ot,xa as v,xc as He,yb as Dt,zb as Mt}from"./chunk-EYRVHQXZ.js";var ze=class{constructor(t){this.roleService=t;t&&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;_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._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(t){this._CouponInputLock=t}get Retrieve(){return this._Retrieve}get DateEditor(){return this._DateEditor}set DateEditor(t){this._DateEditor=t}get NumberEditor(){return this._NumberEditor}set NumberEditor(t){this._NumberEditor=t}get PriceVisible(){return this._PriceVisible}get UnitPriceEditor(){return this._UnitPriceEditor}set UnitPriceEditor(t){this._UnitPriceEditor=t}get PricebookSelector(){return this._PricebookSelector}set PricebookSelector(t){this._PricebookSelector=t}get Cost(){return this._Cost}get Return(){return this._Return}set Return(t){this._Return=t}get Discount(){return this._Discount}set Discount(t){this._Discount=t}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(t){this._Tax=t}get DeleteItem(){return this._DeleteItem}get BundlingPrice(){return this._BundlingPrice}get Email(){return this._EmailRestriction}get ParkedDeletionAuthorized(){return this._ParkedDeletionAuthorized}set ParkedDeletionAuthorized(t){this._ParkedDeletionAuthorized=t}get SellEditor(){return this._SellEditor}get ContactsCreate(){return this._ContactCreate}get PrepaidPackageCreate(){return this._PrepaidPackageCreate}get Order(){return this._Order}get Reprint(){return this._Reprint}get Contacts(){return this._Contacts}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 si=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 gt=class o{constructor(t,e,i,n){this.httpService=t;this._localDataService=e;this._onlineStatusService=i;this._toastrService=n;this._onlineStatusService.getOnlineStatus$().subscribe(r=>{this.isOnline=r})}_Data=new re(null);Data$=this._Data.pipe(Pe(),le(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(z(()=>this.generateCompleteData(i)));this._toastrService.warning("Offline order is not Supported!","Info!")}uploadOfflineOrder(t){return this._localDataService.uploadSingleOrder(t).pipe(ke(e=>e?.message?.includes("objectStore does not exists")?this.submitOnline(t):nt(()=>e)))}submitOnline(t){return this.httpService.post(L.SubmitOrder,t,an.pos.submitOrderTimeout)}handleTimeOutError(t){return Ht(ke(e=>{if(e instanceof Lt||e?.name=="TimeoutError"){let i=this.generateCompleteData(t);this.pushNewValue(i)}throw e}))}generatePOSDataForSubmission(t,e=!0){let i=Object.assign(new ne,t);i.Items=[],i.Order.CustomerID==null&&(i.Order.CustomerID=g.GuidEmpty),i.Order.SalesID==null&&(i.Order.SalesID=g.GuidEmpty);let n=1;i.Payments=i.Payments.map(c=>(c.Date=i.Order.Date,c.Index=n,n++,delete c.TypeID,c));let r=1;for(let c of i.CartItems){let f=new In;f.ID=c.ID,f.VariantID=c.VariantID,f.Quantity=c.Quantity,f.Cost=c.Cost,f.Price=c.Price,f.Discount=c.Discount,f.DiscountAmount=c.DiscountAmount,f.Note=c.Note,f.Taxable=c.Variant.Taxable,f.LoyaltyPoint=c.LoyaltyPoint,f.UnitCost=c.Cost,f.UnitPrice=c.Price,f.UnitPriceOriginal=c.UnitPriceOriginal,f.UnitExpense=c.UnitExpense,f.EntityID=c.EntityID,f.Index=r,f.UnitQuantity=c.UnitQuantity,f.PriceTypeID=c.PriceTypeID,f.PriceNote=c.PriceNote,f.Splited=c.SplitQuantity>0,f.SplitQuantity=c.SplitQuantity,f.InventoryTypeID=c.Variant.TypeID,f.SalesID="",f.Serial=c.Serial,c.SalesID&&(f.SalesID=c.SalesID),delete c.CouponDiscount,i.Items.push(f),r++}return e?(delete i.CartItems,delete i.Order.ClientTimestamp):i.Order.ClientTimestamp=new Date,i}generateCompleteData(t){let e=new si;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(L.ReturInvoice,[{key:"EntityID",value:e},{key:"Number",value:t}])}GetInvoiceBySoID(t){return this.httpService.get(L.GetPOSDataByID,[{key:"ID",value:t}])}UploadCSV(t,e){let i={CartItems:t,EntityID:e};return this.httpService.post(L.UploadCsv,i)}sendEmail(t,e){return new Promise((i,n)=>{this._localDataService.isProductFromServer().subscribe(r=>{if(r){let c={invoiceID:e,email:t};this.httpService.post(L.SendInvoiceEmail,c).subscribe({next:f=>{i(f)},error:f=>{n(f)}})}else n(U.wrongOfflineAction)})})}sendWhatsaap(t,e){let i={InvoiceID:t,PhoneNumber:e};return this.httpService.post(L.SendInvoiceWhatsapp,i)}createCustomerByInvoice(t,e){let i={InvoiceID:t,Mobile:e};return this.httpService.post(L.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(L.InvoiceA4,e)}getVacant(t){return this.httpService.get(L.GetVacant,[{key:"EntityID",value:t}])}static \u0275fac=function(e){return new(e||o)(u(xe),u(Te),u(ue),u(A))};static \u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"})};var j=class o{constructor(t,e,i){this._localDataService=t;this._onlineStatusService=e;this._httpService=i;this._onlineStatusService.getOnlineStatus$().subscribe(n=>{this.isOnline=n})}_Data=new re(null);Data$=this._Data.asObservable().pipe(le(t=>t!==null),Pe());isOnline;get Data(){return this._Data.value}pushNewValue(t){this._Data.next(t)}requestObservable(){return this.isOnline?this._httpService.get(L.GetPOSStorage).pipe(z(t=>({data:t,type:"Online"}))):this._localDataService.getPOSStorage().pipe(le(t=>t!=null),z(t=>({data:t,type:"Offline"})))}getOutletName(t){return this.Data.Entities.find(i=>i.ID==t)?.Name}static \u0275fac=function(e){return new(e||o)(u(Te),u(ue),u(xe))};static \u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"})};var Ne=class o{constructor(t){this.roleService=t;this.pushNewValue(new ze(t))}_Data=new re(new ze(null));get Data(){return this._Data.value}Data$=this._Data.asObservable();pushNewValue(t){this._Data.next(t)}static \u0275fac=function(e){return new(e||o)(u(Xt))};static \u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"})};var Nt=class{ID;Code;EntityID;Name;Description;Start;StartDisplay;State;Open;CashierID;OpeningCash;EntityName;LoginID;Active;CustomerDisplayEnabled;OvoConfigurationID;CustomerDisplayID;ListImage;Suspended};var mo=o=>({active:o}),po=o=>({gray:o});function uo(o,t){if(o&1){let e=x();a(0,"span",17),S("click",function(n){C(e);let r=d().$implicit;return d().closeRegister(r),v(n.stopPropagation())}),s()}}function go(o,t){o&1&&(a(0,"div")(1,"span",18),m(2,"VACANT"),s()())}function fo(o,t){if(o&1&&(a(0,"div")(1,"span",19),b(2,"i",20),a(3,"font"),m(4),s()(),a(5,"span",21),b(6,"i",22),a(7,"font"),m(8),s()()()),o&2){let e=d().$implicit;l(4),P(e.LoginID),l(4),O("",e.StartDisplay.split(" ")[3]," - Now")}}function ho(o,t){if(o&1){let e=x();a(0,"div",9)(1,"div",10)(2,"div",11)(3,"h5",12),S("click",function(){let n=C(e).$implicit,r=d();return v(r.select(n))}),a(4,"span"),b(5,"i",13),m(6),y(7,"limitTo"),s(),h(8,uo,1,0,"span",14),s(),a(9,"div",15),S("click",function(){let n=C(e).$implicit,r=d();return v(r.select(n))}),h(10,go,3,0,"div",16)(11,fo,9,2,"div",16),s()()()()}if(o&2){let e=t.$implicit,i=d();l(),p("ngClass",e.Active?"active":""),l(),p("ngClass",R(11,mo,(e==null?null:e.ID)==(i.selectedRegister==null?null:i.selectedRegister.ID))),l(),p("ngClass",R(13,po,e!=i.selectedRegister)),l(3),P(K(7,8,e.Name,15)),l(2),p("ngIf",e.State!="Close"),l(),p("ngSwitch",e.State),l(),p("ngSwitchCase","Close"),l(),p("ngSwitchCase","Open")}}var li=class o{constructor(t,e,i,n,r){this._dialogRef=t;this._outletService=e;this._posService=i;this._userRoleService=n;this.router=r}registers;searchInput="";selectedRegister=new Nt;modalConfig=new $;role;get AppConfigJSON(){return this._posService.Data.AppConfigJSON}destroy$=new be;ngOnInit(){this.subscribeToObsChanges(),this.initModalConfig()}subscribeToObsChanges(){this._posService.Data$.pipe(ce(this.destroy$)).subscribe(t=>{this.registers=t.Registers}),this._outletService.Data$.pipe(ce(this.destroy$)).subscribe(t=>{this.selectedRegister=this.findOutletRegisterById(t.RegisterID)}),this._userRoleService.Data$.pipe(ce(this.destroy$)).subscribe(t=>{this.role=t})}findOutletRegisterById(t){let e=this.registers.find(i=>i.ID===t);return e||new Nt}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(this.selectedRegister)}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 Fn}from"./chunk-TK5H65DN.js";import{b as Tt}from"./chunk-F6GAPEFT.js";import{a as ai}from"./chunk-6L6CIH5M.js";import{a as Jn}from"./chunk-JTIEIGAH.js";import{e as jn}from"./chunk-GOUID3CK.js";import{b as Gn}from"./chunk-EPRMV63Q.js";import{d as Un}from"./chunk-44EGYWOM.js";import{a as Hn}from"./chunk-3KRMLU6Y.js";import{a as ue,b as we,e as $n}from"./chunk-UNSCASKK.js";import{b as Ln}from"./chunk-THKVMHAC.js";import{a as kn,b as Wn,c as qn}from"./chunk-B73BPWFF.js";import{a as Vn}from"./chunk-LQDFXJL3.js";import{a as Kn}from"./chunk-7WQKC72Q.js";import{b as En,d as Rn,g as Nn}from"./chunk-62NIEYCN.js";import{d as ri}from"./chunk-SJAZWKD4.js";import{b as An}from"./chunk-NHTN2EUV.js";import{a as Qi}from"./chunk-ELFHCLTI.js";import{b as wn}from"./chunk-BUQWIDEH.js";import{a as ut}from"./chunk-FD7OC3LV.js";import{a as Cn}from"./chunk-5PKE5WBY.js";import{a as Bn}from"./chunk-SHZID3U7.js";import{o as _n}from"./chunk-7ADXBAZD.js";import{c as vn}from"./chunk-BV33OXYS.js";import{a as Qn}from"./chunk-NAMDTKS3.js";import{a as zn}from"./chunk-F46IEM3W.js";import{g as yn}from"./chunk-VHPQEU2H.js";import{a as Sn,b as pt}from"./chunk-VZAOS2Y6.js";import{A as xn,C as Je,G as In,H as Be,K as It,L as ve,M as ne,N as U,O as L,P as Te,S as Tn,i as Ce,j as bn,k as q,l as de,m as Ie,s as $,t as J,u as ii}from"./chunk-EDEWZ527.js";import{Aa as ei,Ba as xt}from"./chunk-2IGDDP6G.js";import{G as dt,O as oi,g as Pn,n as ni,o as On,q as Dn,u as Mn}from"./chunk-DK73RB3E.js";import{a as $e}from"./chunk-H777QSO4.js";import{a as sn,c as ln}from"./chunk-DXF4M3Z6.js";import{e as ti}from"./chunk-UXPWDNHV.js";import{a as te}from"./chunk-2FWFPV5I.js";import{C as hn,c as me,e as Zt,h as pe,i as cn,k as mn,l as Ue,n as Me,o as pn,r as mt,u as dn,v as un,x as gn,y as fn}from"./chunk-JLTWVSJC.js";import{a as g,d as Xt}from"./chunk-A63FOA5B.js";import{a as an}from"./chunk-KC5ANQG4.js";import{a as xe}from"./chunk-65NUOJSE.js";import{$b as P,Ab as a,Bb as s,Cb as b,Db as G,E as le,Eb as W,Fb as Wt,Gb as x,I as ke,Ic as We,Jb as S,L as rt,Lb as d,M as Ae,Od as rn,P as Pe,Pa as Ve,Qa as at,Qc as De,Ra as ji,Sc as ae,Tb as qt,Tc as se,Td as A,Ua as l,Ub as $t,Uc as Zi,Va as _,Vb as Jt,Vc as Xi,W as jt,Wc as en,Xc as tn,Yc as lt,Z as Qt,Zb as Q,_ as ie,_b as m,_c as ct,ac as O,ad as Y,b as Ht,ba as ce,bb as Fe,bc as zt,cc as Yi,d as be,da as Oe,dc as F,dd as qe,e as re,ec as H,fc as B,ha as M,hb as h,hc as Kt,ia as Ut,jc as R,k as it,ka as u,kc as Yt,la as ee,ld as nn,n as Ji,nb as p,o as Se,p as nt,pa as V,q as Bt,qa as Gt,r as Lt,rb as Ki,rc as y,sc as T,sd as on,t as z,tc as K,u as ot,uc as st,v as zi,vb as E,wa as C,wb as Ot,xa as v,xc as He,yb as Dt,zb as Mt}from"./chunk-EYRVHQXZ.js";var ze=class{constructor(t){this.roleService=t;t&&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;_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._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(t){this._CouponInputLock=t}get Retrieve(){return this._Retrieve}get DateEditor(){return this._DateEditor}set DateEditor(t){this._DateEditor=t}get NumberEditor(){return this._NumberEditor}set NumberEditor(t){this._NumberEditor=t}get PriceVisible(){return this._PriceVisible}get UnitPriceEditor(){return this._UnitPriceEditor}set UnitPriceEditor(t){this._UnitPriceEditor=t}get PricebookSelector(){return this._PricebookSelector}set PricebookSelector(t){this._PricebookSelector=t}get Cost(){return this._Cost}get Return(){return this._Return}set Return(t){this._Return=t}get Discount(){return this._Discount}set Discount(t){this._Discount=t}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(t){this._Tax=t}get DeleteItem(){return this._DeleteItem}get BundlingPrice(){return this._BundlingPrice}get Email(){return this._EmailRestriction}get ParkedDeletionAuthorized(){return this._ParkedDeletionAuthorized}set ParkedDeletionAuthorized(t){this._ParkedDeletionAuthorized=t}get SellEditor(){return this._SellEditor}get ContactsCreate(){return this._ContactCreate}get PrepaidPackageCreate(){return this._PrepaidPackageCreate}get Order(){return this._Order}get Reprint(){return this._Reprint}get Contacts(){return this._Contacts}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 si=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 gt=class o{constructor(t,e,i,n){this.httpService=t;this._localDataService=e;this._onlineStatusService=i;this._toastrService=n;this._onlineStatusService.getOnlineStatus$().subscribe(r=>{this.isOnline=r})}_Data=new re(null);Data$=this._Data.pipe(Pe(),le(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(z(()=>this.generateCompleteData(i)));this._toastrService.warning("Offline order is not Supported!","Info!")}uploadOfflineOrder(t){return this._localDataService.uploadSingleOrder(t).pipe(ke(e=>e?.message?.includes("objectStore does not exists")?this.submitOnline(t):nt(()=>e)))}submitOnline(t){return this.httpService.post(L.SubmitOrder,t,an.pos.submitOrderTimeout)}handleTimeOutError(t){return Ht(ke(e=>{if(e instanceof Lt||e?.name=="TimeoutError"){let i=this.generateCompleteData(t);this.pushNewValue(i)}throw e}))}generatePOSDataForSubmission(t,e=!0){let i=Object.assign(new ne,t);i.Items=[],i.Order.CustomerID==null&&(i.Order.CustomerID=g.GuidEmpty),i.Order.SalesID==null&&(i.Order.SalesID=g.GuidEmpty);let n=1;i.Payments=i.Payments.map(c=>(c.Date=i.Order.Date,c.Index=n,n++,delete c.TypeID,c));let r=1;for(let c of i.CartItems){let f=new In;f.ID=c.ID,f.VariantID=c.VariantID,f.Quantity=c.Quantity,f.Cost=c.Cost,f.Price=c.Price,f.Discount=c.Discount,f.DiscountAmount=c.DiscountAmount,f.Note=c.Note,f.Taxable=c.Variant.Taxable,f.LoyaltyPoint=c.LoyaltyPoint,f.UnitCost=c.Cost,f.UnitPrice=c.Price,f.UnitPriceOriginal=c.UnitPriceOriginal,f.UnitExpense=c.UnitExpense,f.EntityID=c.EntityID,f.Index=r,f.UnitQuantity=c.UnitQuantity,f.PriceTypeID=c.PriceTypeID,f.PriceNote=c.PriceNote,f.Splited=c.SplitQuantity>0,f.SplitQuantity=c.SplitQuantity,f.InventoryTypeID=c.Variant.TypeID,f.SalesID="",f.Serial=c.Serial,c.SalesID&&(f.SalesID=c.SalesID),delete c.CouponDiscount,i.Items.push(f),r++}return e?(delete i.CartItems,delete i.Order.ClientTimestamp):i.Order.ClientTimestamp=new Date,i}generateCompleteData(t){let e=new si;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(L.ReturInvoice,[{key:"EntityID",value:e},{key:"Number",value:t}])}GetInvoiceBySoID(t){return this.httpService.get(L.GetPOSDataByID,[{key:"ID",value:t}])}UploadCSV(t,e){let i={CartItems:t,EntityID:e};return this.httpService.post(L.UploadCsv,i)}sendEmail(t,e){return new Promise((i,n)=>{this._localDataService.isProductFromServer().subscribe(r=>{if(r){let c={invoiceID:e,email:t};this.httpService.post(L.SendInvoiceEmail,c).subscribe({next:f=>{i(f)},error:f=>{n(f)}})}else n(U.wrongOfflineAction)})})}sendWhatsaap(t,e){let i={InvoiceID:t,PhoneNumber:e};return this.httpService.post(L.SendInvoiceWhatsapp,i)}createCustomerByInvoice(t,e){let i={InvoiceID:t,Mobile:e};return this.httpService.post(L.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(L.InvoiceA4,e)}getVacant(t){return this.httpService.get(L.GetVacant,[{key:"EntityID",value:t}])}static \u0275fac=function(e){return new(e||o)(u(xe),u(Te),u(ue),u(A))};static \u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"})};var j=class o{constructor(t,e,i){this._localDataService=t;this._onlineStatusService=e;this._httpService=i;this._onlineStatusService.getOnlineStatus$().subscribe(n=>{this.isOnline=n})}_Data=new re(null);Data$=this._Data.asObservable().pipe(le(t=>t!==null),Pe());isOnline;get Data(){return this._Data.value}pushNewValue(t){this._Data.next(t)}requestObservable(){return this.isOnline?this._httpService.get(L.GetPOSStorage).pipe(z(t=>({data:t,type:"Online"}))):this._localDataService.getPOSStorage().pipe(le(t=>t!=null),z(t=>({data:t,type:"Offline"})))}getOutletName(t){return this.Data.Entities.find(i=>i.ID==t)?.Name}static \u0275fac=function(e){return new(e||o)(u(Te),u(ue),u(xe))};static \u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"})};var Ne=class o{constructor(t){this.roleService=t;this.pushNewValue(new ze(t))}_Data=new re(new ze(null));get Data(){return this._Data.value}Data$=this._Data.asObservable();pushNewValue(t){this._Data.next(t)}static \u0275fac=function(e){return new(e||o)(u(Xt))};static \u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"})};var Nt=class{ID;Code;EntityID;Name;Description;Start;StartDisplay;State;Open;CashierID;OpeningCash;EntityName;LoginID;Active;CustomerDisplayEnabled;OvoConfigurationID;CustomerDisplayID;ListImage;Suspended};var mo=o=>({active:o}),po=o=>({gray:o});function uo(o,t){if(o&1){let e=x();a(0,"span",17),S("click",function(n){C(e);let r=d().$implicit;return d().closeRegister(r),v(n.stopPropagation())}),s()}}function go(o,t){o&1&&(a(0,"div")(1,"span",18),m(2,"VACANT"),s()())}function fo(o,t){if(o&1&&(a(0,"div")(1,"span",19),b(2,"i",20),a(3,"font"),m(4),s()(),a(5,"span",21),b(6,"i",22),a(7,"font"),m(8),s()()()),o&2){let e=d().$implicit;l(4),P(e.LoginID),l(4),O("",e.StartDisplay.split(" ")[3]," - Now")}}function ho(o,t){if(o&1){let e=x();a(0,"div",9)(1,"div",10)(2,"div",11)(3,"h5",12),S("click",function(){let n=C(e).$implicit,r=d();return v(r.select(n))}),a(4,"span"),b(5,"i",13),m(6),y(7,"limitTo"),s(),h(8,uo,1,0,"span",14),s(),a(9,"div",15),S("click",function(){let n=C(e).$implicit,r=d();return v(r.select(n))}),h(10,go,3,0,"div",16)(11,fo,9,2,"div",16),s()()()()}if(o&2){let e=t.$implicit,i=d();l(),p("ngClass",e.Active?"active":""),l(),p("ngClass",R(11,mo,(e==null?null:e.ID)==(i.selectedRegister==null?null:i.selectedRegister.ID))),l(),p("ngClass",R(13,po,e!=i.selectedRegister)),l(3),P(K(7,8,e.Name,15)),l(2),p("ngIf",e.State!="Close"),l(),p("ngSwitch",e.State),l(),p("ngSwitchCase","Close"),l(),p("ngSwitchCase","Open")}}var li=class o{constructor(t,e,i,n,r){this._dialogRef=t;this._outletService=e;this._posService=i;this._userRoleService=n;this.router=r}registers;searchInput="";selectedRegister=new Nt;modalConfig=new $;role;get AppConfigJSON(){return this._posService.Data.AppConfigJSON}destroy$=new be;ngOnInit(){this.subscribeToObsChanges(),this.initModalConfig()}subscribeToObsChanges(){this._posService.Data$.pipe(ce(this.destroy$)).subscribe(t=>{this.registers=t.Registers}),this._outletService.Data$.pipe(ce(this.destroy$)).subscribe(t=>{this.selectedRegister=this.findOutletRegisterById(t.RegisterID)}),this._userRoleService.Data$.pipe(ce(this.destroy$)).subscribe(t=>{this.role=t})}findOutletRegisterById(t){let e=this.registers.find(i=>i.ID===t);return e||new Nt}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(this.selectedRegister)}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.close(),this.router.navigate(["menu/Shift/Main/My_Shift"],{queryParams:{RegisterID:t.ID}}));else if(!t.Open||this.selectedRegister.ID==t.ID)this.selectedRegister=t;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.close(),this.router.navigate(["/menu/Shift/Main/My_Shift"],{queryParams:{RegisterID:t.ID}})}else this.selectedRegister=t}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.close()}static \u0275fac=function(e){return new(e||o)(_(q),_(Z),_(j),_(Ne),_(rn))};static \u0275cmp=V({type:o,selectors:[["pos-modal-register"]],decls:12,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(e,i){e&1&&(a(0,"modal-material",0),S("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),b(5,"i",4),s(),a(6,"input",5),B("ngModelChange",function(r){return H(i.searchInput,r)||(i.searchInput=r),r}),s()()(),a(7,"div",6)(8,"div",7),h(9,ho,12,15,"div",8),y(10,"FilterByName"),s()()(),b(11,"footer"),s()),e&2&&(p("config",i.modalConfig),l(2),p("hidden",i.registers.length<=6),l(4),F("ngModel",i.searchInput),l(3),p("ngForOf",K(10,4,i.registers,i.searchInput)))},dependencies:[De,ae,se,Zi,Xi,me,pe,Me,J,ni,Mn],styles:[".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}.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 Co=["inputCash"],ci=class o{constructor(t,e){this.dialogRef=t;this.data=e;this.generateModalTitle$.subscribe()}registerService=ee(Z);loadPOSService=ee(j);register=this.registerService.Data;username=this.loadPOSService?.Data?.UserName;amount=Fe(0);config=new $;currentRegisterName;generateModalTitle$=this.registerService.Data$.pipe(le(t=>g.IsNotEmpty(t)),Oe(()=>{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}),Ce());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(e){return new(e||o)(_(q),_(de))};static \u0275cmp=V({type:o,selectors:[["POS-modal-opening-cash"]],viewQuery:function(e,i){if(e&1&&qt(Co,5),e&2){let n;$t(n=Jt())&&(i.inputCashEl=n.first)}},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 n=x();a(0,"modal-material",1),S("onOk",function(){return C(n),v(i.onOk())})("onCancel",function(){return C(n),v(i.dialogRef.close())})("onClose",function(){return C(n),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),B("ngModelChange",function(c){return C(n),H(i.amount,c)||(i.amount=c),v(c)}),s()()()()()()}e&2&&(p("config",i.config),l(7),P(i.currentRegisterName),l(5),P(i.username),l(5),P(K(18,5,i.today,"EEEE, HH:mm")),l(6),F("ngModel",i.amount))},dependencies:[me,pe,Me,J,pt,ct],styles:[".table-title-width[_ngcontent-%COMP%]{width:120px}"]})};var mi=class{OrderNumberElement;InvoiceNumberElement;NewOrderID};var ht=class o{constructor(t,e,i){this._httpService=t;this._onlineStatusService=e;this._localDataService=i;this._onlineStatusService.getOnlineStatus$().subscribe(n=>{this.isOnline=n})}isOnline;GenerateNumber(t,e){if(this.isOnline)return this._httpService.get(L.GenerateNumber,[{key:"EntityID",value:t},{key:"TypeID",value:1}]);{let i=new mi;return g.IsNotEmpty(e.NumberElement)&&(e.NumberElement.Seed+=1),g.IsNotEmpty(e.InvoiceNumberElement)&&(e.InvoiceNumberElement.Seed+=1),i.InvoiceNumberElement=e.InvoiceNumberElement,i.OrderNumberElement=e.NumberElement,i.NewOrderID=g.Guid_NewGuid(),Se(i)}}findRegisterById(t){return new Promise(e=>{this._localDataService.isConfigFromServer().subscribe(i=>{i?this._httpService.get(L.GetRegisterInfo,[{key:"RegisterID",value:t}]).subscribe(n=>{e(n)}):this._localDataService.findRegisterByID(t).subscribe(n=>{e(n)})})})}recordOpeningCash(t){return Bt(this._httpService.post("/API/POS/RecordOpeningCash",t))}static \u0275fac=function(e){return new(e||o)(u(xe),u(ue),u(Te))};static \u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"})};var Z=class o{constructor(t,e,i,n,r){this._signalRClientService=t;this._matDialog=e;this._posHttpResponseService=i;this._CoreHttpService=n;this._toastrService=r}_Data=new re(null);Data$=this._Data.asObservable().pipe(le(t=>t!==null),Pe());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 n=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.Data?this.Data.RegisterID:null;g.IsEmpty(c)?this.openChooseRegisterModal():n&&this.openChooseRegisterModal()}}t.length==1&&(this.pushNewRegister(t[0]),g.IsEmpty(t[0].LoginID)&&g.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(li,{id:"registerModal",disableClose:!0}).afterClosed().pipe(le(t=>g.IsNotEmpty(t))).subscribe(t=>{t&&this.openOpeningCashModal(t.ID)})}openOpeningCashModal(t){this._posHttpResponseService.Data.AppConfigJSON.ModuleShift.Closure.Enabled&&this._matDialog.open(ci,{disableClose:!0}).afterClosed().pipe(le(n=>g.IsNotEmpty(n))).subscribe(n=>{let r={RegisterID:t,OpAmount:n.amount};this._CoreHttpService.recordOpeningCash(r)})}pushNewRegister(t){let e=this._Data.value,i=e?e.RegisterID:null;i!=t.ID&&this._CoreHttpService.findRegisterById(t.ID).then(n=>{n.RegisterCode=t.Code,n.DefaultPrintTemplate=n.PrintTemplate,this._signalRClientService.SubscribeGroup(n.RegisterID,i),this.pushNewValue(n)})}getOutletRegister(){let t=this.Data.RegisterID;return this._posHttpResponseService.Data.Registers.find(n=>n.ID==t)}pushNewValue(t){this._Data.next(t)}findOutletRegisterById(t){return this._posHttpResponseService.Data.Registers.find(n=>n.ID===t)}static \u0275fac=function(e){return new(e||o)(u($e),u(Ie),u(j),u(ht),u(A))};static \u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"})};var pi=class{RegisterID;Number;Amount;TransactionID};var et=class{GroupID;Method;Data};var di=class{Status;InvoiceID;LoyaltyPoint;diff};var ui=class{GopayQr};var kt=(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))(kt||{});var N=class o{constructor(t,e,i){this._OrderHttpService=t;this._customerHttpService=e;this._toastrService=i}_Data=new re(new ne);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:n=>{e(n)},error:n=>{this.Data.Items=[],i(n)}})})}uploadOfflineOrder(){return this.checkTransactionId(),this._OrderHttpService.uploadOfflineOrder(this.Data)}checkTransactionId(){let e=this.Data.Payments.find(i=>i.TypeID==3);g.IsNotEmpty(e)&&g.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:n=>{this._customerHttpService.Data=n,this.pushNewValue(this.Data),e(n)},error:n=>{this.Data.Order.CustomerID=null,this.Data.ContactName=null,i(n)}})})}static \u0275fac=function(e){return new(e||o)(u(gt),u(we),u(A))};static \u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"})};var gi=class{Name;Quantity;Discount;DiscountAmount;Price;UnitQuantity};var fi=class{Items;AmountSummary;GopayQr;Number;Customer;SalesName;CurrencySymbol;FinalAmount};var hi=class o{_state=Fe(this.initCustomerDisplayState());isEnabled=We(()=>this._state()?.enabled);connect(){let e={enabled:!0,timestamp:new Date().toDateString()};localStorage.setItem("customerDisplay",JSON.stringify(e)),this._state.set(e)}initCustomerDisplayState(){let t=localStorage.getItem("customerDisplay"),e={enabled:!1,timestamp:""};return g.IsNotEmpty(t)&&(e=JSON.parse(t)),e}disconnect(){let e={enabled:!1,timestamp:new Date().toDateString()};localStorage.setItem("customerDisplay",JSON.stringify(e)),this._state.set(e)}static \u0275fac=function(e){return new(e||o)};static \u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"})};var oe=class{Amount;CurrencySymbol;Label;Type;constructor(t,e,i,n){this.Amount=t,this.CurrencySymbol=e,this.Label=i,this.Type=n}};var Ke=class{ModuleSell;ApplicationLoyalty;ApplicationMath;CoreDefaults;ModuleDelivery;ApplicationParkAndRetrieve;ApplicationRegisterClosure;PaymentConfigGopay;PaymentConfigLink;PrintConfigInvoice;CorePrint;PaymentConfigEmpatKali;ApplicationSettings;PrintConfigGeneral;ModuleProducts;ModuleContact;ApplicationTransactionNumbering;ModuleOrders;ModuleShift;ModuleBuy;ModuleAdjustment;AddOnsKitchenDisplay;TadaCouponVisible;CouponRedemptionType};var X=class o{constructor(t,e,i,n){this._orderDataService=t;this._posService=e;this.POSMATH=i;this.decimalPipe=n;this._orderDataService.Data$.pipe(ie(r=>this._posService.Data$.pipe(z(c=>({appConfig:c.AppConfigJSON,salesOrder:r}))))).subscribe(r=>{this.salesOrderData=r.salesOrder,this.appConfigJSON=r.appConfig,this.calculateDiscountAmount(),this.pushNewValue(this.grandTotal)})}_Data=new re(0);Data$=this._Data.asObservable().pipe(Pe());tax=new Fn;discountAfterTax=0;currencySymbol="Rp";get Data(){return this._Data.value}salesOrderData=new ne;appConfigJSON=new Ke;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,n=this.GrossTotalTaxable;return this.tax.CalculationTypeID==1?t=this.tax.Rate/(100+this.tax.Rate)*n:t=this.tax.Rate/100*n,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,n=0,r=0,c=0,f=0;for(let D of t)n=D.getItemAfterDiscount/e,r=n*i,f=r*D.Quantity,c+=f;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((n,r)=>n+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}static \u0275fac=function(e){return new(e||o)(u(N),u(j),u(Hn),u(Y))};static \u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"})};var Ci=class o{constructor(t,e,i,n){this._invoiceCalculatorService=t;this._decimalPipe=e;this._poshttpResponseService=i;this._orderService=n;this._poshttpResponseService.Data$.pipe(Ce()).subscribe(r=>{this.appConfig=r.AppConfigJSON})}appConfig=new Ke;generateAmountSummary(){let t=[];this.isUseTax()?t=this.generateSummaryTax():t=this.generateSummaryNonTax();let e=this.generateSurchargeSummary();return e&&t.push(...e),t}generateSummaryTax(){let t=this._invoiceCalculatorService.tax?.CalculationTypeID,e=[];return t==1?e=this.generateSummaryTaxInclude():e=this.generateSummaryTaxExclude(),e}generateSummaryNonTax(){let t=[],e=this.generateCartItemAmount();if(t.push(e),this.isDiscounted()){let i=this.generateDiscountSummary(),n=this.generateAmountTotal("Total");t.push(...i,n)}return t}generateSummaryTaxInclude(){let t=[];return this.isTaxReserveSequence()?t=this.generateTaxIncludeReserveSequence():t=this.generateTaxIncludeNormalSequence(),t}generateTaxIncludeReserveSequence(){let t=[];if(this.isTaxDetailVisible()==!1){let r=this._invoiceCalculatorService.TotalBeforeTax,c=this.isDiscounted()?"Amount":"Before Tax",f=this.isDiscounted()?this._invoiceCalculatorService.GrossTotal:r,D=new oe(f,this.currencySymbol,c,2);t.push(D)}if(this.isDiscounted()){let r=this.generateDiscountSummary(),c=this.generateBeforeTaxSummary();t.push(...r,c)}let i=this.generateTax(),n=this.generateAmountTotal();return t.push(...i,n),t}generateTaxIncludeNormalSequence(){let t=[],e=this.generateCartItemAmount();if(t.push(e),this.isDiscounted()){let n=this.generateDiscountSummary(),r=this.generateSummarySubTotal();t.push(...n,r)}let i=this.generateTax();if(t.push(...i),this.isTaxDetailVisible()==!1){let n=this.generateBeforeTaxSummary();t.push(n)}return t}generateSummaryTaxExclude(){let t=[],e=this.generateCartItemAmount(!0);if(t.push(e),this.isDiscounted()){let c=this.generateDiscountSummary(),f=this.generateSummarySubTotal();t.push(...c,f)}let i=this.generateTax(),n=this._invoiceCalculatorService.TotalAfterTax,r=new oe(n,this.currencySymbol,"Total",1);return t.push(...i,r),t}generateAmountTotal(t="Total Amount"){let e=this._invoiceCalculatorService.Data;return new oe(e,this.currencySymbol,t,1)}generateSummarySubTotal(){let t=this._invoiceCalculatorService.TotalAfterTax;return new oe(t,this.currencySymbol,"SubTotal",1)}generateBeforeTaxSummary(){let t=this._invoiceCalculatorService.TotalBeforeTax;return new oe(t,this.currencySymbol,"Before Tax",2)}isTaxDetailVisible(){return this.appConfig.PrintConfigInvoice?.Footer?.TaxDetailVisible}isUseTax(){let t=this._invoiceCalculatorService.tax;return t?.PrintVisible&&t?.Rate!=0}generateTax(){let t=[],e=this.isTaxDetailVisible(),i=e?2:1,n=this._invoiceCalculatorService.tax;if(e){let r=this.appConfig.PrintConfigInvoice.Footer.TaxableSales,c=this.calculateTaxableSales(),f=new oe(c,this.currencySymbol,r,i);t.push(f)}if(n.TypeID==2){let r=this.generateTaxTypeMultiple();t.push(...r)}else{let r=this.generateSingleTaxSummary(n.Label,this._invoiceCalculatorService.TaxAmount,i);t.push(r)}if(e){let r=this.appConfig.PrintConfigInvoice.Footer.TaxExemptSales,c=this._invoiceCalculatorService.GrossTotalNonTaxable,f=new oe(c,this.currencySymbol,r,i);t.push(f);let D=this.appConfig.PrintConfigInvoice.Footer.LabelWithZeroAmount;if(D){let I=new oe(0,this.currencySymbol,D,i);t.push(I)}}return t}generateCartItemAmount(t=!1){let e=this.isDiscounted()||t?this._invoiceCalculatorService.GrossTotal:this._invoiceCalculatorService.TotalAfterTax;return new oe(e,this.currencySymbol,"Amount",1)}get currencySymbol(){return this._invoiceCalculatorService.currencySymbol}generateDiscountSummary(){let t=[];if(this._invoiceCalculatorService.Discount1Amount!=0){let e=this._decimalPipe.transform(this._orderService.Data.Order.Discount),n=this.checkDiscountIgnoreDecimal(e)?"{0}":"{0} ({1}%)";t.push(new oe(this._invoiceCalculatorService.Discount1Amount*-1,this._invoiceCalculatorService.currencySymbol,g.StringFormat(n,this.appConfig.CorePrint.Alias.Discount1,e),1))}if(this._invoiceCalculatorService.Discount2Amount!=0){let e=this._decimalPipe.transform(this._orderService.Data.Order.Discount2),n=this.checkDiscountIgnoreDecimal(e)?"{0}":"{0} ({1}%)";t.push(new oe(this._invoiceCalculatorService.Discount2Amount*-1,this._invoiceCalculatorService.currencySymbol,g.StringFormat(n,this.appConfig.CorePrint.Alias.Discount2,e),1))}return this._orderService.Data.Order.DiscountAmount!=0&&this.appConfig.PrintConfigInvoice.ItemsFooter.DiscountAmountVisible&&t.push(new oe(this._orderService.Data.Order.DiscountAmount*-1,this._invoiceCalculatorService.currencySymbol,"Discount ("+this._invoiceCalculatorService.currencySymbol+")",1)),t}calculateTaxableSales(){let t=this._invoiceCalculatorService.tax,e=this._invoiceCalculatorService.TaxAmount,i=this._invoiceCalculatorService.GrossTotalTaxable;return t.Rate==0?0:t.CalculationTypeID==1?i-e:i}generateTaxTypeMultiple(){let t=this.appConfig.PrintConfigInvoice.Footer.TaxDetailVisible?2:1,e=[],i=this._invoiceCalculatorService.tax;var n=this._invoiceCalculatorService.TaxAmount;if(i.TypeID==2){let r=i?.Components?i?.Components:[],c=this._invoiceCalculatorService.GrossTotalTaxable,f=this.calculateTotalRate(r);r.forEach(D=>{if(i.CalculationTypeID==0){let I=D.Rate/100*c;e=[...e,this.generateSingleTaxSummary(D.Label,I,t)],i.MultipleTaxTypeID==1&&(c+=I)}else{let I=D.Rate/f*n;e=[...e,this.generateSingleTaxSummary(D.Label,I,t)]}})}else e=[...e,this.generateSingleTaxSummary(i.Label,n,t)];return e}calculateTotalRate(t){let e=0;return t&&t.length>0&&(e=t.map(i=>i.Rate).reduce((i,n)=>i+n)),e}generateSingleTaxSummary(t,e,i){let n=this._invoiceCalculatorService.currencySymbol;return new oe(e,n,t,i)}generateSurchargeSummary(){if(this._invoiceCalculatorService.SurchargeAmount==0)return;let t=[],e=this.appConfig.CorePrint,i=e&&e.Alias.SurchargePcg?e.Alias.SurchargePcg:"Surcharge";t.push(new oe(this._invoiceCalculatorService.SurchargeAmount,this._invoiceCalculatorService.currencySymbol,g.StringFormat("{0} ({1}%)",i,this._decimalPipe.transform(this._orderService.Data?.Invoice.SurchargePcg)),1));let n=this.generateAmountTotal();return t.push(n),t}checkDiscountIgnoreDecimal(t){let i=this.appConfig.PrintConfigInvoice.Footer.DiscountIgnoredDecimal,n=parseFloat(t)%1,r=!1;return n!==0&&i&&(r=!0),r}isDiscounted(){let t=this._invoiceCalculatorService.Discount1Amount,e=this._invoiceCalculatorService.Discount2Amount,i=this._orderService.Data.Order.DiscountAmount,n=!1;return(t!=0||e!=0||i!=0)&&(n=!0),n}isTaxReserveSequence(){let t=this._invoiceCalculatorService.tax,e=!!t,i=e?t.CalculationTypeID:null,n=this.appConfig.PrintConfigInvoice.ItemsFooter.TaxIncludeBeforeTotalAmount;return e&&i===1&&n}static \u0275fac=function(e){return new(e||o)(u(X),u(Y),u(j),u(N))};static \u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"})};var Ye=class o{constructor(t,e,i,n){this._receiptCalculatorService=t;this._cashierCalculatorService=e;this._signal=i;this._customerHttpService=n;this.broadcastOrderUpdate$.subscribe()}_salesOrderDataModelService=ee(N);_outletService=ee(Z);displayService=ee(hi);localdata=ee(Te);orderDataModel;broadcastOrderUpdate$=ot([this._salesOrderDataModelService.Data$,this.localdata.isStoreOrderInServer(),bn(this.displayService.isEnabled)]).pipe(zi(([t,e,i])=>{let n=this._outletService?.Data?.RegisterID;if(e&&i&&n){this.orderDataModel=t;let r=this.ConstructCartModelForCustomerDisplay(),c=new et;return c.GroupID=n+"_Subscriber",c.Method="POSCartAmountUpdated",c.Data=r,this._signal.broadcast(c).pipe(ke(f=>(console.log(f),it)))}else return it}),ke(t=>(console.log(t),it)),Ce());ConstructCartModelForCustomerDisplay(){let t=this._customerHttpService.Data,e=new fi;e.Number=this.orderDataModel.Order.Number,e.Items=Array();for(let i of this.orderDataModel.CartItems){let n=new gi;n.Name=i.Variant.Name,n.Discount=i.Discount,n.DiscountAmount=i.DiscountAmount,n.Price=i.Price,n.Quantity=i.Quantity,n.UnitQuantity=i.UnitQuantity,e.Items.push(n)}return g.IsNotEmpty(this.orderDataModel.Order.SalesID)?e.SalesName=this._outletService.getSalesname(this.orderDataModel.Order.SalesID):e.SalesName="",g.IsNotEmpty(this.orderDataModel.Order.CustomerID)&&g.IsNotEmpty(t)&&(e.Customer=new ut,e.Customer.Email=t.Email,e.Customer.Mobile=t.Mobile,e.Customer.Name=this.orderDataModel.ContactName),e.CurrencySymbol=this._cashierCalculatorService.currencySymbol,e.FinalAmount=this._cashierCalculatorService.Data,e.AmountSummary=this._receiptCalculatorService.generateAmountSummary(),e}BroadcastStateToCustomerDisplay(t,e="",i="",n=0){let r=new di;r.Status=t,r.InvoiceID=e,r.LoyaltyPoint=i,r.diff=n;let c=new et;return c.GroupID=this._outletService.Data.RegisterID+"_Subscriber",c.Method="POSStateUpdated",c.Data=r,this.displayService.isEnabled()?this.localdata.isStoreOrderInServer().pipe(ie(f=>f?this._signal.broadcast(c):Se(U.offlineMode))):it}BroadcastQRToCustomerDisplay(t){let e=new ui;e.GopayQr=t;let i=new et;return i.GroupID=this._outletService.Data.RegisterID+"_Subscriber",i.Method="POSQRPaymentActivated",i.Data=e,this.displayService.isEnabled()?this.localdata.isStoreOrderInServer().pipe(ie(n=>n?this._signal.broadcast(i):Se(U.offlineMode))):it}BroadcastChangeToKitchenDisplay(t){let e=new et;return e.GroupID=this._outletService.Data.EntityID+"_Subscriber",e.Method="ReceiveKitchenDisplayMessage",e.Data={state:t},this.localdata.isStoreOrderInServer().pipe(ie(i=>i?this._signal.broadcast(e):Se(U.offlineMode)))}static \u0275fac=function(e){return new(e||o)(u(Ci),u(X),u($e),u(we))};static \u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"})};var vi=class o{constructor(t){this.httpService=t}VerifyPayment(t,e){let i=this.getVerifyPaymentUrl(e);return this.httpService.post(i,t)}getVerifyPaymentUrl(t){let e;switch(t){case 0:e=L.GopayVerifyPayment;break;case 1:e=L.BcaVerifyPayment;break}return e}generateLink(t){return this.httpService.post(L.GenerateLink,t)}generateQRCode(t,e){return this.httpService.post(t,e)}static \u0275fac=function(e){return new(e||o)(u(xe))};static \u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"})};var Ct=class o{constructor(t,e,i,n,r){this._posHubService=t;this._orderDataService=e;this._PaymentHttpService=i;this._InvoicecashierCalculatorService=n;this._toastrService=r}transactionId;qrPaymentMethodID;QRCodeHttpResponse;_paymentMethod;get paymentMethod(){return this._paymentMethod}resetPaymentMethod(){this._paymentMethod=null}onQRPaymentComplete(t,e){return new Promise((i,n)=>{if(t.transaction_id!==this.transactionId){let c=`transaction_id: ${t.transaction_id} / gross_amount: ${t.gross_amount}`;n({header:"Invalid QR Payment",message:c});return}if(t.gross_amount!==this._InvoicecashierCalculatorService.Data){let c=`paid_amount: ${t.gross_amount} vs invoice_amount: ${this._InvoicecashierCalculatorService.Data}`;n({header:"Invalid QR Payment",message:c});return}let r=this._orderDataService.Data.Order.Number;if(t.order_id.includes(r)==!1){let c=`Order ID: ${t.order_id} vs Order Number: ${r}`;n({header:"Invalid QR Payment",message:c});return}if(t.transaction_status!=="settlement"){let c=`Transaction status is ${t.transaction_status}`;n({header:"Invalid QR Payment",message:c});return}this.validateEMoneyPayment(e).subscribe(c=>{i(c)})})}generateNewPayment(t,e){let i=this._orderDataService.Data;g.IsEmpty(this.qrPaymentMethodID)&&alert("QR PaymentMethod.ID is not available!");let n=new Je;return n.PaidAmount=e,n.Amount=e,n.Date=i.Order.Date,n.MethodID=this.qrPaymentMethodID,n.Code=t,g.IsEmpty(t)&&this._toastrService.warning("Midtrans transaction_id is empty. Please verify manually!","Mobile Payment Failure"),n}sendStateCompleteToCustomerDisplay(t){this._posHubService.BroadcastStateToCustomerDisplay(1,t.ObjectID,t.LoyaltyPoint,0).subscribe()}generateQR(t,e){this._paymentMethod=e,this.qrPaymentMethodID=e.ID;let i=this.getServiceUrl(e.EMoneyTypeID);return this._PaymentHttpService.generateQRCode(i,t).pipe(z(c=>(c=this.manipulateBCAQrisImg(c,e.EMoneyTypeID),this.transactionId=c.Transaction_id,this.QRCodeHttpResponse=c,this._orderDataService.transaction_id=c.Transaction_id,this.sendQRToCustomerDisplay(c.Url),c)))}sendQRToCustomerDisplay(t){this._posHubService.BroadcastQRToCustomerDisplay(t).subscribe()}validateEMoneyPayment(t){if(g.IsNotEmpty(this.transactionId)){let e=this._InvoicecashierCalculatorService.Data,i=this._paymentMethod?.EMoneyTypeID,n=this.generatePaymentVerificationData(e,i);return this._PaymentHttpService.VerifyPayment(n,i).pipe(ie(r=>(this.updatePosDataForSubmission(e),Ji(this._orderDataService.submitOrder(t)).pipe(Oe(c=>{this.sendStateCompleteToCustomerDisplay(c)})))))}else{let e=new Error("Transaction ID is Empty");throw nt(()=>e)}}generatePaymentVerificationData(t,e){let i=this._orderDataService.Data,n=new pi;return n.Number=i.Order.Number,n.Amount=t,n.TransactionID=this.transactionId,n.RegisterID=i.Order.RegisterID,e==1&&(n.Number=this.QRCodeHttpResponse.Number),n}updatePosDataForSubmission(t){let e=this._orderDataService.Data,i=this.generateNewPayment(this.transactionId,t),n=[];n.push(i),e.Invoice.Due=null,e.Action.Type=3,e.Order.InvoicedStateID=3,e.Payments=n,this._orderDataService.pushNewValue(e)}getServiceUrl(t){let e;switch(t){case 0:e=L.GenerateGopayQrCode;break;case 1:e=L.GenerateBcaQrCode;break}return e}manipulateBCAQrisImg(t,e){return e==1&&(t.Url=`data:image/png;base64, ${t.Url}`),t}clearTransactionID(){this.transactionId=null,this._orderDataService.transaction_id=null,this.QRCodeHttpResponse=null}getTransactionId(){return this.transactionId}static \u0275fac=function(e){return new(e||o)(u(Ye),u(N),u(vi),u(X),u(A))};static \u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"})};var vt=class{CommissionID;ReturNumber;parkTemporaryItem;posState;InputTextValue;constructor(){this.posState=0,this.CommissionID="",this.ReturNumber="",this.parkTemporaryItem=[],this.InputTextValue=""}};var _i=class o{constructor(t,e,i){this._promotionEventService=t;this._dialogRef=e;this.data=i;this.modalConfig=new $,this.modalConfig.hideCancel=!0,this.modalConfig.hideClose=!0,this.modalConfig.headerType=te.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||o)(_(he),_(q),_(de))};static \u0275cmp=V({type:o,selectors:[["POS-modal-promotion-confirm"]],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),S("onOk",function(){return i.onOk()}),a(1,"content")(2,"div")(3,"h5"),m(4),s(),a(5,"p",1),m(6),s(),a(7,"p",2),m(8),s()()()()),e&2&&(p("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:[J]})};var yi=class extends Be{};var no=(i=>(i[i.INTERNAL=1]="INTERNAL",i[i.EKSTERNAL=2]="EKSTERNAL",i[i.EKSTERNALINTERNAL=3]="EKSTERNALINTERNAL",i))(no||{});var yt=class o{constructor(t,e,i,n,r,c){this._httpService=t;this._orderDataService=e;this._userRoleService=i;this.toastr=n;this._invoiceCalculatorService=r;this._posHttpResponseService=c;this.subscribeToObservable()}role;originalRoleData;_coupon;get coupon(){return this._coupon}subscribeToObservable(){this._userRoleService.Data$.subscribe(t=>{this.role=t,g.IsEmpty(this.originalRoleData)&&(this.originalRoleData=ve(ze,t))})}RedeemCoupon(t,e,i,n=!0){let r=this._orderDataService.Data?.Order?.CustomerID,c=this._invoiceCalculatorService.Data,f={Code:t,EntityID:this._orderDataService.Data.Order.EntityID,CouponType:i,CustomerID:r,Amount:c,ListVariantID:this.getVariantIdsInCart()},D=this.getApiUrl();this._httpService.post(D,f).subscribe({next:I=>{switch(this._orderDataService.Data.Order.PromotionCoupon=t,this._orderDataService.Data.Order.PromotionNote=e,this._orderDataService.Data.Order.CouponType=i,this.resetAppliedCoupon(),I.Type){case 1:this.HandleDiscountPercentage(I,n);break;case 2:this.HandleDiscountAmount(I),n&&this.toastr.success(I.Notify,"Coupon Applied");break;case 3:this.HandleReturn();break;case 4:this.HandleParkedDeletion();break;case 5:this.HandleFullAccess(),n&&this.toastr.success("You now have Full Access for this Order!","Coupon Applied");break}this._coupon=I,this.orderNote(i,I)},error:I=>{this.resetAppliedCoupon(),this.removeAppliedCoupon()}})}getVariantIdsInCart(){return this._orderDataService.Data.CartItems.map(i=>i.VariantID)}getApiUrl(){let t=this._posHttpResponseService.Data?.AppConfigJSON,e=L.Coupon;return t.CouponRedemptionType==3&&(e=L.InternalEksternalCoupon),e}orderNote(t,e){t==2&&(g.IsNotEmpty(this._orderDataService.Data.Order.Note)?this._orderDataService.Data.Order.Note+=`
|
|
3
3
|
Coupon TADA - `+e.Notify:this._orderDataService.Data.Order.Note=" Coupon TADA - "+e.Notify)}resetAppliedCoupon(){if(g.IsNotEmpty(this.coupon))switch(this.coupon.Type){case 2:this.HandleDiscountAmount(this.coupon,!0);break;case 1:this.HandleDiscountPercentage(this.coupon,!1,!0);break;case 5:this.resetRoleAfterAppliedCoupon();break;case 4:this.HandleParkedDeletion(!0);break;case 3:this.HandleReturn(!0);break}}resetAppliedCouponDiscount(){if(this.coupon){switch(this.coupon.Type){case 1:this.HandleDiscountPercentage(this._coupon,!1,!0);break;case 2:this.HandleDiscountAmount(this._coupon,!0);break}this.removeAppliedCoupon()}}HandleDiscountPercentage(t,e,i=!1){t.amount>0?t.MaximumDiscount>0?this.applyConfigMaxDiscount(t,i):t.FullPriceProductOnly?this.applyFullPriceDisc(t,e,i):this.applyDiscountPercentage(t,e,i):(this.role.Discount=i?this.originalRoleData.Discount:!0,this._userRoleService.pushNewValue(this.role))}applyFullPriceDisc(t,e,i=!1){let n=this._orderDataService.Data,r=this.filterItemWithDisc(n.CartItems),c=this.filterItemWithCouponDisc(n.CartItems);i?c.length>0?(n.CartItems=this.resetItemsDisc(n.CartItems),this._orderDataService.pushNewValue()):this.applyDiscountPercentage(t,!1,i):r.length>0?(this.filterItemWithoutDisc(n.CartItems).length>0?n.CartItems=this.applyItemsDisc(n.CartItems,t):(this.removeAppliedCoupon(),e=!1),this._orderDataService.pushNewValue()):this.applyDiscountPercentage(t,!1,i),e&&this.toastr.success(t.Notify,"Coupon Applied")}filterItemWithDisc(t){return t.filter(i=>i.Discount>0||i.DiscountAmount>0||i.Price!=i?.Variant?.UnitPrice||g.IsNotEmpty(i.PriceBookID)||i.PriceTypeID==2)}filterItemWithoutDisc(t){return t.filter(i=>this.itemConditionFullPriceOnly(i))}filterItemWithCouponDisc(t){return t.filter(i=>i.CouponDiscount>0)}applyDiscountPercentage(t,e,i=!1){let n=this._orderDataService.Data.Order.CustomerDiscountRate,r=t.amount;i?(this._orderDataService.Data.Order.Discount=0,this._orderDataService.pushNewValue()):r>=n?t.ListVariantID?.length>0?this.applyDiscountRequiredItems(t):(this._orderDataService.Data.Order.Discount=t.amount,this._orderDataService.pushNewValue(),e&&this.toastr.success(t.Notify,"Coupon Applied")):(this.toastr.warning("Member discount is applied because member discount is greater than Coupon Discount","Warning"),this.resetAppliedCouponDiscount())}applyDiscountRequiredItems(t){let e=this._orderDataService.Data.CartItems,i=t.ListVariantID,n;e=e.map(r=>(n=i.findIndex(c=>c==r.VariantID),n>-1&&(r.Discount=t.amount),r)),this._orderDataService.Data.CartItems=e,this._orderDataService.pushNewValue()}applyConfigMaxDiscount(t,e=!1){if(t.FullPriceProductOnly){let i=this.getItemsAppliedMaxDisc(e),n=this._invoiceCalculatorService.GetAmountByCart(i);this.applyMaxDiscount(t,n,e)}else{let i=this._invoiceCalculatorService.GrossTotal;this.applyMaxDiscount(t,i,e)}}getItemsAppliedMaxDisc(t){return this._orderDataService.Data.CartItems.filter((i,n)=>t?i.Discount==0&&i.DiscountAmount==0&&i.CouponDiscount==0?!0:i.CouponDiscount>0:i.Discount==0&&i.DiscountAmount==0)}applyMaxDiscount(t,e,i){let n=this._orderDataService.Data,r=e*t.amount/100,c=t.MaximumDiscount;r>=c?n.Order.DiscountAmount=i?0:c:(n.Order.DiscountAmount==c&&(n.Order.DiscountAmount=0),n.CartItems=i?this.resetItemsDisc(n.CartItems):this.applyItemsDisc(n.CartItems,t)),this._orderDataService.pushNewValue(n)}resetItemsDisc(t){return t=t.map(e=>(e.CouponDiscount>0&&(e.Discount=0,e.DiscountAmount=0,e.CouponDiscount=0),e)),t}applyItemsDisc(t,e){return e.ListVariantID?.length>0?t=this.applyDiscByVariant(t,e):t=t.map(i=>(this.itemConditionFullPriceOnly(i)&&(i.Discount=e.amount,i.CouponDiscount=e.amount),i)),t}applyDiscByVariant(t,e){return t=t.map(i=>(e.ListVariantID.find(r=>r==i.VariantID)&&this.itemConditionFullPriceOnly(i)&&(i.Discount=e.amount,i.CouponDiscount=e.amount),i)),t}itemConditionFullPriceOnly(t){return t.Discount==0&&t.DiscountAmount==0&&t.Price==t?.Variant?.UnitPrice&&g.IsEmpty(t.PriceBookID)}HandleDiscountAmount(t,e=!1){t.amount>0?(t.ListVariantID.length>0?this.applyDiscountInItem(t,e):(this._orderDataService.Data.Order.DiscountAmount=e?0:t.amount,this._orderDataService.pushNewValue()),this.resetCustomerPoint(e)):(this.role.Discount=e?this.originalRoleData.Discount:!0,this._userRoleService.pushNewValue(this.role))}applyDiscountInItem(t,e=!1){let i=this._orderDataService.Data;e?i.CartItems=this.resetItemsDisc(i.CartItems):i.CartItems=i.CartItems.map(n=>(t.ListVariantID.includes(n.VariantID)&&(n.DiscountAmount=t.amount,n.CouponDiscount=t.amount),n)),this._orderDataService.pushNewValue(i)}resetCustomerPoint(t){if(!t){let e=this._orderDataService.Data;e.Order.PointUsed=0}}HandleReturn(t=!1){this.role.Return=t?this.originalRoleData.Return:!0,this._userRoleService.pushNewValue(this.role)}HandleParkedDeletion(t=!1){this.role.ParkedDeletionAuthorized=t?this.originalRoleData.ParkedDeletionAuthorized:!0,this._userRoleService.pushNewValue(this.role),this.toastr.success("You Have Access to delete park and delete item when retrieve!","Coupon Applied")}HandleFullAccess(){this.role.UnitPriceEditor=!0,this.role.Discount=!0,this.role.Return=!0,this.role.Tax=!1,this.role.NumberEditor=!0,this.role.DateEditor=!0,this.role.PricebookSelector=!0,this._userRoleService.pushNewValue(this.role)}resetRoleAfterAppliedCoupon(){let t=ve(ze,this.originalRoleData);this.role.UnitPriceEditor=t.UnitPriceEditor,this.role.Discount=t.Discount,this.role.Return=t.Return,this.role.Tax=t.Tax,this.role.NumberEditor=t.NumberEditor,this.role.DateEditor=t.DateEditor,this.role.PricebookSelector=t.PricebookSelector,this.role.ParkedDeletionAuthorized=t.ParkedDeletionAuthorized,this._userRoleService.pushNewValue(this.role)}removeAppliedCoupon(){let t=this._orderDataService.Data;t.Order.PromotionCoupon=null,t.Order.PromotionNote=null,this._coupon=null,this._orderDataService.pushNewValue()}static \u0275fac=function(e){return new(e||o)(u(xe),u(N),u(Ne),u(A),u(X),u(j))};static \u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"})};var bt=class o{constructor(t,e,i,n,r,c,f,D,I){this.variantService=t;this._posService=e;this._orderDataService=i;this.toastr=n;this._orderProcessorService=r;this._customerHttpService=c;this.promotionCouponService=f;this.userRoleService=D;this.decimalPipe=I;this.subscribeToObservable()}salesOrderData;appConfigJson;entityID;audio=new Audio;subscribeToObservable(){this._posService.Data$.subscribe(t=>{this.appConfigJson=t.AppConfigJSON}),this._orderDataService.Data$.subscribe(t=>{this.salesOrderData=t,this.entityID=t.Order.EntityID})}addCartItemById(t,e,i=!0){return new Promise((n,r)=>{this.variantService.findVariantByID(t,this.entityID,i).then(c=>{this.createNewCartItem(c,e),n(c)}).catch(c=>{r(c)})})}addCartItemByCode(t){return new Promise((e,i)=>{let n=this.appConfigJson.ModuleSell.DigitalScale;n.Digit>0&&g.IsNotEmpty(n.Regex)&&t.length==n.Digit?this.parseDigitalScaleBarcodeWithRegex(t,n).then(c=>{c||(this.toastr.info("Matching Regex Rule to Barcode","Digital Scale"),this.findVariantByCode(t).then(f=>e(f)).catch(f=>i(f)))}):this.findVariantByCode(t).then(c=>e(c)).catch(c=>i(c))})}findVariantByCode(t){let e=this.appConfigJson.ModuleSell.BarcodeSerialEnabled;return new Promise((i,n)=>{this.variantService.findVariantByCode(t,this.entityID,e).then(r=>{i(r),this.createNewCartItem(r)}).catch(r=>{this.playBellRing(),n(r)})})}addItemBySerial(t){this.variantService.findVariantBySerial(t,this.entityID).subscribe(e=>{let i=this.salesOrderData.CartItems;if(i.length>0){let n,r=[],c=i.findIndex(f=>f.Variant.ID==e.ID);r=[],c!==-1?(n=i[c].Serial?.findIndex(f=>f.Number==t),r=[...i[c].Serial?i[c].Serial:[]],n==-1?(r.push({Number:t,Quantity:1}),i[c].Quantity=r.length):r.length>0?r[n].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="//res.cloudinary.com/pos/video/upload/v1659947782/POS/Music/bell_ring.mp3",this.audio.load(),this.audio.play()}updateCartItem(t,e){this.salesOrderData.CartItems[e]=t,this._orderDataService.pushNewValue(this.salesOrderData),this.applyCustomerPoint(),this.reApplyPromotionCoupon()}deleteCartItem(t){this.salesOrderData.CartItems=this.salesOrderData.CartItems.filter(e=>e!==t),this._orderDataService.pushNewValue(this.salesOrderData),this.applyCustomerPoint(),this.reApplyPromotionCoupon()}parseDigitalScaleBarcodeWithRegex(t,e){return new Promise(i=>{let n=this.appConfigJson.ModuleSell.BarcodeSerialEnabled,r=new RegExp(e.Regex),c=t.match(r);if(g.IsNotEmpty(c)){let f=c[1],D=parseFloat(c[2]);D=D/e.QuantityDivider,this.variantService.findVariantByCode(f,this.entityID,n).then(I=>{this.createNewCartItem(I,null,D),i(!0)}).catch(()=>{i(!1)})}else i(!1)})}createNewCartItem(t,e,i){let n=new Be,r=this.appConfigJson.ModuleSell.ProductNotes.CopyProductDescription,c=this.appConfigJson.ModuleSell.ProductNotes.CopyPromotionName;n.patchByVariant(t,r,c),n=this.applyReward(n,e),g.IsEmpty(e)&&(n=this.applyPriceBook(n)),this.validateCartItem(n)&&(n.Quantity=i||n.Quantity,e?.PromotionType==2?this.handlingPromotionQuantity(n):this.pushNewItemToArray(n,n.PromotionGift),this.applyCustomerPoint()),this.addAvailableComponent(n)}applyCustomerPoint(){let t=this.salesOrderData.Order.CustomerID,e=g.IsEmpty(t);this._orderProcessorService.reedemPointToDiscount(e)}handlingPromotionQuantity(t){let e=ve(Be,this.salesOrderData.CartItems),i=e.findIndex(n=>n.VariantID==t.VariantID&&n.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 n=e.OriginalPrice-e.UnitPrice;t.Price=t.UnitPriceOriginal-n,t.UnitPrice=t.UnitPriceOriginal-n,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=e.PromotionName)}return t}addAvailableComponent(t){let e=t.Price!=0,i=this.appConfigJson.ModuleSell.SellProductComponentDefaultPrice,n=t.Variant;if(n.Component!=null&&n.Component.length>0)for(let r of n.Component){let c=new yi;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){let i=this.salesOrderData.CartItems.findIndex(n=>n.VariantID==t.VariantID);if(t=this.applyPromotionProduct(t),i==-1||e)this.salesOrderData.CartItems.push(t);else{let n=this.appConfigJson.ModuleSell.QuickKey.NewRowBehaviour;n==2?this.salesOrderData.CartItems.push(t):n==1?this._orderProcessorService.Data.posState==4?this.salesOrderData.CartItems.push(t):this.addingQuantityItem(i,t):this.addingQuantityItem(i,t)}this._orderDataService.pushNewValue(this.salesOrderData),this.reApplyPromotionCoupon()}reApplyPromotionCoupon(){let t=this.salesOrderData.Order.PromotionCoupon,e=this.salesOrderData.Order.CouponType,i=this.salesOrderData.Order.PromotionNote;g.IsNotEmpty(t)&&this.promotionCouponService.RedeemCoupon(t,i,e,!1)}addingQuantityItem(t,e){let i=this.salesOrderData.CartItems.filter(f=>f.VariantID==e.VariantID),n=i.length,r=i.find(f=>!f.PromotionGift);this.salesOrderData.CartItems[t].PromotionGift&&n==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.validatePriceMinimum(t)||!this.validateSerialItem(t))}validatePriceMinimum(t){let e=!0,i=this.userRoleService.Data.PriceMinimum,n=this.appConfigJson.ModuleSell.ProductDialog.PriceMinimumTypeID;if(i){let r=0;switch(n){case 1:r=t.UnitPrice;break;case 2:r=t.UnitCost;break;case 3:r=t.UnitPriceMinimum;break}if(t.Price<r){e=!1;let c=g.StringFormat("You have no right to sell this item lower than {0}",this.decimalPipe.transform(r));alert(c)}}return e}validateSerialItem(t){let e=!0;if(t?.Serial?.length>0&&t.Variant.TypeID==4&&t.Quantity>0){let i=0;t?.Serial?.forEach(n=>{i+=n.Quantity}),i!=t.Quantity&&(this.toastr.error("Serial must be equal with the quantity","Error"),e=!1)}return e}applyPriceBook(t){let e=t.Variant.PriceBook!=null?t.Variant.PriceBook:[],i=this.findCustomerPricebook(e);if(e&&e.length!==0){let n=e.sort(function(r,c){return c.MinimumQuantity-r.MinimumQuantity}).filter(r=>t.Quantity>=r.MinimumQuantity&&r.MinimumQuantity!=0);n.length>0||g.IsNotEmpty(i)?g.IsNotEmpty(i)?t=this.applyPricebookToItem(t,i):t=this.applyPricebookToItem(t,n[0]):t=this.resetAppliedPricebook(t)}return t}resetAppliedPricebook(t){let e=this.appConfigJson.ModuleSell.ProductNotes,n=(t?.Variant?.PriceBook).find(r=>r.ID==t.PriceBookID);return g.IsNotEmpty(n)&&(t.Discount=t.Variant.PriceDiscount,t.PriceBookID=g.GuidEmpty,t.Price=t.Variant.UnitPrice,t.UnitPrice=t.Variant.UnitPrice,t.PriceTypeID=0,t=this.applyPromotionProduct(t),e.CopyPromotionName?(t.Note=t.Variant.PriceNote,t.PriceNote=t.Variant.PriceNote):(t.Note="",t.PriceNote="")),t}applyPricebookToItem(t,e){let i=this.appConfigJson.ModuleSell.Pricebook.PricebookVisible;return t.Discount=e.PriceDiscount,t.PriceNote=e.Name,t.UnitPrice=e.UnitPrice,t.PriceBookID=e.ID,t.Price=e.UnitPrice,t.PriceTypeID=2,i?t.Note=e.Name:t.Note="",t}findCustomerPricebook(t=[]){let e=this._customerHttpService.Data,i;return e&&(i=t.find(n=>n.ID==e.PricebookID)),i}static \u0275fac=function(e){return new(e||o)(u(Vn),u(j),u(N),u(A),u(je),u(we),u(yt),u(Ne),u(Y))};static \u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"})};function Oo(o,t){if(o&1&&(a(0,"div",9)(1,"div",4),b(2,"input",10),s()()),o&2){let e=d();l(2),p("formControl",e.searchControl)}}function Do(o,t){if(o&1){let e=x();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),S("click",function(){let n=C(e).$implicit,r=d();return v(r.onSelectReward(n))}),m(13,"Apply"),s()()()}if(o&2){let e=t.$implicit;l(2),P(e.VariantName),l(2),P(e.VariantCode),l(2),P(T(7,4,e.OriginalPrice)),l(3),P(T(10,6,e.UnitPrice))}}var Si=class o{constructor(t,e,i,n,r,c){this._dialogRef=t;this._matDialog=e;this._shoppingCartService=i;this._promotionEventService=n;this._toastr=r;this.data=c;this.selectedPromotion=this._promotionEventService.selectedPromotion}modalConfig=new $;selectedPromotion;rewards$;searchControl=new Ue;ngOnInit(){this.modalConfig.title="Select a Reward",this.modalConfig.hideFooter=!0,this.initRewards(!0)}initRewards(t){this.rewards$=this.searchControl.valueChanges.pipe(Qt(""),rt(t?0:500),Pe(),ie(e=>{let i;return i=Se(this.data.rewards).pipe(z(n=>n.filter(r=>this.findKeywordInValue(e,r?.VariantCode)||this.findKeywordInValue(e,r?.VariantName)))),t=!0,i}))}findKeywordInValue(t,e){return e?.toUpperCase()?.indexOf(t?.toUpperCase())>-1}onSelectReward(t){t.PromotionType=this.data.promotion.TypeID,this._shoppingCartService.addCartItemById(t.VariantID,t,!0).then(()=>{this._matDialog.closeAll(),this._promotionEventService.pushNewValue(this._promotionEventService.Data),this.showToastAppliedPromo()})}showToastAppliedPromo(){this._toastr.success("Applied "+this.selectedPromotion.Name+" to order!","Applied successfully!")}close(){this._dialogRef.close()}static \u0275fac=function(e){return new(e||o)(_(q),_(Ie),_(bt),_(he),_(A),_(de))};static \u0275cmp=V({type:o,selectors:[["POS-modal-select-item"]],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"]],template:function(e,i){e&1&&(a(0,"modal-material",0),S("onCancel",function(){return i.close()})("onClose",function(){return i.close()}),a(1,"content")(2,"div",1),h(3,Oo,3,1,"div",2),a(4,"div",3)(5,"div",4)(6,"table",5)(7,"thead",6)(8,"tr")(9,"th",7),m(10,"Name"),s(),a(11,"th",7),m(12,"Code"),s(),a(13,"th",7),m(14,"Price"),s(),a(15,"th",7),m(16,"Promo"),s(),b(17,"th",7),s()(),a(18,"tbody"),h(19,Do,14,8,"tr",8),y(20,"async"),y(21,"sortBy"),s()()()()()()()),e&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",st(21,5,T(20,3,i.rewards$),"desc","VariantCode")))},dependencies:[ae,se,me,pe,mt,J,lt,Y,dt],styles:[".table-scroll[_ngcontent-%COMP%]{max-height:400px;overflow-y:auto}table[_ngcontent-%COMP%]{max-width:600px!important;overflow-x:hidden}"]})};function Mo(o,t){if(o&1&&(G(0),a(1,"div",13)(2,"div",7),b(3,"input",14),s()(),W()),o&2){let e=d();l(3),p("formControl",e.searchCtrl)}}function xo(o,t){o&1&&(G(0),a(1,"th",15),m(2,"Qty"),s(),W())}function Io(o,t){o&1&&b(0,"th",10)}function To(o,t){if(o&1){let e=x();G(0),a(1,"td")(2,"input",17),B("ngModelChange",function(n){C(e);let r=d().$implicit;return H(r.Quantity,n)||(r.Quantity=n),v(n)}),s()(),W()}if(o&2){let e=d().$implicit;l(2),F("ngModel",e.Quantity)}}function wo(o,t){if(o&1){let e=x();a(0,"td",18)(1,"button",19),S("click",function(){C(e);let n=d().$implicit,r=d();return v(r.onApplyReward(n))}),m(2,"Apply"),s()()}}function Eo(o,t){if(o&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(),h(11,To,3,1,"ng-container",11)(12,wo,3,0,"ng-template",null,1,He),s()),o&2){let e=t.$implicit,i=Q(13),n=d();l(2),P(e.VariantName),l(2),P(e.VariantCode),l(2),P(T(7,6,e.OriginalPrice)),l(3),P(T(10,8,e.UnitPrice)),l(2),p("ngIf",n.rewardQuantity>1)("ngIfElse",i)}}var Pi=class o{constructor(t,e,i,n,r,c){this.data=t;this.shoppingCartService=e;this.promotionEventService=i;this.dialogRef=n;this.matDialog=r;this.toastr=c;this.searchCtrl=new Ue,this.rewardQuantity=t.rewardQuantity,this.sourceRewards=[...t.rewards]}modalConfig;rewards$;rewardQuantity;rewards;sourceRewards=[];searchCtrl;ngOnInit(){this.initModalConfig(),this.initSearchCtrl(!0)}initModalConfig(){this.modalConfig=new $,this.modalConfig.title="Select a Reward",this.rewardQuantity<2&&(this.modalConfig.hideFooter=!0)}initSearchCtrl(t){this.rewards$=this.searchCtrl.valueChanges.pipe(Qt(""),rt(t?0:500),Pe(),ie(e=>{let i;return i=Se(this.sourceRewards).pipe(z(n=>(n.length===1&&(n[0].Quantity=this.rewardQuantity),n)),z(n=>n.filter(r=>this.findKeywordInValue(e,r?.VariantCode)||this.findKeywordInValue(e,r?.VariantName)))),t=!1,i}),Oe(e=>{this.rewards=e}))}findKeywordInValue(t,e){return e?.toUpperCase()?.indexOf(t.toUpperCase())>-1}onApplyReward(t){this.addRewardToShoppingCart(t)}onClose(){this.dialogRef.close()}onOk(){this.calculateRewardQty()>this.rewardQuantity?this.toastr.warning("Product reward exceeds the maximum amount earned","Warning"):[...this.rewards].filter(i=>i.Quantity>0).forEach(i=>{this.addRewardToShoppingCart(i)})}calculateRewardQty(){let t=0;return this.rewards.forEach(e=>{t+=e.Quantity?e.Quantity:0}),t}addRewardToShoppingCart(t){t.PromotionType=this.data.promotion.TypeID,this.shoppingCartService.addCartItemById(t.VariantID,t,!0).then(()=>{this.matDialog.closeAll(),this.promotionEventService.pushNewValue(this.promotionEventService.Data)})}static \u0275fac=function(e){return new(e||o)(_(de),_(bt),_(he),_(q),_(Ie),_(A))};static \u0275cmp=V({type:o,selectors:[["app-modal-quantity-reward"]],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"]],template:function(e,i){if(e&1){let n=x();a(0,"modal-material",2),S("onCancel",function(){return C(n),v(i.onClose())})("onOk",function(){return C(n),v(i.onOk())})("onClose",function(){return C(n),v(i.onClose())}),a(1,"header")(2,"small",3),m(3),s()(),a(4,"content")(5,"div",4),h(6,Mo,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(),h(20,xo,3,0,"ng-container",11)(21,Io,1,0,"ng-template",null,0,He),s()(),a(23,"tbody"),h(24,Eo,14,10,"tr",12),y(25,"async"),y(26,"sortBy"),s()()()()()()()}if(e&2){let n=Q(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",n),l(4),p("ngForOf",st(26,8,T(25,6,i.rewards$),"desc","VariantCode"))}},dependencies:[ae,se,me,pe,Me,mt,J,pt,lt,Y,dt]})};var he=class o{constructor(t,e,i,n,r,c,f,D,I){this._orderDataService=t;this._outletService=e;this._invoiceCalculatorService=i;this._dialog=n;this._httpService=r;this._posService=c;this._toastr=f;this._signalrService=D;this.decimalPipe=I;this.previousQuantity=0,this.previousTotalEligible=0,this.subscribeNotification(),this._posService.Data$.subscribe(k=>{this.taxes=k.Taxes}),this._outletService.Data$.subscribe(k=>{this.loadPromotions(k.Promotion)}),this._orderDataService.Data$.pipe(le(k=>{this.salesOrderData=k;let Qe=this.calculateOrderReward(k.getRewards()),Hi=this.calculateOrderReward(this.previousRewards);return this.previousQuantity!=k.TotalQuantity||Hi<Qe||this.isRestroreOrder}),rt(100)).subscribe(k=>{this.isRestroreOrder=!1,this.checkQtyPromotion(),this.applyQuantityPromotion(),this.previousRewards=[...k.getRewards()]}),this._invoiceCalculatorService.Data$.subscribe(k=>{this.checkEligiblePromotionWithMinSpend()})}_Data=new re([]);get Data(){return this._Data.getValue()}Data$=this._Data.asObservable();selectedPromotion=null;onClickToastPromo=new be;previousQuantity;salesOrderData;orderDataBeforePromotion;taxes=[];previousTotalEligible;previousRewards=[];isRestroreOrder=!1;calculateOrderReward(t){let e=0;return t.length>0&&(e=t.map(i=>i.Quantity).reduce((i,n)=>i+n)),e}checkQtyPromotion(){let t=this._orderDataService.Data;this.checkEligibleQtyPromotion(t.CartItems),this.checkEligibleTierPromotion(t.CartItems),this.previousQuantity=t.TotalQuantity}subscribeNotification(){this._signalrService.OnPromotionEventChange.pipe(Ce(),ie(()=>{let t=this._outletService.Data?.RegisterID;return this.getPromotions(t)})).subscribe(()=>{this._toastr.info("Promotion Event Updated","Promotion Update")})}getPromotions(t){return this._httpService.get(L.GetListPromotion,[{key:"RegisterID",value:t}]).pipe(Oe(e=>{this.loadPromotions(e)}))}loadPromotions(t){let e=this.getPromotionDesc(t);this.pushNewValue(e),this.checkQtyPromotion(),this.checkEligiblePromotionWithMinSpend()}pushNewValue(t){this.showToastEligiblePromotion(),this._Data.next(t)}checkSelectedPromotionRequirement(t){this.selectedPromotion!=null&&this.selectedPromotion.TypeID==t&&this.Data.find(i=>i.ID===this.selectedPromotion.ID)?.Eligible===!1&&(this._dialog.open(_i,{id:"modal-promotion-confirm",data:{message:"Order will be restored to before the promotion is applied"},disableClose:!0}),this.isRestroreOrder=!0)}restoreOrder(){this._orderDataService.pushNewValue(this.orderDataBeforePromotion),this.selectedPromotion=null}getPromotionDesc(t=[]){return t?.map(i=>(i.Description=this.generatePromotionDesc(i),i))}checkEligiblePromotionWithMinSpend(){let t=this._invoiceCalculatorService.Data,e=this.Data?.filter(n=>(n.TypeID===1||n.TypeID==3)&&!this.checkExpiredPromotion(n)).map(n=>(t>=n.MinimumAmount?n.Eligible=!0:n.Eligible=!1,n)),i=this.mappingEligiblePromotion(e);this.pushNewValue(i),this.checkSelectedPromotionRequirement(1),this.checkSelectedPromotionRequirement(3)}checkEligibleQtyPromotion(t){let e=0,i=this.Data?.filter(r=>r.TypeID===2&&!this.checkExpiredPromotion(r)).map(r=>(r.Eligible=!1,r.ListVariant.length>0?(e=this.getQuantityByRequirementType(t,"variant",r.ListVariant),e>=r.MinimumAmount&&(r.Eligible=!0)):r.ListCategory.length>0?(e=this.getQuantityByRequirementType(t,"category",r.ListCategory),e>=r.MinimumAmount&&(r.Eligible=!0)):this.salesOrderData.TotalQuantity>=r.MinimumAmount&&(r.Eligible=!0),r)),n=this.mappingEligiblePromotion(i);this.pushNewValue(n)}checkEligibleTierPromotion(t){let e,i=this.Data?.filter(r=>r.TypeID===5&&!this.checkExpiredPromotion(r)).map(r=>(r.Eligible=!1,r.ListVariant.length>0?e=this.getQuantityByRequirementType(t,"variant",r.ListVariant):r.ListCategory.length>0?e=this.getQuantityByRequirementType(t,"category",r.ListCategory):e=this.salesOrderData.TotalQuantity,r.PromotionTieredQuantity.forEach(c=>{e>=c.Quantity&&(r.Eligible=!0)}),r)),n=this.mappingEligiblePromotion(i);this.pushNewValue(n)}getQuantityByRequirementType(t,e,i){let n=0,r;return e=="variant"?t.forEach(c=>{r=i.findIndex(f=>f.ID===c.VariantID),r!==-1&&(n+=c.Quantity)}):t.forEach(c=>{c.Variant&&(r=i.findIndex(f=>f.ID===c.Variant.CategoryID),r!==-1&&(n+=c.Quantity))}),n}mappingEligiblePromotion(t=[]){let e=this.Data;if(t?.length>0){let i;e=this.Data?.map(n=>(i=t.findIndex(r=>r.ID==n.ID),i!==-1&&(n=t[i]),n))}return e}checkExpiredPromotion(t){let e=new Date,i=new Date(t.StartDate),r=(g.IsEmpty(t.StartTime)?"00:00:00":t.StartTime).split(":").map(I=>parseInt(I));i.setHours(r[0],r[1],r[2]);let c=new Date(t.ExpirationDate),D=(g.IsEmpty(t.EndTime)?"23:59:59":t.EndTime).split(":").map(I=>parseInt(I));return c.setHours(D[0],D[1],D[2]),!(e.getTime()>=i.getTime()&&e.getTime()<=c.getTime())}showToastEligiblePromotion(){let t=this.getTotalEligiblePromotion(),e=g.IsNotEmpty(this.salesOrderData.Order.ID);this.previousTotalEligible!==t&&t>0&&!e&&this._toastr.info(t+" promotion(s) can be applied!","Promo available!",{timeOut:2e4}).onTap.pipe(Ae(1)).subscribe(()=>{this.onClickToastPromo.next(!0)}),this.previousTotalEligible=t}getTotalEligiblePromotion(){return this.Data?.filter(e=>e.Eligible).length}generatePromotionDesc(t){let e="";switch(t.TypeID){case 2:e+="Minimum "+this.decimalPipe.transform(t.MinimumAmount)+" ",t.ListVariant.length>0?(e=e+" piece of ",e+=this.generateItemListDescription(t.ListVariant)):t.ListCategory.length>0?(e+="from category ",e+=this.generateItemListDescription(t.ListCategory)):e+="items";break;case 1:e+="Minimum spend Rp. "+this.decimalPipe.transform(t.MinimumAmount);break;case 3:e+=`Apply
|
|
4
4
|
${t.Discount1!==0?"discount1 = "+t.Discount1+"%":""}
|