@springtree/eva-sdk-core-service-extensions 1.1.0-beta.0
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.
- package/LICENSE +5 -0
- package/README.md +57 -0
- package/lib/eva-sdk-core-service-extensions.d.ts +9 -0
- package/lib/eva-sdk-core-service-extensions.d.ts.map +1 -0
- package/lib/eva-sdk-core-service-extensions.js +8 -0
- package/lib/eva-sdk-core-service-extensions.js.map +1 -0
- package/lib/is-bundle-product.d.ts +3 -0
- package/lib/is-bundle-product.d.ts.map +1 -0
- package/lib/is-bundle-product.js +5 -0
- package/lib/is-bundle-product.js.map +1 -0
- package/lib/is-configurable-product.d.ts +3 -0
- package/lib/is-configurable-product.d.ts.map +1 -0
- package/lib/is-configurable-product.js +5 -0
- package/lib/is-configurable-product.js.map +1 -0
- package/lib/order-status.d.ts +152 -0
- package/lib/order-status.d.ts.map +1 -0
- package/lib/order-status.js +326 -0
- package/lib/order-status.js.map +1 -0
- package/lib/orders/order-manager.d.ts +13 -0
- package/lib/orders/order-manager.d.ts.map +1 -0
- package/lib/orders/order-manager.js +37 -0
- package/lib/orders/order-manager.js.map +1 -0
- package/lib/orders/order-operations.d.ts +17 -0
- package/lib/orders/order-operations.d.ts.map +1 -0
- package/lib/orders/order-operations.js +2 -0
- package/lib/orders/order-operations.js.map +1 -0
- package/lib/orders/order.d.ts +30 -0
- package/lib/orders/order.d.ts.map +1 -0
- package/lib/orders/order.js +167 -0
- package/lib/orders/order.js.map +1 -0
- package/lib/product-count-by-type.d.ts +26 -0
- package/lib/product-count-by-type.d.ts.map +1 -0
- package/lib/product-count-by-type.js +61 -0
- package/lib/product-count-by-type.js.map +1 -0
- package/lib/settings.d.ts +44 -0
- package/lib/settings.d.ts.map +1 -0
- package/lib/settings.js +78 -0
- package/lib/settings.js.map +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Copyright 2019 SpringTree Solutions <info@springtree.nl>
|
|
2
|
+
|
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
4
|
+
|
|
5
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# `@springtree/eva-sdk-core-service-extensions`
|
|
2
|
+
|
|
3
|
+
This package contains various helpers and support classes for working with services from the EVA backend
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { EvaOrderManager } from '@springtree/eva-sdk-core-service-extensions';
|
|
9
|
+
|
|
10
|
+
const context = new EvaContext({
|
|
11
|
+
applicationToken,
|
|
12
|
+
authenticationToken,
|
|
13
|
+
endpointUrl,
|
|
14
|
+
refreshToken,
|
|
15
|
+
role: 'CLOUD',
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const orderManager = new EvaOrderManager({ context });
|
|
19
|
+
|
|
20
|
+
// Start a new order
|
|
21
|
+
//
|
|
22
|
+
const newOrder = await orderManager.startNewOrder();
|
|
23
|
+
|
|
24
|
+
// Fetch an existing order
|
|
25
|
+
//
|
|
26
|
+
const existingOrder = await orderManager.getOrder({ orderId: '1'});
|
|
27
|
+
|
|
28
|
+
// Add something to a new or existing order
|
|
29
|
+
//
|
|
30
|
+
await existingOrder.addToOrder({
|
|
31
|
+
service: SvcAddProductToOrder,
|
|
32
|
+
payload: { ProductID: '1', Quantity: 1 },
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
await existingOrder.modifyOrder({
|
|
36
|
+
service: SvcPrepareOrderForCheckout,
|
|
37
|
+
payload: {},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// If you want to perform multiple operations disable auto-order update
|
|
41
|
+
// Perform the operations one-by-one to ensure correct order creation
|
|
42
|
+
//
|
|
43
|
+
await existingOrder.addToOrder({
|
|
44
|
+
service: SvcAddProductToOrder,
|
|
45
|
+
payload: { ProductID: '1', Quantity: 1 },
|
|
46
|
+
skipOrderUpdate: true,
|
|
47
|
+
});
|
|
48
|
+
await existingOrder.addToOrder({
|
|
49
|
+
service: SvcAddProductToOrder,
|
|
50
|
+
payload: { ProductID: '2', Quantity: 1 },
|
|
51
|
+
skipOrderUpdate: true,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Fetch updated order when operations complete
|
|
55
|
+
//
|
|
56
|
+
await existingOrder.updateOrder();
|
|
57
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { EvaOrderManager } from './orders/order-manager.js';
|
|
2
|
+
export { IOrderData } from './orders/order.js';
|
|
3
|
+
export * from './orders/order-operations.js';
|
|
4
|
+
export { countOrderProductsByType } from './product-count-by-type.js';
|
|
5
|
+
export { determineOrderMode, determineOrderStatus } from './order-status.js';
|
|
6
|
+
export { isBundleProduct } from './is-bundle-product.js';
|
|
7
|
+
export { isConfigurableProduct } from './is-configurable-product.js';
|
|
8
|
+
export * from './settings.js';
|
|
9
|
+
//# sourceMappingURL=eva-sdk-core-service-extensions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eva-sdk-core-service-extensions.d.ts","sourceRoot":"","sources":["../src/eva-sdk-core-service-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { EvaOrderManager } from './orders/order-manager.js';
|
|
2
|
+
export * from './orders/order-operations.js';
|
|
3
|
+
export { countOrderProductsByType } from './product-count-by-type.js';
|
|
4
|
+
export { determineOrderMode, determineOrderStatus } from './order-status.js';
|
|
5
|
+
export { isBundleProduct } from './is-bundle-product.js';
|
|
6
|
+
export { isConfigurableProduct } from './is-configurable-product.js';
|
|
7
|
+
export * from './settings.js';
|
|
8
|
+
//# sourceMappingURL=eva-sdk-core-service-extensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eva-sdk-core-service-extensions.js","sourceRoot":"","sources":["../src/eva-sdk-core-service-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,cAAc,8BAA8B,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-bundle-product.d.ts","sourceRoot":"","sources":["../src/is-bundle-product.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,eAAO,MAAM,eAAe,8BAA+B,yBAAyB,OAAO,CAAC,YAG3F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-bundle-product.js","sourceRoot":"","sources":["../src/is-bundle-product.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAmB,OAA0C,EAAE,EAAE;IAC9F,MAAM,YAAY,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,IAAI,EAAE,CAAa,CAAC;IACvE,OAAO,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3C,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-configurable-product.d.ts","sourceRoot":"","sources":["../src/is-configurable-product.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,eAAO,MAAM,qBAAqB,8BAA+B,yBAAyB,OAAO,CAAC,YAGjG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-configurable-product.js","sourceRoot":"","sources":["../src/is-configurable-product.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAmB,OAA0C,EAAE,EAAE;IACpG,MAAM,YAAY,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,IAAI,EAAE,CAAa,CAAC;IACvE,OAAO,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC5C,CAAC,CAAC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { ValidationRequirement as Requirement, OrdersProductRequirementLineModel as ProductRequirementLineModel, EnumerationsLineActionTypes as LineActionTypes, ValidationRequiredData as RequiredData, OrdersDtoOrderDto as OrderDto, OrdersProductRequirementModel as ProductRequirementModel } from '@springtree/eva-services-core';
|
|
2
|
+
/**
|
|
3
|
+
* A step is an action that can be performed during an order checkout
|
|
4
|
+
*/
|
|
5
|
+
export interface ICheckoutStepStatus {
|
|
6
|
+
/**
|
|
7
|
+
* Indicates it is possible to perform the step
|
|
8
|
+
* Meaning all requirements and prerequisites are met from
|
|
9
|
+
* getRequiredDataForOrder
|
|
10
|
+
*/
|
|
11
|
+
possible: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Optional indicator for certain steps (ie. placeOrder)
|
|
14
|
+
* which indicates the step will be possible once payment has completed
|
|
15
|
+
* This can be used as a trigger for the front-end to ensure all requirements
|
|
16
|
+
* other then payment have been met
|
|
17
|
+
*/
|
|
18
|
+
possibleAfterPayment?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Indicates this step is required for the current order
|
|
21
|
+
*/
|
|
22
|
+
required: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Indicates all requirements are met for this step
|
|
25
|
+
*/
|
|
26
|
+
valid: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Status for any product that has product requirements.
|
|
30
|
+
* Product requirements are custom values that can be set for a specific order line.
|
|
31
|
+
* Things like inscriptions are an example.
|
|
32
|
+
* Product requirements are updated using `UpdateProductRequirementValuesForOrderLine`
|
|
33
|
+
*/
|
|
34
|
+
export interface IProductRequirementState<ID_TYPE = string> {
|
|
35
|
+
requirement: Requirement<ID_TYPE>;
|
|
36
|
+
orderLineID: ID_TYPE;
|
|
37
|
+
values?: ProductRequirementLineModel<ID_TYPE>[];
|
|
38
|
+
valid: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Status for any product that needs a serial number.
|
|
42
|
+
* Serial numbers are set for an order line using `UpdateSerialNumber`
|
|
43
|
+
*/
|
|
44
|
+
export interface IProductSerialNumberState<ID_TYPE = string> {
|
|
45
|
+
requirement: Requirement<ID_TYPE>;
|
|
46
|
+
orderLineID: ID_TYPE;
|
|
47
|
+
serialNumber?: string;
|
|
48
|
+
valid: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Status for any product bundle.
|
|
52
|
+
* Bundles are collections of sub-product that make one main product.
|
|
53
|
+
*/
|
|
54
|
+
export interface IProductBundleState<ID_TYPE = string> {
|
|
55
|
+
requirement: Requirement<ID_TYPE>;
|
|
56
|
+
orderLineID: ID_TYPE;
|
|
57
|
+
productLineIDs: ID_TYPE[];
|
|
58
|
+
valid: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Status for the pick discount product requirement.
|
|
62
|
+
* This is the feature used to have a customer pick a gift product based on
|
|
63
|
+
* current order properties (total value mostly)
|
|
64
|
+
*/
|
|
65
|
+
export interface IPickDiscountProductState<ID_TYPE = string> {
|
|
66
|
+
requirement: Requirement<ID_TYPE>;
|
|
67
|
+
orderLineID: ID_TYPE;
|
|
68
|
+
pickedProductLineIDs: ID_TYPE[];
|
|
69
|
+
valid: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The checkout steps we provide a status for
|
|
73
|
+
* NOTE: More checkout steps could exist depending on customer requirements
|
|
74
|
+
*/
|
|
75
|
+
export interface IOrderStatus<ID_TYPE = string> {
|
|
76
|
+
orderMode: OrderMode;
|
|
77
|
+
lineActionTypes: LineActionTypes[];
|
|
78
|
+
checkoutSteps: {
|
|
79
|
+
/**
|
|
80
|
+
* Status and validity of the customer attached to the current order
|
|
81
|
+
*/
|
|
82
|
+
attachCustomer: ICheckoutStepStatus;
|
|
83
|
+
/**
|
|
84
|
+
* Status of the preparation of the order for a checkout.
|
|
85
|
+
* Client applications should call `PrepareOrderForCheckout` every time
|
|
86
|
+
* the order enters a checkout flow
|
|
87
|
+
*/
|
|
88
|
+
createOrder: ICheckoutStepStatus;
|
|
89
|
+
/**
|
|
90
|
+
* Status of the placement of the order.
|
|
91
|
+
* This will reserve the products and update stock as needed
|
|
92
|
+
*/
|
|
93
|
+
placeOrder: ICheckoutStepStatus;
|
|
94
|
+
/**
|
|
95
|
+
* Status of the order line(s) handover to the customer
|
|
96
|
+
*/
|
|
97
|
+
shipOrder: ICheckoutStepStatus;
|
|
98
|
+
/**
|
|
99
|
+
* Status of the payment (if required) for the order
|
|
100
|
+
*/
|
|
101
|
+
payment: ICheckoutStepStatus;
|
|
102
|
+
};
|
|
103
|
+
issues: {
|
|
104
|
+
customer: Requirement<ID_TYPE>[];
|
|
105
|
+
order: Requirement<ID_TYPE>[];
|
|
106
|
+
orderLine: {
|
|
107
|
+
[orderlineID: string]: Requirement<ID_TYPE>[];
|
|
108
|
+
};
|
|
109
|
+
invalidOrderLineIDs: ID_TYPE[];
|
|
110
|
+
};
|
|
111
|
+
bundleProducts: IProductBundleState<ID_TYPE>[];
|
|
112
|
+
pickDiscountProducts: IPickDiscountProductState<ID_TYPE>[];
|
|
113
|
+
productsWithRequirements: IProductRequirementState<ID_TYPE>[];
|
|
114
|
+
productsWithSerialNumbers: IProductSerialNumberState<ID_TYPE>[];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The type of order which is deduced based on line action types present
|
|
118
|
+
* and possibly other characteristics
|
|
119
|
+
*/
|
|
120
|
+
export declare enum OrderMode {
|
|
121
|
+
empty = "EMPTY",
|
|
122
|
+
sale = "SALE",
|
|
123
|
+
reservation = "RESERVATION",
|
|
124
|
+
delivery = "DELIVERY",
|
|
125
|
+
order = "ORDER",
|
|
126
|
+
interbranch = "INTERBRANCH",
|
|
127
|
+
returnToSupplier = "RETURN_TO_SUPPLIER",
|
|
128
|
+
mixed = "MIXED"
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Helper method to determine if an order has product with product requirements
|
|
132
|
+
* based on the getRequiredDataForOrder response
|
|
133
|
+
*/
|
|
134
|
+
export declare function hasProductRequirement<ID_TYPE = string>({ requiredData, }: {
|
|
135
|
+
requiredData: RequiredData<ID_TYPE>;
|
|
136
|
+
}): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Helper method to determine the current order mode
|
|
139
|
+
*/
|
|
140
|
+
export declare function determineOrderMode<ID_TYPE = string>({ order, }: {
|
|
141
|
+
order: OrderDto<ID_TYPE>;
|
|
142
|
+
}): OrderMode;
|
|
143
|
+
/**
|
|
144
|
+
* Helper method to calculate the current order (checkout) status based
|
|
145
|
+
* on the order and required data response
|
|
146
|
+
*/
|
|
147
|
+
export declare function determineOrderStatus({ order, requiredData, productRequirements, }: {
|
|
148
|
+
order: OrderDto;
|
|
149
|
+
requiredData: RequiredData;
|
|
150
|
+
productRequirements?: ProductRequirementModel[];
|
|
151
|
+
}): IOrderStatus;
|
|
152
|
+
//# sourceMappingURL=order-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-status.d.ts","sourceRoot":"","sources":["../src/order-status.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,IAAI,WAAW,EACpC,iCAAiC,IAAI,2BAA2B,EAChE,2BAA2B,IAAI,eAAe,EAC9C,sBAAsB,IAAI,YAAY,EACtC,iBAAiB,IAAI,QAAQ,EAC7B,6BAA6B,IAAI,uBAAuB,EAEzD,MAAM,+BAA+B,CAAA;AAGtC;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAElC;;;;OAIG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB,CAAC,OAAO,GAAG,MAAM;IAExD,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAClC,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,2BAA2B,CAAC,OAAO,CAAC,EAAE,CAAC;IAChD,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;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C,EAAE,CAAA;SAAC,CAAC;QAC3D,mBAAmB,EAAE,OAAO,EAAE,CAAC;KAChC,CAAC;IACF,cAAc,EAAE,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;IAC/C,oBAAoB,EAAE,yBAAyB,CAAC,OAAO,CAAC,EAAE,CAAC;IAC3D,wBAAwB,EAAE,wBAAwB,CAAC,OAAO,CAAC,EAAE,CAAC;IAC9D,yBAAyB,EAAE,yBAAyB,CAAC,OAAO,CAAC,EAAE,CAAC;CACjE;AAED;;;GAGG;AACH,oBAAY,SAAS;IACnB,KAAK,UAAuB;IAC5B,IAAI,SAAuB;IAC3B,WAAW,gBAAuB;IAClC,QAAQ,aAAuB;IAC/B,KAAK,UAAuB;IAC5B,WAAW,gBAAuB;IAClC,gBAAgB,uBAAyB;IACzC,KAAK,UAAuB;CAC7B;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAG,MAAM,EAAE,EACtD,YAAY,GACb,EAAE;IACD,YAAY,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;CACrC,GAAG,OAAO,CAUV;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAG,MAAM,EAAE,EACnD,KAAK,GACN,EAAG;IACF,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;CAC1B,aA8CA;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,EACE,KAAK,EACL,YAAY,EACZ,mBAAmB,GACpB,EAAC;IACA,KAAK,EAAE,QAAQ,CAAC;IAChB,YAAY,EAAE,YAAY,CAAC;IAC3B,mBAAmB,CAAC,EAAE,uBAAuB,EAAE,CAAC;CACjD,GACA,YAAY,CAqRd"}
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { each, filter, find, map, pickBy, uniq } from 'lodash-es';
|
|
2
|
+
/**
|
|
3
|
+
* The type of order which is deduced based on line action types present
|
|
4
|
+
* and possibly other characteristics
|
|
5
|
+
*/
|
|
6
|
+
export var OrderMode;
|
|
7
|
+
(function (OrderMode) {
|
|
8
|
+
OrderMode["empty"] = "EMPTY";
|
|
9
|
+
OrderMode["sale"] = "SALE";
|
|
10
|
+
OrderMode["reservation"] = "RESERVATION";
|
|
11
|
+
OrderMode["delivery"] = "DELIVERY";
|
|
12
|
+
OrderMode["order"] = "ORDER";
|
|
13
|
+
OrderMode["interbranch"] = "INTERBRANCH";
|
|
14
|
+
OrderMode["returnToSupplier"] = "RETURN_TO_SUPPLIER";
|
|
15
|
+
OrderMode["mixed"] = "MIXED";
|
|
16
|
+
})(OrderMode || (OrderMode = {}));
|
|
17
|
+
/**
|
|
18
|
+
* Helper method to determine if an order has product with product requirements
|
|
19
|
+
* based on the getRequiredDataForOrder response
|
|
20
|
+
*/
|
|
21
|
+
export function hasProductRequirement({ requiredData, }) {
|
|
22
|
+
const orderLineRequirements = requiredData.OrderLines;
|
|
23
|
+
const hasProductRequirement = !!find(orderLineRequirements, (orderLineRequirementsForOrderLine) => {
|
|
24
|
+
return !!find(orderLineRequirementsForOrderLine, { Name: 'ProductRequirement' });
|
|
25
|
+
});
|
|
26
|
+
return hasProductRequirement;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Helper method to determine the current order mode
|
|
30
|
+
*/
|
|
31
|
+
export function determineOrderMode({ order, }) {
|
|
32
|
+
// Collect the cart order line types currently in use
|
|
33
|
+
//
|
|
34
|
+
// None = 0,
|
|
35
|
+
// ReserveLine = 1,
|
|
36
|
+
// OrderLine = 2,
|
|
37
|
+
// ShipLine = 3,
|
|
38
|
+
// Delivery = 4,
|
|
39
|
+
//
|
|
40
|
+
// The None type will be omitted
|
|
41
|
+
//
|
|
42
|
+
const activeLines = filter(order.Lines, (line) => !line.IsCancelled);
|
|
43
|
+
const lineActionTypesInCart = uniq(filter(map(activeLines, 'LineActionType'), (lineActionType) => lineActionType !== 0));
|
|
44
|
+
// Determine the order mode
|
|
45
|
+
//
|
|
46
|
+
const orderCharacteristics = order.Characteristics ?? 0;
|
|
47
|
+
if ((orderCharacteristics & 4) !== 0) {
|
|
48
|
+
return OrderMode.interbranch;
|
|
49
|
+
}
|
|
50
|
+
if ((orderCharacteristics & 128) !== 0) {
|
|
51
|
+
return OrderMode.returnToSupplier;
|
|
52
|
+
}
|
|
53
|
+
if (lineActionTypesInCart.length === 1 && lineActionTypesInCart[0] === 1) {
|
|
54
|
+
return OrderMode.reservation;
|
|
55
|
+
}
|
|
56
|
+
if (lineActionTypesInCart.length === 1 && lineActionTypesInCart[0] === 2) {
|
|
57
|
+
return OrderMode.order;
|
|
58
|
+
}
|
|
59
|
+
if (lineActionTypesInCart.length === 1 && lineActionTypesInCart[0] === 3) {
|
|
60
|
+
return OrderMode.sale;
|
|
61
|
+
}
|
|
62
|
+
if (lineActionTypesInCart.length === 1 && lineActionTypesInCart[0] === 4) {
|
|
63
|
+
return OrderMode.delivery;
|
|
64
|
+
}
|
|
65
|
+
if (lineActionTypesInCart.length > 1) {
|
|
66
|
+
return OrderMode.mixed;
|
|
67
|
+
}
|
|
68
|
+
return OrderMode.empty;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Helper method to calculate the current order (checkout) status based
|
|
72
|
+
* on the order and required data response
|
|
73
|
+
*/
|
|
74
|
+
export function determineOrderStatus({ order, requiredData, productRequirements, }) {
|
|
75
|
+
const orderLines = order.Lines ?? [];
|
|
76
|
+
// Find all the current issues from the required data response
|
|
77
|
+
//
|
|
78
|
+
const customerRequirements = requiredData.Customer;
|
|
79
|
+
const customerIssues = filter(customerRequirements, { IsValid: false });
|
|
80
|
+
const orderRequirements = requiredData.Order;
|
|
81
|
+
const orderIssues = filter(orderRequirements, { IsValid: false });
|
|
82
|
+
const orderLineRequirements = requiredData.OrderLines;
|
|
83
|
+
const orderLineIssues = pickBy(orderLineRequirements, (orderLineRequirements) => {
|
|
84
|
+
return !!find(orderLineRequirements, { IsValid: false });
|
|
85
|
+
});
|
|
86
|
+
const invalidOrderLineIDs = map(Object.keys(orderLineIssues));
|
|
87
|
+
// We will provide some helpers to deal with specific requirements
|
|
88
|
+
// for bundles, serial numbers and product with required fields
|
|
89
|
+
//
|
|
90
|
+
const bundleProducts = [];
|
|
91
|
+
const pickDiscountProducts = [];
|
|
92
|
+
const productsWithRequirements = [];
|
|
93
|
+
const productsWithSerialNumbers = [];
|
|
94
|
+
each(orderLineRequirements, (orderLineRequirementsForOrderLine, orderLineID) => {
|
|
95
|
+
each(orderLineRequirementsForOrderLine, (orderLineRequirement) => {
|
|
96
|
+
switch (orderLineRequirement.Name) {
|
|
97
|
+
case 'CompleteProductBundle':
|
|
98
|
+
{
|
|
99
|
+
const bundleProductSubProducts = filter(orderLines, orderLine => `${orderLine.ParentID}` === `${orderLineID}`);
|
|
100
|
+
bundleProducts.push({
|
|
101
|
+
orderLineID: orderLineID,
|
|
102
|
+
requirement: orderLineRequirement,
|
|
103
|
+
valid: orderLineRequirement.IsValid,
|
|
104
|
+
productLineIDs: map(bundleProductSubProducts, 'ID'),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
case 'ProductRequirement':
|
|
109
|
+
{
|
|
110
|
+
const productRequirementsForOrderLine = find(productRequirements, { OrderLineID: orderLineID });
|
|
111
|
+
productsWithRequirements.push({
|
|
112
|
+
orderLineID: orderLineID,
|
|
113
|
+
requirement: orderLineRequirement,
|
|
114
|
+
valid: orderLineRequirement.IsValid,
|
|
115
|
+
values: productRequirementsForOrderLine?.RequirementModels || [],
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
break;
|
|
119
|
+
case 'SerialNumber':
|
|
120
|
+
{
|
|
121
|
+
const productWithSerialNumber = find(orderLines, orderLine => `${orderLine.ID}` === `${orderLineID}`);
|
|
122
|
+
productsWithSerialNumbers.push({
|
|
123
|
+
orderLineID: orderLineID,
|
|
124
|
+
requirement: orderLineRequirement,
|
|
125
|
+
valid: orderLineRequirement.IsValid,
|
|
126
|
+
serialNumber: productWithSerialNumber?.SerialNumber,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
case 'PickDiscountProduct':
|
|
131
|
+
{
|
|
132
|
+
// The relation between the discount line and the products picked
|
|
133
|
+
// for the discount is that the discount has the product line as its parent
|
|
134
|
+
//
|
|
135
|
+
const discountLine = find(orderLines, orderLine => `${orderLine.ID}` === `${orderLineID}`);
|
|
136
|
+
const pickedDiscountProducts = filter(orderLines, orderLine => `${orderLine.ID}` === `${discountLine?.ParentID}`);
|
|
137
|
+
pickDiscountProducts.push({
|
|
138
|
+
orderLineID: orderLineID,
|
|
139
|
+
requirement: orderLineRequirement,
|
|
140
|
+
valid: orderLineRequirement.IsValid,
|
|
141
|
+
pickedProductLineIDs: map(pickedDiscountProducts, 'ID'),
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
// Default step status when no information is available
|
|
149
|
+
//
|
|
150
|
+
const orderMode = determineOrderMode({ order });
|
|
151
|
+
const lineActionTypes = uniq(filter(map(order.Lines, 'LineActionType'), (lineActionType) => lineActionType !== 0));
|
|
152
|
+
const status = {
|
|
153
|
+
orderMode,
|
|
154
|
+
lineActionTypes,
|
|
155
|
+
bundleProducts,
|
|
156
|
+
pickDiscountProducts,
|
|
157
|
+
productsWithRequirements,
|
|
158
|
+
productsWithSerialNumbers,
|
|
159
|
+
issues: {
|
|
160
|
+
invalidOrderLineIDs,
|
|
161
|
+
customer: customerIssues,
|
|
162
|
+
order: orderIssues,
|
|
163
|
+
orderLine: orderLineIssues,
|
|
164
|
+
},
|
|
165
|
+
checkoutSteps: {
|
|
166
|
+
attachCustomer: {
|
|
167
|
+
valid: true,
|
|
168
|
+
possible: false,
|
|
169
|
+
required: false,
|
|
170
|
+
},
|
|
171
|
+
createOrder: {
|
|
172
|
+
valid: true,
|
|
173
|
+
possible: false,
|
|
174
|
+
required: false,
|
|
175
|
+
},
|
|
176
|
+
payment: {
|
|
177
|
+
valid: true,
|
|
178
|
+
possible: false,
|
|
179
|
+
required: false,
|
|
180
|
+
},
|
|
181
|
+
placeOrder: {
|
|
182
|
+
valid: true,
|
|
183
|
+
possible: false,
|
|
184
|
+
required: false,
|
|
185
|
+
},
|
|
186
|
+
shipOrder: {
|
|
187
|
+
valid: true,
|
|
188
|
+
possible: false,
|
|
189
|
+
required: false,
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
//////////////////////////////////////////////////////////////////////
|
|
194
|
+
// Step: attachCustomer (order level requirement)
|
|
195
|
+
//////////////////////////////////////////////////////////////////////
|
|
196
|
+
//
|
|
197
|
+
const attachCustomerOrderRequirement = find(orderRequirements, { Name: 'Customer' });
|
|
198
|
+
if (attachCustomerOrderRequirement) {
|
|
199
|
+
status.checkoutSteps.attachCustomer = {
|
|
200
|
+
possible: true,
|
|
201
|
+
required: true,
|
|
202
|
+
valid: attachCustomerOrderRequirement.IsValid && customerIssues.length === 0,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
//////////////////////////////////////////////////////////////////////
|
|
206
|
+
// Step: createOrder (order level requirement)
|
|
207
|
+
//////////////////////////////////////////////////////////////////////
|
|
208
|
+
//
|
|
209
|
+
// This is fulfilled by calling `PrepareOrderForCheckout`
|
|
210
|
+
const createOrderRequirement = find(orderRequirements, { Name: 'CreateOrder' });
|
|
211
|
+
if (createOrderRequirement) {
|
|
212
|
+
status.checkoutSteps.createOrder = {
|
|
213
|
+
possible: true,
|
|
214
|
+
required: !createOrderRequirement.IsValid,
|
|
215
|
+
valid: createOrderRequirement.IsValid,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
//////////////////////////////////////////////////////////////////////
|
|
219
|
+
// Step: payOrder (all levels based on required for)
|
|
220
|
+
//////////////////////////////////////////////////////////////////////
|
|
221
|
+
//
|
|
222
|
+
// Check current issues to determine if possible
|
|
223
|
+
//
|
|
224
|
+
// PlaceOrder = 1,
|
|
225
|
+
// Payment = 2,
|
|
226
|
+
// Ship = 4,
|
|
227
|
+
// Invoice = 8,
|
|
228
|
+
// All = 15,
|
|
229
|
+
//
|
|
230
|
+
const payOrderRequirement = find(orderRequirements, { Name: 'PayOrder' });
|
|
231
|
+
if (payOrderRequirement) {
|
|
232
|
+
const noCustomerIssues = !find(customerIssues, issue => (issue.RequiredFor & 2) === 2);
|
|
233
|
+
const noOrderIssues = !find(orderIssues, issue => (issue.RequiredFor & 2) === 2);
|
|
234
|
+
const noOrderLineIssues = !find(orderLineIssues, (lineIssues) => {
|
|
235
|
+
return !!find(lineIssues, issue => !issue.IsValid && (issue.RequiredFor & 2) === 2);
|
|
236
|
+
});
|
|
237
|
+
/** If its a delivery order, payment is not required */
|
|
238
|
+
const isDeliverMode = orderMode === OrderMode.delivery;
|
|
239
|
+
/** If its an order, payment is not required */
|
|
240
|
+
const isOrderMode = orderMode === OrderMode.order;
|
|
241
|
+
/** If its a reservation order, payment is not required */
|
|
242
|
+
const isReservationMode = orderMode === OrderMode.reservation;
|
|
243
|
+
const payOrderStepRequired = !isDeliverMode && !isOrderMode && !isReservationMode;
|
|
244
|
+
status.checkoutSteps.payment = {
|
|
245
|
+
possible: noCustomerIssues && noOrderIssues && noOrderLineIssues,
|
|
246
|
+
required: payOrderStepRequired,
|
|
247
|
+
valid: payOrderRequirement.IsValid,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
//////////////////////////////////////////////////////////////////////
|
|
251
|
+
// Step: placeOrder (all levels based on required for)
|
|
252
|
+
//////////////////////////////////////////////////////////////////////
|
|
253
|
+
//
|
|
254
|
+
// Check current issues to determine if possible
|
|
255
|
+
//
|
|
256
|
+
// PlaceOrder = 1,
|
|
257
|
+
// Payment = 2,
|
|
258
|
+
// Ship = 4,
|
|
259
|
+
// Invoice = 8,
|
|
260
|
+
// All = 15,
|
|
261
|
+
//
|
|
262
|
+
const placeOrderRequirement = find(orderRequirements, { Name: 'PlaceOrder' });
|
|
263
|
+
if (placeOrderRequirement) {
|
|
264
|
+
// For place order we need to exclude the `PlaceOrder` requirement itself
|
|
265
|
+
// The RequiredFor level for the `PlaceOrder` was ship (4) in the past but it
|
|
266
|
+
// has been lowered to place (1) due to a placement flow interaction with
|
|
267
|
+
// RMA orders
|
|
268
|
+
//
|
|
269
|
+
const noCustomerIssues = !find(customerIssues, issue => (issue.RequiredFor & 1) === 1);
|
|
270
|
+
const noOrderIssues = !find(orderIssues, issue => (issue.RequiredFor & 1) === 1 && issue.Name !== 'PlaceOrder');
|
|
271
|
+
const noOrderIssuesAfterPayment = !find(orderIssues, issue => (issue.RequiredFor & 1) === 1 && issue.Name !== 'PlaceOrder' && issue.Name !== 'PayOrder');
|
|
272
|
+
const noOrderLineIssues = !find(orderLineIssues, (lineIssues) => {
|
|
273
|
+
return !!find(lineIssues, issue => !issue.IsValid && (issue.RequiredFor & 1) === 1);
|
|
274
|
+
});
|
|
275
|
+
status.checkoutSteps.placeOrder = {
|
|
276
|
+
possible: noCustomerIssues && noOrderIssues && noOrderLineIssues,
|
|
277
|
+
required: true,
|
|
278
|
+
valid: placeOrderRequirement.IsValid,
|
|
279
|
+
possibleAfterPayment: noCustomerIssues && noOrderIssuesAfterPayment && noOrderLineIssues,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
//////////////////////////////////////////////////////////////////////
|
|
283
|
+
// Step: ShipOrder (all levels based on required for and order content)
|
|
284
|
+
//////////////////////////////////////////////////////////////////////
|
|
285
|
+
//
|
|
286
|
+
// There is no 'ShipOrder' requirement but if any lines are of type ship
|
|
287
|
+
// then the order should be shipped
|
|
288
|
+
// The IsShipped property on the order indicates completion
|
|
289
|
+
//
|
|
290
|
+
// The presence of RestrictedShippingAddress on either order or order line
|
|
291
|
+
// makes the order un-shippable
|
|
292
|
+
//
|
|
293
|
+
// Check current issues to determine if possible
|
|
294
|
+
// Possible needs to start as true for this logic to work
|
|
295
|
+
//
|
|
296
|
+
// PlaceOrder = 1,
|
|
297
|
+
// Payment = 2,
|
|
298
|
+
// Ship = 4,
|
|
299
|
+
// Invoice = 8,
|
|
300
|
+
// All = 15,
|
|
301
|
+
//
|
|
302
|
+
// For orders with only LineActionType 0 we want to call the shipOrder method.
|
|
303
|
+
// This was added for the returning of fashion cheques flow in the POS
|
|
304
|
+
//
|
|
305
|
+
const onlyHasLineActionTypeZero = filter(map(order.Lines, 'LineActionType'), (lineActionType) => lineActionType === 0).length > 0;
|
|
306
|
+
const hasShippingLines = !!find(orderLines, { LineActionType: 3 });
|
|
307
|
+
if (hasShippingLines || onlyHasLineActionTypeZero) {
|
|
308
|
+
const noCustomerIssues = !find(customerIssues, issue => (issue.RequiredFor & 4) === 4);
|
|
309
|
+
const noOrderIssues = !find(orderIssues, issue => (issue.RequiredFor & 4) === 4);
|
|
310
|
+
const noOrderLineIssues = !find(orderLineIssues, (lineIssues, orderLineID) => {
|
|
311
|
+
// Check the order line is of type ship (3)
|
|
312
|
+
//
|
|
313
|
+
const issueLine = find(orderLines, orderLine => `${orderLine.ID}` === `${orderLineID}`);
|
|
314
|
+
return issueLine?.LineActionType === 3 && !!find(lineIssues, issue => !issue.IsValid && (issue.RequiredFor & 4) === 4);
|
|
315
|
+
});
|
|
316
|
+
const orderRestrictedForShipping = !!find(orderIssues, { Name: 'RestrictedShippingAddress' });
|
|
317
|
+
const orderLineRestrictedForShipping = find(orderLineIssues, lineIssues => !!find(lineIssues, { Name: 'RestrictedShippingAddress' }));
|
|
318
|
+
status.checkoutSteps.shipOrder = {
|
|
319
|
+
possible: noCustomerIssues && noOrderIssues && noOrderLineIssues,
|
|
320
|
+
required: true,
|
|
321
|
+
valid: !orderRestrictedForShipping && !orderLineRestrictedForShipping && !!order.IsShipped,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
return status;
|
|
325
|
+
}
|
|
326
|
+
//# sourceMappingURL=order-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-status.js","sourceRoot":"","sources":["../src/order-status.ts"],"names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K,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QACzH,CAAC,CAAC,CAAC;QAEH,MAAM,0BAA0B,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,2BAA2B,EAAE,CAAC,CAAC;QAC9F,MAAM,8BAA8B,GAAG,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,2BAA2B,EAAE,CAAC,CAAC,CAAC;QAEtI,MAAM,CAAC,aAAa,CAAC,SAAS,GAAG;YAC/B,QAAQ,EAAE,gBAAgB,IAAI,aAAa,IAAI,iBAAiB;YAChE,QAAQ,EAAE,IAAI;YACd,KAAK,EAAK,CAAC,0BAA0B,IAAI,CAAC,8BAA8B,IAAI,CAAC,CAAC,KAAK,CAAC,SAAS;SAC9F,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EvaContext } from '@springtree/eva-sdk-core-service';
|
|
2
|
+
import { EvaOrder } from './order.js';
|
|
3
|
+
export declare class EvaOrderManager {
|
|
4
|
+
private context;
|
|
5
|
+
constructor({ context }: {
|
|
6
|
+
context: EvaContext;
|
|
7
|
+
});
|
|
8
|
+
getOrder({ orderId }: {
|
|
9
|
+
orderId: string;
|
|
10
|
+
}): Promise<EvaOrder>;
|
|
11
|
+
startNewOrder(): Promise<EvaOrder>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=order-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-manager.d.ts","sourceRoot":"","sources":["../../src/orders/order-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAStC,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAa;gBAEf,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,UAAU,CAAA;KAAE;IAOpC,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE;IAezC,aAAa;CAI3B"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { logger } from '@springtree/eva-sdk-core-logger';
|
|
2
|
+
import { EvaOrder } from './order.js';
|
|
3
|
+
// This class ben be used to
|
|
4
|
+
//
|
|
5
|
+
// * create new orders (also known as shopping carts)
|
|
6
|
+
// * fetch an exiting order
|
|
7
|
+
//
|
|
8
|
+
// The returned EvaOrder instance provides methods to perform operations on the order
|
|
9
|
+
//
|
|
10
|
+
export class EvaOrderManager {
|
|
11
|
+
context;
|
|
12
|
+
constructor({ context }) {
|
|
13
|
+
this.context = context;
|
|
14
|
+
}
|
|
15
|
+
// Retrieves an existing order from EVA
|
|
16
|
+
//
|
|
17
|
+
async getOrder({ orderId }) {
|
|
18
|
+
const order = new EvaOrder({ context: this.context, orderId });
|
|
19
|
+
try {
|
|
20
|
+
await order.updateOrder();
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
logger.error(`Error fetching order ${orderId}`, error);
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
return order;
|
|
27
|
+
}
|
|
28
|
+
// Creates a new empty order
|
|
29
|
+
// The order will be created on the EVA context provided
|
|
30
|
+
// Until an order operation is performed the order will not be actually created
|
|
31
|
+
//
|
|
32
|
+
async startNewOrder() {
|
|
33
|
+
const order = new EvaOrder({ context: this.context });
|
|
34
|
+
return order;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=order-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-manager.js","sourceRoot":"","sources":["../../src/orders/order-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,4BAA4B;AAC5B,EAAE;AACF,qDAAqD;AACrD,2BAA2B;AAC3B,EAAE;AACF,qFAAqF;AACrF,EAAE;AACF,MAAM,OAAO,eAAe;IAClB,OAAO,CAAa;IAE5B,YAAa,EAAE,OAAO,EAA2B;QAE/C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,uCAAuC;IACvC,EAAE;IACK,KAAK,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAuB;QACpD,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QAC/D,IAAI,CAAC;YACH,MAAM,KAAK,CAAC,WAAW,EAAE,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,wBAAwB,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;YACvD,MAAM,KAAK,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,4BAA4B;IAC5B,wDAAwD;IACxD,+EAA+E;IAC/E,EAAE;IACK,KAAK,CAAC,aAAa;QACxB,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QACtD,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IEvaServiceCallOptions } from "@springtree/eva-sdk-core-service";
|
|
2
|
+
import { IEvaServiceDefinition, SvcAddBundleProductToOrder, SvcAddDiscountCouponToOrder, SvcAddManualDiscountToOrder, SvcAddProductToOrder, SvcAddServiceProductToOrder, SvcAddUserBorrowedProductToOrder, SvcAttachCustomerToOrder, SvcCancelDiscountOrderLine, SvcCancelOrder, SvcChangeOrderLinesToCarryOut, SvcChangeOrderLinesToDelivery, SvcChangeOrderLinesToPickup, SvcCreateCustomer, SvcCreateOrderLineUnitPriceCorrection, SvcDetachCustomerFromOrder, SvcLogin, SvcModifyOrderLinePrice, SvcModifyQuantityOrdered, SvcPlaceOrder, SvcPrepareOrderForCheckout, SvcRemoveOrderLineUnitPriceCorrection, SvcSetCustomerIdentifiersOnOrder, SvcSetGiftWrappingOptionsOnOrder, SvcSetPickProductDiscountOptionsForOrderLine, SvcSetRemarkOnOrder, SvcSetRequestedDate, SvcShipOrder, SvcSplitOrderLine, SvcUpdateOrderBillingAddress, SvcUpdateOrderCustomFields, SvcUpdateOrderShippingAddress, SvcUpdateProductRequirementValuesForOrderLine, SvcUpdateSerialNumber } from "@springtree/eva-services-core";
|
|
3
|
+
export type TAddToOrderServices = SvcAddBundleProductToOrder | SvcAddDiscountCouponToOrder | SvcAddManualDiscountToOrder | SvcAddProductToOrder | SvcAddServiceProductToOrder | SvcAddUserBorrowedProductToOrder | SvcAttachCustomerToOrder | SvcSetCustomerIdentifiersOnOrder;
|
|
4
|
+
export type TModifyOrderServices = SvcCancelDiscountOrderLine | SvcCancelOrder | SvcChangeOrderLinesToCarryOut | SvcChangeOrderLinesToDelivery | SvcChangeOrderLinesToPickup | SvcCreateCustomer | SvcCreateOrderLineUnitPriceCorrection | SvcDetachCustomerFromOrder | SvcPlaceOrder | SvcLogin | SvcModifyOrderLinePrice | SvcModifyQuantityOrdered | SvcPrepareOrderForCheckout | SvcRemoveOrderLineUnitPriceCorrection | SvcUpdateOrderCustomFields | SvcSetGiftWrappingOptionsOnOrder | SvcSetPickProductDiscountOptionsForOrderLine | SvcSetRequestedDate | SvcSetRemarkOnOrder | SvcShipOrder | SvcSplitOrderLine | SvcUpdateOrderBillingAddress | SvcUpdateOrderCustomFields | SvcUpdateOrderShippingAddress | SvcUpdateProductRequirementValuesForOrderLine | SvcUpdateSerialNumber | SvcSetCustomerIdentifiersOnOrder;
|
|
5
|
+
export interface IAddToOrderOperation<SVC extends IEvaServiceDefinition = TAddToOrderServices> {
|
|
6
|
+
payload: Omit<SVC['request'], 'OrderID' | 'TargetOrderID'>;
|
|
7
|
+
service: new () => SVC;
|
|
8
|
+
serviceOptions?: IEvaServiceCallOptions;
|
|
9
|
+
skipOrderUpdate?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface IModifyOrderOperation<SVC extends IEvaServiceDefinition = TModifyOrderServices> {
|
|
12
|
+
payload: Omit<SVC['request'], 'OrderID' | 'TargetOrderID'>;
|
|
13
|
+
service: new () => SVC;
|
|
14
|
+
serviceOptions?: IEvaServiceCallOptions;
|
|
15
|
+
skipOrderUpdate?: boolean;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=order-operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-operations.d.ts","sourceRoot":"","sources":["../../src/orders/order-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,0BAA0B,EACxD,2BAA2B,EAC3B,2BAA2B,EAC3B,oBAAoB,EACpB,2BAA2B,EAC3B,gCAAgC,EAChC,wBAAwB,EACxB,0BAA0B,EAC1B,cAAc,EACd,6BAA6B,EAC7B,6BAA6B,EAC7B,2BAA2B,EAC3B,iBAAiB,EACjB,qCAAqC,EACrC,0BAA0B,EAC1B,QAAQ,EACR,uBAAuB,EACvB,wBAAwB,EACxB,aAAa,EACb,0BAA0B,EAC1B,qCAAqC,EACrC,gCAAgC,EAChC,gCAAgC,EAChC,4CAA4C,EAC5C,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,iBAAiB,EACjB,4BAA4B,EAC5B,0BAA0B,EAC1B,6BAA6B,EAC7B,6CAA6C,EAC7C,qBAAqB,EACtB,MAAM,+BAA+B,CAAC;AAEvC,MAAM,MAAM,mBAAmB,GAC3B,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@@
|
|
|
1
|
+
import { EvaContext, IEvaServiceCallOptions } from '@springtree/eva-sdk-core-service';
|
|
2
|
+
import { DataModelsOrderTypes, IEvaServiceDefinition, OrdersAdditionalOrderData, OrdersOpenOrderAmounts, ResponseMessageMetadata } from '@springtree/eva-services-core';
|
|
3
|
+
import { OrdersDtoOrderDto } from '@springtree/eva-services-core';
|
|
4
|
+
import { IAddToOrderOperation, IModifyOrderOperation, TAddToOrderServices, TModifyOrderServices } from './order-operations.js';
|
|
5
|
+
export interface IOrderData {
|
|
6
|
+
additionalOrderData?: OrdersAdditionalOrderData;
|
|
7
|
+
amounts?: OrdersOpenOrderAmounts;
|
|
8
|
+
metadata?: ResponseMessageMetadata;
|
|
9
|
+
order?: OrdersDtoOrderDto;
|
|
10
|
+
}
|
|
11
|
+
export declare class EvaOrder {
|
|
12
|
+
private context;
|
|
13
|
+
private orderId?;
|
|
14
|
+
private newOrderType;
|
|
15
|
+
private _orderData$;
|
|
16
|
+
get orderData(): IOrderData | undefined;
|
|
17
|
+
get orderData$(): import("rxjs").Observable<IOrderData | undefined>;
|
|
18
|
+
private _orderService;
|
|
19
|
+
constructor({ context, newOrderType, orderId }: {
|
|
20
|
+
context: EvaContext;
|
|
21
|
+
newOrderType?: DataModelsOrderTypes;
|
|
22
|
+
orderId?: string;
|
|
23
|
+
});
|
|
24
|
+
updateOrder(params?: {
|
|
25
|
+
serviceCallOptions?: IEvaServiceCallOptions;
|
|
26
|
+
}): Promise<IOrderData | undefined>;
|
|
27
|
+
addToOrder<SVC extends IEvaServiceDefinition = TAddToOrderServices>(params: IAddToOrderOperation<SVC>): Promise<SVC['response']>;
|
|
28
|
+
modifyOrder<SVC extends IEvaServiceDefinition = TModifyOrderServices>(params: IModifyOrderOperation<SVC>): Promise<SVC['response']>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=order.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../src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E,MAAM,EAAE,qBAAqB,CAAC,GAAG,CAAC,GACjC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;CA8D5B"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { logger } from '@springtree/eva-sdk-core-logger';
|
|
2
|
+
import { DataModelsOrderTypes, SvcCreateOrder, SvcGetOrder, SvcGetShoppingCart } from '@springtree/eva-services-core';
|
|
3
|
+
import { dequal } from 'dequal';
|
|
4
|
+
import { v4 } from 'uuid';
|
|
5
|
+
import { BehaviorSubject } from 'rxjs';
|
|
6
|
+
import { getCoreServiceExtensionsSettings } from '../settings.js';
|
|
7
|
+
// This class ben be used to
|
|
8
|
+
//
|
|
9
|
+
// * create new orders (also known as shopping carts)
|
|
10
|
+
// * fetch an exiting order
|
|
11
|
+
// * perform operations on an order (add/modify)
|
|
12
|
+
// * determine the status of an order
|
|
13
|
+
// * listen for order updates
|
|
14
|
+
//
|
|
15
|
+
// An EvaContext needs to be provided where the order lives
|
|
16
|
+
// Optionally an OrganizationUnitHub can be provided to
|
|
17
|
+
// listen for external updates. If not provided the order will be updated
|
|
18
|
+
// after each operation
|
|
19
|
+
//
|
|
20
|
+
export class EvaOrder {
|
|
21
|
+
context;
|
|
22
|
+
orderId;
|
|
23
|
+
newOrderType;
|
|
24
|
+
_orderData$ = new BehaviorSubject(undefined);
|
|
25
|
+
get orderData() {
|
|
26
|
+
return structuredClone(this._orderData$.getValue());
|
|
27
|
+
}
|
|
28
|
+
get orderData$() {
|
|
29
|
+
return this._orderData$.asObservable();
|
|
30
|
+
}
|
|
31
|
+
// The current service to use for fetching/updated the order details
|
|
32
|
+
// The GetOrder service is used for existing orders and is faster
|
|
33
|
+
// If an order is still being actively modified the GetShoppingCart service should be used
|
|
34
|
+
//
|
|
35
|
+
_orderService = 'order';
|
|
36
|
+
constructor({ context, newOrderType, orderId }) {
|
|
37
|
+
this.context = context;
|
|
38
|
+
this.newOrderType = newOrderType ?? DataModelsOrderTypes.Sales;
|
|
39
|
+
this.orderId = orderId;
|
|
40
|
+
}
|
|
41
|
+
// Updates the order data
|
|
42
|
+
//
|
|
43
|
+
async updateOrder(params) {
|
|
44
|
+
if (this.orderId) {
|
|
45
|
+
const orderId = this.orderId;
|
|
46
|
+
const settings = getCoreServiceExtensionsSettings();
|
|
47
|
+
let newOrderData;
|
|
48
|
+
if (this._orderService === 'shopping-cart') {
|
|
49
|
+
const response = await this.context.callService(SvcGetShoppingCart, { OrderID: orderId, AdditionalOrderDataOptions: settings.shoppingCartOptions, IncludeAllPayments: true }, params?.serviceCallOptions);
|
|
50
|
+
newOrderData = {
|
|
51
|
+
additionalOrderData: response?.AdditionalOrderData,
|
|
52
|
+
amounts: response?.Amounts,
|
|
53
|
+
metadata: response?.Metadata,
|
|
54
|
+
order: response?.ShoppingCart,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const response = await this.context.callService(SvcGetOrder, { OrderID: orderId, AdditionalOrderDataOptions: settings.currentOrderOptions, IncludeAllPayments: true }, params?.serviceCallOptions);
|
|
59
|
+
newOrderData = {
|
|
60
|
+
additionalOrderData: response?.AdditionalOrderData,
|
|
61
|
+
amounts: response?.Amounts,
|
|
62
|
+
metadata: response?.Metadata,
|
|
63
|
+
order: response?.Result,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
// Only emit on change
|
|
67
|
+
//
|
|
68
|
+
if (!dequal(this._orderData$.getValue(), newOrderData)) {
|
|
69
|
+
this.orderId = newOrderData?.order?.ID ?? this.orderId;
|
|
70
|
+
this._orderData$.next(newOrderData);
|
|
71
|
+
}
|
|
72
|
+
return newOrderData;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Perform an operation on the order which will add or set
|
|
76
|
+
// new details of the order. If no current order exists one will be created
|
|
77
|
+
//
|
|
78
|
+
async addToOrder(params) {
|
|
79
|
+
const currentOrderData = this._orderData$.getValue();
|
|
80
|
+
let orderId = currentOrderData?.order?.ID;
|
|
81
|
+
if (currentOrderData?.order?.IsCompleted) {
|
|
82
|
+
throw new Error(`Order ${orderId} is in a completed state and cannot be modified`);
|
|
83
|
+
}
|
|
84
|
+
const { payload, service, serviceOptions } = params;
|
|
85
|
+
// Create the new order first if needed
|
|
86
|
+
//
|
|
87
|
+
if (!orderId) {
|
|
88
|
+
const createdOrder = await this.context.callService(SvcCreateOrder, { Type: this.newOrderType, ClientOrderID: v4() }, serviceOptions);
|
|
89
|
+
orderId = createdOrder?.OrderID;
|
|
90
|
+
// This really should not be possible but throwing an error to be sure
|
|
91
|
+
//
|
|
92
|
+
if (!orderId) {
|
|
93
|
+
throw new Error(`Failed to create new order`);
|
|
94
|
+
}
|
|
95
|
+
logger.debug(`Created new order ${orderId}`);
|
|
96
|
+
this.orderId = orderId;
|
|
97
|
+
}
|
|
98
|
+
// Ensure we are in shopping cart mode now that we are modifying the order
|
|
99
|
+
//
|
|
100
|
+
this._orderService = 'shopping-cart';
|
|
101
|
+
// Add the order id to the payload
|
|
102
|
+
//
|
|
103
|
+
const requestPayload = {
|
|
104
|
+
...payload,
|
|
105
|
+
};
|
|
106
|
+
requestPayload.OrderID = orderId;
|
|
107
|
+
const response = await this.context.callService(service, requestPayload, serviceOptions);
|
|
108
|
+
if (params.skipOrderUpdate !== true) {
|
|
109
|
+
await this.updateOrder();
|
|
110
|
+
}
|
|
111
|
+
return response;
|
|
112
|
+
}
|
|
113
|
+
async modifyOrder(params) {
|
|
114
|
+
const currentOrderData = this._orderData$.getValue();
|
|
115
|
+
const orderId = currentOrderData?.order?.ID;
|
|
116
|
+
if (!orderId) {
|
|
117
|
+
throw new Error(`There is no current order to modify. Please create one using addToOrder(...) first`);
|
|
118
|
+
}
|
|
119
|
+
if (currentOrderData?.order?.IsCompleted) {
|
|
120
|
+
throw new Error(`Order ${orderId} is in a completed state and cannot be modified`);
|
|
121
|
+
}
|
|
122
|
+
const { payload, service, serviceOptions } = params;
|
|
123
|
+
// Ensure we are in shopping cart mode now that we are modifying the order
|
|
124
|
+
//
|
|
125
|
+
this._orderService = 'shopping-cart';
|
|
126
|
+
// Certain services require the OrderID in their payload
|
|
127
|
+
// You have to instantiate the service to get the name value
|
|
128
|
+
// Using it static only works before bundling/transpiling
|
|
129
|
+
// Learned that the hard way
|
|
130
|
+
//
|
|
131
|
+
const requestPayload = {
|
|
132
|
+
...payload,
|
|
133
|
+
};
|
|
134
|
+
const serviceName = new service().name;
|
|
135
|
+
const servicesRequiringOrderID = [
|
|
136
|
+
'AttachCustomerToOrder',
|
|
137
|
+
'CancelOrder',
|
|
138
|
+
'ChangeOrderLinesToCarryOut',
|
|
139
|
+
'ChangeOrderLinesToDelivery',
|
|
140
|
+
'ChangeOrderLinesToPickup',
|
|
141
|
+
'CreateCustomer',
|
|
142
|
+
'DetachCustomerFromOrder',
|
|
143
|
+
'PrepareOrderForCheckout',
|
|
144
|
+
'SetGiftWrappingOptionsOnOrder',
|
|
145
|
+
'SetRemarkOnOrder',
|
|
146
|
+
'UpdateOrderBillingAddress',
|
|
147
|
+
'UpdateOrderCustomFields',
|
|
148
|
+
'UpdateOrderCustomFields',
|
|
149
|
+
'UpdateOrderShippingAddress',
|
|
150
|
+
'SetCustomerIdentifiersOnOrder',
|
|
151
|
+
// These two are in core admin which is not a peer dependency
|
|
152
|
+
// for this package but it doesn't hurt to include them
|
|
153
|
+
//
|
|
154
|
+
'AttachLoyaltyProgramToOrder',
|
|
155
|
+
'DetachLoyaltyProgramFromOrder',
|
|
156
|
+
];
|
|
157
|
+
if (servicesRequiringOrderID.indexOf(serviceName) !== -1) {
|
|
158
|
+
requestPayload.OrderID = orderId;
|
|
159
|
+
}
|
|
160
|
+
const response = await this.context.callService(service, requestPayload, serviceOptions);
|
|
161
|
+
if (params.skipOrderUpdate !== true) {
|
|
162
|
+
await this.updateOrder();
|
|
163
|
+
}
|
|
164
|
+
return response;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=order.js.map
|
|
@@ -0,0 +1 @@
|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BAAyB;YACzB,yBAAyB;YACzB,+BAA+B;YAC/B,kBAAkB;YAClB,2BAA2B;YAC3B,yBAAyB;YACzB,yBAAyB;YACzB,4BAA4B;YAC5B,+BAA+B;YAE/B,6DAA6D;YAC7D,uDAAuD;YACvD,EAAE;YACF,6BAA6B;YAC7B,+BAA+B;SAChC,CAAC;QACF,IAAI,wBAAwB,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YACxD,cAAyC,CAAC,OAAO,GAAG,OAAO,CAAC;QAC/D,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAC7C,OAAO,EACP,cAAiD,EACjD,cAAc,CACf,CAAC;QACF,IAAI,MAAM,CAAC,eAAe,KAAK,IAAI,EAAE,CAAC;YACpC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QAC3B,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { OrdersDtoOrderDto as OrderDto } from "@springtree/eva-services-core";
|
|
2
|
+
/**
|
|
3
|
+
* Products counted by their type and characteristics.
|
|
4
|
+
* Products can have multiple types and characteristics so adding all the
|
|
5
|
+
* individual counts may not add up to the total count.
|
|
6
|
+
* The totalDistinct count the number products not part of another product
|
|
7
|
+
* like with a bundle.
|
|
8
|
+
* Also note this is a product count not an order line count.
|
|
9
|
+
*/
|
|
10
|
+
export interface IProductCountByType {
|
|
11
|
+
bundle: number;
|
|
12
|
+
cancelled: number;
|
|
13
|
+
configurable: number;
|
|
14
|
+
discount: number;
|
|
15
|
+
giftCard: number;
|
|
16
|
+
nonDiscount: number;
|
|
17
|
+
service: number;
|
|
18
|
+
total: number;
|
|
19
|
+
totalAbsolute: number;
|
|
20
|
+
totalDistinct: number;
|
|
21
|
+
totalDistinctAbsolute: number;
|
|
22
|
+
}
|
|
23
|
+
export declare function countOrderProductsByType<ID_TYPE = string>({ order, }: {
|
|
24
|
+
order: OrderDto<ID_TYPE> | undefined;
|
|
25
|
+
}): IProductCountByType;
|
|
26
|
+
//# sourceMappingURL=product-count-by-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-count-by-type.d.ts","sourceRoot":"","sources":["../src/product-count-by-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,IAAI,QAAQ,EAAyC,MAAM,+BAA+B,CAAC;AAErH;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IAElC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED,wBAAgB,wBAAwB,CAAC,OAAO,GAAG,MAAM,EAAE,EACzD,KAAK,GACN,EAAE;IACD,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAC,SAAS,CAAC;CACpC,uBA0DA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export function countOrderProductsByType({ order, }) {
|
|
2
|
+
const result = {
|
|
3
|
+
cancelled: 0,
|
|
4
|
+
bundle: 0,
|
|
5
|
+
configurable: 0,
|
|
6
|
+
discount: 0,
|
|
7
|
+
giftCard: 0,
|
|
8
|
+
nonDiscount: 0,
|
|
9
|
+
service: 0,
|
|
10
|
+
total: 0,
|
|
11
|
+
totalAbsolute: 0,
|
|
12
|
+
totalDistinct: 0,
|
|
13
|
+
totalDistinctAbsolute: 0,
|
|
14
|
+
};
|
|
15
|
+
const orderLines = order?.Lines ?? [];
|
|
16
|
+
orderLines.forEach((orderLine) => {
|
|
17
|
+
// We are only interested in product counts
|
|
18
|
+
//
|
|
19
|
+
if (orderLine.Product) {
|
|
20
|
+
if (orderLine.IsCancelled) {
|
|
21
|
+
result.cancelled += 1;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const totalQuantityToShip = orderLine.TotalQuantityToShip ?? 0;
|
|
25
|
+
result.total += totalQuantityToShip;
|
|
26
|
+
result.totalAbsolute += Math.abs(totalQuantityToShip);
|
|
27
|
+
if (!orderLine.ParentID) {
|
|
28
|
+
result.totalDistinct += totalQuantityToShip;
|
|
29
|
+
result.totalDistinctAbsolute += Math.abs(totalQuantityToShip);
|
|
30
|
+
}
|
|
31
|
+
const productType = orderLine.Product.Type ?? 0;
|
|
32
|
+
const isBundle = (productType & 2048) !== 0;
|
|
33
|
+
const isConfigurable = (productType & 16384) !== 0;
|
|
34
|
+
const isGiftCard = (productType & 8) !== 0;
|
|
35
|
+
const isService = (productType & 16) !== 0;
|
|
36
|
+
if (isBundle) {
|
|
37
|
+
result.bundle += 1;
|
|
38
|
+
}
|
|
39
|
+
if (isConfigurable) {
|
|
40
|
+
result.configurable += 1;
|
|
41
|
+
}
|
|
42
|
+
if (isGiftCard) {
|
|
43
|
+
result.giftCard += 1;
|
|
44
|
+
}
|
|
45
|
+
if (isService) {
|
|
46
|
+
result.service += 1;
|
|
47
|
+
}
|
|
48
|
+
// Gift products have a special custom order line type
|
|
49
|
+
//
|
|
50
|
+
if (orderLine.CustomOrderLineType === 'DISCOUNTPRODUCT') {
|
|
51
|
+
result.discount += 1;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
// Add non discount count as a convenience
|
|
57
|
+
//
|
|
58
|
+
result.nonDiscount = result.total - result.discount;
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=product-count-by-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-count-by-type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,MAAM,cAAc,GAAG,CAAC,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;gBACnD,MAAM,UAAU,GAAG,CAAC,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;gBAC3C,MAAM,SAAS,GAAG,CAAC,WAAW,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;gBAE3C,IAAI,QAAQ,EAAE,CAAC;oBAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;gBAAC,CAAC;gBACrC,IAAI,cAAc,EAAE,CAAC;oBAAC,MAAM,CAAC,YAAY,IAAI,CAAC,CAAC;gBAAC,CAAC;gBACjD,IAAI,UAAU,EAAE,CAAC;oBAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC;gBAAC,CAAC;gBACzC,IAAI,SAAS,EAAE,CAAC;oBAAC,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC;gBAAC,CAAC;gBAEvC,sDAAsD;gBACtD,EAAE;gBACF,IAAI,SAAS,CAAC,mBAAmB,KAAK,iBAAiB,EAAE,CAAC;oBACxD,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC;gBACvB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,0CAA0C;IAC1C,EAAE;IACF,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC;IAEpD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ISettingsChange } from '@springtree/eva-sdk-core-settings';
|
|
2
|
+
import { OrdersAdditionalOrderDataOptions as AdditionalOrderDataOptions } from '@springtree/eva-services-core';
|
|
3
|
+
/**
|
|
4
|
+
* The settings for the module
|
|
5
|
+
*/
|
|
6
|
+
export interface IEvaCoreServiceExtensionsSettings {
|
|
7
|
+
/**
|
|
8
|
+
* The default included product properties for services such as:
|
|
9
|
+
*
|
|
10
|
+
* - GetOrder
|
|
11
|
+
* - GetShoppingCart
|
|
12
|
+
* - SearchProducts
|
|
13
|
+
* - GetProducts
|
|
14
|
+
* - GetBundleProductDetails
|
|
15
|
+
* - ListProductBundles
|
|
16
|
+
*
|
|
17
|
+
* This is not an exhaustive list. In a service request these can be either
|
|
18
|
+
* called IncludedFields or ProductProperties.
|
|
19
|
+
*/
|
|
20
|
+
defaultProductProperties: string[];
|
|
21
|
+
/**
|
|
22
|
+
* The additional request options for the shoppingCart state.
|
|
23
|
+
* Defaults are set to retrieve the most logical data needed
|
|
24
|
+
* before entering the checkout. Discounts, product requirements, etc.
|
|
25
|
+
*/
|
|
26
|
+
shoppingCartOptions: AdditionalOrderDataOptions;
|
|
27
|
+
/**
|
|
28
|
+
* The additional request options for the currentOrder state.
|
|
29
|
+
* Defaults are set to retrieve the most logical data needed
|
|
30
|
+
* during the checkout. Shipping methods, payment methods, etc.
|
|
31
|
+
*/
|
|
32
|
+
currentOrderOptions: AdditionalOrderDataOptions;
|
|
33
|
+
}
|
|
34
|
+
export declare const defaultProductProperties: string[];
|
|
35
|
+
export declare const SETTINGS_GROUP_NAME = "evaCoreServiceExtensions";
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves the settings for the EvaCoreServiceExtensions module
|
|
38
|
+
*/
|
|
39
|
+
export declare function getCoreServiceExtensionsSettings(): IEvaCoreServiceExtensionsSettings;
|
|
40
|
+
/**
|
|
41
|
+
* Changes a setting for the EvaCoreServiceExtensions module
|
|
42
|
+
*/
|
|
43
|
+
export declare function setCoreServiceExtensionsSetting(settingName: keyof IEvaCoreServiceExtensionsSettings, setting: IEvaCoreServiceExtensionsSettings[keyof IEvaCoreServiceExtensionsSettings]): ISettingsChange;
|
|
44
|
+
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,gCAAgC,IAAI,0BAA0B,EAAwC,MAAM,+BAA+B,CAAC;AAErJ;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD;;;;;;;;;;;;OAYG;IACH,wBAAwB,EAAE,MAAM,EAAE,CAAC;IAEnC;;;;OAIG;IACH,mBAAmB,EAAE,0BAA0B,CAAC;IAEhD;;;;OAIG;IACH,mBAAmB,EAAE,0BAA0B,CAAC;CACjD;AAED,eAAO,MAAM,wBAAwB,UAuBpC,CAAC;AAIF,eAAO,MAAM,mBAAmB,6BAA6B,CAAC;AAyC9D;;GAEG;AACH,wBAAgB,gCAAgC,IAAI,iCAAiC,CAEpF;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,WAAW,EAAE,MAAM,iCAAiC,EAAE,OAAO,EAAE,iCAAiC,CAAC,MAAM,iCAAiC,CAAC,GAAG,eAAe,CAE1M"}
|
package/lib/settings.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { settings } from '@springtree/eva-sdk-core-settings';
|
|
2
|
+
import { ValidationRequiredFor as RequiredFor } from '@springtree/eva-services-core';
|
|
3
|
+
export const defaultProductProperties = [
|
|
4
|
+
'backend_id',
|
|
5
|
+
'barcodes',
|
|
6
|
+
'clothing_primary_color',
|
|
7
|
+
'clothing_size',
|
|
8
|
+
'configurable_properties',
|
|
9
|
+
'currency_id',
|
|
10
|
+
'custom_id',
|
|
11
|
+
'display_price',
|
|
12
|
+
'display_value',
|
|
13
|
+
'is_sellable',
|
|
14
|
+
'logical_level',
|
|
15
|
+
'primary_image.blob',
|
|
16
|
+
'product_description',
|
|
17
|
+
'product_id',
|
|
18
|
+
'product_media',
|
|
19
|
+
'product_name',
|
|
20
|
+
'product_requirements',
|
|
21
|
+
'product_status',
|
|
22
|
+
'product_types',
|
|
23
|
+
'recommended_retail_price',
|
|
24
|
+
'short_product_description',
|
|
25
|
+
'unstackable',
|
|
26
|
+
];
|
|
27
|
+
// Register the default settings
|
|
28
|
+
//
|
|
29
|
+
export const SETTINGS_GROUP_NAME = 'evaCoreServiceExtensions';
|
|
30
|
+
const defaultSettings = {
|
|
31
|
+
defaultProductProperties,
|
|
32
|
+
currentOrderOptions: {
|
|
33
|
+
IncludeAvailablePaymentMethods: true,
|
|
34
|
+
IncludeAvailableRefundPaymentMethods: true,
|
|
35
|
+
IncludeAvailableShippingMethods: true,
|
|
36
|
+
IncludeCheckoutOptions: true,
|
|
37
|
+
IncludeCustomerCustomFields: true,
|
|
38
|
+
IncludeGiftWrapping: true,
|
|
39
|
+
IncludeOrganizationUnitData: true,
|
|
40
|
+
IncludePaymentTransactionActions: true,
|
|
41
|
+
IncludePickProductOptions: false,
|
|
42
|
+
IncludePrefigureDiscounts: false,
|
|
43
|
+
IncludeProductRequirements: true,
|
|
44
|
+
IncludeValidateShipment: true,
|
|
45
|
+
ProductProperties: defaultProductProperties,
|
|
46
|
+
RequiredFor: RequiredFor.PlaceOrder + RequiredFor.Payment + RequiredFor.Ship,
|
|
47
|
+
},
|
|
48
|
+
shoppingCartOptions: {
|
|
49
|
+
IncludeAvailablePaymentMethods: false,
|
|
50
|
+
IncludeAvailableRefundPaymentMethods: false,
|
|
51
|
+
IncludeAvailableShippingMethods: false,
|
|
52
|
+
IncludeCheckoutOptions: false,
|
|
53
|
+
IncludeCustomerCustomFields: true,
|
|
54
|
+
IncludeGiftWrapping: true,
|
|
55
|
+
IncludeOrganizationUnitData: true,
|
|
56
|
+
IncludePaymentTransactionActions: false,
|
|
57
|
+
IncludePickProductOptions: true,
|
|
58
|
+
IncludePrefigureDiscounts: true,
|
|
59
|
+
IncludeProductRequirements: true,
|
|
60
|
+
IncludeValidateShipment: false,
|
|
61
|
+
ProductProperties: defaultProductProperties,
|
|
62
|
+
RequiredFor: RequiredFor.PlaceOrder + RequiredFor.Payment + RequiredFor.Ship,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
settings.register(SETTINGS_GROUP_NAME, defaultSettings);
|
|
66
|
+
/**
|
|
67
|
+
* Retrieves the settings for the EvaCoreServiceExtensions module
|
|
68
|
+
*/
|
|
69
|
+
export function getCoreServiceExtensionsSettings() {
|
|
70
|
+
return settings.getGroup(SETTINGS_GROUP_NAME);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Changes a setting for the EvaCoreServiceExtensions module
|
|
74
|
+
*/
|
|
75
|
+
export function setCoreServiceExtensionsSetting(settingName, setting) {
|
|
76
|
+
return settings.set(SETTINGS_GROUP_NAME, settingName, setting);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAmB,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAkE,qBAAqB,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAoCrJ,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,YAAY;IACZ,UAAU;IACV,wBAAwB;IACxB,eAAe;IACf,yBAAyB;IACzB,aAAa;IACb,WAAW;IACX,eAAe;IACf,eAAe;IACf,aAAa;IACb,eAAe;IACf,oBAAoB;IACpB,qBAAqB;IACrB,YAAY;IACZ,eAAe;IACf,cAAc;IACd,sBAAsB;IACtB,gBAAgB;IAChB,eAAe;IACf,0BAA0B;IAC1B,2BAA2B;IAC3B,aAAa;CACd,CAAC;AAEF,gCAAgC;AAChC,EAAE;AACF,MAAM,CAAC,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAC9D,MAAM,eAAe,GAAsC;IAEzD,wBAAwB;IAExB,mBAAmB,EAAE;QACnB,8BAA8B,EAAE,IAAI;QACpC,oCAAoC,EAAE,IAAI;QAC1C,+BAA+B,EAAE,IAAI;QACrC,sBAAsB,EAAE,IAAI;QAC5B,2BAA2B,EAAE,IAAI;QACjC,mBAAmB,EAAE,IAAI;QACzB,2BAA2B,EAAE,IAAI;QACjC,gCAAgC,EAAE,IAAI;QACtC,yBAAyB,EAAE,KAAK;QAChC,yBAAyB,EAAE,KAAK;QAChC,0BAA0B,EAAE,IAAI;QAChC,uBAAuB,EAAE,IAAI;QAC7B,iBAAiB,EAAE,wBAAwB;QAC3C,WAAW,EAAE,WAAW,CAAC,UAAU,GAAG,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,IAAI;KAC7E;IAED,mBAAmB,EAAE;QACnB,8BAA8B,EAAE,KAAK;QACrC,oCAAoC,EAAE,KAAK;QAC3C,+BAA+B,EAAE,KAAK;QACtC,sBAAsB,EAAE,KAAK;QAC7B,2BAA2B,EAAE,IAAI;QACjC,mBAAmB,EAAE,IAAI;QACzB,2BAA2B,EAAE,IAAI;QACjC,gCAAgC,EAAE,KAAK;QACvC,yBAAyB,EAAE,IAAI;QAC/B,yBAAyB,EAAE,IAAI;QAC/B,0BAA0B,EAAE,IAAI;QAChC,uBAAuB,EAAE,KAAK;QAC9B,iBAAiB,EAAE,wBAAwB;QAC3C,WAAW,EAAE,WAAW,CAAC,UAAU,GAAG,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,IAAI;KAC7E;CACF,CAAC;AACF,QAAQ,CAAC,QAAQ,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAC;AAExD;;GAEG;AACH,MAAM,UAAU,gCAAgC;IAC9C,OAAO,QAAQ,CAAC,QAAQ,CAAC,mBAAmB,CAAiD,CAAC;AAChG,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,+BAA+B,CAAC,WAAoD,EAAE,OAAmF;IACvL,OAAO,QAAQ,CAAC,GAAG,CAAC,mBAAmB,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AACjE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@springtree/eva-sdk-core-service-extensions",
|
|
3
|
+
"version": "1.1.0-beta.0",
|
|
4
|
+
"description": "This package contains various helpers and support classes for working with services from the EVA backend",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"author": "SpringTree <info@springtree.nl>",
|
|
7
|
+
"license": "UNLICENSED",
|
|
8
|
+
"main": "lib/eva-sdk-core-service-extensions.js",
|
|
9
|
+
"directories": {
|
|
10
|
+
"lib": "lib",
|
|
11
|
+
"test": "__tests__"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"lib"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/springtreesolutions/eva-sdk-repo.git"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"test": "node ./__tests__/@springtree/eva-sdk-core-service-extensions.test.js"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/springtreesolutions/eva-sdk-repo/issues"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/springtreesolutions/eva-sdk-repo#readme",
|
|
30
|
+
"typings": "lib/eva-sdk-core-service-extensions.d.ts",
|
|
31
|
+
"module": "lib/eva-sdk-core-service-extensions.js",
|
|
32
|
+
"type": "module",
|
|
33
|
+
"private": false,
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@springtree/eva-sdk-core-logger": "2.1.0-beta.0",
|
|
36
|
+
"@springtree/eva-sdk-core-service": "^6.0.0-beta.5",
|
|
37
|
+
"@springtree/eva-services-core": "^3.0.0-beta.53",
|
|
38
|
+
"dequal": "^2.0.3",
|
|
39
|
+
"uuid": "^9.0.1"
|
|
40
|
+
},
|
|
41
|
+
"gitHead": "1f15a6bf7f832e8dc9dd4ae848cb0d8cf82ed39d"
|
|
42
|
+
}
|