@managesome/eposmatic-toolkit 0.4.64 → 0.4.65

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.
Files changed (29) hide show
  1. package/esm/constants/MATERIALIZED_SCHEMA_VERSIONS.js +3 -0
  2. package/esm/helpers/materialized-reports/index.js +1 -1
  3. package/esm/helpers/materialized-reports/materialized-cash-compile-helpers.js +1 -2
  4. package/esm/helpers/materialized-reports/{materialized-discount-source-helpers.js → materialized-discount-source-assembly.js} +13 -3
  5. package/esm/helpers/materialized-reports/report-compile.js +2 -0
  6. package/esm/schemas/models/materialized_tenant_cash_entries.js +1 -1
  7. package/esm/schemas/models/materialized_tenant_cash_reports.js +1 -1
  8. package/esm/schemas/models/materialized_tenant_discount_sources.js +1 -1
  9. package/lib/constants/MATERIALIZED_SCHEMA_VERSIONS.d.ts +3 -0
  10. package/lib/constants/MATERIALIZED_SCHEMA_VERSIONS.js +4 -1
  11. package/lib/helpers/materialized-reports/index.d.ts +1 -1
  12. package/lib/helpers/materialized-reports/index.js +1 -1
  13. package/lib/helpers/materialized-reports/materialized-cash-compile-helpers.js +3 -4
  14. package/lib/helpers/materialized-reports/{materialized-discount-source-helpers.js → materialized-discount-source-assembly.js} +14 -4
  15. package/lib/helpers/materialized-reports/report-compile.d.ts +2 -0
  16. package/lib/helpers/materialized-reports/report-compile.js +5 -1
  17. package/lib/schemas/models/materialized_tenant_cash_entries.d.ts +0 -13
  18. package/lib/schemas/models/materialized_tenant_cash_entries.js +3 -3
  19. package/lib/schemas/models/materialized_tenant_cash_reports.d.ts +0 -20
  20. package/lib/schemas/models/materialized_tenant_cash_reports.js +3 -3
  21. package/lib/schemas/models/materialized_tenant_discount_sources.d.ts +0 -19
  22. package/lib/schemas/models/materialized_tenant_discount_sources.js +3 -3
  23. package/lib/tests/materialized-reports/materialized-discount-scenarios.test.js +2 -2
  24. package/lib/tests/materialized-reports/materialized-discount-sources.test.js +41 -41
  25. package/lib/tests/materialized-reports/materialized-integer-contract.test.js +2 -2
  26. package/lib/tests/materialized-reports/real-discount-orders.test.js +2 -2
  27. package/lib/tests/materialized-reports/report-platform/registry-conformance.test.js +2 -1
  28. package/package.json +1 -1
  29. /package/lib/helpers/materialized-reports/{materialized-discount-source-helpers.d.ts → materialized-discount-source-assembly.d.ts} +0 -0
@@ -8,6 +8,9 @@
8
8
  * Keep this module dependency-free: it is imported by the worker compile path.
9
9
  */
10
10
  export const MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION = 1;
11
+ export const MATERIALIZED_TENANT_CASH_ENTRIES_SCHEMA_VERSION = 1;
12
+ export const MATERIALIZED_TENANT_CASH_REPORTS_SCHEMA_VERSION = 1;
13
+ export const MATERIALIZED_TENANT_DISCOUNT_SOURCES_SCHEMA_VERSION = 1;
11
14
  export const MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION = 1;
12
15
  export const MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION = 1;
13
16
  export const MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION = 1;
@@ -9,7 +9,7 @@ export * from './materialized-discount-classification-helpers';
9
9
  export * from './materialized-discount-close-day-helpers';
10
10
  export * from './materialized-discount-compile-helpers';
11
11
  export * from './materialized-discount-details-helpers';
12
- export * from './materialized-discount-source-helpers';
12
+ export * from './materialized-discount-source-assembly';
13
13
  export * from './materialized-hourly-comparison-close-day-helpers';
14
14
  export * from './materialized-hourly-comparison-compile-helpers';
15
15
  export * from './materialized-hourly-comparison-selection-helpers';
@@ -1,8 +1,7 @@
1
1
  import { ALL_DAY_INDEX } from '../../constants/ENUMS';
2
2
  import { CASH_IN_OUT_REF_ENUM, CASH_IN_OUT_TYPE_ENUM } from '../../constants/enums/cash';
3
3
  import { CASH_KEY_FILTERS, MATERIALIZED_REPORT_SCOPE_ENUM } from '../../constants/MATERIALIZED_REPORTS';
4
- import { MATERIALIZED_TENANT_CASH_ENTRIES_SCHEMA_VERSION } from '../../schemas/models/materialized_tenant_cash_entries';
5
- import { MATERIALIZED_TENANT_CASH_REPORTS_SCHEMA_VERSION } from '../../schemas/models/materialized_tenant_cash_reports';
4
+ import { MATERIALIZED_TENANT_CASH_ENTRIES_SCHEMA_VERSION, MATERIALIZED_TENANT_CASH_REPORTS_SCHEMA_VERSION, } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
6
5
  import { addCashMovement, classifyCashMovement, addCashSession, finalizeCashAccumulator, freshCashAccumulator, } from './materialized-cash-classification-helpers';
7
6
  /**
8
7
  * M3 cash - key grammar and the day compile.
@@ -1,6 +1,16 @@
1
- import mongoose from 'mongoose';
1
+ /**
2
+ * PURE "by discount" source ASSEMBLY.
3
+ *
4
+ * This module contains the complete source-identity classifier + document
5
+ * assembly used by BOTH the materialization write path and the operations live
6
+ * compile worker. It has NO mongoose import, NO model import and NO DB access:
7
+ * ids are generated with the same `bson-objectid` approach as the other pure
8
+ * close-day helpers (below the legacy `_id` was a Mongoose ObjectId, which was
9
+ * the only reason this helper could not run in a worker).
10
+ */
11
+ import ObjectID from 'bson-objectid';
2
12
  import { DISCOUNTS_KEY_FILTERS, MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM, MATERIALIZED_DISCOUNT_LEVEL_ENUM, MATERIALIZED_DISCOUNT_RATE_KIND_ENUM, MATERIALIZED_DISCOUNT_SLOT_ENUM, MATERIALIZED_DISCOUNT_SOURCE_CLASS_ENUM, MATERIALIZED_DISCOUNT_SOURCE_KEY, MATERIALIZED_DISCOUNT_SOURCE_KEY_PREFIX, MATERIALIZED_DISCOUNT_SUB_KIND_ENUM, } from '../../constants/MATERIALIZED_REPORTS';
3
- import { MATERIALIZED_TENANT_DISCOUNT_SOURCES_SCHEMA_VERSION } from '../../schemas/models/materialized_tenant_discount_sources';
13
+ import { MATERIALIZED_TENANT_DISCOUNT_SOURCES_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
4
14
  /** `'VISA CARD'` / `'visa-card'` → `'visa_card'`; bounded and lowercase. */
5
15
  export function normalizeDiscountSourceKeyPart(value) {
6
16
  if (typeof value !== 'string')
@@ -380,7 +390,7 @@ export function buildDiscountSourcesForScope(input) {
380
390
  ? MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM.FREE_ITEM
381
391
  : MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM.DISCOUNT;
382
392
  docs.push({
383
- _id: new mongoose.Types.ObjectId().toHexString(),
393
+ _id: new ObjectID().toHexString(),
384
394
  tenant_id: tenantId,
385
395
  brand_id: brandId,
386
396
  scope_context: scopeContext,
@@ -20,6 +20,8 @@ export { compileTenantPrepTimeReports } from './materialized-prep-time-compile-h
20
20
  export { buildTenantPrepTimeCloseDayPlan, getMaterializedPrepTimePeriodDayScopeFields, getMaterializedPrepTimeReportPeriodDayScopeFields, } from './materialized-prep-time-close-day-helpers';
21
21
  export { compileTenantDiscountReports } from './materialized-discount-compile-helpers';
22
22
  export { buildTenantDiscountCloseDayPlan } from './materialized-discount-close-day-helpers';
23
+ export { buildDiscountSourcesForScope } from './materialized-discount-source-assembly';
24
+ export { compileTenantCashReports } from './materialized-cash-compile-helpers';
23
25
  export { compileTenantDeliveryReports } from './materialized-delivery-compile-helpers';
24
26
  export { buildTenantDeliveryCloseDayPlan } from './materialized-delivery-close-day-helpers';
25
27
  export { compileTenantDeliveryGeoCellsWithStats } from './materialized-tenant-delivery-geo-helpers';
@@ -14,7 +14,7 @@ import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, CASH_KEY_FILTERS, MATERIALIZED_CAS
14
14
  * Version of the cash ENTRY rules. Bump when row semantics change - historical
15
15
  * documents must then be re-materialized. PRE-RELEASE: folds into version `1`.
16
16
  */
17
- export const MATERIALIZED_TENANT_CASH_ENTRIES_SCHEMA_VERSION = 1;
17
+ import { MATERIALIZED_TENANT_CASH_ENTRIES_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
18
18
  const CashEntrySchema = new Schema({
19
19
  cash_in_out_id: { type: String, required: true },
20
20
  entry_key: { type: String, required: true },
@@ -20,7 +20,7 @@ import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, CASH_KEY_FILTERS, MATERIALIZED_CAS
20
20
  * historical documents must then be re-materialized. PRE-RELEASE: folds into
21
21
  * version `1`.
22
22
  */
23
- export const MATERIALIZED_TENANT_CASH_REPORTS_SCHEMA_VERSION = 1;
23
+ import { MATERIALIZED_TENANT_CASH_REPORTS_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
24
24
  export const MaterializedTenantCashReportSchema = new Schema({
25
25
  tenant_id: { type: String, required: true },
26
26
  brand_id: { type: String, required: true },
@@ -19,7 +19,7 @@ import { ALL_MATERIALIZED_DISCOUNT_ENTRY_KINDS, ALL_MATERIALIZED_DISCOUNT_LEVELS
19
19
  * grouping or rate rule changes — historical documents must then be rebuilt
20
20
  * with the backfill script.
21
21
  */
22
- export const MATERIALIZED_TENANT_DISCOUNT_SOURCES_SCHEMA_VERSION = 1;
22
+ import { MATERIALIZED_TENANT_DISCOUNT_SOURCES_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
23
23
  const DiscountSourceKeyMetricsSchema = new Schema({
24
24
  key: { type: String, required: true },
25
25
  order_count: { type: Number, required: true, min: 0, default: 0 },
@@ -8,6 +8,9 @@
8
8
  * Keep this module dependency-free: it is imported by the worker compile path.
9
9
  */
10
10
  export declare const MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION = 1;
11
+ export declare const MATERIALIZED_TENANT_CASH_ENTRIES_SCHEMA_VERSION = 1;
12
+ export declare const MATERIALIZED_TENANT_CASH_REPORTS_SCHEMA_VERSION = 1;
13
+ export declare const MATERIALIZED_TENANT_DISCOUNT_SOURCES_SCHEMA_VERSION = 1;
11
14
  export declare const MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION = 1;
12
15
  export declare const MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION = 1;
13
16
  export declare const MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION = 1;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION = void 0;
3
+ exports.MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DISCOUNT_SOURCES_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_CASH_REPORTS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_CASH_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION = void 0;
4
4
  /**
5
5
  * PURE materialized-report schema versions.
6
6
  *
@@ -11,6 +11,9 @@ exports.MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_SCHEMA_VERSION = exports.MATE
11
11
  * Keep this module dependency-free: it is imported by the worker compile path.
12
12
  */
13
13
  exports.MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION = 1;
14
+ exports.MATERIALIZED_TENANT_CASH_ENTRIES_SCHEMA_VERSION = 1;
15
+ exports.MATERIALIZED_TENANT_CASH_REPORTS_SCHEMA_VERSION = 1;
16
+ exports.MATERIALIZED_TENANT_DISCOUNT_SOURCES_SCHEMA_VERSION = 1;
14
17
  exports.MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION = 1;
15
18
  exports.MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION = 1;
16
19
  exports.MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION = 1;
@@ -9,7 +9,7 @@ export * from './materialized-discount-classification-helpers';
9
9
  export * from './materialized-discount-close-day-helpers';
10
10
  export * from './materialized-discount-compile-helpers';
11
11
  export * from './materialized-discount-details-helpers';
12
- export * from './materialized-discount-source-helpers';
12
+ export * from './materialized-discount-source-assembly';
13
13
  export * from './materialized-hourly-comparison-close-day-helpers';
14
14
  export * from './materialized-hourly-comparison-compile-helpers';
15
15
  export * from './materialized-hourly-comparison-selection-helpers';
@@ -48,7 +48,7 @@ __exportStar(require("./materialized-discount-classification-helpers"), exports)
48
48
  __exportStar(require("./materialized-discount-close-day-helpers"), exports);
49
49
  __exportStar(require("./materialized-discount-compile-helpers"), exports);
50
50
  __exportStar(require("./materialized-discount-details-helpers"), exports);
51
- __exportStar(require("./materialized-discount-source-helpers"), exports);
51
+ __exportStar(require("./materialized-discount-source-assembly"), exports);
52
52
  __exportStar(require("./materialized-hourly-comparison-close-day-helpers"), exports);
53
53
  __exportStar(require("./materialized-hourly-comparison-compile-helpers"), exports);
54
54
  __exportStar(require("./materialized-hourly-comparison-selection-helpers"), exports);
@@ -8,8 +8,7 @@ exports.compileTenantCashReports = compileTenantCashReports;
8
8
  const ENUMS_1 = require("../../constants/ENUMS");
9
9
  const cash_1 = require("../../constants/enums/cash");
10
10
  const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
11
- const materialized_tenant_cash_entries_1 = require("../../schemas/models/materialized_tenant_cash_entries");
12
- const materialized_tenant_cash_reports_1 = require("../../schemas/models/materialized_tenant_cash_reports");
11
+ const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
13
12
  const materialized_cash_classification_helpers_1 = require("./materialized-cash-classification-helpers");
14
13
  /**
15
14
  * M3 cash - key grammar and the day compile.
@@ -192,7 +191,7 @@ function compileTenantCashReports(input) {
192
191
  sale_type_key_filters: [...MATERIALIZED_REPORTS_1.CASH_KEY_FILTERS],
193
192
  cash_counters: cashCounters,
194
193
  cash_counter_rows: cashCounterRows,
195
- schema_version: materialized_tenant_cash_reports_1.MATERIALIZED_TENANT_CASH_REPORTS_SCHEMA_VERSION,
194
+ schema_version: MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_CASH_REPORTS_SCHEMA_VERSION,
196
195
  source_watermark: watermark,
197
196
  computed_at: computedAt,
198
197
  createdAt: computedAt,
@@ -209,7 +208,7 @@ function compileTenantCashReports(input) {
209
208
  day_index: dayIndexOf(localDate),
210
209
  sale_type_key_filters: [...MATERIALIZED_REPORTS_1.CASH_KEY_FILTERS],
211
210
  cash_entries: Object.keys(cashEntries).length === 0 ? null : cashEntries,
212
- schema_version: materialized_tenant_cash_entries_1.MATERIALIZED_TENANT_CASH_ENTRIES_SCHEMA_VERSION,
211
+ schema_version: MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_CASH_ENTRIES_SCHEMA_VERSION,
213
212
  source_watermark: watermark,
214
213
  computed_at: computedAt,
215
214
  createdAt: computedAt,
@@ -9,9 +9,19 @@ exports.classifyDiscountEntrySource = classifyDiscountEntrySource;
9
9
  exports.buildDiscountSourcesForScope = buildDiscountSourcesForScope;
10
10
  exports.discountSourceDeltaCovers = discountSourceDeltaCovers;
11
11
  exports.applyDiscountSourceDelta = applyDiscountSourceDelta;
12
- const mongoose_1 = __importDefault(require("mongoose"));
12
+ /**
13
+ * PURE "by discount" source ASSEMBLY.
14
+ *
15
+ * This module contains the complete source-identity classifier + document
16
+ * assembly used by BOTH the materialization write path and the operations live
17
+ * compile worker. It has NO mongoose import, NO model import and NO DB access:
18
+ * ids are generated with the same `bson-objectid` approach as the other pure
19
+ * close-day helpers (below the legacy `_id` was a Mongoose ObjectId, which was
20
+ * the only reason this helper could not run in a worker).
21
+ */
22
+ const bson_objectid_1 = __importDefault(require("bson-objectid"));
13
23
  const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
14
- const materialized_tenant_discount_sources_1 = require("../../schemas/models/materialized_tenant_discount_sources");
24
+ const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
15
25
  /** `'VISA CARD'` / `'visa-card'` → `'visa_card'`; bounded and lowercase. */
16
26
  function normalizeDiscountSourceKeyPart(value) {
17
27
  if (typeof value !== 'string')
@@ -391,7 +401,7 @@ function buildDiscountSourcesForScope(input) {
391
401
  ? MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM.FREE_ITEM
392
402
  : MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM.DISCOUNT;
393
403
  docs.push({
394
- _id: new mongoose_1.default.Types.ObjectId().toHexString(),
404
+ _id: new bson_objectid_1.default().toHexString(),
395
405
  tenant_id: tenantId,
396
406
  brand_id: brandId,
397
407
  scope_context: scopeContext,
@@ -420,7 +430,7 @@ function buildDiscountSourcesForScope(input) {
420
430
  .sort(([a], [b]) => a.localeCompare(b))
421
431
  .map(([key, metrics]) => metricsToKeyMetrics(key, metrics)),
422
432
  sale_type_key_filters: [...MATERIALIZED_REPORTS_1.DISCOUNTS_KEY_FILTERS],
423
- schema_version: materialized_tenant_discount_sources_1.MATERIALIZED_TENANT_DISCOUNT_SOURCES_SCHEMA_VERSION,
433
+ schema_version: MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_DISCOUNT_SOURCES_SCHEMA_VERSION,
424
434
  source_watermark: sourceWatermark,
425
435
  computed_at: computedAt,
426
436
  createdAt: computedAt,
@@ -20,6 +20,8 @@ export { compileTenantPrepTimeReports } from './materialized-prep-time-compile-h
20
20
  export { buildTenantPrepTimeCloseDayPlan, getMaterializedPrepTimePeriodDayScopeFields, getMaterializedPrepTimeReportPeriodDayScopeFields, } from './materialized-prep-time-close-day-helpers';
21
21
  export { compileTenantDiscountReports } from './materialized-discount-compile-helpers';
22
22
  export { buildTenantDiscountCloseDayPlan } from './materialized-discount-close-day-helpers';
23
+ export { buildDiscountSourcesForScope } from './materialized-discount-source-assembly';
24
+ export { compileTenantCashReports } from './materialized-cash-compile-helpers';
23
25
  export { compileTenantDeliveryReports } from './materialized-delivery-compile-helpers';
24
26
  export { buildTenantDeliveryCloseDayPlan } from './materialized-delivery-close-day-helpers';
25
27
  export { compileTenantDeliveryGeoCellsWithStats } from './materialized-tenant-delivery-geo-helpers';
@@ -14,7 +14,7 @@
14
14
  * a worker.
15
15
  */
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.normalizeOverviewAggregatedShape = exports.resolveCreditBillDay = exports.getMaterializedCreditBillScopeRefsForIssue = exports.getMaterializedCreditBillScopeRefsForDay = exports.computeMaterializedCreditBillTotalsFromReportsByKey = exports.buildMaterializedCreditBillSelectionFromScopeGroups = exports.applyCreditResolutionToReportDocuments = exports.buildTenantSalesOverviewCloseDayPlan = exports.sumMaterializedTenantSalesOverviewReports = exports.convertOrdersToMaterializedTenantSalesOverviewReports = exports.buildReportResponse = exports.buildReportMeta = exports.buildReportDetailsResponse = exports.REPORT_MODE_ENUM = exports.REPORT_KEY_ENUM = exports.parseMaterializedLocalDate = exports.getMaterializedPeriodScopeFields = exports.mergeMaterializedDineinEntryPages = exports.dineinKeyPassesFilters = exports.pruneDocumentDineinMaps = exports.foldMaterializedDineinPeriodCounters = exports.buildTenantDineinCloseDayPlan = exports.compileTenantDineinReports = exports.buildTenantDialerCloseDayPlan = exports.compileTenantDialerReports = exports.compileTenantDeliveryGeoCellsWithStats = exports.buildTenantDeliveryCloseDayPlan = exports.compileTenantDeliveryReports = exports.buildTenantDiscountCloseDayPlan = exports.compileTenantDiscountReports = exports.getMaterializedPrepTimeReportPeriodDayScopeFields = exports.getMaterializedPrepTimePeriodDayScopeFields = exports.buildTenantPrepTimeCloseDayPlan = exports.compileTenantPrepTimeReports = exports.REPORT_SALE_TYPE_ENUM = exports.SALES_OVERVIEW_KEY_FILTERS = exports.MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION = exports.MATERIALIZED_REPORT_SCOPE_ENUM = exports.MATERIALIZED_PREP_TIME_REPORT_SCOPES = exports.MATERIALIZED_PREP_TIME_ITEM_SCOPES = exports.MATERIALIZED_DINEIN_UNKNOWN_TOKEN = exports.MATERIALIZED_DINEIN_SPLIT_PARENT_DELETE_REASON = exports.MATERIALIZED_DINEIN_REPORT_SCOPES = exports.MATERIALIZED_DINEIN_ORIGIN_ENUM = void 0;
17
+ exports.normalizeOverviewAggregatedShape = exports.resolveCreditBillDay = exports.getMaterializedCreditBillScopeRefsForIssue = exports.getMaterializedCreditBillScopeRefsForDay = exports.computeMaterializedCreditBillTotalsFromReportsByKey = exports.buildMaterializedCreditBillSelectionFromScopeGroups = exports.applyCreditResolutionToReportDocuments = exports.buildTenantSalesOverviewCloseDayPlan = exports.sumMaterializedTenantSalesOverviewReports = exports.convertOrdersToMaterializedTenantSalesOverviewReports = exports.buildReportResponse = exports.buildReportMeta = exports.buildReportDetailsResponse = exports.REPORT_MODE_ENUM = exports.REPORT_KEY_ENUM = exports.parseMaterializedLocalDate = exports.getMaterializedPeriodScopeFields = exports.mergeMaterializedDineinEntryPages = exports.dineinKeyPassesFilters = exports.pruneDocumentDineinMaps = exports.foldMaterializedDineinPeriodCounters = exports.buildTenantDineinCloseDayPlan = exports.compileTenantDineinReports = exports.buildTenantDialerCloseDayPlan = exports.compileTenantDialerReports = exports.compileTenantDeliveryGeoCellsWithStats = exports.buildTenantDeliveryCloseDayPlan = exports.compileTenantDeliveryReports = exports.compileTenantCashReports = exports.buildDiscountSourcesForScope = exports.buildTenantDiscountCloseDayPlan = exports.compileTenantDiscountReports = exports.getMaterializedPrepTimeReportPeriodDayScopeFields = exports.getMaterializedPrepTimePeriodDayScopeFields = exports.buildTenantPrepTimeCloseDayPlan = exports.compileTenantPrepTimeReports = exports.REPORT_SALE_TYPE_ENUM = exports.SALES_OVERVIEW_KEY_FILTERS = exports.MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION = exports.MATERIALIZED_REPORT_SCOPE_ENUM = exports.MATERIALIZED_PREP_TIME_REPORT_SCOPES = exports.MATERIALIZED_PREP_TIME_ITEM_SCOPES = exports.MATERIALIZED_DINEIN_UNKNOWN_TOKEN = exports.MATERIALIZED_DINEIN_SPLIT_PARENT_DELETE_REASON = exports.MATERIALIZED_DINEIN_REPORT_SCOPES = exports.MATERIALIZED_DINEIN_ORIGIN_ENUM = void 0;
18
18
  var MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
19
19
  Object.defineProperty(exports, "MATERIALIZED_DINEIN_ORIGIN_ENUM", { enumerable: true, get: function () { return MATERIALIZED_REPORTS_1.MATERIALIZED_DINEIN_ORIGIN_ENUM; } });
20
20
  Object.defineProperty(exports, "MATERIALIZED_DINEIN_REPORT_SCOPES", { enumerable: true, get: function () { return MATERIALIZED_REPORTS_1.MATERIALIZED_DINEIN_REPORT_SCOPES; } });
@@ -41,6 +41,10 @@ var materialized_discount_compile_helpers_1 = require("./materialized-discount-c
41
41
  Object.defineProperty(exports, "compileTenantDiscountReports", { enumerable: true, get: function () { return materialized_discount_compile_helpers_1.compileTenantDiscountReports; } });
42
42
  var materialized_discount_close_day_helpers_1 = require("./materialized-discount-close-day-helpers");
43
43
  Object.defineProperty(exports, "buildTenantDiscountCloseDayPlan", { enumerable: true, get: function () { return materialized_discount_close_day_helpers_1.buildTenantDiscountCloseDayPlan; } });
44
+ var materialized_discount_source_assembly_1 = require("./materialized-discount-source-assembly");
45
+ Object.defineProperty(exports, "buildDiscountSourcesForScope", { enumerable: true, get: function () { return materialized_discount_source_assembly_1.buildDiscountSourcesForScope; } });
46
+ var materialized_cash_compile_helpers_1 = require("./materialized-cash-compile-helpers");
47
+ Object.defineProperty(exports, "compileTenantCashReports", { enumerable: true, get: function () { return materialized_cash_compile_helpers_1.compileTenantCashReports; } });
44
48
  var materialized_delivery_compile_helpers_1 = require("./materialized-delivery-compile-helpers");
45
49
  Object.defineProperty(exports, "compileTenantDeliveryReports", { enumerable: true, get: function () { return materialized_delivery_compile_helpers_1.compileTenantDeliveryReports; } });
46
50
  var materialized_delivery_close_day_helpers_1 = require("./materialized-delivery-close-day-helpers");
@@ -1,17 +1,4 @@
1
1
  import { Schema } from 'mongoose';
2
- /**
3
- * Mongoose schema for `materialized_tenant_cash_in_out_entries` - the STATEMENT
4
- * rows behind the cash report's drill-down (owner decision (e3): SPLIT).
5
- *
6
- * Scopes are capped at `LOCAL_MONTH`. Each row mirrors what the POS ledger already
7
- * renders (Detail / Before / signed Amount / After), and carries the four
8
- * lifecycle FLAGS computed at compile time so the read never re-derives them.
9
- */
10
- /**
11
- * Version of the cash ENTRY rules. Bump when row semantics change - historical
12
- * documents must then be re-materialized. PRE-RELEASE: folds into version `1`.
13
- */
14
- export declare const MATERIALIZED_TENANT_CASH_ENTRIES_SCHEMA_VERSION = 1;
15
2
  declare const CashEntrySchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
16
3
  _id: false;
17
4
  }, {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MATERIALIZED_TENANT_CASH_ENTRIES_INDEX_OPTIONS = exports.MATERIALIZED_TENANT_CASH_ENTRIES_COLLECTION_INDEXES = exports.MATERIALIZED_TENANT_CASH_ENTRIES_COLLECTION_NAME = exports.MaterializedTenantCashEntriesSchema = exports.CashEntrySchema = exports.MATERIALIZED_TENANT_CASH_ENTRIES_SCHEMA_VERSION = void 0;
3
+ exports.MATERIALIZED_TENANT_CASH_ENTRIES_INDEX_OPTIONS = exports.MATERIALIZED_TENANT_CASH_ENTRIES_COLLECTION_INDEXES = exports.MATERIALIZED_TENANT_CASH_ENTRIES_COLLECTION_NAME = exports.MaterializedTenantCashEntriesSchema = exports.CashEntrySchema = void 0;
4
4
  const mongoose_1 = require("mongoose");
5
5
  const ENUMS_1 = require("../../constants/ENUMS");
6
6
  const cash_1 = require("../../constants/enums/cash");
@@ -17,7 +17,7 @@ const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
17
17
  * Version of the cash ENTRY rules. Bump when row semantics change - historical
18
18
  * documents must then be re-materialized. PRE-RELEASE: folds into version `1`.
19
19
  */
20
- exports.MATERIALIZED_TENANT_CASH_ENTRIES_SCHEMA_VERSION = 1;
20
+ const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
21
21
  const CashEntrySchema = new mongoose_1.Schema({
22
22
  cash_in_out_id: { type: String, required: true },
23
23
  entry_key: { type: String, required: true },
@@ -67,7 +67,7 @@ exports.MaterializedTenantCashEntriesSchema = new mongoose_1.Schema({
67
67
  type: Number,
68
68
  required: true,
69
69
  immutable: true,
70
- default: exports.MATERIALIZED_TENANT_CASH_ENTRIES_SCHEMA_VERSION,
70
+ default: MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_CASH_ENTRIES_SCHEMA_VERSION,
71
71
  },
72
72
  source_watermark: { type: mongoose_1.Schema.Types.Date, required: true },
73
73
  computed_at: { type: mongoose_1.Schema.Types.Date, required: true },
@@ -1,24 +1,4 @@
1
1
  import { Schema } from 'mongoose';
2
- /**
3
- * Mongoose schema for `materialized_tenant_cash_in_out_reports` (M3).
4
- *
5
- * Counters ONLY - the statement rows live in the SIBLING entries collection
6
- * (`materialized_tenant_cash_in_out_entries`, decision (e3)).
7
- *
8
- * The counters are stored TWICE on purpose: a key-addressed MAP (`cash_counters`, the
9
- * store + formatter shape) and the SAME counters as an ARRAY OF ROWS
10
- * (`cash_counter_rows`, the READ shape), so the read aggregation is the canonical
11
- * unwind/group/direct-sum pattern instead of dynamic-key navigation.
12
- *
13
- * Key grammar is `<DRAWER_ID>:<REF_TYPE>` (decision (b3)) - cash has neither an
14
- * order status nor a platform.
15
- */
16
- /**
17
- * Version of the cash COUNTER rules. Bump when counter semantics change -
18
- * historical documents must then be re-materialized. PRE-RELEASE: folds into
19
- * version `1`.
20
- */
21
- export declare const MATERIALIZED_TENANT_CASH_REPORTS_SCHEMA_VERSION = 1;
22
2
  export declare const MaterializedTenantCashReportSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
23
3
  timestamps: true;
24
4
  versionKey: false;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MATERIALIZED_TENANT_CASH_REPORTS_INDEX_OPTIONS = exports.MATERIALIZED_TENANT_CASH_REPORTS_COLLECTION_INDEXES = exports.MATERIALIZED_TENANT_CASH_REPORTS_COLLECTION_NAME = exports.MaterializedTenantCashReportSchema = exports.MATERIALIZED_TENANT_CASH_REPORTS_SCHEMA_VERSION = void 0;
3
+ exports.MATERIALIZED_TENANT_CASH_REPORTS_INDEX_OPTIONS = exports.MATERIALIZED_TENANT_CASH_REPORTS_COLLECTION_INDEXES = exports.MATERIALIZED_TENANT_CASH_REPORTS_COLLECTION_NAME = exports.MaterializedTenantCashReportSchema = void 0;
4
4
  const mongoose_1 = require("mongoose");
5
5
  const ENUMS_1 = require("../../constants/ENUMS");
6
6
  const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
@@ -23,7 +23,7 @@ const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
23
23
  * historical documents must then be re-materialized. PRE-RELEASE: folds into
24
24
  * version `1`.
25
25
  */
26
- exports.MATERIALIZED_TENANT_CASH_REPORTS_SCHEMA_VERSION = 1;
26
+ const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
27
27
  exports.MaterializedTenantCashReportSchema = new mongoose_1.Schema({
28
28
  tenant_id: { type: String, required: true },
29
29
  brand_id: { type: String, required: true },
@@ -49,7 +49,7 @@ exports.MaterializedTenantCashReportSchema = new mongoose_1.Schema({
49
49
  type: Number,
50
50
  required: true,
51
51
  immutable: true,
52
- default: exports.MATERIALIZED_TENANT_CASH_REPORTS_SCHEMA_VERSION,
52
+ default: MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_CASH_REPORTS_SCHEMA_VERSION,
53
53
  },
54
54
  source_watermark: { type: mongoose_1.Schema.Types.Date, required: true },
55
55
  computed_at: { type: mongoose_1.Schema.Types.Date, required: true },
@@ -1,23 +1,4 @@
1
1
  import { Schema } from 'mongoose';
2
- /**
3
- * Mongoose schema for `materialized_tenant_discount_sources` — the DERIVED
4
- * "by discount" projection of the discounts report (see
5
- * `schemas/types/materialized_tenant_discount_sources.ts`).
6
- *
7
- * One document per (tenant, scope context, scope field, source key, level).
8
- * The top-level metrics are the sum of `key_metrics`, which carries the
9
- * `ORDER_STATUS:PLATFORM` split so the report filters stay exact.
10
- *
11
- * This collection is REBUILT from the post-plan entry documents in the close
12
- * transaction. It has no iteration history of its own: the parent entry
13
- * documents are the audit trail.
14
- */
15
- /**
16
- * Version of the source-projection rules. Bump when the source identity,
17
- * grouping or rate rule changes — historical documents must then be rebuilt
18
- * with the backfill script.
19
- */
20
- export declare const MATERIALIZED_TENANT_DISCOUNT_SOURCES_SCHEMA_VERSION = 1;
21
2
  declare const DiscountSourceKeyMetricsSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
22
3
  _id: false;
23
4
  }, {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MATERIALIZED_TENANT_DISCOUNT_SOURCES_INDEX_OPTIONS = exports.MATERIALIZED_TENANT_DISCOUNT_SOURCES_COLLECTION_INDEXES = exports.MATERIALIZED_TENANT_DISCOUNT_SOURCES_COLLECTION_NAME = exports.DiscountSourceKeyMetricsSchema = exports.MaterializedTenantDiscountSourceSchema = exports.MATERIALIZED_TENANT_DISCOUNT_SOURCES_SCHEMA_VERSION = void 0;
3
+ exports.MATERIALIZED_TENANT_DISCOUNT_SOURCES_INDEX_OPTIONS = exports.MATERIALIZED_TENANT_DISCOUNT_SOURCES_COLLECTION_INDEXES = exports.MATERIALIZED_TENANT_DISCOUNT_SOURCES_COLLECTION_NAME = exports.DiscountSourceKeyMetricsSchema = exports.MaterializedTenantDiscountSourceSchema = void 0;
4
4
  const mongoose_1 = require("mongoose");
5
5
  const ENUMS_1 = require("../../constants/ENUMS");
6
6
  const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
@@ -22,7 +22,7 @@ const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
22
22
  * grouping or rate rule changes — historical documents must then be rebuilt
23
23
  * with the backfill script.
24
24
  */
25
- exports.MATERIALIZED_TENANT_DISCOUNT_SOURCES_SCHEMA_VERSION = 1;
25
+ const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
26
26
  const DiscountSourceKeyMetricsSchema = new mongoose_1.Schema({
27
27
  key: { type: String, required: true },
28
28
  order_count: { type: Number, required: true, min: 0, default: 0 },
@@ -110,7 +110,7 @@ exports.MaterializedTenantDiscountSourceSchema = new mongoose_1.Schema({
110
110
  type: Number,
111
111
  required: true,
112
112
  immutable: true,
113
- default: exports.MATERIALIZED_TENANT_DISCOUNT_SOURCES_SCHEMA_VERSION,
113
+ default: MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_DISCOUNT_SOURCES_SCHEMA_VERSION,
114
114
  },
115
115
  source_watermark: { type: mongoose_1.Schema.Types.Date, required: true },
116
116
  computed_at: { type: mongoose_1.Schema.Types.Date, required: true },
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const globals_1 = require("@jest/globals");
4
4
  const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
5
5
  const materialized_discount_compile_helpers_1 = require("../../helpers/materialized-reports/materialized-discount-compile-helpers");
6
- const materialized_discount_source_helpers_1 = require("../../helpers/materialized-reports/materialized-discount-source-helpers");
6
+ const materialized_discount_source_assembly_1 = require("../../helpers/materialized-reports/materialized-discount-source-assembly");
7
7
  const materialized_integer_contract_1 = require("../../helpers/materialized-reports/materialized-integer-contract");
8
8
  /**
9
9
  * The Discounts scenarios that the real-order fixture and the classifier tests
@@ -96,7 +96,7 @@ const sourcesOf = (orders) => {
96
96
  const entry = compiled.entries.find((candidate) => candidate.scope_context === MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH);
97
97
  return {
98
98
  compiled,
99
- sources: (0, materialized_discount_source_helpers_1.buildDiscountSourcesForScope)({
99
+ sources: (0, materialized_discount_source_assembly_1.buildDiscountSourcesForScope)({
100
100
  tenantId: TENANT,
101
101
  brandId: BRAND,
102
102
  scopeContext: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH,
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
4
4
  const materialized_discount_accumulator_helpers_1 = require("../../helpers/materialized-reports/materialized-discount-accumulator-helpers");
5
- const materialized_discount_source_helpers_1 = require("../../helpers/materialized-reports/materialized-discount-source-helpers");
5
+ const materialized_discount_source_assembly_1 = require("../../helpers/materialized-reports/materialized-discount-source-assembly");
6
6
  /**
7
7
  * "By discount" SOURCE projection (M1) — the grouping that answers "which
8
8
  * discount was this?" instead of "which generated amount was it?".
@@ -63,7 +63,7 @@ const scopeInput = (rows) => ({
63
63
  describe('discount source identity', () => {
64
64
  it('keys a collection discount by its discount _id and keeps its name', () => {
65
65
  const id = '69f1c56ef9c86581b0ae9e36';
66
- const identity = (0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({
66
+ const identity = (0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({
67
67
  sub_kind: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SUB_KIND_ENUM.COLLECTION,
68
68
  discount_id: id,
69
69
  name: 'UBL Bank 15%',
@@ -74,15 +74,15 @@ describe('discount source identity', () => {
74
74
  expect(identity.level).toBe(MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_LEVEL_ENUM.ORDER);
75
75
  });
76
76
  it('groups every manual order amount under ONE source', () => {
77
- const a = (0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({ discount_id: 'MANUAL_50%', rate: 5000, name: 'Discount' }));
78
- const b = (0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({ discount_id: 'MANUAL_Rs 500', rate: 500, name: 'Apply Discount', is_percentage: false }));
77
+ const a = (0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({ discount_id: 'MANUAL_50%', rate: 5000, name: 'Discount' }));
78
+ const b = (0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({ discount_id: 'MANUAL_Rs 500', rate: 500, name: 'Apply Discount', is_percentage: false }));
79
79
  expect(a.source_key).toBe(MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SOURCE_KEY.MANUAL_ORDER);
80
80
  expect(b.source_key).toBe(a.source_key);
81
81
  expect(a.source_class).toBe(MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SOURCE_CLASS_ENUM.MANUAL);
82
82
  expect(a.source_name).toBe('Manual / quick discount');
83
83
  });
84
84
  it('separates item manual from order manual', () => {
85
- const identity = (0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({
85
+ const identity = (0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({
86
86
  level: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_LEVEL_ENUM.ITEM,
87
87
  item_id: 'item-1',
88
88
  discount_id: 'MANUAL_25%',
@@ -92,9 +92,9 @@ describe('discount source identity', () => {
92
92
  expect(identity.source_name).toBe('Manual item discount');
93
93
  });
94
94
  it('separates a payment-type discount from a manual one by its reason', () => {
95
- expect((0, materialized_discount_source_helpers_1.getPaymentTypeFromDiscountReason)('Discount applied for VISA CARD')).toBe('VISA CARD');
96
- expect((0, materialized_discount_source_helpers_1.normalizeDiscountSourceKeyPart)('VISA CARD')).toBe('visa_card');
97
- const identity = (0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({
95
+ expect((0, materialized_discount_source_assembly_1.getPaymentTypeFromDiscountReason)('Discount applied for VISA CARD')).toBe('VISA CARD');
96
+ expect((0, materialized_discount_source_assembly_1.normalizeDiscountSourceKeyPart)('VISA CARD')).toBe('visa_card');
97
+ const identity = (0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({
98
98
  discount_id: 'MANUAL_10%',
99
99
  rate: 1000,
100
100
  name: 'MANUAL_10%',
@@ -105,7 +105,7 @@ describe('discount source identity', () => {
105
105
  expect(identity.source_name).toBe('Visa Card discount');
106
106
  });
107
107
  it('groups a price override under one item source', () => {
108
- const identity = (0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({
108
+ const identity = (0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({
109
109
  level: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_LEVEL_ENUM.ITEM,
110
110
  item_id: 'item-1',
111
111
  sub_kind: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SUB_KIND_ENUM.PRICE_OVERRIDE,
@@ -119,7 +119,7 @@ describe('discount source identity', () => {
119
119
  });
120
120
  it('recognises catalog auto from the CURRENT marker, not the id shape', () => {
121
121
  const catalogItemId = '69f1c56ef9c86581b0ae9e36';
122
- const current = (0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({
122
+ const current = (0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({
123
123
  level: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_LEVEL_ENUM.ITEM,
124
124
  item_id: 'order-item-1',
125
125
  catalog_item_id: catalogItemId,
@@ -132,7 +132,7 @@ describe('discount source identity', () => {
132
132
  expect(current.sub_kind).toBe(MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SUB_KIND_ENUM.CATALOG_ITEM);
133
133
  // No legacy id-shape fallback: the same catalog id on a COLLECTION row is
134
134
  // a collection. Pre-release periods are replayed, not read through this.
135
- const noMarker = (0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({
135
+ const noMarker = (0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({
136
136
  level: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_LEVEL_ENUM.ITEM,
137
137
  item_id: 'order-item-1',
138
138
  catalog_item_id: catalogItemId,
@@ -145,7 +145,7 @@ describe('discount source identity', () => {
145
145
  it('keys loyalty offers, gift cards and wallet cashback separately', () => {
146
146
  const offer = '6aa472763689e5f08dd0599f';
147
147
  const giftCard = '6aa472763689e5f08dd059a0';
148
- const offerIdentity = (0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({
148
+ const offerIdentity = (0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({
149
149
  slot: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SLOT_ENUM.LOYALTY,
150
150
  sub_kind: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SUB_KIND_ENUM.OFFER,
151
151
  discount_id: offer,
@@ -154,7 +154,7 @@ describe('discount source identity', () => {
154
154
  }));
155
155
  expect(offerIdentity.source_key).toBe(`loyalty:offer:${offer}`);
156
156
  expect(offerIdentity.source_class).toBe(MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SOURCE_CLASS_ENUM.LOYALTY);
157
- const giftIdentity = (0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({
157
+ const giftIdentity = (0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({
158
158
  slot: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SLOT_ENUM.LOYALTY,
159
159
  sub_kind: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SUB_KIND_ENUM.OFFER,
160
160
  discount_id: giftCard,
@@ -163,7 +163,7 @@ describe('discount source identity', () => {
163
163
  }));
164
164
  expect(giftIdentity.source_key).toBe(`loyalty:gift_card:${giftCard}`);
165
165
  expect(giftIdentity.sub_kind).toBe(MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SUB_KIND_ENUM.GIFT_CARD);
166
- const walletIdentity = (0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({
166
+ const walletIdentity = (0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({
167
167
  slot: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SLOT_ENUM.LOYALTY,
168
168
  sub_kind: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SUB_KIND_ENUM.WALLET_CASHBACK,
169
169
  discount_id: 'wallet_cashback_redemption',
@@ -175,7 +175,7 @@ describe('discount source identity', () => {
175
175
  });
176
176
  it('keys a voucher by its offer id (fallback: the code)', () => {
177
177
  const offer = '6a14165680f2052bbbcbe9b7';
178
- expect((0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({
178
+ expect((0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({
179
179
  slot: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SLOT_ENUM.VOUCHER,
180
180
  sub_kind: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SUB_KIND_ENUM.OFFER,
181
181
  discount_id: offer,
@@ -183,7 +183,7 @@ describe('discount source identity', () => {
183
183
  reference_number: 'RS150',
184
184
  is_percentage: false,
185
185
  })).source_key).toBe(`voucher:${offer}`);
186
- expect((0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({
186
+ expect((0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({
187
187
  slot: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SLOT_ENUM.VOUCHER,
188
188
  sub_kind: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SUB_KIND_ENUM.OFFER,
189
189
  discount_id: null,
@@ -200,14 +200,14 @@ describe('discount source identity', () => {
200
200
  rate: null,
201
201
  is_percentage: null,
202
202
  };
203
- expect((0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({ ...base, entry_key: 'payment:1', complimentary_full: true, covered_amount: 1000 })).source_key).toBe(MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SOURCE_KEY.COMPLIMENTARY_FULL);
204
- expect((0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({ ...base, entry_key: 'payment:2', complimentary_full: false, covered_amount: 400 })).source_key).toBe(MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SOURCE_KEY.COMPLIMENTARY_PARTIAL);
205
- expect((0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({ ...base, entry_key: 'payment:3', complimentary_full: null })).source_key).toBe(MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SOURCE_KEY.COMPLIMENTARY_UNKNOWN);
203
+ expect((0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({ ...base, entry_key: 'payment:1', complimentary_full: true, covered_amount: 1000 })).source_key).toBe(MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SOURCE_KEY.COMPLIMENTARY_FULL);
204
+ expect((0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({ ...base, entry_key: 'payment:2', complimentary_full: false, covered_amount: 400 })).source_key).toBe(MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SOURCE_KEY.COMPLIMENTARY_PARTIAL);
205
+ expect((0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({ ...base, entry_key: 'payment:3', complimentary_full: null })).source_key).toBe(MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SOURCE_KEY.COMPLIMENTARY_UNKNOWN);
206
206
  });
207
207
  it('classifies a CATALOG_ITEM row from its current sub_kind', () => {
208
208
  // The current classifier writes CATALOG_ITEM; the explicit catalog_auto
209
209
  // marker is the primary signal, but the current sub_kind is equivalent.
210
- const identity = (0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({
210
+ const identity = (0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({
211
211
  level: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_LEVEL_ENUM.ITEM,
212
212
  item_id: '6abce4ef6d1de61c4383a59d', // order item _id
213
213
  catalog_item_id: null,
@@ -224,7 +224,7 @@ describe('discount source identity', () => {
224
224
  // The correct answer is COLLECTION; guessing from the display name or the
225
225
  // id shape would mislabel a real collection. Pre-release periods are
226
226
  // replayed, so this shape is not a supported compatibility path.
227
- const identity = (0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({
227
+ const identity = (0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({
228
228
  level: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_LEVEL_ENUM.ITEM,
229
229
  item_id: '6abce4ef6d1de61c4383a59d',
230
230
  catalog_item_id: null,
@@ -237,7 +237,7 @@ describe('discount source identity', () => {
237
237
  expect(identity.source_class).toBe(MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SOURCE_CLASS_ENUM.COLLECTION);
238
238
  });
239
239
  it('falls back to unattributed when no usable id exists', () => {
240
- const identity = (0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({
240
+ const identity = (0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({
241
241
  slot: null,
242
242
  sub_kind: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SUB_KIND_ENUM.UNATTRIBUTED,
243
243
  discount_id: null,
@@ -247,7 +247,7 @@ describe('discount source identity', () => {
247
247
  });
248
248
  describe('buildDiscountSourcesForScope', () => {
249
249
  it('groups two manual order rows into one source with distinct orders', () => {
250
- const docs = (0, materialized_discount_source_helpers_1.buildDiscountSourcesForScope)(scopeInput([
250
+ const docs = (0, materialized_discount_source_assembly_1.buildDiscountSourcesForScope)(scopeInput([
251
251
  entry({ order_id: 'o1', discount_id: 'MANUAL_50%', rate: 5000, amount: 500 }),
252
252
  entry({ order_id: 'o2', discount_id: 'MANUAL_Rs 200', rate: 200, is_percentage: false, amount: 200 }),
253
253
  ]));
@@ -264,7 +264,7 @@ describe('buildDiscountSourcesForScope', () => {
264
264
  expect(docs[0].percentage_row_count).toBe(1);
265
265
  });
266
266
  it('counts an order ONCE per source even with several item rows', () => {
267
- const docs = (0, materialized_discount_source_helpers_1.buildDiscountSourcesForScope)(scopeInput([
267
+ const docs = (0, materialized_discount_source_assembly_1.buildDiscountSourcesForScope)(scopeInput([
268
268
  entry({
269
269
  level: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_LEVEL_ENUM.ITEM,
270
270
  order_id: 'o1',
@@ -299,12 +299,12 @@ describe('buildDiscountSourcesForScope', () => {
299
299
  amount: 500,
300
300
  item_value: 500,
301
301
  });
302
- const allFree = (0, materialized_discount_source_helpers_1.buildDiscountSourcesForScope)(scopeInput([free]));
302
+ const allFree = (0, materialized_discount_source_assembly_1.buildDiscountSourcesForScope)(scopeInput([free]));
303
303
  expect(allFree[0].kind).toBe(MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM.FREE_ITEM);
304
304
  expect(allFree[0].free_item_count).toBe(1);
305
305
  expect(allFree[0].free_item_value).toBe(500);
306
306
  expect(allFree[0].discount_amount).toBe(500);
307
- const mixed = (0, materialized_discount_source_helpers_1.buildDiscountSourcesForScope)(scopeInput([
307
+ const mixed = (0, materialized_discount_source_assembly_1.buildDiscountSourcesForScope)(scopeInput([
308
308
  free,
309
309
  entry({
310
310
  kind: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM.DISCOUNT,
@@ -321,7 +321,7 @@ describe('buildDiscountSourcesForScope', () => {
321
321
  expect(mixed[0].discount_amount).toBe(600);
322
322
  });
323
323
  it('carries the complimentary coverage but never discount money', () => {
324
- const docs = (0, materialized_discount_source_helpers_1.buildDiscountSourcesForScope)(scopeInput([
324
+ const docs = (0, materialized_discount_source_assembly_1.buildDiscountSourcesForScope)(scopeInput([
325
325
  entry({
326
326
  kind: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM.COMPLIMENTARY,
327
327
  slot: null,
@@ -342,7 +342,7 @@ describe('buildDiscountSourcesForScope', () => {
342
342
  expect(docs[0].order_count).toBe(1);
343
343
  });
344
344
  it('keeps key_metrics and the top-level totals in lockstep', () => {
345
- const docs = (0, materialized_discount_source_helpers_1.buildDiscountSourcesForScope)({
345
+ const docs = (0, materialized_discount_source_assembly_1.buildDiscountSourcesForScope)({
346
346
  ...scopeInput([
347
347
  entry({ order_id: 'o1', discount_id: 'MANUAL_10%', amount: 100 }),
348
348
  entry({ order_id: 'o2', discount_id: 'MANUAL_10%', amount: 200 }),
@@ -380,7 +380,7 @@ describe('buildDiscountSourcesForScope', () => {
380
380
  covered_amount: 900,
381
381
  }),
382
382
  ];
383
- const docs = (0, materialized_discount_source_helpers_1.buildDiscountSourcesForScope)(scopeInput(rows));
383
+ const docs = (0, materialized_discount_source_assembly_1.buildDiscountSourcesForScope)(scopeInput(rows));
384
384
  const sourceTotal = docs.reduce((sum, doc) => sum + doc.discount_amount, 0);
385
385
  const entryTotal = rows.reduce((sum, row) => (row.kind === MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM.COMPLIMENTARY ? sum : sum + row.amount), 0);
386
386
  expect(sourceTotal).toBe(entryTotal);
@@ -487,7 +487,7 @@ describe('complimentary full/partial accumulator', () => {
487
487
  });
488
488
  describe('missing discount mechanisms (synthetic coverage)', () => {
489
489
  it('classifies an order-level loyalty offer', () => {
490
- const identity = (0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({
490
+ const identity = (0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({
491
491
  slot: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SLOT_ENUM.LOYALTY,
492
492
  sub_kind: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SUB_KIND_ENUM.OFFER,
493
493
  level: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_LEVEL_ENUM.ORDER,
@@ -500,7 +500,7 @@ describe('missing discount mechanisms (synthetic coverage)', () => {
500
500
  expect(identity.level).toBe(MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_LEVEL_ENUM.ORDER);
501
501
  });
502
502
  it('classifies an item-level voucher and keeps its reference', () => {
503
- const identity = (0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({
503
+ const identity = (0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({
504
504
  slot: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SLOT_ENUM.VOUCHER,
505
505
  sub_kind: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SUB_KIND_ENUM.OFFER,
506
506
  level: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_LEVEL_ENUM.ITEM,
@@ -514,7 +514,7 @@ describe('missing discount mechanisms (synthetic coverage)', () => {
514
514
  expect(identity.level).toBe(MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_LEVEL_ENUM.ITEM);
515
515
  });
516
516
  it('classifies a gift card from loyalty evidence/reference', () => {
517
- const identity = (0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({
517
+ const identity = (0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({
518
518
  slot: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SLOT_ENUM.LOYALTY,
519
519
  sub_kind: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SUB_KIND_ENUM.OFFER,
520
520
  level: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_LEVEL_ENUM.ORDER,
@@ -529,14 +529,14 @@ describe('missing discount mechanisms (synthetic coverage)', () => {
529
529
  });
530
530
  it('classifies order and item collection discounts at either level', () => {
531
531
  const id = '69f1c56ef9c86581b0ae9e36';
532
- const order = (0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({
532
+ const order = (0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({
533
533
  sub_kind: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SUB_KIND_ENUM.COLLECTION,
534
534
  level: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_LEVEL_ENUM.ORDER,
535
535
  discount_id: id,
536
536
  rate: 1500,
537
537
  name: 'Order Bank Discount',
538
538
  }));
539
- const item = (0, materialized_discount_source_helpers_1.classifyDiscountEntrySource)(entry({
539
+ const item = (0, materialized_discount_source_assembly_1.classifyDiscountEntrySource)(entry({
540
540
  sub_kind: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_SUB_KIND_ENUM.COLLECTION,
541
541
  level: MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_LEVEL_ENUM.ITEM,
542
542
  item_id: 'item-1',
@@ -639,7 +639,7 @@ describe('incremental source deltas', () => {
639
639
  ...over,
640
640
  });
641
641
  const sourceForSections = (sections) => {
642
- const docs = (0, materialized_discount_source_helpers_1.buildDiscountSourcesForScope)({
642
+ const docs = (0, materialized_discount_source_assembly_1.buildDiscountSourcesForScope)({
643
643
  tenantId: 'tenant-source-delta',
644
644
  brandId: 'brand-source-delta',
645
645
  scopeContext: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
@@ -655,8 +655,8 @@ describe('incremental source deltas', () => {
655
655
  const oldPercentage = sourceFor(row({ entry_key: 'old', is_percentage: true, rate: 1000, amount: 100 }));
656
656
  const freshFixed = sourceFor(row({ entry_key: 'new', is_percentage: false, rate: 200, amount: 200 }));
657
657
  expect(oldPercentage.rate_kind).toBe(MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_RATE_KIND_ENUM.PERCENTAGE);
658
- expect((0, materialized_discount_source_helpers_1.applyDiscountSourceDelta)(oldPercentage, oldPercentage, -1, NOW)).toBeNull();
659
- const replaced = (0, materialized_discount_source_helpers_1.applyDiscountSourceDelta)(null, freshFixed, 1, NOW);
658
+ expect((0, materialized_discount_source_assembly_1.applyDiscountSourceDelta)(oldPercentage, oldPercentage, -1, NOW)).toBeNull();
659
+ const replaced = (0, materialized_discount_source_assembly_1.applyDiscountSourceDelta)(null, freshFixed, 1, NOW);
660
660
  expect(replaced?.rate_kind).toBe(MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_RATE_KIND_ENUM.FIXED);
661
661
  expect(replaced?.discount_amount).toBe(200);
662
662
  expect(replaced?.percentage_row_count).toBe(0);
@@ -675,7 +675,7 @@ describe('incremental source deltas', () => {
675
675
  rows: [row({ order_id: 'order-a', entry_key: 'a', amount: 100 })],
676
676
  },
677
677
  });
678
- const remaining = (0, materialized_discount_source_helpers_1.applyDiscountSourceDelta)(old, removed, -1, NOW);
678
+ const remaining = (0, materialized_discount_source_assembly_1.applyDiscountSourceDelta)(old, removed, -1, NOW);
679
679
  expect(remaining?.discount_amount).toBe(200);
680
680
  expect(remaining?.row_count).toBe(1);
681
681
  expect(remaining?.key_metrics.map((metric) => metric.key)).toEqual(['COMPLETED:APP_DINE-IN']);
@@ -684,14 +684,14 @@ describe('incremental source deltas', () => {
684
684
  rows: [row({ order_id: 'order-c', entry_key: 'c', amount: 50 })],
685
685
  },
686
686
  });
687
- const merged = (0, materialized_discount_source_helpers_1.applyDiscountSourceDelta)(remaining, fresh, 1, NOW);
687
+ const merged = (0, materialized_discount_source_assembly_1.applyDiscountSourceDelta)(remaining, fresh, 1, NOW);
688
688
  expect(merged?.discount_amount).toBe(250);
689
689
  expect(merged?.key_metrics).toHaveLength(2);
690
690
  });
691
691
  it('is idempotent for a new day (add) and removes a source that reaches zero', () => {
692
692
  const fresh = sourceFor(row({ entry_key: 'new', amount: 200, is_percentage: false, rate: 200 }));
693
- const added = (0, materialized_discount_source_helpers_1.applyDiscountSourceDelta)(null, fresh, 1, NOW);
693
+ const added = (0, materialized_discount_source_assembly_1.applyDiscountSourceDelta)(null, fresh, 1, NOW);
694
694
  expect(added.discount_amount).toBe(200);
695
- expect((0, materialized_discount_source_helpers_1.applyDiscountSourceDelta)(added, fresh, -1, NOW)).toBeNull();
695
+ expect((0, materialized_discount_source_assembly_1.applyDiscountSourceDelta)(added, fresh, -1, NOW)).toBeNull();
696
696
  });
697
697
  });
@@ -4,7 +4,7 @@ const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
4
4
  const materialized_integer_contract_1 = require("../../helpers/materialized-reports/materialized-integer-contract");
5
5
  const materialized_report_drilldown_rows_1 = require("../../helpers/materialized-reports/materialized-report-drilldown-rows");
6
6
  const materialized_discount_compile_helpers_1 = require("../../helpers/materialized-reports/materialized-discount-compile-helpers");
7
- const materialized_discount_source_helpers_1 = require("../../helpers/materialized-reports/materialized-discount-source-helpers");
7
+ const materialized_discount_source_assembly_1 = require("../../helpers/materialized-reports/materialized-discount-source-assembly");
8
8
  const fixtures_1 = require("./fixtures");
9
9
  /**
10
10
  * THE integer-only storage contract.
@@ -206,7 +206,7 @@ describe('a FULL discount document set is integer-only', () => {
206
206
  collection: 'materialized_tenant_discount_entries',
207
207
  });
208
208
  // 3. the source projection, built from the compiled entries
209
- const sources = (0, materialized_discount_source_helpers_1.buildDiscountSourcesForScope)({
209
+ const sources = (0, materialized_discount_source_assembly_1.buildDiscountSourcesForScope)({
210
210
  tenantId: TENANT,
211
211
  brandId: BRAND,
212
212
  scopeContext: compiled.entries[0].scope_context,
@@ -9,7 +9,7 @@ const node_path_1 = __importDefault(require("node:path"));
9
9
  const globals_1 = require("@jest/globals");
10
10
  const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
11
11
  const materialized_discount_compile_helpers_1 = require("../../helpers/materialized-reports/materialized-discount-compile-helpers");
12
- const materialized_discount_source_helpers_1 = require("../../helpers/materialized-reports/materialized-discount-source-helpers");
12
+ const materialized_discount_source_assembly_1 = require("../../helpers/materialized-reports/materialized-discount-source-assembly");
13
13
  const materialized_integer_contract_1 = require("../../helpers/materialized-reports/materialized-integer-contract");
14
14
  const ORDERS = JSON.parse(node_fs_1.default.readFileSync(node_path_1.default.join(__dirname, '..', 'real-discount-orders-2026-10-23.json'), 'utf8'));
15
15
  const TENANT = 'thailemon.uae';
@@ -29,7 +29,7 @@ const sourcesForMonth = () => {
29
29
  const entry = compiled.entries.find((e) => e.scope_context === MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH);
30
30
  return {
31
31
  compiled,
32
- sources: (0, materialized_discount_source_helpers_1.buildDiscountSourcesForScope)({
32
+ sources: (0, materialized_discount_source_assembly_1.buildDiscountSourcesForScope)({
33
33
  tenantId: TENANT,
34
34
  brandId: BRAND,
35
35
  scopeContext: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH,
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  const fs_1 = __importDefault(require("fs"));
40
40
  const path_1 = __importDefault(require("path"));
41
41
  const MATERIALIZED_REPORTS_1 = require("../../../constants/MATERIALIZED_REPORTS");
42
+ const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../../constants/MATERIALIZED_SCHEMA_VERSIONS");
42
43
  const overviewModel = __importStar(require("../../../schemas/models/materialized_tenant_sales_overview_reports"));
43
44
  const creditModel = __importStar(require("../../../schemas/models/materialized_credit_bills"));
44
45
  const discountReportModel = __importStar(require("../../../schemas/models/materialized_tenant_discount_reports"));
@@ -81,7 +82,7 @@ const MODEL_BY_COLLECTION = {
81
82
  },
82
83
  materialized_tenant_discount_sources: {
83
84
  collectionName: discountSourceModel.MATERIALIZED_TENANT_DISCOUNT_SOURCES_COLLECTION_NAME,
84
- schemaVersion: discountSourceModel.MATERIALIZED_TENANT_DISCOUNT_SOURCES_SCHEMA_VERSION,
85
+ schemaVersion: MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_DISCOUNT_SOURCES_SCHEMA_VERSION,
85
86
  indexOptions: discountSourceModel.MATERIALIZED_TENANT_DISCOUNT_SOURCES_INDEX_OPTIONS,
86
87
  },
87
88
  materialized_tenant_prep_time_reports: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managesome/eposmatic-toolkit",
3
- "version": "0.4.64",
3
+ "version": "0.4.65",
4
4
  "description": "A Toolkit Library for Eposmatic",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",