0% found this document useful (0 votes)
15 views3 pages

python invoice managment

This document describes a Python Invoice Management Application using Tkinter for the GUI and SQLite for data storage. The application allows users to add, view, and search invoices by customer name or ID, featuring a simple interface and essential invoice details. It includes step-by-step code to set up the application and mentions that no external packages are required.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

python invoice managment

This document describes a Python Invoice Management Application using Tkinter for the GUI and SQLite for data storage. The application allows users to add, view, and search invoices by customer name or ID, featuring a simple interface and essential invoice details. It includes step-by-step code to set up the application and mentions that no external packages are required.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Here’s a simple **Python Invoice Management Application** using **Tkinter for GUI**

and **SQLite for data storage**. This will allow you to:

* Add new invoices


* View existing invoices
* Search invoices by customer name or ID

---

### ✅ Features

* GUI with Tkinter


* SQLite3 for database storage
* Invoice ID, Customer Name, Item, Quantity, Price, Total

---

### 🧾 Step-by-step Code

Save this as `invoice_app.py` and run it:

```python
import sqlite3
from tkinter import *
from tkinter import messagebox

# Initialize DB
conn = sqlite3.connect("invoices.db")
cur = conn.cursor()
cur.execute('''CREATE TABLE IF NOT EXISTS invoice (
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer TEXT,
item TEXT,
quantity INTEGER,
price REAL,
total REAL
)''')
conn.commit()

# Functions
def add_invoice():
if not (customer_entry.get() and item_entry.get() and quantity_entry.get() and
price_entry.get()):
messagebox.showwarning("Input Error", "All fields must be filled")
return

try:
quantity = int(quantity_entry.get())
price = float(price_entry.get())
total = quantity * price
cur.execute("INSERT INTO invoice (customer, item, quantity, price, total)
VALUES (?, ?, ?, ?, ?)",
(customer_entry.get(), item_entry.get(), quantity, price,
total))
conn.commit()
messagebox.showinfo("Success", "Invoice Added")
clear_fields()
view_invoices()
except ValueError:
messagebox.showerror("Input Error", "Quantity must be integer and price
must be numeric")

def view_invoices():
listbox.delete(0, END)
for row in cur.execute("SELECT * FROM invoice"):
listbox.insert(END, row)

def search_invoice():
query = search_entry.get()
listbox.delete(0, END)
for row in cur.execute("SELECT * FROM invoice WHERE customer LIKE ? OR id
LIKE ?",
(f'%{query}%', f'%{query}%')):
listbox.insert(END, row)

def clear_fields():
customer_entry.delete(0, END)
item_entry.delete(0, END)
quantity_entry.delete(0, END)
price_entry.delete(0, END)

# GUI Setup
root = Tk()
root.title("Invoice Management System")
root.geometry("600x500")

# Labels and Entries


Label(root, text="Customer Name").grid(row=0, column=0, pady=5)
customer_entry = Entry(root)
customer_entry.grid(row=0, column=1)

Label(root, text="Item").grid(row=1, column=0, pady=5)


item_entry = Entry(root)
item_entry.grid(row=1, column=1)

Label(root, text="Quantity").grid(row=2, column=0, pady=5)


quantity_entry = Entry(root)
quantity_entry.grid(row=2, column=1)

Label(root, text="Price").grid(row=3, column=0, pady=5)


price_entry = Entry(root)
price_entry.grid(row=3, column=1)

# Buttons
Button(root, text="Add Invoice", command=add_invoice).grid(row=4, column=0,
columnspan=2, pady=10)
Button(root, text="View Invoices", command=view_invoices).grid(row=5, column=0,
columnspan=2, pady=5)

# Search
Label(root, text="Search by Customer/ID").grid(row=6, column=0, pady=5)
search_entry = Entry(root)
search_entry.grid(row=6, column=1)
Button(root, text="Search", command=search_invoice).grid(row=7, column=0,
columnspan=2)

# Listbox
listbox = Listbox(root, width=80)
listbox.grid(row=8, column=0, columnspan=2, pady=10)

# Run App
view_invoices()
root.mainloop()
```

---

### 📦 Requirements

No external packages needed; works with:

* Python 3.x
* Built-in `sqlite3` and `tkinter`

---

Would you like features like:

* PDF invoice generation?


* Export to Excel?
* User login system?

Let me know and I’ll help expand it!

You might also like