summaryrefslogtreecommitdiff
path: root/app/models/product_order.rb
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-04-16 11:29:54 -0600
committerHombreLaser <sebastian-440@live.com>2023-04-16 11:29:54 -0600
commitf158d350f10ae6850c7ee168f0345197c3265d5c (patch)
tree3f1959ce3d3aff9b753651dab1e02422b5275bd4 /app/models/product_order.rb
parent3c76bc939f44614850898bcf1e5086f997d94dcf (diff)
Añade método total a ProductOrder
Diffstat (limited to 'app/models/product_order.rb')
-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