Preview Invoice Items

For the purpose of this test, we have created a project and tracked some time on it (4 billable and 3 unbillable hours):

Response: HTTP 200, application/json (Hide)
GET /projects/1/time-records

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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
{
    "time_records": [
        {
            "id": 3,
            "class": "TimeRecord",
            "url_path": "\/projects\/1\/time-records\/3",
            "is_trashed": false,
            "trashed_on": null,
            "trashed_by_id": 0,
            "billable_status": 0,
            "value": 3,
            "record_date": 1400198400,
            "summary": "Non-billable task time record",
            "user_id": 1,
            "parent_type": "Task",
            "parent_id": 1,
            "created_on": 1430164780,
            "created_by_id": 1,
            "updated_on": 1430164780,
            "updated_by_id": 1,
            "job_type_id": 1
        },
        {
            "id": 2,
            "class": "TimeRecord",
            "url_path": "\/projects\/1\/time-records\/2",
            "is_trashed": false,
            "trashed_on": null,
            "trashed_by_id": 0,
            "billable_status": 1,
            "value": 2.5,
            "record_date": 1400112000,
            "summary": "Billable task time record",
            "user_id": 1,
            "parent_type": "Task",
            "parent_id": 1,
            "created_on": 1430164780,
            "created_by_id": 1,
            "updated_on": 1430164780,
            "updated_by_id": 1,
            "job_type_id": 1
        },
        {
            "id": 1,
            "class": "TimeRecord",
            "url_path": "\/projects\/1\/time-records\/1",
            "is_trashed": false,
            "trashed_on": null,
            "trashed_by_id": 0,
            "billable_status": 1,
            "value": 1.5,
            "record_date": 1400025600,
            "summary": "Billable project time record",
            "user_id": 1,
            "parent_type": "Project",
            "parent_id": 1,
            "created_on": 1430164780,
            "created_by_id": 1,
            "updated_on": 1430164780,
            "updated_by_id": 1,
            "job_type_id": 1
        }
    ],
    "related": {
        "Project": {
            "1": {
                "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": 1430164779,
                "created_by_id": 1,
                "updated_on": 1430164781,
                "updated_by_id": 1,
                "body": null,
                "body_formatted": "",
                "company_id": 2,
                "leader_id": 1,
                "currency_id": 1,
                "template_id": 0,
                "based_on_type": null,
                "based_on_id": null,
                "email": "notifications+m2p-ukOfyNA@mail.manageprojects.com",
                "is_tracking_enabled": true,
                "is_client_reporting_enabled": false,
                "budget": null,
                "count_tasks": 1,
                "count_discussions": 0,
                "count_files": 0,
                "count_notes": 0
            }
        },
        "Task": {
            "1": {
                "id": 1,
                "class": "Task",
                "url_path": "\/projects\/1\/tasks\/1",
                "name": "Test Task",
                "assignee_id": 0,
                "delegated_by_id": 0,
                "completed_on": null,
                "completed_by_id": null,
                "is_completed": false,
                "comments_count": 0,
                "attachments": [],
                "labels": [],
                "is_trashed": false,
                "trashed_on": null,
                "trashed_by_id": 0,
                "project_id": 1,
                "is_hidden_from_clients": false,
                "body": "",
                "body_formatted": "",
                "created_on": 1430164780,
                "created_by_id": 1,
                "updated_on": 1430164781,
                "updated_by_id": 1,
                "task_number": 1,
                "task_list_id": 0,
                "position": 1,
                "is_important": false,
                "due_on": null,
                "estimate": 0,
                "job_type_id": 0,
                "total_subtasks": 0,
                "completed_subtasks": 0,
                "open_subtasks": 0
            }
        }
    }
}

at rate of US$150 per hour that we have for this client:

Response: HTTP 200, application/json (Hide)
GET /companies/2

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
{
    "single": {
        "id": 2,
        "class": "Company",
        "url_path": "\/companies\/2",
        "name": "Client Company GmbH",
        "members": [],
        "is_trashed": false,
        "trashed_on": null,
        "trashed_by_id": 0,
        "is_archived": false,
        "created_on": 1430164779,
        "created_by_id": 1,
        "updated_on": 1430164779,
        "updated_by_id": 1,
        "address": "Street Name 12\nCity",
        "phone": null,
        "homepage_url": null,
        "tax_id": null,
        "currency_id": 1,
        "is_owner": false,
        "has_note": false
    },
    "hourly_rates": {
        "1": 150
    },
    "active_projects_count": 1
}

we expect to make US$600.

We also tracked some project expenses that are not time related (US$630.50 in billable and US$125.25 in unbillable expenses):

Response: HTTP 200, application/json (Hide)
GET /projects/1/expenses

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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
{
    "expenses": [
        {
            "id": 3,
            "class": "Expense",
            "url_path": "\/projects\/1\/expenses\/3",
            "is_trashed": false,
            "trashed_on": null,
            "trashed_by_id": 0,
            "billable_status": 0,
            "value": 125.25,
            "record_date": 1400198400,
            "summary": "Non-billable task expense",
            "user_id": 1,
            "parent_type": "Task",
            "parent_id": 1,
            "created_on": 1430164781,
            "created_by_id": 1,
            "updated_on": 1430164781,
            "updated_by_id": 1,
            "category_id": 1,
            "currency_id": 1
        },
        {
            "id": 2,
            "class": "Expense",
            "url_path": "\/projects\/1\/expenses\/2",
            "is_trashed": false,
            "trashed_on": null,
            "trashed_by_id": 0,
            "billable_status": 1,
            "value": 380.5,
            "record_date": 1400112000,
            "summary": "Billable task expense",
            "user_id": 1,
            "parent_type": "Task",
            "parent_id": 1,
            "created_on": 1430164781,
            "created_by_id": 1,
            "updated_on": 1430164781,
            "updated_by_id": 1,
            "category_id": 1,
            "currency_id": 1
        },
        {
            "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": "Billable project expense",
            "user_id": 1,
            "parent_type": "Project",
            "parent_id": 1,
            "created_on": 1430164780,
            "created_by_id": 1,
            "updated_on": 1430164780,
            "updated_by_id": 1,
            "category_id": 1,
            "currency_id": 1
        }
    ],
    "related": {
        "Project": {
            "1": {
                "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": 1430164779,
                "created_by_id": 1,
                "updated_on": 1430164781,
                "updated_by_id": 1,
                "body": null,
                "body_formatted": "",
                "company_id": 2,
                "leader_id": 1,
                "currency_id": 1,
                "template_id": 0,
                "based_on_type": null,
                "based_on_id": null,
                "email": "notifications+m2p-ukOfyNA@mail.manageprojects.com",
                "is_tracking_enabled": true,
                "is_client_reporting_enabled": false,
                "budget": null,
                "count_tasks": 1,
                "count_discussions": 0,
                "count_files": 0,
                "count_notes": 0
            }
        },
        "Task": {
            "1": {
                "id": 1,
                "class": "Task",
                "url_path": "\/projects\/1\/tasks\/1",
                "name": "Test Task",
                "assignee_id": 0,
                "delegated_by_id": 0,
                "completed_on": null,
                "completed_by_id": null,
                "is_completed": false,
                "comments_count": 0,
                "attachments": [],
                "labels": [],
                "is_trashed": false,
                "trashed_on": null,
                "trashed_by_id": 0,
                "project_id": 1,
                "is_hidden_from_clients": false,
                "body": "",
                "body_formatted": "",
                "created_on": 1430164780,
                "created_by_id": 1,
                "updated_on": 1430164781,
                "updated_by_id": 1,
                "task_number": 1,
                "task_list_id": 0,
                "position": 1,
                "is_important": false,
                "due_on": null,
                "estimate": 0,
                "job_type_id": 0,
                "total_subtasks": 0,
                "completed_subtasks": 0,
                "open_subtasks": 0
            }
        }
    }
}

To prepare and preview invoice items, we can call /invoices/preview-items command:

Response: HTTP 200, application/json (Hide)
GET /invoices/preview-items

Query Parameters:

1
2
3
4
5
6
{
    "project_ids": [
        1
    ],
    "include_time_records": 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
[
    {
        "description": "#1: Test Task: Billable task time record (May 15. 2014)",
        "unit_cost": 150,
        "quantity": 2.5,
        "first_tax_rate_id": null,
        "second_tax_rate_id": null,
        "time_record_ids": [
            2
        ],
        "expense_ids": []
    },
    {
        "description": "Test Project: Billable project time record (May 14. 2014)",
        "unit_cost": 150,
        "quantity": 1.5,
        "first_tax_rate_id": null,
        "second_tax_rate_id": null,
        "time_record_ids": [
            1
        ],
        "expense_ids": []
    }
]

Date filter is also available:

Response: HTTP 200, application/json (Hide)
GET /invoices/preview-items

Query Parameters:

1
2
3
4
5
6
7
8
{
    "project_ids": [
        1
    ],
    "include_time_records": true,
    "date_filter_from": "2014-01-01",
    "date_filter_to": "2014-12-31"
}

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
[
    {
        "description": "#1: Test Task: Billable task time record (May 15. 2014)",
        "unit_cost": 150,
        "quantity": 2.5,
        "first_tax_rate_id": null,
        "second_tax_rate_id": null,
        "time_record_ids": [
            2
        ],
        "expense_ids": []
    },
    {
        "description": "Test Project: Billable project time record (May 14. 2014)",
        "unit_cost": 150,
        "quantity": 1.5,
        "first_tax_rate_id": null,
        "second_tax_rate_id": null,
        "time_record_ids": [
            1
        ],
        "expense_ids": []
    }
]
Response: HTTP 200, application/json (Hide)
GET /invoices/preview-items

Query Parameters:

1
2
3
4
5
6
7
8
{
    "project_ids": [
        1
    ],
    "include_time_records": true,
    "date_filter_from": "2013-01-01",
    "date_filter_to": "2013-12-31"
}

Response:

1
[]