Skip to content

Commit

Permalink
IN-392 Moves return itens to builder
Browse files Browse the repository at this point in the history
  • Loading branch information
reinaldob committed Dec 16, 2014
1 parent b1ccb3f commit bd82043
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
11 changes: 8 additions & 3 deletions lib/integrations/builders/return.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ def build
end

def build_body(object)
returned_items = object["inventory_units"].map{|item| item["variant"]["sku"]}
returned_counts = returned_items.inject(Hash.new(0)) { |total, item| total[item] += 1; total }
extra = "Returned items: "
returned_counts.each { |item_name, count| extra += "#{item_name}: (#{count}) " }

<<-body
Status: #{object['status']}
Amount: #{object['refund_amount']}
Extra: #{object['extra']}
Status: #{object['state']}
Amount: #{object['amount']}
Extra: #{extra}
body
end
end
Expand Down
5 changes: 0 additions & 5 deletions lib/integrations/return.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ def handle_all!
end

def handle _return
returned_items = _return["inventory_units"].map{|item| item["variant"]["sku"]}
returned_counts = returned_items.inject(Hash.new(0)) { |total, item| total[item] += 1; total }
result = "Returned items: "
returned_counts.each { |item_name, count| result += "#{item_name}: (#{count}) " }
#.merge({"extra" => result})
return_service.upsert!(return_params(_return), _return['order_id'])
end

Expand Down

0 comments on commit bd82043

Please sign in to comment.