Sha256: 301d3dcf84ab2fe2edd2af98fbe415ad56f70921406888e300d5f49276371438

Contents?: true

Size: 585 Bytes

Versions: 12

Compression:

Stored size: 585 Bytes

Contents

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

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

      scope :by_project, ->(id) { where(project_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, project_id: project_id)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ecom_core-1.2.34 app/models/ecom/core/payroll.rb
ecom_core-1.2.33 app/models/ecom/core/payroll.rb
ecom_core-1.2.32 app/models/ecom/core/payroll.rb
ecom_core-1.2.31 app/models/ecom/core/payroll.rb
ecom_core-1.2.30 app/models/ecom/core/payroll.rb
ecom_core-1.2.29 app/models/ecom/core/payroll.rb
ecom_core-1.2.28 app/models/ecom/core/payroll.rb
ecom_core-1.2.27 app/models/ecom/core/payroll.rb
ecom_core-1.2.26 app/models/ecom/core/payroll.rb
ecom_core-1.2.25 app/models/ecom/core/payroll.rb
ecom_core-1.2.24 app/models/ecom/core/payroll.rb
ecom_core-1.2.23 app/models/ecom/core/payroll.rb