Sha256: a9f1e72313bac3ee7d5a35e4a65e95f7ce2ffd550da8ca9970dbbe6b7aa42434

Contents?: true

Size: 881 Bytes

Versions: 13

Compression:

Stored size: 881 Bytes

Contents

module Billing
  class Origin < ActiveRecord::Base
    has_many :bills, inverse_of: :origin
    has_many :charges, inverse_of: :origin
    has_many :payments, through: :bills
    if defined? Extface
      belongs_to :fiscal_device, ->(o) { where( extfaceable_id: o.master_id ) }, class_name: 'Extface::Device'
      belongs_to :transfer_device, ->(o) { where( extfaceable_id: o.master_id ) }, class_name: 'Extface::Device'
      belongs_to :print_device, ->(o) { where( extfaceable_id: o.master_id ) }, class_name: 'Extface::Device'
    end
    belongs_to :receipt_config, inverse_of: :origins

    validates_presence_of :name
    validates :payment_model, inclusion: { in: Payment::PAYMENT_MODELS }
    
    def external_payment?
      payment_model != Payment::PAYMENT_WITH_TYPE
    end
    
    def room_transfer?
      payment_model == Payment::ROOM_TRANSFER
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
billing-0.2.2 app/models/billing/origin.rb
billing-0.2.1 app/models/billing/origin.rb
billing-0.2.0 app/models/billing/origin.rb
billing-0.1.9 app/models/billing/origin.rb
billing-0.1.8 app/models/billing/origin.rb
billing-0.1.7 app/models/billing/origin.rb
billing-0.1.6 app/models/billing/origin.rb
billing-0.1.5 app/models/billing/origin.rb
billing-0.1.4 app/models/billing/origin.rb
billing-0.1.3 app/models/billing/origin.rb
billing-0.1.2a app/models/billing/origin.rb
billing-0.1.2 app/models/billing/origin.rb
billing-0.1.1 app/models/billing/origin.rb