Petty cash program ?

J

John Fitzsimons

I know I can do this in a spreadsheet, or even some word processors,
but that IMO would be swatting a fly with a sledge hammer. I want
something that is small, quick, easy and does the following.

Something that could be used in a normal petty cash situation or
when getting income in something like a flea market. So the end
result could be a plus, or minus, figure compared to the starting
figure.

Petty cash income/expenditure :

Starting amount :

Number of $100s [ ] = $
Number of $50s [ ] = $
Number of $20s [ ] = $
Number of $10s [ ] = $
Number of $ 5s [ ] = $
Number of $ 1s [ ] = $
Number of 50c [ ] = $ - c
Number of 20c [ ] = $ - c
Number of 10c [ ] = $ - c
Number of 5c [ ] = $ - c
--------------------------
Total (A) = $ - c


End amount ;

(As above)

Less (A) $ - c
--------------------
Result = $ - c

Does anyone here know if such a program already exists please ?
Or can perhaps code something ? In windows. :)

Regards, John.
 
J

John Corliss

John said:
I know I can do this in a spreadsheet, or even some word processors,
but that IMO would be swatting a fly with a sledge hammer. I want
something that is small, quick, easy and does the following.

Something that could be used in a normal petty cash situation or
when getting income in something like a flea market. So the end
result could be a plus, or minus, figure compared to the starting
figure.

Petty cash income/expenditure :

Starting amount :

Number of $100s [ ] = $
Number of $50s [ ] = $
Number of $20s [ ] = $
Number of $10s [ ] = $
Number of $ 5s [ ] = $
Number of $ 1s [ ] = $
Number of 50c [ ] = $ - c
Number of 20c [ ] = $ - c
Number of 10c [ ] = $ - c
Number of 5c [ ] = $ - c
--------------------------
Total (A) = $ - c


End amount ;

(As above)

Less (A) $ - c
--------------------
Result = $ - c

Does anyone here know if such a program already exists please ?
Or can perhaps code something ? In windows. :)

Regards, John.

How about this one:

http://www.calcant.net/calcant.html
 
C

Cousin Stanley

....

when getting income in something like a flea market.

So the end result could be a plus, or minus,
figure compared to the starting figure.

....

Cousin John ....

Have you considered stroking your snake ????

Usage is : python count_bucks.py

When prompted, ALWAYS enter something,
if values are 0 ....


'''
Module ....... count_bucks.py

Code_By ...... Stanley C. Kitching

Code_Date .... 2004-06-21
'''

import sys

module_this = sys.argv[ 0 ]

NL = '\n'

print NL , ' ' , module_this , NL


amount_starting = 0.00
amount_ending = 0.00


list_bills = [ 100 , 50 , 20 , 10 , 5 , 1 ]

dict_bills = { 100 : [ 0 , 0.00 ] ,
50 : [ 0 , 0.00 ] ,
20 : [ 0 , 0.00 ] ,
10 : [ 0 , 0.00 ] ,
5 : [ 0 , 0.00 ] ,
1 : [ 0 , 0.00 ] }


list_coins = [ 1.00 , 0.50 , 0.25 , 0.10 , 0.05 , 0.10 ]

dict_coins = { 1. : [ 0 , 0.00 ] ,
.5 : [ 0 , 0.00 ] ,
.25 : [ 0 , 0.00 ] ,
.1 : [ 0 , 0.00 ] ,
.05 : [ 0 , 0.00 ] ,
.01 : [ 0 , 0.00 ] }


def bills_input( dict_this ) :

print NL , ' Enter Number of Bills .... ' , NL

dict_this[ 100 ][ 0 ] = int( raw_input( ' # 100s : ' ) )
dict_this[ 50 ][ 0 ] = int( raw_input( ' # 50s : ' ) )
dict_this[ 20 ][ 0 ] = int( raw_input( ' # 20s : ' ) )
dict_this[ 10 ][ 0 ] = int( raw_input( ' # 10s : ' ) )
dict_this[ 5 ][ 0 ] = int( raw_input( ' # 5s : ' ) )
dict_this[ 1 ][ 0 ] = int( raw_input( ' # 1s : ' ) )


def dict_update( dict_this ) :

for this_key , these_values in dict_this.items() :

count = these_values[ 0 ]

amount = this_key * count

dict_this[ this_key ][ 1 ] = amount


def coins_input( dict_this ) :

print NL , ' Enter Number of Coins ....' , NL

dict_this[ 1. ][ 0 ] = int( raw_input( ' # 1.00s : ' ) )
dict_this[ .5 ][ 0 ] = int( raw_input( ' # 0.50s : ' ) )
dict_this[ .25 ][ 0 ] = int( raw_input( ' # 0.25s : ' ) )
dict_this[ .10 ][ 0 ] = int( raw_input( ' # 0.10s : ' ) )
dict_this[ .05 ][ 0 ] = int( raw_input( ' # 0.05s : ' ) )
dict_this[ .01 ][ 0 ] = int( raw_input( ' # 0.01s : ' ) )


def bucks_update() :

amount_starting = float( raw_input( ' Starting Amount : ' ) )

amount_ending = 0.00

bill_total = 0.00

coin_total = 0.00


bills_input( dict_bills )

dict_update( dict_bills )


coins_input( dict_coins )

dict_update( dict_coins )


print NL , NL
print ' Bill Count Amount'
print

for this_bill in list_bills :

count = dict_bills[ this_bill ][ 0 ]

amount = dict_bills[ this_bill ][ 1 ]

print ' %3d : %4d %d' % ( this_bill , count , amount )

bill_total += amount

print
print ' Bills Total ...... %d' % ( bill_total )


print NL

print ' Coin Count Amount'
print

for this_coin in list_coins :

count = dict_coins[ this_coin ][ 0 ]

amount = dict_coins[ this_coin ][ 1 ]

print ' %5.2f : %4d %7.2f' % ( this_coin , count , amount )

coin_total += amount


count_total = bill_total + coin_total

amount_ending = amount_starting + count_total


print NL , ' Coins Total ...... %6.2f' % ( coin_total ) , NL

print ' ------------------------------------------- ' , NL

print NL , ' Amount Starting .... %7.2f' % ( amount_starting )

print NL , ' Count Total ........ %7.2f' % ( count_total ) , ' Bills + Coins'

print ' ------'

print NL , ' Amount Ending ...... %7.2f' % ( amount_ending ) , NL



if __name__ == '__main__' :

bucks_update()
 
C

Cousin Stanley

Noticed a small typo in the coins list for the pennies value ....
list_coins = [ 1.00 , 0.50 , 0.25 , 0.10 , 0.05 , 0.10 ]

Should read ....

list_coins = [ 1.00 , 0.50 , 0.25 , 0.10 , 0.05 , 0.01 ]
 
J

John Fitzsimons

Cousin John ....

Hi Cousin Stanley,
Have you considered stroking your snake ????

Yes, I had. But learning Python is still on my "To do" list. Only
so many hours in a day. :-(
Usage is : python count_bucks.py
When prompted, ALWAYS enter something,
if values are 0 ....

< snip code >

Excellent ! Very nice. My first preference was a windows program
BUT this is (as I would expect from you) a very good option as
well. :)

A few very minor points.

(1) The script "as is" is fine for a petty cash situation. For a Flea
Market situation however my "Starting Amount" may differ from day
to day. So ideally the notes/coins totals * that I start with * would
need to be inputted to arrive at a "Starting Amount".

(2) "Bills" in Australia are what we call "invoices". I already have
too many of them ! "Bills" should be changed to "Notes". :)

(3) We do not have $1.00 notes here. Our paper (plastic) money only
goes down to a $5.00 note value.

(4) As far as coins are concerned we do not have 25c coins (your
quarters ?) we have 20c pieces.

(5) Our coins start at $2.00.

(6) As far as 10c coins are concerned I ended up with that item twice
on my display. I think the second one was supposed to be for .01c
coins ? We no longer have .01c coins currency in use in Australia.

If you don't have time to do a version (2) then I will see if I can
work out the changes myself. I will also need to try and work out what
the syntax is * if * I ever wanted to print the whole step by step
thing out.

I guess printing to a file is probably the way to go ? Though I mostly
wouldn't want to bother. Particularly as a "cut and paste" will also
give me what I want.

Don't know whether a print/don't "print to clipboard" and/or
print/don't "print to printer" and/or print/don't "print to file"
option would be possible or not. Maybe defaulting to "No" as I
wouldn't often bother printing things out.

In any case thanks again for putting in the time to help out. Very
much appreciated. :)

Regards, John.
 
C

Cousin Stanley

....
Excellent ! Very nice. My first preference was a windows program
BUT this is (as I would expect from you) a very good option as
well. :)

A few very minor points.

(1) The script "as is" is fine for a petty cash situation. For a Flea

Market situation however my "Starting Amount" may differ
from day to day.

So ideally the notes/coins totals * that I start with *
would need to be inputted to arrive at a "Starting Amount".

I considered Starting Amount to mean what was left over
from yesterday ....

As coded, will entering 0 for Starting Amount work for you ????
(2) "Bills" in Australia are what we call "invoices". I already have
too many of them ! "Bills" should be changed to "Notes". :)

I did tune the program for US names/values,
since that is what I know and use,
but it will be fairly simple to change
for any other currency type ....
(3) We do not have $1.00 notes here. Our paper (plastic) money only
goes down to a $5.00 note value.
Would the following list of notes be correct for Australia ????

list_notes = [ 100 , 50 , 20 , 10 , 5 ]
(4) As far as coins are concerned we do not have 25c coins (your
quarters ?) we have 20c pieces.

(5) Our coins start at $2.00.

(6) As far as 10c coins are concerned I ended up with that item twice
on my display. I think the second one was supposed to be for .01c
coins ? We no longer have .01c coins currency in use in Australia.

Yes ....

I made a typo in the original coins list
and entered .10 instead of 0.01 ....

A correction should have shown up in a follow up
to my original reply ....Would the following list of coins be correct for Australia ????

list_coins = [ 2.00 , 1,00 , 0.50 , 0.20 , 0.10 ]
If you don't have time to do a version (2) then I will see if I can
work out the changes myself. I will also need to try and work out what
the syntax is * if * I ever wanted to print the whole step by step
thing out.

I have time and will make changes tonight
or in the morning ....

Stay tuned ....
I guess printing to a file is probably the way to go ?

Though I mostly wouldn't want to bother.

Particularly as a "cut and paste" will also give me what I want.

Don't know whether a print/don't "print to clipboard" and/or
print/don't "print to printer" and/or print/don't "print to file"
option would be possible or not. Maybe defaulting to "No" as I
wouldn't often bother printing things out.

Copying the program output and pasting into an editor
then saving to a file should work ok to save the output ....

Also, you might try to pipe the output to a file ....

python count_bucks.py > yesterdays_count.txt
python count_bucks.py > todays_count.txt
python count_bucks.py > tommorrows_count.txt

Adding a prompt at the end to save program output to a file
might not be too hard ....
In any case thanks again for putting in the time to help out.

Very much appreciated. :)

You're welcome ....

Hopefully, the program will be useful for you
and encourage you to consider Python solutions
for other tasks that you may encounter ....

A primary advantage is cross-platform capabilities
without changes in coding ....

I built this small program under a Linux/Debian/Knoppix_3.2
hard-disk installation, but it should work on any platform
where Python is installed ....
 
C

Cousin Stanley

Cousin John ....

Made a few changes to the program that will hopefully
work for counting Australian instead of U.S. bucks,
and deals in Notes instead of Bills ....

I'm still not sure whether or not
I have the Coins List coded correctly ....

Since you mentioned a $2.00 coin,
I included one at the top of the list,
but didn't know if you also had a $1.00 coin ....

If not, you do now ....

If you really don't, let me know and you can
make a couple of simple changes at your end
that will get rid of it....


'''
Module ....... count_bucks_au.py

Code_By ...... Stanley C. Kitching

Code_Date .... 2004-06-21
'''

import sys

module_this = sys.argv[ 0 ]

NL = '\n'

print NL , ' ' , module_this , NL

amount_starting = 0.00
amount_ending = 0.00

list_notes = [ 100 , 50 , 20 , 10 , 5 , 1 ]

dict_notes = { 100 : [ 0 , 0.00 ] ,
50 : [ 0 , 0.00 ] ,
20 : [ 0 , 0.00 ] ,
10 : [ 0 , 0.00 ] ,
5 : [ 0 , 0.00 ] ,
1 : [ 0 , 0.00 ] }

list_coins = [ 2. , 1. , .5 , .2 , .1 , .05 ]

dict_coins = { 2. : [ 0 , 0.00 ] ,
1. : [ 0 , 0.00 ] ,
.5 : [ 0 , 0.00 ] ,
.2 : [ 0 , 0.00 ] ,
.1 : [ 0 , 0.00 ] ,
.05 : [ 0 , 0.00 ] }

def notes_input( dict_this ) :

print NL , ' Enter Number of Notes .... ' , NL

dict_this[ 100 ][ 0 ] = int( raw_input( ' # 100s : ' ) )
dict_this[ 50 ][ 0 ] = int( raw_input( ' # 50s : ' ) )
dict_this[ 20 ][ 0 ] = int( raw_input( ' # 20s : ' ) )
dict_this[ 10 ][ 0 ] = int( raw_input( ' # 10s : ' ) )
dict_this[ 5 ][ 0 ] = int( raw_input( ' # 5s : ' ) )
dict_this[ 1 ][ 0 ] = int( raw_input( ' # 1s : ' ) )

def dict_update( dict_this ) :

for this_key , these_values in dict_this.items() :

count = these_values[ 0 ]

amount = this_key * count

dict_this[ this_key ][ 1 ] = amount

def coins_input( dict_this ) :

print NL , ' Enter Number of Coins ....' , NL

dict_this[ 2. ][ 0 ] = int( raw_input( ' # 2.00s : ' ) )
dict_this[ 1. ][ 0 ] = int( raw_input( ' # 1.00s : ' ) )
dict_this[ .5 ][ 0 ] = int( raw_input( ' # 0.50s : ' ) )
dict_this[ .2 ][ 0 ] = int( raw_input( ' # 0.20s : ' ) )
dict_this[ .1 ][ 0 ] = int( raw_input( ' # 0.10s : ' ) )
dict_this[ .05 ][ 0 ] = int( raw_input( ' # 0.05s : ' ) )

def bucks_update() :

amount_starting = float( raw_input( ' Starting Amount : ' ) )

amount_ending = 0.00

note_total = 0.00

coin_total = 0.00


notes_input( dict_notes )

dict_update( dict_notes )


coins_input( dict_coins )

dict_update( dict_coins )


print NL , NL
print ' Note Count Amount'
print

for this_note in list_notes :

count = dict_notes[ this_note ][ 0 ]

amount = dict_notes[ this_note ][ 1 ]

print ' %3d : %4d %d' % ( this_note , count , amount )

note_total += amount

print
print ' Notes Total ...... %d' % ( note_total )


print NL

print ' Coin Count Amount'
print

for this_coin in list_coins :

count = dict_coins[ this_coin ][ 0 ]

amount = dict_coins[ this_coin ][ 1 ]

print ' %5.2f : %4d %7.2f' % ( this_coin , count , amount )

coin_total += amount


count_total = note_total + coin_total

amount_ending = amount_starting + count_total


print NL , ' Coins Total ....... %7.2f' % ( coin_total ) , NL

print ' ------------------------------------------- ' , NL

print NL , ' Amount Starting .... %7.2f' % ( amount_starting )

print NL , ' Count Total ........ %7.2f' % ( count_total ) , ' Notes + Coins'

print ' ------'

print NL , ' Amount Ending ...... %7.2f' % ( amount_ending ) , NL



if __name__ == '__main__' :

bucks_update()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top