diff --git a/source/app/controllers/util.py b/source/app/controllers/util.py index a26d6e4..d27c90f 100644 --- a/source/app/controllers/util.py +++ b/source/app/controllers/util.py @@ -1126,6 +1126,8 @@ class LIBO(object): return def _cfdipays(self, data): + version = data['Version'] + related = data.pop('related', []) for k, v in data.items(): if k.lower() in ('monto',): @@ -1574,13 +1576,13 @@ def to_pdf(data, emisor_rfc, ods=False, pdf_from='1'): version = f'{version}_cn_{version_nomina}' if 'carta_porte' in data: - default = 'plantilla_factura_cp.ods' - version = '{}_cp_{}'.format(version, data['carta_porte']['version']) + default = 'plantilla_factura_ccp.ods' + version = '{}_ccp_{}'.format(version, data['carta_porte']['version']) - pagos = '' if data.get('pagos', False): - version = '1.0' - pagos = 'pagos_' + version_pagos = data['pays']['version'] + default = f'plantilla_pagos_{version}_{version_pagos}.ods' + version = f'{version}_cp_{version_pagos}' if pdf_from == '2': return to_pdf_from_json(rfc, version, data) @@ -1590,6 +1592,7 @@ def to_pdf(data, emisor_rfc, ods=False, pdf_from='1'): donativo = '_donativo' template_name = f'{rfc.lower()}_{version}.ods' + # ~ print('T', template_name, default) if APP_LIBO: app = LIBO() @@ -2109,11 +2112,17 @@ def _nomina(doc, data, values, version_cfdi): def _cfdipays(doc, data, version): - node = doc.find('{}Complemento/{}Pagos'.format(PRE[version], PRE['pagos'])) + #todo: Obtener versión de complemento + if version == '4.0': + node = doc.find(f"{PRE[version]}Complemento/{PRE['pagos20']}Pagos") + else: + node = doc.find('{}Complemento/{}Pagos'.format(PRE[version], PRE['pagos'])) + if node is None: return {} info = CaseInsensitiveDict(node.attrib.copy()) + related = [] for n1 in node: info.update(CaseInsensitiveDict(n1.attrib.copy())) @@ -2258,8 +2267,8 @@ def upload_file(rfc, opt, file_obj): ext = tmp[-1].lower() versions = ('_3.2.ods', - '_3.3.ods', '_3.3_cn_1.2.ods', '_3.3_cp_2.0.ods', - '_4.0.ods', '_4.0_cn_1.2.ods') + '_3.3.ods', '_3.3_cn_1.2.ods', '_3.3_ccp_2.0.ods', + '_4.0.ods', '_4.0_cn_1.2.ods', '_4.0_cp_2.0.ods') if opt in versions: return save_template(rfc, opt, file_obj) diff --git a/source/app/models/main.py b/source/app/models/main.py index ce08700..4168a10 100644 --- a/source/app/models/main.py +++ b/source/app/models/main.py @@ -7707,6 +7707,7 @@ class CfdiPagos(BaseModel): 'donativo': {}, 'edu': False, 'complementos': complementos, + 'global': {}, } return utils.make_xml(data, certificado) @@ -7826,6 +7827,8 @@ class CfdiPagos(BaseModel): target = emisor.rfc + '/' + str(obj.fecha)[:7].replace('-', '/') values = cls._get_not_in_xml(cls, obj, emisor) data = util.get_data_from_xml(obj, values) + data['informacion_global'] = {} + obj = SATFormaPago.get(SATFormaPago.key==data['pays']['FormaDePagoP']) data['pays']['formadepago'] = '{} ({})'.format(obj.name, obj.key) doc = util.to_pdf(data, emisor.rfc) diff --git a/source/app/settings.py b/source/app/settings.py index 9d3d1bd..87725fb 100644 --- a/source/app/settings.py +++ b/source/app/settings.py @@ -144,6 +144,7 @@ PRE = { '1.2': '{http://www.sat.gob.mx/nomina12}', }, 'pagos': '{http://www.sat.gob.mx/Pagos}', + 'pagos20': '{http://www.sat.gob.mx/Pagos20}', } CURRENT_CFDI = '3.3' diff --git a/source/static/js/ui/admin.js b/source/static/js/ui/admin.js index 98af3a6..8a8525f 100644 --- a/source/static/js/ui/admin.js +++ b/source/static/js/ui/admin.js @@ -599,9 +599,11 @@ var type_make_pdf = [ var opt_templates_cfdi = [ {id: '_4.0.ods', value: 'CFDI v4.0'}, {id: '_4.0_cn_1.2.ods', value: 'CFDI v4.0 - Nómina v1.2'}, + {id: '_4.0_cp_2.0.ods', value: 'CFDI v4.0 - Pagos v2.0'}, {id: '_3.3.ods', value: 'CFDI v3.3'}, {id: '_3.3_cn_1.2.ods', value: 'CFDI v3.3 - Nómina v1.2'}, - {id: '_3.3_cp_2.0.ods', value: 'CFDI v3.3 - Carta Porte v2.0'}, + {id: '_3.3_ccp_2.0.ods', value: 'CFDI v3.3 - Carta Porte v2.0'}, + {id: '_3.3_cp_1.0.ods', value: 'CFDI v3.3 - Pagos v1.0'}, {id: '_3.2.ods', value: 'CFDI v3.2'}, ] diff --git a/source/templates/plantilla_factura_cp.ods b/source/templates/plantilla_factura_ccp.ods similarity index 100% rename from source/templates/plantilla_factura_cp.ods rename to source/templates/plantilla_factura_ccp.ods diff --git a/source/templates/plantilla_pagos.ods b/source/templates/plantilla_pagos_3.3_1.0.ods similarity index 100% rename from source/templates/plantilla_pagos.ods rename to source/templates/plantilla_pagos_3.3_1.0.ods diff --git a/source/templates/plantilla_pagos_4.0_2.0.ods b/source/templates/plantilla_pagos_4.0_2.0.ods new file mode 100644 index 0000000..07b2528 Binary files /dev/null and b/source/templates/plantilla_pagos_4.0_2.0.ods differ