From c9fb11bd60a2170fb896d77ff8d7706f563ad597 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 8 Nov 2004 06:43:11 +0000 Subject: updated to version 2.0 --- scripts/README | 5 ++--- scripts/bal | 18 ++++++------------ scripts/bal-huquq | 21 +++++++++++++++++++++ scripts/entry | 2 +- scripts/getquote | 8 ++++---- scripts/mean | 27 --------------------------- scripts/profit | 2 -- scripts/reg | 14 -------------- scripts/report | 28 ++++++++++++++++------------ scripts/spending | 8 -------- scripts/tc | 7 +++++++ scripts/ti | 5 +++++ scripts/to | 3 +++ scripts/trend | 30 ++++++++++++++++++++++++++++++ scripts/worth | 2 -- 15 files changed, 95 insertions(+), 85 deletions(-) mode change 100644 => 100755 scripts/bal create mode 100755 scripts/bal-huquq mode change 100644 => 100755 scripts/entry mode change 100644 => 100755 scripts/getquote delete mode 100644 scripts/mean delete mode 100644 scripts/profit delete mode 100644 scripts/reg mode change 100644 => 100755 scripts/report delete mode 100644 scripts/spending create mode 100755 scripts/tc create mode 100755 scripts/ti create mode 100755 scripts/to create mode 100755 scripts/trend delete mode 100644 scripts/worth (limited to 'scripts') 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 old mode 100644 new mode 100755 index 7fdf54ca..be7c3a0a --- 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 old mode 100644 new mode 100755 index 28daf8c8..cc030d8e --- 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 old mode 100644 new mode 100755 index cf8c8abd..bed561d6 --- 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 () { - ($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 old mode 100644 new mode 100755 index aa42982e..24418cdc --- 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 <