rerobe-js-orm 2.4.76 → 2.4.81
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/lib/factories/Order/OrderFromShopifyWebhook.js +126 -10
- package/lib/factories/Product/ProductFromFormState.js +24 -2
- package/lib/helpers/ReRobeProductHelpers.d.ts +3 -0
- package/lib/helpers/ReRobeProductHelpers.js +80 -0
- package/lib/models/Product.d.ts +1 -0
- package/lib/models/Product.js +31 -1
- package/lib/types/rerobe-order-types.d.ts +28 -3
- package/lib/types/rerobe-product-types.d.ts +22 -0
- package/lib/types/rerobe-user-types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -4,6 +4,18 @@ const OrderFactory_1 = require("./OrderFactory");
|
|
|
4
4
|
const Order_1 = require("../../models/Order");
|
|
5
5
|
const OrderHelpers_1 = require("../../helpers/OrderHelpers");
|
|
6
6
|
const orderHelpers = new OrderHelpers_1.default();
|
|
7
|
+
const fulfillmentStatusRestMapping = {
|
|
8
|
+
fulfilled: 'FULFILLED',
|
|
9
|
+
null: '',
|
|
10
|
+
partial: 'PARTIALLY_FULFILLED',
|
|
11
|
+
restocked: 'RESTOCKED',
|
|
12
|
+
pending: 'PENDING_FULFILLMENT',
|
|
13
|
+
open: 'OPEN',
|
|
14
|
+
success: 'SUCCESS',
|
|
15
|
+
cancelled: 'CANCELED',
|
|
16
|
+
error: 'ERROR',
|
|
17
|
+
failure: 'FAILURE',
|
|
18
|
+
};
|
|
7
19
|
class OrderFromShopifyWebhook extends OrderFactory_1.default {
|
|
8
20
|
createOrder(order) {
|
|
9
21
|
const { id, financial_status, fulfillment_status, cancel_reason, line_items, discount_applications, shipping_address, subtotal_price_set, total_price_set, total_shipping_price_set, currency, cancelled_at, closed_at, created_at, order_number, processed_at, updated_at, shipping_lines, tax_lines, name, total_discounts, tags = '', } = order;
|
|
@@ -78,23 +90,123 @@ class OrderFromShopifyWebhook extends OrderFactory_1.default {
|
|
|
78
90
|
}
|
|
79
91
|
: null;
|
|
80
92
|
const fulfillments = order.fulfillments
|
|
81
|
-
? order.fulfillments.map((item) => (
|
|
93
|
+
? order.fulfillments.map((item) => ({
|
|
94
|
+
name: item.name,
|
|
95
|
+
id: item.id,
|
|
96
|
+
createdAt: item.created_at,
|
|
97
|
+
updatedAt: item.updated_at,
|
|
98
|
+
location: {
|
|
82
99
|
id: item.location_id || '',
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
|
|
100
|
+
},
|
|
101
|
+
shipmentStatus: item.shipment_status ? item.shipment_status.toUpperCase() : '',
|
|
102
|
+
service: {
|
|
86
103
|
serviceType: item.service ? item.service.toUpperCase() : '',
|
|
87
|
-
},
|
|
104
|
+
},
|
|
105
|
+
status: item.status ? item.status.toUpperCase() : '',
|
|
106
|
+
trackingInfo: {
|
|
88
107
|
company: item.tracking_company,
|
|
89
108
|
number: item.tracking_numbers && !!item.tracking_numbers.length ? item.tracking_numbers[0] : '',
|
|
90
109
|
url: item.tracking_urls && !!item.tracking_urls.length ? item.tracking_urls[0] : '',
|
|
91
|
-
},
|
|
110
|
+
},
|
|
111
|
+
fulfillmentLineItems: item.line_items
|
|
92
112
|
? item.line_items.map((lineItem) => ({
|
|
93
|
-
lineItem,
|
|
113
|
+
lineItem: { shopifyProductId: lineItem === null || lineItem === void 0 ? void 0 : lineItem.product_id },
|
|
94
114
|
quantity: lineItem.quantity,
|
|
95
115
|
}))
|
|
96
|
-
: []
|
|
116
|
+
: [],
|
|
117
|
+
}))
|
|
118
|
+
: [];
|
|
119
|
+
const refunds = order.refunds
|
|
120
|
+
? order.refunds.map((rawRefundItem) => {
|
|
121
|
+
const currencyCode = currency;
|
|
122
|
+
const refundedShippingAmount = !rawRefundItem.order_adjustments.length
|
|
123
|
+
? 0
|
|
124
|
+
: rawRefundItem.order_adjustments.reduce((result, item) => {
|
|
125
|
+
if (item.kind === 'shipping_refund') {
|
|
126
|
+
result = result - Number(item.amount);
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
}, 0);
|
|
130
|
+
const totalRefundedAmount = !rawRefundItem.transactions.length
|
|
131
|
+
? 0
|
|
132
|
+
: rawRefundItem.transactions.reduce((result, item) => {
|
|
133
|
+
if (item.kind === 'refund') {
|
|
134
|
+
result = result + Number(item.amount);
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}, 0);
|
|
138
|
+
let refundDiscountAmount = 0;
|
|
139
|
+
const subtotalRefundedAmount = !rawRefundItem.refund_line_items.length
|
|
140
|
+
? 0
|
|
141
|
+
: rawRefundItem.refund_line_items.reduce((result, item) => {
|
|
142
|
+
if (item.line_item) {
|
|
143
|
+
const itemSubtotal = Number(Number(item.line_item.price) * item.quantity);
|
|
144
|
+
result = result + itemSubtotal;
|
|
145
|
+
refundDiscountAmount = refundDiscountAmount + itemSubtotal - Number(item.subtotal);
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}, 0);
|
|
149
|
+
let refundLineItems = !rawRefundItem.refund_line_items || !rawRefundItem.refund_line_items.length
|
|
150
|
+
? []
|
|
151
|
+
: rawRefundItem.refund_line_items.map((item) => {
|
|
152
|
+
var _a, _b;
|
|
153
|
+
const quantityRefund = !item.location_id ? item.quantity : 0;
|
|
154
|
+
const quantityCancel = item.location_id ? item.quantity : 0;
|
|
155
|
+
const discountRefundAmount = Number(Number((_a = item.line_item) === null || _a === void 0 ? void 0 : _a.price) * item.quantity) - Number(item.subtotal);
|
|
156
|
+
const subtotalRefundAmount = !item.location_id ? item.subtotal : 0;
|
|
157
|
+
const subtotalCanceledAmount = item.location_id ? item.subtotal : 0;
|
|
158
|
+
return {
|
|
159
|
+
lineItem: { shopifyProductId: (_b = item.line_item) === null || _b === void 0 ? void 0 : _b.product_id },
|
|
160
|
+
quantityRefund,
|
|
161
|
+
quantityCancel,
|
|
162
|
+
discountRefund: { currencyCode, amount: discountRefundAmount },
|
|
163
|
+
subtotalRefund: { currencyCode, amount: subtotalRefundAmount },
|
|
164
|
+
subtotalCanceled: { currencyCode, amount: subtotalCanceledAmount },
|
|
165
|
+
};
|
|
166
|
+
});
|
|
167
|
+
if (refundLineItems.length) {
|
|
168
|
+
refundLineItems = refundLineItems.reduce((result, item) => {
|
|
169
|
+
var _a;
|
|
170
|
+
const existedLineItemsIds = !result.length ? [] : result.map((itm) => itm.lineItem.shopifyProductId);
|
|
171
|
+
const existedLineItemIdx = existedLineItemsIds.indexOf((_a = item.lineItem) === null || _a === void 0 ? void 0 : _a.shopifyProductId);
|
|
172
|
+
if (existedLineItemIdx < 0) {
|
|
173
|
+
result.push(item);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
result[existedLineItemIdx] = {
|
|
177
|
+
lineItem: result[existedLineItemIdx].lineItem,
|
|
178
|
+
quantityRefund: result[existedLineItemIdx].quantityRefund + item.quantityRefund,
|
|
179
|
+
quantityCancel: result[existedLineItemIdx].quantityCancel + item.quantityCancel,
|
|
180
|
+
discountRefund: Object.assign(Object.assign({}, result[existedLineItemIdx].discountRefund), { amount: result[existedLineItemIdx].discountRefund.amount + item.discountRefund.amount }),
|
|
181
|
+
subtotalRefund: Object.assign(Object.assign({}, result[existedLineItemIdx].subtotalRefund), { amount: result[existedLineItemIdx].subtotalRefund.amount + item.subtotalRefund.amount }),
|
|
182
|
+
subtotalCanceled: Object.assign(Object.assign({}, result[existedLineItemIdx].subtotalCanceled), { amount: result[existedLineItemIdx].subtotalCanceled.amount + item.subtotalCanceled.amount }),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return result;
|
|
186
|
+
}, []);
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
documentId: rawRefundItem.id,
|
|
190
|
+
createdAt: rawRefundItem.created_at,
|
|
191
|
+
note: rawRefundItem.note,
|
|
192
|
+
totalRefunded: { amount: totalRefundedAmount, currencyCode },
|
|
193
|
+
subtotalRefunded: { amount: subtotalRefundedAmount, currencyCode },
|
|
194
|
+
refundDiscount: { amount: refundDiscountAmount, currencyCode },
|
|
195
|
+
refundShipping: { amount: refundedShippingAmount, currencyCode },
|
|
196
|
+
totalTax: { amount: 0, currencyCode },
|
|
197
|
+
refundLineItems,
|
|
198
|
+
};
|
|
199
|
+
})
|
|
97
200
|
: [];
|
|
201
|
+
const totalRefunded = {
|
|
202
|
+
currencyCode: currency,
|
|
203
|
+
amount: !refunds || !refunds.length
|
|
204
|
+
? 0
|
|
205
|
+
: refunds.reduce((result, item) => {
|
|
206
|
+
result = result + Number(item.totalRefunded.amount);
|
|
207
|
+
return result;
|
|
208
|
+
}, 0),
|
|
209
|
+
};
|
|
98
210
|
const taxLines = tax_lines
|
|
99
211
|
? tax_lines.map((item) => ({
|
|
100
212
|
rate: item.rate,
|
|
@@ -150,13 +262,17 @@ class OrderFromShopifyWebhook extends OrderFactory_1.default {
|
|
|
150
262
|
},
|
|
151
263
|
source: '',
|
|
152
264
|
};
|
|
153
|
-
|
|
265
|
+
// @ts-ignore
|
|
266
|
+
const fulfillmentStatus = !fulfillment_status ? '' : fulfillmentStatusRestMapping[fulfillment_status];
|
|
267
|
+
const rerobeOrder = new Order_1.default(Object.assign(Object.assign({}, order), { id: orderHelpers.getOrderIdFromShopifyObj(order), shopifyId: `gid://shopify/Order/${id}`, shopifyOrderNumber: name ? Number(name.split('#')[1]) : 0, financialStatus: financial_status ? financial_status.toUpperCase() : '', fulfillmentStatus, cancelReason: cancel_reason ? cancel_reason.toUpperCase() : '', lineItems,
|
|
154
268
|
subtotalPrice,
|
|
155
269
|
totalPrice,
|
|
156
270
|
totalShippingPrice,
|
|
157
|
-
totalDiscount,
|
|
271
|
+
totalDiscount,
|
|
272
|
+
totalRefunded, canceledAt: cancelled_at, closedAt: closed_at, createdAt: created_at, orderNumber: order_number, processedAt: processed_at, updatedAt: updated_at, shippingAddress,
|
|
158
273
|
discountApplications,
|
|
159
274
|
fulfillments,
|
|
275
|
+
refunds,
|
|
160
276
|
taxLines,
|
|
161
277
|
shippingLine, state: Order_1.default.ORDER_STATES.completed, shippingType: orderHelpers.getShippingTypeFromShopifyObj(shipping_lines), paymentType: orderHelpers.getPaymentTypeUsingTags(tags), salesChannel: orderHelpers.getSalesChannelUsingTags(tags), tags: tags ? tags.split(', ') : [] }));
|
|
162
278
|
return rerobeOrder.toObj();
|
|
@@ -4,7 +4,7 @@ const ProductFactory_1 = require("./ProductFactory");
|
|
|
4
4
|
const Product_1 = require("../../models/Product");
|
|
5
5
|
class ProductFromFormState extends ProductFactory_1.default {
|
|
6
6
|
createProduct(props) {
|
|
7
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
7
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11;
|
|
8
8
|
const productAttributes = {
|
|
9
9
|
availableForSale: props.fields.availableForSale.selectedValue,
|
|
10
10
|
description: props.fields.description.inputValue,
|
|
@@ -77,7 +77,29 @@ class ProductFromFormState extends ProductFactory_1.default {
|
|
|
77
77
|
selectedForClearance: ((_r = props.props) === null || _r === void 0 ? void 0 : _r.selectedForClearance) || '',
|
|
78
78
|
locationIds: props.fields.locationIds.selectedValues || [],
|
|
79
79
|
};
|
|
80
|
-
|
|
80
|
+
const timestampAttributes = {
|
|
81
|
+
sellRequestReviewTimestamp: (_s = props.props) === null || _s === void 0 ? void 0 : _s.sellRequestReviewTimestamp,
|
|
82
|
+
sellRequestReviewDraftTimestamp: (_t = props.props) === null || _t === void 0 ? void 0 : _t.sellRequestReviewDraftTimestamp,
|
|
83
|
+
rejectedTimestamp: (_u = props.props) === null || _u === void 0 ? void 0 : _u.rejectedTimestamp,
|
|
84
|
+
holdTimestamp: (_v = props.props) === null || _v === void 0 ? void 0 : _v.holdTimestamp,
|
|
85
|
+
acceptedTimestamp: (_w = props.props) === null || _w === void 0 ? void 0 : _w.acceptedTimestamp,
|
|
86
|
+
sellerToDropOffTimestamp: (_x = props.props) === null || _x === void 0 ? void 0 : _x.sellerToDropOffTimestamp,
|
|
87
|
+
sellerToShipTimestamp: (_y = props.props) === null || _y === void 0 ? void 0 : _y.sellerToShipTimestamp,
|
|
88
|
+
sellerToGetPickUpTimestamp: (_z = props.props) === null || _z === void 0 ? void 0 : _z.sellerToGetPickUpTimestamp,
|
|
89
|
+
qualityControlTimestamp: (_0 = props.props) === null || _0 === void 0 ? void 0 : _0.qualityControlTimestamp,
|
|
90
|
+
pendingPublicationTimestamp: (_1 = props.props) === null || _1 === void 0 ? void 0 : _1.pendingPublicationTimestamp,
|
|
91
|
+
listedTimestamp: (_2 = props.props) === null || _2 === void 0 ? void 0 : _2.listedTimestamp,
|
|
92
|
+
clearanceTimestamp: (_3 = props.props) === null || _3 === void 0 ? void 0 : _3.clearanceTimestamp,
|
|
93
|
+
reservedTimestamp: (_4 = props.props) === null || _4 === void 0 ? void 0 : _4.reservedTimestamp,
|
|
94
|
+
soldTimestamp: (_5 = props.props) === null || _5 === void 0 ? void 0 : _5.soldTimestamp,
|
|
95
|
+
returnedTimestamp: (_6 = props.props) === null || _6 === void 0 ? void 0 : _6.returnedTimestamp,
|
|
96
|
+
soldSellerToBePaidTimestamp: (_7 = props.props) === null || _7 === void 0 ? void 0 : _7.soldSellerToBePaidTimestamp,
|
|
97
|
+
soldSellerPaidTimestamp: (_8 = props.props) === null || _8 === void 0 ? void 0 : _8.soldSellerPaidTimestamp,
|
|
98
|
+
sellerSelfRejectTimestamp: (_9 = props.props) === null || _9 === void 0 ? void 0 : _9.sellerSelfRejectTimestamp,
|
|
99
|
+
liquidationRequestedTimestamp: (_10 = props.props) === null || _10 === void 0 ? void 0 : _10.liquidationRequestedTimestamp,
|
|
100
|
+
sellerLiquidatedTimestamp: (_11 = props.props) === null || _11 === void 0 ? void 0 : _11.sellerLiquidatedTimestamp,
|
|
101
|
+
};
|
|
102
|
+
return new Product_1.default(Object.assign(Object.assign(Object.assign(Object.assign({}, productAttributes), productFilterAttributes), consignmentAttributes), timestampAttributes));
|
|
81
103
|
}
|
|
82
104
|
}
|
|
83
105
|
exports.default = ProductFromFormState;
|
|
@@ -12,6 +12,9 @@ export default class ReRobeProductHelpers {
|
|
|
12
12
|
static prepareProductForMutation(productObj: CompleteProduct, mediaInputArr?: {
|
|
13
13
|
originalSource: string;
|
|
14
14
|
}[]): CompleteProduct;
|
|
15
|
+
static createTimestampsForStates(productObj: CompleteProduct): {
|
|
16
|
+
[key: string]: number;
|
|
17
|
+
};
|
|
15
18
|
static getSubtitle(title: string): string;
|
|
16
19
|
static sizeFinder(sizeLabel: string, sizeToMatch: string): boolean;
|
|
17
20
|
static convertReRobeSizeToStandardSize(productObj: CompleteProduct): string;
|
|
@@ -223,6 +223,86 @@ class ReRobeProductHelpers {
|
|
|
223
223
|
}
|
|
224
224
|
return productObjClone;
|
|
225
225
|
}
|
|
226
|
+
static createTimestampsForStates(productObj) {
|
|
227
|
+
const docFieldsToUpdate = {};
|
|
228
|
+
if (productObj) {
|
|
229
|
+
const { dateSold, status, sellRequestReviewDraftTimestamp, sellRequestReviewTimestamp, rejectedTimestamp, holdTimestamp, acceptedTimestamp, sellerToDropOffTimestamp, sellerToShipTimestamp, sellerToGetPickUpTimestamp, qualityControlTimestamp, pendingPublicationTimestamp, listedTimestamp, clearanceTimestamp, reservedTimestamp, soldTimestamp, soldSellerToBePaidTimestamp, soldSellerPaidTimestamp, returnedTimestamp, sellerSelfRejectTimestamp, liquidationRequestedTimestamp, sellerLiquidatedTimestamp, } = productObj;
|
|
230
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.sellRequestReviewDraft && !sellRequestReviewDraftTimestamp) {
|
|
231
|
+
docFieldsToUpdate.sellRequestReviewDraftTimestamp = new Date().getTime();
|
|
232
|
+
}
|
|
233
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.sellRequestReview && !sellRequestReviewTimestamp) {
|
|
234
|
+
docFieldsToUpdate.sellRequestReviewTimestamp = new Date().getTime();
|
|
235
|
+
}
|
|
236
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.rejected && !rejectedTimestamp) {
|
|
237
|
+
docFieldsToUpdate.rejectedTimestamp = new Date().getTime();
|
|
238
|
+
}
|
|
239
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.hold && !holdTimestamp) {
|
|
240
|
+
docFieldsToUpdate.holdTimestamp = new Date().getTime();
|
|
241
|
+
}
|
|
242
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.accepted && !acceptedTimestamp) {
|
|
243
|
+
docFieldsToUpdate.acceptedTimestamp = new Date().getTime();
|
|
244
|
+
}
|
|
245
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.sellerToDropOff && !sellerToDropOffTimestamp) {
|
|
246
|
+
docFieldsToUpdate.sellerToDropOffTimestamp = new Date().getTime();
|
|
247
|
+
}
|
|
248
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.sellerToShip && !sellerToShipTimestamp) {
|
|
249
|
+
docFieldsToUpdate.sellerToShipTimestamp = new Date().getTime();
|
|
250
|
+
}
|
|
251
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.sellerToGetPickUp && !sellerToGetPickUpTimestamp) {
|
|
252
|
+
docFieldsToUpdate.sellerToGetPickUpTimestamp = new Date().getTime();
|
|
253
|
+
}
|
|
254
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.qualityControl && !qualityControlTimestamp) {
|
|
255
|
+
docFieldsToUpdate.qualityControlTimestamp = new Date().getTime();
|
|
256
|
+
}
|
|
257
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.pendingPublication && !pendingPublicationTimestamp) {
|
|
258
|
+
docFieldsToUpdate.pendingPublicationTimestamp = new Date().getTime();
|
|
259
|
+
}
|
|
260
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.listed && !listedTimestamp) {
|
|
261
|
+
docFieldsToUpdate.listedTimestamp = new Date().getTime();
|
|
262
|
+
}
|
|
263
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.clearance && !clearanceTimestamp) {
|
|
264
|
+
docFieldsToUpdate.clearanceTimestamp = new Date().getTime();
|
|
265
|
+
}
|
|
266
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.reserved && !reservedTimestamp) {
|
|
267
|
+
docFieldsToUpdate.reservedTimestamp = new Date().getTime();
|
|
268
|
+
}
|
|
269
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.sold && !soldTimestamp) {
|
|
270
|
+
docFieldsToUpdate.soldTimestamp = new Date().getTime();
|
|
271
|
+
}
|
|
272
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.soldSellerToBePaid && !soldSellerToBePaidTimestamp) {
|
|
273
|
+
const timeNow = new Date().getTime();
|
|
274
|
+
docFieldsToUpdate.soldSellerToBePaidTimestamp = timeNow;
|
|
275
|
+
if (!soldTimestamp) {
|
|
276
|
+
docFieldsToUpdate.soldTimestamp =
|
|
277
|
+
dateSold && typeof dateSold === 'string' ? new Date(dateSold).getTime() : timeNow;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.soldSellerPaid && !soldSellerPaidTimestamp) {
|
|
281
|
+
const timeNow = new Date().getTime();
|
|
282
|
+
docFieldsToUpdate.soldSellerPaidTimestamp = timeNow;
|
|
283
|
+
if (!soldSellerToBePaidTimestamp) {
|
|
284
|
+
docFieldsToUpdate.soldSellerToBePaidTimestamp = timeNow;
|
|
285
|
+
}
|
|
286
|
+
if (!soldTimestamp) {
|
|
287
|
+
docFieldsToUpdate.soldTimestamp =
|
|
288
|
+
dateSold && typeof dateSold === 'string' ? new Date(dateSold).getTime() : timeNow;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.returned && !returnedTimestamp) {
|
|
292
|
+
docFieldsToUpdate.returnedTimestamp = new Date().getTime();
|
|
293
|
+
}
|
|
294
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.sellerSelfReject && !sellerSelfRejectTimestamp) {
|
|
295
|
+
docFieldsToUpdate.sellerSelfRejectTimestamp = new Date().getTime();
|
|
296
|
+
}
|
|
297
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.liquidationRequested && !liquidationRequestedTimestamp) {
|
|
298
|
+
docFieldsToUpdate.liquidationRequestedTimestamp = new Date().getTime();
|
|
299
|
+
}
|
|
300
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.sellerLiquidated && !sellerLiquidatedTimestamp) {
|
|
301
|
+
docFieldsToUpdate.sellerLiquidatedTimestamp = new Date().getTime();
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return docFieldsToUpdate;
|
|
305
|
+
}
|
|
226
306
|
static getSubtitle(title) {
|
|
227
307
|
if (typeof title === 'string' && title.trim()) {
|
|
228
308
|
return title.split('by')[0].trim();
|
package/lib/models/Product.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export default class Product extends Base {
|
|
|
3
3
|
attributes: ProductAttributes;
|
|
4
4
|
filterAttributes: ProductFilterAttributes;
|
|
5
5
|
consignmentAttributes: ProductConsignmentAttributes;
|
|
6
|
+
timestampAttributes: ProductTimestampAttributes;
|
|
6
7
|
FIELD_NOT_TRANSLATABLE_KEY: string;
|
|
7
8
|
constructor(props?: any);
|
|
8
9
|
toPartialObj(): ShopifyProduct;
|
package/lib/models/Product.js
CHANGED
|
@@ -81,12 +81,42 @@ class Product extends Base_1.default {
|
|
|
81
81
|
selectedForClearance: (props === null || props === void 0 ? void 0 : props.selectedForClearance) || '',
|
|
82
82
|
locationIds: (props === null || props === void 0 ? void 0 : props.locationIds) || [],
|
|
83
83
|
};
|
|
84
|
+
this.timestampAttributes = {
|
|
85
|
+
sellRequestReviewDraftTimestamp: (props === null || props === void 0 ? void 0 : props.sellRequestReviewDraftTimestamp)
|
|
86
|
+
? Number(props === null || props === void 0 ? void 0 : props.sellRequestReviewDraftTimestamp)
|
|
87
|
+
: null,
|
|
88
|
+
sellRequestReviewTimestamp: (props === null || props === void 0 ? void 0 : props.sellRequestReviewTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.sellRequestReviewTimestamp) : null,
|
|
89
|
+
rejectedTimestamp: (props === null || props === void 0 ? void 0 : props.rejectedTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.rejectedTimestamp) : null,
|
|
90
|
+
holdTimestamp: (props === null || props === void 0 ? void 0 : props.holdTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.holdTimestamp) : null,
|
|
91
|
+
acceptedTimestamp: (props === null || props === void 0 ? void 0 : props.acceptedTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.acceptedTimestamp) : null,
|
|
92
|
+
sellerToDropOffTimestamp: (props === null || props === void 0 ? void 0 : props.sellerToDropOffTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.sellerToDropOffTimestamp) : null,
|
|
93
|
+
sellerToShipTimestamp: (props === null || props === void 0 ? void 0 : props.sellerToShipTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.sellerToShipTimestamp) : null,
|
|
94
|
+
sellerToGetPickUpTimestamp: (props === null || props === void 0 ? void 0 : props.sellerToGetPickUpTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.sellerToGetPickUpTimestamp) : null,
|
|
95
|
+
qualityControlTimestamp: (props === null || props === void 0 ? void 0 : props.qualityControlTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.qualityControlTimestamp) : null,
|
|
96
|
+
pendingPublicationTimestamp: (props === null || props === void 0 ? void 0 : props.pendingPublicationTimestamp)
|
|
97
|
+
? Number(props === null || props === void 0 ? void 0 : props.pendingPublicationTimestamp)
|
|
98
|
+
: null,
|
|
99
|
+
listedTimestamp: (props === null || props === void 0 ? void 0 : props.listedTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.listedTimestamp) : null,
|
|
100
|
+
clearanceTimestamp: (props === null || props === void 0 ? void 0 : props.clearanceTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.clearanceTimestamp) : null,
|
|
101
|
+
reservedTimestamp: (props === null || props === void 0 ? void 0 : props.reservedTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.reservedTimestamp) : null,
|
|
102
|
+
soldTimestamp: (props === null || props === void 0 ? void 0 : props.soldTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.soldTimestamp) : null,
|
|
103
|
+
returnedTimestamp: (props === null || props === void 0 ? void 0 : props.returnedTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.returnedTimestamp) : null,
|
|
104
|
+
soldSellerToBePaidTimestamp: (props === null || props === void 0 ? void 0 : props.soldSellerToBePaidTimestamp)
|
|
105
|
+
? Number(props === null || props === void 0 ? void 0 : props.soldSellerToBePaidTimestamp)
|
|
106
|
+
: null,
|
|
107
|
+
soldSellerPaidTimestamp: (props === null || props === void 0 ? void 0 : props.soldSellerPaidTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.soldSellerPaidTimestamp) : null,
|
|
108
|
+
sellerSelfRejectTimestamp: (props === null || props === void 0 ? void 0 : props.sellerSelfRejectTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.sellerSelfRejectTimestamp) : null,
|
|
109
|
+
liquidationRequestedTimestamp: (props === null || props === void 0 ? void 0 : props.liquidationRequestedTimestamp)
|
|
110
|
+
? Number(props === null || props === void 0 ? void 0 : props.liquidationRequestedTimestamp)
|
|
111
|
+
: null,
|
|
112
|
+
sellerLiquidatedTimestamp: (props === null || props === void 0 ? void 0 : props.sellerLiquidatedTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.sellerLiquidatedTimestamp) : null,
|
|
113
|
+
};
|
|
84
114
|
}
|
|
85
115
|
toPartialObj() {
|
|
86
116
|
return Object.assign(Object.assign({}, this.attributes), this.filterAttributes);
|
|
87
117
|
}
|
|
88
118
|
toObj() {
|
|
89
|
-
return Object.assign(Object.assign(Object.assign({}, this.attributes), this.filterAttributes), this.consignmentAttributes);
|
|
119
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, this.attributes), this.filterAttributes), this.consignmentAttributes), this.timestampAttributes);
|
|
90
120
|
}
|
|
91
121
|
toProductInputObjForShopify(location) {
|
|
92
122
|
const productInputObj = {
|
|
@@ -492,6 +492,25 @@ declare type OrderLineItemRest = {
|
|
|
492
492
|
total_discount_set?: MoneyBagRest;
|
|
493
493
|
discount_allocations?: DiscountAllocationRest[];
|
|
494
494
|
origin_location?: AddressInputRest;
|
|
495
|
+
line_item?: {
|
|
496
|
+
[key: string]: any;
|
|
497
|
+
};
|
|
498
|
+
subtotal?: number | string;
|
|
499
|
+
location_id?: string | null;
|
|
500
|
+
};
|
|
501
|
+
declare type RefundLineItemRest = {
|
|
502
|
+
id: number | string;
|
|
503
|
+
line_item?: {
|
|
504
|
+
[key: string]: any;
|
|
505
|
+
};
|
|
506
|
+
line_item_id: number;
|
|
507
|
+
location_id?: number | string | null;
|
|
508
|
+
quantity: number;
|
|
509
|
+
restock_type: string;
|
|
510
|
+
total_tax?: number;
|
|
511
|
+
total_tax_set?: MoneyBagRest;
|
|
512
|
+
subtotal?: number | string;
|
|
513
|
+
subtotal_set?: MoneyBagRest;
|
|
495
514
|
};
|
|
496
515
|
declare type CancelReasonRestTypes = 'customer' | 'declined' | 'fraud' | 'inventory' | 'other';
|
|
497
516
|
declare type FinancialStatusRestTypes = 'authorized' | 'paid' | 'partially_paid' | 'partially_refunded' | 'pending' | 'refunded' | 'voided';
|
|
@@ -524,17 +543,23 @@ declare type DiscountCodeRest = {
|
|
|
524
543
|
declare type OrderRefundRest = {
|
|
525
544
|
id: number | string;
|
|
526
545
|
order_id: number | string;
|
|
527
|
-
refund_line_items:
|
|
546
|
+
refund_line_items: RefundLineItemRest[];
|
|
528
547
|
created_at?: string;
|
|
529
548
|
note?: string;
|
|
530
549
|
user_id?: number | string;
|
|
531
550
|
processed_at?: string;
|
|
551
|
+
order_adjustments: any[];
|
|
552
|
+
transactions: any[];
|
|
553
|
+
admin_graphql_api_id?: string | null;
|
|
554
|
+
restock?: boolean;
|
|
555
|
+
duties?: any[];
|
|
556
|
+
total_duties_set?: MoneyBagRest;
|
|
532
557
|
};
|
|
533
558
|
declare type AddressInputRest = {
|
|
534
559
|
address1: string;
|
|
535
560
|
address2?: string;
|
|
536
561
|
city: string;
|
|
537
|
-
country
|
|
562
|
+
country?: string;
|
|
538
563
|
company?: string | null;
|
|
539
564
|
first_name?: string | null;
|
|
540
565
|
last_name?: string | null;
|
|
@@ -568,7 +593,7 @@ declare type FulfillmentRest = {
|
|
|
568
593
|
service?: FulfillmentServiceRestTypes | string | null;
|
|
569
594
|
shipment_status?: FulfillmentShipmentStatusRestTypes | string | null;
|
|
570
595
|
status?: FulfillmentStatusRestTypes | string | null;
|
|
571
|
-
tracking_company?: string;
|
|
596
|
+
tracking_company?: string | null;
|
|
572
597
|
tracking_numbers?: string[] | number[];
|
|
573
598
|
tracking_urls?: string[];
|
|
574
599
|
updated_at?: string;
|
|
@@ -70,6 +70,28 @@ declare type ProductConsignmentAttributes = {
|
|
|
70
70
|
selectedForClearance: string;
|
|
71
71
|
locationIds?: string[];
|
|
72
72
|
};
|
|
73
|
+
declare type ProductTimestampAttributes = {
|
|
74
|
+
sellRequestReviewTimestamp: number | null;
|
|
75
|
+
sellRequestReviewDraftTimestamp: number | null;
|
|
76
|
+
rejectedTimestamp: number | null;
|
|
77
|
+
holdTimestamp: number | null;
|
|
78
|
+
acceptedTimestamp: number | null;
|
|
79
|
+
sellerToDropOffTimestamp: number | null;
|
|
80
|
+
sellerToShipTimestamp: number | null;
|
|
81
|
+
sellerToGetPickUpTimestamp: number | null;
|
|
82
|
+
qualityControlTimestamp: number | null;
|
|
83
|
+
pendingPublicationTimestamp: number | null;
|
|
84
|
+
listedTimestamp: number | null;
|
|
85
|
+
clearanceTimestamp: number | null;
|
|
86
|
+
reservedTimestamp: number | null;
|
|
87
|
+
soldTimestamp: number | null;
|
|
88
|
+
returnedTimestamp: number | null;
|
|
89
|
+
soldSellerToBePaidTimestamp: number | null;
|
|
90
|
+
soldSellerPaidTimestamp: number | null;
|
|
91
|
+
sellerSelfRejectTimestamp: number | null;
|
|
92
|
+
liquidationRequestedTimestamp: number | null;
|
|
93
|
+
sellerLiquidatedTimestamp: number | null;
|
|
94
|
+
};
|
|
73
95
|
declare type TranslatableAttributes = {
|
|
74
96
|
description: string;
|
|
75
97
|
color: string;
|