Отчёт о поставках

This commit is contained in:
2024-11-21 11:41:31 +03:00
parent 54cf175b00
commit da90fe023f
5 changed files with 24 additions and 13 deletions

View File

@@ -24,14 +24,16 @@ def create():
title='Создание отчета',
items = report_list)
else:
data = dict(month=request.form.get('month'), year=request.form.get('year'))
id = request.form.get('category')
with open(path.join(path.dirname(__file__), f'access/{id}.json')) as f:
data = dict(id=request.form.get('category'),
month=request.form.get('month'),
year=request.form.get('year'))
with open(path.join(path.dirname(__file__), f'access/{data['id']}.json')) as f:
report_access = json.load(f)
if session['role'] in report_access['write']:
proc_name = report_access['procedure']
ready_report = make_report(data, int(id),proc_name)
ready_report = make_report(data, proc_name)
if ready_report.status:
return render_template("OK.html")
else:
@@ -48,11 +50,11 @@ def view():
title='Просмотр отчета',
items = report_list)
else:
data = dict(month=request.form.get('month'),
year=request.form.get('year'),
id = request.form.get('category'))
id = request.form.get('category')
with open(path.join(path.dirname(__file__), f'access/{id}.json')) as f:
data = dict(id=request.form.get('category'),
month=request.form.get('month'),
year=request.form.get('year'))
with open(path.join(path.dirname(__file__), f'access/{data['id']}.json')) as f:
report_access = json.load(f)
if session['role'] in report_access['read']:

View File

@@ -33,14 +33,14 @@ def view_report(input_data: dict, view_script: str) -> InfoRespronse:
status=False)
return InfoRespronse(result, error_message='', status=True)
def make_report(input_data: dict, report_id: int, proc_name: str) -> InfoRespronse:
def make_report(input_data: dict, proc_name: str) -> InfoRespronse:
status = check_report(input_data)
if status:
return InfoRespronse((),
error_message = 'Отчет уже существует',
status=False)
data = (report_id,*input_data.values())
data = tuple(input_data.values())
result = procedure(current_app.config['db_config'], proc_name, data)
if result is None:
return InfoRespronse((),

View File

@@ -1,4 +1,4 @@
SELECT EXISTS (
SELECT 1 FROM reports
WHERE month = $month AND year = $year
WHERE report_category_id = '$id' AND (month = '$month' AND year = '$year')
) AS exist;

View File

@@ -0,0 +1,8 @@
SELECT
s.name AS Поставщик,
SUM(reports.count) AS 'Количество поставок',
SUM(reports.sum) AS Сумма
FROM reports
JOIN sellers s ON reports.item_id = s.sel_id
WHERE report_category_id = '$id' AND (month = '$month' AND year = '$year')
GROUP BY s.name;

View File

@@ -5,7 +5,8 @@
"Управляющий": [
"requests_bp",
"report_bp"],
"Бухгалтер": [
"report_bp"],
"Поставщик": [
"waybill_bp"]
}