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
1457a7bf
Commit
1457a7bf
authored
Dec 21, 2016
by
Krophil
Committed by
Skia
Dec 21, 2016
Browse files
Bilan for accounting added
parent
96c6bf80
Changes
2
Hide whitespace changes
Inline
Side-by-side
accounting/templates/accounting/journal_bilan_accounting.jinja
View file @
1457a7bf
...
...
@@ -21,13 +21,13 @@
{%
for
key
in
bilan.keys
()
%}
<tr>
<td>
{{
key
}}
</td>
<td>
{{
bilan
[
key
]
}}
</td>
<td>
{{
bilan
[
key
]
}}
</td>
</tr>
{%
endfor
%}
</tbody>
</table>
<p>
Total :
{{
total_credit
}}
</p>
<p>
Total :
{{
total_credit
}}
</p>
{%
endblock
%}
\ No newline at end of file
accounting/views.py
View file @
1457a7bf
...
...
@@ -455,13 +455,8 @@ class JournalBilanNatureView(CanViewMixin, DetailView):
def
sum_by_code
(
self
,
code
):
from
decimal
import
Decimal
from
django.db.models
import
Sum
,
DecimalField
amount_sum
=
Decimal
(
0
)
print
(
self
.
object
.
operations
.
filter
(
accounting_type__code
=
code
).
values
(
'amount'
).
annotate
(
sum
=
Sum
(
'amount'
)).
values
(
'sum'
).
first
()[
'sum'
])
return
(
self
.
object
.
operations
.
filter
(
accounting_type__code
=
code
).
values
(
'amount'
).
annotate
(
sum
=
Sum
(
'amount'
)).
values
(
'sum'
).
first
()[
'sum'
])
return
(
list
((
self
.
object
.
operations
.
filter
(
accounting_type__code
=
code
).
aggregate
(
Sum
(
'amount'
))).
values
())[
0
])
def
bilan_credit
(
self
):
bilan
=
{}
...
...
@@ -501,13 +496,8 @@ class JournalBilanPersonView(CanViewMixin, DetailView):
def
sum_by_target
(
self
,
target_id
):
from
decimal
import
Decimal
from
django.db.models
import
Sum
,
DecimalField
amount_sum
=
Decimal
(
0
)
print
(
self
.
object
.
operations
.
filter
(
target_id
=
target_id
).
values
(
'amount'
).
annotate
(
sum
=
Sum
(
'amount'
)).
values
(
'sum'
).
first
()[
'sum'
])
return
(
self
.
object
.
operations
.
filter
(
target_id
=
target_id
).
values
(
'amount'
).
annotate
(
sum
=
Sum
(
'amount'
)).
values
(
'sum'
).
first
()[
'sum'
])
return
(
list
((
self
.
object
.
operations
.
filter
(
target_id
=
target_id
).
aggregate
(
Sum
(
'amount'
))).
values
())[
0
])
def
bilan_credit
(
self
):
...
...
@@ -545,33 +535,31 @@ class JournalBilanAccountingView(CanViewMixin, DetailView):
pk_url_kwarg
=
"j_id"
template_name
=
'accounting/journal_bilan_accounting.jinja'
def
recursive_sum
(
self
,
code
,
bilan
):
op
=
Operation
.
objects
.
filter
(
accounting_type__code__startswith
=
code
)
if
op
.
exists
():
for
o
in
op
:
if
o
.
accounting_type
.
code
in
bilan
:
bilan
[
o
.
accounting_type
.
code
]
+=
o
.
amount
else
:
bilan
[
o
.
accounting_type
.
code
]
=
o
.
amount
if
o
.
number
==
code
:
self
.
recursive_sum
(
o
.
accounting_type
.
code
,
bilan
)
else
:
return
bilan
def
recursive_sum
(
self
,
max_length
):
import
collections
from
decimal
import
Decimal
from
django.db.models
import
Sum
,
DecimalField
bilan
=
{}
bilan
=
collections
.
OrderedDict
(
bilan
)
for
at
in
AccountingType
.
objects
.
order_by
(
'code'
).
all
()
:
#bilan[at] = self.object.operations.filter(type__startswith=at.code)
sum_by_type
=
list
((
self
.
object
.
operations
.
filter
(
accounting_type__code__startswith
=
at
.
code
).
aggregate
(
Sum
(
'amount'
))).
values
())[
0
]
if
sum_by_type
!=
0
:
bilan
[
at
]
=
sum_by_type
return
bilan
def
bilan
(
self
):
bilan
=
{}
self
.
recursive_sum
(
'6'
,
bilan
)
print
(
bilan
)
bilan
=
self
.
recursive_sum
(
3
)
return
bilan
def
total_credit
(
self
):
return
sum
(
self
.
bilan
().
values
())
return
self
.
bilan
().
get
(
'6'
)
#
sum(self.bilan().values())
def
total_debit
(
self
):
return
sum
(
self
.
bilan
().
values
())
return
self
.
bilan
().
get
(
'6'
)
#
sum(self.bilan().values())
def
get_context_data
(
self
,
**
kwargs
):
""" Add journal to the context """
...
...
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