Commit graph

21 commits

Author SHA1 Message Date
Bruno BELANYI 8d89bdf31d doc: add 'README.md' 2022-08-23 16:50:58 +02:00
Bruno BELANYI e66f4f687d samples: add sample CSV files 2022-08-23 16:50:47 +02:00
Bruno BELANYI 1b7471dfb8 processor: implement CLI interface 2022-08-23 16:50:23 +02:00
Bruno BELANYI 211147db2c ledger: additional error-cases testing 2022-08-23 15:35:53 +02:00
Bruno BELANYI 12972a01c0 ledger: additional testing 2022-08-23 15:35:53 +02:00
Bruno BELANYI 6d98a05cee ledger: add dispute-related flow
It is unclear whether or deposits should be disputable, or only
withdrawals.

At the moment, both are disputable, but that does mean we can get into
"weird" states by disputing a deposit: the held funds being negative.

In turn, this means that there is relatively little error-checking for
those balance values, the only clear thing is that withdrawing more than
is currently available is absolutely an error. But is holding more than
is available also an error? What about having a negative held funds
balance? A negative total funds? Etc...
2022-08-23 15:35:53 +02:00
Bruno BELANYI 17e7bb9988 core: implement display for all core types 2022-08-23 15:35:53 +02:00
Bruno BELANYI 6df9c9d7a9 ledger: process deposits and withdrawals 2022-08-23 15:35:53 +02:00
Bruno BELANYI a00567cadc ledger: introduce 'Ledger' type
Unfortunately, rust-csv does not support serializing maps [1], so
instead of trying to write a `Deserialize` impl, the `dump_csv` method
takes care of formatting the output as expected.

[1]: https://github.com/BurntSushi/rust-csv/issues/98
2022-08-23 14:05:57 +02:00
Bruno BELANYI ab8ecf8121 transaction: use proper 'ParseError' type 2022-08-23 14:05:03 +02:00
Bruno BELANYI 19b5f3390d core: add arithmetic operators for 'TxAmount' 2022-08-23 14:05:03 +02:00
Bruno BELANYI 963748e1d9 core: define 'TxAmount::ZERO' 2022-08-23 14:05:03 +02:00
Bruno BELANYI ffd6a20a30 transaction: add CSV deserialization
It is unfortunate that both [1] and [2] conspire to make this code way
worse than it could otherwise be with a saner (de)serialization format.

We both need to introduce `TransactionRecord` due to tagged enums not
being powerful enough in CSV, and make its `amount` field optional to
deal with the varying number of fields for each kind of transaction.

[1]: https://github.com/BurntSushi/rust-csv/issues/211
[2]: https://github.com/BurntSushi/rust-csv/issues/172
2022-08-23 14:05:03 +02:00
Bruno BELANYI c7e64692e6 lib: add 'Transaction' variants
Represent each enum variant with its own type to allow stronger typing
when processing only a singular type of transactions.
2022-08-23 14:05:03 +02:00
Bruno BELANYI eae54b8ce0 lib: add core type definitions 2022-08-23 14:05:03 +02:00
Bruno BELANYI 1ea0505098 cargo: move 'processor' to 'bin' directory
I like to keep executables in their own folders, and the as much of the
business logic in a library at the root.
2022-08-22 17:49:06 +02:00
Bruno BELANYI c17a70bb39 cargo: add 'fpdec' dependency
Instead of implementing custom fixed-point decimal numbers, let's make
use of an existing implementation until it is deemed inappropriate.
2022-08-22 17:25:18 +02:00
Bruno BELANYI aedc20526a git: ignore generated files 2022-08-22 17:11:53 +02:00
Bruno BELANYI aae81e0e91 nix: add direnv integration 2022-08-22 17:11:53 +02:00
Bruno BELANYI e53634976c nix: init flake environment 2022-08-22 17:11:53 +02:00
Bruno BELANYI 7797f40d2e cargo: init build system 2022-08-22 17:11:53 +02:00