u
This commit is contained in:
@@ -242,25 +242,31 @@ export async function importOrders({
|
|||||||
|
|
||||||
if (shippableLines.length > 0) {
|
if (shippableLines.length > 0) {
|
||||||
try {
|
try {
|
||||||
|
const isSelbstabholer = (shippingType || '').trim().toLowerCase() === 'selbstabholer';
|
||||||
|
const deliveryState = isShipped ? 'delivered' : 'new';
|
||||||
|
|
||||||
const shipment = await store.shipment.create(googleAuthId, {
|
const shipment = await store.shipment.create(googleAuthId, {
|
||||||
orderId: createdOrder.id,
|
orderId: createdOrder.id,
|
||||||
date: validDate,
|
date: validDate,
|
||||||
|
state: deliveryState,
|
||||||
lines: shippableLines,
|
lines: shippableLines,
|
||||||
});
|
});
|
||||||
|
|
||||||
const trackingCode = cleanValue(m.trackingCode ?? m.tracking_code ?? m.cTracking);
|
if (!isSelbstabholer) {
|
||||||
const carrier = cleanValue(m.carrier ?? m.cCarrier);
|
const trackingCode = cleanValue(m.trackingCode ?? m.tracking_code ?? m.cTracking);
|
||||||
const shippingState = isShipped ? 'shipped' : 'draft';
|
const carrier = cleanValue(m.carrier ?? m.cCarrier);
|
||||||
|
const shippingState = isShipped ? 'shipped' : 'draft';
|
||||||
|
|
||||||
await store.shipping.create(googleAuthId, {
|
await store.shipping.create(googleAuthId, {
|
||||||
manifestId: shipment.id,
|
manifestId: shipment.id,
|
||||||
type: shippingType || 'standard',
|
type: shippingType || 'standard',
|
||||||
state: shippingState,
|
state: shippingState,
|
||||||
trackingCode: trackingCode || undefined,
|
trackingCode: trackingCode || undefined,
|
||||||
carrier: carrier || undefined,
|
carrier: carrier || undefined,
|
||||||
warehouseId: defaultWarehouseId || undefined,
|
warehouseId: defaultWarehouseId || undefined,
|
||||||
});
|
});
|
||||||
shippingsImported++;
|
shippingsImported++;
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log.warn(`Failed to create shipment/shipping for order ${orderNumber}:`, err.message);
|
log.warn(`Failed to create shipment/shipping for order ${orderNumber}:`, err.message);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user