diff --git a/l10n_es_aeat/models/l10n_es_aeat_report.py b/l10n_es_aeat/models/l10n_es_aeat_report.py index 4e8f98a7634..6305086add0 100644 --- a/l10n_es_aeat/models/l10n_es_aeat_report.py +++ b/l10n_es_aeat/models/l10n_es_aeat_report.py @@ -8,7 +8,7 @@ import re from calendar import monthrange from odoo import _, api, fields, exceptions, models -from odoo.tools import config +from odoo.tools import config, ormcache from datetime import datetime from .spanish_states_mapping import SPANISH_STATES as ss @@ -202,6 +202,24 @@ def _check_previous_number(self): "a previous declaration number should be provided.") ) + @ormcache('tax_template', 'company_id') + def _get_tax_id_from_tax_template(self, tax_template, company_id): + xmlids = self.env['ir.model.data'].search_read([ + ('model', '=', 'account.tax.template'), + ('res_id', '=', tax_template.id) + ], ['name', 'module']) + return xmlids and self.env['ir.model.data'].search([ + ('model', '=', 'account.tax'), + ('module', '=', xmlids[0]['module']), + ('name', '=', '{}_{}'.format(company_id, xmlids[0]['name'])) + ]).res_id or False + + def get_taxes_from_templates(self, tax_templates): + company_id = self.company_id.id or self.env.user.company_id.id + tax_ids = [self._get_tax_id_from_tax_template(tmpl, company_id) + for tmpl in tax_templates] + return self.env['account.tax'].browse(tax_ids) + @api.onchange('company_id') def onchange_company_id(self): """Load some company data (the VAT number) when company changes. diff --git a/l10n_es_vat_book/README.rst b/l10n_es_vat_book/README.rst index ad19d1a66da..a37cf6f4a71 100644 --- a/l10n_es_vat_book/README.rst +++ b/l10n_es_vat_book/README.rst @@ -23,7 +23,7 @@ Libro de IVA :target: https://runbot.odoo-community.org/runbot/189/11.0 :alt: Try me on Runbot -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| Módulo que calcula el libro de IVA español. diff --git a/l10n_es_vat_book/__manifest__.py b/l10n_es_vat_book/__manifest__.py index 6b4f21f23e2..9f6b5ec4080 100644 --- a/l10n_es_vat_book/__manifest__.py +++ b/l10n_es_vat_book/__manifest__.py @@ -20,7 +20,8 @@ 'data': [ 'security/ir_rule.xml', 'security/ir.model.access.csv', - 'data/map_taxes_vat_book.xml', + 'data/aeat_vat_book_map_data.xml', + 'views/aeat_vat_book_map_view.xml', 'views/l10n_es_vat_book.xml', 'views/l10n_es_vat_book_line.xml', 'views/l10n_es_vat_book_tax_summary.xml', diff --git a/l10n_es_vat_book/data/aeat_vat_book_map_data.xml b/l10n_es_vat_book/data/aeat_vat_book_map_data.xml new file mode 100644 index 00000000000..177bf51c86b --- /dev/null +++ b/l10n_es_vat_book/data/aeat_vat_book_map_data.xml @@ -0,0 +1,105 @@ + + + + + IVA repercutido + issued + + N + O + + + + + IVA soportado + received + + O + P + + + + + IVA soportado no deducible + received + + + + + + Recargo Eq. + issued + req + P + Q + + + + + Recargo Eq. + received + req + R + S + + + + diff --git a/l10n_es_vat_book/data/map_taxes_vat_book.xml b/l10n_es_vat_book/data/map_taxes_vat_book.xml deleted file mode 100644 index 37d149b0aee..00000000000 --- a/l10n_es_vat_book/data/map_taxes_vat_book.xml +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - 340 - - - - 01 - - - SuministroFactEmitidas Sujetas Bienes - - - - 02 - - - SuministroFactEmitidas Sujetas ISP - - - - 03 - - - SuministroFactEmitidas No Sujeta - - - - 04 - - - SuministroFactEmitidas Servicios No Sujeta - - - 05 - - - SuministroFactEmitidas Sujetas Servicios - - - - 06 - - - SuministroFactEmitidas Bienes Exento - - - - 07 - - - SuministroFactEmitidas Servicios Exento - - - - 08 - - - SuministroFactRecibidas Sujetas - - - - 09 - - - SuministroFactRecibidas Sujetas Agricultura - - - - 10 - - - SuministroFactRecibidas ISP - - - - 11 - - - SuministroFactRecibidas Bienes de Inversión - - - - 12 - - - SuministroFactRecibidas No Sujeta - - - - 13 - - - SuministroFact Recargo Equivalencia - - - - 14 - - - SuministroFactRecibidas No Deducible - - diff --git a/l10n_es_vat_book/i18n/es.po b/l10n_es_vat_book/i18n/es.po index b2778e40b18..d2e31d9cf35 100644 --- a/l10n_es_vat_book/i18n/es.po +++ b/l10n_es_vat_book/i18n/es.po @@ -6,21 +6,34 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-08-08 11:17+0000\n" -"PO-Revision-Date: 2018-08-08 11:17+0000\n" -"Last-Translator: <>\n" +"POT-Creation-Date: 2019-10-28 23:52+0100\n" +"PO-Revision-Date: 2019-10-28 23:53+0100\n" +"Last-Translator: Carlos Dauden \n" "Language-Team: \n" -"Language: \n" +"Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" +"Content-Transfer-Encoding: 8bit\n" "Plural-Forms: \n" +"X-Generator: Poedit 1.8.7.1\n" #. module: l10n_es_vat_book #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_summary msgid "Total" msgstr "Total" +#. module: l10n_es_vat_book +#: model:ir.model,name:l10n_es_vat_book.model_aeat_vat_book_map_line +msgid "AEAT Vat Book Map Line" +msgstr "Linea ,apeo libro de IVA AEAT" + +#. module: l10n_es_vat_book +#: model:ir.actions.act_window,name:l10n_es_vat_book.action_aeat_vat_book_mapping +#: model:ir.ui.menu,name:l10n_es_vat_book.menu_aeat_vat_book_map +#: model:ir.ui.view,arch_db:l10n_es_vat_book.l10n_es_aeat_vat_book_map_lines_view_tree +msgid "AEAT vat book map" +msgstr "Mapeo AEAT libro de IVA" + #. module: l10n_es_vat_book #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_tax_summary_tax_id msgid "Account Tax" @@ -42,11 +55,10 @@ msgid "BOOK REGISTER OF INVOICES RECEIVED" msgstr "LIBRO REGISTRO DE FACTURAS RECIBIDAS" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:23 +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_base_amount #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_base_amount #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_invoices_head #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_taxes_head -#, python-format msgid "Base" msgstr "Base" @@ -56,6 +68,11 @@ msgstr "Base" msgid "Base amount" msgstr "Importe base" +#. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_fee_amount_xlsx_column +msgid "Base xlsx column" +msgstr "Columna xlsx base" + #. module: l10n_es_vat_book #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_summary_book_type #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_tax_summary_book_type @@ -88,6 +105,7 @@ msgid "Contact phone:" msgstr "Teléfono de contacto:" #. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_create_uid #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_create_uid #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_create_uid #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_create_uid @@ -97,6 +115,7 @@ msgid "Created by" msgstr "Creado por" #. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_create_date #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_create_date #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_create_date #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_create_date @@ -105,18 +124,13 @@ msgstr "Creado por" msgid "Created on" msgstr "Creado en" -#. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:20 -#, python-format -msgid "Date" -msgstr "Fecha" - #. module: l10n_es_vat_book #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_dates msgid "Date Range:" msgstr "Rango de fechas:" #. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_display_name #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_display_name #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_display_name #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_display_name @@ -136,11 +150,6 @@ msgstr "Empresa" msgid "Entry number" msgstr "Nº entrada" -#. module: l10n_es_vat_book -#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_exception -msgid "Exception" -msgstr "Excepción" - #. module: l10n_es_vat_book #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_exception_text msgid "Exception text" @@ -148,8 +157,13 @@ msgstr "Texto de excepción" #. module: l10n_es_vat_book #: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form -msgid "Export to XLSX" -msgstr "Exportar a XLSX" +msgid "Export BOE" +msgstr "Exportar BOE" + +#. module: l10n_es_vat_book +#: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form +msgid "Export draft" +msgstr "Exportar borrador" #. module: l10n_es_vat_book #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_external_ref @@ -157,10 +171,8 @@ msgid "External Reference" msgstr "Referencia externa" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:25 #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_invoices_head #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_taxes_head -#, python-format msgid "Fee" msgstr "Cuota" @@ -170,6 +182,7 @@ msgid "Fiscal Year:" msgstr "Año fiscal:" #. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_id #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_id #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_id #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_id @@ -180,9 +193,12 @@ msgid "ID" msgstr "ID (identificación)" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:19 +#: selection:l10n.es.vat.book.line.tax,special_tax_group:0 +msgid "IRPF" +msgstr "IRPF" + +#. module: l10n_es_vat_book #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_invoice_id -#, python-format msgid "Invoice" msgstr "Factura" @@ -204,19 +220,15 @@ msgid "Issued" msgstr "Emitida" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:59 #: model:ir.ui.view,arch_db:l10n_es_vat_book.report_vat_book_invoices_issued_document #: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form -#, python-format msgid "Issued Invoices" msgstr "Facturas emitidas" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:63 #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_rectification_issued_line_ids #: model:ir.ui.view,arch_db:l10n_es_vat_book.report_vat_book_invoices_issued_document #: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form -#, python-format msgid "Issued Refund Invoices" msgstr "Facturas rectificativas emitidas" @@ -227,6 +239,7 @@ msgstr "Resumen Emitidas" #. module: l10n_es_vat_book #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_issued_tax_summary_ids +#: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form msgid "Issued Tax Summary" msgstr "Resumen Impuestos Emitidas" @@ -248,6 +261,7 @@ msgid "Journal Entry" msgstr "Asiento contable" #. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line___last_update #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book___last_update #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line___last_update #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax___last_update @@ -258,6 +272,7 @@ msgid "Last Modified on" msgstr "Última modificación en" #. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_write_uid #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_write_uid #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_write_uid #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_summary_write_uid @@ -267,6 +282,7 @@ msgid "Last Updated by" msgstr "Última actualización de" #. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_write_date #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_write_date #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_write_date #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_summary_write_date @@ -302,10 +318,14 @@ msgid "NIF" msgstr "NIF" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/models/l10n_es_vat_book.py:328 -#, python-format -msgid "No AEAT Tax Mapping was found" -msgstr "No se encontró Mapeo de Impuestos AEAT" +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_name +msgid "Name" +msgstr "Nombre" + +#. module: l10n_es_vat_book +#: selection:aeat.vat.book.map.line,type_tax_use:0 +msgid "None" +msgstr "Ninguno" #. module: l10n_es_vat_book #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_invoices_head @@ -313,10 +333,14 @@ msgid "Number" msgstr "Número" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:21 -#, python-format -msgid "Partner" -msgstr "Empresa" +#: selection:aeat.vat.book.map.line,type_tax_use:0 +msgid "Purchases" +msgstr "Compras" + +#. module: l10n_es_vat_book +#: selection:l10n.es.vat.book.line.tax,special_tax_group:0 +msgid "R.Eq." +msgstr "R.Eq." #. module: l10n_es_vat_book #: selection:l10n.es.vat.book.line,line_type:0 @@ -326,19 +350,15 @@ msgid "Received" msgstr "Recibida" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:67 #: model:ir.ui.view,arch_db:l10n_es_vat_book.report_vat_book_invoices_received_document #: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form -#, python-format msgid "Received Invoices" msgstr "Facturas recibidas" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:71 #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_rectification_received_line_ids #: model:ir.ui.view,arch_db:l10n_es_vat_book.report_vat_book_invoices_received_document #: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form -#, python-format msgid "Received Refund Invoices" msgstr "Facturas rectificativas recibidas" @@ -349,8 +369,9 @@ msgstr "Resumen recibidas" #. module: l10n_es_vat_book #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_received_tax_summary_ids +#: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form msgid "Received Tax Summary" -msgstr "Resumen impuestos recibidas" +msgstr "Resumen Impuestos Recibidas" #. module: l10n_es_vat_book #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_received_line_ids @@ -358,9 +379,7 @@ msgid "Received invoices" msgstr "Facturas recibidas" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:29 #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_ref -#, python-format msgid "Reference" msgstr "Referencia" @@ -374,6 +393,39 @@ msgstr "Rectificativa emitida" msgid "Refund Received" msgstr "Rectificativa recibida" +#. module: l10n_es_vat_book +#: selection:aeat.vat.book.map.line,type_tax_use:0 +msgid "Sales" +msgstr "Ventas" + +#. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_special_tax_id +msgid "Special Tax" +msgstr "Impto. especial" + +#. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_special_tax_amount +msgid "Special Tax fee" +msgstr "Cuota impto. especial" + +#. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_special_tax_group +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_special_tax_group +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_special_tax_group +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_summary_special_tax_group +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_tax_summary_special_tax_group +msgid "Special group" +msgstr "Grupo especial" + +#. module: l10n_es_vat_book +#: model:ir.model.fields,help:l10n_es_vat_book.field_aeat_vat_book_map_line_special_tax_group +#: model:ir.model.fields,help:l10n_es_vat_book.field_l10n_es_vat_book_line_special_tax_group +#: model:ir.model.fields,help:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_special_tax_group +#: model:ir.model.fields,help:l10n_es_vat_book.field_l10n_es_vat_book_summary_special_tax_group +#: model:ir.model.fields,help:l10n_es_vat_book.field_l10n_es_vat_book_tax_summary_special_tax_group +msgid "Special tax group as R.Eq, IRPF, etc" +msgstr "Grupo de impuesto especial como R.Eq, IRPF, etc." + #. module: l10n_es_vat_book #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_summary_ids #: model:ir.ui.view,arch_db:l10n_es_vat_book.report_vat_book_invoices_issued_document @@ -390,11 +442,9 @@ msgid "Surnames and name contact:" msgstr "Apellidos y nombre de contacto:" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:24 #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_tax_id #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_invoices_head #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_taxes_head -#, python-format msgid "Tax" msgstr "Impuesto" @@ -408,6 +458,11 @@ msgstr "Líneas del impuesto" msgid "Tax Rate (%)" msgstr "Tipo Impositivo (%)" +#. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_type_tax_use +msgid "Tax Scope" +msgstr "Ámbito del impuesto" + #. module: l10n_es_vat_book #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_tax_summary_ids #: model:ir.ui.view,arch_db:l10n_es_vat_book.view_vat_book_tax_summary_form @@ -427,33 +482,34 @@ msgid "Tax fee" msgstr "Cuota" #. module: l10n_es_vat_book -#: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form -msgid "Tax summary" -msgstr "Resumen impuestos" - -#. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_tax_tmpl_ids #: model:ir.ui.view,arch_db:l10n_es_vat_book.view_vat_book_line_form msgid "Taxes" msgstr "Impuestos" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/models/l10n_es_vat_book.py:261 +#: model:ir.model,name:l10n_es_vat_book.model_account_tax_template +msgid "Templates for Taxes" +msgstr "Plantilla de impuestos" + +#. module: l10n_es_vat_book +#: code:addons/l10n_es_vat_book/models/l10n_es_vat_book.py:467 #, python-format -msgid "The partner doesn't have a VAT number" -msgstr "La empresa no tiene NIF" +msgid "This book has warnings. Fix it before confirm" +msgstr "Este libro contiene advertencias. Arréglelas antes de confirmar." #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/models/l10n_es_vat_book.py:312 +#: code:addons/l10n_es_vat_book/models/l10n_es_vat_book.py:365 #, python-format msgid "This company doesn't have VAT" msgstr "Esta compañía no tiene NIF" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:26 #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_total_amount +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_total_amount #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_invoices_head #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_taxes_head -#, python-format +#: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form msgid "Total" msgstr "Total" @@ -464,9 +520,17 @@ msgid "Total amount" msgstr "Importe Total" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:22 +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_total_amount_special_include +msgid "Total w/Special" +msgstr "Total especial incl." + +#. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_fee_type_xlsx_column +msgid "Type xlsx column" +msgstr "Columna xlsx tipo" + +#. module: l10n_es_vat_book #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_invoices_head -#, python-format msgid "VAT" msgstr "NIF" @@ -527,6 +591,12 @@ msgstr "Ver facturas emitidas" msgid "View Received Invoices" msgstr "Ver facturas recibidas" +#. module: l10n_es_vat_book +#: code:addons/l10n_es_vat_book/models/l10n_es_vat_book.py:330 +#, python-format +msgid "Without VAT" +msgstr "Sin NIF" + #. module: l10n_es_vat_book #: model:ir.model,name:l10n_es_vat_book.model_l10n_es_vat_book msgid "l10n.es.vat.book" diff --git a/l10n_es_vat_book/i18n/l10n_es_vat_book.pot b/l10n_es_vat_book/i18n/l10n_es_vat_book.pot index e258c855e29..654b13cd303 100644 --- a/l10n_es_vat_book/i18n/l10n_es_vat_book.pot +++ b/l10n_es_vat_book/i18n/l10n_es_vat_book.pot @@ -6,6 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-10-28 22:52+0000\n" +"PO-Revision-Date: 2019-10-28 22:52+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -18,6 +20,18 @@ msgstr "" msgid "Total" msgstr "" +#. module: l10n_es_vat_book +#: model:ir.model,name:l10n_es_vat_book.model_aeat_vat_book_map_line +msgid "AEAT Vat Book Map Line" +msgstr "" + +#. module: l10n_es_vat_book +#: model:ir.actions.act_window,name:l10n_es_vat_book.action_aeat_vat_book_mapping +#: model:ir.ui.menu,name:l10n_es_vat_book.menu_aeat_vat_book_map +#: model:ir.ui.view,arch_db:l10n_es_vat_book.l10n_es_aeat_vat_book_map_lines_view_tree +msgid "AEAT vat book map" +msgstr "" + #. module: l10n_es_vat_book #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_tax_summary_tax_id msgid "Account Tax" @@ -39,11 +53,10 @@ msgid "BOOK REGISTER OF INVOICES RECEIVED" msgstr "" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:23 +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_base_amount #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_base_amount #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_invoices_head #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_taxes_head -#, python-format msgid "Base" msgstr "" @@ -53,6 +66,11 @@ msgstr "" msgid "Base amount" msgstr "" +#. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_fee_amount_xlsx_column +msgid "Base xlsx column" +msgstr "" + #. module: l10n_es_vat_book #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_summary_book_type #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_tax_summary_book_type @@ -85,6 +103,7 @@ msgid "Contact phone:" msgstr "" #. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_create_uid #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_create_uid #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_create_uid #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_create_uid @@ -94,6 +113,7 @@ msgid "Created by" msgstr "" #. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_create_date #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_create_date #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_create_date #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_create_date @@ -102,18 +122,13 @@ msgstr "" msgid "Created on" msgstr "" -#. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:20 -#, python-format -msgid "Date" -msgstr "" - #. module: l10n_es_vat_book #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_dates msgid "Date Range:" msgstr "" #. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_display_name #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_display_name #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_display_name #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_display_name @@ -134,18 +149,18 @@ msgid "Entry number" msgstr "" #. module: l10n_es_vat_book -#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_exception -msgid "Exception" +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_exception_text +msgid "Exception text" msgstr "" #. module: l10n_es_vat_book -#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_exception_text -msgid "Exception text" +#: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form +msgid "Export BOE" msgstr "" #. module: l10n_es_vat_book #: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form -msgid "Export to XLSX" +msgid "Export draft" msgstr "" #. module: l10n_es_vat_book @@ -154,10 +169,8 @@ msgid "External Reference" msgstr "" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:25 #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_invoices_head #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_taxes_head -#, python-format msgid "Fee" msgstr "" @@ -167,6 +180,7 @@ msgid "Fiscal Year:" msgstr "" #. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_id #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_id #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_id #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_id @@ -177,9 +191,12 @@ msgid "ID" msgstr "" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:19 +#: selection:l10n.es.vat.book.line.tax,special_tax_group:0 +msgid "IRPF" +msgstr "" + +#. module: l10n_es_vat_book #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_invoice_id -#, python-format msgid "Invoice" msgstr "" @@ -201,19 +218,15 @@ msgid "Issued" msgstr "" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:59 #: model:ir.ui.view,arch_db:l10n_es_vat_book.report_vat_book_invoices_issued_document #: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form -#, python-format msgid "Issued Invoices" msgstr "" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:63 #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_rectification_issued_line_ids #: model:ir.ui.view,arch_db:l10n_es_vat_book.report_vat_book_invoices_issued_document #: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form -#, python-format msgid "Issued Refund Invoices" msgstr "" @@ -224,6 +237,7 @@ msgstr "" #. module: l10n_es_vat_book #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_issued_tax_summary_ids +#: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form msgid "Issued Tax Summary" msgstr "" @@ -245,6 +259,7 @@ msgid "Journal Entry" msgstr "" #. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line___last_update #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book___last_update #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line___last_update #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax___last_update @@ -255,6 +270,7 @@ msgid "Last Modified on" msgstr "" #. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_write_uid #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_write_uid #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_write_uid #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_summary_write_uid @@ -264,6 +280,7 @@ msgid "Last Updated by" msgstr "" #. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_write_date #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_write_date #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_write_date #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_summary_write_date @@ -299,9 +316,13 @@ msgid "NIF" msgstr "" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/models/l10n_es_vat_book.py:328 -#, python-format -msgid "No AEAT Tax Mapping was found" +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_name +msgid "Name" +msgstr "" + +#. module: l10n_es_vat_book +#: selection:aeat.vat.book.map.line,type_tax_use:0 +msgid "None" msgstr "" #. module: l10n_es_vat_book @@ -310,9 +331,13 @@ msgid "Number" msgstr "" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:21 -#, python-format -msgid "Partner" +#: selection:aeat.vat.book.map.line,type_tax_use:0 +msgid "Purchases" +msgstr "" + +#. module: l10n_es_vat_book +#: selection:l10n.es.vat.book.line.tax,special_tax_group:0 +msgid "R.Eq." msgstr "" #. module: l10n_es_vat_book @@ -323,19 +348,15 @@ msgid "Received" msgstr "" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:67 #: model:ir.ui.view,arch_db:l10n_es_vat_book.report_vat_book_invoices_received_document #: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form -#, python-format msgid "Received Invoices" msgstr "" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:71 #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_rectification_received_line_ids #: model:ir.ui.view,arch_db:l10n_es_vat_book.report_vat_book_invoices_received_document #: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form -#, python-format msgid "Received Refund Invoices" msgstr "" @@ -346,6 +367,7 @@ msgstr "" #. module: l10n_es_vat_book #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_received_tax_summary_ids +#: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form msgid "Received Tax Summary" msgstr "" @@ -355,9 +377,7 @@ msgid "Received invoices" msgstr "" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:29 #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_ref -#, python-format msgid "Reference" msgstr "" @@ -371,6 +391,39 @@ msgstr "" msgid "Refund Received" msgstr "" +#. module: l10n_es_vat_book +#: selection:aeat.vat.book.map.line,type_tax_use:0 +msgid "Sales" +msgstr "" + +#. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_special_tax_id +msgid "Special Tax" +msgstr "" + +#. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_special_tax_amount +msgid "Special Tax fee" +msgstr "" + +#. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_special_tax_group +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_special_tax_group +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_special_tax_group +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_summary_special_tax_group +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_tax_summary_special_tax_group +msgid "Special group" +msgstr "" + +#. module: l10n_es_vat_book +#: model:ir.model.fields,help:l10n_es_vat_book.field_aeat_vat_book_map_line_special_tax_group +#: model:ir.model.fields,help:l10n_es_vat_book.field_l10n_es_vat_book_line_special_tax_group +#: model:ir.model.fields,help:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_special_tax_group +#: model:ir.model.fields,help:l10n_es_vat_book.field_l10n_es_vat_book_summary_special_tax_group +#: model:ir.model.fields,help:l10n_es_vat_book.field_l10n_es_vat_book_tax_summary_special_tax_group +msgid "Special tax group as R.Eq, IRPF, etc" +msgstr "" + #. module: l10n_es_vat_book #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_summary_ids #: model:ir.ui.view,arch_db:l10n_es_vat_book.report_vat_book_invoices_issued_document @@ -387,11 +440,9 @@ msgid "Surnames and name contact:" msgstr "" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:24 #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_tax_id #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_invoices_head #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_taxes_head -#, python-format msgid "Tax" msgstr "" @@ -405,6 +456,11 @@ msgstr "" msgid "Tax Rate (%)" msgstr "" +#. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_type_tax_use +msgid "Tax Scope" +msgstr "" + #. module: l10n_es_vat_book #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_tax_summary_ids #: model:ir.ui.view,arch_db:l10n_es_vat_book.view_vat_book_tax_summary_form @@ -424,33 +480,34 @@ msgid "Tax fee" msgstr "" #. module: l10n_es_vat_book -#: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form -msgid "Tax summary" +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_tax_tmpl_ids +#: model:ir.ui.view,arch_db:l10n_es_vat_book.view_vat_book_line_form +msgid "Taxes" msgstr "" #. module: l10n_es_vat_book -#: model:ir.ui.view,arch_db:l10n_es_vat_book.view_vat_book_line_form -msgid "Taxes" +#: model:ir.model,name:l10n_es_vat_book.model_account_tax_template +msgid "Templates for Taxes" msgstr "" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/models/l10n_es_vat_book.py:261 +#: code:addons/l10n_es_vat_book/models/l10n_es_vat_book.py:467 #, python-format -msgid "The partner doesn't have a VAT number" +msgid "This book has warnings. Fix it before confirm" msgstr "" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/models/l10n_es_vat_book.py:312 +#: code:addons/l10n_es_vat_book/models/l10n_es_vat_book.py:365 #, python-format msgid "This company doesn't have VAT" msgstr "" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:26 #: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_total_amount +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_total_amount #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_invoices_head #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_taxes_head -#, python-format +#: model:ir.ui.view,arch_db:l10n_es_vat_book.view_l10n_es_vat_book_form msgid "Total" msgstr "" @@ -461,9 +518,17 @@ msgid "Total amount" msgstr "" #. module: l10n_es_vat_book -#: code:addons/l10n_es_vat_book/report/vat_book_xlsx.py:22 +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book_line_tax_total_amount_special_include +msgid "Total w/Special" +msgstr "" + +#. module: l10n_es_vat_book +#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line_fee_type_xlsx_column +msgid "Type xlsx column" +msgstr "" + +#. module: l10n_es_vat_book #: model:ir.ui.view,arch_db:l10n_es_vat_book.vat_book_invoices_head -#, python-format msgid "VAT" msgstr "" @@ -524,6 +589,12 @@ msgstr "" msgid "View Received Invoices" msgstr "" +#. module: l10n_es_vat_book +#: code:addons/l10n_es_vat_book/models/l10n_es_vat_book.py:330 +#, python-format +msgid "Without VAT" +msgstr "" + #. module: l10n_es_vat_book #: model:ir.model,name:l10n_es_vat_book.model_l10n_es_vat_book msgid "l10n.es.vat.book" diff --git a/l10n_es_vat_book/models/__init__.py b/l10n_es_vat_book/models/__init__.py index 6ecac224da1..53b55bca790 100644 --- a/l10n_es_vat_book/models/__init__.py +++ b/l10n_es_vat_book/models/__init__.py @@ -1,3 +1,4 @@ +from . import aeat_vat_book_map_line from . import l10n_es_vat_book from . import l10n_es_vat_book_line from . import l10n_es_vat_book_line_tax diff --git a/l10n_es_vat_book/models/aeat_vat_book_map_line.py b/l10n_es_vat_book/models/aeat_vat_book_map_line.py new file mode 100644 index 00000000000..6a24d3bb73c --- /dev/null +++ b/l10n_es_vat_book/models/aeat_vat_book_map_line.py @@ -0,0 +1,39 @@ +# Copyright 2019 Tecnativa - Carlos Dauden +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class AeatVatBookMapLines(models.Model): + _name = 'aeat.vat.book.map.line' + _description = 'AEAT Vat Book Map Line' + + def _selection_special_tax_group(self): + return self.env['l10n.es.vat.book.line.tax'].fields_get( + allfields=['special_tax_group'])['special_tax_group']['selection'] + + name = fields.Char( + string='Name', + ) + book_type = fields.Selection( + selection=[ + ('issued', 'Issued'), + ('received', 'Received'), + ], + string='Book type', + ) + special_tax_group = fields.Selection( + selection=_selection_special_tax_group, + string='Special group', + help='Special tax group as R.Eq, IRPF, etc', + ) + fee_type_xlsx_column = fields.Char( + string='Type xlsx column' + ) + fee_amount_xlsx_column = fields.Char( + string='Base xlsx column' + ) + tax_tmpl_ids = fields.Many2many( + comodel_name='account.tax.template', + string="Taxes", + ) diff --git a/l10n_es_vat_book/models/l10n_es_vat_book.py b/l10n_es_vat_book/models/l10n_es_vat_book.py index ce2a19ac26a..1cd009e9ddf 100644 --- a/l10n_es_vat_book/models/l10n_es_vat_book.py +++ b/l10n_es_vat_book/models/l10n_es_vat_book.py @@ -3,11 +3,14 @@ # Copyright 2017 Eficent Business and IT Consulting Services, S.L. # # Copyright 2018 Luis M. Ontalba +# Copyright 2019 Tecnativa - Carlos Dauden # License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0 import datetime +import re from odoo import models, api, fields, _ from odoo.exceptions import Warning as UserError +from odoo.tools import ormcache class L10nEsVatBook(models.Model): @@ -117,6 +120,7 @@ def _prepare_vat_book_tax_summary(self, tax_lines, book_type): 'total_amount': 0.0, 'tax_id': tax_line.tax_id.id, 'vat_book_id': self.id, + 'special_tax_group': tax_line.special_tax_group, } tax_summary_data_recs[tax_line.tax_id]['base_amount'] += \ tax_line.base_amount @@ -134,25 +138,38 @@ def _create_vat_book_tax_summary(self, tax_summary_data_recs, tax_summary_data_recs[tax_id]) return tax_summary - @api.model def _prepare_vat_book_summary(self, tax_summary_recs, book_type): - base_amount = sum(tax_summary_recs.mapped('base_amount')) - tax_amount = sum(tax_summary_recs.mapped('tax_amount')) - total_amount = sum(tax_summary_recs.mapped('total_amount')) - return { - 'book_type': book_type, - 'base_amount': base_amount, - 'tax_amount': tax_amount, - 'total_amount': total_amount, - 'vat_book_id': self.id, - } + vals_list = [] + total_dic = {} + for line in tax_summary_recs: + if line.special_tax_group not in total_dic: + total_dic[line.special_tax_group] = { + 'base_amount': line.base_amount, + 'tax_amount': line.tax_amount, + 'total_amount': line.total_amount, + } + else: + total_group = total_dic[line.special_tax_group] + total_group['base_amount'] += line.base_amount + total_group['tax_amount'] += line.tax_amount + total_group['total_amount'] += line.total_amount + for key, total_group in total_dic.items(): + vals_list.append({ + 'book_type': book_type, + 'special_tax_group': key, + 'base_amount': total_group['base_amount'], + 'tax_amount': total_group['tax_amount'], + 'total_amount': total_group['total_amount'], + 'vat_book_id': self.id, + }) + return vals_list @api.model def _create_vat_book_summary(self, tax_summary_recs, book_type): - vals = self._prepare_vat_book_summary(tax_summary_recs, book_type) - self.env['l10n.es.vat.book.summary'].create(vals) + for vals in self._prepare_vat_book_summary( + tax_summary_recs, book_type): + self.env['l10n.es.vat.book.summary'].create(vals) - @api.multi def calculate(self): """ Funcion call from vat_book @@ -160,114 +177,101 @@ def calculate(self): self._calculate_vat_book() return True - def _get_vals_invoice_line(self, move, line_type): + def _prepare_book_line_vals(self, move_line, line_type): """ This function make the dictionary to create a new record in issued invoices, Received invoices or rectification invoices Args: - move (obj): move + move_line (obj): move Returns: dictionary: Vals from the new record. """ - ref = move.ref + ref = move_line.ref ext_ref = '' - invoice = move.line_ids.mapped('invoice_id')[:1] - partner = move.partner_id + invoice = move_line.invoice_id + partner = move_line.partner_id if invoice: partner = invoice.commercial_partner_id ref = invoice.number ext_ref = invoice.reference return { 'line_type': line_type, - 'invoice_date': move.date, + 'invoice_date': move_line.date, 'partner_id': partner.id, 'vat_number': partner.vat, 'invoice_id': invoice.id, 'ref': ref, 'external_ref': ext_ref, 'vat_book_id': self.id, - 'move_id': move.id, + 'move_id': move_line.move_id.id, + 'tax_lines': {}, + 'base_amount': 0.0, + 'special_tax_group': False, } - def _get_vat_book_line_tax(self, tax, move, vat_book_line): - base_move_lines = move.line_ids.filtered( - lambda l: any(t == tax for t in l.tax_ids)) - base_amount_untaxed = sum(x.credit - x.debit for x in base_move_lines) - - parent_tax = self.env['account.tax'].search([ - ('children_tax_ids.id', '=', tax.id)], limit=1) - taxes = self.env['account.tax'] - if parent_tax: - taxes = tax.children_tax_ids - tax = parent_tax - else: - taxes += tax - fee_move_lines = move.line_ids.filtered( - lambda l: l.tax_line_id in taxes) - fee_amount_untaxed = 0.0 - if fee_move_lines: - fee_amount_untaxed = sum( - x.credit - x.debit for x in fee_move_lines) - - if vat_book_line.line_type == 'issued' and fee_amount_untaxed < 0.0: - vat_book_line.line_type = 'rectification_issued' - - if vat_book_line.line_type == 'received' and fee_amount_untaxed > 0.0: - vat_book_line.line_type = 'rectification_received' - - if vat_book_line.line_type in ['received', 'rectification_received']: - base_amount_untaxed *= -1 - fee_amount_untaxed *= -1 - + def _prepare_book_line_tax_vals(self, move_line, vat_book_line): + balance = move_line.credit - move_line.debit + if vat_book_line['line_type'] in [ + 'received', 'rectification_received']: + balance = -balance + base_amount_untaxed = balance if move_line.tax_ids else 0.0 + fee_amount_untaxed = balance if move_line.tax_line_id else 0.0 return { - 'tax_id': tax.id, + 'tax_id': move_line.tax_line_id.id, 'base_amount': base_amount_untaxed, 'tax_amount': fee_amount_untaxed, 'total_amount': base_amount_untaxed + fee_amount_untaxed, - 'move_line_ids': [(4, aml.id) for aml - in base_move_lines + fee_move_lines], - 'vat_book_line_id': vat_book_line.id, + 'move_line_ids': [(4, move_line.id)], + 'special_tax_group': False, } - def _create_vat_book_line_tax(self, tax, vat_book_line_id, - move): - vat_book_line_tax_obj = self.env['l10n.es.vat.book.line.tax'] - vals = self._get_vat_book_line_tax(tax, move, vat_book_line_id) - - new_record = vat_book_line_tax_obj.create(vals) - - return new_record - - def _create_vat_book_line(self, move, line_type): - """ - This function create a new record in issued invoices, Received - invoices or rectification invoices - - Args: - move (obj): move - - Returns: - obj: obj with new object create depends invoice type. - """ - vat_book_line_obj = self.env['l10n.es.vat.book.line'] - - vals = self._get_vals_invoice_line(move, line_type) - exception_text = "" - exception = False - if vals['invoice_id'] and not vals['vat_number']: - exception = True - exception_text += _("The partner doesn't have a VAT number") - - if exception: - vals.update({ - 'exception': True, - 'exception_text': exception_text, + def upsert_book_line_tax(self, move_line, vat_book_line, implied_taxes): + vals = self._prepare_book_line_tax_vals(move_line, vat_book_line) + tax_lines = vat_book_line['tax_lines'] + implied_lines = [] + if move_line.tax_line_id: + key = self.get_book_line_tax_key(move_line, move_line.tax_line_id) + if key not in tax_lines: + tax_lines[key] = vals + else: + tax_lines[key]['tax_amount'] += vals['tax_amount'] + tax_lines[key]['total_amount'] += vals['total_amount'] + tax_lines[key]['move_line_ids'] += vals['move_line_ids'] + implied_lines.append(tax_lines[key]) + for i, tax in enumerate(move_line.tax_ids): + if i == 0: + vat_book_line['base_amount'] += vals['base_amount'] + if tax not in implied_taxes: + continue + key = self.get_book_line_tax_key(move_line, tax) + if key not in tax_lines: + tax_lines[key] = vals + tax_lines[key]['tax_id'] = tax.id + else: + tax_lines[key]['base_amount'] += vals['base_amount'] + tax_lines[key]['total_amount'] += vals['total_amount'] + # if i == 0: + tax_lines[key]['move_line_ids'] += vals['move_line_ids'] + implied_lines.append(tax_lines[key]) + sp_taxes_dic = self.get_special_taxes_dic() + if tax.id in sp_taxes_dic: + tax_group = sp_taxes_dic[tax.id]['special_tax_group'] + vat_book_line['special_tax_group'] = tax_group + tax_lines[key]['special_tax_group'] = tax_group + if vat_book_line['special_tax_group']: + base_line = next(filter( + lambda l: not l['special_tax_group'], implied_lines)) + special_line = next(filter( + lambda l: l['special_tax_group'], implied_lines)) + base_line.update({ + 'special_tax_id': special_line['tax_id'], + 'special_tax_amount': special_line['tax_amount'], + 'total_amount_special_include': + base_line['total_amount'] + special_line['tax_amount'], }) - return vat_book_line_obj.create(vals) - def _clear_old_data(self): """ This function clean all the old data to make a new calculation @@ -278,28 +282,79 @@ def _clear_old_data(self): def _account_move_line_domain(self, taxes): # search move lines that contain these tax codes - return [('date', '>=', self.date_start), - ('date', '<=', self.date_end), - '|', ('tax_ids', 'in', taxes.ids), - ('tax_line_id', 'in', taxes.ids)] - - def _get_account_moves(self, taxes): - aml_obj = self.env['account.move.line'] - groups = aml_obj.read_group( - self._account_move_line_domain(taxes), ['move_id'], ['move_id']) - return self.env['account.move'].browse([ - x['move_id'][0] for x in groups + return [ + ('date', '>=', self.date_start), + ('date', '<=', self.date_end), + '|', ('tax_ids', 'in', taxes.ids), + ('tax_line_id', 'in', taxes.ids), + ] + + def _get_account_move_lines(self, taxes): + return self.env['account.move.line'].search( + self._account_move_line_domain(taxes)) + + @ormcache('self.id') + def get_pos_partner_ids(self): + return self.env['res.partner'].with_context(active_test=False).search([ + ('aeat_anonymous_cash_customer', '=', True), + ]).ids + + @ormcache('self.id') + def get_special_taxes_dic(self): + map_lines = self.env['aeat.vat.book.map.line'].search([ + ('special_tax_group', '!=', False), ]) - - def _create_vat_book_records(self, move, line_type, taxes): - line = self._create_vat_book_line( - move, line_type) - # Create tax lines - ml_taxes = move.line_ids.mapped('tax_ids') - for tax in ml_taxes.filtered(lambda x: x.id in taxes.ids): - # Create tax lines for the current vat_book_line - self._create_vat_book_line_tax( - tax, line, move) + special_dic = {} + for map_line in map_lines: + for tax in self.get_taxes_from_templates(map_line.tax_tmpl_ids): + special_dic[tax.id] = { + 'name': map_line.name, + 'book_type': map_line.book_type, + 'special_tax_group': map_line.special_tax_group, + 'fee_type_xlsx_column': map_line.fee_type_xlsx_column, + 'fee_amount_xlsx_column': map_line.fee_amount_xlsx_column, + } + return special_dic + + def get_book_line_key(self, move_line): + return move_line.move_id.id, move_line.invoice_id.id + + def get_book_line_tax_key(self, move_line, tax): + return move_line.move_id.id, move_line.invoice_id.id, tax.id + + def _set_line_type(self, line_vals, line_type): + if line_vals['base_amount'] < 0.0: + line_vals['line_type'] = 'rectification_{}'.format(line_type) + + def _check_exceptions(self, line_vals): + if (not line_vals['vat_number'] and line_vals['partner_id'] not in + self.get_pos_partner_ids()): + line_vals['exception_text'] = _("Without VAT") + + def create_vat_book_lines(self, move_lines, line_type, taxes): + VatBookLine = self.env['l10n.es.vat.book.line'] + moves_dic = {} + for move_line in move_lines: + line_key = self.get_book_line_key(move_line) + if line_key not in moves_dic: + moves_dic[line_key] = self._prepare_book_line_vals( + move_line, line_type) + self.upsert_book_line_tax(move_line, moves_dic[line_key], taxes) + for line_vals in moves_dic.values(): + tax_lines = line_vals.pop('tax_lines') + tax_line_list = [] + tax_amount = 0.0 + for tax_line_vals in tax_lines.values(): + tax_amount += tax_line_vals['tax_amount'] + tax_line_list.append((0, 0, tax_line_vals)) + self._set_line_type(line_vals, line_type) + line_vals.update({ + 'total_amount': line_vals['base_amount'] + tax_amount, + 'tax_line_ids': [ + (0, 0, vals) for vals in tax_lines.values()], + }) + self._check_exceptions(line_vals) + VatBookLine.create(line_vals) def _calculate_vat_book(self): """ @@ -314,47 +369,22 @@ def _calculate_vat_book(self): # clean the old records rec._clear_old_data() - tax_model = self.env['account.tax'] - # Obtain Map code template from vat_book. - tax_code_map = self.env['l10n.es.aeat.map.tax'].search( - [('model', '=', '340'), - '|', - ('date_from', '<=', rec.date_start), - ('date_from', '=', False), - '|', - ('date_to', '>=', rec.date_end), - ('date_to', '=', False)], limit=1) - if not tax_code_map: - raise UserError(_('No AEAT Tax Mapping was found')) - - # Obtain all the codes from account.tax.code.template - codes_issued = tax_code_map.map_line_ids.mapped( - 'tax_ids').filtered( - lambda t: t.type_tax_use == 'sale').mapped('description') - codes_received = tax_code_map.map_line_ids.mapped( - 'tax_ids').filtered( - lambda t: t.type_tax_use == 'purchase').mapped('description') - # search the account.tax referred to by the template - taxes_issued = tax_model.search( - [('description', 'in', codes_issued), - ('company_id', 'child_of', rec.company_id.id)]) - taxes_received = tax_model.search( - [('description', 'in', codes_received), - ('company_id', 'child_of', rec.company_id.id)]) + tax_templates = self.env['aeat.vat.book.map.line'].search( + []).mapped('tax_tmpl_ids') + taxes_issued = self.get_taxes_from_templates( + tax_templates.filtered(lambda t: t.type_tax_use == 'sale') + ) + taxes_received = self.get_taxes_from_templates( + tax_templates.filtered(lambda t: t.type_tax_use == 'purchase') + ) # Get all the account move lines that contain VAT that is # applicable to this report. - moves_issued = rec._get_account_moves(taxes_issued) - - for move in moves_issued: - line_type = 'issued' - rec._create_vat_book_records(move, line_type, taxes_issued) - - moves_received = rec._get_account_moves(taxes_received) - - for move in moves_received: - line_type = 'received' - rec._create_vat_book_records(move, line_type, taxes_received) + lines_issued = rec._get_account_move_lines(taxes_issued) + self.create_vat_book_lines(lines_issued, 'issued', taxes_issued) + lines_received = rec._get_account_move_lines(taxes_received) + self.create_vat_book_lines( + lines_received, 'received', taxes_received) # Issued book_type = 'issued' @@ -408,7 +438,6 @@ def _calculate_vat_book(self): 'calculation_date': fields.Datetime.now(), }) - @api.multi def view_issued_invoices(self): self.ensure_one() action = self.env.ref( @@ -417,7 +446,6 @@ def view_issued_invoices(self): vals['context'] = self.env.context return vals - @api.multi def view_received_invoices(self): self.ensure_one() action = self.env.ref( @@ -434,16 +462,16 @@ def _format_date(self, date): return datetime.datetime.strftime( fields.Date.from_string(date), date_format) - @api.multi + def get_report_file_name(self): + return '{}{}C{}'.format(self.year, self.company_vat, + re.sub(r'[\W_]+', '', self.company_id.name)) + + def button_confirm(self): + if any(l.exception_text for l in self.line_ids): + raise UserError(_('This book has warnings. Fix it before confirm')) + return super().button_confirm() + def export_xlsx(self): self.ensure_one() - context = dict(self.env.context, active_ids=self.ids) - return { - 'name': 'VAT book XLSX report', - 'model': 'l10n.es.vat.book', - 'type': 'ir.actions.report', - 'report_name': 'l10n_es_vat_book.l10n_es_vat_book_xlsx', - 'report_type': 'xlsx', - 'report_file': 'l10n.es.vat.book', - 'context': context, - } + return self.env.ref( + 'l10n_es_vat_book.l10n_es_vat_book_xlsx').report_action(self) diff --git a/l10n_es_vat_book/models/l10n_es_vat_book_line.py b/l10n_es_vat_book/models/l10n_es_vat_book_line.py index 2793c96e386..360412a0ff5 100644 --- a/l10n_es_vat_book/models/l10n_es_vat_book_line.py +++ b/l10n_es_vat_book/models/l10n_es_vat_book_line.py @@ -2,6 +2,7 @@ # Daniel Rodriguez Lijo # Copyright 2017 Eficent Business and IT Consulting Services, S.L. # +# Copyright 2019 Tecnativa - Carlos Dauden # License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0 from odoo import api, fields, models @@ -11,6 +12,10 @@ class L10nEsVatBookLine(models.Model): _name = 'l10n.es.vat.book.line' _order = 'entry_number asc, ref asc, invoice_date asc' + def _selection_special_tax_group(self): + return self.env['l10n.es.vat.book.line.tax'].fields_get( + allfields=['special_tax_group'])['special_tax_group']['selection'] + ref = fields.Char('Reference') entry_number = fields.Integer('Entry number') external_ref = fields.Char('External Reference') @@ -46,12 +51,21 @@ class L10nEsVatBookLine(models.Model): inverse_name='vat_book_line_id', string='Tax Lines', copy=False) - exception = fields.Boolean( - string="Exception") - exception_text = fields.Char( string="Exception text") + base_amount = fields.Float( + string='Base', + ) + total_amount = fields.Float( + string='Total', + ) + special_tax_group = fields.Selection( + selection=_selection_special_tax_group, + string='Special group', + help='Special tax group as R.Eq, IRPF, etc', + ) + @api.multi @api.depends('tax_id') def _compute_tax_rate(self): diff --git a/l10n_es_vat_book/models/l10n_es_vat_book_line_tax.py b/l10n_es_vat_book/models/l10n_es_vat_book_line_tax.py index 74083332bed..b51635cf9b7 100644 --- a/l10n_es_vat_book/models/l10n_es_vat_book_line_tax.py +++ b/l10n_es_vat_book/models/l10n_es_vat_book_line_tax.py @@ -2,6 +2,7 @@ # Daniel Rodriguez Lijo # Copyright 2017 Eficent Business and IT Consulting Services, S.L. # +# Copyright 2019 Tecnativa - Carlos Dauden # License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0 from odoo import api, fields, models @@ -10,9 +11,12 @@ class L10nEsVatBookLineTax(models.Model): _name = 'l10n.es.vat.book.line.tax' - vat_book_line_id = fields.Many2one(comodel_name='l10n.es.vat.book.line', - required=True, ondelete='cascade') - + vat_book_line_id = fields.Many2one( + comodel_name='l10n.es.vat.book.line', + required=True, + ondelete='cascade', + index=True, + ) base_amount = fields.Float( string='Base') @@ -28,6 +32,24 @@ class L10nEsVatBookLineTax(models.Model): move_line_ids = fields.Many2many( comodel_name='account.move.line', string='Move Lines') + special_tax_group = fields.Selection( + selection=[ + ('req', 'R.Eq.'), + ('irpf', 'IRPF'), + ], + string='Special group', + help='Special tax group as R.Eq, IRPF, etc', + ) + special_tax_id = fields.Many2one( + comodel_name='account.tax', + string='Special Tax', + ) + special_tax_amount = fields.Float( + string='Special Tax fee', + ) + total_amount_special_include = fields.Float( + string='Total w/Special', + ) @api.multi @api.depends('tax_id') diff --git a/l10n_es_vat_book/models/l10n_es_vat_book_summary.py b/l10n_es_vat_book/models/l10n_es_vat_book_summary.py index 0e98cf45051..ff1ef24bda4 100644 --- a/l10n_es_vat_book/models/l10n_es_vat_book_summary.py +++ b/l10n_es_vat_book/models/l10n_es_vat_book_summary.py @@ -2,6 +2,7 @@ # Daniel Rodriguez Lijo # Copyright 2017 Eficent Business and IT Consulting Services, S.L. # +# Copyright 2019 Tecnativa - Carlos Dauden # License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0 from odoo import fields, models @@ -10,6 +11,12 @@ class L10nEsVatBookIssuedSummary(models.Model): _name = 'l10n.es.vat.book.summary' + _order = 'book_type, special_tax_group DESC' + + def _selection_special_tax_group(self): + return self.env['l10n.es.vat.book.line.tax'].fields_get( + allfields=['special_tax_group'])['special_tax_group']['selection'] + vat_book_id = fields.Many2one( comodel_name='l10n.es.vat.book', string='Vat Book id') @@ -30,3 +37,8 @@ class L10nEsVatBookIssuedSummary(models.Model): total_amount = fields.Float( string='Total amount', readonly="True") + special_tax_group = fields.Selection( + selection=_selection_special_tax_group, + string='Special group', + help='Special tax group as R.Eq, IRPF, etc', + ) diff --git a/l10n_es_vat_book/models/l10n_es_vat_book_tax_summary.py b/l10n_es_vat_book/models/l10n_es_vat_book_tax_summary.py index 20ec177ce2e..b63c80166b5 100644 --- a/l10n_es_vat_book/models/l10n_es_vat_book_tax_summary.py +++ b/l10n_es_vat_book/models/l10n_es_vat_book_tax_summary.py @@ -2,6 +2,7 @@ # Daniel Rodriguez Lijo # Copyright 2017 Eficent Business and IT Consulting Services, S.L. # +# Copyright 2019 Tecnativa - Carlos Dauden # License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0 from odoo import fields, models @@ -11,6 +12,8 @@ class L10nEsVatBookIssuedTaxSummary(models.Model): _name = 'l10n.es.vat.book.tax.summary' _inherit = 'l10n.es.vat.book.summary' + _order = 'book_type, special_tax_group DESC, tax_id' + tax_id = fields.Many2one( comodel_name='account.tax', string='Account Tax', diff --git a/l10n_es_vat_book/readme/CONFIGURE.rst b/l10n_es_vat_book/readme/CONFIGURE.rst index df196bc5339..80f7f807cc8 100644 --- a/l10n_es_vat_book/readme/CONFIGURE.rst +++ b/l10n_es_vat_book/readme/CONFIGURE.rst @@ -1,3 +1,6 @@ Los códigos de impuestos incluidos en el Libro de IVA pueden verse en: -Contabilidad -> Configuración -> AEAT -> Mapeo de códigos de impuesto -> -Declaración AEAT 340 +Contabilidad -> Configuración -> AEAT -> Mapeo AEAT libro de IVA + +Los clientes utilizados para ventas por caja deben tener marcado el campo +"AEAT - Cliente anónimo" para que no se muestren advertencias por no tener NIF +informado siguiendo lo especificado en el formato BOE. diff --git a/l10n_es_vat_book/readme/CONTRIBUTORS.rst b/l10n_es_vat_book/readme/CONTRIBUTORS.rst index 1cac3e01d08..35b24849c11 100644 --- a/l10n_es_vat_book/readme/CONTRIBUTORS.rst +++ b/l10n_es_vat_book/readme/CONTRIBUTORS.rst @@ -4,3 +4,4 @@ * `Tecnativa `_: * Pedro M. Baeza + * Carlos Dauden diff --git a/l10n_es_vat_book/readme/ROADMAP.rst b/l10n_es_vat_book/readme/ROADMAP.rst index bb87633187a..a9043bf2654 100644 --- a/l10n_es_vat_book/readme/ROADMAP.rst +++ b/l10n_es_vat_book/readme/ROADMAP.rst @@ -1,4 +1,3 @@ Funcionalidades del Libro Registro de IVA no incluídas por el momento: -* Libro Registro de Bienes de Inversión -* Libro Registro de Determinadas Operaciones Intracomunitarias +* Criterio de caja diff --git a/l10n_es_vat_book/report/common_templates.xml b/l10n_es_vat_book/report/common_templates.xml index df1ec89c753..081093bd983 100644 --- a/l10n_es_vat_book/report/common_templates.xml +++ b/l10n_es_vat_book/report/common_templates.xml @@ -200,7 +200,10 @@ Total - + + + +# Copyright 2019 Tecnativa - Carlos Dauden # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import _, models +from odoo import fields, models +from odoo.tools import ormcache + + +def excel_col_number(col_name): + """Excel column name to number""" + n = 0 + for c in col_name: + n = n * 26 + 1 + ord(c) - ord('A') + return n - 1 class VatNumberXlsx(models.AbstractModel): _name = 'report.l10n_es_vat_book.l10n_es_vat_book_xlsx' _inherit = 'report.report_xlsx.abstract' + def format_boe_date(self, date): + return fields.Datetime.from_string(date) + + @ormcache('self.id') + def _get_undeductible_taxes(self, book): + line = self.env.ref('l10n_es_vat_book.aeat_vat_book_map_line_p_iva_nd') + return book.get_taxes_from_templates(line.tax_tmpl_ids) + + def _get_vat_book_map_lines(self, book_type): + return self.env['aeat.vat.book.map.line'].search([ + ('special_tax_group', '!=', False), + ('book_type', '=', book_type), + ('fee_type_xlsx_column', '!=', False), + ('fee_amount_xlsx_column', '!=', False), + ]) + + def create_issued_sheet(self, workbook, book): + title_format = workbook.add_format({ + 'bold': 1, + 'border': 1, + 'align': 'center', + 'valign': 'vjustify', + }) + header_format = workbook.add_format({ + 'bold': 1, + 'border': 1, + 'align': 'center', + 'valign': 'vjustify', + 'fg_color': '#F2F2F2'}) + subheader_format = workbook.add_format({ + 'bold': 1, + 'border': 1, + 'align': 'center', + 'valign': 'vjustify'}) + decimal_format = workbook.add_format({'num_format': '0.00'}) + date_format = workbook.add_format({'num_format': 'dd/mm/yyyy'}) + + sheet = workbook.add_worksheet('EXPEDIDAS') + + sheet.merge_range('B1:Q1', 'LIBRO REGISTRO FACTURAS EXPEDIDAS', + title_format) + sheet.write('A2', 'Ejercicio: %s' % book.year) + sheet.write('A3', 'NIF: %s' % book.company_vat) + sheet.merge_range('A4:D4', 'NOMBRE/RAZÓN SOCIAL: %s' % + book.company_id.name) + + sheet.merge_range('C6:E6', 'Identificación de la Factura', + header_format) + sheet.merge_range('F6:H6', 'NIF Destinatario', header_format) + + sheet.merge_range('A6:A7', 'Fecha Expedición', header_format) + sheet.merge_range('B6:B7', 'Fecha Operación', header_format) + sheet.write('C7', 'Serie', subheader_format) + sheet.write('D7', 'Número', subheader_format) + sheet.write('E7', 'Número-Final', subheader_format) + sheet.write('F7', 'Tipo', subheader_format) + sheet.write('G7', 'Código País', subheader_format) + sheet.write('H7', 'Identificación', subheader_format) + sheet.merge_range('I6:I7', 'Nombre Destinatario', header_format) + sheet.merge_range('J6:J7', 'Factura Sustitutiva', header_format) + sheet.merge_range('K6:K7', 'Clave de Operación', header_format) + sheet.merge_range('L6:L7', 'Total Factura', header_format) + sheet.merge_range('M6:M7', 'Base Imponible', header_format) + sheet.merge_range('N6:N7', 'Tipo de IVA', header_format) + sheet.merge_range('O6:O7', 'Cuota IVA Repercutida', header_format) + last_col = 'O' + for line in self._get_vat_book_map_lines('issued'): + sheet.merge_range('{0}6:{0}7'.format(line.fee_type_xlsx_column), + 'Tipo de {}'.format(line.name), header_format) + sheet.merge_range('{0}6:{0}7'.format(line.fee_amount_xlsx_column), + 'Cuota {}'.format(line.name), header_format) + last_col = line.fee_amount_xlsx_column + next_col = excel_col_number(last_col) + 1 + # Las filas empiezan por 0, por eso se resta 1 + sheet.merge_range(5, next_col, 5, next_col + 3, + 'Cobro (Operación Criterio de Caja)', header_format) + sheet.write(6, next_col, 'Fecha', subheader_format) + next_col += 1 + sheet.write(6, next_col, 'Importe', subheader_format) + next_col += 1 + sheet.write(6, next_col, 'Medio Utilizado', subheader_format) + next_col += 1 + sheet.write(6, next_col, 'Identificación Medio Utilizado', + subheader_format) + + sheet.set_column('A:B', 16, date_format) + sheet.set_column('C:C', 14) + sheet.set_column('D:D', 17) + sheet.set_column('E:E', 17) + sheet.set_column('F:F', 8) + sheet.set_column('G:G', 12) + sheet.set_column('H:H', 14) + sheet.set_column('I:I', 40) + sheet.set_column('J:J', 16) + sheet.set_column('K:K', 16) + sheet.set_column('L:Q', 14, decimal_format) + + next_col = excel_col_number(last_col) + 1 + sheet.set_column(next_col, next_col, 14, date_format) + next_col += 1 + sheet.set_column(next_col, next_col, 14, decimal_format) + next_col += 1 + sheet.set_column(next_col, next_col, 14) + next_col += 1 + sheet.set_column(next_col, next_col, 30) + + return sheet + + def fill_issued_row_data(self, sheet, row, line, tax_line, with_total): + """ Fill issued data """ + + country_code, identifier_type, vat_number = ( + line.partner_id._parse_aeat_vat_info()) + sheet.write('A' + str(row), self.format_boe_date(line.invoice_date)) + # sheet.write('B' + str(row), self.format_boe_date(line.invoice_date)) + sheet.write('C' + str(row), line.ref[:-20]) + sheet.write('D' + str(row), line.ref[-20:]) + sheet.write('E' + str(row), '') # Final number + sheet.write('F' + str(row), identifier_type) + if country_code != 'ES': + sheet.write('G' + str(row), country_code) + sheet.write('H' + str(row), vat_number) + if not vat_number and line.partner_id.aeat_anonymous_cash_customer: + sheet.write('I' + str(row), 'VENTA POR CAJA') + else: + sheet.write('I' + str(row), line.partner_id.name[:40]) + # TODO: Substitute Invoice + # sheet.write('J' + str(row), + # line.invoice_id.refund_invoice_id.number or '') + sheet.write('K' + str(row), '') # Operation Key + if with_total: + sheet.write('L' + str(row), line.total_amount) + sheet.write('M' + str(row), tax_line.base_amount) + sheet.write('N' + str(row), tax_line.tax_id.amount) + sheet.write('O' + str(row), tax_line.tax_amount) + if tax_line.special_tax_id: + map_vals = line.vat_book_id.get_special_taxes_dic()[ + tax_line.special_tax_id.id] + sheet.write(map_vals['fee_type_xlsx_column'] + str(row), + tax_line.special_tax_id.amount) + sheet.write(map_vals['fee_amount_xlsx_column'] + str(row), + tax_line.special_tax_amount) + + def create_received_sheet(self, workbook, book): + title_format = workbook.add_format({ + 'bold': 1, + 'border': 1, + 'align': 'center', + 'valign': 'vjustify', + }) + header_format = workbook.add_format({ + 'bold': 1, + 'border': 1, + 'align': 'center', + 'valign': 'vjustify', + 'fg_color': '#F2F2F2'}) + subheader_format = workbook.add_format({ + 'bold': 1, + 'border': 1, + 'align': 'center', + 'valign': 'vjustify'}) + decimal_format = workbook.add_format({'num_format': '0.00'}) + date_format = workbook.add_format({'num_format': 'dd/mm/yyyy'}) + + sheet = workbook.add_worksheet('RECIBIDAS') + + sheet.merge_range('B1:S1', 'LIBRO REGISTRO FACTURAS RECIBIDAS', + title_format) + sheet.write('A2', 'Ejercicio: %s' % book.year) + sheet.write('A3', 'NIF: %s' % book.company_vat) + sheet.merge_range('A4:D4', 'NOMBRE/RAZÓN SOCIAL: %s' % + book.company_id.name) + + sheet.merge_range('C6:D6', 'Identificación Factura del Expedidor', + header_format) + sheet.merge_range('G6:I6', 'NIF Expedidor', header_format) + + sheet.merge_range('A6:A7', 'Fecha Expedición', header_format) + sheet.merge_range('B6:B7', 'Fecha Operación', header_format) + sheet.write('C7', '(Serie-Número)', subheader_format) + sheet.write('D7', 'Número-Final', subheader_format) + sheet.merge_range('E6:E7', 'Número Recepción', header_format) + sheet.merge_range('F6:F7', 'Número Recepción Final', header_format) + sheet.write('G7', 'Tipo', subheader_format) + sheet.write('H7', 'Código País', subheader_format) + sheet.write('I7', 'Identificación', subheader_format) + sheet.merge_range('J6:J7', 'Nombre Expedidor', header_format) + sheet.merge_range('K6:K7', 'Factura Sustitutiva', header_format) + sheet.merge_range('L6:L7', 'Clave de Operación', header_format) + sheet.merge_range('M6:M7', 'Total Factura', header_format) + sheet.merge_range('N6:N7', 'Base Imponible', header_format) + sheet.merge_range('O6:O7', 'Tipo de IVA', header_format) + sheet.merge_range('P6:P7', 'Cuota IVA Soportado', header_format) + sheet.merge_range('Q6:Q7', 'Cuota Deducible', header_format) + last_col = 'Q' + for line in self._get_vat_book_map_lines('received'): + sheet.merge_range('{0}6:{0}7'.format(line.fee_type_xlsx_column), + 'Tipo de {}'.format(line.name), header_format) + sheet.merge_range('{0}6:{0}7'.format(line.fee_amount_xlsx_column), + 'Cuota {}'.format(line.name), header_format) + last_col = line.fee_amount_xlsx_column + next_col = excel_col_number(last_col) + 1 + # Las filas empiezan por 0, por eso se resta 1 + sheet.merge_range(5, next_col, 5, next_col + 3, + 'Pago (Operación Criterio de Caja)', header_format) + sheet.write(6, next_col, 'Fecha', subheader_format) + next_col += 1 + sheet.write(6, next_col, 'Importe', subheader_format) + next_col += 1 + sheet.write(6, next_col, 'Medio Utilizado', subheader_format) + next_col += 1 + sheet.write(6, next_col, 'Identificación Medio Utilizado', + subheader_format) + + sheet.set_column('A:B', 16, date_format) + sheet.set_column('C:F', 17) + sheet.set_column('G:G', 8) + sheet.set_column('H:H', 12) + sheet.set_column('I:I', 14) + sheet.set_column('J:J', 40) + sheet.set_column('K:K', 16) + sheet.set_column('L:L', 14) + sheet.set_column('M:S', 14, decimal_format) + next_col = excel_col_number(last_col) + 1 + sheet.set_column(next_col, next_col, 14, date_format) + next_col += 1 + sheet.set_column(next_col, next_col, 14, decimal_format) + next_col += 1 + sheet.set_column(next_col, next_col, 14) + next_col += 1 + sheet.set_column(next_col, next_col, 30) + + return sheet + + def fill_received_row_data(self, sheet, row, line, tax_line, with_total): + """ Fill received data """ + + date_invoice = line.invoice_id.date_invoice + country_code, identifier_type, vat_number = ( + line.partner_id._parse_aeat_vat_info()) + sheet.write('A' + str(row), self.format_boe_date(line.invoice_date)) + if date_invoice and date_invoice != line.invoice_date: + sheet.write('B' + str(row), self.format_boe_date(date_invoice)) + sheet.write('C' + str(row), + line.external_ref and line.external_ref[:40] or '') + sheet.write('D' + str(row), '') + sheet.write('E' + str(row), line.ref[:20]) + sheet.write('F' + str(row), '') + sheet.write('G' + str(row), identifier_type) + if country_code != 'ES': + sheet.write('H' + str(row), country_code) + sheet.write('I' + str(row), vat_number) + sheet.write('J' + str(row), line.partner_id.name[:40]) + # TODO: Substitute Invoice + # sheet.write('K' + str(row), + # line.invoice_id.refund_invoice_id.number or '') + sheet.write('L' + str(row), '') # Operation Key + if with_total: + sheet.write('M' + str(row), line.total_amount) + sheet.write('N' + str(row), tax_line.base_amount) + sheet.write('O' + str(row), tax_line.tax_id.amount) + sheet.write('P' + str(row), tax_line.tax_amount) + if tax_line.tax_id not in self._get_undeductible_taxes( + line.vat_book_id): + sheet.write('Q' + str(row), tax_line.tax_amount) + if tax_line.special_tax_id: + map_vals = line.vat_book_id.get_special_taxes_dic()[ + tax_line.special_tax_id.id] + sheet.write(map_vals['fee_type_xlsx_column'] + str(row), + tax_line.special_tax_id.amount) + sheet.write(map_vals['fee_amount_xlsx_column'] + str(row), + tax_line.special_tax_amount) + def generate_xlsx_report(self, workbook, data, objects): + """ Create vat book xlsx in BOE format """ + book = objects[0] - bold = workbook.add_format({'bold': True}) - - def fill_table(sheet_name, lines, received_lines=False): - sheet = workbook.add_worksheet(sheet_name[:31]) - row = col = 0 - xlsx_header = [ - _('Invoice'), - _('Date'), - _('Partner'), - _('VAT'), - _('Base'), - _('Tax'), - _('Fee'), - _('Total'), - ] - if received_lines: - xlsx_header.insert(0, _('Reference')) - for col_header in xlsx_header: - sheet.write(row, col, col_header, bold) - col += 1 - - row = 1 - for line in lines: - for tax_line in line.tax_line_ids: - col = 0 - if received_lines: - sheet.write(row, col, line.invoice_id.reference) - col += 1 - sheet.write(row, col, line.invoice_id.number) - col += 1 - sheet.write(row, col, line.invoice_date) - col += 1 - sheet.write(row, col, line.partner_id.name) - col += 1 - sheet.write(row, col, line.vat_number) - col += 1 - sheet.write(row, col, tax_line.base_amount) - col += 1 - sheet.write(row, col, tax_line.tax_id.name) - col += 1 - sheet.write(row, col, tax_line.tax_amount) - col += 1 - sheet.write(row, col, tax_line.total_amount) + + # Issued + issued_sheet = self.create_issued_sheet(workbook, book) + lines = book.issued_line_ids + book.rectification_issued_line_ids + lines = lines.sorted(key=lambda l: (l.invoice_date, l.ref)) + row = 8 + for line in lines: + with_total = True + for tax_line in line.tax_line_ids: + if not tax_line.special_tax_group: + # TODO: Payments bucle + self.fill_issued_row_data( + issued_sheet, row, line, tax_line, with_total) + with_total = False row += 1 - if book.issued_line_ids: - report_name = _('Issued Invoices') - lines = book.issued_line_ids - fill_table(report_name, lines) - if book.rectification_issued_line_ids: - report_name = _('Issued Refund Invoices') - lines = book.rectification_issued_line_ids - fill_table(report_name, lines) - if book.received_line_ids: - report_name = _('Received Invoices') - lines = book.received_line_ids - fill_table(report_name, lines, received_lines=True) - if book.rectification_received_line_ids: - report_name = _('Received Refund Invoices') - lines = book.rectification_received_line_ids - fill_table(report_name, lines, received_lines=True) + # Received + received_sheet = self.create_received_sheet(workbook, book) + lines = book.received_line_ids + book.rectification_received_line_ids + lines = lines.sorted(key=lambda l: (l.invoice_date, l.ref)) + row = 8 + for line in lines: + with_total = True + for tax_line in line.tax_line_ids: + if not tax_line.special_tax_group: + # TODO: Payments bucle + self.fill_received_row_data( + received_sheet, row, line, tax_line, with_total) + with_total = False + row += 1 diff --git a/l10n_es_vat_book/report/vat_book_xlsx.xml b/l10n_es_vat_book/report/vat_book_xlsx.xml index c272a982127..e8d801a7b8b 100644 --- a/l10n_es_vat_book/report/vat_book_xlsx.xml +++ b/l10n_es_vat_book/report/vat_book_xlsx.xml @@ -1,13 +1,14 @@ - - VAT book XLSX report - l10n.es.vat.book - ir.actions.report - l10n_es_vat_book.l10n_es_vat_book_xlsx - xlsx - l10n_es_vat_book - + diff --git a/l10n_es_vat_book/security/ir.model.access.csv b/l10n_es_vat_book/security/ir.model.access.csv index c8d095c7568..07bb0935032 100644 --- a/l10n_es_vat_book/security/ir.model.access.csv +++ b/l10n_es_vat_book/security/ir.model.access.csv @@ -4,3 +4,4 @@ access_l10n_es_aeat_vat_book_line,l10n_es_aeat_vat_book_line,model_l10n_es_vat_b access_l10n_es_aeat_vat_book_line_tax,l10n_es_aeat_vat_book_line_tax,model_l10n_es_vat_book_line_tax,l10n_es_aeat.group_account_aeat,1,1,1,1 access_l10n_es_aeat_vat_book_tax_summary,l10n_es_aeat_vat_book_tax_summary,model_l10n_es_vat_book_tax_summary,l10n_es_aeat.group_account_aeat,1,1,1,1 access_l10n_es_aeat_vat_book_summary,l10n_es_aeat_vat_book_summary,model_l10n_es_vat_book_summary,l10n_es_aeat.group_account_aeat,1,1,1,1 +access_aeat_vat_book_map_line,aeat_vat_book_map_line,model_aeat_vat_book_map_line,l10n_es_aeat.group_account_aeat,1,1,1,1 diff --git a/l10n_es_vat_book/views/aeat_vat_book_map_view.xml b/l10n_es_vat_book/views/aeat_vat_book_map_view.xml new file mode 100644 index 00000000000..b5d09728043 --- /dev/null +++ b/l10n_es_vat_book/views/aeat_vat_book_map_view.xml @@ -0,0 +1,31 @@ + + + + + AEAT vat book map + aeat.vat.book.map.line + form + tree,form + + + + + + aeat.vat.book.map.lines.view.tree + aeat.vat.book.map.line + + + + + + + + + + + + + diff --git a/l10n_es_vat_book/views/l10n_es_vat_book.xml b/l10n_es_vat_book/views/l10n_es_vat_book.xml index 1b7237c8a33..d18568104c7 100644 --- a/l10n_es_vat_book/views/l10n_es_vat_book.xml +++ b/l10n_es_vat_book/views/l10n_es_vat_book.xml @@ -21,10 +21,15 @@ type="object" attrs="{'invisible':[('state', '=', 'draft')]}"/>