@managesome/eposmatic-toolkit 0.4.58 → 0.4.59
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 +45 -0
- package/esm/helpers/materialized-reports/index.js +1 -0
- package/esm/helpers/materialized-reports/materialized-day-readiness.js +94 -0
- package/esm/helpers/materialized-reports/materialized-index-bootstrap.js +3 -0
- package/esm/helpers/materialized-reports/report-platform/definition.js +12 -2
- package/esm/helpers/order/generate-warehouse-purchase-order.js +3 -0
- package/esm/helpers/reporting-contract/report-contract.js +12 -0
- package/esm/helpers/store/common-tenant-purchase-order-actions.js +23 -0
- package/esm/helpers/store/common-warehouse-purchase-order-actions.js +21 -0
- package/esm/helpers/store/tenant-purchase-orders-cart-actions.js +60 -12
- package/esm/helpers/store/warehouse-purchase-orders-cart-actions.js +58 -13
- package/esm/schemas/models/index.js +1 -0
- package/esm/schemas/models/materialized_tenant_day_readiness.js +66 -0
- package/esm/schemas/models/tenant_purchase_orders.js +36 -0
- package/esm/schemas/models/warehouse_purchase_orders.js +48 -0
- package/esm/schemas/types/index.js +1 -0
- package/esm/schemas/types/materialized_tenant_day_readiness.js +1 -0
- package/lib/constants/MATERIALIZED_REPORTS.d.ts +42 -0
- package/lib/constants/MATERIALIZED_REPORTS.js +46 -1
- package/lib/helpers/materialized-reports/index.d.ts +1 -0
- package/lib/helpers/materialized-reports/index.js +1 -0
- package/lib/helpers/materialized-reports/materialized-day-readiness.d.ts +84 -0
- package/lib/helpers/materialized-reports/materialized-day-readiness.js +100 -0
- package/lib/helpers/materialized-reports/materialized-index-bootstrap.js +3 -0
- package/lib/helpers/materialized-reports/report-platform/definition.js +12 -2
- package/lib/helpers/order/generate-warehouse-purchase-order.js +3 -0
- package/lib/helpers/reporting-contract/report-contract.d.ts +13 -1
- package/lib/helpers/reporting-contract/report-contract.js +12 -0
- package/lib/helpers/store/common-tenant-purchase-order-actions.d.ts +2 -1
- package/lib/helpers/store/common-tenant-purchase-order-actions.js +24 -0
- package/lib/helpers/store/common-warehouse-purchase-order-actions.d.ts +2 -1
- package/lib/helpers/store/common-warehouse-purchase-order-actions.js +22 -0
- package/lib/helpers/store/tenant-purchase-orders-cart-actions.d.ts +15 -1
- package/lib/helpers/store/tenant-purchase-orders-cart-actions.js +61 -12
- package/lib/helpers/store/warehouse-purchase-orders-cart-actions.d.ts +10 -1
- package/lib/helpers/store/warehouse-purchase-orders-cart-actions.js +59 -13
- package/lib/schemas/models/index.d.ts +1 -0
- package/lib/schemas/models/index.js +1 -0
- package/lib/schemas/models/materialized_tenant_day_readiness.d.ts +78 -0
- package/lib/schemas/models/materialized_tenant_day_readiness.js +69 -0
- package/lib/schemas/models/orders.d.ts +240 -240
- package/lib/schemas/models/tenant_purchase_orders.d.ts +132 -0
- package/lib/schemas/models/tenant_purchase_orders.js +36 -0
- package/lib/schemas/models/warehouse_purchase_orders.d.ts +132 -0
- package/lib/schemas/models/warehouse_purchase_orders.js +48 -0
- package/lib/schemas/types/index.d.ts +1 -0
- package/lib/schemas/types/index.js +1 -0
- package/lib/schemas/types/materialized_tenant_day_readiness.d.ts +28 -0
- package/lib/schemas/types/materialized_tenant_day_readiness.js +2 -0
- package/lib/schemas/types/tenant_purchase_orders.d.ts +28 -0
- package/lib/schemas/types/warehouse_purchase_orders.d.ts +12 -0
- package/lib/tests/materialized-reports/materialized-day-readiness.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-day-readiness.test.js +64 -0
- package/package.json +1 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
4
|
+
const materialized_day_readiness_1 = require("../../helpers/materialized-reports/materialized-day-readiness");
|
|
5
|
+
const report_contract_1 = require("../../helpers/reporting-contract/report-contract");
|
|
6
|
+
const record = (over = {}) => ({
|
|
7
|
+
tenant_id: 'tenant-a',
|
|
8
|
+
localDate: '2026-09-14',
|
|
9
|
+
report_key: report_contract_1.REPORT_KEY_ENUM.DELIVERY,
|
|
10
|
+
schema_version: MATERIALIZED_REPORTS_1.MATERIALIZED_TENANT_DAY_READINESS_SCHEMA_VERSION,
|
|
11
|
+
status: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_READINESS_STATUS_ENUM.COMMITTED,
|
|
12
|
+
...over,
|
|
13
|
+
});
|
|
14
|
+
describe('materialized day readiness contract', () => {
|
|
15
|
+
it('covers exactly the five production writers', () => {
|
|
16
|
+
expect([...MATERIALIZED_REPORTS_1.MATERIALIZED_READINESS_REPORT_KEYS].sort()).toEqual([
|
|
17
|
+
report_contract_1.REPORT_KEY_ENUM.OVERVIEW,
|
|
18
|
+
report_contract_1.REPORT_KEY_ENUM.DISCOUNTS,
|
|
19
|
+
report_contract_1.REPORT_KEY_ENUM.PREP_TIME,
|
|
20
|
+
report_contract_1.REPORT_KEY_ENUM.DELIVERY,
|
|
21
|
+
report_contract_1.REPORT_KEY_ENUM.DIALER,
|
|
22
|
+
].sort());
|
|
23
|
+
for (const key of MATERIALIZED_REPORTS_1.MATERIALIZED_READINESS_REPORT_KEYS) {
|
|
24
|
+
expect((0, materialized_day_readiness_1.isMaterializedReadinessReportKey)(key)).toBe(true);
|
|
25
|
+
}
|
|
26
|
+
for (const key of ['CASH_IN_OUT', 'SALES_COMPARISON', 'HOURLY_COMPARISON', 'PAYMENTS_COMPARISON']) {
|
|
27
|
+
expect((0, materialized_day_readiness_1.isMaterializedReadinessReportKey)(key)).toBe(false);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
it('is an explicit all-requested-tenants cross product', () => {
|
|
31
|
+
const gaps = (0, materialized_day_readiness_1.summarizeMaterializedDayReadiness)({
|
|
32
|
+
reportKey: report_contract_1.REPORT_KEY_ENUM.DELIVERY,
|
|
33
|
+
tenants: ['tenant-a', 'tenant-b'],
|
|
34
|
+
dates: ['2026-09-14', '2026-09-15'],
|
|
35
|
+
records: [record(), record({ localDate: '2026-09-15' })],
|
|
36
|
+
});
|
|
37
|
+
expect(gaps.missing_tenants).toEqual(['tenant-b']);
|
|
38
|
+
expect(gaps.missing_dates).toEqual(['2026-09-14', '2026-09-15']);
|
|
39
|
+
expect(gaps.missing_pairs).toHaveLength(2);
|
|
40
|
+
});
|
|
41
|
+
it('separates missing from NEEDS_RECONCILIATION and ignores other versions', () => {
|
|
42
|
+
const gaps = (0, materialized_day_readiness_1.summarizeMaterializedDayReadiness)({
|
|
43
|
+
reportKey: report_contract_1.REPORT_KEY_ENUM.DELIVERY,
|
|
44
|
+
tenants: ['tenant-a'],
|
|
45
|
+
dates: ['2026-09-14', '2026-09-15', '2026-09-16'],
|
|
46
|
+
records: [
|
|
47
|
+
record({ status: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_READINESS_STATUS_ENUM.NEEDS_RECONCILIATION }),
|
|
48
|
+
record({ localDate: '2026-09-15', schema_version: 0 }),
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
expect(gaps.missing_dates).toEqual(['2026-09-15', '2026-09-16']);
|
|
52
|
+
expect(gaps.needs_reconciliation_dates).toEqual(['2026-09-14']);
|
|
53
|
+
});
|
|
54
|
+
it('never builds a readiness document for an out-of-scope report', () => {
|
|
55
|
+
expect(() => (0, materialized_day_readiness_1.buildMaterializedDayReadinessDocument)({
|
|
56
|
+
tenantId: 'tenant-a',
|
|
57
|
+
localDate: '2026-09-14',
|
|
58
|
+
reportKey: report_contract_1.REPORT_KEY_ENUM.CASH_IN_OUT,
|
|
59
|
+
status: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_READINESS_STATUS_ENUM.COMMITTED,
|
|
60
|
+
runId: 'run-1',
|
|
61
|
+
committedAt: new Date(),
|
|
62
|
+
})).toThrow(/outside the five report readiness contract/);
|
|
63
|
+
});
|
|
64
|
+
});
|