@@ -55,7 +55,7 @@ def process_generic_rlc(rlc_type, salary_date, salary_file_path, rlc_folder_path
5555 + " will be skipped." )
5656 return
5757
58- pdf_path_list = [salary_output_path , rlc_n_path , rlc_p_path ]
58+ pdf_path_list = [rlc_n_path , rlc_p_path ]
5959 pdf_merged_name = salary_date .year .__str__ () + unparse_month (salary_date ) + "_L" + rlc_type + "Merge.pdf"
6060 merge_pdfs (pdf_path_list , os .path .join (naf_dir , RLCS_OUTPUT_NAME , pdf_merged_name ))
6161
@@ -100,7 +100,7 @@ def process_rlc_l03(salary_file_path, salary_page_number, salary_page, salary_da
100100 logger .debug ("Breaking out of the bucle because " + rlc_path_p +
101101 "does not exist." )
102102 months_found [salary_date ][2 ] = True # Delay salary P is found
103- pdf_path_list .append (salary_output_path )
103+ # pdf_path_list.append(salary_output_path) # Do not add salary to RLC merge
104104 pdf_path_list .append (rlc_path_n )
105105 pdf_path_list .append (rlc_path_p )
106106 merge_pdfs (pdf_path_list , pdf_output_path )
@@ -242,17 +242,18 @@ def process_proofs(proofs_folder_path, naf_dir, naf, begin, end, naf_to_dni):
242242 write_page (page , output_path )
243243
244244 elif bank .__eq__ ("LA_CAIXA" ) or bank .__eq__ ("LA_CAIXA_EXTRA" ) or bank .__eq__ ("LA_CAIXA_endarreriments" ):
245- file_name = list_dir (os .path .join (proofs_folder_path , bankproof_folder ))[0 ]
246- try :
247- page = get_matching_page (os .path .join (proofs_folder_path , bankproof_folder , file_name ),
248- naf_to_dni [naf ], "[A-Z]\\ d{7}[A-Z]|\\ d{8}[A-Z]" )
249- except ValueError as e :
250- logger .debug ("NAF " + naf .__str__ () + " not detected in " + file_name + ". Error: " + e .__str__ ())
251- continue
252- output_path = os .path .join (proofs_dir , file_name )
253- logger .info (
254- "NAF " + naf .__str__ () + " was detected in " + file_name + ". Writing page to " + output_path .__str__ () + "." )
255- write_page (page , output_path )
245+ file_names = list_dir (os .path .join (proofs_folder_path , bankproof_folder ))
246+ for file_name in file_names :
247+ try :
248+ page = get_matching_page (os .path .join (proofs_folder_path , bankproof_folder , file_name ),
249+ naf_to_dni [naf ], "[A-Z]\\ d{7}[A-Z]|\\ d{8}[A-Z]" )
250+ except ValueError as e :
251+ logger .debug ("NAF " + naf .__str__ () + " not detected in " + file_name + ". Error: " + e .__str__ ())
252+ continue
253+ output_path = os .path .join (proofs_dir , file_name )
254+ logger .info (
255+ "NAF " + naf .__str__ () + " was detected in " + file_name + ". Writing page to " + output_path .__str__ () + "." )
256+ write_page (page , output_path )
256257 else :
257258 logger .error (bank .__str__ () + " is a bad bank. Skipping to next bank proof." )
258259 continue
@@ -313,14 +314,24 @@ def process_RNTs(rnts_folder_path, naf_dir, naf, begin, end):
313314 file_date = parse_date ("20" + rnt_file .split ("/" )[1 ][:4 ], "%Y%m" )
314315 if begin <= file_date <= end :
315316 rnt_file_name = rnt_file .split ("/" )[1 ]
317+ rnt_file_name_without_extension = rnt_file_name .split ("." )[0 ]
316318 rnt_path = os .path .join (rnts_folder_path , file_date .year .__str__ (), rnt_file_name )
317- rnt_path_destination = os .path .join (naf_dir , RNTS_OUTPUT_NAME , rnt_file_name )
319+ rnt_partial_path_destination = os .path .join (naf_dir , RNTS_OUTPUT_NAME , rnt_file_name )
318320 logger .info ("RNT file " + rnt_path .__str__ () + " is selected, because its date is " +
319321 unparse_date (file_date ) + "."
320- " It will be copied into " + rnt_path_destination )
321- shutil .copy (src = rnt_path ,
322- dst = rnt_path_destination )
323- rnts_found [file_date ] = True
322+ " It will be copied into " + rnt_partial_path_destination )
323+ try :
324+ pages = get_matching_pages (rnt_path , naf .__str__ (), r"\d{12}" )
325+ except ValueError as e :
326+ logger .debug ("NAF " + naf .__str__ () + " not detected in " + rnt_path + ". Error: " + e .__str__ ())
327+ continue
328+ for page , page_num in pages :
329+ rnt_path_destination = os .path .join (naf_dir , RNTS_OUTPUT_NAME , rnt_file_name_without_extension + "_" + str (page_num ) + ".pdf" )
330+ logger .info (
331+ "NAF " + naf .__str__ () + " was detected in " + rnt_path + " in page " + str (page_num + 1 ) +
332+ ". Writing page to " + rnt_path_destination .__str__ () + "." )
333+ write_page (page , rnt_path_destination )
334+ rnts_found [file_date ] = True
324335 else :
325336 logger .debug ("RNT file " + rnt_file .__str__ () + " is not selected, because its date is " +
326337 unparse_date (file_date ) + "." )
0 commit comments