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