shareneus 1.7.339 → 1.7.340

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.
@@ -186,12 +186,15 @@ class TransactionCalculationEngine {
186
186
  includeTaxInTotal: input.includeTaxInTotal,
187
187
  qty,
188
188
  });
189
+ console.log('Subtotal from total using taxes', subtotal);
189
190
  const disc = toNum(input.disc);
190
191
  const recDisc = toNum(input.recDisc);
192
+ console.log('Discounts', { disc, recDisc });
191
193
  const amount = input.noDisc
192
194
  ? subtotal
193
195
  : (0, math_operations_1.Add)(subtotal, (0, math_operations_1.Add)(disc, recDisc));
194
196
  const unitPrice = (0, math_operations_1.Divide)(amount, qty);
197
+ console.log('Reverse calculated amount and unit price', { amount, unitPrice });
195
198
  return { amount, unitPrice };
196
199
  }
197
200
  // Shared reverse-calculation formula. Components only need to supply their own field mapping.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.7.339",
3
+ "version": "1.7.340",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -106,7 +106,7 @@ function getReverseTaxBreakdown(taxes: any, qty: number): {
106
106
  (summary, row) => {
107
107
  const calcMethod = normalizeCalcMethod(row?.CalcMethod ?? row?.calcMethod);
108
108
  const rate = toNum(row?.Rate ?? row?.rate);
109
- console.log('Reverse tax row', { row, calcMethod, rate, qty });
109
+ console.log('Reverse tax row', { row, calcMethod, rate, qty });
110
110
  switch (calcMethod) {
111
111
  case 'PerUnit':
112
112
  summary.fixedTaxAmount = Add(
@@ -271,14 +271,15 @@ export class TransactionCalculationEngine {
271
271
  includeTaxInTotal: input.includeTaxInTotal,
272
272
  qty,
273
273
  });
274
-
274
+ console.log('Subtotal from total using taxes', subtotal);
275
275
  const disc = toNum(input.disc);
276
276
  const recDisc = toNum(input.recDisc);
277
+ console.log('Discounts', { disc, recDisc });
277
278
  const amount = input.noDisc
278
279
  ? subtotal
279
280
  : Add(subtotal, Add(disc, recDisc));
280
281
  const unitPrice = Divide(amount, qty);
281
-
282
+ console.log('Reverse calculated amount and unit price', { amount, unitPrice });
282
283
  return { amount, unitPrice };
283
284
  }
284
285
 
@@ -314,7 +315,7 @@ export class TransactionCalculationEngine {
314
315
  ? taxCode.Components
315
316
  : [];
316
317
 
317
- return components.reduce((sum:number, comp: any) => Add(sum, toNum(comp?.Rate)), 0);
318
+ return components.reduce((sum: number, comp: any) => Add(sum, toNum(comp?.Rate)), 0);
318
319
  }
319
320
 
320
321
  // -------------------------------------------------------------------------
@@ -558,11 +559,11 @@ export class TransactionCalculationEngine {
558
559
  // If total doesn't include tax, treat it as "already stripped".
559
560
  const subtotal = includeTaxInTotal
560
561
  ? TransactionCalculationEngine.calculateSubtotalFromTotalUsingTaxes({
561
- total,
562
- taxRows: item?.Taxes ?? item?.taxes,
563
- includeTaxInTotal,
564
- qty,
565
- })
562
+ total,
563
+ taxRows: item?.Taxes ?? item?.taxes,
564
+ includeTaxInTotal,
565
+ qty,
566
+ })
566
567
  : total;
567
568
 
568
569
  if (item.NoDisc) {