import{j as t,c as E,S as g,a8 as O,o as T}from"./vendor-mui-CBBEb17G.js";import{a as i,u as K}from"./vendor-react-BBazpZul.js";import{v as F,c5 as L,aX as A,x as M,z as c,J as U,gx as _,ao as B,aP as v,bE as W,I as J}from"./index-IP_FWtso.js";import{s as z}from"./index-B93gEanO.js";import{a as Q}from"./vendor-utils-BveVE6Uf.js";import"./vendor-charts-tGnAgELZ.js";class R{constructor(){this.getProductAsync=async r=>{const d=await Q.get("Tax/Product",{params:r});return d==null?void 0:d.data}}}const X=({serviceDetail:p,onClose:r})=>{var I,y,j;const d=new R,{editServiceDetailAsync:f}=z(),[S,x]=i.useState(!1),[m,D]=i.useState(""),[a,k]=i.useState(null),[l,N]=i.useState(null),n=async(e=1,h=25)=>{try{x(!0);const{data:C}=await d.getProductAsync({PageNumber:e,PageSize:h,DescriptionOfID:m});k(C)}finally{x(!1)}},b=async()=>{try{if(x(!0),!l)return;const{message:e}=await f({...p,taxInfo:{code:l.taxId.toString(),valueAddedPercent:l.vat}});U.success(e),r()}finally{x(!1)}};i.useEffect(()=>{m&&n()},[m]);const w=[{title:"",key:"check",dataIndex:"taxId",width:40,render:e=>t.jsx(O,{checked:e===(l==null?void 0:l.taxId),className:"!m-0 !p-0"})},{title:"کد مالیاتی",key:"taxId",dataIndex:"taxId",width:150,render:e=>c(e??0)},{title:"عنوان",key:"descriptionOfID",dataIndex:"descriptionOfID",width:250},{title:"درصد ارزش افزوده",key:"vat",dataIndex:"vat",width:120,render:e=>c(e??0)},{title:"مشمول مالیات",key:"taxable",dataIndex:"taxable",width:100},{title:"تاریخ اجرا",key:"runDate",dataIndex:"runDate",width:100,render:e=>e?c(e):""},{title:"تاریخ انقضا",key:"expirationDate",dataIndex:"expirationDate",width:100,render:e=>e?c(e):""},{title:"تاریخ ایجاد",key:"createDate",dataIndex:"createDate",width:100,render:e=>e?c(e):""},{title:"تاریخ آخرین ویرایش",key:"lastEditDate",dataIndex:"lastEditDate",width:130,render:e=>e?c(e):""},{title:"نوع",key:"type",dataIndex:"type",width:150},{title:"شرح قیمت گذاری",key:"pricingDescription",dataIndex:"pricingDescription",width:150}];return t.jsxs(F,{onClose:r,title:`تعیین کد مالیاتی برای خدمت  ${p.title}`,maxWidth:"lg",isFixWidth:!0,children:[t.jsxs(E,{className:"flex flex-col gap-2 h-full m-1 !p-2",children:[t.jsx(L,{onChange:D}),t.jsx(g,{className:"h-full",children:t.jsx(A,{loading:S,rowKey:"taxId",columns:w||[],data:(a==null?void 0:a.list)||[],onClick:e=>N(e),totalCount:((I=a==null?void 0:a.pagination)==null?void 0:I.totalCount)??0,pageNumber:(((y=a==null?void 0:a.pagination)==null?void 0:y.pageNumber)??1)-1,pageSize:((j=a==null?void 0:a.pagination)==null?void 0:j.pageSize)??25,onPaginationLoad:(e,h)=>{n(e+1,h)}})})]}),t.jsx(M,{onClose:r,onSubmit:b,loading:S})]})},$=()=>{var h,C,P;const{getServiceDetailsAsync:p}=z(),r=K(),[d,f]=i.useState(!1),[S,x]=i.useState(!1),[m,D]=i.useState(""),[a,k]=i.useState(""),[l,N]=i.useState(0),[n,b]=i.useState(null),[w,I]=i.useState(null),y=async(s=1,o=25)=>{try{f(!0);const{data:u}=await p({PageNumber:s,PageSize:o,Name:m,NationalCode:a,CustomId:l||void 0});b(u)}finally{f(!1)}},j=()=>{x(!1),I(null)},e=[{title:"",key:"edit",dataIndex:"taxId",width:40,render:()=>t.jsx(T,{size:"small",color:"primary",className:"!p-0 !m-0",onClick:()=>x(!0),children:t.jsx(J.EditIcon,{})})},{title:"کد ",key:"customId",dataIndex:"customId",width:100,render:(s,o)=>c(s||o.id)},{title:"عنوان",key:"title",dataIndex:"title",width:150,render:(s,o)=>o.customName||s},{title:"کد ملی",key:"nationalCode",dataIndex:"nationalCode",width:100,render:s=>s?c(s):"-"},{title:"کد مالیاتی",key:"code",width:100,render:(s,o)=>{var u;return(u=o.taxInfo)==null?void 0:u.code}},{title:"درصد ارزش افزوده",key:"valueAddedPercent",width:100,render:(s,o)=>{var u;return(u=o.taxInfo)==null?void 0:u.valueAddedPercent}}];return t.jsx(_,{loading:d,onSearch:y,sidebarModules:{},sidebarContent:t.jsxs(g,{spacing:2,children:[t.jsx(v,{label:"عنوان",value:m,onChange:D}),t.jsx(v,{label:"کد ملی",value:a,onChange:k}),t.jsx(W,{label:"کد",value:l,onChange:N})]}),children:t.jsxs(g,{className:"h-[calc(100vh-200px)]",spacing:1,children:[t.jsx(g,{className:"h-full",children:t.jsx(A,{loading:d,rowKey:"id",columns:e||[],data:(n==null?void 0:n.list)||[],onClick:s=>I(s),totalCount:((h=n==null?void 0:n.pagination)==null?void 0:h.totalCount)??0,pageNumber:(((C=n==null?void 0:n.pagination)==null?void 0:C.pageNumber)??1)-1,pageSize:((P=n==null?void 0:n.pagination)==null?void 0:P.pageSize)??25,onPaginationLoad:(s,o)=>{y(s+1,o)}})}),t.jsx(g,{direction:"row",justifyContent:"center",alignItems:"center",spacing:1,children:t.jsx(B,{color:"error",className:"w-32",onClick:()=>r(-1),children:"بازگشت"})}),S&&w&&t.jsx(X,{onClose:j,serviceDetail:w})]})})},ee=()=>t.jsxs(g,{className:"h-full p-2 px-4",children:[t.jsx("h1",{className:"flex justify-center items-center w-full p-2 py-4 text-2xl  text-slate-50 bg-[#056586] shadow-2xl rounded-lg",children:"لیست اقلام مالیاتی"}),t.jsx($,{})]});export{ee as default};
