1"use strict";(self.webpackChunkdimebags_admin_portal=self.webpackChunkdimebags_admin_portal||[]).push([[436],{7436:(Pt,L,l)=>{l.r(L),l.d(L,{InvoicesModule:()=>Et});var _=l(61496),ee=l(16161),te=l(29968),V=l(44551),g=l(60646),F=l(51545),h=l(94065),U=l(69141),e=l(80201),j=l(39531),G=l(14024),f=l(15897),I=l(55018),O=l(76436),m=l(47238),A=l(92314),ne=l(87684),oe=l(30630),X=l(15032),ie=l(30590),re=l(77007);function Y(i,s=ne.E,t){const o=(0,re.O)(i,s);return function ae(i,s){return(0,oe.N)((t,o)=>{const{leading:n=!0,trailing:a=!1}=s??{};let r=!1,c=null,p=null,d=!1;const k=()=>{p?.unsubscribe(),p=null,a&&(D(),d&&o.complete())},x=()=>{p=null,d&&o.complete()},T=C=>p=(0,ie.Tg)(i(C)).subscribe((0,X._)(o,k,x)),D=()=>{if(r){r=!1;const C=c;c=null,o.next(C),!d&&T(C)}};t.subscribe((0,X._)(o,C=>{r=!0,c=C,(!p||p.closed)&&(n?D():T(C))},()=>{d=!0,(!(a&&r&&p)||p.closed)&&o.complete()}))})}(()=>o,t)}var Z=l(33737),se=l(48591),P=l(79590),b=l(93772),u=l(89589),R=l(6642),z=l(33936),$=l(3704),J=l(42582),le=l(53929),E=l(93214),M=l(95590);function ce(i,s){1&i&&e.eu8(0)}function pe(i,s){if(1&i&&(e.j41(0,"mat-option",45),e.EFF(1),e.k0s()),2&i){const t=s.$implicit;e.Y8G("value",t._id),e.R7$(),e.SpI("",t.name," ")}}function me(i,s){if(1&i&&(e.j41(0,"mat-optgroup",43),e.DNE(1,pe,2,2,"mat-option",44),e.k0s()),2&i){const t=s.$implicit;e.FS9("label",t.type),e.R7$(),e.Y8G("ngForOf",t.companies)}}function de(i,s){1&i&&(e.j41(0,"mat-error"),e.EFF(1,"Required"),e.k0s())}function ue(i,s){if(1&i&&(e.j41(0,"mat-form-field",5)(1,"mat-select",41),e.DNE(2,me,2,2,"mat-optgroup",42),e.k0s(),e.DNE(3,de,2,0,"mat-error",15),e.k0s()),2&i){const t=e.XpG();e.R7$(2),e.Y8G("ngForOf",t.groupedCompanies),e.R7$(),e.Y8G("ngIf",t.invoiceForm.get("company_id").hasError("required"))}}function ge(i,s){1&i&&e.nrm(0,"input",46)}function _e(i,s){1&i&&(e.j41(0,"mat-error"),e.EFF(1,"Invalid email"),e.k0s())}function fe(i,s){1&i&&(e.j41(0,"mat-error"),e.EFF(1,"Required"),e.k0s())}function he(i,s){1&i&&(e.j41(0,"mat-error"),e.EFF(1,"Required"),e.k0s())}function ve(i,s){1&i&&(e.j41(0,"mat-error"),e.EFF(1,"Required"),e.k0s())}function ye(i,s){1&i&&(e.j41(0,"mat-error"),e.EFF(1,"Required"),e.k0s())}let Ie=(()=>{class i{get superUser(){return this._isSuperUser}constructor(t,o,n,a,r,c){this.formBuilder=t,this.permission=o,this.viewAsCompanyService=n,this.companyService=a,this.dispensaryService=r,this.accountService=c,this._onDestroy=new F.B,this.formData=new e.bkB,this.selectedLocations=[],this.locationsLoading=!0,this.invoiceForm=this.formBuilder.group({dueDate:[{value:new Date,disabled:!0},m.k0.required],company_id:["",m.k0.required],payeeLocation_id:["",m.k0.required],payerLocation_id:["",m.k0.required],payerCompanyName:[{value:"",disabled:!0}],payerCompany_id:[""],recipientEmail:["",m.k0.email],payType:["",m.k0.required],payTerm:["",m.k0.required],isPaid:[!1,m.k0.required],paymentStatus:["unpaid",m.k0.required],subtotal:[0,m.k0.required],tax:[0,m.k0.required],total:[{value:"0",disabled:!0}],comments:[""]}),this.permission.isSuperUser().then(p=>{this._isSuperUser=p,this.companyService.currentCompanyInfo.pipe((0,h.Q)(this._onDestroy)).subscribe(d=>{this.currentCompany=d}),p&&(this.viewAsCompanyService.viewAsCompanyInfo.pipe((0,h.Q)(this._onDestroy)).subscribe(d=>{this.isViewAsCompany=d}),this.companyService.currentCompaniesInfo.pipe((0,h.Q)(this._onDestroy)).subscribe(d=>{d&&d.length?(this.companies=d,this.groupedCompanies=this.companyService.getGroupedCompaniesByType(d)):(this.companies=[],this.groupedCompanies=[])}))})}ngOnInit(){this.init()}init(){var t=this;return(0,g.A)(function*(){t.invoiceForm.get("company_id").valueChanges.pipe(Y(1e3)).subscribe(function(){var a=(0,g.A)(function*(r){r?console.log(r):(t.payerDispensaries=[],t.payeeDispensaries=[],t.payCompanies=[],t.invoiceForm.patchValue({payeeLocation_id:"",payerLocation_id:"",recipientEmail:"",payerCompany_id:""}))});return function(r){return a.apply(this,arguments)}}()),t.invoiceForm.get("payerLocation_id").valueChanges.pipe(Y(1e3)).subscribe(function(){var a=(0,g.A)(function*(r){if(r){const c=t.selectedLocations?.find(k=>k._id===r);let p,d;p=yield t.companyService.getData(c.company_id),p?(t.invoiceForm.patchValue({payerCompanyName:p.name,payerCompany_id:p._id}),d=yield t.accountService.getData(p.owner_id),d&&t.invoiceForm.patchValue({recipientEmail:d?.email||""})):t.invoiceForm.patchValue({payerCompanyName:"",payerCompany_id:"",recipientEmail:""})}else t.invoiceForm.patchValue({payerCompanyName:"",payerCompany_id:"",recipientEmail:""})});return function(r){return a.apply(this,arguments)}}()),t.invoiceForm.get("isPaid").valueChanges.subscribe(a=>{t.invoiceForm.patchValue({paymentStatus:a?"paid":"unpaid"})}),(!t.superUser||t.isViewAsCompany)&&t.invoiceForm.patchValue({company_id:t.currentCompany._id}),(0,A.h)(t.invoiceForm.get("subtotal").valueChanges,t.invoiceForm.get("tax").valueChanges).subscribe(()=>{const a=t.invoiceForm.getRawValue(),r=a.subtotal?Number(a.subtotal.replace(/,/g,"")):0,c=a.tax?Number(a.tax.replace(/,/g,"")):0;t.invoiceForm.patchValue({total:r+c},{emitEvent:!1})})})()}
1emitForm(){if(this.invoiceForm.valid){const t=this.invoiceForm.getRawValue(),o=t.subtotal?Number(t.subtotal.replace(/,/g,"")):0,n=t.tax?Number(t.tax.replace(/,/g,"")):0;t.subtotal=o,t.tax=n,t.total=o+n,delete t.isPaid,this.formData.emit(t)}}cancel(){this.formData.emit(null)}captureLocation(t,o){this.selectedLocations.push(t),this.invoiceForm.patchValue({[o]:t._id})}static{this.\u0275fac=function(o){return new(o||i)(e.rXU(m.ze),e.rXU(Z.n),e.rXU(I.yL),e.rXU(f.Bl),e.rXU(f.MC),e.rXU(f.Di))}}static{this.\u0275cmp=e.VBU({type:i,selectors:[["app-invoice-form"]],inputs:{submitText:"submitText"},outputs:{formData:"formData"},standalone:!1,decls:82,vars:15,consts:[["dp",""],["companyList",""],["hiddenCompany",""],[1,"dimebags-form",3,"ngSubmit","formGroup"],[1,"form-row"],[1,"fx-50"],["matInput","","formControlName","dueDate",3,"matDatepicker"],["matSuffix","",3,"for"],["disabled","false"],[4,"ngIf","ngIfThen","ngIfElse"],["type","my","placeholder","Select receiver location","hint","The receiver of the payment, with ACH option this will create a QR code to send to the attached account.",3,"selection","currentCompany"],["type","authorized","placeholder","Select payer location",3,"selection","currentCompany"],["type","hidden","formControlName","payerCompany_id"],["matInput","","formControlName","payerCompanyName","type","text","placeholder","Invoice To Company"],["matInput","","formControlName","recipientEmail","type","email","placeholder","Recipient Email"],[4,"ngIf"],[1,"form-row","align-center","switch"],["formControlName","payType","placeholder","Payment Type"],["value","terms"],["value","cash"],["value","check"],["value","cashlessAtm"],["value","ach"],["formControlName","payTerm","placeholder","Payment Terms"],["value","payOnDelivery"],["value","net7"],["value","net14"],["value","net30"],["value","net45"],["value","net60"],[1,"form-row","switch"],["formControlName","isPaid"],["matInput","","currencyFormatter","","formControlName","subtotal","placeholder","Subtotal"],["matPrefix",""],["matInput","","currencyFormatter","","formControlName","tax","placeholder","Tax"],["matInput","","currencyFormatter","","formControlName","total","placeholder","Total"],[1,"fx-100"],["matInput","","formControlName","comments","cdkTextareaAutosize","","cdkAutosizeMinRows","3","placeholder","Add comments to the invoice..."],[1,"action-buttons"],["mat-raised-button","","type","button","color","primary",3,"click"],["mat-raised-button","","type","submit","color","primary",3,"disabled"],["formControlName","company_id","placeholder","Select company"],[3,"label",4,"ngFor","ngForOf"],[3,"label"],[3,"value",4,"ngFor","ngForOf"],[3,"value"],["type","hidden","formControlName","company_id"]],template:function(o,n){if(1&o){const a=e.RV6();e.j41(0,"form",3),e.bIt("ngSubmit",function(){return e.eBV(a),e.Njj(n.emitForm())}),e.j41(1,"div",4)(2,"mat-form-field",5)(3,"mat-label"),e.EFF(4,"Issue Date"),e.k0s(),e.nrm(5,"input",6),e.j41(6,"mat-hint"),e.EFF(7,"MM/DD/YYYY"),e.k0s(),e.nrm(8,"mat-datepicker-toggle",7)(9,"mat-datepicker",8,0),e.k0s(),e.DNE(11,ce,1,0,"ng-container",9)(12,ue,4,2,"ng-template",null,1,e.C5r)(14,ge,1,0,"ng-template",null,2,e.C5r),e.k0s(),e.j41(16,"app-location-select",10),e.bIt("selection",function(c){return e.eBV(a),e.Njj(n.captureLocation(c,"payeeLocation_id"))}),e.k0s(),e.nrm(17,"mat-divider"),e.j41(18,"app-location-select",11),e.bIt("selection",function(c){return e.eBV(a),e.Njj(n.captureLocation(c,"payerLocation_id"))}),e.k0s(),e.j41(19,"div",4)(20,"mat-form-field",5),e.nrm(21,"input",12)(22,"input",13),e.k0s(),e.j41(23,"mat-form-field",5),e.nrm(24,"input",14),e.DNE(25,_e,2,0,"mat-error",15),e.k0s()(),e.j41(26,"div",16)(27,"mat-form-field",5)(28,"mat-select",17)(29,"mat-option",18),e.EFF(30,"Terms"),e.k0s(),e.j41(31,"mat-option",19),e.EFF(32,"Cash"),e.k0s(),e.j41(33,"mat-option",20),e.EFF(34,"Check"),e.k0s(),e.j41(35,"mat-option",21),e.EFF(36,"Cashless ATM"),e.k0s(),e.j41(37,"mat-option",22),e.EFF(38,"ACH"),e.k0s()(),e.DNE(39,fe,2,0,"mat-error",15),e.k0s(),e.j41(40,"mat-form-field",5)(41,"mat-select",23)(42,"mat-option",24),e.EFF(43,"Pay on Delivery"),e.k0s(),e.j41(44,"mat-option",25),e.EFF(45,"Net 7"),e.k0s(),e.j41(46,"mat-option",26),e.EFF(47,"Net 14"),e.k0s(),e.j41(48,"mat-option",27),e.EFF(49,"Net 30"),e.k0s(),e.j41(50,"mat-option",28),e.EFF(51,"Net 45"),e.k0s(),e.j41(52,"mat-option",29),e.EFF(53,"Net 60"),e.k0s()(),e.DNE(54,he,2,0,"mat-error",15),e.k0s()(),e.j41(55,"div",30)(56,"div",5)(57,"mat-slide-toggle",31),e.EFF(58,"Mark as Paid"),e.k0s()()(),e.nrm(59,"mat-divider"),e.j41(60,"div",4)(61,"mat-form-field"),e.nrm(62,"input",32),e.j41(63,"span",33),e.EFF(64,"$"),e.k0s(),e.DNE(65,ve,2,0,"mat-error",15),e.k0s(),e.j41(66,"mat-form-field"),e.nrm(67,"input",34),e.j41(68,"span",33),e.EFF(69,"$"),e.k0s(),e.DNE(70,ye,2,0,"mat-error",15),e.k0s(),e.j41(71,"mat-form-field"),e.nrm(72,"input",35),e.j41(73,"span",33),e.EFF(74,"$"),e.k0s()()(),e.j41(75,"mat-form-field",36),e.nrm(76,"textarea",37),e.k0s(),e.j41(77,"div",38)(78,"button",39),e.bIt("click",function(){return e.eBV(a),e.Njj(n.cancel())}),e.EFF(79,"Cancel"),e.k0s(),e.j41(80,"button",40),e.EFF(81),e.k0s()()()}if(2&o){const a=e.sdS(10),r=e.sdS(13),c=e.sdS(15);e.Y8G("formGroup",n.invoiceForm),e.R7$(5),e.Y8G("matDatepicker",a),e.R7$(3),e.Y8G("for",a),e.R7$(3),e.Y8G("ngIf",n.superUser&&!n.isViewAsCompany)("ngIfThen",r)("ngIfElse",c),e.R7$(5),e.Y8G("currentCompany",n.currentCompany),e.R7$(2),e.Y8G("currentCompany",n.currentCompany),e.R7$(7),e.Y8G("ngIf",n.invoiceForm.get("recipientEmail").hasError("email")),e.R7$(14),e.Y8G("ngIf",n.invoiceForm.get("payType").hasError("required")),e.R7$(15),e.Y8G("ngIf",n.invoiceForm.get("payTerm").hasError("required")),e.R7$(11),e.Y8G("ngIf",n.invoiceForm.get("subtotal").hasError("required")),e.R7$(5),e.Y8G("ngIf",n.invoiceForm.get("tax").hasError("required")),e.R7$(10),e.Y8G("disabled",n.invoiceForm.invali
1d),e.R7$(),e.JRh(n.submitText)}},dependencies:[_.Sq,_.bT,m.qT,m.me,m.BC,m.cb,m.j4,m.JD,se.d,P.M,P.a,b.Vh,b.bZ,b.bU,u.j,u.M,u.c,u.b,u.e,u.g,R.fg,z.xb,$.g,J.sG,le.q,E.$z,M.R],styles:[".deferred-select-placeholder-container[_ngcontent-%COMP%]{display:flex;align-items:center}.deferred-select-placeholder-container[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{flex:1} .hide-deferred-select-dummy-option{display:none!important}.internal-spinner[_ngcontent-%COMP%]{display:inline-block;position:absolute;right:25px}.payee-option-wrap[_ngcontent-%COMP%]{display:flex;align-items:center}.ach-available[_ngcontent-%COMP%]{margin-left:2em;font-size:11px;color:red}mat-divider[_ngcontent-%COMP%]{margin:2em 0 1em}"]})}}return i})();function Ce(i,s){if(1&i&&(e.j41(0,"h2",4),e.EFF(1),e.k0s()),2&i){const t=e.XpG();e.R7$(),e.JRh(t.title)}}function be(i,s){if(1&i&&(e.j41(0,"h2",5),e.EFF(1),e.k0s()),2&i){const t=e.XpG();e.R7$(),e.Lme("",t.title," as ",null==t.currentCompany?null:t.currentCompany.name,"")}}let Fe=(()=>{class i{constructor(t,o,n,a,r,c){this.dialogRef=t,this.independentInvoicesService=o,this.companyService=n,this.viewAsCompanyService=a,this.snackBar=r,this.loaderService=c,this._onDestroy=new F.B,this.title="Creating an invoice",this.companyService.currentCompanyInfo.pipe((0,h.Q)(this._onDestroy)).subscribe(p=>{p&&(this.currentCompany=p)}),this.viewAsCompanyService.viewAsCompanyInfo.pipe((0,h.Q)(this._onDestroy)).subscribe(p=>{this.isViewAsCompany=p})}ngOnInit(){this.invoiceId=this.independentInvoicesService.generateID()}ngOnDestroy(){this._onDestroy.next(),this._onDestroy.complete()}createInvoice(t){var o=this;return(0,g.A)(function*(){if(t){if(o.subscription)return void console.log("Subscription was not unsubscribed yet.");o.loaderService.open("Generating Invoice..."),o.generated&&(yield o.independentInvoicesService.delete(o.invoiceId)),t.generatePdf=!0,yield o.independentInvoicesService.create(t,o.invoiceId),o.subscription=o.independentInvoicesService.watch(o.invoiceId).pipe((0,h.Q)(o._onDestroy)).subscribe(n=>{"success"===n.creationStatus?(o.loaderService.close(),o.dialogRef.close(!0),o.subscription.unsubscribe(),o.subscription=null):"fail"===n.creationStatus&&(o.loaderService.close(),o.subscription.unsubscribe(),o.subscription=null,o.snackBar.open("An error occurred creating the invoice. "+n.errorMsg,"OK"))})}else o.dialogRef.close(!1)})()}static{this.\u0275fac=function(o){return new(o||i)(e.rXU(j.m),e.rXU(G.W),e.rXU(f.Bl),e.rXU(I.yL),e.rXU(O.UG),e.rXU(I.Cl))}}static{this.\u0275cmp=e.VBU({type:i,selectors:[["app-create-invoice"]],standalone:!1,decls:4,vars:2,consts:[["mat-dialog-content","",1,"dimebags-dialog"],["mat-dialog-title","",4,"ngIf"],["mat-dialog-title","","style","color: red",4,"ngIf"],["submitText","Create an Invoice",3,"formData"],["mat-dialog-title",""],["mat-dialog-title","",2,"color","red"]],template:function(o,n){1&o&&(e.j41(0,"div",0),e.DNE(1,Ce,2,1,"h2",1)(2,be,2,2,"h2",2),e.j41(3,"app-invoice-form",3),e.bIt("formData",function(r){return n.createInvoice(r)}),e.k0s()()),2&o&&(e.R7$(),e.Y8G("ngIf",!n.isViewAsCompany),e.R7$(),e.Y8G("ngIf",n.isViewAsCompany))},dependencies:[_.bT,j.b,j.c,Ie],encapsulation:2})}}return i})();var Q=l(98205),H=l(53790),N=l(5183),w=l(89723),ke=l(63716),W=l(55619),v=l(33946),S=l(13310),je=l(72633),Se=l(21092),Te=l(42806),De=l(32162),Ee=l(36941),xe=l(53341),Pe=l(84107);let Re=(()=>{class i{constructor(t){this.dialogRef=t,this.amount=0}static{this.\u0275fac=function(o){return new(o||i)(e.rXU(j.m))}}static{this.\u0275cmp=e.VBU({type:i,selectors:[["app-partial-payment-dialog"]],standalone:!1,decls:12,vars:2,consts:[[1,"p-6"],[1,"text-xl","mb-4"],[1,"w-full"],["matInput","","type","number","min","0","step","0.01",3,"ngModelChange","ngModel"],[1,"flex","justify-end","gap-3","mt-4"],["mat-button","",3,"click"],["mat-raised-button","","color","primary",3,"click","disabled"]],template:function(o,n){1&o&&(e.j41(0,"div",0)(1,"h2",1),e.EFF(2,"Enter Partial Payment Amount"),e.k0s(),e.j41(3,"mat-form-field",2)(4,"mat-label"),e.EFF(5,"Payment Amount"),e.k0s(),e.j41(6,"input",3),e.mxI("ngModelChange",function(r){return e.DH7(n.amount,r)||(n.amount=r),r}),e.k0s()(),e.j41(7,"div",4)(8,"button",5),e.bIt("click",function(){return n.dialogRef.close()}),e.EFF(9,"Cancel"),e.k0s(),e.j41(10,"button",6),e.bIt("click",function(){return n.dialogRef.close(n.amount)}),e.EFF(11," Confirm "),e.k0s()()()),2&o&&(e.R7$(6),e.R50("ngModel",n.amount),e.R7$(4),e.Y8G("disabled",!n.amount))},dependencies:[m.me,m.Q0,m.BC,m.VZ,m.vS,u.j,u.M,R.fg,E.$z],encapsulation:2})}}return i})();var K=l(88241),B=l(46927),q=l(76830),Me=l(13822);const Ge=()=>[10,25,100],Oe=i=>({"selected-row":i});
1function $e(i,s){if(1&i){const t=e.RV6();e.j41(0,"button",5),e.bIt("click",function(){e.eBV(t);const n=e.XpG();return e.Njj(n.clearSearch())}),e.j41(1,"mat-icon"),e.EFF(2,"close"),e.k0s()()}}function Ne(i,s){1&i&&(e.j41(0,"div",43),e.nrm(1,"mat-spinner",44),e.k0s())}function we(i,s){if(1&i){const t=e.RV6();e.j41(0,"td",45),e.bIt("click",function(n){return e.eBV(t),e.Njj(n.stopPropagation())}),e.j41(1,"mat-checkbox",46),e.bIt("change",function(n){const a=e.eBV(t).$implicit,r=e.XpG();return e.Njj(n?r.selection.toggle(a):null)}),e.k0s()()}if(2&i){const t=s.$implicit,o=e.XpG();e.R7$(),e.Y8G("checked",o.selection.isSelected(t))}}function Be(i,s){if(1&i&&(e.j41(0,"td",47)(1,"span",48),e.EFF(2,"Invoice"),e.k0s(),e.nrm(3,"br"),e.j41(4,"span",49),e.EFF(5),e.k0s()()),2&i){const t=s.$implicit;e.R7$(5),e.JRh(null!=t.invoiceNumber?"#"+t.invoiceNumber:"\u2014")}}function Le(i,s){if(1&i&&(e.j41(0,"td",47)(1,"span",49),e.EFF(2),e.k0s(),e.nrm(3,"br"),e.j41(4,"span",48),e.EFF(5),e.k0s()()),2&i){const t=s.$implicit;e.R7$(2),e.JRh(t.payerCompanyName),e.R7$(3),e.JRh(t.payerLocationName)}}function Ve(i,s){if(1&i&&(e.j41(0,"td",47)(1,"span",49),e.EFF(2),e.nI1(3,"currency"),e.k0s()()),2&i){const t=s.$implicit;e.R7$(2),e.JRh(e.bMT(3,1,t.total||0))}}function Ue(i,s){1&i&&(e.j41(0,"th",50),e.EFF(1," Due Date "),e.k0s())}function Ae(i,s){if(1&i&&(e.j41(0,"span",54),e.EFF(1),e.k0s()),2&i){const t=e.XpG(2).$implicit;e.R7$(),e.SpI(" ($",null==t.partialPaymentAmount?null:t.partialPaymentAmount.toFixed(2),") ")}}function Xe(i,s){if(1&i&&(e.j41(0,"div")(1,"span"),e.EFF(2),e.k0s(),e.DNE(3,Ae,2,1,"span",53),e.k0s()),2&i){const t=e.XpG().$implicit,o=e.XpG();e.ZvI("paid-status ",t.paymentStatus,""),e.R7$(2),e.JRh(o.getPaymentStatus(t.paymentStatus)),e.R7$(),e.Y8G("ngIf","partially_paid"===t.paymentStatus)}}function Ye(i,s){if(1&i&&(e.j41(0,"td",47)(1,"div",51),e.DNE(2,Xe,4,5,"div",52),e.k0s()()),2&i){const t=s.$implicit;e.R7$(2),e.Y8G("ngIf",t.paymentStatus)}}function Ze(i,s){if(1&i&&(e.j41(0,"td",47)(1,"table",55)(2,"tr")(3,"td",56),e.EFF(4,"Due Date"),e.k0s(),e.j41(5,"td",57),e.EFF(6),e.nI1(7,"date"),e.k0s()(),e.j41(8,"tr")(9,"td",56),e.EFF(10,"Recipient Email"),e.k0s(),e.j41(11,"td",57),e.EFF(12),e.k0s()(),e.j41(13,"tr")(14,"td",56),e.EFF(15,"Type"),e.k0s(),e.j41(16,"td",57),e.EFF(17),e.k0s()()()()),2&i){const t=s.$implicit;e.R7$(6),e.JRh(e.i5U(7,3,t.dueDate.toDate(),"mediumDate")),e.R7$(6),e.JRh(t.recipientEmail),e.R7$(5),e.JRh(t.zoneBasedInvoice?"Zone Based":"Invoice")}}function ze(i,s){if(1&i){const t=e.RV6();e.qex(0),e.j41(1,"button",61),e.bIt("click",function(){e.eBV(t);const n=e.XpG(),a=n.$implicit,r=n.index,c=e.XpG();return e.Njj(c.togglePaymentStatus(a,r,"paid"))}),e.EFF(2,"Mark as Paid"),e.k0s(),e.j41(3,"button",61),e.bIt("click",function(){e.eBV(t);const n=e.XpG(),a=n.$implicit,r=n.index,c=e.XpG();return e.Njj(c.togglePaymentStatus(a,r,"partially_paid"))}),e.EFF(4),e.k0s(),e.j41(5,"button",63),e.bIt("click",function(){e.eBV(t);const n=e.XpG(),a=n.$implicit,r=n.index,c=e.XpG();return e.Njj(c.voidInvoice(a,r))}),e.EFF(6,"Void Invoice"),e.k0s(),e.bVm()}if(2&i){const t=e.XpG().$implicit;
1e.R7$(4),e.JRh("partially_paid"===t.paymentStatus?"Update Partial Payment":"Mark as Partially Paid"),e.R7$(),e.Y8G("disabled",t.zoneBasedInvoice)}}function Je(i,s){if(1&i){const t=e.RV6();e.j41(0,"button",61),e.bIt("click",function(){e.eBV(t);const n=e.XpG().$implicit,a=e.XpG();return e.Njj(a.deleteInvoice(n))}),e.EFF(1,"Delete"),e.k0s()}}function Qe(i,s){if(1&i){const t=e.RV6();e.j41(0,"td",58)(1,"button",59)(2,"mat-icon"),e.EFF(3,"more_vert"),e.k0s()(),e.j41(4,"mat-menu",null,0),e.DNE(6,ze,7,2,"ng-container",60),e.j41(7,"button",61),e.bIt("click",function(){const n=e.eBV(t).$implicit,a=e.XpG();return e.Njj(a.downloadInvoice(n))}),e.EFF(8,"Download"),e.k0s(),e.DNE(9,Je,2,0,"button",62),e.k0s()()}if(2&i){const t=s.$implicit,o=e.sdS(5),n=e.XpG();e.R7$(),e.Y8G("matMenuTriggerFor",o),e.R7$(5),e.Y8G("ngIf",n.userHasPermission(n.UserPermissions.EDIT)&&("unpaid"===t.paymentStatus||"partially_paid"===t.paymentStatus)),e.R7$(3),e.Y8G("ngIf",n.userHasPermission(n.UserPermissions.DELETE))}}function He(i,s){if(1&i&&e.nrm(0,"tr",64),2&i){const t=s.$implicit,o=e.XpG();e.Y8G("ngClass",e.eq3(1,Oe,o.selection.isSelected(t)))}}let We=(()=>{class i{set adminPerm(t){this._adminPerm=t,this.setPermissions()}set selfPerm(t){this._selfPerm=t,this.setPermissions()}constructor(t,o,n,a,r,c,p,d,k,x,T,D,C,xt){this.accountService=t,this.independentInvoiceService=o,this.companyService=n,this.permission=a,this.statisticsLifetimeService=r,this.viewAsCompanyService=c,this.ref=p,this.httpClientService=d,this.appLoader=k,this.pdfGeneratorService=x,this.orderService=T,this.dispensaryService=D,this.dialog=C,this.snackBar=xt,this._onDestroy=new F.B,this.isLoadingResults=!0,this.sorting="dateCreated-desc",this.sortingEvent=new F.B,this.tableData=new v.I6,this.reloadTable=new F.B,this.selectionChanged=new e.bkB,this.lastResult=[],this.displayedColumns=["select","invoiceNumber","locationInfo","total","paidStatus","metaInfo","actions"],this.selection=new ke.S(!0,[]),this.invoiceStatus="",this.UserPermissions=xe.FO,this.sortingEvent.next(this.sorting)}ngAfterViewInit(){this.sortingEvent.subscribe(()=>{this.paginator.pageIndex=0,this.lastResult=[]}),this.accountService.currentAccountInfo.pipe((0,h.Q)(this._onDestroy)).subscribe(t=>{this.currentUser=t}),this.companyService.currentCompanyInfo.pipe((0,h.Q)(this._onDestroy)).subscribe(t=>{t&&(this.currentCompany=t,this.company_id=t._id)}),this.permission.isSuperUser().then(t=>{t?(this._isSuperUser=!0,this.viewAsCompanyService.viewAsCompanyInfo.pipe((0,h.Q)(this._onDestroy)).subscribe(o=>{this.isViewAsCompany=o}),this.initTableData()):(this._isSuperUser=!1,this.initTableData())}),this.initGlobalStats(),this.selection.changed.subscribe(t=>{this.selectionChanged.emit(t.source.selected)})}ngOnDestroy(){this._onDestroy.next(),this._onDestroy.complete()}get superUser(){return this._isSuperUser}get adminPerm(){return this._adminPerm}get selfPerm(){return this._selfPerm}changeSort(t){this.sorting=t;const o=t.split("-");o&&2===o.length&&this.sortingEvent.next(t)}initGlobalStats(){this.statisticsLifetimeService.globalStats.pipe((0,h.Q)(this._onDestroy)).subscribe(t=>{this.globalStats=t})}setPermissions(){(this.selfPerm||this.adminPerm)&&!this.displayedColumns.includes("actions")&&(this.displayedColumns.push("actions"),this.ref.markForCheck())}initTableData(){(0,A.h)(this.companyService.currentCompanyInfo,this.viewAsCompanyService.viewAsCompanyInfo,this.sortingEvent,this.paginator.page,this.reloadTable).pipe((0,Se.Z)({}),(0,Te.n)(()=>{if((!this.superUser||this.isViewAsCompany)&&!this.company_id)return[];const t=this.sorting.split("-"),o=t[0],n=t[1];this.isLoadingResults=!0;let a={startAfter:this.paginator.pageIndex?this.lastResult[this.paginator.pageIndex-1]:null,order:o,dir:n};return this.search&&(a.invoiceNumber=+this.search,this.searched=!!this.search),this.invoiceStatus&&(a.status=this.invoiceStatus),this.independentInvoiceService.paginateInvoices(this.paginator.pageSize,a,this.isViewAsCompany?this.company_id:this.superUser?null:this.company_id)}),(0,De.T)(t=>(this.isLoadingResults=!1,this.lastResult[this.paginator.pageIndex]=t?.lastRef,t?.items)),(0,Ee.W)(t=>(S.c.catch("[IndependentInvoicesTableComponent], initTableData",t),this.isLoadingResults=!1,(0,je.of)([])))).subscribe(t=>{this.initialLoaded=!0,this.tableData=new v.I6(t),this.ref.markForCheck()})}isAllSelected(){return this.selection.selected.length===this.tableData.data.length}masterToggle(){this.isAllSelected()?this.selection.clear():this.selection.select(...this.tableData.data)}downloadInvoice(t){var o=this;return(0,g.A)(function*(){try{if(o.appLoader.open("Downloading invoice..."),t.zoneBasedInvoice){const n="string"==typeof t.payeeLocation_ids?t.payeeLocation_ids:t.payeeLocation_ids?.[0];if(!t.startDate?.toDate||!t.endDate?.toDate||!n)throw new Error("This zone-based invoice is missing data required to regenerate the PDF.");const a=yield o.orderService.getGroup(t.order_ids),r=yield o.companyService.getData(t.company_id),c=yield o.dispensaryService.getData(n),p=yield o.dispensaryService.getData(t.payerLocation_id);yield o.pdfGeneratorService.createInvoicePdf(a,[p],t.startDate.toDate(),t.endDate.toDate(),c,r,t.comments||"",{qrCode:t.paymentUrl,uuid:t.paymentUuid,invoiceNumber:t.invoiceNumber,dueDate:t.dueDate?.toDate?t.dueDate.toDate().toLocaleDateString():"",payType:t.payType||"",payTerm:t.payTerm||""},t.dropOffInvoice)}else{const n=yield o.independentInvoiceService.getManualDownloadUrl(t),a=yield o.httpClientService.getFile(n,"application/pdf");(0,U.saveAs)(a,`Invoice-${t._id}.pdf`)}}catch(n){S.c.catch("[IndependentInvoicesTableComponent] downloadInvoice",n
1),o.snackBar.open("Could not download this invoice. Please try again or contact support.",null,{duration:6e3})}finally{o.appLoader.close()}})()}togglePaymentStatus(t,o,n){var a=this;return(0,g.A)(function*(){try{let r=null;if("partially_paid"===n){if(r=yield a.dialog.open(Re).afterClosed().toPromise(),!r)return;a.appLoader.open("Marking as Partially Paid..."),yield a.independentInvoiceService.update(t._id,{paymentStatus:"partially_paid",partialPaymentAmount:r})}else a.appLoader.open("paid"===n?"Marking as Paid...":"Marking as Unpaid"),yield a.independentInvoiceService.update(t._id,{paymentStatus:n,partialPaymentAmount:null});const c=[...a.tableData.data];for(const p of c)p._id===t._id&&(p.paymentStatus=n,p.partialPaymentAmount="partially_paid"===n?r:null);a.tableData=new v.I6(c),a.appLoader.close()}catch{a.appLoader.close()}})()}getPaymentStatus(t){return"partially_paid"===t?"partial":t}voidInvoice(t,o){var n=this;return(0,g.A)(function*(){try{n.appLoader.open("Voiding invoice..."),yield n.independentInvoiceService.update(t._id,{paymentStatus:"void"}),n.tableData.data[o].paymentStatus="void",n.appLoader.close()}catch(a){S.c.catch("[IndependentInvoicesTableComponent] voidInvoice",a),n.appLoader.close()}})()}deleteInvoice(t){var o=this;return(0,g.A)(function*(){try{let n="Are you sure you want to delete this invoice? This cannot be undone.";t.zoneBasedInvoice&&(n+=" Orders from this invoice will remain in the BILLED status."),(yield o.dialog.open(Pe.M,{data:{message:n},width:"500px",maxWidth:"100vw"})).afterClosed().subscribe(function(){var r=(0,g.A)(function*(c){c&&(o.appLoader.open(),yield o.independentInvoiceService.delete(t._id),o.appLoader.close(),o.refreshForSearch())});return function(c){return r.apply(this,arguments)}}())}catch(n){S.c.catch("[IndependentInvoicesTableComponent] deleteInvoice",n),o.appLoader.close()}})()}toggleStatus(t){this.invoiceStatus=this.invoiceStatus===t?"":t,this.refreshForSearch()}clearSearch(){this.search="",this.searched&&this.initTableData()}refreshForSearch(){this.initTableData()}userHasPermission(t){return this.accountService.hasPermission(this.currentUser,t)}static{this.\u0275fac=function(o){return new(o||i)(e.rXU(f.Di),e.rXU(G.W),e.rXU(f.Bl),e.rXU(Z.n),e.rXU(f.S6),e.rXU(I.yL),e.rXU(e.gRc),e.rXU(Q.v),e.rXU(I.Cl),e.rXU(I.V6),e.rXU(f.QE),e.rXU(f.MC),e.rXU(j.j),e.rXU(O.UG))}}static{this.\u0275cmp=e.VBU({type:i,selectors:[["app-independent-invoices-table"]],viewQuery:function(o,n){if(1&o&&e.GBs(W.iy,5),2&o){let a;e.mGM(a=e.lsd())&&(n.paginator=a.first)}},inputs:{reloadTable:"reloadTable",adminPerm:"adminPerm",selfPerm:"selfPerm"},outputs:{selectionChanged:"selectionChanged"},standalone:!1,decls:65,vars:19,consts:[["actionMenu","matMenu"],["align","start center",1,"search-bar"],["appearance","fill"],["matInput","","type","text",3,"ngModelChange","keyup.enter","ngModel"],["matSuffix","","mat-icon-button","","aria-label","Search",3,"click",4,"ngIf"],["matSuffix","","mat-icon-button","","aria-label","Search",3,"click"],[1,"dimebags-table-wrap","invoices-table-wrap","mat-elevation-z2"],["class","loading-shade",4,"ngIf"],[1,"paginator-container"],[1,"pre-actions"],[3,"change","checked","indeterminate"],[1,"status-select","w-80","mx-auto","flex","items-center"],[1,"paid-status","partially_paid","h-8",3,"click"],[1,"paid-status","paid","h-8",3,"click"],[1,"paid-status","unpaid","h-8",3,"click"],[1,"paid-status","void","h-8",3,"click"],[1,"text-right"],[1,"dimebags-paginator","bg-transparent",3,"length","pageSizeOptions"],[1,"sort"],[3,"selectionChange","ngModel"],["value","dateCreated-desc"],["value","dateCreated-asc"],["value","dueDate-desc"],["value","dueDate-asc"],["value","recipientEmail-asc"],["value","recipientEmail-desc"],["value","payerLocationName-asc"],["value","payerLocationName-desc"],["value","payerCompanyName-asc"],["value","payerCompanyName-desc"],["mat-table","",1,"dimebags-table",3,"dataSource"],["matColumnDef","select"],["mat-cell","","class","select-column",3,"click",4,"matCellDef"],["matColumnDef","invoiceNumber"],["mat-cell","",4,"matCellDef"],["matColumnDef","locationInfo"],["matColumnDef","total"],["matColumnDef","paidStatus"],["mat-header-cell","","mat-sort-header","",4,"matHeaderCellDef"],["matColumnDef","metaInfo"],["matColumnDef","actions"],["mat-cell","","class","actions",4,"matCellDef"],["mat-row","",3,"ngClass",4,"matRowDef","matRowDefColumns"],[1,"loading-shade"],["color","primary"],["mat-cell","",1,"select-column",3,"click"],[3,"change","checked"],["mat-cell",""],[1,"sub-label","t-content"],[1,"main-label","t-content"],["mat-header-cell","","mat-sort-header",""],[1,"paid-col"],[3,"class",4,"ngIf"],["class","ml-2",4,"ngIf"],[1,"ml-2"],[1,"sub-table"],[1,"t-cell","row-name"],[1,"t-cell","row-value"],["mat-cell","",1,"actions"],["mat-icon-button","",3,"matMenuTriggerFor"],[4,"ngIf"],["mat-menu-item","",3,"click"],["mat-menu-item","",3,"click",4,"ngIf"],["mat-menu-item","",3,"click","disabled"],["mat-row","",3,"ngClass"]],template:function(o,n){1&o&&(e.j41(0,"div",1)(1,"mat-form-field",2)(2,"mat-label"),e.EFF(3,"Type your invoice number to search."),e.k0s(),e.j41(4,"input",3),e.mxI("ngModelChange",function(r){return e.DH7(n.search,r)||(n.search=r),r}),e.bIt("keyup.enter",function(){return n.refreshForSearch()}),e.k0s(),e.DNE(5,$e,3,0,"button",4),e.j41(6,"button",5),e.bIt("click",function(){return n.refreshForSearch()}),e.j41(7,"mat-icon"),e.EFF(8,"search"),e.k0s()()()(),e.j41(9,"div",6),e.DNE(10,Ne,2,0,"div",7),e.j41(11,"div",8)(12,"div",9)(13,"mat-checkbox",10),e.bIt("change",function(r){return r?n.masterToggle():null}),e.k0s()(),e.j41(14,"div",11)(15,"button",12),e.bIt("click",function(){return n.toggleStatus("partially_paid")}),e.EFF(16,"Partially Paid"),e.k0s(),e.j41(17,"button",13),e.bIt("click",function(){return n.toggleStatus("paid")}),e.EFF(18,"Paid"),e.k0s(),e.j41(19,"button",14),e.bIt("click",function(){return n.toggleStatus("unpaid")}),e.EFF(20,"Unpaid"),e.k0s(),e.j41(21,"button",15),e.bIt("click",function(){return n.toggleStatus("void")}),e.EFF(22,"Void"),e.k0s()(),e.j41(23,"div",16),e.nrm(24,"mat-paginator",17),e.k0s(),e.j41(25,"div",18)(26,"mat-form-field")(27,"mat-select",19),e.bIt("selectionChange",function(r){return n.changeSort(r.value)}),e.j41(28,"mat-option",20),e.EFF(29,"Sort by Created Date (Newest)"),e.k0s(),e.j41(30,"mat-option",21),e.EFF(31,"Sort by Created Date (Oldest)"),e.k0s(),e.j41(32,"mat-option",22),e.EFF(33,"Sort by Due Date (Newest)"),e.k0s(),e.j41(34,"mat-option",23),e.EFF(35,"Sort by Due Date (Oldest)"),e.k0s(),e.j41(36,"mat-option",24),e.EFF(37,"Sort by Recipent Email (A to Z)"),e.k0s(),e.j41(38,"mat-option",25),e.EFF(39,"Sort by Recipent Email (Z to A)"),e.k0s(),e.j41(40,"mat-option",26),e.EFF(41,"Sort by Payer Location (A to Z)"),e.k0s(),e.j41(42,"mat-option",27),e.EFF(43,"Sort by Payer Location (Z to A)"),e.k0s(),e.j41(44,"mat-option",28),e.EFF(45,"Sort by Payer Company (A to Z)"),e.k0s(),e.j41(46,"mat-option",29),e.EFF(47,"Sort by Payer Company (Z to A)"),e.k0s()()()()(),e.j41(48,"table",30),e.qex(49,31),e.DNE(50,we,2,1,"td",32),e.bVm(),e.qex(51,33),e.DNE(
152,Be,6,1,"td",34),e.bVm(),e.qex(53,35),e.DNE(54,Le,6,2,"td",34),e.bVm(),e.qex(55,36),e.DNE(56,Ve,4,3,"td",34),e.bVm(),e.qex(57,37),e.DNE(58,Ue,2,0,"th",38)(59,Ye,3,1,"td",34),e.bVm(),e.qex(60,39),e.DNE(61,Ze,18,6,"td",34),e.bVm(),e.qex(62,40),e.DNE(63,Qe,10,3,"td",41),e.bVm(),e.DNE(64,He,1,3,"tr",42),e.k0s()()),2&o&&(e.R7$(4),e.R50("ngModel",n.search),e.R7$(),e.Y8G("ngIf",n.search),e.R7$(5),e.Y8G("ngIf",n.isLoadingResults),e.R7$(3),e.Y8G("checked",n.selection.hasValue()&&n.isAllSelected())("indeterminate",n.selection.hasValue()&&!n.isAllSelected()),e.R7$(2),e.AVh("active","partially_paid"===n.invoiceStatus),e.R7$(2),e.AVh("active","paid"===n.invoiceStatus),e.R7$(2),e.AVh("active","unpaid"===n.invoiceStatus),e.R7$(2),e.AVh("active","void"===n.invoiceStatus),e.R7$(3),e.Y8G("length",(null==n.globalStats?null:n.globalStats.totalInvoices)||0)("pageSizeOptions",e.lJ4(18,Ge)),e.R7$(3),e.Y8G("ngModel",n.sorting),e.R7$(21),e.Y8G("dataSource",n.tableData),e.R7$(16),e.Y8G("matRowDefColumns",n.displayedColumns))},dependencies:[_.YU,_.bT,m.me,m.BC,m.vS,P.M,K.So,u.j,u.M,u.g,R.fg,$.g,B.kk,B.fb,B.Cp,q.M,N.An,w.LG,W.iy,Me.aE,v.Zl,v.tL,v.cC,v.YV,v.iL,v.KS,v.$R,v.NB,_.oe,_.vh],styles:[".paginator-container[_ngcontent-%COMP%] .pre-actions[_ngcontent-%COMP%]{padding-left:20px}.search-bar[_ngcontent-%COMP%]{margin-left:.5em}.search-bar[_ngcontent-%COMP%] mat-form-field[_ngcontent-%COMP%]{width:450px}.actions[_ngcontent-%COMP%]{text-align:right}.select-column[_ngcontent-%COMP%]{width:30px}.paid-col[_ngcontent-%COMP%]{text-align:right;width:100%}.paid-status[_ngcontent-%COMP%]{padding-top:4px;padding-bottom:4px;display:flex;align-items:center;justify-content:center;text-transform:capitalize;margin-left:auto;margin-right:0;border-radius:8px;border:2px solid transparent;outline:2px solid transparent}.paid-status[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{font-family:Source Sans Pro;font-style:normal;font-weight:600;font-size:14px;line-height:20px;color:#162649}.paid-status.partially_paid[_ngcontent-%COMP%]{background-color:#d5dfb2;color:#162649;width:120px}.paid-status.paid[_ngcontent-%COMP%]{background-color:#b2dfdb;color:#162649;width:44px}.paid-status.unpaid[_ngcontent-%COMP%]{background-color:#dfe8ec;color:#162649;width:60px}.paid-status.void[_ngcontent-%COMP%]{background-color:#e07096;color:#162649;width:44px}.paid-status.active[_ngcontent-%COMP%]{border:2px solid white;outline:2px solid red}"]})}}return i})();var Ke=l(59370),y=l(36183),qe=l(53389),et=l(73096),tt=l(8806);function nt(i,s){1&i&&(e.j41(0,"div",6)(1,"mat-icon",7),e.EFF(2,"store"),e.k0s(),e.j41(3,"h2",8),e.EFF(4,"Select Locations"),e.k0s()())}function ot(i,s){1&i&&(e.j41(0,"mat-error"),e.EFF(1,"Invalid start date"),e.k0s())}function it(i,s){1&i&&(e.j41(0,"mat-error"),e.EFF(1,"Invalid end date"),e.k0s())}function at(i,s){1&i&&(e.j41(0,"mat-error"),e.EFF(1,"Required"),e.k0s())}function rt(i,s){1&i&&(e.j41(0,"span"),e.EFF(1,", "),e.k0s())}function st(i,s){if(1&i&&(e.qex(0),e.DNE(1,rt,2,0,"span",20),e.EFF(2),e.bVm()),2&i){const t=s.$implicit,o=s.index;e.R7$(),e.Y8G("ngIf",o>0),e.R7$(),e.SpI("",t.name," ")}}function lt(i,s){if(1&i&&(e.j41(0,"p",44),e.EFF(1),e.nI1(2,"date"),e.k0s()),2&i){const t=e.XpG(2);e.R7$(),e.SpI("Due Date: ",e.bMT(2,1,t.calculateDueDate()),"")}}function ct(i,s){if(1&i&&(e.j41(0,"p",44),e.EFF(1),e.k0s()),2&i){const t=e.XpG(2);e.R7$(),e.SpI("Pay Type: ",t.rangeForm.get("payType").value,"")}}function pt(i,s){if(1&i&&(e.j41(0,"p",44),e.EFF(1),e.k0s()),2&i){const t=e.XpG(2);e.R7$(),e.SpI("Pay Term: ",t.rangeForm.get("payTerm").value,"")}}function mt(i,s){1&i&&(e.j41(0,"div",50),e.nrm(1,"mat-spinner"),e.k0s())}function dt(i,s){1&i&&(e.j41(0,"div",52)(1,"h2",53),e.EFF(2,"No Data"),e.k0s()())}function ut(i,s){if(1&i&&(e.j41(0,"div",69)(1,"h3",70),e.EFF(2,"Comments:"),e.k0s(),e.j41(3,"p",71),e.EFF(4),e.k0s()()),2&i){const t=e.XpG(4);e.R7$(4),e.JRh(t.rangeForm.get("comments").value)}}function gt(i,s){if(1&i){const t=e.RV6();e.j41(0,"div",81)(1,"input",82),e.mxI("ngModelChange",function(n){const a=e.eBV(t).$implicit;return e.DH7(a.title,n)||(a.title=n),e.Njj(n)}),e.k0s(),e.j41(2,"span",63)(3,"input",75),e.mxI("ngModelChange",function(n){const a=e.eBV(t).$implicit;
1return e.DH7(a.price,n)||(a.price=n),e.Njj(n)}),e.bIt("ngModelChange",function(){e.eBV(t);const n=e.XpG().$implicit,a=e.XpG(4);return e.Njj(a.onFinalPriceChange(n))}),e.k0s()(),e.j41(4,"mat-icon",83),e.bIt("click",function(){const n=e.eBV(t).index,a=e.XpG().index,r=e.XpG(4);return e.Njj(r.removeLine(a,n))}),e.EFF(5,"remove"),e.k0s()()}if(2&i){const t=s.$implicit;e.R7$(),e.R50("ngModel",t.title),e.R7$(2),e.R50("ngModel",t.price)}}function _t(i,s){if(1&i){const t=e.RV6();e.j41(0,"div",72)(1,"div",73)(2,"mat-checkbox",74),e.mxI("ngModelChange",function(n){const a=e.eBV(t).$implicit;return e.DH7(a.selected,n)||(a.selected=n),e.Njj(n)}),e.bIt("change",function(){e.eBV(t);const n=e.XpG(4);return e.Njj(n.onOrderSelectionChange())}),e.k0s(),e.j41(3,"span",59),e.EFF(4),e.k0s(),e.j41(5,"span",60),e.EFF(6),e.k0s(),e.j41(7,"span",61),e.EFF(8),e.nI1(9,"date"),e.k0s(),e.j41(10,"span",61),e.EFF(11),e.k0s(),e.j41(12,"span",62),e.EFF(13),e.k0s(),e.j41(14,"span",63)(15,"input",75),e.mxI("ngModelChange",function(n){const a=e.eBV(t).$implicit;return e.DH7(a.finalPrice,n)||(a.finalPrice=n),e.Njj(n)}),e.bIt("ngModelChange",function(){const n=e.eBV(t).$implicit,a=e.XpG(4);return e.Njj(a.onFinalPriceChange(n))}),e.k0s()(),e.j41(16,"button",76),e.bIt("click",function(){const n=e.eBV(t).$implicit,a=e.XpG(4);return e.Njj(a.resetToZonePrice(n))}),e.j41(17,"mat-icon"),e.EFF(18,"refresh"),e.k0s()()(),e.j41(19,"div",77)(20,"button",78),e.bIt("click",function(){const n=e.eBV(t).index,a=e.XpG(4);return e.Njj(a.addLineItem(n))}),e.EFF(21,"+ Add Line Item"),e.k0s(),e.j41(22,"div",79)(23,"span"),e.EFF(24),e.k0s(),e.j41(25,"span"),e.EFF(26),e.k0s(),e.j41(27,"span"),e.EFF(28),e.nI1(29,"currency"),e.k0s()()(),e.DNE(30,gt,6,2,"div",80),e.k0s()}if(2&i){const t=s.$implicit,o=s.index,n=e.XpG(4);e.R7$(2),e.R50("ngModel",t.selected),e.R7$(2),e.SpI("",o+1,"."),e.R7$(2),e.JRh(t.manifestNumber),e.R7$(2),e.JRh(e.i5U(9,11,t.isoDateDelivered,"medium")),e.R7$(3),e.JRh(n.dropOffInvoice?t.dispensaryBusinessAs?t.dispensaryBusinessAs:t.dispensaryName:t.manifestDestinationName),e.R7$(2),e.JRh(t.boxQuantity),e.R7$(2),e.R50("ngModel",t.finalPrice),e.R7$(9),e.SpI("From Zone: ",null==t.fromZone?null:t.fromZone.name,""),e.R7$(2),e.SpI("To Zone: ",null==t.toZone?null:t.toZone.name,""),e.R7$(2),e.SpI("Zone Price: ",e.i5U(29,14,t.zonePrice,"USD"),""),e.R7$(2),e.Y8G("ngForOf",t.lineItems)}}function ft(i,s){if(1&i){const t=e.RV6();e.j41(0,"div",54)(1,"div")(2,"h3",55),e.EFF(3),e.k0s(),e.j41(4,"h3",55),e.EFF(5),e.nI1(6,"currency"),e.k0s()(),e.j41(7,"div")(8,"h3",55),e.EFF(9),e.nI1(10,"currency"),e.k0s()()(),e.DNE(11,ut,5,1,"div",56),e.j41(12,"div",57)(13,"mat-checkbox",58),e.bIt("change",function(n){e.eBV(t);const a=e.XpG(3);return e.Njj(a.toggleAllOrders(n))}),e.k0s(),e.j41(14,"span",59),e.EFF(15,"#"),e.k0s(),e.j41(16,"span",60),e.EFF(17,"Manifest #"),e.k0s(),e.j41(18,"span",61),e.EFF(19,"Delivery Date"),e.k0s(),e.j41(20,"span",61),e.EFF(21),e.k0s(),e.j41(22,"span",62),e.EFF(23,"Boxes"),e.k0s(),e.j41(24,"span",63),e.EFF(25,"Price"),e.k0s(),e.j41(26,"span",64),e.EFF(27,"Reset"),e.k0s()(),e.j41(28,"div",65),e.DNE(29,_t,31,17,"div",66),e.k0s(),e.j41(30,"div",67)(31,"h3",68),e.EFF(32),e.nI1(33,"currency"),e.k0s()()}if(2&i){const t=e.XpG(3);e.R7$(3),e.SpI("Total Orders: ",null==t.orders?null:t.orders.length,""),e.R7$(2),e.SpI("Wholesale Amount: ",e.i5U(6,7,null==t.totals?null:t.totals.wholesaleAmount,"USD"),""),e.R7$(4),e.SpI("Transportation Fees: ",e.i5U(10,10,null==t.totals?null:t.totals.transportationFee,"USD"),""),e.R7$(2),e.Y8G("ngIf",null==t.rangeForm?null:t.rangeForm.get("comments").value),e.R7$(10),e.JRh(t.dropOffInvoice?"Pickup Location":"Delivery Location"),e.R7$(8),e.Y8G("ngForOf",t.orders),e.R7$(3),e.SpI("Total Selected Price: ",e.i5U(33,13,t.totalSelectedPrice,"USD"),"")}}function ht(i,s){if(1&i&&e.DNE(0,dt,3,0,"div",51)(1,ft,34,16,"ng-template",null,3,e.C5r),2&i){const t=e.sdS(2),o=e.XpG(2);e.Y8G("ngIf",!(null!=o.orders&&o.orders.length))("ngIfElse",t)}}function vt(i,s){if(1&i){const t=e.RV6();e.j41(0,"div",9)(1,"div",10)(2,"h2",11),e.EFF(3,"Report Generator"),e.k0s()(),e.j41(4,"div",12)(5,"div",13)(6,"form",14)(7,"mat-form-field",15)(8,"mat-label"),e.EFF(9,"Enter a date range"),e.k0s(),e.j41(10,"mat-date-range-input",16),e.nrm(11,"input",17)(12,"input",18),e.k0s(),e.nrm(13,"mat-datepicker-toggle",19)(14,"mat-date-range-picker",null,1),e.DNE(16,ot,2,0,"mat-error",20)(17,it,2,0,"mat-error",20),e.k0s(),e.j41(18,"div",21)(19,"app-location-select",22),e.bIt("selection",function(n){e.eBV(t);const a=e.XpG();return e.Njj(a.captureLocation(n))}),e.k0s()(),e.j41(20,"mat-form-field",15)(21,"mat-select",23)(22,"mat-option",24),e.EFF(23,"Terms"),e.k0s(),e.j41(24,"mat-option",25),e.EFF(25,"Cash"),e.k0s(),e.j41(26,"mat-option",26),e.EFF(27,"Check"),e.k0s(),e.j41(28,"mat-option",27),e.EFF(29,"Cashless ATM"),e.k0s(),e.j41(30,"mat-option",28),e.EFF(31,"ACH"),e.k0s()(),e.DNE(32,at,2,0,"mat-error",20),e.k0s(),e.j41(33,"mat-form-field",15)(34,"mat-select",29)(35,"mat-option",30),e.EFF(36,"Pay on Delivery"),e.k0s(),e.j41(37,"mat-option",31),e.EFF(38,"Net 7"),e.k0s(),e.j41(39,"mat-option",32),e.EFF(40,"Net 14"),e.k0s(),e.j41(41,"mat-option",33),e.EFF(42,"Net 30"),e.k0s(),e.j41(43,"mat-option",34),e.EFF(44,"Net 45"),e.k0s(),e.j41(45,"mat-option",35),e.EFF(46,"Net 60"),e.k0s()()(),e.j41(47,"mat-form-field",15),e.nrm(48,"textarea",36),e.k0s(),e.j41(49,"div",37)(50,"button",38),e.bIt("click",function(){e.eBV(t);const n=e.XpG();return e.Njj(n.generateReport())}),e.EFF(51,"Generate Report"),e.k0s(),e.j41(52,"button",39),e.bIt("click",function(){e.eBV(t);const n=e.XpG();return e.Njj(n.downloadReport())}),e.EFF(53,"Download Invoice"),e.k0s()()()(),e.j41(54,"div",40)(55,"div",41)(56,"div",42)(57,"div")(58,"h1",11),e.EFF(59,"Invoice for "),e.DNE(60,st,3,2,"ng-container",43),e.k0s(),e.j41(61,"p",44),e.EFF(62),e.nI1(63,"date"),e.nI1(64,"date"),e.k0s(),e.DNE(65,lt,3,3,"p",45)(66,ct,2,1,"p",45)(67,pt,2,1,"p",45),e.k0s(),e.j41(68,"div",46),e.nrm(69,"img",47),e.j41(70,"app-image-upload",48),e.bIt("uploadComplete",function(n){e.eBV(t);const a=e.XpG();return e.Njj(a.onUploadComplete(n))}),e.k0s(),e.j41(71,"h3"),e.EFF(72),e.k0s(),e.j41(73,"p"),e.EFF(74),e.k0s(),e.j41(75,"p"),e.EFF(76),e.k0s()()(),e.DNE(77,mt,2,0,"div",49)(78,ht,3,2,"ng-template",null,2,e.C5r),e.k0s()()()()}if(2&i){const t=e.sdS(15),o=e.sdS(79),n=e.XpG();e.R7$(6),e.Y8G("formGroup",n.rangeForm),e.R7$(4),e.Y8G("rangePicker",t),e.R7$(3),e.Y8G("for",t),e.R7$(3),e.Y8G("ngIf",n.rangeForm.get("start").hasError("matStartDateInvalid")),e.R7$(),e.Y8G("ngIf",n.rangeForm.get("end").hasError("matEndDateInvalid")),e.R7$(2),e.Y8G("currentCompany",n.currentCompany),e.R7$(13),e.Y8G("ngIf",n.rangeForm.get("payType").hasError("required")),e.R7$(18),e.Y8G("disabled",n.rangeForm.invali
1d),e.R7$(2),e.Y8G("disabled",!(null!=n.orders&&n.orders.length&&n.anyOrderSelected()&&null!=n.payeeLocation&&n.payeeLocation._id)),e.R7$(8),e.Y8G("ngForOf",n.dispensaries),e.R7$(2),e.Lme("",e.bMT(63,25,n.rangeForm.get("start").value)," - ",e.bMT(64,27,n.rangeForm.get("end").value),""),e.R7$(3),e.Y8G("ngIf",n.rangeForm.get("payTerm").value),e.R7$(),e.Y8G("ngIf",n.rangeForm.get("payType").value),e.R7$(),e.Y8G("ngIf",n.rangeForm.get("payTerm").value),e.R7$(2),e.Y8G("src",n.getLogoImg(),e.B4B),e.R7$(),e.Y8G("hideImage",!0),e.R7$(2),e.JRh(n.currentCompany.name),e.R7$(2),e.Lme("",n.currentCompany.address1," ",n.currentCompany.address2,""),e.R7$(2),e.E5c("",n.currentCompany.city,", ",n.currentCompany.state," ",n.currentCompany.zip,""),e.R7$(),e.Y8G("ngIf",n.loading)("ngIfElse",o)}}let yt=(()=>{class i{set dispensaries(t){this._dispensaries=t}set currentCompany(t){this._currentCompany=t,this.getZonePrices()}set dropOffInvoice(t){this._dropOffInvoice=t}constructor(t,o,n,a,r,c,p,d,k,x,T){this.formBuilder=t,this.companyService=o,this.orderService=n,this.accountService=a,this.zoneRateService=r,this.appLoader=c,this.snackBar=p,this.pdfGeneratorService=d,this.independentInvoiceService=k,this.companiesPublicService=x,this.companySettingsService=T,this.totalSelectedPrice=0,this.feeSettings=null,this.accountService.currentAccountInfo.subscribe(D=>{this.currentUser=D}),this.rangeForm=this.formBuilder.group({start:["",m.k0.required],end:["",m.k0.required],payTerm:["payOnDelivery",m.k0.required],payType:["terms",m.k0.required],comments:[""]})}ngOnInit(){}get currentCompany(){return this._currentCompany}get dispensaries(){return this._dispensaries}get dropOffInvoice(){return this._dropOffInvoice}toggleAllOrders(t){const o=t.checked;this.orders.forEach(n=>n.selected=o),this.calculateTotalSelectedPrice()}getZonePrices(){var t=this;return(0,g.A)(function*(){if(t.currentCompany?._id){const[{zones:o,zonePrices:n},a]=yield Promise.all([t.zoneRateService.load(t.currentCompany._id),t.companySettingsService.getFeeSettings(t.currentCompany._id)]);t.zones=o,t.zonePrices=n,t.feeSettings=a}})()}matchZonesAndPrices(){this.orders.forEach(t=>{const{fromZone:o,toZone:n,price:a}=(0,y.rq)(this.zones,this.zonePrices,t.origin?.context,t.destination?.place?.context);if(t.fromZone=o||null,t.toZone=n||null,t.zonePrice=a||0,t.finalPrice=this.defaultPriceFor(t),!t.lineItems?.length){const r=(0,y.bY)(t,this.feeSettings);r.length&&(t.lineItems=r)}}),this.calculateTotalSelectedPrice()}defaultPriceFor(t){return t.zonePrice||(0,y.DH)(t)||(0,y.rj)(t,this.feeSettings)||t.total}onOrderSelectionChange(){this.calculateTotalSelectedPrice()}calculateTotalSelectedPrice(){this.totalSelectedPrice=(0,y.LJ)(this.orders?.filter(t=>t.selected)||[])}onFinalPriceChange(t){this.calculateTotalSelectedPrice()}resetToZonePrice(t){t.finalPrice=this.defaultPriceFor(t),this.calculateTotalSelectedPrice()}anyOrderSelected(){return this.orders?.some(t=>t.selected)}generateReport(){var t=this;return(0,g.A)(function*(){if(t.rangeForm.valid){t.loading=!0;try{const o=t.rangeForm.getRawValue(),n=30;let a=[];if(t.dropOffInvoice){const r=t.dispensaries[0].queryMetrcLicenses;a=yield t.fetchOrdersInChunks(r,n,c=>t.orderService.getOrderRange(o.start.toISOString(),o.end.toISOString(),null,"delivered",c))}else{const r=t.dispensaries.reduce((c,p)=>[...c,p._id],[]);a=yield t.fetchOrdersInChunks(r,n,c=>t.orderService.getOrderRange(o.start.toISOString(),o.end.toISOString(),c,"delivered"))}t.orders=a,t.matchZonesAndPrices(),t.totals=a?.reduce((r,c)=>({wholesaleAmount:+(r.wholesaleAmount+(0,y.J9)(c)).toFixed(2),transportationFee:+(r.transportationFee+(0,y.DH)(c)).toFixed(2)}),{wholesaleAmount:0,transportationFee:0})}catch(o){S.c.catch("ZBI generrateReport",o)}t.loading=!1}})()}fetchOrdersInChunks(t,o,n){return(0,g.A)(function*(){let a=[];for(let r=0;r<t.length;r+=o){const c=t.slice(r,Math.min(r+o,t.length)),p=yield n(c);p&&p.length&&(a=[...a,...p])}return a})()}addLineItem(t){this.orders[t].lineItems?.length||(this.orders[t].lineItems=[]),this.orders[t].lineItems.push({title:"",price:0})}removeLine(t,o){this.orders[t].lineItems.splice(o,1)}downloadReport(){var t=this;return(0,g.A)(function*(){try{const o=t.orders.filter(r=>r.selected).map(r=>
1({...r,finalPrice:(0,y.oK)(r.finalPrice),...r.lineItems?.length?{lineItems:r.lineItems.map(c=>({...c,price:(0,y.oK)(c.price)}))}:{}})),n=t.rangeForm.get("comments").value||"",a=yield t.pdfGeneratorService.createInvoicePdf(o,t.dispensaries,t.rangeForm.get("start").value,t.rangeForm.get("end").value,t.dispensaries[0],t.currentCompany,n,{qrCode:null,uuid:null,invoiceNumber:null,dueDate:t.calculateDueDate().toLocaleDateString(),payType:t.rangeForm.get("payType").value||"",payTerm:t.rangeForm.get("payTerm").value||""},t.dropOffInvoice);if(o?.length){for(let p of o){const d={status:"billed",finalPrice:p.finalPrice};p.lineItems?.length>0&&(d.lineItems=p.lineItems),t.orderService.update(p._id,d)}const r=yield t.companiesPublicService.getData(t.dispensaries[0].company_id),c={dueDate:t.calculateDueDate(),company_id:t.currentCompany._id,payerLocation_id:t.dispensaries[0]._id,payerLocationAddress:t.dispensaries[0].location?.place_name,payerLocationName:t.dispensaries[0].name,payerCompanyName:r?.name||"",payerCompany_id:t.dispensaries[0].company_id,recipientEmail:t.dispensaries[0].email||"",payType:t.rangeForm.get("payType").value,payTerm:t.rangeForm.get("payTerm").value,isPaid:!1,paymentStatus:"unpaid",total:(0,y.LJ)(o),comments:n,zoneBasedInvoice:!0,startDate:t.rangeForm.get("start").value,endDate:t.rangeForm.get("end").value,order_ids:o.map(p=>p._id),payeeLocation_ids:t.payeeLocation._id,payeeLocationNames:t.payeeLocation.name,payeeLocationNamesCaseInsensitive:t.payeeLocation.nameCaseInsensitive,paymentUrl:a?.qrCode||"",paymentUuid:a?.uuid||"",invoiceNumber:a?.invoiceNumber,creationStatus:"success",dropOffInvoice:t.dropOffInvoice,logoBase64:t.currentCompany.logoBase64||""};yield t.independentInvoiceService.create(c),window.location.reload()}}catch(o){S.c.catch("[ZoneBaseInvoicesComponent] downloadReport",o),t.snackBar.open("string"==typeof o?o:"An error occurred while downloading pdf.","OK"),t.appLoader.close()}})()}captureLocation(t){this.payeeLocation=t}calculateDueDate(){const t=new Date;let o=new Date(t);switch(this.rangeForm.get("payTerm").value){case"payOnDelivery":break;case"net7":o.setDate(t.getDate()+7);break;case"net14":o.setDate(t.getDate()+14);break;case"net30":o.setDate(t.getDate()+30);break;case"net45":o.setDate(t.getDate()+45);break;case"net60":o.setDate(t.getDate()+60);break;default:console.error("Invalid payment term")}return o}onUploadComplete(t){var o=this;return(0,g.A)(function*(){console.log("File uploaded:",t),yield o.companyService.update(o.currentCompany._id,{logoFileName:t.fileName,logoFilePath:t.filePath,logoDownloadUrl:t.downloadUrl,logoBase64:t.base64}),o._currentCompany.logoFileName=t.fileName,o._currentCompany.logoFilePath=t.filePath,o._currentCompany.logoDownloadUrl=t.downloadUrl,o._currentCompany.logoBase64=t.base64})()}getLogoImg(){return this.currentCompany.logoDownloadUrl||Ke.O.logoPng}static{this.\u0275fac=function(o){return new(o||i)(e.rXU(m.ze),e.rXU(f.Bl),e.rXU(f.QE),e.rXU(f.Di),e.rXU(I.U5),e.rXU(I.Cl),e.rXU(O.UG),e.rXU(I.V6),e.rXU(G.W),e.rXU(f.gd),e.rXU(qe.W))}}static{this.\u0275cmp=e.VBU({type:i,selectors:[["app-zone-based-invoices"]],inputs:{dispensaries:"dispensaries",currentCompany:"currentCompany",dropOffInvoice:"dropOffInvoice"},standalone:!1,decls:4,vars:2,consts:[["showReports",""],["picker",""],["fullData",""],["showTotals",""],[1,"bg-white","dimebags-aggregate-reports"],["class","select-dispensaries flex flex-col items-center justify-center",4,"ngIf","ngIfElse"],[1,"select-dispensaries","flex","flex-col","items-center","justify-center"],["color","accent",1,"text-6xl"],[1,"text-2xl","font-semibold","mt-4"],[1,"bg-white","shadow-lg","rounded-lg","overflow-hidden"],[1,"border-b","border-primary","p-4"],[1,"text-2xl","font-bold"],[1,"flex"],[1,"w-1/5","border-r","border-primary","p-4"],[1,"max-w-xs",3,"formGroup"],[1,"w-full"],[3,"rangePicker"],["matStartDate","","formControlName","start","placeholder","Start date"],["matEndDate","","formControlName","end","placeholder","End date"],["matSuffix","",3,"for"],[4,"ngIf"],[1,"-mt-4","w-full","loc-select"],["type","my","placeholder","Select receiver location",3,"selection","currentCompany"],["formControlName","payType","placeholder","Payment Type"],["value","terms"],["value","cash"],["value","check"],["value","cashlessAtm"],["value","ach"],["formControlName","payTerm","placeholder","Payment Terms"],["value","payOnDelivery"],["value","net7"],["value","net14"],["value","net30"],["value","net45"],["value","net60"],["matInput","","formControlName","comments","cdkTextareaAutosize","","cdkAutosizeMinRows","3","placeholder","Add comments to the invoice..."],[1,"mt-4","space-y-2"],["mat-raised-button","","color","primary",1,"w-full",3,"click","disabled"],["mat-raised-button","","color","accent",1,"w-full",3,"click","disabled"],[1,"w-4/5","p-8"],[1,"max-w-4xl","mx-auto","bg-white","shadow-lg","p-8"],[1,"flex","justify-between","items-start","mb-6"],[4,"ngFor","ngForOf"],[1,"text-gray-600"],["class","text-gray-600",4,"ngIf"],[1,"w-1/2","flex","flex-col","items-end"],["alt","Logo",1,"w-24",3,"src"],[3,"uploadComplete","hideImage"],["class","flex justify-center items-center h-96",4,"ngIf","ngIfElse"],[1,"flex","justify-center","items-center","h-96"],["class","text-center py-8",4,"ngIf","ngIfElse"],[1,"text-center","py-8"],[1,"text-xl","font-semibold"],[1,"grid","grid-cols-2","gap-4","mb-6"],[1,"font-semibold"],["class","mb-6",4,"ngIf"],[1,"mb-4","flex","items-center","space-x-4","font-semibold"],[3,"change"],[1,"w-8"],[1,"w-32"],[1,"w-48"],[1,"w-16"],[1,"w-24"],[1,"w-12"],[1,"space-y-4"],["class","border-b border-gray-200 pb-2",4,"ngFor","ngForOf"],[1,"mt-4"],[1,"text-xl","font-bold"],[1,"mb-6"],[1,"font-semibold","mb-1"],[1,"text-sm","italic"],[1,"border-b","border-gray-200","pb-2"],[1,"flex","items-center","space-x-4"],[3,"ngModelChange","change","ngModel"],[1,"w-full","px-2","py-1","border","rounded",3,"ngModelChange","ngModel"],["mat-icon-button","","matTooltip","Re
1set to Zone Price",3,"click"],[1,"flex","justify-between"],["mat-button","","color","primary",3,"click"],[1,"flex","justify-end","space-x-4","text-sm","text-gray-600","mt-1"],["class","flex justify-between my-2 ml-4",4,"ngFor","ngForOf"],[1,"flex","justify-between","my-2","ml-4"],["matInput","","placeholder","Line description",1,"w-full","px-2","py-1","mr-4","border","rounded",3,"ngModelChange","ngModel"],["color","warn",3,"click"]],template:function(o,n){if(1&o&&(e.j41(0,"div",4),e.DNE(1,nt,5,0,"div",5)(2,vt,80,29,"ng-template",null,0,e.C5r),e.k0s()),2&o){const a=e.sdS(3);e.R7$(),e.Y8G("ngIf",!(null!=n.dispensaries&&n.dispensaries.length))("ngIfElse",a)}},dependencies:[_.Sq,_.bT,m.qT,m.me,m.BC,m.cb,m.vS,m.j4,m.JD,et.W,P.M,K.So,b.bU,b.el,b.xR,b.IG,b.SG,u.j,u.M,u.b,u.g,R.fg,z.xb,$.g,E.$z,q.M,N.An,w.LG,tt.e,M.R,_.oe,_.vh],styles:[".dimebags-aggregate-reports[_ngcontent-%COMP%]{height:75vh}.select-dispensaries[_ngcontent-%COMP%]{height:100%}.select-dispensaries[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:48px;height:48px;width:48px}mat-card-header[_ngcontent-%COMP%]{border-bottom:1px solid #162649}mat-card-content[_ngcontent-%COMP%]{display:flex;height:100%}.report-content[_ngcontent-%COMP%]{height:100%}.report-content.left[_ngcontent-%COMP%]{border-right:1px solid #162649;width:20%}.report-content.right[_ngcontent-%COMP%]{width:80%}.range-form[_ngcontent-%COMP%]{max-width:300px}.report-details[_ngcontent-%COMP%]{padding:1em;width:850px;min-height:1100px;margin:2em auto;box-shadow:2px 6px 8px #162649}.report-details[_ngcontent-%COMP%] .report-header[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:flex-start;width:100%}.report-details[_ngcontent-%COMP%] .report-header[_ngcontent-%COMP%] h1[_ngcontent-%COMP%]{margin-bottom:0}.report-details[_ngcontent-%COMP%] .report-header[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0}.report-details[_ngcontent-%COMP%] .report-header[_ngcontent-%COMP%] .logo-wrap[_ngcontent-%COMP%]{width:100px}.report-details[_ngcontent-%COMP%] .report-header[_ngcontent-%COMP%] .logo-wrap[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{width:100%;image-rendering:crisp-edges}.report-details[_ngcontent-%COMP%] .loading[_ngcontent-%COMP%]{max-height:900px;height:900px}.report-details[_ngcontent-%COMP%] .order-quick-info[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0}.report-details[_ngcontent-%COMP%] .order-line[_ngcontent-%COMP%]{padding:1em;border-bottom:1px solid rgba(22,38,73,.3);width:calc(100% - 2em);display:flex}.report-details[_ngcontent-%COMP%] .order-line[_ngcontent-%COMP%] .line-number[_ngcontent-%COMP%]{width:10%}.report-details[_ngcontent-%COMP%] .order-line[_ngcontent-%COMP%] .order-number[_ngcontent-%COMP%]{width:15%}.report-details[_ngcontent-%COMP%] .order-line[_ngcontent-%COMP%] .total[_ngcontent-%COMP%]{margin-left:auto}.report-details[_ngcontent-%COMP%] .order-price-info[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:flex-end}.action-buttons[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{width:160px}.action-buttons.download-action[_ngcontent-%COMP%]{margin-top:10px}"]})}}return i})();function It(i,s){1&i&&(e.j41(0,"mat-error"),e.EFF(1,"Must be viewing as a company to use this system"),e.k0s())}function Ct(i,s){1&i&&(e.j41(0,"mat-error"),e.EFF(1,"Drop off location must be a registered location in our system to find orders"),e.k0s())}function bt(i,s){if(1&i){const t=e.RV6();e.qex(0),e.j41(1,"button",17),e.bIt("click",function(){const n=e.eBV(t).index,a=e.XpG(2);return e.Njj(a.removeSelected(n))}),e.EFF(2),e.k0s(),e.bVm()}if(2&i){const t=s.$implicit;e.R7$(2),e.JRh(t.name)}}
1function Ft(i,s){if(1&i){const t=e.RV6();e.qex(0),e.j41(1,"app-location-select",11),e.bIt("selection",function(n){e.eBV(t);const a=e.XpG();return e.Njj(a.captureLocation(n))}),e.k0s(),e.j41(2,"div",12)(3,"mat-slide-toggle",13),e.bIt("toggleChange",function(){e.eBV(t);const n=e.XpG();return e.Njj(n.toggleDropOff())}),e.EFF(4,"Invoice Drop Off"),e.k0s(),e.DNE(5,Ct,2,0,"mat-error",9),e.k0s(),e.j41(6,"div",14),e.DNE(7,bt,3,1,"ng-container",15),e.k0s(),e.nrm(8,"app-zone-based-invoices",16),e.bVm()}if(2&i){const t=e.XpG();e.R7$(),e.Y8G("currentCompany",t.currentCompany)("clearAfterSelection",!0),e.R7$(4),e.Y8G("ngIf",t.isDropOffInvoice),e.R7$(2),e.Y8G("ngForOf",t.selectedDispensaries),e.R7$(),e.Y8G("currentCompany",t.currentCompany)("dispensaries",t.selectedDispensaries)("dropOffInvoice",t.isDropOffInvoice)}}function kt(i,s){if(1&i&&(e.j41(0,"div"),e.nrm(1,"mat-spinner",19),e.j41(2,"div",20)(3,"span"),e.EFF(4),e.k0s()()()),2&i){const t=e.XpG(2);e.R7$(4),e.JRh(t.downloadingStatus)}}function jt(i,s){if(1&i){const t=e.RV6();e.j41(0,"div")(1,"button",21),e.bIt("click",function(){e.eBV(t);const n=e.XpG(2);return e.Njj(n.downloadInvoices())}),e.j41(2,"mat-icon"),e.EFF(3,"cloud_download"),e.k0s()()()}}function St(i,s){if(1&i&&(e.j41(0,"div",18),e.DNE(1,kt,5,1,"div",9)(2,jt,4,0,"div",9),e.k0s()),2&i){const t=e.XpG();e.R7$(),e.Y8G("ngIf",t.downloading),e.R7$(),e.Y8G("ngIf",!t.downloading)}}const Tt=[{path:"",component:(()=>{class i{constructor(t,o,n){this.companyService=t,this.httpClientService=o,this.dialog=n,this._onDestroy=new F.B,this.reloadTable=new F.B,this.selectedDispensaries=[],this.isDropOffInvoice=!1,this.companyService.currentCompanyInfo.pipe((0,h.Q)(this._onDestroy)).subscribe(a=>{this.currentCompany=a})}ngOnInit(){}ngOnDestroy(){this._onDestroy.next(null),this._onDestroy.complete()}createInvoice(){this.dialog.open(Fe,{width:"800px",maxWidth:"100vw",disableClose:!0}).afterClosed().subscribe(o=>{o&&this.reloadTable.next(!0)})}selectionChanged(t){this.selectedInvoices=t}captureLocation(t){this.selectedDispensaries=[t]}removeSelected(t){this.selectedDispensaries.splice(t,1)}toggleDropOff(){this.isDropOffInvoice=!this.isDropOffInvoice}downloadInvoices(){var t=this;return(0,g.A)(function*(){t.downloading=!0;var r,n=new(l(73522)),a=t.selectedInvoices.length,c=0;for(r=0;r<t.selectedInvoices.length;r++)if(t.selectedInvoices[r]){var p=t.selectedInvoices[r].invoiceDownloadUrl;if(p){t.downloadingStatus=`${c+=1}/${a}`;const d=yield t.httpClientService.getFile(p,"application/pdf");yield n.file(`Invoice-${t.selectedInvoices[r]._id}.pdf`,d)}}t.downloadingStatus="Zipping",n.generateAsync({type:"blob"}).then(d=>{(0,U.saveAs)(d,`Invoices-${(new Date).getTime()}.zip`),t.downloading=!1}).catch(d=>{t.downloading=!1})})()}static{this.\u0275fac=function(o){return new(o||i)(e.rXU(f.Bl),e.rXU(Q.v),e.rXU(j.j))}}static{this.\u0275cmp=e.VBU({type:i,selectors:[["app-independent-invoices"]],standalone:!1,decls:16,vars:4,consts:[[1,"page-container"],["label","Invoices"],[1,"page-titlebar"],[1,"page-title"],[1,"page-actions"],["mat-raised-button","","color","primary","type","button",1,"mat-large",3,"click"],[1,"main-content"],[3,"selectionChanged","reloadTable"],["label","Zone Based Invoices"],[4,"ngIf"],["class","download",4,"ngIf"],["placeholder","Select Location",1,"w-24",3,"selection","currentCompany","clearAfterSelection"],[1,"ml-8","mb-8"],[3,"toggleChange"],[1,"select-dispensaries","flex-row"],[4,"ngFor","ngForOf"],[3,"currentCompany","dispensaries","dropOffInvoice"],["mat-raised-button","","color","primary",3,"click"],[1,"download"],["diameter","70"],[1,"downloading-status"],["mat-mini-fab","","color","primary",3,"click"]],template:function(o,n){1&o&&(e.j41(0,"div",0)(1,"mat-tab-group")(2,"mat-tab",1)(3,"div",2)(4,"div",3)(5,"h1"),e.EFF(6,"Invoices"),e.k0s()(),e.j41(7,"div",4)(8,"button",5),e.bIt("click",function(){return n.createInvoice()}),e.EFF(9,"Create an Invoice"),e.k0s()()(),e.j41(10,"div",6)(11,"app-independent-invoices-table",7),e.bIt("selectionChanged",function(r){return n.selectionChanged(r)}),e.k0s()()(),e.j41(12,"mat-tab",8),e.DNE(13,It,2,0,"mat-error",9)(14,Ft,9,7,"ng-container",9),e.k0s()(),e.DNE(15,St,3,2,"div",10),e.k0s()),2&o&&(e.R7$(11),e.Y8G("reloadTable",n.reloadTable),e.R7$(2),e.Y8G("ngIf",!(null!=n.currentCompany&&n.currentCompany._id)),e.R7$(),e.Y8G("ngIf",null==n.currentCompany?null:n.currentCompany._id),e.R7$(),e.Y8G("ngIf",n.selectedInvoices&&n.selectedInvoices.length>0))},dependencies:[_.Sq,_.bT,u.b,J.sG,H.mq,H.T8,E.$z,E.$0,N.An,w.LG,M.R,We,yt],styles:[".download[_ngcontent-%COMP%]{position:fixed;bottom:20px;right:20px}.downloading-status[_ngcontent-%COMP%]{position:absolute;inset:0;display:flex;align-items:center;justify-content:center}"]})}}return i})(),data:{title:"Invoices | Dimebags Portal"}}];let Dt=(()=>
1{class i{static{this.\u0275fac=function(o){return new(o||i)}}static{this.\u0275mod=e.$C({type:i})}static{this.\u0275inj=e.G2t({imports:[V.iI.forChild(Tt),V.iI]})}}return i})(),Et=(()=>{class i{static{this.\u0275fac=function(o){return new(o||i)}}static{this.\u0275mod=e.$C({type:i})}static{this.\u0275inj=e.G2t({imports:[_.MD,ee.G,te.e,Dt,M.R]})}}return i})()}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.