diff --git a/bt5/erp5_accounting_l10n_fr/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr/AccountingTransaction_viewAsDestinationFECXML.zpt b/bt5/erp5_accounting_l10n_fr/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr/AccountingTransaction_viewAsDestinationFECXML.zpt index 0301620b2efae456f8a437faf0f4c1d74f485458..2d98db80230fcbff1cc35a130c14d77b9cce2114 100644 --- a/bt5/erp5_accounting_l10n_fr/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr/AccountingTransaction_viewAsDestinationFECXML.zpt +++ b/bt5/erp5_accounting_l10n_fr/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr/AccountingTransaction_viewAsDestinationFECXML.zpt @@ -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 diff --git a/bt5/erp5_accounting_l10n_fr/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr/AccountingTransaction_viewAsSourceFECXML.zpt b/bt5/erp5_accounting_l10n_fr/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr/AccountingTransaction_viewAsSourceFECXML.zpt index 66c9f8d4bb72d8650afeccff53b7bb27b84c8ad5..d905d90bc64bd5bf7288c5ec6b3c3addaeec8e6f 100644 --- a/bt5/erp5_accounting_l10n_fr/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr/AccountingTransaction_viewAsSourceFECXML.zpt +++ b/bt5/erp5_accounting_l10n_fr/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr/AccountingTransaction_viewAsSourceFECXML.zpt @@ -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 diff --git a/bt5/erp5_accounting_l10n_fr/TestTemplateItem/portal_components/test.erp5.testAccounting_l10n_fr.py b/bt5/erp5_accounting_l10n_fr/TestTemplateItem/portal_components/test.erp5.testAccounting_l10n_fr.py index a5be95b926e5750f72bde0ca6205ec34bf245023..843fa1f03313353243bc3cde3cf09778878ce299 100644 --- a/bt5/erp5_accounting_l10n_fr/TestTemplateItem/portal_components/test.erp5.testAccounting_l10n_fr.py +++ b/bt5/erp5_accounting_l10n_fr/TestTemplateItem/portal_components/test.erp5.testAccounting_l10n_fr.py @@ -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()