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.
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
jsonPath
is a mandatory argument to run the script
balances <jsonPath>
To get help
balances --help
To get version
balances --version
To set a different max file size in Mb (default is 1)
balances --version
- Clone the repo
git clone https://github.com/FranRom/transactions-cli.git
- Install dependencies
npm install
- Build
npm run build
- Run the script
node dist/index.js <path-to-JSON-file>
or
npm run balances <path-to-JSON-file>
- You can install the CLI locally (Optional)
npm run local
so then you can run the script with
balances <path-to-JSON-file>
- To develop you can run nodemon watch
npm run start
To run the tests
npm run test
To run tests in watch mode
npm run test:watch
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