Fixed the way prices and costs are print'd
This commit is contained in:
parent
a4d4f99794
commit
c85cf0d810
9 changed files with 581 additions and 581 deletions
|
|
@ -1216,7 +1216,7 @@ void amount_t::parse_conversion(const string& larger_str,
|
||||||
smaller.commodity().set_larger(larger);
|
smaller.commodity().set_larger(larger);
|
||||||
}
|
}
|
||||||
|
|
||||||
void amount_t::print(std::ostream& _out, const uint_least8_t) const
|
void amount_t::print(std::ostream& _out, const uint_least8_t flags) const
|
||||||
{
|
{
|
||||||
VERIFY(valid());
|
VERIFY(valid());
|
||||||
|
|
||||||
|
|
@ -1246,7 +1246,7 @@ void amount_t::print(std::ostream& _out, const uint_least8_t) const
|
||||||
|
|
||||||
// If there are any annotations associated with this commodity, output them
|
// If there are any annotations associated with this commodity, output them
|
||||||
// now.
|
// now.
|
||||||
comm.write_annotations(out);
|
comm.write_annotations(out, flags & AMOUNT_PRINT_NO_COMPUTED_ANNOTATIONS);
|
||||||
|
|
||||||
// Things are output to a string first, so that if anyone has specified a
|
// Things are output to a string first, so that if anyone has specified a
|
||||||
// width or fill for _out, it will be applied to the entire amount string,
|
// width or fill for _out, it will be applied to the entire amount string,
|
||||||
|
|
|
||||||
|
|
@ -66,15 +66,6 @@ void annotation_t::parse(std::istream& in)
|
||||||
temp.parse(buf, PARSE_NO_MIGRATE);
|
temp.parse(buf, PARSE_NO_MIGRATE);
|
||||||
|
|
||||||
DEBUG("commodity.annotations", "Parsed annotation price: " << temp);
|
DEBUG("commodity.annotations", "Parsed annotation price: " << temp);
|
||||||
|
|
||||||
// Since this price will maintain its own precision, make sure
|
|
||||||
// it is at least as large as the base commodity, since the user
|
|
||||||
// may have only specified {$1} or something similar.
|
|
||||||
|
|
||||||
if (temp.has_commodity() &&
|
|
||||||
temp.precision() > temp.commodity().precision())
|
|
||||||
temp = temp.rounded(); // no need to retain individual precision
|
|
||||||
|
|
||||||
price = temp;
|
price = temp;
|
||||||
}
|
}
|
||||||
else if (c == '[') {
|
else if (c == '[') {
|
||||||
|
|
@ -118,18 +109,22 @@ void annotation_t::parse(std::istream& in)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void annotation_t::print(std::ostream& out, bool keep_base) const
|
void annotation_t::print(std::ostream& out, bool keep_base,
|
||||||
|
bool no_computed_annotations) const
|
||||||
{
|
{
|
||||||
if (price)
|
if (price &&
|
||||||
|
(! no_computed_annotations || ! has_flags(ANNOTATION_PRICE_CALCULATED)))
|
||||||
out << " {"
|
out << " {"
|
||||||
<< (has_flags(ANNOTATION_PRICE_FIXATED) ? "=" : "")
|
<< (has_flags(ANNOTATION_PRICE_FIXATED) ? "=" : "")
|
||||||
<< (keep_base ? *price : price->unreduced()).rounded()
|
<< (keep_base ? *price : price->unreduced())
|
||||||
<< '}';
|
<< '}';
|
||||||
|
|
||||||
if (date)
|
if (date &&
|
||||||
|
(! no_computed_annotations || ! has_flags(ANNOTATION_DATE_CALCULATED)))
|
||||||
out << " [" << format_date(*date, FMT_WRITTEN) << ']';
|
out << " [" << format_date(*date, FMT_WRITTEN) << ']';
|
||||||
|
|
||||||
if (tag)
|
if (tag &&
|
||||||
|
(! no_computed_annotations || ! has_flags(ANNOTATION_TAG_CALCULATED)))
|
||||||
out << " (" << *tag << ')';
|
out << " (" << *tag << ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -197,9 +192,10 @@ annotated_commodity_t::strip_annotations(const keep_details_t& what_to_keep)
|
||||||
return *new_comm;
|
return *new_comm;
|
||||||
}
|
}
|
||||||
|
|
||||||
void annotated_commodity_t::write_annotations(std::ostream& out) const
|
void annotated_commodity_t::write_annotations
|
||||||
|
(std::ostream& out, bool no_computed_annotations) const
|
||||||
{
|
{
|
||||||
details.print(out, pool().keep_base);
|
details.print(out, pool().keep_base, no_computed_annotations);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ledger
|
} // namespace ledger
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,8 @@ struct annotation_t : public supports_flags<>,
|
||||||
|
|
||||||
void parse(std::istream& in);
|
void parse(std::istream& in);
|
||||||
|
|
||||||
void print(std::ostream& out, bool keep_base = false) const;
|
void print(std::ostream& out, bool keep_base = false,
|
||||||
|
bool no_computed_annotations = false) const;
|
||||||
|
|
||||||
bool valid() const {
|
bool valid() const {
|
||||||
assert(*this);
|
assert(*this);
|
||||||
|
|
@ -230,7 +231,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual commodity_t& strip_annotations(const keep_details_t& what_to_keep);
|
virtual commodity_t& strip_annotations(const keep_details_t& what_to_keep);
|
||||||
virtual void write_annotations(std::ostream& out) const;
|
virtual void write_annotations(std::ostream& out,
|
||||||
|
bool no_computed_annotations = false) const;
|
||||||
|
|
||||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -273,7 +273,7 @@ public:
|
||||||
virtual commodity_t& strip_annotations(const keep_details_t&) {
|
virtual commodity_t& strip_annotations(const keep_details_t&) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
virtual void write_annotations(std::ostream&) const {}
|
virtual void write_annotations(std::ostream&, bool) const {}
|
||||||
|
|
||||||
commodity_pool_t& pool() const {
|
commodity_pool_t& pool() const {
|
||||||
return *parent_;
|
return *parent_;
|
||||||
|
|
|
||||||
14
src/print.cc
14
src/print.cc
|
|
@ -177,8 +177,8 @@ namespace {
|
||||||
report.HANDLER(amount_width_).value.to_int() : 12);
|
report.HANDLER(amount_width_).value.to_int() : 12);
|
||||||
|
|
||||||
std::ostringstream amt_str;
|
std::ostringstream amt_str;
|
||||||
report.scrub(post->amount)
|
value_t(post->amount).print(amt_str, amount_width, -1,
|
||||||
.print(amt_str, amount_width, -1, AMOUNT_PRINT_RIGHT_JUSTIFY |
|
AMOUNT_PRINT_RIGHT_JUSTIFY |
|
||||||
AMOUNT_PRINT_NO_COMPUTED_ANNOTATIONS);
|
AMOUNT_PRINT_NO_COMPUTED_ANNOTATIONS);
|
||||||
amt = amt_str.str();
|
amt = amt_str.str();
|
||||||
}
|
}
|
||||||
|
|
@ -191,15 +191,17 @@ namespace {
|
||||||
amtbuf << string(2 - (slip + amt_slip), ' ');
|
amtbuf << string(2 - (slip + amt_slip), ' ');
|
||||||
amtbuf << amt;
|
amtbuf << amt;
|
||||||
|
|
||||||
if (post->cost && ! post->has_flags(POST_CALCULATED)) {
|
if (post->cost &&
|
||||||
|
! post->has_flags(POST_CALCULATED | POST_COST_CALCULATED)) {
|
||||||
if (post->has_flags(POST_COST_IN_FULL))
|
if (post->has_flags(POST_COST_IN_FULL))
|
||||||
amtbuf << " @@ " << report.scrub(post->cost->abs());
|
amtbuf << " @@ " << post->cost->abs();
|
||||||
else
|
else
|
||||||
amtbuf << " @ " << report.scrub((*post->cost / post->amount).abs());
|
amtbuf << " @ "
|
||||||
|
<< (*post->cost / post->amount).abs();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (post->assigned_amount)
|
if (post->assigned_amount)
|
||||||
amtbuf << " = " << report.scrub(*post->assigned_amount);
|
amtbuf << " = " << post->assigned_amount;
|
||||||
|
|
||||||
string trailer = amtbuf.str();
|
string trailer = amtbuf.str();
|
||||||
out << trailer;
|
out << trailer;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -7,11 +7,11 @@ D 1.0000s
|
||||||
Assets:Gruulmorg 248720c {10.051463493s}
|
Assets:Gruulmorg 248720c {10.051463493s}
|
||||||
Equity:Gold -5000000s
|
Equity:Gold -5000000s
|
||||||
>>>1
|
>>>1
|
||||||
1339829c {1.8659s} [2006/03/14]
|
1339829c {1.86590975416s} [2006/03/14]
|
||||||
1339829c {1.8659s} [2006/03/14]
|
1339829c {1.86590975416s} [2006/03/14]
|
||||||
248720c {10.0515s}
|
248720c {10.051463493s}
|
||||||
1339829c {1.8659s} [2006/03/14]
|
1339829c {1.86590975416s} [2006/03/14]
|
||||||
248720c {10.0515s}
|
248720c {10.051463493s}
|
||||||
-1388.9h
|
-1388.9h
|
||||||
>>>2
|
>>>2
|
||||||
=== 0
|
=== 0
|
||||||
|
|
@ -19,9 +19,9 @@ reg --format '%(justify(scrub(total_expr), 40, 40, true))\n' --lots-actual
|
||||||
>>>1
|
>>>1
|
||||||
1339829c
|
1339829c
|
||||||
1339829c
|
1339829c
|
||||||
248720c {10.0515s}
|
248720c {10.051463493s}
|
||||||
1339829c
|
1339829c
|
||||||
248720c {10.0515s}
|
248720c {10.051463493s}
|
||||||
-1388.9h
|
-1388.9h
|
||||||
>>>2
|
>>>2
|
||||||
=== 0
|
=== 0
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -89,11 +89,11 @@ D 1.200,40 €
|
||||||
Actif:SV 14,89 €
|
Actif:SV 14,89 €
|
||||||
>>>1
|
>>>1
|
||||||
1999/11/01 * Achat
|
1999/11/01 * Achat
|
||||||
Actif:SSB 125,0000 STK @ 13,37936 $
|
Actif:SSB 125,0000 STK
|
||||||
Actif:SSB -1672,42 $
|
Actif:SSB -1672,42 $
|
||||||
|
|
||||||
1999/11/04 * Vente
|
1999/11/04 * Vente
|
||||||
Actif:SSB -125,0000 STK @ 15,01288 $
|
Actif:SSB -125,0000 STK
|
||||||
Dépense:SSB:Commissions 55,07 $
|
Dépense:SSB:Commissions 55,07 $
|
||||||
Actif:SSB 1821,54 $
|
Actif:SSB 1821,54 $
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue