Sha256: 786bbf98711e4de66b34fbaab3f6c26c5d5cbb9fe14e638ec33e5d347e90ad00

Contents?: true

Size: 1.39 KB

Versions: 4

Compression:

Stored size: 1.39 KB

Contents

require "test_helper"
require "acceptance_test"

class AboutCreatingPrepayment < Test::Unit::TestCase
  include AcceptanceTest

  let :client do
    Xeroizer::PrivateApplication.new(@consumer_key, @consumer_secret, @key_file)
  end

  def setup
    super
    all_accounts = client.Account.all
    @account = all_accounts.select{|acct| acct.status == "ACTIVE" && acct.type == "REVENUE"}.first
    @bank_account = all_accounts.select{|acct| acct.status == "ACTIVE" && acct.type == "BANK"}.first    
  end

  can "create a new PrePayment bank transaction" do
    new_transaction = client.BankTransaction.build(
      :type => "RECEIVE-PREPAYMENT",
      :contact => { :name => "Jazz Kang" },
      :line_items => any_line_items(@account),
      :bank_account => { :account_id => @bank_account.account_id }
    )

    assert new_transaction.save, "Save failed with the following errors: #{new_transaction.errors.inspect}"
    assert_exists new_transaction
  end

  def any_line_items(account)
    [{
      :description => "Clingfilm bike shorts",
      :quantity => 1,
      :unit_amount => "200.00",
      :account_code => account.code,
      :tax_type => account.tax_type
    }]
  end

  def assert_exists(prepayment)
    assert_not_nil prepayment.id,
      "Cannot check for exitence unless the prepayment (bank transaction) has non-null identifier"
    assert_not_nil client.BankTransaction.find prepayment.id
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
xeroizer-2.20.0 test/acceptance/about_creating_prepayment_test.rb
xeroizer-2.19.0 test/acceptance/about_creating_prepayment_test.rb
xeroizer-2.18.1 test/acceptance/about_creating_prepayment_test.rb
xeroizer-2.17.1 test/acceptance/about_creating_prepayment_test.rb