Sha256: eb93aa52fc39253024e1624fc103ccccce6d26b63812e60cf24b2064a8bc589d

Contents?: true

Size: 1.4 KB

Versions: 8

Compression:

Stored size: 1.4 KB

Contents

require "test_helper"

class BankTransactionTest < Test::Unit::TestCase
  include Xeroizer::Record

  def setup

    the_line_items = [
      LineItem.build({:quantity => 1, :tax_amount => 0.15, :unit_amount => 1.00, :tax_amount => 0.50}, nil),
      LineItem.build({:quantity => 1, :tax_amount => 0.15, :unit_amount => 1.00, :tax_amount => 0.50}, nil)
    ]

    @the_bank_transaction = BankTransaction.new(nil)
    @the_bank_transaction.line_items = the_line_items
  end

  context "given a bank_transaction with line_amount_types set to \"Exclusive\"" do
    setup do
      @the_bank_transaction.line_amount_types = "Exclusive"
    end

    must "calculate the total as the sum of its line item line_amount and tax_amount" do
      assert_equal "3.0", @the_bank_transaction.total.to_s
    end

    must "calculate the sub_total as the sum of the line_amounts" do
      assert_equal "2.0", @the_bank_transaction.sub_total.to_s
    end
  end

  context "given a bank_transaction with line_amount_types set to \"Inclusive\"" do
    setup do
      @the_bank_transaction.line_amount_types = "Inclusive"
    end

    must "calculate the total as the sum of its line item line_amount and tax_amount" do
      assert_equal "2.0", @the_bank_transaction.total.to_s
    end

    must "calculate the sub_total as the sum of the line_amounts minus the total tax" do
      assert_equal "1.0", @the_bank_transaction.sub_total.to_s
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
xeroizer-2.16.4 test/unit/models/bank_transaction_test.rb
xeroizer-2.16.3 test/unit/models/bank_transaction_test.rb
xeroizer-2.16.1 test/unit/models/bank_transaction_test.rb
xeroizer-2.16.0 test/unit/models/bank_transaction_test.rb
xeroizer-2.15.9 test/unit/models/bank_transaction_test.rb
xeroizer-2.15.8 test/unit/models/bank_transaction_test.rb
xeroizer-2.15.7 test/unit/models/bank_transaction_test.rb
xeroizer-2.15.6 test/unit/models/bank_transaction_test.rb