invoice_processor
v1.8.2
Published
Iterates through a folder system of invoices and converts to an array of invoice objects that the caller can then access. Right now, only works for Sobeys West invoices.
Downloads
6
Readme
Invoice Parser
Parses through a folder system of invoices on a vendor basis. Creates an array of invoice objects that the caller can then work with.
Currently Implemented Vendor Invoices
Sobeys West
Future Vendor Invoices:
- CTG
- Modern Houseware
- Symak Sales
- Tree of Life
- UNFI
Details
package is run with the invoiceParser.parseInvoicesInDir(inputPath, vendors) function aftwards, can access data via invoices object:
/**
* type {[]}
*/
const invoices = invoiceParser.invoices;
then, you can grab items and metadata within each invoice
const invoice = invoices[0];
/**
* @type {invoiceNo: {string}, invoiceDate: {string, yyyy-mm-dd format}, vendor: {string}}
*/
const metaData = invoice.metaData;
/**
* @type {[InvoiceItem]}
*/
const items = invoice.items;
Usage
ES6
import {InvoiceParser} from 'invoice_processor';
const invoiceParser = new InvoiceParser();
const vendors = ['sobeys', 'ctg'];
const inputPath = 'demo/in'
await invoiceParser.parseInvoicesInDir(inputPath, vendors);
/// all parsed invoices:
invoiceParser.parsedInvoices.forEach((parsedInvoice) => {
console.log(`${JSON.stringify(parsedInvoice.metaData)}`);
console.log(`${JSON.stringify(parsedInvoice.items)}`);
});
Folder System Example
- demo/
- in/
- sobeys/
- inv1.pdf
- inv2.pdf
- ctg/
- inv55123.pdf
- modern/
- (empty)
- sobeys/
- in/
after being run, these invoices are moved to out folder:
- demo/
- out/
- sobeys/
- inv1.pdf
- inv2.pdf
- ctg/
- inv55123.pdf
- modern/
- (empty)
- sobeys/
- out/