Medical shop billing system code
Medical shop billing system code
Table Creation: The CREATE TABLE IF NOT EXISTS ensures that each table (items,
items_2, items_3) is only created if it doesn't already exist.
Inserting Data: The executemany() function is used to insert multiple records for
each table in one go.
Committing: The conn.commit() function saves the changes to the database.
Closing the Cursor: cursor.close() is used to close the cursor.
class Bill_App:
def __init__(self,root):
self.root=root
self.root.geometry("1350x700+0+0")
self.root.configure(bg="#5B2C6F")
self.root.title("Billing Software")
title=Label(self.root,text="Marvel
Pharmacy",bd=12,relief=RIDGE,font=("Arial
Black",20),bg="#A569BD",fg="white").pack(fill=X)
#===================================variables==========================
=============================================================
self.para=IntVar()
self.pan_d=IntVar()
self.saridon=IntVar()
self.thyrox=IntVar()
self.ambizyme=IntVar()
self.ecosprin=IntVar()
self.broncophil=IntVar()
self.multivitamin=IntVar()
self.protein=IntVar()
self.ors=IntVar()
self.baby=IntVar()
self.endura=IntVar()
self.beta_g=IntVar()
self.vaseline=IntVar()
self.diaper=IntVar()
self.pad=IntVar()
self.beta_d=IntVar()
self.bandaid=IntVar()
self.cotton=IntVar()
self.sanitizer=IntVar()
self.wipes=IntVar()
self.total_med=StringVar()
self.total_hel=StringVar()
self.total_hyg=StringVar()
self.a=StringVar()
self.b=StringVar()
self.c=StringVar()
self.c_name=StringVar()
self.bill_no=StringVar()
x=random.randint(1000,9999)
self.bill_no.set(str(x))
self.phone=StringVar()
#==========================================customer details
label frame=================================================
details=LabelFrame(self.root,text="Customer
Details",font=("Arial
Black",12),bg="#A569BD",fg="white",relief=GROOVE,bd=10)
details.place(x=0,y=80,relwidth=1)
cust_name=Label(details,text="Customer Name",font=("Arial
Black",14),bg="#A569BD",fg="white").grid(row=0,column=0,padx=15)
cust_entry=Entry(details,borderwidth=4,width=30,textvariable=self.c_nam
e).grid(row=0,column=1,padx=8)
contact_name=Label(details,text="Contact No.",font=("Arial
Black",14),bg="#A569BD",fg="white").grid(row=0,column=2,padx=10)
contact_entry=Entry(details,borderwidth=4,width=30,textvariable=self.ph
one).grid(row=0,column=3,padx=8)
bill_name=Label(details,text="Bill.No.",font=("Arial
Black",14),bg="#A569BD",fg="white").grid(row=0,column=4,padx=10)
bill_entry=Entry(details,borderwidth=4,width=30,textvariable=self.bill_
no).grid(row=0,column=5,padx=8)
#=======================================Medicine label
frame=================================================================
medicine=LabelFrame(self.root,text="Medicine",font=("Arial
Black",12),bg="#E5B4F3",fg="#6C3483",relief=GROOVE,bd=10)
medicine.place(x=5,y=180,height=380,width=325)
item1=Label(medicine,text="Paracetamol(650mg)",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=0,column=0,pady=11)
item1_entry=Entry(medicine,borderwidth=2,width=15,textvariable=self.par
a).grid(row=0,column=1,padx=10)
item2=Label(medicine,text="Pan-D(1 strip)",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=1,column=0,pady=11)
item2_entry=Entry(medicine,borderwidth=2,width=15,textvariable=self.pan
_d).grid(row=1,column=1,padx=10)
item3=Label(medicine,text="Saridon(1 strip)",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=2,column=0,pady=11)
item3_entry=Entry(medicine,borderwidth=2,width=15,textvariable=self.sar
idon).grid(row=2,column=1,padx=10)
item4=Label(medicine,text="Thyrox(50 mg)",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=3,column=0,pady=11)
item4_entry=Entry(medicine,borderwidth=2,width=15,textvariable=self.thy
rox).grid(row=3,column=1,padx=10)
item5=Label(medicine,text="Ambizyme",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=4,column=0,pady=11)
item5_entry=Entry(medicine,borderwidth=2,width=15,textvariable=self.amb
izyme).grid(row=4,column=1,padx=10)
item6=Label(medicine,text="Ecosprin(75 mg)",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=5,column=0,pady=11)
item6_entry=Entry(medicine,borderwidth=2,width=15,textvariable=self.eco
sprin).grid(row=5,column=1,padx=10)
item7=Label(medicine,text="Broncophil(100 mg)",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=6,column=0,pady=11)
item7_entry=Entry(medicine,borderwidth=2,width=15,textvariable=self.bro
ncophil).grid(row=6,column=1,padx=10)
#===================================HEALTH=============================
========================================================
health=LabelFrame(self.root,text="Health",font=("Arial
Black",12),relief=GROOVE,bd=10,bg="#E5B4F3",fg="#6C3483")
health.place(x=340,y=180,height=380,width=325)
item8=Label(health,text="Multi-Vitamin",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=0,column=0,pady=11)
item8_entry=Entry(health,borderwidth=2,width=15,textvariable=self.multi
vitamin).grid(row=0,column=1,padx=10)
item9=Label(health,text="Protein-X",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=1,column=0,pady=11)
item9_entry=Entry(health,borderwidth=2,width=15,textvariable=self.prote
in).grid(row=1,column=1,padx=10)
item10=Label(health,text="Ors",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=2,column=0,pady=11)
item10_entry=Entry(health,borderwidth=2,width=15,textvariable=self.ors)
.grid(row=2,column=1,padx=10)
item11=Label(health,text="Himalaya-Powder(Baby)",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=3,column=0,pady=11)
item11_entry=Entry(health,borderwidth=2,width=15,textvariable=self.baby
).grid(row=3,column=1,padx=10)
item12=Label(health,text="Endura-Mass",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=4,column=0,pady=11)
item12_entry=Entry(health,borderwidth=2,width=15,textvariable=self.endu
ra).grid(row=4,column=1,padx=10)
item13=Label(health,text="Betadine-Gargle",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=5,column=0,pady=11)
item13_entry=Entry(health,borderwidth=2,width=15,textvariable=self.beta
_g).grid(row=5,column=1,padx=10)
item14=Label(health,text="Vaseline",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=6,column=0,pady=11)
item14_entry=Entry(health,borderwidth=2,width=15,textvariable=self.vase
line).grid(row=6,column=1,padx=10)
#========================================HYGIENE=======================
========================================================
hygiene=LabelFrame(self.root,text="Hygiene",font=("Arial
Black",12),relief=GROOVE,bd=10,bg="#E5B4F3",fg="#6C3483")
hygiene.place(x=677,y=180,height=380,width=325)
item15=Label(hygiene,text="Baby-Diapers",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=0,column=0,pady=11)
item15_entry=Entry(hygiene,borderwidth=2,width=15,textvariable=self.dia
per).grid(row=0,column=1,padx=10)
item16=Label(hygiene,text="Sanitary-Pad",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=1,column=0,pady=11)
item16_entry=Entry(hygiene,borderwidth=2,width=15,textvariable=self.pad
).grid(row=1,column=1,padx=10)
item17=Label(hygiene,text="Betadine",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=2,column=0,pady=11)
item17_entry=Entry(hygiene,borderwidth=2,width=15,textvariable=self.bet
a_d).grid(row=2,column=1,padx=10)
item18=Label(hygiene,text="Band-Aid",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=3,column=0,pady=11)
item18_entry=Entry(hygiene,borderwidth=2,width=15,textvariable=self.ban
daid).grid(row=3,column=1,padx=10)
item19=Label(hygiene,text="Cotton",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=4,column=0,pady=11)
item19_entry=Entry(hygiene,borderwidth=2,width=15,textvariable=self.cot
ton).grid(row=4,column=1,padx=10)
item20=Label(hygiene,text="Sanitizer",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=5,column=0,pady=11)
item20_entry=Entry(hygiene,borderwidth=2,width=15,textvariable=self.san
itizer).grid(row=5,column=1,padx=10)
item21=Label(hygiene,text="Baby-Wipes",font=("Arial
Black",11),bg="#E5B4F3",fg="#6C3483").grid(row=6,column=0,pady=11)
item21_entry=Entry(hygiene,borderwidth=2,width=15,textvariable=self.wip
es).grid(row=6,column=1,padx=10)
1. Library Imports
tkinter: Used for creating the graphical user interface (GUI).
random: Generates a random bill number.
mysql.connector: Used to connect to a MySQL database.
messagebox: Displays messages like error notifications or success alerts.
2. Database Connection
python
Copy code
conn = sql.connect(host="localhost", user="root", passwd="password123",
database="medic")
cur = conn.cursor()
Table Creation: The CREATE TABLE IF NOT EXISTS ensures that each table (items,
items_2, items_3) is only created if it doesn't already exist.
Inserting Data: The executemany() function is used to insert multiple records for
each table in one go.
Committing: The conn.commit() function saves the changes to the database.
Closing the Cursor: cursor.close() is used to close the cursor.
3. Class Initialization
python
Copy code
class Bill_App:
def __init__(self, root):
self.root = root
...
python
Copy code
self.para = IntVar()
self.pan_d = IntVar()
...
IntVar and StringVar: Special Tkinter variables that store data from input fields.
Separate variables are declared for each item, total amounts, customer name, phone
number, and bill number.
5. Customer Details Section
python
Copy code
details = LabelFrame(self.root, text="Customer Details", ...)
cust_name = Label(details, text="Customer Name", ...)
cust_entry = Entry(details, ...)
...
6. Item Categories
1. Medicines
2. Health Products
3. Hygiene Products
Example:
python
Copy code
medicine = LabelFrame(self.root, text="Medicine", ...)
item1 = Label(medicine, text="Paracetamol(650mg)", ...)
item1_entry = Entry(medicine, textvariable=self.para).grid(...)
python
Copy code
x = random.randint(1000, 9999)
self.bill_no.set(str(x))
A random 4-digit bill number is generated and assigned to the bill_no variable.
How It Works
#=====================================================Billarea=========
=====================================================================
billarea=Frame(self.root,bd=10,relief=GROOVE,bg="#E5B4F3")
billarea.place(x=1010,y=188,width=330,height=372)
bill_title=Label(billarea,text="Bill Area",font=("Arial
Black",17),bd=7,relief=GROOVE,bg="#E5B4F3",fg="#6C3483").pack(fill=X)
scrol_y=Scrollbar(billarea,orient=VERTICAL)
self.txtarea=Text(billarea,yscrollcommand=scrol_y.set)
scrol_y.pack(side=RIGHT,fill=Y)
scrol_y.config(command=self.txtarea.yview)
self.txtarea.pack(fill=BOTH,expand=1)
This section sets up the bill area where the generated bill will be displayed. It uses a Frame
widget to contain other elements:
The frame has a styled border (bd=10, relief=GROOVE) and a background color
(bg="#E5B4F3").
Positioned on the right side of the window (place(x=1010, y=188, width=330,
height=372)).
A Label widget titled "Bill Area" is added to the top of the frame.
The title uses a bold font (font=("Arial Black", 17)) and is centered across the
frame (pack(fill=X)).
3. Scrollbar for Text Area
A vertical scrollbar (Scrollbar) is created for navigation in case the bill content
exceeds the visible area.
The scrollbar is linked to the text area (command=self.txtarea.yview), enabling
synchronized scrolling.
4. Text Area
A Text widget is used for displaying the bill content. This multiline text area allows
for detailed bill information, such as:
o Customer name and contact details.
o Purchased items with quantities and prices.
o Total amount and bill number.
The text area is linked to the scrollbar (yscrollcommand=scrol_y.set) for smooth
navigation.
It is configured to dynamically fill the frame space (fill=BOTH, expand=1).
This section is crucial for displaying the bill to the user in a readable and scrollable
format.
It acts as the main output area for the billing software.
#=====================================================StockArea==
=================================================================
===========
def stock(self):
stock=Frame(self.root,bd=10,relief=GROOVE,bg="#E5B4F3")
stock.place(x=1350,y=188,width=330,height=372)
stock_title=Label(stock,text="Current
Stock",font=("Arial
Black",17),bd=7,relief=GROOVE,bg="#E5B4F3",fg="#6C3483").pack(fil
l=X)
scrol_y=Scrollbar(stock,orient=VERTICAL)
self.txtarea1=Text(stock,yscrollcommand=scrol_y.set)
scrol_y.pack(side=RIGHT,fill=Y)
scrol_y.config(command=self.txtarea.yview)
self.txtarea1.pack(fill=BOTH,expand=1)
self.txtarea1.insert(END,"\tMEDICINE CATAGORY\n")
self.txtarea1.insert(END,"serial\tname\t\tquantity\
n")
cur.execute("select * from medicine\n")
data=cur.fetchall()
for row in data:
self.txtarea1.insert(END,f"{row[0]}\t{row[1]}\t\
t{row[3]}\n")
self.txtarea1.insert(END,"\n\tHEALTH CATAGORY\n")
self.txtarea1.insert(END,"serial\tname\t\tquantity\
n")
cur.execute("select * from health\n")
data=cur.fetchall()
for row in data:
self.txtarea1.insert(END,f"{row[0]}\t{row[1]}\t\
t{row[3]}\n")
self.txtarea1.insert(END,"\n\tHYGIENE CATAGORY\n")
self.txtarea1.insert(END,"serial\tname\t\tquantity\
n")
cur.execute("select * from hygiene\n")
data=cur.fetchall()
for row in data:
self.txtarea1.insert(END,f"{row[0]}\t{row[1]}\t\
t{row[3]}\n")
A Label widget is used to display the title "Current Stock" at the top of the frame.
The label's styling includes:
o Bold font (font=("Arial Black",17)).
o Colors for background and text (bg="#E5B4F3", fg="#6C3483").
A Scrollbar widget is added for navigation in case the stock data exceeds the visible
area.
The Text widget (self.txtarea1) is used to display stock data, such as:
o Categories (Medicine, Health, Hygiene).
o Item details (Serial number, Name, Quantity).
The scrollbar is linked to the text area for seamless scrolling
(yscrollcommand=scrol_y.set).
SQL queries fetch data from tables (medicine, health, hygiene) in the database:
o cur.execute("select * from ...") retrieves all rows from each table.
o cur.fetchall() gets all results of the query.
The data is formatted and inserted into the text area (self.txtarea1.insert):
o Column headers (e.g., "serial, name, quantity") are displayed first.
o A loop (for row in data) appends each row's details.
This section is responsible for displaying the current stock inventory to the user.
It helps in:
o Monitoring available stock for each category.
o Ensuring sufficient supply by tracking quantities.
#=====================================================StockArea=
=================================================================
============
def record(self):
record=Frame(self.root,bd=10,relief=GROOVE,bg="#E5B4F3")
record.place(x=5,y=700,width=600,height=250)
record_title=Label(record,text="Customer
Details",font=("Arial
Black",17),bd=7,relief=GROOVE,bg="#E5B4F3",fg="#6C3483").pack(fil
l=X)
scrol_y=Scrollbar(record,orient=VERTICAL)
self.txtarea2=Text(record,yscrollcommand=scrol_y.set)
scrol_y.pack(side=RIGHT,fill=Y)
scrol_y.config(command=self.txtarea.yview)
self.txtarea2.pack(fill=BOTH,expand=1)
self.txtarea2.insert(END,"\t\t\t2024-25\n")
cur.execute("select date(sysdate())")
a=cur.fetchall()
if a: # Ensure data is returned
b = a[0][0]
cur.execute("INSERT INTO record VALUES (%s, %s, %s,
%s, %s)",(self.bill_no.get(), self.c_name.get(
), self.phone.get(), self.total_all_bill, str(b)))
conn.commit()
cur.execute("select * from record\n")
data = cur.fetchall()
self.txtarea2.insert(END,"\t\t\tCUSTOMER RECORDS\n")
self.txtarea2.insert(END,"\nBill no\tName\t\t\tPhone\
t\tTotal\tDate\n")
for row in data:
self.txtarea2.insert(END, f"{row[0]}\t{row[1]}\t\
t\t{row[2]}\t\t{row[3]}\t{row[4]}\n")
cur.execute("select count(purchase_value) as
total_customers,sum(purchase_value) as total_sale from record
where purchase_date = date(sysdate())")
data = cur.fetchall()
self.txtarea2.insert(END,f"today {data[0][0]}
customers visited\n")
self.txtarea2.insert(END,f"today's total puchase
value is: {data[0][1]}")
sql
Copy code
select date(sysdate())
If the query returns a result, the date is stored and used in further processing.
A new record is inserted into the record database table with the following values:
o Bill number (self.bill_no.get()).
o Customer name (self.c_name.get()).
o Phone number (self.phone.get()).
o Total bill value (self.total_all_bill).
o Purchase date (fetched from the database).
The changes are committed to the database to save the new record.
sql
Copy code
select * from record
The data is formatted and displayed in the text area with headers (e.g., "Bill no,
Name, Phone, Total, Date").
7. Daily Summary
sql
Copy code
select count(purchase_value) as total_customers, sum(purchase_value)
as total_sale
from record
where purchase_date = date(sysdate())
#=================================================billing
menu===================================================================
======================
billing_menu=LabelFrame(self.root,text="Billing
Summary",font=("Arial
Black",12),relief=GROOVE,bd=10,bg="#A569BD",fg="white")
billing_menu.place(x=0,y=560,relwidth=2,height=137)
total_medicine=Label(billing_menu,text="Total Medicine
Price",font=("Arial
Black",11),bg="#A569BD",fg="white").grid(row=0,column=0)
total_medicine_entry=Entry(billing_menu,width=30,borderwidth=2,textvari
able=self.total_med).grid(row=0,column=1,padx=10,pady=7)
total_health=Label(billing_menu,text="Total Health
Price",font=("Arial
Black",11),bg="#A569BD",fg="white").grid(row=1,column=0)
total_health_entry=Entry(billing_menu,width=30,borderwidth=2,textvariab
le=self.total_hel).grid(row=1,column=1,padx=10,pady=7)
total_hygiene_entry=Entry(billing_menu,width=30,borderwidth=2,textvaria
ble=self.total_hyg).grid(row=2,column=1,padx=10,pady=7)
tax_medicine=Label(billing_menu,text="Medicine
Tax",font=("Arial
Black",11),bg="#A569BD",fg="white").grid(row=0,column=2)
tax_medicine_entry=Entry(billing_menu,width=30,borderwidth=2,textvariab
le=self.a).grid(row=0,column=3,padx=10,pady=7)
tax_health=Label(billing_menu,text="Health Tax",font=("Arial
Black",11),bg="#A569BD",fg="white").grid(row=1,column=2)
tax_health_entry=Entry(billing_menu,width=30,borderwidth=2,textvariable
=self.b).grid(row=1,column=3,padx=10,pady=7)
tax_hygiene=Label(billing_menu,text="Hygine Tax",font=("Arial
Black",11),bg="#A569BD",fg="white").grid(row=2,column=2)
tax_hygiene_entry=Entry(billing_menu,width=30,borderwidth=2,textvariabl
e=self.c).grid(row=2,column=3,padx=10,pady=7)
button_frame=Frame(billing_menu,bd=7,relief=GROOVE,bg="#6C3483")
button_frame.place(x=830,width=780,height=95)
button_total=Button(button_frame,text="Total Bill",font=("Arial
Black",15),
pady=10,bg="#E5B4F3",fg="#6C3483",command=lambda:total(self)
).grid(row=0,column=0,padx=12)
button_clear=Button(button_frame,text="Clear
Field",font=("Arial Black",15)
,pady=10,bg="#E5B4F3",fg="#6C3483",command=lambda:clear(self)
).grid(row=0,column=1,padx=10,pady=6)
button_exit=Button(button_frame,text="Exit",font=("Arial
Black",15)
,pady=10,bg="#E5B4F3",fg="#6C3483",width=8,command=lambda:exit1(self)
).grid(row=0,column=2,padx=10,pady=6)
intro(self)
button_stock=Button(button_frame,text="Current
Stock",font=("Arial Black",15),
pady=10,bg="#E5B4F3",fg="#6C3483",command=lambda:stock(self)
).grid(row=0,column=3,padx=12)
button_record=Button(button_frame,text="Record",font=("Arial
Black",15),
pady=10,bg="#E5B4F3",fg="#6C3483",command=lambda:record(self)
).grid(row=0,column=4,padx=12)
A LabelFrame is created to encapsulate all the widgets for the Billing Summary
section.
o It includes labels, entry fields, and action buttons.
o Positioned near the bottom of the application window (place(x=0, y=560,
relwidth=2, height=137)).
o Styled with a purple background and white text for a clean and vibrant look.
2. Displaying Total Prices
3. Displaying Taxes
A separate Frame (button_frame) organizes the buttons at the bottom of the billing
summary.
o Positioned within the billing menu frame (place(x=830, width=780,
height=95)).
Buttons include:
o Total Bill: Triggers the total(self) function to calculate the total bill.
o Clear Field: Calls the clear(self) function to reset all fields in the section.
o Exit: Executes the exit1(self) function to close the application.
o Current Stock: Launches the stock(self) function to display current stock
details.
o Record: Opens the record(self) function to view customer records.
5. Overall Functionality
1. Customer Validation
The function first checks if the customer's name (self.c_name) or phone number
(self.phone) is empty.
o If either is missing, an error message box (messagebox.showerror) prompts
the user to fill in the details.
The code updates the quantities of items in the database based on the customer's
purchase.
o Executes multiple SQL UPDATE statements to reduce stock (qty) in the
medicine, health, and hygiene tables.
o Each item is referenced by its unique item_no or intemno.
o The quantity to be deducted is taken from the respective fields (e.g.,
self.para.get() for Paracetamol).
Changes are committed to the database using conn.commit().
Medicine Prices:
o Individual prices for medicines are calculated by multiplying quantities
(get() values) with their respective rates (e.g., self.para.get() * 120 for
Paracetamol at ₹120 per unit).
o Total medicine price is computed by summing these individual prices.
Medicine Tax:
o Calculated as 5% of the total medicine price and rounded to 3 decimal places.
o Stored in self.a and displayed as a string with "Rs" appended.
def intro(self):
self.txtarea.delete(1.0,END)
self.txtarea.insert(END,"\tWELCOME TO MARVEL PHARMACY\n\tPhone-
No.739275410")
self.txtarea.insert(END,f"\n\nBill no. : {self.bill_no.get()}")
self.txtarea.insert(END,f"\nCustomer Name : {self.c_name.get()}")
self.txtarea.insert(END,f"\nPhone No. : {self.phone.get()}")
self.txtarea.insert(END,"\n====================================\n")
self.txtarea.insert(END,"\nProduct\t\tQty\tPrice\n")
self.txtarea.insert(END,"\n====================================\n")
The function begins by clearing the existing content in the self.txtarea text
widget using:
o self.txtarea.delete(1.0, END) which deletes all text from the first line to
the end.
A welcome message for "Marvel Pharmacy" is inserted into the text area.
o Includes the pharmacy name and contact number: "WELCOME TO MARVEL
PHARMACY\nPhone-No.739275410".
5. Final Layout
def billarea(self):
intro(self)
if self.para.get()!=0:
self.txtarea.insert(END,f"Paracetamol(650 mg)\t\t
{self.para.get()}\t{self.pa}\n")
if self.pan_d.get()!=0:
self.txtarea.insert(END,f"Pan-D(1 strip)\t\t
{self.pan_d.get()}\t{self.pan}\n")
if self.saridon.get()!=0:
self.txtarea.insert(END,f"Saridon(1 strip\t\t
{self.saridon.get()}\t{self.sa}\n")
if self.thyrox.get()!=0:
self.txtarea.insert(END,f"Thyrox(50mg)\t\t {self.thyrox.get()}\
t{self.th}\n")
if self.ambizyme.get()!=0:
self.txtarea.insert(END,f"Ambizyme\t\t {self.ambizyme.get()}\
t{self.am}\n")
if self.ecosprin.get()!=0:
self.txtarea.insert(END,f"Ecosprin(75mg)\t\t
{self.ecosprin.get()}\t{self.eco}\n")
if self.broncophil.get()!=0:
self.txtarea.insert(END,f"Broncophil(100mg)\t\t
{self.broncophil.get()}\t{self.bro}\n")
if self.multivitamin.get()!=0:
self.txtarea.insert(END,f"Multivitamin\t\t
{self.multivitamin.get()}\t{self.mu}\n")
if self.protein.get()!=0:
self.txtarea.insert(END,f"Protein-X\t\t {self.protein.get()}\
t{self.pro}\n")
if self.ors.get()!=0:
self.txtarea.insert(END,f"ORS\t\t {self.ors.get()}\t{self.o}\
n")
if self.baby.get()!=0:
self.txtarea.insert(END,f"Himalaya-Powder(baby)\t\t
{self.baby.get()}\t{self.bab}\n")
if self.endura.get()!=0:
self.txtarea.insert(END,f"Endura-Mass\t\t {self.endura.get()}\
t{self.en}\n")
if self.beta_g.get()!=0:
self.txtarea.insert(END,f"Betadine-Gargle\t\t
{self.beta_g.get()}\t{self.be}\n")
if self.vaseline.get()!=0:
self.txtarea.insert(END,f"Vaseline\t\t {self.vaseline.get()}\
t{self.va}\n")
if self.diaper.get()!=0:
self.txtarea.insert(END,f"Baby-Diaper\t\t {self.diaper.get()}\
t{self.di}\n")
if self.pad.get()!=0:
self.txtarea.insert(END,f"Sanitary-Pad\t\t {self.pad.get()}\
t{self.p}\n")
if self.beta_d.get()!=0:
self.txtarea.insert(END,f"Betadine\t\t {self.beta_d.get()}\
t{self.bet}\n")
if self.bandaid.get()!=0:
self.txtarea.insert(END,f"Band-Aid\t\t {self.bandaid.get()}\
t{self.ban}\n")
if self.cotton.get()!=0:
self.txtarea.insert(END,f"Cotton\t\t {self.cotton.get()}\
t{self.co}\n")
if self.sanitizer.get()!=0:
self.txtarea.insert(END,f"Sanitizer\t\t {self.sanitizer.get()}\
t{self.san}\n")
if self.wipes.get()!=0:
self.txtarea.insert(END,f"Baby-Wipes\t\t {self.wipes.get()}\
t{self.w}\n")
self.txtarea.insert(END,f"------------------------------------\n")
if self.a.get()!="0.0 Rs":
self.txtarea.insert(END,f"Total Medicine Tax : {self.a.get()}\
n")
if self.b.get()!="0.0 Rs":
self.txtarea.insert(END,f"Total Health Tax : {self.b.get()}\n")
if self.c.get()!="0.0 Rs":
self.txtarea.insert(END,f"Total Hygiene Tax : {self.c.get()}\
n")
self.txtarea.insert(END,f"Total Bill Amount : {self.total_all_bil}\
n")
self.txtarea.insert(END,f"------------------------------------\n")
The function first calls intro(self) to initialize the bill with the customer's details
and the table header.
The function then checks each item (e.g., para, pan_d, saridon, etc.) to see if its
quantity is greater than 0. If it is, it inserts the product details (name, quantity, and
price) into the txtarea widget.
o Format: "Product Name\t\t Quantity\t Price"
o For example:
If para.get() is not zero, the line "Paracetamol(650 mg)\t\t
{self.para.get()}\t{self.pa}" is inserted.
The following product categories are checked and inserted in the order of priority:
o Medicines: Paracetamol, Pan-D, Saridon, Thyrox, Ambizyme, Ecosprin,
Broncophil.
o Health: Multivitamin, Protein-X, ORS, Himalaya Powder, Endura Mass,
Betadine Gargle, Vaseline.
o Hygiene: Diaper, Sanitary Pad, Betadine, Band-Aid, Cotton, Sanitizer, Baby
Wipes.
After listing the products, the function checks if there is any tax for each category
(medicine, health, hygiene).
o If a tax is applied (i.e., not zero), the tax for that category is displayed.
o The format used is "Total [Category] Tax : [tax amount]".
The total bill amount is inserted at the end with the format:
o "Total Bill Amount : [total amount]".
5. Divider Line
python
Copy code
self.txtarea.insert(END, f"Paracetamol(650 mg)\t\t
{str(self.para.get()).rjust(2)}\t {str(self.pa).rjust(3)}\n")
3. Error Handling
o Consider adding error handling for cases where database retrieval fails or there
is an issue with product data.
4. Improved Tax Formatting
o The tax information could be shown in a more structured format, such as by
calculating a subtotal before taxes.
Final Note
The function is useful for displaying a detailed, formatted bill in a text area, listing products,
quantities, prices, taxes, and the total bill amount. The structure is clear, and it's easy to
follow when reading the output on the GUI.
def clear(self):
# Clear the text area
self.txtarea.delete(1.0, END)
self.txtarea.delete(1.0, END) is used to clear the entire text area from the
beginning (index 1.0) to the end (END).
The next set of lines resets the values of all product quantities (e.g.,
self.para.set(0), self.pan_d.set(0)), setting them back to zero for each
product.
This ensures that the quantity for each product is cleared and ready to be updated for
the next customer.
root=Tk()
obj=Bill_App(root)
root.mainloop()
Explanation:
self.root.destroy(): This line calls the destroy method on the Tk instance, which
closes the main window and effectively terminates the application.
root=Tk(): This line initializes the Tkinter root window, which is the main window
for the application.
obj=Bill_App(root): This creates an instance of the Bill_App class and passes the
root window to it. This ensures that your Bill_App class has access to the Tkinter
root window.
root.mainloop(): This starts the Tkinter event loop, which keeps the application
running and waits for user interactions (e.g., button clicks).
OUTPUT
Conclusion:
Key Features:
1. Product Management:
o Allows entry of quantities for various products such as medicines, health products,
and hygiene items.
o Tracks stock levels and automatically updates quantities after each sale.
3. Stock Management:
o Updates inventory upon product sale by reducing the quantity of sold items in the
database.
o Displays real-time stock levels to ensure that pharmacy staff can monitor inventory.
4. User-Friendly Interface:
o The GUI is intuitive and simple to navigate, designed with Tkinter for ease of use.
o Provides a clear and organized billing summary for customers, with options to print
or exit the bill.
5. Error Handling:
o The system includes error checks to ensure customer details are entered before
proceeding with the bill.
o It prompts for missing details and prevents accidental actions like incomplete billing.
Benefits:
Efficiency in Operations:
The automated billing system significantly reduces human errors and speeds up the
transaction process, making it easier for pharmacy staff to focus on customer service.
Accurate Tax Calculations:
By calculating taxes based on product categories (medicines, health, and hygiene), the
system ensures compliance with local tax regulations and provides transparency in
billing.
Stock Tracking:
The application helps in tracking inventory levels in real-time, which reduces the
chances of over-selling products and allows for timely reordering.
Clear Billing Summary:
The detailed and clear billing summary ensures that customers are aware of the
products they are purchasing, along with the total cost and taxes applied.
Conclusion:
This "Marvel Pharmacy Billing System" serves as an efficient, user-friendly tool for
automating the sales and stock management processes in a pharmacy setting. The application
helps streamline operations, reduce human error, and improve customer satisfaction by
providing quick and accurate billing information. By integrating basic inventory and tax
management, this project offers a solid foundation for a pharmacy management system that
can be further enhanced with additional features such as invoice generation, multi-user
support, and enhanced database management.
Future Enhancements:
Invoice Generation: Integrating a feature that allows for PDF or print invoice generation.
Product Search and Sorting: Implementing a search feature to allow easy product look-up by
name or category.
Multi-User Support: Enabling multiple user access for different roles (e.g., cashiers,
managers).
Data Analytics: Incorporating data analytics to generate reports on sales trends and stock
performance.
THANK YOU