Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
AE
Sith
Commits
50efc07e
Commit
50efc07e
authored
Jun 24, 2016
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic close journal functions
parent
e9544f25
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
13 deletions
+54
-13
accounting/models.py
accounting/models.py
+9
-1
accounting/templates/accounting/club_account_details.jinja
accounting/templates/accounting/club_account_details.jinja
+33
-8
accounting/templates/accounting/journal_details.jinja
accounting/templates/accounting/journal_details.jinja
+10
-2
accounting/views.py
accounting/views.py
+2
-2
No files found.
accounting/models.py
View file @
50efc07e
...
...
@@ -70,6 +70,12 @@ class ClubAccount(models.Model):
return
True
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
):
return
reverse
(
'accounting:club_details'
,
kwargs
=
{
'c_account_id'
:
self
.
id
})
...
...
@@ -143,6 +149,8 @@ class Operation(models.Model):
"""
if
user
.
is_in_group
(
settings
.
SITH_GROUPS
[
'accounting-admin'
][
'name'
]):
return
True
if
self
.
journal
.
closed
:
return
False
m
=
self
.
journal
.
club_account
.
club
.
get_membership_for
(
user
)
if
m
is
not
None
and
m
.
role
>=
7
:
return
True
...
...
@@ -152,7 +160,7 @@ class Operation(models.Model):
"""
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
False
...
...
accounting/templates/accounting/club_account_details.jinja
View file @
50efc07e
...
...
@@ -11,16 +11,41 @@
<li>
{{
k
}}
-
{{
v
}}
</li>
{%
endfor
%}
</ul>
<p><a
href=
"
{{
url
(
'accounting:journal_new'
)
}}
?parent=
{{
object.id
}}
"
>
New journal
</a></p>
<ul>
{%
if
not
object.has_open_journal
()
%}
<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
()
%}
<li>
<a
href=
"
{{
url
(
'accounting:journal_details'
,
j_id
=
j.id
)
}}
"
>
{{
j
}}
</a>
-
<a
href=
"
{{
url
(
'accounting:journal_edit'
,
j_id
=
j.id
)
}}
"
>
Edit
</a>
</li>
<tr>
<td>
{{
j.name
}}
</td>
<td>
{{
j.start_date
}}
</td>
{%
if
j.end_date
%}
<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
%}
</
ul
>
</
table
>
{%
endblock
%}
...
...
accounting/templates/accounting/journal_details.jinja
View file @
50efc07e
...
...
@@ -8,7 +8,11 @@
{{
object.name
}}
</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>
{%
endif
%}
<table>
<tr>
<td>
Nb
</td>
...
...
@@ -16,7 +20,7 @@
<td>
Label
</td>
<td>
Amount
</td>
<td>
Payment mode
</td>
<!-- <td>Target</td> -->
<!--
TODO:
<td>Target</td> -->
<td>
Code
</td>
<td>
Nature
</td>
<td>
Done
</td>
...
...
@@ -38,7 +42,11 @@
<td>
No
</td>
{%
endif
%}
<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>
{%
endfor
%}
</table>
...
...
accounting/views.py
View file @
50efc07e
...
...
@@ -153,7 +153,7 @@ class JournalEditView(CanEditMixin, UpdateView):
"""
model
=
GeneralJournal
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'
# Operation views
...
...
@@ -177,7 +177,7 @@ class OperationCreateView(CanCreateMixin, CreateView):
ret
[
'journal'
]
=
obj
.
id
return
ret
class
OperationEditView
(
Can
View
Mixin
,
UpdateView
):
class
OperationEditView
(
Can
Edit
Mixin
,
UpdateView
):
"""
An edit view, working as detail for the moment
"""
...
...
Write
Preview
Markdown
is supported
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