add Accounting Audit Report

This commit is contained in:
Wilson Gomez 2023-08-04 15:38:41 -05:00
parent 7677db7b7f
commit 8e1abeacae
7 changed files with 1247 additions and 82 deletions

View File

@ -14,6 +14,7 @@ from . import invoice_authorization
from . import asset
from . import payment_term
from . import user
from . import audit
def register():
@ -73,6 +74,7 @@ def register():
invoice.InvoiceUpdateStart,
invoice.InvoiceReport,
payment_term.PaymentTerm,
audit.AuditReportStart,
module='account_col', type_='model')
Pool.register(
move.AccountMoveSheet,
@ -90,6 +92,7 @@ def register():
account.IncomeStatementCOLGAAP,
account.CashflowStatement,
invoice.MovesInvoicesReport,
audit.AuditReport,
# account.BalanceSheetDetail,
module='account_col', type_='report')
Pool.register(
@ -115,4 +118,5 @@ def register():
invoice.InvoiceUpdate,
party.PartyFix,
user.UserLoginAttempRemove,
audit.AuditReportWizard,
module='account_col', type_='wizard')

Binary file not shown.

146
audit.py Normal file
View File

@ -0,0 +1,146 @@
from trytond.transaction import Transaction
from trytond.pool import Pool, PoolMeta
from trytond.model import ModelView, ModelSQL, fields
from trytond.wizard import Wizard, StateView, Button, StateReport, StateTransition
from dateutil.relativedelta import relativedelta
from trytond.modules.company import CompanyReport
from datetime import timedelta
from trytond.pyson import Eval, Bool
from trytond.report import Report
class AuditReportStart(ModelView):
'Audit Report Start'
__name__ = 'account_col.audit_report_start'
company = fields.Many2One('company.company', 'Company')
start_date = fields.Date('Start Date', states={'required': True})
end_date = fields.Date('End Date', states={'required': True})
@staticmethod
def default_company():
return Transaction().context.get('company')
class AuditReportWizard(Wizard):
'Audit Report Wizard'
__name__ = 'account_col.audit_report_wizard'
start = StateView('account_col.audit_report_start',
'account_col.print_audit_report_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Print', 'print_', 'tryton-print', default=True),
])
print_ = StateReport('account_col.audit_report')
def do_print_(self, action):
data = {
'company': self.start.company.id,
'company_name': self.start.company.rec_name,
'start_date': self.start.start_date,
'end_date': self.start.end_date,
'time_now': self.start.company.time_now()
}
return action, data
def transition_print_(self):
return 'end'
class AuditReport(CompanyReport):
'Audit Report'
__name__ = 'account_col.audit_report'
@classmethod
def get_context(cls, records, header, data):
report_context = super().get_context(records, header, data)
pool = Pool()
start_date = data['start_date']
end_date = data['end_date']
Liquidation = pool.get('staff.liquidation')
Payroll = pool.get('staff.payroll')
Voucher = pool.get('account.voucher')
Note = pool.get('account.note')
Invoice = pool.get('account.invoice')
Move = pool.get('account.move')
ShipmentInternal = pool.get('stock.shipment.internal')
Accounts = pool.get('account.account')
today = pool.get('ir.date').today()
cursor = Transaction().connection.cursor()
query = """SELECT m.number, c.code, c.id, c.name FROM account_move_line as ml
join account_move as m on ml.move=m.id
join account_account as c on ml.account=c.id where c.type is null"""
cursor.execute(query)
columns = list(cursor.description)
result = cursor.fetchall()
accounts = {}
for row in result:
row_dict = {}
id_ = None
for i, col in enumerate(columns):
if col.name == 'id':
id_ = row[i]
row_dict[col.name] = row[i]
if id_ in accounts.keys():
continue
accounts[id_] = row_dict
liquidations = Liquidation.search_read([
('state', '!=', 'posted'),
('liquidation_date', '>=', start_date),
('liquidation_date', '>=', end_date),
], fields_names=['number', 'liquidation_date', 'employee.rec_name'])
payrolls = Payroll.search_read([
('state', '!=', 'posted'),
('date_effective', '>=', start_date),
('date_effective', '>=', end_date),
], fields_names=['number', 'date_effective', 'employee.rec_name'])
notes = Note.search_read([
('state', '!=', 'posted'),
('date', '>=', start_date),
('date', '>=', end_date),
], fields_names=['number', 'date', 'description'])
vouchers = Voucher.search_read([
('state', '!=', 'posted'),
('date', '>=', start_date),
('date', '>=', end_date),
], fields_names=['number', 'date', 'party.name'])
invoices = Invoice.search_read([
('state', 'in', ['posted', 'paid']),
('invoice_date', '>=', start_date),
('invoice_date', '>=', end_date),
], fields_names=['number', 'invoice_date', 'party.name'])
moves = Move.search_read([
('state', '!=', 'posted'),
('date', '>=', start_date),
('date', '>=', end_date),
], fields_names=['number', 'date', 'origin.rec_name'])
moves_future = Move.search_read([
('date', '>', today),
], fields_names=['number', 'date', 'origin.rec_name'])
shipments = []
if 'account_move' in ShipmentInternal._fields:
shipments = ShipmentInternal.search_read([
('account_move', '=', None),
('date_effective', '>=', start_date),
('date_effective', '>=', end_date),
], fields_names=['number', 'effective_date'])
report_context['liquidations'] = liquidations
report_context['payrolls'] = payrolls
report_context['notes'] = notes
report_context['invoices'] = invoices
report_context['moves'] = moves
report_context['vouchers'] = vouchers
report_context['shipments'] = shipments
report_context['accounts'] = list(accounts.values())
report_context['moves_future'] = moves_future
return report_context

29
audit.xml Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.ui.view" id="print_audit_report_start_view_form">
<field name="model">account_col.audit_report_start</field>
<field name="type">form</field>
<field name="name">audit_report_start_form</field>
</record>
<record model="ir.action.wizard" id="wizard_audit_report">
<field name="name">Print Accounting Audit Report</field>
<field name="wiz_name">account_col.audit_report_wizard</field>
</record>
<record model="ir.action.report" id="report_accounting_audit">
<field name="name">Accounting Audit Report </field>
<field name="model"></field>
<field name="report_name">account_col.audit_report</field>
<field name="report">account_col/account_audit.fods</field>
<field name="template_extension">ods</field>
<field name="translatable">False</field>
</record>
<menuitem parent="account.menu_reporting" action="wizard_audit_report" sequence="250"
id="menu_accounting_audit_report" icon="tryton-print"/>
</data>
</tryton>

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
[tryton]
version=6.0.12
version=6.0.13
depends:
ir
res
@ -28,3 +28,4 @@ xml:
payment_term.xml
message.xml
user.xml
audit.xml

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
<label name="company"/>
<field name="company" widget="selection"/>
<label name="start_date"/>
<field name="start_date"/>
<label name="end_date"/>
<field name="end_date" />
</form>