diff options
author | HombreLaser <sebastian-440@live.com> | 2023-04-16 11:29:54 -0600 |
---|---|---|
committer | HombreLaser <sebastian-440@live.com> | 2023-04-16 11:29:54 -0600 |
commit | f158d350f10ae6850c7ee168f0345197c3265d5c (patch) | |
tree | 3f1959ce3d3aff9b753651dab1e02422b5275bd4 /app/models | |
parent | 3c76bc939f44614850898bcf1e5086f997d94dcf (diff) |
Añade método total a ProductOrder
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/product_order.rb | 8 |
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 |