Sha256: bb735406cf33fc52b646415374c992bfcf9af69da2d2d9e85c9f6d4777263e97

Contents?: true

Size: 985 Bytes

Versions: 1

Compression:

Stored size: 985 Bytes

Contents

module Comee
  module Core
    class Invoice < ApplicationRecord
      belongs_to :sales_order
      belongs_to :pod
      has_many :invoice_items

      has_noticed_notifications model_name: "Comee::Core::Notification"

      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 :date_issued, :payment_term, :status, :payment_status, presence: true
      validates :total_price, numericality: {greater_than_or_equal_to: 0, allow_nil: true}

      def self.ransackable_attributes(_auth_object = nil)
        %w[
          id
          sales_order_id
          invoice_no
          date_issued
          ship_name
          delivery_date
          voyage_no
          status
          payment_status
        ]
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
comee_core-0.2.3 app/models/comee/core/invoice.rb