Skip to content

Commit 89c9a55

Browse files
committed
FIXED: corrections from last output
1 parent e8314e7 commit 89c9a55

3 files changed

Lines changed: 35 additions & 23 deletions

File tree

requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
pypdf~=5.5.0
2-
PyPDF2~=3.0.1
3-
pandas~=2.0.3
1+
pypdf
2+
PyPDF2
3+
pandas
44
openpyxl
55
PyCryptodome
66
Office365-REST-Python-Client
7-
pyfiglet~=0.8.post1
7+
pyfiglet

src/main.py

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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) + ".")

src/sharepoint/demo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import json
33

4+
45
def demo_request():
56
from . import get_request_ctx
67

@@ -24,4 +25,4 @@ def demo_client():
2425

2526
ctx = get_client_ctx(subdomain, username, password)
2627
web = ctx.web.get().execute_query()
27-
print("Web title: {0}".format(web.properties['Title']))
28+
print("Web title: {0}".format(web.properties['Title']))

0 commit comments

Comments
 (0)