diff --git a/doc/api/resources/invoices.rst b/doc/api/resources/invoices.rst index 30fb4005c5..5dde127c32 100644 --- a/doc/api/resources/invoices.rst +++ b/doc/api/resources/invoices.rst @@ -58,6 +58,15 @@ lines list of objects The actual invo created before this field was introduced as well as for all lines not created by a product (e.g. a shipping or cancellation fee). +├ fee_type string Fee type, e.g. ``shipping``, ``service``, ``payment``, + ``cancellation``, ``giftcard``, or ``other. Can be ``null`` for + all invoice lines + created before this field was introduced as well as for + all lines not created by a fee (e.g. a product). +├ fee_internal_type string Additional fee type, e.g. type of payment provider. Can be ``null`` + for all invoice lines + created before this field was introduced as well as for + all lines not created by a fee (e.g. a product). ├ event_date_from datetime Start date of the (sub)event this line was created for as it was set during invoice creation. Can be ``null`` for all invoice lines created before this was introduced as well as for lines in @@ -97,6 +106,10 @@ internal_reference string Customer's refe ``lines.event_date_to``, and ``lines.attendee_name`` have been added. ``refers`` now returns an invoice number including the prefix. +.. versionchanged:: 4.1 + + The attributes ``fee_type`` and ``fee_internal_type`` have been added. + Endpoints --------- @@ -162,6 +175,8 @@ Endpoints "description": "Budget Ticket", "item": 1234, "variation": 245, + "fee_type": null, + "fee_internal_type": null, "event_date_from": "2017-12-27T10:00:00Z", "event_date_to": null, "attendee_name": null, @@ -248,6 +263,8 @@ Endpoints "description": "Budget Ticket", "item": 1234, "variation": 245, + "fee_type": null, + "fee_internal_type": null, "event_date_from": "2017-12-27T10:00:00Z", "event_date_to": null, "attendee_name": null, diff --git a/src/pretix/api/serializers/order.py b/src/pretix/api/serializers/order.py index a51da18636..f4267f7348 100644 --- a/src/pretix/api/serializers/order.py +++ b/src/pretix/api/serializers/order.py @@ -1425,7 +1425,8 @@ class InlineInvoiceLineSerializer(I18nAwareModelSerializer): class Meta: model = InvoiceLine fields = ('position', 'description', 'item', 'variation', 'attendee_name', 'event_date_from', - 'event_date_to', 'gross_value', 'tax_value', 'tax_rate', 'tax_name') + 'event_date_to', 'gross_value', 'tax_value', 'tax_rate', 'tax_name', 'fee_type', + 'fee_internal_type') class InvoiceSerializer(I18nAwareModelSerializer): diff --git a/src/pretix/base/migrations/0195_auto_20210622_1457.py b/src/pretix/base/migrations/0195_auto_20210622_1457.py new file mode 100644 index 0000000000..ad5f5af9ef --- /dev/null +++ b/src/pretix/base/migrations/0195_auto_20210622_1457.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.3 on 2021-06-22 14:57 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('pretixbase', '0194_membership_canceled'), + ] + + operations = [ + migrations.AddField( + model_name='invoiceline', + name='fee_internal_type', + field=models.CharField(max_length=190, null=True), + ), + migrations.AddField( + model_name='invoiceline', + name='fee_type', + field=models.CharField(max_length=190, null=True), + ), + ] diff --git a/src/pretix/base/models/invoices.py b/src/pretix/base/models/invoices.py index fe1220608b..8e2a81b6a6 100644 --- a/src/pretix/base/models/invoices.py +++ b/src/pretix/base/models/invoices.py @@ -343,6 +343,8 @@ class InvoiceLine(models.Model): item = models.ForeignKey('Item', null=True, blank=True, on_delete=models.PROTECT) variation = models.ForeignKey('ItemVariation', null=True, blank=True, on_delete=models.PROTECT) attendee_name = models.TextField(null=True, blank=True) + fee_type = models.CharField(max_length=190, null=True, blank=True) + fee_internal_type = models.CharField(max_length=190, null=True, blank=True) @property def net_value(self): diff --git a/src/pretix/base/services/invoices.py b/src/pretix/base/services/invoices.py index 32424f2680..d0f6199461 100644 --- a/src/pretix/base/services/invoices.py +++ b/src/pretix/base/services/invoices.py @@ -244,7 +244,9 @@ def build_invoice(invoice: Invoice) -> Invoice: event_date_to=None if invoice.event.has_subevents else invoice.event.date_to, tax_value=fee.tax_value, tax_rate=fee.tax_rate, - tax_name=fee.tax_rule.name if fee.tax_rule else '' + tax_name=fee.tax_rule.name if fee.tax_rule else '', + fee_type=fee.fee_type, + fee_internal_type=fee.internal_type or None, ) if fee.tax_rule and fee.tax_rule.is_reverse_charge(ia) and fee.value and not fee.tax_value: diff --git a/src/tests/api/test_orders.py b/src/tests/api/test_orders.py index 07ee22f554..b48f059bc4 100644 --- a/src/tests/api/test_orders.py +++ b/src/tests/api/test_orders.py @@ -1024,6 +1024,8 @@ TEST_INVOICE_RES = { 'attendee_name': 'Peter', 'item': None, 'variation': None, + 'fee_type': None, + 'fee_internal_type': None, "gross_value": "23.00", "tax_value": "0.00", "tax_name": "", @@ -1035,6 +1037,8 @@ TEST_INVOICE_RES = { 'event_date_from': '2017-12-27T10:00:00Z', 'event_date_to': None, 'attendee_name': None, + 'fee_type': "payment", + 'fee_internal_type': None, 'item': None, 'variation': None, "gross_value": "0.25", @@ -4401,6 +4405,8 @@ def test_order_create_invoice(token_client, organizer, event, order): 'description': 'Budget Ticket
Attendee: Peter', 'event_date_from': '2017-12-27T10:00:00Z', 'event_date_to': None, + 'fee_type': None, + 'fee_internal_type': None, 'attendee_name': 'Peter', 'item': pos.item_id, 'variation': None, @@ -4414,6 +4420,8 @@ def test_order_create_invoice(token_client, organizer, event, order): 'description': 'Payment fee', 'event_date_from': '2017-12-27T10:00:00Z', 'event_date_to': None, + 'fee_type': "payment", + 'fee_internal_type': None, 'attendee_name': None, 'item': None, 'variation': None, diff --git a/src/tests/base/test_invoices.py b/src/tests/base/test_invoices.py index fa89fb172b..85da6c2e83 100644 --- a/src/tests/base/test_invoices.py +++ b/src/tests/base/test_invoices.py @@ -341,6 +341,7 @@ def test_positions(env): assert last.gross_value == fee.value assert last.tax_rate == fee.tax_rate assert last.tax_value == fee.tax_value + assert last.fee_type == 'payment' assert inv.invoice_to == ""