1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-13 23:48:55 +01:00
fab-manager/app/models/offer_day.rb

19 lines
543 B
Ruby
Raw Normal View History

# frozen_string_literal: true
# OfferDay provides a way for admins to extend the subscription of a member for free.
2020-03-25 10:16:47 +01:00
class OfferDay < ApplicationRecord
2016-03-23 18:39:41 +01:00
include NotifyWith::NotificationAttachedObject
has_many :invoice_items, as: :object, dependent: :destroy
2016-03-23 18:39:41 +01:00
belongs_to :subscription
# buying invoice
def original_invoice
invoice_items.select(:invoice_id)
.group(:invoice_id)
.map(&:invoice_id)
.map { |id| Invoice.find_by(id: id, type: nil) }
.first
end
2016-03-23 18:39:41 +01:00
end