@managesome/eposmatic-toolkit 0.2.624 → 0.2.626

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.
@@ -417,7 +417,7 @@ export interface IXReportAnalytics {
417
417
  export declare enum REPORT_SALE_TYPE_ENUM {
418
418
  TOTAL_SALES = "TOTAL_SALES",
419
419
  AMOUNT_COLLECTED = "AMOUNT_COLLECTED",
420
- OPEN_ORDERS = "OPEN_ORDERS"
420
+ CREDIT_BILLS = "CREDIT_BILLS"
421
421
  }
422
422
  export declare const ALL_REPORT_SALE_TYPES: REPORT_SALE_TYPE_ENUM[];
423
423
  export declare enum REPORT_TIME_BIAS_ENUM {
@@ -126,7 +126,7 @@ var REPORT_SALE_TYPE_ENUM;
126
126
  (function (REPORT_SALE_TYPE_ENUM) {
127
127
  REPORT_SALE_TYPE_ENUM["TOTAL_SALES"] = "TOTAL_SALES";
128
128
  REPORT_SALE_TYPE_ENUM["AMOUNT_COLLECTED"] = "AMOUNT_COLLECTED";
129
- REPORT_SALE_TYPE_ENUM["OPEN_ORDERS"] = "OPEN_ORDERS";
129
+ REPORT_SALE_TYPE_ENUM["CREDIT_BILLS"] = "CREDIT_BILLS";
130
130
  })(REPORT_SALE_TYPE_ENUM || (exports.REPORT_SALE_TYPE_ENUM = REPORT_SALE_TYPE_ENUM = {}));
131
131
  exports.ALL_REPORT_SALE_TYPES = Object.values(REPORT_SALE_TYPE_ENUM);
132
132
  // ==================><=================
@@ -12,7 +12,7 @@ export declare function getOrderPaymentsDetails(grand_total: number | undefined,
12
12
  amountLeftToPay: number;
13
13
  cardCharges: number;
14
14
  change: number;
15
- openAmount: number;
15
+ creditAmount: number;
16
16
  existingPayments: IOrderPayment[];
17
17
  };
18
18
  export declare function getTotalCardCharges(payments: IOrderPayment[] | undefined): number;
@@ -69,7 +69,7 @@ function getOrderPaymentsDetails(grand_total, payments) {
69
69
  let amountLeft = (0, common_1.parseNum)(grand_total ?? 0);
70
70
  let cardCharges = 0;
71
71
  let change = 0;
72
- let openAmount = 0;
72
+ let creditAmount = 0;
73
73
  payments?.forEach((payment) => {
74
74
  const { totalAmountPaid, changeAmount, cardFee } = getPaymentAmountPayed(payment);
75
75
  payed += totalAmountPaid;
@@ -78,7 +78,7 @@ function getOrderPaymentsDetails(grand_total, payments) {
78
78
  cardCharges += cardFee;
79
79
  if (payment.payment_type === constants_1.PAYMENT_TYPE_ENUM.PAY_LATER &&
80
80
  payment.payment_status === constants_1.PAYMENT_STATUS_ENUM.PENDING) {
81
- openAmount += payment.amount_due;
81
+ creditAmount += payment.amount_due;
82
82
  }
83
83
  });
84
84
  return {
@@ -86,7 +86,7 @@ function getOrderPaymentsDetails(grand_total, payments) {
86
86
  amountLeftToPay: amountLeft,
87
87
  cardCharges,
88
88
  change,
89
- openAmount,
89
+ creditAmount,
90
90
  existingPayments: (payments ?? []).filter((payment) => payment.payment_type !== constants_1.PAYMENT_TYPE_ENUM.UNPAID && payment.amount_due > 0),
91
91
  };
92
92
  }
@@ -504,7 +504,7 @@ function receiptEngine(payload, mappedItems = {}) {
504
504
  const { full_width, included_categories_map, printing_preference, receipt_type, show_modifiers, display_modifiers_on_separate_lines, display_item_instructions_on_customer_receipt, display_order_instructions_on_customer_receipt, display_unit_item_price_on_customer_receipt, hide_modifier_name, display_qr_code_on_receipt, customMessage, } = payload.printer_settings;
505
505
  const currencySymbol = currency_symbol ?? '';
506
506
  const grandTotal = payload.order.grand_total ?? 0;
507
- const { amountPayedSoFar, existingPayments, change, openAmount } = (0, payment_helpers_1.getOrderPaymentsDetails)(payload.order.grand_total, payload.order.payments);
507
+ const { amountPayedSoFar, existingPayments, change, creditAmount } = (0, payment_helpers_1.getOrderPaymentsDetails)(payload.order.grand_total, payload.order.payments);
508
508
  const payments = (0, payment_helpers_1.getSortedPayments)(existingPayments.filter((payment) => payment.payment_status === constants_1.PAYMENT_STATUS_ENUM.SETTLED ||
509
509
  payment.payment_status === constants_1.PAYMENT_STATUS_ENUM.REFUNDED));
510
510
  const gstName = (0, common_1.getGSTName)(country_alpha_2, tax_invoice_provider);
@@ -770,12 +770,12 @@ function receiptEngine(payload, mappedItems = {}) {
770
770
  payment_status = '* CANCELLED *';
771
771
  }
772
772
  else if (receipt_type === constants_1.RECEIPT_TYPE_ENUM.CUSTOMER || !payload.printer_settings.keep_kitchen_receipt_concise) {
773
- // OPEN BILL has priority - check first if there's an open amount (PAY_LATER)
774
- if (openAmount > 0) {
775
- payment_status = '* OPEN BILL *';
773
+ // CREDIT BILL has priority - check first if there's an credit amount (PAY_LATER)
774
+ if (creditAmount > 0) {
775
+ payment_status = '* CREDIT BILL *';
776
776
  payment_details.push({
777
- left: `Open Amount${getExpectedPaymentLabel()}`,
778
- right: (0, common_1.localeAmount)(currencySymbol, openAmount),
777
+ left: `Credit Amount${getExpectedPaymentLabel()}`,
778
+ right: (0, common_1.localeAmount)(currencySymbol, creditAmount),
779
779
  });
780
780
  }
781
781
  else if (parsedAmountPayedSoFar >= (0, common_1.parseNum)(grandTotal)) {
@@ -18,8 +18,8 @@ function getTenantCalendarDayFromCents(day) {
18
18
  ...(typeof day.cancelled_orders_amount === 'number'
19
19
  ? { cancelled_orders_amount: (0, price_conversion_1.convertPriceFromCents)(day.cancelled_orders_amount) }
20
20
  : {}),
21
- ...(typeof day.open_orders_amount === 'number'
22
- ? { open_orders_amount: (0, price_conversion_1.convertPriceFromCents)(day.open_orders_amount) }
21
+ ...(typeof day.credit_orders_amount === 'number'
22
+ ? { credit_orders_amount: (0, price_conversion_1.convertPriceFromCents)(day.credit_orders_amount) }
23
23
  : {}),
24
24
  };
25
25
  }
@@ -38,8 +38,8 @@ function getTenantCalendarDayWithCents(day) {
38
38
  ...(typeof day.cancelled_orders_amount === 'number'
39
39
  ? { cancelled_orders_amount: (0, price_conversion_1.convertPriceToCents)(day.cancelled_orders_amount) }
40
40
  : {}),
41
- ...(typeof day.open_orders_amount === 'number'
42
- ? { open_orders_amount: (0, price_conversion_1.convertPriceToCents)(day.open_orders_amount) }
41
+ ...(typeof day.credit_orders_amount === 'number'
42
+ ? { credit_orders_amount: (0, price_conversion_1.convertPriceToCents)(day.credit_orders_amount) }
43
43
  : {}),
44
44
  };
45
45
  }
@@ -48,4 +48,4 @@ export declare function getLocalDocumentFields(gmtOffset: number, date: Date): {
48
48
  * from the actual `order_settled_at` timestamp expressed in the tenant's time
49
49
  * zone (`operational_time_zone_offset_gmt`).
50
50
  */
51
- export declare function getLocalFieldsFromLocalDate(localDate: string, operational_time_zone_offset_gmt: number, order_settled_at: Date): ILocalTimeFields;
51
+ export declare function getLocalFieldsFromLocalDate(localDate: string, operational_time_zone_offset_gmt: number, createdAt: Date): ILocalTimeFields;
@@ -114,7 +114,7 @@ function getLocalDocumentFields(gmtOffset, date) {
114
114
  * from the actual `order_settled_at` timestamp expressed in the tenant's time
115
115
  * zone (`operational_time_zone_offset_gmt`).
116
116
  */
117
- function getLocalFieldsFromLocalDate(localDate, operational_time_zone_offset_gmt, order_settled_at) {
117
+ function getLocalFieldsFromLocalDate(localDate, operational_time_zone_offset_gmt, createdAt) {
118
118
  const [localYear, localMonth, localDay] = localDate.split('-').map(Number);
119
119
  // localDate is already the tenant's local calendar date, so every date
120
120
  // component is derived directly from the string using pure calendar math
@@ -130,7 +130,7 @@ function getLocalFieldsFromLocalDate(localDate, operational_time_zone_offset_gmt
130
130
  // Time components come from the actual settle timestamp in the tenant's
131
131
  // timezone. The timestamp is normalized with new Date() since callers pass
132
132
  // the field straight from the order (which may be a Date or an ISO string).
133
- const timeFields = getLocalDocumentFields(operational_time_zone_offset_gmt, new Date(order_settled_at));
133
+ const timeFields = getLocalDocumentFields(operational_time_zone_offset_gmt, new Date(createdAt));
134
134
  return {
135
135
  day_index: constants_1.ALL_DAY_INDEX[weekday],
136
136
  localDate,
@@ -15415,19 +15415,20 @@ export declare const ORDERS_COLLECTION_NAME = "orders";
15415
15415
  * Describes the indexes for `orders`. Values are Mongo key patterns that can be
15416
15416
  * passed straight to `.hint()`.
15417
15417
  * - `_id`: unique primary key.
15418
- * - `tenant_id__deferred_settlement__createdAt`: PARTIAL index — create with
15419
- * `partialFilterExpression: { deferred_settlement: true }` (only open bills /
15420
- * credit-tab orders are indexed; every query using this hint filters
15421
- * deferred_settlement: true). Supports per-tenant open-bill lookups newest
15422
- * first via created_at desc.
15418
+ * - `tenant_id__deferred_settlement__is_deleted__createdAt`: PARTIAL index —
15419
+ * create with `partialFilterExpression: { deferred_settlement: true }` (only
15420
+ * credit bills / credit-tab orders are indexed; every query using this hint
15421
+ * filters deferred_settlement: true and typically is_deleted: false).
15422
+ * Supports per-tenant credit-bill lookups newest first via created_at desc.
15423
15423
  */
15424
15424
  export declare const ORDERS_COLLECTION_INDEXES: {
15425
15425
  _id: {
15426
15426
  _id: number;
15427
15427
  };
15428
- tenant_id__deferred_settlement__createdAt: {
15428
+ tenant_id__deferred_settlement__is_deleted__createdAt: {
15429
15429
  tenant_id: number;
15430
15430
  deferred_settlement: number;
15431
+ is_deleted: number;
15431
15432
  createdAt: number;
15432
15433
  };
15433
15434
  };
@@ -975,17 +975,18 @@ exports.ORDERS_COLLECTION_NAME = 'orders';
975
975
  * Describes the indexes for `orders`. Values are Mongo key patterns that can be
976
976
  * passed straight to `.hint()`.
977
977
  * - `_id`: unique primary key.
978
- * - `tenant_id__deferred_settlement__createdAt`: PARTIAL index — create with
979
- * `partialFilterExpression: { deferred_settlement: true }` (only open bills /
980
- * credit-tab orders are indexed; every query using this hint filters
981
- * deferred_settlement: true). Supports per-tenant open-bill lookups newest
982
- * first via created_at desc.
978
+ * - `tenant_id__deferred_settlement__is_deleted__createdAt`: PARTIAL index —
979
+ * create with `partialFilterExpression: { deferred_settlement: true }` (only
980
+ * credit bills / credit-tab orders are indexed; every query using this hint
981
+ * filters deferred_settlement: true and typically is_deleted: false).
982
+ * Supports per-tenant credit-bill lookups newest first via created_at desc.
983
983
  */
984
984
  exports.ORDERS_COLLECTION_INDEXES = {
985
985
  _id: { _id: 1 }, // Unique Index
986
- tenant_id__deferred_settlement__createdAt: {
986
+ tenant_id__deferred_settlement__is_deleted__createdAt: {
987
987
  tenant_id: 1,
988
988
  deferred_settlement: 1,
989
+ is_deleted: 1,
989
990
  createdAt: -1,
990
- }, // partial index (partialFilterExpression: { deferred_settlement: true }) — open bills per tenant, newest first
991
+ }, // partial index (partialFilterExpression: { deferred_settlement: true }) — active open bills per tenant, newest first
991
992
  };
@@ -20,8 +20,8 @@ export declare const TenantCalendarSchema: Schema<any, import("mongoose").Model<
20
20
  discount_orders_count: number;
21
21
  discount_orders_amount: number;
22
22
  cancelled_orders_count: number;
23
- open_orders_count: number;
24
- open_orders_amount: number;
23
+ credit_orders_count: number;
24
+ credit_orders_amount: number;
25
25
  }>;
26
26
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
27
27
  createdAt: NativeDate;
@@ -40,8 +40,8 @@ export declare const TenantCalendarSchema: Schema<any, import("mongoose").Model<
40
40
  discount_orders_count: number;
41
41
  discount_orders_amount: number;
42
42
  cancelled_orders_count: number;
43
- open_orders_count: number;
44
- open_orders_amount: number;
43
+ credit_orders_count: number;
44
+ credit_orders_amount: number;
45
45
  }>;
46
46
  }>> & import("mongoose").FlatRecord<{
47
47
  createdAt: NativeDate;
@@ -60,8 +60,8 @@ export declare const TenantCalendarSchema: Schema<any, import("mongoose").Model<
60
60
  discount_orders_count: number;
61
61
  discount_orders_amount: number;
62
62
  cancelled_orders_count: number;
63
- open_orders_count: number;
64
- open_orders_amount: number;
63
+ credit_orders_count: number;
64
+ credit_orders_amount: number;
65
65
  }>;
66
66
  }> & Required<{
67
67
  _id: import("mongoose").Types.ObjectId;
@@ -31,11 +31,11 @@ const TenantCalendarDaySchema = new mongoose_1.Schema({
31
31
  type: Number,
32
32
  required: true,
33
33
  },
34
- open_orders_count: {
34
+ credit_orders_count: {
35
35
  type: Number,
36
36
  required: true,
37
37
  },
38
- open_orders_amount: {
38
+ credit_orders_amount: {
39
39
  type: Number,
40
40
  required: true,
41
41
  },
@@ -6,8 +6,8 @@ export interface ITenantCalendarDay {
6
6
  discount_orders_amount: number;
7
7
  cancelled_orders_count: number;
8
8
  cancelled_orders_amount: number;
9
- open_orders_count: number;
10
- open_orders_amount: number;
9
+ credit_orders_count: number;
10
+ credit_orders_amount: number;
11
11
  }
12
12
  export interface ITenantCalendar {
13
13
  _id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managesome/eposmatic-toolkit",
3
- "version": "0.2.624",
3
+ "version": "0.2.626",
4
4
  "description": "A Toolkit Library for Eposmatic",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",