diff --git a/l10n_es_aeat_mod303_cash_basis/README.rst b/l10n_es_aeat_mod303_cash_basis/README.rst new file mode 100644 index 00000000000..7e015d58893 --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/README.rst @@ -0,0 +1,98 @@ +================================================= +AEAT modelo 303 - Extensión para criterio de caja +================================================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--spain-lightgray.png?logo=github + :target: https://github.com/OCA/l10n-spain/tree/12.0/l10n_es_aeat_mod303_cash_basis + :alt: OCA/l10n-spain +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/l10n-spain-12-0/l10n-spain-12-0-l10n_es_aeat_mod303_cash_basis + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/189/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Módulo que extiende el modelo 303 para las empresas que requieran criterio de +caja. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +Para su correcto uso, se deben configurar manualmente los impuestos estándar +que correspondan, activando la opción de criterio de caja. + +Usage +===== + +#. Ir a *Contabilidad > Declaraciones AEAT > Modelo 303*. +#. Crear una nueva declaración. Si se detecta algún impuesto de venta o de + compra con criterio de caja, se marcará la correspondiente casilla en el + modelo, aunque dichos valores se pueden cambiar a mano. +#. Pulsar en "Calcular". +#. Los importes correspondientes a los impuestos no cobrados/pagados aparecerán + en sus correspondientes casillas 62, 63, 74 y 75. +#. Los cobros y pagos se declaran sobre la conciliación del asiento de la + factura independientemente de si es un cobro o pago real o si es + una contabilización por algún movimiento intermedio + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_ + + * Pedro M. Baeza. + +* Vicent Cubells + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/l10n-spain `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_es_aeat_mod303_cash_basis/__init__.py b/l10n_es_aeat_mod303_cash_basis/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/l10n_es_aeat_mod303_cash_basis/__manifest__.py b/l10n_es_aeat_mod303_cash_basis/__manifest__.py new file mode 100644 index 00000000000..b5625d1be2c --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2018 Tecnativa - Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0 +{ + "name": "AEAT modelo 303 - Extensión para criterio de caja", + "version": "12.0.1.0.0", + 'category': "Accounting & Finance", + 'author': "Tecnativa," + "Odoo Community Association (OCA)", + 'website': "https://github.com/OCA/l10n-spain", + "license": "AGPL-3", + "depends": [ + "l10n_es_aeat_mod303", + ], + "data": [ + "data/aeat_export_mod303_2018_data.xml", + "data/tax_code_map_mod303_data.xml", + "views/mod303_view.xml", + ], + 'installable': True, +} diff --git a/l10n_es_aeat_mod303_cash_basis/data/aeat_export_mod303_2018_data.xml b/l10n_es_aeat_mod303_cash_basis/data/aeat_export_mod303_2018_data.xml new file mode 100644 index 00000000000..e53c863fe76 --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/data/aeat_export_mod303_2018_data.xml @@ -0,0 +1,38 @@ + + + + + + Identificación: Opción por el régimen especial de criterio de Caja + + ${'cash_basis_receivable' in object._fields.keys() and object.cash_basis_receivable and '1' or '2'} + + + + Identificación: Destinatario de las operaciones a las que se aplique el régimen especial del criterio de Caja + + ${'cash_basis_payable' in object._fields.keys() and object.cash_basis_payable and '1' or '2'} + + + + ${object.tax_line_ids.filtered(lambda r: r.field_number==62).amount} + + + + + ${object.tax_line_ids.filtered(lambda r: r.field_number==63).amount} + + + + + ${object.tax_line_ids.filtered(lambda r: r.field_number==74).amount} + + + + + ${object.tax_line_ids.filtered(lambda r: r.field_number==75).amount} + + + + diff --git a/l10n_es_aeat_mod303_cash_basis/data/tax_code_map_mod303_data.xml b/l10n_es_aeat_mod303_cash_basis/data/tax_code_map_mod303_data.xml new file mode 100644 index 00000000000..a3dbae1000b --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/data/tax_code_map_mod303_data.xml @@ -0,0 +1,54 @@ + + + + + + 62 + Importes de las entregas de bienes y prestaciones de servicios a las que habiéndoles sido aplicado el régimen especial del criterio de caja hubieran resultado devengadas conforme a la regla general de devengo contenida en el art. 75 LIVA - Base imponible + + all + base + both + no + + + + + + 63 + Importes de las entregas de bienes y prestaciones de servicios a las que habiéndoles sido aplicado el régimen especial del criterio de caja hubieran resultado devengadas conforme a la regla general de devengo contenida en el art. 75 LIVA - Cuota + + all + amount + both + no + + + + + + + 74 + Importe de las adquisiciones de bienes y servicios a las que sea de aplicación o afecte el régimen especial del criterio de caja conforme a la ley general de devengo contenida en el artículo 75 de LIVA - Base imponible + + all + base + both + no + + + + + + 75 + Importe de las adquisiciones de bienes y servicios a las que sea de aplicación o afecte el régimen especial del criterio de caja conforme a la ley general de devengo contenida en el artículo 75 de LIVA - Cuota + + all + amount + both + no + + + + diff --git a/l10n_es_aeat_mod303_cash_basis/i18n/es.po b/l10n_es_aeat_mod303_cash_basis/i18n/es.po new file mode 100644 index 00000000000..0ac82559ce8 --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/i18n/es.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_es_aeat_mod303_cash_basis +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-04-24 16:09+0000\n" +"PO-Revision-Date: 2018-04-24 16:09+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_es_aeat_mod303_cash_basis +#: model:ir.model,name:l10n_es_aeat_mod303_cash_basis.model_l10n_es_aeat_mod303_report +msgid "AEAT 303 Report" +msgstr "Declaración AEAT 303" + +#. module: l10n_es_aeat_mod303_cash_basis +#: model:ir.model.fields,field_description:l10n_es_aeat_mod303_cash_basis.field_l10n_es_aeat_mod303_report_cash_basis_payable +msgid "Cash basis for purchases" +msgstr "Criterio de caja para compras" + +#. module: l10n_es_aeat_mod303_cash_basis +#: model:ir.model.fields,field_description:l10n_es_aeat_mod303_cash_basis.field_l10n_es_aeat_mod303_report_cash_basis_receivable +msgid "Cash basis for sales" +msgstr "Criterio de caja para ventas" + +#. module: l10n_es_aeat_mod303_cash_basis +#: model:ir.model,name:l10n_es_aeat_mod303_cash_basis.model_account_partial_reconcile +msgid "Partial Reconcile" +msgstr "" diff --git a/l10n_es_aeat_mod303_cash_basis/i18n/l10n_es_aeat_mod303_cash_basis.pot b/l10n_es_aeat_mod303_cash_basis/i18n/l10n_es_aeat_mod303_cash_basis.pot new file mode 100644 index 00000000000..7bb96fb5b22 --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/i18n/l10n_es_aeat_mod303_cash_basis.pot @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_es_aeat_mod303_cash_basis +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_es_aeat_mod303_cash_basis +#: model:ir.model,name:l10n_es_aeat_mod303_cash_basis.model_l10n_es_aeat_mod303_report +msgid "AEAT 303 Report" +msgstr "" + +#. module: l10n_es_aeat_mod303_cash_basis +#: model:ir.model.fields,field_description:l10n_es_aeat_mod303_cash_basis.field_l10n_es_aeat_mod303_report_cash_basis_payable +msgid "Cash basis for purchases" +msgstr "" + +#. module: l10n_es_aeat_mod303_cash_basis +#: model:ir.model.fields,field_description:l10n_es_aeat_mod303_cash_basis.field_l10n_es_aeat_mod303_report_cash_basis_receivable +msgid "Cash basis for sales" +msgstr "" + +#. module: l10n_es_aeat_mod303_cash_basis +#: model:ir.model,name:l10n_es_aeat_mod303_cash_basis.model_account_partial_reconcile +msgid "Partial Reconcile" +msgstr "" + diff --git a/l10n_es_aeat_mod303_cash_basis/models/__init__.py b/l10n_es_aeat_mod303_cash_basis/models/__init__.py new file mode 100644 index 00000000000..3de10ff3337 --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/models/__init__.py @@ -0,0 +1,3 @@ +from . import account_move +from . import account_partial_reconcile +from . import mod303 diff --git a/l10n_es_aeat_mod303_cash_basis/models/account_move.py b/l10n_es_aeat_mod303_cash_basis/models/account_move.py new file mode 100644 index 00000000000..6fe5cfa1a74 --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/models/account_move.py @@ -0,0 +1,45 @@ +# Copyright 2018 Comunitea - Santi Argüeso +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class AccountMove(models.Model): + _inherit = 'account.move' + + move_type_cash_basis = fields.Selection( + string="Move type RECC", selection=[ + ('other', 'Other'), + ('receivable', 'Receivable'), + ('receivable_refund', 'Receivable refund'), + ('payable', 'Payable'), + ('payable_refund', 'Payable refund'), + ], readonly=True) + + def _store_move_type_cash_basis(self): + for move in self: + rec = move.tax_cash_basis_rec_id + move_type = 'other' + if rec: + invoice = rec.debit_move_id.invoice_id or \ + rec.credit_move_id.invoice_id + if invoice: + move_type = invoice.move_id.move_type + move.move_type_cash_basis = move_type + + @api.multi + def reverse_moves(self, date=None, journal_id=None): + reversed_move_ids = super(AccountMove, self).reverse_moves(date, + journal_id) + reversed_moves = self.browse(reversed_move_ids) + reverse_types = { + 'receivable': 'receivable_refund', + 'receivable_refund': 'receivable', + 'payable': 'payable_refund', + 'payable_refund': 'payable', + } + for move in reversed_moves: + if move.move_type_cash_basis in reverse_types.keys(): + move.move_type_cash_basis = reverse_types[ + move.move_type_cash_basis] + return reversed_moves.mapped('id') diff --git a/l10n_es_aeat_mod303_cash_basis/models/account_partial_reconcile.py b/l10n_es_aeat_mod303_cash_basis/models/account_partial_reconcile.py new file mode 100644 index 00000000000..b1d51b58f78 --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/models/account_partial_reconcile.py @@ -0,0 +1,45 @@ +# Copyright 2018 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class AccountPartialReconcileCashBasis(models.Model): + _inherit = 'account.partial.reconcile' + + def create_tax_cash_basis_entry(self, value_before_reconciliation): + """Modify tax_exigible and tax values before reconciliation for + the special case of 12% VAT for farming, as its value is included in + IRPF 2%. + + This way, we trick standard cash basis system for generating proper + payment accounting moves. + """ + moves = self.debit_move_id.move_id + self.credit_move_id.move_id + tax_lines = self.env['account.move.line'] + base_lines = {} + for line in moves.mapped('line_ids'): + if 'P_IRPF2' in line.tax_ids.mapped('description'): + base_lines[line.tax_ids] = line + if (line.tax_line_id.description == 'P_IVA12_AGR' and + line.tax_exigible): + tax_lines += line + if tax_lines: + tax_lines.write({'tax_exigible': False}) + for line in base_lines.values(): + line.tax_ids = [ + (3, x.id) for x in + line.tax_ids.filtered(lambda l: l.description == 'P_IRPF2') + ] + super( + AccountPartialReconcileCashBasis, self, + ).create_tax_cash_basis_entry(value_before_reconciliation) + if tax_lines: + tax_lines.write({'tax_exigible': True}) + for taxes, line in list(base_lines.items()): + line.tax_ids = [(6, 0, taxes.ids)] + res = self.env['account.move'].search([('tax_cash_basis_rec_id', '=', + self.id)]) + if res: + res._store_move_type_cash_basis() + return res diff --git a/l10n_es_aeat_mod303_cash_basis/models/mod303.py b/l10n_es_aeat_mod303_cash_basis/models/mod303.py new file mode 100644 index 00000000000..6c9538e4053 --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/models/mod303.py @@ -0,0 +1,101 @@ +# Copyright 2018 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models +from odoo.osv.expression import normalize_domain, AND, OR + + +class L10nEsAeatMod303Report(models.Model): + _inherit = 'l10n.es.aeat.mod303.report' + + def _default_cash_basis_receivable(self): + return bool(self.env['account.tax'].search_count([ + ('company_id', '=', self._default_company_id().id), + ('type_tax_use', '=', 'sale'), + ('tax_exigibility', '=', 'on_payment'), + ])) + + def _default_cash_basis_payable(self): + return bool(self.env['account.tax'].search_count([ + ('company_id', '=', self._default_company_id().id), + ('type_tax_use', '=', 'purchase'), + ('tax_exigibility', '=', 'on_payment'), + ])) + + cash_basis_receivable = fields.Boolean( + string="Cash basis for sales", + default=_default_cash_basis_receivable, + ) + cash_basis_payable = fields.Boolean( + string="Cash basis for purchases", + default=_default_cash_basis_payable, + ) + + @api.model + def _get_tax_lines(self, codes, date_start, date_end, map_line): + """Hide cash basis lines that are payment entries for the same period + of their counterpart, for not declaring twice the amount. + """ + AccountMove = self.env['account.move'] + move_lines = super(L10nEsAeatMod303Report, self)._get_tax_lines( + codes, date_start, date_end, map_line, + ) + if map_line.field_number in [62, 63, 74, 75]: + new_lines = self.env['account.move.line'] + for line in move_lines: + recs = ( + line.move_id.mapped('line_ids.matched_debit_ids') + + line.move_id.mapped('line_ids.matched_credit_ids') + ) + other_move = AccountMove.search([ + ('tax_cash_basis_rec_id', 'in', recs.ids), + ], limit=1) + if (not other_move or other_move.date < date_start or + other_move.date > date_end): + new_lines += line + move_lines = new_lines + return move_lines + + def _get_move_line_domain(self, codes, date_start, date_end, map_line): + """Add the possibility of getting move lines from moves generated + from cash basis reconciliations so that the amounts appear on the + payment date. This is needed as the cash basis move is not of the + expected move type. + + Also adjust domains for the special case of 12% VAT for farming. + """ + domain = super(L10nEsAeatMod303Report, self)._get_move_line_domain( + codes, date_start, date_end, map_line, + ) + for i, element in enumerate(domain): + if element[0] == 'move_id.move_type': + domain[i:i] = [ + '|', + ('move_id.move_type_cash_basis', 'in', element[2]), + ] + break + if map_line.field_number == 42: + # Exclude here the VAT that is used as base for IRPF 2%, as it + # has the tax_exigible field marked. + domain += [ + ('tax_ids', '=', False), + ] + elif map_line.field_number == 75: + # And add it here + domain_mandatory = [] + domain_optional = [] + domain_extra = [] + for i, element in enumerate(domain): + if element[0] == 'date' and element[1] == '<=': + domain_mandatory = normalize_domain(domain[:i+1]) + domain_optional = normalize_domain(domain[i+1:]) + domain_extra = [ + '&', + ('tax_ids', '!=', False), + ('tax_line_id.description', '=', 'P_IVA12_AGR'), + ] + break + domain = AND( + [domain_mandatory] + [OR([domain_extra, domain_optional])] + ) + return domain diff --git a/l10n_es_aeat_mod303_cash_basis/readme/CONFIGURE.rst b/l10n_es_aeat_mod303_cash_basis/readme/CONFIGURE.rst new file mode 100644 index 00000000000..39cddbcc8a1 --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/readme/CONFIGURE.rst @@ -0,0 +1,2 @@ +Para su correcto uso, se deben configurar manualmente los impuestos estándar +que correspondan, activando la opción de criterio de caja. diff --git a/l10n_es_aeat_mod303_cash_basis/readme/CONTRIBUTORS.rst b/l10n_es_aeat_mod303_cash_basis/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..e7818a3e68f --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/readme/CONTRIBUTORS.rst @@ -0,0 +1,5 @@ +* `Tecnativa `_ + + * Pedro M. Baeza. + +* Vicent Cubells diff --git a/l10n_es_aeat_mod303_cash_basis/readme/DESCRIPTION.rst b/l10n_es_aeat_mod303_cash_basis/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..46e4eccad04 --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +Módulo que extiende el modelo 303 para las empresas que requieran criterio de +caja. diff --git a/l10n_es_aeat_mod303_cash_basis/readme/USAGE.rst b/l10n_es_aeat_mod303_cash_basis/readme/USAGE.rst new file mode 100644 index 00000000000..71af1709c2a --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/readme/USAGE.rst @@ -0,0 +1,10 @@ +#. Ir a *Contabilidad > Declaraciones AEAT > Modelo 303*. +#. Crear una nueva declaración. Si se detecta algún impuesto de venta o de + compra con criterio de caja, se marcará la correspondiente casilla en el + modelo, aunque dichos valores se pueden cambiar a mano. +#. Pulsar en "Calcular". +#. Los importes correspondientes a los impuestos no cobrados/pagados aparecerán + en sus correspondientes casillas 62, 63, 74 y 75. +#. Los cobros y pagos se declaran sobre la conciliación del asiento de la + factura independientemente de si es un cobro o pago real o si es + una contabilización por algún movimiento intermedio diff --git a/l10n_es_aeat_mod303_cash_basis/static/description/icon.png b/l10n_es_aeat_mod303_cash_basis/static/description/icon.png new file mode 100644 index 00000000000..0a3fe8a4a22 Binary files /dev/null and b/l10n_es_aeat_mod303_cash_basis/static/description/icon.png differ diff --git a/l10n_es_aeat_mod303_cash_basis/static/description/icon_source.svg b/l10n_es_aeat_mod303_cash_basis/static/description/icon_source.svg new file mode 100644 index 00000000000..f63a4c5f340 --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/static/description/icon_source.svg @@ -0,0 +1,114 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + 303 + CRITERIOCAJA + diff --git a/l10n_es_aeat_mod303_cash_basis/static/description/index.html b/l10n_es_aeat_mod303_cash_basis/static/description/index.html new file mode 100644 index 00000000000..125afa2146d --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/static/description/index.html @@ -0,0 +1,446 @@ + + + + + + +AEAT modelo 303 - Extensión para criterio de caja + + + +
+

AEAT modelo 303 - Extensión para criterio de caja

+ + +

Beta License: AGPL-3 OCA/l10n-spain Translate me on Weblate Try me on Runbot

+

Módulo que extiende el modelo 303 para las empresas que requieran criterio de +caja.

+

Table of contents

+ +
+

Configuration

+

Para su correcto uso, se deben configurar manualmente los impuestos estándar +que correspondan, activando la opción de criterio de caja.

+
+
+

Usage

+
    +
  1. Ir a Contabilidad > Declaraciones AEAT > Modelo 303.
  2. +
  3. Crear una nueva declaración. Si se detecta algún impuesto de venta o de +compra con criterio de caja, se marcará la correspondiente casilla en el +modelo, aunque dichos valores se pueden cambiar a mano.
  4. +
  5. Pulsar en “Calcular”.
  6. +
  7. Los importes correspondientes a los impuestos no cobrados/pagados aparecerán +en sus correspondientes casillas 62, 63, 74 y 75.
  8. +
  9. Los cobros y pagos se declaran sobre la conciliación del asiento de la +factura independientemente de si es un cobro o pago real o si es +una contabilización por algún movimiento intermedio
  10. +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/l10n-spain project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/l10n_es_aeat_mod303_cash_basis/tests/__init__.py b/l10n_es_aeat_mod303_cash_basis/tests/__init__.py new file mode 100644 index 00000000000..77bd57fab81 --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/tests/__init__.py @@ -0,0 +1 @@ +from . import test_l10n_es_aeat_mod303_cash_basis diff --git a/l10n_es_aeat_mod303_cash_basis/tests/test_l10n_es_aeat_mod303_cash_basis.py b/l10n_es_aeat_mod303_cash_basis/tests/test_l10n_es_aeat_mod303_cash_basis.py new file mode 100644 index 00000000000..dd52ca97af3 --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/tests/test_l10n_es_aeat_mod303_cash_basis.py @@ -0,0 +1,124 @@ +# Copyright 2018 Tecnativa - Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0 + +from odoo.addons.l10n_es_aeat_mod303.tests.test_l10n_es_aeat_mod303 \ + import TestL10nEsAeatMod303Base + + +class TestL10nEsAeatMod303CashBasis(TestL10nEsAeatMod303Base): + def setUp(self): + super(TestL10nEsAeatMod303CashBasis, self).setUp() + self.account_type = self.env['account.account.type'].create({ + 'name': 'Test account type', + 'type': 'other', + }) + self.account = self.env['account.account'].create({ + 'name': 'Test cash basis account', + 'code': 'CASH_BASIS', + 'user_type_id': self.account_type.id, + }) + self.journal = self.env['account.journal'].create({ + 'name': 'Test cash basis journal', + 'code': 'TCBJ', + 'type': 'general', + 'default_credit_account_id': self.account.id, + 'default_debit_account_id': self.account.id, + }) + self.env.user.company_id.tax_cash_basis_journal_id = self.journal.id + taxes = self.env['account.tax'].search([ + ('description', 'in', ('S_IVA21B', 'P_IVA21_BC')), + ('company_id', '=', self.env.user.company_id.id), + ]) + taxes.write({ + 'tax_exigibility': 'on_payment', + 'cash_basis_account_id': self.account.id, + }) + self.taxes_sale = { + # tax code: (base, tax_amount) + 'S_IVA21B': (1000, 210), + } + self.taxes_purchase = { + # tax code: (base, tax_amount) + 'P_IVA21_BC': (2000, 420), + } + self.sale_invoice = self._invoice_purchase_create('2017-01-03') + self.purchase_invoice = self._invoice_sale_create('2017-01-13') + self.model303_2t = self.model303.copy({ + 'name': '2019000000303', + 'period_type': '2T', + 'date_start': '2017-04-01', + 'date_end': '2017-06-30', + }) + + def _register_payment(self, invoice, date): + wizard = self.env['account.register.payments'].with_context( + active_model='account.invoice', + active_ids=invoice.ids, + ).create({ + 'journal_id': self.journal.id, + 'payment_method_id': ( + self.env.ref('account.account_payment_method_manual_in').id + ), + 'payment_date': date, + 'communication': 'Test payment', + }) + wizard.create_payments() + + def _check_results(self, model, tax_results): + for field, expected_result in list(tax_results.items()): + lines = model.tax_line_ids.filtered( + lambda x: x.field_number == int(field) + ) + self.assertAlmostEqual( + expected_result, sum(lines.mapped('amount')), 2, + "Incorrect result in field %s" % field, + ) + + def test_mod303_cash_basis(self): + self._register_payment(self.sale_invoice, '2017-04-01') + self._register_payment(self.purchase_invoice, '2017-04-01') + # Defaults + self.assertTrue(self.model303._default_cash_basis_receivable()) + self.assertTrue(self.model303._default_cash_basis_payable()) + # First trimester + self.model303.button_calculate() + tax_results = { + '7': 0, + '9': 0, + '28': 0, + '29': 0, + '62': 1000, + '63': 210, + '74': 2000, + '75': 420, + } + self._check_results(self.model303, tax_results) + # Second trimester + self.model303_2t.button_calculate() + tax_results = { + '7': 1000, + '9': 210, + '28': 2000, + '29': 420, + '62': 0, + '63': 0, + '74': 0, + '75': 0, + } + self._check_results(self.model303_2t, tax_results) + + def test_mod303_cash_basis_same_period(self): + self._register_payment(self.sale_invoice, '2017-03-30') + self._register_payment(self.purchase_invoice, '2017-03-30') + self.model303.button_calculate() + tax_results = { + '7': 1000, + '9': 210, + '28': 2000, + '29': 420, + '62': 0, + '63': 0, + '74': 0, + '75': 0, + } + self._check_results(self.model303, tax_results) diff --git a/l10n_es_aeat_mod303_cash_basis/views/mod303_view.xml b/l10n_es_aeat_mod303_cash_basis/views/mod303_view.xml new file mode 100644 index 00000000000..9517883ed12 --- /dev/null +++ b/l10n_es_aeat_mod303_cash_basis/views/mod303_view.xml @@ -0,0 +1,17 @@ + + + + + + l10n.es.aeat.mod303.report + + + + + + + + + +