Zum Hauptinhalt springen

Nachträgliche Anpassung der EK-Preise für Wareneingänge mit einem EK-Preis von 0,- €

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.

Bitte beachte, dass du immer ein Backup der Datenbank machen solltest, bevor du SQL-Queries auf deiner Datenbank ausführst. In diesem Fall ist vor allem ein Backup der Tabelle pickware_erp_stock_ledger_entries wichtig!

# 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 stockUPDATE s_plugin_pickware_stocks AS stocksINNER JOIN s_articles_details AS articleDetail ON articleDetail.id = stocks.articleDetailIdSET stocks.purchasePrice = articleDetail.purchasepriceWHERE 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 stockUPDATE s_plugin_pickware_stocks AS stocksINNER JOIN s_plugin_pickware_stocks AS parentStocks ON parentStocks.id = stocks.parentIdSET stocks.purchasePrice = parentStocks.purchasePriceWHERE stocks.changeAmount < 0;
Hat dies deine Frage beantwortet?