Skip to content

Commit

Permalink
Edited method since it only has to take into consideration variants l…
Browse files Browse the repository at this point in the history
…inked to a sale and not left alone parcels
  • Loading branch information
Zank94 committed Aug 17, 2017
1 parent 2682e7b commit bc719de
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions app/models/product_nature_variant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,7 @@ 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
sales_not_delivered = Sale.where(state: %w(order invoice)).includes(:parcels).where(parcels: { state: %w(draft ordered in_preparation prepared) })
sale_items_not_delivered = SaleItem.where(variant_id: id, sale_id: sales_not_delivered.pluck(:id)).sum(:quantity)
parcel_items_not_delivered = ParcelItem.where(variant_id: id, sale_item_id: nil).includes(:parcel).where(parcels: { state: %w(draft ordered in_preparation prepared) }).sum(:population)
(sale_items_not_delivered + parcel_items_not_delivered).to_f
SaleItem.where(variant_id: id, sale_id: sales_not_delivered.pluck(:id)).sum(:quantity).to_f
end

def picture_path(style = :original)
Expand Down

0 comments on commit bc719de

Please sign in to comment.