def edit_rekening(): os.system('cls') print(f"{'Edit rekening':^50}") print("=" * 50) users = load_users() user_id = input_id("Masukkan Id:") if user_id in [user.id for user in users]: print("1. Edit pin") print("2. Edit nama") print("3. Edit email") user_choice = input_int("Masukkan pilihan anda: ") if user_choice == 1: user_new_pin = input_pin("Masukkan pin baru: ") edit_user(user_id, 1, user_new_pin) print("Pin berhasil diedit") elif user_choice == 2: user_new_name = input_string("Masukkan nama baru: ") edit_user(user_id, 2, user_new_name) print("Nama berhasil diedit") elif user_choice == 3: user_new_email = input_email("Masukkan email baru: ") edit_user(user_id, 3, user_new_email) print("Email berhasil diedit") else: print("Id tidak ditemukan") print() os.system('pause')
def history_user(): os.system('cls') print(f"{'History pengguna':^50}") print("=" * 50) print("1. Transaksi") print("2. Login") print() user_input = input_int("Masukkan pilihan anda:") user_id = input_id("Id: ") if user_input == 1: with open("History.json") as f: datas = json.load(f) print(f"{'Tanggal':^30} {'Status':10} {'Jumlah':^33} ") for data in datas: if data["ID"] == user_id: print(( f"{data['date']:^30} {data['desc']:10} {'Rp ':3}{data['nominal']:30,.2f}" )) elif user_input == 2: with open("history_login.json") as f: logindatas = json.load(f) print(f"{'tanggal':^30} {'Status':^10}") for data in logindatas: if data["ID"] == user_id: print((f"{data['date']:^30} {data['Status']:^10}")) else: print("Terjadi kesalahan. Silahkan ulangi.") os.system('pause')
def unblok_rekening(): os.system('cls') print(f"{'Unblock rekening':^50}") print("=" * 50) users = load_users() user_id = input_id("Masukkan Id: ") if user_id in [user.id for user in users]: unblock_user(user_id) print("Unblock berhasil") else: print("Id tidak ditemukan") print() os.system('pause')
def remove_rekening(): os.system('cls') print(f"{'Remove rekening':^50}") print("=" * 50) users = load_users() user_id = input_id("Masukkan Id: ") if user_id in [user.id for user in users]: remove_user(user_id) print("Rekening berhasil dihapus") else: print("Id tidak ditemukan") print() os.system('pause')
def cek_saldo_user(): os.system('cls') print(f"{'Cek saldo pengguna':^50}") print("=" * 50) users = load_users() user_id = input_id("Masukkan Id: ") if user_id in [user.id for user in users]: for user in users: if user_id == user.id: print(f"{user_id}'s balance = Rp {user.balance:,.2f}") else: print("Id tidak ditemukan") print() os.system('pause')
def add_rekening(): os.system('cls') users = load_users() print(f"{'Add rekening baru':^50}") print("=" * 50) user_name = input_string("Nama lengkap: ") user_age = input_int("Umur: ") while True: user_id = input_id("Id: ") if user_id not in [user.id for user in users]: break else: print("Id telah digunakan") user_pin = input_pin("Pin: ") user_email = input_email("Email: ") user = User(user_id, user_name, user_pin, user_age, 0, "active", user_email) add_user(user) print('Rekening berhasil ditambahkan') os.system('pause')
def transfer(data): all_data = load_users() system('cls') print(f"{'Transfer':^50}") print("=" * 50) print() list_bank = [ "Bank INI", "Bank SINI", "Bank SITU", "Bank SANA", "Bank SONO", "Sesama Bank ITU" ] print("Masukan kode Bank") for idx, bank in enumerate(list_bank): print(f"{idx+1}. {bank}") print() try: kode_bank = input_int('Masukan Kode Bank : ') if kode_bank < 0 or kode_bank > 6: print('Tidak ditemukan Bank') print('Kode Bank harus antara 1-6') # system('pause') except: print('Masukan Kode Bank dalam angka') system('pause') if 0 < kode_bank < 6: target_transfer = input_id('ID penerima : ') for user in all_data: if user.id == data.id: nominal = input_int('Jumlah : Rp. ') if nominal > data.balance: print('Saldo anda tidak cukup') else: desc_sender = "Anda melakukan transfer kepada\n Bank:{} \n Rekening: {}\n Nama: -\n Sebesar Rp {:,.2f}".format( list_bank[kode_bank - 1], target_transfer, nominal) print(desc_sender) pin = input_pin('PIN : ') if pin == data.pin: edit_balance(user.id, nominal) print('Transaksi Berhasil') transaction_history(nominal, 'transfer', data.id, target_transfer) send_email(user.email, desc_sender) break elif kode_bank == 6: target_transfer = input_id('ID penerima : ') target = False if data.id == target_transfer: #jika id sender dan receiver sama print("Anda tidak bisa melakukan Transfer ke Rekening sendiri") system('pause') return False for x in all_data: if target_transfer == x.id: target = True if target == False: print('ID Tidak ditemukan') system('pause') return False for user in all_data: if user.id == data.id: nominal = input_int('Jumlah : Rp. ') if nominal > data.balance: print('Saldo anda tidak cukup') else: desc_sender = "Anda melakukan transfer kepada\n Rekening: {}\n Sebesar Rp {:,.2f}".format( target_transfer, nominal) desc_receiver = "Anda menerima transfer dari\n Rekening: {}\n Sebesar Rp {:,.2f}".format( user, nominal) # print(desc_sender) for user_target in all_data: if user_target.id == target_transfer: print( "Anda melakukan transfer kepada\n Bank:{} \n Rekening: {}\n Nama: {}\n Sebesar Rp {:,.2f}" .format(list_bank[kode_bank - 1], target_transfer, user_target.name, nominal)) pin = input_pin('PIN : ') if not pin: print('transaksi dibatalkan') elif pin == data.pin: edit_balance(user.id, -nominal) for user_target in all_data: if user_target.id == target_transfer: edit_balance(user_target.id, nominal) transaction_history(nominal, "transfer", data.id, target_transfer) send_email(user.email, desc_sender) send_email(user_target.email, desc_receiver) else: print('PIN anda salah') print() system('pause')
def login(): users = load_users() while True: userid = False login_fail = 4 system('cls') print("{:^50}".format('Welcome To Bank ITU')) print("{:^50}".format('Login')) print("=" * 50) user_id = input_id("ID : ") user_pin = input_pin("PIN : ") for user in users: if user_id == user.id: userid = True while login_fail > 0: if user_pin == user.pin: if user.status == "inactive": print( 'Your account is blocked, contact your admin') system("pause") break else: print('Login berhasil') history_login(user_id, "berhasil") return user else: system('cls') print("{:=^50}".format('Login')) print('Try again, Kesempatan', login_fail) print('ID :', user_id) user_pin = input_pin("PIN : ") if not user_pin: login_fail = -1 elif user_pin == user.pin: if user.status == "inactive": print( 'Your account is blocked, contact your admin' ) system("pause") break else: print('Login berhasil') history_login(user_id, "berhasil") return user else: print('PIN salah') history_login(user_id, "gagal") login_fail -= 1 if login_fail == 0: print('Your Account has been blocked') print('Contact admin!!') system('pause') block_user(user_id) break if login_fail == -1: print('Canceled') try_again_choice = ['yes', "y", "no", 'n'] try_again = input('Continue (y/n) ? ') while try_again not in try_again_choice: try_again = input_string('Continue (y/n) ? ') if try_again == "n": break if userid == False: print('ID or PIN Wrong !!') system('pause')