Megaventory API v2017a

<back to all web services

WorkOrderAllocateMaterials

The following routes are available for this service:
POST/WorkOrder/WorkOrderAllocateMaterialsAllocates materials to a work order.Uses your API Key and allocates materials to the Work Order specified by the WorkOrderId. WorkOrderAllocateMaterials field contains all the information for the materials to be allocated: the ProductSKU and the AllocateQuantity fields are mandatory. If the material contains serial and/or batch numbers, use the AllocateSerialNumbers and the AllocateBatchNumbers field to specify the information of the material.

AutoInsertBatchNumbersToProductRows: this field is used to automatically attach batch numbers to the material that is being allocated, depending on the order that you have selected (e.g. if you want to attach first the batch numbers that have the closest expiry date, give this field the value ByExpiryDate).

Examples:



A.

Allocate Materials for Work Order with Id 67795.

Value:

{
  "WorkOrderId": 67795,
  "Comments": "Material Allocation",
  "WorkOrderAllocateMaterials": [
    {
      "ProductSKU": "Product 1",
      "AllocateQuantity": 2
    }
  ]
}  


Response:

{
  "mvWorkOrder": {
    "WorkOrderId": 67795,
    "WorkOrderTypeId": -8,
    "WorkOrderFinishedGoodTypeId": -9,
    "WorkOrderTypeAbbreviation": "WO",
    "WorkOrderTypeDescription": "Work order",
    "WorkOrderNo": "44",
    "WorkOrderFinishedGoodSKU": "Finished Good 1",
    "WorkOrderStartDate": "/Date(1684184400000-0000)/",
    "WorkOrderDueDate": "/Date(-62135596800000-0000)/",
    "WorkOrderPriority": "Medium",
    "WorkOrderCurrencyCode": "USD",
    "WorkOrderInventoryLocationID": 4442,
    "WorkOrderComments": "",
    "WorkOrderTags": "",
    "WorkOrderReferenceNo": "",
    "WorkOrderReferenceApplication": "",
    "TopLevelWorkOrderId": 0,
    "WorkOrderOrderedQuantity": 15,
    "WorkOrderReceivedQuantity": 0,
    "WorkOrderTotalMaterialCost": 8.283835057,
    "WorkOrderTotalLabourCost": 0,
    "WorkOrderTotalOverheadCost": 0,
    "WorkOrderFinishedGoodUnitCost": 4.141917529,
    "WorkOrderDetails": [
      {
        "WorkOrderBOMRowProductSKU": "batch-product",
        "WorkOrderBOMRowProductDescription": "Product that requires batch numbers",
        "WorkOrderBOMRowProductVariant": "",
        "WorkOrderBOMRowOrderedQuantity": 15,
        "WorkOrderBOMRowTotalAllocatedQuantity": 0,
        "WorkOrderBOMRowProductQuantityUnit": "",
        "WorkOrderBOMRowRemarks": "",
        "WorkOrderRowAllocatedDetails": [
          {
            "WorkOrderBOMRowAllocatedQuantity": 2,
            "WorkOrderBOMRowAllocatedDateTime": "/Date(1685484867053-0000)/",
            "WorkOrderBOMRowAllocatedDateTimeFormatted": ""
          }
        ]
      },
      {
        "WorkOrderBOMRowProductSKU": "Product 1",
        "WorkOrderBOMRowProductDescription": "Product Description",
        "WorkOrderBOMRowProductVariant": "",
        "WorkOrderBOMRowOrderedQuantity": 15,
        "WorkOrderBOMRowTotalAllocatedQuantity": 0,
        "WorkOrderBOMRowProductQuantityUnit": "Kg",
        "WorkOrderBOMRowRemarks": "",
        "WorkOrderRowAllocatedDetails": [
          {
            "WorkOrderBOMRowAllocatedQuantity": 2,
            "WorkOrderBOMRowAllocatedDateTime": "/Date(1685484948599+0300)/",
            "WorkOrderBOMRowAllocatedDateTimeFormatted": ""
          }
        ]
      }
    ],
    "WorkOrderStatus": "InProcess",
    "WorkOrderCreationDate": "/Date(1684225634023-0000)/",
    "WorkOrderLastUpdatedDate": "/Date(1685484948816+0300)/"
  },
  "ResponseStatus": {
    "ErrorCode": "0"
  },
  "entityID": 67795
}


B.

Allocate Materials when product requires Batch Numbers for Work Order with Id 67795 .

Value:

{
  "WorkOrderId": 67795,
  "Comments": "Material Allocation",
  "WorkOrderAllocateMaterials": [
    {
      "ProductSKU": "batch-product",
      "AllocateQuantity": 2,
      "AllocateBatchNumbers": [
        {
          "BatchNumberName": "bn2",
          "Quantity": 2
        }
      ]
    }
  ]
}  


Response:

{
  "mvWorkOrder": {
    "WorkOrderId": 67795,
    "WorkOrderTypeId": -8,
    "WorkOrderFinishedGoodTypeId": -9,
    "WorkOrderTypeAbbreviation": "WO",
    "WorkOrderTypeDescription": "Work order",
    "WorkOrderNo": "44",
    "WorkOrderFinishedGoodSKU": "Finished Good 1",
    "WorkOrderStartDate": "/Date(1684184400000-0000)/",
    "WorkOrderDueDate": "/Date(-62135596800000-0000)/",
    "WorkOrderPriority": "Medium",
    "WorkOrderCurrencyCode": "USD",
    "WorkOrderInventoryLocationID": 4442,
    "WorkOrderComments": "",
    "WorkOrderTags": "",
    "WorkOrderReferenceNo": "",
    "WorkOrderReferenceApplication": "",
    "TopLevelWorkOrderId": 0,
    "WorkOrderOrderedQuantity": 15,
    "WorkOrderReceivedQuantity": 0,
    "WorkOrderTotalMaterialCost": 11.611548184,
    "WorkOrderTotalLabourCost": 0,
    "WorkOrderTotalOverheadCost": 0,
    "WorkOrderFinishedGoodUnitCost": 5.805774092,
    "WorkOrderDetails": [
      {
        "WorkOrderBOMRowProductSKU": "batch-product",
        "WorkOrderBOMRowProductDescription": "Product that requires batch numbers",
        "WorkOrderBOMRowProductVariant": "",
        "WorkOrderBOMRowOrderedQuantity": 15,
        "WorkOrderBOMRowTotalAllocatedQuantity": 0,
        "WorkOrderBOMRowProductQuantityUnit": "",
        "WorkOrderBOMRowRemarks": "",
        "WorkOrderRowAllocatedDetails": [
          {
            "WorkOrderBOMRowAllocatedQuantity": 2,
            "WorkOrderBOMRowAllocatedDateTime": "/Date(1685485280514+0300)/",
            "WorkOrderBOMRowAllocatedDateTimeFormatted": ""
          },
          {
            "WorkOrderBOMRowAllocatedQuantity": 2,
            "WorkOrderBOMRowAllocatedDateTime": "/Date(1685484867053-0000)/",
            "WorkOrderBOMRowAllocatedDateTimeFormatted": ""
          }
        ]
      },
      {
        "WorkOrderBOMRowProductSKU": "Product 1",
        "WorkOrderBOMRowProductDescription": "Product Description",
        "WorkOrderBOMRowProductVariant": "",
        "WorkOrderBOMRowOrderedQuantity": 15,
        "WorkOrderBOMRowTotalAllocatedQuantity": 0,
        "WorkOrderBOMRowProductQuantityUnit": "Kg",
        "WorkOrderBOMRowRemarks": "",
        "WorkOrderRowAllocatedDetails": [
          {
            "WorkOrderBOMRowAllocatedQuantity": 2,
            "WorkOrderBOMRowAllocatedDateTime": "/Date(1685484948600-0000)/",
            "WorkOrderBOMRowAllocatedDateTimeFormatted": ""
          }
        ]
      }
    ],
    "WorkOrderStatus": "InProcess",
    "WorkOrderCreationDate": "/Date(1684225634023-0000)/",
    "WorkOrderLastUpdatedDate": "/Date(1685485280643+0300)/"
  },
  "ResponseStatus": {
    "ErrorCode": "0"
  },
  "entityID": 67795
}

 

To override the Content-type in your clients HTTP Accept Header, append the .json suffix or ?format=json

To embed the response in a jsonp callback, append ?callback=myCallback

HTTP + JSON

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /json/reply/WorkOrderAllocateMaterials HTTP/1.1 
Host: api.megaventory.com 
Content-Type: application/json
Content-Length: length

{"APIKEY":"String","WorkOrderId":0,"Comments":"String","WorkOrderAllocateMaterials":[{"ProductSKU":"String","AllocateQuantity":0,"AllocateSerialNumbers":["String"],"AllocateBatchNumbers":[{"BatchNumberName":"String","ExpiryDate":"\/Date(-62135596800000-0000)\/","Quantity":0}]}],"AutoInsertBatchNumbersToProductRows":"Undefined"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"mvWorkOrder":{"WorkOrderId":0,"WorkOrderTypeId":0,"WorkOrderFinishedGoodTypeId":0,"WorkOrderTypeAbbreviation":"String","WorkOrderTypeDescription":"String","WorkOrderNo":"String","WorkOrderFinishedGoodSKU":"String","WorkOrderStartDate":"\/Date(-62135596800000-0000)\/","WorkOrderDueDate":"\/Date(-62135596800000-0000)\/","WorkOrderPriority":"Medium","WorkOrderCurrencyCode":"String","WorkOrderInventoryLocationID":0,"WorkOrderComments":"String","WorkOrderTags":"String","WorkOrderReferenceNo":"String","WorkOrderReferenceApplication":"String","TopLevelWorkOrderId":0,"WorkOrderOrderedQuantity":0,"WorkOrderReceivedQuantity":0,"WorkOrderTotalMaterialCost":0,"WorkOrderTotalLabourCost":0,"WorkOrderTotalOverheadCost":0,"WorkOrderFinishedGoodUnitCost":0,"WorkOrderDetails":[{"WorkOrderBOMRowProductSKU":"String","WorkOrderBOMRowProductDescription":"String","WorkOrderBOMRowProductVariant":"String","WorkOrderBOMRowOrderedQuantity":0,"WorkOrderBOMRowTotalAllocatedQuantity":0,"WorkOrderBOMRowProductQuantityUnit":"String","WorkOrderBOMRowRemarks":"String","WorkOrderRowAllocatedDetails":[{"WorkOrderBOMRowAllocatedQuantity":0,"WorkOrderBOMRowAllocatedDateTime":"\/Date(-62135596800000-0000)\/","WorkOrderBOMRowAllocatedDateTimeFormatted":"String","WorkOrderBOMRowAllocatedSerialNumbers":["String"],"WorkOrderBOMRowAllocatedBatchNumbers":[{"BatchNumberName":"String","ExpiryDate":"\/Date(-62135596800000-0000)\/","AssignedQTYInDetail":0}]}]}],"WorkOrderStatus":"Pending","WorkOrderCreationDate":"\/Date(-62135596800000-0000)\/","WorkOrderLastUpdatedDate":"\/Date(-62135596800000-0000)\/"},"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String"}]},"entityID":0,"InternalErrorCode":"String"}