app accounts updated

This commit is contained in:
2024-11-25 21:34:33 +03:00
parent a371d5d6e3
commit c525ac1117
4 changed files with 226 additions and 134 deletions

View File

@@ -148,8 +148,10 @@ def account_get_people_and_living_space_info_via_iban() -> dict:
if living_space.person_id
]
people_list = People.filter_all(
People.id.in_(living_spaces_people), system=True
People.id.in_(living_spaces_people),
system=True
).data
print('build_parts', build_parts)
build_living_space_dict[str(account_records_iban[0])] = {
"people": list(people_list),
"living_space": list(living_spaces),
@@ -160,11 +162,10 @@ def account_get_people_and_living_space_info_via_iban() -> dict:
def account_records_search():
build_living_space_dict = account_get_people_and_living_space_info_via_iban()
AccountRecords.filter_attr = account_list
AccountRecords.filter_attr, found_list = account_list, []
account_records_list: list[AccountRecords] = AccountRecords.filter_all(
AccountRecords.build_decision_book_id != None, system=True
# AccountRecords.build_decision_book_id != None, system=True
).data
found_list = []
for account_record in account_records_list:
similarity_result = parse_comment_with_name(
account_record=account_record, living_space_dict=build_living_space_dict
@@ -172,9 +173,9 @@ def account_records_search():
fs, ac = similarity_result.get("similarity"), account_record.similarity or 0
if float(fs) >= 0.8 and float(fs) > float(ac):
found_list.append(similarity_result)
account_save_search_result(
account_record=account_record, similarity_result=similarity_result
)
# account_save_search_result(
# account_record=account_record, similarity_result=similarity_result
# )
else:
similarity_result = parse_comment_with_name_iban_description(
account_record=account_record
@@ -182,9 +183,9 @@ def account_records_search():
fs, ac = similarity_result.get("similarity"), account_record.similarity or 0
if float(fs) >= 0.8 and float(fs) > float(ac):
found_list.append(similarity_result)
account_save_search_result(
account_record=account_record, similarity_result=similarity_result
)
# account_save_search_result(
# account_record=account_record, similarity_result=similarity_result
# )
print("Account Records Search : ", len(found_list), "/", len(account_records_list))
return
@@ -309,9 +310,7 @@ def send_accounts_to_decision_payment():
AccountRecords.receive_debit == receive_enum.id,
).data
for account_record in account_records_list:
current_currency_value = pay_the_registration(
account_record, receive_enum, debit_enum
)
current_currency_value = pay_the_registration(account_record, receive_enum, debit_enum)
if current_currency_value > 0:
pay_the_registration(account_record, receive_enum, debit_enum, True)
if abs(float(Decimal(account_record.remainder_balance))) == abs(
@@ -319,14 +318,14 @@ def send_accounts_to_decision_payment():
):
account_record.update(status_id=97)
account_record.save()
# todo If the payment is more than the amount, then create a new account record with the remaining amount
# # # todo If the payment is more than the amount, then create a new account record with the remaining amount
return
def account_records_service() -> None:
account_records_find_decision_book()
# account_records_find_decision_book()
account_records_search()
send_accounts_to_decision_payment()
# send_accounts_to_decision_payment()
return

View File

@@ -0,0 +1,28 @@
import re
from difflib import get_close_matches
categories = {
"DAIRE": ["daire", "dagire", "daare", "nolu daire", "no", "nolu dairenin"],
"APARTMAN": ["apartman", "aparman", "aprmn"],
"VILLA": ["villa", "vlla"],
"BINA": ["bina", "binna"]
}
def word_straighten(word, ref_list, threshold=0.8):
matches = get_close_matches(word, ref_list, n=1, cutoff=threshold)
return matches[0] if matches else word
def category_finder(text, output_template="{kategori} {numara}"):
result = {category: [] for category in categories} # Sonuçları depolamak için bir sözlük
for category, patterns in categories.items():
words = re.split(r'\W+', text)
straighten_words = [word_straighten(word, patterns) for word in words]
straighten_text = ' '.join(straighten_words)
pattern = r'(?:\b|\s|^)(?:' + '|'.join(map(re.escape, patterns)) + r')(?:\s*|:|\-|\#)*(\d+)(?:\b|$)'
if founds_list := re.findall(pattern, straighten_text, re.IGNORECASE):
list_of_output = [output_template.format(kategori=category, numara=num) for num in founds_list]
result[category].extend([i for i in list_of_output if str(i).replace(' ', '')])
return result