Commit 1c60256f authored by Jérome Perrin's avatar Jérome Perrin

*: refactor with a modified 2to3's raise fixer

The fixer was modified to not rewrite:

raise E, V, T -> raise E(V).with_traceback(T)
raise E, None, T -> raise E.with_traceback(T)

which is python3 only syntax
parent 4e5ad574
...@@ -10,7 +10,7 @@ start_date = closing_period.getStartDate() ...@@ -10,7 +10,7 @@ start_date = closing_period.getStartDate()
stop_date = closing_period.getStopDate() stop_date = closing_period.getStopDate()
if start_date > stop_date: if start_date > stop_date:
raise ValidationFailed, translateString("Start date is after stop date.") raise ValidationFailed(translateString("Start date is after stop date."))
period_list = closing_period.getParentValue().searchFolder( period_list = closing_period.getParentValue().searchFolder(
simulation_state=valid_state_list, simulation_state=valid_state_list,
...@@ -21,18 +21,18 @@ for period in period_list: ...@@ -21,18 +21,18 @@ for period in period_list:
period = period.getObject() period = period.getObject()
if period.getSimulationState() in valid_state_list: if period.getSimulationState() in valid_state_list:
if start_date <= period.getStopDate() and not stop_date <= period.getStartDate(): if start_date <= period.getStopDate() and not stop_date <= period.getStartDate():
raise ValidationFailed, translateString( raise ValidationFailed(translateString(
"${date} is already in an open accounting period.", "${date} is already in an open accounting period.",
mapping={'date': start_date}) mapping={'date': start_date}))
if len(period_list) > 1: if len(period_list) > 1:
last_period = period_list[-1].getObject() last_period = period_list[-1].getObject()
if last_period.getId() == closing_period.getId(): if last_period.getId() == closing_period.getId():
last_period = period_list[-2].getObject() last_period = period_list[-2].getObject()
if (start_date - last_period.getStopDate()) > 1: if (start_date - last_period.getStopDate()) > 1:
raise ValidationFailed, translateString( raise ValidationFailed(translateString(
"Last opened period ends on ${last_openned_date},"+ "Last opened period ends on ${last_openned_date},"+
" this period starts on ${this_period_start_date}."+ " this period starts on ${this_period_start_date}."+
" Accounting Periods must be consecutive.", " Accounting Periods must be consecutive.",
mapping = { 'last_openned_date': last_period.getStopDate(), mapping = { 'last_openned_date': last_period.getStopDate(),
'this_period_start_date': start_date } ) 'this_period_start_date': start_date } ))
...@@ -34,7 +34,7 @@ while section.getPortalType() == period.getPortalType(): ...@@ -34,7 +34,7 @@ while section.getPortalType() == period.getPortalType():
section_category = section.getGroup(base=True) section_category = section.getGroup(base=True)
if not section_category: if not section_category:
raise ValidationFailed, translateString("This Organisation must be member of a Group") raise ValidationFailed(translateString("This Organisation must be member of a Group"))
# XXX copy and paste from AccountingPeriod_createBalanceTransaction ! # XXX copy and paste from AccountingPeriod_createBalanceTransaction !
...@@ -81,5 +81,5 @@ movement_list = portal.portal_simulation.getMovementHistoryList( ...@@ -81,5 +81,5 @@ movement_list = portal.portal_simulation.getMovementHistoryList(
limit=1) limit=1)
if movement_list: if movement_list:
raise ValidationFailed, translateString( raise ValidationFailed(translateString(
"All Accounting Transactions for this organisation during the period have to be closed first.") "All Accounting Transactions for this organisation during the period have to be closed first."))
...@@ -32,21 +32,21 @@ for line in transaction_lines: ...@@ -32,21 +32,21 @@ for line in transaction_lines:
): ):
if account is not None and account.getValidationState() != 'validated': if account is not None and account.getValidationState() != 'validated':
raise ValidationFailed, translateString( raise ValidationFailed(translateString(
"Account ${account_title} is not validated.", "Account ${account_title} is not validated.",
mapping=dict(account_title=account.Account_getFormattedTitle())) mapping=dict(account_title=account.Account_getFormattedTitle())))
if third_party is not None and\ if third_party is not None and\
third_party.getValidationState() in invalid_state_list: third_party.getValidationState() in invalid_state_list:
raise ValidationFailed, translateString( raise ValidationFailed(translateString(
"Third party ${third_party_name} is invalid.", "Third party ${third_party_name} is invalid.",
mapping=dict(third_party_name=third_party.getTitle())) mapping=dict(third_party_name=third_party.getTitle())))
if bank_account is not None: if bank_account is not None:
if bank_account.getValidationState() in invalid_state_list: if bank_account.getValidationState() in invalid_state_list:
raise ValidationFailed, translateString( raise ValidationFailed(translateString(
"Bank Account ${bank_account_reference} is invalid.", "Bank Account ${bank_account_reference} is invalid.",
mapping=dict(bank_account_reference=bank_account.getReference())) mapping=dict(bank_account_reference=bank_account.getReference())))
if account is not None and account.isMemberOf('account_type/asset/cash/bank'): if account is not None and account.isMemberOf('account_type/asset/cash/bank'):
# also check that currencies are consistent if we use this quantity for # also check that currencies are consistent if we use this quantity for
...@@ -54,11 +54,11 @@ for line in transaction_lines: ...@@ -54,11 +54,11 @@ for line in transaction_lines:
bank_account_currency = bank_account.getProperty('price_currency') bank_account_currency = bank_account.getProperty('price_currency')
if bank_account_currency is not None and \ if bank_account_currency is not None and \
bank_account_currency != line.getResource(): bank_account_currency != line.getResource():
raise ValidationFailed, translateString( raise ValidationFailed(translateString(
"Bank Account ${bank_account_reference} " "Bank Account ${bank_account_reference} "
"uses ${bank_account_currency} as default currency.", "uses ${bank_account_currency} as default currency.",
mapping=dict(bank_account_reference=bank_account.getReference(), mapping=dict(bank_account_reference=bank_account.getReference(),
bank_account_currency=bank_account.getPriceCurrencyReference())) bank_account_currency=bank_account.getPriceCurrencyReference())))
source_currency = None source_currency = None
source_section = line.getSourceSectionValue() source_section = line.getSourceSectionValue()
......
...@@ -4,7 +4,7 @@ the new Invoice. ...@@ -4,7 +4,7 @@ the new Invoice.
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
if related_simulation_movement_path_list is None: if related_simulation_movement_path_list is None:
raise RuntimeError, 'related_simulation_movement_path_list is missing. Update ERP5 Product.' raise RuntimeError('related_simulation_movement_path_list is missing. Update ERP5 Product.')
invoice = context invoice = context
......
...@@ -8,17 +8,17 @@ start_date = inventory.getStartDate() ...@@ -8,17 +8,17 @@ start_date = inventory.getStartDate()
if start_date is None: if start_date is None:
text = "Sorry, you must define the inventory date" text = "Sorry, you must define the inventory date"
message = Message(domain='ui', message=text) message = Message(domain='ui', message=text)
raise ValidationFailed, message raise ValidationFailed(message)
# Make sure the node is defined # Make sure the node is defined
node = inventory.getDestination() node = inventory.getDestination()
if node is None: if node is None:
text = "Sorry, you must define the inventory warehouse" text = "Sorry, you must define the inventory warehouse"
message = Message(domain='ui', message=text) message = Message(domain='ui', message=text)
raise ValidationFailed, message raise ValidationFailed(message)
# use of the constraint # use of the constraint
error_list = inventory.checkConsistency() error_list = inventory.checkConsistency()
if len(error_list) > 0: if len(error_list) > 0:
raise ValidationFailed, (error_list[0].getTranslatedMessage(),) raise ValidationFailed(error_list[0].getTranslatedMessage(),)
...@@ -11,7 +11,7 @@ catalog_id = archive.getCatalogId() ...@@ -11,7 +11,7 @@ catalog_id = archive.getCatalogId()
if "deferred" not in archive.getDeferredConnectionId(): if "deferred" not in archive.getDeferredConnectionId():
msg = Message(domain='ui', message='Deferred connection ID choose is not a deferred connection.') msg = Message(domain='ui', message='Deferred connection ID choose is not a deferred connection.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
def sort_max_date(a, b): def sort_max_date(a, b):
return cmp(a.getStopDateRangeMax(), b.getStopDateRangeMax()) return cmp(a.getStopDateRangeMax(), b.getStopDateRangeMax())
...@@ -32,7 +32,7 @@ if archive.getStopDateRangeMax() is not None: ...@@ -32,7 +32,7 @@ if archive.getStopDateRangeMax() is not None:
break break
if previous_archive.getStopDateRangeMax().Date() != min_stop_date: if previous_archive.getStopDateRangeMax().Date() != min_stop_date:
msg = Message(domain='ui', message='Archive are not contiguous.') msg = Message(domain='ui', message='Archive are not contiguous.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
else: else:
previous_archive_list = [x.getObject() for x in archive.portal_catalog(portal_type="Archive", previous_archive_list = [x.getObject() for x in archive.portal_catalog(portal_type="Archive",
validation_state='ready')] validation_state='ready')]
...@@ -47,7 +47,7 @@ else: ...@@ -47,7 +47,7 @@ else:
break break
if previous_archive.getStopDateRangeMax().Date() != min_stop_date: if previous_archive.getStopDateRangeMax().Date() != min_stop_date:
msg = Message(domain='ui', message='Archive are not contiguous.') msg = Message(domain='ui', message='Archive are not contiguous.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Check the catalog # Check the catalog
...@@ -57,4 +57,4 @@ previous_archive_list = [x.getObject() for x in archive.portal_catalog(portal_ty ...@@ -57,4 +57,4 @@ previous_archive_list = [x.getObject() for x in archive.portal_catalog(portal_ty
for arch in previous_archive_list: for arch in previous_archive_list:
if arch.getCatalogId() == catalog_id and arch is not previous_archive: if arch.getCatalogId() == catalog_id and arch is not previous_archive:
msg = Message(domain='ui', message='Use of a former catalog is prohibited.') msg = Message(domain='ui', message='Use of a former catalog is prohibited.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -9,4 +9,4 @@ for site in site_list: ...@@ -9,4 +9,4 @@ for site in site_list:
return site return site
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import Message
message = Message(domain="ui", message="The owner is not assigned to the right vault.") message = Message(domain="ui", message="The owner is not assigned to the right vault.")
raise ValueError,message raise ValueError(message)
...@@ -9,4 +9,4 @@ for site in site_list: ...@@ -9,4 +9,4 @@ for site in site_list:
return site return site
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import Message
message = Message(domain="ui", message="The owner is not assigned to the right vault.") message = Message(domain="ui", message="The owner is not assigned to the right vault.")
raise ValueError,message raise ValueError(message)
...@@ -9,4 +9,4 @@ for site in site_list: ...@@ -9,4 +9,4 @@ for site in site_list:
return site return site
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import Message
message = Message(domain="ui", message="The owner is not assigned to the right vault.") message = Message(domain="ui", message="The owner is not assigned to the right vault.")
raise ValueError,message raise ValueError(message)
site_list = context.Baobab_getUserAssignedSiteList() site_list = context.Baobab_getUserAssignedSiteList()
if len(site_list) == 0: if len(site_list) == 0:
raise ValueError, "Unable to determine site" raise ValueError("Unable to determine site")
site = site_list[0] site = site_list[0]
site = context.Baobab_getVaultSite(site) site = context.Baobab_getVaultSite(site)
......
...@@ -9,4 +9,4 @@ for site in site_list: ...@@ -9,4 +9,4 @@ for site in site_list:
return site return site
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import Message
message = Message(domain="ui", message="Object owner is not assigned to a counter.") message = Message(domain="ui", message="Object owner is not assigned to a counter.")
raise ValueError,message raise ValueError(message)
...@@ -21,15 +21,15 @@ else: ...@@ -21,15 +21,15 @@ else:
# check if an exchange rate is defined # check if an exchange rate is defined
if total_quantity is None: if total_quantity is None:
raise ValidationFailed, (Message(domain='ui', raise ValidationFailed(Message(domain='ui',
message="No exchange rate defined for this currency at document date.")) message="No exchange rate defined for this currency at document date."))
# check resource on currency fastinput # check resource on currency fastinput
doc_resource = context.getResource() doc_resource = context.getResource()
for line in context.contentValues(portal_type=foreign_currency_portal_type): for line in context.contentValues(portal_type=foreign_currency_portal_type):
if line.getResourceValue().getPriceCurrency() != doc_resource: if line.getResourceValue().getPriceCurrency() != doc_resource:
raise ValidationFailed, (Message(domain="ui", raise ValidationFailed(Message(domain="ui",
message="Resource defined on document is different from currency cash."), ) message="Resource defined on document is different from currency cash."),)
# check outgoing amount # check outgoing amount
if is_currency_sale: if is_currency_sale:
...@@ -38,7 +38,7 @@ else: ...@@ -38,7 +38,7 @@ else:
amount = context.getQuantity() amount = context.getQuantity()
if amount is None or amount <= 0: if amount is None or amount <= 0:
msg = Message(domain="ui", message="Amount is not valid.") msg = Message(domain="ui", message="Amount is not valid.")
raise ValidationFailed, (msg, ) raise ValidationFailed(msg,)
# Reverse error messages in cash of currency purchase # Reverse error messages in cash of currency purchase
default_msg = "Received amount is different from input cash." default_msg = "Received amount is different from input cash."
...@@ -49,18 +49,18 @@ if not is_currency_sale: ...@@ -49,18 +49,18 @@ if not is_currency_sale:
# Check default currency amount consistency # Check default currency amount consistency
if context.getTotalPrice(portal_type=[default_currency_portal_type, if context.getTotalPrice(portal_type=[default_currency_portal_type,
'Cash Delivery Cell'], fast=0) != context.getQuantity(): 'Cash Delivery Cell'], fast=0) != context.getQuantity():
raise ValidationFailed, (Message(domain="ui", message=default_msg), ) raise ValidationFailed(Message(domain="ui", message=default_msg),)
# Check foreign currency amount consistency # Check foreign currency amount consistency
if context.getTotalPrice(portal_type=[foreign_currency_portal_type, if context.getTotalPrice(portal_type=[foreign_currency_portal_type,
'Cash Delivery Cell'], fast=0) != context.getSourceTotalAssetPrice(): 'Cash Delivery Cell'], fast=0) != context.getSourceTotalAssetPrice():
raise ValidationFailed, (Message(domain="ui", message=foreign_msg), ) raise ValidationFailed(Message(domain="ui", message=foreign_msg),)
# Check outgoing inventory # Check outgoing inventory
resource_one = context.CashDelivery_checkCounterInventory( resource_one = context.CashDelivery_checkCounterInventory(
portal_type=outgoing_portal_type) portal_type=outgoing_portal_type)
if resource_one == 2: if resource_one == 2:
raise ValidationFailed, (Message(domain="ui", message="No Resource."), ) raise ValidationFailed(Message(domain="ui", message="No Resource."),)
elif resource_one == 1: elif resource_one == 1:
raise ValidationFailed, (Message(domain="ui", raise ValidationFailed(Message(domain="ui",
message="Insufficient balance"), ) message="Insufficient balance"),)
...@@ -2,7 +2,7 @@ site = context.Baobab_getUserAssignedRootSite() ...@@ -2,7 +2,7 @@ site = context.Baobab_getUserAssignedRootSite()
if site in ('', None): if site in ('', None):
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import Message
message = Message(domain="ui", message="The owner is not assigned to the right vault.") message = Message(domain="ui", message="The owner is not assigned to the right vault.")
raise ValueError,message raise ValueError(message)
context.setSource("%s/caveau/auxiliaire/encaisse_des_billets_a_ventiler_et_a_detruire" %(site,)) context.setSource("%s/caveau/auxiliaire/encaisse_des_billets_a_ventiler_et_a_detruire" %(site,))
......
...@@ -9,4 +9,4 @@ for site in site_list: ...@@ -9,4 +9,4 @@ for site in site_list:
return site + '/encaisse_des_billets_et_monnaies/entrante' return site + '/encaisse_des_billets_et_monnaies/entrante'
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import Message
message = Message(domain="ui", message="Object owner is not assigned to a counter.") message = Message(domain="ui", message="Object owner is not assigned to a counter.")
raise ValueError,message raise ValueError(message)
...@@ -15,6 +15,6 @@ if source_trade is None or context.getSimulationState() != 'delivered': ...@@ -15,6 +15,6 @@ if source_trade is None or context.getSimulationState() != 'delivered':
return source_trade return source_trade
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import Message
message = Message(domain="ui", message="The owner is not assigned to the right vault.") message = Message(domain="ui", message="The owner is not assigned to the right vault.")
raise ValueError,message raise ValueError(message)
else: else:
return source_trade return source_trade
user_site = context.Baobab_getUserAssignedRootSite() user_site = context.Baobab_getUserAssignedRootSite()
user_counter = context.Baobab_getUserAssignedSiteList()[0] user_counter = context.Baobab_getUserAssignedSiteList()[0]
if user_site in ('', None) or user_counter in ('', None): if user_site in ('', None) or user_counter in ('', None):
raise ValueError, "Unable to determine site" raise ValueError("Unable to determine site")
if 'guichet' not in user_counter: if 'guichet' not in user_counter:
raise ValueError, "You are not assigned to a counter" raise ValueError("You are not assigned to a counter")
context.edit(source=user_counter, source_trade=user_site) context.edit(source=user_counter, source_trade=user_site)
...@@ -21,7 +21,7 @@ if resource_portal_type == 'Banknote': ...@@ -21,7 +21,7 @@ if resource_portal_type == 'Banknote':
# This case is/must be protected by a constraint: a document containing a # This case is/must be protected by a constraint: a document containing a
# line matching this condition must not get validated. # line matching this condition must not get validated.
# XXX: Maybe we should return None here instead of raising. # XXX: Maybe we should return None here instead of raising.
raise Exception, 'Should not be here' raise Exception('Should not be here')
elif emission_letter == site_letter: elif emission_letter == site_letter:
if cash_status == "valid": if cash_status == "valid":
# banknote 'valid' from same country -> caisse de reserve / billets et monnaies # banknote 'valid' from same country -> caisse de reserve / billets et monnaies
......
...@@ -9,7 +9,7 @@ vault = transaction.getSource() ...@@ -9,7 +9,7 @@ vault = transaction.getSource()
if not (vault.endswith('encaisse_des_billets_et_monnaies') or vault.endswith('encaisse_des_externes')or \ if not (vault.endswith('encaisse_des_billets_et_monnaies') or vault.endswith('encaisse_des_externes')or \
'encaisse_des_devises' in vault): 'encaisse_des_devises' in vault):
msg = Message(domain="ui", message="Invalid source.") msg = Message(domain="ui", message="Invalid source.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
root_site = context.Baobab_getVaultSite(vault) root_site = context.Baobab_getVaultSite(vault)
site_emission_letter = context.Baobab_getSiteEmissionLetter(site=root_site) site_emission_letter = context.Baobab_getSiteEmissionLetter(site=root_site)
...@@ -17,7 +17,7 @@ if vault.endswith('encaisse_des_externes'): ...@@ -17,7 +17,7 @@ if vault.endswith('encaisse_des_externes'):
for line in transaction.getMovementList(portal_type=['Outgoing Cash Balance Regulation Line','Cash Delivery Cell']): for line in transaction.getMovementList(portal_type=['Outgoing Cash Balance Regulation Line','Cash Delivery Cell']):
if line.getEmissionLetter() == site_emission_letter: if line.getEmissionLetter() == site_emission_letter:
msg = Message(domain="ui", message="You must not select the local emission letter.") msg = Message(domain="ui", message="You must not select the local emission letter.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# check resource between line and document # check resource between line and document
doc_resource = transaction.getResource() doc_resource = transaction.getResource()
...@@ -27,10 +27,10 @@ for line in transaction.contentValues(portal_type=['Outgoing Cash Balance Regula ...@@ -27,10 +27,10 @@ for line in transaction.contentValues(portal_type=['Outgoing Cash Balance Regula
res = line.getResourceValue() res = line.getResourceValue()
if res.getPriceCurrency() != doc_resource: if res.getPriceCurrency() != doc_resource:
msg = Message(domain="ui", message="Resource defined on document is different from input cash.") msg = Message(domain="ui", message="Resource defined on document is different from input cash.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if resource_type is not None and res.getPortalType() != resource_type: if resource_type is not None and res.getPortalType() != resource_type:
msg = Message(domain="ui", message="You can't use both banknote and coin on same document.") msg = Message(domain="ui", message="You can't use both banknote and coin on same document.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
resource_type = res.getPortalType() resource_type = res.getPortalType()
# check again that we are in the good accounting date # check again that we are in the good accounting date
...@@ -56,19 +56,19 @@ outgoing_total = transaction.getTotalPrice(portal_type =['Outgoing Cash Balance ...@@ -56,19 +56,19 @@ outgoing_total = transaction.getTotalPrice(portal_type =['Outgoing Cash Balance
if amount != incoming_total: if amount != incoming_total:
msg = Message(domain="ui", message="Amount differ from total price.") msg = Message(domain="ui", message="Amount differ from total price.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if resource_one == 2: if resource_one == 2:
msg = Message(domain="ui", message="No resource.") msg = Message(domain="ui", message="No resource.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource_one == 1: elif resource_one == 1:
msg = Message(domain="ui", message="Insufficient Balance.") msg = Message(domain="ui", message="Insufficient Balance.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if resource_two == 2: if resource_two == 2:
msg = Message(domain="ui", message="No resource.") msg = Message(domain="ui", message="No resource.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if incoming_total != outgoing_total: if incoming_total != outgoing_total:
msg = Message(domain="ui", message="No same balance.") msg = Message(domain="ui", message="No same balance.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -39,16 +39,16 @@ amount_total = transaction.getSourceTotalAssetPrice() ...@@ -39,16 +39,16 @@ amount_total = transaction.getSourceTotalAssetPrice()
if resource_two == 2: if resource_two == 2:
msg = Message(domain="ui", message="No resource.") msg = Message(domain="ui", message="No resource.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource_two == 1: elif resource_two == 1:
msg = Message(domain="ui", message="Insufficient Balance.") msg = Message(domain="ui", message="Insufficient Balance.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if incoming_total != outgoing_total: if incoming_total != outgoing_total:
msg = Message(domain="ui", message="No same balance.") msg = Message(domain="ui", message="No same balance.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if amount_total != outgoing_total: if amount_total != outgoing_total:
msg = Message(domain="ui", message="Amount not correct.") msg = Message(domain="ui", message="Amount not correct.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -14,14 +14,14 @@ transaction.Baobab_checkCounterDateOpen(site=vault, date=transaction.getStartDat ...@@ -14,14 +14,14 @@ transaction.Baobab_checkCounterDateOpen(site=vault, date=transaction.getStartDat
vliste = transaction.checkConsistency() vliste = transaction.checkConsistency()
transaction.log('vliste', vliste) transaction.log('vliste', vliste)
if len(vliste) != 0: if len(vliste) != 0:
raise ValidationFailed, (vliste[0].getMessage(),) raise ValidationFailed(vliste[0].getMessage(),)
portal_type_with_no_space = transaction.getPortalType().replace(' ','') portal_type_with_no_space = transaction.getPortalType().replace(' ','')
check_path_script = getattr(transaction,'%s_checkPath' % portal_type_with_no_space,None) check_path_script = getattr(transaction,'%s_checkPath' % portal_type_with_no_space,None)
if check_path_script is not None: if check_path_script is not None:
message = check_path_script() message = check_path_script()
if message is not None: if message is not None:
raise ValidationFailed, (message,) raise ValidationFailed(message,)
resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_type='Cash Movement New Not Emitted Line') resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_type='Cash Movement New Not Emitted Line')
...@@ -32,10 +32,10 @@ total_price = transaction.getTotalPrice(portal_type=['Cash Movement New Not Emit ...@@ -32,10 +32,10 @@ total_price = transaction.getTotalPrice(portal_type=['Cash Movement New Not Emit
if resource == 2: if resource == 2:
msg = Message(domain="ui", message="No Resource.") msg = Message(domain="ui", message="No Resource.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif amount != total_price: elif amount != total_price:
msg = Message(domain="ui", message="Amount differ from total price.") msg = Message(domain="ui", message="Amount differ from total price.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource <> 0 : elif resource <> 0 :
msg = Message(domain="ui", message="Insufficient Balance.") msg = Message(domain="ui", message="Insufficient Balance.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -8,6 +8,6 @@ transaction = state_change['object'] ...@@ -8,6 +8,6 @@ transaction = state_change['object']
stop_date_key = 'stop_date' stop_date_key = 'stop_date'
if not state_change.kwargs.has_key(stop_date_key): if not state_change.kwargs.has_key(stop_date_key):
msg = Message(domain = "ui", message="No stop date provided") msg = Message(domain = "ui", message="No stop date provided")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
transaction.setStopDate(state_change.kwargs[stop_date_key]) transaction.setStopDate(state_change.kwargs[stop_date_key])
context.validateDestinationCounterDate(state_change, **kw) context.validateDestinationCounterDate(state_change, **kw)
...@@ -9,12 +9,12 @@ vaultDestination = transaction.getDestination() ...@@ -9,12 +9,12 @@ vaultDestination = transaction.getDestination()
if vault is None: if vault is None:
msg = Message(domain="ui", msg = Message(domain="ui",
message="Sorry, you must define a source.") message="Sorry, you must define a source.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if transaction.isCurrencyHandover() and vaultDestination is not None: if transaction.isCurrencyHandover() and vaultDestination is not None:
msg = Message(domain="ui", msg = Message(domain="ui",
message="Sorry, you must not set a destination in case of currency handover.") message="Sorry, you must not set a destination in case of currency handover.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# if not transaction.isCurrencyHandover() and vaultDestination is not None: # if not transaction.isCurrencyHandover() and vaultDestination is not None:
# msg = Message(domain="ui", # msg = Message(domain="ui",
...@@ -24,7 +24,7 @@ if transaction.isCurrencyHandover() and vaultDestination is not None: ...@@ -24,7 +24,7 @@ if transaction.isCurrencyHandover() and vaultDestination is not None:
if not transaction.isCurrencyHandover() and vaultDestination is None: if not transaction.isCurrencyHandover() and vaultDestination is None:
msg = Message(domain="ui", msg = Message(domain="ui",
message="Sorry, you must define a destination.") message="Sorry, you must define a destination.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# use of the constraint : Test source and destination # use of the constraint : Test source and destination
...@@ -46,7 +46,7 @@ if check_path_script is not None: ...@@ -46,7 +46,7 @@ if check_path_script is not None:
message = check_path_script() message = check_path_script()
transaction.log('check_path_script','found') transaction.log('check_path_script','found')
if message is not None: if message is not None:
raise ValidationFailed, (message,) raise ValidationFailed(message,)
resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_type='Cash Delivery Line') resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_type='Cash Delivery Line')
...@@ -57,10 +57,10 @@ total_price = transaction.getTotalPrice(portal_type=['Cash Delivery Line','Cash ...@@ -57,10 +57,10 @@ total_price = transaction.getTotalPrice(portal_type=['Cash Delivery Line','Cash
if resource == 2: if resource == 2:
msg = Message(domain="ui", message="No Resource.") msg = Message(domain="ui", message="No Resource.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif amount != total_price: elif amount != total_price:
msg = Message(domain="ui", message="Amount differ from total price.") msg = Message(domain="ui", message="Amount differ from total price.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource <> 0 : elif resource <> 0 :
msg = Message(domain="ui", message="Insufficient Balance.") msg = Message(domain="ui", message="Insufficient Balance.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -18,4 +18,4 @@ for resource, total_quantity in resource_dict.items(): ...@@ -18,4 +18,4 @@ for resource, total_quantity in resource_dict.items():
resource_value = portal.restrictedTraverse(resource) resource_value = portal.restrictedTraverse(resource)
message = Message(domain='ui', message="Sorry, you must have a quantity of 1 for : $resource_title", message = Message(domain='ui', message="Sorry, you must have a quantity of 1 for : $resource_title",
mapping={'resource_title': resource_value.getTranslatedTitle()}) mapping={'resource_title': resource_value.getTranslatedTitle()})
raise ValidationFailed, message raise ValidationFailed(message)
...@@ -6,7 +6,7 @@ transaction = state_change['object'] ...@@ -6,7 +6,7 @@ transaction = state_change['object']
# use of the constraint : Test if quantity is multiple of 1000 # use of the constraint : Test if quantity is multiple of 1000
vliste = transaction.checkConsistency() vliste = transaction.checkConsistency()
if len(vliste) != 0: if len(vliste) != 0:
raise ValidationFailed, (vliste[0].getMessage(),) raise ValidationFailed(vliste[0].getMessage(),)
# check again that we are in the good accounting date # check again that we are in the good accounting date
vault = transaction.getSource() vault = transaction.getSource()
...@@ -23,10 +23,10 @@ resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_ ...@@ -23,10 +23,10 @@ resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_
if input_cash != output_cash : if input_cash != output_cash :
msg=Message(domain="ui", message="Incoming cash amount is different from outgoing cash amount.") msg=Message(domain="ui", message="Incoming cash amount is different from outgoing cash amount.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif price != output_cash : elif price != output_cash :
msg=Message(domain='ui',message='Amount differs from cash total.') msg=Message(domain='ui',message='Amount differs from cash total.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource != 0 : elif resource != 0 :
msg=Message(domain='ui',message='Insufficient Balance.') msg=Message(domain='ui',message='Insufficient Balance.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -22,10 +22,10 @@ output_cash = transaction.getTotalPrice(portal_type=['Outgoing Classification Su ...@@ -22,10 +22,10 @@ output_cash = transaction.getTotalPrice(portal_type=['Outgoing Classification Su
if input_cash != output_cash : if input_cash != output_cash :
msg=Message(domain="ui", message="Incoming cash amount is different from outgoing cash amount.") msg=Message(domain="ui", message="Incoming cash amount is different from outgoing cash amount.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif price != output_cash : elif price != output_cash :
msg=Message(domain='ui',message='Amount differs from cash total.') msg=Message(domain='ui',message='Amount differs from cash total.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource != 0 : elif resource != 0 :
msg=Message(domain='ui',message='Insufficient Balance.') msg=Message(domain='ui',message='Insufficient Balance.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -26,10 +26,10 @@ total_price = transaction.getTotalPrice(portal_type=['Cash Delivery Line','Cash ...@@ -26,10 +26,10 @@ total_price = transaction.getTotalPrice(portal_type=['Cash Delivery Line','Cash
if resource == 2: if resource == 2:
msg = Message(domain="ui", message="No Resource.") msg = Message(domain="ui", message="No Resource.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif amount != total_price: elif amount != total_price:
msg = Message(domain="ui", message="Amount differ from total price.") msg = Message(domain="ui", message="Amount differ from total price.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource <> 0 : elif resource <> 0 :
msg = Message(domain="ui", message="Insufficient Balance.") msg = Message(domain="ui", message="Insufficient Balance.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -15,10 +15,10 @@ total_price = transaction.getTotalPrice(portal_type=['Cash Delivery Line','Cash ...@@ -15,10 +15,10 @@ total_price = transaction.getTotalPrice(portal_type=['Cash Delivery Line','Cash
if resource == 2: if resource == 2:
msg = Message(domain="ui", message="No Resource.") msg = Message(domain="ui", message="No Resource.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif amount != total_price: elif amount != total_price:
msg = Message(domain="ui", message="Amount differ from total price.") msg = Message(domain="ui", message="Amount differ from total price.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource <> 0 : elif resource <> 0 :
msg = Message(domain="ui", message="Insufficient Balance.") msg = Message(domain="ui", message="Insufficient Balance.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -9,18 +9,18 @@ transaction = state_change['object'] ...@@ -9,18 +9,18 @@ transaction = state_change['object']
vliste = object.checkConsistency() vliste = object.checkConsistency()
object.log('vliste', vliste) object.log('vliste', vliste)
if len(vliste) != 0: if len(vliste) != 0:
raise ValidationFailed, (vliste[0].getMessage(),) raise ValidationFailed(vliste[0].getMessage(),)
dest = object.getDestination() dest = object.getDestination()
# check again that we are in the good accounting date # check again that we are in the good accounting date
transaction.Baobab_checkCounterDateOpen(site=dest, date=transaction.getStartDate()) transaction.Baobab_checkCounterDateOpen(site=dest, date=transaction.getStartDate())
if not 'encaisse_des_devises' in object.getDestination(): if not 'encaisse_des_devises' in object.getDestination():
msg = Message(domain="ui", message="Wrong Destination Selected.") msg = Message(domain="ui", message="Wrong Destination Selected.")
raise validationFailed, (msg,) raise validationFailed(msg,)
object_price = object.getSourceTotalAssetPrice() object_price = object.getSourceTotalAssetPrice()
line_price = object.getTotalPrice(portal_type=['Cash Delivery Line','Cash Delivery Cell'],fast=0) line_price = object.getTotalPrice(portal_type=['Cash Delivery Line','Cash Delivery Cell'],fast=0)
if object_price != line_price: if object_price != line_price:
msg = Message(domain="ui", message="Amount differs between document and lines.") msg = Message(domain="ui", message="Amount differs between document and lines.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -7,13 +7,13 @@ total_cash = delivery.getTotalPrice(fast=0,portal_type=('Cash Delivery Line','Ca ...@@ -7,13 +7,13 @@ total_cash = delivery.getTotalPrice(fast=0,portal_type=('Cash Delivery Line','Ca
if len(delivery.objectValues(portal_type="Cash Delivery Line")) == 0: if len(delivery.objectValues(portal_type="Cash Delivery Line")) == 0:
msg=Message(domain='ui',message='No resource defined.') msg=Message(domain='ui',message='No resource defined.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if total_cash != delivery.getSourceTotalAssetPrice(): if total_cash != delivery.getSourceTotalAssetPrice():
msg=Message(domain='ui',message='Amount differs from cash total.') msg=Message(domain='ui',message='Amount differs from cash total.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
historical_operation_type = delivery.getHistoricalOperationTypeValue() historical_operation_type = delivery.getHistoricalOperationTypeValue()
if historical_operation_type is None: if historical_operation_type is None:
msg=Message(domain='ui',message='You must define an historical operation type.') msg=Message(domain='ui',message='You must define an historical operation type.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -16,7 +16,7 @@ context.Baobab_checkCounterOpened(destination) ...@@ -16,7 +16,7 @@ context.Baobab_checkCounterOpened(destination)
if transaction.getResource() is None: if transaction.getResource() is None:
msg = Message(domain="ui", message="No resource defined.") msg = Message(domain="ui", message="No resource defined.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Check getBaobabSource and getBaobabDestination # Check getBaobabSource and getBaobabDestination
#transaction.Base_checkBaobabSourceAndDestination() #transaction.Base_checkBaobabSourceAndDestination()
...@@ -29,11 +29,11 @@ lettering = transaction.getGroupingReference() ...@@ -29,11 +29,11 @@ lettering = transaction.getGroupingReference()
if lettering is None: if lettering is None:
msg = Message(domain='ui', message='No lettering defined.') msg = Message(domain='ui', message='No lettering defined.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if destination is None: if destination is None:
msg = Message(domain='ui', message='No counter defined.') msg = Message(domain='ui', message='No counter defined.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -43,4 +43,4 @@ cash_detail = transaction.getTotalPrice(portal_type = ['Cash Delivery Line', 'Ca ...@@ -43,4 +43,4 @@ cash_detail = transaction.getTotalPrice(portal_type = ['Cash Delivery Line', 'Ca
if price != cash_detail: if price != cash_detail:
msg = Message(domain="ui", message="Amount differs from input.") msg = Message(domain="ui", message="Amount differs from input.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -16,7 +16,7 @@ context.Baobab_checkCounterOpened(source) ...@@ -16,7 +16,7 @@ context.Baobab_checkCounterOpened(source)
if transaction.getPaymentType() in (None, ""): if transaction.getPaymentType() in (None, ""):
msg = Message(domain="ui", message="No payment type defined.") msg = Message(domain="ui", message="No payment type defined.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
#test if the source or the destination is correct #test if the source or the destination is correct
...@@ -28,11 +28,11 @@ total_price = transaction.getTotalPrice(portal_type=('Cash Delivery Line','Cash ...@@ -28,11 +28,11 @@ total_price = transaction.getTotalPrice(portal_type=('Cash Delivery Line','Cash
if amount != total_price: if amount != total_price:
msg = Message(domain="ui", message="Amount differ from total price.") msg = Message(domain="ui", message="Amount differ from total price.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if source is None: if source is None:
msg = Message(domain='ui', message='No counter defined.') msg = Message(domain='ui', message='No counter defined.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -47,4 +47,4 @@ resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_t ...@@ -47,4 +47,4 @@ resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_t
if resource == 2: if resource == 2:
msg = Message(domain="ui", message="No Resource.") msg = Message(domain="ui", message="No Resource.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -8,6 +8,6 @@ transaction = state_change['object'] ...@@ -8,6 +8,6 @@ transaction = state_change['object']
stop_date_key = 'stop_date' stop_date_key = 'stop_date'
if not state_change.kwargs.has_key(stop_date_key): if not state_change.kwargs.has_key(stop_date_key):
msg = Message(domain = "ui", message="No stop date provided") msg = Message(domain = "ui", message="No stop date provided")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
transaction.setStopDate(state_change.kwargs[stop_date_key]) transaction.setStopDate(state_change.kwargs[stop_date_key])
context.validateDestinationCounterDate(state_change, **kw) context.validateDestinationCounterDate(state_change, **kw)
...@@ -13,13 +13,13 @@ if check_source_counter_date: ...@@ -13,13 +13,13 @@ if check_source_counter_date:
if 'encaisse_des_externes' not in vault and \ if 'encaisse_des_externes' not in vault and \
'encaisse_des_billets_retires_de_la_circulation' not in vault: 'encaisse_des_billets_retires_de_la_circulation' not in vault:
msg = Message(domain="ui", message="Invalid source.") msg = Message(domain="ui", message="Invalid source.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if 'encaisse_des_externes' in vault: if 'encaisse_des_externes' in vault:
source_section = transaction.getSourceSection() source_section = transaction.getSourceSection()
if source_section is None: if source_section is None:
msg = Message(domain="ui", message="Invalid Foreign Agency.") msg = Message(domain="ui", message="Invalid Foreign Agency.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# In case of dematerialization, we must have only coins # In case of dematerialization, we must have only coins
...@@ -27,43 +27,43 @@ if transaction.isDematerialization(): ...@@ -27,43 +27,43 @@ if transaction.isDematerialization():
for line in transaction.objectValues(portal_type='Monetary Destruction Line'): for line in transaction.objectValues(portal_type='Monetary Destruction Line'):
if line.getResourceValue().getPortalType() != 'Coin': if line.getResourceValue().getPortalType() != 'Coin':
msg = Message(domain="ui", message="Sorry, dematerialization is possible only with coins.") msg = Message(domain="ui", message="Sorry, dematerialization is possible only with coins.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Not possible from auxiliary agency # Not possible from auxiliary agency
if 'auxiliaire' in vault: if 'auxiliaire' in vault:
msg = Message(domain="ui", message="You can't do this operation on auxiliary site.") msg = Message(domain="ui", message="You can't do this operation on auxiliary site.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Also we must make sure that the source_section is defined # Also we must make sure that the source_section is defined
source_section = transaction.getSourceSection() source_section = transaction.getSourceSection()
if source_section is None: if source_section is None:
msg = Message(domain="ui", message="Sorry, dematerialization is possible only if the external agency is defined.") msg = Message(domain="ui", message="Sorry, dematerialization is possible only if the external agency is defined.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if 'encaisse_des_billets_retires_de_la_circulation' not in vault: if 'encaisse_des_billets_retires_de_la_circulation' not in vault:
msg = Message(domain="ui", message="Invalid source.") msg = Message(domain="ui", message="Invalid source.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if source_section in source_object.getPath(): if source_section in source_object.getPath():
msg = Message(domain="ui", message="You can't used this site.") msg = Message(domain="ui", message="You can't used this site.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Check specific for auxiliary agencies # Check specific for auxiliary agencies
elif "principale" not in vault: elif "principale" not in vault:
site = transaction.getSourceSection() site = transaction.getSourceSection()
if site in (None, ""): if site in (None, ""):
msg = Message(domain="ui", message="You must select a foreign agency.") msg = Message(domain="ui", message="You must select a foreign agency.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
source_country_site = transaction.Baobab_getVaultSite(source_object) source_country_site = transaction.Baobab_getVaultSite(source_object)
source_country = transaction.Baobab_getCountryForSite(source_country_site) source_country = transaction.Baobab_getCountryForSite(source_country_site)
site_country = transaction.Baobab_getCountryForSite(site) site_country = transaction.Baobab_getCountryForSite(site)
if 'encaisse_des_externes' in vault and \ if 'encaisse_des_externes' in vault and \
site_country == source_country: site_country == source_country:
msg = Message(domain="ui", message="You must select an agency from a foreign country.") msg = Message(domain="ui", message="You must select an agency from a foreign country.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif 'encaisse_des_billets_retires_de_la_circulation' in vault and \ elif 'encaisse_des_billets_retires_de_la_circulation' in vault and \
site_country != source_country: site_country != source_country:
msg = Message(domain="ui", message="You must select an agency from the same country.") msg = Message(domain="ui", message="You must select an agency from the same country.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Get price and total_price. # Get price and total_price.
...@@ -73,10 +73,10 @@ resource = transaction.CashDelivery_checkCounterInventory(source=source_object.g ...@@ -73,10 +73,10 @@ resource = transaction.CashDelivery_checkCounterInventory(source=source_object.g
if resource == 2: if resource == 2:
msg = Message(domain="ui", message="No Resource.") msg = Message(domain="ui", message="No Resource.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif amount != total_price: elif amount != total_price:
msg = Message(domain="ui", message="Amount differ from total price.") msg = Message(domain="ui", message="Amount differ from total price.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource <> 0 : elif resource <> 0 :
msg = Message(domain="ui", message="Insufficient Balance.") msg = Message(domain="ui", message="Insufficient Balance.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -7,7 +7,7 @@ transaction = state_change['object'] ...@@ -7,7 +7,7 @@ transaction = state_change['object']
vliste = transaction.checkConsistency() vliste = transaction.checkConsistency()
transaction.log('vliste', vliste) transaction.log('vliste', vliste)
if len(vliste) != 0: if len(vliste) != 0:
raise ValidationFailed, (vliste[0].getMessage(),) raise ValidationFailed(vliste[0].getMessage(),)
vault = transaction.getSource() vault = transaction.getSource()
resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_type='Monetary Issue Line') resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_type='Monetary Issue Line')
...@@ -21,10 +21,10 @@ total_price = transaction.getTotalPrice(portal_type=['Monetary Issue Line','Cash ...@@ -21,10 +21,10 @@ total_price = transaction.getTotalPrice(portal_type=['Monetary Issue Line','Cash
if resource == 2: if resource == 2:
msg = Message(domain="ui", message="No Resource.") msg = Message(domain="ui", message="No Resource.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif amount != total_price: elif amount != total_price:
msg = Message(domain="ui", message="Amount differ from total price.") msg = Message(domain="ui", message="Amount differ from total price.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource <> 0 : elif resource <> 0 :
msg = Message(domain="ui", message="Insufficient Balance.") msg = Message(domain="ui", message="Insufficient Balance.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -7,7 +7,7 @@ vault = transaction.getSource() ...@@ -7,7 +7,7 @@ vault = transaction.getSource()
if ('encaisse_des_billets_et_monnaies' not in vault): if ('encaisse_des_billets_et_monnaies' not in vault):
msg = Message(domain="ui", message="Invalid source.") msg = Message(domain="ui", message="Invalid source.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_type='Monetary Recall Line') resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_type='Monetary Recall Line')
...@@ -25,10 +25,10 @@ total_price = transaction.getTotalPrice(portal_type=['Monetary Recall Line','Cas ...@@ -25,10 +25,10 @@ total_price = transaction.getTotalPrice(portal_type=['Monetary Recall Line','Cas
if resource == 2: if resource == 2:
msg = Message(domain="ui", message="No Resource.") msg = Message(domain="ui", message="No Resource.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif amount != total_price: elif amount != total_price:
msg = Message(domain="ui", message="Amount differ from total price.") msg = Message(domain="ui", message="Amount differ from total price.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource <> 0 : elif resource <> 0 :
msg = Message(domain="ui", message="Insufficient Balance.") msg = Message(domain="ui", message="Insufficient Balance.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -7,18 +7,18 @@ object = state_change['object'] ...@@ -7,18 +7,18 @@ object = state_change['object']
vliste = object.checkConsistency() vliste = object.checkConsistency()
object.log('vliste', vliste) object.log('vliste', vliste)
if len(vliste) != 0: if len(vliste) != 0:
raise ValidationFailed, (vliste[0].getMessage(),) raise ValidationFailed(vliste[0].getMessage(),)
# first check if we have line defined # first check if we have line defined
if len(object.objectValues(portal_type='Cash Delivery Line')) == 0: if len(object.objectValues(portal_type='Cash Delivery Line')) == 0:
msg = Message(domain="ui", message="No line defined on document.") msg = Message(domain="ui", message="No line defined on document.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
dest = object.getDestinationValue() dest = object.getDestinationValue()
if dest is None or 'encaisse_des_billets_retires_de_la_circulation' in dest.getRelativeUrl(): if dest is None or 'encaisse_des_billets_retires_de_la_circulation' in dest.getRelativeUrl():
msg = Message(domain="ui", message="Wrong Destination Selected.") msg = Message(domain="ui", message="Wrong Destination Selected.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# check again that we are in the good accounting date # check again that we are in the good accounting date
object.Baobab_checkCounterDateOpen(site=dest, date=object.getStartDate()) object.Baobab_checkCounterDateOpen(site=dest, date=object.getStartDate())
...@@ -32,4 +32,4 @@ if 'transit' not in dest.getRelativeUrl(): ...@@ -32,4 +32,4 @@ if 'transit' not in dest.getRelativeUrl():
line_letter = first_movement.getEmissionLetter() line_letter = first_movement.getEmissionLetter()
if line_letter.lower() != dest.getCodification()[0].lower(): if line_letter.lower() != dest.getCodification()[0].lower():
msg = Message(domain="ui", message="Letter defined on line do not correspond to destination site.") msg = Message(domain="ui", message="Letter defined on line do not correspond to destination site.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -8,7 +8,7 @@ destination = transaction.getDestination() ...@@ -8,7 +8,7 @@ destination = transaction.getDestination()
if vault is None or destination is None: if vault is None or destination is None:
msg = Message(domain="ui", message="You must define source and destination.") msg = Message(domain="ui", message="You must define source and destination.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# check we are in an opened accounting day # check we are in an opened accounting day
...@@ -16,19 +16,19 @@ transaction.Baobab_checkCounterDateOpen(site=vault, date=date) ...@@ -16,19 +16,19 @@ transaction.Baobab_checkCounterDateOpen(site=vault, date=date)
if ('encaisse_des_billets_et_monnaies' not in vault) and ('encaisse_des_billets_a_ventiler_et_a_detruire' not in vault): if ('encaisse_des_billets_et_monnaies' not in vault) and ('encaisse_des_billets_a_ventiler_et_a_detruire' not in vault):
msg = Message(domain="ui", message="Invalid source.") msg = Message(domain="ui", message="Invalid source.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if ('encaisse_des_billets_et_monnaies' not in destination) and ('encaisse_des_billets_a_ventiler_et_a_detruire' not in destination): if ('encaisse_des_billets_et_monnaies' not in destination) and ('encaisse_des_billets_a_ventiler_et_a_detruire' not in destination):
msg = Message(domain="ui", message="Invalid destination.") msg = Message(domain="ui", message="Invalid destination.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if ('encaisse_des_billets_et_monnaies' in vault) and ('encaisse_des_billets_a_ventiler_et_a_detruire' not in destination): if ('encaisse_des_billets_et_monnaies' in vault) and ('encaisse_des_billets_a_ventiler_et_a_detruire' not in destination):
msg = Message(domain="ui", message="Impossible Monetary Survey.") msg = Message(domain="ui", message="Impossible Monetary Survey.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if ('encaisse_des_billets_a_ventiler_et_a_detruire' in vault) and ('encaisse_des_billets_et_monnaies' not in destination): if ('encaisse_des_billets_a_ventiler_et_a_detruire' in vault) and ('encaisse_des_billets_et_monnaies' not in destination):
msg = Message(domain="ui", message="Impossible Monetary Survey Reintregration.") msg = Message(domain="ui", message="Impossible Monetary Survey Reintregration.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_type='Cash Delivery Line') resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_type='Cash Delivery Line')
# Get price and total_price. # Get price and total_price.
...@@ -37,10 +37,10 @@ total_price = transaction.getTotalPrice(portal_type=['Cash Delivery Line','Cash ...@@ -37,10 +37,10 @@ total_price = transaction.getTotalPrice(portal_type=['Cash Delivery Line','Cash
if resource == 2: if resource == 2:
msg = Message(domain="ui", message="No Resource.") msg = Message(domain="ui", message="No Resource.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif amount != total_price: elif amount != total_price:
msg = Message(domain="ui", message="Amount differ from total price.") msg = Message(domain="ui", message="Amount differ from total price.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource <> 0 : elif resource <> 0 :
msg = Message(domain="ui", message="Insufficient Balance.") msg = Message(domain="ui", message="Insufficient Balance.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -22,10 +22,10 @@ total_price = transaction.getTotalPrice(portal_type=['Cash Delivery Line','Cash ...@@ -22,10 +22,10 @@ total_price = transaction.getTotalPrice(portal_type=['Cash Delivery Line','Cash
if resource == 2: if resource == 2:
msg = Message(domain="ui", message="No Resource.") msg = Message(domain="ui", message="No Resource.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif amount != total_price: elif amount != total_price:
msg = Message(domain="ui", message="Amount differ from total price.") msg = Message(domain="ui", message="Amount differ from total price.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource <> 0 : elif resource <> 0 :
msg = Message(domain="ui", message="Insufficient Balance.") msg = Message(domain="ui", message="Insufficient Balance.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -9,12 +9,12 @@ transaction.log('destination:',destination) ...@@ -9,12 +9,12 @@ transaction.log('destination:',destination)
amount = transaction.getSourceTotalAssetPrice() amount = transaction.getSourceTotalAssetPrice()
if amount is None: if amount is None:
msg = Message(domain="ui", message="Sorry, you have to define a quantity.") msg = Message(domain="ui", message="Sorry, you have to define a quantity.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
destination_payment = transaction.getDestinationPayment() destination_payment = transaction.getDestinationPayment()
if destination_payment is None: if destination_payment is None:
msg = Message(domain="ui", message="Sorry, you have to define an account.") msg = Message(domain="ui", message="Sorry, you have to define an account.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
var_state = transaction.getSimulationState() var_state = transaction.getSimulationState()
if var_state == 'confirmed': if var_state == 'confirmed':
...@@ -24,11 +24,11 @@ if var_state == 'confirmed': ...@@ -24,11 +24,11 @@ if var_state == 'confirmed':
if amount != total_price: if amount != total_price:
msg = Message(domain="ui", message="Amount differ from total price.") msg = Message(domain="ui", message="Amount differ from total price.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if destination is None: if destination is None:
msg = Message(domain='ui', message='No counter defined.') msg = Message(domain='ui', message='No counter defined.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# check we are in an opened accounting day # check we are in an opened accounting day
......
...@@ -40,10 +40,10 @@ cash_detail = transaction.getTotalPrice(portal_type=['Cash Delivery Line','Cash ...@@ -40,10 +40,10 @@ cash_detail = transaction.getTotalPrice(portal_type=['Cash Delivery Line','Cash
#transaction.log("price vs cash detail", str((price, cash_detail))) #transaction.log("price vs cash detail", str((price, cash_detail)))
if resource == 3: if resource == 3:
msg = Message(domain="ui", message="No banknote or coin defined.") msg = Message(domain="ui", message="No banknote or coin defined.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource == 2: elif resource == 2:
msg = Message(domain="ui", message="No resource defined.") msg = Message(domain="ui", message="No resource defined.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif price != cash_detail: elif price != cash_detail:
msg = Message(domain="ui", message="Amount differs from input.") msg = Message(domain="ui", message="Amount differs from input.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -18,15 +18,15 @@ for outgoing_line in ob.objectValues(portal_type="Outgoing Mutilated Banknote Li ...@@ -18,15 +18,15 @@ for outgoing_line in ob.objectValues(portal_type="Outgoing Mutilated Banknote Li
if len(ob.objectValues(portal_type="Outgoing Mutilated Banknote Line")) == 0: if len(ob.objectValues(portal_type="Outgoing Mutilated Banknote Line")) == 0:
msg = Message(domain = "ui", message="You must defined returned banknote.") msg = Message(domain = "ui", message="You must defined returned banknote.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if ob.getDestinationTotalAssetPrice() != ob.getTotalPrice(portal_type="Outgoing Mutilated Banknote Line", fast=0): if ob.getDestinationTotalAssetPrice() != ob.getTotalPrice(portal_type="Outgoing Mutilated Banknote Line", fast=0):
msg = Message(domain = "ui", message="Returned value different from exchanged value.") msg = Message(domain = "ui", message="Returned value different from exchanged value.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# now check balance # now check balance
resource = ob.CashDelivery_checkCounterInventory(source=vault, portal_type='Outgoing Mutilated Banknote Line', same_source=1) resource = ob.CashDelivery_checkCounterInventory(source=vault, portal_type='Outgoing Mutilated Banknote Line', same_source=1)
if resource == 2: if resource == 2:
msg = Message(domain="ui", message="No Returned banknote defined.") msg = Message(domain="ui", message="No Returned banknote defined.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource <> 0 : elif resource <> 0 :
msg = Message(domain="ui", message="Insufficient Balance.") msg = Message(domain="ui", message="Insufficient Balance.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -12,14 +12,14 @@ for exchanged_line in ob.objectValues(portal_type='Exchanged Mutilated Banknote ...@@ -12,14 +12,14 @@ for exchanged_line in ob.objectValues(portal_type='Exchanged Mutilated Banknote
if ob.getDestinationTotalAssetPrice() == 0: if ob.getDestinationTotalAssetPrice() == 0:
msg = Message(domain = "ui", message="Exchanged amount must be defined on document.") msg = Message(domain = "ui", message="Exchanged amount must be defined on document.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if len(ob.objectValues(portal_type='Exchanged Mutilated Banknote Line')) == 0: if len(ob.objectValues(portal_type='Exchanged Mutilated Banknote Line')) == 0:
msg = Message(domain = "ui", message="You must defined exchanged banknote line.") msg = Message(domain = "ui", message="You must defined exchanged banknote line.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
exchanged_mutilated_banknote_total_price = ob.getTotalPrice(portal_type='Exchanged Mutilated Banknote Line', fast=0) exchanged_mutilated_banknote_total_price = ob.getTotalPrice(portal_type='Exchanged Mutilated Banknote Line', fast=0)
if exchanged_mutilated_banknote_total_price > ob.getTotalPrice(portal_type='Incoming Mutilated Banknote Line', fast=0): if exchanged_mutilated_banknote_total_price > ob.getTotalPrice(portal_type='Incoming Mutilated Banknote Line', fast=0):
msg = Message(domain = "ui", message="Total exchanged greater than total supply.") msg = Message(domain = "ui", message="Total exchanged greater than total supply.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if exchanged_mutilated_banknote_total_price != ob.getDestinationTotalAssetPrice(): if exchanged_mutilated_banknote_total_price != ob.getDestinationTotalAssetPrice():
msg = Message(domain = "ui", message="Exchanged amount differ between line and document.") msg = Message(domain = "ui", message="Exchanged amount differ between line and document.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -6,4 +6,4 @@ ob = state_change['object'] ...@@ -6,4 +6,4 @@ ob = state_change['object']
# check presence of banknote # check presence of banknote
if len(ob.objectValues(portal_type="Exchanged Mutilated Banknote Line")) != 0: if len(ob.objectValues(portal_type="Exchanged Mutilated Banknote Line")) != 0:
msg = Message(domain = "ui", message="Transition forbidden with exchanged banknote line defined.") msg = Message(domain = "ui", message="Transition forbidden with exchanged banknote line defined.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -10,19 +10,19 @@ ob.Baobab_checkCounterDateOpen(site=ob.getSource(), date=ob.getStartDate()) ...@@ -10,19 +10,19 @@ ob.Baobab_checkCounterDateOpen(site=ob.getSource(), date=ob.getStartDate())
# check presence of banknote # check presence of banknote
if len(ob.objectValues()) == 0: if len(ob.objectValues()) == 0:
msg = Message(domain = "ui", message="No mutilated banknotes defined.") msg = Message(domain = "ui", message="No mutilated banknotes defined.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# check price defined # check price defined
if ob.getSourceTotalAssetPrice() != ob.getTotalPrice(portal_type='Incoming Mutilated Banknote Line', fast=0): if ob.getSourceTotalAssetPrice() != ob.getTotalPrice(portal_type='Incoming Mutilated Banknote Line', fast=0):
msg = Message(domain = "ui", message="Amount differ between document and line.") msg = Message(domain = "ui", message="Amount differ between document and line.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# check reporter defined # check reporter defined
if ob.getDeponent() in (None, ""): if ob.getDeponent() in (None, ""):
msg = Message(domain = "ui", message="You must define a reporter.") msg = Message(domain = "ui", message="You must define a reporter.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# check original site defined is hq # check original site defined is hq
if "siege" in ob.getSource() and ob.getSourceTrade() is None: if "siege" in ob.getSource() and ob.getSourceTrade() is None:
msg = Message(domain = "ui", message="You must define the original site.") msg = Message(domain = "ui", message="You must define the original site.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -9,7 +9,7 @@ vaultDestination = transaction.getDestination() ...@@ -9,7 +9,7 @@ vaultDestination = transaction.getDestination()
# use of the constraint # use of the constraint
vliste = transaction.checkConsistency() vliste = transaction.checkConsistency()
if len(vliste) != 0: if len(vliste) != 0:
raise ValidationFailed, (vliste[0].getTranslatedMessage(),) raise ValidationFailed(vliste[0].getTranslatedMessage(),)
# check we are in an opened accounting day # check we are in an opened accounting day
transaction.Baobab_checkCounterDateOpen(site=vault, date=date) transaction.Baobab_checkCounterDateOpen(site=vault, date=date)
...@@ -19,7 +19,7 @@ if 'reserve' in vault and 'salle_tri' in vaultDestination: ...@@ -19,7 +19,7 @@ if 'reserve' in vault and 'salle_tri' in vaultDestination:
mapping={'source':transaction.getSourceValue().getParentValue().getTitle(), mapping={'source':transaction.getSourceValue().getParentValue().getTitle(),
'destination':transaction.getDestinationValue().getParentValue().getTitle()}) 'destination':transaction.getDestinationValue().getParentValue().getTitle()})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_type='Cash Delivery Line') resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_type='Cash Delivery Line')
# Get price and total_price. # Get price and total_price.
...@@ -28,10 +28,10 @@ total_price = transaction.getTotalPrice(portal_type=['Cash Delivery Line','Cash ...@@ -28,10 +28,10 @@ total_price = transaction.getTotalPrice(portal_type=['Cash Delivery Line','Cash
if resource == 2: if resource == 2:
msg = Message(domain="ui", message="No Resource.") msg = Message(domain="ui", message="No Resource.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif amount != total_price: elif amount != total_price:
msg = Message(domain="ui", message="Amount differ from total price.") msg = Message(domain="ui", message="Amount differ from total price.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource <> 0 : elif resource <> 0 :
msg = Message(domain="ui", message="Insufficient Balance.") msg = Message(domain="ui", message="Insufficient Balance.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -19,7 +19,7 @@ context.Baobab_checkCounterOpened(source_counter) ...@@ -19,7 +19,7 @@ context.Baobab_checkCounterOpened(source_counter)
vliste = transaction.checkConsistency() vliste = transaction.checkConsistency()
transaction.log('vliste', vliste) transaction.log('vliste', vliste)
if len(vliste) != 0: if len(vliste) != 0:
raise ValidationFailed, (vliste[0].getMessage(),) raise ValidationFailed(vliste[0].getMessage(),)
resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_type='Cash Delivery Line') resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_type='Cash Delivery Line')
...@@ -29,10 +29,10 @@ total_price = transaction.getTotalPrice(portal_type=['Cash Delivery Line','Cash ...@@ -29,10 +29,10 @@ total_price = transaction.getTotalPrice(portal_type=['Cash Delivery Line','Cash
if resource == 2: if resource == 2:
msg = Message(domain="ui", message="No Resource.") msg = Message(domain="ui", message="No Resource.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif amount != total_price: elif amount != total_price:
msg = Message(domain="ui", message="Amount differ from total price.") msg = Message(domain="ui", message="Amount differ from total price.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource <> 0 : elif resource <> 0 :
msg = Message(domain="ui", message="Insufficient Balance.") msg = Message(domain="ui", message="Insufficient Balance.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -8,13 +8,13 @@ vaultDestination = transaction.getDestination() ...@@ -8,13 +8,13 @@ vaultDestination = transaction.getDestination()
if vault is None or vaultDestination is None: if vault is None or vaultDestination is None:
msg = Message(domain="ui", message="You must define vaults.") msg = Message(domain="ui", message="You must define vaults.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# use of the constraint : Test source and destination # use of the constraint : Test source and destination
vliste = transaction.checkConsistency() vliste = transaction.checkConsistency()
transaction.log('vliste', vliste) transaction.log('vliste', vliste)
if len(vliste) != 0: if len(vliste) != 0:
raise ValidationFailed, (vliste[0].getMessage(),) raise ValidationFailed(vliste[0].getMessage(),)
# check we are in an opened accounting day # check we are in an opened accounting day
transaction.Baobab_checkCounterDateOpen(site=vaultDestination, date=date) transaction.Baobab_checkCounterDateOpen(site=vaultDestination, date=date)
...@@ -25,7 +25,7 @@ if 'reserve' in vault and 'salle_tri' in vaultDestination: ...@@ -25,7 +25,7 @@ if 'reserve' in vault and 'salle_tri' in vaultDestination:
mapping={'source':transaction.getSourceValue().getParentValue().getTitle(), mapping={'source':transaction.getSourceValue().getParentValue().getTitle(),
'destination':transaction.getDestinationValue().getParentValue().getTitle()}) 'destination':transaction.getDestinationValue().getParentValue().getTitle()})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_type='Vault Transfer Line') resource = transaction.CashDelivery_checkCounterInventory(source=vault, portal_type='Vault Transfer Line')
# Get price and total_price. # Get price and total_price.
...@@ -34,10 +34,10 @@ total_price = transaction.getTotalPrice(portal_type=['Vault Transfer Line','Vaul ...@@ -34,10 +34,10 @@ total_price = transaction.getTotalPrice(portal_type=['Vault Transfer Line','Vaul
if resource == 2: if resource == 2:
msg = Message(domain="ui", message="No Resource.") msg = Message(domain="ui", message="No Resource.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif amount != total_price: elif amount != total_price:
msg = Message(domain="ui", message="Amount differ from total price.") msg = Message(domain="ui", message="Amount differ from total price.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource <> 0 : elif resource <> 0 :
msg = Message(domain="ui", message="Insufficient Balance.") msg = Message(domain="ui", message="Insufficient Balance.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -43,7 +43,7 @@ def CheckbookReception_importItemFile(self, import_file=None, REQUEST=None, **kw ...@@ -43,7 +43,7 @@ def CheckbookReception_importItemFile(self, import_file=None, REQUEST=None, **kw
'Check Model'], 'Check Model'],
reference = reference_dict[checkbook_type]) reference = reference_dict[checkbook_type])
if len(resource_list) != 1: if len(resource_list) != 1:
raise ValueError, "The import does not support this type : %s" % checkbook_type raise ValueError("The import does not support this type : %s" % checkbook_type)
resource = resource_list[0].getObject() resource = resource_list[0].getObject()
resource_relative_url = resource.getRelativeUrl() resource_relative_url = resource.getRelativeUrl()
resource_amount_dict = {} resource_amount_dict = {}
......
...@@ -18,6 +18,6 @@ if simulation_state != 'confirmed': ...@@ -18,6 +18,6 @@ if simulation_state != 'confirmed':
msg = Message(domain='ui', message=bad_simulation_state_dict[simulation_state]) msg = Message(domain='ui', message=bad_simulation_state_dict[simulation_state])
else: else:
msg = 'Invalid and unhandled simulation state: %s' % (simulation_state, ) msg = 'Invalid and unhandled simulation state: %s' % (simulation_state, )
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
return check return check
...@@ -15,11 +15,11 @@ if bank_account is None: ...@@ -15,11 +15,11 @@ if bank_account is None:
if bank_account is None: if bank_account is None:
msg = Message(domain='ui',message='Sorry, you must select an account') msg = Message(domain='ui',message='Sorry, you must select an account')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if resource is None: if resource is None:
msg = Message(domain='ui',message='Sorry, you must select a resource') msg = Message(domain='ui',message='Sorry, you must select a resource')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if reference is not None: if reference is not None:
reference_list = [reference] reference_list = [reference]
...@@ -38,11 +38,11 @@ elif reference_range_min is not None or reference_range_max is not None: ...@@ -38,11 +38,11 @@ elif reference_range_min is not None or reference_range_max is not None:
reference_range_max = int(reference_range_max) reference_range_max = int(reference_range_max)
except ValueError: except ValueError:
msg = Message(domain='ui', message='Sorry, make sure you have entered the right check number.') msg = Message(domain='ui', message='Sorry, make sure you have entered the right check number.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if reference_range_min>reference_range_max : if reference_range_min>reference_range_max :
msg = Message(domain='ui', message='Sorry, the min number must be less than the max number.') msg = Message(domain='ui', message='Sorry, the min number must be less than the max number.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
for ref in range(reference_range_min,reference_range_max+1): for ref in range(reference_range_min,reference_range_max+1):
# We will look for each reference and add the right number # We will look for each reference and add the right number
...@@ -59,7 +59,7 @@ for check_reference in reference_list: ...@@ -59,7 +59,7 @@ for check_reference in reference_list:
# just raise an error. # just raise an error.
if context.portal_activities.countMessageWithTag(message_tag) != 0: if context.portal_activities.countMessageWithTag(message_tag) != 0:
msg = Message(domain='ui', message="There are operations pending that prevent to validate this document. Please try again later.") msg = Message(domain='ui', message="There are operations pending that prevent to validate this document. Please try again later.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
result = context.portal_catalog(portal_type = 'Check', reference = check_reference, result = context.portal_catalog(portal_type = 'Check', reference = check_reference,
destination_payment_uid = bank_account.getUid(), destination_payment_uid = bank_account.getUid(),
default_resource_uid = resource_value.uid, default_resource_uid = resource_value.uid,
...@@ -70,13 +70,13 @@ for check_reference in reference_list: ...@@ -70,13 +70,13 @@ for check_reference in reference_list:
msg = Message(domain = "ui", message="Sorry, the $type $reference for the account $account does not exist", msg = Message(domain = "ui", message="Sorry, the $type $reference for the account $account does not exist",
mapping={'reference' : check_reference, 'account': bank_account.getInternalBankAccountNumber(), mapping={'reference' : check_reference, 'account': bank_account.getInternalBankAccountNumber(),
'type': resource_value.getTitle()}) 'type': resource_value.getTitle()})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif result_len > 1: elif result_len > 1:
msg = Message(domain = "ui", message="Sorry, the $type $reference for the account $account is duplicated", msg = Message(domain = "ui", message="Sorry, the $type $reference for the account $account is duplicated",
mapping={'reference' : reference, 'account': bank_account.getInternalBankAccountNumber(), mapping={'reference' : reference, 'account': bank_account.getInternalBankAccountNumber(),
'type': resource_value.getTitle()}) 'type': resource_value.getTitle()})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
reference_dict[check_reference] = {} reference_dict[check_reference] = {}
reference_dict[check_reference]['result'] = result reference_dict[check_reference]['result'] = result
...@@ -96,10 +96,10 @@ for check_reference in reference_list: ...@@ -96,10 +96,10 @@ for check_reference in reference_list:
composition_related_list = resource_value.getCompositionRelatedValueList() composition_related_list = resource_value.getCompositionRelatedValueList()
if len(composition_related_list) == 0: if len(composition_related_list) == 0:
msg = Message(domain = "ui", message="Sorry, no checkbook model found") msg = Message(domain = "ui", message="Sorry, no checkbook model found")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if len(composition_related_list) != 1: if len(composition_related_list) != 1:
msg = Message(domain = "ui", message="Sorry, too many many checkbook model found") msg = Message(domain = "ui", message="Sorry, too many many checkbook model found")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
generic_model = composition_related_list[0] generic_model = composition_related_list[0]
#generic_model = context.portal_catalog(portal_type = 'Checkbook Model', title = 'Generic')[0].getObject() #generic_model = context.portal_catalog(portal_type = 'Checkbook Model', title = 'Generic')[0].getObject()
...@@ -120,7 +120,7 @@ for check_reference in reference_list: ...@@ -120,7 +120,7 @@ for check_reference in reference_list:
checkbook_tag = "checkbook_%s_%s" % (resource, bank_account_uid) checkbook_tag = "checkbook_%s_%s" % (resource, bank_account_uid)
if context.portal_activities.countMessageWithTag(checkbook_tag) != 0: if context.portal_activities.countMessageWithTag(checkbook_tag) != 0:
msg = Message(domain='ui', message="There are operations pending that prevent to validate this document. Please try again later.") msg = Message(domain='ui', message="There are operations pending that prevent to validate this document. Please try again later.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
checkbook = context.checkbook_module.newContent(portal_type = 'Checkbook', checkbook = context.checkbook_module.newContent(portal_type = 'Checkbook',
title = 'Generic', title = 'Generic',
resource_value = generic_model, resource_value = generic_model,
......
...@@ -43,7 +43,7 @@ def convertTravelerCheckReferenceToInt(traveler_check_reference): ...@@ -43,7 +43,7 @@ def convertTravelerCheckReferenceToInt(traveler_check_reference):
def convertCheckReferenceToInt(check_reference): def convertCheckReferenceToInt(check_reference):
if len(check_reference) != 7: if len(check_reference) != 7:
raise ValueError, 'Check reference must be 7-char long.' raise ValueError('Check reference must be 7-char long.')
return int(check_reference) return int(check_reference)
# listbox is not passed at the first time when this script is called. # listbox is not passed at the first time when this script is called.
......
...@@ -16,4 +16,4 @@ for line in context.getMovementList(): ...@@ -16,4 +16,4 @@ for line in context.getMovementList():
reference = '%s - %s' % (aggregate_value.getReferenceRangeMin() or '', aggregate_value.getReferenceRangeMax() or '') reference = '%s - %s' % (aggregate_value.getReferenceRangeMin() or '', aggregate_value.getReferenceRangeMax() or '')
msg = Message(domain="ui", message="Sorry, the item with reference $reference is not available any more", msg = Message(domain="ui", message="Sorry, the item with reference $reference is not available any more",
mapping={'reference':reference}) mapping={'reference':reference})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -27,7 +27,7 @@ def validateTravelerCheckReferenceFormat(traveler_check_reference): ...@@ -27,7 +27,7 @@ def validateTravelerCheckReferenceFormat(traveler_check_reference):
""" """
if len(traveler_check_reference) != 10: if len(traveler_check_reference) != 10:
message = Message(domain='ui', message='Traveler check reference must be 10-char long.') message = Message(domain='ui', message='Traveler check reference must be 10-char long.')
raise ValueError, (message,) raise ValueError(message,)
int(traveler_check_reference[4:]) int(traveler_check_reference[4:])
def getTravelerCheckReferenceNumber(traveler_check_reference): def getTravelerCheckReferenceNumber(traveler_check_reference):
...@@ -51,10 +51,10 @@ def generateTravelerCheckReference(number, original_traveler_check_reference): ...@@ -51,10 +51,10 @@ def generateTravelerCheckReference(number, original_traveler_check_reference):
""" """
if not same_type(number, 0): if not same_type(number, 0):
message = Message(domain='ui', message='Traveler check number must be only numeric.') message = Message(domain='ui', message='Traveler check number must be only numeric.')
raise ValueError, (message, ) raise ValueError(message,)
if len(str(number)) > 6: if len(str(number)) > 6:
message = Message(domain='ui', message='Traveler check number representation length must not exceed 6 char.') message = Message(domain='ui', message='Traveler check number representation length must not exceed 6 char.')
raise ValueError, (message,) raise ValueError(message,)
prefix = getTravelerCheckReferencePrefix(original_traveler_check_reference) prefix = getTravelerCheckReferencePrefix(original_traveler_check_reference)
return '%s%06d' % (prefix, number) return '%s%06d' % (prefix, number)
...@@ -69,7 +69,7 @@ def assertReferenceMatchListEmpty(match_list, internal_bank_account_number): ...@@ -69,7 +69,7 @@ def assertReferenceMatchListEmpty(match_list, internal_bank_account_number):
matched_reference_list.append('%s (%s)' % (match.getReference(), internal_bank_account_number)) matched_reference_list.append('%s (%s)' % (match.getReference(), internal_bank_account_number))
message = Message(domain='ui', message='The following references are already allocated : $reference_list', message = Message(domain='ui', message='The following references are already allocated : $reference_list',
mapping={'reference_list': matched_reference_list}) mapping={'reference_list': matched_reference_list})
raise ValidationFailed, (message,) raise ValidationFailed(message,)
def checkReferenceListUniqueness(reference_list, model_uid, destination_payment_value, unique_per_account): def checkReferenceListUniqueness(reference_list, model_uid, destination_payment_value, unique_per_account):
""" """
...@@ -101,7 +101,7 @@ def checkReferenceListUniqueness(reference_list, model_uid, destination_payment_ ...@@ -101,7 +101,7 @@ def checkReferenceListUniqueness(reference_list, model_uid, destination_payment_
if encountered_check_identifiers_dict.has_key(tag): if encountered_check_identifiers_dict.has_key(tag):
message = Message(domain='ui', message='The following references are already allocated : $reference_list', message = Message(domain='ui', message='The following references are already allocated : $reference_list',
mapping={'reference_list': ['%s (%s)' % (reference, internal_bank_account_number) ]}) mapping={'reference_list': ['%s (%s)' % (reference, internal_bank_account_number) ]})
raise ValidationFailed, (message,) raise ValidationFailed(message,)
encountered_check_identifiers_dict[tag] = None encountered_check_identifiers_dict[tag] = None
start_date = checkbook_reception.getStartDate() start_date = checkbook_reception.getStartDate()
...@@ -149,7 +149,7 @@ if resource.getAccountNumberEnabled(): ...@@ -149,7 +149,7 @@ if resource.getAccountNumberEnabled():
context.log('context.getRelativeUrl() before getUid of destination payment', context.getRelativeUrl()) context.log('context.getRelativeUrl() before getUid of destination payment', context.getRelativeUrl())
if destination_payment_value is None: if destination_payment_value is None:
message = Message(domain='ui', message='There is not destination payment on line with id: $id', mapping={'id': context.getId()}) message = Message(domain='ui', message='There is not destination payment on line with id: $id', mapping={'id': context.getId()})
raise ValueError, (message,) raise ValueError(message,)
destination_trade = line.getDestinationTrade() destination_trade = line.getDestinationTrade()
else: else:
destination_payment_value = None destination_payment_value = None
......
...@@ -12,7 +12,7 @@ from Products.ERP5Type.Message import Message ...@@ -12,7 +12,7 @@ from Products.ERP5Type.Message import Message
destination_id = context.getDestinationId() destination_id = context.getDestinationId()
if destination_id is None: if destination_id is None:
msg = Message(domain='ui', message='Sorry, you must define the site') msg = Message(domain='ui', message='Sorry, you must define the site')
raise ValidationFailed, (msg, ) raise ValidationFailed(msg,)
# serialize destination vault to only have one operation at a time # serialize destination vault to only have one operation at a time
destination_value = context.getDestinationValue() destination_value = context.getDestinationValue()
...@@ -28,7 +28,7 @@ else: ...@@ -28,7 +28,7 @@ else:
msg = Message(domain='ui', message='Sorry, there is already a checkbook reception newly validated') msg = Message(domain='ui', message='Sorry, there is already a checkbook reception newly validated')
checkbook_reception_tag = "CheckbookReception_%s" % destination_id checkbook_reception_tag = "CheckbookReception_%s" % destination_id
if context.portal_activities.countMessageWithTag(checkbook_reception_tag) != 0: if context.portal_activities.countMessageWithTag(checkbook_reception_tag) != 0:
raise ValidationFailed, (msg, ) raise ValidationFailed(msg,)
if check == 1: if check == 1:
encountered_check_identifiers_dict = {} encountered_check_identifiers_dict = {}
......
...@@ -27,5 +27,5 @@ for site in site_list: ...@@ -27,5 +27,5 @@ for site in site_list:
if user_site is None: if user_site is None:
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import Message
message = Message(domain="ui", message="The owner is not assigned to the right vault.") message = Message(domain="ui", message="The owner is not assigned to the right vault.")
raise ValueError,message raise ValueError(message)
context.setSource(user_site) context.setSource(user_site)
...@@ -9,4 +9,4 @@ for site in site_list: ...@@ -9,4 +9,4 @@ for site in site_list:
return site + '/encaisse_des_billets_et_monnaies' return site + '/encaisse_des_billets_et_monnaies'
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import Message
message = Message(domain="ui", message="The owner is not assigned to the right vault.") message = Message(domain="ui", message="The owner is not assigned to the right vault.")
raise ValueError,message raise ValueError(message)
...@@ -9,8 +9,8 @@ for line in txn.contentValues(filter = {'portal_type' : 'Check Operation Line'} ...@@ -9,8 +9,8 @@ for line in txn.contentValues(filter = {'portal_type' : 'Check Operation Line'}
if account is None: if account is None:
msg = Message(domain='ui', message="No account defined on line") msg = Message(domain='ui', message="No account defined on line")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if not account.isOverdraftFacility(): if not account.isOverdraftFacility():
msg = Message(domain='ui', message="Can't sent to manual validation because of not overdraft facility for this bank account") msg = Message(domain='ui', message="Can't sent to manual validation because of not overdraft facility for this bank account")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -37,14 +37,14 @@ else: ...@@ -37,14 +37,14 @@ else:
if error['error_code'] == 1: if error['error_code'] == 1:
msg = Message(domain='ui', message="Bank account $account is not sufficient on line $line.", msg = Message(domain='ui', message="Bank account $account is not sufficient on line $line.",
mapping={"account": source_bank_account.getInternalBankAccountNumber(), "line" : check_operation_line.getId()}) mapping={"account": source_bank_account.getInternalBankAccountNumber(), "line" : check_operation_line.getId()})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif error['error_code'] == 2: elif error['error_code'] == 2:
msg = Message(domain='ui', message="Bank account $account is not valid on $line.", msg = Message(domain='ui', message="Bank account $account is not valid on $line.",
mapping={"account": source_bank_account.getInternalBankAccountNumber(), "line" : check_operation_line.getId()}) mapping={"account": source_bank_account.getInternalBankAccountNumber(), "line" : check_operation_line.getId()})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif error['error_code'] != 0: elif error['error_code'] != 0:
msg = Message(domain='ui', message="Unknown error code.") msg = Message(domain='ui', message="Unknown error code.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
context.validateSourceAndDestination(state_change) context.validateSourceAndDestination(state_change)
...@@ -12,34 +12,34 @@ transaction.Baobab_checkAccountingDateOpen(site=site, date=date) ...@@ -12,34 +12,34 @@ transaction.Baobab_checkAccountingDateOpen(site=site, date=date)
if transaction.getDestinationSection() not in ("", None) and \ if transaction.getDestinationSection() not in ("", None) and \
transaction.getDestinationPayment() not in ("", None): transaction.getDestinationPayment() not in ("", None):
msg = Message(domain='ui', message="You can't defined both account and accounting code.") msg = Message(domain='ui', message="You can't defined both account and accounting code.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if transaction.getDestinationSection() in ("", None) and \ if transaction.getDestinationSection() in ("", None) and \
transaction.getDestinationPayment() in ("", None): transaction.getDestinationPayment() in ("", None):
msg = Message(domain='ui', message="You must defined an account or and accounting code as destination.") msg = Message(domain='ui', message="You must defined an account or and accounting code as destination.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if transaction.getSite() in ("", None): if transaction.getSite() in ("", None):
msg = Message(domain='ui', message="You must defined site on document.") msg = Message(domain='ui', message="You must defined site on document.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Check the amount. # Check the amount.
price = transaction.getSourceTotalAssetPrice() price = transaction.getSourceTotalAssetPrice()
if price is None or price <= 0: if price is None or price <= 0:
msg = Message(domain='ui', message='Amount is not valid.') msg = Message(domain='ui', message='Amount is not valid.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Check the bank account. # Check the bank account.
destination_bank_account = transaction.getDestinationPaymentValue() destination_bank_account = transaction.getDestinationPaymentValue()
if destination_bank_account is not None: if destination_bank_account is not None:
if destination_bank_account.getValidationState() != 'valid': if destination_bank_account.getValidationState() != 'valid':
msg = Message(domain='ui', message='Destination bank account is not valid.') msg = Message(domain='ui', message='Destination bank account is not valid.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Check if the total price is equal to the total asset price. # Check if the total price is equal to the total asset price.
if transaction.getTotalPrice(fast=0, portal_type = 'Check Operation Line') != transaction.getSourceTotalAssetPrice(): if transaction.getTotalPrice(fast=0, portal_type = 'Check Operation Line') != transaction.getSourceTotalAssetPrice():
msg = Message(domain='ui', message="Total price doesn't match.") msg = Message(domain='ui', message="Total price doesn't match.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
seen_check_dict = {} seen_check_dict = {}
...@@ -51,13 +51,13 @@ for check_operation_line in transaction.contentValues(filter = {'portal_type' : ...@@ -51,13 +51,13 @@ for check_operation_line in transaction.contentValues(filter = {'portal_type' :
if check_operation_line.getDescription() in (None, ''): if check_operation_line.getDescription() in (None, ''):
msg = Message(domain='ui', message='The description is not defined on line $line.' msg = Message(domain='ui', message='The description is not defined on line $line.'
, mapping={"line" : check_operation_line.getId()}) , mapping={"line" : check_operation_line.getId()})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
source_bank_account = check_operation_line.getSourcePaymentValue() source_bank_account = check_operation_line.getSourcePaymentValue()
if source_bank_account is None: if source_bank_account is None:
msg = Message(domain='ui', message='Bank account not defined on line $line.' msg = Message(domain='ui', message='Bank account not defined on line $line.'
, mapping={"line" : check_operation_line.getId()}) , mapping={"line" : check_operation_line.getId()})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
check_number = check_operation_line.getAggregateFreeText() check_number = check_operation_line.getAggregateFreeText()
check_type = check_operation_line.getAggregateResource() check_type = check_operation_line.getAggregateResource()
...@@ -65,29 +65,29 @@ for check_operation_line in transaction.contentValues(filter = {'portal_type' : ...@@ -65,29 +65,29 @@ for check_operation_line in transaction.contentValues(filter = {'portal_type' :
if check_number: if check_number:
msg = Message(domain='ui', message='Check is defined on line $line.' msg = Message(domain='ui', message='Check is defined on line $line.'
, mapping={"line" : check_operation_line.getId()}) , mapping={"line" : check_operation_line.getId()})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if check_type is not None: if check_type is not None:
msg = Message(domain='ui', message='Check type is defined on line $line.' msg = Message(domain='ui', message='Check type is defined on line $line.'
, mapping={"line" : check_operation_line.getId()}) , mapping={"line" : check_operation_line.getId()})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
else: else:
if not check_number: if not check_number:
msg = Message(domain='ui', message='Check is not defined on line $line.' msg = Message(domain='ui', message='Check is not defined on line $line.'
, mapping={"line" : check_operation_line.getId()}) , mapping={"line" : check_operation_line.getId()})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if check_type is None: if check_type is None:
msg = Message(domain='ui', message='Check type is not defined on line $line.' msg = Message(domain='ui', message='Check type is not defined on line $line.'
, mapping={"line" : check_operation_line.getId()}) , mapping={"line" : check_operation_line.getId()})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
seen_check_dict_key = (source_bank_account, check_type, check_number) seen_check_dict_key = (source_bank_account, check_type, check_number)
seen_check = seen_check_dict.get(seen_check_dict_key) seen_check = seen_check_dict.get(seen_check_dict_key)
if seen_check is not None: if seen_check is not None:
msg = Message(domain='ui', message='Check on line $line is already used on line $oldline.' msg = Message(domain='ui', message='Check on line $line is already used on line $oldline.'
, mapping={"line" : check_operation_line.getId(), "oldline": seen_check}) , mapping={"line" : check_operation_line.getId(), "oldline": seen_check})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
seen_check_dict[seen_check_dict_key] = check_operation_line.getId() seen_check_dict[seen_check_dict_key] = check_operation_line.getId()
# Test check is valid based on date # Test check is valid based on date
......
...@@ -15,13 +15,13 @@ for account_path, amount in amount_dict.items(): ...@@ -15,13 +15,13 @@ for account_path, amount in amount_dict.items():
error = transaction.BankAccount_checkBalance(account_path, amount)['error_code'] error = transaction.BankAccount_checkBalance(account_path, amount)['error_code']
source_bank_account = bank_account_dict[account_path] source_bank_account = bank_account_dict[account_path]
if error == 1: if error == 1:
raise ValidationFailed, (Message(domain='ui', message="Bank account $account is not sufficient.", raise ValidationFailed(Message(domain='ui', message="Bank account $account is not sufficient.",
mapping={"account": source_bank_account.getInternalBankAccountNumber()}), ) mapping={"account": source_bank_account.getInternalBankAccountNumber()}),)
elif error == 2: elif error == 2:
raise ValidationFailed, (Message(domain='ui', message="Bank account $account is not valid.", raise ValidationFailed(Message(domain='ui', message="Bank account $account is not valid.",
mapping={"account": source_bank_account.getInternalBankAccountNumber()}), ) mapping={"account": source_bank_account.getInternalBankAccountNumber()}),)
elif error != 0: elif error != 0:
raise ValidationFailed, (Message(domain='ui', message="Unknown error code."),) raise ValidationFailed(Message(domain='ui', message="Unknown error code."),)
context.validateConsistency(state_change) context.validateConsistency(state_change)
......
...@@ -6,7 +6,7 @@ date = transaction.getStartDate() ...@@ -6,7 +6,7 @@ date = transaction.getStartDate()
source = transaction.getSource(None) source = transaction.getSource(None)
if source is None: if source is None:
msg = Message(domain='ui', message='No counter defined.') msg = Message(domain='ui', message='No counter defined.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# check we are in an opened accounting day # check we are in an opened accounting day
transaction.Baobab_checkCounterDateOpen(site=source, date=date) transaction.Baobab_checkCounterDateOpen(site=source, date=date)
...@@ -21,7 +21,7 @@ bank_account = transaction.getDestinationPaymentValue() ...@@ -21,7 +21,7 @@ bank_account = transaction.getDestinationPaymentValue()
if not bank_account.isOverdraftFacility(): if not bank_account.isOverdraftFacility():
msg = Message(domain='ui', message="Can't sent to manual validation because of not overdraft facility for this bank account") msg = Message(domain='ui', message="Can't sent to manual validation because of not overdraft facility for this bank account")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
price = transaction.getSourceTotalAssetPrice() price = transaction.getSourceTotalAssetPrice()
...@@ -31,7 +31,7 @@ bank_account.serialize() ...@@ -31,7 +31,7 @@ bank_account.serialize()
# Make sure there are no other operations pending for this account # Make sure there are no other operations pending for this account
if transaction.BankAccount_isMessagePending(bank_account): if transaction.BankAccount_isMessagePending(bank_account):
msg = Message(domain='ui', message="There are operations pending for this account that prevent form calculating its position. Please try again later.") msg = Message(domain='ui', message="There are operations pending for this account that prevent form calculating its position. Please try again later.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Index the banking operation line so it impacts account position # Index the banking operation line so it impacts account position
transaction.BankingOperationLine_index(line) transaction.BankingOperationLine_index(line)
...@@ -39,4 +39,4 @@ transaction.BankingOperationLine_index(line) ...@@ -39,4 +39,4 @@ transaction.BankingOperationLine_index(line)
# Check if the banking operation is correct. Do not depend on catalog because line might not be indexed immediatelly. # Check if the banking operation is correct. Do not depend on catalog because line might not be indexed immediatelly.
if - price != (line.getPrice() * line.getQuantity()): if - price != (line.getPrice() * line.getQuantity()):
msg = Message(domain='ui', message='Banking operation and check payment price do not match.') msg = Message(domain='ui', message='Banking operation and check payment price do not match.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -16,14 +16,14 @@ else: ...@@ -16,14 +16,14 @@ else:
while True: while True:
if not hasattr(site, 'getVaultTypeList'): if not hasattr(site, 'getVaultTypeList'):
msg = Message(domain = 'ui', message = 'The site value is misconfigured; report this to system administrators.') msg = Message(domain = 'ui', message = 'The site value is misconfigured; report this to system administrators.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if 'site' in site.getVaultTypeList(): if 'site' in site.getVaultTypeList():
break break
site = site.getParentValue() site = site.getParentValue()
if site is None: if site is None:
msg = Message(domain = 'ui', message = 'Impossible to determine site for the transaction.') msg = Message(domain = 'ui', message = 'Impossible to determine site for the transaction.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
date = transaction.getStartDate() date = transaction.getStartDate()
...@@ -40,13 +40,13 @@ document_date = DateTime(date).Date() ...@@ -40,13 +40,13 @@ document_date = DateTime(date).Date()
price = transaction.getSourceTotalAssetPrice() price = transaction.getSourceTotalAssetPrice()
if price is None or price <= 0: if price is None or price <= 0:
msg = Message(domain="ui", message="Amount is not valid.") msg = Message(domain="ui", message="Amount is not valid.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Check the bank account. # Check the bank account.
bank_account = transaction.getDestinationPaymentValue() bank_account = transaction.getDestinationPaymentValue()
if bank_account is None: if bank_account is None:
msg = Message(domain='ui', message='Bank account is not defined.') msg = Message(domain='ui', message='Bank account is not defined.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Check the check. # Check the check.
check_number = transaction.getAggregateFreeText() check_number = transaction.getAggregateFreeText()
...@@ -59,10 +59,10 @@ transaction.edit(aggregate_resource=check_resource) ...@@ -59,10 +59,10 @@ transaction.edit(aggregate_resource=check_resource)
if not check_number: if not check_number:
msg = Message(domain='ui', message="Check not defined.") msg = Message(domain='ui', message="Check not defined.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if check_resource is None: if check_resource is None:
msg = Message(domain='ui', message="Check type not defined.") msg = Message(domain='ui', message="Check type not defined.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
check = transaction.Base_checkCheck(reference=check_number, bank_account=bank_account, check = transaction.Base_checkCheck(reference=check_number, bank_account=bank_account,
resource=check_resource) resource=check_resource)
...@@ -79,10 +79,10 @@ if no_balance_check == 1: ...@@ -79,10 +79,10 @@ if no_balance_check == 1:
error = transaction.BankAccount_checkAvailableBalance(bank_account.getRelativeUrl(), price) error = transaction.BankAccount_checkAvailableBalance(bank_account.getRelativeUrl(), price)
if error['error_code'] == 1: if error['error_code'] == 1:
msg = Message(domain='ui', message="Bank account is not sufficient.") msg = Message(domain='ui', message="Bank account is not sufficient.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif error['error_code'] == 2: elif error['error_code'] == 2:
msg = Message(domain='ui', message="Bank account is not valid.") msg = Message(domain='ui', message="Bank account is not valid.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif error['error_code'] != 0: elif error['error_code'] != 0:
msg = Message(domain='ui', message="Unknown error code.") msg = Message(domain='ui', message="Unknown error code.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -6,7 +6,7 @@ date = transaction.getStartDate() ...@@ -6,7 +6,7 @@ date = transaction.getStartDate()
source = transaction.getSource(None) source = transaction.getSource(None)
if source is None: if source is None:
msg = Message(domain='ui', message='No counter defined.') msg = Message(domain='ui', message='No counter defined.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# check we are in an opened accounting day # check we are in an opened accounting day
transaction.Baobab_checkCounterDateOpen(site=source, date=date) transaction.Baobab_checkCounterDateOpen(site=source, date=date)
...@@ -28,7 +28,7 @@ bank_account.serialize() ...@@ -28,7 +28,7 @@ bank_account.serialize()
# Make sure there are no other operations pending for this account # Make sure there are no other operations pending for this account
if transaction.BankAccount_isMessagePending(bank_account): if transaction.BankAccount_isMessagePending(bank_account):
msg = Message(domain='ui', message="There are operations pending for this account that prevent form calculating its position. Please try again later.") msg = Message(domain='ui', message="There are operations pending for this account that prevent form calculating its position. Please try again later.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Index the banking operation line so it impacts account position # Index the banking operation line so it impacts account position
transaction.BankingOperationLine_index(line) transaction.BankingOperationLine_index(line)
...@@ -36,17 +36,17 @@ transaction.BankingOperationLine_index(line) ...@@ -36,17 +36,17 @@ transaction.BankingOperationLine_index(line)
# Check if the banking operation is correct. Do not depend on catalog because line might not be indexed immediatelly. # Check if the banking operation is correct. Do not depend on catalog because line might not be indexed immediatelly.
if - price != (line.getPrice() * line.getQuantity()): if - price != (line.getPrice() * line.getQuantity()):
msg = Message(domain='ui', message='Banking operation and check payment price do not match.') msg = Message(domain='ui', message='Banking operation and check payment price do not match.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Test if the account balance is sufficient. # Test if the account balance is sufficient.
if state_change['transition'].getId() != "agree_action": if state_change['transition'].getId() != "agree_action":
error = transaction.BankAccount_checkAvailableBalance(bank_account.getRelativeUrl(), price) error = transaction.BankAccount_checkAvailableBalance(bank_account.getRelativeUrl(), price)
if error['error_code'] == 1: if error['error_code'] == 1:
msg = Message(domain='ui', message="Bank account is not sufficient.") msg = Message(domain='ui', message="Bank account is not sufficient.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif error['error_code'] == 2: elif error['error_code'] == 2:
msg = Message(domain='ui', message="Bank account is not valid.") msg = Message(domain='ui', message="Bank account is not valid.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif error['error_code'] != 0: elif error['error_code'] != 0:
msg = Message(domain='ui', message="Unknown error code.") msg = Message(domain='ui', message="Unknown error code.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -18,7 +18,7 @@ for site in site_list: ...@@ -18,7 +18,7 @@ for site in site_list:
if baobab_source is None: if baobab_source is None:
msg = Message(domain="ui", message="Unable to determine counter from user assignement.") msg = Message(domain="ui", message="Unable to determine counter from user assignement.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
source = baobab_source source = baobab_source
source_object = context.portal_categories.getCategoryValue(source) source_object = context.portal_categories.getCategoryValue(source)
...@@ -40,16 +40,16 @@ cash_detail = transaction.getTotalPrice(portal_type = ('Cash Delivery Line','Cas ...@@ -40,16 +40,16 @@ cash_detail = transaction.getTotalPrice(portal_type = ('Cash Delivery Line','Cas
#transaction.log("price vs cash detail", str((price, cash_detail))) #transaction.log("price vs cash detail", str((price, cash_detail)))
if resource == 3: if resource == 3:
msg = Message(domain="ui", message="No banknote or coin defined.") msg = Message(domain="ui", message="No banknote or coin defined.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource == 2: elif resource == 2:
msg = Message(domain="ui", message="No resource defined.") msg = Message(domain="ui", message="No resource defined.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif price != cash_detail: elif price != cash_detail:
msg = Message(domain="ui", message="Amount differs from input.") msg = Message(domain="ui", message="Amount differs from input.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif resource == 1: elif resource == 1:
msg = Message(domain="ui", message="Insufficient Balance in counter.") msg = Message(domain="ui", message="Insufficient Balance in counter.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
transaction.Base_checkCheck(None, None, None, check=transaction.getAggregateValue()) transaction.Base_checkCheck(None, None, None, check=transaction.getAggregateValue())
...@@ -11,16 +11,16 @@ date = transaction.getStartDate() ...@@ -11,16 +11,16 @@ date = transaction.getStartDate()
source = transaction.getBaobabSource(None) source = transaction.getBaobabSource(None)
if source is None: if source is None:
msg = Message(domain='ui', message='No counter defined.') msg = Message(domain='ui', message='No counter defined.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
destination_payment = transaction.getDestinationPayment() destination_payment = transaction.getDestinationPayment()
if destination_payment is None: if destination_payment is None:
msg = Message(domain='ui', message='No account defined.') msg = Message(domain='ui', message='No account defined.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if sum([len(x.getAggregateList()) for x in transaction.objectValues(portal_type=['Checkbook Delivery Line'])]) == 0: if sum([len(x.getAggregateList()) for x in transaction.objectValues(portal_type=['Checkbook Delivery Line'])]) == 0:
msg = Message(domain='ui', message='No checkbook selected for delivery.') msg = Message(domain='ui', message='No checkbook selected for delivery.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
at_date = transaction.getStartDate() at_date = transaction.getStartDate()
transaction.CheckbookDelivery_checkAggregateStockList(at_date=at_date, node_url = source) transaction.CheckbookDelivery_checkAggregateStockList(at_date=at_date, node_url = source)
...@@ -44,13 +44,13 @@ for line in line_list: ...@@ -44,13 +44,13 @@ for line in line_list:
if aggregate.getPortalType()=='Check': if aggregate.getPortalType()=='Check':
if aggregate.getSimulationState() != 'draft': if aggregate.getSimulationState() != 'draft':
message = Message(domain='ui', message='Sorry, the check is not new') message = Message(domain='ui', message='Sorry, the check is not new')
raise ValidationFailed, (message,) raise ValidationFailed(message,)
if aggregate.getPortalType()=='Checkbook': if aggregate.getPortalType()=='Checkbook':
if aggregate.getValidationState() != 'draft': if aggregate.getValidationState() != 'draft':
message = Message(domain='ui', message='Sorry, the checkbook is not new') message = Message(domain='ui', message='Sorry, the checkbook is not new')
raise ValidationFailed, (message,) raise ValidationFailed(message,)
for check in aggregate.objectValues(portal_type='Check'): for check in aggregate.objectValues(portal_type='Check'):
if check.getSimulationState() != 'draft': if check.getSimulationState() != 'draft':
message = Message(domain='ui', message = Message(domain='ui',
message='Sorry, there is a check wich is not in the new state inside the checkbook') message='Sorry, there is a check wich is not in the new state inside the checkbook')
raise ValidationFailed, (message,) raise ValidationFailed(message,)
...@@ -7,15 +7,15 @@ object = state_change['object'] ...@@ -7,15 +7,15 @@ object = state_change['object']
destination = object.getDestination() destination = object.getDestination()
if destination is None: if destination is None:
message = Message(domain="ui",message="Please select a destination") message = Message(domain="ui",message="Please select a destination")
raise ValidationFailed, (message,) raise ValidationFailed(message,)
# Check that the destination is not empty # Check that the destination is not empty
description = object.getDescription() description = object.getDescription()
if description in (None, ''): if description in (None, ''):
message = Message(domain="ui",message="Please set a description") message = Message(domain="ui",message="Please set a description")
raise ValidationFailed, (message,) raise ValidationFailed(message,)
# Check that there is a least one line # Check that there is a least one line
if len(object.objectValues())==0: if len(object.objectValues())==0:
message = Message(domain="ui",message="Please enter some check or checkbooks") message = Message(domain="ui",message="Please enter some check or checkbooks")
raise ValidationFailed, (message,) raise ValidationFailed(message,)
...@@ -19,4 +19,4 @@ at_date = transaction.getStartDate() ...@@ -19,4 +19,4 @@ at_date = transaction.getStartDate()
transaction.CheckbookDelivery_checkAggregateStockList(at_date=at_date, node_url = source) transaction.CheckbookDelivery_checkAggregateStockList(at_date=at_date, node_url = source)
if msg is not None: if msg is not None:
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -17,4 +17,4 @@ at_date = transaction.getStartDate() ...@@ -17,4 +17,4 @@ at_date = transaction.getStartDate()
transaction.CheckbookDelivery_checkAggregateStockList(at_date=at_date, node_url = source) transaction.CheckbookDelivery_checkAggregateStockList(at_date=at_date, node_url = source)
if msg is not None: if msg is not None:
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -7,7 +7,7 @@ date = transaction.getStartDate() ...@@ -7,7 +7,7 @@ date = transaction.getStartDate()
source = transaction.getSource(None) source = transaction.getSource(None)
if source is None: if source is None:
msg = Message(domain='ui', message='No counter defined.') msg = Message(domain='ui', message='No counter defined.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# No need to check the counter date for stop payment # No need to check the counter date for stop payment
#if not transaction.Baobab_checkCounterDateOpen(site=source, date=date): #if not transaction.Baobab_checkCounterDateOpen(site=source, date=date):
...@@ -24,17 +24,17 @@ for movement in movement_list: ...@@ -24,17 +24,17 @@ for movement in movement_list:
for item in aggregate_value_list: for item in aggregate_value_list:
if item.getPortalType()!='Check': if item.getPortalType()!='Check':
msg = Message(domain = "ui", message="Sorry, You should select a check") msg = Message(domain = "ui", message="Sorry, You should select a check")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if item.getSimulationState()!='stopped': if item.getSimulationState()!='stopped':
msg = Message(domain = "ui", message="Sorry, this check is not stopped") msg = Message(domain = "ui", message="Sorry, this check is not stopped")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
debit_required = transaction.isDebitRequired() debit_required = transaction.isDebitRequired()
if debit_required: if debit_required:
if transaction.getSimulationState() == 'started': if transaction.getSimulationState() == 'started':
stop_date = state_change.kwargs.get('stop_date') stop_date = state_change.kwargs.get('stop_date')
if stop_date is None: if stop_date is None:
msg = Message(domain = "ui", message="No stop date provided") msg = Message(domain = "ui", message="No stop date provided")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
transaction.setStopDate(stop_date) transaction.setStopDate(stop_date)
# Source and destination will be updated automaticaly based on the category of bank account # Source and destination will be updated automaticaly based on the category of bank account
......
...@@ -14,7 +14,7 @@ ref_max = transaction.getReferenceRangeMin() ...@@ -14,7 +14,7 @@ ref_max = transaction.getReferenceRangeMin()
if ref_min is not None or ref_max is not None: if ref_min is not None or ref_max is not None:
if len(aggregate_list)==0: if len(aggregate_list)==0:
msg = Message(domain='ui', message='Sorry, no check was found, but there is a reference.') msg = Message(domain='ui', message='Sorry, no check was found, but there is a reference.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
for aggregate in aggregate_list: for aggregate in aggregate_list:
if aggregate.getPortalType()=='Check': if aggregate.getPortalType()=='Check':
aggregate.setStopDate(transaction.getStartDate()) aggregate.setStopDate(transaction.getStartDate())
......
...@@ -10,7 +10,7 @@ now = DateTime() ...@@ -10,7 +10,7 @@ now = DateTime()
source = transaction.getSource(None) source = transaction.getSource(None)
if source is None: if source is None:
msg = Message(domain='ui', message='No counter defined.') msg = Message(domain='ui', message='No counter defined.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# No need for stop payment to check the counter date # No need for stop payment to check the counter date
#if not transaction.Baobab_checkCounterDateOpen(site=source, date=date): #if not transaction.Baobab_checkCounterDateOpen(site=source, date=date):
...@@ -64,10 +64,10 @@ for movement in movement_list: ...@@ -64,10 +64,10 @@ for movement in movement_list:
for item in aggregate_value_list: for item in aggregate_value_list:
if item.getPortalType()!='Check': if item.getPortalType()!='Check':
msg = Message(domain = "ui", message="Sorry, You should select a check") msg = Message(domain = "ui", message="Sorry, You should select a check")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if item.getSimulationState()!='confirmed': if item.getSimulationState()!='confirmed':
msg = Message(domain = "ui", message="Sorry, this check is not issued") msg = Message(domain = "ui", message="Sorry, this check is not issued")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Test check is valid based on date # Test check is valid based on date
transaction.Check_checkIntervalBetweenDate(resource=item.getResourceValue(), transaction.Check_checkIntervalBetweenDate(resource=item.getResourceValue(),
start_date=date, start_date=date,
...@@ -78,7 +78,7 @@ for movement in movement_list: ...@@ -78,7 +78,7 @@ for movement in movement_list:
debit_required = transaction.isDebitRequired() debit_required = transaction.isDebitRequired()
if total_debit in (None,0.0) and debit_required: if total_debit in (None,0.0) and debit_required:
msg = Message(domain = "ui", message="Sorry, you forgot to give the amount") msg = Message(domain = "ui", message="Sorry, you forgot to give the amount")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if debit_required: if debit_required:
# Source and destination will be updated automaticaly based on the category of bank account # Source and destination will be updated automaticaly based on the category of bank account
# The default account chosen should act as some kind of *temp* account or *parent* account # The default account chosen should act as some kind of *temp* account or *parent* account
...@@ -101,7 +101,7 @@ if debit_required: ...@@ -101,7 +101,7 @@ if debit_required:
# Make sure there are no other operations pending for this account # Make sure there are no other operations pending for this account
if transaction.BankAccount_isMessagePending(bank_account): if transaction.BankAccount_isMessagePending(bank_account):
msg = Message(domain='ui', message="There are operations pending for this account that prevent form calculating its position. Please try again later.") msg = Message(domain='ui', message="There are operations pending for this account that prevent form calculating its position. Please try again later.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Index the banking operation line so it impacts account position # Index the banking operation line so it impacts account position
transaction.BankingOperationLine_index(line) transaction.BankingOperationLine_index(line)
...@@ -110,10 +110,10 @@ if debit_required: ...@@ -110,10 +110,10 @@ if debit_required:
error = transaction.BankAccount_checkBalance(bank_account.getRelativeUrl(), total_debit) error = transaction.BankAccount_checkBalance(bank_account.getRelativeUrl(), total_debit)
if error['error_code'] == 1: if error['error_code'] == 1:
msg = Message(domain='ui', message="Bank account is not sufficient.") msg = Message(domain='ui', message="Bank account is not sufficient.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif error['error_code'] == 2: elif error['error_code'] == 2:
msg = Message(domain='ui', message="Bank account is not valid.") msg = Message(domain='ui', message="Bank account is not valid.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif error['error_code'] != 0: elif error['error_code'] != 0:
msg = Message(domain='ui', message="Unknown error code.") msg = Message(domain='ui', message="Unknown error code.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -7,7 +7,7 @@ date = transaction.getStartDate() ...@@ -7,7 +7,7 @@ date = transaction.getStartDate()
source = transaction.getSource(None) source = transaction.getSource(None)
if source is None: if source is None:
msg = Message(domain='ui', message='No counter defined.') msg = Message(domain='ui', message='No counter defined.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# check we don't change of user # check we don't change of user
transaction.Baobab_checkSameUserVault(source) transaction.Baobab_checkSameUserVault(source)
...@@ -28,7 +28,7 @@ for movement in movement_list: ...@@ -28,7 +28,7 @@ for movement in movement_list:
if item.getPortalType()=='Check': if item.getPortalType()=='Check':
if item.getSimulationState()!='confirmed': if item.getSimulationState()!='confirmed':
msg = Message(domain = "ui", message="Sorry, one traveler check was not sale yet") msg = Message(domain = "ui", message="Sorry, one traveler check was not sale yet")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if item.getPrice() is not None: if item.getPrice() is not None:
# then we must calculate the exchange value at the # then we must calculate the exchange value at the
# time where the item was first delivered # time where the item was first delivered
...@@ -40,11 +40,11 @@ for movement in movement_list: ...@@ -40,11 +40,11 @@ for movement in movement_list:
start_date=item.getStartDate())[0] start_date=item.getStartDate())[0]
if base_price is None: if base_price is None:
msg = Message(domain = "ui", message="Sorry, no valid price was found for this currency") msg = Message(domain = "ui", message="Sorry, no valid price was found for this currency")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
total_credit += base_price*item.getPrice() total_credit += base_price*item.getPrice()
else: else:
msg = Message(domain = "ui", message="Sorry, the price was not defined on some traveler checks") msg = Message(domain = "ui", message="Sorry, the price was not defined on some traveler checks")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if total_credit>0: if total_credit>0:
total_credit = round(total_credit,0) total_credit = round(total_credit,0)
......
...@@ -6,7 +6,7 @@ transaction = state_change['object'] ...@@ -6,7 +6,7 @@ transaction = state_change['object']
# check we have defined an account # check we have defined an account
if transaction.getDestinationPayment() is None: if transaction.getDestinationPayment() is None:
msg = Message(domain = "ui", message="Sorry, no account selected") msg = Message(domain = "ui", message="Sorry, no account selected")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# First we have to look if we have some checks with some prices, # First we have to look if we have some checks with some prices,
# if so, this means that we are saling such kinds of check, thus # if so, this means that we are saling such kinds of check, thus
...@@ -18,7 +18,7 @@ for movement in movement_list: ...@@ -18,7 +18,7 @@ for movement in movement_list:
for item in aggregate_value_list: for item in aggregate_value_list:
if item.getSimulationState()!='draft': if item.getSimulationState()!='draft':
msg = Message(domain = "ui", message="Sorry, one traveler check was already saled") msg = Message(domain = "ui", message="Sorry, one traveler check was already saled")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if item.getPortalType()=='Check': if item.getPortalType()=='Check':
if item.getPrice() is not None: if item.getPrice() is not None:
# then we must calculate the exchange value # then we must calculate the exchange value
...@@ -29,11 +29,11 @@ for movement in movement_list: ...@@ -29,11 +29,11 @@ for movement in movement_list:
currency_exchange_type='transfer')[0] currency_exchange_type='transfer')[0]
if base_price is None: if base_price is None:
msg = Message(domain = "ui", message="Sorry, no valid price was found for this currency") msg = Message(domain = "ui", message="Sorry, no valid price was found for this currency")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
total_debit += base_price*item.getPrice() total_debit += base_price*item.getPrice()
else: else:
msg = Message(domain = "ui", message="Sorry, the price was not defined on some traveler checks") msg = Message(domain = "ui", message="Sorry, the price was not defined on some traveler checks")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if total_debit>0: if total_debit>0:
total_debit = round(total_debit) total_debit = round(total_debit)
# Source and destination will be updated automaticaly based on the category of bank account # Source and destination will be updated automaticaly based on the category of bank account
...@@ -53,7 +53,7 @@ if total_debit>0: ...@@ -53,7 +53,7 @@ if total_debit>0:
if bank_account is None: if bank_account is None:
msg = Message(domain='ui', message="Sorry, no account defined.") msg = Message(domain='ui', message="Sorry, no account defined.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
price = total_debit price = total_debit
...@@ -63,7 +63,7 @@ if total_debit>0: ...@@ -63,7 +63,7 @@ if total_debit>0:
# Make sure there are no other operations pending for this account # Make sure there are no other operations pending for this account
if context.BankAccount_isMessagePending(bank_account): if context.BankAccount_isMessagePending(bank_account):
msg = Message(domain='ui', message="There are operations pending for this account that prevent form calculating its position. Please try again later.") msg = Message(domain='ui', message="There are operations pending for this account that prevent form calculating its position. Please try again later.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Index the banking operation line so it impacts account position # Index the banking operation line so it impacts account position
context.BankingOperationLine_index(line) context.BankingOperationLine_index(line)
...@@ -72,23 +72,23 @@ if total_debit>0: ...@@ -72,23 +72,23 @@ if total_debit>0:
error = transaction.BankAccount_checkBalance(bank_account.getRelativeUrl(), price) error = transaction.BankAccount_checkBalance(bank_account.getRelativeUrl(), price)
if error['error_code'] == 1: if error['error_code'] == 1:
msg = Message(domain='ui', message="Bank account is not sufficient.") msg = Message(domain='ui', message="Bank account is not sufficient.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif error['error_code'] == 2: elif error['error_code'] == 2:
msg = Message(domain='ui', message="Bank account is not valid.") msg = Message(domain='ui', message="Bank account is not valid.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif error['error_code'] != 0: elif error['error_code'] != 0:
msg = Message(domain='ui', message="Unknown error code.") msg = Message(domain='ui', message="Unknown error code.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if total_debit==0: if total_debit==0:
msg = Message(domain='ui', message='Please select at least one traveler check.') msg = Message(domain='ui', message='Please select at least one traveler check.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
date = transaction.getStartDate() date = transaction.getStartDate()
source = transaction.getSource(None) source = transaction.getSource(None)
if source is None: if source is None:
msg = Message(domain='ui', message='No counter defined.') msg = Message(domain='ui', message='No counter defined.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# check we are in an opened accounting day # check we are in an opened accounting day
transaction.Baobab_checkCounterDateOpen(site=source, date=date) transaction.Baobab_checkCounterDateOpen(site=source, date=date)
......
...@@ -2,7 +2,7 @@ from DateTime import DateTime ...@@ -2,7 +2,7 @@ from DateTime import DateTime
user_site_list = context.Baobab_getUserAssignedSiteList() user_site_list = context.Baobab_getUserAssignedSiteList()
if len(user_site_list) == 0: if len(user_site_list) == 0:
raise ValueError, "You cannot create an AccountingDate if you don't have an assignment." raise ValueError("You cannot create an AccountingDate if you don't have an assignment.")
site = context.Baobab_getVaultSite(user_site_list[0]) site = context.Baobab_getVaultSite(user_site_list[0])
context.setSiteValue(site) context.setSiteValue(site)
......
reference = bank_account.getReference() reference = bank_account.getReference()
if not same_type(reference, ''): if not same_type(reference, ''):
raise TypeError, 'Reference is not a string: %s.getReference() == %s' % (repr(bank_account), repr(reference)) raise TypeError('Reference is not a string: %s.getReference() == %s' % (repr(bank_account), repr(reference)))
return 'bank_account_%s' % (reference, ) return 'bank_account_%s' % (reference, )
bank_account = context bank_account = context
resource = bank_account.getPriceCurrencyValue() resource = bank_account.getPriceCurrencyValue()
if resource is None: if resource is None:
raise AttributeError, 'No currency defined on %s' % payment raise AttributeError('No currency defined on %s' % payment)
account_balance = getattr(resource, get_inventory_id)( account_balance = getattr(resource, get_inventory_id)(
payment_uid=bank_account.getUid(), payment_uid=bank_account.getUid(),
optimisation__=False, # XXX: optimisation disabled as it has bugs optimisation__=False, # XXX: optimisation disabled as it has bugs
......
...@@ -6,7 +6,7 @@ portal_type = "Bank Account" ...@@ -6,7 +6,7 @@ portal_type = "Bank Account"
if reference is None: if reference is None:
message = Message(domain="ui", message="Please give a reference") message = Message(domain="ui", message="Please give a reference")
raise ValueError, message raise ValueError(message)
#context.log('reference',reference) #context.log('reference',reference)
account_list = catalog(string_index=reference, portal_type=portal_type, validation_state=('valid', 'closed')) account_list = catalog(string_index=reference, portal_type=portal_type, validation_state=('valid', 'closed'))
...@@ -17,10 +17,10 @@ if len(account_list) == 0: ...@@ -17,10 +17,10 @@ if len(account_list) == 0:
#context.log('len 2',len(account_list)) #context.log('len 2',len(account_list))
if len(account_list) == 0: if len(account_list) == 0:
message = Message(domain="ui", message="No bank account have this reference") message = Message(domain="ui", message="No bank account have this reference")
raise ValueError, message raise ValueError(message)
if force_one_account and len(account_list) != 1: if force_one_account and len(account_list) != 1:
message = Message(domain="ui", message="More than one account match this research") message = Message(domain="ui", message="More than one account match this research")
raise ValueError, message raise ValueError(message)
account_list = [x.getObject() for x in account_list] account_list = [x.getObject() for x in account_list]
......
...@@ -35,6 +35,6 @@ else: ...@@ -35,6 +35,6 @@ else:
if DateTime(date) < opened_accounting_date: if DateTime(date) < opened_accounting_date:
msg = Message(domain = "ui", message="Transaction date incompatible with opened accounting date ${accounting_date}.", mapping={'accounting_date': opened_accounting_date}) msg = Message(domain = "ui", message="Transaction date incompatible with opened accounting date ${accounting_date}.", mapping={'accounting_date': opened_accounting_date})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
return "ok" return "ok"
...@@ -27,4 +27,4 @@ site = context.Baobab_getVaultSite(site) ...@@ -27,4 +27,4 @@ site = context.Baobab_getVaultSite(site)
if context.portal_catalog.countResults(portal_type='Counter Date', start_date=date, site_id=site.getId(), simulation_state="open")[0][0] == 0: if context.portal_catalog.countResults(portal_type='Counter Date', start_date=date, site_id=site.getId(), simulation_state="open")[0][0] == 0:
msg = Message(domain = "ui", message="Transaction not in the good counter date") msg = Message(domain = "ui", message="Transaction not in the good counter date")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -18,4 +18,4 @@ for counter_ob in counter_list: ...@@ -18,4 +18,4 @@ for counter_ob in counter_list:
found = 1 found = 1
if found == 0: if found == 0:
msg = Message(domain = "ui", message="Counter is not opened") msg = Message(domain = "ui", message="Counter is not opened")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -14,4 +14,4 @@ for document in document_list: ...@@ -14,4 +14,4 @@ for document in document_list:
message = Message(domain="ui", message = Message(domain="ui",
message="Sorry, the $portal_type (reference:$reference) is not finished", message="Sorry, the $portal_type (reference:$reference) is not finished",
mapping={'portal_type':portal_type,'reference':reference}) mapping={'portal_type':portal_type,'reference':reference})
raise ValidationFailed,message raise ValidationFailed(message)
...@@ -8,4 +8,4 @@ for site in site_list: ...@@ -8,4 +8,4 @@ for site in site_list:
return return
msg = Message(domain = "ui", message="Vault differ between initialisation and transition") msg = Message(domain = "ui", message="Vault differ between initialisation and transition")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -35,13 +35,13 @@ for counter_vault in counter_vault_list: ...@@ -35,13 +35,13 @@ for counter_vault in counter_vault_list:
message = Message(domain='ui', message = Message(domain='ui',
message='Sorry, some resources are still remaining here : $counter_title', message='Sorry, some resources are still remaining here : $counter_title',
mapping={'counter_title':counter_title}) mapping={'counter_title':counter_title})
raise ValidationFailed,message raise ValidationFailed(message)
max_price = context.portal_preferences.getPreferredUsualCashMaxRenderingPrice() max_price = context.portal_preferences.getPreferredUsualCashMaxRenderingPrice()
if max_price is None: if max_price is None:
message = Message(domain='ui', message = Message(domain='ui',
message='Sorry, you must defined the max price for the usual cash in your preference') message='Sorry, you must defined the max price for the usual cash in your preference')
raise ValidationFailed,message raise ValidationFailed(message)
usual_cash = site.getRelativeUrl() + '/surface/caisse_courante/encaisse_des_billets_et_monnaies' usual_cash = site.getRelativeUrl() + '/surface/caisse_courante/encaisse_des_billets_et_monnaies'
inventory_list = context.portal_simulation.getCurrentInventoryList( inventory_list = context.portal_simulation.getCurrentInventoryList(
...@@ -53,4 +53,4 @@ context.log('current_price',total_price) ...@@ -53,4 +53,4 @@ context.log('current_price',total_price)
if total_price > max_price: if total_price > max_price:
message = Message(domain='ui', message = Message(domain='ui',
message='Sorry, the amount in the usual cash is too high') message='Sorry, the amount in the usual cash is too high')
raise ValidationFailed,message raise ValidationFailed(message)
...@@ -10,7 +10,7 @@ def getCountry(site): ...@@ -10,7 +10,7 @@ def getCountry(site):
organisation = context.organisation_module[orga_id] organisation = context.organisation_module[orga_id]
country = organisation.getDefaultRegionTitle() country = organisation.getDefaultRegionTitle()
if country is None: if country is None:
raise ValueError, "No Region found for site %s / %s defined by organisation %s" %(site.getPath(), site.getCodification(), organisation.getPath()) raise ValueError("No Region found for site %s / %s defined by organisation %s" %(site.getPath(), site.getCodification(), organisation.getPath()))
return country return country
......
...@@ -16,4 +16,4 @@ if 'encaisse_des_devises' in vault_list: ...@@ -16,4 +16,4 @@ if 'encaisse_des_devises' in vault_list:
else: else:
return context.currency_module[context.Baobab_getPortalReferenceCurrencyID()].getRelativeUrl() return context.currency_module[context.Baobab_getPortalReferenceCurrencyID()].getRelativeUrl()
raise ValueError, 'No currency found for vault %s' %vault raise ValueError('No currency found for vault %s' %vault)
...@@ -10,7 +10,7 @@ while True: ...@@ -10,7 +10,7 @@ while True:
if not hasattr(site, 'getVaultTypeList'): if not hasattr(site, 'getVaultTypeList'):
context.log('no getVaultTypeList on :', site.getRelativeUrl()) context.log('no getVaultTypeList on :', site.getRelativeUrl())
msg = Message(domain = 'ui', message = 'The site value is misconfigured; report this to system administrators.') msg = Message(domain = 'ui', message = 'The site value is misconfigured; report this to system administrators.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if 'site' in site.getVaultTypeList(): if 'site' in site.getVaultTypeList():
break break
site = site.getParentValue() site = site.getParentValue()
......
...@@ -16,4 +16,4 @@ for object in object_to_check_list: ...@@ -16,4 +16,4 @@ for object in object_to_check_list:
except KeyError: except KeyError:
context.log('Error on ', (context.getRelativeUrl(),node_url)) context.log('Error on ', (context.getRelativeUrl(),node_url))
msg = Message(domain='ui',message='Sorry, wrong source or destination') msg = Message(domain='ui',message='Sorry, wrong source or destination')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -2,7 +2,7 @@ from Products.DCWorkflow.DCWorkflow import ValidationFailed ...@@ -2,7 +2,7 @@ from Products.DCWorkflow.DCWorkflow import ValidationFailed
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import Message
if reference is None: if reference is None:
msg = Message(domain='ui', message="Check not defined.") msg = Message(domain='ui', message="Check not defined.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
model_list = [x model_list = [x
for x in context.checkbook_model_module.objectValues() for x in context.checkbook_model_module.objectValues()
if x.getReference() == reference if x.getReference() == reference
...@@ -11,8 +11,8 @@ model_list = [x ...@@ -11,8 +11,8 @@ model_list = [x
model_list_len = len(model_list) model_list_len = len(model_list)
if model_list_len == 0: if model_list_len == 0:
msg = Message(domain='ui', message="Check not defined.") msg = Message(domain='ui', message="Check not defined.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if model_list_len > 1: if model_list_len > 1:
msg = Message(domain='ui', message="Two many check models with this reference.") msg = Message(domain='ui', message="Two many check models with this reference.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
return model_list[0] return model_list[0]
...@@ -51,7 +51,7 @@ activity_tool = context.portal_activities ...@@ -51,7 +51,7 @@ activity_tool = context.portal_activities
def checkActivities(source_counter): def checkActivities(source_counter):
if activity_tool.countMessageWithTag(source_counter): if activity_tool.countMessageWithTag(source_counter):
msg = Message(domain='ui', message="There are operations pending for this vault that prevent form calculating its position. Please try again later.") msg = Message(domain='ui', message="There are operations pending for this vault that prevent form calculating its position. Please try again later.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
inventory_list = context.portal_simulation.getCurrentInventoryList( inventory_list = context.portal_simulation.getCurrentInventoryList(
#at_date=start_date, #at_date=start_date,
...@@ -85,7 +85,7 @@ for line in line_list : ...@@ -85,7 +85,7 @@ for line in line_list :
serialize_dict[source_counter] = 1 serialize_dict[source_counter] = 1
if source_counter is None: if source_counter is None:
msg = Message(domain="ui", message="No source counter define to check inventory.") msg = Message(domain="ui", message="No source counter define to check inventory.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
#context.log("CashDelivery_checkCounterInventory", "source_counter = %s" %source_counter) #context.log("CashDelivery_checkCounterInventory", "source_counter = %s" %source_counter)
source_object = context.portal_categories.getCategoryValue(source_counter) source_object = context.portal_categories.getCategoryValue(source_counter)
source_object.serialize() source_object.serialize()
...@@ -108,9 +108,9 @@ for line in line_list : ...@@ -108,9 +108,9 @@ for line in line_list :
'letter': cell.getEmissionLetterTitle(), 'letter': cell.getEmissionLetterTitle(),
'status': cell.getCashStatusTranslatedTitle(), 'status': cell.getCashStatusTranslatedTitle(),
'variation':cell.getVariationTitle()}) 'variation':cell.getVariationTitle()})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
else : else :
raise ValueError, 'This script must not be used on movements without cells. It is deprecated and dangerous, therefor it raises.' raise ValueError('This script must not be used on movements without cells. It is deprecated and dangerous, therefor it raises.')
# inventory_value = context.portal_simulation.getCurrentInventory(section=source_counter, resource=line_resource) # inventory_value = context.portal_simulation.getCurrentInventory(section=source_counter, resource=line_resource)
# if inventory_value - line.getQuantity() < 0 : # if inventory_value - line.getQuantity() < 0 :
# msg = Message(domain='ui', message='Insufficient balance for $resource, letter $letter, status $status and variation $variation', mapping={'resource':line.getResourceTranslatedTitle(), # msg = Message(domain='ui', message='Insufficient balance for $resource, letter $letter, status $status and variation $variation', mapping={'resource':line.getResourceTranslatedTitle(),
......
...@@ -16,11 +16,11 @@ if 'compte' in resource_title: ...@@ -16,11 +16,11 @@ if 'compte' in resource_title:
if interval['month'] > 0 or interval["day"] > 0: if interval['month'] > 0 or interval["day"] > 0:
msg = Message(domain='ui', message="Check $check is more than 3 years old.", msg = Message(domain='ui', message="Check $check is more than 3 years old.",
mapping={"check" : check_nb}) mapping={"check" : check_nb})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif interval['year'] > 3: elif interval['year'] > 3:
msg = Message(domain='ui', message="Check $check is more than 3 years old.", msg = Message(domain='ui', message="Check $check is more than 3 years old.",
mapping={"check" : check_nb}) mapping={"check" : check_nb})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif 'virement' in resource_title: elif 'virement' in resource_title:
interval = getIntervalBetweenDates(start_date, stop_date) interval = getIntervalBetweenDates(start_date, stop_date)
...@@ -29,8 +29,8 @@ elif 'virement' in resource_title: ...@@ -29,8 +29,8 @@ elif 'virement' in resource_title:
if interval["day"] > 0: if interval["day"] > 0:
msg = Message(domain='ui', message="Check $check is more than 3 month old.", msg = Message(domain='ui', message="Check $check is more than 3 month old.",
mapping={"check" : check_nb}) mapping={"check" : check_nb})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
elif interval['month'] > 3 or interval['year'] > 0: elif interval['month'] > 3 or interval['year'] > 0:
msg = Message(domain='ui', message="Check $check is more than 3 month old.", msg = Message(domain='ui', message="Check $check is more than 3 month old.",
mapping={"check" : check_nb}) mapping={"check" : check_nb})
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -2,7 +2,7 @@ from DateTime import DateTime ...@@ -2,7 +2,7 @@ from DateTime import DateTime
user_site_list = context.Baobab_getUserAssignedSiteList() user_site_list = context.Baobab_getUserAssignedSiteList()
if len(user_site_list) == 0: if len(user_site_list) == 0:
raise ValueError, "You cannot create a CounterDate if you don't have an assignment." raise ValueError("You cannot create a CounterDate if you don't have an assignment.")
site = context.Baobab_getVaultSite(user_site_list[0]) site = context.Baobab_getVaultSite(user_site_list[0])
context.setSiteValue(site) context.setSiteValue(site)
......
...@@ -40,7 +40,7 @@ if same_type(vault, 'a'): ...@@ -40,7 +40,7 @@ if same_type(vault, 'a'):
vault_url_list = [vault,] vault_url_list = [vault,]
#context.log("vault_url_list", vault_url_list) #context.log("vault_url_list", vault_url_list)
if vault_url_list is None: if vault_url_list is None:
raise ValueError, "The vault must be defined" raise ValueError("The vault must be defined")
for vault_url in vault_url_list: for vault_url in vault_url_list:
vault_dict[vault_url] = 1 vault_dict[vault_url] = 1
vault_inventory_dict[vault_url] = {} vault_inventory_dict[vault_url] = {}
...@@ -67,7 +67,7 @@ total_inventory_list = [] ...@@ -67,7 +67,7 @@ total_inventory_list = []
inventory_kw = {} inventory_kw = {}
#context.log('CounterModule_getVaultTransactionList, vault_report_type',vault_report_type) #context.log('CounterModule_getVaultTransactionList, vault_report_type',vault_report_type)
if vault_report_type == 'inventory' and from_date is not None: if vault_report_type == 'inventory' and from_date is not None:
raise ValueError, "The from date must be None in the case of inventory" raise ValueError("The from date must be None in the case of inventory")
if vault_report_type is None or vault_report_type=='inventory': if vault_report_type is None or vault_report_type=='inventory':
inventory_kw['group_by_variation'] = 1 inventory_kw['group_by_variation'] = 1
inventory_kw['group_by_resource'] = 1 inventory_kw['group_by_resource'] = 1
......
...@@ -16,13 +16,13 @@ transaction.Baobab_checkAccountingDateOpen(site=site, date=date) ...@@ -16,13 +16,13 @@ transaction.Baobab_checkAccountingDateOpen(site=site, date=date)
price = transaction.getSourceTotalAssetPrice() price = transaction.getSourceTotalAssetPrice()
if price is None or price <= 0: if price is None or price <= 0:
msg = Message(domain='ui', message='Amount is not valid.') msg = Message(domain='ui', message='Amount is not valid.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if transaction.getSiteValue() is None: if transaction.getSiteValue() is None:
msg = Message(domain='ui', message='Sorry, no site defined.') msg = Message(domain='ui', message='Sorry, no site defined.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if transaction.getResource() is None: if transaction.getResource() is None:
msg = Message(domain='ui', message='No resource defined.') msg = Message(domain='ui', message='No resource defined.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Check the source bank account. # Check the source bank account.
source_bank_account = transaction.getSourcePaymentValue() source_bank_account = transaction.getSourcePaymentValue()
...@@ -31,7 +31,7 @@ source_bank_account = transaction.getSourcePaymentValue() ...@@ -31,7 +31,7 @@ source_bank_account = transaction.getSourcePaymentValue()
nb_transfer_line = len(transaction.objectValues(portal_type='Accounting Cancellation Line')) nb_transfer_line = len(transaction.objectValues(portal_type='Accounting Cancellation Line'))
if nb_transfer_line == 0: if nb_transfer_line == 0:
msg = Message(domain='ui', message='You must add line before validating the operation') msg = Message(domain='ui', message='You must add line before validating the operation')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# only one line can be defined with SICA/STAR, on order as it can be cancel or reject later # only one line can be defined with SICA/STAR, on order as it can be cancel or reject later
#if transaction.getExternalSoftware() in ('sica', 'star') and nb_transfer_line != 1: #if transaction.getExternalSoftware() in ('sica', 'star') and nb_transfer_line != 1:
...@@ -46,21 +46,21 @@ for line in transaction.objectValues(portal_type='Accounting Cancellation Line') ...@@ -46,21 +46,21 @@ for line in transaction.objectValues(portal_type='Accounting Cancellation Line')
if line.getSourcePaymentReference(None) is None and \ if line.getSourcePaymentReference(None) is None and \
line.getSourceSection() is None: line.getSourceSection() is None:
msg = Message(domain='ui', message="No account defined on line.") msg = Message(domain='ui', message="No account defined on line.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# check we don't have both account and accounting code defined # check we don't have both account and accounting code defined
if line.getDestinationPayment(None) is not None \ if line.getDestinationPayment(None) is not None \
and line.getDestinationSection() is not None: and line.getDestinationSection() is not None:
msg = Message(domain='ui', message="You can't defined account and accounting code on line.") msg = Message(domain='ui', message="You can't defined account and accounting code on line.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# check that at least destination_payment or destination_section is defined # check that at least destination_payment or destination_section is defined
if line.getDestinationPayment() is None and \ if line.getDestinationPayment() is None and \
line.getDestinationSection() is None: line.getDestinationSection() is None:
msg = Message(domain='ui', message="Destination account is not defined.") msg = Message(domain='ui', message="Destination account is not defined.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Index the banking operation line so it impacts account position # Index the banking operation line so it impacts account position
if line.getSourcePaymentReference() not in (None, ''): if line.getSourcePaymentReference() not in (None, ''):
context.BankingOperationLine_index(line, source=1) context.BankingOperationLine_index(line, source=1)
if total_line_price != transaction.getSourceTotalAssetPrice(): if total_line_price != transaction.getSourceTotalAssetPrice():
msg = Message(domain='ui', message="Total price doesn't match between line and document.") msg = Message(domain='ui', message="Total price doesn't match between line and document.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -7,14 +7,14 @@ bank_account = state_change['object'] ...@@ -7,14 +7,14 @@ bank_account = state_change['object']
if bank_account.getParentValue().getPortalType()!= 'Person': if bank_account.getParentValue().getPortalType()!= 'Person':
vliste = bank_account.checkConsistency() vliste = bank_account.checkConsistency()
if len(vliste) != 0: if len(vliste) != 0:
raise ValidationFailed, (vliste[0].getTranslatedMessage(),) raise ValidationFailed(vliste[0].getTranslatedMessage(),)
if bank_account.getParentValue().getPortalType()== 'Person': if bank_account.getParentValue().getPortalType()== 'Person':
# Can't have two bank account # Can't have two bank account
for obj in bank_account.getParentValue().objectValues(): for obj in bank_account.getParentValue().objectValues():
if obj.getPortalType() == "Bank Account" and obj.getValidationState() not in ('draft', 'closed') \ if obj.getPortalType() == "Bank Account" and obj.getValidationState() not in ('draft', 'closed') \
and obj.getSource() == bank_account.getSource() and obj.getPath()!= bank_account.getPath(): and obj.getSource() == bank_account.getSource() and obj.getPath()!= bank_account.getPath():
raise ValidationFailed, "You cannot open two bank accounts for the same person on the same site" raise ValidationFailed("You cannot open two bank accounts for the same person on the same site")
valid_state = ["valid", "being_closed", "validating_closing", valid_state = ["valid", "being_closed", "validating_closing",
"being_modified", "validating_modification", "closed"] "being_modified", "validating_modification", "closed"]
...@@ -26,7 +26,7 @@ same_ref_list = context.portal_catalog(validation_state=valid_state, ...@@ -26,7 +26,7 @@ same_ref_list = context.portal_catalog(validation_state=valid_state,
for doc in same_ref_list: for doc in same_ref_list:
if doc.getPath() != bank_account.getPath(): if doc.getPath() != bank_account.getPath():
context.log("doc path %s" %(doc.getPath(),)) context.log("doc path %s" %(doc.getPath(),))
raise ValidationFailed, "Bank account with same reference already exists" raise ValidationFailed("Bank account with same reference already exists")
# Same for internal reference if exists # Same for internal reference if exists
...@@ -38,4 +38,4 @@ if bank_account.getInternalBankAccountNumber() not in ("", None): ...@@ -38,4 +38,4 @@ if bank_account.getInternalBankAccountNumber() not in ("", None):
for doc in same_ref_list: for doc in same_ref_list:
if doc.getPath() != bank_account.getPath(): if doc.getPath() != bank_account.getPath():
context.log("doc path %s" %(doc.getPath(),)) context.log("doc path %s" %(doc.getPath(),))
raise ValidationFailed, "Bank account with same internal reference already exists" raise ValidationFailed("Bank account with same internal reference already exists")
...@@ -5,4 +5,4 @@ for check in checkbook.objectValues(): ...@@ -5,4 +5,4 @@ for check in checkbook.objectValues():
if check.getSimulationState() != 'deleted': if check.getSimulationState() != 'deleted':
msg = Message(domain="ui", message="Sorry, no way to delete this check $id", msg = Message(domain="ui", message="Sorry, no way to delete this check $id",
mapping = {'id' : check.getId()}) mapping = {'id' : check.getId()})
raise ValueError, (msg,) raise ValueError(msg,)
...@@ -8,4 +8,4 @@ if len(check_result) > 0: ...@@ -8,4 +8,4 @@ if len(check_result) > 0:
check_type = N_(check_result[0][-1]) check_type = N_(check_result[0][-1])
# TODO: use nice url encoding method there instead of replace() # TODO: use nice url encoding method there instead of replace()
check_details = check_result[0][-2].replace('<', '&lt;').replace('>', '&gt;') check_details = check_result[0][-2].replace('<', '&lt;').replace('>', '&gt;')
raise ValidationFailed, "%s : %s" % (check_type, check_details) raise ValidationFailed("%s : %s" % (check_type, check_details))
...@@ -8,7 +8,7 @@ site = transaction.getSiteValue() ...@@ -8,7 +8,7 @@ site = transaction.getSiteValue()
while True: while True:
if not hasattr(site, 'getVaultTypeList'): if not hasattr(site, 'getVaultTypeList'):
msg = Message(domain = 'ui', message = 'The site value is misconfigured; report this to system administrators.') msg = Message(domain = 'ui', message = 'The site value is misconfigured; report this to system administrators.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if 'site' in site.getVaultTypeList(): if 'site' in site.getVaultTypeList():
break break
site = site.getParentValue() site = site.getParentValue()
......
...@@ -13,7 +13,7 @@ date_list = [x.getObject() for x in context.portal_catalog(**kwd)] ...@@ -13,7 +13,7 @@ date_list = [x.getObject() for x in context.portal_catalog(**kwd)]
current_date = None current_date = None
if len(date_list) == 0: if len(date_list) == 0:
msg = Message(domain = 'ui', message = 'No Counter Date found for this counter') msg = Message(domain = 'ui', message = 'No Counter Date found for this counter')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
else: else:
current_date = date_list[0].getStartDate() current_date = date_list[0].getStartDate()
......
...@@ -8,7 +8,7 @@ site = transaction.getSiteValue() ...@@ -8,7 +8,7 @@ site = transaction.getSiteValue()
while True: while True:
if not hasattr(site, 'getVaultTypeList'): if not hasattr(site, 'getVaultTypeList'):
msg = Message(domain = 'ui', message = 'The site value is misconfigured; report this to system administrators.') msg = Message(domain = 'ui', message = 'The site value is misconfigured; report this to system administrators.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
if 'site' in site.getVaultTypeList(): if 'site' in site.getVaultTypeList():
break break
site = site.getParentValue() site = site.getParentValue()
...@@ -18,4 +18,4 @@ date_list = [x.getObject() for x in context.portal_catalog(**kwd)] ...@@ -18,4 +18,4 @@ date_list = [x.getObject() for x in context.portal_catalog(**kwd)]
if len(date_list) == 0: if len(date_list) == 0:
msg = Message(domain='ui', message="Counter date is not opened.") msg = Message(domain='ui', message="Counter date is not opened.")
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
...@@ -10,7 +10,7 @@ exchange_line = state_change['object'] ...@@ -10,7 +10,7 @@ exchange_line = state_change['object']
if exchange_line.getBasePrice() in (None, 0, 0.0): if exchange_line.getBasePrice() in (None, 0, 0.0):
msg = Message(domain = 'ui', message = 'Sorry, you must define a fixing price.') msg = Message(domain = 'ui', message = 'Sorry, you must define a fixing price.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# We have to looking for other currency exchanges lines # We have to looking for other currency exchanges lines
...@@ -34,7 +34,7 @@ line_list = [x for x in exchange_line.portal_domains.searchPredicateList(temp_ob ...@@ -34,7 +34,7 @@ line_list = [x for x in exchange_line.portal_domains.searchPredicateList(temp_ob
start_date = exchange_line.getStartDate() start_date = exchange_line.getStartDate()
if start_date is None: if start_date is None:
msg = Message(domain = 'ui', message = 'Sorry, you must define a start date.') msg = Message(domain = 'ui', message = 'Sorry, you must define a start date.')
raise ValidationFailed, (msg,) raise ValidationFailed(msg,)
# Make sure there is not two exchange lines wich defines the same dates # Make sure there is not two exchange lines wich defines the same dates
# for this particular ressource and price_currency # for this particular ressource and price_currency
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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