feat: combine multiple orderrequests into one order
This commit is contained in:
@@ -373,23 +373,26 @@ Vue.component('warehouse-order-modal', {
|
||||
return;
|
||||
}
|
||||
|
||||
const orderRequest = JSON.parse(localStorage.getItem('WarehouseOrder_create'));
|
||||
if (!orderRequest) return;
|
||||
const orderRequests = JSON.parse(localStorage.getItem('WarehouseOrder_create'));
|
||||
if (!orderRequests) return;
|
||||
|
||||
const positions = JSON.parse(orderRequest.positions);
|
||||
this.order.positions = await Promise.all(positions.map(async p => {
|
||||
const distributor = (await axios.get(`${window.TT_CONFIG.BASE_PATH}/WarehouseOrder/getArticleDistributorData`,
|
||||
{params: {articleId: p.articleId}})).data[0];
|
||||
return {
|
||||
article: p.articleId,
|
||||
amount: p.amount,
|
||||
buyPrice: distributor.purchasePrice,
|
||||
distributorId: distributor.id,
|
||||
distributorArticleNumber: distributor.externalArticleNumber,
|
||||
verwendung: `${p.hasOwnProperty('purpose') ? p.purpose : ''} [Bestellwunsch: #${orderRequest.id}]`,
|
||||
linkedOrderRequestId: orderRequest.id
|
||||
};
|
||||
}));
|
||||
for (const orderRequest of orderRequests) {
|
||||
const positions = JSON.parse(orderRequest.positions);
|
||||
const parsedPositions = await Promise.all(positions.map(async p => {
|
||||
const distributor = (await axios.get(`${window.TT_CONFIG.BASE_PATH}/WarehouseOrder/getArticleDistributorData`,
|
||||
{params: {articleId: p.articleId}})).data[0];
|
||||
return {
|
||||
article: p.articleId,
|
||||
amount: p.amount,
|
||||
buyPrice: distributor.purchasePrice,
|
||||
distributorId: distributor.id,
|
||||
distributorArticleNumber: distributor.externalArticleNumber,
|
||||
verwendung: `${p.hasOwnProperty('purpose') ? p.purpose : ''} [Bestellwunsch: #${orderRequest.id}]`,
|
||||
linkedOrderRequestId: orderRequest.id
|
||||
};
|
||||
}));
|
||||
this.order.positions = [...this.order.positions, ...parsedPositions];
|
||||
}
|
||||
|
||||
localStorage.removeItem('WarehouseOrder_create');
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user