purchase.order.create

This method allows you to create Purchase Orders based on Prebooks or Standalone Purchase Orders.

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 obtain this value from vendor.list API method. If the token used belongs to a vendor, this field is optional and it will be ignored. 

  • vendorCode (required: if vendorId is not given)(string:20): vendor or grower code, only required if vendorId is not given. If the token used belongs to a vendor, this field is optional and it will be ignored. 

  • companyLocationCode (required: if the company is Multi-Location)(string: 10): Company location code. 

  • carrierId (optional)(integer:20): Carrier ID. The carrier entered must be Inbound. You can obtain this value from the carrier.list API method. This value could be required if the company turns on a setting that makes this value required on all the screens. 

  • carrierCode (optional)(string:20) : carrier code, if carrierId is not given. The carrier entered must be Inbound. This value could be required if the company turns on a setting that makes this value required on all the screens.

  • AWB Number (optional) (number:4): Last four digits of the AWB. When this field is entered, the AWB will have a 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 want to use this field if you want to use an existing PO to add these items. 

  • purchaseOrderItems (required)(array): Array of items that want to associate to the PO. 

    • prebookItemId (integer:20): Prebook Line Id. You can obtain 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 (in case this feature is enabled).

    • vendorName (optional)(string:200): vendor or grower name, if vendorId is not given.

    • productCode (To create PO Standalone you must send either the product description or code) (string:20): code of the product.

    • productDescription (To create PO Standalone you must send either the product description or code) (string:200): description of the product.

    • boxes (required)(integer:10): number of boxes.

    • cost (required) (decimal:10,2): when unitType is bunch you must use the bunch cost. When unitType is stem you must use the stem cost. If the token used belongs to a vendor, this field will be accepted if the vendor has the Allow changing cost option enabled.

    • boxTypeCode (required: if the Prebook is in Units)(string:3): code of the box type.

    • boxTypeId (required: if boxTypeCode is not sent)(integer:10): Id of the box type. You can obtain this value from the boxtype.list API method.

    • bunches (required: if the product is in Units) (integer:10): bunches per box.

    • unitType (required: if the product is in Units) (string:5): Stem or Bunch are the unique valid values.

    • stemsBunch (required: if the product is in Units)(integer:10): stems per bunch.

Information

  • You can use either vendorId or the 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.

  • Using a vendor token, the system will validate that the Prebook Lines processed really belong to the vendor authenticated.

  • To create Standalone PO, you must send the product description or the product code. 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.

Sample 1: 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 2: 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

Output

  • status (integer:1): transaction status. 1 for success or 0 for failure. Please notice that every PO item processed will have its own status. 

  • items (array)

    • status: (integer:1): transaction status. 1 for success or 0 for failure.

    • message (string:500): description of the status of the transaction.

    • prebookItemId (integer:10) ID of the prebook item that was added to the purchase order.

    • purchaseOrderId (integer:10) ID of the Purchase Order that was used during this transaction.

    • purchaseOrderItemId (integer:10) ID of the Purchase Order Item that was created during this transaction

    • purchaseOrderNumber (string:10) Purchase Order Number that was used during this transaction. 

Sample Response 1: 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 2: Vendor Token, Prebook in Boxes