Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][IMP] l10n_br_sped_efd_icms_ipi: add Registro0200 to SPED #62

Open
wants to merge 2 commits into
base: 14.0-ak-sped-hack-poppi
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 33 additions & 6 deletions l10n_br_sped_efd_icms_ipi/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SPED - EFD ICMS IPI
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:da8644dc46b3804bb2fe18147e5b0e5481b1b48b135bb30ea993ed7e104f095b
!! source digest: sha256:5c90c680fdf839a66bd2ea323af60b071ce814c0d7a0667d85932c230f245edd
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
Expand All @@ -28,7 +28,24 @@ SPED - EFD ICMS IPI

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

TODO
Arquivo EFD ICMS/IPI do SPED / SPED Fiscal
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Este módulo contém toda a estrutura dos registros da ECF ICMS/IPI do SPED.
Ou seja se vocẽ preencher todos registros do SPED, o arquivo digital vai sair certinho.
**Porem o mapeamento dos dados a partir das transações do Odoo é um trabalho parcial
e em andamento**. Foi colocado o módulo no repo da localização para facilitar as contribuições
mas é importante vocẽ homologar bem até que ponto os mapeamentos atuais atendem você.

A ideia é começar pelos mapeamentos das transações mais intensivas e mais comum
para facilitar a geração dos blocos relevantes do SPED e completar o arquivo
do SPED manualmente (dentro do Odoo, dentro do validador gratuito ou dentro
de um software especializado) ou deixar um escritório de contabilidade fazê-lo.
É possível também importar arquivos de SPED para completar o que o ainda
não teria sido possível mapear a partir do Odoo.

Vocẽ pode se referir a documentação do módulo l10n_br_sped_base para ver como
O sistema de mapeamento funciona.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Expand All @@ -40,6 +57,13 @@ TODO
.. contents::
:local:

Usage
=====

1. Entre no menu SPED>ECD ICMS IPI e crie uma Declaração do SPED para a empresa e o período desejado. Preencher os dados (se trata dos dados do registro 0000 na verdade)
2. clique no botão "Puxar os registros do Odoo" para popular os registros do SPED.
3. Finalmente, clique no botão "Gerar arquivo do SPED" e baixe o arquivo que foi adicionado no chatter. Vocẽ pode transmitir o arquivo com o validador gratuito da receita por exemplo.

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

Expand Down Expand Up @@ -67,6 +91,9 @@ Contributors
* Renato Lima <[email protected]>
* Clement Monbereau <[email protected]>

* `ATS Soluções Empresariais <https://atsti.com.br>`_:

* Carlos Silveira <[email protected]>

Maintainers
~~~~~~~~~~~
Expand All @@ -81,16 +108,16 @@ 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.

.. |maintainer-renatonlima| image:: https://github.com/renatonlima.png?size=40px
:target: https://github.com/renatonlima
:alt: renatonlima
.. |maintainer-rvalyi| image:: https://github.com/rvalyi.png?size=40px
:target: https://github.com/rvalyi
:alt: rvalyi
.. |maintainer-renatonlima| image:: https://github.com/renatonlima.png?size=40px
:target: https://github.com/renatonlima
:alt: renatonlima

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-renatonlima| |maintainer-rvalyi|
|maintainer-rvalyi| |maintainer-renatonlima|

This module is part of the `OCA/l10n-brazil <https://github.com/OCA/l10n-brazil/tree/14.0/l10n_br_sped_efd_icms_ipi>`_ project on GitHub.

Expand Down
80 changes: 48 additions & 32 deletions l10n_br_sped_efd_icms_ipi/models/sped_efd_icms_ipi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@
# flake8: noqa: B950

import textwrap
from datetime import datetime

from erpbrasil.base import misc
from lxml.builder import E

from odoo import api, fields, models
from odoo.exceptions import UserError

from datetime import datetime, timedelta
import pytz
import base64

from odoo.addons.l10n_br_sped_base.models.sped_mixin import LAYOUT_VERSIONS


Expand Down Expand Up @@ -304,23 +301,44 @@ class Registro0200(models.Model):
_description = textwrap.dedent(" %s" % (__doc__,))
_name = "l10n_br_sped.efd_icms_ipi.0200"
_inherit = "l10n_br_sped.efd_icms_ipi.17.0200"
_odoo_model = "product.product"

# @api.model
# def _map_from_odoo(self, record, parent_record, declaration, index=0):
# return {
# "COD_ITEM": 0, # Código do item
# "DESCR_ITEM": 0, # Descrição do item
# "COD_BARRA": 0, # Representação alfanumérico do código de barra do p...
# "COD_ANT_ITEM": 0, # Código anterior do item com relação à última in...
# "UNID_INV": 0, # Unidade de medida utilizada na quantificação de est...
# "TIPO_ITEM": 0, # Tipo do item – Atividades Industriais, Comerciais ...
# "COD_NCM": 0, # Código da Nomenclatura Comum do Mercosul
# "EX_IPI": 0, # Código EX, conforme a TIPI
# "COD_GEN": 0, # Código do gênero do item, conforme a Tabela 4.2.1
# "COD_LST": 0, # Código do serviço conforme lista do Anexo I da Lei C...
# "ALIQ_ICMS": 0, # Alíquota de ICMS aplicável ao item nas operações i...
# "CEST": 0, # Código Especificador da Substituição Tributária
# }
@api.model
def _odoo_domain(self, parent_record, declaration):
to_date = "%s 23:59:00" % (datetime.strftime(declaration.DT_FIN, "%Y-%m-%d"))
context = dict(self.env.context, to_date=to_date)
product = self.env["product.product"].with_context(context)
records = product.search([("qty_available", ">", 0)])
return [
("id", "in", records.ids),
]

@api.model
def _map_from_odoo(self, record, parent_record, declaration, index=0):
state_id = record.company_id.state_id or self.env.company.state_id
tax_definition_id = env["l10n_br_fiscal.tax.definition"].search([
("tax_group_id.name", "ilike", "ICMS"),
("state_from_id", "=", state_id.id),
("state_to_ids", "ilike", state_id.id),
("ncm_ids", "ilike", record.ncm_id.id),
],
limit=1,
)
aliq_icms = tax_definition_id.tax_id.percent_amount
return {
"COD_ITEM": record.default_code, # Código do item
"DESCR_ITEM": record.name, # Descrição do item
"COD_BARRA": record.barcode or "", # Representação alfanumérico do códi...
"COD_ANT_ITEM": "", # Código anterior do item com relação à última in...
"UNID_INV": record.uom_id.code, # Unidade de medida utilizada na quanti...
"TIPO_ITEM": record.fiscal_type, # Tipo do item – Atividades Industriai...
"COD_NCM": record.ncm_id.code, # Código da Nomenclatura Comum do Mercosul
"EX_IPI": "", # Código EX, conforme a TIPI
"COD_GEN": record.fiscal_genre_id.code, # Código do gênero do item
"COD_LST": record.service_type_id.code or "", # Código do serviço
"ALIQ_ICMS": aliq_icms or "", # Alíquota de ICMS
"CEST": record.cest_id.code or "", # Código Especificador da Substituiç...
}


class Registro0205(models.Model):
Expand Down Expand Up @@ -3687,11 +3705,10 @@ class RegistroH005(models.Model):
@api.model
def _map_from_odoo(self, record, parent_record, declaration, index=0):

to_date = '%s 23:59:00' %(datetime.strftime(
declaration.DT_FIN, '%Y-%m-%d'))
to_date = "%s 23:59:00" % (datetime.strftime(declaration.DT_FIN, "%Y-%m-%d"))
context = dict(self.env.context, to_date=to_date)
product = self.env['product.product'].with_context(context)
records = product.search([('qty_available','>', 0)])
product = self.env["product.product"].with_context(context)
records = product.search([("qty_available", ">", 0)])
inventory_amount = 0.0
for record in records:
inventory_amount += record.qty_available * record.standard_price
Expand All @@ -3711,11 +3728,10 @@ class RegistroH010(models.Model):

@api.model
def _odoo_domain(self, parent_record, declaration):
to_date = '%s 23:59:00' %(datetime.strftime(
declaration.DT_FIN, '%Y-%m-%d'))
to_date = "%s 23:59:00" % (datetime.strftime(declaration.DT_FIN, "%Y-%m-%d"))
context = dict(self.env.context, to_date=to_date)
product = self.env['product.product'].with_context(context)
records = product.search([('qty_available','>', 0)])
product = self.env["product.product"].with_context(context)
records = product.search([("qty_available", ">", 0)])
return [
("id", "in", records.ids),
]
Expand All @@ -3735,6 +3751,7 @@ def _map_from_odoo(self, record, parent_record, declaration, index=0):
"VL_ITEM_IR": 0, # Valor do item para efeitos do Imposto de Renda.
}


class RegistroH020(models.Model):
"Informação complementar do Inventário"
_description = textwrap.dedent(" %s" % (__doc__,))
Expand Down Expand Up @@ -3789,11 +3806,10 @@ class RegistroK200(models.Model):

@api.model
def _odoo_domain(self, parent_record, declaration):
to_date = '%s 23:59:00' %(datetime.strftime(
declaration.DT_FIN, '%Y-%m-%d'))
to_date = "%s 23:59:00" % (datetime.strftime(declaration.DT_FIN, "%Y-%m-%d"))
context = dict(self.env.context, to_date=to_date)
product = self.env['product.product'].with_context(context)
records = product.search([('qty_available','>', 0)])
product = self.env["product.product"].with_context(context)
records = product.search([("qty_available", ">", 0)])
return [
("id", "in", records.ids),
]
Expand Down
65 changes: 44 additions & 21 deletions l10n_br_sped_efd_icms_ipi/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>SPED - EFD ICMS IPI</title>
<style type="text/css">

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.

See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/

Expand Down Expand Up @@ -367,10 +367,24 @@ <h1 class="title">SPED - EFD ICMS IPI</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:da8644dc46b3804bb2fe18147e5b0e5481b1b48b135bb30ea993ed7e104f095b
!! source digest: sha256:5c90c680fdf839a66bd2ea323af60b071ce814c0d7a0667d85932c230f245edd
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/l10n-brazil/tree/14.0/l10n_br_sped_efd_icms_ipi"><img alt="OCA/l10n-brazil" src="https://img.shields.io/badge/github-OCA%2Fl10n--brazil-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/l10n-brazil-14-0/l10n-brazil-14-0-l10n_br_sped_efd_icms_ipi"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-brazil&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>TODO</p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/l10n-brazil/tree/14.0/l10n_br_sped_efd_icms_ipi"><img alt="OCA/l10n-brazil" src="https://img.shields.io/badge/github-OCA%2Fl10n--brazil-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/l10n-brazil-14-0/l10n-brazil-14-0-l10n_br_sped_efd_icms_ipi"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-brazil&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<div class="section" id="arquivo-efd-icms-ipi-do-sped-sped-fiscal">
<h1>Arquivo EFD ICMS/IPI do SPED / SPED Fiscal</h1>
<p>Este módulo contém toda a estrutura dos registros da ECF ICMS/IPI do SPED.
Ou seja se vocẽ preencher todos registros do SPED, o arquivo digital vai sair certinho.
<strong>Porem o mapeamento dos dados a partir das transações do Odoo é um trabalho parcial
e em andamento</strong>. Foi colocado o módulo no repo da localização para facilitar as contribuições
mas é importante vocẽ homologar bem até que ponto os mapeamentos atuais atendem você.</p>
<p>A ideia é começar pelos mapeamentos das transações mais intensivas e mais comum
para facilitar a geração dos blocos relevantes do SPED e completar o arquivo
do SPED manualmente (dentro do Odoo, dentro do validador gratuito ou dentro
de um software especializado) ou deixar um escritório de contabilidade fazê-lo.
É possível também importar arquivos de SPED para completar o que o ainda
não teria sido possível mapear a partir do Odoo.</p>
<p>Vocẽ pode se referir a documentação do módulo l10n_br_sped_base para ver como
O sistema de mapeamento funciona.</p>
<div class="admonition important">
<p class="first admonition-title">Important</p>
<p class="last">This is an alpha version, the data model and design can change at any time without warning.
Expand All @@ -380,55 +394,64 @@ <h1 class="title">SPED - EFD ICMS IPI</h1>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#bug-tracker" id="id1">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id5">Maintainers</a></li>
</ul>
</li>
<li><a class="reference internal" href="#usage" id="toc-entry-1">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a></li>
</ul>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
<ol class="arabic simple">
<li>Entre no menu SPED&gt;ECD ICMS IPI e crie uma Declaração do SPED para a empresa e o período desejado. Preencher os dados (se trata dos dados do registro 0000 na verdade)</li>
<li>clique no botão “Puxar os registros do Odoo” para popular os registros do SPED.</li>
<li>Finalmente, clique no botão “Gerar arquivo do SPED” e baixe o arquivo que foi adicionado no chatter. Vocẽ pode transmitir o arquivo com o validador gratuito da receita por exemplo.</li>
</ol>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id1">Bug Tracker</a></h1>
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/l10n-brazil/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/l10n-brazil/issues/new?body=module:%20l10n_br_sped_efd_icms_ipi%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id2">Credits</a></h1>
<h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
</div>
</div>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id3">Authors</a></h2>
<h1>Authors</h1>
<ul class="simple">
<li>Akretion</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id4">Contributors</a></h2>
<h1>Contributors</h1>
<ul class="simple">
<li><a class="reference external" href="https://akretion.com/pt-BR/">AKRETION</a>:<ul>
<li>Raphaël Valyi &lt;<a class="reference external" href="mailto:raphael.valyi&#64;akretion.com.br">raphael.valyi&#64;akretion.com.br</a>&gt;</li>
<li>Renato Lima &lt;<a class="reference external" href="mailto:renato.lima&#64;akretion.com.br">renato.lima&#64;akretion.com.br</a>&gt;</li>
<li>Clement Monbereau &lt;<a class="reference external" href="mailto:clement.mombereau&#64;akretion.com.br">clement.mombereau&#64;akretion.com.br</a>&gt;</li>
</ul>
</li>
<li><a class="reference external" href="https://atsti.com.br">ATS Soluções Empresariais</a>:<ul>
<li>Carlos Silveira &lt;<a class="reference external" href="mailto:carlos&#64;atsti.com.br">carlos&#64;atsti.com.br</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id5">Maintainers</a></h2>
<h1>Maintainers</h1>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external" href="https://github.com/renatonlima"><img alt="renatonlima" src="https://github.com/renatonlima.png?size=40px" /></a> <a class="reference external" href="https://github.com/rvalyi"><img alt="rvalyi" src="https://github.com/rvalyi.png?size=40px" /></a></p>
<p><a class="reference external image-reference" href="https://github.com/rvalyi"><img alt="rvalyi" src="https://github.com/rvalyi.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/renatonlima"><img alt="renatonlima" src="https://github.com/renatonlima.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/l10n-brazil/tree/14.0/l10n_br_sped_efd_icms_ipi">OCA/l10n-brazil</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>
Loading