app/models/concerns/order_state_config.rb
# Returns true if Order is finished
Returns true if Order is finished
Returns true if Order is finished
def finished?
      finished = nil
      active_item_orders = item_orders.where(active: true)
      if state_reached?(:fulfilled)
        if active_item_orders.length == 0
          finished = true
        else
          active_item_orders.each do |io|
            i = io.item
            if !i.obsolete
              last_transition = i.state_transitions.where(order_id: id).first
              if last_transition && (last_transition.to_state == i.final_state.to_s)
                finished = true
              else
                finished = false
                break
              end
            end
          end
        end
      end
      finished
    end
def finished? finished = nil active_item_orders = item_orders . where ( active : true ) if state_reached? ( :fulfilled ) if active_item_orders . length == 0 finished = true else active_item_orders . each do | io | i = io . item if ! i . obsolete last_transition = i . state_transitions . where ( order_id : id ) . first if last_transition && ( last_transition . to_state == i . final_state . to_s ) finished = true else finished = false break end end end end end finished end
Returns true if Order is finished
Returns true if Order is finished