This section describes the API for accessing the organisation's expenses. This will include all of the expenses from the organisation that the authenticated expense has access to.
This API route will return a paginated list of all of the expenses that belong to the organisation.
The index endpoint can be used as a reliable form of searching, as search results are paginated, and related resources of the expense are also searched to increase the effeciveness of the search.
This resource requires authorisation. Please read the documentation on authorisation.
GET https://api.dailys.nz/api/v1/expenses
Parameter | Type | Description |
---|---|---|
sortKey | string | The sort key specifies which resource attribute you want to search by. |
sortAsc | integer | The sort asc defines if sorting should be ascending, accepts: 0 or 1 . |
query | string | The search term the expense has provided, to refine results. |
page | integer | The page number requested; used for pagination. |
limit | integer | The number of resrouces per page; maximum: 100 minimum: 1 |
date
, name
, updated_at
{
"current_page": 1,
"data": [
{
"id": 1,
"date": "2001-01-01",
"name": "Coffee",
"quantity": 5,
"notes": null,
"chargeable": 1,
"total_charge": 1750,
"unit_charge": 350,
"unit": "cup",
"total_cost": 0,
"tax": "includes",
"tax_rate": 0.15,
"currency": "NZD",
"created_at": "2000-01-01 00:00:00",
"updated_at": "2000-01-01 00:00:00",
"original_total_charge": 0,
"original_unit_charge": 0,
"original_currency": "NZD",
"exchange_rate": 0,
"charge": {
"id": 1,
"name": "Coffee",
"charge": 350,
"unit": "cup",
"currency": "NZD",
"created_at": "2000-01-01 00:00:00",
"updated_at": "2000-01-01 00:00:00",
"deleted": false
},
"project": {
"id": 1,
"status": "complete",
"name": "Example Project",
"code": "1000",
"description": "Here is an example project.",
"currency": "NZD",
"increment": 15,
"budget": null,
"budget_type": null,
"start_date": "2000-01-01",
"end_date": null,
"created_at": "2000-01-01 00:00:00",
"updated_at": "2000-01-01 00:00:00",
"type": "client",
"deleted": false
}
},
...
],
"from": 1,
"last_page": 1,
"next_page_url": null,
"path": "https://api.dailys.nz/api/v1/expenses",
"per_page": 100,
"prev_page_url": null,
"to": 100,
"total": 1000
}
This API route will allow you to store a new expense entry. There are required fields, as the resource does not already exist. There as some business rules associated with making expense entries:
This resource requires authorisation. Please read the documentation on authorisation.
POST https://api.dailys.nz/api/v1/expenses
Parameter | Required | Type | Description |
---|---|---|---|
project_id | required | integer | The ID of the project that the expense entry should log to. |
charge_id | optional | integer | The ID of the chanrge that the expense entry should use. |
date | required | date | The date the expense entry should refer to. These can be made in advance. |
name | required_without:charge_id | string | The name of the one-off charge. |
quantity | required_with:charge_id | integer | The number of pre-defined charges for the expense entry. |
`chargable | required | boolean | Determines if the expense should be charged to the client, which will appear on an invoice. |
unit_charge | required_without:charge_id | integer | The charge amount of each unit for one-off charge. |
unit | optional | string | The unit type for the one-off charge, can be left as null or omitted. |
total_cost | optional | integer | The real cost for the expense (does not get charge to client), for internal purposes. |
tax | required_with:total_cost | tax | The tax type that applies to the total cost. |
tax_rate | required_with:total_cost | decimal | The tax rate to apply to the total cost. |
currency | required_with:total_cost | currency | The currency the total cost is using. |
notes | optional | string | Any notes or descriptions related to the expense entry. |
{
"project_id": 1,
"charge_id": 1,
"date": "2001-01-01",
"quantity": 10,
"notes": "some notes",
"chargeable": true
}
{
"success": true,
"expense": {
"id": 1,
"date": "2001-01-01",
"name": "Coffee",
"quantity": 10,
"notes": "some notes",
"chargeable": 1,
"total_charge": 3500,
"unit_charge": 350,
"unit": "cup",
"total_cost": 0,
"tax": "includes",
"tax_rate": 0.15,
"currency": "NZD",
"created_at": "2000-01-01 00:00:00",
"updated_at": "2000-01-01 00:00:00",
"original_total_charge": 0,
"original_unit_charge": 0,
"original_currency": "NZD",
"exchange_rate": 0,
"charge": {
"id": 1,
"name": "Coffee",
"charge": 350,
"unit": "cup",
"currency": "NZD",
"created_at": "2000-01-01 00:00:00",
"updated_at": "2000-01-01 00:00:00",
"deleted": false
},
"project": {
"id": 1,
"status": "complete",
"name": "Example Project",
"code": "1000",
"description": "Here is an example project.",
"currency": "NZD",
"increment": 15,
"budget": null,
"budget_type": null,
"start_date": "2000-01-01",
"end_date": null,
"created_at": "2000-01-01 00:00:00",
"updated_at": "2000-01-01 00:00:00",
"type": "client",
"deleted": false
}
}
}
This API route will return the expense's data, which includes the personal information as well as the settings that the expense has selected for the application.
This data also includes a listing of all of the assigned permissions that the expense has, a long with the currently assigned roles that the expense has.
This resource requires authorisation. Please read the documentation on authorisation.
GET https://api.dailys.nz/api/v1/expenses/:EXPENSE_ID
{
"id": 1,
"date": "2001-01-01",
"name": "Coffee",
"quantity": 5,
"notes": null,
"chargeable": 1,
"total_charge": 1750,
"unit_charge": 350,
"unit": "cup",
"total_cost": 0,
"tax": "includes",
"tax_rate": 0.15,
"currency": "NZD",
"created_at": "2000-01-01 00:00:00",
"updated_at": "2000-01-01 00:00:00",
"original_total_charge": 0,
"original_unit_charge": 0,
"original_currency": "NZD",
"exchange_rate": 0,
"charge": {
"id": 1,
"name": "Coffee",
"charge": 350,
"unit": "cup",
"currency": "NZD",
"created_at": "2000-01-01 00:00:00",
"updated_at": "2000-01-01 00:00:00",
"deleted": false
},
"project": {
"id": 1,
"status": "complete",
"name": "Example Project",
"code": "1000",
"description": "Here is an example project.",
"currency": "NZD",
"increment": 15,
"budget": null,
"budget_type": null,
"start_date": "2000-01-01",
"end_date": null,
"created_at": "2000-01-01 00:00:00",
"updated_at": "2000-01-01 00:00:00",
"type": "client",
"deleted": false
}
}
This API route will allow you to update expense entry. As this resource already exists, there are no required fields, so you can send as many or as few parameters as you would like.
This resource requires authorisation. Please read the documentation on authorisation.
PUT https://api.dailys.nz/api/v1/expenses/:EXPENSE_ID
Parameter | Type | Description |
---|---|---|
project_id | integer | The ID of the project that the expense entry should log to. |
charge_id | integer | The ID of the chanrge that the expense entry should use. |
date | date | The date the expense entry should refer to. These can be made in advance. |
name | string | The name of the one-off charge. |
quantity | integer | The number of pre-defined charges for the expense entry. |
chargable | boolean | Determines if the expense should be charged to the client, which will appear on an invoice. |
unit_charge | integer | The charge amount of each unit for one-off charge. |
unit | string | The unit type for the one-off charge, can be left as null or omitted. |
total_cost | integer | The real cost for the expense (does not get charge to client), for internal purposes. |
tax | tax | The tax type that applies to the total cost. |
tax_rate | decimal | The tax rate to apply to the total cost. |
currency | currency | The currency the total cost is using. |
notes | string | Any notes or descriptions related to the expense entry. |
{
"notes": "Some different notes all together."
}
{
"success": true,
"expense": {
"id": 1,
"date": "2001-01-01",
"name": "Coffee",
"quantity": 5,
"notes": "Some different notes all together.",
"chargeable": 1,
"total_charge": 1750,
"unit_charge": 350,
"unit": "cup",
"total_cost": 0,
"tax": "includes",
"tax_rate": 0.15,
"currency": "NZD",
"created_at": "2000-01-01 00:00:00",
"updated_at": "2000-01-01 00:00:00",
"original_total_charge": 0,
"original_unit_charge": 0,
"original_currency": "NZD",
"exchange_rate": 0,
"charge": {
"id": 1,
"name": "Coffee",
"charge": 350,
"unit": "cup",
"currency": "NZD",
"created_at": "2000-01-01 00:00:00",
"updated_at": "2000-01-01 00:00:00",
"deleted": false
},
"project": {
"id": 1,
"status": "complete",
"name": "Example Project",
"code": "1000",
"description": "Here is an example project.",
"currency": "NZD",
"increment": 15,
"budget": null,
"budget_type": null,
"start_date": "2000-01-01",
"end_date": null,
"created_at": "2000-01-01 00:00:00",
"updated_at": "2000-01-01 00:00:00",
"type": "client",
"deleted": false
}
}
}
This API route will allow you to delete a expense entry. This expense will no long be accessible using this API endpoint. There is no archive functionality for expense entries, so deleting expense entries will permanently remove them.
This resource requires authorisation. Please read the documentation on authorisation.
DELETE https://api.dailys.nz/api/v1/expenses/:EXPENSE_ID
{
"success": true,
"expense": {
"id": 1,
"date": "2001-01-01",
"name": "Coffee",
"quantity": 5,
"notes": "Some different notes all together.",
"chargeable": 1,
"total_charge": 1750,
"unit_charge": 350,
"unit": "cup",
"total_cost": 0,
"tax": "includes",
"tax_rate": 0.15,
"currency": "NZD",
"created_at": "2000-01-01 00:00:00",
"updated_at": "2000-01-01 00:00:00",
"original_total_charge": 0,
"original_unit_charge": 0,
"original_currency": "NZD",
"exchange_rate": 0,
"charge": {
"id": 1,
"name": "Coffee",
"charge": 350,
"unit": "cup",
"currency": "NZD",
"created_at": "2000-01-01 00:00:00",
"updated_at": "2000-01-01 00:00:00",
"deleted": false
},
"project": {
"id": 1,
"status": "complete",
"name": "Example Project",
"code": "1000",
"description": "Here is an example project.",
"currency": "NZD",
"increment": 15,
"budget": null,
"budget_type": null,
"start_date": "2000-01-01",
"end_date": null,
"created_at": "2000-01-01 00:00:00",
"updated_at": "2000-01-01 00:00:00",
"type": "client",
"deleted": false
}
}
}