Changes to be committed:
new file: .editorconfig deleted: app.py deleted: init_db.py deleted: readme.md deleted: requirements.txt deleted: static/styles.css deleted: templates/add.html deleted: templates/edit.html deleted: templates/index.html
This commit is contained in:
59
.editorconfig
Normal file
59
.editorconfig
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
[*]
|
||||||
|
cpp_indent_braces=false
|
||||||
|
cpp_indent_multi_line_relative_to=innermost_parenthesis
|
||||||
|
cpp_indent_within_parentheses=indent
|
||||||
|
cpp_indent_preserve_within_parentheses=false
|
||||||
|
cpp_indent_case_labels=false
|
||||||
|
cpp_indent_case_contents=true
|
||||||
|
cpp_indent_case_contents_when_block=false
|
||||||
|
cpp_indent_lambda_braces_when_parameter=true
|
||||||
|
cpp_indent_goto_labels=one_left
|
||||||
|
cpp_indent_preprocessor=leftmost_column
|
||||||
|
cpp_indent_access_specifiers=false
|
||||||
|
cpp_indent_namespace_contents=true
|
||||||
|
cpp_indent_preserve_comments=false
|
||||||
|
cpp_new_line_before_open_brace_namespace=ignore
|
||||||
|
cpp_new_line_before_open_brace_type=ignore
|
||||||
|
cpp_new_line_before_open_brace_function=ignore
|
||||||
|
cpp_new_line_before_open_brace_block=ignore
|
||||||
|
cpp_new_line_before_open_brace_lambda=ignore
|
||||||
|
cpp_new_line_scope_braces_on_separate_lines=false
|
||||||
|
cpp_new_line_close_brace_same_line_empty_type=false
|
||||||
|
cpp_new_line_close_brace_same_line_empty_function=false
|
||||||
|
cpp_new_line_before_catch=true
|
||||||
|
cpp_new_line_before_else=true
|
||||||
|
cpp_new_line_before_while_in_do_while=false
|
||||||
|
cpp_space_before_function_open_parenthesis=remove
|
||||||
|
cpp_space_within_parameter_list_parentheses=false
|
||||||
|
cpp_space_between_empty_parameter_list_parentheses=false
|
||||||
|
cpp_space_after_keywords_in_control_flow_statements=true
|
||||||
|
cpp_space_within_control_flow_statement_parentheses=false
|
||||||
|
cpp_space_before_lambda_open_parenthesis=false
|
||||||
|
cpp_space_within_cast_parentheses=false
|
||||||
|
cpp_space_after_cast_close_parenthesis=false
|
||||||
|
cpp_space_within_expression_parentheses=false
|
||||||
|
cpp_space_before_block_open_brace=true
|
||||||
|
cpp_space_between_empty_braces=false
|
||||||
|
cpp_space_before_initializer_list_open_brace=false
|
||||||
|
cpp_space_within_initializer_list_braces=true
|
||||||
|
cpp_space_preserve_in_initializer_list=true
|
||||||
|
cpp_space_before_open_square_bracket=false
|
||||||
|
cpp_space_within_square_brackets=false
|
||||||
|
cpp_space_before_empty_square_brackets=false
|
||||||
|
cpp_space_between_empty_square_brackets=false
|
||||||
|
cpp_space_group_square_brackets=true
|
||||||
|
cpp_space_within_lambda_brackets=false
|
||||||
|
cpp_space_between_empty_lambda_brackets=false
|
||||||
|
cpp_space_before_comma=false
|
||||||
|
cpp_space_after_comma=true
|
||||||
|
cpp_space_remove_around_member_operators=true
|
||||||
|
cpp_space_before_inheritance_colon=true
|
||||||
|
cpp_space_before_constructor_colon=true
|
||||||
|
cpp_space_remove_before_semicolon=true
|
||||||
|
cpp_space_after_semicolon=false
|
||||||
|
cpp_space_remove_around_unary_operator=true
|
||||||
|
cpp_space_around_binary_operator=insert
|
||||||
|
cpp_space_around_assignment_operator=insert
|
||||||
|
cpp_space_pointer_reference_alignment=left
|
||||||
|
cpp_space_around_ternary_operator=insert
|
||||||
|
cpp_wrap_preserve_blocks=one_liners
|
||||||
116
app.py
116
app.py
@@ -1,116 +0,0 @@
|
|||||||
import os
|
|
||||||
from flask import Flask, render_template, request, redirect, url_for, flash
|
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
|
||||||
from datetime import datetime, date
|
|
||||||
from dotenv import load_dotenv
|
|
||||||
|
|
||||||
load_dotenv() # Загрузка переменных окружения из .env
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
|
||||||
app.secret_key = os.getenv('SECRET_KEY', 'secret-key')
|
|
||||||
|
|
||||||
# Конфигурация PostgreSQL
|
|
||||||
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DATABASE_URL', 'postgresql://user:password@localhost/finance_db')
|
|
||||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
|
||||||
|
|
||||||
db = SQLAlchemy(app)
|
|
||||||
|
|
||||||
# Модель данных
|
|
||||||
class Transaction(db.Model):
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
|
||||||
type = db.Column(db.String(10), nullable=False) # 'income' или 'expense'
|
|
||||||
amount = db.Column(db.Float, nullable=False)
|
|
||||||
category = db.Column(db.String(50), nullable=False)
|
|
||||||
date = db.Column(db.Date, nullable=False, default=date.today())
|
|
||||||
description = db.Column(db.Text)
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return f'<Transaction {self.id}: {self.type} {self.amount}>'
|
|
||||||
|
|
||||||
# Роуты
|
|
||||||
@app.route('/')
|
|
||||||
def index():
|
|
||||||
# Получаем все транзакции, отсортированные по дате
|
|
||||||
transactions = Transaction.query.order_by(Transaction.date.desc()).all()
|
|
||||||
|
|
||||||
# Рассчитываем общие суммы
|
|
||||||
total_income = sum(t.amount for t in transactions if t.type == 'income')
|
|
||||||
total_expense = sum(t.amount for t in transactions if t.type == 'expense')
|
|
||||||
balance = total_income - total_expense
|
|
||||||
|
|
||||||
# Группируем по категориям
|
|
||||||
categories = {}
|
|
||||||
for t in transactions:
|
|
||||||
if t.category not in categories:
|
|
||||||
categories[t.category] = {'income': 0, 'expense': 0}
|
|
||||||
categories[t.category][t.type] += t.amount
|
|
||||||
|
|
||||||
return render_template('index.html',
|
|
||||||
transactions=transactions,
|
|
||||||
total_income=total_income,
|
|
||||||
total_expense=total_expense,
|
|
||||||
balance=balance,
|
|
||||||
categories=categories,
|
|
||||||
current_date=date.today())
|
|
||||||
|
|
||||||
@app.route('/add', methods=['GET', 'POST'])
|
|
||||||
def add_transaction():
|
|
||||||
if request.method == 'POST':
|
|
||||||
# Получаем данные из формы
|
|
||||||
transaction_type = request.form['type']
|
|
||||||
amount = float(request.form['amount'])
|
|
||||||
category = request.form['category']
|
|
||||||
transaction_date = datetime.strptime(request.form['date'], '%Y-%m-%d').date()
|
|
||||||
description = request.form['description']
|
|
||||||
|
|
||||||
# Создаем новую транзакцию
|
|
||||||
new_transaction = Transaction(
|
|
||||||
type=transaction_type,
|
|
||||||
amount=amount,
|
|
||||||
category=category,
|
|
||||||
date=transaction_date,
|
|
||||||
description=description
|
|
||||||
)
|
|
||||||
|
|
||||||
# Сохраняем в БД
|
|
||||||
db.session.add(new_transaction)
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
flash('Транзакция успешно добавлена!', 'success')
|
|
||||||
return redirect(url_for('index'))
|
|
||||||
|
|
||||||
# Для GET-запроса показываем форму
|
|
||||||
return render_template('add.html', current_date=date.today())
|
|
||||||
|
|
||||||
@app.route('/edit/<int:id>', methods=['GET', 'POST'])
|
|
||||||
def edit_transaction(id):
|
|
||||||
transaction = Transaction.query.get_or_404(id)
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
|
||||||
# Обновляем данные
|
|
||||||
transaction.type = request.form['type']
|
|
||||||
transaction.amount = float(request.form['amount'])
|
|
||||||
transaction.category = request.form['category']
|
|
||||||
transaction.date = datetime.strptime(request.form['date'], '%Y-%m-%d').date()
|
|
||||||
transaction.description = request.form['description']
|
|
||||||
|
|
||||||
# Сохраняем изменения
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
flash('Транзакция успешно обновлена!', 'success')
|
|
||||||
return redirect(url_for('index'))
|
|
||||||
|
|
||||||
# Для GET-запроса показываем форму с текущими данными
|
|
||||||
return render_template('edit.html', transaction=transaction)
|
|
||||||
|
|
||||||
@app.route('/delete/<int:id>')
|
|
||||||
def delete_transaction(id):
|
|
||||||
transaction = Transaction.query.get_or_404(id)
|
|
||||||
db.session.delete(transaction)
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
flash('Транзакция успешно удалена!', 'success')
|
|
||||||
return redirect(url_for('index'))
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run(debug=True)
|
|
||||||
25
init_db.py
25
init_db.py
@@ -1,25 +0,0 @@
|
|||||||
import os
|
|
||||||
from app import db, app, Transaction
|
|
||||||
from datetime import date
|
|
||||||
|
|
||||||
app.app_context().push()
|
|
||||||
|
|
||||||
# Создание таблиц
|
|
||||||
db.create_all()
|
|
||||||
|
|
||||||
# Добавление начальных данных
|
|
||||||
if not Transaction.query.first():
|
|
||||||
transactions = [
|
|
||||||
Transaction(type='income', amount=50000, category='Зарплата', date=date(2023, 10, 15), description='Основная зарплата'),
|
|
||||||
Transaction(type='expense', amount=15000, category='Аренда', date=date(2023, 10, 5), description='Аренда квартиры'),
|
|
||||||
Transaction(type='expense', amount=3500, category='Продукты', date=date(2023, 10, 12), description='Супермаркет'),
|
|
||||||
Transaction(type='expense', amount=2500, category='Транспорт', date=date(2023, 10, 18), description='Бензин'),
|
|
||||||
Transaction(type='income', amount=10000, category='Фриланс', date=date(2023, 10, 20), description='Веб-разработка')
|
|
||||||
]
|
|
||||||
|
|
||||||
for t in transactions:
|
|
||||||
db.session.add(t)
|
|
||||||
db.session.commit()
|
|
||||||
print("База данных инициализирована с тестовыми данными")
|
|
||||||
else:
|
|
||||||
print("База данных уже содержит данные")
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
flask
|
|
||||||
flask-sqlalchemy
|
|
||||||
psycopg2-binary
|
|
||||||
python-dotenv
|
|
||||||
@@ -1,338 +0,0 @@
|
|||||||
:root {
|
|
||||||
--primary: #2c3e50;
|
|
||||||
--secondary: #3498db;
|
|
||||||
--income: #2ecc71;
|
|
||||||
--expense: #e74c3c;
|
|
||||||
--light: #ecf0f1;
|
|
||||||
--dark: #34495e;
|
|
||||||
--gray: #7f8c8d;
|
|
||||||
}
|
|
||||||
|
|
||||||
* {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
box-sizing: border-box;
|
|
||||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
background: linear-gradient(135deg, #1a2a6c, #b21f1f, #1a2a6c);
|
|
||||||
color: var(--dark);
|
|
||||||
padding: 20px;
|
|
||||||
min-height: 100vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
|
||||||
background: white;
|
|
||||||
border-radius: 15px;
|
|
||||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
|
|
||||||
overflow: hidden;
|
|
||||||
max-width: 1200px;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-container {
|
|
||||||
max-width: 600px;
|
|
||||||
padding: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
header {
|
|
||||||
background: var(--primary);
|
|
||||||
color: white;
|
|
||||||
padding: 20px;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
header h1 {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 15px;
|
|
||||||
font-size: 1.8rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.summary {
|
|
||||||
display: flex;
|
|
||||||
gap: 20px;
|
|
||||||
margin-top: 15px;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.summary-item {
|
|
||||||
flex: 1;
|
|
||||||
background: white;
|
|
||||||
border-radius: 10px;
|
|
||||||
padding: 15px;
|
|
||||||
text-align: center;
|
|
||||||
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.summary-item.income {
|
|
||||||
border-top: 5px solid var(--income);
|
|
||||||
}
|
|
||||||
|
|
||||||
.summary-item.expense {
|
|
||||||
border-top: 5px solid var(--expense);
|
|
||||||
}
|
|
||||||
|
|
||||||
.summary-item.balance {
|
|
||||||
border-top: 5px solid var(--secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.summary-item span {
|
|
||||||
display: block;
|
|
||||||
color: var(--gray);
|
|
||||||
font-size: 0.9rem;
|
|
||||||
margin-bottom: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.summary-item strong {
|
|
||||||
font-size: 1.5rem;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.controls {
|
|
||||||
padding: 20px;
|
|
||||||
background: var(--light);
|
|
||||||
border-bottom: 1px solid #ddd;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
padding: 10px 20px;
|
|
||||||
border-radius: 50px;
|
|
||||||
text-decoration: none;
|
|
||||||
font-weight: 500;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
border: none;
|
|
||||||
font-size: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.add-btn {
|
|
||||||
background: var(--secondary);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.add-btn:hover {
|
|
||||||
background: #2980b9;
|
|
||||||
}
|
|
||||||
|
|
||||||
.back-btn {
|
|
||||||
background: var(--gray);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.save-btn {
|
|
||||||
background: var(--income);
|
|
||||||
color: white;
|
|
||||||
padding: 12px 25px;
|
|
||||||
font-size: 1.1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.back-btn:hover {
|
|
||||||
background: #666;
|
|
||||||
}
|
|
||||||
|
|
||||||
section {
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
color: var(--primary);
|
|
||||||
border-bottom: 2px solid var(--light);
|
|
||||||
padding-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.category-list {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
|
|
||||||
gap: 15px;
|
|
||||||
margin-bottom: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.category-item {
|
|
||||||
background: white;
|
|
||||||
border-radius: 10px;
|
|
||||||
padding: 15px;
|
|
||||||
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
border-left: 5px solid var(--expense);
|
|
||||||
}
|
|
||||||
|
|
||||||
.category-item span.amount {
|
|
||||||
font-weight: bold;
|
|
||||||
font-size: 1.2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table th, table td {
|
|
||||||
padding: 12px 15px;
|
|
||||||
text-align: left;
|
|
||||||
border-bottom: 1px solid #eee;
|
|
||||||
}
|
|
||||||
|
|
||||||
table th {
|
|
||||||
background: var(--primary);
|
|
||||||
color: white;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
table tbody tr:hover {
|
|
||||||
background: rgba(52, 152, 219, 0.05);
|
|
||||||
}
|
|
||||||
|
|
||||||
table .income {
|
|
||||||
color: var(--income);
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
table .expense {
|
|
||||||
color: var(--expense);
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn.edit-btn {
|
|
||||||
background: #f39c12;
|
|
||||||
color: white;
|
|
||||||
padding: 8px 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn.delete-btn {
|
|
||||||
background: var(--expense);
|
|
||||||
color: white;
|
|
||||||
padding: 8px 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn.edit-btn:hover {
|
|
||||||
background: #e67e22;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn.delete-btn:hover {
|
|
||||||
background: #c0392b;
|
|
||||||
}
|
|
||||||
|
|
||||||
.empty {
|
|
||||||
text-align: center;
|
|
||||||
padding: 20px;
|
|
||||||
color: var(--gray);
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
footer {
|
|
||||||
text-align: center;
|
|
||||||
padding: 20px;
|
|
||||||
color: var(--gray);
|
|
||||||
font-size: 0.9rem;
|
|
||||||
border-top: 1px solid #eee;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tip {
|
|
||||||
font-style: italic;
|
|
||||||
margin-top: 10px;
|
|
||||||
color: var(--primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Формы */
|
|
||||||
.form-group {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group label {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group input,
|
|
||||||
.form-group textarea,
|
|
||||||
.form-group select {
|
|
||||||
width: 100%;
|
|
||||||
padding: 12px;
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
border-radius: 8px;
|
|
||||||
font-size: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group textarea {
|
|
||||||
min-height: 100px;
|
|
||||||
resize: vertical;
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-group {
|
|
||||||
display: flex;
|
|
||||||
gap: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-label {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-custom {
|
|
||||||
display: inline-block;
|
|
||||||
padding: 10px 20px;
|
|
||||||
border-radius: 50px;
|
|
||||||
font-weight: 500;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-custom.income {
|
|
||||||
background: rgba(46, 204, 113, 0.2);
|
|
||||||
color: var(--income);
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-custom.expense {
|
|
||||||
background: rgba(231, 76, 60, 0.2);
|
|
||||||
color: var(--expense);
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="radio"] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="radio"]:checked + .radio-custom.income {
|
|
||||||
background: var(--income);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="radio"]:checked + .radio-custom.expense {
|
|
||||||
background: var(--expense);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Адаптивность */
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.summary {
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
table {
|
|
||||||
display: block;
|
|
||||||
overflow-x: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.category-list {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="ru">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Добавить операцию</title>
|
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
|
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container form-container">
|
|
||||||
<header>
|
|
||||||
<h1><i class="fas fa-plus-circle"></i> Добавить операцию</h1>
|
|
||||||
<a href="{{ url_for('index') }}" class="btn back-btn">
|
|
||||||
<i class="fas fa-arrow-left"></i> Назад
|
|
||||||
</a>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<form method="POST">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="type">Тип операции:</label>
|
|
||||||
<div class="radio-group">
|
|
||||||
<label class="radio-label">
|
|
||||||
<input type="radio" name="type" value="income" checked>
|
|
||||||
<span class="radio-custom income">Доход</span>
|
|
||||||
</label>
|
|
||||||
<label class="radio-label">
|
|
||||||
<input type="radio" name="type" value="expense">
|
|
||||||
<span class="radio-custom expense">Расход</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="amount">Сумма (₽):</label>
|
|
||||||
<input type="number" step="0.01" min="0.01" name="amount" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="category">Категория:</label>
|
|
||||||
<input type="text" name="category" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="date">Дата:</label>
|
|
||||||
<input type="date" name="date" value="{{ current_date }}" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="description">Описание:</label>
|
|
||||||
<textarea name="description" rows="3"></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button type="submit" class="btn save-btn">
|
|
||||||
<i class="fas fa-save"></i> Сохранить
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="ru">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Редактировать операцию</title>
|
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
|
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container form-container">
|
|
||||||
<header>
|
|
||||||
<h1><i class="fas fa-edit"></i> Редактировать операцию</h1>
|
|
||||||
<a href="{{ url_for('index') }}" class="btn back-btn">
|
|
||||||
<i class="fas fa-arrow-left"></i> Назад
|
|
||||||
</a>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<form method="POST">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="type">Тип операции:</label>
|
|
||||||
<div class="radio-group">
|
|
||||||
<label class="radio-label">
|
|
||||||
<input type="radio" name="type" value="income" {% if transaction.type == 'income' %}checked{% endif %}>
|
|
||||||
<span class="radio-custom income">Доход</span>
|
|
||||||
</label>
|
|
||||||
<label class="radio-label">
|
|
||||||
<input type="radio" name="type" value="expense" {% if transaction.type == 'expense' %}checked{% endif %}>
|
|
||||||
<span class="radio-custom expense">Расход</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="amount">Сумма (₽):</label>
|
|
||||||
<input type="number" step="0.01" min="0.01" name="amount" value="{{ transaction.amount }}" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="category">Категория:</label>
|
|
||||||
<input type="text" name="category" value="{{ transaction.category }}" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="date">Дата:</label>
|
|
||||||
<input type="date" name="date" value="{{ transaction.date }}" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="description">Описание:</label>
|
|
||||||
<textarea name="description" rows="3">{{ transaction.description }}</textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button type="submit" class="btn save-btn">
|
|
||||||
<i class="fas fa-save"></i> Сохранить изменения
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="ru">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Финансовый учет</title>
|
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
|
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container">
|
|
||||||
<header>
|
|
||||||
<h1><i class="fas fa-coins"></i> Финансовый учет</h1>
|
|
||||||
<div class="summary">
|
|
||||||
<div class="summary-item income">
|
|
||||||
<span>Доходы</span>
|
|
||||||
<strong>{{ total_income|int }} ₽</strong>
|
|
||||||
</div>
|
|
||||||
<div class="summary-item expense">
|
|
||||||
<span>Расходы</span>
|
|
||||||
<strong>{{ total_expense|int }} ₽</strong>
|
|
||||||
</div>
|
|
||||||
<div class="summary-item balance">
|
|
||||||
<span>Баланс</span>
|
|
||||||
<strong>{{ balance|int }} ₽</strong>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<div class="controls">
|
|
||||||
<a href="{{ url_for('add_transaction') }}" class="btn add-btn">
|
|
||||||
<i class="fas fa-plus"></i> Добавить операцию
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<section class="categories">
|
|
||||||
<h2>Расходы по категориям</h2>
|
|
||||||
<div class="category-list">
|
|
||||||
{% for category, amounts in categories.items() %}
|
|
||||||
{% if amounts['expense'] > 0 %}
|
|
||||||
<div class="category-item">
|
|
||||||
<span>{{ category }}</span>
|
|
||||||
<span class="amount expense">{{ amounts['expense']|int }} ₽</span>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="transactions">
|
|
||||||
<h2>История операций</h2>
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Дата</th>
|
|
||||||
<th>Категория</th>
|
|
||||||
<th>Описание</th>
|
|
||||||
<th>Сумма</th>
|
|
||||||
<th>Действия</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for t in transactions %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ t.date.strftime('%d.%m.%Y') }}</td>
|
|
||||||
<td>{{ t.category }}</td>
|
|
||||||
<td>{{ t.description }}</td>
|
|
||||||
<td class="{{ 'income' if t.type == 'income' else 'expense' }}">
|
|
||||||
{{ t.amount|int }} ₽
|
|
||||||
</td>
|
|
||||||
<td class="actions">
|
|
||||||
<a href="{{ url_for('edit_transaction', id=t.id) }}" class="btn edit-btn">
|
|
||||||
<i class="fas fa-edit"></i>
|
|
||||||
</a>
|
|
||||||
<a href="{{ url_for('delete_transaction', id=t.id) }}" class="btn delete-btn">
|
|
||||||
<i class="fas fa-trash"></i>
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% else %}
|
|
||||||
<tr>
|
|
||||||
<td colspan="5" class="empty">Нет операций</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<footer>
|
|
||||||
<p>Сегодня: {{ current_date.strftime('%d.%m.%Y') }}</p>
|
|
||||||
<p class="tip">"Учет финансов - первый шаг к финансовой свободе!"</p>
|
|
||||||
</footer>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Обработка сообщений flash -->
|
|
||||||
<script>
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
setTimeout(function() {
|
|
||||||
const messages = document.querySelectorAll('.flash-message');
|
|
||||||
messages.forEach(msg => {
|
|
||||||
msg.style.opacity = '0';
|
|
||||||
setTimeout(() => msg.remove(), 500);
|
|
||||||
});
|
|
||||||
}, 3000);
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Reference in New Issue
Block a user