Files
openfoodnetwork/app/models/subscription_line_item.rb
Luis Ramos e52937c113 Use rubocop auto correct to add frozen string literal to all files
This is an unsafe auto corection, we will need to trust our build here
2021-06-17 23:07:26 +01:00

25 lines
646 B
Ruby

# frozen_string_literal: true
class SubscriptionLineItem < ApplicationRecord
belongs_to :subscription, inverse_of: :subscription_line_items
belongs_to :variant, -> { with_deleted }, class_name: 'Spree::Variant'
validates :subscription, presence: true
validates :variant, presence: true
validates :quantity, presence: true, numericality: { only_integer: true }
default_scope { order('id ASC') }
def total_estimate
(price_estimate || 0) * (quantity || 0)
end
# Used to calculators to estimate fees
alias_method :amount, :total_estimate
# Used to calculators to estimate fees
def price
price_estimate
end
end