Create PO

Estimated reading: 3 minutes

Description :

Use this API to create a new Purchase Order (PO) with the provided details.

URL :

				
					 http://<server-ip-address>/custom_api/capex_track_purchase_order/create
				
			
Method: POST
URL Parameters Required
format=json (In the future, maybe change to default)
Yes

Form Data Parameters :

Key Value
business_unit_name:
Almiranta1 / Aurora
request_number
AU-2020-4133
PO_number:
1
vendor_name
sdfsddf
vendor_number:
sdfsdf
PO_amount
5.85555
vendor_currency
USD
capex_to_vendor_currency_rate
1
committed
858
expense_type
Capital Expenditures

Header Parameters :

Authorization :

				
					Bearer <Token>
				
			

Success Response :

Code: 200

Content :

				
					{
  "code": 200,
  "message": "success",
  "data": []
}

				
			

Error Response

Code: 401 BAD REQUEST

Content :

				
					json{
  "code": 401,
  "message": "fail",
  "data": {
    "error": "Invalid API Token"
  }
}

				
			

OR

				
					{
  "code": 400,
  "message": "fail",
  "data": {
    "[field_name]": [
      "This field is missing."
    ]
  }
}

				
			

Notes :

Explanation :

The API allows you to create a new Purchase Order (PO) by submitting the necessary details as form data parameters. These details include business unit name, request number, PO number, description, vendor name, vendor number, PO amount, vendor currency, conversion rate from capex to vendor currency, committed amount, status of the PO, and the expense type.

Sample Code :

JavaScript (Using Fetch API) :

				
					const apiUrl = 'http://<server-ip-address>/custom_api/capex_track_purchase_order/create';
const token = '<Token>';

const formData = new FormData();
formData.append('business_unit_name', 'Almiranta1 / Aurora');
formData.append('request_number', 'AU-2020-4133');
formData.append('PO_number', '1');
formData.append('description', 'sdfsdf');
formData.append('vendor_name', 'sdfsddf');
formData.append('vendor_number', 'sdfsdf');
formData.append('PO_amount', '5.85555');
formData.append('vendor_currency', 'USD');
formData.append('capex_to_vendor_currency_rate', '1');
formData.append('committed', '858');
formData.append('status', 'Open');
formData.append('expense_type', 'Capital Expenditures');

fetch(apiUrl + '?format=json', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`
  },
  body: formData
})
.then(response => response.json())
.then(data => {
  // Process the response data here
})
.catch(error => {
  // Handle error
});

				
			
PHP (Using cURL) :
				
					<?php
$apiUrl = 'http://<server-ip-address>/custom_api/capex_track_purchase_order/create';
$token = '<Token>';

$data = array(
  'business_unit_name' => 'Almiranta1 / Aurora',
  'request_number' => 'AU-2020-4133',
  'PO_number' => '1',
  'description' => 'sdfsdf',
  'vendor_name' => 'sdfsddf',
  'vendor_number' => 'sdfsdf',
  'PO_amount' => '5.85555',
  'vendor_currency' => 'USD',
  'capex_to_vendor_currency_rate' => '1',
  'committed' => '858',
  'status' => 'Open',
  'expense_type' => 'Capital Expenditures'
);

$ch = curl_init($apiUrl . '?format=json');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$response = curl_exec($ch);

if (!$response) {
  // Handle cURL error
}

$data = json_decode($response, true);

if (isset($data['code']) && $data['code'] === 200) {
  // Process the response data here
} else {
  // Handle API error
}

curl_close($ch);
?>

				
			
Note :
Share this Doc

Create PO

Or copy link

CONTENTS