@managesome/eposmatic-toolkit 0.2.500 → 0.2.501

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.
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getWarehouseInternalMovementItemsWithPrice = getWarehouseInternalMovementItemsWithPrice;
4
4
  exports.getWarehouseInternalMovementWithPrice = getWarehouseInternalMovementWithPrice;
5
5
  const utils_1 = require("../utils");
6
+ const common_order_actions_1 = require("./common-order-actions");
6
7
  /**
7
8
  * Convert unit_price on every internal movement item.
8
9
  */
@@ -14,6 +15,20 @@ function getWarehouseInternalMovementItemsWithPrice(items, convertToPrice) {
14
15
  unit_price: item.unit_price != null ? convertToPrice(item.unit_price) : undefined,
15
16
  }));
16
17
  }
18
+ /**
19
+ * Convert monetary fields on payments array.
20
+ */
21
+ function getPaymentsWithPrice(payments, convertToPrice) {
22
+ if (!payments)
23
+ return [];
24
+ return payments.map((payment) => ({
25
+ ...payment,
26
+ card_details: (0, common_order_actions_1.getOrderPaymentsCardDetailsWithPrice)(payment.card_details, convertToPrice),
27
+ amount_paid: payment.amount_paid != null ? convertToPrice(payment.amount_paid) : payment.amount_paid,
28
+ amount_due: payment.amount_due != null ? convertToPrice(payment.amount_due) : payment.amount_due,
29
+ amount_refunded: payment.amount_refunded != null ? convertToPrice(payment.amount_refunded) : payment.amount_refunded,
30
+ }));
31
+ }
17
32
  /**
18
33
  * Convert all monetary fields on an internal movement.
19
34
  *
@@ -24,10 +39,20 @@ function getWarehouseInternalMovementWithPrice(order, writeable) {
24
39
  const convertToPrice = writeable ? utils_1.convertDecimalToInt : utils_1.convertIntToDecimal;
25
40
  return {
26
41
  ...order,
42
+ ...(order.grand_total != null ? { grand_total: convertToPrice(order.grand_total) } : {}),
43
+ ...(order.gst_amount != null ? { gst_amount: convertToPrice(order.gst_amount) } : {}),
44
+ ...(order.amount_collected != null ? { amount_collected: convertToPrice(order.amount_collected) } : {}),
45
+ ...(order.amount_earned != null ? { amount_earned: convertToPrice(order.amount_earned) } : {}),
46
+ ...(order.gst != null ? { gst: convertToPrice(order.gst) } : {}),
27
47
  ...(order.items != null
28
48
  ? {
29
49
  items: getWarehouseInternalMovementItemsWithPrice(order.items, convertToPrice),
30
50
  }
31
51
  : {}),
52
+ ...(order.payments != null
53
+ ? {
54
+ payments: getPaymentsWithPrice(order.payments, convertToPrice),
55
+ }
56
+ : {}),
32
57
  };
33
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managesome/eposmatic-toolkit",
3
- "version": "0.2.500",
3
+ "version": "0.2.501",
4
4
  "description": "A Toolkit Library for Eposmatic",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",