forked from elmau/empresa-libre
Abrir PDFs grandes
This commit is contained in:
parent
7873a4376c
commit
6a32760b05
|
@ -740,6 +740,7 @@ class LIBO(object):
|
||||||
|
|
||||||
def _conceptos(self, data):
|
def _conceptos(self, data):
|
||||||
first = True
|
first = True
|
||||||
|
copy = False
|
||||||
for concepto in data:
|
for concepto in data:
|
||||||
key = concepto.get('noidentificacion', '')
|
key = concepto.get('noidentificacion', '')
|
||||||
description = concepto['descripcion']
|
description = concepto['descripcion']
|
||||||
|
@ -757,18 +758,14 @@ class LIBO(object):
|
||||||
cell_6 = self._set_cell('{importe}', importe, value=True)
|
cell_6 = self._set_cell('{importe}', importe, value=True)
|
||||||
else:
|
else:
|
||||||
row = cell_2.getCellAddress().Row + 1
|
row = cell_2.getCellAddress().Row + 1
|
||||||
self._sheet.getRows().insertByIndex(row, 1)
|
if not copy:
|
||||||
if cell_1:
|
self._sheet.getRows().insertByIndex(row, len(data)-1)
|
||||||
self._copy_cell(cell_1)
|
copy = True
|
||||||
cell_1 = self._set_cell(v=key, cell=cell_1)
|
source = self._sheet.getRows().getByIndex(row - 1)
|
||||||
if cell_3:
|
cell_1 = self._set_cell(v=key, cell=cell_1)
|
||||||
self._copy_cell(cell_3)
|
self._sheet.copyRange(cell_1.getCellAddress(), source.getRangeAddress())
|
||||||
cell_3 = self._set_cell(v=unidad, cell=cell_3)
|
|
||||||
self._copy_cell(cell_2)
|
|
||||||
self._copy_cell(cell_4)
|
|
||||||
self._copy_cell(cell_5)
|
|
||||||
self._copy_cell(cell_6)
|
|
||||||
cell_2 = self._set_cell(v=description, cell=cell_2)
|
cell_2 = self._set_cell(v=description, cell=cell_2)
|
||||||
|
cell_3 = self._set_cell(v=unidad, cell=cell_3)
|
||||||
cell_4 = self._set_cell(v=cantidad, cell=cell_4, value=True)
|
cell_4 = self._set_cell(v=cantidad, cell=cell_4, value=True)
|
||||||
cell_5 = self._set_cell(v=valor_unitario, cell=cell_5, value=True)
|
cell_5 = self._set_cell(v=valor_unitario, cell=cell_5, value=True)
|
||||||
cell_6 = self._set_cell(v=importe, cell=cell_6, value=True)
|
cell_6 = self._set_cell(v=importe, cell=cell_6, value=True)
|
||||||
|
|
|
@ -15,4 +15,5 @@ thunder-lock = true
|
||||||
#~ stats = 127.0.0.1:9191
|
#~ stats = 127.0.0.1:9191
|
||||||
#~ Establece una ruta accesible para el servidor web
|
#~ Establece una ruta accesible para el servidor web
|
||||||
logger = file:/srv/log/empresalibre-uwsgi.log
|
logger = file:/srv/log/empresalibre-uwsgi.log
|
||||||
log-maxsize = 1000000
|
log-maxsize = 1000000
|
||||||
|
http-timeout = 180
|
|
@ -8,3 +8,4 @@ threads = 4
|
||||||
py-autoreload = 1
|
py-autoreload = 1
|
||||||
thunder-lock = true
|
thunder-lock = true
|
||||||
static-map = /static=../static
|
static-map = /static=../static
|
||||||
|
http-timeout = 120
|
|
@ -25,6 +25,9 @@ class StorageEngine(object):
|
||||||
return getattr(self, '_get_{}'.format(table))(values, session)
|
return getattr(self, '_get_{}'.format(table))(values, session)
|
||||||
return getattr(self, '_get_{}'.format(table))(values)
|
return getattr(self, '_get_{}'.format(table))(values)
|
||||||
|
|
||||||
|
def _get_canopenpre(self, values):
|
||||||
|
return main.PreFacturasDetalle.can_open(values['id'])
|
||||||
|
|
||||||
def _get_importinvoice(self, values):
|
def _get_importinvoice(self, values):
|
||||||
return main.import_invoice()
|
return main.import_invoice()
|
||||||
|
|
||||||
|
|
|
@ -3534,6 +3534,44 @@ class PreFacturas(BaseModel):
|
||||||
class Meta:
|
class Meta:
|
||||||
order_by = ('fecha',)
|
order_by = ('fecha',)
|
||||||
|
|
||||||
|
@util.run_in_thread
|
||||||
|
def _send_in_thread(self, id, obj, values):
|
||||||
|
log.info('Generando PDF...')
|
||||||
|
files = (self.get_pdf(id),)
|
||||||
|
log.info('PDF Generado...')
|
||||||
|
|
||||||
|
invoice = PreFacturas.select().where(PreFacturas.id==id).dicts()[0]
|
||||||
|
fields = {
|
||||||
|
'receptor_nombre': obj.cliente.nombre,
|
||||||
|
'receptor_rfc': obj.cliente.rfc,
|
||||||
|
}
|
||||||
|
fields.update(invoice)
|
||||||
|
|
||||||
|
asunto = 'Enviamos la prefactura: PRE-{}'.format(obj.folio)
|
||||||
|
server = {
|
||||||
|
'servidor': values['correo_servidor'],
|
||||||
|
'puerto': values['correo_puerto'],
|
||||||
|
'ssl': bool(int(values['correo_ssl'])),
|
||||||
|
'usuario': values['correo_usuario'],
|
||||||
|
'contra': values['correo_contra'],
|
||||||
|
}
|
||||||
|
options = {
|
||||||
|
'para': obj.cliente.correo_facturas,
|
||||||
|
'copia': values['correo_copia'],
|
||||||
|
'confirmar': util.get_bool(values.get('correo_confirmacion', '0')),
|
||||||
|
'asunto': asunto,
|
||||||
|
'mensaje': util.make_info_mail(values['correo_mensaje'], fields),
|
||||||
|
'files': files,
|
||||||
|
}
|
||||||
|
data= {
|
||||||
|
'server': server,
|
||||||
|
'options': options,
|
||||||
|
}
|
||||||
|
log.info('Enviando prefactura...')
|
||||||
|
result = util.send_mail(data)
|
||||||
|
log.info('Prefactura enviada...')
|
||||||
|
return
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def enviar(cls, id):
|
def enviar(cls, id):
|
||||||
values = Configuracion.get_({'fields': 'correo'})
|
values = Configuracion.get_({'fields': 'correo'})
|
||||||
|
@ -3546,6 +3584,12 @@ class PreFacturas(BaseModel):
|
||||||
msg = 'El cliente no tiene configurado el correo para facturas'
|
msg = 'El cliente no tiene configurado el correo para facturas'
|
||||||
return {'ok': False, 'msg': msg}
|
return {'ok': False, 'msg': msg}
|
||||||
|
|
||||||
|
rows = PreFacturasDetalle.count(id)
|
||||||
|
if rows > 300:
|
||||||
|
cls._send_in_thread(cls, id, obj, values)
|
||||||
|
msg = 'Enviando correo...'
|
||||||
|
return {'ok': True, 'msg': msg}
|
||||||
|
|
||||||
files = (cls.get_pdf(id),)
|
files = (cls.get_pdf(id),)
|
||||||
|
|
||||||
invoice = PreFacturas.select().where(PreFacturas.id==id).dicts()[0]
|
invoice = PreFacturas.select().where(PreFacturas.id==id).dicts()[0]
|
||||||
|
@ -3661,6 +3705,25 @@ class PreFacturas(BaseModel):
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@util.run_in_thread
|
||||||
|
def _get_pdf_in_thread(self, id):
|
||||||
|
obj = PreFacturas.get(PreFacturas.id==id)
|
||||||
|
name = '{}{}_{}.pdf'.format(obj.serie, obj.folio, obj.cliente.rfc)
|
||||||
|
data = self._get_info_to_pdf(self, id)
|
||||||
|
doc = util.to_pdf(data, data['emisor']['rfc'])
|
||||||
|
|
||||||
|
emisor = Emisor.select()[0]
|
||||||
|
target = emisor.rfc + '/Prefacturas/'
|
||||||
|
files = (
|
||||||
|
(doc, name, target),
|
||||||
|
)
|
||||||
|
util.sync_cfdi({'REPO': False}, files)
|
||||||
|
return
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_pdf_in_thread(cls, id):
|
||||||
|
return cls._get_pdf_in_thread(cls, id)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_pdf(cls, id):
|
def get_pdf(cls, id):
|
||||||
obj = PreFacturas.get(PreFacturas.id==id)
|
obj = PreFacturas.get(PreFacturas.id==id)
|
||||||
|
@ -4008,6 +4071,21 @@ class PreFacturasDetalle(BaseModel):
|
||||||
|
|
||||||
return {'rows': data, 'receptor': receptor}
|
return {'rows': data, 'receptor': receptor}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def count(cls, id):
|
||||||
|
c = PreFacturasDetalle.select().where(
|
||||||
|
PreFacturasDetalle.factura==id).count()
|
||||||
|
return c
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def can_open(cls, id):
|
||||||
|
c = cls.count(id)
|
||||||
|
# ~ result = c < 300
|
||||||
|
# ~ if result:
|
||||||
|
# ~ return True
|
||||||
|
PreFacturas.get_pdf_in_thread(id)
|
||||||
|
return c < 300
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_(cls, id):
|
def get_(cls, id):
|
||||||
data = []
|
data = []
|
||||||
|
|
|
@ -1543,12 +1543,26 @@ function enviar_prefactura(id){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function grid_preinvoices_click(id, e, node){
|
function generate_pdf(id){
|
||||||
//~ var row = this.getItem(id)
|
webix.ajax().get('/values/canopenpre', {id: id}, {
|
||||||
|
error: function(text, data, xhr) {
|
||||||
|
},
|
||||||
|
success: function(text, data, xhr) {
|
||||||
|
var value = data.json();
|
||||||
|
//~ if(value){
|
||||||
|
window.open('/doc/pre/' + id, '_blank')
|
||||||
|
//~ }else{
|
||||||
|
//~ msg_ok('Generando prefactura...')
|
||||||
|
//~ }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function grid_preinvoices_click(id, e, node){
|
||||||
if(id.column == 'pdf'){
|
if(id.column == 'pdf'){
|
||||||
//~ location = '/doc/pre/' + row.id
|
generate_pdf(id.row)
|
||||||
window.open('/doc/pre/' + id, '_blank')
|
|
||||||
}else if(id.column == 'email'){
|
}else if(id.column == 'email'){
|
||||||
enviar_prefactura(id)
|
enviar_prefactura(id)
|
||||||
}
|
}
|
||||||
|
@ -1895,21 +1909,6 @@ function cmd_upload_invoice_click(){
|
||||||
|
|
||||||
|
|
||||||
function add_import_product_taxes(taxes){
|
function add_import_product_taxes(taxes){
|
||||||
//~ var taxes = values.taxes
|
|
||||||
//~ var row = grid.getItem(values.id)
|
|
||||||
|
|
||||||
//~ values['delete'] = '-'
|
|
||||||
//~ if (row == undefined){
|
|
||||||
//~ grid.add(values)
|
|
||||||
//~ } else {
|
|
||||||
//~ values['cantidad'] = parseFloat(row.cantidad) + parseFloat(values['cantidad'])
|
|
||||||
//~ values['valor_unitario'] = parseFloat(row.valor_unitario)
|
|
||||||
//~ values['descuento'] = parseFloat(row.descuento)
|
|
||||||
//~ var precio_final = values['valor_unitario'] - values['descuento']
|
|
||||||
//~ values['importe'] = (precio_final * values['cantidad']).round(DECIMALES)
|
|
||||||
//~ grid.updateItem(row.id, values)
|
|
||||||
//~ }
|
|
||||||
|
|
||||||
for(var v of taxes){
|
for(var v of taxes){
|
||||||
var pt = table_pt.findOne(v)
|
var pt = table_pt.findOne(v)
|
||||||
if(pt === null){
|
if(pt === null){
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue