@bookipi/htmlgenerator 1.12.0-alpha9 → 1.13.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -415,7 +415,29 @@ var en = (_deposit_due$terms$pr = {
415
415
  return "This offer is valid from the date of issue and will expire at the close of business (" + x + "). Acceptance will be in the form of accepting and signing this proposal.";
416
416
  }, _deposit_due$terms$pr.details_line_3 = function details_line_3(x, y, z) {
417
417
  return x + " (" + y + "). " + z;
418
- }, _deposit_due$terms$pr.details_line_3_1 = 'This offer is valid from the date of issue and will expire at the close of business', _deposit_due$terms$pr.details_line_3_2 = 'Acceptance will be in the form of accepting and signing this proposal.', _deposit_due$terms$pr.details_line_4 = "Please accept this proposal and terms of service. This creates a legally binding contract between us. At any time if you have any questions please contact us on the details above. These terms will be effective throughout the period of our engagement and may only be changed by the Parties' agreement in writing.", _deposit_due$terms$pr.supplier_details = 'Supplier Details', _deposit_due$terms$pr.customer_details = 'Customer Details', _deposit_due$terms$pr.effective_date = 'Dated', _deposit_due$terms$pr.supplier_empty = 'No supplier added yet.', _deposit_due$terms$pr.customer_empty = 'No customer added yet.', _deposit_due$terms$pr.kind_regards = 'Kind regards', _deposit_due$terms$pr.services_title = 'Billing Schedule', _deposit_due$terms$pr["total"] = 'Total:', _deposit_due$terms$pr.items_empty = 'No services added yet.', _deposit_due$terms$pr.agreement_title = 'Terms and Conditions', _deposit_due$terms$pr["signature"] = 'Signature', _deposit_due$terms$pr.proposal_id = 'Proposal ID:', _deposit_due$terms$pr.client = 'Client:', _deposit_due$terms$pr.email_addresses = 'Email address:', _deposit_due$terms$pr.ip = 'IP:', _deposit_due$terms$pr.time = 'Time:', _deposit_due$terms$pr.upgradeRequired = 'Upgrade required', _deposit_due$terms$pr.document = 'Document', _deposit_due$terms$pr["invoice"] = 'Invoice', _deposit_due$terms$pr.estimate = 'Estimate', _deposit_due$terms$pr.creditNote = 'Credit Note', _deposit_due$terms$pr.deliveryNote = 'Delivery Note', _deposit_due$terms$pr.purchaseOrder = 'Purchase Order', _deposit_due$terms$pr.Invoice = 'Invoice', _deposit_due$terms$pr["Estimate"] = 'Estimate', _deposit_due$terms$pr.creditnote = 'Credit Note', _deposit_due$terms$pr.service_delivery_date = 'Date of delivery or completion of service', _deposit_due$terms$pr["tax_label"] = 'VAT Rate', _deposit_due$terms$pr.label_siren = 'SIREN', _deposit_due$terms$pr.vat = 'VAT', _deposit_due$terms$pr.total_tax = 'Total tax', _deposit_due$terms$pr);
418
+ }, _deposit_due$terms$pr.details_line_3_1 = 'This offer is valid from the date of issue and will expire at the close of business', _deposit_due$terms$pr.details_line_3_2 = 'Acceptance will be in the form of accepting and signing this proposal.', _deposit_due$terms$pr.details_line_4 = "Please accept this proposal and terms of service. This creates a legally binding contract between us. At any time if you have any questions please contact us on the details above. These terms will be effective throughout the period of our engagement and may only be changed by the Parties' agreement in writing.", _deposit_due$terms$pr.supplier_details = 'Supplier Details', _deposit_due$terms$pr.customer_details = 'Customer Details', _deposit_due$terms$pr.effective_date = 'Dated', _deposit_due$terms$pr.supplier_empty = 'No supplier added yet.', _deposit_due$terms$pr.customer_empty = 'No customer added yet.', _deposit_due$terms$pr.kind_regards = 'Kind regards', _deposit_due$terms$pr.services_title = 'Billing Schedule', _deposit_due$terms$pr["total"] = 'Total:', _deposit_due$terms$pr.items_empty = 'No services added yet.', _deposit_due$terms$pr.agreement_title = 'Terms and Conditions', _deposit_due$terms$pr["signature"] = 'Signature', _deposit_due$terms$pr.proposal_id = 'Proposal ID:', _deposit_due$terms$pr.client = 'Client:', _deposit_due$terms$pr.email_addresses = 'Email address:', _deposit_due$terms$pr.ip = 'IP:', _deposit_due$terms$pr.time = 'Time:', _deposit_due$terms$pr.upgradeRequired = 'Upgrade required', _deposit_due$terms$pr.document = 'Document', _deposit_due$terms$pr["invoice"] = 'Invoice', _deposit_due$terms$pr.estimate = 'Estimate', _deposit_due$terms$pr.creditNote = 'Credit Note', _deposit_due$terms$pr.deliveryNote = 'Delivery Note', _deposit_due$terms$pr.purchaseOrder = 'Purchase Order', _deposit_due$terms$pr.Invoice = 'Invoice', _deposit_due$terms$pr["Estimate"] = 'Estimate', _deposit_due$terms$pr.creditnote = 'Credit Note', _deposit_due$terms$pr.service_delivery_date = 'Date of delivery or completion of service', _deposit_due$terms$pr["tax_label"] = 'VAT Rate', _deposit_due$terms$pr.label_siren = 'SIREN', _deposit_due$terms$pr.vat = 'VAT', _deposit_due$terms$pr.total_tax = 'Total tax', _deposit_due$terms$pr.item_unit_unit = 'Unit', _deposit_due$terms$pr.item_unit_unit_short = function item_unit_unit_short(n) {
419
+ return n === 1 ? 'unit' : 'units';
420
+ }, _deposit_due$terms$pr.item_unit_piece = 'Piece', _deposit_due$terms$pr.item_unit_piece_short = function item_unit_piece_short(n) {
421
+ return n === 1 ? 'pc' : 'pcs';
422
+ }, _deposit_due$terms$pr.item_unit_each = 'Each', _deposit_due$terms$pr.item_unit_each_short = 'ea', _deposit_due$terms$pr.item_unit_pair = 'Pair', _deposit_due$terms$pr.item_unit_pair_short = function item_unit_pair_short(n) {
423
+ return n === 1 ? 'pr' : 'prs';
424
+ }, _deposit_due$terms$pr.item_unit_dozen = 'Dozen', _deposit_due$terms$pr.item_unit_dozen_short = 'dz', _deposit_due$terms$pr.item_unit_set = 'Set', _deposit_due$terms$pr.item_unit_set_short = function item_unit_set_short(n) {
425
+ return n === 1 ? 'set' : 'sets';
426
+ }, _deposit_due$terms$pr.item_unit_box = 'Box', _deposit_due$terms$pr.item_unit_box_short = function item_unit_box_short(n) {
427
+ return n === 1 ? 'box' : 'boxes';
428
+ }, _deposit_due$terms$pr.item_unit_pack = 'Pack', _deposit_due$terms$pr.item_unit_pack_short = function item_unit_pack_short(n) {
429
+ return n === 1 ? 'pk' : 'pks';
430
+ }, _deposit_due$terms$pr.item_unit_kg = 'Kilogram', _deposit_due$terms$pr.item_unit_kg_short = 'kg', _deposit_due$terms$pr.item_unit_gram = 'Gram', _deposit_due$terms$pr.item_unit_gram_short = 'g', _deposit_due$terms$pr.item_unit_tonne = 'Tonne', _deposit_due$terms$pr.item_unit_tonne_short = 't', _deposit_due$terms$pr.item_unit_litre = 'Litre', _deposit_due$terms$pr.item_unit_litre_short = 'L', _deposit_due$terms$pr.item_unit_millilitre = 'Millilitre', _deposit_due$terms$pr.item_unit_millilitre_short = 'mL', _deposit_due$terms$pr.item_unit_metre = 'Metre', _deposit_due$terms$pr.item_unit_metre_short = 'm', _deposit_due$terms$pr.item_unit_centimetre = 'Centimetre', _deposit_due$terms$pr.item_unit_centimetre_short = 'cm', _deposit_due$terms$pr.item_unit_hour = 'Hour', _deposit_due$terms$pr.item_unit_hour_short = function item_unit_hour_short(n) {
431
+ return n === 1 ? 'hr' : 'hrs';
432
+ }, _deposit_due$terms$pr.item_unit_day = 'Day', _deposit_due$terms$pr.item_unit_day_short = function item_unit_day_short(n) {
433
+ return n === 1 ? 'day' : 'days';
434
+ }, _deposit_due$terms$pr.item_unit_week = 'Week', _deposit_due$terms$pr.item_unit_week_short = function item_unit_week_short(n) {
435
+ return n === 1 ? 'wk' : 'wks';
436
+ }, _deposit_due$terms$pr.item_unit_month = 'Month', _deposit_due$terms$pr.item_unit_month_short = function item_unit_month_short(n) {
437
+ return n === 1 ? 'mo' : 'mos';
438
+ }, _deposit_due$terms$pr.item_unit_year = 'Year', _deposit_due$terms$pr.item_unit_year_short = function item_unit_year_short(n) {
439
+ return n === 1 ? 'yr' : 'yrs';
440
+ }, _deposit_due$terms$pr);
419
441
 
420
442
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
421
443
 
@@ -9104,7 +9126,8 @@ var frConfig = {
9104
9126
  format: formatVatNumber
9105
9127
  }],
9106
9128
  serviceDeliveryDate: true,
9107
- taxLabel: 'tax_label'
9129
+ taxLabel: 'tax_label',
9130
+ itemUnitType: true
9108
9131
  };
9109
9132
 
9110
9133
  var EINVOICE_CONFIGS = {
@@ -11996,6 +12019,36 @@ var nl2br = function nl2br(str, is_xhtml) {
11996
12019
  return (str + "").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, "$1" + breakTag + "$2");
11997
12020
  };
11998
12021
 
12022
+ var getItemUnitLabel = function getItemUnitLabel(_ref) {
12023
+ var _lang;
12024
+ var company = _ref.company,
12025
+ item = _ref.item,
12026
+ lang = _ref.lang,
12027
+ _ref$short = _ref["short"],
12028
+ _short = _ref$short === void 0 ? true : _ref$short;
12029
+ var config = getEInvoiceConfig(company === null || company === void 0 ? void 0 : company.co);
12030
+ if (!(config !== null && config !== void 0 && config.itemUnitType) || !(item !== null && item !== void 0 && item.unitType)) {
12031
+ return '';
12032
+ }
12033
+ var label = _short ? (_lang = lang === null || lang === void 0 ? void 0 : lang["item_unit_" + item.unitType + "_short"]) != null ? _lang : lang === null || lang === void 0 ? void 0 : lang["item_unit_" + item.unitType] : lang === null || lang === void 0 ? void 0 : lang["item_unit_" + item.unitType];
12034
+ if (typeof label === 'function') {
12035
+ return label(Number(item.q) || 0);
12036
+ }
12037
+ return label != null ? label : item.unitType;
12038
+ };
12039
+ var getItemQuantityWithUnit = function getItemQuantityWithUnit(_ref2) {
12040
+ var company = _ref2.company,
12041
+ item = _ref2.item,
12042
+ lang = _ref2.lang,
12043
+ quantity = _ref2.quantity;
12044
+ var unit = getItemUnitLabel({
12045
+ company: company,
12046
+ item: item,
12047
+ lang: lang
12048
+ });
12049
+ return unit ? quantity + " " + unit : "" + quantity;
12050
+ };
12051
+
11999
12052
  var _templateObject$6, _templateObject2$1, _templateObject3;
12000
12053
  var FormatCurrency$1 = util.FormatCurrency;
12001
12054
  var html$6 = String.raw;
@@ -12004,7 +12057,8 @@ var ItemsContainer = function ItemsContainer(_ref) {
12004
12057
  discountOnItem = _ref.discountOnItem,
12005
12058
  document = _ref.document,
12006
12059
  forceItemUnitPriceDecimal = _ref.forceItemUnitPriceDecimal,
12007
- defaultLang = _ref.defaultLang;
12060
+ defaultLang = _ref.defaultLang,
12061
+ lang = _ref.lang;
12008
12062
  if (!(document !== null && document !== void 0 && document.it)) {
12009
12063
  return '';
12010
12064
  }
@@ -12016,9 +12070,19 @@ var ItemsContainer = function ItemsContainer(_ref) {
12016
12070
  var photoUrl = (_item$photos = item.photos) !== null && _item$photos !== void 0 && _item$photos[0] ? item.photos[0].url || "https://s3.amazonaws.com/bookipi/" + company._id + "/item/images/" + item.photos[0].filename + ".jpg" : '';
12017
12071
  itemsContainer = itemsContainer + html$6(_templateObject$6 || (_templateObject$6 = _taggedTemplateLiteralLoose(["<tr>\n <td>\n ", "\n <div style=\"display: block;page-break-inside: auto!important;\">\n <span class=\"text-inverse\"><strong>", "</strong></span>\n ", "\n <div class=\"mt-2\" style=\"page-break-inside: auto!important;\">\n ", "\n </div>\n <div class=\"d-block d-md-none mt-1\">\n ", "\n ", "\n </div>\n </div>\n </td>\n <td class=\"text-center d-none d-md-table-cell\">\n ", "\n </td>\n <td class=\"text-right d-none d-md-table-cell\">\n ", "\n </td>\n ", "\n <td class=\"text-right\">\n ", "\n </td>\n </tr>"])), photoUrl ? "<img style=\"width:56px;height:56px;display:inline-block;margin-right:12px;border-radius:4px;vertical-align:top;\" src=\"" + photoUrl + "\" />" : '', item.n || '', item.productCode ? html$6(_templateObject2$1 || (_templateObject2$1 = _taggedTemplateLiteralLoose(["<div class=\"text-inverse\">", "</div>"])), item.productCode) : '', nl2br(item.dsc) || '', (item.p || item.p == 0) && (item.q || item.q == 0) ? FormatCurrency$1(item.p, effectiveCurrency, company.la, company.cf, {
12018
12072
  forceDecimal: forceItemUnitPriceDecimal
12019
- }) + ' ✕ ' + (item.q || '0') : '', discountOnItem && (item.p || item.p == 0) && item.dc ? "" + (item.dc > 0 ? ' - ' : ' + ') + FormatCurrency$1(Math.abs(item.dc), effectiveCurrency, company.la, company.cf, {
12073
+ }) + ' ✕ ' + getItemQuantityWithUnit({
12074
+ company: company,
12075
+ item: item,
12076
+ lang: lang,
12077
+ quantity: item.q || '0'
12078
+ }) : '', discountOnItem && (item.p || item.p == 0) && item.dc ? "" + (item.dc > 0 ? ' - ' : ' + ') + FormatCurrency$1(Math.abs(item.dc), effectiveCurrency, company.la, company.cf, {
12020
12079
  forceDecimal: forceItemUnitPriceDecimal
12021
- }) + " (" + (company.r_dc ? company.r_dc : defaultLang.discount) + ")" : '', (item.p || item.p == 0) && (item.q || item.q == 0) ? item.q : '', item.p || item.p == 0 ? FormatCurrency$1(item.p, effectiveCurrency, company.la, company.cf, {
12080
+ }) + " (" + (company.r_dc ? company.r_dc : defaultLang.discount) + ")" : '', (item.p || item.p == 0) && (item.q || item.q == 0) ? getItemQuantityWithUnit({
12081
+ company: company,
12082
+ item: item,
12083
+ lang: lang,
12084
+ quantity: item.q
12085
+ }) : '', item.p || item.p == 0 ? FormatCurrency$1(item.p, effectiveCurrency, company.la, company.cf, {
12022
12086
  forceDecimal: forceItemUnitPriceDecimal
12023
12087
  }) : '', discountOnItem ? html$6(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["<td class=\"text-right d-none d-md-table-cell\">\n ", "\n </td>"])), (item.p || item.p == 0) && item.dc ? FormatCurrency$1(item.dc, effectiveCurrency, company.la, company.cf) : '') : '', item.p || item.p == 0 ? FormatCurrency$1(item.t, effectiveCurrency, company.la, company.cf) : '');
12024
12088
  }
@@ -12103,7 +12167,8 @@ var InvoiceContent = function InvoiceContent(_ref) {
12103
12167
  forceItemUnitPriceDecimal: forceItemUnitPriceDecimal,
12104
12168
  defaultLang: {
12105
12169
  discount: defaultLang.discount
12106
- }
12170
+ },
12171
+ lang: lang
12107
12172
  });
12108
12173
  var paymentContainer = PaymentContainer({
12109
12174
  document: document,
@@ -12852,7 +12917,8 @@ var ItemsContainer$1 = function ItemsContainer(_ref) {
12852
12917
  discountOnItem = _ref.discountOnItem,
12853
12918
  document = _ref.document,
12854
12919
  forceItemUnitPriceDecimal = _ref.forceItemUnitPriceDecimal,
12855
- defaultLang = _ref.defaultLang;
12920
+ defaultLang = _ref.defaultLang,
12921
+ lang = _ref.lang;
12856
12922
  if (!(document !== null && document !== void 0 && document.it)) {
12857
12923
  return "";
12858
12924
  }
@@ -12864,11 +12930,21 @@ var ItemsContainer$1 = function ItemsContainer(_ref) {
12864
12930
  var photoUrl = (_item$photos = item.photos) !== null && _item$photos !== void 0 && _item$photos[0] ? item.photos[0].url || "https://s3.amazonaws.com/bookipi/" + company._id + "/item/images/" + item.photos[0].filename + ".jpg" : "";
12865
12931
  itemsContainer = itemsContainer + html$o(_templateObject$p || (_templateObject$p = _taggedTemplateLiteralLoose(["<tr>\n <td>\n ", "\n <div style=\"display:block;page-break-inside: auto!important;\">\n <span class=\"text-inverse\"\n ><span class=\"item-name\">", "</span></span\n >\n ", "\n <div class=\"item-description mt-2\" style=\"page-break-inside: auto!important;\">", "</div>\n <div class=\"d-block d-md-none mt-1\">\n ", "\n ", "\n </div>\n </div>\n </td>\n <td class=\"item-detail-cell text-center d-none d-md-table-cell\">\n ", "\n </td>\n <td class=\"item-detail-cell text-center d-none d-md-table-cell\">\n ", "\n </td>\n ", "\n <td class=\"item-detail-cell t text-right\" style=\"color: #000000;\">\n ", "\n </td>\n </tr>"])), photoUrl ? "<img style=\"width:56px;height:56px;display:inline-block;margin-right:12px;border-radius:4px;vertical-align:top;\" src=\"" + photoUrl + "\" />" : "", item.n || "", item.productCode ? html$o(_templateObject2$b || (_templateObject2$b = _taggedTemplateLiteralLoose(["<div class=\"item-productcode text-inverse\">\n ", "\n </div>"])), item.productCode) : "", nl2br(item.dsc) || "", (item.p || item.p == 0) && (item.q || item.q == 0) ? FormatCurrency$5(item.p, effectiveCurrency, company.la, company.cf, {
12866
12932
  forceDecimal: forceItemUnitPriceDecimal
12867
- }) + " ✕ " + (item.q || "0") : "", discountOnItem && (item.p || item.p == 0) && item.dc ? "" + (item.dc > 0 ? " - " : " + ") + FormatCurrency$5(Math.abs(item.dc), effectiveCurrency, company.la, company.cf, {
12933
+ }) + " ✕ " + getItemQuantityWithUnit({
12934
+ company: company,
12935
+ item: item,
12936
+ lang: lang,
12937
+ quantity: item.q || "0"
12938
+ }) : "", discountOnItem && (item.p || item.p == 0) && item.dc ? "" + (item.dc > 0 ? " - " : " + ") + FormatCurrency$5(Math.abs(item.dc), effectiveCurrency, company.la, company.cf, {
12868
12939
  forceDecimal: forceItemUnitPriceDecimal
12869
12940
  }) + " (" + (company.r_dc ? company.r_dc : defaultLang.discount) + ")" : "", item.p || item.p == 0 ? FormatCurrency$5(item.p, effectiveCurrency, company.la, company.cf, {
12870
12941
  forceDecimal: forceItemUnitPriceDecimal
12871
- }) : "", (item.p || item.p == 0) && (item.q || item.q == 0) ? item.q : "", discountOnItem ? html$o(_templateObject3$5 || (_templateObject3$5 = _taggedTemplateLiteralLoose(["<td class=\"item-detail-cell text-right d-none d-md-table-cell\">\n ", "\n </td>"])), (item.p || item.p == 0) && item.dc ? FormatCurrency$5(item.dc, effectiveCurrency, company.la, company.cf) : "") : "", item.p || item.p == 0 ? FormatCurrency$5(item.t, effectiveCurrency, company.la, company.cf) : "");
12942
+ }) : "", (item.p || item.p == 0) && (item.q || item.q == 0) ? getItemQuantityWithUnit({
12943
+ company: company,
12944
+ item: item,
12945
+ lang: lang,
12946
+ quantity: item.q
12947
+ }) : "", discountOnItem ? html$o(_templateObject3$5 || (_templateObject3$5 = _taggedTemplateLiteralLoose(["<td class=\"item-detail-cell text-right d-none d-md-table-cell\">\n ", "\n </td>"])), (item.p || item.p == 0) && item.dc ? FormatCurrency$5(item.dc, effectiveCurrency, company.la, company.cf) : "") : "", item.p || item.p == 0 ? FormatCurrency$5(item.t, effectiveCurrency, company.la, company.cf) : "");
12872
12948
  }
12873
12949
  return itemsContainer;
12874
12950
  };
@@ -12951,7 +13027,8 @@ var InvoiceContent$1 = function InvoiceContent(_ref) {
12951
13027
  forceItemUnitPriceDecimal: forceItemUnitPriceDecimal,
12952
13028
  defaultLang: {
12953
13029
  discount: defaultLang.discount
12954
- }
13030
+ },
13031
+ lang: lang
12955
13032
  });
12956
13033
  var paymentContainer = PaymentContainer$1({
12957
13034
  document: document,