umwd-components 0.1.808 → 0.1.809
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/src/components/e-commerce/invoice/InvoicePDF.js +1 -1
- package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/src/components/e-commerce/invoice/InvoicePDF.js +70 -59
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/types/components/e-commerce/invoice/InvoicePDFOLD.d.ts +13 -0
- package/package.json +1 -1
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material/IconButton"),s=require("@mui/material/Dialog"),n=require("@mui/material/DialogContent"),l=require("@mui/material/DialogActions"),c=require("@mui/material/Button"),o=require("@mui/material/CircularProgress"),r=require("@mui/icons-material/PictureAsPdf");let d=null;const x=async()=>("undefined"==typeof window||d||(d=await import("@react-pdf/renderer")),d),h=({props:i})=>{const{invoice:s}=i,[n,l]=t.useState(null),[c,r]=t.useState(null);if(t.useEffect(()=>{(async()=>{const e=await x();e&&(l(e),r(e.StyleSheet.create({page:{flexDirection:"column",backgroundColor:"#E4E4E4"},header:{padding:10,flexDirection:"row",alignItems:"center"},logo:{width:24,height:24,marginRight:10},section:{margin:10,padding:10,fontSize:12},row:{flexDirection:"row"},rowSection:{flex:1},productRowSection:{flex:1,width:1/6},h1:{fontSize:28},h2:{fontSize:24,fontWeight:"bold"},h3:{fontSize:16,fontWeight:"bold"}})))})()},[]),!n||!c)return e.jsx(o,{});const{Document:d,Page:h,View:j,Text:y}=n,{seller_business_credentials:p,seller_company_address:a,buyer_company_address:u,buyer_business_credentials:S,type:_,invoice_number:f}=s;console.log("type",_);return"credit"===_?e.jsx(d,{title:`credit_${s?.invoice_number}`,children:e.jsxs(h,{size:"A4",style:c.page,children:[e.jsx(j,{style:c.header,children:e.jsx(y,{style:c.h1,children:p?.company_name})}),e.jsx(j,{style:c.section,children:e.jsx(y,{style:c.h2,children:"CREDIT NOTE"})}),e.jsx(j,{style:c.section,children:e.jsxs(j,{style:c.row,children:[e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:c.h3,children:"BILLING DETAILS"}),e.jsx(y,{children:S?.company_name}),e.jsxs(y,{children:[s?.buyer_first_name," ",s?.buyer_last_name]}),e.jsxs(y,{children:[u?.street," ",u?.street_number," ",u?.street_number_addition]}),e.jsxs(y,{children:[u?.postal_code," ",u?.city]})]}),e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:c.h3,children:"FROM"}),e.jsx(y,{children:p?.company_name}),e.jsxs(y,{children:[a?.street," ",a?.street_number," ",a?.street_number_addition]}),e.jsxs(y,{children:[a?.postal_code," ",a?.city]}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"CoC Number"}),e.jsx(y,{children:p?.coc_number}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"VAT Number"}),e.jsx(y,{children:p?.vat_number})]})]})}),e.jsx(j,{style:c.section,children:e.jsxs(j,{style:c.row,children:[e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice number: "}),e.jsx(y,{children:s?.invoice_number})]}),s?.customer_reference&&e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Your reference: "}),e.jsx(y,{children:s?.customer_reference})]}),e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice date"}),e.jsx(y,{children:s?.invoice_date})]})]})}),e.jsxs(j,{style:c.section,children:[e.jsx(y,{style:c.h3,children:"SUMMARY"}),e.jsxs(j,{style:c.row,children:[s?.admin_items?.length>0&&e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Line Item Number"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Title"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Amount"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT rate"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Incl. VAT"})})]}),s?.items?.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["product_title"in i&&i.product_title,"item_description"in i&&i.item_description]})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.quantity})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[i.vat_rate," %"]})}),e.jsx(j,{style:c.productRowSection,children:i.price_excl_vat&&i.price_incl_vat&&e.jsxs(y,{style:{fontSize:"10px"},children:["€"," ",(i.price_incl_vat-i.price_excl_vat)?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i.price_excl_vat?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i.price_incl_vat?.toFixed(2)]})})]})},s)),s?.admin_items?.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.line_item_number})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.description})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.quantity})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[i?.price?.vat_rate," %"]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i?.price?.vat?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i?.price?.price?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i?.price?.price_incl_vat?.toFixed(2)]})})]})},s))]}),e.jsxs(j,{style:c.section,children:[e.jsx(y,{style:c.h3,children:"TOTALS"}),e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Incl. VAT"})})]}),e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{children:["€ ",s?.VAT_total?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{children:["€ ",s?.total_excl_vat?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{children:["€ ",s?.total_incl_vat?.toFixed(2)]})})]})]}),e.jsx(j,{style:c.section,children:e.jsxs(y,{style:{...c.h3,border:"2px solid black",padding:10},children:["Total: € ",s?.total_incl_vat?.toFixed(2)]})})]})}):"proforma"===_?e.jsx(d,{title:`proforma_${s?.invoice_number}`,children:e.jsxs(h,{size:"A4",style:c.page,children:[e.jsx(j,{style:c.header,children:e.jsx(y,{style:c.h1,children:p?.company_name})}),e.jsxs(j,{style:c.section,children:[e.jsx(y,{style:c.h2,children:"PROFORMA INVOICE"}),e.jsx(y,{style:{fontSize:10,marginTop:5},children:"This is not a final invoice and cannot be used for tax purposes"})]}),e.jsx(j,{style:c.section,children:e.jsxs(j,{style:c.row,children:[e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:c.h3,children:"BILLING DETAILS"}),e.jsx(y,{children:S?.company_name}),e.jsxs(y,{children:[s?.buyer_first_name," ",s?.buyer_last_name]}),e.jsxs(y,{children:[u?.street," ",u?.street_number," ",u?.street_number_addition]}),e.jsxs(y,{children:[u?.postal_code," ",u?.city]})]}),e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:c.h3,children:"FROM"}),e.jsx(y,{children:p?.company_name}),e.jsxs(y,{children:[a?.street," ",a?.street_number," ",a?.street_number_addition]}),e.jsxs(y,{children:[a?.postal_code," ",a?.city]}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"CoC Number"}),e.jsx(y,{children:p?.coc_number}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"VAT Number"}),e.jsx(y,{children:p?.vat_number})]})]})}),e.jsx(j,{style:c.section,children:e.jsxs(j,{style:c.row,children:[e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice number: "}),e.jsx(y,{children:s?.invoice_number})]}),s?.customer_reference&&e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Your reference: "}),e.jsx(y,{children:s?.customer_reference})]}),e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice date"}),e.jsx(y,{children:s?.invoice_date})]})]})}),e.jsxs(j,{style:c.section,children:[e.jsx(y,{style:c.h3,children:"SUMMARY"}),e.jsxs(j,{style:c.row,children:[s?.admin_items?.length>0&&e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Line Item Number"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Title"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Amount"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT rate"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Incl. VAT"})})]}),s?.items?.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["product_title"in i&&i.product_title,"item_description"in i&&i.item_description]})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.quantity})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[i.vat_rate," %"]})}),e.jsx(j,{style:c.productRowSection,children:i.price_excl_vat&&i.price_incl_vat&&e.jsxs(y,{style:{fontSize:"10px"},children:["€"," ",(i.price_incl_vat-i.price_excl_vat)?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i.price_excl_vat?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i.price_incl_vat?.toFixed(2)]})})]})},s)),s?.admin_items?.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.line_item_number})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.description})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.quantity})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[i?.price?.vat_rate," %"]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i?.price?.vat?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i?.price?.price?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i?.price?.price_incl_vat?.toFixed(2)]})})]})},s))]}),e.jsxs(j,{style:c.section,children:[e.jsx(y,{style:c.h3,children:"TOTALS"}),e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Incl. VAT"})})]}),e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{children:["€ ",s?.VAT_total?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{children:["€ ",s?.total_excl_vat?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{children:["€ ",s?.total_incl_vat?.toFixed(2)]})})]})]}),e.jsx(j,{style:c.section,children:e.jsxs(y,{style:{...c.h3,border:"2px solid black",padding:10},children:["Total Due: € ",s?.total_incl_vat?.toFixed(2)]})})]})}):e.jsx(d,{title:`invoice_${s?.invoice_number}`,children:e.jsxs(h,{size:"A4",style:c.page,children:[e.jsx(j,{style:c.header,children:e.jsx(y,{style:c.h1,children:p?.company_name})}),e.jsx(j,{style:c.section,children:e.jsx(y,{style:c.h2,children:"INVOICE"})}),e.jsx(j,{style:c.section,children:e.jsxs(j,{style:c.row,children:[e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:c.h3,children:"BILLING DETAILS"}),e.jsx(y,{children:S?.company_name}),e.jsxs(y,{children:[s?.buyer_first_name," ",s?.buyer_last_name]}),e.jsxs(y,{children:[u?.street," ",u?.street_number," ",u?.street_number_addition]}),e.jsxs(y,{children:[u?.postal_code," ",u?.city]})]}),e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:c.h3,children:"FROM"}),e.jsx(y,{children:p?.company_name}),e.jsxs(y,{children:[a?.street," ",a?.street_number," ",a?.street_number_addition]}),e.jsxs(y,{children:[a?.postal_code," ",a?.city]}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"CoC Number"}),e.jsx(y,{children:p?.coc_number}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"VAT Number"}),e.jsx(y,{children:p?.vat_number})]})]})}),e.jsx(j,{style:c.section,children:e.jsxs(j,{style:c.row,children:[e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice number: "}),e.jsx(y,{children:s?.invoice_number})]}),s?.customer_reference&&e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Your reference: "}),e.jsx(y,{children:s?.customer_reference})]}),e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice date"}),e.jsx(y,{children:s?.invoice_date})]})]})}),e.jsxs(j,{style:c.section,children:[e.jsx(y,{style:c.h3,children:"SUMMARY"}),e.jsxs(j,{style:c.row,children:[s?.admin_items?.length>0&&e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Line Item Number"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Title"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Amount"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT rate"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Incl. VAT"})})]}),s?.items?.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["product_title"in i&&i.product_title,"item_description"in i&&i.item_description]})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.quantity})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[i.vat_rate," %"]})}),e.jsx(j,{style:c.productRowSection,children:i.price_excl_vat&&i.price_incl_vat&&e.jsxs(y,{style:{fontSize:"10px"},children:["€"," ",(i.price_incl_vat-i.price_excl_vat)?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i.price_excl_vat?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i.price_incl_vat?.toFixed(2)]})})]})},s)),s?.admin_items?.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.line_item_number})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.description})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.quantity})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[i?.price?.vat_rate," %"]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i?.price?.vat?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i?.price?.price?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i?.price?.price_incl_vat?.toFixed(2)]})})]})},s))]}),e.jsxs(j,{style:c.section,children:[e.jsx(y,{style:c.h3,children:"TOTALS"}),e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Incl. VAT"})})]}),e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{children:["€ ",s?.VAT_total?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{children:["€ ",s?.total_excl_vat?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{children:["€ ",s?.total_incl_vat?.toFixed(2)]})})]})]}),e.jsx(j,{style:c.section,children:e.jsxs(y,{style:{...c.h3,border:"2px solid black",padding:10},children:["Total Due: € ",s?.total_incl_vat?.toFixed(2)]})})]})})};exports.InvoiceDownloadLink=function({invoice:s}){const[n,l]=t.useState(null);if(t.useEffect(()=>{(async()=>{const e=await x();l(e)})()},[]),!n)return e.jsx(i,{disabled:!0,children:e.jsx(o,{size:20})});const{PDFDownloadLink:c}=n;return e.jsx(c,{document:e.jsx(h,{props:{invoice:s}}),fileName:`invoice_${s?.invoice_number}`,children:e.jsx(i,{children:e.jsx(r,{})})})},exports.InvoicePDFViewer=function({invoice:d}){const[j,y]=t.useState(!1),[p,a]=t.useState(null);if(t.useEffect(()=>{(async()=>{const e=await x();a(e)})()},[]),!p)return e.jsx(i,{disabled:!0,children:e.jsx(o,{size:20})});const{PDFViewer:u}=p;return e.jsxs(e.Fragment,{children:[e.jsx(i,{onClick:()=>y(!0),children:e.jsx(r,{})}),e.jsxs(s,{open:j,fullWidth:!0,maxWidth:"lg",children:[e.jsx(n,{children:e.jsx(u,{style:{width:"100%",minHeight:"70vh"},children:e.jsx(h,{props:{invoice:d}})})}),e.jsx(l,{children:e.jsx(c,{variant:"contained",onClick:()=>y(!1),children:"Close"})})]})]})},exports.default=h;
|
|
7
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material/IconButton"),s=require("@mui/material/Dialog"),n=require("@mui/material/DialogContent"),r=require("@mui/material/DialogActions"),o=require("@mui/material/Button"),l=require("@mui/material/CircularProgress"),c=require("@mui/icons-material/PictureAsPdf");const d=()=>{const[e,i]=t.useState(null),[s,n]=t.useState(!0),[r,o]=t.useState(null);return t.useEffect(()=>{let e=!0;return(async()=>{try{const t=await import("@react-pdf/renderer");e&&(i(t),n(!1))}catch(t){console.error("Failed to load PDF renderer:",t),e&&(o("Failed to load PDF components"),n(!1))}})(),()=>{e=!1}},[]),{pdfComponents:e,loading:s,error:r}},x=(e,t,i="")=>t.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:i,e),h=({props:i})=>{const{invoice:s}=i,{pdfComponents:n,loading:r,error:o}=d();if(r)return e.jsx(l,{});if(o)return e.jsxs("div",{children:["Error loading PDF components: ",o]});if(!n)return e.jsx("div",{children:"PDF components not available"});if(!s)return e.jsx("div",{children:"No invoice data provided"});const{Document:c,Page:h,View:j,Text:y,StyleSheet:p}=n,a=(e=>e.create({page:{flexDirection:"column",backgroundColor:"#E4E4E4"},header:{padding:10,flexDirection:"row",alignItems:"center"},logo:{width:24,height:24,marginRight:10},section:{margin:10,padding:10,fontSize:12},row:{flexDirection:"row"},rowSection:{flex:1},productRowSection:{flex:1,width:1/6},h1:{fontSize:28},h2:{fontSize:24,fontWeight:"bold"},h3:{fontSize:16,fontWeight:"bold"}}))(p),{seller_business_credentials:u,seller_company_address:m,buyer_company_address:S,buyer_business_credentials:_,type:f}=s;return"credit"===f?e.jsx(c,{title:`credit_${x(s,"invoice_number","unknown")}`,children:e.jsxs(h,{size:"A4",style:a.page,children:[e.jsx(j,{style:a.header,children:e.jsx(y,{style:a.h1,children:x(u,"company_name")})}),e.jsx(j,{style:a.section,children:e.jsx(y,{style:a.h2,children:"CREDIT NOTE"})}),e.jsx(j,{style:a.section,children:e.jsxs(j,{style:a.row,children:[e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:a.h3,children:"BILLING DETAILS"}),e.jsx(y,{children:x(_,"company_name")}),e.jsxs(y,{children:[x(s,"buyer_first_name")," ",x(s,"buyer_last_name")]}),e.jsxs(y,{children:[x(S,"street")," ",x(S,"street_number")," ",x(S,"street_number_addition")]}),e.jsxs(y,{children:[x(S,"postal_code")," ",x(S,"city")]})]}),e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:a.h3,children:"FROM"}),e.jsx(y,{children:x(u,"company_name")}),e.jsxs(y,{children:[x(m,"street")," ",x(m,"street_number")," ",x(m,"street_number_addition")]}),e.jsxs(y,{children:[x(m,"postal_code")," ",x(m,"city")]}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"CoC Number"}),e.jsx(y,{children:x(u,"coc_number")}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"VAT Number"}),e.jsx(y,{children:x(u,"vat_number")})]})]})}),e.jsx(j,{style:a.section,children:e.jsxs(j,{style:a.row,children:[e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice number: "}),e.jsx(y,{children:x(s,"invoice_number")})]}),x(s,"customer_reference")&&e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Your reference: "}),e.jsx(y,{children:x(s,"customer_reference")})]}),e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice date"}),e.jsx(y,{children:x(s,"invoice_date")})]})]})}),e.jsxs(j,{style:a.section,children:[e.jsx(y,{style:a.h3,children:"SUMMARY"}),e.jsxs(j,{style:a.row,children:[s?.admin_items&&Array.isArray(s.admin_items)&&s.admin_items.length>0&&e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Line Item Number"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Title"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Amount"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT rate"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Incl. VAT"})})]}),s?.items&&Array.isArray(s.items)&&s.items.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[i&&"product_title"in i?i.product_title:"",i&&"item_description"in i?i.item_description:""]})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"quantity")})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[x(i,"vat_rate")," %"]})}),e.jsx(j,{style:a.productRowSection,children:i?.price_excl_vat&&i?.price_incl_vat&&e.jsxs(y,{style:{fontSize:"10px"},children:["€"," ",(i.price_incl_vat-i.price_excl_vat)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price_excl_vat",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price_incl_vat",0)?.toFixed(2)]})})]})},`credit-item-${s}`)),s?.admin_items&&Array.isArray(s.admin_items)&&s.admin_items.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"line_item_number")})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"description")})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"quantity")})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[x(i,"price.vat_rate")," %"]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price.vat",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price.price",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price.price_incl_vat",0)?.toFixed(2)]})})]})},`credit-admin-item-${s}`))]}),e.jsxs(j,{style:a.section,children:[e.jsx(y,{style:a.h3,children:"TOTALS"}),e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Incl. VAT"})})]}),e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{children:["€ ",x(s,"VAT_total",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{children:["€ ",x(s,"total_excl_vat",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{children:["€ ",x(s,"total_incl_vat",0)?.toFixed(2)]})})]})]}),e.jsx(j,{style:a.section,children:e.jsxs(y,{style:{...a.h3,border:"2px solid black",padding:10},children:["Total: € ",x(s,"total_incl_vat",0)?.toFixed(2)]})})]})}):"proforma"===f?e.jsx(c,{title:`proforma_${x(s,"invoice_number","unknown")}`,children:e.jsxs(h,{size:"A4",style:a.page,children:[e.jsx(j,{style:a.header,children:e.jsx(y,{style:a.h1,children:x(u,"company_name")})}),e.jsxs(j,{style:a.section,children:[e.jsx(y,{style:a.h2,children:"PROFORMA INVOICE"}),e.jsx(y,{style:{fontSize:10,marginTop:5},children:"This is not a final invoice and cannot be used for tax purposes"})]}),e.jsx(j,{style:a.section,children:e.jsxs(j,{style:a.row,children:[e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:a.h3,children:"BILLING DETAILS"}),e.jsx(y,{children:x(_,"company_name")}),e.jsxs(y,{children:[x(s,"buyer_first_name")," ",x(s,"buyer_last_name")]}),e.jsxs(y,{children:[x(S,"street")," ",x(S,"street_number")," ",x(S,"street_number_addition")]}),e.jsxs(y,{children:[x(S,"postal_code")," ",x(S,"city")]})]}),e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:a.h3,children:"FROM"}),e.jsx(y,{children:x(u,"company_name")}),e.jsxs(y,{children:[x(m,"street")," ",x(m,"street_number")," ",x(m,"street_number_addition")]}),e.jsxs(y,{children:[x(m,"postal_code")," ",x(m,"city")]}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"CoC Number"}),e.jsx(y,{children:x(u,"coc_number")}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"VAT Number"}),e.jsx(y,{children:x(u,"vat_number")})]})]})}),e.jsx(j,{style:a.section,children:e.jsxs(j,{style:a.row,children:[e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice number: "}),e.jsx(y,{children:x(s,"invoice_number")})]}),x(s,"customer_reference")&&e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Your reference: "}),e.jsx(y,{children:x(s,"customer_reference")})]}),e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice date"}),e.jsx(y,{children:x(s,"invoice_date")})]})]})}),e.jsxs(j,{style:a.section,children:[e.jsx(y,{style:a.h3,children:"SUMMARY"}),e.jsxs(j,{style:a.row,children:[s?.admin_items&&Array.isArray(s.admin_items)&&s.admin_items.length>0&&e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Line Item Number"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Title"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Amount"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT rate"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Incl. VAT"})})]}),s?.items&&Array.isArray(s.items)&&s.items.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[i&&"product_title"in i?i.product_title:"",i&&"item_description"in i?i.item_description:""]})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"quantity")})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[x(i,"vat_rate")," %"]})}),e.jsx(j,{style:a.productRowSection,children:i?.price_excl_vat&&i?.price_incl_vat&&e.jsxs(y,{style:{fontSize:"10px"},children:["€"," ",(i.price_incl_vat-i.price_excl_vat)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price_excl_vat",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price_incl_vat",0)?.toFixed(2)]})})]})},`proforma-item-${s}`)),s?.admin_items&&Array.isArray(s.admin_items)&&s.admin_items.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"line_item_number")})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"description")})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"quantity")})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[x(i,"price.vat_rate")," %"]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price.vat",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price.price",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price.price_incl_vat",0)?.toFixed(2)]})})]})},`proforma-admin-item-${s}`))]}),e.jsxs(j,{style:a.section,children:[e.jsx(y,{style:a.h3,children:"TOTALS"}),e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Incl. VAT"})})]}),e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{children:["€ ",x(s,"VAT_total",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{children:["€ ",x(s,"total_excl_vat",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{children:["€ ",x(s,"total_incl_vat",0)?.toFixed(2)]})})]})]}),e.jsx(j,{style:a.section,children:e.jsxs(y,{style:{...a.h3,border:"2px solid black",padding:10},children:["Total Due: € ",x(s,"total_incl_vat",0)?.toFixed(2)]})})]})}):e.jsx(c,{title:`invoice_${x(s,"invoice_number","unknown")}`,children:e.jsxs(h,{size:"A4",style:a.page,children:[e.jsx(j,{style:a.header,children:e.jsx(y,{style:a.h1,children:x(u,"company_name")})}),e.jsx(j,{style:a.section,children:e.jsx(y,{style:a.h2,children:"INVOICE"})}),e.jsx(j,{style:a.section,children:e.jsxs(j,{style:a.row,children:[e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:a.h3,children:"BILLING DETAILS"}),e.jsx(y,{children:x(_,"company_name")}),e.jsxs(y,{children:[x(s,"buyer_first_name")," ",x(s,"buyer_last_name")]}),e.jsxs(y,{children:[x(S,"street")," ",x(S,"street_number")," ",x(S,"street_number_addition")]}),e.jsxs(y,{children:[x(S,"postal_code")," ",x(S,"city")]})]}),e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:a.h3,children:"FROM"}),e.jsx(y,{children:x(u,"company_name")}),e.jsxs(y,{children:[x(m,"street")," ",x(m,"street_number")," ",x(m,"street_number_addition")]}),e.jsxs(y,{children:[x(m,"postal_code")," ",x(m,"city")]}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"CoC Number"}),e.jsx(y,{children:x(u,"coc_number")}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"VAT Number"}),e.jsx(y,{children:x(u,"vat_number")})]})]})}),e.jsx(j,{style:a.section,children:e.jsxs(j,{style:a.row,children:[e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice number: "}),e.jsx(y,{children:x(s,"invoice_number")})]}),x(s,"customer_reference")&&e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Your reference: "}),e.jsx(y,{children:x(s,"customer_reference")})]}),e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice date"}),e.jsx(y,{children:x(s,"invoice_date")})]})]})}),e.jsxs(j,{style:a.section,children:[e.jsx(y,{style:a.h3,children:"SUMMARY"}),e.jsxs(j,{style:a.row,children:[s?.admin_items&&Array.isArray(s.admin_items)&&s.admin_items.length>0&&e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Line Item Number"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Title"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Amount"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT rate"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Incl. VAT"})})]}),s?.items&&Array.isArray(s.items)&&s.items.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[i&&"product_title"in i?i.product_title:"",i&&"item_description"in i?i.item_description:""]})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"quantity")})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[x(i,"vat_rate")," %"]})}),e.jsx(j,{style:a.productRowSection,children:i?.price_excl_vat&&i?.price_incl_vat&&e.jsxs(y,{style:{fontSize:"10px"},children:["€"," ",(i.price_incl_vat-i.price_excl_vat)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price_excl_vat",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price_incl_vat",0)?.toFixed(2)]})})]})},`invoice-item-${s}`)),s?.admin_items&&Array.isArray(s.admin_items)&&s.admin_items.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"line_item_number")})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"description")})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"quantity")})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[x(i,"price.vat_rate")," %"]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price.vat",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price.price",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price.price_incl_vat",0)?.toFixed(2)]})})]})},`invoice-admin-item-${s}`))]}),e.jsxs(j,{style:a.section,children:[e.jsx(y,{style:a.h3,children:"TOTALS"}),e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Incl. VAT"})})]}),e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{children:["€ ",x(s,"VAT_total",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{children:["€ ",x(s,"total_excl_vat",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{children:["€ ",x(s,"total_incl_vat",0)?.toFixed(2)]})})]})]}),e.jsx(j,{style:a.section,children:e.jsxs(y,{style:{...a.h3,border:"2px solid black",padding:10},children:["Total Due: € ",x(s,"total_incl_vat",0)?.toFixed(2)]})})]})})};exports.InvoiceDownloadLink=function({invoice:t}){const{pdfComponents:s,loading:n,error:r}=d();if(n||r||!s||!t)return e.jsx(i,{disabled:!0,children:e.jsx(l,{size:20})});const{PDFDownloadLink:o}=s;try{return e.jsx(o,{document:e.jsx(h,{props:{invoice:t}}),fileName:`invoice_${x(t,"invoice_number","unknown")}`,children:e.jsx(i,{children:e.jsx(c,{})})})}catch(t){return console.error("Error creating PDF download link:",t),e.jsx(i,{disabled:!0,children:e.jsx(c,{})})}},exports.InvoicePDFViewer=function({invoice:x}){const[j,y]=t.useState(!1),[p,a]=t.useState(null),{pdfComponents:u,loading:m,error:S}=d();if(m||S||!u||!x)return e.jsx(i,{disabled:!0,children:e.jsx(l,{size:20})});const{PDFViewer:_}=u;return e.jsxs(e.Fragment,{children:[e.jsx(i,{onClick:()=>{a(null),y(!0)},children:e.jsx(c,{})}),e.jsxs(s,{open:j,fullWidth:!0,maxWidth:"lg",children:[e.jsx(n,{children:p?e.jsxs("div",{children:["Error rendering PDF: ",p]}):e.jsx(_,{style:{width:"100%",minHeight:"70vh"},children:e.jsx(h,{props:{invoice:x}})})}),e.jsx(r,{children:e.jsx(o,{variant:"contained",onClick:()=>y(!1),children:"Close"})})]})]})},exports.default=h;
|