@harbortouch/skytab-analytics-report-utils 0.8.1 → 0.9.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/index.cjs CHANGED
@@ -509,7 +509,16 @@ var FIELDS6 = {
509
509
  orderTypeName: { type: "string", columnKey: "orderType", filteringAvailable: false },
510
510
  taxName: { type: "string", columnKey: "taxName", filteringAvailable: false },
511
511
  taxValue: { type: "money", columnKey: "taxableSales" },
512
- taxRate: { type: "number", columnKey: "taxRate" },
512
+ taxRate: {
513
+ type: "conditional",
514
+ columnKey: "taxRate",
515
+ conditionalConfiguration: {
516
+ conditionalField: "taxIsFlat",
517
+ conditionalFormat: (field) => {
518
+ return field ? "money" : "percent";
519
+ }
520
+ }
521
+ },
513
522
  recordsCount: { type: "number", columnKey: "quantity" },
514
523
  taxableSales: { type: "money", columnKey: "taxableSales" },
515
524
  totalCollected: { type: "money", columnKey: "totalCollected" },
@@ -658,11 +667,13 @@ var dailySalesPaymentsConfig = {
658
667
  var FIRST_COLUMN_WIDTH6 = 240;
659
668
  var FIELDS9 = {
660
669
  discountName: { type: "string", columnKey: "discountName", size: FIRST_COLUMN_WIDTH6 },
661
- discountsCount: { type: "number", columnKey: "discountCount", footerCalculation: { type: "sum" } },
670
+ ticketCount: { type: "number", columnKey: "ticketCount", footerCalculation: { type: "sum" } },
671
+ itemCount: { type: "number", columnKey: "itemCount", footerCalculation: { type: "sum" } },
662
672
  discountsAmount: { type: "money", columnKey: "discountAmount", footerCalculation: { type: "sum" } }
663
673
  };
664
674
  var DAILY_SALES_DISCOUNTS_AVAILABLE_COLUMNS = [
665
- "discountsCount",
675
+ "ticketCount",
676
+ "itemCount",
666
677
  "discountsAmount"
667
678
  ];
668
679
  var DAILY_SALES_DISCOUNTS_DEFAULT_VISIBLE_COLUMNS = DAILY_SALES_DISCOUNTS_AVAILABLE_COLUMNS;
@@ -970,10 +981,15 @@ var COLUMN_REGISTRY = {
970
981
  shortTitleKey: "common.report-col.discount-amount.short",
971
982
  infoTextKey: "common.report-col.discount-amount.info"
972
983
  },
973
- discountCount: {
974
- titleKey: "common.report-col.discount-count",
975
- shortTitleKey: "common.report-col.discount-count.short",
976
- infoTextKey: "common.report-col.discount-count.info"
984
+ ticketCount: {
985
+ titleKey: "common.report-col.ticket-count",
986
+ shortTitleKey: "common.report-col.ticket-count.short",
987
+ infoTextKey: "common.report-col.ticket-count.info"
988
+ },
989
+ itemCount: {
990
+ titleKey: "common.report-col.item-count",
991
+ shortTitleKey: "common.report-col.item-count.short",
992
+ infoTextKey: "common.report-col.item-count.info"
977
993
  },
978
994
  discover: {
979
995
  titleKey: "common.report-col.discover",
@@ -1713,9 +1729,18 @@ var getReportFormattingLocaleOptions = (locations) => {
1713
1729
  ).values()
1714
1730
  );
1715
1731
  };
1716
- var formatFieldValue = (value, type, localeOptions) => {
1732
+ var DEFAULT_FIELD_CONFIG = { type: "string" };
1733
+ var formatFieldValue = (value, type, localeOptions, fullRecord, fieldConfig = DEFAULT_FIELD_CONFIG) => {
1717
1734
  const { currency, locale } = localeOptions;
1718
1735
  switch (type) {
1736
+ case "conditional": {
1737
+ if (!fullRecord) {
1738
+ return formatString(value);
1739
+ }
1740
+ const conditionalConfig = fieldConfig.conditionalConfiguration;
1741
+ const configType = conditionalConfig.conditionalFormat(fullRecord[conditionalConfig.conditionalField]);
1742
+ return formatFieldValue(value, configType, localeOptions, fullRecord, fieldConfig);
1743
+ }
1719
1744
  case "string":
1720
1745
  return formatString(value);
1721
1746
  case "money":
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- type ReportColumnKey = 'fifteenMinInterval' | 'adjustedTips' | 'advantageProgram' | 'amex' | 'amexReturns' | 'attachRate' | 'autoGratuity' | 'averageGrossPrice' | 'bankFees' | 'batchAmount' | 'batchDate' | 'batchNumber' | 'clockInTime' | 'clockOutTime' | 'country' | 'customerName' | 'date' | 'dateClose' | 'daypart' | 'debit' | 'debitReturns' | 'declaredTips' | 'department' | 'depositCurrency' | 'depositDate' | 'discountAmount' | 'discountCount' | 'discover' | 'discoverReturns' | 'ebt' | 'ebtReturns' | 'employeeId' | 'employeeJob' | 'employeeName' | 'exemptTaxes' | 'grandTotal' | 'grossCashSales' | 'grossCashTips' | 'grossCreditCardTips' | 'grossCreditSales' | 'grossSales' | 'grossTips' | 'guestCount' | 'guestsVarLw' | 'guestsVarLwPct' | 'guestsVarLy' | 'guestsVarLyPct' | 'hour' | 'hoursWorked' | 'inclusiveTax' | 'itemName' | 'itemPrice' | 'locationCity' | 'locationId' | 'locationMid' | 'locationName' | 'locationState' | 'mastercard' | 'mcReturns' | 'modifierName' | 'modifierPrice' | 'modifierQuantity' | 'netSales' | 'netTaxCollected' | 'netTips' | 'numberOfGuests' | 'orderType' | 'paymentType' | 'payrollId' | 'quantity' | 'referenceNumber' | 'refundAmount' | 'refundedTaxAmount' | 'revenueCenter' | 'revenueClass' | 'salesVarLw' | 'salesVarLwPct' | 'salesVarLy' | 'salesVarLyPct' | 'salesMixByPct' | 'salesPerGuest' | 'salesPerGuestLw' | 'salesPerGuestLy' | 'scheduledShiftEnd' | 'scheduledShiftStart' | 'settlementBatchDate' | 'shiftDurationHrs' | 'subtotal' | 'taxCollected' | 'taxName' | 'taxRate' | 'taxableSales' | 'ticketClosed' | 'ticketFee' | 'ticketNumber' | 'ticketOpen' | 'ticketTotal' | 'timeOpenMins' | 'tipPct' | 'tipReduction' | 'tipShare' | 'tips' | 'tipsPerHour' | 'totalCollected' | 'totalItemSales' | 'totalModifierSales' | 'totalReturns' | 'totalSales' | 'totalTips' | 'transactionDate' | 'transactionType' | 'untaxedSales' | 'visa' | 'visaReturns' | 'paymentsCount' | 'paymentsAmount' | 'paymentsTotal' | 'refundVoidDescription' | 'refundVoidCount' | 'refundVoidAmount' | 'refundVoidPctSales' | 'discountName' | 'tickets' | 'guests' | 'ticketAverage' | 'guestAverage' | 'net' | 'salePaymentType' | 'status';
1
+ type ReportColumnKey = 'fifteenMinInterval' | 'adjustedTips' | 'advantageProgram' | 'amex' | 'amexReturns' | 'attachRate' | 'autoGratuity' | 'averageGrossPrice' | 'bankFees' | 'batchAmount' | 'batchDate' | 'batchNumber' | 'clockInTime' | 'clockOutTime' | 'country' | 'customerName' | 'date' | 'dateClose' | 'daypart' | 'debit' | 'debitReturns' | 'declaredTips' | 'department' | 'depositCurrency' | 'depositDate' | 'discountAmount' | 'ticketCount' | 'itemCount' | 'discover' | 'discoverReturns' | 'ebt' | 'ebtReturns' | 'employeeId' | 'employeeJob' | 'employeeName' | 'exemptTaxes' | 'grandTotal' | 'grossCashSales' | 'grossCashTips' | 'grossCreditCardTips' | 'grossCreditSales' | 'grossSales' | 'grossTips' | 'guestCount' | 'guestsVarLw' | 'guestsVarLwPct' | 'guestsVarLy' | 'guestsVarLyPct' | 'hour' | 'hoursWorked' | 'inclusiveTax' | 'itemName' | 'itemPrice' | 'locationCity' | 'locationId' | 'locationMid' | 'locationName' | 'locationState' | 'mastercard' | 'mcReturns' | 'modifierName' | 'modifierPrice' | 'modifierQuantity' | 'netSales' | 'netTaxCollected' | 'netTips' | 'numberOfGuests' | 'orderType' | 'paymentType' | 'payrollId' | 'quantity' | 'referenceNumber' | 'refundAmount' | 'refundedTaxAmount' | 'revenueCenter' | 'revenueClass' | 'salesVarLw' | 'salesVarLwPct' | 'salesVarLy' | 'salesVarLyPct' | 'salesMixByPct' | 'salesPerGuest' | 'salesPerGuestLw' | 'salesPerGuestLy' | 'scheduledShiftEnd' | 'scheduledShiftStart' | 'settlementBatchDate' | 'shiftDurationHrs' | 'subtotal' | 'taxCollected' | 'taxName' | 'taxRate' | 'taxableSales' | 'ticketClosed' | 'ticketFee' | 'ticketNumber' | 'ticketOpen' | 'ticketTotal' | 'timeOpenMins' | 'tipPct' | 'tipReduction' | 'tipShare' | 'tips' | 'tipsPerHour' | 'totalCollected' | 'totalItemSales' | 'totalModifierSales' | 'totalReturns' | 'totalSales' | 'totalTips' | 'transactionDate' | 'transactionType' | 'untaxedSales' | 'visa' | 'visaReturns' | 'paymentsCount' | 'paymentsAmount' | 'paymentsTotal' | 'refundVoidDescription' | 'refundVoidCount' | 'refundVoidAmount' | 'refundVoidPctSales' | 'discountName' | 'tickets' | 'guests' | 'ticketAverage' | 'guestAverage' | 'net' | 'salePaymentType' | 'status';
2
2
  interface ColumnMetadata {
3
3
  titleKey: string;
4
4
  shortTitleKey: string;
@@ -135,10 +135,15 @@ declare const COLUMN_REGISTRY: {
135
135
  readonly shortTitleKey: "common.report-col.discount-amount.short";
136
136
  readonly infoTextKey: "common.report-col.discount-amount.info";
137
137
  };
138
- readonly discountCount: {
139
- readonly titleKey: "common.report-col.discount-count";
140
- readonly shortTitleKey: "common.report-col.discount-count.short";
141
- readonly infoTextKey: "common.report-col.discount-count.info";
138
+ readonly ticketCount: {
139
+ readonly titleKey: "common.report-col.ticket-count";
140
+ readonly shortTitleKey: "common.report-col.ticket-count.short";
141
+ readonly infoTextKey: "common.report-col.ticket-count.info";
142
+ };
143
+ readonly itemCount: {
144
+ readonly titleKey: "common.report-col.item-count";
145
+ readonly shortTitleKey: "common.report-col.item-count.short";
146
+ readonly infoTextKey: "common.report-col.item-count.info";
142
147
  };
143
148
  readonly discover: {
144
149
  readonly titleKey: "common.report-col.discover";
@@ -756,9 +761,13 @@ declare function getColumnMetadata(key: ReportColumnKey): {
756
761
  readonly shortTitleKey: "common.report-col.discount-amount.short";
757
762
  readonly infoTextKey: "common.report-col.discount-amount.info";
758
763
  } | {
759
- readonly titleKey: "common.report-col.discount-count";
760
- readonly shortTitleKey: "common.report-col.discount-count.short";
761
- readonly infoTextKey: "common.report-col.discount-count.info";
764
+ readonly titleKey: "common.report-col.ticket-count";
765
+ readonly shortTitleKey: "common.report-col.ticket-count.short";
766
+ readonly infoTextKey: "common.report-col.ticket-count.info";
767
+ } | {
768
+ readonly titleKey: "common.report-col.item-count";
769
+ readonly shortTitleKey: "common.report-col.item-count.short";
770
+ readonly infoTextKey: "common.report-col.item-count.info";
762
771
  } | {
763
772
  readonly titleKey: "common.report-col.discover";
764
773
  readonly shortTitleKey: "common.report-col.discover.short";
@@ -1170,7 +1179,7 @@ declare function getColumnMetadata(key: ReportColumnKey): {
1170
1179
  };
1171
1180
  declare function getColumnExportHeaderLabel(colTitle: string, groupTitle: string | null): string;
1172
1181
 
1173
- type FieldType = 'string' | 'money' | 'percent' | 'number' | 'fixedNumber' | 'date' | 'time' | 'boolean';
1182
+ type FieldType = 'string' | 'money' | 'percent' | 'number' | 'fixedNumber' | 'date' | 'time' | 'boolean' | 'conditional';
1174
1183
  type ColumnAlignment = 'left' | 'right';
1175
1184
  type FooterCalculationType = 'sum' | 'percentChange' | 'average' | 'none';
1176
1185
  interface FooterCalculation<TField = string> {
@@ -1178,14 +1187,24 @@ interface FooterCalculation<TField = string> {
1178
1187
  numeratorField?: TField;
1179
1188
  denominatorField?: TField;
1180
1189
  }
1181
- interface ColumnPresentationConfig<TField = string> {
1190
+ interface ConditionalConfiguration<TField = string> {
1191
+ conditionalField: TField;
1192
+ conditionalFormat: (value: unknown) => Exclude<FieldType, 'conditional'>;
1193
+ }
1194
+ interface BaseColumnPresentationConfig<TField = string> {
1182
1195
  columnKey?: ReportColumnKey;
1183
- type: FieldType;
1184
1196
  size?: number;
1185
1197
  enableSorting?: boolean;
1186
1198
  filteringAvailable?: boolean;
1187
1199
  footerCalculation?: FooterCalculation<TField>;
1188
1200
  }
1201
+ type ColumnPresentationConfig<TField = string> = (BaseColumnPresentationConfig<TField> & {
1202
+ type: Exclude<FieldType, 'conditional'>;
1203
+ conditionalConfiguration?: never;
1204
+ }) | (BaseColumnPresentationConfig<TField> & {
1205
+ type: 'conditional';
1206
+ conditionalConfiguration: ConditionalConfiguration<TField>;
1207
+ });
1189
1208
  interface ColumnGroupConfig {
1190
1209
  id: string;
1191
1210
  headerTranslationKey: string;
@@ -1269,7 +1288,7 @@ declare const DAILY_SALES_PAYMENTS_AVAILABLE_COLUMNS: DailySalesPaymentsField[];
1269
1288
  declare const DAILY_SALES_PAYMENTS_DEFAULT_VISIBLE_COLUMNS: DailySalesPaymentsField[];
1270
1289
  declare const dailySalesPaymentsConfig: ReportConfig<DailySalesPaymentsField>;
1271
1290
 
1272
- type DailySalesDiscountsField = 'discountName' | 'discountsCount' | 'discountsAmount';
1291
+ type DailySalesDiscountsField = 'discountName' | 'ticketCount' | 'itemCount' | 'discountsAmount';
1273
1292
  declare const DAILY_SALES_DISCOUNTS_AVAILABLE_COLUMNS: DailySalesDiscountsField[];
1274
1293
  declare const DAILY_SALES_DISCOUNTS_DEFAULT_VISIBLE_COLUMNS: DailySalesDiscountsField[];
1275
1294
  declare const dailySalesDiscountsConfig: ReportConfig<DailySalesDiscountsField>;
@@ -1333,6 +1352,6 @@ declare const getReportFormattingLocaleOptions: (locations: {
1333
1352
  countryCode: string;
1334
1353
  language: string;
1335
1354
  }[]) => LocaleOption[];
1336
- declare const formatFieldValue: (value: unknown, type: FieldType, localeOptions: LocaleOption) => string;
1355
+ declare const formatFieldValue: (value: unknown, type: FieldType, localeOptions: LocaleOption, fullRecord: Record<string, unknown> | null, fieldConfig?: ColumnPresentationConfig) => string;
1337
1356
 
1338
1357
  export { COLUMN_REGISTRY, type CalculateReportTotalsOptions, type ColumnAlignment, type ColumnGroupConfig, type ColumnMetadata, type ColumnPresentationConfig, DAILY_SALES_AVAILABLE_COLUMNS, DAILY_SALES_BY_GROUP_AVAILABLE_COLUMNS, DAILY_SALES_DEFAULT_VISIBLE_COLUMNS, DAILY_SALES_DISCOUNTS_AVAILABLE_COLUMNS, DAILY_SALES_DISCOUNTS_DEFAULT_VISIBLE_COLUMNS, DAILY_SALES_PAYMENTS_AVAILABLE_COLUMNS, DAILY_SALES_PAYMENTS_DEFAULT_VISIBLE_COLUMNS, DAILY_SALES_REFUNDS_VOIDS_AVAILABLE_COLUMNS, DAILY_SALES_REFUNDS_VOIDS_DEFAULT_VISIBLE_COLUMNS, DAILY_SALES_TAXES_AVAILABLE_COLUMNS, DAILY_SALES_TAXES_DEFAULT_VISIBLE_COLUMNS, DAILY_SALES_TRENDS_AVAILABLE_COLUMNS, EMPLOYEE_TIMECARD_AVAILABLE_COLUMNS, EMPLOYEE_TIMECARD_DEFAULT_VISIBLE_COLUMNS, type FieldType, type FooterCalculation, type FooterCalculationType, type FormatDateOptions, type FormatMoneyOptions, type FormatNumberOptions, type FormatTimeOptions, ITEM_TAX_AVAILABLE_COLUMNS, ITEM_TAX_DEFAULT_VISIBLE_COLUMNS, type LocaleOption, MODIFIER_MIX_AVAILABLE_COLUMNS, MODIFIER_MIX_DEFAULT_VISIBLE_COLUMNS, PRODUCT_MIX_AVAILABLE_COLUMNS, PRODUCT_MIX_CHART_FIELDS, PRODUCT_MIX_DEFAULT_VISIBLE_COLUMNS, Report, type ReportColumnKey, type ReportConfig, type ReportType, SALES_BY_ITEM_DETAIL_AVAILABLE_COLUMNS, SALES_BY_ITEM_DETAIL_DEFAULT_VISIBLE_COLUMNS, SALES_SUMMARY_AVAILABLE_COLUMNS, SALES_SUMMARY_DEFAULT_VISIBLE_COLUMNS, TICKET_LIVE_AVAILABLE_COLUMNS, TICKET_LIVE_DEFAULT_VISIBLE_COLUMNS, TICKET_SUMMARY_AVAILABLE_COLUMNS, TICKET_SUMMARY_DEFAULT_VISIBLE_COLUMNS, type TimeFormat, calculateReportTotals, dailySalesConfig, dailySalesDiscountsConfig, dailySalesPaymentsConfig, dailySalesRefundsVoidsConfig, dailySalesTaxesConfig, dailySalesTrendsConfig, employeeTimecardConfig, formatDate, formatFieldValue, formatFixedNumber, formatInteger, formatMoney, formatMoneyWithoutSymbol, formatPercent, formatString, formatTime, getColumnAlignment, getColumnExportHeaderLabel, getColumnMetadata, getDateToFormat, getNumberToFormat, getReportConfig, getReportFormattingLocaleOptions, isNumericType, itemTaxConfig, modifierMixConfig, productMixConfig, salesByItemDetailConfig, salesSummaryConfig, ticketLiveConfig, ticketSummaryConfig };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- type ReportColumnKey = 'fifteenMinInterval' | 'adjustedTips' | 'advantageProgram' | 'amex' | 'amexReturns' | 'attachRate' | 'autoGratuity' | 'averageGrossPrice' | 'bankFees' | 'batchAmount' | 'batchDate' | 'batchNumber' | 'clockInTime' | 'clockOutTime' | 'country' | 'customerName' | 'date' | 'dateClose' | 'daypart' | 'debit' | 'debitReturns' | 'declaredTips' | 'department' | 'depositCurrency' | 'depositDate' | 'discountAmount' | 'discountCount' | 'discover' | 'discoverReturns' | 'ebt' | 'ebtReturns' | 'employeeId' | 'employeeJob' | 'employeeName' | 'exemptTaxes' | 'grandTotal' | 'grossCashSales' | 'grossCashTips' | 'grossCreditCardTips' | 'grossCreditSales' | 'grossSales' | 'grossTips' | 'guestCount' | 'guestsVarLw' | 'guestsVarLwPct' | 'guestsVarLy' | 'guestsVarLyPct' | 'hour' | 'hoursWorked' | 'inclusiveTax' | 'itemName' | 'itemPrice' | 'locationCity' | 'locationId' | 'locationMid' | 'locationName' | 'locationState' | 'mastercard' | 'mcReturns' | 'modifierName' | 'modifierPrice' | 'modifierQuantity' | 'netSales' | 'netTaxCollected' | 'netTips' | 'numberOfGuests' | 'orderType' | 'paymentType' | 'payrollId' | 'quantity' | 'referenceNumber' | 'refundAmount' | 'refundedTaxAmount' | 'revenueCenter' | 'revenueClass' | 'salesVarLw' | 'salesVarLwPct' | 'salesVarLy' | 'salesVarLyPct' | 'salesMixByPct' | 'salesPerGuest' | 'salesPerGuestLw' | 'salesPerGuestLy' | 'scheduledShiftEnd' | 'scheduledShiftStart' | 'settlementBatchDate' | 'shiftDurationHrs' | 'subtotal' | 'taxCollected' | 'taxName' | 'taxRate' | 'taxableSales' | 'ticketClosed' | 'ticketFee' | 'ticketNumber' | 'ticketOpen' | 'ticketTotal' | 'timeOpenMins' | 'tipPct' | 'tipReduction' | 'tipShare' | 'tips' | 'tipsPerHour' | 'totalCollected' | 'totalItemSales' | 'totalModifierSales' | 'totalReturns' | 'totalSales' | 'totalTips' | 'transactionDate' | 'transactionType' | 'untaxedSales' | 'visa' | 'visaReturns' | 'paymentsCount' | 'paymentsAmount' | 'paymentsTotal' | 'refundVoidDescription' | 'refundVoidCount' | 'refundVoidAmount' | 'refundVoidPctSales' | 'discountName' | 'tickets' | 'guests' | 'ticketAverage' | 'guestAverage' | 'net' | 'salePaymentType' | 'status';
1
+ type ReportColumnKey = 'fifteenMinInterval' | 'adjustedTips' | 'advantageProgram' | 'amex' | 'amexReturns' | 'attachRate' | 'autoGratuity' | 'averageGrossPrice' | 'bankFees' | 'batchAmount' | 'batchDate' | 'batchNumber' | 'clockInTime' | 'clockOutTime' | 'country' | 'customerName' | 'date' | 'dateClose' | 'daypart' | 'debit' | 'debitReturns' | 'declaredTips' | 'department' | 'depositCurrency' | 'depositDate' | 'discountAmount' | 'ticketCount' | 'itemCount' | 'discover' | 'discoverReturns' | 'ebt' | 'ebtReturns' | 'employeeId' | 'employeeJob' | 'employeeName' | 'exemptTaxes' | 'grandTotal' | 'grossCashSales' | 'grossCashTips' | 'grossCreditCardTips' | 'grossCreditSales' | 'grossSales' | 'grossTips' | 'guestCount' | 'guestsVarLw' | 'guestsVarLwPct' | 'guestsVarLy' | 'guestsVarLyPct' | 'hour' | 'hoursWorked' | 'inclusiveTax' | 'itemName' | 'itemPrice' | 'locationCity' | 'locationId' | 'locationMid' | 'locationName' | 'locationState' | 'mastercard' | 'mcReturns' | 'modifierName' | 'modifierPrice' | 'modifierQuantity' | 'netSales' | 'netTaxCollected' | 'netTips' | 'numberOfGuests' | 'orderType' | 'paymentType' | 'payrollId' | 'quantity' | 'referenceNumber' | 'refundAmount' | 'refundedTaxAmount' | 'revenueCenter' | 'revenueClass' | 'salesVarLw' | 'salesVarLwPct' | 'salesVarLy' | 'salesVarLyPct' | 'salesMixByPct' | 'salesPerGuest' | 'salesPerGuestLw' | 'salesPerGuestLy' | 'scheduledShiftEnd' | 'scheduledShiftStart' | 'settlementBatchDate' | 'shiftDurationHrs' | 'subtotal' | 'taxCollected' | 'taxName' | 'taxRate' | 'taxableSales' | 'ticketClosed' | 'ticketFee' | 'ticketNumber' | 'ticketOpen' | 'ticketTotal' | 'timeOpenMins' | 'tipPct' | 'tipReduction' | 'tipShare' | 'tips' | 'tipsPerHour' | 'totalCollected' | 'totalItemSales' | 'totalModifierSales' | 'totalReturns' | 'totalSales' | 'totalTips' | 'transactionDate' | 'transactionType' | 'untaxedSales' | 'visa' | 'visaReturns' | 'paymentsCount' | 'paymentsAmount' | 'paymentsTotal' | 'refundVoidDescription' | 'refundVoidCount' | 'refundVoidAmount' | 'refundVoidPctSales' | 'discountName' | 'tickets' | 'guests' | 'ticketAverage' | 'guestAverage' | 'net' | 'salePaymentType' | 'status';
2
2
  interface ColumnMetadata {
3
3
  titleKey: string;
4
4
  shortTitleKey: string;
@@ -135,10 +135,15 @@ declare const COLUMN_REGISTRY: {
135
135
  readonly shortTitleKey: "common.report-col.discount-amount.short";
136
136
  readonly infoTextKey: "common.report-col.discount-amount.info";
137
137
  };
138
- readonly discountCount: {
139
- readonly titleKey: "common.report-col.discount-count";
140
- readonly shortTitleKey: "common.report-col.discount-count.short";
141
- readonly infoTextKey: "common.report-col.discount-count.info";
138
+ readonly ticketCount: {
139
+ readonly titleKey: "common.report-col.ticket-count";
140
+ readonly shortTitleKey: "common.report-col.ticket-count.short";
141
+ readonly infoTextKey: "common.report-col.ticket-count.info";
142
+ };
143
+ readonly itemCount: {
144
+ readonly titleKey: "common.report-col.item-count";
145
+ readonly shortTitleKey: "common.report-col.item-count.short";
146
+ readonly infoTextKey: "common.report-col.item-count.info";
142
147
  };
143
148
  readonly discover: {
144
149
  readonly titleKey: "common.report-col.discover";
@@ -756,9 +761,13 @@ declare function getColumnMetadata(key: ReportColumnKey): {
756
761
  readonly shortTitleKey: "common.report-col.discount-amount.short";
757
762
  readonly infoTextKey: "common.report-col.discount-amount.info";
758
763
  } | {
759
- readonly titleKey: "common.report-col.discount-count";
760
- readonly shortTitleKey: "common.report-col.discount-count.short";
761
- readonly infoTextKey: "common.report-col.discount-count.info";
764
+ readonly titleKey: "common.report-col.ticket-count";
765
+ readonly shortTitleKey: "common.report-col.ticket-count.short";
766
+ readonly infoTextKey: "common.report-col.ticket-count.info";
767
+ } | {
768
+ readonly titleKey: "common.report-col.item-count";
769
+ readonly shortTitleKey: "common.report-col.item-count.short";
770
+ readonly infoTextKey: "common.report-col.item-count.info";
762
771
  } | {
763
772
  readonly titleKey: "common.report-col.discover";
764
773
  readonly shortTitleKey: "common.report-col.discover.short";
@@ -1170,7 +1179,7 @@ declare function getColumnMetadata(key: ReportColumnKey): {
1170
1179
  };
1171
1180
  declare function getColumnExportHeaderLabel(colTitle: string, groupTitle: string | null): string;
1172
1181
 
1173
- type FieldType = 'string' | 'money' | 'percent' | 'number' | 'fixedNumber' | 'date' | 'time' | 'boolean';
1182
+ type FieldType = 'string' | 'money' | 'percent' | 'number' | 'fixedNumber' | 'date' | 'time' | 'boolean' | 'conditional';
1174
1183
  type ColumnAlignment = 'left' | 'right';
1175
1184
  type FooterCalculationType = 'sum' | 'percentChange' | 'average' | 'none';
1176
1185
  interface FooterCalculation<TField = string> {
@@ -1178,14 +1187,24 @@ interface FooterCalculation<TField = string> {
1178
1187
  numeratorField?: TField;
1179
1188
  denominatorField?: TField;
1180
1189
  }
1181
- interface ColumnPresentationConfig<TField = string> {
1190
+ interface ConditionalConfiguration<TField = string> {
1191
+ conditionalField: TField;
1192
+ conditionalFormat: (value: unknown) => Exclude<FieldType, 'conditional'>;
1193
+ }
1194
+ interface BaseColumnPresentationConfig<TField = string> {
1182
1195
  columnKey?: ReportColumnKey;
1183
- type: FieldType;
1184
1196
  size?: number;
1185
1197
  enableSorting?: boolean;
1186
1198
  filteringAvailable?: boolean;
1187
1199
  footerCalculation?: FooterCalculation<TField>;
1188
1200
  }
1201
+ type ColumnPresentationConfig<TField = string> = (BaseColumnPresentationConfig<TField> & {
1202
+ type: Exclude<FieldType, 'conditional'>;
1203
+ conditionalConfiguration?: never;
1204
+ }) | (BaseColumnPresentationConfig<TField> & {
1205
+ type: 'conditional';
1206
+ conditionalConfiguration: ConditionalConfiguration<TField>;
1207
+ });
1189
1208
  interface ColumnGroupConfig {
1190
1209
  id: string;
1191
1210
  headerTranslationKey: string;
@@ -1269,7 +1288,7 @@ declare const DAILY_SALES_PAYMENTS_AVAILABLE_COLUMNS: DailySalesPaymentsField[];
1269
1288
  declare const DAILY_SALES_PAYMENTS_DEFAULT_VISIBLE_COLUMNS: DailySalesPaymentsField[];
1270
1289
  declare const dailySalesPaymentsConfig: ReportConfig<DailySalesPaymentsField>;
1271
1290
 
1272
- type DailySalesDiscountsField = 'discountName' | 'discountsCount' | 'discountsAmount';
1291
+ type DailySalesDiscountsField = 'discountName' | 'ticketCount' | 'itemCount' | 'discountsAmount';
1273
1292
  declare const DAILY_SALES_DISCOUNTS_AVAILABLE_COLUMNS: DailySalesDiscountsField[];
1274
1293
  declare const DAILY_SALES_DISCOUNTS_DEFAULT_VISIBLE_COLUMNS: DailySalesDiscountsField[];
1275
1294
  declare const dailySalesDiscountsConfig: ReportConfig<DailySalesDiscountsField>;
@@ -1333,6 +1352,6 @@ declare const getReportFormattingLocaleOptions: (locations: {
1333
1352
  countryCode: string;
1334
1353
  language: string;
1335
1354
  }[]) => LocaleOption[];
1336
- declare const formatFieldValue: (value: unknown, type: FieldType, localeOptions: LocaleOption) => string;
1355
+ declare const formatFieldValue: (value: unknown, type: FieldType, localeOptions: LocaleOption, fullRecord: Record<string, unknown> | null, fieldConfig?: ColumnPresentationConfig) => string;
1337
1356
 
1338
1357
  export { COLUMN_REGISTRY, type CalculateReportTotalsOptions, type ColumnAlignment, type ColumnGroupConfig, type ColumnMetadata, type ColumnPresentationConfig, DAILY_SALES_AVAILABLE_COLUMNS, DAILY_SALES_BY_GROUP_AVAILABLE_COLUMNS, DAILY_SALES_DEFAULT_VISIBLE_COLUMNS, DAILY_SALES_DISCOUNTS_AVAILABLE_COLUMNS, DAILY_SALES_DISCOUNTS_DEFAULT_VISIBLE_COLUMNS, DAILY_SALES_PAYMENTS_AVAILABLE_COLUMNS, DAILY_SALES_PAYMENTS_DEFAULT_VISIBLE_COLUMNS, DAILY_SALES_REFUNDS_VOIDS_AVAILABLE_COLUMNS, DAILY_SALES_REFUNDS_VOIDS_DEFAULT_VISIBLE_COLUMNS, DAILY_SALES_TAXES_AVAILABLE_COLUMNS, DAILY_SALES_TAXES_DEFAULT_VISIBLE_COLUMNS, DAILY_SALES_TRENDS_AVAILABLE_COLUMNS, EMPLOYEE_TIMECARD_AVAILABLE_COLUMNS, EMPLOYEE_TIMECARD_DEFAULT_VISIBLE_COLUMNS, type FieldType, type FooterCalculation, type FooterCalculationType, type FormatDateOptions, type FormatMoneyOptions, type FormatNumberOptions, type FormatTimeOptions, ITEM_TAX_AVAILABLE_COLUMNS, ITEM_TAX_DEFAULT_VISIBLE_COLUMNS, type LocaleOption, MODIFIER_MIX_AVAILABLE_COLUMNS, MODIFIER_MIX_DEFAULT_VISIBLE_COLUMNS, PRODUCT_MIX_AVAILABLE_COLUMNS, PRODUCT_MIX_CHART_FIELDS, PRODUCT_MIX_DEFAULT_VISIBLE_COLUMNS, Report, type ReportColumnKey, type ReportConfig, type ReportType, SALES_BY_ITEM_DETAIL_AVAILABLE_COLUMNS, SALES_BY_ITEM_DETAIL_DEFAULT_VISIBLE_COLUMNS, SALES_SUMMARY_AVAILABLE_COLUMNS, SALES_SUMMARY_DEFAULT_VISIBLE_COLUMNS, TICKET_LIVE_AVAILABLE_COLUMNS, TICKET_LIVE_DEFAULT_VISIBLE_COLUMNS, TICKET_SUMMARY_AVAILABLE_COLUMNS, TICKET_SUMMARY_DEFAULT_VISIBLE_COLUMNS, type TimeFormat, calculateReportTotals, dailySalesConfig, dailySalesDiscountsConfig, dailySalesPaymentsConfig, dailySalesRefundsVoidsConfig, dailySalesTaxesConfig, dailySalesTrendsConfig, employeeTimecardConfig, formatDate, formatFieldValue, formatFixedNumber, formatInteger, formatMoney, formatMoneyWithoutSymbol, formatPercent, formatString, formatTime, getColumnAlignment, getColumnExportHeaderLabel, getColumnMetadata, getDateToFormat, getNumberToFormat, getReportConfig, getReportFormattingLocaleOptions, isNumericType, itemTaxConfig, modifierMixConfig, productMixConfig, salesByItemDetailConfig, salesSummaryConfig, ticketLiveConfig, ticketSummaryConfig };
package/dist/index.js CHANGED
@@ -421,7 +421,16 @@ var FIELDS6 = {
421
421
  orderTypeName: { type: "string", columnKey: "orderType", filteringAvailable: false },
422
422
  taxName: { type: "string", columnKey: "taxName", filteringAvailable: false },
423
423
  taxValue: { type: "money", columnKey: "taxableSales" },
424
- taxRate: { type: "number", columnKey: "taxRate" },
424
+ taxRate: {
425
+ type: "conditional",
426
+ columnKey: "taxRate",
427
+ conditionalConfiguration: {
428
+ conditionalField: "taxIsFlat",
429
+ conditionalFormat: (field) => {
430
+ return field ? "money" : "percent";
431
+ }
432
+ }
433
+ },
425
434
  recordsCount: { type: "number", columnKey: "quantity" },
426
435
  taxableSales: { type: "money", columnKey: "taxableSales" },
427
436
  totalCollected: { type: "money", columnKey: "totalCollected" },
@@ -570,11 +579,13 @@ var dailySalesPaymentsConfig = {
570
579
  var FIRST_COLUMN_WIDTH6 = 240;
571
580
  var FIELDS9 = {
572
581
  discountName: { type: "string", columnKey: "discountName", size: FIRST_COLUMN_WIDTH6 },
573
- discountsCount: { type: "number", columnKey: "discountCount", footerCalculation: { type: "sum" } },
582
+ ticketCount: { type: "number", columnKey: "ticketCount", footerCalculation: { type: "sum" } },
583
+ itemCount: { type: "number", columnKey: "itemCount", footerCalculation: { type: "sum" } },
574
584
  discountsAmount: { type: "money", columnKey: "discountAmount", footerCalculation: { type: "sum" } }
575
585
  };
576
586
  var DAILY_SALES_DISCOUNTS_AVAILABLE_COLUMNS = [
577
- "discountsCount",
587
+ "ticketCount",
588
+ "itemCount",
578
589
  "discountsAmount"
579
590
  ];
580
591
  var DAILY_SALES_DISCOUNTS_DEFAULT_VISIBLE_COLUMNS = DAILY_SALES_DISCOUNTS_AVAILABLE_COLUMNS;
@@ -882,10 +893,15 @@ var COLUMN_REGISTRY = {
882
893
  shortTitleKey: "common.report-col.discount-amount.short",
883
894
  infoTextKey: "common.report-col.discount-amount.info"
884
895
  },
885
- discountCount: {
886
- titleKey: "common.report-col.discount-count",
887
- shortTitleKey: "common.report-col.discount-count.short",
888
- infoTextKey: "common.report-col.discount-count.info"
896
+ ticketCount: {
897
+ titleKey: "common.report-col.ticket-count",
898
+ shortTitleKey: "common.report-col.ticket-count.short",
899
+ infoTextKey: "common.report-col.ticket-count.info"
900
+ },
901
+ itemCount: {
902
+ titleKey: "common.report-col.item-count",
903
+ shortTitleKey: "common.report-col.item-count.short",
904
+ infoTextKey: "common.report-col.item-count.info"
889
905
  },
890
906
  discover: {
891
907
  titleKey: "common.report-col.discover",
@@ -1625,9 +1641,18 @@ var getReportFormattingLocaleOptions = (locations) => {
1625
1641
  ).values()
1626
1642
  );
1627
1643
  };
1628
- var formatFieldValue = (value, type, localeOptions) => {
1644
+ var DEFAULT_FIELD_CONFIG = { type: "string" };
1645
+ var formatFieldValue = (value, type, localeOptions, fullRecord, fieldConfig = DEFAULT_FIELD_CONFIG) => {
1629
1646
  const { currency, locale } = localeOptions;
1630
1647
  switch (type) {
1648
+ case "conditional": {
1649
+ if (!fullRecord) {
1650
+ return formatString(value);
1651
+ }
1652
+ const conditionalConfig = fieldConfig.conditionalConfiguration;
1653
+ const configType = conditionalConfig.conditionalFormat(fullRecord[conditionalConfig.conditionalField]);
1654
+ return formatFieldValue(value, configType, localeOptions, fullRecord, fieldConfig);
1655
+ }
1631
1656
  case "string":
1632
1657
  return formatString(value);
1633
1658
  case "money":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harbortouch/skytab-analytics-report-utils",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "Centralized report column presentation configuration for SkyTab Analytics",
5
5
  "engines": {
6
6
  "node": ">=22.6.0",