Add TaxRule selection in OrderPositionChange (#1700)

Co-authored-by: Raphael Michel <mail@raphaelmichel.de>
This commit is contained in:
Martin Gross
2020-06-30 11:13:33 +02:00
committed by GitHub
parent 626e332886
commit 5f50aa95eb
12 changed files with 176 additions and 8 deletions

View File

@@ -4224,6 +4224,7 @@ def test_orderposition_price_calculation(token_client, organizer, event, order,
'name': '',
'net': Decimal('23.00'),
'rate': Decimal('0.00'),
'tax_rule': None,
'tax': Decimal('0.00')
}
@@ -4246,6 +4247,7 @@ def test_orderposition_price_calculation_item_with_tax(token_client, organizer,
'name': '',
'net': Decimal('19.33'),
'rate': Decimal('19.00'),
'tax_rule': taxrule.pk,
'tax': Decimal('3.67')
}
@@ -4270,6 +4272,7 @@ def test_orderposition_price_calculation_item_with_variation(token_client, organ
'name': '',
'net': Decimal('12.00'),
'rate': Decimal('0.00'),
'tax_rule': None,
'tax': Decimal('0.00')
}
@@ -4295,6 +4298,7 @@ def test_orderposition_price_calculation_subevent(token_client, organizer, event
'name': '',
'net': Decimal('23.00'),
'rate': Decimal('0.00'),
'tax_rule': None,
'tax': Decimal('0.00')
}
@@ -4322,6 +4326,7 @@ def test_orderposition_price_calculation_subevent_with_override(token_client, or
'name': '',
'net': Decimal('12.00'),
'rate': Decimal('0.00'),
'tax_rule': None,
'tax': Decimal('0.00')
}
@@ -4350,6 +4355,7 @@ def test_orderposition_price_calculation_voucher_matching(token_client, organize
'name': '',
'net': Decimal('15.00'),
'rate': Decimal('0.00'),
'tax_rule': None,
'tax': Decimal('0.00')
}
@@ -4377,6 +4383,7 @@ def test_orderposition_price_calculation_voucher_not_matching(token_client, orga
'name': '',
'net': Decimal('23.00'),
'rate': Decimal('0.00'),
'tax_rule': None,
'tax': Decimal('0.00')
}
@@ -4401,6 +4408,7 @@ def test_orderposition_price_calculation_net_price(token_client, organizer, even
'name': '',
'net': Decimal('10.00'),
'rate': Decimal('19.00'),
'tax_rule': taxrule.pk,
'tax': Decimal('1.90')
}
@@ -4432,5 +4440,6 @@ def test_orderposition_price_calculation_reverse_charge(token_client, organizer,
'name': '',
'net': Decimal('10.00'),
'rate': Decimal('0.00'),
'tax_rule': taxrule.pk,
'tax': Decimal('0.00')
}

View File

@@ -2262,6 +2262,72 @@ class OrderChangeManagerTests(TestCase):
self.order.refresh_from_db()
assert self.order.total == Decimal('46.00')
@classscope(attr='o')
def test_change_taxrate(self):
self.ocm.change_tax_rule(self.op1, self.tr19)
self.ocm.commit()
self.order.refresh_from_db()
nop = self.order.positions.first()
assert nop.price == Decimal('23.00')
assert nop.tax_rule != self.ticket.tax_rule
assert nop.tax_rate == self.tr19.rate
assert round_decimal(nop.price * (1 - 100 / (100 + self.tr19.rate))) == nop.tax_value
@classscope(attr='o')
def test_change_taxrate_and_product(self):
self.ocm.change_item(self.op1, self.shirt, None)
self.ocm.change_tax_rule(self.op1, self.tr7)
self.ocm.commit()
self.order.refresh_from_db()
nop = self.order.positions.first()
assert nop.item == self.shirt
assert nop.price == Decimal('23.00')
assert nop.tax_rule != self.shirt.tax_rule
assert nop.tax_rate == self.tr7.rate
assert round_decimal(nop.price * (1 - 100 / (100 + self.tr7.rate))) == nop.tax_value
@classscope(attr='o')
def test_change_taxrate_to_reverse_charge(self):
self.tr19.eu_reverse_charge = True
self.tr19.home_country = Country('DE')
self.tr19.save()
InvoiceAddress.objects.create(
order=self.order, is_business=True, vat_id='ATU1234567', vat_id_validated=True,
country=Country('AT')
)
self.ocm.change_tax_rule(self.op1, self.tr19)
self.ocm.commit()
self.order.refresh_from_db()
nop = self.order.positions.first()
assert nop.price == Decimal('23.00')
assert nop.tax_rule == self.tr19
assert nop.tax_rate == Decimal('0.00')
assert nop.tax_value == Decimal('0.00')
@classscope(attr='o')
def test_change_taxrate_from_reverse_charge(self):
self.tr7.eu_reverse_charge = True
self.tr7.home_country = Country('DE')
self.tr7.save()
nop = self.order.positions.first()
nop.tax_value = Decimal('0.00')
nop.tax_rate = Decimal('0.00')
nop.save()
InvoiceAddress.objects.create(
order=self.order, is_business=True, vat_id='ATU1234567', vat_id_validated=True,
country=Country('AT')
)
self.ocm.change_tax_rule(self.op1, self.tr19)
self.ocm.commit()
self.order.refresh_from_db()
nop = self.order.positions.first()
assert nop.price == Decimal('23.00')
assert nop.tax_rule == self.tr19
assert nop.tax_rate == Decimal('19.00')
assert nop.tax_value == Decimal('3.67')
@pytest.mark.django_db
def test_autocheckin(clist_autocheckin, event):