Sha256: 8621db08dde0d1206b406d1333d1a0c3749fe538d6a6fdefff5a402d9334e648

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

require 'unit_test_helper'

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

  def setup

    the_line_items = [
      LineItem.build({:quantity => 1, :unit_amount => 1.00, :tax_amount => 0.50}, nil),
      LineItem.build({:quantity => 1, :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

3 entries across 3 versions & 2 rubygems

Version Path
xeroizer-3.0.1 test/unit/models/bank_transaction_test.rb
xeroizer-3.0.0 test/unit/models/bank_transaction_test.rb
xeroizer-3-pre-beta-3.0.0.pre.beta test/unit/models/bank_transaction_test.rb