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