Price annotation no longer inject an implied cost

Consider the following transaction:

  2010-06-22 Sample
      Assets:Brokerage       10 AAPL {$30}
      Assets:Brokerage

Previously, this would have been equivalent to:

  2010-06-22 Sample
      Assets:Brokerage       10 AAPL @ $30
      Assets:Brokerage

However, this is not always what the user expects to happen.  When @ is
not being used, the transaction should reflect a mere transfer of
commodities.  This is now how it works, and thus the above transaction
is now equivalent to the following instead:

  2010-06-22 Sample
      Assets:Brokerage       10 AAPL {$30}
      Assets:Brokerage      -10 AAPL {$30}
This commit is contained in:
John Wiegley 2010-06-22 20:56:35 -04:00
parent 1f3dba7756
commit 266dee564f
7 changed files with 4098 additions and 4295 deletions

View file

@ -124,28 +124,14 @@ bool xact_base_t::finalize()
amount_t& p(post->cost ? *post->cost : post->amount);
if (! p.is_null()) {
DEBUG("xact.finalize", "post must balance = " << p.reduced());
if (! post->cost && post->amount.has_annotation() &&
post->amount.annotation().price) {
// If the amount has no cost, but is annotated with a per-unit
// price, use the price times the amount as the cost
post->cost = (*post->amount.annotation().price *
post->amount).unrounded();
DEBUG("xact.finalize",
"annotation price = " << *post->amount.annotation().price);
DEBUG("xact.finalize", "amount = " << post->amount);
DEBUG("xact.finalize", "priced cost = " << *post->cost);
post->add_flags(POST_COST_CALCULATED);
add_or_set_value(balance, post->cost->rounded().reduced());
} else {
// If the amount was a cost, it very likely has the "keep_precision"
// flag set, meaning commodity display precision is ignored when
// displaying the amount. We never want this set for the balance,
// so we must clear the flag in a temporary to avoid it propagating
// into the balance.
// If the amount was a cost, it very likely has the
// "keep_precision" flag set, meaning commodity display precision
// is ignored when displaying the amount. We never want this set
// for the balance, so we must clear the flag in a temporary to
// avoid it propagating into the balance.
add_or_set_value(balance, p.keep_precision() ?
p.rounded().reduced() : p.reduced());
}
}
else if (null_post) {
throw_(std::logic_error,
_("Only one posting with null amount allowed per transaction"));

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -4,24 +4,22 @@ D 1.0000s
2006/03/14 Opening Balances
Assets:Tajer 1339829c @ 1.86590975416s
Assets:Gruulmorg 248720c {10.051463493s}
Assets:Gruulmorg 248720c @ 10.051463493s
Equity:Gold -5000000s
>>>1
1339829c {1.86590975416s} [2006/03/14]
1339829c {1.86590975416s} [2006/03/14]
248720c {10.051463493s}
248720c {10.051463493s} [2006/03/14]
1339829c {1.86590975416s} [2006/03/14]
248720c {10.051463493s}
248720c {10.051463493s} [2006/03/14]
-1388.9h
>>>2
=== 0
reg --format '%(justify(scrub(total_expr), 40, 40, true))\n' --lots-actual
>>>1
1339829c
1339829c
248720c {10.051463493s}
1339829c
248720c {10.051463493s}
1588549c
1588549c
-1388.9h
>>>2
=== 0

File diff suppressed because it is too large Load diff

View file

@ -356,8 +356,8 @@ D 1.00G
Assets:Tajer
2006/03/17 Player: raev
Assets:Tajer:Items "Wildheart Belt" 1 {30G}
Assets:Tajer:Items "Ace of Warlords" -2 {15G}
Assets:Tajer:Items "Wildheart Belt" 1 @ 30G
Assets:Tajer:Items "Ace of Warlords" -2 @ 15G
2006/03/17 Auction House
Expenses:Fees:Auction 7482c
@ -609,8 +609,8 @@ D 1.00G
Assets:Tajer -1.20s 0
06-Mar-14 Puldoost Assets:Tajer 8.00G 8.00G
Expenses:Items -8.00G 0
06-Mar-14 Auction House Assets:Wyshona:Items 1.25G 1.25G
Assets:Tajer:Items -1.25G 0
06-Mar-14 Auction House Assets:Wyshona:Items "Plans: Wildthorn Mail" 1 "Plans: Wildthorn Mail" 1
Assets:Tajer:Items "Plans: Wildthorn Mail" -1 0
06-Mar-15 Auction House Assets:Tajer 45.00s 45.00s
Assets:Tajer 2.59s 47.59s
Assets:Bids -47.59s 0
@ -680,11 +680,17 @@ D 1.00G
Assets:Tajer:Items -119.58G 0
Income:Brokering -54.58G -54.58G
Equity:Capital Gains 54.58G 0
06-Mar-16 Auction House Assets:Wyshona:Items 2.11G 2.11G
Assets:Wyshona:Items 2.30G 4.40G
Assets:Wyshona:Items 1.00G 5.40G
Assets:Wyshona:Items 1.50G 6.90G
Assets:Tajer:Items -6.90G 0
06-Mar-16 Auction House Assets:Wyshona:Items "Plans: Mithril Shield Spike" 1 "Plans: Mithril Shield Spike" 1
Assets:Wyshona:Items "Plans: Mithril Shield Spike" 1 "Plans: Mithril Shield Spike" 2
Assets:Wyshona:Items "Recipe: Elixir of Giant Growth" 1 "Plans: Mithril Shield Spike" 2
"Recipe: Elixir of Giant Growth" 1
Assets:Wyshona:Items "Recipe: Elixir of Giant Growth" 1 "Plans: Mithril Shield Spike" 2
"Recipe: Elixir of Giant Growth" 2
Assets:Tajer:Items "Plans: Mithril Shield Spike" -1 "Plans: Mithril Shield Spike" 1
"Recipe: Elixir of Giant Growth" 2
Assets:Tajer:Items "Plans: Mithril Shield Spike" -1 "Recipe: Elixir of Giant Growth" 2
Assets:Tajer:Items "Recipe: Elixir of Giant Growth" -1 "Recipe: Elixir of Giant Growth" 1
Assets:Tajer:Items "Recipe: Elixir of Giant Growth" -1 0
06-Mar-16 Player Assets:Tajer 4.00G 4.00G
Equity:Gold -4.00G 0
06-Mar-16 Auction House Assets:Wyshona 13.41G 13.41G
@ -718,8 +724,8 @@ D 1.00G
Assets:Tajer -30.00G 0
06-Mar-16 Auction House Assets:Gruulmorg:Items 30.00G 30.00G
Assets:Gruulmorg -30.00G 0
06-Mar-16 Transfer Assets:Tajer:Items 30.00G 30.00G
Assets:Gruulmorg:Items -30.00G 0
06-Mar-16 Transfer Assets:Tajer:Items "Ace of Warlords" 2 "Ace of Warlords" 2
Assets:Gruulmorg:Items "Ace of Warlords" -2 0
06-Mar-16 Post Expenses:Fees:Mail 60c 60c
Assets:Gruulmorg -60c 0
06-Mar-16 Post Expenses:Fees:Mail 1.20s 1.20s

View file

@ -356,8 +356,8 @@ D 1.00G
Assets:Tajer
2006/03/17 Player: raev
Assets:Tajer:Items "Wildheart Belt" 1 {30G}
Assets:Tajer:Items "Ace of Warlords" -2 {15G}
Assets:Tajer:Items "Wildheart Belt" 1 @ 30G
Assets:Tajer:Items "Ace of Warlords" -2 @ 15G
2006/03/17 Auction House
Expenses:Fees:Auction 7482c
@ -610,8 +610,8 @@ D 1.00G
Assets:Tajer -120c 0
06-Mar-14 Puldoost Assets:Tajer 80000c 80000c
Expenses:Items -80000c 0
06-Mar-14 Auction House Assets:Wyshona:Items 12500c 12500c
Assets:Tajer:Items -12500c 0
06-Mar-14 Auction House Assets:Wyshona:Items "Plans: Wildthorn Mail" 1 "Plans: Wildthorn Mail" 1
Assets:Tajer:Items "Plans: Wildthorn Mail" -1 0
06-Mar-15 Auction House Assets:Tajer 4500c 4500c
Assets:Tajer 259c 4759c
Assets:Bids -4759c 0
@ -681,11 +681,17 @@ D 1.00G
Assets:Tajer:Items -1195768c 0
Income:Brokering -545768c -545768c
Equity:Capital Gains 545768c 0
06-Mar-16 Auction House Assets:Wyshona:Items 21050c 21050c
Assets:Wyshona:Items 23000c 44050c
Assets:Wyshona:Items 10000c 54050c
Assets:Wyshona:Items 15000c 69050c
Assets:Tajer:Items -69050c 0
06-Mar-16 Auction House Assets:Wyshona:Items "Plans: Mithril Shield Spike" 1 "Plans: Mithril Shield Spike" 1
Assets:Wyshona:Items "Plans: Mithril Shield Spike" 1 "Plans: Mithril Shield Spike" 2
Assets:Wyshona:Items "Recipe: Elixir of Giant Growth" 1 "Plans: Mithril Shield Spike" 2
"Recipe: Elixir of Giant Growth" 1
Assets:Wyshona:Items "Recipe: Elixir of Giant Growth" 1 "Plans: Mithril Shield Spike" 2
"Recipe: Elixir of Giant Growth" 2
Assets:Tajer:Items "Plans: Mithril Shield Spike" -1 "Plans: Mithril Shield Spike" 1
"Recipe: Elixir of Giant Growth" 2
Assets:Tajer:Items "Plans: Mithril Shield Spike" -1 "Recipe: Elixir of Giant Growth" 2
Assets:Tajer:Items "Recipe: Elixir of Giant Growth" -1 "Recipe: Elixir of Giant Growth" 1
Assets:Tajer:Items "Recipe: Elixir of Giant Growth" -1 0
06-Mar-16 Player Assets:Tajer 40000c 40000c
Equity:Gold -40000c 0
06-Mar-16 Auction House Assets:Wyshona 134100c 134100c
@ -719,8 +725,8 @@ D 1.00G
Assets:Tajer -300030c 0
06-Mar-16 Auction House Assets:Gruulmorg:Items 300000c 300000c
Assets:Gruulmorg -300000c 0
06-Mar-16 Transfer Assets:Tajer:Items 300000c 300000c
Assets:Gruulmorg:Items -300000c 0
06-Mar-16 Transfer Assets:Tajer:Items "Ace of Warlords" 2 "Ace of Warlords" 2
Assets:Gruulmorg:Items "Ace of Warlords" -2 0
06-Mar-16 Post Expenses:Fees:Mail 60c 60c
Assets:Gruulmorg -60c 0
06-Mar-16 Post Expenses:Fees:Mail 120c 120c