node package manager

docparse-save-invoice

save scraper data to a new invoice document in the database'

Create new invoice document in the database only if needed Dependency Status Dependency tracking by David

Usage

see check.js for the required fields

var saveInvoice = require('docparse-save-invoice')
var inspect = require('eyepsect').inspector()
var data = {
  db: <cradle db connection>,
  loginID: 'fooLoginID',
  customerID: 'fooCustomerID',
  billingSupplierCode: 'FGS',
  billingSupplierID: supplierID,
  supplierCode: 'FGS',
  supplierID: supplierID,
  billID: 'fooBillID',
  billNumber: 'foo bill number',
  billNumberPrinted: true,
  dataType: 'pdf',
  accountNumber: 'foo account number',
  fromDate: moment().format("YYYY-MM-DD HH:mm:ss Z"),
  toDate: moment().format("YYYY-MM-DD HH:mm:ss Z"),
  readType: 'ACTUAL',
  days: 30,
  costOther: {
    total: '0',
    costs: []
  },
  costSupply: '10.99',
  costDelivery: '21.63',
  use: 546,
  demandKw: 564,
  invoiceType: {
    commodity: 'electricity',
    type: 'utility'
  },
  capacityCharge: '0',
  capacityChargeUse: '0',
  capacityChargeAdjustment: '0',
  toPay: '32.63'
}
saveInvoice(data, function(err, reply) {
  if (err) {
    inspect(err, 'error saving invoice')
    return
  }
  inspect(reply, 'saved invoice to couchdb')
}