Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. def sell():
  2. global base
  3. global magazine_base
  4. load_data()
  5. XD=1
  6. W1=0
  7. XD2=1
  8. W2=0
  9. while(XD1==1):
  10. name = raw_input('Name of the product: ')
  11.  
  12. is_new_entry = True
  13.  
  14. while(XD2==1 OR XD1==1):
  15. for entry in base:
  16. if name.lower() == entry['name'].lower():
  17. is_new_entry = False
  18. sp=float(entry['price'])
  19. quantity = raw_input('Quantity to sell: ')
  20. a=entry['quantity']
  21. if int(quantity) < entry['quantity']:
  22.  
  23. entry['quantity'] -= int(quantity)
  24. print '%s' % quantity, "of %s" % entry['name'], 'was sold for ' '%s' % float(sp*int(quantity)), 'PLN'
  25. magazine_base['base'] = base
  26. magazine_base.close()
  27. load_data()
  28. elif int(quantity) == int(a):
  29. print '%s' % quantity, "of %s" % entry['name'], 'was sold for ' '%s' % float(sp*int(quantity)), 'PLN'
  30. print "%s" % entry['name'], 'removed from the list'
  31. del base[base.index(entry)]
  32.  
  33. magazine_base['base'] = base
  34. magazine_base.close()
  35. else:
  36. print 'Not enough in magazine'
  37. W2=0;
  38. if is_new_entry:
  39. print 'Product is not in magazine'
  40. W1=0
  41.  
  42.  
  43.  
  44. magazine_base['base'] = base
  45. magazine_base.close()
  46.  
  47. if W1==1:
  48. XD1=0
  49. if W2==1:
  50. XD2=0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement