From 935ebf291afd54e31dbc325c699c354c846c7c5a Mon Sep 17 00:00:00 2001 From: Pierre-antoine Comby Date: Sat, 28 Mar 2020 21:31:22 +0100 Subject: [PATCH] use note id , not alias id --- static/js/consos.js | 2 +- static/js/transfer.js | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/static/js/consos.js b/static/js/consos.js index 20859933..9450febc 100644 --- a/static/js/consos.js +++ b/static/js/consos.js @@ -167,7 +167,7 @@ function reset() { function consumeAll() { notes_display.forEach(function(note_display) { buttons.forEach(function(button) { - consume(note_display.id, note_display.name, button.dest, button.quantity * note_display.quantity, button.amount, + consume(note_display.note.id, note_display.name, button.dest, button.quantity * note_display.quantity, button.amount, button.name + " (" + button.category_name + ")", button.type, button.category_id, button.id); }); }); diff --git a/static/js/transfer.js b/static/js/transfer.js index cf62e453..5b673acb 100644 --- a/static/js/transfer.js +++ b/static/js/transfer.js @@ -83,7 +83,7 @@ $("#transfer").click(function() { "polymorphic_ctype": TRANSFER_POLYMORPHIC_CTYPE, "resourcetype": "Transaction", "source": user_id, - "destination": dest.id, + "destination": dest.note.id, "destination_alias": dest.name }).done(function () { addMsg("Le transfert de " @@ -91,7 +91,7 @@ $("#transfer").click(function() { + " vers la note " + dest.name + " a été fait avec succès !", "success"); reset(); - }).fail(function () { + }).fail(function () { // do it again but valid = false $.post("/api/note/transaction/transaction/", { "csrfmiddlewaretoken": CSRF_TOKEN, @@ -103,7 +103,7 @@ $("#transfer").click(function() { "polymorphic_ctype": TRANSFER_POLYMORPHIC_CTYPE, "resourcetype": "Transaction", "source": user_id, - "destination": dest.id, + "destination": dest.note.id, "destination_alias": dest.name }).done(function () { addMsg("Le transfert de " @@ -133,9 +133,9 @@ $("#transfer").click(function() { "valid": true, "polymorphic_ctype": TRANSFER_POLYMORPHIC_CTYPE, "resourcetype": "Transaction", - "source": source.id, + "source": source.note.id, "source_alias": source.name, - "destination": dest.id, + "destination": dest.note.id, "destination_alias": dest.name }).done(function () { addMsg("Le transfert de " @@ -143,7 +143,7 @@ $("#transfer").click(function() { + " vers la note " + dest.name + " a été fait avec succès !", "success"); reset(); - }).fail(function (err) { + }).fail(function (err) { // do it again but valid = false $.post("/api/note/transaction/transaction/", { "csrfmiddlewaretoken": CSRF_TOKEN, @@ -154,9 +154,9 @@ $("#transfer").click(function() { "invalidity_reason": "Solde insuffisant", "polymorphic_ctype": TRANSFER_POLYMORPHIC_CTYPE, "resourcetype": "Transaction", - "source": source.id, + "source": source.note.id, "source_alias": source.name, - "destination": dest.id, + "destination": dest.note.id, "destination_alias": dest.name }).done(function () { addMsg("Le transfert de " @@ -176,7 +176,7 @@ $("#transfer").click(function() { }); } else if ($("#type_credit").is(':checked') || $("#type_debit").is(':checked')) { let special_note = $("#credit_type").val(); - let user_note = dests_notes_display[0].id; + let user_note = dests_notes_display[0].note.id; let given_reason = $("#reason").val(); let source, dest, reason; if ($("#type_credit").is(':checked')) { @@ -217,4 +217,4 @@ $("#transfer").click(function() { reset(); }); } -}); \ No newline at end of file +});