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
1396f2ca
Commit
1396f2ca
authored
Jun 24, 2016
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve accounting ease of use
parent
ace58f54
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
79 additions
and
24 deletions
+79
-24
accounting/migrations/0010_remove_operation_type.py
accounting/migrations/0010_remove_operation_type.py
+18
-0
accounting/models.py
accounting/models.py
+3
-7
accounting/templates/accounting/bank_account_details.jinja
accounting/templates/accounting/bank_account_details.jinja
+1
-1
accounting/templates/accounting/club_account_details.jinja
accounting/templates/accounting/club_account_details.jinja
+1
-1
accounting/templates/accounting/journal_details.jinja
accounting/templates/accounting/journal_details.jinja
+1
-1
accounting/views.py
accounting/views.py
+40
-13
core/templates/core/create.jinja
core/templates/core/create.jinja
+2
-1
core/templates/core/edit.jinja
core/templates/core/edit.jinja
+13
-0
No files found.
accounting/migrations/0010_remove_operation_type.py
0 → 100644
View file @
1396f2ca
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'accounting'
,
'0009_auto_20160622_1030'
),
]
operations
=
[
migrations
.
RemoveField
(
model_name
=
'operation'
,
name
=
'type'
,
),
]
accounting/models.py
View file @
1396f2ca
...
...
@@ -130,7 +130,7 @@ class GeneralJournal(models.Model):
self
.
amount
=
0
self
.
effective_amount
=
0
for
o
in
self
.
operations
.
all
():
if
o
.
type
==
"credit"
:
if
o
.
accounting_type
.
movement_
type
==
"credit"
:
if
o
.
done
:
self
.
effective_amount
+=
o
.
amount
self
.
amount
+=
o
.
amount
...
...
@@ -154,10 +154,6 @@ class Operation(models.Model):
invoice
=
models
.
FileField
(
upload_to
=
'invoices'
,
null
=
True
,
blank
=
True
)
done
=
models
.
BooleanField
(
_
(
'is done'
),
default
=
False
)
accounting_type
=
models
.
ForeignKey
(
'AccountingType'
,
related_name
=
"operations"
)
type
=
models
.
CharField
(
_
(
'operation type'
),
max_length
=
8
,
choices
=
[
(
'debit'
,
_
(
'Debit'
)),
(
'credit'
,
_
(
'Credit'
)),
])
def
save
(
self
):
super
(
Operation
,
self
).
save
()
...
...
@@ -186,8 +182,8 @@ class Operation(models.Model):
return
reverse
(
'accounting:journal_details'
,
kwargs
=
{
'j_id'
:
self
.
journal
.
id
})
def
__str__
(
self
):
return
"%d |
%s |
%d € | %s | %s | %s"
%
(
self
.
id
,
self
.
type
,
self
.
amount
,
self
.
date
,
self
.
accounting_type
,
self
.
done
,
return
"%d | %d € | %s | %s | %s"
%
(
self
.
id
,
self
.
amount
,
self
.
date
,
self
.
accounting_type
,
self
.
done
,
)
class
AccountingType
(
models
.
Model
):
...
...
accounting/templates/accounting/bank_account_details.jinja
View file @
1396f2ca
...
...
@@ -11,7 +11,7 @@
<li>
{{
k
}}
-
{{
v
}}
</li>
{%
endfor
%}
</ul>
<p><a
href=
"
{{
url
(
'accounting:club_new'
)
}}
"
>
New club account
</a></p>
<p><a
href=
"
{{
url
(
'accounting:club_new'
)
}}
?parent=
{{
object.id
}}
"
>
New club account
</a></p>
<ul>
{%
for
c
in
object.club_accounts.all
()
%}
<li><a
href=
"
{{
url
(
'accounting:club_details'
,
c_account_id
=
c.id
)
}}
"
>
{{
c
}}
</a>
-
...
...
accounting/templates/accounting/club_account_details.jinja
View file @
1396f2ca
...
...
@@ -11,7 +11,7 @@
<li>
{{
k
}}
-
{{
v
}}
</li>
{%
endfor
%}
</ul>
<p><a
href=
"
{{
url
(
'accounting:journal_new'
)
}}
"
>
New journal
</a></p>
<p><a
href=
"
{{
url
(
'accounting:journal_new'
)
}}
?parent=
{{
object.id
}}
"
>
New journal
</a></p>
<ul>
{%
for
j
in
object.journals.all
()
%}
<li>
...
...
accounting/templates/accounting/journal_details.jinja
View file @
1396f2ca
...
...
@@ -8,7 +8,7 @@
{{
object.name
}}
</p>
<p><strong>
Amount:
</strong>
{{
object.amount
}}
€ -
<strong>
Effective amount:
</strong>
{{
object.effective_amount
}}
€
</p>
<p><a
href=
"
{{
url
(
'accounting:op_new'
)
}}
"
>
New operation
</a></p>
<p><a
href=
"
{{
url
(
'accounting:op_new'
)
}}
?parent=
{{
object.id
}}
"
>
New operation
</a></p>
<table>
<tr>
<td>
Nb
</td>
...
...
accounting/views.py
View file @
1396f2ca
...
...
@@ -24,7 +24,7 @@ class AccountingTypeEditView(CanViewMixin, UpdateView):
model
=
AccountingType
pk_url_kwarg
=
"type_id"
fields
=
[
'code'
,
'label'
,
'movement_type'
]
template_name
=
'
accounting/account_
edit.jinja'
template_name
=
'
core/
edit.jinja'
class
AccountingTypeCreateView
(
CanEditPropMixin
,
CreateView
):
# TODO: move to CanCreateMixin
"""
...
...
@@ -32,7 +32,7 @@ class AccountingTypeCreateView(CanEditPropMixin, CreateView): # TODO: move to Ca
"""
model
=
AccountingType
fields
=
[
'code'
,
'label'
,
'movement_type'
]
template_name
=
'
accounting/account_edit
.jinja'
template_name
=
'
core/create
.jinja'
# BankAccount views
...
...
@@ -49,8 +49,8 @@ class BankAccountEditView(CanViewMixin, UpdateView):
"""
model
=
BankAccount
pk_url_kwarg
=
"b_account_id"
fields
=
[
'name'
,
'
r
ib'
,
'number'
]
template_name
=
'
accounting/account_
edit.jinja'
fields
=
[
'name'
,
'ib
an
'
,
'number'
]
template_name
=
'
core/
edit.jinja'
class
BankAccountDetailView
(
CanViewMixin
,
DetailView
):
"""
...
...
@@ -65,8 +65,8 @@ class BankAccountCreateView(CanEditPropMixin, CreateView): # TODO: move to CanCr
Create a bank account (for the admins)
"""
model
=
BankAccount
fields
=
[
'name'
,
'
r
ib'
,
'number'
]
template_name
=
'
accounting/account_edit
.jinja'
fields
=
[
'name'
,
'ib
an
'
,
'number'
]
template_name
=
'
core/create
.jinja'
class
BankAccountDeleteView
(
CanEditPropMixin
,
DeleteView
):
# TODO change Delete to Close
"""
...
...
@@ -86,7 +86,7 @@ class ClubAccountEditView(CanViewMixin, UpdateView):
model
=
ClubAccount
pk_url_kwarg
=
"c_account_id"
fields
=
[
'name'
,
'club'
,
'bank_account'
]
template_name
=
'
accounting/account_
edit.jinja'
template_name
=
'
core/
edit.jinja'
class
ClubAccountDetailView
(
CanViewMixin
,
DetailView
):
"""
...
...
@@ -102,7 +102,15 @@ class ClubAccountCreateView(CanEditPropMixin, CreateView): # TODO: move to CanCr
"""
model
=
ClubAccount
fields
=
[
'name'
,
'club'
,
'bank_account'
]
template_name
=
'accounting/account_edit.jinja'
template_name
=
'core/create.jinja'
def
get_initial
(
self
):
ret
=
super
(
ClubAccountCreateView
,
self
).
get_initial
()
if
'parent'
in
self
.
request
.
GET
.
keys
():
obj
=
BankAccount
.
objects
.
filter
(
id
=
int
(
self
.
request
.
GET
[
'parent'
])).
first
()
if
obj
is
not
None
:
ret
[
'bank_account'
]
=
obj
.
id
return
ret
class
ClubAccountDeleteView
(
CanEditPropMixin
,
DeleteView
):
# TODO change Delete to Close
"""
...
...
@@ -120,8 +128,16 @@ class JournalCreateView(CanCreateMixin, CreateView):
Create a general journal
"""
model
=
GeneralJournal
template_name
=
'accounting/account_edit.jinja'
fields
=
[
'name'
,
'start_date'
,
'club_account'
]
template_name
=
'core/create.jinja'
def
get_initial
(
self
):
ret
=
super
(
JournalCreateView
,
self
).
get_initial
()
if
'parent'
in
self
.
request
.
GET
.
keys
():
obj
=
ClubAccount
.
objects
.
filter
(
id
=
int
(
self
.
request
.
GET
[
'parent'
])).
first
()
if
obj
is
not
None
:
ret
[
'club_account'
]
=
obj
.
id
return
ret
class
JournalDetailView
(
CanViewMixin
,
DetailView
):
"""
...
...
@@ -138,7 +154,7 @@ class JournalEditView(CanEditMixin, UpdateView):
model
=
GeneralJournal
pk_url_kwarg
=
"j_id"
fields
=
[
'name'
,
'start_date'
,
'club_account'
]
template_name
=
'
accounting/account_
edit.jinja'
template_name
=
'
core/
edit.jinja'
# Operation views
...
...
@@ -147,8 +163,19 @@ class OperationCreateView(CanEditMixin, CreateView): # TODO: move to CanCreateMi
Create an operation
"""
model
=
Operation
fields
=
[
'type'
,
'amount'
,
'label'
,
'remark'
,
'journal'
,
'date'
,
'cheque_number'
,
'accounting_type'
,
'done'
]
template_name
=
'accounting/account_edit.jinja'
# fields = ['type', 'amount', 'label', 'remark', 'journal', 'date', 'cheque_number', 'accounting_type', 'done']
form_class
=
modelform_factory
(
Operation
,
fields
=
[
'amount'
,
'label'
,
'remark'
,
'journal'
,
'date'
,
'cheque_number'
,
'accounting_type'
,
'done'
],
widgets
=
{
'journal'
:
HiddenInput
})
template_name
=
'core/create.jinja'
def
get_initial
(
self
):
ret
=
super
(
OperationCreateView
,
self
).
get_initial
()
if
'parent'
in
self
.
request
.
GET
.
keys
():
obj
=
GeneralJournal
.
objects
.
filter
(
id
=
int
(
self
.
request
.
GET
[
'parent'
])).
first
()
if
obj
is
not
None
:
ret
[
'journal'
]
=
obj
.
id
return
ret
class
OperationEditView
(
CanViewMixin
,
UpdateView
):
"""
...
...
@@ -157,5 +184,5 @@ class OperationEditView(CanViewMixin, UpdateView):
model
=
Operation
pk_url_kwarg
=
"op_id"
fields
=
[
'amount'
,
'label'
,
'remark'
,
'date'
,
'cheque_number'
,
'accounting_type'
,
'done'
]
template_name
=
'
accounting/account_
edit.jinja'
template_name
=
'
core/
edit.jinja'
accounting
/templates/
accounting/account_edit
.jinja
→
core
/templates/
core/create
.jinja
View file @
1396f2ca
{%
extends
"core/base.jinja"
%}
{%
block
content
%}
<h2>
Edit account
</h2>
<h2>
Create
</h2>
<form
action=
""
method=
"post"
>
{%
csrf_token
%}
{{
form.as_p
()
}}
...
...
@@ -11,3 +11,4 @@
core/templates/core/edit.jinja
0 → 100644
View file @
1396f2ca
{%
extends
"core/base.jinja"
%}
{%
block
content
%}
<h2>
Edit
{{
object
}}
</h2>
<form
action=
""
method=
"post"
>
{%
csrf_token
%}
{{
form.as_p
()
}}
<p><input
type=
"submit"
value=
"Save!"
/></p>
</form>
{%
endblock
%}
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