Purchase Order Line Items Reference
Purchase Order Line Items contain a part, along with its quantity and unit cost. You may only create, edit, and delete line items if the Purchase Order's state is in one of the following states:
draft
pending_approval
rejected
If you try to make any changes to a Line Item belonging to a Purchase Order in another state, you will get a HTTP 403 (Forbidden) error.
After you create a Purchase Order, it will be in a draft
state. Once you have the Purchase Order's number, you can hit the /purchase_orders/:number/purchase_order_line_items
url to create, edit, or delete line items.
Adding a Line Item
Below is an example of creating a line item for a Purchase Order:
curl https://secure.fleetio.com/api/v1/purchase_orders/123/purchase_order_line_items \
-H 'Authorization: Token token="API_KEY"' \
-H "Account-Token: ACCOUNT_TOKEN" \
-H "Content-Type: application/json" \
-X POST -d '{
"part_id": 12345,
"quantity": 12,
"unit_cost": 44.56",
}'
In response, you will get something like:
{
"id": 29152,
"part_id": 12345,
"quantity": 12,
"total_quantity_received": null,
"part_number": "Your part",
"unit_cost": 44.56,
"subtotal": 534.72,
"created_at": "2017-08-10T13:48:14.401-05:00",
"updated_at": "2017-08-10T13:49:39.689-05:00"
}
Editing a Line Item
If you change your mind about the line item's quantity, you can perform a PATCH
with the new line item id:
curl https://secure.fleetio.com/api/v1/purchase_orders/123/purchase_order_line_items/29152 \
-H 'Authorization: Token token="API_KEY"' \
-H "Account-Token: ACCOUNT_TOKEN" \
-H "Content-Type: application/json" \
-X PATCH -d '{
"quantity": 1
}'
Removing a Line Item
And finally, if you decided you don't want this line item anymore, just DELETE
it:
curl https://secure.fleetio.com/api/v1/purchase_orders/123/purchase_order_line_items/29153 \
-H 'Authorization: Token token="API_KEY"' \
-H "Account-Token: ACCOUNT_TOKEN" \
-H "Content-Type: application/json" \
-X DELETE