Merge pull request #1 from NaN-tic/043571

Add new report, taxes_by_invoice and fix general ledger.
This commit is contained in:
Albert Cervera i Areny 2021-08-27 12:40:02 +02:00 committed by GitHub
commit f443bad93c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 1040 additions and 124 deletions

View file

@ -2,8 +2,8 @@
# copyright notices and license terms.
from trytond.pool import Pool
from .common import *
# from .general_ledger import *
from . import general_ledger
from . import taxes_by_invoice
def register():
@ -11,14 +11,8 @@ def register():
Pool.register(
Account,
Party,
# PrintGeneralLedgerStart,
FiscalYear,
module=module, type_='model')
# Pool.register(
# PrintGeneralLedger,
# module='account_reports', type_='wizard')
# Pool.register(
# GeneralLedgerReport,
# module='account_reports', type_='report')
general_ledger.register(module)
taxes_by_invoice.register(module)

View file

@ -15,6 +15,7 @@ from trytond.modules.html_report.html_report import HTMLReport
from trytond.report import Report
from trytond.modules.html_report.engine import DualRecord
from babel.dates import format_date, format_datetime
from trytond.rpc import RPC
__all__ = ['PrintGeneralLedgerStart', 'PrintGeneralLedger',
'GeneralLedgerReport']
@ -129,6 +130,11 @@ class PrintGeneralLedger(Wizard):
class GeneralLedgerReport(HTMLReport):
__name__ = 'account_reports.general_ledger'
@classmethod
def __setup__(cls):
super(GeneralLedgerReport, cls).__setup__()
cls.__rpc__['execute'] = RPC(False)
@classmethod
def prepare(cls, data):
pool = Pool()
@ -290,26 +296,15 @@ class GeneralLedgerReport(HTMLReport):
rline = {
'sequence': sequence,
# 'key': str(currentKey),
'line': line,
# 'account_code': line.account.code or '',
# 'account_name': line.account.name or '',
# 'account_type': account_type,
# 'date': line.date.strftime('%d/%m/%Y'),
# 'move_line_name': line.description or '',
'ref': (line.origin.rec_name if line.origin and
hasattr(line.origin, 'rec_name') else None),
# 'move_number': line.move.number,
# 'move_post_number': (line.move.post_number
# if line.move.post_number else ''),
# 'party_name': line.party.name if line.party else '',
'credit': credit,
'debit': debit,
'balance': balance,
}
key = _get_key(currentKey)
print(key)
if records.get(key):
records[key]['lines'].append(rline)
records[key]['total_debit'] += debit
@ -343,24 +338,7 @@ class GeneralLedgerReport(HTMLReport):
elif account.type and account.type.payable:
account_type = 'payable'
# records.append({
# 'sequence': 1,
# 'key': str(account),
# 'account_code': account.code or '',
# 'account_name': account.name or '',
# 'account_type': account_type,
# 'move_line_name': '###PREVIOUSBALANCE###',
# 'ref': '-',
# 'move_number': '-',
# 'move_post_number': '-',
# 'credit': credit,
# 'debit': debit,
# 'balance': balance,
# 'previous_balance': (balance or _ZERO) + (credit or _ZERO) - (debit or _ZERO),
# })
key = '%s %s' % (account.code, account.name)
print(key)
if records.get(key):
records[key]['total_debit'] += debit
records[key]['total_credit'] += credit
@ -369,7 +347,6 @@ class GeneralLedgerReport(HTMLReport):
records[key] = {
'account': account.name,
'code': account.code,
# 'party': DualRecord(line.party) if line.party else None,
'lines': [],
'previous_balance': (balance + credit - debit),
'total_debit': debit,
@ -402,26 +379,8 @@ class GeneralLedgerReport(HTMLReport):
credit = z.get('credit', Decimal(0))
debit = z.get('debit', Decimal(0))
balance = z.get('balance', Decimal(0))
# rline = {
# 'sequence': sequence,
# 'key': str(currentKey),
# 'account_code': account.code or '',
# 'account_name': account.name or '',
# 'account_type': account_type,
# 'move_line_name': '###PREVIOUSBALANCE###',
# 'ref': '-',
# 'move_number': '-',
# 'move_post_number': '-',
# 'party_name': party.name,
# 'credit': credit,
# 'debit': debit,
# 'balance': balance,
# 'previous_balance': (balance + credit - debit),
# }
key = _get_key(currentKey)
print('account')
print(key)
if records.get(key):
records[key]['total_debit'] += debit
records[key]['total_credit'] += credit
@ -430,15 +389,12 @@ class GeneralLedgerReport(HTMLReport):
records[key] = {
'account': account.name,
'code': account.code,
# 'party': DualRecord(line.party) if line.party else None,
'lines': [],
'previous_balance': (balance + credit - debit),
'total_debit': debit,
'total_credit': credit,
'total_balance': balance,
}
# return records, parameters
return collections.OrderedDict(sorted(records.items())), parameters
@classmethod
@ -449,10 +405,10 @@ class GeneralLedgerReport(HTMLReport):
context = Transaction().context
context['report_lang'] = Transaction().language
context['report_translations'] = os.path.join(
os.path.dirname(__file__), 'translations')
os.path.dirname(__file__), 'translations')
with Transaction().set_context(**context):
return super(GeneralLedgerReport, cls).execute(ids, {
return super(GeneralLedgerReport, cls).execute(records, {
'name': 'account_reports.general_ledger',
'model': 'account.move.line',
'records': records,

View file

@ -14,6 +14,12 @@ copyright notices and license terms. -->
</record>
<!-- templates -->
<record model="html.template" id="general_ledger_html_header_template">
<field name="name">Header</field>
<field name="type">header</field>
<field name="sequence" eval="99"/>
<field name="filename">account_reports/general_ledger/templates/header_macro.html</field>
</record>
<record model='html.template' id="general_ledger_html_template">
<field name="name">General Ledger</field>
<field name="type">base</field>
@ -25,25 +31,11 @@ copyright notices and license terms. -->
<field name="name">General Ledger</field>
<field name="report_name">account_reports.general_ledger</field>
<field name="html_template" ref="general_ledger_html_template"/>
<field name="html_header_template" ref="general_ledger_html_header_template"/>
<field name="extension">pdf</field>
<field name="template_extension">jinja</field>
</record>
<record model='html.template.signature' id="general_ledger_show_header_macro_signature">
<field name="name">show_header(parameters)</field>
</record>
<record model='html.template' id="general_ledger_show_header_macro_html">
<field name="name">Header</field>
<field name="type">macro</field>
<field name="sequence" eval="99"/>
<field name="filename">account_reports/general_ledger/templates/header_macro.html</field>
<field name="implements" ref="account_reports.general_ledger_show_header_macro_signature"/>
</record>
<record model="html.report.template" id="report_general_ledger_template_show_header_html">
<field name="report" ref="report_general_ledger"/>
<field name="signature" ref="general_ledger_show_header_macro_signature"/>
</record>
<record model='html.template.signature' id="general_ledger_show_detail_macro_signature">
<field name="name">show_detail(records)</field>
</record>

View file

@ -2,15 +2,6 @@
{% block style %}
<style type="text/css">
@page {
@top-left {
content: "{{ data['parameters']['company'] }}. {{ _('VAT') }}: {{ data['parameters']['company_vat'] }}";
}
@top-right {
content: "{{ data['parameters']['now'] }}";
}
}
@media print {
#header-details {
display: none;
@ -24,18 +15,8 @@
{% endblock %}
{% block main %}
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
{{ show_header(data['parameters']) }}
</div>
</div>
<div class="row">
<div class="col-md-12">
{{ show_detail(data['records']) }}
<p>{{ _("When the Move number is between '()' means it hasn't Post Number and the shown number is the provisional one.") }}</p>
</div>
</div>
</div>
<div>
{{ show_detail(data['records']) }}
<p>{{ _("When the Move number is between '()' means it hasn't Post Number and the shown number is the provisional one.") }}</p>
</div>
{% endblock %}

View file

@ -1,25 +1,40 @@
<table>
<tr id="header-details">
<td>
{{ parameters['company'] }}. {{ _('VAT') }}: {{ parameters['company_vat'] }}
</td>
<td class="right">
{{ parameters['now'] }}
</td>
</tr>
<tr>
<td colspan="2" align="center">
<h1>{{ _('General Ledger') }}</h1>
</td>
<tr>
<td>
{{ _('Fiscal Year') }}: {{ parameters['fiscal_year'] }}<br/>
{% if parameters['start_period'] %}{{ _('Start Period') }}: {{ parameters['start_period'] }}{% endif %}
{% if parameters['end_period'] %} {{ _('End Period') }}: {{ parameters['end_period'] }}{% endif %}
</td>
<td class="right">
{% if parameters['parties'] %}{{ _('Parties') }}: {{ parameters['parties'] }}{% else %}{{ _('All Parties' )}}{% endif %}<br/>
{% if parameters['accounts'] %}{{ _('Accounts') }}: {{ parameters['accounts'] }}{% else %}{{ _('All Accounts' )}}{% endif %}
</td>
</tr>
</table>
<link rel="stylesheet" href="{{ 'html_report/templates/base.css'|modulepath }}">
<style>
#header-table {
/* width: 650px !important;*/
width: 17cm;
}
</style>
{% language party and party.raw.lang and party.lang.raw.code or company.party.lang and company.party.raw.lang.code or 'en' %}
<header id="header">
<table>
<tr id="header-details">
<td>
{{ data['parameters']['company'] }}. {{ _('VAT') }}: {{ data['parameters']['company_vat'] }}
</td>
<td class="right">
{{ data['parameters']['now'] }}
</td>
</tr>
<tr>
<td colspan="2" align="center">
<h1>{{ _('General Ledger') }}</h1>
</td>
<tr>
<td>
{{ _('Fiscal Year') }}: {{ data['parameters']['fiscal_year'] }}<br/>
{% if data['parameters']['start_period'] %}{{ _('Start Period') }}: {{ data['parameters']['start_period'] }}{% endif %}
{% if data['parameters']['end_period'] %} {{ _('End Period') }}: {{ data['parameters']['end_period'] }}{% endif %}
</td>
<td class="right">
{% if data['parameters']['parties'] %}{{ _('Parties') }}: {{ data['parameters']['parties'] }}{% else %}{{ _('All Parties' )}}{% endif %}<br/>
{% if data['parameters']['accounts'] %}{{ _('Accounts') }}: {{ data['parameters']['accounts'] }}{% else %}{{ _('All Accounts' )}}{% endif %}
</td>
</tr>
</table>
</header>
{% endlanguage %}

View file

@ -396,7 +396,7 @@ msgid "Print General Ledger"
msgstr "Imprimir libro mayor"
msgctxt "model:ir.ui.menu,name:menu_print_taxes_by_invoice"
msgid "Print Taxes by Invoice and Period"
msgid "Print Taxes by Invoice and Period HTML"
msgstr "Imprimir impuestos por factura y período"
msgctxt "model:ir.ui.menu,name:menu_print_trial_balance"

View file

@ -0,0 +1,14 @@
from trytond.pool import Pool
from . import taxes_by_invoice
def register(module):
Pool.register(
taxes_by_invoice.PrintTaxesByInvoiceAndPeriodStart,
module=module, type_='model')
Pool.register(
taxes_by_invoice.PrintTaxesByInvoiceAndPeriod,
module=module, type_='wizard')
Pool.register(
taxes_by_invoice.TaxesByInvoiceReport,
module=module, type_='report')

View file

@ -0,0 +1,2 @@
[jinja2: **/templates/**.html]
extensions=jinja2.ext.autoescape,jinja2.ext.with_,formencode_jinja2.formfill

View file

@ -0,0 +1,99 @@
# Translations template for PROJECT.
# Copyright (C) 2021 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2021.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2021-08-02 13:46+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.8.0\n"
#: templates/detail_macro.html:6 templates/detail_macro.html:20
msgid "Move Date"
msgstr ""
#: templates/detail_macro.html:7 templates/detail_macro.html:21
msgid "Account"
msgstr ""
#: templates/detail_macro.html:8 templates/detail_macro.html:22
msgid "NIF"
msgstr ""
#: templates/detail_macro.html:9 templates/detail_macro.html:23
msgid "Invoice"
msgstr ""
#: templates/detail_macro.html:10 templates/detail_macro.html:24
msgid "Date"
msgstr ""
#: templates/detail_macro.html:11 templates/detail_macro.html:25
msgid "Base"
msgstr ""
#: templates/detail_macro.html:12 templates/detail_macro.html:26
msgid "Tax"
msgstr ""
#: templates/detail_macro.html:13 templates/detail_macro.html:27
msgid "Base + Tax"
msgstr ""
#: templates/detail_macro.html:14 templates/detail_macro.html:28
msgid "Total Invoice"
msgstr ""
#: templates/detail_macro.html:38
msgid "Total Period"
msgstr ""
#: templates/detail_macro.html:38 templates/detail_macro.html:48
msgid "Total"
msgstr ""
#: templates/header_macro.html:19 templates/taxes_by_invoice.html:15
msgid "Taxes By Invoice and Period"
msgstr ""
#: templates/header_macro.html:19 templates/taxes_by_invoice.html:17
msgid "Taxes By Invoice"
msgstr ""
#: templates/header_macro.html:31
msgid "Fiscal Year"
msgstr ""
#: templates/header_macro.html:31
msgid "Periods:"
msgstr ""
#: templates/header_macro.html:31
msgid "All Periods"
msgstr ""
#: templates/header_macro.html:32
msgid "This document includes cancelled invoices marked with a *"
msgstr ""
#: templates/header_macro.html:32
msgid "This document not includes cancelled invoices"
msgstr ""
#: templates/header_macro.html:35
msgid "Parties: "
msgstr ""
#: templates/header_macro.html:35
msgid "All Parties"
msgstr ""

View file

@ -0,0 +1,360 @@
# The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms.
import os
import collections
from datetime import timedelta, datetime
from decimal import Decimal
from trytond.pool import Pool
from trytond.transaction import Transaction
from trytond.model import ModelView, fields
from trytond.wizard import Wizard, StateView, StateAction, StateReport, Button
from trytond.pyson import Eval, If, Bool
from trytond.rpc import RPC
from trytond.modules.html_report.html_report import HTMLReport
from trytond.report import Report
from trytond.modules.html_report.engine import DualRecord
from babel.dates import format_date, format_datetime
_ZERO = Decimal(0)
class PrintTaxesByInvoiceAndPeriodStart(ModelView):
'Print Taxes by Invoice and Period'
__name__ = 'account_reports.print_taxes_by_invoice.start'
fiscalyear = fields.Many2One('account.fiscalyear', 'Fiscal Year',
states={
'invisible': Eval('start_date') | Eval('end_date'),
'required': ~Eval('start_date') & ~Eval('end_date'),
})
periods = fields.Many2Many('account.period', None, None, 'Periods',
states={
'invisible': Eval('start_date') | Eval('end_date'),
},
domain=[
('fiscalyear', '=', Eval('fiscalyear')),
], depends=['fiscalyear'])
partner_type = fields.Selection([
('customers', 'Customers'),
('suppliers', 'Suppliers'),
], 'Party Type', required=True)
grouping = fields.Selection([
('base_tax_code', 'Base Tax Code'),
('invoice', 'Invoice'),
], 'Grouping', required=True)
tax_type = fields.Selection([
('all', 'All'),
('invoiced', 'Invoiced'),
('refunded', 'Refunded'),
], 'Tax Type', required=True)
totals_only = fields.Boolean('Totals Only')
parties = fields.Many2Many('party.party', None, None, 'Parties')
output_format = fields.Selection([
('pdf', 'PDF'),
('xls', 'XLS'),
], 'Output Format', required=True)
company = fields.Many2One('company.company', 'Company', required=True)
start_date = fields.Date('Initial posting date',
domain=[
If(Eval('start_date') & Eval('end_date'),
('start_date', '<=', Eval('end_date', None)),
()),
],
states={
'invisible': Bool(Eval('periods')),
'required': ((Eval('start_date') | Eval('end_date')) &
~Bool(Eval('periods'))),
},
depends=['end_date'])
end_date = fields.Date('Final posting date',
domain=[
If(Eval('start_date') & Eval('end_date'),
('end_date', '>=', Eval('start_date', None)),
()),
],
states={
'invisible': Bool(Eval('periods')),
'required': ((Eval('end_date') | Eval('start_date')) &
~Bool(Eval('periods'))),
},
depends=['start_date'])
taxes = fields.Many2Many('account.tax', None, None, 'Taxes',
domain=[
If(Eval('partner_type') == 'customers',
('group.kind', 'in', ('both', 'sale')),
('group.kind', 'in', ('both', 'purchase'))
),
], depends=['partner_type'])
include_cancel = fields.Boolean('Include cancel')
@staticmethod
def default_partner_type():
return 'customers'
@staticmethod
def default_grouping():
return 'base_tax_code'
@staticmethod
def default_tax_type():
return 'all'
@staticmethod
def default_fiscalyear():
FiscalYear = Pool().get('account.fiscalyear')
return FiscalYear.find(
Transaction().context.get('company'), exception=False)
@staticmethod
def default_company():
return Transaction().context.get('company')
@staticmethod
def default_output_format():
return 'pdf'
@fields.depends('fiscalyear')
def on_change_fiscalyear(self):
self.periods = None
class PrintTaxesByInvoiceAndPeriod(Wizard):
'Print TaxesByInvoiceAndPeriod'
__name__ = 'account_reports.print_taxes_by_invoice'
start = StateView('account_reports.print_taxes_by_invoice.start',
'account_reports.print_taxes_by_invoice_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Print', 'print_', 'tryton-print', default=True),
])
print_ = StateReport('account_reports.taxes_by_invoice')
def do_print_(self, action):
fiscalyear = (self.start.fiscalyear.id if self.start.fiscalyear
else None)
if self.start.start_date:
fiscalyear = None
data = {
'company': self.start.company.id,
'fiscalyear': fiscalyear,
'start_date': self.start.start_date,
'end_date': self.start.end_date,
'periods': [x.id for x in self.start.periods],
'parties': [x.id for x in self.start.parties],
'output_format': self.start.output_format,
'partner_type': self.start.partner_type,
'totals_only': self.start.totals_only,
'grouping': self.start.grouping,
'tax_type': self.start.tax_type,
'taxes': [x.id for x in self.start.taxes],
'include_cancel': self.start.include_cancel,
}
return action, data
def transition_print_(self):
return 'end'
def default_start(self, fields):
Party = Pool().get('party.party')
party_ids = []
if Transaction().context.get('model') == 'party.party':
for party in Party.browse(Transaction().context.get('active_ids')):
party_ids.append(party.id)
return {
'parties': party_ids,
}
class TaxesByInvoiceReport(HTMLReport):
__name__ = 'account_reports.taxes_by_invoice'
@classmethod
def __setup__(cls):
super(TaxesByInvoiceReport, cls).__setup__()
cls.__rpc__['execute'] = RPC(False)
@classmethod
def prepare(cls, data):
pool = Pool()
Company = pool.get('company.company')
FiscalYear = pool.get('account.fiscalyear')
Period = pool.get('account.period')
Party = pool.get('party.party')
Tax = pool.get('account.tax')
AccountInvoiceTax = pool.get('account.invoice.tax')
fiscalyear = (FiscalYear(data['fiscalyear']) if data.get('fiscalyear')
else None)
start_date = None
if data['start_date']:
start_date = data['start_date']
end_date = None
if data['end_date']:
end_date = data['end_date']
periods = []
periods_subtitle = ''
if data.get('periods'):
periods = Period.browse(data.get('periods', []))
periods_subtitle = []
for x in periods:
periods_subtitle.append(x.rec_name)
periods_subtitle = '; '.join(periods_subtitle)
elif not start_date and not end_date:
periods = Period.search([('fiscalyear', '=', fiscalyear.id)])
with Transaction().set_context(active_test=False):
parties = Party.browse(data.get('parties', []))
if parties:
parties_subtitle = []
for x in parties:
if len(parties_subtitle) > 4:
parties_subtitle.append('...')
break
parties_subtitle.append(x.rec_name)
parties_subtitle = '; '.join(parties_subtitle)
else:
parties_subtitle = ''
company = None
if data['company']:
company = Company(data['company'])
parameters = {}
parameters['fiscal_year'] = fiscalyear.rec_name if fiscalyear else ''
parameters['start_date'] = (start_date.strftime('%d/%m/%Y')
if start_date else '')
parameters['end_date'] = (end_date.strftime('%d/%m/%Y')
if end_date else '')
parameters['parties'] = parties_subtitle
parameters['periods'] = periods_subtitle
parameters['TOTALS_ONLY'] = data['totals_only'] and True or False
parameters['company_rec_name'] = company.rec_name if company else ''
parameters['now'] = format_datetime(datetime.now(), format='short',
locale=Transaction().language or 'en')
parameters['company_vat'] = (company
and company.party.tax_identifier and
company.party.tax_identifier.code) or ''
parameters['jump_page'] = (True if data['grouping'] == 'invoice'
else False)
parameters['include_cancel'] = data['include_cancel'] or False
parameters['records_found'] = True
domain = [
('invoice.move', '!=', None),
]
if data['partner_type'] == 'customers':
domain += [('invoice.type', '=', 'out')]
else:
domain += [('invoice.type', '=', 'in')]
if start_date:
domain += [
('invoice.move.date', '>=', start_date),
]
if end_date:
domain += [
('invoice.move.date', '<=', end_date),
]
if not start_date and not end_date and periods:
domain += [('invoice.move.period', 'in', periods)]
if parties:
domain += [('invoice.party', 'in', parties)],
if data['tax_type'] == 'invoiced':
domain += [('base', '>=', 0)]
elif data['tax_type'] == 'refunded':
domain += [('base', '<', 0)]
if data['taxes']:
domain += [('tax', 'in', data.get('taxes', []))]
if not data['include_cancel']:
domain += [('invoice.state', '!=', 'cancel')]
records = {}
totals = {'total_total':0,'total_tax':0,'total_invoice':0}
tax_totals = {}
if data['grouping'] == 'invoice':
periods = AccountInvoiceTax.search(domain,
order=[('invoice.move.period', 'ASC'),
('invoice','ASC')])
for period in periods:
records.setdefault(period.invoice.move.period, []).append(
DualRecord(period))
# With this we have the total for each tax (total base, total
# amount and total)
tax_totals.setdefault(period.invoice.move.period, {
'total_untaxed':0, 'total_tax':0, 'total':0})
tax_totals[period.invoice.move.period]['total_untaxed'] += (
period.company_base)
tax_totals[period.invoice.move.period]['total_tax'] += (
period.company_amount)
tax_totals[period.invoice.move.period]['total'] += (
period.company_base + period.company_amount)
# We need this fields in the report
totals['total_total'] += period.company_base + period.company_base
totals['total_tax'] += period.company_base
totals['total_invoice'] += period.invoice.company_total_amount
parameters['totals'] = totals
else:
taxes = AccountInvoiceTax.search(domain, order=[('account', 'ASC'),
('invoice','ASC')])
for tax in taxes:
records.setdefault(tax.tax, []).append(DualRecord(tax))
# With this we have the total for each tax (total base, total
# amount and total)
tax_totals.setdefault(tax.tax, {'total_untaxed':0,
'total_tax':0, 'total':0})
tax_totals[tax.tax]['total_untaxed'] += tax.company_base
tax_totals[tax.tax]['total_tax'] += tax.company_amount
tax_totals[tax.tax]['total'] += (tax.company_base +
tax.company_amount)
parameters['tax_totals'] = tax_totals
return records, parameters
@classmethod
def execute(cls, ids, data):
with Transaction().set_context(active_test=False):
records, parameters = cls.prepare(data)
context = Transaction().context
context['report_lang'] = Transaction().language
context['report_translations'] = os.path.join(
os.path.dirname(__file__), 'translations')
# We need the records dictionary to have at leat one record, otherwise
# the report will not be generated
if len(records) == 0:
parameters['records_found'] = False
records['no_records'] = ''
with Transaction().set_context(**context):
name = 'account_reports.taxes_by_invoice'
if parameters['jump_page']:
name = 'account_reports.taxes_by_invoice_and_period'
return super(TaxesByInvoiceReport,cls).execute(records, {
'name': name,
'model': 'account.invoice.tax',
'records': records,
'parameters': parameters,
'output_format': data.get('output_format', 'pdf'),
})
class TaxesByInvoiceAndPeriodReport(TaxesByInvoiceReport):
__name__ = 'account_reports.taxes_by_invoice_and_period'

View file

@ -0,0 +1,74 @@
<?xml version="1.0"?>
<!-- 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_taxes_by_invoice_start_view_form">
<field name="model">account_reports.print_taxes_by_invoice.start</field>
<field name="type">form</field>
<field name="name">print_taxes_by_invoice_start_form</field>
</record>
<record model="ir.action.wizard" id="wizard_print_taxes_by_invoice">
<field name="name">Print Taxes by Invoice and Period</field>
<field name="wiz_name">account_reports.print_taxes_by_invoice</field>
</record>
<!-- templates -->
<record model="html.template" id="taxes_by_invoice_header_template">
<field name="name">Header</field>
<field name="type">header</field>
<field name="sequence" eval="99"/>
<field name="filename">account_reports/taxes_by_invoice/templates/header_macro.html</field>
</record>
<record model="html.template" id="taxes_by_invoice_html_template">
<field name="name">Taxes By Invoice</field>
<field name="type">base</field>
<field name="sequence" eval="99"/>
<field name="filename">account_reports/taxes_by_invoice/templates/taxes_by_invoice.html</field>
</record>
<record model="ir.action.report" id="report_taxes_by_invoice">
<field name="name">Taxes by Invoice</field>
<field name="report_name">account_reports.taxes_by_invoice</field>
<field name="html_template" ref="taxes_by_invoice_html_template"/>
<field name="html_header_template" ref="taxes_by_invoice_header_template"/>
<field name="extension">pdf</field>
<field name="template_extension">jinja</field>
</record>
<record model="html.template.signature" id="taxes_by_invoice_show_detail_macro_signature">
<field name="name">show_detail(records)</field>
</record>
<record model="html.template" id="taxes_by_invoice_show_detail_macro_html">
<field name="name">Detail</field>
<field name="type">macro</field>
<field name="sequence" eval="99"/>
<field name="filename">account_reports/taxes_by_invoice/templates/detail_macro.html</field>
<field name="implements" ref="account_reports.taxes_by_invoice_show_detail_macro_signature"/>
</record>
<record model="html.report.template" id="report_taxes_by_invoice_template_show_detail_html">
<field name="report" ref="report_taxes_by_invoice"/>
<field name="signature" ref="account_reports.taxes_by_invoice_show_detail_macro_signature"/>
</record>
<record model='html.template.signature' id="taxes_by_invoice_show_detail_lines_macro_signature">
<field name="name">show_detail_lines(record)</field>
</record>
<record model='html.template' id="taxes_by_invoice_show_detail_lines_macro_html">
<field name="name">Detail Lines</field>
<field name="type">macro</field>
<field name="sequence" eval="99"/>
<field name="filename">account_reports/taxes_by_invoice/templates/detail_lines_macro.html</field>
<field name="implements" ref="account_reports.taxes_by_invoice_show_detail_lines_macro_signature"/>
</record>
<record model="html.report.template" id="report_taxes_by_invoice_template_show_detail_lines_html">
<field name="report" ref="report_taxes_by_invoice"/>
<field name="signature" ref="taxes_by_invoice_show_detail_lines_macro_signature"/>
</record>
<!-- menu wizard -->
<menuitem id="menu_print_taxes_by_invoice" name="Print Taxes by Invoice and Period HTML"
parent="account.menu_reporting" action="wizard_print_taxes_by_invoice"
icon="tryton-print"/>
</data>
</tryton>

View file

@ -0,0 +1,20 @@
{%for l in record %}
<tr>
<td>{{ l.invoice.move.render.date }}</td>
<td>{{ l.account.render.code}}</td>
<td style="text-align: left;">{{ l.invoice.party.render.rec_name}}</td>
<td>{% if l.invoice.party.raw.tax_identifier %}{{ l.invoice.party.tax_identifier.render.code}}{% endif %}</td>
<td>{% if l.invoice.raw.state == 'cancel' %}*{% endif %}{{ l.invoice.render.number }}</td>
<td>{{ l.invoice.render.invoice_date }}</td>
{% for tax_line in l.invoice.taxes %}
{% if tax_line.tax.raw.id == l.tax.raw.id %}
<td>{% if tax_line.render.base %}{{tax_line.raw.company_base | render(digits=l.invoice.company.currency.raw.digits)}}{% else %}0.0{% endif %}</td>
<td>{{ l.tax.raw.name }}</td>
<td>{% if tax_line.render.amount %}{{ tax_line.raw.company_amount | render(digits=l.invoice.company.currency.raw.digits)}}{% else %}0.0{% endif %}</td>
{% set total = tax_line.raw.company_base + l.raw.company_amount%}
<td>{{ total | render(l.invoice.company.currency.raw.digits) }} </td>
{% endif %}
{% endfor %}
<td class="bold">{{ l.invoice.raw.company_total_amount | render(digits=l.invoice.company.currency.raw.digits)}}</td>
</tr>
{% endfor %}

View file

@ -0,0 +1,63 @@
{% for k in data['records'] %}
<table style="text-align: right;width: 1110px !important;margin-left: -90px !important;">
{%if data['parameters']['jump_page'] %}
<thead>
<tr>
<th>{{ _('Move Date')}}</th>
<th>{{ _('Account')}}</th>
<th colspan="2">{{ _('NIF')}}</th>
<th>{{ _('Invoice')}}</th>
<th>{{ _('Date')}}</th>
<th>{{ _('Base')}}</th>
<th colspan="2">{{ _('Tax')}}</th>
<th>{{ _('Base + Tax')}}</th>
<th>{{ _('Total Invoice')}}</th>
</tr>
</thead>
{% else %}
<thead>
<tr>
<th>{{ _('Move Date')}}</th>
<th>{{ _('Account')}}</th>
<th colspan="2" style="text-align: right;">{{ _('NIF')}}</th>
<th>{{ _('Invoice')}}</th>
<th>{{ _('Date')}}</th>
<th>{{ _('Base')}}</th>
<th colspan="2">{{ _('Tax')}}</th>
<th>{{ _('Base + Tax')}}</th>
<th>{{ _('Total Invoice')}}</th>
</tr>
</thead>
{% endif %}
<tr>
<td class="bold">{{ k.name }}</td>
</tr>
{% set record = data['records'][k] %}
{{ show_detail_lines(record) }}
<tr class="bold">
<td colspan="6" class="right">{% if data['parameters']['jump_page'] %} {{ _('Total Period') }} {% else %} {{ _('Total') }} {% endif %} {{k.name}}</td>
<td>{{data['parameters']['tax_totals'][k]['total_untaxed'] | render(digits=record[0].invoice.company.currency.raw.digits)}}</td>
<td></td>
<td>{{data['parameters']['tax_totals'][k]['total_tax'] | render(digits=record[0].invoice.company.currency.raw.digits)}}</td>
<td>{{data['parameters']['tax_totals'][k]['total'] | render(digits=record[0].invoice.company.currency.raw.digits)}}</td>
<td></td>
</tr>
{% if data['parameters']['jump_page'] %}
{% if loop.nextitem is not defined %}
<tr class="bold">
<td colspan="6" class="right"> {{ _('Total') }} </td>
<td></td>
<td></td>
<td>{{ data['parameters']['totals']['total_tax'] | render(digits=record[0].invoice.company.currency.raw.digits)}}</td>
<td>{{ data['parameters']['totals']['total_total'] | render(digits=record[0].invoice.company.currency.raw.digits)}}</td>
<td>{{ data['parameters']['totals']['total_invoice'] | render(digits=record[0].invoice.company.currency.raw.digits)}}</td>
</tr>
{% endif %}
{% endif %}
</table>
{%if data['parameters']['jump_page'] %}
{% if loop.nextitem is defined %}
<p style="page-break-before: always" ></p>
{% endif %}
{% endif %}
{% endfor %}

View file

@ -0,0 +1,37 @@
<table>
<tr>
<th>{{ _('Date')}}</th>
<th>{{ _('Account')}}</th>
<th colspan="2">{{ _('NIF')}}</th>
<th>{{ _('Invoice')}}</th>
<th>{{ _('Date')}}</th>
<th>{{ _('Base')}}</th>
<th colspan="2">{{ _('Tax')}}</th>
<th>{{ _('Base + Tax')}}</th>
<th>{{ _('Total Invoice')}}</th>
</tr>
{% for k in data['records'] %}
<tr>
<td class="bold">{{ k.name }}</td>
</tr>
{% set record = data['records'][k] %}
{{ show_detail_lines(record) }}
{% set total_untaxed = record|sum(attribute='invoice.raw.company_untaxed_amount') %}
{% set total_tax = record|sum(attribute='invoice.raw.company_tax_amount') %}
{% set total = total_untaxed + total_tax%}
<tr class="bold">
<td colspan="6" class="right">Total {{k.name}}</td>
<td>{{ total_untaxed }}</td>
<td></td>
<td>{{ total_tax }}</td>
<td>{{ total }}</td>
<td></td>
</tr>
{%if data['parameters']['jump_page'] %}
{% if loop.nextitem is defined %}
<p style="page-break-before: always" ></p>
{% endif %}
{% endif %}
{% endfor %}
</table>

View file

@ -0,0 +1,41 @@
<link rel="stylesheet" href="{{ 'html_report/templates/base.css'|modulepath }}">
<style>
#header-table {
width: 17cm;
}
</style>
{% language party and party.raw.lang and party.lang.raw.code or company.party.lang and company.party.raw.lang.code or 'en' %}
<header id="header">
<table style="width: 1110px !important; margin-left: -70px !important;">
<thead>
<tr>
<td style="font-style: italic;font-size: 14px;font-weight: bold;">
{{ data['parameters']['company_rec_name']}}
</td>
<td class="center" style="width:60%;text-align: right;font-size: 15px;">
<h1>{% if data['parameters']['jump_page'] %}{{ _('Taxes By Invoice and Period') }}{% else %}{{ _('Taxes By Invoice') }}{% endif %}</h1>
</td>
<td style="text-align: right;">
{{ data['parameters']['now']}}
</td>
</tr>
</thead>
</table>
<table style="width: 1110px !important; margin-left: -70px !important;">
<thead>
<tr>
<td>{{ _('Fiscal Year') }}: {{ data['parameters']['fiscal_year']}} {% if data['parameters']['periods'] %}{{ _('Periods:') }} {{data['parameters']['periods']}} {% else %}{{ _('All Periods') }}{% endif %}</td>
<td style="text-align: right;">{% if data['parameters']['include_cancel'] %}{{ _('This document includes cancelled invoices marked with a *') }}{% else %}{{ _('This document not includes cancelled invoices') }}{% endif %}</td>
</tr>
<tr>
<td>{% if data['parameters']['parties'] %}{{ _('Parties: ') }}{{ data['parameters']['parties']}}{% else %}{{ _('All Parties') }}{% endif %}</td>
</tr>
</thead>
</table>
</header>
{% endlanguage %}

View file

@ -0,0 +1,33 @@
{% extends 'account_reports/templates/base.html' %}
{% block style %}
<style type="text/css">
@media print {
#header-details {
display: none;
}
}
</style>
{% endblock %}
{% block title %}
{% if data['parameters']['jump_page'] %}
{{ _('Taxes By Invoice and Period') }} - {{ data['parameters']['company_rec_name'] }} - {{ data['parameters']['now'] }}
{% else %}
{{ _('Taxes By Invoice') }} - {{ data['parameters']['company_rec_name'] }} - {{ data['parameters']['now'] }}
{% endif %}
{% endblock %}
{% block main %}
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
{% if data['parameters']['records_found'] %}
{{ show_detail(data['records']) }}
{% else %}
<strong>No records found</strong>
{% endif %}
</div>
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,100 @@
# Catalan translations for PROJECT.
# Copyright (C) 2021 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2021.
#
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2021-08-02 13:46+0200\n"
"PO-Revision-Date: 2021-08-02 13:47+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: ca\n"
"Language-Team: ca <LL@li.org>\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.8.0\n"
#: templates/detail_macro.html:6 templates/detail_macro.html:20
msgid "Move Date"
msgstr "Data assentament"
#: templates/detail_macro.html:7 templates/detail_macro.html:21
msgid "Account"
msgstr "Compte"
#: templates/detail_macro.html:8 templates/detail_macro.html:22
msgid "NIF"
msgstr "NIF"
#: templates/detail_macro.html:9 templates/detail_macro.html:23
msgid "Invoice"
msgstr "Factura"
#: templates/detail_macro.html:10 templates/detail_macro.html:24
msgid "Date"
msgstr "Data Factura"
#: templates/detail_macro.html:11 templates/detail_macro.html:25
msgid "Base"
msgstr "Base"
#: templates/detail_macro.html:12 templates/detail_macro.html:26
msgid "Tax"
msgstr "Impost"
#: templates/detail_macro.html:13 templates/detail_macro.html:27
msgid "Base + Tax"
msgstr "Base+Imp."
#: templates/detail_macro.html:14 templates/detail_macro.html:28
msgid "Total Invoice"
msgstr "Total factura"
#: templates/detail_macro.html:38
msgid "Total Period"
msgstr "Total període"
#: templates/detail_macro.html:38 templates/detail_macro.html:48
msgid "Total"
msgstr "Total"
#: templates/header_macro.html:19 templates/taxes_by_invoice.html:15
msgid "Taxes By Invoice and Period"
msgstr "Impostos per factura i període"
#: templates/header_macro.html:19 templates/taxes_by_invoice.html:17
msgid "Taxes By Invoice"
msgstr "Impostos per factura"
#: templates/header_macro.html:31
msgid "Fiscal Year"
msgstr "Any Fiscal"
#: templates/header_macro.html:31
msgid "Periods:"
msgstr "Períodes:"
#: templates/header_macro.html:31
msgid "All Periods"
msgstr "Tots els períodes"
#: templates/header_macro.html:32
msgid "This document includes cancelled invoices marked with a *"
msgstr "Aquest document inclou factures cancel·lades marcades amb un *"
#: templates/header_macro.html:32
msgid "This document not includes cancelled invoices"
msgstr "Aquest document no inclou factures cancel·lades"
#: templates/header_macro.html:35
msgid "Parties: "
msgstr "Tercers: "
#: templates/header_macro.html:35
msgid "All Parties"
msgstr "Tots els tercers"

View file

@ -0,0 +1,100 @@
# Spanish translations for PROJECT.
# Copyright (C) 2021 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2021.
#
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2021-08-02 13:46+0200\n"
"PO-Revision-Date: 2021-08-02 13:47+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: es\n"
"Language-Team: es <LL@li.org>\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.8.0\n"
#: templates/detail_macro.html:6 templates/detail_macro.html:20
msgid "Move Date"
msgstr "Fecha asiento"
#: templates/detail_macro.html:7 templates/detail_macro.html:21
msgid "Account"
msgstr "Cuenta"
#: templates/detail_macro.html:8 templates/detail_macro.html:22
msgid "NIF"
msgstr "NIF"
#: templates/detail_macro.html:9 templates/detail_macro.html:23
msgid "Invoice"
msgstr ""
#: templates/detail_macro.html:10 templates/detail_macro.html:24
msgid "Date"
msgstr "Factura"
#: templates/detail_macro.html:11 templates/detail_macro.html:25
msgid "Base"
msgstr "Base"
#: templates/detail_macro.html:12 templates/detail_macro.html:26
msgid "Tax"
msgstr "Impuestos"
#: templates/detail_macro.html:13 templates/detail_macro.html:27
msgid "Base + Tax"
msgstr "Base+Imp."
#: templates/detail_macro.html:14 templates/detail_macro.html:28
msgid "Total Invoice"
msgstr "Total Factura"
#: templates/detail_macro.html:38
msgid "Total Period"
msgstr "Total Período"
#: templates/detail_macro.html:38 templates/detail_macro.html:48
msgid "Total"
msgstr "Total"
#: templates/header_macro.html:19 templates/taxes_by_invoice.html:15
msgid "Taxes By Invoice and Period"
msgstr "Impuestos por factura y período"
#: templates/header_macro.html:19 templates/taxes_by_invoice.html:17
msgid "Taxes By Invoice"
msgstr "Impuestos por factura"
#: templates/header_macro.html:31
msgid "Fiscal Year"
msgstr "Ejercicio fiscal"
#: templates/header_macro.html:31
msgid "Periods:"
msgstr "Períodos"
#: templates/header_macro.html:31
msgid "All Periods"
msgstr "Todos los períodos"
#: templates/header_macro.html:32
msgid "This document includes cancelled invoices marked with a *"
msgstr "Este documento incluye facturas canceladas marcadas con un *"
#: templates/header_macro.html:32
msgid "This document not includes cancelled invoices"
msgstr "Este documento no incluye facturas canceladas"
#: templates/header_macro.html:35
msgid "Parties: "
msgstr "Terceros: "
#: templates/header_macro.html:35
msgid "All Parties"
msgstr "Todos los terceros"

View file

@ -7,4 +7,5 @@ depends:
account_invoice_company_currency
xml:
general_ledger/general_ledger.xml
taxes_by_invoice/taxes_by_invoice.xml
message.xml

View file

@ -0,0 +1,34 @@
<?xml version="1.0"?>
<!-- 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"/>
<newline/>
<label name="partner_type"/>
<field name="partner_type"/>
<label name="grouping"/>
<field name="grouping"/>
<label name="tax_type"/>
<field name="tax_type"/>
<label name="fiscalyear"/>
<field name="fiscalyear"/>
<newline/>
<label name="start_date"/>
<field name="start_date"/>
<label name="end_date"/>
<field name="end_date"/>
<label name="totals_only"/>
<field name="totals_only"/>
<label name="include_cancel"/>
<field name="include_cancel"/>
<newline/>
<label id="select_periods" string="Left empty to select all periods"/>
<field name="periods" colspan="4"/>
<label id="select_parties" string="Left empty to select all parties"/>
<field name="parties" colspan="4"/>
<label id="select_taxes" string="Left empty to select all taxes"/>
<field name="taxes" colspan="4"/>
<label name="output_format"/>
<field name="output_format"/>
</form>