@@ -239,9 +239,29 @@ instance Show Status where -- custom show.. bad idea.. don't do it..
239
239
240
240
-- | The amount to compare an account's balance to, to verify that the history
241
241
-- leading to a given point is correct or to set the account to a known value.
242
+ --
243
+ -- Different kinds of balance assertion (from #290):
244
+ --
245
+ -- * simple assertions: single-commodity, non-total, subaccount-exclusive
246
+ -- assertions, as in Ledger (syntax: `=`). See definitions below.
247
+ --
248
+ -- * subaccount-inclusive assertions: asserting the balance of an account
249
+ -- including all its subaccounts' balances. Not implemented, proposed by #290.
250
+ --
251
+ -- * multicommodity assertions: writing multiple amounts separated by + to
252
+ -- assert a multicommodity balance, in a single assertion. Not implemented,
253
+ -- proposed by #934. In current hledger you can assert a multicommodity
254
+ -- balance by using multiple postings/assertions. But in either case, the
255
+ -- balance might contain additional unasserted commodities. To disallow that
256
+ -- you need...
257
+ --
258
+ -- * total assertions: asserting that the balance is as written, with no extra
259
+ -- commodities in the account. Added by #902, with syntax `==`. I sometimes
260
+ -- wish this was the default behaviour, of `=`.
261
+ --
242
262
data BalanceAssertion = BalanceAssertion {
243
- baamount :: Amount , -- ^ the expected value of a particular commodity
244
- baexact :: Bool , -- ^ whether the assertion is exclusive, and doesn't allow other commodities alongside 'baamount'
263
+ baamount :: Amount , -- ^ the expected balance of a single commodity
264
+ baexact :: Bool , -- ^ whether the assertion is total, ie disallowing amounts in other commodities
245
265
baposition :: GenericSourcePos
246
266
} deriving (Eq ,Typeable ,Data ,Generic ,Show )
247
267
@@ -256,7 +276,8 @@ data Posting = Posting {
256
276
pcomment :: Text , -- ^ this posting's comment lines, as a single non-indented multi-line string
257
277
ptype :: PostingType ,
258
278
ptags :: [Tag ], -- ^ tag names and values, extracted from the comment
259
- pbalanceassertion :: Maybe BalanceAssertion , -- ^ optional: the expected balance in this commodity in the account after this posting
279
+ pbalanceassertion :: Maybe BalanceAssertion , -- ^ an expected balance in the account after this posting,
280
+ -- in a single commodity, excluding subaccounts.
260
281
ptransaction :: Maybe Transaction , -- ^ this posting's parent transaction (co-recursive types).
261
282
-- Tying this knot gets tedious, Maybe makes it easier/optional.
262
283
porigin :: Maybe Posting -- ^ When this posting has been transformed in some way
0 commit comments