34 lines
23 KiB
JavaScript
34 lines
23 KiB
JavaScript
import{a as ge,r as H,e as q,u as O,x as ie,A as $e,f as ee,d as te,g as ve,ft as re,c as a,D as Se,h as A,m as G,ad as xe,s as ye,b0 as me,b1 as ke,bk as R,z as U,j as C,ck as J,p as y,H as F,fe as be,cB as Ce,bg as pe,ae as X,fu as Te,aL as Ie,ci as Ne,d4 as he,fd as we,fv as De,fw as Pe,fx as Me,G as Ke,bq as Ee,bH as Be,bI as Ae,bs as Fe,J as oe,fy as Oe,fz as Qe,bc as M,a7 as Z,fA as je,fB as Ve,eT as Re,fC as ze,bt as D,bA as Le,fD as He,ah as qe,af as le,eD as Ge,fE as Ue,bw as We,O as Je,Z as Ze,T as Xe,k as Ye,a3 as et,a4 as tt,a5 as se}from"./bundle.0b839d67.js";import{E as at,A as ae,T as Y,u as nt,a as fe,b as st}from"./bundle.5cb8dfe1.js";import{u as ot,a as lt}from"./bundle.a80c43bb.js";import{I as it}from"./bundle.9ee86cb5.js";import{c as rt,b as ct}from"./bundle.ee417884.js";import{I as B}from"./bundle.756326ba.js";import{P as V}from"./bundle.51e1486d.js";import{S as dt}from"./bundle.ab2b2c18.js";/**
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
*
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
*
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
|
*
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
*/function ce(e){return ge(["/api/v1/invoices",e],()=>H("GET",q("/api/v1/invoices?client_status=:client_status&filter=:filter&client_id=:client_id&filter_deleted_clients=:without_deleted_clients&per_page=:per_page&page=:page&include=:include",{per_page:e.perPage??"100",page:e.currentPage??"1",client_status:e.clientStatus??"all",client_id:e.clientId??"",filter:e.filter??"",without_deleted_clients:e.withoutDeletedClients||!0,include:e.include||""})).then(s=>s.data.data),{enabled:e.enabled??!0,staleTime:1/0})}function ut(){const{t:e}=O(),s=ie(),n=$e(),{dateFormat:o}=ee(),i=te(),t=ve(),r=ot(),{data:$}=ce({perPage:1e3}),{data:k}=re({perPage:1e3}),b=m=>{var l;return((l=$==null?void 0:$.find(g=>g.id===m))==null?void 0:l.number)||""},v=m=>{var l;return((l=k==null?void 0:k.find(g=>g.id===m))==null?void 0:l.number)||""};return[{id:"status",label:e("status"),format:(m,l)=>a(Se,{to:A("/transactions/:id/edit",{id:l.id}),renderSpan:t("bank_transaction",l),children:a(at,{transaction:l})})},{id:"deposit",label:e("deposit"),format:(m,l)=>{var g;if(l.base_type===ae.Credit)return i(l.amount,(g=s==null?void 0:s.settings)==null?void 0:g.country_id,l.currency_id)}},{id:"withdrawal",label:e("withdrawal"),format:(m,l)=>{var g;if(l.base_type===ae.Debit)return i(l.amount,(g=s==null?void 0:s.settings)==null?void 0:g.country_id,l.currency_id)}},{id:"date",label:e("date"),format:m=>G(m,o)},{id:"description",label:e("description"),format:m=>a(xe,{width:"auto",tooltipElement:a("div",{className:"w-full max-h-48 overflow-auto whitespace-normal break-all",children:a("article",{className:ye("prose prose-sm",{"prose-invert":n.dark_mode}),dangerouslySetInnerHTML:{__html:me(r(m))}})}),children:a("span",{children:ke(me(r(m))).slice(0,50)})})},{id:"invoice_ids",label:e("invoices"),format:m=>m&&a("div",{className:"flex space-x-2",children:m.toString().split(",").map(l=>a(R,{to:A("/invoices/:id/edit",{id:l}),children:b(l)},l))})},{id:"expense_id",label:e("expense"),format:m=>m&&a("div",{className:"flex space-x-2",children:m.toString().split(",").map(l=>a(R,{to:A("/expenses/:id/edit",{id:l}),children:v(l)},l))})}]}function mt(e){const[s]=O(),n=U(),o=(i,t)=>{e.setSearchParams(r=>({...r,[i]:t}))};return a("div",{className:"absolute w-full top-full left-0 mt-1 text-center z-10",style:{color:n.$3,colorScheme:n.$0,backgroundColor:n.$1,borderColor:n.$4},children:C("div",{className:"flex flex-col items-center pt-3 pb-6 space-y-3",style:{color:n.$3,colorScheme:n.$0,backgroundColor:n.$1,borderBottom:`1px solid ${n.$5}`},children:[C("div",{className:"flex justify-evenly w-full",style:{color:n.$3,colorScheme:n.$0,backgroundColor:n.$1,borderColor:n.$4},children:[a(J,{changeOverride:!0,style:{color:n.$3,colorScheme:n.$0,backgroundColor:n.$1,borderColor:n.$4},width:"12rem",label:`${s("min")} ${s("amount")}`,value:e.searchParams.minAmount,onValueChange:i=>o("minAmount",isNaN(Number(i))?0:Number(i))}),a(J,{changeOverride:!0,style:{color:n.$3,colorScheme:n.$0,backgroundColor:n.$1,borderColor:n.$4},width:"12rem",label:`${s("max")} ${s("amount")}`,value:e.searchParams.maxAmount,onValueChange:i=>o("maxAmount",isNaN(Number(i))?0:Number(i))})]}),C("div",{className:"flex justify-evenly w-full",children:[a(J,{style:{color:n.$3,colorScheme:n.$0,backgroundColor:n.$1,borderColor:n.$4},className:"w-full",width:"12rem",label:s("start"),type:"date",value:e.searchParams.startDate,onValueChange:i=>o("startDate",i||"")}),a(J,{changeOverride:!0,style:{color:n.$3,colorScheme:n.$0,backgroundColor:n.$1,borderColor:n.$4},className:"w-full",width:"12rem",label:s("end"),type:"date",value:e.searchParams.endDate,onValueChange:i=>o("endDate",i||"")})]})]})})}function ht(e){const s=e.dataKey==="invoices",n=e.dataKey==="payments",o=e.dataKey==="expenses",[i,t]=y.useState(!1),[r,$]=y.useState(!1),k=(v,_)=>{e.setSearchParams(m=>({...m,[v]:_}))},b=U();return C(F,{children:[a(be,{initiallyVisible:i,setVisible:t,setSelectedIds:e.setSelectedIds,onChange:()=>{}}),a(Ce,{initiallyVisibleModal:r,setVisible:$,setSelectedIds:e.setSelectedIds,onChange:()=>{}}),C("div",{className:"flex items-center pr-3",children:[a(J,{changeOverride:!0,style:{color:b.$3,colorScheme:b.$0,backgroundColor:b.$1,borderColor:b.$4},placeholder:pe(`search_${e.dataKey}`,{count:""}),value:e.searchParams.searchTerm,onValueChange:v=>k("searchTerm",v)}),s||n||o?a(F,{children:a(X,{element:Te,className:"ml-3 cursor-pointer",size:28,onClick:()=>e.setIsFilterModalOpened(v=>!v)})}):a(F,{children:a(X,{element:Ie,className:"ml-3 cursor-pointer",size:28,onClick:()=>e.dataKey==="vendors"?$(!0):t(!0)})}),e.isFilterModalOpened&&a(mt,{searchParams:e.searchParams,setSearchParams:e.setSearchParams})]})]})}/**
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
*
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
|
*
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
|
*
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
*/const ft={[B.Cancelled]:"cancelled",[B.Unpaid]:"unpaid",[B.PastDue]:"past_due",[B.Draft]:"draft",[B.Sent]:"sent",[B.Partial]:"partial",[B.Paid]:"paid",[B.Cancelled]:"cancelled",[B.Reversed]:"reversed"};/**
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
*
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
|
*
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
|
*
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
*/const yt={[V.PartiallyUnapplied]:"partially_unapplied",[V.Unapplied]:"unapplied",[V.Pending]:"pending",[V.Cancelled]:"cancelled",[V.Failed]:"failed",[V.Completed]:"completed",[V.PartiallyRefunded]:"partially_refunded",[V.Refunded]:"refunded"};function bt(e){const s=te(),{dateFormat:n}=ee(),o=U();return C("li",{style:{color:o.$3,colorScheme:o.$0,backgroundColor:o.$1,borderColor:o.$4},className:"flex justify-between w-full cursor-pointer p-4 border-b last:border-b-0",onClick:()=>e.selectItem(e.resourceItem.id,e.resourceItem.clientId),children:[C("div",{className:"flex items-center",children:[a(Ne,{style:{color:o.$3,colorScheme:o.$0,backgroundColor:o.$1,borderColor:o.$4},checked:e.isItemChecked,onClick:()=>e.selectItem(e.resourceItem.id)}),C("div",{className:"flex flex-col items-start",style:{color:o.$3,colorScheme:o.$0,backgroundColor:o.$1,borderColor:o.$4},children:[a("span",{className:"text-sm",children:e.resourceItem.name}),a("span",{className:"text-sm",children:e.resourceItem.number})]})]}),C("div",{className:"flex items-center flex-grow pr-3",style:{color:o.$3,colorScheme:o.$0,backgroundColor:o.$1,borderColor:o.$4},children:[C("div",{className:"flex flex-col flex-grow pl-8 pr-3",style:{color:o.$3,colorScheme:o.$0,backgroundColor:o.$1,borderColor:o.$4},children:[a("span",{className:"text-sm",style:{color:o.$3,colorScheme:o.$0,backgroundColor:o.$1,borderColor:o.$4},children:e.resourceItem.clientName}),a("span",{className:"text-sm",style:{color:o.$3,colorScheme:o.$0,backgroundColor:o.$1,borderColor:o.$4},children:G(e.resourceItem.date||"",n)})]}),typeof e.resourceItem.amount=="number"&&a("span",{className:"text-sm",style:{color:o.$3,colorScheme:o.$0,backgroundColor:o.$1,borderColor:o.$4},children:s(e.resourceItem.amount||0,e.resourceItem.country_id,e.resourceItem.currency_id)})]}),a("div",{className:"flex items-center",style:{color:o.$3,colorScheme:o.$0,backgroundColor:o.$1,borderColor:o.$4},children:e.resourceItem.statusId?C(F,{children:[e.dataKey==="invoices"&&a(he,{for:ft,code:e.resourceItem.statusId}),e.dataKey==="payments"&&a(he,{for:yt,code:e.resourceItem.statusId})]}):a(F,{children:e.dataKey==="expenses"&&a(we,{entity:e.resourceItem})})})]},e.resourceItem.id)}function W(e){const[s]=O(),n=U(),o=te(),[i,t]=y.useState({searchTerm:"",minAmount:0,maxAmount:0,startDate:"",endDate:""}),r=e.dataKey==="vendors",$=e.dataKey==="expenses",k=e.dataKey==="payments",b=e.dataKey==="invoices",v=e.dataKey==="categories",[_,m]=y.useState(),{data:l}=De({enabled:b}),{data:g}=ce({include:"client",clientStatus:"unpaid",filter:i.searchTerm,clientId:_,enabled:b}),{data:p}=Pe({filter:i.searchTerm,enabled:r}),{data:K}=Me({filter:i.searchTerm,enabled:v}),{data:S}=rt({include:"client",filter:i.searchTerm,enabled:k,matchTransactions:!0}),{data:x}=re({include:"client",filter:i.searchTerm,enabled:$,matchTransactions:!0}),[h,N]=y.useState(),[Q,P]=y.useState(),[j,d]=y.useState(!1),c=f=>{var u,T;return!!((T=(u=e.selectedIds)==null?void 0:u.find(E=>E===f))!=null&&T.length)},I=(f,u)=>{var de,ue;m(u);const T=(de=e.selectedIds)==null?void 0:de.find(ne=>f===ne);let E;T!=null&&T.length?(E=(ue=e.selectedIds)==null?void 0:ue.filter(ne=>ne!==f),e.setSelectedIds(E)):(E=[...e.selectedIds||[],f],e.setSelectedIds(E))},z=f=>{var u;return(u=Q==null?void 0:Q.find(({id:T})=>T===f))==null?void 0:u.display_name},w=f=>f==null?void 0:f.map(u=>{var T,E;return{id:u.id,number:u.number,name:u.name,clientName:z(u.client_id),statusId:u.status_id,amount:u.amount,date:u.date,clientId:u.client_id,should_be_invoiced:u.should_be_invoiced,invoice_id:u.invoice_id,payment_date:u.payment_date,transaction_reference:u.transaction_reference,payment_type_id:u.payment_type_id,country_id:u.country_id||((T=u.client)==null?void 0:T.country_id),currency_id:u.currency_id||((E=u.client)==null?void 0:E.settings.currency_id)}}),L=f=>((h==null?void 0:h.filter(u=>c(u.id)&&u.currency_id===f))||[]).reduce((u,T)=>u+T.amount,0)??0,_e=()=>Ke((h==null?void 0:h.filter(f=>c(f.id)))||[]).pluck("currency_id").unique().toArray();return y.useEffect(()=>{P(l),N(w(b?g:r?p:v?K:k?S:x))},[e.dataKey,g,p,K,l,S,x]),y.useEffect(()=>{var f;b&&!((f=e.selectedIds)!=null&&f.length)&&m("")},[e.selectedIds]),C("div",{className:ye("flex flex-col flex-1 w-full relative",{"pb-7":e.calculateTotal}),style:{color:n.$3,colorScheme:n.$0,backgroundColor:n.$1,borderColor:n.$4},children:[a("div",{style:{color:n.$3,colorScheme:n.$0,backgroundColor:n.$1,borderColor:n.$4},className:`flex justify-center px-5 py-3 relative border-b border-t ${e.className}`,children:a(ht,{dataKey:e.dataKey,searchParams:i,setIsFilterModalOpened:d,isFilterModalOpened:j,setSearchParams:t,setSelectedIds:e.setSelectedIds})}),a("ul",{style:{height:b?400:200,color:n.$3,colorScheme:n.$0,backgroundColor:n.$1,borderColor:n.$4},className:"flex flex-col grow justify-start overflow-y-auto",children:h==null?void 0:h.map(f=>{var u;return(c(f.id)||!((u=e.selectedIds)!=null&&u.length)||b||$)&&a(bt,{isItemChecked:c(f.id),resourceItem:f,selectItem:I,dataKey:e.dataKey},f.id)})}),e.calculateTotal&&!!(h!=null&&h.filter(f=>c(f.id)).length)&&a("div",{className:"absolute flex w-full bottom-2 text-sm",children:C("div",{className:"flex flex-1 justify-center items-center space-x-1",children:[a("span",{children:h==null?void 0:h.filter(f=>c(f.id)).length}),a("span",{children:s("selected")}),a("span",{children:"·"}),a("span",{children:_e().map((f,u)=>o(L(f),h==null?void 0:h[u].country_id,f)).join(" | ")})]})})]})}function Ct(e){const[s]=O(),n=Ee(),{transactionRule:o}=e,i=Be(Ae),[t,r]=y.useState(!1),[$,k]=y.useState(!0),[b,v]=y.useState([]),[_,m]=y.useState([]),[l,g]=y.useState([]),[p,K]=y.useState([]),[S,x]=y.useState([]),h=[e.isCreditTransactionType?s("create_payment"):s("create_expense"),e.isCreditTransactionType?s("link_payment"):s("link_expense")],N=c=>{c.preventDefault(),!(!b.length||t)&&(r(!0),M.processing(),H("POST",q("/api/v1/bank_transactions/match"),{transactions:[{id:e.transactionDetails.transaction_id,invoice_ids:b.join(",")}]}).then(()=>{n.invalidateQueries([i]),Z(["invoices","bank_transactions"]),M.success("converted_transaction")}).finally(()=>r(!1)))},Q=c=>{c.preventDefault(),!(!p.length||t)&&(r(!0),M.processing(),H("POST",q("/api/v1/bank_transactions/match"),{transactions:[{id:e.transactionDetails.transaction_id,payment_id:p.join(",")}]}).then(()=>{n.invalidateQueries([i]),Z(["invoices","payments","bank_transactions"]),M.success("linked_transaction")}).finally(()=>r(!1)))},P=c=>{c.preventDefault(),!(!_.length&&!l.length||t)&&(r(!0),M.processing(),H("POST",q("/api/v1/bank_transactions/match"),{transactions:[{id:e.transactionDetails.transaction_id,vendor_id:_.join(","),ninja_category_id:l.join(",")}]}).then(()=>{n.invalidateQueries([i]),Z(["bank_transactions","expenses"]),M.success("converted_transaction")}).finally(()=>r(!1)))},j=c=>{c.preventDefault(),!(!S.length||t)&&(r(!0),M.processing(),H("POST",q("/api/v1/bank_transactions/match"),{transactions:[{id:e.transactionDetails.transaction_id,expense_id:S.join(",")}]}).then(()=>{n.invalidateQueries([i]),Z(["expenses","bank_transactions"]),M.success("linked_transaction")}).finally(()=>r(!1)))};y.useEffect(()=>{k(e.transactionDetails.status_id===Y.Converted)},[e.transactionDetails.status_id,e.isCreditTransactionType,_,b,l,p,S]),y.useEffect(()=>()=>{k(!0)},[]),y.useEffect(()=>{if(o){const{category_id:c,vendor_id:I}=o;c&&g([c]),I&&m([I])}},[o]);const d=U();return a("div",{className:"flex flex-col flex-1",children:a("div",{className:"flex flex-col flex-1",children:!$&&C(Fe,{className:"flex flex-col flex-1 border-t border-gray-200",tabs:h,height:"full",width:"full",children:[C("div",{children:[e.isCreditTransactionType?a(W,{style:{color:d.$3,colorScheme:d.$0,backgroundColor:d.$1,borderColor:d.$4},transactionDetails:e.transactionDetails,dataKey:"invoices",setSelectedIds:v,selectedIds:b,calculateTotal:!0}):C(F,{children:[a(W,{style:{color:d.$3,colorScheme:d.$0,backgroundColor:d.$1,borderColor:d.$4},transactionDetails:e.transactionDetails,dataKey:"vendors",setSelectedIds:m,selectedIds:_}),a(W,{style:{color:d.$3,colorScheme:d.$0,backgroundColor:d.$1,borderColor:d.$4},transactionDetails:e.transactionDetails,dataKey:"categories",setSelectedIds:g,selectedIds:l})]}),a("div",{className:"px-3 py-3 w-full border-t border-gray-200",children:C(oe,{style:{color:d.$3,colorScheme:d.$0,backgroundColor:d.$1,borderColor:d.$4},className:"w-full",onClick:e.isCreditTransactionType?N:P,disableWithoutIcon:!0,disabled:t||e.isCreditTransactionType&&!b.length&&!p.length||!e.isCreditTransactionType&&!_.length&&!l.length&&!S.length,children:[a(Oe,{fontSize:22}),a("span",{children:e.isCreditTransactionType?s("create_payment"):s("create_expense")})]})})]}),C("div",{children:[e.isCreditTransactionType?a(W,{style:{color:d.$3,colorScheme:d.$0,backgroundColor:d.$1,borderColor:d.$4},transactionDetails:e.transactionDetails,dataKey:"payments",setSelectedIds:K,selectedIds:p,calculateTotal:!0}):a(W,{style:{color:d.$3,colorScheme:d.$0,backgroundColor:d.$1,borderColor:d.$4},transactionDetails:e.transactionDetails,dataKey:"expenses",setSelectedIds:x,selectedIds:S,calculateTotal:!0}),a("div",{className:"px-3 py-3 w-full border-t border-gray-200",children:C(oe,{style:{color:d.$3,colorScheme:d.$0,backgroundColor:d.$1,borderColor:d.$4},className:"w-full",onClick:e.isCreditTransactionType?Q:j,disableWithoutIcon:!0,disabled:t||e.isCreditTransactionType&&!b.length&&!p.length||!e.isCreditTransactionType&&!_.length&&!l.length&&!S.length,children:[a(Qe,{fontSize:22}),a("span",{children:e.isCreditTransactionType?s("link_payment"):s("link_expense")})]})})]})]})})})}function _t(e){const[s]=O(),n=ie(),o=te(),{dateFormat:i}=ee(),{data:t}=nt({id:e.transactionId,enabled:!!e.transactionId}),{data:r}=je({id:(t==null?void 0:t.bank_integration_id)||"",enabled:!!t}),$=Y.Matched===(t==null?void 0:t.status_id),{data:k}=Ve({id:(t==null?void 0:t.bank_transaction_rule_id)||"",enabled:!!t&&$}),[b,v]=y.useState(),[_,m]=y.useState(),[l,g]=y.useState(),[p,K]=y.useState(),S=(t==null?void 0:t.base_type)===ae.Credit,x=Y.Converted!==(t==null?void 0:t.status_id),h=t&&!x&&!!e.transactionId,{data:N}=ce({enabled:S&&h}),{data:Q}=ct({id:(t==null?void 0:t.payment_id)||"",enabled:S&&h}),{data:P}=Re({id:(t==null?void 0:t.vendor_id)||"",enabled:!S&&h}),{data:j}=re({enabled:!S&&h}),{data:d}=ze({id:(t==null?void 0:t.ninja_category_id)||"",enabled:!S&&h});y.useEffect(()=>{if(t){const I=N==null?void 0:N.filter(({id:w})=>{var L;return(L=t.invoice_ids)==null?void 0:L.includes(w)});v(I);const z=j==null?void 0:j.filter(({id:w})=>{var L;return(L=t.expense_id)==null?void 0:L.includes(w)});K(z),g(d==null?void 0:d.data.data),m(Q)}},[t,d,Q,e.transactionId,j]);const c=U();return C("div",{className:"flex flex-col flex-1 border-b",style:{color:c.$3,colorScheme:c.$0,backgroundColor:c.$1,borderColor:c.$4},children:[C("div",{children:[a(D,{leftSide:s("type"),children:s(S?fe.Deposit:fe.Withdrawal)}),a(D,{leftSide:s("amount"),children:o((t==null?void 0:t.amount)||0,n==null?void 0:n.settings.country_id,t==null?void 0:t.currency_id)}),a(D,{leftSide:s("date"),children:G((t==null?void 0:t.date)||"",i)}),a(D,{leftSide:s("bank_account"),className:"cursor-pointer",children:a(R,{style:{color:c.$3,colorScheme:c.$0,backgroundColor:c.$1,borderColor:c.$4},to:A("/settings/bank_accounts/:id/details",{id:r==null?void 0:r.id}),children:r==null?void 0:r.bank_account_name})}),(t==null?void 0:t.participant)&&a(D,{leftSide:s("participant"),children:t.participant}),(t==null?void 0:t.participant_name)&&a(D,{leftSide:s("participant_name"),children:t.participant_name})]}),x?a(Ct,{transactionDetails:{base_type:(t==null?void 0:t.base_type)||"",transaction_id:(t==null?void 0:t.id)||"",status_id:(t==null?void 0:t.status_id)||""},isCreditTransactionType:S,transactionRule:k}):C(F,{children:[b==null?void 0:b.map(({id:I,number:z})=>a(D,{leftSide:s("invoice"),className:"cursor-pointer",children:a(R,{style:{color:c.$3,colorScheme:c.$0,backgroundColor:c.$1,borderColor:c.$4},to:A("/invoices/:id/edit",{id:I}),children:z})},I)),(t==null?void 0:t.payment_id)&&a(D,{leftSide:s("payment"),className:"cursor-pointer",children:a(R,{style:{color:c.$3,colorScheme:c.$0},to:A("/payments/:id/edit",{id:_==null?void 0:_.id}),children:_==null?void 0:_.number})}),(t==null?void 0:t.vendor_id)&&a(D,{leftSide:s("vendor"),className:"cursor-pointer",children:a(R,{style:{color:c.$3,colorScheme:c.$0,backgroundColor:c.$1,borderColor:c.$4},to:A("/vendors/:id",{id:P==null?void 0:P.id}),children:P==null?void 0:P.name})}),(t==null?void 0:t.ninja_category_id)&&a(D,{leftSide:s("category"),className:"cursor-pointer",children:a(R,{style:{color:c.$3,colorScheme:c.$0},to:A("/settings/expense_categories/:id/edit",{id:l==null?void 0:l.id}),children:l==null?void 0:l.name})}),p==null?void 0:p.map(({id:I,number:z,date:w})=>a(D,{leftSide:s("expense"),className:"cursor-pointer",children:a(R,{style:{color:c.$3,colorScheme:c.$0},to:A("/expenses/:id/edit",{id:I}),children:z||G(w,i)})},I))]})]})}/**
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
*
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
*
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
|
*
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
*/function gt(){const[e]=O(),s=Le(),{data:n}=He({perPage:1e3}),o=[{label:e("unmatched"),value:"unmatched",color:"white",backgroundColor:s.$1||"#6B7280",dropdownKey:"0"},{label:e("matched"),value:"matched",color:"white",backgroundColor:s.$2||"#1D4ED8",dropdownKey:"0"},{label:e("converted"),value:"converted",color:"white",backgroundColor:s.$3||"#22C55E",dropdownKey:"0"},{label:e("deposits"),value:"deposits",color:"white",backgroundColor:s.$4||"#e6b05c",dropdownKey:"0"},{label:e("withdrawals"),value:"withdrawals",color:"white",backgroundColor:s.$5||"#93C5FD",dropdownKey:"0"}];return n==null||n.forEach(i=>{o.push({label:i.bank_account_name,value:i.id,color:"white",backgroundColor:"#6B7280",queryKey:"bank_integration_ids",dropdownKey:"1",placeHolder:"bank_account"})}),o}function $t(e){const[s]=O(),{transactions:n,setSelected:o}=e,i=ie(),t=te(),{dateFormat:r}=ee(),[$,k]=y.useState(!1),[b,v]=y.useState(!1),[_,m]=y.useState(""),[l,g]=y.useState(""),p=()=>n.every(({base_type:x,status_id:h})=>x===ae.Debit&&h!==Y.Converted),K=()=>{m(""),o([]),k(!1),g("")},S=()=>{M.processing(),v(!0);const x=n.map(h=>({id:h.id,vendor_id:_,ninja_category_id:l}));H("POST",q("/api/v1/bank_transactions/match"),{transactions:x}).then(()=>{Z(["bank_transactions","expenses"]),M.success("converted_transaction"),K()}).finally(()=>v(!1))};return p()?C(F,{children:[C(qe,{title:s("create_expense"),visible:$,onClose:K,overflowVisible:!0,children:[C("div",{className:"flex flex-col space-y-3",children:[C("span",{className:"text-base font-medium",children:[s("transactions"),":"]}),a("div",{className:"flex flex-col px-10",children:n.map((x,h)=>C("div",{className:"flex justify-evenly",children:[a("span",{className:"flex-1",children:G(x.date,r)}),a("span",{className:"ml-16 flex-1",children:t(x.amount,i==null?void 0:i.settings.country_id,x.currency_id)})]},h))})]}),a(Ce,{inputLabel:s("vendor"),value:_,onChange:x=>m(x.id),onClearButtonClick:()=>m("")}),a(be,{inputLabel:s("expense_category"),value:l,onChange:x=>g(x.id),onClearButtonClick:()=>g("")}),a(oe,{behavior:"button",onClick:S,disableWithoutIcon:!0,disabled:!_&&!l||b,children:s("create_expense")})]}),a(le,{onClick:()=>k(!0),icon:a(X,{element:Ge}),children:s("create_expense")})]}):null}const vt=()=>{const[e]=O(),s=st(),n=t=>t.every(({status_id:r})=>Y.Matched===r),o=t=>t.every(({payment_id:r})=>r);return[({selectedIds:t,selectedResources:r,setSelected:$})=>r&&o(r)&&a(le,{onClick:()=>{s(t,"unlink"),$([])},icon:a(X,{element:Ue}),children:e("unlink")}),({selectedResources:t,setSelected:r})=>t&&a($t,{setSelected:r,transactions:t}),({selectedIds:t,selectedResources:r,setSelected:$})=>r&&n(r)&&a(le,{onClick:()=>{s(t,"convert_matched"),$([])},icon:a(X,{element:We}),children:e("convert")})]};function Dt(){Je("transactions");const[e]=O(),s=Ze(),n=[{name:e("transactions"),href:"/transactions"}],o=lt(),i=gt(),t=ut(),r=vt(),{dateFormat:$}=ee(),[k,b]=y.useState(),[v,_]=y.useState(""),m=l=>{if(_(l.id),l.description){let g=l.description;l.description.length>35&&(g=g.slice(0,35).concat("...")),b(g)}else b(G(l.date,$))};return C(F,{children:[a(dt,{title:k,visible:!!v,onClose:()=>_(""),size:"large",children:a(_t,{transactionId:v,setTransactionId:_})}),a(Xe,{title:e("transactions"),breadcrumbs:n,docsLink:"en/transactions/",children:a(Ye,{resource:"transaction",endpoint:"/api/v1/bank_transactions?sort=id|desc",bulkRoute:"/api/v1/bank_transactions/bulk",columns:t,linkToCreate:"/transactions/create",linkToEdit:"/transactions/:id/edit",onTableRowClick:m,customActions:o,customFilters:i,customBulkActions:r,customFilterPlaceholder:"status",rightSide:a(et,{type:"component",guards:[tt(se("create_bank_transaction"),se("edit_bank_transaction"))],component:a(it,{route:"/transactions/import"})}),withResourcefulActions:!0,linkToCreateGuards:[se("create_bank_transaction")],hideEditableOptions:!s("edit_bank_transaction")})})]})}export{Dt as default};
|