API documentation

v1.0

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

NameTypeDescription
nameString / RequiredExpense name or invoice number
dateDate / Required / yyyy-mm-ddExpense date in format yyyy-mm-dd
contactInteger / Optional / Required if not sent `own_expense´Contact identifier. Only `contact´ or `own_expense´ should be sent
own_expenseBoolean / Optional / Required if not sent `contact´ / trueSet as own expense. Only `contact´ or `own_expense´ should be sent
currencyString / OptionalCurrency. If not sent the default currency configured in the documents will be used. Currencies available in data.options.currencies of the endpoint: /info.
expense_typeInteger / OptionalExpense type identifier
linesArray / RequiredArray of line objects

Line

NameTypeDescription
descriptionString / Required / Maximum 500 charactersLine description
priceNumber up to 2 decimals / RequiredPrice / Can contain a negative sign as "-100.05"
taxesArray / OptionalArray 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

NameTypeDescription
pageInteger / Optional / Min:1Page
per_pageInteger / Optional / Min:1 Max:100Items per page
expense_type_idInteger / OptionalFilter by expense type identifier
contact_idInteger / OptionalFilter by contact identifier
fromDate / Optional / yyyy-mm-ddFilter with date from format yyyy-mm-dd, example: 2022-09-21
toDate / Optional / yyyy-mm-ddFilter with date until format yyyy-mm-dd, example: 2022-09-21
only_without_filesBoolean / Optional / trueShow only items without associated file
own_expenseBoolean / Optional / true, falseShow own expenses, if sent with value `true´, `contact_id´ will be ignored
searchString / Optional / Min:3Search by string of at least 3 characters
orderString / OptionalOrder 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

NameTypeDescription
nameString / OptionalExpense name or invoice number
dateDate / Optional / yyyy-mm-ddExpense date in format yyyy-mm-dd
contactInteger / OptionalContact identifier. Only `contact´ or `own_expense´ should be sent
own_expenseBoolean / Optional / trueSet as own expense. Only `contact´ or `own_expense´ should be sent
currencyString / OptionalCurrencies available in data.options.currencies of the endpoint: /info.
expense_typeInteger / OptionalExpense type identifier. The current value can be deleted by sending the parameter with value `null´
linesArray / OptionalArray of line objects. All lines can be deleted by sending the parameter as an empty array `[]´

Line

NameTypeDescription
descriptionString / Required / Maximum 500 charactersLine description
priceNumber up to 2 decimals / RequiredPrice / Can contain a negative sign as "-100.05"
taxesArray / OptionalArray 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.