Commit 38741651 authored by fnux's avatar fnux

Fix bill generation

parent 56d98cbb
Pipeline #1397 failed with stage
in 3 minutes and 10 seconds
......@@ -521,9 +521,8 @@ class Bill(models.Model):
bill_records = []
orders = Order.objects.filter(bill=self)
for order in orders:
for order_record in order.records:
bill_record = BillRecord(self, order_record)
bill_records.append(bill_record)
bill_record = BillRecord(self, order)
bill_records.append(bill_record)
return bill_records
......@@ -710,18 +709,18 @@ class Bill(models.Model):
class BillRecord():
"""
Entry of a bill, dynamically generated from order records.
Entry of a bill, dynamically generated from an order.
"""
def __init__(self, bill, order_record):
def __init__(self, bill, order):
self.bill = bill
self.order = order_record.order
self.recurring_price = order_record.recurring_price
self.recurring_period = order_record.recurring_period
self.description = order_record.description
self.order = order
self.recurring_price = order.recurring_price
self.recurring_period = order.recurring_period
self.description = order.description
if self.order.starting_date >= self.bill.starting_date:
self.one_time_price = order_record.one_time_price
self.one_time_price = order.one_time_price
else:
self.one_time_price = 0
......@@ -779,7 +778,7 @@ class BillRecord():
return 0
else:
raise Exception('Unsupported recurring period: {}.'.
format(record.recurring_period))
format(self.order.recurring_period))
@property
def vat_rate(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment