Sofern vor der Bestandsinitialisierung vergessen wurde, die Einkaufspreise für einzelne/alle Artikel zu setzen, wird der initiale physische Lagerbestand dieser Artikel mit einem Einkaufspreis von 0,- € bewertet. Dies führt ggf. dazu, dass der bewertete Warenbestand für diese Artikel niedriger ausfällt, als es tatsächlich der Fall sein sollte.
# Copy purchase price to stock entries that increase the stock
UPDATE pickware_erp_stock_ledger_entries AS stocks
INNER JOIN s_articles_details AS articleDetail
ON articleDetail.id = stocks.articleDetailId
SET stocks.purchasePrice = articleDetail.purchaseprice
WHERE
stocks.type IN (
'incoming',
'initialization',
'manual',
'purchase',
'stocktake'
)
AND (
stocks.purchasePrice = 0
OR stocks.purchasePrice IS NULL
)
AND stocks.changeAmount > 0;
# Apply purchase price to all children of stock entries that increase the stock
UPDATE pickware_erp_stock_ledger_entries AS stocks
INNER JOIN pickware_erp_stock_ledger_entries AS parentStocks
ON parentStocks.id = stocks.sourceLotEntryId
SET stocks.purchasePrice = parentStocks.purchasePrice
WHERE stocks.changeAmount < 0;
Solltest du eine Pickware ERP Version < 5.0.0 nutzen, verwende bitte das nachfolgende Skript:
# Copy purchase price to stock entries that increase the stock
UPDATE s_plugin_pickware_stocks AS stocks
INNER JOIN s_articles_details AS articleDetail
ON articleDetail.id = stocks.articleDetailId
SET stocks.purchasePrice = articleDetail.purchaseprice
WHERE
stocks.type IN (
'incoming',
'initialization',
'manual',
'purchase',
'stocktake'
)
AND (
stocks.purchasePrice = 0
OR stocks.purchasePrice IS NULL
)
AND stocks.changeAmount > 0;
# Apply purchase price to all children of stock entries that increase the stock
UPDATE s_plugin_pickware_stocks AS stocks
INNER JOIN s_plugin_pickware_stocks AS parentStocks
ON parentStocks.id = stocks.parentId
SET stocks.purchasePrice = parentStocks.purchasePrice
WHERE stocks.changeAmount < 0;