+ }
+
+ impl Posting {
+ pub fn on(account: impl Into<Account>) -> Self {
+ let account = account.into();
+ let (flag, amount, cost, price) = Default::default();
+
+ Self {
+ flag,
+ account,
+ amount,
+ cost,
+ price,
+ }
+ }
+ }
+
+ impl Posting {
+ #[inline]
+ pub fn clear_amount(&mut self) -> &mut Self {
+ self.amount = Default::default();
+ self
+ }
+
+ #[inline]
+ pub fn clear_cost(&mut self) -> &mut Self {
+ self.cost = Default::default();
+ self
+ }
+
+ #[inline]
+ pub fn clear_flag(&mut self) -> &mut Self {
+ self.flag = Default::default();
+ self
+ }
+
+ #[inline]
+ pub fn clear_price(&mut self) -> &mut Self {
+ self.price = Default::default();
+ self
+ }
+
+ #[inline]
+ pub fn complete(&mut self) -> &mut Self {
+ self.set_flag(Flag::Complete)
+ }
+
+ #[inline]
+ pub fn incomplete(&mut self) -> &mut Self {
+ self.set_flag(Flag::Incomplete)
+ }
+
+ #[inline]
+ pub fn set_account(&mut self, account: impl Into<Account>) -> &mut Self {
+ self.account = account.into();
+ self
+ }
+
+ #[inline]
+ pub fn set_amount(&mut self, amount: Amount) -> &mut Self {
+ self.amount = Some(amount);
+ self
+ }
+
+ #[inline]
+ pub fn set_cost(&mut self, cost: CostBasis) -> &mut Self {
+ self.cost = Some(cost);
+ self
+ }
+
+ #[inline]
+ pub fn set_flag(&mut self, flag: Flag) -> &mut Self {
+ self.flag = Some(flag);
+ self
+ }
+
+ #[inline]
+ pub fn set_price(&mut self, price: Amount) -> &mut Self {
+ self.price = Some(price);
+ self
+ }