add reports colgaap account
This commit is contained in:
parent
46d9407822
commit
89802f6a91
|
@ -3,6 +3,7 @@
|
|||
from trytond.pool import Pool
|
||||
import company
|
||||
import sale
|
||||
import account
|
||||
|
||||
|
||||
def register():
|
||||
|
@ -11,10 +12,16 @@ def register():
|
|||
company.ConnectionCompanies,
|
||||
sale.Sale,
|
||||
sale.SaleIncomeDailyStart,
|
||||
account.PrintBalanceSheetCOLGAAPStart,
|
||||
account.PrintIncomeStatementCOLGAAPStart,
|
||||
module='syncronize_companies', type_='model')
|
||||
Pool.register(
|
||||
sale.SaleIncomeDailyReport,
|
||||
account.BalanceSheetCOLGAAP,
|
||||
account.IncomeStatementCOLGAAP,
|
||||
module='syncronize_companies', type_='report')
|
||||
Pool.register(
|
||||
sale.SaleIncomeDaily,
|
||||
account.PrintBalanceSheetCOLGAAP,
|
||||
account.PrintIncomeStatementCOLGAAP,
|
||||
module='syncronize_companies', type_='wizard')
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
import time
|
||||
from decimal import Decimal
|
||||
import requests
|
||||
import simplejson as json
|
||||
from datetime import datetime, date
|
||||
from trytond.model import ModelView, fields
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pyson import Bool, Eval, Or, Not
|
||||
from trytond.wizard import (
|
||||
Wizard, StateView, StateAction, StateReport, StateTransition, Button)
|
||||
from trytond.report import Report
|
||||
|
||||
__all__ = [
|
||||
'PrintBalanceSheetCOLGAAPStart', 'PrintBalanceSheetCOLGAAP',
|
||||
'BalanceSheetCOLGAAP', 'PrintIncomeStatementCOLGAAPStart',
|
||||
'PrintIncomeStatementCOLGAAP', 'IncomeStatementCOLGAAP'
|
||||
]
|
||||
|
||||
_ZERO = Decimal('0.00')
|
||||
|
||||
|
||||
class PrintIncomeStatementCOLGAAPStart(metaclass=PoolMeta):
|
||||
__name__ = 'account_col.print_income_statement_colgaap.start'
|
||||
|
||||
sincronize = fields.Boolean('Syncronize')
|
||||
|
||||
|
||||
class PrintIncomeStatementCOLGAAP(metaclass=PoolMeta):
|
||||
__name__ = 'account_col.print_income_statement_colgaap'
|
||||
|
||||
def do_print_(self, action):
|
||||
action, data = super(PrintIncomeStatementCOLGAAP, self).do_print_(action)
|
||||
data['sincronize'] = self.start.sincronize
|
||||
return action, data
|
||||
|
||||
|
||||
class IncomeStatementCOLGAAP(metaclass=PoolMeta):
|
||||
__name__ = 'account_col.income_statement_colgaap'
|
||||
|
||||
@classmethod
|
||||
def get_context(cls, records, data):
|
||||
report_context = super(IncomeStatementCOLGAAP, cls).get_context(records, data)
|
||||
Company = Pool().get('company.company')
|
||||
company = Company(Transaction().context.get('company'))
|
||||
result = {}
|
||||
sync = data['sincronize']
|
||||
if sync:
|
||||
data['sincronize'] = [False]
|
||||
|
||||
args = {
|
||||
'records': records,
|
||||
'data': data,
|
||||
}
|
||||
for sync in company.connection_companies:
|
||||
api_ = 'http://' + sync.api_connection + '/'+ sync.database
|
||||
route = api_ + '/' + 'report_context'
|
||||
data_ = json.dumps({
|
||||
'database': sync.database,
|
||||
'report_name': 'account_col.income_statement_colgaap',
|
||||
'args': args,
|
||||
})
|
||||
res = requests.get(route, data=data_)
|
||||
result = res.json()
|
||||
obj_ = dict(sorted(result['records'].items()))
|
||||
report_context['records'].extend(obj_.values())
|
||||
report_context['global_result'] += Decimal(result['global_result'])
|
||||
return report_context
|
||||
|
||||
|
||||
class PrintBalanceSheetCOLGAAPStart(metaclass=PoolMeta):
|
||||
__name__ = 'account_col.print_balance_sheet_colgaap.start'
|
||||
|
||||
sincronize = fields.Boolean('Syncronize')
|
||||
|
||||
|
||||
class PrintBalanceSheetCOLGAAP(metaclass=PoolMeta):
|
||||
__name__ = 'account_col.print_balance_sheet_colgaap'
|
||||
|
||||
def do_print_(self, action):
|
||||
action, data = super(PrintBalanceSheetCOLGAAP, self).do_print_(action)
|
||||
data['sincronize'] = self.start.sincronize
|
||||
return action, data
|
||||
|
||||
|
||||
class BalanceSheetCOLGAAP(metaclass=PoolMeta):
|
||||
__name__ = 'account_col.balance_sheet_colgaap'
|
||||
|
||||
@classmethod
|
||||
def get_context(cls, records, data):
|
||||
report_context = super(BalanceSheetCOLGAAP, cls).get_context(records, data)
|
||||
Company = Pool().get('company.company')
|
||||
company = Company(Transaction().context.get('company'))
|
||||
result = {}
|
||||
sync = data['sincronize']
|
||||
if sync:
|
||||
data['sincronize'] = [False]
|
||||
|
||||
args = {
|
||||
'records': records,
|
||||
'data': data,
|
||||
}
|
||||
for sync in company.connection_companies:
|
||||
api_ = 'http://' + sync.api_connection + '/'+ sync.database
|
||||
route = api_ + '/' + 'report_context'
|
||||
data_ = json.dumps({
|
||||
'database': sync.database,
|
||||
'report_name': 'account_col.balance_sheet_colgaap',
|
||||
'args': args,
|
||||
})
|
||||
res = requests.get(route, data=data_)
|
||||
result = res.json()
|
||||
obj_ = dict(sorted(result['records'].items()))
|
||||
report_context['records'].extend(obj_.values())
|
||||
report_context['global_result'] += Decimal(result['global_result'])
|
||||
return report_context
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<tryton>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="print_balance_sheet_colgaap_start_view_form">
|
||||
<field name="model">account_col.print_balance_sheet_colgaap.start</field>
|
||||
<field name="inherit" ref="account_col.print_balance_sheet_colgaap_start_view_form"/>
|
||||
<field name="name">print_balance_sheet_colgaap_start_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="print_income_statement_colgaap_start_view_form">
|
||||
<field name="model">account_col.print_income_statement_colgaap.start</field>
|
||||
<field name="inherit" ref="account_col.print_income_statement_colgaap_start_view_form"/>
|
||||
<field name="name">print_income_statement_colgaap_start_form</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
||||
</tryton>
|
208
sale.py
208
sale.py
|
@ -24,200 +24,12 @@ _ZERO = Decimal('0.00')
|
|||
class Sale(metaclass=PoolMeta):
|
||||
__name__ = 'sale.sale'
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_records_income_daily_report(cls, args, ctx):
|
||||
report_context = {}
|
||||
pool = Pool()
|
||||
Report = pool._pool['TODOREPUESTOS']['report']['sale_pos.report_sale_detailed']
|
||||
# Report = pool._pool['TODOREPUESTOS']['report']['sale_pos.sale_income_daily_report']
|
||||
report_context = Report.get_context({}, args['data'])
|
||||
# data = args['data']
|
||||
# pool = Pool()
|
||||
# Invoice = pool.get('account.invoice')
|
||||
# Voucher = pool.get('account.voucher')
|
||||
# Sale = pool.get('sale.sale')
|
||||
# Company = pool.get('company.company')
|
||||
# company = Company(data['company'])
|
||||
# Statement = pool.get('account.statement')
|
||||
# Shop = pool.get('sale.shop')
|
||||
# User = pool.get('res.user')
|
||||
#
|
||||
# shop = Shop(data['shop'])
|
||||
# statements = Statement.search([
|
||||
# ('date', '=', data['date']),
|
||||
# # ('create_uid', '=', data['user']),
|
||||
# ])
|
||||
# user_id = Transaction().user
|
||||
# user = User(user_id)
|
||||
# records = []
|
||||
# advances = []
|
||||
# statements_ = []
|
||||
# total_advances = []
|
||||
# advances_cash = []
|
||||
# advances_electronic = []
|
||||
# total_statements = []
|
||||
# statement_cash = []
|
||||
# statement_electronic = []
|
||||
#
|
||||
# for statement in statements:
|
||||
# st_amount = sum(l.amount for l in statement.lines)
|
||||
# statements_.append({
|
||||
# 'id': statement.id,
|
||||
# 'sale_device': statement.sale_device.name,
|
||||
# 'journal': statement.journal.name,
|
||||
# 'turn': statement.turn,
|
||||
# 'total_amount': st_amount,
|
||||
# 'state': statement.state,
|
||||
# })
|
||||
# total_statements.append(st_amount)
|
||||
#
|
||||
# for l in statement.lines:
|
||||
# if l.statement.journal.kind == 'cash':
|
||||
# statement_cash.append(l.amount)
|
||||
# else:
|
||||
# statement_electronic.append(l.amount)
|
||||
#
|
||||
# sales = Sale.search([
|
||||
# ('sale_date', '=', data['date']),
|
||||
# ('vouchers', '!=', None),
|
||||
# ])
|
||||
# advances_voucher = []
|
||||
# voucher_ids = []
|
||||
# for sale in sales:
|
||||
# for v in sale.vouchers:
|
||||
# cash, electronic = 0,0
|
||||
# if v.payment_mode.payment_type == 'cash':
|
||||
# advances_cash.append(v.amount_to_pay)
|
||||
# cash = v.amount_to_pay
|
||||
# else:
|
||||
# electronic = v.amount_to_pay
|
||||
# advances_electronic.append(v.amount_to_pay)
|
||||
# voucher_ids.append(v.id)
|
||||
# advances_voucher.append(v.amount_to_pay)
|
||||
# advances.append({
|
||||
# 'number': v.number,
|
||||
# 'reference': sale.number,
|
||||
# 'party': v.party.name,
|
||||
# 'total_amount': v.amount_to_pay,
|
||||
# 'payment_mode': v.payment_mode.name,
|
||||
# 'cash': cash,
|
||||
# 'electronic': electronic,
|
||||
# })
|
||||
# total_advances.append(v.amount_to_pay)
|
||||
#
|
||||
# dom_vouchers = [
|
||||
# ('date', '=', data['date']),
|
||||
# ('state', '!=', 'draft')
|
||||
# ]
|
||||
# if voucher_ids:
|
||||
# dom_vouchers.append(
|
||||
# ('id', 'not in', voucher_ids)
|
||||
# )
|
||||
# vouchers = Voucher.search(dom_vouchers)
|
||||
#
|
||||
# for v in vouchers:
|
||||
# cash = 0
|
||||
# electronic = 0
|
||||
# for l in v.lines:
|
||||
# if v.payment_mode.payment_type == 'cash':
|
||||
# advances_cash.append(l.amount)
|
||||
# cash = l.amount
|
||||
# else:
|
||||
# advances_electronic.append(l.amount)
|
||||
# electronic = l.amount
|
||||
# advances_voucher.append(l.amount)
|
||||
# advances.append({
|
||||
# 'number': l.voucher.number,
|
||||
# 'reference': l.detail,
|
||||
# 'party': l.party.name if l.party else l.voucher.party.name,
|
||||
# 'total_amount': l.amount,
|
||||
# 'payment_mode': l.voucher.payment_mode.name,
|
||||
# 'cash': cash,
|
||||
# 'electronic': electronic,
|
||||
# })
|
||||
# total_advances.append(l.amount)
|
||||
#
|
||||
# dom_ = [
|
||||
# ('company', '=', data['company']),
|
||||
# ('invoice_date', '=', data['date']),
|
||||
# ('shop', '=', data['shop']),
|
||||
# ('number', '!=', None),
|
||||
# ('state', 'in', ['posted', 'paid', 'canceled']),
|
||||
# ]
|
||||
#
|
||||
# invoices = Invoice.search(dom_, order=[('number', 'ASC')])
|
||||
#
|
||||
# invoices_number = []
|
||||
# total_invoices_cash = []
|
||||
# total_invoices_electronic = []
|
||||
# total_invoices_credit = []
|
||||
# total_invoices_paid = []
|
||||
#
|
||||
# total_invoices_amount = []
|
||||
# for invoice in invoices:
|
||||
# invoices_number.append(invoice.number)
|
||||
# cash = 0
|
||||
# electronic = 0
|
||||
# credit = 0
|
||||
# total_invoices_amount.append(invoice.total_amount)
|
||||
# sale = invoice.sales[0]
|
||||
# if not sale.payments:
|
||||
# total_invoices_credit.append(invoice.amount_to_pay)
|
||||
# credit = invoice.amount_to_pay
|
||||
# else:
|
||||
# for p in sale.payments:
|
||||
# if p.statement.date == data['date']:
|
||||
# if p.statement.journal.kind == 'cash':
|
||||
# cash += p.amount
|
||||
# total_invoices_cash.append(p.amount)
|
||||
# else:
|
||||
# electronic += p.amount
|
||||
# total_invoices_electronic.append(p.amount)
|
||||
# total_invoices_paid.append(p.amount)
|
||||
#
|
||||
# inv = {
|
||||
# 'number': invoice.number,
|
||||
# 'reference': invoice.reference,
|
||||
# 'party': invoice.party.name,
|
||||
# 'total_amount': invoice.total_amount,
|
||||
# 'credit': credit,
|
||||
# 'cash': cash,
|
||||
# 'electronic': electronic,
|
||||
# 'paid': cash + electronic,
|
||||
# 'state': invoice.state_string,
|
||||
# }
|
||||
# records.append(inv)
|
||||
#
|
||||
# advances_cash_ = sum(advances_cash)
|
||||
# advances_electronic_ = sum(advances_electronic)
|
||||
# statement_cash_ = sum(statement_cash)
|
||||
# statement_electronic_ = sum(statement_electronic)
|
||||
#
|
||||
# report_context['records'] = records
|
||||
# report_context['advances'] = advances
|
||||
# report_context['statements'] = statements_
|
||||
# report_context['date'] = data['date']
|
||||
# report_context['company'] = company.party.name
|
||||
# report_context['shop'] = shop.name
|
||||
# report_context['user'] = user.name
|
||||
# report_context['print_date'] = datetime.now()
|
||||
# report_context['statement_cash'] = statement_cash_
|
||||
# report_context['statement_electronic'] = statement_electronic_
|
||||
# report_context['total_invoices_amount'] = sum(total_invoices_amount)
|
||||
# report_context['total_invoices_cash'] = sum(total_invoices_cash)
|
||||
# report_context['total_invoices_electronic'] = sum(total_invoices_electronic)
|
||||
# report_context['total_invoices_credit'] = sum(total_invoices_credit)
|
||||
# report_context['total_invoices_paid'] = sum(total_invoices_paid)
|
||||
# report_context['total_advances'] = sum(total_advances)
|
||||
# report_context['advances_cash'] = advances_cash_
|
||||
# report_context['advances_electronic'] = advances_electronic_
|
||||
# report_context['advances_voucher'] = sum(advances_voucher)
|
||||
# report_context['total_statements'] = sum(total_statements)
|
||||
# report_context['start_invoice'] = min(invoices_number) if invoices_number else ''
|
||||
# report_context['end_invoice'] = max(invoices_number) if invoices_number else ''
|
||||
# report_context['total_cash'] = advances_cash_ + statement_cash_
|
||||
# report_context['total_electronic'] = advances_electronic_ + statement_electronic_
|
||||
return report_context
|
||||
|
||||
|
||||
|
@ -232,7 +44,7 @@ class SaleIncomeDaily(metaclass=PoolMeta):
|
|||
|
||||
def do_print_(self, action):
|
||||
action, data = super(SaleIncomeDaily, self).do_print_(action)
|
||||
data['sincronize'] = self.start.sincronize,
|
||||
data['sincronize'] = self.start.sincronize
|
||||
return action, data
|
||||
|
||||
|
||||
|
@ -245,7 +57,7 @@ class SaleIncomeDailyReport(metaclass=PoolMeta):
|
|||
Company = Pool().get('company.company')
|
||||
company = Company(data['company'])
|
||||
result = {}
|
||||
sync = data['sincronize'][0]
|
||||
sync = data['sincronize']
|
||||
if sync:
|
||||
date_ = {
|
||||
'__class__': 'date',
|
||||
|
@ -261,17 +73,17 @@ class SaleIncomeDailyReport(metaclass=PoolMeta):
|
|||
'records': records,
|
||||
'data': data,
|
||||
}
|
||||
object_ = {
|
||||
'database': '',
|
||||
'report_name': 'sale_pos.sale_income_daily_report',
|
||||
'args': args,
|
||||
}
|
||||
for sync in company.connection_companies:
|
||||
object_['database'] = sync.database
|
||||
api_ = sync.api_connection + '/'+ sync.database
|
||||
api_ = 'http://' + sync.api_connection + '/'+ sync.database
|
||||
route = api_ + '/' + 'report_context'
|
||||
data_ = json.dumps(object_)
|
||||
data_ = json.dumps({
|
||||
'database': sync.database,
|
||||
'report_name': 'sale_pos.sale_income_daily_report',
|
||||
'args': args,
|
||||
})
|
||||
res = requests.get(route, data=data_)
|
||||
print(res)
|
||||
print(res.text)
|
||||
result = res.json()
|
||||
|
||||
for k in result.keys():
|
||||
|
|
|
@ -7,3 +7,4 @@ depends:
|
|||
xml:
|
||||
company.xml
|
||||
sale.xml
|
||||
account.xml
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<?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. -->
|
||||
<data>
|
||||
|
||||
<xpath
|
||||
expr="/form/field[@name='account_profit']"
|
||||
position="after">
|
||||
<label name="sincronize"/>
|
||||
<field name="sincronize"/>
|
||||
</xpath>
|
||||
</data>
|
|
@ -0,0 +1,12 @@
|
|||
<?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. -->
|
||||
<data>
|
||||
|
||||
<xpath
|
||||
expr="/form/field[@name='detailed']"
|
||||
position="after">
|
||||
<label name="sincronize"/>
|
||||
<field name="sincronize"/>
|
||||
</xpath>
|
||||
</data>
|
Loading…
Reference in New Issue