Обновлены модели и функции для поддержки групповых продаж. Внесены изменения в API для передачи идентификаторов групповых продаж. Обновлены SQL-скрипты и модели для учета нового поля group_sale_id. Изменены данные для создания продажи, включая категорию и стоимость.

This commit is contained in:
Redsandyg
2025-06-18 11:31:32 +03:00
parent bf6a6a8987
commit 9157570e58
6 changed files with 15 additions and 6 deletions

View File

@@ -198,7 +198,9 @@ def fill_db():
all_categories = session.query(SaleCategory).filter_by(company_id=company.id).all()
for ref in refs:
sale_count = random.randint(20, int(20 * 1.25)) # от 20 до 25
for _ in range(sale_count):
group_size = 5
group_sale_ids = [str(uuid4()) for _ in range((sale_count // group_size) + 1)]
for idx in range(sale_count):
cost = round(random.uniform(100, 1000), 2)
sale_category = random.choice(all_categories)
crediting = round(cost * (sale_category.perc / 100.0), 2)
@@ -208,11 +210,13 @@ def fill_db():
time_diff = end_dttm - start_dttm
random_seconds = random.uniform(0, time_diff.total_seconds())
sale_dttm = start_dttm + timedelta(seconds=random_seconds)
group_sale_id = group_sale_ids[idx // group_size]
sale = Sale(
cost=cost,
crediting=crediting,
ref=ref.id,
sale_id=str(uuid4()),
group_sale_id=group_sale_id,
company_id=company.id,
category=sale_category.id,
sale_dttm=sale_dttm,