mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 19:14:30 +00:00
Used lambda function in user detail
This commit is contained in:
parent
41d5a02d77
commit
2f7dc9ec19
@ -345,18 +345,12 @@ class UserAccountView(UserAccountBase):
|
|||||||
|
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
def buyings_calc(self, query):
|
|
||||||
return query.unit_price * query.quantity
|
|
||||||
|
|
||||||
def invoices_calc(self, query):
|
def invoices_calc(self, query):
|
||||||
t = 0
|
t = 0
|
||||||
for it in query.items.all():
|
for it in query.items.all():
|
||||||
t += it.quantity * it.product_unit_price
|
t += it.quantity * it.product_unit_price
|
||||||
return t
|
return t
|
||||||
|
|
||||||
def refilling_calc(self, query):
|
|
||||||
return query.amount
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
kwargs = super(UserAccountView, self).get_context_data(**kwargs)
|
kwargs = super(UserAccountView, self).get_context_data(**kwargs)
|
||||||
kwargs['profile'] = self.object
|
kwargs['profile'] = self.object
|
||||||
@ -364,7 +358,7 @@ class UserAccountView(UserAccountBase):
|
|||||||
kwargs['customer'] = self.object.customer
|
kwargs['customer'] = self.object.customer
|
||||||
kwargs['buyings_month'] = self.expense_by_month(
|
kwargs['buyings_month'] = self.expense_by_month(
|
||||||
self.object.customer.buyings,
|
self.object.customer.buyings,
|
||||||
self.buyings_calc
|
(lambda q: q.unit_price * q.quantity)
|
||||||
)
|
)
|
||||||
kwargs['invoices_month'] = self.expense_by_month(
|
kwargs['invoices_month'] = self.expense_by_month(
|
||||||
self.object.customer.user.invoices,
|
self.object.customer.user.invoices,
|
||||||
@ -372,7 +366,7 @@ class UserAccountView(UserAccountBase):
|
|||||||
)
|
)
|
||||||
kwargs['refilling_month'] = self.expense_by_month(
|
kwargs['refilling_month'] = self.expense_by_month(
|
||||||
self.object.customer.refillings,
|
self.object.customer.refillings,
|
||||||
self.refilling_calc
|
(lambda q: q.amount)
|
||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user