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
Tristan Cavelier
erp5
Commits
ed21149a
Commit
ed21149a
authored
Jul 28, 2014
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accounting: Fix bug with closing period when all accounts have 0 balance
parent
7b917688
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
2 deletions
+86
-2
bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingPeriod_createBalanceTransaction.xml
..._accounting/AccountingPeriod_createBalanceTransaction.xml
+29
-1
bt5/erp5_accounting/bt/revision
bt5/erp5_accounting/bt/revision
+1
-1
product/ERP5/tests/testAccounting.py
product/ERP5/tests/testAccounting.py
+56
-0
No files found.
bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingPeriod_createBalanceTransaction.xml
View file @
ed21149a
...
@@ -158,7 +158,17 @@ for section in section_list:\n
...
@@ -158,7 +158,17 @@ for section in section_list:\n
precision=section_currency_precision,\n
precision=section_currency_precision,\n
portal_type=portal.getPortalAccountingMovementTypeList(),\n
portal_type=portal.getPortalAccountingMovementTypeList(),\n
at_date=at_date.latestTime(),)\n
at_date=at_date.latestTime(),)\n
\n
\n
# Calculate the sum of profit and loss accounts balances for that period.\n
# This must match the difference between assets, liability and equity accounts.\n
profit_and_loss_accounts_balance = portal.portal_simulation.getInventoryAssetPrice(\n
from_date=context.getStartDate(),\n
node_category=profit_and_loss_node_category_list,\n
**inventory_param_dict)\n
selected_profit_and_loss_account_balance = portal.portal_simulation.getInventoryAssetPrice(\n
node=profit_and_loss_account,\n
**inventory_param_dict)\n
\n
section_currency_uid = context.getParentValue().getPriceCurrencyUid()\n
section_currency_uid = context.getParentValue().getPriceCurrencyUid()\n
\n
\n
profit_and_loss_quantity = 0\n
profit_and_loss_quantity = 0\n
...
@@ -300,8 +310,26 @@ for section in section_list:\n
...
@@ -300,8 +310,26 @@ for section in section_list:\n
\n
\n
if balance_transaction is None:\n
if balance_transaction is None:\n
# we did not have any transaction for this section\n
# we did not have any transaction for this section\n
\n
# One possible corner case is that we have only transactions that brings\n
# the balance of all balance sheets accounts to 0. In this case we want to\n
# create a balance transaction that notes that the current balance of profit\n
# and loss account is 0, so that the delta gets indexed. \n
if profit_and_loss_accounts_balance:\n
balance_transaction = createBalanceTransaction(section)\n
balance_transaction.newContent(\n
activate_kw=activate_kw,\n
portal_type=\'Balance Transaction Line\',\n
destination=profit_and_loss_account,\n
quantity=0)\n
balance_transaction.stop()\n
balance_transaction.deliver()\n
continue\n
continue\n
\n
\n
assert roundCurrency(profit_and_loss_accounts_balance, section_currency) == (\n
- roundCurrency(selected_profit_and_loss_account_balance, section_currency)\n
- roundCurrency(profit_and_loss_quantity, section_currency))\n
\n
# add a final line for p&l\n
# add a final line for p&l\n
balance_transaction.newContent(\n
balance_transaction.newContent(\n
id=\'%03d\' % (line_count + 1),\n
id=\'%03d\' % (line_count + 1),\n
...
...
bt5/erp5_accounting/bt/revision
View file @
ed21149a
1571
1572
\ No newline at end of file
\ No newline at end of file
product/ERP5/tests/testAccounting.py
View file @
ed21149a
...
@@ -1854,6 +1854,62 @@ class TestClosingPeriod(AccountingTestCase):
...
@@ -1854,6 +1854,62 @@ class TestClosingPeriod(AccountingTestCase):
balance_transaction
.
reindexObject
()
balance_transaction
.
reindexObject
()
self
.
tic
()
self
.
tic
()
def
test_BalanceTransactionWhenProfitAndLossBalanceIsZero
(
self
):
# The case of a balance transaction after all accounts have a 0 balance.
period1
=
self
.
section
.
newContent
(
portal_type
=
'Accounting Period'
)
period1
.
setStartDate
(
DateTime
(
2006
,
1
,
1
))
period1
.
setStopDate
(
DateTime
(
2006
,
12
,
31
))
period2
=
self
.
section
.
newContent
(
portal_type
=
'Accounting Period'
)
period2
.
setStartDate
(
DateTime
(
2007
,
1
,
1
))
period2
.
setStopDate
(
DateTime
(
2007
,
12
,
31
))
pl
=
self
.
portal
.
account_module
.
newContent
(
portal_type
=
'Account'
,
account_type
=
'equity'
)
transaction1
=
self
.
_makeOne
(
start_date
=
DateTime
(
2006
,
1
,
1
),
portal_type
=
'Sale Invoice Transaction'
,
destination_section_value
=
self
.
organisation_module
.
client_1
,
simulation_state
=
'delivered'
,
lines
=
(
dict
(
source_value
=
self
.
account_module
.
receivable
,
source_debit
=
100
),
dict
(
source_value
=
self
.
account_module
.
goods_sales
,
source_credit
=
100
)))
self
.
tic
()
period1
.
AccountingPeriod_createBalanceTransaction
(
profit_and_loss_account
=
pl
.
getRelativeUrl
())
year_1_accounting_transaction_list
=
self
.
accounting_module
.
contentValues
()
self
.
assertEqual
(
2
,
len
(
year_1_accounting_transaction_list
))
self
.
tic
()
transaction2
=
self
.
_makeOne
(
start_date
=
DateTime
(
2007
,
1
,
1
),
portal_type
=
'Sale Invoice Transaction'
,
destination_section_value
=
self
.
organisation_module
.
client_1
,
simulation_state
=
'delivered'
,
lines
=
(
dict
(
source_value
=
self
.
account_module
.
receivable
,
source_debit
=-
100
),
dict
(
source_value
=
self
.
account_module
.
goods_sales
,
source_credit
=-
100
)))
self
.
tic
()
period2
.
AccountingPeriod_createBalanceTransaction
(
profit_and_loss_account
=
pl
.
getRelativeUrl
())
accounting_transaction_list
=
self
.
accounting_module
.
contentValues
()
self
.
assertEqual
(
4
,
len
(
accounting_transaction_list
))
self
.
tic
()
balance_transaction
,
=
[
t
for
t
in
accounting_transaction_list
if
t
not
in
year_1_accounting_transaction_list
and
t
!=
transaction2
]
# Maybe we want to add line for each account in that case ?
line
,
=
balance_transaction
.
contentValues
()
self
.
assertEquals
(
line
.
getDestinationValue
(),
pl
)
self
.
assertEquals
(
line
.
getQuantity
(),
0
)
self
.
assertEquals
(
line
.
getDestinationTotalAssetPrice
(),
None
)
def
test_InventoryIndexingNodeAndMirrorSection
(
self
):
def
test_InventoryIndexingNodeAndMirrorSection
(
self
):
# Balance Transactions are indexed as Inventories.
# Balance Transactions are indexed as Inventories.
transaction1
=
self
.
_makeOne
(
transaction1
=
self
.
_makeOne
(
...
...
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