[Erp5-report] r40896 arnaud.fontaine - in /erp5/trunk/products/ERP5: Document/ PropertySheet/
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Nov 30 05:39:43 CET 2010
Author: arnaud.fontaine
Date: Tue Nov 30 05:39:43 2010
New Revision: 40896
URL: http://svn.erp5.org?rev=40896&view=rev
Log:
Add Accounting Transaction Balance Constraint for ZODB Property Sheets
Added:
erp5/trunk/products/ERP5/Document/AccountingTransactionBalanceConstraint.py
- copied, changed from r40829, erp5/trunk/products/ERP5/Constraint/AccountingTransactionBalance.py
erp5/trunk/products/ERP5/PropertySheet/AccountingTransactionBalanceConstraint.py
Copied: erp5/trunk/products/ERP5/Document/AccountingTransactionBalanceConstraint.py (from r40829, erp5/trunk/products/ERP5/Constraint/AccountingTransactionBalance.py)
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/AccountingTransactionBalanceConstraint.py?p2=erp5/trunk/products/ERP5/Document/AccountingTransactionBalanceConstraint.py&p1=erp5/trunk/products/ERP5/Constraint/AccountingTransactionBalance.py&r1=40829&r2=40896&rev=40896&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Constraint/AccountingTransactionBalance.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/AccountingTransactionBalanceConstraint.py [utf8] Tue Nov 30 05:39:43 2010
@@ -1,7 +1,8 @@
##############################################################################
#
-# Copyright (c) 2007 Nexedi SA and Contributors. All Rights Reserved.
-# Jerome Perrin <jerome at nexedi.com>
+# Copyright (c) 2007-2010 Nexedi SA and Contributors. All Rights Reserved.
+# Jerome Perrin <jerome at nexedi.com>
+# Arnaud Fontaine <arnaud.fontaine at nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
@@ -26,24 +27,32 @@
#
##############################################################################
-from Products.ERP5Type.Constraint import Constraint
-translateString = lambda msg: msg # just to extract messages
+from Products.ERP5Type.mixin.constraint import ConstraintMixin
+from Products.ERP5Type import PropertySheet
-class AccountingTransactionBalance(Constraint):
- """Check that accounting transaction total debit and total credit are equals.
+class AccountingTransactionBalanceConstraint(ConstraintMixin):
"""
-
- _message_id_list = [ 'message_transaction_not_balanced_for_source',
- 'message_transaction_not_balanced_for_destination' ]
-
- message_transaction_not_balanced_for_source = translateString(
- 'Transaction is not balanced for ${section_title}')
- message_transaction_not_balanced_for_destination = translateString(
- 'Transaction is not balanced for ${section_title}')
+ Check that accounting transaction total debit and total credit are equals.
+
+ This is only relevant for ZODB Property Sheets (filesystem Property
+ Sheets rely on Products.ERP5.Constraint.AccountingTransactionBalance
+ instead).
+ """
+ meta_type = 'ERP5 Accounting Transaction Balance Constraint'
+ portal_type = 'Accounting Transaction Balance Constraint'
+
+ property_sheets = (PropertySheet.SimpleItem,
+ PropertySheet.Predicate,
+ PropertySheet.Reference,
+ PropertySheet.AccountingTransactionBalanceConstraint)
def checkConsistency(self, obj, fixit=0):
- """Implement here the consistency checker
"""
+ Check the object's consistency
+ """
+ if not self.test(obj):
+ return []
+
error_list = []
source_sum = dict()
destination_sum = dict()
@@ -57,7 +66,7 @@ class AccountingTransactionBalance(Const
section = line.getDestinationSectionValue()
destination_sum[section] = destination_sum.get(section, 0) + \
(line.getDestinationInventoriatedTotalAssetPrice() or 0)
-
+
for section, total in source_sum.items():
precision = 2
if section is not None and\
@@ -70,7 +79,7 @@ class AccountingTransactionBalance(Const
'message_transaction_not_balanced_for_source'),
mapping=dict(section_title=section.getTranslatedTitle())))
break
-
+
for section, total in destination_sum.items():
precision = 2
if section is not None and\
Added: erp5/trunk/products/ERP5/PropertySheet/AccountingTransactionBalanceConstraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/PropertySheet/AccountingTransactionBalanceConstraint.py?rev=40896&view=auto
==============================================================================
--- erp5/trunk/products/ERP5/PropertySheet/AccountingTransactionBalanceConstraint.py (added)
+++ erp5/trunk/products/ERP5/PropertySheet/AccountingTransactionBalanceConstraint.py [utf8] Tue Nov 30 05:39:43 2010
@@ -0,0 +1,45 @@
+##############################################################################
+#
+# Copyright (c) 2010 Nexedi SARL and Contributors. All Rights Reserved.
+# Arnaud Fontaine <arnaud.fontaine at nexedi.com>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+class AccountingTransactionBalanceConstraint:
+ """
+ Define an Accounting Transaction Balance Constraint for ZODB
+ Property Sheets
+ """
+ _properties = (
+ { 'id': 'message_transaction_not_balanced_for_source',
+ 'type': 'string',
+ 'description' : 'Error message when transaction is not balanced '\
+ 'for source',
+ 'default': 'Transaction is not balanced for ${section_title}' },
+ { 'id': 'message_transaction_not_balanced_for_destination',
+ 'type': 'string',
+ 'description' : 'Error message when transaction is not balanced '\
+ 'for destination',
+ 'default': 'Transaction is not balanced for ${section_title}' },
+ )
More information about the Erp5-report
mailing list