pub struct Transaction {
pub date: NaiveDate,
pub flag: char,
pub payee: Option<InternedStr>,
pub narration: InternedStr,
pub tags: Vec<Tag>,
pub links: Vec<Link>,
pub meta: Metadata,
pub postings: Vec<Spanned<Posting>>,
pub trailing_comments: Vec<String>,
}Expand description
A transaction directive.
Transactions are the most common directive type. They record transfers between accounts and must balance (sum of all postings equals zero).
Fields§
§date: NaiveDateTransaction date
flag: charTransaction flag (* or !)
payee: Option<InternedStr>Payee (optional)
narration: InternedStrNarration (description)
Tags attached to this transaction
links: Vec<Link>Links attached to this transaction
meta: MetadataTransaction metadata
postings: Vec<Spanned<Posting>>Postings (account entries), each wrapped with its source span and
file ID. Parser-emitted postings carry the byte range of the
posting line (from leading indent through trailing same-line
comment, not including following metadata lines); programmatically
constructed postings use crate::Spanned::synthesized which
pairs crate::Span::ZERO with crate::SYNTHESIZED_FILE_ID.
trailing_comments: Vec<String>Comments that appear after all postings
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub fn new(date: NaiveDate, narration: impl Into<InternedStr>) -> Self
pub fn new(date: NaiveDate, narration: impl Into<InternedStr>) -> Self
Create a new transaction.
Sourcepub fn with_payee(self, payee: impl Into<InternedStr>) -> Self
pub fn with_payee(self, payee: impl Into<InternedStr>) -> Self
Set the payee.
Sourcepub fn with_posting(self, posting: Spanned<Posting>) -> Self
pub fn with_posting(self, posting: Spanned<Posting>) -> Self
Add a posting that already carries source location metadata. Use this when constructing transactions from source (e.g. a parser implementation) or when round-tripping through a plugin that preserves spans.
Sourcepub fn with_synthesized_posting(self, posting: Posting) -> Self
pub fn with_synthesized_posting(self, posting: Posting) -> Self
Add a programmatically-built posting (no source representation),
wrapping it with crate::Spanned::synthesized. Use this from
test fixtures, CLI commands, and importers that build directives
in memory rather than parsing them. The name is intentionally
longer than Self::with_posting so that synthesis is visible
at the call site — silently dropping a real span is the foot-gun
this rename prevents.
Sourcepub const fn is_complete(&self) -> bool
pub const fn is_complete(&self) -> bool
Check if this transaction is marked as complete (*).
Sourcepub const fn is_incomplete(&self) -> bool
pub const fn is_incomplete(&self) -> bool
Check if this transaction is marked as incomplete/pending (!).
Sourcepub const fn is_pending(&self) -> bool
pub const fn is_pending(&self) -> bool
Check if this transaction is marked as pending (!).
Alias for is_incomplete.
Sourcepub const fn is_summarization(&self) -> bool
pub const fn is_summarization(&self) -> bool
Check if this is a summarization transaction (S).
Sourcepub const fn is_transfer(&self) -> bool
pub const fn is_transfer(&self) -> bool
Check if this is a transfer transaction (T).
Sourcepub const fn is_conversion(&self) -> bool
pub const fn is_conversion(&self) -> bool
Check if this is a currency conversion transaction (C).
Sourcepub const fn is_unrealized(&self) -> bool
pub const fn is_unrealized(&self) -> bool
Check if this is an unrealized gains transaction (U).
Sourcepub const fn is_bookmarked(&self) -> bool
pub const fn is_bookmarked(&self) -> bool
Check if this transaction is bookmarked (#).
Sourcepub const fn needs_investigation(&self) -> bool
pub const fn needs_investigation(&self) -> bool
Check if this transaction needs investigation (?).
Sourcepub const fn is_valid_flag(flag: char) -> bool
pub const fn is_valid_flag(flag: char) -> bool
Check if the given character is a valid transaction flag.
Trait Implementations§
Source§impl Archive for Transactionwhere
AsNaiveDate: ArchiveWith<NaiveDate>,
char: Archive,
AsOptionInternedStr: ArchiveWith<Option<InternedStr>>,
AsInternedStr: ArchiveWith<InternedStr>,
Vec<Tag>: Archive,
Vec<Link>: Archive,
Metadata: Archive,
Vec<Spanned<Posting>>: Archive,
Vec<String>: Archive,
impl Archive for Transactionwhere
AsNaiveDate: ArchiveWith<NaiveDate>,
char: Archive,
AsOptionInternedStr: ArchiveWith<Option<InternedStr>>,
AsInternedStr: ArchiveWith<InternedStr>,
Vec<Tag>: Archive,
Vec<Link>: Archive,
Metadata: Archive,
Vec<Spanned<Posting>>: Archive,
Vec<String>: Archive,
Source§type Archived = ArchivedTransaction
type Archived = ArchivedTransaction
Source§type Resolver = TransactionResolver
type Resolver = TransactionResolver
Source§fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
Source§const COPY_OPTIMIZATION: CopyOptimization<Self> = _
const COPY_OPTIMIZATION: CopyOptimization<Self> = _
serialize. Read moreSource§impl Clone for Transaction
impl Clone for Transaction
Source§fn clone(&self) -> Transaction
fn clone(&self) -> Transaction
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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>,
Source§impl<__D: Fallible + ?Sized> Deserialize<Transaction, __D> for Archived<Transaction>where
AsNaiveDate: ArchiveWith<NaiveDate> + DeserializeWith<<AsNaiveDate as ArchiveWith<NaiveDate>>::Archived, NaiveDate, __D>,
char: Archive,
<char as Archive>::Archived: Deserialize<char, __D>,
AsOptionInternedStr: ArchiveWith<Option<InternedStr>> + DeserializeWith<<AsOptionInternedStr as ArchiveWith<Option<InternedStr>>>::Archived, Option<InternedStr>, __D>,
AsInternedStr: ArchiveWith<InternedStr> + DeserializeWith<<AsInternedStr as ArchiveWith<InternedStr>>::Archived, InternedStr, __D>,
Vec<Tag>: Archive,
<Vec<Tag> as Archive>::Archived: Deserialize<Vec<Tag>, __D>,
Vec<Link>: Archive,
<Vec<Link> as Archive>::Archived: Deserialize<Vec<Link>, __D>,
Metadata: Archive,
<Metadata as Archive>::Archived: Deserialize<Metadata, __D>,
Vec<Spanned<Posting>>: Archive,
<Vec<Spanned<Posting>> as Archive>::Archived: Deserialize<Vec<Spanned<Posting>>, __D>,
Vec<String>: Archive,
<Vec<String> as Archive>::Archived: Deserialize<Vec<String>, __D>,
impl<__D: Fallible + ?Sized> Deserialize<Transaction, __D> for Archived<Transaction>where
AsNaiveDate: ArchiveWith<NaiveDate> + DeserializeWith<<AsNaiveDate as ArchiveWith<NaiveDate>>::Archived, NaiveDate, __D>,
char: Archive,
<char as Archive>::Archived: Deserialize<char, __D>,
AsOptionInternedStr: ArchiveWith<Option<InternedStr>> + DeserializeWith<<AsOptionInternedStr as ArchiveWith<Option<InternedStr>>>::Archived, Option<InternedStr>, __D>,
AsInternedStr: ArchiveWith<InternedStr> + DeserializeWith<<AsInternedStr as ArchiveWith<InternedStr>>::Archived, InternedStr, __D>,
Vec<Tag>: Archive,
<Vec<Tag> as Archive>::Archived: Deserialize<Vec<Tag>, __D>,
Vec<Link>: Archive,
<Vec<Link> as Archive>::Archived: Deserialize<Vec<Link>, __D>,
Metadata: Archive,
<Metadata as Archive>::Archived: Deserialize<Metadata, __D>,
Vec<Spanned<Posting>>: Archive,
<Vec<Spanned<Posting>> as Archive>::Archived: Deserialize<Vec<Spanned<Posting>>, __D>,
Vec<String>: Archive,
<Vec<String> as Archive>::Archived: Deserialize<Vec<String>, __D>,
Source§fn deserialize(
&self,
deserializer: &mut __D,
) -> Result<Transaction, <__D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut __D, ) -> Result<Transaction, <__D as Fallible>::Error>
Source§impl Display for Transaction
impl Display for Transaction
impl Eq for Transaction
Source§impl PartialEq for Transaction
impl PartialEq for Transaction
Source§fn eq(&self, other: &Transaction) -> bool
fn eq(&self, other: &Transaction) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for Transaction
impl Serialize for Transaction
Source§impl<__S: Fallible + ?Sized> Serialize<__S> for Transactionwhere
AsNaiveDate: SerializeWith<NaiveDate, __S>,
char: Serialize<__S>,
AsOptionInternedStr: SerializeWith<Option<InternedStr>, __S>,
AsInternedStr: SerializeWith<InternedStr, __S>,
Vec<Tag>: Serialize<__S>,
Vec<Link>: Serialize<__S>,
Metadata: Serialize<__S>,
Vec<Spanned<Posting>>: Serialize<__S>,
Vec<String>: Serialize<__S>,
impl<__S: Fallible + ?Sized> Serialize<__S> for Transactionwhere
AsNaiveDate: SerializeWith<NaiveDate, __S>,
char: Serialize<__S>,
AsOptionInternedStr: SerializeWith<Option<InternedStr>, __S>,
AsInternedStr: SerializeWith<InternedStr, __S>,
Vec<Tag>: Serialize<__S>,
Vec<Link>: Serialize<__S>,
Metadata: Serialize<__S>,
Vec<Spanned<Posting>>: Serialize<__S>,
Vec<String>: Serialize<__S>,
Source§impl ShiftSpans for Transaction
impl ShiftSpans for Transaction
impl StructuralPartialEq for Transaction
Auto Trait Implementations§
impl Freeze for Transaction
impl RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnsafeUnpin for Transaction
impl UnwindSafe for Transaction
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read moreSource§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.