Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Computer Science Project

Submitted by Group 2 students of Class XII-Sc(A)


Name :- Subhankar Roy
Class:- XII (Science)
Roll.no:- 42 Section:- A
Students list
Sl.no. Name Roll no.
1 Abhishek Roy 2
2 Bishal Das 9
3 Debojit Paul 15
4 Kaberi Paul 22
5 Paramita Paul 29
6 Subhankar Roy 42

Topic: GST billing


Python base code:
class Product:
def __init__(self, name, price, quantity, gst_rate):
self.name = name
self.price = price
self.quantity = quantity
self.gst_rate = gst_rate

def get_total_price(self):
return self.price * self.quantity

def get_gst_amount(self):
return (self.price * self.quantity) * (self.gst_rate / 100)

def get_total_amount(self):
return self.get_total_price() + self.get_gst_amount()
class BillingSoftware:
def __init__(self):
self.products = []

def add_product(self, product):


self.products.append(product)

def remove_product(self, product):


self.products.remove(product)

def calculate_total_amount(self):
total_amount = 0
for product in self.products:
total_amount += product.get_total_amount()
return total_amount

def generate_bill(self):
print("********** Invoice **********")
for product in self.products:
print(f"Name: {product.name}")
print(f"Price: {product.price}")
print(f"Quantity: {product.quantity}")
print(f"GST Rate: {product.gst_rate}")
print(f"Total Price: {product.get_total_price()}")
print(f"GST Amount: {product.get_gst_amount()}")
print(f"Total Amount (incl. GST): {product.get_total_amount()}")
print("-----------------------------")
print(f"Total Amount to be paid: {self.calculate_total_amount()}")

def clear_bill(self):
self.products = []

if __name__ == "__main__":
Operation of code (used with an indentation):
# Creating instance of the billing software
billing = BillingSoftware()
1) This code under the ‘if’ statement (with an
indentation) is used to create instance for the
software.

# Adding products
billing.add_product(Product("Product name", Price, Quantity, GST rate))
2) This code is used to add products with its name, price,
quantity and GST rate accordingly. Multiple of it can
be written to add multiple products.

# Generating bill
billing.generate_bill()
3) This line of code is used to generate the processed bill.

# Clearing the bill


billing.clear_bill()
4) This code is used to clear the bill to restart again.
Here is a table with Products, their prices, quantities and
GST rate to show its working.
Sl.no. Product name Price Quantity GST rate
1 Iphone 1,99,900 1 18
2 Mac pro 7,69,700 1 18
3 Ipad pro 2,37,900 1 18

Our code will work as follows (under class =


BillingSoftware):
if __name__ == "__main__":
billing = BillingSoftware()
billing.add_product(Product("Iphone", 199900.0, 1, 18))
billing.add_product(Product("Mac pro", 769700.0, 1, 18))
billing.add_product(Product("Ipad pro", 237900.0, 1, 18))
billing.generate_bill()

Output:

You might also like