asset gain report added (-A)
This commit is contained in:
parent
1a1c8cdd2b
commit
d022744c18
2 changed files with 55 additions and 12 deletions
26
README
26
README
|
|
@ -403,7 +403,12 @@ To enable pricing reports, three options are possible:
|
|||
at time of purchase. Thus, totals in the register and balance
|
||||
report reflect the total amount spent.
|
||||
|
||||
**-Q FILE** ::
|
||||
**-A** ::
|
||||
Report commodities in terms of their net gain, which is: the market
|
||||
value minus the cost basis. A balance report using this option
|
||||
shows very quickly the performance of investments.
|
||||
|
||||
**-Q** ::
|
||||
When needed (see the =-L= option) pricing quotes are obtained by
|
||||
calling the script =getquote= (a sample Perl script is provided, but
|
||||
the interface is kept simple so replacements may be made).
|
||||
|
|
@ -413,8 +418,16 @@ To enable pricing reports, three options are possible:
|
|||
pricing data is older than MINS minutes. The default is one day,
|
||||
or 1440 minutes.
|
||||
|
||||
Note that the =-B=, =-T=, =-V=, and =-P= and =-Q= flags are all
|
||||
mutually exclusive. Whichever option appears last is used.
|
||||
**-p ARG** ::
|
||||
If a string, such as "COMM=$1.20", the commodity COMM will be
|
||||
reported only in terms of the conversion factor, which supersedes
|
||||
all other pricing histories for that commodity. This can be used to
|
||||
perform arbitrary value substitutions. For example, to report the
|
||||
value of your dollars in terms of the ounces of gold they would buy,
|
||||
use: -p "$=0.00280112 AU" (or whatever the current exchange rate
|
||||
is).
|
||||
|
||||
Note that the =-B=, =-T=, =-V=, and =-A= are mutually exclusive.
|
||||
|
||||
** Accounts and Inventories
|
||||
|
||||
|
|
@ -1169,7 +1182,12 @@ launches =vi= to let you confirm that the entry looks appropriate.
|
|||
at time of purchase. Thus, totals in the register and balance
|
||||
report reflect the total amount spent.
|
||||
|
||||
**-Q FILE** ::
|
||||
**-A** ::
|
||||
Report commodities in terms of their net gain, which is: the market
|
||||
value minus the cost basis. A balance report using this option
|
||||
shows very quickly the performance of investments.
|
||||
|
||||
**-Q** ::
|
||||
When needed (see the =-L= option) pricing quotes are obtained by
|
||||
calling the script =getquote= (a sample Perl script is provided, but
|
||||
the interface is kept simple so replacements may be made).
|
||||
|
|
|
|||
41
reports.cc
41
reports.cc
|
|
@ -18,9 +18,10 @@ static bool full_names = false;
|
|||
static bool print_monthly = false;
|
||||
static bool gnuplot_safe = false;
|
||||
|
||||
static bool cost_basis = false;
|
||||
static bool use_history = false;
|
||||
static bool get_quotes = false;
|
||||
static bool cost_basis = false;
|
||||
static bool use_history = false;
|
||||
static bool net_gain = false;
|
||||
static bool get_quotes = false;
|
||||
long pricing_leeway = 24 * 3600;
|
||||
std::string price_db;
|
||||
|
||||
|
|
@ -88,6 +89,23 @@ static amount * resolve_amount(amount * amt,
|
|||
else if (cost_basis) {
|
||||
value = amt->value();
|
||||
}
|
||||
else if (net_gain) {
|
||||
value = amt->street(when ? when : (have_ending ? &end_date : NULL),
|
||||
use_history, get_quotes);
|
||||
amount * basis = amt->value();
|
||||
if (value->commdty() == basis->commdty()) {
|
||||
basis->negate();
|
||||
value->credit(basis);
|
||||
} else {
|
||||
// If the commodities do not match, ignore this amount by
|
||||
// returning a zeroed value.
|
||||
delete basis;
|
||||
basis = value->copy();
|
||||
basis->negate();
|
||||
value->credit(basis);
|
||||
delete basis;
|
||||
}
|
||||
}
|
||||
else {
|
||||
value = amt->street(when ? when : (have_ending ? &end_date : NULL),
|
||||
use_history, get_quotes);
|
||||
|
|
@ -992,7 +1010,7 @@ int main(int argc, char * argv[])
|
|||
|
||||
int c;
|
||||
while (-1 != (c = getopt(argc, argv,
|
||||
"+Bb:Ccd:Ee:Ff:Ghi:L:l:MN:nP:p:QRSsTUVv"))) {
|
||||
"+ABb:Ccd:Ee:Ff:Ghi:L:l:MN:nP:p:QRSsTUVv"))) {
|
||||
switch (char(c)) {
|
||||
case 'b':
|
||||
have_beginning = true;
|
||||
|
|
@ -1059,13 +1077,20 @@ int main(int argc, char * argv[])
|
|||
get_quotes = true;
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
cost_basis = true;
|
||||
// fall through...
|
||||
case 'V':
|
||||
use_history = true;
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
cost_basis = true;
|
||||
use_history = true;
|
||||
break;
|
||||
|
||||
case 'A':
|
||||
net_gain = true;
|
||||
use_history = true;
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
cost_basis = false;
|
||||
use_history = false;
|
||||
|
|
@ -1147,7 +1172,7 @@ int main(int argc, char * argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if (use_history && ! price_db.empty())
|
||||
if (use_history && ! cost_basis && ! price_db.empty())
|
||||
entry_count += parse_ledger_file(main_ledger, price_db, regexps,
|
||||
command == "equity");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue