mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
move to abstract model
This commit is contained in:
parent
2036164ef1
commit
72d565d17a
@ -151,6 +151,23 @@ class Order(ReferenceIndexingMixin):
|
|||||||
|
|
||||||
notes = MarkdownxField(blank=True, verbose_name=_('Notes'), help_text=_('Order notes'))
|
notes = MarkdownxField(blank=True, verbose_name=_('Notes'), help_text=_('Order notes'))
|
||||||
|
|
||||||
|
def get_total_price(self):
|
||||||
|
"""
|
||||||
|
Calculates the total price of all order lines
|
||||||
|
"""
|
||||||
|
target_currency = currency_code_default()
|
||||||
|
total = Money(0, target_currency)
|
||||||
|
|
||||||
|
# order items
|
||||||
|
total += sum([a.quantity * convert_money(a.sale_price, target_currency) for a in self.lines.all() if a.sale_price])
|
||||||
|
|
||||||
|
# additional lines
|
||||||
|
total += sum([a.quantity * convert_money(a.sale_price, target_currency) for a in self.additional_lines.all() if a.sale_price])
|
||||||
|
|
||||||
|
# set decimal-places
|
||||||
|
total.decimal_places = 4
|
||||||
|
return total
|
||||||
|
|
||||||
|
|
||||||
class PurchaseOrder(Order):
|
class PurchaseOrder(Order):
|
||||||
""" A PurchaseOrder represents goods shipped inwards from an external supplier.
|
""" A PurchaseOrder represents goods shipped inwards from an external supplier.
|
||||||
@ -601,23 +618,6 @@ class SalesOrder(Order):
|
|||||||
verbose_name=_('shipped by')
|
verbose_name=_('shipped by')
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_total_price(self):
|
|
||||||
"""
|
|
||||||
Calculates the total price of all order lines
|
|
||||||
"""
|
|
||||||
target_currency = currency_code_default()
|
|
||||||
total = Money(0, target_currency)
|
|
||||||
|
|
||||||
# order items
|
|
||||||
total += sum([a.quantity * convert_money(a.sale_price, target_currency) for a in self.lines.all() if a.sale_price])
|
|
||||||
|
|
||||||
# additional lines
|
|
||||||
total += sum([a.quantity * convert_money(a.sale_price, target_currency) for a in self.additional_lines.all() if a.sale_price])
|
|
||||||
|
|
||||||
# set decimal-places
|
|
||||||
total.decimal_places = 4
|
|
||||||
return total
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_overdue(self):
|
def is_overdue(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user