@managesome/eposmatic-toolkit 0.2.565 → 0.2.568
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/constants/MATERIALIZED_REPORTS.d.ts +44 -0
- package/lib/constants/MATERIALIZED_REPORTS.js +58 -0
- package/lib/helpers/utils/materialized-report-helpers.d.ts +35 -0
- package/lib/helpers/utils/materialized-report-helpers.js +73 -0
- package/lib/schemas/models/materialized_reports.d.ts +277 -0
- package/lib/schemas/models/materialized_reports.js +60 -0
- package/lib/schemas/models/tenant_cash_drawer_sessions.d.ts +6 -0
- package/lib/schemas/models/tenant_cash_drawer_sessions.js +8 -0
- package/lib/schemas/models/tenant_cash_in_out.d.ts +0 -3
- package/lib/schemas/models/tenant_cash_in_out.js +0 -4
- package/lib/schemas/models/wallet_transactions.d.ts +3 -3
- package/lib/schemas/types/materialized_reports.d.ts +82 -0
- package/lib/schemas/types/materialized_reports.js +2 -0
- package/lib/schemas/types/tenant_cash_drawer_sessions.d.ts +12 -0
- package/lib/schemas/types/tenant_cash_in_out.d.ts +0 -1
- package/lib/tests/materialized-report-helpers.test.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,44 @@
|
|
|
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;
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ISalesOverviewBucket, ITenantSalesOverviewReport } from '../../schemas/types';
|
|
2
|
+
/**
|
|
3
|
+
* The rollup payload of a materialized sales overview doc — every
|
|
4
|
+
* additive metric, without identity/period metadata.
|
|
5
|
+
*/
|
|
6
|
+
export interface ISalesOverviewRollupPayload {
|
|
7
|
+
total_sales: ISalesOverviewBucket;
|
|
8
|
+
cancelled_orders: ISalesOverviewBucket;
|
|
9
|
+
total_payment_sales: ISalesOverviewBucket[];
|
|
10
|
+
sales_by_platform: ISalesOverviewBucket[];
|
|
11
|
+
complimentary_amount: number;
|
|
12
|
+
unpaid_amount: number;
|
|
13
|
+
amount_collected: number;
|
|
14
|
+
net_sales: number;
|
|
15
|
+
average_order_value: number;
|
|
16
|
+
covers: number;
|
|
17
|
+
first_order_at: Date | null;
|
|
18
|
+
last_order_at: Date | null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Sums an array of bucket arrays, merging buckets by _id.
|
|
22
|
+
* Used to roll up localDate docs into week/month/quarter/semester/year docs.
|
|
23
|
+
*/
|
|
24
|
+
export declare function mergeSalesOverviewBuckets(bucketArrays: ISalesOverviewBucket[][]): ISalesOverviewBucket[];
|
|
25
|
+
/**
|
|
26
|
+
* Sums a single bucket across multiple docs.
|
|
27
|
+
*/
|
|
28
|
+
export declare function sumSalesOverviewBuckets(buckets: ISalesOverviewBucket[]): ISalesOverviewBucket;
|
|
29
|
+
/**
|
|
30
|
+
* Merges (rolls up) multiple materialized sales overview docs into one
|
|
31
|
+
* payload. All additive fields are summed; first/last order timestamps are
|
|
32
|
+
* min/max respectively. Non-additive derived fields (average_order_value)
|
|
33
|
+
* are recomputed from the summed values.
|
|
34
|
+
*/
|
|
35
|
+
export declare function rollupSalesOverviewDocs(docs: ITenantSalesOverviewReport[]): ISalesOverviewRollupPayload;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergeSalesOverviewBuckets = mergeSalesOverviewBuckets;
|
|
4
|
+
exports.sumSalesOverviewBuckets = sumSalesOverviewBuckets;
|
|
5
|
+
exports.rollupSalesOverviewDocs = rollupSalesOverviewDocs;
|
|
6
|
+
/**
|
|
7
|
+
* Sums an array of bucket arrays, merging buckets by _id.
|
|
8
|
+
* Used to roll up localDate docs into week/month/quarter/semester/year docs.
|
|
9
|
+
*/
|
|
10
|
+
function mergeSalesOverviewBuckets(bucketArrays) {
|
|
11
|
+
const map = new Map();
|
|
12
|
+
for (const buckets of bucketArrays) {
|
|
13
|
+
for (const bucket of buckets) {
|
|
14
|
+
const existing = map.get(bucket._id);
|
|
15
|
+
if (existing == null) {
|
|
16
|
+
map.set(bucket._id, { ...bucket });
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
existing.count += bucket.count;
|
|
20
|
+
existing.grossAmount += bucket.grossAmount;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return Array.from(map.values());
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Sums a single bucket across multiple docs.
|
|
28
|
+
*/
|
|
29
|
+
function sumSalesOverviewBuckets(buckets) {
|
|
30
|
+
return buckets.reduce((acc, b) => {
|
|
31
|
+
acc.count += b.count;
|
|
32
|
+
acc.grossAmount += b.grossAmount;
|
|
33
|
+
return acc;
|
|
34
|
+
}, { _id: buckets[0]?._id ?? '', count: 0, grossAmount: 0 });
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Merges (rolls up) multiple materialized sales overview docs into one
|
|
38
|
+
* payload. All additive fields are summed; first/last order timestamps are
|
|
39
|
+
* min/max respectively. Non-additive derived fields (average_order_value)
|
|
40
|
+
* are recomputed from the summed values.
|
|
41
|
+
*/
|
|
42
|
+
function rollupSalesOverviewDocs(docs) {
|
|
43
|
+
const totalSales = sumSalesOverviewBuckets(docs.map((d) => d.total_sales));
|
|
44
|
+
return {
|
|
45
|
+
total_sales: totalSales,
|
|
46
|
+
cancelled_orders: sumSalesOverviewBuckets(docs.map((d) => d.cancelled_orders)),
|
|
47
|
+
total_payment_sales: mergeSalesOverviewBuckets(docs.map((d) => d.total_payment_sales)),
|
|
48
|
+
sales_by_platform: mergeSalesOverviewBuckets(docs.map((d) => d.sales_by_platform)),
|
|
49
|
+
complimentary_amount: sumField(docs, 'complimentary_amount'),
|
|
50
|
+
unpaid_amount: sumField(docs, 'unpaid_amount'),
|
|
51
|
+
amount_collected: sumField(docs, 'amount_collected'),
|
|
52
|
+
net_sales: sumField(docs, 'net_sales'),
|
|
53
|
+
covers: sumField(docs, 'covers'),
|
|
54
|
+
first_order_at: minDate(docs.map((d) => d.first_order_at)),
|
|
55
|
+
last_order_at: maxDate(docs.map((d) => d.last_order_at)),
|
|
56
|
+
average_order_value: totalSales.count > 0 ? totalSales.grossAmount / totalSales.count : 0,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function sumField(docs, field) {
|
|
60
|
+
return docs.reduce((sum, doc) => sum + (doc[field] ?? 0), 0);
|
|
61
|
+
}
|
|
62
|
+
function minDate(dates) {
|
|
63
|
+
const valid = dates.filter((d) => d != null);
|
|
64
|
+
return valid.length > 0
|
|
65
|
+
? new Date(Math.min(...valid.map((d) => new Date(d).getTime())))
|
|
66
|
+
: null;
|
|
67
|
+
}
|
|
68
|
+
function maxDate(dates) {
|
|
69
|
+
const valid = dates.filter((d) => d != null);
|
|
70
|
+
return valid.length > 0
|
|
71
|
+
? new Date(Math.max(...valid.map((d) => new Date(d).getTime())))
|
|
72
|
+
: null;
|
|
73
|
+
}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { Schema } from 'mongoose';
|
|
2
|
+
export declare const TenantSalesOverviewReportSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
3
|
+
timestamps: true;
|
|
4
|
+
versionKey: false;
|
|
5
|
+
minimize: false;
|
|
6
|
+
}, {
|
|
7
|
+
createdAt: NativeDate;
|
|
8
|
+
updatedAt: NativeDate;
|
|
9
|
+
} & {
|
|
10
|
+
localDate: string;
|
|
11
|
+
localWeek: number;
|
|
12
|
+
localMonth: number;
|
|
13
|
+
localQuarter: number;
|
|
14
|
+
localSemester: number;
|
|
15
|
+
localYear: number;
|
|
16
|
+
_id: import("mongoose").Types.ObjectId;
|
|
17
|
+
tenant_id: string;
|
|
18
|
+
createdAt: NativeDate;
|
|
19
|
+
updatedAt: NativeDate;
|
|
20
|
+
last_order_at: NativeDate;
|
|
21
|
+
localDay: number;
|
|
22
|
+
amount_collected: number;
|
|
23
|
+
day_index: import("../../constants").DAY_INDEX_ENUM;
|
|
24
|
+
localSecond: number;
|
|
25
|
+
localMinute: number;
|
|
26
|
+
localHour: number;
|
|
27
|
+
localWeekOfYear: number;
|
|
28
|
+
localTime: string;
|
|
29
|
+
localDayOfYear: number;
|
|
30
|
+
complimentary_amount: number;
|
|
31
|
+
unpaid_amount: number;
|
|
32
|
+
net_sales: number;
|
|
33
|
+
covers: number;
|
|
34
|
+
query_field: import("../../constants").REPORT_QUERY_FIELD_ENUM;
|
|
35
|
+
period_start_local_date: string;
|
|
36
|
+
period_end_local_date: string;
|
|
37
|
+
total_sales: {
|
|
38
|
+
count: number;
|
|
39
|
+
_id: string;
|
|
40
|
+
grossAmount: number;
|
|
41
|
+
};
|
|
42
|
+
cancelled_orders: {
|
|
43
|
+
count: number;
|
|
44
|
+
_id: string;
|
|
45
|
+
grossAmount: number;
|
|
46
|
+
};
|
|
47
|
+
total_payment_sales: import("mongoose").Types.DocumentArray<{
|
|
48
|
+
count: number;
|
|
49
|
+
_id: string;
|
|
50
|
+
grossAmount: number;
|
|
51
|
+
}, import("mongoose").Types.Subdocument<string, any, {
|
|
52
|
+
count: number;
|
|
53
|
+
_id: string;
|
|
54
|
+
grossAmount: number;
|
|
55
|
+
}> & {
|
|
56
|
+
count: number;
|
|
57
|
+
_id: string;
|
|
58
|
+
grossAmount: number;
|
|
59
|
+
}>;
|
|
60
|
+
sales_by_platform: import("mongoose").Types.DocumentArray<{
|
|
61
|
+
count: number;
|
|
62
|
+
_id: string;
|
|
63
|
+
grossAmount: number;
|
|
64
|
+
}, import("mongoose").Types.Subdocument<string, any, {
|
|
65
|
+
count: number;
|
|
66
|
+
_id: string;
|
|
67
|
+
grossAmount: number;
|
|
68
|
+
}> & {
|
|
69
|
+
count: number;
|
|
70
|
+
_id: string;
|
|
71
|
+
grossAmount: number;
|
|
72
|
+
}>;
|
|
73
|
+
average_order_value: number;
|
|
74
|
+
first_order_at: NativeDate;
|
|
75
|
+
compiled_at: NativeDate;
|
|
76
|
+
compile_source: import("../../constants").MATERIALIZE_SOURCE_ENUM;
|
|
77
|
+
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
78
|
+
createdAt: NativeDate;
|
|
79
|
+
updatedAt: NativeDate;
|
|
80
|
+
} & {
|
|
81
|
+
localDate: string;
|
|
82
|
+
localWeek: number;
|
|
83
|
+
localMonth: number;
|
|
84
|
+
localQuarter: number;
|
|
85
|
+
localSemester: number;
|
|
86
|
+
localYear: number;
|
|
87
|
+
_id: import("mongoose").Types.ObjectId;
|
|
88
|
+
tenant_id: string;
|
|
89
|
+
createdAt: NativeDate;
|
|
90
|
+
updatedAt: NativeDate;
|
|
91
|
+
last_order_at: NativeDate;
|
|
92
|
+
localDay: number;
|
|
93
|
+
amount_collected: number;
|
|
94
|
+
day_index: import("../../constants").DAY_INDEX_ENUM;
|
|
95
|
+
localSecond: number;
|
|
96
|
+
localMinute: number;
|
|
97
|
+
localHour: number;
|
|
98
|
+
localWeekOfYear: number;
|
|
99
|
+
localTime: string;
|
|
100
|
+
localDayOfYear: number;
|
|
101
|
+
complimentary_amount: number;
|
|
102
|
+
unpaid_amount: number;
|
|
103
|
+
net_sales: number;
|
|
104
|
+
covers: number;
|
|
105
|
+
query_field: import("../../constants").REPORT_QUERY_FIELD_ENUM;
|
|
106
|
+
period_start_local_date: string;
|
|
107
|
+
period_end_local_date: string;
|
|
108
|
+
total_sales: {
|
|
109
|
+
count: number;
|
|
110
|
+
_id: string;
|
|
111
|
+
grossAmount: number;
|
|
112
|
+
};
|
|
113
|
+
cancelled_orders: {
|
|
114
|
+
count: number;
|
|
115
|
+
_id: string;
|
|
116
|
+
grossAmount: number;
|
|
117
|
+
};
|
|
118
|
+
total_payment_sales: import("mongoose").Types.DocumentArray<{
|
|
119
|
+
count: number;
|
|
120
|
+
_id: string;
|
|
121
|
+
grossAmount: number;
|
|
122
|
+
}, import("mongoose").Types.Subdocument<string, any, {
|
|
123
|
+
count: number;
|
|
124
|
+
_id: string;
|
|
125
|
+
grossAmount: number;
|
|
126
|
+
}> & {
|
|
127
|
+
count: number;
|
|
128
|
+
_id: string;
|
|
129
|
+
grossAmount: number;
|
|
130
|
+
}>;
|
|
131
|
+
sales_by_platform: import("mongoose").Types.DocumentArray<{
|
|
132
|
+
count: number;
|
|
133
|
+
_id: string;
|
|
134
|
+
grossAmount: number;
|
|
135
|
+
}, import("mongoose").Types.Subdocument<string, any, {
|
|
136
|
+
count: number;
|
|
137
|
+
_id: string;
|
|
138
|
+
grossAmount: number;
|
|
139
|
+
}> & {
|
|
140
|
+
count: number;
|
|
141
|
+
_id: string;
|
|
142
|
+
grossAmount: number;
|
|
143
|
+
}>;
|
|
144
|
+
average_order_value: number;
|
|
145
|
+
first_order_at: NativeDate;
|
|
146
|
+
compiled_at: NativeDate;
|
|
147
|
+
compile_source: import("../../constants").MATERIALIZE_SOURCE_ENUM;
|
|
148
|
+
}>> & import("mongoose").FlatRecord<{
|
|
149
|
+
createdAt: NativeDate;
|
|
150
|
+
updatedAt: NativeDate;
|
|
151
|
+
} & {
|
|
152
|
+
localDate: string;
|
|
153
|
+
localWeek: number;
|
|
154
|
+
localMonth: number;
|
|
155
|
+
localQuarter: number;
|
|
156
|
+
localSemester: number;
|
|
157
|
+
localYear: number;
|
|
158
|
+
_id: import("mongoose").Types.ObjectId;
|
|
159
|
+
tenant_id: string;
|
|
160
|
+
createdAt: NativeDate;
|
|
161
|
+
updatedAt: NativeDate;
|
|
162
|
+
last_order_at: NativeDate;
|
|
163
|
+
localDay: number;
|
|
164
|
+
amount_collected: number;
|
|
165
|
+
day_index: import("../../constants").DAY_INDEX_ENUM;
|
|
166
|
+
localSecond: number;
|
|
167
|
+
localMinute: number;
|
|
168
|
+
localHour: number;
|
|
169
|
+
localWeekOfYear: number;
|
|
170
|
+
localTime: string;
|
|
171
|
+
localDayOfYear: number;
|
|
172
|
+
complimentary_amount: number;
|
|
173
|
+
unpaid_amount: number;
|
|
174
|
+
net_sales: number;
|
|
175
|
+
covers: number;
|
|
176
|
+
query_field: import("../../constants").REPORT_QUERY_FIELD_ENUM;
|
|
177
|
+
period_start_local_date: string;
|
|
178
|
+
period_end_local_date: string;
|
|
179
|
+
total_sales: {
|
|
180
|
+
count: number;
|
|
181
|
+
_id: string;
|
|
182
|
+
grossAmount: number;
|
|
183
|
+
};
|
|
184
|
+
cancelled_orders: {
|
|
185
|
+
count: number;
|
|
186
|
+
_id: string;
|
|
187
|
+
grossAmount: number;
|
|
188
|
+
};
|
|
189
|
+
total_payment_sales: import("mongoose").Types.DocumentArray<{
|
|
190
|
+
count: number;
|
|
191
|
+
_id: string;
|
|
192
|
+
grossAmount: number;
|
|
193
|
+
}, import("mongoose").Types.Subdocument<string, any, {
|
|
194
|
+
count: number;
|
|
195
|
+
_id: string;
|
|
196
|
+
grossAmount: number;
|
|
197
|
+
}> & {
|
|
198
|
+
count: number;
|
|
199
|
+
_id: string;
|
|
200
|
+
grossAmount: number;
|
|
201
|
+
}>;
|
|
202
|
+
sales_by_platform: import("mongoose").Types.DocumentArray<{
|
|
203
|
+
count: number;
|
|
204
|
+
_id: string;
|
|
205
|
+
grossAmount: number;
|
|
206
|
+
}, import("mongoose").Types.Subdocument<string, any, {
|
|
207
|
+
count: number;
|
|
208
|
+
_id: string;
|
|
209
|
+
grossAmount: number;
|
|
210
|
+
}> & {
|
|
211
|
+
count: number;
|
|
212
|
+
_id: string;
|
|
213
|
+
grossAmount: number;
|
|
214
|
+
}>;
|
|
215
|
+
average_order_value: number;
|
|
216
|
+
first_order_at: NativeDate;
|
|
217
|
+
compiled_at: NativeDate;
|
|
218
|
+
compile_source: import("../../constants").MATERIALIZE_SOURCE_ENUM;
|
|
219
|
+
}> & Required<{
|
|
220
|
+
_id: import("mongoose").Types.ObjectId;
|
|
221
|
+
}> & {
|
|
222
|
+
__v: number;
|
|
223
|
+
}>;
|
|
224
|
+
export declare const TenantProcessesSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
225
|
+
timestamps: true;
|
|
226
|
+
versionKey: false;
|
|
227
|
+
minimize: false;
|
|
228
|
+
}, {
|
|
229
|
+
createdAt: NativeDate;
|
|
230
|
+
updatedAt: NativeDate;
|
|
231
|
+
} & {
|
|
232
|
+
localDate: string;
|
|
233
|
+
_id: import("mongoose").Types.ObjectId;
|
|
234
|
+
tenant_id: string;
|
|
235
|
+
createdAt: NativeDate;
|
|
236
|
+
updatedAt: NativeDate;
|
|
237
|
+
completed_at: NativeDate;
|
|
238
|
+
running_process: import("../../constants").TENANT_PROCESS_ENUM;
|
|
239
|
+
total_processes: number;
|
|
240
|
+
current_process: number;
|
|
241
|
+
completed_processes: any;
|
|
242
|
+
started_at: NativeDate;
|
|
243
|
+
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
244
|
+
createdAt: NativeDate;
|
|
245
|
+
updatedAt: NativeDate;
|
|
246
|
+
} & {
|
|
247
|
+
localDate: string;
|
|
248
|
+
_id: import("mongoose").Types.ObjectId;
|
|
249
|
+
tenant_id: string;
|
|
250
|
+
createdAt: NativeDate;
|
|
251
|
+
updatedAt: NativeDate;
|
|
252
|
+
completed_at: NativeDate;
|
|
253
|
+
running_process: import("../../constants").TENANT_PROCESS_ENUM;
|
|
254
|
+
total_processes: number;
|
|
255
|
+
current_process: number;
|
|
256
|
+
completed_processes: any;
|
|
257
|
+
started_at: NativeDate;
|
|
258
|
+
}>> & import("mongoose").FlatRecord<{
|
|
259
|
+
createdAt: NativeDate;
|
|
260
|
+
updatedAt: NativeDate;
|
|
261
|
+
} & {
|
|
262
|
+
localDate: string;
|
|
263
|
+
_id: import("mongoose").Types.ObjectId;
|
|
264
|
+
tenant_id: string;
|
|
265
|
+
createdAt: NativeDate;
|
|
266
|
+
updatedAt: NativeDate;
|
|
267
|
+
completed_at: NativeDate;
|
|
268
|
+
running_process: import("../../constants").TENANT_PROCESS_ENUM;
|
|
269
|
+
total_processes: number;
|
|
270
|
+
current_process: number;
|
|
271
|
+
completed_processes: any;
|
|
272
|
+
started_at: NativeDate;
|
|
273
|
+
}> & Required<{
|
|
274
|
+
_id: import("mongoose").Types.ObjectId;
|
|
275
|
+
}> & {
|
|
276
|
+
__v: number;
|
|
277
|
+
}>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TenantProcessesSchema = exports.TenantSalesOverviewReportSchema = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
const common_models_1 = require("./common-models");
|
|
7
|
+
const SalesOverviewBucketSchema = new mongoose_1.Schema({
|
|
8
|
+
_id: { type: String, required: true },
|
|
9
|
+
count: { type: Number, required: true, min: 0 },
|
|
10
|
+
grossAmount: { type: Number, required: true },
|
|
11
|
+
}, { _id: false, minimize: false });
|
|
12
|
+
exports.TenantSalesOverviewReportSchema = new mongoose_1.Schema({
|
|
13
|
+
_id: { type: mongoose_1.Schema.Types.ObjectId, required: true, immutable: true },
|
|
14
|
+
tenant_id: { type: String, required: true, immutable: true, ref: 'tenants' },
|
|
15
|
+
query_field: { type: String, enum: constants_1.ALL_REPORT_QUERY_FIELDS, required: true, immutable: true },
|
|
16
|
+
period_start_local_date: { type: String, required: true, immutable: true },
|
|
17
|
+
period_end_local_date: { type: String, required: true, immutable: true },
|
|
18
|
+
total_sales: { type: SalesOverviewBucketSchema, required: true },
|
|
19
|
+
cancelled_orders: { type: SalesOverviewBucketSchema, required: true },
|
|
20
|
+
total_payment_sales: { type: [SalesOverviewBucketSchema], required: true, default: [] },
|
|
21
|
+
sales_by_platform: { type: [SalesOverviewBucketSchema], required: true, default: [] },
|
|
22
|
+
complimentary_amount: { type: Number, required: true, default: 0 },
|
|
23
|
+
unpaid_amount: { type: Number, required: true, default: 0 },
|
|
24
|
+
amount_collected: { type: Number, required: true, default: 0 },
|
|
25
|
+
net_sales: { type: Number, required: true, default: 0 },
|
|
26
|
+
average_order_value: { type: Number, required: true, default: 0 },
|
|
27
|
+
covers: { type: Number, required: true, default: 0 },
|
|
28
|
+
first_order_at: { type: mongoose_1.Schema.Types.Date, required: true, default: null },
|
|
29
|
+
last_order_at: { type: mongoose_1.Schema.Types.Date, required: true, default: null },
|
|
30
|
+
compiled_at: { type: mongoose_1.Schema.Types.Date, required: true, default: () => new Date() },
|
|
31
|
+
compile_source: { type: String, enum: constants_1.ALL_MATERIALIZE_SOURCES, required: true },
|
|
32
|
+
...common_models_1.LocalTimeFieldsSchema,
|
|
33
|
+
createdAt: { type: mongoose_1.Schema.Types.Date, required: true, default: () => new Date(), immutable: true },
|
|
34
|
+
updatedAt: { type: mongoose_1.Schema.Types.Date, required: true, default: () => new Date() },
|
|
35
|
+
}, { timestamps: true, versionKey: false, minimize: false });
|
|
36
|
+
// Partial unique indexes — one per query_field so targeted queries hit a dedicated index.
|
|
37
|
+
exports.TenantSalesOverviewReportSchema.index({ tenant_id: 1, localDate: 1 }, { unique: true, partialFilterExpression: { query_field: 'localDate' }, name: 'tenant_sales_overview_report_localDate' });
|
|
38
|
+
exports.TenantSalesOverviewReportSchema.index({ tenant_id: 1, localYear: 1, localWeekOfYear: 1 }, { unique: true, partialFilterExpression: { query_field: 'localWeek' }, name: 'tenant_sales_overview_report_localWeek' });
|
|
39
|
+
exports.TenantSalesOverviewReportSchema.index({ tenant_id: 1, localYear: 1, localMonth: 1 }, { unique: true, partialFilterExpression: { query_field: 'localMonth' }, name: 'tenant_sales_overview_report_localMonth' });
|
|
40
|
+
exports.TenantSalesOverviewReportSchema.index({ tenant_id: 1, localYear: 1, localQuarter: 1 }, { unique: true, partialFilterExpression: { query_field: 'localQuarter' }, name: 'tenant_sales_overview_report_localQuarter' });
|
|
41
|
+
exports.TenantSalesOverviewReportSchema.index({ tenant_id: 1, localYear: 1, localSemester: 1 }, { unique: true, partialFilterExpression: { query_field: 'localSemester' }, name: 'tenant_sales_overview_report_localSemester' });
|
|
42
|
+
exports.TenantSalesOverviewReportSchema.index({ tenant_id: 1, localYear: 1 }, { unique: true, partialFilterExpression: { query_field: 'localYear' }, name: 'tenant_sales_overview_report_localYear' });
|
|
43
|
+
exports.TenantProcessesSchema = new mongoose_1.Schema({
|
|
44
|
+
_id: { type: mongoose_1.Schema.Types.ObjectId, required: true, immutable: true },
|
|
45
|
+
tenant_id: { type: String, required: true, immutable: true, ref: 'tenants' },
|
|
46
|
+
localDate: { type: String, required: true },
|
|
47
|
+
running_process: { type: String, enum: constants_1.ALL_TENANT_PROCESSES, default: null },
|
|
48
|
+
total_processes: { type: Number, required: true, default: 0 },
|
|
49
|
+
current_process: { type: Number, required: true, default: 0 },
|
|
50
|
+
completed_processes: {
|
|
51
|
+
type: Object,
|
|
52
|
+
required: true,
|
|
53
|
+
default: () => Object.fromEntries(constants_1.ALL_TENANT_PROCESSES.map((p) => [p, false])),
|
|
54
|
+
},
|
|
55
|
+
started_at: { type: mongoose_1.Schema.Types.Date, default: null },
|
|
56
|
+
completed_at: { type: mongoose_1.Schema.Types.Date, default: null },
|
|
57
|
+
createdAt: { type: mongoose_1.Schema.Types.Date, required: true, default: () => new Date(), immutable: true },
|
|
58
|
+
updatedAt: { type: mongoose_1.Schema.Types.Date, required: true, default: () => new Date() },
|
|
59
|
+
}, { timestamps: true, versionKey: false, minimize: false });
|
|
60
|
+
exports.TenantProcessesSchema.index({ tenant_id: 1 }, { unique: true, name: 'tenant_processes_tenant_id' });
|
|
@@ -49,6 +49,8 @@ export declare const TenantCashDrawerSessionsSchema: Schema<any, import("mongoos
|
|
|
49
49
|
denominations: Map<string, number>;
|
|
50
50
|
closed_at: NativeDate;
|
|
51
51
|
};
|
|
52
|
+
running_balance: number;
|
|
53
|
+
net_movements: number;
|
|
52
54
|
reopened_iterations: import("mongoose").Types.DocumentArray<{
|
|
53
55
|
staff_id: string;
|
|
54
56
|
staff_name: string;
|
|
@@ -109,6 +111,8 @@ export declare const TenantCashDrawerSessionsSchema: Schema<any, import("mongoos
|
|
|
109
111
|
denominations: Map<string, number>;
|
|
110
112
|
closed_at: NativeDate;
|
|
111
113
|
};
|
|
114
|
+
running_balance: number;
|
|
115
|
+
net_movements: number;
|
|
112
116
|
reopened_iterations: import("mongoose").Types.DocumentArray<{
|
|
113
117
|
staff_id: string;
|
|
114
118
|
staff_name: string;
|
|
@@ -169,6 +173,8 @@ export declare const TenantCashDrawerSessionsSchema: Schema<any, import("mongoos
|
|
|
169
173
|
denominations: Map<string, number>;
|
|
170
174
|
closed_at: NativeDate;
|
|
171
175
|
};
|
|
176
|
+
running_balance: number;
|
|
177
|
+
net_movements: number;
|
|
172
178
|
reopened_iterations: import("mongoose").Types.DocumentArray<{
|
|
173
179
|
staff_id: string;
|
|
174
180
|
staff_name: string;
|
|
@@ -125,6 +125,14 @@ exports.TenantCashDrawerSessionsSchema = new mongoose_1.Schema({
|
|
|
125
125
|
type: TenantCashDrawerSessionClosingSchema,
|
|
126
126
|
default: null,
|
|
127
127
|
},
|
|
128
|
+
running_balance: {
|
|
129
|
+
type: Number,
|
|
130
|
+
default: 0,
|
|
131
|
+
},
|
|
132
|
+
net_movements: {
|
|
133
|
+
type: Number,
|
|
134
|
+
default: 0,
|
|
135
|
+
},
|
|
128
136
|
reopened_iterations: {
|
|
129
137
|
type: [TenantCashDrawerSessionReopeningSchema],
|
|
130
138
|
default: [],
|
|
@@ -33,7 +33,6 @@ export declare const TenantCashInOutSchema: Schema<any, import("mongoose").Model
|
|
|
33
33
|
day_id: import("mongoose").Types.ObjectId;
|
|
34
34
|
drawer_id: import("mongoose").Types.ObjectId;
|
|
35
35
|
shift_id: import("mongoose").Types.ObjectId;
|
|
36
|
-
expense_id: import("mongoose").Types.ObjectId;
|
|
37
36
|
shift_number: number;
|
|
38
37
|
drawer_balance_before: number;
|
|
39
38
|
drawer_balance_after: number;
|
|
@@ -67,7 +66,6 @@ export declare const TenantCashInOutSchema: Schema<any, import("mongoose").Model
|
|
|
67
66
|
day_id: import("mongoose").Types.ObjectId;
|
|
68
67
|
drawer_id: import("mongoose").Types.ObjectId;
|
|
69
68
|
shift_id: import("mongoose").Types.ObjectId;
|
|
70
|
-
expense_id: import("mongoose").Types.ObjectId;
|
|
71
69
|
shift_number: number;
|
|
72
70
|
drawer_balance_before: number;
|
|
73
71
|
drawer_balance_after: number;
|
|
@@ -101,7 +99,6 @@ export declare const TenantCashInOutSchema: Schema<any, import("mongoose").Model
|
|
|
101
99
|
day_id: import("mongoose").Types.ObjectId;
|
|
102
100
|
drawer_id: import("mongoose").Types.ObjectId;
|
|
103
101
|
shift_id: import("mongoose").Types.ObjectId;
|
|
104
|
-
expense_id: import("mongoose").Types.ObjectId;
|
|
105
102
|
shift_number: number;
|
|
106
103
|
drawer_balance_before: number;
|
|
107
104
|
drawer_balance_after: number;
|
|
@@ -24,10 +24,6 @@ exports.TenantCashInOutSchema = new mongoose_1.Schema({
|
|
|
24
24
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
25
25
|
required: true,
|
|
26
26
|
},
|
|
27
|
-
expense_id: {
|
|
28
|
-
type: mongoose_1.Schema.Types.ObjectId,
|
|
29
|
-
required: true,
|
|
30
|
-
},
|
|
31
27
|
drawer_id: {
|
|
32
28
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
33
29
|
required: true,
|
|
@@ -17,9 +17,9 @@ export declare const WalletTransactionsSchema: Schema<any, import("mongoose").Mo
|
|
|
17
17
|
payment_method: string;
|
|
18
18
|
transaction_type: import("../../constants").WALLET_TRANSACTION_TYPE_ENUM;
|
|
19
19
|
transaction_category: import("../../constants").WALLET_TRANSACTION_CATEGORY_ENUM;
|
|
20
|
+
running_balance: number;
|
|
20
21
|
previous_balance: number;
|
|
21
22
|
transaction_amount: number;
|
|
22
|
-
running_balance: number;
|
|
23
23
|
transaction_status: import("../../constants").WALLET_TRANSACTION_STATUS_ENUM;
|
|
24
24
|
order_id?: import("mongoose").Types.ObjectId | null | undefined;
|
|
25
25
|
description?: string | null | undefined;
|
|
@@ -39,9 +39,9 @@ export declare const WalletTransactionsSchema: Schema<any, import("mongoose").Mo
|
|
|
39
39
|
payment_method: string;
|
|
40
40
|
transaction_type: import("../../constants").WALLET_TRANSACTION_TYPE_ENUM;
|
|
41
41
|
transaction_category: import("../../constants").WALLET_TRANSACTION_CATEGORY_ENUM;
|
|
42
|
+
running_balance: number;
|
|
42
43
|
previous_balance: number;
|
|
43
44
|
transaction_amount: number;
|
|
44
|
-
running_balance: number;
|
|
45
45
|
transaction_status: import("../../constants").WALLET_TRANSACTION_STATUS_ENUM;
|
|
46
46
|
order_id?: import("mongoose").Types.ObjectId | null | undefined;
|
|
47
47
|
description?: string | null | undefined;
|
|
@@ -61,9 +61,9 @@ export declare const WalletTransactionsSchema: Schema<any, import("mongoose").Mo
|
|
|
61
61
|
payment_method: string;
|
|
62
62
|
transaction_type: import("../../constants").WALLET_TRANSACTION_TYPE_ENUM;
|
|
63
63
|
transaction_category: import("../../constants").WALLET_TRANSACTION_CATEGORY_ENUM;
|
|
64
|
+
running_balance: number;
|
|
64
65
|
previous_balance: number;
|
|
65
66
|
transaction_amount: number;
|
|
66
|
-
running_balance: number;
|
|
67
67
|
transaction_status: import("../../constants").WALLET_TRANSACTION_STATUS_ENUM;
|
|
68
68
|
order_id?: import("mongoose").Types.ObjectId | null | undefined;
|
|
69
69
|
description?: string | null | undefined;
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
}
|
|
@@ -34,6 +34,18 @@ export interface ITenantCashDrawerSession extends ILocalTimeFields {
|
|
|
34
34
|
status: CASH_DRAWER_STATUS_ENUM;
|
|
35
35
|
opening: ITenantCashDrawerSessionOpening | null;
|
|
36
36
|
closing: ITenantCashDrawerSessionClosing | null;
|
|
37
|
+
/**
|
|
38
|
+
* Live drawer balance = opening.cash_amount + net_movements.
|
|
39
|
+
* Computed server-side on every cash in/out and pushed to POS in real time.
|
|
40
|
+
* Stored as integer cents; POS converts via `fromCentsSession`.
|
|
41
|
+
*/
|
|
42
|
+
running_balance: number;
|
|
43
|
+
/**
|
|
44
|
+
* Net cash movement for this session = Σ CASH_IN − Σ CASH_OUT.
|
|
45
|
+
* Computed server-side on every cash in/out and pushed to POS in real time.
|
|
46
|
+
* Stored as integer cents; POS converts via `fromCentsSession`.
|
|
47
|
+
*/
|
|
48
|
+
net_movements: number;
|
|
37
49
|
reopened_iterations: ITenantCashDrawerSessionReopening[];
|
|
38
50
|
reopened_times: number;
|
|
39
51
|
createdAt: Date;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|