Exemple #1
0
    def show_user_datas(cls):
        super().describe_current_stage('사용자 정보 조회')

        users = reader.read_all_users()
        all_deposits = reader.read_all_accounts(account_type='Deposits')
        all_savings = reader.read_all_accounts()

        for info in users.values():
            deposits, savings = [], []
            # 적금, 예금 분리
            for account_num in info['accounts']:
                if int(account_num[0]) < 5:  # 예금
                    deposits.append(account_num)
                else:  # 적금
                    savings.append(account_num)

            # 출력
            print(f"{info['name']} / {info['sign_up_date']}", end=' / ')

            for deposit in deposits:
                balance = all_deposits[deposit]['balance']
                print(f"{deposit} / {balance}", end=' / ')
            for saving in savings:
                balance = all_savings[saving]['balance']
                print(f"{saving} / {balance}", end=' / ')

            print()
        print(f"총 {len(users)} 명 입니다.\n\n")

        print('아무키나 입력하세요\n')
        input()
    def integrity_check(self) :
        
        # 무결성 검사 
        errorCheck = True   # 에러가 있으면 False로 변경

        # 홈 경로에 데이터 파일이 있는지 확인 
        # 없으면 경고문구 출력, 빈 데이터 파일 생성 
        # 있으면 다음 단계
        user_file_check = fm.make_users()
        history_file_check = fm.make_history()
        account_file_check = fm.make_accounts()

        if user_file_check and history_file_check and account_file_check :
            pass
        else :
            bmv.file_error_output()

        # 데이터 파일 확인 
        # accounts.json, history.json, users.json
        # 예금, 적금 계좌번호 중복확인 
        # 이름, 비밀번호 중복 확인 
        # 문법 규칙 확인 
        ################## keys가 자동으로 중복을 처리해버리는 문제 
        ## json 자체에서 중복이 오류 처리됨
        try :
            users_data = fr.read_all_users()
            if len(set(users_data.keys())) == len(users_data.keys()) :
                pass
            else :
                errorCheck = False
            history_data = fr.read_all_transactions()
            if len(set(history_data.keys())) == len(history_data.keys()) :
                pass
            else :
                errorCheck = False
                
            savings_data = fr.read_all_accounts()
            if len(set(savings_data.keys())) == len(savings_data.keys()) :
                pass
            else :
                errorCheck = False

            deposits_data = fr.read_all_accounts_in_deposit()
            if len(set(deposits_data.keys())) == len(deposits_data.keys()) :
                pass
            else :
                errorCheck = False
        except :
            bmv.error_output()
            errorCheck = False 



        # 오류가 있으면 종료 
        
        
        return errorCheck
Exemple #3
0
    def __send_money_sub1(cls, user):
        # TODO 금액입력형식 / 계좌번호 입력형식

        money_amount = input()
        if money_amount:
            if prd.dataConfirm(money_amount):
                money_amount = int(prd.dataToBasicType(money_amount))
            else:
                print('잘못된 형식입니다\n아무키나 입력하세요')
                input()
                return
        else:
            print('잘못된 형식입니다\n  아무키나 입력하세요')
            input()
            return
        accounts_sender = reader.read_all_accounts_in_deposit()
        balance = accounts_sender[user.deposits]['balance']

        super().request_keyin('계좌번호')
        account_receiver = input()
        confirm = bd.dataConfirm(account_receiver)
        if confirm:
            account_receiver = bd.dataToBasicType(account_receiver)
            print(f'\n입금액 : {money_amount} 원')
            print(f'계좌번호 : {account_receiver}')
            super().confirm_check('이체')
            keyin_result = keyin.type_in_yes_or_no()
            if keyin_result == 'y' or keyin_result == 'yes':
                pass
            else:
                print('취소하였습니다')
                input()
                return
        else:
            print('잘못된 계좌번호입니다.  아무키나 입력하세요')
            input()
            return

        user_receiver = reader.read_one_users(account_receiver)

        if money_amount < balance:
            writer.withdraw_money(user.deposits, money_amount)
            writer.put_money_in_deposit(user_receiver['accounts'][0],
                                        money_amount)
            writer.make_history(user.deposits, user_receiver['accounts'][0],
                                money_amount, 'Deposits_send')
            cls.send_money_result(user, money_amount)
        else:
            print('''잔액이 부족합니다 아무키나 입력하세요''')
            input()
 def give_account(self) :
     # 계좌번호 생성기  
     # user.json에서 키값으로 확인하고 없는것 체크
     # random 
     # 계좌 생성기     
     while True :
         result = ""
         for i in range(14) :
             num = random()
             num = int(num * 10)
             if i == 0 :
                 num = num % 4 + 1
                 '''
                 if typeNum == 1 :   # 예금 계좌번호
                     num = num % 4 + 1
                 elif typeNum == 2 : # 적금 계좌번호
                     num = num % 5 + 5
                 '''
             num = str(num)
             result = result + num
         if fr.new_account_check(result) : 
             pass
         else :
             break
     return result
Exemple #5
0
    def send_money_result(user, amount):
        print(f'{amount}원 이 이체되었습니다.')

        # 완료 메세지를 위해 예금 계좌 잔액 다시 로드
        accounts = reader.read_all_accounts_in_deposit()
        balance = accounts[user.deposits]['balance']
        print(f'잔액은 {balance}원 입니다.')
Exemple #6
0
    def show_deposit_balance(cls, user):
        super().describe_current_stage('예금 조회')

        accounts = reader.read_all_accounts_in_deposit()
        # for user_deposit in user.deposits:
        balance = accounts[user.deposits]['balance']
        print(f'잔액은 {balance}원 입니다.\n\n')
        print('아무키나 입력하세요')
        input()
Exemple #7
0
    def __withdraw_money_in_deposit_result(user, amount):
        print(f'{amount} 이 출금되었습니다.')

        # 예금 계좌 갱신
        writer.withdraw_money(user.deposits, amount)
        accounts = reader.read_all_accounts_in_deposit()
        balance = accounts[user.deposits]['balance']
        print(f"잔액은 {balance}원 입니다.")

        # 거래 내역 저장
        writer.make_history(user.deposits, '00000000000000', amount,
                            "Deposits_withdraw")
Exemple #8
0
    def show_saving_balance(cls, user):
        super().describe_current_stage('적금 조회')

        savings = reader.read_all_accounts()
        if user.savings in savings.keys():
            balance = savings[user.savings]['balance']
            due_date = savings[user.savings]['expiration_date']
            print(f'잔액은 {balance}원 입니다.')
            print(f'만기일은 {due_date} 입니다.\n\n')
        else:
            print(f'{user.name}님의 적금 계좌가 존재하지 않습니다.')

        print('아무키나 입력하세요....\n')
        input()
Exemple #9
0
    def __put_money_in_saving_result(user, amount):
        print(f'{amount}원이 입금되었습니다.')

        # 적금 계좌 갱신
        writer.put_money(user.savings, amount)
        accounts = reader.read_all_accounts()
        balance = accounts[user.savings]['balance']
        print(f"잔액은 {balance}원 입니다.")
        print('아무키나 입력하세요.....\n\n')
        input()

        # 거래 내역 저장
        writer.make_history(user.savings,
                            user.savings,
                            amount,
                            account_type='Savings')
Exemple #10
0
    def __show_saving_history_result(cls, user, start_date, end_date):
        super().Ais('<' + user.name + '님의 내역>\n')

        transactions = reader.read_all_transactions()
        if user.savings in transactions.keys():
            for history in transactions[user.savings]:
                if int(history['date']) > int(start_date) and int(
                        history['date']) < int(end_date):
                    print(
                        f"{history['from']} / {history['to']} / {history['date']} / {history['time']} / {history['amount']}\n"
                    )
            super().Ais('마지막 페이지')
            print('아무키나 입력하세요....\n\n')
            input()
        else:
            print('내역이 없습니다.\n\n')
Exemple #11
0
    def show_transaction_datas(cls):
        super().describe_current_stage('전체 내역 조회')

        transactions = reader.read_all_transactions()
        transactions_without_redundancy = []
        for one_account_history in transactions.values():
            for history in one_account_history:
                stamp = history['date'] + history['time']  # exclude redundancy
                if stamp not in transactions_without_redundancy:
                    transactions_without_redundancy.append(stamp)
                    print(
                        f"{history['from']} / {history['to']} / {history['date']} / {history['time']} / {history['amount']}"
                    )

        print(f"총 {len(transactions_without_redundancy)} 건 입니다.")

        print('아무키나 입력하세요.....\n')
        input()
    def getData(self, account):
        userData = fr.read_one_users(account)
        result = ""
        if userData == False:
            return result
        else:
            id = int(account[:4])
            if 0 <= id < 1000:
                # 관리자
                admin = 0
                name = userData['name']
                pw = userData['pw']
                date = userData['sign_up_date']
                result = {
                    'id': account,
                    'name': name,
                    'sign_up_date': date,
                    'user_class': admin,
                    'Deposits': id,
                    'Savings': 0
                }
                return result
            elif 1000 <= id < 5000:
                # 일반 사용자
                admin = 1
                name = userData['name']
                pw = userData['pw']
                date = userData['sign_up_date']
                depositAccount = userData['accounts'][0]
                try :
                    savingsAccount = userData['accounts'][1]
                except IndexError:
                    savingsAccount = ""
                result = {
                    'id': account,
                    'name': name,
                    'sign_up_date': date,

                    'user_class': admin,
                    'Deposits': depositAccount,
                    'Savings': savingsAccount
                }
                return result
Exemple #13
0
 def __show_deposit_history_result(cls, user, start_date, end_date):
     super().Ais(user.name + '님의 내역')
     #10개씩 출력 --> 아무키나 입력시 다음 10개로
     transactions = reader.read_all_transactions()
     if user.deposits in transactions.keys():
         cnt = -1
         for history in transactions[user.deposits]:
             cnt = cnt + 1
             if int(history['date']) >= int(start_date) and int(
                     history['date']) <= int(end_date):
                 print(
                     f"{history['from']} / {history['to']} / {history['date']} / {history['time']} / {history['amount']}"
                 )
                 if cnt == 10:
                     cnt = 0
                     input()
                     continue
                 else:
                     pass
         super().Ais('마지막 페이지')
     else:
         print('내역이 없습니다.')
Exemple #14
0
    def __withdraw_money_in_deposit_sub(cls, user):
        # TODO 올바른 금액 입력 keyin utils

        money_amount = input()
        if money_amount:
            if prd.dataConfirm(money_amount):
                money_amount = int(prd.dataToBasicType(money_amount))
            else:
                print('잘못된 형식입니다\n아무키나 입력하세요')
                input()
                return
        else:
            print('잘못된 형식입니다\n  아무키나 입력하세요')
            input()
            return
        accounts = reader.read_all_accounts_in_deposit()
        balance = accounts[user.deposits]['balance']

        if money_amount < balance:
            cls.__withdraw_money_in_deposit_result(user, money_amount)
        else:
            print('''잔액이 부족합니다 아무키나 입력하세요''')
            input()
 def loginCheck(self, id, pw):
     userData = fr.read_one_users(id)
     if userData['pw'] == pw:
         return True
     else:
         return False