Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AE UTBM
Sith
Commits
57bb0720
Commit
57bb0720
authored
Jan 05, 2017
by
Skia
🤘
Browse files
Merge branch 'Tresorerie' into 'master'
Add benefit on sellings view See merge request
!41
parents
a90a5539
2c71c18d
Pipeline
#685
passed with stage
in 3 minutes and 23 seconds
Changes
3
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
club/templates/club/club_sellings.jinja
View file @
57bb0720
...
...
@@ -11,7 +11,8 @@
</form>
<p>
{%
trans
%}
Quantity:
{%
endtrans
%}{{
total_quantity
}}
{%
trans
%}
units
{%
endtrans
%}
<br/>
{%
trans
%}
Total:
{%
endtrans
%}{{
total
}}
€
{%
trans
%}
Total:
{%
endtrans
%}{{
total
}}
€
<br/>
{%
trans
%}
Benefit:
{%
endtrans
%}{{
benefit
}}
€
</p>
<table>
<thead>
...
...
club/views.py
View file @
57bb0720
...
...
@@ -203,6 +203,7 @@ class ClubSellingView(ClubTabsMixin, CanEditMixin, DetailView):
kwargs
[
'result'
]
=
qs
.
all
().
order_by
(
'-id'
)
kwargs
[
'total'
]
=
sum
([
s
.
quantity
*
s
.
unit_price
for
s
in
qs
.
all
()])
kwargs
[
'total_quantity'
]
=
sum
([
s
.
quantity
for
s
in
qs
.
all
()])
kwargs
[
'benefit'
]
=
kwargs
[
'total'
]
-
sum
([
s
.
product
.
purchase_price
for
s
in
qs
.
exclude
(
product
=
None
)])
else
:
kwargs
[
'result'
]
=
qs
[:
0
]
kwargs
[
'form'
]
=
form
...
...
@@ -222,8 +223,11 @@ class ClubSellingCSVView(ClubSellingView):
kwargs
=
self
.
get_context_data
(
**
kwargs
)
writer
=
csv
.
writer
(
response
,
delimiter
=
";"
,
lineterminator
=
'
\n
'
,
quoting
=
csv
.
QUOTE_ALL
)
writer
.
writerow
([
_t
(
'Quantity'
),
kwargs
[
'total_quantity'
]])
writer
.
writerow
([
_t
(
'Total'
),
kwargs
[
'total'
]])
writer
.
writerow
([
_t
(
'Benefit'
),
kwargs
[
'benefit'
]])
writer
.
writerow
([
_t
(
'Date'
),
_t
(
'Counter'
),
_t
(
'Barman'
),
_t
(
'Customer'
),
_t
(
'Label'
),
_t
(
'Quantity'
),
_t
(
'Total'
),
_t
(
'Payment method'
)])
_t
(
'Quantity'
),
_t
(
'Total'
),
_t
(
'Payment method'
)
,
_t
(
'Selling price'
),
_t
(
'Purchase price'
),
_t
(
'Benefit'
)
])
for
o
in
kwargs
[
'result'
]:
row
=
[
o
.
date
,
o
.
counter
]
if
o
.
seller
:
...
...
@@ -234,6 +238,11 @@ class ClubSellingCSVView(ClubSellingView):
else
:
row
.
append
(
''
)
row
=
row
+
[
o
.
label
,
o
.
quantity
,
o
.
quantity
*
o
.
unit_price
,
o
.
get_payment_method_display
()]
if
o
.
product
:
row
.
append
(
o
.
product
.
selling_price
)
row
.
append
(
o
.
product
.
purchase_price
)
row
.
append
(
o
.
product
.
selling_price
-
o
.
product
.
purchase_price
)
else
:
row
=
row
+
[
''
,
''
,
''
]
writer
.
writerow
(
row
)
return
response
...
...
locale/fr/LC_MESSAGES/django.po
View file @
57bb0720
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment