@softwear/latestcollectioncore 1.0.143 → 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.
- package/dist/articleStatus.js +3 -13
- package/dist/hashBrand.js +1 -1
- package/package.json +1 -1
- package/src/articleStatus.ts +3 -13
- package/src/hashBrand.ts +1 -1
- package/test/articleStatus.spec.js +3 -3
package/dist/articleStatus.js
CHANGED
|
@@ -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
|
-
|
|
270
|
-
|
|
271
|
-
|
|
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/dist/hashBrand.js
CHANGED
|
@@ -5,7 +5,7 @@ const DIACRITIC_REGEX = /[\u0300-\u036f]/g;
|
|
|
5
5
|
// '~.<>!@#$%^&*():'"? /-\\'
|
|
6
6
|
// Note: '-' is placed at the end of the class so it is treated literally,
|
|
7
7
|
// and '\' is escaped.
|
|
8
|
-
const REMOVE_CHARS_TEST_REGEX = /[~.<>!@#$%^&*()
|
|
8
|
+
const REMOVE_CHARS_TEST_REGEX = /[~.<>!@#$%^&*():´'"? \/\\-]/;
|
|
9
9
|
const REMOVE_CHARS_REGEX = /[~.<>!@#$%^&*():´'"? \/\\-]/g;
|
|
10
10
|
// Fast check: returns true if the string contains any non-ASCII character,
|
|
11
11
|
// which we treat as a potential diacritic and normalize only in that case.
|
package/package.json
CHANGED
package/src/articleStatus.ts
CHANGED
|
@@ -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
|
-
|
|
352
|
-
|
|
353
|
-
|
|
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
|
package/src/hashBrand.ts
CHANGED
|
@@ -3,7 +3,7 @@ const DIACRITIC_REGEX = /[\u0300-\u036f]/g
|
|
|
3
3
|
// '~.<>!@#$%^&*():'"? /-\\'
|
|
4
4
|
// Note: '-' is placed at the end of the class so it is treated literally,
|
|
5
5
|
// and '\' is escaped.
|
|
6
|
-
const REMOVE_CHARS_TEST_REGEX = /[~.<>!@#$%^&*()
|
|
6
|
+
const REMOVE_CHARS_TEST_REGEX = /[~.<>!@#$%^&*():´'"? \/\\-]/
|
|
7
7
|
const REMOVE_CHARS_REGEX = /[~.<>!@#$%^&*():´'"? \/\\-]/g
|
|
8
8
|
|
|
9
9
|
// Fast check: returns true if the string contains any non-ASCII character,
|
|
@@ -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)
|
|
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(
|
|
369
|
-
expect(testResult.vector[articleStatus.AMOUNT_SHELF_STOCK]).toBe(
|
|
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
|