A Python script that automatically generates and sends invoices to clients based on the data entered in a Google Sheet.
- Python 3.x installed on your system
- A Google Cloud Platform (GCP) project with Google Sheets API and Gmail API enabled
- A
credentials.json
file for your GCP project - A Google Sheet containing invoice data with the following columns:
- Invoice ID
- Client Name
- Client Email
- Total Amount
- Send Invoice
- (optional) Other columns
-
Clone the repository or download the
dynamic_invoice_generator.py
andrequirements.txt
files. -
Install the required Python packages by running the following command:
pip install -r requirements.txt
-
Update the
dynamic_invoice_generator.py
script with yourSERVICE_ACCOUNT_FILE
,SPREADSHEET_ID
, andINVOICE_TEMPLATE_PATH
.
Run the script using the following command:
python dynamic_invoice_generator.py
The script will read the data from your Google Sheet, generate invoices as PDF files, and send them via email to the specified clients if the "Send Invoice" column is set to "YES."
To automate the execution of the script, you can set up a scheduled task (e.g., using cron
on a Linux system or Task Scheduler on Windows) to run it at regular intervals.