@managesome/eposmatic-toolkit 0.2.225 → 0.2.227

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.
@@ -86,7 +86,6 @@ function generateOrderOnCreate(order, withIterations) {
86
86
  }
87
87
  : {}),
88
88
  ...(order.categories != null ? { categories: generateOrderCategories(order.categories) } : {}),
89
- order_taker_details: order.order_taker_details ?? order.staff_details,
90
89
  _id: new mongoose_1.default.Types.ObjectId(order._id),
91
90
  iterations: withIterations ? getOrderIterations(order.iterations) : [],
92
91
  };
@@ -1,4 +1,4 @@
1
- import { PAYMENT_EXTENSION_ENUM } from '../../constants';
1
+ import { PAYMENT_EXTENSION_ENUM, PAYMENT_TYPE_ENUM } from '../../constants';
2
2
  import { IOrderPayment } from '../../schemas';
3
3
  export declare function getPaymentAmountPayed(payment: IOrderPayment, allowUnverifiedPayments?: boolean): {
4
4
  amountPaid: number;
@@ -16,6 +16,7 @@ export declare function getOrderPaymentsDetails(grand_total: number | undefined,
16
16
  existingPayments: IOrderPayment[];
17
17
  };
18
18
  export declare function getTotalCardCharges(payments: IOrderPayment[] | undefined): number;
19
+ export declare function getPaymentTypeTotalAmount(payments: IOrderPayment[] | undefined, paymentType: PAYMENT_TYPE_ENUM | string, allowUnverifiedPayments?: boolean): number;
19
20
  export declare function getCardChargesAndAmountCollected(payments: IOrderPayment[] | undefined): {
20
21
  cardCharges: number;
21
22
  amountCollected: number;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getPaymentAmountPayed = getPaymentAmountPayed;
7
7
  exports.getOrderPaymentsDetails = getOrderPaymentsDetails;
8
8
  exports.getTotalCardCharges = getTotalCardCharges;
9
+ exports.getPaymentTypeTotalAmount = getPaymentTypeTotalAmount;
9
10
  exports.getCardChargesAndAmountCollected = getCardChargesAndAmountCollected;
10
11
  exports.isOrderFullyPaid = isOrderFullyPaid;
11
12
  exports.syncPayments = syncPayments;
@@ -95,6 +96,13 @@ function getTotalCardCharges(payments) {
95
96
  return acc + payment.card_details.card_charges;
96
97
  }, 0) ?? 0);
97
98
  }
99
+ function getPaymentTypeTotalAmount(payments, paymentType, allowUnverifiedPayments) {
100
+ return (payments?.reduce((acc, payment) => {
101
+ if (payment.payment_type !== paymentType)
102
+ return acc;
103
+ return acc + getPaymentAmountPayed(payment, allowUnverifiedPayments).totalAmountPaid;
104
+ }, 0) ?? 0);
105
+ }
98
106
  function getCardChargesAndAmountCollected(payments) {
99
107
  let cardCharges = 0;
100
108
  let amountCollected = 0;
@@ -739,7 +739,7 @@ function receiptEngine(payload, mappedItems = {}) {
739
739
  const staff_name = payload.printer_settings.print_staff_name && payload.order.staff_details != null
740
740
  ? (payload.order.staff_details.staff_name ?? null)
741
741
  : null;
742
- const order_taker_name = payload.order.order_taker_details?.staff_name ?? staff_name;
742
+ const order_taker_name = payload.order.order_taker_details?.staff_name ?? null;
743
743
  const rider_name = payload.order.delivery_details?.rider_details?.staff_name ?? null;
744
744
  let payment_status = null;
745
745
  // Helper to get expected payment label suffix
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managesome/eposmatic-toolkit",
3
- "version": "0.2.225",
3
+ "version": "0.2.227",
4
4
  "description": "A Toolkit Library for Eposmatic",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",