Skip to content

A modern, efficient billing system designed for retail businesses. Built with Django and modern web technologies, it offers real-time updates, flexible discounting, and comprehensive sales tracking. Perfect for small to medium retail stores looking for a simple yet powerful billing solution.

Notifications You must be signed in to change notification settings

jethliya-balaji/Billing-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Billing System

A modern billing system built with Django, Tailwind CSS, and HTMX. The system features a responsive design with light/dark theme support and real-time updates.

Live Demo

The system is live at: http://midknightdev.pythonanywhere.com/

  • Username: admin
  • Password: 123

Customization

You can customize the business name throughout the application by setting the BUSINESS_NAME environment variable in your .env file:

# Add to your .env file
BUSINESS_NAME="Your Business Name"

This will automatically update the business name across:

  • Admin interface
  • Navigation bar
  • Page titles
  • Printed bills
  • All other relevant places in the application

If BUSINESS_NAME is not set, it defaults to "Billing System".

Features

  • πŸ›οΈ Product management
    • Add, edit products through admin panel
    • Set default rates for products
    • Product search with Select2
    • Enhanced barcode scanning for quick product selection:
      • Scan barcodes from create/edit bill page
      • NEW: Quick product lookup from dashboard
      • NEW: Product details modal for scanned items
  • πŸ“Š Sales dashboard with period-wise summaries
    • 7 days sales summary
    • Monthly sales summary
    • 3 months sales summary
    • Filter bills by date, salesperson, and search terms
  • 🧾 Bill management
    • Create new bills
    • Add multiple items with custom rates
    • Flexible discount options:
      • Pre-defined discounts (40%, 50%)
      • Custom percentage discount
      • Per-item discount application
    • Print bills in a clean format
    • Edit existing bills
    • Delete bills (with proper permissions)
  • πŸ‘₯ Multi-user support
    • Admin/Owner access to all bills
    • Salesperson can create and manage their own bills
    • Role-based permissions
  • πŸŒ“ Light/Dark theme support
  • πŸ“± Responsive design
  • ⚑ Real-time updates using HTMX
  • πŸ” User authentication and authorization
  • πŸ“· Enhanced barcode scanning capabilities:
    • Product selection during bill creation
    • NEW: Product information lookup from dashboard
    • Mobile-friendly camera interface
    • Support for multiple barcode formats

Tech Stack

  • Backend: Django 4.2

  • Frontend:

    • Tailwind CSS 3.4
    • DaisyUI 4.12
    • HTMX 1.18
    • Web Barcode Detector API
  • Database: SQLite (default Django DB)

Prerequisites

  • Python 3.x
  • Node.js and npm
  • Git
  • Modern browser that supports BarcodeDetector API

Installation

  1. Clone the repository
git clone https://github.com/jethliya-balaji/Billing-System.git
cd Billing-System
  1. Create and activate virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install Python dependencies
pip install -r requirements.txt
  1. Install Node.js dependencies
npm install
  1. Create .env file in the root directory
# Create .env file
touch .env  # On Windows: type nul > .env

# Add the following configuration to .env
SECRET_KEY=django-insecure-your-secret-key-here
DEBUG=TRUE
ALLOWED_HOSTS=localhost 127.0.0.1
BUSINESS_NAME="Your Business Name"  # Optional: defaults to "Billing System"

Note: You can generate a secure secret key using Python:

python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
  1. Run database migrations
python manage.py migrate
  1. Create a superuser
python manage.py createsuperuser

Development

  1. Start the Django development server
python manage.py runserver
  1. Watch for Tailwind CSS changes
npm run dev

Project Structure

Billing-System/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ billing/                    # Main Django app
β”‚   β”‚   β”œβ”€β”€ management/
β”‚   β”‚   β”‚   └── commands/
β”‚   β”‚   β”‚       └── delete_empty_bills.py
β”‚   β”‚   β”œβ”€β”€ migrations/
β”‚   β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”‚   └── 0001_initial.py
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ admin.py               # Admin interface configuration
β”‚   β”‚   β”œβ”€β”€ apps.py               # App configuration
β”‚   β”‚   β”œβ”€β”€ filters.py            # Bill filtering logic
β”‚   β”‚   β”œβ”€β”€ forms.py              # Form definitions
β”‚   β”‚   β”œβ”€β”€ models.py             # Database models
β”‚   β”‚   β”œβ”€β”€ tests.py             # Test cases
β”‚   β”‚   β”œβ”€β”€ urls.py              # URL routing
β”‚   β”‚   └── views.py             # View logic
β”‚   β”œβ”€β”€ core/                     # Project settings
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ settings.py          # Django settings
β”‚   β”‚   β”œβ”€β”€ urls.py              # Main URL configuration
β”‚   β”‚   └── wsgi.py              # WSGI configuration
β”‚   β”œβ”€β”€ static/
β”‚   β”‚   β”œβ”€β”€ css/
β”‚   β”‚   β”‚   └── tailwind-output.css   # Compiled Tailwind CSS
β”‚   β”‚   β”œβ”€β”€ js/
β”‚   β”‚   β”‚   β”œβ”€β”€ script.js        # General JavaScript
β”‚   β”‚   β”‚   β”œβ”€β”€ barcode-scanner.js  # Barcode scanning functionality 
β”‚   β”‚   β”‚   └── create_edit_bill_page.js  # Bill page specific logic
β”‚   β”‚   β”œβ”€β”€ htmx.min.js          # HTMX library
β”‚   β”‚   └── src/
β”‚   β”‚       └── tailwind-input.css    # Tailwind source
β”‚   └── templates/
β”‚       β”œβ”€β”€ 403.html             # Permission denied page
β”‚       β”œβ”€β”€ 404.html             # Not found page
β”‚       └── billing/
β”‚           β”œβ”€β”€ partials/
β”‚           β”‚   β”œβ”€β”€ create_edit_bill_item.html
β”‚           β”‚   β”œβ”€β”€ dashboard_bill.html
β”‚           β”‚   β”œβ”€β”€ messages.html
β”‚           β”‚   └── navbar.html
β”‚           β”œβ”€β”€ base.html         # Base template
β”‚           β”œβ”€β”€ create_edit_bill.html
β”‚           β”œβ”€β”€ dashboard.html
β”‚           β”œβ”€β”€ login.html
β”‚           β”œβ”€β”€ print_bill.html
β”‚           └── view_bill.html
β”œβ”€β”€ .gitignore
β”œβ”€β”€ manage.py                     # Django management script
β”œβ”€β”€ package.json                  # Node.js dependencies
β”œβ”€β”€ requirements.txt              # Python dependencies
└── tailwind.config.js           # Tailwind configuration

Theme Customization

The project uses DaisyUI themes with two default options:

  • Corporate (Light theme)
  • Business (Dark theme)

Theme preferences are automatically saved to localStorage and persists across sessions.

Features in Detail

Product Management

  • Add and edit products through Django admin interface
  • Set default rates for products
  • Products appear in Select2 dropdown during bill creation
  • Enhanced barcode scanning using device camera for quick selection and lookup
  • Auto-barcode generation for new products
  • Inventory tracking with stock management

Barcode Scanning

  • Uses Web BarcodeDetector API for real-time barcode scanning
  • Compatible with various barcode formats including Code 128, EAN-13, UPC-A, and QR codes
  • Two scanning modes:
    • Product selection during bill creation
    • NEW: Product information lookup from dashboard
  • Camera access with mobile-friendly interface
  • Optimized video resolution settings for better scanning performance
  • Improved callback pattern for flexible implementation

Bill Management

  • Create new bills with customer details
  • Add multiple items with option for custom rates
  • Flexible discount options:
    • Pre-defined discounts (40%, 50%)
    • Custom percentage discount
    • Per-item discount application
  • Print bills in a clean, professional format
  • Edit existing bills (own bills for salesperson, all bills for admin)
  • Delete bills with proper permissions
  • Automatic bill number generation with date prefix

Dashboard Features

  • View comprehensive sales summaries
  • NEW: Quick product lookup via barcode scanner
  • NEW: Product details modal for displaying scanned product information
  • Filter bills by:
    • Date
    • Salesperson (admin only)
    • Search terms (customer name, bill number)
  • Quick access to recent bills
  • Pagination with "Load More" functionality
  • Different views for admin and salesperson

User Management

  • Admin/Owner can:
    • View all bills
    • Filter by salesperson
    • Access admin panel
    • Manage products
  • Salesperson can:
    • Create new bills
    • View their own bills
    • Edit their own bills
    • Print bills

Code Organization

  • Improved JavaScript organization:
    • Core UI functionality in script.js
    • Billing page logic in dedicated create_edit_bill_page.js
    • Barcode scanning functionality in barcode-scanner.js
  • Reduced dependencies with optimized script loading
  • Better template structure with proper script blocks

Browser Compatibility

The barcode scanning feature requires a browser that supports the BarcodeDetector API

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

MIT License

Acknowledgments

Support

If you encounter any issues or have questions, please open an issue.

About

A modern, efficient billing system designed for retail businesses. Built with Django and modern web technologies, it offers real-time updates, flexible discounting, and comprehensive sales tracking. Perfect for small to medium retail stores looking for a simple yet powerful billing solution.

Topics

Resources

Stars

Watchers

Forks