Commit graph

61 commits

Author SHA1 Message Date
John Wiegley
e2afc783db Increased file copyrights to 2012 2012-02-29 22:32:23 -06:00
John Wiegley
656e46e182 Renamed actual/effective dates to primary/auxiliary 2012-02-28 03:02:16 -06:00
John Wiegley
0efdc0cf6f The "id" of an item now maps to its UUID 2012-02-27 02:31:08 -06:00
John Wiegley
c3a9a7d2c5 Fixed many Clang type conversion warnings with static_cast 2012-02-17 15:17:52 -06:00
John Wiegley
6a9743d833 Fixes for variable shadowing (21/28) 2012-02-17 15:06:21 -06:00
John Wiegley
ad79230158 Fixes for variable shadowing (20/28) 2012-02-17 15:06:20 -06:00
John Wiegley
5e3e204766 Do not evaluate strings as booleans 2012-02-11 16:53:31 -10:00
John Wiegley
f0791bbd72 Cleanup whitespace 2011-08-18 14:48:38 -04:00
John Wiegley
c2b5b1a516 Whitespace corrections 2011-02-10 23:00:41 -05:00
John Wiegley
b80be82b8d has_tag and get_tag now take an 'inherit' parameter 2010-06-18 02:19:39 -04:00
John Wiegley
31e8ed7587 Individual postings may each have their own payee
If a posting has the metadata field "Payee" set to a string, that will
be used as the payee name for that posting.  This affects the register
report, the payees report, and the --by-payee option.

This is useful because sometimes I send, say, 4 checks at a time to my
bank.  So on my bank statement, this is all just one amount:

   2010-06-17 Sample
     Assets:Bank        $400.00
     Income:Check1     $-100.00
     Income:Check2     $-100.00
     Income:Check3     $-100.00
     Income:Check4     $-100.00

Though it's important that the Assets:Bank posting be a single posting
of $400 value, I'd like for income reports to show whom each check came
from.  Now I can say:

   2010-06-17 Sample
     Assets:Bank        $400.00
     Income:Check1     $-100.00  ; Payee: Person One
     Income:Check2     $-100.00  ; Payee: Person Two
     Income:Check3     $-100.00  ; Payee: Person Three
     Income:Check4     $-100.00  ; Payee: Person Four

When I report this, it appears as:

10-Jun-17 Sample             Assets:Bank             $400.00     $400.00
          Person One         Income:Check1          $-100.00     $300.00
          Person Two         Income:Check2          $-100.00     $200.00
          Person Three       Income:Check3          $-100.00     $100.00
          Person Four        Income:Check4          $-100.00           0

This shows that they are all in the same transaction (which is why the
date is not repeated), but they have different payees.
2010-06-17 23:42:23 -04:00
John Wiegley
2ea075dc4f Report error context in expressions more precisely 2010-06-13 18:39:26 -04:00
John Wiegley
ea1642b3f9 Completely reworked argument passing in expressions 2010-06-13 05:02:14 -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
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
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
dea2aed0b5 Untabified all source files 2010-06-11 17:02:25 -04:00
John Wiegley
fc09b69fb7 Fixed interaction with -V/X and grouped postings
With -s, -M/Y/D, -n, and a few other flags, postings get "grouped" into
meta-transactions that contain more postings than before.  In all these
cases, -V use the date of the *earliest* posting in that group, which
makes little sense and caused breakages with -J.  It now uses the latest
date.

Fixes #197 / 68EAF363-D0FE-4127-866E-A5AEBACB65D6
2010-06-09 02:22:50 -04:00
John Wiegley
4f3b39e22c Empty notes and tags now return null values 2010-05-30 03:01:11 -06:00
John Wiegley
b5c9be4d29 Created new valexpr variable display_account
Where display_account might be '(Expenses:Food)', account will always be
'Expenses:Food'.  account is now used by all matching and query
operations, while display_account is used in the various report outputs
(besides balance, which never distinguished virtual accounts).

Fixes F2832452-4521-49A3-B854-F4E12CC4D82E
2010-05-22 21:35:03 -04:00
John Wiegley
33aa0cc3a6 Changed the report generated by the csv command
Fields are now:

  Date,Code,Payee,Account,Commodity,Total,State,Note

Instead of outputting amounts potentially as $1,000.00 (which was an
error anyway), the output is now: $,1000.00.  This makes the commodity
available in a separate field, and removes display of thousands markers.
Also, european formatting is always off.
2010-05-22 21:35:02 -04:00
John Wiegley
47bfe58ab3 Added account_id and xact_id valexpr vars for posts
account_id is the "whicheth" number for that posting within its
account.  The xact_id is within its transaction.
2010-05-18 17:37:27 -04:00
John Wiegley
4ec54b86f8 Added any() and all() value expression macros
any() matches an expression against every post in a transaction or
account, and returns true if any of them are true.  all() tests if all
are true.  For example:

  ledger -l 'account =~ /Expense/ & any(account =~ /MasterCard/)' reg

This reports every posting affecting an Expense account (regex match),
but only if some other posting in the same transaction affects the
MasterCard account.

Both functions also take a second boolean argument.  If it is false, the
"source" posting is not considered.  For example:

  ledger -l 'any(/x/, false)'

This matches any posting where a *different* posting in the same
transaction contains the letter 'x'.
2010-05-08 02:06:06 -04:00
John Wiegley
75b7294a6d Rewrite the "print" command as a custom function
There ended up being too many corner cases for the generalized formatter
to handle.
2010-03-08 01:11:48 -05:00
John Wiegley
ab416f759f Updated copyrights to 2003-2010 2010-03-05 22:14:10 -05:00
John Wiegley
69da18cd30 Some minor refactoring of the textual parser 2010-02-05 00:00:40 -05:00
John Wiegley
9d61d3d621 Added actual_date() methods for items 2010-02-05 00:00:29 -05:00
John Wiegley
a461e17eee Added historical support for single-letter valexprs 2009-11-14 03:11:48 -05:00
John Wiegley
7cd37b1d50 Moving the #include of unistring.h into format.h 2009-11-10 18:43:38 -05:00
John Wiegley
294bf5a83d Whitespace fix 2009-11-10 02:42:09 -05:00
John Wiegley
bf24b93818 Fixes to the value expression parser and evaluator 2009-11-10 02:26:20 -05:00
John Wiegley
a5f0b6e5dc account_amount() is now account().amount 2009-11-10 01:28:57 -05:00
John Wiegley
6cdb79e2a6 XML reporting now works via the "xml" command 2009-11-09 03:42:35 -05:00
John Wiegley
c8641a6de6 Added support for Boost.Regex w/ ICU
This allows for correct searching of UTF-8 encoded strings, such as
lower-case versions of Russian words to find mixed-case words.
2009-11-07 08:34:13 -05:00
John Wiegley
4464ed187b If a posting's amount is null, return 0L 2009-11-05 05:11:15 -05:00
John Wiegley
78e6770c4c Segregated symbols into 5 separate namespaces
The different namespaces are:

  Function      Value expression functions, which receive a "context"
  Option        Command-line options
  Precommand    Commands which are invoked before reading the journal
  Command       Commands which are invoked after reading the journal
  Directive     Directives that occur at column 0 in a data file

This greatly eases the ability for Python uses to add intercept hooks to
change how the basic Ledger module functions.  An example of what should
be possible soon:

  import ledger

  def my_foo_handler(value):
      print "--foo received:", value

  ledger.add_handler(ledger.Option, "foo=", my_foo_handler)
2009-11-04 20:40:48 -05:00
John Wiegley
3a0879aff0 Added "reported posts" into account xdata
This is necessary because sometimes, a post from one account will get
reported as though it were in another account (this happens with
--budget, to show child account postings within their parent account).
In that case, the account needs to remember which postings have been
reported as being within it, so that it can add these amounts to its own
total in the balance report.
2009-11-02 01:40:07 -05:00
John Wiegley
39973b1277 A posting's note includes its parent xact's note 2009-11-01 21:17:31 -05:00
John Wiegley
3909d2678e Removed most #if 0 blocks and callout comments 2009-10-31 04:50:07 -04:00
John Wiegley
07cca71893 Renamed two methods, for consistency's sake 2009-10-27 21:33:33 -04:00
John Wiegley
ddfd00afe1 Made the id function available in post contexts 2009-10-27 04:00:59 -04:00
John Wiegley
588f2ef2f5 Fixed many compiler warnings from g++ 4.4 2009-10-25 05:01:39 -04:00
John Wiegley
521b935aa8 Restored --percent option, added baseline test 2009-06-21 18:07:27 +01:00
John Wiegley
1fd4387b67 Restored pricesdb command and --pricesdb-format option 2009-06-18 01:49:49 +01:00
John Wiegley
110f0b8023 Enabled use of pre-compiled headers by default 2009-03-10 17:02:03 -04:00
John Wiegley
2728e4d55e Changed the way that account balances are computed 2009-03-06 00:27:29 -04:00
John Wiegley
5167e6223b Enriched the behavior of post_t::add_to_value
The new behavior will be used in future by some pending topic branches
I'm working on.
2009-03-05 23:02:50 -04:00
John Wiegley
a2c7312080 Renamed some flags and members in post_t 2009-03-05 22:39:32 -04:00