diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-22 01:56:01 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-22 04:51:08 -0400 |
commit | cebc1da25604c9142b9bbc479d5b05e7bee062f9 (patch) | |
tree | 0e43135fbfb9ce3ca7bd9f99c706be503d2b3906 | |
parent | 3c5b5fbc0a5f7d1652c6b59f2ae324f725662a0e (diff) | |
download | fork-ledger-cebc1da25604c9142b9bbc479d5b05e7bee062f9.tar.gz fork-ledger-cebc1da25604c9142b9bbc479d5b05e7bee062f9.tar.bz2 fork-ledger-cebc1da25604c9142b9bbc479d5b05e7bee062f9.zip |
Restored the --invert option
-rw-r--r-- | src/chain.cc | 4 | ||||
-rw-r--r-- | src/filters.cc | 15 | ||||
-rw-r--r-- | src/filters.h | 16 | ||||
-rw-r--r-- | src/report.h | 5 | ||||
-rw-r--r-- | test/baseline/opt-invert.test | 11 |
5 files changed, 15 insertions, 36 deletions
diff --git a/src/chain.cc b/src/chain.cc index 14c07b8c..8d51d11c 100644 --- a/src/chain.cc +++ b/src/chain.cc @@ -143,10 +143,6 @@ xact_handler_ptr chain_xact_handlers(report_t& report, handler.reset(new sort_xacts(handler, "date")); } - // invert_xacts inverts the value of the xacts it receives. - if (report.HANDLED(invert)) - handler.reset(new invert_xacts(handler)); - // related_xacts will pass along all xacts related to the xact received. If // the `related_all' handler is on, then all the entry's xacts are passed; // meaning that if one xact of an entry is to be printed, all the xact for diff --git a/src/filters.cc b/src/filters.cc index 13b62d9d..c6ab5c4e 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -211,21 +211,6 @@ void calc_xacts::operator()(xact_t& xact) last_xact = &xact; } -void invert_xacts::operator()(xact_t& xact) -{ - if (xact.has_xdata() && - xact.xdata().has_flags(XACT_EXT_COMPOUND)) { - xact.xdata().value.in_place_negate(); - } else { - xact.amount.in_place_negate(); - if (xact.cost) - xact.cost->in_place_negate(); - } - - item_handler<xact_t>::operator()(xact); -} - - namespace { void handle_value(const value_t& value, account_t * account, diff --git a/src/filters.h b/src/filters.h index 112ebbcd..81039125 100644 --- a/src/filters.h +++ b/src/filters.h @@ -361,22 +361,6 @@ public: * * Long. */ -class invert_xacts : public item_handler<xact_t> -{ - invert_xacts(); - -public: - invert_xacts(xact_handler_ptr handler) - : item_handler<xact_t>(handler) {} - - virtual void operator()(xact_t& xact); -}; - -/** - * @brief Brief - * - * Long. - */ class collapse_xacts : public item_handler<xact_t> { expr_t& amount_expr; diff --git a/src/report.h b/src/report.h index 6806dc62..f8077d0b 100644 --- a/src/report.h +++ b/src/report.h @@ -379,7 +379,10 @@ public: OPTION(report_t, format_); // -F OPTION(report_t, gain); // -G OPTION(report_t, head_); - OPTION(report_t, invert); + + OPTION_(report_t, invert, DO() { + parent->HANDLER(amount_).set_expr("-amount"); + }); OPTION__ (report_t, limit_, // -l diff --git a/test/baseline/opt-invert.test b/test/baseline/opt-invert.test new file mode 100644 index 00000000..9a9f6d02 --- /dev/null +++ b/test/baseline/opt-invert.test @@ -0,0 +1,11 @@ +reg --invert +<<< +2007/02/02 RD VMMXX + Assets:Investments:Vanguard:VMMXX 0.350 VMMXX @ $1.00 + Income:Dividends:Vanguard:VMMXX $-0.35 +>>>1 +07-Feb-02 RD VMMXX As:In:Vanguard:VMMXX -0.350 VMMXX -0.350 VMMXX + In:Di:Vanguard:VMMXX $0.35 $0.35 + -0.350 VMMXX +>>>2 +=== 0 |