Skip to content

A command line tool that ingest a JSON file containing a list of credit/debit card transactions for a group of users, process the transactions and compute the final balances for each user.

Notifications You must be signed in to change notification settings

FranRom/transactions-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Screenshot 2022-09-08 at 12 22 41

balances-cli

A command line tool that ingest a JSON file containing a list of credit/debit card transactions for a group of users, process the transactions and compute the final balances for each user.

How it works

The JSON file must have an array of transactions, each transaction must have the following structure:

 {
  user_id: string
  timestamp: string
  currency: Currency
  amount: string
 }

where currency are limited to

 enum Currency {
  GBP = "GBP",
  EUR = 'EUR',
  USD = 'USD'
}
  • If a transaction have missing or malformed data the record will be discarded logging info about it.
  • Amount must be a string that contains negative or positive prefix and a number
  • Timestamp must be a string with valid UTC date-time as per ISO 8601
  • The maximum file size by default is 1Mb
  • The only file extension accepted is .json

The output will have one user per line and balances for each currency

Screenshot 2022-09-08 at 12 23 42

Usage

jsonPath is a mandatory argument to run the script

balances <jsonPath>

Options

Screenshot 2022-09-08 at 12 24 35

To get help

balances --help

To get version

balances --version

To set a different max file size in Mb (default is 1)

balances --version

Guetting started

  1. Clone the repo
 git clone https://github.com/FranRom/transactions-cli.git
  1. Install dependencies
 npm install
  1. Build
 npm run build
  1. Run the script
  node dist/index.js <path-to-JSON-file>

or

 npm run balances <path-to-JSON-file>
  1. You can install the CLI locally (Optional)
  npm run local

so then you can run the script with

  balances <path-to-JSON-file>
  1. To develop you can run nodemon watch
 npm run start

Tests

To run the tests

 npm run test

To run tests in watch mode

 npm run test:watch

Additional scripts

You can refresh the project with

 npm run refresh

This will remove node_modules and package-lock.json ending with npm install

You also can run a build + tests with

 npm run create

About

A command line tool that ingest a JSON file containing a list of credit/debit card transactions for a group of users, process the transactions and compute the final balances for each user.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published