Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Sith
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
59
Issues
59
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AE
Sith
Commits
3c8a4f06
Commit
3c8a4f06
authored
Nov 30, 2016
by
Sli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refound Account
parent
00feca44
Pipeline
#455
passed with stage
in 2 minutes and 50 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
162 additions
and
31 deletions
+162
-31
accounting/templates/accounting/refound_account.jinja
accounting/templates/accounting/refound_account.jinja
+14
-0
accounting/tests.py
accounting/tests.py
+46
-2
accounting/urls.py
accounting/urls.py
+2
-0
accounting/views.py
accounting/views.py
+53
-2
core/management/commands/populate.py
core/management/commands/populate.py
+1
-0
core/templates/core/user_tools.jinja
core/templates/core/user_tools.jinja
+1
-0
locale/fr/LC_MESSAGES/django.po
locale/fr/LC_MESSAGES/django.po
+45
-27
No files found.
accounting/templates/accounting/refound_account.jinja
0 → 100644
View file @
3c8a4f06
{%
extends
"core/base.jinja"
%}
{%
block
title
%}
{%
trans
%}
Refound account
{%
endtrans
%}
{%
endblock
%}
{%
block
content
%}
<h3>
{%
trans
%}
Refound account
{%
endtrans
%}
</h3>
<form
action=
""
method=
"post"
>
{%
csrf_token
%}
{{
form.as_p
()
}}
<p><input
type=
"submit"
value=
"
{%
trans
%}
Refound
{%
endtrans
%}
"
/></p>
</form>
{%
endblock
%}
\ No newline at end of file
accounting/tests.py
View file @
3c8a4f06
from
django.test
import
TestCase
from
django.test
import
Client
,
TestCase
from
django.core.urlresolvers
import
reverse
from
django.contrib.auth.models
import
Group
from
django.core.management
import
call_command
from
django.conf
import
settings
# Create your tests here.
from
core.models
import
User
from
counter.models
import
Counter
class
RefoundAccountTest
(
TestCase
):
def
setUp
(
self
):
call_command
(
"populate"
)
self
.
skia
=
User
.
objects
.
filter
(
username
=
"skia"
).
first
()
# reffil skia's account
self
.
skia
.
customer
.
amount
=
800
self
.
skia
.
customer
.
save
()
def
test_permission_denied
(
self
):
self
.
client
.
login
(
useername
=
'guy'
,
password
=
'plop'
)
response_post
=
self
.
client
.
post
(
reverse
(
"accounting:refound_account"
),
{
"user"
:
self
.
skia
.
id
})
response_get
=
self
.
client
.
get
(
reverse
(
"accounting:refound_account"
))
self
.
assertTrue
(
response_get
.
status_code
==
403
)
self
.
assertTrue
(
response_post
.
status_code
==
403
)
def
test_root_granteed
(
self
):
self
.
client
.
login
(
username
=
'root'
,
password
=
'plop'
)
response_post
=
self
.
client
.
post
(
reverse
(
"accounting:refound_account"
),
{
"user"
:
self
.
skia
.
id
})
self
.
skia
=
User
.
objects
.
filter
(
username
=
'skia'
).
first
()
response_get
=
self
.
client
.
get
(
reverse
(
"accounting:refound_account"
))
self
.
assertFalse
(
response_get
.
status_code
==
403
)
self
.
assertTrue
(
'<form action="" method="post">'
in
str
(
response_get
.
content
))
self
.
assertFalse
(
response_post
.
status_code
==
403
)
self
.
assertTrue
(
self
.
skia
.
customer
.
amount
==
0
)
def
test_comptable_granteed
(
self
):
self
.
client
.
login
(
username
=
'comptable'
,
password
=
'plop'
)
response_post
=
self
.
client
.
post
(
reverse
(
"accounting:refound_account"
),
{
"user"
:
self
.
skia
.
id
})
self
.
skia
=
User
.
objects
.
filter
(
username
=
'skia'
).
first
()
response_get
=
self
.
client
.
get
(
reverse
(
"accounting:refound_account"
))
self
.
assertFalse
(
response_get
.
status_code
==
403
)
self
.
assertTrue
(
'<form action="" method="post">'
in
str
(
response_get
.
content
))
self
.
assertFalse
(
response_post
.
status_code
==
403
)
self
.
assertTrue
(
self
.
skia
.
customer
.
amount
==
0
)
accounting/urls.py
View file @
3c8a4f06
...
...
@@ -38,6 +38,8 @@ urlpatterns = [
url
(
r
'^label/(?P<clubaccount_id>[0-9]+)$'
,
LabelListView
.
as_view
(),
name
=
'label_list'
),
url
(
r
'^label/(?P<label_id>[0-9]+)/edit$'
,
LabelEditView
.
as_view
(),
name
=
'label_edit'
),
url
(
r
'^label/(?P<label_id>[0-9]+)/delete$'
,
LabelDeleteView
.
as_view
(),
name
=
'label_delete'
),
# User account
url
(
r
'^refound/account$'
,
RefoundAccountView
.
as_view
(),
name
=
'refound_account'
),
]
accounting/views.py
View file @
3c8a4f06
from
django.views.generic
import
ListView
,
DetailView
,
RedirectView
from
django.views.generic.edit
import
UpdateView
,
CreateView
,
DeleteView
from
django.views.generic.edit
import
UpdateView
,
CreateView
,
DeleteView
,
FormView
from
django.shortcuts
import
render
from
django.core.urlresolvers
import
reverse_lazy
from
django.core.urlresolvers
import
reverse_lazy
,
reverse
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.forms.models
import
modelform_factory
from
django.core.exceptions
import
PermissionDenied
from
django.forms
import
HiddenInput
from
django.db
import
transaction
from
django.conf
import
settings
from
django
import
forms
from
django.http
import
HttpResponseRedirect
,
HttpResponse
from
django.utils.translation
import
ugettext
as
_
...
...
@@ -15,6 +19,7 @@ from ajax_select.fields import AutoCompleteSelectField, AutoCompleteSelectMultip
from
core.views
import
CanViewMixin
,
CanEditMixin
,
CanEditPropMixin
,
CanCreateMixin
from
core.views.forms
import
SelectFile
,
SelectDate
from
accounting.models
import
BankAccount
,
ClubAccount
,
GeneralJournal
,
Operation
,
AccountingType
,
Company
,
SimplifiedAccountingType
,
Label
from
counter.models
import
Counter
,
Selling
# Main accounting view
...
...
@@ -481,3 +486,49 @@ class LabelDeleteView(CanEditMixin, DeleteView):
def
get_success_url
(
self
):
return
self
.
object
.
get_absolute_url
()
class
CloseCustomerAccountForm
(
forms
.
Form
):
user
=
AutoCompleteSelectField
(
'users'
,
label
=
_
(
'Refound this account'
),
help_text
=
None
,
required
=
True
)
class
RefoundAccountView
(
FormView
):
"""
Create a selling with the same amount than the current user money
"""
template_name
=
"accounting/refound_account.jinja"
form_class
=
CloseCustomerAccountForm
def
permission
(
self
,
user
):
if
user
.
is_root
or
user
.
is_in_group
(
settings
.
SITH_GROUPS
[
'accounting-admin'
][
'name'
]):
return
True
else
:
raise
PermissionDenied
def
dispatch
(
self
,
request
,
*
arg
,
**
kwargs
):
res
=
super
(
RefoundAccountView
,
self
).
dispatch
(
request
,
*
arg
,
**
kwargs
)
if
self
.
permission
(
request
.
user
):
return
res
def
post
(
self
,
request
,
*
arg
,
**
kwargs
):
self
.
operator
=
request
.
user
if
self
.
permission
(
request
.
user
):
return
super
(
RefoundAccountView
,
self
).
post
(
self
,
request
,
*
arg
,
**
kwargs
)
def
form_valid
(
self
,
form
):
self
.
customer
=
form
.
cleaned_data
[
'user'
]
self
.
create_selling
()
return
super
(
RefoundAccountView
,
self
).
form_valid
(
form
)
def
get_success_url
(
self
):
return
reverse
(
'accounting:refound_account'
)
def
create_selling
(
self
):
with
transaction
.
atomic
():
uprice
=
self
.
customer
.
customer
.
amount
main_club_counter
=
Counter
.
objects
.
filter
(
club__unix_name
=
settings
.
SITH_MAIN_CLUB
[
'unix_name'
],
type
=
'OFFICE'
).
first
()
main_club
=
main_club_counter
.
club
s
=
Selling
(
label
=
_
(
'Refound account'
),
unit_price
=
uprice
,
quantity
=
1
,
seller
=
self
.
operator
,
customer
=
self
.
customer
.
customer
,
club
=
main_club
,
counter
=
main_club_counter
)
s
.
save
()
core/management/commands/populate.py
View file @
3c8a4f06
...
...
@@ -67,6 +67,7 @@ class Command(BaseCommand):
c
.
save
()
self
.
reset_index
(
"counter"
)
Counter
(
name
=
"Eboutic"
,
club
=
main_club
,
type
=
'EBOUTIC'
).
save
()
Counter
(
name
=
"AE"
,
club
=
main_club
,
type
=
'OFFICE'
).
save
()
home_root
.
view_groups
=
[
Group
.
objects
.
filter
(
name
=
settings
.
SITH_MAIN_MEMBERS_GROUP
).
first
()]
club_root
.
view_groups
=
[
Group
.
objects
.
filter
(
name
=
settings
.
SITH_MAIN_MEMBERS_GROUP
).
first
()]
...
...
core/templates/core/user_tools.jinja
View file @
3c8a4f06
...
...
@@ -43,6 +43,7 @@
<h4>
{%
trans
%}
Accounting
{%
endtrans
%}
</h4>
<ul>
{%
if
user.is_in_group
(
settings.SITH_GROUPS
[
'accounting-admin'
][
'name'
])
or
user.is_root
%}
<li><a
href=
"
{{
url
(
'accounting:refound_account'
)
}}
"
>
{%
trans
%}
Refound Account
{%
endtrans
%}
</a></li>
<li><a
href=
"
{{
url
(
'accounting:bank_list'
)
}}
"
>
{%
trans
%}
General accounting
{%
endtrans
%}
</a></li>
{%
endif
%}
{%
for
m
in
user.memberships.
filter
(
end_date
=
None
)
.
filter
(
role__gte
=
7
)
.
all
()
-
%}
...
...
locale/fr/LC_MESSAGES/django.po
View file @
3c8a4f06
...
...
@@ -6,7 +6,7 @@
msgid
""
msgstr
""
"Report-Msgid-Bugs-To:
\n
"
"POT-Creation-Date: 2016-11-29 1
2:34
+0100
\n
"
"POT-Creation-Date: 2016-11-29 1
5:16
+0100
\n
"
"PO-Revision-Date: 2016-07-18
\n
"
"Last-Translator: Skia <skia@libskia.so>
\n
"
"Language-Team: AE info <ae.info@utbm.fr>
\n
"
...
...
@@ -296,7 +296,7 @@ msgstr "Il n'y a pas de types comptable dans ce site web."
#: accounting/templates/accounting/bank_account_details.jinja:4
#: accounting/templates/accounting/bank_account_details.jinja:13
#: core/templates/core/user_tools.jinja:5
0
#: core/templates/core/user_tools.jinja:5
1
msgid
"Bank account: "
msgstr
"Compte en banque : "
...
...
@@ -515,7 +515,7 @@ msgid "Done"
msgstr
"Effectué"
#: accounting/templates/accounting/journal_details.jinja:37
#: counter/templates/counter/cash_summary_list.jinja:37 counter/views.py:71
1
#: counter/templates/counter/cash_summary_list.jinja:37 counter/views.py:71
2
msgid
"Comment"
msgstr
"Commentaire"
...
...
@@ -556,6 +556,16 @@ msgstr "Éditer l'opération"
msgid
"Save"
msgstr
"Sauver"
#: accounting/templates/accounting/refound_account.jinja:4
#: accounting/templates/accounting/refound_account.jinja:8
#: accounting/views.py:399
msgid
"Refound account"
msgstr
"Remboursement de compte"
#: accounting/templates/accounting/refound_account.jinja:12
msgid
"Refound"
msgstr
"Rembourser"
#: accounting/templates/accounting/simplifiedaccountingtype_list.jinja:4
#: accounting/templates/accounting/simplifiedaccountingtype_list.jinja:15
msgid
"Simplified type list"
...
...
@@ -608,6 +618,10 @@ msgstr "Créditeur"
msgid
"Comment:"
msgstr
"Commentaire :"
#: accounting/views.py:491
msgid
"Refound this account"
msgstr
"Rembourser ce compte"
#: club/models.py:21
msgid
"unix name"
msgstr
"nom unix"
...
...
@@ -808,7 +822,7 @@ msgid "Payment method"
msgstr
"Méthode de paiement"
#: club/templates/club/club_tools.jinja:4
#: core/templates/core/user_tools.jinja:7
4
#: core/templates/core/user_tools.jinja:7
5
msgid
"Club tools"
msgstr
"Outils club"
...
...
@@ -851,16 +865,16 @@ msgstr "Choisir un utilisateur"
msgid
"You do not have the permission to do that"
msgstr
"Vous n'avez pas la permission de faire cela"
#: club/views.py:165 counter/views.py:9
09
#: club/views.py:165 counter/views.py:9
10
msgid
"Begin date"
msgstr
"Date de début"
#: club/views.py:166 counter/views.py:91
0
#: club/views.py:166 counter/views.py:91
1
msgid
"End date"
msgstr
"Date de fin"
#: club/views.py:180 core/templates/core/user_stats.jinja:27
#: counter/views.py:99
0
#: counter/views.py:99
1
msgid
"Product"
msgstr
"Produit"
...
...
@@ -2027,22 +2041,26 @@ msgid "Stats"
msgstr
"Stats"
#: core/templates/core/user_tools.jinja:46
msgid
"Refound Account"
msgstr
"Rembourser un compte"
#: core/templates/core/user_tools.jinja:47
msgid
"General accounting"
msgstr
"Comptabilité générale"
#: core/templates/core/user_tools.jinja:5
5
#: core/templates/core/user_tools.jinja:5
6
msgid
"Club account: "
msgstr
"Compte club : "
#: core/templates/core/user_tools.jinja:6
2
#: core/templates/core/user_tools.jinja:6
3
msgid
"Communication"
msgstr
"Communication"
#: core/templates/core/user_tools.jinja:6
5
#: core/templates/core/user_tools.jinja:6
6
msgid
"Moderate files"
msgstr
"Modérer les fichiers"
#: core/templates/core/user_tools.jinja:6
8
#: core/templates/core/user_tools.jinja:6
9
msgid
"Moderate pictures"
msgstr
"Modérer les photos"
...
...
@@ -2351,7 +2369,7 @@ msgstr "Liste des relevés de caisse"
msgid
"Theoric sums"
msgstr
"Sommes théoriques"
#: counter/templates/counter/cash_summary_list.jinja:36 counter/views.py:71
2
#: counter/templates/counter/cash_summary_list.jinja:36 counter/views.py:71
3
msgid
"Emptied"
msgstr
"Coffre vidé"
...
...
@@ -2609,57 +2627,57 @@ msgstr "Produit parent"
msgid
"Buying groups"
msgstr
"Groupes d'achat"
#: counter/views.py:69
1
#: counter/views.py:69
2
msgid
"10 cents"
msgstr
"10 centimes"
#: counter/views.py:69
2
#: counter/views.py:69
3
msgid
"20 cents"
msgstr
"20 centimes"
#: counter/views.py:69
3
#: counter/views.py:69
4
msgid
"50 cents"
msgstr
"50 centimes"
#: counter/views.py:69
4
#: counter/views.py:69
5
msgid
"1 euro"
msgstr
"1 €"
#: counter/views.py:69
5
#: counter/views.py:69
6
msgid
"2 euros"
msgstr
"2 €"
#: counter/views.py:69
6
#: counter/views.py:69
7
msgid
"5 euros"
msgstr
"5 €"
#: counter/views.py:69
7
#: counter/views.py:69
8
msgid
"10 euros"
msgstr
"10 €"
#: counter/views.py:69
8
#: counter/views.py:69
9
msgid
"20 euros"
msgstr
"20 €"
#: counter/views.py:
699
#: counter/views.py:
700
msgid
"50 euros"
msgstr
"50 €"
#: counter/views.py:70
0
#: counter/views.py:70
1
msgid
"100 euros"
msgstr
"100 €"
#: counter/views.py:70
1 counter/views.py:703 counter/views.py:705
#: counter/views.py:70
7 counter/views.py:709
#: counter/views.py:70
2 counter/views.py:704 counter/views.py:706
#: counter/views.py:70
8 counter/views.py:710
msgid
"Check amount"
msgstr
"Montant du chèque"
#: counter/views.py:70
2 counter/views.py:704 counter/views.py:706
#: counter/views.py:70
8 counter/views.py:710
#: counter/views.py:70
3 counter/views.py:705 counter/views.py:707
#: counter/views.py:70
9 counter/views.py:711
msgid
"Check quantity"
msgstr
"Nombre de chèque"
#: counter/views.py:106
1
#: counter/views.py:106
2
msgid
"people(s)"
msgstr
"personne(s)"
...
...
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