1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-12-22 15:32:22 +00:00

🐛 Prevent transactions to have the same source and destination

This commit is contained in:
Yohann D'ANELLO 2020-08-06 12:46:44 +02:00
parent 252ddb832d
commit d9cf812074
2 changed files with 8 additions and 2 deletions

View File

@ -222,8 +222,7 @@ class Transaction(PolymorphicModel):
self.destination_alias = str(self.destination)
if self.source.pk == self.destination.pk:
# When source == destination, no money is transferred
super().save(*args, **kwargs)
# When source == destination, no money is transferred and no transaction is created
return
self.log("Saving")

View File

@ -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
[...sources_notes_display].forEach(function (source) {
[...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/",
{
"csrfmiddlewaretoken": CSRF_TOKEN,