@@ -530,8 +530,8 @@ def action_button(self, action_name, action_items, action_text):
530530
531531 def attachments ():
532532 for ni in facturas :
533- yield ni .filename + ".xml"
534- yield ni .filename + ".pdf"
533+ yield ni .xml_filename
534+ yield ni .pdf_filename
535535
536536 if "I" in tipos_facturas :
537537 titulo = "Comprobantes Fiscales"
@@ -1357,6 +1357,23 @@ def action(self, event, values):
13571357 cfdi .status_sat (update = True )
13581358 self .done_message ("FIN" )
13591359
1360+ case 'descargar_emitidas' :
1361+ download_folder = sg .popup_get_folder ('' , no_window = True ,)
1362+ if download_folder :
1363+ emitidas = self .window ["emitidas_table" ].selected_items ()
1364+
1365+ zip_name = f"emitidas_{ datetime .now ().strftime ('%Y%m%d_%H%M%S' )} .zip"
1366+ zip_path = os .path .join (download_folder , zip_name )
1367+ added = 0
1368+ with ZipFile (zip_path , 'w' ) as zf :
1369+ for i in emitidas :
1370+ for f in (i .xml_filename , i .pdf_filename ):
1371+ if not os .path .isfile (f ):
1372+ raise FileNotFoundError (f"Archivo no encontrado: { f } " )
1373+ zf .write (f , arcname = os .path .basename (f ))
1374+ added += 1
1375+ self .done_message (f"ZIP creado con { added } archivo(s): { zip_path } " )
1376+
13601377 case "exportar_metadata" :
13611378 with open (METADATA_FILE , 'w' , newline = '' , encoding = 'utf-8' ) as f :
13621379 writer = csv .writer (f )
0 commit comments