shareneus 1.7.6 → 1.7.7

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.
@@ -11,15 +11,16 @@ function buildInvoiceTotalsAndNotesSection(invoiceData, availableWidth, PrintCon
11
11
  var _a, _b, _c;
12
12
  const normalizedInvoice = invoiceData || {};
13
13
  const sType = (0, pdf_shared_utils_1.firstValue)(normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.SType);
14
+ const taxMode = resolveInvoiceTaxMode(normalizedInvoice);
14
15
  const companyName = (0, pdf_shared_utils_1.firstValue)((_a = normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Entity) === null || _a === void 0 ? void 0 : _a.CName, (_b = normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Entity) === null || _b === void 0 ? void 0 : _b.Name, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.CName, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.CompanyName);
15
16
  const hideTopSection = isTruthy((_c = normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Settings) === null || _c === void 0 ? void 0 : _c.NoPr);
16
17
  const isPoSPrint = isTruthy(PrintConfigData === null || PrintConfigData === void 0 ? void 0 : PrintConfigData.IsPoSPrint);
17
- const shouldShowTaxSummary = resolveShowTaxSummary(normalizedInvoice, PrintConfigData);
18
+ const shouldShowTaxSummary = resolveShowTaxSummary(normalizedInvoice, PrintConfigData, taxMode);
18
19
  const taxSummary = resolveTaxSummary(normalizedInvoice, shouldShowTaxSummary);
19
20
  const showBankDetails = resolveShowBankDetails(normalizedInvoice, PrintConfigData);
20
21
  const showDueSection = shouldShowDueSection(PrintConfigData);
21
22
  const bankDetails = showBankDetails ? resolveBankDetails(normalizedInvoice) : { lines: [], hasData: false };
22
- const totals = resolveTotals(normalizedInvoice, taxSummary.totalTax, PrintConfigData);
23
+ const totals = resolveTotals(normalizedInvoice, taxSummary.totalTax, PrintConfigData, taxMode);
23
24
  const totalInWords = resolveTotalInWords(normalizedInvoice);
24
25
  const notes = (0, pdf_shared_utils_1.firstValue)(normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Notes, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Note, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Remarks, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Remark);
25
26
  const terms = (0, pdf_shared_utils_1.firstValue)(normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.TermsAndConditions, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.TermsCondition, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Terms, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.TC);
@@ -487,7 +488,10 @@ function resolveTaxSummary(invoiceData, shouldShowTaxSummary) {
487
488
  hasData: rows.length > 0
488
489
  };
489
490
  }
490
- function resolveShowTaxSummary(invoiceData, printConfigData = {}) {
491
+ function resolveShowTaxSummary(invoiceData, printConfigData = {}, taxMode = '') {
492
+ if (shouldHideTaxDetails(taxMode)) {
493
+ return false;
494
+ }
491
495
  const value = (0, pdf_shared_utils_1.firstValue)(printConfigData === null || printConfigData === void 0 ? void 0 : printConfigData.ShowTaxSummary, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.ShowTaxSummary);
492
496
  return isTruthy(value);
493
497
  }
@@ -549,10 +553,11 @@ function hasDisplayValue(value) {
549
553
  }
550
554
  return true;
551
555
  }
552
- function resolveTotals(invoiceData, totalTax, printConfigData = {}) {
556
+ function resolveTotals(invoiceData, totalTax, printConfigData = {}, taxMode = '') {
553
557
  var _a;
554
558
  const subtotal = (0, pdf_table_section_1.readNumericValue)(invoiceData, ['SIndTotal', 'STotal', 'SubTotal', 'SubTot', 'TaxableAmount', 'TaxableValue']);
555
559
  const isPoSPrint = isTruthy((_a = printConfigData === null || printConfigData === void 0 ? void 0 : printConfigData.IsPoSPrint) !== null && _a !== void 0 ? _a : printConfigData === null || printConfigData === void 0 ? void 0 : printConfigData.isPoSPrint);
560
+ const hideTaxDetails = shouldHideTaxDetails(taxMode);
556
561
  const showDetailedDisc = isTruthy((0, pdf_shared_utils_1.firstValue)(printConfigData === null || printConfigData === void 0 ? void 0 : printConfigData.ShowDetailedDisc));
557
562
  const itemsDiscount = parseNumber((0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.PDisc));
558
563
  const servicesDiscount = parseNumber((0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.LDisc));
@@ -600,7 +605,7 @@ function resolveTotals(invoiceData, totalTax, printConfigData = {}) {
600
605
  const totalLines = [
601
606
  { label: 'SubTotal', amount: subtotal },
602
607
  ...discountLines,
603
- { label: 'Total Tax', amount: totalTaxValue },
608
+ ...(!hideTaxDetails ? [{ label: 'Total Tax', amount: totalTaxValue }] : []),
604
609
  { label: 'Return Total', amount: returnTotal },
605
610
  { label: 'Total', amount: totalBeforeRound },
606
611
  { label: 'Rounding', amount: roundOff },
@@ -680,6 +685,13 @@ function parseNumber(value) {
680
685
  const numeric = Number(normalized);
681
686
  return Number.isFinite(numeric) ? numeric : 0;
682
687
  }
688
+ function resolveInvoiceTaxMode(invoiceData) {
689
+ var _a, _b;
690
+ return String((_b = (_a = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Settings) === null || _a === void 0 ? void 0 : _a.Tax) !== null && _b !== void 0 ? _b : '').trim().toUpperCase();
691
+ }
692
+ function shouldHideTaxDetails(taxMode) {
693
+ return taxMode === 'BS' || taxMode === 'NO';
694
+ }
683
695
  function formatTaxRate(value) {
684
696
  const normalized = (0, pdf_shared_utils_1.firstValue)(value);
685
697
  if (!normalized) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.7.06",
3
+ "version": "1.7.07",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,6 +8,7 @@ import { formatAmount, readNumericValue } from '../table-section/pdf-table.secti
8
8
  export function buildInvoiceTotalsAndNotesSection(invoiceData: any, availableWidth: number, PrintConfigData: any = {}) {
9
9
  const normalizedInvoice = invoiceData || {};
10
10
  const sType = firstValue(normalizedInvoice?.SType);
11
+ const taxMode = resolveInvoiceTaxMode(normalizedInvoice);
11
12
  const companyName = firstValue(
12
13
  normalizedInvoice?.Entity?.CName,
13
14
  normalizedInvoice?.Entity?.Name,
@@ -16,12 +17,12 @@ export function buildInvoiceTotalsAndNotesSection(invoiceData: any, availableWid
16
17
  );
17
18
  const hideTopSection = isTruthy(normalizedInvoice?.Settings?.NoPr);
18
19
  const isPoSPrint = isTruthy(PrintConfigData?.IsPoSPrint);
19
- const shouldShowTaxSummary = resolveShowTaxSummary(normalizedInvoice, PrintConfigData);
20
+ const shouldShowTaxSummary = resolveShowTaxSummary(normalizedInvoice, PrintConfigData, taxMode);
20
21
  const taxSummary = resolveTaxSummary(normalizedInvoice, shouldShowTaxSummary);
21
22
  const showBankDetails = resolveShowBankDetails(normalizedInvoice, PrintConfigData);
22
23
  const showDueSection = shouldShowDueSection(PrintConfigData);
23
24
  const bankDetails = showBankDetails ? resolveBankDetails(normalizedInvoice) : { lines: [], hasData: false };
24
- const totals = resolveTotals(normalizedInvoice, taxSummary.totalTax, PrintConfigData);
25
+ const totals = resolveTotals(normalizedInvoice, taxSummary.totalTax, PrintConfigData, taxMode);
25
26
  const totalInWords = resolveTotalInWords(normalizedInvoice);
26
27
  const notes = firstValue(
27
28
  normalizedInvoice?.Notes,
@@ -595,7 +596,11 @@ function resolveTaxSummary(invoiceData: any, shouldShowTaxSummary: boolean) {
595
596
  };
596
597
  }
597
598
 
598
- function resolveShowTaxSummary(invoiceData: any, printConfigData: any = {}) {
599
+ function resolveShowTaxSummary(invoiceData: any, printConfigData: any = {}, taxMode: string = '') {
600
+ if (shouldHideTaxDetails(taxMode)) {
601
+ return false;
602
+ }
603
+
599
604
  const value = firstValue(
600
605
  printConfigData?.ShowTaxSummary,
601
606
  invoiceData?.ShowTaxSummary
@@ -670,9 +675,10 @@ function hasDisplayValue(value: any) {
670
675
  return true;
671
676
  }
672
677
 
673
- function resolveTotals(invoiceData: any, totalTax: number, printConfigData: any = {}) {
678
+ function resolveTotals(invoiceData: any, totalTax: number, printConfigData: any = {}, taxMode: string = '') {
674
679
  const subtotal = readNumericValue(invoiceData, ['SIndTotal', 'STotal', 'SubTotal', 'SubTot', 'TaxableAmount', 'TaxableValue']);
675
680
  const isPoSPrint = isTruthy(printConfigData?.IsPoSPrint ?? printConfigData?.isPoSPrint);
681
+ const hideTaxDetails = shouldHideTaxDetails(taxMode);
676
682
  const showDetailedDisc = isTruthy(firstValue(printConfigData?.ShowDetailedDisc));
677
683
  const itemsDiscount = parseNumber(firstValue(invoiceData?.PDisc));
678
684
  const servicesDiscount = parseNumber(firstValue(invoiceData?.LDisc));
@@ -721,7 +727,7 @@ function resolveTotals(invoiceData: any, totalTax: number, printConfigData: any
721
727
  const totalLines = [
722
728
  { label: 'SubTotal', amount: subtotal },
723
729
  ...discountLines,
724
- { label: 'Total Tax', amount: totalTaxValue },
730
+ ...(!hideTaxDetails ? [{ label: 'Total Tax', amount: totalTaxValue }] : []),
725
731
  { label: 'Return Total', amount: returnTotal },
726
732
  { label: 'Total', amount: totalBeforeRound },
727
733
  { label: 'Rounding', amount: roundOff },
@@ -827,6 +833,14 @@ function parseNumber(value: any) {
827
833
  return Number.isFinite(numeric) ? numeric : 0;
828
834
  }
829
835
 
836
+ function resolveInvoiceTaxMode(invoiceData: any) {
837
+ return String(invoiceData?.Settings?.Tax ?? '').trim().toUpperCase();
838
+ }
839
+
840
+ function shouldHideTaxDetails(taxMode: string) {
841
+ return taxMode === 'BS' || taxMode === 'NO';
842
+ }
843
+
830
844
  function formatTaxRate(value: string) {
831
845
  const normalized = firstValue(value);
832
846
  if (!normalized) {