Beispiel #1
0
def validate_order(product, quantity, errs, msgs):
    if product not in inventory.skus(): 
        errs.append('bad-product') 
    elif quantity > inventory.stock(product):
        errs.append('check-quantity')
    else:
        inventory.reduce(product, quantity)
        if inventory.stock(product) / quantity < 2:
            msgs.append('reorder-soon:' + repr(product))
def validate_order():
    if PRODUCT not in inventory.skus():      # this function could be imported
        errs.append('bad-product')           # from a user-defined module too
    elif QUANTITY > inventory.stock(PRODUCT):
        errs.append('check-quantity')
    else:
        inventory.reduce(PRODUCT, QUANTITY)
        if inventory.stock(PRODUCT) / QUANTITY < 2:
            msgs.append('reorder-soon:' + `PRODUCT`)
Beispiel #3
0
def validate_order():
    if PRODUCT not in inventory.skus():  # this function could be imported
        errs.append('bad-product')  # from a user-defined module too
    elif QUANTITY > inventory.stock(PRODUCT):
        errs.append('check-quantity')
    else:
        inventory.reduce(PRODUCT, QUANTITY)
        if inventory.stock(PRODUCT) / QUANTITY < 2:
            msgs.append('reorder-soon:' + ` PRODUCT `)
Beispiel #4
0
def validate_order(product, quantity, errs, msgs):
    if product not in inventory.skus():
        errs.append('bad-product')
    elif quantity > inventory.stock(product):
        errs.append('check-quantity')
    else:
        inventory.reduce(product, quantity)
        if inventory.stock(product) / quantity < 2:
            msgs.append('reorder-soon:' + ` product `)