Add xls format to general ledger report. (#4)
Adapt general_ledger report: - Change positon page - Add missing fields - Add missing agrupations - Other visuals changes (header, etc.) Task #071305
This commit is contained in:
parent
626059d87d
commit
11001fad8c
|
@ -2,7 +2,6 @@
|
|||
# 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
|
||||
|
@ -53,6 +52,7 @@ class PrintGeneralLedgerStart(ModelView):
|
|||
output_format = fields.Selection([
|
||||
('pdf', 'PDF'),
|
||||
('html', 'HTML'),
|
||||
('xls', 'Excel'),
|
||||
], 'Output Format', required=True)
|
||||
company = fields.Many2One('company.company', 'Company', required=True)
|
||||
|
||||
|
@ -157,6 +157,7 @@ class GeneralLedgerReport(HTMLReport):
|
|||
Account = pool.get('account.account')
|
||||
Party = pool.get('party.party')
|
||||
Line = pool.get('account.move.line')
|
||||
InvoiceLine = pool.get('account.invoice.line')
|
||||
|
||||
def _get_key(currentKey):
|
||||
account_code = currentKey[0].code or currentKey[0].name
|
||||
|
@ -172,6 +173,10 @@ class GeneralLedgerReport(HTMLReport):
|
|||
key = currentKey[0].name
|
||||
return key
|
||||
|
||||
def _get_key_id(currentKey):
|
||||
key = currentKey[0].id
|
||||
return key
|
||||
|
||||
fiscalyear = FiscalYear(data['fiscalyear'])
|
||||
start_period = None
|
||||
if data['start_period']:
|
||||
|
@ -302,17 +307,41 @@ class GeneralLedgerReport(HTMLReport):
|
|||
balance += line.debit - line.credit
|
||||
sequence += 1
|
||||
|
||||
party = None
|
||||
ref = None
|
||||
|
||||
if line.origin and isinstance(line.origin, InvoiceLine):
|
||||
# If the account have the check "party_required", try to
|
||||
# get from the invoice
|
||||
if line.account.party_required:
|
||||
party = line.origin.invoice.party
|
||||
|
||||
if line.origin.invoice.number:
|
||||
ref = '%s' % line.origin.invoice.number
|
||||
if line.origin.invoice.reference:
|
||||
ref += ' [%s]' % line.origin.invoice.reference
|
||||
if line.origin.invoice.party.rec_name:
|
||||
ref += ' %s' % line.origin.invoice.party.rec_name
|
||||
else:
|
||||
ref = (line.origin.rec_name if line.origin and
|
||||
hasattr(line.origin, 'rec_name') else None)
|
||||
|
||||
# If we dont fill the party in a party_required account, try
|
||||
# get the party field in the line
|
||||
if line.account.party_required and not party:
|
||||
party = line.party
|
||||
|
||||
rline = {
|
||||
'sequence': sequence,
|
||||
'line': line,
|
||||
'ref': (line.origin.rec_name if line.origin
|
||||
and hasattr(line.origin, 'rec_name') else None),
|
||||
'ref': ref,
|
||||
'credit': credit,
|
||||
'debit': debit,
|
||||
'balance': balance,
|
||||
'party': party
|
||||
}
|
||||
|
||||
key = _get_key(currentKey)
|
||||
key = _get_key_id(currentKey)
|
||||
if records.get(key):
|
||||
records[key]['lines'].append(rline)
|
||||
records[key]['total_debit'] += debit
|
||||
|
@ -323,6 +352,7 @@ class GeneralLedgerReport(HTMLReport):
|
|||
'account': line.account.name,
|
||||
'code': line.account.code,
|
||||
'party': line.party.name if line.party else None,
|
||||
'party_required': line.account.party_required,
|
||||
'lines': [rline],
|
||||
'previous_balance': (balance + credit - debit),
|
||||
'total_debit': debit,
|
||||
|
@ -342,7 +372,7 @@ class GeneralLedgerReport(HTMLReport):
|
|||
if balance == 0:
|
||||
continue
|
||||
|
||||
key = '%s %s' % (account.code, account.name)
|
||||
key = account.id
|
||||
if records.get(key):
|
||||
records[key]['total_debit'] += debit
|
||||
records[key]['total_credit'] += credit
|
||||
|
@ -351,6 +381,7 @@ class GeneralLedgerReport(HTMLReport):
|
|||
records[key] = {
|
||||
'account': account.name,
|
||||
'code': account.code,
|
||||
'party_required': line.account.party_required,
|
||||
'lines': [],
|
||||
'previous_balance': (balance + credit - debit),
|
||||
'total_debit': debit,
|
||||
|
@ -389,12 +420,21 @@ class GeneralLedgerReport(HTMLReport):
|
|||
'account': account.name,
|
||||
'code': account.code,
|
||||
'lines': [],
|
||||
'party_required': line.account.party_required,
|
||||
'previous_balance': (balance + credit - debit),
|
||||
'total_debit': debit,
|
||||
'total_credit': credit,
|
||||
'total_balance': balance,
|
||||
}
|
||||
return collections.OrderedDict(sorted(records.items())), parameters
|
||||
|
||||
accounts = {}
|
||||
for record in records.keys():
|
||||
accounts[records[record]['code']+' '+records[record]['account']] = record
|
||||
sorted_records = {}
|
||||
for account in dict(sorted(accounts.items())).values():
|
||||
sorted_records[account] = records[account]
|
||||
|
||||
return sorted_records, parameters
|
||||
|
||||
@classmethod
|
||||
def execute(cls, ids, data):
|
||||
|
@ -409,7 +449,7 @@ class GeneralLedgerReport(HTMLReport):
|
|||
with Transaction().set_context(**context):
|
||||
return super(GeneralLedgerReport, cls).execute(ids, {
|
||||
'name': 'account_reports.general_ledger',
|
||||
'model': 'account.move.line',
|
||||
'model': 'account.account',
|
||||
'records': records,
|
||||
'parameters': parameters,
|
||||
'output_format': data.get('output_format', 'pdf'),
|
||||
|
|
|
@ -1,16 +1,52 @@
|
|||
{% if record.lines %}{% for l in record.lines %}<tr>
|
||||
<td>{{ l.line.date|dateformat }}</td>
|
||||
<td>{% if l.line.move.post_number %}{{ l.line.move.post_number }}{% else %}{{ l.line.move.move_number }}{{ l.line.party and l.line.party.name }}{% endif %}</td>
|
||||
<td>{% if l.ref %}{{ l.ref }}{% endif %}{% if l.ref and l.line.description %} // {% endif %}{{ l.line.description }}</td>
|
||||
<td>{{ l.debit|numberformat }}</td>
|
||||
<td>{{ l.credit|numberformat }}</td>
|
||||
<td>{{ l.balance|numberformat }}</td>
|
||||
</tr>{% endfor %}{% else %}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>{{ _('Previous balance') }}</td>
|
||||
<td>{{ record.total_debit|numberformat }}</td>
|
||||
<td>{{ record.total_credit|numberformat }}</td>
|
||||
<td>{{ (record.total_debit - record.total_credit)|numberformat }}</td>
|
||||
</tr>{% endif %}
|
||||
{% if record.lines and record.party_required %}
|
||||
{% for party, lines in record.lines|groupby('party') %}
|
||||
{% set ns = namespace(total_debit=0,total_credit=0,total_balance=0) %}
|
||||
<tr>
|
||||
<td colspan="2" class="bold">{{ record.code }}</td>
|
||||
<td class="bold">{{ party.rec_name }}</td>
|
||||
<td colspan="2" style="text-align: right;">{% if record.lines %}{{ _('Previous balance...') }}{% endif %}</td>
|
||||
<td style="text-align: right;"> {{ (lines[0].balance+lines[0].credit-lines[0].debit)|render }}</td>
|
||||
</tr>{% for l in lines %}
|
||||
<tr>
|
||||
<td>{{ l.line.date }}</td>
|
||||
<td>{% if l.line.move.post_number %}{{ l.line.move.post_number }}{% else %}{{ l.line.move.move_number }}{{ l.line.party and l.line.party.name }}{% endif %}</td>
|
||||
<td>{% if l.ref %}{{ l.ref }}{% endif %}{% if l.ref and l.line.description %} // {% endif %}{% if l.line and l.line.description %} {{ l.line.description }} {% endif %}</td>
|
||||
<td style="text-align: right;">{{ l.debit|render }} {% set ns.total_debit = ns.total_debit + l.debit %}</td>
|
||||
<td style="text-align: right;">{{ l.credit|render }} {% set ns.total_credit = ns.total_credit + l.credit %}</td>
|
||||
<td style="text-align: right;">{{ l.balance|render }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr class="bold">
|
||||
<td colspan="3" class="right">{{ _('Total Fiscal Year') }}</td>
|
||||
<td style="text-align: right;">{{ ns.total_debit|render }}</td>
|
||||
<td style="text-align: right;">{{ ns.total_credit|render }}</td>
|
||||
<td style="text-align: right;">{{ (ns.total_debit - ns.total_credit)|render }}</td>
|
||||
</tr>
|
||||
<tr class="bold bottom">
|
||||
<td colspan="2" class="bold">{{ record.code }}</td>
|
||||
<td class="bold">{{ party.rec_name }}</td>
|
||||
<td colspan="2" class="left">{{ _('Total') }}</td>
|
||||
<td style="text-align: right;">{{ lines[-1].balance|render }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% elif record.lines %}
|
||||
{% for l in record.lines %}
|
||||
<tr>
|
||||
<td>{{ l.line.date }}</td>
|
||||
<td>{% if l.line.move.post_number %}{{ l.line.move.post_number }}{% else %}{{ l.line.move.move_number }}{{ l.line.party and l.line.party.name }}{% endif %}</td>
|
||||
<td>{% if l.ref %}{{ l.ref }}{% endif %}{% if l.ref and l.line.description %} // {% endif %}{% if l.line and l.line.description %} {{ l.line.description }} {% endif %}</td>
|
||||
<td style="text-align: right;">{{ l.debit|render }}</td>
|
||||
<td style="text-align: right;">{{ l.credit|render }}</td>
|
||||
<td style="text-align: right;">{{ l.balance|render }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>-</td>
|
||||
<td>{{ _('Previous balance') }}</td>
|
||||
<td style="text-align: right;">{{ record.total_debit|render }}</td>
|
||||
<td style="text-align: right;">{{ record.total_credit|render }}</td>
|
||||
<td style="text-align: right;">{{ (record.total_debit - record.total_credit)|render }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
|
|
@ -1,32 +1,36 @@
|
|||
<table>
|
||||
<table style="width: 760px !important;margin-left: -70px !important;">
|
||||
<tr>
|
||||
<th>{{ _('Date') }}</th>
|
||||
<th></th>
|
||||
<th>{{ _('Reference') }} + "//" + {{ _('Description') }}</th>
|
||||
<th>{{ _('Debit') }}</th>
|
||||
<th>{{ _('Credit') }}</th>
|
||||
<th>{{ _('Balance') }}</th>
|
||||
<th>{{ _('Número') }}</th>
|
||||
<th>{{ _('Reference') }} // {{ _('Description') }}</th>
|
||||
<th style="text-align: right;">{{ _('Debit') }}</th>
|
||||
<th style="text-align: right;">{{ _('Credit') }}</th>
|
||||
<th style="text-align: right;">{{ _('Balance') }}</th>
|
||||
</tr>
|
||||
{% for k, record in records.items() %}
|
||||
<tr>
|
||||
<td colspan="4" class="bold">{{ k }}</td>
|
||||
<td class="right">{% if record.lines %}{{ _('Previous balance...') }}{% endif %}</td>
|
||||
<td>{% if record.lines %}{{ record.previous_balance|numberformat }}{% endif %}</td>
|
||||
</tr>
|
||||
{% if not record.party_required %}
|
||||
<tr>
|
||||
<td colspan="2" class="bold">{{ record.code }}</td>
|
||||
<td class="bold">{{ record.account }}</td>
|
||||
<td colspan="2" style="text-align: right;">{% if record.lines %}{{ _('Previous balance...') }}{% endif %}</td>
|
||||
<td style="text-align: right;">{% if record.lines %}{{ record.previous_balance|render }}{% endif %}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
||||
{{ show_detail_lines(record) }}
|
||||
{{ show_detail_lines(record) }}
|
||||
|
||||
<tr class="bold">
|
||||
<td colspan="3" class="right">{{ _('Total Fiscal Year') }}</td>
|
||||
<td>{{ record.total_debit|numberformat }}</td>
|
||||
<td>{{ record.total_credit|numberformat }}</td>
|
||||
<td>{{ (record.total_debit - record.total_credit)|numberformat }}</td>
|
||||
</tr>
|
||||
<tr class="bold">
|
||||
<td colspan="3" style="text-align: right;">{{ _('Total Fiscal Year') }}</td>
|
||||
<td style="text-align: right;">{{ record.total_debit|render }}</td>
|
||||
<td style="text-align: right;">{{ record.total_credit|render }}</td>
|
||||
<td style="text-align: right;">{{ (record.total_debit - record.total_credit)|render }}</td>
|
||||
</tr>
|
||||
|
||||
<tr class="bold bottom">
|
||||
<td colspan="4">{{ k }}</td>
|
||||
<td class="right">{{ _('Total') }}</td>
|
||||
<td>{{ record.total_balance|numberformat }}</td>
|
||||
</tr>
|
||||
<tr class="bold bottom">
|
||||
<td colspan="2" class="bold">{{ record.code }}</td>
|
||||
<td class="bold">{{ record.account }}</td>
|
||||
<td colspan="2" class="left">{{ _('Total') }}</td>
|
||||
<td style="text-align: right;">{{ record.total_balance|render }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
|
||||
{% block style %}
|
||||
<style type="text/css">
|
||||
@media print {
|
||||
@page {
|
||||
size: A4;
|
||||
}
|
||||
|
||||
@media print {
|
||||
#header-details {
|
||||
display: none;
|
||||
}
|
||||
|
@ -17,6 +21,5 @@
|
|||
{% block main %}
|
||||
<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 %}
|
||||
|
|
|
@ -1,40 +1,37 @@
|
|||
<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">
|
||||
<header id="header" style="width: 760px !important;margin-left: -70px !important;">
|
||||
<table>
|
||||
<tr id="header-details">
|
||||
<td>
|
||||
{{ data['parameters']['company'] }}. {{ _('VAT') }}: {{ data['parameters']['company_vat'] }}
|
||||
<h1><em>{{ data['parameters']['company'] }} </em></h1> <br>
|
||||
{{ _('VAT') }}: {{ data['parameters']['company_vat'] }}
|
||||
</td>
|
||||
<td>
|
||||
<br>
|
||||
<h1 style="margin-left: -105px !important;">{{ _('General Ledger') }}</h1>
|
||||
</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">
|
||||
{{ _('Fiscal Year') }}: {{ data['parameters']['fiscal_year'] }}
|
||||
{% if data['parameters']['start_period'] %} {{ _('Start Period') }}: {{ data['parameters']['start_period'].name|render }}{% endif %}
|
||||
{% if data['parameters']['end_period'] %} {{ _('End Period') }}: {{ data['parameters']['end_period'].name|render }}{% endif %} <br>
|
||||
{% 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>
|
||||
<tr>
|
||||
<td colspan="3" >
|
||||
{{ _("When the Move number is between '()' means it hasn't Post Number and the shown number is the provisional one.") }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</header>
|
||||
|
||||
{% endlanguage %}
|
||||
{% endlanguage %}
|
||||
|
|
|
@ -71,4 +71,20 @@ copyright notices and license terms. -->
|
|||
parent="account.menu_reporting" action="wizard_print_taxes_by_invoice"
|
||||
icon="tryton-print"/>
|
||||
</data>
|
||||
</tryton>
|
||||
<data noupdate="1">
|
||||
<record model="html.template.translation" id="report_translation_invoice_ca">
|
||||
<field name="report" ref="report_taxes_by_invoice"/>
|
||||
<field name="src">Invoice</field>
|
||||
<field name="value">Factura</field>
|
||||
<!-- <field name="lang" ref="ir.lang_ca"/> -->
|
||||
<field name="lang">ca</field>
|
||||
</record>
|
||||
<record model="html.template.translation" id="report_translation_invoice_es">
|
||||
<field name="report" ref="report_taxes_by_invoice"/>
|
||||
<field name="src">Invoice</field>
|
||||
<field name="value">Factura</field>
|
||||
<!-- <field name="lang" ref="ir.lang_ca"/> -->
|
||||
<field name="lang">es</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
</thead>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td class="bold">{{ k.name }}</td>
|
||||
<td colspan="11" style="text-align: left !important;padding-left: 35px !important;" class="bold">{{ k.name }}</td>
|
||||
</tr>
|
||||
{% set record = data['records'][k] %}
|
||||
{% if not data['parameters']['totals_only'] %}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
{{ 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>
|
||||
<h1 style="font-size:20px">{% 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']}}
|
||||
|
@ -48,4 +48,4 @@
|
|||
</table>
|
||||
</header>
|
||||
|
||||
{% endlanguage %}
|
||||
{% endlanguage %}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue