Add inventory costs

distru-add-inventory-costsWrite

Adds costs to one package, batch or product, spread over its quantity on hand.

Inputs

Every tool also takes the common inputs.

FieldTypeRequiredDescription
packageIdstringNoSend exactly one of packageId, batchId or productId. Resolve via distru-search-packages.
batchIdstringNoA batch of a batch-tracked product. Resolve via distru-search-batches.
productIdstringNoA product-tracked product; package- and batch-tracked products take costs per package or batch. Resolve via distru-search-products.
locationIdsstring[]NobatchId or productId only: spread the costs over the stock at these locations only; default all. Resolve via distru-search-locations.
expectedQuantitystring or numberYesThe record's quantity on hand as you last read it, in its unit type; refused when it has changed since. packageId: quantity from distru-get-package. batchId: quantity from distru-get-batch. productId: quantityActive from distru-get-product. With locationIds: the sum of those locations' activeQuantitiesByLocation.
costsobject[]Yes
costs[].costTypeIdstringYesResolve via distru-search-lookups (type COST_TYPE).
costs[].quantitystring or numberYesGreater than 0, in the cost type's unit type.
costs[].costPerUnitstring or numberNoDollars per unit of the cost type's unit type. Defaults to the cost type's costPerUnit; refused when the cost type's allowInlineEdits is false.
costs[].descriptionstringNo

Output

This tool returns one of 3 shapes, depending on its inputs.

Presence on a nested field assumes its parent exists.

Result with package

FieldTypePresence
costsobject[]Always
costs[].namestringAlways
costs[].descriptionstringCan be null
costs[].costTypeobjectCan be null
costs[].costType.idstringAlways
costs[].costType.namestringAlways
costs[].createdByobjectCan be null
costs[].createdBy.idstringAlways
costs[].createdBy.fullNamestringAlways
costs[].insertedAtstringAlways
costs[].originobjectAlways
costs[].origin.typeenum
ASSEMBLYBIOTRACK_ADJUSTMENTBIOTRACK_MANIFEST_RECEIVEDBREAKDOWNCOST_ENTRYMETRC_ADJUSTMENTMETRC_TRANSFER_RECEIVEDOTHERPACKAGE_IMPORTPLANT_BATCH_PACKAGINGPURCHASE_ORDERSTOCK_ADJUSTMENT
Always
costs[].origin.purchaseOrderobjectCan be null
costs[].origin.purchaseOrder.idstringAlways
costs[].origin.purchaseOrder.purchaseNumberstringAlways
costs[].origin.assemblyobjectCan be null
costs[].origin.assembly.idstringAlways
costs[].origin.assembly.numberstringAlways
costs[].origin.breakdownobjectCan be null
costs[].origin.breakdown.breakdownNumberstringCan be null
costs[].recordedOnobjectAlways
costs[].recordedOn.typeenum
PACKAGEBATCHPRODUCTHARVESTPLANTPLANT_BATCHMULTIPLE_PLANTSNONE
Always
costs[].recordedOn.productobjectCan be null
costs[].recordedOn.product.idstringAlways
costs[].recordedOn.product.namestringAlways
costs[].recordedOn.product.skustringAlways
costs[].recordedOn.packageobjectCan be null
costs[].recordedOn.package.idstringAlways
costs[].recordedOn.package.metrcLabelstringAlways
costs[].recordedOn.batchobjectCan be null
costs[].recordedOn.batch.idstringAlways
costs[].recordedOn.batch.namestringAlways
costs[].recordedOn.harvestobjectCan be null
costs[].recordedOn.harvest.namestringAlways
costs[].recordedOn.plantobjectCan be null
costs[].recordedOn.plant.labelstringCan be null
costs[].recordedOn.plant.strainNamestringCan be null
costs[].recordedOn.plantBatchobjectCan be null
costs[].recordedOn.plantBatch.namestringAlways
costs[].recordedOn.plantBatch.strainNamestringCan be null
costs[].recordedOn.multiplePlantsobjectCan be null
costs[].recordedOn.multiplePlants.summarystringAlways
costs[].recordedOn.multiplePlants.detailsstringAlways
costs[].quantitystringAlways
costs[].costQuantitystringAlways
costs[].unitTypeobjectAlways
costs[].unitType.idstringAlways
costs[].unitType.namestringAlways
costs[].costPerUnitstringCan be null
costs[].totalCoststringCan be null
packageobjectAlways
package.idstringAlways
package.metrcLabelstringAlways
package.quantitystringAlways
package.quantityCoststringCan be null

Result with batch

FieldTypePresence
costsobject[]Always
costs[].namestringAlways
costs[].descriptionstringCan be null
costs[].costTypeobjectCan be null
costs[].costType.idstringAlways
costs[].costType.namestringAlways
costs[].createdByobjectCan be null
costs[].createdBy.idstringAlways
costs[].createdBy.fullNamestringAlways
costs[].insertedAtstringAlways
costs[].originobjectAlways
costs[].origin.typeenum
ASSEMBLYBIOTRACK_ADJUSTMENTBIOTRACK_MANIFEST_RECEIVEDBREAKDOWNCOST_ENTRYMETRC_ADJUSTMENTMETRC_TRANSFER_RECEIVEDOTHERPACKAGE_IMPORTPLANT_BATCH_PACKAGINGPURCHASE_ORDERSTOCK_ADJUSTMENT
Always
costs[].origin.purchaseOrderobjectCan be null
costs[].origin.purchaseOrder.idstringAlways
costs[].origin.purchaseOrder.purchaseNumberstringAlways
costs[].origin.assemblyobjectCan be null
costs[].origin.assembly.idstringAlways
costs[].origin.assembly.numberstringAlways
costs[].origin.breakdownobjectCan be null
costs[].origin.breakdown.breakdownNumberstringCan be null
costs[].recordedOnobjectAlways
costs[].recordedOn.typeenum
PACKAGEBATCHPRODUCTHARVESTPLANTPLANT_BATCHMULTIPLE_PLANTSNONE
Always
costs[].recordedOn.productobjectCan be null
costs[].recordedOn.product.idstringAlways
costs[].recordedOn.product.namestringAlways
costs[].recordedOn.product.skustringAlways
costs[].recordedOn.packageobjectCan be null
costs[].recordedOn.package.idstringAlways
costs[].recordedOn.package.metrcLabelstringAlways
costs[].recordedOn.batchobjectCan be null
costs[].recordedOn.batch.idstringAlways
costs[].recordedOn.batch.namestringAlways
costs[].recordedOn.harvestobjectCan be null
costs[].recordedOn.harvest.namestringAlways
costs[].recordedOn.plantobjectCan be null
costs[].recordedOn.plant.labelstringCan be null
costs[].recordedOn.plant.strainNamestringCan be null
costs[].recordedOn.plantBatchobjectCan be null
costs[].recordedOn.plantBatch.namestringAlways
costs[].recordedOn.plantBatch.strainNamestringCan be null
costs[].recordedOn.multiplePlantsobjectCan be null
costs[].recordedOn.multiplePlants.summarystringAlways
costs[].recordedOn.multiplePlants.detailsstringAlways
costs[].quantitystringAlways
costs[].costQuantitystringAlways
costs[].unitTypeobjectAlways
costs[].unitType.idstringAlways
costs[].unitType.namestringAlways
costs[].costPerUnitstringCan be null
costs[].totalCoststringCan be null
batchobjectAlways
batch.idstringAlways
batch.namestringAlways
batch.quantitystringAlways
batch.activeQuantityCoststringCan be null

Result with product

FieldTypePresence
costsobject[]Always
costs[].namestringAlways
costs[].descriptionstringCan be null
costs[].costTypeobjectCan be null
costs[].costType.idstringAlways
costs[].costType.namestringAlways
costs[].createdByobjectCan be null
costs[].createdBy.idstringAlways
costs[].createdBy.fullNamestringAlways
costs[].insertedAtstringAlways
costs[].originobjectAlways
costs[].origin.typeenum
ASSEMBLYBIOTRACK_ADJUSTMENTBIOTRACK_MANIFEST_RECEIVEDBREAKDOWNCOST_ENTRYMETRC_ADJUSTMENTMETRC_TRANSFER_RECEIVEDOTHERPACKAGE_IMPORTPLANT_BATCH_PACKAGINGPURCHASE_ORDERSTOCK_ADJUSTMENT
Always
costs[].origin.purchaseOrderobjectCan be null
costs[].origin.purchaseOrder.idstringAlways
costs[].origin.purchaseOrder.purchaseNumberstringAlways
costs[].origin.assemblyobjectCan be null
costs[].origin.assembly.idstringAlways
costs[].origin.assembly.numberstringAlways
costs[].origin.breakdownobjectCan be null
costs[].origin.breakdown.breakdownNumberstringCan be null
costs[].recordedOnobjectAlways
costs[].recordedOn.typeenum
PACKAGEBATCHPRODUCTHARVESTPLANTPLANT_BATCHMULTIPLE_PLANTSNONE
Always
costs[].recordedOn.productobjectCan be null
costs[].recordedOn.product.idstringAlways
costs[].recordedOn.product.namestringAlways
costs[].recordedOn.product.skustringAlways
costs[].recordedOn.packageobjectCan be null
costs[].recordedOn.package.idstringAlways
costs[].recordedOn.package.metrcLabelstringAlways
costs[].recordedOn.batchobjectCan be null
costs[].recordedOn.batch.idstringAlways
costs[].recordedOn.batch.namestringAlways
costs[].recordedOn.harvestobjectCan be null
costs[].recordedOn.harvest.namestringAlways
costs[].recordedOn.plantobjectCan be null
costs[].recordedOn.plant.labelstringCan be null
costs[].recordedOn.plant.strainNamestringCan be null
costs[].recordedOn.plantBatchobjectCan be null
costs[].recordedOn.plantBatch.namestringAlways
costs[].recordedOn.plantBatch.strainNamestringCan be null
costs[].recordedOn.multiplePlantsobjectCan be null
costs[].recordedOn.multiplePlants.summarystringAlways
costs[].recordedOn.multiplePlants.detailsstringAlways
costs[].quantitystringAlways
costs[].costQuantitystringAlways
costs[].unitTypeobjectAlways
costs[].unitType.idstringAlways
costs[].unitType.namestringAlways
costs[].costPerUnitstringCan be null
costs[].totalCoststringCan be null
productobjectAlways
product.idstringAlways
product.namestringAlways
product.quantityActivestringAlways
product.activeQuantityCoststringCan be null
What the AI reads

Adds costs to one package, batch or product, spread over its quantity on hand. Each cost adds costPerUnit × quantity to the record's total cost, not to each unit. Not idempotent: calling twice adds the costs twice. Distru cost accounting only; nothing is sent to Metrc. Returns the added costs in the get tools' cost breakdown shape, and the record with its total cost after the change: quantityCost (package) or activeQuantityCost (batch, product), not per unit; null when the caller cannot view costs.