Merge branch 'develop'

Guardar logos de emisor en carpeta correcta
This commit is contained in:
Mauricio Baeza 2019-01-16 23:38:05 -06:00
commit dbf3a342bf
6 changed files with 28 additions and 8 deletions

View File

@ -1,3 +1,8 @@
v 1.26.1 [16-ene-2019]
----------------------
- Error: Guardar logos de emisor
v 1.26.0 [15-ene-2019]
----------------------
- Mejora: Generar PDF desde plantilla JSON

View File

@ -1 +1 @@
1.26.0
1.26.1

View File

@ -584,6 +584,16 @@ class TemplateInvoice(BaseDocTemplate):
ps = ParagraphStyle(**v['estilo'])
p = Paragraph(data[k], ps)
ls.append(p)
elif k=='formametodopago':
ps = ParagraphStyle(**v['estilo'])
v = f"{data['formadepago']} - {data['metododepago']}"
p = Paragraph(v, ps)
ls.append(p)
elif k=='monedatipocambio':
ps = ParagraphStyle(**v['estilo'])
v = f"{data['moneda']} - {data['tipocambio']}"
p = Paragraph(v, ps)
ls.append(p)
cbb = Image(data['path_cbb'])
cbb.drawHeight = 4 * cm

View File

@ -1596,10 +1596,13 @@ def to_pdf_from_json(rfc, version, data):
name = '{}_{}.json'.format(rfc, version)
custom_styles = get_custom_styles(name)
path_logo = _join(PATHS['IMG'], f"{rfc}.png")
data['emisor']['logo'] = path_logo
path_logo = _join(PATHS['IMG'], f"{rfc}_2.png")
data['emisor']['logo2'] = path_logo
path_logo = _join(PATHS['LOGOS'], f"{rfc}.png")
if exists(path_logo):
data['emisor']['logo'] = path_logo
path_logo = _join(PATHS['LOGOS'], f"{rfc}_2.png")
if exists(path_logo):
data['emisor']['logo2'] = path_logo
path = get_path_temp()
pdf = TemplateInvoice(path)
@ -1735,7 +1738,7 @@ def _comprobante(doc, options):
serie = ''
if 'serie' in data:
serie = '{} -'.format(data['serie'])
serie = '{}-'.format(data['serie'])
data['seriefolio'] = '{}{}'.format(serie, data.get('folio', ''))
data['totalenletras'] = to_letters(float(data['total']), data['moneda'])

View File

@ -876,7 +876,7 @@ class Emisor(BaseModel):
emisor = Emisor.select()[0]
rfc = emisor.rfc.lower()
name = f'{rfc}.png'
path = util._join(PATHS['IMG'], name)
path = util._join(PATHS['LOGOS'], name)
if util.save_file(path, file_obj.file.read()):
emisor.logo = file_obj.filename
emisor.save()

View File

@ -47,7 +47,7 @@ except ImportError:
DEBUG = DEBUG
VERSION = '1.26.0'
VERSION = '1.26.1'
EMAIL_SUPPORT = ('soporte@empresalibre.net',)
TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)
@ -59,6 +59,7 @@ path_docs = os.path.abspath(os.path.join(BASE_DIR, '..', 'docs'))
path_css = os.path.join(path_static, 'css')
path_img = os.path.join(path_static, 'img')
path_user_template = os.path.join(path_docs, 'templates')
path_user_logos = os.path.join(path_docs, 'logos')
# ~ PATH_STATIC = os.path.abspath(os.path.join(BASE_DIR, '..'))
@ -209,6 +210,7 @@ PATHS = {
'IMG': path_img,
'DOCS': path_docs,
'USER': path_user_template,
'LOGOS': path_user_logos,
}
VALUES_PDF = {
'CANCEL': {True: 'inline', False: 'none'},