111#define BUDGET_NO_BUDGET 0x00
112#define BUDGET_BUDGETED 0x01
113#define BUDGET_UNBUDGETED 0x02
114#define BUDGET_WRAP_VALUES 0x04
142 return _(
"current report");
249 HANDLER(align_intervals).report(out);
331 HANDLER(primary_date).report(out);
414 OTHER(empty).on(whence);
416 .on(whence,
"count>0?(display_total/count):0");
424 " justify(scrub(display_total), max(int(amount_width),20),"
425 " max(int(amount_width),20) + int(prepend_width), true, color),"
426 " bold if should_bold))"
427 " %(!options.flat ? depth_spacer : \"\")"
429 " ansify_if(partial_account(options.flat), blue if color),"
430 " bold if should_bold))\n%/"
432 "%(prepend_width ? \" \" * int(prepend_width) : \"\")"
433 "%(\"-\" * max(int(amount_width),20))\n");
449 throw_(std::invalid_argument,
450 _f(
"Could not determine beginning of period '%1%'") % str);
469 "%(justify(scrub(get_at(display_total, 0)), int(amount_width), -1, true, color))"
470 " %(justify(-scrub(get_at(display_total, 1)), int(amount_width), "
471 " int(amount_width) + 1 + int(amount_width), true, color))"
472 " %(justify(scrub((get_at(display_total, 1) || 0) + "
473 " (get_at(display_total, 0) || 0)), int(amount_width), "
474 " int(amount_width) + 1 + int(amount_width) + 1 + int(amount_width), true, color))"
476 " justify((get_at(display_total, 1) ? "
477 " (100% * quantity(scrub(get_at(display_total, 0)))) / "
478 " -quantity(scrub(get_at(display_total, 1))) : 0), "
479 " 5, -1, true, false),"
480 " magenta if (color and get_at(display_total, 1) and "
481 " (abs(quantity(scrub(get_at(display_total, 0))) / "
482 " quantity(scrub(get_at(display_total, 1)))) >= 1))))"
483 " %(!options.flat ? depth_spacer : \"\")"
484 "%-(ansify_if(partial_account(options.flat), blue if color))\n"
485 "%/%$1 %$2 %$3 %$4\n%/"
486 "%(prepend_width ? \" \" * int(prepend_width) : \"\")"
487 "------------ ------------ ------------ -----\n");
500 "%(justify(scrub(get_at(display_total, 0)), 16, 16 + int(prepend_width), "
501 " true, color)) %(justify(scrub(get_at(display_total, 1)), 18, "
502 " 36 + int(prepend_width), true, color))"
503 " %(latest_cleared ? format_date(latest_cleared) : \" \")"
504 " %(!options.flat ? depth_spacer : \"\")"
505 "%-(ansify_if(partial_account(options.flat), blue if color))\n%/"
507 "%(prepend_width ? \" \" * int(prepend_width) : \"\")"
508 "---------------- ---------------- ---------\n");
533 "%(quoted(display_account)),"
534 "%(quoted(commodity(scrub(display_amount)))),"
535 "%(quoted(quantity(scrub(display_amount)))),"
536 "%(quoted(cleared ? \"*\" : (pending ? \"!\" : \"\"))),"
537 "%(quoted(join(note | xact.note)))\n");
554 (
"(amount > 0 ? amount : 0, amount < 0 ? amount : 0)");
559 " ansify_if(justify(format_date(date), int(date_width)),"
560 " green if color and date > today),"
561 " bold if should_bold))"
563 " ansify_if(justify(truncated(payee, int(payee_width)), int(payee_width)), "
564 " bold if color and !cleared and actual),"
565 " bold if should_bold))"
567 " ansify_if(justify(truncated(display_account, int(account_width), "
568 " int(abbrev_len)), int(account_width)),"
570 " bold if should_bold))"
572 " justify(scrub(abs(get_at(display_amount, 0))), int(amount_width), "
573 " 3 + int(meta_width) + int(date_width) + int(payee_width)"
574 " + int(account_width) + int(amount_width) + int(prepend_width),"
576 " bold if should_bold))"
578 " justify(scrub(abs(get_at(display_amount, 1))), int(amount_width), "
579 " 4 + int(meta_width) + int(date_width) + int(payee_width)"
580 " + int(account_width) + int(amount_width) + int(amount_width) + int(prepend_width),"
582 " bold if should_bold))"
584 " justify(scrub(get_at(display_total, 0) + get_at(display_total, 1)), int(total_width), "
585 " 5 + int(meta_width) + int(date_width) + int(payee_width)"
586 " + int(account_width) + int(amount_width) + int(amount_width) + int(total_width)"
587 " + int(prepend_width), true, color),"
588 " bold if should_bold))\n%/"
589 "%(justify(\" \", int(date_width)))"
591 " justify(truncated(has_tag(\"Payee\") ? payee : \" \", "
592 " int(payee_width)), int(payee_width)),"
593 " bold if should_bold))"
594 " %$3 %$4 %$5 %$6\n");
599 " justify(scrub(abs(get_at(display_total, 0))), 14,"
600 " 14 + int(prepend_width), true, color),"
601 " bold if should_bold)) "
603 " justify(scrub(abs(get_at(display_total, 1))), 14,"
604 " 14 + 1 + int(prepend_width) + int(total_width), true, color),"
605 " bold if should_bold)) "
607 " justify(scrub(get_at(display_total, 0) + get_at(display_total, 1)), 14,"
608 " 14 + 2 + int(prepend_width) + int(total_width) + int(total_width), true, color),"
609 " bold if should_bold))"
610 " %(!options.flat ? depth_spacer : \"\")"
612 " ansify_if(partial_account(options.flat), blue if color),"
613 " bold if should_bold))\n%/"
615 "%(prepend_width ? \" \" * int(prepend_width) : \"\")"
616 "--------------------------------------------\n");
625 .on(whence,
"display_amount-display_total");
632 value =
string(
"(") + value +
")&(" + str +
")";
638 (
"display_amount",
"amount_expr")) {}
646 (
"display_total",
"total_expr")) {}
666 throw_(std::invalid_argument,
667 _f(
"Could not determine end of period '%1%'")
697 "use_direct_amount ? amount :"
698 " (is_seq(get_at(amount_expr, 0)) ?"
699 " get_at(get_at(amount_expr, 0), 0) :"
700 " market(get_at(amount_expr, 0), value_date, exchange)"
701 " - get_at(amount_expr, 1))");
704 "(market(get_at(total_expr, 0), value_date, exchange), "
705 "get_at(total_expr, 1))");
708 "use_direct_amount ? total_expr :"
709 " market(get_at(total_expr, 0), value_date, exchange)"
710 " - get_at(total_expr, 1)");
725 on(
none,
"%(value)\n");
733 .on(whence,
"nail_down(amount_expr, "
734 "market(amount_expr, value_date, exchange))");
748 value =
string(
"(") + value +
")&(" + str +
")";
756 .on(whence,
"averaged_lots(display_amount)");
758 .on(whence,
"averaged_lots(display_total)");
768 .on(whence,
"market(display_amount, value_date, exchange)");
770 .on(whence,
"market(display_total, value_date, exchange)");
796 throw_(std::invalid_argument,
797 _f(
"Could not determine beginning of period '%1%'")
806 value =
string(
"(") + value +
")&(" + str +
")";
812#if HAVE_ISATTY and !defined(_WIN32) and !defined(__CYGWIN__)
817 if (! std::getenv(
"PAGER")) {
826 setenv(
"LESS",
"-FRSX", 0);
829 on(
none, std::getenv(
"PAGER"));
830 setenv(
"LESS",
"-FRSX", 0);
851 "((is_account&parent&parent.total)?"
852 " percent(scrub(total), scrub(parent.total)):0)");
859 value +=
string(
" ") + str;
868 "%(format_date(date, \"%Y-%m-%d\")) %(quantity(scrub(display_amount)))\n");
875 "%(format_date(date, \"%Y-%m-%d\")) %(quantity(scrub(display_total)))\n");
889 "%(date) %-8(display_account) %(justify(scrub(display_amount), 12, "
890 " 2 + 9 + 8 + 12, true, color))\n");
897 "P %(datetime) %(display_account) %(scrub(display_amount))\n");
924 " ansify_if(justify(format_date(date), int(date_width)),"
925 " green if color and date > today),"
926 " bold if should_bold))"
928 " ansify_if(justify(truncated(payee, int(payee_width)), int(payee_width)), "
929 " bold if color and !cleared and actual),"
930 " bold if should_bold))"
932 " ansify_if(justify(truncated(display_account, int(account_width), "
933 " int(abbrev_len)), int(account_width)),"
935 " bold if should_bold))"
937 " justify(scrub(display_amount), int(amount_width), "
938 " 3 + int(meta_width) + int(date_width) + int(payee_width)"
939 " + int(account_width) + int(amount_width) + int(prepend_width),"
941 " bold if should_bold))"
943 " justify(scrub(display_total), int(total_width), "
944 " 4 + int(meta_width) + int(date_width) + int(payee_width)"
945 " + int(account_width) + int(amount_width) + int(total_width)"
946 " + int(prepend_width), true, color),"
947 " bold if should_bold))\n%/"
948 "%(justify(\" \", int(date_width)))"
950 " justify(truncated(has_tag(\"Payee\") ? payee : \" \", "
951 " int(payee_width)), int(payee_width)),"
952 " bold if should_bold))"
998 "%(ansify_if(justify(earliest_checkin ? "
999 " format_datetime(earliest_checkin) : \"\", 19, -1, true),"
1000 " bold if latest_checkout_cleared)) "
1001 "%(ansify_if(justify(latest_checkout ? "
1002 " format_datetime(latest_checkout) : \"\", 19, -1, true), "
1003 " bold if latest_checkout_cleared)) "
1004 "%(latest_checkout_cleared ? \"*\" : \" \") "
1006 " justify(scrub(display_total), 8,"
1007 " 8 + 4 + 19 * 2, true, color), bold if should_bold))"
1008 " %(!options.flat ? depth_spacer : \"\")"
1010 " ansify_if(partial_account(options.flat), blue if color),"
1011 " bold if should_bold))\n%/"
1013 "%(prepend_width ? \" \" * int(prepend_width) : \"\")"
1014 "--------------------------------------------------\n");
1027 if (
style ==
"leading")
1029 else if (
style ==
"middle")
1031 else if (
style ==
"trailing")
1034 throw_(std::invalid_argument,
1035 _f(
"Unrecognized truncation style: '%1%'") %
style);
1054 OTHER(
total_).on(whence,
"unrounded(total_expr)");
1096 : handler(
other.handler), report(
other.report), whence(
other.whence) {
1105 if (args.
size() > 0)
#define TRACE_CTOR(cls, args)
Basic type and macros for handling command-line options.
#define DECL1(type, name, vartype, var, value)
#define OPTION(type, name)
#define OPTION_(type, name, body)
#define OPTION__(type, name, body)
A utility class for abstracting an output stream.
#define BUDGET_UNBUDGETED
Types for annotating commodities.
Types for handling commodities.
optional< datetime_t > epoch
balance_t average_lot_prices(const balance_t &bal)
shared_ptr< item_handler< post_t > > post_handler_ptr
boost::filesystem::path path
value_t scope_value(scope_t *val)
boost::posix_time::ptime datetime_t
shared_ptr< item_handler< account_t > > acct_handler_ptr
intrusive_ptr< op_t > ptr_op_t
static enum ledger::format_t::elision_style_t default_style
static bool default_style_changed
void commodities_report(post_handler_ptr handler)
value_t fn_lot_date(call_scope_t &scope)
virtual void define(const symbol_t::kind_t kind, const string &name, expr_t::ptr_op_t def)
value_t fn_amount_expr(call_scope_t &scope)
value_t fn_commodity_price(call_scope_t &scope)
value_t fn_rounded(call_scope_t &scope)
value_t fn_total_expr(call_scope_t &scope)
report_t(const report_t &report)
value_t fn_truncated(call_scope_t &scope)
value_t fn_to_balance(call_scope_t &scope)
keep_details_t what_to_keep()
value_t fn_quoted_rfc(call_scope_t &scope)
value_t fn_round(call_scope_t &scope)
value_t fn_get_at(call_scope_t &scope)
value_t fn_quoted(call_scope_t &scope)
value_t fn_to_amount(call_scope_t &scope)
value_t fn_to_mask(call_scope_t &scope)
value_t fn_to_sequence(call_scope_t &scope)
void report_options(std::ostream &out)
value_t fn_unround(call_scope_t &scope)
void xact_report(post_handler_ptr handler, xact_t &xact)
value_t fn_lot_tag(call_scope_t &scope)
value_t fn_to_string(call_scope_t &scope)
report_t(session_t &_session)
value_t echo_command(call_scope_t &scope)
value_t fn_unrounded(call_scope_t &scope)
void normalize_options(const string &verb)
value_t fn_is_seq(call_scope_t &scope)
value_t fn_format_datetime(call_scope_t &scope)
value_t fn_to_int(call_scope_t &scope)
value_t pricemap_command(call_scope_t &scope)
void accounts_report(acct_handler_ptr handler)
uint_least8_t budget_flags
value_t fn_commodity(call_scope_t &scope)
virtual string description()
value_t fn_ansify_if(call_scope_t &scope)
option_t< report_t > * lookup_option(const char *p)
value_t fn_now(call_scope_t &)
value_t fn_today(call_scope_t &)
value_t display_value(const value_t &val)
value_t fn_justify(call_scope_t &scope)
value_t fn_to_boolean(call_scope_t &scope)
value_t fn_to_date(call_scope_t &scope)
value_t fn_set_commodity_price(call_scope_t &scope)
value_t fn_abs(call_scope_t &scope)
value_t fn_display_amount(call_scope_t &scope)
value_t fn_trim(call_scope_t &scope)
value_t fn_display_total(call_scope_t &scope)
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind, const string &name)
value_t fn_market(call_scope_t &scope)
value_t fn_to_datetime(call_scope_t &scope)
value_t fn_print(call_scope_t &scope)
value_t fn_averaged_lots(call_scope_t &scope)
value_t fn_lot_price(call_scope_t &scope)
value_t fn_quantity(call_scope_t &scope)
value_t fn_clear_commodity(call_scope_t &scope)
void generate_report(post_handler_ptr handler)
value_t fn_top_amount(call_scope_t &val)
value_t fn_floor(call_scope_t &scope)
value_t fn_options(call_scope_t &)
value_t fn_nail_down(call_scope_t &scope)
value_t fn_strip(call_scope_t &scope)
string report_format(option_t< report_t > &option)
value_t fn_format_date(call_scope_t &scope)
value_t fn_join(call_scope_t &scope)
void posts_report(post_handler_ptr handler)
value_t fn_format(call_scope_t &scope)
value_t fn_ceiling(call_scope_t &scope)
value_t fn_should_bold(call_scope_t &scope)
value_t reload_command(call_scope_t &)
value_t fn_roundto(call_scope_t &scope)
optional< string > maybe_format(option_t< report_t > &option)
output_stream_t output_stream
value_t fn_percent(call_scope_t &scope)
void parse_query_args(const value_t &args, const string &whence)
value_t fn_scrub(call_scope_t &scope)
reporter(const reporter &other)
value_t operator()(call_scope_t &args)
reporter(shared_ptr< item_handler< Type > > _handler, report_t &_report, const string &_whence)
void close()
Close the output stream, waiting on the pager process if necessary.
optional< date_t > begin() const
Dynamic type representing various numeric types.