shareneus 1.7.344 → 1.7.346

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.
@@ -268,6 +268,7 @@ class InvoiceTotalsService {
268
268
  finalTotalsData.CustPartCGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(PartTaxInfo[0]);
269
269
  finalTotalsData.CustPartIGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(PartTaxInfo[2]);
270
270
  finalTotalsData.CustPartSGST = tr_utils_1.TrUtils.SetValueToZeroIfNull(PartTaxInfo[1]);
271
+ finalTotalsData.CustPartCESS = tr_utils_1.TrUtils.SetValueToZeroIfNull(PartTaxInfo[3]);
271
272
  finalTotalsData.CustLaborAfterTax = (0, math_operations_1.Add)(finalTotalsData.CustLaborITax, finalTotalsData.CustLaborTotalAfterDisc);
272
273
  finalTotalsData.CustPartAfterTax = (0, math_operations_1.Add)(finalTotalsData.CustPartITax, finalTotalsData.CustPartsTotalAfterDisc);
273
274
  finalTotalsData.CustTaxGroupData = this.GetTaxGroupingForPartsByHSN(PartsList, TaxCodes, DecimalsNumber);
@@ -471,10 +472,10 @@ class InvoiceTotalsService {
471
472
  if (IsIndependentTax) {
472
473
  PartsList.forEach((Part) => {
473
474
  if (Part.Ret === true) {
474
- RetTotalTaxAmt = (0, math_operations_1.Add)(RetTotalTaxAmt, Part.CGST, Part.SGST, Part.IGST);
475
+ RetTotalTaxAmt = (0, math_operations_1.Add)(RetTotalTaxAmt, Part.CGST, Part.SGST, Part.IGST, Part.CESS);
475
476
  }
476
477
  else {
477
- TotalTaxAmt = (0, math_operations_1.Add)(TotalTaxAmt, Part.CGST, Part.SGST, Part.IGST);
478
+ TotalTaxAmt = (0, math_operations_1.Add)(TotalTaxAmt, Part.CGST, Part.SGST, Part.IGST, Part.CESS);
478
479
  }
479
480
  });
480
481
  }
@@ -485,7 +486,7 @@ class InvoiceTotalsService {
485
486
  if (IsIndependentTax) {
486
487
  PartsList.forEach((Part) => {
487
488
  if (Part.Ret === true) {
488
- RetTotalTaxAmt = (0, math_operations_1.Add)(RetTotalTaxAmt, Part.CGST, Part.SGST, Part.IGST);
489
+ RetTotalTaxAmt = (0, math_operations_1.Add)(RetTotalTaxAmt, Part.CGST, Part.SGST, Part.IGST, Part.CESS);
489
490
  }
490
491
  });
491
492
  }
@@ -496,7 +497,7 @@ class InvoiceTotalsService {
496
497
  if (IsIndependentTax) {
497
498
  PartsList.forEach((Part) => {
498
499
  if (tr_utils_1.TrUtils.IsNull(Part.Ret) || Part.Ret === false) {
499
- NonRetTotalTaxAmt = (0, math_operations_1.Add)(NonRetTotalTaxAmt, Part.CGST, Part.SGST, Part.IGST);
500
+ NonRetTotalTaxAmt = (0, math_operations_1.Add)(NonRetTotalTaxAmt, Part.CGST, Part.SGST, Part.IGST, Part.CESS);
500
501
  }
501
502
  });
502
503
  }
@@ -582,21 +583,25 @@ class InvoiceTotalsService {
582
583
  let TotalIGSTAmt = 0;
583
584
  let TotalSGSTAmt = 0;
584
585
  let RetTotalSGSTAmt = 0;
586
+ let TotalCESSAmt = 0;
587
+ let RetTotalCESSAmt = 0;
585
588
  if (IsIndependentTax) {
586
589
  PartsList.forEach((Part) => {
587
590
  if (Part.Ret === true) {
588
591
  RetTotalCGSTAmt = (0, math_operations_1.Add)(RetTotalCGSTAmt, Part.CGST);
589
592
  RetTotalSGSTAmt = (0, math_operations_1.Add)(RetTotalSGSTAmt, Part.SGST);
590
593
  RetTotalIGSTAmt = (0, math_operations_1.Add)(RetTotalIGSTAmt, Part.IGST);
594
+ RetTotalCESSAmt = (0, math_operations_1.Add)(RetTotalCESSAmt, Part.CESS);
591
595
  }
592
596
  else {
593
597
  TotalCGSTAmt = (0, math_operations_1.Add)(TotalCGSTAmt, Part.CGST);
594
598
  TotalSGSTAmt = (0, math_operations_1.Add)(TotalSGSTAmt, Part.SGST);
595
599
  TotalIGSTAmt = (0, math_operations_1.Add)(TotalIGSTAmt, Part.IGST);
600
+ TotalCESSAmt = (0, math_operations_1.Add)(TotalCESSAmt, Part.CESS);
596
601
  }
597
602
  });
598
603
  }
599
- return [TotalCGSTAmt, TotalSGSTAmt, TotalIGSTAmt];
604
+ return [TotalCGSTAmt, TotalSGSTAmt, TotalIGSTAmt, TotalCESSAmt, RetTotalCGSTAmt];
600
605
  }
601
606
  static GetTaxGroupingForPartsByHSN(Parts, TaxCodes, DecimalsNumber) {
602
607
  Parts = this.GetCombinedTaxPercentage(tr_utils_1.TrUtils.Stringify(Parts), TaxCodes);
@@ -571,7 +571,7 @@ function resolveTotals(invoiceData, totalTax, printConfigData = {}, taxMode = ''
571
571
  ? itemsDiscount + servicesDiscount + overallDiscount
572
572
  : (0, pdf_table_section_1.readNumericValue)(invoiceData, ['Disc', 'Discount', 'TotDisc']);
573
573
  const roundOff = (0, pdf_table_section_1.readNumericValue)(invoiceData, ['Round', 'RoundOff']);
574
- const taxFromInvoice = (0, pdf_table_section_1.readNumericValue)(invoiceData, ['TotalTax', 'TaxTotal', 'TaxAmt', 'GSTTotal', 'CustItemITax']);
574
+ const taxFromInvoice = (0, pdf_table_section_1.readNumericValue)(invoiceData, ['TotalTax', 'TaxTotal', 'TaxAmt', 'GSTTotal', 'CustItemITax', 'CustPartITax']);
575
575
  const totalTaxValue = taxFromInvoice !== 0 ? taxFromInvoice : totalTax;
576
576
  const returnTotal = (0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.RetTotal);
577
577
  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);
@@ -44,14 +44,12 @@ function GetInvoicePDF(invoiceData, entityData, headerConfig, printConfig, taxCo
44
44
  invPrint = (0, unified_invoice_pdf_service_1.GetInvoicePrint)(invoicePrintData, numberofCopies, withPass, options.Size, options.MoreDiscDetails, options.Orientation);
45
45
  }
46
46
  else {
47
- console.log("options", options);
48
47
  if (options.PartInvoice && options.LaborInvoice) {
49
48
  invoicePrintData.Round = tr_utils_1.TrUtils.FixedTo(invoiceData.Round);
50
49
  invoicePrintData.Total = tr_utils_1.TrUtils.FixedTo(invoiceData.Total);
51
50
  invoicePrintData.SubToal = tr_utils_1.TrUtils.FixedTo(invoiceData.SubToal);
52
51
  invoicePrintData.TaxTotal = tr_utils_1.TrUtils.FixedTo(invoiceData.TaxTotal);
53
52
  }
54
- console.log("invoicePrintData", invoicePrintData);
55
53
  delete invoicePrintData.SIndTotal;
56
54
  invPrint = (0, invoice_pdf_service_1.CreateInvoicePDFService)(invoicePrintData, printConfigData, numberofCopies);
57
55
  }
@@ -3,4 +3,5 @@ export declare function TotalCalculations(items?: any[], ops?: any[], isTaxable?
3
3
  * Enhanced version with decimal places control
4
4
  */
5
5
  export declare function TotalCalculationsWithDecimals(items: any[] | undefined, ops: any[] | undefined, isTaxable: boolean | undefined, taxCodes: any[] | undefined, Adjust: number, decimalPlaces?: number): any;
6
+ export declare function getTaxName(taxes: any): string;
6
7
  export declare function CalculateTaxSummary(items: any[], taxCodes: any[]): unknown[];
@@ -2,9 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TotalCalculations = TotalCalculations;
4
4
  exports.TotalCalculationsWithDecimals = TotalCalculationsWithDecimals;
5
+ exports.getTaxName = getTaxName;
5
6
  exports.CalculateTaxSummary = CalculateTaxSummary;
6
7
  const math_operations_1 = require("../shared/math-operations");
7
8
  const util_1 = require("../shared/util");
9
+ const tr_utils_1 = require("../utils/tr-utils");
8
10
  /**
9
11
  * Safely handles null/undefined arrays and returns empty array
10
12
  */
@@ -340,12 +342,45 @@ function TotalCalculationsWithDecimals(items = [], ops = [], isTaxable = false,
340
342
  }
341
343
  return roundedResult;
342
344
  }
345
+ function getTaxName(taxes) {
346
+ if (Array.isArray(taxes) && taxes.length > 0) {
347
+ const taxRates = taxes.reduce((rates, tax) => {
348
+ var _a, _b;
349
+ const code = (_a = tax === null || tax === void 0 ? void 0 : tax.Code) === null || _a === void 0 ? void 0 : _a.toString().trim().toUpperCase();
350
+ const rawCalcMethod = (_b = tax === null || tax === void 0 ? void 0 : tax.CalcMethod) === null || _b === void 0 ? void 0 : _b.toString().trim().toUpperCase();
351
+ const calcMethod = !rawCalcMethod || rawCalcMethod === 'PERCENTAGE' ? 'PERCENT' : rawCalcMethod;
352
+ if (['CGST', 'SGST', 'IGST'].includes(code)) {
353
+ rates.gstRate = (0, math_operations_1.Add)(rates.gstRate, tr_utils_1.TrUtils.SetValueToZeroIfNull(tax === null || tax === void 0 ? void 0 : tax.Rate));
354
+ }
355
+ else if (code === 'CESS' && calcMethod === 'PERCENT') {
356
+ rates.cessRate = (0, math_operations_1.Add)(rates.cessRate, tr_utils_1.TrUtils.SetValueToZeroIfNull(tax === null || tax === void 0 ? void 0 : tax.Rate));
357
+ }
358
+ else if (code === 'CESS' && calcMethod === 'PERUNIT') {
359
+ rates.cessPerUnit = (0, math_operations_1.Add)(rates.cessPerUnit, tr_utils_1.TrUtils.SetValueToZeroIfNull(tax === null || tax === void 0 ? void 0 : tax.PerUnitAmt));
360
+ }
361
+ return rates;
362
+ }, { gstRate: 0, cessRate: 0, cessPerUnit: 0 });
363
+ const taxNames = [];
364
+ if (!tr_utils_1.TrUtils.IsZero(taxRates.gstRate)) {
365
+ taxNames.push(tr_utils_1.TrUtils.FixedTo(taxRates.gstRate) + '%');
366
+ }
367
+ if (!tr_utils_1.TrUtils.IsZero(taxRates.cessRate)) {
368
+ taxNames.push(tr_utils_1.TrUtils.FixedTo(taxRates.cessRate) + '% CESS');
369
+ }
370
+ if (!tr_utils_1.TrUtils.IsZero(taxRates.cessPerUnit)) {
371
+ taxNames.push(tr_utils_1.TrUtils.FixPriceValue(taxRates.cessPerUnit) + ' CESS Per Unit');
372
+ }
373
+ return taxNames.join(' + ');
374
+ }
375
+ return '';
376
+ }
343
377
  function CalculateTaxSummary(items, taxCodes) {
344
378
  return Object.values(items.reduce((acc, item) => {
345
379
  const taxes = getResolvedTaxes(item, taxCodes);
346
380
  if (taxes.length === 0)
347
381
  return acc;
348
- const percent = (taxes.reduce((sum, tax) => (0, math_operations_1.Add)(sum, (0, util_1.GetNumber)(tax.Rate)), 0) + "%");
382
+ // const percent = (taxes.reduce((sum: number, tax: any) => Add(sum, GetNumber(tax.Rate)), 0) + "%");
383
+ const percent = getTaxName(taxes);
349
384
  const taxable = getLineNetAmount(item);
350
385
  const cgstAmount = getTaxAmountByCode(taxes, "CGST");
351
386
  const sgstAmount = getTaxAmountByCode(taxes, "SGST");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.7.344",
3
+ "version": "1.7.346",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -335,6 +335,7 @@ export class InvoiceTotalsService {
335
335
  finalTotalsData.CustPartCGST = TrUtils.SetValueToZeroIfNull(PartTaxInfo[0]);
336
336
  finalTotalsData.CustPartIGST = TrUtils.SetValueToZeroIfNull(PartTaxInfo[2]);
337
337
  finalTotalsData.CustPartSGST = TrUtils.SetValueToZeroIfNull(PartTaxInfo[1]);
338
+ finalTotalsData.CustPartCESS = TrUtils.SetValueToZeroIfNull(PartTaxInfo[3]);
338
339
 
339
340
  finalTotalsData.CustLaborAfterTax = Add(finalTotalsData.CustLaborITax, finalTotalsData.CustLaborTotalAfterDisc);
340
341
  finalTotalsData.CustPartAfterTax = Add(finalTotalsData.CustPartITax, finalTotalsData.CustPartsTotalAfterDisc);
@@ -573,9 +574,9 @@ export class InvoiceTotalsService {
573
574
  if (IsIndependentTax) {
574
575
  PartsList.forEach((Part: any) => {
575
576
  if (Part.Ret === true) {
576
- RetTotalTaxAmt = Add(RetTotalTaxAmt, Part.CGST, Part.SGST, Part.IGST);
577
+ RetTotalTaxAmt = Add(RetTotalTaxAmt, Part.CGST, Part.SGST, Part.IGST, Part.CESS);
577
578
  } else {
578
- TotalTaxAmt = Add(TotalTaxAmt, Part.CGST, Part.SGST, Part.IGST);
579
+ TotalTaxAmt = Add(TotalTaxAmt, Part.CGST, Part.SGST, Part.IGST, Part.CESS);
579
580
  }
580
581
  });
581
582
  }
@@ -587,7 +588,7 @@ export class InvoiceTotalsService {
587
588
  if (IsIndependentTax) {
588
589
  PartsList.forEach((Part: any) => {
589
590
  if (Part.Ret === true) {
590
- RetTotalTaxAmt = Add(RetTotalTaxAmt, Part.CGST, Part.SGST, Part.IGST);
591
+ RetTotalTaxAmt = Add(RetTotalTaxAmt, Part.CGST, Part.SGST, Part.IGST, Part.CESS);
591
592
  }
592
593
  });
593
594
  }
@@ -599,7 +600,7 @@ export class InvoiceTotalsService {
599
600
  if (IsIndependentTax) {
600
601
  PartsList.forEach((Part: any) => {
601
602
  if (TrUtils.IsNull(Part.Ret) || Part.Ret === false) {
602
- NonRetTotalTaxAmt = Add(NonRetTotalTaxAmt, Part.CGST, Part.SGST, Part.IGST);
603
+ NonRetTotalTaxAmt = Add(NonRetTotalTaxAmt, Part.CGST, Part.SGST, Part.IGST, Part.CESS);
603
604
  }
604
605
  });
605
606
  }
@@ -694,20 +695,24 @@ export class InvoiceTotalsService {
694
695
  let TotalIGSTAmt: number = 0;
695
696
  let TotalSGSTAmt: number = 0;
696
697
  let RetTotalSGSTAmt: number = 0;
698
+ let TotalCESSAmt: number = 0;
699
+ let RetTotalCESSAmt: number = 0;
697
700
  if (IsIndependentTax) {
698
701
  PartsList.forEach((Part: any) => {
699
702
  if (Part.Ret === true) {
700
703
  RetTotalCGSTAmt = Add(RetTotalCGSTAmt, Part.CGST);
701
704
  RetTotalSGSTAmt = Add(RetTotalSGSTAmt, Part.SGST);
702
705
  RetTotalIGSTAmt = Add(RetTotalIGSTAmt, Part.IGST);
706
+ RetTotalCESSAmt = Add(RetTotalCESSAmt, Part.CESS);
703
707
  } else {
704
708
  TotalCGSTAmt = Add(TotalCGSTAmt, Part.CGST);
705
709
  TotalSGSTAmt = Add(TotalSGSTAmt, Part.SGST);
706
710
  TotalIGSTAmt = Add(TotalIGSTAmt, Part.IGST);
711
+ TotalCESSAmt = Add(TotalCESSAmt, Part.CESS);
707
712
  }
708
713
  });
709
714
  }
710
- return [TotalCGSTAmt, TotalSGSTAmt, TotalIGSTAmt];
715
+ return [TotalCGSTAmt, TotalSGSTAmt, TotalIGSTAmt, TotalCESSAmt, RetTotalCGSTAmt];
711
716
  }
712
717
 
713
718
  static GetTaxGroupingForPartsByHSN(Parts: any, TaxCodes: any, DecimalsNumber: any) {
@@ -693,7 +693,7 @@ function resolveTotals(invoiceData: any, totalTax: number, printConfigData: any
693
693
  ? itemsDiscount + servicesDiscount + overallDiscount
694
694
  : readNumericValue(invoiceData, ['Disc', 'Discount', 'TotDisc']);
695
695
  const roundOff = readNumericValue(invoiceData, ['Round', 'RoundOff']);
696
- const taxFromInvoice = readNumericValue(invoiceData, ['TotalTax', 'TaxTotal', 'TaxAmt', 'GSTTotal', 'CustItemITax']);
696
+ const taxFromInvoice = readNumericValue(invoiceData, ['TotalTax', 'TaxTotal', 'TaxAmt', 'GSTTotal', 'CustItemITax', 'CustPartITax']);
697
697
  const totalTaxValue = taxFromInvoice !== 0 ? taxFromInvoice : totalTax;
698
698
  const returnTotal = firstValue(invoiceData?.RetTotal);
699
699
  const finalTotalRaw = firstValue(invoiceData?.FinalTotal, invoiceData?.Total, invoiceData?.GrandTotal, invoiceData?.NetTotal);
@@ -40,14 +40,12 @@ export function GetInvoicePDF(invoiceData: any, entityData: any, headerConfig: a
40
40
  if (options.ConsolidateGST) {
41
41
  invPrint = GetInvoicePrint(invoicePrintData, numberofCopies, withPass, options.Size, options.MoreDiscDetails, options.Orientation);
42
42
  } else {
43
- console.log("options", options);
44
43
  if(options.PartInvoice && options.LaborInvoice){
45
44
  invoicePrintData.Round = TrUtils.FixedTo(invoiceData.Round);
46
45
  invoicePrintData.Total = TrUtils.FixedTo(invoiceData.Total);
47
46
  invoicePrintData.SubToal = TrUtils.FixedTo(invoiceData.SubToal);
48
47
  invoicePrintData.TaxTotal = TrUtils.FixedTo(invoiceData.TaxTotal);
49
48
  }
50
- console.log("invoicePrintData", invoicePrintData);
51
49
  delete invoicePrintData.SIndTotal;
52
50
  invPrint = CreateInvoicePDFService(invoicePrintData, printConfigData, numberofCopies);
53
51
  }
@@ -1,5 +1,6 @@
1
1
  import { Add, Divide, Multiply, Subtract } from "../shared/math-operations";
2
2
  import { GetNumber } from "../shared/util";
3
+ import { TrUtils } from "../utils/tr-utils";
3
4
 
4
5
  /**
5
6
  * Safely handles null/undefined arrays and returns empty array
@@ -427,13 +428,54 @@ export function TotalCalculationsWithDecimals(
427
428
  return roundedResult;
428
429
  }
429
430
 
431
+ export function getTaxName(taxes: any): string {
432
+ if (Array.isArray(taxes) && taxes.length > 0) {
433
+ const taxRates = taxes.reduce(
434
+ (rates: any, tax: any) => {
435
+ const code = tax?.Code?.toString().trim().toUpperCase();
436
+ const rawCalcMethod = tax?.CalcMethod?.toString().trim().toUpperCase();
437
+ const calcMethod = !rawCalcMethod || rawCalcMethod === 'PERCENTAGE' ? 'PERCENT' : rawCalcMethod;
438
+
439
+ if (['CGST', 'SGST', 'IGST'].includes(code)) {
440
+ rates.gstRate = Add(rates.gstRate, TrUtils.SetValueToZeroIfNull(tax?.Rate));
441
+ } else if (code === 'CESS' && calcMethod === 'PERCENT') {
442
+ rates.cessRate = Add(rates.cessRate, TrUtils.SetValueToZeroIfNull(tax?.Rate));
443
+ } else if (code === 'CESS' && calcMethod === 'PERUNIT') {
444
+ rates.cessPerUnit = Add(
445
+ rates.cessPerUnit,
446
+ TrUtils.SetValueToZeroIfNull(tax?.PerUnitAmt),
447
+ );
448
+ }
449
+
450
+ return rates;
451
+ },
452
+ { gstRate: 0, cessRate: 0, cessPerUnit: 0 },
453
+ );
454
+
455
+ const taxNames: string[] = [];
456
+ if (!TrUtils.IsZero(taxRates.gstRate)) {
457
+ taxNames.push(TrUtils.FixedTo(taxRates.gstRate) + '%');
458
+ }
459
+ if (!TrUtils.IsZero(taxRates.cessRate)) {
460
+ taxNames.push(TrUtils.FixedTo(taxRates.cessRate) + '% CESS');
461
+ }
462
+ if (!TrUtils.IsZero(taxRates.cessPerUnit)) {
463
+ taxNames.push(TrUtils.FixPriceValue(taxRates.cessPerUnit) + ' CESS Per Unit');
464
+ }
465
+
466
+ return taxNames.join(' + ');
467
+ }
468
+ return '';
469
+ }
470
+
430
471
  export function CalculateTaxSummary(items: any[], taxCodes: any[]) {
431
472
  return Object.values(
432
473
  items.reduce((acc: any, item: any) => {
433
474
  const taxes = getResolvedTaxes(item, taxCodes);
434
475
  if (taxes.length === 0) return acc;
435
476
 
436
- const percent = (taxes.reduce((sum: number, tax: any) => Add(sum, GetNumber(tax.Rate)), 0) + "%");
477
+ // const percent = (taxes.reduce((sum: number, tax: any) => Add(sum, GetNumber(tax.Rate)), 0) + "%");
478
+ const percent = getTaxName(taxes);
437
479
  const taxable = getLineNetAmount(item);
438
480
  const cgstAmount = getTaxAmountByCode(taxes, "CGST");
439
481
  const sgstAmount = getTaxAmountByCode(taxes, "SGST");