more fixes
This commit is contained in:
parent
cd8f61fb2d
commit
33b6cfa801
2 changed files with 37 additions and 20 deletions
36
walk.cc
36
walk.cc
|
|
@ -71,15 +71,26 @@ void changed_value_transactions::operator()(transaction_t * xact)
|
||||||
last_xact->entry->date = prev_date;
|
last_xact->entry->date = prev_date;
|
||||||
|
|
||||||
if (balance_t diff = cur_bal - prev_bal) {
|
if (balance_t diff = cur_bal - prev_bal) {
|
||||||
modified_entry.date = current;
|
entry_t * entry = new entry_t;
|
||||||
|
|
||||||
// jww (2004-08-07): What if there are multiple commodities?
|
entry->payee = "Commodities revalued";
|
||||||
assert(diff.amounts.size() == 1);
|
entry->date = current;
|
||||||
modified_xact.amount = diff.amount();
|
|
||||||
modified_xact.total = diff;
|
|
||||||
modified_xact.total.negate();
|
|
||||||
|
|
||||||
(*handler)(&modified_xact);
|
entry_temps.push_back(entry);
|
||||||
|
|
||||||
|
for (amounts_map::const_iterator i = diff.amounts.begin();
|
||||||
|
i != diff.amounts.end();
|
||||||
|
i++) {
|
||||||
|
transaction_t * temp_xact = new transaction_t(entry, NULL);
|
||||||
|
|
||||||
|
temp_xact->amount = (*i).second;
|
||||||
|
temp_xact->total = (*i).second;
|
||||||
|
temp_xact->total.negate();
|
||||||
|
|
||||||
|
xact_temps.push_back(temp_xact);
|
||||||
|
|
||||||
|
(*handler)(temp_xact);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,7 +103,6 @@ void changed_value_transactions::operator()(transaction_t * xact)
|
||||||
void subtotal_transactions::flush()
|
void subtotal_transactions::flush()
|
||||||
{
|
{
|
||||||
entry_t * entry = new entry_t;
|
entry_t * entry = new entry_t;
|
||||||
entry->date = start;
|
|
||||||
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
// jww (2004-08-10): allow for a format string here
|
// jww (2004-08-10): allow for a format string here
|
||||||
|
|
@ -104,22 +114,22 @@ void subtotal_transactions::flush()
|
||||||
for (balances_map::iterator i = balances.begin();
|
for (balances_map::iterator i = balances.begin();
|
||||||
i != balances.end();
|
i != balances.end();
|
||||||
i++) {
|
i++) {
|
||||||
|
entry->date = finish;
|
||||||
transaction_t * xact = new transaction_t(entry, (*i).first);
|
transaction_t * xact = new transaction_t(entry, (*i).first);
|
||||||
xact->total = (*i).second;
|
xact->total = (*i).second;
|
||||||
balance_t result;
|
balance_t result;
|
||||||
format_t::compute_total(result, details_t(xact));
|
format_t::compute_total(result, details_t(xact));
|
||||||
xact->total = 0;
|
xact->total = 0;
|
||||||
|
entry->date = start;
|
||||||
|
|
||||||
|
xact_temps.push_back(xact);
|
||||||
|
|
||||||
for (amounts_map::const_iterator j = result.amounts.begin();
|
for (amounts_map::const_iterator j = result.amounts.begin();
|
||||||
j != result.amounts.end();
|
j != result.amounts.end();
|
||||||
j++) {
|
j++) {
|
||||||
xact->amount = (*j).second;
|
xact->amount = xact->cost = (*j).second;
|
||||||
xact->cost = (*j).second;
|
|
||||||
|
|
||||||
(*handler)(xact);
|
(*handler)(xact);
|
||||||
}
|
}
|
||||||
|
|
||||||
xact_temps.push_back(xact);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
balances.clear();
|
balances.clear();
|
||||||
|
|
|
||||||
21
walk.h
21
walk.h
|
|
@ -191,24 +191,31 @@ class collapse_transactions : public item_handler<transaction_t>
|
||||||
|
|
||||||
class changed_value_transactions : public item_handler<transaction_t>
|
class changed_value_transactions : public item_handler<transaction_t>
|
||||||
{
|
{
|
||||||
entry_t modified_entry;
|
|
||||||
transaction_t modified_xact;
|
|
||||||
transaction_t * last_xact;
|
transaction_t * last_xact;
|
||||||
|
|
||||||
item_handler<transaction_t> * handler;
|
item_handler<transaction_t> * handler;
|
||||||
|
|
||||||
|
entries_deque entry_temps;
|
||||||
|
transactions_deque xact_temps;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
changed_value_transactions(item_handler<transaction_t> * _handler)
|
changed_value_transactions(item_handler<transaction_t> * _handler)
|
||||||
: modified_xact(&modified_entry, NULL), last_xact(NULL),
|
: last_xact(NULL), handler(_handler) {}
|
||||||
handler(_handler) {
|
|
||||||
assert(handler);
|
|
||||||
modified_entry.payee = "Commodities revalued";
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~changed_value_transactions() {
|
virtual ~changed_value_transactions() {
|
||||||
flush();
|
flush();
|
||||||
handler->flush();
|
handler->flush();
|
||||||
delete handler;
|
delete handler;
|
||||||
|
|
||||||
|
for (entries_deque::iterator i = entry_temps.begin();
|
||||||
|
i != entry_temps.end();
|
||||||
|
i++)
|
||||||
|
delete *i;
|
||||||
|
|
||||||
|
for (transactions_deque::iterator i = xact_temps.begin();
|
||||||
|
i != xact_temps.end();
|
||||||
|
i++)
|
||||||
|
delete *i;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void flush() {
|
virtual void flush() {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue