Last active
December 27, 2015 02:39
-
-
Save iamricard/7253541 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Reference AVX as a parameter is not needed. Just print it.
@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
@aaleex oops