Example #1
0
def main():
    action = "Start"

    while action != "End":
        action = input(
            "What do you want to do?[Add meal, Add Service, Sum, Discount, Save, End]:"
        )

        if action == "Add meal":
            name, price = view.ask_for_meal()
            if name is None or price is None:
                continue
            bill.add_meal(name, price)
        elif action == "Add Service":
            name, price, guest_number = view.ask_for_service()
            bill.add_service(name, price, guest_number)
        elif action == "Sum":
            print(bill.calculate())
        elif action == "Discount":
            discount = view.ask_for_discount()
            print(bill.calculate_with_discount(discount))
        elif action == "Check":
            overall_sum, discount = view.ask_for_check_discount()
            if overall_sum is None or discount is None:
                continue
            print(Bill.check_discount(overall_sum, discount))
        elif action == "Save":
            filename = view.ask_for_filename()
            bill.print_to_file(filename)
Example #2
0
def check():
    overall_sum = float(request.form['overall_sum'])
    discount_value = int(request.form['discount'])
    value = Bill.check_discount(overall_sum, discount_value)
    return render_template(
        'default_template.html',
        message=f"Whole order will cost: {value} after discount")