getProductCostForSpecificAmount

Get FIFO unit cost for a specific amount of specific items you are planning to subtract from inventory.

API inspects all the batches that are currently in stock, calculates (according to FIFO rules) how many items should be discounted from which batch (starting with the oldest ones), and returns the weighted average cost of the resulting lot.

This API call is useful when you plan to make an inventory transaction (eg. a sale, transfer or inventory write-off), but want to know the exact total cost of the items before actually making the transaction.

You need to specify amount, because each batch may have a different cost. The amount that you require may have to be pulled from one or multiple batches, depending on how many items are left in each batch.

Please contact Erply support if you plan to use this API call. Your account may need updates or customizations to be applied.

Input parameters

Parameter name Description Possible value Required
warehouseID integer yes
productID# Product ID. You can ask cost for multiple products at once. Replace "#" with 1, 2, 3 etc. For example: productID1 and amount1, productID2 and amount2, etc. integer
amount# Product amount Decimal

Response

Field name Type Description
productID integer Product ID
amount Decimal (6 places) Requested amount
cost Decimal (6 places) Unit cost.
amountActuallyInStock Decimal (6 places) IF THERE IS NOT ENOUGH INVENTORY, API can only return a preliminary cost value! This is because the real cost will be determined by the next Purchase Invoice or Inventory Registration. If that is the case, costIsPreliminary will be set to 1 and amountActuallyInStock will tell the actual current stock quantity.
costIsPreliminary 0 or 1