I'm building a tool for a construction company to automate our invoice intake process. Outlook already sorts incoming invoices into a dedicated folder, but I currently have to download each one, determine which job it belongs to, rename it, and move it into the correct job folder on a shared server.
Most invoices arrive as PDFs, though a small number come as Excel files. Some invoices are for change orders, which use job numbers such as 11111x01 or 11111x02 instead of the base job number 11111.
My initial workflow is:
1. Download the invoice from Outlook.
2. Extract the job number and invoice number.
3. Identify the company name and other required information.
4. Rename the file using our naming convention.
5. Move it into the folder for the matching job.
Our folders look roughly like this:
\Invoices\11111 - Washington HS
\Invoices\11112 - Adams MS
\Invoices\11113 - Jefferson HS
The final filenames should include the vendor and a reformatted invoice number. For example, `154873-005` would become `Acme - 154873.005`.
I have some JavaScript and TypeScript experience, so Node.js is appealing, although I'm willing to learn Python if it has better tools for this. I was considering maintaining a JSON file that maps job numbers to folder paths, but jobs change occasionally and I'd prefer a solution that nontechnical staff can maintain simply by adding or removing folders. I'm also unsure whether OCR is necessary, or whether PDF text can be extracted directly. What tools and overall design would you recommend for this workflow?
2 Answers
Before adding OCR, check whether the PDFs already contain selectable text. Many digitally generated invoices have a text layer, so a PDF parser can extract the job number, invoice number, and vendor much more reliably and quickly than OCR. In Node.js, libraries such as pdf.js or pdf-parse can help; Python has similar PDF extraction libraries. OCR should mainly be a fallback for scanned or image-only invoices.
Node.js should work well for this. You can use filesystem libraries such as `fs` and `path` to scan the Invoices directory and build a lookup from the existing folder names, rather than maintaining a separate JSON mapping. That way, staff can add or remove job folders normally and the program discovers them automatically. Extract the PDF text first, use patterns to identify the base job number or a change-order number like `11111x01`, then match that number against the discovered folders. Keep the original file and log anything that fails validation so unusual invoices can be reviewed instead of being filed incorrectly. OCR can be added later for scanned PDFs or difficult layouts.

That makes sense. I had assumed OCR would be required, but I’ll test several sample invoices to see whether they already contain usable text and compare the results.