What's new

Python [Need Help] Simple POS python

maxsalvatore

Grasshopper
Mga lods baka matulungan ako ayaw ko po kasi mag record sa Logbook. Txt
ang Problema nalng is:

  • Not recording in Logbook.txt
  • the Delete has bug around "except Exception"

Not Done:
  • Transaction Sale
Document Link: You do not have permission to view the full content of this post. Log in or register now.
Code:
Python:
import sys

print("POS - PYTHON")
print(" = = = = = ")
while True:
    # **** Input ****
    choice = input(
        "Tasks: \n\tA - Add a Product \n\tV - View Products \n\tD  - Delete a Product \n\tT - Transact Sales \n\t[ANY KEY] - Exit\nChosen Task is: ")
    print(" = = = = = ")

    # **** Choices ****
    if choice in ('A', 'V', 'D', 'T', 'E'):

        if choice == "A":
            # **** Add Product ****
            print("< Add a Product >")
            prod1 = input(str("Product Name: "))
            prod2 = input(f"Product Price: ")
            print("! Product Added to the system.")
            try:
                file1 = open("Logbook.txt," "a")
            except Exception:
               pass  # print("! Product Not Valid. Invalid Price.")
            except ValueError:
                print("! Product Not Valid. Invalid Price.")
            else:
                print("")
                file1.write("", + {prod1.open})

        # **** View Product ****
        elif choice == "V":
            print("< View Products >")
            print("Product Name: ", {prod1})
            print("\tProduct Price: ", {prod2})
       
        # **** Delete Product ****
        elif choice == "D":
            print("< Delete a Product >")
            inp2 = input("Product Name: ")
            given_prod = [inp2]
            print(given_prod)
            if inp2 in given_prod:
                given_prod.remove(inp2)
            else:
                print("Product Removed from the Inventory.")
            try:

                file1 = prod1("Logbook.txt," "a")
            except Exception:
                print("! Product does not Exist!")
            else:
                print("")
                file1.write("", + {prod1.open})

        # **** Transact Sale ****
        elif choice == "T":
            print("< Transact Sales >")
            inp3 = input("Product Name: ")
            print("Total Cost: ")
            print("See LOGBOOK for transaction details.")
            try:
                inp3 = prod2
                print("Product does not Exist!")
            except Exception:
                pass
            else:
                print("")
    else:
        sys.exit(0)
        break
 

Similar threads

Back
Top