This project provides a complete solution for generating professional invoices for A.T COMMODITIES. It includes both a standalone Python script for command-line invoice generation and a web application built with Flask for browser-based invoice creation.
-
Standalone Invoice Generator
- Text-based invoice display in console
- PDF invoice generation using ReportLab
- Automatic total calculation
- Amount conversion to words
- Professional invoice formatting
- Landscape-oriented PDFs
- Date formatting (DD-MMM-YYYY)
-
Web Application
- Responsive HTML form for data entry
- Form validation with JavaScript
- PDF generation via Flask backend
- Download generated invoices
- Clean, professional UI with CSS styling
- AJAX form submission
- Error handling
- Python 3.6+
- pip package manager
pip install flask reportlab
AT-Commodities-Invoice-Generator/
├── standalone/ # Standalone invoice generator
│ └── invoice_generator.py
├── webapp/ # Web application files
│ ├── app.py # Flask application
│ ├── invoice_generator.py # PDF generation module
│ ├── templates/
│ │ └── invoice.html # HTML form template
│ └── static/
│ └── style.css # CSS stylesheet
└── README.md # This file
- Navigate to the standalone directory:
cd standalone
- Run the script:
python invoice_generator.py
- Follow the prompts to enter invoice details:
- Invoice Number
- Delivery Date (YYYY-MM-DD format)
- Vehicle Number
- Quantity (M/TON)
- Unit Price (Rs)
- View the text invoice in the console
- Find the generated PDF in the same directory
- Navigate to the webapp directory:
cd webapp
- Run the Flask application:
python app.py
- Open your browser and visit: http://localhost:5000
- Fill out the form with invoice details
- Click "Generate Invoice"
- Download the generated PDF invoice
To customize the company information, modify the following constants in both invoice_generator.py
files:
COMPANY_NAME = "A.T COMMODITIES"
ADDRESS = "C-2 WESTLAND TRADE CENTER, SHAHEED E MILLAT ROAD, KARACHI"
PHONE = "021-34381222"
WEBSITE = "www.atcommodities.pk"
The customer information is currently hardcoded as:
# In generate_pdf function
invoice_details = [
["Invoice for", "Mr. Talha Niazi Sb - Niazi Bricks"],
# ... other details ...
]
To change this, modify the "Invoice for" field in the generate_pdf
function.
To adjust the PDF layout:
- Modify column widths in the
generate_pdf
function - Adjust table styles
- Change page orientation (currently landscape)
- Python 3
- Flask (web framework)
- ReportLab (PDF generation)
- HTML5/CSS3 (frontend)
- JavaScript (form handling)
- Landscape-oriented PDF invoices
- Professional formatting with proper alignment
- Amount conversion to words (English)
- Date formatting (DD-MMM-YYYY)
- Error handling in both CLI and web versions
- Responsive web design
If you encounter jinja2.exceptions.TemplateNotFound
:
- Verify directory structure:
webapp/ ├── templates/ │ └── invoice.html
- Ensure you're running the app from the webapp directory
- Check for correct file naming (case-sensitive)
- Always enter dates in YYYY-MM-DD format
- The system will automatically convert to DD-MMM-YYYY format
- Ensure ReportLab is installed:
pip install reportlab
- Check file permissions in the output directory
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create your feature branch (
git checkout -b feature/your-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin feature/your-feature
) - Open a pull request
For any issues or questions, please open an issue on the GitHub repository.