@open-tender/utils 0.5.77 → 0.5.78

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.
@@ -133,3 +133,41 @@ describe('group order checkout payload', () => {
133
133
  expect(payload.cart).toEqual(GROUP_CHECKOUT_CART.slice(1));
134
134
  });
135
135
  });
136
+ describe('existing order payload', () => {
137
+ const orderData = {
138
+ address: null,
139
+ cart: [],
140
+ cartId: null,
141
+ customer: null,
142
+ deposit: null,
143
+ details: null,
144
+ deviceType: null,
145
+ discounts: null,
146
+ orderId: null,
147
+ points: null,
148
+ prepType: null,
149
+ promoCodes: null,
150
+ requestedAt: 'asap',
151
+ revenueCenterId: 3,
152
+ serviceType: 'PICKUP',
153
+ surcharges: null,
154
+ table: null,
155
+ tenders: null,
156
+ tip: null
157
+ };
158
+ it('sends the order uuid together with the order id', () => {
159
+ const payload = (0, utils_1.prepareOrder)(Object.assign(Object.assign({}, orderData), { orderId: 42, orderUuid: 'abc-123' }));
160
+ expect(payload.order_id).toBe(42);
161
+ expect(payload.order_uuid).toBe('abc-123');
162
+ });
163
+ it('omits the order uuid without an order id', () => {
164
+ const payload = (0, utils_1.prepareOrder)(Object.assign(Object.assign({}, orderData), { orderUuid: 'abc-123' }));
165
+ expect(payload).not.toHaveProperty('order_id');
166
+ expect(payload).not.toHaveProperty('order_uuid');
167
+ });
168
+ it('omits the order uuid when it is null', () => {
169
+ const payload = (0, utils_1.prepareOrder)(Object.assign(Object.assign({}, orderData), { orderId: 42, orderUuid: null }));
170
+ expect(payload.order_id).toBe(42);
171
+ expect(payload).not.toHaveProperty('order_uuid');
172
+ });
173
+ });
@@ -242,6 +242,8 @@ export declare const validateCart: (cart: Cart, categories: MenuCategories, sold
242
242
  errors: CartErrors | null;
243
243
  };
244
244
  export declare const getDefaultTip: (config: CheckoutConfig) => string | null;
245
- export declare const prepareOrder: (data: OrderData) => OrderCreate;
245
+ export declare const prepareOrder: (data: OrderData & {
246
+ orderUuid?: string | null;
247
+ }) => OrderCreate;
246
248
  export declare const checkAmountRemaining: (total: Money, tenders: CheckoutTenders) => number;
247
249
  export declare const makeDeviceType: (deviceType: string, deviceId?: string) => "DESKTOP" | "MOBILE" | "TABLET";
@@ -1056,6 +1056,8 @@ const prepareOrder = (data) => {
1056
1056
  }
1057
1057
  if (data.orderId)
1058
1058
  order.order_id = data.orderId;
1059
+ if (data.orderId && data.orderUuid)
1060
+ order.order_uuid = data.orderUuid;
1059
1061
  if (data.cartId)
1060
1062
  order.cart_id = data.cartId;
1061
1063
  if (data.save)
@@ -131,3 +131,41 @@ describe('group order checkout payload', () => {
131
131
  expect(payload.cart).toEqual(GROUP_CHECKOUT_CART.slice(1));
132
132
  });
133
133
  });
134
+ describe('existing order payload', () => {
135
+ const orderData = {
136
+ address: null,
137
+ cart: [],
138
+ cartId: null,
139
+ customer: null,
140
+ deposit: null,
141
+ details: null,
142
+ deviceType: null,
143
+ discounts: null,
144
+ orderId: null,
145
+ points: null,
146
+ prepType: null,
147
+ promoCodes: null,
148
+ requestedAt: 'asap',
149
+ revenueCenterId: 3,
150
+ serviceType: 'PICKUP',
151
+ surcharges: null,
152
+ table: null,
153
+ tenders: null,
154
+ tip: null
155
+ };
156
+ it('sends the order uuid together with the order id', () => {
157
+ const payload = prepareOrder(Object.assign(Object.assign({}, orderData), { orderId: 42, orderUuid: 'abc-123' }));
158
+ expect(payload.order_id).toBe(42);
159
+ expect(payload.order_uuid).toBe('abc-123');
160
+ });
161
+ it('omits the order uuid without an order id', () => {
162
+ const payload = prepareOrder(Object.assign(Object.assign({}, orderData), { orderUuid: 'abc-123' }));
163
+ expect(payload).not.toHaveProperty('order_id');
164
+ expect(payload).not.toHaveProperty('order_uuid');
165
+ });
166
+ it('omits the order uuid when it is null', () => {
167
+ const payload = prepareOrder(Object.assign(Object.assign({}, orderData), { orderId: 42, orderUuid: null }));
168
+ expect(payload.order_id).toBe(42);
169
+ expect(payload).not.toHaveProperty('order_uuid');
170
+ });
171
+ });
@@ -242,6 +242,8 @@ export declare const validateCart: (cart: Cart, categories: MenuCategories, sold
242
242
  errors: CartErrors | null;
243
243
  };
244
244
  export declare const getDefaultTip: (config: CheckoutConfig) => string | null;
245
- export declare const prepareOrder: (data: OrderData) => OrderCreate;
245
+ export declare const prepareOrder: (data: OrderData & {
246
+ orderUuid?: string | null;
247
+ }) => OrderCreate;
246
248
  export declare const checkAmountRemaining: (total: Money, tenders: CheckoutTenders) => number;
247
249
  export declare const makeDeviceType: (deviceType: string, deviceId?: string) => "DESKTOP" | "MOBILE" | "TABLET";
@@ -1016,6 +1016,8 @@ export const prepareOrder = (data) => {
1016
1016
  }
1017
1017
  if (data.orderId)
1018
1018
  order.order_id = data.orderId;
1019
+ if (data.orderId && data.orderUuid)
1020
+ order.order_uuid = data.orderUuid;
1019
1021
  if (data.cartId)
1020
1022
  order.cart_id = data.cartId;
1021
1023
  if (data.save)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.5.77",
3
+ "version": "0.5.78",
4
4
  "description": "A library of utils for use with Open Tender applications that utilize our cloud-based Order API.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",