Don't print amounts when not necessary in 'print'
This commit is contained in:
parent
4ebcce3067
commit
40ab813080
2 changed files with 20 additions and 10 deletions
28
src/print.cc
28
src/print.cc
|
|
@ -119,7 +119,12 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::size_t count = xact.posts.size();
|
||||||
|
std::size_t index = 0;
|
||||||
|
|
||||||
foreach (post_t * post, xact.posts) {
|
foreach (post_t * post, xact.posts) {
|
||||||
|
index++;
|
||||||
|
|
||||||
if (! report.HANDLED(generated) &&
|
if (! report.HANDLED(generated) &&
|
||||||
(post->has_flags(ITEM_TEMP | ITEM_GENERATED) &&
|
(post->has_flags(ITEM_TEMP | ITEM_GENERATED) &&
|
||||||
! post->has_flags(POST_ANONYMIZED)))
|
! post->has_flags(POST_ANONYMIZED)))
|
||||||
|
|
@ -163,17 +168,15 @@ namespace {
|
||||||
std::string::size_type slip =
|
std::string::size_type slip =
|
||||||
(static_cast<std::string::size_type>(account_width) -
|
(static_cast<std::string::size_type>(account_width) -
|
||||||
static_cast<std::string::size_type>(name.length()));
|
static_cast<std::string::size_type>(name.length()));
|
||||||
if (slip > 0) {
|
|
||||||
out.width(static_cast<std::streamsize>(slip));
|
|
||||||
out << ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostringstream amtbuf;
|
|
||||||
|
|
||||||
string amt;
|
string amt;
|
||||||
if (post->amount_expr) {
|
if (post->amount_expr) {
|
||||||
amt = post->amount_expr->text();
|
amt = post->amount_expr->text();
|
||||||
} else {
|
}
|
||||||
|
else if (! (count == 2 && index == 2 &&
|
||||||
|
(*xact.posts.begin())->amount.commodity() ==
|
||||||
|
post->amount.commodity() &&
|
||||||
|
! (*xact.posts.begin())->cost && ! post->cost)) {
|
||||||
int amount_width =
|
int amount_width =
|
||||||
(report.HANDLER(amount_width_).specified ?
|
(report.HANDLER(amount_width_).specified ?
|
||||||
report.HANDLER(amount_width_).value.to_int() : 12);
|
report.HANDLER(amount_width_).value.to_int() : 12);
|
||||||
|
|
@ -191,6 +194,7 @@ namespace {
|
||||||
(static_cast<std::string::size_type>(amt.length()) -
|
(static_cast<std::string::size_type>(amt.length()) -
|
||||||
static_cast<std::string::size_type>(trimmed_amt.length()));
|
static_cast<std::string::size_type>(trimmed_amt.length()));
|
||||||
|
|
||||||
|
std::ostringstream amtbuf;
|
||||||
if (slip + amt_slip < 2)
|
if (slip + amt_slip < 2)
|
||||||
amtbuf << string(2 - (slip + amt_slip), ' ');
|
amtbuf << string(2 - (slip + amt_slip), ' ');
|
||||||
amtbuf << amt;
|
amtbuf << amt;
|
||||||
|
|
@ -208,9 +212,15 @@ namespace {
|
||||||
amtbuf << " = " << *post->assigned_amount;
|
amtbuf << " = " << *post->assigned_amount;
|
||||||
|
|
||||||
string trailer = amtbuf.str();
|
string trailer = amtbuf.str();
|
||||||
out << trailer;
|
if (! trailer.empty()) {
|
||||||
|
if (slip > 0) {
|
||||||
|
out.width(static_cast<std::streamsize>(slip));
|
||||||
|
out << ' ';
|
||||||
|
}
|
||||||
|
out << trailer;
|
||||||
|
|
||||||
account_width += unistring(trailer).length();
|
account_width += unistring(trailer).length();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
out << pbuf.str();
|
out << pbuf.str();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,5 @@
|
||||||
test equity assets
|
test equity assets
|
||||||
2007/02/02 Opening Balances
|
2007/02/02 Opening Balances
|
||||||
Assets:Investments:Vanguard:VMMXX 0.350 VMMXX
|
Assets:Investments:Vanguard:VMMXX 0.350 VMMXX
|
||||||
Equity:Opening Balances -0.350 VMMXX
|
Equity:Opening Balances
|
||||||
end test
|
end test
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue