From bf7be18166ddb4f253d1470bf2fcb5c8edb6c778 Mon Sep 17 00:00:00 2001 From: Alnus Tmp Date: Wed, 24 Mar 2021 19:00:07 -0500 Subject: [PATCH] =?UTF-8?q?Informe=20de=20cuentas=20anal=C3=ADticas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 15 + analytic_account.fods | 1347 ++++++++++++++++++++ analytic_account_report.py | 183 +++ analytic_account_report.xml | 26 + locale/es.po | 47 +- tryton.cfg | 1 + view/print_analytic_account_start_form.xml | 21 + 7 files changed, 1639 insertions(+), 1 deletion(-) create mode 100644 analytic_account.fods create mode 100644 analytic_account_report.py create mode 100644 analytic_account_report.xml create mode 100755 view/print_analytic_account_start_form.xml diff --git a/__init__.py b/__init__.py index f01a07f..99eda81 100644 --- a/__init__.py +++ b/__init__.py @@ -1 +1,16 @@ from trytond.pool import Pool + +from . import analytic_account_report + +def register(): + Pool.register( + analytic_account_report.PrintAnalyticAccountStart, + module='analytic_account_co',type_='model') + + Pool.register( + analytic_account_report.PrintAnalyticAccount, + module='analytic_account_co',type_='wizard') + + Pool.register( + analytic_account_report.AnalyticAccount, + module='analytic_account_co',type_='report') diff --git a/analytic_account.fods b/analytic_account.fods new file mode 100644 index 0000000..e991852 --- /dev/null +++ b/analytic_account.fods @@ -0,0 +1,1347 @@ + + + + 2012-09-27T06:56:34P0D1LibreOffice/7.1.1.2$Linux_X86_64 LibreOffice_project/10$Build-2 + + + 0 + 0 + 18915 + 23491 + + + view1 + + + 3 + 4 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 160 + 120 + false + false + + + Informe + 1609 + 0 + 160 + 120 + false + true + true + true + 12632256 + true + true + true + true + false + false + false + 1000 + 1000 + 1 + 1 + true + false + + + + + true + true + true + false + 1000 + true + 1 + 12632256 + true + true + true + owH+/0dlbmVyaWMgUHJpbnRlcgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU0dFTlBSVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWAAMAxAAAAAAAAAAIAFZUAAAkbQAASm9iRGF0YSAxCnByaW50ZXI9R2VuZXJpYyBQcmludGVyCm9yaWVudGF0aW9uPVBvcnRyYWl0CmNvcGllcz0xCmNvbGxhdGU9ZmFsc2UKbWFyZ2luZGFqdXN0bWVudD0wLDAsMCwwCmNvbG9yZGVwdGg9MjQKcHNsZXZlbD0wCnBkZmRldmljZT0xCmNvbG9yZGV2aWNlPTAKUFBEQ29udGV4RGF0YQpEdXBsZXg6Tm9uZQBQYWdlU2l6ZTpMZXR0ZXIAABIAQ09NUEFUX0RVUExFWF9NT0RFDwBEdXBsZXhNb2RlOjpPZmY= + 1000 + 0 + false + true + false + 1 + true + + + en + US + + + + + + es + CO + + + + + + false + true + false + true + true + Generic Printer + false + 0 + 3 + true + false + false + false + true + false + true + + + Hoja1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $ + + + + + ( + $ + + ) + + + + + + + + + + - + + + + + + + + + + + - + + + + + + + + + - + + + + + ( + + ) + + + + + + ( + + ) + + + + $ + + + + + - + $ + + + + + $ + + + + + - + $ + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + / + + / + + + + + + + + + + $ + + + + + ( + $ + + ) + + + + + + + + / + + / + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ??? + + + + Página 1 + + + + + + + ???(???) + + + 00/00/0000, 00:00:00 + + + + + Página 1/ 99 + + + + + + + + + + + + + + + + + + + + PLAN DE CUENTAS ANALÍTICAS + + + + + + + + + + + company.rec_name + + + + + + + + + + NIT company.party.identifiers and company.party.identifiers[0].code + + + + + + + + + + + FECHA INICIAL: + + format_date(start_date, company.party.lang) + + + FECHA FINAL: + + format_date(end_date, company.party.lang) + + + + + + + + + + + + + if test="account_move" + + + + + + + + + COD. + + + CUENTA/TERCERO + + + DÉBITO + + + CRÉDITO + + + SALDO + + NÚMEROASIENTO + + FECHAASIENTO + + + + + + + + + /if + + + + + + + + + + if test="account_move == False" + + + + + + + + + + + COD. + + + CUENTA + + + DÉBITO + + + CRÉDITO + + + SALDO + + + + + + + + + /if + + + + + + + + + + root[0].code + + root[0].name + + + $0,00 + + total + + + + + + + + + for each='analytic_account, accounts in record.items()' + + + + + + + + if test="accounts[analytic_account][3] > 0 or accounts[analytic_account][3] < 0 or without_balance" + + + + + + + + + + + + + + + analytic_account + + accounts[analytic_account][0].name + + accounts[analytic_account][1] + + accounts[analytic_account][2] + + -accounts[analytic_account][3] + + + + + + /if + + + + + + + + + for each='account in accounts.values()' + + + + + + + + if test="(account[3] > 0 or account[3] < 0 or without_balance) and account[0].parent.parent" + + + + + + + + account[0].code + + account[0].name + + account[1] + + account[2] + + -account[3] + + + + + + + + /if + + + + + + + + + + if test="account[0].type == 'normal' and len(account) == 5 and detailed" + + + + + + + + + + + + + for each='key, line in account[4].items()' + + + + + + + + + + + + key + + line[0] + + line[1] + + -line[2] + + + + + + + + + + + if test="len(line[3]) > 0 and account_move" + + + + + + + + + + + + + + for each='move in line[3]' + + + + + + + + + + + + + if test="move.party" + + + + + + + + + + + move.party.identifiers[0].code + + move.party.name + + move.debit + + -move.credit + + move.debit-move.credit + + move.move.number + + move.date + + + + + + + + + /if + + + + + + + + + + + + if test="move.party == None" + + + + + + + + + + + + move.debit + + -move.credit + + move.debit-move.credit + + move.move.number + + move.date + + + + + + + + + /if + + + + + + + + + + + /for + + + + + + + + + + + + /if + + + + + + + + + + + + /for + + + + + + + + + + + + /if + + + + + + + + + + + + /for + + + + + + + + /for + + + + + + + + + + + + + + + Impresión: format_date(datetime.date.today(), company.party.lang) + + + + + + + + + + + + + + + + + + REPRESENTANTE LEGAL + + + + CONTADOR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/analytic_account_report.py b/analytic_account_report.py new file mode 100644 index 0000000..0044058 --- /dev/null +++ b/analytic_account_report.py @@ -0,0 +1,183 @@ +# The COPYRIGHT file at the top level of this repository contains the full +# copyright notices and license terms. +from trytond.model import ModelView, fields +from trytond.wizard import Wizard, StateView, Button, StateReport +from trytond.pyson import Eval +from trytond.transaction import Transaction +from trytond.report import Report +from trytond.pool import Pool +import datetime + + +def compute_report(data): + pool = Pool() + Analytic_Account = pool.get('analytic_account.account') + Analytic_Account_Line = pool.get('analytic_account.line') + + res = {} + ctx = { + 'company': data['company'] + } + + def is_child(child, parent): + if child in parent.childs: + return True + else: + for parent_child in parent.childs: + if child in parent_child.childs: + return True + else: + if is_child(child,parent_child): + return True + return False + + with Transaction().set_context(ctx): + analytic_accounts_filter = Analytic_Account.search([('parent', '!=', None), + ('parent.type', '=','root'), + ('id', 'in', data['analytic_account']), + ], order=[('code', 'ASC')]) + + analytic_accounts = Analytic_Account.search([],order=[('code', 'ASC')]) + aas = {} + total = 0 + + for aaf in analytic_accounts_filter: + aas[aaf.code] = {} + aas[aaf.code][aaf.code] = [aaf,0,0,0,False] + + for aa in analytic_accounts: + record = [] + if is_child(aa, aaf): + record.append(aa) + record = record + [0,0,0] + if aa.type == 'normal': + aa_line = Analytic_Account_Line.search([ + ('account', '=', aa), + ('date', '>=', data['start_date']), + ('date', '<=', data['end_date']), + ], order=[('date', 'ASC')]) + lines = {} + + for a_l in aa_line: + if a_l.move_line.account.code in lines: + lines[a_l.move_line.account.code][1] += a_l.debit + lines[a_l.move_line.account.code][2] += a_l.credit + lines[a_l.move_line.account.code][3].append(a_l.move_line) + else: + move_line = [a_l.move_line] + lines[a_l.move_line.account.code] = [ + a_l.move_line.account.name, + a_l.debit, + a_l.credit, + move_line + ] + record[1] += a_l.debit + record[2] += a_l.credit + record[3] += a_l.debit - a_l.credit + total += a_l.debit - a_l.credit + def is_parent(parent, account, debit, credit): + if parent and account and parent.code in aas[aaf.code]: + aas[aaf.code][parent.code][3] += debit - credit + if parent.parent and parent.parent.code: + is_parent(parent.parent, account, debit, credit) + + is_parent(aa.parent, aa, a_l.debit, a_l.credit) + record.append(lines) + aas[aaf.code][aa.code] = record + res['record'] = aas + res['total'] = -total + + res['root'] = Analytic_Account.search([ + ('id', '=', data['analytic_account_root']) + ]) + res['start_date'] = data['start_date'] + res['end_date'] = data['end_date'] + + res['detailed'] = data['detailed'] + res['account_move'] = data['account_move'] + res['without_balance'] = data['without_balance'] + + return res + + +class PrintAnalyticAccountStart(ModelView): + 'Print Analytic Account' + __name__ = 'analytic_account_co.print_analytic_account.start' + company = fields.Many2One('company.company', 'Company', required=True) + start_date = fields.Date('Start Date', required=True) + end_date = fields.Date('End Date', required=True) + detailed = fields.Boolean('Detailed') + account_move = fields.Boolean('Account Move', + states={'invisible': ~Eval('detailed'), + }, + depends=['detailed'], + help='Show account move detailed') + without_balance = fields.Boolean('Without Balance') + analytic_account_root = fields.Many2One('analytic_account.account', + 'Analytic Account Root', required=True, + domain=[('type', '=', 'root')] + ) + analytic_account = fields.Many2Many('analytic_account.account', + None, None, 'Analytic Account', + domain=[('parent', '=', Eval('analytic_account_root')), + ('type', '!=', 'root')], + depends=['analytic_account_root'] + ) + + @staticmethod + def default_company(): + return Transaction().context.get('company') + + +class PrintAnalyticAccount(Wizard): + 'Print Analytic Accoount' + __name__ = 'analytic_account_co.print_analytic_account' + start = StateView('analytic_account_co.print_analytic_account.start', + 'analytic_account_co.print_analytic_account_start_view_form', [ + Button('Cancel', 'end', 'tryton-cancel'), + Button('Print', 'print_', 'tryton-print', default=True), + ]) + print_ = StateReport('analytic_account_co.analytic_account') + + def do_print_(self, action): + Analytic_Account = Pool().get('analytic_account.account') + + + if self.start.analytic_account: + analytic_account_ids = [ac.id for ac in self.start.analytic_account] + else: + analytic_account = Analytic_Account.search([('parent.type', '=', 'root'), + ('parent', '=', self.start.analytic_account_root)]) + analytic_account_ids = [ac.id for ac in analytic_account] + + data = { + 'start_date': self.start.start_date, + 'end_date': self.start.end_date, + 'company': self.start.company.id, + 'detailed': self.start.detailed, + 'account_move': self.start.account_move, + 'without_balance': self.start.without_balance, + 'analytic_account_root': self.start.analytic_account_root.id, + 'analytic_account': analytic_account_ids + } + return action, data + + def transition_print_(self): + return 'end' + + +class AnalyticAccount(Report): + __name__ = 'analytic_account_co.analytic_account' + + @classmethod + def get_context(cls, records, data): + report_context = super(AnalyticAccount, cls).get_context(records, data) + pool = Pool() + Company = pool.get('company.company') + company = Company(data['company']) + + res = compute_report(data) + + report_context.update(res) + report_context['company'] = company + return report_context diff --git a/analytic_account_report.xml b/analytic_account_report.xml new file mode 100644 index 0000000..f6554f5 --- /dev/null +++ b/analytic_account_report.xml @@ -0,0 +1,26 @@ + + + + + + + Analytic Account + + analytic_account_co.analytic_account + analytic_account_co/analytic_account.fods + ods + + + analytic_account_co.print_analytic_account.start + form + print_analytic_account_start_form + + + Analytic Account + analytic_account_co.print_analytic_account + + + + + diff --git a/locale/es.po b/locale/es.po index 3ad1542..a196a27 100644 --- a/locale/es.po +++ b/locale/es.po @@ -1,3 +1,48 @@ +# msgctxt "model:ir.ui.menu,name:menu_analytic_account_line" msgid "Analytic Lines" -msgstr "Líneas Analíticas" \ No newline at end of file +msgstr "Líneas Analíticas" + +msgctxt "field:analytic_account_co.print_analytic_account.start,start_date:" +msgid "Start Date" +msgstr "Fecha Inicial" + +msgctxt "field:analytic_account_co.print_analytic_account.start,end_date:" +msgid "End Date" +msgstr "Fecha Final" + +msgctxt "field:analytic_account_co.print_analytic_account.start,detailed:" +msgid "Detailed" +msgstr "Detalle" + +msgctxt "field:analytic_account_co.print_analytic_account.start,company:" +msgid "Company" +msgstr "Compañia" + +msgctxt "field:analytic_account_co.print_analytic_account.start,without_balance:" +msgid "Without Balance" +msgstr "Sin Saldo" + +msgctxt "field:analytic_account_co.print_analytic_account.start,account_move:" +msgid "Account Move" +msgstr "Movimiento de cuentas" + +msgctxt "field:analytic_account_co.print_analytic_account.start,analytic_account_root:" +msgid "Analytic Account Root" +msgstr "Cuenta Analítica Raíz" + +msgctxt "field:analytic_account_co.print_analytic_account.start,analytic_account:" +msgid "Analytic Account" +msgstr "Cuenta Analítica" + +msgctxt "model:ir.action,name:report_analytic_account" +msgid "Analytic Account" +msgstr "Cuentas Analíticas" + +msgctxt "model:ir.action,name:wizard_print_analytic_account" +msgid "Analytic Account" +msgstr "Cuentas Analíticas" + +msgctxt "model:ir.ui.menu,name:menu_print_analytic_account" +msgid "Analityc Account" +msgstr "Cuentas Analíticas" \ No newline at end of file diff --git a/tryton.cfg b/tryton.cfg index 6b43de1..656d9c3 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -5,4 +5,5 @@ depends= res analytic_account xml: + analytic_account_report.xml analytic_account_line.xml \ No newline at end of file diff --git a/view/print_analytic_account_start_form.xml b/view/print_analytic_account_start_form.xml new file mode 100755 index 0000000..be81803 --- /dev/null +++ b/view/print_analytic_account_start_form.xml @@ -0,0 +1,21 @@ + + +
+