Sha256: 69fe51aa617349541e0a6e268a521d6b93a0fcd9d1cfdef8d3564b9feffe3291

Contents?: true

Size: 948 Bytes

Versions: 4

Compression:

Stored size: 948 Bytes

Contents

module Comee
  module Core
    class SupplierInvoice < ApplicationRecord
      belongs_to :purchase_order
      has_many :supplier_invoice_items
      has_many :supplier_payments

      enum :status, {draft: 0, approved: 1}
      enum :payment_status, {not_paid: 0, partially_paid: 1, fully_paid: 2, overpaid: 3}

      validates :invoice_no, presence: true, uniqueness: true
      validates :status, :payment_status, presence: true
      validates :total_price, numericality: {greater_than_or_equal_to: 0, allow_nil: true}
      validates :amount_paid, numericality: {greater_than_or_equal_to: 0, allow_nil: true}

      def self.ransackable_attributes(_auth_object = nil)
        %w[
          id
          purchase_order_id
          invoice_no
          date_issued
          status
          payment_status
        ]
      end

      def self.ransackable_associations(_auth_object = nil)
        ["purchase_order"]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
comee_core-0.2.50 app/models/comee/core/supplier_invoice.rb
comee_core-0.2.49 app/models/comee/core/supplier_invoice.rb
comee_core-0.2.48 app/models/comee/core/supplier_invoice.rb
comee_core-0.2.47 app/models/comee/core/supplier_invoice.rb