unaffected eranings accounts movements in journal ledger
This commit is contained in:
parent
f0dd16ab38
commit
168a29dec7
@ -21,8 +21,12 @@ It is based on modules:
|
||||
### General Ledger
|
||||
- Displays unaffected earnings
|
||||
|
||||
### Journal Ledger
|
||||
- Operations on unaffected earnings account displayed as 110 or 119
|
||||
|
||||
## ChangeLog
|
||||
|
||||
- v16.0.0.0.6: unaffected earnings movements in journal ledger
|
||||
- v16.0.0.0.5:
|
||||
- remove year's earning in trial balance
|
||||
- remove year's earning in general ledger
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
'name': "Gn Financial Report",
|
||||
'version': '16.0.0.0.4',
|
||||
'version': '16.0.0.0.6',
|
||||
'author': 'Garage Numérique',
|
||||
'category': 'Accounting',
|
||||
'description': """
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import trial_balance, general_ledger
|
||||
from . import trial_balance, general_ledger, journal_ledger
|
||||
132
gn_financial_report/report/journal_ledger.py
Normal file
132
gn_financial_report/report/journal_ledger.py
Normal file
@ -0,0 +1,132 @@
|
||||
# Copyright 2019-20 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
import itertools
|
||||
import operator
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
class JournalLedgerReport(models.AbstractModel):
|
||||
_inherit = "report.account_financial_report.journal_ledger"
|
||||
|
||||
def _get_account_data(self, accounts):
|
||||
data = {}
|
||||
# Modified part by GN (loss and profit account definition)
|
||||
unaffected_loss_account = self.env['account.account'].search([('code', '=', '119000')])
|
||||
if unaffected_loss_account and len(unaffected_loss_account) == 1:
|
||||
accounts |= unaffected_loss_account[0]
|
||||
|
||||
unaffected_profit_account = self.env['account.account'].search([('code', '=', '110000')])
|
||||
if unaffected_profit_account and len(unaffected_profit_account) == 1:
|
||||
accounts |= unaffected_profit_account[0]
|
||||
# End of modified part by GN
|
||||
|
||||
for account in accounts:
|
||||
data[account.id] = self._get_account_id_data(account)
|
||||
return data
|
||||
|
||||
def _get_report_values(self, docids, data):
|
||||
wizard_id = data["wizard_id"]
|
||||
wizard = self.env["journal.ledger.report.wizard"].browse(wizard_id)
|
||||
company = self.env["res.company"].browse(data["company_id"])
|
||||
journal_ids = data["journal_ids"]
|
||||
journal_ledgers_data = self._get_journal_ledgers(wizard, journal_ids, company)
|
||||
move_ids, moves_data, move_ids_data = self._get_moves(wizard, journal_ids)
|
||||
journal_moves_data = {}
|
||||
for key, items in itertools.groupby(
|
||||
moves_data, operator.itemgetter("journal_id")
|
||||
):
|
||||
if key not in journal_moves_data.keys():
|
||||
journal_moves_data[key] = []
|
||||
journal_moves_data[key] += list(items)
|
||||
move_lines_data = (
|
||||
account_ids_data
|
||||
) = (
|
||||
partner_ids_data
|
||||
) = currency_ids_data = tax_line_ids_data = move_line_ids_taxes_data = {}
|
||||
if move_ids:
|
||||
move_lines = self._get_move_lines(move_ids, wizard, journal_ids)
|
||||
move_lines_data = move_lines[1]
|
||||
account_ids_data = move_lines[2]
|
||||
partner_ids_data = move_lines[3]
|
||||
currency_ids_data = move_lines[4]
|
||||
tax_line_ids_data = move_lines[5]
|
||||
|
||||
# Loss and profit account definition and replacement (Modified part from original OCA module by GN)
|
||||
unaffected_earning_account = self.env['account.account'].search([('account_type', '=', 'equity_unaffected')])
|
||||
unaffected_earning_id = False
|
||||
if unaffected_earning_account and len(unaffected_earning_account) == 1:
|
||||
unaffected_earning_id = unaffected_earning_account[0].id
|
||||
|
||||
unaffected_loss_account = self.env['account.account'].search([('code', '=', '119000')])
|
||||
unaffected_loss_id = False
|
||||
if unaffected_loss_account and len(unaffected_loss_account) == 1:
|
||||
unaffected_loss_id = unaffected_loss_account[0].id
|
||||
|
||||
unaffected_profit_account = self.env['account.account'].search([('code', '=', '110000')])
|
||||
unaffected_profit_id = False
|
||||
if unaffected_profit_account and len(unaffected_profit_account) == 1:
|
||||
unaffected_profit_id = unaffected_profit_account[0].id
|
||||
# End of loss and profit account definition by GN
|
||||
|
||||
for move_data in moves_data:
|
||||
move_id = move_data["move_id"]
|
||||
move_data["report_move_lines"] = []
|
||||
if move_id in move_lines_data.keys():
|
||||
|
||||
# This part is modified by GN
|
||||
for line in move_lines_data[move_id]:
|
||||
if unaffected_earning_id and line['account_id'] == unaffected_earning_id:
|
||||
if line['debit'] > 0:
|
||||
line['account_id'] = unaffected_profit_id
|
||||
elif line['credit'] >0:
|
||||
line['account_id'] = unaffected_profit_id
|
||||
# End of modification by GN
|
||||
|
||||
move_data["report_move_lines"] += move_lines_data[move_id]
|
||||
journals_taxes_data = {}
|
||||
if moves_data:
|
||||
journals_taxes_data = self._get_journal_tax_lines(wizard, moves_data)
|
||||
for journal_ledger_data in journal_ledgers_data:
|
||||
journal_id = journal_ledger_data["id"]
|
||||
journal_ledger_data["tax_lines"] = journals_taxes_data.get(journal_id, [])
|
||||
journal_totals = {}
|
||||
for move_id in move_lines_data.keys():
|
||||
for move_line_data in move_lines_data[move_id]:
|
||||
journal_id = move_line_data["journal_id"]
|
||||
if journal_id not in journal_totals.keys():
|
||||
journal_totals[journal_id] = {"debit": 0.0, "credit": 0.0}
|
||||
for item in ["debit", "credit"]:
|
||||
journal_totals[journal_id][item] += move_line_data[item]
|
||||
for journal_ledger_data in journal_ledgers_data:
|
||||
journal_id = journal_ledger_data["id"]
|
||||
if journal_id in journal_moves_data.keys():
|
||||
journal_ledger_data["report_moves"] = journal_moves_data[journal_id]
|
||||
else:
|
||||
journal_ledger_data["report_moves"] = []
|
||||
if journal_id in journal_totals.keys():
|
||||
for item in ["debit", "credit"]:
|
||||
journal_ledger_data[item] += journal_totals[journal_id][item]
|
||||
return {
|
||||
"doc_ids": [wizard_id],
|
||||
"doc_model": "journal.ledger.report.wizard",
|
||||
"docs": self.env["journal.ledger.report.wizard"].browse(wizard_id),
|
||||
"group_option": data["group_option"],
|
||||
"foreign_currency": data["foreign_currency"],
|
||||
"with_account_name": data["with_account_name"],
|
||||
"company_name": company.display_name,
|
||||
"currency_name": company.currency_id.name,
|
||||
"date_from": data["date_from"],
|
||||
"date_to": data["date_to"],
|
||||
"move_target": data["move_target"],
|
||||
"with_auto_sequence": data["with_auto_sequence"],
|
||||
"account_ids_data": account_ids_data,
|
||||
"partner_ids_data": partner_ids_data,
|
||||
"currency_ids_data": currency_ids_data,
|
||||
"move_ids_data": move_ids_data,
|
||||
"tax_line_data": tax_line_ids_data,
|
||||
"move_line_ids_taxes_data": move_line_ids_taxes_data,
|
||||
"Journal_Ledgers": journal_ledgers_data,
|
||||
"Moves": moves_data,
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user