Skip to content

Commit

Permalink
Update opportunity lines properly
Browse files Browse the repository at this point in the history
  • Loading branch information
huoxito committed Dec 16, 2014
1 parent 896588a commit 2ae5bae
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/SF_services/line_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def upsert!(line_item_attr = {}, opportunity_id, product_code)
end

if line_item_id = find_line_item(opportunity_id, pricebook_entry_id)
update!(line_item_attr.merge Id: line_item_id )
else
line_item_attr = line_item_attr.merge OpportunityId: opportunity_id, PricebookEntryId: pricebook_entry_id
create!(line_item_attr)
else
update!(line_item_attr.merge Id: line_item_id )
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions lib/integrations/line_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ def initialize(config, order)

def upsert!(opportunity_id)
items.each do |item|
line_item_service.upsert!(item_params(item), opportunity_id, item.fetch('product_id'))
params = item_params(item)
line_item_service.upsert!(params, opportunity_id, item.fetch('product_id'))
end
end

def item_params(item)
Integration::Builder::LineItem.new(item).build.merge 'Currency' => order['currency']
Integration::Builder::LineItem.new(item).build
end
end
end
4 changes: 2 additions & 2 deletions lib/integrations/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ def upsert!
params = order_params.merge "AccountId" => account_id
opportunity_id = order_service.upsert! params

Integration::LineItem.new(config, object[:order]).upsert! opportunity_id
LineItem.new(config, object[:order]).upsert! opportunity_id
end

private

def order_params
Integration::Builder::Order.new(object['order']).build
Builder::Order.new(object['order']).build
end
end
end

0 comments on commit 2ae5bae

Please sign in to comment.