Skip to content

Commit 8953261

Browse files
committed
ADDED: dalayed dalaries
1 parent fab2a5f commit 8953261

1 file changed

Lines changed: 37 additions & 6 deletions

File tree

src/main.py

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ def is_monthly_salary(salary_page):
139139
return True
140140

141141

142+
def is_delayed_salary(salary_file_path):
143+
return str(salary_file_path).split("/")[1].split("_")[1].split(".")[0].__eq__("Atrasos")
144+
145+
142146
def process_salaries_with_rlc(salaries_folder_path, rlc_folder_path, naf_dir, naf, begin, end):
143147
months_found = get_monthly_result_structure(begin, end)
144148

@@ -179,8 +183,9 @@ def process_salaries_with_rlc(salaries_folder_path, rlc_folder_path, naf_dir, na
179183
dst=os.path.join(naf_dir, RLCS_OUTPUT_NAME))
180184
months_found[key][1] = True
181185
else:
182-
logger.warning("Monthly salary was found in " + str(salary_file) + " but the expected L00 N RLC was "
183-
"not found in the expected location " + str(rlc_n_path))
186+
logger.warning("Monthly salary was found in " + str(salary_file) +
187+
" but the expected L00 N RLC was "
188+
"not found in the expected location " + str(rlc_n_path))
184189

185190
p_name = month + "_L00P01.pdf"
186191
rlc_p_path = os.path.join(rlc_folder_path, year, p_name)
@@ -189,10 +194,37 @@ def process_salaries_with_rlc(salaries_folder_path, rlc_folder_path, naf_dir, na
189194
dst=os.path.join(naf_dir, RLCS_OUTPUT_NAME))
190195
months_found[key][2] = True
191196
else:
192-
logger.warning("Monthly salary was found in " + str(salary_file) + " but the expected L00 P RLC was "
193-
"not found in the expected location " + str(rlc_n_path))
194-
else:
197+
logger.warning("Monthly salary was found in " + str(salary_file) +
198+
" but the expected L00 P RLC was "
199+
"not found in the expected location " + str(rlc_p_path))
200+
elif is_delayed_salary: # Atrasos
201+
year = "20" + salary_file.split("/")[1].split("_")[0][:2]
202+
month = salary_file.split("/")[1].split("_")[0][2:]
203+
204+
rlc_path = os.path.join(naf_dir, RLCS_OUTPUT_NAME, year, month + "_L03")
205+
suffix = 1
206+
while suffix < 100: # Accepting only suffix under 100
207+
if suffix < 10:
208+
str_suffix = "0" + str(suffix)
209+
else:
210+
str_suffix = str(suffix)
211+
rlc_path_n = rlc_path + "N" + str_suffix
212+
rlc_path_p = rlc_path + "P" + str_suffix
213+
214+
if not os.path.exists(rlc_path_n) and os.path.exists(rlc_path_p):
215+
break
216+
suffix += 1
217+
218+
219+
220+
221+
222+
elif False: # Finiquitos
223+
pass
224+
else: # Throw exception
195225
pass # TODO Check finiquitos and atrasos
226+
227+
196228
except ValueError as exc:
197229
logger.debug("NAF " + naf.__str__() + " was not detected in PDF " + str(salary_file) + ". The error is " +
198230
exc.__str__())
@@ -210,7 +242,6 @@ def process_salaries_with_rlc(salaries_folder_path, rlc_folder_path, naf_dir, na
210242
" months, but only " + str(salaries_found) + " regular salaries were found.")
211243

212244

213-
214245
def process_proofs(proofs_folder_path, naf_dir, naf, begin, end, naf_to_dni):
215246
# Flatten year directories (flat list of document for all years)
216247
all_bankproof_folders = flatten_dirs(proofs_folder_path)

0 commit comments

Comments
 (0)