Files
freelance_invoice/README.md
2024-09-17 14:24:19 +02:00

98 lines
2.2 KiB
Markdown

# Freelance Invoice
is a simple command line tool to generate invoices for freelance work. It uses a simple template system based
on `jinja2` to generate the
invoice in HTML and then converts it to a PDF using `xhtml2pdf`.
## Install
Use python venv:
```bash
python -m venv .venv
source .venv/bin/activate
```
Build executable:
```bash
pip install --upgrade build
python -m build
```
Install the executable:
```bash
pip install .
```
See where it is installed:
```bash
which invoice
```
## usage
```bash
invoice -h
```
There are two yaml files describing your invoice:
- [RG004211.yaml](test_data/RG004211.yaml) Contains the invoice data. The filename is takes as the invoice id-number.
- [envelope.yaml](test_data/envelope.yaml) contains the address data of the sender and the recipient
The invoice data is read from the `invoice.yaml` file and the address data is read from the `envelope.yaml` file. The
invoice data is then used to fill in the invoice template and the address data is used to fill in the address fields of
the invoice.
Some data are globaly available from the envelope template. Some of them can be overriden by the invoice template.
invoice.yaml - The Name of the invoice file is used as the invoice number but you are free to override it in the
invoice.yaml file.
```yaml
```bash
python src/main.py --help
Simple invoice generator for freelancers and small businesses by Torsten Ueberschar
usage: main.py [-h] -b BASE -i INVOICE [-e ENVELOPE] [-t TEMPLATE]
Read invoice and envelope data from yaml file
options:
-h, --help show this help message and exit
-b BASE, --base BASE base directory for invoice and envelope files
-i INVOICE, --invoice INVOICE
Invoice file name
-e ENVELOPE, --envelope ENVELOPE
Envelope file name
-t TEMPLATE, --template TEMPLATE
directory for template files
```
## example
```bash
invoice -b test_data -i invoice.yaml -e envelope.yaml -t test_data/templates
```
## to do
- give more structure to code
- make code testable
## see also
- https://xhtml2pdf.readthedocs.io/en/latest/index.html
- https://jinja.palletsprojects.com/