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
d244618d
Commit
d244618d
authored
Jun 22, 2016
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve accounting views
parent
d0654008
Pipeline
#44
passed with stage
in 1 minute and 16 seconds
Changes
11
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
211 additions
and
43 deletions
+211
-43
accounting/migrations/0005_auto_20160622_0953.py
accounting/migrations/0005_auto_20160622_0953.py
+25
-0
accounting/migrations/0006_operation_type.py
accounting/migrations/0006_operation_type.py
+20
-0
accounting/migrations/0007_auto_20160622_0959.py
accounting/migrations/0007_auto_20160622_0959.py
+19
-0
accounting/migrations/0008_auto_20160622_1005.py
accounting/migrations/0008_auto_20160622_1005.py
+19
-0
accounting/migrations/0009_auto_20160622_1030.py
accounting/migrations/0009_auto_20160622_1030.py
+25
-0
accounting/models.py
accounting/models.py
+52
-27
accounting/templates/accounting/bank_account_details.jinja
accounting/templates/accounting/bank_account_details.jinja
+4
-0
accounting/templates/accounting/club_account_details.jinja
accounting/templates/accounting/club_account_details.jinja
+4
-0
accounting/templates/accounting/journal_details.jinja
accounting/templates/accounting/journal_details.jinja
+38
-11
accounting/views.py
accounting/views.py
+2
-2
core/management/commands/populate.py
core/management/commands/populate.py
+3
-3
No files found.
accounting/migrations/0005_auto_20160622_0953.py
0 → 100644
View file @
d244618d
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
accounting.models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'accounting'
,
'0004_auto_20160620_1307'
),
]
operations
=
[
migrations
.
RenameField
(
model_name
=
'operation'
,
old_name
=
'type'
,
new_name
=
'accounting_type'
,
),
migrations
.
AddField
(
model_name
=
'generaljournal'
,
name
=
'effective_amount'
,
field
=
accounting
.
models
.
CurrencyField
(
default
=
0
,
decimal_places
=
2
,
verbose_name
=
'effective_amount'
,
max_digits
=
12
),
),
]
accounting/migrations/0006_operation_type.py
0 → 100644
View file @
d244618d
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'accounting'
,
'0005_auto_20160622_0953'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'operation'
,
name
=
'type'
,
field
=
models
.
CharField
(
verbose_name
=
'operation type'
,
choices
=
[(
'DEBIT'
,
'Debit'
),
(
'CREDIT'
,
'Credit'
)],
max_length
=
10
,
default
=
'DEBIT'
),
preserve_default
=
False
,
),
]
accounting/migrations/0007_auto_20160622_0959.py
0 → 100644
View file @
d244618d
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'accounting'
,
'0006_operation_type'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'operation'
,
name
=
'cheque_number'
,
field
=
models
.
IntegerField
(
verbose_name
=
'cheque number'
,
default
=-
1
),
),
]
accounting/migrations/0008_auto_20160622_1005.py
0 → 100644
View file @
d244618d
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'accounting'
,
'0007_auto_20160622_0959'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'operation'
,
name
=
'type'
,
field
=
models
.
CharField
(
verbose_name
=
'operation type'
,
choices
=
[(
'debit'
,
'Debit'
),
(
'credit'
,
'Credit'
)],
max_length
=
10
),
),
]
accounting/migrations/0009_auto_20160622_1030.py
0 → 100644
View file @
d244618d
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'accounting'
,
'0008_auto_20160622_1005'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'operation'
,
name
=
'label'
,
field
=
models
.
CharField
(
verbose_name
=
'label'
,
default
=
''
,
max_length
=
50
),
preserve_default
=
False
,
),
migrations
.
AlterField
(
model_name
=
'operation'
,
name
=
'type'
,
field
=
models
.
CharField
(
verbose_name
=
'operation type'
,
choices
=
[(
'debit'
,
'Debit'
),
(
'credit'
,
'Credit'
)],
max_length
=
8
),
),
]
accounting/models.py
View file @
d244618d
...
...
@@ -86,6 +86,7 @@ class GeneralJournal(models.Model):
closed
=
models
.
BooleanField
(
_
(
'is closed'
),
default
=
False
)
club_account
=
models
.
ForeignKey
(
ClubAccount
,
related_name
=
"journals"
,
null
=
False
)
amount
=
CurrencyField
(
_
(
'amount'
),
default
=
0
)
effective_amount
=
CurrencyField
(
_
(
'effective_amount'
),
default
=
0
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
GeneralJournal
,
self
).
__init__
(
*
args
,
**
kwargs
)
...
...
@@ -125,29 +126,19 @@ class GeneralJournal(models.Model):
def
__str__
(
self
):
return
self
.
name
class
AccountingType
(
models
.
Model
):
"""
Class describing the accounting types.
Thoses are numbers used in accounting to classify operations
"""
code
=
models
.
CharField
(
_
(
'code'
),
max_length
=
16
)
# TODO: add number validator
label
=
models
.
CharField
(
_
(
'label'
),
max_length
=
60
)
movement_type
=
models
.
CharField
(
_
(
'movement type'
),
choices
=
[(
'credit'
,
'Credit'
),
(
'debit'
,
'Debit'
),
(
'neutral'
,
'Neutral'
)],
max_length
=
12
)
def
is_owned_by
(
self
,
user
):
"""
Method to see if that object can be edited by the given user
"""
if
user
.
is_in_group
(
settings
.
SITH_GROUPS
[
'accounting-admin'
][
'name'
]):
return
True
return
False
def
get_absolute_url
(
self
):
return
reverse
(
'accounting:type_list'
)
def
__str__
(
self
):
return
self
.
movement_type
+
" - "
+
self
.
code
+
" - "
+
self
.
label
def
update_amounts
(
self
):
self
.
amount
=
0
self
.
effective_amount
=
0
for
o
in
self
.
operations
.
all
():
if
o
.
type
==
"credit"
:
if
o
.
done
:
self
.
effective_amount
+=
o
.
amount
self
.
amount
+=
o
.
amount
else
:
if
o
.
done
:
self
.
effective_amount
-=
o
.
amount
self
.
amount
-=
o
.
amount
self
.
save
()
class
Operation
(
models
.
Model
):
"""
...
...
@@ -156,12 +147,21 @@ class Operation(models.Model):
journal
=
models
.
ForeignKey
(
GeneralJournal
,
related_name
=
"operations"
,
null
=
False
)
amount
=
CurrencyField
(
_
(
'amount'
))
date
=
models
.
DateField
(
_
(
'date'
))
label
=
models
.
CharField
(
_
(
'label'
),
max_length
=
50
)
remark
=
models
.
TextField
(
_
(
'remark'
),
max_length
=
255
)
mode
=
models
.
CharField
(
_
(
'payment method'
),
max_length
=
255
,
choices
=
settings
.
SITH_ACCOUNTING_PAYMENT_METHOD
)
cheque_number
=
models
.
IntegerField
(
_
(
'cheque number'
))
cheque_number
=
models
.
IntegerField
(
_
(
'cheque number'
)
,
default
=-
1
)
invoice
=
models
.
FileField
(
upload_to
=
'invoices'
,
null
=
True
,
blank
=
True
)
done
=
models
.
BooleanField
(
_
(
'is done'
),
default
=
False
)
type
=
models
.
ForeignKey
(
AccountingType
,
related_name
=
"operations"
)
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
()
self
.
journal
.
update_amounts
()
def
is_owned_by
(
self
,
user
):
"""
...
...
@@ -182,10 +182,35 @@ class Operation(models.Model):
return
True
return
False
def
get_absolute_url
(
self
):
return
reverse
(
'accounting:journal_details'
,
kwargs
=
{
'j_id'
:
self
.
journal
.
id
})
def
__str__
(
self
):
return
str
(
self
.
id
)
+
" - "
+
str
(
self
.
date
)
return
"%d | %s | %d € | %s | %s | %s"
%
(
self
.
id
,
self
.
type
,
self
.
amount
,
self
.
date
,
self
.
accounting_type
,
self
.
done
,
)
class
AccountingType
(
models
.
Model
):
"""
Class describing the accounting types.
Thoses are numbers used in accounting to classify operations
"""
code
=
models
.
CharField
(
_
(
'code'
),
max_length
=
16
)
# TODO: add number validator
label
=
models
.
CharField
(
_
(
'label'
),
max_length
=
60
)
movement_type
=
models
.
CharField
(
_
(
'movement type'
),
choices
=
[(
'credit'
,
'Credit'
),
(
'debit'
,
'Debit'
),
(
'neutral'
,
'Neutral'
)],
max_length
=
12
)
def
is_owned_by
(
self
,
user
):
"""
Method to see if that object can be edited by the given user
"""
if
user
.
is_in_group
(
settings
.
SITH_GROUPS
[
'accounting-admin'
][
'name'
]):
return
True
return
False
def
get_absolute_url
(
self
):
return
reverse
(
'accounting:type_list'
)
def
__str__
(
self
):
return
self
.
movement_type
+
" - "
+
self
.
code
+
" - "
+
self
.
label
accounting/templates/accounting/bank_account_details.jinja
View file @
d244618d
{%
extends
"core/base.jinja"
%}
{%
block
content
%}
<p>
<a
href=
"
{{
url
(
'accounting:bank_list'
)
}}
"
>
Accounting
</a>
>
{{
object.name
}}
</p>
<h2>
View account
</h2>
<ul>
{%
for
k
,
v
in
object.__dict__.items
()
%}
...
...
accounting/templates/accounting/club_account_details.jinja
View file @
d244618d
{%
extends
"core/base.jinja"
%}
{%
block
content
%}
<p>
<a
href=
"
{{
url
(
'accounting:bank_list'
)
}}
"
>
Accounting
</a>
>
<a
href=
"
{{
url
(
'accounting:bank_details'
,
b_account_id
=
object.bank_account.id
)
}}
"
>
{{
object.bank_account
}}
</a>
>
{{
object
}}
<h2>
View account:
{{
object.name
}}
</h2>
<ul>
{%
for
k
,
v
in
object.__dict__.items
()
%}
...
...
accounting/templates/accounting/journal_details.jinja
View file @
d244618d
{%
extends
"core/base.jinja"
%}
{%
block
content
%}
<h2>
View journal:
{{
object.name
}}
</h2>
<ul>
{%
for
k
,
v
in
object.__dict__.items
()
%}
<li>
{{
k
}}
-
{{
v
}}
</li>
{%
endfor
%}
</ul>
<p>
<a
href=
"
{{
url
(
'accounting:bank_list'
)
}}
"
>
Accounting
</a>
>
<a
href=
"
{{
url
(
'accounting:bank_details'
,
b_account_id
=
object.club_account.bank_account.id
)
}}
"
>
{{
object.club_account.bank_account
}}
</a>
>
<a
href=
"
{{
url
(
'accounting:club_details'
,
c_account_id
=
object.club_account.id
)
}}
"
>
{{
object.club_account
}}
</a>
>
{{
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>
<ul>
<table>
<tr>
<td>
Nb
</td>
<td>
Date
</td>
<td>
Label
</td>
<td>
Amount
</td>
<td>
Payment mode
</td>
<!-- <td>Target</td> -->
<td>
Code
</td>
<td>
Nature
</td>
<td>
Done
</td>
<td>
Comment
</td>
<td>
Actions
</td>
</tr>
{%
for
o
in
object.operations.all
()
%}
<li>
<a
href=
"
{{
url
(
'accounting:op_edit'
,
op_id
=
o.id
)
}}
"
>
{{
o
}}
</a>
</li>
<tr>
<td>
{{
o.id
}}
</td>
<td>
{{
o.date
}}
</td>
<td>
{{
o.label
}}
</td>
<td>
{{
o.amount
}}
€
</td>
<td>
{{
o.mode
}}
</td>
<td>
{{
o.accounting_type.code
}}
</td>
<td>
{{
o.accounting_type.label
}}
</td>
{%
if
o.done
%}
<td>
Yes
</td>
{%
else
%}
<td>
No
</td>
{%
endif
%}
<td>
{{
o.remark
}}
</td>
<td><a
href=
"
{{
url
(
'accounting:op_edit'
,
op_id
=
o.id
)
}}
"
>
Edit
</a></td>
</tr>
{%
endfor
%}
</
ul
>
</
table
>
{%
endblock
%}
...
...
accounting/views.py
View file @
d244618d
...
...
@@ -147,7 +147,7 @@ class OperationCreateView(CanEditMixin, CreateView):
Create an operation
"""
model
=
Operation
fields
=
[
'amount'
,
'journal'
,
'date'
,
'cheque_number'
,
'
typ
e'
]
fields
=
[
'type'
,
'amount'
,
'label'
,
'remark'
,
'journal'
,
'date'
,
'cheque_number'
,
'
accounting_type'
,
'don
e'
]
template_name
=
'accounting/account_edit.jinja'
class
OperationEditView
(
CanViewMixin
,
UpdateView
):
...
...
@@ -156,6 +156,6 @@ class OperationEditView(CanViewMixin, UpdateView):
"""
model
=
Operation
pk_url_kwarg
=
"op_id"
fields
=
[
'
journal
'
,
'date'
,
'cheque_number'
,
'
typ
e'
]
fields
=
[
'
amount'
,
'label'
,
'remark
'
,
'date'
,
'cheque_number'
,
'
accounting_type'
,
'don
e'
]
template_name
=
'accounting/account_edit.jinja'
core/management/commands/populate.py
View file @
d244618d
...
...
@@ -132,7 +132,7 @@ Cette page vise à documenter la syntaxe *Markdown* utilisée sur le site.
Club
(
name
=
"Woenzel'UT"
,
unix_name
=
"woenzel"
,
address
=
"Woenzel"
,
parent
=
guyut
).
save
()
Club
(
name
=
"BdF"
,
unix_name
=
"bdf"
,
address
=
"
Guyéuéyuéyuyé
"
).
save
()
address
=
"
6 Bd Anatole France
"
).
save
()
Membership
(
user
=
skia
,
club
=
ae
,
role
=
3
,
description
=
""
).
save
()
troll
=
Club
(
name
=
"Troll Penché"
,
unix_name
=
"troll"
,
address
=
"Terre Du Milieu"
,
parent
=
ae
)
...
...
@@ -166,6 +166,6 @@ Cette page vise à documenter la syntaxe *Markdown* utilisée sur le site.
ba
.
save
()
ca
=
ClubAccount
(
name
=
"Troll Penché"
,
bank_account
=
ba
,
club
=
troll
)
ca
.
save
()
AccountingType
(
code
=
66
6
,
label
=
"
Guy credit
"
,
movement_type
=
'credit'
).
save
()
AccountingType
(
code
=
400
0
,
label
=
"
Guy debit
"
,
movement_type
=
'debit'
).
save
()
AccountingType
(
code
=
75
6
,
label
=
"
Someone gave us money
"
,
movement_type
=
'credit'
).
save
()
AccountingType
(
code
=
857
0
,
label
=
"
Had to pay for food
"
,
movement_type
=
'debit'
).
save
()
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