Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
640e851f
Commit
640e851f
authored
8 years ago
by
Quentin De Paoli
Browse files
Options
Downloads
Patches
Plain Diff
[FIX] l10n_fr_fec: intial balance of accounts from the P&L should be summarized into a single line
parent
dd92f960
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
addons/l10n_fr_fec/wizard/fec.py
+84
-1
84 additions, 1 deletion
addons/l10n_fr_fec/wizard/fec.py
with
84 additions
and
1 deletion
addons/l10n_fr_fec/wizard/fec.py
+
84
−
1
View file @
640e851f
...
...
@@ -23,6 +23,56 @@ class AccountFrFec(models.TransientModel):
(
'
nonofficial
'
,
'
Non-official FEC report (posted and unposted entries)
'
),
],
string
=
'
Export Type
'
,
required
=
True
,
default
=
'
official
'
)
def
do_query_unaffected_earnings
(
self
):
'''
Compute the sum of ending balances for all accounts that are of a type that does not bring forward the balance in new fiscal years.
This is needed because we have to display only one line for the initial balance of all expense/revenue accounts in the FEC.
'''
sql_query
=
'''
SELECT
'
OUV
'
AS JournalCode,
'
Balance initiale
'
AS JournalLib,
'
Balance initiale PL
'
AS EcritureNum,
%s AS EcritureDate,
'
120/129
'
AS CompteNum,
'
Benefice (perte) reporte(e)
'
AS CompteLib,
''
AS CompAuxNum,
''
AS CompAuxLib,
'
-
'
AS PieceRef,
%s AS PieceDate,
'
/
'
AS EcritureLib,
replace(CASE WHEN sum(aml.balance) <= 0 THEN
'
0,00
'
ELSE to_char(SUM(aml.balance),
'
999999999999999D99
'
) END,
'
.
'
,
'
,
'
) AS Debit,
replace(CASE WHEN sum(aml.balance) >= 0 THEN
'
0,00
'
ELSE to_char(-SUM(aml.balance),
'
999999999999999D99
'
) END,
'
.
'
,
'
,
'
) AS Credit,
''
AS EcritureLet,
''
AS DateLet,
%s AS ValidDate,
''
AS Montantdevise,
''
AS Idevise
FROM
account_move_line aml
LEFT JOIN account_move am ON am.id=aml.move_id
JOIN account_account aa ON aa.id = aml.account_id
LEFT JOIN account_account_type aat ON aa.user_type_id = aat.id
WHERE
am.date < %s
AND am.company_id = %s
AND aat.include_initial_balance =
'
f
'
AND (aml.debit != 0 OR aml.credit != 0)
'''
# For official report: only use posted entries
if
self
.
export_type
==
"
official
"
:
sql_query
+=
'''
AND am.state =
'
posted
'
'''
company
=
self
.
env
.
user
.
company_id
formatted_date_from
=
self
.
date_from
.
replace
(
'
-
'
,
''
)
self
.
_cr
.
execute
(
sql_query
,
(
formatted_date_from
,
formatted_date_from
,
formatted_date_from
,
self
.
date_from
,
company
.
id
))
listrow
=
[]
row
=
self
.
_cr
.
fetchone
()
listrow
=
list
(
row
)
return
listrow
@api.multi
def
generate_fec
(
self
):
self
.
ensure_one
()
...
...
@@ -68,6 +118,13 @@ class AccountFrFec(models.TransientModel):
w
.
writerow
(
header
)
# INITIAL BALANCE
unaffected_earnings_xml_ref
=
self
.
env
.
ref
(
'
account.data_unaffected_earnings
'
)
unaffected_earnings_line
=
True
# used to make sure that we add the unaffected earning initial balance only once
if
unaffected_earnings_xml_ref
:
#compute the benefit/loss of last year to add in the initial balance of the current year earnings account
unaffected_earnings_results
=
self
.
do_query_unaffected_earnings
()
unaffected_earnings_line
=
False
sql_query
=
'''
SELECT
'
OUV
'
AS JournalCode,
...
...
@@ -87,14 +144,17 @@ class AccountFrFec(models.TransientModel):
''
AS DateLet,
%s AS ValidDate,
''
AS Montantdevise,
''
AS Idevise
''
AS Idevise,
MIN(aa.id) AS CompteID
FROM
account_move_line aml
LEFT JOIN account_move am ON am.id=aml.move_id
JOIN account_account aa ON aa.id = aml.account_id
LEFT JOIN account_account_type aat ON aa.user_type_id = aat.id
WHERE
am.date < %s
AND am.company_id = %s
AND aat.include_initial_balance =
'
t
'
AND (aml.debit != 0 OR aml.credit != 0)
'''
...
...
@@ -113,7 +173,30 @@ class AccountFrFec(models.TransientModel):
for
row
in
self
.
_cr
.
fetchall
():
listrow
=
list
(
row
)
account_id
=
listrow
.
pop
()
if
not
unaffected_earnings_line
:
account
=
self
.
env
[
'
account.account
'
].
browse
(
account_id
)
if
account
.
user_type_id
.
id
==
self
.
env
.
ref
(
'
account.data_unaffected_earnings
'
).
id
:
#add the benefit/loss of previous fiscal year to the first unaffected earnings account found.
unaffected_earnings_line
=
True
current_amount
=
float
(
listrow
[
11
].
replace
(
'
,
'
,
'
.
'
))
-
float
(
listrow
[
12
].
replace
(
'
,
'
,
'
.
'
))
unaffected_earnings_amount
=
float
(
unaffected_earnings_results
[
11
].
replace
(
'
,
'
,
'
.
'
))
-
float
(
unaffected_earnings_results
[
12
].
replace
(
'
,
'
,
'
.
'
))
listrow_amount
=
current_amount
+
unaffected_earnings_amount
if
listrow_amount
>
0
:
listrow
[
11
]
=
str
(
listrow_amount
)
listrow
[
12
]
=
'
0.00
'
else
:
listrow
[
11
]
=
'
0.00
'
listrow
[
12
]
=
str
(
listrow_amount
)
w
.
writerow
([
s
.
encode
(
"
utf-8
"
)
for
s
in
listrow
])
#if the unaffected earnings account wasn't in the selection yet: add it manually
if
not
unaffected_earnings_line
and
unaffected_earnings_results
:
#search an unaffected earnings account
unaffected_earnings_account
=
self
.
env
[
'
account.account
'
].
search
([(
'
user_type_id
'
,
'
=
'
,
self
.
env
.
ref
(
'
account.data_unaffected_earnings
'
).
id
)],
limit
=
1
)
if
unaffected_earnings_account
:
unaffected_earnings_results
[
4
]
=
unaffected_earnings_account
.
code
unaffected_earnings_results
[
5
]
=
unaffected_earnings_account
.
name
w
.
writerow
([
s
.
encode
(
"
utf-8
"
)
for
s
in
unaffected_earnings_results
])
# LINES
sql_query
=
'''
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment