Commit 26e445c7 authored by Luca Cristaldi's avatar Luca Cristaldi

add test case for changing join_date

parent 0e48d8cc
==================
Member change date
==================
Imports::
>>> import datetime
>>> from dateutil.relativedelta import relativedelta
>>> from decimal import Decimal
>>> from operator import attrgetter
>>> from proteus import Model, Wizard
>>> from trytond.tests.tools import activate_modules
>>> from trytond.modules.company.tests.tools import create_company, \
... get_company
>>> from trytond.modules.account.tests.tools import create_fiscalyear, \
... create_chart, get_accounts, create_tax, create_tax_code
>>> from trytond.modules.association.tests.tools import create_period
>>> from decimal import *
>>> today = datetime.date.today()
Install association::
>>> config = activate_modules('association')
Create company::
>>> _ = create_company()
>>> company = get_company()
Create fiscal year::
>>> fiscalyear = create_fiscalyear(company)
>>> fiscalyear.click('create_period')
>>> period = fiscalyear.periods[0]
Create chart of accounts::
>>> _ = create_chart(company)
>>> accounts = get_accounts(company)
>>> receivable = accounts['receivable']
>>> payable = accounts['payable']
>>> revenue = accounts['revenue']
>>> expense = accounts['expense']
>>> account_tax = accounts['tax']
>>> account_cash = accounts['cash']
Create party::
>>> Party = Model.get('party.party')
>>> party = Party(name='Party')
>>> party.account_payable = payable
>>> party.account_receivable = receivable
>>> party.save()
Create member::
>>> Member = Model.get('association.member')
>>> member = Member()
>>> member.party = party
>>> member.save()
Get a revenue journal::
>>> Journal = Model.get('account.journal')
>>> journal_revenue, = Journal.find([
... ('code', '=', 'REV'),
... ])
Create memberships::
>>> def periodgen(startDate,deltaTime,quantity):
... firstDate = startDate
... for period in range(quantity):
... lastDate = firstDate + deltaTime
... yield (firstDate,lastDate)
... firstDate = lastDate + datetime.timedelta(days=1)
>>> start_date = datetime.date(2018,1,1)
>>> fiscalMonth = 13
>>> timedelta = datetime.timedelta(weeks=4)
>>> Membership = Model.get('association.membership.type')
>>> Period = Model.get('association.membership.period')
>>> membership1 = Membership()
>>> membership1.party = party
>>> membership1.name = "membership1"
>>> membership1.account_revenue = revenue
>>> membership1.journal = journal_revenue
>>> periods1 = []
>>> for period in periodgen(start_date,timedelta,fiscalMonth):
... newPeriod = membership1.periods.new(
... start_date=period[0],
... end_date=period[1],
... name="test",
... amount=Decimal(42))
... periods1.append(newPeriod)
>>> membership1.save()
Add membership to member::
>>> _ = member.memberships.new(
... membership_type=membership1,
... )
>>> member.save()
Enroll member::
>>> member.join_date = start_date + datetime.timedelta(weeks=10)
>>> member.save()
>>> member.click("run")
Create fee lines::
>>> Fee = Model.get('association.membership.fee')
>>> create_fee = Wizard('association.membership.fee_create')
>>> create_fee.form.date = start_date + datetime.timedelta(weeks=40)
>>> create_fee.execute('create_')
>>> len(Fee.find([])) > 0
True
Create fee after change date::
>>> before_fees = set(Fee.find([]))
>>> member.click("draft")
>>> new_date = start_date - datetime.timedelta(weeks=10)
>>> member.join_date = new_date
>>> member.save()
>>> member.click("run")
>>> create_fee = Wizard('association.membership.fee_create')
>>> create_fee.form.date = start_date + datetime.timedelta(weeks=40)
>>> create_fee.execute('create_')
>>> after_fees = set(Fee.find([]))
>>> newfees = after_fees - before_fees
>>> all(map(lambda x: x.period.start_date >= new_date, newfees))
True
......@@ -42,4 +42,10 @@ def suite():
encoding='utf-8',
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE,
checker=doctest_checker))
suite.addTests(
doctest.DocFileSuite('scenario_member_change_date.rst',
tearDown=doctest_teardown,
encoding='utf-8',
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE,
checker=doctest_checker))
return suite
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment