When automatically associating lot details with a commodity, use only the
price (based on the cost of the transactions), don't automatically use the date and the entry code -- since most people aren't going to be that specific at the time of sale, it's causes confusion in certain cases.
This commit is contained in:
parent
fdc7a4e4c5
commit
1c2944d829
3 changed files with 7 additions and 13 deletions
|
|
@ -182,7 +182,10 @@ amount_t commodity_t::exchange(const amount_t& amount,
|
||||||
basis_cost = final_cost;
|
basis_cost = final_cost;
|
||||||
|
|
||||||
amount_t ann_amount(amount);
|
amount_t ann_amount(amount);
|
||||||
ann_amount.annotate(annotation_t(per_unit_cost, moment->date(), tag));
|
ann_amount.annotate
|
||||||
|
(annotation_t(per_unit_cost,
|
||||||
|
moment ? moment->date() : optional<date_t>(), tag));
|
||||||
|
|
||||||
return ann_amount;
|
return ann_amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -291,10 +291,7 @@ bool entry_base_t::finalize()
|
||||||
amount_t final_cost;
|
amount_t final_cost;
|
||||||
amount_t basis_cost;
|
amount_t basis_cost;
|
||||||
amount_t ann_amount =
|
amount_t ann_amount =
|
||||||
commodity_t::exchange(x_amt, final_cost, basis_cost, xact->cost, none,
|
commodity_t::exchange(x_amt, final_cost, basis_cost, xact->cost);
|
||||||
datetime_t(*xact->actual_date(),
|
|
||||||
time_duration_t(0, 0, 0)),
|
|
||||||
entry ? entry->code : optional<string>());
|
|
||||||
|
|
||||||
if (xact->amount.is_annotated()) {
|
if (xact->amount.is_annotated()) {
|
||||||
if (ann_amount.annotation().price)
|
if (ann_amount.annotation().price)
|
||||||
|
|
|
||||||
|
|
@ -285,14 +285,8 @@ xact_t * parse_xact(char * line, account_t * account, entry_t * entry = NULL)
|
||||||
per_unit_cost /= xact->amount;
|
per_unit_cost /= xact->amount;
|
||||||
|
|
||||||
if (xact->amount.commodity() &&
|
if (xact->amount.commodity() &&
|
||||||
! xact->amount.commodity().annotated) {
|
! xact->amount.commodity().annotated)
|
||||||
if (xact->entry)
|
xact->amount.annotate(annotation_t(per_unit_cost));
|
||||||
xact->amount.annotate(annotation_t(per_unit_cost,
|
|
||||||
xact->entry->actual_date(),
|
|
||||||
xact->entry->code));
|
|
||||||
else
|
|
||||||
xact->amount.annotate(annotation_t(per_unit_cost));
|
|
||||||
}
|
|
||||||
|
|
||||||
DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
|
DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
|
||||||
"Total cost is " << *xact->cost);
|
"Total cost is " << *xact->cost);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue