Отчёт о поставках
This commit is contained in:
@@ -24,14 +24,16 @@ def create():
|
|||||||
title='Создание отчета',
|
title='Создание отчета',
|
||||||
items = report_list)
|
items = report_list)
|
||||||
else:
|
else:
|
||||||
data = dict(month=request.form.get('month'), year=request.form.get('year'))
|
data = dict(id=request.form.get('category'),
|
||||||
id = request.form.get('category')
|
month=request.form.get('month'),
|
||||||
with open(path.join(path.dirname(__file__), f'access/{id}.json')) as f:
|
year=request.form.get('year'))
|
||||||
|
|
||||||
|
with open(path.join(path.dirname(__file__), f'access/{data['id']}.json')) as f:
|
||||||
report_access = json.load(f)
|
report_access = json.load(f)
|
||||||
|
|
||||||
if session['role'] in report_access['write']:
|
if session['role'] in report_access['write']:
|
||||||
proc_name = report_access['procedure']
|
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:
|
if ready_report.status:
|
||||||
return render_template("OK.html")
|
return render_template("OK.html")
|
||||||
else:
|
else:
|
||||||
@@ -48,11 +50,11 @@ def view():
|
|||||||
title='Просмотр отчета',
|
title='Просмотр отчета',
|
||||||
items = report_list)
|
items = report_list)
|
||||||
else:
|
else:
|
||||||
data = dict(month=request.form.get('month'),
|
data = dict(id=request.form.get('category'),
|
||||||
year=request.form.get('year'),
|
month=request.form.get('month'),
|
||||||
id = request.form.get('category'))
|
year=request.form.get('year'))
|
||||||
id = request.form.get('category')
|
|
||||||
with open(path.join(path.dirname(__file__), f'access/{id}.json')) as f:
|
with open(path.join(path.dirname(__file__), f'access/{data['id']}.json')) as f:
|
||||||
report_access = json.load(f)
|
report_access = json.load(f)
|
||||||
|
|
||||||
if session['role'] in report_access['read']:
|
if session['role'] in report_access['read']:
|
||||||
|
|||||||
@@ -33,14 +33,14 @@ def view_report(input_data: dict, view_script: str) -> InfoRespronse:
|
|||||||
status=False)
|
status=False)
|
||||||
return InfoRespronse(result, error_message='', status=True)
|
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)
|
status = check_report(input_data)
|
||||||
if status:
|
if status:
|
||||||
return InfoRespronse((),
|
return InfoRespronse((),
|
||||||
error_message = 'Отчет уже существует',
|
error_message = 'Отчет уже существует',
|
||||||
status=False)
|
status=False)
|
||||||
|
|
||||||
data = (report_id,*input_data.values())
|
data = tuple(input_data.values())
|
||||||
result = procedure(current_app.config['db_config'], proc_name, data)
|
result = procedure(current_app.config['db_config'], proc_name, data)
|
||||||
if result is None:
|
if result is None:
|
||||||
return InfoRespronse((),
|
return InfoRespronse((),
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
SELECT EXISTS (
|
SELECT EXISTS (
|
||||||
SELECT 1 FROM reports
|
SELECT 1 FROM reports
|
||||||
WHERE month = $month AND year = $year
|
WHERE report_category_id = '$id' AND (month = '$month' AND year = '$year')
|
||||||
) AS exist;
|
) AS exist;
|
||||||
8
App/Report/sql/sellers_report.sql
Normal file
8
App/Report/sql/sellers_report.sql
Normal 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;
|
||||||
@@ -5,7 +5,8 @@
|
|||||||
"Управляющий": [
|
"Управляющий": [
|
||||||
"requests_bp",
|
"requests_bp",
|
||||||
"report_bp"],
|
"report_bp"],
|
||||||
|
"Бухгалтер": [
|
||||||
|
"report_bp"],
|
||||||
"Поставщик": [
|
"Поставщик": [
|
||||||
"waybill_bp"]
|
"waybill_bp"]
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user