1var q=Object.defineProperty;var W=(a,e,r)=>e in a?q(a,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[e]=r;var f=(a,e,r)=>W(a,typeof e!="symbol"?e+"":e,r);import{R as t}from"./react-DJo-hRcj.js";import{b$ as b,bV as x,I as v,bZ as z,co as O,bW as L,d as I,bX as B,ax as Y,c8 as w,ca as G,be as K}from"./vendors-_9dKRPAn.js";import{W as H,ah as Q}from"./lodash-D9U91hCZ.js";import{H as V}from"./index-fAv5m2E8.js";import{C as U}from"./index-BKy_m-tN.js";import{D as M}from"./index-DFLPX0VU.js";import{a as E,A as g,b as S,P as A,B as R,a7 as Z,I as J}from"./index-B5XNITP8.js";import{P as X}from"./Plus-VBX5Yw5b.js";import{D as ee}from"./index-PcIn_X-S.js";import{L as te}from"./Layout-hleQVaK2.js";import{M as ae}from"./index-Yvay8wXO.js";import{D as re}from"./DeleteIcon-qmV7R3MF.js";import{M as ie}from"./index-CpEgVe4x.js";import{F as k}from"./FormLayout-C-HA-4gU.js";import{t as F,a as oe}from"./toastifyV2-JsPZrQKQ.js";import{c as _}from"./StyleDataGrid-DjXRjjzZ.js";import{C as $}from"./CheckRole-B9FjKecA.js";import{g as ne}from"./handleStrapiResponse-q3L5wG0O.js";import{f as P}from"./TimeManager-GQjd9ziw.js";import{M as se}from"./index-Bp8KVhOo.js";import{D as ce,a as le}from"./dataGridPagination-DreUZyh_.js";import{aq as me}from"./mui-core-DIGHSUz9.js";import"./ModalV2-Bwgoj2D8.js";import"./mui-x-WaaF4sFd.js";import"./useCheckPermissionSidebar-BJ_M-sXv.js";import"./LocalStorageManager-Brbsb2wO.js";import"./index-C6hXkfvS.js";import"./useUrlParams-9vBjnh_J.js";import"./Search-BtClgkYE.js";import"./org-switch-rules-CALv74Cz.js";import"./useOrgList-CLYvyZdj.js";import"./DashboardQueryRepository-BaKnPLob.js";import"./Search-CSvDv4Dl.js";import"./Building-_OqbRV1u.js";import"./Check-DzZWfpvT.js";import"./languageManager-_RIZidnS.js";import"./SharedComponents-CFIIYYlL.js";import"./LocalStorageManager-Cf9EMmua.js";import"./constants-BhQb0AAi.js";import"./getHttpStatusCode-D6Fy-dO9.js";import"./getTenantId-D-FzaJmc.js";import"./index-DNOYbucS.js";import"./DotVertical-DGLn8uE4.js";import"./index-B2-3scyh.js";import"./Calendar-CZtGAmeq.js";class D{constructor({projectId:e,queryClient:r}){f(this,"invalidateCache",()=>{this.queryClient.invalidateQueries(this.queryKey())});f(this,"updatePeriodStatusMutation",e=>({mutationKey:`updatePeriodStatusMutation-${e}`,mutationFn:r=>E.put(`/v1/project/${this.projectId}/${e}/status`,r),onSuccess:this.invalidateCache}));f(this,"createPeriodMutation",()=>({mutationKey:"createPeriod",mutationFn:e=>E.post(`/v1/project/${this.projectId}/fi-years`,e),onSuccess:this.invalidateCache}));f(this,"removePeriodMutation",()=>({mutationKey:"removePeriod",mutationFn:e=>E.delete(`/v1/project/${this.projectId}/fi-years/${e}`),onSuccess:this.invalidateCache}));this.projectId=e,this.queryClient=r}queryKey(e){if(!e)return["company",this.projectId,"fiscal-year"];const{page:r,pageSize:i}=e;return[this.projectId,"fiscal-year",{page:r,pageSize:i}]}filterPeriods(e){const{page:r,pageSize:i}=e,o={deleted:!1};return e.status&&(o.status=e.status),E.get(`/v1/project/${this.projectId}/fi-years`,{params:{pagination:{page:r,pageSize:i},filters:{...o},populate:{periods:{sort:"startDate:asc",fields:["id","name","startDate","endDate","status","lastSync"],filters:{deleted:!1}}},sort:"name:asc"}})}}function de({fiYearId:a,projectId:e,onClose:r,refetch:i,translate:o}){const m=b(),c=new D({projectId:e,queryClient:m}),d=x(c.removePeriodMutation()),u=()=>F(d.mutateAsync(a).then(()=>{r(),i()}));return t.createElement("div",null,t.createElement("div",null,o("delete_this_fiscal_year_message")),t.createElement(k.Action,{py:6},t.createElement(g,{onClick:r,variant:"tertiary",size:"modal"},o("button.cancel")),t.createElement(g,{onClick:u,variant:"danger",size:"modal"},o("button.confirm"))))}function ue(a){const{t:e}=v();return t.createElement("div",null,t.createElement(M,{title:e("delete_this_fiscal_year"),popupId:"update-currency",renderContent:({onClose:r})=>t.createElement(de,{onClose:r,fiYearId:a.periodId,projectId:a.projectId,refetch:a.refetch,translate:e})},t.createElement(ie,{isDelete:!0,icon:t.createElement(re,null),text:e("button.delete")})))}const pe=(a,e,r)=>[{id:"name",field:"name",headerName:a("name"),minWidth:400,maxWidth:400,flex:1,display:"flex",renderCell:i=>_(i)},{id:"duration",field:"duration",headerName:a("duration"),minWidth:176,flex:1,display:"flex",renderCell:i=>_(i)},{id:"createdAt",field:"createdAt",headerName:a("created_date"),minWidth:300,maxWidth:300,flex:1,display:"flex",renderCell:i=>_(i)},{id:"actions",field:"actions",headerName:a("actions"),flex:1,maxWidth:80,minWidth:80,headerAlign:"center",align:"center",disableColumnMenu:!0,sortable:!1,display:"flex",renderCell:i=>t.createElement($,{action:A.madjust["remove-period"],subject:{name:S.workspace,id:r},key:`remove-period-${r}`},t.createElement(R,{display:"flex",alignItems:"center",justifyContent:"center"},t.createElement(ae,{menuItems:t.createElement(ue,{periodId:i.row.id,status:i.row.status,slug:"peri
1ods",slugName:a("PAGE.ACCOUNTING_PERIOD.FINANCIAL_PERIOD"),projectId:r,refetch:e})})))}];function fe(a){const{t:e}=v(),r=b(),i=a.projectId||null,{onClose:o,refetch:m}=a,c=z().shape({year:O().required(e("invalid_field"))}),d=L({resolver:B(c),defaultValues:{year:I()}}),u=new D({projectId:i,queryClient:r}),{mutateAsync:j,isLoading:y}=x(u.createPeriodMutation()),{control:C,handleSubmit:l}=d,p=s=>{const n=String(I(s.year).year()||I().year());return n?F(j({year:n})).then(()=>{o(),m()}):oe.error(e("invalid_field"))};return t.createElement("form",{onSubmit:l(p)},t.createElement(Y,{name:"year",control:C,render:({field:s,fieldState:{error:n}})=>t.createElement(se,{label:e("fiscal_year"),openTo:"year",value:s.value,views:["year"],onChange:h=>{s.onChange(h)},error:!!n,helperText:n?.message||"",size:"md"})}),t.createElement(k.Action,{py:6},t.createElement(g,{variant:"tertiary",size:"modal",onClick:o},e("button.cancel")),t.createElement(g,{variant:"primary",size:"modal",type:"submit",loading:y,disabled:y},e("button.save"))))}function ye(){const{t:a}=v(),{id:e}=w(),r=b(),i=new D({projectId:e,queryClient:r}),o={},[m]=G([{queryKey:i.queryKey(o),queryFn:()=>i.filterPeriods(o)}]),{refetch:c,data:d,isLoading:u}=m,y=(d?.data.data||[]).map(l=>{const p=l.attributes,s=ne(p.periods.data),n=H(s),h=Q(s),T=n?P(n.startDate):"",N=h?P(h.endDate):"";return{id:l.id,...p,createdAt:P(p.createdAt),duration:`${T} - ${N}`}}),C=pe(a,c,e);return t.createElement(te,null,t.createElement(K,null,t.createElement("title",null,`${a("madjust")} > ${a("fiscal_year")} - FPT Data Suite`),t.createElement("meta",{name:"description",content:"Your personalized dashboard with reports"}),t.createElement("meta",{name:"keywords",content:"dashboard, reports, workspace, analytics"})),t.createElement(me,{direction:"row",justifyContent:"space-between",alignItems:"center"},t.createElement(V,{title:a("fiscal_year_configuration"),description:a("manage_fiscal_year_configuration")}),t.createElement($,{action:A.madjust["write-period"],subject:{name:S.workspace,id:e},key:`write-period-${e}`},t.createElement(M,{title:a("create_new_fiscal_year"),popupId:"update-currency",renderContent:({onClose:l})=>t.createElement(fe,{onClose:l,projectId:e,refetch:c})},t.createElement(J,{text:a("create_new_fiscal_year"),variant:"primary",icon:t.createElement(X,{size:"sm"})})))),t.createElement(U,null,t.createElement(R,{sx:{height:"500px",maxHeight:"100%",minHeight:"calc(100% - 0px)"}},t.createElement(ee,{loading:u,rows:y,columns:C,disableSelectionOnClick:!0,disableColumnSelector:!0,disableColumnFilter:!0,columnMenu:!0,pageSizeOptions:le,initialState:{pagination:{paginationModel:{pageSize:ce,page:0}}}}))))}function ct(){const{id:a}=w();return t.createElement(Z,{action:A.madjust["read-period"],subject:{name:S.workspace,id:a},key:`read-period-${a}`},t.createElement(ye,null))}export{ct 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.