Invoice From Time and Expenses
For the purpose of this test, we have created a project and tracked some time on it (4 billable and 3 unbillable hours):
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": 1430164747, "created_by_id": 1, "updated_on": 1430164747, "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": 1430164747, "created_by_id": 1, "updated_on": 1430164747, "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": 1430164747, "created_by_id": 1, "updated_on": 1430164747, "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": 1430164746, "created_by_id": 1, "updated_on": 1430164748, "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-a6JUk0S@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": 1430164747, "created_by_id": 1, "updated_on": 1430164748, "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:
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": 1430164746, "created_by_id": 1, "updated_on": 1430164746, "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:
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": 1430164748, "created_by_id": 1, "updated_on": 1430164748, "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": 1430164748, "created_by_id": 1, "updated_on": 1430164748, "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": 1430164747, "created_by_id": 1, "updated_on": 1430164747, "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": 1430164746, "created_by_id": 1, "updated_on": 1430164748, "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-a6JUk0S@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": 1430164747, "created_by_id": 1, "updated_on": 1430164748, "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 create an invoice based on tracked time and expenses, we send POST request to /invoices
resources with items_from_tracked_data
properly set:
Payload:
1 2 3 4 5 6 7 8 9 10
{ "company_id": 2, "number": "1\/2014", "items_from_tracked_data": { "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 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 146 147 148 149 150 151 152 153 154 155 156
{ "single": { "id": 1, "class": "Invoice", "url_path": "\/invoices\/1", "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "company_id": 2, "company_name": "Client Company GmbH", "company_address": "Street Name 12\nCity", "note": null, "currency_id": 1, "language_id": 0, "discount_rate": 0, "subtotal": 600, "subtotal_without_discount": 600, "discount": 0, "tax": 0, "rounding_difference": 0, "rounded_total": 600, "total": 600, "paid_amount": 0, "balance_due": 600, "recipients": null, "email_from": null, "email_subject": null, "email_body": null, "second_tax_is_enabled": false, "second_tax_is_compound": false, "created_on": 1430164749, "created_by_id": 1, "updated_on": 1430164749, "based_on_type": null, "based_on_id": null, "number": "1\/2014", "project_id": 0, "purchase_order_number": null, "issued_on": 1430164749, "due_on": 1430164749, "allow_payments": 1, "closed_on": null, "sent_on": null, "hash": "l4rxRpYrnx8reNKjpksYqJtJMwxCfYPqQ8OwmBNz", "status": "issued", "public_url": "http:\/\/feather.dev\/s\/invoice?hash=l4rxRpYrnx8reNKjpksYqJtJMwxCfYPqQ8OwmBNz&number=1%2F2014", "is_credit_invoice": false }, "reminders": [], "items": [ { "id": 1, "class": "InvoiceItem", "url_path": "\/invoice-items\/1", "parent_type": "Invoice", "parent_id": 1, "discount_rate": 0, "description": "#1: Test Task: Billable task time record (May 15. 2014)", "quantity": 2.5, "unit_cost": 150, "first_tax_rate_id": 0, "first_tax_value": 0, "first_tax_name": "", "first_tax_rate": 0, "second_tax_rate_id": 0, "second_tax_value": 0, "second_tax_name": "", "second_tax_rate": 0, "second_tax_is_enabled": false, "second_tax_is_compound": false, "subtotal": 375, "subtotal_without_discount": 375, "discount": 0, "total": 375, "position": 1, "time_record_ids": [ 2 ], "expense_ids": [] }, { "id": 2, "class": "InvoiceItem", "url_path": "\/invoice-items\/2", "parent_type": "Invoice", "parent_id": 1, "discount_rate": 0, "description": "Test Project: Billable project time record (May 14. 2014)", "quantity": 1.5, "unit_cost": 150, "first_tax_rate_id": 0, "first_tax_value": 0, "first_tax_name": "", "first_tax_rate": 0, "second_tax_rate_id": 0, "second_tax_value": 0, "second_tax_name": "", "second_tax_rate": 0, "second_tax_is_enabled": false, "second_tax_is_compound": false, "subtotal": 225, "subtotal_without_discount": 225, "discount": 0, "total": 225, "position": 2, "time_record_ids": [ 1 ], "expense_ids": [] } ], "time_records": [ { "id": 1, "class": "TimeRecord", "url_path": "\/projects\/1\/time-records\/1", "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "billable_status": 2, "value": 1.5, "record_date": 1400025600, "summary": "Billable project time record", "user_id": 1, "parent_type": "Project", "parent_id": 1, "created_on": 1430164747, "created_by_id": 1, "updated_on": 1430164749, "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": 2, "value": 2.5, "record_date": 1400112000, "summary": "Billable task time record", "user_id": 1, "parent_type": "Task", "parent_id": 1, "created_on": 1430164747, "created_by_id": 1, "updated_on": 1430164749, "updated_by_id": 1, "job_type_id": 1 } ], "expenses": [], "payments": [] }
Lets release time records from this invoice, so we can use them for a new invoice:
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
{ "single": { "id": 1, "class": "Invoice", "url_path": "\/invoices\/1", "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "company_id": 2, "company_name": "Client Company GmbH", "company_address": "Street Name 12\nCity", "note": null, "currency_id": 1, "language_id": 0, "discount_rate": 0, "subtotal": 600, "subtotal_without_discount": 600, "discount": 0, "tax": 0, "rounding_difference": 0, "rounded_total": 600, "total": 600, "paid_amount": 0, "balance_due": 600, "recipients": null, "email_from": null, "email_subject": null, "email_body": null, "second_tax_is_enabled": false, "second_tax_is_compound": false, "created_on": 1430164749, "created_by_id": 1, "updated_on": 1430164749, "based_on_type": null, "based_on_id": null, "number": "1\/2014", "project_id": 0, "purchase_order_number": null, "issued_on": 1430092800, "due_on": 1430092800, "allow_payments": 1, "closed_on": null, "sent_on": null, "hash": "l4rxRpYrnx8reNKjpksYqJtJMwxCfYPqQ8OwmBNz", "status": "issued", "public_url": "http:\/\/feather.dev\/s\/invoice?hash=l4rxRpYrnx8reNKjpksYqJtJMwxCfYPqQ8OwmBNz&number=1%2F2014", "is_credit_invoice": false }, "reminders": [], "items": [ { "id": 1, "class": "InvoiceItem", "url_path": "\/invoice-items\/1", "parent_type": "Invoice", "parent_id": 1, "discount_rate": 0, "description": "#1: Test Task: Billable task time record (May 15. 2014)", "quantity": 2.5, "unit_cost": 150, "first_tax_rate_id": 0, "first_tax_value": 0, "first_tax_name": "", "first_tax_rate": 0, "second_tax_rate_id": 0, "second_tax_value": 0, "second_tax_name": "", "second_tax_rate": 0, "second_tax_is_enabled": false, "second_tax_is_compound": false, "subtotal": 375, "subtotal_without_discount": 375, "discount": 0, "total": 375, "position": 1, "time_record_ids": [ 2 ], "expense_ids": [] }, { "id": 2, "class": "InvoiceItem", "url_path": "\/invoice-items\/2", "parent_type": "Invoice", "parent_id": 1, "discount_rate": 0, "description": "Test Project: Billable project time record (May 14. 2014)", "quantity": 1.5, "unit_cost": 150, "first_tax_rate_id": 0, "first_tax_value": 0, "first_tax_name": "", "first_tax_rate": 0, "second_tax_rate_id": 0, "second_tax_value": 0, "second_tax_name": "", "second_tax_rate": 0, "second_tax_is_enabled": false, "second_tax_is_compound": false, "subtotal": 225, "subtotal_without_discount": 225, "discount": 0, "total": 225, "position": 2, "time_record_ids": [ 1 ], "expense_ids": [] } ], "time_records": [], "expenses": [], "payments": [] }
Lets create an invoice with expenses included:
Payload:
1 2 3 4 5 6 7 8 9 10 11
{ "company_id": 2, "number": "2\/2014", "items_from_tracked_data": { "project_ids": [ 1 ], "include_time_records": true, "include_expenses": 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 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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
{ "single": { "id": 2, "class": "Invoice", "url_path": "\/invoices\/2", "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "company_id": 2, "company_name": "Client Company GmbH", "company_address": "Street Name 12\nCity", "note": null, "currency_id": 1, "language_id": 0, "discount_rate": 0, "subtotal": 1230.5, "subtotal_without_discount": 1230.5, "discount": 0, "tax": 0, "rounding_difference": 0, "rounded_total": 1230.5, "total": 1230.5, "paid_amount": 0, "balance_due": 1230.5, "recipients": null, "email_from": null, "email_subject": null, "email_body": null, "second_tax_is_enabled": false, "second_tax_is_compound": false, "created_on": 1430164749, "created_by_id": 1, "updated_on": 1430164749, "based_on_type": null, "based_on_id": null, "number": "2\/2014", "project_id": 0, "purchase_order_number": null, "issued_on": 1430164749, "due_on": 1430164749, "allow_payments": 1, "closed_on": null, "sent_on": null, "hash": "hqcyOzm8aOxySRvOk4nUsyAyIxf2JQXR71eKoqGp", "status": "issued", "public_url": "http:\/\/feather.dev\/s\/invoice?hash=hqcyOzm8aOxySRvOk4nUsyAyIxf2JQXR71eKoqGp&number=2%2F2014", "is_credit_invoice": false }, "reminders": [], "items": [ { "id": 3, "class": "InvoiceItem", "url_path": "\/invoice-items\/3", "parent_type": "Invoice", "parent_id": 2, "discount_rate": 0, "description": "#1: Test Task: Billable task time record (May 15. 2014)", "quantity": 2.5, "unit_cost": 150, "first_tax_rate_id": 0, "first_tax_value": 0, "first_tax_name": "", "first_tax_rate": 0, "second_tax_rate_id": 0, "second_tax_value": 0, "second_tax_name": "", "second_tax_rate": 0, "second_tax_is_enabled": false, "second_tax_is_compound": false, "subtotal": 375, "subtotal_without_discount": 375, "discount": 0, "total": 375, "position": 1, "time_record_ids": [ 2 ], "expense_ids": [] }, { "id": 4, "class": "InvoiceItem", "url_path": "\/invoice-items\/4", "parent_type": "Invoice", "parent_id": 2, "discount_rate": 0, "description": "Test Project: Billable project time record (May 14. 2014)", "quantity": 1.5, "unit_cost": 150, "first_tax_rate_id": 0, "first_tax_value": 0, "first_tax_name": "", "first_tax_rate": 0, "second_tax_rate_id": 0, "second_tax_value": 0, "second_tax_name": "", "second_tax_rate": 0, "second_tax_is_enabled": false, "second_tax_is_compound": false, "subtotal": 225, "subtotal_without_discount": 225, "discount": 0, "total": 225, "position": 2, "time_record_ids": [ 1 ], "expense_ids": [] }, { "id": 5, "class": "InvoiceItem", "url_path": "\/invoice-items\/5", "parent_type": "Invoice", "parent_id": 2, "discount_rate": 0, "description": "#1: Test Task: Billable task expense (May 15. 2014)", "quantity": 1, "unit_cost": 380.5, "first_tax_rate_id": 0, "first_tax_value": 0, "first_tax_name": "", "first_tax_rate": 0, "second_tax_rate_id": 0, "second_tax_value": 0, "second_tax_name": "", "second_tax_rate": 0, "second_tax_is_enabled": false, "second_tax_is_compound": false, "subtotal": 380.5, "subtotal_without_discount": 380.5, "discount": 0, "total": 380.5, "position": 3, "time_record_ids": [], "expense_ids": [ 2 ] }, { "id": 6, "class": "InvoiceItem", "url_path": "\/invoice-items\/6", "parent_type": "Invoice", "parent_id": 2, "discount_rate": 0, "description": "Test Project: Billable project expense (May 14. 2014)", "quantity": 1, "unit_cost": 250, "first_tax_rate_id": 0, "first_tax_value": 0, "first_tax_name": "", "first_tax_rate": 0, "second_tax_rate_id": 0, "second_tax_value": 0, "second_tax_name": "", "second_tax_rate": 0, "second_tax_is_enabled": false, "second_tax_is_compound": false, "subtotal": 250, "subtotal_without_discount": 250, "discount": 0, "total": 250, "position": 4, "time_record_ids": [], "expense_ids": [ 1 ] } ], "time_records": [ { "id": 1, "class": "TimeRecord", "url_path": "\/projects\/1\/time-records\/1", "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "billable_status": 2, "value": 1.5, "record_date": 1400025600, "summary": "Billable project time record", "user_id": 1, "parent_type": "Project", "parent_id": 1, "created_on": 1430164747, "created_by_id": 1, "updated_on": 1430164749, "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": 2, "value": 2.5, "record_date": 1400112000, "summary": "Billable task time record", "user_id": 1, "parent_type": "Task", "parent_id": 1, "created_on": 1430164747, "created_by_id": 1, "updated_on": 1430164749, "updated_by_id": 1, "job_type_id": 1 } ], "expenses": [ { "id": 1, "class": "Expense", "url_path": "\/projects\/1\/expenses\/1", "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "billable_status": 2, "value": 250, "record_date": 1400025600, "summary": "Billable project expense", "user_id": 1, "parent_type": "Project", "parent_id": 1, "created_on": 1430164747, "created_by_id": 1, "updated_on": 1430164749, "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": 2, "value": 380.5, "record_date": 1400112000, "summary": "Billable task expense", "user_id": 1, "parent_type": "Task", "parent_id": 1, "created_on": 1430164748, "created_by_id": 1, "updated_on": 1430164749, "updated_by_id": 1, "category_id": 1, "currency_id": 1 } ], "payments": [] }
We will release related records again, in order to test project grouping:
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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
{ "single": { "id": 2, "class": "Invoice", "url_path": "\/invoices\/2", "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "company_id": 2, "company_name": "Client Company GmbH", "company_address": "Street Name 12\nCity", "note": null, "currency_id": 1, "language_id": 0, "discount_rate": 0, "subtotal": 1230.5, "subtotal_without_discount": 1230.5, "discount": 0, "tax": 0, "rounding_difference": 0, "rounded_total": 1230.5, "total": 1230.5, "paid_amount": 0, "balance_due": 1230.5, "recipients": null, "email_from": null, "email_subject": null, "email_body": null, "second_tax_is_enabled": false, "second_tax_is_compound": false, "created_on": 1430164749, "created_by_id": 1, "updated_on": 1430164749, "based_on_type": null, "based_on_id": null, "number": "2\/2014", "project_id": 0, "purchase_order_number": null, "issued_on": 1430092800, "due_on": 1430092800, "allow_payments": 1, "closed_on": null, "sent_on": null, "hash": "hqcyOzm8aOxySRvOk4nUsyAyIxf2JQXR71eKoqGp", "status": "issued", "public_url": "http:\/\/feather.dev\/s\/invoice?hash=hqcyOzm8aOxySRvOk4nUsyAyIxf2JQXR71eKoqGp&number=2%2F2014", "is_credit_invoice": false }, "reminders": [], "items": [ { "id": 3, "class": "InvoiceItem", "url_path": "\/invoice-items\/3", "parent_type": "Invoice", "parent_id": 2, "discount_rate": 0, "description": "#1: Test Task: Billable task time record (May 15. 2014)", "quantity": 2.5, "unit_cost": 150, "first_tax_rate_id": 0, "first_tax_value": 0, "first_tax_name": "", "first_tax_rate": 0, "second_tax_rate_id": 0, "second_tax_value": 0, "second_tax_name": "", "second_tax_rate": 0, "second_tax_is_enabled": false, "second_tax_is_compound": false, "subtotal": 375, "subtotal_without_discount": 375, "discount": 0, "total": 375, "position": 1, "time_record_ids": [ 2 ], "expense_ids": [] }, { "id": 4, "class": "InvoiceItem", "url_path": "\/invoice-items\/4", "parent_type": "Invoice", "parent_id": 2, "discount_rate": 0, "description": "Test Project: Billable project time record (May 14. 2014)", "quantity": 1.5, "unit_cost": 150, "first_tax_rate_id": 0, "first_tax_value": 0, "first_tax_name": "", "first_tax_rate": 0, "second_tax_rate_id": 0, "second_tax_value": 0, "second_tax_name": "", "second_tax_rate": 0, "second_tax_is_enabled": false, "second_tax_is_compound": false, "subtotal": 225, "subtotal_without_discount": 225, "discount": 0, "total": 225, "position": 2, "time_record_ids": [ 1 ], "expense_ids": [] }, { "id": 5, "class": "InvoiceItem", "url_path": "\/invoice-items\/5", "parent_type": "Invoice", "parent_id": 2, "discount_rate": 0, "description": "#1: Test Task: Billable task expense (May 15. 2014)", "quantity": 1, "unit_cost": 380.5, "first_tax_rate_id": 0, "first_tax_value": 0, "first_tax_name": "", "first_tax_rate": 0, "second_tax_rate_id": 0, "second_tax_value": 0, "second_tax_name": "", "second_tax_rate": 0, "second_tax_is_enabled": false, "second_tax_is_compound": false, "subtotal": 380.5, "subtotal_without_discount": 380.5, "discount": 0, "total": 380.5, "position": 3, "time_record_ids": [], "expense_ids": [ 2 ] }, { "id": 6, "class": "InvoiceItem", "url_path": "\/invoice-items\/6", "parent_type": "Invoice", "parent_id": 2, "discount_rate": 0, "description": "Test Project: Billable project expense (May 14. 2014)", "quantity": 1, "unit_cost": 250, "first_tax_rate_id": 0, "first_tax_value": 0, "first_tax_name": "", "first_tax_rate": 0, "second_tax_rate_id": 0, "second_tax_value": 0, "second_tax_name": "", "second_tax_rate": 0, "second_tax_is_enabled": false, "second_tax_is_compound": false, "subtotal": 250, "subtotal_without_discount": 250, "discount": 0, "total": 250, "position": 4, "time_record_ids": [], "expense_ids": [ 1 ] } ], "time_records": [], "expenses": [], "payments": [] }
This invoice will be created with records grouped by project.
Payload:
1 2 3 4 5 6 7 8 9 10 11 12
{ "company_id": 2, "number": "3\/2014", "items_from_tracked_data": { "project_ids": [ 1 ], "include_time_records": true, "include_expenses": true, "sum_by": "sum_all_by_project" } }
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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
{ "single": { "id": 3, "class": "Invoice", "url_path": "\/invoices\/3", "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "company_id": 2, "company_name": "Client Company GmbH", "company_address": "Street Name 12\nCity", "note": null, "currency_id": 1, "language_id": 0, "discount_rate": 0, "subtotal": 1230.5, "subtotal_without_discount": 1230.5, "discount": 0, "tax": 0, "rounding_difference": 0, "rounded_total": 1230.5, "total": 1230.5, "paid_amount": 0, "balance_due": 1230.5, "recipients": null, "email_from": null, "email_subject": null, "email_body": null, "second_tax_is_enabled": false, "second_tax_is_compound": false, "created_on": 1430164750, "created_by_id": 1, "updated_on": 1430164750, "based_on_type": null, "based_on_id": null, "number": "3\/2014", "project_id": 0, "purchase_order_number": null, "issued_on": 1430164750, "due_on": 1430164750, "allow_payments": 1, "closed_on": null, "sent_on": null, "hash": "21604ai2QEkYwfjwxNa4ikDc97LZL0PB0Kz3LITr", "status": "issued", "public_url": "http:\/\/feather.dev\/s\/invoice?hash=21604ai2QEkYwfjwxNa4ikDc97LZL0PB0Kz3LITr&number=3%2F2014", "is_credit_invoice": false }, "reminders": [], "items": [ { "id": 7, "class": "InvoiceItem", "url_path": "\/invoice-items\/7", "parent_type": "Invoice", "parent_id": 3, "discount_rate": 0, "description": "Project Test Project", "quantity": 4, "unit_cost": 150, "first_tax_rate_id": 0, "first_tax_value": 0, "first_tax_name": "", "first_tax_rate": 0, "second_tax_rate_id": 0, "second_tax_value": 0, "second_tax_name": "", "second_tax_rate": 0, "second_tax_is_enabled": false, "second_tax_is_compound": false, "subtotal": 600, "subtotal_without_discount": 600, "discount": 0, "total": 600, "position": 1, "time_record_ids": [ 1, 2 ], "expense_ids": [] }, { "id": 8, "class": "InvoiceItem", "url_path": "\/invoice-items\/8", "parent_type": "Invoice", "parent_id": 3, "discount_rate": 0, "description": "Other expenses", "quantity": 1, "unit_cost": 630.5, "first_tax_rate_id": 0, "first_tax_value": 0, "first_tax_name": "", "first_tax_rate": 0, "second_tax_rate_id": 0, "second_tax_value": 0, "second_tax_name": "", "second_tax_rate": 0, "second_tax_is_enabled": false, "second_tax_is_compound": false, "subtotal": 630.5, "subtotal_without_discount": 630.5, "discount": 0, "total": 630.5, "position": 2, "time_record_ids": [], "expense_ids": [ 1, 2 ] } ], "time_records": [ { "id": 1, "class": "TimeRecord", "url_path": "\/projects\/1\/time-records\/1", "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "billable_status": 2, "value": 1.5, "record_date": 1400025600, "summary": "Billable project time record", "user_id": 1, "parent_type": "Project", "parent_id": 1, "created_on": 1430164747, "created_by_id": 1, "updated_on": 1430164750, "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": 2, "value": 2.5, "record_date": 1400112000, "summary": "Billable task time record", "user_id": 1, "parent_type": "Task", "parent_id": 1, "created_on": 1430164747, "created_by_id": 1, "updated_on": 1430164750, "updated_by_id": 1, "job_type_id": 1 } ], "expenses": [ { "id": 1, "class": "Expense", "url_path": "\/projects\/1\/expenses\/1", "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "billable_status": 2, "value": 250, "record_date": 1400025600, "summary": "Billable project expense", "user_id": 1, "parent_type": "Project", "parent_id": 1, "created_on": 1430164747, "created_by_id": 1, "updated_on": 1430164750, "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": 2, "value": 380.5, "record_date": 1400112000, "summary": "Billable task expense", "user_id": 1, "parent_type": "Task", "parent_id": 1, "created_on": 1430164748, "created_by_id": 1, "updated_on": 1430164750, "updated_by_id": 1, "category_id": 1, "currency_id": 1 } ], "payments": [] }
Please notice sum_by
parameter in the previous request. This parameter can have one of the following values:
sum_all
- Sum all records as a single invoice item,sum_all_by_project
- Sum all records and as them groupe by project,sum_all_by_task
- Sum all records based on their tasks. Non-task related records are grouped per project,sum_records_by_job_type
- Sum time records based on their job type. Expenses go as a separate line item,keep_records_as_separate_invoice_items
- Each time record and expense will have their own line item.
Lets try group by task option. Before that, we need to release time records and 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
{ "single": { "id": 3, "class": "Invoice", "url_path": "\/invoices\/3", "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "company_id": 2, "company_name": "Client Company GmbH", "company_address": "Street Name 12\nCity", "note": null, "currency_id": 1, "language_id": 0, "discount_rate": 0, "subtotal": 1230.5, "subtotal_without_discount": 1230.5, "discount": 0, "tax": 0, "rounding_difference": 0, "rounded_total": 1230.5, "total": 1230.5, "paid_amount": 0, "balance_due": 1230.5, "recipients": null, "email_from": null, "email_subject": null, "email_body": null, "second_tax_is_enabled": false, "second_tax_is_compound": false, "created_on": 1430164750, "created_by_id": 1, "updated_on": 1430164750, "based_on_type": null, "based_on_id": null, "number": "3\/2014", "project_id": 0, "purchase_order_number": null, "issued_on": 1430092800, "due_on": 1430092800, "allow_payments": 1, "closed_on": null, "sent_on": null, "hash": "21604ai2QEkYwfjwxNa4ikDc97LZL0PB0Kz3LITr", "status": "issued", "public_url": "http:\/\/feather.dev\/s\/invoice?hash=21604ai2QEkYwfjwxNa4ikDc97LZL0PB0Kz3LITr&number=3%2F2014", "is_credit_invoice": false }, "reminders": [], "items": [ { "id": 7, "class": "InvoiceItem", "url_path": "\/invoice-items\/7", "parent_type": "Invoice", "parent_id": 3, "discount_rate": 0, "description": "Project Test Project", "quantity": 4, "unit_cost": 150, "first_tax_rate_id": 0, "first_tax_value": 0, "first_tax_name": "", "first_tax_rate": 0, "second_tax_rate_id": 0, "second_tax_value": 0, "second_tax_name": "", "second_tax_rate": 0, "second_tax_is_enabled": false, "second_tax_is_compound": false, "subtotal": 600, "subtotal_without_discount": 600, "discount": 0, "total": 600, "position": 1, "time_record_ids": [ 1, 2 ], "expense_ids": [] }, { "id": 8, "class": "InvoiceItem", "url_path": "\/invoice-items\/8", "parent_type": "Invoice", "parent_id": 3, "discount_rate": 0, "description": "Other expenses", "quantity": 1, "unit_cost": 630.5, "first_tax_rate_id": 0, "first_tax_value": 0, "first_tax_name": "", "first_tax_rate": 0, "second_tax_rate_id": 0, "second_tax_value": 0, "second_tax_name": "", "second_tax_rate": 0, "second_tax_is_enabled": false, "second_tax_is_compound": false, "subtotal": 630.5, "subtotal_without_discount": 630.5, "discount": 0, "total": 630.5, "position": 2, "time_record_ids": [], "expense_ids": [ 1, 2 ] } ], "time_records": [], "expenses": [], "payments": [] }
Now we'll set sum_by
to sum_all_by_task
and create a new invoice:
Payload:
1 2 3 4 5 6 7 8 9 10 11 12
{ "company_id": 2, "number": "4\/2014", "items_from_tracked_data": { "project_ids": [ 1 ], "include_time_records": true, "include_expenses": true, "sum_by": "sum_all_by_task" } }
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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
{ "single": { "id": 4, "class": "Invoice", "url_path": "\/invoices\/4", "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "company_id": 2, "company_name": "Client Company GmbH", "company_address": "Street Name 12\nCity", "note": null, "currency_id": 1, "language_id": 0, "discount_rate": 0, "subtotal": 1230.5, "subtotal_without_discount": 1230.5, "discount": 0, "tax": 0, "rounding_difference": 0, "rounded_total": 1230.5, "total": 1230.5, "paid_amount": 0, "balance_due": 1230.5, "recipients": null, "email_from": null, "email_subject": null, "email_body": null, "second_tax_is_enabled": false, "second_tax_is_compound": false, "created_on": 1430164750, "created_by_id": 1, "updated_on": 1430164750, "based_on_type": null, "based_on_id": null, "number": "4\/2014", "project_id": 0, "purchase_order_number": null, "issued_on": 1430164750, "due_on": 1430164750, "allow_payments": 1, "closed_on": null, "sent_on": null, "hash": "zhPHWDHMIJ5d5AohFPZCTDzmTLWFQYbe6QLRiisR", "status": "issued", "public_url": "http:\/\/feather.dev\/s\/invoice?hash=zhPHWDHMIJ5d5AohFPZCTDzmTLWFQYbe6QLRiisR&number=4%2F2014", "is_credit_invoice": false }, "reminders": [], "items": [ { "id": 9, "class": "InvoiceItem", "url_path": "\/invoice-items\/9", "parent_type": "Invoice", "parent_id": 4, "discount_rate": 0, "description": "Project Test Project", "quantity": 1.5, "unit_cost": 150, "first_tax_rate_id": 0, "first_tax_value": 0, "first_tax_name": "", "first_tax_rate": 0, "second_tax_rate_id": 0, "second_tax_value": 0, "second_tax_name": "", "second_tax_rate": 0, "second_tax_is_enabled": false, "second_tax_is_compound": false, "subtotal": 225, "subtotal_without_discount": 225, "discount": 0, "total": 225, "position": 1, "time_record_ids": [ 1 ], "expense_ids": [] }, { "id": 10, "class": "InvoiceItem", "url_path": "\/invoice-items\/10", "parent_type": "Invoice", "parent_id": 4, "discount_rate": 0, "description": "Task #1: Test Task (Test Project)", "quantity": 2.5, "unit_cost": 150, "first_tax_rate_id": 0, "first_tax_value": 0, "first_tax_name": "", "first_tax_rate": 0, "second_tax_rate_id": 0, "second_tax_value": 0, "second_tax_name": "", "second_tax_rate": 0, "second_tax_is_enabled": false, "second_tax_is_compound": false, "subtotal": 375, "subtotal_without_discount": 375, "discount": 0, "total": 375, "position": 2, "time_record_ids": [ 2 ], "expense_ids": [] }, { "id": 11, "class": "InvoiceItem", "url_path": "\/invoice-items\/11", "parent_type": "Invoice", "parent_id": 4, "discount_rate": 0, "description": "Other expenses", "quantity": 1, "unit_cost": 630.5, "first_tax_rate_id": 0, "first_tax_value": 0, "first_tax_name": "", "first_tax_rate": 0, "second_tax_rate_id": 0, "second_tax_value": 0, "second_tax_name": "", "second_tax_rate": 0, "second_tax_is_enabled": false, "second_tax_is_compound": false, "subtotal": 630.5, "subtotal_without_discount": 630.5, "discount": 0, "total": 630.5, "position": 3, "time_record_ids": [], "expense_ids": [ 1, 2 ] } ], "time_records": [ { "id": 1, "class": "TimeRecord", "url_path": "\/projects\/1\/time-records\/1", "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "billable_status": 2, "value": 1.5, "record_date": 1400025600, "summary": "Billable project time record", "user_id": 1, "parent_type": "Project", "parent_id": 1, "created_on": 1430164747, "created_by_id": 1, "updated_on": 1430164750, "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": 2, "value": 2.5, "record_date": 1400112000, "summary": "Billable task time record", "user_id": 1, "parent_type": "Task", "parent_id": 1, "created_on": 1430164747, "created_by_id": 1, "updated_on": 1430164750, "updated_by_id": 1, "job_type_id": 1 } ], "expenses": [ { "id": 1, "class": "Expense", "url_path": "\/projects\/1\/expenses\/1", "is_trashed": false, "trashed_on": null, "trashed_by_id": 0, "billable_status": 2, "value": 250, "record_date": 1400025600, "summary": "Billable project expense", "user_id": 1, "parent_type": "Project", "parent_id": 1, "created_on": 1430164747, "created_by_id": 1, "updated_on": 1430164750, "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": 2, "value": 380.5, "record_date": 1400112000, "summary": "Billable task expense", "user_id": 1, "parent_type": "Task", "parent_id": 1, "created_on": 1430164748, "created_by_id": 1, "updated_on": 1430164750, "updated_by_id": 1, "category_id": 1, "currency_id": 1 } ], "payments": [] }