🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: dc.org.linux-users
Article #34

Bash point-of-sale script

#34
From: r cLIeNUX user
Date: Tue, 05 Apr 2005 09:20
712 lines
12367 bytes




# POSSE   Point Of Sale script etc.
# non-Bash dependancies: uses unix "date", cLIeNUX (screen) clear, 
#	(ASCII) bel...

storedir=/cornerpocket		
checksdir=$storedir/checks		## spam

# $CURCH is the current check #

fullname=RICK


riser		() {
echo "







"
}


undernplist	() {
       while read  timest  quant iname IPRICE  licost
                do
		  if test $licost != OPEN -a $licost != CLOSE   ; then
		     if test $quant -ne 1 ; then
			echo  $quant $iname $IPRICE $licost 
		     else 
			echo $iname $IPRICE 
		     fi	
		  fi
                done	
}


underTOClist	() {
unset table_t
unset table_p
unset table_n
       while read  timest playrs tname tnum licost
	do
		if test $licost = OPEN    ; then
			
			table_t[tnum]=$timest
			table_p[tnum]=$playrs
			table_n[tnum]=$tnum

		echo ${table_p[*]}
		echo ${table_t[*]}
		echo ${table_n[*]}
		fi
		
		if test $licost = CLOSE    ; then
			elapsedMinutes  $timest   ${table_t[tnum]}
			tablecalc   ${table_p[tnum]}  $elapsedmin
			echo $tablenet "table net"
			
			unset table_t[tnum]
			unset table_p[tnum]
			unset table_n[tnum]
		fi
	done
		echo ${table_p[*]}
		echo ${table_t[*]}
timestamp
for hanging in  ${table_n[*]}
do
	elapsedMinutes  $TIMESTAMP   ${table_t[$hanging]}
	tablecalc   ${table_p[$hanging]}  $elapsedmin
	echo $tablenet "table net "
			
done
}



TOClist 	() {
	underTOClist <    $checksdir/$CURCH

}



nonpoollist	() {
	undernplist  <   $checksdir/$CURCH
}


timestamp	() {
		TIMESTAMP=`date +%H%M`
}


getlast		() {
	read lastcheck < ${checksdir}/lastcheck
	echo $lastcheck
	let lastcheck=($lastcheck+1)%1000
	echo $lastcheck >  ${checksdir}/lastcheck 
}


huh		() { 
	bel
	clear
	date >> $storedir/huh 
	echo "			no comprendez"
	riser
	read junk
}


salestax 	() {
	let salesTAX=$SUBTOT/20
	echo "sales tax		" $salesTAX
}


elapsedMinutes	() {	#   stop  start
	stophours=${1:0:2}
	starthours=${2:0:2}
	stopmin=${1:2:2}
	startmin=${2:2:2}
	if test $stophours -lt $starthours 	; then
		let stophours=$stophours+24
	fi
	stopmin=$(((stophours*60)+$stopmin))
	startmin=$(((starthours*60)+$startmin))
elapsedmin=$(($stopmin-$startmin))
if test $elapsedmin -lt 30	; then
	elapsedmin=30
	bel
	echo "half-hour minimum in effect"
fi
}


entertainmenttax 	() {
	let entertainmentTAX=$SUBTOT/10
	echo 
	echo "entertainment tax	" $entertainmentTAX
}


undersubtot	() {
	while read  bla zay woof wuuf IPRICE  
		do
		 let SUBTOT=$SUBTOT+$IPRICE
		done
		echo "pretax subtotal	" $SUBTOT
}


subtot		() {
	SUBTOT=
	undersubtot < $checksdir/$CURCH
}


opencheck	() {	# get and set the next open check #
	getlast	
	CURCH=$NEXTCHECK
	let NEXTCHECK=$(($NEXTCHECK+1%10000))
	clear
	echo " New check is # " $CURCH
	read junk
	top
}


subtotal	() { #   sum all regular line items
	nonpoollist
	subtot
	salestax
	let TOTAL=$SUBTOT+$salesTAX
	echo "SUBTOTAL........... " $TOTAL
}


lineadd		() { #  append one line-item to current check 
	timestamp	
echo  $TIMESTAMP " 1 " $1 $2 $2 >>   $checksdir/$CURCH
}


multadd		() { #  append one line-item to current check 
	timestamp	
	mprice=$(($BAR*$2))
echo  $TIMESTAMP $BAR $1 $2 $mprice >> $checksdir/$CURCH
# add some server feedback
}


viewchecks	() {
	clear
	cd $checksdir
	for check_ in	`ls  `	; do
		echo "
CHECK " $check_
		cat $check_
	done
	cd -
}


scantables	() {
	grep -r TABLE $checksdir
}


setcheck	() {
	viewchecks
	echo "

	set current check #  to...


	"	
	read CURCH	
	# check for a valid numerical entry here please	
}


checkis		() {
 echo "current check and server is... " $CURCH " and " $fullname
}


shingle		() {
  echo              "
              Corner Pocket
          blabla Cherry Hill Rd.
	  Silver Spring Maryland
		  20902
	     301-931-blabla
	   whatevah@email.bla
"
}


appendcheck	() { 
clear 
checkis
echo "
	k	kitchen
	b	bar
	t	table
"
riser
read APPEND
case $APPEND in
	v)	void	;;
	k)	kitchen	;;
	b)	bar	;;
	t)	pool	;;
esac
}


kitchen		() {
	clear
	echo "
	a	appetizer
	b	bar
	d	soft drink
	sa	salad
	sf	seafood	dinner
	s	side
	su	sub
	sw	sandwich
"
riser
read KITC
case $KITC in
	a)	appetizer		;;
	b)	bar			;;
	d)	softdrink		;;	
	sa)	salad			;;
	sf)	seafood			;;
	s)	side			;;
	su)	sub			;;
	sw)	sandwich		;;
	*)	huh 			;;
esac
}


special		() {
clear
echo "
	l)	lunch special		
	p)	pool playa special		


stub.
	
"
riser
read crud
}


sub		() {
clear
echo "
	cb	cheeseburger
	cc	cold cut
	CC	chicken and cheese	
	fc	fish and cheese
	h	ham and cheese
	sc	steak and cheese
 	ssc	shrimp, steak and cheese
"
riser
read SUBM
case $SUBM in
	cb)	lineadd		cheeseburgsub		799	;;
	cc)	lineadd    	cold_cut		849	;;
	CC)	lineadd    	chickNcheese		799	;;
	fc)	lineadd    	fishNcheese		899	;;
	h)	lineadd    	hamNcheese		799	;;
	sc)	lineadd    	steakNcheese		799	;;
	ssc)	lineadd    	shrimpsteakcheese	899	;;
	*) huh							;;
esac
}


softdrink	() {
        clear
echo "
	b		bottomless soda	
	s		single soda
	j		juice	
"
riser
read  SOFTD
case $SOFTD in
	b)	lineadd	bottomless_soda		299	;;	
	s)	lineadd	single_soda		150	;;
	j)	lineadd	juice			300	;;
	*)	huh 					;;
esac
}


sandwich	() {
	clear 
echo "
	1	crabcake
	2	tuna salad
	3	turkey
	4	turkey club
	5	reuben

	6	chicken reuben
	7	turkey reuben
	8	patty melt
	9	tuna melt
	10 	BLT

	11	burger
	12	cheeseburger
	13	bacon cheeseburger
	14	grilled cheese
"
riser
read SANDW
case $SANDW in
	1)	lineadd		crabcake	1099	;;	
	2)      lineadd        	tunasalad	699	;;
	3)      lineadd        	turkey		699	;;
	4)      lineadd        	turkeyclub	799	;;
	5)      lineadd        	reuben		799	;;
	6)      lineadd        	chickenreuben	799	;;
	7)      lineadd        	turkeyreuben	799	;;
	8)      lineadd        	pattymelt	799	;;
	9)      lineadd        	tunamelt	799	;;
	10)      lineadd         BLT		599	;;
	11)      lineadd        burger		599	;;
	12)      lineadd        cheeseburger	649	;;	
	13)      lineadd        baccheeburger	749	;;
	14)      lineadd        grilledcheese	499	;;
	*) 	huh 		;;
esac
}


seafood		() {
	clear
	echo "
	1	pound of steamed shrimp	
	2	half pound steamed shrip
	3	fish and chips
	4	crab cake dinner
	5	super combo

	6	jumbo shrimp dinner
	7	scallop dinner
	8	oyster dinner
	9	CP combo
"
riser
read FISH
case $FISH in 
	1)	lineadd		half_lb_shrimp		 999	;;	
	2)	lineadd		lb_shrimp		1899	;;
	3)	lineadd		fishNchips		1099	;;
	4)	lineadd		crab_cake_din		1599	;;
	5)	lineadd		super_combo		1899	;;
	6)	lineadd		jumbo_shrimp_din	1099	;;
	7)	lineadd		scallop_din		 999	;;
	8)	lineadd		oyster_din		 999	;;
	9)	lineadd		CP_combo		1499	;;
	*) huh				;;
esac
}


side		() {
	clear
echo "
	c		cole slaw
	cf		curly fries
	Cf		cheese fries
	f		basket of fries
	o		onion rings
	t		toast
	s		side salad
"
riser
read SIDE
case	$SIDE in	 
	c)	lineadd		side_slaw	199	;;
	cf)	lineadd    	curly_fries	299	;;
	Cf)	lineadd    	cheese_fries	350	;;
	f)	lineadd    	side_fries	299	;;
	o)	lineadd    	onion_rings	399	;;
	t)	lineadd		toast		 99	;;
	s)	lineadd		side_salad 	399	;;
	*) huh 						;;
esac	
}


appetizer	() {
	clear
echo "
	1		10 Buffalo wings	
	2		20 Buffalo wings
	c		crab minis
	cc		celery and carrots
	cf		curly fries
	Cf		cheese fries
	f		basket of fries
	g		goya poppers
	h		half pound steamed shrimp
	j		jalapeno poppers	
	m		mozzarella sticks
	o		onion rings
	t		chicken tenders
	bt		Buffalo tenders
	s		Corner Pocket sampler


"
read APPET
case	$APPET in
	 
		1)	lineadd 	10_wings	699	;;
		2)	lineadd    	20_wings	1299	;;
		c)	lineadd    	crab_minis	899	;;
		cc)	lineadd    	celerycarrots	399	;;
		cf)	lineadd    	curly_fries	299	;;
		Cf)	lineadd    	cheese_fries	350	;;
		f)	lineadd    	side_fries	299	;;
		g)	lineadd    	goya_poppers	699	;;
		h)	lineadd    	steam_shrimp	999	;;
		j)	lineadd    	jalapeno_pop	699	;;
		m)	lineadd    	mozzarella_st	699	;;
		o)	lineadd    	onion_rings	399	;;
		t)	lineadd    	chicken_tenders	699	;;
		bt)	lineadd    	Buffalo_tenders	749	;;
		s)	lineadd    	sampler		899	;;
		*) huh 						;;
esac	
}


multibar	() {
clear
echo $BAR  " each of... 

		b		domestic bottle
		c		call
		d		draft
		i		import bottle
		h		high call
		r		rail
	"
riser
	read MULT
	case $MULT in
		 b)      multadd        	domestic	20	;;
		 c)      multadd        	call		40	;;
		 d)      multadd        	draft		25	;;
		 i)      multadd        	import		55	;;
		 h)      multadd        	highcall	100	;;	
		 r)      multadd        	rail		75	;;	
		 *)	huh					;;
	esac
}


bar		() {
	clear
	echo "

	happy hour prices are in specials menu
	
	input a number for a multiple entry

	b		domestic bottle
	c		call
	d		draft
	i		import bottle
	h		high call
	r		rail
"
riser
read BAR
case $BAR in
	b)      lineadd        	domestic	20	;;
	c)      lineadd        	call		40	;;
	d)      lineadd        	draft		25	;;
	i)      lineadd        	import		55	;;
	h)      lineadd        	highcall	100	;;	
	r)      lineadd        	rail		75	;;
	1|2|3|4|56|7|8|9) multibar		;;
	*)	huh					;;
esac
}


salad		() {
clear 
echo "
		g	garden
		C	chef
		c	chicken
		s	side
		t	tuna

"
riser
read 	SALAD

case $SALAD   in
		g) 	lineadd 	garden_salad	599	;;
		C)	lineadd		chef_salad	799	;;
		c)	lineadd		chicken_salad	799	;;
		s)	lineadd		side_salad	399	;;
		t)	lineadd		tuna_salad	699	;;		
		*) 	huh					;;	
esac
}


tablecalc	() { #	players  minutes	
	let flartch=(600+(200*$1))*$2
	let tablenet=$flartch/60
}


poolstart	() {
	clear 
	echo " enter table number"
	read TN
	clear
	echo " enter number of players"
	read PN
	clear
	timestamp
echo $TIMESTAMP $PN "TABLE" $TN "OPEN"  >>   $checksdir/$CURCH
 }


poolcloseevent	() {
	clear 
	scantables
	riser
		## grep TABLE $checksdir/$CURCH | wc

	echo " enter table number to close"
	riser
	read TN
	clear
	timestamp
	echo "
	entering a close event for table " $TN " on check " $CURCH
	echo $TIMESTAMP " nullPN TABLE " $TN " CLOSE " > $checksdir/$CURCH
}


poolsubtot	() {




:
}


pool		() {
clear 
echo "
	o	open
	c	close	
	l	list
"
riser
read POO
case 	$POO in
	o)	poolstart	;;
	c)	poolcloseevent	;;
	l)	scantables	
		read junk
		pool		;;
	*)	huh 		;;
esac
}


closeSALE	() {	
timestamp
clear
echo "
	closing check # " $CURCH 
riser

cat  /$checksdir/$CURCH  
riser
read junk	

## subtotal restaurant, then tables. Close tables at related close events
##   or now.

shingle
subtotal

}


top		() {
clear
if  test $CURCH ; then :
else
	setcheck
fi 	
checkis
riser
echo "
a	append to current check, i.e. add item other than pool table
c	set current check number
n	open a new check
p	start/close a pool table
s	SALE. close a check
t	view timed cost items (pool tables)
v	view open checks 
"
riser
read junk
case $junk in
	a)	appendcheck				;;
	c)	setcheck 				;;
	n)	opencheck				;;
	p)	pool					;;
	v)	viewchecks 				;;
	s)	closeSALE				;;
	t)	scantables				;;
	*) echo "bailout " 				;;	
esac
}


echo "
POSSE 
Point Of Sale Script Etc.
Rick Hohensee
started March 11 2005

Everything is timestamped internally. A check is a chronology. An active
tables list is ancillary to the checks effected. 

restaurant item...
timestamp QUAN  name  price  (cost=QUAN*price)

OR
start pool table...
timestamp players "TABLE" table# "VOID"

or something.

" > /dev/null
Technical Details
Message-ID: <1154m2llem5jp03@corp.supernews.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!sn-xit-03!sn-xit-08!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!r

Show Full Headers
Complete Article Headers
X-Google-Thread: 11663c,2cac8e894f04672f,start
X-Google-Attributes: gid11663c,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!sn-xit-03!sn-xit-08!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!r
From: r@cLIeNUX. (cLIeNUX user)
Newsgroups: dc.org.linux-users
Subject: Bash point-of-sale script
Date: Tue, 05 Apr 2005 09:20:21 -0000
Organization: Posted via Supernews, http://www.supernews.com
Message-ID: <1154m2llem5jp03@corp.supernews.com>
X-Newsreader: slrn (0.9.4.6 UNIX)
X-Complaints-To: abuse@supernews.com
Lines: 712