A comprehensive, production-ready Set Invoice built with Django that allows businesses to manage customers, items, invoices, and payments efficiently. The system features a custom admin interface, role-based access control, and a modern, responsive UI built with TailwindCSS.
- USER_GUIDE.md - Complete setup and usage guide for end users
- SECURITY.md - Security best practices and deployment checklist
- ADMIN_SETUP.md - Admin configuration guide
This system provides a complete solution for invoice management with:
- Secure authentication and authorization
- Customer relationship management
- Inventory tracking with low stock alerts
- Professional invoice generation with PDF export
- Payment tracking and reconciliation
- Comprehensive dashboard with business metrics
- Custom user model with email-based authentication
- Role-Based Access Control (RBAC): Admin, Manager, Staff, Viewer
- Secure password hashing (Django's PBKDF2)
- Session management with CSRF protection
- Password reset functionality
- Security headers (X-Frame-Options, XSS protection)
- Overview of total invoices, pending payments, customers
- Revenue statistics (total and monthly)
- Recent activities and low stock alerts
- Quick action buttons for common tasks
- Add, edit, delete, and list customers
- Search and filter customers
- View customer invoice history
- Customer status management (active/inactive)
- Manage item categories
- Add, edit, delete items
- Track total quantity and available quantity
- Low stock alerts (threshold: 10 units)
- Automatic quantity reduction when invoices are finalized
- Search and filter items
- Create new invoices with multiple items
- Auto-generate invoice numbers (format: INV-2025-0001)
- Add items dynamically with JavaScript
- Auto-calculate subtotal, tax, discount, and total
- Save as draft or finalize
- Edit draft invoices only
- Mark as paid/cancelled
- Generate PDF invoices
- Invoice status tracking (draft, pending, paid, cancelled)
- Validation: due date must be after issue date
- Record payments against invoices
- Multiple payment methods (cash, card, bank transfer, online)
- Partial payment support
- Payment history per invoice
- Transaction ID tracking
- Automatic invoice status update on payment
- List all users
- Create/edit/delete users
- Assign roles to users
- Activate/deactivate users
- Backend: Django 5.2.8
- Python: 3.10+
- Database: SQLite (Development), PostgreSQL ready (Production)
- Frontend: Jinja2 Templates, TailwindCSS
- PDF Generation: xhtml2pdf
- Package Management: pip, npm
📖 For detailed setup instructions, see USER_GUIDE.md
- Python 3.10 or higher
- Node.js (for TailwindCSS)
- pip and virtualenv
# Clone repository
git clone <repository-url>
cd invoice_management_system
### Step 2: Create Virtual Environment
```bash
python -m venv venv
# Windows
venv\Scripts\activate
# Linux/Mac
source venv/bin/activatepip install -r requirements.txtnpm install -D tailwindcss
npx tailwindcss initcp .env.example .env
# Edit .env with your settingsRequired environment variables:
SECRET_KEY: Django secret key (generate a secure random string)DEBUG: Set toFalsein productionALLOWED_HOSTS: Comma-separated list of allowed hostsDATABASE_NAME: Database file name (default: db.sqlite3)- Email settings (for password reset functionality)
python manage.py makemigrations
python manage.py migratepython manage.py createsuperuser
⚠️ Security Note: Never use default credentials in production. See SECURITY.md for best practices.
npx tailwindcss -i ./static/css/input.css -o ./static/css/output.css --watchFor production, build once:
npx tailwindcss -i ./static/css/input.css -o ./static/css/output.css --minifypython manage.py runserverVisit: http://127.0.0.1:8000
- Login: Use your credentials to access the system
- Setup Roles: As admin, create user roles (Admin, Manager, Staff, Viewer)
- Add Categories: Navigate to Inventory → Categories to create item categories
- Add Items: Go to Inventory → Items to add products with quantities
- Add Customers: Navigate to Customers → Add Customer
- Create Invoice:
- Go to Invoices → Create Invoice
- Select customer and add items
- System auto-calculates totals
- Save as draft or finalize
- Record Payment:
- Go to Payments → Record Payment
- Select invoice and enter payment details
- Invoice status updates automatically
Creating an Invoice:
- Select a customer
- Add items with quantities (validated against available stock)
- System calculates subtotal, tax, and total
- Add discount if applicable
- Save as draft (editable) or finalize (reduces inventory)
Recording Payment:
- Select the invoice
- Enter payment amount (supports partial payments)
- Choose payment method
- Add transaction ID (optional)
- Invoice status updates to "paid" if fully paid
Managing Inventory:
- Available quantity is automatically reduced when invoice is finalized
- Low stock alerts appear on dashboard when available_qty < 10
- Edit items to update quantities
invoice_management_system/
├── manage.py
├── requirements.txt
├── README.md
├── .env.example
├── .gitignore
├── config/
│ ├── settings.py # Django settings
│ ├── urls.py # Root URL configuration
│ ├── wsgi.py
│ └── asgi.py
├── apps/
│ ├── accounts/ # User authentication and management
│ ├── customers/ # Customer management
│ ├── inventory/ # Item and category management
│ ├── invoices/ # Invoice processing and PDF generation
│ ├── payments/ # Payment tracking
│ └── core/ # Dashboard and common views
├── templates/ # Jinja2 templates
│ ├── base.html
│ ├── accounts/
│ ├── customers/
│ ├── inventory/
│ ├── invoices/
│ ├── payments/
│ └── core/
├── static/
│ ├── css/ # TailwindCSS compiled files
│ ├── js/ # JavaScript files
│ └── images/ # Static images
└── media/ # User-uploaded files (PDFs, etc.)
See .env.example for all available configuration options.
-
Install PostgreSQL and psycopg2:
pip install psycopg2-binary
-
Update
config/settings.py:DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'your_databaes_name', 'USER': 'your_database_username', 'PASSWORD': 'your_database_password', 'HOST': 'localhost', 'PORT': '5432', } }
-
Run migrations:
python manage.py migrate
For password reset and email notifications, configure email settings in .env:
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USE_TLS=True
EMAIL_HOST_USER=johndoe@gmail.com
EMAIL_HOST_PASSWORD=johndoe_password- Password Security: Django's PBKDF2 hashing algorithm
- CSRF Protection: Enabled on all forms
- XSS Protection: All user inputs are escaped in templates
- SQL Injection Prevention: Django ORM used throughout
- Security Headers: X-Frame-Options, X-Content-Type-Options
- Session Security: Secure session cookies in production
- Access Control: Role-based permissions on all views
The system uses the following main tables:
user_roles: User role definitionsusers: User accounts with role assignmentcustomer: Customer informationitem_category: Item categoriesitem: Inventory items with quantity trackinginvoice: Invoice headersinvoice_item: Invoice line itemspayment: Payment records
All tables include proper indexes for optimal query performance.
python manage.py testTo measure test coverage:
pip install coverage
coverage run --source='.' manage.py test
coverage report-
Environment Variables:
- Set
DEBUG=False - Set
SECRET_KEYto a secure random string - Configure
ALLOWED_HOSTS
- Set
-
Static Files:
python manage.py collectstatic
-
Database:
- Migrate to PostgreSQL (recommended)
- Run migrations:
python manage.py migrate
-
Security:
- Enable HTTPS
- Configure security headers (already in settings.py)
- Set up proper email backend
-
Performance:
- Use a production WSGI server (Gunicorn, uWSGI)
- Set up reverse proxy (Nginx)
- Enable database connection pooling
- Configure caching (Redis/Memcached)
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow PEP 8 for Python code
- Use meaningful variable and function names
- Add docstrings to classes and functions
- Write tests for new features
MIT License - see LICENSE file for details
For issues, questions, or contributions, please open an issue on the repository.
Set Invoice - Built with Django and TailwindCSS