Commit 28c4777c authored by Tomáš Peterka's avatar Tomáš Peterka

[accounting_ui_test] Add necessary scripts for Report UI Testing

parent cc0d8c88
"""Create document of `portal_type` inside `parent` or Accounting Module.
`embedded` is a list of documents to create inside the top-level document
`simulation_state` is known to be a workflow transition variable thus we correctly
use workflows to change the state
"""
portal = context.getPortalObject()
parent = parent or portal.accounting_module
document = parent.newContent(portal_type=portal_type, **kwargs)
for embed in embedded:
script(parent=document, **embed)
if simulation_state == 'planned':
document.plan()
elif simulation_state == 'validated':
document.validate()
elif simulation_state == 'confirmed':
document.confirm()
elif simulation_state in ('stopped', 'delivered'):
document.stop()
if simulation_state == 'delivered':
document.deliver()
return document
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>portal_type, simulation_state=None, parent=None, embedded=(), **kwargs</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingZuite_createDocument</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
"""Create data set for aged balance:
$last_month: Purchase invoice 1 (500)
$last_month: Sale invoice 2 (300)
$next_month: Payment 1 (500)
$this_month + one_day: Payment 2 (300)
"""
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery
from DateTime import DateTime
portal = context.getPortalObject()
account_module = portal.account_module
organisation_module = portal.organisation_module
now = DateTime()
this_month = DateTime(now.year(), now.month(), 1)
last_month = this_month - 1
next_month = this_month + 32
later_this_month = this_month + 8
def get_object_by_title(portal_type, title):
"""Use portal catalog to search&fetch the object."""
result = portal.portal_catalog(
portal_type=portal_type,
title=SimpleQuery(title=title, comparison_operator='='))
if len(result) == 1:
return result.getObject()
return None
bank1 = get_object_by_title(portal_type='Bank Account', title='Bank1')
if bank1 is None:
bank1 = portal.AccountingZuite_createDocument(
portal_type='Bank Account', title='Bank1', simulation_state='validated',
parent=organisation_module.my_organisation)
purchase1 = portal.AccountingZuite_createDocument(
portal_type='Purchase Invoice Transaction',
title='Purchase invoice 1',
destination_reference='1',
source_reference='no',
reference='ref1',
simulation_state='delivered',
ledger='',
source_section_value=organisation_module.supplier,
start_date=last_month,
embedded=(dict(portal_type='Purchase Invoice Transaction Line',
destination_value=account_module.goods_purchase,
destination_debit=500.0),
dict(portal_type='Purchase Invoice Transaction Line',
destination_value=account_module.payable,
destination_credit=500.0)),
)
sale2 = portal.AccountingZuite_createDocument(
portal_type='Sale Invoice Transaction',
title='Sale invoice 2',
source_reference='2',
destination_reference='no',
reference='ref2',
simulation_state='delivered',
ledger='',
destination_section_value=organisation_module.client_1,
start_date=last_month,
embedded=(dict(portal_type='Sale Invoice Transaction Line',
source_value=account_module.goods_sales,
source_credit=300.0),
dict(portal_type='Sale Invoice Transaction Line',
source_value=account_module.receivable,
source_debit=300.0)),
)
portal.Zuite_waitForActivities()
payment3 = portal.AccountingZuite_createDocument(
portal_type='Payment Transaction',
title='Payment 1',
source_reference='3',
destination_reference='no',
simulation_state='delivered',
ledger='',
causality_value=purchase1,
payment_mode='payment_mode',
destination_section_value=organisation_module.supplier,
start_date=next_month,
embedded=(dict(portal_type='Accounting Transaction Line',
source_value=account_module.payable,
source_debit=500.0),
dict(portal_type='Accounting Transaction Line',
source_value=account_module.bank,
source_credit=500.0)),
)
payment4 = portal.AccountingZuite_createDocument(
portal_type='Payment Transaction',
title='Payment 2',
source_reference='4',
destination_reference='4',
simulation_state='delivered',
causality_value=sale2,
payment_mode='payment_mode',
ledger='',
destination_section_value=organisation_module.client_1,
start_date=later_this_month,
embedded=(dict(portal_type='Accounting Transaction Line',
source_value=account_module.bank,
source_debit=300.0),
dict(portal_type='Accounting Transaction Line',
source_value=account_module.receivable,
source_credit=300.0)),
)
# we should have all receivable and payable lines grouped.
for transaction in [purchase1, sale2, payment3, payment4]:
for line in transaction.getMovementList():
if (line.getSourceValue() in (account_module.receivable,
account_module.payable) or
line.getDestinationValue() in (account_module.receivable,
account_module.payable)):
assert line.getGroupingReference()
assert line.getGroupingDate()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Python Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingZuite_createReportAgedBalanceDataset</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Python Script</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
"""Create Dataset for basic Trial Balance Report such as defined at
https://lab.nexedi.com/nexedi/erp5/blob/master/product/ERP5/tests/testAccountingReports.py#L563
The test operates on 'today' transactions.
"""
from DateTime import DateTime
portal = context.getPortalObject()
person_module = portal.person_module
accounting_module = portal.accounting_module
account_module = portal.account_module
organisation_module = portal.organisation_module
one_hour = 1.0 / 24.0
one_day = 1.0
now = DateTime()
today = DateTime(now.year(), now.month(), now.day()) + 8 * one_hour
yesterday = today - one_day
tomorrow = today + one_day
bank1 = context.AccountingZuite_createDocument(
parent=organisation_module.my_organisation,
portal_type='Bank Account',
title='Bank1',
simulation_state='validated'
)
bank2 = bank1
if two_banks:
bank2 = context.AccountingZuite_createDocument(
parent=organisation_module.my_organisation,
portal_type='Bank Account',
title='Bank2',
simulation_state='validated'
)
context.AccountingZuite_createDocument(
portal_type='Accounting Transaction',
title='Transaction 1',
source_reference='1',
reference='ref1',
simulation_state='delivered',
destination_section_value=organisation_module.client_1,
start_date=yesterday,
embedded=(dict(portal_type='Accounting Transaction Line',
source_value=account_module.receivable,
source_debit=100.0),
dict(portal_type='Accounting Transaction Line',
source_value=account_module.payable,
source_credit=100.0)),
)
context.AccountingZuite_createDocument(
portal_type='Accounting Transaction',
title='Transaction 2',
source_reference='2',
reference='ref2',
simulation_state='delivered',
destination_section_value=organisation_module.client_1,
start_date=yesterday + one_hour,
embedded=(dict(portal_type='Accounting Transaction Line',
source_value=account_module.payable,
source_debit=200.0),
dict(portal_type='Accounting Transaction Line',
source_value=account_module.receivable,
source_credit=200.0)),
)
# in the period
context.AccountingZuite_createDocument(
portal_type='Payment Transaction',
title='Transaction 3',
source_reference='3',
reference='ref3',
simulation_state='delivered',
source_payment_value=bank1,
destination_section_value=organisation_module.client_1,
start_date=today + one_hour,
embedded=(dict(portal_type='Accounting Transaction Line',
source_value=account_module.receivable,
source_debit=300.0),
dict(portal_type='Accounting Transaction Line',
source_value=account_module.bank,
source_credit=300.0)),
)
context.AccountingZuite_createDocument(
portal_type='Payment Transaction',
title='Transaction 4',
destination_reference='4',
reference='ref4',
simulation_state='delivered',
destination_section_value=organisation_module.my_organisation,
destination_payment_value=bank1,
source_section_value=organisation_module.client_2,
stop_date=today + 2 * one_hour,
start_date=yesterday,
embedded=(dict(portal_type='Accounting Transaction Line',
destination_value=account_module.receivable,
destination_debit=400.0),
dict(portal_type='Accounting Transaction Line',
destination_value=account_module.bank,
destination_credit=400.0)),
)
context.AccountingZuite_createDocument(
portal_type='Accounting Transaction',
title='Transaction 5',
source_reference='5',
reference='ref5',
simulation_state='delivered',
source_payment_value=bank2,
destination_section_value=person_module.john_smith,
start_date=today + 3 * one_hour,
embedded=(dict(portal_type='Accounting Transaction Line',
source_value=account_module.receivable,
source_debit=500.0),
dict(portal_type='Accounting Transaction Line',
source_value=account_module.bank,
source_credit=500.0)),
)
context.AccountingZuite_createDocument(
portal_type='Purchase Invoice Transaction',
title='Transaction 6',
destination_reference='6',
reference='ref6',
simulation_state='delivered',
destination_payment_value=bank2,
source_section_value=organisation_module.client_1,
start_date=yesterday + 2 * one_hour,
stop_date=today + 4 * one_hour,
embedded=(dict(portal_type='Purchase Invoice Transaction Line',
destination_value=account_module.receivable,
destination_debit=600.0),
dict(portal_type='Purchase Invoice Transaction Line',
destination_value=account_module.bank,
destination_credit=600.0)),
)
# another simulation state
context.AccountingZuite_createDocument(
portal_type='Accounting Transaction',
title='Transaction 7',
source_reference='7',
reference='ref7',
simulation_state='stopped',
source_payment_value=bank2,
destination_section_value=organisation_module.client_1,
start_date=today + 5 * one_hour,
embedded=(dict(portal_type='Accounting Transaction Line',
source_value=account_module.receivable,
source_debit=700.0),
dict(portal_type='Accounting Transaction Line',
source_value=account_module.bank,
source_credit=700.0)),
)
# after the period
context.AccountingZuite_createDocument(
portal_type='Accounting Transaction',
title='Transaction 8',
source_reference='8',
reference='ref8',
simulation_state='delivered',
source_payment_value=bank2,
destination_section_value=organisation_module.client_1,
start_date=tomorrow,
embedded=(dict(portal_type='Accounting Transaction Line',
source_value=account_module.receivable,
source_debit=800.0),
dict(portal_type='Accounting Transaction Line',
source_value=account_module.bank,
source_credit=800.0)),
)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>two_banks=False</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingZuite_createReportDataset</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from DateTime import DateTime
portal = context.getPortalObject()
accounting_module = portal.accounting_module
account_module = portal.account_module
one_hour = 1.0 / 24.0
today = DateTime(DateTime().Date()) + 8 * one_hour
yesterday = today - 1
tomorrow = today + 1
context.AccountingZuite_createDocument(
portal_type='Accounting Transaction',
simulation_state='delivered',
start_date=yesterday,
embedded=[
{"portal_type": 'Accounting Transaction Line',
"source_value": account_module.equity,
"source_debit": 100},
{"portal_type": 'Accounting Transaction Line',
"source_value": account_module.stocks,
"source_credit": 100}
]
)
context.AccountingZuite_createDocument(
portal_type='Sale Invoice Transaction',
title='First One',
simulation_state='delivered',
reference='1',
destination_section_value=portal.organisation_module.client_1,
start_date=today,
embedded=[
{"portal_type": 'Sale Invoice Transaction Line',
"source_value": account_module.receivable,
"source_debit": 119.60},
{"portal_type": 'Sale Invoice Transaction Line',
"source_value": account_module.collected_vat,
"source_credit": 19.60},
{"portal_type": 'Sale Invoice Transaction Line',
"source_value": account_module.goods_sales,
"source_credit": 100.00},
]
)
context.AccountingZuite_createDocument(
portal_type='Sale Invoice Transaction',
title='Second One',
simulation_state='delivered',
reference='2',
destination_section_value=portal.organisation_module.client_2,
start_date=today + one_hour,
# different values of hour minutes, because /for now/ sorting is
# done on date, uid. Sorting on [source|destination]_reference
# would be too heavy, and we just want a sort on date, with a
# stable order (hence the cheap sort on uid)
embedded=[
{"portal_type": 'Sale Invoice Transaction Line',
"source_value": account_module.receivable,
"source_debit": 239.20},
{"portal_type": 'Sale Invoice Transaction Line',
"source_value": account_module.collected_vat,
"source_credit": 39.20},
{"portal_type": 'Sale Invoice Transaction Line',
"source_value": account_module.goods_sales,
"source_credit": 200.00},
]
)
context.AccountingZuite_createDocument(
portal_type='Sale Invoice Transaction',
title='Third One',
simulation_state='delivered',
reference='3',
destination_section_value=portal.person_module.john_smith,
start_date=today + 2 * one_hour,
embedded=[
{"portal_type": 'Sale Invoice Transaction Line',
"source_value": account_module.receivable,
"source_debit": 358.80},
{"portal_type": 'Sale Invoice Transaction Line',
"source_value": account_module.collected_vat,
"source_credit": 58.80},
{"portal_type": 'Sale Invoice Transaction Line',
"source_value": account_module.goods_sales,
"title": 'Line Title',
"source_credit": 300.00},
]
)
context.AccountingZuite_createDocument(
portal_type='Accounting Transaction',
simulation_state='delivered',
start_date=today,
embedded=[
{"portal_type": 'Accounting Transaction Line',
"source_value": account_module.equity,
"source_debit": 111},
{"portal_type": 'Accounting Transaction Line',
"source_value": account_module.stocks,
"source_credit": 111},
]
)
context.AccountingZuite_createDocument(
portal_type='Sale Invoice Transaction',
simulation_state='delivered',
destination_section_value=portal.organisation_module.client_2,
start_date=tomorrow,
embedded=[
{"portal_type": "Sale Invoice Transaction Line",
"source_value": account_module.receivable,
"source_debit": 598.00},
{"portal_type": "Sale Invoice Transaction Line",
"source_value": account_module.collected_vat,
"source_credit": 98.00},
{"portal_type": "Sale Invoice Transaction Line",
"source_value": account_module.goods_sales,
"source_credit": 500.00}])
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingZuite_createReportJournalDataset</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
"""Create Dataset for basic Trial Balance Report such as defined at
https://lab.nexedi.com/nexedi/erp5/blob/master/product/ERP5/tests/testAccountingReports.py#L4583
The test operates on 'today' transactions.
:param with_ledger: if true then data are prepared for
testOtherPartiesReportLedger unittest rather than testOtherPartiesReport
"""
from DateTime import DateTime
portal = context.getPortalObject()
accounting_module = portal.accounting_module
account_module = portal.account_module
ledger = portal.portal_categories.ledger
organisation_module = portal.organisation_module
person_module = portal.person_module
one_hour = 1.0 / 24.0
now = DateTime()
today = DateTime(now.year(), now.month(), now.day()) + 8 * one_hour
if with_ledger:
extra_kwargs_general = {'ledger': 'accounting/general'}
extra_kwargs_detailed = {'ledger': 'accounting/detailed'}
accounting_ledger = ledger.get('accounting', None) \
or 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')
# necessary for the "ledger" form field to appear and have correct options
accounting_transaction = portal.portal_types.get('Accounting Transaction')
if not accounting_transaction.getLedgerList():
accounting_transaction.setProperty(
"ledger_list", ['accounting/general', 'accounting/detailed'])
else:
extra_kwargs_general = {}
extra_kwargs_detailed = {}
context.AccountingZuite_createDocument(
portal_type='Accounting Transaction',
title='Transaction 1',
source_reference='1',
simulation_state='delivered',
destination_section_value=organisation_module.client_1,
start_date=today + 1 * one_hour,
embedded=(dict(portal_type='Accounting Transaction Line',
source_value=account_module.receivable,
source_debit=100.0),
dict(portal_type='Accounting Transaction Line',
source_value=account_module.goods_sales,
source_credit=100.0)),
**extra_kwargs_general
)
context.AccountingZuite_createDocument(
portal_type='Accounting Transaction',
title='Transaction 2',
source_reference='2',
simulation_state='delivered',
destination_section_value=organisation_module.client_1,
start_date=today + 2 * one_hour,
embedded=(dict(portal_type='Accounting Transaction Line',
source_value=account_module.payable, source_debit=200.0),
dict(portal_type='Accounting Transaction Line',
source_value=account_module.goods_sales,
source_credit=200.0)),
**extra_kwargs_general
)
if with_ledger:
context.AccountingZuite_createDocument(
portal_type='Accounting Transaction',
title='Transaction 3',
source_reference='3',
simulation_state='delivered',
destination_section_value=organisation_module.client_1,
start_date=today + 3 * one_hour,
embedded=(dict(portal_type='Accounting Transaction Line',
source_value=account_module.payable, source_debit=400.0),
dict(portal_type='Accounting Transaction Line',
source_value=account_module.goods_sales,
source_credit=400.0)),
**extra_kwargs_detailed
)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Python Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>with_ledger=True</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingZuite_createReportOtherPartiesDataset</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Python Script</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
"""Create deterministically transactions to test outputs of Reports."""
from DateTime import DateTime
portal = context.getPortalObject()
module = portal.accounting_module
# This option is necessary for RJS interface to render Reports
# If you'd keep XHTML value "View" the RJS will not crash it will
# only refuse to validate Report Form View
portal.AccountingZuite_setAccountReferencePreference(report_style=report_style)
# First, clean up the module
module.manage_delObjects(list(module.objectIds()))
# Create datasets
if report_name == "journal":
module.AccountingZuite_createReportJournalDataset()
elif report_name in ("trial-balance", "general-ledger"):
module.AccountingZuite_createReportDataset()
elif report_name in ("account-statement", "balance-sheet", "profit-and-loss"):
module.AccountingZuite_createReportDataset(two_banks=True)
elif report_name == "other-parties":
module.AccountingZuite_createReportOtherPartiesDataset(with_ledger=False)
elif report_name == "other-parties-ledger":
module.AccountingZuite_createReportOtherPartiesDataset()
elif report_name == "aged-balance":
module.AccountingZuite_createReportAgedBalanceDataset()
else:
raise RuntimeError('Unknown "{}" report - no create*Dataset defined'.format(
report_name))
# test depends on this
return "Accounting Transactions Created."
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>report_name, report_style</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingZuite_initializeAccountingTransactionReportTest</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingZuite_reportMacros</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<!-- Those macros help to check cell values in tables.
It solves the problem when a column changes its position - then you modify once-here.
Further macros allow to copy&paste code from UnitTest so you are sure you didn't
forget anything.
Usage:
:param row_selector: mandatory XPath selector of processed row - has to be a
full-path selector with possible embedded zope variables
example: tal:define="row_selector string:$${table}/tbody/tr[1]"
will use Zuite's own variable ${table} save by 'store'.
Other parameters copy the names from unittest and are optional. If a parameter
is unspecified then the check is either skipped or replaced with a meaningful
default value (e.g. 0 for numerical variables).
-->
<head>
<title tal:content="template/title">Macros for testing Reports</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body tal:define="offset python:0">
<!-- Following macro checks values in generally used "Transactions Table".
Since all macros are very similar - please refer to the docs at the top. -->
<tal:block metal:define-macro='check_row_in_transactions_table'>
<tr tal:condition="exists:row_selector"><td>store</td>
<td tal:content="string:$row_selector"></td>
<td>current_row</tr>
<tr tal:condition="exists:specific_reference">
<td>assertText</td>
<td>${current_row}/td[1]//a</td>
<td tal:content="string:$specific_reference"></td></tr>
<tr tal:condition="exists:date">
<td>assertText</td>
<td>${current_row}/td[2]//p</td>
<td tal:content="string:$date"></td></tr>
<tr tal:condition="exists:title">
<td>assertText</td>
<td>${current_row}/td[3]//a</td>
<td tal:content="string:$title"></td></tr>
<tr tal:condition="exists:parent_reference">
<td>assertText</td>
<td>${current_row}/td[4]//a</td>
<td tal:content="string:$parent_reference"></td></tr>
<tr tal:condition="exists:node_title">
<td>assertText</td>
<td>${current_row}/td[5]//a</td>
<td tal:content="string:$node_title"></td></tr>
<tr tal:condition="exists:mirror_section_title">
<td>assertText</td>
<td>${current_row}/td[6]//a</td>
<td tal:content="string:$mirror_section_title"></td></tr>
<tr tal:condition="exists:debit">
<td>assertFloat</td>
<td>${current_row}/td[7]//div[@data-gadget-url="${renderjs_url}/gadget_html5_element.html"]/div</td>
<td tal:content="string:$debit"></td></tr>
<tr tal:condition="exists:credit">
<td>assertFloat</td>
<td>${current_row}/td[8]//div[@data-gadget-url="${renderjs_url}/gadget_html5_element.html"]/div</td>
<td tal:content="string:$credit"></td></tr>
</tal:block>
<!-- Following macro checks values in generally used "Accounts Ledger Table"
Since all macros are very similar - please refer to the docs at the top. -->
<tal:block metal:define-macro='check_row_in_accounts_ledger_table'>
<tr tal:condition="exists:row_selector"><td>store</td>
<td tal:content="string:$row_selector"></td>
<td>current_row</tr>
<tr tal:condition="exists:date">
<td>assertText</td><!-- Date -->
<td tal:content="python: '${{current_row}}/td[{:d}]//p'.format(offset + 1)"></td>
<td tal:content="string:$date"></td></tr>
<tr tal:condition="exists:Movement_getExplanationTranslatedPortalType">
<td>assertText</td><!-- Type -->
<td tal:content="python: '${{current_row}}/td[{:d}]//a'.format(offset + 2)"></td>
<td tal:content="string:$Movement_getExplanationTranslatedPortalType"></td></tr>
<tr tal:condition="exists:Movement_getNodeGapId">
<td>assertText</td><!-- GAP -->
<td tal:content="python: '${{current_row}}/td[{:d}]//a'.format(offset + 3)"></td>
<td tal:content="string:$Movement_getNodeGapId"></td></tr>
<tr tal:condition="exists:Movement_getExplanationReference">
<td>assertText</td><!-- Invoice No -->
<td tal:content="python: '${{current_row}}/td[{:d}]//a'.format(offset + 4)"></td>
<td tal:content="string:$Movement_getExplanationReference"></td></tr>
<tr tal:condition="exists:Movement_getExplanationTitle">
<td>assertText</td><!-- Title -->
<td tal:content="python:'${{current_row}}/td[{:d}]//a'.format(offset + 5)"></td>
<td tal:content="string:$Movement_getExplanationTitle"></td></tr>
<tr tal:condition="exists:Movement_getSpecificReference">
<td>assertText</td><!-- Reference -->
<td tal:content="python: '${{current_row}}/td[{:d}]//a'.format(offset + 6)"></td>
<td tal:content="string:$Movement_getSpecificReference">1</td></tr>
<tr tal:condition="exists:getTranslatedSimulationStateTitle">
<td>assertText</td><!-- State -->
<td tal:content="python: '${{current_row}}/td[{:d}]//a'.format(offset + 7)"></td>
<td tal:content="string:$getTranslatedSimulationStateTitle"></td></tr>
<tr tal:condition="exists:debit_price">
<td>assertFloat</td>
<td tal:content="python: '${{current_row}}/td[{:d}]//div[contains(@data-gadget-url, \'gadget_html5_element.html\')]/div'.format(offset + 8)"></td>
<td tal:content="string:$debit_price"></td></tr>
<tr tal:condition="exists:credit_price">
<td>assertFloat</td>
<td tal:content="python: '${{current_row}}/td[{:d}]//div[contains(@data-gadget-url, \'gadget_html5_element.html\')]/div'.format(offset + 9)"></td>
<td tal:content="string:$credit_price"></td></tr>
<tr tal:condition="exists:running_total_price">
<td>assertFloat</td><!-- Balance -->
<td tal:content="python: '${{current_row}}/td[{:d}]//div[contains(@data-gadget-url, \'gadget_html5_element.html\')]/div'.format(offset + 10)"></td>
<td tal:content="string:$running_total_price"></td></tr>
</tal:block>
<!-- Following macro checks values in generally used "Accounts Table"
Since all macros are very similar - please refer to the docs at the top. -->
<tal:block metal:define-macro='check_row_in_accounts_table'>
<tr tal:condition="exists:row_selector"><td>store</td>
<td tal:content="string:$row_selector"></td>
<td>current_row</tr>
<tr tal:condition="exists:date">
<td>assertText</td><!-- Date -->
<td tal:content="python: '${{current_row}}/td[{:d}]//p'.format(offset + 1)"></td>
<td tal:content="string:$date"></td></tr>
<tr tal:condition="exists:Movement_getSpecificReference">
<td>assertText</td><!-- Transaction Reference -->
<td tal:content="python: '${{current_row}}/td[{:d}]//a'.format(offset + 2)"></td>
<td tal:content="string:$Movement_getSpecificReference"></td></tr>
<tr tal:condition="exists:mirror_section_title">
<td>assertText</td><!-- Third Party -->
<td tal:content="python: '${{current_row}}/td[{:d}]//a'.format(offset + 3)"></td>
<td tal:content="string:$mirror_section_title"></td></tr>
<tr tal:condition="exists:Movement_getExplanationTitleAndAnalytics">
<td>assertText</td><!-- Title Reference -->
<td tal:content="python: '${{current_row}}/td[{:d}]//a'.format(offset + 4)"></td>
<td tal:content="string:$Movement_getExplanationTitleAndAnalytics"></td></tr>
<tr tal:condition="exists:debit_price">
<td>assertFloat</td>
<td tal:content="python: '${{current_row}}/td[{:d}]//div[contains(@data-gadget-url, \'gadget_html5_element.html\')]/div'.format(offset + 5)"></td>
<td tal:content="string:$debit_price"></td></tr>
<tr tal:condition="exists:credit_price">
<td>assertFloat</td>
<td tal:content="python: '${{current_row}}/td[{:d}]//div[contains(@data-gadget-url, \'gadget_html5_element.html\')]/div'.format(offset + 6)"></td>
<td tal:content="string:$credit_price"></td></tr>
<tr tal:condition="exists:running_total_price">
<td>assertFloat</td><!-- Balance -->
<td tal:content="python: '${{current_row}}/td[{:d}]//div[contains(@data-gadget-url, \'gadget_html5_element.html\')]/div'.format(offset + 7)"></td>
<td tal:content="string:$running_total_price"></td></tr>
<!-- Grouping Reference -->
<!-- Grouping Date -->
<!-- State -->
</tal:block>
<!-- Following macro checks values in generally used "Balance Table".
Since all macros are very similar - please refer to the docs at the top. -->
<tal:block metal:define-macro='check_row_in_balance_table'>
<tr><td>store</td><td tal:content="string:$row_selector"></td><td>current_row</td></tr>
<tr><td>store</td><td>div[@data-gadget-url="${renderjs_url}/gadget_html5_element.html"]/div</td><td>float_val</td></tr>
<tr tal:condition="exists:node_id">
<td>assertText</td>
<td>${current_row}/td[1]//a</td>
<td tal:content="string:$node_id"></td></tr><!-- not covered by the unittest -->
<tr tal:condition="exists:node_title">
<td>assertText</td>
<td>${current_row}/td[2]//a</td>
<td tal:content="string:$node_title"></td></tr>
<tr tal:condition="exists:initial_debit_balance">
<td>assertFloat</td>
<td>${current_row}/td[3]//${float_val}</td>
<td tal:condition="exists:initial_debit_balance" tal:content="string:$initial_debit_balance"></td>
<td tal:condition="not:exists:initial_debit_balance">0</td></tr>
<tr tal:condition="exists:initial_credit_balance">
<td>assertFloat</td>
<td>${current_row}/td[4]//${float_val}</td>
<td tal:condition="exists:initial_credit_balance" tal:content="string:$initial_credit_balance"></td>
<td tal:condition="not:exists:initial_credit_balance">0</td></tr>
<tr tal:condition="exists:initial_balance">
<td>assertFloat</td>
<td>${current_row}/td[5]//${float_val}</td>
<td tal:condition="exists:initial_balance" tal:content="string:$initial_balance"></td>
<td tal:condition="not:exists:initial_balance">0</td></tr>
<tr tal:condition="exists:debit">
<td>assertFloat</td>
<td>${current_row}/td[6]//${float_val}</td>
<td tal:condition="exists:debit" tal:content="string:$debit"></td>
<td tal:condition="not:exists:debit">0</td></tr>
<tr tal:condition="exists:credit">
<td>assertFloat</td>
<td>${current_row}/td[7]//${float_val}</td>
<td tal:condition="exists:credit" tal:content="string:$credit"></td>
<td tal:condition="not:exists:credit">0</td></tr>
<tr tal:condition="exists:final_debit_balance">
<td>assertFloat</td>
<td>${current_row}/td[8]//${float_val}</td>
<td tal:condition="exists:final_debit_balance" tal:content="string:$final_debit_balance"></td>
<td tal:condition="not:exists:final_debit_balance">0</td></tr>
<tr tal:condition="exists:final_credit_balance">
<td>assertFloat</td>
<td>${current_row}/td[9]//${float_val}</td>
<td tal:condition="exists:final_credit_balance" tal:content="string:$final_credit_balance"></td>
<td tal:condition="not:exists:final_credit_balance">0</td></tr>
<tr tal:condition="exists:final_balance">
<td>assertFloat</td>
<td>${current_row}/td[10]//${float_val}</td>
<td tal:condition="exists:final_balance" tal:content="string:$final_balance"></td>
<td tal:condition="not:exists:final_balance">0</td></tr>
<tr tal:condition="exists:final_balance_if_debit">
<td>assertFloat</td>
<td>${current_row}/td[11]//${float_val}</td>
<td tal:condition="exists:final_balance_if_debit" tal:content="string:$final_balance_if_debit"></td>
<td tal:condition="not:exists:final_balance_if_debit">0</td></tr>
<tr tal:condition="exists:final_balance_if_credit">
<td>assertFloat</td>
<td>${current_row}/td[12]//${float_val}</td>
<td tal:condition="exists:final_balance_if_credit" tal:content="string:$final_balance_if_credit"></td>
<td tal:condition="not:exists:final_balance_if_credit">0</td></tr>
</tal:block>
</body>
</html>
\ No newline at end of file
preference = context.portal_preferences.accounting_zuite_preference
preference.edit(preferred_account_number_method='account_reference')
preference.edit(
preferred_account_number_method='account_reference',
preferred_report_style=report_style)
return "Preference Set"
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
<value> <string>report_style=\'View\'</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
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