shareneus 1.6.51 → 1.6.53

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.
@@ -12,9 +12,10 @@ const inv_print_service_1 = require("./inv-print.service");
12
12
  const invoice_pdf_service_1 = require("./invoice-pdf/invoice-pdf.service");
13
13
  const unified_invoice_pdf_service_1 = require("./unified-invoice-pdf.service");
14
14
  function GetInvoicePDF(invoiceData, entityData, headerConfig, printConfig, taxCodes, image = null, numberofCopies = ['Original'], withPass = false, options = null) {
15
+ var _a;
15
16
  if (!options) {
16
17
  options = {
17
- ShowGST: true,
18
+ ShowGST: (((_a = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Settings) === null || _a === void 0 ? void 0 : _a.Tax) === 'TI') ? true : false,
18
19
  ConsolidateGST: false,
19
20
  PartInvoice: true,
20
21
  LaborInvoice: true,
@@ -42,9 +43,10 @@ function GetInvoicePDF(invoiceData, entityData, headerConfig, printConfig, taxCo
42
43
  return invPrint;
43
44
  }
44
45
  function GetSalesReceiptPDF(salesReceiptData, entityData, headerConfig, printConfig, taxCodes, image = null, numberofCopies = ['Original'], withPass = false, options = null) {
46
+ var _a;
45
47
  if (!options) {
46
48
  options = {
47
- ShowGST: true,
49
+ ShowGST: (((_a = salesReceiptData === null || salesReceiptData === void 0 ? void 0 : salesReceiptData.Settings) === null || _a === void 0 ? void 0 : _a.Tax) === 'TI') ? true : false,
48
50
  ConsolidateGST: false,
49
51
  PartInvoice: true,
50
52
  LaborInvoice: true,
@@ -182,7 +182,7 @@ class InvoiceTotalsService {
182
182
  let CustPartsTotalAfterDisc1 = this.GetPartsAfterDiscount1(PartsList);
183
183
  let AmtAfterIndvidualItemDisc = (0, math_operations_1.Add)(CustLaborTotalAfterDisc1, CustPartsTotalAfterDisc1);
184
184
  finalTotalsData.SIndTotal = AmtAfterIndvidualItemDisc;
185
- finalTotalsData.Disc = !tr_utils_1.TrUtils.IsEmpty(finalTotalsData.Perc) ? tr_utils_1.TrUtils.ConvertPercToVal(finalTotalsData.Perc, AmtAfterIndvidualItemDisc, DecimalsNumber) : finalTotalsData.Disc;
185
+ finalTotalsData.Disc = !tr_utils_1.TrUtils.IsZero(finalTotalsData.Perc) ? tr_utils_1.TrUtils.ConvertPercToVal(finalTotalsData.Perc, AmtAfterIndvidualItemDisc, DecimalsNumber) : finalTotalsData.Disc;
186
186
  let CustTotal = this.GetCustomerTotalBasedOnTaxType(finalTotalsData, CustLaborTaxTotal, CustPartTaxTotal, LaborList, PartsList, IsIndependentTax, Adjust);
187
187
  let RetCustTotal = this.GetRetCustomerTotalBasedOnTaxType(finalTotalsData, CustLaborTaxTotal, RetCustParrtTaxTotal, LaborList, PartsList, IsIndependentTax, Adjust, DecimalsNumber);
188
188
  let NonRetCustTotal = this.GetNonRetCustomerTotalBasedOnTaxType(finalTotalsData, CustLaborTaxTotal, NonRetCustParrtTaxTotal, LaborList, PartsList, IsIndependentTax, Adjust, DecimalsNumber);
@@ -1,4 +1,7 @@
1
1
  export declare class PurchaseOrderTotalsService {
2
+ static GetTaxAmountFromTaxes(item: any, taxCode: string): any;
3
+ static GetTaxRateFromTaxes(item: any, taxCode: string): any;
4
+ static GetTCodeFromTaxes(item: any): any;
2
5
  static GetTotalsValue(opCodesList: any, argPartsList: any, IsTaxable: boolean, DetailedTotalsInfo: boolean, TaxCodes: any, Tax: any, ReturnPartsAlso: boolean, HasNoTax: boolean, GetSubTotal: boolean, Discount: number, DiscInPerc: boolean, Adjust: number, EntitySettings: any): any;
3
6
  static CalculateLaborValues(opCodesList: any, IsIndependentTax: boolean, DecimalsNumber: number): any;
4
7
  static ResetLaborValues(opCodesList: any, IsIndependentTax: boolean, DecimalsNumber: number): any;
@@ -5,6 +5,30 @@ const code_enums_1 = require("../../enums/code-enums");
5
5
  const math_operations_1 = require("../../shared/math-operations");
6
6
  const tr_utils_1 = require("../../utils/tr-utils");
7
7
  class PurchaseOrderTotalsService {
8
+ static GetTaxAmountFromTaxes(item, taxCode) {
9
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
10
+ const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
11
+ if (matchedTaxes.length !== 0) {
12
+ return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Amt), 0);
13
+ }
14
+ return 0;
15
+ }
16
+ static GetTaxRateFromTaxes(item, taxCode) {
17
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
18
+ const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
19
+ if (matchedTaxes.length !== 0) {
20
+ return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Rate), 0);
21
+ }
22
+ return 0;
23
+ }
24
+ static GetTCodeFromTaxes(item) {
25
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
26
+ const matchedTax = taxes.find((tax) => !tr_utils_1.TrUtils.IsNull(tax === null || tax === void 0 ? void 0 : tax.TaxCodeId));
27
+ if (!tr_utils_1.TrUtils.IsNull(matchedTax === null || matchedTax === void 0 ? void 0 : matchedTax.TaxCodeId)) {
28
+ return matchedTax.TaxCodeId;
29
+ }
30
+ return item === null || item === void 0 ? void 0 : item.TCode;
31
+ }
8
32
  static GetTotalsValue(opCodesList, argPartsList, IsTaxable, DetailedTotalsInfo, TaxCodes, Tax, ReturnPartsAlso, HasNoTax, GetSubTotal, Discount, DiscInPerc, Adjust, EntitySettings) {
9
33
  let PartsList = tr_utils_1.TrUtils.IsNull(argPartsList) ? [] : tr_utils_1.TrUtils.Stringify(argPartsList);
10
34
  // PartsList = this.ResetPartValuesIfInvalid(PartsList);
@@ -65,9 +89,10 @@ class PurchaseOrderTotalsService {
65
89
  Operation.UnCo = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.UnCo);
66
90
  Operation.RecDisc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.RecDisc);
67
91
  Operation.Disc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.Disc);
68
- Operation.CGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.CGST);
69
- Operation.SGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.SGST);
70
- Operation.IGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Operation.IGST);
92
+ Operation.CGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxAmountFromTaxes(Operation, 'CGST') || Operation.CGST);
93
+ Operation.SGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxAmountFromTaxes(Operation, 'SGST') || Operation.SGST);
94
+ Operation.IGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxAmountFromTaxes(Operation, 'IGST') || Operation.IGST);
95
+ Operation.TCode = this.GetTCodeFromTaxes(Operation);
71
96
  return Operation;
72
97
  }
73
98
  static CheckPartStatusAndReturn(PartsList) {
@@ -83,9 +108,10 @@ class PurchaseOrderTotalsService {
83
108
  }
84
109
  Part.UnCo = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.UnCo);
85
110
  Part.Disc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.Disc);
86
- Part.SGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.SGST);
87
- Part.IGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.IGST);
88
- Part.CGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Part.CGST);
111
+ Part.SGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxAmountFromTaxes(Part, 'SGST') || Part.SGST);
112
+ Part.IGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxAmountFromTaxes(Part, 'IGST') || Part.IGST);
113
+ Part.CGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxAmountFromTaxes(Part, 'CGST') || Part.CGST);
114
+ Part.TCode = this.GetTCodeFromTaxes(Part);
89
115
  // }
90
116
  return Part;
91
117
  }
@@ -241,9 +267,9 @@ class PurchaseOrderTotalsService {
241
267
  finalTotalsData.PartSGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxAmt[1]);
242
268
  finalTotalsData.PartIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxAmt[2]);
243
269
  let ServiceTaxAmt = this.GetServicesGSTTaxTotal(LaborList);
244
- finalTotalsData.ServieCGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxAmt[0]);
245
- finalTotalsData.ServieSGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxAmt[1]);
246
- finalTotalsData.ServieIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxAmt[2]);
270
+ finalTotalsData.ServieCGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(ServiceTaxAmt[0]);
271
+ finalTotalsData.ServieSGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(ServiceTaxAmt[1]);
272
+ finalTotalsData.ServieIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(ServiceTaxAmt[2]);
247
273
  finalTotalsData.PartAfterTax = (0, math_operations_1.Add)(finalTotalsData.PartsTotalAfterDisc, finalTotalsData.TaxTotal);
248
274
  finalTotalsData.ServiceAfterTax = (0, math_operations_1.Add)(finalTotalsData.ServiceTotalAfterDisc, finalTotalsData.ServiceTaxTotal);
249
275
  finalTotalsData.IsTaxable = IsTaxable;
@@ -434,13 +460,10 @@ class PurchaseOrderTotalsService {
434
460
  if (tr_utils_1.TrUtils.IsNull(Part.HSN)) {
435
461
  Part.HSN = '';
436
462
  }
437
- let TaxInfo = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
438
- Part.CGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[0]);
439
- Part.SGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[1]);
440
- Part.IGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[2]);
441
- // Part.CGSTAmt = this.GetCGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
442
- // Part.SGSTAmt = this.GetSGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
443
- // Part.IGSTAmt = this.GetIGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
463
+ Part.TCode = this.GetTCodeFromTaxes(Part);
464
+ Part.CGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxRateFromTaxes(Part, 'CGST'));
465
+ Part.SGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxRateFromTaxes(Part, 'SGST'));
466
+ Part.IGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxRateFromTaxes(Part, 'IGST'));
444
467
  Part.CombinedTaxPercentage = (0, math_operations_1.Add)(Part.CGSTAmt, Part.SGSTAmt, Part.IGSTAmt);
445
468
  });
446
469
  return Items;
@@ -472,6 +472,8 @@ function resolveTotals(invoiceData, totalTax, printConfigData = {}) {
472
472
  const itemsDiscount = parseNumber((0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.PDisc));
473
473
  const servicesDiscount = parseNumber((0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.LDisc));
474
474
  const overallDiscount = parseNumber((0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Disc, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Discount, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.TotDisc));
475
+ const overalItemsDiscount = parseNumber((0, pdf_shared_utils_1.firstValue)((invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.CustPartsDiscTotal) || (invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.PartsDiscTotal)));
476
+ const overalServicesDiscount = parseNumber((0, pdf_shared_utils_1.firstValue)((invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.CustLaborDiscTotal) || (invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.ServiceDiscTotal)));
475
477
  const hasDetailedDiscSource = (0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.PDisc) !== ''
476
478
  || (0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.LDisc) !== ''
477
479
  || (0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Disc, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Discount, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.TotDisc) !== '';
@@ -480,9 +482,7 @@ function resolveTotals(invoiceData, totalTax, printConfigData = {}) {
480
482
  : (0, pdf_table_section_1.readNumericValue)(invoiceData, ['Disc', 'Discount', 'TotDisc']);
481
483
  const roundOff = (0, pdf_table_section_1.readNumericValue)(invoiceData, ['Round', 'RoundOff']);
482
484
  console.log('invoiceData', invoiceData);
483
- console.log('TotalTax', invoiceData.TotalTax);
484
485
  const taxFromInvoice = (0, pdf_table_section_1.readNumericValue)(invoiceData, ['TotalTax', 'TaxTotal', 'TaxAmt', 'GSTTotal', 'CustItemITax']);
485
- console.log('taxFromInvoice', taxFromInvoice);
486
486
  const totalTaxValue = taxFromInvoice !== 0 ? taxFromInvoice : totalTax;
487
487
  const returnTotal = (0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.RetTotal);
488
488
  const finalTotalRaw = (0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.FinalTotal, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Total, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.GrandTotal, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.NetTotal);
@@ -507,7 +507,7 @@ function resolveTotals(invoiceData, totalTax, printConfigData = {}) {
507
507
  { label: 'Overall Discount', amount: overallDiscount }
508
508
  ]
509
509
  : [
510
- { label: 'Discount', amount: discount }
510
+ { label: 'Discount', amount: overalItemsDiscount + overalServicesDiscount }
511
511
  ])
512
512
  .filter((line) => Math.abs(parseNumber(line === null || line === void 0 ? void 0 : line.amount)) > 0);
513
513
  const totalLines = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.6.51",
3
+ "version": "1.6.53",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",