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::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 @@ -356,22 +356,6 @@ public: virtual void operator()(xact_t& xact); }; -/** - * @brief Brief - * - * Long. - */ -class invert_xacts : public item_handler -{ - invert_xacts(); - -public: - invert_xacts(xact_handler_ptr handler) - : item_handler(handler) {} - - virtual void operator()(xact_t& xact); -}; - /** * @brief Brief * 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