Restored the --invert option
This commit is contained in:
parent
3c5b5fbc0a
commit
cebc1da256
5 changed files with 15 additions and 36 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -356,22 +356,6 @@ public:
|
|||
virtual void operator()(xact_t& xact);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Brief
|
||||
*
|
||||
* 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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
11
test/baseline/opt-invert.test
Normal file
11
test/baseline/opt-invert.test
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Reference in a new issue