mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Remove currency from OrderContents
The currency argument here is not actually used anywhere. The related conditional logic is also not covered in any tests.
This commit is contained in:
@@ -16,7 +16,7 @@ module Api
|
||||
quantity = params[:quantity].to_i
|
||||
@shipment = get_or_create_shipment(params[:stock_location_id])
|
||||
|
||||
@order.contents.add(variant, quantity, nil, @shipment)
|
||||
@order.contents.add(variant, quantity, @shipment)
|
||||
|
||||
@shipment.refresh_rates
|
||||
@shipment.save!
|
||||
@@ -68,7 +68,7 @@ module Api
|
||||
variant = scoped_variant(params[:variant_id])
|
||||
quantity = params[:quantity].to_i
|
||||
|
||||
@order.contents.add(variant, quantity, nil, @shipment)
|
||||
@order.contents.add(variant, quantity, @shipment)
|
||||
@order.recreate_all_fees!
|
||||
|
||||
render json: @shipment, serializer: Api::ShipmentSerializer, status: :ok
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
module Spree
|
||||
class OrderContents
|
||||
attr_accessor :order, :currency
|
||||
attr_accessor :order
|
||||
|
||||
def initialize(order)
|
||||
@order = order
|
||||
@@ -10,9 +10,9 @@ module Spree
|
||||
|
||||
# Get current line item for variant if exists
|
||||
# Add variant qty to line_item
|
||||
def add(variant, quantity = 1, currency = nil, shipment = nil)
|
||||
def add(variant, quantity = 1, shipment = nil)
|
||||
line_item = order.find_line_item_by_variant(variant)
|
||||
add_to_line_item(line_item, variant, quantity, currency, shipment)
|
||||
add_to_line_item(line_item, variant, quantity, shipment)
|
||||
end
|
||||
|
||||
# Get current line item for variant
|
||||
@@ -29,20 +29,14 @@ module Spree
|
||||
|
||||
private
|
||||
|
||||
def add_to_line_item(line_item, variant, quantity, currency = nil, shipment = nil)
|
||||
def add_to_line_item(line_item, variant, quantity, shipment = nil)
|
||||
if line_item
|
||||
line_item.target_shipment = shipment
|
||||
line_item.quantity += quantity.to_i
|
||||
line_item.currency = currency unless currency.nil?
|
||||
else
|
||||
line_item = order.line_items.new(quantity: quantity, variant: variant)
|
||||
line_item.target_shipment = shipment
|
||||
if currency
|
||||
line_item.currency = currency unless currency.nil?
|
||||
line_item.price = variant.price_in(currency).amount
|
||||
else
|
||||
line_item.price = variant.price
|
||||
end
|
||||
line_item.price = variant.price
|
||||
end
|
||||
|
||||
line_item.save
|
||||
|
||||
Reference in New Issue
Block a user