shareneus 1.7.345 → 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.
@@ -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.345",
3
+ "version": "1.7.346",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -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");