@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.
Files changed (59) hide show
  1. package/lib/helpers/utils/receipt-engine.d.ts +7 -1
  2. package/lib/helpers/utils/receipt-engine.js +38 -33
  3. package/lib/tests/receipt-engine.test.js +86 -21
  4. package/package.json +1 -1
  5. package/lib/constants/MATERIALIZED_REPORTS.d.ts +0 -44
  6. package/lib/constants/MATERIALIZED_REPORTS.js +0 -58
  7. package/lib/constants/WAREHOUSE_INVOICE.d.ts +0 -14
  8. package/lib/constants/WAREHOUSE_INVOICE.js +0 -35
  9. package/lib/helpers/offer/generate-offer.d.ts +0 -11
  10. package/lib/helpers/offer/generate-offer.js +0 -143
  11. package/lib/helpers/offer/index.d.ts +0 -1
  12. package/lib/helpers/offer/index.js +0 -17
  13. package/lib/helpers/order/generate-warehouse-invoice.d.ts +0 -11
  14. package/lib/helpers/order/generate-warehouse-invoice.js +0 -196
  15. package/lib/helpers/store/all-warehouse-invoice-actions.d.ts +0 -13
  16. package/lib/helpers/store/all-warehouse-invoice-actions.js +0 -58
  17. package/lib/helpers/store/common-warehouse-invoice-actions.d.ts +0 -31
  18. package/lib/helpers/store/common-warehouse-invoice-actions.js +0 -545
  19. package/lib/helpers/store/warehouse-invoice-cart-actions.d.ts +0 -24
  20. package/lib/helpers/store/warehouse-invoice-cart-actions.js +0 -486
  21. package/lib/helpers/types/sockets.d.ts +0 -6
  22. package/lib/helpers/types/sockets.js +0 -2
  23. package/lib/helpers/types/warehouse-invoice-cart-actions.d.ts +0 -26
  24. package/lib/helpers/types/warehouse-invoice-cart-actions.js +0 -2
  25. package/lib/helpers/utils/materialized-report-helpers.d.ts +0 -35
  26. package/lib/helpers/utils/materialized-report-helpers.js +0 -73
  27. package/lib/helpers/utils/void-warehouse-invoice-items-helpers.d.ts +0 -3
  28. package/lib/helpers/utils/void-warehouse-invoice-items-helpers.js +0 -38
  29. package/lib/helpers/utils/void-warehouse-invoice-items-report-helpers.d.ts +0 -13
  30. package/lib/helpers/utils/void-warehouse-invoice-items-report-helpers.js +0 -22
  31. package/lib/helpers/utils/warehouse-invoice-order-engine.d.ts +0 -11
  32. package/lib/helpers/utils/warehouse-invoice-order-engine.js +0 -39
  33. package/lib/helpers/utils/warehouse-invoice-x-report-helpers.d.ts +0 -58
  34. package/lib/helpers/utils/warehouse-invoice-x-report-helpers.js +0 -1432
  35. package/lib/schemas/models/inventory_department_transactions.d.ts +0 -86
  36. package/lib/schemas/models/inventory_department_transactions.js +0 -116
  37. package/lib/schemas/models/inventory_department_utilities.d.ts +0 -108
  38. package/lib/schemas/models/inventory_department_utilities.js +0 -88
  39. package/lib/schemas/models/inventory_departments.d.ts +0 -53
  40. package/lib/schemas/models/inventory_departments.js +0 -58
  41. package/lib/schemas/models/inventory_entries.d.ts +0 -152
  42. package/lib/schemas/models/inventory_entries.js +0 -142
  43. package/lib/schemas/models/materialized_reports.d.ts +0 -277
  44. package/lib/schemas/models/materialized_reports.js +0 -60
  45. package/lib/schemas/models/warehouse_invoices.d.ts +0 -2675
  46. package/lib/schemas/models/warehouse_invoices.js +0 -327
  47. package/lib/schemas/models/warehouse_void_invoice_items.d.ts +0 -176
  48. package/lib/schemas/models/warehouse_void_invoice_items.js +0 -176
  49. package/lib/schemas/types/inventory_entries.d.ts +0 -41
  50. package/lib/schemas/types/inventory_entries.js +0 -2
  51. package/lib/schemas/types/materialized_reports.d.ts +0 -82
  52. package/lib/schemas/types/materialized_reports.js +0 -2
  53. package/lib/schemas/types/warehouse_invoices.d.ts +0 -69
  54. package/lib/schemas/types/warehouse_invoices.js +0 -2
  55. package/lib/schemas/types/warehouse_void_invoice_items.d.ts +0 -37
  56. package/lib/schemas/types/warehouse_void_invoice_items.js +0 -2
  57. package/lib/tests/materialized-report-helpers.test.d.ts +0 -1
  58. package/lib/tests/no-choice-modifier-selection.test.d.ts +0 -1
  59. package/lib/tests/no-choice-modifier-selection.test.js +0 -142
@@ -1,82 +0,0 @@
1
- import { MATERIALIZE_SOURCE_ENUM, REPORT_QUERY_FIELD_ENUM, TENANT_PROCESS_ENUM } from '../../constants';
2
- import { ILocalTimeFields } from '../../helpers';
3
- /** A single aggregated bucket inside a materialized sales overview doc. */
4
- export interface ISalesOverviewBucket {
5
- _id: string;
6
- count: number;
7
- grossAmount: number;
8
- }
9
- /**
10
- * The materialized sales overview report document.
11
- *
12
- * One document exists per (tenant, query_field, period) — i.e. 6 documents
13
- * per tenant-day (localDate / localWeek / localMonth / localQuarter /
14
- * localSemester / localYear). The payload preserves the output shape of the
15
- * live getSalesOverview aggregation (ISalesOverview) while adding richer
16
- * fields for analytics.
17
- */
18
- export interface ITenantSalesOverviewReport extends ILocalTimeFields {
19
- _id: string;
20
- tenant_id: string;
21
- /** Which local-time granularity this doc was compiled for. */
22
- query_field: REPORT_QUERY_FIELD_ENUM;
23
- /** Inclusive bounds of the period this doc covers ('YYYY-MM-DD'). */
24
- period_start_local_date: string;
25
- period_end_local_date: string;
26
- total_sales: ISalesOverviewBucket;
27
- cancelled_orders: ISalesOverviewBucket;
28
- total_payment_sales: ISalesOverviewBucket[];
29
- sales_by_platform: ISalesOverviewBucket[];
30
- complimentary_amount: number;
31
- unpaid_amount: number;
32
- amount_collected: number;
33
- net_sales: number;
34
- average_order_value: number;
35
- covers: number;
36
- first_order_at: Date | null;
37
- last_order_at: Date | null;
38
- compiled_at: Date;
39
- compile_source: MATERIALIZE_SOURCE_ENUM;
40
- createdAt: Date;
41
- updatedAt: Date;
42
- }
43
- /**
44
- * The day-end materialization pipeline tracker. One document per tenant.
45
- *
46
- * running_process is the process currently being compiled (null when idle).
47
- * completed_processes maps each process enum to its completion state for the
48
- * current run — the anti-loop mechanism: a handler only enqueues the next
49
- * process at the moment it flips its own flag from false to true, and ignores
50
- * duplicate Cloud Task deliveries when its flag is already true.
51
- */
52
- export interface ITenantProcesses {
53
- _id: string;
54
- tenant_id: string;
55
- /** The business day ('YYYY-MM-DD') being materialized. */
56
- localDate: string;
57
- running_process: TENANT_PROCESS_ENUM | null;
58
- total_processes: number;
59
- current_process: number;
60
- completed_processes: Record<TENANT_PROCESS_ENUM, boolean>;
61
- started_at: Date | null;
62
- completed_at: Date | null;
63
- createdAt: Date;
64
- updatedAt: Date;
65
- }
66
- /** Request body for the POS_DAY_END worker endpoint. */
67
- export interface IWorker_PosDayEnd {
68
- tenant_id: string;
69
- /** The business day that just closed ('YYYY-MM-DD'). */
70
- localDate: string;
71
- }
72
- /** Request body for the MATERIALIZE_SALES_OVERVIEW_REPORT worker endpoint. */
73
- export interface IWorker_MaterializeSalesOverviewReport {
74
- tenant_id: string;
75
- localDate: string;
76
- source?: MATERIALIZE_SOURCE_ENUM;
77
- }
78
- /** Request body for the RESET_TENANT_PROCESSES worker endpoint. */
79
- export interface IWorker_ResetTenantProcesses {
80
- tenant_id: string;
81
- localDate: string;
82
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,69 +0,0 @@
1
- import { WAREHOUSE_INVOICE_STATUS_ENUM } from '../../constants';
2
- import { IOrderPayment, IStaffDetails } from './orders';
3
- export interface IWarehouseClientInvoiceItem {
4
- _id: string;
5
- item_id: string;
6
- is_ready?: boolean;
7
- void_reason?: string;
8
- name: string;
9
- price: number;
10
- subtotal: number;
11
- quantity: number;
12
- _net_amount: number;
13
- _gross_amount: number;
14
- _gst_amount: number;
15
- _discount_amount: number;
16
- special_instructions: string;
17
- }
18
- export interface IWarehouseClientInvoiceCategory {
19
- name: string;
20
- category_id: string;
21
- items: IWarehouseClientInvoiceItem[];
22
- }
23
- export interface IWarehouseClientInvoiceIteration {
24
- categories: IWarehouseClientInvoiceCategory[];
25
- payments: IOrderPayment[];
26
- staff_details: IStaffDetails;
27
- is_gst_inclusive?: boolean;
28
- gst?: number;
29
- gst_amount?: number;
30
- special_instructions: string;
31
- order_status: WAREHOUSE_INVOICE_STATUS_ENUM;
32
- /**
33
- * price is the total price of the all items in the order
34
- * without any discounts
35
- */
36
- price: number;
37
- /**
38
- * amount_earned is the total amount amount_earned by the store
39
- */
40
- amount_earned: number;
41
- /**
42
- * grand_total is the final amount of the order including all taxes and discounts
43
- */
44
- grand_total: number;
45
- tax_number: string;
46
- updatedAt: Date;
47
- }
48
- export interface IWarehouseClientInvoice extends IWarehouseClientInvoiceIteration {
49
- _id: string;
50
- warehouse_id: string;
51
- client_id: string;
52
- client_name: string;
53
- iterations: IWarehouseClientInvoiceIteration[];
54
- /**
55
- * amount_collected is the total amount collected from the consumer
56
- */
57
- amount_collected: number;
58
- order_number: number | null;
59
- delete_reason?: string | null;
60
- cancel_reason?: string | null;
61
- is_deleted: boolean;
62
- order_status_updated_at: Date;
63
- is_reopened?: boolean;
64
- deferred_settlement?: boolean;
65
- order_settled_at: Date;
66
- order_settled_at_mins: number;
67
- createdAt_mins: number;
68
- createdAt: Date;
69
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,37 +0,0 @@
1
- import { VOID_WAREHOUSE_INVOICE_ITEM_TYPE_ENUM } from '../../constants';
2
- export interface IWarehouseVoidInvoiceItemAdjustment {
3
- _id: string;
4
- order_id: string;
5
- order_number: number | null;
6
- order_item_id: string;
7
- quantity: number;
8
- subtotal: number;
9
- staff_id: string;
10
- staff_name: string;
11
- }
12
- export interface IWarehouseVoidInvoiceItem {
13
- _id: string;
14
- warehouse_id: string;
15
- order_id: string;
16
- order_number: number | null;
17
- item_id: string;
18
- order_item_id: string;
19
- void_type: VOID_WAREHOUSE_INVOICE_ITEM_TYPE_ENUM;
20
- client_id: string;
21
- client_name: string;
22
- staff_id: string;
23
- staff_name: string;
24
- void_reason: string;
25
- iteration: number;
26
- name: string;
27
- quantity: number;
28
- subtotal: number;
29
- description: string;
30
- total_adjusted_quantity: number;
31
- total_adjusted_subtotal: number;
32
- adjustments?: IWarehouseVoidInvoiceItemAdjustment[] | null;
33
- order_punched_at: Date;
34
- createdAt_mins: number;
35
- createdAt: Date;
36
- updatedAt: Date;
37
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,142 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const constants_1 = require("../constants");
4
- const order_engine_1 = require("../helpers/utils/order-engine");
5
- // ============================================================================
6
- // No-choice modifier trees: "the user has nothing to pick".
7
- //
8
- // Used by POS to skip the options drawer entirely — when every usable level is
9
- // a single REQUIRED modifier with a single usable option, adding the item
10
- // direct-to-cart with the chain applied produces EXACTLY what the drawer would
11
- // have produced by hand.
12
- // ============================================================================
13
- const PLATFORM = constants_1.PLATFORMS_ENUM.POS_WALK_IN;
14
- function makeOption(id, overrides = {}) {
15
- return {
16
- _id: id,
17
- ref: id,
18
- name: id,
19
- active: true,
20
- sold_out: [],
21
- sort_id: 1,
22
- excluded_platforms: [],
23
- price: null,
24
- modifiers: null,
25
- ...overrides,
26
- };
27
- }
28
- function makeModifier(id, overrides = {}) {
29
- return {
30
- _id: id,
31
- ref: id,
32
- name: id,
33
- description: '',
34
- active: true,
35
- sold_out: [],
36
- sort_id: 1,
37
- options: [],
38
- ...overrides,
39
- };
40
- }
41
- describe('getNoChoiceModifierSelection', () => {
42
- it('reports an item without modifiers as plain', () => {
43
- expect((0, order_engine_1.getNoChoiceModifierSelection)(null, PLATFORM)).toEqual({ kind: 'plain' });
44
- expect((0, order_engine_1.getNoChoiceModifierSelection)([], PLATFORM)).toEqual({ kind: 'plain' });
45
- });
46
- it('reports an item whose modifiers are all unusable as plain', () => {
47
- const modifiers = [makeModifier('mod-off', { active: false, options: [makeOption('a')] })];
48
- expect((0, order_engine_1.getNoChoiceModifierSelection)(modifiers, PLATFORM)).toEqual({ kind: 'plain' });
49
- });
50
- it('finds a single required modifier with a single option', () => {
51
- const modifiers = [
52
- makeModifier('mod-1', { min_num_options: 1, max_num_options: 1, options: [makeOption('opt-a')] }),
53
- ];
54
- const selection = (0, order_engine_1.getNoChoiceModifierSelection)(modifiers, PLATFORM);
55
- expect(selection?.kind).toBe('no-choice');
56
- if (selection?.kind !== 'no-choice')
57
- throw new Error('expected no-choice selection');
58
- expect(selection.selectionPath).toBe('mod-1_opt-a');
59
- expect(selection.selectedOptions.map((option) => option._id)).toEqual(['opt-a']);
60
- });
61
- it('treats a required quantity group (aggregates) with one option as no-choice', () => {
62
- const modifiers = [
63
- makeModifier('mod-1', {
64
- min_aggregate_options_quantity: 2,
65
- max_aggregate_options_quantity: 2,
66
- min_option_choice_quantity: 2,
67
- max_option_choice_quantity: 2,
68
- options: [makeOption('opt-a')],
69
- }),
70
- ];
71
- expect((0, order_engine_1.getNoChoiceModifierSelection)(modifiers, PLATFORM)?.kind).toBe('no-choice');
72
- });
73
- it('walks a fully forced nested chain and builds the full path', () => {
74
- const nestedModifier = makeModifier('mod-2', {
75
- min_num_options: 1,
76
- max_num_options: 1,
77
- options: [makeOption('opt-b')],
78
- });
79
- const option = makeOption('opt-a', { modifiers: [nestedModifier] });
80
- const modifiers = [
81
- makeModifier('mod-1', { min_num_options: 1, max_num_options: 1, options: [option] }),
82
- ];
83
- const selection = (0, order_engine_1.getNoChoiceModifierSelection)(modifiers, PLATFORM);
84
- expect(selection?.kind).toBe('no-choice');
85
- if (selection?.kind !== 'no-choice')
86
- throw new Error('expected no-choice selection');
87
- expect(selection.selectionPath).toBe('mod-1_opt-a_mod-2_opt-b');
88
- expect(selection.selectedOptions.map((selected) => selected._id)).toEqual(['opt-a', 'opt-b']);
89
- });
90
- it('returns null when a level is optional (the user can skip it)', () => {
91
- const modifiers = [makeModifier('mod-1', { options: [makeOption('opt-a')] })];
92
- expect((0, order_engine_1.getNoChoiceModifierSelection)(modifiers, PLATFORM)).toBeNull();
93
- });
94
- it('returns null when a level offers more than one usable option', () => {
95
- const modifiers = [
96
- makeModifier('mod-1', {
97
- min_num_options: 1,
98
- max_num_options: 1,
99
- options: [makeOption('opt-a'), makeOption('opt-b')],
100
- }),
101
- ];
102
- expect((0, order_engine_1.getNoChoiceModifierSelection)(modifiers, PLATFORM)).toBeNull();
103
- });
104
- it('ignores options the platform cannot use when counting choices', () => {
105
- const modifiers = [
106
- makeModifier('mod-1', {
107
- min_num_options: 1,
108
- max_num_options: 1,
109
- options: [
110
- makeOption('opt-a'),
111
- makeOption('opt-b', { excluded_platforms: [PLATFORM] }),
112
- ],
113
- }),
114
- ];
115
- expect((0, order_engine_1.getNoChoiceModifierSelection)(modifiers, PLATFORM)?.kind).toBe('no-choice');
116
- });
117
- it('returns null when a nested level offers a choice', () => {
118
- const nestedModifier = makeModifier('mod-2', {
119
- min_num_options: 1,
120
- max_num_options: 1,
121
- options: [makeOption('opt-b'), makeOption('opt-c')],
122
- });
123
- const option = makeOption('opt-a', { modifiers: [nestedModifier] });
124
- const modifiers = [
125
- makeModifier('mod-1', { min_num_options: 1, max_num_options: 1, options: [option] }),
126
- ];
127
- expect((0, order_engine_1.getNoChoiceModifierSelection)(modifiers, PLATFORM)).toBeNull();
128
- });
129
- it('returns null when two usable modifier groups exist', () => {
130
- const modifiers = [
131
- makeModifier('mod-1', { min_num_options: 1, max_num_options: 1, options: [makeOption('a')] }),
132
- makeModifier('mod-2', { min_num_options: 1, max_num_options: 1, options: [makeOption('b')] }),
133
- ];
134
- expect((0, order_engine_1.getNoChoiceModifierSelection)(modifiers, PLATFORM)).toBeNull();
135
- });
136
- it('returns plain when no platform is provided', () => {
137
- const modifiers = [
138
- makeModifier('mod-1', { min_num_options: 1, max_num_options: 1, options: [makeOption('a')] }),
139
- ];
140
- expect((0, order_engine_1.getNoChoiceModifierSelection)(modifiers, undefined)).toEqual({ kind: 'plain' });
141
- });
142
- });