@bookipi/htmlgenerator 1.0.8 → 1.1.1

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/README.md CHANGED
@@ -25,11 +25,14 @@ b) npm link react-dom
25
25
  ```jsx
26
26
  import React, { Component } from 'react'
27
27
 
28
- import {Invoice} from '@bookipi/htmlgenerator'
28
+ import {InvoiceCompatHtml} from '@bookipi/htmlgenerator'
29
29
 
30
30
  class Example extends Component {
31
31
  render() {
32
- return <Invoice invoice={invoice} lang={lang} />
32
+ return <div dangerouslySetInnerHTML={{__html: InvoiceCompatHtml(
33
+ invoice,
34
+ lang
35
+ )}} />
33
36
  }
34
37
  }
35
38
  ```
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
2
2
 
3
3
  var moment = _interopDefault(require('moment-timezone'));
4
- var React = _interopDefault(require('react'));
5
4
 
6
5
  function _extends() {
7
6
  _extends = Object.assign || function (target) {
@@ -1813,9 +1812,131 @@ var invoiceHtml = (function (_ref) {
1813
1812
 
1814
1813
  var signatureContainer = document.signDate && "\n <div className=\"col-6\" style={textAlign:'center'}>\n <strong>{document.customerSignature || customerSignBase64 ? company.name : ''}</strong>\n <div style={{height:'130px',borderBottom:'2px solid #dee2e6', marginRight:'40px', marginLeft:'40px'}}>\n { signatureBase64 && <img src=" + signatureBase64 + " style={{width:'220px',marginTop:'20px'}} />}\n </div>\n <div>{document.signDate && formatDate(document.signDate) }</div>\n </div>" || '';
1815
1814
  var clientSignature = (document.customer || customerSignBase64) && "\n <div className=\"col-6\" style={{textAlign: 'center'}}>\n <strong>{customer.companyName}</strong>\n <div style={{height:'130px',borderBottom:'2px solid #dee2e6', marginRight:'40px', marginLeft:'40px'}}>\n { customerSignBase64 && <img src=" + customerSignBase64 + " style={{width:'220px',marginTop:'20px'}} />}\n </div>\n <div>{customerSignBase64 ? formatDate(new Date()) : '( &nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp/ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp)'}</div>\n </div>" || '';
1816
- return "\n<!DOCTYPE html>\n<html>\n <head>\n <meta charset=\"utf-8\">\n <title>Invoice</title>\n <link rel=\"stylesheet\" href=\"https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css\" integrity=\"sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh\" crossorigin=\"anonymous\">\n <link href=\"https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css\" rel=\"stylesheet\">\n </head>\n <style>\n body {\n font-size: 18px;\n }\n .invoice-body {\n background: #fff;\n padding: 50px\n }\n\n .invoice-company {\n font-size: 20px\n }\n\n .invoice-header {\n /* margin: 0 -50px; */\n background: #f0f3f4;\n padding: 30px 50px;\n }\n .invoice-content {\n padding: 38px;\n }\n .invoice-date,\n .invoice-from,\n .invoice-to {\n /* display: table-cell; */\n /* width: 1% */\n }\n\n .invoice-from,\n .invoice-to {\n padding-right: 20px\n }\n\n .invoice-date .date,\n .invoice-from strong,\n .invoice-to strong {\n font-size: 18px;\n font-weight: 600\n }\n\n .invoice-date {\n /* text-align: right; */\n padding-left: 20px\n }\n\n .invoice-price {\n /* background: #f0f3f4; */\n display: table;\n width: 100%\n }\n\n .invoice-price .invoice-price-left,\n .invoice-price .invoice-price-right {\n display: table-cell;\n padding: 28px 12px 16px;\n font-size: 20px;\n font-weight: 600;\n width: 70%;\n position: relative;\n vertical-align: middle\n }\n\n .invoice-price .invoice-price-left .sub-price {\n display: table-cell;\n vertical-align: middle;\n padding: 0 20px\n }\n\n .invoice-price small {\n font-size: 18px;\n font-weight: 400;\n display: block\n }\n\n .invoice-price .invoice-price-row {\n display: table;\n float: left\n }\n\n .invoice-price .invoice-price-right {\n width: 30%;\n background: #2d353c;\n color: #fff;\n font-size: 28px;\n text-align: right;\n vertical-align: bottom;\n font-weight: 300;\n right: 38px;\n }\n\n .invoice-price .invoice-price-right small {\n display: block;\n opacity: .7;\n position: absolute;\n top: 10px;\n left: 12px;\n font-size: 18px\n }\n\n .invoice-footer {\n border-top: 1px solid #ddd;\n padding-top: 10px;\n font-size: 18px\n }\n\n .invoice-note {\n color: #999;\n margin-top: 80px;\n font-size: 85%\n }\n\n .invoice-body > div:not(.invoice-footer) {\n margin-bottom: 20px\n }\n\n .btn.btn-white, .btn.btn-white.disabled, .btn.btn-white.disabled:focus, .btn.btn-white.disabled:hover, .btn.btn-white[disabled], .btn.btn-white[disabled]:focus, .btn.btn-white[disabled]:hover {\n color: #2d353c;\n background: #fff;\n border-color: #d9dfe3;\n }\n .table-inline-block{\n display: inline-block;\n }\n\n @media print {\n body, page {\n /* width: 21cm; */\n /* margin: 0; */\n box-shadow: 0;\n background-color: #fff\n }\n /* .invoice-body {\n padding:10;\n } */\n #invoice {\n width:100%\n }\n\n .invoice-price .invoice-price-right {\n background: #f0f3f4;\n color: black;\n border: 2px solid #f0f3f4;\n }\n }\n\n @media only screen {\n #invoice {\n margin-top:10px;\n max-width:28cm;\n zoom: 0.8;\n box-shadow: 0 0 0.5cm rgba(0,0,0,0.2);\n margin-right:auto;margin-left:auto;\n background: white;\n }\n }\n\n @media (min-width: 767.99px) {\n .invoice-detail-right {\n max-width: 200px;\n }\n }\n @media (max-width: 767.98px) {\n .invoice-body {\n padding: 30px\n }\n .invoice-header {\n padding: 20px 30px;\n }\n .invoice-content {\n padding: 18px;\n }\n .invoice-price .invoice-price-right {\n right: 18px;\n }\n #invoice-logo {\n padding-top:0;\n max-width: 250px;\n text-align: center;\n margin-right:auto;\n margin-left:auto;\n display: block;\n }\n .invoice-date {\n margin-top:10px;\n border-top: 1px solid #dee2e6;\n }\n }\n\n .table-small td{\n padding: 8px 12px\n }\n .table-invoice-header{\n background: #f0f3f4\n }\n h1,h2,h3,h4 {margin-top:15px}\n h1 {font-size:27px}\n h2 {font-size:22px}\n </style>\n <body>\n <div id=\"invoice\" class=\"print\">\n <div class=\"invoice-body\">\n <!-- begin invoice-company -->\n <div class=\"row\">\n <div class=\"col-sm-12 col-md-6 mb-3 mb-md-0\">\n " + logoContainer + "\n </div>\n <div class=\"col-sm-12 col-md-6 text-md-right\">\n <h1>" + documentName + "</h1>\n <div class=\"text-inverse mb-1\" style=\"font-size: 20px;\">\n <strong>" + company.c + "</strong>\n </div>\n <address class=\"m-t-5 m-b-5\">\n <div class=\"mb-2\">\n " + (companyAddress.address1 ? "<div>" + companyAddress.address1 + "</div>" : "") + "\n " + (companyAddress.address2 ? "<div>" + companyAddress.address2 + "</div>" : "") + "\n " + (companyAddress.address3 ? "<div>" + companyAddress.address3 + "</div>" : "") + "\n " + (companyAddress.city || companyAddress.state || companyAddress.zip ? "<div>" + ((companyAddress.city ? companyAddress.city + " " : "") + (companyAddress.state ? companyAddress.state + " " : "") + (companyAddress.zip ? companyAddress.zip + " " : "")) + "</div>" : "") + "\n " + (companyAddress.country ? "<div>" + companyAddress.country + "</div>" : "") + "\n </div>\n " + (company.ai ? "<div>" + company.ai + "</div>" : "") + "\n " + (company.ph ? "<div>" + company.ph + "</div>" : "") + "\n " + (company.de ? "<div>" + company.de + "</div>" : "") + "\n " + (company.tfn ? "<div>" + ((company.bn ? company.bn : "Tax no.") + " : " + company.tfn) + "</div>" : "") + "\n </address>\n </div>\n </div>\n </div>\n <!-- end invoice-company -->\n <!-- begin invoice-header -->\n <div class=\"invoice-header\">\n <div class=\"row\">\n <div class=\"invoice-to col-sm-12 col-md-6\">\n <strong>" + (company.r_bt ? company.r_bt : lang["bill_to"]) + "</strong>\n <div class=\"text-inverse mb-1\">\n <small style=\"font-size: 18px;\">" + document.cu.c + "</small>\n </div>\n <address class=\"m-t-5 m-b-5\">\n " + (customerAddress.address1 ? "<div>" + customerAddress.address1 + "</div>" : "") + "\n " + (customerAddress.address2 ? "<div>" + customerAddress.address2 + "</div>" : "") + "\n " + (customerAddress.address3 ? "<div>" + customerAddress.address3 + "</div>" : "") + "\n " + (customerAddress.city || customerAddress.state || customerAddress.zip ? "<div>" + ((customerAddress.city ? customerAddress.city + " " : "") + (customerAddress.state ? customerAddress.state + " " : "") + (customerAddress.zip ? customerAddress.zip + " " : "")) + "</div>" : "") + "\n " + (customerAddress.country ? "<div>" + customerAddress.country + "</div>" : "") + "\n " + (document.cu.tfn ? "<div>" + (document.cu.tfn ? (company.bn || "Tax no.") + " : " + document.cu.tfn : "") + "</div>" : "") + "\n " + (document.cu.ph ? "<div>" + document.cu.ph + "</div>" : "") + "\n </address>\n\n " + (shippingAddressExists ? "<strong stryle=\"margin-top:10px\">" + (company.r_st ? company.r_st : lang.ship_to) + "</strong>" : "") + "\n " + (shippingAddressExists ? "\n <address class=\"m-t-5 m-b-5\">\n " + (customerShippingAddress.address1 ? "<div>" + customerShippingAddress.address1 + "</div>" : "") + "\n " + (customerShippingAddress.address2 ? "<div>" + customerShippingAddress.address2 + "</div>" : "") + "\n " + (customerShippingAddress.address3 ? "<div>" + customerShippingAddress.address3 + "</div>" : "") + "\n " + (customerShippingAddress.city || customerShippingAddress.state || customerShippingAddress.zip ? "<div>" + ((customerShippingAddress.city ? customerShippingAddress.city + " " : "") + (customerShippingAddress.state ? customerShippingAddress.state + " " : "") + (customerShippingAddress.zip ? customerShippingAddress.zip + " " : "")) + "</div>" : "") + "\n " + (customerShippingAddress.country ? "<div>" + customerShippingAddress.country + "</div>" : "") + "\n " + (document.asi ? "<div>" + document.asi + "</div>" : "") + "\n </address>\n " : "") + "\n </div>\n\n <div class=\"invoice-date col-sm-12 col-md-6\">\n <small>&nbsp;</small>\n <div class=\"row text-md-right\">\n <div class=\"col\">\n <strong>" + documentName + " #</strong>\n </div>\n <div class=\"col invoice-detail-right\">" + (document.no ? document.no : "") + "</div>\n </div>\n <div class=\"row text-md-right\">\n <div class=\"col\">\n <strong>" + (company.r_d ? company.r_d : lang["date"]) + "</strong>\n </div>\n <div class=\"col invoice-detail-right\">" + formatDate(document.d) + "</div>\n </div>\n " + (document.ty == 1 && !document.rd ? "<div class=\"row text-md-right\">\n <div class=\"col\">\n <strong>" + (company.r_dd ? company.r_dd : lang["due_date"]) + "</strong>\n </div>\n <div class=\"col invoice-detail-right\">\n " + (document.dd ? formatDate(document.dd) : formatDate(new Date(document.d).setDate(new Date(document.d).getDate() + parseInt(document.di)))) + "\n </div>\n </div>" : '') + "\n " + (document.pon ? "<div class=\"row text-md-right\">\n <div class=\"col\">\n <strong>" + (company.r_po ? company.r_po : lang['po_number']) + "</strong>\n </div>\n <div class=\"col invoice-detail-right\">" + document.pon + "</div>\n </div>\n " : '') + "\n </div>\n </div>\n </div>\n <!-- end invoice-header -->\n <!-- begin invoice-content -->\n <div class=\"invoice-content\">\n <div class=\"table-responsive\">\n <table class=\"table table-invoice\">\n <thead>\n <tr class=\"table table-invoice\">\n <th class=\"text-left\">" + (company.r_it ? company.r_it : lang['item']) + "</th>\n <th class=\"text-center d-none d-sm-table-cell\" width=\"15%\">" + (document.um ? document.um : company.r_q ? company.r_q : lang['quantity']) + "</th>\n <th class=\"text-right d-none d-sm-table-cell\" width=\"15%\">" + (company.r_p ? company.r_p : lang['price']) + "</th>\n " + (discountOnItem ? "<th class=\"text-right\" width=\"15%\">" + (company.r_dc ? company.r_dc : lang['discount']) + "</th>" : '') + "\n <th class=\"text-right\" width=\"15%\">" + (company.r_a ? company.r_a : lang['amount']) + "</th>\n </tr>\n </thead>\n <tbody>\n " + itemsContainer + "\n </tbody>\n </table>\n </div>\n \n <hr>\n <div class=\"row\">\n <div class=\"col-12\">\n <table class=\"table table-borderless table-small\">\n <tbody>\n <tr>\n <td class=\"d-none d-sm-table-cell\"></td>\n <td class=\"text-md-right\" width=\"25%\">" + (company.r_sb ? company.r_sb : lang["subtotal"]) + "</td>\n <td class=\"text-right\" width=\"25%\">" + FormatCurrency(document.st, company.cr, company.la, company.cf) + "</td>\n </tr>\n " + (document.dc ? " <tr>\n <td class=\"d-none d-sm-table-cell\"></td>\n <td class=\"text-md-right\" width=\"25%\">" + ((company.r_dc ? company.r_dc : lang["discount"]) + (document.dcpo && document.dcp ? " (" + document.dcp + "%)" : "")) + "</td>\n <td class=\"text-right\" width=\"25%\">" + ("(" + FormatCurrency(document.dc, company.cr, company.la, company.cf) + ")") + "</td>\n </tr>" : '') + "\n " + (document.sp && !document.sntx ? "<tr>\n <td class=\"d-none d-sm-table-cell\"></td>\n <td class=\"text-md-right\" width=\"25%\">" + (company.r_sp ? company.r_sp : lang["shipping"]) + "</td>\n <td class=\"text-right\" width=\"25%\">" + FormatCurrency(document.sp, company.cr, company.la, company.cf) + "</td>\n </tr>" : '') + "\n " + (document.tx != 0 ? "<tr>\n <td class=\"d-none d-sm-table-cell\"></td>\n <td class=\"text-md-right\" width=\"25%\">" + (taxName1 + taxIncluded1 + "(" + document.tp + "%)") + "</td>\n <td class=\"text-right\" width=\"25%\">" + ((document.t1d ? "(" : "") + FormatCurrency(document.tx, company.cr, company.la, company.cf) + (document.t1d ? ")" : "")) + "</td>\n </tr>" : '') + "\n " + (document.ttx && document.tx2 != 0 ? "<tr>\n <td class=\"d-none d-sm-table-cell\"></td>\n <td class=\"text-md-right\" width=\"25%\">" + (taxName2 + taxIncluded2 + "(" + document.tp2 + "%)") + "</td>\n <td class=\"text-right\" width=\"25%\">" + ((document.t2d ? "(" : "") + FormatCurrency(document.tx2, company.cr, company.la, company.cf) + (document.t2d ? ")" : "")) + "</td>\n </tr>" : '') + "\n " + (document.sp && document.sntx ? " <tr>\n <td class=\"d-none d-sm-table-cell\"></td>\n <td class=\"text-md-right\" width=\"25%\">" + (company.r_sp ? company.r_sp : lang["shipping"]) + "</td>\n <td class=\"text-right\" width=\"25%\">" + FormatCurrency(document.sp, company.cr, company.la, company.cf) + "</td>\n </tr>" : '') + "\n " + (document.ti ? " <tr>\n <td class=\"d-none d-sm-table-cell\"></td>\n <td class=\"text-md-right\" width=\"25%\" style=\"border-top: 1px solid #ddd\">" + (company.r_n ? company.r_n : lang["net"]) + "</td>\n <td class=\"text-right\" width=\"25%\" style=\"border-top: 1px solid #ddd\">" + FormatCurrency(document.tt - (document.tx || 0) - (document.tx2 || 0), company.cr, company.la, company.cd) + "</td>\n </tr>" : '') + "\n " + (document.ty == 1 || document.ty !== 1 && (document.t1d || document.ttx && document.tx2 > 0 && document.t2d) ? "<tr>\n <td class=\"d-none d-sm-table-cell\"></td>\n <td class=\"text-md-right\" width=\"25%\" style=\"border-bottom: 1px solid #ddd\">" + (company.r_tt ? company.r_tt : lang["total"]) + "</td>\n <td class=\"text-right\" width=\"25%\" style=\"border-bottom: 1px solid #ddd\">" + FormatCurrency(document.tt ? document.tt : 0, company.cr, company.la, company.cf) + "</td>\n </tr>" : '') + "\n " + (document.sca ? "<tr>\n <td class=\"d-none d-sm-table-cell\"></td>\n <td class=\"text-md-right\" width=\"25%\">" + lang["credit_card_surcharge"] + "</td>\n <td class=\"text-right\" width=\"25%\">" + FormatCurrency(document.sca, company.cr, company.la, company.cf) + "</td>\n </tr>" : '') + "\n " + (document.ty == 1 && document.pma && document.pm ? paymentContainer : '') + "\n </tbody>\n </table>\n </div>\n </div>\n </div>\n <!-- end invoice-content -->\n\n <!-- begin invoice price -->\n <div class=\"invoice-price\">\n <div class=\"invoice-price-left\">\n <div class=\"invoice-price-row\"></div>\n </div>\n <div class=\"invoice-price-right\">\n <small>" + (document.ty == 1 ? company.r_ad ? company.r_ad : lang["amount_due"] : company.r_gt ? company.r_gt : lang["grand_total"]) + "</small>\n <span class=\"f-w-600\">" + FormatCurrency(document.ad, company.cr, company.la, company.cf) + "</span>\n </div>\n </div>\n <!-- end invoice price -->\n\n <div class=\"invoice-body\">\n <!-- begin payment-instruction -->\n " + (paymentOn ? "<h2>" + (company.r_pi ? company.r_pi : lang['payment_instruction']) + "</h2>" : "") + "\n " + (paymentOn && company.p1 ? company.p1 + "<br>" : "") + "\n " + (paymentOn && company.p2 ? company.p2 + "<br>" : "") + "\n " + (paymentOn && company.p3 ? company.p3 + "<br>" : "") + "\n <!-- end payment-instruction -->\n\n <!-- begin invoice-note -->\n " + (document.noteHtml ? "<div class=\"mt-4\">\n " + document.noteHtml + "\n </div>" : (document.nt ? "<div class=\"mt-4\">\n <h2>" + (company.r_nt ? company.r_nt : lang["note"]) + "</h2>\n " + nl2br(document.nt) + "\n </div>" : '') + "\n " + (document.tc ? "<div class=\"mt-4\">\n <h2>" + (company.r_tc ? company.r_tc : lang["terms"]) + "</h2>\n " + nl2br(document.tc) + "\n </div>" : '')) + "\n <!-- end invoice-note -->\n " + signatureContainer + "\n " + clientSignature + "\n \n <!--- begin company signature -->\n <!-- begin invoice-signature -->\n " + (document.sd || document.cs || customerSignBase64 ? "<hr class=\"mt-5\">\n <div>" + (company.r_bs || lang['by_signing'] || "") + "</div>\n <div class=\"row mt-4\">\n " + (signatureContainer || clientSignature || "") + "\n " + (signatureContainer && clientSignature || "") + "\n </div>" : '') + "\n <!-- end invoice-signature-->\n\n <!-- begin invoice attachments -->\n\n " + (attachments && attachments.length > 0 ? "<div style=\"text-align: center\">\n " + attachmentContainer + "\n </div>" : '') + "\n <!-- end invoice attachment -->\n </div>\n </body>\n\n " + (referral ? "<div style=\"text-align:center;color:rgb(108, 108, 108);font-size:16px;padding:10px\">\n <div style=\"font-size:14px;padding:10px\">{lang[\"try_bookipi\"]}</div>\n <div style=\"text-align:center;font-size:12px\">\n <a href=\"" + referral + "\"><img src=\"https://s3.amazonaws.com/bookipi.com/img/appstore-btn-130.png\"/></a>\n <a href=\"" + referral + "\"><img src=\"https://s3.amazonaws.com/bookipi.com/img/googleplay-btn-130.png\"/></a>\n </div>\n </div>" : '') + "\n</html>\n";
1815
+ return "\n<!DOCTYPE html>\n<html>\n <head>\n <meta charset=\"utf-8\">\n <title>Invoice</title>\n <link rel=\"stylesheet\" href=\"https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css\" integrity=\"sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh\" crossorigin=\"anonymous\">\n <link href=\"https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css\" rel=\"stylesheet\">\n </head>\n <style>\n body {\n font-size: 18px;\n }\n .invoice-body {\n background: #fff;\n padding: 50px\n }\n\n .invoice-company {\n font-size: 20px\n }\n\n .invoice-header {\n /* margin: 0 -50px; */\n background: #f0f3f4;\n padding: 30px 50px;\n }\n .invoice-content {\n padding: 38px;\n }\n .invoice-date,\n .invoice-from,\n .invoice-to {\n /* display: table-cell; */\n /* width: 1% */\n }\n\n .invoice-from,\n .invoice-to {\n padding-right: 20px\n }\n\n .invoice-date .date,\n .invoice-from strong,\n .invoice-to strong {\n font-size: 18px;\n font-weight: 600\n }\n\n .invoice-date {\n /* text-align: right; */\n padding-left: 20px\n }\n\n .invoice-price {\n /* background: #f0f3f4; */\n display: table;\n width: 100%\n }\n\n .invoice-price .invoice-price-left,\n .invoice-price .invoice-price-right {\n display: table-cell;\n padding: 28px 12px 16px;\n font-size: 20px;\n font-weight: 600;\n width: 70%;\n position: relative;\n vertical-align: middle\n }\n\n .invoice-price .invoice-price-left .sub-price {\n display: table-cell;\n vertical-align: middle;\n padding: 0 20px\n }\n\n .invoice-price small {\n font-size: 18px;\n font-weight: 400;\n display: block\n }\n\n .invoice-price .invoice-price-row {\n display: table;\n float: left\n }\n\n .invoice-price .invoice-price-right {\n width: 30%;\n background: #2d353c;\n color: #fff;\n font-size: 28px;\n text-align: right;\n vertical-align: bottom;\n font-weight: 300;\n right: 38px;\n }\n\n .invoice-price .invoice-price-right small {\n display: block;\n opacity: .7;\n position: absolute;\n top: 10px;\n left: 12px;\n font-size: 18px\n }\n\n .invoice-footer {\n border-top: 1px solid #ddd;\n padding-top: 10px;\n font-size: 18px\n }\n\n .invoice-note {\n color: #999;\n margin-top: 80px;\n font-size: 85%\n }\n\n .invoice-body > div:not(.invoice-footer) {\n margin-bottom: 20px\n }\n\n .btn.btn-white, .btn.btn-white.disabled, .btn.btn-white.disabled:focus, .btn.btn-white.disabled:hover, .btn.btn-white[disabled], .btn.btn-white[disabled]:focus, .btn.btn-white[disabled]:hover {\n color: #2d353c;\n background: #fff;\n border-color: #d9dfe3;\n }\n .table-inline-block{\n display: inline-block;\n }\n\n @media print {\n body, page {\n /* width: 21cm; */\n /* margin: 0; */\n box-shadow: 0;\n background-color: #fff\n }\n /* .invoice-body {\n padding:10;\n } */\n #invoice {\n width:100%\n }\n\n .invoice-price .invoice-price-right {\n background: #f0f3f4;\n color: black;\n border: 2px solid #f0f3f4;\n }\n }\n\n @media only screen {\n #invoice {\n margin-top:10px;\n max-width:28cm;\n zoom: 0.8;\n box-shadow: 0 0 0.5cm rgba(0,0,0,0.2);\n margin-right:auto;margin-left:auto;\n background: white;\n }\n }\n\n @media (min-width: 767.99px) {\n .invoice-detail-right {\n max-width: 200px;\n }\n }\n @media (max-width: 767.98px) {\n .invoice-body {\n padding: 30px\n }\n .invoice-header {\n padding: 20px 30px;\n }\n .invoice-content {\n padding: 18px;\n }\n .invoice-price .invoice-price-right {\n right: 18px;\n }\n #invoice-logo {\n padding-top:0;\n max-width: 250px;\n text-align: center;\n margin-right:auto;\n margin-left:auto;\n display: block;\n }\n .invoice-date {\n margin-top:10px;\n border-top: 1px solid #dee2e6;\n }\n }\n\n .table-small td{\n padding: 8px 12px\n }\n .table-invoice-header{\n background: #f0f3f4\n }\n h1,h2,h3,h4 {margin-top:15px}\n h1 {font-size:27px}\n h2 {font-size:22px}\n </style>\n <body>\n <div id=\"invoice\" class=\"print\">\n <div class=\"invoice-body\">\n <!-- begin invoice-company -->\n <div class=\"row\">\n <div class=\"col-sm-12 col-md-6 mb-3 mb-md-0\">\n " + logoContainer + "\n </div>\n <div class=\"col-sm-12 col-md-6 text-md-right\">\n <h1>" + documentName + "</h1>\n <div class=\"text-inverse mb-1\" style=\"font-size: 20px;\">\n <strong>" + company.c + "</strong>\n </div>\n <address class=\"m-t-5 m-b-5\">\n <div class=\"mb-2\">\n " + (companyAddress.address1 ? "<div>" + companyAddress.address1 + "</div>" : "") + "\n " + (companyAddress.address2 ? "<div>" + companyAddress.address2 + "</div>" : "") + "\n " + (companyAddress.address3 ? "<div>" + companyAddress.address3 + "</div>" : "") + "\n " + (companyAddress.city || companyAddress.state || companyAddress.zip ? "<div>" + ((companyAddress.city ? companyAddress.city + " " : "") + (companyAddress.state ? companyAddress.state + " " : "") + (companyAddress.zip ? companyAddress.zip + " " : "")) + "</div>" : "") + "\n " + (companyAddress.country ? "<div>" + companyAddress.country + "</div>" : "") + "\n </div>\n " + (company.ai ? "<div>" + company.ai + "</div>" : "") + "\n " + (company.ph ? "<div>" + company.ph + "</div>" : "") + "\n " + (company.de ? "<div>" + company.de + "</div>" : "") + "\n " + (company.tfn ? "<div>" + ((company.bn ? company.bn : "Tax no.") + " : " + company.tfn) + "</div>" : "") + "\n </address>\n </div>\n </div>\n </div>\n <!-- end invoice-company -->\n <!-- begin invoice-header -->\n <div class=\"invoice-header\">\n <div class=\"row\">\n <div class=\"invoice-to col-sm-12 col-md-6\">\n <strong>" + (company.r_bt ? company.r_bt : lang["bill_to"]) + "</strong>\n <div class=\"text-inverse mb-1\">\n <small style=\"font-size: 18px;\">" + document.cu.c + "</small>\n </div>\n <address class=\"m-t-5 m-b-5\">\n " + (customerAddress.address1 ? "<div>" + customerAddress.address1 + "</div>" : "") + "\n " + (customerAddress.address2 ? "<div>" + customerAddress.address2 + "</div>" : "") + "\n " + (customerAddress.address3 ? "<div>" + customerAddress.address3 + "</div>" : "") + "\n " + (customerAddress.city || customerAddress.state || customerAddress.zip ? "<div>" + ((customerAddress.city ? customerAddress.city + " " : "") + (customerAddress.state ? customerAddress.state + " " : "") + (customerAddress.zip ? customerAddress.zip + " " : "")) + "</div>" : "") + "\n " + (customerAddress.country ? "<div>" + customerAddress.country + "</div>" : "") + "\n " + (document.cu.tfn ? "<div>" + (document.cu.tfn ? (company.bn || "Tax no.") + " : " + document.cu.tfn : "") + "</div>" : "") + "\n " + (document.cu.ph ? "<div>" + document.cu.ph + "</div>" : "") + "\n </address>\n\n " + (shippingAddressExists ? "<strong stryle=\"margin-top:10px\">" + (company.r_st ? company.r_st : lang.ship_to) + "</strong>" : "") + "\n " + (shippingAddressExists ? "\n <address class=\"m-t-5 m-b-5\">\n " + (customerShippingAddress.address1 ? "<div>" + customerShippingAddress.address1 + "</div>" : "") + "\n " + (customerShippingAddress.address2 ? "<div>" + customerShippingAddress.address2 + "</div>" : "") + "\n " + (customerShippingAddress.address3 ? "<div>" + customerShippingAddress.address3 + "</div>" : "") + "\n " + (customerShippingAddress.city || customerShippingAddress.state || customerShippingAddress.zip ? "<div>" + ((customerShippingAddress.city ? customerShippingAddress.city + " " : "") + (customerShippingAddress.state ? customerShippingAddress.state + " " : "") + (customerShippingAddress.zip ? customerShippingAddress.zip + " " : "")) + "</div>" : "") + "\n " + (customerShippingAddress.country ? "<div>" + customerShippingAddress.country + "</div>" : "") + "\n " + (document.asi ? "<div>" + document.asi + "</div>" : "") + "\n </address>\n " : "") + "\n </div>\n\n <div class=\"invoice-date col-sm-12 col-md-6\">\n <small>&nbsp;</small>\n <div class=\"row text-md-right\">\n <div class=\"col\">\n <strong>" + documentName + " #</strong>\n </div>\n <div class=\"col invoice-detail-right\">" + (document.no ? document.no : "") + "</div>\n </div>\n <div class=\"row text-md-right\">\n <div class=\"col\">\n <strong>" + (company.r_d ? company.r_d : lang["date"]) + "</strong>\n </div>\n <div class=\"col invoice-detail-right\">" + formatDate(document.d) + "</div>\n </div>\n " + (document.ty == 1 && !document.rd ? "<div class=\"row text-md-right\">\n <div class=\"col\">\n <strong>" + (company.r_dd ? company.r_dd : lang["due_date"]) + "</strong>\n </div>\n <div class=\"col invoice-detail-right\">\n " + (document.dd ? formatDate(document.dd) : formatDate(new Date(document.d).setDate(new Date(document.d).getDate() + parseInt(document.di)))) + "\n </div>\n </div>" : '') + "\n " + (document.pon ? "<div class=\"row text-md-right\">\n <div class=\"col\">\n <strong>" + (company.r_po ? company.r_po : lang['po_number']) + "</strong>\n </div>\n <div class=\"col invoice-detail-right\">" + document.pon + "</div>\n </div>\n " : '') + "\n </div>\n </div>\n </div>\n <!-- end invoice-header -->\n <!-- begin invoice-content -->\n <div class=\"invoice-content\">\n <div class=\"table-responsive\">\n <table class=\"table table-invoice\">\n <thead>\n <tr class=\"table table-invoice\">\n <th class=\"text-left\">" + (company.r_it ? company.r_it : lang['item']) + "</th>\n <th class=\"text-center d-none d-sm-table-cell\" width=\"15%\">" + (document.um ? document.um : company.r_q ? company.r_q : lang['quantity']) + "</th>\n <th class=\"text-right d-none d-sm-table-cell\" width=\"15%\">" + (company.r_p ? company.r_p : lang['price']) + "</th>\n " + (discountOnItem ? "<th class=\"text-right\" width=\"15%\">" + (company.r_dc ? company.r_dc : lang['discount']) + "</th>" : '') + "\n <th class=\"text-right\" width=\"15%\">" + (company.r_a ? company.r_a : lang['amount']) + "</th>\n </tr>\n </thead>\n <tbody>\n " + itemsContainer + "\n </tbody>\n </table>\n </div>\n \n <hr>\n <div class=\"row\">\n <div class=\"col-12\">\n <table class=\"table table-borderless table-small\">\n <tbody>\n <tr>\n <td class=\"d-none d-sm-table-cell\"></td>\n <td class=\"text-md-right\" width=\"25%\">" + (company.r_sb ? company.r_sb : lang["subtotal"]) + "</td>\n <td class=\"text-right\" width=\"25%\">" + FormatCurrency(document.st, company.cr, company.la, company.cf) + "</td>\n </tr>\n " + (document.dc ? " <tr>\n <td class=\"d-none d-sm-table-cell\"></td>\n <td class=\"text-md-right\" width=\"25%\">" + ((company.r_dc ? company.r_dc : lang["discount"]) + (document.dcpo && document.dcp ? " (" + document.dcp + "%)" : "")) + "</td>\n <td class=\"text-right\" width=\"25%\">" + ("(" + FormatCurrency(document.dc, company.cr, company.la, company.cf) + ")") + "</td>\n </tr>" : '') + "\n " + (document.sp && !document.sntx ? "<tr>\n <td class=\"d-none d-sm-table-cell\"></td>\n <td class=\"text-md-right\" width=\"25%\">" + (company.r_sp ? company.r_sp : lang["shipping"]) + "</td>\n <td class=\"text-right\" width=\"25%\">" + FormatCurrency(document.sp, company.cr, company.la, company.cf) + "</td>\n </tr>" : '') + "\n " + (document.tx != 0 ? "<tr>\n <td class=\"d-none d-sm-table-cell\"></td>\n <td class=\"text-md-right\" width=\"25%\">" + (taxName1 + taxIncluded1 + "(" + document.tp + "%)") + "</td>\n <td class=\"text-right\" width=\"25%\">" + ((document.t1d ? "(" : "") + FormatCurrency(document.tx, company.cr, company.la, company.cf) + (document.t1d ? ")" : "")) + "</td>\n </tr>" : '') + "\n " + (document.ttx && document.tx2 != 0 ? "<tr>\n <td class=\"d-none d-sm-table-cell\"></td>\n <td class=\"text-md-right\" width=\"25%\">" + (taxName2 + taxIncluded2 + "(" + document.tp2 + "%)") + "</td>\n <td class=\"text-right\" width=\"25%\">" + ((document.t2d ? "(" : "") + FormatCurrency(document.tx2, company.cr, company.la, company.cf) + (document.t2d ? ")" : "")) + "</td>\n </tr>" : '') + "\n " + (document.sp && document.sntx ? " <tr>\n <td class=\"d-none d-sm-table-cell\"></td>\n <td class=\"text-md-right\" width=\"25%\">" + (company.r_sp ? company.r_sp : lang["shipping"]) + "</td>\n <td class=\"text-right\" width=\"25%\">" + FormatCurrency(document.sp, company.cr, company.la, company.cf) + "</td>\n </tr>" : '') + "\n " + (document.ti ? " <tr>\n <td class=\"d-none d-sm-table-cell\"></td>\n <td class=\"text-md-right\" width=\"25%\" style=\"border-top: 1px solid #ddd\">" + (company.r_n ? company.r_n : lang["net"]) + "</td>\n <td class=\"text-right\" width=\"25%\" style=\"border-top: 1px solid #ddd\">" + FormatCurrency(document.tt - (document.tx || 0) - (document.tx2 || 0), company.cr, company.la, company.cd) + "</td>\n </tr>" : '') + "\n " + (document.ty == 1 || document.ty !== 1 && (document.t1d || document.ttx && document.tx2 > 0 && document.t2d) ? "<tr>\n <td class=\"d-none d-sm-table-cell\"></td>\n <td class=\"text-md-right\" width=\"25%\" style=\"border-bottom: 1px solid #ddd\">" + (company.r_tt ? company.r_tt : lang["total"]) + "</td>\n <td class=\"text-right\" width=\"25%\" style=\"border-bottom: 1px solid #ddd\">" + FormatCurrency(document.tt ? document.tt : 0, company.cr, company.la, company.cf) + "</td>\n </tr>" : '') + "\n " + (document.sca ? "<tr>\n <td class=\"d-none d-sm-table-cell\"></td>\n <td class=\"text-md-right\" width=\"25%\">" + lang["credit_card_surcharge"] + "</td>\n <td class=\"text-right\" width=\"25%\">" + FormatCurrency(document.sca, company.cr, company.la, company.cf) + "</td>\n </tr>" : '') + "\n " + (document.ty == 1 && document.pma && document.pm ? paymentContainer : '') + "\n </tbody>\n </table>\n </div>\n </div>\n </div>\n <!-- end invoice-content -->\n\n <!-- begin invoice price -->\n <div class=\"invoice-price\">\n <div class=\"invoice-price-left\">\n <div class=\"invoice-price-row\"></div>\n </div>\n <div class=\"invoice-price-right\">\n <small>" + (document.ty == 1 ? company.r_ad ? company.r_ad : lang["amount_due"] : company.r_gt ? company.r_gt : lang["grand_total"]) + "</small>\n <span class=\"f-w-600\">" + FormatCurrency(document.ad, company.cr, company.la, company.cf) + "</span>\n </div>\n </div>\n <!-- end invoice price -->\n\n <div class=\"invoice-body\">\n <!-- begin payment-instruction -->\n " + (paymentOn ? "<h2>" + (company.r_pi ? company.r_pi : lang['payment_instruction']) + "</h2>" : "") + "\n " + (paymentOn && company.p1 ? company.p1 + "<br>" : "") + "\n " + (paymentOn && company.p2 ? company.p2 + "<br>" : "") + "\n " + (paymentOn && company.p3 ? company.p3 + "<br>" : "") + "\n <!-- end payment-instruction -->\n\n <!-- begin invoice-note -->\n " + (document.noteHtml ? "<div class=\"mt-4\">\n " + document.noteHtml + "\n </div>" : (document.nt ? "<div class=\"mt-4\">\n <h2>" + (company.r_nt ? company.r_nt : lang["note"]) + "</h2>\n " + nl2br(document.nt) + "\n </div>" : '') + "\n " + (document.tc ? "<div class=\"mt-4\">\n <h2>" + (company.r_tc ? company.r_tc : lang["terms"]) + "</h2>\n " + nl2br(document.tc) + "\n </div>" : '')) + "\n <!-- end invoice-note -->\n " + signatureContainer + "\n " + clientSignature + "\n \n <!--- begin company signature -->\n <!-- begin invoice-signature -->\n " + (document.sd || document.cs || customerSignBase64 ? "<hr class=\"mt-5\">\n <div>" + (company.r_bs || lang['by_signing'] || "") + "</div>\n <div class=\"row mt-4\">\n " + (signatureContainer || clientSignature || "") + "\n " + (signatureContainer && clientSignature || "") + "\n </div>" : '') + "\n <!-- end invoice-signature-->\n\n <!-- begin invoice attachments -->\n\n " + (attachments && attachments.length > 0 ? "<div style=\"text-align: center\">\n " + attachmentContainer + "\n </div>" : '') + "\n <!-- end invoice attachment -->\n </div>\n </body>\n\n " + (referral ? "<div style=\"text-align:center;color:rgb(108, 108, 108);font-size:16px;padding:10px\">\n <div style=\"font-size:14px;padding:10px\">" + lang["try_bookipi"] + "</div>\n <div style=\"text-align:center;font-size:12px\">\n <a href=\"" + referral + "\"><img src=\"https://s3.amazonaws.com/bookipi.com/img/appstore-btn-130.png\"/></a>\n <a href=\"" + referral + "\"><img src=\"https://s3.amazonaws.com/bookipi.com/img/googleplay-btn-130.png\"/></a>\n </div>\n </div>" : '') + "\n</html>\n";
1817
1816
  });
1818
1817
 
1818
+ var docTypeMapping = new Map([[0, 'estimate'], [1, 'invoice'], [2, 'credit_note'], [3, 'delivery_note'], [4, 'purchase_order'], ['estimate', 0], ['invoice', 1], ['credit_note', 2], ['delivery_note', 3], ['purchase_order', 4]]);
1819
+
1820
+ var ItemCompat = function ItemCompat(item) {
1821
+ var mapping = new Map([['name', 'n'], ['description', 'dsc'], ['price', 'p'], ['quantity', 'q'], ['tax', 'tx'], ['tax2', 'tx2'], ['discount', 'dc'], ['total', 't']]);
1822
+ return Object.fromEntries(Object.entries(item).map(function (_ref) {
1823
+ var k = _ref[0],
1824
+ v = _ref[1];
1825
+ return [mapping.get(k) || k, v];
1826
+ }));
1827
+ };
1828
+
1829
+ var PaymentCompat = function PaymentCompat(payment) {
1830
+ var mapping = new Map([['amount', 'a'], ['date', 'd'], ['chargeId', 'cid'], ['surchargeRate', 'sr'], ['last4', 'l'], ['brand', 'b']]);
1831
+ return Object.fromEntries(Object.entries(payment).map(function (_ref2) {
1832
+ var k = _ref2[0],
1833
+ v = _ref2[1];
1834
+ return [mapping.get(k) || k, v];
1835
+ }));
1836
+ };
1837
+
1838
+ var CustomerCompat = function CustomerCompat(customer) {
1839
+ var mapping = new Map([['companyName', 'c'], ['firstName', 'f'], ['lastName', 'l'], ['email', 'e'], ['additionalInfo', 'ai'], ['address1', 'a1'], ['address2', 'a2'], ['address3', 'a3'], ['shippingAddress1', 'sa1'], ['shippingAddress2', 'sa2'], ['shippingAddress3', 'sa3'], ['mobile', 'mb'], ['phone', 'ph'], ['TFN', 'tfn'], ['trashed', 'tr'], ['trashedDate', 'trd'], ['company', 'ui'], ['fax', 'fax']]);
1840
+ return Object.fromEntries(Object.entries(customer).map(function (_ref3) {
1841
+ var k = _ref3[0],
1842
+ v = _ref3[1];
1843
+ return [mapping.get(k) || k, v];
1844
+ }));
1845
+ };
1846
+
1847
+ var InvoiceCompat = function InvoiceCompat(doc) {
1848
+ var mapping = new Map([['address1', 'a1'], ['address2', 'a2'], ['address3', 'a3'], ['customer', ['cu', CustomerCompat]], ['items', ['it', ItemCompat]], ['taxInclusive', 'ti'], ['taxPercentage', 'tp'], ['taxDeductible', 't1d'], ['taxInclusive', 'ti'], ['taxName', 'tn'], ['twoTaxes', 'ttx'], ['taxName2', 'tn2'], ['taxPercentage2', 'tp2'], ['taxDeductible2', 't2d'], ['taxAmount', 'tx'], ['tax2', 'tx2'], ['taxDeductibleInc2', 't2di'], ['shippingCost', 'sp'], ['shippingNonTax', 'sntx'], ['total', 'tt'], ['subTotal', 'st'], ['amountDue', 'ad'], ['discount', 'dc'], ['discountOption', 'dco'], ['discountPercentage', 'dcp'], ['discountPercentageOption', 'dcpo'], ['payments', ['pm', PaymentCompat]], ['timeZone', 'tz'], ['type', 'ty'], ['date', 'd'], ['dueDate', 'dd'], ['dueIn', 'di'], ['removeDueDate', 'rd'], ['purchaseOrderNumber', 'pon'], ['note', 'nt']]);
1849
+ return Object.fromEntries(Object.entries(doc).map(function (_ref4) {
1850
+ var k = _ref4[0],
1851
+ v = _ref4[1];
1852
+ var mapV = mapping.get(k);
1853
+
1854
+ if (!mapV) {
1855
+ return [k, v];
1856
+ } else if (!Array.isArray(mapV)) {
1857
+ return [mapV || k, v];
1858
+ } else {
1859
+ if (Array.isArray(v)) {
1860
+ return [mapV[0] || k, v.map(function (val) {
1861
+ return mapV[1](val);
1862
+ })];
1863
+ } else {
1864
+ return [mapV[0] || k, mapV[1](v)];
1865
+ }
1866
+ }
1867
+ }));
1868
+ };
1869
+
1870
+ var TemplateCompat = function TemplateCompat(template) {
1871
+ var mapping = new Map([['billTo', 'r_bt'], ['shipTo', 'r_st'], ['item', 'r_it'], ['quantity', 'r_q'], ['price', 'r_p'], ['amount', 'r_a'], ['date', 'r_d'], ['dueDate', 'r_dd'], ['postCode', 'r_po'], ['shipping', 'r_sp'], ['included', 'r_ic'], ['subtotal', 'r_sb'], ['net', 'r_n'], ['total', 'r_tt'], ['amountDue', 'r_ad'], ['grandTotal', 'r_gt'], ['payInt', 'r_pi'], ['note', 'r_nt'], ['Tos', 'r_tc'], ['bySigning', 'r_bs']]);
1872
+ return Object.fromEntries(Object.entries(template).map(function (_ref5) {
1873
+ var k = _ref5[0],
1874
+ v = _ref5[1];
1875
+ return [mapping.get(k) || k, v];
1876
+ }));
1877
+ };
1878
+
1879
+ var CompanyCompat = function CompanyCompat(doc) {
1880
+ var mapping = new Map([['dateFormat', 'df'], ['timeZone', 'tz'], ['language', 'la'], ['TFN', 'tfn'], ['paymentInstruction1', 'p1'], ['paymentInstruction2', 'p2'], ['paymentInstruction3', 'p3'], ['invoiceColor', 'ct'], ['taxPercentage', 'tp'], ['taxDeductible', 't1d'], ['taxInclusive', 'ti'], ['taxName', 'tn'], ['twoTaxes', 'ttx'], ['taxName2', 'tn2'], ['taxPercentage2', 'tp2'], ['taxDeductible2', 't2d'], ['name', 'c'], ['hasPaymentInstruction', 'pi'], ['additionalInfo', 'ai'], ['phoneNumber', 'ph'], ['displayEmail', 'de'], ['email', 'e']]);
1881
+ var rootMapping = new Map([['template', TemplateCompat]]);
1882
+ var newCompany = Object.fromEntries(Object.entries(doc).map(function (_ref6) {
1883
+ var k = _ref6[0],
1884
+ v = _ref6[1];
1885
+ return [mapping.get(k) || k, v];
1886
+ }));
1887
+ var subDoc = {};
1888
+ Object.entries(newCompany).forEach(function (_ref7) {
1889
+ var k = _ref7[0],
1890
+ v = _ref7[1];
1891
+
1892
+ if (rootMapping.get(k)) {
1893
+ var mapped = rootMapping.get(k)(v);
1894
+ delete mapped.__typename;
1895
+ subDoc = _extends({}, subDoc, mapped);
1896
+ }
1897
+ });
1898
+ newCompany = _extends({}, newCompany, subDoc);
1899
+
1900
+ var documentDefinitionCompat = function documentDefinitionCompat(doc) {
1901
+ if (!doc.documentDefinitions) {
1902
+ return {
1903
+ value: []
1904
+ };
1905
+ }
1906
+
1907
+ doc.ms = [];
1908
+ doc.pf = [];
1909
+ doc.tc = [];
1910
+ var ret = doc.documentDefinitions.map(function (def, idx) {
1911
+ var enabled = false;
1912
+
1913
+ if (typeof def.enabled === 'undefined') {
1914
+ if (def.name) {
1915
+ enabled = true;
1916
+ }
1917
+ } else {
1918
+ enabled = def.enabled;
1919
+ }
1920
+
1921
+ var obj = {
1922
+ n: def.name,
1923
+ enabled: enabled,
1924
+ ty: docTypeMapping.get(def.type),
1925
+ note: def.note,
1926
+ docType: def.docType
1927
+ };
1928
+ doc.ms.push(obj.defaultMessage);
1929
+ doc.pf.push(obj.prefix);
1930
+ doc.tc.push(obj.terms);
1931
+ return obj;
1932
+ });
1933
+ return ret;
1934
+ };
1935
+
1936
+ newCompany.documentDefinitions = documentDefinitionCompat(newCompany);
1937
+ return newCompany;
1938
+ };
1939
+
1819
1940
  var defaultLang = {
1820
1941
  terms: "Terms and conditions",
1821
1942
  privacy: "Privacy Policy",
@@ -2198,137 +2319,6 @@ var defaultLang = {
2198
2319
  search_item: "Search item"
2199
2320
  };
2200
2321
 
2201
- var PreviewDocument = function PreviewDocument(_ref) {
2202
- var previewDocument = _ref.invoice;
2203
- return /*#__PURE__*/React.createElement("div", {
2204
- dangerouslySetInnerHTML: {
2205
- __html: invoiceHtml(previewDocument)
2206
- }
2207
- });
2208
- };
2209
-
2210
- var docTypeMapping = new Map([[0, 'estimate'], [1, 'invoice'], [2, 'credit_note'], [3, 'delivery_note'], [4, 'purchase_order'], ['estimate', 0], ['invoice', 1], ['credit_note', 2], ['delivery_note', 3], ['purchase_order', 4]]);
2211
-
2212
- var ItemCompat = function ItemCompat(item) {
2213
- var mapping = new Map([['name', 'n'], ['description', 'dsc'], ['price', 'p'], ['quantity', 'q'], ['tax', 'tx'], ['tax2', 'tx2'], ['discount', 'dc'], ['total', 't']]);
2214
- return Object.fromEntries(Object.entries(item).map(function (_ref) {
2215
- var k = _ref[0],
2216
- v = _ref[1];
2217
- return [mapping.get(k) || k, v];
2218
- }));
2219
- };
2220
-
2221
- var PaymentCompat = function PaymentCompat(payment) {
2222
- var mapping = new Map([['amount', 'a'], ['date', 'd'], ['chargeId', 'cid'], ['surchargeRate', 'sr'], ['last4', 'l'], ['brand', 'b']]);
2223
- return Object.fromEntries(Object.entries(payment).map(function (_ref2) {
2224
- var k = _ref2[0],
2225
- v = _ref2[1];
2226
- return [mapping.get(k) || k, v];
2227
- }));
2228
- };
2229
-
2230
- var CustomerCompat = function CustomerCompat(customer) {
2231
- var mapping = new Map([['companyName', 'c'], ['firstName', 'f'], ['lastName', 'l'], ['email', 'e'], ['additionalInfo', 'ai'], ['address1', 'a1'], ['address2', 'a2'], ['address3', 'a3'], ['shippingAddress1', 'sa1'], ['shippingAddress2', 'sa2'], ['shippingAddress3', 'sa3'], ['mobile', 'mb'], ['phone', 'ph'], ['TFN', 'tfn'], ['trashed', 'tr'], ['trashedDate', 'trd'], ['company', 'ui'], ['fax', 'fax']]);
2232
- return Object.fromEntries(Object.entries(customer).map(function (_ref3) {
2233
- var k = _ref3[0],
2234
- v = _ref3[1];
2235
- return [mapping.get(k) || k, v];
2236
- }));
2237
- };
2238
-
2239
- var InvoiceCompat = function InvoiceCompat(doc) {
2240
- var mapping = new Map([['address1', 'a1'], ['address2', 'a2'], ['address3', 'a3'], ['customer', ['cu', CustomerCompat]], ['items', ['it', ItemCompat]], ['taxInclusive', 'ti'], ['taxPercentage', 'tp'], ['taxDeductible', 't1d'], ['taxInclusive', 'ti'], ['taxName', 'tn'], ['twoTaxes', 'ttx'], ['taxName2', 'tn2'], ['taxPercentage2', 'tp2'], ['taxDeductible2', 't2d'], ['taxAmount', 'tx'], ['tax2', 'tx2'], ['taxDeductibleInc2', 't2di'], ['shippingCost', 'sp'], ['shippingNonTax', 'sntx'], ['total', 'tt'], ['subTotal', 'st'], ['amountDue', 'ad'], ['discount', 'dc'], ['discountOption', 'dco'], ['discountPercentage', 'dcp'], ['discountPercentageOption', 'dcpo'], ['payments', ['pm', PaymentCompat]], ['timeZone', 'tz'], ['type', 'ty'], ['date', 'd'], ['dueDate', 'dd'], ['dueIn', 'di'], ['removeDueDate', 'rd'], ['purchaseOrderNumber', 'pon'], ['note', 'nt']]);
2241
- return Object.fromEntries(Object.entries(doc).map(function (_ref4) {
2242
- var k = _ref4[0],
2243
- v = _ref4[1];
2244
- var mapV = mapping.get(k);
2245
-
2246
- if (!mapV) {
2247
- return [k, v];
2248
- } else if (!Array.isArray(mapV)) {
2249
- return [mapV || k, v];
2250
- } else {
2251
- if (Array.isArray(v)) {
2252
- return [mapV[0] || k, v.map(function (val) {
2253
- return mapV[1](val);
2254
- })];
2255
- } else {
2256
- return [mapV[0] || k, mapV[1](v)];
2257
- }
2258
- }
2259
- }));
2260
- };
2261
-
2262
- var TemplateCompat = function TemplateCompat(template) {
2263
- var mapping = new Map([['billTo', 'r_bt'], ['shipTo', 'r_st'], ['item', 'r_it'], ['quantity', 'r_q'], ['price', 'r_p'], ['amount', 'r_a'], ['date', 'r_d'], ['dueDate', 'r_dd'], ['postCode', 'r_po'], ['shipping', 'r_sp'], ['included', 'r_ic'], ['subtotal', 'r_sb'], ['net', 'r_n'], ['total', 'r_tt'], ['amountDue', 'r_ad'], ['grandTotal', 'r_gt'], ['payInt', 'r_pi'], ['note', 'r_nt'], ['Tos', 'r_tc'], ['bySigning', 'r_bs']]);
2264
- return Object.fromEntries(Object.entries(template).map(function (_ref5) {
2265
- var k = _ref5[0],
2266
- v = _ref5[1];
2267
- return [mapping.get(k) || k, v];
2268
- }));
2269
- };
2270
-
2271
- var CompanyCompat = function CompanyCompat(doc) {
2272
- var mapping = new Map([['dateFormat', 'df'], ['timeZone', 'tz'], ['language', 'la'], ['TFN', 'tfn'], ['paymentInstruction1', 'p1'], ['paymentInstruction2', 'p2'], ['paymentInstruction3', 'p3'], ['invoiceColor', 'ct'], ['taxPercentage', 'tp'], ['taxDeductible', 't1d'], ['taxInclusive', 'ti'], ['taxName', 'tn'], ['twoTaxes', 'ttx'], ['taxName2', 'tn2'], ['taxPercentage2', 'tp2'], ['taxDeductible2', 't2d'], ['name', 'c'], ['hasPaymentInstruction', 'pi'], ['additionalInfo', 'ai'], ['phoneNumber', 'ph'], ['displayEmail', 'de'], ['email', 'e']]);
2273
- var rootMapping = new Map([['template', TemplateCompat]]);
2274
- var newCompany = Object.fromEntries(Object.entries(doc).map(function (_ref6) {
2275
- var k = _ref6[0],
2276
- v = _ref6[1];
2277
- return [mapping.get(k) || k, v];
2278
- }));
2279
- var subDoc = {};
2280
- Object.entries(newCompany).forEach(function (_ref7) {
2281
- var k = _ref7[0],
2282
- v = _ref7[1];
2283
-
2284
- if (rootMapping.get(k)) {
2285
- var mapped = rootMapping.get(k)(v);
2286
- delete mapped.__typename;
2287
- subDoc = _extends({}, subDoc, mapped);
2288
- }
2289
- });
2290
- newCompany = _extends({}, newCompany, subDoc);
2291
-
2292
- var documentDefinitionCompat = function documentDefinitionCompat(doc) {
2293
- if (!doc.documentDefinitions) {
2294
- return {
2295
- value: []
2296
- };
2297
- }
2298
-
2299
- doc.ms = [];
2300
- doc.pf = [];
2301
- doc.tc = [];
2302
- var ret = doc.documentDefinitions.map(function (def, idx) {
2303
- var enabled = false;
2304
-
2305
- if (typeof def.enabled === 'undefined') {
2306
- if (def.name) {
2307
- enabled = true;
2308
- }
2309
- } else {
2310
- enabled = def.enabled;
2311
- }
2312
-
2313
- var obj = {
2314
- n: def.name,
2315
- enabled: enabled,
2316
- ty: docTypeMapping.get(def.type),
2317
- note: def.note,
2318
- docType: def.docType
2319
- };
2320
- doc.ms.push(obj.defaultMessage);
2321
- doc.pf.push(obj.prefix);
2322
- doc.tc.push(obj.terms);
2323
- return obj;
2324
- });
2325
- return ret;
2326
- };
2327
-
2328
- newCompany.documentDefinitions = documentDefinitionCompat(newCompany);
2329
- return newCompany;
2330
- };
2331
-
2332
2322
  var InvoiceCompatHtml = function InvoiceCompatHtml(invoice, lang) {
2333
2323
  if (lang === void 0) {
2334
2324
  lang = defaultLang;
@@ -2343,19 +2333,6 @@ var InvoiceCompatHtml = function InvoiceCompatHtml(invoice, lang) {
2343
2333
  });
2344
2334
  };
2345
2335
 
2346
- var PreviewDocumentCompat = function PreviewDocumentCompat(_ref) {
2347
- var previewDocument = _ref.invoice,
2348
- _ref$lang = _ref.lang,
2349
- lang = _ref$lang === void 0 ? defaultLang : _ref$lang;
2350
- return /*#__PURE__*/React.createElement("div", {
2351
- dangerouslySetInnerHTML: {
2352
- __html: InvoiceCompatHtml(previewDocument, lang)
2353
- }
2354
- });
2355
- };
2356
-
2357
- exports.Invoice = PreviewDocument;
2358
- exports.InvoiceCompat = PreviewDocumentCompat;
2359
2336
  exports.InvoiceCompatHtml = InvoiceCompatHtml;
2360
2337
  exports.InvoiceHtml = invoiceHtml;
2361
2338
  //# sourceMappingURL=index.js.map