Pankaj-Str / Complete-Python-Mastery

Explore the world of Python programming with 'Complete Python Mastery'! Our repository, led by Pankaj, offers a series of in-depth tutorials under the banner 'Codes with Pankaj.' Dive into hands-on coding examples, insightful explanations, and practical projects as Pankaj guides you through mastering Python.
https://www.codeswithpankaj.com/
31 stars 24 forks source link

Assignment: E-commerce-like Advanced Billing System using Python #5

Open Pankaj-Str opened 1 month ago

Pankaj-Str commented 1 month ago

Objective:

Create an advanced billing system for an e-commerce application that allows users to input product details, apply GST, select discount offers, remove products, and calculate the final bill. The system should provide a detailed invoice with a breakdown of each item, taxes, discounts, and the total amount in Indian Rupees (₹).

Requirements:

  1. Product Input:

    • Allow the user to input multiple product details including:
      • Product ID
      • Product Name
      • Quantity
      • Unit Price (in ₹)
  2. GST Calculation:

    • Apply GST (Goods and Services Tax) to each product. GST rates should be variable and user-defined (e.g., 5%, 12%, 18%, 28%).
  3. Discount Offers:

    • Allow the user to select from various discount offers:
      • Percentage Discount on the total bill (e.g., 5%, 10%, 15%)
      • Fixed Amount Discount on the total bill (e.g., ₹100, ₹200)
      • Discount on specific products (e.g., 10% off on Product A)
  4. Product Removal:

    • Allow the user to remove products from the list by entering the Product ID.
  5. View Products:

    • Allow the user to view all products added to the bill with their details.
  6. Invoice Generation:

    • Generate a detailed invoice including:
      • Product details (Product ID, Name, Quantity, Unit Price, Subtotal)
      • GST applied
      • Discounts applied
      • Total amount before and after tax and discounts
  7. User Interface:

    • Create a simple text-based menu-driven interface to interact with the system.
    • Provide options to:
      • Add a new product
      • View all products
      • Remove a product
      • Apply GST
      • Apply Discounts
      • Generate and view the final invoice
  8. Data Validation:

    • Ensure data validation for user inputs (e.g., numeric values for prices and quantities, valid GST rates).

Example Workflow:

  1. Add Products:

    Enter Product ID: 101
    Enter Product Name: Laptop
    Enter Quantity: 2
    Enter Unit Price (₹): 75000
    Enter Product ID: 102
    Enter Product Name: Mouse
    Enter Quantity: 5
    Enter Unit Price (₹): 500
  2. View Products:

    -----------------------------------
    Products List:
    -----------------------------------
    Product ID: 101, Product Name: Laptop, Quantity: 2, Unit Price (₹): 75000
    Product ID: 102, Product Name: Mouse, Quantity: 5, Unit Price (₹): 500
  3. Remove Product:

    Enter Product ID to remove: 102
  4. Apply GST:

    Enter GST rate (%): 18
  5. Apply Discounts:

    Select Discount Type:
    1. Percentage Discount on Total Bill
    2. Fixed Amount Discount on Total Bill
    3. Discount on Specific Product
    Enter Choice: 1
    Enter Discount Rate (%): 10
  6. Generate Invoice:

    -----------------------------------
    E-commerce Billing System Invoice
    -----------------------------------
    Product ID: 101
    Product Name: Laptop
    Quantity: 2
    Unit Price (₹): 75000
    Subtotal (₹): 150000
    GST @ 18% (₹): 27000
    -----------------------------------
    Total before discount (₹): 177000
    Discount @ 10% (₹): 17700
    -----------------------------------
    Final Total (₹): 159300
    -----------------------------------

Submission:

Submit the Python script implementing the advanced billing system. Ensure your code is well-documented with comments explaining each part of the logic. Include a README file explaining how to run your program and any dependencies required.

Evaluation Criteria:


nickyjbn commented 1 month ago

productID = []
productName = []
quantity = []
unitPrice = []

option = 1
gst = 0
val = 0
discount = 0
switchOption = int(input("Enter 1. To add new product\n 2. To view all products\n 3. To remove a product\n 4. To apply GST\n 5. To apply discounts\n 6. To generate and view the final invoice\n"))
while(switchOption != 0):

        if(switchOption == 1):

            prodID = input("Enter Product ID: ")
            productID.append(prodID)
            prodName = input("Enter Product Name: ")
            productName.append(prodName)
            quanti = int(input("Enter Quantity: "))
            quantity.append(quanti)
            uniPrice = int(input("Enter Unit Price (Rs): "))
            unitPrice.append(uniPrice)
            switchOption = int(input("Enter 1. To add new product\n 2. To view all products\n 3. To remove a product\n 4. To apply GST\n 5. To apply discounts\n 6. To generate and view the final invoice\n"))

        elif(switchOption == 2):
            print("-----------------------------------")
            print("Products List:")
            print("-----------------------------------")
            for i in range(0, len(productID)):

                print(f"Product ID: {productID[i]}, Product Name: {productName[i]}, Quantity: {quantity[i]} + Unit Price (Rs): {unitPrice[i]}")

            switchOption = int(input("Enter 1. To add new product\n 2. To view all products\n 3. To remove a product\n 4. To apply GST\n 5. To apply discounts\n 6. To generate and view the final invoice\n"))

        elif(switchOption == 3):
            prodID = input("Enter Product ID to remove: ")
            index = 0
            for i in range(0, len(productID)):
                if(productID[i] == prodID):
                    index = i

            num = productID.pop(index)
            num = productName.pop(index)
            num = quantity.pop(index)
            num = unitPrice.pop(index)
            switchOption = int(input("Enter 1. To add new product\n 2. To view all products\n 3. To remove a product\n 4. To apply GST\n 5. To apply discounts\n 6. To generate and view the final invoice\n"))

        elif(switchOption == 4):

            gst = int(input("Enter GST rate (%): "))
            switchOption = int(input("Enter 1. To add new product\n 2. To view all products\n 3. To remove a product\n 4. To apply GST\n 5. To apply discounts\n 6. To generate and view the final invoice\n"))

        elif(switchOption == 5):
            rate = 0
            discount = 0
            print("Select Discount Type:\n 1. Percentage Discount on Total Bill\n 2. Fixed Amount Discount on Total Bill\n 3. Discount on Specific Product\n")
            val = int(input("Enter choice: "))
            if(val == 1):
                rate = int(input("Enter Discount Rate (%): "))

            elif(val == 2):
                discount = int(input("Enter the fixed amount discount on total bill: "))

            elif(val == 3):
                for i in range(0, len(productID)):
                    dis = int(input(f"Enter the discount for productID {productID[i]}: "))
                    unitPrice[i] = unitPrice[i] - (unitPrice[i] * dis / 100)
            switchOption = int(input("Enter 1. To add new product\n 2. To view all products\n 3. To remove a product\n 4. To apply GST\n 5. To apply discounts\n 6. To generate and view the final invoice\n"))

        elif(switchOption == 6):
            print("-----------------------------------")
            print("E-commerce Billing System Invoice")
            print("-----------------------------------")
            subtotal = 0
            for i in range(0, len(productID)):
                print(f"Product ID: {productID[i]}")
                print(f"Product Name: {productName[i]}")
                print(f"Quantity: {quantity[i]}")
                print(f"Unit Price (Rs): {unitPrice[i]}")
                subtotal = subtotal + quantity[i] * unitPrice[i]
            print(f"Subtotal (Rs): {subtotal}")
            print(f"GST @ {gst}% (Rs): {(gst*subtotal/100)}")
            print("-----------------------------------")
            print(f"Total before discount (₹): {(subtotal + gst*subtotal/100)}")
            if(val == 1):
                print(f"Discount @ {rate}% (Rs): {rate*(subtotal + gst*subtotal/100)/100}")
                print("-----------------------------------")
                finalTotal = (subtotal + gst*subtotal/100) - ((rate*(subtotal + gst*subtotal/100)/100))
                print(f"Final Total (₹): {finalTotal}")
                print("-----------------------------------")
            elif(val == 2):
                print(f"Discount is {discount}")
                print("-----------------------------------")
                finalTotal = (subtotal + gst*subtotal/100) - discount
                print(f"Final Total (₹): {finalTotal}")
                print("-----------------------------------")   
            elif(val == 3):
                print("-----------------------------------")
                finalTotal = (subtotal + gst*subtotal/100)
                print(f"Final Total (₹): {finalTotal}")
                print("-----------------------------------")
            switchOption = 0
developology commented 1 month ago

https://github.com/developology/E-Commerce-Billing-System-