DriveFlow Accountant is a microservice built for driving schools to generate professional invoices for their students. This API service can generate and serve both HTML previews and PDF invoice documents.
- Generate PDF invoices with detailed student, instructor, and vehicle information
- Preview HTML version of the invoice before generation
- Beautifully styled invoices with responsive layout
- Romanian date formatting (DD Month YYYY) for better readability
- Docker support for easy deployment
- Heroku-ready configuration
Generates and returns a PDF invoice document.
- URL:
/api/v1/getInvoice - Method:
POST - Content-Type:
application/json - Response: PDF file (application/pdf)
Generates and returns an HTML preview of the invoice.
- URL:
/preview - Method:
POST - Content-Type:
application/json - Response: HTML content
Both endpoints accept the same JSON data format:
{
"autoSchool": {
"name": "Auto School Name",
"website": "www.example.com",
"phone": "+40 123 456 789",
"email": "contact@example.com"
},
"student": {
"firstName": "First",
"lastName": "Last",
"email": "student@example.com",
"phone": "+40 712 345 678",
"cnp": "1990123456789" // Optional
},
"file": {
"scholarshipStartDate": "2023-05-01", // Format: YYYY-MM-DD (will be displayed as "01 Mai 2023")
"criminalRecordExpiryDate": "2023-12-31", // Format: YYYY-MM-DD (will be displayed as "31 Decembrie 2023")
"medicalRecordExpiryDate": "2023-12-31", // Format: YYYY-MM-DD (will be displayed as "31 Decembrie 2023")
"status": "Activ"
},
"teachingCategory": {
"type": "B",
"sessionCost": 150.0,
"sessionDuration": 60,
"scholarshipPrice": 2000.0,
"minDrivingLessonsReq": 30
},
"vehicle": {
"licensePlateNumber": "B 123 ABC",
"transmissionType": "Manual",
"color": "White",
"licenseType": "B"
},
"instructor": {
"fullName": "Instructor Name"
},
"payment": {
"sessionsPayed": 10,
"scholarshipBasePayment": true
}
}All dates in the generated invoice are automatically formatted in Romanian style:
- Input format: YYYY-MM-DD (ISO standard)
- Display format: DD Month YYYY (e.g., "01 Mai 2023")
- Month names are in Romanian language
This formatting applies to:
- Issue Date
- Medical Record Expiry Date
- Criminal Record Expiry Date
- Scholarship Start Date
-
Clone the repository:
git clone https://github.com/yourusername/DF-Accountant.git cd DF-Accountant -
Set up a virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the application:
python app.py
-
Build and run using Docker Compose:
./docker_run.sh
Or manually:
docker-compose up --build -d
-
Access the API at: http://localhost:5000
-
Install the Heroku CLI and log in:
heroku login
-
Create a new Heroku app:
heroku create your-app-name
-
Set the stack to container:
heroku stack:set container
-
Push to Heroku:
git push heroku main
app.py- Main application codewsgi.py- WSGI entry point for production serverstemplates/- HTML templates and CSS filesinvoice_template.html- The invoice HTML templateinvoice.css- CSS styles for the invoice
static/- Static assets (logos, fonts)Dockerfile- Docker container configurationdocker-compose.yml- Docker Compose service definitionheroku.yml- Heroku Docker deployment configurationrequirements.txt- Python dependenciestest_data.json- Example data for testing the API
- Flask - Web framework
- WeasyPrint - HTML to PDF conversion
- Pydantic - Data validation
- Gunicorn - WSGI HTTP Server for production
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or support, please contact the DriveFlow development team.
