fixInventoryBatches

Fixes a product's list of remaining batches, so that inventory tracking for the item would work correctly from this point on.

The product could be experiencing two kinds of problems:

  1. The list of remaining batches does not match the current inventory quantity. For example, the store has 5 items in stock, but the list of batches has a total quantity of 4 or 6, or there are no remaining batches at all.
  2. Some "inventory out" transactions have been incorrectly marked as "cost is not known yet". For example, the quantity in stock is positive, but there are still transactions with a "cost not known yet" flag. Or the quantity in stock is -2 and the total amount of "cost not known" transactions is larger or smaller than that.

These issues do not fix themselves over time. The error constantly propagates and eventually, all cost management of that product has a "shift" in it.

For example, if the item is in stock, but some transactions still have the "cost not known yet" flag, and the store receives a new batch, part of that batch will go towards covering those transactions — and the remaining quantity of the batch will again be smaller than it is supposed to be.

The call does not change historic cost of goods sold, but it ensures that future transactions will register correctly.

Calling fixInventoryBatches might help if the "in" and "out" costs in back office are weird (not correct according to FIFO). But if the remaining inventory quantity is wrong (on the "Stock levels" tab in back office), see Inventory Transaction API call "fixBrokenQuantities" instead.

Input parameters

Parameter name Description Possible value Required
productIDs Comma-separated list of product IDs that Erply must check. string yes

Response

Field name Type Description
productID integer Product ID.
status string "NO_ISSUES" or "FIXED".
changes array List of fixes made, one record per warehouse.

Field nameTypeDescription
productIDintegerProduct ID
warehouseIDintegerWarehouse ID
quantityInStocknumberCurrent quantity in stock
oldQuantityInBatchesnumberTotal amount in available batches before fixing.
newQuantityInBatchesnumberTotal amount in available batches after fixing. Must match quantity in stock if quantity in stock is positive; otherwise must be 0.
oldPendingQuantitynumberTotal amount of "cost not known yet" transactions before fixing.
newPendingQuantitynumberTotal amount of "cost not known yet" transactions after fixing. Must be 0 if quantity in stock is positive; otherwise, must equal the (negative) quantity in stock.
errorstringAn error message if the fix could not be completed. For example, API avoids splitting an inventory transfer row into two transactions.