Commit 7baa871a authored by Jérome Perrin's avatar Jérome Perrin

accounting_l10n_fr: fix issue with transaction using asset price

We used a wrong condition that was causing lines with a debit
and asset credit (ie. different sides) to be output wrongly
with debit and credit.
parent 4223004e
Pipeline #27488 failed with stage
in 0 seconds
......@@ -17,7 +17,7 @@
<CompteAuxLib tal:content="third_party/getTitle"></CompteAuxLib></tal:block><tal:block>
<Montantdevise></Montantdevise>
<Idevise></Idevise></tal:block>
<Debit tal:content="python: '%0.2f' % (line.getDestinationAssetDebit() or line.getDestinationDebit())"></Debit>
<Credit tal:content="python: '%0.2f' % (line.getDestinationAssetCredit() or line.getDestinationCredit())"></Credit>
<Debit tal:content="python: '%0.2f' % (line.getDestinationAssetDebit() if line.hasDestinationTotalAssetPrice() else line.getDestinationDebit())"></Debit>
<Credit tal:content="python: '%0.2f' % (line.getDestinationAssetCredit() if line.hasDestinationTotalAssetPrice() else line.getDestinationCredit())"></Credit>
</ligne></tal:block>
</ecriture>
\ No newline at end of file
......@@ -17,7 +17,7 @@
<CompteAuxLib tal:content="third_party/getTitle"></CompteAuxLib></tal:block><tal:block>
<Montantdevise></Montantdevise>
<Idevise></Idevise></tal:block>
<Debit tal:content="python: '%0.2f' % (line.getSourceAssetDebit() or line.getSourceDebit())"></Debit>
<Credit tal:content="python: '%0.2f' % (line.getSourceAssetCredit() or line.getSourceCredit())"></Credit>
<Debit tal:content="python: '%0.2f' % (line.getSourceAssetDebit() if line.hasSourceTotalAssetPrice() else line.getSourceDebit())"></Debit>
<Credit tal:content="python: '%0.2f' % (line.getSourceAssetCredit() if line.hasSourceTotalAssetPrice() else line.getSourceCredit())"></Credit>
</ligne></tal:block>
</ecriture>
\ No newline at end of file
......@@ -586,6 +586,72 @@ class TestAccounting_l10n_fr(AccountingTestCase):
tree.xpath('//EcritureNum/text()'), ['destination_reference'])
self.assertEqual([n.text for n in tree.xpath('//PieceRef')], [None])
def test_AssetPriceAndQuantityEdgeCase(self):
# Edge case where we have an asset price and quantity of reverse sides.
account_module = self.portal.account_module
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=100,
destination_asset_credit=123,
),
dict(
destination_value=account_module.goods_purchase,
destination_credit=100,
destination_asset_debit=123,
)))
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=200.00,
source_asset_debit=345,
),
dict(
source_value=account_module.goods_sales,
source_credit=200.00,
source_asset_credit=345,
)))
self.tic()
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()'),
['0.00', '123.00'])
self.assertEqual(
tree.xpath(
'//ecriture/PieceRef[text()="destination"]/../ligne/Credit/text()'),
['123.00', '0.00'])
self.assertEqual(
tree.xpath('//ecriture/PieceRef[text()="source"]/../ligne/Debit/text()'),
['345.00', '0.00'])
self.assertEqual(
tree.xpath(
'//ecriture/PieceRef[text()="source"]/../ligne/Credit/text()'),
['0.00', '345.00'])
def test_suite():
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