summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-12-09 14:03:57 -0500
committerJohn Wiegley <johnw@newartisans.com>2009-12-09 14:03:57 -0500
commite3c8b91b5faedafd6b8f6a9a4c54638eba78c769 (patch)
treeeeef84ba9b48e11296793c64a1ce20436cfd4316 /src
parent12db51e6bb8876102ab2d535d77869981411176d (diff)
parentf1a2a5a18d5e7104ad308b2f56a9188f441bb7f2 (diff)
downloadfork-ledger-e3c8b91b5faedafd6b8f6a9a4c54638eba78c769.tar.gz
fork-ledger-e3c8b91b5faedafd6b8f6a9a4c54638eba78c769.tar.bz2
fork-ledger-e3c8b91b5faedafd6b8f6a9a4c54638eba78c769.zip
Merge branch 'next'
Diffstat (limited to 'src')
-rw-r--r--src/draft.cc3
-rw-r--r--src/pool.cc4
-rw-r--r--src/textual.cc17
3 files changed, 18 insertions, 6 deletions
diff --git a/src/draft.cc b/src/draft.cc
index 8478a31d..fc53e956 100644
--- a/src/draft.cc
+++ b/src/draft.cc
@@ -458,6 +458,9 @@ xact_t * draft_t::insert(journal_t& journal)
*post.cost *= new_post->amount;
post.cost->set_commodity(cost_commodity);
}
+ else if (new_post->amount.sign() < 0) {
+ new_post->cost->in_place_negate();
+ }
new_post->cost = *post.cost;
DEBUG("derive.xact", "Copied over posting cost");
diff --git a/src/pool.cc b/src/pool.cc
index 70f4eed6..f895a8bc 100644
--- a/src/pool.cc
+++ b/src/pool.cc
@@ -247,7 +247,7 @@ commodity_pool_t::exchange(const amount_t& amount,
current_annotation = &as_annotated_commodity(commodity).details;
amount_t per_unit_cost =
- (is_per_unit || amount.is_realzero() ? cost : cost / amount).abs();
+ (is_per_unit || amount.is_realzero()) ? cost.abs() : (cost / amount).abs();
DEBUG("commodity.prices.add", "exchange: per-unit-cost = " << per_unit_cost);
@@ -255,7 +255,7 @@ commodity_pool_t::exchange(const amount_t& amount,
exchange(commodity, per_unit_cost, moment ? *moment : CURRENT_TIME());
cost_breakdown_t breakdown;
- breakdown.final_cost = ! is_per_unit ? cost : cost * amount;
+ breakdown.final_cost = ! is_per_unit ? cost : cost * amount.abs();
DEBUG("commodity.prices.add",
"exchange: final-cost = " << breakdown.final_cost);
diff --git a/src/textual.cc b/src/textual.cc
index cf670cae..cbeb6358 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -663,20 +663,26 @@ void instance_t::include_directive(char * line)
{
path filename;
+ DEBUG("textual.include", "include: " << line);
+
if (line[0] != '/' && line[0] != '\\' && line[0] != '~') {
+ DEBUG("textual.include", "received a relative path");
+ DEBUG("textual.include", "parent file path: " << pathname.string());
string::size_type pos = pathname.string().rfind('/');
if (pos == string::npos)
pos = pathname.string().rfind('\\');
- if (pos != string::npos)
+ if (pos != string::npos) {
filename = path(string(pathname.string(), 0, pos + 1)) / line;
+ DEBUG("textual.include", "normalized path: " << filename.string());
+ } else {
+ filename = path(string(".")) / line;
+ }
} else {
filename = line;
}
filename = resolve_path(filename);
-
- DEBUG("textual.include", "Line " << linenum << ": " <<
- "Including path '" << filename << "'");
+ DEBUG("textual.include", "resolved path: " << filename.string());
if (! exists(filename))
throw_(std::runtime_error,
@@ -1044,6 +1050,9 @@ post_t * instance_t::parse_post(char * line,
*post->cost *= post->amount;
post->cost->set_commodity(cost_commodity);
}
+ else if (post->amount.sign() < 0) {
+ post->cost->in_place_negate();
+ }
DEBUG("textual.parse", "line " << linenum << ": "
<< "Total cost is " << *post->cost);