PageSourceSearch

https://portal.struxtion.com/assets/Payments-C-QVKe3i.js

js struxtion.com collected 2026-10-04 09:52:27 UTC 12,942 bytes, 1 lines download raw bytes

1import{r as T,j as e,f as u,O as p,K as te,B as n,t as _,v as L,U as ie,w as ae,M as ne,P as v,A as re,_ as oe,y as w,T as N,F as G,aa as V,R as $,m as M,n as q,ar as B,e as I,S as le,p as se,as as de,H as me}from"./index-izS9yct_.js";import{T as ce,a as U}from"./Tabs-CdmRYzp9.js";import{D as z}from"./luxon--C7Xj71B.js";import{D as H}from"./DynamicTable-B9goygjM.js";import{C as k}from"./CurrencyFormat-B2s-iK4w.js";import{u as pe}from"./getSubscriptions-3Dfu7r5A.js";import{A as W}from"./AdvancedFilter-C6m41vbj.js";import{D as ue}from"./DateRangeFilter-B-rfC4oW.js";import{M as xe}from"./MoreMenu-67TBPH5y.js";import{u as Y}from"./getSubscription-DmM4XPsm.js";import{F as X,T as O}from"./TextField-CkT4wjoe.js";import{X as he}from"./XpayPayments-CJbYqsgN.js";import"./TablePagination-62L2mvbn.js";import"./Chip-B5r_wRCE.js";import"./TableSortLabel-CTMxGT08.js";import"./KeyboardArrowUp-DaOunogI.js";import"./Collapse-BWThNiCu.js";import"./react-number-format.es-DdB0zUIN.js";import"./Search-DBbCX8fM.js";import"./Clear-S4fIeh78.js";import"./Tooltip-Csq33AuB.js";import"./Popper-DuHhDYPX.js";import"./index-CCXKShhK.js";import"./defineProperty-DWm6lKFB.js";import"./assertThisInitialized-C91vtUtA.js";import"./MoreVert-CGUJiS7R.js";import"./ClickAwayListener-wWi0Kxcf.js";import"./ArrowDropUp-CRjV6DFp.js";import"./XpayChildPayments-nxjGb7wf.js";import"./Wrapper-BjpXqUDt.js";import"./StruxtionLogo-DiWji7QS.js";import"./DetailsGrid-Deqlf6Pv.js";import"./createTransaction-1OF7SwDJ.js";import"./useXPayPayments-DmbyGRTE.js";import"./PickerField-CPg4iYn8.js";import"./formatErrorMessage-DkKmrRLY.js";import"./InputAdornment-Cp-6De_o.js";import"./NativeSelect-C2wMRPTC.js";import"./HookedDocReview-YSnAy-bt.js";import"./pdfWorkerConfig-BBOJ8QlB.js";import"./useDispatch-DVFeSOo_.js";import"./NavigateBefore-Dmu77UIs.js";import"./NavigateNext-0qmSDq9z.js";import"./downloadDocument-gI-qFG6B.js";import"./GroupIconsRole-C0witPBH.js";import"./Table-C5h7fqAj.js";import"./useBankAccount-4sscd918.js";import"./Snackbar-BIvCOiSo.js";import"./useDownloadFiles-DZTUHXof.js";const K=({onChange:o})=>{const[a,m]=T.useState(0),t=T.useCallback((S,s)=>{m(s),o(s)},[o]);return e.jsxs(ce,{value:a,onChange:t,indicatorColor:"primary",children:[e.jsx(U,{label:"XPay"}),e.jsx(U,{label:"Project Financing"}),e.jsx(U,{label:"Subscriptions"})]})};K.propTypes={onChange:u.func.isRequired};const je=[{id:"amount",label:"AMOUNT"},{id:"description",label:"DESCRIPTION"},{id:"name",label:"NAME"},{id:"accountNumber",label:"ACCOUNT #"},{id:"date",label:"DATE"}],ge=o=>o.map(a=>
1({id:a.id,companyId:a.companyId,amount:e.jsx(k,{displayType:"text",decimalScale:2,value:a.paymentAmount||0}),description:a.paymentDescription||"--",name:a.companyName||"--",accountNumber:a.accountNumber?`****${a.accountNumber.slice(-4)}`:"--",date:a.paymentDate?z.fromISO(a.paymentDate).toLocaleString(z.DATE_SHORT):"--"})),J=({visible:o})=>{const[a,m]=T.useState({startDate:new Date(new Date().getFullYear(),0,1),endDate:new Date,key:"selection"}),[t,S]=p.useState({companyName:""}),[s,C]=p.useState(0),[g,c]=p.useState(20),F=te(),{loading:r,error:R,pagination:h,payments:y,getSubscriptionsPayments:f}=pe(),E=i=>{C(0),m(i)},A=p.useCallback((i,l)=>{C(0),S(j=>({...j,[l]:i}))},[]);T.useEffect(()=>{const i=z.fromMillis(Date.parse(a.startDate)).toISODate(),l=z.fromMillis(Date.parse(a.endDate)).toISODate();o&&f(i,l,t.companyName,s,g)},[a,f,s,g,o,t]);const b=(i,l)=>{s!==i&&C(i),g!==l&&c(l)},D=[{label:"Sub Contractor",onFilterChange:i=>A(i,"companyName"),endAdornment:{type:"clear",action:()=>A("","companyName")},breakpoint:12}];return e.jsxs(n,{hidden:!o,sx:{mt:5},children:[e.jsx(_,{padding:16,children:e.jsx(W,{inputs:D,justifyContent:"start",actions:e.jsx(ue,{tooltipTitle:"Payment date",selectionDate:a,setSelectionDate:E})})}),r&&e.jsx(L,{}),e.jsx(H,{columns:je,rows:ge(y),pagination:h,hasPagination:!0,controlledPage:s,handleChangePageCallback:b,retrieveErrorData:R||null,isRowsClickeable:{active:!0,isOnClickAction:!0,action:i=>F(`${ie}/scs/${i.companyId}`)}})]})};J.propTypes={visible:u.bool.isRequired};const ye=se()(()=>({paper:{position:"absolute",maxHeight:"90vh",overflowY:"auto",overflowX:"hidden"},modal:{display:"flex",alignItems:"center",justifyContent:"center"}})),Q=({modalStatus:o,open:a,onClose:m,subsc:t=void 0})=>{const{classes:S}=ye(),s=ae(),{handleSubmit:C,register:g,control:c,reset:F,formState:{errors:r}}=s,[R,h]=p.useState(!1);p.useEffect(()=>{a&&F({id:(t==null?void 0:t.id)||"",billingPeriod:(t==null?void 0:t.billingPeriod)||"",name:(t==null?void 0:t.name)||"",amount:(t==null?void 0:t.amount)||0})},[a,t,F]);const{loading:y,error:f,createSubscription:E,updateSubscription:A,deleteSubscription:b}=Y(),D=i=>{h(!0),o==="creating"&&E({...i,amount:parseFloat(i.amount).toFixed(2)}),o==="editing"&&A({...i,amount:parseFloat(i.amount).toFixed(2),id:t.id}),o==="deleting"&&b(t.id);const l=setTimeout(()=>{f||(h(!1),m(!0))},1e3);return()=>{clearTimeout(l)}};return e.jsx(e.Fragment,{children:e.jsx(ne,{className:S.modal,open:a,onClose:()=>m(),"aria-labelledby":"Edit Company","aria-describedby":"edit company modal",children:e.jsxs(v,{square:!0,elevation:24,style:{maxWidth:"700px",padding:32,margin:"1em"},children:[f&&e.jsx(re,{severity:"error",children:f}),e.jsx(oe,{...s,children:e.jsxs("form",{onSubmit:C(D),children:[(y||R)&&e.jsx(L,{}),e.jsxs(e.Fragment,{children:[e.jsx(w,{name:"id",defaultValue:(t==null?void 0:t.id)||"",control:c,render:({field:i})=>e.jsx("input",{...i,type:"hidden"})}),o==="creating"&&e.jsxs(n,{sx:{minWidth:"340px"},children:[e.jsx(n,{sx:{mb:4,borderBottom:"2px solid lightGray",display:"inline-flex"},children:e.jsx(N,{variant:"h6",children:"Create Subscription"})}),e.jsx(n,{sx:{display:"flex",mb:2},children:e.jsx(v,{elevation:24,style:{padding:"32px 32px 0",width:"100%"},children:e.jsx(w,{name:"billingPeriod",control:c,rules:{required:!0},render:({field:i})=>{var l;return e.jsxs(G,{error:!!r.billingPeriod,children:[e.jsx(V,{children:"SUBSCRIPTION PERIOD"}),e.jsxs($,{row:!0,"aria-label":"billingPeriod",...i,children:[e.jsx(M,{value:"Monthly",control:e.jsx(q,{color:"primary"}),label:"Monthly"}),e.jsx(M,{value:"Annually",control:e.jsx(q,{color:"primary"}),label:"Annually"})]}),((l=r.billingPeriod)==null?void 0:l.type)==="required"&&e.jsx(X,{error:!0,children:"Please choose the repeat Perio
1d."})]})}})})}),e.jsx(n,{sx:{display:"flex",alignItems:"center",mb:2},children:e.jsx(v,{elevation:24,style:{padding:32,width:"100%"},children:e.jsx(O,{label:"Subscription Name",name:"name",error:!!r.name,helperText:r.name&&"Company name is required.",...g("name",{required:!0}),defaultValue:""})})}),e.jsx(n,{sx:{display:"flex",alignItems:"center",mt:2,mb:4},children:e.jsx(v,{elevation:24,style:{padding:32,width:"100%"},children:e.jsx(w,{name:"amount",control:c,rules:{required:!0,validate:i=>!i||parseFloat(i)<=B||"Amount cannot exceed $10,000,000"},defaultValue:0,render:({field:{value:i,...l}})=>{var j;return e.jsx(O,{id:"amount",label:"Subscription Amount",error:!!r.amount,helperText:((j=r.amount)==null?void 0:j.message)||r.amount&&"Subscription Amount is required.",slotProps:{inputLabel:{shrink:i!=null},input:{inputComponent:k},htmlInput:{...l,value:i,decimalScale:2,allowNegative:!1,isAllowed:({floatValue:P})=>P===void 0||P<=B}}})}})})}),e.jsxs(n,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end"},children:[e.jsx(n,{sx:{mr:1},children:e.jsx(I,{variant:"contained",size:"small",onClick:()=>m(),children:"Close"})}),e.jsx(I,{variant:"contained",color:"primary",size:"small",type:"submit",disabled:y,children:"Create"})]})]}),o==="editing"&&e.jsxs(n,{sx:{minWidth:"340px"},children:[e.jsx(n,{sx:{mb:4,borderBottom:"2px solid lightGray",display:"inline-flex"},children:e.jsx(N,{variant:"h6",children:"Edit Subscription"})}),e.jsx(n,{sx:{display:"flex",mb:2},children:e.jsx(v,{elevation:24,style:{padding:"32px 32px 0",width:"100%"},children:e.jsx(w,{defaultValue:t==null?void 0:t.billingPeriod,name:"billingPeriod",control:c,rules:{required:!0},render:({field:i})=>{var l;return e.jsxs(G,{error:!!r.billingPeriod,children:[e.jsx(V,{color:"#1B75BA",children:"SUBSCRIPTION PERIOD"}),e.jsxs($,{row:!0,"aria-label":"billingPeriod",...i,children:[e.jsx(M,{value:"Monthly",control:e.jsx(q,{color:"primary"}),label:"Monthly"}),e.jsx(M,{value:"Annually",control:e.jsx(q,{color:"primary"}),label:"Annually"})]}),((l=r.billingPeriod)==null?void 0:l.type)==="required"&&e.jsx(X,{error:!0,children:"Please choose the repeat Perio
1d."})]})}})})}),e.jsx(n,{sx:{display:"flex",alignItems:"center",mb:2},children:e.jsx(v,{elevation:24,style:{padding:32,width:"100%"},children:e.jsx(O,{label:"Subscription Name",name:"name",error:!!r.name,helperText:r.name&&"Company name is required.",...g("name",{required:!0}),defaultValue:(t==null?void 0:t.name)||""})})}),e.jsx(n,{sx:{display:"flex",alignItems:"center",mt:2,mb:4},children:e.jsx(v,{elevation:24,style:{padding:32,width:"100%"},children:e.jsx(w,{name:"amount",control:c,rules:{required:!0,validate:i=>!i||parseFloat(i)<=B||"Amount cannot exceed $10,000,000"},defaultValue:(t==null?void 0:t.amount)||0,render:({field:{value:i,...l}})=>{var j;return e.jsx(O,{defaultValue:(t==null?void 0:t.amount)||"",id:"amount",label:"Subscription Amount",error:!!r.amount,helperText:((j=r.amount)==null?void 0:j.message)||r.amount&&"Subscription Amount is required.",slotProps:{inputLabel:{shrink:i!=null},input:{inputComponent:k},htmlInput:{...l,value:i,decimalScale:2,allowNegative:!1,isAllowed:({floatValue:P})=>P===void 0||P<=B}}})}})})}),e.jsxs(n,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end"},children:[e.jsx(n,{sx:{mr:1},children:e.jsx(I,{variant:"contained",size:"small",onClick:()=>m(),children:"Close"})}),e.jsx(I,{variant:"contained",color:"primary",size:"small",type:"submit",disabled:y,children:"Update"})]})]}),o==="deleting"&&e.jsxs(n,{children:[e.jsx(N,{variant:"h5",style:{width:"400px"},children:"Are you sure you want to delete this subscription?"}),e.jsxs(n,{sx:{display:"flex",alignItems:"center",my:2},children:[e.jsx(n,{sx:{mr:1},children:e.jsx("strong",{children:"Name: "})}),e.jsx(N,{variant:"body1",children:t.name})]}),e.jsxs(n,{sx:{display:"flex",alignItems:"center",mt:2,mb:4},children:[e.jsx(n,{sx:{mr:1},children:e.jsx("strong",{children:"Amount: "})}),e.jsx(N,{variant:"body1",children:e.jsx(k,{displayType:"text",decimalScale:0,value:t.amount})})]}),e.jsxs(n,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end"},children:[e.jsx(n,{sx:{mr:1},children:e.jsx(le,{size:"small",onClick:()=>m(),children:"Cancel"})}),e.jsx(I,{variant:"contained",style:{backgroundColor:"#C46E6E",color:"#FFFFFF"},size:"small",type:"submit",disabled:y,children:"Delete"})]})]})]})]})})]})})})};Q.propTypes={subsc:u.shape({name:u.string,id:u.string,billingPeriod:u.string,amount:u.number}),modalStatus:u.string.isRequired,open:u.bool.isRequired,onClose:u.func.isRequired,getSubscriptions:u.func};const fe=[{id:"name",label:"NAME"},{id:"amount",label:"AMOUNT"},{id:"billingPeriod",label:"BILLING"},{id:"status",label:"STATUS"},{id:"actions",label:"",isEmpty:!0,align:"right"}],Z=({visible:o})=>{const[a,m]=T.useState({companyName:""}),[t,S]=p.useState(0),[s,C]=p.useState(20),[g,c]=p.useState(!1),[F,r]=p.useState(""),[R,h]=p.useState({}),{loading:y,error:f,pagination:E,subscriptions:A,getSubscriptions:b}=Y(),D=p.useCallback((x=!1)=>{h({}),r(""),c(!1),x&&b()},[b]);T.useEffect(()=>{o&&b(a.companyName,t,s)},[b,o,t,s,a,D]);const i=p.useCallback((x,d)=>{S(0),m(ee=>({...ee,[d]:x}))},[]),l=(x,d)=>{t!==x&&S(x),s!==d&&C(d)},j=[{label:"Subscription",onFilterChange:x=>i(x,"companyName"),endAdornment:{type:"clear",action:()=>i("","companyName")},breakpoint:12}],P=x=>x.map(d=>({id:d.id,name:d.name||"--",amount:e.jsx(k,{displayType:"text",decimalScale:2,value:d.amount||0}),billingPeriod:d.billingPeriod||"--",status:de[d.status]||"--",actions:e.jsx(xe,{options:d.status==="active"?[{name:"Edit Subscription",callback:()=>{r("editing"),h(d),c(!0)}}]:[{name:"Edit Subscription",callback:()=>{r("editing"),h(d),c(!0)}},{name:"Delete Subscription",callback:()=>{r("deleting"),h(d),c(!0)}}]})}));return e.jsxs(n,{hidden:!o,sx:{mt:5},children:[e.jsx(Q,{open:g,onClose:D,modalStatus:F,subsc:R}),e.jsx(_,{padding:16,children:e.jsx(W,{inputs:j,justifyContent:"start",actions:e.jsx(I,{type:"button",variant:"contained",color:"primary",disableElevation:!0,onClick:()=>{r("creating"),c(!0)},size:"small",children:"Create Subscription"})})}),y&&e.jsx(L,{}),e.jsx(H,{columns:fe,rows:P(A),pagination:E,hasPagination:!0,controlledPage:t,handleChangePageCallback:l,retrieveErrorData:f||null})]})};Z.propTypes={visible:u.bool.isRequired};const ht=()=>{const{user:o}=me(),[a,m]=T.useState(0);return e.jsxs(e.Fragment,{children:[e.jsx(n,{sx:{mb:4},children:e.jsx(N,{variant:"h1",children:"PAYMENTS"})}),e.jsx(K,{onChange:m}),e.jsx(he,{user:o,visible:a===0}),e.jsx(J,{admin:!0,visible:a===1}),e.jsx(Z,{admin:!0,visible:a===2})]})};export{ht as Companies,ht as default};

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.