Fix bill generation
This commit is contained in:
parent
56d98cbb55
commit
3874165189
1 changed files with 10 additions and 11 deletions
|
@ -521,8 +521,7 @@ class Bill(models.Model):
|
||||||
bill_records = []
|
bill_records = []
|
||||||
orders = Order.objects.filter(bill=self)
|
orders = Order.objects.filter(bill=self)
|
||||||
for order in orders:
|
for order in orders:
|
||||||
for order_record in order.records:
|
bill_record = BillRecord(self, order)
|
||||||
bill_record = BillRecord(self, order_record)
|
|
||||||
bill_records.append(bill_record)
|
bill_records.append(bill_record)
|
||||||
|
|
||||||
return bill_records
|
return bill_records
|
||||||
|
@ -710,18 +709,18 @@ class Bill(models.Model):
|
||||||
|
|
||||||
class BillRecord():
|
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.bill = bill
|
||||||
self.order = order_record.order
|
self.order = order
|
||||||
self.recurring_price = order_record.recurring_price
|
self.recurring_price = order.recurring_price
|
||||||
self.recurring_period = order_record.recurring_period
|
self.recurring_period = order.recurring_period
|
||||||
self.description = order_record.description
|
self.description = order.description
|
||||||
|
|
||||||
if self.order.starting_date >= self.bill.starting_date:
|
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:
|
else:
|
||||||
self.one_time_price = 0
|
self.one_time_price = 0
|
||||||
|
|
||||||
|
@ -779,7 +778,7 @@ class BillRecord():
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
raise Exception('Unsupported recurring period: {}.'.
|
raise Exception('Unsupported recurring period: {}.'.
|
||||||
format(record.recurring_period))
|
format(self.order.recurring_period))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def vat_rate(self):
|
def vat_rate(self):
|
||||||
|
|
Loading…
Reference in a new issue