pub struct Posting {
pub account: Account,
pub units: Option<IncompleteAmount>,
pub cost: Option<CostSpec>,
pub price: Option<PriceAnnotation>,
pub flag: Option<char>,
pub meta: Metadata,
pub comments: Vec<String>,
pub trailing_comments: Vec<String>,
}Expand description
A posting within a transaction.
Postings represent the individual legs of a transaction. Each posting specifies an account and optionally an amount, cost, and price.
When the units are None, the entire amount will be inferred by the
interpolation algorithm to balance the transaction. When units is
Some(IncompleteAmount), it may still have missing components that
need to be filled in.
Fields§
§account: AccountThe account for this posting
units: Option<IncompleteAmount>The units (may be incomplete or None for auto-calculated postings)
cost: Option<CostSpec>Cost specification for the position
price: Option<PriceAnnotation>Price annotation (@ or @@)
flag: Option<char>Whether this posting has the “!” flag
meta: MetadataPosting metadata
comments: Vec<String>Comments that appear before this posting (one per line)
trailing_comments: Vec<String>Trailing comment(s) on the same line as the posting
Implementations§
Source§impl Posting
impl Posting
Sourcepub fn new(account: impl Into<Account>, units: Amount) -> Self
pub fn new(account: impl Into<Account>, units: Amount) -> Self
Create a new posting with the given account and complete units.
Sourcepub fn with_incomplete(
account: impl Into<Account>,
units: IncompleteAmount,
) -> Self
pub fn with_incomplete( account: impl Into<Account>, units: IncompleteAmount, ) -> Self
Create a new posting with an incomplete amount.
Sourcepub fn auto(account: impl Into<Account>) -> Self
pub fn auto(account: impl Into<Account>) -> Self
Create a posting without any amount (to be fully interpolated).
Sourcepub fn with_cost(self, cost: CostSpec) -> Self
pub fn with_cost(self, cost: CostSpec) -> Self
Add a cost specification.
Consuming builder — takes self by value and returns Posting.
To apply this to a Spanned<Posting> while preserving its source
location, use crate::Spanned::map:
let spanned: Spanned<Posting> = Spanned::synthesized(
Posting::new("Assets:Stock", Amount::new(dec!(10), "AAPL"))
);
let with_cost: Spanned<Posting> = spanned.map(|p| p.with_cost(cost));Sourcepub fn with_price(self, price: PriceAnnotation) -> Self
pub fn with_price(self, price: PriceAnnotation) -> Self
Add a price annotation.
See Self::with_cost for the Spanned<Posting> pattern.
Sourcepub const fn with_flag(self, flag: char) -> Self
pub const fn with_flag(self, flag: char) -> Self
Add a flag.
See Self::with_cost for the Spanned<Posting> pattern.
Trait Implementations§
Source§impl Archive for Posting
impl Archive for Posting
Source§const COPY_OPTIMIZATION: CopyOptimization<Self>
const COPY_OPTIMIZATION: CopyOptimization<Self>
serialize. Read moreSource§type Archived = ArchivedPosting
type Archived = ArchivedPosting
Source§type Resolver = PostingResolver
type Resolver = PostingResolver
Source§impl<'de> Deserialize<'de> for Posting
impl<'de> Deserialize<'de> for Posting
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<Posting, __D> for Archived<Posting>where
Account: Archive,
<Account as Archive>::Archived: Deserialize<Account, __D>,
Option<IncompleteAmount>: Archive,
<Option<IncompleteAmount> as Archive>::Archived: Deserialize<Option<IncompleteAmount>, __D>,
Option<CostSpec>: Archive,
<Option<CostSpec> as Archive>::Archived: Deserialize<Option<CostSpec>, __D>,
Option<PriceAnnotation>: Archive,
<Option<PriceAnnotation> as Archive>::Archived: Deserialize<Option<PriceAnnotation>, __D>,
Option<char>: Archive,
<Option<char> as Archive>::Archived: Deserialize<Option<char>, __D>,
Metadata: Archive,
<Metadata as Archive>::Archived: Deserialize<Metadata, __D>,
Vec<String>: Archive,
<Vec<String> as Archive>::Archived: Deserialize<Vec<String>, __D>,
impl<__D: Fallible + ?Sized> Deserialize<Posting, __D> for Archived<Posting>where
Account: Archive,
<Account as Archive>::Archived: Deserialize<Account, __D>,
Option<IncompleteAmount>: Archive,
<Option<IncompleteAmount> as Archive>::Archived: Deserialize<Option<IncompleteAmount>, __D>,
Option<CostSpec>: Archive,
<Option<CostSpec> as Archive>::Archived: Deserialize<Option<CostSpec>, __D>,
Option<PriceAnnotation>: Archive,
<Option<PriceAnnotation> as Archive>::Archived: Deserialize<Option<PriceAnnotation>, __D>,
Option<char>: Archive,
<Option<char> as Archive>::Archived: Deserialize<Option<char>, __D>,
Metadata: Archive,
<Metadata as Archive>::Archived: Deserialize<Metadata, __D>,
Vec<String>: Archive,
<Vec<String> as Archive>::Archived: Deserialize<Vec<String>, __D>,
impl Eq for Posting
Source§impl ShiftSpans for Posting
impl ShiftSpans for Posting
impl StructuralPartialEq for Posting
Auto Trait Implementations§
impl Freeze for Posting
impl RefUnwindSafe for Posting
impl Send for Posting
impl Sync for Posting
impl Unpin for Posting
impl UnsafeUnpin for Posting
impl UnwindSafe for Posting
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.