Plantillas

This commit is contained in:
el Mau 2023-01-01 22:58:58 -06:00
parent a13c7c0a1d
commit 5418b23200
7 changed files with 24 additions and 9 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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'

View File

@ -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'},
]

Binary file not shown.