Example #1
0
 def print_bills(bills):
     print("-" * 40)
     print("All Bills are here:")
     for bill_id in bills:
         bill = Bill.get_bill_by_id(bill_id)
         Db.print_bill(bill)
     print("-" * 40)
Example #2
0
def handling_cart():

    items_present = Users.view_cart(db_obj.user_id)

    if items_present:

        t = PrettyTable(["Cart Menu", "Type"])
        t.add_row(["Checkout & Buy", "c/C"])
        t.add_row(["<--Back to Customer Menu", "b/B"])
        print(t)

        choice = input("\nYour Choice: ")

        if len(choice) == 1:
            if choice in 'cC':

                # generate bill
                print("Do you want to checkout cart now? ")
                tb = PrettyTable(["Cart Menu", "Type"])
                tb.add_row(["Yes", "y/Y"])
                tb.add_row(["No", "n/N"])
                print(tb)

                choice = input("Generate Bill : ")
                print("-" * 30)

                if choice in "yY":
                    actual_amount = 0
                    actual_amount = Users.generate_bill(db_obj.user_id)

                    print("You will be paying Rs.{} ................".format(
                        actual_amount))
                    yes_no = input("Pay : ")

                    # pay bill
                    billing = Bill()
                    bill_id = billing.add_bill(userid=db_obj.user_id,
                                               actual_amount=actual_amount)

                    bill_object = Bill.get_bill_by_id(bill_id)
                    Db.print_bill(bill_object)

                    print("Thanks for Shopping !!!")
                else:
                    return

            elif choice in 'bB':
                return
            else:
                print("Wrong Choice. Please Try again")
                return
        else:
            print("Type 1 character only!! Try again")
            return
    else:
        print(
            "Empty Cart.\nShop Now !! And get discount upto Rs.500!!\nHurry!!!!!!!!!!"
        )

        # put category link here
        return