Sha256: ee1acaee0936992f357db4b736e1f5477c6f8aa91070ce427da80c2dfdc243ac

Contents?: true

Size: 1.98 KB

Versions: 35

Compression:

Stored size: 1.98 KB

Contents

require 'test_helper'

class Kaui::InvoicePaymentTest < ActiveSupport::TestCase

  test 'can convert to money' do
    payment = Kaui::InvoicePayment.new(:auth_amount      => 12.42,
                                       :captured_amount  => 10.2,
                                       :purchased_amount => 12,
                                       :refunded_amount  => 9,
                                       :credited_amount  => 5,
                                       :currency         => 'USD')

    assert_equal 1242, payment.auth_amount_to_money.cents
    assert_equal 'USD', payment.auth_amount_to_money.currency_as_string

    assert_equal 1020, payment.captured_amount_to_money.cents
    assert_equal 'USD', payment.captured_amount_to_money.currency_as_string

    assert_equal 1200, payment.purchased_amount_to_money.cents
    assert_equal 'USD', payment.purchased_amount_to_money.currency_as_string

    assert_equal 900, payment.refunded_amount_to_money.cents
    assert_equal 'USD', payment.refunded_amount_to_money.currency_as_string

    assert_equal 500, payment.credited_amount_to_money.cents
    assert_equal 'USD', payment.credited_amount_to_money.currency_as_string

    assert_equal 2220, payment.paid_amount_to_money.cents
    assert_equal 'USD', payment.paid_amount_to_money.currency_as_string

    assert_equal 1400, payment.returned_amount_to_money.cents
    assert_equal 'USD', payment.returned_amount_to_money.currency_as_string
  end

  test 'can check for full refunds' do
    assert Kaui::InvoicePayment.new(:purchased_amount => 10.2, :refunded_amount => 10.20, :currency => 'USD').is_fully_refunded?
    assert !Kaui::InvoicePayment.new(:purchased_amount => 10.2, :refunded_amount => 9, :currency => 'USD').is_fully_refunded?

    assert Kaui::InvoicePayment.new(:captured_amount => 10.2, :refunded_amount => 10.20, :currency => 'USD').is_fully_refunded?
    assert !Kaui::InvoicePayment.new(:captured_amount => 10.2, :refunded_amount => 9, :currency => 'USD').is_fully_refunded?
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
kaui-2.0.4 test/unit/kaui/invoice_payment_test.rb
kaui-2.0.3 test/unit/kaui/invoice_payment_test.rb
kaui-2.0.2 test/unit/kaui/invoice_payment_test.rb
kaui-2.0.1 test/unit/kaui/invoice_payment_test.rb
kaui-2.0.0 test/unit/kaui/invoice_payment_test.rb
kaui-1.4.1 test/unit/kaui/invoice_payment_test.rb
kaui-1.4.0 test/unit/kaui/invoice_payment_test.rb
kaui-1.3.0 test/unit/kaui/invoice_payment_test.rb
kaui-1.2.0 test/unit/kaui/invoice_payment_test.rb
kaui-1.1.0 test/unit/kaui/invoice_payment_test.rb
kaui-1.0.0 test/unit/kaui/invoice_payment_test.rb
kaui-0.16.2 test/unit/kaui/invoice_payment_test.rb
kaui-0.16.1 test/unit/kaui/invoice_payment_test.rb
kaui-0.16.0 test/unit/kaui/invoice_payment_test.rb
kaui-0.15.5 test/unit/kaui/invoice_payment_test.rb
kaui-0.15.4 test/unit/kaui/invoice_payment_test.rb
kaui-0.15.3 test/unit/kaui/invoice_payment_test.rb
kaui-0.15.2 test/unit/kaui/invoice_payment_test.rb
kaui-0.15.1 test/unit/kaui/invoice_payment_test.rb
kaui-0.15.0 test/unit/kaui/invoice_payment_test.rb