Commit ae2c8fdf authored by Sebastien Robin's avatar Sebastien Robin

create mixin class and integrate last changes made by Nicolas

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13367 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 98ce9718
...@@ -46,6 +46,7 @@ from Testing import ZopeTestCase ...@@ -46,6 +46,7 @@ from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import Sequence, SequenceList from Products.ERP5Type.tests.Sequence import Sequence, SequenceList
from AccessControl.SecurityManagement import newSecurityManager, noSecurityManager from AccessControl.SecurityManagement import newSecurityManager, noSecurityManager
from Products.DCWorkflow.DCWorkflow import Unauthorized, ValidationFailed
from DateTime import DateTime from DateTime import DateTime
from Acquisition import aq_base, aq_inner from Acquisition import aq_base, aq_inner
from zLOG import LOG from zLOG import LOG
...@@ -58,12 +59,15 @@ try: ...@@ -58,12 +59,15 @@ try:
except ImportError: except ImportError:
pass pass
class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
run_all_test = 1 run_all_test = 1
# Different variables used for this test # Different variables used for this test
item_portal_type = 'Apparel Fabric Item' item_portal_type = 'Apparel Fabric Item'
packing_list_portal_type = 'Purchase Packing List'
internal_packing_list_portal_type = 'Internal Packing List'
sale_packing_list_portal_type = 'Sale Packing List'
inventory_portal_type = 'Inventory'
inventory_line_portal_type = 'Inventory Line'
organisation_portal_type = 'Organisation' organisation_portal_type = 'Organisation'
account_portal_type = 'Account' account_portal_type = 'Account'
currency_portal_type = 'Currency' currency_portal_type = 'Currency'
...@@ -74,7 +78,8 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -74,7 +78,8 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
no_amortisation_method = 'eu/no_amortisation' no_amortisation_method = 'eu/no_amortisation'
diverged = 'diverged' diverged = 'diverged'
solved = 'solved' solved = 'solved'
id_transaction = 0
id_simulation = 0
reindex_done = 0 reindex_done = 0
def getTitle(self): def getTitle(self):
...@@ -91,16 +96,14 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -91,16 +96,14 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
Return the list of business templates. Return the list of business templates.
""" """
return ("erp5_base", return ( "erp5_base",
"erp5_trade", "erp5_trade",
"erp5_pdm", # Needed by accounting "erp5_pdm",# Needed by accounting
"erp5_accounting", "erp5_accounting",
"erp5_apparel", # In order to use items "erp5_apparel", # In order to use items
"erp5_immobilisation", "erp5_immobilisation",
) )
def getCategoriesTool(self):
return getattr(self.getPortal(), 'portal_categories', None)
def getRuleTool(self): def getRuleTool(self):
return getattr(self.getPortal(), 'portal_rules', None) return getattr(self.getPortal(), 'portal_rules', None)
def getAccountingModule(self): def getAccountingModule(self):
...@@ -111,14 +114,104 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -111,14 +114,104 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
return self.getPortal().getDefaultModule(portal_type=self.item_portal_type) return self.getPortal().getDefaultModule(portal_type=self.item_portal_type)
def getPackingListModule(self): def getPackingListModule(self):
return self.getPortal().getDefaultModule(portal_type=self.packing_list_portal_type) return self.getPortal().getDefaultModule(portal_type=self.packing_list_portal_type)
def getInternalPackingListModule(self):
return self.getPortal().getDefaultModule(portal_type=self.internal_packing_list_portal_type)
def getSalePackingListModule(self):
return self.getPortal().getDefaultModule(portal_type=self.sale_packing_list_portal_type)
def getInventoryModule(self):
return self.getPortal().getDefaultModule(portal_type=self.inventory_portal_type)
def getAccountModule(self): def getAccountModule(self):
return self.getPortal().getDefaultModule(portal_type=self.account_portal_type) return self.getPortal().getDefaultModule(portal_type=self.account_portal_type)
def getCurrencyModule(self): def getUserFolder(self):
return self.getPortal().getDefaultModule(portal_type=self.currency_portal_type) return getattr(self.getPortal(), 'acl_users', None)
def getWorkflowTool(self):
return getattr(self.getPortal(), 'portal_workflow', None)
def createManagerAndLogin(self, quiet=0, run=run_all_test):
"""
Create a simple user in user_folder with manager rights.
This user will be used to initialize data in the method afterSetup
"""
all_roles = ['Manager','Assignor','Assignee','Author','Associate','Auditor']
self.getUserFolder()._doAddUser('manager', '', all_roles, [])
self.login('manager')
self.assignPASRolesToUser('test_user_1_', all_roles)
def checkUserFolderType(self, quiet=0, run=run_all_test):
"""
Check the type of user folder to let the test working with both NuxUserGroup and PAS.
"""
self.user_folder = self.getUserFolder()
self.PAS_installed = 0
if self.user_folder.meta_type == 'Pluggable Auth Service':
# we use PAS
self.PAS_installed = 1
def assignPASRolesToUser(self, user_name, role_list, quiet=0, run=run_all_test):
"""
Assign a list of roles to one user with PAS.
"""
user_folder = self.getUserFolder()
for role in role_list:
if role not in user_folder.zodb_roles.listRoleIds():
user_folder.zodb_roles.addRole(role)
user_folder.zodb_roles.assignRoleToPrincipal(role, user_name)
def createERP5Users(self, user_dict, quiet=0, run=run_all_test):
"""
Create all ERP5 users needed for the test.
ERP5 user = Person object + Assignment object in erp5 person_module.
"""
for user_login, user_data in user_dict.items():
user_roles = user_data[0]
# Create the Person.
if len([p for p in self.getPersonModule().objectValues() if p.getReference() == user_login]) == 0:
person = self.getPersonModule().newContent(id=user_login,
portal_type='Person',
reference=user_login,
career_role="internal")
# Create the Assignment.
assignment = person.newContent( portal_type = 'Assignment'
, destination_value = user_data[1]
, function = user_data[2]
, group = user_data[3]
, site = user_data[4]
)
if self.PAS_installed and len(user_roles) > 0:
# In the case of PAS, if we want global roles on user, we have to do it manually.
self.assignPASRolesToUser(user_login, user_roles)
elif not self.PAS_installed:
# The user_folder counterpart of the erp5 user must be
# created manually in the case of NuxUserGroup.
self.user_folder.userFolderAddUser( name = user_login
, password = ''
, roles = user_roles
, domains = []
)
# User assignment to security groups is also required, but is taken care of
# by the assignment workflow when NuxUserGroup is used and
# by ERP5Security PAS plugins in the context of PAS use.
assignment.open()
person.validate()
def updateRoleMappings(self, portal_type_list=[]):
"""
Update the local roles in existing objects.
"""
portal_catalog = self.portal.portal_catalog
for portal_type in portal_type_list:
for brain in portal_catalog(portal_type = portal_type):
obj = brain.getObject()
userdb_path, user_id = obj.getOwnerTuple()
obj.updateLocalRolesOnSecurityGroups(user_name = user_id)
#obj.assignRoleToSecurityGroup(user_name = user_id)
def afterSetUp(self): def afterSetUp(self):
self.login() LOG('testImmobilisationMixin',0,'In AfterSetUp')
portal = self.getPortal() portal = self.getPortal()
self.createManagerAndLogin()
# remove all message in the message_table because # remove all message in the message_table because
# the previous test might have failed # the previous test might have failed
...@@ -126,21 +219,66 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -126,21 +219,66 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
for message in message_list: for message in message_list:
portal.portal_activities.manageCancel(message.object_path,message.method_id) portal.portal_activities.manageCancel(message.object_path,message.method_id)
self.createCategories()
#Assert default security Value
list_module = [ 'Inventory Module',
'Purchase Packing List Module',
'Internal Packing List Module',
'Sale Packing List Module',
'Building Module',
'Incorporeal Item Module',
'Reevaluation Module',
'Restoration Module',
self.getAccountingModule().getPortalType(),
self.getOrganisationModule().getPortalType(),
self.getItemModule().getPortalType(),
self.getPackingListModule().getPortalType(),
self.getInventoryModule().getPortalType(),
self.getAccountModule().getPortalType(),
self.getCurrencyModule().getPortalType(),
self.getPersonModule().getPortalType()
]
# Then add new components # Then add new components
self.createCurrency() self.createCurrency()
self.createCategories()
self.createOrganisationList() self.createOrganisationList()
self.createItemList()
self.createAccountList() self.createAccountList()
self.createItemList()
get_transaction().commit()
self.tic()
self.workflow_tool = self.getWorkflowTool()
self.checkUserFolderType()
def beforeTearDown(self):
"""
Delete all Objects in PL & M Module
"""
LOG('testImmobilisationMixin',0,'In beforeTearDown')
self.logout()
self.login('manager')
#simulation_id_list = [r for r in self.getPortal().portal_simulation.objectIds()]
#self.getPortal().portal_simulation.manage_delObjects(simulation_id_list)
item_id_list = [r for r in self.getItemModule().objectIds()]
#LOG('item_id_list before',0,item_id_list)
self.getItemModule().manage_delObjects(item_id_list)
#LOG('item_id_list after',0,[r for r in self.getPortal().material_module.objectIds()])
#item_catalog = [(r.uid,r.path) for r in self.getPortal().portal_catalog(portal_type = 'Material')]
#LOG('item_catalog after',0,item_catalog)
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
pl_id_list = [r for r in self.getPortal().purchase_packing_list_module.objectIds()]
def login(self, quiet=0, run=run_all_test): #LOG('pl_id_list before',0,pl_id_list)
uf = self.getPortal().acl_users self.getPortal().purchase_packing_list_module.manage_delObjects(pl_id_list)
uf._doAddUser('guillaume', '', ['Manager'], [])
uf._doAddUser('ERP5TypeTestCase', '', ['Manager'], []) get_transaction().commit()
user = uf.getUserById('guillaume').__of__(uf) self.tic()
newSecurityManager(None, user)
def createCategories(self): def createCategories(self):
""" """
...@@ -150,15 +288,30 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -150,15 +288,30 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
category_tool = self.getCategoryTool() category_tool = self.getCategoryTool()
if len(category_tool.group.contentValues())==0: if len(category_tool.group.contentValues())==0:
self.createCategoryTree(category_tool.group, self.createCategoryTree(category_tool.group,
[ ("group A", [
[("group Aa", [("group Aa1",[]),("group Aa2",[])]), ("group A","GA",
("group Ab", [("group Ab1",[]),("group Ab2",[])])] [
("group Aa","GAa",
[
("group Aa1","GAa1",[]),
("group Aa2","GAa2",[])
]
),
("group Ab","GAb",
[
("group Ab1","GAb1",[]),
("group Ab2","GAb2",[])
]
)
]
), ),
("group B", ("group B","GB",
[("group Ba", []), [
("group Bb", [])], ("group Ba","GBa", []),
("group Bb","GBb", [])
],
), ),
("group C", []), ("group C","GC", []),
] ]
) )
...@@ -166,14 +319,26 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -166,14 +319,26 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
""" """
Create a category tree Create a category tree
""" """
for category, new_tree in category_tree: for category, codification, new_tree in category_tree:
new_category = current_category.newContent(portal_type='Category', id=category) new_category = current_category.newContent(portal_type='Category', id=category, codification=codification)
self.createCategoryTree(new_category, new_tree) self.createCategoryTree(new_category, new_tree)
def createCategorySiteTree(self, current_category, category_tree):
"""
Create a category tree
"""
for category, codification, vault_type, new_tree in category_tree:
new_category = current_category.newContent(portal_type='Category',
id=category,
codification=codification)
new_category.setVaultType(vault_type)
self.createCategorySiteTree(new_category, new_tree)
def createCurrency(self): def createCurrency(self):
currency_module = self.getCurrencyModule() currency_module = self.getCurrencyModule()
if len(currency_module.contentValues())==0: if len(currency_module.contentValues())==0:
currency_module.newContent(id="EUR") currency_module.newContent(id="EUR", portal_type='Currency')
currency_module.newContent(id="FCFA", portal_type='Currency')
def createOrganisationList(self): def createOrganisationList(self):
""" """
...@@ -181,24 +346,29 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -181,24 +346,29 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
""" """
organisation_module = self.getOrganisationModule() organisation_module = self.getOrganisationModule()
if len(organisation_module.contentValues())==0: if len(organisation_module.contentValues())==0:
for organisation_id, group, mapping in ( organisation_list= (
("A", "group/group A", "group/group A"), ("A", "A", "group A", "group/group A"),
("Aa", "group/group A", "group/group A/group Aa"), ("Aa", "Aa", "group A", "group/group A/group Aa"),
("Ab", "group/group A", "group/group A/group Ab"), ("Ab", "Ab", "group A", "group/group A/group Ab"),
("Aa1", "group/group A", "group/group A/group Aa/group Aa1"), ("Aa1", "Aa1", "group A", "group/group A/group Aa/group Aa1"),
("Aa2", "group/group A", "group/group A/group Aa/group Aa2"), ("Aa2", "Aa2", "group A", "group/group A/group Aa/group Aa2"),
("Ab1", "group/group A", "group/group A/group Ab/group Ab1"), ("Ab1", "Ab1", "group A", "group/group A/group Ab/group Ab1"),
("Ab2", "group/group A", "group/group A/group Ab/group Ab2"), ("Ab2", "Ab2", "group A", "group/group A/group Ab/group Ab2"),
("B", "group/group B", "group/group B"), ("B", "B", "group B", "group/group B"),
("Ba", "group/group B", "group/group B/group Ba"), ("Ba", "Ba", "group B", "group/group B/group Ba"),
("Bb", "group/group B", "group/group B/group Bb"), ("Bb", "Bb", "group B", "group/group B/group Bb"),
("standalone", "", ""), ("standalone", "standalone", "", ""),
): )
for organisation_id, title, group, mapping in organisation_list:
organisation_module.newContent(id = organisation_id, organisation_module.newContent(id = organisation_id,
title = title,
group = group, group = group,
mapping = mapping, mapping = mapping,
) )
for organisation_id in ('A','Aa','Ab','B','Ba','Bb','standalone'): ##We need to commit here because edit organisation doesn't apply
#get_transaction().commit()
#self.tic()
for organisation_id in ['A','Aa','Ab','B','Ba','Bb','standalone']:
organisation = organisation_module[organisation_id] organisation = organisation_module[organisation_id]
organisation.edit(price_currency_value = self.getCurrencyModule()["EUR"], organisation.edit(price_currency_value = self.getCurrencyModule()["EUR"],
financial_year_stop_date = DateTime('2000/01/01')) financial_year_stop_date = DateTime('2000/01/01'))
...@@ -234,19 +404,44 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -234,19 +404,44 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
'monthly_amortisation_account':'%s/%s' % (self.getAccountModule().getId(),'account12'), 'monthly_amortisation_account':'%s/%s' % (self.getAccountModule().getId(),'account12'),
} }
def createAmortisationDefaultData(self):
amo_data_module = self.getPortal().amortisation_default_data_module
if len(amo_data_module.contentValues()) == 0:
property_dict1 = {'amortisation_method':self.linear_method,
'amortisation_start_price':0.0,
'disposal_price':0.0,
'amortisation_duration':72,
'immobilisation_vat':0.0,
'product_line':'armoires',
}
amo_data1 = amo_data_module.newContent()
amo_data1.edit(**property_dict1)
property_dict2 = {'amortisation_method':self.linear_method,
'amortisation_start_price':0.0,
'disposal_price':0.0,
'amortisation_duration':72,
'immobilisation_vat':0.0,
'product_line':'art_tableaux',
}
amo_data2 = amo_data_module.newContent()
amo_data2.edit(**property_dict2)
def createItemList(self): def createItemList(self):
""" """
Create some items Create some items
""" """
item_module = self.getItemModule() item_module = self.getItemModule()
if len(item_module.contentValues())==0: if len(item_module.contentValues()) == 0:
for i in range(20): for i in range(30):
item_id = 'item%i' % i item_id = 'item%i' % i
item_module.newContent(id=item_id) item_module.newContent(id=item_id, reference=item_id)
def stepPdb(self, sequence=None, sequence_list=None, **kw):
import pdb;pdb.set_trace()
def stepCreatePackingList(self, sequence=None, sequence_list=None, **kw): def stepCreatePackingList(self, sequence=None, sequence_list=None, **kw):
property_dict = {} property_dict = {}
for property in ('source_section','destination_section','datetime'): for property in ('source_section','destination_section','datetime','destination'):
value_list = sequence.get(property) value_list = sequence.get(property)
if value_list is not None: if value_list is not None:
if type(value_list) == type([]): if type(value_list) == type([]):
...@@ -257,24 +452,58 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -257,24 +452,58 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
else: else:
value = value_list value = value_list
property_dict[property] = value property_dict[property] = value
pl_module = self.getPackingListModule() pl_module = self.getPackingListModule()
pl = pl_module.newContent(portal_type = self.packing_list_portal_type) pl = pl_module.newContent(portal_type = self.packing_list_portal_type)
pl.edit( source_section_value = property_dict['source_section'], pl.edit( source_section_value = property_dict['source_section'],
destination_section_value = property_dict['destination_section'], destination_section_value = property_dict['destination_section'],
start_date = property_dict['datetime'], start_date = property_dict['datetime'],
stop_date = property_dict['datetime'],) stop_date = property_dict['datetime'],
# Set the Packing List to stopped state, because the expand destination = property_dict['destination'],
# process get only deliveries in current_inventory_state )
pl.confirm()
pl.setReady()
pl.start()
pl.stop()
# Artificially update causality state because we don't want to tic here
pl.updateCausalityState()
packing_list_list = sequence.get('packing_list_list', []) packing_list_list = sequence.get('packing_list_list', [])
packing_list_list.append(pl) packing_list_list.append(pl)
sequence.set('packing_list_list', packing_list_list) sequence.set('packing_list_list', packing_list_list)
#LOG('createPL',0,[(ppl.getUid(),ppl.getRelativeUrl()) for ppl in pl_module.objectValues()])
def stepDeliverPackingList(self, sequence=None, sequence_list=None, **kw):
pl = sequence.get('packing_list')
if pl is None: pl = sequence.get('packing_list_list', [])[-1]
self.workflow_tool.doActionFor(pl, 'confirm_action', wf_id='packing_list_workflow')
get_transaction().commit()
self.tic()
self.workflow_tool.doActionFor(pl, 'set_ready_action', wf_id='packing_list_workflow')
self.workflow_tool.doActionFor(pl, 'start_action', wf_id='packing_list_workflow')
#import pdb; pdb.set_trace()
get_transaction().commit()
self.tic()
self.workflow_tool.doActionFor(pl, 'stop_action', wf_id='packing_list_workflow')
get_transaction().commit()
self.tic()
#self.workflow_tool.doActionFor(pl, 'deliver_action', wf_id='packing_list_workflow')
def stepTestItemValidationState(self, sequence=None, sequence_list=None, **kw):
item = self.getItemModule()['item1']
self.assertEquals(item.getValidationState(), 'exploited')
def stepAggregateItems(self, sequence=None, sequence_list=None, **kw):
pl = sequence.get('packing_list_list', [])[-1]
parameter_dict = sequence.get('parameter_dict', {})
if parameter_dict is None: parameter_dict = {}
item_list_list = sequence.get('item_list_list') # This is a list of list in
# order to make multiple lines
for item_list in item_list_list:
pl_line = pl.newContent(portal_type = self.packing_list_line_portal_type)
pl_line.edit(aggregate_value_list = item_list, **parameter_dict)
get_transaction().commit()
self.tic()
pl.edit()
def stepEditPackingList(self, sequence=None, sequence_list=None, **kw):
pl = sequence.get('packing_list')
if pl is None: pl = sequence.get('packing_list_list', [])[-1]
pl.edit()
def stepCreateComplexPackingListStructure(self, sequence=None, sequence_list=None, **kw): def stepCreateComplexPackingListStructure(self, sequence=None, sequence_list=None, **kw):
...@@ -291,23 +520,21 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -291,23 +520,21 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
item_list_list = [[ self.getItemModule()['item1'] ], [ self.getItemModule()['item2'] ]]) item_list_list = [[ self.getItemModule()['item1'] ], [ self.getItemModule()['item2'] ]])
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
sequence.edit(item_list_list = [[self.getItemModule()['item4']]], datetime = self.datetime+5) sequence.edit(item_list_list = [[self.getItemModule()['item4']]], datetime = self.datetime+5)
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
sequence.edit(item_list_list = [[ self.getItemModule()['item1'],self.getItemModule()['item3'] ]], sequence.edit(item_list_list = [[ self.getItemModule()['item1'],self.getItemModule()['item3'] ]],
datetime = self.datetime+10) datetime = self.datetime+10)
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
sequence.edit(item_list_list = [[ self.getItemModule()['item2'],self.getItemModule()['item3'] ]], sequence.edit(item_list_list = [[ self.getItemModule()['item2'],self.getItemModule()['item3'] ]],
datetime = self.datetime+15) datetime = self.datetime+15)
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
def stepEditPackingList(self, sequence=None, sequence_list=None, **kw):
pl = sequence.get('packing_list')
if pl is None: pl = sequence.get('packing_list_list', [])[-1]
pl.edit()
def stepDeletePackingList(self, sequence=None, sequence_list=None, **kw): def stepDeletePackingList(self, sequence=None, sequence_list=None, **kw):
pl = sequence.get('packing_list') pl = sequence.get('packing_list')
...@@ -351,17 +578,11 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -351,17 +578,11 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
def stepValidateAccounting(self, sequence=None, sequence_list=None, **kw): def stepValidateAccounting(self, sequence=None, sequence_list=None, **kw):
for transaction in self.getAccountingModule().contentValues(): for transaction in self.getAccountingModule().contentValues():
transaction.stop() transaction.stop()
get_transaction().commit()
self.tic()
transaction.deliver() transaction.deliver()
get_transaction().commit()
def stepAggregateItems(self, sequence=None, sequence_list=None, **kw): self.tic()
pl = sequence.get('packing_list_list', [])[-1]
parameter_dict = sequence.get('parameter_dict', {})
if parameter_dict is None: parameter_dict = {}
item_list_list = sequence.get('item_list_list') # This is a list of list in
# order to make multiple lines
for item_list in item_list_list:
pl_line = pl.newContent(portal_type = self.packing_list_line_portal_type)
pl_line.edit(aggregate_value_list = item_list, **parameter_dict)
def stepTestPackingListInvalidImmobilisationState(self, sequence=None, sequence_list=None, **kw): def stepTestPackingListInvalidImmobilisationState(self, sequence=None, sequence_list=None, **kw):
pl = sequence.get('packing_list') pl = sequence.get('packing_list')
...@@ -373,6 +594,11 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -373,6 +594,11 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
if pl is None: pl = sequence.get('packing_list_list', [])[-1] if pl is None: pl = sequence.get('packing_list_list', [])[-1]
self.stepTestPackingListImmobilisationState(pl, "valid") self.stepTestPackingListImmobilisationState(pl, "valid")
def stepTestPackingListDeliveredSimulationState(self, sequence=None, sequence_list=None, **kw):
pl = sequence.get('packing_list')
if pl is None: pl = sequence.get('packing_list_list', [])[-1]
self.stepTestPackingListSimulationState(pl, "delivered")
def stepTestPackingListCalculatingImmobilisationState(self, sequence=None, sequence_list=None, **kw): def stepTestPackingListCalculatingImmobilisationState(self, sequence=None, sequence_list=None, **kw):
pl = sequence.get('packing_list') pl = sequence.get('packing_list')
if pl is None: pl = sequence.get('packing_list_list', [])[-1] if pl is None: pl = sequence.get('packing_list_list', [])[-1]
...@@ -381,6 +607,11 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -381,6 +607,11 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
def stepTestPackingListImmobilisationState(self, pl, state, **kw): def stepTestPackingListImmobilisationState(self, pl, state, **kw):
self.assertEquals(pl.getImmobilisationState(), state) self.assertEquals(pl.getImmobilisationState(), state)
def stepTestPackingListSimulationState(self, pl, state, **kw):
self.assertEquals(pl.getSimulationState(), state)
def stepTestPackingListValidationState(self, pl, state, **kw):
self.assertEquals(pl.getValidationState(), state)
def stepCreatePackingListsForContinuousAmortisationPeriodList(self, sequence=None, sequence_list=None, **kw): def stepCreatePackingListsForContinuousAmortisationPeriodList(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -392,6 +623,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -392,6 +623,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
2002/10/01 : owner set to None 2002/10/01 : owner set to None
2003/01/01 : immobilisation with no values (4) 2003/01/01 : immobilisation with no values (4)
""" """
item = sequence.get('item') item = sequence.get('item')
amortisation_method = sequence.get('amortisation_method') amortisation_method = sequence.get('amortisation_method')
parameter_dict = sequence.get('parameter_dict', {}) parameter_dict = sequence.get('parameter_dict', {})
...@@ -408,6 +640,8 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -408,6 +640,8 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
destination_section = self.getOrganisationModule()["A"]) destination_section = self.getOrganisationModule()["A"])
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
#1
parameter_dict.update( {'amortisation_start_price':12000, parameter_dict.update( {'amortisation_start_price':12000,
'disposal_price':0, 'disposal_price':0,
'amortisation_duration':48, 'amortisation_duration':48,
...@@ -416,26 +650,38 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -416,26 +650,38 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
parameter_dict = parameter_dict) parameter_dict = parameter_dict)
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
#2
for parameter in ('amortisation_start_price', 'disposal_price', 'amortisation_duration', 'immobilisation_vat'): for parameter in ('amortisation_start_price', 'disposal_price', 'amortisation_duration', 'immobilisation_vat'):
del parameter_dict[parameter] del parameter_dict[parameter]
sequence.edit(datetime = DateTime('2002/01/01'), sequence.edit(datetime = DateTime('2002/01/01'),
parameter_dict = parameter_dict) parameter_dict = parameter_dict)
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
#3
sequence.edit(datetime = DateTime('2003/01/01')) sequence.edit(datetime = DateTime('2003/01/01'))
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
#4
# Create owner changing movements # Create owner changing movements
sequence.edit(datetime = DateTime('2002/07/01'), sequence.edit(datetime = DateTime('2002/07/01'),
destination_section=self.getOrganisationModule()["B"], destination_section=self.getOrganisationModule()["B"],
parameter_dict=None) parameter_dict=None)
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
#5
sequence.edit(datetime = DateTime('2002/10/01'),destination_section=None) sequence.edit(datetime = DateTime('2002/10/01'),destination_section=None)
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
#6
#sequence.edit(datetime = DateTime('2003/01/01'))
#self.stepCreatePackingList(sequence=sequence)
#self.stepAggregateItems(sequence=sequence)
#self.stepDeliverPackingList(sequence=sequence)
def stepCreatePackingListsForUncontinuousAmortisationPeriodList(self, sequence=None, sequence_list=None, **kw): def stepCreatePackingListsForUncontinuousAmortisationPeriodList(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -463,6 +709,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -463,6 +709,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
destination_section = self.getOrganisationModule()["A"]) destination_section = self.getOrganisationModule()["A"])
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
parameter_dict.update( {'amortisation_method':UNIMMOBILISING_METHOD, parameter_dict.update( {'amortisation_method':UNIMMOBILISING_METHOD,
'amortisation_start_price':12000, 'amortisation_start_price':12000,
'amortisation_start_price':0, 'amortisation_start_price':0,
...@@ -474,10 +721,12 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -474,10 +721,12 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
parameter_dict = parameter_dict) parameter_dict = parameter_dict)
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
sequence.edit(datetime = DateTime('2001/07/01'), sequence.edit(datetime = DateTime('2001/07/01'),
parameter_dict = parameter_dict) parameter_dict = parameter_dict)
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
parameter_dict.update( {'amortisation_method':amortisation_method, parameter_dict.update( {'amortisation_method':amortisation_method,
'amortisation_start_price':10000, 'amortisation_start_price':10000,
'disposal_price':0, 'disposal_price':0,
...@@ -489,6 +738,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -489,6 +738,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
destination_section = self.getOrganisationModule()["B"]) destination_section = self.getOrganisationModule()["B"])
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
# Create owner changing movements # Create owner changing movements
sequence.edit(datetime = DateTime('2002/01/01'), sequence.edit(datetime = DateTime('2002/01/01'),
...@@ -496,10 +746,12 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -496,10 +746,12 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
destination_section=self.getOrganisationModule()["B"]) destination_section=self.getOrganisationModule()["B"])
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
sequence.edit(datetime = DateTime('2004/01/01'), sequence.edit(datetime = DateTime('2004/01/01'),
destination_section=self.getOrganisationModule()["A"]) destination_section=self.getOrganisationModule()["A"])
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
def stepCreatePackingListsForSimpleItemImmobilisation(self, sequence=None, sequence_list=None, **kw): def stepCreatePackingListsForSimpleItemImmobilisation(self, sequence=None, sequence_list=None, **kw):
...@@ -524,6 +776,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -524,6 +776,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
destination_section = self.getOrganisationModule()["A"]) destination_section = self.getOrganisationModule()["A"])
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
parameter_dict.update( {'amortisation_start_price':12000, parameter_dict.update( {'amortisation_start_price':12000,
'amortisation_duration':84, 'amortisation_duration':84,
'immobilisation_vat':0, 'immobilisation_vat':0,
...@@ -533,6 +786,33 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -533,6 +786,33 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
parameter_dict = parameter_dict) parameter_dict = parameter_dict)
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
"""
09BIS
"""
def stepCreatePackingListsForSimpleItemImmobilisationBIS(self, sequence=None, sequence_list=None, **kw):
"""
Create a list of packing lists describing a continuous period list :
2000/01/01 : immobilisation (1)
"""
item = sequence.get('item')
amortisation_method = sequence.get('amortisation_method')
parameter_dict = sequence.get('parameter_dict', {})
parameter_dict.update(self.account_dict)
parameter_dict.update( {'amortisation_method':amortisation_method,
'amortisation_start_price':10000,
'disposal_price':0,
'amortisation_duration':48,
'immobilisation_vat':0,
} )
sequence.edit(item_list_list = [[item]],
datetime = DateTime('2000/07/01'),
parameter_dict = parameter_dict,
destination_section = self.getOrganisationModule()["orga"])
self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
def stepCreatePackingListsForSimulationTest(self, sequence=None, sequence_list=None, **kw): def stepCreatePackingListsForSimulationTest(self, sequence=None, sequence_list=None, **kw):
...@@ -559,6 +839,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -559,6 +839,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
destination_section = self.getOrganisationModule()["Aa1"]) destination_section = self.getOrganisationModule()["Aa1"])
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
parameter_dict.update( {'amortisation_start_price':12000, parameter_dict.update( {'amortisation_start_price':12000,
'amortisation_duration':36, 'amortisation_duration':36,
'immobilisation_vat':0, 'immobilisation_vat':0,
...@@ -572,6 +853,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -572,6 +853,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
destination_section = self.getOrganisationModule()["Aa2"]) destination_section = self.getOrganisationModule()["Aa2"])
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
def stepCreatePackingListsForNoChangeMethodSimulationTest(self, sequence=None, sequence_list=None, **kw): def stepCreatePackingListsForNoChangeMethodSimulationTest(self, sequence=None, sequence_list=None, **kw):
...@@ -598,6 +880,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -598,6 +880,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
destination_section = self.getOrganisationModule()["Aa1"]) destination_section = self.getOrganisationModule()["Aa1"])
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
for property in ('amortisation_start_price','amortisation_duration','immobilisation_vat', for property in ('amortisation_start_price','amortisation_duration','immobilisation_vat',
'extra_cost_price','disposal_price'): 'extra_cost_price','disposal_price'):
del parameter_dict[property] del parameter_dict[property]
...@@ -607,6 +890,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -607,6 +890,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
destination_section = self.getOrganisationModule()["Aa2"]) destination_section = self.getOrganisationModule()["Aa2"])
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
def stepChangeCurrentPackingListDestinationSectionForOwnerChange(self, sequence=None, sequence_list=None, **kw): def stepChangeCurrentPackingListDestinationSectionForOwnerChange(self, sequence=None, sequence_list=None, **kw):
...@@ -627,7 +911,9 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -627,7 +911,9 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
pl.edit(destination_section_value = self.getOrganisationModule()['Ba']) pl.edit(destination_section_value = self.getOrganisationModule()['Ba'])
pl.contentValues()[0].edit(**self.account_dict) pl.contentValues()[0].edit(**self.account_dict)
"""
TEST 17
"""
def stepCreatePackingListsForMonthlyAmortisationTest(self, sequence=None, sequence_list=None, **kw): def stepCreatePackingListsForMonthlyAmortisationTest(self, sequence=None, sequence_list=None, **kw):
""" """
Create a list of packing lists describing a continuous period list : Create a list of packing lists describing a continuous period list :
...@@ -655,6 +941,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -655,6 +941,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
destination_section = self.getOrganisationModule()["Aa1"]) destination_section = self.getOrganisationModule()["Aa1"])
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
for property in ('amortisation_start_price','amortisation_duration','immobilisation_vat', for property in ('amortisation_start_price','amortisation_duration','immobilisation_vat',
'extra_cost_price','disposal_price'): 'extra_cost_price','disposal_price'):
del parameter_dict[property] del parameter_dict[property]
...@@ -666,21 +953,25 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -666,21 +953,25 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
destination_section = self.getOrganisationModule()["Aa2"]) destination_section = self.getOrganisationModule()["Aa2"])
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
parameter_dict.update(self.monthly_dict) parameter_dict.update(self.monthly_dict)
sequence.edit(datetime = DateTime('2002/04/16'), sequence.edit(datetime = DateTime('2002/04/16'),
parameter_dict = parameter_dict) parameter_dict = parameter_dict)
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
sequence.edit(datetime = DateTime('2002/05/16'), sequence.edit(datetime = DateTime('2002/05/16'),
parameter_dict = parameter_dict, parameter_dict = parameter_dict,
destination_section = self.getOrganisationModule()["Ab1"]) destination_section = self.getOrganisationModule()["Ab1"])
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
sequence.edit(datetime = DateTime('2002/06/16'), sequence.edit(datetime = DateTime('2002/06/16'),
parameter_dict = parameter_dict, parameter_dict = parameter_dict,
destination_section = self.getOrganisationModule()["Ba"]) destination_section = self.getOrganisationModule()["Ba"])
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence)
def stepBuildAccounting(self, sequence=None, sequence_list=None, **kw): def stepBuildAccounting(self, sequence=None, sequence_list=None, **kw):
...@@ -695,6 +986,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -695,6 +986,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
""" """
if build_parameter_dict is None: if build_parameter_dict is None:
build_parameter_dict = sequence.get('build_parameter_dict',{}) build_parameter_dict = sequence.get('build_parameter_dict',{})
LOG('build_parameter_dict for PartialBuildAccounting', 0, build_parameter_dict)
self.getPortal().AccountingTransactionModule_activateBuildAmortisationTransaction(**build_parameter_dict) self.getPortal().AccountingTransactionModule_activateBuildAmortisationTransaction(**build_parameter_dict)
def stepAdoptPrevision(self,sequence=None, sequence_list=None, **kw): def stepAdoptPrevision(self,sequence=None, sequence_list=None, **kw):
...@@ -713,7 +1005,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -713,7 +1005,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
Launch accept_decision() on each Amortisation Transaction Launch accept_decision() on each Amortisation Transaction
""" """
for transaction in self.getAccountingModule().contentValues(): for transaction in self.getAccountingModule().contentValues():
LOG('transaction %s causality state :' % transaction, 0, transaction.getCausalityState()) #LOG('transaction %s causality state :' % transaction, 0, transaction.getCausalityState())
try: try:
self.getPortal().portal_workflow.doActionFor(transaction, self.getPortal().portal_workflow.doActionFor(transaction,
'accept_decision_action', 'accept_decision_action',
...@@ -741,9 +1033,8 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -741,9 +1033,8 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
Test if all applied rules are empty Test if all applied rules are empty
""" """
for item in self.getItemModule().contentValues(): for item in self.getItemModule().contentValues():
applied_rule = item.getCausalityRelatedValueList(portal_type = 'Applied Rule') applied_rule_list = item.getCausalityRelatedValueList()
if len(applied_rule) > 0: for applied_rule in applied_rule_list:
applied_rule = applied_rule[0]
LOG('testing if applied rule is empty for item', 0, item) LOG('testing if applied rule is empty for item', 0, item)
self.assertEquals(len(applied_rule.contentValues()), 0) self.assertEquals(len(applied_rule.contentValues()), 0)
...@@ -816,6 +1107,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -816,6 +1107,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
""" """
item = sequence.get('item') item = sequence.get('item')
c_period_list = item.getImmobilisationPeriodList() c_period_list = item.getImmobilisationPeriodList()
e_period_list = [ { 'start_date':DateTime('2000/01/01'), 'stop_date':DateTime('2001/01/01'), e_period_list = [ { 'start_date':DateTime('2000/01/01'), 'stop_date':DateTime('2001/01/01'),
'initial_date':DateTime('2000/01/01'), 'initial_date':DateTime('2000/01/01'),
'start_price':10000, 'owner':self.getOrganisationModule()["A"], 'start_price':10000, 'owner':self.getOrganisationModule()["A"],
...@@ -867,16 +1159,19 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -867,16 +1159,19 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
def _testImmobilisationPeriods(self,c_period_list,e_period_list): def _testImmobilisationPeriods(self,c_period_list,e_period_list):
#LOG('c_period_list :', 0, c_period_list)
e_period_cursor = 0 e_period_cursor = 0
for c_period in c_period_list: for c_period in c_period_list:
#LOG('c_period :', 0, c_period)
if e_period_cursor >= len(e_period_list): if e_period_cursor >= len(e_period_list):
LOG('More calculated periods than expected !', 0, '') LOG('More calculated periods than expected !', 0, '')
self.assertEquals(len(c_period_list), len(e_period_list)) self.assertEquals(len(c_period_list), len(e_period_list))
e_period = e_period_list[e_period_cursor] e_period = e_period_list[e_period_cursor]
#LOG('e_period :', 0, e_period)
e_period_cursor += 1 e_period_cursor += 1
for key in e_period.keys(): for key in e_period.keys():
e_value = e_period[key] e_value = e_period[key]
LOG('testing c_period %s "%s" value' % (e_period_cursor-1, key), 0, '') #LOG('testing c_period %s "%s" value' % (e_period_cursor-1, key), 0, '')
self.failUnless(c_period.has_key(key)) self.failUnless(c_period.has_key(key))
c_value = c_period[key] c_value = c_period[key]
is_float = 0 is_float = 0
...@@ -913,8 +1208,33 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -913,8 +1208,33 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
] ]
for date, e_price in price_list: for date, e_price in price_list:
c_price = item.getAmortisationPrice(at_date=date) c_price = item.getAmortisationPrice(at_date=date)
#LOG('testing amortisation price at date', 0, date)
#LOG('c_price',0,c_price)
self.assertEquals(round(c_price,2), e_price) self.assertEquals(round(c_price,2), e_price)
"""
09BIS
"""
def stepTestLinearAmortisationPriceCalculationBIS(self, sequence=None, sequence_list=None, **kw):
"""
Test calculated prices
"""
item = sequence.get('item')
price_list = [
(DateTime('2001/01/01'), 8750.00),
(DateTime('2002/01/01'), 6250.00),
(DateTime('2003/01/01'), 3750.00),
(DateTime('2003/12/31'), 1250.00),
(DateTime('2004/01/01'), 1243.17),
(DateTime('2005/01/01'), 0),
(DateTime('2006/01/01'), 0),
(DateTime('2020/01/01'), 0),
]
for date, e_price in price_list:
c_price = item.getAmortisationPrice(at_date=date)
#LOG('testing amortisation price at date', 0, date)
#LOG('c_price',0,c_price)
self.assertEquals(round(c_price,2), e_price)
def stepTestDegressiveAmortisationPriceCalculation(self, sequence=None, sequence_list=None, **kw): def stepTestDegressiveAmortisationPriceCalculation(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -934,6 +1254,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -934,6 +1254,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
] ]
for date, e_price in price_list: for date, e_price in price_list:
c_price = item.getAmortisationPrice(at_date=date) c_price = item.getAmortisationPrice(at_date=date)
#LOG('testing amortisation price at date', 0, date)
self.assertEquals(round(c_price,2), e_price) self.assertEquals(round(c_price,2), e_price)
...@@ -955,6 +1276,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -955,6 +1276,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
] ]
for date, e_price in price_list: for date, e_price in price_list:
c_price = item.getAmortisationPrice(at_date=date) c_price = item.getAmortisationPrice(at_date=date)
#LOG('testing amortisation price at date', 0, date)
self.assertEquals(round(c_price,2), e_price) self.assertEquals(round(c_price,2), e_price)
...@@ -977,6 +1299,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -977,6 +1299,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
] ]
for date, e_price in price_list: for date, e_price in price_list:
c_price = item.getAmortisationPrice(at_date=date) c_price = item.getAmortisationPrice(at_date=date)
#LOG('testing amortisation price at date', 0, date)
self.assertEquals(round(c_price,2), e_price) self.assertEquals(round(c_price,2), e_price)
...@@ -998,12 +1321,14 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -998,12 +1321,14 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
] ]
for date, e_price in price_list: for date, e_price in price_list:
c_price = item.getAmortisationPrice(at_date=date) c_price = item.getAmortisationPrice(at_date=date)
#LOG('testing amortisation price at date', 0, date)
self.assertEquals(round(c_price,2), e_price) self.assertEquals(round(c_price,2), e_price)
def _createExpectedMovement(self, date, quantity, source=None, destination=None, def _createExpectedMovement(self, date, quantity, source=None, destination=None,
source_section=None, destination_section=None): source_section=None, destination_section=None):
r_dict = {'start_date':DateTime(date), 'stop_date':DateTime(date), self.id_simulation+=1
r_dict = {'id':self.id_simulation,'start_date':DateTime(date), 'stop_date':DateTime(date),
'quantity':quantity, 'resource':'currency_module/EUR'} 'quantity':quantity, 'resource':'currency_module/EUR'}
my_account_dict = dict(self.account_dict) my_account_dict = dict(self.account_dict)
my_account_dict.update(self.monthly_dict) my_account_dict.update(self.monthly_dict)
...@@ -1026,6 +1351,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1026,6 +1351,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
def stepTestLinearAmortisationSimulationBuild(self, sequence=None, sequence_list=None, **kw): def stepTestLinearAmortisationSimulationBuild(self, sequence=None, sequence_list=None, **kw):
""" """
Test 09
Test built simulation for linear amortisation Test built simulation for linear amortisation
""" """
item = sequence.get('item') item = sequence.get('item')
...@@ -1066,12 +1392,55 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1066,12 +1392,55 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
'2006/01/01', -1666.67, 'depreciation_account', None, 'A', None)) '2006/01/01', -1666.67, 'depreciation_account', None, 'A', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
self._testSimulationBuild(c_simulation_movement_list, e_simulation_movement_list) self._testSimulationBuild(c_simulation_movement_list, e_simulation_movement_list)
"""
09BIS
"""
def stepTestLinearAmortisationSimulationBuildBIS(self, sequence=None, sequence_list=None, **kw):
"""
Test built simulation for linear amortisation
"""
item = sequence.get('item')
e_simulation_movement_list = []
# Immobilisation
e_simulation_movement_list.append(self._createExpectedMovement(
'2000/07/01', 10000, 'input_account', None, 'orga', None))
e_simulation_movement_list.append(self._createExpectedMovement(
'2000/07/01', -10000, 'immobilisation_account', None, 'orga', None))
# Annuities
e_simulation_movement_list.append(self._createExpectedMovement(
'2000/12/31', 1250.00, 'amortisation_account', None, 'orga', None))
e_simulation_movement_list.append(self._createExpectedMovement(
'2000/12/31', -1250.00, 'depreciation_account', None, 'orga', None))
e_simulation_movement_list.append(self._createExpectedMovement(
'2001/12/31', 2500.00, 'amortisation_account', None, 'orga', None))
e_simulation_movement_list.append(self._createExpectedMovement(
'2001/12/31', -2500.00, 'depreciation_account', None, 'orga', None))
e_simulation_movement_list.append(self._createExpectedMovement(
'2002/12/31', 2500.00, 'amortisation_account', None, 'orga', None))
e_simulation_movement_list.append(self._createExpectedMovement(
'2002/12/31', -2500.00, 'depreciation_account', None, 'orga', None))
e_simulation_movement_list.append(self._createExpectedMovement(
'2003/12/31', 2500.00, 'amortisation_account', None, 'orga', None))
e_simulation_movement_list.append(self._createExpectedMovement(
'2003/12/31', -2500.00, 'depreciation_account', None, 'orga', None))
e_simulation_movement_list.append(self._createExpectedMovement(
'2004/12/31', 1250.00, 'amortisation_account', None, 'orga', None))
e_simulation_movement_list.append(self._createExpectedMovement(
'2004/12/31', -1250.00, 'depreciation_account', None, 'orga', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
#LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues()
self._testSimulationBuild(c_simulation_movement_list, e_simulation_movement_list)
def stepTestUncontinuousDegressiveAmortisationSimulationBuild(self, sequence=None, sequence_list=None, **kw): def stepTestUncontinuousDegressiveAmortisationSimulationBuild(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -1144,7 +1513,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1144,7 +1513,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
'2010/01/01', -841.74, 'depreciation_account', None, 'A', None)) '2010/01/01', -841.74, 'depreciation_account', None, 'A', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
...@@ -1176,7 +1545,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1176,7 +1545,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
# No annuity # No annuity
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
...@@ -1221,7 +1590,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1221,7 +1590,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
'2003/01/01', -3333.33, 'depreciation_account_extra', None, 'Aa', None)) '2003/01/01', -3333.33, 'depreciation_account_extra', None, 'Aa', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
...@@ -1264,7 +1633,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1264,7 +1633,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
'2003/01/01', -3333.33, 'depreciation_account', None, 'Ab', None)) '2003/01/01', -3333.33, 'depreciation_account', None, 'Ab', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
...@@ -1314,7 +1683,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1314,7 +1683,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
'2003/01/01', -3333.33, 'depreciation_account', None, 'Ba', None)) '2003/01/01', -3333.33, 'depreciation_account', None, 'Ba', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
...@@ -1368,7 +1737,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1368,7 +1737,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
'2004/01/01', -1333.33, 'depreciation_account_extra', None, 'Aa', None)) '2004/01/01', -1333.33, 'depreciation_account_extra', None, 'Aa', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
...@@ -1422,7 +1791,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1422,7 +1791,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
'2004/01/01', -1333.33, 'depreciation_account', None, 'Ab', None)) '2004/01/01', -1333.33, 'depreciation_account', None, 'Ab', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
...@@ -1476,7 +1845,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1476,7 +1845,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
'2004/01/01', -1333.33, 'depreciation_account', None, 'Ba', None)) '2004/01/01', -1333.33, 'depreciation_account', None, 'Ba', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
...@@ -1513,7 +1882,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1513,7 +1882,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
'2003/01/01', -3333.33, 'depreciation_account', None, 'Aa', None)) '2003/01/01', -3333.33, 'depreciation_account', None, 'Aa', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
...@@ -1556,7 +1925,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1556,7 +1925,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
'2003/01/01', -3333.33, 'depreciation_account', None, 'Ab', None)) '2003/01/01', -3333.33, 'depreciation_account', None, 'Ab', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
...@@ -1606,13 +1975,15 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1606,13 +1975,15 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
'2003/01/01', -3333.33, 'depreciation_account', None, 'Ba', None)) '2003/01/01', -3333.33, 'depreciation_account', None, 'Ba', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
self._testSimulationBuild(c_simulation_movement_list, e_simulation_movement_list) self._testSimulationBuild(c_simulation_movement_list, e_simulation_movement_list)
"""
TEST 17
"""
def stepTestSimulationBuildForMonthlyAmortisation(self, sequence=None, sequence_list=None, **kw): def stepTestSimulationBuildForMonthlyAmortisation(self, sequence=None, sequence_list=None, **kw):
""" """
Test built simulation for a linear amortisation method with a monthly amortisation Test built simulation for a linear amortisation method with a monthly amortisation
...@@ -1736,7 +2107,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1736,7 +2107,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
'2003/01/01', -1805.56, 'depreciation_account', None, 'Ba', None)) '2003/01/01', -1805.56, 'depreciation_account', None, 'Ba', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
...@@ -1745,20 +2116,22 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1745,20 +2116,22 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
def _testSimulationBuild(self, c_simulation_movement_list, e_simulation_movement_list): def _testSimulationBuild(self, c_simulation_movement_list, e_simulation_movement_list):
for c_movement in c_simulation_movement_list: for c_movement in c_simulation_movement_list:
# LOG('c_movement %s :' % c_movement, 0, LOG('c_movement %s :' % c_movement, 0,
# 'date=%s, source=%s, source_section=%s, destination=%s, destination_section=%s, quantity=%s, resource=%s, profit_quantity=%s' % ( 'date=%s\n, source=%s\n, source_section=%s\n, destination=%s\n, destination_section=%s\n, quantity=%s\n, resource=%s\n, profit_quantity=%s\n' % (
# (c_movement.getStopDate(), c_movement.getSource(), c_movement.getSourceSection(), (c_movement.getStopDate(), c_movement.getSource(), c_movement.getSourceSection(),
# c_movement.getDestination(), c_movement.getDestinationSection(), c_movement.getQuantity(), c_movement.getDestination(), c_movement.getDestinationSection(), c_movement.getQuantity(),
# c_movement.getResource(), c_movement.getProfitQuantity()) c_movement.getResource(), c_movement.getProfitQuantity())
# ) )
# ) )
e_found_movement = None e_found_movement = None
e_cursor = 0 e_cursor = 0
LOG('len e_simulation_movement_list start',0,len(e_simulation_movement_list))
while e_cursor < len(e_simulation_movement_list) and e_found_movement is None: while e_cursor < len(e_simulation_movement_list) and e_found_movement is None:
e_movement = e_simulation_movement_list[e_cursor] e_movement = e_simulation_movement_list[e_cursor]
wrong_movement = 0 wrong_movement = 0
key_cursor = 0 key_cursor = 0
key_list = e_movement.keys() key_list = e_movement.keys()
key_list.remove('id')
while key_cursor < len(key_list) and not wrong_movement: while key_cursor < len(key_list) and not wrong_movement:
key = key_list[key_cursor] key = key_list[key_cursor]
e_value = e_movement[key] e_value = e_movement[key]
...@@ -1776,20 +2149,23 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1776,20 +2149,23 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
else: else:
wrong_movement = (c_value != e_value) wrong_movement = (c_value != e_value)
key_cursor += 1 key_cursor += 1
LOG('_testSimulationBuild',0,'key:%s, c_value:%s e_value:%s ' % (key, c_value,e_value))
if not wrong_movement: if not wrong_movement:
e_found_movement = e_movement e_found_movement = e_movement
e_cursor += 1 e_cursor += 1
#LOG('_testSimulationBuild',0,'wrong movement %s' % wrong_movement)
if e_found_movement is None: if e_found_movement is None:
LOG('No expected movement found for this calculated one !',0,'') LOG('No expected movement found for this calculated one !',0,c_movement.getRelativeUrl())
LOG('len e_simulation_movement_list after fail',0,len(e_simulation_movement_list))
self.failUnless(e_found_movement is not None) self.failUnless(e_found_movement is not None)
e_simulation_movement_list.remove(e_found_movement) e_simulation_movement_list.remove(e_found_movement)
if len(e_simulation_movement_list) > 0: if len(e_simulation_movement_list) > 0:
LOG('More expected movements than calculated ! Remaining expected ones are', 0, e_simulation_movement_list) LOG('More expected movements than calculated ! Remaining expected ones are', 0, e_simulation_movement_list)
self.assertEquals(len(e_simulation_movement_list),0) self.assertEquals(len(e_simulation_movement_list),0)
def _buildExpectedTransaction(self, date, source_section, destination_section, causality_state, causality_list=[]): def _buildExpectedTransaction(self, date, source_section, destination_section, causality_state, causality_list=[]):
r_dict = {'start_date':DateTime(date), 'stop_date':DateTime(date), self.id_transaction+=1
r_dict = {'id':self.id_transaction,'start_date':DateTime(date), 'stop_date':DateTime(date),
'resource':'currency_module/EUR', 'line_list':[], 'resource':'currency_module/EUR', 'line_list':[],
'causality_state':causality_state} 'causality_state':causality_state}
for name, prop in (('source_section_value', source_section), ('destination_section_value', destination_section)): for name, prop in (('source_section_value', source_section), ('destination_section_value', destination_section)):
...@@ -1804,7 +2180,6 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1804,7 +2180,6 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
r_dict['causality_value_list'] = causality_value_list r_dict['causality_value_list'] = causality_value_list
return r_dict return r_dict
def _buildExpectedTransactionLine(self, source, destination, quantity): def _buildExpectedTransactionLine(self, source, destination, quantity):
r_dict = {'quantity':quantity} r_dict = {'quantity':quantity}
my_account_dict = dict(self.account_dict) my_account_dict = dict(self.account_dict)
...@@ -1820,7 +2195,6 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1820,7 +2195,6 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
r_dict[name] = my_account_dict[prop] r_dict[name] = my_account_dict[prop]
return r_dict return r_dict
def stepTestPartialAccountingBuild(self, sequence=None, sequence_list=None, **kw): def stepTestPartialAccountingBuild(self, sequence=None, sequence_list=None, **kw):
""" """
Test partial accounting build, based on a single movement of 10000 for a 4 year linear amortisation Test partial accounting build, based on a single movement of 10000 for a 4 year linear amortisation
...@@ -1842,7 +2216,6 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1842,7 +2216,6 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
c_transaction_list = self.getPortal().portal_catalog(portal_type='Amortisation Transaction') c_transaction_list = self.getPortal().portal_catalog(portal_type='Amortisation Transaction')
c_transaction_list = [o.getObject() for o in c_transaction_list] c_transaction_list = [o.getObject() for o in c_transaction_list]
c_transaction_list.sort(lambda a,b: cmp(a.getStopDate(),b.getStopDate()))
self._testAccountingBuild(c_transaction_list, e_transaction_list) self._testAccountingBuild(c_transaction_list, e_transaction_list)
...@@ -1908,7 +2281,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1908,7 +2281,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
c_transaction_list = self.getPortal().portal_catalog(portal_type='Amortisation Transaction') c_transaction_list = self.getPortal().portal_catalog(portal_type='Amortisation Transaction')
c_transaction_list = [o.getObject() for o in c_transaction_list] c_transaction_list = [o.getObject() for o in c_transaction_list]
c_transaction_list.sort(lambda a,b: cmp(a.getStopDate(),b.getStopDate())) #c_transaction_list.sort(lambda a,b: cmp(a.getStopDate(),b.getStopDate()))
self._testAccountingBuild(c_transaction_list, e_transaction_list) self._testAccountingBuild(c_transaction_list, e_transaction_list)
...@@ -1966,7 +2339,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -1966,7 +2339,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
'2004/01/01', -2500, 'depreciation_account', None, 'B', None)) '2004/01/01', -2500, 'depreciation_account', None, 'B', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
...@@ -2028,7 +2401,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2028,7 +2401,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
'2004/01/01', -0, 'depreciation_account', None, 'B', None)) '2004/01/01', -0, 'depreciation_account', None, 'B', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
...@@ -2093,7 +2466,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2093,7 +2466,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
...@@ -2151,7 +2524,6 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2151,7 +2524,6 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
c_transaction_list = self.getPortal().portal_catalog(portal_type='Amortisation Transaction') c_transaction_list = self.getPortal().portal_catalog(portal_type='Amortisation Transaction')
c_transaction_list = [o.getObject() for o in c_transaction_list] c_transaction_list = [o.getObject() for o in c_transaction_list]
c_transaction_list.sort(lambda a,b: cmp(a.getStopDate(),b.getStopDate()))
self._testAccountingBuild(c_transaction_list, e_transaction_list) self._testAccountingBuild(c_transaction_list, e_transaction_list)
...@@ -2207,7 +2579,6 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2207,7 +2579,6 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
c_transaction_list = self.getPortal().portal_catalog(portal_type='Amortisation Transaction') c_transaction_list = self.getPortal().portal_catalog(portal_type='Amortisation Transaction')
c_transaction_list = [o.getObject() for o in c_transaction_list] c_transaction_list = [o.getObject() for o in c_transaction_list]
c_transaction_list.sort(lambda a,b: cmp(a.getStopDate(),b.getStopDate()))
self._testAccountingBuild(c_transaction_list, e_transaction_list) self._testAccountingBuild(c_transaction_list, e_transaction_list)
...@@ -2272,7 +2643,6 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2272,7 +2643,6 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
c_transaction_list = self.getPortal().portal_catalog(portal_type='Amortisation Transaction') c_transaction_list = self.getPortal().portal_catalog(portal_type='Amortisation Transaction')
c_transaction_list = [o.getObject() for o in c_transaction_list] c_transaction_list = [o.getObject() for o in c_transaction_list]
c_transaction_list.sort(lambda a,b: cmp(a.getStopDate(),b.getStopDate()))
self._testAccountingBuild(c_transaction_list, e_transaction_list) self._testAccountingBuild(c_transaction_list, e_transaction_list)
...@@ -2342,10 +2712,8 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2342,10 +2712,8 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
c_transaction_list = self.getPortal().portal_catalog(portal_type='Amortisation Transaction') c_transaction_list = self.getPortal().portal_catalog(portal_type='Amortisation Transaction')
c_transaction_list = [o.getObject() for o in c_transaction_list] c_transaction_list = [o.getObject() for o in c_transaction_list]
c_transaction_list.sort(lambda a,b: cmp(a.getStopDate(),b.getStopDate()))
self._testAccountingBuild(c_transaction_list, e_transaction_list) self._testAccountingBuild(c_transaction_list, e_transaction_list)
def stepTestSimulationBuildAfterAcceptDecision(self, sequence=None, sequence_list=None, **kw): def stepTestSimulationBuildAfterAcceptDecision(self, sequence=None, sequence_list=None, **kw):
item = sequence.get('item') item = sequence.get('item')
e_simulation_movement_list = [] e_simulation_movement_list = []
...@@ -2375,7 +2743,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2375,7 +2743,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
'2004/01/01', -2500, 'depreciation_account', None, 'A', None)) '2004/01/01', -2500, 'depreciation_account', None, 'A', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
...@@ -2426,7 +2794,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2426,7 +2794,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
'2004/01/01', 2500, 'depreciation_account', None, 'A', None)) '2004/01/01', 2500, 'depreciation_account', None, 'A', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
...@@ -2477,7 +2845,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2477,7 +2845,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
'2004/01/01', 2500, 'depreciation_account', None, 'A', None)) '2004/01/01', 2500, 'depreciation_account', None, 'A', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
...@@ -2564,7 +2932,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2564,7 +2932,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
...@@ -2572,14 +2940,16 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2572,14 +2940,16 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
def _testAccountingBuild(self, c_transaction_list, e_transaction_list): def _testAccountingBuild(self, c_transaction_list, e_transaction_list):
#self.assertEquals(len(c_transaction_list),len(e_transaction_list))
e_removed_list = []
for c_transaction in c_transaction_list: for c_transaction in c_transaction_list:
# LOG('c_transaction %s :' % c_transaction, 0, LOG('c_transaction %s :' % c_transaction, 0,
# 'date=%s, source_section=%s, destination_section=%s, resource=%s, state=%s, causality_list=%s' % ( 'date=%s\n, source_section=%s\n, destination_section=%s\n, resource=%s\n, state=%s\n, causality_list=%s\n' % (
# (c_transaction.getStopDate(), c_transaction.getSourceSection(), (c_transaction.getStopDate(), c_transaction.getSourceSection(),
# c_transaction.getDestinationSection(), c_transaction.getResource(), c_transaction.getCausalityState(), c_transaction.getDestinationSection(), c_transaction.getResource(), c_transaction.getCausalityState(),
# c_transaction.getCausalityList()) c_transaction.getCausalityList())
# ) )
# ) )
e_found_transaction = None e_found_transaction = None
e_cursor = 0 e_cursor = 0
while e_cursor < len(e_transaction_list) and e_found_transaction is None: while e_cursor < len(e_transaction_list) and e_found_transaction is None:
...@@ -2589,11 +2959,16 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2589,11 +2959,16 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
key_list = e_transaction.keys() key_list = e_transaction.keys()
if 'line_list' in key_list: if 'line_list' in key_list:
key_list.remove('line_list') key_list.remove('line_list')
if 'id' in key_list:
key_list.remove('id')
while key_cursor < len(key_list) and not wrong_transaction: while key_cursor < len(key_list) and not wrong_transaction:
key = key_list[key_cursor] key = key_list[key_cursor]
#LOG('key : ',0,key)
e_value = e_transaction[key] e_value = e_transaction[key]
#LOG('e_value : ',0,e_value)
key = 'get' + ''.join([k.capitalize() for k in key.split('_')]) key = 'get' + ''.join([k.capitalize() for k in key.split('_')])
c_value = getattr(c_transaction,key)() c_value = getattr(c_transaction,key)()
#LOG('c_value : ',0,c_value)
is_float = 0 is_float = 0
try: try:
if type(c_value) != type(DateTime()): if type(c_value) != type(DateTime()):
...@@ -2610,22 +2985,25 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2610,22 +2985,25 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
else: else:
wrong_transaction = (c_value != e_value) wrong_transaction = (c_value != e_value)
key_cursor += 1 key_cursor += 1
#LOG('wrong_transaction',0,wrong_transaction)
if not wrong_transaction: if not wrong_transaction:
e_found_transaction = e_transaction e_found_transaction = e_transaction
else:
LOG('',0,'key:%s\ncalculated:%s\n expected:%s' % (key,c_value,e_value))
e_cursor += 1 e_cursor += 1
if e_found_transaction is None: if e_found_transaction is None:
LOG('No expected transaction found for this calculated one !',0,'') LOG('No expected transaction found for this calculated one !',0,'')
self.failUnless(e_found_transaction is not None) self.failUnless(e_found_transaction is not None)
e_transaction_list.remove(e_transaction) #e_transaction_list.remove(e_transaction)
e_removed_list.append(e_transaction_list.pop(e_transaction_list.index(e_transaction)))
e_line_list = e_transaction['line_list'] e_line_list = e_transaction['line_list']
c_line_list = c_transaction.contentValues() c_line_list = c_transaction.contentValues()
for c_line in c_line_list: for c_line in c_line_list:
# LOG('c_line %s :' % c_line, 0, LOG('c_line %s :' % c_line, 0,
# 'source=%s,destination=%s,quantity=%s' % ( 'source=%s\n,destination=%s\n,quantity=%s\n' % (
# (c_line.getSource(),c_line.getDestination(),c_line.getQuantity()) (c_line.getSource(),c_line.getDestination(),c_line.getQuantity())
# ) )
# ) )
e_found_line = None e_found_line = None
e_line_cursor = 0 e_line_cursor = 0
while e_line_cursor < len(e_line_list) and e_found_line is None: while e_line_cursor < len(e_line_list) and e_found_line is None:
...@@ -2652,6 +3030,8 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2652,6 +3030,8 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
key_cursor += 1 key_cursor += 1
if not wrong_line: if not wrong_line:
e_found_line = e_line e_found_line = e_line
else:
LOG('',0,'key:%s\ncalculated:%s\n expected:%s' % (key,c_value,e_value))
e_line_cursor += 1 e_line_cursor += 1
if e_found_line is None: if e_found_line is None:
LOG('No expected line found for this calculated one !',0,'') LOG('No expected line found for this calculated one !',0,'')
...@@ -2662,15 +3042,19 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2662,15 +3042,19 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
self.assertEquals(len(e_line_list),0) self.assertEquals(len(e_line_list),0)
if len(e_transaction_list) > 0: if len(e_transaction_list) > 0:
LOG('More expected movements than calculated ! Remaining expected ones are', 0, e_transaction_list) LOG('More expected transaction than calculated ! Remaining expected ones are', 0, e_transaction_list)
self.assertEquals(len(e_transaction_list),0) self.assertEquals(len(e_transaction_list),0)
class TestImmobilisation(TestImmobilisationMixin):
run_all_test = 1
def stepSetTest01SequenceData(self, sequence=None, sequence_list=None, **kw): def stepSetTest01SequenceData(self, sequence=None, sequence_list=None, **kw):
sequence.edit(destination_section = self.getOrganisationModule()["A"], sequence.edit(destination_section = self.getOrganisationModule()["A"],
datetime = self.datetime, datetime = self.datetime,
item_list_list = [[ self.getItemModule()['item1'] ]] item_list_list = [[ self.getItemModule()['item1'] ]]
) )
def test_01_singlePackingListImmobilisationStateChange(self, quiet=0, run=run_all_test): def test_01_singlePackingListImmobilisationStateChange(self, quiet=0, run=run_all_test):
# Test if an added packing list has a correct immobilisation state # Test if an added packing list has a correct immobilisation state
if not run: return if not run: return
...@@ -2697,6 +3081,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2697,6 +3081,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
datetime= [self.datetime, self.datetime+5, self.datetime+10], datetime= [self.datetime, self.datetime+5, self.datetime+10],
item_list_list = [[ self.getItemModule()['item2'] ]] item_list_list = [[ self.getItemModule()['item2'] ]]
) )
def test_02_singleItemImmobilisationStateChange(self, quiet=0, run=run_all_test): def test_02_singleItemImmobilisationStateChange(self, quiet=0, run=run_all_test):
# Test if an edit on a preceding delivery switches the following in calculating state # Test if an edit on a preceding delivery switches the following in calculating state
if not run: return if not run: return
...@@ -2782,16 +3167,17 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2782,16 +3167,17 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def stepSetTest04SequenceData(self, sequence=None, sequence_list=None, **kw): def stepSetTest04SequenceData(self, sequence=None, sequence_list=None, **kw):
sequence.edit(item = self.getItemModule()['item5'], sequence.edit(item = self.getItemModule()['item5'],
destination_section = self.getOrganisationModule()["A"], destination_section = self.getOrganisationModule()["A"],
amortisation_method = self.linear_method) amortisation_method = self.linear_method)
def stepTest04ModifyPackingList(self, sequence=None, sequence_list=None, **kw): def stepTest04ModifyPackingList(self, sequence=None, sequence_list=None, **kw):
pl = sequence.get('packing_list') pl = sequence.get('packing_list')
if pl is None: pl = sequence.get('packing_list_list', [])[-1] if pl is None: pl = sequence.get('packing_list_list', [])[-1]
for line in pl.contentValues(): for line in pl.contentValues():
line.edit(amortisation_start_price=None) line.edit(amortisation_start_price=None)
def test_04_TestContinuousMethodMovementValidity(self, quiet=0, run=run_all_test): def test_04_TestContinuousMethodMovementValidity(self, quiet=0, run=run_all_test):
# Create a continuous method with some movements, then test their validity # Create a continuous method with some movements, then test their validity
# by invalidating some of them # by invalidating some of them
...@@ -2850,6 +3236,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2850,6 +3236,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
def stepSetTest05SequenceData(self, sequence=None, sequence_list=None, **kw): def stepSetTest05SequenceData(self, sequence=None, sequence_list=None, **kw):
sequence.edit(item = self.getItemModule()['item6'], sequence.edit(item = self.getItemModule()['item6'],
amortisation_method = self.linear_method) amortisation_method = self.linear_method)
def test_05_TestImmobilisationPeriodsWithContinuousMethodDuringContinuousTime(self, quiet=0, run=run_all_test): def test_05_TestImmobilisationPeriodsWithContinuousMethodDuringContinuousTime(self, quiet=0, run=run_all_test):
# Test the calculated amortisation periods with a continuous amortisation method # Test the calculated amortisation periods with a continuous amortisation method
# and with no stop of immobilisation # and with no stop of immobilisation
...@@ -2871,6 +3258,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2871,6 +3258,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
def stepSetTest06SequenceData(self, sequence=None, sequence_list=None, **kw): def stepSetTest06SequenceData(self, sequence=None, sequence_list=None, **kw):
sequence.edit(item = self.getItemModule()['item7'], sequence.edit(item = self.getItemModule()['item7'],
amortisation_method = self.linear_method) amortisation_method = self.linear_method)
def test_06_TestImmobilisationPeriodsWithContinuousMethodDuringUncontinuousTime(self, quiet=0, run=run_all_test): def test_06_TestImmobilisationPeriodsWithContinuousMethodDuringUncontinuousTime(self, quiet=0, run=run_all_test):
# Test the calculated amortisation periods with a continuous amortisation method # Test the calculated amortisation periods with a continuous amortisation method
# and with stops of immobilisation in the time # and with stops of immobilisation in the time
...@@ -2893,6 +3281,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2893,6 +3281,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
sequence.edit(item = self.getItemModule()['item8'], sequence.edit(item = self.getItemModule()['item8'],
amortisation_method = self.uncontinuous_degressive_method, amortisation_method = self.uncontinuous_degressive_method,
parameter_dict = {'degressive_coefficient': 2}) parameter_dict = {'degressive_coefficient': 2})
def test_07_TestImmobilisationPeriodsWithUncontinuousMethodDuringContinuousTime(self, quiet=0, run=run_all_test): def test_07_TestImmobilisationPeriodsWithUncontinuousMethodDuringContinuousTime(self, quiet=0, run=run_all_test):
# Test the calculated amortisation periods with a uncontinuous amortisation method # Test the calculated amortisation periods with a uncontinuous amortisation method
# and with no stop of immobilisation in the time # and with no stop of immobilisation in the time
...@@ -2915,6 +3304,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2915,6 +3304,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
sequence.edit(item = self.getItemModule()['item9'], sequence.edit(item = self.getItemModule()['item9'],
amortisation_method = self.uncontinuous_degressive_method, amortisation_method = self.uncontinuous_degressive_method,
parameter_dict = {'degressive_coefficient': 2}) parameter_dict = {'degressive_coefficient': 2})
def test_08_TestImmobilisationPeriodsWithUncontinuousMethodDuringUncontinuousTime(self, quiet=0, run=run_all_test): def test_08_TestImmobilisationPeriodsWithUncontinuousMethodDuringUncontinuousTime(self, quiet=0, run=run_all_test):
# Test the calculated amortisation periods with an uncontinuous amortisation method # Test the calculated amortisation periods with an uncontinuous amortisation method
# and with stops of immobilisation in the time # and with stops of immobilisation in the time
...@@ -2936,6 +3326,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2936,6 +3326,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
def stepSetTest09SequenceData(self, sequence=None, sequence_list=None, **kw): def stepSetTest09SequenceData(self, sequence=None, sequence_list=None, **kw):
sequence.edit(item = self.getItemModule()['item10'], sequence.edit(item = self.getItemModule()['item10'],
amortisation_method = self.linear_method) amortisation_method = self.linear_method)
def test_09_TestAmortisationPriceAndSimulationForLinearAmortisation(self, quiet=0, run=run_all_test): def test_09_TestAmortisationPriceAndSimulationForLinearAmortisation(self, quiet=0, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
...@@ -2957,6 +3348,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2957,6 +3348,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
sequence.edit(item = self.getItemModule()['item11'], sequence.edit(item = self.getItemModule()['item11'],
amortisation_method = self.degressive_method, amortisation_method = self.degressive_method,
parameter_dict={'degressive_coefficient':2}) parameter_dict={'degressive_coefficient':2})
def test_10_TestAmortisationPriceForDegressiveAmortisation(self, quiet=0, run=run_all_test): def test_10_TestAmortisationPriceForDegressiveAmortisation(self, quiet=0, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
...@@ -2977,6 +3369,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2977,6 +3369,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
sequence.edit(item = self.getItemModule()['item12'], sequence.edit(item = self.getItemModule()['item12'],
amortisation_method = self.uncontinuous_degressive_method, amortisation_method = self.uncontinuous_degressive_method,
parameter_dict={'degressive_coefficient':2}) parameter_dict={'degressive_coefficient':2})
def test_11_TestAmortisationPriceAndSimulationForUncontinuousDegressiveAmortisation(self, quiet=0, run=run_all_test): def test_11_TestAmortisationPriceAndSimulationForUncontinuousDegressiveAmortisation(self, quiet=0, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
...@@ -2998,6 +3391,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -2998,6 +3391,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
sequence.edit(item = self.getItemModule()['item13'], sequence.edit(item = self.getItemModule()['item13'],
amortisation_method = self.actual_use_method, amortisation_method = self.actual_use_method,
parameter_dict={'durability':1000}) parameter_dict={'durability':1000})
def test_12_TestAmortisationPriceForActualUseDegressiveAmortisation(self, quiet=0, run=run_all_test): def test_12_TestAmortisationPriceForActualUseDegressiveAmortisation(self, quiet=0, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
...@@ -3078,6 +3472,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -3078,6 +3472,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
sequence.edit(item = self.getItemModule()['item16'], sequence.edit(item = self.getItemModule()['item16'],
amortisation_method = self.uncontinuous_degressive_method, amortisation_method = self.uncontinuous_degressive_method,
parameter_dict = {'degressive_coefficient':2}) parameter_dict = {'degressive_coefficient':2})
def test_15_TestOwnerChangeSimulationForUnContinuousAmortisationMethod(self, quiet=0, run=run_all_test): def test_15_TestOwnerChangeSimulationForUnContinuousAmortisationMethod(self, quiet=0, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
...@@ -3103,6 +3498,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -3103,6 +3498,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
def stepSetTest16SequenceData(self, sequence=None, sequence_list=None, **kw): def stepSetTest16SequenceData(self, sequence=None, sequence_list=None, **kw):
sequence.edit(item = self.getItemModule()['item17'], sequence.edit(item = self.getItemModule()['item17'],
amortisation_method = self.linear_method) amortisation_method = self.linear_method)
def test_16_TestOwnerChangeSimulationForContinuousAmortisationMethod(self, quiet=0, run=run_all_test): def test_16_TestOwnerChangeSimulationForContinuousAmortisationMethod(self, quiet=0, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
...@@ -3128,6 +3524,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -3128,6 +3524,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
def stepSetTest17SequenceData(self, sequence=None, sequence_list=None, **kw): def stepSetTest17SequenceData(self, sequence=None, sequence_list=None, **kw):
sequence.edit(item = self.getItemModule()['item18'], sequence.edit(item = self.getItemModule()['item18'],
amortisation_method = self.linear_method) amortisation_method = self.linear_method)
def test_17_TestMonthlyAmortisation(self, quiet=0, run=run_all_test): def test_17_TestMonthlyAmortisation(self, quiet=0, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
...@@ -3162,6 +3559,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -3162,6 +3559,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
parameter_dict = parameter_dict, parameter_dict = parameter_dict,
destination_section = self.getOrganisationModule()["A"], destination_section = self.getOrganisationModule()["A"],
build_parameter_dict = build_parameter_dict) build_parameter_dict = build_parameter_dict)
def test_18_TestAccountingBuilding(self, quiet=0, run=run_all_test): def test_18_TestAccountingBuilding(self, quiet=0, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
...@@ -3174,6 +3572,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -3174,6 +3572,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
Tic \ Tic \
TestAllAppliedRulesAreEmpty \ TestAllAppliedRulesAreEmpty \
CreatePackingList \ CreatePackingList \
DeliverPackingList \
AggregateItems \ AggregateItems \
Tic \ Tic \
PartialBuildAccounting \ PartialBuildAccounting \
...@@ -3188,7 +3587,6 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -3188,7 +3587,6 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def stepSetTest19SequenceData(self, sequence=None, sequence_list=None, **kw): def stepSetTest19SequenceData(self, sequence=None, sequence_list=None, **kw):
item_list = ['item1'] item_list = ['item1']
item_list = [self.getItemModule()[item] for item in item_list] item_list = [self.getItemModule()[item] for item in item_list]
...@@ -3204,6 +3602,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -3204,6 +3602,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
datetime = DateTime('2000/01/01'), datetime = DateTime('2000/01/01'),
parameter_dict = parameter_dict, parameter_dict = parameter_dict,
destination_section = self.getOrganisationModule()["A"]) destination_section = self.getOrganisationModule()["A"])
def stepSetTest19SequenceData2(self, sequence=None, sequence_list=None, **kw): def stepSetTest19SequenceData2(self, sequence=None, sequence_list=None, **kw):
""" """
Add a section change packing_list at date 2002/01/01 Add a section change packing_list at date 2002/01/01
...@@ -3212,11 +3611,13 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -3212,11 +3611,13 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
sequence.edit(datetime = DateTime('2002/01/01'), sequence.edit(datetime = DateTime('2002/01/01'),
parameter_dict = parameter_dict, parameter_dict = parameter_dict,
destination_section = self.getOrganisationModule()["B"]) destination_section = self.getOrganisationModule()["B"])
def stepTest19ModifyPackingList(self, sequence=None, sequence_list=None, **kw): def stepTest19ModifyPackingList(self, sequence=None, sequence_list=None, **kw):
pl = sequence.get('packing_list') pl = sequence.get('packing_list')
if pl is None: pl = sequence.get('packing_list_list', [])[-1] if pl is None: pl = sequence.get('packing_list_list', [])[-1]
for line in pl.contentValues(): for line in pl.contentValues():
line.edit(amortisation_account=self.extra_account_dict['amortisation_account']) line.edit(amortisation_account=self.extra_account_dict['amortisation_account'])
def test_19_TestAccountingBuildingAndDivergence(self, quiet=0, run=run_all_test): def test_19_TestAccountingBuildingAndDivergence(self, quiet=0, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
...@@ -3231,6 +3632,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -3231,6 +3632,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
Tic \ Tic \
TestAllAppliedRulesAreEmpty \ TestAllAppliedRulesAreEmpty \
CreatePackingList \ CreatePackingList \
DeliverPackingList \
AggregateItems \ AggregateItems \
Tic \ Tic \
BuildAccounting \ BuildAccounting \
...@@ -3238,6 +3640,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -3238,6 +3640,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
TestSimpleAccountingBuild \ TestSimpleAccountingBuild \
SetTest19SequenceData2 \ SetTest19SequenceData2 \
CreatePackingList \ CreatePackingList \
DeliverPackingList \
AggregateItems \ AggregateItems \
Tic \ Tic \
TestSimulationBuildAfterFirstAccountingChange \ TestSimulationBuildAfterFirstAccountingChange \
...@@ -3279,6 +3682,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -3279,6 +3682,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
datetime = DateTime('2000/01/01'), datetime = DateTime('2000/01/01'),
parameter_dict = parameter_dict, parameter_dict = parameter_dict,
destination_section = self.getOrganisationModule()["A"]) destination_section = self.getOrganisationModule()["A"])
def test_20_TestAccountingAcceptDecisionSolver(self, quiet=0, run=run_all_test): def test_20_TestAccountingAcceptDecisionSolver(self, quiet=0, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
...@@ -3293,6 +3697,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -3293,6 +3697,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
Tic \ Tic \
TestAllAppliedRulesAreEmpty \ TestAllAppliedRulesAreEmpty \
CreatePackingList \ CreatePackingList \
DeliverPackingList \
AggregateItems \ AggregateItems \
Tic \ Tic \
BuildAccounting \ BuildAccounting \
...@@ -3307,7 +3712,6 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -3307,7 +3712,6 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def stepSetTest21SequenceData(self, sequence=None, sequence_list=None, **kw): def stepSetTest21SequenceData(self, sequence=None, sequence_list=None, **kw):
item_list = ['item1'] item_list = ['item1']
item_list = [self.getItemModule()[item] for item in item_list] item_list = [self.getItemModule()[item] for item in item_list]
...@@ -3323,26 +3727,31 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -3323,26 +3727,31 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
datetime = DateTime('2000/01/01'), datetime = DateTime('2000/01/01'),
parameter_dict = parameter_dict, parameter_dict = parameter_dict,
destination_section = self.getOrganisationModule()["A"]) destination_section = self.getOrganisationModule()["A"])
def stepTest21FirstModifyPackingList(self, sequence=None, sequence_list=None, **kw): def stepTest21FirstModifyPackingList(self, sequence=None, sequence_list=None, **kw):
pl = sequence.get('packing_list') pl = sequence.get('packing_list')
if pl is None: pl = sequence.get('packing_list_list', [])[-1] if pl is None: pl = sequence.get('packing_list_list', [])[-1]
for line in pl.contentValues(): for line in pl.contentValues():
line.edit(amortisation_duration=36) line.edit(amortisation_duration=36)
def stepTest21SecondModifyPackingList(self, sequence=None, sequence_list=None, **kw): def stepTest21SecondModifyPackingList(self, sequence=None, sequence_list=None, **kw):
pl = sequence.get('packing_list') pl = sequence.get('packing_list')
if pl is None: pl = sequence.get('packing_list_list', [])[-1] if pl is None: pl = sequence.get('packing_list_list', [])[-1]
for line in pl.contentValues(): for line in pl.contentValues():
line.edit(amortisation_duration=24) line.edit(amortisation_duration=24)
def stepTest21ThirdModifyPackingList(self, sequence=None, sequence_list=None, **kw): def stepTest21ThirdModifyPackingList(self, sequence=None, sequence_list=None, **kw):
pl = sequence.get('packing_list') pl = sequence.get('packing_list')
if pl is None: pl = sequence.get('packing_list_list', [])[-1] if pl is None: pl = sequence.get('packing_list_list', [])[-1]
for line in pl.contentValues(): for line in pl.contentValues():
line.edit(amortisation_duration=48) line.edit(amortisation_duration=48)
def stepTest21FourthModifyPackingList(self, sequence=None, sequence_list=None, **kw): def stepTest21FourthModifyPackingList(self, sequence=None, sequence_list=None, **kw):
pl = sequence.get('packing_list') pl = sequence.get('packing_list')
if pl is None: pl = sequence.get('packing_list_list', [])[-1] if pl is None: pl = sequence.get('packing_list_list', [])[-1]
for line in pl.contentValues(): for line in pl.contentValues():
line.edit(amortisation_account=self.extra_account_dict['amortisation_account']) line.edit(amortisation_account=self.extra_account_dict['amortisation_account'])
def test_21_TestSimulationBuildingWithValidatedTransactions(self, quiet=0, run=run_all_test): def test_21_TestSimulationBuildingWithValidatedTransactions(self, quiet=0, run=run_all_test):
""" """
The expand process takes care of already validated transactions : it creates The expand process takes care of already validated transactions : it creates
...@@ -3363,6 +3772,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase): ...@@ -3363,6 +3772,7 @@ class TestImmobilisation(TestOrderMixin, ERP5TypeTestCase):
Tic \ Tic \
TestAllAppliedRulesAreEmpty \ TestAllAppliedRulesAreEmpty \
CreatePackingList \ CreatePackingList \
DeliverPackingList \
AggregateItems \ AggregateItems \
Tic \ Tic \
BuildAccounting \ BuildAccounting \
......
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