@softwear/latestcollectioncore 1.0.201 → 1.0.203

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.
@@ -33,7 +33,7 @@ function resolvePath(obj, path) {
33
33
  return path.reduce((o, key) => o === null || o === void 0 ? void 0 : o[key], obj);
34
34
  }
35
35
  function propFunction(propertyName, getPropertyName, obj) {
36
- var _a, _b;
36
+ var _a;
37
37
  const positionOfDot = propertyName.indexOf('.');
38
38
  if (positionOfDot < 0)
39
39
  return obj[propertyName];
@@ -42,7 +42,7 @@ function propFunction(propertyName, getPropertyName, obj) {
42
42
  if (table == 'transaction')
43
43
  return resolvePath(obj, path);
44
44
  const joinedRecord = (_a = globalRelations[table]) === null || _a === void 0 ? void 0 : _a[obj[globalJoinableTables[table]]];
45
- return (_b = resolvePath(joinedRecord, path)) !== null && _b !== void 0 ? _b : '~ ?';
45
+ return resolvePath(joinedRecord, path) || '~ ?';
46
46
  }
47
47
  const lower = (s) => s.toLowerCase();
48
48
  const upper = (s) => s.toUpperCase();
@@ -86,18 +86,9 @@ function addTransactionToAggregations(beginTimestamp, endTimestamp, aggregateKey
86
86
  // Calculate derived fields
87
87
  aggregateVector[QTY_RETURN] += v[QTY_SOLD] < 0 ? v[QTY_SOLD] : 0;
88
88
  aggregateVector[AMOUNT_RETURN] += v[AMOUNT_SOLD_EXCL] < 0 ? v[AMOUNT_SOLD_EXCL] : 0;
89
- aggregateVector[STOCK_TIME_PRODUCT] +=
90
- ((v[QTY_RECIEVED] || 0) + (v[QTY_TRANSIT] || 0) + (v[QTY_CHANGE] || 0) - (v[QTY_SOLD] || 0) - (v[QTY_B2B_SOLD] || 0) - (v[QTY_B2B_RESOLD] || 0) + (v[QTY_B2B_RETURN] || 0)) *
91
- (endTimestamp - transaction.time);
89
+ aggregateVector[STOCK_TIME_PRODUCT] += ((v[QTY_RECIEVED] || 0) + (v[QTY_TRANSIT] || 0) + (v[QTY_CHANGE] || 0) - (v[QTY_SOLD] || 0) - (v[QTY_B2B_SOLD] || 0) - (v[QTY_B2B_RESOLD] || 0) + (v[QTY_B2B_RETURN] || 0)) * (endTimestamp - transaction.time);
92
90
  aggregateVector[STOCKAMOUNT_TIME_PRODUCT] +=
93
- ((v[AMOUNT_RECIEVED] || 0) +
94
- (v[AMOUNT_TRANSIT] || 0) +
95
- (v[AMOUNT_CHANGE] || 0) -
96
- (v[COSTPRICE_SOLD] || 0) -
97
- (v[COSTPRICE_B2B_SOLD] || 0) -
98
- (v[COSTPRICE_B2B_RESOLD] || 0) +
99
- (v[COSTPRICE_B2B_RETURN] || 0)) *
100
- (endTimestamp - transaction.time);
91
+ ((v[AMOUNT_RECIEVED] || 0) + (v[AMOUNT_TRANSIT] || 0) + (v[AMOUNT_CHANGE] || 0) - (v[COSTPRICE_SOLD] || 0) - (v[COSTPRICE_B2B_SOLD] || 0) - (v[COSTPRICE_B2B_RESOLD] || 0) + (v[COSTPRICE_B2B_RETURN] || 0)) * (endTimestamp - transaction.time);
101
92
  }
102
93
  function buildAggregationEvaluator(aggregationExpression) {
103
94
  return (0, filtrex_1.compileExpression)(aggregationExpression, filtrexOptions);
@@ -149,7 +140,7 @@ function getTrieLeaf(root, transaction, keys) {
149
140
  *
150
141
  * @returns {Function} - The aggregator function
151
142
  */
152
- function aggregator({ beginTimestamp, endTimestamp, filterExpression, aggregationExpression, rawAggregations, maxRows, totals, subtotalsForOuterGrouper, parentGroupTotals, }) {
143
+ function aggregator({ beginTimestamp, endTimestamp, filterExpression, aggregationExpression, rawAggregations, maxRows, totals, subtotalsForOuterGrouper, parentGroupTotals }) {
153
144
  let filter;
154
145
  let filterGranularity = [];
155
146
  const filterTrieRoot = {};
@@ -219,7 +210,7 @@ function aggregator({ beginTimestamp, endTimestamp, filterExpression, aggregatio
219
210
  }
220
211
  };
221
212
  }
222
- function aggregate({ beginTimestamp, endTimestamp, filterExpression, aggregationExpression, transactions, beginStock, relations, rawAggregations, maxRows, totals, subtotalsForOuterGrouper, parentGroupTotals, }) {
213
+ function aggregate({ beginTimestamp, endTimestamp, filterExpression, aggregationExpression, transactions, beginStock, relations, rawAggregations, maxRows, totals, subtotalsForOuterGrouper, parentGroupTotals }) {
223
214
  globalNrAggegationExpressions = 0;
224
215
  globalRelations = relations;
225
216
  const compiledAggregator = aggregator({
@@ -290,8 +281,7 @@ function postAgg(v, timeFrame) {
290
281
  // - beginStock from type 0 (same as QTY_STOCK)
291
282
  // - beginShelfStock adjustment from type 10 (negative picktickets from previous shards)
292
283
  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];
293
- v[AMOUNT_END_SHELF_STOCK] =
294
- v[AMOUNT_SHELF_STOCK] + v[AMOUNT_RECIEVED] + v[AMOUNT_CHANGE] + v[AMOUNT_TRANSIT] + v[AMOUNT_REVALUATE] - totalCostSold - v[AMOUNT_CONSIGNMENT] - v[AMOUNT_PICKLIST];
284
+ v[AMOUNT_END_SHELF_STOCK] = v[AMOUNT_SHELF_STOCK] + v[AMOUNT_RECIEVED] + v[AMOUNT_CHANGE] + v[AMOUNT_TRANSIT] + v[AMOUNT_REVALUATE] - totalCostSold - v[AMOUNT_CONSIGNMENT] - v[AMOUNT_PICKLIST];
295
285
  v[SELLOUT_PERCENTAGE] = (totalQtySold / (totalQtySold + v[QTY_END_STOCK])) * 100;
296
286
  v[ROI] = totalAmountSold - v[AMOUNT_RECIEVED] + v[AMOUNT_TRANSIT];
297
287
  v[QTY_AVG_STOCK] = (v[QTY_STOCK] * timeFrame + v[STOCK_TIME_PRODUCT]) / timeFrame;
package/dist/types.d.ts CHANGED
@@ -129,6 +129,7 @@ interface SkuI {
129
129
  brandhash?: string;
130
130
  ATTRIBUTES?: object;
131
131
  IMAGES?: Array<ImageI>;
132
+ IMAGE_URLS?: Array<string>;
132
133
  SIZES?: unknown;
133
134
  FOOTPRINT?: number;
134
135
  /** UI-only clustering key for product tiles / matrices; not persisted. Phase 1 mirrors articleCodeSupplier after ensureImpliedProperties. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softwear/latestcollectioncore",
3
- "version": "1.0.201",
3
+ "version": "1.0.203",
4
4
  "description": "Core functions for LatestCollections applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -108,7 +108,7 @@ function propFunction(propertyName: string, getPropertyName: Function, obj: Reco
108
108
  const path = propertyName.substring(positionOfDot + 1).split('.')
109
109
  if (table == 'transaction') return resolvePath(obj, path)
110
110
  const joinedRecord = globalRelations[table]?.[obj[globalJoinableTables[table]]]
111
- return resolvePath(joinedRecord, path) ?? '~ ?'
111
+ return resolvePath(joinedRecord, path) || '~ ?'
112
112
  }
113
113
 
114
114
  const lower = (s: string) => s.toLowerCase()
@@ -153,18 +153,9 @@ function addTransactionToAggregations(beginTimestamp: number, endTimestamp: numb
153
153
  aggregateVector[QTY_RETURN] += v[QTY_SOLD] < 0 ? v[QTY_SOLD] : 0
154
154
  aggregateVector[AMOUNT_RETURN] += v[AMOUNT_SOLD_EXCL] < 0 ? v[AMOUNT_SOLD_EXCL] : 0
155
155
 
156
- aggregateVector[STOCK_TIME_PRODUCT] +=
157
- ((v[QTY_RECIEVED] || 0) + (v[QTY_TRANSIT] || 0) + (v[QTY_CHANGE] || 0) - (v[QTY_SOLD] || 0) - (v[QTY_B2B_SOLD] || 0) - (v[QTY_B2B_RESOLD] || 0) + (v[QTY_B2B_RETURN] || 0)) *
158
- (endTimestamp - transaction.time)
156
+ aggregateVector[STOCK_TIME_PRODUCT] += ((v[QTY_RECIEVED] || 0) + (v[QTY_TRANSIT] || 0) + (v[QTY_CHANGE] || 0) - (v[QTY_SOLD] || 0) - (v[QTY_B2B_SOLD] || 0) - (v[QTY_B2B_RESOLD] || 0) + (v[QTY_B2B_RETURN] || 0)) * (endTimestamp - transaction.time)
159
157
  aggregateVector[STOCKAMOUNT_TIME_PRODUCT] +=
160
- ((v[AMOUNT_RECIEVED] || 0) +
161
- (v[AMOUNT_TRANSIT] || 0) +
162
- (v[AMOUNT_CHANGE] || 0) -
163
- (v[COSTPRICE_SOLD] || 0) -
164
- (v[COSTPRICE_B2B_SOLD] || 0) -
165
- (v[COSTPRICE_B2B_RESOLD] || 0) +
166
- (v[COSTPRICE_B2B_RETURN] || 0)) *
167
- (endTimestamp - transaction.time)
158
+ ((v[AMOUNT_RECIEVED] || 0) + (v[AMOUNT_TRANSIT] || 0) + (v[AMOUNT_CHANGE] || 0) - (v[COSTPRICE_SOLD] || 0) - (v[COSTPRICE_B2B_SOLD] || 0) - (v[COSTPRICE_B2B_RESOLD] || 0) + (v[COSTPRICE_B2B_RETURN] || 0)) * (endTimestamp - transaction.time)
168
159
  }
169
160
 
170
161
  function buildAggregationEvaluator(aggregationExpression: string): Function {
@@ -222,17 +213,7 @@ function getTrieLeaf<T extends { children?: Map<unknown, T> }>(root: T, transact
222
213
  *
223
214
  * @returns {Function} - The aggregator function
224
215
  */
225
- function aggregator({
226
- beginTimestamp,
227
- endTimestamp,
228
- filterExpression,
229
- aggregationExpression,
230
- rawAggregations,
231
- maxRows,
232
- totals,
233
- subtotalsForOuterGrouper,
234
- parentGroupTotals,
235
- }: AggregatorFnI) {
216
+ function aggregator({ beginTimestamp, endTimestamp, filterExpression, aggregationExpression, rawAggregations, maxRows, totals, subtotalsForOuterGrouper, parentGroupTotals }: AggregatorFnI) {
236
217
  let filter: ((transaction: TransactionI) => unknown) | undefined
237
218
  let filterGranularity: string[] = []
238
219
  const filterTrieRoot: FilterResultTrieNode = {}
@@ -303,20 +284,7 @@ function aggregator({
303
284
  }
304
285
  }
305
286
 
306
- function aggregate({
307
- beginTimestamp,
308
- endTimestamp,
309
- filterExpression,
310
- aggregationExpression,
311
- transactions,
312
- beginStock,
313
- relations,
314
- rawAggregations,
315
- maxRows,
316
- totals,
317
- subtotalsForOuterGrouper,
318
- parentGroupTotals,
319
- }: AggregateFnI) {
287
+ function aggregate({ beginTimestamp, endTimestamp, filterExpression, aggregationExpression, transactions, beginStock, relations, rawAggregations, maxRows, totals, subtotalsForOuterGrouper, parentGroupTotals }: AggregateFnI) {
320
288
  globalNrAggegationExpressions = 0
321
289
  globalRelations = relations
322
290
 
@@ -353,8 +321,7 @@ function whichShardsToProcess(dateRange: any, granularity: 'year' | 'month'): an
353
321
  else
354
322
  for (let year = dateRange.utcFromYear; year <= dateRange.utcToYear; year++) {
355
323
  if (year == dateRange.utcFromYear && year < dateRange.utcToYear) for (let month = dateRange.utcFromMonth; month <= 12; month++) result.push('' + year + '' + padl(month))
356
- if (year == dateRange.utcFromYear && year == dateRange.utcToYear)
357
- for (let month = dateRange.utcFromMonth; month <= dateRange.utcToMonth; month++) result.push('' + year + '' + padl(month))
324
+ if (year == dateRange.utcFromYear && year == dateRange.utcToYear) for (let month = dateRange.utcFromMonth; month <= dateRange.utcToMonth; month++) result.push('' + year + '' + padl(month))
358
325
  if (year != dateRange.utcFromYear && year != dateRange.utcToYear) for (let month = 1; month <= 12; month++) result.push('' + year + '' + padl(month))
359
326
  if (year != dateRange.utcFromYear && year == dateRange.utcToYear) for (let month = 1; month <= dateRange.utcToMonth; month++) result.push('' + year + '' + padl(month))
360
327
  }
@@ -378,8 +345,7 @@ function postAgg(v: any, timeFrame: number): void {
378
345
  // - beginStock from type 0 (same as QTY_STOCK)
379
346
  // - beginShelfStock adjustment from type 10 (negative picktickets from previous shards)
380
347
  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]
381
- v[AMOUNT_END_SHELF_STOCK] =
382
- v[AMOUNT_SHELF_STOCK] + v[AMOUNT_RECIEVED] + v[AMOUNT_CHANGE] + v[AMOUNT_TRANSIT] + v[AMOUNT_REVALUATE] - totalCostSold - v[AMOUNT_CONSIGNMENT] - v[AMOUNT_PICKLIST]
348
+ v[AMOUNT_END_SHELF_STOCK] = v[AMOUNT_SHELF_STOCK] + v[AMOUNT_RECIEVED] + v[AMOUNT_CHANGE] + v[AMOUNT_TRANSIT] + v[AMOUNT_REVALUATE] - totalCostSold - v[AMOUNT_CONSIGNMENT] - v[AMOUNT_PICKLIST]
383
349
  v[SELLOUT_PERCENTAGE] = (totalQtySold / (totalQtySold + v[QTY_END_STOCK])) * 100
384
350
  v[ROI] = totalAmountSold - v[AMOUNT_RECIEVED] + v[AMOUNT_TRANSIT]
385
351
  v[QTY_AVG_STOCK] = (v[QTY_STOCK] * timeFrame + v[STOCK_TIME_PRODUCT]) / timeFrame
package/src/types.ts CHANGED
@@ -138,6 +138,7 @@ interface SkuI {
138
138
  brandhash?: string
139
139
  ATTRIBUTES?: object
140
140
  IMAGES?: Array<ImageI>
141
+ IMAGE_URLS?: Array<string>
141
142
  SIZES?: unknown
142
143
  FOOTPRINT?: number
143
144
  /** UI-only clustering key for product tiles / matrices; not persisted. Phase 1 mirrors articleCodeSupplier after ensureImpliedProperties. */