@managesome/eposmatic-toolkit 0.2.770 → 0.2.772
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/lib/helpers/utils/receipt-engine.d.ts +7 -1
- package/lib/helpers/utils/receipt-engine.js +38 -33
- package/lib/tests/receipt-engine.test.js +86 -21
- package/package.json +1 -1
- package/lib/constants/MATERIALIZED_REPORTS.d.ts +0 -44
- package/lib/constants/MATERIALIZED_REPORTS.js +0 -58
- package/lib/constants/WAREHOUSE_INVOICE.d.ts +0 -14
- package/lib/constants/WAREHOUSE_INVOICE.js +0 -35
- package/lib/helpers/offer/generate-offer.d.ts +0 -11
- package/lib/helpers/offer/generate-offer.js +0 -143
- package/lib/helpers/offer/index.d.ts +0 -1
- package/lib/helpers/offer/index.js +0 -17
- package/lib/helpers/order/generate-warehouse-invoice.d.ts +0 -11
- package/lib/helpers/order/generate-warehouse-invoice.js +0 -196
- package/lib/helpers/store/all-warehouse-invoice-actions.d.ts +0 -13
- package/lib/helpers/store/all-warehouse-invoice-actions.js +0 -58
- package/lib/helpers/store/common-warehouse-invoice-actions.d.ts +0 -31
- package/lib/helpers/store/common-warehouse-invoice-actions.js +0 -545
- package/lib/helpers/store/warehouse-invoice-cart-actions.d.ts +0 -24
- package/lib/helpers/store/warehouse-invoice-cart-actions.js +0 -486
- package/lib/helpers/types/sockets.d.ts +0 -6
- package/lib/helpers/types/sockets.js +0 -2
- package/lib/helpers/types/warehouse-invoice-cart-actions.d.ts +0 -26
- package/lib/helpers/types/warehouse-invoice-cart-actions.js +0 -2
- package/lib/helpers/utils/materialized-report-helpers.d.ts +0 -35
- package/lib/helpers/utils/materialized-report-helpers.js +0 -73
- package/lib/helpers/utils/void-warehouse-invoice-items-helpers.d.ts +0 -3
- package/lib/helpers/utils/void-warehouse-invoice-items-helpers.js +0 -38
- package/lib/helpers/utils/void-warehouse-invoice-items-report-helpers.d.ts +0 -13
- package/lib/helpers/utils/void-warehouse-invoice-items-report-helpers.js +0 -22
- package/lib/helpers/utils/warehouse-invoice-order-engine.d.ts +0 -11
- package/lib/helpers/utils/warehouse-invoice-order-engine.js +0 -39
- package/lib/helpers/utils/warehouse-invoice-x-report-helpers.d.ts +0 -58
- package/lib/helpers/utils/warehouse-invoice-x-report-helpers.js +0 -1432
- package/lib/schemas/models/inventory_department_transactions.d.ts +0 -86
- package/lib/schemas/models/inventory_department_transactions.js +0 -116
- package/lib/schemas/models/inventory_department_utilities.d.ts +0 -108
- package/lib/schemas/models/inventory_department_utilities.js +0 -88
- package/lib/schemas/models/inventory_departments.d.ts +0 -53
- package/lib/schemas/models/inventory_departments.js +0 -58
- package/lib/schemas/models/inventory_entries.d.ts +0 -152
- package/lib/schemas/models/inventory_entries.js +0 -142
- package/lib/schemas/models/materialized_reports.d.ts +0 -277
- package/lib/schemas/models/materialized_reports.js +0 -60
- package/lib/schemas/models/warehouse_invoices.d.ts +0 -2675
- package/lib/schemas/models/warehouse_invoices.js +0 -327
- package/lib/schemas/models/warehouse_void_invoice_items.d.ts +0 -176
- package/lib/schemas/models/warehouse_void_invoice_items.js +0 -176
- package/lib/schemas/types/inventory_entries.d.ts +0 -41
- package/lib/schemas/types/inventory_entries.js +0 -2
- package/lib/schemas/types/materialized_reports.d.ts +0 -82
- package/lib/schemas/types/materialized_reports.js +0 -2
- package/lib/schemas/types/warehouse_invoices.d.ts +0 -69
- package/lib/schemas/types/warehouse_invoices.js +0 -2
- package/lib/schemas/types/warehouse_void_invoice_items.d.ts +0 -37
- package/lib/schemas/types/warehouse_void_invoice_items.js +0 -2
- package/lib/tests/materialized-report-helpers.test.d.ts +0 -1
- package/lib/tests/no-choice-modifier-selection.test.d.ts +0 -1
- package/lib/tests/no-choice-modifier-selection.test.js +0 -142
|
@@ -136,7 +136,13 @@ export declare function getReceiptEngineFooterDetails(order: Partial<IOrder>, se
|
|
|
136
136
|
export declare const plusSymbolModifierTitles: string[];
|
|
137
137
|
export declare const minusSymbolModifierTitles: string[];
|
|
138
138
|
export declare function getItemModifierTitle(name: string): string;
|
|
139
|
-
|
|
139
|
+
/**
|
|
140
|
+
* The modifier title with the option name removed, so the line does not print
|
|
141
|
+
* the overlap twice. A + / - marker (added by `getItemModifierTitle`) is always
|
|
142
|
+
* kept, and a title the option name already covers is dropped entirely.
|
|
143
|
+
* Matching is case-insensitive and treats whitespace runs as equivalent.
|
|
144
|
+
*/
|
|
145
|
+
export declare function getStrippedModifierTitle(modifierTitle: string, optionName: string): string;
|
|
140
146
|
/**
|
|
141
147
|
* Mutates the options array by adding modifier options to it.
|
|
142
148
|
*
|
|
@@ -7,7 +7,7 @@ exports.getPartialItems = exports.minusSymbolModifierTitles = exports.plusSymbol
|
|
|
7
7
|
exports.getDiscountLabel = getDiscountLabel;
|
|
8
8
|
exports.getReceiptEngineFooterDetails = getReceiptEngineFooterDetails;
|
|
9
9
|
exports.getItemModifierTitle = getItemModifierTitle;
|
|
10
|
-
exports.
|
|
10
|
+
exports.getStrippedModifierTitle = getStrippedModifierTitle;
|
|
11
11
|
exports.getReceiptItemModifiers = getReceiptItemModifiers;
|
|
12
12
|
exports.getOrderItemReceiptBody = getOrderItemReceiptBody;
|
|
13
13
|
exports.getReceiptBody = getReceiptBody;
|
|
@@ -302,11 +302,28 @@ function getItemModifierTitle(name) {
|
|
|
302
302
|
}
|
|
303
303
|
return modifierName;
|
|
304
304
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
305
|
+
/**
|
|
306
|
+
* The modifier title with the option name removed, so the line does not print
|
|
307
|
+
* the overlap twice. A + / - marker (added by `getItemModifierTitle`) is always
|
|
308
|
+
* kept, and a title the option name already covers is dropped entirely.
|
|
309
|
+
* Matching is case-insensitive and treats whitespace runs as equivalent.
|
|
310
|
+
*/
|
|
311
|
+
function getStrippedModifierTitle(modifierTitle, optionName) {
|
|
312
|
+
const marker = modifierTitle.match(/^[+-]/)?.[0] ?? '';
|
|
313
|
+
const title = modifierTitle.replace(/^[+-]\s*/, '');
|
|
314
|
+
const normalizedTitle = title.trim().toLowerCase().replace(/\s+/g, ' ');
|
|
315
|
+
const normalizedOption = optionName.trim().toLowerCase().replace(/\s+/g, ' ');
|
|
316
|
+
// The option name already says everything the title says - keep only the marker.
|
|
317
|
+
if (normalizedTitle !== '' && normalizedOption.includes(normalizedTitle)) {
|
|
318
|
+
return marker;
|
|
319
|
+
}
|
|
320
|
+
const pattern = optionName
|
|
321
|
+
.trim()
|
|
322
|
+
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
323
|
+
.split(/\s+/)
|
|
324
|
+
.join('\\s+');
|
|
325
|
+
const strippedTitle = title.replace(new RegExp(pattern, 'gi'), '').trim();
|
|
326
|
+
return `${marker}${strippedTitle !== '' ? ` ${strippedTitle}` : ''}`.trim();
|
|
310
327
|
}
|
|
311
328
|
/**
|
|
312
329
|
* Mutates the options array by adding modifier options to it.
|
|
@@ -351,27 +368,19 @@ function getReceiptItemModifiers(itemModifiers, options = [], display_modifiers_
|
|
|
351
368
|
modifierOptions.push(option);
|
|
352
369
|
}
|
|
353
370
|
}
|
|
354
|
-
else {
|
|
355
|
-
modifierOptions = modifierOptions.map((option) => ({
|
|
356
|
-
...option,
|
|
357
|
-
name: (0, common_1.titleCase)(getItemModifierOptionTitle(modifierName, option.name)),
|
|
358
|
-
}));
|
|
359
|
-
}
|
|
360
371
|
for (let j = 0; j < modifierOptions.length; j++) {
|
|
361
372
|
const option = modifierOptions[j];
|
|
362
373
|
const optionQuantity = option.quantity > 1 ? `${option.quantity}x ` : '';
|
|
363
|
-
// The option name
|
|
364
|
-
//
|
|
365
|
-
//
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
? `${space}${optionQuantity}`
|
|
371
|
-
: `${space}${optionQuantity}${modifierName} `;
|
|
374
|
+
// The option name is what survives; the modifier title only prints its
|
|
375
|
+
// non-overlapping remainder, so identical names collapse into the option
|
|
376
|
+
// name alone.
|
|
377
|
+
const strippedModifierName = hide_modifier_name ? '' : getStrippedModifierTitle(modifierName, option.name);
|
|
378
|
+
const optionDescription = strippedModifierName !== ''
|
|
379
|
+
? `${space}${optionQuantity}${strippedModifierName} `
|
|
380
|
+
: `${space}${optionQuantity}`;
|
|
372
381
|
options.push({
|
|
373
382
|
left: (0, emoji_strip_1.default)(optionDescription),
|
|
374
|
-
option_name: (0, emoji_strip_1.default)(option.name),
|
|
383
|
+
option_name: (0, emoji_strip_1.default)((0, common_1.titleCase)(option.name)),
|
|
375
384
|
});
|
|
376
385
|
if (option.modifiers != null && option.modifiers.length > 0) {
|
|
377
386
|
getReceiptItemModifiers(option.modifiers, options, display_modifiers_on_separate_lines, space, hide_modifier_name);
|
|
@@ -385,20 +394,16 @@ function getReceiptItemModifiers(itemModifiers, options = [], display_modifiers_
|
|
|
385
394
|
const modifierName = getItemModifierTitle(modifier.name);
|
|
386
395
|
for (let j = 0; j < modifier.options.length; j++) {
|
|
387
396
|
const option = modifier.options[j];
|
|
388
|
-
const optionName = (0, common_1.sentenceCase)(getItemModifierOptionTitle(modifierName, option.name));
|
|
389
397
|
const optionQuantity = option.quantity > 1 ? `${option.quantity}x ` : '';
|
|
390
|
-
//
|
|
391
|
-
// modifier
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
const optionDescription = hide_modifier_name && !isMergedWithModifierName
|
|
397
|
-
? `${space}${optionQuantity}`
|
|
398
|
-
: `${space}${optionQuantity}${modifierName} `;
|
|
398
|
+
// Mirrors the flat mode: the option name is what survives, and the
|
|
399
|
+
// modifier title only prints its non-overlapping remainder.
|
|
400
|
+
const strippedModifierName = hide_modifier_name ? '' : getStrippedModifierTitle(modifierName, option.name);
|
|
401
|
+
const optionDescription = strippedModifierName !== ''
|
|
402
|
+
? `${space}${optionQuantity}${strippedModifierName} `
|
|
403
|
+
: `${space}${optionQuantity}`;
|
|
399
404
|
options.push({
|
|
400
405
|
left: (0, emoji_strip_1.default)(optionDescription),
|
|
401
|
-
option_name: (0, emoji_strip_1.default)(
|
|
406
|
+
option_name: (0, emoji_strip_1.default)((0, common_1.sentenceCase)(option.name)),
|
|
402
407
|
});
|
|
403
408
|
if (option.modifiers) {
|
|
404
409
|
getReceiptItemModifiers(option.modifiers, options, display_modifiers_on_separate_lines, space, hide_modifier_name);
|
|
@@ -254,7 +254,7 @@ describe('getPartialItems - composite items on partial KOTs (ref_type)', () => {
|
|
|
254
254
|
});
|
|
255
255
|
// =========================><=========================
|
|
256
256
|
describe('getReceiptItemModifiers - hide_modifier_name', () => {
|
|
257
|
-
it('
|
|
257
|
+
it('collapses identical modifier and option names into the option name', () => {
|
|
258
258
|
const options = [];
|
|
259
259
|
(0, receipt_engine_1.getReceiptItemModifiers)([
|
|
260
260
|
makeModifier('mod-pizza', 'modref-pizza', 'Tikka Pizza', [
|
|
@@ -262,10 +262,10 @@ describe('getReceiptItemModifiers - hide_modifier_name', () => {
|
|
|
262
262
|
]),
|
|
263
263
|
], options, false, '', false);
|
|
264
264
|
expect(options).toHaveLength(1);
|
|
265
|
-
expect(options[0].left).toBe('
|
|
266
|
-
expect(options[0].option_name).toBe('');
|
|
265
|
+
expect(options[0].left).toBe(' ');
|
|
266
|
+
expect(options[0].option_name).toBe('Tikka pizza');
|
|
267
267
|
});
|
|
268
|
-
it('
|
|
268
|
+
it('prints the full option name when hide_modifier_name is on (no merge)', () => {
|
|
269
269
|
const options = [];
|
|
270
270
|
(0, receipt_engine_1.getReceiptItemModifiers)([
|
|
271
271
|
makeModifier('mod-pizza', 'modref-pizza', 'Tikka Pizza', [
|
|
@@ -273,10 +273,10 @@ describe('getReceiptItemModifiers - hide_modifier_name', () => {
|
|
|
273
273
|
]),
|
|
274
274
|
], options, false, '', true);
|
|
275
275
|
expect(options).toHaveLength(1);
|
|
276
|
-
expect(options[0].left).toBe('
|
|
277
|
-
expect(options[0].option_name).toBe('');
|
|
276
|
+
expect(options[0].left).toBe(' ');
|
|
277
|
+
expect(options[0].option_name).toBe('Tikka pizza');
|
|
278
278
|
});
|
|
279
|
-
it('keeps the
|
|
279
|
+
it('keeps the option name and quantity when hide_modifier_name is on', () => {
|
|
280
280
|
const options = [];
|
|
281
281
|
(0, receipt_engine_1.getReceiptItemModifiers)([
|
|
282
282
|
makeModifier('mod-pizza', 'modref-pizza', 'Tikka Pizza', [
|
|
@@ -284,8 +284,8 @@ describe('getReceiptItemModifiers - hide_modifier_name', () => {
|
|
|
284
284
|
]),
|
|
285
285
|
], options, false, '', true);
|
|
286
286
|
expect(options).toHaveLength(1);
|
|
287
|
-
expect(options[0].left).toBe(' 2x
|
|
288
|
-
expect(options[0].option_name).toBe('');
|
|
287
|
+
expect(options[0].left).toBe(' 2x ');
|
|
288
|
+
expect(options[0].option_name).toBe('Tikka pizza');
|
|
289
289
|
});
|
|
290
290
|
it('still hides the modifier name when the option name is different', () => {
|
|
291
291
|
const options = [];
|
|
@@ -294,7 +294,7 @@ describe('getReceiptItemModifiers - hide_modifier_name', () => {
|
|
|
294
294
|
expect(options[0].left).toBe(' ');
|
|
295
295
|
expect(options[0].option_name).toBe('Large');
|
|
296
296
|
});
|
|
297
|
-
it('
|
|
297
|
+
it('prints the full option name in separate-lines mode when hide_modifier_name is on', () => {
|
|
298
298
|
const options = [];
|
|
299
299
|
(0, receipt_engine_1.getReceiptItemModifiers)([
|
|
300
300
|
makeModifier('mod-pizza', 'modref-pizza', 'Tikka Pizza', [
|
|
@@ -302,29 +302,94 @@ describe('getReceiptItemModifiers - hide_modifier_name', () => {
|
|
|
302
302
|
]),
|
|
303
303
|
], options, true, '', true);
|
|
304
304
|
expect(options).toHaveLength(1);
|
|
305
|
-
expect(options[0].left).toBe('
|
|
305
|
+
expect(options[0].left).toBe(' ');
|
|
306
|
+
expect(options[0].option_name).toBe('Tikka Pizza');
|
|
307
|
+
});
|
|
308
|
+
it('hides the modifier name even when the option name has no printable text (emoji only)', () => {
|
|
309
|
+
const options = [];
|
|
310
|
+
(0, receipt_engine_1.getReceiptItemModifiers)([makeModifier('mod-pizza', 'modref-pizza', 'Tikka Pizza', [makeOption('opt-tikka', 'pizza-tikka', '🍕')])], options, false, '', true);
|
|
311
|
+
expect(options).toHaveLength(1);
|
|
312
|
+
expect(options[0].left).toBe(' ');
|
|
313
|
+
expect(options[0].option_name).toBe('');
|
|
314
|
+
});
|
|
315
|
+
it('hides the modifier name when the option has no printable text in separate-lines mode too', () => {
|
|
316
|
+
const options = [];
|
|
317
|
+
(0, receipt_engine_1.getReceiptItemModifiers)([makeModifier('mod-pizza', 'modref-pizza', 'Tikka Pizza', [makeOption('opt-tikka', 'pizza-tikka', '🍕')])], options, true, '', true);
|
|
318
|
+
expect(options).toHaveLength(1);
|
|
319
|
+
expect(options[0].left).toBe(' ');
|
|
306
320
|
expect(options[0].option_name).toBe('');
|
|
307
321
|
});
|
|
308
|
-
it('
|
|
322
|
+
it('does not strip the modifier name out of the option name when hiding is on', () => {
|
|
309
323
|
const options = [];
|
|
310
324
|
(0, receipt_engine_1.getReceiptItemModifiers)([
|
|
311
325
|
makeModifier('mod-pizza', 'modref-pizza', 'Tikka Pizza', [
|
|
312
|
-
makeOption('opt-tikka', 'pizza-tikka', 'Tikka Pizza
|
|
326
|
+
makeOption('opt-tikka', 'pizza-tikka', 'Tikka Pizza Large'),
|
|
313
327
|
]),
|
|
314
|
-
], options,
|
|
328
|
+
], options, true, '', true);
|
|
315
329
|
expect(options).toHaveLength(1);
|
|
316
|
-
expect(options[0].left).toBe('
|
|
317
|
-
expect(options[0].option_name).toBe('');
|
|
330
|
+
expect(options[0].left).toBe(' ');
|
|
331
|
+
expect(options[0].option_name).toBe('Tikka Pizza Large');
|
|
318
332
|
});
|
|
319
|
-
it('
|
|
333
|
+
it('collapses identical names into the option name in separate-lines mode too', () => {
|
|
320
334
|
const options = [];
|
|
321
335
|
(0, receipt_engine_1.getReceiptItemModifiers)([
|
|
322
336
|
makeModifier('mod-pizza', 'modref-pizza', 'Tikka Pizza', [
|
|
323
|
-
makeOption('opt-tikka', 'pizza-tikka', 'Tikka Pizza
|
|
337
|
+
makeOption('opt-tikka', 'pizza-tikka', 'Tikka Pizza'),
|
|
324
338
|
]),
|
|
325
|
-
], options, true, '',
|
|
339
|
+
], options, true, '', false);
|
|
326
340
|
expect(options).toHaveLength(1);
|
|
327
|
-
expect(options[0].left).toBe('
|
|
328
|
-
expect(options[0].option_name).toBe('');
|
|
341
|
+
expect(options[0].left).toBe(' ');
|
|
342
|
+
expect(options[0].option_name).toBe('Tikka Pizza');
|
|
343
|
+
});
|
|
344
|
+
it('keeps the modifier title when the option name does not overlap it', () => {
|
|
345
|
+
const options = [];
|
|
346
|
+
(0, receipt_engine_1.getReceiptItemModifiers)([makeModifier('mod-size', 'modref-size', 'SIZE', [makeOption('opt-large', 'size-large', 'Large')])], options, false, '', false);
|
|
347
|
+
expect(options).toHaveLength(1);
|
|
348
|
+
expect(options[0].left).toBe(' SIZE ');
|
|
349
|
+
expect(options[0].option_name).toBe('Large');
|
|
350
|
+
});
|
|
351
|
+
it('keeps the + marker when a keyword-styled title collapses', () => {
|
|
352
|
+
const options = [];
|
|
353
|
+
(0, receipt_engine_1.getReceiptItemModifiers)([
|
|
354
|
+
makeModifier('mod-wings', 'modref-wings', 'Extra Hot Wings', [
|
|
355
|
+
makeOption('opt-wings', 'wings-extra', 'Extra Hot Wings'),
|
|
356
|
+
]),
|
|
357
|
+
], options, false, '', false);
|
|
358
|
+
expect(options).toHaveLength(1);
|
|
359
|
+
expect(options[0].left).toBe(' + ');
|
|
360
|
+
expect(options[0].option_name).toBe('Extra hot wings');
|
|
361
|
+
});
|
|
362
|
+
it('keeps the - marker for removal-style titles', () => {
|
|
363
|
+
const options = [];
|
|
364
|
+
(0, receipt_engine_1.getReceiptItemModifiers)([
|
|
365
|
+
makeModifier('mod-onion', 'modref-onion', 'Without Onion', [
|
|
366
|
+
makeOption('opt-onion', 'onion-remove', 'Without Onion'),
|
|
367
|
+
]),
|
|
368
|
+
], options, false, '', false);
|
|
369
|
+
expect(options).toHaveLength(1);
|
|
370
|
+
expect(options[0].left).toBe(' - ');
|
|
371
|
+
expect(options[0].option_name).toBe('Without onion');
|
|
372
|
+
});
|
|
373
|
+
it('drops the title when the option name fully covers it', () => {
|
|
374
|
+
const options = [];
|
|
375
|
+
(0, receipt_engine_1.getReceiptItemModifiers)([
|
|
376
|
+
makeModifier('mod-pizza', 'modref-pizza', 'Tikka Pizza', [
|
|
377
|
+
makeOption('opt-tikka', 'pizza-tikka', 'Tikka Pizza Large'),
|
|
378
|
+
]),
|
|
379
|
+
], options, false, '', false);
|
|
380
|
+
expect(options).toHaveLength(1);
|
|
381
|
+
expect(options[0].left).toBe(' ');
|
|
382
|
+
expect(options[0].option_name).toBe('Tikka pizza large');
|
|
383
|
+
});
|
|
384
|
+
it('collapses names that only differ in whitespace', () => {
|
|
385
|
+
const options = [];
|
|
386
|
+
(0, receipt_engine_1.getReceiptItemModifiers)([
|
|
387
|
+
makeModifier('mod-pizza', 'modref-pizza', 'Tikka Pizza', [
|
|
388
|
+
makeOption('opt-tikka', 'pizza-tikka', 'Tikka Pizza'),
|
|
389
|
+
]),
|
|
390
|
+
], options, false, '', false);
|
|
391
|
+
expect(options).toHaveLength(1);
|
|
392
|
+
expect(options[0].left).toBe(' ');
|
|
393
|
+
expect(options[0].option_name).toBe('Tikka pizza');
|
|
329
394
|
});
|
|
330
395
|
});
|
package/package.json
CHANGED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Every materialized report/analytics compilation that runs at day-end.
|
|
3
|
-
*
|
|
4
|
-
* The order of `ALL_TENANT_PROCESSES` defines the strict, forward-only
|
|
5
|
-
* execution order of the day-end pipeline. A materialization handler may
|
|
6
|
-
* only ever enqueue the process at `index + 1` — never itself, never an
|
|
7
|
-
* earlier one — which makes infinite loops structurally impossible.
|
|
8
|
-
*/
|
|
9
|
-
export declare enum TENANT_PROCESS_ENUM {
|
|
10
|
-
SALES_OVERVIEW_REPORT = "SALES_OVERVIEW_REPORT"
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Static, ordered, finite list of day-end processes.
|
|
14
|
-
* Handlers advance strictly forward through this array.
|
|
15
|
-
*/
|
|
16
|
-
export declare const ALL_TENANT_PROCESSES: TENANT_PROCESS_ENUM[];
|
|
17
|
-
/**
|
|
18
|
-
* The local-time granularity a materialized document is compiled for.
|
|
19
|
-
* Each materialized report stores 6 documents per tenant-day — one per
|
|
20
|
-
* query field — so the frontend can query by date / week / month /
|
|
21
|
-
* quarter / semester / year using targeted `$in` queries against
|
|
22
|
-
* dedicated partial indexes.
|
|
23
|
-
*/
|
|
24
|
-
export declare enum REPORT_QUERY_FIELD_ENUM {
|
|
25
|
-
LOCAL_DATE = "localDate",
|
|
26
|
-
LOCAL_WEEK = "localWeek",
|
|
27
|
-
LOCAL_MONTH = "localMonth",
|
|
28
|
-
LOCAL_QUARTER = "localQuarter",
|
|
29
|
-
LOCAL_SEMESTER = "localSemester",
|
|
30
|
-
LOCAL_YEAR = "localYear"
|
|
31
|
-
}
|
|
32
|
-
export declare const ALL_REPORT_QUERY_FIELDS: REPORT_QUERY_FIELD_ENUM[];
|
|
33
|
-
/** How the materialized document was produced. */
|
|
34
|
-
export declare enum MATERIALIZE_SOURCE_ENUM {
|
|
35
|
-
DAY_END = "DAY_END",
|
|
36
|
-
MANUAL = "MANUAL",
|
|
37
|
-
BACKFILL = "BACKFILL"
|
|
38
|
-
}
|
|
39
|
-
export declare const ALL_MATERIALIZE_SOURCES: MATERIALIZE_SOURCE_ENUM[];
|
|
40
|
-
/** Collection names for materialized reporting. */
|
|
41
|
-
export declare const TENANT_PROCESSES_COLLECTION_NAME = "tenant_processes";
|
|
42
|
-
export declare const TENANT_SALES_OVERVIEW_REPORT_COLLECTION_NAME = "tenant_sales_overview_report";
|
|
43
|
-
/** Default ETA (seconds) after which a finished tenant_processes doc resets. */
|
|
44
|
-
export declare const TENANT_PROCESSES_RESET_ETA_SECONDS = 300;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ======================>> MATERIALIZED REPORTS / ANALYTICS <<====================== //
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.TENANT_PROCESSES_RESET_ETA_SECONDS = exports.TENANT_SALES_OVERVIEW_REPORT_COLLECTION_NAME = exports.TENANT_PROCESSES_COLLECTION_NAME = exports.ALL_MATERIALIZE_SOURCES = exports.MATERIALIZE_SOURCE_ENUM = exports.ALL_REPORT_QUERY_FIELDS = exports.REPORT_QUERY_FIELD_ENUM = exports.ALL_TENANT_PROCESSES = exports.TENANT_PROCESS_ENUM = void 0;
|
|
5
|
-
/**
|
|
6
|
-
* Every materialized report/analytics compilation that runs at day-end.
|
|
7
|
-
*
|
|
8
|
-
* The order of `ALL_TENANT_PROCESSES` defines the strict, forward-only
|
|
9
|
-
* execution order of the day-end pipeline. A materialization handler may
|
|
10
|
-
* only ever enqueue the process at `index + 1` — never itself, never an
|
|
11
|
-
* earlier one — which makes infinite loops structurally impossible.
|
|
12
|
-
*/
|
|
13
|
-
var TENANT_PROCESS_ENUM;
|
|
14
|
-
(function (TENANT_PROCESS_ENUM) {
|
|
15
|
-
TENANT_PROCESS_ENUM["SALES_OVERVIEW_REPORT"] = "SALES_OVERVIEW_REPORT";
|
|
16
|
-
// Future materialized reports / analytics are appended here, e.g.:
|
|
17
|
-
// SALES_SUMMARY_REPORT = 'SALES_SUMMARY_REPORT',
|
|
18
|
-
// X_REPORT = 'X_REPORT',
|
|
19
|
-
})(TENANT_PROCESS_ENUM || (exports.TENANT_PROCESS_ENUM = TENANT_PROCESS_ENUM = {}));
|
|
20
|
-
/**
|
|
21
|
-
* Static, ordered, finite list of day-end processes.
|
|
22
|
-
* Handlers advance strictly forward through this array.
|
|
23
|
-
*/
|
|
24
|
-
exports.ALL_TENANT_PROCESSES = [TENANT_PROCESS_ENUM.SALES_OVERVIEW_REPORT];
|
|
25
|
-
// ======================>> <<====================== //
|
|
26
|
-
/**
|
|
27
|
-
* The local-time granularity a materialized document is compiled for.
|
|
28
|
-
* Each materialized report stores 6 documents per tenant-day — one per
|
|
29
|
-
* query field — so the frontend can query by date / week / month /
|
|
30
|
-
* quarter / semester / year using targeted `$in` queries against
|
|
31
|
-
* dedicated partial indexes.
|
|
32
|
-
*/
|
|
33
|
-
var REPORT_QUERY_FIELD_ENUM;
|
|
34
|
-
(function (REPORT_QUERY_FIELD_ENUM) {
|
|
35
|
-
REPORT_QUERY_FIELD_ENUM["LOCAL_DATE"] = "localDate";
|
|
36
|
-
REPORT_QUERY_FIELD_ENUM["LOCAL_WEEK"] = "localWeek";
|
|
37
|
-
REPORT_QUERY_FIELD_ENUM["LOCAL_MONTH"] = "localMonth";
|
|
38
|
-
REPORT_QUERY_FIELD_ENUM["LOCAL_QUARTER"] = "localQuarter";
|
|
39
|
-
REPORT_QUERY_FIELD_ENUM["LOCAL_SEMESTER"] = "localSemester";
|
|
40
|
-
REPORT_QUERY_FIELD_ENUM["LOCAL_YEAR"] = "localYear";
|
|
41
|
-
})(REPORT_QUERY_FIELD_ENUM || (exports.REPORT_QUERY_FIELD_ENUM = REPORT_QUERY_FIELD_ENUM = {}));
|
|
42
|
-
exports.ALL_REPORT_QUERY_FIELDS = Object.values(REPORT_QUERY_FIELD_ENUM);
|
|
43
|
-
// ======================>> <<====================== //
|
|
44
|
-
/** How the materialized document was produced. */
|
|
45
|
-
var MATERIALIZE_SOURCE_ENUM;
|
|
46
|
-
(function (MATERIALIZE_SOURCE_ENUM) {
|
|
47
|
-
MATERIALIZE_SOURCE_ENUM["DAY_END"] = "DAY_END";
|
|
48
|
-
MATERIALIZE_SOURCE_ENUM["MANUAL"] = "MANUAL";
|
|
49
|
-
MATERIALIZE_SOURCE_ENUM["BACKFILL"] = "BACKFILL";
|
|
50
|
-
})(MATERIALIZE_SOURCE_ENUM || (exports.MATERIALIZE_SOURCE_ENUM = MATERIALIZE_SOURCE_ENUM = {}));
|
|
51
|
-
exports.ALL_MATERIALIZE_SOURCES = Object.values(MATERIALIZE_SOURCE_ENUM);
|
|
52
|
-
// ======================>> <<====================== //
|
|
53
|
-
/** Collection names for materialized reporting. */
|
|
54
|
-
exports.TENANT_PROCESSES_COLLECTION_NAME = 'tenant_processes';
|
|
55
|
-
exports.TENANT_SALES_OVERVIEW_REPORT_COLLECTION_NAME = 'tenant_sales_overview_report';
|
|
56
|
-
// ======================>> <<====================== //
|
|
57
|
-
/** Default ETA (seconds) after which a finished tenant_processes doc resets. */
|
|
58
|
-
exports.TENANT_PROCESSES_RESET_ETA_SECONDS = 300; // 5 minutes
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { IWarehouseClientInvoice } from '../schemas';
|
|
2
|
-
export interface IWarehouseInvoiceStatus {
|
|
3
|
-
status: IWarehouseClientInvoice['order_status'];
|
|
4
|
-
color: string;
|
|
5
|
-
contrast_color: string;
|
|
6
|
-
priority: number;
|
|
7
|
-
}
|
|
8
|
-
export interface IWarehouseInvoiceStatusColorCode {
|
|
9
|
-
color: string;
|
|
10
|
-
contrast_color: string;
|
|
11
|
-
}
|
|
12
|
-
export type IWarehouseInvoiceStatusColorCodeMap = Record<IWarehouseClientInvoice['order_status'], IWarehouseInvoiceStatusColorCode>;
|
|
13
|
-
export declare const DEFAULT_WAREHOUSE_INVOICE_STATUS_COLOR_CODE_MAP: IWarehouseInvoiceStatusColorCodeMap;
|
|
14
|
-
export declare const DEFAULT_WAREHOUSE_INVOICE_STATUS: IWarehouseInvoiceStatus[];
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_WAREHOUSE_INVOICE_STATUS = exports.DEFAULT_WAREHOUSE_INVOICE_STATUS_COLOR_CODE_MAP = void 0;
|
|
4
|
-
const WAREHOUSE_ENUMS_1 = require("./WAREHOUSE_ENUMS");
|
|
5
|
-
exports.DEFAULT_WAREHOUSE_INVOICE_STATUS_COLOR_CODE_MAP = {
|
|
6
|
-
[WAREHOUSE_ENUMS_1.WAREHOUSE_INVOICE_STATUS_ENUM.PENDING]: {
|
|
7
|
-
color: '#727472',
|
|
8
|
-
contrast_color: '#FFFFFF',
|
|
9
|
-
},
|
|
10
|
-
[WAREHOUSE_ENUMS_1.WAREHOUSE_INVOICE_STATUS_ENUM.COMPLETED]: {
|
|
11
|
-
color: '#4CC417',
|
|
12
|
-
contrast_color: '#FFFFFF',
|
|
13
|
-
},
|
|
14
|
-
[WAREHOUSE_ENUMS_1.WAREHOUSE_INVOICE_STATUS_ENUM.CANCELLED]: {
|
|
15
|
-
color: '#FF0000',
|
|
16
|
-
contrast_color: '#FFFFFF',
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
exports.DEFAULT_WAREHOUSE_INVOICE_STATUS = [
|
|
20
|
-
{
|
|
21
|
-
status: WAREHOUSE_ENUMS_1.WAREHOUSE_INVOICE_STATUS_ENUM.PENDING,
|
|
22
|
-
...exports.DEFAULT_WAREHOUSE_INVOICE_STATUS_COLOR_CODE_MAP[WAREHOUSE_ENUMS_1.WAREHOUSE_INVOICE_STATUS_ENUM.PENDING],
|
|
23
|
-
priority: 0,
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
status: WAREHOUSE_ENUMS_1.WAREHOUSE_INVOICE_STATUS_ENUM.COMPLETED,
|
|
27
|
-
...exports.DEFAULT_WAREHOUSE_INVOICE_STATUS_COLOR_CODE_MAP[WAREHOUSE_ENUMS_1.WAREHOUSE_INVOICE_STATUS_ENUM.COMPLETED],
|
|
28
|
-
priority: 1,
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
status: WAREHOUSE_ENUMS_1.WAREHOUSE_INVOICE_STATUS_ENUM.CANCELLED,
|
|
32
|
-
...exports.DEFAULT_WAREHOUSE_INVOICE_STATUS_COLOR_CODE_MAP[WAREHOUSE_ENUMS_1.WAREHOUSE_INVOICE_STATUS_ENUM.CANCELLED],
|
|
33
|
-
priority: 2,
|
|
34
|
-
},
|
|
35
|
-
];
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import Mongoose from 'mongoose';
|
|
2
|
-
import { IItemSpecialHour, IOffer } from '../../schemas';
|
|
3
|
-
export declare function generateOfferSpecialHours(specialHours?: IItemSpecialHour[] | null): IItemSpecialHour[] | null;
|
|
4
|
-
export declare function generateOfferOnCreate<T extends IOffer | Partial<IOffer>>(offer: T): T;
|
|
5
|
-
export declare function generateOfferOnUpdate(partialUpdatedOffer: Partial<IOffer>): {
|
|
6
|
-
updateOperation: {
|
|
7
|
-
$unset?: (Mongoose.AnyKeys<IOffer> & Mongoose.AnyObject) | undefined;
|
|
8
|
-
$set?: (Mongoose.AnyKeys<IOffer> & Mongoose.AnyObject) | undefined;
|
|
9
|
-
};
|
|
10
|
-
partialResponseOffer: Partial<IOffer>;
|
|
11
|
-
};
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generateOfferSpecialHours = generateOfferSpecialHours;
|
|
7
|
-
exports.generateOfferOnCreate = generateOfferOnCreate;
|
|
8
|
-
exports.generateOfferOnUpdate = generateOfferOnUpdate;
|
|
9
|
-
const mongoose_1 = __importDefault(require("mongoose"));
|
|
10
|
-
function toObjectId(value) {
|
|
11
|
-
return new mongoose_1.default.Types.ObjectId(value);
|
|
12
|
-
}
|
|
13
|
-
function toObjectIdArray(values) {
|
|
14
|
-
return values.map((value) => toObjectId(value));
|
|
15
|
-
}
|
|
16
|
-
function generateOfferSpecialHours(specialHours) {
|
|
17
|
-
if (specialHours == null)
|
|
18
|
-
return null;
|
|
19
|
-
return specialHours.map((specialHour) => ({
|
|
20
|
-
...specialHour,
|
|
21
|
-
start_date: specialHour.start_date != null ? new Date(specialHour.start_date) : null,
|
|
22
|
-
end_date: specialHour.end_date != null ? new Date(specialHour.end_date) : null,
|
|
23
|
-
}));
|
|
24
|
-
}
|
|
25
|
-
function getOfferPathway(offer) {
|
|
26
|
-
const normalizedPathway = {};
|
|
27
|
-
if (offer.pathway_to_unlock_type_items != null) {
|
|
28
|
-
normalizedPathway.pathway_to_unlock_type_items = {
|
|
29
|
-
...offer.pathway_to_unlock_type_items,
|
|
30
|
-
item_ids: toObjectIdArray(offer.pathway_to_unlock_type_items.item_ids),
|
|
31
|
-
category_ids: toObjectIdArray(offer.pathway_to_unlock_type_items.category_ids),
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
if (offer.pathway_to_unlock_type_vouchers != null) {
|
|
35
|
-
normalizedPathway.pathway_to_unlock_type_vouchers = {
|
|
36
|
-
...offer.pathway_to_unlock_type_vouchers,
|
|
37
|
-
voucher_ids: toObjectIdArray(offer.pathway_to_unlock_type_vouchers.voucher_ids),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
return normalizedPathway;
|
|
41
|
-
}
|
|
42
|
-
function getNormalizedRewardItems(rewardItems) {
|
|
43
|
-
return {
|
|
44
|
-
...rewardItems,
|
|
45
|
-
item_ids: toObjectIdArray(rewardItems.item_ids),
|
|
46
|
-
...(rewardItems.allocation != null
|
|
47
|
-
? {
|
|
48
|
-
allocation: rewardItems.allocation.map((allocation) => ({
|
|
49
|
-
...allocation,
|
|
50
|
-
item_ids: toObjectIdArray(allocation.item_ids),
|
|
51
|
-
})),
|
|
52
|
-
}
|
|
53
|
-
: {}),
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function getNormalizedRewardDiscountItems(rewardDiscountItems) {
|
|
57
|
-
return {
|
|
58
|
-
...rewardDiscountItems,
|
|
59
|
-
item_ids: toObjectIdArray(rewardDiscountItems.item_ids),
|
|
60
|
-
...(rewardDiscountItems.allocation != null
|
|
61
|
-
? {
|
|
62
|
-
allocation: rewardDiscountItems.allocation.map((allocation) => ({
|
|
63
|
-
...allocation,
|
|
64
|
-
item_ids: toObjectIdArray(allocation.item_ids),
|
|
65
|
-
})),
|
|
66
|
-
}
|
|
67
|
-
: {}),
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
function getOfferReward(offer) {
|
|
71
|
-
const normalizedReward = {};
|
|
72
|
-
if (offer.reward_items != null) {
|
|
73
|
-
normalizedReward.reward_items = getNormalizedRewardItems(offer.reward_items);
|
|
74
|
-
}
|
|
75
|
-
if (offer.reward_discount_items != null) {
|
|
76
|
-
normalizedReward.reward_discount_items = getNormalizedRewardDiscountItems(offer.reward_discount_items);
|
|
77
|
-
}
|
|
78
|
-
return normalizedReward;
|
|
79
|
-
}
|
|
80
|
-
const OFFER_VARIANT_FIELDS = [
|
|
81
|
-
'pathway_to_unlock_type_items',
|
|
82
|
-
'pathway_to_unlock_type_orders',
|
|
83
|
-
'pathway_to_unlock_type_points',
|
|
84
|
-
'pathway_to_unlock_type_vouchers',
|
|
85
|
-
'reward_items',
|
|
86
|
-
'reward_discount',
|
|
87
|
-
'reward_discount_items',
|
|
88
|
-
'reward_points',
|
|
89
|
-
'reward_cashback',
|
|
90
|
-
'reward_gift_cards',
|
|
91
|
-
'reward_voucher',
|
|
92
|
-
];
|
|
93
|
-
function generateOfferOnCreate(offer) {
|
|
94
|
-
const newOffer = {
|
|
95
|
-
...offer,
|
|
96
|
-
...getOfferPathway(offer),
|
|
97
|
-
...getOfferReward(offer),
|
|
98
|
-
...(offer.offer_special_hours != null
|
|
99
|
-
? { offer_special_hours: generateOfferSpecialHours(offer.offer_special_hours) }
|
|
100
|
-
: {}),
|
|
101
|
-
_id: toObjectId(offer._id),
|
|
102
|
-
};
|
|
103
|
-
const cleanedOffer = newOffer;
|
|
104
|
-
if (cleanedOffer.offer_special_hours == null) {
|
|
105
|
-
delete cleanedOffer.offer_special_hours;
|
|
106
|
-
}
|
|
107
|
-
OFFER_VARIANT_FIELDS.forEach((field) => {
|
|
108
|
-
if (cleanedOffer[field] == null) {
|
|
109
|
-
delete cleanedOffer[field];
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
return cleanedOffer;
|
|
113
|
-
}
|
|
114
|
-
// ===============================>>><<<=====================================
|
|
115
|
-
function generateOfferOnUpdate(partialUpdatedOffer) {
|
|
116
|
-
const partialResponseOffer = {
|
|
117
|
-
...partialUpdatedOffer,
|
|
118
|
-
};
|
|
119
|
-
const unset = {};
|
|
120
|
-
const set = {
|
|
121
|
-
...partialUpdatedOffer,
|
|
122
|
-
...getOfferPathway(partialUpdatedOffer),
|
|
123
|
-
...getOfferReward(partialUpdatedOffer),
|
|
124
|
-
...(partialUpdatedOffer.offer_special_hours != null
|
|
125
|
-
? { offer_special_hours: generateOfferSpecialHours(partialUpdatedOffer.offer_special_hours) }
|
|
126
|
-
: {}),
|
|
127
|
-
};
|
|
128
|
-
if (set.offer_special_hours === null) {
|
|
129
|
-
delete set.offer_special_hours;
|
|
130
|
-
unset['offer_special_hours'] = '';
|
|
131
|
-
}
|
|
132
|
-
OFFER_VARIANT_FIELDS.forEach((field) => {
|
|
133
|
-
if (set[field] === null) {
|
|
134
|
-
delete set[field];
|
|
135
|
-
unset[field] = '';
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
const updateOperation = {
|
|
139
|
-
...(Object.keys(set).length > 0 ? { $set: set } : {}),
|
|
140
|
-
...(Object.keys(unset).length > 0 ? { $unset: unset } : {}),
|
|
141
|
-
};
|
|
142
|
-
return { updateOperation, partialResponseOffer };
|
|
143
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './generate-offer';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./generate-offer"), exports);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { IWarehouseClientInvoice, IWarehouseClientInvoiceIteration } from '../../schemas';
|
|
2
|
-
export declare function generateWarehouseClientInvoiceCategories(categories?: IWarehouseClientInvoice['categories']): IWarehouseClientInvoice['categories'];
|
|
3
|
-
export declare function generateWarehouseClientInvoiceIteration(order: IWarehouseClientInvoice | IWarehouseClientInvoiceIteration, partial?: boolean, skipItemMetadata?: boolean): IWarehouseClientInvoiceIteration;
|
|
4
|
-
export declare function generateWarehouseClientInvoiceOnCreate<T extends IWarehouseClientInvoice | Partial<IWarehouseClientInvoice>>(order: T, withIterations?: boolean): T;
|
|
5
|
-
export declare function generateWarehouseClientInvoiceOnUpdate(partialUpdatedOrder: Partial<IWarehouseClientInvoice>): {
|
|
6
|
-
updateOperation: {
|
|
7
|
-
$unset?: Partial<Record<string | number | symbol, any>> | undefined;
|
|
8
|
-
$set?: Partial<Record<string | number | symbol, any>> | undefined;
|
|
9
|
-
};
|
|
10
|
-
partialResponseOrder: IWarehouseClientInvoice;
|
|
11
|
-
};
|