ruạṛ
import{u as f,p as h,c as s,ax as k,bc as x,ay as C,aG as y,fe as _,j as p,H as v,ff as A,dZ as D,fg as w,aq as B,ad as T,c1 as E,e as I,D as S,J as F,bi as P,T as j,a1 as M,dt as O,dv as V,du as G,fh as z,W as H,k as L,a6 as N,a7 as $,a8 as g,fi as q}from"./bundle.9abe88c8.js";import{D as J}from"./DataTableColumnsPicker-72027136.js";import{I as U}from"./ImportButton-83a39628.js";function W({isVisible:a,setIsVisible:r,selectedExpenses:c,setSelected:l}){const[o]=f(),[u,i]=h.useState(""),d=w(),{isAdmin:b,isOwner:e}=B();h.useEffect(()=>()=>{i("")},[]);const n=()=>{x.processing();const t=c.map(({id:m})=>m);d(t,"bulk_categorize",{category_id:u}),l&&l([]),r(!1),i("")};return p(T,{title:`${o("change")} ${o("category")}`,visible:a,onClose:r,overflowVisible:!0,children:[p("p",{children:[o("recurring_expenses"),":"]}),s("ul",{children:c.map(({id:t,number:m})=>s("li",{children:m},t))}),s(E,{endpoint:I("/api/v1/expense_categories"),inputOptions:{value:u,label:o("category")??""},entryOptions:{id:"id",label:"name",value:"id"},sortBy:"name|asc",onChange:t=>t.resource?i(t.resource.id):null}),p("p",{children:[s("span",{className:"capitalize",children:o("manage")})," ",s(S,{className:"lowercase",to:"/settings/expense_settings",renderSpan:!b&&!e,children:o("expense_categories")})]}),s(F,{onClick:n,children:o("save")})]})}const Z=()=>{const[a]=f(),r=P(),c=e=>e.some(({documents:n})=>n.length),l=e=>e.flatMap(({documents:n})=>n.map(({id:t})=>t)),o=e=>e.every(({should_be_invoiced:n,invoice_id:t})=>n&&!t.length),u=(e,n)=>{const t=l(e);r(t,"download"),n([])},[i,d]=h.useState(!1);return[({selectedResources:e,setSelected:n})=>s(k,{onClick:()=>c(e)?u(e,n):x.error("no_documents_to_download"),icon:s(C,{element:y}),children:a("documents")}),({selectedResources:e})=>o(e)&&s(_,{expenses:e,bulkAction:!0}),({selectedResources:e,setSelected:n})=>p(v,{children:[e?s(W,{isVisible:i,setIsVisible:d,selectedExpenses:e,setSelected:n}):null,p(k,{onClick:()=>e.length?d(!0):x.error("no_expenses_selected"),icon:s(C,{element:A}),children:[a("change")," ",a("category")]})]}),({selectedIds:e,setSelected:n})=>s(D,{entity:"expense",resourceIds:e,setSelected:n})]};function Y(){j("expenses");const[a]=f(),r=M(),c=[{name:a("expenses"),href:"/expenses"}],l=O(),o=V(),u=G(),i=z(),d=Z();return s(H,{title:a("expenses"),breadcrumbs:c,docsLink:"en/expenses",children:s(L,{resource:"expense",endpoint:"/api/v1/expenses?include=client,vendor,category,project&without_deleted_clients=true&without_deleted_vendors=true&sort=id|desc",columns:l,bulkRoute:"/api/v1/expenses/bulk",linkToCreate:"/expenses/create",linkToEdit:"/expenses/:id/edit",customActions:o,customFilters:u,customBulkActions:d,customFilterPlaceholder:"status",withResourcefulActions:!0,rightSide:s(N,{type:"component",guards:[$(g("create_expense"),g("edit_expense"))],component:s(U,{route:"/expenses/import"})}),leftSideChevrons:s(J,{columns:i,defaultColumns:q,table:"expense"}),linkToCreateGuards:[g("create_expense")],hideEditableOptions:!r("edit_expense"),enableSavingFilterPreference:!0})})}export{Y as default};
cải xoăn