import{ek as V,b as G,a as Q,jT as U,r as d,j as F,B as W}from"./index-d2b25495.js";import{T as H}from"./index-75fca24c.js";import{T as J}from"./TopComponent-23a44952.js";import"./TableContainer-dd7cf0ce.js";import"./TableRow-74f9cf3b.js";import"./Skeleton-1012c2e6.js";import"./index-1249dfe4.js";import"./useMediaQuery-b1fbc166.js";import"./TableHead-fac214d3.js";import"./createSvgIcon-e39ae511.js";import"./TablePagination-2c2a1682.js";import"./Select-ef36a2b2.js";import"./Menu-337a466b.js";import"./Grow-8719411b.js";import"./List-863f013e.js";import"./OutlinedInput-86f3ec98.js";import"./useFormControl-2b068664.js";import"./useControlled-8d737f13.js";import"./MenuItem-2bdddad4.js";import"./dividerClasses-02a44d89.js";import"./listItemTextClasses-cadd4b00.js";import"./KeyboardArrowRight-7e978a8a.js";import"./yup-267e586f.js";import"./index.esm-ce3c2c20.js";import"./componentStyles-0e851d91.js";import"./index-709861af.js";import"./popper-f3391c26.js";import"./InputAdornment-d0c3ebef.js";import"./index-38f860bc.js";import"./InputLabel-bb6ab40e.js";/* empty css                   */import"./PageBreadCrumb-02480d86.js";import"./PageMetaData-7797a3b7.js";import"./ScrollableList-fc1de312.js";import"./Loader-1b927baf.js";import"./index.esm-3043d6d4.js";import"./TextField-e155d2be.js";import"./FormControl-73683015.js";import"./FilterFilled-4dfce120.js";import"./AntdIcon-8449be55.js";import"./objectSpread2-b41ee31b.js";import"./FilterOutlined-653b7cb0.js";const qt=()=>{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 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 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,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),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 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),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)&&((v=(k=t==null?void 0:t.tax)==null?void 0:k.value)==null?void 0:v.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:R,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{qt as default};
