Skip to content

Commit c8050b6

Browse files
committed
fix: Исправление использования моделей
Signed-off-by: Roman Chursanov <[email protected]>
1 parent 55deb53 commit c8050b6

File tree

6 files changed

+35
-35
lines changed

6 files changed

+35
-35
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = "Бот-помощник СТП"
55
readme = "README.md"
66
requires-python = ">=3.13"
77
dependencies = [
8-
"stp-database @ git+https://[email protected]/ERTG-BOTS/stp-database.git",
8+
"stp-database @ git+https://[email protected]/ERTG-BOTS/stp-database.git@35ea48b",
99
"aiogram>=3.21.0",
1010
"aiomysql>=0.2.0",
1111
"alembic==1.16.5",

tgbot/handlers/head/group/members.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ async def view_member_kpi(
434434
🎯 <b>Цель - {SalaryFormatter.format_percentage(premium.target_premium)}</b>
435435
<blockquote>Тип: {premium.target_type or "—"}
436436
Факт: {SalaryFormatter.format_value(premium.target)}
437-
План: {SalaryFormatter.format_value(round(premium.target_goal_first)) if premium.target_goal_first else "—"} / {SalaryFormatter.format_value(round(premium.target_goal_second)) if premium.target_goal_second else "—"}</blockquote>
437+
План: {SalaryFormatter.format_value(round(premium.target_normative_first)) if premium.target_normative_first else "—"} / {SalaryFormatter.format_value(round(premium.target_normative_second)) if premium.target_normative_second else "—"}</blockquote>
438438
439439
💼 <b>Дополнительно</b>
440440
<blockquote>Дисциплина: {SalaryFormatter.format_percentage(premium.discipline_premium)}
@@ -463,8 +463,8 @@ async def view_member_kpi(
463463
)
464464
target_calculation = KPICalculator.calculate_target_needed(
465465
premium.target,
466-
premium.target_goal_first,
467-
premium.target_goal_second,
466+
premium.target_normative_first,
467+
premium.target_normative_second,
468468
premium.target_type,
469469
)
470470

@@ -495,8 +495,8 @@ async def view_member_kpi(
495495
{gok_calculation}</blockquote>
496496
497497
🎯 <b>Цель</b>
498-
<blockquote>Факт: {SalaryFormatter.format_value(premium.target)} ({SalaryFormatter.format_percentage(round((premium.target_goal_first / premium.target * 100) if premium.target_type and "AHT" in premium.target_type and premium.target and premium.target > 0 and premium.target_goal_first else (premium.target / premium.target_goal_first * 100) if premium.target_goal_first and premium.target_goal_first > 0 else 0))} / {SalaryFormatter.format_percentage(round((premium.target_goal_second / premium.target * 100) if premium.target_type and "AHT" in premium.target_type and premium.target and premium.target > 0 and premium.target_goal_second else (premium.target / premium.target_goal_second * 100) if premium.target_goal_second and premium.target_goal_second > 0 else 0))})
499-
План: {SalaryFormatter.format_value(round(premium.target_goal_first))} / {SalaryFormatter.format_value(round(premium.target_goal_second))}
498+
<blockquote>Факт: {SalaryFormatter.format_value(premium.target)} ({SalaryFormatter.format_percentage(round((premium.target_normative_first / premium.target * 100) if premium.target_type and "AHT" in premium.target_type and premium.target and premium.target > 0 and premium.target_normative_first else (premium.target / premium.target_normative_first * 100) if premium.target_normative_first and premium.target_normative_first > 0 else 0))} / {SalaryFormatter.format_percentage(round((premium.target_normative_second / premium.target * 100) if premium.target_type and "AHT" in premium.target_type and premium.target and premium.target > 0 and premium.target_normative_second else (premium.target / premium.target_normative_second * 100) if premium.target_normative_second and premium.target_normative_second > 0 else 0))})
499+
План: {SalaryFormatter.format_value(round(premium.target_normative_first))} / {SalaryFormatter.format_value(round(premium.target_normative_second))}
500500
501501
Требуется минимум 100 {"чатов" if member.division == "НЦК" else "звонков"} для получения премии за цель
502502

tgbot/handlers/head/kpi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async def head_start_cb(
4343
🎯 <b>Цель - {SalaryFormatter.format_percentage(premium.target_premium)}</b>
4444
<blockquote>Тип: {premium.target_type or "—"}
4545
Факт: {SalaryFormatter.format_value(premium.target)}
46-
План: {SalaryFormatter.format_value(round(premium.target_goal_first))} / {SalaryFormatter.format_value(round(premium.target_goal_second))}</blockquote>
46+
План: {SalaryFormatter.format_value(round(premium.target_normative_first))} / {SalaryFormatter.format_value(round(premium.target_normative_second))}</blockquote>
4747
4848
💰 <b>Итого:</b>
4949
<b>Общая премия: {SalaryFormatter.format_percentage(premium.total_premium)}</b>
@@ -82,8 +82,8 @@ async def head_kpi_calculator_cb(
8282
)
8383
target_calculation = KPICalculator.calculate_target_needed(
8484
user_premium.target,
85-
user_premium.target_goal_first,
86-
user_premium.target_goal_second,
85+
user_premium.target_normative_first,
86+
user_premium.target_normative_second,
8787
user_premium.target_type,
8888
is_head=True,
8989
)
@@ -106,7 +106,7 @@ async def head_kpi_calculator_cb(
106106
107107
🎯 <b>Цель</b>
108108
<blockquote>Факт: {SalaryFormatter.format_value(user_premium.target)} ({SalaryFormatter.format_percentage(user_premium.target_result_first)} / {SalaryFormatter.format_percentage(user_premium.target_result_second)})
109-
План: {SalaryFormatter.format_value(round(user_premium.target_goal_first))} / {SalaryFormatter.format_value(round(user_premium.target_goal_second))}
109+
План: {SalaryFormatter.format_value(round(user_premium.target_normative_first))} / {SalaryFormatter.format_value(round(user_premium.target_normative_second))}
110110
111111
<b>Для премии:</b>
112112
{target_calculation}</blockquote>

tgbot/handlers/search/main.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,8 @@ async def view_user_kpi_calculator(
673673
)
674674
target_calculation = KPICalculator.calculate_target_needed(
675675
user_premium.target,
676-
user_premium.target_goal_first,
677-
user_premium.target_goal_second,
676+
user_premium.target_normative_first,
677+
user_premium.target_normative_second,
678678
user_premium.target_type,
679679
is_head=True,
680680
)
@@ -700,7 +700,7 @@ async def view_user_kpi_calculator(
700700
701701
🎯 <b>Цель</b>
702702
<blockquote>Факт: {SalaryFormatter.format_value(user_premium.target)} ({SalaryFormatter.format_percentage(user_premium.target_result_first)} / {SalaryFormatter.format_percentage(user_premium.target_result_second)})
703-
План: {SalaryFormatter.format_value(round(user_premium.target_goal_first))} / {SalaryFormatter.format_value(round(user_premium.target_goal_second))}
703+
План: {SalaryFormatter.format_value(round(user_premium.target_normative_first))} / {SalaryFormatter.format_value(round(user_premium.target_normative_second))}
704704
705705
<b>Для премии:</b>
706706
{target_calculation}</blockquote>
@@ -719,8 +719,8 @@ async def view_user_kpi_calculator(
719719
)
720720
target_calculation = KPICalculator.calculate_target_needed(
721721
user_premium.target,
722-
user_premium.target_goal_first,
723-
user_premium.target_goal_second,
722+
user_premium.target_normative_first,
723+
user_premium.target_normative_second,
724724
user_premium.target_type,
725725
)
726726

@@ -751,8 +751,8 @@ async def view_user_kpi_calculator(
751751
{gok_calculation}</blockquote>
752752
753753
🎯 <b>Цель</b>
754-
<blockquote>Факт: {SalaryFormatter.format_value(user_premium.target)} ({SalaryFormatter.format_percentage(round((user_premium.target_goal_first / user_premium.target * 100) if user_premium.target_type and "AHT" in user_premium.target_type and user_premium.target and user_premium.target > 0 and user_premium.target_goal_first else (user_premium.target / user_premium.target_goal_first * 100) if user_premium.target_goal_first and user_premium.target_goal_first > 0 else 0))} / {SalaryFormatter.format_percentage(round((user_premium.target_goal_second / user_premium.target * 100) if user_premium.target_type and "AHT" in user_premium.target_type and user_premium.target and user_premium.target > 0 and user_premium.target_goal_second else (user_premium.target / user_premium.target_goal_second * 100) if user_premium.target_goal_second and user_premium.target_goal_second > 0 else 0))})
755-
План: {SalaryFormatter.format_value(round(user_premium.target_goal_first))} / {SalaryFormatter.format_value(round(user_premium.target_goal_second))}
754+
<blockquote>Факт: {SalaryFormatter.format_value(user_premium.target)} ({SalaryFormatter.format_percentage(round((user_premium.target_normative_first / user_premium.target * 100) if user_premium.target_type and "AHT" in user_premium.target_type and user_premium.target and user_premium.target > 0 and user_premium.target_normative_first else (user_premium.target / user_premium.target_normative_first * 100) if user_premium.target_normative_first and user_premium.target_normative_first > 0 else 0))} / {SalaryFormatter.format_percentage(round((user_premium.target_normative_second / user_premium.target * 100) if user_premium.target_type and "AHT" in user_premium.target_type and user_premium.target and user_premium.target > 0 and user_premium.target_normative_second else (user_premium.target / user_premium.target_normative_second * 100) if user_premium.target_normative_second and user_premium.target_normative_second > 0 else 0))})
755+
План: {SalaryFormatter.format_value(round(user_premium.target_normative_first))} / {SalaryFormatter.format_value(round(user_premium.target_normative_second))}
756756
757757
Требуется минимум 100 {"чатов" if user.division == "НЦК" else "звонков"} для получения премии за цель
758758
@@ -923,7 +923,7 @@ async def view_user_kpi(
923923
🎯 <b>Цель - {SalaryFormatter.format_percentage(premium.target_premium)}</b>
924924
<blockquote>Тип: {premium.target_type or "—"}
925925
Факт: {SalaryFormatter.format_value(premium.target)}
926-
План: {SalaryFormatter.format_value(round(premium.target_goal_first))} / {SalaryFormatter.format_value(round(premium.target_goal_second))}</blockquote>
926+
План: {SalaryFormatter.format_value(round(premium.target_normative_first))} / {SalaryFormatter.format_value(round(premium.target_normative_second))}</blockquote>
927927
928928
💰 <b>Итого:</b>
929929
<b>Общая премия: {SalaryFormatter.format_percentage(premium.total_premium)}</b>
@@ -956,7 +956,7 @@ async def view_user_kpi(
956956
🎯 <b>Цель - {SalaryFormatter.format_percentage(premium.target_premium)}</b>
957957
<blockquote>Тип: {premium.target_type or "—"}
958958
Факт: {SalaryFormatter.format_value(premium.target)}
959-
План: {SalaryFormatter.format_value(round(premium.target_goal_first)) if premium.target_goal_first else "—"} / {SalaryFormatter.format_value(round(premium.target_goal_second)) if premium.target_goal_second else "—"}</blockquote>
959+
План: {SalaryFormatter.format_value(round(premium.target_normative_first)) if premium.target_normative_first else "—"} / {SalaryFormatter.format_value(round(premium.target_normative_second)) if premium.target_normative_second else "—"}</blockquote>
960960
961961
💼 <b>Дополнительно</b>
962962
<blockquote>Дисциплина: {SalaryFormatter.format_percentage(premium.discipline_premium)}

tgbot/handlers/user/kpi.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async def user_kpi_cb(
6060
🎯 <b>Цель - {SalaryFormatter.format_percentage(premium.target_premium)}</b>
6161
<blockquote>Тип: {premium.target_type or "—"}
6262
Факт: {SalaryFormatter.format_value(premium.target)}
63-
План: {SalaryFormatter.format_value(round(premium.target_goal_first))} / {SalaryFormatter.format_value(round(premium.target_goal_second))}</blockquote>
63+
План: {SalaryFormatter.format_value(round(premium.target_normative_first))} / {SalaryFormatter.format_value(round(premium.target_normative_second))}</blockquote>
6464
6565
💼 <b>Дополнительно</b>
6666
<blockquote>Дисциплина: {SalaryFormatter.format_percentage(premium.discipline_premium)}
@@ -118,8 +118,8 @@ async def user_kpi_calculator_cb(
118118
)
119119
target_calculation = KPICalculator.calculate_target_needed(
120120
premium.target,
121-
premium.target_goal_first,
122-
premium.target_goal_second,
121+
premium.target_normative_first,
122+
premium.target_normative_second,
123123
premium.target_type,
124124
)
125125

@@ -147,8 +147,8 @@ async def user_kpi_calculator_cb(
147147
{gok_calculation}</blockquote>
148148
149149
🎯 <b>Цель</b>
150-
<blockquote>Факт: {SalaryFormatter.format_value(premium.target)} ({SalaryFormatter.format_percentage(round((premium.target_goal_first / premium.target * 100) if premium.target_type and "AHT" in premium.target_type and premium.target and premium.target > 0 and premium.target_goal_first else (premium.target / premium.target_goal_first * 100) if premium.target_goal_first and premium.target_goal_first > 0 else 0))} / {SalaryFormatter.format_percentage(round((premium.target_goal_second / premium.target * 100) if premium.target_type and "AHT" in premium.target_type and premium.target and premium.target > 0 and premium.target_goal_second else (premium.target / premium.target_goal_second * 100) if premium.target_goal_second and premium.target_goal_second > 0 else 0))})
151-
План: {SalaryFormatter.format_value(round(premium.target_goal_first))} / {SalaryFormatter.format_value(round(premium.target_goal_second))}
150+
<blockquote>Факт: {SalaryFormatter.format_value(premium.target)} ({SalaryFormatter.format_percentage(round((premium.target_normative_first / premium.target * 100) if premium.target_type and "AHT" in premium.target_type and premium.target and premium.target > 0 and premium.target_normative_first else (premium.target / premium.target_normative_first * 100) if premium.target_normative_first and premium.target_normative_first > 0 else 0))} / {SalaryFormatter.format_percentage(round((premium.target_normative_second / premium.target * 100) if premium.target_type and "AHT" in premium.target_type and premium.target and premium.target > 0 and premium.target_normative_second else (premium.target / premium.target_normative_second * 100) if premium.target_normative_second and premium.target_normative_second > 0 else 0))})
151+
План: {SalaryFormatter.format_value(round(premium.target_normative_first))} / {SalaryFormatter.format_value(round(premium.target_normative_second))}
152152
153153
Требуется минимум 100 {"чатов" if user.division == "НЦК" else "звонков"} для получения премии за цель
154154

tgbot/services/salary/kpi_calculator.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,13 @@ def calculate_gok_needed(
209209
@staticmethod
210210
def calculate_target_needed(
211211
current_target,
212-
target_goal_first,
213-
target_goal_second,
212+
target_normative_first,
213+
target_normative_second,
214214
target_type: Optional[str] = None,
215215
is_head: bool = False,
216216
):
217217
"""Расчет цели, необходимой для достижения уровней премии"""
218-
if target_goal_first is None and target_goal_second is None:
218+
if target_normative_first is None and target_normative_second is None:
219219
return "—"
220220

221221
current_target = current_target or 0
@@ -228,11 +228,11 @@ def calculate_target_needed(
228228

229229
# Для руководителей используем упрощенную систему премий
230230
if is_head:
231-
# Определяем основной норматив (приоритет - target_goal_second, если есть)
231+
# Определяем основной норматив (приоритет - target_normative_second, если есть)
232232
normative = (
233-
target_goal_second
234-
if target_goal_second and target_goal_second > 0
235-
else target_goal_first
233+
target_normative_second
234+
if target_normative_second and target_normative_second > 0
235+
else target_normative_first
236236
)
237237

238238
if not normative:
@@ -291,9 +291,9 @@ def calculate_target_needed(
291291
return "\n".join(results)
292292

293293
# Для специалистов
294-
if target_goal_second and target_goal_second > 0:
294+
if target_normative_second and target_normative_second > 0:
295295
# Когда есть вторая цель, используем ее как основной план
296-
normative = target_goal_second
296+
normative = target_normative_second
297297

298298
if is_aht_target:
299299
# Для AHT, чем ниже, тем лучше — процент рассчитывается как (план / текущий * 100)
@@ -346,9 +346,9 @@ def calculate_target_needed(
346346
else:
347347
results.append("0%: ✅ (&lt; 99,99% - менее плана 1)")
348348

349-
elif target_goal_first and target_goal_first > 0:
349+
elif target_normative_first and target_normative_first > 0:
350350
# Когда есть только первая цель, используем ее как план
351-
normative = target_goal_first
351+
normative = target_normative_first
352352

353353
if is_aht_target:
354354
target_rate = (

0 commit comments

Comments
 (0)