Sha256: 82748c85a9152d5cbfdd71bdd40741f49fb56522cd4631ae29c6471cee4a0368

Contents?: true

Size: 561 Bytes

Versions: 1

Compression:

Stored size: 561 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)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ecom_core-1.2.22 app/models/ecom/core/payroll.rb