Commit 1c49a1ac authored by Nicolas Wavrant's avatar Nicolas Wavrant

erp5_accounting: closing an Accounting Period generates one Balance...

erp5_accounting: closing an Accounting Period generates one Balance Transaction per accounting ledger

BalanceTransaction.py updated to correctly index Balance Transactions with their ledgers.
_computeStockDifferenceList also now returns a correct result
parent 880248d8
...@@ -32,6 +32,7 @@ from AccessControl import ClassSecurityInfo ...@@ -32,6 +32,7 @@ from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.Document.Inventory import Inventory from Products.ERP5.Document.Inventory import Inventory
from Products.ERP5.Document.AccountingTransaction import AccountingTransaction from Products.ERP5.Document.AccountingTransaction import AccountingTransaction
from Products.ZSQLCatalog.SQLCatalog import Query
import types import types
...@@ -136,6 +137,10 @@ class BalanceTransaction(AccountingTransaction, Inventory): ...@@ -136,6 +137,10 @@ class BalanceTransaction(AccountingTransaction, Inventory):
getInventoryList = self.getPortalObject()\ getInventoryList = self.getPortalObject()\
.portal_simulation.getInventoryList .portal_simulation.getInventoryList
section_uid = self.getDestinationSectionUid() section_uid = self.getDestinationSectionUid()
ledger_uid = self.getLedgerUid()
if ledger_uid is None:
ledger_uid = Query(ledger_uid=None)
precision = 2 precision = 2
if section_uid is not None: if section_uid is not None:
accounting_currency = \ accounting_currency = \
...@@ -150,7 +155,8 @@ class BalanceTransaction(AccountingTransaction, Inventory): ...@@ -150,7 +155,8 @@ class BalanceTransaction(AccountingTransaction, Inventory):
section_uid=section_uid, section_uid=section_uid,
precision=precision, precision=precision,
portal_type=self.getPortalAccountingMovementTypeList(), portal_type=self.getPortalAccountingMovementTypeList(),
simulation_state=('delivered', )) simulation_state=('delivered', ),
ledger_uid=ledger_uid)
# node # node
for movement in self._getGroupByNodeMovementList(): for movement in self._getGroupByNodeMovementList():
...@@ -267,7 +273,8 @@ class BalanceTransaction(AccountingTransaction, Inventory): ...@@ -267,7 +273,8 @@ class BalanceTransaction(AccountingTransaction, Inventory):
relative_url=movement.getRelativeUrl(), relative_url=movement.getRelativeUrl(),
quantity=movement.getQuantity(), quantity=movement.getQuantity(),
total_price=movement\ total_price=movement\
.getDestinationInventoriatedTotalAssetPrice(), )) .getDestinationInventoriatedTotalAssetPrice(),
ledger_uid=movement.getLedgerUid(), ))
# mirror section # mirror section
for movement in self._getGroupByMirrorSectionMovementList(): for movement in self._getGroupByMirrorSectionMovementList():
...@@ -291,7 +298,8 @@ class BalanceTransaction(AccountingTransaction, Inventory): ...@@ -291,7 +298,8 @@ class BalanceTransaction(AccountingTransaction, Inventory):
relative_url=movement.getRelativeUrl(), relative_url=movement.getRelativeUrl(),
quantity=movement.getQuantity(), quantity=movement.getQuantity(),
total_price=movement\ total_price=movement\
.getDestinationInventoriatedTotalAssetPrice(), )) .getDestinationInventoriatedTotalAssetPrice(),
ledger_uid=movement.getLedgerUid(), ))
# payment # payment
for movement in self._getGroupByPaymentMovementList(): for movement in self._getGroupByPaymentMovementList():
...@@ -315,7 +323,8 @@ class BalanceTransaction(AccountingTransaction, Inventory): ...@@ -315,7 +323,8 @@ class BalanceTransaction(AccountingTransaction, Inventory):
relative_url=movement.getRelativeUrl(), relative_url=movement.getRelativeUrl(),
quantity=movement.getQuantity(), quantity=movement.getQuantity(),
total_price=movement\ total_price=movement\
.getDestinationInventoriatedTotalAssetPrice(), )) .getDestinationInventoriatedTotalAssetPrice(),
ledger_uid=movement.getLedgerUid(), ))
return new_stock return new_stock
......
This diff is collapsed.
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