FlabbergastedMuffin

Inventory software

Sep 22nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.32 KB | None | 0 0
  1. # Fruit stand log by Morten BEIT KEA18DK
  2. from sys import argv
  3.  
  4. script, filename = argv
  5.  
  6. counter = 0
  7. promt = "> "
  8. spend = []
  9. sale = []
  10.  
  11. target = open(filename, 'a')
  12. def main_menu():
  13.     choice = 0
  14.     print("Fruitmarket Stock software 10.0.1")
  15.     print("Press 1 to add an iten to the inventory")
  16.     print("Press 2 to add an entry for a sale")
  17.     print("Press 3 to see a list of sales and purchases")
  18.     print("Press 4 to exit the program")
  19.  
  20. main_menu()
  21.  
  22. choice = input("What would you like to do? ")
  23.  
  24. while choice!=4:
  25.     if choice==0:
  26.         choice = int(input("What would you like to do? "))
  27.  
  28.     if choice==1:
  29.         print("What item did you purchase?")
  30.         item = input("Item: ")
  31.         print("Please enter the amount purchased")
  32.         amount = input("Amount: ")
  33.         entry = "Purchase"
  34.  
  35.         if len(item) >= 8:
  36.             target_formatter = "{0}\t{1}\t\t{2}\n"
  37.             formatted_lines = target_formatter.format(entry, item, amount)
  38.             target.write(formatted_lines)
  39.             choice = 0;
  40.             print("I've added the item to your inventory.")
  41.             print("\n")
  42.             main_menu()
  43.        
  44.         else:
  45.             target_formatter = "{0}\t{1}\t\t\t{2}\n"
  46.             formatted_lines = target_formatter.format(entry, item, amount)
  47.             target.write(formatted_lines)
  48.             choice = 0;
  49.             print("I've added sale entry to your list")
  50.             print("\n")
  51.             main_menu()
  52.    
  53.     elif choice==2:
  54.         print("What item did you sell?")
  55.         item = input("Item: ")
  56.         print("How many were sold?")
  57.         amount = input("Amount: ")
  58.         entry = "Sale"
  59.         if len(item) >= 8:
  60.             target_formatter = "{0}\t\t{1}\t\t{2}\n"
  61.             formatted_lines = target_formatter.format(entry, item, amount)
  62.             target.write(formatted_lines)
  63.             choice = 0;
  64.             print("I've added the item to your inventory")
  65.             print("\n")
  66.             main_menu()
  67.        
  68.         else:
  69.             target_formatter = "{0}\t\t{1}\t\t\t{2}\n"
  70.             formatted_lines = target_formatter.format(entry, item, amount)
  71.             target.write(formatted_lines)
  72.             choice = 0;
  73.             print("I've added the item to your inventory")
  74.             print("\n")
  75.             main_menu()
  76.    
  77.     elif choice==3:
  78.         print(f"Your current inputs are:")
  79.         target.close()
  80.         my_text = open(filename).read()
  81.         print(my_text, flush=True)
  82.         target = open(filename, 'a')
  83.         choice = 0
  84.         main_menu()
  85.        
  86.     elif choice==4:
  87.         print("Thank you! Come again.")
  88.         target.close()
  89.         exit()
  90.  
  91. else:
  92.     print("Please enter a number between 1 and 4")
  93.     print("\n")
  94.     choice = 0
  95.     main_menu()
Add Comment
Please, Sign In to add comment