mirror of https://gitlab.crans.org/bde/nk20
🐛 Prevent transactions to have the same source and destination
This commit is contained in:
parent
252ddb832d
commit
d9cf812074
|
@ -222,8 +222,7 @@ class Transaction(PolymorphicModel):
|
||||||
self.destination_alias = str(self.destination)
|
self.destination_alias = str(self.destination)
|
||||||
|
|
||||||
if self.source.pk == self.destination.pk:
|
if self.source.pk == self.destination.pk:
|
||||||
# When source == destination, no money is transferred
|
# When source == destination, no money is transferred and no transaction is created
|
||||||
super().save(*args, **kwargs)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
self.log("Saving")
|
self.log("Saving")
|
||||||
|
|
|
@ -246,6 +246,13 @@ $("#btn_transfer").click(function() {
|
||||||
// We copy the arrays to ensure that transactions are well-processed even if the form is reset
|
// We copy the arrays to ensure that transactions are well-processed even if the form is reset
|
||||||
[...sources_notes_display].forEach(function (source) {
|
[...sources_notes_display].forEach(function (source) {
|
||||||
[...dests_notes_display].forEach(function (dest) {
|
[...dests_notes_display].forEach(function (dest) {
|
||||||
|
if (source.note.id === dest.note.id) {
|
||||||
|
addMsg("Attention : la transaction de " + pretty_money(amount) + " de la note " + source.name
|
||||||
|
+ " vers la note " + dest.name + " n'a pas été faite car il s'agit de la même note au départ" +
|
||||||
|
" et à l'arrivée.","warning", 10000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$.post("/api/note/transaction/transaction/",
|
$.post("/api/note/transaction/transaction/",
|
||||||
{
|
{
|
||||||
"csrfmiddlewaretoken": CSRF_TOKEN,
|
"csrfmiddlewaretoken": CSRF_TOKEN,
|
||||||
|
|
Loading…
Reference in New Issue