From de2ab5cedd18e043d8a43bae968d6bf7657f30d1 Mon Sep 17 00:00:00 2001 From: El Mau Date: Mon, 11 Apr 2022 22:47:37 -0500 Subject: [PATCH] Obtener regimen fiscal del receptor al facturar desde tickets --- source/app/models/main.py | 15 ++++++++++----- source/static/js/controller/tickets.js | 1 - 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source/app/models/main.py b/source/app/models/main.py index ff69b4c..9bf608c 100644 --- a/source/app/models/main.py +++ b/source/app/models/main.py @@ -8425,6 +8425,14 @@ class Tickets(BaseModel): data = {'ok': False, 'msg': msg} return data + try: + receptor_regimen = SociosRegimenes.get_by_key(client)[0]['id'] + except Exception as e: + log.error(e) + msg = 'Error al obtener el Regimen Fiscal del receptor' + data = {'ok': False, 'msg': msg} + return data + payment_type = cls._get_payment_type(cls, tickets) emisor = Emisor.select()[0] @@ -8432,15 +8440,12 @@ class Tickets(BaseModel): data['cliente'] = client data['serie'] = cls._get_serie(cls, user, True) data['folio'] = cls._get_folio_invoice(cls, data['serie']) - # ~ data['forma_pago'] = client.forma_pago.key data['forma_pago'] = payment_type data['tipo_cambio'] = 1.00 data['lugar_expedicion'] = emisor.cp_expedicion or emisor.codigo_postal - if client.uso_cfdi is None: - data['uso_cfdi'] = 'P01' - else: - data['uso_cfdi'] = client.uso_cfdi.key + data['uso_cfdi'] = client.uso_cfdi.key data['regimen_fiscal'] = emisor.regimenes[0].key + data['receptor_regimen'] = receptor_regimen with database_proxy.atomic() as txn: obj = Facturas.create(**data) diff --git a/source/static/js/controller/tickets.js b/source/static/js/controller/tickets.js index bb0b4ca..00681c0 100644 --- a/source/static/js/controller/tickets.js +++ b/source/static/js/controller/tickets.js @@ -616,7 +616,6 @@ function chk_is_invoice_day_change(new_value, old_value){ function send_timbrar_invoice(id){ - //~ webix.ajax().get('/values/timbrar', {id: id, update: false}, function(text, data){ webix.ajax().post('invoices', {opt: 'timbrar', id: id, update: false}, function(text, data){ var values = data.json() if(values.ok){