Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Backup Retail POS
#1
While at work yesterday (small retail setting) the POS systems all crashed and left us manually writing down and calculating taxes by hand. I experimented with writing a script that takes purchases and puts them into a list, adding tax totals at the end.

I'm curious if anyone sees anything that can be improved upon/made more pythonic.

"""
Emergency Retail POS
Quick fix to add totals with tax
Tracks purchases and totals
"""

tax = float(input("What is tax: ")) #Sets amount of tax applied to each purchase, ex. 0.15
total_sales = 0 #Total $ value of purchase
sales = [] #List of individual items
sales_with_tax = [] #List of items plus tax
sales_tax = 0 #Cost of item plus tax
item = 1

while True:
    sale = float((input("Price of item number {} before taxes: ".format(item))))
    if sale == 0: #Exits loop and displays total
        print("="*40)
        item -= 1 #Ensure item count is correct
        print ("Total sales with tax: {}".format(total_sales)) #Total cost of purchase
        print("Total number of items: {}".format(item)) #How many items in cart
        break
    elif sale > 0:
        taxes = sale * tax
        sale_with_tax = round(sale + taxes, 2) #Rounds to two decimals places
        sales.append(sale)
        sales_with_tax.append(sale_with_tax)
        total_sales += sale_with_tax
        item += 1
        print("_" * 40)
        print("There are {} items".format(item - 1))
        print("Items without tax: $ {}".format(sales))
        print ("Items with tax: ${}".format((sales_with_tax)))
        print("Total purchase with tax: {}".format(round(total_sales, 2)))
        pass
Reply
#2
I think it could be functionally improved by using the cmd module. You could display the current list of items and add commands to remove or correct items or select tax rates, etc. There is some work to achieve this however.
Reply
#3
Looking into cmd it looks like it would work great. Thanks for your reply, I'm going to see what I can make of that.
Reply
#4
There's currently not a way to add items that aren't taxed, like food.
Another cool thing to add, would be a tally that went beyond a single transaction, so you could see how much sales were for the entire day/shift.
Perhaps ask how much they're paying, if cash, and offer what the change is?
Reply
#5
That's a great point - not taxing certain items on the fly would be a good addition. I was thinking of adding the daily net too. And I like the change idea! All workable helpful ideas.

Might post an update in here if I get some of those working.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020