Expense Categories

Expense categories are used for sorting project expenses. When installed, ActiveCollab will set up one expense category and make it default:

Response: HTTP 200, application/json (Hide)
GET /expense-categories

Response:

1
2
3
4
5
6
7
8
9
[
    {
        "id": 1,
        "class": "ExpenseCategory",
        "url_path": "\/expense-categories\/1",
        "name": "General",
        "is_default": true
    }
]

Lets rename it to something that makes more sense to us:

Response: HTTP 200, application/json (Hide)
PUT /expense-categories/1

Payload:

1
2
3
{
    "name": "Gas"
}

Response:

1
2
3
4
5
6
7
8
9
{
    "single": {
        "id": 1,
        "class": "ExpenseCategory",
        "url_path": "\/expense-categories\/1",
        "name": "Gas",
        "is_default": true
    }
}

Now lets define new categories:

Response: HTTP 200, application/json (Hide)
POST /expense-categories

Payload:

1
2
3
{
    "name": "Travel"
}

Response:

1
2
3
4
5
6
7
8
9
{
    "single": {
        "id": 2,
        "class": "ExpenseCategory",
        "url_path": "\/expense-categories\/2",
        "name": "Travel",
        "is_default": false
    }
}
Response: HTTP 200, application/json (Hide)
POST /expense-categories

Payload:

1
2
3
{
    "name": "Gear Rent"
}

Response:

1
2
3
4
5
6
7
8
9
{
    "single": {
        "id": 3,
        "class": "ExpenseCategory",
        "url_path": "\/expense-categories\/3",
        "name": "Gear Rent",
        "is_default": false
    }
}

And track one Gear Rent expense:

Response: HTTP 200, application/json (Hide)
POST /projects

Payload:

1
2
3
4
{
    "name": "Test Project",
    "is_tracking_enabled": true
}

Response:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{
    "single": {
        "id": 1,
        "class": "Project",
        "url_path": "\/projects\/1",
        "name": "Test Project",
        "completed_on": null,
        "completed_by_id": null,
        "is_completed": false,
        "members": [
            1
        ],
        "category_id": 0,
        "label_id": 0,
        "is_trashed": false,
        "trashed_on": null,
        "trashed_by_id": 0,
        "created_on": 1430164088,
        "created_by_id": 1,
        "updated_on": 1430164088,
        "updated_by_id": 1,
        "body": null,
        "body_formatted": "",
        "company_id": 1,
        "leader_id": 0,
        "currency_id": 2,
        "template_id": 0,
        "based_on_type": null,
        "based_on_id": null,
        "email": "notifications+m2p-cXx6z4g@mail.manageprojects.com",
        "is_tracking_enabled": true,
        "is_client_reporting_enabled": false,
        "budget": null,
        "count_tasks": 0,
        "count_discussions": 0,
        "count_files": 0,
        "count_notes": 0
    },
    "category": null,
    "hourly_rates": {
        "1": 100
    },
    "label_ids": [],
    "task_lists": null
}
Response: HTTP 500, application/json (Hide)
POST /projects/1/time-records

Payload:

1
2
3
4
5
6
7
{
    "value": 1.5,
    "user_id": 1,
    "job_type_id": 4,
    "record_date": "2014-05-14",
    "billable_status": 0
}

Response:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{
    "message": "Validation failed",
    "type": "ValidationErrors",
    "field_errors": {
        "job_type_id": [
            "Value of job_type_id field is required"
        ]
    },
    "object_class": "TimeRecord",
    "object_fields": {
        "id": null,
        "parent_type": "Project",
        "parent_id": 1,
        "invoice_item_id": 0,
        "job_type_id": 4,
        "record_date": 1400025600,
        "value": 1.5,
        "user_id": 1,
        "user_name": null,
        "user_email": null,
        "summary": null,
        "billable_status": 0,
        "created_on": 1430164088,
        "created_by_id": 1,
        "created_by_name": "ilija.studen",
        "created_by_email": "ilija.studen@activecollab.com",
        "updated_on": 1430164088,
        "updated_by_id": 1,
        "updated_by_name": "ilija.studen",
        "updated_by_email": "ilija.studen@activecollab.com",
        "is_trashed": false,
        "original_is_trashed": false,
        "trashed_on": null,
        "trashed_by_id": 0
    }
}
Response: HTTP 200, application/json (Hide)
POST /projects/1/expenses

Payload:

1
2
3
4
5
6
{
    "value": 250,
    "user_id": 1,
    "category_id": 3,
    "record_date": "2014-05-14"
}

Response:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
    "single": {
        "id": 1,
        "class": "Expense",
        "url_path": "\/projects\/1\/expenses\/1",
        "is_trashed": false,
        "trashed_on": null,
        "trashed_by_id": 0,
        "billable_status": 1,
        "value": 250,
        "record_date": 1400025600,
        "summary": null,
        "user_id": 1,
        "parent_type": "Project",
        "parent_id": 1,
        "created_on": 1430164089,
        "created_by_id": 1,
        "updated_on": 1430164089,
        "updated_by_id": 1,
        "category_id": 3,
        "currency_id": 2
    }
}

Default Category #

Default expense category is pre-selected in expense tracking forms:

Response: HTTP 200, application/json (Hide)
GET /expense-categories/default

Response:

1
2
3
4
5
6
7
8
9
{
    "single": {
        "id": 1,
        "class": "ExpenseCategory",
        "url_path": "\/expense-categories\/1",
        "name": "Gas",
        "is_default": true
    }
}

We would like our Travel category to be the default one:

Response: HTTP 200, application/json (Hide)
PUT /expense-categories/default

Payload:

1
2
3
{
    "expense_category_id": 2
}

Response:

1
2
3
4
5
6
7
8
9
{
    "single": {
        "id": 2,
        "class": "ExpenseCategory",
        "url_path": "\/expense-categories\/2",
        "name": "Travel",
        "is_default": true
    }
}

Deleting a Category #

Categories that have expenses tracked can't be deleted:

Response: HTTP 404, text/html
DELETE /expense-categories/3

Default category can't be deleted as well:

Response: HTTP 404, text/html
DELETE /expense-categories/2

Only unused categories can be deleted:

Response: HTTP 200, text/html
DELETE /expense-categories/1