Commit 7597c300 authored by Jérome Perrin's avatar Jérome Perrin

accounting_l10n_fr: don't export lines with 0 quantity in FEC

"Test Compta Demat" complains about these
https://github.com/DGFiP/Test-Compta-Demat/blob/1563a42a260e754a7543b2ee178d4300d1582db5/src/testeur/trt_txt.pl#L1023-L1033
parent 5ae0508d
...@@ -88,7 +88,11 @@ for journal_code, journal_lib, journal_search_kw in _groupedJournalTupleDict(): ...@@ -88,7 +88,11 @@ for journal_code, journal_lib, journal_search_kw in _groupedJournalTupleDict():
portal.portal_catalog.searchAndActivate( portal.portal_catalog.searchAndActivate(
method_id='AccountingTransaction_postFECResult', method_id='AccountingTransaction_postFECResult',
method_kw=dict(section_uid_list=section_uid_list, active_process=this_journal_active_process.getRelativeUrl()), method_kw=dict(
section_uid_list=section_uid_list,
active_process=this_journal_active_process.getRelativeUrl(),
test_compta_demat_compatibility=test_compta_demat_compatibility,
),
activate_kw=dict(tag=tag, priority=priority), activate_kw=dict(tag=tag, priority=priority),
**journal_search_kw) **journal_search_kw)
......
...@@ -10,10 +10,12 @@ accounting_line_list = context.contentValues(portal_type=portal.getPortalAccount ...@@ -10,10 +10,12 @@ accounting_line_list = context.contentValues(portal_type=portal.getPortalAccount
if context.getSourceSectionUid() in section_uid_list: if context.getSourceSectionUid() in section_uid_list:
if any([line.getSource(portal_type='Account') for line in accounting_line_list]): if any([line.getSource(portal_type='Account') for line in accounting_line_list]):
source_xml = context.AccountingTransaction_viewAsSourceFECXML() source_xml = context.AccountingTransaction_viewAsSourceFECXML(
test_compta_demat_compatibility=test_compta_demat_compatibility)
active_process.postResult(ActiveResult(detail=source_xml.encode('utf8').encode('zlib'))) active_process.postResult(ActiveResult(detail=source_xml.encode('utf8').encode('zlib')))
if context.getDestinationSectionUid() in section_uid_list: if context.getDestinationSectionUid() in section_uid_list:
if any([line.getDestination(portal_type='Account') for line in accounting_line_list]): if any([line.getDestination(portal_type='Account') for line in accounting_line_list]):
destination_xml = context.AccountingTransaction_viewAsDestinationFECXML() destination_xml = context.AccountingTransaction_viewAsDestinationFECXML(
test_compta_demat_compatibility=test_compta_demat_compatibility)
active_process.postResult(ActiveResult(detail=destination_xml.encode('utf8').encode('zlib'))) active_process.postResult(ActiveResult(detail=destination_xml.encode('utf8').encode('zlib')))
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>active_process, section_uid_list</string> </value> <value> <string>active_process, section_uid_list, test_compta_demat_compatibility</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
<DateLet></DateLet></tal:block> <DateLet></DateLet></tal:block>
<ValidDate tal:content="python: context.AccountingTransaction_getDeliverDate().strftime('%Y-%m-%d')">Modification Date</ValidDate> <ValidDate tal:content="python: context.AccountingTransaction_getDeliverDate().strftime('%Y-%m-%d')">Modification Date</ValidDate>
<tal:block tal:repeat="line python:context.contentValues(portal_type=context.getPortalAccountingMovementTypeList())"><ligne <tal:block tal:repeat="line python:context.contentValues(portal_type=context.getPortalAccountingMovementTypeList())"><ligne
tal:define="account python:line.getDestinationValue(portal_type='Account')" tal:condition="python: account is not None"> tal:define="account python:line.getDestinationValue(portal_type='Account')"
tal:condition="python: account is not None and (line.getQuantity() or line.getDestinationAssetDebit() or line.getDestinationAssetCredit() or not options['test_compta_demat_compatibility'])">
<CompteNum tal:content="account/Account_getGapId">Reference Compte (Account_getGapId)</CompteNum> <CompteNum tal:content="account/Account_getGapId">Reference Compte (Account_getGapId)</CompteNum>
<CompteLib tal:content="line/Movement_getDestinationCompteLib">Translated Title Compte</CompteLib> <CompteLib tal:content="line/Movement_getDestinationCompteLib">Translated Title Compte</CompteLib>
<tal:block tal:condition="python: account.getAccountType() in ('asset/receivable', 'liability/payable')" <tal:block tal:condition="python: account.getAccountType() in ('asset/receivable', 'liability/payable')"
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
<DateLet></DateLet></tal:block> <DateLet></DateLet></tal:block>
<ValidDate tal:content="python: context.AccountingTransaction_getDeliverDate().strftime('%Y-%m-%d')">Modification Date</ValidDate> <ValidDate tal:content="python: context.AccountingTransaction_getDeliverDate().strftime('%Y-%m-%d')">Modification Date</ValidDate>
<tal:block tal:repeat="line python:context.contentValues(portal_type=context.getPortalAccountingMovementTypeList())"><ligne <tal:block tal:repeat="line python:context.contentValues(portal_type=context.getPortalAccountingMovementTypeList())"><ligne
tal:define="account python:line.getSourceValue(portal_type='Account')" tal:condition="python: account is not None"> tal:define="account python:line.getSourceValue(portal_type='Account')"
tal:condition="python: account is not None and (line.getQuantity() or line.getSourceAssetDebit() or line.getSourceAssetCredit() or not options['test_compta_demat_compatibility'])">
<CompteNum tal:content="account/Account_getGapId">Reference Compte (Account_getGapId)</CompteNum> <CompteNum tal:content="account/Account_getGapId">Reference Compte (Account_getGapId)</CompteNum>
<CompteLib tal:content="line/Movement_getSourceCompteLib">Translated Title Compte</CompteLib> <CompteLib tal:content="line/Movement_getSourceCompteLib">Translated Title Compte</CompteLib>
<tal:block tal:condition="python: account.getAccountType() in ('asset/receivable', 'liability/payable')" <tal:block tal:condition="python: account.getAccountType() in ('asset/receivable', 'liability/payable')"
......
...@@ -413,9 +413,13 @@ class TestAccounting_l10n_fr(AccountingTestCase): ...@@ -413,9 +413,13 @@ class TestAccounting_l10n_fr(AccountingTestCase):
assert invoice.workflow_history['accounting_workflow'][-1]['action'] == 'deliver' assert invoice.workflow_history['accounting_workflow'][-1]['action'] == 'deliver'
invoice.workflow_history['accounting_workflow'][-1]['time'] = DateTime(2001, 2, 3) invoice.workflow_history['accounting_workflow'][-1]['time'] = DateTime(2001, 2, 3)
tree = etree.fromstring(invoice.AccountingTransaction_viewAsSourceFECXML()) tree = etree.fromstring(
invoice.AccountingTransaction_viewAsSourceFECXML(
test_compta_demat_compatibility=True))
self.assertEqual(tree.xpath('//ValidDate/text()'), ['2001-02-03']) self.assertEqual(tree.xpath('//ValidDate/text()'), ['2001-02-03'])
tree = etree.fromstring(invoice.AccountingTransaction_viewAsDestinationFECXML()) tree = etree.fromstring(
invoice.AccountingTransaction_viewAsDestinationFECXML(
test_compta_demat_compatibility=True))
self.assertEqual(tree.xpath('//ValidDate/text()'), ['2001-02-03']) self.assertEqual(tree.xpath('//ValidDate/text()'), ['2001-02-03'])
def test_EscapeTestComptaDematUnsupportedCharacters(self): def test_EscapeTestComptaDematUnsupportedCharacters(self):
...@@ -454,6 +458,81 @@ class TestAccounting_l10n_fr(AccountingTestCase): ...@@ -454,6 +458,81 @@ class TestAccounting_l10n_fr(AccountingTestCase):
tree.xpath('//EcritureLib/text()'), tree.xpath('//EcritureLib/text()'),
[u'Des oeufs, des OEufs, des Y et des EUR']) [u'Des oeufs, des OEufs, des Y et des EUR'])
def test_Skip0QuantityLines(self):
# Don't include lines with 0 quantity in the output, because they are
# reported as invalid by Test Compta Demat
account_module = self.portal.account_module
destination_invoice = self._makeOne(
portal_type='Purchase Invoice Transaction',
title='destination 0',
simulation_state='delivered',
reference='destination',
source_section_value=self.organisation_module.supplier,
stop_date=DateTime(2014, 2, 2),
lines=(
dict(
destination_value=account_module.payable, destination_debit=132.00),
dict(
destination_value=account_module.refundable_vat,
destination_credit=22.00),
dict(
destination_value=account_module.refundable_vat,
destination_credit=0.00),
dict(
destination_value=account_module.goods_purchase,
destination_credit=110.00)))
self._makeOne(
portal_type='Sale Invoice Transaction',
title='source 0',
simulation_state='delivered',
reference='source',
destination_section_value=self.organisation_module.client_2,
start_date=DateTime(2014, 3, 1),
lines=(
dict(source_value=account_module.receivable, source_debit=240.00),
dict(source_value=account_module.collected_vat, source_credit=0.00),
dict(source_value=account_module.collected_vat, source_credit=40.00),
dict(source_value=account_module.goods_sales, source_credit=200.00)))
self.tic()
# make sure we don't have interaction removing the lines
self.assertEqual(
sorted(
[
(line.getDestinationDebit(), line.getSourceDebit())
for line in destination_invoice.contentValues()
]), [
(0.0, 0.0),
(0.0, 22.0),
(0.0, 110.0),
(132.0, 0.0),
])
self.portal.accounting_module.AccountingTransactionModule_viewFrenchAccountingTransactionFile(
section_category='group/demo_group',
section_category_strict=False,
at_date=DateTime(2014, 12, 31),
simulation_state=['delivered'])
self.tic()
tree = etree.fromstring(self.getFECFromMailMessage())
self.validateFECXML(tree)
self.assertEqual(
tree.xpath(
'//ecriture/PieceRef[text()="destination"]/../ligne/Debit/text()'),
['132.00', '0.00', '0.00'])
self.assertEqual(
tree.xpath(
'//ecriture/PieceRef[text()="destination"]/../ligne/Credit/text()'),
['0.00', '22.00', '110.00'])
self.assertEqual(
tree.xpath('//ecriture/PieceRef[text()="source"]/../ligne/Debit/text()'),
['240.00', '0.00', '0.00'])
self.assertEqual(
tree.xpath(
'//ecriture/PieceRef[text()="source"]/../ligne/Credit/text()'),
['0.00', '40.00', '200.00'])
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
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