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
50efc07e
Commit
50efc07e
authored
Jun 24, 2016
by
Skia
🤘
Browse files
Add basic close journal functions
parent
e9544f25
Changes
4
Hide whitespace changes
Inline
Side-by-side
accounting/models.py
View file @
50efc07e
...
@@ -70,6 +70,12 @@ class ClubAccount(models.Model):
...
@@ -70,6 +70,12 @@ class ClubAccount(models.Model):
return
True
return
True
return
False
return
False
def
has_open_journal
(
self
):
for
j
in
self
.
journals
.
all
():
if
not
j
.
closed
:
return
True
return
False
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
reverse
(
'accounting:club_details'
,
kwargs
=
{
'c_account_id'
:
self
.
id
})
return
reverse
(
'accounting:club_details'
,
kwargs
=
{
'c_account_id'
:
self
.
id
})
...
@@ -143,6 +149,8 @@ class Operation(models.Model):
...
@@ -143,6 +149,8 @@ class Operation(models.Model):
"""
"""
if
user
.
is_in_group
(
settings
.
SITH_GROUPS
[
'accounting-admin'
][
'name'
]):
if
user
.
is_in_group
(
settings
.
SITH_GROUPS
[
'accounting-admin'
][
'name'
]):
return
True
return
True
if
self
.
journal
.
closed
:
return
False
m
=
self
.
journal
.
club_account
.
club
.
get_membership_for
(
user
)
m
=
self
.
journal
.
club_account
.
club
.
get_membership_for
(
user
)
if
m
is
not
None
and
m
.
role
>=
7
:
if
m
is
not
None
and
m
.
role
>=
7
:
return
True
return
True
...
@@ -152,7 +160,7 @@ class Operation(models.Model):
...
@@ -152,7 +160,7 @@ class Operation(models.Model):
"""
"""
Method to see if that object can be edited by the given user
Method to see if that object can be edited by the given user
"""
"""
if
self
.
journal
.
can_be_edit
ed_by
(
user
):
if
self
.
is_own
ed_by
(
user
):
return
True
return
True
return
False
return
False
...
...
accounting/templates/accounting/club_account_details.jinja
View file @
50efc07e
...
@@ -11,16 +11,41 @@
...
@@ -11,16 +11,41 @@
<li>
{{
k
}}
-
{{
v
}}
</li>
<li>
{{
k
}}
-
{{
v
}}
</li>
{%
endfor
%}
{%
endfor
%}
</ul>
</ul>
<p><a
href=
"
{{
url
(
'accounting:journal_new'
)
}}
?parent=
{{
object.id
}}
"
>
New journal
</a></p>
{%
if
not
object.has_open_journal
()
%}
<ul>
<p><a
href=
"
{{
url
(
'accounting:journal_new'
)
}}
?parent=
{{
object.id
}}
"
>
New journal
</a></p>
{%
else
%}
<p>
You can not create new journal while you still have one opened
</p>
{%
endif
%}
<table>
<tr>
<td>
Name
</td>
<td>
Start
</td>
<td>
End
</td>
<td>
Amount
</td>
<td>
Effective amount
</td>
<td>
Closed
</td>
</tr>
{%
for
j
in
object.journals.all
()
%}
{%
for
j
in
object.journals.all
()
%}
<li>
<tr>
<a
href=
"
{{
url
(
'accounting:journal_details'
,
j_id
=
j.id
)
}}
"
>
{{
j
}}
</a>
-
<td>
{{
j.name
}}
</td>
<a
href=
"
{{
url
(
'accounting:journal_edit'
,
j_id
=
j.id
)
}}
"
>
Edit
</a>
<td>
{{
j.start_date
}}
</td>
{%
if
j.end_date
%}
</li>
<td>
{{
j.end_date
}}
</td>
{%
else
%}
<td>
-
</td>
{%
endif
%}
<td>
{{
j.amount
}}
€
</td>
<td>
{{
j.effective_amount
}}
€
</td>
{%
if
j.closed
%}
<td>
Yes
</td>
{%
else
%}
<td>
No
</td>
{%
endif
%}
<td>
<a
href=
"
{{
url
(
'accounting:journal_details'
,
j_id
=
j.id
)
}}
"
>
View
</a>
<a
href=
"
{{
url
(
'accounting:journal_edit'
,
j_id
=
j.id
)
}}
"
>
Edit
</a>
</td>
</tr>
{%
endfor
%}
{%
endfor
%}
</
ul
>
</
table
>
{%
endblock
%}
{%
endblock
%}
...
...
accounting/templates/accounting/journal_details.jinja
View file @
50efc07e
...
@@ -8,7 +8,11 @@
...
@@ -8,7 +8,11 @@
{{
object.name
}}
{{
object.name
}}
</p>
</p>
<p><strong>
Amount:
</strong>
{{
object.amount
}}
€ -
<strong>
Effective amount:
</strong>
{{
object.effective_amount
}}
€
</p>
<p><strong>
Amount:
</strong>
{{
object.amount
}}
€ -
<strong>
Effective amount:
</strong>
{{
object.effective_amount
}}
€
</p>
{%
if
object.closed
%}
<p>
Journal is closed, you can not create operation
</p>
{%
else
%}
<p><a
href=
"
{{
url
(
'accounting:op_new'
)
}}
?parent=
{{
object.id
}}
"
>
New operation
</a></p>
<p><a
href=
"
{{
url
(
'accounting:op_new'
)
}}
?parent=
{{
object.id
}}
"
>
New operation
</a></p>
{%
endif
%}
<table>
<table>
<tr>
<tr>
<td>
Nb
</td>
<td>
Nb
</td>
...
@@ -16,7 +20,7 @@
...
@@ -16,7 +20,7 @@
<td>
Label
</td>
<td>
Label
</td>
<td>
Amount
</td>
<td>
Amount
</td>
<td>
Payment mode
</td>
<td>
Payment mode
</td>
<!-- <td>Target</td> -->
<!--
TODO:
<td>Target</td> -->
<td>
Code
</td>
<td>
Code
</td>
<td>
Nature
</td>
<td>
Nature
</td>
<td>
Done
</td>
<td>
Done
</td>
...
@@ -38,7 +42,11 @@
...
@@ -38,7 +42,11 @@
<td>
No
</td>
<td>
No
</td>
{%
endif
%}
{%
endif
%}
<td>
{{
o.remark
}}
</td>
<td>
{{
o.remark
}}
</td>
<td><a
href=
"
{{
url
(
'accounting:op_edit'
,
op_id
=
o.id
)
}}
"
>
Edit
</a></td>
<td>
{%
if
not
o.journal.closed
%}
<a
href=
"
{{
url
(
'accounting:op_edit'
,
op_id
=
o.id
)
}}
"
>
Edit
</a>
{%
endif
%}
</td>
</tr>
</tr>
{%
endfor
%}
{%
endfor
%}
</table>
</table>
...
...
accounting/views.py
View file @
50efc07e
...
@@ -153,7 +153,7 @@ class JournalEditView(CanEditMixin, UpdateView):
...
@@ -153,7 +153,7 @@ class JournalEditView(CanEditMixin, UpdateView):
"""
"""
model
=
GeneralJournal
model
=
GeneralJournal
pk_url_kwarg
=
"j_id"
pk_url_kwarg
=
"j_id"
fields
=
[
'name'
,
'start_date'
,
'club_account'
]
fields
=
[
'name'
,
'start_date'
,
'end_date'
,
'club_account'
,
'closed'
]
template_name
=
'core/edit.jinja'
template_name
=
'core/edit.jinja'
# Operation views
# Operation views
...
@@ -177,7 +177,7 @@ class OperationCreateView(CanCreateMixin, CreateView):
...
@@ -177,7 +177,7 @@ class OperationCreateView(CanCreateMixin, CreateView):
ret
[
'journal'
]
=
obj
.
id
ret
[
'journal'
]
=
obj
.
id
return
ret
return
ret
class
OperationEditView
(
Can
View
Mixin
,
UpdateView
):
class
OperationEditView
(
Can
Edit
Mixin
,
UpdateView
):
"""
"""
An edit view, working as detail for the moment
An edit view, working as detail for the moment
"""
"""
...
...
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