summaryrefslogtreecommitdiff
path: root/contrib/raw/ledger-shell-environment-functions
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2013-01-29 13:45:44 -0700
committerCraig Earls <enderw88@gmail.com>2013-01-29 13:45:44 -0700
commit870c62bf14ec75d0bf2e951126c20747bee174f1 (patch)
tree39c0fa9e16775f2477710d6b0960146ed09f62dd /contrib/raw/ledger-shell-environment-functions
parentc1ad213f4e197b80a0b619bb04769f807a2be645 (diff)
parentc235b59a68d04ff22a16d317e4d67b69e570a1e4 (diff)
downloadfork-ledger-870c62bf14ec75d0bf2e951126c20747bee174f1.tar.gz
fork-ledger-870c62bf14ec75d0bf2e951126c20747bee174f1.tar.bz2
fork-ledger-870c62bf14ec75d0bf2e951126c20747bee174f1.zip
Merge commit 'c235b59a68d04ff22a16d317e4d67b69e570a1e4' into kitchen-sink
Diffstat (limited to 'contrib/raw/ledger-shell-environment-functions')
-rw-r--r--contrib/raw/ledger-shell-environment-functions90
1 files changed, 90 insertions, 0 deletions
diff --git a/contrib/raw/ledger-shell-environment-functions b/contrib/raw/ledger-shell-environment-functions
new file mode 100644
index 00000000..7746dc41
--- /dev/null
+++ b/contrib/raw/ledger-shell-environment-functions
@@ -0,0 +1,90 @@
+# Environment for ledger expenses
+
+[ $(whoami) == "adamsrl" ] \
+ && export LEDGER_HOME="/home/adamsrl/AdamsInfoServ/BusinessDocuments/Ledger/AdamsRussell" \
+ || export LEDGER_HOME="/home/Heather/AdamsRussell"
+
+[ $(hostname) == "cardamom" ] \
+ && export LEDGER_BIN="${LEDGER_HOME}/ledger" \
+ || export LEDGER_BIN="${LEDGER_HOME}/ledger.exe"
+
+[ $(whoami) == "andersonll" ] \
+ && export LEDGER_HOME="/home/andersonll/AdamsInfoServ/Expenses" \
+ && export LEDGER_BIN="${LEDGER_HOME}/ledger"
+
+# Common reports
+
+alias ledger='${LEDGER_BIN} -f "${LEDGER_HOME}/.ledger" -VE '
+alias ERSummary='ledger --pivot ER bal | egrep "AIS(ER|IN)[0-9]+|Unassigned"'
+
+function ERTxns() {
+ [ -z "$1" ] && echo "Please specify an ER number (ie: AISER0042)." && return
+
+ ledger reg "%ER=${1}"
+}
+
+function ERCategorySummary() {
+ [ -z "$1" ] && echo "Please specify an ER number (ie: AISER0042)." && return
+
+ ledger bal --pivot CATEGORY "%ER=${1}"
+}
+
+function ERMealSummary() {
+ [ -z "$1" ] && echo "Please specify an ER number (ie: AISER0042)." && return
+
+ ledger reg "%ER=${1}" and %CATEGORY=Meals -D
+}
+
+function ERMeals() {
+ [ -z "$1" ] && echo "Please specify an ER number (ie: AISER0042)." && return
+
+ ledger reg "%ER=${1}" and %CATEGORY=Meals
+}
+
+function ERUncleared() {
+ [ -z "$1" ] && echo "Please specify an ER number (ie: AISER0042)." && return
+
+ ledger reg "%ER=${1}" -U
+}
+
+function ERMissingReceipts() {
+ [ -z "$1" ] && echo "Please specify an ER number (ie: AISER0042)." && return
+
+ ledger reg "%ER=${1}" and not %RECEIPT
+}
+
+function ERVerify() {
+ [ -z "$1" ] && echo "Please specify an ER number (ie: AISER0042)." && return
+
+ echo "========== Uncleared txns below =========="
+ ERUncleared "$1"
+ echo "========== Missing receipts below (miles and stubs ok) =========="
+ ERMissingReceipts "$1"
+ echo "========== Category Summary (airline? mileage? car? hotel? =========="
+ ERCategorySummary "$1"
+ echo "========== Meal summary (<\$50 / day unless otherwise specified) =========="
+ ERMealSummary "$1"
+ echo "========== Account Verification (Internal vs Project ER should be ONE type) =========="
+ echo $1 | grep AISIN >/dev/null 2>&1 \
+ || { ledger reg "%ER=${1}" | grep Dest:Internal ; } \
+ && { ledger reg "%ER=${1}" | grep Dest:Projects ; }
+ echo "========== Project Verification (only one project code should be listed) =========="
+ ledger print "%ER=${1}" | grep PROJECT | sort -u
+ echo "========== Receipts missing =========="
+ ledger print "%ER=${1}" | grep -h '; RECEIPT: ' \
+ | sed 's,\W*; RECEIPT: ,,g' \
+ | tr , '\n' \
+ | sort -u \
+ | while read X ; do
+ [ -f "${LEDGER_HOME}/${X}" ] \
+ || echo XX $X
+ done
+}
+
+function ERListing() {
+ ledger reg Stub --register-format="%(tag('ER')) %(tag('NOTE'))\n" | sort -u
+}
+
+function ERQueue() {
+ ledger reg %ER=Unassigned --prepend-format="%(filename) "
+}