diff --git a/app/controllers/api/v1/orders_controller.rb b/app/controllers/api/v1/orders_controller.rb index b66689f4a..320c4b7e6 100644 --- a/app/controllers/api/v1/orders_controller.rb +++ b/app/controllers/api/v1/orders_controller.rb @@ -130,6 +130,7 @@ def order_record if order_params[:stockit_id] @order = Order.accessible_by(current_ability).where(stockit_id: order_params[:stockit_id]).first_or_initialize @order.assign_attributes(order_params) + @order.assign_state(params[:status]) @order.stockit_activity = stockit_activity @order.stockit_contact = stockit_contact @order.stockit_organisation = stockit_organisation diff --git a/app/models/order.rb b/app/models/order.rb index a6f32d924..36a784719 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -111,6 +111,10 @@ class Order < ActiveRecord::Base scope :goodcity_orders, -> { where(detail_type: "GoodCity") } scope :shipments, -> { where(detail_type: "Shipment") } + def assign_state(status) + self.state = SHIPMENT_STATUS_MAP[status] || "processing" + end + def can_dispatch_item? ORDER_UNPROCESSED_STATES.include?(state) end