diff --git a/source/app/controllers/util.py b/source/app/controllers/util.py index 68023b5..9f45f2e 100644 --- a/source/app/controllers/util.py +++ b/source/app/controllers/util.py @@ -1554,11 +1554,11 @@ class LIBO(object): def to_pdf(data, emisor_rfc, ods=False, pdf_from='1'): rfc = data['emisor']['rfc'] - default = 'plantilla_factura.ods' if DEBUG: rfc = emisor_rfc version = data['comprobante']['version'] + default = f'plantilla_factura_{version}.ods' if 'nomina' in data and data['nomina']: default = 'plantilla_nomina.ods' @@ -2227,11 +2227,27 @@ class UpFile(object): return +def save_template(rfc, opt, file_obj): + result = {'status': 'error', 'ok': False} + + name_template = f'{rfc}{opt}' + path_template = _join(PATH_MEDIA, 'templates', name_template) + + if save_file(path_template, file_obj.file.read()): + result = {'status': 'server', 'name': file_obj.filename, 'ok': True} + + return result + + def upload_file(rfc, opt, file_obj): rfc = rfc.lower() tmp = file_obj.filename.split('.') ext = tmp[-1].lower() + versions = ('_3.3.ods', '_3.3_cp_2.0.ods', '_4.0.ods') + if opt in versions: + return save_template(rfc, opt, file_obj) + EXTENSIONS = { 'txt_plantilla_factura_32': EXT['ODS'], 'txt_plantilla_factura_33': EXT['ODS'], diff --git a/source/static/js/ui/admin.js b/source/static/js/ui/admin.js index e9f1e35..b9e197d 100644 --- a/source/static/js/ui/admin.js +++ b/source/static/js/ui/admin.js @@ -597,6 +597,7 @@ var type_make_pdf = [ var opt_templates_cfdi = [ + {id: '_4.0.ods', value: 'CFDI v4.0'}, {id: '_3.3_cp_2.0.ods', value: 'CFDI v3.3 - Carta Porte 2.0'}, ] diff --git a/source/templates/plantilla_factura.ods b/source/templates/plantilla_factura_3.3.ods similarity index 100% rename from source/templates/plantilla_factura.ods rename to source/templates/plantilla_factura_3.3.ods diff --git a/source/templates/plantilla_factura_4.0.ods b/source/templates/plantilla_factura_4.0.ods new file mode 100644 index 0000000..a19230a Binary files /dev/null and b/source/templates/plantilla_factura_4.0.ods differ