Commit b6ccfc26 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: erp5_accounting: Migrate Unit Tests.

parent 719b21e3
......@@ -51,6 +51,7 @@ QUIET = 1
transaction_to_line_mapping = {
'Accounting Transaction': 'Accounting Transaction Line',
'Balance Transaction': 'Balance Transaction Line',
'Internal Invoice Transaction': 'Internal Invoice Transaction Line',
'Purchase Invoice Transaction': 'Purchase Invoice Transaction Line',
'Sale Invoice Transaction': 'Sale Invoice Transaction Line',
'Payment Transaction': 'Accounting Transaction Line',
......@@ -1083,7 +1084,7 @@ class TestClosingPeriod(AccountingTestCase):
period.setStartDate(DateTime(2006, 1, 1))
period.setStopDate(DateTime(2006, 12, 31))
transaction1 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 1),
portal_type='Accounting Transaction',
simulation_state='delivered',
......@@ -1092,7 +1093,7 @@ class TestClosingPeriod(AccountingTestCase):
dict(source_value=self.account_module.stocks,
source_credit=500)))
transaction2 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 2),
portal_type='Accounting Transaction',
simulation_state='delivered',
......@@ -1173,7 +1174,7 @@ class TestClosingPeriod(AccountingTestCase):
portal_type='Account',
account_type='equity')
transaction1 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 1),
destination_section_value=organisation_module.client_1,
portal_type='Sale Invoice Transaction',
......@@ -1183,7 +1184,7 @@ class TestClosingPeriod(AccountingTestCase):
dict(source_value=self.account_module.receivable,
source_credit=100)))
transaction2 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 2),
destination_section_value=organisation_module.client_2,
portal_type='Sale Invoice Transaction',
......@@ -1275,7 +1276,7 @@ class TestClosingPeriod(AccountingTestCase):
id='bank2', reference='bank2',
portal_type='Bank Account')
transaction1 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 1),
destination_section_value=organisation_module.client_1,
source_payment_value=bank1,
......@@ -1288,7 +1289,7 @@ class TestClosingPeriod(AccountingTestCase):
source_credit=100)))
# we are destination on this one
transaction2 = self._makeOne(
self._makeOne(
stop_date=DateTime(2006, 1, 2),
destination_section_value=self.section,
destination_payment_value=bank2,
......@@ -1400,7 +1401,7 @@ class TestClosingPeriod(AccountingTestCase):
account_type='equity')
# 2 Transactions for clients 1 and 2 on ledger accounting/general
transaction1 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 1),
portal_type='Sale Invoice Transaction',
ledger='accounting/general',
......@@ -1411,7 +1412,7 @@ class TestClosingPeriod(AccountingTestCase):
dict(source_value=self.account_module.receivable,
source_credit=100)))
transaction2 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 2),
portal_type='Sale Invoice Transaction',
ledger='accounting/general',
......@@ -1423,7 +1424,7 @@ class TestClosingPeriod(AccountingTestCase):
source_credit=200)))
# 2 Transactions for clients 1 and 2 on ledger accounting/detailed
transaction3 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 1),
portal_type='Sale Invoice Transaction',
ledger='accounting/detailed',
......@@ -1434,7 +1435,7 @@ class TestClosingPeriod(AccountingTestCase):
dict(source_value=self.account_module.receivable,
source_credit=400)))
transaction4 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 2),
portal_type='Sale Invoice Transaction',
ledger='accounting/detailed',
......@@ -1568,7 +1569,7 @@ class TestClosingPeriod(AccountingTestCase):
account_type='equity')
# 2 Transactions for clients 1 and 2 on ledger accounting/general
transaction1 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 1),
portal_type='Sale Invoice Transaction',
ledger='accounting/general',
......@@ -1579,7 +1580,7 @@ class TestClosingPeriod(AccountingTestCase):
dict(source_value=self.account_module.receivable,
source_credit=100)))
transaction2 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 2),
portal_type='Sale Invoice Transaction',
ledger='accounting/general',
......@@ -1591,7 +1592,7 @@ class TestClosingPeriod(AccountingTestCase):
source_credit=200)))
# 2 Transactions for clients 1 and 2 on ledger accounting/detailed
transaction3 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 1),
portal_type='Sale Invoice Transaction',
ledger='accounting/detailed',
......@@ -1602,7 +1603,7 @@ class TestClosingPeriod(AccountingTestCase):
dict(source_value=self.account_module.receivable,
source_credit=400)))
transaction4 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 2),
portal_type='Sale Invoice Transaction',
ledger='accounting/detailed',
......@@ -1732,7 +1733,7 @@ class TestClosingPeriod(AccountingTestCase):
period.setStartDate(DateTime(2006, 1, 1))
period.setStopDate(DateTime(2006, 12, 31))
transaction1 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 1),
title='Yen',
resource='currency_module/yen',
......@@ -1746,7 +1747,7 @@ class TestClosingPeriod(AccountingTestCase):
source_asset_credit=1.1,
source_credit=100)))
transaction2 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 2),
title='Dollar',
resource='currency_module/usd',
......@@ -1889,7 +1890,7 @@ class TestClosingPeriod(AccountingTestCase):
period.setStartDate(DateTime(2006, 1, 1))
period.setStopDate(DateTime(2006, 12, 31))
transaction1 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 1),
title='Yen',
resource='currency_module/yen',
......@@ -1903,7 +1904,7 @@ class TestClosingPeriod(AccountingTestCase):
source_asset_credit=1.1,
source_credit=100)))
transaction2 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 2),
title='Dollar',
resource='currency_module/usd',
......@@ -2028,7 +2029,7 @@ class TestClosingPeriod(AccountingTestCase):
self.assertEqual('started', period.getSimulationState())
# create a simple transaction in the period
accounting_transaction = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 6, 30),
portal_type='Sale Invoice Transaction',
destination_section_value=self.organisation_module.client_1,
......@@ -2082,7 +2083,7 @@ class TestClosingPeriod(AccountingTestCase):
period.setStopDate(DateTime(2006, 12, 31))
period.start()
transaction_main = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 2),
portal_type='Purchase Invoice Transaction',
destination_section_value=self.main_section,
......@@ -2156,7 +2157,7 @@ class TestClosingPeriod(AccountingTestCase):
period_section.setStopDate(DateTime(2006, 12, 31))
period_section.start()
transaction_main = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 2),
portal_type='Purchase Invoice Transaction',
destination_section_value=self.main_section,
......@@ -2239,7 +2240,7 @@ class TestClosingPeriod(AccountingTestCase):
period.setStopDate(DateTime(2006, 12, 31))
period.start()
transaction_main = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 2),
portal_type='Purchase Invoice Transaction',
destination_section_value=self.main_section,
......@@ -2271,7 +2272,7 @@ class TestClosingPeriod(AccountingTestCase):
period1.setStopDate(DateTime(2006, 12, 31))
period1.start()
transaction1 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 2),
portal_type='Purchase Invoice Transaction',
source_section_value=self.organisation_module.client_1,
......@@ -2301,7 +2302,7 @@ class TestClosingPeriod(AccountingTestCase):
period2.setStopDate(DateTime(2007, 12, 31))
period2.start()
transaction2 = self._makeOne(
self._makeOne(
start_date=DateTime(2007, 1, 2),
portal_type='Accounting Transaction',
simulation_state='delivered',
......@@ -2309,7 +2310,7 @@ class TestClosingPeriod(AccountingTestCase):
source_debit=100),
dict(source_value=pl_account,
source_credit=100)))
transaction3 = self._makeOne(
self._makeOne(
start_date=DateTime(2007, 1, 3),
portal_type='Purchase Invoice Transaction',
source_section_value=self.organisation_module.client_1,
......@@ -2371,7 +2372,7 @@ class TestClosingPeriod(AccountingTestCase):
title='Profit & Loss')
pl_account.validate()
transaction1 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 1),
portal_type='Accounting Transaction',
simulation_state='delivered',
......@@ -2495,7 +2496,7 @@ class TestClosingPeriod(AccountingTestCase):
portal_type='Account',
account_type='equity')
transaction1 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 1),
portal_type='Sale Invoice Transaction',
destination_section_value=self.organisation_module.client_1,
......@@ -2647,7 +2648,7 @@ class TestClosingPeriod(AccountingTestCase):
def test_InventoryIndexingNodeDiffOnNode(self):
# Balance Transactions are indexed as Inventories.
transaction1 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 1),
portal_type='Accounting Transaction',
simulation_state='delivered',
......@@ -2735,7 +2736,7 @@ class TestClosingPeriod(AccountingTestCase):
def test_BalanceTransactionLineBrainGetObject(self):
# Balance Transaction Line can be retrieved using Brain.getObject
existing_transaction = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 31),
portal_type='Sale Invoice Transaction',
simulation_state='delivered',
......@@ -2796,7 +2797,7 @@ class TestClosingPeriod(AccountingTestCase):
def test_BalanceTransactionLineBrainGetObjectDifferentThirdParties(self):
# Balance Transaction Line can be retrieved using Brain.getObject, when
# the balance is for different third parties
existing_transaction = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 30),
portal_type='Sale Invoice Transaction',
simulation_state='delivered',
......@@ -2805,7 +2806,7 @@ class TestClosingPeriod(AccountingTestCase):
source_debit=30),
dict(source_value=self.account_module.goods_sales,
source_credit=30)))
another_existing_transaction = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 31),
portal_type='Sale Invoice Transaction',
simulation_state='delivered',
......@@ -2866,7 +2867,7 @@ class TestClosingPeriod(AccountingTestCase):
# check that dates are correctly used for Balance Transaction indexing
organisation_module = self.organisation_module
transaction1 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 12, 31),
destination_section_value=organisation_module.client_1,
portal_type='Sale Invoice Transaction',
......@@ -2881,11 +2882,11 @@ class TestClosingPeriod(AccountingTestCase):
destination_section_value=self.section,
start_date=DateTime(2007, 1, 1),
resource_value=self.currency_module.euro,)
balance_line = balance.newContent(
balance.newContent(
portal_type='Balance Transaction Line',
destination_value=self.account_module.equity,
destination_debit=100,)
balance_line = balance.newContent(
balance.newContent(
portal_type='Balance Transaction Line',
source_section_value=organisation_module.client_1,
destination_value=self.account_module.receivable,
......@@ -2907,7 +2908,7 @@ class TestClosingPeriod(AccountingTestCase):
# this is a transaction with the same date as the balance transaction, but
# this transaction should not be taken into account when we reindex the
# Balance Transaction.
transaction2 = self._makeOne(
self._makeOne(
start_date=DateTime(2007, 1, 1),
destination_section_value=organisation_module.client_1,
portal_type='Sale Invoice Transaction',
......@@ -2940,7 +2941,7 @@ class TestClosingPeriod(AccountingTestCase):
destination_section_value=self.section,
start_date=DateTime(2006, 12, 31),
resource_value=self.currency_module.euro,)
balance_line = balance.newContent(
balance.newContent(
portal_type='Balance Transaction Line',
destination_value=self.account_module.receivable,
destination_debit=100,)
......@@ -2977,7 +2978,7 @@ class TestClosingPeriod(AccountingTestCase):
destination_section_value=self.section,
start_date=DateTime(2006, 12, 31),
resource_value=self.currency_module.euro,)
balance_line = balance.newContent(
balance.newContent(
portal_type='Balance Transaction Line',
destination_value=self.account_module.receivable,
destination_debit=100,)
......@@ -3009,7 +3010,7 @@ class TestClosingPeriod(AccountingTestCase):
portal_type='Account',
account_type='equity')
transaction1 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 1),
destination_section_value=organisation_module.client_1,
portal_type='Sale Invoice Transaction',
......@@ -3057,7 +3058,6 @@ class TestClosingPeriod(AccountingTestCase):
def test_ParrallelClosingRefused(self):
organisation_module = self.organisation_module
stool = self.portal.portal_simulation
period = self.section.newContent(portal_type='Accounting Period')
period.setStartDate(DateTime(2006, 1, 1))
period.setStopDate(DateTime(2006, 12, 31))
......@@ -3071,7 +3071,7 @@ class TestClosingPeriod(AccountingTestCase):
portal_type='Account',
account_type='equity')
transaction1 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 1),
destination_section_value=organisation_module.client_1,
portal_type='Sale Invoice Transaction',
......@@ -3097,11 +3097,11 @@ class TestClosingPeriod(AccountingTestCase):
period.setStopDate(DateTime(2006, 12, 31))
period.start()
pl = self.portal.account_module.newContent(
self.portal.account_module.newContent(
portal_type='Account',
account_type='equity')
transaction1 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 1),
destination_section_value=organisation_module.client_1,
portal_type='Sale Invoice Transaction',
......@@ -3131,7 +3131,7 @@ class TestClosingPeriod(AccountingTestCase):
# This transaction has lines that should block closing for `main_section`,
# but not for `section` because from `section` side there are no accounting lines.
transaction1 = self._makeOne(
self._makeOne(
start_date=DateTime(2006, 1, 1),
source_section_value=self.main_section,
source_value=self.main_section,
......@@ -3348,7 +3348,7 @@ class TestTransactions(AccountingTestCase):
def test_Organisation_getMappingRelatedOrganisation(self):
# the main section needs an accounting period to be treated as mapping
# related by Organisation_getMappingRelatedOrganisation
section_period_2001 = self.main_section.newContent(
self.main_section.newContent(
portal_type='Accounting Period',
short_title='code-2001',
start_date=DateTime(2001, 1, 1),
......@@ -3520,7 +3520,7 @@ class TestTransactions(AccountingTestCase):
source_debit=100),
dict(source_value=self.account_module.receivable,
source_credit=100),))
accounting_transaction = self._makeOne(
self._makeOne(
destination_section_value=self.organisation_module.client_1,
causality_value=invoice,
lines=(dict(source_value=self.account_module.goods_purchase,
......@@ -3607,7 +3607,7 @@ class TestTransactions(AccountingTestCase):
for portal_type in accounting_module.getVisibleAllowedContentTypeList():
accounting_transaction = accounting_module.newContent(
portal_type=portal_type)
line = accounting_transaction.newContent(
accounting_transaction.newContent(
id = 'line_with_grouping_reference',
grouping_reference='A',
grouping_date=DateTime(),
......@@ -3727,7 +3727,6 @@ class TestTransactions(AccountingTestCase):
source_debit=100),
dict(source_value=self.account_module.bank,
source_credit=100,)))
payment_line = payment.line_with_grouping_reference
self.tic()
invoice.cancel()
invoice.manage_delObjects([line.getId() for line in invoice.contentValues()])
......@@ -3799,7 +3798,7 @@ class TestTransactions(AccountingTestCase):
# the main section needs an accounting period to be treated as mapping
# related by Organisation_getMappingRelatedOrganisation
section_period_2001 = self.main_section.newContent(
self.main_section.newContent(
portal_type='Accounting Period',
short_title='code-2001',
start_date=DateTime(2001, 1, 1),
......@@ -4054,7 +4053,6 @@ class TestTransactions(AccountingTestCase):
source_debit=100.032345),
dict(source_value=self.account_module.receivable,
source_credit=100.000001)))
precision = invoice.getQuantityPrecisionFromResource(invoice.getResource())
invoice.newContent(portal_type='Invoice Line', quantity=1, price=100)
self.assertRaises(invoice.AccountingTransaction_roundDebitCredit)
......@@ -4940,10 +4938,10 @@ class TestAccountingWithSequences(ERP5TypeTestCase):
created_by_builder = 0,
)
line = invoice.newContent(
invoice.newContent(
portal_type = self.sale_invoice_transaction_line_portal_type,
quantity = 100, source_value = sequence.get('account_list')[0])
line = invoice.newContent(
invoice.newContent(
portal_type = self.sale_invoice_transaction_line_portal_type,
quantity = -100, source_value = sequence.get('account_list')[1])
sequence.edit(invoice_list = [invoice])
......@@ -5113,7 +5111,7 @@ class TestAccountingWithSequences(ERP5TypeTestCase):
def createAccountingTransaction(self,
portal_type=accounting_transaction_portal_type,
line_portal_type=accounting_transaction_line_portal_type,
quantity=100, reindex=1, check_consistency=1, **kw):
quantity=100, reindex=1, check_consistency=1, **kw): # pylint: disable=redefined-outer-name
"""Creates an accounting transaction.
By default, this transaction contains 2 lines, income and receivable.
quantity - The quantity property on created lines.
......@@ -5272,7 +5270,7 @@ class TestAccountingWithSequences(ERP5TypeTestCase):
self.getWorkflowTool().doActionFor(accounting_transaction, 'stop_action')
self.assertEqual(accounting_transaction.getSimulationState(), 'stopped')
except ValidationFailed as err:
self.assert_(0, "Validation failed : %s" % err.msg)
raise AssertionError("Validation failed : %s" % err.msg)
# if we do not use any payable / receivable account, then we can
# validate the transaction without setting the mirror section.
......@@ -5294,13 +5292,12 @@ class TestAccountingWithSequences(ERP5TypeTestCase):
self.getWorkflowTool().doActionFor(accounting_transaction, 'stop_action')
self.assertEqual(accounting_transaction.getSimulationState(), 'stopped')
except ValidationFailed as err:
self.assert_(0, "Validation failed : %s" % err.msg)
raise AssertionError("Validation failed : %s" % err.msg)
def stepValidateNoCurrency(self, sequence, sequence_list=None, **kw) :
"""Check validation behaviour related to currency.
"""
accounting_transaction = sequence.get('transaction')
old_resource = accounting_transaction.getResource()
accounting_transaction.setResource(None)
self.assertRaises(ValidationFailed,
self.getWorkflowTool().doActionFor,
......@@ -5368,7 +5365,7 @@ class TestAccountingWithSequences(ERP5TypeTestCase):
# 0 quantity, but a destination asset price => do not delete the
# line
accounting_transaction = self.createAccountingTransaction()
new_line = accounting_transaction.newContent(
accounting_transaction.newContent(
portal_type = self.accounting_transaction_line_portal_type)
self.assertEqual(len(accounting_transaction.getMovementList()), 3)
line_list = accounting_transaction.getMovementList()
......@@ -5385,7 +5382,7 @@ class TestAccountingWithSequences(ERP5TypeTestCase):
self.getWorkflowTool().doActionFor(accounting_transaction, 'stop_action')
self.assertEqual(accounting_transaction.getSimulationState(), 'stopped')
except ValidationFailed as err:
self.assert_(0, "Validation failed : %s" % err.msg)
raise AssertionError("Validation failed : %s" % err.msg)
def stepValidateNotBalanced(self, sequence, sequence_list=None, **kw) :
"""Check validation behaviour when transaction is not balanced.
......@@ -5430,7 +5427,7 @@ class TestAccountingWithSequences(ERP5TypeTestCase):
self.getWorkflowTool().doActionFor(accounting_transaction, 'stop_action')
self.assertEqual(accounting_transaction.getSimulationState(), 'stopped')
except ValidationFailed as err:
self.assert_(0, "Validation failed : %s" % err.msg)
raise AssertionError("Validation failed : %s" % err.msg)
def stepValidateNoPayment(self, sequence, sequence_list=None, **kw) :
"""Check validation behaviour related to payment & mirror_payment.
......@@ -5519,7 +5516,7 @@ class TestAccountingWithSequences(ERP5TypeTestCase):
source_section=accounting_transaction.getSourceSection(),
destination_section=accounting_transaction.getDestinationSection(),
created_by_builder=1)
for i in range(3):
for _ in range(3):
another_accounting_transaction.newContent(
portal_type=self.accounting_transaction_line_portal_type)
lines_count = len(another_accounting_transaction.getMovementList())
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testAccounting</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testAccounting</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testAccounting</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -33,7 +33,7 @@ import unittest
from DateTime import DateTime
from Products.ERP5.tests.testAccounting import AccountingTestCase
from erp5.component.test.testAccounting import AccountingTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5ReportTestCase
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
......@@ -523,7 +523,6 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
node_title='7',
debit=0,
credit=500)
stat_line = line_list[-1]
self.assertTrue(line_list[-1].isStatLine())
self.checkLineProperties(line_list[-1], debit=500, credit=500)
......@@ -556,7 +555,6 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
node_title='7',
debit=0,
credit=500)
stat_line = line_list[-1]
self.assertTrue(line_list[-1].isStatLine())
self.checkLineProperties(line_list[-1], debit=500, credit=500)
......@@ -1100,7 +1098,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
dict(source_value=account_module.stocks,
source_credit=100)))
first = self._makeOne(
self._makeOne(
portal_type='Sale Invoice Transaction',
title='Grouped during period',
simulation_state='delivered',
......@@ -1116,7 +1114,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
dict(source_value=account_module.goods_sales,
source_credit=100.00)))
second = self._makeOne(
self._makeOne(
portal_type='Sale Invoice Transaction',
title='Grouped after period',
simulation_state='delivered',
......@@ -1251,7 +1249,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
bank.validate()
# before
# this one will not have grouping reference
t1 = self._makeOne(
self._makeOne(
portal_type='Accounting Transaction',
title='Transaction 1',
reference='ref1',
......@@ -1278,7 +1276,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
source_credit=200.0)))
# payment related to t2 invoice
t3 = self._makeOne(
self._makeOne(
portal_type='Payment Transaction',
title='Transaction 3',
reference='ref3',
......@@ -1311,7 +1309,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
source_debit=400.0),
dict(source_value=account_module.payable,
source_credit=400.0)))
t5 = self._makeOne(
self._makeOne(
portal_type='Payment Transaction',
title='Transaction 5',
reference='ref5',
......@@ -1407,7 +1405,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
bank.validate()
# before
# this one will not have grouping reference
t1 = self._makeOne(
self._makeOne(
portal_type='Accounting Transaction',
title='Transaction 1',
reference='ref1',
......@@ -1436,7 +1434,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
source_credit=200.0)))
# payment related to t2 invoice
t3 = self._makeOne(
self._makeOne(
portal_type='Payment Transaction',
title='Transaction 3',
reference='ref3',
......@@ -1724,7 +1722,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
self.createAccountStatementDataSetOnTwoPeriods()
t1b = self._makeOne(
self._makeOne(
portal_type='Sale Invoice Transaction',
title='Transaction 1b',
reference='ref1b',
......@@ -1789,7 +1787,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
self.createAccountStatementDataSetOnTwoPeriods()
t1b = self._makeOne(
self._makeOne(
portal_type='Sale Invoice Transaction',
title='Transaction 1b',
reference='ref1b',
......@@ -1974,7 +1972,6 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
data_line_list = [l for l in line_list if l.isDataLine()]
self.assertEqual(1, len(data_line_list))
line = data_line_list[0]
self.checkLineProperties(data_line_list[0],
Movement_getSpecificReference='4',
date=DateTime(2006, 2, 2, 0, 3),
......@@ -2025,7 +2022,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
def testAccountStatementCancellationAmount(self):
# Account statement with cancellation amount set on lines
account_module = self.account_module
t1 = self._makeOne(
self._makeOne(
portal_type='Accounting Transaction',
title='Transaction 1',
source_reference='1',
......@@ -2038,7 +2035,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
source_debit=-100.0,
cancellation_amount=True)))
t2 = self._makeOne(
self._makeOne(
portal_type='Accounting Transaction',
title='Transaction 2',
source_reference='2',
......@@ -2092,7 +2089,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
def testAccountStatementSameSectionSameNode(self):
# Account statement with a movement on the same section and the same node
account_module = self.account_module
t1 = self._makeOne(
self._makeOne(
portal_type='Accounting Transaction',
title='Transaction 1',
source_reference='Source Reference',
......@@ -2155,7 +2152,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
# When there are multiple sections for the same group, an extra column
# is added for the section
account_module = self.portal.account_module
t1 = self._makeOne(
self._makeOne(
portal_type='Accounting Transaction',
title='Transaction 1',
reference='ref1',
......@@ -2168,7 +2165,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
dict(source_value=account_module.payable,
source_credit=100.0)))
t2 = self._makeOne(
self._makeOne(
portal_type='Accounting Transaction',
title='Transaction 2',
reference='ref2',
......@@ -2510,7 +2507,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
def testTrialBalanceMultipleSection(self):
account_module = self.portal.account_module
t1 = self._makeOne(
self._makeOne(
portal_type='Accounting Transaction',
title='Transaction 1',
source_reference='1',
......@@ -2522,7 +2519,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
dict(source_value=account_module.payable,
source_credit=100.0)))
t2 = self._makeOne(
self._makeOne(
portal_type='Accounting Transaction',
title='Transaction 2',
source_reference='2',
......@@ -3602,10 +3599,8 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
request_form['function'] = ''
request_form['group_analytic'] = ["function"]
request_form['show_detailed_balance_columns'] = 1
report_section_list = self.portal.accounting_module.AccountModule_getTrialBalanceReportSectionList()
line_list = self.getListBoxLineList(report_section_list[0])
# XXX where is the end of this test ?
#report_section_list = self.portal.accounting_module.AccountModule_getTrialBalanceReportSectionList()
def testTrialBalanceProject(self):
# trial balance restricted to a project
......@@ -4583,7 +4578,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
def testOtherPartiesReport(self):
# Other parties report
account_module = self.portal.account_module
t1 = self._makeOne(
self._makeOne(
portal_type='Accounting Transaction',
title='Transaction 1',
source_reference='1',
......@@ -4595,7 +4590,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
dict(source_value=account_module.goods_sales,
source_credit=100.0)))
t2 = self._makeOne(
self._makeOne(
portal_type='Accounting Transaction',
title='Transaction 2',
source_reference='2',
......@@ -4661,7 +4656,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
# entities belong to the same ledger
self.createLedgerCategory()
account_module = self.portal.account_module
t1 = self._makeOne(
self._makeOne(
portal_type='Accounting Transaction',
title='Transaction 1',
source_reference='1',
......@@ -4674,7 +4669,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
dict(source_value=account_module.goods_sales,
source_credit=100.0)))
t2 = self._makeOne(
self._makeOne(
portal_type='Accounting Transaction',
title='Transaction 2',
source_reference='2',
......@@ -4687,7 +4682,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
dict(source_value=account_module.goods_sales,
source_credit=200.0)))
t3 = self._makeOne(
self._makeOne(
portal_type='Accounting Transaction',
title='Transaction 3',
source_reference='3',
......@@ -5074,7 +5069,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
portal_type='Organisation',
title='ZZZ Supplier'
)
purchase2 = self._makeOne(
self._makeOne(
portal_type='Purchase Invoice Transaction',
title='Purchase invoice 0',
destination_reference='0',
......@@ -5261,7 +5256,6 @@ class TestAccountingReportsWithAnalytic(AccountingTestCase, ERP5ReportTestCase):
debit=0,
credit=700)
stat_line = line_list[-1]
self.assertTrue(line_list[-1].isStatLine())
self.checkLineProperties(line_list[-1], debit=1500, credit=1500)
......@@ -5299,7 +5293,6 @@ class TestAccountingReportsWithAnalytic(AccountingTestCase, ERP5ReportTestCase):
node_title='7',
debit=0,
credit=1500)
stat_line = line_list[-1]
self.assertTrue(line_list[-1].isStatLine())
self.checkLineProperties(line_list[-1], debit=1500, credit=1500)
......@@ -5345,7 +5338,6 @@ DT, b, P2 - Project 2''',
credit_price=700,
running_total_price=-1500)
stat_line = line_list[-1]
self.assertTrue(line_list[-1].isStatLine())
self.checkLineProperties(line_list[-1], debit_price=0, credit_price=1500)
......@@ -5374,7 +5366,6 @@ DT, b, P2 - Project 2''',
credit_price=1500,
running_total_price=-1500)
stat_line = line_list[-1]
self.assertTrue(line_list[-1].isStatLine())
self.checkLineProperties(line_list[-1], debit_price=0, credit_price=1500)
......@@ -5493,7 +5484,6 @@ DT, b, P2 - Project 2''',
getTranslatedSimulationStateTitle='Closed')
# There is no stat line in export
stat_line = line_list[-1]
self.assertFalse(line_list[-1].isStatLine())
def testGeneralLedgerAnalyticsShown(self):
......@@ -5543,7 +5533,6 @@ DT, b, P2 - Project 2''',
credit_price=700,
running_total_price=-1500)
stat_line = line_list[-1]
self.assertTrue(line_list[-1].isStatLine())
self.checkLineProperties(line_list[-1], debit_price=0, credit_price=1500)
......@@ -5583,7 +5572,6 @@ DT, b, P2 - Project 2''',
debit_price=1500,
credit_price=0,
running_total_price=1500)
stat_line = line_list[-1]
self.assertTrue(line_list[-1].isStatLine())
self.checkLineProperties(line_list[-1], debit_price=1500, credit_price=0)
# good sales account
......@@ -5594,7 +5582,6 @@ DT, b, P2 - Project 2''',
debit_price=0,
credit_price=1500,
running_total_price=-1500)
stat_line = line_list[-1]
self.assertTrue(line_list[-1].isStatLine())
self.checkLineProperties(line_list[-1], debit_price=0, credit_price=1500)
# summary
......@@ -5763,7 +5750,6 @@ DT, b, P2 - Project 2''',
grouping_date=None,
getTranslatedSimulationStateTitle='Closed')
stat_line = line_list[-1]
# There is no stat in export mode
self.assertFalse(line_list[-1].isStatLine())
# There is not stat section either
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testAccountingReports</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testAccountingReports</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testAccountingReports</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
##############################################################################
# Copyright (c) 2016 Nexedi SARL and Contributors. All Rights Reserved.
#
# 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.
#
##############################################################################
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
class PortalTypeOfPortalTypeTestCase(ERP5TypeTestCase):
"""
Base class to test Portal Types of other Portal Types
"""
def getBusinessTemplateList(self):
return ('erp5_core', 'erp5_base', 'erp5_simulation', 'erp5_accounting')
def setUpPropertyOnPortalType(self, portal_type_id, property_name, property_value):
portal_type = self.portal.portal_types.get(portal_type_id, None)
portal_type.setProperty(property_name, property_value)
def cleanPropertyOnPortalType(self, portal_type_id, property_name):
portal_type = self.portal.portal_types.get(portal_type_id, None)
portal_type.setProperty(property_name, None)
class TestDeliveryTypeInformation(PortalTypeOfPortalTypeTestCase):
"""
Delivery Type is a Base Type on which a list of allowed ledgers is defined.
This suite checks that its custom features are correctly implemented.
"""
def afterSetUp(self):
self.createLedgerCategory()
@UnrestrictedMethod
def createLedgerCategory(self):
portal_categories = self.portal.portal_categories
ledger = self.portal.portal_categories.get('ledger', None)
if ledger is None:
ledger = portal_categories.newContent(portal_type='Base Category',
id='ledger')
accounting_ledger = ledger.get('accounting', None)
if accounting_ledger is None:
accounting_ledger = ledger.newContent(portal_type='Category',
id='accounting')
if accounting_ledger.get('general', None) is None:
accounting_ledger.newContent(portal_type='Category', id='general')
if accounting_ledger.get('detailed', None) is None:
accounting_ledger.newContent(portal_type='Category', id='detailed')
def testDefaultLedgerIsSetOnObjectIfSetOnPortalType(self):
"""
Sets up a list of ledger on the Accounting Transaction portal type,
which is a DeliveryTypeInformation, and checks that new Accounting Transactions
have a default ledger set at their creation
"""
portal_type = "Accounting Transaction"
self.setUpPropertyOnPortalType(
portal_type,
"ledger_list",
['accounting/general', 'accounting/detailed'])
self.assertEqual(self.portal.portal_types.get(portal_type).getDefaultLedger(),
'accounting/general')
module = self.portal.getDefaultModule(portal_type)
accounting_transaction = module.newContent(portal_type=portal_type)
self.assertEqual(accounting_transaction.hasLedger(), True)
self.assertEqual(accounting_transaction.getLedgerList(),
['accounting/general'])
def testDefaultLedgerIsNotSetOnObjectIfNotSetOnPortalType(self):
"""
If no ledger is defined on the portal type, then it means the
"allowed ledger list" feature is not in use in this instance
"""
portal_type = "Accounting Transaction"
portal_type_object = self.portal.portal_types.get(portal_type)
self.cleanPropertyOnPortalType(portal_type, 'ledger')
# No ledger should be set on the portal type
self.assertEqual(portal_type_object.getLedgerList(), [])
module = self.portal.getDefaultModule(portal_type)
accounting_transaction = module.newContent(portal_type=portal_type)
self.assertEqual(accounting_transaction.getLedgerList(), [])
def testDefaultLedgerIsOverwrittenByNewContentParameter(self):
"""
If a Delivery is created with a given ledger, then it should overwrite
the default ledger
"""
portal_type = "Accounting Transaction"
self.setUpPropertyOnPortalType(
portal_type,
"ledger_list",
['accounting/general', 'accounting/detailed'])
self.assertEqual(self.portal.portal_types.get(portal_type).getDefaultLedger(),
'accounting/general')
module = self.portal.getDefaultModule(portal_type)
accounting_transaction = module.newContent(portal_type=portal_type,
ledger='accounting/detailed')
self.assertEqual(accounting_transaction.hasLedger(), True)
self.assertEqual(accounting_transaction.getLedgerList(),
['accounting/detailed'])
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testTypeDefinition</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5Type.tests.testTypeDefinition</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testTypeDefinition</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
test.erp5.testAccounting
test.erp5.testAccountingReports
test.erp5.testTypeDefinition
\ No newline at end of file
erp5_full_text_mroonga_catalog
erp5_core_proxy_field_legacy
erp5_base
erp5_pdm
erp5_simulation
erp5_trade
erp5_project
erp5_ods_style
erp5_configurator_standard_trade_template
erp5_invoicing
erp5_configurator_standard_accounting_template
erp5_configurator_standard_invoicing_template
erp5_simulation_test
erp5_accounting_ui_test
erp5_simplified_invoicing
\ No newline at end of file
......@@ -40,7 +40,7 @@ from DateTime import DateTime
from lxml import etree
from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5.tests.testAccounting import AccountingTestCase
from erp5.component.test.testAccounting import AccountingTestCase
class TestAccounting_l10n_fr(AccountingTestCase):
"""Test Accounting L10N FR
......@@ -92,7 +92,7 @@ class TestAccounting_l10n_fr(AccountingTestCase):
def test_FEC(self):
account_module = self.portal.account_module
first = self._makeOne(
self._makeOne(
portal_type='Purchase Invoice Transaction',
title='Première Écriture',
simulation_state='delivered',
......@@ -106,7 +106,7 @@ class TestAccounting_l10n_fr(AccountingTestCase):
dict(destination_value=account_module.goods_purchase,
destination_credit=110.00)))
second = self._makeOne(
self._makeOne(
portal_type='Sale Invoice Transaction',
title='Seconde Écriture',
simulation_state='delivered',
......@@ -130,7 +130,7 @@ class TestAccounting_l10n_fr(AccountingTestCase):
fec_xml = ''
last_message = self.portal.MailHost._last_message
self.assertNotEquals((), last_message)
mfrom, mto, message_text = last_message
_, mto, message_text = last_message
self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0])
mail_message = email.message_from_string(message_text)
for part in mail_message.walk():
......@@ -146,8 +146,9 @@ class TestAccounting_l10n_fr(AccountingTestCase):
self.fail("Attachment not found")
# validate against official schema
import Products.ERP5.tests
schema = etree.XMLSchema(etree.XML(open(os.path.join(
os.path.dirname(__file__), 'test_data',
os.path.dirname(Products.ERP5.tests.__file__), 'test_data',
'formatA47A-I-VII-1.xsd')).read()))
# this raise if invalid
......@@ -164,7 +165,7 @@ class TestAccounting_l10n_fr(AccountingTestCase):
def _FECWithLedger(self, ledger_list=None, group_by=None):
self.setUpLedger()
account_module = self.portal.account_module
first = self._makeOne(
self._makeOne(
portal_type='Purchase Invoice Transaction',
title='Première Écriture',
simulation_state='delivered',
......@@ -179,7 +180,7 @@ class TestAccounting_l10n_fr(AccountingTestCase):
dict(destination_value=account_module.goods_purchase,
destination_credit=110.00)))
second = self._makeOne(
self._makeOne(
portal_type='Sale Invoice Transaction',
title='Seconde Écriture',
simulation_state='delivered',
......@@ -194,7 +195,7 @@ class TestAccounting_l10n_fr(AccountingTestCase):
dict(source_value=account_module.goods_sales,
source_credit=200.00)))
third = self._makeOne(
self._makeOne(
portal_type='Sale Invoice Transaction',
title='Troisième Écriture',
simulation_state='delivered',
......@@ -222,7 +223,7 @@ class TestAccounting_l10n_fr(AccountingTestCase):
fec_xml = ''
last_message = self.portal.MailHost._last_message
self.assertNotEquals((), last_message)
mfrom, mto, message_text = last_message
_, mto, message_text = last_message
self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0])
mail_message = email.message_from_string(message_text)
for part in mail_message.walk():
......@@ -238,8 +239,9 @@ class TestAccounting_l10n_fr(AccountingTestCase):
self.fail("Attachment not found")
# validate against official schema
import Products.ERP5.tests
schema = etree.XMLSchema(etree.XML(open(os.path.join(
os.path.dirname(__file__), 'test_data',
os.path.dirname(Products.ERP5.tests.__file__), 'test_data',
'formatA47A-I-VII-1.xsd')).read()))
# this raise if invalid
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testAccounting_l10n_fr</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testAccounting_l10n_fr</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testAccounting_l10n_fr</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
test.erp5.testAccounting_l10n_fr
\ No newline at end of file
erp5_full_text_mroonga_catalog
erp5_core_proxy_field_legacy
erp5_base
erp5_pdm
erp5_simulation
erp5_trade
erp5_project
erp5_ods_style
erp5_configurator_standard_trade_template
erp5_invoicing
erp5_configurator_standard_accounting_template
erp5_configurator_standard_invoicing_template
erp5_simulation_test
erp5_accounting_ui_test
erp5_deferred_style
\ No newline at end of file
......@@ -31,7 +31,7 @@ import unittest
from DateTime import DateTime
from zLOG import LOG
from Testing import ZopeTestCase
from Products.ERP5.tests.testAccounting import AccountingTestCase
from erp5.component.test.testAccounting import AccountingTestCase
from AccessControl.SecurityManagement import newSecurityManager
QUIET = False
run_all_test = True
......@@ -80,11 +80,11 @@ class TestConversionInSimulation(AccountingTestCase):
def createCategoriesInCategory(self, category, category_id_list):
for category_id in category_id_list:
child = category
for id in category_id.split('/'):
for id_ in category_id.split('/'):
try:
child = child[id]
child = child[id_]
except KeyError:
child = child.newContent(id)
child = child.newContent(id_)
def createCategories(self):
"""Create the categories for our test. """
......@@ -101,16 +101,16 @@ class TestConversionInSimulation(AccountingTestCase):
['accounting', 'delivery', 'invoicing', 'discount', 'tax', 'payment'])
_(category_tool.product_line, ['apparel'])
def _solveDivergence(self, obj, property, decision, group='line'):
def _solveDivergence(self, obj, prop, decision, group='line'):
"""
Check if simulation movement are disconnected
"""
kw = {'%s_group_listbox' % group:{}}
for divergence in obj.getDivergenceList():
if divergence.getProperty('tested_property') != property:
if divergence.getProperty('tested_property') != prop:
continue
sm_url = divergence.getProperty('simulation_movement').getRelativeUrl()
kw['line_group_listbox']['%s&%s' % (sm_url, property)] = {
kw['line_group_listbox']['%s&%s' % (sm_url, prop)] = {
'choice':decision}
self.portal.portal_workflow.doActionFor(
obj,
......@@ -144,7 +144,7 @@ class TestConversionInSimulation(AccountingTestCase):
self.tic()
super(TestConversionInSimulation, self).beforeTearDown()
def login(self,name=username, quiet=0, run=run_all_test):
def login(self, *args, **kw):
uf = self.getPortal().acl_users
uf._doAddUser(self.username, '', ['Assignee', 'Assignor',
'Author'], [])
......@@ -247,7 +247,7 @@ class TestConversionInSimulation(AccountingTestCase):
"""
if not run: return
if not quiet:
printAndLog('test_01_simulation_movement_destination_asset_price')
printAndLog('test_01_simulation_movement_destination_asset_price')
resource = self.portal.product_module.newContent(
portal_type='Product',
title='Resource',
......@@ -291,10 +291,10 @@ class TestConversionInSimulation(AccountingTestCase):
price_currency_value=currency,
specialise_value=self.business_process,
title='Order')
order_line = order.newContent(portal_type='Sale Order Line',
resource_value=resource,
quantity=1,
price=2)
order.newContent(portal_type='Sale Order Line',
resource_value=resource,
quantity=1,
price=2)
order.confirm()
self.tic()
......@@ -339,7 +339,7 @@ class TestConversionInSimulation(AccountingTestCase):
"""
if not run: return
if not quiet:
printAndLog('test_01_simulation_movement_source_asset_price')
printAndLog('test_01_simulation_movement_source_asset_price')
resource = self.portal.product_module.newContent(
portal_type='Product',
title='Resource',
......@@ -383,10 +383,10 @@ class TestConversionInSimulation(AccountingTestCase):
price_currency_value=currency,
specialise_value=self.business_process,
title='Order')
order_line = order.newContent(portal_type='Sale Order Line',
resource_value=resource,
quantity=1,
price=2)
order.newContent(portal_type='Sale Order Line',
resource_value=resource,
quantity=1,
price=2)
order.confirm()
self.tic()
......@@ -421,7 +421,7 @@ class TestConversionInSimulation(AccountingTestCase):
"""
if not run: return
if not quiet:
printAndLog(
printAndLog(
'test_01_destination_total_asset_price_on_accounting_lines')
resource = self.portal.product_module.newContent(
......@@ -467,10 +467,10 @@ class TestConversionInSimulation(AccountingTestCase):
price_currency_value=currency,
specialise_value=self.business_process,
title='Order')
order_line = order.newContent(portal_type='Sale Order Line',
resource_value=resource,
quantity=1,
price=2)
order.newContent(portal_type='Sale Order Line',
resource_value=resource,
quantity=1,
price=2)
order.confirm()
self.tic()
self.buildPackingLists()
......@@ -495,7 +495,7 @@ class TestConversionInSimulation(AccountingTestCase):
portal_type=self.portal.getPortalAccountingMovementTypeList())
self.assertNotEquals(line_list, None)
for line in line_list:
self.assertEqual(line.getDestinationTotalAssetPrice(),
self.assertEqual(line.getDestinationTotalAssetPrice(),
round(655.957*delivery_movement.getTotalPrice()))
def test_01_diverged_sale_packing_list_destination_total_asset_price(
......@@ -509,7 +509,7 @@ class TestConversionInSimulation(AccountingTestCase):
"""
if not run: return
if not quiet:
printAndLog(
printAndLog(
'test_01_diverged_sale_packing_list_destination_total_asset_price')
resource = self.portal.product_module.newContent(
......@@ -555,10 +555,10 @@ class TestConversionInSimulation(AccountingTestCase):
price_currency_value=currency,
specialise_value=self.business_process,
title='Order')
order_line = order.newContent(portal_type='Sale Order Line',
resource_value=resource,
quantity=5,
price=2)
order.newContent(portal_type='Sale Order Line',
resource_value=resource,
quantity=5,
price=2)
order.confirm()
self.tic()
self.buildPackingLists()
......@@ -608,7 +608,7 @@ class TestConversionInSimulation(AccountingTestCase):
"""
if not run: return
if not quiet:
printAndLog(
printAndLog(
'test_01_diverged_purchase_packing_list_source_total_asset_price')
resource = self.portal.product_module.newContent(
......@@ -654,10 +654,10 @@ class TestConversionInSimulation(AccountingTestCase):
price_currency_value=currency,
specialise_value=self.business_process,
title='Order')
order_line = order.newContent(portal_type='Purchase Order Line',
resource_value=resource,
quantity=5,
price=2)
order.newContent(portal_type='Purchase Order Line',
resource_value=resource,
quantity=5,
price=2)
order.confirm()
self.tic()
self.buildPackingLists()
......@@ -707,7 +707,7 @@ class TestConversionInSimulation(AccountingTestCase):
"""
if not run: return
if not quiet:
printAndLog(
printAndLog(
'test_01_delivery_mode_on_sale_packing_list_and_invoice')
resource = self.portal.product_module.newContent(
......@@ -755,10 +755,10 @@ class TestConversionInSimulation(AccountingTestCase):
incoterm=self.cpt_incoterm,
specialise_value=self.business_process,
title='Order')
order_line = order.newContent(portal_type='Sale Order Line',
resource_value=resource,
quantity=5,
price=2)
order.newContent(portal_type='Sale Order Line',
resource_value=resource,
quantity=5,
price=2)
order.confirm()
self.tic()
self.buildPackingLists()
......@@ -788,7 +788,7 @@ class TestConversionInSimulation(AccountingTestCase):
"""
if not run: return
if not quiet:
printAndLog(
printAndLog(
'test_01_quantity_unit_on_sale_packing_list')
resource = self.portal.product_module.newContent(
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testConversionInSimulation</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testConversionInSimulation</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testConversionInSimulation</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -28,7 +28,7 @@
import unittest
from DateTime import DateTime
from Products.ERP5.tests.testAccounting import AccountingTestCase
from erp5.component.test.testAccounting import AccountingTestCase
from AccessControl.SecurityManagement import newSecurityManager
class CurrencyExchangeTestCase(AccountingTestCase):
......@@ -56,7 +56,7 @@ class CurrencyExchangeTestCase(AccountingTestCase):
self.tic()
def login(self, name=username):
def login(self, *args, **kw):
uf = self.getPortal().acl_users
uf._doAddUser(self.username, '', ['Assignee', 'Assignor',
'Author','Manager'], [])
......@@ -146,7 +146,6 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase):
x_curr_ex_line.validate()
self.assertEqual(x_curr_ex_line.getValidationState(),
'validated')
accounting_module = self.portal.accounting_module
invoice = self._makeOne(
portal_type='Purchase Invoice Transaction',
stop_date=DateTime('2008/09/08'),
......@@ -195,21 +194,16 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase):
self.assertEqual(x_curr_ex_line.getValidationState(),
'validated')
yen = self.portal.currency_module.yen
yen_line1 = yen.newContent(
portal_type='Currency Exchange Line')
yen_line2 = yen.newContent(
portal_type='Currency Exchange Line')
yen.newContent(portal_type='Currency Exchange Line')
yen.newContent(portal_type='Currency Exchange Line')
usd = self.portal.currency_module.usd
usd_line1 = usd.newContent(
portal_type='Currency Exchange Line')
usd_line2 = usd.newContent(
portal_type='Currency Exchange Line')
usd.newContent(portal_type='Currency Exchange Line')
usd.newContent(portal_type='Currency Exchange Line')
euro_line = euro.newContent(
portal_type='Currency Exchange Line')
euro_line.validate()
accounting_module = self.portal.accounting_module
invoice = self._makeOne(
portal_type='Purchase Invoice Transaction',
stop_date=DateTime('2008/09/08'),
......@@ -256,7 +250,6 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase):
x_curr_ex_line.validate()
self.assertEqual(x_curr_ex_line.getValidationState(),
'validated')
accounting_module = self.portal.accounting_module
invoice = self._makeOne(
portal_type='Sale Invoice Transaction',
start_date=DateTime('2008/09/08'),
......@@ -294,8 +287,6 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase):
self.tic()
self.organisation1.edit(
price_currency=new_currency.getRelativeUrl())
euro = self.portal.currency_module.euro
accounting_module = self.portal.accounting_module
invoice = self._makeOne(
portal_type='Purchase Invoice Transaction',
stop_date=DateTime('2008/09/08'),
......@@ -345,7 +336,6 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase):
x_curr_ex_line.validate()
self.assertEqual(x_curr_ex_line.getValidationState(),
'validated')
accounting_module = self.portal.accounting_module
transaction1 = self._makeOne(
portal_type='Purchase Invoice Transaction',
stop_date=DateTime('2008/09/08'),
......@@ -413,7 +403,6 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase):
self.assertEqual(x_curr_ex_line.getValidationState(),
'validated')
accounting_module = self.portal.accounting_module
invoice = self._makeOne(
portal_type='Purchase Invoice Transaction',
stop_date=DateTime('2008/09/08'),
......@@ -429,8 +418,7 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase):
line_list = invoice.contentValues(
portal_type=self.portal.getPortalAccountingMovementTypeList())
for line in line_list:
self.assertEqual(line.getDestinationTotalAssetPrice(),
None)
self.assertEqual(line.getDestinationTotalAssetPrice(), None)
def test_CreateCELWithNoBasePrice(self):
......@@ -476,7 +464,6 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase):
self.assertEqual(euro_line2.getValidationState(),
'validated')
accounting_module = self.portal.accounting_module
invoice = self._makeOne(
portal_type='Purchase Invoice Transaction',
stop_date=DateTime('2008/09/08'),
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testERP5CurrencyExchangeLine</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testERP5CurrencyExchangeLine</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testERP5CurrencyExchangeLine</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
test.erp5.testConversionInSimulation
test.erp5.testERP5CurrencyExchangeLine
\ No newline at end of file
erp5_full_text_mroonga_catalog
erp5_base
erp5_core_proxy_field_legacy
erp5_pdm
erp5_simulation
erp5_trade
erp5_simulation_test
erp5_simplified_invoicing
erp5_configurator_standard_accounting_template
\ No newline at end of file
erp5_configurator_standard_solver
erp5_configurator_standard_trade_template
erp5_configurator_standard_invoicing_template
\ No newline at end of file
......@@ -35,7 +35,7 @@ from DateTime import DateTime
from Products.DCWorkflow.DCWorkflow import ValidationFailed
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5ReportTestCase
from Products.ERP5.tests.testAccounting import AccountingTestCase
from erp5.component.test.testAccounting import AccountingTestCase
class TestBankReconciliation(AccountingTestCase, ERP5ReportTestCase):
"""Test Bank Reconciliation
......
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