forked from DGNum/gestioCOF
Ajout liste transferts
This commit is contained in:
parent
022e1f3984
commit
be8243c4ce
5 changed files with 85 additions and 24 deletions
|
@ -1,3 +1,20 @@
|
|||
.transfer_general {
|
||||
margin:15px 0;
|
||||
height:45px;
|
||||
}
|
||||
|
||||
.transfer_general input {
|
||||
height:100%;
|
||||
border:0;
|
||||
padding:0 5px;
|
||||
font-size:16px;
|
||||
}
|
||||
|
||||
.transfer_general button {
|
||||
height:100%;
|
||||
margin-top:-3px;
|
||||
}
|
||||
|
||||
.transfer_formset {
|
||||
background:#FFF;
|
||||
}
|
||||
|
@ -11,11 +28,9 @@
|
|||
text-align:center;
|
||||
}
|
||||
|
||||
.transfer_form {
|
||||
height:50px;
|
||||
}
|
||||
|
||||
.transfer_form td {
|
||||
height:50px;
|
||||
vertical-align:middle;
|
||||
padding:0 !important;
|
||||
}
|
||||
|
||||
|
@ -31,13 +46,13 @@
|
|||
font-weight:bold;
|
||||
|
||||
text-align:center;
|
||||
vertical-align:middle;
|
||||
text-transform:uppercase;
|
||||
}
|
||||
|
||||
.transfer_form .from_acc_data, .transfer_form .to_acc_data {
|
||||
width:30%;
|
||||
text-align:center;
|
||||
vertical-align:middle;
|
||||
font-size:20px;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,42 @@
|
|||
{% block content %}
|
||||
|
||||
<div class="row">
|
||||
<form action="" method="post">
|
||||
{% csrf_token %}
|
||||
{{ form }}
|
||||
<input type="submit" value="Enregistrer">
|
||||
</form>
|
||||
<div class="col-sm-4 col-md-3 col-content-left">
|
||||
<div class="content-left">
|
||||
<div class="content-left-top">
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<a class="btn btn-primary btn-lg" href="{% url 'kfet.transfers.create' %}">
|
||||
Nouveaux
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-8 col-md-9 col-content-right">
|
||||
{% include 'kfet/base_messages.html' %}
|
||||
<div class="content-right">
|
||||
<div class="content-right-block">
|
||||
<h2>Liste des transferts</h2>
|
||||
<div id="history">
|
||||
{% for transfergroup in transfergroups %}
|
||||
<div class="opegroup">
|
||||
<span>{{ transfergroup.at }}</span>
|
||||
<span>{{ transfergroup.valid_by.trigramme }}</span>
|
||||
<span>{{ transfergroup.comment }}</span>
|
||||
</div>
|
||||
{% for transfer in transfergroup.transfers.all %}
|
||||
<div>
|
||||
<span>{{ transfer.amount }} €</span>
|
||||
<span>{{ transfer.from_acc.trigramme }}</span>
|
||||
<span>--></span>
|
||||
<span>{{ transfer.to_acc.trigramme }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -14,6 +14,11 @@
|
|||
{% csrf_token %}
|
||||
|
||||
<form id="transfers_form">
|
||||
<div class="transfer_general text-center">
|
||||
<input type="text" name="comment" id="comment" placeholder="Commentaire"><!--
|
||||
--><button type="submit" id="submit" class="btn btn-primary btn-lg">Enregistrer</button>
|
||||
{{ transfer_formset.management_form }}
|
||||
</div>
|
||||
<table class="transfer_formset table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -42,12 +47,6 @@
|
|||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div>
|
||||
<label for="comment">Commentaire:</label>
|
||||
<input type="text" name="comment" id="comment">
|
||||
{{ transfer_formset.management_form }}
|
||||
<button type="submit" id="submit" class="btn btn-primary btn-lg">Enregistrer</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
@ -105,7 +104,7 @@ $(document).ready(function () {
|
|||
},
|
||||
})
|
||||
.done(function(data) {
|
||||
window.location.replace("{% url 'kfet.transfers' %}");
|
||||
window.location.href = "{% url 'kfet.transfers' %}";
|
||||
})
|
||||
.fail(function($xhr) {
|
||||
var data = $xhr.responseJSON;
|
||||
|
|
|
@ -155,9 +155,9 @@ urlpatterns = [
|
|||
# Transfers urls
|
||||
# -----
|
||||
|
||||
url(r'^transfers/$', views.home,
|
||||
url(r'^transfers/$', views.transfers,
|
||||
name = 'kfet.transfers'),
|
||||
url(r'^transfers/new$', views.transfer_create,
|
||||
url(r'^transfers/new$', views.transfers_create,
|
||||
name = 'kfet.transfers.create'),
|
||||
url(r'^transfers/perform$', views.perform_transfers,
|
||||
name = 'kfet.transfers.perform'),
|
||||
|
|
|
@ -1128,11 +1128,22 @@ class SettingsUpdate(SuccessMessageMixin, UpdateView):
|
|||
# Transfer views
|
||||
# -----
|
||||
|
||||
def transfer_create(request):
|
||||
@permission_required('kfet.is_team')
|
||||
def transfers(request):
|
||||
transfergroups = (TransferGroup.objects
|
||||
.prefetch_related('transfers')
|
||||
.order_by('-at'))
|
||||
return render(request, 'kfet/transfers.html', {
|
||||
'transfergroups': transfergroups,
|
||||
})
|
||||
|
||||
@permission_required('kfet.is_team')
|
||||
def transfers_create(request):
|
||||
transfer_formset = TransferFormSet(queryset=Transfer.objects.none())
|
||||
return render(request, 'kfet/transfers_create.html',
|
||||
{ 'transfer_formset': transfer_formset })
|
||||
|
||||
@permission_required('kfet.is_team')
|
||||
def perform_transfers(request):
|
||||
data = { 'errors': {}, 'transfers': [], 'transfergroup': 0 }
|
||||
|
||||
|
@ -1168,6 +1179,14 @@ def perform_transfers(request):
|
|||
data['errors']['negative'] = True
|
||||
return JsonResponse(data, status=403)
|
||||
|
||||
# Creating transfer group
|
||||
transfergroup = TransferGroup()
|
||||
if required_perms:
|
||||
transfergroup.valid_by = request.user.profile.account_kfet
|
||||
|
||||
comment = request.POST.get('comment', '')
|
||||
transfergroup.comment = comment.strip()
|
||||
|
||||
with transaction.atomic():
|
||||
# Updating balances accounts
|
||||
for account in to_accounts_balances:
|
||||
|
@ -1187,10 +1206,7 @@ def perform_transfers(request):
|
|||
and not account.negative.balance_offset):
|
||||
account.negative.delete()
|
||||
|
||||
# Creating transfer group
|
||||
transfergroup = TransferGroup()
|
||||
if required_perms:
|
||||
transfergroup.valid_by = request.user.profile.account_kfet
|
||||
# Saving transfer group
|
||||
transfergroup.save()
|
||||
data['transfergroup'] = transfergroup.pk
|
||||
|
||||
|
|
Loading…
Reference in a new issue