Descancelar ticket al eliminar factura

This commit is contained in:
Mauricio Baeza 2018-03-07 23:52:03 -06:00
parent 3e3c4be720
commit e2da894d8b
2 changed files with 27 additions and 3 deletions

View File

@ -24,6 +24,7 @@ from settings import log, DEBUG, VERSION, PATH_CP, COMPANIES, PRE, CURRENT_CFDI,
FORMAT = '{0:.2f}' FORMAT = '{0:.2f}'
FORMAT3 = '{0:.3f}' FORMAT3 = '{0:.3f}'
FORMAT_TAX = '{0:.4f}' FORMAT_TAX = '{0:.4f}'
RFC_PUBLICO = 'XAXX010101000'
database_proxy = Proxy() database_proxy = Proxy()
@ -3401,6 +3402,9 @@ class Facturas(BaseModel):
if invoice.donativo and invoice.forma_pago == '12': if invoice.donativo and invoice.forma_pago == '12':
return return
if invoice.cliente.rfc == RFC_PUBLICO:
return
importe = invoice.total_mn importe = invoice.total_mn
if invoice.tipo_comprobante == 'E': if invoice.tipo_comprobante == 'E':
importe *= -1 importe *= -1
@ -3647,6 +3651,7 @@ class Facturas(BaseModel):
q.execute() q.execute()
q = FacturasRelacionadas.delete().where(FacturasRelacionadas.factura==obj) q = FacturasRelacionadas.delete().where(FacturasRelacionadas.factura==obj)
q.execute() q.execute()
Tickets.uncancel(obj)
return bool(obj.delete_instance()) return bool(obj.delete_instance())
def _get_folio(self, serie): def _get_folio(self, serie):
@ -4252,7 +4257,7 @@ class Facturas(BaseModel):
tipo_persona = 1 tipo_persona = 1
if receptor['rfc'] == 'XEXX010101000': if receptor['rfc'] == 'XEXX010101000':
tipo_persona = 4 tipo_persona = 4
elif receptor['rfc'] == 'XAXX010101000': elif receptor['rfc'] == RFC_PUBLICO:
tipo_persona = 3 tipo_persona = 3
elif len(receptor['rfc']) == 12: elif len(receptor['rfc']) == 12:
tipo_persona = 2 tipo_persona = 2
@ -5353,6 +5358,15 @@ class Tickets(BaseModel):
return inicio return inicio
@classmethod
def uncancel(cls, invoice):
query = (Tickets
.update(estatus='Generado', cancelado=False, factura=None)
.where(Tickets.factura==invoice)
)
result = query.execute()
return result
def _cancel_tickets(self, invoice, tickets): def _cancel_tickets(self, invoice, tickets):
query = (Tickets query = (Tickets
.update(estatus='Facturado', cancelado=True, factura=invoice) .update(estatus='Facturado', cancelado=True, factura=invoice)
@ -5453,7 +5467,7 @@ class Tickets(BaseModel):
if is_invoice_day: if is_invoice_day:
filters = ( filters = (
Socios.rfc == 'XAXX010101000' and Socios.rfc == RFC_PUBLICO and
Socios.slug == 'publico_en_general') Socios.slug == 'publico_en_general')
try: try:
client = Socios.get(filters) client = Socios.get(filters)
@ -7166,7 +7180,7 @@ def _init_values(rfc):
data = ( data = (
{'clave': 'version', 'valor': VERSION}, {'clave': 'version', 'valor': VERSION},
{'clave': 'migracion', 'valor': '0'}, {'clave': 'migracion', 'valor': '0'},
{'clave': 'rfc_publico', 'valor': 'XAXX010101000'}, {'clave': 'rfc_publico', 'valor': RFC_PUBLICO},
{'clave': 'rfc_extranjero', 'valor': 'XEXX010101000'}, {'clave': 'rfc_extranjero', 'valor': 'XEXX010101000'},
{'clave': 'decimales', 'valor': '2'}, {'clave': 'decimales', 'valor': '2'},
{'clave': 'path_key', 'valor': ''}, {'clave': 'path_key', 'valor': ''},

View File

@ -495,6 +495,16 @@ function cmd_cancelar_ticket_click(){
return return
} }
if(row['estatus']=='Cancelado'){
msg_error('El ticket ya esta cancelado')
return
}
if(row['estatus']=='Facturado'){
msg_error('El ticket esta facturado')
return
}
msg = '¿Estás seguro de cancelar el siguiente Ticket?<BR><BR>' msg = '¿Estás seguro de cancelar el siguiente Ticket?<BR><BR>'
msg += 'Folio: ' + row['folio'] msg += 'Folio: ' + row['folio']
msg += '<BR><BR>ESTA ACCIÓN NO SE PUEDE DESHACER' msg += '<BR><BR>ESTA ACCIÓN NO SE PUEDE DESHACER'