Untitled

 avatar
unknown
plain_text
2 years ago
2.9 kB
5
Indexable
    elif option == 2:
        product_rented = {}
        k = str(datetime.today())
        date_now = k[0:10] + '~' + k[11:19]
        print("The available products are ")
        data_show()
        x = correct_sn('rent')
        if available(x) == False:
            print("sorry the product is not available, perhaps you could email us to request for this product")
            main_loop()
        elif available(x) == True:
            print("The product is available")
        ask = input(f'are you sure you want to rent {data[x - 1][1]} () : ')
        if ask == 'yes':
            name = correct_name()
            number = correct_number()
            quantity = correct_quantity('rent', x)
            update(x, 0, 'record.txt', quantity)
            product_rented[x] = quantity
            boole = True
            while (boole):
                ask = input("Do you again want to rent another custom (yes/no) : ")
                if ask == 'yes':
                    data_show()
                    x = correct_sn('rent')
                    if available(x) == False:
                        print(
                            "sorry the product is not available, perhaps you could email us to "
                            "request for this product")
                        continue
                    elif available(x) == True:
                        print("The product is available")
                    y = input(f'are you sure you want to rent {data[x - 1][1]} (yes/no) : ')
                    if y == 'yes':
                        quantity = correct_quantity('rent', x)
                        update(x, 0, 'record.txt', quantity)
                        product_rented[x] = quantity
                elif ask == 'no':
                    boole = False
            gap = ' ' * 5
            print("=" * 65)
            print(f"{'Here is your reciept' :^65s}")
            print('-' * 65)
            print(f"{'Name of customer' :20s}{gap}{name :20s}")
            print(f"{'Number of customer' :20s}{gap}{number :<20d}")
            print(f"{'Date of purchase' :20s}{gap}{date_now :20s}")
            print("=" * 65)
            print(f"{f'Products rented by {name}' :^65s}")
            print('-' * 65)
            net = 0
            print(f"{'Name of costume' :17s}{gap}{'Brand' :14s}{gap}{'Unit price' :5s}{gap}{'Quantity' :5s}")
            print('-' * 65)
            for key in product_rented:
                print(
                    f"{data[key - 1][1] :17s}{gap}{data[key - 1][2] :14s}{gap}{data[key - 1][3] :^5s}{gap}{gap}"
                    f"{product_rented[key] :>5d}")
                net += int((data[key - 1][3])[1:]) * int(product_rented[key])
            print("=" * 65)
            print(f"{'Net amount' :20s}{gap}{'$' + str(net) :20s}")
            print("=" * 65)
            write_to_file_rent(name, number, product_rented)
Editor is loading...