Struct bcheck::Transaction
source · pub struct Transaction {
pub date: DateTime<Local>,
pub check_number: Option<u32>,
pub category: Option<String>,
pub vendor: String,
pub memo: String,
pub amount: OrderedFloat<f64>,
pub transaction_type: TransactionType,
pub is_reconciled: bool,
}
Expand description
Represent a transaction made.
Fields§
§date: DateTime<Local>
§check_number: Option<u32>
§category: Option<String>
§vendor: String
§memo: String
§amount: OrderedFloat<f64>
§transaction_type: TransactionType
§is_reconciled: bool
Implementations§
source§impl Transaction
impl Transaction
sourcepub fn new() -> Transaction
pub fn new() -> Transaction
create empty Transaction object.
sourcepub fn from(
date: Option<&str>,
check_number: Option<u32>,
category: Option<&str>,
vendor: &str,
memo: &str,
amount: f64,
transaction_type: TransactionType,
is_reconciled: bool
) -> Result<Transaction, String>
pub fn from( date: Option<&str>, check_number: Option<u32>, category: Option<&str>, vendor: &str, memo: &str, amount: f64, transaction_type: TransactionType, is_reconciled: bool ) -> Result<Transaction, String>
Create a transaction object with given values. This function will throw an Error if a given date string is not in the proper format, which is “yyyy-mm-dd” or “yyyy-m-d”.
Example
let transaction = Transaction::from(None, Some(1260), Some("Opening Balance"), "Sam Hill Credit Union", "Open Account", 500 as f64, TransactionType::Deposit, false);
sourcepub fn from_string(s: &str) -> Transaction
pub fn from_string(s: &str) -> Transaction
create a transaction directly from a string.
Trait Implementations§
source§impl Clone for Transaction
impl Clone for Transaction
source§fn clone(&self) -> Transaction
fn clone(&self) -> Transaction
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for Transaction
impl Debug for Transaction
source§impl<'de> Deserialize<'de> for Transaction
impl<'de> Deserialize<'de> for Transaction
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for Transaction
impl Display for Transaction
source§impl Ord for Transaction
impl Ord for Transaction
source§fn cmp(&self, other: &Transaction) -> Ordering
fn cmp(&self, other: &Transaction) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for Transaction
impl PartialEq for Transaction
source§impl PartialOrd for Transaction
impl PartialOrd for Transaction
source§fn partial_cmp(&self, other: &Transaction) -> Option<Ordering>
fn partial_cmp(&self, other: &Transaction) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for Transaction
impl Serialize for Transaction
impl Eq for Transaction
impl StructuralEq for Transaction
Auto Trait Implementations§
impl RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnwindSafe for Transaction
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more