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