@managesome/eposmatic-toolkit 0.4.7 → 0.4.9

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 (54) hide show
  1. package/esm/constants/MATERIALIZED_REPORTS.js +33 -0
  2. package/esm/constants/enums/communications.js +1 -0
  3. package/esm/helpers/materialized-reports/index.js +1 -0
  4. package/esm/helpers/materialized-reports/materialized-credit-bills-helpers.js +982 -0
  5. package/esm/helpers/materialized-reports/materialized-reports-selection-helpers.js +276 -33
  6. package/esm/helpers/materialized-reports/tenant-sales-overview-close-day-helpers.js +327 -41
  7. package/esm/helpers/materialized-reports/tenant-sales-overview-formatter.js +72 -11
  8. package/esm/helpers/materialized-reports/tenant-sales-overview-helpers.js +118 -235
  9. package/esm/schemas/models/index.js +1 -0
  10. package/esm/schemas/models/materialized_credit_bills.js +265 -0
  11. package/esm/schemas/models/materialized_tenant_reports_iterations.js +13 -0
  12. package/esm/schemas/models/materialized_tenant_sales_overview_reports.js +39 -97
  13. package/esm/schemas/types/index.js +1 -0
  14. package/esm/schemas/types/materialized_credit_bills.js +1 -0
  15. package/lib/constants/MATERIALIZED_REPORTS.d.ts +28 -2
  16. package/lib/constants/MATERIALIZED_REPORTS.js +34 -1
  17. package/lib/constants/enums/communications.d.ts +1 -0
  18. package/lib/constants/enums/communications.js +2 -1
  19. package/lib/helpers/materialized-reports/index.d.ts +1 -0
  20. package/lib/helpers/materialized-reports/index.js +1 -0
  21. package/lib/helpers/materialized-reports/materialized-credit-bills-helpers.d.ts +307 -0
  22. package/lib/helpers/materialized-reports/materialized-credit-bills-helpers.js +1003 -0
  23. package/lib/helpers/materialized-reports/materialized-reports-selection-helpers.d.ts +36 -2
  24. package/lib/helpers/materialized-reports/materialized-reports-selection-helpers.js +278 -34
  25. package/lib/helpers/materialized-reports/tenant-sales-overview-close-day-helpers.d.ts +66 -8
  26. package/lib/helpers/materialized-reports/tenant-sales-overview-close-day-helpers.js +326 -40
  27. package/lib/helpers/materialized-reports/tenant-sales-overview-formatter.d.ts +18 -2
  28. package/lib/helpers/materialized-reports/tenant-sales-overview-formatter.js +72 -11
  29. package/lib/helpers/materialized-reports/tenant-sales-overview-helpers.d.ts +46 -37
  30. package/lib/helpers/materialized-reports/tenant-sales-overview-helpers.js +119 -238
  31. package/lib/helpers/types/materialized-reports-apis.d.ts +32 -5
  32. package/lib/schemas/models/index.d.ts +1 -0
  33. package/lib/schemas/models/index.js +1 -0
  34. package/lib/schemas/models/materialized_credit_bills.d.ts +337 -0
  35. package/lib/schemas/models/materialized_credit_bills.js +268 -0
  36. package/lib/schemas/models/materialized_tenant_reports_iterations.d.ts +20 -6
  37. package/lib/schemas/models/materialized_tenant_reports_iterations.js +14 -1
  38. package/lib/schemas/models/materialized_tenant_sales_overview_reports.d.ts +37 -165
  39. package/lib/schemas/models/materialized_tenant_sales_overview_reports.js +40 -98
  40. package/lib/schemas/types/index.d.ts +1 -0
  41. package/lib/schemas/types/index.js +1 -0
  42. package/lib/schemas/types/materialized_credit_bills.d.ts +139 -0
  43. package/lib/schemas/types/materialized_credit_bills.js +2 -0
  44. package/lib/schemas/types/materialized_tenant_sales_overview_reports.d.ts +32 -77
  45. package/lib/tests/materialized-reports/materialized-credit-bills-helpers.test.d.ts +1 -0
  46. package/lib/tests/materialized-reports/materialized-credit-bills-helpers.test.js +715 -0
  47. package/lib/tests/materialized-reports/materialized-reports-selection-helpers.test.js +96 -0
  48. package/lib/tests/materialized-reports/materialized-tenant-reports-iterations-schema.test.js +9 -0
  49. package/lib/tests/materialized-reports/materialized-tenant-sales-overview-reports-schema.test.js +23 -24
  50. package/lib/tests/materialized-reports/tenant-sales-overview-close-day-helpers.test.js +327 -22
  51. package/lib/tests/materialized-reports/tenant-sales-overview-formatter-aggregated.test.js +27 -2
  52. package/lib/tests/materialized-reports/tenant-sales-overview-formatter.test.js +12 -27
  53. package/lib/tests/materialized-reports/tenant-sales-overview-helpers.test.js +79 -146
  54. package/package.json +1 -1
@@ -62,6 +62,22 @@ export const MATERIALIZED_REPORT_SCOPES_WITH_DAY_INDEX = [
62
62
  MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_HOUR,
63
63
  MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
64
64
  ];
65
+ /**
66
+ * Scopes materialized by `materialized_tenant_credit_bills` — the credit
67
+ * ledger is CAPPED AT `LOCAL_MONTH`: a month bounds how many bills a document
68
+ * accumulates, so no document grows unboundedly over time. Whole-year /
69
+ * multi-year reads cover their range with the month documents (plus
70
+ * date/hour documents at range edges and for hour-precise time windows).
71
+ * `LOCAL_HOUR` is kept for zoomed-in selections (e.g. a report restricted to
72
+ * certain hours of a day).
73
+ */
74
+ export const MATERIALIZED_CREDIT_BILLS_SCOPES = [
75
+ MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_HOUR,
76
+ MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
77
+ MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK,
78
+ MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK_OF_YEAR,
79
+ MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH,
80
+ ];
65
81
  /**
66
82
  * Filter dimensions that can be encoded into the metric keys of a materialized
67
83
  * report document (`sale_type_metrics`). The declaration order defines the key
@@ -90,6 +106,22 @@ export const SALES_OVERVIEW_KEY_FILTERS = [
90
106
  * total sales.
91
107
  */
92
108
  export const MATERIALIZED_CREDIT_SETTLEMENT_PAYMENT_TYPE = 'CREDIT_SETTLEMENT';
109
+ /**
110
+ * Kind of a credit-bill ledger receipt event (`received.bills[].event_type` of
111
+ * the `CREDIT_BILLS` slot). The compile pipeline emits `RECEIPT`s today;
112
+ * `REFUND` / `WRITE_OFF` are reserved for SIGNED adjustments and are
113
+ * deliberately unimplemented (see `MATERIALIZED_REPORTS.md`). The event
114
+ * identity is `(order_id, payment_id, event_local_date)` — the kind never
115
+ * partakes in the key, so introducing the reserved kinds cannot rewrite
116
+ * existing events.
117
+ */
118
+ export var MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM;
119
+ (function (MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM) {
120
+ MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM["RECEIPT"] = "RECEIPT";
121
+ MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM["REFUND"] = "REFUND";
122
+ MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM["WRITE_OFF"] = "WRITE_OFF";
123
+ })(MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM || (MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM = {}));
124
+ export const ALL_MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPES = Object.values(MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM);
93
125
  /**
94
126
  * Materialized report kinds — the discriminator stored on
95
127
  * `materialized_tenant_reports_iterations` rows. A single shared history collection records
@@ -101,5 +133,6 @@ export const MATERIALIZED_CREDIT_SETTLEMENT_PAYMENT_TYPE = 'CREDIT_SETTLEMENT';
101
133
  export var MATERIALIZED_REPORT_TYPE_ENUM;
102
134
  (function (MATERIALIZED_REPORT_TYPE_ENUM) {
103
135
  MATERIALIZED_REPORT_TYPE_ENUM["TENANT_SALES_OVERVIEW"] = "TENANT_SALES_OVERVIEW";
136
+ MATERIALIZED_REPORT_TYPE_ENUM["TENANT_CREDIT_BILLS"] = "TENANT_CREDIT_BILLS";
104
137
  })(MATERIALIZED_REPORT_TYPE_ENUM || (MATERIALIZED_REPORT_TYPE_ENUM = {}));
105
138
  export const ALL_MATERIALIZED_REPORT_TYPES = Object.values(MATERIALIZED_REPORT_TYPE_ENUM);
@@ -290,6 +290,7 @@ export const BLACKLISTED_SMS_COUNTRY_CODES = [
290
290
  '+263', // Zimbabwe
291
291
  ];
292
292
  export const WHITELISTED_API_SMS_COUNTRY_CODES = ['+92']; // Pakistan
293
+ export const BLACKLISTED_WHATSAPP_COUNTRY_CODES = ['+92']; // Pakistan
293
294
  // ======================>> <<====================== //
294
295
  export var ALERT_NOTIFICATIONS_TYPE_ENUM;
295
296
  (function (ALERT_NOTIFICATIONS_TYPE_ENUM) {
@@ -1,4 +1,5 @@
1
1
  export * from './key-helpers';
2
+ export * from './materialized-credit-bills-helpers';
2
3
  export * from './materialized-reports-read-helpers';
3
4
  export * from './materialized-reports-scope-group-helpers';
4
5
  export * from './materialized-reports-selection-helpers';