Split

Struct Split 

Source
pub struct Split { /* private fields */ }
Expand description

A GnuCash Split - a single entry in a transaction.

A Split represents one side of a double-entry transaction, linking an amount to an account. Each Split has both an ‘amount’ (in the account’s commodity) and a ‘value’ (in the transaction’s currency).

Implementations§

Source§

impl Split

Source

pub fn new(book: &Book) -> Self

Creates a new Split in the given book.

Source

pub unsafe fn from_raw(ptr: *mut Split, owned: bool) -> Option<Self>

Creates a Split wrapper from a raw pointer.

§Safety

The pointer must be valid and point to a properly initialized Split.

Source

pub fn as_ptr(&self) -> *mut Split

Returns the raw pointer to the underlying Split.

Source

pub fn guid(&self) -> Guid

Returns the GUID of this split.

Source

pub fn reinit(&self)

Reinitializes the split to default values.

Source

pub fn account(&self) -> Option<Account>

Returns the account this split belongs to.

Source

pub fn set_account(&self, account: &Account)

Sets the account for this split.

Source

pub fn transaction(&self) -> Option<Transaction>

Returns the parent transaction of this split.

Source

pub fn set_transaction(&self, trans: &Transaction)

Sets the parent transaction for this split.

Source

pub fn book(&self) -> Option<Book>

Returns the book this split belongs to.

Source

pub fn memo(&self) -> Option<String>

Returns the split memo.

Source

pub fn set_memo(&self, memo: &str)

Sets the split memo.

§Panics

Panics if memo contains a null byte.

Source

pub fn action(&self) -> Option<String>

Returns the split action (e.g., “Buy”, “Sell”, “Deposit”).

Source

pub fn set_action(&self, action: &str)

Sets the split action.

§Panics

Panics if action contains a null byte.

Source

pub fn split_type(&self) -> Option<String>

Returns the split type (“normal” or “stock-split”).

Source

pub fn make_stock_split(&self)

Marks this split as a stock split.

Source

pub fn amount(&self) -> Numeric

Returns the amount in the account’s commodity.

Source

pub fn set_amount(&self, amount: Numeric)

Sets the amount in the account’s commodity.

Source

pub fn value(&self) -> Numeric

Returns the value in the transaction’s currency.

Source

pub fn set_value(&self, value: Numeric)

Sets the value in the transaction’s currency.

Source

pub fn share_price(&self) -> Numeric

Returns the share price (value / amount).

Source

pub fn set_share_price_and_amount(&self, price: Numeric, amount: Numeric)

Sets both share price and amount simultaneously.

Source

pub fn balance(&self) -> Numeric

Returns the running balance up to and including this split.

Source

pub fn noclosing_balance(&self) -> Numeric

Returns the running balance excluding closing transactions.

Source

pub fn cleared_balance(&self) -> Numeric

Returns the cleared balance (cleared + reconciled splits).

Source

pub fn reconciled_balance(&self) -> Numeric

Returns the reconciled balance (only reconciled splits).

Source

pub fn reconcile_state(&self) -> char

Returns the reconcile state (‘n’, ‘c’, ‘y’, ‘f’, ‘v’).

Source

pub fn set_reconcile_state(&self, state: char)

Sets the reconcile state.

Source

pub fn date_reconciled(&self) -> i64

Returns the date when this split was reconciled.

Source

pub fn set_date_reconciled(&self, time: i64)

Sets the date when this split was reconciled.

Source

pub fn is_reconciled(&self) -> bool

Returns true if this split is reconciled.

Source

pub fn is_cleared(&self) -> bool

Returns true if this split is cleared.

Source

pub fn other_split(&self) -> Option<Split>

Returns the other split in a two-split transaction. Returns None if the transaction has more than two splits.

Source

pub fn corr_account_full_name(&self) -> Option<String>

Returns the full name of the corresponding account.

Source

pub fn corr_account_name(&self) -> Option<String>

Returns the name of the corresponding account.

Source

pub fn corr_account_code(&self) -> Option<String>

Returns the code of the corresponding account.

Source

pub fn void_former_amount(&self) -> Numeric

Returns the original amount before voiding.

Source

pub fn void_former_value(&self) -> Numeric

Returns the original value before voiding.

Source

pub fn has_peers(&self) -> bool

Returns true if this split has peer splits.

Source

pub fn is_peer(&self, other: &Split) -> bool

Returns true if the other split is a peer of this one.

Source

pub fn add_peer(&self, other: &Split, timestamp: i64)

Adds a peer split to this split’s lot-split list.

Source

pub fn remove_peer(&self, other: &Split)

Removes a peer split from this split’s lot-split list.

Trait Implementations§

Source§

impl Debug for Split

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Split

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Hash for Split

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Split

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Split

Source§

impl Send for Split

Auto Trait Implementations§

§

impl Freeze for Split

§

impl RefUnwindSafe for Split

§

impl !Sync for Split

§

impl Unpin for Split

§

impl UnwindSafe for Split

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.