Commit graph

1431 commits

Author SHA1 Message Date
John Wiegley
526cbc4c93 Restored min() and max() virtual functions 2010-06-13 23:35:22 -04:00
John Wiegley
6bbfb86d75 When parsing date expressions, assume current year 2010-06-13 23:33:06 -04:00
John Wiegley
ead42c27e3 Added a missing break statement
This broke the meaning of -p "this month".
2010-06-13 23:09:01 -04:00
John Wiegley
e3f228bd5b Fixed several misplaced parentheses 2010-06-13 19:56:10 -04:00
John Wiegley
2ea075dc4f Report error context in expressions more precisely 2010-06-13 18:39:26 -04:00
John Wiegley
cf0147fcd0 Removed an invalid called to VERIFY() 2010-06-13 05:57:02 -04:00
John Wiegley
2dec00a882 Fixes to scope.h for the sake of Boost.Serialization 2010-06-13 05:31:39 -04:00
John Wiegley
7146926fd5 Removed unneeded debug code 2010-06-13 05:25:36 -04:00
John Wiegley
ea1642b3f9 Completely reworked argument passing in expressions 2010-06-13 05:02:14 -04:00
John Wiegley
ad3b30a964 In value_t::_dup, test if storage is uninitialized 2010-06-13 05:01:54 -04:00
John Wiegley
4a44218da1 For value_t, use boost::any to refer to objects 2010-06-13 03:55:08 -04:00
John Wiegley
44a5103e1c Moved value_t::label() to value.cc 2010-06-13 03:54:36 -04:00
John Wiegley
f3fa011d39 Improved support for value_t::in_place* functions 2010-06-13 03:54:10 -04:00
John Wiegley
0c02b720ef Moved join_args function to precmd.cc 2010-06-13 03:53:08 -04:00
John Wiegley
0bb9c11062 Changed display order of format exceptions 2010-06-13 03:52:20 -04:00
John Wiegley
dcdd9c4a56 If a type context exists, confirm the result matches 2010-06-13 01:03:49 -04:00
John Wiegley
1bc5b894df Expression evaluations now have a "type context"
Thus, an expression can know if the context in which it's being
evaluated requires a string, and if so, determine it's output
accordingly.  For example:

  account       ; returns the full name of the posting's account
  account.total ; here the context is SCOPE, so account is an obj
2010-06-13 01:03:48 -04:00
John Wiegley
536e3e7322 Added a new scope_value() inline helper function 2010-06-13 01:03:48 -04:00
John Wiegley
6ef755c133 Added support for assert, check and expr directives
These can occur in many places:

  ; Within an automated transaction, the assert is evaluated every time
  ; a posting is matched, with the expression context set to the
  ; matching posting.
  = /Food/
    assert account("Expenses:Food").total >= $100

  2010-06-12 Sample
    Expenses:Food                $100
    Assets:Checking

  ; At file scope, the expression is evaluated with "global" scope.
  assert account("Expenses:Food").total == $100

  ; At the top of a transction, the assertion's scope is the
  ; transaction.  After a posting, the scope is that posting.  Note
  ; however that account totals are only adjusted after successful
  ; parsing of a transaction, which means that all the assertions below
  ; are true, even though it appears as though the middle posting should
  ; affect the total immediately (which is not the case).
  2010-06-12 Sample 2
    assert account("Expenses:Food").total == $100
    Expenses:Food                $50
    assert account("Expenses:Food").total == $100
    Assets:Checking
    assert account("Expenses:Food").total == $100
2010-06-13 01:03:48 -04:00
John Wiegley
6f56a7443f Removed an unused function 2010-06-13 01:03:48 -04:00
John Wiegley
8d2fce1ae8 Automated xacts may now contain "deferred tags"
For example, consider the following automated transaction:

  = /Food/
    ; Next Date:: date + 10
    (Expenses:Tax)                1.00
    ; Next Date:: date + 20

This will add a metadata field named 'Next Date' to the _matching
posting_, with a value that is 10 days later than that posting.  It will
also generate a new posting for that transaction, whose amount is the
same as the matching posting.  Further, it will add a 'Next Date'
metadata tag to the _generated posting_ whose value is 20 days later
than the date of the matching posting.
2010-06-13 01:03:48 -04:00
John Wiegley
5ec85538d9 account_t::add_post resets family_details.gathered 2010-06-13 01:03:48 -04:00
John Wiegley
15bf3ed39e account(NAME) function can lookup account objects
For example, just the word "account" returns the name of the current
posting's account, but account("Expenses:Food") returns the actual
account object, so that it's total may be accessed.
2010-06-13 01:03:47 -04:00
John Wiegley
9effdb3aa2 Option --input-date-format adds to candidate list 2010-06-13 01:03:47 -04:00
John Wiegley
1ced1f3d83 Reformatted a comment 2010-06-13 01:03:47 -04:00
John Wiegley
c558613ae4 Fixed a spelling error 2010-06-13 01:03:47 -04:00
John Wiegley
baad7272c7 Minor whitespace fix 2010-06-13 01:03:47 -04:00
John Wiegley
b1b4e2aadf Add support for typed metadata
The metadata construct 'Key: Value' is now just a special case for
'Key:: "Value"'.  Another after a :: in metadata setting is parsed as a
full value expression and typed as such.  For example:

  ; Key:: $400 + $500

  ledger -l 'tag("Key") < $1000'
2010-06-12 15:43:00 -04:00
John Wiegley
0555e7f61e Improved value expression function 'commodity'
Without arguments -- and in a posting -- it is equivalent to
"commodity(amount)".  Otherwise, it returns the commodity symbol of its
argument.
2010-06-12 14:58:44 -04:00
John Wiegley
28c65cda51 Store metadata values as value_t instead of string 2010-06-12 14:55:18 -04:00
John Wiegley
a1fc3c5cfe The --anon option now randomizes its effect 2010-06-12 14:43:40 -04:00
John Wiegley
1a60c9e82c Include serialize_ptr_deque, for Boost.Serialization 2010-06-12 00:51:36 -04:00
John Wiegley
dea2aed0b5 Untabified all source files 2010-06-11 17:02:25 -04:00
John Wiegley
d580079df8 Scrub account totals before applying --percent 2010-06-11 17:02:25 -04:00
John Wiegley
ab749742d9 Several corrections to transaction finalization 2010-06-10 16:33:46 -04:00
John Wiegley
92d2eb9574 Use ptr_deque for value_t::sequence_t
This is to work around undefined behavior according to the Standard,
[lib.res.on.functions]/2:

"In particular, the effects are undefined in the following cases: [..]
- if an incomplete type (3.9) is used as a template argument when
instantiating a template component."
2010-06-10 16:32:24 -04:00
John Wiegley
3e05dce72e gain/loss posting based on a virtual should also be 2010-06-10 14:45:44 -04:00
John Wiegley
bea90a2b98 Fixed the "generate" command 2010-06-10 14:28:07 -04:00
John Wiegley
685b12d8d3 Allow fixated costs, as well as prices
You can now establish a fixated price automatically by way of a fixated
cost.  The syntax for this is:

  2009/11/01 Sample
      Assets                1 apple @ =$0.10
      Equity
2010-06-10 12:29:58 -04:00
John Wiegley
a2bcfe4338 Increase item_t's flags to 16-bit 2010-06-10 12:04:00 -04:00
John Wiegley
4da78bb881 Corrected behavior of "draft" argument parser 2010-06-10 11:34:09 -04:00
John Wiegley
920dbc3f00 Corrected some math used by the budget command 2010-06-10 08:17:50 -04:00
John Wiegley
91a99fc88e Fix to budgeting when fixed dates are involved 2010-06-10 08:17:32 -04:00
John Wiegley
77c5df4053 Errors involving value objects provide more context 2010-06-10 08:16:59 -04:00
John Wiegley
7be17fd779 Corrections to the way error strings are generated 2010-06-10 08:16:26 -04:00
John Wiegley
c28fad384c The --anon option now anonymizes commodities
Fixes #227 / 1C90D8AF-830E-43C2-A5B7-D382F68EBDE3
2010-06-09 07:47:45 -04:00
John Wiegley
8637dd6ccf New display flag AMOUNT_PRINT_ELIDE_COMMODITY_QUOTES
This is used by reports like register and balance so that separated
commodities without spaces in them needed be surrounded by quotes.  It
will still occur in most other places.

Fixes #200 / F82CF11F-BFD9-4512-A562-202B04B68051
2010-06-09 06:45:07 -04:00
John Wiegley
da2f415f14 In value_t::print, pass along display flags 2010-06-09 06:36:40 -04:00
John Wiegley
158b9c92fd Fixed minor rounding issue with priced commodities 2010-06-09 03:39:17 -04:00
John Wiegley
659741ac47 Insert <Rounding> posts within the affected xact 2010-06-09 02:25:53 -04:00