@bookipi/htmlgenerator 1.12.0-alpha7 → 1.12.0-alpha8

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
@@ -142,6 +142,7 @@ var en = (_deposit_due$terms$pr = {
142
142
  enter_date: 'Enter date',
143
143
  add_customer: 'Add Customer',
144
144
  item: 'Item',
145
+ items: 'Items',
145
146
  add_item: 'Add Item',
146
147
  total: 'Total',
147
148
  subtotal: 'Subtotal',
@@ -11902,25 +11903,71 @@ var computeShippingTax = function computeShippingTax(document) {
11902
11903
  }
11903
11904
  return document.ti ? shipping * (1 - 1 / (1 + rate / 100)) : shipping * rate / 100;
11904
11905
  };
11906
+ var computeItemTaxes = function computeItemTaxes(document) {
11907
+ var taxPercent1 = document.tp ? parseFloat(document.tp) : 0;
11908
+ var taxPercent2 = document.tp2 ? parseFloat(document.tp2) : 0;
11909
+ var itemTax1 = 0;
11910
+ var itemTax2 = 0;
11911
+ var items = Array.isArray(document.it) ? document.it : [];
11912
+ items.forEach(function (item) {
11913
+ var amount = Number(item === null || item === void 0 ? void 0 : item.t) || 0;
11914
+ var isTaxed1 = (item === null || item === void 0 ? void 0 : item.tx) != null ? item.tx : true;
11915
+ var isTaxed2 = (item === null || item === void 0 ? void 0 : item.tx2) != null ? item.tx2 : true;
11916
+ if (taxPercent1 > 0 && isTaxed1) {
11917
+ if (document.ti && !document.t1d) {
11918
+ var alsoTaxed2 = document.ttx && taxPercent2 > 0 && isTaxed2 && !document.t2d;
11919
+ var totalTaxRate = alsoTaxed2 ? taxPercent1 + taxPercent2 : taxPercent1;
11920
+ itemTax1 += amount * (1 - 1 / (1 + totalTaxRate / 100)) * (taxPercent1 / totalTaxRate);
11921
+ } else {
11922
+ itemTax1 += amount * taxPercent1 / 100;
11923
+ }
11924
+ }
11925
+ if (document.ttx && taxPercent2 > 0 && isTaxed2) {
11926
+ if (document.ti && !document.t2d) {
11927
+ var _totalTaxRate = isTaxed1 ? taxPercent1 + taxPercent2 : taxPercent2;
11928
+ itemTax2 += amount * (1 - 1 / (1 + _totalTaxRate / 100)) * (taxPercent2 / _totalTaxRate);
11929
+ } else {
11930
+ itemTax2 += amount * taxPercent2 / 100;
11931
+ }
11932
+ }
11933
+ });
11934
+ return {
11935
+ itemTax1: itemTax1,
11936
+ itemTax2: itemTax2
11937
+ };
11938
+ };
11905
11939
  var getShippingTaxBreakdown = function getShippingTaxBreakdown(document) {
11906
11940
  var hasShippingTaxRate = checkHasShippingTaxRate(document);
11907
11941
  var shippingTaxRate = hasShippingTaxRate ? parseFloat(document.shippingTaxRate) : 0;
11908
11942
  var shippingTax = computeShippingTax(document);
11909
- var itemTax1 = document.tx ? parseFloat(document.tx) : 0;
11910
- var itemTax2 = document.tx2 ? parseFloat(document.tx2) : 0;
11911
- var shippingMatchesTax1 = hasShippingTaxRate && shippingTaxRate > 0 && !document.sntx && shippingTaxRate === parseFloat(document.tp || 0);
11912
- var shippingMatchesTax2 = hasShippingTaxRate && shippingTaxRate > 0 && !document.sntx && !!document.ttx && shippingTaxRate === parseFloat(document.tp2 || 0) && !shippingMatchesTax1;
11913
- var showTax1SubBreakdown = shippingMatchesTax1 && !!shippingTax;
11914
- var showTax2SubBreakdown = shippingMatchesTax2 && !!shippingTax;
11943
+ var shipping = document.sp ? parseFloat(document.sp) : 0;
11944
+ var tax1 = document.tx ? parseFloat(document.tx) : 0;
11945
+ var tax2 = document.tx2 ? parseFloat(document.tx2) : 0;
11946
+ var _computeItemTaxes = computeItemTaxes(document),
11947
+ itemTax1 = _computeItemTaxes.itemTax1,
11948
+ itemTax2 = _computeItemTaxes.itemTax2;
11949
+ var shippingMatchesTax1 = hasShippingTaxRate && shippingTaxRate > 0 && !document.sntx && shippingTaxRate === parseFloat(document.tp || 0) && tax1 > 0;
11950
+ var shippingMatchesTax2 = hasShippingTaxRate && shippingTaxRate > 0 && !document.sntx && !!document.ttx && shippingTaxRate === parseFloat(document.tp2 || 0) && tax2 > 0 && !shippingMatchesTax1;
11951
+ var shippingFoldedIn = !hasShippingTaxRate && !!shipping && !document.sntx;
11952
+ var showTax1SubBreakdown = shippingFoldedIn && tax1 > itemTax1 || shippingMatchesTax1 && !!shippingTax;
11953
+ var showTax2SubBreakdown = shippingFoldedIn && !(document.t2d && document.t2di) && tax2 > itemTax2 || shippingMatchesTax2 && !!shippingTax;
11915
11954
  var showSeparateShippingLine = hasShippingTaxRate && shippingTaxRate > 0 && !document.sntx && !shippingMatchesTax1 && !shippingMatchesTax2 && !!shippingTax;
11916
11955
  return {
11917
11956
  hasShippingTaxRate: hasShippingTaxRate,
11918
11957
  shippingTaxRate: shippingTaxRate,
11919
11958
  shippingTax: shippingTax,
11959
+ tax1: tax1,
11960
+ tax2: tax2,
11920
11961
  itemTax1: itemTax1,
11921
11962
  itemTax2: itemTax2,
11922
11963
  shippingMatchesTax1: shippingMatchesTax1,
11923
11964
  shippingMatchesTax2: shippingMatchesTax2,
11965
+ tax1Amount: shippingMatchesTax1 ? tax1 + shippingTax : tax1,
11966
+ tax2Amount: shippingMatchesTax2 ? tax2 + shippingTax : tax2,
11967
+ tax1ItemsAmount: shippingMatchesTax1 ? tax1 : itemTax1,
11968
+ tax1ShippingAmount: shippingMatchesTax1 ? shippingTax : tax1 - itemTax1,
11969
+ tax2ItemsAmount: shippingMatchesTax2 ? tax2 : itemTax2,
11970
+ tax2ShippingAmount: shippingMatchesTax2 ? shippingTax : tax2 - itemTax2,
11924
11971
  showTax1SubBreakdown: showTax1SubBreakdown,
11925
11972
  showTax2SubBreakdown: showTax2SubBreakdown,
11926
11973
  showSeparateShippingLine: showSeparateShippingLine
@@ -12060,9 +12107,9 @@ var InvoiceContent = function InvoiceContent(_ref) {
12060
12107
  };
12061
12108
  var shippingLabel = company.r_sp ? company.r_sp : defaultLang['shipping'];
12062
12109
  var subBreakdownRows = function subBreakdownRows(itemsAmount, shippingAmount) {
12063
- 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>";
12110
+ return "<tr>\n <td class=\"text-md-right\" width=\"22%\" style=\"padding-left: 24px;\">" + defaultLang['items'] + "</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>";
12064
12111
  };
12065
- 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>" : '');
12112
+ 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.tax1Amount) + (document.t1d ? ')' : '')) + "</td>\n </tr>" + (shippingBreakdown.showTax1SubBreakdown ? subBreakdownRows(shippingBreakdown.tax1ItemsAmount, shippingBreakdown.tax1ShippingAmount) : '') : '') + (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.tax2Amount) + (document.t2d ? ')' : '')) + "</td>\n </tr>" + (shippingBreakdown.showTax2SubBreakdown ? subBreakdownRows(shippingBreakdown.tax2ItemsAmount, shippingBreakdown.tax2ShippingAmount) : '') : '') + (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>" : '');
12066
12113
  var taxBreakdownRows = !eInvoiceTaxLines ? defaultTaxRows : isTaxSummaryMatching(eInvoiceTaxLines, document) ? eInvoiceTaxLines.map(function (line) {
12067
12114
  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>";
12068
12115
  }).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>";
@@ -12432,6 +12479,7 @@ var getDefaultLang = function getDefaultLang(t, lang) {
12432
12479
  price: t ? t('Price') : lang['price'],
12433
12480
  quantity: t ? t('Quantity') : lang['quantity'],
12434
12481
  item: t ? t('Item') : lang['item'],
12482
+ items: t ? t('Items') : lang['items'] || lang['item'],
12435
12483
  number: t ? t('Number') : lang['number'],
12436
12484
  po_number: t ? t('PO Number') : lang['po_number'],
12437
12485
  due_date: t ? t('Due date') : lang['due_date'],
@@ -12907,9 +12955,9 @@ var InvoiceContent$1 = function InvoiceContent(_ref) {
12907
12955
  };
12908
12956
  var shippingLabel = company.r_sp ? company.r_sp : defaultLang['shipping'];
12909
12957
  var subBreakdownRows = function subBreakdownRows(itemsAmount, shippingAmount) {
12910
- 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>";
12958
+ return "<tr>\n <td width=\"22%\" style=\"padding-left: 24px;\">" + defaultLang['items'] + "</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>";
12911
12959
  };
12912
- 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>" : '');
12960
+ 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.tax1Amount) + (document.t1d ? ')' : '')) + "</td>\n </tr>" + (shippingBreakdown.showTax1SubBreakdown ? subBreakdownRows(shippingBreakdown.tax1ItemsAmount, shippingBreakdown.tax1ShippingAmount) : '') : '') + (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.tax2Amount) + (document.t2d ? ')' : '')) + "</td>\n </tr>" + (shippingBreakdown.showTax2SubBreakdown ? subBreakdownRows(shippingBreakdown.tax2ItemsAmount, shippingBreakdown.tax2ShippingAmount) : '') : '') + (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>" : '');
12913
12961
  var taxBreakdownRows = !eInvoiceTaxLines ? defaultTaxRows : isTaxSummaryMatching(eInvoiceTaxLines, document) ? eInvoiceTaxLines.map(function (line) {
12914
12962
  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>";
12915
12963
  }).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>";
@@ -13990,6 +14038,7 @@ var langJP = (_document$invoice$est = {
13990
14038
  amount: '金額',
13991
14039
  price: '価格',
13992
14040
  item: '項目',
14041
+ items: '項目',
13993
14042
  po_number: '発注番号',
13994
14043
  due_date: '支払期限',
13995
14044
  due: '期限'