Skip to content

Commit

Permalink
Merge branch '11.0' into 11.0-br_nfe
Browse files Browse the repository at this point in the history
  • Loading branch information
danimaribeiro committed Apr 3, 2018
2 parents cd41926 + 54fdb6e commit c9303ab
Show file tree
Hide file tree
Showing 27 changed files with 851 additions and 41 deletions.
2 changes: 1 addition & 1 deletion br_account/models/account_invoice_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def _compute_cst_icms(self):
tax_icms_fcp_id = fields.Many2one(
'account.tax', string="% FCP", domain=[('domain', '=', 'fcp')])
icms_aliquota_inter_part = fields.Float(
u'% Partilha', default=20.0, digits=dp.get_precision('Discount'))
u'% Partilha', default=80.0, digits=dp.get_precision('Discount'))
icms_fcp_uf_dest = fields.Float(
string=u'Valor FCP', compute='_compute_price',
digits=dp.get_precision('Discount'), )
Expand Down
6 changes: 3 additions & 3 deletions br_account/models/account_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,11 @@ def _compute_difal(self, price_base, ipi_value):
if 'icms_aliquota_inter_part' in self.env.context:
icms_inter_part = self.env.context["icms_aliquota_inter_part"]
else:
icms_inter_part = 20.0
icms_inter_part = 80.0
vals_inter['amount'] = round((interno - interestadual) *
icms_inter_part / 100, 2)
vals_intra['amount'] = round((interno - interestadual) *
(100 - icms_inter_part) / 100, 2)
vals_intra['amount'] = round((interno - interestadual) *
icms_inter_part / 100, 2)

taxes = [vals_inter, vals_intra]
if vals_fcp:
Expand Down
8 changes: 4 additions & 4 deletions br_account/tests/test_taxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ def test_tax_difal(self):
self.assertEquals(res['total_excluded'], 100.0)
self.assertEquals(res['total_included'], 100.0)
self.assertEquals(len(res['taxes']), 2)
self.assertEquals(res['taxes'][0]['amount'], 3.0) # Remetente
self.assertEquals(res['taxes'][1]['amount'], 7.0) # Destinatário
self.assertEquals(res['taxes'][0]['amount'], 7.0) # Remetente
self.assertEquals(res['taxes'][1]['amount'], 3.0) # Destinatário

def test_tax_difal_por_dentro(self):
taxes = self.icms_difal_inter_1200 | self.icms_difal_intra_1800
Expand All @@ -238,8 +238,8 @@ def test_tax_difal_por_dentro(self):
self.assertEquals(res['total_excluded'], 100.0)
self.assertEquals(res['total_included'], 100.0)
self.assertEquals(len(res['taxes']), 2)
self.assertEquals(res['taxes'][0]['amount'], 2.2) # Remetente
self.assertEquals(res['taxes'][1]['amount'], 5.12) # Destinatário
self.assertEquals(res['taxes'][0]['amount'], 5.12) # Remetente
self.assertEquals(res['taxes'][1]['amount'], 2.2) # Destinatário

def test_difal_fcp(self):
taxes = self.icms_difal_inter_700 | self.icms_difal_intra_1700 | \
Expand Down
12 changes: 8 additions & 4 deletions br_boleto/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,15 @@ def action_register_boleto(self):
if not move.payment_mode_id.nosso_numero_sequence.id:
raise UserError(u'Cadastre a sequência do nosso número no modo \
de pagamento')
vencimento = fields.Date.from_string(move.date_maturity)
if vencimento < datetime.today().date() and not move.reconciled:
raise UserError(u'A data de vencimento deve ser maior que a \
data atual. Altere a data de vencimento!')
if not move.boleto_emitido:
vencimento = fields.Date.from_string(move.date_maturity)
if vencimento < datetime.today().date() and not\
move.reconciled:
raise UserError(u'A data de vencimento deve ser maior que a \
data atual na fatura: ' +
move.move_id.name +
u' - ' + move.partner_id.name +
u'.\n Altere a data de vencimento!')
move.boleto_emitido = True
move.nosso_numero = \
move.payment_mode_id.nosso_numero_sequence.next_by_id()
Expand Down
3 changes: 2 additions & 1 deletion br_data_account/data/br_account.fiscal.document.csv
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@
"fiscal_document_007","007","NFS-e - Provedor SAATRI","True","True"
"fiscal_document_008","008","NFS-e - Provedor SIMPLISS","True","True"
"fiscal_document_009","009","NFS-e - Provedor SUSESU","True","True"
"fiscal_document_010","010","NFS-e Imperial - Petrópolis","True","True"
"fiscal_document_010","010","NFS-e - Nota Imperial Petrópolis","True","True"
"fiscal_document_012","012","NFS-e - Florianópolis","True","True"
"fiscal_document_013","013","NFS-e - Nota Carioca","True","True"
14 changes: 9 additions & 5 deletions br_nfe/models/invoice_eletronic.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
from pytrustnfe.nfe import recepcao_evento_cancelamento
from pytrustnfe.nfe import consultar_protocolo_nfe
from pytrustnfe.certificado import Certificado
from pytrustnfe.utils import ChaveNFe, gerar_chave, gerar_nfeproc
from pytrustnfe.utils import ChaveNFe, gerar_chave, gerar_nfeproc, \
gerar_nfeproc_cancel
from pytrustnfe.nfe.danfe import danfe
from pytrustnfe.xml.validate import valida_nfe
except ImportError:
Expand Down Expand Up @@ -806,20 +807,18 @@ def action_send_eletronic_invoice(self):
self.mensagem_retorno = retorno.protNFe.infProt.xMotivo
if self.codigo_retorno == '100':
self.write({
'state': 'done', 'nfe_exception': False,
'state': 'done',
'protocolo_nfe': retorno.protNFe.infProt.nProt,
'data_autorizacao': retorno.protNFe.infProt.dhRecbto})
# Duplicidade de NF-e significa que a nota já está emitida
# TODO Buscar o protocolo de autorização, por hora só finalizar
if self.codigo_retorno == '204':
self.write({'state': 'done', 'codigo_retorno': '100',
'nfe_exception': False,
'mensagem_retorno': 'Autorizado o uso da NF-e'})

# Denegada e nota já está denegada
if self.codigo_retorno in ('302', '205'):
self.write({'state': 'denied',
'nfe_exception': True})
self.write({'state': 'denied'})

self.env['invoice.eletronic.event'].create({
'code': self.codigo_retorno,
Expand Down Expand Up @@ -952,3 +951,8 @@ def action_cancel_document(self, context=None, justificativa=None):
})
self._create_attachment('canc', self, resp['sent_xml'])
self._create_attachment('canc-ret', self, resp['received_xml'])
nfe_processada = base64.decodestring(self.nfe_processada)
nfe_proc_cancel = gerar_nfeproc_cancel(nfe_processada,
resp['received_xml'])
self.nfe_processada = base64.encodestring(nfe_proc_cancel)
self.nfe_processada_name = "NFe%08d.xml" % self.numero
2 changes: 1 addition & 1 deletion br_nfe/models/invoice_eletronic_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _compute_cst_danfe(self):
icms_aliquota_interestadual = fields.Float(
string=u"% ICMS Inter", readonly=True, states=STATE)
icms_aliquota_inter_part = fields.Float(
string=u'% Partilha', default=60.0, readonly=True, states=STATE)
string=u'% Partilha', default=80.0, readonly=True, states=STATE)
icms_uf_remet = fields.Monetary(
string=u'ICMS Remetente', readonly=True, states=STATE)
icms_uf_dest = fields.Monetary(
Expand Down
6 changes: 6 additions & 0 deletions br_nfe/tests/test_nfe.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,12 @@ def test_nfe_cancelamento_ok(self, consulta, cancelar, validar):

invoice_eletronic = self.env['invoice.eletronic'].search(
[('invoice_id', '=', invoice.id)])

# As 2 linhas seguintes servem apenas para setar o nfe_processada
# do invoice_eletronic -> famosa gambiarra
encoded_xml = '<xml />'.encode('utf-8')
invoice_eletronic.nfe_processada = base64.encodestring(encoded_xml)

invoice_eletronic.action_cancel_document(
justificativa="Cancelamento de teste")

Expand Down
5 changes: 5 additions & 0 deletions br_nfse_carioca/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Danimar Ribeiro, Trustcode
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
28 changes: 28 additions & 0 deletions br_nfse_carioca/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# © 2016 Danimar Ribeiro, Trustcode
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{ # pylint: disable=C8101,C8103
'name': 'Integração Nota Carioca',
'description': """Efetua a integração com a prefeitura do Rio de Janeiro
- Mantido por Trustcode""",
'summary': """Efetua a integração com a prefeitura do Rio de Janeiro
- Mantido por Trustcode""",
'version': '11.0.1.0.0',
'category': "Accounting & Finance",
'author': 'Trustcode',
'license': 'AGPL-3',
'website': 'http://www.trustcode.com.br',
'contributors': [
'Danimar Ribeiro <danimaribeiro@gmail.com>'
],
'depends': [
'br_nfse',
],
'data': [
'views/br_account_service.xml',
'views/res_company.xml',
'reports/danfpse.xml',
],
'application': True,
}
8 changes: 8 additions & 0 deletions br_nfse_carioca/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
# © 2017 Danimar Ribeiro, Trustcode
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import account_invoice
from . import invoice_eletronic
from . import br_account_service
from . import res_company
21 changes: 21 additions & 0 deletions br_nfse_carioca/models/account_invoice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# © 2017 Danimar Ribeiro, Trustcode
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).


from odoo import models


class AccountInvoice(models.Model):
_inherit = 'account.invoice'

def _return_pdf_invoice(self, doc):
if self.service_document_id.code == '013': # Nota carioca
return 'br_nfse_carioca.report_br_nfse_danfe_carioca'
return super(AccountInvoice, self)._return_pdf_invoice(doc)

def _prepare_edoc_item_vals(self, line):
res = super(AccountInvoice, self)._prepare_edoc_item_vals(line)
res['codigo_tributacao_municipio'] = \
line.service_type_id.codigo_tributacao_municipio
return res
12 changes: 12 additions & 0 deletions br_nfse_carioca/models/br_account_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# © 2018 Danimar Ribeiro <danimaribeiro@gmail.com>, Trustcode
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class BrAccountServiceType(models.Model):
_inherit = 'br_account.service.type'

codigo_tributacao_municipio = fields.Char(
string=u"Cód. Tribut. Munic.", size=20,
help="Código de Tributação no Munípio")
Loading

0 comments on commit c9303ab

Please sign in to comment.