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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Aaron Chen
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
Show 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,12 +170,16 @@ 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
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
...
...
@@ -182,8 +188,8 @@ if from_date or is_pl_account:\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
\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
...
...
@@ -192,17 +198,12 @@ if from_date or is_pl_account:\n
from_date=period_start_date,\n
to_date=initial_balance_from_date,\n
**get_inventory_kw) - max(-period_openning_balance, 0)\n
\n
\n
if previous_total_credit != 0:\n
previous_total_credit = - previous_total_credit\n
\n
if \'group_by\' in kw:\n
params[\'group_by\'] = kw[\'group_by\']\n
\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
...
...
@@ -212,6 +213,9 @@ if from_date or is_pl_account:\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
...
...
@@ -227,11 +231,26 @@ if from_date or is_pl_account:\n
Movement_getProjectTitle=lambda: \'\',\n
Node_statAccountingBalance=\'\',\n
getTranslatedSimulationStateTitle=\'\',\n
modification_date=\'\',\n
)\n
\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
new_result = [previous_balance]\n
if \'group_by\' in kw:\n
params[\'group_by\'] = kw[\'group_by\']\n
new_result.extend(\n
portal.portal_simulation.getMovementHistoryList(\n
from_date=from_date,\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