shareneus 1.4.85 → 1.4.87

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.
@@ -262,6 +262,12 @@ class InvoiceTotalsService {
262
262
  return finalTotalsData;
263
263
  }
264
264
  static groupTaxData(items, ops) {
265
+ if (tr_utils_1.TrUtils.IsNull(items)) {
266
+ items = [];
267
+ }
268
+ if (tr_utils_1.TrUtils.IsNull(ops)) {
269
+ ops = [];
270
+ }
265
271
  const combined = [...items, ...ops];
266
272
  const groupedMap = new Map();
267
273
  combined.forEach(item => {
@@ -13,11 +13,17 @@ export declare class PurchaseOrderTotalsService {
13
13
  static GetPartsTotalTaxAndAfterDiscount(PartsList: any): any[];
14
14
  static GetTotalBasedOnTaxType(PartsTotalAfterDisc: number, PartsTaxAmount: number, ServicesTotalAfterDisc: number, ServicesTaxTotal: number, IsTaxable: boolean, Adjust: number, DecimalsNumber: number): number;
15
15
  static GetDetailedTotalsData(finalTotalsData: any, IsTaxable: boolean, PartsList: any, LaborList: any, TaxCodes: any, Tax: any, HasNoTax: boolean, DecimalsNumber: number): any;
16
+ static groupTaxData(items: any[], ops: any[]): any[];
17
+ static GetTaxGroupingForLaborByPerc(opCodesList: any, TaxCodes: any, DecimalsNumber: any): any[];
18
+ static GetTaxGroupingForPartsByPerc(Parts: any, TaxCodes: any, DecimalsNumber: any): any[];
19
+ static GetTaxGroupingInfoBySAC(FinalMatchedLabors: any, TaxCodes: any, DecimalsNumber: any): any[];
20
+ static CompareLaborByPerc(opCodesList: any, TaxCodes: any): any[];
21
+ static ComparePartsByPerc(Parts: any, TaxCodes: any): any[];
16
22
  static GetPartGSTTaxTotal(PartsList: Array<any>): number[];
17
23
  static GetServicesGSTTaxTotal(ServicesList: Array<any>): number[];
18
24
  static GetPartsTaxGroupingFor(PartsList: any, TaxCodes: any, DecimalsNumber: number): any[];
19
25
  static GetTaxGroupingForPartsByHSN(Items: any, TaxCodes: any, DecimalsNumber: number): any[];
20
26
  static GetCombinedTaxPercentage(Items: any, TaxCodes: any): any;
21
27
  static ComparePartsByHSN(Items: any, TaxCodes: any): any[];
22
- static GetTaxGroupingInfoByHSN(FinalMatchedParts: any, TaxCodes: any, DecimalsNumber: number): any[];
28
+ static GetTaxGroupingInfoByHSN(FinalMatchedParts: any, TaxCodes: any, DecimalsNumber: any): any[];
23
29
  }
@@ -250,12 +250,154 @@ class PurchaseOrderTotalsService {
250
250
  finalTotalsData.Tax = Tax;
251
251
  finalTotalsData.HasNoTax = HasNoTax;
252
252
  finalTotalsData.TaxGroupData = this.GetPartsTaxGroupingFor(PartsList, TaxCodes, DecimalsNumber);
253
+ finalTotalsData.CustTaxGroupDataByPerc = this.GetTaxGroupingForPartsByPerc(PartsList, TaxCodes, DecimalsNumber);
254
+ finalTotalsData.CustLaborTaxGroupDataByPerc = this.GetTaxGroupingForLaborByPerc(LaborList, TaxCodes, DecimalsNumber);
255
+ finalTotalsData.TaxSummary = this.groupTaxData(finalTotalsData.CustTaxGroupData, finalTotalsData.CustLaborTaxGroupDataByPerc);
253
256
  // finalTotalsData.TotalRoundedBy = TrUtils.FixedTo(Math.round(finalTotalsData.Total) - finalTotalsData.Total);
254
257
  finalTotalsData.RoundedTotal = Math.round(finalTotalsData.Total);
255
258
  // finalTotalsData.Round = TrUtils.FixedTo(Math.round(finalTotalsData.Total) - finalTotalsData.Total);
256
259
  // finalTotalsData.Total = Math.round(finalTotalsData.Total);
257
260
  return finalTotalsData;
258
261
  }
262
+ static groupTaxData(items, ops) {
263
+ if (tr_utils_1.TrUtils.IsNull(items)) {
264
+ items = [];
265
+ }
266
+ if (tr_utils_1.TrUtils.IsNull(ops)) {
267
+ ops = [];
268
+ }
269
+ const combined = [...items, ...ops];
270
+ const groupedMap = new Map();
271
+ combined.forEach(item => {
272
+ if (groupedMap.has(item.CombinedTaxPercentage)) {
273
+ const existing = groupedMap.get(item.CombinedTaxPercentage);
274
+ existing.CGSTAmt = (0, aggregation_1.addition)(existing.CGSTAmt, item.CGSTAmt);
275
+ existing.SGSTAmt = (0, aggregation_1.addition)(existing.SGSTAmt, item.SGSTAmt);
276
+ // Sum IGST if present
277
+ if (item.IGSTAmt !== undefined) {
278
+ existing.IGSTAmt = (0, aggregation_1.addition)(existing.IGSTAmt || 0, item.IGSTAmt);
279
+ }
280
+ existing.TotalTaxAmount = (0, aggregation_1.addition)(existing.TotalTaxAmount || 0, item.TotalTaxAmount || 0);
281
+ existing.TotalTaxableAmount = (0, aggregation_1.addition)(existing.TotalTaxableAmount || 0, item.TotalTaxableAmount || 0);
282
+ }
283
+ else {
284
+ // Clone the object to avoid mutation
285
+ groupedMap.set(item.CombinedTaxPercentage, Object.assign({}, item));
286
+ }
287
+ });
288
+ return Array.from(groupedMap.values());
289
+ }
290
+ static GetTaxGroupingForLaborByPerc(opCodesList, TaxCodes, DecimalsNumber) {
291
+ opCodesList = this.GetCombinedTaxPercentage(tr_utils_1.TrUtils.Stringify(opCodesList), TaxCodes);
292
+ // opCodesList = this.ResetPartsHSNIfInvalid(opCodesList);
293
+ let FinalMatchedParts = this.CompareLaborByPerc(opCodesList, TaxCodes);
294
+ return this.GetTaxGroupingInfoBySAC(FinalMatchedParts, TaxCodes, DecimalsNumber);
295
+ }
296
+ static GetTaxGroupingForPartsByPerc(Parts, TaxCodes, DecimalsNumber) {
297
+ Parts = this.GetCombinedTaxPercentage(tr_utils_1.TrUtils.Stringify(Parts), TaxCodes);
298
+ // Parts = this.ResetPartsHSNIfInvalid(Parts);
299
+ let FinalMatchedParts = this.ComparePartsByPerc(Parts, TaxCodes);
300
+ return this.GetTaxGroupingInfoByHSN(FinalMatchedParts, TaxCodes, DecimalsNumber);
301
+ }
302
+ static GetTaxGroupingInfoBySAC(FinalMatchedLabors, TaxCodes, DecimalsNumber) {
303
+ let SACTaxInfo = [];
304
+ FinalMatchedLabors === null || FinalMatchedLabors === void 0 ? void 0 : FinalMatchedLabors.forEach((MatchedLabor) => {
305
+ let TaxInfo = {};
306
+ let TaxOnAmount = 0;
307
+ let TaxAmount = 0;
308
+ let CGSTAmt = 0;
309
+ let SGSTAmt = 0;
310
+ let IGSTAmt = 0;
311
+ let SAC = MatchedLabor[0].SAC;
312
+ TaxInfo.CombinedTaxPercentage = MatchedLabor[0].CombinedTaxPercentage;
313
+ MatchedLabor === null || MatchedLabor === void 0 ? void 0 : MatchedLabor.forEach((argMatchedGSTLabor) => {
314
+ TaxOnAmount = (0, aggregation_1.addition)(TaxOnAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTLabor.AfterLaborDisc, DecimalsNumber));
315
+ TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTLabor.CGST, DecimalsNumber));
316
+ TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTLabor.IGST, DecimalsNumber));
317
+ TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTLabor.SGST, DecimalsNumber));
318
+ CGSTAmt = (0, aggregation_1.addition)(CGSTAmt, tr_utils_1.TrUtils.FixedTo(argMatchedGSTLabor.CGST, DecimalsNumber));
319
+ SGSTAmt = (0, aggregation_1.addition)(SGSTAmt, tr_utils_1.TrUtils.FixedTo(argMatchedGSTLabor.SGST, DecimalsNumber));
320
+ IGSTAmt = (0, aggregation_1.addition)(IGSTAmt, tr_utils_1.TrUtils.FixedTo(argMatchedGSTLabor.IGST, DecimalsNumber));
321
+ });
322
+ TaxInfo.SAC = SAC;
323
+ TaxInfo.CGSTAmt = CGSTAmt;
324
+ TaxInfo.SGSTAmt = SGSTAmt;
325
+ TaxInfo.IGSTAmt = IGSTAmt;
326
+ TaxInfo.TotalTaxableAmount = tr_utils_1.TrUtils.FixPriceValue(TaxOnAmount, DecimalsNumber);
327
+ TaxInfo.TotalTaxAmount = tr_utils_1.TrUtils.FixPriceValue(TaxAmount, DecimalsNumber);
328
+ TaxInfo.ItemsCount = MatchedLabor.length;
329
+ let GSTValues = this.GetGSTValueBasedOnTaxCode(MatchedLabor[0].TCode, TaxCodes);
330
+ TaxInfo.CGST = GSTValues[0];
331
+ TaxInfo.SGST = GSTValues[1];
332
+ TaxInfo.IGST = GSTValues[2];
333
+ if (TaxOnAmount !== 0) {
334
+ SACTaxInfo.push(TaxInfo);
335
+ }
336
+ });
337
+ return SACTaxInfo;
338
+ }
339
+ static CompareLaborByPerc(opCodesList, TaxCodes) {
340
+ let FinalMatchedLabors = [];
341
+ opCodesList === null || opCodesList === void 0 ? void 0 : opCodesList.forEach((Labor) => {
342
+ let MatchedLaborsBasedOnPerc = opCodesList.filter((argLabor) => {
343
+ let PartFound = false;
344
+ FinalMatchedLabors.forEach((FinalArgLabors) => {
345
+ let PartIndex = FinalArgLabors.findIndex((FinalArgPart) => {
346
+ return FinalArgPart._id === argLabor._id;
347
+ });
348
+ if (PartIndex !== -1) {
349
+ PartFound = true;
350
+ }
351
+ });
352
+ // let argGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(argLabor.TCode, TaxCodes);
353
+ // let argCGST = argGSTValues[0];
354
+ // let argSGST = argGSTValues[1];
355
+ // let argIGST = argGSTValues[2];
356
+ // let laborGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(Labor.TCode, TaxCodes);
357
+ // let laborCGST = laborGSTValues[0];
358
+ // let laborSGST = laborGSTValues[1];
359
+ // let laborIGST = laborGSTValues[2];
360
+ return (!PartFound) &&
361
+ (argLabor.CGSTAmt === Labor.CGSTAmt) && (argLabor.IGSTAmt === Labor.IGSTAmt) &&
362
+ (argLabor.SGSTAmt === Labor.SGSTAmt);
363
+ });
364
+ if (MatchedLaborsBasedOnPerc.length !== 0) {
365
+ FinalMatchedLabors.push(MatchedLaborsBasedOnPerc);
366
+ }
367
+ });
368
+ return FinalMatchedLabors;
369
+ }
370
+ static ComparePartsByPerc(Parts, TaxCodes) {
371
+ let FinalMatchedParts = [];
372
+ Parts === null || Parts === void 0 ? void 0 : Parts.forEach((Part) => {
373
+ let MatchedPartsBasedOnHSN = Parts.filter((argPart) => {
374
+ let PartFound = false;
375
+ FinalMatchedParts.forEach((FinalArgParts) => {
376
+ let PartIndex = FinalArgParts.findIndex((FinalArgPart) => {
377
+ return FinalArgPart._id === argPart._id;
378
+ });
379
+ if (PartIndex !== -1) {
380
+ PartFound = true;
381
+ }
382
+ });
383
+ // let argGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(argPart.TCode, TaxCodes);
384
+ // let argCGST = argGSTValues[0];
385
+ // let argSGST = argGSTValues[1];
386
+ // let argIGST = argGSTValues[2];
387
+ // let partGSTValues: any[] = this.GetGSTValueBasedOnTaxCode(Part.TCode, TaxCodes);
388
+ // let partCGST = partGSTValues[0];
389
+ // let partSGST = partGSTValues[1];
390
+ // let partIGST = partGSTValues[2];
391
+ return (!PartFound) &&
392
+ (argPart.CGSTAmt === Part.CGSTAmt) && (argPart.IGSTAmt === Part.IGSTAmt) &&
393
+ (argPart.SGSTAmt === Part.SGSTAmt);
394
+ });
395
+ if (MatchedPartsBasedOnHSN.length !== 0) {
396
+ FinalMatchedParts.push(MatchedPartsBasedOnHSN);
397
+ }
398
+ });
399
+ return FinalMatchedParts;
400
+ }
259
401
  static GetPartGSTTaxTotal(PartsList) {
260
402
  let CGSTAmt = 0;
261
403
  let SGSTAmt = 0;
@@ -338,21 +480,31 @@ class PurchaseOrderTotalsService {
338
480
  let TaxInfo = {};
339
481
  let TaxOnAmount = 0;
340
482
  let TaxAmount = 0;
483
+ let CGSTAmt = 0;
484
+ let SGSTAmt = 0;
485
+ let IGSTAmt = 0;
341
486
  let HSN = MatchedPart[0].HSN;
342
487
  TaxInfo.CombinedTaxPercentage = MatchedPart[0].CombinedTaxPercentage;
343
488
  MatchedPart.forEach((argMatchedGSTPart) => {
344
- TaxOnAmount = (0, aggregation_1.addition)(TaxOnAmount, argMatchedGSTPart.AfterDiscountPrice);
345
- TaxAmount = (0, aggregation_1.addition)(TaxAmount, argMatchedGSTPart.CGST);
346
- TaxAmount = (0, aggregation_1.addition)(TaxAmount, argMatchedGSTPart.IGST);
347
- TaxAmount = (0, aggregation_1.addition)(TaxAmount, argMatchedGSTPart.SGST);
489
+ TaxOnAmount = (0, aggregation_1.addition)(TaxOnAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.AfterDiscountPrice, DecimalsNumber));
490
+ TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.CGST, DecimalsNumber));
491
+ TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.IGST, DecimalsNumber));
492
+ TaxAmount = (0, aggregation_1.addition)(TaxAmount, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.SGST, DecimalsNumber));
493
+ CGSTAmt = (0, aggregation_1.addition)(CGSTAmt, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.CGST, DecimalsNumber));
494
+ SGSTAmt = (0, aggregation_1.addition)(SGSTAmt, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.SGST, DecimalsNumber));
495
+ IGSTAmt = (0, aggregation_1.addition)(IGSTAmt, tr_utils_1.TrUtils.FixedTo(argMatchedGSTPart.IGST, DecimalsNumber));
348
496
  });
349
497
  TaxInfo.HSN = HSN;
498
+ TaxInfo.CGSTAmt = CGSTAmt;
499
+ TaxInfo.SGSTAmt = SGSTAmt;
500
+ TaxInfo.IGSTAmt = IGSTAmt;
350
501
  TaxInfo.TotalTaxableAmount = tr_utils_1.TrUtils.FixPriceValue(TaxOnAmount, DecimalsNumber);
351
502
  TaxInfo.TotalTaxAmount = tr_utils_1.TrUtils.FixPriceValue(TaxAmount, DecimalsNumber);
352
- TaxInfo.PartsCount = MatchedPart.length;
353
- // let CGST = this.GetCGSTValueBasedOnTaxCode(MatchedPart[0].TCode, TaxCodes);
354
- // let SGST = this.GetSGSTValueBasedOnTaxCode(MatchedPart[0].TCode, TaxCodes);
355
- // let IGST = this.GetIGSTValueBasedOnTaxCode(MatchedPart[0].TCode, TaxCodes);
503
+ TaxInfo.ItemsCount = MatchedPart.length;
504
+ // let GSTValues: any[] = this.GetGSTValueBasedOnTaxCode(MatchedPart[0].TCode, TaxCodes);
505
+ // TaxInfo.CGST = GSTValues[0];
506
+ // TaxInfo.SGST = GSTValues[1];
507
+ // TaxInfo.IGST = GSTValues[2];
356
508
  TaxInfo.CGST = MatchedPart[0].CGSTAmt;
357
509
  TaxInfo.IGST = MatchedPart[0].IGSTAmt;
358
510
  TaxInfo.SGST = MatchedPart[0].SGSTAmt;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.4.85",
3
+ "version": "1.4.87",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",