Giter Club home page Giter Club logo

presto-report's Introduction

presto-report

presto-report, a cli tool to automate the generation (and emailing) of prestocard.ca transit activity reports, mainly for expense purposes.

License: MIT

About

presto-report is a simple NodeJS app packaged in a Docker image alongside a full Chrome headless browser. It is based on zenika/alpine-chrome and uses puppeteer to crawl the Web and generate PDFs. It supports emailing PDFs with a [free] SendGrid API key.

What it does:

  1. Navigates to https://www.prestocard.ca/en/dashboard/card-activity & signs in;
  2. Picks a date range, transaction types(s) (default: 'card loads') and clicks 'View';
  3. Clicks 'Print' & saves as PDF;
  4. (Optional) Emails that PDF.

Installation

docker pull pndurette/presto-report
cat << EOF > .env
PRESTO_USER=youruser
PRESTO_PASS=yourpass
EOF

Define PRESTO_USER and PRESTO_PASS respectively as your prestocard.ca credentials (see .env.example).

Usage

docker run --rm --privileged --env-file .env pndurette/presto-report --help

Examples

Last month's report to ./artifacts/<report>.pdf:

Emailing is optional. Mount the /artifacts directory from the container to access your report:

docker run --rm --privileged --env-file .env \
           -v $(pwd)/artifacts:/artifacts \
           pndurette/presto-report --lastmonth

June 2018's report to [email protected]:

To email, you'll need a SendGrid API Key (with at least the 'Mail Send' scope—it's free for 100 emails/day) set to SENDGRID_API_KEY in your .env file

Some expensing systems (like Chrome River) that supports receipts emailing allows you to set the 'subjet' to the amount of the expense.

docker run --rm --privileged --env-file .env \
           -v $(pwd)/artifacts:/artifacts \
           pndurette/presto-report --year 2018 --month 06 \
           --to [email protected] \
           --from [email protected] \
           --subject '$100'

Last month's report to [email protected]

Any CLI option opt can be set via a PRESTO_<OPT> environment variable in .env (e.g. PRESTO_TO, PRESTO_FROM, etc.) as defaults. See .env.example.

docker run --rm --privileged --env-file .env pndurette/presto-report --lastmonth

Caveats

The error management in this piece of software is piss-poor at best. Effort was made to pre-validate the input, but that's about it. If it hangs, CTRL-C and check your parameters (username, password, api keys) but also the network, etc. Timeouts are also possible. Please note that is also my first forray into NodeJS.

This only supports PRESTO card accounts with one card set up as I don't have a second one to test.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.