Coder Social home page Coder Social logo

stte's Introduction

Simple Toy Transactions Engine

Requirements interpretation

Dispute deposit assumptions

When disputed transaction amount > client available amount => allow negative number in available amount.

Dispute withdrawal assumptions

Provided dispute process describes/matches only handling/reversing of deposit transactions. Assuming handling of withdrawals:

The only action in the whole dispute withdrawal handling is to increase available amount (= reverse withdrawal) and lock account on chargeback. Starting the dispute changes only dispute_state of the transaction.

Creating new client considerations

Currently, a new client is created irrespectively of transaction type if one for particular client id does not exist. However, new client should probably be created only when processing Deposit type of transactions...

Implementation notes

Using type system for checking input file correctness. Checking presence and validity of the amount field for deposit/withdrawal transactions programmatically. Field amount and internally stored amounts use type Decimal from crate rust_decimal. See crate description: "Decimal number implementation written in pure Rust suitable for financial and fixed-precision calculations."

Error handling with crate thiserror.

Testing

Testing correctness of transaction processing with unit tests.

$ cargo test

Testing checking of input csv file validity with invalid input files in data folder.

$ NUM=1
$ cargo run -- data/input-invalid${NUM}.csv

Testing more complicated transaction "flows" with data/input-flow?.csv / data/output-flow?.csv files.

Running

$ cargo run -- transactions.csv > accounts.csv

stte's People

Contributors

ohirjak avatar

Watchers

 avatar

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.