invoice_processor

1.8.2 • Public • Published

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)

after being run, these invoices are moved to out folder:

  • demo/
    • out/
      • sobeys/
        • inv1.pdf
        • inv2.pdf
      • ctg/
        • inv55123.pdf
      • modern/
        • (empty)

Readme

Keywords

none

Package Sidebar

Install

npm i invoice_processor

Weekly Downloads

6

Version

1.8.2

License

ISC

Unpacked Size

51.3 kB

Total Files

25

Last publish

Collaborators

  • npmjoes