import{eh as V,b as G,a as Q,k3 as U,r as d,j as F,B as W}from"./index-def636a4.js";import{T as H}from"./index-fc769754.js";import{T as J}from"./TopComponent-7f7c384d.js";import"./TableContainer-5944247b.js";import"./TableRow-2c544f58.js";import"./Skeleton-5cf57ed1.js";import"./index-b5a6fbe3.js";import"./useMediaQuery-4304fb25.js";import"./TableHead-f0476938.js";import"./createSvgIcon-ff487f53.js";import"./TablePagination-7d3b42e9.js";import"./Select-2cfb5afd.js";import"./Menu-af49d134.js";import"./List-17cd485b.js";import"./Grow-85576dd3.js";import"./OutlinedInput-ddb8bb3f.js";import"./useFormControl-880b2f7b.js";import"./useControlled-bd643819.js";import"./MenuItem-8fdd2340.js";import"./dividerClasses-2b953c2a.js";import"./listItemTextClasses-063fcacf.js";import"./KeyboardArrowRight-bfb3d848.js";import"./yup-c8535458.js";import"./index.esm-7d9d1491.js";import"./componentStyles-41382c67.js";import"./floating-ui.dom-e7d69f3b.js";import"./InputAdornment-196a5386.js";import"./index-f48c8aa0.js";import"./InputLabel-e2e73b27.js";/* empty css                   */import"./PageBreadCrumb-816019c3.js";import"./PageMetaData-0f9457e5.js";import"./ScrollableList-a550bc32.js";import"./Loader-16c57fae.js";import"./index.esm-eec4f448.js";import"./TextField-2ba95a45.js";import"./FormControl-1f811046.js";import"./FilterFilled-08c5b5a7.js";import"./AntdIcon-34324527.js";import"./objectSpread2-a4d0f5f6.js";import"./presets-dbb0f3bf.js";import"./FilterOutlined-03ee9578.js";const qt=()=>{var P;V(),G();const{system:{userAccessList:K},workOrder:{selectedData:e}}=Q(i=>U(i)),[x,g]=d.useState(e!=null&&e.project_items?e==null?void 0:e.project_items:[]),[s,I]=d.useState({page:1,page_size:10});d.useEffect(()=>{e!=null&&e.project_items&&g(e==null?void 0:e.project_items)},[e==null?void 0:e.project_items]);const R=[{title:"S.No",width:100},{title:"Bid Item",width:100},{title:"Bid Item Code",width:100},{title:"Quantity",width:100},{title:"Price",width:100},{title:"Discount",width:100},{title:"Price After Discount",width:100},{title:"Gross",width:100},{title:"Tax Type",width:100},{title:"Tax",width:100}];function b(i,p,o,t,n,a,m,r,c,f){return{index:i,bid_item:p,bid_item_code:o,quantity:t,price:n,discount:a,afterdiscount:m,gross:r,taxtype:c,tax:f}}const y=d.useMemo(()=>{if(!x)return[];const i=(s.page-1)*s.page_size,p=i+s.page_size;return x.slice(i,p).map((t,n)=>{var z,A,B,C,S,k,v;const a=i+(n+1),m=t!=null&&t.quantity?+(t==null?void 0:t.quantity):0,r=t!=null&&t.price?parseFloat(`${t==null?void 0:t.price}`):0,c=t!=null&&t.discount?+(t==null?void 0:t.discount):0,f=c/100*Number(r),T=c?parseFloat(parseFloat(`${Number(r)-f}`).toFixed(2)):r;let u=parseFloat(parseFloat(`${m*parseFloat(`${T}`)}`).toFixed(2)),_=0;const $=(t==null?void 0:t.taxtype)||0;return(()=>{var L,N;const l=((L=t==null?void 0:t.tax)==null?void 0:L.tax)||0,h=typeof l=="string"?parseFloat(l):l;if($==2){if((N=t==null?void 0:t.tax)!=null&&N.id){const j=parseFloat(`${u*(h/100)}`);return _=u+j,j}return 0}else if($==1){if(l>0){const O=u/(1+h/100)*(h/100);return _=u,O}return 0}return 0})(),parseFloat(`${_}`).toFixed(2),b(a,(z=t==null?void 0:t.tenderitemmaster)!=null&&z.label?(A=t==null?void 0:t.tenderitemmaster)==null?void 0:A.label:"",(B=t==null?void 0:t.tenderitemmaster)!=null&&B.code?(C=t==null?void 0:t.tenderitemmaster)==null?void 0:C.code:"",m,r,`${c} %`,T,u,(t==null?void 0:t.taxtype_name)||"",`${(S=t==null?void 0:t.tax)==null?void 0:S.label} (${(t==null?void 0:t.tax)&&((v=(k=t==null?void 0:t.tax)==null?void 0:k.value)==null?void 0:v.tax)||""}%)`)})},[b,x,s,e]),q=(i,p)=>{I({...s,page:p+1})},E=i=>{I({...s,page_size:parseInt(i.target.value)})},M=({search:i})=>{var p;if(i&&i!=""){const o=(p=e==null?void 0:e.project_items)==null?void 0:p.filter(t=>{var n,a,m;return(m=(a=(n=t==null?void 0:t.tenderitemmaster)==null?void 0:n.label)==null?void 0:a.toLowerCase())==null?void 0:m.includes(i.toLowerCase())});g(o||[])}else g(e!=null&&e.project_items?e==null?void 0:e.project_items:[])};return F.jsxs(W,{mt:1,children:[F.jsx(J,{permissionPreFix:"ProjectManagement",permissionPostFix:"projectitem",navigateLink:"",showAddButton:!1,showFilterButton:!1,addButtonName:"Update Items",handleSearch:M,filteredData:s}),F.jsx(H,{count:((P=e==null?void 0:e.project_items)==null?void 0:P.length)??0,columns:R,rows:y||[],loading:!1,page:s.page?s.page:1,pageSize:s.page_size?s==null?void 0:s.page_size:10,handleChangePage:q,handleChangeRowsPerPage:E})]})};export{qt as default};
