def test__EnergyValue__update_data_5(database):
    """Creates bookings for advanced pay for the next year."""
    from sw.allotmentclub import EnergyValue, ElectricMeter, EnergyPrice
    from sw.allotmentclub import Booking, BookingKind, BankingAccount
    setUp()
    BookingKind.create(title='Energieabschlag I')
    BookingKind.create(title='Energieabschlag II')
    BankingAccount.create(number='3')
    EnergyPrice.create(year=2016,
                       price=3020,
                       normal_fee=81700,
                       power_fee=243300)
    meter = ElectricMeter.get(1)
    value = EnergyValue.create(electric_meter=meter, year=2016, value=7132)
    assert Booking.query().filter(Booking.accounting_year == 2017).all() == []
    value.update_member()
    value.update_usage()
    value.update_data()
    ap1, ap2 = Booking.query().filter(Booking.accounting_year == 2017).all()
    assert ap1.value == ap2.value == -267800
    assert ap1.member == ap2.member == value.member
    assert ap1.booking_day == datetime.date(2017, 3, 31)
    assert ap2.booking_day == datetime.date(2017, 6, 30)
    assert ap1.purpose == 'Energieabschlag I für Zähler 318992603'
    assert ap2.purpose == 'Energieabschlag II für Zähler 318992603'
예제 #2
0
def test_import_sepa_creates_new_booking_entry_for_open_amount(database,
                                                               member):
    from ..account import import_transactions, SEPASammler, SEPASammlerEntry
    from ..account import BankingAccount, Booking
    account = BankingAccount.find_or_create(
        organization_id=1, number='3440000167')
    sammler = SEPASammler.create(
        pmtinfid='PII7ebef1ebc3ec4a5185583851c8f7dbb2',
        booking_day=datetime.datetime.now(),
        accounting_year=2018)
    SEPASammlerEntry.create(sepasammler=sammler, value=10000000)
    statements = [{
        'date': datetime.datetime.now(),
        'currency': 'EUR',
        'purpose': 'Energieabrechnung',
        'amount': Amount(2743.12, 'EUR'),
        'applicant_name': 'Verein',
        'posting_text': 'SAMMEL-LS-EINZUG',
        'applicant_iban': 'DE123456778899',
        'applicant_bin': 'NOLADE21HAL',
        'customer_reference': ('DATUM 14.06.2018, 14.28 UHR ANZAHL 9\n'
                               'PII7ebef1ebc3ec4a5185583851c8f7dbb2')
    }]
    assert 0 == Booking.query().count()
    import_transactions(statements, account)
    assert 3 == Booking.query().count()

    assert 27431200 == Booking.get(1).value
    assert 10000000 == Booking.get(2).value
    assert 17431200 == Booking.get(3).value

    assert 1 == Booking.get(2).splitted_from_id
    assert 1 == Booking.get(3).splitted_from_id

    assert 'SAMMEL-LS-EINZUG Verrechnet' == Booking.get(2).booking_text
예제 #3
0
def test_import_sepa_raises_value_error_if_empty_sammler(database, member):
    from ..account import import_transactions, BankingAccount, SEPASammler
    from ..account import Booking
    account = BankingAccount.find_or_create(
        organization_id=1, number='3440000167')
    SEPASammler.create(pmtinfid='PII7ebef1ebc3ec4a5185583851c8f7dbb2',
                       booking_day=datetime.datetime.now(),
                       accounting_year=2018)
    statements = [{
        'date': datetime.datetime.now(),
        'currency': 'EUR',
        'purpose': 'Energieabrechnung',
        'amount': Amount(2743.12, 'EUR'),
        'applicant_name': 'Verein',
        'posting_text': 'SAMMEL-LS-EINZUG',
        'applicant_iban': 'DE123456778899',
        'applicant_bin': 'NOLADE21HAL',
        'customer_reference': ('DATUM 14.06.2018, 14.28 UHR ANZAHL 9\n'
                               'PII7ebef1ebc3ec4a5185583851c8f7dbb2')
    }]
    assert 0 == Booking.query().count()
    with pytest.raises(
            ValueError,
            match=(r"Keine Sammler-Einträge zu PmtInfId "
                   r"'PII7ebef1ebc3ec4a5185583851c8f7dbb2' gefunden.")):
        import_transactions(statements, account)
    assert 0 == Booking.query().count()
def test__EnergyValue__update_data_6(database):
    """Creates multiple bookings for multiple meters of the same allotment."""
    from sw.allotmentclub import EnergyValue, ElectricMeter, EnergyPrice
    from sw.allotmentclub import Booking, BookingKind, BankingAccount
    setUp()
    BookingKind.create(title='Energieabrechnung')
    BookingKind.create(title='Energieabschlag I')
    BankingAccount.create(number='3')
    EnergyPrice.create(year=2016,
                       price=3020,
                       normal_fee=81700,
                       power_fee=243300)
    meter = ElectricMeter.get(1)
    value = EnergyValue.create(electric_meter=meter, year=2016, value=7132)
    meter2 = ElectricMeter.get(2)
    value2 = EnergyValue.create(electric_meter=meter2, year=2016, value=14123)
    meter.allotment = meter2.allotment

    assert Booking.query().filter(Booking.accounting_year == 2017).all() == []
    value.update_member()
    value.update_usage()
    value.update_data()
    value2.update_member()
    value2.update_usage()
    value2.update_data()

    ap1, ap2 = Booking.query().filter(Booking.accounting_year == 2017).all()
    assert ap1.value != ap2.value
    assert ap1.member == ap2.member == value.member
    assert ap1.booking_day == ap2.booking_day == datetime.date(2017, 3, 31)
    assert ap1.purpose == 'Energieabschlag I für Zähler 318992603'
    assert ap2.purpose == 'Energieabschlag I für Zähler 136426011'

    enab1, enab2 = Booking.query().filter(
        Booking.accounting_year == 2016).all()
    assert enab1.value != enab2.value
    assert enab1.member == enab2.member == value.member
    assert enab1.booking_day == enab2.booking_day == datetime.date(2016, 8, 31)
    assert enab1.purpose == 'Energieabrechnung für Zähler 318992603'
    assert enab2.purpose == 'Energieabrechnung für Zähler 136426011'
예제 #5
0
def setUpSEPASammlerUpdate(kind_shorttitle):
    from sw.allotmentclub import (
        SEPASammler, Booking, BookingKind, BankingAccount, Member)
    kind = BookingKind.find_or_create(title='', shorttitle=kind_shorttitle)
    sammler = SEPASammler.create(
        booking_day='2016-06-30', accounting_year=2016, kind=kind)
    for value in [-2500, -821300]:
        Booking.find_or_create(
            value=value, banking_account=BankingAccount.find_or_create(),
            accounting_year=2016, kind=kind,
            member=Member.create(direct_debit=True))
    setUp()
    return sammler
예제 #6
0
 def update(self):
     account = (BankingAccount.query().filter(
         BankingAccount.number == '1')).one()
     kind = (BookingKind.query().filter(
         BookingKind.title == 'Mitgliedsbeitrag')).one()
     year = get_selected_year()
     for member, fee_data in get_membership_fees(year).items():
         parcel_numbers = fee_data['parcel_number']
         parcel_size = fee_data['parcel_size']
         fee = fee_data['membership_fee']
         Booking.create(
             banking_account=account,
             purpose=(f'Mitgliedsbeitrag {year} Flurstück {parcel_numbers} '
                      f'({parcel_size}qm)'),
             value=0 - fee,
             accounting_year=year,
             booking_day=datetime.date(int(year), 3, 31),
             member=member,
             kind=kind)
예제 #7
0
def test_import_via_sparkassen_csv(database):
    from sw.allotmentclub import Booking, BankingAccount
    import_bookings()
    assert 1 == len(BankingAccount.query().all())
    assert 30 == len(Booking.query().all())