예제 #1
0
    def check_create_conditions(cls,
                                state,
                                dt_execution,
                                inputs=None,
                                quantity=None,
                                **kwargs):

        super(WmsSplitterOperation,
              cls).check_create_conditions(state,
                                           dt_execution,
                                           inputs=inputs,
                                           quantity=quantity,
                                           **kwargs)

        phobj = inputs[0].obj
        if quantity is None:
            raise OperationMissingQuantityError(
                cls, "The 'quantity keyword argument must be passed to "
                "the create() method")
        if quantity > phobj.quantity:
            raise OperationQuantityError(
                cls,
                "Can't split a greater quantity ({op_quantity}) than held in "
                "{input} (which have quantity={input.obj.quantity})",
                op_quantity=quantity,
                input=inputs[0])
예제 #2
0
 def check_execute_conditions(self):
     """Call the base class's version and check that quantity is suitable.
     """
     super(Split, self).check_execute_conditions()
     phobj = self.input.obj
     if self.quantity > phobj.quantity:
         raise OperationQuantityError(
             self,
             "Can't execute {op}, whose quantity {op.quantity} is greater "
             "than on its input {phobj}, "
             "although it's been successfully planned.",
             op=self, phobj=self.input)
예제 #3
0
    def check_execute_conditions(self):
        """Check that the quantity (after possible Split) is as on the input.

        If a Split has been inserted, then this calls the base class
        for the input of the Split, instead of ``self``, because the input of
        ``self`` is in that case the outcome of the Split, and it's normal
        that it's in state ``future``: the Split will be executed during
        ``self.execute()``, which comes once the present method has agreed.
        """
        if self.quantity != self.input.obj.quantity:
            raise OperationQuantityError(
                self,
                "Can't execute planned for a different quantity {op_quantity} "
                "than held in its input {input} "
                "(which have quantity={input.obj.quantity}). "
                "If it's less, a Split should have occured first ",
                input=input)
        if self.partial:
            self.input.outcome_of.check_execute_conditions()
        else:
            super(WmsSplitterOperation, self).check_execute_conditions()