shareneus 1.5.13 → 1.5.15

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.
@@ -1,6 +1,6 @@
1
- export declare function SalesTotalCalculations(items?: any[], ops?: any[], isTaxable?: boolean, taxCodes?: any[]): any;
1
+ export declare function SalesTotalCalculations(items?: any[], ops?: any[], isTaxable?: boolean, taxCodes?: any[], Adjust?: number): any;
2
2
  /**
3
3
  * Enhanced version with decimal places control
4
4
  */
5
- export declare function SalesTotalCalculationsWithDecimals(items?: any[], ops?: any[], isTaxable?: boolean, taxCodes?: any[], decimalPlaces?: number): any;
5
+ export declare function SalesTotalCalculationsWithDecimals(items: any[] | undefined, ops: any[] | undefined, isTaxable: boolean | undefined, taxCodes: any[] | undefined, Adjust: number, decimalPlaces?: number): any;
6
6
  export declare function CalculateTaxSummary(items: any[], taxCodes: any[]): unknown[];
@@ -11,7 +11,7 @@ const util_1 = require("../shared/util");
11
11
  function safeArray(arr) {
12
12
  return Array.isArray(arr) ? arr : [];
13
13
  }
14
- function SalesTotalCalculations(items = [], ops = [], isTaxable = false, taxCodes = []) {
14
+ function SalesTotalCalculations(items = [], ops = [], isTaxable = false, taxCodes = [], Adjust = 0) {
15
15
  // Handle null/undefined arrays
16
16
  const safeItems = safeArray(items);
17
17
  const safeOps = safeArray(ops);
@@ -92,6 +92,7 @@ function SalesTotalCalculations(items = [], ops = [], isTaxable = false, taxCode
92
92
  const netAmountAfterDiscount = (0, math_operations_1.Subtract)(subtotal, totalDiscount);
93
93
  // Step 2: Add tax if taxable
94
94
  total = isTaxable ? (0, math_operations_1.Add)(netAmountAfterDiscount, totalTax) : netAmountAfterDiscount;
95
+ total = (0, math_operations_1.Add)(total, (0, util_1.GetNumber)(Adjust));
95
96
  // FIXED ROUNDING: Use Math.round instead of Math.floor
96
97
  const roundedTotal = Math.round(total);
97
98
  roundOff = (0, math_operations_1.Subtract)(roundedTotal, total);
@@ -133,8 +134,8 @@ function SalesTotalCalculations(items = [], ops = [], isTaxable = false, taxCode
133
134
  /**
134
135
  * Enhanced version with decimal places control
135
136
  */
136
- function SalesTotalCalculationsWithDecimals(items = [], ops = [], isTaxable = false, taxCodes = [], decimalPlaces = 2) {
137
- const result = SalesTotalCalculations(items, ops, isTaxable, taxCodes);
137
+ function SalesTotalCalculationsWithDecimals(items = [], ops = [], isTaxable = false, taxCodes = [], Adjust, decimalPlaces = 2) {
138
+ const result = SalesTotalCalculations(items, ops, isTaxable, taxCodes, Adjust);
138
139
  // Round all values to specified decimal places
139
140
  const roundToDecimals = (num) => Math.round(num * Math.pow(10, decimalPlaces)) / Math.pow(10, decimalPlaces);
140
141
  // Base rounded result
@@ -183,7 +184,7 @@ function CalculateTaxSummary(items, taxCodes) {
183
184
  return acc;
184
185
  const percent = (((tax.IGST || 0) + (tax.CGST || 0) + (tax.SGST || 0)) + "%");
185
186
  // taxable value after discounts
186
- const taxable = (0, math_operations_1.Subtract)((0, util_1.GetNumber)(item.UnAmt), (0, math_operations_1.Add)((0, util_1.GetNumber)(item.Disc), (0, util_1.GetNumber)(item.RecDisc)));
187
+ const taxable = (0, math_operations_1.Subtract)((0, util_1.GetNumber)(item.UnAmt || item.Amt), (0, math_operations_1.Add)((0, util_1.GetNumber)(item.Disc), (0, util_1.GetNumber)(item.RecDisc)));
187
188
  if (!acc[percent]) {
188
189
  acc[percent] = {
189
190
  Tax: percent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.5.13",
3
+ "version": "1.5.15",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",