Sha256: 8fbb3fa552bf83ae0d3373b55f4b2ef909defb3d60372e6a8fe4d2c0b161b18f

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module IronBank
  module Resources
    # A Zuora invoice is generated through a bill run, belongs to an account and
    # holds many invoice items.
    #
    class Invoice < Resource
      # These fields are declared as `<selectable>true</selectable>` but Zuora
      # returns a QueryError when trying to query an invoice with them. Also,
      # the `Body` field can only be retrieved for a single invoice at a time.
      def self.exclude_fields
        %w[
          AutoPay
          BillRunId
          BillToContactSnapshotId
          Body
          RegenerateInvoicePDF
          SoldToContactSnapshotId
        ]
      end
      with_schema

      with_one :account

      with_many :invoice_adjustments, alias: :adjustments
      with_many :invoice_items, alias: :items
      with_many :invoice_payments

      # We can only retrieve one invoice body at a time, hence Body is excluded
      # from the query fields, but is populated using the `find` class method
      def body
        remote[:body] || reload[:body]
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
iron_bank-3.0.1 lib/iron_bank/resources/invoice.rb
iron_bank-3.0.0 lib/iron_bank/resources/invoice.rb
iron_bank-2.2.0 lib/iron_bank/resources/invoice.rb
iron_bank-2.1.0 lib/iron_bank/resources/invoice.rb
iron_bank-2.0.2 lib/iron_bank/resources/invoice.rb
iron_bank-2.0.1 lib/iron_bank/resources/invoice.rb