-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] l10n_ve_seniat: handle basic venezuelan fiscal law requirements…
… by seniat
- Loading branch information
Showing
21 changed files
with
845 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
======================================== | ||
Requerimientos Fiscales Seniat Venezuela | ||
======================================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:bd5c7dd8fc91f21e3d455b14f9e524ec6f831ee65538e8429c467dd58c4645bb | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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--venezuela-lightgray.png?logo=github | ||
:target: https://github.com/OCA/l10n-venezuela/tree/16.0/l10n_ve_seniat | ||
:alt: OCA/l10n-venezuela | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/l10n-venezuela-16-0/l10n-venezuela-16-0-l10n_ve_seniat | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-venezuela&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
Requisitos fiscales leyes venezolanas | ||
===================================== | ||
|
||
Funcionalidades: | ||
- Número de Control de Factura único para el partner. | ||
- Tipo de alicuota en impuestos según lo establecido por las leyes venezolanas. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-venezuela/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/l10n-venezuela/issues/new?body=module:%20l10n_ve_seniat%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Binhex | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
- `Vauxo <https://www.vauxo.com>`_ | ||
|
||
- `Binhex <https://binhex.cloud>`_ | ||
|
||
- Rolando Pérez | ||
|
||
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-venezuela <https://github.com/OCA/l10n-venezuela/tree/16.0/l10n_ve_seniat>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright 2024 Binhex - Rolando Pérez | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from .hooks import post_init_hook | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "Requerimientos Fiscales Seniat Venezuela", | ||
"author": "Binhex," "Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/l10n-venezuela", | ||
"license": "AGPL-3", | ||
"category": "Localization", | ||
"version": "16.0.1.0.0", | ||
"depends": [ | ||
"account", | ||
"base_vat", | ||
"l10n_ve", | ||
"account_invoice_supplier_ref_unique", | ||
], | ||
"data": [ | ||
"data/ir_sequence_data.xml", | ||
"data/account_tax_template_data.xml", | ||
"views/account_tax_views.xml", | ||
"views/account_move_views.xml", | ||
], | ||
"post_init_hook": "post_init_hook", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record id="l10n_ve.tax0sale" model="account.tax.template"> | ||
<field name="l10n_ve_rate_type">exempt</field> | ||
</record> | ||
<record id="l10n_ve.tax1sale" model="account.tax.template"> | ||
<field name="l10n_ve_rate_type">general</field> | ||
</record> | ||
<record id="l10n_ve.tax2sale" model="account.tax.template"> | ||
<field name="l10n_ve_rate_type">reduced</field> | ||
</record> | ||
<record id="l10n_ve.tax3sale" model="account.tax.template"> | ||
<field name="l10n_ve_rate_type">additional</field> | ||
</record> | ||
<record id="l10n_ve.tax0purchase" model="account.tax.template"> | ||
<field name="l10n_ve_rate_type">exempt</field> | ||
</record> | ||
<record id="l10n_ve.tax1purchase" model="account.tax.template"> | ||
<field name="l10n_ve_rate_type">general</field> | ||
</record> | ||
<record id="l10n_ve.tax2purchase" model="account.tax.template"> | ||
<field name="l10n_ve_rate_type">reduced</field> | ||
</record> | ||
<record id="l10n_ve.tax3purchase" model="account.tax.template"> | ||
<field name="l10n_ve_rate_type">additional</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo noupdate="1"> | ||
|
||
<record id="seq_account_move" model="ir.sequence"> | ||
<field name="name">L10n Venezuela - Control Number</field> | ||
<field name="code">l10n_ve_seniat.control.number</field> | ||
<field name="prefix">00-</field> | ||
<field name="padding">8</field> | ||
<field name="company_id" eval="False" /> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright 2024 Binhex (http://binhex.cloud/) | ||
# @author: Rolando Pérez <rolando.perez@binhex.cloud> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
import logging | ||
|
||
from odoo import SUPERUSER_ID, api | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def set_rate_type_on_built_in_taxes(env, company): | ||
tax_templates = ( | ||
env["account.tax.template"] | ||
.with_context(active_test=False) | ||
.search( | ||
[ | ||
("l10n_ve_rate_type", "!=", False), | ||
("chart_template_id.country_id", "=", company.country_id.id), | ||
] | ||
) | ||
) | ||
tax_template_external_ids = tax_templates.get_external_id() | ||
for tax_template in tax_templates: | ||
external_id = tax_template_external_ids.get(tax_template.id) | ||
if external_id: | ||
tax_external_id = ( | ||
f"{external_id.split('.')[0]}.{company.id}_{external_id.split('.')[-1]}" | ||
) | ||
tax = env.ref(tax_external_id, raise_if_not_found=False) | ||
if tax: | ||
tax.l10n_ve_rate_type = tax_template.l10n_ve_rate_type | ||
|
||
|
||
def post_init_hook(cr, registry): | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
companies = env["res.company"].search([]) | ||
for company in companies.filtered(lambda c: c.country_id == env.ref("base.ve")): | ||
logger.info( | ||
"Updating rate types according to venezuelan law for built-in taxes on\ | ||
company %s ID %d", | ||
company.display_name, | ||
company.id, | ||
) | ||
set_rate_type_on_built_in_taxes(env, company) | ||
|
||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import account_move, account_tax, account_tax_template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from odoo import _, api, fields, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class AccountMove(models.Model): | ||
_inherit = "account.move" | ||
|
||
l10n_ve_control_number = fields.Char( | ||
"Control Number", | ||
help="Number used to manage pre-printed invoices, by venezuelan law", | ||
copy=False, | ||
tracking=True, | ||
) | ||
|
||
marck_paper = fields.Boolean("Voided Document", default=False) | ||
|
||
maq_fiscal_p = fields.Boolean("Fiscal Machine", default=False) | ||
|
||
@api.constrains("l10n_ve_control_number") | ||
def _check_unique_l10n_ve_control_number_insensitive(self): | ||
""" | ||
Check if another invoice/bill (as appropiate) has the same | ||
l10n_ve_control_number and the same commercial_partner_id than | ||
the current record. If so, raise a ValidationError. | ||
""" | ||
for record in self: | ||
include_receipts = True | ||
if record.l10n_ve_control_number and record.is_invoice(): | ||
move_type_range = ( | ||
record.is_sale_document(include_receipts) | ||
and record.get_sale_types(include_receipts) | ||
or record.get_purchase_types(include_receipts) | ||
) | ||
same_control_number = record.search( | ||
[ | ||
("commercial_partner_id", "=", record.commercial_partner_id.id), | ||
("move_type", "in", move_type_range), | ||
( | ||
"l10n_ve_control_number", | ||
"=ilike", | ||
record.l10n_ve_control_number, | ||
), | ||
("id", "!=", record.id), | ||
], | ||
limit=1, | ||
) | ||
if same_control_number: | ||
raise ValidationError( | ||
_( | ||
"The journal entry with control number %(number)s " | ||
"already exists in Odoo under the number %(same)s " | ||
"for supplier %(supplier)s.", | ||
number=same_control_number.l10n_ve_control_number, | ||
same=same_control_number.name or "-", | ||
supplier=same_control_number.partner_id.display_name, | ||
) | ||
) | ||
|
||
def action_post(self): | ||
result = super().action_post() | ||
country_ve = self.env.ref("base.ve") | ||
for record in self.filtered( | ||
lambda it: it.is_invoice() | ||
and it.company_id.country_id == country_ve | ||
and not it.l10n_ve_control_number | ||
): | ||
record.l10n_ve_control_number = self.env["ir.sequence"].next_by_code( | ||
"l10n_ve_seniat.control.number" | ||
) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from odoo import fields, models | ||
|
||
from .tax_rate_types_mapping import TAX_RATE_TYPES | ||
|
||
|
||
class AccountTax(models.Model): | ||
_inherit = "account.tax" | ||
|
||
l10n_ve_rate_type = fields.Selection( | ||
TAX_RATE_TYPES, | ||
string="Rate Type", | ||
help="Specify the type of rate according to Venezuelan tax law.", | ||
default="general", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2024 Binhex | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import fields, models | ||
|
||
from .tax_rate_types_mapping import TAX_RATE_TYPES | ||
|
||
|
||
class AccountTaxTemplate(models.Model): | ||
_inherit = "account.tax.template" | ||
|
||
l10n_ve_rate_type = fields.Selection(selection=TAX_RATE_TYPES) | ||
|
||
def _get_tax_vals(self, company, tax_template_to_tax): | ||
val = super()._get_tax_vals(company, tax_template_to_tax) | ||
val["l10n_ve_rate_type"] = self.l10n_ve_rate_type | ||
return val |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
TAX_RATE_TYPES = [ | ||
("exempt", "Exempt"), | ||
("no_tax_credit", "No right to tax credit"), | ||
("general", "General Rate"), | ||
("reduced", "Reduced Rate"), | ||
("additional", "General Rate + Additional"), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- `Vauxo <https://www.vauxo.com>`_ | ||
|
||
- `Binhex <https://binhex.cloud>`_ | ||
|
||
- Rolando Pérez |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Requisitos fiscales leyes venezolanas | ||
===================================== | ||
|
||
Funcionalidades: | ||
- Número de Control de Factura único para el partner. | ||
- Tipo de alicuota en impuestos según lo establecido por las leyes venezolanas. |
Oops, something went wrong.