Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Importer::Order to accept array of line items and stock_location_id #3655

Merged
merged 2 commits into from
Jun 26, 2020

Conversation

ccarruitero
Copy link
Contributor

Description
This PR is for improve Importer::Order to allow stock_location_id when create shipments and allow use an array for line_item_attributes.

Importer::Order is used internally for solidus_api to create orders, and like is documented should allow stock_location_id in shipments_attributes and an array for line_item_attributes.

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)
  • I have attached screenshots to this PR for visual changes (if needed)

shipment.stock_location = Spree::StockLocation.find_by(admin_name: target[:stock_location]) || Spree::StockLocation.find_by!(name: target[:stock_location])
shipment.stock_location = Spree::StockLocation.find_by(id: target[:stock_location_id]) ||
Spree::StockLocation.find_by(admin_name: target[:stock_location]) ||
Spree::StockLocation.find_by!(name: target[:stock_location])

Choose a reason for hiding this comment

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

Layout/MultilineOperationIndentation: Align the operands of an expression in an assignment spanning multiple lines.

@@ -56,7 +56,9 @@ def self.create_shipments_from_params(shipments_hash, order)
shipments_hash.each do |target|
shipment = Shipment.new
shipment.tracking = target[:tracking]
shipment.stock_location = Spree::StockLocation.find_by(admin_name: target[:stock_location]) || Spree::StockLocation.find_by!(name: target[:stock_location])
shipment.stock_location = Spree::StockLocation.find_by(id: target[:stock_location_id]) ||
Spree::StockLocation.find_by(admin_name: target[:stock_location]) ||

Choose a reason for hiding this comment

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

Layout/MultilineOperationIndentation: Align the operands of an expression in an assignment spanning multiple lines.

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

Thanks @ccarruitero, it works for me.

I'd also deprecate the line_items_hash since it's no more always a hash, maybe line_itemswith some good YARD documentation of this method args is enough to make it more clear. But we can do this in another PR if we have time.

@kennyadsl kennyadsl changed the title improve Importer::Order Allow Importer::Order to accept array of line items and stock_location_id Jun 22, 2020
@kennyadsl kennyadsl added Needs Core Team Review changelog:solidus_core Changes to the solidus_core gem labels Jun 22, 2020
@aldesantis aldesantis merged commit b555216 into solidusio:master Jun 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:solidus_core Changes to the solidus_core gem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants