- For now, we can only dispute
deposit
transaction. Technically it's okay to dipsute both deposit and withdrawl transaction but the guidline description seemed to be only for deposit transactoin. Hence I choose to dispute only deposit transaction to be clear and minimum - New transaction is added and marked as
normal
status - Disputing any transaction other than normal status is an error
- After
resolving
adisputed
transaction, it becamenormal
status and we candispute
it again later - After
charging back
adisputed
transaction, any further transaction will be skipped and then pop an error - Using
f64
foramount
type but it migh haveoverflow
andround
problem. In reality, we should usestring
to be safe - When printing out to stdout, we use
format
macro to get a precision up to 4 places past to decimal
Running result will output to stdout
cargo run -- YOUR_CSV_FILE
#[derive(Error, Debug)]
pub enum PaymentError {
#[error("Duplicate transaction id, {0:?}")]
DuplicateTransaction(Transaction),
#[error("Insuffiecient balance, tx = {0:?}, availabe = {1}")]
InsuffiecientBalance(Transaction, Amount),
#[error("No such transaction id, txn = {0:?}")]
NoSuchTransactionID(Transaction),
#[error("Invalid disputed status, txn = {0:?}, current status = {1:?}")]
InvalidDisputeStatus(Transaction, DisputeStatus),
#[error("Account is locked after tx = {1}, txn={0:?}")]
Locked(Transaction, TransactionID), //
#[error("Unknown error")]
Unknown(Transaction, Option<TransactionInner>),
}