Sha256: f73e635c9c92f446f49c9b37ae9e540b422a26f4bc2471d74a6edfddcec89581

Contents?: true

Size: 570 Bytes

Versions: 17

Compression:

Stored size: 570 Bytes

Contents

module Ecom
  module Core
    class Payroll < ApplicationRecord
      validates :month, :year, presence: true

      has_many :payments, class_name: 'Ecom::Core::Payment'
      belongs_to :site

      scope :by_site, ->(id) { where(site_id: id) }
      scope :by_month, ->(month) { where(month: month) }
      scope :by_year, ->(year) { where(year: year) }

      def create_next
        m = month + 1
        y = year
        if m > 12
          m = 1
          y += 1
        end
        Payroll.create(month: m, year: y, site_id: site_id)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ecom_core-1.3.14 app/models/ecom/core/payroll.rb
ecom_core-1.3.13 app/models/ecom/core/payroll.rb
ecom_core-1.3.12 app/models/ecom/core/payroll.rb
ecom_core-1.3.11 app/models/ecom/core/payroll.rb
ecom_core-1.3.10 app/models/ecom/core/payroll.rb
ecom_core-1.3.9 app/models/ecom/core/payroll.rb
ecom_core-1.3.8 app/models/ecom/core/payroll.rb
ecom_core-1.3.7 app/models/ecom/core/payroll.rb
ecom_core-1.3.6 app/models/ecom/core/payroll.rb
ecom_core-1.3.5 app/models/ecom/core/payroll.rb
ecom_core-1.3.4 app/models/ecom/core/payroll.rb
ecom_core-1.3.3 app/models/ecom/core/payroll.rb
ecom_core-1.3.2 app/models/ecom/core/payroll.rb
ecom_core-1.3.1 app/models/ecom/core/payroll.rb
ecom_core-1.3.0 app/models/ecom/core/payroll.rb
ecom_core-1.2.36 app/models/ecom/core/payroll.rb
ecom_core-1.2.35 app/models/ecom/core/payroll.rb