Search

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 writeoff), 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 nameDescriptionPossible valueRequired
warehouseIDInteger 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 amountDecimal

Response

Field nameTypeDescription
productIDIntegerProduct ID
amountDecimal (6 places)Requested amount
costDecimal (6 places)Unit cost.
amountActuallyInStockDecimal (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.
costIsPreliminary0 or 1