service acout records updated
This commit is contained in:
@@ -54,57 +54,55 @@ def strip_date_to_valid(date_str):
|
||||
|
||||
|
||||
def find_iban_in_comment(iban: str, comment: str):
|
||||
iban_results, iban_count = BuildIbanDescription.filter_by(iban=iban)
|
||||
iban_results = BuildIbanDescription.filter_by_one(system=True, iban=iban).data
|
||||
sm_dict_extended, sm_dict_digit = {}, {}
|
||||
# is_reference_build = any(
|
||||
# letter in comment.lower() for letter in ["no", "daire", "nolu"]
|
||||
# )
|
||||
if iban_count:
|
||||
for iban_result in iban_results:
|
||||
candidate_parts = comment.split(" ")
|
||||
extended_candidate_parts, digit_part = [], []
|
||||
for part in candidate_parts:
|
||||
if part.lower() not in ["no", "daire", "nolu"]:
|
||||
extended_candidate_parts.append(part)
|
||||
# if part.isdigit():
|
||||
# digit_part.append(part)
|
||||
if extended_candidate_parts:
|
||||
if all(
|
||||
candidate_part.lower() in comment.lower()
|
||||
for candidate_part in extended_candidate_parts
|
||||
):
|
||||
similarity_ratio = textdistance.jaro_winkler(
|
||||
unidecode(str(iban_result.search_word)), comment
|
||||
)
|
||||
found = False
|
||||
name_list = (
|
||||
unidecode(str(iban_result.search_word))
|
||||
.replace(".", " ")
|
||||
.split(" ")
|
||||
)
|
||||
for name in name_list:
|
||||
if len(name) > 3 and name.lower() in comment.lower():
|
||||
found = True
|
||||
break
|
||||
for iban_result in iban_results or []:
|
||||
candidate_parts = comment.split(" ")
|
||||
extended_candidate_parts, digit_part = [], []
|
||||
for part in candidate_parts:
|
||||
if part.lower() not in ["no", "daire", "nolu"]:
|
||||
extended_candidate_parts.append(part)
|
||||
# if part.isdigit():
|
||||
# digit_part.append(part)
|
||||
if extended_candidate_parts:
|
||||
if all(
|
||||
candidate_part.lower() in comment.lower()
|
||||
for candidate_part in extended_candidate_parts
|
||||
):
|
||||
similarity_ratio = textdistance.jaro_winkler(
|
||||
unidecode(str(iban_result.search_word)), comment
|
||||
)
|
||||
found = False
|
||||
name_list = (
|
||||
unidecode(str(iban_result.search_word))
|
||||
.replace(".", " ")
|
||||
.split(" ")
|
||||
)
|
||||
for name in name_list:
|
||||
if len(name) > 3 and name.lower() in comment.lower():
|
||||
found = True
|
||||
break
|
||||
|
||||
if not found:
|
||||
similarity_ratio = 0.1
|
||||
sm_dict_extended[f"{iban_result.id}"] = similarity_ratio
|
||||
|
||||
if sm_dict_extended:
|
||||
result = sorted(
|
||||
sm_dict_extended.items(), key=lambda item: item[1], reverse=True
|
||||
)[0]
|
||||
if float(result[1]) >= 0.5:
|
||||
iban_result = BuildIbanDescription.find_one(id=int(result[0]))
|
||||
return {
|
||||
"decision_book_project_id": iban_result.decision_book_project_id,
|
||||
"company_id": iban_result.company_id,
|
||||
"customer_id": iban_result.customer_id,
|
||||
"build_parts_id": iban_result.build_parts_id,
|
||||
"found_from": "Name",
|
||||
"similarity": result[1],
|
||||
}
|
||||
if not found:
|
||||
similarity_ratio = 0.1
|
||||
sm_dict_extended[f"{iban_result.id}"] = similarity_ratio
|
||||
if sm_dict_extended:
|
||||
result = sorted(
|
||||
sm_dict_extended.items(), key=lambda item: item[1], reverse=True
|
||||
)[0]
|
||||
if float(result[1]) >= 0.5:
|
||||
iban_result = BuildIbanDescription.filter_one(
|
||||
BuildIbanDescription.id==int(result[0]),
|
||||
system=True
|
||||
).data
|
||||
return {
|
||||
"decision_book_project_id": iban_result.decision_book_project_id,
|
||||
"company_id": iban_result.company_id,
|
||||
"customer_id": iban_result.customer_id,
|
||||
"build_parts_id": iban_result.build_parts_id,
|
||||
"found_from": "Name",
|
||||
"similarity": result[1],
|
||||
}
|
||||
return {
|
||||
"decision_book_project_id": None,
|
||||
"company_id": None,
|
||||
|
||||
Reference in New Issue
Block a user