Commit graph

1358 commits

Author SHA1 Message Date
John Wiegley
9b905f2b44 query command's parsing behavior sensitive to -n
With -n, the first argument is parsed as a string containing
subarguments.  Otherwise, each argument is parsed as a separate
argument.

In short, the -n mode mimicks what happens when the query expr after "="
is parsed for automated expressions.  The non -n mode mimicks what
happens at the command line for users.
2010-06-19 14:02:33 -04:00
John Wiegley
627162acc0 Made amount_t::value a bit safer 2010-06-19 13:34:15 -04:00
John Wiegley
4bbce6dc7b When --inject is used for a tag, convert to an amount 2010-06-18 19:44:10 -04:00
John Wiegley
b7ea365bfc Renamed the "Rounding" account to "Adjustment" 2010-06-18 08:29:14 -04:00
John Wiegley
66de7e3055 Filename globs now surrounded by ^$ 2010-06-18 07:28:11 -04:00
John Wiegley
a961f15f00 Fixed bug that had broken any() and all() 2010-06-18 07:27:53 -04:00
John Wiegley
9205809d49 Fixed register formatting of postings with payees 2010-06-18 07:27:35 -04:00
John Wiegley
6f73a4db0c Made "convert" command insensitive to null amounts 2010-06-18 07:27:18 -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
7e2547b1e4 A metadata key must occur at the beginning
Before, this was valid:

  ; Today Yesterday: Tomorrow

Which would set the key Yesterday to the value Tomorrow.  Now, it is
just an ordinary comment.
2010-06-18 02:21:02 -04:00
John Wiegley
b881220987 Minor fix to the way transfer_details sets post date 2010-06-18 02:20:12 -04:00
John Wiegley
b80be82b8d has_tag and get_tag now take an 'inherit' parameter 2010-06-18 02:19:39 -04:00
John Wiegley
5f989f7d9f Corrected printing of assigned amounts 2010-06-18 02:18:44 -04:00
John Wiegley
805a78c121 Only look for [date] outside of metadata entries 2010-06-18 00:46:37 -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
968a6f3c0a Changes for building with Visual Studio 2008 2010-06-15 05:14:00 -04:00
John Wiegley
34fcc62b4d Removed unused --unsorted option 2010-06-15 04:34:16 -04:00
John Wiegley
63b4bdaecf Support period expressions "this/next/last week" 2010-06-14 08:14:48 -04:00
John Wiegley
d9d04f62a3 Allow period exprs "from today", "until tomorrow" 2010-06-14 08:04:40 -04:00
John Wiegley
c4e908915c Support period expressions like "last 4 weeks" 2010-06-14 07:56:21 -04:00
John Wiegley
904fff97d0 Fix to allow time periods like "every 14 days" 2010-06-14 07:30:24 -04:00
John Wiegley
c367dcab82 Improved algorithm for abbreviating account names 2010-06-14 07:20:23 -04:00
John Wiegley
47e91a8a92 Added initial implementation of lot_*() functions 2010-06-14 04:40:39 -04:00
John Wiegley
c2a77c1237 Don't elide quotes for all-digit commodities 2010-06-14 03:46:50 -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
847a5fae3d Removed some unneeded code 2010-06-14 01:00:11 -04:00
John Wiegley
e78af146e8 Corrected bug with forecasting date bounded xacts 2010-06-13 23:41:50 -04:00
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