0

Trying to create a pos system that develop an application that verify that the right user enters the system, and provide ability for the cashier to perform sales related activities like selling an item, accepting returns, recording sales and updating on-hand inventory, handle payments. etc.

Here are my codes:

Login Verification

X | [a) Assignment

def login():

attempts = 0

user_id = input("Please enter your User ID: ")

password = input("Please enter your password: ")

while attempts < 3:

if user_id == "user" and password ==

"password":

print( Login successful!")

return True else:

attempts += 1 if attempts < 3:

print("Incorrect credentials. Please try again.")

else:

print("Too many attempts. Access denied.")

return False

Create Item Class

class Item:

def init(self, upc, description, item_max_qty, order_threshold, replenishment_order_qty, item_on_hand, unit_price, order_placed):

self.upc = upc

self.description = description

self.item_max_qty = item_max_qty

self.order_threshold = order_threshold

self.replenishment_order_qty = replenishment_order_aty

self.item_on_hand = item_on_ hand

self.unit price = unit price

self.order_placed = order _placed

def updateUnitOnHand(self, numberOfltems):

self.item_on_hand += numberOfltems

Load Inventory Data

login():

file = open("RetailStoreltemData.txt", "r")

inventory = {

for line in file:

upc, description, item_max_qty, order_threshold, replenishment_order_aty, item_on_hand, unit_price, order_placed = line.strip().split("")

item = Item(upc, description, item_max_aty, order_ threshold, replenishment _order_aty, item_on_hand, unit price, order_placed)

inventory[upc] = item

Start a new Sale

def newSale():

sale = {]

while True:

upc = input("Please enter the UPC of the item you'd like to add to your sale. Enter 'done' when finished: ")

if upc.lower == "done":

break

item = inventory upc]

if item.item_on_hand > 0:

item.updateUnitOnHand(-1)

if upc in sale:

sale[upc] += 1 else:

sale[upc] = 1

else:

return sale

print("Sorry, we are currently out of stock on this item.")

X

Assignment 7 - Designi

Finalize Sale

def finalizeSale(sale):

total = 0

print("In Your sale:")

for upc in sale:

item = inventory[upc]

price = item.unit_price * sale[upc]

total += price

print (f"(item.description]: {sale [upc]} × {item.unit_price) = (price]")

print (f"Total: {totall\n")

cash = input(Please enter the amount of cash given: ")

if float(cash) >= total:

return True else:

return False

Assic

Handle Returns

def returnltem(sale):

upc = input("Please enter the UPC of the item you'd like to return: ")

if upc in sale:

item = inventory[upc]

item.updateUnitOnHand(1)

sale[upc] -= 1 if sale[upc] == 0:

del sale[upc]

print("Item successfully returned.")

else:

print("This item is not in your sale.")

def returnAllitems (sale):

for upc in sale:

item = inventory [upc]

item.updateUnitOnHand(sale [upc])

sale.clear()

print("All items successfully returned.")

Generate Reports

def generatelnventory Report():

print ("\nINVENTORY REPORTIn")

print (*UPC\DESCRIPTION\MAX QTY\tORDER THRESHOLD\tREPLENISHMENT ORDER QTY\tON HAND\UNIT PRICE\ORDER PLACED\n") for upc in inventory:

item = inventory[upc]

print(f" (item.upc)\t(item.description]\t(item.item_max_qty|\t{item.order_threshold)\t(item.replenishment_order_aty|\titem.item_on_hand/\t{item.unit_price}\t(item.order_placed)")

def generateSalesReport:

print("\nSALES REPORT\n")

print("UPC\tDESCRIPTION\tUNIT PRICE\QTY SOLD\n")

total = 0

for upc in inventory:

item = inventory [upc]

if item.order_placed == "y".

aty_sold = int(item.item_max_qty) - int(item.item_on_hand)

print (fª(item.upc}\t(item.description}\t(item.unit_price|\taty_sold!")

total += aty_sold * float(item.unit price)

print(fIn Total Sales: (total)")

Main Program

An

if login0:

while True:

if option == "1".

sale = newSale()

if finalize.Sale(sale).

option = input("\n. Start a new sale\n2. Generate Inventory Report\n3. Generate Sales Report\n4. Quit\n\nPlease enter an option: ")

if finalizeSale(sale):

print("Thank you for your purchase!")

else:

print("Insufficient funds.")

return item(sale)

elif option == "2".

generate inventory Report()

elif option == "3":

generateSalesReport0

elif option == "4".

break else:

print(Invalid option. Please try again.")

print("\n Thank you for using the POS system. Have a great day!")

H-Y
  • 1
  • this question could really use some formatting and showing the errors, and what is wrong. See https://stackoverflow.com/help/how-to-ask and https://stackoverflow.com/help/minimal-reproducible-example – Matthias Dec 19 '22 at 11:13
  • Needs a tag to say what programming language it is written in. I don't recognize `X | [a) Assignment`. Also, you haven't asked a question yet. – Raymond Chen Dec 19 '22 at 15:43

0 Answers0