@bookipi/htmlgenerator 1.1.4 → 1.1.6

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.
@@ -1666,7 +1666,7 @@ var invoiceHtmlWithDetails = (function (_ref) {
1666
1666
  var attachments = invoice.attachments || [];
1667
1667
  var customerSignBase64 = invoice.customerSignBase64;
1668
1668
  var signatureBase64 = invoice.signatureBase64;
1669
- var logoPath = invoice.logoPath || company.logoExists && "" + companyLogoBase + company._id + "/logo.jpg?" + new Date().getTime();
1669
+ var logoPath = invoice.logoPath || company.lg && "" + companyLogoBase + company._id + "/logo.jpg?" + new Date().getTime();
1670
1670
  var documentName = null;
1671
1671
 
1672
1672
  if (company.doc && company.doc[document.ty] && company.doc[document.ty].n) {
@@ -1819,142 +1819,6 @@ var invoiceHtmlWithDetails = (function (_ref) {
1819
1819
  };
1820
1820
  });
1821
1821
 
1822
- var invoiceHtml = (function (_ref) {
1823
- var invoice = _ref.invoice,
1824
- lang = _ref.lang,
1825
- referral = _ref.referral,
1826
- _ref$companyLogoBase = _ref.companyLogoBase,
1827
- companyLogoBase = _ref$companyLogoBase === void 0 ? 'https://s3.amazonaws.com/bookipi/' : _ref$companyLogoBase;
1828
- return invoiceHtmlWithDetails({
1829
- invoice: invoice,
1830
- lang: lang,
1831
- referral: referral,
1832
- companyLogoBase: companyLogoBase
1833
- }).html;
1834
- });
1835
-
1836
- 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]]);
1837
-
1838
- var ItemCompat = function ItemCompat(item) {
1839
- var mapping = new Map([['name', 'n'], ['description', 'dsc'], ['price', 'p'], ['quantity', 'q'], ['tax', 'tx'], ['tax2', 'tx2'], ['discount', 'dc'], ['total', 't']]);
1840
- return Object.fromEntries(Object.entries(item).map(function (_ref) {
1841
- var k = _ref[0],
1842
- v = _ref[1];
1843
- return [mapping.get(k) || k, v];
1844
- }));
1845
- };
1846
-
1847
- var PaymentCompat = function PaymentCompat(payment) {
1848
- var mapping = new Map([['amount', 'a'], ['date', 'd'], ['chargeId', 'cid'], ['surchargeRate', 'sr'], ['last4', 'l'], ['brand', 'b']]);
1849
- return Object.fromEntries(Object.entries(payment).map(function (_ref2) {
1850
- var k = _ref2[0],
1851
- v = _ref2[1];
1852
- return [mapping.get(k) || k, v];
1853
- }));
1854
- };
1855
-
1856
- var CustomerCompat = function CustomerCompat(customer) {
1857
- 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']]);
1858
- return Object.fromEntries(Object.entries(customer).map(function (_ref3) {
1859
- var k = _ref3[0],
1860
- v = _ref3[1];
1861
- return [mapping.get(k) || k, v];
1862
- }));
1863
- };
1864
-
1865
- var InvoiceCompat = function InvoiceCompat(doc) {
1866
- 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']]);
1867
- return Object.fromEntries(Object.entries(doc).map(function (_ref4) {
1868
- var k = _ref4[0],
1869
- v = _ref4[1];
1870
- var mapV = mapping.get(k);
1871
-
1872
- if (!mapV) {
1873
- return [k, v];
1874
- } else if (!Array.isArray(mapV)) {
1875
- return [mapV || k, v];
1876
- } else {
1877
- if (Array.isArray(v)) {
1878
- return [mapV[0] || k, v.map(function (val) {
1879
- return mapV[1](val);
1880
- })];
1881
- } else {
1882
- return [mapV[0] || k, mapV[1](v)];
1883
- }
1884
- }
1885
- }));
1886
- };
1887
-
1888
- var TemplateCompat = function TemplateCompat(template) {
1889
- 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']]);
1890
- return Object.fromEntries(Object.entries(template).map(function (_ref5) {
1891
- var k = _ref5[0],
1892
- v = _ref5[1];
1893
- return [mapping.get(k) || k, v];
1894
- }));
1895
- };
1896
-
1897
- var CompanyCompat = function CompanyCompat(doc) {
1898
- 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']]);
1899
- var rootMapping = new Map([['template', TemplateCompat]]);
1900
- var newCompany = Object.fromEntries(Object.entries(doc).map(function (_ref6) {
1901
- var k = _ref6[0],
1902
- v = _ref6[1];
1903
- return [mapping.get(k) || k, v];
1904
- }));
1905
- var subDoc = {};
1906
- Object.entries(newCompany).forEach(function (_ref7) {
1907
- var k = _ref7[0],
1908
- v = _ref7[1];
1909
-
1910
- if (rootMapping.get(k)) {
1911
- var mapped = rootMapping.get(k)(v);
1912
- delete mapped.__typename;
1913
- subDoc = _extends({}, subDoc, mapped);
1914
- }
1915
- });
1916
- newCompany = _extends({}, newCompany, subDoc);
1917
-
1918
- var documentDefinitionCompat = function documentDefinitionCompat(doc) {
1919
- if (!doc.documentDefinitions) {
1920
- return {
1921
- value: []
1922
- };
1923
- }
1924
-
1925
- doc.ms = [];
1926
- doc.pf = [];
1927
- doc.tc = [];
1928
- var ret = doc.documentDefinitions.map(function (def, idx) {
1929
- var enabled = false;
1930
-
1931
- if (typeof def.enabled === 'undefined') {
1932
- if (def.name) {
1933
- enabled = true;
1934
- }
1935
- } else {
1936
- enabled = def.enabled;
1937
- }
1938
-
1939
- var obj = {
1940
- n: def.name,
1941
- enabled: enabled,
1942
- ty: docTypeMapping.get(def.type),
1943
- note: def.note,
1944
- docType: def.docType
1945
- };
1946
- doc.ms.push(obj.defaultMessage);
1947
- doc.pf.push(obj.prefix);
1948
- doc.tc.push(obj.terms);
1949
- return obj;
1950
- });
1951
- return ret;
1952
- };
1953
-
1954
- newCompany.documentDefinitions = documentDefinitionCompat(newCompany);
1955
- return newCompany;
1956
- };
1957
-
1958
1822
  var defaultLang = {
1959
1823
  terms: "Terms and conditions",
1960
1824
  privacy: "Privacy Policy",
@@ -1995,7 +1859,7 @@ var defaultLang = {
1995
1859
  menu: "Menu",
1996
1860
  options: "Options",
1997
1861
  invoice: "Invoice",
1998
- estimate: "Estimate",
1862
+ Estimate: "Estimate",
1999
1863
  customer: "Customer",
2000
1864
  settings: "Settings",
2001
1865
  support: "Support",
@@ -2337,6 +2201,181 @@ var defaultLang = {
2337
2201
  search_item: "Search item"
2338
2202
  };
2339
2203
 
2204
+ var invoiceHtml = (function (_ref) {
2205
+ var invoice = _ref.invoice,
2206
+ _ref$lang = _ref.lang,
2207
+ lang = _ref$lang === void 0 ? defaultLang : _ref$lang,
2208
+ referral = _ref.referral,
2209
+ _ref$companyLogoBase = _ref.companyLogoBase,
2210
+ companyLogoBase = _ref$companyLogoBase === void 0 ? 'https://s3.amazonaws.com/bookipi/' : _ref$companyLogoBase;
2211
+ return invoiceHtmlWithDetails({
2212
+ invoice: invoice,
2213
+ lang: lang,
2214
+ referral: referral,
2215
+ companyLogoBase: companyLogoBase
2216
+ }).html;
2217
+ });
2218
+
2219
+ 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]]);
2220
+
2221
+ var ItemCompat = function ItemCompat(item) {
2222
+ var mapping = new Map([['name', 'n'], ['description', 'dsc'], ['price', 'p'], ['quantity', 'q'], ['tax', 'tx'], ['tax2', 'tx2'], ['discount', 'dc'], ['total', 't']]);
2223
+ return Object.fromEntries(Object.entries(item).map(function (_ref) {
2224
+ var k = _ref[0],
2225
+ v = _ref[1];
2226
+ return [mapping.get(k) || k, v];
2227
+ }));
2228
+ };
2229
+
2230
+ var PaymentCompat = function PaymentCompat(payment) {
2231
+ var mapping = new Map([['amount', 'a'], ['date', 'd'], ['chargeId', 'cid'], ['surchargeRate', 'sr'], ['last4', 'l'], ['brand', 'b']]);
2232
+ return Object.fromEntries(Object.entries(payment).map(function (_ref2) {
2233
+ var k = _ref2[0],
2234
+ v = _ref2[1];
2235
+ return [mapping.get(k) || k, v];
2236
+ }));
2237
+ };
2238
+
2239
+ var CustomerCompat = function CustomerCompat(customer) {
2240
+ 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']]);
2241
+ return Object.fromEntries(Object.entries(customer).map(function (_ref3) {
2242
+ var k = _ref3[0],
2243
+ v = _ref3[1];
2244
+ return [mapping.get(k) || k, v];
2245
+ }));
2246
+ };
2247
+
2248
+ var InvoiceCompat = function InvoiceCompat(doc) {
2249
+ 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']]);
2250
+ return Object.fromEntries(Object.entries(doc).map(function (_ref4) {
2251
+ var k = _ref4[0],
2252
+ v = _ref4[1];
2253
+ var mapV = mapping.get(k);
2254
+
2255
+ if (!mapV) {
2256
+ return [k, v];
2257
+ } else if (!Array.isArray(mapV)) {
2258
+ return [mapV || k, v];
2259
+ } else {
2260
+ if (Array.isArray(v)) {
2261
+ return [mapV[0] || k, v.map(function (val) {
2262
+ return mapV[1](val);
2263
+ })];
2264
+ } else {
2265
+ return [mapV[0] || k, mapV[1](v)];
2266
+ }
2267
+ }
2268
+ }));
2269
+ };
2270
+
2271
+ var TemplateCompat = function TemplateCompat(template) {
2272
+ 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']]);
2273
+ return Object.fromEntries(Object.entries(template).map(function (_ref5) {
2274
+ var k = _ref5[0],
2275
+ v = _ref5[1];
2276
+ return [mapping.get(k) || k, v];
2277
+ }));
2278
+ };
2279
+
2280
+ var DocumentDefinitionCompat = function DocumentDefinitionCompat(dd) {
2281
+ 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]]);
2282
+ var docs = [];
2283
+ var ms = [];
2284
+ var nt = [];
2285
+ var tc = [];
2286
+ var pf = [];
2287
+
2288
+ for (var _iterator = _createForOfIteratorHelperLoose(dd), _step; !(_step = _iterator()).done;) {
2289
+ var doc = _step.value;
2290
+ docs.push({
2291
+ n: doc.name,
2292
+ ty: docTypeMapping.get(doc.type),
2293
+ note: doc.note,
2294
+ docType: doc.docType,
2295
+ enabled: doc.enabled
2296
+ });
2297
+ ms.push(doc.defaultMessage);
2298
+ nt.push(doc.note);
2299
+ tc.push(doc.terms);
2300
+ pf.push(doc.prefix);
2301
+ }
2302
+
2303
+ return {
2304
+ doc: docs,
2305
+ ms: ms,
2306
+ nt: nt,
2307
+ tc: tc,
2308
+ pf: pf
2309
+ };
2310
+ };
2311
+
2312
+ var CompanyCompat = function CompanyCompat(doc) {
2313
+ 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'], ['logoExists', 'lg']]);
2314
+ var rootMapping = new Map([['template', TemplateCompat], ['documentDefinitions', DocumentDefinitionCompat]]);
2315
+ var newCompany = Object.fromEntries(Object.entries(doc).map(function (_ref6) {
2316
+ var k = _ref6[0],
2317
+ v = _ref6[1];
2318
+ var mapV = mapping.get(k);
2319
+
2320
+ if (mapV && Array.isArray(mapV)) {
2321
+ return [mapV[0] || k, mapV[1](v)];
2322
+ } else {
2323
+ return [mapping.get(k) || k, v];
2324
+ }
2325
+ }));
2326
+ var subDoc = {};
2327
+ Object.entries(newCompany).forEach(function (_ref7) {
2328
+ var k = _ref7[0],
2329
+ v = _ref7[1];
2330
+
2331
+ if (rootMapping.get(k)) {
2332
+ var mapped = rootMapping.get(k)(v);
2333
+ delete mapped.__typename;
2334
+ subDoc = _extends({}, subDoc, mapped);
2335
+ }
2336
+ });
2337
+ newCompany = _extends({}, newCompany, subDoc);
2338
+
2339
+ var documentDefinitionCompat = function documentDefinitionCompat(doc) {
2340
+ if (!doc.documentDefinitions) {
2341
+ return {
2342
+ value: []
2343
+ };
2344
+ }
2345
+
2346
+ doc.ms = [];
2347
+ doc.pf = [];
2348
+ doc.tc = [];
2349
+ var ret = doc.documentDefinitions.map(function (def, idx) {
2350
+ var enabled = false;
2351
+
2352
+ if (typeof def.enabled === 'undefined') {
2353
+ if (def.name) {
2354
+ enabled = true;
2355
+ }
2356
+ } else {
2357
+ enabled = def.enabled;
2358
+ }
2359
+
2360
+ var obj = {
2361
+ n: def.name,
2362
+ enabled: enabled,
2363
+ ty: docTypeMapping.get(def.type),
2364
+ note: def.note,
2365
+ docType: def.docType
2366
+ };
2367
+ doc.ms.push(obj.defaultMessage);
2368
+ doc.pf.push(obj.prefix);
2369
+ doc.tc.push(obj.terms);
2370
+ return obj;
2371
+ });
2372
+ return ret;
2373
+ };
2374
+
2375
+ newCompany.documentDefinitions = documentDefinitionCompat(newCompany);
2376
+ return newCompany;
2377
+ };
2378
+
2340
2379
  var InvoiceCompatHtml = function InvoiceCompatHtml(invoice, lang) {
2341
2380
  if (lang === void 0) {
2342
2381
  lang = defaultLang;