@bookipi/htmlgenerator 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,8 +1,67 @@
1
1
  function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
2
2
 
3
- var Moment = _interopDefault(require('moment'));
4
- var React = _interopDefault(require('react'));
5
3
  var moment = _interopDefault(require('moment-timezone'));
4
+ var React = _interopDefault(require('react'));
5
+
6
+ function _extends() {
7
+ _extends = Object.assign || function (target) {
8
+ for (var i = 1; i < arguments.length; i++) {
9
+ var source = arguments[i];
10
+
11
+ for (var key in source) {
12
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
13
+ target[key] = source[key];
14
+ }
15
+ }
16
+ }
17
+
18
+ return target;
19
+ };
20
+
21
+ return _extends.apply(this, arguments);
22
+ }
23
+
24
+ function _unsupportedIterableToArray(o, minLen) {
25
+ if (!o) return;
26
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
27
+ var n = Object.prototype.toString.call(o).slice(8, -1);
28
+ if (n === "Object" && o.constructor) n = o.constructor.name;
29
+ if (n === "Map" || n === "Set") return Array.from(o);
30
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
31
+ }
32
+
33
+ function _arrayLikeToArray(arr, len) {
34
+ if (len == null || len > arr.length) len = arr.length;
35
+
36
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
37
+
38
+ return arr2;
39
+ }
40
+
41
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
42
+ var it;
43
+
44
+ if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
45
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
46
+ if (it) o = it;
47
+ var i = 0;
48
+ return function () {
49
+ if (i >= o.length) return {
50
+ done: true
51
+ };
52
+ return {
53
+ done: false,
54
+ value: o[i++]
55
+ };
56
+ };
57
+ }
58
+
59
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
60
+ }
61
+
62
+ it = o[Symbol.iterator]();
63
+ return it.next.bind(it);
64
+ }
6
65
 
7
66
  var currencies = {
8
67
  "AED": {
@@ -1598,466 +1657,6 @@ var nl2br = function nl2br(str, is_xhtml) {
1598
1657
  return (str + "").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, "$1" + breakTag + "$2");
1599
1658
  };
1600
1659
 
1601
- var PreviewDocument = function PreviewDocument(_ref) {
1602
- var previewDocument = _ref.invoice,
1603
- documentDefinitions = _ref.documentDefinitions,
1604
- _ref$lang = _ref.lang,
1605
- lang = _ref$lang === void 0 ? {} : _ref$lang;
1606
- var company = previewDocument.company;
1607
- var document = previewDocument.document;
1608
- var logoBase64 = previewDocument.logoBase64;
1609
- var attachments = previewDocument.attachments;
1610
- var customerSignBase64 = previewDocument.customerSignBase64;
1611
- var signatureBase64 = previewDocument.signatureBase64;
1612
-
1613
- if (!company || !document || !document.customer || !document.items) {
1614
- return false;
1615
- }
1616
-
1617
- var formatDate = function formatDate(date) {
1618
- return Moment(date).format(company.dateFormat === 1 ? 'D/MM/YYYY' : company.dateFormat === 3 ? 'MM/D/YYYY' : company.dateFormat === 4 ? 'YYYY/MM/DD' : 'MMM DD, YYYY');
1619
- };
1620
-
1621
- var convertTypeIntoVal = function convertTypeIntoVal(type) {
1622
- switch (type) {
1623
- case 'estimate':
1624
- return 0;
1625
-
1626
- case 'invoice':
1627
- return 1;
1628
-
1629
- default:
1630
- return 1;
1631
- }
1632
- };
1633
-
1634
- var documentName;
1635
-
1636
- if (company.doc && company.doc[convertTypeIntoVal(document.type)] && company.doc[convertTypeIntoVal(document.type)].n) {
1637
- documentName = company.doc[convertTypeIntoVal(document.type)].n;
1638
- } else {
1639
- documentName = documentDefinitions[document.type].name;
1640
- }
1641
-
1642
- var businessNumberName = company.businessNumber ? company.businessNumber : 'Tax no.';
1643
- var companyAddress = {
1644
- address1: company && (company.address && company.address.address1 || company.address1) || null,
1645
- address2: company && (company.address && company.address.address2 || company.address2) || null,
1646
- address3: company && (company.address && company.address.address3 || company.address3) || null,
1647
- city: company && company.address && company.address.city || null,
1648
- state: company && company.address && company.address.state || null,
1649
- zip: company && company.address && company.address.zip || null,
1650
- country: company && company.address && company.address.country || null
1651
- };
1652
- var customer = document.customer;
1653
- var customerAddress = {
1654
- address1: customer && (customer.address && customer.address.address1 || customer.address1) || null,
1655
- address2: customer && (customer.address && customer.address.address2 || customer.address2) || null,
1656
- address3: customer && (customer.address && customer.address.address3 || customer.address3) || null,
1657
- city: customer && customer.address && customer.address.city || null,
1658
- state: customer && customer.address && customer.address.state || null,
1659
- zip: customer && customer.address && customer.address.zip || null,
1660
- country: customer && customer.address && customer.address.country || null
1661
- };
1662
- var customerShippingAddress = {
1663
- address1: customer && (customer.shippingAddress && customer.shippingAddress.address1 || customer.shippingAddress1) || null,
1664
- address2: customer && (customer.shippingAddress && customer.shippingAddress.address2 || customer.shippingAddress2) || null,
1665
- address3: customer && (customer.shippingAddress && customer.shippingAddress.address3 || customer.shippingAddress3) || null,
1666
- city: customer && customer.shippingAddress && customer.shippingAddress.city || null,
1667
- state: customer && customer.shippingAddress && customer.shippingAddress.state || null,
1668
- zip: customer && customer.shippingAddress && customer.shippingAddress.zip || null,
1669
- country: customer && customer.shippingAddress && customer.shippingAddress.country || null
1670
- };
1671
- var shippingAddressExists = customerShippingAddress.address1 || customerShippingAddress.address2 || customerShippingAddress.address3 || customerShippingAddress.city || customerShippingAddress.state || customerShippingAddress.zip || document.shippingInfo;
1672
- var invoiceDate = formatDate(document.date);
1673
- var dueDate = new Date(document.date);
1674
- dueDate.setDate(dueDate.getDate() + parseInt(document.dueIn));
1675
- var invoiceDue = formatDate(dueDate);
1676
- var taxPercent1 = document.taxPercentage ? parseFloat(document.taxPercentage) : 0;
1677
- var taxPercent2 = document.taxPercentage2 ? parseFloat(document.taxPercentage2) : 0;
1678
- var discountOnItem = false;
1679
- document.items.map(function (item, i) {
1680
- if (item.discount && item.discount > 0) {
1681
- discountOnItem = true;
1682
- }
1683
-
1684
- if (taxPercent1 > 0 && item.taxAmount) {
1685
- if (document.taxInclusive && !document.taxDeductible) {
1686
- var totalTaxRate;
1687
-
1688
- if (document.twoTaxes && !document.taxDeductible2) {
1689
- totalTaxRate = taxPercent1 + taxPercent2;
1690
- } else {
1691
- totalTaxRate = taxPercent1;
1692
- }
1693
-
1694
- document.items[i].taxAmount1 = item.total * (1 - 1 / (1 + totalTaxRate / 100)) * (taxPercent1 / totalTaxRate);
1695
- } else {
1696
- document.items[i].taxAmount1 = item.total * taxPercent1 / 100;
1697
- }
1698
- }
1699
-
1700
- if (document.ttx && taxPercent2 > 0 && item.tax2) {
1701
- if (document.taxInclusive && !document.taxDeductible2) {
1702
- var _totalTaxRate = taxPercent1 + taxPercent2;
1703
-
1704
- document.items[i].taxAmount2 = item.total * (1 - 1 / (1 + _totalTaxRate / 100)) * (taxPercent2 / _totalTaxRate);
1705
- } else {
1706
- document.items[i].taxAmount2 = item.total * taxPercent2 / 100;
1707
- }
1708
- }
1709
- });
1710
- var taxName1;
1711
- var taxIncluded1;
1712
- var taxName2;
1713
- var taxIncluded2;
1714
- var paymentLabel;
1715
-
1716
- if (document.tx != 0) {
1717
- taxName1 = document.taxName ? document.taxName : 'Tax';
1718
- taxIncluded1 = document.taxInclusive ? ' ' + (company.template.included ? company.template.included : 'included') : ' ';
1719
- }
1720
-
1721
- if (document.tax2 != 0) {
1722
- taxName2 = document.taxName2 ? document.taxName2 : 'Tax 2';
1723
- taxIncluded2 = document.taxInclusive2 ? ' ' + (company.template.included ? company.template.included : 'included') : ' ';
1724
- }
1725
-
1726
- function payment_on(date, brand, endNumber) {
1727
- if (brand && endNumber) {
1728
- return 'Paid on ' + date + ' using ' + brand + ' ending in ' + endNumber;
1729
- } else if (brand && !endNumber) {
1730
- return 'Paid on ' + date + ' using ' + brand;
1731
- } else {
1732
- return 'Paid on ' + date;
1733
- }
1734
- }
1735
-
1736
- if (document.type == 'invoice') {
1737
- if (document.paymentAmount) {
1738
- for (var i = 0; i < document.payments.length; i++) {
1739
- if (document.payments[i].brand) {
1740
- paymentLabel = payment_on(formatDate(document.payments[i].date), document.payments[i].brand);
1741
- } else {
1742
- paymentLabel = payment_on(formatDate(document.payments[i].date));
1743
- }
1744
- }
1745
- }
1746
- }
1747
-
1748
- 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>" || '';
1749
- 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>" || '';
1750
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("link", {
1751
- rel: "stylesheet",
1752
- href: "https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css",
1753
- integrity: "sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh",
1754
- crossOrigin: "anonymous"
1755
- }), /*#__PURE__*/React.createElement("link", {
1756
- href: "https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css",
1757
- rel: "stylesheet"
1758
- }), /*#__PURE__*/React.createElement("div", {
1759
- className: "print invoice-preview"
1760
- }, /*#__PURE__*/React.createElement("div", {
1761
- className: "invoice-body"
1762
- }, /*#__PURE__*/React.createElement("div", {
1763
- className: "row"
1764
- }, /*#__PURE__*/React.createElement("div", {
1765
- className: "col-sm",
1766
- style: {
1767
- paddingTop: '10px'
1768
- }
1769
- }, logoBase64 ? /*#__PURE__*/React.createElement("img", {
1770
- src: logoBase64,
1771
- id: "invoice-logo",
1772
- className: "img-fluid",
1773
- style: {
1774
- width: company.ls * 2 || 200,
1775
- height: 'auto'
1776
- }
1777
- }) : /*#__PURE__*/React.createElement("h1", null, company.name)), /*#__PURE__*/React.createElement("div", {
1778
- className: "col-sm text-right"
1779
- }, /*#__PURE__*/React.createElement("h1", null, documentName), /*#__PURE__*/React.createElement("div", {
1780
- className: "text-inverse mb-1",
1781
- style: {
1782
- fontSize: '20px'
1783
- }
1784
- }, /*#__PURE__*/React.createElement("strong", null, company.name)), /*#__PURE__*/React.createElement("address", {
1785
- className: "m-t-5 m-b-5"
1786
- }, /*#__PURE__*/React.createElement("div", {
1787
- className: "mb-2"
1788
- }, companyAddress.address1 && /*#__PURE__*/React.createElement("div", null, companyAddress.address1), companyAddress.address2 && /*#__PURE__*/React.createElement("div", null, companyAddress.address2), companyAddress.address3 && /*#__PURE__*/React.createElement("div", null, companyAddress.address3), (companyAddress.city || companyAddress.state || companyAddress.zip) && /*#__PURE__*/React.createElement("div", null, (companyAddress.city ? companyAddress.city + ' ' : '') + (companyAddress.state ? companyAddress.state + ' ' : '') + (companyAddress.zip ? companyAddress.zip + ' ' : '')), companyAddress.country && /*#__PURE__*/React.createElement("div", null, companyAddress.country)), company.additionalInfo && /*#__PURE__*/React.createElement("div", null, company.additionalInfo), company.phoneNumber && /*#__PURE__*/React.createElement("div", null, company.phoneNumber), company.displayEmail && /*#__PURE__*/React.createElement("div", null, company.displayEmail), company.TFN && /*#__PURE__*/React.createElement("div", null, businessNumberName + ' : ' + company.TFN)))), /*#__PURE__*/React.createElement("div", {
1789
- className: "invoice-header"
1790
- }, /*#__PURE__*/React.createElement("div", {
1791
- className: "invoice-to"
1792
- }, /*#__PURE__*/React.createElement("strong", null, company.template.billTo ? company.template.billTo : 'Bill to'), /*#__PURE__*/React.createElement("div", {
1793
- className: "text-inverse mb-1"
1794
- }, /*#__PURE__*/React.createElement("small", {
1795
- style: {
1796
- fontSize: '18px'
1797
- }
1798
- }, customer.companyName)), /*#__PURE__*/React.createElement("address", {
1799
- className: "m-t-5 m-b-5"
1800
- }, customerAddress.address1 && /*#__PURE__*/React.createElement("div", null, customerAddress.address1), customerAddress.address2 && /*#__PURE__*/React.createElement("div", null, customerAddress.address2), customerAddress.address3 && /*#__PURE__*/React.createElement("div", null, customerAddress.address3), customerAddress.city || customerAddress.state || customerAddress.zip && /*#__PURE__*/React.createElement("div", null, (customerAddress.city ? customerAddress.city + ' ' : '') + (customerAddress.state ? customerAddress.state + ' ' : '') + (customerAddress.zip ? customerAddress.zip + ' ' : '')), customerAddress.country && /*#__PURE__*/React.createElement("div", null, customerAddress.country), document.customer.TFN && /*#__PURE__*/React.createElement("div", null, document.cu.TFN ? businessNumberName + ' : ' + document.cu.TFN : ''), document.customer.phone && /*#__PURE__*/React.createElement("div", null, document.cu.phone)), shippingAddressExists && /*#__PURE__*/React.createElement("strong", {
1801
- style: {
1802
- marginTop: '10px'
1803
- }
1804
- }, company.template.shipTo ? company.template.shipTo : 'Ship to'), shippingAddressExists && /*#__PURE__*/React.createElement("address", {
1805
- className: "m-t-5 m-b-5"
1806
- }, customerShippingAddress.address1 && /*#__PURE__*/React.createElement("div", null, customerShippingAddress.address1), customerShippingAddress.address2 && /*#__PURE__*/React.createElement("div", null, customerShippingAddress.address2), customerShippingAddress.address3 && /*#__PURE__*/React.createElement("div", null, customerShippingAddress.address3), customerShippingAddress.city || customerShippingAddress.state || customerShippingAddress.zip && /*#__PURE__*/React.createElement("div", null, (customerShippingAddress.city ? customerShippingAddress.city + ' ' : '') + (customerShippingAddress.state ? customerShippingAddress.state + ' ' : '') + (customerShippingAddress.zip ? customerShippingAddress.zip + ' ' : '')), customerShippingAddress.country && /*#__PURE__*/React.createElement("div", null, customerShippingAddress.country), document.shippingInfo && /*#__PURE__*/React.createElement("div", null, document.shippingInfo))), /*#__PURE__*/React.createElement("div", {
1807
- className: "invoice-date"
1808
- }, /*#__PURE__*/React.createElement("small", null, "\xA0"), /*#__PURE__*/React.createElement("div", {
1809
- className: "row"
1810
- }, /*#__PURE__*/React.createElement("div", {
1811
- className: "col text-right"
1812
- }, /*#__PURE__*/React.createElement("strong", null, documentName, " #")), /*#__PURE__*/React.createElement("div", {
1813
- className: "col text-right",
1814
- style: {
1815
- maxWidth: '200px'
1816
- }
1817
- }, document.no ? document.no : '')), /*#__PURE__*/React.createElement("div", {
1818
- className: "row"
1819
- }, /*#__PURE__*/React.createElement("div", {
1820
- className: "col"
1821
- }, /*#__PURE__*/React.createElement("strong", null, company.template.date ? company.template.date : 'date' )), /*#__PURE__*/React.createElement("div", {
1822
- className: "col",
1823
- style: {
1824
- maxWidth: '200px'
1825
- }
1826
- }, invoiceDate)), document.type == 'invoice' && !document.removeDueDate && /*#__PURE__*/React.createElement("div", {
1827
- className: "row"
1828
- }, /*#__PURE__*/React.createElement("div", {
1829
- className: "col text-right"
1830
- }, /*#__PURE__*/React.createElement("strong", null, company.template.dueDate ? company.template.dueDate : 'Due date')), /*#__PURE__*/React.createElement("div", {
1831
- className: "col",
1832
- style: {
1833
- maxWidth: '200px'
1834
- }
1835
- }, invoiceDue)), !!document.purchaseOrderNumber && /*#__PURE__*/React.createElement("div", {
1836
- className: "row"
1837
- }, /*#__PURE__*/React.createElement("div", {
1838
- className: "col text-right"
1839
- }, /*#__PURE__*/React.createElement("strong", null, company.template.postCode ? company.template.postCode : 'PO #')), /*#__PURE__*/React.createElement("div", {
1840
- className: "col",
1841
- style: {
1842
- maxWidth: '200px'
1843
- }
1844
- }, document.purchaseOrderNumber)))), /*#__PURE__*/React.createElement("div", {
1845
- className: "invoice-content"
1846
- }, /*#__PURE__*/React.createElement("div", {
1847
- className: "table-responsive"
1848
- }, /*#__PURE__*/React.createElement("table", {
1849
- className: "table table-invoice"
1850
- }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", {
1851
- className: "table table-invoice"
1852
- }, /*#__PURE__*/React.createElement("th", {
1853
- className: "text-left"
1854
- }, company.template.item ? company.template.item : 'Item'), /*#__PURE__*/React.createElement("th", {
1855
- className: "text-right",
1856
- width: "15%"
1857
- }, document.unitMeasure ? document.unitMeasure : company.template.quantity ? company.template.quantity : 'Quantity'), /*#__PURE__*/React.createElement("th", {
1858
- className: "text-right",
1859
- width: "15%"
1860
- }, company.template.price ? company.template.price : 'Price'), discountOnItem && /*#__PURE__*/React.createElement("th", {
1861
- className: "text-right",
1862
- width: "15%"
1863
- }, company.r_dc ? company.r_dc : 'Discount'), /*#__PURE__*/React.createElement("th", {
1864
- className: "text-right",
1865
- width: "15%"
1866
- }, company.template.amount ? company.template.amount : 'Amount'))), /*#__PURE__*/React.createElement("tbody", null, document.items.map(function (item, idx) {
1867
- return /*#__PURE__*/React.createElement("tr", {
1868
- key: "item-" + idx
1869
- }, /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", {
1870
- className: "text-inverse"
1871
- }, /*#__PURE__*/React.createElement("strong", null, item.name || '')), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("small", null, item.description || '')), /*#__PURE__*/React.createElement("td", {
1872
- className: "text-center"
1873
- }, (item.price || item.price == 0) && (item.quantity || item.quantity == 0) ? item.quantity : ''), /*#__PURE__*/React.createElement("td", {
1874
- className: "text-right"
1875
- }, item.price || item.price == 0 ? FormatCurrency(item.price, company.defaultCurrency, company.language, company.currencyFormat) : ''), discountOnItem && /*#__PURE__*/React.createElement("td", {
1876
- className: "text-right"
1877
- }, (item.price || item.price == 0) && item.discount ? FormatCurrency(item.dc, company.defaultCurrency, company.language, company.currencyFormat) : ''), /*#__PURE__*/React.createElement("td", {
1878
- className: "text-right"
1879
- }, item.price || item.price == 0 ? FormatCurrency(item.total, company.defaultCurrency, company.language, company.currencyFormat) : ''));
1880
- })))), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("hr", null), /*#__PURE__*/React.createElement("div", {
1881
- className: "row"
1882
- }, /*#__PURE__*/React.createElement("div", {
1883
- className: "col-12"
1884
- }, /*#__PURE__*/React.createElement("table", {
1885
- className: "table table-borderless table-small"
1886
- }, /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null), /*#__PURE__*/React.createElement("td", {
1887
- className: "text-right",
1888
- width: "25%"
1889
- }, company.template.subtotal ? company.template.subtotal : 'Subtotal' ), /*#__PURE__*/React.createElement("td", {
1890
- className: "text-right",
1891
- width: "25%"
1892
- }, /*#__PURE__*/React.createElement("strong", null, FormatCurrency(document.total, company.currency, company.language, company.currencyFormat)))), !!document.discount && document.discount != 0 && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null), /*#__PURE__*/React.createElement("td", {
1893
- className: "text-right",
1894
- width: "25%"
1895
- }, (company.r_dc ? company.r_dc : 'Discount' ) + (document.discountPercentageOption && document.discountPercentage ? ' (' + document.discountPercentage + '%)' : '')), /*#__PURE__*/React.createElement("td", {
1896
- className: "text-right",
1897
- width: "25%"
1898
- }, FormatCurrency(document.discount, company.currency, company.language, company.currencyFormat))), !!document.shippingCost && !document.shippingNonTax && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null), /*#__PURE__*/React.createElement("td", {
1899
- className: "text-right",
1900
- width: "25%"
1901
- }, company.template.shipping ? company.template.shipping : 'Shipping' ), /*#__PURE__*/React.createElement("td", {
1902
- className: "text-right",
1903
- width: "25%"
1904
- }, FormatCurrency(document.shippingCost, company.currency, company.language, company.currencyFormat))), !!document.tax1 && document.tax1_total != 0 && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null), /*#__PURE__*/React.createElement("td", {
1905
- className: "text-right",
1906
- width: "25%"
1907
- }, taxName1 + taxIncluded1 + '(' + document.taxPercentage + '%)'), /*#__PURE__*/React.createElement("td", {
1908
- className: "text-right",
1909
- width: "25%"
1910
- }, FormatCurrency(document.tax1_total, company.currency, company.language, company.currencyFormat))), !!document.twoTaxes && !!document.tax2 && document.tax2_total != 0 && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null), /*#__PURE__*/React.createElement("td", {
1911
- className: "text-right",
1912
- width: "25%"
1913
- }, taxName2 + taxIncluded2 + '(' + document.taxPercentage2 + '%)'), /*#__PURE__*/React.createElement("td", {
1914
- className: "text-right",
1915
- width: "25%"
1916
- }, FormatCurrency(document.tax2_total, company.currency, company.language, company.currencyFormat))), !!document.shippingCost && document.shippingNonTax && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null), /*#__PURE__*/React.createElement("td", {
1917
- className: "text-right",
1918
- width: "25%"
1919
- }, company.r_sp ? company.r_sp : 'Shipping' ), /*#__PURE__*/React.createElement("td", {
1920
- className: "text-right",
1921
- width: "25%"
1922
- }, FormatCurrency(document.shippingCost, company.currency, company.language, company.currencyFormat))), !!document.taxInclusive && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null), /*#__PURE__*/React.createElement("td", {
1923
- className: "text-right",
1924
- width: "25%",
1925
- style: {
1926
- borderTop: '1px solid #ddd'
1927
- }
1928
- }, company.template.net ? company.template.net : 'Net' ), /*#__PURE__*/React.createElement("td", {
1929
- className: "text-right",
1930
- width: "25%",
1931
- style: {
1932
- borderTop: '1px solid #ddd'
1933
- }
1934
- }, FormatCurrency(document.total + (document.taxInclusive ? 0 : document.tax1_total || 0) + (document.taxInclusive2 ? 0 : document.tax2_total || 0), company.currency, company.language, company.currencyFormat))), document.type == 'invoice' || document.type != 'invoice' && (document.taxDeductible || document.twoTaxes && document.tax2 > 0 && document.taxDeductible2) && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null), /*#__PURE__*/React.createElement("td", {
1935
- className: "text-right",
1936
- width: "25%",
1937
- style: {
1938
- borderBottom: '1px solid #ddd'
1939
- }
1940
- }, company.template.total ? company.template.total : 'Total' ), /*#__PURE__*/React.createElement("td", {
1941
- className: "text-right",
1942
- width: "25%",
1943
- style: {
1944
- borderBottom: '1px solid #ddd'
1945
- }
1946
- }, FormatCurrency(document.subTotal ? document.subTotal : 0, company.currency, company.language, company.currencyFormat))), !!document.surchargeAmount && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null), /*#__PURE__*/React.createElement("td", {
1947
- className: "text-right",
1948
- width: "25%"
1949
- }, 'Credit Card Surcharge' ), /*#__PURE__*/React.createElement("td", {
1950
- className: "text-right",
1951
- width: "25%"
1952
- }, FormatCurrency(document.surchargeAmount, company.currency, company.language, company.currencyFormat))), !!document.paymentAmount && document.payments && document.payments.map(function (payment, idx, index) {
1953
- return /*#__PURE__*/React.createElement("tr", {
1954
- key: "paymeny-" + idx
1955
- }, /*#__PURE__*/React.createElement("td", null), /*#__PURE__*/React.createElement("td", {
1956
- className: "text-right",
1957
- width: "25%"
1958
- }, payment_on(formatDate(payment.date), payment.brand)), /*#__PURE__*/React.createElement("td", {
1959
- className: "text-right",
1960
- width: "25%"
1961
- }, FormatCurrency(payment.amount, company.currency, company.language, company.currencyFormat)));
1962
- })))))), /*#__PURE__*/React.createElement("div", {
1963
- className: "invoice-price"
1964
- }, /*#__PURE__*/React.createElement("div", {
1965
- className: "invoice-price-left"
1966
- }, /*#__PURE__*/React.createElement("div", {
1967
- className: "invoice-price-row"
1968
- })), /*#__PURE__*/React.createElement("div", {
1969
- className: "invoice-price-right"
1970
- }, /*#__PURE__*/React.createElement("small", null, document.ty == 1 ? company.template.amountDue ? company.template.amountDue : 'Amount Due' : company.template.grandTotal ? company.template.grandTotal : 'Grand total' ), /*#__PURE__*/React.createElement("span", {
1971
- className: "f-w-600"
1972
- }, FormatCurrency(document.amountDue, company.currency, company.language, company.currencyFormat)))), company.hasPaymentInstruction && document.amountDue > 0 && /*#__PURE__*/React.createElement("h2", null, company.template.payInt ? company.template.payInt : 'Payment Instruction' ), company.paymentInstruction1 && /*#__PURE__*/React.createElement(React.Fragment, null, company.paymentInstruction1, /*#__PURE__*/React.createElement("br", null)), company.paymentInstruction2 && /*#__PURE__*/React.createElement(React.Fragment, null, company.paymentInstruction2, /*#__PURE__*/React.createElement("br", null)), company.paymentInstruction3 && /*#__PURE__*/React.createElement(React.Fragment, null, company.paymentInstruction3, /*#__PURE__*/React.createElement("br", null)), /*#__PURE__*/React.createElement("div", {
1973
- className: "mt-4"
1974
- }, document.note && /*#__PURE__*/React.createElement(React.Fragment, null, document.note && /*#__PURE__*/React.createElement("div", {
1975
- className: "mt-4"
1976
- }, /*#__PURE__*/React.createElement("small", null, /*#__PURE__*/React.createElement("strong", null, company.template.note ? company.template.note : 'Note' )), /*#__PURE__*/React.createElement("div", {
1977
- dangerouslySetInnerHTML: {
1978
- __html: nl2br(document.note)
1979
- }
1980
- })), document.tc && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("small", null, /*#__PURE__*/React.createElement("strong", null, company.template.Tos ? company.template.Tos : 'Terms' )), /*#__PURE__*/React.createElement("div", {
1981
- dangerouslySetInnerHTML: {
1982
- __html: nl2br(document.tc)
1983
- }
1984
- })))), document.signDate || document.customerSignature || customerSignBase64 && /*#__PURE__*/React.createElement("hr", {
1985
- className: "mt-5"
1986
- }, /*#__PURE__*/React.createElement("div", null, company.template.bySigning || 'By signing this document, the customer agrees to the services and conditions described in this document.' || ''), /*#__PURE__*/React.createElement("div", {
1987
- className: "row mt-4"
1988
- }, signatureContainer || clientSignature || '', signatureContainer && clientSignature || '')), /*#__PURE__*/React.createElement("div", {
1989
- style: {
1990
- textAlign: 'center'
1991
- }
1992
- }, attachments && attachments.map(function (photo, idx) {
1993
- return /*#__PURE__*/React.createElement("div", {
1994
- key: "photo-" + idx
1995
- }, /*#__PURE__*/React.createElement("img", {
1996
- src: photo.imageBase64
1997
- }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("strong", null, photo.text)), /*#__PURE__*/React.createElement("div", null, photo.description));
1998
- }))), lang.empowered_by));
1999
- };
2000
-
2001
- function _extends() {
2002
- _extends = Object.assign || function (target) {
2003
- for (var i = 1; i < arguments.length; i++) {
2004
- var source = arguments[i];
2005
-
2006
- for (var key in source) {
2007
- if (Object.prototype.hasOwnProperty.call(source, key)) {
2008
- target[key] = source[key];
2009
- }
2010
- }
2011
- }
2012
-
2013
- return target;
2014
- };
2015
-
2016
- return _extends.apply(this, arguments);
2017
- }
2018
-
2019
- function _unsupportedIterableToArray(o, minLen) {
2020
- if (!o) return;
2021
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
2022
- var n = Object.prototype.toString.call(o).slice(8, -1);
2023
- if (n === "Object" && o.constructor) n = o.constructor.name;
2024
- if (n === "Map" || n === "Set") return Array.from(o);
2025
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
2026
- }
2027
-
2028
- function _arrayLikeToArray(arr, len) {
2029
- if (len == null || len > arr.length) len = arr.length;
2030
-
2031
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
2032
-
2033
- return arr2;
2034
- }
2035
-
2036
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
2037
- var it;
2038
-
2039
- if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
2040
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
2041
- if (it) o = it;
2042
- var i = 0;
2043
- return function () {
2044
- if (i >= o.length) return {
2045
- done: true
2046
- };
2047
- return {
2048
- done: false,
2049
- value: o[i++]
2050
- };
2051
- };
2052
- }
2053
-
2054
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2055
- }
2056
-
2057
- it = o[Symbol.iterator]();
2058
- return it.next.bind(it);
2059
- }
2060
-
2061
1660
  var invoiceHtml = (function (_ref) {
2062
1661
  var invoice = _ref.invoice,
2063
1662
  lang = _ref.lang,
@@ -2095,8 +1694,6 @@ var invoiceHtml = (function (_ref) {
2095
1694
  logoContainer = " <h1>" + company.c + " </h1>";
2096
1695
  }
2097
1696
 
2098
- console.log(company);
2099
- console.log(document);
2100
1697
  var timeZone = company.tz;
2101
1698
 
2102
1699
  var formatDate = function formatDate(date) {
@@ -2119,10 +1716,6 @@ var invoiceHtml = (function (_ref) {
2119
1716
  country: company && company.address && company.address.country || null
2120
1717
  };
2121
1718
  var customer = document.cu;
2122
- console.log("customer");
2123
- console.log(customer);
2124
- console.log("company");
2125
- console.log(company);
2126
1719
  var customerAddress = customer.address || {};
2127
1720
  var customerShippingAddress = customer.shippingAddress || {};
2128
1721
  var shippingAddressExists = customerShippingAddress.address1 || customerShippingAddress.address2 || customerShippingAddress.address3 || customerShippingAddress.city || customerShippingAddress.state || customerShippingAddress.zip || document.asi;
@@ -2130,40 +1723,43 @@ var invoiceHtml = (function (_ref) {
2130
1723
  var taxPercent2 = document.tp2 ? parseFloat(document.tp2) : 0;
2131
1724
  var discountOnItem = false;
2132
1725
 
2133
- for (var _iterator = _createForOfIteratorHelperLoose(document.it), _step; !(_step = _iterator()).done;) {
2134
- var item = _step.value;
1726
+ if (document.it) {
1727
+ for (var _iterator = _createForOfIteratorHelperLoose(document.it), _step; !(_step = _iterator()).done;) {
1728
+ var item = _step.value;
2135
1729
 
2136
- if (item.dc && item.dc > 0) {
2137
- discountOnItem = true;
2138
- }
1730
+ if (item.dc && item.dc > 0) {
1731
+ discountOnItem = true;
1732
+ }
2139
1733
 
2140
- if (taxPercent1 > 0 && item.tx) {
2141
- if (document.ti && !document.t1d) {
2142
- var totalTaxRate = void 0;
1734
+ if (taxPercent1 > 0 && item.tx) {
1735
+ if (document.ti && !document.t1d) {
1736
+ var totalTaxRate = void 0;
2143
1737
 
2144
- if (document.ttx && !document.t2d) {
2145
- totalTaxRate = taxPercent1 + taxPercent2;
1738
+ if (document.ttx && !document.t2d) {
1739
+ totalTaxRate = taxPercent1 + taxPercent2;
1740
+ } else {
1741
+ totalTaxRate = taxPercent1;
1742
+ }
1743
+
1744
+ item.taxAmount1 = item.t * (1 - 1 / (1 + totalTaxRate / 100)) * (taxPercent1 / totalTaxRate);
2146
1745
  } else {
2147
- totalTaxRate = taxPercent1;
1746
+ item.taxAmount1 = item.t * taxPercent1 / 100;
2148
1747
  }
2149
-
2150
- item.taxAmount1 = item.t * (1 - 1 / (1 + totalTaxRate / 100)) * (taxPercent1 / totalTaxRate);
2151
- } else {
2152
- item.taxAmount1 = item.t * taxPercent1 / 100;
2153
1748
  }
2154
- }
2155
1749
 
2156
- if (document.ttx && taxPercent2 > 0 && item.tx2) {
2157
- if (document.ti && !document.t2d) {
2158
- var _totalTaxRate = taxPercent1 + taxPercent2;
1750
+ if (document.ttx && taxPercent2 > 0 && item.tx2) {
1751
+ if (document.ti && !document.t2d) {
1752
+ var _totalTaxRate = taxPercent1 + taxPercent2;
2159
1753
 
2160
- item.taxAmount2 = item.t * (1 - 1 / (1 + _totalTaxRate / 100)) * (taxPercent2 / _totalTaxRate);
2161
- } else {
2162
- item.taxAmount2 = item.t * taxPercent2 / 100;
1754
+ item.taxAmount2 = item.t * (1 - 1 / (1 + _totalTaxRate / 100)) * (taxPercent2 / _totalTaxRate);
1755
+ } else {
1756
+ item.taxAmount2 = item.t * taxPercent2 / 100;
1757
+ }
2163
1758
  }
2164
1759
  }
2165
1760
  }
2166
1761
 
1762
+ console.log('end of item loop');
2167
1763
  var itemsContainer = '';
2168
1764
 
2169
1765
  for (var _iterator2 = _createForOfIteratorHelperLoose(document.it), _step2; !(_step2 = _iterator2()).done;) {
@@ -2212,135 +1808,9 @@ var invoiceHtml = (function (_ref) {
2212
1808
 
2213
1809
  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>" || '';
2214
1810
  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>" || '';
2215
- 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>" : 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";
1811
+ 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";
2216
1812
  });
2217
1813
 
2218
- 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]]);
2219
-
2220
- var ItemCompat = function ItemCompat(item) {
2221
- var mapping = new Map([['name', 'n'], ['description', 'dsc'], ['price', 'p'], ['quantity', 'q'], ['tax', 'tx'], ['tax2', 'tx2'], ['discount', 'dc'], ['total', 't']]);
2222
- return Object.fromEntries(Object.entries(item).map(function (_ref) {
2223
- var k = _ref[0],
2224
- v = _ref[1];
2225
- return [mapping.get(k) || k, v];
2226
- }));
2227
- };
2228
-
2229
- var PaymentCompat = function PaymentCompat(payment) {
2230
- var mapping = new Map([['amount', 'a'], ['date', 'd'], ['chargeId', 'cid'], ['surchargeRate', 'sr'], ['last4', 'l'], ['brand', 'b']]);
2231
- return Object.fromEntries(Object.entries(payment).map(function (_ref2) {
2232
- var k = _ref2[0],
2233
- v = _ref2[1];
2234
- return [mapping.get(k) || k, v];
2235
- }));
2236
- };
2237
-
2238
- var CustomerCompat = function CustomerCompat(customer) {
2239
- 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']]);
2240
- return Object.fromEntries(Object.entries(customer).map(function (_ref3) {
2241
- var k = _ref3[0],
2242
- v = _ref3[1];
2243
- return [mapping.get(k) || k, v];
2244
- }));
2245
- };
2246
-
2247
- var InvoiceCompat = function InvoiceCompat(doc) {
2248
- 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']]);
2249
- return Object.fromEntries(Object.entries(doc).map(function (_ref4) {
2250
- var k = _ref4[0],
2251
- v = _ref4[1];
2252
- var mapV = mapping.get(k);
2253
-
2254
- if (!mapV) {
2255
- return [k, v];
2256
- } else if (!Array.isArray(mapV)) {
2257
- return [mapV || k, v];
2258
- } else {
2259
- if (Array.isArray(v)) {
2260
- return [mapV[0] || k, v.map(function (val) {
2261
- return mapV[1](val);
2262
- })];
2263
- } else {
2264
- return [mapV[0] || k, mapV[1](v)];
2265
- }
2266
- }
2267
- }));
2268
- };
2269
-
2270
- var TemplateCompat = function TemplateCompat(template) {
2271
- console.log('template');
2272
- console.log(template);
2273
- 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']]);
2274
- return Object.fromEntries(Object.entries(template).map(function (_ref5) {
2275
- var k = _ref5[0],
2276
- v = _ref5[1];
2277
- return [mapping.get(k) || k, v];
2278
- }));
2279
- };
2280
-
2281
- var CompanyCompat = function CompanyCompat(doc) {
2282
- console.log('company');
2283
- console.log(doc);
2284
- 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']]);
2285
- var rootMapping = new Map([['template', TemplateCompat]]);
2286
- var newCompany = Object.fromEntries(Object.entries(doc).map(function (_ref6) {
2287
- var k = _ref6[0],
2288
- v = _ref6[1];
2289
- return [mapping.get(k) || k, v];
2290
- }));
2291
- var subDoc = {};
2292
- Object.entries(newCompany).forEach(function (_ref7) {
2293
- var k = _ref7[0],
2294
- v = _ref7[1];
2295
-
2296
- if (rootMapping.get(k)) {
2297
- var mapped = rootMapping.get(k)(v);
2298
- delete mapped.__typename;
2299
- subDoc = _extends({}, subDoc, mapped);
2300
- }
2301
- });
2302
- newCompany = _extends({}, newCompany, subDoc);
2303
-
2304
- var documentDefinitionCompat = function documentDefinitionCompat(doc) {
2305
- if (!doc.documentDefinitions) {
2306
- return {
2307
- value: []
2308
- };
2309
- }
2310
-
2311
- doc.ms = [];
2312
- doc.pf = [];
2313
- doc.tc = [];
2314
- var ret = doc.documentDefinitions.map(function (def, idx) {
2315
- var enabled = false;
2316
-
2317
- if (typeof def.enabled === 'undefined') {
2318
- if (def.name) {
2319
- enabled = true;
2320
- }
2321
- } else {
2322
- enabled = def.enabled;
2323
- }
2324
-
2325
- var obj = {
2326
- n: def.name,
2327
- enabled: enabled,
2328
- ty: docTypeMapping.get(def.type),
2329
- note: def.note,
2330
- docType: def.docType
2331
- };
2332
- doc.ms.push(obj.defaultMessage);
2333
- doc.pf.push(obj.prefix);
2334
- doc.tc.push(obj.terms);
2335
- return obj;
2336
- });
2337
- return ret;
2338
- };
2339
-
2340
- newCompany.documentDefinitions = documentDefinitionCompat(newCompany);
2341
- return newCompany;
2342
- };
2343
-
2344
1814
  var defaultLang = {
2345
1815
  terms: "Terms and conditions",
2346
1816
  privacy: "Privacy Policy",
@@ -2723,6 +2193,137 @@ var defaultLang = {
2723
2193
  search_item: "Search item"
2724
2194
  };
2725
2195
 
2196
+ var PreviewDocument = function PreviewDocument(_ref) {
2197
+ var previewDocument = _ref.invoice;
2198
+ return /*#__PURE__*/React.createElement("div", {
2199
+ dangerouslySetInnerHTML: {
2200
+ __html: invoiceHtml(previewDocument)
2201
+ }
2202
+ });
2203
+ };
2204
+
2205
+ 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]]);
2206
+
2207
+ var ItemCompat = function ItemCompat(item) {
2208
+ var mapping = new Map([['name', 'n'], ['description', 'dsc'], ['price', 'p'], ['quantity', 'q'], ['tax', 'tx'], ['tax2', 'tx2'], ['discount', 'dc'], ['total', 't']]);
2209
+ return Object.fromEntries(Object.entries(item).map(function (_ref) {
2210
+ var k = _ref[0],
2211
+ v = _ref[1];
2212
+ return [mapping.get(k) || k, v];
2213
+ }));
2214
+ };
2215
+
2216
+ var PaymentCompat = function PaymentCompat(payment) {
2217
+ var mapping = new Map([['amount', 'a'], ['date', 'd'], ['chargeId', 'cid'], ['surchargeRate', 'sr'], ['last4', 'l'], ['brand', 'b']]);
2218
+ return Object.fromEntries(Object.entries(payment).map(function (_ref2) {
2219
+ var k = _ref2[0],
2220
+ v = _ref2[1];
2221
+ return [mapping.get(k) || k, v];
2222
+ }));
2223
+ };
2224
+
2225
+ var CustomerCompat = function CustomerCompat(customer) {
2226
+ 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']]);
2227
+ return Object.fromEntries(Object.entries(customer).map(function (_ref3) {
2228
+ var k = _ref3[0],
2229
+ v = _ref3[1];
2230
+ return [mapping.get(k) || k, v];
2231
+ }));
2232
+ };
2233
+
2234
+ var InvoiceCompat = function InvoiceCompat(doc) {
2235
+ 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']]);
2236
+ return Object.fromEntries(Object.entries(doc).map(function (_ref4) {
2237
+ var k = _ref4[0],
2238
+ v = _ref4[1];
2239
+ var mapV = mapping.get(k);
2240
+
2241
+ if (!mapV) {
2242
+ return [k, v];
2243
+ } else if (!Array.isArray(mapV)) {
2244
+ return [mapV || k, v];
2245
+ } else {
2246
+ if (Array.isArray(v)) {
2247
+ return [mapV[0] || k, v.map(function (val) {
2248
+ return mapV[1](val);
2249
+ })];
2250
+ } else {
2251
+ return [mapV[0] || k, mapV[1](v)];
2252
+ }
2253
+ }
2254
+ }));
2255
+ };
2256
+
2257
+ var TemplateCompat = function TemplateCompat(template) {
2258
+ 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']]);
2259
+ return Object.fromEntries(Object.entries(template).map(function (_ref5) {
2260
+ var k = _ref5[0],
2261
+ v = _ref5[1];
2262
+ return [mapping.get(k) || k, v];
2263
+ }));
2264
+ };
2265
+
2266
+ var CompanyCompat = function CompanyCompat(doc) {
2267
+ 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']]);
2268
+ var rootMapping = new Map([['template', TemplateCompat]]);
2269
+ var newCompany = Object.fromEntries(Object.entries(doc).map(function (_ref6) {
2270
+ var k = _ref6[0],
2271
+ v = _ref6[1];
2272
+ return [mapping.get(k) || k, v];
2273
+ }));
2274
+ var subDoc = {};
2275
+ Object.entries(newCompany).forEach(function (_ref7) {
2276
+ var k = _ref7[0],
2277
+ v = _ref7[1];
2278
+
2279
+ if (rootMapping.get(k)) {
2280
+ var mapped = rootMapping.get(k)(v);
2281
+ delete mapped.__typename;
2282
+ subDoc = _extends({}, subDoc, mapped);
2283
+ }
2284
+ });
2285
+ newCompany = _extends({}, newCompany, subDoc);
2286
+
2287
+ var documentDefinitionCompat = function documentDefinitionCompat(doc) {
2288
+ if (!doc.documentDefinitions) {
2289
+ return {
2290
+ value: []
2291
+ };
2292
+ }
2293
+
2294
+ doc.ms = [];
2295
+ doc.pf = [];
2296
+ doc.tc = [];
2297
+ var ret = doc.documentDefinitions.map(function (def, idx) {
2298
+ var enabled = false;
2299
+
2300
+ if (typeof def.enabled === 'undefined') {
2301
+ if (def.name) {
2302
+ enabled = true;
2303
+ }
2304
+ } else {
2305
+ enabled = def.enabled;
2306
+ }
2307
+
2308
+ var obj = {
2309
+ n: def.name,
2310
+ enabled: enabled,
2311
+ ty: docTypeMapping.get(def.type),
2312
+ note: def.note,
2313
+ docType: def.docType
2314
+ };
2315
+ doc.ms.push(obj.defaultMessage);
2316
+ doc.pf.push(obj.prefix);
2317
+ doc.tc.push(obj.terms);
2318
+ return obj;
2319
+ });
2320
+ return ret;
2321
+ };
2322
+
2323
+ newCompany.documentDefinitions = documentDefinitionCompat(newCompany);
2324
+ return newCompany;
2325
+ };
2326
+
2726
2327
  var InvoiceCompatHtml = function InvoiceCompatHtml(invoice, lang) {
2727
2328
  if (lang === void 0) {
2728
2329
  lang = defaultLang;