summaryrefslogtreecommitdiff
path: root/app/models/product_order.rb
blob: 5194e6d25fbfa7e584fea504c2bed65393f1ef95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# frozen_string_literal: true

# ProductOrder
# quantity: integer
class ProductOrder < ApplicationRecord
  belongs_to :order
  belongs_to :product

  def total
    if quantity < 5
      product.unitary_price * quantity
    else
      product.bulk_price * quantity
    end
  end
end