Class: C2eCore::Drops::OrderPriceDrop
- Includes:
- Helpers::OrderConversions
- Defined in:
- /build/app/mailers/c2e_core/drops/order_price_drop.rb
Instance Method Summary collapse
-
#collect_from_customer ⇒ Float
-
The amount that should be collected from customer.
-
-
#discounts ⇒ Array[OrderDiscountDrop]
-
Array of all order discounts.
-
-
#extra_charge ⇒ Float
-
Price for extra charge (only used by DameJidlo now) converted into order’s currency.
-
-
#extra_fees ⇒ Array[OrderExternalFeeDrop]
-
Array of all extra fees.
-
-
#initialize(order) ⇒ OrderPriceDrop
constructor
A new instance of OrderPriceDrop.
-
#rounding ⇒ Float
-
Rounding of total_raw to cash rounding unit.
-
-
#tip ⇒ Float
-
Value of tip given by customer converted into order’s currency.
-
-
#tip_percentage ⇒ Integer
-
Percentage value of tip given by customer.
-
-
#total ⇒ Float
-
Total price of order converted into order’s currency.
-
-
#total_discount ⇒ Float
-
Sum of all discounts converted into order’s currency.
-
-
#total_raw ⇒ Float
-
Total price of order converted into order’s currency.
-
-
#total_vouchers ⇒ Float
-
Sum of all vouchers converted into order’s currency.
-
-
#transportation ⇒ Float
-
Price for delivery converted into order’s currency.
-
-
#vats ⇒ Array[OrderVatDrop]
-
Array of all order discounts.
-
-
#vouchers ⇒ Array[OrderDiscountDrop]
-
Array of all order vouchers.
-
Methods included from Helpers::OrderConversions
#converted_price, #format_price
Constructor Details
#initialize(order) ⇒ OrderPriceDrop
Returns a new instance of OrderPriceDrop.
8 9 10 11 |
# File '/build/app/mailers/c2e_core/drops/order_price_drop.rb', line 8 def initialize(order) super() @order = order end |
Instance Method Details
#collect_from_customer ⇒ Float
Returns - The amount that should be collected from customer.
82 83 84 85 |
# File '/build/app/mailers/c2e_core/drops/order_price_drop.rb', line 82 def collect_from_customer converted_amount = converted_price @order.price.collect_from_customer converted_amount.zero? ? converted_amount.abs : converted_amount end |
#discounts ⇒ Array[OrderDiscountDrop]
Returns - Array of all order discounts.
56 57 58 59 60 |
# File '/build/app/mailers/c2e_core/drops/order_price_drop.rb', line 56 def discounts stored_value __method__ do @order.apply_rules.discount.map { |discount_hash| OrderDiscountDrop.new discount_hash, @order } end end |
#extra_charge ⇒ Float
Returns - Price for extra charge (only used by DameJidlo now) converted into order’s currency. E.g.: 28.
36 37 38 |
# File '/build/app/mailers/c2e_core/drops/order_price_drop.rb', line 36 def extra_charge converted_price @order.extra_charge end |
#extra_fees ⇒ Array[OrderExternalFeeDrop]
Returns - Array of all extra fees.
88 89 90 91 92 |
# File '/build/app/mailers/c2e_core/drops/order_price_drop.rb', line 88 def extra_fees stored_value __method__ do @order.price.external_fees.map { |name, value| OrderExternalFeeDrop.new name, value, @order } end end |
#rounding ⇒ Float
Returns - Rounding of total_raw to cash rounding unit. E.g.: SK(EUR) -> 0.05, CZ(CZK) -> 1.00.
26 27 28 |
# File '/build/app/mailers/c2e_core/drops/order_price_drop.rb', line 26 def rounding converted_price(@order.price.rounding) end |
#tip ⇒ Float
Returns - Value of tip given by customer converted into order’s currency. E.g.: 34.8.
41 42 43 |
# File '/build/app/mailers/c2e_core/drops/order_price_drop.rb', line 41 def tip converted_price @order.price.tip end |
#tip_percentage ⇒ Integer
Returns - Percentage value of tip given by customer. E.g.: 25.
46 47 48 |
# File '/build/app/mailers/c2e_core/drops/order_price_drop.rb', line 46 def tip_percentage @order.price.tip_percentage end |
#total ⇒ Float
Returns - Total price of order converted into order’s currency. E.g.: 378.
21 22 23 |
# File '/build/app/mailers/c2e_core/drops/order_price_drop.rb', line 21 def total total_raw + rounding end |
#total_discount ⇒ Float
Returns - Sum of all discounts converted into order’s currency. E.g.: 78.
51 52 53 |
# File '/build/app/mailers/c2e_core/drops/order_price_drop.rb', line 51 def total_discount converted_price @order.price.total_discount end |
#total_raw ⇒ Float
Returns - Total price of order converted into order’s currency. E.g.: 378.
14 15 16 17 18 |
# File '/build/app/mailers/c2e_core/drops/order_price_drop.rb', line 14 def total_raw stored_value __method__ do converted_price(@order.price.total) end end |
#total_vouchers ⇒ Float
Returns - Sum of all vouchers converted into order’s currency. E.g.: 78.
63 64 65 |
# File '/build/app/mailers/c2e_core/drops/order_price_drop.rb', line 63 def total_vouchers converted_price @order.price.total_vouchers end |
#transportation ⇒ Float
Returns - Price for delivery converted into order’s currency. E.g.: 50.
31 32 33 |
# File '/build/app/mailers/c2e_core/drops/order_price_drop.rb', line 31 def transportation converted_price @order.price.transportation_fee end |
#vats ⇒ Array[OrderVatDrop]
Returns - Array of all order discounts.
75 76 77 78 79 |
# File '/build/app/mailers/c2e_core/drops/order_price_drop.rb', line 75 def vats stored_value __method__ do @order.vats.map { |vat_record| OrderVatDrop.new vat_record, @order }.sort_by(&:percentage) end end |
#vouchers ⇒ Array[OrderDiscountDrop]
Returns - Array of all order vouchers.
68 69 70 71 72 |
# File '/build/app/mailers/c2e_core/drops/order_price_drop.rb', line 68 def vouchers stored_value __method__ do @order.apply_rules.vouchers.map { |discount_hash| OrderDiscountDrop.new discount_hash, @order } end end |