#!/bin/bash
#                      /usr/local/bin/statement
# http://crystalfaeries.net/posix/bin/statement
# celeste:crystalfaery 2016-06-14 01:33:52+00:00

# where are general clockins and payments stored?
directory="/home/celeste/documents/ministry/"
cd	$directory	||	exit 1
for	person			 in $*;do
PERSON="$(echo ${person} | sed 's/\.statement\.txt$//g')"
	comment=$PERSON.statement.txt
	if [ -f $comment ]
	then
	echo ======= History for $PERSON from most recent preceeding statement, as of `/usr/local/bin/now` ======= ;	cat 	 $comment
	fi
	echo		 ======= Statement for $PERSON preceeding `/usr/local/bin/now` =======	 | tee -a	 $comment
	for	transaction	 in `ls *$PERSON.{clockin,payment}.txt` ;do
		echo	 ======= Transaction for $PERSON at $transaction =======				 | tee -a	 $comment
		cat	 $transaction										 | tee -a	 $comment
	done
	echo		 ======= Comment for $PERSON at `/usr/local/bin/now` =======				 | tee -a	 $comment
	read	answer
	echo	"$answer"											 >>		 $comment
	echo		 ======= Statement End for $PERSON at `/usr/local/bin/now` =======			 | tee -a	 $comment
	vi	 $comment
done


syntax highlighted by Code2HTML, v. 0.9.1