use rust_decimal;
use rust_decimal::prelude::*;
pub fn add(left: u64, right: u64) -> u64 {
left + right
}
pub fn fund(howmuch: rust_decimal::Decimal) -> bool {
if howmuch > dec!(0.0) {
return true;
} else {
return false;
}
}
pub struct Account {
pub name: String,
pub balance: rust_decimal::Decimal,
pub id: String,
}
pub struct Transaction {
pub amount: rust_decimal::Decimal,
pub description: String,
pub account: Account,
pub date: String,
pub category: String,
pub tags: Vec<String>,
pub from: Account,
}
impl Account {
pub fn new(name: String, balance: rust_decimal::Decimal, id: String) -> Account {
Account { name, balance, id }
}
}
impl Transaction {
pub fn new(
amount: rust_decimal::Decimal,
description: String,
account: Account,
date: String,
category: String,
tags: Vec<String>,
from: Account,
) -> Transaction {
Transaction {
amount,
description,
account,
date,
category,
tags,
from,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}