service acout records updated

This commit is contained in:
2024-11-20 20:06:36 +03:00
parent 1291ac87e2
commit 6ad1ba7d62
14 changed files with 581 additions and 162 deletions

View File

@@ -0,0 +1,93 @@
# Git
.git
.gitignore
.gitattributes
# CI
.codeclimate.yml
.travis.yml
.taskcluster.yml
# Docker
docker-compose.yml
service_app/Dockerfile
.docker
.dockerignore
# Byte-compiled / optimized / DLL files
**/__pycache__/
**/*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
service_app/env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Virtual environment
service_app/.env
.venv/
venv/
# PyCharm
.idea
# Python mode for VIM
.ropeproject
**/.ropeproject
# Vim swap files
**/*.swp
# VS Code
.vscode/
test_application/

162
service_account_records/.gitignore vendored Normal file
View File

@@ -0,0 +1,162 @@
# ---> Python
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.idea/
.Python
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
service_app/.env
.venv
service_app/env/
venv/
service_app/env/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

View File

View File

@@ -0,0 +1,35 @@
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
COPY ../service_account_records/account.requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache-dir --upgrade -r account.requirements.txt
COPY ../service_account_records ./service_account_records
COPY ../api_library ./service_account_records/api_library
COPY ../api_services ./service_account_records/api_services
COPY ../databases ./service_account_records/databases
COPY ../api_configs ./service_account_records/api_configs
COPY ../api_objects ./service_account_records/api_objects
COPY ../api_validations ./service_account_records/api_validations
#COPY ../service_account_records/crontab_list /service_account_records/crontab_to_write
RUN apt-get update && apt-get install -y cron
# 11:00 Istanbul Time (UTC+3) system time is 08:00 UTC
#RUN echo "0 8 * * * /usr/local/bin/python /service_account_records/app_mail_sender.py >> /var/log/cron.log 2>&1" > /tmp/crontab_list && crontab /tmp/crontab_list
#RUN echo "*/15 * * * * /usr/local/bin/python /service_account_records/isbank/main_single_thread.py >> /var/log/cron.log 2>&1" >> /tmp/crontab_list && crontab /tmp/crontab_list
RUN echo "*/15 * * * * /usr/local/bin/python " >> /tmp/crontab_list && crontab /tmp/crontab_list
#RUN echo /service_account_records/crontab_to_write > /tmp/crontab_list
#RUN crontab /tmp/crontab_list
RUN touch /var/log/cron.log
CMD cron && tail -f /var/log/cron.log
#RUN chmod 0644 /etc/cron.d/app_mail_sender_cron
#RUN crontab /etc/cron.d/send_email_cron
#CMD ["python", "-m", "app_mail_sender"]

View File

@@ -0,0 +1,18 @@
arrow
Deprecated
python-dotenv
pydantic
sqlalchemy-mixins
psycopg2-binary
redmail
redbox
pandas
xlrd
Unidecode
redis
cryptography
fastapi
requests
pymongo
unidecode
textdistance

View File

@@ -0,0 +1,94 @@
import json
from api_services.bank_actions.wag_account_record_parser import parse_comment_with_name
from databases import (
AccountRecords,
BuildIbans,
BuildDecisionBook,
)
from api_validations.validations_request import (
ListOptions
)
from api_library.date_time_actions.date_functions import (
system_arrow
)
from service_account_records.configs import AccountConfig
account_list = ListOptions(
page=1,
size=1000,
order_field="bank_date",
order_type="desc",
)
def account_records_find_decision_book():
created_ibans, iban_build_dict = [], {}
AccountRecords.filter_attr = account_list
created_ibans, iban_build_dict = [], {}
AccountRecords.filter_attr = account_list
days_before_now = system_arrow.now().shift(days=(int(AccountConfig.BEFORE_DAY) * -1))
account_records_list: list[AccountRecords] = AccountRecords.filter_all(
# AccountRecords.bank_date >= str(days_before_now),
AccountRecords.build_decision_book_id == None,
system=True
).data
for account_record in account_records_list:
if account_record.iban not in created_ibans:
found_iban: BuildIbans = BuildIbans.filter_one(
BuildIbans.iban == account_record.iban,
system=True
).data
if not found_iban:
create_build_ibans = BuildIbans.find_or_create(
iban=account_record.iban,
start_date=str(system_arrow.now().shift(days=-1)),
)
create_build_ibans.save_and_confirm()
created_ibans.append(account_record.iban)
# It is in database already
if not found_iban.build_id:
iban_build_dict["iban"] = account_record.iban
iban_build_dict["build_id"] = None
else:
found_decision_book = BuildDecisionBook.filter_one(
BuildDecisionBook.build_id == found_iban.build_id,
BuildDecisionBook.expiry_starts <= account_record.bank_date,
BuildDecisionBook.expiry_ends > account_record.bank_date,
).data
if found_decision_book:
print('found_decision_book', found_decision_book.get_dict())
account_record.update(
build_decision_book_id=found_decision_book.id,
build_decision_book_uu_id=str(found_decision_book.uu_id),
)
account_record.save()
print('iban_build_dict', iban_build_dict)
print('created_ibans', created_ibans)
return
def account_records_search():
AccountRecords.filter_attr = account_list
account_records_list: list[AccountRecords] = AccountRecords.filter_all(
AccountRecords.build_decision_book_id != None,
system=True
).data
for account_record in account_records_list:
print('account_record', account_record.get_dict())
similarity_result = parse_comment_with_name(account_record.iban, account_record.process_comment)
print('similarity_result', similarity_result)
# build_iban = BuildIbans.find_one(iban=data["iban"])
print('account_records_list', account_records_list)
return
def account_records_service() -> None:
account_records_find_decision_book()
account_records_search()
return
if __name__ == "__main__":
account_records_service()

View File

@@ -0,0 +1,4 @@
class AccountConfig:
BEFORE_DAY = 30

View File

@@ -0,0 +1,2 @@
0 8 * * * /usr/local/bin/python /service_app_banks/app_mail_sender.py >> /var/log/cron.log 2>&1
*/15 * * * * /usr/local/bin/python /service_app_banks/isbank/main_single_thread.py >> /var/log/cron.log 2>&1