summaryrefslogtreecommitdiff
path: root/src/amount.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-11-09 13:25:45 -0500
committerJohn Wiegley <johnw@newartisans.com>2009-11-09 13:25:45 -0500
commit865c0ff828f88ed1d00eea73a3fc55b3e57d21b3 (patch)
tree5acdfae32811b25fb46271bf349a216bea41fddb /src/amount.cc
parent55c7792c9329f97dd19fc5aeca466cb2de4fbf9c (diff)
parent9b396b41220646cf73fcd2a8afebcee06dde2a29 (diff)
downloadfork-ledger-865c0ff828f88ed1d00eea73a3fc55b3e57d21b3.tar.gz
fork-ledger-865c0ff828f88ed1d00eea73a3fc55b3e57d21b3.tar.bz2
fork-ledger-865c0ff828f88ed1d00eea73a3fc55b3e57d21b3.zip
Merge branch 'next'
Diffstat (limited to 'src/amount.cc')
-rw-r--r--src/amount.cc25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/amount.cc b/src/amount.cc
index e9b971f8..6fb0056b 100644
--- a/src/amount.cc
+++ b/src/amount.cc
@@ -669,7 +669,8 @@ namespace {
for (const char * p = buf; *p; p++) {
if (*p == '.') {
- if (comm && comm->has_flags(COMMODITY_STYLE_EUROPEAN))
+ if (commodity_t::european_by_default ||
+ (comm && comm->has_flags(COMMODITY_STYLE_EUROPEAN)))
out << ',';
else
out << *p;
@@ -682,7 +683,8 @@ namespace {
out << *p;
if (integer_digits > 3 && --integer_digits % 3 == 0) {
- if (comm && comm->has_flags(COMMODITY_STYLE_EUROPEAN))
+ if (commodity_t::european_by_default ||
+ (comm && comm->has_flags(COMMODITY_STYLE_EUROPEAN)))
out << '.';
else
out << ',';
@@ -977,12 +979,14 @@ bool amount_t::parse(std::istream& in, const parse_flags_t& flags)
}
}
else if (last_comma != string::npos &&
- commodity().has_flags(COMMODITY_STYLE_EUROPEAN)) {
+ (commodity_t::european_by_default ||
+ commodity().has_flags(COMMODITY_STYLE_EUROPEAN))) {
comm_flags |= COMMODITY_STYLE_EUROPEAN;
quantity->prec = static_cast<precision_t>(quant.length() - last_comma - 1);
}
else if (last_period != string::npos &&
- ! (commodity().has_flags(COMMODITY_STYLE_EUROPEAN))) {
+ ! (commodity_t::european_by_default ||
+ commodity().has_flags(COMMODITY_STYLE_EUROPEAN))) {
quantity->prec = static_cast<precision_t>(quant.length() - last_period - 1);
}
else {
@@ -1121,6 +1125,19 @@ bool amount_t::valid() const
return true;
}
+void to_xml(std::ostream& out, const amount_t& amt, bool commodity_details)
+{
+ push_xml x(out, "amount");
+
+ if (amt.has_commodity())
+ to_xml(out, amt.commodity(), commodity_details);
+
+ {
+ push_xml y(out, "quantity");
+ out << y.guard(amt.quantity_string());
+ }
+}
+
#if defined(HAVE_BOOST_SERIALIZATION)
template<class Archive>