Пример #1
0
def test_ensures_rates_multiple_currencies(app):
    # Upon calling save and load, rates are asked for the 20-today range for both USD and EUR.
    db, log = set_ratedb_for_tests()
    app.save_and_load()
    expected = {
        (date(2008, 4, 20), date(2008, 4, 29), 'USD'), 
        (date(2008, 4, 20), date(2008, 4, 29), 'EUR'),
    }
    eq_(set(log), expected)
    # Now let's test that the rates are in the DB
    eq_(USD.value_in(CAD, date(2008, 4, 20)), 1.42)
    eq_(EUR.value_in(CAD, date(2008, 4, 22)), 1.44)
    eq_(EUR.value_in(USD, date(2008, 4, 24)), 1.0)
    eq_(USD.value_in(CAD, date(2008, 4, 25)), 1.47)
    eq_(USD.value_in(CAD, date(2008, 4, 27)), 1.49)
Пример #2
0
def test_balance_sheet_with_multiple_currencies(app):
    eq_(USD.value_in(CAD, date(2008, 2, 1)), 0.9)
    eq_(app.doc.date_range, MonthRange(date(2008, 1, 1)))
    eq_(app.bsheet.assets.start, '40.00')
    eq_(app.bsheet.assets.end, '235.00')
    eq_(app.bsheet.assets.delta, '195.00')
    eq_(app.bsheet.assets.delta_perc, '+487.5%')
    eq_(app.bsheet.assets[0].start, '40.00')
    eq_(app.bsheet.assets[0].end, '235.00')
    eq_(app.bsheet.assets[0].delta, '195.00')
    eq_(app.bsheet.assets[0].delta_perc, '+487.5%')
Пример #3
0
def test_balance_sheet_with_multiple_currencies(app):
    # Totals in balance sheets are properly converted using conversion rates. Also, whenever
    # multiple currencies are involved, we always explicitly display currencies. Ref #392
    eq_(USD.value_in(CAD, date(2008, 2, 1)), 0.9)
    eq_(app.doc.date_range, MonthRange(date(2008, 1, 1)))
    eq_(app.bsheet.assets.start, 'CAD 40.00')
    eq_(app.bsheet.assets.end, 'CAD 235.00')
    eq_(app.bsheet.assets.delta, 'CAD 195.00')
    eq_(app.bsheet.assets.delta_perc, '+487.5%')
    eq_(app.bsheet.assets[0].start, 'CAD 40.00')
    eq_(app.bsheet.assets[0].end, 'CAD 235.00')
    eq_(app.bsheet.assets[0].delta, 'CAD 195.00')
    eq_(app.bsheet.assets[0].delta_perc, '+487.5%')
    eq_(app.bsheet.net_worth.start, 'CAD 40.00')
    eq_(app.bsheet.net_worth.end, 'CAD 235.00')
    eq_(app.bsheet.net_worth.delta, 'CAD 195.00')
    eq_(app.bsheet.net_worth.delta_perc, '+487.5%')