Sha256: 3862813e91c65efb59dcc55e182c1b05a27911d246f4d41347e1db9cf61ce4e1

Contents?: true

Size: 686 Bytes

Versions: 58

Compression:

Stored size: 686 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Budgets
    # The data store for a LineItem in the Budget resource. It describes an
    # association between an order and a project.
    class LineItem < Budgets::ApplicationRecord
      belongs_to :order, class_name: "Decidim::Budgets::Order", foreign_key: "decidim_order_id"
      belongs_to :project, class_name: "Decidim::Budgets::Project", foreign_key: "decidim_project_id"

      validates :order, uniqueness: { scope: :project }
      validate :same_budget

      def same_budget
        return unless order && project

        errors.add(:order, :invalid) unless order.budget == project.budget
      end
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
decidim-budgets-0.29.1 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.28.4 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.27.9 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.29.0 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.28.3 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.27.8 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.29.0.rc4 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.29.0.rc3 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.29.0.rc2 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.29.0.rc1 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.28.2 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.27.7 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.28.1 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.27.6 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.26.10 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.26.9 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.28.0 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.27.5 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.28.0.rc5 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.28.0.rc4 app/models/decidim/budgets/line_item.rb