Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blankscreen-exe/invoice_generator
python invoice generator using Jinja2 and WeasyPrint
https://github.com/blankscreen-exe/invoice_generator
Last synced: about 1 month ago
JSON representation
python invoice generator using Jinja2 and WeasyPrint
- Host: GitHub
- URL: https://github.com/blankscreen-exe/invoice_generator
- Owner: Blankscreen-exe
- Created: 2023-11-11T19:49:20.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-16T16:34:57.000Z (about 1 year ago)
- Last Synced: 2023-12-16T17:29:25.549Z (about 1 year ago)
- Language: HTML
- Size: 155 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Invoice Generator
This is an invoice generator built with `Jinja2` and `WeasyPrint`.
You can use this to make a pdf and an html invoice. Before you can use this script, you will need to customize some settings beforehand.
> 📌 This repository is a part of a blog article that I wrote [here on medium.com](https://medium.com/@hammad.ai/create-an-invoice-generator-using-python-jinja2-weasyprint-48ef1f450ac5)
## Installation
I recommend that you create a virtual environment first, before installing the dependencies.
```shell
pip3 install -r requirements.txt
```> **NOTE**: WeasyPrint is known to have problems in Windows OS which can easily be fixed [like this](https://doc.courtbouillon.org/weasyprint/stable/first_steps.html#missing-library).
## Usage
The templates(HTML/CSS) are completely upto you to customize. These templates are found in the project root directory by default. The starter template can be found as `invoice_template_001.html`.Similarly, the associated style file can be found as `invoice_template_001.css`.
To apply bootstrap styling and loading other CDNs you can append to the `TEMPLATE_CSS` variable which can be found inside `settings.py`. This is an array of all the `css` which is required to render the template. You should load your custom `css` file in this array as well.
`data.json` contains the context data which will be renderd into the template. In case you want to perform calculations, you can wither engineer those formulas directly into the `html` template or in the `get_context_data()` function which can be found inside `settings.py`.
To run the script, make sure all of the above is present inside the project root directory and run this command:
```shell
python3 invoice_gen.py
```If all goes as planned, you will see a message in the terminal like this:
```shell
PDF generated: output-12-Nov-2023.pdf
```## Preview
![preview](./docs/preview.png)
> 📌 I found the original template [here](https://www.bootdey.com/snippets/view/bs4-invoice) and did some modifications to it to fit my needs.