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.
This commit is contained in:
parent
48d985aacc
commit
fcd7f4f73b
5 changed files with 5 additions and 41 deletions
|
|
@ -193,8 +193,6 @@ void export_value()
|
|||
|
||||
.def("value", &value_t::value, value_overloads())
|
||||
|
||||
.def("cost", &value_t::cost)
|
||||
|
||||
.def("__nonzero__", &value_t::is_nonzero)
|
||||
.def("is_nonzero", &value_t::is_nonzero)
|
||||
.def("is_realzero", &value_t::is_realzero)
|
||||
|
|
|
|||
|
|
@ -161,11 +161,6 @@ namespace {
|
|||
return account.xdata_->total;
|
||||
}
|
||||
|
||||
value_t get_total_cost(account_t& account) {
|
||||
assert(account.xdata_);
|
||||
return account.xdata_->total.cost();
|
||||
}
|
||||
|
||||
value_t get_amount(account_t& account) {
|
||||
assert(account.xdata_);
|
||||
return account.xdata_->value;
|
||||
|
|
@ -216,8 +211,6 @@ expr_t::ptr_op_t account_t::lookup(const string& name)
|
|||
case 't':
|
||||
if (name == "total")
|
||||
return WRAP_FUNCTOR(get_wrapper<&get_total>);
|
||||
else if (name == "total_cost")
|
||||
return WRAP_FUNCTOR(get_wrapper<&get_total_cost>);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
16
src/value.cc
16
src/value.cc
|
|
@ -1245,22 +1245,6 @@ value_t value_t::strip_annotations(const keep_details_t& what_to_keep) const
|
|||
return NULL_VALUE;
|
||||
}
|
||||
|
||||
value_t value_t::cost() const
|
||||
{
|
||||
switch (type()) {
|
||||
case INTEGER:
|
||||
case AMOUNT:
|
||||
case BALANCE:
|
||||
return *this;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
throw_(value_error, "Cannot find the cost of " << label());
|
||||
return NULL_VALUE;
|
||||
}
|
||||
|
||||
void value_t::print(std::ostream& out,
|
||||
const int first_width,
|
||||
const int latter_width,
|
||||
|
|
|
|||
|
|
@ -425,8 +425,6 @@ public:
|
|||
// Return the "market value" of a given value at a specific time.
|
||||
value_t value(const optional<datetime_t>& moment = none,
|
||||
const optional<commodity_t&>& in_terms_of = none) const;
|
||||
value_t cost() const;
|
||||
|
||||
|
||||
/**
|
||||
* Truth tests.
|
||||
|
|
|
|||
19
src/xact.cc
19
src/xact.cc
|
|
@ -157,7 +157,7 @@ namespace {
|
|||
value_t get_cost(xact_t& xact) {
|
||||
if (xact.has_xdata() &&
|
||||
xact.xdata().has_flags(XACT_EXT_COMPOUND)) {
|
||||
return xact.xdata().value.cost();
|
||||
return xact.xdata().value;
|
||||
} else {
|
||||
if (xact.cost)
|
||||
return *xact.cost;
|
||||
|
|
@ -173,18 +173,11 @@ namespace {
|
|||
return xact.amount;
|
||||
}
|
||||
|
||||
value_t get_total_cost(xact_t& xact) {
|
||||
if (xact.xdata_)
|
||||
return xact.xdata_->total.cost();
|
||||
else if (xact.cost)
|
||||
return *xact.cost;
|
||||
else
|
||||
return xact.amount;
|
||||
}
|
||||
|
||||
value_t get_count(xact_t& xact) {
|
||||
assert(xact.xdata_);
|
||||
return xact.xdata_->count;
|
||||
if (xact.xdata_)
|
||||
return xact.xdata_->count;
|
||||
else
|
||||
return 1L;
|
||||
}
|
||||
|
||||
value_t get_account(call_scope_t& scope)
|
||||
|
|
@ -260,8 +253,6 @@ expr_t::ptr_op_t xact_t::lookup(const string& name)
|
|||
case 't':
|
||||
if (name[1] == '\0' || name == "total")
|
||||
return WRAP_FUNCTOR(get_wrapper<&get_total>);
|
||||
else if (name == "total_cost")
|
||||
return WRAP_FUNCTOR(get_wrapper<&get_total_cost>);
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue