Work Order Line Items Reference
Work Order Line Items specify each unit of work that the work order targets. Line items must reference a Service Task, and support fields such as description
, labor_cost
, parts_cost
, and subtotal
.
For more information about Work Orders and line items in general, please reference our Help Center docs.
Type
You must set the line item type to WorkOrderServiceTaskLineItem
Item
As mentioned above, each line item must reference a Service Task
. This association is called item
in Fleetio and it is polymorphic.
In order to create a line item that is associated with a Service Task with an id
of 12345
, you would set item_type
to ServiceTask
and item_id
to 12345
. Both fields are required.
Linking Issues
You can link one or more Issues to a Work Order Line Item by passing an array of integers called issue_ids
inside the request body. Each integer in the array should be the ID of an Issue you want to link to the Line Item.
Including Parts and Labor Costs
Line items allow for the specification of cost for both parts and labor. There are two ways to denote these costs for each line item, either by specifying the cost directly, or by adding parts and labor sub line items to the line item in question.
To add costs directly to a line item, pass a value to the parts_cost
, labor_cost
and/or subtotal
fields. To set subtotal
directly on a line item, you must not set parts_cost
and labor_cost
. If you do, subtotal will be calculated as parts + labor.
Adding a Line Item with Part and Labor Sub Line Items
Each line item can have many sub line items (or none at all), which specify any parts used or any labor performed.
Sub line items support 3 properties: item
, unit_cost
, and quantity
.
The total cost for the sub line item is calculated as unit_cost * quantity
. The item
property for sub line items works exactly the same way as it does for line items. There is an item_type
field and an item_id
field. Supported values for item_type
are Part
(denotes a part line item), and Contact
(denotes a labor line item).
Below is an example of adding a line item with a part and a labor sub line item:
curl https://secure.fleetio.com/api/v2/work_orders/123/work_order_line_items \
-H 'Authorization: Token token="API_KEY"' \
-H "Account-Token: ACCOUNT_TOKEN" \
-H "Content-Type: application/json" \
-X POST -d '{
"type": "WorkOrderServiceTaskLineItem",
"item_type": "ServiceTask",
"item_id": 12345,
"description": "Replacing brake pads",
"issue_ids": [321251, 987847],
"work_order_sub_line_items_attributes":[
{
"item_type": "Part",
"item_id": 101,
"unit_cost": 9.95,
"quantity": 2
},
{
"item_type": "Contact",
"item_id": 4455,
"unit_cost": 24,
"quantity": 0.5
}
]
}'
Work Order Line Item Fields
Field | Type | Description |
---|---|---|
type | string (required, string) | Used to denote what type of line item this is. Currently, the only valid value is WorkOrderServiceTaskLineItem . |
item_type | string (required, editable) | Used in conjunction with item_id denotes the class name for the item association. Valid values are ServiceTask . |
item_id | integer (required, editable) | Used in conjunction with item_id , denotes the foreign key for the item association. This is typically the Service Task ID. |
description | text (optional, editable) | Free text field for item description. |
issue_ids[] | integer (optional, editable) | An array of Issue IDs that you want the line item to be linked to. |
labor_cost | double (optional, editable) | Total labor cost for this line item. If there are labor line items present, the labor cost will be calculated from the sum of their totals and this value will be overwritten. |
parts_cost | double (optional, editable) | Total parts cost for this line item. If there are part line items present, the labor cost will be calculated from the sum of their totals and this value will be overwritten. |
subtotal | double (optional, editable) | Subtotal for this line item. If parts or labor are present and non zero, this value is ignored. |
Work Order Sub Line Item Fields
Field | Description |
---|---|
item_type | string (required, editable) |
item_id | integer (required, editable) |
unit_cost | double (optional, editable) |
quantity | double (optional, editable) |
If your account has been setup to use LIFO/FIFO, in addition to the fields listed above you must also provide inventory_set_id
and part_location_detail_id
for any part line items. Additional information available here.