Skip to content

kketch/sumac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSV Transactions Processor

This program processes a CSV file of transactions and outputs a CSV file of account summaries. The executable accepts a single argument: the path to the input CSV file.

Example usage:

cargo run -- <path_to_csv_file> > <path_to_output_csv_file>

The program reads the input CSV file and processes each row. If a row is invalid, it is written to stderr as a CSV row, and then the next rows are processed until the end of the input file. After the entire input file is processed, each resulting account summary is written to stdout as a CSV row.

There are several examples of input CSV files and resulting output files in the tests/cases folder.

Supported transactions on an account

The following transactions are supported:

  • Deposit: adding funds to the account
  • Withdrawal: removing funds from the account
  • Dispute: reports a deposit or withdrawal transaction for review
    • When a deposit is disputed, the funds are immediately held until the dispute is resolved
    • When a withdrawal is disputed, there are no funds held, only when the dispute outcome is a chargeback is the withdrawal reversed by crediting the account with the previously withdrawn amount
  • Resolve: resolves a previously raised dispute for a deposit or withdrawal transaction
    • When a deposit dispute is resolved, the held funds are released
  • Chargeback: rejecting a disputed transaction
    • When a chargeback is issued, the client is immediately frozen and will no longer accept any new transactions of any type
    • When a chargeback is issued for a deposit, the held funds on the account are debited from the account balance
    • When a chargeback is issued for a withdrawal, the account balance is credited with the previously withdrawn amount

Tests

Invariants are enforced structurally through the type system where possible, and business logic is further validated using unit tests.

There are also several integration test cases in the tests/cases folder. A test case typically has an input CSV file named with the test case name and matching stdout and stderr output files. The test runner runs each test case and compares the output to the expected output.

All tests (unit & integration) can be run using cargo test.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages