Expenses
Expenses allow you to store purchase documents and costs associated with your activity.
Create an expense
This endpoint allows the creation of a new expense in your application.
HTTP Request
POST/expenses
Parameters
Name | Type | Description |
---|---|---|
name | String / Required | Expense name or invoice number |
date | Date / Required / yyyy-mm-dd | Expense date in format yyyy-mm-dd |
contact | Integer / Optional / Required if not sent `own_expense´ | Contact identifier. Only `contact´ or `own_expense´ should be sent |
own_expense | Boolean / Optional / Required if not sent `contact´ / true | Set as own expense. Only `contact´ or `own_expense´ should be sent |
currency | String / Optional | Currency. If not sent the default currency configured in the documents will be used. Currencies available in data.options.currencies of the endpoint: /info. |
expense_type | Integer / Optional | Expense type identifier |
lines | Array / Required | Array of line objects |
Line
Name | Type | Description |
---|---|---|
description | String / Required / Maximum 500 characters | Line description |
price | Number up to 2 decimals / Required | Price / Can contain a negative sign as "-100.05" |
taxes | Array / Optional | Array of identifiers of taxes that will be applied to the expense |
Playload
{
"name": "Expense name nº1234",
"date": "2020-09-01",
"contact": 12,
"currency": "€",
"expense_type": 6,
"lines" : [
{"description": "Line 1 description", "price":"0.23"},
{"description": "Line 2 description", "price":"1.42", "taxes":[9,2]}
]
}
201Response
{
"data": {
"id": 75,
"name": "Expense name nº1234",
"date": "2020-09-01",
"own_expense": false,
"currency": "€",
"expense_type": {
"id": 6,
"name": "Consultancy"
},
"contact": {
"id": 12,
"name": "Acme"
},
"lines": [
{
"description": "Line 1 description",
"price": 0.23,
"total_before_taxes": 0.23,
"taxes": [],
"total_taxes": 0,
"total_with_taxes": 0.23
},
{
"description": "Line 2 description",
"price": 1.42,
"total_before_taxes": 1.42,
"taxes": [
{
"id": 9,
"version": "f5449e5f-d45b-49ae-ab71-29b01bf8344b",
"name": "IRPF-2022",
"percentage": -16,
"total": -0.23
},
{
"id": 2,
"version": "a3449e5f-d45b-49ae-ab71-29b01bf8694c",
"name": "Iva",
"percentage": 21,
"total": 0.3
}
],
"total_taxes": 0.07,
"total_with_taxes": 1.49
}
],
"file": null,
"total": 1.65,
"total_taxes": 0.07,
"total_with_taxes": 1.72,
"created_at": "2022-09-30T15:30:15+00:00",
"updated_at": "2022-09-30T15:30:15+00:00"
}
}
List expenses
This endpoint allows the consultation of expenses from your application.
HTTP Request
GET/expenses
GET Parameters
Name | Type | Description |
---|---|---|
page | Integer / Optional / Min:1 | Page |
per_page | Integer / Optional / Min:1 Max:100 | Items per page |
expense_type_id | Integer / Optional | Filter by expense type identifier |
contact_id | Integer / Optional | Filter by contact identifier |
from | Date / Optional / yyyy-mm-dd | Filter with date from format yyyy-mm-dd, example: 2022-09-21 |
to | Date / Optional / yyyy-mm-dd | Filter with date until format yyyy-mm-dd, example: 2022-09-21 |
only_without_files | Boolean / Optional / true | Show only items without associated file |
own_expense | Boolean / Optional / true, false | Show own expenses, if sent with value `true´, `contact_id´ will be ignored |
search | String / Optional / Min:3 | Search by string of at least 3 characters |
order | String / Optional | Order by a field in ascending or descending, descending by default, in format "{field},desc" or "{field},asc" where {field} can be: id, name, date, quantity, total |
200 Response
If there are modified taxes, and they are applied in the expense, it is possible that the response includes taxes with the same `id` and different version.
{
"data": [
{
"id": 25,
"name": "Payroll 08",
"date": "2022-08-01",
"own_expense": true,
"currency": "A$",
"expense_type": null,
"contact": null,
"lines": [
{
"description": "Payroll 01",
"price": 2000,
"total_before_taxes": 2000,
"taxes": [
{
"id": 2,
"version": "a3449e5f-d45b-49ae-ab71-29b01bf8694c",
"name": "Iva",
"percentage": 21,
"total": 420
}
],
"total_taxes": 420,
"total_with_taxes": 2420
},
{
"description": "Payroll 02",
"price": 500,
"total_before_taxes": 500,
"taxes": [
{
"id": 9,
"version": "e5325e5f-d45b-49ae-ab71-29b01bf6433v",
"name": "IRPF-2021",
"percentage": -15,
"total": -75
},
{
"id": 9,
"version": "f5449e5f-d45b-49ae-ab71-29b01bf8344b",
"name": "IRPF-2022",
"percentage": -16,
"total": -80
}
],
"total_taxes": -155,
"total_with_taxes": 345
}
],
"file": null,
"total": 2500,
"total_taxes": 265,
"total_with_taxes": 2765,
"created_at": "2022-09-30T15:30:15+00:00",
"updated_at": "2022-09-30T15:30:15+00:00"
},
{
"id": 24,
"name": "Invoice 2022-08",
"date": "2022-08-15",
"own_expense": false,
"currency": "€",
"expense_type": {
"id": 6,
"name": "Consultancy"
},
"contact": {
"id": 12,
"name": "Acme"
},
"lines": [
{
"description": "Consultancy",
"price": 1000,
"total_before_taxes": 1000,
"taxes": [
{
"id": 2,
"version": "a3449e5f-d45b-49ae-ab71-29b01bf8694c",
"name": "Iva",
"percentage": 21,
"total": 210
}
],
"total_taxes": 210,
"total_with_taxes": 1210
},
{
"description": "Consultancy Prime",
"price": 200,
"total_before_taxes": 200,
"taxes": [
{
"id": 2,
"version": "a3449e5f-d45b-49ae-ab71-29b01bf8694c",
"name": "Iva",
"percentage": 21,
"total": 42
},
{
"id": 9,
"version": "e5325e5f-d45b-49ae-ab71-29b01bf6433v",
"name": "IRPF-2021",
"percentage": -15,
"total": -30
}
],
"total_taxes": 12,
"total_with_taxes": 212
}
],
"file": {
"name": "Invoice 2022-08.pdf",
"content_type": "application\/pdf"
},
"total": 1200,
"total_taxes": 222,
"total_with_taxes": 1422,
"created_at": "2022-09-30T15:29:15+00:00",
"updated_at": "2022-09-30T15:29:15+00:00"
}
],
"links": {
"first": "http:\/\/api.orzame.com\/v1\/expenses?per_page=10&page=1",
"last": "http:\/\/api.orzame.com\/v1\/expenses?per_page=10&page=1",
"prev": null,
"next": null
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 1,
"path": "http:\/\/api.orzame.com\/v1\/expenses",
"per_page": 10,
"to": 2,
"total": 2
}
}
Get an expense
This endpoint allows the consultation of an expense from your application.
HTTP Request
GET/expenses/{id}
200 Response
If there are modified taxes, and they are applied in the expense, it is possible that the response includes taxes with the same `id` and different version.
{
"data": {
"id": 24,
"name": "Invoice 2022-08",
"date": "2022-08-15",
"own_expense": false,
"currency": "€",
"expense_type": {
"id": 6,
"name": "Consultancy"
},
"contact": {
"id": 12,
"name": "Acme"
},
"lines": [
{
"description": "Consultancy",
"price": 1000,
"total_before_taxes": 1000,
"taxes": [
{
"id": 2,
"version": "a3449e5f-d45b-49ae-ab71-29b01bf8694c",
"name": "Iva",
"percentage": 21,
"total": 210
}
],
"total_taxes": 210,
"total_with_taxes": 1210
},
{
"description": "Consultancy Prime",
"price": 200,
"total_before_taxes": 200,
"taxes": [
{
"id": 2,
"version": "a3449e5f-d45b-49ae-ab71-29b01bf8694c",
"name": "Iva",
"percentage": 21,
"total": 42
},
{
"id": 9,
"version": "e5325e5f-d45b-49ae-ab71-29b01bf6433v",
"name": "IRPF-2021",
"percentage": -15,
"total": -30
}
],
"total_taxes": 12,
"total_with_taxes": 212
}
],
"file": {
"name": "Invoice 2022-08.pdf",
"content_type": "application\/pdf"
},
"total": 1200,
"total_taxes": 222,
"total_with_taxes": 1422,
"created_at": "2022-09-30T15:30:15+00:00",
"updated_at": "2022-09-30T15:30:15+00:00"
}
}
Update an expense
This endpoint allows the update of an expense from your application.
HTTP Request
PATCH/expenses/{id}
Parameters
Name | Type | Description |
---|---|---|
name | String / Optional | Expense name or invoice number |
date | Date / Optional / yyyy-mm-dd | Expense date in format yyyy-mm-dd |
contact | Integer / Optional | Contact identifier. Only `contact´ or `own_expense´ should be sent |
own_expense | Boolean / Optional / true | Set as own expense. Only `contact´ or `own_expense´ should be sent |
currency | String / Optional | Currencies available in data.options.currencies of the endpoint: /info. |
expense_type | Integer / Optional | Expense type identifier. The current value can be deleted by sending the parameter with value `null´ |
lines | Array / Optional | Array of line objects. All lines can be deleted by sending the parameter as an empty array `[]´ |
Line
Name | Type | Description |
---|---|---|
description | String / Required / Maximum 500 characters | Line description |
price | Number up to 2 decimals / Required | Price / Can contain a negative sign as "-100.05" |
taxes | Array / Optional | Array of identifiers of taxes that will be applied to the expense |
Playload
{
"name": "New invoice name",
"date": "2022-08-20"
}
200 Response
{
"data": {
"id": 24,
"name": "New invoice name",
"date": "2022-08-20",
"own_expense": false,
"currency": "€",
"expense_type": {
"id": 6,
"name": "Consultancy"
},
"contact": {
"id": 12,
"name": "Acme"
},
"lines": [
{
"description": "Consultancy",
"price": 1000,
"total_before_taxes": 1000,
"taxes": [
{
"id": 2,
"version": "a3449e5f-d45b-49ae-ab71-29b01bf8694c",
"name": "Iva",
"percentage": 21,
"total": 210
}
],
"total_taxes": 210,
"total_with_taxes": 1210
},
{
"description": "Consultancy Prime",
"price": 200,
"total_before_taxes": 200,
"taxes": [
{
"id": 2,
"version": "a3449e5f-d45b-49ae-ab71-29b01bf8694c",
"name": "Iva",
"percentage": 21,
"total": 42
},
{
"id": 9,
"version": "e5325e5f-d45b-49ae-ab71-29b01bf6433v",
"name": "IRPF-2021",
"percentage": -15,
"total": -30
}
],
"total_taxes": 12,
"total_with_taxes": 212
}
],
"file": {
"name": "Invoice 2022-08.pdf",
"content_type": "application\/pdf"
},
"total": 1200,
"total_taxes": 222,
"total_with_taxes": 1422,
"created_at": "2022-09-30T15:30:15+00:00",
"updated_at": "2022-09-30T16:40:25+00:00"
}
}
Duplicate an expense
This endpoint allows the duplication of an expense from your application.
The record will be duplicated with the saved data, without file, with today as date.
HTTP Request
POST/expenses/{id}
201Response
{
"data": {
"id": 40,
"name": "Invoice 2022-08",
"date": "2022-09-01",
"own_expense": false,
"currency": "€",
"expense_type": {
"id": 6,
"name": "Consultancy"
},
"contact": {
"id": 12,
"name": "Acme"
},
"lines": [
{
"description": "Consultancy",
"price": 1000,
"total_before_taxes": 1000,
"taxes": [
{
"id": 2,
"version": "a3449e5f-d45b-49ae-ab71-29b01bf8694c",
"name": "Iva",
"percentage": 21,
"total": 210
}
],
"total_taxes": 210,
"total_with_taxes": 1210
},
{
"description": "Consultancy Prime",
"price": 200,
"total_before_taxes": 200,
"taxes": [
{
"id": 2,
"version": "a3449e5f-d45b-49ae-ab71-29b01bf8694c",
"name": "Iva",
"percentage": 21,
"total": 42
},
{
"id": 9,
"version": "e5325e5f-d45b-49ae-ab71-29b01bf6433v",
"name": "IRPF-2021",
"percentage": -15,
"total": -30
}
],
"total_taxes": 12,
"total_with_taxes": 212
}
],
"file": null,
"total": 1200,
"total_taxes": 222,
"total_with_taxes": 1422
}
}
Delete an expense
This endpoint allows the deletion of an expense from your application.
HTTP Request
DELETE/expenses/{id}
204 Response
Response without body.