Skip to content

Instantly share code, notes, and snippets.

@iamricard
Last active December 27, 2015 02:39
Show Gist options
  • Save iamricard/7253541 to your computer and use it in GitHub Desktop.
Save iamricard/7253541 to your computer and use it in GitHub Desktop.
def update_stock(movements, stock, reference, min_stock):
if not stock:
stock = 0
if not min_stock:
min_stock = 0
output_string = ''
for movement in movements:
stock += movements[movement]
output_string += ('{0} => {1} unidades\n'.format(movement, movements[movement]))
print ("REFERENCIA: {0}".format(reference))
print ('Inventario final: {0}'.format(stock))
print (output_string)
if (stock < min_stock):
print ('Inventario inferior a {0} unidades, ¡URGENTE SOLICITAR A PROVEEDOR!'.format(min_stock))
movements = {
'11:30': -50,
'12:30': 15,
'16:30': 40
}
update_stock(movements, 40, 'AVX-23', 35)
@iamricard
Copy link
Author

@aaleex oops

@sospedra
Copy link

Reference AVX as a parameter is not needed. Just print it.

@iamricard
Copy link
Author

@bursos this assumes the reference may change. As it would in real life. Granted if it always were AVX-23 we could just print it out instead, but it is always better practice to avoid hard coding anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment