@managesome/eposmatic-toolkit 0.4.5 → 0.4.8
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/esm/constants/MATERIALIZED_REPORTS.js +33 -0
- package/esm/constants/REPORT_CALENDAR.js +47 -0
- package/esm/constants/index.js +1 -0
- package/esm/helpers/materialized-reports/index.js +2 -0
- package/esm/helpers/materialized-reports/materialized-credit-bills-helpers.js +982 -0
- package/esm/helpers/materialized-reports/materialized-reports-read-helpers.js +1 -76
- package/esm/helpers/materialized-reports/materialized-reports-selection-helpers.js +716 -0
- package/esm/helpers/materialized-reports/tenant-sales-overview-close-day-helpers.js +327 -41
- package/esm/helpers/materialized-reports/tenant-sales-overview-formatter.js +72 -11
- package/esm/helpers/materialized-reports/tenant-sales-overview-helpers.js +118 -235
- package/esm/helpers/types/index.js +1 -0
- package/esm/schemas/models/index.js +1 -0
- package/esm/schemas/models/materialized_credit_bills.js +265 -0
- package/esm/schemas/models/materialized_tenant_reports_iterations.js +13 -0
- package/esm/schemas/models/materialized_tenant_sales_overview_reports.js +39 -97
- package/esm/schemas/types/index.js +1 -0
- package/esm/schemas/types/materialized_credit_bills.js +1 -0
- package/lib/constants/MATERIALIZED_REPORTS.d.ts +28 -2
- package/lib/constants/MATERIALIZED_REPORTS.js +34 -1
- package/lib/constants/REPORT_CALENDAR.d.ts +31 -0
- package/lib/constants/REPORT_CALENDAR.js +50 -0
- package/lib/constants/index.d.ts +1 -0
- package/lib/constants/index.js +1 -0
- package/lib/helpers/materialized-reports/index.d.ts +2 -0
- package/lib/helpers/materialized-reports/index.js +2 -0
- package/lib/helpers/materialized-reports/materialized-credit-bills-helpers.d.ts +307 -0
- package/lib/helpers/materialized-reports/materialized-credit-bills-helpers.js +1003 -0
- package/lib/helpers/materialized-reports/materialized-reports-read-helpers.d.ts +0 -30
- package/lib/helpers/materialized-reports/materialized-reports-read-helpers.js +0 -76
- package/lib/helpers/materialized-reports/materialized-reports-selection-helpers.d.ts +59 -0
- package/lib/helpers/materialized-reports/materialized-reports-selection-helpers.js +723 -0
- package/lib/helpers/materialized-reports/tenant-sales-overview-close-day-helpers.d.ts +66 -8
- package/lib/helpers/materialized-reports/tenant-sales-overview-close-day-helpers.js +326 -40
- package/lib/helpers/materialized-reports/tenant-sales-overview-formatter.d.ts +18 -2
- package/lib/helpers/materialized-reports/tenant-sales-overview-formatter.js +72 -11
- package/lib/helpers/materialized-reports/tenant-sales-overview-helpers.d.ts +46 -37
- package/lib/helpers/materialized-reports/tenant-sales-overview-helpers.js +119 -238
- package/lib/helpers/types/index.d.ts +1 -0
- package/lib/helpers/types/index.js +1 -0
- package/lib/helpers/types/materialized-reports-apis.d.ts +46 -17
- package/lib/helpers/types/report-calendar.d.ts +20 -0
- package/lib/helpers/types/report-calendar.js +2 -0
- package/lib/schemas/models/index.d.ts +1 -0
- package/lib/schemas/models/index.js +1 -0
- package/lib/schemas/models/materialized_credit_bills.d.ts +337 -0
- package/lib/schemas/models/materialized_credit_bills.js +268 -0
- package/lib/schemas/models/materialized_tenant_reports_iterations.d.ts +20 -6
- package/lib/schemas/models/materialized_tenant_reports_iterations.js +14 -1
- package/lib/schemas/models/materialized_tenant_sales_overview_reports.d.ts +37 -165
- package/lib/schemas/models/materialized_tenant_sales_overview_reports.js +40 -98
- package/lib/schemas/types/index.d.ts +1 -0
- package/lib/schemas/types/index.js +1 -0
- package/lib/schemas/types/materialized_credit_bills.d.ts +139 -0
- package/lib/schemas/types/materialized_credit_bills.js +2 -0
- package/lib/schemas/types/materialized_tenant_sales_overview_reports.d.ts +32 -77
- package/lib/tests/materialized-reports/materialized-credit-bills-helpers.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-credit-bills-helpers.test.js +715 -0
- package/lib/tests/materialized-reports/materialized-reports-selection-helpers.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-reports-selection-helpers.test.js +262 -0
- package/lib/tests/materialized-reports/materialized-tenant-reports-iterations-schema.test.js +9 -0
- package/lib/tests/materialized-reports/materialized-tenant-sales-overview-reports-schema.test.js +23 -24
- package/lib/tests/materialized-reports/tenant-sales-overview-close-day-helpers.test.js +327 -22
- package/lib/tests/materialized-reports/tenant-sales-overview-formatter-aggregated.test.js +27 -2
- package/lib/tests/materialized-reports/tenant-sales-overview-formatter.test.js +12 -27
- package/lib/tests/materialized-reports/tenant-sales-overview-helpers.test.js +79 -146
- package/package.json +1 -1
- package/lib/tests/materialized-reports/materialized-reports-read-helpers.test.js +0 -100
- /package/{lib/tests/materialized-reports/materialized-reports-read-helpers.test.d.ts → esm/helpers/types/report-calendar.js} +0 -0
|
@@ -62,6 +62,22 @@ export const MATERIALIZED_REPORT_SCOPES_WITH_DAY_INDEX = [
|
|
|
62
62
|
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_HOUR,
|
|
63
63
|
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
|
|
64
64
|
];
|
|
65
|
+
/**
|
|
66
|
+
* Scopes materialized by `materialized_tenant_credit_bills` — the credit
|
|
67
|
+
* ledger is CAPPED AT `LOCAL_MONTH`: a month bounds how many bills a document
|
|
68
|
+
* accumulates, so no document grows unboundedly over time. Whole-year /
|
|
69
|
+
* multi-year reads cover their range with the month documents (plus
|
|
70
|
+
* date/hour documents at range edges and for hour-precise time windows).
|
|
71
|
+
* `LOCAL_HOUR` is kept for zoomed-in selections (e.g. a report restricted to
|
|
72
|
+
* certain hours of a day).
|
|
73
|
+
*/
|
|
74
|
+
export const MATERIALIZED_CREDIT_BILLS_SCOPES = [
|
|
75
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_HOUR,
|
|
76
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
|
|
77
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK,
|
|
78
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK_OF_YEAR,
|
|
79
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH,
|
|
80
|
+
];
|
|
65
81
|
/**
|
|
66
82
|
* Filter dimensions that can be encoded into the metric keys of a materialized
|
|
67
83
|
* report document (`sale_type_metrics`). The declaration order defines the key
|
|
@@ -90,6 +106,22 @@ export const SALES_OVERVIEW_KEY_FILTERS = [
|
|
|
90
106
|
* total sales.
|
|
91
107
|
*/
|
|
92
108
|
export const MATERIALIZED_CREDIT_SETTLEMENT_PAYMENT_TYPE = 'CREDIT_SETTLEMENT';
|
|
109
|
+
/**
|
|
110
|
+
* Kind of a credit-bill ledger receipt event (`received.bills[].event_type` of
|
|
111
|
+
* the `CREDIT_BILLS` slot). The compile pipeline emits `RECEIPT`s today;
|
|
112
|
+
* `REFUND` / `WRITE_OFF` are reserved for SIGNED adjustments and are
|
|
113
|
+
* deliberately unimplemented (see `MATERIALIZED_REPORTS.md`). The event
|
|
114
|
+
* identity is `(order_id, payment_id, event_local_date)` — the kind never
|
|
115
|
+
* partakes in the key, so introducing the reserved kinds cannot rewrite
|
|
116
|
+
* existing events.
|
|
117
|
+
*/
|
|
118
|
+
export var MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM;
|
|
119
|
+
(function (MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM) {
|
|
120
|
+
MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM["RECEIPT"] = "RECEIPT";
|
|
121
|
+
MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM["REFUND"] = "REFUND";
|
|
122
|
+
MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM["WRITE_OFF"] = "WRITE_OFF";
|
|
123
|
+
})(MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM || (MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM = {}));
|
|
124
|
+
export const ALL_MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPES = Object.values(MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM);
|
|
93
125
|
/**
|
|
94
126
|
* Materialized report kinds — the discriminator stored on
|
|
95
127
|
* `materialized_tenant_reports_iterations` rows. A single shared history collection records
|
|
@@ -101,5 +133,6 @@ export const MATERIALIZED_CREDIT_SETTLEMENT_PAYMENT_TYPE = 'CREDIT_SETTLEMENT';
|
|
|
101
133
|
export var MATERIALIZED_REPORT_TYPE_ENUM;
|
|
102
134
|
(function (MATERIALIZED_REPORT_TYPE_ENUM) {
|
|
103
135
|
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_SALES_OVERVIEW"] = "TENANT_SALES_OVERVIEW";
|
|
136
|
+
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_CREDIT_BILLS"] = "TENANT_CREDIT_BILLS";
|
|
104
137
|
})(MATERIALIZED_REPORT_TYPE_ENUM || (MATERIALIZED_REPORT_TYPE_ENUM = {}));
|
|
105
138
|
export const ALL_MATERIALIZED_REPORT_TYPES = Object.values(MATERIALIZED_REPORT_TYPE_ENUM);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Report Calendar selection model constants (see the Report Calendar
|
|
2
|
+
// concept doc §5). The calendar produces an `IReportCalendarSelection`;
|
|
3
|
+
// every materialized report read API decodes it server-side with the
|
|
4
|
+
// toolkit's `buildMaterializedReportScopeGroupsFromSelection` — the
|
|
5
|
+
// selection model is the SINGLE shared contract between the calendar UI and
|
|
6
|
+
// the read services.
|
|
7
|
+
export var CALENDAR_MODE_ENUM;
|
|
8
|
+
(function (CALENDAR_MODE_ENUM) {
|
|
9
|
+
CALENDAR_MODE_ENUM["LIVE"] = "LIVE";
|
|
10
|
+
CALENDAR_MODE_ENUM["HISTORICAL"] = "HISTORICAL";
|
|
11
|
+
})(CALENDAR_MODE_ENUM || (CALENDAR_MODE_ENUM = {}));
|
|
12
|
+
export const ALL_CALENDAR_MODE_ENUMS = Object.values(CALENDAR_MODE_ENUM);
|
|
13
|
+
// Historical selection modes (doc §4.2) — default = DATE_RANGE.
|
|
14
|
+
// Every materialized scope context is selectable: day/hour ranges, calendar
|
|
15
|
+
// weeks (Sun–Sat), ISO weeks of year (Mon–Sun), months, quarters, semesters
|
|
16
|
+
// and years — contiguous ranges plus discrete (DIFFERENT_*) picks.
|
|
17
|
+
// Two refinements apply to ANY historical view (they are modifiers, not
|
|
18
|
+
// modes): the time-of-day window (hour-level, own `localHour`
|
|
19
|
+
// materialization) and the weekday filter (`day_index`, applied by the
|
|
20
|
+
// decoder).
|
|
21
|
+
export var CALENDAR_VIEW_MODE_ENUM;
|
|
22
|
+
(function (CALENDAR_VIEW_MODE_ENUM) {
|
|
23
|
+
CALENDAR_VIEW_MODE_ENUM["DATE_RANGE"] = "DATE_RANGE";
|
|
24
|
+
CALENDAR_VIEW_MODE_ENUM["MULTI_DATE"] = "MULTI_DATE";
|
|
25
|
+
CALENDAR_VIEW_MODE_ENUM["DATE_RANGE_TIME_WINDOW"] = "DATE_RANGE_TIME_WINDOW";
|
|
26
|
+
CALENDAR_VIEW_MODE_ENUM["WEEK"] = "WEEK";
|
|
27
|
+
CALENDAR_VIEW_MODE_ENUM["DIFFERENT_WEEKS"] = "DIFFERENT_WEEKS";
|
|
28
|
+
CALENDAR_VIEW_MODE_ENUM["WEEK_OF_YEAR"] = "WEEK_OF_YEAR";
|
|
29
|
+
CALENDAR_VIEW_MODE_ENUM["DIFFERENT_WEEKS_OF_YEAR"] = "DIFFERENT_WEEKS_OF_YEAR";
|
|
30
|
+
CALENDAR_VIEW_MODE_ENUM["MONTH"] = "MONTH";
|
|
31
|
+
CALENDAR_VIEW_MODE_ENUM["DIFFERENT_MONTHS"] = "DIFFERENT_MONTHS";
|
|
32
|
+
CALENDAR_VIEW_MODE_ENUM["QUARTER"] = "QUARTER";
|
|
33
|
+
CALENDAR_VIEW_MODE_ENUM["DIFFERENT_QUARTERS"] = "DIFFERENT_QUARTERS";
|
|
34
|
+
CALENDAR_VIEW_MODE_ENUM["SEMESTER"] = "SEMESTER";
|
|
35
|
+
CALENDAR_VIEW_MODE_ENUM["DIFFERENT_SEMESTERS"] = "DIFFERENT_SEMESTERS";
|
|
36
|
+
CALENDAR_VIEW_MODE_ENUM["YEAR"] = "YEAR";
|
|
37
|
+
CALENDAR_VIEW_MODE_ENUM["DIFFERENT_YEARS"] = "DIFFERENT_YEARS";
|
|
38
|
+
})(CALENDAR_VIEW_MODE_ENUM || (CALENDAR_VIEW_MODE_ENUM = {}));
|
|
39
|
+
export const ALL_CALENDAR_VIEW_MODE_ENUMS = Object.values(CALENDAR_VIEW_MODE_ENUM);
|
|
40
|
+
/**
|
|
41
|
+
* Version of the `IReportCalendarSelection` spec carried by a materialized
|
|
42
|
+
* report READ body (`selection.spec_version`). Bump on any meaning-changing
|
|
43
|
+
* reshape of the selection model — the read API rejects unknown versions
|
|
44
|
+
* with a 400, so rolling deploys (old frontend → new backend) fail loudly
|
|
45
|
+
* instead of decoding a stale shape.
|
|
46
|
+
*/
|
|
47
|
+
export const MATERIALIZED_REPORT_SELECTION_SPEC_VERSION = 1;
|
package/esm/constants/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export * from './MATERIALIZED_REPORTS';
|
|
|
11
11
|
export * from './NOTIFICATIONS';
|
|
12
12
|
export * from './ORDER';
|
|
13
13
|
export * from './PRA_ENUMS';
|
|
14
|
+
export * from './REPORT_CALENDAR';
|
|
14
15
|
export * from './REPORT_WEBVIEW';
|
|
15
16
|
export * from './RFQ_GO';
|
|
16
17
|
export * from './SMARTPAY_ENUMS';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './key-helpers';
|
|
2
|
+
export * from './materialized-credit-bills-helpers';
|
|
2
3
|
export * from './materialized-reports-read-helpers';
|
|
3
4
|
export * from './materialized-reports-scope-group-helpers';
|
|
5
|
+
export * from './materialized-reports-selection-helpers';
|
|
4
6
|
export * from './materialized-tenant-reports-iterations-helpers';
|
|
5
7
|
export * from './scope-helpers';
|
|
6
8
|
export * from './tenant-sales-overview-close-day-helpers';
|