Commit graph

25 commits

Author SHA1 Message Date
John Wiegley
cdaba43fa7 Fixed the --gain option for balance reports 2009-02-25 02:07:57 -04:00
John Wiegley
1f39d4148e Create a new interactive_t helper class
The purpose of this class is much like Emacs' (interactive) form: it
allows a value expression function to declare exactly how many
arguments, and of what type, it intends to receive.  It then offers
type-safe access to theese arguments in a consistent manner.

An example value expression function definition in C++:

    value_t fn_foo(call_scope_t& scope) {
      // We expect a string, an integer, and an optional date
      interactive_t args(scope, "sl&d");

      std::cout << "String  = " << args.get<string>(0)
                << "Integer = " << args.get<long>(1) << std::endl;

      if (args.has(2)) // was a date provided?
        std::cout << "Date    = " << args.get<date_t>(2) << std::endl;

      return NULL_VALUE;
    }

There is also an in_context_t<T> template, which finds the context type
T in the current scope hierarchy.  The in_context_t then also acts as a
smart pointer to reference this context object, in addition to serving
the same duty as interactive_t.  This combination of intent is solely
for the sake of brevity.

    value_t fn_bar(call_scope_t& scope) {
      in_context_t<account_t> env(scope, "sl&d");
      std::cout << "Account name = " << env->fullname()
                << "String arg   = " << env.get<string>(0)
                << std::endl;
      return NULL_VALUE;
    }

As you can see here, 'env' acts as a smart pointer to the required
context, and an object to extract the typed arguments.
2009-02-21 18:49:43 -04:00
John Wiegley
bef9fdc471 If an account's aggregate amount is null, return 0 2009-02-19 15:46:57 -04:00
John Wiegley
4ec2dfeef1 Added --flat option, to flatten the balance report 2009-02-17 21:19:31 -04:00
John Wiegley
ce8442a30d Rewrote how the balance command displays accounts
The previous method bent over backwards to try and avoid multiple passes
through the account tree, but the result was a horribly complicated mess
that never ceased to dredge up obscure bugs.  The new scheme is a very,
very simple two-pass algorithm, with multiple subpasses during the
second pass for refining the output based on the report options.
2009-02-17 04:49:10 -04:00
John Wiegley
e8c90ef96f If an account's "total" is empty, return 0 2009-02-15 22:34:10 -04:00
John Wiegley
503a96034e Added account(_base) accessors to account_t 2009-02-15 21:48:22 -04:00
John Wiegley
dfee8bc691 Added 'count' and 'subcount' props for accounts 2009-02-15 19:24:17 -04:00
John Wiegley
fcd7f4f73b Removed "total_cost" valexpr, and value_t::cost
Since cost reports are now calculated by setting the amount_ expression,
there is no need to track a separate "total cost" entity.
2009-02-15 16:26:26 -04:00
John Wiegley
02110394b4 Use the report's amount_expr everywhere that computes an xact's amount. 2009-02-09 14:53:29 -04:00
John Wiegley
f50def86c4 Moved get_partial_name from format.cc into account_t, where it belongs. 2009-02-08 23:28:30 -04:00
John Wiegley
682544ef17 Refer to empty expression operators as simply NULL. 2009-02-07 04:27:04 -04:00
John Wiegley
de816e8307 Whitespace fix. 2009-02-05 02:45:24 -04:00
John Wiegley
2d941730b1 Largely removed all of Ledger's use of global variables, for the REPL's sake. 2009-02-04 19:55:27 -04:00
John Wiegley
43c4636d9d Removed the global references to session->report. 2009-02-03 13:03:10 -04:00
John Wiegley
9d267fa133 Inspired by Omari Norman, I've rewritten main.cc so it's easy to approach. 2009-01-31 18:52:34 -04:00
John Wiegley
887828a40c Increased copyright range to include 2009. 2009-01-20 01:53:31 -04:00
John Wiegley
906d8004ae Added a function for account_t to get the account's total cost. 2009-01-19 22:31:04 -04:00
John Wiegley
fdc7a4e4c5 Factored common parts of entry_t and xact_t into new item_t 2008-09-19 08:06:20 -04:00
John Wiegley
b9182bccdc If a value expression lookup on an account object fails, defer to the current
session object.  Transactions and entries already do this.
2008-09-18 11:34:22 -04:00
John Wiegley
bdc180ff9c Don't use single code format characters anymore. Access to object details
will now always be done with "%(identifier)".
2008-09-18 11:25:56 -04:00
John Wiegley
ad02a482b6 Added the "depth" value expression function for accounts. 2008-08-14 04:13:18 -04:00
John Wiegley
7ffb6c472c The balance report is working again. 2008-08-10 02:53:56 -04:00
John Wiegley
c9d575abce Basic balance reports are working again! 2008-08-10 00:57:29 -04:00
John Wiegley
f6f4a46cf5 Moved around most of the files so that source code is in src/, documentation
is in doc/, etc.
2008-08-05 18:05:49 -04:00
Renamed from account.cc (Browse further)