def create_account(self,bank_ID):
     virtID = db.get_virtual_ID()
     account_num = db.get_account()
     self.full_name = self.first_name, self.last_name
     self.account_info = db.get_accounts(virtID, account_num, self.full_name, self.social, self.address,self.balance,bank_ID)
     print("Account saved.")
     return self.account_info
Exemple #2
0
def parse_bid():
    if request.method == 'POST':
        print(request.form)

    accesstoken = read_account_token_from_db()
    accounts = get_accounts("om2")
    print(accounts)
    acc2 = {}

    for acc in accounts["accounts"]["Data"]["Account"]:
        acc2[acc["Nickname"]] = acc["AccountId"]

    accountid = acc2[request.form.get('selectedAccount')]
    bidamount = request.form.get('bidAmount')

    print(request.form.get('selectedAccount'), accountid)
    print(request.form.get('bidAmount'), bidamount)

    balance = get_balance(accountid, accesstoken)
    print(balance)
    if float(balance['Data']['Balance'][0]['Amount']['Amount']) < float(
            bidamount):
        print("You don't have the money dude!")
        return jsonify({"bidStatus": "You don't have the money dude!"}), 200
    else:
        try:
            from helpers import make_payment, create_payment_request
            print("calling make payment")
            req = create_payment_request(bidamount)
            print(req)
            return jsonify({"Redirect:": req, "code": 302}), 200
        except Exception as e:
            print(e)
        return jsonify({"bidStatus": "Success"}), 200
def change_reps():
	accts = db.get_accounts()
	idx = 0
	for x in accts:
		if idx > len(reps) - 1:
			idx = 0
		rep = reps[idx]
		idx += 1
		check = {'action':'account_representative','account':x}
		output = wallet.communicate_wallet(check)
		if 'representative' not in output or output['representative'] not in reps:
			print("Setting REP: {0} for ACCT: {1}".format(rep, x))
			action = {'action':'account_representative_set', 'wallet':settings.wallet, 'account':x, 'representative':rep}
			wallet.communicate_wallet(action)
		else:
			print("Acct: {0} already set".format(x))
Exemple #4
0
def create_account_ui():
    while True:
        name = input("Enter username: "******"Name already taken!")
        else:
            break
    while True:
        password = input("Enter password: "******"Confirm password: "******"Passwords do not match!")
        else:
            break
    db.create_account(name, password)
    print("Account created! Please proceed by logging in.")
    return
Exemple #5
0
def console_ui():
    actions = [
        "add", "remove", "enable", "disable", "transaction", "transactions",
        "accounts", "delete", "modify", "cancel", "process", "exit"
    ]

    print(f"""
    ================================================================================
    Welcome Admin!
    
""" + "\n".join(actions) + """
    ================================================================================
    """)

    while True:
        # get action
        while True:
            action = input("Action: ").lower()
            if action in actions:
                break

        if action == "transactions":
            print(db.get_transactions())
        elif action == "exit":
            break
        elif action == "transaction":
            transaction_id = input("ID: ")
            transaction_id = int(transaction_id)
            print(db.get_transaction(transaction_id))
        elif action == "accounts":
            print(db.get_accounts())
        elif action == "add":
            name = input_existing_user()
            db.deposit(name)
        elif action == "remove":
            name = input_existing_user()
            db.withdraw(name)
        elif action == "delete":
            name = input_existing_user()
            confirm = input("Confirm action? ").lower()
            if confirm == "yes":
                db.delete_account(name)
        elif action == "enable":
            name = input_existing_user()
            if not db.get_status(name):
                db.enable_account(name)
            else:
                print("Account already enabled!")
        elif action == "disable":
            name = input_existing_user()
            if not db.get_status(name):
                db.enable_account(name)
        elif action == "modify":
            name = input_existing_user()
            password = db.get_password(name)
            new_name = input("New name (put none if no new name): ")
            while True:
                new_password = input(
                    "New password (put none if no new password): ")
                confirm_password = input(
                    "Confirm password (put none if no new password): ")
                if new_password != confirm_password:
                    print("Password does not match!")
                else:
                    break
            if new_name == "none":
                new_name = None
            if new_password == "none":
                new_password = None
            db.modify_account(name, password, new_name, new_password)
            print("Changes saved.")
            break
Exemple #6
0
def show() -> 'json':
    """For AJAX-requests"""
    trans_type = request.args.get('trtype')
    gr_id = request.args.get('group')
    d_params = {
        'd': request.args.get('trn_day'),
        'm': request.args.get('trn_month'),
        'y': request.args.get('trn_year')
    }
    last_m_pars = request.args.get('show_months')
    show_acc = request.args.get('show_accounts')

    # check get-request-arguments
    db_res = 'Parameters are not identified'
    if trans_type is not None:
        db_res = db_session.execute(
            '''SELECT group_goods_id, name FROM group_goods
                            WHERE transacion_type_id = :w1''', {
                'w1': trans_type
            }).fetchall()
    elif gr_id is not None:
        db_res = db_session.execute(
            '''SELECT purchase_id, name FROM purchase
                            WHERE group_goods_id = :w1''', {
                'w1': gr_id
            }).fetchall()

    elif last_m_pars is not None:
        if not json.loads(last_m_pars):
            return
        app_date = datetime.date(app.config['MONTH_YEAR']['y'],
                                 app.config['MONTH_YEAR']['m'], 1)
        last_m_pur = get_last_months_purchase(datepar=app_date)
        db_res = {
            k: [itm[k] if itm[k] is not None else 0 for itm in last_m_pur]
            for rw in last_m_pur for k in rw.keys()
        }
        try:
            db_res['month'] = [get_rus_month(m) for m in db_res['month']]
        except KeyError:
            db_res.setdefault('month', '')

    elif None not in d_params.values():
        try:
            d_params['m'] = get_month(d_params['m'])
            db_res = get_transactions_per_day(d_params)
            if len(db_res) == 0:
                db_res = [['Данные не найдены']]
        except MonthFindError:
            pass

    elif show_acc is not None:
        if json.loads(show_acc):
            db_res = get_accounts()

    elif request.args.get('upd_sber_data') is not None:
        if json.loads(request.args.get('upd_sber_data')):
            m, y = [
                app.config['MONTH_YEAR']['m'], app.config['MONTH_YEAR']['y']
            ]
            db_res = {
                'bal':
                get_balance(m, y),
                'sber_bal':
                get_sber_balance(m, y),
                'sber_tbl': [{
                    ky: val if ky != 'date' else str(val.day) + ' ' +
                    get_rus_month(val.month) + ' ' + str(val.year)
                    for ky, val in line.items()
                } for line in get_sber_transactions(m, y)]
            }

    elif request.args.get('show_users') is not None:
        if json.loads(request.args.get('show_users')):
            db_res = get_owner()

    elif request.args.get('month_year') is not None:
        if json.loads(request.args.get('month_year')):
            db_res = {
                'month': app.config['MONTH_YEAR']['m'],
                'year': app.config['MONTH_YEAR']['y']
            }

    elif request.args.get('show_planning') is not None and request.args.get(
            'planning_group') is not None:
        if json.loads(request.args.get('show_planning')):
            d = datetime.date(app.config['MONTH_YEAR']['y'],
                              app.config['MONTH_YEAR']['m'], 1)
            planning_groups = {
                pl_gr_row['pl_gr_id']: pl_gr_row['name']
                for pl_gr_row in get_planning_groups()
            }
            par_plan_gr = request.args.get('planning_group')
            if par_plan_gr not in planning_groups:
                db_res = {'message': 'Не указана группа планирования'}
            else:
                db_res = {
                    'title':
                    planning_groups[par_plan_gr],
                    'data': [{k: v
                              for k, v in plan_par_row.items()}
                             for plan_par_row in get_planning_parameters(
                                 par_plan_gr, cur_date=d, with_pur_id=True)]
                }
                if len(db_res['data']) != 0:
                    db_res_keys = list(db_res['data'][0].keys())
                    db_res['keys'] = get_field_props(db_res_keys)

    # we need list-type for returning the json-answer
    if type(db_res) == list:
        db_res_for_json = [list(line) for line in db_res]
    else:
        db_res_for_json = db_res

    # json-answer
    return json.dumps(db_res_for_json, sort_keys=True, ensure_ascii=False)