import{eh as V,b as G,a as Q,k3 as U,r as d,j as F,B as W}from"./index-43bf7a1c.js";import{T as H}from"./index-2d303f1d.js";import{T as J}from"./TopComponent-6b8acdbd.js";import"./TableContainer-b977c6cc.js";import"./TableRow-86264944.js";import"./Skeleton-ed4df299.js";import"./index-5757b954.js";import"./useMediaQuery-d6627623.js";import"./TableHead-fb4972c5.js";import"./createSvgIcon-f118be02.js";import"./TablePagination-9147f93d.js";import"./Select-44fd3147.js";import"./Menu-362130d3.js";import"./List-6fcc4821.js";import"./Grow-ca573f65.js";import"./OutlinedInput-6bcf3cf8.js";import"./useFormControl-2c5d60c2.js";import"./useControlled-ab567149.js";import"./MenuItem-58b8887e.js";import"./dividerClasses-497df10c.js";import"./listItemTextClasses-0ea25cee.js";import"./KeyboardArrowRight-8bd7c13f.js";import"./yup-3b80ed10.js";import"./index.esm-0548c843.js";import"./componentStyles-4624000e.js";import"./floating-ui.dom-e7d69f3b.js";import"./InputAdornment-b1a1aa58.js";import"./index-913b2dc6.js";import"./InputLabel-6c7474f0.js";/* empty css                   */import"./PageBreadCrumb-9a31a3c1.js";import"./PageMetaData-7350980e.js";import"./ScrollableList-e19132c3.js";import"./Loader-aabe9ed3.js";import"./index.esm-f9e0a906.js";import"./TextField-4da97115.js";import"./FormControl-8d011aab.js";import"./FilterFilled-ccc86e02.js";import"./AntdIcon-634507e8.js";import"./objectSpread2-c31b885b.js";import"./presets-bb9bdfd8.js";import"./FilterOutlined-908c8e25.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};
