@harbortouch/skytab-analytics-report-utils 0.2.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.
@@ -0,0 +1,6 @@
1
+ export { salesSummaryConfig, SALES_SUMMARY_AVAILABLE_COLUMNS, SALES_SUMMARY_DEFAULT_VISIBLE_COLUMNS, } from './salesSummary';
2
+ export { ticketSummaryConfig, TICKET_SUMMARY_AVAILABLE_COLUMNS, TICKET_SUMMARY_DEFAULT_VISIBLE_COLUMNS, } from './ticketSummary';
3
+ export { ticketLiveConfig, TICKET_LIVE_AVAILABLE_COLUMNS, TICKET_LIVE_DEFAULT_VISIBLE_COLUMNS } from './ticketLive';
4
+ export { productMixConfig, PRODUCT_MIX_AVAILABLE_COLUMNS, PRODUCT_MIX_DEFAULT_VISIBLE_COLUMNS, PRODUCT_MIX_CHART_FIELDS, } from './productMix';
5
+ export { modifierMixConfig, MODIFIER_MIX_AVAILABLE_COLUMNS, MODIFIER_MIX_DEFAULT_VISIBLE_COLUMNS } from './modifierMix';
6
+ export { itemTaxConfig, ITEM_TAX_AVAILABLE_COLUMNS, ITEM_TAX_DEFAULT_VISIBLE_COLUMNS } from './itemTax';
@@ -0,0 +1,6 @@
1
+ import { type ReportConfig } from '../types';
2
+ type ItemTaxField = 'locationId' | 'taxIsFlat' | 'merchantId' | 'locationName' | 'locationCity' | 'locationState' | 'itemName' | 'itemPrice' | 'departmentName' | 'revenueClassName' | 'orderTypeName' | 'taxName' | 'taxValue' | 'taxRate' | 'recordsCount' | 'taxableSales' | 'totalCollected' | 'itemTax' | 'taxCollected';
3
+ export declare const ITEM_TAX_AVAILABLE_COLUMNS: ItemTaxField[];
4
+ export declare const ITEM_TAX_DEFAULT_VISIBLE_COLUMNS: ItemTaxField[];
5
+ export declare const itemTaxConfig: ReportConfig<ItemTaxField>;
6
+ export {};
@@ -0,0 +1,6 @@
1
+ import { type ReportConfig } from '../types';
2
+ type ModifierMixField = 'groupById' | 'groupByName' | 'groupById2' | 'groupByName2' | 'modifiersSales' | 'modifiersQuantity' | 'itemsQuantity' | 'avgGross' | 'attachRate' | 'modifiersSalesComp' | 'modifiersQuantityComp' | 'itemsQuantityComp' | 'attachRateComp' | 'modifiersSalesVar' | 'modifiersSalesVarPct' | 'modifiersQuantityVar' | 'modifiersQuantityVarPct' | 'attachRateVar' | 'attachRateVarPct';
3
+ export declare const MODIFIER_MIX_AVAILABLE_COLUMNS: ModifierMixField[];
4
+ export declare const MODIFIER_MIX_DEFAULT_VISIBLE_COLUMNS: ModifierMixField[];
5
+ export declare const modifierMixConfig: ReportConfig<ModifierMixField>;
6
+ export {};
@@ -0,0 +1,7 @@
1
+ import { type ReportConfig } from '../types';
2
+ type ProductMixField = 'groupById' | 'groupByName' | 'salesAmountGross' | 'discountsAmount' | 'inclusiveTaxesAmount' | 'salesAmountNet' | 'itemsQuantity' | 'avgPrice' | 'salesMixPct';
3
+ export declare const PRODUCT_MIX_AVAILABLE_COLUMNS: ProductMixField[];
4
+ export declare const PRODUCT_MIX_DEFAULT_VISIBLE_COLUMNS: ProductMixField[];
5
+ export declare const PRODUCT_MIX_CHART_FIELDS: ProductMixField[];
6
+ export declare const productMixConfig: ReportConfig<ProductMixField>;
7
+ export {};
@@ -0,0 +1,6 @@
1
+ import { type ReportConfig } from '../types';
2
+ type SalesSummaryField = 'groupById' | 'groupByName' | 'salesAmountNet' | 'salesVarLW' | 'salesVarLY' | 'salesVarLWPct' | 'salesVarLYPct' | 'salesAmountNetLastWeek' | 'salesAmountNetLastYear' | 'salesAmountGross' | 'salesAmountGrossLastWeek' | 'salesAmountGrossLastYear' | 'ticketsCount' | 'ticketsCountLastWeek' | 'ticketsCountLastYear' | 'guestsCount' | 'guestsVarLW' | 'guestsVarLY' | 'guestsVarLWPct' | 'guestsVarLYPct' | 'guestsCountLastWeek' | 'guestsCountLastYear' | 'salesPerGuestTY' | 'salesPerGuestLW' | 'salesPerGuestLY';
3
+ export declare const SALES_SUMMARY_AVAILABLE_COLUMNS: SalesSummaryField[];
4
+ export declare const SALES_SUMMARY_DEFAULT_VISIBLE_COLUMNS: SalesSummaryField[];
5
+ export declare const salesSummaryConfig: ReportConfig<SalesSummaryField>;
6
+ export {};
@@ -0,0 +1,6 @@
1
+ import { type ReportConfig } from '../types';
2
+ type TicketLiveField = 'locationName' | 'orderNumber' | 'dateOpen' | 'timeOpen' | 'dateClose' | 'timeClose' | 'durationMinutes' | 'subtotal' | 'discountTotal' | 'surchargeTotal' | 'taxTotal' | 'grandTotal' | 'gratuityTotal' | 'totalTips' | 'paymentsReceived' | 'paymentTypeName' | 'guestCount' | 'customerName' | 'employeeName' | 'orderType';
3
+ export declare const TICKET_LIVE_AVAILABLE_COLUMNS: TicketLiveField[];
4
+ export declare const TICKET_LIVE_DEFAULT_VISIBLE_COLUMNS: TicketLiveField[];
5
+ export declare const ticketLiveConfig: ReportConfig<TicketLiveField>;
6
+ export {};
@@ -0,0 +1,6 @@
1
+ import { type ReportConfig } from '../types';
2
+ type TicketSummaryField = 'ticketId' | 'locationId' | 'orderName' | 'revenueCenterName' | 'daypartName' | 'inclusiveTaxesAmount' | 'locationName' | 'orderNumber' | 'businessDate' | 'ticketOpenedAt' | 'ticketClosedAt' | 'ticketTime' | 'ticketSubtotal' | 'discountsAmount' | 'surchargesAmount' | 'taxesAmount' | 'ticketGrandTotal' | 'gratuitiesAmount' | 'tipAmount' | 'paymentsAmount' | 'paymentTypeName' | 'guestsCount' | 'employeeName' | 'orderTypeName';
3
+ export declare const TICKET_SUMMARY_AVAILABLE_COLUMNS: TicketSummaryField[];
4
+ export declare const TICKET_SUMMARY_DEFAULT_VISIBLE_COLUMNS: TicketSummaryField[];
5
+ export declare const ticketSummaryConfig: ReportConfig<TicketSummaryField>;
6
+ export {};
@@ -0,0 +1,6 @@
1
+ import { type ColumnPresentationConfig } from './types';
2
+ export interface CalculateReportTotalsOptions {
3
+ labelField: string;
4
+ label: string;
5
+ }
6
+ export declare function calculateReportTotals(data: Record<string, unknown>[], fieldConfig: Record<string, ColumnPresentationConfig>, opts: CalculateReportTotalsOptions): Record<string, unknown>;
@@ -0,0 +1,30 @@
1
+ import { type ReportColumnKey } from './columns';
2
+ export type FieldType = 'string' | 'money' | 'percent' | 'number' | 'fixedNumber' | 'date' | 'time' | 'boolean';
3
+ export type ColumnAlignment = 'left' | 'right';
4
+ export type FooterCalculationType = 'sum' | 'percentChange' | 'average' | 'none';
5
+ export interface FooterCalculation {
6
+ type: FooterCalculationType;
7
+ numeratorField?: string;
8
+ denominatorField?: string;
9
+ }
10
+ export interface ColumnPresentationConfig {
11
+ columnKey?: ReportColumnKey;
12
+ type?: FieldType;
13
+ size?: number;
14
+ enableSorting?: boolean;
15
+ filteringAvailable?: boolean;
16
+ footerCalculation?: FooterCalculation;
17
+ }
18
+ export interface ColumnGroupConfig {
19
+ id: string;
20
+ headerTranslationKey: string;
21
+ baseFields: string[];
22
+ lastWeekFields?: string[];
23
+ lastYearFields?: string[];
24
+ }
25
+ export interface ReportConfig<TField extends string = string> {
26
+ fields: Record<TField, ColumnPresentationConfig>;
27
+ availableColumns: TField[];
28
+ defaultVisibleColumns: TField[];
29
+ columnGroups?: ColumnGroupConfig[];
30
+ }
@@ -0,0 +1,3 @@
1
+ import { type ColumnAlignment, type FieldType } from '../types';
2
+ export declare function getColumnAlignment(type?: FieldType): ColumnAlignment;
3
+ export declare function isNumericType(type?: FieldType): boolean;
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@harbortouch/skytab-analytics-report-utils",
3
+ "version": "0.2.0",
4
+ "description": "Centralized report column presentation configuration for SkyTab Analytics",
5
+ "engines": {
6
+ "node": ">=22.6.0",
7
+ "pnpm": ">=9.0.0"
8
+ },
9
+ "main": "dist/index.cjs",
10
+ "module": "dist/index.js",
11
+ "types": "dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js",
16
+ "require": "./dist/index.cjs"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "type": "module",
23
+ "scripts": {
24
+ "build": "tsup && tsc -p tsconfig.build.json",
25
+ "dev": "tsup --watch",
26
+ "lint:js": "eslint src",
27
+ "lint:js:fix": "eslint src --fix",
28
+ "lint:types": "tsc --noEmit",
29
+ "typecheck": "tsc --noEmit",
30
+ "prepare": "husky"
31
+ },
32
+ "devDependencies": {
33
+ "eslint": "^9.39.2",
34
+ "eslint-config-prettier": "^10.1.8",
35
+ "eslint-import-resolver-typescript": "^4.2.2",
36
+ "eslint-plugin-import": "^2.32.0",
37
+ "eslint-plugin-prettier": "^5.5.5",
38
+ "globals": "^17.0.0",
39
+ "husky": "^9.1.7",
40
+ "prettier": "^3.8.0",
41
+ "pretty-quick": "^4.2.2",
42
+ "tsup": "^8.0.0",
43
+ "typescript": "^5.9.3",
44
+ "typescript-eslint": "^8.53.1"
45
+ },
46
+ "packageManager": "pnpm@10.24.0+sha512.01ff8ae71b4419903b65c60fb2dc9d34cf8bb6e06d03bde112ef38f7a34d6904c424ba66bea5cdcf12890230bf39f9580473140ed9c946fef328b6e5238a345a"
47
+ }