Fix bill generation
This commit is contained in:
parent
56d98cbb55
commit
3874165189
1 changed files with 10 additions and 11 deletions
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue