ApiLogicServer 14.2.2__py3-none-any.whl → 14.3.0__py3-none-any.whl
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.
- {ApiLogicServer-14.2.2.dist-info → ApiLogicServer-14.3.0.dist-info}/METADATA +2 -2
- {ApiLogicServer-14.2.2.dist-info → ApiLogicServer-14.3.0.dist-info}/RECORD +73 -54
- api_logic_server_cli/api_logic_server.py +47 -10
- api_logic_server_cli/api_logic_server_info.yaml +3 -3
- api_logic_server_cli/cli.py +9 -3
- api_logic_server_cli/create_from_model/__pycache__/api_logic_server_utils.cpython-312.pyc +0 -0
- api_logic_server_cli/create_from_model/__pycache__/ont_build.cpython-312.pyc +0 -0
- api_logic_server_cli/create_from_model/__pycache__/ont_create.cpython-312.pyc +0 -0
- api_logic_server_cli/create_from_model/api_logic_server_utils.py +4 -0
- api_logic_server_cli/create_from_model/ont_build.py +53 -19
- api_logic_server_cli/create_from_model/ont_create.py +14 -5
- api_logic_server_cli/fragments/declare_logic.py +72 -0
- api_logic_server_cli/{prototypes/manager/system/genai/create_db_models_inserts/logic_discovery_prefix.py → fragments/declare_logic_begin.py} +2 -1
- api_logic_server_cli/fragments/declare_logic_end.py +52 -0
- api_logic_server_cli/genai/client.py +24 -0
- api_logic_server_cli/genai/genai.py +37 -17
- api_logic_server_cli/genai/genai_logic_builder.py +21 -35
- api_logic_server_cli/genai/genai_svcs.py +109 -13
- api_logic_server_cli/genai/genai_utils.py +0 -1
- api_logic_server_cli/model_migrator/model_migrator_start.py +1 -1
- api_logic_server_cli/model_migrator/reposreader.py +9 -1
- api_logic_server_cli/model_migrator/rule_obj.py +24 -6
- api_logic_server_cli/prototypes/base/api/api_discovery/ontimize_api.py +4 -1
- api_logic_server_cli/prototypes/base/config/activate_logicbank.py +8 -4
- api_logic_server_cli/prototypes/base/config/config.py +10 -6
- api_logic_server_cli/prototypes/base/database/bind_dbs.py +2 -1
- api_logic_server_cli/prototypes/base/database/test_data/readme.md +5 -5
- api_logic_server_cli/prototypes/base/logic/declare_logic.py +8 -3
- api_logic_server_cli/prototypes/base/logic/load_verify_rules.py +216 -0
- api_logic_server_cli/prototypes/base/logic/logic_discovery/auto_discovery.py +23 -11
- api_logic_server_cli/prototypes/genai_demo/database/models.py +11 -55
- api_logic_server_cli/prototypes/genai_demo/logic/declare_logic.py +29 -21
- api_logic_server_cli/prototypes/manager/.vscode/launch.json +3 -3
- api_logic_server_cli/prototypes/manager/README.md +25 -10
- api_logic_server_cli/prototypes/manager/system/genai/create_db_models_inserts/create_db_models_imports.py +1 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo.response_example +19 -18
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/.DS_Store +0 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/000_you_are.prompt +1 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/001_logic_training.prompt +314 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/002_create_db_models.prompt +150 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/003_create_db_models.response +134 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/004_iteratio_logic.prompt +131 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/005_create_db_models.response-example +141 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/create_db_models.py +105 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/db.dbml +70 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/readme.md +6 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/response.json +178 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/wg_dev_merge/base_genai_demo_no_logic/logic/declare_logic.py +0 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/wg_dev_merge/dev_demo_no_logic_fixed/logic/declare_logic.py +0 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/wg_dev_merge/wg_demo_no_logic_fixed/genai/examples/genai_demo/wg_dev_merge/base_genai_demo_no_logic/logic/declare_logic.py +0 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/wg_dev_merge/wg_demo_no_logic_fixed/genai/examples/genai_demo/wg_dev_merge/dev_demo_no_logic_fixed/logic/declare_logic.py +0 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/wg_dev_merge/wg_demo_no_logic_fixed/genai/examples/genai_demo/wg_dev_merge/wg_genai_demo_no_logic_fixed_from_CLI/logic/declare_logic.py +0 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/wg_dev_merge/wg_demo_no_logic_fixed/logic/declare_logic.py +0 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/wg_dev_merge/wg_demo_no_logic_fixed/system/genai/examples/genai_demo/wg_dev_merge/base_genai_demo_no_logic/logic/declare_logic.py +0 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/wg_dev_merge/wg_demo_no_logic_fixed/system/genai/examples/genai_demo/wg_dev_merge/dev_demo_no_logic_fixed/logic/declare_logic.py +0 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/wg_dev_merge/wg_demo_no_logic_fixed/system/genai/examples/genai_demo/wg_dev_merge/wg_genai_demo_no_logic_fixed_from_CLI/logic/declare_logic.py +0 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/time_tracking_billing/002_create_db_models.prompt +194 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/time_tracking_billing/003_create_db_models.response +298 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/time_tracking_billing/db.sqlite +0 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/time_tracking_billing/readme.md +8 -0
- api_logic_server_cli/prototypes/manager/system/genai/learning_requests/logic_bank_api.prompt +14 -10
- api_logic_server_cli/prototypes/manager/system/genai/prompt_inserts/iteration.prompt +2 -1
- api_logic_server_cli/prototypes/nw_no_cust/venv_setup/system_note.txt +1 -1
- api_logic_server_cli/prototypes/ont_app/templates/home_tree_template.html +9 -0
- api_logic_server_cli/prototypes/ont_app/templates/tree_routing.jinja +32 -0
- api_logic_server_cli/sqlacodegen_wrapper/sqlacodegen/sqlacodegen/__pycache__/codegen.cpython-312.pyc +0 -0
- api_logic_server_cli/sqlacodegen_wrapper/sqlacodegen/sqlacodegen/codegen.py +2 -1
- api_logic_server_cli/tools/mini_skel/logic/load_verify_rules.py +1 -1
- api_logic_server_cli/tools/mini_skel/run.py +1 -0
- api_logic_server_cli/model_migrator/system/custom_endpoint.py +0 -545
- api_logic_server_cli/prototypes/base/database/test_data/z_test_data_rows.py +0 -98
- {ApiLogicServer-14.2.2.dist-info → ApiLogicServer-14.3.0.dist-info}/LICENSE +0 -0
- {ApiLogicServer-14.2.2.dist-info → ApiLogicServer-14.3.0.dist-info}/WHEEL +0 -0
- {ApiLogicServer-14.2.2.dist-info → ApiLogicServer-14.3.0.dist-info}/entry_points.txt +0 -0
- {ApiLogicServer-14.2.2.dist-info → ApiLogicServer-14.3.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
Update the prior response - be sure not to lose classes and test data already created.
|
|
2
|
+
|
|
3
|
+
Provide a 10% discount when buying more than 10 carbon neutral products
|
|
4
|
+
|
|
5
|
+
The Item carbon neutral is copied from the Product carbon neutral
|
|
6
|
+
|
|
7
|
+
Hints: use autonum keys (for all tables - including for link/join/junction/intersection tables), allow nulls, foreign keys, no check constraints.
|
|
8
|
+
|
|
9
|
+
Be sure to create classes, never tables.
|
|
10
|
+
|
|
11
|
+
If you create sum, count or formula Logic Bank rules, then you MUST create a corresponding column in the data model.
|
|
12
|
+
|
|
13
|
+
Remember that SQLite DateTime type only accepts Python datetime and date objects as input,
|
|
14
|
+
this means you can not enter string attributes where a date or datetime object is expected.
|
|
15
|
+
|
|
16
|
+
Don't install additional packages.
|
|
17
|
+
Don't use the faker pip package.
|
|
18
|
+
|
|
19
|
+
When creating SQLAlchemy data model classes, follow these guidelines carefully:
|
|
20
|
+
* Use foreign key columns instead of relationship names for the data.
|
|
21
|
+
* Do not specify nullable unless explicitly specified.
|
|
22
|
+
* Do not use unique unless explicitly specified.
|
|
23
|
+
* Do not use Float unless explicitly specified.
|
|
24
|
+
* Generate the classes ONLY.
|
|
25
|
+
* Do NOT generate imports.
|
|
26
|
+
* Do NOT generate connect statements.
|
|
27
|
+
* Do NOT generate engines.
|
|
28
|
+
|
|
29
|
+
Create 4 rows of test data for each table, and follow these guidelines carefully:
|
|
30
|
+
* Create separate objects for each test data row, not in arrays.
|
|
31
|
+
* Be sure to initialize derived attributes for test data rows - including all sums and counts, but do not rely on Logic Bank,
|
|
32
|
+
and do not generate db.execute statements.
|
|
33
|
+
* Do not create arrays of test data.
|
|
34
|
+
* Do not create a function to load test data.
|
|
35
|
+
* Do not print the test data.
|
|
36
|
+
* Use double quotes " for strings.
|
|
37
|
+
* For test data, format dates as date(year, month, day).
|
|
38
|
+
|
|
39
|
+
<responseFormat>
|
|
40
|
+
class Rule(BaseModel):
|
|
41
|
+
name: str
|
|
42
|
+
description: str
|
|
43
|
+
use_case: str # specified use case or requirement name (use 'General' if missing)
|
|
44
|
+
entity: str # the entity being constrained or derived
|
|
45
|
+
code: str # logicbank rule code
|
|
46
|
+
|
|
47
|
+
class Model(BaseModel):
|
|
48
|
+
classname: str
|
|
49
|
+
code: str # sqlalchemy model code
|
|
50
|
+
sqlite_create: str # sqlite create table statement
|
|
51
|
+
description: str
|
|
52
|
+
name: str
|
|
53
|
+
|
|
54
|
+
class TestDataRow(BaseModel):
|
|
55
|
+
test_data_row_variable: str # the Python test data row variable
|
|
56
|
+
code: str # Python code to create a test data row instance
|
|
57
|
+
|
|
58
|
+
class WGResult(BaseModel): # must match system/genai/prompt_inserts/response_format.prompt
|
|
59
|
+
# response: str # result
|
|
60
|
+
models : List[Model] # list of sqlalchemy classes in the response
|
|
61
|
+
rules : List[Rule] # list rule declarations
|
|
62
|
+
test_data: str
|
|
63
|
+
test_data_rows: List[TestDataRow] # list of test data rows
|
|
64
|
+
test_data_sqlite: str # test data as sqlite INSERT statements
|
|
65
|
+
name: str # suggest a short name for the project
|
|
66
|
+
|
|
67
|
+
Format the response as a WGResult.
|
|
68
|
+
|
|
69
|
+
</responseFormat>
|
|
70
|
+
|
|
71
|
+
<responseFormat>
|
|
72
|
+
|
|
73
|
+
class Rule(BaseModel):
|
|
74
|
+
|
|
75
|
+
name: str
|
|
76
|
+
|
|
77
|
+
description: str
|
|
78
|
+
|
|
79
|
+
use_case: str # specified use case or requirement name (use 'General' if missing)
|
|
80
|
+
|
|
81
|
+
entity: str # the entity being constrained or derived
|
|
82
|
+
|
|
83
|
+
code: str # logicbank rule code
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class Model(BaseModel):
|
|
88
|
+
|
|
89
|
+
classname: str
|
|
90
|
+
|
|
91
|
+
code: str # sqlalchemy model code
|
|
92
|
+
|
|
93
|
+
sqlite_create: str # sqlite create table statement
|
|
94
|
+
|
|
95
|
+
description: str
|
|
96
|
+
|
|
97
|
+
name: str
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class TestDataRow(BaseModel):
|
|
102
|
+
|
|
103
|
+
test_data_row_variable: str # the Python test data row variable
|
|
104
|
+
|
|
105
|
+
code: str # Python code to create a test data row instance
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class WGResult(BaseModel): # must match system/genai/prompt_inserts/response_format.prompt
|
|
110
|
+
|
|
111
|
+
# response: str # result
|
|
112
|
+
|
|
113
|
+
models : List[Model] # list of sqlalchemy classes in the response
|
|
114
|
+
|
|
115
|
+
rules : List[Rule] # list rule declarations
|
|
116
|
+
|
|
117
|
+
test_data: str
|
|
118
|
+
|
|
119
|
+
test_data_rows: List[TestDataRow] # list of test data rows
|
|
120
|
+
|
|
121
|
+
test_data_sqlite: str # test data as sqlite INSERT statements
|
|
122
|
+
|
|
123
|
+
name: str # suggest a short name for the project
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
Format the response as a WGResult.
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
</responseFormat>
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
{
|
|
2
|
+
"models": [
|
|
3
|
+
{
|
|
4
|
+
"classname": "Customer",
|
|
5
|
+
"code": "class Customer(Base):\n __tablename__ = 'customer'\n\n id = Column(Integer, primary_key=True, autoincrement=True)\n name = Column(String(8000), unique=True)\n balance = Column(DECIMAL)\n credit_limit = Column(DECIMAL)",
|
|
6
|
+
"description": "Class representing customers with unique names and credit limits.",
|
|
7
|
+
"name": "Customer"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"classname": "Order",
|
|
11
|
+
"code": "class Order(Base):\n __tablename__ = 'order'\n\n id = Column(Integer, primary_key=True, autoincrement=True)\n customer_id = Column(Integer, ForeignKey('customer.id'))\n amount_total = Column(DECIMAL)\n date_shipped = Column(DateTime)\n notes = Column(String(8000))",
|
|
12
|
+
"description": "Class representing orders linked to customers, with notes and shipment date.",
|
|
13
|
+
"name": "Order"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"classname": "Item",
|
|
17
|
+
"code": "class Item(Base):\n __tablename__ = 'item'\n\n id = Column(Integer, primary_key=True, autoincrement=True)\n order_id = Column(Integer, ForeignKey('order.id'))\n product_id = Column(Integer, ForeignKey('product.id'))\n quantity = Column(Integer, nullable=False)\n amount = Column(DECIMAL)\n unit_price = Column(DECIMAL)\n carbon_neutral = Column(Boolean)",
|
|
18
|
+
"description": "Class representing items with quantity, amount, and carbon neutral status.",
|
|
19
|
+
"name": "Item"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"classname": "Product",
|
|
23
|
+
"code": "class Product(Base):\n __tablename__ = 'product'\n\n id = Column(Integer, primary_key=True, autoincrement=True)\n name = Column(String(8000))\n unit_price = Column(DECIMAL)\n carbon_neutral = Column(Boolean)",
|
|
24
|
+
"description": "Class representing products with their unit prices and carbon neutral status.",
|
|
25
|
+
"name": "Product"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"rules": [
|
|
29
|
+
{
|
|
30
|
+
"name": "Customer Balance Sum",
|
|
31
|
+
"description": "Customer's balance is the sum of the Order amount_total where date_shipped is null.",
|
|
32
|
+
"use_case": "Check Credit",
|
|
33
|
+
"entity": "Customer",
|
|
34
|
+
"code": "Rule.sum(derive=Customer.balance, as_sum_of=Order.amount_total, where=lambda row: row.date_shipped is None)"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "Order Amount Total",
|
|
38
|
+
"description": "The Order's amount_total is the sum of the Item amount.",
|
|
39
|
+
"use_case": "Check Credit",
|
|
40
|
+
"entity": "Order",
|
|
41
|
+
"code": "Rule.sum(derive=Order.amount_total, as_sum_of=Item.amount)"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "Item Amount Formula",
|
|
45
|
+
"description": "The Item amount is the quantity * unit_price.",
|
|
46
|
+
"use_case": "Check Credit",
|
|
47
|
+
"entity": "Item",
|
|
48
|
+
"code": "Rule.formula(derive=Item.amount, as_expression=lambda row: row.quantity * row.unit_price if not row.carbon_neutral or row.quantity <= 10 else 0.9 * row.quantity * row.unit_price)"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "Item Unit Price Copy",
|
|
52
|
+
"description": "The Item unit_price is copied from the Product unit_price.",
|
|
53
|
+
"use_case": "Check Credit",
|
|
54
|
+
"entity": "Item",
|
|
55
|
+
"code": "Rule.copy(derive=Item.unit_price, from_parent=Product.unit_price)"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "Customer Credit Constraint",
|
|
59
|
+
"description": "The Customer's balance must be less than the credit limit.",
|
|
60
|
+
"use_case": "Check Credit",
|
|
61
|
+
"entity": "Customer",
|
|
62
|
+
"code": "Rule.constraint(validate=Customer, as_condition=lambda row: row.balance <= row.credit_limit, error_msg='Customer balance ({row.balance}) exceeds credit limit ({row.credit_limit})')"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "Item Carbon Neutral Copy",
|
|
66
|
+
"description": "Copy carbon neutral status from Product to Item.",
|
|
67
|
+
"use_case": "General",
|
|
68
|
+
"entity": "Item",
|
|
69
|
+
"code": "Rule.copy(derive=Item.carbon_neutral, from_parent=Product.carbon_neutral)"
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
"test_data": "Sample test data includes initial customers, orders with associated items, and products.",
|
|
73
|
+
"test_data_rows": [
|
|
74
|
+
{
|
|
75
|
+
"test_data_row_variable": "customer1",
|
|
76
|
+
"code": "customer1 = Customer(id=1, name=\"Customer A\", balance=0.0, credit_limit=1000.0)"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"test_data_row_variable": "customer2",
|
|
80
|
+
"code": "customer2 = Customer(id=2, name=\"Customer B\", balance=0.0, credit_limit=1500.0)"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"test_data_row_variable": "customer3",
|
|
84
|
+
"code": "customer3 = Customer(id=3, name=\"Customer C\", balance=0.0, credit_limit=2000.0)"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"test_data_row_variable": "customer4",
|
|
88
|
+
"code": "customer4 = Customer(id=4, name=\"Customer D\", balance=0.0, credit_limit=2500.0)"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"test_data_row_variable": "product1",
|
|
92
|
+
"code": "product1 = Product(id=1, name=\"Product A\", unit_price=10.0, carbon_neutral=True)"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"test_data_row_variable": "product2",
|
|
96
|
+
"code": "product2 = Product(id=2, name=\"Product B\", unit_price=20.0, carbon_neutral=False)"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"test_data_row_variable": "product3",
|
|
100
|
+
"code": "product3 = Product(id=3, name=\"Product C\", unit_price=30.0, carbon_neutral=True)"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"test_data_row_variable": "product4",
|
|
104
|
+
"code": "product4 = Product(id=4, name=\"Product D\", unit_price=40.0, carbon_neutral=False)"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"test_data_row_variable": "order1",
|
|
108
|
+
"code": "order1 = Order(id=1, customer_id=1, amount_total=0.0, date_shipped=None, notes='Urgent order')"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"test_data_row_variable": "order2",
|
|
112
|
+
"code": "order2 = Order(id=2, customer_id=2, amount_total=0.0, date_shipped=None, notes='Regular order')"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"test_data_row_variable": "order3",
|
|
116
|
+
"code": "order3 = Order(id=3, customer_id=3, amount_total=0.0, date_shipped=None, notes='Delayed order')"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"test_data_row_variable": "order4",
|
|
120
|
+
"code": "order4 = Order(id=4, customer_id=4, amount_total=0.0, date_shipped=None, notes='Important client')"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"test_data_row_variable": "item1",
|
|
124
|
+
"code": "item1 = Item(id=1, order_id=1, product_id=1, quantity=15, amount=135.0, unit_price=10.0, carbon_neutral=True)"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"test_data_row_variable": "item2",
|
|
128
|
+
"code": "item2 = Item(id=2, order_id=1, product_id=2, quantity=5, amount=100.0, unit_price=20.0, carbon_neutral=False)"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"test_data_row_variable": "item3",
|
|
132
|
+
"code": "item3 = Item(id=3, order_id=2, product_id=3, quantity=8, amount=216.0, unit_price=30.0, carbon_neutral=True)"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"test_data_row_variable": "item4",
|
|
136
|
+
"code": "item4 = Item(id=4, order_id=3, product_id=4, quantity=2, amount=80.0, unit_price=40.0, carbon_neutral=False)"
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
"test_data_sqlite": "INSERT INTO customer (id, name, balance, credit_limit) VALUES\n(1, \"Customer A\", 0.0, 1000.0),\n(2, \"Customer B\", 0.0, 1500.0),\n(3, \"Customer C\", 0.0, 2000.0),\n(4, \"Customer D\", 0.0, 2500.0);\n\nINSERT INTO product (id, name, unit_price, carbon_neutral) VALUES\n(1, \"Product A\", 10.0, 1),\n(2, \"Product B\", 20.0, 0),\n(3, \"Product C\", 30.0, 1),\n(4, \"Product D\", 40.0, 0);\n\nINSERT INTO \"order\" (id, customer_id, amount_total, date_shipped, notes) VALUES\n(1, 1, 0.0, NULL, 'Urgent order'),\n(2, 2, 0.0, NULL, 'Regular order'),\n(3, 3, 0.0, NULL, 'Delayed order'),\n(4, 4, 0.0, NULL, 'Important client');\n\nINSERT INTO item (id, order_id, product_id, quantity, amount, unit_price, carbon_neutral) VALUES\n(1, 1, 1, 15, 135.0, 10.0, 1),\n(2, 1, 2, 5, 100.0, 20.0, 0),\n(3, 2, 3, 8, 216.0, 30.0, 1),\n(4, 3, 4, 2, 80.0, 40.0, 0);",
|
|
140
|
+
"name": "CustomerOrderSystem"
|
|
141
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# using resolved_model self.resolved_model FIXME
|
|
2
|
+
# created from response, to create create_db_models.sqlite, with test data
|
|
3
|
+
# that is used to create project
|
|
4
|
+
# should run without error in manager
|
|
5
|
+
# if not, check for decimal, indent, or import issues
|
|
6
|
+
|
|
7
|
+
import decimal
|
|
8
|
+
import logging
|
|
9
|
+
import sqlalchemy
|
|
10
|
+
from sqlalchemy.sql import func
|
|
11
|
+
from logic_bank.logic_bank import Rule
|
|
12
|
+
from sqlalchemy import create_engine, Column, Integer, String, Float, ForeignKey, Date, DateTime, Numeric, Boolean, Text, DECIMAL
|
|
13
|
+
from sqlalchemy.types import *
|
|
14
|
+
from sqlalchemy.ext.declarative import declarative_base
|
|
15
|
+
from sqlalchemy.orm import sessionmaker
|
|
16
|
+
from sqlalchemy.orm import relationship
|
|
17
|
+
from sqlalchemy.orm import Mapped
|
|
18
|
+
from datetime import date
|
|
19
|
+
from datetime import datetime
|
|
20
|
+
from typing import List
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
logging.getLogger('sqlalchemy.engine.Engine').disabled = True # remove for additional logging
|
|
24
|
+
|
|
25
|
+
Base = declarative_base() # from system/genai/create_db_models_inserts/create_db_models_prefix.py
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
from sqlalchemy.dialects.sqlite import *
|
|
29
|
+
|
|
30
|
+
class CustomerAccount(Base):
|
|
31
|
+
"""description: This table holds customer account details with credit checks."""
|
|
32
|
+
"""
|
|
33
|
+
description: This table holds customer account details with credit checks.
|
|
34
|
+
"""
|
|
35
|
+
__tablename__ = 'customer_account'
|
|
36
|
+
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
37
|
+
name = Column(String, nullable=True)
|
|
38
|
+
email = Column(String, nullable=True)
|
|
39
|
+
balance = Column(Float, nullable=True)
|
|
40
|
+
credit_limit = Column(Float, nullable=True)
|
|
41
|
+
|
|
42
|
+
class Address(Base):
|
|
43
|
+
"""description: This table contains addresses associated with CustomerAccount."""
|
|
44
|
+
"""
|
|
45
|
+
description: This table contains addresses associated with CustomerAccount.
|
|
46
|
+
"""
|
|
47
|
+
__tablename__ = 'address'
|
|
48
|
+
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
49
|
+
customer_account_id = Column(Integer, ForeignKey('customer_account.id'),
|
|
50
|
+
nullable=False)
|
|
51
|
+
street = Column(String, nullable=True)
|
|
52
|
+
city = Column(String, nullable=True)
|
|
53
|
+
state = Column(String, nullable=True)
|
|
54
|
+
zip_code = Column(String, nullable=True)
|
|
55
|
+
|
|
56
|
+
class SalesRep(Base):
|
|
57
|
+
"""description: This table contains sales representative details."""
|
|
58
|
+
"""
|
|
59
|
+
description: This table contains sales representative details.
|
|
60
|
+
"""
|
|
61
|
+
__tablename__ = 'sales_rep'
|
|
62
|
+
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
63
|
+
name = Column(String, nullable=True)
|
|
64
|
+
region = Column(String, nullable=True)
|
|
65
|
+
|
|
66
|
+
class Order(Base):
|
|
67
|
+
"""description: This table contains order details with an assigned sales representative."""
|
|
68
|
+
"""
|
|
69
|
+
description: This table contains order details with an assigned sales representative.
|
|
70
|
+
"""
|
|
71
|
+
__tablename__ = 'order'
|
|
72
|
+
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
73
|
+
customer_account_id = Column(Integer, ForeignKey('customer_account.id'),
|
|
74
|
+
nullable=False)
|
|
75
|
+
order_date = Column(Date, nullable=True)
|
|
76
|
+
sales_rep_id = Column(Integer, ForeignKey('sales_rep.id'), nullable=False)
|
|
77
|
+
notes = Column(String, nullable=True)
|
|
78
|
+
amount_total = Column(Float, nullable=True)
|
|
79
|
+
|
|
80
|
+
class Item(Base):
|
|
81
|
+
"""description: This table links orders to products for each item on an order."""
|
|
82
|
+
"""
|
|
83
|
+
description: This table links orders to products for each item on an order.
|
|
84
|
+
"""
|
|
85
|
+
__tablename__ = 'item'
|
|
86
|
+
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
87
|
+
order_id = Column(Integer, ForeignKey('order.id'), nullable=False)
|
|
88
|
+
product_id = Column(Integer, ForeignKey('product.id'), nullable=False)
|
|
89
|
+
quantity = Column(Integer, nullable=True)
|
|
90
|
+
unit_price = Column(Float, nullable=True)
|
|
91
|
+
amount = Column(Float, nullable=True)
|
|
92
|
+
|
|
93
|
+
class Product(Base):
|
|
94
|
+
"""description: This table contains product information."""
|
|
95
|
+
"""
|
|
96
|
+
description: This table contains product information.
|
|
97
|
+
"""
|
|
98
|
+
__tablename__ = 'product'
|
|
99
|
+
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
100
|
+
name = Column(String, nullable=True)
|
|
101
|
+
price = Column(Float, nullable=True)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# end of model classes
|
|
105
|
+
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Copy this text, paste to https://dbdiagram.io/d
|
|
2
|
+
// Or, https://databasediagram.com/app
|
|
3
|
+
// Or, view in VSCode with extension: "DBML Live Preview"
|
|
4
|
+
|
|
5
|
+
Project DBML {
|
|
6
|
+
Note: '''
|
|
7
|
+
Address: This table contains addresses associated with CustomerAccount.
|
|
8
|
+
CustomerAccount: This table holds customer account details with credit checks.
|
|
9
|
+
Item: This table links orders to products for each item on an order.
|
|
10
|
+
Order: This table contains order details with an assigned sales representative.
|
|
11
|
+
Product: This table contains product information.
|
|
12
|
+
SalesRep: This table contains sales representative details.
|
|
13
|
+
'''
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Table Address {
|
|
17
|
+
id INTEGER [primary key]
|
|
18
|
+
customer_account_id INTEGER
|
|
19
|
+
street VARCHAR
|
|
20
|
+
city VARCHAR
|
|
21
|
+
state VARCHAR
|
|
22
|
+
zip_code VARCHAR
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Table CustomerAccount {
|
|
26
|
+
id INTEGER [primary key]
|
|
27
|
+
name VARCHAR
|
|
28
|
+
email VARCHAR
|
|
29
|
+
balance FLOAT
|
|
30
|
+
credit_limit FLOAT
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Table Item {
|
|
34
|
+
id INTEGER [primary key]
|
|
35
|
+
order_id INTEGER
|
|
36
|
+
product_id INTEGER
|
|
37
|
+
quantity INTEGER
|
|
38
|
+
unit_price FLOAT
|
|
39
|
+
amount FLOAT
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
Table Order {
|
|
43
|
+
id INTEGER [primary key]
|
|
44
|
+
customer_account_id INTEGER
|
|
45
|
+
order_date DATE
|
|
46
|
+
sales_rep_id INTEGER
|
|
47
|
+
notes VARCHAR
|
|
48
|
+
amount_total FLOAT
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
Table Product {
|
|
52
|
+
id INTEGER [primary key]
|
|
53
|
+
name VARCHAR
|
|
54
|
+
price FLOAT
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
Table SalesRep {
|
|
58
|
+
id INTEGER [primary key]
|
|
59
|
+
name VARCHAR
|
|
60
|
+
region VARCHAR
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
// Relationships
|
|
66
|
+
Ref: Address.(customer_account_id) < CustomerAccount.(id)
|
|
67
|
+
Ref: Item.(order_id) < Order.(id)
|
|
68
|
+
Ref: Item.(product_id) < Product.(id)
|
|
69
|
+
Ref: Order.(customer_account_id) < CustomerAccount.(id)
|
|
70
|
+
Ref: Order.(sales_rep_id) < SalesRep.(id)
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
{
|
|
2
|
+
"models": [
|
|
3
|
+
{
|
|
4
|
+
"classname": "CustomerAccount",
|
|
5
|
+
"code": "class CustomerAccount(Base):\n \"\"\"\n description: This table holds customer account details with credit checks.\n \"\"\"\n __tablename__ = 'customer_account'\n\n id = Column(Integer, primary_key=True, autoincrement=True)\n name = Column(String, nullable=True)\n email = Column(String, nullable=True)\n balance = Column(Float, nullable=True)\n credit_limit = Column(Float, nullable=True)\n",
|
|
6
|
+
"description": "This table holds customer account details with credit checks.",
|
|
7
|
+
"name": "CustomerAccount"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"classname": "Address",
|
|
11
|
+
"code": "class Address(Base):\n \"\"\"\n description: This table contains addresses associated with CustomerAccount.\n \"\"\"\n __tablename__ = 'address'\n\n id = Column(Integer, primary_key=True, autoincrement=True)\n customer_account_id = Column(Integer, ForeignKey('customer_account.id'), nullable=False)\n street = Column(String, nullable=True)\n city = Column(String, nullable=True)\n state = Column(String, nullable=True)\n zip_code = Column(String, nullable=True)\n",
|
|
12
|
+
"description": "This table contains addresses associated with CustomerAccount.",
|
|
13
|
+
"name": "Address"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"classname": "SalesRep",
|
|
17
|
+
"code": "class SalesRep(Base):\n \"\"\"\n description: This table contains sales representative details.\n \"\"\"\n __tablename__ = 'sales_rep'\n\n id = Column(Integer, primary_key=True, autoincrement=True)\n name = Column(String, nullable=True)\n region = Column(String, nullable=True)\n",
|
|
18
|
+
"description": "This table contains sales representative details.",
|
|
19
|
+
"name": "SalesRep"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"classname": "Order",
|
|
23
|
+
"code": "class Order(Base):\n \"\"\"\n description: This table contains order details with an assigned sales representative.\n \"\"\"\n __tablename__ = 'order'\n\n id = Column(Integer, primary_key=True, autoincrement=True)\n customer_account_id = Column(Integer, ForeignKey('customer_account.id'), nullable=False)\n order_date = Column(Date, nullable=True)\n sales_rep_id = Column(Integer, ForeignKey('sales_rep.id'), nullable=False)\n notes = Column(String, nullable=True)\n amount_total = Column(Float, nullable=True)\n",
|
|
24
|
+
"description": "This table contains order details with an assigned sales representative.",
|
|
25
|
+
"name": "Order"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"classname": "Item",
|
|
29
|
+
"code": "class Item(Base):\n \"\"\"\n description: This table links orders to products for each item on an order.\n \"\"\"\n __tablename__ = 'item'\n\n id = Column(Integer, primary_key=True, autoincrement=True)\n order_id = Column(Integer, ForeignKey('order.id'), nullable=False)\n product_id = Column(Integer, ForeignKey('product.id'), nullable=False)\n quantity = Column(Integer, nullable=True)\n unit_price = Column(Float, nullable=True)\n amount = Column(Float, nullable=True) # derived in logic\n",
|
|
30
|
+
"description": "This table links orders to products for each item on an order.",
|
|
31
|
+
"name": "Item"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"classname": "Product",
|
|
35
|
+
"code": "class Product(Base):\n \"\"\"\n description: This table contains product information.\n \"\"\"\n __tablename__ = 'product'\n\n id = Column(Integer, primary_key=True, autoincrement=True)\n name = Column(String, nullable=True)\n price = Column(Float, nullable=True)\n",
|
|
36
|
+
"description": "This table contains product information.",
|
|
37
|
+
"name": "Product"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"rules": [
|
|
41
|
+
{
|
|
42
|
+
"name": "Check Credit",
|
|
43
|
+
"description": "Enforces that a CustomerAccount's balance does not exceed the credit limit.",
|
|
44
|
+
"use_case": "Check Credit",
|
|
45
|
+
"entity": "CustomerAccount",
|
|
46
|
+
"code": "Rule.constraint(validate=CustomerAccount, as_condition=lambda row: row.balance <= row.credit_limit, error_msg=\"CustomerAccount balance ({row.balance}) exceeds credit limit ({row.credit_limit})\")"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "Balance Sum",
|
|
50
|
+
"description": "Calculates CustomerAccount balance based on orders' amount_total where date_shipped is null.",
|
|
51
|
+
"use_case": "Check Credit",
|
|
52
|
+
"entity": "CustomerAccount",
|
|
53
|
+
"code": "Rule.sum(derive=CustomerAccount.balance, as_sum_of=Order.amount_total, where=lambda row: row.order_date is None)"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "Order Amount Total",
|
|
57
|
+
"description": "Calculates Order's amount_total from sum of Item.amount values.",
|
|
58
|
+
"use_case": "Check Credit",
|
|
59
|
+
"entity": "Order",
|
|
60
|
+
"code": "Rule.sum(derive=Order.amount_total, as_sum_of=Item.amount)"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"name": "Item Amount Formula",
|
|
64
|
+
"description": "Derives Item.amount as quantity * unit_price.",
|
|
65
|
+
"use_case": "Check Credit",
|
|
66
|
+
"entity": "Item",
|
|
67
|
+
"code": "Rule.formula(derive=Item.amount, as_expression=lambda row: row.quantity * row.unit_price)"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "Copy Unit Price",
|
|
71
|
+
"description": "Copies Product.unit_price to Item.unit_price when an order item is created.",
|
|
72
|
+
"use_case": "Check Credit",
|
|
73
|
+
"entity": "Item",
|
|
74
|
+
"code": "Rule.copy(derive=Item.unit_price, from_parent=Product.price)"
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
"test_data": "from datetime import date\n\n# CustomerAccount Test Data\ncustomer_account1 = CustomerAccount(name=\"John Doe\", email=\"john.doe@example.com\", balance=0, credit_limit=1500)\ncustomer_account2 = CustomerAccount(name=\"Jane Smith\", email=\"jane.smith@example.com\", balance=0, credit_limit=1000)\ncustomer_account3 = CustomerAccount(name=\"Alice Johnson\", email=\"alice.johnson@example.com\", balance=0, credit_limit=2000)\ncustomer_account4 = CustomerAccount(name=\"Bob Brown\", email=\"bob.brown@example.com\", balance=0, credit_limit=1200)\n\n# Address Test Data\naddress1 = Address(customer_account_id=1, street=\"123 Elm St\", city=\"Springfield\", state=\"IL\", zip_code=\"62701\")\naddress2 = Address(customer_account_id=2, street=\"456 Maple Ave\", city=\"Dover\", state=\"DE\", zip_code=\"19901\")\naddress3 = Address(customer_account_id=3, street=\"789 Oak Dr\", city=\"Albany\", state=\"NY\", zip_code=\"12207\")\naddress4 = Address(customer_account_id=4, street=\"321 Pine St\", city=\"Madison\", state=\"WI\", zip_code=\"53703\")\n\n# SalesRep Test Data\nsales_rep1 = SalesRep(name=\"Sam Allen\", region=\"West\")\nsales_rep2 = SalesRep(name=\"Linda Carter\", region=\"East\")\nsales_rep3 = SalesRep(name=\"Dan Miller\", region=\"North\")\nsales_rep4 = SalesRep(name=\"Karen White\", region=\"South\")\n\n# Product Test Data\nproduct1 = Product(name=\"Laptop\", price=999.99)\nproduct2 = Product(name=\"Smartphone\", price=499.99)\nproduct3 = Product(name=\"Tablet\", price=299.99)\nproduct4 = Product(name=\"Headphones\", price=89.99)\n\n# Order Test Data\norder1 = Order(customer_account_id=1, order_date=date(2023, 1, 10), sales_rep_id=1, notes=\"First order.\", amount_total=0)\norder2 = Order(customer_account_id=2, order_date=date(2023, 2, 15), sales_rep_id=2, notes=\"In a rush.\", amount_total=0)\norder3 = Order(customer_account_id=3, order_date=date(2023, 3, 20), sales_rep_id=3, notes=\"Regular customer.\", amount_total=0)\norder4 = Order(customer_account_id=4, order_date=date(2023, 4, 25), sales_rep_id=4, notes=\"Check delivery.\", amount_total=0)\n\n# Item Test Data\nitem1 = Item(order_id=1, product_id=2, quantity=3, unit_price=product2.price, amount=1500)\nitem2 = Item(order_id=1, product_id=3, quantity=2, unit_price=product3.price, amount=600)\nitem3 = Item(order_id=2, product_id=1, quantity=1, unit_price=product1.price, amount=1000)\nitem4 = Item(order_id=3, product_id=4, quantity=5, unit_price=product4.price, amount=450)\n",
|
|
78
|
+
"test_data_rows": [
|
|
79
|
+
{
|
|
80
|
+
"test_data_row_variable": "customer_account1",
|
|
81
|
+
"code": "customer_account1 = CustomerAccount(name=\"John Doe\", email=\"john.doe@example.com\", balance=0, credit_limit=1500)"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"test_data_row_variable": "customer_account2",
|
|
85
|
+
"code": "customer_account2 = CustomerAccount(name=\"Jane Smith\", email=\"jane.smith@example.com\", balance=0, credit_limit=1000)"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"test_data_row_variable": "customer_account3",
|
|
89
|
+
"code": "customer_account3 = CustomerAccount(name=\"Alice Johnson\", email=\"alice.johnson@example.com\", balance=0, credit_limit=2000)"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"test_data_row_variable": "customer_account4",
|
|
93
|
+
"code": "customer_account4 = CustomerAccount(name=\"Bob Brown\", email=\"bob.brown@example.com\", balance=0, credit_limit=1200)"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"test_data_row_variable": "address1",
|
|
97
|
+
"code": "address1 = Address(customer_account_id=1, street=\"123 Elm St\", city=\"Springfield\", state=\"IL\", zip_code=\"62701\")"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"test_data_row_variable": "address2",
|
|
101
|
+
"code": "address2 = Address(customer_account_id=2, street=\"456 Maple Ave\", city=\"Dover\", state=\"DE\", zip_code=\"19901\")"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"test_data_row_variable": "address3",
|
|
105
|
+
"code": "address3 = Address(customer_account_id=3, street=\"789 Oak Dr\", city=\"Albany\", state=\"NY\", zip_code=\"12207\")"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"test_data_row_variable": "address4",
|
|
109
|
+
"code": "address4 = Address(customer_account_id=4, street=\"321 Pine St\", city=\"Madison\", state=\"WI\", zip_code=\"53703\")"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"test_data_row_variable": "sales_rep1",
|
|
113
|
+
"code": "sales_rep1 = SalesRep(name=\"Sam Allen\", region=\"West\")"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"test_data_row_variable": "sales_rep2",
|
|
117
|
+
"code": "sales_rep2 = SalesRep(name=\"Linda Carter\", region=\"East\")"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"test_data_row_variable": "sales_rep3",
|
|
121
|
+
"code": "sales_rep3 = SalesRep(name=\"Dan Miller\", region=\"North\")"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"test_data_row_variable": "sales_rep4",
|
|
125
|
+
"code": "sales_rep4 = SalesRep(name=\"Karen White\", region=\"South\")"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"test_data_row_variable": "product1",
|
|
129
|
+
"code": "product1 = Product(name=\"Laptop\", price=999.99)"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"test_data_row_variable": "product2",
|
|
133
|
+
"code": "product2 = Product(name=\"Smartphone\", price=499.99)"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"test_data_row_variable": "product3",
|
|
137
|
+
"code": "product3 = Product(name=\"Tablet\", price=299.99)"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"test_data_row_variable": "product4",
|
|
141
|
+
"code": "product4 = Product(name=\"Headphones\", price=89.99)"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"test_data_row_variable": "order1",
|
|
145
|
+
"code": "order1 = Order(customer_account_id=1, order_date=date(2023, 1, 10), sales_rep_id=1, notes=\"First order.\", amount_total=0)"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"test_data_row_variable": "order2",
|
|
149
|
+
"code": "order2 = Order(customer_account_id=2, order_date=date(2023, 2, 15), sales_rep_id=2, notes=\"In a rush.\", amount_total=0)"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"test_data_row_variable": "order3",
|
|
153
|
+
"code": "order3 = Order(customer_account_id=3, order_date=date(2023, 3, 20), sales_rep_id=3, notes=\"Regular customer.\", amount_total=0)"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"test_data_row_variable": "order4",
|
|
157
|
+
"code": "order4 = Order(customer_account_id=4, order_date=date(2023, 4, 25), sales_rep_id=4, notes=\"Check delivery.\", amount_total=0)"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"test_data_row_variable": "item1",
|
|
161
|
+
"code": "item1 = Item(order_id=1, product_id=2, quantity=3, unit_price=product2.price, amount=1500)"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"test_data_row_variable": "item2",
|
|
165
|
+
"code": "item2 = Item(order_id=1, product_id=3, quantity=2, unit_price=product3.price, amount=600)"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"test_data_row_variable": "item3",
|
|
169
|
+
"code": "item3 = Item(order_id=2, product_id=1, quantity=1, unit_price=product1.price, amount=1000)"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"test_data_row_variable": "item4",
|
|
173
|
+
"code": "item4 = Item(order_id=3, product_id=4, quantity=5, unit_price=product4.price, amount=450)"
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
"test_data_sqlite": "INSERT INTO customer_account (name, email, balance, credit_limit) VALUES ('John Doe', 'john.doe@example.com', 0, 1500);\nINSERT INTO customer_account (name, email, balance, credit_limit) VALUES ('Jane Smith', 'jane.smith@example.com', 0, 1000);\nINSERT INTO customer_account (name, email, balance, credit_limit) VALUES ('Alice Johnson', 'alice.johnson@example.com', 0, 2000);\nINSERT INTO customer_account (name, email, balance, credit_limit) VALUES ('Bob Brown', 'bob.brown@example.com', 0, 1200);\n\nINSERT INTO address (customer_account_id, street, city, state, zip_code) VALUES (1, '123 Elm St', 'Springfield', 'IL', '62701');\nINSERT INTO address (customer_account_id, street, city, state, zip_code) VALUES (2, '456 Maple Ave', 'Dover', 'DE', '19901');\nINSERT INTO address (customer_account_id, street, city, state, zip_code) VALUES (3, '789 Oak Dr', 'Albany', 'NY', '12207');\nINSERT INTO address (customer_account_id, street, city, state, zip_code) VALUES (4, '321 Pine St', 'Madison', 'WI', '53703');\n\nINSERT INTO sales_rep (name, region) VALUES ('Sam Allen', 'West');\nINSERT INTO sales_rep (name, region) VALUES ('Linda Carter', 'East');\nINSERT INTO sales_rep (name, region) VALUES ('Dan Miller', 'North');\nINSERT INTO sales_rep (name, region) VALUES ('Karen White', 'South');\n\nINSERT INTO product (name, price) VALUES ('Laptop', 999.99);\nINSERT INTO product (name, price) VALUES ('Smartphone', 499.99);\nINSERT INTO product (name, price) VALUES ('Tablet', 299.99);\nINSERT INTO product (name, price) VALUES ('Headphones', 89.99);\n\nINSERT INTO \"order\" (customer_account_id, order_date, sales_rep_id, notes, amount_total) VALUES (1, '2023-01-10', 1, 'First order.', 0);\nINSERT INTO \"order\" (customer_account_id, order_date, sales_rep_id, notes, amount_total) VALUES (2, '2023-02-15', 2, 'In a rush.', 0);\nINSERT INTO \"order\" (customer_account_id, order_date, sales_rep_id, notes, amount_total) VALUES (3, '2023-03-20', 3, 'Regular customer.', 0);\nINSERT INTO \"order\" (customer_account_id, order_date, sales_rep_id, notes, amount_total) VALUES (4, '2023-04-25', 4, 'Check delivery.', 0);\n\nINSERT INTO \"item\" (order_id, product_id, quantity, unit_price, amount) VALUES (1, 2, 3, 499.99, 1500);\nINSERT INTO \"item\" (order_id, product_id, quantity, unit_price, amount) VALUES (1, 3, 2, 299.99, 600);\nINSERT INTO \"item\" (order_id, product_id, quantity, unit_price, amount) VALUES (2, 1, 1, 999.99, 1000);\nINSERT INTO \"item\" (order_id, product_id, quantity, unit_price, amount) VALUES (3, 4, 5, 89.99, 450);",
|
|
177
|
+
"name": "EnhancedOrderManagementSystem"
|
|
178
|
+
}
|
|
@@ -3,7 +3,6 @@ from decimal import Decimal
|
|
|
3
3
|
from logic_bank.exec_row_logic.logic_row import LogicRow
|
|
4
4
|
from logic_bank.extensions.rule_extensions import RuleExtension
|
|
5
5
|
from logic_bank.logic_bank import Rule
|
|
6
|
-
from logic_bank.logic_bank import DeclareRule
|
|
7
6
|
import database.models as models
|
|
8
7
|
from database.models import *
|
|
9
8
|
import api.system.opt_locking.opt_locking as opt_locking
|
|
@@ -3,7 +3,6 @@ from decimal import Decimal
|
|
|
3
3
|
from logic_bank.exec_row_logic.logic_row import LogicRow
|
|
4
4
|
from logic_bank.extensions.rule_extensions import RuleExtension
|
|
5
5
|
from logic_bank.logic_bank import Rule
|
|
6
|
-
from logic_bank.logic_bank import DeclareRule
|
|
7
6
|
import database.models as models
|
|
8
7
|
from database.models import *
|
|
9
8
|
import api.system.opt_locking.opt_locking as opt_locking
|