dealpos 25.49.4 → 25.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/{chunk-WYRHUSXS.js → chunk-2ENLMKGR.js} +1 -1
- package/browser/{chunk-QS32TZGB.js → chunk-2FJNMKCN.js} +1 -1
- package/browser/{chunk-OYEU5L3I.js → chunk-2ITJBRJU.js} +1 -1
- package/browser/{chunk-34X4ZZD5.js → chunk-2KI73XNT.js} +1 -1
- package/browser/{chunk-T4E5A3KH.js → chunk-2SZZVWQD.js} +11 -11
- package/browser/{chunk-JZFX4FNK.js → chunk-3AZAILT2.js} +1 -1
- package/browser/{chunk-INWLOCX3.js → chunk-3CUT73ZP.js} +1 -1
- package/browser/{chunk-D2OMTDKS.js → chunk-3ZWJMFYL.js} +1 -1
- package/browser/{chunk-SY463GX6.js → chunk-4KYROBKJ.js} +1 -1
- package/browser/{chunk-IFKUMLMD.js → chunk-4MQZXTMM.js} +1 -1
- package/browser/{chunk-KWFL5YOV.js → chunk-4YZVDERU.js} +1 -1
- package/browser/{chunk-F3YWM4BJ.js → chunk-5SIEW7SH.js} +1 -1
- package/browser/{chunk-FTZZHFXM.js → chunk-7L5VMLEF.js} +1 -1
- package/browser/{chunk-P2R2O6GD.js → chunk-7MJWZXSK.js} +2 -2
- package/browser/{chunk-ROVDZJVT.js → chunk-A5CTHLE4.js} +1 -1
- package/browser/{chunk-C777CYT4.js → chunk-A6Z5ZHVO.js} +1 -1
- package/browser/{chunk-SFXDXOSB.js → chunk-B7BVEOOI.js} +1 -1
- package/browser/{chunk-LNZY3GKF.js → chunk-BFNGPKGX.js} +1 -1
- package/browser/{chunk-52ONOTHS.js → chunk-BLEJLNEO.js} +1 -1
- package/browser/{chunk-QOCGWG6L.js → chunk-BQ7QT5RB.js} +1 -1
- package/browser/chunk-BZ3GMUQ7.js +14 -0
- package/browser/{chunk-Y4XWHUVX.js → chunk-CB6QEEJX.js} +1 -1
- package/browser/{chunk-ASHEF37H.js → chunk-CCJ6SHBL.js} +1 -1
- package/browser/{chunk-7V6NCJRQ.js → chunk-COL56R4A.js} +1 -1
- package/browser/chunk-CXWICNFP.js +1 -0
- package/browser/{chunk-TLLI6Z5X.js → chunk-CZHWPDAM.js} +1 -1
- package/browser/{chunk-XOQUXJ6S.js → chunk-DYBRYTEM.js} +1 -1
- package/browser/{chunk-SO3RL6QR.js → chunk-EAEOJMTA.js} +1 -1
- package/browser/{chunk-LI6G74I7.js → chunk-F765TCAS.js} +1 -1
- package/browser/{chunk-RGO36X34.js → chunk-FMKY4THI.js} +1 -1
- package/browser/{chunk-KJ5BS7KR.js → chunk-FSOHJLXB.js} +1 -1
- package/browser/{chunk-APHRANVH.js → chunk-FV4MYFQI.js} +1 -1
- package/browser/{chunk-7V2CY4DW.js → chunk-G3DZI5XK.js} +1 -1
- package/browser/{chunk-YTXYAEFO.js → chunk-G5JGQBAG.js} +1 -1
- package/browser/{chunk-BVMFVFGN.js → chunk-GBSRXCWH.js} +1 -1
- package/browser/{chunk-BSV3Y4MG.js → chunk-GDQGP7DV.js} +1 -1
- package/browser/{chunk-TAVEJBKL.js → chunk-GESNWWTD.js} +2 -2
- package/browser/{chunk-3Y2TKGP4.js → chunk-GRLVYPPM.js} +1 -1
- package/browser/{chunk-WZWXE6GT.js → chunk-HFDJ5XSI.js} +1 -1
- package/browser/{chunk-NTCQH6TH.js → chunk-HFOJZ3B5.js} +1 -1
- package/browser/{chunk-ADQOH7YA.js → chunk-HFZ437GH.js} +1 -1
- package/browser/{chunk-OXMLRZZ4.js → chunk-IPPIH4F4.js} +1 -1
- package/browser/{chunk-RULBTV6L.js → chunk-ISN5K6K2.js} +1 -1
- package/browser/{chunk-V45WTUQ2.js → chunk-ISQHQTAS.js} +1 -1
- package/browser/chunk-JCLYKROE.js +1 -0
- package/browser/chunk-KUF3JPB2.js +1 -0
- package/browser/{chunk-743523SK.js → chunk-KZBVWICA.js} +1 -1
- package/browser/{chunk-CLO7U3RB.js → chunk-LIX7XJ55.js} +1 -1
- package/browser/{chunk-ZEI66KM2.js → chunk-LIXEWT4U.js} +3 -3
- package/browser/{chunk-XTU3LHA6.js → chunk-M2HEFQUY.js} +1 -1
- package/browser/{chunk-HOZ6XJ4Z.js → chunk-MFJH22SW.js} +1 -1
- package/browser/{chunk-NFODKKJI.js → chunk-MZSJCSUV.js} +2 -2
- package/browser/{chunk-6H5XBM35.js → chunk-O3ENARQZ.js} +1 -1
- package/browser/{chunk-QE5OFO56.js → chunk-OZ3MKU4C.js} +1 -1
- package/browser/chunk-PHYDJ3P5.js +1 -0
- package/browser/{chunk-HCMW3RC5.js → chunk-PIAQ4TBN.js} +1 -1
- package/browser/{chunk-N7M4OSQZ.js → chunk-PLR55YR2.js} +1 -1
- package/browser/{chunk-CD6ZWSFG.js → chunk-PMDFKXZY.js} +1 -1
- package/browser/{chunk-XFJYJSZU.js → chunk-PV4YHZX5.js} +1 -1
- package/browser/chunk-PVBS6SYW.js +3 -0
- package/browser/{chunk-WFSJDUCV.js → chunk-PXIMA665.js} +2 -2
- package/browser/{chunk-OETRAGYY.js → chunk-Q3DS2RLM.js} +1 -1
- package/browser/chunk-QWB3USYP.js +3 -0
- package/browser/{chunk-K3V25WUQ.js → chunk-QZRMHLML.js} +1 -1
- package/browser/{chunk-XWXXETJY.js → chunk-RE6SQEP6.js} +1 -1
- package/browser/{chunk-GT5IX3D6.js → chunk-S4D5UGSM.js} +1 -1
- package/browser/{chunk-IQ5KAZ7I.js → chunk-S65MPEJS.js} +1 -1
- package/browser/{chunk-46D5QBZT.js → chunk-SBTTKQ4L.js} +1 -1
- package/browser/{chunk-UJ63ZNAO.js → chunk-SK6Y77W4.js} +4 -4
- package/browser/{chunk-XBRNDXDZ.js → chunk-SOW7VMSU.js} +1 -1
- package/browser/{chunk-R2Y4JAXW.js → chunk-T3ZHKT2K.js} +1 -1
- package/browser/{chunk-WP2FVSCM.js → chunk-T7PBUS2H.js} +1 -1
- package/browser/{chunk-FD7ICK7T.js → chunk-TTCSYFRX.js} +1 -1
- package/browser/{chunk-3YFVIHNY.js → chunk-UZN4OKOJ.js} +2 -2
- package/browser/{chunk-TBBZ7RAN.js → chunk-WXYXGYFH.js} +1 -1
- package/browser/{chunk-H4U5GDQZ.js → chunk-X2GHGFH2.js} +2 -2
- package/browser/{chunk-LX26RD3F.js → chunk-XFAV2VZL.js} +1 -1
- package/browser/{chunk-YZY45SFB.js → chunk-XSZJISVJ.js} +1 -1
- package/browser/{chunk-5DNDULL7.js → chunk-Y5DX5U5Q.js} +1 -1
- package/browser/{chunk-GNIF2YD2.js → chunk-Y7KCHRMM.js} +1 -1
- package/browser/{chunk-3RQ35Y7Q.js → chunk-YBUERVXV.js} +1 -1
- package/browser/{chunk-V3KYBOFM.js → chunk-YLEKN2EU.js} +1 -1
- package/browser/{chunk-QVI22QDX.js → chunk-YUILNWDI.js} +1 -1
- package/browser/index.html +2 -2
- package/browser/{main-DAVMX2B6.js → main-4PHVOJ3C.js} +2 -2
- package/package.json +1 -1
- package/browser/chunk-3PJCCDIY.js +0 -14
- package/browser/chunk-6LSNTX2C.js +0 -1
- package/browser/chunk-FQVYXDHS.js +0 -3
- package/browser/chunk-KJF3M7DY.js +0 -1
- package/browser/chunk-N6JQHXKN.js +0 -3
- package/browser/chunk-NZBKYR7R.js +0 -1
- package/browser/chunk-OWK34F6X.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{O as b}from"./chunk-TEGIL5RZ.js";import{a as m}from"./chunk-2FWFPV5I.js";import{a as u}from"./chunk-
|
|
1
|
+
import{O as b}from"./chunk-TEGIL5RZ.js";import{a as m}from"./chunk-2FWFPV5I.js";import{a as u}from"./chunk-EAEOJMTA.js";import{p as d,s as h}from"./chunk-LGOSIAUC.js";import{la as n,pa as c}from"./chunk-IEVGW2RT.js";import{k as l}from"./chunk-SNAKHGZS.js";var p=class a{constructor(){}copy(t){return new Promise((o,r)=>{try{if(navigator.clipboard)navigator.clipboard.writeText(t).then(o,r);else{let e=document.createElement("textarea");e.value=t,e.style.position="fixed",document.body.appendChild(e),e.focus(),e.select();try{document.execCommand("copy")?o():r(new Error("Failed to copy with execCommand"))}catch(i){r(i)}finally{document.body.removeChild(e)}}}catch(e){r(e)}})}static \u0275fac=function(o){return new(o||a)};static \u0275prov=n({token:a,factory:a.\u0275fac,providedIn:"root"})};var y=class a{toastr=c(d);httpService=c(h);copyToClipBoard=c(p);createCustomerFromNewNumberAndSendReceipt(t,o,r,e,i){r==0?this.httpService.post(b.CreateCustomerInvoice,{InvoiceID:e.ObjectID,Mobile:t}).subscribe(s=>l(this,null,function*(){this.toastr.success(s.Message,m.Success),yield this.sendReceiptToWhatsapp(t,e,o,i)})):this.toastr.info("WABA is not supported yet",m.Info)}createWhatsappReceipt(t,o,r){let e=I=>new Intl.NumberFormat("id-ID",{style:"currency",currency:"IDR"}).format(I).replace("Rp","").trim().split(",00")?.[0],i=JSON.parse(localStorage.getItem("AccountInfo"))?.BrandName,{ObjectID:s,Final:g,InvoiceNumber:f}=t,v=window.location.host,w=`https://receipt.dealpos.app/s?Data=${window.btoa(`${s}_${v}`)}`;return this.convertWhatsappTemplateMessage({Amount:e(g),Brand:i,Currency:o,Number:f,ReceiptLink:w},r)}convertWhatsappTemplateMessage(t,o){let r=o||u?.whatsappTemplateMessage,e=["Brand","Number","Currency","Amount","ReceiptLink"],i=r;return e.forEach(s=>i=i.replace(`{${s}}`,t[s])),i}redirectToWhatsapp(t,o){let r=t;r=r[0]==="0"?`62${r.slice(1)}`:r;let e=`whatsapp://send?phone=${r}&text=${encodeURIComponent(o)}`;window.location.href=e,this.showToastrWhatsappNoInstalled()}showToastrWhatsappNoInstalled(){let t=!1;window.onblur=function(){t=!0},setTimeout(()=>{t||this.toastr.warning(`Currently, sending an e-receipt automatically opens WhatsApp Desktop, provided the device has the app installed
|
|
2
2
|
`,"WhatsApp not installed")},2e3)}copyToClipboard(t){return new Promise((o,r)=>this.copyToClipBoard.copy(t).then(()=>{this.toastr.info("Message copied to clipboard. If WhatsApp doesn't show the message, please paste it manually.","Receipt Ready",{timeOut:8e3}),o("Copied to clipboard")}).catch(e=>{console.log(e),this.toastr.warning("Could not copy message to clipboard","Clipboard Error",{timeOut:8e3}),r(e)}))}sendReceiptToWhatsapp(t,o,r,e){return l(this,null,function*(){try{let i=this.createWhatsappReceipt(o,r,e);try{yield this.copyToClipboard(i)}finally{this.redirectToWhatsapp(t,i)}}catch(i){console.warn(i),this.toastr.error("Failed to send receipt")}})}static \u0275fac=function(o){return new(o||a)};static \u0275prov=n({token:a,factory:a.\u0275fac})};export{y as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as io}from"./chunk-ZTU3TIGR.js";import{a as no,c as oo}from"./chunk-53VS5DA7.js";import{a as li}from"./chunk-GDNVMJOU.js";import{a as Yn,b as Xn,c as Zn,d as eo,e as to,f as ke}from"./chunk-PPVORSJQ.js";import{a as Kn}from"./chunk-H74MLHRV.js";import{a as zn}from"./chunk-T4MU3R7Y.js";import"./chunk-USD2ALDX.js";import{a as ii}from"./chunk-A565EUMD.js";import{a as $n}from"./chunk-DOCQN2VL.js";import{a as ri}from"./chunk-MZITJQAC.js";import{a as ki}from"./chunk-IZLEZJ6U.js";import{c as Qn,d as Un}from"./chunk-4XJWQAS6.js";import"./chunk-DC3TCY6D.js";import{a as Gn}from"./chunk-CFWHBIM3.js";import{a as qn}from"./chunk-7DAPNQYU.js";import"./chunk-NM3IQUNN.js";import"./chunk-NQX7EX5A.js";import"./chunk-A2EVMYAR.js";import"./chunk-P3KIIKY4.js";import{a as ni,b as jn,c as Ln}from"./chunk-CQLZHUT4.js";import"./chunk-S27D5MBU.js";import{a as Nt}from"./chunk-HGSF7LOB.js";import"./chunk-2VE2WNSA.js";import"./chunk-25H27N7N.js";import{a as Xt}from"./chunk-T7XU5W5A.js";import{b as Rn}from"./chunk-MNJSQKLX.js";import{a as Wn,b as Jn,c as Hn}from"./chunk-OXWQ7ZZS.js";import{a as oi,b as ai}from"./chunk-FW4OCSXV.js";import{a as Bn}from"./chunk-4CPRMZL6.js";import"./chunk-BYXBJQAS.js";import"./chunk-PRVQ3NAP.js";import"./chunk-BYXBJQAS.js";import{b as Vn}from"./chunk-4OEDK7YE.js";import"./chunk-GWKBJZYT.js";import"./chunk-B5IABJO5.js";import{e as Dt}from"./chunk-O2VVATBW.js";import{a as ei}from"./chunk-363IDTE3.js";import"./chunk-FAED643P.js";import{d as kn,e as ti}from"./chunk-WMZLH4YK.js";import"./chunk-72RZBOHX.js";import"./chunk-3RK6DDJD.js";import"./chunk-M3DKYPGC.js";import"./chunk-6WATOQG3.js";import"./chunk-VM4K4MNV.js";import"./chunk-XTCEZONP.js";import"./chunk-LNDHYAFW.js";import"./chunk-ZZBF7AOW.js";import"./chunk-SIQZO2WM.js";import"./chunk-2CL5FM3P.js";import"./chunk-LGINK7BD.js";import{a as Dn,b as xn,c as Sn}from"./chunk-IKKPP4JS.js";import"./chunk-QPAUI5EG.js";import"./chunk-45E6XCHN.js";import"./chunk-SIDUUVNA.js";import"./chunk-KZFNI67M.js";import"./chunk-4BXCIT62.js";import{a as st,c as ct}from"./chunk-D4FCXEV4.js";import{a as Mn,c as In,e as Pn,g as On}from"./chunk-6P2ASCNY.js";import{a as Tn,b as wn}from"./chunk-KJF3M7DY.js";import"./chunk-R2GUMKAU.js";import{a as vn}from"./chunk-BT7NN7PT.js";import{A as Fn,G as An,q as _n,u as Ie,v as Pe,w as Oe,x as Nn,z as En}from"./chunk-26YFRPR2.js";import{b as rt,c as lt}from"./chunk-JBS5UYZC.js";import{O as Ae}from"./chunk-TEGIL5RZ.js";import{a as un,b as fn,c as gn}from"./chunk-EQLHPWVB.js";import{d as xt}from"./chunk-THT6CY5E.js";import{a as z,e as Me,f as Fe,g as Z,l as Zt}from"./chunk-ZTD4APMR.js";import"./chunk-7P3L3ODB.js";import"./chunk-S7FOJJP2.js";import"./chunk-FU2ZGMX4.js";import{a as ve}from"./chunk-2FWFPV5I.js";import"./chunk-SLX34TWD.js";import{E as bn,F as Se,G as Ye,a as Ke,b as Cn,c as be,h as ae,l as me,o as xe,r as yn,s as ze}from"./chunk-DWZ5JTI2.js";import{a as hn}from"./chunk-46D5QBZT.js";import"./chunk-36GWLMZX.js";import{b as he}from"./chunk-WFQIMZGL.js";import{a as S}from"./chunk-WUV22SZ4.js";import{a as dn}from"./chunk-SO3RL6QR.js";import{p as qe,s as re}from"./chunk-LGOSIAUC.js";import{$ as je,Ab as _,Ca as Le,Cb as Qe,D as ot,Db as Ue,E as V,Eb as We,Fb as b,Fc as f,Fd as mn,Gb as r,Gc as g,H as Hi,Hb as a,Hc as wt,I as ye,Ib as M,Ja as Fi,Jb as Je,Kb as it,Lb as kt,Lc as Gt,M as Gi,Mb as Vt,N as Ei,Nb as $t,Nd as pn,Ob as on,Pb as j,Pc as rn,Pd as Kt,Q as qi,Qa as Yi,Qd as zt,Sa as at,Sb as D,Sd as Yt,T as Ki,Tb as bt,Ub as p,Uc as qt,W as Tt,Wa as Xi,Xa as l,Y as X,Yb as Rt,Zb as Bt,_b as jt,aa as Y,ac as Lt,bc as Qt,ca as zi,cc as ht,d as ge,db as Zi,e as et,eb as u,ec as vt,f as Ui,fa as E,ga as le,gb as en,gc as an,gd as Ge,hc as m,ib as A,ic as te,id as ln,jc as $,k as we,kc as He,la as ne,mb as tn,mc as W,n as Wi,nc as L,nd as sn,o as tt,oa as U,ob as ut,oc as J,od as Ee,p as Ji,pa as se,pc as Ut,qc as Wt,qd as cn,rc as Jt,sc as Ai,sd as De,t as d,ta as P,u as Ce,ua as O,v as Ni,vd as ce,wc as Ne,xc as Ht,y as dt,yb as v,yc as ie,zb as nn,zc as _t}from"./chunk-IEVGW2RT.js";import"./chunk-WFMAM73Y.js";import{a as w,b as B,e as Qi,k as yt}from"./chunk-SNAKHGZS.js";var G=class n{constructor(t,e){this.http=e;this.buyForm=t.group({NewOrderID:[""],Order:t.group({Att:[""],SupplierID:[""],Number:[""],Date:[new Date],ID:[S.GuidEmpty]}),Invoice:t.group({ID:[S.GuidEmpty],Due:[new Date],Tax:[0]}),Payment:t.group({ID:[S.GuidEmpty],Amount:[0],MethodID:[0],Code:[""],Note:[""],ImageUrl:[""]})})}outlet=new me({ID:"",Name:"Choose an Outlet"});dueDays=new me(0);deliveryEntityID=new me(S.GuidEmpty);noteForm=new me({Note:"",TagID:"",Currency:{ID:"",ExchangeRate:0,Symbol:""},InvoiceNumber:""});discountAndTaxForm=new me({Discount:{Amount:0,Percentage:0},Tax:{ID:"",CalculationTypeName:"",Rate:0,Label:"",Discontinue:!1}});buyForm;setPONumber(t){let e="";if(t.Seed){let i=t.Seed+"";for(;i.length<t.Digit;)i="0"+i;e=S.StringFormat(t.Prefix,i)}this.buyForm.controls.Order.controls.Number.setValue(e)}setDueDateBasedOnDaysDue(t){console.log(t);let e=this.invoiceDate,i=new Date(S.cloneObject(e));i.setDate(i.getDate()+t),this.buyForm.controls.Invoice.controls.Due.setValue(i)}get dueDate(){return this.buyForm.controls.Invoice.controls.Due.value}get invoiceDate(){return this.buyForm.controls.Order.controls.Date.value}setAmount(t){this.buyForm.controls.Payment.controls.Amount.setValue(t)}setPaymentMethodID(t){this.buyForm.controls.Payment.controls.MethodID.setValue(t)}setTaxAmount(t){this.buyForm.controls.Invoice.controls.Tax.setValue(t)}setNewOrderID(t){this.buyForm.controls.NewOrderID.setValue(t)}setTax(t){let e=w({},this.discountAndTaxForm.value.Discount);this.discountAndTaxForm.setValue({Discount:e,Tax:t})}setCurrency(t){let e=this.noteForm.value;this.noteForm.setValue(B(w({},e),{Currency:t}))}setDeliveryEntityID(t){this.deliveryEntityID.setValue(t)}setdueDays(t){this.dueDays.setValue(t)}setBulkOrderForm(t){this.buyForm.controls.Order.setValue(t)}setBulkNoteForm(t){this.noteForm.setValue(t)}setBulkDiscountAndTaxForm(t){this.discountAndTaxForm.setValue(t)}setOutletForm(t){this.outlet.setValue(t)}setBulkInvoice(t){this.buyForm.controls.Invoice.setValue(w(w({},this.buyForm.controls.Invoice.value),t))}setBulkPayment(t){this.buyForm.controls.Payment.setValue(t)}resetOutletForm(){this.outlet.setValue({ID:"",Name:"Choose an Outlet"})}resetDueDaysForm(){this.dueDays.setValue(0)}resetDeliveryEntityID(){this.deliveryEntityID.setValue(S.GuidEmpty)}resetNoteForm(){this.noteForm.setValue(B(w({},this.noteForm.value),{Note:"",TagID:"",InvoiceNumber:""}))}resetDiscountAndTaxForm(){let t=this.discountAndTaxForm.value;this.discountAndTaxForm.setValue(B(w({},t),{Discount:{Amount:0,Percentage:0}}))}resetBuyForm(){this.buyForm.reset(),this.buyForm.controls.Invoice.controls.ID.setValue(S.GuidEmpty),this.buyForm.controls.Invoice.controls.Due.setValue(new Date),this.buyForm.controls.Order.controls.Date.setValue(new Date),this.buyForm.controls.Order.controls.ID.setValue(S.GuidEmpty),this.generateNumberOnNewTransaction()}generateNumberOnNewTransaction(){this.http.post("/API/Buy/GenerateNumber",{ID:this.outlet.value.ID}).subscribe(t=>{this.setNewOrderID(S.Guid_NewGuid()),this.buyForm.controls.Order.controls.Number.setValue(t.Number)})}static \u0275fac=function(e){return new(e||n)(U(bn),U(re))};static \u0275prov=ne({token:n,factory:n.\u0275fac,providedIn:"root"})};var de=class n{entities$;appConfigJSON$;taxes$;currencies$;supplierPOTypes$;predefinedNotes$;denomination$;defaultDueDays$;constructor(t,e){let i=t.get("/API/Buy2/Load").pipe(E(o=>e.setCurrency(o.Currencies.find(s=>s.ID==o.AppConfigJSON.CoreDefaults.CurrencyID))),X(1));this.denomination$=i.pipe(d(o=>o.Denomination)),this.entities$=i.pipe(d(o=>o.Entities)),this.appConfigJSON$=i.pipe(d(o=>o.AppConfigJSON)),this.taxes$=i.pipe(d(o=>o.Taxes),X(1)),this.currencies$=i.pipe(d(o=>o.Currencies),X(1)),this.supplierPOTypes$=i.pipe(d(o=>o.SupplierPOTypes)),this.predefinedNotes$=i.pipe(d(o=>o.PredefinedNotes)),this.defaultDueDays$=i.pipe(d(o=>o.AppConfigJSON.ModuleBuy.PaymentDialog.DefaultDueDays),E(o=>e.setdueDays(o)),E(o=>e.setDueDateBasedOnDaysDue(o)))}updateDueDays(){this.defaultDueDays$.subscribe()}static \u0275fac=function(e){return new(e||n)(U(re),U(G))};static \u0275prov=ne({token:n,factory:n.\u0275fac,providedIn:"root"})};var mt=class n{returnInvoiceNumber=new me("");invoiceInfo$;constructor(t,e,i){let o=e.outlet.valueChanges.pipe(d(c=>c.ID),z());this.invoiceInfo$=this.returnInvoiceNumber.valueChanges.pipe(V(c=>!!c),le(o),Y(([c,I])=>t.post("/API/Buy/GetSupplierInvoiceRetur2",{EntityID:I,Number:c}).pipe(ye(()=>we))),X(1),z());let s=this.invoiceInfo$.pipe(d(c=>w({},c.Order)),E(c=>{let I={Att:c.Att,SupplierID:{Key:c.SupplierID,Value:c.SupplierName,OnSet:!0},Date:new Date,Number:e.buyForm.controls.Order.controls.Number.value,ID:S.GuidEmpty};e.setBulkOrderForm(I)}),z()),T=this.invoiceInfo$.pipe(d(c=>c.Order),le(i.currencies$,i.appConfigJSON$),E(([c,I,Q])=>{let H=Q.CoreDefaults.CurrencyID,C=I.find(F=>F.ID===H)?.Symbol??"$",N={Note:`Return #${c.Number}`,TagID:c.TypeID,Currency:{ID:c.CurrencyID||H,ExchangeRate:c.CurrencyRate,Symbol:c.CurrencySymbol||C},InvoiceNumber:c.Number};e.setBulkNoteForm(N)}),z()),h=this.invoiceInfo$.pipe(d(c=>c.Order),le(i.taxes$),d(([c,I])=>B(w({},c),{Tax:I.find(Q=>Q.ID===c.TaxTypeID)})),E(c=>{let I={Discount:{Amount:c.DiscountAmount,Percentage:c.Discount},Tax:{ID:c.TaxTypeID,Rate:c.Tax?.Rate,CalculationTypeName:c.Tax?.CalculationTypeName,Label:c.Tax?.Label,Discontinue:!c.Tax?.Label}};e.setBulkDiscountAndTaxForm(I)}),z()),R=this.invoiceInfo$.pipe(d(c=>c.DeliveryEntityID),E(c=>e.setDeliveryEntityID(c)),z()),q=this.invoiceInfo$.pipe(d(c=>c.Invoice),E(c=>{let I={ID:c.ID,Tax:c.Tax};e.setBulkInvoice(I)}),z()),x=this.invoiceInfo$.pipe(d(c=>c.Payment),E(c=>{let I={ID:S.GuidEmpty,Amount:c.Amount,MethodID:c.MethodID,Note:c.Note,Code:c.Code,ImageUrl:c.ImageUrl};e.setBulkPayment(I)}),z());Ce(s,T,h,R,q,x).pipe(z()).subscribe()}static \u0275fac=function(e){return new(e||n)(U(re),U(G),U(de))};static \u0275prov=ne({token:n,factory:n.\u0275fac,providedIn:"root"})};var ee=class n{constructor(t,e,i,o){this.matDialog=o;let s=e.outlet.valueChanges.pipe(d(c=>c.ID));this.addVariantThroughSerial$=this._addVariantThroughSerial.asObservable().pipe(le(s),Y(([c,I])=>t.get(Ae.GetVariantBySerial,[{key:"Serial",value:c},{key:"EntityID",value:I}]).pipe(ye(()=>we))),d(c=>this.setUnitPrice(c)),d(c=>B(w({},c),{Quantity:1,Total:c.UnitPrice,VariantID:c.ID})),d(c=>({action:"addAsSerial",variant:c})));let T=this.variantAutocomplete.valueChanges.pipe(V(c=>S.IsNotEmpty(c)&&c.type=="Code"),d(c=>c.str),le(s),Y(([c,I])=>t.get(Ae.GetVariantByCode,[{key:"Code",value:c},{key:"EntityID",value:I},{key:"Promotion",value:!0}]).pipe(ye(()=>we))),d(c=>this.setUnitPrice(c)),d(c=>B(w({},c),{Quantity:1,Total:c.UnitPrice*((100-c.PriceDiscount)/100),Discount:c.PriceDiscount,VariantID:c.ID}))),h=this.variantAutocomplete.valueChanges.pipe(V(c=>S.IsNotEmpty(c)&&c.type=="ID"),d(c=>c.str)),R=this.variantQuickKey.valueChanges,q=ot(h,R).pipe(le(s),Y(([c,I])=>t.get(Ae.GetVariantByID,[{key:"ID",value:c},{key:"EntityID",value:I}]).pipe(ye(()=>we))),d(c=>this.setUnitPrice(c)),d(c=>B(w({},c),{Quantity:1,Total:c.UnitPrice*((100-c.OrderPriceDiscount)/100),Discount:c.OrderPriceDiscount,VariantID:c.ID}))),x=ot(q,T).pipe(E(c=>{c.CategoryTypeID===1&&this.toastr.info(`${c.Name} is sellable only.`,ve.Info)}),V(c=>c.CategoryTypeID!==1),d(c=>({action:"add",variant:c})),E(()=>{this.cartDisplayRef&&setTimeout(()=>{let c=this.cartDisplayRef.nativeElement.scrollHeight;this.cartDisplayRef.nativeElement.scrollTop=c},1)})),k=i.invoiceInfo$.pipe(d(c=>({action:"returnInvoice",variants:c.Items.map(I=>B(w({},I.Variant),{Quantity:I.Quantity,Total:I.Total,UnitPrice:I.UnitPrice,Discount:I.Discount,Serial:I.Serial,ID:I.ID,DiscountAmount:I.DiscountAmount,VariantID:I.VariantID,UnitQuantity:I.UnitQuantity}))})));this.cart$=ot(x,k,this.deleteVariant$,this.dragDropCart$,this.returnCart$,this.updateVariant$,this.returnVariant$,this.purchaseVariant$,this.clearCart$,this.onEditForm$,this.addVariantThroughSerial$,this.addVariant$,this.onUploadCart$,this.listenRFID$).pipe(Tt((c,I)=>{let Q=[...c],H=[],y=I.action;if(y=="add"){let C=I.variant;H=!!Q.find(F=>F.VariantID==C.ID)?Q.map(F=>F.VariantID==C.ID?B(w({},F),{Quantity:F.Quantity+1,Total:F.Total+F.UnitPrice}):F):[...Q,C]}else if(y=="returnInvoice"||y=="onEditForm")H=I.variants;else if(y=="delete"){let C=I.index;H=Q.filter((N,F)=>F!=C)}else if(y=="sort"){let C=I.ev;H=Q,Mn(H,C.previousIndex,C.currentIndex)}else if(y=="returnCart")H=Q.map(C=>B(w({},C),{Quantity:-Math.abs(C.Quantity),Total:-Math.abs(C.Total)}));else if(y=="update"){let C=I.index;H=Q.map((N,F)=>F==C?I.variant:N)}else if(y=="returnVariant"){let C=I.index;H=Q.map((N,F)=>F==C?B(w({},N),{Quantity:-Math.abs(N.Quantity),Total:-Math.abs(N.Total)}):N)}else if(y=="purchaseVariant"){let C=I.index;H=Q.map((N,F)=>F==C?B(w({},N),{Quantity:Math.abs(N.Quantity),Total:Math.abs(N.Total)}):N)}else if(y=="clearCart")H=[];else if(y=="addAsSerial"){let C=B(w({},I.variant),{Serial:[{Number:I.variant.Serial.Number,Quantity:1,ExpiryDate:I.variant.Serial.ExpiryDate}]});if(!!Q.find(F=>F.ID==C.ID)){let F=C.Serial[0],fe=Q.find(pe=>pe.ID==C.ID),At=!!fe.Serial.find(pe=>pe.Number==F.Number)?[...fe.Serial].map(pe=>pe.Number==F.Number?B(w({},pe),{Quantity:pe.Quantity+1}):pe):[...fe.Serial,F];H=Q.map(pe=>pe.ID==C.ID?B(w({},pe),{Quantity:pe.Quantity+1,Total:pe.Total+pe.UnitPrice,Serial:At}):pe)}else H=[...Q,B(w({},C),{Quantity:1,Total:C.UnitPrice})]}else if(y=="uploadCart")H=[...Q,...I.variants];else if(y=="addNewRow"){let C=I.variant;H=[...Q,C]}else if(y=="rfid"){let C=I.variants;Object.keys(C).forEach(N=>{if(C.hasOwnProperty(N)){let F=C[N];if(F&&Object.keys(F.variant).length>0){let fe=Q.findIndex(Ct=>Ct.Code.toLowerCase()===N.toLowerCase());if(fe!==-1){let Ct=Number(F.count);Q[fe].Quantity+=Ct,Q[fe].Total=+Q[fe].UnitPrice*+Q[fe].Quantity,delete C[N],H=[...Q]}else{let Ct=F.variant,At=Number(F.count),pe=this.setUnitPrice(Ct),co=this.formatItemObject(B(w({},pe),{Quantity:At,Total:+pe.UnitPrice*+At}));delete C[N],H=[...Q,co]}}}})}return H},[]),je([]),X(1)),this.totalVariantOrdered$=this.cart$.pipe(d(c=>c.map(I=>I.Quantity)),d(c=>c.reduce((I,Q)=>I+Q,0)),je(0))}toastr=se(qe);cartDisplayRef;variantAutocomplete=new me;variantQuickKey=new me;_listenRFID=new ge;listenRFID$=this._listenRFID.asObservable().pipe(d(t=>({action:"rfid",variants:t})));_deleteVariant=new ge;deleteVariant$=this._deleteVariant.asObservable().pipe(d(t=>({action:"delete",index:t})));_dragDropCart=new ge;dragDropCart$=this._dragDropCart.asObservable().pipe(d(t=>({action:"sort",ev:t})));_returnCart=new ge;returnCart$=this._returnCart.asObservable().pipe(d(()=>({action:"returnCart"})));_onEditForm=new et(null);onEditForm$=this._onEditForm.asObservable().pipe(V(t=>!!t),d(t=>({action:"onEditForm",variants:t})));_clearCart=new ge;clearCart$=this._clearCart.asObservable().pipe(d(()=>({action:"clearCart"})));_updateVariant=new ge;updateVariant$=this._updateVariant.asObservable().pipe(d(t=>({action:"update",variant:t.variant,index:t.index})));_returnVariant=new ge;returnVariant$=this._returnVariant.asObservable().pipe(d(t=>({action:"returnVariant",index:t})));_purchaseVariant=new ge;purchaseVariant$=this._purchaseVariant.asObservable().pipe(d(t=>({action:"purchaseVariant",index:t})));_addVariant=new ge;addVariant$=this._addVariant.asObservable().pipe(d(t=>({action:"addNewRow",variant:t})));_onUploadCart=new ge;onUploadCart$=this._onUploadCart.asObservable().pipe(d(t=>({action:"uploadCart",variants:t})));cart$;totalVariantOrdered$;_addVariantThroughSerial=new ge;addVariantThroughSerial$;deleteVariant(t){this._deleteVariant.next(t)}dragDropCart(t){this._dragDropCart.next(t)}returnCart(){this._returnCart.next()}updateVariant(t,e){this._updateVariant.next({variant:t,index:e})}returnVariant(t){this._returnVariant.next(t)}purchaseVariant(t){this._purchaseVariant.next(t)}clearCart(){this._clearCart.next()}editForm(t){this._onEditForm.next(t)}addVariant(t){this._addVariant.next(t)}addVariantThroughSerial(t){this._addVariantThroughSerial.next(t)}uploadCart(t){this._onUploadCart.next(t)}setUnitPrice(t){let e=w({},t);return S.IsNotEmpty(t.OrderPrice)?e.UnitPrice=t.OrderPrice:e.UnitPrice=t.UnitCost,e}formatItemObject=t=>{let o=t,{ID:e}=o,i=Qi(o,["ID"]);return B(w({},i),{Quantity:i.Quantity??1,Total:i.Total??i.UnitPrice,VariantID:e})};addCartRFID(t){this._listenRFID.next(t)}static \u0275fac=function(e){return new(e||n)(U(re),U(G),U(mt),U(Z))};static \u0275prov=ne({token:n,factory:n.\u0275fac,providedIn:"root"})};var Ve=class n{_isEdit=new ge;isEdit$;id$;isUnpaid$;dialog=se(Z);constructor(t,e,i,o,s){let T=tt(t.snapshot.queryParams);this.isEdit$=ot(T.pipe(d(y=>!!y.ID)),this._isEdit.asObservable()).pipe(X(1)),this.id$=T.pipe(V(y=>y.ID),d(y=>y.ID));let h=this.id$.pipe(Y(y=>e.post("/api/Buy2/GetDataByID2",{ID:y})),X(1)),R=dt(()=>o.entities$).pipe(Y(y=>h.pipe(d(C=>[C.Order,y]))),E(([y,C])=>{let N={Att:y.Att,SupplierID:{Key:y.SupplierID,Value:y.SupplierName,OnSet:!0},Date:y.Date,Number:y.Number,ID:y.ID};i.setBulkOrderForm(N)}),E(([y,C])=>{let N=C.find(F=>F.ID==y.EntityID);i.setOutletForm(N)})),q=h.pipe(d(y=>y.Items),d(y=>y.map(C=>B(w({},C.Variant),{Quantity:C.Quantity,Total:C.Total,Note:C.Note,UnitPrice:C.UnitPrice,Discount:C.Discount,Serial:C.Serial,ID:C.ID,VariantID:C.VariantID,UnitQuantity:C.UnitQuantity,QtyRequested:C.QtyRequested,DiscountAmount:C.DiscountAmount}))),E(y=>s.editForm(y))),x=dt(()=>o.currencies$).pipe(Y(y=>h.pipe(d(C=>[C.Order,y,C.Invoice]))),d(([y,C,N])=>B(w({},y),{Number:y.Number!=N.Number?N.Number:y.Number,Currency:C.find(F=>F.ID===y.CurrencyID)})),E(y=>{let C={Note:y.Note,TagID:y.TypeID,Currency:w({},y.Currency),InvoiceNumber:y.Number};i.setBulkNoteForm(C)})),k=h.pipe(d(y=>y.DeliveryEntityID),E(y=>i.setDeliveryEntityID(y))),c=dt(()=>o.taxes$).pipe(Y(y=>h.pipe(d(C=>[C.Order,y]))),d(([y,C])=>B(w({},y),{Taxes:C})),E(y=>{let C=y.Taxes.find(F=>F.ID===y.TaxTypeID);C?.Bin&&this.dialog.open(ni,{id:"ModalInfo",data:{title:"Default Tax Discontinued",message:`
|
|
1
|
+
import{a as io}from"./chunk-ZTU3TIGR.js";import{a as no,c as oo}from"./chunk-53VS5DA7.js";import{a as li}from"./chunk-GDNVMJOU.js";import{a as Yn,b as Xn,c as Zn,d as eo,e as to,f as ke}from"./chunk-PPVORSJQ.js";import{a as Kn}from"./chunk-H74MLHRV.js";import{a as zn}from"./chunk-T4MU3R7Y.js";import"./chunk-USD2ALDX.js";import{a as ii}from"./chunk-A565EUMD.js";import{a as $n}from"./chunk-DOCQN2VL.js";import{a as ri}from"./chunk-MZITJQAC.js";import{a as ki}from"./chunk-IZLEZJ6U.js";import{c as Qn,d as Un}from"./chunk-4XJWQAS6.js";import"./chunk-DC3TCY6D.js";import{a as Gn}from"./chunk-CFWHBIM3.js";import{a as qn}from"./chunk-7DAPNQYU.js";import"./chunk-NM3IQUNN.js";import"./chunk-NQX7EX5A.js";import"./chunk-A2EVMYAR.js";import"./chunk-P3KIIKY4.js";import{a as ni,b as jn,c as Ln}from"./chunk-CQLZHUT4.js";import"./chunk-S27D5MBU.js";import{a as Nt}from"./chunk-HGSF7LOB.js";import"./chunk-2VE2WNSA.js";import{a as Xt}from"./chunk-T7XU5W5A.js";import"./chunk-25H27N7N.js";import{b as Rn}from"./chunk-MNJSQKLX.js";import{a as Wn,b as Jn,c as Hn}from"./chunk-OXWQ7ZZS.js";import{a as oi,b as ai}from"./chunk-FW4OCSXV.js";import{a as Bn}from"./chunk-4CPRMZL6.js";import"./chunk-BYXBJQAS.js";import"./chunk-PRVQ3NAP.js";import"./chunk-BYXBJQAS.js";import{b as Vn}from"./chunk-4OEDK7YE.js";import"./chunk-GWKBJZYT.js";import"./chunk-B5IABJO5.js";import{e as Dt}from"./chunk-O2VVATBW.js";import{a as ei}from"./chunk-363IDTE3.js";import"./chunk-FAED643P.js";import{d as kn,e as ti}from"./chunk-WMZLH4YK.js";import"./chunk-72RZBOHX.js";import"./chunk-3RK6DDJD.js";import"./chunk-M3DKYPGC.js";import"./chunk-6WATOQG3.js";import"./chunk-VM4K4MNV.js";import"./chunk-XTCEZONP.js";import"./chunk-LNDHYAFW.js";import"./chunk-ZZBF7AOW.js";import"./chunk-SIQZO2WM.js";import"./chunk-2CL5FM3P.js";import"./chunk-LGINK7BD.js";import{a as Dn,b as xn,c as Sn}from"./chunk-IKKPP4JS.js";import"./chunk-QPAUI5EG.js";import"./chunk-45E6XCHN.js";import"./chunk-SIDUUVNA.js";import"./chunk-KZFNI67M.js";import"./chunk-4BXCIT62.js";import{a as st,c as ct}from"./chunk-D4FCXEV4.js";import{a as Mn,c as In,e as Pn,g as On}from"./chunk-6P2ASCNY.js";import{a as Tn,b as wn}from"./chunk-JCLYKROE.js";import"./chunk-R2GUMKAU.js";import{a as vn}from"./chunk-BT7NN7PT.js";import{A as Fn,G as An,q as _n,u as Ie,v as Pe,w as Oe,x as Nn,z as En}from"./chunk-26YFRPR2.js";import{b as rt,c as lt}from"./chunk-JBS5UYZC.js";import{O as Ae}from"./chunk-TEGIL5RZ.js";import{a as un,b as fn,c as gn}from"./chunk-EQLHPWVB.js";import{d as xt}from"./chunk-THT6CY5E.js";import{a as z,e as Me,f as Fe,g as Z,l as Zt}from"./chunk-ZTD4APMR.js";import"./chunk-7P3L3ODB.js";import"./chunk-S7FOJJP2.js";import"./chunk-FU2ZGMX4.js";import{a as ve}from"./chunk-2FWFPV5I.js";import"./chunk-SLX34TWD.js";import{E as bn,F as Se,G as Ye,a as Ke,b as Cn,c as be,h as ae,l as me,o as xe,r as yn,s as ze}from"./chunk-DWZ5JTI2.js";import{a as hn}from"./chunk-SBTTKQ4L.js";import"./chunk-36GWLMZX.js";import{b as he}from"./chunk-WFQIMZGL.js";import{a as S}from"./chunk-WUV22SZ4.js";import{a as dn}from"./chunk-EAEOJMTA.js";import{p as qe,s as re}from"./chunk-LGOSIAUC.js";import{$ as je,Ab as _,Ca as Le,Cb as Qe,D as ot,Db as Ue,E as V,Eb as We,Fb as b,Fc as f,Fd as mn,Gb as r,Gc as g,H as Hi,Hb as a,Hc as wt,I as ye,Ib as M,Ja as Fi,Jb as Je,Kb as it,Lb as kt,Lc as Gt,M as Gi,Mb as Vt,N as Ei,Nb as $t,Nd as pn,Ob as on,Pb as j,Pc as rn,Pd as Kt,Q as qi,Qa as Yi,Qd as zt,Sa as at,Sb as D,Sd as Yt,T as Ki,Tb as bt,Ub as p,Uc as qt,W as Tt,Wa as Xi,Xa as l,Y as X,Yb as Rt,Zb as Bt,_b as jt,aa as Y,ac as Lt,bc as Qt,ca as zi,cc as ht,d as ge,db as Zi,e as et,eb as u,ec as vt,f as Ui,fa as E,ga as le,gb as en,gc as an,gd as Ge,hc as m,ib as A,ic as te,id as ln,jc as $,k as we,kc as He,la as ne,mb as tn,mc as W,n as Wi,nc as L,nd as sn,o as tt,oa as U,ob as ut,oc as J,od as Ee,p as Ji,pa as se,pc as Ut,qc as Wt,qd as cn,rc as Jt,sc as Ai,sd as De,t as d,ta as P,u as Ce,ua as O,v as Ni,vd as ce,wc as Ne,xc as Ht,y as dt,yb as v,yc as ie,zb as nn,zc as _t}from"./chunk-IEVGW2RT.js";import"./chunk-WFMAM73Y.js";import{a as w,b as B,e as Qi,k as yt}from"./chunk-SNAKHGZS.js";var G=class n{constructor(t,e){this.http=e;this.buyForm=t.group({NewOrderID:[""],Order:t.group({Att:[""],SupplierID:[""],Number:[""],Date:[new Date],ID:[S.GuidEmpty]}),Invoice:t.group({ID:[S.GuidEmpty],Due:[new Date],Tax:[0]}),Payment:t.group({ID:[S.GuidEmpty],Amount:[0],MethodID:[0],Code:[""],Note:[""],ImageUrl:[""]})})}outlet=new me({ID:"",Name:"Choose an Outlet"});dueDays=new me(0);deliveryEntityID=new me(S.GuidEmpty);noteForm=new me({Note:"",TagID:"",Currency:{ID:"",ExchangeRate:0,Symbol:""},InvoiceNumber:""});discountAndTaxForm=new me({Discount:{Amount:0,Percentage:0},Tax:{ID:"",CalculationTypeName:"",Rate:0,Label:"",Discontinue:!1}});buyForm;setPONumber(t){let e="";if(t.Seed){let i=t.Seed+"";for(;i.length<t.Digit;)i="0"+i;e=S.StringFormat(t.Prefix,i)}this.buyForm.controls.Order.controls.Number.setValue(e)}setDueDateBasedOnDaysDue(t){console.log(t);let e=this.invoiceDate,i=new Date(S.cloneObject(e));i.setDate(i.getDate()+t),this.buyForm.controls.Invoice.controls.Due.setValue(i)}get dueDate(){return this.buyForm.controls.Invoice.controls.Due.value}get invoiceDate(){return this.buyForm.controls.Order.controls.Date.value}setAmount(t){this.buyForm.controls.Payment.controls.Amount.setValue(t)}setPaymentMethodID(t){this.buyForm.controls.Payment.controls.MethodID.setValue(t)}setTaxAmount(t){this.buyForm.controls.Invoice.controls.Tax.setValue(t)}setNewOrderID(t){this.buyForm.controls.NewOrderID.setValue(t)}setTax(t){let e=w({},this.discountAndTaxForm.value.Discount);this.discountAndTaxForm.setValue({Discount:e,Tax:t})}setCurrency(t){let e=this.noteForm.value;this.noteForm.setValue(B(w({},e),{Currency:t}))}setDeliveryEntityID(t){this.deliveryEntityID.setValue(t)}setdueDays(t){this.dueDays.setValue(t)}setBulkOrderForm(t){this.buyForm.controls.Order.setValue(t)}setBulkNoteForm(t){this.noteForm.setValue(t)}setBulkDiscountAndTaxForm(t){this.discountAndTaxForm.setValue(t)}setOutletForm(t){this.outlet.setValue(t)}setBulkInvoice(t){this.buyForm.controls.Invoice.setValue(w(w({},this.buyForm.controls.Invoice.value),t))}setBulkPayment(t){this.buyForm.controls.Payment.setValue(t)}resetOutletForm(){this.outlet.setValue({ID:"",Name:"Choose an Outlet"})}resetDueDaysForm(){this.dueDays.setValue(0)}resetDeliveryEntityID(){this.deliveryEntityID.setValue(S.GuidEmpty)}resetNoteForm(){this.noteForm.setValue(B(w({},this.noteForm.value),{Note:"",TagID:"",InvoiceNumber:""}))}resetDiscountAndTaxForm(){let t=this.discountAndTaxForm.value;this.discountAndTaxForm.setValue(B(w({},t),{Discount:{Amount:0,Percentage:0}}))}resetBuyForm(){this.buyForm.reset(),this.buyForm.controls.Invoice.controls.ID.setValue(S.GuidEmpty),this.buyForm.controls.Invoice.controls.Due.setValue(new Date),this.buyForm.controls.Order.controls.Date.setValue(new Date),this.buyForm.controls.Order.controls.ID.setValue(S.GuidEmpty),this.generateNumberOnNewTransaction()}generateNumberOnNewTransaction(){this.http.post("/API/Buy/GenerateNumber",{ID:this.outlet.value.ID}).subscribe(t=>{this.setNewOrderID(S.Guid_NewGuid()),this.buyForm.controls.Order.controls.Number.setValue(t.Number)})}static \u0275fac=function(e){return new(e||n)(U(bn),U(re))};static \u0275prov=ne({token:n,factory:n.\u0275fac,providedIn:"root"})};var de=class n{entities$;appConfigJSON$;taxes$;currencies$;supplierPOTypes$;predefinedNotes$;denomination$;defaultDueDays$;constructor(t,e){let i=t.get("/API/Buy2/Load").pipe(E(o=>e.setCurrency(o.Currencies.find(s=>s.ID==o.AppConfigJSON.CoreDefaults.CurrencyID))),X(1));this.denomination$=i.pipe(d(o=>o.Denomination)),this.entities$=i.pipe(d(o=>o.Entities)),this.appConfigJSON$=i.pipe(d(o=>o.AppConfigJSON)),this.taxes$=i.pipe(d(o=>o.Taxes),X(1)),this.currencies$=i.pipe(d(o=>o.Currencies),X(1)),this.supplierPOTypes$=i.pipe(d(o=>o.SupplierPOTypes)),this.predefinedNotes$=i.pipe(d(o=>o.PredefinedNotes)),this.defaultDueDays$=i.pipe(d(o=>o.AppConfigJSON.ModuleBuy.PaymentDialog.DefaultDueDays),E(o=>e.setdueDays(o)),E(o=>e.setDueDateBasedOnDaysDue(o)))}updateDueDays(){this.defaultDueDays$.subscribe()}static \u0275fac=function(e){return new(e||n)(U(re),U(G))};static \u0275prov=ne({token:n,factory:n.\u0275fac,providedIn:"root"})};var mt=class n{returnInvoiceNumber=new me("");invoiceInfo$;constructor(t,e,i){let o=e.outlet.valueChanges.pipe(d(c=>c.ID),z());this.invoiceInfo$=this.returnInvoiceNumber.valueChanges.pipe(V(c=>!!c),le(o),Y(([c,I])=>t.post("/API/Buy/GetSupplierInvoiceRetur2",{EntityID:I,Number:c}).pipe(ye(()=>we))),X(1),z());let s=this.invoiceInfo$.pipe(d(c=>w({},c.Order)),E(c=>{let I={Att:c.Att,SupplierID:{Key:c.SupplierID,Value:c.SupplierName,OnSet:!0},Date:new Date,Number:e.buyForm.controls.Order.controls.Number.value,ID:S.GuidEmpty};e.setBulkOrderForm(I)}),z()),T=this.invoiceInfo$.pipe(d(c=>c.Order),le(i.currencies$,i.appConfigJSON$),E(([c,I,Q])=>{let H=Q.CoreDefaults.CurrencyID,C=I.find(F=>F.ID===H)?.Symbol??"$",N={Note:`Return #${c.Number}`,TagID:c.TypeID,Currency:{ID:c.CurrencyID||H,ExchangeRate:c.CurrencyRate,Symbol:c.CurrencySymbol||C},InvoiceNumber:c.Number};e.setBulkNoteForm(N)}),z()),h=this.invoiceInfo$.pipe(d(c=>c.Order),le(i.taxes$),d(([c,I])=>B(w({},c),{Tax:I.find(Q=>Q.ID===c.TaxTypeID)})),E(c=>{let I={Discount:{Amount:c.DiscountAmount,Percentage:c.Discount},Tax:{ID:c.TaxTypeID,Rate:c.Tax?.Rate,CalculationTypeName:c.Tax?.CalculationTypeName,Label:c.Tax?.Label,Discontinue:!c.Tax?.Label}};e.setBulkDiscountAndTaxForm(I)}),z()),R=this.invoiceInfo$.pipe(d(c=>c.DeliveryEntityID),E(c=>e.setDeliveryEntityID(c)),z()),q=this.invoiceInfo$.pipe(d(c=>c.Invoice),E(c=>{let I={ID:c.ID,Tax:c.Tax};e.setBulkInvoice(I)}),z()),x=this.invoiceInfo$.pipe(d(c=>c.Payment),E(c=>{let I={ID:S.GuidEmpty,Amount:c.Amount,MethodID:c.MethodID,Note:c.Note,Code:c.Code,ImageUrl:c.ImageUrl};e.setBulkPayment(I)}),z());Ce(s,T,h,R,q,x).pipe(z()).subscribe()}static \u0275fac=function(e){return new(e||n)(U(re),U(G),U(de))};static \u0275prov=ne({token:n,factory:n.\u0275fac,providedIn:"root"})};var ee=class n{constructor(t,e,i,o){this.matDialog=o;let s=e.outlet.valueChanges.pipe(d(c=>c.ID));this.addVariantThroughSerial$=this._addVariantThroughSerial.asObservable().pipe(le(s),Y(([c,I])=>t.get(Ae.GetVariantBySerial,[{key:"Serial",value:c},{key:"EntityID",value:I}]).pipe(ye(()=>we))),d(c=>this.setUnitPrice(c)),d(c=>B(w({},c),{Quantity:1,Total:c.UnitPrice,VariantID:c.ID})),d(c=>({action:"addAsSerial",variant:c})));let T=this.variantAutocomplete.valueChanges.pipe(V(c=>S.IsNotEmpty(c)&&c.type=="Code"),d(c=>c.str),le(s),Y(([c,I])=>t.get(Ae.GetVariantByCode,[{key:"Code",value:c},{key:"EntityID",value:I},{key:"Promotion",value:!0}]).pipe(ye(()=>we))),d(c=>this.setUnitPrice(c)),d(c=>B(w({},c),{Quantity:1,Total:c.UnitPrice*((100-c.PriceDiscount)/100),Discount:c.PriceDiscount,VariantID:c.ID}))),h=this.variantAutocomplete.valueChanges.pipe(V(c=>S.IsNotEmpty(c)&&c.type=="ID"),d(c=>c.str)),R=this.variantQuickKey.valueChanges,q=ot(h,R).pipe(le(s),Y(([c,I])=>t.get(Ae.GetVariantByID,[{key:"ID",value:c},{key:"EntityID",value:I}]).pipe(ye(()=>we))),d(c=>this.setUnitPrice(c)),d(c=>B(w({},c),{Quantity:1,Total:c.UnitPrice*((100-c.OrderPriceDiscount)/100),Discount:c.OrderPriceDiscount,VariantID:c.ID}))),x=ot(q,T).pipe(E(c=>{c.CategoryTypeID===1&&this.toastr.info(`${c.Name} is sellable only.`,ve.Info)}),V(c=>c.CategoryTypeID!==1),d(c=>({action:"add",variant:c})),E(()=>{this.cartDisplayRef&&setTimeout(()=>{let c=this.cartDisplayRef.nativeElement.scrollHeight;this.cartDisplayRef.nativeElement.scrollTop=c},1)})),k=i.invoiceInfo$.pipe(d(c=>({action:"returnInvoice",variants:c.Items.map(I=>B(w({},I.Variant),{Quantity:I.Quantity,Total:I.Total,UnitPrice:I.UnitPrice,Discount:I.Discount,Serial:I.Serial,ID:I.ID,DiscountAmount:I.DiscountAmount,VariantID:I.VariantID,UnitQuantity:I.UnitQuantity}))})));this.cart$=ot(x,k,this.deleteVariant$,this.dragDropCart$,this.returnCart$,this.updateVariant$,this.returnVariant$,this.purchaseVariant$,this.clearCart$,this.onEditForm$,this.addVariantThroughSerial$,this.addVariant$,this.onUploadCart$,this.listenRFID$).pipe(Tt((c,I)=>{let Q=[...c],H=[],y=I.action;if(y=="add"){let C=I.variant;H=!!Q.find(F=>F.VariantID==C.ID)?Q.map(F=>F.VariantID==C.ID?B(w({},F),{Quantity:F.Quantity+1,Total:F.Total+F.UnitPrice}):F):[...Q,C]}else if(y=="returnInvoice"||y=="onEditForm")H=I.variants;else if(y=="delete"){let C=I.index;H=Q.filter((N,F)=>F!=C)}else if(y=="sort"){let C=I.ev;H=Q,Mn(H,C.previousIndex,C.currentIndex)}else if(y=="returnCart")H=Q.map(C=>B(w({},C),{Quantity:-Math.abs(C.Quantity),Total:-Math.abs(C.Total)}));else if(y=="update"){let C=I.index;H=Q.map((N,F)=>F==C?I.variant:N)}else if(y=="returnVariant"){let C=I.index;H=Q.map((N,F)=>F==C?B(w({},N),{Quantity:-Math.abs(N.Quantity),Total:-Math.abs(N.Total)}):N)}else if(y=="purchaseVariant"){let C=I.index;H=Q.map((N,F)=>F==C?B(w({},N),{Quantity:Math.abs(N.Quantity),Total:Math.abs(N.Total)}):N)}else if(y=="clearCart")H=[];else if(y=="addAsSerial"){let C=B(w({},I.variant),{Serial:[{Number:I.variant.Serial.Number,Quantity:1,ExpiryDate:I.variant.Serial.ExpiryDate}]});if(!!Q.find(F=>F.ID==C.ID)){let F=C.Serial[0],fe=Q.find(pe=>pe.ID==C.ID),At=!!fe.Serial.find(pe=>pe.Number==F.Number)?[...fe.Serial].map(pe=>pe.Number==F.Number?B(w({},pe),{Quantity:pe.Quantity+1}):pe):[...fe.Serial,F];H=Q.map(pe=>pe.ID==C.ID?B(w({},pe),{Quantity:pe.Quantity+1,Total:pe.Total+pe.UnitPrice,Serial:At}):pe)}else H=[...Q,B(w({},C),{Quantity:1,Total:C.UnitPrice})]}else if(y=="uploadCart")H=[...Q,...I.variants];else if(y=="addNewRow"){let C=I.variant;H=[...Q,C]}else if(y=="rfid"){let C=I.variants;Object.keys(C).forEach(N=>{if(C.hasOwnProperty(N)){let F=C[N];if(F&&Object.keys(F.variant).length>0){let fe=Q.findIndex(Ct=>Ct.Code.toLowerCase()===N.toLowerCase());if(fe!==-1){let Ct=Number(F.count);Q[fe].Quantity+=Ct,Q[fe].Total=+Q[fe].UnitPrice*+Q[fe].Quantity,delete C[N],H=[...Q]}else{let Ct=F.variant,At=Number(F.count),pe=this.setUnitPrice(Ct),co=this.formatItemObject(B(w({},pe),{Quantity:At,Total:+pe.UnitPrice*+At}));delete C[N],H=[...Q,co]}}}})}return H},[]),je([]),X(1)),this.totalVariantOrdered$=this.cart$.pipe(d(c=>c.map(I=>I.Quantity)),d(c=>c.reduce((I,Q)=>I+Q,0)),je(0))}toastr=se(qe);cartDisplayRef;variantAutocomplete=new me;variantQuickKey=new me;_listenRFID=new ge;listenRFID$=this._listenRFID.asObservable().pipe(d(t=>({action:"rfid",variants:t})));_deleteVariant=new ge;deleteVariant$=this._deleteVariant.asObservable().pipe(d(t=>({action:"delete",index:t})));_dragDropCart=new ge;dragDropCart$=this._dragDropCart.asObservable().pipe(d(t=>({action:"sort",ev:t})));_returnCart=new ge;returnCart$=this._returnCart.asObservable().pipe(d(()=>({action:"returnCart"})));_onEditForm=new et(null);onEditForm$=this._onEditForm.asObservable().pipe(V(t=>!!t),d(t=>({action:"onEditForm",variants:t})));_clearCart=new ge;clearCart$=this._clearCart.asObservable().pipe(d(()=>({action:"clearCart"})));_updateVariant=new ge;updateVariant$=this._updateVariant.asObservable().pipe(d(t=>({action:"update",variant:t.variant,index:t.index})));_returnVariant=new ge;returnVariant$=this._returnVariant.asObservable().pipe(d(t=>({action:"returnVariant",index:t})));_purchaseVariant=new ge;purchaseVariant$=this._purchaseVariant.asObservable().pipe(d(t=>({action:"purchaseVariant",index:t})));_addVariant=new ge;addVariant$=this._addVariant.asObservable().pipe(d(t=>({action:"addNewRow",variant:t})));_onUploadCart=new ge;onUploadCart$=this._onUploadCart.asObservable().pipe(d(t=>({action:"uploadCart",variants:t})));cart$;totalVariantOrdered$;_addVariantThroughSerial=new ge;addVariantThroughSerial$;deleteVariant(t){this._deleteVariant.next(t)}dragDropCart(t){this._dragDropCart.next(t)}returnCart(){this._returnCart.next()}updateVariant(t,e){this._updateVariant.next({variant:t,index:e})}returnVariant(t){this._returnVariant.next(t)}purchaseVariant(t){this._purchaseVariant.next(t)}clearCart(){this._clearCart.next()}editForm(t){this._onEditForm.next(t)}addVariant(t){this._addVariant.next(t)}addVariantThroughSerial(t){this._addVariantThroughSerial.next(t)}uploadCart(t){this._onUploadCart.next(t)}setUnitPrice(t){let e=w({},t);return S.IsNotEmpty(t.OrderPrice)?e.UnitPrice=t.OrderPrice:e.UnitPrice=t.UnitCost,e}formatItemObject=t=>{let o=t,{ID:e}=o,i=Qi(o,["ID"]);return B(w({},i),{Quantity:i.Quantity??1,Total:i.Total??i.UnitPrice,VariantID:e})};addCartRFID(t){this._listenRFID.next(t)}static \u0275fac=function(e){return new(e||n)(U(re),U(G),U(mt),U(Z))};static \u0275prov=ne({token:n,factory:n.\u0275fac,providedIn:"root"})};var Ve=class n{_isEdit=new ge;isEdit$;id$;isUnpaid$;dialog=se(Z);constructor(t,e,i,o,s){let T=tt(t.snapshot.queryParams);this.isEdit$=ot(T.pipe(d(y=>!!y.ID)),this._isEdit.asObservable()).pipe(X(1)),this.id$=T.pipe(V(y=>y.ID),d(y=>y.ID));let h=this.id$.pipe(Y(y=>e.post("/api/Buy2/GetDataByID2",{ID:y})),X(1)),R=dt(()=>o.entities$).pipe(Y(y=>h.pipe(d(C=>[C.Order,y]))),E(([y,C])=>{let N={Att:y.Att,SupplierID:{Key:y.SupplierID,Value:y.SupplierName,OnSet:!0},Date:y.Date,Number:y.Number,ID:y.ID};i.setBulkOrderForm(N)}),E(([y,C])=>{let N=C.find(F=>F.ID==y.EntityID);i.setOutletForm(N)})),q=h.pipe(d(y=>y.Items),d(y=>y.map(C=>B(w({},C.Variant),{Quantity:C.Quantity,Total:C.Total,Note:C.Note,UnitPrice:C.UnitPrice,Discount:C.Discount,Serial:C.Serial,ID:C.ID,VariantID:C.VariantID,UnitQuantity:C.UnitQuantity,QtyRequested:C.QtyRequested,DiscountAmount:C.DiscountAmount}))),E(y=>s.editForm(y))),x=dt(()=>o.currencies$).pipe(Y(y=>h.pipe(d(C=>[C.Order,y,C.Invoice]))),d(([y,C,N])=>B(w({},y),{Number:y.Number!=N.Number?N.Number:y.Number,Currency:C.find(F=>F.ID===y.CurrencyID)})),E(y=>{let C={Note:y.Note,TagID:y.TypeID,Currency:w({},y.Currency),InvoiceNumber:y.Number};i.setBulkNoteForm(C)})),k=h.pipe(d(y=>y.DeliveryEntityID),E(y=>i.setDeliveryEntityID(y))),c=dt(()=>o.taxes$).pipe(Y(y=>h.pipe(d(C=>[C.Order,y]))),d(([y,C])=>B(w({},y),{Taxes:C})),E(y=>{let C=y.Taxes.find(F=>F.ID===y.TaxTypeID);C?.Bin&&this.dialog.open(ni,{id:"ModalInfo",data:{title:"Default Tax Discontinued",message:`
|
|
2
2
|
<div class="d-flex justify-content-center my-4">
|
|
3
3
|
<img class="img-2x" src="https://cdn.dealpos.xyz/web-image/globalerror.svg"
|
|
4
4
|
alt="Empty Sales Order Tag" />
|
|
@@ -20,5 +20,5 @@ import{a as io}from"./chunk-ZTU3TIGR.js";import{a as no,c as oo}from"./chunk-53V
|
|
|
20
20
|
<p class="text-center">
|
|
21
21
|
Please change the default tax or re-activate the tax <a href="/menu/Setup/Payment/Tax">here</a>.
|
|
22
22
|
</p>
|
|
23
|
-
`,headerType:ve.Error},width:"31rem"})}updateTax(){this.updateDefaultTax$.pipe(Ei(1)).subscribe()}updatePaymentMethodID(){this.updatePaymentMethodID$.pipe(Ei(1)).subscribe()}static \u0275fac=function(e){return new(e||n)(U(re),U(G),U(Ve),U(de),U($e))};static \u0275prov=ne({token:n,factory:n.\u0275fac,providedIn:"root"})};function po(n,t){if(n&1&&(r(0,"mat-option",7),m(1),a()),n&2){let e=t.$implicit;b("value",e),l(),$(" ",e.Value," ")}}function uo(n,t){if(n&1){let e=j();r(0,"i",8),D("click",function(){P(e);let o=p();return O(o.openSupplierDetail())}),a()}}var ci=class n{constructor(t,e,i,o){this.http=t;this.form=e;this.matDialog=i;this.router=o}supplierPOTypes;appConfigJSON;filteredSuppliers$;supplier=new me("");disabled=!1;onChange=t=>{};onTouched=()=>{};ngOnInit(){this.filteredSuppliers$=this.supplier.valueChanges.pipe(V(i=>typeof i=="string"&&i.length>=3),Gi(300),Y(i=>this.http.get("/API/AC/GetSupplierSuggestion",[{key:"count",value:100},{key:"prefix",value:i}]))),this.supplier.valueChanges.pipe(V(i=>typeof i!="string"),d(i=>i),E(i=>i?.Key!=S.GuidEmpty&&S.IsNotEmpty(i)?this.onChange(i.Key):this.onChange(null))).pipe(V(i=>S.IsNotEmpty(i)&&!i.OnSet),Y(i=>this.http.post("/API/Contact/GetSupplierDTO",{id:i.Key}).pipe(ye(()=>we))),d(i=>i.DaysDue),V(i=>i!=0),E(i=>this.form.setdueDays(i)),E(i=>this.form.setDueDateBasedOnDaysDue(i))).subscribe()}writeValue(t){this.supplier.setValue(t)}registerOnChange(t){this.onChange=t}registerOnTouched(t){this.onTouched=t}setDisabledState(t){this.disabled=t}displaySupplierNameFn(t){return t?.Value}openNewSupplierModal(){this.matDialog.open(Qn,{data:{options:this.supplierPOTypes,config:this.appConfigJSON.ModuleContact,type:"supplier",title:"New Supplier Form"}}).afterClosed().pipe(V(t=>S.IsNotEmpty(t.supplier.Name)),Y(t=>{let e={contact:t.supplier,type:"supplier",groups:t.supplier.Group?t.supplier.Group:[]};return this.http.post("/API/Contact/Supplier/Create",e).pipe(d(i=>({Key:i.ID,Value:t.supplier.Name})))})).subscribe(t=>{this.writeValue(t),this.onChange(t.Key)})}openSupplierDetail(){let t=this.supplier.value.Key;if(S.IsNotEmpty(t)){let e=this.router.serializeUrl(this.router.createUrlTree(["/menu/Contacts/Contact/Suppliers/Info"],{queryParams:{ID:t}}));window.open(e,"_blank")}}static \u0275fac=function(e){return new(e||n)(u(re),u(G),u(Z),u(Kt))};static \u0275cmp=A({type:n,selectors:[["POS-supplier-autocomplete"]],inputs:{supplierPOTypes:"supplierPOTypes",appConfigJSON:"appConfigJSON"},features:[Ne([{provide:Ke,multi:!0,useExisting:n}])],decls:8,vars:7,consts:[["auto","matAutocomplete"],[1,"d-flex","align-items-center","position-relative"],["matTooltipPosition","above","matTooltip","New Supplier Form",1,"fa-light","fa-user-plus","position-absolute",2,"font-size","12px",3,"click"],["type","text","placeholder","Assign Supplier",3,"formControl","matAutocomplete"],[3,"displayWith"],[3,"value",4,"ngFor","ngForOf"],["matTooltipPosition","left","matTooltip","Open Supplier Details",1,"fa-regular","fa-arrow-up-right-from-square","position-absolute",2,"font-size","12px","right","0","cursor","pointer"],[3,"value"],["matTooltipPosition","left","matTooltip","Open Supplier Details",1,"fa-regular","fa-arrow-up-right-from-square","position-absolute",2,"font-size","12px","right","0","cursor","pointer",3,"click"]],template:function(e,i){if(e&1){let o=j();r(0,"div",1)(1,"i",2),D("click",function(){return P(o),O(i.openNewSupplierModal())}),a(),M(2,"input",3),r(3,"mat-autocomplete",4,0),ut(5,po,2,2,"mat-option",5),f(6,"async"),a(),v(7,uo,1,0,"i",6),a()}if(e&2){let o=ht(4);l(2),b("formControl",i.supplier)("matAutocomplete",o),l(),b("displayWith",i.displaySupplierNameFn),l(2),b("ngForOf",g(6,5,i.filteredSuppliers$)),l(2),_(i.supplier&&(i.supplier!=null&&i.supplier.value)&&(!(i.supplier==null||i.supplier.value==null)&&i.supplier.value.Key)?7:-1)}},dependencies:[ce,ln,Fn,Nn,_n,En,Ye,be,ae,ze,lt,rt,Un,Ee],styles:["input[_ngcontent-%COMP%]{width:100%;height:38px!important;border-radius:.375rem;border:1px solid #ced4da;padding-left:32px;padding-right:32px}input[_ngcontent-%COMP%]::placeholder{color:#ced4da}i.fa-user-plus[_ngcontent-%COMP%]{font-size:16px;top:10.6px;left:13px}i.fa-arrow-up-right-from-square[_ngcontent-%COMP%]{transform:none;position:absolute;margin-right:13px;top:10.6px;font-size:12px}"]})};var go=["quantity"],Et=n=>({selected:n}),Co=()=>["/menu/Products/Catalog/Variants/Info"],yo=n=>({ID:n}),bo=n=>({"table-light":n});function ho(n,t){if(n&1){let e=j();r(0,"a",18),D("click",function(){P(e);let o=p();return O(o.onTabChange("Discount"))}),m(1," Discount "),a()}if(n&2){let e=p();b("ngClass",ie(1,Et,e.tabState=="Discount"))}}function vo(n,t){if(n&1){let e=j();r(0,"a",19),D("click",function(){P(e);let o=p();return O(o.onTabChange("Product"))}),m(1," Product "),a()}if(n&2){let e=p();b("ngClass",ie(1,Et,e.tabState=="Product"))}}function _o(n,t){if(n&1){let e=j();r(0,"a",20),D("click",function(){P(e);let o=p();return O(o.onTabChange("Serial"))}),m(1," Serial "),a()}if(n&2){let e=p();b("ngClass",ie(1,Et,e.tabState=="Serial"))}}function Do(n,t){if(n&1&&(r(0,"div",13)(1,"div",27),M(2,"POS-variant-autocomplete",28),a()()),n&2){let e=p(2);l(2),b("formControl",e.variantAutocomplete)("isOnModalVariant",!0)}}function xo(n,t){if(n&1&&(r(0,"span"),m(1),a()),n&2){let e=p(2);l(),$("(",e.variant.UOMName,")")}}function So(n,t){if(n&1){let e=j();r(0,"div",23)(1,"strong")(2,"span"),m(3),a()(),r(4,"input",29),J("ngModelChange",function(o){P(e);let s=p(2);return L(s.variant.UnitQuantity,o)||(s.variant.UnitQuantity=o),O(o)}),D("ngModelChange",function(){P(e);let o=p(2);return O(o.onUnitQtyChange())}),a()()}if(n&2){let e=p(2);l(3),te(e.unitQtyLabel),l(),b("preventNegative",!0)("decimalPlaces",e.isSerialItem?0:4),W("ngModel",e.variant.UnitQuantity)}}function Mo(n,t){if(n&1){let e=j();r(0,"div",24)(1,"strong"),m(2,"Cost"),a(),r(3,"input",30,1),J("ngModelChange",function(o){P(e);let s=p(2);return L(s.variant.UnitPrice,o)||(s.variant.UnitPrice=o),O(o)}),D("ngModelChange",function(){P(e);let o=p(2);return O(o.onPriceChange())}),a()()}if(n&2){let e=p(2);l(3),b("simpleKeyboard",e.keyboard),W("ngModel",e.variant.UnitPrice)}}function Io(n,t){if(n&1){let e=j();r(0,"div",12),v(1,Do,3,2,"div",13),r(2,"div",13)(3,"div",21)(4,"strong"),m(5," Qty "),v(6,xo,2,1,"span"),a(),r(7,"input",22,0),J("ngModelChange",function(o){P(e);let s=p();return L(s.variant.Quantity,o)||(s.variant.Quantity=o),O(o)}),D("ngModelChange",function(){P(e);let o=p();return O(o.onQtyChange())}),a()(),v(9,So,5,4,"div",23),v(10,Mo,5,2,"div",24),a(),r(11,"div",13)(12,"div",25)(13,"POS-tinymce-editor",26),J("ngModelChange",function(o){P(e);let s=p();return L(s.variant.Note,o)||(s.variant.Note=o),O(o)}),a()()()()}if(n&2){let e=p();l(),_(e.isCreate?1:-1),l(5),_(e.variant.UOMName?6:-1),l(),b("simpleKeyboard",e.keyboard)("decimalPlaces",e.isSerialItem?0:4),W("ngModel",e.variant.Quantity),b("disabled",e.isEditBuyForm&&e.isSerialItem),l(2),_(e.unitQtyLabel?9:-1),l(),_(e.role.product.Cost?10:-1),l(3),W("ngModel",e.variant.Note)}}function Po(n,t){if(n&1&&(r(0,"div",44)(1,"div",33)(2,"strong"),m(3,"Discount Amount / Qty"),a()(),r(4,"div",34)(5,"div",46)(6,"p"),m(7),f(8,"number"),a()()()()),n&2){let e=p(2);l(7),te(g(8,1,e.variant.DiscountAmount))}}function Oo(n,t){if(n&1&&(r(0,"div",52)(1,"h5",58),m(2),f(3,"number"),a()()),n&2){let e=p(3);l(2),$(" ",g(3,1,e.variant.Discount),"% ")}}function To(n,t){if(n&1&&(r(0,"div",53)(1,"h5"),m(2),f(3,"number"),a(),r(4,"span",51),m(5,"x"),a(),r(6,"h5"),m(7),f(8,"number"),a()()),n&2){let e=p(3);l(2),te(g(3,2,e.variant.Quantity)),l(5),te(g(8,4,e.variant.DiscountAmount))}}function wo(n,t){if(n&1&&(r(0,"h5",56),m(1),f(2,"number"),a()),n&2){let e=p(3);l(),$(" -",g(2,1,e.totalBeforeDiscount()*(e.variant.Discount/100))," ")}}function No(n,t){if(n&1&&(r(0,"div",55)(1,"h5",56),m(2),f(3,"number"),a()()),n&2){let e=p(3);l(2),$(" -",g(3,1,e.variant.Quantity*e.variant.DiscountAmount)," ")}}function Eo(n,t){if(n&1&&(r(0,"div",57)(1,"div",59)(2,"h5"),m(3,"Grand Total"),a()(),r(4,"div",59)(5,"h5"),m(6),f(7,"number"),a()()()),n&2){let e=p(3);l(6),te(g(7,1,e.totalAfterDiscount()))}}function Fo(n,t){if(n&1&&(r(0,"div",45)(1,"div",47)(2,"h4"),m(3,"Discount Simulation"),a(),r(4,"h4",48),m(5),a()(),r(6,"div",49)(7,"div",33)(8,"div",50)(9,"h5"),m(10),f(11,"number"),a(),r(12,"span",51),m(13,"x"),a(),r(14,"h5"),m(15),f(16,"number"),a()(),v(17,Oo,4,3,"div",52),v(18,To,9,6,"div",53),a(),r(19,"div",33)(20,"div",54)(21,"h5"),m(22),f(23,"number"),a()(),r(24,"div",55),v(25,wo,3,3,"h5",56),a(),v(26,No,4,3,"div",55),a(),v(27,Eo,8,3,"div",57),a()()),n&2){let e=p(2);l(5),$(" ",e.variant==null?null:e.variant.Name," "),l(5),te(g(11,9,e.variant.Quantity)),l(5),te(g(16,11,e.variant.UnitPrice)),l(2),_(e.variant.Discount?17:-1),l(),_(e.variant.DiscountAmount>0?18:-1),l(4),te(g(23,13,e.totalBeforeDiscount())),l(3),_(e.variant.Discount?25:-1),l(),_(e.variant.DiscountAmount>0?26:-1),l(),_(e.variant.DiscountAmount>0||e.variant.Discount>0?27:-1)}}function Ao(n,t){if(n&1){let e=j();r(0,"div",13)(1,"div",31)(2,"div",32)(3,"div",33)(4,"strong"),m(5,"Discount %"),a()(),r(6,"div",34)(7,"input",35,2),J("ngModelChange",function(o){P(e);let s=p();return L(s.variant.Discount,o)||(s.variant.Discount=o),O(o)}),D("ngModelChange",function(){P(e);let o=p();return O(o.onDiscountChange())}),a()()(),r(9,"div",36)(10,"div",33)(11,"strong"),m(12,"Discount Amount"),a()(),r(13,"div",34)(14,"input",37,2),J("ngModelChange",function(o){P(e);let s=p();return L(s.inputedDiscountAmount,o)||(s.inputedDiscountAmount=o),O(o)}),D("ngModelChange",function(o){P(e);let s=p();return O(s.onDiscountAmountChange(o))}),a()()(),r(16,"div",38)(17,"div",39)(18,"input",40),J("ngModelChange",function(o){P(e);let s=p();return L(s.isDiscMultipliciedQty,o)||(s.isDiscMultipliciedQty=o),O(o)}),D("ngModelChange",function(){P(e);let o=p();return O(o.onSwitchDiscountTypeChange())}),a()(),r(19,"div",41)(20,"strong"),m(21,"*Quantity"),a(),r(22,"span",42),M(23,"i",43),a()()(),v(24,Po,9,3,"div",44),a(),v(25,Fo,28,15,"div",45),a()}if(n&2){let e=p();l(7),b("simpleKeyboard",e.keyboard),W("ngModel",e.variant.Discount),b("min",0)("readonly",!e.role.sell.Discount),l(7),b("simpleKeyboard",e.keyboard),W("ngModel",e.inputedDiscountAmount),b("max",e.variant.UnitPrice*e.variant.Quantity)("min",0)("readonly",!e.role.sell.Discount),l(4),W("ngModel",e.isDiscMultipliciedQty),l(6),_(e.isDiscMultipliciedQty()?-1:24),l(),_(e.role.product.Cost?25:-1)}}function ko(n,t){n&1&&(M(0,"i",65),r(1,"h6"),m(2,"No Image"),a())}function Vo(n,t){if(n&1&&M(0,"img",62),n&2){let e=p(2);b("src",e.variant.ThumbnailUrl,at)}}function $o(n,t){if(n&1){let e=j();r(0,"button",78),D("click",function(){P(e);let o=p(),s=p(2);return O(s.setQuantityToMax(o))}),m(1," Place Order "),a()}}function Ro(n,t){if(n&1&&(r(0,"tbody")(1,"tr")(2,"th",66),M(3,"i",67),m(4,"Inventory "),a(),r(5,"th",66),M(6,"i",68),m(7),a(),r(8,"th",66),M(9,"i",69),m(10," Diff "),a(),r(11,"th",66),M(12,"i",70),m(13," Action "),a()(),r(14,"tr")(15,"th",71),m(16,"On Hand"),a(),r(17,"td",72),m(18),f(19,"number"),a(),M(20,"td",73)(21,"td",74),a(),r(22,"tr")(23,"th",71),m(24,"Allocated"),a(),r(25,"td",72),m(26),f(27,"number"),a()(),r(28,"tr")(29,"th",71),m(30,"Available"),a(),r(31,"td",72),m(32),f(33,"number"),a()(),r(34,"tr")(35,"th",71),m(36,"ROP"),a(),r(37,"td",72),m(38),f(39,"number"),a(),r(40,"td",56),m(41),f(42,"number"),a()(),r(43,"tr")(44,"th",71),m(45,"Max"),a(),r(46,"td",72),m(47),f(48,"number"),a(),r(49,"td",75),m(50),f(51,"number"),a(),r(52,"td",76),v(53,$o,2,0,"button",77),a()()()),n&2){let e=t,i=p(2);l(7),$("",i.outletName," "),l(11),$(" ",g(19,12,e.onHand)," "),l(8),$(" ",g(27,14,e.allocated)," "),l(6),$(" ",g(33,16,e.onHand-e.allocated)," "),l(6),$(" ",g(39,18,e.rop)," "),l(3),He(" ",e.ropDiff>=0?"+":"","",g(42,20,e.ropDiff)," "),l(6),$(" ",g(48,22,e.max)," "),l(3),He(" ",e.maxDiff>=0?"+":"","",g(51,24,e.maxDiff)," "),l(2),b("ngClass",ie(26,bo,i.variant.Quantity==e.max-e.onHand-e.allocated)),l(),_(i.variant.Quantity!=e.max-e.onHand-e.allocated?53:-1)}}function Bo(n,t){if(n&1&&(r(0,"div",14)(1,"div",60)(2,"a",61),v(3,ko,3,0)(4,Vo,1,1,"img",62),a()(),r(5,"div",63)(6,"table",64),v(7,Ro,54,28,"tbody"),f(8,"async"),a()()()),n&2){let e,i=p();l(2),b("routerLink",Ht(6,Co))("queryParams",ie(7,yo,i.variant==null?null:i.variant.ID)),l(),_((i.variant==null?null:i.variant.ThumbnailUrl)==null?3:4),l(4),_((e=g(8,4,i.variantStock$))?7:-1,e)}}function jo(n,t){if(n&1){let e=j();r(0,"POS-tab-serial",79),J("variantChange",function(o){P(e);let s=p();return L(s.variant,o)||(s.variant=o),O(o)})("isFocusOnSerialInputChange",function(o){P(e);let s=p();return L(s.isFocusOnSerialInput,o)||(s.isFocusOnSerialInput=o),O(o)})("serialsChange",function(o){P(e);let s=p();return L(s.serials,o)||(s.serials=o),O(o)}),a()}if(n&2){let e=p();b("disabledEditQty",e.isEditBuyForm)("outletID",e.outletID),W("variant",e.variant)("isFocusOnSerialInput",e.isFocusOnSerialInput)("serials",e.serials)}}var pt=class n{constructor(t,e,i,o,s,T){this.dialogRef=t;this.http=i;this.role=o;this.toastr=T;this.config=new Ie,this.config.title=e.variant?.Name??"Add Variant",this.config.customWidth="700px",this.config.noPadding=!0,this.appConfigJSON=e.appConfigJSON,this.unitQtyLabel=this.appConfigJSON.ModuleSell.ProductDialog.UnitQtyLabel,this.numpadVisible=this.appConfigJSON.ModuleSell.NumPadVisible,this.numpadVisible&&(this.keyboard=s.keyboard),this.isEditBuyForm=e.isEdit,this.outletID=e.outletID,this.outletName=e.outletName,this.variant=e.variant;let R=this.appConfigJSON?.ModuleSell?.ProductDialog?.QuantityToOneInDialog?1:null;if(this.variant)this.isSerialItem=this.variant.TypeID==4,this.variantStock$=this.getOnInventory(),this.inputedDiscountAmount.set(this.variant.DiscountAmount),this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount();else{this.isCreate=!0,this.variant={Name:"",Quantity:R,UnitQuantity:1,OrderPrice:0,Total:0,Note:"",UnitPrice:0,ThumbnailUrl:"",UOMName:"",TypeID:0,Discount:0,ID:"",DiscountAmount:0,Serial:[]};let q=this.variantAutocomplete.valueChanges.pipe(V(c=>c.type=="Code"),d(c=>c.str),Y(c=>i.get(Ae.GetVariantByCode,[{key:"Code",value:c},{key:"EntityID",value:this.outletID},{key:"Promotion",value:!0}]).pipe(ye(()=>we))),d(c=>this.setUnitPrice(c)),d(c=>B(w({},c),{Quantity:R,Total:c.UnitPrice,Discount:c.PriceDiscount}))),x=this.variantAutocomplete.valueChanges.pipe(V(c=>c.type=="ID"),d(c=>c.str),Y(c=>i.get(Ae.GetVariantByID,[{key:"ID",value:c},{key:"EntityID",value:this.outletID},{key:"Promotion",value:!1}]).pipe(ye(()=>we))),d(c=>this.setUnitPrice(c)),d(c=>B(w({},c),{Quantity:R,Total:c.UnitPrice,Discount:c.PriceDiscount})));ot(q,x).pipe(E(c=>this.setFocusField("quantity")),X(1)).subscribe(c=>{this.variant=c,this.isSerialItem=this.variant.TypeID==4,this.showInventory=!0,this.variantStock$=this.getOnInventory(),this.inputedDiscountAmount.set(this.variant.DiscountAmount),this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()})}}calculatorTab=qt(ri);variantAutocomplete=new me;_quantityElement;variant;variantStock$=we;isSerialItem=!1;outletID;outletName;appConfigJSON;numpadVisible;keyboard;isEditBuyForm=!1;unitQtyLabel;config;tabState="Cart";isCreate=!1;showInventory=!1;serials=[];isFocusOnSerialInput=!1;_onGetInventory=new et(void 0);onGetInventory$=this._onGetInventory.asObservable();isDiscMultipliciedQty=Le(!0);totalBeforeDiscount=Le(0);totalAfterDiscount=Le(0);inputedDiscountAmount=Le(0);setFocusField(t){switch(t){case"quantity":this._quantityElement.nativeElement.focus();break}}onPriceChange(){this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()}onQtyChange(){this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()}onUnitQtyChange(){this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()}onDiscountChange(){this.calculateTotalAfterDiscount(),this.calculateTotalAfterDiscount()}onDiscountAmountChange(t){this.calculateDiscountAmount(t),this.calculateTotalAfterDiscount()}onSwitchDiscountTypeChange(){this.calculateDiscAmountOnSwitch(),this.calculateTotalAfterDiscount()}calculateDiscountAmount(t){this.isDiscMultipliciedQty()?this.variant.DiscountAmount=t:this.variant.DiscountAmount=t/this.getQty()}calculateDiscAmountOnSwitch(){let t=this.variant.DiscountAmount,e=this.getQty();this.isDiscMultipliciedQty()?this.variant.DiscountAmount=t*e:this.variant.DiscountAmount=t/e}calculateTotalBeforeDiscount(){let t=this.variant.UnitPrice*this.getQty();this.totalBeforeDiscount.set(t)}calculateTotalAfterDiscount(){let t=this.totalBeforeDiscount()-this.getTotalDiscPercentage();this.validateDiscountAmount(t);let e=this.getTotalDiscAmount(),i=t-e;this.totalAfterDiscount.set(i)}validateDiscountAmount(t){let e=this.variant.Quantity%1===0;t>0&&this.variant.DiscountAmount>t&&e&&(this.variant.DiscountAmount=t)}getTotalDiscPercentage(){return this.variant.Discount?this.totalBeforeDiscount()*this.variant.Discount/100:0}getTotalDiscAmount(){return this.variant.DiscountAmount?this.variant.DiscountAmount*this.getQty():0}getQty(){return this.variant.Quantity*this.variant.UnitQuantity}onTabChange(t){this.tabState=t,t==="Calculator"&&(console.log(this.calculatorTab()?.priceInputNativeElement),setTimeout(()=>this.calculatorTab()?.priceInputNativeElement?.focus(),100))}ok(){if(!this.isFocusOnSerialInput){if(this.checkQuantityIsNull(),this.isSerialItem){if(this.serials.length){let i=this.serials.map(o=>({Quantity:1,Number:o}));this.variant.Serial=[...this.variant.Serial,...i]}let t=this.variant.Serial?.map(i=>i.Quantity).reduce((i,o)=>i+o,0)??0,e=this.variant.Quantity;t!=e&&this.toastr.warning("Serial Quantity must be equal to Variant Quantity","Warning"),this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()}this.dialogRef.close(B(w({},this.variant),{Total:this.totalAfterDiscount()}))}}close(){this.dialogRef.close()}checkQuantityIsNull(){this.variant.Quantity==null&&(this.variant.Quantity=1)}setQuantityToMax(t){let e=t.onHand-t.allocated;t.max>=e?(this.variant.Quantity=t.max-e,this.toastr.success("Qty adjusted to Max Inventory","Success"),this.ok()):this.toastr.warning("Your Inventory Available is more than Max Inventory","Warning")}getOnInventory(){return this.onGetInventory$.pipe(zi((t,e)=>t?tt(t):this.http.get(Ae.GetVariantStockByID,[{key:"ID",value:this.variant.ID},{key:"EntityID",value:this.outletID}]).pipe(d(i=>{let o=i.OnHand-i.Allocated;return{onHand:i.OnHand,allocated:i.Allocated,rop:i.ROP,max:i.Max,maxDiff:i.Max-i.OnHand-o,ropDiff:i.ROP-i.OnHand-o}})),null),d(t=>t),X(1))}setUnitPrice(t){let e=w({},t);return S.IsNotEmpty(t.OrderPrice)?e.UnitPrice=t.OrderPrice:e.UnitPrice=t.UnitCost,e}static \u0275fac=function(e){return new(e||n)(u(Me),u(Fe),u(re),u(he),u(jn),u(qe))};static \u0275cmp=A({type:n,selectors:[["POS-modal-variant"]],viewQuery:function(e,i){if(e&1&&(Lt(i.calculatorTab,ri,5),Rt(go,5)),e&2){Qt();let o;Bt(o=jt())&&(i._quantityElement=o.first)}},decls:19,vars:20,consts:[["quantity",""],["price",""],["discount",""],[3,"onOk","onCancel","onClose","config"],[1,"container","w-100","h-100"],[1,"row","border-bottom","mx-5","mt-8"],["data-cy","input_sell",1,"btn","btn-link",3,"click","ngClass"],["data-cy","discount",1,"btn","btn-link",3,"ngClass"],["data-cy","product",1,"btn","btn-link",3,"ngClass"],["data-cy","serial",1,"btn","btn-link",3,"ngClass"],["data-cy","calculator",1,"btn","btn-link",3,"click","ngClass"],[1,"mx-8"],[1,"py-8"],[1,"row"],[1,"row","py-8"],[3,"disabledEditQty","outletID","variant","isFocusOnSerialInput","serials"],[3,"hidden"],["priceLabel","Cost",3,"discountTotal","priceTotal","qtyTotal","noteChanges","price","discount","quantity","notes","variantName"],["data-cy","discount",1,"btn","btn-link",3,"click","ngClass"],["data-cy","product",1,"btn","btn-link",3,"click","ngClass"],["data-cy","serial",1,"btn","btn-link",3,"click","ngClass"],[1,"col-auto","mb-4","pe-0",2,"width","82px"],["id","txtCartQuantity","keyboardType","number","type","text","autoNum","",1,"form-control","input-numpad",2,"height","38px",3,"ngModelChange","simpleKeyboard","decimalPlaces","ngModel","disabled"],[1,"col-auto","pe-0",2,"width","82px"],[1,"col-auto","pe-0",2,"width","112px"],[1,"col","tinymce"],["height","210px",3,"ngModelChange","ngModel"],[1,"col"],[3,"formControl","isOnModalVariant"],["type","text","autoNum","",1,"form-control","input-numpad",2,"height","38px",3,"ngModelChange","preventNegative","decimalPlaces","ngModel"],["id","inputPrice","keyboardType","number","type","text","autoNum","",1,"form-control",2,"height","38px",3,"ngModelChange","simpleKeyboard","ngModel"],[1,"col-6","border-end","py-8"],[1,"row","d-flex","align-items-center"],[1,"col-6"],[1,"col-auto","ps-0"],["id","inputDiscount","keyboardType","number","type","text","autoNum","","percentage","","decimalPlaces","2",1,"form-control",2,"width","112px","height","38px",3,"ngModelChange","simpleKeyboard","ngModel","min","readonly"],[1,"row","d-flex","align-items-center","mt-6"],["id","inputDiscount","keyboardType","number","type","text","autoNum","",1,"form-control",2,"width","112px","height","38px",3,"ngModelChange","simpleKeyboard","ngModel","max","min","readonly"],[1,"d-flex","align-items-center","mt-4"],[1,"form-check","form-switch","form-switch-lg","ms-1","mt-1"],["type","checkbox","id","flexSwitchCheckDefault",1,"form-check-input",3,"ngModelChange","ngModel"],[1,"ms-4"],["matTooltipPosition","above","matTooltip",`Use the final discount amount if you want to discount the price of the total
|
|
23
|
+
`,headerType:ve.Error},width:"31rem"})}updateTax(){this.updateDefaultTax$.pipe(Ei(1)).subscribe()}updatePaymentMethodID(){this.updatePaymentMethodID$.pipe(Ei(1)).subscribe()}static \u0275fac=function(e){return new(e||n)(U(re),U(G),U(Ve),U(de),U($e))};static \u0275prov=ne({token:n,factory:n.\u0275fac,providedIn:"root"})};function po(n,t){if(n&1&&(r(0,"mat-option",7),m(1),a()),n&2){let e=t.$implicit;b("value",e),l(),$(" ",e.Value," ")}}function uo(n,t){if(n&1){let e=j();r(0,"i",8),D("click",function(){P(e);let o=p();return O(o.openSupplierDetail())}),a()}}var ci=class n{constructor(t,e,i,o){this.http=t;this.form=e;this.matDialog=i;this.router=o}supplierPOTypes;appConfigJSON;filteredSuppliers$;supplier=new me("");disabled=!1;onChange=t=>{};onTouched=()=>{};ngOnInit(){this.filteredSuppliers$=this.supplier.valueChanges.pipe(V(i=>typeof i=="string"&&i.length>=3),Gi(300),Y(i=>this.http.get("/API/AC/GetSupplierSuggestion",[{key:"count",value:100},{key:"prefix",value:i}]))),this.supplier.valueChanges.pipe(V(i=>typeof i!="string"),d(i=>i),E(i=>i?.Key!=S.GuidEmpty&&S.IsNotEmpty(i)?this.onChange(i.Key):this.onChange(null))).pipe(V(i=>S.IsNotEmpty(i)&&!i.OnSet),Y(i=>this.http.post("/API/Contact/GetSupplierDTO",{id:i.Key}).pipe(ye(()=>we))),d(i=>i.DaysDue),V(i=>i!=0),E(i=>this.form.setdueDays(i)),E(i=>this.form.setDueDateBasedOnDaysDue(i))).subscribe()}writeValue(t){this.supplier.setValue(t)}registerOnChange(t){this.onChange=t}registerOnTouched(t){this.onTouched=t}setDisabledState(t){this.disabled=t}displaySupplierNameFn(t){return t?.Value}openNewSupplierModal(){this.matDialog.open(Qn,{data:{options:this.supplierPOTypes,config:this.appConfigJSON.ModuleContact,type:"supplier",title:"New Supplier Form"}}).afterClosed().pipe(V(t=>S.IsNotEmpty(t.supplier.Name)),Y(t=>{let e={contact:t.supplier,type:"supplier",groups:t.supplier.Group?t.supplier.Group:[]};return this.http.post("/API/Contact/Supplier/Create",e).pipe(d(i=>({Key:i.ID,Value:t.supplier.Name})))})).subscribe(t=>{this.writeValue(t),this.onChange(t.Key)})}openSupplierDetail(){let t=this.supplier.value.Key;if(S.IsNotEmpty(t)){let e=this.router.serializeUrl(this.router.createUrlTree(["/menu/Contacts/Contact/Suppliers/Info/V2"],{queryParams:{ID:t}}));window.open(e,"_blank")}}static \u0275fac=function(e){return new(e||n)(u(re),u(G),u(Z),u(Kt))};static \u0275cmp=A({type:n,selectors:[["POS-supplier-autocomplete"]],inputs:{supplierPOTypes:"supplierPOTypes",appConfigJSON:"appConfigJSON"},features:[Ne([{provide:Ke,multi:!0,useExisting:n}])],decls:8,vars:7,consts:[["auto","matAutocomplete"],[1,"d-flex","align-items-center","position-relative"],["matTooltipPosition","above","matTooltip","New Supplier Form",1,"fa-light","fa-user-plus","position-absolute",2,"font-size","12px",3,"click"],["type","text","placeholder","Assign Supplier",3,"formControl","matAutocomplete"],[3,"displayWith"],[3,"value",4,"ngFor","ngForOf"],["matTooltipPosition","left","matTooltip","Open Supplier Details",1,"fa-regular","fa-arrow-up-right-from-square","position-absolute",2,"font-size","12px","right","0","cursor","pointer"],[3,"value"],["matTooltipPosition","left","matTooltip","Open Supplier Details",1,"fa-regular","fa-arrow-up-right-from-square","position-absolute",2,"font-size","12px","right","0","cursor","pointer",3,"click"]],template:function(e,i){if(e&1){let o=j();r(0,"div",1)(1,"i",2),D("click",function(){return P(o),O(i.openNewSupplierModal())}),a(),M(2,"input",3),r(3,"mat-autocomplete",4,0),ut(5,po,2,2,"mat-option",5),f(6,"async"),a(),v(7,uo,1,0,"i",6),a()}if(e&2){let o=ht(4);l(2),b("formControl",i.supplier)("matAutocomplete",o),l(),b("displayWith",i.displaySupplierNameFn),l(2),b("ngForOf",g(6,5,i.filteredSuppliers$)),l(2),_(i.supplier&&(i.supplier!=null&&i.supplier.value)&&(!(i.supplier==null||i.supplier.value==null)&&i.supplier.value.Key)?7:-1)}},dependencies:[ce,ln,Fn,Nn,_n,En,Ye,be,ae,ze,lt,rt,Un,Ee],styles:["input[_ngcontent-%COMP%]{width:100%;height:38px!important;border-radius:.375rem;border:1px solid #ced4da;padding-left:32px;padding-right:32px}input[_ngcontent-%COMP%]::placeholder{color:#ced4da}i.fa-user-plus[_ngcontent-%COMP%]{font-size:16px;top:10.6px;left:13px}i.fa-arrow-up-right-from-square[_ngcontent-%COMP%]{transform:none;position:absolute;margin-right:13px;top:10.6px;font-size:12px}"]})};var go=["quantity"],Et=n=>({selected:n}),Co=()=>["/menu/Products/Catalog/Variants/Info"],yo=n=>({ID:n}),bo=n=>({"table-light":n});function ho(n,t){if(n&1){let e=j();r(0,"a",18),D("click",function(){P(e);let o=p();return O(o.onTabChange("Discount"))}),m(1," Discount "),a()}if(n&2){let e=p();b("ngClass",ie(1,Et,e.tabState=="Discount"))}}function vo(n,t){if(n&1){let e=j();r(0,"a",19),D("click",function(){P(e);let o=p();return O(o.onTabChange("Product"))}),m(1," Product "),a()}if(n&2){let e=p();b("ngClass",ie(1,Et,e.tabState=="Product"))}}function _o(n,t){if(n&1){let e=j();r(0,"a",20),D("click",function(){P(e);let o=p();return O(o.onTabChange("Serial"))}),m(1," Serial "),a()}if(n&2){let e=p();b("ngClass",ie(1,Et,e.tabState=="Serial"))}}function Do(n,t){if(n&1&&(r(0,"div",13)(1,"div",27),M(2,"POS-variant-autocomplete",28),a()()),n&2){let e=p(2);l(2),b("formControl",e.variantAutocomplete)("isOnModalVariant",!0)}}function xo(n,t){if(n&1&&(r(0,"span"),m(1),a()),n&2){let e=p(2);l(),$("(",e.variant.UOMName,")")}}function So(n,t){if(n&1){let e=j();r(0,"div",23)(1,"strong")(2,"span"),m(3),a()(),r(4,"input",29),J("ngModelChange",function(o){P(e);let s=p(2);return L(s.variant.UnitQuantity,o)||(s.variant.UnitQuantity=o),O(o)}),D("ngModelChange",function(){P(e);let o=p(2);return O(o.onUnitQtyChange())}),a()()}if(n&2){let e=p(2);l(3),te(e.unitQtyLabel),l(),b("preventNegative",!0)("decimalPlaces",e.isSerialItem?0:4),W("ngModel",e.variant.UnitQuantity)}}function Mo(n,t){if(n&1){let e=j();r(0,"div",24)(1,"strong"),m(2,"Cost"),a(),r(3,"input",30,1),J("ngModelChange",function(o){P(e);let s=p(2);return L(s.variant.UnitPrice,o)||(s.variant.UnitPrice=o),O(o)}),D("ngModelChange",function(){P(e);let o=p(2);return O(o.onPriceChange())}),a()()}if(n&2){let e=p(2);l(3),b("simpleKeyboard",e.keyboard),W("ngModel",e.variant.UnitPrice)}}function Io(n,t){if(n&1){let e=j();r(0,"div",12),v(1,Do,3,2,"div",13),r(2,"div",13)(3,"div",21)(4,"strong"),m(5," Qty "),v(6,xo,2,1,"span"),a(),r(7,"input",22,0),J("ngModelChange",function(o){P(e);let s=p();return L(s.variant.Quantity,o)||(s.variant.Quantity=o),O(o)}),D("ngModelChange",function(){P(e);let o=p();return O(o.onQtyChange())}),a()(),v(9,So,5,4,"div",23),v(10,Mo,5,2,"div",24),a(),r(11,"div",13)(12,"div",25)(13,"POS-tinymce-editor",26),J("ngModelChange",function(o){P(e);let s=p();return L(s.variant.Note,o)||(s.variant.Note=o),O(o)}),a()()()()}if(n&2){let e=p();l(),_(e.isCreate?1:-1),l(5),_(e.variant.UOMName?6:-1),l(),b("simpleKeyboard",e.keyboard)("decimalPlaces",e.isSerialItem?0:4),W("ngModel",e.variant.Quantity),b("disabled",e.isEditBuyForm&&e.isSerialItem),l(2),_(e.unitQtyLabel?9:-1),l(),_(e.role.product.Cost?10:-1),l(3),W("ngModel",e.variant.Note)}}function Po(n,t){if(n&1&&(r(0,"div",44)(1,"div",33)(2,"strong"),m(3,"Discount Amount / Qty"),a()(),r(4,"div",34)(5,"div",46)(6,"p"),m(7),f(8,"number"),a()()()()),n&2){let e=p(2);l(7),te(g(8,1,e.variant.DiscountAmount))}}function Oo(n,t){if(n&1&&(r(0,"div",52)(1,"h5",58),m(2),f(3,"number"),a()()),n&2){let e=p(3);l(2),$(" ",g(3,1,e.variant.Discount),"% ")}}function To(n,t){if(n&1&&(r(0,"div",53)(1,"h5"),m(2),f(3,"number"),a(),r(4,"span",51),m(5,"x"),a(),r(6,"h5"),m(7),f(8,"number"),a()()),n&2){let e=p(3);l(2),te(g(3,2,e.variant.Quantity)),l(5),te(g(8,4,e.variant.DiscountAmount))}}function wo(n,t){if(n&1&&(r(0,"h5",56),m(1),f(2,"number"),a()),n&2){let e=p(3);l(),$(" -",g(2,1,e.totalBeforeDiscount()*(e.variant.Discount/100))," ")}}function No(n,t){if(n&1&&(r(0,"div",55)(1,"h5",56),m(2),f(3,"number"),a()()),n&2){let e=p(3);l(2),$(" -",g(3,1,e.variant.Quantity*e.variant.DiscountAmount)," ")}}function Eo(n,t){if(n&1&&(r(0,"div",57)(1,"div",59)(2,"h5"),m(3,"Grand Total"),a()(),r(4,"div",59)(5,"h5"),m(6),f(7,"number"),a()()()),n&2){let e=p(3);l(6),te(g(7,1,e.totalAfterDiscount()))}}function Fo(n,t){if(n&1&&(r(0,"div",45)(1,"div",47)(2,"h4"),m(3,"Discount Simulation"),a(),r(4,"h4",48),m(5),a()(),r(6,"div",49)(7,"div",33)(8,"div",50)(9,"h5"),m(10),f(11,"number"),a(),r(12,"span",51),m(13,"x"),a(),r(14,"h5"),m(15),f(16,"number"),a()(),v(17,Oo,4,3,"div",52),v(18,To,9,6,"div",53),a(),r(19,"div",33)(20,"div",54)(21,"h5"),m(22),f(23,"number"),a()(),r(24,"div",55),v(25,wo,3,3,"h5",56),a(),v(26,No,4,3,"div",55),a(),v(27,Eo,8,3,"div",57),a()()),n&2){let e=p(2);l(5),$(" ",e.variant==null?null:e.variant.Name," "),l(5),te(g(11,9,e.variant.Quantity)),l(5),te(g(16,11,e.variant.UnitPrice)),l(2),_(e.variant.Discount?17:-1),l(),_(e.variant.DiscountAmount>0?18:-1),l(4),te(g(23,13,e.totalBeforeDiscount())),l(3),_(e.variant.Discount?25:-1),l(),_(e.variant.DiscountAmount>0?26:-1),l(),_(e.variant.DiscountAmount>0||e.variant.Discount>0?27:-1)}}function Ao(n,t){if(n&1){let e=j();r(0,"div",13)(1,"div",31)(2,"div",32)(3,"div",33)(4,"strong"),m(5,"Discount %"),a()(),r(6,"div",34)(7,"input",35,2),J("ngModelChange",function(o){P(e);let s=p();return L(s.variant.Discount,o)||(s.variant.Discount=o),O(o)}),D("ngModelChange",function(){P(e);let o=p();return O(o.onDiscountChange())}),a()()(),r(9,"div",36)(10,"div",33)(11,"strong"),m(12,"Discount Amount"),a()(),r(13,"div",34)(14,"input",37,2),J("ngModelChange",function(o){P(e);let s=p();return L(s.inputedDiscountAmount,o)||(s.inputedDiscountAmount=o),O(o)}),D("ngModelChange",function(o){P(e);let s=p();return O(s.onDiscountAmountChange(o))}),a()()(),r(16,"div",38)(17,"div",39)(18,"input",40),J("ngModelChange",function(o){P(e);let s=p();return L(s.isDiscMultipliciedQty,o)||(s.isDiscMultipliciedQty=o),O(o)}),D("ngModelChange",function(){P(e);let o=p();return O(o.onSwitchDiscountTypeChange())}),a()(),r(19,"div",41)(20,"strong"),m(21,"*Quantity"),a(),r(22,"span",42),M(23,"i",43),a()()(),v(24,Po,9,3,"div",44),a(),v(25,Fo,28,15,"div",45),a()}if(n&2){let e=p();l(7),b("simpleKeyboard",e.keyboard),W("ngModel",e.variant.Discount),b("min",0)("readonly",!e.role.sell.Discount),l(7),b("simpleKeyboard",e.keyboard),W("ngModel",e.inputedDiscountAmount),b("max",e.variant.UnitPrice*e.variant.Quantity)("min",0)("readonly",!e.role.sell.Discount),l(4),W("ngModel",e.isDiscMultipliciedQty),l(6),_(e.isDiscMultipliciedQty()?-1:24),l(),_(e.role.product.Cost?25:-1)}}function ko(n,t){n&1&&(M(0,"i",65),r(1,"h6"),m(2,"No Image"),a())}function Vo(n,t){if(n&1&&M(0,"img",62),n&2){let e=p(2);b("src",e.variant.ThumbnailUrl,at)}}function $o(n,t){if(n&1){let e=j();r(0,"button",78),D("click",function(){P(e);let o=p(),s=p(2);return O(s.setQuantityToMax(o))}),m(1," Place Order "),a()}}function Ro(n,t){if(n&1&&(r(0,"tbody")(1,"tr")(2,"th",66),M(3,"i",67),m(4,"Inventory "),a(),r(5,"th",66),M(6,"i",68),m(7),a(),r(8,"th",66),M(9,"i",69),m(10," Diff "),a(),r(11,"th",66),M(12,"i",70),m(13," Action "),a()(),r(14,"tr")(15,"th",71),m(16,"On Hand"),a(),r(17,"td",72),m(18),f(19,"number"),a(),M(20,"td",73)(21,"td",74),a(),r(22,"tr")(23,"th",71),m(24,"Allocated"),a(),r(25,"td",72),m(26),f(27,"number"),a()(),r(28,"tr")(29,"th",71),m(30,"Available"),a(),r(31,"td",72),m(32),f(33,"number"),a()(),r(34,"tr")(35,"th",71),m(36,"ROP"),a(),r(37,"td",72),m(38),f(39,"number"),a(),r(40,"td",56),m(41),f(42,"number"),a()(),r(43,"tr")(44,"th",71),m(45,"Max"),a(),r(46,"td",72),m(47),f(48,"number"),a(),r(49,"td",75),m(50),f(51,"number"),a(),r(52,"td",76),v(53,$o,2,0,"button",77),a()()()),n&2){let e=t,i=p(2);l(7),$("",i.outletName," "),l(11),$(" ",g(19,12,e.onHand)," "),l(8),$(" ",g(27,14,e.allocated)," "),l(6),$(" ",g(33,16,e.onHand-e.allocated)," "),l(6),$(" ",g(39,18,e.rop)," "),l(3),He(" ",e.ropDiff>=0?"+":"","",g(42,20,e.ropDiff)," "),l(6),$(" ",g(48,22,e.max)," "),l(3),He(" ",e.maxDiff>=0?"+":"","",g(51,24,e.maxDiff)," "),l(2),b("ngClass",ie(26,bo,i.variant.Quantity==e.max-e.onHand-e.allocated)),l(),_(i.variant.Quantity!=e.max-e.onHand-e.allocated?53:-1)}}function Bo(n,t){if(n&1&&(r(0,"div",14)(1,"div",60)(2,"a",61),v(3,ko,3,0)(4,Vo,1,1,"img",62),a()(),r(5,"div",63)(6,"table",64),v(7,Ro,54,28,"tbody"),f(8,"async"),a()()()),n&2){let e,i=p();l(2),b("routerLink",Ht(6,Co))("queryParams",ie(7,yo,i.variant==null?null:i.variant.ID)),l(),_((i.variant==null?null:i.variant.ThumbnailUrl)==null?3:4),l(4),_((e=g(8,4,i.variantStock$))?7:-1,e)}}function jo(n,t){if(n&1){let e=j();r(0,"POS-tab-serial",79),J("variantChange",function(o){P(e);let s=p();return L(s.variant,o)||(s.variant=o),O(o)})("isFocusOnSerialInputChange",function(o){P(e);let s=p();return L(s.isFocusOnSerialInput,o)||(s.isFocusOnSerialInput=o),O(o)})("serialsChange",function(o){P(e);let s=p();return L(s.serials,o)||(s.serials=o),O(o)}),a()}if(n&2){let e=p();b("disabledEditQty",e.isEditBuyForm)("outletID",e.outletID),W("variant",e.variant)("isFocusOnSerialInput",e.isFocusOnSerialInput)("serials",e.serials)}}var pt=class n{constructor(t,e,i,o,s,T){this.dialogRef=t;this.http=i;this.role=o;this.toastr=T;this.config=new Ie,this.config.title=e.variant?.Name??"Add Variant",this.config.customWidth="700px",this.config.noPadding=!0,this.appConfigJSON=e.appConfigJSON,this.unitQtyLabel=this.appConfigJSON.ModuleSell.ProductDialog.UnitQtyLabel,this.numpadVisible=this.appConfigJSON.ModuleSell.NumPadVisible,this.numpadVisible&&(this.keyboard=s.keyboard),this.isEditBuyForm=e.isEdit,this.outletID=e.outletID,this.outletName=e.outletName,this.variant=e.variant;let R=this.appConfigJSON?.ModuleSell?.ProductDialog?.QuantityToOneInDialog?1:null;if(this.variant)this.isSerialItem=this.variant.TypeID==4,this.variantStock$=this.getOnInventory(),this.inputedDiscountAmount.set(this.variant.DiscountAmount),this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount();else{this.isCreate=!0,this.variant={Name:"",Quantity:R,UnitQuantity:1,OrderPrice:0,Total:0,Note:"",UnitPrice:0,ThumbnailUrl:"",UOMName:"",TypeID:0,Discount:0,ID:"",DiscountAmount:0,Serial:[]};let q=this.variantAutocomplete.valueChanges.pipe(V(c=>c.type=="Code"),d(c=>c.str),Y(c=>i.get(Ae.GetVariantByCode,[{key:"Code",value:c},{key:"EntityID",value:this.outletID},{key:"Promotion",value:!0}]).pipe(ye(()=>we))),d(c=>this.setUnitPrice(c)),d(c=>B(w({},c),{Quantity:R,Total:c.UnitPrice,Discount:c.PriceDiscount}))),x=this.variantAutocomplete.valueChanges.pipe(V(c=>c.type=="ID"),d(c=>c.str),Y(c=>i.get(Ae.GetVariantByID,[{key:"ID",value:c},{key:"EntityID",value:this.outletID},{key:"Promotion",value:!1}]).pipe(ye(()=>we))),d(c=>this.setUnitPrice(c)),d(c=>B(w({},c),{Quantity:R,Total:c.UnitPrice,Discount:c.PriceDiscount})));ot(q,x).pipe(E(c=>this.setFocusField("quantity")),X(1)).subscribe(c=>{this.variant=c,this.isSerialItem=this.variant.TypeID==4,this.showInventory=!0,this.variantStock$=this.getOnInventory(),this.inputedDiscountAmount.set(this.variant.DiscountAmount),this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()})}}calculatorTab=qt(ri);variantAutocomplete=new me;_quantityElement;variant;variantStock$=we;isSerialItem=!1;outletID;outletName;appConfigJSON;numpadVisible;keyboard;isEditBuyForm=!1;unitQtyLabel;config;tabState="Cart";isCreate=!1;showInventory=!1;serials=[];isFocusOnSerialInput=!1;_onGetInventory=new et(void 0);onGetInventory$=this._onGetInventory.asObservable();isDiscMultipliciedQty=Le(!0);totalBeforeDiscount=Le(0);totalAfterDiscount=Le(0);inputedDiscountAmount=Le(0);setFocusField(t){switch(t){case"quantity":this._quantityElement.nativeElement.focus();break}}onPriceChange(){this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()}onQtyChange(){this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()}onUnitQtyChange(){this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()}onDiscountChange(){this.calculateTotalAfterDiscount(),this.calculateTotalAfterDiscount()}onDiscountAmountChange(t){this.calculateDiscountAmount(t),this.calculateTotalAfterDiscount()}onSwitchDiscountTypeChange(){this.calculateDiscAmountOnSwitch(),this.calculateTotalAfterDiscount()}calculateDiscountAmount(t){this.isDiscMultipliciedQty()?this.variant.DiscountAmount=t:this.variant.DiscountAmount=t/this.getQty()}calculateDiscAmountOnSwitch(){let t=this.variant.DiscountAmount,e=this.getQty();this.isDiscMultipliciedQty()?this.variant.DiscountAmount=t*e:this.variant.DiscountAmount=t/e}calculateTotalBeforeDiscount(){let t=this.variant.UnitPrice*this.getQty();this.totalBeforeDiscount.set(t)}calculateTotalAfterDiscount(){let t=this.totalBeforeDiscount()-this.getTotalDiscPercentage();this.validateDiscountAmount(t);let e=this.getTotalDiscAmount(),i=t-e;this.totalAfterDiscount.set(i)}validateDiscountAmount(t){let e=this.variant.Quantity%1===0;t>0&&this.variant.DiscountAmount>t&&e&&(this.variant.DiscountAmount=t)}getTotalDiscPercentage(){return this.variant.Discount?this.totalBeforeDiscount()*this.variant.Discount/100:0}getTotalDiscAmount(){return this.variant.DiscountAmount?this.variant.DiscountAmount*this.getQty():0}getQty(){return this.variant.Quantity*this.variant.UnitQuantity}onTabChange(t){this.tabState=t,t==="Calculator"&&(console.log(this.calculatorTab()?.priceInputNativeElement),setTimeout(()=>this.calculatorTab()?.priceInputNativeElement?.focus(),100))}ok(){if(!this.isFocusOnSerialInput){if(this.checkQuantityIsNull(),this.isSerialItem){if(this.serials.length){let i=this.serials.map(o=>({Quantity:1,Number:o}));this.variant.Serial=[...this.variant.Serial,...i]}let t=this.variant.Serial?.map(i=>i.Quantity).reduce((i,o)=>i+o,0)??0,e=this.variant.Quantity;t!=e&&this.toastr.warning("Serial Quantity must be equal to Variant Quantity","Warning"),this.calculateTotalBeforeDiscount(),this.calculateTotalAfterDiscount()}this.dialogRef.close(B(w({},this.variant),{Total:this.totalAfterDiscount()}))}}close(){this.dialogRef.close()}checkQuantityIsNull(){this.variant.Quantity==null&&(this.variant.Quantity=1)}setQuantityToMax(t){let e=t.onHand-t.allocated;t.max>=e?(this.variant.Quantity=t.max-e,this.toastr.success("Qty adjusted to Max Inventory","Success"),this.ok()):this.toastr.warning("Your Inventory Available is more than Max Inventory","Warning")}getOnInventory(){return this.onGetInventory$.pipe(zi((t,e)=>t?tt(t):this.http.get(Ae.GetVariantStockByID,[{key:"ID",value:this.variant.ID},{key:"EntityID",value:this.outletID}]).pipe(d(i=>{let o=i.OnHand-i.Allocated;return{onHand:i.OnHand,allocated:i.Allocated,rop:i.ROP,max:i.Max,maxDiff:i.Max-i.OnHand-o,ropDiff:i.ROP-i.OnHand-o}})),null),d(t=>t),X(1))}setUnitPrice(t){let e=w({},t);return S.IsNotEmpty(t.OrderPrice)?e.UnitPrice=t.OrderPrice:e.UnitPrice=t.UnitCost,e}static \u0275fac=function(e){return new(e||n)(u(Me),u(Fe),u(re),u(he),u(jn),u(qe))};static \u0275cmp=A({type:n,selectors:[["POS-modal-variant"]],viewQuery:function(e,i){if(e&1&&(Lt(i.calculatorTab,ri,5),Rt(go,5)),e&2){Qt();let o;Bt(o=jt())&&(i._quantityElement=o.first)}},decls:19,vars:20,consts:[["quantity",""],["price",""],["discount",""],[3,"onOk","onCancel","onClose","config"],[1,"container","w-100","h-100"],[1,"row","border-bottom","mx-5","mt-8"],["data-cy","input_sell",1,"btn","btn-link",3,"click","ngClass"],["data-cy","discount",1,"btn","btn-link",3,"ngClass"],["data-cy","product",1,"btn","btn-link",3,"ngClass"],["data-cy","serial",1,"btn","btn-link",3,"ngClass"],["data-cy","calculator",1,"btn","btn-link",3,"click","ngClass"],[1,"mx-8"],[1,"py-8"],[1,"row"],[1,"row","py-8"],[3,"disabledEditQty","outletID","variant","isFocusOnSerialInput","serials"],[3,"hidden"],["priceLabel","Cost",3,"discountTotal","priceTotal","qtyTotal","noteChanges","price","discount","quantity","notes","variantName"],["data-cy","discount",1,"btn","btn-link",3,"click","ngClass"],["data-cy","product",1,"btn","btn-link",3,"click","ngClass"],["data-cy","serial",1,"btn","btn-link",3,"click","ngClass"],[1,"col-auto","mb-4","pe-0",2,"width","82px"],["id","txtCartQuantity","keyboardType","number","type","text","autoNum","",1,"form-control","input-numpad",2,"height","38px",3,"ngModelChange","simpleKeyboard","decimalPlaces","ngModel","disabled"],[1,"col-auto","pe-0",2,"width","82px"],[1,"col-auto","pe-0",2,"width","112px"],[1,"col","tinymce"],["height","210px",3,"ngModelChange","ngModel"],[1,"col"],[3,"formControl","isOnModalVariant"],["type","text","autoNum","",1,"form-control","input-numpad",2,"height","38px",3,"ngModelChange","preventNegative","decimalPlaces","ngModel"],["id","inputPrice","keyboardType","number","type","text","autoNum","",1,"form-control",2,"height","38px",3,"ngModelChange","simpleKeyboard","ngModel"],[1,"col-6","border-end","py-8"],[1,"row","d-flex","align-items-center"],[1,"col-6"],[1,"col-auto","ps-0"],["id","inputDiscount","keyboardType","number","type","text","autoNum","","percentage","","decimalPlaces","2",1,"form-control",2,"width","112px","height","38px",3,"ngModelChange","simpleKeyboard","ngModel","min","readonly"],[1,"row","d-flex","align-items-center","mt-6"],["id","inputDiscount","keyboardType","number","type","text","autoNum","",1,"form-control",2,"width","112px","height","38px",3,"ngModelChange","simpleKeyboard","ngModel","max","min","readonly"],[1,"d-flex","align-items-center","mt-4"],[1,"form-check","form-switch","form-switch-lg","ms-1","mt-1"],["type","checkbox","id","flexSwitchCheckDefault",1,"form-check-input",3,"ngModelChange","ngModel"],[1,"ms-4"],["matTooltipPosition","above","matTooltip",`Use the final discount amount if you want to discount the price of the total
|
|
24
24
|
quantity of the product. The nominal will be calculated automatically and filled in the discount amount box.`,1,"pointer"],[1,"fa-solid","fa-info-circle","ms-2"],[1,"row","d-flex","align-items-center","justify-content-start","mt-4"],[1,"col-6","py-8"],[1,"border","ps-6",2,"height","38px","padding-top","10px","width","112px","background-color","#e9ecef"],[1,"w-100","text-center"],[1,"text-start","mt-12"],[1,"row","mt-12"],[1,"w-100","d-flex","align-items-center","justify-content-end"],[1,"mx-1","fw-bold"],[1,"d-flex","align-items-center","justify-content-end","mt-2"],[1,"d-flex","align-items-center","justify-content-end","mt-2","text-danger"],[1,"w-100","d-flex","justify-content-end"],[1,"w-100","d-flex","justify-content-end","mt-2"],[1,"text-danger"],[1,"row","border-top","mx-0","px-0","mt-4"],[1,"fw-bold","text-danger"],[1,"col-6","d-flex","justify-content-end","mt-4"],[1,"col-sm-4","d-flex","justify-content-center","flex-column","align-items-center","text-body-secondary"],["target","_blank",2,"color","inherit",3,"routerLink","queryParams"],[1,"border","rounded",3,"src"],[1,"col-sm-8"],[1,"table","table-bordered","text-center","inventory-table","w-auto"],["aria-hidden","true",1,"fa-solid","fa-image","fa-5x"],[1,"bg-light-orange"],["aria-hidden","true",1,"fa-box-archive","fa-solid","fa-1x","me-2"],["aria-hidden","true",1,"fa-solid","fa-house","fa-1x","me-2"],["aria-hidden","true",1,"fa-solid","fa-plus-minus","fa-1x","me-2"],["aria-hidden","true",1,"fa-solid","fa-sliders","fa-1x","me-2"],[1,"table-light","text-start"],[1,"text-end"],["rowspan","3",1,"table-light"],["rowspan","4",1,"table-light"],[1,"text-success"],[3,"ngClass"],["type","button","matTooltipPosition","above","matTooltip","Adjust Bought Qty to max Inventory",1,"btn","btn-success","btn-sm","me-2",2,"font-size","12px"],["type","button","matTooltipPosition","above","matTooltip","Adjust Bought Qty to max Inventory",1,"btn","btn-success","btn-sm","me-2",2,"font-size","12px",3,"click"],[3,"variantChange","isFocusOnSerialInputChange","serialsChange","disabledEditQty","outletID","variant","isFocusOnSerialInput","serials"]],template:function(e,i){e&1&&(r(0,"modal-material",3),D("onOk",function(){return i.ok()})("onCancel",function(){return i.close()})("onClose",function(){return i.close()}),r(1,"content")(2,"div",4)(3,"div",5)(4,"div")(5,"a",6),D("click",function(){return i.onTabChange("Cart")}),m(6," Cart "),a(),v(7,ho,2,3,"a",7),v(8,vo,2,3,"a",8),v(9,_o,2,3,"a",9),r(10,"a",10),D("click",function(){return i.onTabChange("Calculator")}),m(11," Calculator "),a()()(),r(12,"div",11),v(13,Io,14,9,"div",12),v(14,Ao,26,12,"div",13),v(15,Bo,9,9,"div",14),v(16,jo,1,5,"POS-tab-serial",15),r(17,"div",16)(18,"item-calculator-tab",17),D("discountTotal",function(s){return i.variant.Discount=s,i.onDiscountChange()})("priceTotal",function(s){return i.variant.UnitPrice=s,i.onPriceChange()})("qtyTotal",function(s){return i.variant.Quantity=s,i.onQtyChange()})("noteChanges",function(s){return i.variant.Note=s}),a()()()()()()),e&2&&(b("config",i.config),l(5),b("ngClass",ie(16,Et,i.tabState=="Cart")),l(2),_(!i.isCreate||i.showInventory?7:-1),l(),_(!i.isCreate||i.showInventory?8:-1),l(),_(i.isSerialItem?9:-1),l(),b("ngClass",ie(18,Et,i.tabState=="Calculator")),l(3),_(i.tabState=="Cart"?13:-1),l(),_(i.tabState=="Discount"?14:-1),l(),_(i.tabState=="Product"?15:-1),l(),_(i.tabState=="Serial"?16:-1),l(),b("hidden",i.tabState!="Calculator"),l(),b("price",i.variant.UnitPrice)("discount",i.variant.Discount)("quantity",i.variant.Quantity)("notes",i.variant.Note)("variantName",i.variant==null?null:i.variant.Name))},dependencies:[ce,Ge,ai,oi,Se,be,Cn,ae,xe,Dt,Oe,Pe,st,ct,An,Yt,zt,Gn,Ln,li,Ye,ze,io,ri,Ee,De],styles:[".text-warning[_ngcontent-%COMP%]{color:var(--bs-warning)!important}.bg-light-gray[_ngcontent-%COMP%]{background-color:var(--bs-light-gray);--bs-bg-opacity: .15 !important}.bg-gradient-danger[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#f8d7da,#f8d7da 15px,#f5c6cb 15px 30px)!important}.bg-gradient-success[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#beeebb,#beeebb 15px,#afeba8 15px 30px)!important}.bg-gradient-warning[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#fcf3cf,#fcf3cf 15px,#f9e79f 15px 30px)!important}.bg-light-orange[_ngcontent-%COMP%]{background-color:var(--bs-light-orange);--bs-bg-opacity: .15 !important}.text-danger[_ngcontent-%COMP%]{color:#fb404b!important}.text-dark[_ngcontent-%COMP%]{color:#5e5e5e!important}.text-success[_ngcontent-%COMP%]{color:#87cb16!important}.text-black[_ngcontent-%COMP%]{color:#000!important}.text-white[_ngcontent-%COMP%]{color:var(--bs-white)!important}.btn-light-blue[_ngcontent-%COMP%]{color:#212529;background-color:#dfeffc!important;border-color:#dfeffc}.btn-light-blue[_ngcontent-%COMP%]:hover{color:#212529;background-color:#bcdef9;border-color:#b0d8f8}.btn-light-blue[_ngcontent-%COMP%]:focus, .btn-light-blue.focus[_ngcontent-%COMP%]{color:#212529;background-color:#bcdef9;border-color:#b0d8f8;box-shadow:0 0 0 .2rem #c3d1dc80}.btn-light-blue.disabled[_ngcontent-%COMP%], .btn-light-blue[_ngcontent-%COMP%]:disabled{color:#212529;background-color:#dfeffc;border-color:#dfeffc}.btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active, .btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active, .show[_ngcontent-%COMP%] > .btn-light-blue.dropdown-toggle[_ngcontent-%COMP%]{color:#212529;background-color:#b0d8f8;border-color:#a5d2f7}.btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active:focus, .btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active:focus, .show[_ngcontent-%COMP%] > .btn-light-blue.dropdown-toggle[_ngcontent-%COMP%]:focus{box-shadow:0 0 0 .2rem #c3d1dc80}.btn-light-danger[_ngcontent-%COMP%]{color:#212529;background-color:#f8d7da!important;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:hover{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5}.btn-light-danger[_ngcontent-%COMP%]:focus, .btn-light-danger.focus[_ngcontent-%COMP%]{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5;box-shadow:0 0 0 .2rem #dc354540}.btn-light-danger.disabled[_ngcontent-%COMP%], .btn-light-danger[_ngcontent-%COMP%]:disabled{color:#212529;background-color:#f8d7da;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]{color:#212529;background-color:#f1aeb5;border-color:#ea868f}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active:focus, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active:focus, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]:focus{box-shadow:0 0 0 .2rem #dc354540}p-chips[_ngcontent-%COMP%] ul.p-inputtext{width:570px;max-width:570px;border:1px solid #C8D3DF}p-chips[_ngcontent-%COMP%] ul.p-inputtext li.p-chips-input-token>input[type=text]{border:none}p-chips[_ngcontent-%COMP%] .p-chips .p-chips-multiple-container:not(.p-disabled):hover{border:1px solid #C8D3DF}p-chips[_ngcontent-%COMP%] .p-chips-multiple-container{display:inline-block}p-chips[_ngcontent-%COMP%] .p-chips-multiple-container .p-chips-token{margin:2px;background:#96bf48}.inventory-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%], .inventory-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{line-height:6px!important}.btn-link[_ngcontent-%COMP%]{padding-top:0;color:#868686;padding-bottom:8px;border-radius:unset;font-family:Roboto Slab,serif}.btn-link.selected[_ngcontent-%COMP%]{color:#3b3b3b;border-bottom:4px solid #07a519}.form-check-input[_ngcontent-%COMP%]{clear:left}.form-switch.form-switch-lg[_ngcontent-%COMP%] .form-check-input[_ngcontent-%COMP%]{height:1.5rem;width:2.75rem;border-radius:3rem}.form-check-input[_ngcontent-%COMP%]:focus{border-color:#89b03e!important}.form-check-input[_ngcontent-%COMP%]:checked{border-color:#89b03e!important;background-color:#89b03e!important}"]})};var Mt=class n extends no{connection;_Data=new Ui(1);Data=this._Data.asObservable();httpService=se(re);toastService=se(qe);_cache=new Map;previousCountByEpc={};_isConnected=new et(!1);isConnected=this._isConnected.asObservable();_bufferTime=new et(100);set bufferTime(t){this._bufferTime.next(t)}get bufferTime(){return this._bufferTime.getValue()}intializeWebSocket(t="/"){return yt(this,null,function*(){if(t.length<=0){this.toastService.error("RFID URL cannot be empty",ve.Error);return}if(!(this.connection&&this.connection.state===fn.Connected)){this.connection=new gn().withUrl(t).configureLogging(un.Information).withAutomaticReconnect().build();try{yield this.connection.start(),yield this.initiateGroupSubscription(),this.onWebSocketMessageReceived(),this._isConnected.next(!0),this.toastService.success("RFID Connected",ve.Success)}catch(e){throw this._isConnected.next(!1),this.toastService.error(JSON.stringify(e),ve.Error),new Error(JSON.stringify(e))}}})}initiateGroupSubscription(){return yt(this,null,function*(){try{yield this.connection.invoke("SubscribeGroup",{CurrentID:"Buy"})}catch(t){throw this.toastService.error(JSON.stringify(t),ve.Error),new Error(JSON.stringify(t))}})}onWebSocketMessageReceived(){this.connection.on("ReceiveSignal",t=>{this._Data.next(t)})}getVariantByCode(t,e=S.GuidEmpty){let i=[{key:"Code",value:t},{key:"EntityID",value:e}];return this.httpService.get(Ae.GetVariantByCode,i).pipe(ye(o=>o instanceof mn?tt(null):Ji(()=>new Error(o.message))))}processGroupedData(t=S.GuidEmpty){return this._Data.pipe(V(e=>e!==null&&e&&Object.keys(e).length>0),Hi(this._bufferTime.getValue()),Ni(e=>Wi(e)),Ki(e=>e.epc),Ni(e=>e.pipe(Tt((i,o)=>[...i,o],[]),Y(i=>{let o=e.key;if(this._cache.has(o))return this._cache.get(o).pipe(d(s=>({epc:o,items:i,response:s})));{let s=this.getVariantByCode(o,t).pipe(V(T=>T),E(T=>this._cache.set(o,tt(T))));return this._cache.set(o,s),s.pipe(d(T=>({epc:o,items:i,response:T})))}}))),Tt((e,i)=>{let o=this.previousCountByEpc&&this.previousCountByEpc[i.epc]||0,s=i.items.length,T=s-o;return e[i.epc]={data:i.items,count:T,variant:i.response},this.previousCountByEpc[i.epc]=s,e},{}),X({bufferSize:1,refCount:!0}))}constructor(){super(),this.connection&&(this.connection.onclose=t=>yt(this,null,function*(){console.error("SignalR connection closed:",t)}),this.connection.onreconnecting=t=>yt(this,null,function*(){console.warn("SignalR reconnecting:",t)}),this.connection.onreconnected=t=>yt(this,null,function*(){console.log("SignalR reconnected:",t)}))}static \u0275fac=function(e){return new(e||n)};static \u0275prov=ne({token:n,factory:n.\u0275fac,providedIn:"root"})};function Qo(n,t){if(n&1&&(r(0,"td",7),m(1),a()),n&2){let e=p().$index;l(),$(" ",e+1,". ")}}function Uo(n,t){if(n&1&&(r(0,"div",10),M(1,"img",21),a()),n&2){let e=p().$implicit;l(),b("src",e.ThumbnailUrl,at)}}function Wo(n,t){n&1&&(r(0,"div",11),M(1,"i",22),a())}function Jo(n,t){if(n&1&&(r(0,"span"),m(1),f(2,"quantityFraction"),a()),n&2){let e=p().$implicit;l(),te(g(2,1,e.Quantity))}}function Ho(n,t){n&1&&(r(0,"span",17),m(1," x "),a())}function Go(n,t){if(n&1&&(r(0,"span"),m(1),f(2,"number"),a()),n&2){let e=p().$implicit;l(),te(g(2,1,e.UnitQuantity))}}function qo(n,t){n&1&&(r(0,"span",17),m(1," x "),a())}function Ko(n,t){if(n&1&&(r(0,"span"),m(1),f(2,"number"),a()),n&2){let e=p().$implicit;l(),te(g(2,1,e.UnitPrice))}}function zo(n,t){if(n&1&&(r(0,"div"),m(1),f(2,"number"),a()),n&2){let e=p().$implicit;l(),$("-",g(2,1,e.Discount),"%")}}function Yo(n,t){if(n&1&&(r(0,"div"),m(1),f(2,"number"),a()),n&2){let e=p().$implicit;l(),$("-",g(2,1,e.DiscountAmount))}}function Xo(n,t){if(n&1&&(m(0),f(1,"number")),n&2){let e=p().$implicit;$(" ",g(1,1,e.Total)," ")}}function Zo(n,t){n&1&&m(0," - ")}function ea(n,t){if(n&1){let e=j();r(0,"tr",6),D("contextmenu",function(){let o=P(e).$index,s=p(2);return O(s.onContextMenu(o))})("click",function(){let o=P(e),s=o.$implicit,T=o.$index,h=p(2);return O(h.update(s,T))}),v(1,Qo,2,1,"td",7),r(2,"td",8)(3,"div",9),v(4,Uo,2,1,"div",10)(5,Wo,2,0,"div",11),r(6,"div",12)(7,"div"),m(8),a(),r(9,"span",13),m(10),a(),M(11,"app-serial-note",14)(12,"small",15),a()()(),r(13,"td",16)(14,"span"),v(15,Jo,3,3,"span"),v(16,Ho,2,0,"span",17),v(17,Go,3,3,"span"),v(18,qo,2,0,"span",17),v(19,Ko,3,3,"span"),a()(),r(20,"td",18),v(21,zo,3,3,"div"),v(22,Yo,3,3,"div"),a(),r(23,"td",16),v(24,Xo,2,3)(25,Zo,1,0),a(),r(26,"td",19)(27,"i",20),D("click",function(){let o=P(e).$index,s=p(2);return O(s.deleteVariant(o))}),a()()()}if(n&2){let e=t.$implicit,i=p(2);b("cdkDragDisabled",!i.enabledDragDrop),l(),_(i.appConfigJSON!=null&&i.appConfigJSON.ModuleBuy.Grid.RowNumberVisible?1:-1),l(),vt("ps-0",i.appConfigJSON==null?null:i.appConfigJSON.ModuleBuy.Grid.RowNumberVisible),l(2),_(e.ThumbnailUrl?4:5),l(4),te(e.Name),l(2),te(e.Code),l(),b("serials",e.Serial),l(),b("innerHtml",e.Note,Yi),l(3),_(e.Quantity!=1||e.UnitQuantity>1?15:-1),l(),_(e.UnitQuantity>1||e.UnitQuantity<=-1?16:-1),l(),_(e.UnitQuantity>1||e.UnitQuantity<=-1?17:-1),l(),_((e.Quantity>1||e.Quantity<=-1)&&i.role.product.Cost?18:-1),l(),_((e.Quantity>1||e.Quantity<=-1||e.Discount>0||e.DiscountAmount>0)&&i.role.product.Cost?19:-1),l(2),_(e.Discount?21:-1),l(),_(e.DiscountAmount?22:-1),l(2),_(i.role.product.Cost?24:25)}}function ta(n,t){if(n&1){let e=j();r(0,"div",1)(1,"table",3)(2,"tbody",4),D("cdkDropListDropped",function(o){P(e);let s=p();return O(s.drop(o))}),Ue(3,ea,28,17,"tr",5,Qe),a()()()}if(n&2){let e=p(),i=ht(3);b("cdkContextMenuTriggerFor",i),l(3),We(e.cart)}}function ia(n,t){n&1&&(r(0,"div",2)(1,"div",23)(2,"div",24)(3,"div",25)(4,"div",26),M(5,"i",27),a(),r(6,"div",28)(7,"span"),m(8,"Empty Cart"),a(),M(9,"br"),r(10,"span"),m(11,"Add products to the cart"),a(),M(12,"br"),r(13,"span"),m(14,"or scan barcode"),a()()()()()())}function na(n,t){if(n&1){let e=j();r(0,"button",31),D("click",function(){P(e);let o=p(2);return O(o.onReturn())}),m(1," Return "),a()}}function oa(n,t){if(n&1){let e=j();r(0,"div",29),v(1,na,2,0,"button",30),r(2,"button",31),D("click",function(){P(e);let o=p();return O(o.onPurchase())}),m(3," Purchase "),a()()}if(n&2){let e=p();l(),_(e.role.sell.Return?1:-1)}}var mi=class n{constructor(t,e,i,o,s,T){this.cartService=t;this.matDialog=e;this.role=i;this.form=o;this.sf=T}cart=[];appConfigJSON;isEdit;outletID;outletName;RFIDService=se(Mt);outletService=se(G);enabledDragDrop=!0;onOpenContextMenuIndex=-1;ngOnInit(){this.initDragDropEnabled(),this.outletService.outlet.valueChanges.pipe(Y(t=>this.RFIDService.processGroupedData(t.ID)),E(t=>this.cartService.addCartRFID(t))).subscribe()}initDragDropEnabled(){S.isMobileDevice&&(this.enabledDragDrop=!1)}deleteVariant(t){this.cartService.deleteVariant(t)}drop(t){this.cartService.dragDropCart(t)}onContextMenu(t){this.onOpenContextMenuIndex=t}onReturn(){this.cartService.returnVariant(this.onOpenContextMenuIndex)}onPurchase(){this.cartService.purchaseVariant(this.onOpenContextMenuIndex)}update(t,e){let i=w({},t);this.matDialog.open(pt,{data:{variant:i,appConfigJSON:this.appConfigJSON,isEdit:this.isEdit,outletID:this.outletID,outletName:this.outletName,deliveryEntityID:this.form.deliveryEntityID.value}}).afterClosed().pipe(V(o=>!!o)).subscribe(o=>{this.cartService.updateVariant(o,e),this.sf.searchFilterNativeEl.focus()})}static \u0275fac=function(e){return new(e||n)(u(ee),u(Z),u(he),u(G),u(ii),u(Nt))};static \u0275cmp=A({type:n,selectors:[["POS-cart-display"]],inputs:{cart:"cart",appConfigJSON:"appConfigJSON",isEdit:"isEdit",outletID:"outletID",outletName:"outletName"},decls:4,vars:1,consts:[["context_menu",""],[3,"cdkContextMenuTriggerFor"],[1,"row","g-0","h-100"],[1,"table","table-borderless"],["cdkDropList","",3,"cdkDropListDropped"],["cdkDrag","",1,"border-bottom",3,"cdkDragDisabled"],["cdkDrag","",1,"border-bottom",3,"contextmenu","click","cdkDragDisabled"],[2,"width","10px"],[2,"width","50%"],[1,"d-flex"],[1,"ratio","ratio-1x1",2,"width","55px"],[1,"item-image","d-flex","justify-content-center","align-items-center","text-center","fs-1"],[1,"ms-4","d-flex","flex-column","justify-content-center",2,"line-height","18px"],[1,"fw-normal","fs-6","text-muted"],[3,"serials"],["title","Note",1,"special-TinyMCE","m-0","fst-italic","d-block",3,"innerHtml"],[1,"text-end"],[1,"fs-6"],[1,"text-end","text-danger"],[1,"text-end",2,"width","75px"],[1,"fa-solid","fa-trash","fs-4","text-danger","pointer",3,"click"],[1,"item-image",3,"src"],[1,"fa-solid","fa-image",2,"color","#b4b4b4c2"],[1,"col-12"],[1,"d-flex","justify-content-center","align-items-center","h-100"],[1,"row"],[1,"col-12","d-flex","justify-content-center"],[1,"fa-regular","fa-cart-arrow-up","text-secondary",2,"font-size","110px"],[1,"col-12","justify-content-center","text-center","mt-5","empty-cart-description","text-secondary","headings-font-family"],["cdkMenu","",1,"example-menu"],["cdkMenuItem","",1,"example-menu-item"],["cdkMenuItem","",1,"example-menu-item",3,"click"]],template:function(e,i){e&1&&(v(0,ta,5,1,"div",1)(1,ia,15,0,"div",2),ut(2,oa,4,1,"ng-template",null,0,Gt)),e&2&&_(i.cart.length?0:1)},dependencies:[ce,On,Pn,In,to,Zn,Xn,eo,Bn,De,ei],styles:[".item-image[_ngcontent-%COMP%]{height:50px;width:56px;display:block;border:solid 1px #dddddd;border-radius:5px;object-fit:contain}.example-menu[_ngcontent-%COMP%]{display:inline-flex;flex-direction:column;min-width:180px;max-width:280px;background-color:#fff;padding:6px 0}.example-menu-item[_ngcontent-%COMP%]{background-color:transparent;cursor:pointer;border:none;-webkit-user-select:none;user-select:none;min-width:64px;line-height:36px;padding:0 16px;display:flex;align-items:center;flex-direction:row;flex:1}.example-menu-item[_ngcontent-%COMP%]:hover{background-color:#f5f5f5}.example-menu-item[_ngcontent-%COMP%]:active{background-color:#dcdcdc}.table[_ngcontent-%COMP%] > [_ngcontent-%COMP%]:not(caption) > *[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]{padding:12px 10px} .cdk-menu.cdk-menu-group.example-menu{box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.empty-cart-description[_ngcontent-%COMP%]{font-size:14px;font-weight:500;color:#c7c7c7}"]})};var pi=class n{constructor(t,e){this.dialogRef=t;this.data=e;this.config.title="Return",this.invoiceNumber=e.invoiceNumber}config=new Ie;invoiceNumber;ok(){this.dialogRef.close(this.invoiceNumber)}static \u0275fac=function(e){return new(e||n)(u(Me),u(Fe))};static \u0275cmp=A({type:n,selectors:[["POS-modal-return-invoice"]],decls:6,vars:2,consts:[[3,"onOk","onCancel","onClose","config"],[1,"form-floating-outline","m-0"],["type","text","id","invoiceNumber","name","invoiceNumber",1,"form-control",3,"ngModelChange","ngModel"],["for","invoiceNumber"]],template:function(e,i){e&1&&(r(0,"modal-material",0),D("onOk",function(){return i.ok()})("onCancel",function(){return i.dialogRef.close()})("onClose",function(){return i.dialogRef.close()}),r(1,"content")(2,"div",1)(3,"input",2),J("ngModelChange",function(s){return L(i.invoiceNumber,s)||(i.invoiceNumber=s),s}),a(),r(4,"label",3),m(5,"Supplier Bill"),a()()()()),e&2&&(b("config",i.config),l(3),W("ngModel",i.invoiceNumber))},dependencies:[Se,be,ae,xe,Oe,Pe],encapsulation:2})};var di=class n{constructor(t){this.matDialog=t}invoiceNumber;disabled=!1;onChange=t=>{};onTouched=()=>{};writeValue(t){this.invoiceNumber=t}registerOnChange(t){this.onChange=t}registerOnTouched(t){this.onTouched=t}setDisabledState(t){this.disabled=t}openModalReturnInvoice(){this.matDialog.open(pi,{data:{invoiceNumber:this.invoiceNumber}}).afterClosed().pipe(V(t=>!!t)).subscribe(t=>{this.invoiceNumber=t,this.onChange(this.invoiceNumber)})}static \u0275fac=function(e){return new(e||n)(u(Z))};static \u0275cmp=A({type:n,selectors:[["POS-return-invoice"]],features:[Ne([{provide:Ke,multi:!0,useExisting:n}])],decls:1,vars:0,consts:[["icon","fa-solid fa-file-invoice","label","Return Bill",3,"click"]],template:function(e,i){e&1&&(r(0,"POS-dropdown-item-more-action",0),D("click",function(){return i.openModalReturnInvoice()}),a())},dependencies:[Zt,ke],encapsulation:2})};var ui=class n{constructor(t){this.cart=t}returnCart(){this.cart.returnCart()}static \u0275fac=function(e){return new(e||n)(u(ee))};static \u0275cmp=A({type:n,selectors:[["POS-return-cart"]],decls:1,vars:0,consts:[["icon","fa-cart-shopping fa-solid","label","Return Cart",3,"click"]],template:function(e,i){e&1&&(r(0,"POS-dropdown-item-more-action",0),D("click",function(){return i.returnCart()}),a())},dependencies:[ke],encapsulation:2})};var fi=class n{constructor(t){this.cart=t}clearCart(){this.cart.clearCart()}static \u0275fac=function(e){return new(e||n)(u(ee))};static \u0275cmp=A({type:n,selectors:[["POS-clear-cart"]],decls:1,vars:0,consts:[["icon","fa-trash fa-solid","label","Clear",3,"click"]],template:function(e,i){e&1&&(r(0,"POS-dropdown-item-more-action",0),D("click",function(){return i.clearCart()}),a())},dependencies:[ke],encapsulation:2})};var gi=class n{constructor(t,e){this.matDialog=t;this.cart=e}appConfigJSON;isEditBuyForm;outletID;outletName;addVariant(){this.matDialog.open(pt,{data:{appConfigJSON:this.appConfigJSON,isEdit:this.isEditBuyForm,outletID:this.outletID,outletName:this.outletName}}).afterClosed().pipe(V(t=>!!t)).subscribe(t=>this.cart.addVariant(t))}static \u0275fac=function(e){return new(e||n)(u(Z),u(ee))};static \u0275cmp=A({type:n,selectors:[["POS-add-variant"]],inputs:{appConfigJSON:"appConfigJSON",isEditBuyForm:"isEditBuyForm",outletID:"outletID",outletName:"outletName"},decls:1,vars:0,consts:[["icon","fa-circle-plus fa-solid","label","Add",3,"click"]],template:function(e,i){e&1&&(r(0,"POS-dropdown-item-more-action",0),D("click",function(){return i.addVariant()}),a())},dependencies:[ke],encapsulation:2})};var Ci=class n{constructor(t,e){this.matDialog=t;this.cart=e}outletID;uploadCart(){this.matDialog.open(qn,{data:{sampleUrl:dn.files.csv.buy_import,outletID:this.outletID,fileEndpoint:"/API/Buy/UploadCsvV2",useUppy:!0}}).afterClosed().pipe(V(t=>!!t),d(t=>t.map(e=>B(w({},e.Variant),{UnitPrice:e.Cost,Total:e.Cost*e.Quantity*(1-e.Discount/100)-e.DiscountAmount,Quantity:e.Quantity,Serial:e.Serial,Note:e.Note,Discount:e.Discount,DiscountAmount:e.DiscountAmount})))).subscribe(t=>this.cart.uploadCart(t))}static \u0275fac=function(e){return new(e||n)(u(Z),u(ee))};static \u0275cmp=A({type:n,selectors:[["POS-upload-cart"]],inputs:{outletID:"outletID"},decls:1,vars:0,consts:[["icon","fa-upload fa-solid","label","Upload",3,"click"]],template:function(e,i){e&1&&(r(0,"POS-dropdown-item-more-action",0),D("click",function(){return i.uploadCart()}),a())},dependencies:[ke],encapsulation:2})};var aa=["serialInput"],yi=class n{constructor(t,e,i){this.dialogRef=t;this.toastr=e;this.cart=i;this.modalConfig.title="Scan Serial",this.modalConfig.customWidth="350px",this.modalConfig.hideOk=!0,this.modalConfig.hideCancel=!0}serialInputEl;modalConfig=new Ie;serial;ngOnInit(){}onKeyDown(t){t.key=="Enter"&&(S.IsNotEmpty(this.serial)?(this.cart.addVariantThroughSerial(this.serial),this.serial=null):this.toastr.warning("Serial Can`t be empty","Warning!"),this.setFocusInput())}setFocusInput(){this.serialInputEl&&setTimeout(()=>{this.serialInputEl?.nativeElement?.focus()},500)}static \u0275fac=function(e){return new(e||n)(u(Me),u(qe),u(ee))};static \u0275cmp=A({type:n,selectors:[["POS-modal-scan-serial"]],viewQuery:function(e,i){if(e&1&&Rt(aa,5),e&2){let o;Bt(o=jt())&&(i.serialInputEl=o.first)}},decls:7,vars:2,consts:[["serialInput",""],[3,"onClose","config"],[1,"input-group","mt-3"],["type","text","placeholder","Input Product By Serial","aria-label","Serial",1,"form-control",3,"ngModelChange","keydown","ngModel"],[1,"input-group-text"],[1,"fa-solid","fa-barcode","fs-4"]],template:function(e,i){if(e&1){let o=j();r(0,"modal-material",1),D("onClose",function(){return P(o),O(i.dialogRef.close())}),r(1,"content")(2,"div",2)(3,"input",3,0),J("ngModelChange",function(T){return P(o),L(i.serial,T)||(i.serial=T),O(T)}),D("keydown",function(T){return P(o),O(i.onKeyDown(T))}),a(),r(5,"span",4),M(6,"i",5),a()()()()}e&2&&(b("config",i.modalConfig),l(3),W("ngModel",i.serial))},dependencies:[Se,be,ae,xe,Oe,Pe],styles:["input[_ngcontent-%COMP%]{height:55px;border-bottom-left-radius:4px;border-top-left-radius:4px}span.input-group-text[_ngcontent-%COMP%]{border-bottom-right-radius:4px;border-top-right-radius:4px}"]})};var bi=class n{constructor(t,e){this.matDialog=t;this.viewContainerRef=e}scanSerial(){this.matDialog.open(yi,{viewContainerRef:this.viewContainerRef})}static \u0275fac=function(e){return new(e||n)(u(Z),u(en))};static \u0275cmp=A({type:n,selectors:[["POS-scan-serial"]],decls:1,vars:0,consts:[["icon","fa-barcode-read fa-solid","label","Serial",3,"click"]],template:function(e,i){e&1&&(r(0,"POS-dropdown-item-more-action",0),D("click",function(){return i.scanSerial()}),a())},dependencies:[ke],encapsulation:2})};var ra=n=>({disabled:n}),la=(n,t)=>({red:n,green:t}),hi=class n{RFIDService=se(Mt);matDialog=se(Z);constructor(){}onOpenModal(){this.matDialog.open(oo).componentInstance.onOK.pipe($n("onPayload"),E(({hostURL:e,bufferTime:i})=>{this.RFIDService.bufferTime=i,this.RFIDService.intializeWebSocket(e)}),X(1)).subscribe()}ngOnInit(){}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=A({type:n,selectors:[["pos-rfid-buy-action"]],decls:8,vars:13,consts:[[1,"dropdown-item","px-1","d-flex",3,"click","ngClass"],["aria-hidden","true",1,"fa-solid","fa-wifi","fs-2"],[1,"pe-0","ps-4","fs-6"],[1,"blob",2,"position","absolute","top","0","right","0",3,"ngClass"]],template:function(e,i){e&1&&(r(0,"div",0),f(1,"async"),D("click",function(){return i.onOpenModal()}),M(2,"i",1),r(3,"label",2),m(4,"Connect RFID"),a(),M(5,"div",3),f(6,"async"),f(7,"async"),a()),e&2&&(b("ngClass",ie(8,ra,g(1,2,i.RFIDService.isConnected))),l(5),b("ngClass",_t(10,la,!g(6,4,i.RFIDService.isConnected),g(7,6,i.RFIDService.isConnected))))},dependencies:[ce,Ge,Ee],styles:[".disabled[_ngcontent-%COMP%]{color:gray;pointer-events:none;cursor:not-allowed}.blob[_ngcontent-%COMP%]{background:#000;border-radius:50%;box-shadow:0 0 #000;height:15px;width:15px;transform:scale(1);animation:_ngcontent-%COMP%_pulse-black 2s infinite}@keyframes _ngcontent-%COMP%_pulse-black{0%{transform:scale(.95);box-shadow:0 0 #000000b3}70%{transform:scale(1);box-shadow:0 0 0 10px #0000}to{transform:scale(.95);box-shadow:0 0 #0000}}.blob.white[_ngcontent-%COMP%]{background:#fff;box-shadow:0 0 #fff;animation:_ngcontent-%COMP%_pulse-white 2s infinite}@keyframes _ngcontent-%COMP%_pulse-white{0%{transform:scale(.95);box-shadow:0 0 #ffffffb3}70%{transform:scale(1);box-shadow:0 0 0 10px #fff0}to{transform:scale(.95);box-shadow:0 0 #fff0}}.blob.red[_ngcontent-%COMP%]{background:#ff5252;box-shadow:0 0 #ff5252;animation:_ngcontent-%COMP%_pulse-red 2s infinite}@keyframes _ngcontent-%COMP%_pulse-red{0%{transform:scale(.95);box-shadow:0 0 #ff5252b3}70%{transform:scale(1);box-shadow:0 0 0 10px #ff525200}to{transform:scale(.95);box-shadow:0 0 #ff525200}}.blob.orange[_ngcontent-%COMP%]{background:#ff793f;box-shadow:0 0 #ff793f;animation:_ngcontent-%COMP%_pulse-orange 2s infinite}@keyframes _ngcontent-%COMP%_pulse-orange{0%{transform:scale(.95);box-shadow:0 0 #ff793fb3}70%{transform:scale(1);box-shadow:0 0 0 10px #ff793f00}to{transform:scale(.95);box-shadow:0 0 #ff793f00}}.blob.yellow[_ngcontent-%COMP%]{background:#ffb142;box-shadow:0 0 #ffb142;animation:_ngcontent-%COMP%_pulse-yellow 2s infinite}@keyframes _ngcontent-%COMP%_pulse-yellow{0%{transform:scale(.95);box-shadow:0 0 #ffb142b3}70%{transform:scale(1);box-shadow:0 0 0 10px #ffb14200}to{transform:scale(.95);box-shadow:0 0 #ffb14200}}.blob.blue[_ngcontent-%COMP%]{background:#34ace0;box-shadow:0 0 #34ace0;animation:_ngcontent-%COMP%_pulse-blue 2s infinite}@keyframes _ngcontent-%COMP%_pulse-blue{0%{transform:scale(.95);box-shadow:0 0 #34ace0b3}70%{transform:scale(1);box-shadow:0 0 0 10px #34ace000}to{transform:scale(.95);box-shadow:0 0 #34ace000}}.blob.green[_ngcontent-%COMP%]{background:#77d933;box-shadow:0 0 #77d933;animation:_ngcontent-%COMP%_pulse-green 2s infinite}@keyframes _ngcontent-%COMP%_pulse-green{0%{transform:scale(.95);box-shadow:0 0 #33d938b3}70%{transform:scale(1);box-shadow:0 0 0 10px #33d9b200}to{transform:scale(.95);box-shadow:0 0 #33d9b200}}.blob.purple[_ngcontent-%COMP%]{background:#8e44ad;box-shadow:0 0 #8e44ad;animation:_ngcontent-%COMP%_pulse-purple 2s infinite}@keyframes _ngcontent-%COMP%_pulse-purple{0%{transform:scale(.95);box-shadow:0 0 #8e44adb3}70%{transform:scale(1);box-shadow:0 0 0 10px #8e44ad00}to{transform:scale(.95);box-shadow:0 0 #8e44ad00}}"],changeDetection:0})};function sa(n,t){n&1&&(r(0,"li",10),M(1,"POS-return-cart"),a())}function ca(n,t){if(n&1&&(r(0,"li",10),M(1,"POS-return-invoice",14),a()),n&2){let e=p(2);l(),b("formControl",e.returnInvoiceNumber)}}function ma(n,t){if(n&1&&(r(0,"div",7)(1,"div",8),m(2,"Order"),a(),M(3,"div",9),v(4,sa,2,0,"li",10),v(5,ca,2,1,"li",10),a()),n&2){let e=p();l(4),_(e.role.sell.Return?4:-1),l(),_(e.role.sell.Return?5:-1)}}var vi=class n{constructor(t,e,i){this.role=t;this.matDialog=e;this.cart=i}returnInvoiceNumber=new me("");appConfigJSON;isEditBuyForm;outletID;outletName;handleKeyboardEvent(t){t.key==="F4"&&this.matDialog.openDialogs.length===0&&this.addVariant()}addVariant(){this.matDialog.open(pt,{data:{appConfigJSON:this.appConfigJSON,isEdit:this.isEditBuyForm,outletID:this.outletID,outletName:this.outletName}}).afterClosed().pipe(V(t=>!!t)).subscribe(t=>this.cart.addVariant(t))}static \u0275fac=function(e){return new(e||n)(u(he),u(Z),u(ee))};static \u0275cmp=A({type:n,selectors:[["POS-more-actions"]],hostBindings:function(e,i){e&1&&D("keydown",function(s){return i.handleKeyboardEvent(s)},Xi)},inputs:{returnInvoiceNumber:"returnInvoiceNumber",appConfigJSON:"appConfigJSON",isEditBuyForm:"isEditBuyForm",outletID:"outletID",outletName:"outletName"},decls:27,vars:6,consts:[["id","moreMenu","data-bs-toggle","dropdown",1,"d-flex","align-items-center","cursor-pointer"],[1,"me-2"],[1,"fa-solid","fa-caret-down","fa-lg"],[1,"fs-6","headings-font-family","pb-1"],[1,"h-100","d-flex","align-items-center","justify-content-between"],["aria-labelledby","moreMenu",1,"dropdown-menu","more-actions"],[1,"d-flex",2,"width","30rem"],[1,"dropdown-header","text-dark","col"],[1,"h5","mb-4"],[1,"dropdown-divider","m-0"],[1,"cursor-pointer"],[3,"appConfigJSON","isEditBuyForm","outletID","outletName"],[3,"outletID"],[1,"cursor-pointer","position-relative"],[3,"formControl"]],template:function(e,i){e&1&&(r(0,"span",0)(1,"span",1),M(2,"i",2),a(),r(3,"span",3),m(4,"More Actions"),a()(),r(5,"div",4)(6,"div",5)(7,"div",6),v(8,ma,6,2,"div",7),r(9,"div",7)(10,"div",8),m(11,"Item"),a(),M(12,"div",9),r(13,"li",10),M(14,"POS-add-variant",11),a(),r(15,"li",10),M(16,"POS-scan-serial"),a(),r(17,"li",10),M(18,"POS-upload-cart",12),a(),r(19,"li",10),M(20,"POS-clear-cart"),a()(),r(21,"div",7)(22,"div",8),m(23,"Advanced"),a(),M(24,"div",9),r(25,"li",13),M(26,"pos-rfid-buy-action"),a()()()()()),e&2&&(l(8),_(i.role.sell.Return?8:-1),l(6),b("appConfigJSON",i.appConfigJSON)("isEditBuyForm",i.isEditBuyForm)("outletID",i.outletID)("outletName",i.outletName),l(4),b("outletID",i.outletID))},dependencies:[Ye,ae,ze,di,ui,fi,gi,Ci,bi,hi],encapsulation:2})};var _i=class n{constructor(t,e){this.dialogRef=t;this.config.title="Discount and Tax",this.config.customWidth="400px";let i=e.discount;this.discountAmount=i.Amount,this.discountPercentage=i.Percentage;let o=e.tax;this.taxID=o.ID,this.taxRate=o.Rate,this.taxType=o.CalculationTypeName,this.taxLabel=o.Label,this.taxes=e.taxes.filter(s=>!s.Bin),this.currencySymbol=e.currencySymbol}config=new Ie;tabIndexActive;discountAmount=0;discountPercentage=0;taxes=[];taxID="";taxRate=0;taxType="";taxLabel="";discounts=[];currencySymbol="";ok(){this.dialogRef.close({Discount:{Amount:this.discountAmount,Percentage:this.discountPercentage},Tax:{ID:this.taxID,Rate:this.taxRate,CalculationTypeName:this.taxType,Label:this.taxLabel,Discontinue:!1}})}close(){this.dialogRef.close()}calculateDiscountCalculator(){let t=100;this.discounts.forEach(e=>{t=t*(100-e)/100}),this.discountPercentage=100-t}updateTax(t){this.taxID=t.ID,this.taxRate=t.Rate,this.taxType=t.CalculationTypeName,this.taxLabel=t.Label}static \u0275fac=function(e){return new(e||n)(u(Me),u(Fe))};static \u0275cmp=A({type:n,selectors:[["POS-modal-discount-and-tax"]],decls:48,vars:10,consts:[[3,"keydown.F2","onOk","onCancel","onClose","config"],[1,"container"],["matTooltipPosition","above","matTooltip","Discount","tabTitle","Discount"],[1,"row","d-flex","align-items-center","justify-content-start"],[1,"col-3"],[1,"fw-bold","d-block"],[1,"col-9"],["type","text","data-cy","discount1","autoNum","","percentage","","decimalPlaces","2",1,"form-control","d-inline-block",2,"width","100px",3,"ngModelChange","ngModel"],[1,"ms-1"],[1,"row","d-flex","align-items-center","justify-content-start","mt-6"],["type","text","data-cy","discountamount","autoNum","",1,"form-control","d-inline-block",2,"width","100px",3,"ngModelChange","ngModel"],["matTooltipPosition","above","matTooltip","Tax","tabTitle","Tax"],["bindLabel","Label","appendTo","body","bindValue","ID","placeholder","Tax","data-cy","Tax",2,"width","150px",3,"change","clearable","ngModel","items"],["matTooltipPosition","above","matTooltip","Calculation","tabTitle","Calculator"],[1,"row","mt-6","g-0","d-flex","align-items-center","justify-content-start"],[1,"col-4"],[1,"col-8","ps-4"],["type","text","data-cy","discountCal1","autoNum","","percentage","","decimalPlaces","2",1,"form-control","d-inline-block",2,"width","47px",3,"ngModelChange","ngModel"],[1,"mx-2"],["type","text","data-cy","discountCal2","autoNum","","percentage","","decimalPlaces","2",1,"form-control","d-inline-block",2,"width","47px",3,"ngModelChange","ngModel"],["type","text","data-cy","discountCal3","autoNum","","percentage","","decimalPlaces","2",1,"form-control","d-inline-block",2,"width","47px",3,"ngModelChange","ngModel"]],template:function(e,i){e&1&&(r(0,"modal-material",0),D("keydown.F2",function(){return i.ok()})("onOk",function(){return i.ok()})("onCancel",function(){return i.close()})("onClose",function(){return i.close()}),r(1,"content")(2,"div",1)(3,"custom-tabs"),Vt(4),r(5,"tab",2)(6,"div",3)(7,"div",4)(8,"label",5),m(9,"Discount %"),a()(),r(10,"div",6)(11,"input",7),J("ngModelChange",function(s){return L(i.discountPercentage,s)||(i.discountPercentage=s),s}),a(),r(12,"span",8),m(13,"%"),a()()(),r(14,"div",9)(15,"div",4)(16,"label",5),m(17),a()(),r(18,"div",6)(19,"input",10),J("ngModelChange",function(s){return L(i.discountAmount,s)||(i.discountAmount=s),s}),a()()()(),$t(),Vt(20),r(21,"tab",11)(22,"div",3)(23,"div",4)(24,"label",5),m(25,"Tax"),a()(),r(26,"div",6)(27,"ng-select",12),D("change",function(s){return i.updateTax(s)}),a()()()(),$t(),Vt(28),r(29,"tab",13)(30,"div",14)(31,"div",15)(32,"label",5),m(33,"Discount Calculator"),a()(),r(34,"div",16)(35,"input",17),J("ngModelChange",function(s){return L(i.discounts[0],s)||(i.discounts[0]=s),s}),D("ngModelChange",function(){return i.calculateDiscountCalculator()}),a(),r(36,"span"),m(37," %"),a(),r(38,"span",18),m(39,"+"),a(),r(40,"input",19),J("ngModelChange",function(s){return L(i.discounts[1],s)||(i.discounts[1]=s),s}),D("ngModelChange",function(){return i.calculateDiscountCalculator()}),a(),r(41,"span"),m(42," %"),a(),r(43,"span",18),m(44,"+"),a(),r(45,"input",20),J("ngModelChange",function(s){return L(i.discounts[2],s)||(i.discounts[2]=s),s}),D("ngModelChange",function(){return i.calculateDiscountCalculator()}),a(),r(46,"span"),m(47," %"),a()()()(),$t(),a()()()()),e&2&&(b("config",i.config),l(11),W("ngModel",i.discountPercentage),l(6),$("Discount ",i.currencySymbol),l(2),W("ngModel",i.discountAmount),l(8),b("clearable",!1)("ngModel",i.taxID)("items",i.taxes),l(8),W("ngModel",i.discounts[0]),l(5),W("ngModel",i.discounts[1]),l(5),W("ngModel",i.discounts[2]))},dependencies:[Se,be,ae,xe,Dt,Oe,Pe,Wn,Hn,Jn,st,ct,lt,rt,xt],encapsulation:2})};var Di=class n{constructor(t){this.matDialog=t}taxes=[];currencySymbol="";discTax;disabled=!1;onChange=t=>{};onTouched=()=>{};writeValue(t){this.discTax=t}registerOnChange(t){this.onChange=t}registerOnTouched(t){this.onTouched=t}setDisabledState(t){this.disabled=t}openModalDiscountAndTax(){this.matDialog.open(_i,{data:{discount:w({},this.discTax.Discount),tax:w({},this.discTax.Tax),taxes:this.taxes,currencySymbol:this.currencySymbol}}).afterClosed().pipe(V(t=>!!t)).subscribe(t=>{this.discTax.Discount=w({},t.Discount),this.discTax.Tax=w({},t.Tax),this.onChange(this.discTax)})}static \u0275fac=function(e){return new(e||n)(u(Z))};static \u0275cmp=A({type:n,selectors:[["POS-discount-and-tax-form"]],inputs:{taxes:"taxes",currencySymbol:"currencySymbol"},features:[Ne([{provide:Ke,multi:!0,useExisting:n}])],decls:2,vars:0,consts:[["type","button","matTooltip","Discount / Tax","matTooltipPosition","above",1,"btn","btn-success","fs-5",2,"border-right","0.1px solid #fff",3,"click"],[1,"fa-light","fa-percent"]],template:function(e,i){e&1&&(r(0,"button",0),D("click",function(){return i.openModalDiscountAndTax()}),M(1,"i",1),a())},dependencies:[lt,rt,Zt],styles:["button[_ngcontent-%COMP%]{border-right:.1px solid #fff;border-top-right-radius:0;border-bottom-right-radius:0;position:relative;flex:1 1 auto}"]})};var Ft=n=>({selected:n}),pa=(n,t)=>({"col-sm-3":n,"col-sm-7":t});function da(n,t){if(n&1){let e=j();r(0,"div",10)(1,"label",11)(2,"input",12),J("ngModelChange",function(o){P(e);let s=p(2);return L(s.tagID,o)||(s.tagID=o),O(o)}),a(),m(3),a()()}if(n&2){let e=t.$implicit,i=t.$index,o=p(2);l(),b("for",Ai("potype-"+i))("ngClass",ie(8,Ft,o.tagID==e.ID)),l(),b("id",Ai("potype-"+i)),W("ngModel",o.tagID),b("value",e.ID),l(),$(" ",e.Name," ")}}function ua(n,t){if(n&1&&(r(0,"div",8),Ue(1,da,4,10,"div",10,Qe),a()),n&2){let e=p();l(),We(e.supplierPOTypes)}}function fa(n,t){if(n&1){let e=j();r(0,"strong",13),m(1,"Supplier Bill Number"),a(),r(2,"input",14),J("ngModelChange",function(o){P(e);let s=p();return L(s.invoiceNumber,o)||(s.invoiceNumber=o),O(o)}),a()}if(n&2){let e=p();l(2),W("ngModel",e.invoiceNumber)}}function ga(n,t){if(n&1){let e=j();r(0,"div",9)(1,"POS-tinymce-editor",15),J("ngModelChange",function(o){P(e);let s=p();return L(s.note,o)||(s.note=o),O(o)}),a()()}if(n&2){let e=p();l(),W("ngModel",e.note)}}function Ca(n,t){if(n&1){let e=j();r(0,"div",21)(1,"span",26),m(2,"@"),a(),r(3,"input",27),J("ngModelChange",function(o){P(e);let s=p(2);return L(s.exchangeRate,o)||(s.exchangeRate=o),O(o)}),a()()}if(n&2){let e=p(2);l(3),W("ngModel",e.exchangeRate)}}function ya(n,t){if(n&1){let e=j();r(0,"div",16)(1,"div",17)(2,"div",18),m(3,"Currency :"),a(),r(4,"div",19)(5,"ng-select",20),J("ngModelChange",function(o){P(e);let s=p();return L(s.currencyID,o)||(s.currencyID=o),O(o)}),a()(),v(6,Ca,4,1,"div",21),a()(),r(7,"div",22)(8,"div",23),m(9,"Term :"),a(),r(10,"div",24)(11,"ng-select",25),J("ngModelChange",function(o){P(e);let s=p();return L(s.note,o)||(s.note=o),O(o)}),a()()()}if(n&2){let e=p();l(4),b("ngClass",_t(8,pa,e.currencyID!=e.defaultCurrencyID,e.currencyID==e.defaultCurrencyID)),l(),b("items",e.currencies),W("ngModel",e.currencyID),b("clearable",!1),l(),_(e.currencyID!=e.defaultCurrencyID?6:-1),l(5),b("items",e.predefinedNotes),W("ngModel",e.note),b("clearable",!1)}}var xi=class n{constructor(t,e){this.dialogRef=t;this.config=new Ie,this.config.title="Purchase Order Note",this.config.customWidth="700px",this.note=e.note,this.tagID=e.tagID,this.currencyID=e.currencyID,this.exchangeRate=e.currencies.find(i=>i.ID==this.currencyID).ExchangeRate,this.supplierPOTypes=e.supplierPOTypes,this.predefinedNotes=e.predefinedNotes,this.currencies=e.currencies,this.defaultCurrencyID=e.defaultCurrencyID,this.invoiceNumber=e.invoiceNumber,S.IsEmpty(this.tagID)&&(this.tagID=this.supplierPOTypes[0]?.ID)}supplierPOTypes;predefinedNotes;currencies;currencyID;note;tagID;defaultCurrencyID;exchangeRate=0;invoiceNumber;tabState="Note";config;ok(){this.dialogRef.close({Note:this.note,TagID:this.tagID,Currency:B(w({},this.currencies.find(t=>t.ID==this.currencyID)),{ExchangeRate:this.exchangeRate}),InvoiceNumber:this.invoiceNumber})}close(){this.dialogRef.close()}onTabChange(t){this.tabState=t}static \u0275fac=function(e){return new(e||n)(u(Me),u(Fe))};static \u0275cmp=A({type:n,selectors:[["POS-modal-note"]],decls:18,vars:17,consts:[[3,"onCancel","onClose","onOk","config"],[1,"container-fluid"],[1,"row","border-bottom"],["data-cy","note",1,"btn","btn-link",3,"click","ngClass"],["data-cy","type",1,"btn","btn-link",3,"click","ngClass"],["data-cy","number",1,"btn","btn-link",3,"click","ngClass"],["data-cy","other",1,"btn","btn-link",3,"click","ngClass"],[1,"row","mt-8"],[1,"col-12"],[1,"col-12","tinymce"],[1,"rad-btn"],[3,"for","ngClass"],["type","radio",3,"ngModelChange","ngModel","value","id"],[1,"mb-2","ps-0"],["type","text","placeholder","Same as Purchase Order Number when blank",1,"form-control","w-50",3,"ngModelChange","ngModel"],[3,"ngModelChange","ngModel"],[1,"col-7","pe-0"],[1,"row"],[1,"col-sm-3","d-flex","align-items-center"],[1,"ps-0",3,"ngClass"],["bindLabel","Name","bindValue","ID","placeholder","Outlet","appendTo","body",3,"ngModelChange","items","ngModel","clearable"],[1,"col-sm-4","d-flex"],[1,"col-5","d-flex","align-items-center","ps-0"],[1,"col-sm-2"],[1,"col-sm-10"],["bindLabel","Label","bindValue","Description","placeholder","Term","appendTo","body",3,"ngModelChange","items","ngModel","clearable"],[1,"pt-4"],["type","text","autoNum","",1,"border","border-light",2,"width","100px",3,"ngModelChange","ngModel"]],template:function(e,i){e&1&&(r(0,"modal-material",0),D("onCancel",function(){return i.close()})("onClose",function(){return i.close()})("onOk",function(){return i.ok()}),r(1,"content")(2,"div",1)(3,"div",2)(4,"div")(5,"a",3),D("click",function(){return i.onTabChange("Note")}),m(6," Note "),a(),r(7,"a",4),D("click",function(){return i.onTabChange("Tag")}),m(8," Tag "),a(),r(9,"a",5),D("click",function(){return i.onTabChange("Number")}),m(10," Number "),a(),r(11,"a",6),D("click",function(){return i.onTabChange("Other")}),m(12," Other "),a()()(),r(13,"div",7),v(14,ua,3,0,"div",8),v(15,fa,3,1),v(16,ga,2,1,"div",9),v(17,ya,12,11),a()()()()),e&2&&(b("config",i.config),l(5),b("ngClass",ie(9,Ft,i.tabState=="Note")),l(2),b("ngClass",ie(11,Ft,i.tabState=="Tag")),l(2),b("ngClass",ie(13,Ft,i.tabState=="Number")),l(2),b("ngClass",ie(15,Ft,i.tabState=="Other")),l(3),_(i.tabState=="Tag"?14:-1),l(),_(i.tabState=="Number"?15:-1),l(),_(i.tabState=="Note"?16:-1),l(),_(i.tabState=="Other"?17:-1))},dependencies:[ce,Ge,Se,be,yn,ae,xe,Dt,xt,ai,oi,st,ct,Oe,Pe],styles:[".text-warning[_ngcontent-%COMP%]{color:var(--bs-warning)!important}.bg-light-gray[_ngcontent-%COMP%]{background-color:var(--bs-light-gray);--bs-bg-opacity: .15 !important}.bg-gradient-danger[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#f8d7da,#f8d7da 15px,#f5c6cb 15px 30px)!important}.bg-gradient-success[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#beeebb,#beeebb 15px,#afeba8 15px 30px)!important}.bg-gradient-warning[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#fcf3cf,#fcf3cf 15px,#f9e79f 15px 30px)!important}.bg-light-orange[_ngcontent-%COMP%]{background-color:var(--bs-light-orange);--bs-bg-opacity: .15 !important}.text-danger[_ngcontent-%COMP%]{color:#fb404b!important}.text-dark[_ngcontent-%COMP%]{color:#5e5e5e!important}.text-success[_ngcontent-%COMP%]{color:#87cb16!important}.text-black[_ngcontent-%COMP%]{color:#000!important}.text-white[_ngcontent-%COMP%]{color:var(--bs-white)!important}.btn-light-blue[_ngcontent-%COMP%]{color:#212529;background-color:#dfeffc!important;border-color:#dfeffc}.btn-light-blue[_ngcontent-%COMP%]:hover{color:#212529;background-color:#bcdef9;border-color:#b0d8f8}.btn-light-blue[_ngcontent-%COMP%]:focus, .btn-light-blue.focus[_ngcontent-%COMP%]{color:#212529;background-color:#bcdef9;border-color:#b0d8f8;box-shadow:0 0 0 .2rem #c3d1dc80}.btn-light-blue.disabled[_ngcontent-%COMP%], .btn-light-blue[_ngcontent-%COMP%]:disabled{color:#212529;background-color:#dfeffc;border-color:#dfeffc}.btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active, .btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active, .show[_ngcontent-%COMP%] > .btn-light-blue.dropdown-toggle[_ngcontent-%COMP%]{color:#212529;background-color:#b0d8f8;border-color:#a5d2f7}.btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active:focus, .btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active:focus, .show[_ngcontent-%COMP%] > .btn-light-blue.dropdown-toggle[_ngcontent-%COMP%]:focus{box-shadow:0 0 0 .2rem #c3d1dc80}.btn-light-danger[_ngcontent-%COMP%]{color:#212529;background-color:#f8d7da!important;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:hover{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5}.btn-light-danger[_ngcontent-%COMP%]:focus, .btn-light-danger.focus[_ngcontent-%COMP%]{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5;box-shadow:0 0 0 .2rem #dc354540}.btn-light-danger.disabled[_ngcontent-%COMP%], .btn-light-danger[_ngcontent-%COMP%]:disabled{color:#212529;background-color:#f8d7da;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]{color:#212529;background-color:#f1aeb5;border-color:#ea868f}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active:focus, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active:focus, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]:focus{box-shadow:0 0 0 .2rem #dc354540}content[_ngcontent-%COMP%] > div.container-fluid[_ngcontent-%COMP%]{min-height:200px}.tinymce[_ngcontent-%COMP%] a[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{z-index:2;position:absolute;right:15px;bottom:19px}.tinymce[_ngcontent-%COMP%] editor[_ngcontent-%COMP%]{height:max-content;z-index:1}.rad-btn[_ngcontent-%COMP%]{position:relative;display:inline-block}.rad-btn[_ngcontent-%COMP%] label[_ngcontent-%COMP%]{border:1px solid #dddddd;border-radius:3px;margin-right:10px;cursor:pointer;padding:10px;margin-bottom:10px;color:#000}.rad-btn[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{visibility:hidden;position:absolute;left:0;top:0}.rad-btn[_ngcontent-%COMP%] label.selected[_ngcontent-%COMP%]{background:#dcdcdc;border:1px solid #dcdcdc}.btn-link[_ngcontent-%COMP%]{padding-top:0;color:#868686;padding-bottom:8px;border-radius:unset;font-family:Roboto Slab,serif}.btn-link.selected[_ngcontent-%COMP%]{color:#3b3b3b;border-bottom:4px solid #07a519}a.btn.btn-link[_ngcontent-%COMP%]{color:inherit}"]})};var Si=class n{constructor(t){this.matDialog=t}supplierPOTypes;predefinedNotes;defaultCurrencyID;currencies;note;disabled=!1;onChange=t=>{};onTouched=()=>{};writeValue(t){this.note=t}registerOnChange(t){this.onChange=t}registerOnTouched(t){this.onTouched=t}setDisabledState(t){this.disabled=t}openModalNote(){this.matDialog.open(xi,{data:{note:this.note.Note,tagID:this.note.TagID,exchangeRate:this.note.Currency.ExchangeRate,currencyID:this.note.Currency.ID,supplierPOTypes:this.supplierPOTypes,predefinedNotes:this.predefinedNotes,currencies:this.currencies,defaultCurrencyID:this.defaultCurrencyID,invoiceNumber:this.note.InvoiceNumber}}).afterClosed().pipe(V(t=>!!t)).subscribe(t=>{this.note=t,this.onChange(t)})}static \u0275fac=function(e){return new(e||n)(u(Z))};static \u0275cmp=A({type:n,selectors:[["POS-note-form"]],inputs:{supplierPOTypes:"supplierPOTypes",predefinedNotes:"predefinedNotes",defaultCurrencyID:"defaultCurrencyID",currencies:"currencies"},features:[Ne([{provide:Ke,multi:!0,useExisting:n}])],decls:2,vars:0,consts:[["type","button",1,"btn","btn-gray","w-100","h-100","fs-3","px-0","py-6","headings-font-family",3,"click"],[1,"fa-regular","fa-note-sticky","fa-xl"]],template:function(e,i){e&1&&(Je(0,"button",0),bt("click",function(){return i.openModalNote()}),kt(1,"i",1),it())},styles:[".btn-gray[_ngcontent-%COMP%]{border:1px solid #d6d6d6;color:#545454!important;background:linear-gradient(to bottom,#fff,#eee)}"]})};function ba(n,t){if(n&1){let e=j();r(0,"div",10)(1,"div",12)(2,"h5"),m(3,"Add inventory to outlet"),a()(),r(4,"div",13)(5,"ng-select",14),J("ngModelChange",function(o){P(e);let s=p();return L(s.deliveryEntityID,o)||(s.deliveryEntityID=o),O(o)}),a()()()}if(n&2){let e=p();l(5),b("clearable",!1),W("ngModel",e.deliveryEntityID),b("items",e.outlets)("disabled",e.isEdit)}}function ha(n,t){n&1&&(r(0,"div",11)(1,"div",15)(2,"h5",16),m(3," Unfulfilled order, product inventory is awaiting "),a()()())}var Mi=class n{constructor(t,e,i){this.dialogRef=t;this.datePipe=e;this.data=i;this.config=new Ie,this.config.title="Purchase Order Fulfillment",this.config.customWidth="650px",this.isEdit=i.isEdit,this.deliveryEntityID=S.IsNotEmpty(i.deliveryEntityID)?i.deliveryEntityID:i.outletID,this.outlets=i.outlets,this.fulfillmentDate=i.fulfillmentDate,this.appConfigJSON=i.appConfigJSON,S.IsNotEmpty(i.deliveryEntityID)?this.tabState="Now":this.tabState="Later"}isEdit=!1;outlets;deliveryEntityID;tabState="Now";config;fulfillmentDate;fulfillmentTime;fulfillmentDateTime;shippingDateLabel="Fulfillment Date";appConfigJSON;ok(){this.tabState=="Later"&&this.setCustomDateField(),this.dialogRef.close(this.deliveryEntityID)}close(){this.dialogRef.close()}setCustomDateField(){this.fulfillmentDate=this.fulfillmentDate?this.fulfillmentDate:new Date;let t=this.fulfillmentTime?this.datePipe.transform(this.fulfillmentTime,"HH:mm"):"00:00",e=this.datePipe.transform(this.fulfillmentDate,"d MMM y");this.fulfillmentDateTime=`${e} ${t}`}onChangeTab(t){t=="Now"?(this.fulfillmentDate=null,this.deliveryEntityID=S.IsNotEmpty(this.data.deliveryEntityID)?this.data.deliveryEntityID:this.data.outletID):(this.deliveryEntityID=S.GuidEmpty,this.fulfillmentDate=new Date)}static \u0275fac=function(e){return new(e||n)(u(Me),u(cn),u(Fe))};static \u0275cmp=A({type:n,selectors:[["POS-modal-fulfillment"]],decls:20,vars:3,consts:[[3,"onOk","onCancel","onClose","config"],[1,"container"],[1,"row","align-items-start","py-2","my-2"],[1,"col"],["name","fontStyle","aria-label","Font Style",1,"fulfillment-tab",3,"ngModelChange","change","ngModel"],["data-cy","Now","value","Now"],[1,"p-7","me-2"],[1,"text-body-secondary","tabDesc"],["data-cy","Later","value","Later"],[1,"p-7"],[1,"row","align-items-center","mt-5"],[1,"row","mt-8"],[1,"col-auto"],[1,"col","d-flex","justify-content-end"],["appendTo","body","bindLabel","Name","bindValue","ID","placeholder","Outlet","data-cy","DeductInventory",1,"tall","auto-grow",2,"width","250px",3,"ngModelChange","clearable","ngModel","items","disabled"],[1,"col-12","pe-0"],[1,"bg-gradient-warning","text-center","py-7","rounded-3","border","mb-7"]],template:function(e,i){e&1&&(r(0,"modal-material",0),D("onOk",function(){return i.ok()})("onCancel",function(){return i.close()})("onClose",function(){return i.close()}),r(1,"content")(2,"div",1)(3,"div",2)(4,"div",3)(5,"mat-button-toggle-group",4),J("ngModelChange",function(s){return L(i.tabState,s)||(i.tabState=s),s}),D("change",function(s){return i.onChangeTab(s.value)}),r(6,"mat-button-toggle",5)(7,"h3",6),m(8," Now "),r(9,"small",7)(10,"em"),m(11,"(in store purchase)"),a()()()(),r(12,"mat-button-toggle",8)(13,"h3",9),m(14," Later "),r(15,"small",7)(16,"em"),m(17,"(shipped to customer address)"),a()()()()()()(),v(18,ba,6,4,"div",10)(19,ha,4,0,"div",11),a()()()),e&2&&(b("config",i.config),l(5),W("ngModel",i.tabState),l(13),_(i.tabState=="Now"?18:19))},dependencies:[Oe,Pe,xt,Sn,Dn,xn,Se,ae,xe,ti,Vn],styles:[".container[_ngcontent-%COMP%]{min-height:150px} .p-datepicker.p-component.p-datepicker-timeonly{z-index:99999!important}.tabDesc[_ngcontent-%COMP%]{font-size:80%;font-weight:400} mat-button-toggle-group.fulfillment-tab mat-pseudo-checkbox{display:none}"]})};var Ii=class n{constructor(t){this.matDialog=t}outlets;outletID;appConfigJSON;isEdit;deliveryEntityID;disabled=!1;onChange=t=>{};onTouched=()=>{};writeValue(t){this.deliveryEntityID=t}registerOnChange(t){this.onChange=t}registerOnTouched(t){this.onTouched=t}setDisabledState(t){this.disabled=t}openModalFulfillment(){this.matDialog.open(Mi,{data:{deliveryEntityID:this.deliveryEntityID,outlets:this.outlets,outletID:this.outletID,appConfigJSON:this.appConfigJSON,isEdit:this.isEdit}}).afterClosed().pipe(V(t=>!!t)).subscribe(t=>{this.deliveryEntityID=t,this.onChange(t)})}isDeliveryEntityIDEmpty(){return S.IsEmpty(this.deliveryEntityID)&&S.IsNotEmpty(this.outletID)}static \u0275fac=function(e){return new(e||n)(u(Z))};static \u0275cmp=A({type:n,selectors:[["POS-fulfillment-form"]],inputs:{outlets:"outlets",outletID:"outletID",appConfigJSON:"appConfigJSON",isEdit:"isEdit"},features:[Ne([{provide:Ke,multi:!0,useExisting:n}])],decls:4,vars:2,consts:[["type","button",1,"btn","btn-gray","w-100","h-100","fs-3","px-0","py-6","headings-font-family",3,"click"],[1,"fa-solid","fa-dolly","me-3"]],template:function(e,i){e&1&&(Je(0,"button",0),bt("click",function(){return i.openModalFulfillment()}),kt(1,"i",1),Je(2,"span"),m(3,"Fulfillment"),it()()),e&2&&vt("bg-gradient-warning",i.isDeliveryEntityIDEmpty())},styles:[".btn-gray[_ngcontent-%COMP%]{border:1px solid #d6d6d6;color:#545454!important;background:linear-gradient(to bottom,#fff,#eee)}"]})};var lo=n=>({selected:n}),va=n=>({active:n});function _a(n,t){if(n&1){let e=j();r(0,"a",4),D("click",function(){P(e);let o=p();return O(o.isPayNow=!1)}),m(1," Later "),r(2,"span",7),m(3,"Take Credit"),a()()}if(n&2){let e=p();b("ngClass",ie(1,lo,!e.isPayNow))}}function Da(n,t){if(n&1){let e=j();r(0,"div",16)(1,"a",17),D("click",function(){let o=P(e).$implicit,s=p(4);return O(s.inputAmount=o)}),m(2),f(3,"number"),a()()}if(n&2){let e=t.$implicit,i=p(4);l(),b("ngClass",ie(5,va,i.paymentMethodID==i.cashPaymentID&&i.inputAmount==e)),l(),He("",i.currencySymbol," ",g(3,3,e))}}function xa(n,t){if(n&1&&(r(0,"div",14),Ue(1,Da,4,7,"div",16,Qe),a()),n&2){let e=p(3);l(),We(e.suggestedCash)}}function Sa(n,t){if(n&1&&(r(0,"div",19),m(1),f(2,"number"),a()),n&2){let e=p(4);b("ngClass",e.inputAmount>e.amountToPay?"success":"danger"),l(),He(" ",e.currencySymbol," ",g(2,3,e.inputAmount-e.amountToPay)," ")}}function Ma(n,t){if(n&1){let e=j();r(0,"input",18),J("ngModelChange",function(o){P(e);let s=p(3);return L(s.inputAmount,o)||(s.inputAmount=o),O(o)}),D("click",function(){P(e);let o=p(3);return o.paymentMethodID=o.cashPaymentID,o.paymentMethodState="Cash",O(o.paymentMethodName="Cash")}),a(),v(1,Sa,3,5,"div",19)}if(n&2){let e=p(3);W("ngModel",e.inputAmount),l(),_(e.inputAmount!=e.amountToPay?1:-1)}}function Ia(n,t){if(n&1){let e=j();r(0,"div",20),D("click",function(){P(e);let o=p(3);return o.paymentMethodID=o.cashPaymentID,O(o.paymentMethodState="Cash")}),M(1,"input",21),a()}if(n&2){let e=p(3);l(),b("value",e.currencySymbol+" -")}}function Pa(n,t){if(n&1&&(r(0,"div",8)(1,"div",10),M(2,"i",11),m(3," Cash "),a(),r(4,"div",12)(5,"div",13),v(6,xa,3,0,"div",14),r(7,"div",15),v(8,Ma,2,2)(9,Ia,2,1,"div"),a()()()()),n&2){let e=p(2);l(6),_(e.role.product.Cost?6:-1),l(2),_(e.role.product.Cost?8:9)}}function Oa(n,t){if(n&1){let e=j();r(0,"div",23)(1,"a",25),D("click",function(){let o=P(e).$implicit,s=p(3);return O(s.onSelectPaymentMethod(o.ID,"Card",o.Name))}),r(2,"span",26),M(3,"img",27),a(),r(4,"span",26),m(5),f(6,"limitText"),a()()()}if(n&2){let e=t.$implicit,i=p(3);l(),b("ngClass",i.paymentMethodID===e.ID?"active":""),l(),b("hidden",e.ImageUrl==null),l(),b("src",e.ImageUrl,at),l(),b("hidden",e.ImageUrl!=null),l(),$(" ",wt(6,5,e.Name,20)," ")}}function Ta(n,t){if(n&1){let e=j();r(0,"div",24)(1,"div",28)(2,"input",29),J("ngModelChange",function(o){P(e);let s=p(3);return L(s.paymentNote,o)||(s.paymentNote=o),O(o)}),a(),r(3,"input",30),J("ngModelChange",function(o){P(e);let s=p(3);return L(s.paymentCode,o)||(s.paymentCode=o),O(o)}),a()()()}if(n&2){let e=p(3);l(2),W("ngModel",e.paymentNote),l(),W("ngModel",e.paymentCode)}}function wa(n,t){if(n&1&&(r(0,"div",8)(1,"div",10),M(2,"i",22),m(3," Card "),a(),r(4,"div",12)(5,"div",13),Ue(6,Oa,7,8,"div",23,Qe),a(),v(8,Ta,4,2,"div",24),a()()),n&2){let e=p(2);l(6),We(e.cardPayments),l(2),_(e.paymentMethodState=="Card"?8:-1)}}function Na(n,t){if(n&1){let e=j();r(0,"div",23)(1,"a",25),D("click",function(){let o=P(e).$implicit,s=p(3);return O(s.onSelectPaymentMethod(o.ID,"Other",o.Name))}),m(2),f(3,"limitText"),a()()}if(n&2){let e=t.$implicit,i=p(3);l(),b("ngClass",i.paymentMethodID===e.ID?"active":""),l(),$(" ",wt(3,2,e.Name,20)," ")}}function Ea(n,t){if(n&1){let e=j();r(0,"div",24)(1,"div",28)(2,"input",29),J("ngModelChange",function(o){P(e);let s=p(3);return L(s.paymentNote,o)||(s.paymentNote=o),O(o)}),a(),r(3,"input",30),J("ngModelChange",function(o){P(e);let s=p(3);return L(s.paymentCode,o)||(s.paymentCode=o),O(o)}),a()()()}if(n&2){let e=p(3);l(2),W("ngModel",e.paymentNote),l(),W("ngModel",e.paymentCode)}}function Fa(n,t){if(n&1&&(r(0,"div",9)(1,"div",10),m(2,"Others"),a(),r(3,"div",12)(4,"div",13),Ue(5,Na,4,5,"div",23,Qe),a(),v(7,Ea,4,2,"div",24),a()()),n&2){let e=p(2);l(5),We(e.otherPayments),l(2),_(e.paymentMethodState=="Other"?7:-1)}}function Aa(n,t){if(n&1&&(r(0,"div"),v(1,Pa,10,2,"div",8),v(2,wa,9,1,"div",8),v(3,Fa,8,1,"div",9),a()),n&2){let e=p();l(),_(e.isCashSuspended?1:-1),l(),_(e.cardPayments.length>0?2:-1),l(),_(e.otherPayments.length>0?3:-1)}}function ka(n,t){if(n&1){let e=j();r(0,"div",6)(1,"div",31)(2,"h5",32),m(3,"Due"),a(),r(4,"datepicker",33),J("dateChange",function(o){P(e);let s=p();return L(s.dueDate,o)||(s.dueDate=o),O(o)}),D("dateChange",function(){P(e);let o=p();return O(o.onChangeDueDate())}),a()(),r(5,"div",34)(6,"h5",32),m(7,"Days Due"),a(),r(8,"div",12)(9,"input",35),J("ngModelChange",function(o){P(e);let s=p();return L(s.dueDays,o)||(s.dueDays=o),O(o)}),D("ngModelChange",function(){P(e);let o=p();return O(o.onChangeDueDay())}),a()()()()}if(n&2){let e=p();l(4),b("displayToggle",!1),W("date",e.dueDate),l(5),W("ngModel",e.dueDays)}}var Pi=class n{constructor(t,e,i){this.dialogRef=t;this.role=i;this.isDefaultTabPayLater=e.payDefaultState==!1,this.config=new Ie,this.config.title="Amount to Pay:",this.config.customWidth="650px",this.amountToPay=e.displayedAmountToPay,this.inputAmount=this.amountToPay,this.currencySymbol=e.currencySymbol,this.dueDate=e.dueDate,this.invoiceDate=e.invoiceDate,this.cashPaymentID=e.cashPaymentMethodID,this.cardPayments=e.cardPayments,this.otherPayments=e.otherPayments,this.paymentMethodID=e.paymentMethodID;let o=this.cardPayments.find(T=>T.ID==this.paymentMethodID);S.IsNotEmpty(o)&&(this.paymentMethodState="Card",this.paymentMethodName=o.Name);let s=this.otherPayments.find(T=>T.ID==this.paymentMethodID);S.IsNotEmpty(s)&&(this.paymentMethodState="Other",this.paymentMethodName=s.Name),this.paymentNote=e.paymentNote,this.paymentCode=e.paymentCode,this.isPayNow=e.payDefaultState,e.isEdit&&(this.isPayNow=!e.isUnpaidOnEdit),this.onChangeDueDate(),this.dueDays=e.dueDays,this.isCashSuspended=e.isCashSuspended,this.denomination=e.denomination,this.suggestedCash[0]=this.inputAmount,this.denomination.filter(T=>T>this.inputAmount).forEach(T=>{this.suggestedCash.length<3&&this.suggestedCash.push(T)}),console.log(this.suggestedCash)}config;isPayNow=!0;paymentMethodName="Cash";amountToPay=0;inputAmount=0;currencySymbol="";dueDate;dueDays;invoiceDate;cardPayments;otherPayments;cashPaymentID;paymentMethodID;paymentMethodState="Cash";paymentNote;paymentCode;displayedAmountToPay;denomination;suggestedCash=[];isCashSuspended;isDefaultTabPayLater=!1;ok(){let t={};this.isPayNow?(t.amount=this.inputAmount,t.paymentMethodID=this.paymentMethodID,t.paymentNote=this.paymentNote,t.paymentCode=this.paymentCode,t.payState="Now",t.paymentMethodName=this.paymentMethodName):(t.dueDate=this.dueDate,t.payState="Later"),this.dialogRef.close(t)}close(){this.dialogRef.close()}onSelectPaymentMethod(t,e,i){this.paymentMethodName=i,this.paymentMethodID==t?(this.paymentMethodID=this.cashPaymentID,this.paymentMethodState="Cash"):(this.paymentMethodID=t,this.paymentMethodState=e)}onChangeDueDay(){let t=new Date(S.cloneObject(this.invoiceDate));t.setDate(t.getDate()+this.dueDays),t.setHours(0,0,0,0),this.dueDate=t}onChangeDueDate(){this.dueDays=S.differentInDays(typeof this.invoiceDate=="string"?new Date(this.invoiceDate):this.invoiceDate,typeof this.dueDate=="string"?new Date(this.dueDate):this.dueDate)+1}static \u0275fac=function(e){return new(e||n)(u(Me),u(Fe),u(he))};static \u0275cmp=A({type:n,selectors:[["POS-modal-pay"]],decls:14,vars:10,consts:[[3,"onOk","onCancel","onClose","config"],[1,"mt-1","ms-2"],[1,"container","w-100","h-100"],[1,"row","border-bottom"],[1,"btn","btn-link",3,"click","ngClass"],[1,"btn","btn-link",3,"ngClass"],[1,"py-4"],[1,"fst-italic",2,"font-size","10px"],[1,"row","border-bottom","py-5"],[1,"row","py-5"],[1,"col-3","h5","pt-5"],[1,"fa-solid","fa-money-bill-wave"],[1,"col-9"],[1,"row"],[1,"row","mb-5"],[1,"col","pe-0","me-10","position-relative"],[1,"col-4","pe-0","ps-4"],[1,"btn","btn-outline-info","px-1","py-6","w-100",3,"click","ngClass"],["id","cashInput","type","text","placeholder","Custom Cash Amount","autoNum","",1,"form-control","form-control-lg","py-3","mb-3","px-6",3,"ngModelChange","click","ngModel"],[1,"change",3,"ngClass"],[3,"click"],["id","cashInput","type","text","placeholder","Custom Cash Amount","disabled","",1,"form-control","form-control-lg","py-3","mb-3","px-6",3,"value"],[1,"fa-regular","fa-credit-card"],[1,"col-auto","pe-0"],[1,"position-relative","row"],[1,"btn","btn-outline-info","mb-3","px-6",3,"click","ngClass"],[3,"hidden"],[2,"width","40px",3,"src"],[1,"paymentNote","col","row","g-0","pt-2","ms-6"],["type","text","placeholder","Payment Note",1,"form-control","w-50","border-end-0","py-6","col-6",3,"ngModelChange","ngModel"],["type","text","placeholder","Payment Code",1,"form-control","w-50","border-start-0","py-6","paymentCode","col-6",3,"ngModelChange","ngModel"],[1,"row","d-flex","align-items-center","g-0","later-payment"],[1,"col-3","fw-normal"],["appearance","fill","readOnly","true","name","orderDate",1,"col-9",3,"dateChange","displayToggle","date"],[1,"row","d-flex","align-items-center","g-0","later-payment","mt-10"],["type","text","autofocus","","autoNum","",1,"py-8","ps-8","form-control",3,"ngModelChange","ngModel"]],template:function(e,i){e&1&&(r(0,"modal-material",0),D("onOk",function(){return i.ok()})("onCancel",function(){return i.close()})("onClose",function(){return i.close()}),r(1,"header")(2,"div",1),m(3),f(4,"number"),a()(),r(5,"content")(6,"div",2)(7,"div",3)(8,"div")(9,"a",4),D("click",function(){return i.isPayNow=!0}),m(10," Now "),a(),v(11,_a,4,3,"a",5),a()()(),v(12,Aa,4,3,"div"),v(13,ka,10,3,"div",6),a()()),e&2&&(b("config",i.config),l(3),$(" ",i.currencySymbol+" "+g(4,6,i.amountToPay)," "),l(6),b("ngClass",ie(8,lo,i.isPayNow)),l(2),_(i.amountToPay!=0||i.isDefaultTabPayLater?11:-1),l(),_(i.isPayNow?12:-1),l(),_(i.isPayNow?-1:13))},dependencies:[ce,Ge,Se,be,ae,xe,ti,kn,Oe,Pe,st,ct,De,Xt],styles:['.text-warning[_ngcontent-%COMP%]{color:var(--bs-warning)!important}.bg-light-gray[_ngcontent-%COMP%]{background-color:var(--bs-light-gray);--bs-bg-opacity: .15 !important}.bg-gradient-danger[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#f8d7da,#f8d7da 15px,#f5c6cb 15px 30px)!important}.bg-gradient-success[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#beeebb,#beeebb 15px,#afeba8 15px 30px)!important}.bg-gradient-warning[_ngcontent-%COMP%]{background:repeating-linear-gradient(-60deg,#fcf3cf,#fcf3cf 15px,#f9e79f 15px 30px)!important}.bg-light-orange[_ngcontent-%COMP%]{background-color:var(--bs-light-orange);--bs-bg-opacity: .15 !important}.text-danger[_ngcontent-%COMP%]{color:#fb404b!important}.text-dark[_ngcontent-%COMP%]{color:#5e5e5e!important}.text-success[_ngcontent-%COMP%]{color:#87cb16!important}.text-black[_ngcontent-%COMP%]{color:#000!important}.text-white[_ngcontent-%COMP%]{color:var(--bs-white)!important}.btn-light-blue[_ngcontent-%COMP%]{color:#212529;background-color:#dfeffc!important;border-color:#dfeffc}.btn-light-blue[_ngcontent-%COMP%]:hover{color:#212529;background-color:#bcdef9;border-color:#b0d8f8}.btn-light-blue[_ngcontent-%COMP%]:focus, .btn-light-blue.focus[_ngcontent-%COMP%]{color:#212529;background-color:#bcdef9;border-color:#b0d8f8;box-shadow:0 0 0 .2rem #c3d1dc80}.btn-light-blue.disabled[_ngcontent-%COMP%], .btn-light-blue[_ngcontent-%COMP%]:disabled{color:#212529;background-color:#dfeffc;border-color:#dfeffc}.btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active, .btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active, .show[_ngcontent-%COMP%] > .btn-light-blue.dropdown-toggle[_ngcontent-%COMP%]{color:#212529;background-color:#b0d8f8;border-color:#a5d2f7}.btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active:focus, .btn-light-blue[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active:focus, .show[_ngcontent-%COMP%] > .btn-light-blue.dropdown-toggle[_ngcontent-%COMP%]:focus{box-shadow:0 0 0 .2rem #c3d1dc80}.btn-light-danger[_ngcontent-%COMP%]{color:#212529;background-color:#f8d7da!important;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:hover{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5}.btn-light-danger[_ngcontent-%COMP%]:focus, .btn-light-danger.focus[_ngcontent-%COMP%]{color:#212529;background-color:#f5c2c7;border-color:#f1aeb5;box-shadow:0 0 0 .2rem #dc354540}.btn-light-danger.disabled[_ngcontent-%COMP%], .btn-light-danger[_ngcontent-%COMP%]:disabled{color:#212529;background-color:#f8d7da;border-color:#f8d7da}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]{color:#212529;background-color:#f1aeb5;border-color:#ea868f}.btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled):active:focus, .btn-light-danger[_ngcontent-%COMP%]:not(:disabled):not(.disabled).active:focus, .show[_ngcontent-%COMP%] > .btn-light-danger.dropdown-toggle[_ngcontent-%COMP%]:focus{box-shadow:0 0 0 .2rem #dc354540}.change[_ngcontent-%COMP%]{position:absolute;top:0;height:40px;background:#89b03e;color:#fff;right:0;padding:0 10px;line-height:40px;font-size:16px}.change[_ngcontent-%COMP%]:before{content:"\\a";border-style:solid;border-width:40px 24px 0 0;border-color:transparent #89b03e transparent transparent;position:absolute;left:-24px}.change.danger[_ngcontent-%COMP%]{background:#c9302c}.change.danger[_ngcontent-%COMP%]:before{border-color:transparent #c9302c transparent transparent}.paymentNote[_ngcontent-%COMP%]:before{z-index:10;content:"";position:absolute;top:4px;left:calc(50% - 10px);height:90%;width:10px;background-color:inherit;border-right:1px solid lightgray;-webkit-transform:skewX(-10deg);-moz-transform:skewX(-10deg);-ms-transform:skewX(-10deg);transform:skew(-10deg)}.btn-link[_ngcontent-%COMP%]{padding-top:0;color:#868686;padding-bottom:8px;border-radius:unset;font-family:Roboto Slab,serif}.btn-link.selected[_ngcontent-%COMP%]{color:#3b3b3b;border-bottom:4px solid #07a519} .later-payment.date-picker .mat-mdc-form-field{font-size:4px}.ng-select.ng-select-width[_ngcontent-%COMP%] .ng-select-container{width:160px;max-width:160px}input[type=text][_ngcontent-%COMP%]:disabled{background:#dadada}.later-payment[_ngcontent-%COMP%] strong{font-size:20px}.later-payment[_ngcontent-%COMP%] input{font-size:20px}.later-payment[_ngcontent-%COMP%] .mat-mdc-form-field{width:100%;font-size:20px;border:1px solid #c8d3df}.later-payment[_ngcontent-%COMP%] .mat-mdc-form-field .mat-mdc-icon-button, .later-payment[_ngcontent-%COMP%] .mat-mdc-form-field .mat-mdc-button-persistent-ripple, .later-payment[_ngcontent-%COMP%] .mat-mdc-form-field .mat-mdc-form-field-icon-suffix{outline:none!important}']})};var Ze=class n{constructor(t,e,i){this.form=e;this.decimalPipe=i;let o=e.discountAndTaxForm.valueChanges;this.currency$=e.noteForm.valueChanges.pipe(d(h=>h.Currency),X(1),z()),this.currencySymbol$=this.currency$.pipe(d(h=>h.Symbol),z());let s=t.cart$.pipe(E(console.log),d(h=>h.map(R=>R.Total)),d(h=>h.reduce((R,q)=>R+q,0)),d(h=>this.setDecimalDigit(h)),X(1),z()),T=t.cart$.pipe(d(h=>h.filter(R=>R.Taxable).map(R=>R.Total)),d(h=>h.reduce((R,q)=>R+q,0)),d(h=>this.setDecimalDigit(h)),X(1),z());this.displayedAmount$=s,this.displayedDiscountPercentage$=Ce(this.displayedAmount$,o.pipe(d(h=>h.Discount.Percentage))).pipe(d(([h,R])=>({label:`Discount ${R}%`,value:h*(R/100)})),je({label:"",value:0}),X(1),z()),this.displayedDiscountAmount$=Ce(this.currencySymbol$,o.pipe(d(h=>h.Discount.Amount))).pipe(d(([h,R])=>({label:`Discount ${h}`,value:R})),je({label:"",value:0}),X(1),z()),this.displayedTax$=Ce(T,this.displayedDiscountPercentage$.pipe(d(h=>h.value)),this.displayedDiscountAmount$.pipe(d(h=>h.value)),o.pipe(d(h=>h.Tax))).pipe(V(([,,,h])=>!!h.Label),d(([h,R,q,x])=>({amountAfterDiscount:h-R-q,tax:x})),d(h=>{let R=h.amountAfterDiscount,q=h.tax;return{label:q.Label,tax:{id:q.ID,value:q.CalculationTypeName=="Add"?R*(q.Rate/100):q.Rate/(100+q.Rate)*R,type:q.CalculationTypeName,rate:q.Rate}}}),E(h=>e.setTaxAmount(h.tax.value)),je({label:"",tax:{id:"",value:0,type:"",rate:0}}),X(1),z()),this.amountAfterDiscountAndTax$=Ce(this.displayedAmount$,this.displayedDiscountPercentage$.pipe(d(h=>h.value)),this.displayedDiscountAmount$.pipe(d(h=>h.value)),this.displayedTax$.pipe(d(h=>h.tax)),t.cart$.pipe(d(h=>h.length))).pipe(d(([h,R,q,x,k])=>k?h-R-q+(x.type=="Add"?x.value:0):0),z()).pipe(X(1)),this.amountAfterDiscountAndTax$.subscribe()}paymentMethodName=Le("Cash");displayedAmount$;displayedDiscountPercentage$;displayedDiscountAmount$;displayedTax$;currency$;currencySymbol$;amountAfterDiscountAndTax$;get amountToPay(){return this.form.buyForm.controls.Payment.controls.Amount.value}get methodID(){return this.form.buyForm.controls.Payment.controls.MethodID.value}get code(){return this.form.buyForm.controls.Payment.controls.Code.value}get note(){return this.form.buyForm.controls.Payment.controls.Note.value}setDecimalDigit(t){let e=this.decimalPipe.transform(t,"1.0-4");return t=parseFloat(e.split(",").join("")),t}static \u0275fac=function(e){return new(e||n)(U(ee),U(G),U(De))};static \u0275prov=ne({token:n,factory:n.\u0275fac,providedIn:"root"})};function Va(n,t){if(n&1&&(Je(0,"div"),m(1),f(2,"number"),it()),n&2){let e=p();l(),$(" ",g(2,1,e.amountToPayRounded)," ")}}function $a(n,t){n&1&&m(0," - ")}var Oi=class n{constructor(t,e,i,o,s,T,h,R,q,x,k){this.matDialog=t;this.toastr=e;this.form=i;this.cart=o;this.http=s;this.complete=T;this.role=h;this.load=R;this.posMath=q;this.math=x;this.paymentService=k}cartLength;amountToPay;currencySymbol;dueDate;cashPayments;cardPayments;otherPayments;paymentMethodID;paymentNote;paymentCode;defaultDueDays;invoiceDate;dueDays;appConfigJSON;isUnpaidOnEdit;isEditBuyForm;totalVariantOrdered;isCashSuspended;denomination;pay(){if(this.cartLength==0){this.toastr.info("You must have at least one item",ve.Info);return}if(this.form.discountAndTaxForm.value.Tax.Discontinue){this.toastr.info(`Cannot find the ${this.form.discountAndTaxForm.value.Tax.Label}, Set the tax discontinue status to \u201CNo\u201D to use tax or choose another tax type`,ve.Info);return}let t=S.IsEmpty(this.form.buyForm.controls.Order.controls.SupplierID.value);if(this.appConfigJSON.ModuleBuy.Header.SupplierRequired&&t){this.toastr.info("Supplier is required",ve.Info);return}this.matDialog.open(Pi,{data:{displayedAmountToPay:this.posMath.Round(this.amountToPay,this.appConfigJSON.ApplicationMath.RoundingPurchaseDigit.DecimalPlaceValue,this.appConfigJSON.ApplicationMath.RoundingPurchaseDigit.RoundAlgorithm),amountToPay:this.posMath.Round(this.form.buyForm.controls.Payment.controls.Amount.value,this.appConfigJSON.ApplicationMath.RoundingPurchaseDigit.DecimalPlaceValue,this.appConfigJSON.ApplicationMath.RoundingPurchaseDigit.RoundAlgorithm),currencySymbol:this.currencySymbol,dueDate:S.cloneObject(this.dueDate),dueDays:S.cloneObject(this.dueDays),cardPayments:this.cardPayments,otherPayments:this.otherPayments,cashPaymentMethodID:this.cashPayments[0]?.ID,paymentMethodID:this.paymentMethodID,paymentNote:this.paymentNote,paymentCode:this.paymentCode,invoiceDate:this.invoiceDate,payDefaultState:this.appConfigJSON.ModuleBuy.PaymentDialog.DefaultOption!=1,isUnpaidOnEdit:this.isUnpaidOnEdit,isEdit:this.isEditBuyForm,isCashSuspended:this.isCashSuspended,denomination:this.denomination}}).afterClosed().pipe(V(s=>!!s),d(s=>s)).pipe(E(s=>this.paymentService.paymentMethodName.set(s.paymentMethodName)),le(this.cart.cart$),d(([s,T])=>B(w({},s),{cart:T})),le(this.load.entities$),d(([s,T])=>B(w({},s),{entities:T})),le(this.load.supplierPOTypes$),d(([s,T])=>B(w({},s),{supplierPOTypes:T})),Y(s=>{S.IsEmpty(this.form.noteForm.value.TagID)&&this.form.setBulkNoteForm(B(w({},this.form.noteForm.value),{TagID:s.supplierPOTypes[0]?.ID}));let T=this.form.buyForm.controls,h=T.Invoice.controls,R=T.Payment.controls,q=this.form.outlet.value,x=T.Order.controls,k=this.form.noteForm.value,c=this.form.discountAndTaxForm.value,I=R.Amount.value,Q=this.form.deliveryEntityID.value,H={ID:h.ID.value,Due:s.payState=="Now"?void 0:h.Due.value,Tax:h.Tax.value,Sales:I??0,PaymentStateID:s.payState=="Now"?3:1,Number:k.InvoiceNumber?k.InvoiceNumber:x.Number.value},y=s.cart.map(N=>B(w({},N),{VariantID:S.IsEmpty(N.VariantID)?N.ID:N.VariantID}));this.isEditBuyForm&&(y=y.map(N=>B(w({},N),{QtyRequested:N.Quantity})));let C={EntityID:q.ID,SupplierID:x.SupplierID.value,Date:x.Date.value,CurrencyID:k.Currency.ID,CurrencyRate:k.Currency.ExchangeRate,Discount:c.Discount.Percentage,DiscountAmount:c.Discount.Amount,Note:k.Note,Att:x.Att.value,TaxTypeID:c.Tax.ID,TypeID:k.TagID,Number:x.Number.value,ID:x.ID.value};if(s.payState=="Now"){let N={ID:R.ID?.value??S.GuidEmpty,MethodID:s.paymentMethodID,Code:s.paymentCode??"",Note:s.paymentNote??"",Amount:this.posMath.Round(s.amount,this.appConfigJSON.ApplicationMath.RoundingPurchaseDigit.DecimalPlaceValue,this.appConfigJSON.ApplicationMath.RoundingPurchaseDigit.RoundAlgorithm),Date:C.Date,ImageUrl:R.ImageUrl?.value};s.amount<I?H.PaymentStateID=2:s.amount>I&&(H.PaymentStateID=5);let F={DeliveryEntityID:Q,NewOrderID:this.isEditBuyForm?null:S.Guid_NewGuid(),Invoice:H,Order:C,Items:y,Payment:N};return this.http.post("/API/Buy/SubmitOrder2",F,1e4,!0).pipe(d(fe=>B(w({},fe),{differentNumber:fe.InvoiceNumber!=C.Number})),ye(fe=>{throw fe.error&&this.toastr.error(fe.error.Message,"Order Submission Failed"),new Error(fe)}))}else{let N={DeliveryEntityID:Q,NewOrderID:this.isEditBuyForm?null:S.Guid_NewGuid(),Invoice:B(w({},H),{Due:s.dueDate}),Order:C,Items:y};return this.http.post("/API/Buy/SubmitOrder2",N,1e4,!0).pipe(d(F=>B(w({},F),{differentNumber:F.InvoiceNumber!=C.Number})),ye(F=>{throw F.error&&this.toastr.error(F.error.Message,"Order Submission Failed"),new Error(F)}))}})).subscribe(s=>{this.complete.paymentComplete(s),s.differentNumber&&this.toastr.info(`Bill number has been changed to ${s.InvoiceNumber}`,"Bill Number Changed!")})}get amountToPayRounded(){return this.posMath.Round(this.amountToPay,this.appConfigJSON?.ApplicationMath?.RoundingPurchaseDigit?.DecimalPlaceValue,this.appConfigJSON?.ApplicationMath?.RoundingPurchaseDigit.RoundAlgorithm)}static \u0275fac=function(e){return new(e||n)(u(Z),u(qe),u(G),u(ee),u(re),u($e),u(he),u(de),u(ki),u(ki),u(Ze))};static \u0275cmp=A({type:n,selectors:[["POS-pay-button"]],inputs:{cartLength:"cartLength",amountToPay:"amountToPay",currencySymbol:"currencySymbol",dueDate:"dueDate",cashPayments:"cashPayments",cardPayments:"cardPayments",otherPayments:"otherPayments",paymentMethodID:"paymentMethodID",paymentNote:"paymentNote",paymentCode:"paymentCode",defaultDueDays:"defaultDueDays",invoiceDate:"invoiceDate",dueDays:"dueDays",appConfigJSON:"appConfigJSON",isUnpaidOnEdit:"isUnpaidOnEdit",isEditBuyForm:"isEditBuyForm",totalVariantOrdered:"totalVariantOrdered",isCashSuspended:"isCashSuspended",denomination:"denomination"},decls:11,vars:7,consts:[["type","button",1,"btn","btn-success","fs-1","py-4",2,"border-left","0.1px solid #fff",3,"click"],[1,"d-flex","align-items-center","justify-content-between"],[1,"fs-6"]],template:function(e,i){e&1&&(Je(0,"button",0),bt("click",function(){return i.pay()}),Je(1,"div",1)(2,"div")(3,"span"),m(4,"Pay"),it(),Je(5,"small",2),m(6),f(7,"number"),f(8,"quantityFraction"),it()(),v(9,Va,3,3,"div")(10,$a,1,0),it()()),e&2&&(l(6),He(" (",g(7,3,i.cartLength)," Items & ",g(8,5,i.totalVariantOrdered)," Qty) "),l(3),_(i.role.product.Cost?9:10))},dependencies:[ce,De,ei],styles:["button[_ngcontent-%COMP%]{border-right:.1px solid #fff;margin-left:-1px;border-top-left-radius:0;border-bottom-left-radius:0;position:relative;flex:1 1 auto}"]})};var It=class n{noteForm;constructor(t){this.noteForm=t.noteForm}static \u0275fac=function(e){return new(e||n)(U(G))};static \u0275prov=ne({token:n,factory:n.\u0275fac,providedIn:"root"})};var Pt=class n{deliveryEntityID;constructor(t){this.deliveryEntityID=t.deliveryEntityID}static \u0275fac=function(e){return new(e||n)(U(G))};static \u0275prov=ne({token:n,factory:n.\u0275fac,providedIn:"root"})};var Ot=class n{dueDate$;dueDays$;constructor(t){let e=t.buyForm.controls.Invoice.controls.Due.valueChanges;this.dueDays$=t.dueDays.valueChanges,t.buyForm.controls.Order.controls.Date.valueChanges.pipe(E(console.log),le(this.dueDays$),E(([s,T])=>t.setDueDateBasedOnDaysDue(T)),E(console.log)).subscribe(),this.dueDate$=e,this.dueDate$.subscribe(s=>console.log(s,"dueDate$"))}static \u0275fac=function(e){return new(e||n)(U(G))};static \u0275prov=ne({token:n,factory:n.\u0275fac,providedIn:"root"})};function La(n,t){if(n&1&&(r(0,"tr")(1,"th",11),m(2,"Amount"),a(),r(3,"td",12),m(4),f(5,"number"),a()()),n&2){let e=p();l(4),te(g(5,1,e.displayedAmount))}}function Qa(n,t){if(n&1&&(r(0,"td",13),m(1),f(2,"number"),a()),n&2){let e=p(3);l(),$(" ",g(2,1,e.displayedDiscountPercentage.value*-1))}}function Ua(n,t){if(n&1&&(r(0,"tr")(1,"th",11),m(2),a(),v(3,Qa,3,3,"td",13),a()),n&2){let e=p(2),i=p();l(2),te(e.displayedDiscountPercentage.label),l(),_(i.role.product.Cost?3:-1)}}function Wa(n,t){if(n&1&&(r(0,"td",13),m(1),f(2,"number"),a()),n&2){let e=p(3);l(),te(g(2,1,e.displayedDiscountAmount.value*-1))}}function Ja(n,t){if(n&1&&(r(0,"tr")(1,"th",11),m(2),a(),v(3,Wa,3,3,"td",13),a()),n&2){let e=p(2),i=p();l(2),te(e.displayedDiscountAmount.label),l(),_(i.role.product.Cost?3:-1)}}function Ha(n,t){if(n&1&&(r(0,"td",12),m(1),f(2,"number"),a()),n&2){let e=p(3);l(),te(g(2,1,e.displayedTax.tax.value))}}function Ga(n,t){if(n&1&&(r(0,"tr")(1,"th",11),m(2),a(),v(3,Ha,3,3,"td",12),a()),n&2){let e=p(2),i=p();l(2),te(e.displayedTax.label),l(),_(i.role.product.Cost?3:-1)}}function qa(n,t){if(n&1&&(v(0,Ua,4,2,"tr"),v(1,Ja,4,2,"tr"),v(2,Ga,4,2,"tr")),n&2){let e=p();_(e.displayedDiscountPercentage.value!=0?0:-1),l(),_(e.displayedDiscountAmount.value!=0?1:-1),l(),_(e.displayedTax.tax.value!=0?2:-1)}}function Ka(n,t){if(n&1&&(r(0,"div",0)(1,"div",9)(2,"table",10),v(3,La,6,3,"tr"),v(4,qa,3,3),f(5,"async"),a()()()),n&2){let e=t,i=p();l(3),_(i.showAmountWhenDiscountOrTaxIsApplied(e)&&e.displayedAmount&&i.role.product.Cost?3:-1),l(),_(g(5,2,i.cartLength$)?4:-1)}}var Ti=class n{constructor(t,e,i,o,s,T,h,R,q,x){this.payment=t;this.form=o;this.role=R;this.taxes$=i.taxes$,this.defaultCurrencyID$=i.appConfigJSON$.pipe(d(H=>H.CoreDefaults.CurrencyID)),this.totalVariantOrdered$=e.totalVariantOrdered$,this.cartLength$=e.cart$.pipe(d(H=>H.length)),this.amountAfterDiscountAndTax$=t.amountAfterDiscountAndTax$,this.discountAndTaxForm=o.discountAndTaxForm;let k=t.displayedAmount$,c=t.displayedDiscountPercentage$,I=t.displayedDiscountAmount$,Q=t.displayedTax$;this.displayedDiscountAndTax$=Ce({displayedAmount:k,displayedDiscountPercentage:c,displayedDiscountAmount:I,displayedTax:Q}),this.deliveryEntityID=T.deliveryEntityID,this.noteForm=s.noteForm,this.currencies$=i.currencies$,this.currencySymbol$=t.currencySymbol$,this.supplierPOTypes$=i.supplierPOTypes$,this.predefinedNotes$=i.predefinedNotes$,this.outlets$=i.entities$,this.cashPayments$=x.cashPayments$,this.cardPayments$=x.cardPayments$,this.otherPayments$=x.otherPayments$,this.defaultDueDays$=i.defaultDueDays$,this.dueDate$=h.dueDate$,this.dueDays$=h.dueDays$,this.appConfigJSON$=i.appConfigJSON$,this.isUnpaidOnEdit$=Ce(q.isEdit$,q.isUnpaid$).pipe(d(([H,y])=>H&&y)),this.isEdit$=q.isEdit$,this.outlet=o.outlet,this.isCashSuspended$=x.isCashSuspended$,this.denomination$=i.denomination$}taxes$;totalVariantOrdered$;displayedDiscountAndTax$;discountAndTaxForm;deliveryEntityID;noteForm;amountAfterDiscountAndTax$;currencies$;currencySymbol$;supplierPOTypes$;predefinedNotes$;defaultCurrencyID$;outlets$;cashPayments$;cardPayments$;otherPayments$;defaultDueDays$;dueDate$;dueDays$;appConfigJSON$;isUnpaidOnEdit$;isEdit$;isCashSuspended$;outlet;cartLength$;denomination$;get amountToPay(){return this.payment.amountToPay}get invoiceDate(){return this.form.invoiceDate}get paymentMethodID(){return this.payment.methodID}get paymentNote(){return this.payment.note}get paymentCode(){return this.payment.code}showAmountWhenDiscountOrTaxIsApplied(t){return t.displayedDiscountPercentage.value!=0||t.displayedDiscountAmount.value!=0||t.displayedTax.tax.value!=0}static \u0275fac=function(e){return new(e||n)(u(Ze),u(ee),u(de),u(G),u(It),u(Pt),u(Ot),u(he),u(Ve),u(Xe))};static \u0275cmp=A({type:n,selectors:[["POS-cart-footer"]],decls:34,vars:83,consts:[[1,"row","g-0","px-5","justify-content-end"],[1,"row","g-0","pb-6","px-5"],[1,"col-5","d-flex","justify-content-between","pe-5",2,"column-gap","12px"],[2,"flex-grow","1",3,"supplierPOTypes","predefinedNotes","defaultCurrencyID","currencies","formControl"],[2,"flex-grow","3",3,"outlets","formControl","appConfigJSON","outletID","isEdit"],[1,"col-7"],[1,"btn-group","w-100"],[2,"display","inline-flex",3,"taxes","currencySymbol","formControl"],[1,"w-100",2,"display","inline-flex",3,"amountToPay","currencySymbol","dueDate","dueDays","cardPayments","otherPayments","paymentMethodID","paymentCode","paymentNote","defaultDueDays","invoiceDate","appConfigJSON","cashPayments","isUnpaidOnEdit","isEditBuyForm","cartLength","totalVariantOrdered","isCashSuspended","denomination"],[1,"col-6",2,"padding-right","15px"],[1,"table","table-borderless"],[1,"text-start"],[1,"text-end","fs-5"],[1,"text-end","fs-5","text-danger"]],template:function(e,i){if(e&1&&(v(0,Ka,6,4,"div",0),f(1,"async"),r(2,"div",1)(3,"div",2),M(4,"POS-note-form",3),f(5,"async"),f(6,"async"),f(7,"async"),f(8,"async"),M(9,"POS-fulfillment-form",4),f(10,"async"),f(11,"async"),f(12,"async"),a(),r(13,"div",5)(14,"div",6),M(15,"POS-discount-and-tax-form",7),f(16,"async"),f(17,"async"),M(18,"POS-pay-button",8),f(19,"async"),f(20,"async"),f(21,"async"),f(22,"async"),f(23,"async"),f(24,"async"),f(25,"async"),f(26,"async"),f(27,"async"),f(28,"async"),f(29,"async"),f(30,"async"),f(31,"async"),f(32,"async"),f(33,"async"),a()()()),e&2){let o;_((o=g(1,33,i.displayedDiscountAndTax$))?0:-1,o),l(4),b("supplierPOTypes",g(5,35,i.supplierPOTypes$))("predefinedNotes",g(6,37,i.predefinedNotes$))("defaultCurrencyID",g(7,39,i.defaultCurrencyID$))("currencies",g(8,41,i.currencies$))("formControl",i.noteForm),l(5),b("outlets",g(10,43,i.outlets$))("formControl",i.deliveryEntityID)("appConfigJSON",g(11,45,i.appConfigJSON$))("outletID",i.outlet.value.ID)("isEdit",g(12,47,i.isEdit$)),l(6),b("taxes",g(16,49,i.taxes$))("currencySymbol",g(17,51,i.currencySymbol$))("formControl",i.discountAndTaxForm),l(3),b("amountToPay",g(19,53,i.amountAfterDiscountAndTax$))("currencySymbol",g(20,55,i.currencySymbol$))("dueDate",g(21,57,i.dueDate$))("dueDays",g(22,59,i.dueDays$))("cardPayments",g(23,61,i.cardPayments$))("otherPayments",g(24,63,i.otherPayments$))("paymentMethodID",i.paymentMethodID)("paymentCode",i.paymentCode)("paymentNote",i.paymentNote)("defaultDueDays",g(25,65,i.defaultDueDays$))("invoiceDate",i.invoiceDate)("appConfigJSON",g(26,67,i.appConfigJSON$))("cashPayments",g(27,69,i.cashPayments$))("isUnpaidOnEdit",g(28,71,i.isUnpaidOnEdit$))("isEditBuyForm",g(29,73,i.isEdit$))("cartLength",g(30,75,i.cartLength$))("totalVariantOrdered",g(31,77,i.totalVariantOrdered$))("isCashSuspended",g(32,79,i.isCashSuspended$))("denomination",g(33,81,i.denomination$))}},dependencies:[ce,Di,Ye,ae,ze,Si,Ii,Oi,Ee,De],encapsulation:2})};var za=n=>({"date-warning":n}),Ya=()=>["/menu/Orders/Orders/Supplier_Bill/Info"],Xa=n=>({ID:n});function Za(n,t){if(n&1&&(m(0),f(1,"async"),f(2,"number")),n&2){let e=p().$implicit,i=p();He(" ",g(1,2,i.currencySymbol$)," ",g(2,4,e.Total)," ")}}function er(n,t){n&1&&m(0," - ")}function tr(n,t){if(n&1&&(r(0,"div",25)(1,"div",27),m(2),a(),r(3,"div",28),v(4,Za,3,6)(5,er,1,0),a()()),n&2){let e=t.$implicit,i=p();l(2),te(e.Name),l(2),_(i.role.product.Cost?4:5)}}function ir(n,t){if(n&1&&(r(0,"tr")(1,"td",31),m(2),a(),r(3,"td",32),m(4),f(5,"async"),a(),r(6,"td",31),m(7),f(8,"number"),a()()),n&2){p();let e=Jt(0),i=p();l(2),te(e.label),l(2),$(" ",g(5,3,i.currencySymbol$)," "),l(3),$(" ",g(8,5,e.value)," ")}}function nr(n,t){if(n&1&&(r(0,"tr")(1,"td",31),m(2,"Discount:"),a(),r(3,"td",32),m(4),f(5,"async"),a(),r(6,"td",31),m(7),f(8,"number"),a()()),n&2){p();let e=Jt(2),i=p();l(4),$(" ",g(5,2,i.currencySymbol$)," "),l(3),$(" ",g(8,4,e.value)," ")}}function or(n,t){if(n&1&&(r(0,"tr")(1,"td",31),m(2),a(),r(3,"td",32),m(4),f(5,"async"),a(),r(6,"td",31),m(7),f(8,"number"),a()()),n&2){p();let e=Jt(4),i=p();l(2),te(e.label),l(2),$(" ",g(5,3,i.currencySymbol$)," "),l(3),$(" ",g(8,5,e==null||e.tax==null?null:e.tax.value)," ")}}function ar(n,t){if(n&1&&(r(0,"tr",33)(1,"td",31),m(2),a(),r(3,"td",32),m(4),f(5,"async"),a(),r(6,"td",31),m(7),f(8,"async"),f(9,"number"),a()()),n&2){let e=p(2);l(2),$(" ",e.payment.paymentMethodName(),": "),l(2),$(" ",g(5,3,e.currencySymbol$)," "),l(3),$(" ",g(9,7,g(8,5,e.displayedAmount$))," ")}}function rr(n,t){if(n&1&&(Ut(0),f(1,"async"),Ut(2),f(3,"async"),Ut(4),f(5,"async"),r(6,"div",26)(7,"div",29)(8,"table",30)(9,"tbody")(10,"tr")(11,"td",31),m(12,"Amount:"),a(),r(13,"td",32),m(14),f(15,"async"),a(),r(16,"td",31),m(17),f(18,"async"),f(19,"number"),a()(),v(20,ir,9,7,"tr"),v(21,nr,9,6,"tr"),v(22,or,9,7,"tr"),v(23,ar,10,9,"tr",33),a()()()()),n&2){let e=p(),i=Wt(g(1,6,e.displayedDiscountPercentage$));l(2);let o=Wt(g(3,9,e.displayedDiscountAmount$));l(2);let s=Wt(g(5,12,e.displayedTax$));l(10),$(" ",g(15,15,e.currencySymbol$)," "),l(3),$(" ",g(19,19,g(18,17,e.displayedAmount$))," "),l(3),_(i.value>0?20:-1),l(),_(o.value>0?21:-1),l(),_((s==null||s.tax==null?null:s.tax.value)>0?22:-1),l(),_(e.payment.paymentMethodName()?23:-1)}}var wi=class n{constructor(t,e,i,o,s,T,h,R){this.payment=t;this.form=e;this.cart=i;this.complete=o;this.load=s;this.router=T;this.outletInfo=h;this.role=R;this.displayedAmount$=t.displayedAmount$,this.displayedDiscountPercentage$=t.displayedDiscountPercentage$,this.displayedDiscountAmount$=t.displayedDiscountAmount$,this.displayedTax$=t.displayedTax$}data;displayedAmount$;displayedDiscountPercentage$;displayedDiscountAmount$;displayedTax$;currencySymbol$;createNewTransaction(){this.clearCart(),this.resetBuyForm(),this.updateDueDays(),this.updateTax(),this.updatePaymentMethodID(),this.complete.paymentComplete(null),this.complete.createNewTransaction(),this.router.navigate([],{queryParams:{ID:null}})}get amountToPay(){return this.payment.amountToPay}resetBuyForm(){this.form.resetNoteForm(),this.form.resetDiscountAndTaxForm(),this.form.resetDueDaysForm(),this.form.resetBuyForm()}clearCart(){this.cart.clearCart()}updateDueDays(){this.load.updateDueDays()}updateTax(){this.outletInfo.updateTax()}updatePaymentMethodID(){this.outletInfo.updatePaymentMethodID()}static \u0275fac=function(e){return new(e||n)(u(Ze),u(G),u(ee),u($e),u(de),u(Kt),u(Xe),u(he))};static \u0275cmp=A({type:n,selectors:[["POS-complete"]],inputs:{data:[0,"paymentComplete","data"]},decls:38,vars:15,consts:[[1,"pt-7",2,"border-bottom","1px solid rgba(0, 0, 0, 0.1)"],[1,"ps-7","fw-normal","pb-7"],[1,"buy-complete"],[1,"container-fluid","pt-8"],[1,"row"],[1,"col-md-8"],[1,"card"],[1,"card-header"],[1,"d-flex","justify-content-between"],[1,"fa-solid","fa-check","me-1"],[1,"fst-italic"],[1,"card-body"],[1,"container"],[1,"row","mt-9","justify-content-center","g-0","mb-9"],[1,"col-9","text-center"],["type","button",1,"btn","btn-success","btn-lg","w-100","fs-2",3,"click"],[1,"card-footer","bg-light-gray"],[1,"row","justify-content-between","py-5"],[1,"col-auto"],["target","_blank",1,"btn","btn-light-gray",3,"href"],[1,"fa-solid","fa-print","me-2"],[1,"col-md-4"],[1,"card-header","bg-light-gray"],[1,"text-dark"],["target","_blank",1,"text-dark","fst-italic",3,"routerLink","queryParams"],[1,"row","my-1","p-5"],[1,"card-footer","pe-0","bg-white"],[1,"col-8"],[1,"col-4","text-end"],[1,"ms-auto"],[1,"table","table-borderless","mb-0","table-sm"],[1,"text-end"],[1,"text-start"],[2,"border-top","1px solid rgba(0, 0, 0, 0.1)"]],template:function(e,i){e&1&&(r(0,"div",0)(1,"h1",1),m(2,"New Purchase Order"),a()(),r(3,"section",2)(4,"div")(5,"div",3)(6,"div",4)(7,"div",5)(8,"div",6)(9,"div",7)(10,"div",8)(11,"h2"),M(12,"i",9),m(13," Purchase Complete "),r(14,"small",10),m(15),a()()()(),r(16,"div",11)(17,"div",12)(18,"div",13)(19,"div",14)(20,"button",15),D("click",function(){return i.createNewTransaction()}),m(21," New Purchase (F8) "),a()()()()(),r(22,"div",16)(23,"div",17)(24,"div",18)(25,"a",19),M(26,"i",20),m(27,"Print Receipt "),a()()()()()(),r(28,"div",21)(29,"div",6)(30,"div",22)(31,"h3",23)(32,"a",24),m(33),a()()(),Ue(34,tr,6,2,"div",25,Qe),f(36,"async"),v(37,rr,24,21,"div",26),a()()()()()()),e&2&&(l(9),an(ie(10,za,i.data.PaymentStateID<3)),l(6),$(" (",i.data.PaymentStateLabel,") "),l(10),b("href",i.data.Message,at),l(7),b("routerLink",Ht(12,Ya))("queryParams",ie(13,Xa,i.data.InvoiceID)),l(),$(" Supplier Bill #",i.data.InvoiceNumber," "),l(),We(g(36,8,i.cart.cart$)),l(3),_(i.role.product.Cost?37:-1))},dependencies:[ce,Yt,zt,Ee,De],styles:[".print_containers[_ngcontent-%COMP%]{display:none}@media print{.print_containers[_ngcontent-%COMP%]{display:block;text-align:left}.buy-complete[_ngcontent-%COMP%]{display:none}}.table-sm[_ngcontent-%COMP%] th[_ngcontent-%COMP%], .table-sm[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:10px!important}.buy-complete[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] .card-header[_ngcontent-%COMP%]{border-bottom:1px solid rgba(0,0,0,.125);padding-bottom:.9375rem}.buy-complete[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] .card-header[_ngcontent-%COMP%] h2[_ngcontent-%COMP%]{font-size:2rem}.buy-complete[_ngcontent-%COMP%] .card[_ngcontent-%COMP%] .card-body[_ngcontent-%COMP%] .container[_ngcontent-%COMP%]{max-width:500px;margin-top:30px;margin-bottom:30px}.table[_ngcontent-%COMP%] th[_ngcontent-%COMP%], .table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{vertical-align:middle;line-height:15px!important}"]})};var lr=["cartDisplayRef"],sr=(n,t)=>({label:n,tooltip:t}),cr=n=>({data:n}),mr=n=>({"bg-gradient-warning px-2":n}),pr=n=>({"me-3":n});function dr(n,t){n&1&&M(0,"POS-complete",2),n&2&&b("paymentComplete",t)}function ur(n,t){n&1&&on(0)}function fr(n,t){if(n&1&&(r(0,"div",9),ut(1,ur,1,0,"ng-container",31),a()),n&2){let e=p(2),i=ht(4);l(),b("ngTemplateOutlet",i)("ngTemplateOutletContext",ie(5,cr,_t(2,sr,e.fulfillmentOutletName(),e.fulfillmentOutletName())))}}function gr(n,t){if(n&1){let e=j();r(0,"div",3)(1,"div",4)(2,"div",5)(3,"div",6),M(4,"POS-select-outlet-form",7),f(5,"async"),f(6,"async"),f(7,"async"),M(8,"POS-invoice-number-form",8),f(9,"async"),r(10,"div"),v(11,fr,2,7,"div",9),M(12,"POS-invoice-date",10),a()()(),r(13,"div",11)(14,"div",12)(15,"div",13),M(16,"POS-more-actions",14),f(17,"async"),f(18,"async"),a(),r(19,"div",15)(20,"div",16),M(21,"i",17)(22,"input",18),a()(),r(23,"div",19)(24,"div",20)(25,"button",21),f(26,"async"),D("click",function(){P(e);let o=p();return O(o.collapseSidebar())}),M(27,"span",22)(28,"span",22)(29,"span",22),a()()()()()(),r(30,"div",23)(31,"div",5),M(32,"POS-quick-key",24),f(33,"async"),a(),r(34,"div",25)(35,"div",26)(36,"div",27),M(37,"POS-variant-autocomplete",28),a(),r(38,"div",15),M(39,"POS-supplier-autocomplete",29),f(40,"async"),f(41,"async"),a()(),M(42,"POS-cart-display",30,1),f(44,"async"),f(45,"async"),f(46,"async"),M(47,"POS-cart-footer"),a()()()}if(n&2){let e=p();l(4),b("outlets",g(5,31,e.outlets$))("isOpenAfterLoad",g(6,33,e.isOpenDialogOutlet$))("formControl",e.outlet)("disabled",g(7,35,e.isEdit$)),l(4),b("formControl",e.poNumber)("isEdit",g(9,37,e.isEdit$)),l(3),_(e.isFulfillmentDifferentOutlet()?11:-1),l(),b("formControl",e.date)("tooltip",e.role.global!=null&&e.role.global.Date?"":"Date role is required"),l(4),b("returnInvoiceNumber",e.returnInvoiceNumber)("appConfigJSON",g(17,39,e.appConfigJSON$))("isEditBuyForm",g(18,41,e.isEdit$))("outletID",e.outlet.value.ID)("outletName",e.outlet.value.Name),l(6),b("formControl",e.attention),l(3),vt("change",g(26,43,e.toggleState$)),l(7),b("quickKey",g(33,45,e.quickKeyPack$))("outletID",e.outlet.value.ID)("formControl",e.variantQuickKey),l(5),b("formControl",e.variantAutocomplete)("autocompleteEndpoint",e.variantAutocompleteEndpoint)("outletID",e.outlet.value.ID),l(2),b("formControl",e.supplierID)("supplierPOTypes",g(40,47,e.supplierPOTypes$))("appConfigJSON",g(41,49,e.appConfigJSON$)),l(3),b("cart",g(44,51,e.cart$))("appConfigJSON",g(45,53,e.appConfigJSON$))("isEdit",g(46,55,e.isEdit$))("outletID",e.outlet.value.ID)("outletName",e.outlet.value.Name)}}function Cr(n,t){if(n&1&&(r(0,"h5",36),m(1),f(2,"limitText"),a()),n&2){let e=p().data;l(),te(wt(2,1,e==null?null:e.label,14))}}function yr(n,t){if(n&1&&(r(0,"div",32)(1,"div",33)(2,"div",34),M(3,"i",35),a(),v(4,Cr,3,4,"h5",36),a()()),n&2){let e=t.data;b("ngClass",ie(4,mr,e.label))("matTooltip",e==null?null:e.tooltip),l(2),b("ngClass",ie(6,pr,e.label)),l(2),_(e!=null&&e.label?4:-1)}}var so=class n extends Tn{constructor(e,i,o,s,T,h,R,q,x,k,c,I,Q){rn(()=>{this.cartDisplayRef()&&(s.cartDisplayRef=this.cartDisplayRef())});super(I);this.form=i;this.intercom=h;this.role=x;this.toggle=k;this.lowOnStock=c;this.menuData$.subscribe();let H=i.buyForm.controls.Order.controls;this.outlets$=e.entities$,this.outlet=i.outlet,this.isEdit$=R.isEdit$.pipe(E(y=>y?this.outlet.disable():this.outlet.enable())),this.date=H.Date,x.global.Date==!1&&this.date.disable(),this.supplierID=H.SupplierID,this.attention=H.Att,this.poNumber=i.buyForm.controls.Order.controls.Number,this.role?.sell?.Number||this.poNumber.disable(),this.quickKeyPack$=o.quickKeyPack$,this.variantAutocomplete=s.variantAutocomplete,this.variantQuickKey=s.variantQuickKey,this.returnInvoiceNumber=T.returnInvoiceNumber,this.cart$=s.cart$,this.appConfigJSON$=e.appConfigJSON$,this.isOpenDialogOutlet$=c.selectedLowOnStockData.length==0?this.isEdit$.pipe(Y(y=>q.createNewTransaction$.pipe(d(C=>C||y))),d(y=>!y)):tt(!1),c.selectedLowOnStockData.length&&(i.setOutletForm({ID:c.selectedLowOnStockData[0].EntityID,Name:c.selectedLowOnStockData[0].Outlet}),Q.post("/API/catalog/variant/GetVariantByListID",{ListID:c.selectedLowOnStockData.map(y=>y.ID),EntityID:c.selectedLowOnStockData[0].EntityID}).pipe(d(y=>y.map(C=>this.setUnitPrice(C)).map(C=>({VariantID:C.ID,UnitPrice:C.UnitPrice})))).subscribe(y=>{i.setDeliveryEntityID(c.selectedLowOnStockData[0].EntityID);let C=c.selectedLowOnStockData.map(N=>({Quantity:N.Quantity,UnitQuantity:N.UnitQuantity,UnitPrice:y.find(F=>F.VariantID==N.VariantID).UnitPrice,Code:N.Code,Name:N.Product,DiscountAmount:N.DiscountAmount,Discount:N.Discount,Total:N.Total*y.find(F=>F.VariantID==N.VariantID).UnitPrice,VariantID:N.VariantID}));s.editForm(C)})),this.paymentComplete$=q.paymentComplete$,this.supplierPOTypes$=e.supplierPOTypes$,this.toggleState$=k.toggleState$,this.initFulfillmentDifferentOutlet()}cartDisplayRef=qt("cartDisplayRef",{read:Fi});variantAutocompleteEndpoint=Ae.GetVariantSuggestionsByEntityID;sf=se(Nt);outlets$;quickKeyPack$;outlet;poNumber;date;supplierID;variantAutocomplete=new me;variantQuickKey=new me;returnInvoiceNumber;cart$;appConfigJSON$;attention;isEdit$;paymentComplete$;supplierPOTypes$;isOpenDialogOutlet$;toggleState$;renderer=se(Zi);isFulfillmentDifferentOutlet=Le(!1);fulfillmentOutletName=Le("");ngAfterViewInit(){let e=document.querySelector("#full-container");this.renderer.addClass(e,"full-container"),this.intercom.hideLauncher()}initFulfillmentDifferentOutlet(){Ce([this.form.outlet.valueChanges.pipe(je(this.form.outlet.value)),this.form.deliveryEntityID.valueChanges.pipe(je(this.form.deliveryEntityID.value)),this.outlets$]).pipe(z()).subscribe(([e,i,o])=>{let s=e??this.form.outlet.value,T=i??this.form.deliveryEntityID.value;if(S.IsNotEmpty(T)&&T!=S.GuidEmpty&&s?.ID!=T){let h=o.find(R=>R.ID==T);this.fulfillmentOutletName.set(h?.Name??""),this.isFulfillmentDifferentOutlet.set(!0)}else this.isFulfillmentDifferentOutlet.set(!1)})}setUnitPrice(e){let i=w({},e);return S.IsNotEmpty(e.OrderPrice)?i.UnitPrice=e.OrderPrice:i.UnitPrice=e.UnitCost,i}ngOnDestroy(){this.lowOnStock.selectedLowOnStockData=[],this.intercom.showLauncher();let e=document.querySelector("#full-container");this.renderer.removeClass(e,"full-container")}collapseSidebar(){this.toggle.toggleSidebar()}static \u0275fac=function(i){return new(i||n)(u(de),u(G),u(Xe),u(ee),u(mt),u(hn),u(Ve),u($e),u(he),u(vn),u(ii),u(wn),u(re))};static \u0275cmp=A({type:n,selectors:[["POS-buy-v2"]],viewQuery:function(i,o){i&1&&Lt(o.cartDisplayRef,lr,5,Fi),i&2&&Qt()},features:[Ne([ee,$e,Ot,Ve,G,Pt,de,It,Xe,Ze,mt,Nt]),tn],decls:5,vars:3,consts:[["fulfillmentIndicator",""],["cartDisplayRef",""],[3,"paymentComplete"],[1,"container-fluid"],[1,"row","header","border-bottom"],[1,"col-5","border-end"],[1,"left-toolbar-container","h-100","d-flex","align-items-center","justify-content-between"],[3,"outlets","isOpenAfterLoad","formControl","disabled"],["transactionType","Purchase Order",3,"formControl","isEdit"],[1,"d-inline-block","pt-1","px-2","w-100"],[3,"formControl","tooltip"],[1,"col-7","d-flex","align-items-center"],[1,"row","flex-grow-1"],[1,"col-lg-7","col-5","d-flex","align-items-center"],[3,"returnInvoiceNumber","appConfigJSON","isEditBuyForm","outletID","outletName"],[1,"col-5","ps-0"],[1,"d-flex","align-items-center","position-relative"],[1,"fa-light","fa-id-badge","position-absolute"],["type","text","placeholder","Assign Attention",1,"border-bottom-0",3,"formControl"],[1,"col-2"],[1,"navbar","mobile-button","border-bottom-0"],["type","button","aria-controls","navigation-index","aria-expanded","false","aria-label","Toggle navigation",1,"navbar-toggler","navbar-toggler-right","float-end","toggle-menu","ps-2","pe-0","border-0",2,"width","max-content","height","max-content",3,"click"],[1,"navbar-toggler-bar","burger-lines"],[1,"row","content"],[3,"quickKey","outletID","formControl"],[1,"col-7","pt-5","px-0","d-flex","flex-column"],[1,"row","w-100","ms-0"],[1,"col-7","px-0"],["amountProperty","VariantCost",3,"formControl","autocompleteEndpoint","outletID"],[3,"formControl","supplierPOTypes","appConfigJSON"],[1,"cart-display",3,"cart","appConfigJSON","isEdit","outletID","outletName"],[4,"ngTemplateOutlet","ngTemplateOutletContext"],[3,"ngClass","matTooltip"],["role","button",1,"d-flex","align-items-center","cursor-pointer","w-100"],[3,"ngClass"],[1,"fa-duotone","fa-light","fa-truck"],[1,"text--truncated"]],template:function(i,o){if(i&1&&(v(0,dr,1,1,"POS-complete",2),f(1,"async"),nn(2,gr,48,57,"div",3),ut(3,yr,5,8,"ng-template",null,0,Gt)),i&2){let s;_((s=g(1,1,o.paymentComplete$))?0:2,s)}},dependencies:[ce,Ge,sn,Ye,be,ae,ze,Kn,zn,Rn,ci,li,Yn,mi,vi,Ti,wi,lt,rt,Ee,Xt],styles:[".left-toolbar-container[_ngcontent-%COMP%]{position:relative}.left-toolbar-container[_ngcontent-%COMP%] POS-invoice-number-form[_ngcontent-%COMP%]{position:absolute;top:34px;left:32px}.header[_ngcontent-%COMP%]{min-height:60px}.content[_ngcontent-%COMP%]{min-height:calc(100vh - 60px)}.supplier-more-menu[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center}.cart-display[_ngcontent-%COMP%]{flex-grow:1;height:0px;overflow-y:auto}input[_ngcontent-%COMP%]{width:100%;height:38px!important;border:0;border-bottom:1px solid #ced4da;padding-left:32px}input[_ngcontent-%COMP%]::placeholder{color:#ced4da}i.fa-id-badge[_ngcontent-%COMP%]{font-size:16px;top:10.6px;left:13px}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]{transition:.4s}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]:nth-child(1){-webkit-transform:rotate(-45deg) translate(-8px,4px);transform:rotate(-45deg) translate(-8px,4px)}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]:nth-child(2){opacity:0}.change[_ngcontent-%COMP%] .burger-lines[_ngcontent-%COMP%]:nth-child(3){-webkit-transform:rotate(45deg) translate(-5px,0px);transform:rotate(45deg) translate(-5px)}.mobile-button[_ngcontent-%COMP%]{display:none}@media (max-width: 990px){.mobile-button[_ngcontent-%COMP%]{display:block}}.navbar-toggler[_ngcontent-%COMP%]:focus{box-shadow:none!important}.more-actions[_ngcontent-%COMP%] div.d-flex[_ngcontent-%COMP%]{width:30rem}.d-flex[_ngcontent-%COMP%] .text--truncated[_ngcontent-%COMP%]{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}"]})};export{so as BuyV2Component};
|