Sha256: ac9f189454e15a0a837c9f0a496e962f0c1db52a26e968c7ce7b926c8e106a43

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 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.remote[:body]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
iron_bank-3.0.3 lib/iron_bank/resources/invoice.rb
iron_bank-3.0.2 lib/iron_bank/resources/invoice.rb