Commit graph

231 commits

Author SHA1 Message Date
John Wiegley
37e9ec8030 Report an error in the case of '(1' (missing rparen)
Fixes #557
2011-11-10 00:48:19 -06:00
John Wiegley
8c4e145c57 Added round() and unround() valexpr functions 2011-10-24 15:22:18 -05:00
John Wiegley
f0791bbd72 Cleanup whitespace 2011-08-18 14:48:38 -04:00
John Wiegley
dafe7c891a Added "top_amount" value expr function 2010-12-22 15:32:34 -05:00
John Wiegley
bd5a136ad0 Move balance divider right by prepend-width 2010-06-26 00:36:55 -04:00
John Wiegley
8a29c03490 Added "format" value expression function
This function evaluates formatting strings, returning a string.  For
example:

  format("%(amount)")

This is equivalent to "to_string(amount)".
2010-06-24 20:37:31 -04:00
John Wiegley
2f50e30b89 Scopes can now provide a description of themselves
This isn't being used yet, but it likely will to improve the information
presented to users if their value expressions fail to compile or
evaluate.
2010-06-24 19:53:59 -04:00
John Wiegley
e8e28c794b Added report query modifiers: for, since, until
Now instead of ledger reg expense -p "this month", you can say:

  ledger reg expense for this month

And as a shorthand for "for until this month", you can just say "until
this month" or "since this month".
2010-06-22 21:56:19 -04:00
John Wiegley
81bf38584e Added new --bold-if option 2010-06-22 01:27:05 -04:00
John Wiegley
963161a817 bal was sometimes reporting empty accounts 2010-06-21 18:32:03 -04:00
John Wiegley
9205809d49 Fixed register formatting of postings with payees 2010-06-18 07:27:35 -04:00
John Wiegley
5da1e7756d Added new option --inject=KEY[,KEY...]
If you have a typed metadata key which contains an amount, you can use
--inject=KEY to inject a posting with that amount wherever a match
occurs.  There are two main forms of usage:

  2010-06-18 Sample
      ; Key:: $100
      Expenses:Food                $100.00
      Assets:Checking

The command would be:

  ledger reg --inject=Key

In the above, transactional form, a posting under the account "Key" will
be injected before the first posting reported for this transaction.
It's amount will be $100.  This only happens once for the whole
transaction.

It is also possible to associate the key with a posting:

  2010-06-18 Sample
      Expenses:Food                $100.00
      ; Key:: $100
      Assets:Checking

Now the injected posting is generated whenever that particular post is
reported.
2010-06-18 02:28:12 -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
34fcc62b4d Removed unused --unsorted option 2010-06-15 04:34:16 -04:00
John Wiegley
dcffd218a1 Revised how Ledger handles the "current year"
Now when the Y directive sets the current year for a region, it affects
everything, as if the clock really were set back to that year.
2010-06-14 03:23:09 -04:00
John Wiegley
ea1642b3f9 Completely reworked argument passing in expressions 2010-06-13 05:02:14 -04:00
John Wiegley
536e3e7322 Added a new scope_value() inline helper function 2010-06-13 01:03:48 -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
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
bea90a2b98 Fixed the "generate" command 2010-06-10 14:28:07 -04:00
John Wiegley
920dbc3f00 Corrected some math used by the budget command 2010-06-10 08:17:50 -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
4197c88511 Corrected implementation of --percent 2010-06-06 06:05:51 -04:00
John Wiegley
dbac09405f Added new command: "pricemap [DATE]"
This outputs the pricing relationship of commodities in your data file,
as of DATE (optional), using the DOT language.  If you have graphviz
installed, it can be viewed quite simply using:

  ledger pricemap | dotty -

Each relationship in the graph shows the conversion factor to exchange
one commodity for another, and the date at which this factor was
determined.
2010-06-04 02:53:18 -04:00
John Wiegley
647d4aac2f New: --group-by=EXPR and --group-title-format=FMT
The --group-by option allows for most reports to be split up into
sections based on the varying value of EXPR.  For example, to see
register subtotals by payee, use:

  ledger reg --group-by=payee -s

This works for separated balances too:

  ledger bal --group-by=payee

Another interesting possibility is seeing a register of all the accounts
affected by a related account:

  ledger reg -r --group-by=payee

The option --group-title-format can be used to add a separator bar to
the group titles.  The option --no-titles can be used to drop titles
altogether.
2010-05-30 02:47:40 -06:00
John Wiegley
a41d33fba3 Option --rounding inverted to --no-rounding 2010-05-30 02:47:40 -06:00
John Wiegley
f491979d55 Added new option: --no-titles 2010-05-30 02:42:36 -06:00
John Wiegley
7bddcd676b Added --rounding option, which is off by default
The purpose of this option is to add special "<Rounding>" postings, to
ensure that a regiter's running total is *always* the sum of its
postings.  Within --rounding, these adjustment postings are missing,
which was the behavior in Ledger 2.x.  It can be orders of magnitude
slower to turn it on for large reports with many commodities.
2010-05-23 15:45:51 -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
a7c28aa200 Added new option --prepend-width
This is useful for making sure that the column containing the results of
--prepend-format is a consistent width throughout the report (including
those lines where it is not applied).

Fixes 64F9D913-75E1-4830-A3D9-29B72442E68B
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
02e7825516 Option --count sums payees, account, commodities 2010-05-22 21:35:02 -04:00
John Wiegley
8acdb85a91 Added a simple print() value expression function
This is really for debugging more than anything else.
2010-05-08 02:01:23 -04:00
John Wiegley
36b616da5e Added new --meta and --meta-width options
The usages are:

  --meta=<TAG>        prepend value of TAG before every line
  --meta-width=<NUM>  force the meta column to be NUM wide
  --meta=<TAG>:<NUM>  shortcut that also applies --meta-width
2010-03-17 02:20:08 -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
1413085977 Added a --pivot=TAG option
This is equivalent to the following:

  --account='"TAG:" + tag(/TAG/)'
2010-02-02 17:07:05 -05:00
John Wiegley
d406aeb85d Guard against divide by zero error in -A reg report 2010-01-21 04:57:15 -05:00
John Wiegley
a7424c1df9 Added a trim() value expression function 2009-11-25 02:48:58 -05:00
Aristid Breitkreuz
6df3ea10f7 Added options: --unrealized-gains and --unrealized-losses
These options allow the user to specify what accounts names should be
used for these two types of accounts.  They are optional, and default
to:

  --unrealized-gains "Equity:Unrealized Gains"
  --unrealized-losses "Equity:Unrealized Losses"

These are intended to be set in one's ~/.ledgerrc file.
2009-11-24 05:08:28 -05:00
John Wiegley
63fee4c837 Added an --unrealized option, for use with bal -V
When this option is on, then in balance report which show market values,
any gains or losses in value will be balanced into a pair of accounts
called Equity:Unrealized Gains and Equity:Unrealized Losses.
2009-11-19 02:00:10 -05:00
John Wiegley
e4b3f0bb3a The new period parser is passing all tests 2009-11-18 05:45:48 -05:00
John Wiegley
d76a6a82dc Don't bold the payee for virtual or temporary xacts 2009-11-13 19:00:45 -05:00
John Wiegley
9858b4957f Reorganized a bit of the reporting code 2009-11-12 05:11:09 -05:00
John Wiegley
b5dca67396 Moved report normalization into report.cc 2009-11-12 03:31:53 -05:00
John Wiegley
c182b7051b Renamed the pricesdb command to pricedb 2009-11-12 01:43:57 -05:00
John Wiegley
95cc364961 Added new value expressions for value conversion
They are:

  to_boolean
  to_int
  to_datetime
  to_date
  to_amount
  to_balance
  to_string
  to_mask
  to_sequence
2009-11-11 21:33:53 -05:00
John Wiegley
67c9cf134d Added --date, similar to --account and --payee
This lets you do things like store a date as the value of a tag, then
run:

  ledger --date='has_tag("Foo") ? to_date(tag("Foo")) : date' reg
2009-11-11 21:32:32 -05:00
John Wiegley
dae24c259b Added floor() value expression function 2009-11-11 04:22:41 -05:00