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
Vivek
erp5
Commits
ce5a974b
Commit
ce5a974b
authored
Feb 10, 2015
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accounting: support balance transactions with different currencies on the PL account
parent
d2aa9fe9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
3 deletions
+78
-3
bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingPeriod_createBalanceTransaction.xml
..._accounting/AccountingPeriod_createBalanceTransaction.xml
+2
-3
product/ERP5/tests/testAccounting.py
product/ERP5/tests/testAccounting.py
+76
-0
No files found.
bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingPeriod_createBalanceTransaction.xml
View file @
ce5a974b
...
...
@@ -167,6 +167,7 @@ for section in section_list:\n
**inventory_param_dict)\n
selected_profit_and_loss_account_balance = portal.portal_simulation.getInventoryAssetPrice(\n
node=profit_and_loss_account,\n
resource=section_currency,\n
**inventory_param_dict)\n
\n
section_currency_uid = context.getParentValue().getPriceCurrencyUid()\n
...
...
@@ -189,10 +190,8 @@ for section in section_list:\n
\n
line_count += 1\n
if inventory.resource_uid != section_currency_uid:\n
if inventory.node_relative_url == profit_and_loss_account:\n
raise ValueError(\'Using multiple currencies on profit and loss account \'\n
\'is not supported\')\n
profit_and_loss_quantity += total_price\n
\n
if balance_transaction is None:\n
balance_transaction = createBalanceTransaction(section)\n
balance_transaction.newContent(\n
...
...
product/ERP5/tests/testAccounting.py
View file @
ce5a974b
...
...
@@ -1852,6 +1852,82 @@ class TestClosingPeriod(AccountingTestCase):
balance_transaction
.
reindexObject
()
self
.
tic
()
def
test_ProfitAndLossUsedInPeriodWithMultipleCurrency
(
self
):
"""When the profit and loss account has a non zero balance at the end of
the period, AccountingPeriod_createBalanceTransaction script should add
a line for each currency used.
"""
period
=
self
.
section
.
newContent
(
portal_type
=
'Accounting Period'
)
period
.
setStartDate
(
DateTime
(
2006
,
1
,
1
))
period
.
setStopDate
(
DateTime
(
2006
,
12
,
31
))
pl_account
=
self
.
portal
.
account_module
.
newContent
(
portal_type
=
'Account'
,
account_type
=
'equity'
,
gap
=
'my_country/my_accounting_standards/1'
,
title
=
'Profit & Loss'
)
pl_account
.
validate
()
transaction1
=
self
.
_makeOne
(
start_date
=
DateTime
(
2006
,
1
,
1
),
portal_type
=
'Accounting Transaction'
,
simulation_state
=
'delivered'
,
lines
=
(
dict
(
source_value
=
self
.
account_module
.
goods_purchase
,
source_debit
=
400
),
dict
(
source_value
=
pl_account
,
source_debit
=
100
),
dict
(
source_value
=
self
.
account_module
.
stocks
,
source_credit
=
500
)))
self
.
assertEqual
([],
transaction1
.
checkConsistency
())
transaction2
=
self
.
_makeOne
(
start_date
=
DateTime
(
2006
,
1
,
2
),
portal_type
=
'Accounting Transaction'
,
resource_value
=
self
.
portal
.
currency_module
.
yen
,
simulation_state
=
'delivered'
,
lines
=
(
dict
(
source_value
=
self
.
account_module
.
goods_purchase
,
source_debit
=
9000
,
source_asset_debit
=
90
),
dict
(
source_value
=
pl_account
,
source_debit
=
1000
,
source_asset_debit
=
10
),
dict
(
source_value
=
self
.
account_module
.
stocks
,
source_credit
=
10000
,
source_asset_credit
=
100
)))
self
.
assertEqual
([],
transaction2
.
checkConsistency
())
period
.
AccountingPeriod_createBalanceTransaction
(
profit_and_loss_account
=
pl_account
.
getRelativeUrl
())
balance_transaction_list
=
self
.
accounting_module
.
contentValues
(
portal_type
=
'Balance Transaction'
)
self
.
assertEqual
(
1
,
len
(
balance_transaction_list
))
balance_transaction
=
balance_transaction_list
[
0
]
balance_transaction
.
alternateReindexObject
()
movement_list
=
balance_transaction
.
getMovementList
()
pl_movement_list
=
[
m
for
m
in
movement_list
if
m
.
getDestinationValue
()
==
pl_account
]
self
.
assertEqual
(
2
,
len
(
pl_movement_list
))
# This is a 400 + 90 loss, plus the 100 using EUR
self
.
assertEqual
(
sorted
([
(
100
+
490.
,
None
,
self
.
portal
.
currency_module
.
euro
,
),
(
1000.
,
10.
,
self
.
portal
.
currency_module
.
yen
,
),
]),
sorted
([(
m
.
getQuantity
(),
m
.
getDestinationTotalAssetPrice
(),
m
.
getResourceValue
(),
)
for
m
in
pl_movement_list
]))
self
.
tic
()
balance_transaction
.
reindexObject
()
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'
)
...
...
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