This program parses a PDF with one or more pages of invoices, assumed to be generated by Quickbooks.
It extracts fields from the invoices: customer name, account number, invoice number, terms & email address.
For each page, it writes a single page invoice with a filename format: customer_name_invoice_number.pdf
If the page has an email address, then it emails the PDF as an attachment.
To cover special cases, it won't email customers that have EoS (End of Season) in their Terms.
An App Password is used to access Google's email.
After creating the app password, store in in a json file. Here is the format as an example:
{
"email_address": "address@gmail.com",
"app_password": "password_obtained_from_google"
}
The program defaults to reading "email_credentials.json".
An example invocation:
./email_invoices/process_invoices.py invoices.pdf
The program requires these modules to be installed:
- PyPDF2: allows reading PDFs per page, parsing the pages to get text, and write PDFs
- yagmail: yet another gmail client. Allows sending from a gmail account using SMTP.
To install, do the following:
git clone https://github.com/manningt/email_invoices
cd email_invoices
python3 -m venv env
source env/bin/activate
pip install PyPDF2
pip install yagmail
Reads a CSV file which has a header row with the column titles customer_id & amount.
Writes a Quickbooks IIF file, which starts with the commented format of the fields:
!TRNS TRNSTYPE DATE ACCNT NAME AMOUNT
!SPL TRNSTYPE DATE ACCNT NAME AMOUNT
!ENDTRNS
and each payment generates the following lines:
TRNS PAYMENT 12/28/2023 Undeposited Funds Whitcomb, Andrea 35
SPL PAYMENT 12/28/2023 Accounts Receivable Whitcomb, Andrea -35
ENDTRNS