def main(): while True: user = login() #login page system('pause') while True: #user page system('cls') print("\nWelcome, {} ".format(user.name)) print() print("1. Cek Saldo") print("2. Setor") print("3. Tarik") print("4. Transfer") print("5. Exit") print() # try: user_choices = input_int('Masukkan pilihan anda : ') if user_choices == 1: system('cls') cek_saldo(user) system('pause') elif user_choices == 2: setor(user) elif user_choices == 3: tarik(user) elif user_choices == 4: transfer(user) elif user_choices == 5: break
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 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 setor(user): system('cls') amount = input_int('Jumlah Setoran : Rp. ') edit_balance(user.id, amount) transaction_history(amount, "setor", user.id, '') user.balance += amount print("Penyetoran berhasil") print(f'Anda telah melakukan penyetoran sebesar Rp. {amount:,.2f}') print(terbilang(amount), 'Rupiah') system('pause')
def tarik(user): system('cls') amount = input_int('Jumlah Penarikan : Rp. ') if (user.balance - amount) < 0: print("Saldo tidak mencukupi") else: edit_balance(user.id, -amount) transaction_history(amount, "tarik", user.id, '') print("Penarikan berhasil") print(f'Anda telah melakukan penarikan sebesar Rp. {amount:,.2f}') print(terbilang(amount), 'Rupiah') user.balance -= amount system('pause')
def add_admin(): os.system('cls') print(f"{'Add admin baru':^50}") print("=" * 50) admins = load_admins() admin_name = input_string("Nama lengkap: ") admin_age = input_int("Umur: ") while True: admin_id = input_string("Id: ") if admin_id not in [admin.id for admin in admins]: break else: print("Id telah digunakan") admin_password = input_password("Password: "******"Admin berhasil ditambahkan") 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 main(): login_admin() startupCheck() while True: os.system('cls') print_menu() print() user_input = input_int("Masukkan pilihan anda: ") if user_input == 1: add_rekening() elif user_input == 2: remove_rekening() elif user_input == 3: edit_rekening() elif user_input == 4: blok_rekening() elif user_input == 5: unblok_rekening() elif user_input == 6: cek_saldo_user() elif user_input == 7: print_list_rekening() elif user_input == 8: history_user() elif user_input == 9: add_admin() elif user_input == 10: remove_admin() elif user_input == 11: list_admin() elif user_input == 12: edit_admin() elif user_input == 13: os.system('cls') print( "Terima kasih telah mempercayai Bank ITU sebagai bank pilihan anda\n" ) os.system('pause') break
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')