@bookipi/htmlgenerator 1.12.0-alpha5 → 1.12.0-alpha6

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.
@@ -11881,6 +11881,42 @@ var getEInvoiceTaxLabel = function getEInvoiceTaxLabel(company, defaultLang) {
11881
11881
  return (_ref = (_ref2 = configLabel != null ? configLabel : defaultLang === null || defaultLang === void 0 ? void 0 : defaultLang.vat) != null ? _ref2 : defaultLang === null || defaultLang === void 0 ? void 0 : defaultLang.tax) != null ? _ref : 'Tax';
11882
11882
  };
11883
11883
 
11884
+ var checkHasShippingTaxRate = function checkHasShippingTaxRate(document) {
11885
+ return document.shippingTaxRate != null && document.shippingTaxRate !== '';
11886
+ };
11887
+ var computeShippingTax = function computeShippingTax(document) {
11888
+ var rate = checkHasShippingTaxRate(document) ? parseFloat(document.shippingTaxRate) : 0;
11889
+ var shipping = document.sp ? parseFloat(document.sp) : 0;
11890
+ if (!(rate > 0) || document.sntx || !shipping) {
11891
+ return 0;
11892
+ }
11893
+ return document.ti ? shipping * (1 - 1 / (1 + rate / 100)) : shipping * rate / 100;
11894
+ };
11895
+ var getShippingTaxBreakdown = function getShippingTaxBreakdown(document) {
11896
+ var hasShippingTaxRate = checkHasShippingTaxRate(document);
11897
+ var shippingTaxRate = hasShippingTaxRate ? parseFloat(document.shippingTaxRate) : 0;
11898
+ var shippingTax = computeShippingTax(document);
11899
+ var itemTax1 = document.tx ? parseFloat(document.tx) : 0;
11900
+ var itemTax2 = document.tx2 ? parseFloat(document.tx2) : 0;
11901
+ var shippingMatchesTax1 = hasShippingTaxRate && shippingTaxRate > 0 && !document.sntx && shippingTaxRate === parseFloat(document.tp || 0);
11902
+ var shippingMatchesTax2 = hasShippingTaxRate && shippingTaxRate > 0 && !document.sntx && !!document.ttx && shippingTaxRate === parseFloat(document.tp2 || 0) && !shippingMatchesTax1;
11903
+ var showTax1SubBreakdown = shippingMatchesTax1 && !!shippingTax;
11904
+ var showTax2SubBreakdown = shippingMatchesTax2 && !!shippingTax;
11905
+ var showSeparateShippingLine = hasShippingTaxRate && shippingTaxRate > 0 && !document.sntx && !shippingMatchesTax1 && !shippingMatchesTax2 && !!shippingTax;
11906
+ return {
11907
+ hasShippingTaxRate: hasShippingTaxRate,
11908
+ shippingTaxRate: shippingTaxRate,
11909
+ shippingTax: shippingTax,
11910
+ itemTax1: itemTax1,
11911
+ itemTax2: itemTax2,
11912
+ shippingMatchesTax1: shippingMatchesTax1,
11913
+ shippingMatchesTax2: shippingMatchesTax2,
11914
+ showTax1SubBreakdown: showTax1SubBreakdown,
11915
+ showTax2SubBreakdown: showTax2SubBreakdown,
11916
+ showSeparateShippingLine: showSeparateShippingLine
11917
+ };
11918
+ };
11919
+
11884
11920
  var nl2br = function nl2br(str, is_xhtml) {
11885
11921
  if (typeof str === "undefined" || str === null) {
11886
11922
  return "";
@@ -12008,7 +12044,15 @@ var InvoiceContent = function InvoiceContent(_ref) {
12008
12044
  var effectiveCurrency = document.currency || company.cr;
12009
12045
  var eInvoiceTaxLines = getEInvoiceTaxLines(document);
12010
12046
  var eInvoiceTaxRowLabel = getEInvoiceTaxLabel(company, defaultLang);
12011
- var defaultTaxRows = "" + (document.tx != 0 ? "<tr>\n <td class=\"text-md-right\" width=\"22%\">" + ("" + displayTaxName1 + taxIncluded1 + "(" + document.tp + "%)") + "</td>\n <td class=\"text-right\" width=\"22%\">" + ("" + (document.t1d ? '(' : '') + FormatCurrency$3(document.tx, effectiveCurrency, company.la, company.cf) + (document.t1d ? ')' : '')) + "</td>\n </tr>" : '') + (document.ttx && document.tx2 != 0 ? "<tr>\n <td class=\"text-md-right\" width=\"22%\">" + ("" + displayTaxName2 + taxIncluded2 + "(" + document.tp2 + "%)") + "</td>\n <td class=\"text-right\" width=\"22%\">" + ("" + (document.t2d ? '(' : '') + FormatCurrency$3(document.tx2, effectiveCurrency, company.la, company.cf) + (document.t2d ? ')' : '')) + "</td>\n </tr>" : '');
12047
+ var shippingBreakdown = getShippingTaxBreakdown(document);
12048
+ var formatAmount = function formatAmount(amount) {
12049
+ return FormatCurrency$3(amount, effectiveCurrency, company.la, company.cf);
12050
+ };
12051
+ var shippingLabel = company.r_sp ? company.r_sp : defaultLang['shipping'];
12052
+ var subBreakdownRows = function subBreakdownRows(itemsAmount, shippingAmount) {
12053
+ return "<tr>\n <td class=\"text-md-right\" width=\"22%\" style=\"padding-left: 24px;\">" + defaultLang['item'] + "</td>\n <td class=\"text-right\" width=\"22%\">" + formatAmount(itemsAmount) + "</td>\n </tr>\n <tr>\n <td class=\"text-md-right\" width=\"22%\" style=\"padding-left: 24px;\">" + shippingLabel + "</td>\n <td class=\"text-right\" width=\"22%\">" + formatAmount(shippingAmount) + "</td>\n </tr>";
12054
+ };
12055
+ var defaultTaxRows = "" + (document.tx != 0 ? "<tr>\n <td class=\"text-md-right\" width=\"22%\">" + ("" + displayTaxName1 + taxIncluded1 + "(" + document.tp + "%)") + "</td>\n <td class=\"text-right\" width=\"22%\">" + ("" + (document.t1d ? '(' : '') + formatAmount(shippingBreakdown.shippingMatchesTax1 ? shippingBreakdown.itemTax1 + shippingBreakdown.shippingTax : document.tx) + (document.t1d ? ')' : '')) + "</td>\n </tr>" + (shippingBreakdown.showTax1SubBreakdown ? subBreakdownRows(shippingBreakdown.itemTax1, shippingBreakdown.shippingTax) : '') : '') + (document.ttx && document.tx2 != 0 ? "<tr>\n <td class=\"text-md-right\" width=\"22%\">" + ("" + displayTaxName2 + taxIncluded2 + "(" + document.tp2 + "%)") + "</td>\n <td class=\"text-right\" width=\"22%\">" + ("" + (document.t2d ? '(' : '') + formatAmount(shippingBreakdown.shippingMatchesTax2 ? shippingBreakdown.itemTax2 + shippingBreakdown.shippingTax : document.tx2) + (document.t2d ? ')' : '')) + "</td>\n </tr>" + (shippingBreakdown.showTax2SubBreakdown ? subBreakdownRows(shippingBreakdown.itemTax2, shippingBreakdown.shippingTax) : '') : '') + (shippingBreakdown.showSeparateShippingLine ? "<tr>\n <td class=\"text-md-right\" width=\"22%\">" + (shippingLabel + " " + defaultLang['tax'] + (document.ti ? ' ' + defaultLang['included'] : '') + " (" + formatTaxRate(shippingBreakdown.shippingTaxRate, company.la) + "%)") + "</td>\n <td class=\"text-right\" width=\"22%\">" + formatAmount(shippingBreakdown.shippingTax) + "</td>\n </tr>" : '');
12012
12056
  var taxBreakdownRows = !eInvoiceTaxLines ? defaultTaxRows : isTaxSummaryMatching(eInvoiceTaxLines, document) ? eInvoiceTaxLines.map(function (line) {
12013
12057
  return "<tr>\n <td class=\"text-md-right\" width=\"22%\">" + (eInvoiceTaxRowLabel + " (" + formatTaxRate(line.rate, company.la) + "%)") + "</td>\n <td class=\"text-right\" width=\"22%\">" + FormatCurrency$3(line.taxAmount, effectiveCurrency, company.la, company.cf) + "</td>\n </tr>";
12014
12058
  }).join('') : "<tr>\n <td class=\"text-md-right\" width=\"22%\">" + (defaultLang['total_tax'] || 'Total tax') + "</td>\n <td class=\"text-right\" width=\"22%\">" + FormatCurrency$3(document.tx || 0, effectiveCurrency, company.la, company.cf) + "</td>\n </tr>";
@@ -12202,7 +12246,7 @@ var PaymentInstructions = function PaymentInstructions(_ref) {
12202
12246
 
12203
12247
  var COMPANY_KEYS = ['_id', 'fax', 'contactName', 'c', 'e', 'ph', 'tfn', 'la', 'cr', 'cf', 'tz', 'ls', 'doc', 'bn', 'tn', 'tn2', 'tp', 'tp2', 'ti', 'ttx', 't1d', 't2d', 'pi', 'p1', 'p2', 'p3', 'sg', 'a1', 'a2', 'a3', 'address', 'language', 'la', 'sc', 'sr', 'ai', 'ct', 'de', 'r_bs', 'r_tc', 'r_nt', 'r_deposit_due', 'r_ad', 'r_gt', 'r_po', 'r_bt', 'r_st', 'r_d', 'r_a', 'r_dc', 'r_ic', 'r_it', 'r_n', 'r_p', 'r_q', 'r_sb', 'r_sp', 'r_tt', 'r_pi', 'r_inv', 'r_est', 'r_crd', 'r_dd', 'df', 'lg', 'hasPaymentInstructionQRCode', 'updatedAt', 'payment_in_progress', 'eInvoicing', 'co'];
12204
12248
 
12205
- var DOCUMENT_KEYS = ['_id', 'ad', 'ty', 'cu', 'currency', 'd', 'dd', 'rn', 'it', 'st', 'tx', 'tx2', 'tt', 'dc', 'dcp', 'dcpo', 'sp', 'sntx', 'tp', 'tp2', 'tn', 'tn2', 'tax1BaseAmount', 'tax2BaseAmount', 'ti', 'ttx', 't1d', 't2d', 'pm', 'sca', 'hangingAmount', 'depositAmount', 'um', 'shouldShowPaymentInstructions', 'customization', 'asi', 'no', 'proposal', 'd', 'rd', 'di', 'pon', 'pma', 'depositDue', 'noteHtml', 'nt', 'tc', 'sd', 'cs', 'a1', 'a2', 'a3', 't2di', 'dco', 'discountAfterTax', 'csd', 'tz', 'sent', 'isUserSignatureOverlayed', 'serviceDeliveryDate', 'eInvoicing'];
12249
+ var DOCUMENT_KEYS = ['_id', 'ad', 'ty', 'cu', 'currency', 'd', 'dd', 'rn', 'it', 'st', 'tx', 'tx2', 'tt', 'dc', 'dcp', 'dcpo', 'sp', 'sntx', 'shippingTaxRate', 'tp', 'tp2', 'tn', 'tn2', 'tax1BaseAmount', 'tax2BaseAmount', 'ti', 'ttx', 't1d', 't2d', 'pm', 'sca', 'hangingAmount', 'depositAmount', 'um', 'shouldShowPaymentInstructions', 'customization', 'asi', 'no', 'proposal', 'd', 'rd', 'di', 'pon', 'pma', 'depositDue', 'noteHtml', 'nt', 'tc', 'sd', 'cs', 'a1', 'a2', 'a3', 't2di', 'dco', 'discountAfterTax', 'csd', 'tz', 'sent', 'isUserSignatureOverlayed', 'serviceDeliveryDate', 'eInvoicing'];
12206
12250
 
12207
12251
  var decodeHtml = function decodeHtml(str) {
12208
12252
  if (str === void 0) {
@@ -12399,7 +12443,8 @@ var getDefaultLang = function getDefaultLang(t, lang) {
12399
12443
  vat: t ? t('vat') : lang['vat'],
12400
12444
  serviceDeliveryDate: t ? t('service_delivery_date') : lang['service_delivery_date'],
12401
12445
  tax_label: t ? t('tax_label') : lang['tax_label'],
12402
- total_tax: t ? t('total_tax') : lang['total_tax']
12446
+ total_tax: t ? t('total_tax') : lang['total_tax'],
12447
+ tax: t ? t('tax') : lang['tax']
12403
12448
  };
12404
12449
  };
12405
12450
 
@@ -12834,7 +12879,15 @@ var InvoiceContent$1 = function InvoiceContent(_ref) {
12834
12879
  var effectiveCurrency = document.currency || company.cr;
12835
12880
  var eInvoiceTaxLines = getEInvoiceTaxLines(document);
12836
12881
  var eInvoiceTaxRowLabel = getEInvoiceTaxLabel(company, defaultLang);
12837
- var defaultTaxRows = "" + (document.tx != 0 ? "<tr>\n <td width=\"22%\">" + (displayTaxName1 + taxIncluded1 + '(' + document.tp + '%)') + "</td>\n <td class=\"text-right\" width=\"22%\">" + ((document.t1d ? '(' : '') + FormatCurrency$7(document.tx, effectiveCurrency, company.la, company.cf) + (document.t1d ? ')' : '')) + "</td>\n </tr>" : '') + (document.ttx && document.tx2 != 0 ? "<tr>\n <td width=\"22%\">" + (displayTaxName2 + taxIncluded2 + '(' + document.tp2 + '%)') + "</td>\n <td class=\"text-right\" width=\"22%\">" + ((document.t2d ? '(' : '') + FormatCurrency$7(document.tx2, effectiveCurrency, company.la, company.cf) + (document.t2d ? ')' : '')) + "</td>\n </tr>" : '');
12882
+ var shippingBreakdown = getShippingTaxBreakdown(document);
12883
+ var formatAmount = function formatAmount(amount) {
12884
+ return FormatCurrency$7(amount, effectiveCurrency, company.la, company.cf);
12885
+ };
12886
+ var shippingLabel = company.r_sp ? company.r_sp : defaultLang['shipping'];
12887
+ var subBreakdownRows = function subBreakdownRows(itemsAmount, shippingAmount) {
12888
+ return "<tr>\n <td width=\"22%\" style=\"padding-left: 24px;\">" + defaultLang['item'] + "</td>\n <td class=\"text-right\" width=\"22%\">" + formatAmount(itemsAmount) + "</td>\n </tr>\n <tr>\n <td width=\"22%\" style=\"padding-left: 24px;\">" + shippingLabel + "</td>\n <td class=\"text-right\" width=\"22%\">" + formatAmount(shippingAmount) + "</td>\n </tr>";
12889
+ };
12890
+ var defaultTaxRows = "" + (document.tx != 0 ? "<tr>\n <td width=\"22%\">" + (displayTaxName1 + taxIncluded1 + '(' + document.tp + '%)') + "</td>\n <td class=\"text-right\" width=\"22%\">" + ((document.t1d ? '(' : '') + formatAmount(shippingBreakdown.shippingMatchesTax1 ? shippingBreakdown.itemTax1 + shippingBreakdown.shippingTax : document.tx) + (document.t1d ? ')' : '')) + "</td>\n </tr>" + (shippingBreakdown.showTax1SubBreakdown ? subBreakdownRows(shippingBreakdown.itemTax1, shippingBreakdown.shippingTax) : '') : '') + (document.ttx && document.tx2 != 0 ? "<tr>\n <td width=\"22%\">" + (displayTaxName2 + taxIncluded2 + '(' + document.tp2 + '%)') + "</td>\n <td class=\"text-right\" width=\"22%\">" + ((document.t2d ? '(' : '') + formatAmount(shippingBreakdown.shippingMatchesTax2 ? shippingBreakdown.itemTax2 + shippingBreakdown.shippingTax : document.tx2) + (document.t2d ? ')' : '')) + "</td>\n </tr>" + (shippingBreakdown.showTax2SubBreakdown ? subBreakdownRows(shippingBreakdown.itemTax2, shippingBreakdown.shippingTax) : '') : '') + (shippingBreakdown.showSeparateShippingLine ? "<tr>\n <td width=\"22%\">" + (shippingLabel + ' ' + defaultLang['tax'] + (document.ti ? ' ' + defaultLang['included'] : '') + ' (' + formatTaxRate(shippingBreakdown.shippingTaxRate, company.la) + '%)') + "</td>\n <td class=\"text-right\" width=\"22%\">" + formatAmount(shippingBreakdown.shippingTax) + "</td>\n </tr>" : '');
12838
12891
  var taxBreakdownRows = !eInvoiceTaxLines ? defaultTaxRows : isTaxSummaryMatching(eInvoiceTaxLines, document) ? eInvoiceTaxLines.map(function (line) {
12839
12892
  return "<tr>\n <td width=\"22%\">" + (eInvoiceTaxRowLabel + ' (' + formatTaxRate(line.rate, company.la) + '%)') + "</td>\n <td class=\"text-right\" width=\"22%\">" + FormatCurrency$7(line.taxAmount, effectiveCurrency, company.la, company.cf) + "</td>\n </tr>";
12840
12893
  }).join('') : "<tr>\n <td width=\"22%\">" + (defaultLang['total_tax'] || 'Total tax') + "</td>\n <td class=\"text-right\" width=\"22%\">" + FormatCurrency$7(document.tx || 0, effectiveCurrency, company.la, company.cf) + "</td>\n </tr>";