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
6bb1e0e4
Commit
6bb1e0e4
authored
Dec 14, 2016
by
Krophil
Committed by
Skia
Dec 21, 2016
Browse files
person bilan added and renamed classes
parent
147287f9
Changes
5
Hide whitespace changes
Inline
Side-by-side
accounting/templates/accounting/journal_bilan.jinja
→
accounting/templates/accounting/journal_bilan
_nature
.jinja
View file @
6bb1e0e4
...
...
@@ -18,16 +18,38 @@
</tr>
</thead>
<tbody>
{%
for
key
in
bilan.keys
()
%}
{%
for
key
in
bilan
_credit
.keys
()
%}
<tr>
<td>
{{
object.operations.get
(
accounting_type__code
=
key
)
.
accounting_type.label
}}
</td>
<td>
{{
bilan
[
key
]
}}
</td>
<td>
{{
key
}}
</td>
<td>
{{
bilan
_credit
[
key
]
}}
</td>
</tr>
{%
endfor
%}
</tbody>
</table>
<p>
Total :
{{
total_credit
}}
</p>
<h3>
{%
trans
%}
Debit
{%
endtrans
%}
</h3>
<table>
<thead>
<tr>
<td>
{%
trans
%}
Nature of operation
{%
endtrans
%}
</td>
<td>
{%
trans
%}
Sum
{%
endtrans
%}
</td>
</tr>
</thead>
<tbody>
{%
for
key
in
bilan_debit.keys
()
%}
<tr>
<td>
{{
key
}}
</td>
<td>
{{
bilan_debit
[
key
]
}}
</td>
</tr>
{%
endfor
%}
</tbody>
</table>
<p>
Total :
{{
total_debit
}}
</p>
{%
endblock
%}
\ No newline at end of file
accounting/templates/accounting/journal_bilan_person.jinja
0 → 100644
View file @
6bb1e0e4
{%
extends
"core/base.jinja"
%}
{%
block
title
%}
{%
trans
%}
General journal:
{%
endtrans
%}
{{
object.name
}}
{%
endblock
%}
{%
block
content
%}
<h2>
{%
trans
%}
Person bilan:
{%
endtrans
%}
{{
object.name
}}
</h2>
<h3>
{%
trans
%}
Credit
{%
endtrans
%}
</h3>
<table>
<thead>
<tr>
<td>
{%
trans
%}
Target of the operation
{%
endtrans
%}
</td>
<td>
{%
trans
%}
Sum
{%
endtrans
%}
</td>
</tr>
</thead>
<tbody>
{%
for
key
in
bilan_credit.keys
()
%}
<tr>
{%
if
key.target_type
==
"OTHER"
%}
<td>
{{
o.target_label
}}
</td>
{%
else
%}
<td><a
href=
"
{{
key.get_absolute_url
()
}}
"
>
{{
key.get_display_name
()
}}
</a></td>
{%
endif
%}
<td>
{{
bilan_credit
[
key
]
}}
</td>
</tr>
{%
endfor
%}
</tbody>
</table>
<p>
Total :
{{
total_credit
}}
</p>
<h3>
{%
trans
%}
Debit
{%
endtrans
%}
</h3>
<table>
<thead>
<tr>
<td>
{%
trans
%}
Target of the operation
{%
endtrans
%}
</td>
<td>
{%
trans
%}
Sum
{%
endtrans
%}
</td>
</tr>
</thead>
<tbody>
{%
for
key
in
bilan_debit.keys
()
%}
<tr>
{%
if
key.target_type
==
"OTHER"
%}
<td>
{{
o.target_label
}}
</td>
{%
else
%}
<td><a
href=
"
{{
key.get_absolute_url
()
}}
"
>
{{
key.get_display_name
()
}}
</a></td>
{%
endif
%}
<td>
{{
bilan_debit
[
key
]
}}
</td>
</tr>
{%
endfor
%}
</tbody>
</table>
<p>
Total :
{{
total_debit
}}
</p>
{%
endblock
%}
\ No newline at end of file
accounting/templates/accounting/journal_details.jinja
View file @
6bb1e0e4
...
...
@@ -22,7 +22,9 @@
<p>
{%
trans
%}
Journal is closed, you can not create operation
{%
endtrans
%}
</p>
{%
else
%}
<p><a
href=
"
{{
url
(
'accounting:op_new'
,
j_id
=
object.id
)
}}
"
>
{%
trans
%}
New operation
{%
endtrans
%}
</a></p>
<p><a
href=
"
{{
url
(
'accounting:journal_bilan'
,
j_id
=
object.id
)
}}
"
>
{%
trans
%}
Journal Bilan
{%
endtrans
%}
</a></p>
<p><a
href=
"
{{
url
(
'accounting:journal_bilan_nature'
,
j_id
=
object.id
)
}}
"
>
{%
trans
%}
Journal Bilan Nature
{%
endtrans
%}
</a></p>
<p><a
href=
"
{{
url
(
'accounting:journal_bilan_person'
,
j_id
=
object.id
)
}}
"
>
{%
trans
%}
Journal Bilan Person
{%
endtrans
%}
</a></p>
<p><a
href=
"
{{
url
(
'accounting:journal_bilan_accounting'
,
j_id
=
object.id
)
}}
"
>
{%
trans
%}
Journal Bilan Accounting
{%
endtrans
%}
</a></p>
{%
endif
%}
<table>
<thead>
...
...
accounting/urls.py
View file @
6bb1e0e4
...
...
@@ -26,7 +26,10 @@ urlpatterns = [
url
(
r
'^journal/create$'
,
JournalCreateView
.
as_view
(),
name
=
'journal_new'
),
url
(
r
'^journal/(?P<j_id>[0-9]+)$'
,
JournalDetailView
.
as_view
(),
name
=
'journal_details'
),
url
(
r
'^journal/(?P<j_id>[0-9]+)/edit$'
,
JournalEditView
.
as_view
(),
name
=
'journal_edit'
),
url
(
r
'^journal/(?P<j_id>[0-9]+)/bilan$'
,
JournalBilanView
.
as_view
(),
name
=
'journal_bilan'
),
url
(
r
'^journal/(?P<j_id>[0-9]+)/bilan/nature$'
,
JournalBilanNatureView
.
as_view
(),
name
=
'journal_bilan_nature'
),
url
(
r
'^journal/(?P<j_id>[0-9]+)/bilan/person$'
,
JournalBilanPersonView
.
as_view
(),
name
=
'journal_bilan_person'
),
url
(
r
'^journal/(?P<j_id>[0-9]+)/bilan/accounting$'
,
JournalBilanAccountingView
.
as_view
(),
name
=
'journal_bilan_accounting'
),
# Operations
url
(
r
'^operation/create/(?P<j_id>[0-9]+)$'
,
OperationCreateView
.
as_view
(),
name
=
'op_new'
),
url
(
r
'^operation/(?P<op_id>[0-9]+)$'
,
OperationEditView
.
as_view
(),
name
=
'op_edit'
),
...
...
accounting/views.py
View file @
6bb1e0e4
...
...
@@ -444,34 +444,145 @@ class OperationPDFView(CanViewMixin, DetailView):
p
.
save
()
return
response
class
JournalBilanView
(
CanViewMixin
,
DetailView
):
class
JournalBilan
Nature
View
(
CanViewMixin
,
DetailView
):
"""
Calculate a dictionary with operation code and sum of operations
"""
model
=
GeneralJournal
pk_url_kwarg
=
"j_id"
template_name
=
'accounting/journal_bilan.jinja'
template_name
=
'accounting/journal_bilan
_nature
.jinja'
def
sum_by_code
(
self
,
code
):
from
decimal
import
Decimal
from
django.db.models
import
Sum
,
DecimalField
amount_sum
=
Decimal
(
0
)
for
amount
in
self
.
get_object
().
operations
.
filter
(
accounting_type__code
=
code
).
values
(
'amount'
):
amount_sum
+=
amount
[
'amount'
]
return
amount_sum
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'
])
def
bilan_credit
(
self
):
bilan
=
{}
for
el
in
AccountingType
.
objects
.
filter
(
movement_type
=
'CREDIT'
):
bilan
[
"%s - %s"
%
(
el
.
code
,
el
.
label
)]
=
self
.
sum_by_code
(
el
.
code
)
return
bilan
def
bilan
(
self
):
def
bilan
_debit
(
self
):
bilan
=
{}
for
el
in
AccountingType
.
objects
.
values
(
'code'
).
distinct
():
bilan
[
el
[
'code'
]]
=
self
.
sum_by_code
(
el
[
'code'
])
print
(
bilan
)
for
el
in
AccountingType
.
objects
.
filter
(
movement_type
=
'DEBIT'
):
bilan
[
"%s - %s"
%
(
el
.
code
,
el
.
label
)]
=
self
.
sum_by_code
(
el
.
code
)
return
bilan
def
total_credit
(
self
):
return
sum
(
self
.
bilan_credit
().
values
())
def
total_debit
(
self
):
return
sum
(
self
.
bilan_debit
().
values
())
def
get_context_data
(
self
,
**
kwargs
):
""" Add journal to the context """
kwargs
=
super
(
JournalBilanView
,
self
).
get_context_data
(
**
kwargs
)
kwargs
[
'bilan'
]
=
self
.
bilan
()
kwargs
=
super
(
JournalBilanNatureView
,
self
).
get_context_data
(
**
kwargs
)
kwargs
[
'bilan_credit'
]
=
self
.
bilan_credit
()
kwargs
[
'bilan_debit'
]
=
self
.
bilan_debit
()
kwargs
[
'total_credit'
]
=
self
.
total_credit
()
kwargs
[
'total_debit'
]
=
self
.
total_debit
()
return
kwargs
class
JournalBilanPersonView
(
CanViewMixin
,
DetailView
):
"""
Calculate a dictionary with operation target and sum of operations
"""
model
=
GeneralJournal
pk_url_kwarg
=
"j_id"
template_name
=
'accounting/journal_bilan_person.jinja'
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'
])
def
bilan_credit
(
self
):
bilan
=
{}
for
el
in
Operation
.
objects
.
filter
(
accounting_type__movement_type
=
'CREDIT'
):
bilan
[
el
.
target
]
=
self
.
sum_by_target
(
el
.
target_id
)
return
bilan
def
bilan_debit
(
self
):
bilan
=
{}
for
el
in
Operation
.
objects
.
filter
(
accounting_type__movement_type
=
'DEBIT'
):
bilan
[
el
.
target
]
=
self
.
sum_by_target
(
el
.
target_id
)
return
bilan
def
total_credit
(
self
):
return
sum
(
self
.
bilan_credit
().
values
())
def
total_debit
(
self
):
return
sum
(
self
.
bilan_debit
().
values
())
def
get_context_data
(
self
,
**
kwargs
):
""" Add journal to the context """
kwargs
=
super
(
JournalBilanPersonView
,
self
).
get_context_data
(
**
kwargs
)
kwargs
[
'bilan_credit'
]
=
self
.
bilan_credit
()
kwargs
[
'bilan_debit'
]
=
self
.
bilan_debit
()
kwargs
[
'total_credit'
]
=
self
.
total_credit
()
kwargs
[
'total_debit'
]
=
self
.
total_debit
()
return
kwargs
class
JournalBilanAccountingView
(
CanViewMixin
,
DetailView
):
"""
Calculate a dictionary with operation type and sum of operations
"""
model
=
GeneralJournal
pk_url_kwarg
=
"j_id"
template_name
=
'accounting/journal_bilan_person.jinja'
def
sum_by_code
(
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'
])
def
bilan_credit
(
self
):
bilan
=
{}
for
el
in
Operation
.
objects
.
filter
(
accounting_type__movement_type
=
'CREDIT'
):
bilan
[
el
.
target
]
=
self
.
sum_by_code
(
el
.
target_id
)
return
bilan
def
bilan_debit
(
self
):
bilan
=
{}
for
el
in
Operation
.
objects
.
filter
(
accounting_type__movement_type
=
'DEBIT'
):
bilan
[
el
.
target
]
=
self
.
sum_by_code
(
el
.
target_id
)
return
bilan
def
total_credit
(
self
):
return
sum
(
self
.
bilan_credit
().
values
())
def
total_debit
(
self
):
return
sum
(
self
.
bilan_debit
().
values
())
def
get_context_data
(
self
,
**
kwargs
):
""" Add journal to the context """
kwargs
=
super
(
JournalBilanAccountingView
,
self
).
get_context_data
(
**
kwargs
)
kwargs
[
'bilan_credit'
]
=
self
.
bilan_credit
()
kwargs
[
'bilan_debit'
]
=
self
.
bilan_debit
()
kwargs
[
'total_credit'
]
=
self
.
total_credit
()
kwargs
[
'total_debit'
]
=
self
.
total_debit
()
return
kwargs
# Company views
...
...
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