diff options
author | John Wiegley <johnw@newartisans.com> | 2004-11-08 06:43:11 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 02:40:47 -0400 |
commit | c9fb11bd60a2170fb896d77ff8d7706f563ad597 (patch) | |
tree | 42bdf09e7d8727ba31d1d8dae9b4eb4b2a605441 /scripts | |
parent | fa2ceaed13c031add578ee8eb33da0c9980b9fb1 (diff) | |
download | fork-ledger-c9fb11bd60a2170fb896d77ff8d7706f563ad597.tar.gz fork-ledger-c9fb11bd60a2170fb896d77ff8d7706f563ad597.tar.bz2 fork-ledger-c9fb11bd60a2170fb896d77ff8d7706f563ad597.zip |
updated to version 2.0
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/README | 5 | ||||
-rwxr-xr-x[-rw-r--r--] | scripts/bal | 18 | ||||
-rwxr-xr-x | scripts/bal-huquq | 21 | ||||
-rwxr-xr-x[-rw-r--r--] | scripts/entry | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | scripts/getquote | 8 | ||||
-rw-r--r-- | scripts/mean | 27 | ||||
-rw-r--r-- | scripts/profit | 2 | ||||
-rw-r--r-- | scripts/reg | 14 | ||||
-rwxr-xr-x[-rw-r--r--] | scripts/report | 28 | ||||
-rw-r--r-- | scripts/spending | 8 | ||||
-rwxr-xr-x | scripts/tc | 7 | ||||
-rwxr-xr-x | scripts/ti | 5 | ||||
-rwxr-xr-x | scripts/to | 3 | ||||
-rwxr-xr-x | scripts/trend | 30 | ||||
-rw-r--r-- | scripts/worth | 2 |
15 files changed, 95 insertions, 85 deletions
diff --git a/scripts/README b/scripts/README index 7221f95f..6108afbf 100644 --- a/scripts/README +++ b/scripts/README @@ -1,5 +1,4 @@ -This scripts are provided just in the way of giving ideas. They -probably all need to be modified to suit your particular environment. -Beware! +This scripts are provided just to give some ideas. They probably need +to be modified to better suit your environment. Beware! John diff --git a/scripts/bal b/scripts/bal index 7fdf54ca..be7c3a0a 100644..100755 --- a/scripts/bal +++ b/scripts/bal @@ -1,27 +1,21 @@ #!/bin/sh -switch="" -current="-c" -limit="-l \$50" -negonly="-N ^Liabilities" +switch="-c" +limit="-t (/Liabilities/?a<0:Ua>100)&a" -if [ "$1" = "-C" -o "$1" = "-U" -o "$1" = "-P" ]; then +if [ "$1" = "-C" -o "$1" = "-U" ]; then switch="$1" shift -elif [ "$1" = "-b" -o "$1" = "-e" ]; then - current="$1 $2" +elif [ "$1" = "-b" -o "$1" = "-e" -o "$1" = "-p" ]; then + switch="$1 $2" shift 2 fi accts="$@" if [ -z "$accts" ]; then accts="-Equity -Income -Expenses" - if [ ! "$switch" = "-P" ]; then - accts="$accts -Savings -Retirement" - fi else limit="" - negonly="" fi -ledger $current $limit $negonly -s $switch balance $accts +ledger -VQ $switch $limit -s -S "-AT" balance $accts diff --git a/scripts/bal-huquq b/scripts/bal-huquq new file mode 100755 index 00000000..c17c84a2 --- /dev/null +++ b/scripts/bal-huquq @@ -0,0 +1,21 @@ +#!/bin/sh + +switch="-c" +limit="-t (/Liabilities/?(/Huquq/?a/P{2.22AU}<={-1.0}:a<0):Ua>100)&a" + +if [ "$1" = "-C" -o "$1" = "-U" ]; then + switch="$1" + shift +elif [ "$1" = "-b" -o "$1" = "-e" -o "$1" = "-p" ]; then + switch="$1 $2" + shift 2 +fi + +accts="$@" +if [ -z "$accts" ]; then + accts="-Equity -Income -Expenses" +else + limit="" +fi + +ledger -VQ $switch $limit -s -S "-AT" balance $accts diff --git a/scripts/entry b/scripts/entry index 28daf8c8..cc030d8e 100644..100755 --- a/scripts/entry +++ b/scripts/entry @@ -1,6 +1,6 @@ #!/bin/sh -if [ -z "$LEDGER" -o ! -r $LEDGER ]; then +if [ -z "$LEDGER" -o ! -r "$LEDGER" ]; then echo Please set your LEDGER environment variable. fi diff --git a/scripts/getquote b/scripts/getquote index cf8c8abd..bed561d6 100644..100755 --- a/scripts/getquote +++ b/scripts/getquote @@ -1,16 +1,16 @@ #!/usr/bin/perl -exit 0 if $ARGV[0] eq "\$"; +$timeout = 60; use Finance::Quote; $q = Finance::Quote->new; - -$q->timeout(60); +$q->timeout($timeout); $q->require_labels(qw/price/); %quotes = $q->fetch("nasdaq", $ARGV[0]); - if ($quotes{$ARGV[0], "price"}) { print "\$", $quotes{$ARGV[0], "price"}, "\n"; +} else { + exit 1; } diff --git a/scripts/mean b/scripts/mean deleted file mode 100644 index 3c6f779a..00000000 --- a/scripts/mean +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/perl - -$last = $ARGV[-1]; -splice(@ARGV, -1); - -open(PIPE, "ledger -MG @ARGV register $last |") || die; -@values = (); -while (<PIPE>) { - ($date, $value) = split; - push @values, $value; -} -close(PIPE); - -@values = sort @values; -splice(@values, 0, 1); -splice(@values, -1); - -$value = 0.0; -for $item (@values) { - $value += $item; -} - -if (@values) { - printf("%.2f\n", $value / @values); -} else { - die "There are no values to average!\n"; -} diff --git a/scripts/profit b/scripts/profit deleted file mode 100644 index 26f112d1..00000000 --- a/scripts/profit +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -ledger "$@" balance ^Income$ ^Expenses$ diff --git a/scripts/reg b/scripts/reg deleted file mode 100644 index 75ac364e..00000000 --- a/scripts/reg +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -switch="-U" -current="-c" - -if [ "$1" = "-C" -o "$1" = "-U" -o "$1" = "-P" -o "$1" = "-M" ]; then - switch="$1" - shift -elif [ "$1" = "-b" -o "$1" = "-e" ]; then - current="$1 $2" - shift 2 -fi - -ledger $current -s $switch register "$@" diff --git a/scripts/report b/scripts/report index aa42982e..24418cdc 100644..100755 --- a/scripts/report +++ b/scripts/report @@ -1,17 +1,21 @@ #!/bin/sh -dir=$HOME/doc/finance +# This script facilities plotting of a ledger register report. If you +# use OS/X, and have AquaTerm installed, you will probably want to set +# LEDGER_TERM to "aqua". +# +# Examples of use: +# +# report -j -M reg food # plot monthly food costs +# report -J reg checking # plot checking account balance -cd /tmp +if [ -z "$LEDGER_TERM" ]; then + LEDGER_TERM="x11 persist" +fi -ledger -M -G register "$@" > $1 - -gnuplot <<EOF -set terminal png -set output "report.png" -set xdata time -set timefmt "%Y/%m/%d" -plot "$1" using 1:2 with linespoints +(cat <<EOF; ledger "$@") | gnuplot + set terminal $LEDGER_TERM + set xdata time + set timefmt "%Y/%m/%d" + plot "-" using 1:2 with lines EOF - -open report.png diff --git a/scripts/spending b/scripts/spending deleted file mode 100644 index 895c4170..00000000 --- a/scripts/spending +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -ledger "$@" balance \ - Expenses:Food \ - Expenses:Movies \ - Expenses:Auto:Gas \ - Expenses:Tips \ - Expenses:Health \ - Expenses:Supplies diff --git a/scripts/tc b/scripts/tc new file mode 100755 index 00000000..c24be99a --- /dev/null +++ b/scripts/tc @@ -0,0 +1,7 @@ +#!/bin/sh + +timeclock out + +proj="$1" +shift +timeclock in "$proj" "$@" diff --git a/scripts/ti b/scripts/ti new file mode 100755 index 00000000..a7214e65 --- /dev/null +++ b/scripts/ti @@ -0,0 +1,5 @@ +#!/bin/sh + +proj="$1" +shift +timeclock in "$proj" "$@" diff --git a/scripts/to b/scripts/to new file mode 100755 index 00000000..3198db3c --- /dev/null +++ b/scripts/to @@ -0,0 +1,3 @@ +#!/bin/sh + +timeclock out "$@" diff --git a/scripts/trend b/scripts/trend new file mode 100755 index 00000000..3c189c0b --- /dev/null +++ b/scripts/trend @@ -0,0 +1,30 @@ +#!/bin/sh + +# This script requires Python support. +# +# To use, just run "trend" with the accounts to compute the trend for: +# +# trend dining +# +# The trend values are not terribly meaningful, but this gives an +# example of how Python can be used to create more complex reports. + +ledger --import-stdin -T "@rdev()" reg "$@" <<EOF +import ledger + +mean = ledger.parse_value_expr ("AT") +last_mean = None +last_dev = None + +def rdev (details): + global last_mean, last_dev + mval = mean.compute (details) + if last_mean is None: + dev = ledger.Value () + else: + dev = mval - last_mean + dev = (last_dev + dev) / 2 + last_mean = mval + last_dev = dev + return dev +EOF diff --git a/scripts/worth b/scripts/worth deleted file mode 100644 index 58b20440..00000000 --- a/scripts/worth +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -ledger "$@" balance ^Assets$ ^Liabilities$ |