Commit 48ac1c99 authored by Jorge Sanabria's avatar Jorge Sanabria
Browse files

Update 2020-12-08-21:24

parent ec59a601
......@@ -20,4 +20,5 @@
# email: info@jorels.com
#
from . import controllers
from . import models
......@@ -37,9 +37,9 @@
'account',
# 'snailmail_account',
'l10n_co',
#'web_notify',
'web_notify',
'update_from_csv',
#'account_debitnote',
'account_debitnote',
],
'data': [
'security/security.xml',
......
from . import main
\ No newline at end of file
import json
import logging
from odoo import http
from odoo.http import request
_logger = logging.getLogger(__name__)
class Webhooks(http.Controller):
@http.route('/l10n_co_edi_jorels/webhook/in_invoice/<company_id>', type='json', auth='public', methods=['POST'],
csrf=False)
def webhook_in_invoice(self, company_id, **args):
# journal_id = 2
# partner_id = 1
# json_example = {'a': 1, 'b': 2, 'c': '3', 'd': '4'}
# data = json.loads(request.httprequest.args)
data = json.loads(request.httprequest.data)
# request.env['account.invoice'].sudo().create({
# 'partner_id': partner_id,
# 'journal_id': journal_id,
# 'type': 'in_invoice',
# 'comment': data
# })
_logger.debug("webhook_in_invoice: company_id: %s, json: %s", company_id, data)
return "Test Ok"
......@@ -88,6 +88,9 @@ class AccountInvoice(models.Model):
ei_amount_tax_no_withholding = fields.Monetary("Impuestos sin retenciones", compute="_compute_amount", store=True)
ei_amount_total_no_withholding = fields.Monetary("Total sin retenciones", compute="_compute_amount", store=True)
# Total base excluida de impuestos
ei_amount_excluded = fields.Monetary("Excluido", compute="_compute_amount", store=True)
def action_invoice_sent(self):
self.ensure_one()
action = super().action_invoice_sent()
......@@ -263,11 +266,11 @@ class AccountInvoice(models.Model):
def get_ei_legal_monetary_totals(self):
for rec in self:
line_extension_amount = rec.amount_untaxed
tax_exclusive_amount = rec.amount_untaxed
tax_inclusive_amount = rec.ei_amount_total_no_withholding
tax_exclusive_amount = rec.amount_untaxed - rec.ei_amount_excluded
allowance_total_amount = 0.0
charge_total_amount = 0.0
payable_amount = tax_inclusive_amount
payable_amount = rec.ei_amount_total_no_withholding
tax_inclusive_amount = payable_amount - charge_total_amount + allowance_total_amount
return {
"line_extension_amount": line_extension_amount,
......@@ -369,6 +372,8 @@ class AccountInvoice(models.Model):
# los impuestos se adjuntan dentro de este json
if tax_totals['tax_totals']:
invoice_temps.update({'tax_totals': tax_totals['tax_totals']})
else:
invoice_temps.pop("reference_price_id")
lines.append(invoice_temps)
......@@ -403,30 +408,37 @@ class AccountInvoice(models.Model):
# }
# ]
# Calculo de las retenciones
# Calculo de las retenciones, excluidos, etc
@api.one
def _compute_amount(self):
res = super(AccountInvoice, self)._compute_amount()
amount_tax_withholding = 0
amount_tax_no_withholding = 0
amount_excluded = 0
for tax_line_id in self.tax_line_ids:
if tax_line_id.tax_id.edi_tax_id:
edi_tax_name = tax_line_id.tax_id.edi_tax_id.name
if edi_tax_name[:4] != 'Rete':
amount_tax_no_withholding = amount_tax_no_withholding + tax_line_id.amount_total
else:
tax_name = tax_line_id.tax_id.name
if tax_name == 'IVA Excluido':
amount_excluded = amount_excluded + tax_line_id.base
elif edi_tax_name[:4] == 'Rete':
amount_tax_withholding = amount_tax_withholding + tax_line_id.amount_total
else:
amount_tax_no_withholding = amount_tax_no_withholding + tax_line_id.amount_total
else:
tax_name = tax_line_id.tax_id.name
if tax_name[:3] != 'Rte':
amount_tax_no_withholding = amount_tax_no_withholding + tax_line_id.amount_total
else:
if tax_name == 'IVA Excluido':
amount_excluded = amount_excluded + tax_line_id.base
elif tax_name[:3] == 'Rte':
amount_tax_withholding = amount_tax_withholding + tax_line_id.amount_total
else:
amount_tax_no_withholding = amount_tax_no_withholding + tax_line_id.amount_total
self.ei_amount_tax_withholding = amount_tax_withholding
self.ei_amount_tax_no_withholding = amount_tax_no_withholding
self.ei_amount_total_no_withholding = self.amount_untaxed + amount_tax_no_withholding
self.ei_amount_excluded = amount_excluded
return res
@api.multi
......@@ -690,7 +702,7 @@ class AccountInvoice(models.Model):
@api.multi
def validate_dian_generic(self, is_test):
# raise Warning(json.dumps(self.get_json_request(), indent=2, sort_keys=False))
# _logger.debug("Request Validación DIAN: %s", json.dumps(self.get_json_request(), indent=2, sort_keys=False))
_logger.debug("Request Validación DIAN: %s", json.dumps(self.get_json_request(), indent=2, sort_keys=False))
for rec in self:
try:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment