def __init__(self, quantity, time_unit='Y'): Validate.required(quantity, "quantity") Validate.non_negative(quantity, "quantity") self.quantity = quantity Validate.one_of_allowable(time_unit, ['Y', 'M', 'W', 'D'], "time_unit") self.time_unit = time_unit
def validate_init_values(unit_cost, ordering_cost, holding_rate, holding_cost, holding_time_unit, shortage_cost): Validate.required(unit_cost, "unit_cost") Validate.non_negative(unit_cost, "unit_cost") Validate.required(ordering_cost, "ordering_cost") Validate.non_negative(ordering_cost, "ordering_cost") # accept holding_rate or holding_cost, but not both # (at least one is required) Validate.one_only([holding_rate, holding_cost], ["holding_rate", "holding_cost"]) if holding_rate is not None: Validate.non_negative(holding_rate, "holding_rate") else: Validate.non_negative(holding_cost, holding_cost) Validate.one_of_allowable(holding_time_unit, RawCosts.supported_time_units, "holding_time_unit") Validate.required(shortage_cost, "shortage_cost") Validate.non_negative(shortage_cost, "shortage_cost")