*** empty log message ***
This commit is contained in:
parent
c8ebf53ed8
commit
964e74e333
3 changed files with 38 additions and 34 deletions
34
amount.cc
34
amount.cc
|
|
@ -1729,6 +1729,40 @@ annotated_commodity_t::find_or_create(const commodity_t& comm,
|
|||
return create(comm, price, date, tag, name);
|
||||
}
|
||||
|
||||
bool compare_amount_commodities::operator()(const amount_t * left,
|
||||
const amount_t * right) const
|
||||
{
|
||||
commodity_t& leftcomm(left->commodity());
|
||||
commodity_t& rightcomm(right->commodity());
|
||||
|
||||
int cmp = leftcomm.base_symbol().compare(rightcomm.base_symbol());
|
||||
if (cmp != 0)
|
||||
return cmp < 0;
|
||||
|
||||
if (! leftcomm.annotated) {
|
||||
assert(rightcomm.annotated);
|
||||
return true;
|
||||
}
|
||||
else if (! rightcomm.annotated) {
|
||||
assert(leftcomm.annotated);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
annotated_commodity_t& aleftcomm(static_cast<annotated_commodity_t&>(leftcomm));
|
||||
annotated_commodity_t& arightcomm(static_cast<annotated_commodity_t&>(rightcomm));
|
||||
|
||||
amount_t val = aleftcomm.price - arightcomm.price;
|
||||
if (val)
|
||||
return val < 0;
|
||||
|
||||
int diff = aleftcomm.date - arightcomm.date;
|
||||
if (diff)
|
||||
return diff < 0;
|
||||
|
||||
return aleftcomm.tag < arightcomm.tag;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ledger
|
||||
|
||||
#ifdef USE_BOOST_PYTHON
|
||||
|
|
|
|||
4
amount.h
4
amount.h
|
|
@ -606,6 +606,10 @@ class amount_error : public error {
|
|||
virtual ~amount_error() throw() {}
|
||||
};
|
||||
|
||||
struct compare_amount_commodities {
|
||||
bool operator()(const amount_t * left, const amount_t * right) const;
|
||||
};
|
||||
|
||||
} // namespace ledger
|
||||
|
||||
#endif // _AMOUNT_H
|
||||
|
|
|
|||
34
balance.cc
34
balance.cc
|
|
@ -88,40 +88,6 @@ balance_t balance_t::strip_annotations(const bool keep_price,
|
|||
return temp;
|
||||
}
|
||||
|
||||
struct compare_amount_commodities {
|
||||
bool operator()(const amount_t * left, const amount_t * right) const {
|
||||
commodity_t& leftcomm(left->commodity());
|
||||
commodity_t& rightcomm(right->commodity());
|
||||
|
||||
int cmp = leftcomm.symbol().compare(rightcomm.symbol());
|
||||
if (cmp != 0)
|
||||
return cmp < 0;
|
||||
|
||||
if (! leftcomm.annotated) {
|
||||
assert(rightcomm.annotated);
|
||||
return true;
|
||||
}
|
||||
else if (! rightcomm.annotated) {
|
||||
assert(leftcomm.annotated);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
annotated_commodity_t& aleftcomm(static_cast<annotated_commodity_t&>(leftcomm));
|
||||
annotated_commodity_t& arightcomm(static_cast<annotated_commodity_t&>(rightcomm));
|
||||
|
||||
amount_t val = aleftcomm.price - arightcomm.price;
|
||||
if (val)
|
||||
return val < 0;
|
||||
|
||||
int diff = aleftcomm.date - arightcomm.date;
|
||||
if (diff)
|
||||
return diff < 0;
|
||||
|
||||
return aleftcomm.tag < arightcomm.tag;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void balance_t::write(std::ostream& out,
|
||||
const int first_width,
|
||||
const int latter_width) const
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue