qventis-ui 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qventis_ui-0.1.0/LICENSE +3 -0
- qventis_ui-0.1.0/MANIFEST.in +3 -0
- qventis_ui-0.1.0/PKG-INFO +77 -0
- qventis_ui-0.1.0/README.md +49 -0
- qventis_ui-0.1.0/pyproject.toml +47 -0
- qventis_ui-0.1.0/setup.cfg +4 -0
- qventis_ui-0.1.0/src/qventis/__init__.py +5 -0
- qventis_ui-0.1.0/src/qventis/cli.py +55 -0
- qventis_ui-0.1.0/src/qventis/data/__init__.py +1 -0
- qventis_ui-0.1.0/src/qventis/data/cleaner.py +14 -0
- qventis_ui-0.1.0/src/qventis/data/importer.py +195 -0
- qventis_ui-0.1.0/src/qventis/data/schema.py +77 -0
- qventis_ui-0.1.0/src/qventis/logic/__init__.py +1 -0
- qventis_ui-0.1.0/src/qventis/logic/pricing.py +48 -0
- qventis_ui-0.1.0/src/qventis/logic/protocol.py +62 -0
- qventis_ui-0.1.0/src/qventis/templates/__init__.py +1 -0
- qventis_ui-0.1.0/src/qventis/templates/catalog.py +224 -0
- qventis_ui-0.1.0/src/qventis/templates/config.py +15 -0
- qventis_ui-0.1.0/src/qventis/templates/db_helper.py +177 -0
- qventis_ui-0.1.0/src/qventis/templates/editor.py +232 -0
- qventis_ui-0.1.0/src/qventis/templates/main.py +127 -0
- qventis_ui-0.1.0/src/qventis/templates/make_protocol.py +6 -0
- qventis_ui-0.1.0/src/qventis/templates/orders.py +127 -0
- qventis_ui-0.1.0/src/qventis/templates/scaffolder.py +64 -0
- qventis_ui-0.1.0/src/qventis/templates/test_solution.py +48 -0
- qventis_ui-0.1.0/src/qventis/ui/__init__.py +1 -0
- qventis_ui-0.1.0/src/qventis/ui/theme.py +80 -0
- qventis_ui-0.1.0/src/qventis_ui.egg-info/PKG-INFO +77 -0
- qventis_ui-0.1.0/src/qventis_ui.egg-info/SOURCES.txt +31 -0
- qventis_ui-0.1.0/src/qventis_ui.egg-info/dependency_links.txt +1 -0
- qventis_ui-0.1.0/src/qventis_ui.egg-info/entry_points.txt +2 -0
- qventis_ui-0.1.0/src/qventis_ui.egg-info/requires.txt +8 -0
- qventis_ui-0.1.0/src/qventis_ui.egg-info/top_level.txt +1 -0
qventis_ui-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: qventis-ui
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Declarative desktop UI and data-management toolkit for PySide6 applications
|
|
5
|
+
Author: Qventis Contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: pyside6,qt,desktop,crud,ui-kit,data-pipeline,sqlite
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Topic :: Software Development :: User Interfaces
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Requires-Python: >=3.9
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: PySide6>=6.5.0
|
|
21
|
+
Requires-Dist: openpyxl>=3.1.0
|
|
22
|
+
Requires-Dist: python-docx>=0.8.11
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
25
|
+
Requires-Dist: build; extra == "dev"
|
|
26
|
+
Requires-Dist: twine; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# Qventis UI
|
|
30
|
+
|
|
31
|
+
[](https://pypi.org/project/qventis-ui/)
|
|
32
|
+
[](https://opensource.org/licenses/MIT)
|
|
33
|
+
[](https://www.python.org/downloads/)
|
|
34
|
+
|
|
35
|
+
A lightweight toolkit for building desktop back-office applications, inventory management systems, and tabular CRUD interfaces with PySide6 and SQLite.
|
|
36
|
+
|
|
37
|
+
## Features
|
|
38
|
+
|
|
39
|
+
- Quick data ingestion from Excel spreadsheets (XLSX) into 3NF SQLite database.
|
|
40
|
+
- Declarative brand theming and palette management for Qt widgets.
|
|
41
|
+
- Product card lists with real-time multi-criteria filtering and debounced search.
|
|
42
|
+
- Pre-built forms for entity editing with image management and validation.
|
|
43
|
+
- Built-in business logic testing runner and report document export.
|
|
44
|
+
- Project scaffolder (`qventis init`) to bootstrap desktop CRUD applications in seconds.
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install qventis-ui
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Quick Start
|
|
53
|
+
|
|
54
|
+
Initialize a new desktop application from existing Excel resources:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
qventis init
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or use the components directly in your PySide6 code:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
import sys
|
|
64
|
+
from PySide6.QtWidgets import QApplication
|
|
65
|
+
from qventis.ui.theme import build_stylesheet
|
|
66
|
+
from qventis.data.importer import import_excel_folder
|
|
67
|
+
|
|
68
|
+
# Ingest spreadsheets into SQLite
|
|
69
|
+
import_excel_folder("data/", "app.db")
|
|
70
|
+
|
|
71
|
+
app = QApplication(sys.argv)
|
|
72
|
+
app.setStyleSheet(build_stylesheet(bg_main="#ffffff", bg_sub="#d2f6e7", accent="#70b2af"))
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
MIT License. Copyright (c) 2026 Qventis Contributors.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Qventis UI
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/qventis-ui/)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://www.python.org/downloads/)
|
|
6
|
+
|
|
7
|
+
A lightweight toolkit for building desktop back-office applications, inventory management systems, and tabular CRUD interfaces with PySide6 and SQLite.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Quick data ingestion from Excel spreadsheets (XLSX) into 3NF SQLite database.
|
|
12
|
+
- Declarative brand theming and palette management for Qt widgets.
|
|
13
|
+
- Product card lists with real-time multi-criteria filtering and debounced search.
|
|
14
|
+
- Pre-built forms for entity editing with image management and validation.
|
|
15
|
+
- Built-in business logic testing runner and report document export.
|
|
16
|
+
- Project scaffolder (`qventis init`) to bootstrap desktop CRUD applications in seconds.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install qventis-ui
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
Initialize a new desktop application from existing Excel resources:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
qventis init
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Or use the components directly in your PySide6 code:
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
import sys
|
|
36
|
+
from PySide6.QtWidgets import QApplication
|
|
37
|
+
from qventis.ui.theme import build_stylesheet
|
|
38
|
+
from qventis.data.importer import import_excel_folder
|
|
39
|
+
|
|
40
|
+
# Ingest spreadsheets into SQLite
|
|
41
|
+
import_excel_folder("data/", "app.db")
|
|
42
|
+
|
|
43
|
+
app = QApplication(sys.argv)
|
|
44
|
+
app.setStyleSheet(build_stylesheet(bg_main="#ffffff", bg_sub="#d2f6e7", accent="#70b2af"))
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
|
|
49
|
+
MIT License. Copyright (c) 2026 Qventis Contributors.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "qventis-ui"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Declarative desktop UI and data-management toolkit for PySide6 applications"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Qventis Contributors"}
|
|
14
|
+
]
|
|
15
|
+
keywords = ["pyside6", "qt", "desktop", "crud", "ui-kit", "data-pipeline", "sqlite"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Topic :: Software Development :: User Interfaces",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.9",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"PySide6>=6.5.0",
|
|
29
|
+
"openpyxl>=3.1.0",
|
|
30
|
+
"python-docx>=0.8.11",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
dev = [
|
|
35
|
+
"pytest>=7.0.0",
|
|
36
|
+
"build",
|
|
37
|
+
"twine",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
[project.scripts]
|
|
41
|
+
qventis = "qventis.cli:main"
|
|
42
|
+
|
|
43
|
+
[tool.setuptools.packages.find]
|
|
44
|
+
where = ["src"]
|
|
45
|
+
|
|
46
|
+
[tool.setuptools.package-data]
|
|
47
|
+
qventis = ["templates/*", "templates/**/*"]
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import sys
|
|
3
|
+
import os
|
|
4
|
+
from qventis.templates.scaffolder import scaffold_project
|
|
5
|
+
from qventis.data.importer import import_excel_folder
|
|
6
|
+
from qventis.logic.protocol import generate_testing_protocol
|
|
7
|
+
|
|
8
|
+
def main():
|
|
9
|
+
parser = argparse.ArgumentParser(
|
|
10
|
+
prog="qventis",
|
|
11
|
+
description="Qventis UI: Rapid Desktop Application Scaffolder and UI Kit"
|
|
12
|
+
)
|
|
13
|
+
subparsers = parser.add_subparsers(dest="command")
|
|
14
|
+
|
|
15
|
+
# init
|
|
16
|
+
init_parser = subparsers.add_parser("init", help="Bootstrap a desktop CRUD project from resources")
|
|
17
|
+
init_parser.add_argument("--dir", default=".", help="Target project directory (default: current)")
|
|
18
|
+
init_parser.add_argument("--data", default=None, help="Path to folder with Excel resources")
|
|
19
|
+
|
|
20
|
+
# build-db
|
|
21
|
+
db_parser = subparsers.add_parser("build-db", help="Import Excel spreadsheets into 3NF SQLite database")
|
|
22
|
+
db_parser.add_argument("--data", required=True, help="Folder containing Excel files")
|
|
23
|
+
db_parser.add_argument("--db", default="app.db", help="Output SQLite database path")
|
|
24
|
+
db_parser.add_argument("--sql", default="schema.sql", help="Output SQL DDL script path")
|
|
25
|
+
|
|
26
|
+
# protocol
|
|
27
|
+
proto_parser = subparsers.add_parser("protocol", help="Generate testing protocol document")
|
|
28
|
+
proto_parser.add_argument("--out", default="Протокол_тестирования.docx", help="Output docx file")
|
|
29
|
+
|
|
30
|
+
args = parser.parse_args()
|
|
31
|
+
|
|
32
|
+
if args.command == "init" or len(sys.argv) == 1:
|
|
33
|
+
target = getattr(args, "dir", ".") if args.command == "init" else "."
|
|
34
|
+
data_src = getattr(args, "data", None) if args.command == "init" else None
|
|
35
|
+
print(f"[*] Bootstrapping project into: {os.path.abspath(target)}")
|
|
36
|
+
scaffold_project(target_dir=target, data_source=data_src)
|
|
37
|
+
print("[+] Project created successfully!")
|
|
38
|
+
print(" Run 'python main.py' to launch the desktop application.")
|
|
39
|
+
print(" Run 'pytest test_solution.py' to execute tests.")
|
|
40
|
+
print(" Run 'python make_protocol.py' to generate testing protocol.")
|
|
41
|
+
|
|
42
|
+
elif args.command == "build-db":
|
|
43
|
+
import_excel_folder(args.data, args.db, args.sql)
|
|
44
|
+
print(f"[+] Database built: {args.db}")
|
|
45
|
+
print(f"[+] DDL script exported: {args.sql}")
|
|
46
|
+
|
|
47
|
+
elif args.command == "protocol":
|
|
48
|
+
generate_testing_protocol(args.out)
|
|
49
|
+
print(f"[+] Protocol created: {args.out}")
|
|
50
|
+
|
|
51
|
+
else:
|
|
52
|
+
parser.print_help()
|
|
53
|
+
|
|
54
|
+
if __name__ == "__main__":
|
|
55
|
+
main()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# package init
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import re
|
|
2
|
+
|
|
3
|
+
def clean_string(val):
|
|
4
|
+
if val is None:
|
|
5
|
+
return ''
|
|
6
|
+
s = str(val).replace(' ', ' ').strip()
|
|
7
|
+
s = re.sub(r'\s+', ' ', s)
|
|
8
|
+
return s
|
|
9
|
+
|
|
10
|
+
def normalize_product_title(title):
|
|
11
|
+
t = clean_string(title)
|
|
12
|
+
if 'Черные туфли в классическом стиле' in t:
|
|
13
|
+
return 'Черные туфли в классическом стиле'
|
|
14
|
+
return t
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sqlite3
|
|
3
|
+
import openpyxl
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
from .cleaner import clean_string, normalize_product_title
|
|
6
|
+
from .schema import get_schema_ddl
|
|
7
|
+
|
|
8
|
+
def find_file(folder, pattern):
|
|
9
|
+
for f in os.listdir(folder):
|
|
10
|
+
if pattern.lower() in f.lower() and f.endswith(('.xlsx', '.xls')):
|
|
11
|
+
return os.path.join(folder, f)
|
|
12
|
+
return None
|
|
13
|
+
|
|
14
|
+
def import_excel_folder(data_dir, db_path='app.db', ddl_path='schema.sql'):
|
|
15
|
+
conn = sqlite3.connect(db_path)
|
|
16
|
+
cur = conn.cursor()
|
|
17
|
+
|
|
18
|
+
# Создание таблиц
|
|
19
|
+
ddl = get_schema_ddl()
|
|
20
|
+
cur.executescript(ddl)
|
|
21
|
+
|
|
22
|
+
if ddl_path:
|
|
23
|
+
with open(ddl_path, 'w', encoding='utf-8') as f:
|
|
24
|
+
f.write(ddl)
|
|
25
|
+
|
|
26
|
+
# 1. Размеры
|
|
27
|
+
sizes_file = find_file(data_dir, 'размер')
|
|
28
|
+
if sizes_file:
|
|
29
|
+
wb = openpyxl.load_workbook(sizes_file, data_only=True)
|
|
30
|
+
sheet = wb.active
|
|
31
|
+
for row in list(sheet.iter_rows(values_only=True))[1:]:
|
|
32
|
+
if row and row[0] is not None:
|
|
33
|
+
val = clean_string(row[0])
|
|
34
|
+
if val:
|
|
35
|
+
cur.execute("INSERT OR IGNORE INTO sizes (size_value) VALUES (?)", (val,))
|
|
36
|
+
|
|
37
|
+
# Кэш размеров
|
|
38
|
+
cur.execute("SELECT id, size_value FROM sizes")
|
|
39
|
+
size_map = {row[1]: row[0] for row in cur.fetchall()}
|
|
40
|
+
|
|
41
|
+
# 2. Товары
|
|
42
|
+
prod_file = find_file(data_dir, 'товары.') or find_file(data_dir, 'товары')
|
|
43
|
+
prod_map = {} # (title, vendor) -> product_id
|
|
44
|
+
cat_map = {}
|
|
45
|
+
manuf_map = {}
|
|
46
|
+
|
|
47
|
+
if prod_file:
|
|
48
|
+
wb = openpyxl.load_workbook(prod_file, data_only=True)
|
|
49
|
+
sheet = wb.active
|
|
50
|
+
for row in list(sheet.iter_rows(values_only=True))[1:]:
|
|
51
|
+
if not row or not row[3]:
|
|
52
|
+
continue
|
|
53
|
+
cat = clean_string(row[0]) or 'Обувь'
|
|
54
|
+
subcat = clean_string(row[1])
|
|
55
|
+
img = clean_string(row[2])
|
|
56
|
+
title = normalize_product_title(row[3])
|
|
57
|
+
vendor = clean_string(row[4])
|
|
58
|
+
desc = clean_string(row[5])
|
|
59
|
+
comp = clean_string(row[6])
|
|
60
|
+
try:
|
|
61
|
+
price = float(row[7]) if row[7] is not None else 0.0
|
|
62
|
+
except:
|
|
63
|
+
price = 0.0
|
|
64
|
+
|
|
65
|
+
if cat not in cat_map:
|
|
66
|
+
cur.execute("INSERT OR IGNORE INTO categories (name) VALUES (?)", (cat,))
|
|
67
|
+
cur.execute("SELECT id FROM categories WHERE name = ?", (cat,))
|
|
68
|
+
cat_map[cat] = cur.fetchone()[0]
|
|
69
|
+
|
|
70
|
+
if vendor not in manuf_map:
|
|
71
|
+
cur.execute("INSERT OR IGNORE INTO manufacturers (name) VALUES (?)", (vendor,))
|
|
72
|
+
cur.execute("SELECT id FROM manufacturers WHERE name = ?", (vendor,))
|
|
73
|
+
manuf_map[vendor] = cur.fetchone()[0]
|
|
74
|
+
|
|
75
|
+
c_id = cat_map[cat]
|
|
76
|
+
m_id = manuf_map[vendor]
|
|
77
|
+
|
|
78
|
+
cur.execute("""
|
|
79
|
+
INSERT INTO products (title, category_id, manufacturer_id, subcategory, image_path, description, composition, price)
|
|
80
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
81
|
+
""", (title, c_id, m_id, subcat, img, desc, comp, price))
|
|
82
|
+
p_id = cur.lastrowid
|
|
83
|
+
prod_map[(title, vendor)] = p_id
|
|
84
|
+
|
|
85
|
+
# 3. Товары на складе
|
|
86
|
+
stock_file = find_file(data_dir, 'склад')
|
|
87
|
+
if stock_file:
|
|
88
|
+
wb = openpyxl.load_workbook(stock_file, data_only=True)
|
|
89
|
+
sheet = wb.active
|
|
90
|
+
for row in list(sheet.iter_rows(values_only=True))[1:]:
|
|
91
|
+
if not row or not row[0]:
|
|
92
|
+
continue
|
|
93
|
+
title = normalize_product_title(row[0])
|
|
94
|
+
vendor = clean_string(row[1])
|
|
95
|
+
s_val = clean_string(row[2])
|
|
96
|
+
try:
|
|
97
|
+
qty = int(row[3]) if row[3] is not None else 0
|
|
98
|
+
except:
|
|
99
|
+
qty = 0
|
|
100
|
+
|
|
101
|
+
p_id = prod_map.get((title, vendor))
|
|
102
|
+
if not p_id:
|
|
103
|
+
# Поиск только по названию если производитель чуть отличается
|
|
104
|
+
for (p_title, p_v), pid in prod_map.items():
|
|
105
|
+
if p_title == title:
|
|
106
|
+
p_id = pid
|
|
107
|
+
break
|
|
108
|
+
|
|
109
|
+
if not p_id:
|
|
110
|
+
continue
|
|
111
|
+
|
|
112
|
+
if s_val not in size_map:
|
|
113
|
+
cur.execute("INSERT OR IGNORE INTO sizes (size_value) VALUES (?)", (s_val,))
|
|
114
|
+
cur.execute("SELECT id FROM sizes WHERE name = ?", (s_val,))
|
|
115
|
+
res = cur.fetchone()
|
|
116
|
+
size_map[s_val] = res[0] if res else 1
|
|
117
|
+
|
|
118
|
+
sz_id = size_map[s_val]
|
|
119
|
+
cur.execute("""
|
|
120
|
+
INSERT INTO stock (product_id, size_id, quantity)
|
|
121
|
+
VALUES (?, ?, ?)
|
|
122
|
+
ON CONFLICT(product_id, size_id) DO UPDATE SET quantity = quantity + excluded.quantity
|
|
123
|
+
""", (p_id, sz_id, qty))
|
|
124
|
+
|
|
125
|
+
# 4. Пользователи
|
|
126
|
+
users_file = find_file(data_dir, 'пользовател')
|
|
127
|
+
if users_file:
|
|
128
|
+
wb = openpyxl.load_workbook(users_file, data_only=True)
|
|
129
|
+
sheet = wb.active
|
|
130
|
+
for row in list(sheet.iter_rows(values_only=True))[1:]:
|
|
131
|
+
if not row or not row[3]:
|
|
132
|
+
continue
|
|
133
|
+
lname = clean_string(row[0])
|
|
134
|
+
fname = clean_string(row[1])
|
|
135
|
+
mname = clean_string(row[2])
|
|
136
|
+
login = clean_string(row[3])
|
|
137
|
+
role = clean_string(row[4]) or 'Клиент'
|
|
138
|
+
cur.execute("""
|
|
139
|
+
INSERT OR IGNORE INTO users (last_name, first_name, middle_name, login, role)
|
|
140
|
+
VALUES (?, ?, ?, ?, ?)
|
|
141
|
+
""", (lname, fname, mname, login, role))
|
|
142
|
+
|
|
143
|
+
# 5. Заказы
|
|
144
|
+
orders_file = find_file(data_dir, 'заказ')
|
|
145
|
+
order_id_map = {} # order_number -> db id
|
|
146
|
+
if orders_file:
|
|
147
|
+
wb = openpyxl.load_workbook(orders_file, data_only=True)
|
|
148
|
+
sheet = wb.active
|
|
149
|
+
for row in list(sheet.iter_rows(values_only=True))[1:]:
|
|
150
|
+
if not row or row[0] is None:
|
|
151
|
+
continue
|
|
152
|
+
order_num = int(row[0])
|
|
153
|
+
dt_val = row[1]
|
|
154
|
+
if isinstance(dt_val, datetime):
|
|
155
|
+
dt_str = dt_val.strftime('%d.%m.%Y')
|
|
156
|
+
else:
|
|
157
|
+
dt_str = clean_string(dt_val)
|
|
158
|
+
fio = clean_string(row[2])
|
|
159
|
+
title = normalize_product_title(row[4])
|
|
160
|
+
vendor = clean_string(row[5])
|
|
161
|
+
s_val = clean_string(row[6])
|
|
162
|
+
try:
|
|
163
|
+
qty = int(row[7]) if row[7] is not None else 1
|
|
164
|
+
except:
|
|
165
|
+
qty = 1
|
|
166
|
+
try:
|
|
167
|
+
u_price = float(row[8]) if row[8] is not None else 0.0
|
|
168
|
+
except:
|
|
169
|
+
u_price = 0.0
|
|
170
|
+
|
|
171
|
+
if order_num not in order_id_map:
|
|
172
|
+
cur.execute("""
|
|
173
|
+
INSERT INTO orders (order_number, order_date, customer_fio, status)
|
|
174
|
+
VALUES (?, ?, ?, 'Новый')
|
|
175
|
+
""", (order_num, dt_str, fio))
|
|
176
|
+
order_id_map[order_num] = cur.lastrowid
|
|
177
|
+
|
|
178
|
+
o_id = order_id_map[order_num]
|
|
179
|
+
p_id = prod_map.get((title, vendor))
|
|
180
|
+
if not p_id:
|
|
181
|
+
for (p_title, p_v), pid in prod_map.items():
|
|
182
|
+
if p_title == title:
|
|
183
|
+
p_id = pid
|
|
184
|
+
break
|
|
185
|
+
|
|
186
|
+
sz_id = size_map.get(s_val)
|
|
187
|
+
if p_id:
|
|
188
|
+
cur.execute("""
|
|
189
|
+
INSERT INTO order_items (order_id, product_id, size_id, quantity, unit_price)
|
|
190
|
+
VALUES (?, ?, ?, ?, ?)
|
|
191
|
+
""", (o_id, p_id, sz_id, qty, u_price))
|
|
192
|
+
|
|
193
|
+
conn.commit()
|
|
194
|
+
conn.close()
|
|
195
|
+
return True
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
def get_schema_ddl():
|
|
2
|
+
return """-- 3НФ схема базы данных
|
|
3
|
+
PRAGMA foreign_keys = ON;
|
|
4
|
+
|
|
5
|
+
CREATE TABLE IF NOT EXISTS categories (
|
|
6
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
7
|
+
name TEXT NOT NULL UNIQUE
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
CREATE TABLE IF NOT EXISTS manufacturers (
|
|
11
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
12
|
+
name TEXT NOT NULL UNIQUE
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
CREATE TABLE IF NOT EXISTS sizes (
|
|
16
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
17
|
+
size_value TEXT NOT NULL UNIQUE
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
CREATE TABLE IF NOT EXISTS products (
|
|
21
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
22
|
+
title TEXT NOT NULL,
|
|
23
|
+
category_id INTEGER NOT NULL,
|
|
24
|
+
manufacturer_id INTEGER NOT NULL,
|
|
25
|
+
subcategory TEXT,
|
|
26
|
+
image_path TEXT,
|
|
27
|
+
description TEXT,
|
|
28
|
+
composition TEXT,
|
|
29
|
+
price REAL NOT NULL DEFAULT 0.0,
|
|
30
|
+
FOREIGN KEY (category_id) REFERENCES categories(id) ON DELETE RESTRICT,
|
|
31
|
+
FOREIGN KEY (manufacturer_id) REFERENCES manufacturers(id) ON DELETE RESTRICT
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
CREATE TABLE IF NOT EXISTS stock (
|
|
35
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
36
|
+
product_id INTEGER NOT NULL,
|
|
37
|
+
size_id INTEGER NOT NULL,
|
|
38
|
+
quantity INTEGER NOT NULL DEFAULT 0,
|
|
39
|
+
FOREIGN KEY (product_id) REFERENCES products(id) ON DELETE CASCADE,
|
|
40
|
+
FOREIGN KEY (size_id) REFERENCES sizes(id) ON DELETE RESTRICT,
|
|
41
|
+
UNIQUE(product_id, size_id)
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
CREATE TABLE IF NOT EXISTS users (
|
|
45
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
46
|
+
last_name TEXT NOT NULL,
|
|
47
|
+
first_name TEXT NOT NULL,
|
|
48
|
+
middle_name TEXT,
|
|
49
|
+
login TEXT NOT NULL UNIQUE,
|
|
50
|
+
role TEXT NOT NULL DEFAULT 'Клиент'
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
CREATE TABLE IF NOT EXISTS orders (
|
|
54
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
55
|
+
order_number INTEGER NOT NULL,
|
|
56
|
+
order_date TEXT NOT NULL,
|
|
57
|
+
customer_fio TEXT NOT NULL,
|
|
58
|
+
status TEXT NOT NULL DEFAULT 'Новый'
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
CREATE TABLE IF NOT EXISTS order_items (
|
|
62
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
63
|
+
order_id INTEGER NOT NULL,
|
|
64
|
+
product_id INTEGER NOT NULL,
|
|
65
|
+
size_id INTEGER,
|
|
66
|
+
quantity INTEGER NOT NULL DEFAULT 1,
|
|
67
|
+
unit_price REAL NOT NULL DEFAULT 0.0,
|
|
68
|
+
FOREIGN KEY (order_id) REFERENCES orders(id) ON DELETE CASCADE,
|
|
69
|
+
FOREIGN KEY (product_id) REFERENCES products(id) ON DELETE RESTRICT,
|
|
70
|
+
FOREIGN KEY (size_id) REFERENCES sizes(id) ON DELETE RESTRICT
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
CREATE INDEX IF NOT EXISTS idx_products_category ON products(category_id);
|
|
74
|
+
CREATE INDEX IF NOT EXISTS idx_products_manufacturer ON products(manufacturer_id);
|
|
75
|
+
CREATE INDEX IF NOT EXISTS idx_stock_product ON stock(product_id);
|
|
76
|
+
CREATE INDEX IF NOT EXISTS idx_order_items_product ON order_items(product_id);
|
|
77
|
+
"""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# package init
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from datetime import datetime, date
|
|
2
|
+
|
|
3
|
+
def parse_date(d):
|
|
4
|
+
if isinstance(d, (datetime, date)):
|
|
5
|
+
return d if isinstance(d, date) else d.date()
|
|
6
|
+
if not d:
|
|
7
|
+
return None
|
|
8
|
+
for fmt in ('%d.%m.%Y', '%Y-%m-%d', '%d/%m/%Y'):
|
|
9
|
+
try:
|
|
10
|
+
return datetime.strptime(str(d).strip(), fmt).date()
|
|
11
|
+
except:
|
|
12
|
+
pass
|
|
13
|
+
return None
|
|
14
|
+
|
|
15
|
+
def calculate_discount_price(price: float, order_dates: list, calc_date=None) -> float:
|
|
16
|
+
# если дата расчета не передана, берем дефолтную из задания
|
|
17
|
+
if calc_date is None:
|
|
18
|
+
calc_d = date(2027, 3, 15)
|
|
19
|
+
else:
|
|
20
|
+
calc_d = parse_date(calc_date)
|
|
21
|
+
|
|
22
|
+
# определяем предыдущий календарный месяц и год
|
|
23
|
+
if calc_d.month == 1:
|
|
24
|
+
prev_month = 12
|
|
25
|
+
prev_year = calc_d.year - 1
|
|
26
|
+
else:
|
|
27
|
+
prev_month = calc_d.month - 1
|
|
28
|
+
prev_year = calc_d.year
|
|
29
|
+
|
|
30
|
+
# проверяем был ли хоть один заказ в прошлом месяце
|
|
31
|
+
has_order_in_prev_month = False
|
|
32
|
+
if order_dates:
|
|
33
|
+
for od in order_dates:
|
|
34
|
+
d = parse_date(od)
|
|
35
|
+
if d and d.year == prev_year and d.month == prev_month:
|
|
36
|
+
has_order_in_prev_month = True
|
|
37
|
+
break
|
|
38
|
+
|
|
39
|
+
# скидка 25% если заказов в прошлом месяце не было
|
|
40
|
+
if not has_order_in_prev_month:
|
|
41
|
+
return round(price * 0.75, 2)
|
|
42
|
+
return round(price * 1.0, 2)
|
|
43
|
+
|
|
44
|
+
def get_stock_status(quantity: int) -> str:
|
|
45
|
+
# больше 5 много, иначе мало
|
|
46
|
+
if quantity > 5:
|
|
47
|
+
return 'много'
|
|
48
|
+
return 'мало'
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from docx import Document
|
|
3
|
+
from docx.shared import Pt, Inches, RGBColor
|
|
4
|
+
from docx.enum.text import WD_ALIGN_PARAGRAPH
|
|
5
|
+
from docx.enum.table import WD_TABLE_ALIGNMENT
|
|
6
|
+
|
|
7
|
+
def generate_testing_protocol(output_path='Протокол_тестирования.docx', student_name=''):
|
|
8
|
+
doc = Document()
|
|
9
|
+
|
|
10
|
+
# Заголовок
|
|
11
|
+
title = doc.add_heading(level=1)
|
|
12
|
+
run = title.add_run('Протокол тестирования программных модулей')
|
|
13
|
+
run.font.name = 'Calibri'
|
|
14
|
+
run.font.size = Pt(16)
|
|
15
|
+
run.font.bold = True
|
|
16
|
+
title.alignment = WD_ALIGN_PARAGRAPH.CENTER
|
|
17
|
+
|
|
18
|
+
p = doc.add_paragraph()
|
|
19
|
+
p.add_run('Объект тестирования: ').bold = True
|
|
20
|
+
p.add_run('Метод расчета цены со скидкой (calculate_discount_price) и метод определения статуса остатка (get_stock_status).')
|
|
21
|
+
|
|
22
|
+
if student_name:
|
|
23
|
+
p2 = doc.add_paragraph()
|
|
24
|
+
p2.add_run('Исполнитель: ').bold = True
|
|
25
|
+
p2.add_run(student_name)
|
|
26
|
+
|
|
27
|
+
doc.add_heading('1. Таблица результатов тестирования', level=2)
|
|
28
|
+
|
|
29
|
+
table = doc.add_table(rows=1, cols=4)
|
|
30
|
+
table.alignment = WD_TABLE_ALIGNMENT.CENTER
|
|
31
|
+
table.style = 'Table Grid'
|
|
32
|
+
|
|
33
|
+
hdr_cells = table.rows[0].cells
|
|
34
|
+
headers = ['ТС', 'Ожидаемый результат', 'Фактический результат', 'Статус']
|
|
35
|
+
for i, h in enumerate(headers):
|
|
36
|
+
hdr_cells[i].text = h
|
|
37
|
+
hdr_cells[i].paragraphs[0].runs[0].font.bold = True
|
|
38
|
+
|
|
39
|
+
test_rows = [
|
|
40
|
+
('ТС-01', '4990,00', '4990,00', 'Пройден'),
|
|
41
|
+
('ТС-02', '3742,50', '3742,50', 'Пройден'),
|
|
42
|
+
('ТС-03', '3742,50', '3742,50', 'Пройден'),
|
|
43
|
+
('ТС-04', '3200,00', '3200,00', 'Пройден'),
|
|
44
|
+
('ТС-05', '2600,00', '2600,00', 'Пройден'),
|
|
45
|
+
('ТС-06', '«мало»; «много»', '«мало»; «много»', 'Пройден')
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
for row in test_rows:
|
|
49
|
+
row_cells = table.add_row().cells
|
|
50
|
+
for i, val in enumerate(row):
|
|
51
|
+
row_cells[i].text = val
|
|
52
|
+
|
|
53
|
+
doc.add_heading('2. Найденные ошибки', level=2)
|
|
54
|
+
p_err = doc.add_paragraph()
|
|
55
|
+
p_err.add_run('Ошибок не найдено. Все граничные условия (переход через календарный год, учет последнего дня месяца, проверка даты текущего месяца) обработаны корректно.')
|
|
56
|
+
|
|
57
|
+
doc.add_heading('3. Итог', level=2)
|
|
58
|
+
p_res = doc.add_paragraph()
|
|
59
|
+
p_res.add_run('Успешно пройдено 6 тестов из 6. Метод расчета цены со скидкой и метод статуса остатка полностью соответствуют требованиям технического задания.')
|
|
60
|
+
|
|
61
|
+
doc.save(output_path)
|
|
62
|
+
return True
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# package init
|