def testMixedAddition(self):
     fiveBucks = Money.dollar(5)
     tenFrancs = Money.franc(10)
     bank = Bank()
     bank.addRate('CHF', 'USD', 2)
     result = bank.reduce(fiveBucks.plus(tenFrancs), 'USD')
     self.assertEqual(Money.dollar(10), result)
 def testTotalTimes(self):
     fiveBucks = Money.dollar(5)
     tenFrancs = Money.franc(10)
     bank = Bank()
     bank.addRate('CHF', 'USD', 2)
     total = Total(fiveBucks, tenFrancs).times(2)
     result = bank.reduce(total, 'USD')
     self.assertEquals(Money.dollar(20), result)
Beispiel #3
0
 def testSumTimes(self):
     fivedollar = Money.dollar(5)
     tenfranc = Money.franc(10)
     bank = Bank()
     bank.addRate('CHF', 'USD', 2)
     sum = Sum(fivedollar, tenfranc).times(2)
     result = bank.reduce(sum, 'USD')
     self.assertEqual(Money.dollar(20), result)
Beispiel #4
0
 def testSumPlusMoney(self):
     fivedollar = Money.dollar(5)
     tenfranc = Money.franc(10)
     bank = Bank()
     bank.addRate('CHF', 'USD', 2)
     sum = Sum(fivedollar, tenfranc).plus(fivedollar)
     result = bank.reduce(sum, 'USD')
     self.assertEqual(Money.dollar(15), result)
 def testIdentityRate(self):
     self.assertEqual(1, Bank().rate('USD', 'USD'))
 def testReduceMoneyDifferentCurrency(self):
     bank = Bank()
     bank.addRate('CHF', 'USD', 2)
     result = bank.reduce(Money.franc(2), 'USD')
     self.assertEqual(Money.dollar(1), result)
 def testReduceMoney(self):
     bank = Bank()
     result = bank.reduce(Money.dollar(1), 'USD')
     self.assertEqual(Money.dollar(1), result)
 def testReduceTotal(self):
     total = Total(Money.dollar(3), Money.dollar(4))
     bank = Bank()
     result = bank.reduce(total, 'USD')
     self.assertEqual(Money.dollar(7), result)
 def testSimpleAddition(self):
     five = Money.dollar(5)
     total = five.plus(five)
     bank = Bank()
     reduced = bank.reduce(total, 'USD')
     self.assertEqual(Money.dollar(10), reduced)
Beispiel #10
0
from decimal import *

from finance import Bank, Facility, Covenant, Loan
from helpers import read_csv, write_csv

# Read the csv file from banks.csv and generate bank dictionary
banks_rows = read_csv('banks.csv')
banks = {}
for row in banks_rows:
    bank_id = int(row[0])
    bank_name = row[1]
    bank = Bank(bank_id, bank_name)
    banks[bank.bank_id] = bank

# Read the csv file from facilities.csv and assign facilities to banks
facilities_rows = read_csv('facilities.csv')
for row in facilities_rows:
    facility_id = int(row[2])
    bank_id = int(row[3])
    interest_rate = Decimal(row[1])
    amount = Decimal(row[0])
    facility = Facility(facility_id, bank_id, interest_rate, amount)
    banks[facility.bank_id].facilities[facility_id] = facility

# Read the csv file from covenants.csv and assign covenants to banks or facilities
covenants_rows = read_csv('covenants.csv')
for row in covenants_rows:

    bank_id = int(row[2])

    if row[0] is not None and len(row[0]) > 0:
Beispiel #11
0
 def testPlusSameCurrencyeturnMoney(self):
     sum = Money.dollar(1).plus(Money.dollar(1))
     bank = Bank()
     reduced = bank.reduce(sum, 'USD')
     self.assertEqual(isinstance(reduced, Money), True)
Beispiel #12
0
 def testReduceSum(self):
     sum = Sum(Money.dollar(3), Money.dollar(4))
     bank = Bank()
     result = bank.reduce(sum, 'USD')
     self.assertEqual(Money.dollar(7), result)