Sale Rev

Sale Reverse. Sell Stuff.

Python script for point of sale computer time.

more $ == more time.

Opens up sales data of products and saves for daily reports.

Saving the data as a json object. File has name of product as key and amount sold for value.

Easily merge json files.

At the end of each day keep the product in product folder but change sales data to 0.


In [123]:
import arrow
import os
import json

In [124]:
arut = arrow.utcnow()

In [ ]:
arday = arut

In [168]:



Out[168]:
'2015-02-28'

In [165]:
cofdot = dict()

In [126]:
#print('a to add time, b to remove time, c to')


a to add time, b to remove time, c to

In [127]:
#subscripe based.
#Get time

#Password expire.
#One month pass.
#10pm to 10am weekend pass.

In [128]:
armonth = arday.replace(month=+1)

In [129]:
armonth.month


Out[129]:
1

In [130]:
bemon = arday.replace(month=+4)

In [131]:
lsitems = os.listdir('/home/wcmckee/sellcoffee/products/')

In [132]:
lsitems

#Sales per day of items. Resets at midnight.


Out[132]:
['debian', 'internet', 'python', 'coffee', 'tired', 'snake', 'vogals', 'sleep']

In [133]:
dirza = ('/home/wcmckee/sellcoffee/products/')

In [140]:
daydict = dict()

#daydict.update({'datetime': str(arday.utcnow())})

In [141]:
for lsit in lsitems:
    print lsit
    #open each item up and read it.
    opitez = open(dirza + lsit, 'r')
    #print opitez.read()
    daydict.update({lsit : opitez.read()})
    opitez.close()
    
    #Make a json object for that days sales. 
    #Name of product. Amount Sold.


debian
internet
python
coffee
tired
snake
vogals
sleep

In [142]:
print daydict


{'vogals': '1', 'coffee': '1', 'sleep': '1', 'snake': '1', 'tired': '1', 'python': '1', 'internet': '15', 'debian': '1'}

In [158]:
jsday = json.dumps(daydict)

In [163]:
#The json object.  Should sale it to a folder. Maybe to 
#/yr/mnth/day folder?
#All in one folder, name of json file is datetime.

jsday


Out[163]:
'{"vogals": "1", "coffee": "1", "sleep": "1", "snake": "1", "tired": "1", "python": "1", "internet": "15", "debian": "1"}'

In [ ]:


In [169]:
savjsf = open('/home/wcmckee/sellcoffee/archive/' + str(arut.date()) + '.json', 'w')

In [170]:
savjsf.write(jsday)

In [171]:
savjsf.close()

In [172]:
#Reset value of int in products/nameofproducts folder to 0.

In [174]:
for lst in lsitems:
    print lst
    opfolaz = open('/home/wcmckee/sellcoffee/products/' + lst, 'w')
    opfolaz.write('0')
    opfolaz.close()


debian
internet
python
coffee
tired
snake
vogals
sleep

In [143]:
#for r in arrow.Arrow.span_range('hour', arday, bemon):
    #print r
#    for res in r:
#        print res.humanize()

In [144]:
#Total sales is value of all items in daydict

In [147]:
print (daydict.values())


['1', '1', '1', '1', '1', '1', '15', '1']

In [149]:
addnum = 0

In [151]:
for dayv in daydict.values():
    print dayv
    addnum = addnum + int(dayv)


1
1
1
1
1
1
15
1

In [156]:
totdsal = ('Total Sale numbers: ' + str(addnum))

In [157]:
print totdsal


Out[157]:
'Total Sale numbers: 22'

In [ ]: