@harbortouch/skytab-analytics-report-utils 0.38.1 → 0.40.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.
@@ -1,5 +1,5 @@
1
- import { E as ExportSection } from '../../types-BPT5hjCR.cjs';
2
- export { a as XlsxFilter, b as XlsxTable, c as XlsxTableColumn } from '../../types-BPT5hjCR.cjs';
1
+ import { a as ExportSection } from '../../types-MalWTEdo.cjs';
2
+ export { E as XlsxFilter, b as XlsxTable, c as XlsxTableColumn } from '../../types-MalWTEdo.cjs';
3
3
 
4
4
  declare class ExcelExporter {
5
5
  generate(content: {
@@ -1,5 +1,5 @@
1
- import { E as ExportSection } from '../../types-BPT5hjCR.js';
2
- export { a as XlsxFilter, b as XlsxTable, c as XlsxTableColumn } from '../../types-BPT5hjCR.js';
1
+ import { a as ExportSection } from '../../types-MalWTEdo.js';
2
+ export { E as XlsxFilter, b as XlsxTable, c as XlsxTableColumn } from '../../types-MalWTEdo.js';
3
3
 
4
4
  declare class ExcelExporter {
5
5
  generate(content: {
@@ -494,6 +494,9 @@ var enUS = {
494
494
  "common.report-col.total-pay": "Total Pay",
495
495
  "common.report-col.total-pay.short": "Total Pay",
496
496
  "common.report-col.total-pay.info": "Total compensation including wages, overtime, and adjustments",
497
+ "common.report-col.table-name": "Table Name",
498
+ "common.report-col.table-name.short": "Table Name",
499
+ "common.report-col.table-name.info": "Table Name if assigned",
497
500
  "common.report-section.revenue-class": "Sales by Revenue Class",
498
501
  "common.report-section.payments": "Payments",
499
502
  "common.report-section.cash": "Expected Closeout Cash",
@@ -513,12 +516,16 @@ var enUS = {
513
516
  "common.report-section.rev-class-footer.non-sales-revenue": "Non-Sales Revenue",
514
517
  "common.report-section.rev-class-footer.house-account": "House Account",
515
518
  "common.report-section.rev-class-footer.total-accountable": "Total Accountable",
519
+ "scheduled-reports.report-name": "Report",
516
520
  "scheduled-reports.period": "Period",
521
+ "scheduled-reports.generated-at": "Generated at",
522
+ "scheduled-reports.generated-by": "Generated by",
517
523
  "components.form.field.group-by": "Group By",
518
524
  "components.form.field.last-week": "Compare to Last Week",
519
525
  "components.form.field.last-year": "Compare to Last Year",
520
526
  "common.labels.locations": "Locations",
521
527
  "common.labels.yes": "Yes",
528
+ "common.labels.unassigned": "Unassigned",
522
529
  // Analytic fields
523
530
  "analytics.field.location_id": "Location",
524
531
  "analytics.field.order_type_id": "Order Types",
@@ -1018,6 +1025,9 @@ var enUS2 = {
1018
1025
  "common.report-col.total-pay": false,
1019
1026
  "common.report-col.total-pay.short": false,
1020
1027
  "common.report-col.total-pay.info": false,
1028
+ "common.report-col.table-name": false,
1029
+ "common.report-col.table-name.short": false,
1030
+ "common.report-col.table-name.info": false,
1021
1031
  "common.report-section.revenue-class": false,
1022
1032
  "common.report-section.payments": false,
1023
1033
  "common.report-section.cash": false,
@@ -1037,12 +1047,16 @@ var enUS2 = {
1037
1047
  "common.report-section.rev-class-footer.non-sales-revenue": false,
1038
1048
  "common.report-section.rev-class-footer.house-account": false,
1039
1049
  "common.report-section.rev-class-footer.total-accountable": false,
1050
+ "scheduled-reports.report-name": false,
1040
1051
  "scheduled-reports.period": false,
1052
+ "scheduled-reports.generated-at": false,
1053
+ "scheduled-reports.generated-by": false,
1041
1054
  "components.form.field.group-by": false,
1042
1055
  "components.form.field.last-week": false,
1043
1056
  "components.form.field.last-year": false,
1044
1057
  "common.labels.locations": false,
1045
1058
  "common.labels.yes": false,
1059
+ "common.labels.unassigned": false,
1046
1060
  // Analytic fields
1047
1061
  "analytics.field.location_id": false,
1048
1062
  "analytics.field.order_type_id": false,
@@ -1542,6 +1556,9 @@ var enUS3 = {
1542
1556
  "common.report-col.total-pay": false,
1543
1557
  "common.report-col.total-pay.short": false,
1544
1558
  "common.report-col.total-pay.info": false,
1559
+ "common.report-col.table-name": false,
1560
+ "common.report-col.table-name.short": false,
1561
+ "common.report-col.table-name.info": false,
1545
1562
  "common.report-section.revenue-class": false,
1546
1563
  "common.report-section.payments": false,
1547
1564
  "common.report-section.cash": false,
@@ -1561,12 +1578,16 @@ var enUS3 = {
1561
1578
  "common.report-section.rev-class-footer.non-sales-revenue": false,
1562
1579
  "common.report-section.rev-class-footer.house-account": false,
1563
1580
  "common.report-section.rev-class-footer.total-accountable": false,
1581
+ "scheduled-reports.report-name": false,
1564
1582
  "scheduled-reports.period": false,
1583
+ "scheduled-reports.generated-at": false,
1584
+ "scheduled-reports.generated-by": false,
1565
1585
  "components.form.field.group-by": false,
1566
1586
  "components.form.field.last-week": false,
1567
1587
  "components.form.field.last-year": false,
1568
1588
  "common.labels.locations": false,
1569
1589
  "common.labels.yes": false,
1590
+ "common.labels.unassigned": false,
1570
1591
  // Analytic fields
1571
1592
  "analytics.field.location_id": false,
1572
1593
  "analytics.field.order_type_id": false,
@@ -2089,7 +2110,18 @@ var FIELDS3 = {
2089
2110
  filteringAvailable: false
2090
2111
  },
2091
2112
  employeeName: { type: "string", columnKey: "employeeName", filteringAvailable: false },
2092
- orderTypeName: { type: "string", columnKey: "orderType", filteringAvailable: false }
2113
+ orderTypeName: { type: "string", columnKey: "orderType", filteringAvailable: false },
2114
+ tableName: {
2115
+ type: "custom",
2116
+ columnKey: "tableName",
2117
+ enableSorting: false,
2118
+ filteringAvailable: false,
2119
+ customConfiguration: {
2120
+ customFormat: (value, _full, locale) => {
2121
+ return typeof value === "string" && value !== "" ? value : resolveTranslate("common.labels.unassigned", locale);
2122
+ }
2123
+ }
2124
+ }
2093
2125
  };
2094
2126
  var TICKET_SUMMARY_VISIBLE_COLUMNS = [
2095
2127
  "locationName",
@@ -2108,7 +2140,8 @@ var TICKET_SUMMARY_VISIBLE_COLUMNS = [
2108
2140
  "paymentTypeName",
2109
2141
  "guestsCount",
2110
2142
  "employeeName",
2111
- "orderTypeName"
2143
+ "orderTypeName",
2144
+ "tableName"
2112
2145
  ];
2113
2146
  var TICKET_SUMMARY_AVAILABLE_COLUMNS = ["orderNumber", ...TICKET_SUMMARY_VISIBLE_COLUMNS];
2114
2147
  var ticketSummaryConfig = {
@@ -2147,7 +2180,18 @@ var FIELDS4 = {
2147
2180
  },
2148
2181
  customerName: { type: "string", columnKey: "customerName" },
2149
2182
  employeeName: { type: "string", columnKey: "employeeName" },
2150
- orderType: { type: "string", columnKey: "orderType" }
2183
+ orderType: { type: "string", columnKey: "orderType" },
2184
+ tableName: {
2185
+ type: "custom",
2186
+ columnKey: "tableName",
2187
+ enableSorting: false,
2188
+ filteringAvailable: false,
2189
+ customConfiguration: {
2190
+ customFormat: (value, _full, locale) => {
2191
+ return typeof value === "string" && value !== "" ? value : resolveTranslate("common.labels.unassigned", locale);
2192
+ }
2193
+ }
2194
+ }
2151
2195
  };
2152
2196
  var TICKET_LIVE_VISIBLE_COLUMNS = [
2153
2197
  "locationName",
@@ -2166,7 +2210,8 @@ var TICKET_LIVE_VISIBLE_COLUMNS = [
2166
2210
  "paymentTypeName",
2167
2211
  "guestCount",
2168
2212
  "employeeName",
2169
- "orderType"
2213
+ "orderType",
2214
+ "tableName"
2170
2215
  ];
2171
2216
  var TICKET_LIVE_AVAILABLE_COLUMNS = ["orderNumber", ...TICKET_LIVE_VISIBLE_COLUMNS];
2172
2217
  var ticketLiveConfig = {
@@ -3697,6 +3742,11 @@ var COLUMN_REGISTRY = {
3697
3742
  titleKey: "common.report-col.total-pay",
3698
3743
  shortTitleKey: "common.report-col.total-pay.short",
3699
3744
  infoTextKey: "common.report-col.total-pay.info"
3745
+ },
3746
+ tableName: {
3747
+ titleKey: "common.report-col.table-name",
3748
+ shortTitleKey: "common.report-col.table-name.short",
3749
+ infoTextKey: "common.report-col.table-name.info"
3700
3750
  }
3701
3751
  };
3702
3752
  function getColumnMetadata(key) {
@@ -3918,50 +3968,71 @@ var ExportBuilder = class {
3918
3968
  }
3919
3969
  return (0, import_date_fns.format)(date, "yyyy-MM-dd");
3920
3970
  }
3921
- buildMetadata(parameters) {
3922
- const rows = [];
3923
- rows.push([
3924
- this.translate("scheduled-reports.period"),
3925
- `${this.formatMaybeDate(parameters.startDate)} - ${this.formatMaybeDate(parameters.endDate)}`
3926
- ]);
3971
+ buildReportMetadataFilters(parameters, name, meta) {
3972
+ const locationNames = this.locations.map((l) => l.name).join(", ");
3973
+ const period = `${this.formatMaybeDate(parameters.startDate)} - ${this.formatMaybeDate(parameters.endDate)}`;
3974
+ const filters = [
3975
+ { label: this.translate("scheduled-reports.report-name"), value: name },
3976
+ { label: this.translate("common.labels.locations"), value: locationNames },
3977
+ { label: this.translate("scheduled-reports.period"), value: period }
3978
+ ];
3927
3979
  if (parameters.groupBy) {
3928
- rows.push([
3929
- this.translate("components.form.field.group-by"),
3930
- this.translate(`analytics.field.${parameters.groupBy}`)
3931
- ]);
3932
- }
3933
- const locationNames = this.locations.map((l) => l.name);
3934
- if (locationNames.length > 0) {
3935
- rows.push([this.translate("common.labels.locations"), locationNames.join(", ")]);
3980
+ filters.push({
3981
+ label: this.translate("components.form.field.group-by"),
3982
+ value: this.translate(`analytics.field.${parameters.groupBy}`)
3983
+ });
3936
3984
  }
3937
3985
  if (parameters.compareToLastWeek === true) {
3938
- rows.push([this.translate("components.form.field.last-week"), this.translate("common.labels.yes")]);
3986
+ filters.push({
3987
+ label: this.translate("components.form.field.last-week"),
3988
+ value: this.translate("common.labels.yes")
3989
+ });
3939
3990
  }
3940
3991
  if (parameters.compareToLastYear === true) {
3941
- rows.push([this.translate("components.form.field.last-year"), this.translate("common.labels.yes")]);
3992
+ filters.push({
3993
+ label: this.translate("components.form.field.last-year"),
3994
+ value: this.translate("common.labels.yes")
3995
+ });
3996
+ }
3997
+ if (meta.generatedAt) {
3998
+ const formatted = new Intl.DateTimeFormat(this.locale, {
3999
+ year: "numeric",
4000
+ month: "short",
4001
+ day: "numeric",
4002
+ hour: "numeric",
4003
+ minute: "2-digit",
4004
+ timeZoneName: "short"
4005
+ }).format(meta.generatedAt);
4006
+ filters.push({ label: this.translate("scheduled-reports.generated-at"), value: formatted });
4007
+ }
4008
+ if (meta.generatedBy.email) {
4009
+ filters.push({ label: this.translate("scheduled-reports.generated-by"), value: meta.generatedBy.email });
3942
4010
  }
3943
- return rows;
4011
+ return filters.filter(({ value }) => value !== "");
3944
4012
  }
3945
- getContent(reportData, parameters, name) {
4013
+ getContent(reportData, parameters, name, metadata, appliedFilters) {
3946
4014
  const rawConfig = this.getConfig();
3947
4015
  if (!rawConfig) {
3948
4016
  throw new Error("Missing report config");
3949
4017
  }
4018
+ const metadataFilters = this.buildReportMetadataFilters(parameters, name, metadata);
4019
+ const resolvedAppliedFilters = appliedFilters ?? [];
3950
4020
  let sections;
3951
4021
  if (Array.isArray(rawConfig)) {
3952
4022
  const sectionParameters = { ...parameters, cols: void 0 };
3953
- sections = rawConfig.map((config) => {
3954
- return {
4023
+ sections = [
4024
+ { title: name, filters: metadataFilters, appliedFilters: resolvedAppliedFilters },
4025
+ ...rawConfig.map((config) => ({
3955
4026
  title: this.getConfigSectionName(config),
3956
4027
  ...this.renderTableContent(config, reportData, sectionParameters)
3957
- };
3958
- });
4028
+ }))
4029
+ ];
3959
4030
  } else {
3960
- const metadata = this.buildMetadata(parameters);
3961
4031
  sections = [
3962
4032
  {
3963
4033
  title: name,
3964
- filters: metadata.map(([label, value]) => ({ label, value })),
4034
+ filters: metadataFilters,
4035
+ appliedFilters: resolvedAppliedFilters,
3965
4036
  ...this.renderTableContent(rawConfig, reportData, parameters)
3966
4037
  }
3967
4038
  ];
@@ -1,5 +1,5 @@
1
- import { R as ReportType, A as AnalyticsField } from '../report-ZRoya9wR.cjs';
2
- import { E as ExportSection } from '../types-BPT5hjCR.cjs';
1
+ import { R as ReportType, A as AnalyticsField } from '../report-BNVH_1-b.cjs';
2
+ import { R as ReportMetadata, E as ExportFilter, a as ExportSection } from '../types-MalWTEdo.cjs';
3
3
 
4
4
  type ReportDocumentSection = ExportSection;
5
5
  interface ReportLocation {
@@ -45,8 +45,8 @@ declare class ExportBuilder {
45
45
  private renderTableContent;
46
46
  private getDataForConfig;
47
47
  private formatMaybeDate;
48
- private buildMetadata;
49
- getContent(reportData: ReportData, parameters: ReportParameters, name: string): ExportSection[];
48
+ private buildReportMetadataFilters;
49
+ getContent(reportData: ReportData, parameters: ReportParameters, name: string, metadata: ReportMetadata, appliedFilters?: ExportFilter[]): ExportSection[];
50
50
  }
51
51
 
52
- export { ExportBuilder, type ReportData, type ReportDocumentSection, type ReportLocation, type ReportParameters, type SingleReportData };
52
+ export { ExportBuilder, type ReportData, type ReportDocumentSection, type ReportLocation, ReportMetadata, type ReportParameters, ReportType, type SingleReportData };
@@ -1,5 +1,5 @@
1
- import { R as ReportType, A as AnalyticsField } from '../report-ZRoya9wR.js';
2
- import { E as ExportSection } from '../types-BPT5hjCR.js';
1
+ import { R as ReportType, A as AnalyticsField } from '../report-BNVH_1-b.js';
2
+ import { R as ReportMetadata, E as ExportFilter, a as ExportSection } from '../types-MalWTEdo.js';
3
3
 
4
4
  type ReportDocumentSection = ExportSection;
5
5
  interface ReportLocation {
@@ -45,8 +45,8 @@ declare class ExportBuilder {
45
45
  private renderTableContent;
46
46
  private getDataForConfig;
47
47
  private formatMaybeDate;
48
- private buildMetadata;
49
- getContent(reportData: ReportData, parameters: ReportParameters, name: string): ExportSection[];
48
+ private buildReportMetadataFilters;
49
+ getContent(reportData: ReportData, parameters: ReportParameters, name: string, metadata: ReportMetadata, appliedFilters?: ExportFilter[]): ExportSection[];
50
50
  }
51
51
 
52
- export { ExportBuilder, type ReportData, type ReportDocumentSection, type ReportLocation, type ReportParameters, type SingleReportData };
52
+ export { ExportBuilder, type ReportData, type ReportDocumentSection, type ReportLocation, ReportMetadata, type ReportParameters, ReportType, type SingleReportData };
@@ -7,7 +7,7 @@ import {
7
7
  getReportConfig,
8
8
  getReportFormattingLocaleOptions,
9
9
  resolveTranslate
10
- } from "../chunk-MFOOIOP4.js";
10
+ } from "../chunk-HKSLZ6DJ.js";
11
11
 
12
12
  // src/exporters/exportBuilder.ts
13
13
  import { format, isValid, parseISO } from "date-fns";
@@ -158,50 +158,71 @@ var ExportBuilder = class {
158
158
  }
159
159
  return format(date, "yyyy-MM-dd");
160
160
  }
161
- buildMetadata(parameters) {
162
- const rows = [];
163
- rows.push([
164
- this.translate("scheduled-reports.period"),
165
- `${this.formatMaybeDate(parameters.startDate)} - ${this.formatMaybeDate(parameters.endDate)}`
166
- ]);
161
+ buildReportMetadataFilters(parameters, name, meta) {
162
+ const locationNames = this.locations.map((l) => l.name).join(", ");
163
+ const period = `${this.formatMaybeDate(parameters.startDate)} - ${this.formatMaybeDate(parameters.endDate)}`;
164
+ const filters = [
165
+ { label: this.translate("scheduled-reports.report-name"), value: name },
166
+ { label: this.translate("common.labels.locations"), value: locationNames },
167
+ { label: this.translate("scheduled-reports.period"), value: period }
168
+ ];
167
169
  if (parameters.groupBy) {
168
- rows.push([
169
- this.translate("components.form.field.group-by"),
170
- this.translate(`analytics.field.${parameters.groupBy}`)
171
- ]);
172
- }
173
- const locationNames = this.locations.map((l) => l.name);
174
- if (locationNames.length > 0) {
175
- rows.push([this.translate("common.labels.locations"), locationNames.join(", ")]);
170
+ filters.push({
171
+ label: this.translate("components.form.field.group-by"),
172
+ value: this.translate(`analytics.field.${parameters.groupBy}`)
173
+ });
176
174
  }
177
175
  if (parameters.compareToLastWeek === true) {
178
- rows.push([this.translate("components.form.field.last-week"), this.translate("common.labels.yes")]);
176
+ filters.push({
177
+ label: this.translate("components.form.field.last-week"),
178
+ value: this.translate("common.labels.yes")
179
+ });
179
180
  }
180
181
  if (parameters.compareToLastYear === true) {
181
- rows.push([this.translate("components.form.field.last-year"), this.translate("common.labels.yes")]);
182
+ filters.push({
183
+ label: this.translate("components.form.field.last-year"),
184
+ value: this.translate("common.labels.yes")
185
+ });
186
+ }
187
+ if (meta.generatedAt) {
188
+ const formatted = new Intl.DateTimeFormat(this.locale, {
189
+ year: "numeric",
190
+ month: "short",
191
+ day: "numeric",
192
+ hour: "numeric",
193
+ minute: "2-digit",
194
+ timeZoneName: "short"
195
+ }).format(meta.generatedAt);
196
+ filters.push({ label: this.translate("scheduled-reports.generated-at"), value: formatted });
182
197
  }
183
- return rows;
198
+ if (meta.generatedBy.email) {
199
+ filters.push({ label: this.translate("scheduled-reports.generated-by"), value: meta.generatedBy.email });
200
+ }
201
+ return filters.filter(({ value }) => value !== "");
184
202
  }
185
- getContent(reportData, parameters, name) {
203
+ getContent(reportData, parameters, name, metadata, appliedFilters) {
186
204
  const rawConfig = this.getConfig();
187
205
  if (!rawConfig) {
188
206
  throw new Error("Missing report config");
189
207
  }
208
+ const metadataFilters = this.buildReportMetadataFilters(parameters, name, metadata);
209
+ const resolvedAppliedFilters = appliedFilters ?? [];
190
210
  let sections;
191
211
  if (Array.isArray(rawConfig)) {
192
212
  const sectionParameters = { ...parameters, cols: void 0 };
193
- sections = rawConfig.map((config) => {
194
- return {
213
+ sections = [
214
+ { title: name, filters: metadataFilters, appliedFilters: resolvedAppliedFilters },
215
+ ...rawConfig.map((config) => ({
195
216
  title: this.getConfigSectionName(config),
196
217
  ...this.renderTableContent(config, reportData, sectionParameters)
197
- };
198
- });
218
+ }))
219
+ ];
199
220
  } else {
200
- const metadata = this.buildMetadata(parameters);
201
221
  sections = [
202
222
  {
203
223
  title: name,
204
- filters: metadata.map(([label, value]) => ({ label, value })),
224
+ filters: metadataFilters,
225
+ appliedFilters: resolvedAppliedFilters,
205
226
  ...this.renderTableContent(rawConfig, reportData, parameters)
206
227
  }
207
228
  ];