@harbortouch/skytab-analytics-report-utils 0.19.1 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-7NXZJEGU.js +3340 -0
- package/dist/exporters/exportBuilder.cjs +3503 -0
- package/dist/exporters/exportBuilder.d.cts +56 -0
- package/dist/exporters/exportBuilder.d.ts +56 -0
- package/dist/exporters/exportBuilder.js +246 -0
- package/dist/index.cjs +182 -9
- package/dist/index.d.cts +52 -1247
- package/dist/index.d.ts +52 -1247
- package/dist/index.js +70 -3156
- package/dist/report-BOL9p86o.d.cts +1291 -0
- package/dist/report-BOL9p86o.d.ts +1291 -0
- package/package.json +7 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { R as ReportType, A as AnalyticsField } from '../report-BOL9p86o.cjs';
|
|
2
|
+
import { E as ExportTable, a as ExportFilter } from '../types-BzLsgnfc.cjs';
|
|
3
|
+
|
|
4
|
+
interface ReportDocumentSection {
|
|
5
|
+
sheetName: string;
|
|
6
|
+
table?: ExportTable;
|
|
7
|
+
filters?: ExportFilter[];
|
|
8
|
+
}
|
|
9
|
+
interface ReportLocation {
|
|
10
|
+
id: number;
|
|
11
|
+
name: string;
|
|
12
|
+
timezone: string;
|
|
13
|
+
language: string;
|
|
14
|
+
currency: string;
|
|
15
|
+
countryCode: string;
|
|
16
|
+
merchantId: string;
|
|
17
|
+
}
|
|
18
|
+
interface ReportParameters {
|
|
19
|
+
compareToLastWeek?: boolean;
|
|
20
|
+
compareToLastYear?: boolean;
|
|
21
|
+
cols?: string[];
|
|
22
|
+
secondGroupBy?: AnalyticsField;
|
|
23
|
+
startDate: string | Date;
|
|
24
|
+
endDate: string | Date;
|
|
25
|
+
groupBy?: AnalyticsField;
|
|
26
|
+
order?: string;
|
|
27
|
+
}
|
|
28
|
+
type ReportData = SingleReportData | Record<string, SingleReportData>;
|
|
29
|
+
type SingleReportData = Record<string, unknown>[];
|
|
30
|
+
declare class ExportBuilder {
|
|
31
|
+
private readonly reportType;
|
|
32
|
+
private readonly locations;
|
|
33
|
+
private readonly locale;
|
|
34
|
+
constructor(reportType: ReportType, locations: ReportLocation[], locale: string);
|
|
35
|
+
private getFormattingConfig;
|
|
36
|
+
private getConfig;
|
|
37
|
+
private getConfigSectionName;
|
|
38
|
+
private translate;
|
|
39
|
+
private buildColumnPrefix;
|
|
40
|
+
private sortAndPrependPrefix;
|
|
41
|
+
private resolveColumns;
|
|
42
|
+
private getColumnHeader;
|
|
43
|
+
private resolveColumnsAndHeaders;
|
|
44
|
+
private formatField;
|
|
45
|
+
private formatRow;
|
|
46
|
+
private resolveLabelField;
|
|
47
|
+
private buildTotalsRow;
|
|
48
|
+
private getExtraFooterRows;
|
|
49
|
+
private renderTableContent;
|
|
50
|
+
private getDataForConfig;
|
|
51
|
+
private formatMaybeDate;
|
|
52
|
+
private buildMetadata;
|
|
53
|
+
getContent(reportData: ReportData, parameters: ReportParameters, name: string): ReportDocumentSection[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { ExportBuilder, type ReportData, type ReportDocumentSection, type ReportLocation, type ReportParameters, type SingleReportData };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { R as ReportType, A as AnalyticsField } from '../report-BOL9p86o.js';
|
|
2
|
+
import { E as ExportTable, a as ExportFilter } from '../types-BzLsgnfc.js';
|
|
3
|
+
|
|
4
|
+
interface ReportDocumentSection {
|
|
5
|
+
sheetName: string;
|
|
6
|
+
table?: ExportTable;
|
|
7
|
+
filters?: ExportFilter[];
|
|
8
|
+
}
|
|
9
|
+
interface ReportLocation {
|
|
10
|
+
id: number;
|
|
11
|
+
name: string;
|
|
12
|
+
timezone: string;
|
|
13
|
+
language: string;
|
|
14
|
+
currency: string;
|
|
15
|
+
countryCode: string;
|
|
16
|
+
merchantId: string;
|
|
17
|
+
}
|
|
18
|
+
interface ReportParameters {
|
|
19
|
+
compareToLastWeek?: boolean;
|
|
20
|
+
compareToLastYear?: boolean;
|
|
21
|
+
cols?: string[];
|
|
22
|
+
secondGroupBy?: AnalyticsField;
|
|
23
|
+
startDate: string | Date;
|
|
24
|
+
endDate: string | Date;
|
|
25
|
+
groupBy?: AnalyticsField;
|
|
26
|
+
order?: string;
|
|
27
|
+
}
|
|
28
|
+
type ReportData = SingleReportData | Record<string, SingleReportData>;
|
|
29
|
+
type SingleReportData = Record<string, unknown>[];
|
|
30
|
+
declare class ExportBuilder {
|
|
31
|
+
private readonly reportType;
|
|
32
|
+
private readonly locations;
|
|
33
|
+
private readonly locale;
|
|
34
|
+
constructor(reportType: ReportType, locations: ReportLocation[], locale: string);
|
|
35
|
+
private getFormattingConfig;
|
|
36
|
+
private getConfig;
|
|
37
|
+
private getConfigSectionName;
|
|
38
|
+
private translate;
|
|
39
|
+
private buildColumnPrefix;
|
|
40
|
+
private sortAndPrependPrefix;
|
|
41
|
+
private resolveColumns;
|
|
42
|
+
private getColumnHeader;
|
|
43
|
+
private resolveColumnsAndHeaders;
|
|
44
|
+
private formatField;
|
|
45
|
+
private formatRow;
|
|
46
|
+
private resolveLabelField;
|
|
47
|
+
private buildTotalsRow;
|
|
48
|
+
private getExtraFooterRows;
|
|
49
|
+
private renderTableContent;
|
|
50
|
+
private getDataForConfig;
|
|
51
|
+
private formatMaybeDate;
|
|
52
|
+
private buildMetadata;
|
|
53
|
+
getContent(reportData: ReportData, parameters: ReportParameters, name: string): ReportDocumentSection[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { ExportBuilder, type ReportData, type ReportDocumentSection, type ReportLocation, type ReportParameters, type SingleReportData };
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import {
|
|
2
|
+
calculateReportTotals,
|
|
3
|
+
en_US_default,
|
|
4
|
+
formatFieldValue,
|
|
5
|
+
getColumnExportHeaderLabel,
|
|
6
|
+
getColumnMetadata,
|
|
7
|
+
getReportConfig,
|
|
8
|
+
getReportFormattingLocaleOptions,
|
|
9
|
+
resolveTranslate
|
|
10
|
+
} from "../chunk-7NXZJEGU.js";
|
|
11
|
+
|
|
12
|
+
// src/exporters/exportBuilder.ts
|
|
13
|
+
import { format, isValid, parseISO } from "date-fns";
|
|
14
|
+
var ExportBuilder = class {
|
|
15
|
+
constructor(reportType, locations, locale) {
|
|
16
|
+
this.reportType = reportType;
|
|
17
|
+
this.locations = locations;
|
|
18
|
+
this.locale = locale;
|
|
19
|
+
}
|
|
20
|
+
getFormattingConfig() {
|
|
21
|
+
const configs = getReportFormattingLocaleOptions(this.locations);
|
|
22
|
+
return configs[0];
|
|
23
|
+
}
|
|
24
|
+
getConfig() {
|
|
25
|
+
return getReportConfig(this.reportType);
|
|
26
|
+
}
|
|
27
|
+
getConfigSectionName(config) {
|
|
28
|
+
return config.sectionName ? this.translate(config.sectionName) : "Unknown section";
|
|
29
|
+
}
|
|
30
|
+
translate(messageKey) {
|
|
31
|
+
return resolveTranslate(messageKey, this.locale);
|
|
32
|
+
}
|
|
33
|
+
buildColumnPrefix(config, parameters) {
|
|
34
|
+
const prefix = [];
|
|
35
|
+
if ("groupByName" in config.fields) {
|
|
36
|
+
prefix.push("groupByName");
|
|
37
|
+
}
|
|
38
|
+
if (parameters.secondGroupBy && "groupByName2" in config.fields) {
|
|
39
|
+
prefix.push("groupByName2");
|
|
40
|
+
}
|
|
41
|
+
return prefix;
|
|
42
|
+
}
|
|
43
|
+
sortAndPrependPrefix(config, parameters, collected) {
|
|
44
|
+
const orderMap = new Map(config.availableColumns.map((col, i) => [col, i]));
|
|
45
|
+
const sorted = [...collected].sort((a, b) => (orderMap.get(a) ?? Infinity) - (orderMap.get(b) ?? Infinity));
|
|
46
|
+
return [...this.buildColumnPrefix(config, parameters), ...sorted];
|
|
47
|
+
}
|
|
48
|
+
resolveColumns(config, parameters) {
|
|
49
|
+
const selectedGroupIds = Array.isArray(parameters.cols) ? parameters.cols : null;
|
|
50
|
+
const compareToLastWeek = parameters.compareToLastWeek === true;
|
|
51
|
+
const compareToLastYear = parameters.compareToLastYear === true;
|
|
52
|
+
if (selectedGroupIds !== null && selectedGroupIds.length === 0) {
|
|
53
|
+
return this.buildColumnPrefix(config, parameters);
|
|
54
|
+
}
|
|
55
|
+
if (selectedGroupIds?.length && config.columnGroups?.length) {
|
|
56
|
+
const collected = [];
|
|
57
|
+
for (const groupId of selectedGroupIds) {
|
|
58
|
+
const group = config.columnGroups.find((g) => g.id === groupId);
|
|
59
|
+
if (!group) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
collected.push(...group.baseFields);
|
|
63
|
+
if (compareToLastWeek && group.lastWeekFields) {
|
|
64
|
+
collected.push(...group.lastWeekFields);
|
|
65
|
+
}
|
|
66
|
+
if (compareToLastYear && group.lastYearFields) {
|
|
67
|
+
collected.push(...group.lastYearFields);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return this.sortAndPrependPrefix(config, parameters, collected);
|
|
71
|
+
}
|
|
72
|
+
if (!selectedGroupIds && config.columnGroups?.length && (compareToLastWeek || compareToLastYear)) {
|
|
73
|
+
const collected = [];
|
|
74
|
+
for (const col of config.defaultVisibleColumns) {
|
|
75
|
+
collected.push(col);
|
|
76
|
+
const group = config.columnGroups.find((g) => g.baseFields.includes(col));
|
|
77
|
+
if (group) {
|
|
78
|
+
if (compareToLastWeek && group.lastWeekFields) {
|
|
79
|
+
collected.push(...group.lastWeekFields);
|
|
80
|
+
}
|
|
81
|
+
if (compareToLastYear && group.lastYearFields) {
|
|
82
|
+
collected.push(...group.lastYearFields);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return this.sortAndPrependPrefix(config, parameters, collected);
|
|
87
|
+
}
|
|
88
|
+
const metricCols = selectedGroupIds?.length ? config.availableColumns.filter((c) => selectedGroupIds.includes(c)) : config.defaultVisibleColumns;
|
|
89
|
+
return [...this.buildColumnPrefix(config, parameters), ...metricCols];
|
|
90
|
+
}
|
|
91
|
+
getColumnHeader(fieldName, config) {
|
|
92
|
+
const columnKey = config.fields[fieldName]?.columnKey;
|
|
93
|
+
const titleKey = columnKey ? getColumnMetadata(columnKey)?.shortTitleKey : void 0;
|
|
94
|
+
const colHeader = titleKey ? this.translate(titleKey) : fieldName.replace(/([A-Z])/g, " $1").replace(/^./, (c) => c.toUpperCase()).trim();
|
|
95
|
+
const group = config.columnGroups?.find(
|
|
96
|
+
(g) => g.baseFields.includes(fieldName) || (g.lastWeekFields?.includes(fieldName) ?? false) || (g.lastYearFields?.includes(fieldName) ?? false)
|
|
97
|
+
);
|
|
98
|
+
return group ? getColumnExportHeaderLabel(colHeader, this.translate(group.headerTranslationKey)) : colHeader;
|
|
99
|
+
}
|
|
100
|
+
resolveColumnsAndHeaders(parameters, config) {
|
|
101
|
+
const columns = this.resolveColumns(config, parameters);
|
|
102
|
+
const headers = columns.map((col) => {
|
|
103
|
+
if (col === "groupByName2" && parameters.secondGroupBy) {
|
|
104
|
+
return this.translate(`analytics.field.${parameters.secondGroupBy}`);
|
|
105
|
+
}
|
|
106
|
+
return this.getColumnHeader(col, config);
|
|
107
|
+
});
|
|
108
|
+
const columnTypes = columns.map((col) => config.fields[col]);
|
|
109
|
+
return { columns, headers, columnTypes };
|
|
110
|
+
}
|
|
111
|
+
formatField(value, config, localeOption, fullRecord) {
|
|
112
|
+
if (!config || value === void 0 || value === null) {
|
|
113
|
+
return "";
|
|
114
|
+
}
|
|
115
|
+
const formatted = formatFieldValue(value, config.type, localeOption, fullRecord, config);
|
|
116
|
+
return typeof formatted === "string" && formatted in en_US_default ? this.translate(formatted) : formatted;
|
|
117
|
+
}
|
|
118
|
+
formatRow(raw, columns, columnTypes, localeConfig, fullRecord) {
|
|
119
|
+
const formatted = {};
|
|
120
|
+
columns.forEach((col, i) => {
|
|
121
|
+
formatted[col] = this.formatField(raw[col], columnTypes[i], localeConfig, fullRecord);
|
|
122
|
+
});
|
|
123
|
+
return formatted;
|
|
124
|
+
}
|
|
125
|
+
resolveLabelField(config, columns) {
|
|
126
|
+
if ("groupByName" in config.fields) {
|
|
127
|
+
return "groupByName";
|
|
128
|
+
}
|
|
129
|
+
const firstStringCol = columns.find((col) => {
|
|
130
|
+
const field = config.fields[col];
|
|
131
|
+
return field?.type === "string" && !field.footerCalculation;
|
|
132
|
+
});
|
|
133
|
+
return firstStringCol ?? columns[0] ?? "groupByName";
|
|
134
|
+
}
|
|
135
|
+
buildTotalsRow(data, config, columns) {
|
|
136
|
+
if (data.length === 0) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
const labelField = this.resolveLabelField(config, columns);
|
|
140
|
+
const label = config.totalsLabel ? this.translate(config.totalsLabel) : this.translate("table.total");
|
|
141
|
+
return calculateReportTotals(data, config.fields, { labelField, label });
|
|
142
|
+
}
|
|
143
|
+
getExtraFooterRows(data, config, sectionData, columns) {
|
|
144
|
+
if (config.extraFooterRowsKey) {
|
|
145
|
+
if (!Array.isArray(data)) {
|
|
146
|
+
const rows = data[config.extraFooterRowsKey];
|
|
147
|
+
if (Array.isArray(rows)) {
|
|
148
|
+
return rows;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (config.extraFooterFields?.length && sectionData.length > 0) {
|
|
153
|
+
const labelField = this.resolveLabelField(config, columns);
|
|
154
|
+
const totals = calculateReportTotals(sectionData, config.fields, {
|
|
155
|
+
labelField,
|
|
156
|
+
label: this.translate("table.total")
|
|
157
|
+
});
|
|
158
|
+
const row = { [labelField]: totals[labelField] };
|
|
159
|
+
for (const field of config.extraFooterFields) {
|
|
160
|
+
row[field] = totals[field];
|
|
161
|
+
}
|
|
162
|
+
return [row];
|
|
163
|
+
}
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
renderTableContent(config, reportData, parameters) {
|
|
167
|
+
const localeConfig = this.getFormattingConfig();
|
|
168
|
+
const data = this.getDataForConfig(reportData, config);
|
|
169
|
+
const { columns, headers, columnTypes } = this.resolveColumnsAndHeaders(parameters, config);
|
|
170
|
+
const tableColumns = columns.map((col, i) => ({ header: headers[i], key: col }));
|
|
171
|
+
const rows = data.filter((row) => typeof row === "object" && row !== null).map((row) => this.formatRow(row, columns, columnTypes, localeConfig, row));
|
|
172
|
+
if (config.hasFooter) {
|
|
173
|
+
const totalsRow = this.buildTotalsRow(data, config, columns);
|
|
174
|
+
if (totalsRow) {
|
|
175
|
+
rows.push(this.formatRow(totalsRow, columns, columnTypes, localeConfig, null));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
for (const extraRow of this.getExtraFooterRows(reportData, config, data, columns)) {
|
|
179
|
+
rows.push(this.formatRow(extraRow, columns, columnTypes, localeConfig, extraRow));
|
|
180
|
+
}
|
|
181
|
+
return { table: { columns: tableColumns, rows } };
|
|
182
|
+
}
|
|
183
|
+
getDataForConfig(data, config) {
|
|
184
|
+
if (Array.isArray(data)) {
|
|
185
|
+
return data;
|
|
186
|
+
}
|
|
187
|
+
return config.dataAccessKey ? data[config.dataAccessKey] ?? [] : [];
|
|
188
|
+
}
|
|
189
|
+
formatMaybeDate(value) {
|
|
190
|
+
const date = typeof value === "string" ? parseISO(value) : value;
|
|
191
|
+
if (!isValid(date)) {
|
|
192
|
+
return "";
|
|
193
|
+
}
|
|
194
|
+
return format(date, "yyyy-MM-dd");
|
|
195
|
+
}
|
|
196
|
+
buildMetadata(parameters) {
|
|
197
|
+
const rows = [];
|
|
198
|
+
rows.push([
|
|
199
|
+
this.translate("scheduled-reports.period"),
|
|
200
|
+
`${this.formatMaybeDate(parameters.startDate)} - ${this.formatMaybeDate(parameters.endDate)}`
|
|
201
|
+
]);
|
|
202
|
+
if (parameters.groupBy) {
|
|
203
|
+
rows.push([
|
|
204
|
+
this.translate("components.form.field.group-by"),
|
|
205
|
+
this.translate(`analytics.field.${parameters.groupBy}`)
|
|
206
|
+
]);
|
|
207
|
+
}
|
|
208
|
+
const locationNames = this.locations.map((l) => l.name);
|
|
209
|
+
if (locationNames.length > 0) {
|
|
210
|
+
rows.push([this.translate("common.labels.locations"), locationNames.join(", ")]);
|
|
211
|
+
}
|
|
212
|
+
if (parameters.compareToLastWeek === true) {
|
|
213
|
+
rows.push([this.translate("components.form.field.last-week"), this.translate("common.labels.yes")]);
|
|
214
|
+
}
|
|
215
|
+
if (parameters.compareToLastYear === true) {
|
|
216
|
+
rows.push([this.translate("components.form.field.last-year"), this.translate("common.labels.yes")]);
|
|
217
|
+
}
|
|
218
|
+
return rows;
|
|
219
|
+
}
|
|
220
|
+
getContent(reportData, parameters, name) {
|
|
221
|
+
const rawConfig = this.getConfig();
|
|
222
|
+
if (!rawConfig) {
|
|
223
|
+
throw new Error("Missing report config");
|
|
224
|
+
}
|
|
225
|
+
let sections;
|
|
226
|
+
if (Array.isArray(rawConfig)) {
|
|
227
|
+
sections = rawConfig.map((config) => ({
|
|
228
|
+
sheetName: this.getConfigSectionName(config),
|
|
229
|
+
...this.renderTableContent(config, reportData, parameters)
|
|
230
|
+
}));
|
|
231
|
+
} else {
|
|
232
|
+
const metadata = this.buildMetadata(parameters);
|
|
233
|
+
sections = [
|
|
234
|
+
{
|
|
235
|
+
sheetName: name,
|
|
236
|
+
filters: metadata.map(([label, value]) => ({ label, value })),
|
|
237
|
+
...this.renderTableContent(rawConfig, reportData, parameters)
|
|
238
|
+
}
|
|
239
|
+
];
|
|
240
|
+
}
|
|
241
|
+
return sections;
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
export {
|
|
245
|
+
ExportBuilder
|
|
246
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -25,6 +25,9 @@ __export(index_exports, {
|
|
|
25
25
|
DAILY_SALES_REV_CLASS_FOOTER_LABELS: () => DAILY_SALES_REV_CLASS_FOOTER_LABELS,
|
|
26
26
|
REPORT_SECTION_CONFIGS: () => REPORT_SECTION_CONFIGS,
|
|
27
27
|
Report: () => Report,
|
|
28
|
+
TENDER_TYPE: () => TENDER_TYPE,
|
|
29
|
+
buildDailySalesCashPayments: () => buildDailySalesCashPayments,
|
|
30
|
+
buildDailySalesRevClassFooter: () => buildDailySalesRevClassFooter,
|
|
28
31
|
calculateFieldTotal: () => calculateFieldTotal,
|
|
29
32
|
calculateReportTotals: () => calculateReportTotals,
|
|
30
33
|
dailySalesCacheConfig: () => dailySalesCacheConfig,
|
|
@@ -901,8 +904,7 @@ var Report = {
|
|
|
901
904
|
EMPLOYEE_TIP: "employee-tip",
|
|
902
905
|
SALES_BY_ITEM: "sales-by-item",
|
|
903
906
|
DAILY_SALES: "daily-sales",
|
|
904
|
-
DAILY_SALES_LIVE: "daily-sales-live"
|
|
905
|
-
DAILY_SALES_TRENDS: "daily-sales-trends"
|
|
907
|
+
DAILY_SALES_LIVE: "daily-sales-live"
|
|
906
908
|
};
|
|
907
909
|
var DAILY_SALES_SECTION_CONFIGS = [
|
|
908
910
|
dailySalesConfig,
|
|
@@ -925,8 +927,7 @@ var REPORT_CONFIG_MAP = {
|
|
|
925
927
|
"employee-tip": employeeTipConfig,
|
|
926
928
|
"sales-by-item": salesByItemDetailConfig,
|
|
927
929
|
"daily-sales": DAILY_SALES_SECTION_CONFIGS,
|
|
928
|
-
"daily-sales-live": DAILY_SALES_SECTION_CONFIGS
|
|
929
|
-
"daily-sales-trends": null
|
|
930
|
+
"daily-sales-live": DAILY_SALES_SECTION_CONFIGS
|
|
930
931
|
};
|
|
931
932
|
var REPORT_DEFAULT_NAME_MAP = {
|
|
932
933
|
"sales-summary": "Sales",
|
|
@@ -939,8 +940,7 @@ var REPORT_DEFAULT_NAME_MAP = {
|
|
|
939
940
|
"employee-tip": "Employee Tip",
|
|
940
941
|
"sales-by-item": "Sales by Item",
|
|
941
942
|
"daily-sales": "Daily Sales",
|
|
942
|
-
"daily-sales-live": "Daily Sales Live"
|
|
943
|
-
"daily-sales-trends": "Daily Sales Trends"
|
|
943
|
+
"daily-sales-live": "Daily Sales Live"
|
|
944
944
|
};
|
|
945
945
|
var getReportConfig = (reportType) => REPORT_CONFIG_MAP[reportType];
|
|
946
946
|
var getReportExportFileName = ({
|
|
@@ -1897,6 +1897,38 @@ var REPORT_SECTION_CONFIGS = {
|
|
|
1897
1897
|
[Report.DAILY_SALES_LIVE]: DAILY_SALES_SECTIONS
|
|
1898
1898
|
};
|
|
1899
1899
|
|
|
1900
|
+
// src/constants.ts
|
|
1901
|
+
var TENDER_TYPE = {
|
|
1902
|
+
CASH: "Cash",
|
|
1903
|
+
CASH_REFUNDS: "Cash Refunds",
|
|
1904
|
+
UNKNOWN: "Unknown"
|
|
1905
|
+
};
|
|
1906
|
+
|
|
1907
|
+
// src/reports/dailySales.utils.ts
|
|
1908
|
+
var buildDailySalesCashPayments = (payments, paidOutAmount, gratuitiesPaidOutAmount, tipsPaidOutAmount) => [
|
|
1909
|
+
{
|
|
1910
|
+
name: DAILY_SALES_CASH_ROW_LABELS.cashPayments,
|
|
1911
|
+
amount: payments.filter((r) => r.paymentTypeName === TENDER_TYPE.CASH || r.paymentTypeName === TENDER_TYPE.CASH_REFUNDS).reduce((sum, r) => sum + r.paymentsAmount, 0)
|
|
1912
|
+
},
|
|
1913
|
+
{ name: DAILY_SALES_CASH_ROW_LABELS.paidInOuts, amount: paidOutAmount },
|
|
1914
|
+
{ name: DAILY_SALES_CASH_ROW_LABELS.gratuitiesPaidOut, amount: gratuitiesPaidOutAmount },
|
|
1915
|
+
{ name: DAILY_SALES_CASH_ROW_LABELS.ccTipsPaidOut, amount: tipsPaidOutAmount }
|
|
1916
|
+
];
|
|
1917
|
+
var buildDailySalesRevClassFooter = (inputs) => {
|
|
1918
|
+
const totalAccountable = inputs.revClassNetSales + inputs.taxTotal + inputs.gratuitiesTotal + inputs.giftCardSalesTotal - inputs.balancePaymentsTotal + inputs.nonSalesTotal;
|
|
1919
|
+
return [
|
|
1920
|
+
{ groupByName: DAILY_SALES_REV_CLASS_FOOTER_LABELS.taxTotal, salesAmountNet: inputs.taxTotal },
|
|
1921
|
+
{ groupByName: DAILY_SALES_REV_CLASS_FOOTER_LABELS.gratuities, salesAmountNet: inputs.gratuitiesTotal },
|
|
1922
|
+
{
|
|
1923
|
+
groupByName: DAILY_SALES_REV_CLASS_FOOTER_LABELS.balancePayments,
|
|
1924
|
+
salesAmountNet: inputs.balancePaymentsTotal
|
|
1925
|
+
},
|
|
1926
|
+
{ groupByName: DAILY_SALES_REV_CLASS_FOOTER_LABELS.giftCardSales, salesAmountNet: inputs.giftCardSalesTotal },
|
|
1927
|
+
{ groupByName: DAILY_SALES_REV_CLASS_FOOTER_LABELS.nonSalesRevenue, salesAmountNet: inputs.nonSalesTotal },
|
|
1928
|
+
{ groupByName: DAILY_SALES_REV_CLASS_FOOTER_LABELS.totalAccountable, salesAmountNet: totalAccountable }
|
|
1929
|
+
];
|
|
1930
|
+
};
|
|
1931
|
+
|
|
1900
1932
|
// src/translations/crowdin/skytab-analytics-report-utils/en-GB.ts
|
|
1901
1933
|
var enUS = {
|
|
1902
1934
|
"common.report-col.fifteen-min-interval": false,
|
|
@@ -2333,7 +2365,53 @@ var enUS = {
|
|
|
2333
2365
|
"common.report-col.gross-credit-card-tips.info": false,
|
|
2334
2366
|
"common.report-col.type": false,
|
|
2335
2367
|
"common.report-col.type.short": false,
|
|
2336
|
-
"common.report-col.type.info": false
|
|
2368
|
+
"common.report-col.type.info": false,
|
|
2369
|
+
"common.report-section.revenue-class": false,
|
|
2370
|
+
"common.report-section.payments": false,
|
|
2371
|
+
"common.report-section.cash": false,
|
|
2372
|
+
"common.report-section.taxes": false,
|
|
2373
|
+
"common.report-section.refunds-voids": false,
|
|
2374
|
+
"common.report-section.discounts": false,
|
|
2375
|
+
"common.report-section.sales-by-day-part": false,
|
|
2376
|
+
"common.report-section.sales-by-order-type": false,
|
|
2377
|
+
"common.report-section.cash-row.cash-payments": false,
|
|
2378
|
+
"common.report-section.cash-row.paid-in-outs": false,
|
|
2379
|
+
"common.report-section.cash-row.gratuities-paid-out": false,
|
|
2380
|
+
"common.report-section.cash-row.cc-tips-paid-out": false,
|
|
2381
|
+
"common.report-section.trends-footer.total-sales": false,
|
|
2382
|
+
"common.report-section.rev-class-footer.tax-total": false,
|
|
2383
|
+
"common.report-section.rev-class-footer.gratuities": false,
|
|
2384
|
+
"common.report-section.rev-class-footer.balance-payments": false,
|
|
2385
|
+
"common.report-section.rev-class-footer.gift-card-sales": false,
|
|
2386
|
+
"common.report-section.rev-class-footer.non-sales-revenue": false,
|
|
2387
|
+
"common.report-section.rev-class-footer.total-accountable": false,
|
|
2388
|
+
"scheduled-reports.period": false,
|
|
2389
|
+
"components.form.field.group-by": false,
|
|
2390
|
+
"components.form.field.last-week": false,
|
|
2391
|
+
"components.form.field.last-year": false,
|
|
2392
|
+
"common.labels.locations": false,
|
|
2393
|
+
"common.labels.yes": false,
|
|
2394
|
+
// Analytic fields
|
|
2395
|
+
"analytics.field.location_id": false,
|
|
2396
|
+
"analytics.field.order_type_id": false,
|
|
2397
|
+
"analytics.field.revenue_center_id": false,
|
|
2398
|
+
"analytics.field.revenue_center_id.all": false,
|
|
2399
|
+
"analytics.field.hour_id": false,
|
|
2400
|
+
"analytics.field.daypart_id": false,
|
|
2401
|
+
"analytics.field.timeslot_id": false,
|
|
2402
|
+
"analytics.field.employee_id": false,
|
|
2403
|
+
"analytics.field.payroll_id": false,
|
|
2404
|
+
"analytics.field.intraday_period_group": false,
|
|
2405
|
+
"analytics.field.item_id": false,
|
|
2406
|
+
"analytics.field.department_id": false,
|
|
2407
|
+
"analytics.field.revenue_class_id": false,
|
|
2408
|
+
"analytics.field.modifier_id": false,
|
|
2409
|
+
// Common labels
|
|
2410
|
+
"table.total": false,
|
|
2411
|
+
"table.groups.sales": false,
|
|
2412
|
+
"table.groups.net-sales": false,
|
|
2413
|
+
"table.groups.guests": false,
|
|
2414
|
+
"table.groups.sales-per-guest": false
|
|
2337
2415
|
};
|
|
2338
2416
|
var en_GB_default = enUS;
|
|
2339
2417
|
|
|
@@ -2773,7 +2851,53 @@ var enUS2 = {
|
|
|
2773
2851
|
"common.report-col.gross-credit-card-tips.info": false,
|
|
2774
2852
|
"common.report-col.type": false,
|
|
2775
2853
|
"common.report-col.type.short": false,
|
|
2776
|
-
"common.report-col.type.info": false
|
|
2854
|
+
"common.report-col.type.info": false,
|
|
2855
|
+
"common.report-section.revenue-class": false,
|
|
2856
|
+
"common.report-section.payments": false,
|
|
2857
|
+
"common.report-section.cash": false,
|
|
2858
|
+
"common.report-section.taxes": false,
|
|
2859
|
+
"common.report-section.refunds-voids": false,
|
|
2860
|
+
"common.report-section.discounts": false,
|
|
2861
|
+
"common.report-section.sales-by-day-part": false,
|
|
2862
|
+
"common.report-section.sales-by-order-type": false,
|
|
2863
|
+
"common.report-section.cash-row.cash-payments": false,
|
|
2864
|
+
"common.report-section.cash-row.paid-in-outs": false,
|
|
2865
|
+
"common.report-section.cash-row.gratuities-paid-out": false,
|
|
2866
|
+
"common.report-section.cash-row.cc-tips-paid-out": false,
|
|
2867
|
+
"common.report-section.trends-footer.total-sales": false,
|
|
2868
|
+
"common.report-section.rev-class-footer.tax-total": false,
|
|
2869
|
+
"common.report-section.rev-class-footer.gratuities": false,
|
|
2870
|
+
"common.report-section.rev-class-footer.balance-payments": false,
|
|
2871
|
+
"common.report-section.rev-class-footer.gift-card-sales": false,
|
|
2872
|
+
"common.report-section.rev-class-footer.non-sales-revenue": false,
|
|
2873
|
+
"common.report-section.rev-class-footer.total-accountable": false,
|
|
2874
|
+
"scheduled-reports.period": false,
|
|
2875
|
+
"components.form.field.group-by": false,
|
|
2876
|
+
"components.form.field.last-week": false,
|
|
2877
|
+
"components.form.field.last-year": false,
|
|
2878
|
+
"common.labels.locations": false,
|
|
2879
|
+
"common.labels.yes": false,
|
|
2880
|
+
// Analytic fields
|
|
2881
|
+
"analytics.field.location_id": false,
|
|
2882
|
+
"analytics.field.order_type_id": false,
|
|
2883
|
+
"analytics.field.revenue_center_id": false,
|
|
2884
|
+
"analytics.field.revenue_center_id.all": false,
|
|
2885
|
+
"analytics.field.hour_id": false,
|
|
2886
|
+
"analytics.field.daypart_id": false,
|
|
2887
|
+
"analytics.field.timeslot_id": false,
|
|
2888
|
+
"analytics.field.employee_id": false,
|
|
2889
|
+
"analytics.field.payroll_id": false,
|
|
2890
|
+
"analytics.field.intraday_period_group": false,
|
|
2891
|
+
"analytics.field.item_id": false,
|
|
2892
|
+
"analytics.field.department_id": false,
|
|
2893
|
+
"analytics.field.revenue_class_id": false,
|
|
2894
|
+
"analytics.field.modifier_id": false,
|
|
2895
|
+
// Common labels
|
|
2896
|
+
"table.total": false,
|
|
2897
|
+
"table.groups.sales": false,
|
|
2898
|
+
"table.groups.net-sales": false,
|
|
2899
|
+
"table.groups.guests": false,
|
|
2900
|
+
"table.groups.sales-per-guest": false
|
|
2777
2901
|
};
|
|
2778
2902
|
var es_ES_default = enUS2;
|
|
2779
2903
|
|
|
@@ -3213,7 +3337,53 @@ var enUS3 = {
|
|
|
3213
3337
|
"common.report-col.gross-credit-card-tips.info": "Gross credit card tips before any deductions or redistribution",
|
|
3214
3338
|
"common.report-col.type": "Type",
|
|
3215
3339
|
"common.report-col.type.short": "Type",
|
|
3216
|
-
"common.report-col.type.info": " "
|
|
3340
|
+
"common.report-col.type.info": " ",
|
|
3341
|
+
"common.report-section.revenue-class": "Revenue Class",
|
|
3342
|
+
"common.report-section.payments": "Payments",
|
|
3343
|
+
"common.report-section.cash": "Expected Closeout Cash",
|
|
3344
|
+
"common.report-section.taxes": "Taxes",
|
|
3345
|
+
"common.report-section.refunds-voids": "Refunds & Voids",
|
|
3346
|
+
"common.report-section.discounts": "Discounts",
|
|
3347
|
+
"common.report-section.sales-by-day-part": "Sales by Day Part",
|
|
3348
|
+
"common.report-section.sales-by-order-type": "Sales by Order Type",
|
|
3349
|
+
"common.report-section.cash-row.cash-payments": "Cash Payments",
|
|
3350
|
+
"common.report-section.cash-row.paid-in-outs": "Paid-In/Outs",
|
|
3351
|
+
"common.report-section.cash-row.gratuities-paid-out": "Gratuities Paid Out",
|
|
3352
|
+
"common.report-section.cash-row.cc-tips-paid-out": "CC Tips Paid Out",
|
|
3353
|
+
"common.report-section.trends-footer.total-sales": "Total Sales",
|
|
3354
|
+
"common.report-section.rev-class-footer.tax-total": "Tax Total",
|
|
3355
|
+
"common.report-section.rev-class-footer.gratuities": "Gratuities",
|
|
3356
|
+
"common.report-section.rev-class-footer.balance-payments": "Balance Payments",
|
|
3357
|
+
"common.report-section.rev-class-footer.gift-card-sales": "Gift Card Sales",
|
|
3358
|
+
"common.report-section.rev-class-footer.non-sales-revenue": "Non-Sales Revenue",
|
|
3359
|
+
"common.report-section.rev-class-footer.total-accountable": "Total Accountable",
|
|
3360
|
+
"scheduled-reports.period": "Period",
|
|
3361
|
+
"components.form.field.group-by": "Group By",
|
|
3362
|
+
"components.form.field.last-week": "Compare to Last Week",
|
|
3363
|
+
"components.form.field.last-year": "Compare to Last Year",
|
|
3364
|
+
"common.labels.locations": "Locations",
|
|
3365
|
+
"common.labels.yes": "Yes",
|
|
3366
|
+
// Analytic fields
|
|
3367
|
+
"analytics.field.location_id": "Location",
|
|
3368
|
+
"analytics.field.order_type_id": "Order Types",
|
|
3369
|
+
"analytics.field.revenue_center_id": "Revenue Centers",
|
|
3370
|
+
"analytics.field.revenue_center_id.all": "All Revenue Centers",
|
|
3371
|
+
"analytics.field.hour_id": "Hours",
|
|
3372
|
+
"analytics.field.daypart_id": "Day Parts",
|
|
3373
|
+
"analytics.field.timeslot_id": "15 Mins",
|
|
3374
|
+
"analytics.field.employee_id": "Employees",
|
|
3375
|
+
"analytics.field.payroll_id": "Payroll IDs",
|
|
3376
|
+
"analytics.field.intraday_period_group": "Day Parts",
|
|
3377
|
+
"analytics.field.item_id": "Item",
|
|
3378
|
+
"analytics.field.department_id": "Department",
|
|
3379
|
+
"analytics.field.revenue_class_id": "Revenue Class",
|
|
3380
|
+
"analytics.field.modifier_id": "Modifier",
|
|
3381
|
+
// Common labels
|
|
3382
|
+
"table.total": "Total",
|
|
3383
|
+
"table.groups.sales": "Sales",
|
|
3384
|
+
"table.groups.net-sales": "Net Sales",
|
|
3385
|
+
"table.groups.guests": "Guests",
|
|
3386
|
+
"table.groups.sales-per-guest": "Sales / Guest"
|
|
3217
3387
|
};
|
|
3218
3388
|
var en_US_default = enUS3;
|
|
3219
3389
|
|
|
@@ -3382,6 +3552,9 @@ var formatFieldValue = (value, type, localeOptions, fullRecord, fieldConfig = DE
|
|
|
3382
3552
|
DAILY_SALES_REV_CLASS_FOOTER_LABELS,
|
|
3383
3553
|
REPORT_SECTION_CONFIGS,
|
|
3384
3554
|
Report,
|
|
3555
|
+
TENDER_TYPE,
|
|
3556
|
+
buildDailySalesCashPayments,
|
|
3557
|
+
buildDailySalesRevClassFooter,
|
|
3385
3558
|
calculateFieldTotal,
|
|
3386
3559
|
calculateReportTotals,
|
|
3387
3560
|
dailySalesCacheConfig,
|