lib/catissue/domain/specimen.rb
def decrement_derived_quantity(child)
      return unless specimen_type == child.specimen_type and child.initial_quantity
      if available_quantity.nil? then
        raise Jinx::ValidationError.new("Derived specimen has an initial quantity #{child.initial_quantity} but the parent is missing an available quantity")
      elsif (available_quantity - child.initial_quantity).abs < 0.00000001 then
        # rounding error
        self.available_quantity = 0.0
      elsif child.initial_quantity <= available_quantity then
        self.available_quantity -= child.initial_quantity
      else
        raise Jinx::ValidationError.new("Derived specimen initial quantity #{child.initial_quantity} exceeds parent available quantity #{available_quantity}")
      end
    end
def decrement_derived_quantity(child)
      return unless specimen_type == child.specimen_type and child.initial_quantity
      if available_quantity.nil? then
        raise Jinx::ValidationError.new("Derived specimen has an initial quantity #{child.initial_quantity} but the parent is missing an available quantity")
      elsif (available_quantity - child.initial_quantity).abs < 0.00000001 then
        # rounding error
        self.available_quantity = 0.0
      elsif child.initial_quantity <= available_quantity then
        self.available_quantity -= child.initial_quantity
      else
        raise Jinx::ValidationError.new("Derived specimen initial quantity #{child.initial_quantity} exceeds parent available quantity #{available_quantity}")
      end
    end
def decrement_derived_quantity ( child ) return unless specimen_type == child . specimen_type and child . initial_quantity if available_quantity . nil? then raise Jinx :: ValidationError . new ( "Derived specimen has an initial quantity #{child.initial_quantity} but the parent is missing an available quantity" ) elsif ( available_quantity - child . initial_quantity ) . abs < 0.00000001 then # rounding error self . available_quantity = 0.0 elsif child . initial_quantity <= available_quantity then self . available_quantity -= child . initial_quantity else raise Jinx :: ValidationError . new ( "Derived specimen initial quantity #{child.initial_quantity} exceeds parent available quantity #{available_quantity}" ) end end
Decrements this parent's available quantity by the given child's initial quantity, if the specimen types are the same and there
 are the relevant quantities.
Decrements this parent s available quantity by the given child s initial quantity if the specimen types are the same and there are the relevant quantities .