Discounts
When you create a new invoice, you can sepficy a discount rate. This rate is a value between 0 and 100 and it is applied to all invoice items, priour to them being taxed. Lets create an invoice with 15% discount:
Response: HTTP 200, application/json (Hide)
POST /invoices
Payload:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
{
"company_id": 2,
"number": "1\/2014",
"discount_rate": 15,
"items": [
{
"description": "First item",
"quantity": 100,
"unit_cost": 25
},
{
"description": "Second item",
"quantity": 250,
"unit_cost": 100,
"first_tax_rate_id": 1
}
]
}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
{
"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": 15,
"subtotal": 23375,
"subtotal_without_discount": 27500,
"discount": 4125,
"tax": 3718.75,
"rounding_difference": 0,
"rounded_total": 27093.75,
"total": 27093.75,
"paid_amount": 0,
"balance_due": 27093.75,
"recipients": null,
"email_from": null,
"email_subject": null,
"email_body": null,
"second_tax_is_enabled": false,
"second_tax_is_compound": false,
"created_on": 1430164740,
"created_by_id": 1,
"updated_on": 1430164740,
"based_on_type": null,
"based_on_id": null,
"number": "1\/2014",
"project_id": 0,
"purchase_order_number": null,
"issued_on": 1430164740,
"due_on": 1430164740,
"allow_payments": 1,
"closed_on": null,
"sent_on": null,
"hash": "dbxy3d7WjwHX2eypeXqopaarEOc1gQIjS6IJ0Dvh",
"status": "issued",
"public_url": "http:\/\/feather.dev\/s\/invoice?hash=dbxy3d7WjwHX2eypeXqopaarEOc1gQIjS6IJ0Dvh&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": 15,
"description": "First item",
"quantity": 100,
"unit_cost": 25,
"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": 2125,
"subtotal_without_discount": 2500,
"discount": 375,
"total": 2125,
"position": 1,
"time_record_ids": [],
"expense_ids": []
},
{
"id": 2,
"class": "InvoiceItem",
"url_path": "\/invoice-items\/2",
"parent_type": "Invoice",
"parent_id": 1,
"discount_rate": 15,
"description": "Second item",
"quantity": 250,
"unit_cost": 100,
"first_tax_rate_id": 1,
"first_tax_value": 3718.75,
"first_tax_name": "VAT",
"first_tax_rate": 17.5,
"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": 21250,
"subtotal_without_discount": 25000,
"discount": 3750,
"total": 24968.75,
"position": 2,
"time_record_ids": [],
"expense_ids": []
}
],
"time_records": [],
"expenses": [],
"payments": []
}If we update the discount rate, it will propagate to the items:
Response: HTTP 200, application/json (Hide)
PUT /invoices/1
Payload:
1 2 3
{
"discount_rate": 25
}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
{
"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": 25,
"subtotal": 20625,
"subtotal_without_discount": 27500,
"discount": 6875,
"tax": 3281.25,
"rounding_difference": 0,
"rounded_total": 23906.25,
"total": 23906.25,
"paid_amount": 0,
"balance_due": 27093.75,
"recipients": null,
"email_from": null,
"email_subject": null,
"email_body": null,
"second_tax_is_enabled": false,
"second_tax_is_compound": false,
"created_on": 1430164740,
"created_by_id": 1,
"updated_on": 1430164740,
"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": "dbxy3d7WjwHX2eypeXqopaarEOc1gQIjS6IJ0Dvh",
"status": "issued",
"public_url": "http:\/\/feather.dev\/s\/invoice?hash=dbxy3d7WjwHX2eypeXqopaarEOc1gQIjS6IJ0Dvh&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": 25,
"description": "First item",
"quantity": 100,
"unit_cost": 25,
"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": 1875,
"subtotal_without_discount": 2500,
"discount": 625,
"total": 1875,
"position": 1,
"time_record_ids": [],
"expense_ids": []
},
{
"id": 2,
"class": "InvoiceItem",
"url_path": "\/invoice-items\/2",
"parent_type": "Invoice",
"parent_id": 1,
"discount_rate": 25,
"description": "Second item",
"quantity": 250,
"unit_cost": 100,
"first_tax_rate_id": 1,
"first_tax_value": 3281.25,
"first_tax_name": "VAT",
"first_tax_rate": 17.5,
"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": 18750,
"subtotal_without_discount": 25000,
"discount": 6250,
"total": 22031.25,
"position": 2,
"time_record_ids": [],
"expense_ids": []
}
],
"time_records": [],
"expenses": [],
"payments": []
}