shareneus 1.6.36 → 1.6.37

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.
@@ -37,6 +37,7 @@ export declare class InvoiceTotalsService {
37
37
  static GetLaborGSTTaxTotal(opCodesList: any, IsIndependentTax: boolean): number[];
38
38
  static GetPartGSTTaxTotal(PartsList: any, IsIndependentTax: boolean): number[];
39
39
  static GetTaxGroupingForPartsByHSN(Parts: any, TaxCodes: any, DecimalsNumber: any): any[];
40
+ static GetTaxRateFromTaxes(item: any, taxCode: string): any;
40
41
  static GetCombinedTaxPercentage(Parts: any, TaxCodes: any): any;
41
42
  static ComparePartsByHSN(Parts: any, TaxCodes: any): any[];
42
43
  static GetTaxGroupingInfoByHSN(FinalMatchedParts: any, TaxCodes: any, DecimalsNumber: any): any[];
@@ -574,18 +574,22 @@ class InvoiceTotalsService {
574
574
  let FinalMatchedParts = this.ComparePartsByHSN(Parts, TaxCodes);
575
575
  return this.GetTaxGroupingInfoByHSN(FinalMatchedParts, TaxCodes, DecimalsNumber);
576
576
  }
577
+ static GetTaxRateFromTaxes(item, taxCode) {
578
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
579
+ const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
580
+ if (matchedTaxes.length !== 0) {
581
+ return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Rate), 0);
582
+ }
583
+ return 0;
584
+ }
577
585
  static GetCombinedTaxPercentage(Parts, TaxCodes) {
578
586
  Parts.forEach((Part) => {
579
587
  if (tr_utils_1.TrUtils.IsNull(Part.HSN)) {
580
588
  Part.HSN = '';
581
589
  }
582
- let GSTValues = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
583
- // let CGST = GSTValues[0];
584
- // let SGST = GSTValues[1];
585
- // let IGST = GSTValues[2];
586
- Part.CGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(GSTValues[0]);
587
- Part.SGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(GSTValues[1]);
588
- Part.IGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(GSTValues[2]);
590
+ Part.CGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxRateFromTaxes(Part, 'CGST'));
591
+ Part.SGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxRateFromTaxes(Part, 'SGST'));
592
+ Part.IGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(this.GetTaxRateFromTaxes(Part, 'IGST'));
589
593
  Part.CombinedTaxPercentage = (0, math_operations_1.Add)(Part.CGSTAmt, Part.SGSTAmt, Part.IGSTAmt);
590
594
  });
591
595
  return Parts;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.6.36",
3
+ "version": "1.6.37",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",