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 --helpTo get version
balances --versionTo 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 localso then you can run the script with
balances <path-to-JSON-file>- To develop you can run nodemon watch
npm run startTo run the tests
npm run testTo run tests in watch mode
npm run test:watchYou can refresh the project with
npm run refreshThis will remove node_modules and package-lock.json ending with npm install
You also can run a build + tests with
npm run create

