1import{n as R,H as E,D,r as u,d as B,c as y,o as F,a as T,Q as w,G as d,A as S,u as k}from"./index-C3PRlZvS.js";import{P as z}from"./PageHeader-PLupPr9R.js";import{B as H}from"./BudgetFilters-CY6e804T.js";import{B as N}from"./BudgetTable-Cp0nLklo.js";import"./TagResource-OUGSc4hg.js";import"./ParentOrganizationResource-DRWNWs2Q.js";import"./GroupResource-tmrjxvnY.js";import"./IndustryResource-M9XhWYYL.js";import"./ManufacturerResource-i5WXFyNd.js";import"./useFilter--W0njOqf.js";import"./ClientLink-CuuBmMiC.js";const O={__name:"ActiveBudgetsIndex",setup(I){const{isInAccountingDepartment:n,isInExecutiveDepartment:t}=E(),{can:e}=D(),{showErrorNotificationFromError:p}=k(),c=[{text:"Client",value:"client.name"},{text:"Service",value:"Service.name"},{text:"Starts At",value:"startsAt"},{text:"Ends At",value:"endsAt"},{text:"Invoice Amount",value:"invoiceAmount"},{text:"Actual Spend",value:"actualSpend"},{text:"Internal Margin Percentage",value:"markupPercentage"},{text:"Partner Margin Percentage",value:"partnerMargin"},{text:"Platform Margin Percentage",value:"platformMargin"},{text:"Platform Margin Amount",value:"platformMarginAmount"},{text:"Notes",value:"notes",sortable:!1},{text:"Actions",value:"actions",sortable:!1}],_=["markupPercentage","platformMargin","platformMarginAmount","partnerMargin"],v=u(!0),g=u(!1),s=u([]),a=u({includeFees:!0,month:B().format("MMMM"),year:B().format("YYYY"),division:null,parentOrganizationId:null,excludeClientTagIds:[]}),M="active",P=y(()=>n.value||t.value?c:c.filter(({value:r})=>!_.includes(r))),b=y(()=>e("export","Budgets")),l=async()=>{var r;v.value=!0,s.value=await w.getActiveBudgetList({...a.value,isExternal:!0}).then(o=>o.data),a.value.division&&(s.value=s.value.filter(o=>{var i,A;return(A=(i=a.value.division)==null?void 0:i.value)==null?void 0:A.includes(o.client.industryId)})),a.value.parentOrganizationId&&(s.value=s.value.filter(o=>a.value.parentOrganizationId===o.client.parentOrganizationId)),(r=a.value.excludeClientTagIds)!=null&&r.length&&(s.value=s.value.filter(o=>!o.client.ClientTags.some(i=>a.value.excludeClientTagIds.includes(i.tagId)))),v.value=!1},f=r=>{a.value={...a.value,...r},l()},m=()=>{l()},x=()=>{d.on("budget-filter",f),d.on("budget-refresh",m)},h=()=>{d.off("budget-filter",f),d.off("budget-refresh",m)},C=async()=>{g.value=!0;try{const r=await w.downloadActiveBudgetReport({...a.value,isExternal:!0}),o=`Active Budgets For ${a.value.month} ${a.value.year}.xlsx`;S(r.data,o,r.headers["content-type"])}catch(r){p(r,"There was an error downloading the report. Please try again later.")}finally{g.value=!1}};return F(()=>
1{l(),x()}),T(()=>{h()}),{__sfc:!0,isInAccountingDepartment:n,isInExecutiveDepartment:t,can:e,showErrorNotificationFromError:p,headers:c,hiddenColumns:_,loading:v,downloading:g,items:s,filters:a,type:M,filteredHeaders:P,canUserDownloadReport:b,getInitialData:l,handleBudgetFilter:f,handleBudgetRefresh:m,registerEvents:x,unloadEvents:h,downloadReport:C,PageHeader:z,BudgetFilters:H,BudgetTable:N}}};var U=function(){var n=this,t=n._self._c,e=n._self._setupProxy;return t("section",[t(e.PageHeader,{scopedSlots:n._u([{key:"right",fn:function(){return[t("RouterLink",{attrs:{to:{name:"budgets.create"}}},[t("v-btn",{attrs:{color:"primary"}},[t("v-icon",{attrs:{left:"",small:""}},[n._v("fas fa-plus")]),n._v(" New Budget ")],1)],1),e.canUserDownloadReport&&e.items.length?t("v-btn",{attrs:{color:"secondary",loading:e.downloading,disabled:e.loading||e.downloading},on:{click:e.downloadReport}},[t("v-icon",{attrs:{left:"",small:""}},[n._v("fas fa-download")]),n._v(" Download ")],1):n._e(),t(e.BudgetFilters,{ref:"active-budget-filters",staticClass:"ml-2"})]},proxy:!0}])},[n._v(" Active Budgets ")]),t("v-divider"),t("div",{staticClass:"p-6"},[t(e.BudgetTable,{attrs:{headers:e.filteredHeaders,items:e.items,loading:e.loading,type:e.type}})],1)],1)},Y=[],$=R(O,U,Y,!1,null,null);const ee=$.exports;export{ee 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.