diff options
author | Martin Michlmayr <tbm@cyrius.com> | 2014-07-14 21:09:57 -0400 |
---|---|---|
committer | Martin Michlmayr <tbm@cyrius.com> | 2014-07-14 21:09:57 -0400 |
commit | 3f9fc276d3a802ebdd3c694029d56b948fecb841 (patch) | |
tree | 08ffacae3c1d72251d8ba25a446c5ea10140f40f /src | |
parent | 511b17a21f79bbb19fe151402b07e3d0cc3948ec (diff) | |
parent | b88634206402814f63ba8db192e52d3e3bec2b38 (diff) | |
download | fork-ledger-3f9fc276d3a802ebdd3c694029d56b948fecb841.tar.gz fork-ledger-3f9fc276d3a802ebdd3c694029d56b948fecb841.tar.bz2 fork-ledger-3f9fc276d3a802ebdd3c694029d56b948fecb841.zip |
Merge pull request #310 from tbm/712-713-costs
Change the definition of cost
Diffstat (limited to 'src')
-rw-r--r-- | src/post.h | 1 | ||||
-rw-r--r-- | src/print.cc | 6 | ||||
-rw-r--r-- | src/textual.cc | 2 | ||||
-rw-r--r-- | src/xact.cc | 6 |
4 files changed, 10 insertions, 5 deletions
@@ -68,6 +68,7 @@ public: amount_t amount; // can be null until finalization optional<expr_t> amount_expr; optional<amount_t> cost; + optional<amount_t> given_cost; optional<amount_t> assigned_amount; optional<datetime_t> checkin; optional<datetime_t> checkout; diff --git a/src/print.cc b/src/print.cc index 9be3b511..54cfa578 100644 --- a/src/print.cc +++ b/src/print.cc @@ -243,7 +243,7 @@ namespace { amtbuf << string(2 - (slip + amt_slip), ' '); amtbuf << amt; - if (post->cost && + if (post->given_cost && ! post->has_flags(POST_CALCULATED | POST_COST_CALCULATED)) { std::string cost_op; if (post->has_flags(POST_COST_IN_FULL)) @@ -254,10 +254,10 @@ namespace { cost_op = "(" + cost_op + ")"; if (post->has_flags(POST_COST_IN_FULL)) - amtbuf << " " << cost_op << " " << post->cost->abs(); + amtbuf << " " << cost_op << " " << post->given_cost->abs(); else amtbuf << " " << cost_op << " " - << (*post->cost / post->amount).abs(); + << (*post->given_cost / post->amount).abs(); } if (post->assigned_amount) diff --git a/src/textual.cc b/src/textual.cc index eea79de0..156e2b9c 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -1578,6 +1578,8 @@ post_t * instance_t::parse_post(char * line, if (fixed_cost) post->add_flags(POST_COST_FIXATED); + post->given_cost = post->cost; + DEBUG("textual.parse", "line " << context.linenum << ": " << "Total cost is " << *post->cost); DEBUG("textual.parse", "line " << context.linenum << ": " diff --git a/src/xact.cc b/src/xact.cc index eec4cff3..3e563714 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -304,10 +304,9 @@ bool xact_base_t::finalize() DEBUG("xact.finalize", "gain_loss = " << gain_loss); gain_loss.in_place_round(); DEBUG("xact.finalize", "gain_loss rounds to = " << gain_loss); - if (post->must_balance()) add_or_set_value(balance, gain_loss.reduced()); - +#if 0 account_t * account; if (gain_loss.sign() > 0) account = journal->find_account(_("Equity:Capital Gains")); @@ -321,6 +320,9 @@ bool xact_base_t::finalize() p->add_flags(post->flags() & (POST_VIRTUAL | POST_MUST_BALANCE)); } add_post(p); +#else + *post->cost += gain_loss; +#endif DEBUG("xact.finalize", "added gain_loss, balance = " << balance); } else { DEBUG("xact.finalize", "gain_loss would have displayed as zero"); |