Sha256: 5c2e5cebfebb3bb6b594df0d45e23e1aa5af2e3db2e015c07b685c6de2e5b622

Contents?: true

Size: 745 Bytes

Versions: 21

Compression:

Stored size: 745 Bytes

Contents

module Zuora
  class InvoiceItem < ZObject

    def invoice
      @invoice ||= Invoice.find(invoiceId)
    end

    def rate_plan_charge
      @rate_plan_charge ||= RatePlanCharge.find(ratePlanChargeId)
    end

    def adjustments
      @adjustments ||= InvoiceItemAdjustment.where(:sourceType => 'InvoiceDetail', :sourceId => id)
    end

    def adjusted_charge_amount
      @adjusted_charge_amount ||=
        adjustments.inject(chargeAmount) do |amount, adjustment|
          # Adjustment types are either Credit or Charge
          # Credits will have a reducing (subtracting) effect on the invoice item charge.
          adjustment.type == "Credit" ? amount - adjustment.amount : amount + adjustment.amount
        end
    end

  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
active_zuora-1.5.2 lib/active_zuora/invoice_item.rb
active_zuora-1.5.1 lib/active_zuora/invoice_item.rb
active_zuora-1.5.0 lib/active_zuora/invoice_item.rb
active_zuora-1.4.21 lib/active_zuora/invoice_item.rb
active_zuora-1.4.20 lib/active_zuora/invoice_item.rb
active_zuora-1.4.19 lib/active_zuora/invoice_item.rb
active_zuora-1.4.18 lib/active_zuora/invoice_item.rb
active_zuora-1.4.17 lib/active_zuora/invoice_item.rb
active_zuora-1.4.16 lib/active_zuora/invoice_item.rb
active_zuora-1.4.15 lib/active_zuora/invoice_item.rb
active_zuora-1.4.13 lib/active_zuora/invoice_item.rb
active_zuora-1.4.12 lib/active_zuora/invoice_item.rb
active_zuora-1.4.11 lib/active_zuora/invoice_item.rb
active_zuora-1.4.8 lib/active_zuora/invoice_item.rb
active_zuora-1.4.7 lib/active_zuora/invoice_item.rb
active_zuora-1.4.6 lib/active_zuora/invoice_item.rb
active_zuora-1.4.5 lib/active_zuora/invoice_item.rb
active_zuora-1.4.4 lib/active_zuora/invoice_item.rb
active_zuora-1.4.2 lib/active_zuora/invoice_item.rb
active_zuora-1.4.1 lib/active_zuora/invoice_item.rb