Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alecs_myu
erp5
Commits
f4639fde
Commit
f4639fde
authored
Mar 19, 2015
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounting: Properly support initial balance in GL export
parent
c8dee291
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
61 deletions
+84
-61
bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Node_getAccountingTransactionList.xml
...ins/erp5_accounting/Node_getAccountingTransactionList.xml
+80
-61
product/ERP5/tests/testAccountingReports.py
product/ERP5/tests/testAccountingReports.py
+4
-0
No files found.
bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Node_getAccountingTransactionList.xml
View file @
f4639fde
...
...
@@ -52,6 +52,7 @@
<key>
<string>
_body
</string>
</key>
<value>
<string
encoding=
"cdata"
>
<![CDATA[
from Products.ERP5Type.Document import newTempBase\n
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery\n
from Products.ERP5Type.Message import translateString\n
from Products.ERP5Type.Log import log\n
...
...
@@ -123,6 +124,7 @@ net_balance = 0.0\n
is_pl_account = False\n
if params.get(\'node_uid\'):\n
if context.getUid() == params[\'node_uid\']:\n
node = context\n
is_pl_account = context.isMemberOf(\'account_type/expense\')\\\n
or context.isMemberOf(\'account_type/income\')\n
else:\n
...
...
@@ -168,72 +170,89 @@ if from_date or is_pl_account:\n
# I don\'t think this should happen\n
log(\'from_date not passed, defaulting to period_start_date\')\n
initial_balance_from_date = period_start_date\n
\n
\n
# Get previous debit and credit\n
if initial_balance_from_date == period_start_date and is_pl_account:\n
previous_total_debit = previous_total_credit = 0\n
else:\n
if not (initial_balance_from_date == period_start_date and is_pl_account):\n
getInventoryAssetPrice = portal.portal_simulation.getInventoryAssetPrice\n
# first to the balance at the period start date\n
if is_pl_account:\n
period_openning_balance = 0\n
else:\n
period_openning_balance = getInventoryAssetPrice(\n
to_date=min(period_start_date,\n
initial_balance_from_date),\n
**get_inventory_kw)\n
\n
# then all movement between period_start_date and from_date\n
previous_total_debit = getInventoryAssetPrice(omit_asset_decrease=True,\n
from_date=period_start_date,\n
to_date=initial_balance_from_date,\n
**get_inventory_kw) + max(period_openning_balance, 0)\n
previous_total_credit = getInventoryAssetPrice(omit_asset_increase=True,\n
from_date=period_start_date,\n
to_date=initial_balance_from_date,\n
**get_inventory_kw) - max(-period_openning_balance, 0)\n
for section_uid in list(params.get(\'section_uid\', [])):\n
# We add one initial balance line per section. The main reason is to be able\n
# to know the section_title for the GL export.\n
# XXX we may also want detail by resource or analytic columns sometimes.\n
get_inventory_kw[\'section_uid\'] = section_uid\n
# Initial balance calculation uses the same logic as Trial Balance.\n
# first to the balance at the period start date\n
if is_pl_account:\n
period_openning_balance = 0\n
else:\n
period_openning_balance = getInventoryAssetPrice(\n
to_date=min(period_start_date,\n
initial_balance_from_date),\n
**get_inventory_kw)\n
\n
# then all movements between period_start_date and from_date\n
previous_total_debit = getInventoryAssetPrice(omit_asset_decrease=True,\n
from_date=period_start_date,\n
to_date=initial_balance_from_date,\n
**get_inventory_kw) + max(period_openning_balance, 0)\n
previous_total_credit = getInventoryAssetPrice(omit_asset_increase=True,\n
from_date=period_start_date,\n
to_date=initial_balance_from_date,\n
**get_inventory_kw) - max(-period_openning_balance, 0)\n
\n
if previous_total_credit != 0:\n
previous_total_credit = - previous_total_credit\n
\n
# Show the previous balance if not empty\n
if previous_total_credit != 0 or previous_total_debit != 0:\n
net_balance = previous_total_debit - previous_total_credit\n
previous_balance = newTempBase(portal, \'_temp_accounting_transaction\')\n
previous_balance.edit(\n
uid=\'new_000\',\n
date=initial_balance_from_date,\n
simulation_state_title="",\n
credit_price=previous_total_credit,\n
debit_price=previous_total_debit,\n
total_price=net_balance,\n
credit=previous_total_credit,\n
debit=previous_total_debit,\n
total_quantity=net_balance,\n
running_total_price=net_balance,\n
is_previous_balance=True,\n
Movement_getSpecificReference=u\'%s\' % translateString(\'Previous Balance\'),\n
Movement_getExplanationTitle=u\'%s\' % translateString(\'Previous Balance\'),\n
Movement_getExplanationTranslatedPortalType=\'\',\n
Movement_getExplanationReference=\'\',\n
Movement_getMirrorSectionTitle=\'\',\n
Movement_getNodeGapId=\'\',\n
getListItemUrl=lambda *args,**kw: None,\n
Movement_getExplanationUrl=lambda **kw:None,\n
Movement_getFundingTitle=lambda: \'\',\n
Movement_getFunctionTitle=lambda: \'\',\n
Movement_getProjectTitle=lambda: \'\',\n
Node_statAccountingBalance=\'\',\n
getTranslatedSimulationStateTitle=\'\',\n
modification_date=\'\',\n
)\n
\n
if previous_total_credit != 0:\n
previous_total_credit = - previous_total_credit\n
if context.getPortalType() == \'Account\':\n
previous_balance.edit(Movement_getExplanationTitle=\'\')\n
if params.get(\'node_uid\'):\n
previous_balance.edit(\n
Movement_getNodeGapId=node.Account_getGapId(),\n
node_translated_title=node.getTranslatedTitle()\n
)\n
section = portal.portal_catalog.getObject(section_uid)\n
previous_balance.edit(\n
Movement_getSectionPriceCurrency=section.getPriceCurrencyReference(),\n
resource_reference=section.getPriceCurrencyReference(),\n
section_title=section.getTitle(),\n
)\n
new_result.append(previous_balance)\n
\n
if \'group_by\' in kw:\n
params[\'group_by\'] = kw[\'group_by\']\n
\n
# Show the previous balance if not empty\n
if previous_total_credit != 0 or previous_total_debit != 0:\n
from Products.ERP5Type.Document import newTempBase\n
\n
net_balance = previous_total_debit - previous_total_credit\n
previous_balance = newTempBase(portal, \'_temp_accounting_transaction\')\n
previous_balance.edit(\n
uid=\'new_000\',\n
date=initial_balance_from_date,\n
simulation_state_title="",\n
credit_price=previous_total_credit,\n
debit_price=previous_total_debit,\n
total_price=net_balance,\n
running_total_price=net_balance,\n
is_previous_balance=True,\n
Movement_getSpecificReference=u\'%s\' % translateString(\'Previous Balance\'),\n
Movement_getExplanationTitle=u\'%s\' % translateString(\'Previous Balance\'),\n
Movement_getExplanationTranslatedPortalType=\'\',\n
Movement_getExplanationReference=\'\',\n
Movement_getMirrorSectionTitle=\'\',\n
Movement_getNodeGapId=\'\',\n
getListItemUrl=lambda *args,**kw: None,\n
Movement_getExplanationUrl=lambda **kw:None,\n
Movement_getFundingTitle=lambda: \'\',\n
Movement_getFunctionTitle=lambda: \'\',\n
Movement_getProjectTitle=lambda: \'\',\n
Node_statAccountingBalance=\'\',\n
getTranslatedSimulationStateTitle=\'\',\n
)\n
if context.getPortalType() == \'Account\':\n
previous_balance.edit(Movement_getExplanationTitle=\'\')\n
\n
new_result = [previous_balance]\n
new_result.extend(\n
portal.portal_simulation.getMovementHistoryList(\n
new_result.extend(\n
portal.portal_simulation.getMovementHistoryList(\n
from_date=from_date,\n
initial_running_total_price=net_balance,\n
# initial_running_quantity=net_balance, TODO\n
...
...
@@ -242,7 +261,7 @@ if from_date or is_pl_account:\n
sort_on=sort_on,\n
ignore_group_by=True,\n
**params))\n
return new_result\n
return new_result\n
\n
# We try not to convert to a list, hence the copy & paste\n
return portal.portal_simulation.getMovementHistoryList(\n
...
...
product/ERP5/tests/testAccountingReports.py
View file @
f4639fde
...
...
@@ -1619,7 +1619,11 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
self
.
checkLineProperties
(
data_line_list
[
0
],
Movement_getSpecificReference
=
'Previous Balance'
,
date
=
DateTime
(
2006
,
2
,
2
),
section_title
=
'My Organisation'
,
Movement_getExplanationTitleAndAnalytics
=
None
,
grouping_date
=
None
,
grouping_reference
=
None
,
modification_date
=
''
,
debit_price
=
300
,
credit_price
=
21
,
running_total_price
=
279
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment