import{eh as V,b as G,a as Q,k3 as U,r as d,j as F,B as W}from"./index-60a3c753.js";import{T as H}from"./index-7e55cf46.js";import{T as J}from"./TopComponent-69eda74c.js";import"./TableContainer-414c12e0.js";import"./TableRow-0b33776c.js";import"./Skeleton-98c353d9.js";import"./index-a99c9f65.js";import"./useMediaQuery-dba48e3b.js";import"./TableHead-f864c753.js";import"./createSvgIcon-de433e5f.js";import"./TablePagination-218dde38.js";import"./Select-99fc0d84.js";import"./Menu-d1b7e1c3.js";import"./List-f567f8e4.js";import"./Grow-68442588.js";import"./OutlinedInput-3a884178.js";import"./useFormControl-e13b5747.js";import"./useControlled-194ef007.js";import"./MenuItem-2f410bd2.js";import"./dividerClasses-3fa67596.js";import"./listItemTextClasses-36afdb92.js";import"./KeyboardArrowRight-b2645aed.js";import"./yup-92678dde.js";import"./index.esm-c494934a.js";import"./componentStyles-7753bbb9.js";import"./floating-ui.dom-e7d69f3b.js";import"./InputAdornment-96c40dce.js";import"./index-900fa817.js";import"./InputLabel-71dfc9d4.js";/* empty css                   */import"./PageBreadCrumb-fcf1e00a.js";import"./PageMetaData-198e143e.js";import"./ScrollableList-1962b023.js";import"./Loader-466ccb5e.js";import"./index.esm-62d6b2f7.js";import"./TextField-32b29087.js";import"./FormControl-d13d2693.js";import"./FilterFilled-cdde02db.js";import"./AntdIcon-bed41c21.js";import"./objectSpread2-85813881.js";import"./presets-06d13753.js";import"./FilterOutlined-c131dc67.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};
