umwd-components 0.1.643 → 0.1.644

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.
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__read as e,__assign as t}from"../../../../node_modules/tslib/tslib.es6.js";import{StyleSheet as l,PDFDownloadLink as n,PDFViewer as o,Document as c,Page as r,View as i,Text as a}from"@react-pdf/renderer";import m,{useState as d,Fragment as u}from"react";import s from"@mui/material/IconButton";import y from"@mui/material/Dialog";import E from"@mui/material/DialogContent";import v from"@mui/material/DialogActions";import p from"@mui/material/Button";import S from"@mui/icons-material/PictureAsPdf";var _=l.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,fontStyle:"bold"},h3:{fontSize:16,fontStyle:"bold"}});function f(e){var l,n,o,d,s,y,E,v,p,S,f,w,x,b,R,z,T,A,h,F,g,I=e.props.invoice;console.log("invoice from invoicePDF",I);var V=I.seller_business_credentials,N=I.seller_company_address,L=I.buyer_company_address,C=I.buyer_business_credentials,D=I.type;return I.invoice_number,console.log("type",D),"credit"===D?m.createElement(c,{title:"credit_".concat(null==I?void 0:I.invoice_number)},m.createElement(r,{size:"A4",style:_.page},m.createElement(i,{style:_.header},m.createElement(a,{style:_.h1},null==V?void 0:V.company_name)),m.createElement(i,{style:_.section},m.createElement(a,{style:_.h2},"CREDIT NOTE")),m.createElement(i,{style:_.section},m.createElement(i,{style:_.row},m.createElement(i,{style:_.rowSection},m.createElement(a,{style:_.h3},"BILLING DETAILS"),m.createElement(a,null,null==C?void 0:C.company_name),m.createElement(a,null,null==I?void 0:I.buyer_first_name," ",null==I?void 0:I.buyer_last_name),m.createElement(a,null,null==L?void 0:L.street," ",null==L?void 0:L.street_number," ",null==L?void 0:L.street_number_addition),m.createElement(a,null,null==L?void 0:L.postal_code," ",null==L?void 0:L.city)),m.createElement(i,{style:_.rowSection},m.createElement(a,{style:_.h3},"FROM"),m.createElement(a,null,null==V?void 0:V.company_name),m.createElement(a,null,null==N?void 0:N.street," ",null==N?void 0:N.street_number," ",null==N?void 0:N.street_number_addition),m.createElement(a,null,null==N?void 0:N.postal_code," ",null==N?void 0:N.city),m.createElement(a,{style:{fontStyle:"bold",marginTop:10}},"CoC Number"),m.createElement(a,null,null==V?void 0:V.coc_number),m.createElement(a,{style:{fontStyle:"bold",marginTop:10}},"VAT Number"),m.createElement(a,null,null==V?void 0:V.vat_number)))),m.createElement(i,{style:_.section},m.createElement(i,{style:_.row},m.createElement(i,{style:_.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Invoice number: "),m.createElement(a,null,null==I?void 0:I.invoice_number)),(null==I?void 0:I.customer_reference)&&m.createElement(i,{style:_.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Your reference: "),m.createElement(a,null,null==I?void 0:I.customer_reference)),m.createElement(i,{style:_.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Invoice date"),m.createElement(a,null,null==I?void 0:I.invoice_date)))),m.createElement(i,{style:_.section},m.createElement(a,{style:_.h3},"SUMMARY"),m.createElement(i,{style:_.row},(null===(l=null==I?void 0:I.admin_items)||void 0===l?void 0:l.length)>0&&m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Line Item Number")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Title")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Amount")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"VAT rate")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Excl. VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Incl. VAT"))),null===(n=null==I?void 0:I.items)||void 0===n?void 0:n.map((function(e,t){var l,n,o;return m.createElement(u,{key:t},m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"product_title"in e&&e.product_title,"item_description"in e&&e.item_description)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.quantity)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.vat_rate," %")," "),m.createElement(i,{style:_.productRowSection},e.price_excl_vat&&e.price_incl_vat&&m.createElement(a,{style:{fontSize:"10px"}},"€"," ",null===(l=e.price_incl_vat-e.price_excl_vat)||void 0===l?void 0:l.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(n=e.price_excl_vat)||void 0===n?void 0:n.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(o=e.price_incl_vat)||void 0===o?void 0:o.toFixed(2)))))})),null===(o=null==I?void 0:I.admin_items)||void 0===o?void 0:o.map((function(e,t){var l,n,o,c,r,d,s;return m.createElement(u,{key:t},m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.line_item_number)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.description)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.quantity)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},null===(l=null==e?void 0:e.price)||void 0===l?void 0:l.vat_rate," %")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(o=null===(n=null==e?void 0:e.price)||void 0===n?void 0:n.vat)||void 0===o?void 0:o.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(r=null===(c=null==e?void 0:e.price)||void 0===c?void 0:c.price)||void 0===r?void 0:r.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(s=null===(d=null==e?void 0:e.price)||void 0===d?void 0:d.price_incl_vat)||void 0===s?void 0:s.toFixed(2)))))}))),m.createElement(i,{style:_.section},m.createElement(a,{style:_.h3},"TOTALS"),m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Excl. VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Incl. VAT"))),m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection},m.createElement(a,null,"€ ",null===(d=null==I?void 0:I.VAT_total)||void 0===d?void 0:d.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,null,"€ ",null===(s=null==I?void 0:I.total_excl_vat)||void 0===s?void 0:s.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,null,"€ ",null===(y=null==I?void 0:I.total_incl_vat)||void 0===y?void 0:y.toFixed(2))))),m.createElement(i,{style:_.section},m.createElement(a,{style:t(t({},_.h3),{border:"2px solid black",padding:10})},"Total Due: € ",null===(E=null==I?void 0:I.total_incl_vat)||void 0===E?void 0:E.toFixed(2))))):"proforma"===D?m.createElement(c,{title:"proforma_".concat(null==I?void 0:I.invoice_number)},m.createElement(r,{size:"A4",style:_.page},m.createElement(i,{style:_.header},m.createElement(a,{style:_.h1},null==V?void 0:V.company_name)),m.createElement(i,{style:_.section},m.createElement(a,{style:_.h2},"PROFORMA INVOICE"),m.createElement(a,{style:{fontSize:10,marginTop:5}},"This is not a final invoice and cannot be used for tax purposes")),m.createElement(i,{style:_.section},m.createElement(i,{style:_.row},m.createElement(i,{style:_.rowSection},m.createElement(a,{style:_.h3},"BILLING DETAILS"),m.createElement(a,null,null==C?void 0:C.company_name),m.createElement(a,null,null==I?void 0:I.buyer_first_name," ",null==I?void 0:I.buyer_last_name),m.createElement(a,null,null==L?void 0:L.street," ",null==L?void 0:L.street_number," ",null==L?void 0:L.street_number_addition),m.createElement(a,null,null==L?void 0:L.postal_code," ",null==L?void 0:L.city)),m.createElement(i,{style:_.rowSection},m.createElement(a,{style:_.h3},"FROM"),m.createElement(a,null,null==V?void 0:V.company_name),m.createElement(a,null,null==N?void 0:N.street," ",null==N?void 0:N.street_number," ",null==N?void 0:N.street_number_addition),m.createElement(a,null,null==N?void 0:N.postal_code," ",null==N?void 0:N.city),m.createElement(a,{style:{fontStyle:"bold",marginTop:10}},"CoC Number"),m.createElement(a,null,null==V?void 0:V.coc_number),m.createElement(a,{style:{fontStyle:"bold",marginTop:10}},"VAT Number"),m.createElement(a,null,null==V?void 0:V.vat_number)))),m.createElement(i,{style:_.section},m.createElement(i,{style:_.row},m.createElement(i,{style:_.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Invoice number: "),m.createElement(a,null,null==I?void 0:I.invoice_number)),(null==I?void 0:I.customer_reference)&&m.createElement(i,{style:_.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Your reference: "),m.createElement(a,null,null==I?void 0:I.customer_reference)),m.createElement(i,{style:_.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Invoice date"),m.createElement(a,null,null==I?void 0:I.invoice_date)))),m.createElement(i,{style:_.section},m.createElement(a,{style:_.h3},"SUMMARY"),m.createElement(i,{style:_.row},(null===(v=null==I?void 0:I.admin_items)||void 0===v?void 0:v.length)>0&&m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Line Item Number")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Title")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Amount")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"VAT rate")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Excl. VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Incl. VAT"))),null===(p=null==I?void 0:I.items)||void 0===p?void 0:p.map((function(e,t){var l,n,o;return m.createElement(u,{key:t},m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"product_title"in e&&e.product_title,"item_description"in e&&e.item_description)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.quantity)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.vat_rate," %")," "),m.createElement(i,{style:_.productRowSection},e.price_excl_vat&&e.price_incl_vat&&m.createElement(a,{style:{fontSize:"10px"}},"€"," ",null===(l=e.price_incl_vat-e.price_excl_vat)||void 0===l?void 0:l.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(n=e.price_excl_vat)||void 0===n?void 0:n.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(o=e.price_incl_vat)||void 0===o?void 0:o.toFixed(2)))))})),null===(S=null==I?void 0:I.admin_items)||void 0===S?void 0:S.map((function(e,t){var l,n,o,c,r,d,s;return m.createElement(u,{key:t},m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.line_item_number)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.description)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.quantity)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},null===(l=null==e?void 0:e.price)||void 0===l?void 0:l.vat_rate," %")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(o=null===(n=null==e?void 0:e.price)||void 0===n?void 0:n.vat)||void 0===o?void 0:o.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(r=null===(c=null==e?void 0:e.price)||void 0===c?void 0:c.price)||void 0===r?void 0:r.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(s=null===(d=null==e?void 0:e.price)||void 0===d?void 0:d.price_incl_vat)||void 0===s?void 0:s.toFixed(2)))))}))),m.createElement(i,{style:_.section},m.createElement(a,{style:_.h3},"TOTALS"),m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Excl. VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Incl. VAT"))),m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection},m.createElement(a,null,"€ ",null===(f=null==I?void 0:I.VAT_total)||void 0===f?void 0:f.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,null,"€ ",null===(w=null==I?void 0:I.total_excl_vat)||void 0===w?void 0:w.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,null,"€ ",null===(x=null==I?void 0:I.total_incl_vat)||void 0===x?void 0:x.toFixed(2))))),m.createElement(i,{style:_.section},m.createElement(a,{style:t(t({},_.h3),{border:"2px solid black",padding:10})},"Total Due: € ",null===(b=null==I?void 0:I.total_incl_vat)||void 0===b?void 0:b.toFixed(2))))):m.createElement(c,{title:"invoice_".concat(null==I?void 0:I.invoice_number)},m.createElement(r,{size:"A4",style:_.page},m.createElement(i,{style:_.header},m.createElement(a,{style:_.h1},null==V?void 0:V.company_name)),m.createElement(i,{style:_.section},m.createElement(a,{style:_.h2},"INVOICE")),m.createElement(i,{style:_.section},m.createElement(i,{style:_.row},m.createElement(i,{style:_.rowSection},m.createElement(a,{style:_.h3},"BILLING DETAILS"),m.createElement(a,null,null==C?void 0:C.company_name),m.createElement(a,null,null==I?void 0:I.buyer_first_name," ",null==I?void 0:I.buyer_last_name),m.createElement(a,null,null==L?void 0:L.street," ",null==L?void 0:L.street_number," ",null==L?void 0:L.street_number_addition),m.createElement(a,null,null==L?void 0:L.postal_code," ",null==L?void 0:L.city)),m.createElement(i,{style:_.rowSection},m.createElement(a,{style:_.h3},"FROM"),m.createElement(a,null,null==V?void 0:V.company_name),m.createElement(a,null,null==N?void 0:N.street," ",null==N?void 0:N.street_number," ",null==N?void 0:N.street_number_addition),m.createElement(a,null,null==N?void 0:N.postal_code," ",null==N?void 0:N.city),m.createElement(a,{style:{fontStyle:"bold",marginTop:10}},"CoC Number"),m.createElement(a,null,null==V?void 0:V.coc_number),m.createElement(a,{style:{fontStyle:"bold",marginTop:10}},"VAT Number"),m.createElement(a,null,null==V?void 0:V.vat_number)))),m.createElement(i,{style:_.section},m.createElement(i,{style:_.row},m.createElement(i,{style:_.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Invoice number: "),m.createElement(a,null,null==I?void 0:I.invoice_number)),(null==I?void 0:I.customer_reference)&&m.createElement(i,{style:_.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Your reference: "),m.createElement(a,null,null==I?void 0:I.customer_reference)),m.createElement(i,{style:_.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Invoice date"),m.createElement(a,null,null==I?void 0:I.invoice_date)))),m.createElement(i,{style:_.section},m.createElement(a,{style:_.h3},"SUMMARY"),m.createElement(i,{style:_.row},(null===(R=null==I?void 0:I.admin_items)||void 0===R?void 0:R.length)>0&&m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Line Item Number")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Title")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Amount")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"VAT rate")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Excl. VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Incl. VAT"))),null===(z=null==I?void 0:I.items)||void 0===z?void 0:z.map((function(e,t){var l,n,o;return m.createElement(u,{key:t},m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"product_title"in e&&e.product_title,"item_description"in e&&e.item_description)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.quantity)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.vat_rate," %")," "),m.createElement(i,{style:_.productRowSection},e.price_excl_vat&&e.price_incl_vat&&m.createElement(a,{style:{fontSize:"10px"}},"€"," ",null===(l=e.price_incl_vat-e.price_excl_vat)||void 0===l?void 0:l.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(n=e.price_excl_vat)||void 0===n?void 0:n.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(o=e.price_incl_vat)||void 0===o?void 0:o.toFixed(2)))))})),null===(T=null==I?void 0:I.admin_items)||void 0===T?void 0:T.map((function(e,t){var l,n,o,c,r,d,s;return m.createElement(u,{key:t},m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.line_item_number)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.description)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.quantity)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},null===(l=null==e?void 0:e.price)||void 0===l?void 0:l.vat_rate," %")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(o=null===(n=null==e?void 0:e.price)||void 0===n?void 0:n.vat)||void 0===o?void 0:o.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(r=null===(c=null==e?void 0:e.price)||void 0===c?void 0:c.price)||void 0===r?void 0:r.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(s=null===(d=null==e?void 0:e.price)||void 0===d?void 0:d.price_incl_vat)||void 0===s?void 0:s.toFixed(2)))))}))),m.createElement(i,{style:_.section},m.createElement(a,{style:_.h3},"TOTALS"),m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Excl. VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Incl. VAT"))),m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection},m.createElement(a,null,"€ ",null===(A=null==I?void 0:I.VAT_total)||void 0===A?void 0:A.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,null,"€ ",null===(h=null==I?void 0:I.total_excl_vat)||void 0===h?void 0:h.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,null,"€ ",null===(F=null==I?void 0:I.total_incl_vat)||void 0===F?void 0:F.toFixed(2))))),m.createElement(i,{style:_.section},m.createElement(a,{style:t(t({},_.h3),{border:"2px solid black",padding:10})},"Total Due: € ",null===(g=null==I?void 0:I.total_incl_vat)||void 0===g?void 0:g.toFixed(2)))))}function w(e){var t=e.invoice;return m.createElement(n,{document:m.createElement(f,{props:{invoice:t}}),fileName:"invoice_".concat(null==t?void 0:t.invoice_number)},m.createElement(s,null,m.createElement(S,null)))}function x(t){var l=t.invoice,n=e(d(!1),2),c=n[0],r=n[1];return m.createElement(m.Fragment,null,m.createElement(s,{onClick:function(){return r(!0)}},m.createElement(S,null)),m.createElement(y,{open:c,fullWidth:!0,maxWidth:"lg"},m.createElement(E,null,m.createElement(o,{style:{width:"100%",minHeight:"70vh"}},m.createElement(f,{props:{invoice:l}}))),m.createElement(v,null,m.createElement(p,{variant:"contained",onClick:function(){return r(!1)}},"Close"))))}export{w as InvoiceDownloadLink,x as InvoicePDFViewer};
7
+ import{__read as e,__assign as t}from"../../../../node_modules/tslib/tslib.es6.js";import{StyleSheet as l,PDFDownloadLink as n,PDFViewer as o,Document as c,Page as r,View as i,Text as a}from"@react-pdf/renderer";import m,{useState as d,Fragment as u}from"react";import s from"@mui/material/IconButton";import y from"@mui/material/Dialog";import E from"@mui/material/DialogContent";import v from"@mui/material/DialogActions";import p from"@mui/material/Button";import S from"@mui/icons-material/PictureAsPdf";var _=l.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,fontStyle:"bold"},h3:{fontSize:16,fontStyle:"bold"}});function f(e){var l,n,o,d,s,y,E,v,p,S,f,w,x,b,R,z,T,A,h,F,g,I=e.props.invoice;console.log("invoice from invoicePDF",I);var V=I.seller_business_credentials,N=I.seller_company_address,L=I.buyer_company_address,C=I.buyer_business_credentials,D=I.type;return I.invoice_number,console.log("type",D),"credit"===D?m.createElement(c,{title:"credit_".concat(null==I?void 0:I.invoice_number)},m.createElement(r,{size:"A4",style:_.page},m.createElement(i,{style:_.header},m.createElement(a,{style:_.h1},null==V?void 0:V.company_name)),m.createElement(i,{style:_.section},m.createElement(a,{style:_.h2},"CREDIT NOTE")),m.createElement(i,{style:_.section},m.createElement(i,{style:_.row},m.createElement(i,{style:_.rowSection},m.createElement(a,{style:_.h3},"BILLING DETAILS"),m.createElement(a,null,null==C?void 0:C.company_name),m.createElement(a,null,null==I?void 0:I.buyer_first_name," ",null==I?void 0:I.buyer_last_name),m.createElement(a,null,null==L?void 0:L.street," ",null==L?void 0:L.street_number," ",null==L?void 0:L.street_number_addition),m.createElement(a,null,null==L?void 0:L.postal_code," ",null==L?void 0:L.city)),m.createElement(i,{style:_.rowSection},m.createElement(a,{style:_.h3},"FROM"),m.createElement(a,null,null==V?void 0:V.company_name),m.createElement(a,null,null==N?void 0:N.street," ",null==N?void 0:N.street_number," ",null==N?void 0:N.street_number_addition),m.createElement(a,null,null==N?void 0:N.postal_code," ",null==N?void 0:N.city),m.createElement(a,{style:{fontStyle:"bold",marginTop:10}},"CoC Number"),m.createElement(a,null,null==V?void 0:V.coc_number),m.createElement(a,{style:{fontStyle:"bold",marginTop:10}},"VAT Number"),m.createElement(a,null,null==V?void 0:V.vat_number)))),m.createElement(i,{style:_.section},m.createElement(i,{style:_.row},m.createElement(i,{style:_.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Invoice number: "),m.createElement(a,null,null==I?void 0:I.invoice_number)),(null==I?void 0:I.customer_reference)&&m.createElement(i,{style:_.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Your reference: "),m.createElement(a,null,null==I?void 0:I.customer_reference)),m.createElement(i,{style:_.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Invoice date"),m.createElement(a,null,null==I?void 0:I.invoice_date)))),m.createElement(i,{style:_.section},m.createElement(a,{style:_.h3},"SUMMARY"),m.createElement(i,{style:_.row},(null===(l=null==I?void 0:I.admin_items)||void 0===l?void 0:l.length)>0&&m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Line Item Number")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Title")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Amount")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"VAT rate")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Excl. VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Incl. VAT"))),null===(n=null==I?void 0:I.items)||void 0===n?void 0:n.map((function(e,t){var l,n,o;return m.createElement(u,{key:t},m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"product_title"in e&&e.product_title,"item_description"in e&&e.item_description)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.quantity)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.vat_rate," %")," "),m.createElement(i,{style:_.productRowSection},e.price_excl_vat&&e.price_incl_vat&&m.createElement(a,{style:{fontSize:"10px"}},"€"," ",null===(l=e.price_incl_vat-e.price_excl_vat)||void 0===l?void 0:l.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(n=e.price_excl_vat)||void 0===n?void 0:n.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(o=e.price_incl_vat)||void 0===o?void 0:o.toFixed(2)))))})),null===(o=null==I?void 0:I.admin_items)||void 0===o?void 0:o.map((function(e,t){var l,n,o,c,r,d,s;return m.createElement(u,{key:t},m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.line_item_number)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.description)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.quantity)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},null===(l=null==e?void 0:e.price)||void 0===l?void 0:l.vat_rate," %")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(o=null===(n=null==e?void 0:e.price)||void 0===n?void 0:n.vat)||void 0===o?void 0:o.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(r=null===(c=null==e?void 0:e.price)||void 0===c?void 0:c.price)||void 0===r?void 0:r.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(s=null===(d=null==e?void 0:e.price)||void 0===d?void 0:d.price_incl_vat)||void 0===s?void 0:s.toFixed(2)))))}))),m.createElement(i,{style:_.section},m.createElement(a,{style:_.h3},"TOTALS"),m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Excl. VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Incl. VAT"))),m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection},m.createElement(a,null,"€ ",null===(d=null==I?void 0:I.VAT_total)||void 0===d?void 0:d.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,null,"€ ",null===(s=null==I?void 0:I.total_excl_vat)||void 0===s?void 0:s.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,null,"€ ",null===(y=null==I?void 0:I.total_incl_vat)||void 0===y?void 0:y.toFixed(2))))),m.createElement(i,{style:_.section},m.createElement(a,{style:t(t({},_.h3),{border:"2px solid black",padding:10})},"Total: € ",null===(E=null==I?void 0:I.total_incl_vat)||void 0===E?void 0:E.toFixed(2))))):"proforma"===D?m.createElement(c,{title:"proforma_".concat(null==I?void 0:I.invoice_number)},m.createElement(r,{size:"A4",style:_.page},m.createElement(i,{style:_.header},m.createElement(a,{style:_.h1},null==V?void 0:V.company_name)),m.createElement(i,{style:_.section},m.createElement(a,{style:_.h2},"PROFORMA INVOICE"),m.createElement(a,{style:{fontSize:10,marginTop:5}},"This is not a final invoice and cannot be used for tax purposes")),m.createElement(i,{style:_.section},m.createElement(i,{style:_.row},m.createElement(i,{style:_.rowSection},m.createElement(a,{style:_.h3},"BILLING DETAILS"),m.createElement(a,null,null==C?void 0:C.company_name),m.createElement(a,null,null==I?void 0:I.buyer_first_name," ",null==I?void 0:I.buyer_last_name),m.createElement(a,null,null==L?void 0:L.street," ",null==L?void 0:L.street_number," ",null==L?void 0:L.street_number_addition),m.createElement(a,null,null==L?void 0:L.postal_code," ",null==L?void 0:L.city)),m.createElement(i,{style:_.rowSection},m.createElement(a,{style:_.h3},"FROM"),m.createElement(a,null,null==V?void 0:V.company_name),m.createElement(a,null,null==N?void 0:N.street," ",null==N?void 0:N.street_number," ",null==N?void 0:N.street_number_addition),m.createElement(a,null,null==N?void 0:N.postal_code," ",null==N?void 0:N.city),m.createElement(a,{style:{fontStyle:"bold",marginTop:10}},"CoC Number"),m.createElement(a,null,null==V?void 0:V.coc_number),m.createElement(a,{style:{fontStyle:"bold",marginTop:10}},"VAT Number"),m.createElement(a,null,null==V?void 0:V.vat_number)))),m.createElement(i,{style:_.section},m.createElement(i,{style:_.row},m.createElement(i,{style:_.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Invoice number: "),m.createElement(a,null,null==I?void 0:I.invoice_number)),(null==I?void 0:I.customer_reference)&&m.createElement(i,{style:_.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Your reference: "),m.createElement(a,null,null==I?void 0:I.customer_reference)),m.createElement(i,{style:_.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Invoice date"),m.createElement(a,null,null==I?void 0:I.invoice_date)))),m.createElement(i,{style:_.section},m.createElement(a,{style:_.h3},"SUMMARY"),m.createElement(i,{style:_.row},(null===(v=null==I?void 0:I.admin_items)||void 0===v?void 0:v.length)>0&&m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Line Item Number")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Title")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Amount")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"VAT rate")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Excl. VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Incl. VAT"))),null===(p=null==I?void 0:I.items)||void 0===p?void 0:p.map((function(e,t){var l,n,o;return m.createElement(u,{key:t},m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"product_title"in e&&e.product_title,"item_description"in e&&e.item_description)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.quantity)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.vat_rate," %")," "),m.createElement(i,{style:_.productRowSection},e.price_excl_vat&&e.price_incl_vat&&m.createElement(a,{style:{fontSize:"10px"}},"€"," ",null===(l=e.price_incl_vat-e.price_excl_vat)||void 0===l?void 0:l.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(n=e.price_excl_vat)||void 0===n?void 0:n.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(o=e.price_incl_vat)||void 0===o?void 0:o.toFixed(2)))))})),null===(S=null==I?void 0:I.admin_items)||void 0===S?void 0:S.map((function(e,t){var l,n,o,c,r,d,s;return m.createElement(u,{key:t},m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.line_item_number)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.description)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.quantity)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},null===(l=null==e?void 0:e.price)||void 0===l?void 0:l.vat_rate," %")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(o=null===(n=null==e?void 0:e.price)||void 0===n?void 0:n.vat)||void 0===o?void 0:o.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(r=null===(c=null==e?void 0:e.price)||void 0===c?void 0:c.price)||void 0===r?void 0:r.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(s=null===(d=null==e?void 0:e.price)||void 0===d?void 0:d.price_incl_vat)||void 0===s?void 0:s.toFixed(2)))))}))),m.createElement(i,{style:_.section},m.createElement(a,{style:_.h3},"TOTALS"),m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Excl. VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Incl. VAT"))),m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection},m.createElement(a,null,"€ ",null===(f=null==I?void 0:I.VAT_total)||void 0===f?void 0:f.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,null,"€ ",null===(w=null==I?void 0:I.total_excl_vat)||void 0===w?void 0:w.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,null,"€ ",null===(x=null==I?void 0:I.total_incl_vat)||void 0===x?void 0:x.toFixed(2))))),m.createElement(i,{style:_.section},m.createElement(a,{style:t(t({},_.h3),{border:"2px solid black",padding:10})},"Total Due: € ",null===(b=null==I?void 0:I.total_incl_vat)||void 0===b?void 0:b.toFixed(2))))):m.createElement(c,{title:"invoice_".concat(null==I?void 0:I.invoice_number)},m.createElement(r,{size:"A4",style:_.page},m.createElement(i,{style:_.header},m.createElement(a,{style:_.h1},null==V?void 0:V.company_name)),m.createElement(i,{style:_.section},m.createElement(a,{style:_.h2},"INVOICE")),m.createElement(i,{style:_.section},m.createElement(i,{style:_.row},m.createElement(i,{style:_.rowSection},m.createElement(a,{style:_.h3},"BILLING DETAILS"),m.createElement(a,null,null==C?void 0:C.company_name),m.createElement(a,null,null==I?void 0:I.buyer_first_name," ",null==I?void 0:I.buyer_last_name),m.createElement(a,null,null==L?void 0:L.street," ",null==L?void 0:L.street_number," ",null==L?void 0:L.street_number_addition),m.createElement(a,null,null==L?void 0:L.postal_code," ",null==L?void 0:L.city)),m.createElement(i,{style:_.rowSection},m.createElement(a,{style:_.h3},"FROM"),m.createElement(a,null,null==V?void 0:V.company_name),m.createElement(a,null,null==N?void 0:N.street," ",null==N?void 0:N.street_number," ",null==N?void 0:N.street_number_addition),m.createElement(a,null,null==N?void 0:N.postal_code," ",null==N?void 0:N.city),m.createElement(a,{style:{fontStyle:"bold",marginTop:10}},"CoC Number"),m.createElement(a,null,null==V?void 0:V.coc_number),m.createElement(a,{style:{fontStyle:"bold",marginTop:10}},"VAT Number"),m.createElement(a,null,null==V?void 0:V.vat_number)))),m.createElement(i,{style:_.section},m.createElement(i,{style:_.row},m.createElement(i,{style:_.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Invoice number: "),m.createElement(a,null,null==I?void 0:I.invoice_number)),(null==I?void 0:I.customer_reference)&&m.createElement(i,{style:_.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Your reference: "),m.createElement(a,null,null==I?void 0:I.customer_reference)),m.createElement(i,{style:_.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Invoice date"),m.createElement(a,null,null==I?void 0:I.invoice_date)))),m.createElement(i,{style:_.section},m.createElement(a,{style:_.h3},"SUMMARY"),m.createElement(i,{style:_.row},(null===(R=null==I?void 0:I.admin_items)||void 0===R?void 0:R.length)>0&&m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Line Item Number")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Title")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Amount")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"VAT rate")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Excl. VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Incl. VAT"))),null===(z=null==I?void 0:I.items)||void 0===z?void 0:z.map((function(e,t){var l,n,o;return m.createElement(u,{key:t},m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"product_title"in e&&e.product_title,"item_description"in e&&e.item_description)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.quantity)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.vat_rate," %")," "),m.createElement(i,{style:_.productRowSection},e.price_excl_vat&&e.price_incl_vat&&m.createElement(a,{style:{fontSize:"10px"}},"€"," ",null===(l=e.price_incl_vat-e.price_excl_vat)||void 0===l?void 0:l.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(n=e.price_excl_vat)||void 0===n?void 0:n.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(o=e.price_incl_vat)||void 0===o?void 0:o.toFixed(2)))))})),null===(T=null==I?void 0:I.admin_items)||void 0===T?void 0:T.map((function(e,t){var l,n,o,c,r,d,s;return m.createElement(u,{key:t},m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.line_item_number)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.description)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.quantity)),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},null===(l=null==e?void 0:e.price)||void 0===l?void 0:l.vat_rate," %")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(o=null===(n=null==e?void 0:e.price)||void 0===n?void 0:n.vat)||void 0===o?void 0:o.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(r=null===(c=null==e?void 0:e.price)||void 0===c?void 0:c.price)||void 0===r?void 0:r.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(s=null===(d=null==e?void 0:e.price)||void 0===d?void 0:d.price_incl_vat)||void 0===s?void 0:s.toFixed(2)))))}))),m.createElement(i,{style:_.section},m.createElement(a,{style:_.h3},"TOTALS"),m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Excl. VAT")),m.createElement(i,{style:_.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Incl. VAT"))),m.createElement(i,{style:_.row},m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection}),m.createElement(i,{style:_.productRowSection},m.createElement(a,null,"€ ",null===(A=null==I?void 0:I.VAT_total)||void 0===A?void 0:A.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,null,"€ ",null===(h=null==I?void 0:I.total_excl_vat)||void 0===h?void 0:h.toFixed(2))),m.createElement(i,{style:_.productRowSection},m.createElement(a,null,"€ ",null===(F=null==I?void 0:I.total_incl_vat)||void 0===F?void 0:F.toFixed(2))))),m.createElement(i,{style:_.section},m.createElement(a,{style:t(t({},_.h3),{border:"2px solid black",padding:10})},"Total Due: € ",null===(g=null==I?void 0:I.total_incl_vat)||void 0===g?void 0:g.toFixed(2)))))}function w(e){var t=e.invoice;return m.createElement(n,{document:m.createElement(f,{props:{invoice:t}}),fileName:"invoice_".concat(null==t?void 0:t.invoice_number)},m.createElement(s,null,m.createElement(S,null)))}function x(t){var l=t.invoice,n=e(d(!1),2),c=n[0],r=n[1];return m.createElement(m.Fragment,null,m.createElement(s,{onClick:function(){return r(!0)}},m.createElement(S,null)),m.createElement(y,{open:c,fullWidth:!0,maxWidth:"lg"},m.createElement(E,null,m.createElement(o,{style:{width:"100%",minHeight:"70vh"}},m.createElement(f,{props:{invoice:l}}))),m.createElement(v,null,m.createElement(p,{variant:"contained",onClick:function(){return r(!1)}},"Close"))))}export{w as InvoiceDownloadLink,x as InvoicePDFViewer};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- import{__read as e,__spreadArray as t,__assign as n,__awaiter as r,__generator as a}from"../../../../node_modules/tslib/tslib.es6.js";import i,{useState as l,useEffect as o}from"react";import{useFormState as c}from"react-dom";import{updateIroAction as m}from"../../../data/actions/e-commerce/iro/updateIroAction.js";import u from"./TextualIROItemUpdater.js";import s from"./IroItemDisplay.js";import d from"../../logistics/note/NotesDisplay.js";import v from"../../logistics/note/NoteTakingComponent.js";import{StrapiErrors as p}from"../../StrapiErrors.js";import{SubmitButton as f}from"../../SubmitButton.js";import E from"@mui/material/Alert";import g from"@mui/material/Dialog";import _ from"@mui/material/DialogActions";import h from"@mui/material/DialogContent";import y from"@mui/material/DialogTitle";import b from"@mui/material/Typography";import x from"@mui/material/Button";import C from"@mui/material/Grid";import w from"@mui/material/Box";import q from"@mui/material/Paper";import I from"@mui/material/Stack";import k from"@mui/material/Divider";import{confirmationService as A}from"../../../data/services/common/confirmation-service.js";import{cancellationService as D}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as j,Checkbox as R,DialogContentText as T,CircularProgress as W,TextField as S,List as P,ListItem as F}from"@mui/material";import O from"@mui/icons-material/Numbers";import N from"@mui/icons-material/AssignmentReturn";import B from"@mui/icons-material/CalendarToday";import M from"@mui/icons-material/Business";import U from"@mui/icons-material/Description";import z from"@mui/icons-material/Update";import{IroStatusIndicator as V}from"./IroStatusIndicator.js";import{queryAllProducts as Y}from"../../../data/loaders/e-commerce/queryAllProducts.js";import Q from"../../../../node_modules/qs/lib/index.js";var G={zodErrors:null,strapiErrors:null,data:null,message:null};function J(c){var m,u,s=this,d=c.open,v=c.handleClose,p=c.overwrites,f=c.setOverwrites,E=c.iro,C=e(l(!1),2),w=C[0],q=C[1];return o((function(){var e,t;d&&(null===(t=null===(e=null==E?void 0:E.iro_items)||void 0===e?void 0:e.data)||void 0===t?void 0:t.length)>0&&r(s,void 0,void 0,(function(){var e,t,n,r,i,l;return a(this,(function(a){switch(a.label){case 0:return q(!0),e=Q.stringify({filters:{product_number:{$in:E.iro_items.data.map((function(e){var t,n;return(null===(n=null===(t=e.product)||void 0===t?void 0:t.product_number)||void 0===n?void 0:n.replace(/^r-/,""))||""}))}},populate:{price:!0}},{encodeValuesOnly:!0}),[4,Y(e)];case 1:return t=a.sent(),n=t.data.map((function(e){return{id:e.id,product_number:e.product_number,price:e.price}})),console.log("correspondingProducts",n),q(!1),r=0,i=0,l=E.iro_items.data.map((function(e,t){var a=e.product,l=n.find((function(e){var t;return e.product_number===(null===(t=null==a?void 0:a.product_number)||void 0===t?void 0:t.replace(/^r-/,""))||""})),o=0,c=0,m=0;if(l&&l.price){o=l.price.price||0,c=l.price.price_incl_vat||0,m=l.price.vat_rate||0;var u=o*e.returned_quantity,s=c*e.returned_quantity;r+=u,i+=s}return{vat_rate:m,price_excl_vat:o,price_incl_vat:c,quantity:e.returned_quantity}})),f({customer_internal_reference:E.customer_reference||"",total_excl_vat:parseFloat(r.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:l}),[2]}}))}))}),[d,E]),i.createElement(g,{open:d,fullWidth:!0,maxWidth:"lg"},i.createElement(y,null,"Check or overwrite value for the return payment"),i.createElement(h,null,i.createElement(I,{spacing:2,alignItems:"left",sx:{px:0}},i.createElement(T,null,"This is very important because these values will be used for automated invoice generation"),i.createElement(T,{variant:"h5"},"Overwrites"),w?i.createElement(W,null):i.createElement(I,{spacing:2},i.createElement(S,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:p.customer_internal_reference,onChange:function(e){return f(n(n({},p),{customer_internal_reference:e.target.value}))}}),i.createElement(S,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:p.total_excl_vat,onChange:function(e){return f(n(n({},p),{total_excl_vat:parseFloat(e.target.value)}))}}),i.createElement(S,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:p.total_incl_vat,onChange:function(e){return f(n(n({},p),{total_incl_vat:parseFloat(e.target.value)}))}})),(null===(u=null===(m=null==E?void 0:E.iro_items)||void 0===m?void 0:m.data)||void 0===u?void 0:u.length)>0&&i.createElement(i.Fragment,null,i.createElement(T,{variant:"h5"},"Items"),E.iro_items.data.map((function(r,a){var l,o,c,m,u,s,d,v,E,g,_,h,y,x;return i.createElement(I,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},key:r.id},i.createElement(b,{sx:{minWidth:100}},r.line_item_number),i.createElement(b,{sx:{minWidth:150}},null===(l=r.product)||void 0===l?void 0:l.product_number),i.createElement(b,{sx:{minWidth:200}},null===(o=r.product)||void 0===o?void 0:o.title),i.createElement(S,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:null!==(u=null===(m=null===(c=null==p?void 0:p.lines)||void 0===c?void 0:c[a])||void 0===m?void 0:m.vat_rate)&&void 0!==u?u:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{vat_rate:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}),i.createElement(S,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:null!==(v=null===(d=null===(s=null==p?void 0:p.lines)||void 0===s?void 0:s[a])||void 0===d?void 0:d.price_excl_vat)&&void 0!==v?v:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{price_excl_vat:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}),i.createElement(S,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:null!==(_=null===(g=null===(E=null==p?void 0:p.lines)||void 0===E?void 0:E[a])||void 0===g?void 0:g.price_incl_vat)&&void 0!==_?_:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{price_incl_vat:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}),i.createElement(S,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:null!==(x=null===(y=null===(h=null==p?void 0:p.lines)||void 0===h?void 0:h[a])||void 0===y?void 0:y.quantity)&&void 0!==x?x:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{quantity:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}))}))))),i.createElement(_,null,i.createElement(x,{variant:"contained",onClick:function(e){A("iros",[E.id],p),v()}},"Confirm"),i.createElement(x,{variant:"contained",onClick:v},"Cancel")))}function L(e){var t=e.open,n=e.handleClose,r=e.orderID,a=e.currentStatus,l=e.revalidateCallback,o=e.openOverwritesDialog;return i.createElement(g,{open:t},i.createElement(y,null,"Confirm Return"),i.createElement(h,null,i.createElement(I,{spacing:2},i.createElement(b,null,"Are you sure you want to confirm this return?"),i.createElement(P,null,"requested"===a&&i.createElement(F,null,"When confirming this return order a rma number will be generated"),i.createElement(F,null,"requested"===a?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done"),"finalising_process"===a&&i.createElement(F,null,"Confirming this order will automatically create an invoice")),i.createElement(b,null,"Current status: ",a))),i.createElement(_,null,i.createElement(x,{variant:"contained",onClick:function(e){"finalising_process"===a?(o&&o(),n()):"requested"===a&&(A("iros",[r]),l&&l(),n())}},"Yes"),i.createElement(x,{variant:"contained",onClick:n},"No")))}function $(t){var n=t.open,r=t.handleClose,a=t.orderID,o=t.revalidateCallback,c=e(l(""),2),m=c[0],u=c[1],s=e(l(""),2),d=s[0],v=s[1];return i.createElement("form",null,i.createElement(g,{open:n},i.createElement(y,null,"Cancel Return"),i.createElement(h,null,i.createElement(I,{spacing:2},i.createElement(b,null,"Are you sure you want to cancel this return?"),i.createElement(P,null,i.createElement(F,null,"By cancelling this return order you will update it's status from requested to cancelled"),i.createElement(F,null,"Please provide a reason for the cancellation"),i.createElement(F,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),i.createElement(S,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:m,onChange:function(e){return u(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d}))),i.createElement(_,null,i.createElement(x,{variant:"contained",onClick:function(e){m.length<5?v("Please provide a reason for the cancellation"):(D("iros",a,m),o&&o(),r())}},"Yes"),i.createElement(x,{variant:"contained",onClick:r},"No"))))}function H(r){var a,g,_,h,y=r.data,A=r.sx,D=r.revalidateCallback;r.handleClose;var T=r.role,W=e(c(m,G),2),S=W[0],P=W[1],F=e(l(y.iro_items.data?y.iro_items.data:[]),2),Y=F[0],Q=F[1],H=e(l(!1),2),K=H[0],X=H[1],Z=e(l(!1),2),ee=Z[0],te=Z[1],ne=e(l(!1),2),re=ne[0],ae=ne[1],ie=e(l({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),2),le=ie[0],oe=ie[1],ce=e(l(["received","registered","released","reports"]),2),me=ce[0],ue=ce[1],se=function(n,r,a){var i=t([],e(Y),!1),l=i.findIndex((function(e){return e.id===r}));i[l][a]=n,Q(i)},de=function(r,a){var i,l,o,c=t([],e(Y),!1),m=c.findIndex((function(e){return e.id===a})),u=(null===(l=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===l?void 0:l.data)||[],s=t(t([],e(u),!1),[r],!1);null==(null===(o=c[m])||void 0===o?void 0:o.reports)&&(c[m]=n(n({},c[m]),{reports:{data:[]}})),c[m].reports.data=s,Q(c)},ve=function(n,r){var a,i,l=t([],e(Y),!1),o=l.findIndex((function(e){return e.id===n})),c=(null===(i=null===(a=l[o])||void 0===a?void 0:a.reports)||void 0===i?void 0:i.data)||[],m=c.filter((function(e){return"id"in e})),u=c.filter((function(e){return!("id"in e)}));u.splice(r,1);var s=t(t([],e(m),!1),e(u),!1);l[o].reports.data=s,Q(l)};return o((function(){"Iro Updated"===(null==S?void 0:S.message)&&D&&D()}),[S]),o((function(){var e;console.log("data",y),(null===(e=y.iro_items)||void 0===e?void 0:e.data)&&Q(y.iro_items.data?y.iro_items.data:[])}),[y]),i.createElement(w,{sx:t([],e(Array.isArray(A)?A:[A]),!1)},i.createElement(C,{container:!0,spacing:2},i.createElement(C,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(I,{spacing:2},i.createElement(b,{variant:"h3",component:"h1"},"Management Inbound Return"),i.createElement(b,{variant:"body1"},"Manage arrival, registration and release of returns")),i.createElement(v,{content:"",related:[{id:y.id,__type:"api::e-commerce.iro"}],revalidateCallback:D})),i.createElement(k,null))),i.createElement(C,{item:!0,xs:12},i.createElement(b,{variant:"h5",sx:{py:1}},"Details")),i.createElement(C,{item:!0,xs:6},i.createElement(q,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(O,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Number"),i.createElement(b,{variant:"body1",fontWeight:"medium"},y.return_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(N,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"RMA Number"),i.createElement(b,{variant:"body1",fontWeight:"medium"},y.rma_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(U,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer Reference"),i.createElement(b,{variant:"body1",fontWeight:"medium"},y.customer_reference)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(B,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Date"),i.createElement(b,{variant:"body1",fontWeight:"medium"},y.return_date)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(M,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),i.createElement(b,{variant:"body1",fontWeight:"medium"},null===(g=null===(a=y.customer)||void 0===a?void 0:a.business_credentials)||void 0===g?void 0:g.company_name)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(z,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Status"),i.createElement(V,{status:y.status}))))),("requested"===y.status||"finalising_process"===y.status)&&"enduser"===T&&i.createElement(C,{item:!0,xs:6},i.createElement(q,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(x,{variant:"contained",color:"primary",onClick:function(){return X(!0)}},"Confirm order"),"requested"===y.status&&i.createElement(E,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning"),"finalising_process"===y.status&&i.createElement(E,{severity:"warning"},"Please finalise this return order. Make sure the customer recieves a return payment if eligible and than confirm this step. Status: finalising_process - done"),"finalising_process"===y.status&&i.createElement(x,{variant:"contained",sx:{color:"yellow"}},"// TODO RE-PAYMENT PROCESS"),i.createElement(x,{variant:"contained",color:"error",onClick:function(){return te(!0)}},"Cancel order"),i.createElement(L,{open:K,handleClose:function(){return X(!1)},orderID:y.id,currentStatus:y.status,revalidateCallback:D,openOverwritesDialog:function(){return ae(!0)}}),i.createElement(J,{open:re,handleClose:function(){return ae(!1)},overwrites:le,setOverwrites:oe,iro:y}),i.createElement($,{open:ee,handleClose:function(){return te(!1)},orderID:y.id,revalidateCallback:D})))),i.createElement(C,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(b,{variant:"h5"},"Documents"),i.createElement(q,{sx:{p:2}},i.createElement(I,{spacing:1})))),(null===(h=null===(_=null==y?void 0:y.notes)||void 0===_?void 0:_.data)||void 0===h?void 0:h.length)>0&&i.createElement(C,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(b,{variant:"h5"},"Notes"),i.createElement(d,{notes:y.notes.data}),i.createElement(k,null))),i.createElement(C,{item:!0,xs:12},i.createElement(I,{spacing:1},i.createElement(b,{variant:"h5"},"Items"),i.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:q,p:1},i.createElement(b,{variant:"body1"},"Show:"),["received","registered","released","reports"].map((function(n){return i.createElement(j,{key:n,control:i.createElement(R,{checked:me.includes(n),onChange:function(r){r.target.checked?ue(t(t([],e(me),!1),[n],!1)):ue(me.filter((function(e){return e!==n})))}}),label:n.charAt(0).toUpperCase()+n.slice(1)})}))),"requested"===y.status&&i.createElement(E,{severity:"warning"},"Before confirmation you cannot update the items"),i.createElement(k,null),i.createElement("form",{action:P},i.createElement("input",{name:"id",type:"hidden",value:y.id}),Y&&Y.map((function(e,t){var n,r;return i.createElement(q,{sx:{p:2,mb:2},key:t},"requested"===y.status||"cancelled"===y.status||"done"===y.status?i.createElement(s,{item:e,index:t,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image}):i.createElement(u,{item:e,index:t,handleUpdateQuantity:se,handleAddReport:de,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image,handleRemoveReportAtIndex:ve,revalidateCallback:D,showing:me}))})),i.createElement(q,{sx:{p:2}},i.createElement(I,{direction:"row",spacing:2,justifyContent:"end"},i.createElement(f,{text:"Update items",loadingText:"Loading..."}),i.createElement(p,{error:null==S?void 0:S.strapiErrors}),(null==S?void 0:S.message)&&i.createElement(E,{severity:"error"},null==S?void 0:S.message))),i.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,n;return{id:e.id,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:(null===(n=null===(t=e.reports)||void 0===t?void 0:t.data)||void 0===n?void 0:n.map((function(e){return{id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}})))||[]}}))}(Y))}))))))}export{H as default};
6
+ import{__read as e,__spreadArray as t,__assign as n,__awaiter as r,__generator as a}from"../../../../node_modules/tslib/tslib.es6.js";import i,{useState as l,useEffect as o}from"react";import{useFormState as c}from"react-dom";import{updateIroAction as m}from"../../../data/actions/e-commerce/iro/updateIroAction.js";import s from"./TextualIROItemUpdater.js";import u from"./IroItemDisplay.js";import d from"../../logistics/note/NotesDisplay.js";import v from"../../logistics/note/NoteTakingComponent.js";import{SubmitButton as p}from"../../SubmitButton.js";import f from"@mui/material/Alert";import E from"@mui/material/Dialog";import g from"@mui/material/DialogActions";import h from"@mui/material/DialogContent";import _ from"@mui/material/DialogTitle";import y from"@mui/material/Typography";import b from"@mui/material/Button";import x from"@mui/material/Grid";import C from"@mui/material/Box";import w from"@mui/material/Paper";import I from"@mui/material/Stack";import q from"@mui/material/Divider";import{confirmationService as k}from"../../../data/services/common/confirmation-service.js";import{cancellationService as A}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as D,Checkbox as R,DialogContentText as j,CircularProgress as T,TextField as W,List as S,ListItem as O}from"@mui/material";import P from"@mui/icons-material/Numbers";import F from"@mui/icons-material/AssignmentReturn";import N from"@mui/icons-material/CalendarToday";import B from"@mui/icons-material/Business";import M from"@mui/icons-material/Description";import U from"@mui/icons-material/Update";import{IroStatusIndicator as z}from"./IroStatusIndicator.js";import{queryAllProducts as V}from"../../../data/loaders/e-commerce/queryAllProducts.js";import Y from"../../../../node_modules/qs/lib/index.js";import{useSnackbar as Q}from"../../../context/common/SnackbarContext.js";var G={zodErrors:null,strapiErrors:null,data:null,message:null};function J(c){var m,s,u=this,d=c.open,v=c.handleClose,p=c.overwrites,f=c.setOverwrites,x=c.iro,C=e(l(!1),2),w=C[0],q=C[1];return o((function(){var e,t;d&&(null===(t=null===(e=null==x?void 0:x.iro_items)||void 0===e?void 0:e.data)||void 0===t?void 0:t.length)>0&&r(u,void 0,void 0,(function(){var e,t,n,r,i,l;return a(this,(function(a){switch(a.label){case 0:return q(!0),e=Y.stringify({filters:{product_number:{$in:x.iro_items.data.map((function(e){var t,n;return(null===(n=null===(t=e.product)||void 0===t?void 0:t.product_number)||void 0===n?void 0:n.replace(/^r-/,""))||""}))}},populate:{price:!0}},{encodeValuesOnly:!0}),[4,V(e)];case 1:return t=a.sent(),n=t.data.map((function(e){return{id:e.id,product_number:e.product_number,price:e.price}})),console.log("correspondingProducts",n),q(!1),r=0,i=0,l=x.iro_items.data.map((function(e,t){var a=e.product,l=n.find((function(e){var t;return e.product_number===(null===(t=null==a?void 0:a.product_number)||void 0===t?void 0:t.replace(/^r-/,""))||""})),o=0,c=0,m=0;if(l&&l.price){o=l.price.price||0,c=l.price.price_incl_vat||0,m=l.price.vat_rate||0;var s=o*e.returned_quantity,u=c*e.returned_quantity;r+=s,i+=u}return{vat_rate:m,price_excl_vat:o,price_incl_vat:c,quantity:e.returned_quantity}})),f({customer_internal_reference:x.customer_reference||"",total_excl_vat:parseFloat(r.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:l}),[2]}}))}))}),[d,x]),i.createElement(E,{open:d,fullWidth:!0,maxWidth:"lg"},i.createElement(_,null,"Check or overwrite value for the return payment"),i.createElement(h,null,i.createElement(I,{spacing:2,alignItems:"left",sx:{px:0}},i.createElement(j,null,"This is very important because these values will be used for automated invoice generation"),i.createElement(j,{variant:"h5"},"Overwrites"),w?i.createElement(T,null):i.createElement(I,{spacing:2},i.createElement(W,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:p.customer_internal_reference,onChange:function(e){return f(n(n({},p),{customer_internal_reference:e.target.value}))}}),i.createElement(W,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:p.total_excl_vat,onChange:function(e){return f(n(n({},p),{total_excl_vat:parseFloat(e.target.value)}))}}),i.createElement(W,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:p.total_incl_vat,onChange:function(e){return f(n(n({},p),{total_incl_vat:parseFloat(e.target.value)}))}})),(null===(s=null===(m=null==x?void 0:x.iro_items)||void 0===m?void 0:m.data)||void 0===s?void 0:s.length)>0&&i.createElement(i.Fragment,null,i.createElement(j,{variant:"h5"},"Items"),x.iro_items.data.map((function(r,a){var l,o,c,m,s,u,d,v,E,g,h,_,b,x;return i.createElement(I,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},key:r.id},i.createElement(y,{sx:{minWidth:100}},r.line_item_number),i.createElement(y,{sx:{minWidth:150}},null===(l=r.product)||void 0===l?void 0:l.product_number),i.createElement(y,{sx:{minWidth:200}},null===(o=r.product)||void 0===o?void 0:o.title),i.createElement(W,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:null!==(s=null===(m=null===(c=null==p?void 0:p.lines)||void 0===c?void 0:c[a])||void 0===m?void 0:m.vat_rate)&&void 0!==s?s:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{vat_rate:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}),i.createElement(W,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:null!==(v=null===(d=null===(u=null==p?void 0:p.lines)||void 0===u?void 0:u[a])||void 0===d?void 0:d.price_excl_vat)&&void 0!==v?v:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{price_excl_vat:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}),i.createElement(W,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:null!==(h=null===(g=null===(E=null==p?void 0:p.lines)||void 0===E?void 0:E[a])||void 0===g?void 0:g.price_incl_vat)&&void 0!==h?h:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{price_incl_vat:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}),i.createElement(W,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:null!==(x=null===(b=null===(_=null==p?void 0:p.lines)||void 0===_?void 0:_[a])||void 0===b?void 0:b.quantity)&&void 0!==x?x:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{quantity:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}))}))))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){k("iros",[x.id],p),v()}},"Confirm"),i.createElement(b,{variant:"contained",onClick:v},"Cancel")))}function L(e){var t=e.open,n=e.handleClose,r=e.orderID,a=e.currentStatus,l=e.revalidateCallback,o=e.openOverwritesDialog;return i.createElement(E,{open:t},i.createElement(_,null,"Confirm Return"),i.createElement(h,null,i.createElement(I,{spacing:2},i.createElement(y,null,"Are you sure you want to confirm this return?"),i.createElement(S,null,"requested"===a&&i.createElement(O,null,"When confirming this return order a rma number will be generated"),i.createElement(O,null,"requested"===a?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done"),"finalising_process"===a&&i.createElement(O,null,"Confirming this order will automatically create an invoice")),i.createElement(y,null,"Current status: ",a))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){"finalising_process"===a?(o&&o(),n()):"requested"===a&&(k("iros",[r]),l&&l(),n())}},"Yes"),i.createElement(b,{variant:"contained",onClick:n},"No")))}function $(t){var n=t.open,r=t.handleClose,a=t.orderID,o=t.revalidateCallback,c=e(l(""),2),m=c[0],s=c[1],u=e(l(""),2),d=u[0],v=u[1];return i.createElement("form",null,i.createElement(E,{open:n},i.createElement(_,null,"Cancel Return"),i.createElement(h,null,i.createElement(I,{spacing:2},i.createElement(y,null,"Are you sure you want to cancel this return?"),i.createElement(S,null,i.createElement(O,null,"By cancelling this return order you will update it's status from requested to cancelled"),i.createElement(O,null,"Please provide a reason for the cancellation"),i.createElement(O,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),i.createElement(W,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:m,onChange:function(e){return s(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d}))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){m.length<5?v("Please provide a reason for the cancellation"):(A("iros",a,m),o&&o(),r())}},"Yes"),i.createElement(b,{variant:"contained",onClick:r},"No"))))}function H(r){var a,E,g,h,_=r.data,k=r.sx,A=r.revalidateCallback,j=r.handleClose,T=r.role,W=e(c(m,G),2),S=W[0],O=W[1],V=e(l(_.iro_items.data?_.iro_items.data:[]),2),Y=V[0],H=V[1],K=e(l(!1),2),X=K[0],Z=K[1],ee=e(l(!1),2),te=ee[0],ne=ee[1],re=e(l(!1),2),ae=re[0],ie=re[1],le=e(l({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),2),oe=le[0],ce=le[1],me=e(l(["received","registered","released","reports"]),2),se=me[0],ue=me[1],de=function(n,r,a){var i=t([],e(Y),!1),l=i.findIndex((function(e){return e.id===r}));i[l][a]=n,H(i)},ve=function(r,a){var i,l,o,c=t([],e(Y),!1),m=c.findIndex((function(e){return e.id===a})),s=(null===(l=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===l?void 0:l.data)||[],u=t(t([],e(s),!1),[r],!1);null==(null===(o=c[m])||void 0===o?void 0:o.reports)&&(c[m]=n(n({},c[m]),{reports:{data:[]}})),c[m].reports.data=u,H(c)},pe=function(n,r){var a,i,l=t([],e(Y),!1),o=l.findIndex((function(e){return e.id===n})),c=(null===(i=null===(a=l[o])||void 0===a?void 0:a.reports)||void 0===i?void 0:i.data)||[],m=c.filter((function(e){return"id"in e})),s=c.filter((function(e){return!("id"in e)}));s.splice(r,1);var u=t(t([],e(m),!1),e(s),!1);l[o].reports.data=u,H(l)},fe=Q().handleAddMessage;return o((function(){"Iro Updated"===(null==S?void 0:S.message)&&(fe({message:"Iro Updated",severity:"success"}),j&&j(),A&&A())}),[S]),o((function(){(null==S?void 0:S.strapiErrors)&&fe({message:S.strapiErrors.message||"Error updating IRO",severity:"error"})}),[null==S?void 0:S.strapiErrors]),o((function(){var e;console.log("data",_),(null===(e=_.iro_items)||void 0===e?void 0:e.data)&&H(_.iro_items.data?_.iro_items.data:[])}),[_]),i.createElement(C,{sx:t([],e(Array.isArray(k)?k:[k]),!1)},i.createElement(x,{container:!0,spacing:2},i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(I,{spacing:2},i.createElement(y,{variant:"h3",component:"h1"},"Management Inbound Return"),i.createElement(y,{variant:"body1"},"Manage arrival, registration and release of returns")),i.createElement(v,{content:"",related:[{id:_.id,__type:"api::e-commerce.iro"}],revalidateCallback:A})),i.createElement(q,null))),i.createElement(x,{item:!0,xs:12},i.createElement(y,{variant:"h5",sx:{py:1}},"Details")),i.createElement(x,{item:!0,xs:6},i.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(P,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Number"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.return_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(F,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"RMA Number"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.rma_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(M,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer Reference"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.customer_reference)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(N,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Date"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.return_date)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(B,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),i.createElement(y,{variant:"body1",fontWeight:"medium"},null===(E=null===(a=_.customer)||void 0===a?void 0:a.business_credentials)||void 0===E?void 0:E.company_name)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(U,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Status"),i.createElement(z,{status:_.status}))))),("requested"===_.status||"finalising_process"===_.status)&&"enduser"===T&&i.createElement(x,{item:!0,xs:6},i.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(b,{variant:"contained",color:"primary",onClick:function(){return Z(!0)}},"Confirm order"),"requested"===_.status&&i.createElement(f,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning"),"finalising_process"===_.status&&i.createElement(f,{severity:"warning"},"Please finalise this return order. Make sure the customer recieves a return payment if eligible and than confirm this step. Status: finalising_process - done"),"finalising_process"===_.status&&i.createElement(b,{variant:"contained",sx:{color:"yellow"}},"// TODO RE-PAYMENT PROCESS"),i.createElement(b,{variant:"contained",color:"error",onClick:function(){return ne(!0)}},"Cancel order"),i.createElement(L,{open:X,handleClose:function(){return Z(!1)},orderID:_.id,currentStatus:_.status,revalidateCallback:A,openOverwritesDialog:function(){return ie(!0)}}),i.createElement(J,{open:ae,handleClose:function(){return ie(!1)},overwrites:oe,setOverwrites:ce,iro:_}),i.createElement($,{open:te,handleClose:function(){return ne(!1)},orderID:_.id,revalidateCallback:A})))),i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(y,{variant:"h5"},"Documents"),i.createElement(w,{sx:{p:2}},i.createElement(I,{spacing:1})))),(null===(h=null===(g=null==_?void 0:_.notes)||void 0===g?void 0:g.data)||void 0===h?void 0:h.length)>0&&i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(y,{variant:"h5"},"Notes"),i.createElement(d,{notes:_.notes.data}),i.createElement(q,null))),i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:1},i.createElement(y,{variant:"h5"},"Items"),i.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:w,p:1},i.createElement(y,{variant:"body1"},"Show:"),["received","registered","released","reports"].map((function(n){return i.createElement(D,{key:n,control:i.createElement(R,{checked:se.includes(n),onChange:function(r){r.target.checked?ue(t(t([],e(se),!1),[n],!1)):ue(se.filter((function(e){return e!==n})))}}),label:n.charAt(0).toUpperCase()+n.slice(1)})}))),"requested"===_.status&&i.createElement(f,{severity:"warning"},"Before confirmation you cannot update the items"),i.createElement(q,null),i.createElement("form",{action:O},i.createElement("input",{name:"id",type:"hidden",value:_.id}),Y&&Y.map((function(e,t){var n,r;return i.createElement(w,{sx:{p:2,mb:2},key:t},"requested"===_.status||"cancelled"===_.status||"done"===_.status?i.createElement(u,{item:e,index:t,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image}):i.createElement(s,{item:e,index:t,handleUpdateQuantity:de,handleAddReport:ve,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image,handleRemoveReportAtIndex:pe,revalidateCallback:A,showing:se}))})),i.createElement(w,{sx:{p:2}},i.createElement(I,{direction:"row",spacing:2,justifyContent:"end"},i.createElement(p,{text:"Update items",loadingText:"Loading..."}))),i.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,n;return{id:e.id,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:(null===(n=null===(t=e.reports)||void 0===t?void 0:t.data)||void 0===n?void 0:n.map((function(e){return{id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}})))||[]}}))}(Y))}))))))}export{H as default};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__read as e,__assign as t,__spreadArray as s}from"../../../node_modules/tslib/tslib.es6.js";import a,{useReducer as r,useContext as o,createContext as n}from"react";import d from"../../../node_modules/uuid/dist/esm-browser/v4.js";var i={messages:[]},c=n({state:i,dispatch:function(){},handleAddMessage:function(){}}),u=function(a,r){switch(r.type){case"SET_STATE":return t({},r.payload);case"ADD_MESSAGE":return t(t({},a),{messages:s(s([],e(a.messages),!1),[r.payload],!1)});default:throw new Error("No case for type ".concat(r.type))}},l=function(s){var o=s.children,n=e(r(u,i),2),l=n[0],p=n[1],m=a.useCallback((function(e){var s=t(t({},e),{open:!0,id:d()});p({type:"ADD_MESSAGE",payload:s})}),[p]),f={state:l,dispatch:p,handleAddMessage:m};return a.createElement(c.Provider,{value:f},o)},p=function(){return o(c)};export{l as SnackbarProvider,p as useSnackbar};
7
+ import{__read as e,__assign as a,__spreadArray as n}from"../../../node_modules/tslib/tslib.es6.js";import s,{useReducer as t,useContext as o,createContext as r}from"react";import d from"../../../node_modules/uuid/dist/esm-browser/v4.js";var i={messages:[]},c=r({state:i,dispatch:function(){},handleAddMessage:function(){},handleAddMessages:function(){},handleClose:function(){}}),u=function(s,t){switch(t.type){case"SET_STATE":return a({},t.payload);case"ADD_MESSAGE":return a(a({},s),{messages:n(n([],e(s.messages),!1),[t.payload],!1)});case"UPDATE_MESSAGES":return a(a({},s),{messages:t.payload});default:throw new Error("No case for type ".concat(t.type))}},l=function(o){var r=o.children,l=e(t(u,i),2),p=l[0],f=l[1],E=s.useCallback((function(e){var n=a(a({},e),{open:!0,id:d()});f({type:"ADD_MESSAGE",payload:n})}),[f]),m=s.useCallback((function(e){e.map((function(e){return a(a({},e),{open:!0,id:d()})})).forEach((function(e){f({type:"ADD_MESSAGE",payload:e})}))}),[f]),A={state:p,dispatch:f,handleAddMessage:E,handleAddMessages:m,handleClose:function(a,s,t){if("clickaway"!==s){var o=n([],e(p.messages),!1),r=o.findIndex((function(e){return e.id===t}));-1!==r&&(o[r].open=!1,f({type:"UPDATE_MESSAGES",payload:o}))}}};return s.createElement(c.Provider,{value:A},r)},p=function(){return o(c)};export{l as SnackbarProvider,p as useSnackbar};