Skip to content

Commit

Permalink
ADD l10n_it_vat_registries_split_payment to fix the following case: (O…
Browse files Browse the repository at this point in the history
…CA#570)

- Configure Split Payment fiscal position and tax
 - Make a customer invoice with SP
 - Print VAT register

Split Payment VAT must not appear as deductible VAT
  • Loading branch information
eLBati authored and Borruso committed Oct 3, 2023
1 parent c623e85 commit f40e8b2
Show file tree
Hide file tree
Showing 9 changed files with 220 additions and 0 deletions.
69 changes: 69 additions & 0 deletions l10n_it_vat_registries_split_payment/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
==============================
VAT registries + Split Payment
==============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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--italy-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-italy/tree/10.0/l10n_it_vat_registries_split_payment
:alt: OCA/l10n-italy
.. |badge4| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/122/10.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4|

Bridge module to make VAT registries module work along with Split Payment module

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-italy/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
~~~~~~~

* Agile Business Group

Contributors
~~~~~~~~~~~~

* Lorenzo Battistini <[email protected]>

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-italy <https://github.com/OCA/l10n-italy/tree/10.0/l10n_it_vat_registries_split_payment>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions l10n_it_vat_registries_split_payment/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
21 changes: 21 additions & 0 deletions l10n_it_vat_registries_split_payment/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Lorenzo Battistini
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "VAT registries + Split Payment",
"summary": "Bridge module to make VAT registries work with Split Payment",
"version": "10.0.1.0.0",
"development_status": "Beta",
"category": "Hidden",
"website": "https://github.com/OCA/l10n-italy/",
"author": "Agile Business Group, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"auto_install": True,
"depends": [
"l10n_it_vat_registries",
"l10n_it_split_payment"
],
}
4 changes: 4 additions & 0 deletions l10n_it_vat_registries_split_payment/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import account_tax
16 changes: 16 additions & 0 deletions l10n_it_vat_registries_split_payment/models/account_tax.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class AccountTax(models.Model):
_inherit = 'account.tax'

def _compute_totals_tax(self, data):
res = super(AccountTax, self)._compute_totals_tax(data)
if self.is_split_payment:
# res is (tax_name, base, tax, deductible, undeductible)
# so, in case of SP, SP VAT must not appear as deductible
return (res[0], res[1], res[2], 0.0, res[4])
return res
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Lorenzo Battistini <[email protected]>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bridge module to make VAT registries module work along with Split Payment module
3 changes: 3 additions & 0 deletions l10n_it_vat_registries_split_payment/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from . import test_sp
101 changes: 101 additions & 0 deletions l10n_it_vat_registries_split_payment/tests/test_sp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# -*- coding: utf-8 -*-

from odoo.addons.account.tests.account_test_users import AccountTestUsers


class TestSP(AccountTestUsers):

def setUp(self):
super(TestSP, self).setUp()
self.tax_model = self.env['account.tax']
self.invoice_model = self.env['account.invoice']
self.inv_line_model = self.env['account.invoice.line']
self.fp_model = self.env['account.fiscal.position']
self.tax22sp = self.tax_model.create({
'name': '22% SP',
'amount': 22,
})
self.tax22 = self.tax_model.create({
'name': '22%',
'amount': 22,
})
self.sp_fp = self.fp_model.create({
'name': 'Split payment',
'split_payment': True,
'tax_ids': [(0, 0, {
'tax_src_id': self.tax22.id,
'tax_dest_id': self.tax22sp.id
})]
})
self.company = self.env.ref('base.main_company')
self.company.sp_account_id = self.env['account.account'].search([
(
'user_type_id', '=',
self.env.ref('account.data_account_type_current_assets').id
)
], limit=1)
account_user_type = self.env.ref(
'account.data_account_type_receivable')
self.a_recv = self.account_model.sudo(self.account_manager.id).create(
dict(
code="cust_acc",
name="customer account",
user_type_id=account_user_type.id,
reconcile=True,
))
self.a_sale = self.env['account.account'].search([
(
'user_type_id', '=',
self.env.ref('account.data_account_type_revenue').id)
], limit=1)
self.sales_journal = self.env['account.journal'].search(
[('type', '=', 'sale')])[0]
# Set invoice date to recent date in the system
# This solves problems with account_invoice_sequential_dates
self.recent_date = self.invoice_model.search(
[('date_invoice', '!=', False)], order='date_invoice desc',
limit=1).date_invoice

def test_invoice(self):
invoice = self.invoice_model.create({
'date_invoice': self.recent_date,
'partner_id': self.env.ref('base.res_partner_3').id,
'journal_id': self.sales_journal.id,
'account_id': self.a_recv.id,
'fiscal_position_id': self.sp_fp.id,
'invoice_line_ids': [(0, 0, {
'name': 'service',
'account_id': self.a_sale.id,
'quantity': 1,
'price_unit': 100,
'invoice_line_tax_ids': [(6, 0, {
self.tax22sp.id
})]
})]
})
invoice.action_invoice_open()
invoice2 = self.invoice_model.create({
'date_invoice': self.recent_date,
'partner_id': self.env.ref('base.res_partner_3').id,
'journal_id': self.sales_journal.id,
'account_id': self.a_recv.id,
'fiscal_position_id': self.sp_fp.id,
'invoice_line_ids': [(0, 0, {
'name': 'service',
'account_id': self.a_sale.id,
'quantity': 1,
'price_unit': 100,
'invoice_line_tax_ids': [(6, 0, {
self.tax22.id
})]
})]
})
invoice2.action_invoice_open()
data = {
'from_date': self.recent_date,
'to_date': self.recent_date,
}
totals_sp = self.tax22sp._compute_totals_tax(data)
totals = self.tax22._compute_totals_tax(data)
self.assertEqual(totals_sp, (u'22% SP', 100.0, 22.0, 0.0, 0))
self.assertEqual(totals, (u'22%', 100.0, 22.0, 22.0, 0))

0 comments on commit f40e8b2

Please sign in to comment.