Create a Purchase Order

Use this method to create Purchase Orders based on Prebooks or Standalone Purchase Orders.

Valid Tokens: Company and Vendor.

Information

  • You can use vendorId or vendorCode but you cannot use both parameters at the same time. We recommend you to use the vendorId which can be obtained from the vendor.list API method.

  • If you use a Vendor token, the system will validate that the Prebook Lines processed really belong to the authenticated Vendor.

  • To create a Standalone PO, you must send the productDescription or productCode. In case you send a product code and the product description is invalid, the system will create a vendor product alias with the description sent.

  • If the multicurrency option is enabled, and your vendor has a different currency set up, the system will convert the cost in your company's currency, based on the exchange rate set up. 


Related Articles


Request


URL: https://api.kometsales.com/api/purchase.order.create

Method: POST

Content-Type: application/JSON

Input Parameters

authenticationToken (required)(string:50)

Komet Sales security token.


shipDate (required)(date)

Shipping date.

Date format: YYYY-MM-DD


vendorId (required)(integer:20)

Vendor or Grower ID.

You can get this value from vendor.list API method.

Does not apply to Vendor tokens.


vendorCode (required if vendorId is not given)(string:20)

Vendor or Grower code.

Does not apply to Vendor tokens.


companyLocationCode (required)(string:10)

Location code.

Only applies to Multi-Location Companies.


carrierId (optional)(integer:20)

Inbound Carrier ID.

You can get this value from the carrier.list API method.

This value is required if the company has the setting Mandatory Carriers on the POs.


carrierCode (required if carrierId is not given)(string:20) 

Inbound Carrier code.

This value is required if the company has the setting Mandatory Carriers on the POs.


AWB Number (optional)(number:4)

Last four digits of the AWB.

When this field is entered, the AWB will have Shipped status.

If the vendor has temporary AWB enabled, the system will automatically assign an AWB.


purchaseOrderNumber (optional)(string:10)

Purchase order number.

You may use this field to add the items to an existing PO.


purchaseOrderItems (required)(array)

Array containing the items that you want to add to the PO. 


prebookItemId (integer:20)

Prebook Line ID. 

You can get this value from the prebook.details.list API method. 

If this parameter is not included, the system will create a Purchase Order for Future Sales (if this feature is enabled).


vendorName (required if vendorId is not given)(string:200)

Vendor or Grower name.


productId (required)(integer:20)

Product Line ID.

You can get this value from the product.list API method.


productCode (required if productDescription is not given)(string:20)

Product code.

To create a Standalone PO, you must send the productDescription or productCode.


productDescription (required if productCode is not given)(string:20)

Product description.

To create a Standalone PO, you must send the productDescription or productCode.


boxes (required)(integer:10)

Number of boxes.


cost (required)(decimal:10,2)

Unit type according to unitType.

If you are using a Vendor token, the system will only accept the value of this field if your company has the Allow changing cost setting enabled.


boxTypeCode (required)(string:3):

Box type code.

Only applies to Prebooks in Units.


boxTypeId (required if boxTypeCode is not sent)(integer:10)

Box type ID. 

You can get this value from the boxtype.list API method.


bunches (required)(integer:10)

Bunches per box.

Only applies to products in Units.


unitType (required)(string:5)

Unit type.

Valid values: Stem or Bunch

Only applies to products in Units.


stemsBunch (required)(integer:10)

Stems per Bunch.

Only applies to products in Units.


Sample Request one: Company Token, Prebook in Boxes

{ "authenticationToken": "token_info_goes_here", "shipDate": "2017-07-01", "vendorId": 4234, "carrierCode": "DV", "purchaseOrderItems": [ { "prebookItemId": "8531402", "boxes": 1, "cost": 1.5 }, { "prebookItemId": "8531403", "boxes": 3, "cost": 1.8 } ] }

Sample Request two: Vendor Token, Prebook in Boxes

 { "authenticationToken": "token_info_goes_here", "shipDate": "07/01/2017", "carrierCode": "DV", "purchaseOrderItems": [ { "prebookItemId": "8531402", "boxes": 1, "boxTypeCode": "HB", "bunches": 10, "unitType": "Stem", "stemsBunch": 5 }, { "prebookItemId": "8531403", "boxes": 3, "boxTypeCode": "EB", "bunches": 15, "unitType": "Stem", "stemsBunch": 5 } ] }

Response


status (integer:1)

Transaction status.

Valid values: 1 = Success | 0 = Failure


items (array)

An array containing items in the Purchase Order.


status: (integer:1)

Transaction status.

1 = Success | 0 = Failure


message (string:500)

Transaction status description.


prebookItemId (integer:10)

Prebook item ID.


purchaseOrderId (integer:10)

Purchase Order ID.


purchaseOrderItemId (integer:10)

Purchase Order Item ID.


purchaseOrderNumber (string:10) 

Purchase Order Number.


Sample Response one: Company Token, Prebook in Boxes

{ "status": 1, "items": [ { "prebookItemId": 928342, "status": 1, "message": "The PO Item was successfully created.", "purchaseOrderId": 87820, "purchaseOrderNumber": "P007098", "purchaseOrderItemId": 282719 } ] }

Sample Response two: Vendor Token, Prebook in Boxes 

Peacock