1import{a as ht,b as wt}from"./chunk-2VSYC23F.js";import{a as ft,c as It,d as St,e as gt,f as yt}from"./chunk-IASLIXVA.js";import{a as J}from"./chunk-CWXQMCJ7.js";import{a as Ee,c as xt}from"./chunk-RAUF2PAC.js";import{a as vt,b as Te,c as Ct}from"./chunk-KGBTUZLK.js";import"./chunk-YIKU2A2G.js";import{a as Fe,b as ut,c as S,d as X,e as Ve}from"./chunk-DB7NBNZQ.js";import{a as fe}from"./chunk-N3S5PJ6J.js";import"./chunk-3VU5BCPI.js";import"./chunk-JBU7WVCZ.js";import{a as he}from"./chunk-V65ZZVY2.js";import{b as Ie}from"./chunk-72FRQMR6.js";import"./chunk-FHFQTZXY.js";import"./chunk-WR54LXY5.js";import"./chunk-W77CIRIX.js";import{$b as nt,Ce as mt,Ec as at,Ed as ct,Gb as Ce,Gc as lt,Gd as ye,Hc as rt,Hd as we,Kb as xe,Mb as et,Td as st,Ue as _t,Wc as Se,Yb as tt,Zb as it,b as je,d as Ue,jb as Ze,k as ze,kd as ge,kh as pt,lc as ot,ve as be,xb as Xe,ye as dt}from"./chunk-CWIKEVUT.js";import{$ as ae,$a as m,Ad as Ae,Db as k,E as Ne,Fa as s,Fb as N,Gb as se,H as oe,Ib as e,Jb as Y,Ka as T,Kb as h,Lb as de,Ma as L,Na as le,Qb as P,Rb as A,Sa as y,Sb as F,Sc as $e,Th as G,U as g,Wc as We,Xa as Pe,_c as _e,ah as Je,bb as _,be as Qe,bg as Ge,cc as O,d as W,db as j,dc as B,di as ve,eb as U,fa as u,fb as z,ga as v,gb as p,hb as a,ib as l,ij as Ot,jb as C,lc as w,mc as E,me as qe,nb as K,nc as me,o as Me,ob as Z,pb as R,pj as H,qb as I,qc as Q,qh as Ke,sb as x,tb as d,u as $,ua as Le,vd as pe,wd as Ye,xb as Be,xd as ue,yb as re,yd as q,zb as ce,zg as He}from"./chunk-45UQS2YE.js";import{a as b,b as D,h as kt,j as Oe}from"./chunk-BMIYOSOG.js";var ee=kt(Ot());var zt=["form"],Yt=["itemForm"],Qt=()=>["../.."],qt=t=>({invoiceItemAssignID:t}),Gt=()=>[1,2,3];function Ht(t,r){if(t&1&&(e(0,` 2 `),C(1,"app-admin-header",8),e(2,` 3`)),t&2){let i=d();s(),p("pageTitle",i.invoice.invoiceID?i.invoice.shortDescription:"New Invoice")("showBackButton",!0)}}function Jt(t,r){if(t&1){let i=I();e(0,` 4 `),a(1,"app-pill",23),x("onIconClick",function(){u(i);let o=d(5);return v(o.removeRecipients())}),l(),e(2,` 5 `)}if(t&2){let i=d(5);s(),p("text",i.invoice.recipients[0].firstName?i.invoice.recipients[0].firstName+" "+(i.invoice.recipients[0].lastName||""):i.invoice.recipients[0].emailAddress)("iconClickable",!0)}}function Kt(t,r){if(t&1){let i=I();e(0,` 6 `),a(1,"app-pill",24),x("onIconClick",function(){u(i);let o=d(5);return v(o.removeRecipients())}),l(),e(2,` 7 `)}if(t&2){let i=d(5);s(),p("text",i.invoice.recipients.length+" recipients")("iconClickable",!0)}}function Zt(t,r){if(t&1&&(e(0,` 8 `),a(1,"div",22),e(2,` 9 `),m(3,Jt,3,2),m(4,Kt,3,2),l(),e(5,` 10 `)),t&2){let i=d(4);s(3),_(i.invoice.recipients.length===1?3:-1),s(),_(i.invoice.recipients.length>1?4:-1)}}function Xt(t,r){t&1&&(e(0,` 11 `),a(1,"div",25),e(2,` 12 Select who should receive this invoice 13 `),l(),e(3,` 14 `))}function ei(t,r){if(t&1){let i=I();e(0,` 15 `),a(1,"app-dynamic-form",9,0),e(3,` 16 `),a(4,"div",10),e(5,` 17 `),a(6,"label",11),e(7,` 18 `),a(8,"span"),e(9,` 19 `),a(10,"span",12),e(11,"*"),l(),e(12,` 20 `),a(13,"span",13),e(14,"required"),l(),e(15,` 21 `),l(),e(16,` 22 `),a(17,"span"),e(18,` 23 Recipient(s) 24 `),l(),e(19,` 25 `),l(),e(20,` 26 `),a(21,"div",14),e(22,` 27 `),a(23,"button",15),x("click",function(){u(i);let o=d(3);return o.loadSelectRecipients=!0,v(o.showSelectRecipients=!0)}),e(24,` 28 Select Recipient(s) 29 `),l(),e(25,` 30 `),m(26,Zt,6,2),l(),e(27,` 31 `),m(28,Xt,4,0),l(),e(29,` 32 `),C(30,"app-dynamic-form-field",16),e(31,` 33 `),C(32,"app-dynamic-form-field",17),e(33,` 34 `),C(34,"app-dynamic-form-field",18),e(35,` 35 `),a(36,"app-dynamic-form-field",19),x("onAddOption",function(){u(i);let o=d(3);return v(o.addInvoiceAddress())})("onChange",function(o){u(i);let c=d(3);return v(c.invoiceAddressChange(o))}),l(),e(37,` 36 `),a(38,"app-dynamic-form-field",20),x("onChange",function(o){u(i);let c=d(3);return v(c.dueDateOptionChange(o))}),l(),e(39,` 37 `),C(40,"app-dynamic-form-field",21),e(41,`
38 `),l(),e(42,` 39 `)}if(t&2){let i=d(3);s(),p("fields",i.invoiceFields)("entity",i.invoice)("horizontalForm",!0)("contentFieldsMode",!0)("showSaveAndAddButton",!1)("showSubmitButton",!1)("showCancelButton",!1)("enableSavingOverlay",!1),s(25),_(!(i.invoice==null||i.invoice.recipients==null)&&i.invoice.recipients.length?26:-1),s(2),_(i.showRecipientsError?28:-1)}}function ti(t,r){if(t&1){let i=I();e(0,` 40 `),a(1,"button",46),x("click",function(){u(i);let o=d(2).$index,c=d(4);return v(c.removeLine(o))}),e(2,` 41 `),C(3,"i",47),e(4,` 42 `),l(),e(5,` 43 `)}}function ii(t,r){if(t&1&&(e(0,` 44 `),a(1,"div",48),e(2,` 45 `),a(3,"div",49),e(4,` 46 `),a(5,"div",50),C(6,"i",51),e(7),l(),e(8,` 47 `),a(9,"div",30),e(10),w(11,"currency"),l(),e(12,` 48 `),C(13,"div",31),e(14,` 49 `),l(),e(15,` 50 `),l(),e(16,` 51 `)),t&2){let i=d(2).$implicit;s(7),Y(i.invoiceItem.clubSurcharge.surchargeName||"Surcharge"),s(3),h("~",E(11,2,i.projectedSurchargeAmount))}}function ni(t,r){if(t&1){let i=I();e(0,` 52 `),a(1,"app-dynamic-form",37,1),e(3,` 53 `),a(4,"div",38),e(5,` 54 `),a(6,"div",39),e(7,` 55 `),a(8,"app-dynamic-form-field",40),x("onAddOption",function(){u(i);let o=d().$index,c=d(4);return v(c.addInvoiceItem(o))})("onChange",function(o){u(i);let c=d().$index,f=d(4);return v(f.invoiceItemChange(c,o))}),e(9,` 56 `),l(),e(10,` 57 `),l(),e(11,` 58 `),a(12,"div",29),e(13,` 59 `),a(14,"app-dynamic-form-field",41),x("onChange",function(o){u(i);let c=d().$implicit,f=d(4);return v(f.itemQuantityChanged(o.target.value,c))}),e(15,` 60 `),l(),e(16,` 61 `),l(),e(17,` 62 `),a(18,"div",29),e(19,` 63 `),a(20,"app-dynamic-form-field",42),x("onChange",function(o){u(i);let c=d().$implicit,f=d(4);return v(f.itemPriceChanged(o.target.value,c))}),e(21,` 64 `),K(22,2,2),e(24,` 65 `),a(25,"a",43),w(26,"currency"),x("click",function(){u(i);let o=d(),c=o.$implicit,f=o.$index,V=d(4);return v(V.setItemAssignmentToDefaultPrice(f,c))}),e(27,` 66 `),a(28,"span",44),e(29,` 67 `),C(30,"i",45),e(31,` 68 `),l(),e(32,` 69 `),l(),e(33,` 70 `),Z(),e(34,` 71 `),l(),e(35,` 72 `),l(),e(36,` 73 `),a(37,"div",30),e(38),w(39,"currency"),l(),e(40,` 74 `),a(41,"div",31),e(42,` 75 `),m(43,ti,6,0),l(),e(44,` 76 `),m(45,ii,17,4),l(),e(46,` 77 `),l(),e(47,` 78 79 `)}if(t&2){let i=d(),n=i.$implicit,o=i.$index,c=d(4);s(),p("formID","item-form-"+o)("fields",c.invoiceItemFields[o])("entity",n)("contentFieldsMode",!0)("horizontalForm",!0)("showSubmitButton",!1)("showCancelButton",!1)("horizontalForm",!1)("enableSavingOverlay",!1)("formData",B(27,qt,n.invoiceItemAssignID)),s(7),p("formID","item-form-"+o)("hideLabel",!0)("enableFilter",!0),s(6),p("formID","item-form-"+o)("hideLabel",!0),s(6),p("formID","item-form-"+o)("hideLabel",!0),s(5),N("btn-disabled",c.loadingInvoiceItem[o]||!n.invoiceItemID),p("pTooltip","Click to set to default item price of "+E(26,23,(c.invoiceItems[n.invoiceItemID]==null?null:c.invoiceItems[n.invoiceItemID].defaultPrice)||0)),s(13),h(` 80 `,E(39,25,n.totalPrice||0),` 81 `),s(5),_((c.invoice.itemAssignments==null?null:c.invoice.itemAssignments.length)>1?43:-1),s(2),_((n.invoiceItem==null?null:n.invoiceItem.clubSurcharge)!=null&&(n==null?null:n.projectedSurchargeAmount)>0?45:-1)}}function oi(t,r){if(t&1&&(e(0,` 82 `),m(1,ni,48,29)),t&2){let i=r.$implicit;s(),_(i?1:-1)}}function ai(t,r){if(t&1&&(e(0),w(1,"currency")),t&2){let i=d(4);h(` 83 Total: ~`,E(1,1,i.itemsTotalProjectedPriceWithSurcharges||0),` 84 `)}}function li(t,r){if(t&1&&(e(0),w(1,"currency")),t&2){let i=d(4);h(` 85 Total: `,E(1,1,i.itemsTotalPrice||0),` 86 `)}}function ri(t,r){t&1&&(e(0,` 87 `),a(1,"div",49),e(2,` 88 `),a(3,"div",52),e(4,` 89 `),a(5,"p",53),e(6,"~ Estimated \u2014 surcharges are finalized when the invoice is paid."),l(),e(7,`
90 `),l(),e(8,` 91 `),l(),e(9,` 92 `))}function ci(t,r){if(t&1){let i=I();e(0,` 93 `),a(1,"div",26),e(2,` 94 `),C(3,"app-taxable-item-warning"),e(4,` 95 `),a(5,"div",27),e(6,` 96 `),a(7,"div",28),e(8,` 97 Invoice Item 98 `),l(),e(9,` 99 `),a(10,"div",29),e(11,` 100 Item Quantity 101 `),l(),e(12,` 102 `),a(13,"div",29),e(14,` 103 Item Price 104 `),l(),e(15,` 105 `),a(16,"div",30),e(17,` 106 Item Total 107 `),l(),e(18,` 108 `),C(19,"div",31),e(20,` 109 `),l(),e(21,` 110 `),U(22,oi,2,1,null,null,j),a(24,"div",32),e(25,` 111 `),a(26,"div",33),e(27,` 112 `),a(28,"button",34),x("click",function(){u(i);let o=d(3);return v(o.addLine())}),e(29,` 113 Add Line 114 `),l(),e(30,` 115 `),a(31,"button",35),x("click",function(){u(i);let o=d(3);return v(o.removeAllLines())}),e(32,` 116 Clear All Lines 117 `),l(),e(33,` 118 `),l(),e(34,` 119 `),a(35,"div",36),e(36,` 120 `),m(37,ai,2,3)(38,li,2,3),l(),e(39,` 121 `),l(),e(40,` 122 `),m(41,ri,10,0),l(),e(42,` 123 `)}if(t&2){let i=d(3);s(22),z(i.invoice.itemAssignments),s(15),_(i.projectedSurchargeTotal>0?37:38),s(4),_(i.projectedSurchargeTotal>0?41:-1)}}function si(t,r){if(t&1&&(e(0,` 124 `),m(1,ei,43,10),m(2,ci,43,2)),t&2){let i=d(2);s(),_(i.invoice&&i.invoiceFields?1:-1),s(),_(i.invoice&&i.invoiceItemFields?2:-1)}}function di(t,r){t&1&&(e(0,` 125 `),a(1,"div",54),e(2,` 126 `),a(3,"app-inline-alert",55),e(4,` 127 `),a(5,"span",56),e(6,` 128 This invoice is no longer editable 129 `),l(),e(7,` 130 `),l(),e(8,` 131 `),l(),e(9,` 132 `)),t&2&&(s(3),p("isInline",!0))}function mi(t,r){if(t&1&&(e(0,` 133 `),m(1,si,3,2),m(2,di,10,1)),t&2){let i=d();s(),_(i.canEdit?1:-1),s(),_(i.canEdit?-1:2)}}function _i(t,r){t&1&&(e(0,` 134 `),a(1,"div",60),e(2,` 135 `),C(3,"app-skeleton-template",61),e(4,` 136 `),l(),e(5,` 137 `))}function pi(t,r){t&1&&(e(0,` 138 `),a(1,"div",57),e(2,` 139 `),C(3,"app-skeleton-template",58),e(4,` 140 `),l(),e(5,` 141 `),a(6,"div",57),e(7,` 142 `),C(8,"app-skeleton-template",59),e(9,` 143 `),l(),e(10,` 144 `),U(11,_i,6,0,null,null,j)),t&2&&(s(11),z(O(0,Gt)))}function ui(t,r){if(t&1&&(e(0,` 145 `),C(1,"app-shared-invoice",62),e(2,` 146`)),t&2){let i=d();s(),p("invoice",i.invoice)}}function vi(t,r){if(t&1){let i=I();e(0,` 147 `),a(1,"button",63),x("click",function(){u(i);let o=d(2);return v(o.review())}),e(2,` 148 Review Invoice 149 `),l(),e(3,` 150 `)}if(t&2){let i=d(2);s(),p("disabled",i.loading||i.saving||i.loadingAddress)}}function Ci(t,r){t&1&&(e(0,` 151 `),C(1,"app-button-loader"),e(2,` 152 Sending... 153 `))}function xi(t,r){t&1&&e(0,` 154 Send Invoice 155 `)}function fi(t,r){t&1&&(e(0,` 156 `),C(1,"app-button-loader"),e(2,` 157 Saving... 158 `))}function hi(t,r){t&1&&e(0,` 159 Save as Draft 160 `)}function Ii(t,r){if(t&1){let i=I();e(0,` 161 `),a(1,"button",66),x("click",function(){u(i);let o=d(3);return v(o.save(!1))}),e(2,` 162 `),C(3,"i",67),e(4,` 163 `),m(5,fi,3,0),m(6,hi,1,0),l(),e(7,` 164 `)}if(t&2){let i=d(3);s(),p("disabled",i.loading||i.saving||i.savingAndSending),s(4),_(i.saving?5:-1),s(),_(i.saving?-1:6)}}function Si(t,r){if(t&1){let i=I();e(0,` 165 `),a(1,"button",64),x("click",function(){u(i);let o=d(2);return v(o.save(!0))}),e(2,` 166 `),m(3,Ci,3,0),m(4,xi,1,0),l(),e(5,` 167 `),m(6,Ii,8,3),a(7,"button",65),x("click",function(){u(i);let o=d(2);return v(o.onReviewStep=!1)}),e(8,` 168 Edit Invoice 169 `),l(),e(9,` 170 `)}if(t&2){let i=d(2);s(),p("disabled",i.loading||i.saving||i.savingAndSending),s(2),_(i.savingAndSending?3:-1),s(),_(i.savingAndSending?-1:4),s(2),_(i.invoice.invoiceStatusID===i.InvoiceStatus.DRAFT?6:-1),s(),p("disabled",i.loading||i.saving||i.savingAndSending)}}function gi(t,r){if(t&1&&(e(0,` 171 `),m(1,vi,4,1),m(2,Si,10,5)),t&2){let i=d();s(),_(i.onReviewStep?-1:1),s(),_(i.onReviewStep?2:-1)}}function yi(t,r){if(t&1){let i=I();e(0,` 172 `),a(1,"app-invoice-item-edit",68),x("onCancel",function(){u(i);let o=d();return v(o.addInvoiceItemCancel())})("onSave",function(o){u(i);let c=d();return v(c.invoiceItemAdded(o))}),l(),e(2,` 173 `)}t&2&&(s(),p("isModal",!0))}function wi(t,r){if(t&1){let i=I();e(0,` 174 `),a(1,"app-invoice-address-edit",69),x("cancel",function(){u(i);let o=d();return v(o.addInvoiceAddressCancel())})("save",function(o){u(i);let c=d();return v(c.invoiceAddressAdded(o))}),l(),e(2,` 175`)}}function bi(t,r){if(t&1){let i=I();e(0,` 176 `),a(1,"app-recipients",70),F("visibleChange",function(o){u(i);let c=d();return A(c.showSelectRecipients,o)||(c.showSelectRecipients=o),v(o)}),x("select",function(o){u(i);let c=d();return v(c.recipientsSelected(o))}),e(2,` 177 `),a(3,"div",71),e(4,` 178 `),a(5,"app-inline-alert",72),e(6,` 179 `),a(7,"span"),e(8,` 180 Please note: if an invoice should be sent on behalf of a player, select applicable players in player 181 search. The invoice will be sent to all parents/guardians, and the money will only be able to be 182 collected once. To invoice more than one parent/guardian in a household, select applicable users in user 183 search, and each person will get a separate invoice to pay.
184 `),l(),e(9,` 185 `),l(),e(10,` 186 `),l(),e(11,` 187 `),l(),e(12,` 188`)}if(t&2){let i=d();s(),P("visible",i.showSelectRecipients),p("includeClubsFilter",!1)("maxSelectionCount",100)("selection",i.selectedRecipients)("additionalRecipients",i.additionalRecipients)("showMaxRecipientCount",!0),s(4),p("isInline",!0)}}var Dt=(()=>{let r=class r{constructor(n,o,c,f){this.siteDataService=n,this.invoiceService=o,this.route=c,this.router=f,this.selectedRecipients=[],this.additionalRecipients="",this.invoiceItemFields=[],this.invoiceItems={},this.loadingInvoiceItem={},this.InvoiceStatus=S,this.loading=!0,this.onReviewStep=!1,this.saving=!1,this.savingAndSending=!1,this.haveItemAccess=!0,this.showAddItemModal=!1,this.showAddAddressModal=!1,this.loadingAddress=!1,this.addresses={},this.canEdit=!0,this.loadSelectRecipients=!1,this.showSelectRecipients=!1,this.showRecipientsError=!1,this.itemForms=new Le,this.unsubscribe$=new W}ngOnInit(){this.siteDataService.hideSiteLoader(),this.route.params.subscribe({next:n=>{n.id&&(n.id==="new"?$([this.invoiceService.getInvoiceMetadata(),this.invoiceService.getInvoiceItemAssignMetadata(),this.invoiceService.getInvoiceSettings(),this.invoiceService.getDefaultInvoiceAddress()]).pipe(g(this.unsubscribe$)).subscribe({next:o=>{this.invoiceFields=o[0].fields,this.defaultItemFields=o[1].fields,this.invoiceItemFields[0]=(0,ee.cloneDeep)(this.defaultItemFields),this.invoice=new ut(o[2].dueDateDefaultDays),this.invoice.invoiceAddressID=o[3].invoiceAddressID,this.addresses[this.invoice.invoiceAddressID]=o[3],this.loading=!1},error:()=>{this.siteDataService.showSiteErrorAlertDefaultGET()}}):(this.invoiceID=+n.id,$([this.invoiceService.getInvoiceMetadata(this.invoiceID),this.invoiceService.getInvoice(this.invoiceID),this.invoiceService.getInvoiceItemAssignMetadata()]).pipe(g(this.unsubscribe$)).subscribe({next:o=>{this.invoice=o[1],this.selectedRecipients=this.invoice.recipients.filter(c=>c.clubContactID||c.clubUserID||c.playerID),this.additionalRecipients=this.invoice.recipients.filter(c=>!c.clubContactID&&!c.clubUserID&&!c.playerID).map(c=>c.emailAddress).join(", "),this.invoice.invoiceStatusID===S.DRAFT&&!this.invoice.isOverdue?(this.invoiceFields=o[0].fields,this.defaultItemFields=o[2].fields,this.invoice.itemAssignments.forEach((c,f)=>{this.invoiceItems[c.invoiceItemID]=c.invoiceItem,this.invoiceItemFields[f]=(0,ee.cloneDeep)(this.defaultItemFields)})):this.canEdit=!1,this.loading=!1},error:()=>{this.siteDataService.showSiteErrorAlertDefaultGET()}})))}})}dueDateOptionChange(n){let o=this.invoiceFields.find(c=>c.controlName==="dueDate");n===Ve.SPECIFIC_DUE_DATE?(o.hidden=!1,tt(o)):(o.hidden=!0,it(o),this.invoice.dueDate=null,this.form.form.patchValue({dueDate:null})),this.invoiceFields=[...this.invoiceFields]}addLine(){this.invoiceItemFields.push((0,ee.cloneDeep)(this.defaultItemFields)),this.invoice.itemAssignments.push(new Fe)}itemQuantityChanged(n,o){o.itemQuantity=n?+n:0,this.setItemTotalPrice(o)}itemPriceChanged(n,o){let c=Je(n);o.itemPrice=c?+c:0,this.setItemTotalPrice(o)}setItemTotalPrice(n){n.totalPrice=this.getItemTotalPrice(n),n.projectedSurchargeAmount=this.getItemProjectedSurcharges(n),this.setItemsTotalPrice()}getItemTotalPrice(n){return(n.itemPrice||0)*(n.itemQuantity||0)}getItemProjectedSurcharges(n){let o=0;return n.invoiceItem?.clubSurcharge?.rate!=null&&(o=vt(n.totalPrice,n.invoiceItem.clubSurcharge.rate)),o}setItemsTotalPrice(){this.itemsTotalPrice=0,this.itemsTotalProjectedPriceWithSurcharges=0,this.projectedSurchargeTotal=0,this.invoice.itemAssignments.forEach(n=>{this.itemsTotalPrice+=n.totalPrice,this.itemsTotalProjectedPriceWithSurcharges+=n.totalPrice+n.projectedSurchargeAmount,this.projectedSurchargeTotal+=n.projectedSurchargeAmount})}removeLine(n){this.invoice.itemAssignments.splice(n,1),this.invoiceItemFields.splice(n,1),this.setItemsTotalPrice()}removeAllLines(){this.invoice.itemAssignments.splice(1),this.invoiceItemFields.splice(1),this.invoice.itemAssignments[0]=new Fe,this.setItemsTotalPrice()}setItemAssignmentToDefaultPrice(n,o){this.loadingInvoiceItem[n]||this.invoiceItemChange(n,o.invoiceItemID)}invoiceItemChange(n,o){o>
1880&&(this.invoiceItems[o]?(this.invoice.itemAssignments[n]=D(b({},this.invoice.itemAssignments[n]),{invoiceItem:this.invoiceItems[o]}),this.setItemAssignmentPrice(n,this.invoiceItems[o])):(this.loadingInvoiceItem[n]=!0,this.disableItemPriceField(n),this.invoiceService.getInvoiceItem(o).pipe(g(this.unsubscribe$)).subscribe({next:c=>{this.invoiceItems[o]=c,this.invoice.itemAssignments[n]=D(b({},this.invoice.itemAssignments[n]),{invoiceItem:c}),this.setItemAssignmentPrice(n,c),this.enableItemPriceField(n),this.loadingInvoiceItem[n]=!1},error:()=>{this.enableItemPriceField(n),this.loadingInvoiceItem[n]=!1}})))}addInvoiceItem(n){this.addItemIndex=n,this.showAddItemModal=!0}addInvoiceItemCancel(){this.showAddItemModal=!1;try{document.getElementById("item-form-"+this.addItemIndex+"-invoiceItemID").focus()}catch(n){}this.addItemIndex=void 0}invoiceItemAdded(n){this.invoiceItems[n.invoiceItemID]=n;let o={label:n.name,value:n.invoiceItemID};this.defaultItemFields.find(c=>c.controlName==="invoiceItemID").options.push(o),this.defaultItemFields.find(c=>c.controlName==="invoiceItemID").options.sort((c,f)=>c.isAddOption?-1e3:f.isAddOption?1e3:c.label.toLowerCase()<f.label.toLowerCase()?-1:1);for(let c=0;c<this.invoiceItemFields.length;c++)this.invoiceItemFields[c]=(0,ee.cloneDeep)(this.defaultItemFields);this.invoice.itemAssignments[this.addItemIndex]=D(b({},this.invoice.itemAssignments[this.addItemIndex]),{invoiceItemID:n.invoiceItemID,itemPrice:n.defaultPrice||0,invoiceItem:n}),this.setItemTotalPrice(this.invoice.itemAssignments[this.addItemIndex]),this.setItemsTotalPrice(),this.addInvoiceItemCancel()}addInvoiceAddress(){this.showAddAddressModal=!0}addInvoiceAddressCancel(){this.showAddAddressModal=!1;try{document.getElementById("item-form-"+this.addItemIndex+"-invoiceAddressID").focus()}catch(n){}}invoiceAddressAdded(n){this.addresses[n.invoiceAddressID]=n;let o={label:`${n.addressLine1}, ${n.addressLine2?n.addressLine2+", ":""} ${n.city}, ${n.state} ${n.zip}`,value:n.invoiceAddressID};this.invoiceFields.find(c=>c.controlName==="invoiceAddressID").options.push(o),this.invoiceFields.find(c=>c.controlName==="invoiceAddressID").options.sort((c,f)=>c.isAddOption?-1e3:f.isAddOption?1e3:c.value<f.value?-1:1),this.invoice=D(b(b({},this.invoice),this.form.validFieldsValue),{invoiceAddressID:n.invoiceAddressID}),this.showAddAddressModal=!1}invoiceAddressChange(n){n>0&&!this.addresses[n]&&(this.loadingAddress=!0,this.invoiceService.getInvoiceAddress(n).pipe(g(this.unsubscribe$)).subscribe({next:o=>{this.addresses[n]=o,this.loadingAddress=!1}}))}selectRecipientsClosed(){}recipientsSelected(n){this.invoice.recipients=n.recipients.concat(n.additionalRecipients),this.showSelectRecipients=!1,this.invoice.recipients?.length?this.showRecipientsError=!1:this.showRecipientsError=!0}removeRecipients(){this.selectedRecipients=[],this.additionalRecipients="",this.invoice.recipients=[],this.recipientComponent&&this.recipientComponent.clearSelection()}review(){this.showRecipientsError=!1,this.form.isValid?this.invoice.recipients?.length?this.itemForms.some(n=>!n.isValid)?this.itemForms.filter(n=>!n.isValid).forEach(n=>n.submitForm()):(this.invoice=D(b(b({},this.invoice),this.form.validFieldsValue),{itemAssignments:this.itemForms.map(n=>D(b({},n.validFieldsValue),{invoiceItemAssignID:n.formData.invoiceItemAssignID}))}),this.invoice.itemAssignments.forEach(n=>{n.invoiceItem=this.invoiceItems[n.invoiceItemID],n.totalPrice=this.getItemTotalPrice(n),n.projectedSurchargeAmount=this.getItemProjectedSurcharges(n)}),this.invoice.invoiceDueDateOptionID===Ve.DUE_UPON_RECEIPT&&(this.invoice.dueDate=null),this.invoice.invoiceAddressID&&(this.invoice.invoiceAddress=this.addresses[this.invoice.invoiceAddressID]),this.onReviewStep=!0):this.showRecipientsError=!0:this.form.submitForm()}save(n){n?this.savingAndSending=!0:this.saving=!0;let o=b({},this.invoice);o.invoiceStatusID=n?S.OPEN:S.DRAFT,this.invoiceService.saveInvoice(o).pipe(g(this.unsubscribe$)).subscribe({next:c=>{c&&(this.invoice.invoiceID=c.invoiceID),this.saving=!1,this.savingAndSending=!1,this.siteDataService.showSiteSuccessAlert(`Invoice ${n?"sent":"saved"} successfully`),this.invoice.invoiceID&&(this.invoice.recipients.length===1||!n)?this.router.navigate(["..",this.invoice.invoiceID,"view"],{relativeTo:this.route}):this.router.navigate([".."],{relativeTo:this.route})},error:()=>{this.siteDataService.showSiteErrorAlert("There was a problem saving this invoice"),this.saving=!1,this.savingAndSending=!1}})}ngOnDestroy(){this.unsubscribe$.next(),this.unsubscribe$.complete()}disableItemPriceField(n){this.invoiceItemFields[n].find(o=>o.controlName==="itemPrice").disabled=!0,this.invoiceItemFields[n]=[...this.invoiceItemFields[n]]}enableItemPriceField(n){this.invoiceItemFields[n].find(o=>o.controlName==="itemPrice").disabled=!1,this.invoiceItemFields[n]=[...this.invoiceItemFields[n]]}setItemAssignmentPrice(n,o){this.invoice.itemAssignments[n]=D(b(b({},this.invoice.itemAssignments[n]),this.itemForms.find(c=>c.formID==="item-form-"+n).validFieldsValue),{itemPrice:o?.defaultPrice||0}),this.setItemTotalPrice(this.invoice.itemAssignments[n]),this.setItemsTotalPrice()}};r.\u0275fac=function(o){return new(o||r)(T(H),T(J),T(pe),T(ue))},r.\u0275cmp=L({type:r,selectors:[["ng-component"]],viewQuery:function(o,c){if(o&1&&Be(zt,5)(Ee,5)(Yt,5),o&2){let f;re(f=ce())&&(c.form=f.first),re(f=ce())&&(c.recipientComponent=f.first),re(f=ce())&&(c.itemForms=f)}},standalone:!1,decls:23,vars:16,consts:[["form",""],["itemForm",""],["inputGroupEnd",""],[3,"hidden"],["appStickyFormButtons","",1,"row","form-action","no-gutters","d-flex","align-items-center"],[1,"col-md-12","d-flex","justify-content-start"],["type","button",1,"btn","btn-lg","btn-naked",3,"click","routerLink"],["header","Add Invoice Item","styleClass","standardWidthDialog",3,"visibleChange","visible","modal","closable","draggable"],["parentLinkText","Invoices","parentLinkUrl","..",3,"pageTitle","showBackButton"],[3,"fields","entity","horizontalForm","contentFieldsMode","showSaveAndAddButton","showSubmitButton","showCancelButton","enableSavingOverlay"],[1,"form-group"],["for",""],["aria-hidden","true",1,"required-asterisk"],[1,"sr-only"],[1,"d-flex","align-items-center"],["type","button",1,"btn","btn-icon-plus",3,"click"],["fieldName","invoiceDate"],["fieldName","shortDe
188scription"],["fieldName","description"],["fieldName","invoiceAddressID",3,"onAddOption","onChange"],["fieldName","invoiceDueDateOptionID",3,"onChange"],["fieldName","dueDate"],[1,"ml-3"],["status","success","styleClass","pill-success-lt","icon","fa fa-times","iconAriaLabel","Remove recipient",3,"onIconClick","text","iconClickable"],["status","success","styleClass","pill-success-lt","icon","fa fa-times","iconAriaLabel","Remove all recipients",3,"onIconClick","text","iconClickable"],[1,"form-error-message"],[1,"mt-5","p-3","no-gutters","items-section","bg-primary"],[1,"row","fw-800","mb-3"],[1,"col-md-4"],[1,"col-md-3"],[1,"col-md-1","d-flex","justify-content-end"],[1,"col-md-1"],[1,"row","d-flex","align-items-center"],[1,"col-md-8"],["type","button",1,"btn","btn-naked","btn-icon-plus",3,"click"],["type","button",1,"btn","btn-naked","btn-icon-fal-trash-alt",3,"click"],[1,"col-md-3","d-flex","justify-content-end","fw-800"],[3,"formID","fields","entity","contentFieldsMode","horizontalForm","showSubmitButton","showCancelButton","enableSavingOverlay","formData"],[1,"row","item-row","mb-3","pb-3","d-flex","align-items-center","border-bottom"],[1,"col-md-4","no-wrap"],["fieldName","invoiceItemID","styleClass","mb-0",3,"onAddOption","onChange","formID","hideLabel","enableFilter"],["fieldName","itemQuantity","styleClass","mb-0",3,"onChange","formID","hideLabel"],["fieldName","itemPrice","styleClass","mb-0",3,"onChange","formID","hideLabel"],["href","javascript:void(0);",1,"mx-2",3,"click","pTooltip"],[1,"text-medium"],[1,"fa","fa-arrows-rotate"],["type","button",1,"btn","btn-tertiary","pull-right",3,"click"],[1,"fa","fal","fa-trash-alt"],[1,"col-12","surcharge-subrow-edit","text-grey-lt","text-medium","mt-2"],[1,"row"],[1,"col-md-10","surcharge-name-edit"],[1,"far","fa-arrow-turn-down-right","ml-3","mr-1"],[1,"col-md-11","d-flex","justify-content-end"],[1,"text-muted","mt-1","mb-0"],[1,"mt-4"],["alertType","error",3,"isInline"],[1,"fw-800"],[1,"mb-5"],["height","4rem"],["skeletonType","form-no-buttons"],[1,"mb-2"],["height","2rem"],[3,"invoice"],["type","button",1,"btn","btn-lg","btn-primary",3,"click","disabled"],["type","button",1,"btn","btn-lg","btn-primary","btn-icon-e
188nvelope",3,"click","disabled"],["type","button",1,"btn","btn-lg","btn-icon-pencil",3,"click","disabled"],["type","button",1,"btn","btn-lg",3,"click","disabled"],[1,"fa","fa-floppy-disk","mr-1"],[3,"onCancel","onSave","isModal"],[3,"cancel","save"],[3,"visibleChange","select","visible","includeClubsFilter","maxSelectionCount","selection","additionalRecipients","showMaxRecipientCount"],[1,"mb-3"],["alertType","info",3,"isInline"]],template:function(o,c){o&1&&(m(0,Ht,3,2),a(1,"div",3),e(2,` 189 `),m(3,mi,3,2)(4,pi,13,1),l(),e(5,` 190 191`),m(6,ui,3,1),a(7,"div",4),e(8,` 192 `),a(9,"div",5),e(10,` 193 `),m(11,gi,3,2),a(12,"a",6),x("click",function(V){return c.loading||c.saving?V.preventDefault():""}),e(13,` 194 Cancel 195 `),l(),e(14,` 196 `),l(),e(15,` 197`),l(),e(16,` 198 199`),a(17,"p-dialog",7),F("visibleChange",function(V){return A(c.showAddItemModal,V)||(c.showAddItemModal=V),V}),e(18,` 200 `),m(19,yi,3,1),l(),e(20,` 201 202`),m(21,wi,3,0),m(22,bi,13,7)),o&2&&(_(c.invoice?0:-1),s(),p("hidden",c.onReviewStep),s(2),_(c.loading?4:3),s(3),_(c.onReviewStep?6:-1),s(5),_(c.canEdit?11:-1),s(),N("btn-disabled",c.loading||c.saving),p("routerLink",O(15,Qt)),s(5),P("visible",c.showAddItemModal),p("modal",!0)("closable",!1)("draggable",!1),s(2),_(c.showAddItemModal?19:-1),s(2),_(c.showAddAddressModal?21:-1),s(),_(c.loadSelectRecipients?22:-1))},dependencies:[we,ge,q,xe,Se,et,be,ye,ct,Ce,Ze,Te,ht,ft,It,Ee,_e],styles:[".item-row .form-group .form-dropdown{display:inline-block;width:100%;max-width:100%} .item-row .form-group .p-inputgroup{width:90%;max-width:90%;display:inline-flex}"]});let t=r;return t})();var ie=class{constructor(r=void 0){this.page=1,this.rows=100,this.testUserOption=1,this.orderBy=r}};var ke=()=>({width:"100%"}),Ei=t=>["./",t,"view"],Di=t=>["/admin/players",t,"overview"],Pt=t=>["/admin/users",t,"profile"],Pi=t=>["/admin/users/club-contacts",t];function Ai(t,r){if(t&1&&(e(0,` 203 `),a(1,"span"),e(2),l(),e(3,` 204 `)),t&2){let i=r.$implicit;s(2),Y(i.label)}}function Fi(t,r){if(t&1){let i=I();e(0,` 205 `),a(1,"app-admin-filter",6),x("adminFilterReset",function(){u(i);let o=d();return v(o.resetFilters())})("adminFilterSearch",function(){u(i);let o=d();return v(o.run())}),e(2,` 206 `),K(3,7),e(4,` 207 `),a(5,"div",8),e(6,` 208 `),a(7,"span",9),e(8,` 209 `),C(9,"i",10),e(10,` 210 `),a(11,"input",11),F("ngModelChange",function(o){u(i);let c=d();return A(c.invoiceService.filters.searchTerm,o)||(c.invoiceService.filters.searchTerm=o),v(o)}),l(),e(12,` 211 `),C(13,"label",12),e(14,` 212 `),l(),e(15,` 213 `),l(),e(16,` 214 `),Z(),e(17,` 215 `),K(18,13),e(19,` 216 `),a(20,"div",14),e(21,` 217 `),a(22,"div",15),e(23,` 218 `),a(24,"div",16),e(25,` 219 `),a(26,"label",17),e(27,"Status"),l(),e(28,` 220 `),a(29,"p-multiSelect",18),F("ngModelChange",function(o){u(i);let c=d();return A(c.invoiceService.filters.invoiceStatusID,o)||(c.invoiceService.filters.invoiceStatusID=o),v(o)}),e(30,` 221 `),l(),e(31,` 222 `),l(),e(32,` 223 `),l(),e(33,` 224 `),a(34,"div",15),e(35,` 225 `),a(36,"div",16),e(37,` 226 `),a(38,"label",19),e(39,"Invoice Item"),l(),e(40,` 227 `),a(41,"p-multiSelect",20),F("ngModelChange",function(o){u(i);let c=d();return A(c.invoiceService.filters.invoiceItemID,o)||(c.invoiceService.filters.invoiceItemID=o),v(o)}),e(42,` 228 `),l(),e(43,` 229 `),l(),e(44,` 230 `),l(),e(45,` 231 `),a(46,"div",15),e(47,` 232 `),a(48,"div",16),e(49,` 233 `),a(50,"label",21),e(51,"Revenue Category"),l(),e(52,` 234 `),a(53,"p-multiSelect",22),F("ngModelChange",function(o){u(i);let c=d();return A(c.invoiceService.filters.invoiceRevenueCategoryID,o)||(c.invoiceService.filters.invoiceRevenueCategoryID=o),v(o)}),e(54,` 235 `),y(55,Ai,4,1,"ng-template",23),e(56,` 236 `),l(),e(57,` 237 `),l(),e(58,` 238 `),l(),e(59,` 239 `),a(60,"div",15),e(61,` 240 `),a(62,"div",16),e(63,` 241 `),a(64,"label",24),e(65,"Test Users/Players"),l(),e(66,` 242 `),a(67,"p-select",25),F("ngModelChange",function(o){u(i);let c=d();return A(c.invoiceService.filters.testUserOption,o)||(c.invoiceService.filters.testUserOption=o),v(o)}),e(68,`
243 `),l(),e(69,` 244 `),l(),e(70,` 245 `),l(),e(71,` 246 `),l(),e(72,` 247 `),Z(),e(73,` 248 `),l(),e(74,` 249 `)}if(t&2){let i=d();s(),p("showAdvanced",!0),s(10),P("ngModel",i.invoiceService.filters.searchTerm),s(18),se(O(17,ke)),p("options",i.statuses),P("ngModel",i.invoiceService.filters.invoiceStatusID),s(12),se(O(18,ke)),p("options",i.items),P("ngModel",i.invoiceService.filters.invoiceItemID),s(12),se(O(19,ke)),p("options",i.categories)("group",!0),P("ngModel",i.invoiceService.filters.invoiceRevenueCategoryID),s(14),P("ngModel",i.invoiceService.filters.testUserOption),p("options",i.testUserOptions)}}function Vi(t,r){if(t&1&&(e(0,` 250 `),C(1,"p-sortIcon",31),e(2,` 251 `)),t&2){let i=d().$implicit;s(),p("field",i.field)}}function Ri(t,r){if(t&1&&(e(0,` 252 `),a(1,"th",30),e(2),m(3,Vi,3,1),l(),e(4,` 253 `)),t&2){let i=r.$implicit,n=d(3);s(),p("pSortableColumn",i.field),Pe("aria-label",n.AriaLabels.ACTIVATE_SORT),s(),h(` 254 `,i.header,` 255 `),s(),_(i.field?3:-1)}}function ki(t,r){if(t&1&&(e(0,` 256 `),a(1,"tr"),e(2,` 257 `),U(3,Ri,5,4,null,null,j),l(),e(5,` 258 `)),t&2){let i=d(2);s(3),z(i.columns)}}function Oi(t,r){if(t&1&&e(0),t&2){let i=d(2).$implicit;h(` 259 `,i.recipients.length,` recipients 260 `)}}function Mi(t,r){t&1&&R(0)}function Ni(t,r){if(t&1&&(e(0,` 261 `),a(1,"a",32),e(2,` 262 `),y(3,Mi,1,0,"ng-container",34),e(4,` 263 `),l(),e(5,` 264 `)),t&2){d(2);let i=k(7),n=d(2).$implicit;s(),p("routerLink",B(2,Di,n.recipients[0].playerID)),s(2),p("ngTemplateOutlet",i)}}function Li(t,r){t&1&&R(0)}function Bi(t,r){if(t&1&&(e(0,` 265 `),y(1,Li,1,0,"ng-container",34),e(2,` 266 `)),t&2){d(2);let i=k(7);s(),p("ngTemplateOutlet",i)}}function $i(t,r){t&1&&R(0)}function Wi(t,r){if(t&1&&(e(0,` 267 `),y(1,$i,1,0,"ng-container",34),e(2,` 268 `)),t&2){d(2);let i=k(6);s(),p("ngTemplateOutlet",i)}}function ji(t,r){if(t&1&&(e(0,` 269 `),a(1,"a",32),e(2,` 270 `),m(3,Wi,3,1),l(),e(4,` 271 `)),t&2){let i=d().$implicit;s(),p("routerLink",B(2,Pt,i.clubUserID)),s(2),_(i.firstName?3:-1)}}function Ui(t,r){t&1&&R(0)}function zi(t,r){if(t&1&&(e(0,` 272 `),y(1,Ui,1,0,"ng-container",34),e(2,` 273 `)),t&2){d();let i=k(6);s(),p("ngTemplateOutlet",i)}}function Yi(t,r){if(t&1&&e(0),t&2){let i=d().$implicit;de(` 274 `,i.lastName,", ",i.firstName,` 275 `)}}function Qi(t,r){if(t&1&&(e(0,` 276 `),a(1,"span",38),e(2),l(),e(3,` 277 `)),t&2){let i=d().$implicit;s(2),h(` 278 (`,i.emailAddress,`) 279 `)}}function qi(t,r){t&1&&(e(0,` 280 `),a(1,"span"),e(2,";"),l(),e(3,` 281 `))}function Gi(t,r){if(t&1&&(e(0,` 282 `),a(1,"span",37),e(2,` 283 `),m(3,ji,5,4)(4,zi,3,1),y(5,Yi,1,2,"ng-template",null,1,Q),e(7,` 284 `),m(8,Qi,4,1),m(9,qi,4,0),l(),e(10,` 285 `)),t&2){let i=r.$implicit,n=r.$index,o=r.$count,c=d(7);s(3),_(c.user&&c.user[c.Permission.UserAdmin]?3:4),s(5),_(i.emailAddress?8:-1),s(),_(n!==o-1?9:-1)}}function Hi(t,r){if(t&1&&(e(0,` 286 `),a(1,"div",35),e(2,` 287 `),a(3,"div",36),e(4,` 288 Parents: 289 `),l(),e(5,` 290 `),a(6,"div",4),e(7,` 291 `),U(8,Gi,11,3,null,null,j),l(),e(10,` 292 `),l(),e(11,` 293 `)),t&2){let i=d(4).$implicit;s(8),z(i.recipients[0].recipients)}}function Ji(t,r){if(t&1&&(e(0,` 294 `),a(1,"div",14),e(2,` 295 `),a(3,"div",33),e(4,` 296 `),m(5,Ni,6,4)(6,Bi,3,1),l(),e(7,`
297 `),l(),e(8,` 298 `),m(9,Hi,12,0)),t&2){let i=d(3).$implicit,n=d(2);s(5),_(n.user&&n.user[n.Permission.PlayerAdmin]?5:6),s(4),_(i.recipients[0].recipients!=null&&i.recipients[0].recipients.length?9:-1)}}function Ki(t,r){t&1&&R(0)}function Zi(t,r){if(t&1&&(e(0,` 299 `),y(1,Ki,1,0,"ng-container",34),e(2,` 300 `)),t&2){d(3);let i=k(7);s(),p("ngTemplateOutlet",i)}}function Xi(t,r){if(t&1&&(e(0,` 301 `),a(1,"a",32),e(2,` 302 `),m(3,Zi,3,1),l(),e(4,` 303 `)),t&2){let i=d(4).$implicit;s(),p("routerLink",B(2,Pt,i.recipients[0].clubUserID)),s(2),_(i.recipients[0].firstName?3:-1)}}function en(t,r){t&1&&R(0)}function tn(t,r){if(t&1&&(e(0,` 304 `),y(1,en,1,0,"ng-container",34),e(2,` 305 `)),t&2){d(2);let i=k(7);s(),p("ngTemplateOutlet",i)}}function nn(t,r){if(t&1&&(e(0,` 306 `),m(1,Xi,5,4)(2,tn,3,1),a(3,"span",38),e(4),l(),e(5,` 307 `)),t&2){let i=d(3).$implicit,n=d(2);s(),_(n.user&&n.user[n.Permission.UserAdmin]?1:2),s(3),h(` 308 (`,i.recipients[0].emailAddress,`) 309 `)}}function on(t,r){t&1&&R(0)}function an(t,r){if(t&1&&(e(0,` 310 `),y(1,on,1,0,"ng-container",34),e(2,` 311 `)),t&2){d(3);let i=k(7);s(),p("ngTemplateOutlet",i)}}function ln(t,r){if(t&1&&e(0),t&2){let i=d(5).$implicit;h(` 312 (`,i.recipients[0].emailAddress,`) 313 `)}}function rn(t,r){if(t&1&&e(0),t&2){let i=d(5).$implicit;h(` 314 `,i.recipients[0].emailAddress,` 315 `)}}function cn(t,r){if(t&1&&(e(0,` 316 `),a(1,"a",32),e(2,` 317 `),m(3,an,3,1),a(4,"span"),e(5,` 318 `),m(6,ln,1,1),m(7,rn,1,1),l(),e(8,` 319 `),l(),e(9,` 320 `)),t&2){let i=d(4).$implicit;s(),p("routerLink",B(6,Pi,i.recipients[0].clubContactFamilyID)),s(2),_(i.recipients[0].lastName&&i.recipients[0].firstName?3:-1),s(),N("ml-1",i.recipients[0].lastName&&i.recipients[0].firstName),s(2),_(i.recipients[0].lastName&&i.recipients[0].firstName?6:-1),s(),_(!i.recipients[0].lastName||!i.recipients[0].firstName?7:-1)}}function sn(t,r){t&1&&R(0)}function dn(t,r){if(t&1&&(e(0,` 321 `),y(1,sn,1,0,"ng-container",34),e(2,` 322 `)),t&2){d(2);let i=k(7);s(),p("ngTemplateOutlet",i)}}function mn(t,r){t&1&&R(0)}function _n(t,r){if(t&1&&(e(0,` 323 `),y(1,mn,1,0,"ng-container",34),e(2,` 324 `)),t&2){d(3);let i=k(7);s(),p("ngTemplateOutlet",i)}}function pn(t,r){if(t&1&&e(0),t&2){let i=d(5).$implicit;h(` 325 (`,i.recipients[0].emailAddress,`) 326 `)}}function un(t,r){if(t&1&&e(0),t&2){let i=d(5).$implicit;h(` 327 `,i.recipients[0].emailAddress,` 328 `)}}function vn(t,r){if(t&1&&(e(0,` 329 `),m(1,_n,3,1),a(2,"span"),e(3,` 330 `),m(4,pn,1,1),m(5,un,1,1),l(),e(6,` 331 `)),t&2){let i=d(4).$implicit;s(),_(i.recipients[0].lastName&&i.recipients[0].firstName?1:-1),s(),N("ml-1",i.recipients[0].lastName&&i.recipients[0].firstName),s(2),_(i.recipients[0].lastName&&i.recipients[0].firstName?4:-1),s(),_(!i.recipients[0].lastName||!i.recipients[0].firstName?5:-1)}}function Cn(t,r){if(t&1&&(e(0,` 332 `),m(1,cn,10,8)(2,dn,3,1),y(3,vn,7,5,"ng-template",null,2,Q),e(5,` 333 `)),t&2){let i=d(5);s(),_(i.user&&i.user[i.Permission.ClubContacts]?1:2)}}function xn(t,r){if(t&1&&e(0),t&2){let i=d(3).$implicit;h(` 334 `,i.recipients[0].emailAddress,` 335 `)}}function fn(t,r){if(t&1&&(e(0,` 336 `),a(1,"span"),e(2),l(),e(3,` 337 `)),t&2){let i=d(3).$implicit;s(2),de(` 338 `,i.recipients[0].lastName,", ",i.recipients[0].firstName,` 339 `)}}function hn(t,r){if(t&1&&(e(0,` 340 `),m(1,Ji,10,2)(2,nn,6,2)(3,Cn,6,1)(4,xn,1,1),e(5,` 341 `),y(6,fn,4,2,"ng-template",null,0,Q),e(8,` 342 `)),t&2){let i,n=d(2).$implicit,o=d(2);s(),_((i=n.recipients[0].recipientType)===o.RecipientType.PLAYER?1:i===o.RecipientType.CLUB_USER?2:i===o.RecipientType.CLUB_CONTACT?3:i===o.RecipientType.ANONYMOUS_USER?4:-1)}}function In(t,r){if(t&1&&(e(0,` 343 `),m(1,Oi,1,1)(2,hn,9,1)),t&2){let i=d().$implicit;s(),_(i.recipients.length>1?1:2)}}function Sn(t,r){if(t&1&&(e(0),w(1,"date")),t&2){let i=d().$implicit;h(`
344 `,me(1,1,i.invoiceDate,"MM/dd/yyyy"),` 345 `)}}function gn(t,r){if(t&1&&(e(0),w(1,"date")),t&2){let i=d().$implicit;h(` 346 `,me(1,1,i.sentDate,"MM/dd/yyyy"),` 347 `)}}function yn(t,r){t&1&&e(0,` 348 Yet to be Issued 349 `)}function wn(t,r){if(t&1&&(e(0),w(1,"date")),t&2){let i=d().$implicit;h(` 350 `,me(1,1,i.dueDate,"MM/dd/yyyy"),` 351 `)}}function bn(t,r){if(t&1&&e(0),t&2){let i=d().$implicit;h(` 352 `,i.invoiceDueDateOption.description,` 353 `)}}function Tn(t,r){if(t&1&&(e(0,` 354 `),C(1,"app-pill",39),e(2,` 355 `)),t&2){let i=d(2).$implicit;s(),p("text",i.invoiceStatus.description)}}function En(t,r){if(t&1&&(e(0,` 356 `),C(1,"app-pill",40),e(2,` 357 `)),t&2){let i=d(2).$implicit;s(),p("text",i.invoiceStatus.description)}}function Dn(t,r){if(t&1&&(e(0,` 358 `),C(1,"app-pill",41),e(2,` 359 `)),t&2){let i=d(2).$implicit;s(),p("text",i.invoiceStatus.description)}}function Pn(t,r){if(t&1&&(e(0,` 360 `),C(1,"app-pill",42),e(2,` 361 `)),t&2){let i=d(2).$implicit;s(),p("text",i.invoiceStatus.description)}}function An(t,r){if(t&1&&(e(0,` 362 `),C(1,"app-pill",43),e(2,` 363 `)),t&2){let i=d(2).$implicit;s(),p("text",i.invoiceStatus.description)}}function Fn(t,r){if(t&1&&(e(0,` 364 `),C(1,"app-pill",43),e(2,` 365 `)),t&2){let i=d(2).$implicit;s(),p("text",i.invoiceStatus.description)}}function Vn(t,r){if(t&1&&(e(0,` 366 `),C(1,"app-pill",43),e(2,` 367 `)),t&2){let i=d(2).$implicit;s(),p("text",i.invoiceStatus.description)}}function Rn(t,r){if(t&1&&(e(0,` 368 `),C(1,"app-pill",43),e(2,` 369 `)),t&2){let i=d(2).$implicit;s(),p("text",i.invoiceStatus.description)}}function kn(t,r){if(t&1&&(e(0,` 370 `),a(1,"td"),e(2,` 371 `),m(3,Tn,3,1)(4,En,3,1)(5,Dn,3,1)(6,Pn,3,1)(7,An,3,1)(8,Fn,3,1)(9,Vn,3,1)(10,Rn,3,1),e(11,` 372 `),l(),e(12,` 373 `)),t&2){let i,n=d().$implicit,o=d(2);s(3),_((i=n.invoiceStatusID)===o.InvoiceStatus.DRAFT?3:i===o.InvoiceStatus.OPEN?4:i===o.InvoiceStatus.PAID?5:i===o.InvoiceStatus.OVERDUE?6:i===o.InvoiceStatus.WRITTEN_OFF?7:i===o.InvoiceStatus.CANCELLED?8:i===o.InvoiceStatus.PARTIALLY_REFUNDED?9:i===o.InvoiceStatus.REFUNDED?10:-1)}}function On(t,r){if(t&1&&(e(0),w(1,"sprocketCurrency")),t&2){let i=d().$implicit;h(` 374 `,E(1,1,i.amount),` 375 `)}}function Mn(t,r){if(t&1&&(e(0,` 376 `),a(1,"tr"),e(2,` 377 `),a(3,"td"),e(4,` 378 `),a(5,"a",32),e(6),l(),e(7,` 379 `),l(),e(8,` 380 `),a(9,"td"),e(10),l(),e(11,` 381 `),a(12,"td"),e(13,` 382 `),m(14,In,3,1),l(),e(15,` 383 `),a(16,"td"),e(17),l(),e(18,` 384 `),a(19,"td"),e(20,` 385 `),m(21,Sn,2,4),l(),e(22,` 386 `),a(23,"td"),e(24,` 387 `),m(25,gn,2,4)(26,yn,1,0),l(),e(27,` 388 `),a(28,"td"),e(29,` 389 `),m(30,wn,2,4)(31,bn,1,1),l(),e(32,` 390 `),m(33,kn,13,1),a(34,"td"),e(35,` 391 `),m(36,On,2,3),l(),e(37,` 392 `),e(38,` 393 `),l(),e(39,` 394 `)),t&2){let i=r.$implicit;s(5),p("routerLink",B(11,Ei,i.invoiceID)),s(),de(` 395 `,i.invoiceID,"-",i.uniqueID,` 396 `),s(4),h(` 397 `,i.recipients[0].label,` 398 `),s(4),_(i.recipients!=null&&i.recipients.length?14:-1),s(3),h(` 399 `,i.shortDescription,` 400 `),s(4),_(i.invoiceDate?21:-1),s(4),_(i.sentDate?25:26),s(5),_(i.dueDate?30:31),s(3),_(i.invoiceStatus?33:-1),s(3),_(i.amount?36:-1)}}function Nn(t,r){if(t&1&&(e(0,` 401 `),a(1,"tr"),e(2,` 402 `),a(3,"td",44),e(4,` 403 The search criteria produced no results. 404 `),l(),e(5,` 405 `),l(),e(6,` 406 `)),t&2){let i=r.$implicit;s(3),Pe("colspan",i.length+4)}}function Ln(t,r){if(t&1){let i=I();e(0,` 407 `),a(1,"p-table",26),x("onLazyLoad",function(o){u(i);let c=d();return v(c.search(o))}),e(2,` 408 `),y(3,ki,6,0,"ng-template",27),e(4,` 409 `),y(5,Mn,40,13,"ng-template",28),e(6,` 410 `),y(7,Nn,7,1,"ng-template",29),e(8,`
411 `),l(),e(9,` 412 `)}if(t&2){let i=d();s(),p("columns",i.columns)("value",i.searchResults)("lazy",!0)("paginator",!0)("alwaysShowPaginator",!1)("totalRecords",i.totalRecords)("rows",100)("sortOrder",-1)("loading",i.loading)("dataKey","invoiceID")}}var At=(()=>{let r=class r{constructor(n,o,c){this.siteDataService=n,this.invoiceService=o,this.authorizeService=c,this.AriaLabels=Ge,this.totalRecords=0,this.loading=!0,this.showTable=!1,this.showRemoved=!1,this.columns=[{field:"invoiceID",header:"ID"},{header:"Recipient Type"},{field:"recipient",header:"Recipient"},{field:"shortDescription",header:"Description"},{field:"invoiceDate",header:"Invoice Date"},{field:"sentDate",header:"Issue Date"},{field:"dueDate",header:"Due Date"},{field:"status",header:"Status"},{field:"amount",header:"Amount"}],this.InvoiceStatus=S,this.categories=[],this.RecipientType=qe,this.Permission=G,this.testUserOptions=He,this.unsubscribe$=new W}ngOnInit(){this.authorizeService.getUser().pipe(oe(1)).subscribe(n=>{this.user=n}),$([this.invoiceService.getInvoiceStatuses(),this.invoiceService.getInvoiceItems(),this.invoiceService.getInvoiceRevenueCategories()]).pipe(g(this.unsubscribe$)).subscribe({next:n=>{this.statuses=n[0],this.items=n[1],this.categories=n[2],this.invoiceService.filters&&this.invoiceService.filters.page?this.showTable=!0:(this.invoiceService.filters=new ie,this.showTable=!0),this.siteDataService.hideSiteLoader()}})}run(){this.invoiceService.filters.page=1,this.totalRecords=0,this.showTable?this.search():this.showTable=!0}search(n=null){let o=this.invoiceService.filters;n&&n.sortField&&(o.orderBy=n.sortField+" "+(n.sortOrder===1?"ASC":"DESC"),o.page=n.first/o.rows+1),o.getTotalCount=this.totalRecords===0,this.loading=!0,this.invoiceService.searchInvoices().pipe(g(this.unsubscribe$)).subscribe({next:c=>{this.searchResults=c.results,o.getTotalCount&&(this.totalRecords=c.count),this.loading=!1},error:()=>{this.siteDataService.showSiteErrorAlertDefaultGET()}})}resetFilters(){this.invoiceService.filters=new ie(this.invoiceService.filters.orderBy)}ngOnDestroy(){this.unsubscribe$.next(),this.unsubscribe$.complete()}};r.\u0275fac=function(o){return new(o||r)(T(H),T(J),T(ve))},r.\u0275cmp=L({type:r,selectors:[["ng-component"]],standalone:!1,decls:12,vars:2,consts:[["fullRecipientName",""],["fullParentName",""],["noLink_4",""],[3,"keydown.enter"],[1,""],[1,"report-table","table-responsive"],[3,"adminFilterReset","adminFilterSearch","showAdvanced"],["primary",""],[1,"col","pr-0"],[1,"p-input-icon-left","full-width"],[1,"fa","fa-magnifying-glass"],["type","text","id","search","pInputText","","placeholder","Search by Invoice Description, Recipient Name/Email",1,"full-width","pl-4",3,"ngModelChange","ngModel"],["for","search",1,"sr-only"],["advanced",""],[1,"row"],[1,"col-md-3"],[1,"form-group"],["for","invoiceStatusID"],["inputId","invoiceStatusID","placeholder","All","selectedItemsLabel","{0} statuses selected","appendTo","body",3,"ngModelChange","options","ngModel"],["for","invoiceItemID"],["inputId","invoiceItemID","placeholder","All","selectedItemsLabel","{0} items selected","appendTo","body",3,"ngModelChange","options","ngModel"],["for","invoiceRevenueCategoryID"],["inputId","invoiceRevenueCategoryID","placeholder","All","selectedItemsLabel","{0} categories selected","appendTo","body",3,"ngModelChange","options","group","ngModel"],["pTemplate","group"],["for","test-user-option"],["styleClass","full-width","appendTo","body",3,"ngModelChange","ngModel","options"],["sortField","invoiceID",1,"table","table-striped","table-sm",3,"onLazyLoad","columns","value","lazy","paginator","alwaysShowPaginator","totalRecords","rows","sortOrder","loading","dataKey"],["pTemplate","header"],["pTemplate","body"],["pTemplate","emptymessage"],[3,"pSortableColumn"],[3,"field"],[3,"routerLink"],[1,"col-12"],[4,"ngTemplateOutlet"],[1,"d-flex","align-items-center","mt-2","text-small","text-grey"],[1,"mr-2"],[1,"mr-1"],[1,"ml-1"],["status","secondary",3,"text"],["status","warning",3,"text"],["status","success",3,"text"],["status","error",3,"text"],[3,"text"],[2,"text-align","left"]],template:function(o,c){o&1&&(C(0,"app-invoicing-navigation"),e(1,` 413 414`),a(2,"div",3),x("keydown.enter",function(){return c.run()}),e(3,` 415 `),m(4,Fi,75,20),a(5,"section",4),e(6,` 416 `),a(7,"div",5),e(8,` 417 `),m(9,Ln,10,10),l(),e(10,` 418`),l(),e(11,` 419`),l()),o&2&&(s(4),_(c.invoiceService.filters?4:-1),s(5),_(c.showTable?9:-1))},dependencies:[$e,je,Ue,ze,q,Qe,xe,dt,at,lt,rt,Xe,ot,St,We,st],encapsulation:2});let t=r;return t})();var Ft=(()=>{let r=class r{};r.\u0275fac=function(o){return new(o||r)},r.\u0275cmp=L({type:r,selectors:[["ng-component"]],standalone:!1,decls:1,vars:0,template:function(o,c){o&1&&C(0,"router-outlet")},dependencies:[Ye],encapsulation:2});let t=r;return t})();var De=class{constructor(){this.paymentDate=new Date}};var ne=class{};var Bn=()=>["../../new"],$n=()=>["../.."];function Wn(t,r){if(t&1&&(e(0,` 420 `),C(1,"app-admin-header",4),e(2,` 421`)),t&2){let i=d();
421s(),p("pageTitle",i.invoice.shortDescription)("showBackButton",!0)}}function jn(t,r){if(t&1&&(e(0,` 422 `),C(1,"app-shared-invoice",5),e(2,` 423`)),t&2){let i=d();s(),p("invoice",i.invoice)}}function Un(t,r){t&1&&(e(0,` 424 `),C(1,"app-button-loader"),e(2,` 425 Sending... 426 `))}function zn(t,r){t&1&&e(0,` 427 Resend Invoice 428 `)}function Yn(t,r){t&1&&e(0,` 429 Send Invoice 430 `)}function Qn(t,r){if(t&1&&(e(0,` 431 `),m(1,zn,1,0)(2,Yn,1,0)),t&2){let i=d(3);s(),_(i.invoice.invoiceStatusID!==i.InvoiceStatus.DRAFT?1:2)}}function qn(t,r){if(t&1){let i=I();e(0,` 432 `),a(1,"button",10),x("click",function(){u(i);let o=d(2);return v(o.send())}),e(2,` 433 `),m(3,Un,3,0),m(4,Qn,3,1),l(),e(5,` 434 `)}if(t&2){let i=d(2);s(),p("disabled",i.loading||i.sending),s(2),_(i.sending?3:-1),s(),_(i.sending?-1:4)}}function Gn(t,r){if(t&1&&(e(0,` 435 `),C(1,"app-split-button",11),e(2,` 436 `)),t&2){let i=d(2);s(),p("menuItems",i.actionMenuItems)}}function Hn(t,r){if(t&1){let i=I();e(0,` 437 `),a(1,"div",6),e(2,` 438 `),a(3,"div",7),e(4,` 439 `),m(5,qn,6,3),m(6,Gn,3,1),a(7,"a",8),x("click",function(o){u(i);let c=d();return v(c.loading||c.sending?o.preventDefault():"")}),e(8,` 440 Add Invoice 441 `),l(),e(9,` 442 `),a(10,"a",9),x("click",function(o){u(i);let c=d();return v(c.loading||c.sending?o.preventDefault():"")}),e(11,` 443 Cancel 444 `),l(),e(12,` 445 `),l(),e(13,` 446 `),l(),e(14,` 447`)}if(t&2){let i=d();s(5),_(i.invoice.invoiceStatusID===i.InvoiceStatus.OPEN||i.invoice.invoiceStatusID===i.InvoiceStatus.DRAFT?5:-1),s(),_(i.actionMenuItems!=null&&i.actionMenuItems.length?6:-1),s(),N("btn-disabled",i.loading||i.sending),p("routerLink",O(8,Bn)),s(3),N("btn-disabled",i.loading||i.sending),p("routerLink",O(9,$n))}}function Jn(t,r){if(t&1){let i=I();e(0,` 448 `),a(1,"app-yes-no-modal",12),x("onYesSelect",function(){u(i);let o=d();return v(o.delete())})("onNoSelect",function(){u(i);let o=d();return v(o.showDelete=!1)}),l(),e(2,` 449`)}}function Kn(t,r){if(t&1){let i=I();e(0,` 450 `),a(1,"app-yes-no-modal",13),x("onYesSelect",function(){u(i);let o=d();return v(o.writeOff())})("onNoSelect",function(){u(i);let o=d();return v(o.showWriteOff=!1)}),l(),e(2,` 451`)}}function Zn(t,r){if(t&1){let i=I();e(0,` 452 `),a(1,"app-yes-no-modal",14),x("onYesSelect",function(){u(i);let o=d();return v(o.cancelInvoice())})("onNoSelect",function(){u(i);let o=d();return v(o.showCancel=!1)}),l(),e(2,` 453`)}}function Xn(t,r){if(t&1&&(e(0,` 454 `),a(1,"div",18),e(2,` 455 `),a(3,"div",19),e(4,"Surcharges"),l(),e(5,` 456 `),a(6,"div",20),e(7),w(8,"currency"),l(),e(9,` 457 `),l(),e(10,` 458 `)),t&2){let i=d(2);s(7),h(` 459 `,E(8,1,i.offlinePaymentSurchargeTotal),` 460 `)}}function eo(t,r){if(t&1){let i=I();e(0,` 461 `),a(1,"div",15),e(2,` 462 `),a(3,"div",16),e(4,"Payment Breakdown"),l(),e(5,` 463 `),a(6,"div",17),e(7,` 464 `),a(8,"div",18),e(9,` 465 `),a(10,"div",19),e(11,"Amount"),l(),e(12,` 466 `),a(13,"div",20),e(14),w(15,"currency"),l(),e(16,` 467 `),l(),e(17,` 468 `),m(18,Xn,11,3),a(19,"div",21),e(20,` 469 `),a(21,"div",19)(22,"strong"),e(23,"Total"),l()(),e(24,` 470 `),a(25,"div",20),e(26,` 471 `),a(27,"strong"),e(28),w(29,"currency"),l(),e(30,` 472 `),l(),e(31,` 473 `),l(),e(32,` 474 `),l(),e(33,` 475 `),l(),e(34,` 476 `),a(35,"app-dynamic-form",22,1),x("onSubmit",function(o){u(i);let c=d();return v(c.recordOfflinePayment(o))})("onCancel",function(){u(i);let o=d();return v(o.showRecordPayment=!1)}),e(37,` 477 `),a(38,"app-dynamic-form-field",23),e(39,` 478 `),l(),e(40,` 479 `),a(41,"app-dynamic-form-field",24),e(42,` 480 `),l(),e(43,` 481 `),l(),e(44,` 482 `)}if(t&2){let i=d();s(14),h(` 483 `,E(15,10,i.offlinePaymentItemTotal),` 484 `),s(4),_(i.offlinePaymentSurchargeTotal>0?18:-1),s(10),Y(E(29,12,i.offlinePaymentItemTotal+i.offlinePaymentSurchargeTotal)),s(7),p("fields",i.recordOfflinePaymentFields)("entity",i.offlinePaymentData)("contentFieldsMode",!0)("horizontalForm",!0)("showCancelButton",!0)("showSubmitButton",!0)("buttonsPosition","spread")}}function to(t,r){t&1&&(e(0,` 485 `),C(1,"app-skeleton-template",25),e(2,` 486 `))}function io(t,r){if(t&1&&(e(0,` 487 `),a(1,"div",18),e(2,` 488 `),a(3,"div",19),e(4,"Surcharges"),l(),e(5,`
489 `),a(6,"div",20),e(7),w(8,"currency"),l(),e(9,` 490 `),l(),e(10,` 491 `)),t&2){let i=d(3);s(7),h(` 492 `,E(8,1,i.completedPayment.clubUserPayment.surcharge),` 493 `)}}function no(t,r){if(t&1&&(e(0,` 494 `),a(1,"div",18),e(2,` 495 `),a(3,"div",19),e(4),l(),e(5,` 496 `),a(6,"div",20),e(7),w(8,"currency"),l(),e(9,` 497 `),l(),e(10,` 498 `)),t&2){let i=d(3);s(4),h(` 499 `,i.completedPayment.clubUserPayment.userFeePercentage?i.completedPayment.clubUserPayment.userFeePercentage+"% Service Fee":"Service Fee",` 500 `),s(3),h(` 501 `,E(8,2,i.completedPayment.clubUserPayment.paymentFee),` 502 `)}}function oo(t,r){if(t&1&&(e(0,` 503 `),a(1,"div",15),e(2,` 504 `),a(3,"div",16),e(4,"Payment Breakdown"),l(),e(5,` 505 `),a(6,"div",17),e(7,` 506 `),a(8,"div",18),e(9,` 507 `),a(10,"div",19),e(11,"Amount Paid"),l(),e(12,` 508 `),a(13,"div",20),e(14),w(15,"currency"),l(),e(16,` 509 `),l(),e(17,` 510 `),m(18,io,11,3),m(19,no,11,4),a(20,"div",21),e(21,` 511 `),a(22,"div",19),e(23,` 512 `),a(24,"strong"),e(25,"Total Amount Paid"),l(),e(26,` 513 `),l(),e(27,` 514 `),a(28,"div",20),e(29,` 515 `),a(30,"strong"),e(31),w(32,"currency"),l(),e(33,` 516 `),l(),e(34,` 517 `),l(),e(35,` 518 `),l(),e(36,` 519 `),l(),e(37,` 520 `)),t&2){let i=d(2);s(14),h(` 521 `,E(15,4,i.completedPayment.amountPaid),` 522 `),s(4),_(i.completedPayment.clubUserPayment.surcharge>0?18:-1),s(),_(i.completedPayment.clubUserPayment.paymentFee>0?19:-1),s(12),h(` 523 `,E(32,6,(i.completedPayment.amountPaid||0)+(i.completedPayment.clubUserPayment.surcharge||0)+(i.completedPayment.clubUserPayment.paymentFee||0)),` 524 `)}}function ao(t,r){if(t&1){let i=I();e(0,` 525 `),m(1,oo,38,8),a(2,"app-dynamic-form",26,1),x("onSubmit",function(o){u(i);let c=d();return v(c.recordRefundPayment(o))})("onCancel",function(){u(i);let o=d();return v(o.showRefund=!1)}),e(4,` 526 `),a(5,"app-dynamic-form-field",27),e(6,` 527 `),l(),e(7,` 528 `),a(8,"app-dynamic-form-field",28),e(9,` 529 `),l(),e(10,` 530 `),l(),e(11,` 531 `)}if(t&2){let i=d();s(),_(i.completedPayment?1:-1),s(),p("fields",i.refundPaymentFields)("entity",i.refundPaymentData)("contentFieldsMode",!0)("horizontalForm",!0)("showCancelButton",!0)("showSubmitButton",!0)("buttonsPosition","spread"),s(6),p("disabled",!0)("viewOnly",!0)}}function lo(t,r){t&1&&(e(0,` 532 `),C(1,"app-skeleton-template",25),e(2,` 533 `))}function ro(t,r){t&1&&(e(0,` 534 `),C(1,"app-skeleton-template",25),e(2,` 535 `))}var Vt=(()=>{let r=class r{constructor(n,o,c,f,V,M){this.siteDataService=n,this.invoiceService=o,this.route=c,this.router=f,this.authorizeService=V,this.formService=M,this.loading=!0,this.sending=!1,this.canEdit=!1,this.canWriteOff=!1,this.canRecordPayment=!1,this.canDelete=!1,this.canCancel=!1,this.canRefund=!0,this.showWriteOff=!1,this.showRecordPayment=!1,this.showDelete=!1,this.showCancel=!1,this.showRefund=!1,this.loadingOfflinePayment=!1,this.offlinePaymentItemTotal=0,this.offlinePaymentSurchargeTotal=0,this.loadingRefundPaymentDialog=!1,this.InvoiceStatus=S,this.canFail=!1,this.isSuperAdmin=!1,this.unsubscribe$=new W}ngOnInit(){this.siteDataService.hideSiteLoader(),this.route.params.subscribe({next:n=>{n.id&&(this.invoiceID=+n.id,$([this.invoiceService.getInvoice(this.invoiceID)]).pipe(g(this.unsubscribe$)).subscribe({next:o=>{this.invoice=o[0],this.setMenuItems(),this.loading=!1},error:()=>{this.siteDataService.showSiteErrorAlertDefaultGET()}}))}}),this.authorizeService.getUser().pipe(oe(1)).subscribe({next:n=>{n&&(this.canFail=Ke.includes(+n.userID),this.isSuperAdmin=this.authorizeService.isSuperAdmin(n.role))}})}setMenuItems(){return Oe(this,null,function*(){this.canEdit=this.invoice.invoiceStatusID===S.DRAFT,this.canWriteOff=this.invoice.isOverdue&&this.invoice.invoiceStatusID===S.OPEN,this.canRecordPayment=this.invoice.invoiceStatusID===S.OPEN,this.canDelete=this.invoice.invoiceStatusID===S.DRAFT,this.canCancel=this.invoice.invoiceStatusID===S.OPEN,this.canRefund=!1,this.actionMenuItems=[];let n=window.location.host.indexOf(".sprocketsports.com")>-1;this.invoice.invoiceStatusID===S.PAID&&this.isSuperAdmin&&(!n||this.canFail)&&this.actionMenuItems.push({label:"Fail Payment",icon:"fa fa-dumpster-fire",command:()=>{this.markPaymentAsFailed()}}),this.canEdit&&this.actionMenuItems.push({label:"Edit Invoice",icon:"fa fa-pencil",routerLink:[".."]}
535),this.canRecordPayment&&this.actionMenuItems.push({label:"Record Offline Payment",icon:"fa fa-dollar-sign",command:()=>{this.loadOfflinePayment()}}),this.canWriteOff&&this.actionMenuItems.push({label:"Write Off",icon:"fa fa-times",command:()=>{this.showWriteOff=!0}}),this.canCancel&&this.actionMenuItems.push({label:"Cancel Invoice",icon:"fa fa-ban",command:()=>{this.showCancel=!0}}),this.canDelete&&this.actionMenuItems.push({label:"Delete Invoice",icon:"fa fa-trash-alt",command:()=>{this.showDelete=!0}}),this.invoice.invoiceStatusID===S.PAID&&(this.canRefund=yield Me(this.invoiceService.canRefundPayment(this.invoiceID)),this.canRefund&&this.actionMenuItems.push({label:"Refund Payment",icon:"fa fa-dollar-sign",command:()=>{this.loadRefundPaymentDialog()}}))})}send(){this.sending=!0,(this.invoice.invoiceStatusID===S.DRAFT?this.invoiceService.sendInvoice(this.invoiceID):this.invoiceService.resendInvoice(this.invoiceID)).pipe(g(this.unsubscribe$)).subscribe({next:()=>{this.siteDataService.showSiteSuccessAlert("Invoice sent successfully"),this.invoice.recipients.length>1?this.router.navigate(["../.."],{relativeTo:this.route}):(this.invoice=D(b({},this.invoice),{invoiceStatusID:S.OPEN,invoiceStatus:new X(S.OPEN,"Open")}),this.sending=!1,this.setMenuItems())},error:()=>{this.siteDataService.showSiteErrorAlert("There was a problem sending this invoice"),this.sending=!1}})}delete(){this.invoiceService.deleteInvoice(this.invoiceID).pipe(g(this.unsubscribe$)).subscribe({next:()=>{this.siteDataService.showSiteSuccessAlert("Invoice deleted successfully"),this.router.navigate(["../.."],{relativeTo:this.route})},error:()=>{this.siteDataService.showSiteErrorAlert("There was a problem deleting this invoice")}})}writeOff(){this.invoiceService.writeOffInvoice(this.invoiceID).pipe(g(this.unsubscribe$)).subscribe({next:()=>{this.siteDataService.showSiteSuccessAlert("Invoice written off successfully"),this.invoice=D(b({},this.invoice),{isOverdue:!1,invoiceStatusID:S.WRITTEN_OFF,invoiceStatus:new X(S.WRITTEN_OFF,"Written Off")}),this.showWriteOff=!1,this.actionMenuItems=[]},error:()=>{this.siteDataService.showSiteErrorAlert("There was a problem writing off this invoice")}})}cancelInvoice(){this.invoiceService.cancelInvoice(this.invoiceID).pipe(g(this.unsubscribe$)).subscribe({next:()=>{this.siteDataService.showSiteSuccessAlert("Invoice cancelled successfully"),this.invoice=D(b({},this.invoice),{isOverdue:!1,invoiceStatusID:S.CANCELLED,invoiceStatus:new X(S.CANCELLED,"Cancelled")}),this.showCancel=!1,this.actionMenuItems=[]},error:()=>{this.siteDataService.showSiteErrorAlert("There was a problem cancelling this invoice")}})}loadOfflinePayment(){this.offlinePaymentItemTotal=this.calcOfflinePaymentItemTotal(),this.offlinePaymentSurchargeTotal=this.calcOfflinePaymentSurchargeTotal(),this.recordOfflinePaymentFields?this.showRecordPayment=!0:(this.loadingOfflinePayment=!0,this.showRecordPayment=!0,this.invoiceService.getInvoiceOfflinePaymentMetadata().pipe(g(this.unsubscribe$)).subscribe({next:n=>{this.recordOfflinePaymentFields=n.fields,this.offlinePaymentData=new De,this.loadingOfflinePayment=!1}}))}recordOfflinePayment(n){this.invoiceService.recordOfflinePayment(this.invoiceID,n).pipe(g(this.unsubscribe$)).subscribe({next:()=>{this.siteDataService.showSiteSuccessAlert("Payment recorded successfully"),this.showRecordPayment=!1,this.reloadInvoiceAfterPayment()},error:()=>{this.siteDataService.showSiteErrorAlert("There was a problem recording the payment")}})}reloadInvoiceAfterPayment(){this.loading=!0,this.invoiceService.getInvoice(this.invoiceID).pipe(g(this.unsubscribe$)).subscribe({next:n=>{this.invoice=n,this.setMenuItems(),this.loading=!1},error:()=>{this.siteDataService.showSiteErrorAlert("There was a problem reloading the invoice"),this.loading=!1}})}loadRefundPaymentDialog(){this.completedPayment=this.calcCompletedPayment(),this.refundPaymentFields?(this.refundPaymentData=new ne,this.showRefund=!0):(this.loadingRefundPaymentDialog=!0,this.invoiceService.getInvoiceRefundPaymentMetadata(this.invoiceID).pipe(g(this.unsubscribe$)).subscribe({next:n=>{this.refundPaymentFields=n.fields,this.refundPaymentData=new ne,this.loadingRefundPaymentDialog=!1,this.showRefund=!0}}))}recordRefundPayment(n){this.invoiceService.refundPayment(this.invoiceID,n).pipe(g(this.unsubscribe$)).subscribe({next:o=>{if(o.refundSuccess)this.siteDataService.showSiteSuccessAlert("Payment refunded successfully"),this.invoice=D(b({},this.invoice),{invoiceStatusID:S.REFUNDED,invoiceStatus:new X(S.REFUNDED,"Refunded")}),this.showRefund=!1,this.actionMenuItems=[];else{let c=o.refundErrorText!=null?o.refundErrorText:"There was a problem refunding the payment";this.siteDataService.showSiteErrorAlert(c),this.formService.hideFormLoader()}},error:()=>{this.formService.hideFormLoader(),this.siteDataService.showSiteErrorAlert("There was a problem refunding the payment")}})}markPaymentAsFailed(){this.loading=!0,this.invoiceService.failPayment(this.invoiceID).pipe(Ne(()=>this.invoiceService.getInvoice(this.invoiceID)),g(this.unsubscribe$)).subscribe({next:n=>{this.siteDataService.showSiteSuccessAlert("Payment failed successfully"),this.invoice=n,this.setMenuItems(),this.loading=!1},error:()=>{this.siteDataService.showSiteErrorAlert("There was a problem failing this invoice payment"),this.loading=!1}})}calcOfflinePaymentItemTotal(){return this.invoice?.itemAssignments?.reduce((n,o)=>n+(o.totalPrice||0),0)??0}calcOfflinePaymentSurchargeTotal(){return this.invoice?.itemAssignments?.reduce((n,o)=>n+(o.projectedSurchargeAmount||0),0)??0}calcCompletedPayment(){return this.invoice?.invoicePayments?.filter(n=>n.paymentCompleted&&n.clubUserPayment&&!n.clubUserPayment.paymentFailed&&n.transactionTypeID===1)?.sort((n,o)=>o.invoicePaymentID-n.invoicePaymentID)[0]}ngOnDestroy(){this.unsubscribe$.next(),this.unsubscribe$.complete()}};r.\u0275fac=function(o){return new(o||r)(T(H),T(J),T(pe),T(ue),T(ve),T(nt))},r.\u0275cmp=L({type:r,selectors:[["ng-component"]],standalone:!1,decls:19,vars:18,consts:[["skeleton_2",""],["form",""],["header","Record Offline Payment","styleClass","standardWidthDialog",3,"visibleChange","visible","showHeader","closable","modal","draggable"],["header","Refund Invoice Payment","styleClass","standardWidthDialog",3,"visibleChange","visible","showHeader","closable","modal","draggable"],["parentLinkText","Invoices","parentLinkUrl","../..",3,"pageTitle","showBackButton"],[3,"invoice"],[1,"row","form-action","no-gutters"],[1,"col-md-12"],["type","button",1,"btn","btn-lg","btn-icon-plus",3,"click","routerLink"],["type","button",1,"btn","btn-lg","btn-naked",3,"click","routerLink"],["type","button",1,"btn","btn-lg","btn-primary","btn-icon-e
535nvelope",3,"click","disabled"],["buttonClass","btn-lg",3,"menuItems"],["headerText","Confirm Delete","modalText","Are you sure you want to delete this invoice?","yesButtonText","Yes, Delete","yesButtonLoadingText","Deleting...","noButtonText","No, Cancel",3,"onYesSelect","onNoSelect"],["headerText","Confirm Write Off","modalText","Are you sure you want to write off this invoice?","yesButtonText","Yes, Write Off","yesButtonLoadingText","Writing off...","noButtonText","No, Cancel",3,"onYesSelect","onNoSelect"],["headerText","Confirm Cancel","modalText","Are you sure you want to cancel this invoice?","yesButtonText","Yes, Cancel","yesButtonLoadingText","Cancelling...","noButtonText","No, Don't Cancel",3,"onYesSelect","onNoSelect"],[1,"payment-description","bg-grey-lt","px-3","py-3","mb-3"],[1,"text-navy","fw-600"],[1,"text-medium"],[1,"row","payment-row","mt-3"],[1,"col-md-8","label","d-flex","align-items-center"],[1,"col-md-4","d-flex","justify-content-end","align-items-center"],[1,"row","payment-row","mt-3","border-top"],["formID","offline-payment-form",3,"onSubmit","onCancel","fields","entity","contentFieldsMode","horizontalForm","showCancelButton","showSubmitButton","buttonsPosition"],["fieldName","paymentDate","formID","offline-payment-form"],["fieldName","adminNotes","formID","offline-payment-form"],["skeletonType","form"],["formID","refund-invoice-payment-form",3,"onSubmit","onCancel","fields","entity","contentFieldsMode","horizontalForm","showCancelButton","showSubmitButton","buttonsPosition"],["fieldName","adminNotes","formID","refund-invoice-payment-form"],["fieldName","doRefundServiceFee","formID","refund-invoice-payment-form",3,"disabled","viewOnly"]],template:function(o,c){if(o&1){let f=I();m(0,Wn,3,2),m(1,jn,3,1),m(2,Hn,15,10),m(3,Jn,3,0),m(4,Kn,3,0),m(5,Zn,3,0),a(6,"p-dialog",2),F("visibleChange",function(M){return u(f),A(c.showRecordPayment,M)||(c.showRecordPayment=M),v(M)}),e(7,` 536 `),m(8,eo,45,14)(9,to,3,0),l(),e(10,` 537 538`),a(11,"p-dialog",3),F("visibleChange",function(M){return u(f),A(c.showRefund,M)||(c.showRefund=M),v(M)}),e(12,` 539 `),m(13,ao,12,10)(14,lo,3,0),y(15,ro,3,0,"ng-template",null,0,Q),e(17,` 540`),l(),e(18,` 541`)}o&2&&(_(c.invoice?0:-1),s(),_(!c.loading&&c.invoice?1:-1),s(),_(!c.loading&&c.invoice?2:-1),s(),_(c.showDelete?3:-1),s(),_(c.showWriteOff?4:-1),s(),_(c.showCancel?5:-1),s(),P("visible",c.showRecordPayment),p("showHeader",!0)("closable",!1)("modal",!0)("draggable",!1),s(2),_(c.showRecordPayment&&c.recordOfflinePaymentFields&&!c.loadingOfflinePayment?8:9),s(3),P("visible",c.showRefund),p("showHeader",!0)("closable",!1)("modal",!0)("draggable",!1),s(2),_(c.showRefund&&c.refundPaymentFields&&!c.loadingRefundPaymentDialog?13:14))},dependencies:[we,ge,q,Se,be,ye,mt,_t,Ce,Te,_e],encapsulation:2});let t=r;return t})();var Rt=(()=>{let r=class r{};r.\u0275fac=function(o){return new(o||r)},r.\u0275mod=le({type:r}),r.\u0275inj=ae({imports:[Ae.forChild([{path:"",component:Ft,children:[{path:":id/view",canActivate:[fe,Ie,he],component:Vt,data:{permissions:[G.InvoicingAdmin],metaTitle:"Invoice View"}},{path:":id",canActivate:[fe,Ie,he],component:Dt,data:{permissions:[G.InvoicingAdmin],metaTitle:"Invoice Edit"}},{path:"",canActivate:[fe,Ie,he],component:At,data:{permissions:[G.InvoicingAdmin],metaTitle:"Invoice Search"}}]}]),Ae]});let t=r;return t})();var Ha=(()=>{let r=class r{};r.\u0275fac=function(o){return new(o||r)},r.\u0275mod=le({type:r}),r.\u0275inj=ae({imports:[pt,Rt,Ct,wt,gt,yt,xt]});let t=r;return t})();export{Ha as InvoiceModule};
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.