shareneus 1.6.67 → 1.6.68

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.
@@ -25,5 +25,7 @@ export declare class SalesTotalsService {
25
25
  static GetCombinedTaxPercentage(Items: any, TaxCodes: any): any;
26
26
  static CompareItemsByHSN(Items: any, TaxCodes: any): any[];
27
27
  static GetTaxGroupingInfoByHSN(FinalMatchedParts: any, TaxCodes: any, DecimalsNumber: any): any[];
28
+ static GetTaxAmountFromTaxes(item: any, taxCode: string, fallbackAmount?: any): any;
29
+ static GetTaxRateFromTaxes(item: any, taxCode: string, fallbackRate?: any): any;
28
30
  static GetGSTValueBasedOnTaxCode(TCode: any, TaxCodes: any): any[];
29
31
  }
@@ -48,9 +48,9 @@ class SalesTotalsService {
48
48
  Item.UnPr = tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.UnPr);
49
49
  Item.Disc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.Disc);
50
50
  Item.RecDisc = tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.RecDisc);
51
- Item.CGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.CGST);
52
- Item.SGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.SGST);
53
- Item.IGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(Item.IGST);
51
+ Item.CGST = this.GetTaxAmountFromTaxes(Item, 'CGST');
52
+ Item.SGST = this.GetTaxAmountFromTaxes(Item, 'SGST');
53
+ Item.IGST = this.GetTaxAmountFromTaxes(Item, 'IGST');
54
54
  return Item;
55
55
  }
56
56
  static GetFinalRODataForSave(ItemsList, IsIndependentTax, PDisc, PPerc, Disc, Perc, DetailedInfo, Settings, isRoundable, DecimalsNumber) {
@@ -283,9 +283,9 @@ class SalesTotalsService {
283
283
  Item.HSN = '';
284
284
  }
285
285
  let TaxInfo = this.GetGSTValueBasedOnTaxCode(Item.TCode, TaxCodes);
286
- Item.CGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[0]);
287
- Item.SGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[1]);
288
- Item.IGSTAmt = tr_utils_1.TrUtils.SetValueToZeroIfNull(TaxInfo[2]);
286
+ Item.CGSTAmt = this.GetTaxRateFromTaxes(Item, 'CGST');
287
+ Item.SGSTAmt = this.GetTaxRateFromTaxes(Item, 'SGST');
288
+ Item.IGSTAmt = this.GetTaxRateFromTaxes(Item, 'IGST');
289
289
  Item.CombinedTaxPercentage = (0, math_operations_1.Add)(Item.CGSTAmt, Item.SGSTAmt, Item.IGSTAmt);
290
290
  });
291
291
  return Items;
@@ -361,6 +361,22 @@ class SalesTotalsService {
361
361
  });
362
362
  return HSNTaxInfo;
363
363
  }
364
+ static GetTaxAmountFromTaxes(item, taxCode, fallbackAmount = 0) {
365
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
366
+ const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
367
+ if (matchedTaxes.length !== 0) {
368
+ return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Amt), 0);
369
+ }
370
+ return tr_utils_1.TrUtils.SetValueToZeroIfNull(fallbackAmount);
371
+ }
372
+ static GetTaxRateFromTaxes(item, taxCode, fallbackRate = 0) {
373
+ const taxes = Array.isArray(item === null || item === void 0 ? void 0 : item.Taxes) ? item.Taxes : [];
374
+ const matchedTaxes = taxes.filter((tax) => (tax === null || tax === void 0 ? void 0 : tax.Code) === taxCode);
375
+ if (matchedTaxes.length !== 0) {
376
+ return matchedTaxes.reduce((total, tax) => (0, math_operations_1.Add)(total, tax === null || tax === void 0 ? void 0 : tax.Rate), 0);
377
+ }
378
+ return tr_utils_1.TrUtils.SetValueToZeroIfNull(fallbackRate);
379
+ }
364
380
  static GetGSTValueBasedOnTaxCode(TCode, TaxCodes) {
365
381
  let CGST = 0;
366
382
  let SGST = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.6.67",
3
+ "version": "1.6.68",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",