summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/product_order.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/product_order.rb b/app/models/product_order.rb
index 004f8fc..5194e6d 100644
--- a/app/models/product_order.rb
+++ b/app/models/product_order.rb
@@ -5,4 +5,12 @@
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