first commit

This commit is contained in:
2024-11-07 17:44:29 +03:00
commit 643d6d8f65
247 changed files with 420800 additions and 0 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_app_mail/.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,132 @@
from api_services.email.service import send_email
from api_library.date_time_actions.date_functions import client_arrow
def send_mail_to_users_that_have_received_email_from_banks():
from databases.sql_models import AccountRecords
print("Service is booting up")
print("Sending mail to users that have received email from banks")
# account_records = AccountRecords.query.filter(
# AccountRecords.bank_date >= datetime(
# today.year, today.month, today.day - int(day_offset), 23, 59, 59) # AccountRecords.bank_date >= datetime(2024, 9, 5, 23, 59, 59)
# ).order_by(
# AccountRecords.bank_date.desc(), AccountRecords.bank_reference_code.desc()
# ).all()
# if not account_records:
account_records = (
AccountRecords.query.filter()
.order_by(
AccountRecords.bank_date.desc(), AccountRecords.bank_reference_code.desc()
)
.limit(3)
.all()
)
today, first_record, second_record, balance_error = (
client_arrow.now(),
account_records[0],
account_records[1],
False,
)
second_balance = first_record.bank_balance - first_record.currency_value
if second_balance != second_record.bank_balance:
balance_error = True
send_to = "karatay@mehmetkaratay.com.tr"
styles = """<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
table {
width: 100%;
border-collapse: collapse;
}
table, th, td {
border: 1px solid black;
}
th, td {
padding: 10px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
</style>
"""
table_data = ""
table_headers = """
<thead>
<tr>
<th>Ulaştığı Tarih</th>
<th>Banka Transaksiyonu Ek Bilgi</th>
<th>Aktarım Değeri</th>
</tr>
</thead>
"""
table_row_add = (
lambda date, comment, currency: f"""
<thead>
<tr>
<td>{date}</td>
<td>{comment}</td>
<td>{"%.2f" % currency}</td>
</tr>
</thead>
"""
)
if not account_records:
return
for account_record in account_records:
table_data += table_row_add(
account_record.bank_date,
account_record.process_comment,
account_record.currency_value,
)
html_template = f"""
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gelen Banka Kayıtları</title>
{styles}
</head>
<body>
<h1>Günaydın, Admin</h1>
<br>
<p>Banka Kayıtları : {str(today)} </p>
<p><b>Son Bakiye : {"%.2f" % account_records[0].bank_balance} </b></p>
<p><b>{"Status : İkinci Bakiye Hatalı" if balance_error else "Status :OK"}</b></p>
<br>
<table>
{table_headers}
<tbody>
{table_data}
</tbody>
</table>
<br>
<p>Teşekkür ederiz,<br>Evyos Yönetim<br>Saygılarımızla</p>
</body>
</html>
"""
subject = f"{str(today.date())} Gunes Apt. Cari Durum Bilgilendirme Raporu"
try:
send_email(
subject=subject,
receivers=[send_to],
html=html_template,
)
print(f"Email is sent to : {send_to}. BB")
return
except Exception as e:
print(f"Error: {e}")
print("Email is not sent")
send_mail_to_users_that_have_received_email_from_banks()

View File

@@ -0,0 +1,26 @@
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
COPY ../service_app_mail/mailserver.requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache-dir --upgrade -r mailserver.requirements.txt
COPY ../service_app_mail ./service_app_mail
COPY ../api_library ./service_app_mail/api_library
COPY ../api_services ./service_app_mail/api_services
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 /app_mail_sender.py >> /var/log/cron.log 2>&1" > /tmp/crontab_list && 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,7 @@
arrow
Deprecated
python-dotenv
pydantic
sqlalchemy-mixins
psycopg2-binary
redmail