1import{j as e,M as q,a0 as R,I as B,B as j,S as P,p as F,m as Q,n as H,q as T,T as O,aq as V,N as D,s as K,ar as z,C as $}from"./index.D89Ptodw.js";import{r as C,h as J,f as U}from"./router.CrG4uXDR.js";import{P as h}from"./charts.Xucaesy1.js";import{C as Y}from"./CurrencyInput.29OeOaKN.js";import{a as G}from"./useActiveAccounts.BaDOLXPP.js";import{a as W}from"./accountOptions.CaVhY7sp.js";import{u as A}from"./i18n.B5PADymj.js";import{u as X}from"./useInfiniteQuery.BbqtQv1s.js";import{a as Z}from"./accountsService.DNsJ4FYX.js";import{c as L}from"./creditCardsService.BKeS3dlu.js";import"./http.DWSTd2rM.js";import"./forms.DxV8EmvE.js";import"./InstitutionLogo.BPJtk7sx.js";import"./eventBus.a_hYFyd8.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};r.SENTRY_RELEASE={id:"99974e3139a959f25517126c07ed286661dfae1f"};var t=new r.Error().stack;t&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[t]="c3eea58e-2db6-40fb-9a81-ab601253bd59",r._sentryDebugIdIdentifier="sentry-dbid-c3eea58e-2db6-40fb-9a81-ab601253bd59")}catch{}})();const ee="PaymentModal-module__field___UoAxv",te="PaymentModal-module__actions___l9TfL",M={field:ee,actions:te};function k({isOpen:r,onClose:t,statement:_,defaultAccountId:l,onConfirm:v,loading:x}){const{t:d}=A("finances"),u=_?.remaining_amount?.raw??0,{accounts:p}=G({enabled:r}),b=C.useMemo(()=>p.filter(n=>n.type!=="credit_card"),[p]),[s,m]=C.useState({amount:u,payment_account_id:"",payment_date:""}),[o,N]=C.useState({});C.useEffect(()=>{if(!r)return;const n=new Date().toISOString().slice(0,10);m({amount:u,payment_account_id:l?String(l):"",payment_date:n}),N({})},[r,u,l]);function E(){const n={};return(!s.amount||Number(s.amount)<=0)&&(n.amount=d("creditCardStatements.payment.errors.amountRequired")),Number(s.amount)>u+.001&&(n.amount=d("creditCardStatements.payment.errors.amountExceeds")),s.payment_account_id||(n.payment_account_id=d("creditCardStatements.payment.errors.accountRequired")),s.payment_date||(n.payment_date=d("creditCardStatements.payment.errors.dateRequired")),N(n),Object.keys(n).length===0}function g(n){n.preventDefault(),E()&&v({amount:Number(s.amount),payment_account_id:Number(s.payment_account_id),payment_date:s.payment_date})}return e.jsx(q,{isOpen:r,onClose:t,title:d("creditCardStatements.payment.title"),size:"small",children:e.jsxs("form",{onSubmit:g,noValidate:!0,children:[e.jsx("div",{className:M.field,children:e.jsx(Y,{label:d("creditCardStatements.payment.amount"),name:"amount",value:s.amount,onValueChange:n=>m(f=>({...f,amount:n||0})),error:o.amount})}),e.jsx("div",{className:M.field,children:e.jsx(R,{label:d("creditCardStatements.payment.account"),value:s.payment_account_id,onChange:n=>m(f=>({...f,payment_account_id:n})),options:W(b),placeholder:d("creditCardStatements.payment.accountPlaceholder"),error:o.payment_account_id})}),e.jsx("div",{className:M.field,children:e.jsx(B,{type:"date",label:d("creditCardStatements.payment.date"),value:s.payment_date,onChange:n=>m(f=>({...f,payment_date:n.target.value})),error:o.payment_date})}),e.jsxs("div",{className:M.actions,children:[e.jsx(j,{type:"button",variant:"secondary",onClick:t,children:d("creditCardStatements.payment.cancel")}),e.jsx(j,{type:"submit",loading:x,children:d("creditCardStatements.payment.confirm")})]})]})})}k.propTypes={isOpen:h.bool.isRequired,onClose:h.func.isRequired,statement:h.object,defaultAccountId:h.oneOfType([h.number,h.string]),onConfirm:h.func.isRequired,loading:h.bool};const ae="CreditCardStatements-module__container___YKAvV",ne="CreditCardStatements-module__header___je7L-",se="CreditCardStatements-module__headerInfo___Wl8Nv",re="CreditCardStatements-module__title___F-HEd",ie="CreditCardStatements-module__summary___ZJvE6",de="CreditCardStatements-module__summaryItem___wVEii",oe="CreditCardStatements-module__summaryLabel___cFr17",ce="CreditCardStatements-module__list___4vsad",me="CreditCardStatements-module__card___m8xf4",le="CreditCardStatements-module__cardHeader___QoIxH",ue="CreditCardStatements-module__period___-IRJg",_e="CreditCardStatements-module__cardBody___XJscB",fe="CreditCardStatements-module__row___kOHEs",pe="CreditCardStatements-module__cardActions___s1Qng",ye="CreditCardStatements-module__empty___Enhxx",he="CreditCardStatements-module__loadM
1ore___fuVTS",a={container:ae,header:ne,headerInfo:se,title:re,summary:ie,summaryItem:de,summaryLabel:oe,list:ce,card:me,cardHeader:le,period:ue,cardBody:_e,row:fe,cardActions:pe,empty:ye,loadMore:he};function Ce(){return e.jsxs("div",{className:a.container,"aria-hidden":"true",children:[e.jsxs("div",{className:a.header,children:[e.jsx(P,{variant:"rect",width:"120px",height:"38px"}),e.jsx(P,{variant:"text",width:"200px"})]}),e.jsx(P,{variant:"rect",width:"100%",height:"80px"}),e.jsx("div",{className:a.list,children:Array.from({length:3}).map((r,t)=>e.jsx(P,{variant:"rect",width:"100%",height:"200px"},t))})]})}const xe=10;function ge(r="/personal/accounts"){const{id:t}=J(),_=U(),{t:l}=A(["pages","finances"]),{showSuccess:v,showError:x}=F(),d=Q(),[u,p]=C.useState(null),[b,s]=C.useState(!1),m=H({queryKey:T.accounts.detail(t),queryFn:()=>Z.getAccount(t)}),o=X({queryKey:T.creditCards.statements(t),queryFn:({pageParam:c})=>L.getStatements(t,c,xe),initialPageParam:1,getNextPageParam:(c,y)=>{const I=c?.meta?.current_page||y.length,w=c?.meta?.last_page||1;return I<w?I+1:void 0}}),N=m.data??null,E=(o.data?.pages??[]).flatMap(c=>c?.statements??[]),g=o.data?.pages?.[0]?.meta?.total||0;C.useEffect(()=>{(m.isError||o.isError)&&x(l("finances:creditCardStatements.errors.loadFailed"))},[m.isError,o.isError]);const n=async()=>{await Promise.all([d.invalidateQueries({queryKey:T.creditCards.statements(t)}),d.invalidateQueries({queryKey:T.accounts.all})])};async function f(){o.isFetchingNextPage||!o.hasNextPage||await o.fetchNextPage()}async function S({amount:c,payment_account_id:y,payment_date:I}){s(!0);try{const w=await L.payStatement(u.id,{amount:c,payment_account_id:y,payment_date:I});w.success&&(v(w.message),p(null),await n())}catch(w){x(w?.response?.data?.message||l("finances:creditCardStatements.errors.payFailed"))}finally{s(!1)}}async function i(c){s(!0);try{const y=await L.reopenStatement(c.id);y.success&&(v(y.message),await n())}catch(y){x(y?.response?.data?.message||l("finances:creditCardStatements.errors.reopenFailed"))}finally{s(!1)}}return{account:N,statements:E,loading:m.isLoading||o.isLoading,loadingMore:o.isFetchingNextPage,hasMore:!!o.hasNextPage,total:g,payTarget:u,actionLoading:b,setPayTarget:p,handlePay:S,handleReopen:i,handleLoadMore:f,handleOpenEntries:c=>_(`${r}/${t}/statements/${c.id}`),handleBack:()=>_(r)}}const Se={open:"info",closed:"warning",partial:"warning",paid:"success"};function Re({basePath:r="/personal/accounts"}){const{t}=A(["pages","finances"]),{account:_,statements:l,loading:v,loadingMore:x,hasMore:d,payTarget:u,actionLoading:p,setPayTarget:b,handlePay:s,handleReopen:m,handleLoadMore:o,handleOpenEntries:N,handleBack:E}=ge(r),[g,n]=C.useState(null);async function f(){g&&(await m(g),n(null))}if(v&&!_)return e.jsx(Ce,{});const S=_?.credit_card;return e.jsxs("div",{className:a.container,children:[e.jsx(O,{}),e.jsxs("header",{className:a.header,children:[e.jsxs(j,{variant:"secondary",onClick:E,children:[e.jsx(V,{size:16})," ",t("finances:creditCardStatements.back")]}),e.jsxs("div",{className:a.headerInfo,children:[e.jsx(D,{size:20}),e.jsx("h1",{className:a.title,children:_?.name})]})]}),S&&e.jsxs("div",{className:a.summary,children:[e.jsxs("div",{className:a.summaryItem,children:[e.jsx("span",{className:a.summaryLabel,children:t("finances:creditCardStatements.limit")}),e.jsx("strong",{children:S.credit_limit?.formatted||"â"})]}),e.jsxs("div",{className:a.summaryItem,children:[e.jsx("span",{className:a.summaryLabel,children:t("finances:creditCardStatements.debt")}),e.jsx("strong",{children:S.current_debt?.formatted})]}),e.jsxs("div",{className:a.summaryItem,children:[e.jsx("span",{className:a.summaryLabel,children:t("finances:creditCardStatements.available")}),e.jsx("strong",{children:S.available_limit?.formatted||"â"})]})]}),l.length===0?e.jsx("p",{className:a.empty,children:t("finances:creditCardStatements.empty")}):e.jsx("div",{className:a.list,children:l.map(i=>e.jsxs("div",{className:a.card,children:[e.jsxs("div",{className:a.cardHeader,children:[e.jsxs("span",{className:a.period,children:[i.period_start," â ",i.period_end]}),e.jsx(K,{variant:Se[i.status]||"info",children:i.status_label})]}),e.jsxs("div",{className:a.cardBody,children:[e.jsxs("div",{className:a.row,children:[e.jsx("span",{children:t("finances:creditCardStatements.dueDate")}),e.jsx("strong",{children:i.due_date_formatted})]}),e.jsxs("div",{className:a.row,children:[e.jsx("span",{children:t("finances:creditCardStatements.total")}),e.jsx("strong",{children:i.total_amount?.formatted})]}),e.jsxs("div",{className:a.row,children:[e.jsx("span",{children:t("finances:creditCardStatements.paid")}),e.jsx("strong",{children:i.paid_amount?.formatted})]}),e.jsxs("div",{className:a.row,children:[e.jsx("span",{children:t("finances:creditCardStatements.remaining")}),e.jsx("strong",{children:i.remaining_amount?.formatted})]})]}),e.jsxs("div",{className:a.cardActions,children:[e.jsxs(j,{variant:"secondary",onClick:()=>N(i),children:[e.jsx(z,{size:14})," ",t("finances:creditCardStatements.entriesButton")]}),i.status!=="paid"&&(i.total_amount?.raw??0)>0&&e.jsx(j,{onClick:()=>b(i),children:t("finances:creditCardStatements.payButton")}),i.has_payments&&e.jsx(j,{variant:"secondary",onClick:()=>n(i),children:t("finances:creditCardStatements.reopenButton")})]})]},i.id))}
1),d&&e.jsx("div",{className:a.loadMore,children:e.jsx(j,{variant:"secondary",loading:x,onClick:o,children:t("finances:creditCardStatements.loadMore")})}),e.jsx(k,{isOpen:!!u,onClose:()=>b(null),statement:u,defaultAccountId:S?.linked_account_id,onConfirm:s,loading:p}),e.jsx($,{isOpen:!!g,onClose:()=>n(null),onConfirm:f,title:t("finances:creditCardStatements.reopenConfirm.title"),message:t("finances:creditCardStatements.reopenConfirm.message"),confirmText:t("finances:creditCardStatements.reopenConfirm.confirm"),confirmVariant:"warning",isLoading:p})]})}export{Re as default}; 2//# sourceMappingURL=index.Ctsg-g6w.js.map
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.