diff --git a/app/models/spree/order_decorator.rb b/app/models/spree/order_decorator.rb index 4910eb90b1..49e899e28f 100644 --- a/app/models/spree/order_decorator.rb +++ b/app/models/spree/order_decorator.rb @@ -379,7 +379,7 @@ Spree::Order.class_eval do end # Update attributes of a record in the database without callbacks, validations etc. - # This was originally a ext to ActiveRecord in Spree but only used for Spree::Order + # This was originally an extension to ActiveRecord in Spree but only used for Spree::Order def update_attributes_without_callbacks(attributes) assign_attributes(attributes) Spree::Order.where(id: id).update_all(attributes) diff --git a/engines/order_management/app/services/order_management/order/updater.rb b/engines/order_management/app/services/order_management/order/updater.rb index 30b4e27458..d3c496d4e2 100644 --- a/engines/order_management/app/services/order_management/order/updater.rb +++ b/engines/order_management/app/services/order_management/order/updater.rb @@ -52,10 +52,10 @@ module OrderManagement # Updates the following Order total values: # - # - payment_total - the total value of all finalized Payments (excluding non-finalized Payments) - # - item_total - the total value of all LineItems - # - adjustment_total - the total value of all adjustments - # - total - the "order total". This is equivalent to item_total plus adjustment_total + # - payment_total - total value of all finalized Payments (excludes non-finalized Payments) + # - item_total - total value of all LineItems + # - adjustment_total - total value of all adjustments + # - total - order total, it's the equivalent to item_total plus adjustment_total def update_totals order.payment_total = payments.completed.map(&:amount).sum order.item_total = line_items.map(&:amount).sum @@ -160,9 +160,9 @@ module OrderManagement end def infer_state(balance) - if balance > 0 + if balance.positive? 'balance_due' - elsif balance < 0 + elsif balance.negative? 'credit_owed' elsif balance.zero? 'paid' diff --git a/engines/order_management/spec/services/order_management/order/updater_spec.rb b/engines/order_management/spec/services/order_management/order/updater_spec.rb index 51e4d59d85..009176eed2 100644 --- a/engines/order_management/spec/services/order_management/order/updater_spec.rb +++ b/engines/order_management/spec/services/order_management/order/updater_spec.rb @@ -58,7 +58,8 @@ module OrderManagement end it "is partial" do - allow(order).to receive_message_chain(:shipments, :states).and_return(["pending", "ready"]) + allow(order). + to receive_message_chain(:shipments, :states).and_return(["pending", "ready"]) updater.update_shipment_state expect(order.shipment_state).to eq 'partial' end @@ -260,7 +261,9 @@ module OrderManagement context '#before_save_hook' do let(:distributor) { build(:distributor_enterprise) } - let(:shipment) { create(:shipment_with, :shipping_method, shipping_method: shipping_method) } + let(:shipment) { + create(:shipment_with, :shipping_method, shipping_method: shipping_method) + } before do order.distributor = distributor