@softwear/latestcollectioncore 1.0.144 → 1.0.145

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.
@@ -77,14 +77,6 @@ function addTransactionToAggregations(beginTimestamp, endTimestamp, aggregateKey
77
77
  return;
78
78
  // Period transactions: add everything from BEGIN_STOCK_VECTOR_END onwards
79
79
  addVectors(aggregateVector, v, BEGIN_STOCK_VECTOR_END, v.length);
80
- // Also update QTY_SHELF_STOCK and AMOUNT_SHELF_STOCK from period transactions
81
- // (they're in the begin stock range but need to be updated by period transactions too)
82
- if (v[QTY_SHELF_STOCK] !== undefined) {
83
- aggregateVector[QTY_SHELF_STOCK] += v[QTY_SHELF_STOCK] || 0;
84
- }
85
- if (v[AMOUNT_SHELF_STOCK] !== undefined) {
86
- aggregateVector[AMOUNT_SHELF_STOCK] += v[AMOUNT_SHELF_STOCK] || 0;
87
- }
88
80
  // Calculate derived fields
89
81
  aggregateVector[QTY_RETURN] += v[QTY_SOLD] < 0 ? v[QTY_SOLD] : 0;
90
82
  aggregateVector[AMOUNT_RETURN] += v[AMOUNT_SOLD_EXCL] < 0 ? v[AMOUNT_SOLD_EXCL] : 0;
@@ -266,11 +258,9 @@ function postAgg(v, timeFrame) {
266
258
  // QTY_SHELF_STOCK includes:
267
259
  // - beginStock from type 0 (same as QTY_STOCK)
268
260
  // - beginShelfStock adjustment from type 10 (negative picktickets from previous shards)
269
- // - shelfStock-affecting transactions during the period (type 1, type 2, etc.)
270
- // So QTY_SHELF_STOCK already represents the shelfStock value including all transactions
271
- // endShelfStock = QTY_SHELF_STOCK - consignment - picklist
272
- v[QTY_END_SHELF_STOCK] = v[QTY_SHELF_STOCK] - v[QTY_CONSIGNMENT] - v[QTY_PICKLIST];
273
- v[AMOUNT_END_SHELF_STOCK] = v[AMOUNT_SHELF_STOCK] - v[COSTPRICE_CONSIGNMENT] - v[AMOUNT_PICKLIST];
261
+ v[QTY_END_SHELF_STOCK] = v[QTY_SHELF_STOCK] + v[QTY_RECIEVED] + v[QTY_CHANGE] + v[QTY_TRANSIT] - totalQtySold - v[QTY_CONSIGNMENT] - v[QTY_PICKLIST];
262
+ v[AMOUNT_END_SHELF_STOCK] =
263
+ v[AMOUNT_SHELF_STOCK] + v[AMOUNT_RECIEVED] + v[AMOUNT_CHANGE] + v[AMOUNT_TRANSIT] + v[AMOUNT_REVALUATE] - totalCostSold - v[AMOUNT_CONSIGNMENT] - v[AMOUNT_PICKLIST];
274
264
  v[SELLOUT_PERCENTAGE] = (totalQtySold / (totalQtySold + v[QTY_END_STOCK])) * 100;
275
265
  v[ROI] = totalAmountSold - v[AMOUNT_RECIEVED] + v[AMOUNT_TRANSIT];
276
266
  v[QTY_AVG_STOCK] = (v[QTY_STOCK] * timeFrame + v[STOCK_TIME_PRODUCT]) / timeFrame;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softwear/latestcollectioncore",
3
- "version": "1.0.144",
3
+ "version": "1.0.145",
4
4
  "description": "Core functions for LatestCollections applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -139,14 +139,6 @@ function addTransactionToAggregations(beginTimestamp: number, endTimestamp: numb
139
139
  if (transaction.time > endTimestamp) return
140
140
  // Period transactions: add everything from BEGIN_STOCK_VECTOR_END onwards
141
141
  addVectors(aggregateVector, v, BEGIN_STOCK_VECTOR_END, v.length)
142
- // Also update QTY_SHELF_STOCK and AMOUNT_SHELF_STOCK from period transactions
143
- // (they're in the begin stock range but need to be updated by period transactions too)
144
- if (v[QTY_SHELF_STOCK] !== undefined) {
145
- aggregateVector[QTY_SHELF_STOCK] += v[QTY_SHELF_STOCK] || 0
146
- }
147
- if (v[AMOUNT_SHELF_STOCK] !== undefined) {
148
- aggregateVector[AMOUNT_SHELF_STOCK] += v[AMOUNT_SHELF_STOCK] || 0
149
- }
150
142
 
151
143
  // Calculate derived fields
152
144
 
@@ -348,11 +340,9 @@ function postAgg(v: any, timeFrame: number): void {
348
340
  // QTY_SHELF_STOCK includes:
349
341
  // - beginStock from type 0 (same as QTY_STOCK)
350
342
  // - beginShelfStock adjustment from type 10 (negative picktickets from previous shards)
351
- // - shelfStock-affecting transactions during the period (type 1, type 2, etc.)
352
- // So QTY_SHELF_STOCK already represents the shelfStock value including all transactions
353
- // endShelfStock = QTY_SHELF_STOCK - consignment - picklist
354
- v[QTY_END_SHELF_STOCK] = v[QTY_SHELF_STOCK] - v[QTY_CONSIGNMENT] - v[QTY_PICKLIST]
355
- v[AMOUNT_END_SHELF_STOCK] = v[AMOUNT_SHELF_STOCK] - v[COSTPRICE_CONSIGNMENT] - v[AMOUNT_PICKLIST]
343
+ v[QTY_END_SHELF_STOCK] = v[QTY_SHELF_STOCK] + v[QTY_RECIEVED] + v[QTY_CHANGE] + v[QTY_TRANSIT] - totalQtySold - v[QTY_CONSIGNMENT] - v[QTY_PICKLIST]
344
+ v[AMOUNT_END_SHELF_STOCK] =
345
+ v[AMOUNT_SHELF_STOCK] + v[AMOUNT_RECIEVED] + v[AMOUNT_CHANGE] + v[AMOUNT_TRANSIT] + v[AMOUNT_REVALUATE] - totalCostSold - v[AMOUNT_CONSIGNMENT] - v[AMOUNT_PICKLIST]
356
346
  v[SELLOUT_PERCENTAGE] = (totalQtySold / (totalQtySold + v[QTY_END_STOCK])) * 100
357
347
  v[ROI] = totalAmountSold - v[AMOUNT_RECIEVED] + v[AMOUNT_TRANSIT]
358
348
  v[QTY_AVG_STOCK] = (v[QTY_STOCK] * timeFrame + v[STOCK_TIME_PRODUCT]) / timeFrame
@@ -361,12 +361,12 @@ describe('articleStatus', () => {
361
361
  expect(testResult.vector[articleStatus.QTY_STOCK]).toBe(100)
362
362
  expect(testResult.vector[articleStatus.AMOUNT_STOCK]).toBe(1000)
363
363
 
364
- // QTY_SHELF_STOCK includes beginShelfStock (100 - 5 = 95) + period transactions (20 - 2 = 18) = 113
364
+ // QTY_SHELF_STOCK includes beginShelfStock (100 - 5 = 95)
365
365
  // beginShelfStock from beginTimestamp: 100 (type 0) - 5 (type 10) = 95
366
366
  // Period transactions: +20 (receiving) - 2 (sale) = +18
367
367
  // Total: 95 + 18 = 113
368
- expect(testResult.vector[articleStatus.QTY_SHELF_STOCK]).toBe(113)
369
- expect(testResult.vector[articleStatus.AMOUNT_SHELF_STOCK]).toBe(1130)
368
+ expect(testResult.vector[articleStatus.QTY_SHELF_STOCK]).toBe(95)
369
+ expect(testResult.vector[articleStatus.AMOUNT_SHELF_STOCK]).toBe(950)
370
370
 
371
371
  // Transactions during period: +20 (receiving) - 2 (sale) = +18
372
372
  // endStock: 100 + 20 - 2 = 118