A comprehensive Django-based sales and accounting management system with dual department support (Regular & Cash), thermal printing, and advanced reporting capabilities.
Sales_App_Unitary/
βββ π sales_app/ # Main sales application
βββ π accounting_app/ # Accounting & financial reporting
βββ π core/ # Shared utilities & base templates
βββ π sales_management_project/ # Django project settings
βββ π scripts/ # π Utility scripts (ORGANIZED)
β βββ production/ # Production deployment scripts
β βββ data_import/ # CSV import & data processing
β βββ testing/ # Testing & debugging scripts
βββ π docs/ # π All documentation & guides (ORGANIZED)
βββ π data/ # π CSV files & data imports
βββ π sql/ # π SQL scripts & RLS security policies
βββ π tests/ # Test files
βββ π staticfiles/ # Collected static files (production)
βββ π node_modules/ # Node.js dependencies
# 1. Create user groups (Admin, Managers, Cashiers)
python manage.py setup_user_groups
# 2. Assign yourself to Admin group in Django Admin (/admin/)
# 3. Apply database security policies
python manage.py enable_rls_securitySee docs/SECURITY_FIX_WALKTHROUGH.md for complete instructions.
- Role-Based Access Control:
- Admin: Full system access, product management, user management
- Manager: Sales oversight, reporting, dashboard access, invoice management
- Cashier: Sales entry and basic invoice operations
- Secure Authentication: Custom login/logout with automatic role-based redirects
- Group-Based Navigation: Dynamic menu items based on user permissions
-
Advanced Sales Entry:
- Multi-item invoice creation with dynamic row management
- Real-time price calculation and total computation
- Stock validation with live inventory checking
- Customer information management
- Discount and payment tracking
- Local storage auto-save to prevent data loss
-
Smart Product Selection:
- AJAX-powered product search with autocomplete
- Stock level display during product selection
- Automatic price population from product database
- Stock deduction upon sale completion
-
Comprehensive Invoice System:
- Auto-generated unique invoice numbers
- Detailed invoice views with item breakdowns
- Invoice editing capabilities for managers
- Balance tracking (paid/unpaid/overpaid)
- Invoice deletion with automatic stock restoration
-
Print & Receipt System:
- Auto-print functionality on sale completion
- Professional receipt templates optimized for thermal printers
- Standard A4 invoice printing for business records
- Print-friendly layouts with proper formatting
-
Comprehensive Financial Dashboard:
- Monthly revenue and expense tracking
- Real-time profit & loss calculations
- Outstanding invoice monitoring
- Financial KPI cards with visual indicators
- Quick access to all accounting functions
-
Expense Management:
- Detailed expense tracking with categories
- Receipt file upload and storage
- Vendor and payment method tracking
- Recurring expense marking
- Advanced filtering and search capabilities
- Bulk expense operations
-
Financial Reporting:
- Profit & Loss Reports: Monthly and annual P&L statements
- Revenue Analysis: 12-month revenue trends with charts
- Expense Breakdown: Category-wise expense analysis
- Outstanding Invoices: Payment status tracking and aging reports
- Tax Preparation: Automated tax calculations and reporting
-
Audit Trail & Compliance:
- Complete audit log of all financial activities
- User action tracking with timestamps
- IP address logging for security
- Comprehensive change history
- Export capabilities for external auditing
- Multi-Parameter Search:
- Customer name search (partial matching)
- Invoice number search
- Date range filtering
- OR-based search logic for flexible results
- Real-time Search Results:
- Live filtering with visual feedback
- Search criteria persistence
- Results summary with statistics
-
Professional Interface:
- Modern card-based layout with gradient backgrounds
- Sales summary cards (Total Sales, Invoice Count, Averages)
- Real-time statistics and KPI tracking
- Responsive design for all screen sizes
-
Comprehensive Reporting:
- Daily sales reports
- Search result exports
- Professional print layouts for business documentation
- Date-specific report generation
-
Multiple Print Options:
- Print Today: Current day's invoices in professional format
- Print Search Results: Export filtered results to print
- Print Specific Date: Historical date report generation
- Individual Receipts: Thermal printer-optimized receipts
-
Professional Report Format:
- Company header and branding
- Detailed invoice breakdowns with items
- Summary statistics and totals
- Print-optimized A4 layouts
- Auto-generated timestamps and user attribution
-
Real-Time Stock Tracking:
- Automatic stock deduction on sales
- Stock restoration on invoice deletion
- Low stock warnings during sales entry
- Inventory level validation
-
Product Management (Admin):
- Add, edit, delete products
- Price management
- Stock level tracking
- Product search and organization
-
Auto-Save Technology:
- Local storage backup during form entry
- Form restoration on page reload
- Data persistence across sessions
- Loss prevention mechanisms
-
Audit Trail:
- Administrative action logging
- User activity tracking
- Stock movement history
- Invoice modification logs
- Tailwind CSS Framework: Clean, responsive, professional design
- Dark Mode Support: System-responsive dark/light theme switching
- Mobile Responsive: Optimized for desktop, tablet, and mobile devices
- Intuitive Navigation: Role-based menu system with clear visual hierarchy
- Real-Time Feedback: Visual indicators for form validation and user actions
- Keyboard Shortcuts: Enter key support for quick form submission
- Loading States: Progress indicators for better user experience
- Error Handling: Comprehensive error messages and validation feedback
- Django 5.2: Modern Python web framework
- SQLite/PostgreSQL: Flexible database options
- Django Forms: Advanced form handling and validation
- Custom Middleware: Security and session management
- Tailwind CSS: Utility-first CSS framework
- JavaScript ES6+: Modern client-side functionality
- AJAX: Asynchronous data loading and form submission
- Local Storage API: Client-side data persistence
- CSS Print Media: Professional print layouts
- PDF-Ready Formatting: Business-standard report generation
- Responsive Print Design: Optimized for various paper sizes
sales_management_project/
βββ π± sales_app/ # Core sales functionality
β βββ π¨ templates/sales_app/
β β βββ sales_entry.html # Advanced sales form with auto-save
β β βββ manager_dashboard.html # Professional dashboard interface
β β βββ receipt_print.html # Thermal printer receipt template
β β βββ invoices_print.html # A4 business report template
β β βββ invoice_detail.html # Detailed invoice view
β βββ π― static/sales_app/ # CSS, JS, and assets
β β βββ css/ # Custom styling and print layouts
β β βββ js/ # AJAX functionality and form handling
β βββ π§ models.py # Database models (Invoice, Sale, Product)
β βββ π views.py # Business logic and request handling
β βββ π forms.py # Advanced form definitions
β βββ π urls.py # URL routing and patterns
βββ π’ accounting_app/ # Financial management (Admin only)
β βββ π¨ templates/accounting_app/
β β βββ dashboard.html # Financial overview dashboard
β β βββ expense_list.html # Expense management interface
β β βββ expense_form.html # Expense creation/editing form
β β βββ profit_loss_report.html # P&L statement template
β β βββ revenue_tracking.html # Revenue analysis dashboard
β βββ π§ models.py # Financial models (Expense, ProfitLoss, etc.)
β βββ π views.py # Financial business logic
β βββ π urls.py # Accounting URL patterns
βββ π¨ core/ # Shared components and utilities
β βββ π§© templatetags/ # Custom template filters and tags
β βββ π templates/core/ # Base templates and navigation
βββ βοΈ sales_management_project/ # Project configuration
βββ ποΈ db.sqlite3 # Database file
βββ π¦ requirements.txt # Python dependencies
βββ π¨ tailwind.config.js # Tailwind CSS configuration
βββ π README.md # This documentation
- Product: Inventory items with pricing and stock levels
- Invoice: Main sales record with customer and payment info (enhanced with status tracking)
- Sale: Individual line items within invoices
- AdminLog: Audit trail for administrative actions
- StockMovement: Inventory change tracking
- ExpenseCategory: Categorization for business expenses
- Expense: Detailed expense records with receipts and vendor info
- ProfitLossSnapshot: Monthly financial performance snapshots
- TaxSettings: Configurable tax rates and calculations
- AccountingAuditLog: Comprehensive audit trail for financial operations
- Python 3.8+
- Node.js 14+ (for Tailwind CSS)
- Git
-
Clone the Repository:
git clone https://github.com/akyensamuel/Sales-App.git cd Sales-App/sales_management_project -
Create Virtual Environment:
python -m venv virtual # On Windows: virtual\Scripts\activate # On macOS/Linux: source virtual/bin/activate
-
Install Python Dependencies:
pip install -r requirements.txt
-
Install Node.js Dependencies:
npm install
-
Database Setup:
python manage.py migrate python manage.py createsuperuser
-
Create User Groups:
python manage.py shell
from django.contrib.auth.models import Group Group.objects.create(name='Admin') Group.objects.create(name='Managers') Group.objects.create(name='Cashiers') exit()
-
Run Development Server:
python manage.py runserver
-
Access the Application:
- Open browser to
http://127.0.0.1:8000/ - Login with superuser credentials
- Access Django admin at
http://127.0.0.1:8000/admin/to assign users to groups
- Open browser to
- Access Django Admin:
/admin/ - Create Users: Add users in the Users section
- Assign Groups: Add users to appropriate groups (Admin/Managers/Cashiers)
- Test Access: Login as different users to verify permissions
| Feature | Admin | Manager | Cashier |
|---|---|---|---|
| Sales Entry | β | β | β |
| Manager Dashboard | β | β | β |
| Invoice Editing | β | β | β |
| Invoice Deletion | β | β | β |
| Print Reports | β | β | β |
| Product Management | β | β | β |
| User Management | β | β | β |
| Accounting Dashboard | β | β | β |
| Expense Management | β | β | β |
| Financial Reports | β | β | β |
| P&L Analysis | β | β | β |
| Revenue Tracking | β | β | β |
| Audit Logs | β | β | β |
| Accounting Dashboard | β | β | β |
- Configure receipt printer for 58mm or 80mm paper
- Set printer to auto-cut after printing
- Test with receipt_print template
- Use landscape orientation for better table layouts
- Enable background graphics for professional appearance
- Set margins to 0.5 inches for optimal content fit
Create a .env file in the project root:
SECRET_KEY=your-secret-key-here
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1
DATABASE_URL=sqlite:///db.sqlite3- Set
DEBUG=False - Configure proper database (PostgreSQL recommended)
- Set up static file serving with WhiteNoise
- Use environment variables for sensitive settings
- Enable SSL/HTTPS for security
- Navigate to Sales Entry
- Enter customer information
- Add products using the search feature
- Verify stock availability
- Calculate totals and enter payment
- Choose "Save" or "Save and Print"
- Access Manager Dashboard
- Use search filters to find specific invoices
- Click invoice rows for detailed views
- Edit or delete as needed
- Print reports for record-keeping
- Use date filters to select reporting period
- Apply customer or invoice filters if needed
- Click appropriate print button
- Review report in new tab before printing
- Access Accounting Dashboard (Admin only)
- View financial overview and KPIs
- Add expenses with categories and receipts
- Generate P&L reports for any period
- Track revenue trends and payment status
- Monitor outstanding invoices
- Overview Cards: Monthly revenue, expenses, profit, and outstanding amounts
- Quick Actions: Direct access to expense creation and management
- Recent Activity: Latest expenses and financial transactions
- Navigation: Easy access to all accounting features
-
Adding Expenses:
- Choose existing category or create new one
- Enter amount, date, and description
- Add vendor and payment method information
- Include reference numbers and notes
- Mark recurring expenses for tracking
-
Expense Categories:
- Office Supplies, Travel & Transport, Marketing
- Utilities, Professional Services, Equipment
- Rent & Facilities, Insurance, Training
- Customizable categories for specific business needs
-
Filtering & Search:
- Filter by category, date range, payment method
- Search descriptions, vendors, and notes
- Export filtered results for analysis
-
Profit & Loss Reports:
- Monthly or annual P&L statements
- Revenue vs. expense breakdowns
- Profit margin calculations
- Category-wise expense analysis
- Printable professional format
-
Revenue Analysis:
- 12-month revenue trend charts
- Payment status overview
- Outstanding invoice tracking
- Collection aging reports
- Complete audit trail of all financial activities
- User action logging with timestamps
- Change history tracking
- Export capabilities for external auditing
- IP address logging for security
The advanced search system supports multiple search strategies:
- Customer Search: Partial name matching (case-insensitive)
- Invoice Search: Partial invoice number matching
- Date Filtering: Single date or date range selection
- Combined Search: Multiple criteria with OR logic
- Quick Filters: Today's sales, specific date ranges
- Daily Sales Report: All invoices for a specific date
- Search Results Report: Filtered invoice data
- Customer Reports: Sales by customer (via search)
- Period Reports: Date range analysis
- Invoice summary with totals
- Detailed item breakdowns
- Payment status indicators
- Customer information
- Sales representative tracking
- Generation timestamps
- Print not working: Check popup blockers and printer connections
- Search not returning results: Verify date formats and search criteria
- Stock validation errors: Check product inventory levels
- Permission denied: Verify user group assignments
- Auto-save not working: Check browser local storage settings
- Regular database cleanup of old invoices
- Optimize large product catalogs with pagination
- Use date filters for large datasets
- Clear browser cache if experiencing loading issues
- Fork the repository
- Create feature branch:
git checkout -b feature-name - Make changes and test thoroughly
- Commit with descriptive messages
- Push and create pull request
- Follow Django best practices
- Use Tailwind CSS for styling
- Write descriptive comments
- Test all user roles and permissions
- Ensure responsive design compatibility
MIT License - see LICENSE file for details
- PDF export functionality
- Email invoice delivery
- Advanced inventory management
- Barcode scanning integration
- Multi-location support
- Automated tax calculations and filing
- Bank integration for transaction import
- Advanced financial forecasting
- Budget planning and variance analysis
- Integration with accounting software (QuickBooks, Xero)
- Automated recurring expense handling
- Advanced financial dashboards with charts
- Cash flow analysis and projections
- Customer relationship management
- API development for integrations
- Advanced analytics and dashboards
- Multi-currency support
- Cloud deployment options
Version: 2.0.0
Last Updated: August 2025
Maintainer: Akyen Samuel
Status: Production Ready