u
This commit is contained in:
@@ -301,8 +301,21 @@ export async function handleOrder(req, res, next) {
|
||||
// 7. Deliver / Shipment
|
||||
const shouldDeliver = String(order.settings?.deliver ?? '').trim() === '1' || order.deliver === true || order.shipped === true;
|
||||
if (shouldDeliver) {
|
||||
const warehouses = await store.warehouse.list(googleAuthId).catch(() => []);
|
||||
const defaultWarehouseId = warehouses[0]?.id || 1;
|
||||
let warehouses = await store.warehouse.list(googleAuthId).catch(() => []);
|
||||
let defaultWarehouseId = warehouses[0]?.id;
|
||||
if (!defaultWarehouseId) {
|
||||
try {
|
||||
const createdWh = await store.warehouse.create(googleAuthId, { name: 'Standardlager' });
|
||||
defaultWarehouseId = createdWh.id;
|
||||
emit('warehouse', { companyId });
|
||||
} catch {
|
||||
warehouses = await store.warehouse.list(googleAuthId).catch(() => []);
|
||||
defaultWarehouseId = warehouses[0]?.id;
|
||||
}
|
||||
}
|
||||
if (!defaultWarehouseId) {
|
||||
throw new Error('Warehouse not found');
|
||||
}
|
||||
|
||||
const shippableLines = (createdOrder.lines || lines)
|
||||
.filter((l) => l.shippable !== false)
|
||||
|
||||
Reference in New Issue
Block a user