Skip to content

Commit

Permalink
Enhances code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Brice TEXIER committed Aug 28, 2017
1 parent 395a576 commit c9f5d2d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/models/product_nature_variant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ def current_stock

# Return current quantity of all products link to the variant currently ordered or invoiced but not delivered
def current_outgoing_stock_ordered_not_delivered
quantity_ordered = self.sale_items.includes(:sale).where(sales: { state: %w[order invoice] }).sum(:quantity)
quantity_delivered = self.parcel_items.includes(:parcel).where(parcels: { state: 'given', nature: 'outgoing' }).sum(:population)
quantity_ordered = sale_items.includes(:sale).where(sales: { state: %w[order invoice] }).sum(:quantity)
quantity_delivered = parcel_items.includes(:parcel).where(parcels: { state: 'given', nature: 'outgoing' }).sum(:population)
(quantity_ordered - quantity_delivered).to_f
end

Expand Down
1 change: 0 additions & 1 deletion test/models/product_nature_variant_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class ProductNatureVariantTest < ActiveSupport::TestCase
variant = create(:product_nature_variant)
sale = create(:sale)
sale.update(state: 'order')
sale_item = create(:sale_item, sale: sale, variant: variant, quantity: 50.to_d)
parcel = create(:parcel, sale: sale)
parcel.update(state: 'prepared')
assert_equal 50.0, variant.current_outgoing_stock_ordered_not_delivered
Expand Down

0 comments on commit c9f5d2d

Please sign in to comment.