1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-11-30 04:13:01 +00:00

Human-readable amounts

This commit is contained in:
Yohann D'ANELLO 2020-03-17 18:31:26 +01:00
parent 4909a7f09c
commit e8ad906f9c

View File

@ -122,7 +122,12 @@ SPDX-License-Identifier: GPL-2.0-or-later
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="amount">{% trans "Amount" %} :</label> <label for="amount">{% trans "Amount" %} :</label>
<input class="form-control mx-auto d-block" type="number" min="-20" id="amount" /> <div class="input-group">
<input class="form-control mx-auto d-block" type="number" min="0" step="0.01" id="amount" />
<div class="input-group-append">
<span class="input-group-text"></span>
</div>
</div>
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
@ -241,7 +246,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
{ {
"csrfmiddlewaretoken": CSRF_TOKEN, "csrfmiddlewaretoken": CSRF_TOKEN,
"quantity": dest.quantity, "quantity": dest.quantity,
"amount": $("#amount").val(), "amount": 100 * $("#amount").val(),
"reason": $("#reason").val(), "reason": $("#reason").val(),
"valid": true, "valid": true,
"polymorphic_ctype": {{ polymorphic_ctype }}, "polymorphic_ctype": {{ polymorphic_ctype }},
@ -250,13 +255,13 @@ SPDX-License-Identifier: GPL-2.0-or-later
"destination": dest.id "destination": dest.id
}, function () { }, function () {
addMsg("Le transfert de " addMsg("Le transfert de "
+ pretty_money(dest.quantity * $("#amount").val()) + " de votre note " + pretty_money(dest.quantity * 100 * $("#amount").val()) + " de votre note "
+ " vers la note " + dest.name + " a été fait avec succès !", "success"); + " vers la note " + dest.name + " a été fait avec succès !", "success");
reset(); reset();
}).fail(function (err) { }).fail(function (err) {
addMsg("Le transfert de " addMsg("Le transfert de "
+ pretty_money(dest.quantity * $("#amount").val()) + " de votre note " + pretty_money(dest.quantity * 100 * $("#amount").val()) + " de votre note "
+ " vers la note " + dest.name + " a échoué : " + err.responseText, "danger"); + " vers la note " + dest.name + " a échoué : " + err.responseText, "danger");
reset(); reset();
@ -270,7 +275,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
{ {
"csrfmiddlewaretoken": CSRF_TOKEN, "csrfmiddlewaretoken": CSRF_TOKEN,
"quantity": source.quantity * dest.quantity, "quantity": source.quantity * dest.quantity,
"amount": $("#amount").val(), "amount": 100 * $("#amount").val(),
"reason": $("#reason").val(), "reason": $("#reason").val(),
"valid": true, "valid": true,
"polymorphic_ctype": {{ polymorphic_ctype }}, "polymorphic_ctype": {{ polymorphic_ctype }},
@ -279,13 +284,13 @@ SPDX-License-Identifier: GPL-2.0-or-later
"destination": dest.id "destination": dest.id
}, function () { }, function () {
addMsg("Le transfert de " addMsg("Le transfert de "
+ pretty_money(source.quantity * dest.quantity * $("#amount").val()) + " de la note " + source.name + pretty_money(source.quantity * dest.quantity * 100 * $("#amount").val()) + " de la note " + source.name
+ " vers la note " + dest.name + " a été fait avec succès !", "success"); + " vers la note " + dest.name + " a été fait avec succès !", "success");
reset(); reset();
}).fail(function (err) { }).fail(function (err) {
addMsg("Le transfert de " addMsg("Le transfert de "
+ pretty_money(source.quantity * dest.quantity * $("#amount").val()) + " de la note " + source.name + pretty_money(source.quantity * dest.quantity * 100 * $("#amount").val()) + " de la note " + source.name
+ " vers la note " + dest.name + " a échoué : " + err.responseText, "danger"); + " vers la note " + dest.name + " a échoué : " + err.responseText, "danger");
reset(); reset();
@ -316,7 +321,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
{ {
"csrfmiddlewaretoken": CSRF_TOKEN, "csrfmiddlewaretoken": CSRF_TOKEN,
"quantity": 1, "quantity": 1,
"amount": $("#amount").val(), "amount": 100 * $("#amount").val(),
"reason": reason, "reason": reason,
"valid": true, "valid": true,
"polymorphic_ctype": {{ special_polymorphic_ctype }}, "polymorphic_ctype": {{ special_polymorphic_ctype }},