Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/api/v1/orders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abulsayyad123 does this get run for Stockit requests or also for normal goodcity requests?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only for Stockit requests.

@order.stockit_activity = stockit_activity
@order.stockit_contact = stockit_contact
@order.stockit_organisation = stockit_organisation
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to change this code to accept stockit shipments as well as local orders... I wonder if we wait until after we have shutdown stockit then we don't need to do anything

Expand Down
4 changes: 4 additions & 0 deletions app/models/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down