import{q as S,j as e}from"./index-d2b25495.js";import{D as z,P as O,V as n,T as x}from"./react-pdf.browser-2d7aeca0.js";import{P as s}from"./pdf-9a6a61e1.js";import{P as U,a as B}from"./index-07906678.js";const G=r=>{const y=Math.ceil(r.length/2);return[r.slice(0,y),r.slice(y)]};function p({purchaseQuotationData:r,companyData:y}){var C,o,F,P;const A=[{label:"Created On:",value:r==null?void 0:r.created_on},{label:"Delivery Date:",value:S(r==null?void 0:r.deliverydate).format("DD-MM-YYYY")},{label:"PE Code:",value:(C=r==null?void 0:r.purchase_enquiry)==null?void 0:C.name},{label:"Vendor:",value:(o=r==null?void 0:r.vendor)==null?void 0:o.name},{label:"Project:",value:(F=r==null?void 0:r.project)==null?void 0:F.name}],[V,Y]=G(A);return e.jsx(z,{children:e.jsxs(O,{size:"A4",style:s.body,children:[e.jsx(U,{companyData:y}),e.jsxs(n,{style:s.bid,fixed:!0,children:[e.jsx(x,{style:s.content,children:"Purchase Quotation"}),e.jsxs(x,{style:s.companyDetails,children:["PQ Code : ",r==null?void 0:r.code]})]}),e.jsx(n,{style:s.tablefeilds,children:e.jsxs(n,{style:s.tableRow,children:[e.jsx(n,{style:s.column,children:V.map((l,d)=>e.jsxs(n,{style:s.itemRow,children:[e.jsx(x,{style:s.labelCell,children:l.label}),e.jsx(x,{style:s.valueCell,children:l.value})]},`left-${d}`))}),e.jsx(n,{style:s.column,children:Y.map((l,d)=>e.jsxs(n,{style:s.itemRow,children:[e.jsx(x,{style:s.labelCell,children:l.label}),e.jsx(x,{style:s.valueCell,children:l.value})]},`right-${d}`))})]})}),e.jsxs(n,{style:s.table,children:[e.jsxs(n,{style:s.tableRow,children:[e.jsx(x,{style:[s.tableCellHeader,{flex:.4}],children:"SI No"}),e.jsx(x,{style:[s.tableCellHeader,{flex:2}],children:"Item"}),e.jsx(x,{style:[s.tableCellHeader,{flex:1}],children:"Qty"}),e.jsx(x,{style:[s.tableCellHeader,{flex:1}],children:"Units"}),e.jsx(x,{style:[s.tableCellHeader,{flex:1}],children:"Make"}),e.jsx(x,{style:[s.tableCellHeader,{flex:1.2}],children:"Price"}),e.jsx(x,{style:[s.tableCellHeader,{flex:1}],children:"Discount"}),e.jsx(x,{style:[s.tableCellHeader,{flex:2}],children:"After Discount"}),e.jsx(x,{style:[s.tableCellHeader,{flex:1.9}],children:"Tax Type"}),e.jsx(x,{style:[s.tableCellHeader,{flex:2}],children:"Tax Amt"}),e.jsx(x,{style:[s.tableCellHeader,{flex:2}],children:"Total"})]}),(P=r==null?void 0:r.quotationitems)==null?void 0:P.map((l,d)=>{var H,_,T,w,$,g,q,M;const h=l!=null&&l.qty?+(l==null?void 0:l.qty):0,c=l!=null&&l.price?parseFloat(l==null?void 0:l.price):0,b=l!=null&&l.discount?+(l==null?void 0:l.discount):0,k=b/100*c,v=b?parseFloat(`${c-k}`).toFixed(2):c;let j=parseFloat(`${h*parseFloat(`${v}`)}`).toFixed(2);const t=((H=l==null?void 0:l.taxtype)==null?void 0:H.value)==2?(_=l==null?void 0:l.tax)!=null&&_.id?((T=l==null?void 0:l.tax)==null?void 0:T.tax)/100*parseFloat(j):0:(()=>{var R,a,I;const f=parseFloat(j)/((100+((R=l==null?void 0:l.tax)==null?void 0:R.tax))/100),N=f/100*((a=l==null?void 0:l.tax)==null?void 0:a.tax);return j=parseFloat(`${N+f}`).toFixed(2),f/100*((I=l==null?void 0:l.tax)==null?void 0:I.tax)})(),E=parseFloat(j)+t;return parseFloat(`${E}`).toFixed(2),e.jsxs(n,{style:s.tableRow,children:[e.jsx(x,{style:[s.tableCell,{flex:.4}],children:d+1},d),e.jsx(x,{style:[s.tableCell,{flex:2}],children:(w=l.item)==null?void 0:w.name},d),e.jsx(x,{style:[s.tableCell,{flex:1}],children:h},d),e.jsx(x,{style:[s.tableCell,{flex:1}],children:($=l.unit)==null?void 0:$.name},d),e.jsx(x,{style:[s.tableCell,{flex:1}],children:(g=l.make)==null?void 0:g.label},d),e.jsx(x,{style:[s.tableCell,{flex:1.2}],children:c},d),e.jsx(x,{style:[s.tableCell,{flex:1}],children:b+"% "},d),e.jsx(x,{style:[s.tableCell,{flex:2}],children:v},d),e.jsxs(x,{style:[s.tableCell,{flex:1.9}],children:[(l==null?void 0:l.taxtype_name)+" (",((q=l==null?void 0:l.tax)!=null&&q.tax?(M=l==null?void 0:l.tax)==null?void 0:M.tax:"N/A")+"%)"," "]},d),e.jsx(x,{style:[s.tableCell,{flex:2}],children:l==null?void 0:l.tax_amount},d),e.jsx(x,{style:[s.tableCell,{flex:2}],children:l==null?void 0:l.total_price},d)]})})]}),e.jsx(B,{companyData:y})]})})}export{p as P};
