gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-bank] branch master updated: Adding tool to perform


From: gnunet
Subject: [GNUnet-SVN] [taler-bank] branch master updated: Adding tool to perform wire transfers manually - the Web server isn't required to run in order to have wire transfers effective.
Date: Tue, 16 Jan 2018 14:23:23 +0100

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository bank.

The following commit(s) were added to refs/heads/master by this push:
     new 8035958  Adding tool to perform wire transfers manually - the Web 
server isn't required to run in order to have wire transfers effective.
8035958 is described below

commit 8035958596113d5e58a98c8487f0a4c6fb1e7467
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Jan 16 14:21:38 2018 +0100

    Adding tool to perform wire transfers manually - the Web server
    isn't required to run in order to have wire transfers effective.
---
 talerbank/app/management/commands/wire_transfer.py | 80 ++++++++++++++++++++++
 1 file changed, 80 insertions(+)

diff --git a/talerbank/app/management/commands/wire_transfer.py 
b/talerbank/app/management/commands/wire_transfer.py
new file mode 100644
index 0000000..82f18d0
--- /dev/null
+++ b/talerbank/app/management/commands/wire_transfer.py
@@ -0,0 +1,80 @@
+#  This file is part of TALER
+#  (C) 2014, 2015, 2106 INRIA
+#
+#  TALER is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published
+# by the Free Software Foundation; either version 3, or (at your
+# option) any later version.
+#
+#  TALER is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public
+# License along with TALER; see the file COPYING.  If not, see
+# <http://www.gnu.org/licenses/>
+#
+#  @author Marcello Stanisci
+
+import sys
+import logging
+import json
+from django.core.management.base import BaseCommand
+from django.contrib.auth import authenticate
+from ...amount import Amount, BadFormatAmount
+from ...views import wire_transfer
+from ...models import BankAccount, BankTransaction
+
+LOGGER = logging.getLogger(__name__)
+
+class Command(BaseCommand):
+    help = "Wire transfer money and return the transaction id."
+
+    def add_arguments(self, parser):
+        parser.add_argument(
+            "user", type=str, metavar="USERNAME",
+            help="Which user is performing the wire transfer")
+        parser.add_argument(
+            "password", type=str, metavar="PASSWORD",
+            help="Performing user's password.")
+        parser.add_argument(
+            "credit-account", type=int, metavar="CREDIT-ACCOUNT",
+            help="Which account number will *receive* money.")
+        parser.add_argument(
+            "subject", type=str, metavar="SUBJECT",
+            help="SUBJECT will be the wire transfer subject.")
+        parser.add_argument(
+            "amount", type=str, metavar="AMOUNT",
+            help="Wire transfer's amount, given in the " \
+            "CURRENCY:X.Y form.")
+
+
+    def handle(self, *args, **options):
+
+        user = authenticate(
+            username=options["user"], password=options["password"])
+        if not user:
+            LOGGER.error("Wrong user/password.")
+            sys.exit(1)
+        try:
+            amount = Amount.parse(options["amount"])
+        except BadFormatAmount:
+            LOGGER.error("Amount's format is wrong: respect C:X.Y.")
+            sys.exit(1)
+
+        try:
+            credit_account = BankAccount.objects.get(
+                account_no=options["credit-account"])
+        except BankAccount.DoesNotExist:
+            LOGGER.error("Credit account does not exist.")
+            sys.exit(1)
+
+        try:
+            transaction = wire_transfer(
+                amount, user.bankaccount,
+                credit_account, options["subject"])
+            print("Transaction id: " + str(transaction.id))
+        except Exception as exc:
+            LOGGER.error(exc)
+            sys.exit(1)

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]