import{eh as V,b as G,a as Q,jT as U,r as d,j as F,B as W}from"./index-76d4793e.js";import{T as H}from"./index-1fae9bc3.js";import{T as J}from"./TopComponent-82b1f250.js";import"./TableContainer-4147c2f3.js";import"./TableRow-736f36bd.js";import"./Skeleton-5d9101fd.js";import"./index-85763c32.js";import"./useMediaQuery-8cb39c65.js";import"./TableHead-c6031541.js";import"./createSvgIcon-01ec10fc.js";import"./TablePagination-5e47b2d0.js";import"./Select-338083eb.js";import"./Menu-ed7c6894.js";import"./List-4c24b3e8.js";import"./Grow-84b30c0e.js";import"./OutlinedInput-ac933786.js";import"./useFormControl-c8d490e1.js";import"./useControlled-e03384de.js";import"./MenuItem-cff1abce.js";import"./dividerClasses-45958eb8.js";import"./listItemTextClasses-89e7894e.js";import"./KeyboardArrowRight-8920e265.js";import"./yup-688ec4f6.js";import"./index.esm-3adfd9f7.js";import"./componentStyles-0803b39e.js";import"./floating-ui.dom-e7d69f3b.js";import"./InputAdornment-b99403ce.js";import"./index-ecea5cfc.js";import"./InputLabel-5ed57f0e.js";/* empty css                   */import"./PageBreadCrumb-465f4085.js";import"./PageMetaData-e5080ba8.js";import"./ScrollableList-4dae3697.js";import"./Loader-9f443a4c.js";import"./index.esm-ad8a7c9f.js";import"./TextField-9c64a4a2.js";import"./FormControl-c671c595.js";import"./FilterFilled-aa7d40e4.js";import"./AntdIcon-55dc1b5f.js";import"./objectSpread2-51b6810f.js";import"./FilterOutlined-91aa15e3.js";const kt=()=>{var y;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 k=[{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 T(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 b=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,v,L;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),P=c?parseFloat(parseFloat(`${Number(r)-f}`).toFixed(2)):r;let u=parseFloat(parseFloat(`${m*parseFloat(`${P}`)}`).toFixed(2)),_=0;const $=(t==null?void 0:t.taxtype)||0;return(()=>{var N,R;const l=((N=t==null?void 0:t.tax)==null?void 0:N.tax)||0,h=typeof l=="string"?parseFloat(l):l;if($==2){if((R=t==null?void 0:t.tax)!=null&&R.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),T(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} %`,P,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)&&((L=(v=t==null?void 0:t.tax)==null?void 0:v.value)==null?void 0:L.tax)||""}%)`)})},[T,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:((y=e==null?void 0:e.project_items)==null?void 0:y.length)??0,columns:k,rows:b||[],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{kt as default};
