@managesome/eposmatic-toolkit 0.4.62 → 0.4.64

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 (120) hide show
  1. package/esm/constants/MATERIALIZED_SCHEMA_VERSIONS.js +17 -0
  2. package/esm/constants/WORKER_ENDPOINTS.js +2 -2
  3. package/esm/helpers/materialized-reports/index.js +3 -0
  4. package/esm/helpers/materialized-reports/materialized-credit-bills-helpers.js +3 -3
  5. package/esm/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +5 -5
  6. package/esm/helpers/materialized-reports/materialized-delivery-compile-helpers.js +2 -2
  7. package/esm/helpers/materialized-reports/materialized-dialer-close-day-helpers.js +5 -5
  8. package/esm/helpers/materialized-reports/materialized-dialer-compile-helpers.js +2 -2
  9. package/esm/helpers/materialized-reports/materialized-dinein-close-day-helpers.js +5 -5
  10. package/esm/helpers/materialized-reports/materialized-dinein-compile-helpers.js +2 -2
  11. package/esm/helpers/materialized-reports/materialized-discount-compile-helpers.js +3 -3
  12. package/esm/helpers/materialized-reports/materialized-document-size.js +2 -2
  13. package/esm/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +3 -3
  14. package/esm/helpers/materialized-reports/materialized-prep-time-compile-helpers.js +3 -3
  15. package/esm/helpers/materialized-reports/report-compile.js +38 -0
  16. package/esm/helpers/materialized-reports/tenant-sales-overview-bson.js +27 -0
  17. package/esm/helpers/materialized-reports/tenant-sales-overview-helpers.js +3 -22
  18. package/esm/helpers/store/common-tenant-purchase-order-actions.js +12 -0
  19. package/esm/helpers/store/common-warehouse-purchase-order-actions.js +20 -0
  20. package/esm/helpers/store/tenant-purchase-orders-cart-actions.js +24 -7
  21. package/esm/helpers/store/warehouse-purchase-orders-cart-actions.js +23 -10
  22. package/esm/helpers/utils/index.js +1 -0
  23. package/esm/helpers/utils/tenant-purchase-order-engine.js +47 -0
  24. package/esm/helpers/utils/warehouse-purchase-order-engine.js +63 -4
  25. package/esm/schemas/models/materialized_credit_bills.js +2 -1
  26. package/esm/schemas/models/materialized_tenant_delivery_entries.js +2 -1
  27. package/esm/schemas/models/materialized_tenant_delivery_reports.js +2 -1
  28. package/esm/schemas/models/materialized_tenant_dialer_entries.js +2 -1
  29. package/esm/schemas/models/materialized_tenant_dialer_reports.js +2 -1
  30. package/esm/schemas/models/materialized_tenant_dinein_entries.js +2 -1
  31. package/esm/schemas/models/materialized_tenant_dinein_reports.js +2 -1
  32. package/esm/schemas/models/materialized_tenant_sales_overview_reports.js +2 -1
  33. package/esm/schemas/models/tenant_purchase_orders.js +4 -0
  34. package/esm/schemas/models/warehouse_purchase_orders.js +4 -0
  35. package/lib/constants/MATERIALIZED_SCHEMA_VERSIONS.d.ts +17 -0
  36. package/lib/constants/MATERIALIZED_SCHEMA_VERSIONS.js +20 -0
  37. package/lib/constants/WORKER_ENDPOINTS.d.ts +0 -2
  38. package/lib/constants/WORKER_ENDPOINTS.js +2 -2
  39. package/lib/helpers/materialized-reports/index.d.ts +2 -0
  40. package/lib/helpers/materialized-reports/index.js +26 -0
  41. package/lib/helpers/materialized-reports/materialized-credit-bills-helpers.js +4 -4
  42. package/lib/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +6 -6
  43. package/lib/helpers/materialized-reports/materialized-delivery-compile-helpers.js +4 -4
  44. package/lib/helpers/materialized-reports/materialized-dialer-close-day-helpers.js +6 -6
  45. package/lib/helpers/materialized-reports/materialized-dialer-compile-helpers.js +6 -6
  46. package/lib/helpers/materialized-reports/materialized-dinein-close-day-helpers.js +6 -6
  47. package/lib/helpers/materialized-reports/materialized-dinein-compile-helpers.js +6 -6
  48. package/lib/helpers/materialized-reports/materialized-discount-compile-helpers.js +3 -3
  49. package/lib/helpers/materialized-reports/materialized-document-size.js +2 -5
  50. package/lib/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +3 -3
  51. package/lib/helpers/materialized-reports/materialized-prep-time-compile-helpers.js +3 -3
  52. package/lib/helpers/materialized-reports/report-compile.d.ts +38 -0
  53. package/lib/helpers/materialized-reports/report-compile.js +87 -0
  54. package/lib/helpers/materialized-reports/tenant-sales-overview-bson.d.ts +12 -0
  55. package/lib/helpers/materialized-reports/tenant-sales-overview-bson.js +33 -0
  56. package/lib/helpers/materialized-reports/tenant-sales-overview-helpers.d.ts +1 -12
  57. package/lib/helpers/materialized-reports/tenant-sales-overview-helpers.js +4 -24
  58. package/lib/helpers/store/common-tenant-purchase-order-actions.d.ts +6 -1
  59. package/lib/helpers/store/common-tenant-purchase-order-actions.js +13 -0
  60. package/lib/helpers/store/common-warehouse-purchase-order-actions.js +20 -0
  61. package/lib/helpers/store/tenant-purchase-orders-cart-actions.js +23 -6
  62. package/lib/helpers/store/warehouse-purchase-orders-cart-actions.js +23 -10
  63. package/lib/helpers/utils/index.d.ts +1 -0
  64. package/lib/helpers/utils/index.js +1 -0
  65. package/lib/helpers/utils/tenant-purchase-order-engine.d.ts +24 -0
  66. package/lib/helpers/utils/tenant-purchase-order-engine.js +51 -0
  67. package/lib/helpers/utils/warehouse-purchase-order-engine.d.ts +23 -1
  68. package/lib/helpers/utils/warehouse-purchase-order-engine.js +65 -4
  69. package/lib/schemas/models/materialized_credit_bills.d.ts +29 -46
  70. package/lib/schemas/models/materialized_credit_bills.js +3 -2
  71. package/lib/schemas/models/materialized_tenant_cash_entries.d.ts +9 -9
  72. package/lib/schemas/models/materialized_tenant_cash_reports.d.ts +9 -9
  73. package/lib/schemas/models/materialized_tenant_delivery_entries.d.ts +11 -10
  74. package/lib/schemas/models/materialized_tenant_delivery_entries.js +3 -2
  75. package/lib/schemas/models/materialized_tenant_delivery_geo_cells.d.ts +9 -9
  76. package/lib/schemas/models/materialized_tenant_delivery_geo_scopes.d.ts +6 -6
  77. package/lib/schemas/models/materialized_tenant_delivery_reports.d.ts +11 -10
  78. package/lib/schemas/models/materialized_tenant_delivery_reports.js +3 -2
  79. package/lib/schemas/models/materialized_tenant_dialer_entries.d.ts +8 -7
  80. package/lib/schemas/models/materialized_tenant_dialer_entries.js +3 -2
  81. package/lib/schemas/models/materialized_tenant_dialer_reports.d.ts +11 -10
  82. package/lib/schemas/models/materialized_tenant_dialer_reports.js +3 -2
  83. package/lib/schemas/models/materialized_tenant_dinein_entries.d.ts +8 -7
  84. package/lib/schemas/models/materialized_tenant_dinein_entries.js +3 -2
  85. package/lib/schemas/models/materialized_tenant_dinein_reports.d.ts +11 -10
  86. package/lib/schemas/models/materialized_tenant_dinein_reports.js +3 -2
  87. package/lib/schemas/models/materialized_tenant_discount_entries.d.ts +9 -9
  88. package/lib/schemas/models/materialized_tenant_discount_reports.d.ts +9 -9
  89. package/lib/schemas/models/materialized_tenant_discount_sources.d.ts +9 -9
  90. package/lib/schemas/models/materialized_tenant_hourly_comparison_entries.d.ts +9 -9
  91. package/lib/schemas/models/materialized_tenant_hourly_comparison_reports.d.ts +9 -9
  92. package/lib/schemas/models/materialized_tenant_payments_comparison_entries.d.ts +9 -9
  93. package/lib/schemas/models/materialized_tenant_payments_comparison_reports.d.ts +9 -9
  94. package/lib/schemas/models/materialized_tenant_prep_time_entries.d.ts +9 -9
  95. package/lib/schemas/models/materialized_tenant_prep_time_reports.d.ts +9 -9
  96. package/lib/schemas/models/materialized_tenant_sales_comparison_entries.d.ts +9 -9
  97. package/lib/schemas/models/materialized_tenant_sales_comparison_reports.d.ts +9 -9
  98. package/lib/schemas/models/materialized_tenant_sales_overview_reports.d.ts +11 -35
  99. package/lib/schemas/models/materialized_tenant_sales_overview_reports.js +3 -2
  100. package/lib/schemas/models/tenant_purchase_orders.d.ts +972 -0
  101. package/lib/schemas/models/tenant_purchase_orders.js +4 -0
  102. package/lib/schemas/models/warehouse_purchase_orders.d.ts +972 -0
  103. package/lib/schemas/models/warehouse_purchase_orders.js +4 -0
  104. package/lib/schemas/types/tenant_purchase_orders.d.ts +2 -1
  105. package/lib/schemas/types/warehouse_purchase_orders.d.ts +2 -1
  106. package/lib/tests/materialized-reports/tenant-sales-overview-close-day-helpers.test.js +2 -1
  107. package/lib/tests/materialized-reports/tenant-sales-overview-helpers.test.js +5 -4
  108. package/lib/tests/reporting-contract/no-live-transport.test.js +106 -0
  109. package/package.json +2 -1
  110. package/lib/helpers/order/payment-collection.d.ts +0 -25
  111. package/lib/helpers/order/payment-collection.js +0 -51
  112. package/lib/schemas/models/applied_order_discounts.d.ts +0 -80
  113. package/lib/schemas/models/applied_order_discounts.js +0 -106
  114. package/lib/schemas/types/applied_order_discounts.d.ts +0 -22
  115. package/lib/schemas/types/applied_order_discounts.js +0 -2
  116. package/lib/tests/materialized-reports/analytics-overview-helpers.test.d.ts +0 -1
  117. package/lib/tests/materialized-reports/analytics-performance-helpers.test.d.ts +0 -1
  118. package/lib/tests/payment-collection-timestamps.test.d.ts +0 -1
  119. package/lib/tests/payment-collection-timestamps.test.js +0 -71
  120. /package/lib/tests/{materialized-reports/analytics-growth-helpers.test.d.ts → reporting-contract/no-live-transport.test.d.ts} +0 -0
@@ -2,6 +2,7 @@ import ObjectID from 'bson-objectid';
2
2
  import isEqual from 'lodash/isEqual';
3
3
  import { WAREHOUSE_PURCHASE_ORDER_STATUS_ENUM } from '../../constants';
4
4
  import { getCardChargesAndAmountCollected, getPercentageAmount, parseFloatCeil, parseNum } from '../utils';
5
+ import { getWarehousePurchaseOrderItemDiscountAmount, withResolvedWarehouseItemDiscountTotal, } from '../utils/warehouse-purchase-order-engine';
5
6
  export function getWarehousePurchaseOrderOrderDiscountDetails(discountDetails, baseAmount) {
6
7
  if (!discountDetails) {
7
8
  return { order_discount_details: null, total_discount_applied: 0 };
@@ -34,7 +35,12 @@ export function getWarehousePurchaseOrderOrderDiscountDetails(discountDetails, b
34
35
  export function calculateCartWarehousePurchaseOrderInfoAndSyncData(data, calculateItemMetadata) {
35
36
  const isCompleted = data.order_status === WAREHOUSE_PURCHASE_ORDER_STATUS_ENUM.COMPLETED;
36
37
  /* ===============================><=============================== */
38
+ // `grossSubtotal` is the list value (price × quantity) of every line;
39
+ // `subtotal` is what the order actually costs after item-level discounts.
40
+ // Order-level discounts are then applied on top of `subtotal`.
41
+ let grossSubtotal = 0;
37
42
  let subtotal = 0;
43
+ let totalItemDiscount = 0;
38
44
  const categories = [];
39
45
  const length = data.categories?.length ?? 0;
40
46
  for (let c = 0; c < length; c++) {
@@ -43,13 +49,16 @@ export function calculateCartWarehousePurchaseOrderInfoAndSyncData(data, calcula
43
49
  const itemsLength = category.items.length;
44
50
  for (let i = 0; i < itemsLength; i++) {
45
51
  const item = category.items[i];
46
- // For purchase orders, subtotal is already set as price * quantity
47
- // But to ensure, we can recalculate
48
- const itemSubtotal = parseNum(item.price * item.quantity);
52
+ // Recalculate from price × quantity so edits to price/quantity are always
53
+ // reflected, then take the item-level discount off the line.
54
+ const itemGrossSubtotal = parseNum(item.price * item.quantity);
55
+ const itemDiscountAmount = getWarehousePurchaseOrderItemDiscountAmount(item);
56
+ const itemSubtotal = parseNum(Math.max(0, itemGrossSubtotal - itemDiscountAmount));
49
57
  const newItem = {
50
58
  ...item,
51
59
  is_ready: item.is_ready || isCompleted,
52
60
  subtotal: itemSubtotal,
61
+ item_discount_details: withResolvedWarehouseItemDiscountTotal(item),
53
62
  // These values will be auto calculated
54
63
  _discount_amount: 0,
55
64
  _gross_amount: 0,
@@ -58,7 +67,9 @@ export function calculateCartWarehousePurchaseOrderInfoAndSyncData(data, calcula
58
67
  };
59
68
  delete newItem.void_reason;
60
69
  newItems.push(newItem);
70
+ grossSubtotal += itemGrossSubtotal;
61
71
  subtotal += itemSubtotal;
72
+ totalItemDiscount += itemDiscountAmount;
62
73
  }
63
74
  categories.push({
64
75
  ...category,
@@ -98,22 +109,24 @@ export function calculateCartWarehousePurchaseOrderInfoAndSyncData(data, calcula
98
109
  const amount_earned = parseNum(grand_total - cardCharges);
99
110
  if (calculateItemMetadata) {
100
111
  const discountedSubtotal = parseNum(Math.max(0, subtotal - total_discount_applied));
101
- let leftGrossAmount = subtotal;
112
+ let leftGrossAmount = grossSubtotal;
102
113
  let leftNetAmount = discountedSubtotal;
103
- let leftDiscountAmount = total_discount_applied;
114
+ let leftDiscountAmount = parseNum(totalItemDiscount + total_discount_applied);
104
115
  let leftGstAmount = gst_amount;
105
116
  categories.forEach((category, categoryIndex) => {
106
117
  const isLastCategory = categoryIndex === categories.length - 1;
107
118
  category.items.forEach((item, itemIndex) => {
108
119
  const isLastItem = isLastCategory && itemIndex === category.items.length - 1;
109
- // Order-level discounts are distributed proportionally across items,
110
- // mirroring how `IOrder` calculates item metadata.
120
+ // `item.subtotal` is already net of the item-level discount, so the
121
+ // order-level discount is distributed over the discounted subtotal.
111
122
  const itemOrderDiscountAmount = subtotal > 0 ? (item.subtotal / subtotal) * total_discount_applied : 0;
112
- let grossAmount = item.subtotal;
123
+ // Whatever the line lost to its own item-level discount.
124
+ const itemLevelDiscountAmount = parseNum(Math.max(0, item.price * item.quantity - item.subtotal));
125
+ let grossAmount = item.price * item.quantity;
113
126
  let netAmount = item.subtotal - itemOrderDiscountAmount;
114
- let itemTotalDiscountAmount = itemOrderDiscountAmount;
127
+ let itemTotalDiscountAmount = itemLevelDiscountAmount + itemOrderDiscountAmount;
115
128
  let itemGst = 0;
116
- if (gst_amount > 0) {
129
+ if (gst_amount > 0 && subtotal > 0) {
117
130
  itemGst = (item.subtotal / subtotal) * gst_amount;
118
131
  }
119
132
  grossAmount = parseFloatCeil(grossAmount);
@@ -77,6 +77,7 @@ export * from './tenant-cash-drawers-helpers';
77
77
  export * from './tenant-cash-in-out-helpers';
78
78
  export * from './tenant-day-sessions-helpers';
79
79
  export * from './tenant-instore-shift-sessions-helpers';
80
+ export * from './tenant-purchase-order-engine';
80
81
  export * from './tenant-staff-helpers';
81
82
  export * from './tenant_cash_in_hand_transactions';
82
83
  export * from './time-helpers';
@@ -0,0 +1,47 @@
1
+ import { getPercentageAmount, parseNum } from './common';
2
+ // ==========================================================><====================================================
3
+ /**
4
+ * Total item-level discount for a tenant purchase order line, in money.
5
+ *
6
+ * The discount is applied per cart line through the cart's "Item Discount"
7
+ * action and lives in `item_discount_details` — the same record an order item
8
+ * uses:
9
+ * - `special_discount` is a **per-unit** amount when fixed, so the discount
10
+ * scales with quantity, and a percentage of the line's gross when
11
+ * `is_special_discount_percentage` is set.
12
+ * - `total_discount` is a fallback for records written without a
13
+ * `special_discount`.
14
+ *
15
+ * The result is clamped to the line's gross value so a discount can never make
16
+ * a line negative.
17
+ */
18
+ export function getTenantPurchaseOrderItemDiscountAmount(orderItem) {
19
+ const details = orderItem.item_discount_details;
20
+ if (!details)
21
+ return 0;
22
+ const quantity = orderItem.quantity ?? 0;
23
+ const grossAmount = parseNum((orderItem.price ?? 0) * quantity);
24
+ const value = details.special_discount;
25
+ if (typeof value !== 'number' || !(value > 0)) {
26
+ return parseNum(Math.max(0, Math.min(grossAmount, details.total_discount ?? 0)));
27
+ }
28
+ const discountAmount = details.is_special_discount_percentage
29
+ ? getPercentageAmount(grossAmount, value)
30
+ : value * quantity;
31
+ return parseNum(Math.min(grossAmount, Math.max(0, discountAmount)));
32
+ }
33
+ /**
34
+ * Refreshes `total_discount` on a line's discount record so the amount it
35
+ * reports matches the line's current price/quantity. Preserves every other
36
+ * field (id, name, reason, reference) and returns null when there is no
37
+ * discount.
38
+ */
39
+ export function withResolvedTenantItemDiscountTotal(orderItem) {
40
+ const details = orderItem.item_discount_details;
41
+ if (!details)
42
+ return null;
43
+ return {
44
+ ...details,
45
+ total_discount: getTenantPurchaseOrderItemDiscountAmount(orderItem),
46
+ };
47
+ }
@@ -1,15 +1,75 @@
1
1
  import ObjectID from 'bson-objectid';
2
+ import { getPercentageAmount, parseNum } from './common';
3
+ // ==========================================================><====================================================
4
+ /**
5
+ * Total item-level discount for a purchase order line, in money.
6
+ *
7
+ * The line's discount lives in `item_discount_details` (the same record an order
8
+ * item uses):
9
+ * - `special_discount` is a **per-unit** amount when fixed, so the discount
10
+ * scales with quantity, and a percentage of the line's gross when
11
+ * `is_special_discount_percentage` is set.
12
+ * - `total_discount` is used as a fallback for records written without a
13
+ * `special_discount` (e.g. a discount carried over from elsewhere).
14
+ *
15
+ * The result is clamped to the line's gross value so a discount can never make a
16
+ * line negative.
17
+ */
18
+ export function getWarehousePurchaseOrderItemDiscountAmount(orderItem) {
19
+ const details = orderItem.item_discount_details;
20
+ if (!details)
21
+ return 0;
22
+ const quantity = orderItem.quantity ?? 0;
23
+ const grossAmount = parseNum((orderItem.price ?? 0) * quantity);
24
+ const value = details.special_discount;
25
+ if (typeof value !== 'number' || !(value > 0)) {
26
+ return parseNum(Math.max(0, Math.min(grossAmount, details.total_discount ?? 0)));
27
+ }
28
+ const discountAmount = details.is_special_discount_percentage
29
+ ? getPercentageAmount(grossAmount, value)
30
+ : value * quantity;
31
+ return parseNum(Math.min(grossAmount, Math.max(0, discountAmount)));
32
+ }
33
+ /**
34
+ * Refreshes `total_discount` on a line's discount record so the amount it
35
+ * reports matches the line's current price/quantity. Preserves every other
36
+ * field (id, name, reason, reference) and returns null when there is no
37
+ * discount.
38
+ */
39
+ export function withResolvedWarehouseItemDiscountTotal(orderItem) {
40
+ const details = orderItem.item_discount_details;
41
+ if (!details)
42
+ return null;
43
+ return {
44
+ ...details,
45
+ total_discount: getWarehousePurchaseOrderItemDiscountAmount(orderItem),
46
+ };
47
+ }
2
48
  export function convertWarehouseItemToPurchaseOrderItem({ vendorId, item, orderItem, }) {
3
49
  const { _id = ObjectID().toHexString(), price = item.purchase_price?.[vendorId] ?? item.purchase_price?.BASE_PRICE ?? 0, quantity = 1, special_instructions = '', is_ready, } = orderItem ?? {};
50
+ // Item discounts are applied per cart line; an existing order item (split /
51
+ // re-add) keeps the discount it was given.
52
+ const item_discount_details = orderItem?.item_discount_details ?? null;
53
+ const discount_amount = getWarehousePurchaseOrderItemDiscountAmount({
54
+ price,
55
+ quantity,
56
+ item_discount_details,
57
+ });
4
58
  const purchaseOrderItem = {
5
59
  _id,
6
60
  item_id: item._id,
7
61
  name: item.name,
8
62
  price,
9
- subtotal: price * quantity,
63
+ subtotal: parseNum(price * quantity - discount_amount),
10
64
  quantity,
11
65
  special_instructions,
12
66
  is_ready,
67
+ item_discount_details: item_discount_details == null
68
+ ? null
69
+ : {
70
+ ...item_discount_details,
71
+ total_discount: discount_amount,
72
+ },
13
73
  // These values will be auto calculated
14
74
  _discount_amount: 0,
15
75
  _gross_amount: 0,
@@ -20,8 +80,7 @@ export function convertWarehouseItemToPurchaseOrderItem({ vendorId, item, orderI
20
80
  }
21
81
  // ==========================================================><====================================================
22
82
  export function getCurrentWarehousePurchaseOrderItemTotalPrice(orderItem) {
23
- // For purchase orders, total is simply price * quantity
24
- // No modifiers, discounts, etc.
25
- const total = orderItem.price * orderItem.quantity;
83
+ // The line's payable value: price × quantity minus any item-level discount.
84
+ const total = parseNum(orderItem.price * orderItem.quantity - getWarehousePurchaseOrderItemDiscountAmount(orderItem));
26
85
  return total;
27
86
  }
@@ -1,3 +1,5 @@
1
+ import { MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
2
+ export { MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION };
1
3
  import { Schema } from 'mongoose';
2
4
  import { ALL_DAY_INDEX } from '../../constants/ENUMS';
3
5
  import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, MATERIALIZED_CREDIT_BILLS_SCOPES, SALES_OVERVIEW_KEY_FILTERS, } from '../../constants/MATERIALIZED_REPORTS';
@@ -19,7 +21,6 @@ import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, MATERIALIZED_CREDIT_BILLS_SCOPES,
19
21
  * documents must then be re-materialized. PRE-RELEASE: the collection has no
20
22
  * live tenants/consumers yet, so every change so far folds into version `1`.
21
23
  */
22
- export const MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION = 1;
23
24
  const CreditBillIssuedEntrySchema = new Schema({
24
25
  order_id: {
25
26
  type: String,
@@ -1,3 +1,5 @@
1
+ import { MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
2
+ export { MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION };
1
3
  import { Schema } from 'mongoose';
2
4
  import { ALL_DAY_INDEX } from '../../constants/ENUMS';
3
5
  import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, DELIVERY_KEY_FILTERS, MATERIALIZED_DELIVERY_ENTRY_SCOPES, } from '../../constants/MATERIALIZED_REPORTS';
@@ -19,7 +21,6 @@ import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, DELIVERY_KEY_FILTERS, MATERIALIZED
19
21
  * pre-launch contract. Schema versioning will be reintroduced only when a
20
22
  * future stored-shape change requires an explicit migration.
21
23
  */
22
- export const MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION = 1;
23
24
  export const MaterializedTenantDeliveryEntriesSchema = new Schema({
24
25
  tenant_id: { type: String, required: true },
25
26
  brand_id: { type: String, required: true },
@@ -1,3 +1,5 @@
1
+ import { MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
2
+ export { MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION };
1
3
  import { Schema } from 'mongoose';
2
4
  import { ALL_DAY_INDEX } from '../../constants/ENUMS';
3
5
  import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, DELIVERY_KEY_FILTERS, MATERIALIZED_DELIVERY_REPORT_SCOPES, } from '../../constants/MATERIALIZED_REPORTS';
@@ -17,7 +19,6 @@ import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, DELIVERY_KEY_FILTERS, MATERIALIZED
17
19
  * rows as the refund source. Schema versioning is reset to 1 across all
18
20
  * materialized collections for this pre-launch contract.
19
21
  */
20
- export const MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION = 1;
21
22
  export const MaterializedTenantDeliveryReportSchema = new Schema({
22
23
  tenant_id: { type: String, required: true },
23
24
  brand_id: { type: String, required: true },
@@ -1,3 +1,5 @@
1
+ import { MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
2
+ export { MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION };
1
3
  import { Schema } from 'mongoose';
2
4
  import { ALL_DAY_INDEX } from '../../constants/ENUMS';
3
5
  import { MATERIALIZED_DIALER_ENTRY_SCOPES } from '../../constants/MATERIALIZED_REPORTS';
@@ -13,7 +15,6 @@ import { MATERIALIZED_DIALER_ENTRY_SCOPES } from '../../constants/MATERIALIZED_R
13
15
  * sections whose keys are the report's `<ACTION>:<POS_ID>:<STAFF_ID>` grammar.
14
16
  */
15
17
  /** Document shape version. Bump with a migration for already-stored pages. */
16
- export const MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION = 1;
17
18
  export const MaterializedTenantDialerEntriesSchema = new Schema({
18
19
  tenant_id: { type: String, required: true },
19
20
  brand_id: { type: String, required: true },
@@ -1,3 +1,5 @@
1
+ import { MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
2
+ export { MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION };
1
3
  import { Schema } from 'mongoose';
2
4
  import { ALL_DAY_INDEX } from '../../constants/ENUMS';
3
5
  import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, DIALER_KEY_FILTERS, MATERIALIZED_DIALER_REPORT_SCOPES, } from '../../constants/MATERIALIZED_REPORTS';
@@ -12,7 +14,6 @@ import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, DIALER_KEY_FILTERS, MATERIALIZED_D
12
14
  * `materialized_tenant_dialer_entries` collection (one page per source day).
13
15
  */
14
16
  /** Document shape version. Bump on a key-grammar/metric change + backfill. */
15
- export const MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION = 1;
16
17
  export const MaterializedTenantDialerReportSchema = new Schema({
17
18
  tenant_id: { type: String, required: true },
18
19
  brand_id: { type: String, required: true },
@@ -1,3 +1,5 @@
1
+ import { MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
2
+ export { MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION };
1
3
  import { Schema } from 'mongoose';
2
4
  import { ALL_DAY_INDEX } from '../../constants/ENUMS';
3
5
  import { MATERIALIZED_DINEIN_ENTRY_SCOPES } from '../../constants/MATERIALIZED_REPORTS';
@@ -13,7 +15,6 @@ import { MATERIALIZED_DINEIN_ENTRY_SCOPES } from '../../constants/MATERIALIZED_R
13
15
  * `day_index: null`.
14
16
  */
15
17
  /** Document shape version. Bump on a row-shape change + backfill. */
16
- export const MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION = 1;
17
18
  export const MaterializedTenantDineinEntriesSchema = new Schema({
18
19
  tenant_id: { type: String, required: true },
19
20
  brand_id: { type: String, required: true },
@@ -1,3 +1,5 @@
1
+ import { MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
2
+ export { MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION };
1
3
  import { Schema } from 'mongoose';
2
4
  import { ALL_DAY_INDEX } from '../../constants/ENUMS';
3
5
  import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, DINEIN_KEY_FILTERS, MATERIALIZED_DINEIN_REPORT_SCOPES, } from '../../constants/MATERIALIZED_REPORTS';
@@ -14,7 +16,6 @@ import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, DINEIN_KEY_FILTERS, MATERIALIZED_D
14
16
  * `materialized_tenant_dinein_entries` collection (one page per source day).
15
17
  */
16
18
  /** Document shape version. Bump on a key-grammar/metric change + backfill. */
17
- export const MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION = 1;
18
19
  export const MaterializedTenantDineinReportSchema = new Schema({
19
20
  tenant_id: { type: String, required: true },
20
21
  brand_id: { type: String, required: true },
@@ -1,3 +1,5 @@
1
+ import { MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
2
+ export { MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_SCHEMA_VERSION };
1
3
  import { Schema } from 'mongoose';
2
4
  import { REPORT_SALE_TYPE_ENUM } from '../../constants';
3
5
  import { ALL_DAY_INDEX } from '../../constants/ENUMS';
@@ -27,7 +29,6 @@ import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, ALL_MATERIALIZED_REPORT_SCOPES, SA
27
29
  * this value during a rollout). PRE-RELEASE: the collection has no live
28
30
  * tenants/consumers yet, so every change so far folds into version `1`.
29
31
  */
30
- export const MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_SCHEMA_VERSION = 1;
31
32
  const ReportDiscountByTypeSchema = new Schema({
32
33
  special_discount: {
33
34
  type: Number, // cents — Σ order_discount_details.special_discount
@@ -53,6 +53,10 @@ const ItemsSchema = new Schema({
53
53
  _net_amount: { type: Number, min: 0, required: true },
54
54
  _gross_amount: { type: Number, min: 0, required: true },
55
55
  _discount_amount: { type: Number, min: 0, required: true },
56
+ item_discount_details: {
57
+ type: DiscountDetailsSchema,
58
+ required: false,
59
+ },
56
60
  special_instructions: { type: String, default: '' },
57
61
  });
58
62
  const CategoriesSchema = new Schema({
@@ -107,6 +107,10 @@ const ItemsModal = new Schema({
107
107
  min: 0,
108
108
  required: true,
109
109
  },
110
+ item_discount_details: {
111
+ type: DiscountDetailsSchema,
112
+ default: null,
113
+ },
110
114
  special_instructions: {
111
115
  type: String,
112
116
  default: '',
@@ -0,0 +1,17 @@
1
+ /**
2
+ * PURE materialized-report schema versions.
3
+ *
4
+ * The close-day plans stamp these versions on the documents they build, so the
5
+ * COMPILE graph must be able to read them without importing a mongoose schema
6
+ * model (the schema files re-export these constants for their existing API).
7
+ *
8
+ * Keep this module dependency-free: it is imported by the worker compile path.
9
+ */
10
+ export declare const MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION = 1;
11
+ export declare const MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION = 1;
12
+ export declare const MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION = 1;
13
+ export declare const MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION = 1;
14
+ export declare const MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION = 1;
15
+ export declare const MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION = 1;
16
+ export declare const MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION = 1;
17
+ export declare const MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_SCHEMA_VERSION = 1;
@@ -0,0 +1,20 @@
1
+ "use strict";
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;
4
+ /**
5
+ * PURE materialized-report schema versions.
6
+ *
7
+ * The close-day plans stamp these versions on the documents they build, so the
8
+ * COMPILE graph must be able to read them without importing a mongoose schema
9
+ * model (the schema files re-export these constants for their existing API).
10
+ *
11
+ * Keep this module dependency-free: it is imported by the worker compile path.
12
+ */
13
+ exports.MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION = 1;
14
+ exports.MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION = 1;
15
+ exports.MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION = 1;
16
+ exports.MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION = 1;
17
+ exports.MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION = 1;
18
+ exports.MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION = 1;
19
+ exports.MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION = 1;
20
+ exports.MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_SCHEMA_VERSION = 1;
@@ -28,8 +28,6 @@ export declare const WORKER_ENDPOINTS: {
28
28
  readonly INCREMENT_CASH_IN_HAND: "/increment-cash-in-hand";
29
29
  readonly REMOVE_DINEIN_TABLE: "/remove-dinein-table";
30
30
  readonly UPDATE_MODIFIER_NAME_IN_ITEMS: "/update-modifier-name-in-items";
31
- readonly ITEMS_USING_MODIFIER: "/items-using-modifier";
32
- readonly AUDIT_ITEM_MODIFIERS: "/audit-item-modifiers";
33
31
  readonly PROCESS_SWITCHPAY_PAYMENT_FOR_ORDER: "/process-switchpay-payment-for-order";
34
32
  readonly COMMIT_SWITCHPAY_PAYMENT_FOR_ORDER: "/commit-switchpay-payment-for-order";
35
33
  readonly SYNC_SWITCHPAY_PAYMENT_SUCCESS: "/sync-switchpay-payment-success";
@@ -34,8 +34,8 @@ exports.WORKER_ENDPOINTS = {
34
34
  REMOVE_DINEIN_TABLE: '/remove-dinein-table',
35
35
  // ========================>> Modifiers / Catalog <<======================= //
36
36
  UPDATE_MODIFIER_NAME_IN_ITEMS: '/update-modifier-name-in-items',
37
- ITEMS_USING_MODIFIER: '/items-using-modifier',
38
- AUDIT_ITEM_MODIFIERS: '/audit-item-modifiers',
37
+ // The two catalog reads that used to live here (items-using-modifier and
38
+ // audit-item-modifiers) are OWNED by items-service now and run locally.
39
39
  // ========================>> Payment (SwitchPay) <<======================= //
40
40
  PROCESS_SWITCHPAY_PAYMENT_FOR_ORDER: '/process-switchpay-payment-for-order',
41
41
  COMMIT_SWITCHPAY_PAYMENT_FOR_ORDER: '/commit-switchpay-payment-for-order',
@@ -69,4 +69,6 @@ export * from './tenant-dinein-formatter';
69
69
  export * from './tenant-prep-time-formatter';
70
70
  export * from './tenant-sales-overview-formatter';
71
71
  export * from './tenant-sales-overview-helpers';
72
+ export * from './tenant-sales-overview-bson';
72
73
  export * from './report-platform';
74
+ export * as reportCompile from './report-compile';
@@ -10,10 +10,33 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
13
18
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
19
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
20
  };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
16
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.reportCompile = void 0;
17
40
  __exportStar(require("./key-helpers"), exports);
18
41
  __exportStar(require("./materialized-credit-bills-helpers"), exports);
19
42
  __exportStar(require("./materialized-day-readiness"), exports);
@@ -85,4 +108,7 @@ __exportStar(require("./tenant-dinein-formatter"), exports);
85
108
  __exportStar(require("./tenant-prep-time-formatter"), exports);
86
109
  __exportStar(require("./tenant-sales-overview-formatter"), exports);
87
110
  __exportStar(require("./tenant-sales-overview-helpers"), exports);
111
+ __exportStar(require("./tenant-sales-overview-bson"), exports);
88
112
  __exportStar(require("./report-platform"), exports);
113
+ // Worker-only PURE compile surface (also importable via the deep lib path).
114
+ exports.reportCompile = __importStar(require("./report-compile"));
@@ -16,10 +16,10 @@ exports.getMaterializedCreditBillScopeRefsForIssue = getMaterializedCreditBillSc
16
16
  exports.computeMaterializedCreditBillTotalsFromReports = computeMaterializedCreditBillTotalsFromReports;
17
17
  exports.computeMaterializedCreditBillTotalsFromReportsByKey = computeMaterializedCreditBillTotalsFromReportsByKey;
18
18
  exports.buildMaterializedCreditBillSelectionFromScopeGroups = buildMaterializedCreditBillSelectionFromScopeGroups;
19
- const mongoose_1 = __importDefault(require("mongoose"));
19
+ const bson_objectid_1 = __importDefault(require("bson-objectid"));
20
20
  const constants_1 = require("../../constants");
21
21
  const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
22
- const materialized_credit_bills_1 = require("../../schemas/models/materialized_credit_bills");
22
+ const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
23
23
  const time_helpers_1 = require("../utils/time-helpers");
24
24
  const key_helpers_1 = require("./key-helpers");
25
25
  const materialized_day_input_signature_1 = require("./materialized-day-input-signature");
@@ -543,7 +543,7 @@ function buildMaterializedCreditBillDayReports(input) {
543
543
  return [];
544
544
  const sourceWatermark = watermark ?? computedAt;
545
545
  const makeDoc = (scopeContext, scopeField, sections) => ({
546
- _id: new mongoose_1.default.Types.ObjectId().toHexString(),
546
+ _id: new bson_objectid_1.default().toHexString(),
547
547
  tenant_id: tenantId,
548
548
  brand_id: brandId,
549
549
  scope_context: scopeContext,
@@ -555,7 +555,7 @@ function buildMaterializedCreditBillDayReports(input) {
555
555
  sale_type_key_filters: [...MATERIALIZED_REPORTS_1.SALES_OVERVIEW_KEY_FILTERS],
556
556
  credit_bills: sections,
557
557
  iteration: 1,
558
- schema_version: materialized_credit_bills_1.MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION,
558
+ schema_version: MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION,
559
559
  source_watermark: sourceWatermark,
560
560
  source_input_signature: sourceInputSignature,
561
561
  computed_at: computedAt,
@@ -9,9 +9,9 @@ exports.needsMaterializedDeliveryReportWrite = needsMaterializedDeliveryReportWr
9
9
  exports.needsMaterializedDeliveryEntriesWrite = needsMaterializedDeliveryEntriesWrite;
10
10
  exports.foldMaterializedDeliveryPeriodCounters = foldMaterializedDeliveryPeriodCounters;
11
11
  exports.buildTenantDeliveryCloseDayPlan = buildTenantDeliveryCloseDayPlan;
12
- const mongoose_1 = __importDefault(require("mongoose"));
12
+ const bson_objectid_1 = __importDefault(require("bson-objectid"));
13
13
  const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
14
- const materialized_tenant_delivery_reports_1 = require("../../schemas/models/materialized_tenant_delivery_reports");
14
+ const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
15
15
  const materialized_delivery_accumulator_helpers_1 = require("./materialized-delivery-accumulator-helpers");
16
16
  const materialized_delivery_classification_helpers_1 = require("./materialized-delivery-classification-helpers");
17
17
  const materialized_delivery_compile_helpers_1 = require("./materialized-delivery-compile-helpers");
@@ -166,7 +166,7 @@ function buildTenantDeliveryCloseDayPlan(input) {
166
166
  const existing = storedReportsByScope.get(deliveryScopeKey(compiledDateDoc));
167
167
  const next = {
168
168
  ...compiledDateDoc,
169
- _id: existing?._id ?? new mongoose_1.default.Types.ObjectId().toHexString(),
169
+ _id: existing?._id ?? new bson_objectid_1.default().toHexString(),
170
170
  iteration: Number(existing?.iteration ?? 0) + 1,
171
171
  };
172
172
  if (force || needsMaterializedDeliveryReportWrite(existing, next))
@@ -248,7 +248,7 @@ function buildTenantDeliveryCloseDayPlan(input) {
248
248
  counterRows.push({ key, counters: folded[key] });
249
249
  }
250
250
  const report = {
251
- _id: existing?._id ?? new mongoose_1.default.Types.ObjectId().toHexString(),
251
+ _id: existing?._id ?? new bson_objectid_1.default().toHexString(),
252
252
  tenant_id: tenantId,
253
253
  brand_id: existing?.brand_id ?? compiledDateDoc?.brand_id ?? '',
254
254
  scope_context: scope,
@@ -263,7 +263,7 @@ function buildTenantDeliveryCloseDayPlan(input) {
263
263
  iteration: existing?.iteration,
264
264
  // A folded period is always a CURRENT-shape document. v1 data must be wiped and
265
265
  // re-closed; it is never upgraded in place.
266
- schema_version: compiledDateDoc?.schema_version ?? materialized_tenant_delivery_reports_1.MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION,
266
+ schema_version: compiledDateDoc?.schema_version ?? MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION,
267
267
  // FROM THE DAYS THAT BELONG TO THIS PERIOD - never the stored watermark, and never
268
268
  // an unrelated day from another period. Using every sibling day would rewrite a
269
269
  // period whenever any other month moved.
@@ -287,7 +287,7 @@ function buildTenantDeliveryCloseDayPlan(input) {
287
287
  const existing = storedEntriesByPage.get(key) ?? null;
288
288
  const next = {
289
289
  ...compiled,
290
- _id: existing?._id ?? new mongoose_1.default.Types.ObjectId().toHexString(),
290
+ _id: existing?._id ?? new bson_objectid_1.default().toHexString(),
291
291
  iteration: Number(existing?.iteration ?? 0) + 1,
292
292
  };
293
293
  if (existing == null || force || needsMaterializedDeliveryEntriesWrite(existing, next)) {
@@ -9,8 +9,8 @@ exports.compileTenantDeliveryReports = compileTenantDeliveryReports;
9
9
  const ENUMS_1 = require("../../constants/ENUMS");
10
10
  const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
11
11
  const delivery_1 = require("../../constants/enums/delivery");
12
- const materialized_tenant_delivery_entries_1 = require("../../schemas/models/materialized_tenant_delivery_entries");
13
- const materialized_tenant_delivery_reports_1 = require("../../schemas/models/materialized_tenant_delivery_reports");
12
+ const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
13
+ const MATERIALIZED_SCHEMA_VERSIONS_2 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
14
14
  const materialized_delivery_accumulator_helpers_1 = require("./materialized-delivery-accumulator-helpers");
15
15
  const materialized_delivery_classification_helpers_1 = require("./materialized-delivery-classification-helpers");
16
16
  const materialized_delivery_entry_pages_1 = require("./materialized-delivery-entry-pages");
@@ -328,7 +328,7 @@ function compileTenantDeliveryReports(input) {
328
328
  sale_type_key_filters: [...MATERIALIZED_REPORTS_1.DELIVERY_KEY_FILTERS],
329
329
  delivery_counters: deliveryCounters,
330
330
  delivery_counter_rows: deliveryCounterRows,
331
- schema_version: materialized_tenant_delivery_reports_1.MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION,
331
+ schema_version: MATERIALIZED_SCHEMA_VERSIONS_2.MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION,
332
332
  source_watermark: watermark,
333
333
  computed_at: computedAt,
334
334
  createdAt: computedAt,
@@ -359,7 +359,7 @@ function compileTenantDeliveryReports(input) {
359
359
  sale_type_key_filters: [...MATERIALIZED_REPORTS_1.DELIVERY_KEY_FILTERS],
360
360
  delivery_entries: entrySections,
361
361
  off_app_order_count: offAppCount,
362
- schema_version: materialized_tenant_delivery_entries_1.MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION,
362
+ schema_version: MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION,
363
363
  source_watermark: watermark,
364
364
  computed_at: computedAt,
365
365
  createdAt: computedAt,