예제 #1
0
파일: bank.py 프로젝트: kayvic20/first_repo
    def transfer(self, amount, target, comment):

        self.withdraw(amount, should_log=False)

        self.deposit(amount, target, should_log=False)

        pymysql_lib.create_log(self.logged_user,
                               target,
                               amount,
                               comment,
                               type='transfer')
예제 #2
0
파일: bank.py 프로젝트: kayvic20/first_repo
    def withdraw(self, amount, name="self", comment="none", should_log=True):

        target_name = name if name != "self" else self.logged_user

        original_balance = pymysql_lib.get_balance(target_name)[0]['balance']
        bal = int(original_balance) - amount

        pymysql_lib.alter_balance(target_name, bal)

        if should_log:
            pymysql_lib.create_log(target_name,
                                   target_name,
                                   amount,
                                   comment,
                                   type='withdrawal')

        print("withdrawal Successfull...!")
예제 #3
0
파일: bank.py 프로젝트: kayvic20/first_repo
    def deposit(self, amount, name="self", comment='none', should_log=True):

        target_name = name if name != "self" else self.logged_user

        original_balance = pymysql_lib.get_balance(target_name)[0]['balance']
        bal = int(original_balance) + amount

        pymysql_lib.alter_balance(target_name, bal)

        if should_log:

            pymysql_lib.create_log(target_name,
                                   target_name,
                                   amount,
                                   comment,
                                   type='deposit')

        print("Deposit Successfull...!")