ApiLogicServer 14.2.20__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.
Files changed (67) hide show
  1. {ApiLogicServer-14.2.20.dist-info → ApiLogicServer-14.3.0.dist-info}/METADATA +2 -2
  2. {ApiLogicServer-14.2.20.dist-info → ApiLogicServer-14.3.0.dist-info}/RECORD +65 -47
  3. api_logic_server_cli/api_logic_server.py +4 -1
  4. api_logic_server_cli/api_logic_server_info.yaml +3 -3
  5. api_logic_server_cli/create_from_model/__pycache__/api_logic_server_utils.cpython-312.pyc +0 -0
  6. api_logic_server_cli/create_from_model/__pycache__/ont_build.cpython-312.pyc +0 -0
  7. api_logic_server_cli/create_from_model/__pycache__/ont_create.cpython-312.pyc +0 -0
  8. api_logic_server_cli/create_from_model/api_logic_server_utils.py +4 -0
  9. api_logic_server_cli/create_from_model/ont_build.py +53 -19
  10. api_logic_server_cli/create_from_model/ont_create.py +14 -5
  11. api_logic_server_cli/fragments/declare_logic.py +72 -0
  12. api_logic_server_cli/{prototypes/manager/system/genai/create_db_models_inserts/logic_discovery_prefix.py → fragments/declare_logic_begin.py} +2 -1
  13. api_logic_server_cli/fragments/declare_logic_end.py +52 -0
  14. api_logic_server_cli/genai/genai.py +21 -8
  15. api_logic_server_cli/genai/genai_logic_builder.py +14 -11
  16. api_logic_server_cli/genai/genai_svcs.py +102 -7
  17. api_logic_server_cli/model_migrator/model_migrator_start.py +1 -1
  18. api_logic_server_cli/model_migrator/reposreader.py +9 -1
  19. api_logic_server_cli/model_migrator/rule_obj.py +24 -6
  20. api_logic_server_cli/prototypes/base/api/api_discovery/ontimize_api.py +4 -1
  21. api_logic_server_cli/prototypes/base/config/activate_logicbank.py +8 -4
  22. api_logic_server_cli/prototypes/base/database/bind_dbs.py +1 -1
  23. api_logic_server_cli/prototypes/base/database/test_data/readme.md +5 -5
  24. api_logic_server_cli/prototypes/base/logic/declare_logic.py +8 -3
  25. api_logic_server_cli/prototypes/base/logic/load_verify_rules.py +216 -0
  26. api_logic_server_cli/prototypes/base/logic/logic_discovery/auto_discovery.py +22 -13
  27. api_logic_server_cli/prototypes/genai_demo/logic/declare_logic.py +29 -21
  28. api_logic_server_cli/prototypes/manager/README.md +18 -3
  29. api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo.response_example +19 -18
  30. api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/.DS_Store +0 -0
  31. api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/000_you_are.prompt +1 -0
  32. api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/001_logic_training.prompt +314 -0
  33. api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/002_create_db_models.prompt +150 -0
  34. api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/003_create_db_models.response +134 -0
  35. api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/004_iteratio_logic.prompt +131 -0
  36. api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/005_create_db_models.response-example +141 -0
  37. api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/create_db_models.py +105 -0
  38. api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/db.dbml +70 -0
  39. api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/readme.md +6 -0
  40. api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_iteration_discount/response.json +178 -0
  41. 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
  42. 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
  43. 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
  44. 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
  45. 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
  46. 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
  47. 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
  48. 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
  49. 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
  50. api_logic_server_cli/prototypes/manager/system/genai/examples/time_tracking_billing/002_create_db_models.prompt +194 -0
  51. api_logic_server_cli/prototypes/manager/system/genai/examples/time_tracking_billing/003_create_db_models.response +298 -0
  52. api_logic_server_cli/prototypes/manager/system/genai/examples/time_tracking_billing/db.sqlite +0 -0
  53. api_logic_server_cli/prototypes/manager/system/genai/examples/time_tracking_billing/readme.md +8 -0
  54. api_logic_server_cli/prototypes/manager/system/genai/learning_requests/logic_bank_api.prompt +14 -10
  55. api_logic_server_cli/prototypes/manager/system/genai/prompt_inserts/iteration.prompt +2 -1
  56. api_logic_server_cli/prototypes/nw_no_cust/venv_setup/system_note.txt +1 -1
  57. api_logic_server_cli/prototypes/ont_app/templates/home_tree_template.html +9 -0
  58. api_logic_server_cli/prototypes/ont_app/templates/tree_routing.jinja +32 -0
  59. api_logic_server_cli/sqlacodegen_wrapper/sqlacodegen/sqlacodegen/__pycache__/codegen.cpython-312.pyc +0 -0
  60. api_logic_server_cli/sqlacodegen_wrapper/sqlacodegen/sqlacodegen/codegen.py +2 -1
  61. api_logic_server_cli/tools/mini_skel/logic/load_verify_rules.py +1 -1
  62. api_logic_server_cli/model_migrator/system/custom_endpoint.py +0 -545
  63. api_logic_server_cli/prototypes/base/database/test_data/z_test_data_rows.py +0 -98
  64. {ApiLogicServer-14.2.20.dist-info → ApiLogicServer-14.3.0.dist-info}/LICENSE +0 -0
  65. {ApiLogicServer-14.2.20.dist-info → ApiLogicServer-14.3.0.dist-info}/WHEEL +0 -0
  66. {ApiLogicServer-14.2.20.dist-info → ApiLogicServer-14.3.0.dist-info}/entry_points.txt +0 -0
  67. {ApiLogicServer-14.2.20.dist-info → ApiLogicServer-14.3.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,298 @@
1
+ {
2
+ "models": [
3
+ {
4
+ "classname": "Client",
5
+ "code": "class Client(Base):\n __tablename__ = 'client'\n\n id = Column(Integer, primary_key=True)\n name = Column(String, nullable=False)\n email = Column(String, nullable=False)\n phone = Column(String, nullable=False)\n total_hours = Column(DECIMAL(10, 2), default=0)\n total_amount = Column(DECIMAL(10, 2), default=0)\n budget_amount = Column(DECIMAL(10, 2), default=0)\n is_over_budget = Column(Boolean, default=False)",
6
+ "description": "Model representing clients for billing.",
7
+ "name": "Client"
8
+ },
9
+ {
10
+ "classname": "Project",
11
+ "code": "class Project(Base):\n __tablename__ = 'project'\n\n id = Column(Integer, primary_key=True)\n client_id = Column(Integer, ForeignKey('client.id'))\n name = Column(String, nullable=False)\n total_project_hours = Column(DECIMAL(10, 2), default=0)\n total_project_amount = Column(DECIMAL(10, 2), default=0)\n project_budget_amount = Column(DECIMAL(10, 2), default=0)\n is_over_budget = Column(Boolean, default=False)",
12
+ "description": "Model representing projects under a client.",
13
+ "name": "Project"
14
+ },
15
+ {
16
+ "classname": "Invoice",
17
+ "code": "class Invoice(Base):\n __tablename__ = 'invoice'\n\n id = Column(Integer, primary_key=True)\n invoice_date = Column(DateTime, nullable=False)\n project_id = Column(Integer, ForeignKey('project.id'))\n invoice_amount = Column(DECIMAL(10, 2), default=0)\n payment_total = Column(DECIMAL(10, 2), default=0)\n invoice_balance = Column(DECIMAL(10, 2), default=0)\n is_paid = Column(Boolean, default=False)",
18
+ "description": "Model representing invoices for projects.",
19
+ "name": "Invoice"
20
+ },
21
+ {
22
+ "classname": "Task",
23
+ "code": "class Task(Base):\n __tablename__ = 'task'\n\n id = Column(Integer, primary_key=True)\n project_id = Column(Integer, ForeignKey('project.id'))\n name = Column(String, nullable=False)\n description = Column(String, nullable=True)\n total_task_hours_worked = Column(DECIMAL(10, 2), default=0)\n total_task_amount_billed = Column(DECIMAL(10, 2), default=0)\n task_budget_hours = Column(DECIMAL(10, 2), default=0)\n is_over_budget = Column(Boolean, default=False)\n invoice_id = Column(Integer, ForeignKey('invoice.id'))",
24
+ "description": "Model representing tasks under a project.",
25
+ "name": "Task"
26
+ },
27
+ {
28
+ "classname": "Person",
29
+ "code": "class Person(Base):\n __tablename__ = 'person'\n\n id = Column(Integer, primary_key=True)\n client_id = Column(Integer, ForeignKey('client.id'))\n name = Column(String, nullable=False)\n email = Column(String, nullable=False)\n phone = Column(String, nullable=False)\n billing_rate = Column(DECIMAL(10, 2), default=0)\n total_hours_entered = Column(DECIMAL(10, 2), default=0)\n total_amount_billed = Column(DECIMAL(10, 2), default=0)",
30
+ "description": "Model representing personnel working with clients.",
31
+ "name": "Person"
32
+ },
33
+ {
34
+ "classname": "Timesheet",
35
+ "code": "class Timesheet(Base):\n __tablename__ = 'timesheet'\n\n id = Column(Integer, primary_key=True)\n task_id = Column(Integer, ForeignKey('task.id'))\n person_id = Column(Integer, ForeignKey('person.id'))\n date_worked = Column(DateTime, nullable=False)\n hours_worked = Column(DECIMAL(10, 2), default=0)\n month = Column(Integer)\n year = Column(Integer)\n billing_rate = Column(DECIMAL(10, 2), default=0)\n total_amount_billed = Column(DECIMAL(10, 2), default=0)",
36
+ "description": "Model representing timesheets for tasks.",
37
+ "name": "Timesheet"
38
+ },
39
+ {
40
+ "classname": "Payment",
41
+ "code": "class Payment(Base):\n __tablename__ = 'payment'\n\n id = Column(Integer, primary_key=True)\n invoice_id = Column(Integer, ForeignKey('invoice.id'))\n payment_amount = Column(DECIMAL(10, 2), default=0)\n payment_date = Column(Date, nullable=False)\n notes = Column(String, nullable=True)",
42
+ "description": "Model representing payments made against invoices.",
43
+ "name": "Payment"
44
+ }
45
+ ],
46
+ "rules": [
47
+ {
48
+ "name": "Sum Client Total Hours",
49
+ "description": "Total Hours is the sum of Project total project hours",
50
+ "use_case": "Client",
51
+ "entity": "Client",
52
+ "code": "Rule.sum(derive=Client.total_hours, as_sum_of=Project.total_project_hours)"
53
+ },
54
+ {
55
+ "name": "Sum Client Total Amount",
56
+ "description": "Total Amount is the sum of Project total amount",
57
+ "use_case": "Client",
58
+ "entity": "Client",
59
+ "code": "Rule.sum(derive=Client.total_amount, as_sum_of=Project.total_project_amount)"
60
+ },
61
+ {
62
+ "name": "Formula: Client Is Over Budget",
63
+ "description": "Is Over Budget is true when total amount exceeds budget amount",
64
+ "use_case": "Client",
65
+ "entity": "Client",
66
+ "code": "Rule.formula(derive=Client.is_over_budget, as_expression=lambda row: row.total_amount > row.budget_amount)"
67
+ },
68
+ {
69
+ "name": "Sum Project Total Project Hours",
70
+ "description": "Total project hours is the sum of Task total task hours worked",
71
+ "use_case": "Project",
72
+ "entity": "Project",
73
+ "code": "Rule.sum(derive=Project.total_project_hours, as_sum_of=Task.total_task_hours_worked)"
74
+ },
75
+ {
76
+ "name": "Sum Project Total Project Amount",
77
+ "description": "Total project amount is the sum of Task total amount billed",
78
+ "use_case": "Project",
79
+ "entity": "Project",
80
+ "code": "Rule.sum(derive=Project.total_project_amount, as_sum_of=Task.total_task_amount_billed)"
81
+ },
82
+ {
83
+ "name": "Formula: Project Is Over Budget",
84
+ "description": "Is Over Budget when total project amount exceeds project budget amount",
85
+ "use_case": "Project",
86
+ "entity": "Project",
87
+ "code": "Rule.formula(derive=Project.is_over_budget, as_expression=lambda row: row.total_project_amount > row.project_budget_amount)"
88
+ },
89
+ {
90
+ "name": "Sum Task Total Task Hours Worked",
91
+ "description": "Total task hours worked is the sum of the Timesheet hours worked",
92
+ "use_case": "Task",
93
+ "entity": "Task",
94
+ "code": "Rule.sum(derive=Task.total_task_hours_worked, as_sum_of=Timesheet.hours_worked)"
95
+ },
96
+ {
97
+ "name": "Sum Task Total Task Amount Billed",
98
+ "description": "Total task amount billed is the sum of the Timesheet total amount billed",
99
+ "use_case": "Task",
100
+ "entity": "Task",
101
+ "code": "Rule.sum(derive=Task.total_task_amount_billed, as_sum_of=Timesheet.total_amount_billed)"
102
+ },
103
+ {
104
+ "name": "Formula: Task Is Over Budget",
105
+ "description": "Formula: is Over Budget when total task hours worked exceeds task budget hours",
106
+ "use_case": "Task",
107
+ "entity": "Task",
108
+ "code": "Rule.formula(derive=Task.is_over_budget, as_expression=lambda row: row.total_task_hours_worked > row.task_budget_hours)"
109
+ },
110
+ {
111
+ "name": "Copy Timesheet Billing Rate",
112
+ "description": "Copy billing rate from Person billing rate",
113
+ "use_case": "Timesheet",
114
+ "entity": "Timesheet",
115
+ "code": "Rule.copy(derive=Timesheet.billing_rate, from_parent=Person.billing_rate)"
116
+ },
117
+ {
118
+ "name": "Formula Timesheet Total Amount Billed",
119
+ "description": "The total amount billed is the Person billing rate times hours worked",
120
+ "use_case": "Timesheet",
121
+ "entity": "Timesheet",
122
+ "code": "Rule.formula(derive=Timesheet.total_amount_billed, as_expression=lambda row: row.billing_rate * row.hours_worked)"
123
+ },
124
+ {
125
+ "name": "Timesheet Hours Constraint",
126
+ "description": "Hours worked must be greater than 0 and less than 15",
127
+ "use_case": "Timesheet",
128
+ "entity": "Timesheet",
129
+ "code": "Rule.constraint(validate=Timesheet, as_condition=lambda row: 0 < row.hours_worked < 15, error_msg='Hours worked must be > 0 and < 15')"
130
+ },
131
+ {
132
+ "name": "Sum Person Total Hours Entered",
133
+ "description": "Total Hours entered is sum of timesheet hours worked",
134
+ "use_case": "Person",
135
+ "entity": "Person",
136
+ "code": "Rule.sum(derive=Person.total_hours_entered, as_sum_of=Timesheet.hours_worked)"
137
+ },
138
+ {
139
+ "name": "Formula Person Total Amount Billed",
140
+ "description": "Total amount billed is total hours entered times billing rate",
141
+ "use_case": "Person",
142
+ "entity": "Person",
143
+ "code": "Rule.formula(derive=Person.total_amount_billed, as_expression=lambda row: row.total_hours_entered * row.billing_rate)"
144
+ },
145
+ {
146
+ "name": "Person Billing Rate Constraint",
147
+ "description": "Billing rate must be greater than 0 and less than 200",
148
+ "use_case": "Person",
149
+ "entity": "Person",
150
+ "code": "Rule.constraint(validate=Person, as_condition=lambda row: 0 < row.billing_rate < 200, error_msg='Billing rate must be > 0 and < 200')"
151
+ },
152
+ {
153
+ "name": "Sum Invoice Invoice Amount",
154
+ "description": "Invoice Amount is the sum of Task total amount billed",
155
+ "use_case": "Invoice",
156
+ "entity": "Invoice",
157
+ "code": "Rule.sum(derive=Invoice.invoice_amount, as_sum_of=Task.total_task_amount_billed)"
158
+ },
159
+ {
160
+ "name": "Sum Invoice Payment Total",
161
+ "description": "Payment total is the sum of Payment",
162
+ "use_case": "Invoice",
163
+ "entity": "Invoice",
164
+ "code": "Rule.sum(derive=Invoice.payment_total, as_sum_of=Payment.payment_amount)"
165
+ },
166
+ {
167
+ "name": "Formula Invoice Balance",
168
+ "description": "Invoice balance is invoice amount less payment total",
169
+ "use_case": "Invoice",
170
+ "entity": "Invoice",
171
+ "code": "Rule.formula(derive=Invoice.invoice_balance, as_expression=lambda row: row.invoice_amount - row.payment_total)"
172
+ },
173
+ {
174
+ "name": "Formula Invoice Is Paid",
175
+ "description": "Invoice is paid when invoice balance is zero",
176
+ "use_case": "Invoice",
177
+ "entity": "Invoice",
178
+ "code": "Rule.formula(derive=Invoice.is_paid, as_expression=lambda row: row.invoice_balance == 0)"
179
+ }
180
+ ],
181
+ "test_data": "# Test data for Client\nclient1 = Client(id=1, name=\"Acme Corp\", email=\"acme@acme.com\", phone=\"123-456-7890\", total_hours=20, total_amount=5000, budget_amount=10000)\nclient2 = Client(id=2, name=\"Beta LLC\", email=\"beta@beta.com\", phone=\"987-654-3210\", total_hours=15, total_amount=3000, budget_amount=5000)\nclient3 = Client(id=3, name=\"Gamma Industries\", email=\"gamma@gamma.com\", phone=\"456-123-6789\", total_hours=30, total_amount=12000, budget_amount=15000)\nclient4 = Client(id=4, name=\"Delta Services\", email=\"delta@delta.com\", phone=\"789-321-6540\", total_hours=45, total_amount=9000, budget_amount=20000)\n\n# Test data for Project\nproject1 = Project(id=1, client_id=1, name=\"Project X\", total_project_hours=50, total_project_amount=8000, project_budget_amount=10000)\nproject2 = Project(id=2, client_id=1, name=\"Project Y\", total_project_hours=25, total_project_amount=4000, project_budget_amount=7000)\nproject3 = Project(id=3, client_id=2, name=\"Project Z\", total_project_hours=30, total_project_amount=3000, project_budget_amount=4000)\nproject4 = Project(id=4, client_id=3, name=\"Project Alpha\", total_project_hours=60, total_project_amount=15000, project_budget_amount=20000)\n\n# Test data for Invoice\ninvoice1 = Invoice(id=1, project_id=1, invoice_date=date(2023, 2, 15), invoice_amount=5000, payment_total=3000, invoice_balance=2000)\ninvoice2 = Invoice(id=2, project_id=2, invoice_date=date(2023, 3, 20), invoice_amount=1000, payment_total=1000, invoice_balance=0)\ninvoice3 = Invoice(id=3, project_id=3, invoice_date=date(2023, 4, 11), invoice_amount=2000, payment_total=1500, invoice_balance=500)\ninvoice4 = Invoice(id=4, project_id=4, invoice_date=date(2023, 5, 9), invoice_amount=7000, payment_total=5000, invoice_balance=2000)\n\n# Test data for Task\ntask1 = Task(id=1, project_id=1, name=\"Design Phase\", description=\"Initial design work\", total_task_hours_worked=15, total_task_amount_billed=1500, task_budget_hours=20)\ntask2 = Task(id=2, project_id=2, name=\"Development Phase\", description=\"Coding and implementation\", total_task_hours_worked=30, total_task_amount_billed=3000, task_budget_hours=40)\ntask3 = Task(id=3, project_id=3, name=\"Testing Phase\", description=\"QA and testing\", total_task_hours_worked=10, total_task_amount_billed=1000, task_budget_hours=15)\ntask4 = Task(id=4, project_id=4, name=\"Deployment Phase\", description=\"Deployment and support\", total_task_hours_worked=20, total_task_amount_billed=2000, task_budget_hours=25)\n\n# Test data for Person\nperson1 = Person(id=1, client_id=1, name=\"Alice Smith\", email=\"alice@example.com\", phone=\"111-222-3333\", billing_rate=50, total_hours_entered=10, total_amount_billed=500)\nperson2 = Person(id=2, client_id=2, name=\"Bob Brown\", email=\"bob@example.com\", phone=\"444-555-6666\", billing_rate=75, total_hours_entered=8, total_amount_billed=600)\nperson3 = Person(id=3, client_id=3, name=\"Charlie Johnson\", email=\"charlie@example.com\", phone=\"777-888-9999\", billing_rate=60, total_hours_entered=12, total_amount_billed=720)\nperson4 = Person(id=4, client_id=4, name=\"Dana White\", email=\"dana@example.com\", phone=\"123-987-6543\", billing_rate=85, total_hours_entered=15, total_amount_billed=1275)\n\n# Test data for Timesheet\ntimesheet1 = Timesheet(id=1, task_id=1, person_id=1, date_worked=date(2023, 1, 10), hours_worked=5, month=1, year=2023, billing_rate=50, total_amount_billed=250)\ntimesheet2 = Timesheet(id=2, task_id=1, person_id=2, date_worked=date(2023, 1, 12), hours_worked=4, month=1, year=2023, billing_rate=75, total_amount_billed=300)\ntimesheet3 = Timesheet(id=3, task_id=2, person_id=3, date_worked=date(2023, 2, 15), hours_worked=8, month=2, year=2023, billing_rate=60, total_amount_billed=480)\ntimesheet4 = Timesheet(id=4, task_id=3, person_id=4, date_worked=date(2023, 3, 20), hours_worked=7, month=3, year=2023, billing_rate=85, total_amount_billed=595)\n\n# Test data for Payment\npayment1 = Payment(id=1, invoice_id=1, payment_amount=1000, payment_date=date(2023, 4, 1), notes=\"First payment\")\npayment2 = Payment(id=2, invoice_id=2, payment_amount=1000, payment_date=date(2023, 4, 5), notes=\"Full settlement\")\npayment3 = Payment(id=3, invoice_id=3, payment_amount=500, payment_date=date(2023, 4, 10), notes=\"Partial payment\")\npayment4 = Payment(id=4, invoice_id=4, payment_amount=2000, payment_date=date(2023, 4, 15), notes=\"Advance payment\")",
182
+ "test_data_rows": [
183
+ {
184
+ "test_data_row_variable": "client1",
185
+ "code": "client1 = Client(id=1, name=\"Acme Corp\", email=\"acme@acme.com\", phone=\"123-456-7890\", total_hours=20, total_amount=5000, budget_amount=10000)"
186
+ },
187
+ {
188
+ "test_data_row_variable": "client2",
189
+ "code": "client2 = Client(id=2, name=\"Beta LLC\", email=\"beta@beta.com\", phone=\"987-654-3210\", total_hours=15, total_amount=3000, budget_amount=5000)"
190
+ },
191
+ {
192
+ "test_data_row_variable": "client3",
193
+ "code": "client3 = Client(id=3, name=\"Gamma Industries\", email=\"gamma@gamma.com\", phone=\"456-123-6789\", total_hours=30, total_amount=12000, budget_amount=15000)"
194
+ },
195
+ {
196
+ "test_data_row_variable": "client4",
197
+ "code": "client4 = Client(id=4, name=\"Delta Services\", email=\"delta@delta.com\", phone=\"789-321-6540\", total_hours=45, total_amount=9000, budget_amount=20000)"
198
+ },
199
+ {
200
+ "test_data_row_variable": "project1",
201
+ "code": "project1 = Project(id=1, client_id=1, name=\"Project X\", total_project_hours=50, total_project_amount=8000, project_budget_amount=10000)"
202
+ },
203
+ {
204
+ "test_data_row_variable": "project2",
205
+ "code": "project2 = Project(id=2, client_id=1, name=\"Project Y\", total_project_hours=25, total_project_amount=4000, project_budget_amount=7000)"
206
+ },
207
+ {
208
+ "test_data_row_variable": "project3",
209
+ "code": "project3 = Project(id=3, client_id=2, name=\"Project Z\", total_project_hours=30, total_project_amount=3000, project_budget_amount=4000)"
210
+ },
211
+ {
212
+ "test_data_row_variable": "project4",
213
+ "code": "project4 = Project(id=4, client_id=3, name=\"Project Alpha\", total_project_hours=60, total_project_amount=15000, project_budget_amount=20000)"
214
+ },
215
+ {
216
+ "test_data_row_variable": "invoice1",
217
+ "code": "invoice1 = Invoice(id=1, project_id=1, invoice_date=date(2023, 2, 15), invoice_amount=5000, payment_total=3000, invoice_balance=2000)"
218
+ },
219
+ {
220
+ "test_data_row_variable": "invoice2",
221
+ "code": "invoice2 = Invoice(id=2, project_id=2, invoice_date=date(2023, 3, 20), invoice_amount=1000, payment_total=1000, invoice_balance=0)"
222
+ },
223
+ {
224
+ "test_data_row_variable": "invoice3",
225
+ "code": "invoice3 = Invoice(id=3, project_id=3, invoice_date=date(2023, 4, 11), invoice_amount=2000, payment_total=1500, invoice_balance=500)"
226
+ },
227
+ {
228
+ "test_data_row_variable": "invoice4",
229
+ "code": "invoice4 = Invoice(id=4, project_id=4, invoice_date=date(2023, 5, 9), invoice_amount=7000, payment_total=5000, invoice_balance=2000)"
230
+ },
231
+ {
232
+ "test_data_row_variable": "task1",
233
+ "code": "task1 = Task(id=1, project_id=1, name=\"Design Phase\", description=\"Initial design work\", total_task_hours_worked=15, total_task_amount_billed=1500, task_budget_hours=20)"
234
+ },
235
+ {
236
+ "test_data_row_variable": "task2",
237
+ "code": "task2 = Task(id=2, project_id=2, name=\"Development Phase\", description=\"Coding and implementation\", total_task_hours_worked=30, total_task_amount_billed=3000, task_budget_hours=40)"
238
+ },
239
+ {
240
+ "test_data_row_variable": "task3",
241
+ "code": "task3 = Task(id=3, project_id=3, name=\"Testing Phase\", description=\"QA and testing\", total_task_hours_worked=10, total_task_amount_billed=1000, task_budget_hours=15)"
242
+ },
243
+ {
244
+ "test_data_row_variable": "task4",
245
+ "code": "task4 = Task(id=4, project_id=4, name=\"Deployment Phase\", description=\"Deployment and support\", total_task_hours_worked=20, total_task_amount_billed=2000, task_budget_hours=25)"
246
+ },
247
+ {
248
+ "test_data_row_variable": "person1",
249
+ "code": "person1 = Person(id=1, client_id=1, name=\"Alice Smith\", email=\"alice@example.com\", phone=\"111-222-3333\", billing_rate=50, total_hours_entered=10, total_amount_billed=500)"
250
+ },
251
+ {
252
+ "test_data_row_variable": "person2",
253
+ "code": "person2 = Person(id=2, client_id=2, name=\"Bob Brown\", email=\"bob@example.com\", phone=\"444-555-6666\", billing_rate=75, total_hours_entered=8, total_amount_billed=600)"
254
+ },
255
+ {
256
+ "test_data_row_variable": "person3",
257
+ "code": "person3 = Person(id=3, client_id=3, name=\"Charlie Johnson\", email=\"charlie@example.com\", phone=\"777-888-9999\", billing_rate=60, total_hours_entered=12, total_amount_billed=720)"
258
+ },
259
+ {
260
+ "test_data_row_variable": "person4",
261
+ "code": "person4 = Person(id=4, client_id=4, name=\"Dana White\", email=\"dana@example.com\", phone=\"123-987-6543\", billing_rate=85, total_hours_entered=15, total_amount_billed=1275)"
262
+ },
263
+ {
264
+ "test_data_row_variable": "timesheet1",
265
+ "code": "timesheet1 = Timesheet(id=1, task_id=1, person_id=1, date_worked=date(2023, 1, 10), hours_worked=5, month=1, year=2023, billing_rate=50, total_amount_billed=250)"
266
+ },
267
+ {
268
+ "test_data_row_variable": "timesheet2",
269
+ "code": "timesheet2 = Timesheet(id=2, task_id=1, person_id=2, date_worked=date(2023, 1, 12), hours_worked=4, month=1, year=2023, billing_rate=75, total_amount_billed=300)"
270
+ },
271
+ {
272
+ "test_data_row_variable": "timesheet3",
273
+ "code": "timesheet3 = Timesheet(id=3, task_id=2, person_id=3, date_worked=date(2023, 2, 15), hours_worked=8, month=2, year=2023, billing_rate=60, total_amount_billed=480)"
274
+ },
275
+ {
276
+ "test_data_row_variable": "timesheet4",
277
+ "code": "timesheet4 = Timesheet(id=4, task_id=3, person_id=4, date_worked=date(2023, 3, 20), hours_worked=7, month=3, year=2023, billing_rate=85, total_amount_billed=595)"
278
+ },
279
+ {
280
+ "test_data_row_variable": "payment1",
281
+ "code": "payment1 = Payment(id=1, invoice_id=1, payment_amount=1000, payment_date=date(2023, 4, 1), notes=\"First payment\")"
282
+ },
283
+ {
284
+ "test_data_row_variable": "payment2",
285
+ "code": "payment2 = Payment(id=2, invoice_id=2, payment_amount=1000, payment_date=date(2023, 4, 5), notes=\"Full settlement\")"
286
+ },
287
+ {
288
+ "test_data_row_variable": "payment3",
289
+ "code": "payment3 = Payment(id=3, invoice_id=3, payment_amount=500, payment_date=date(2023, 4, 10), notes=\"Partial payment\")"
290
+ },
291
+ {
292
+ "test_data_row_variable": "payment4",
293
+ "code": "payment4 = Payment(id=4, invoice_id=4, payment_amount=2000, payment_date=date(2023, 4, 15), notes=\"Advance payment\")"
294
+ }
295
+ ],
296
+ "test_data_sqlite": "CREATE TABLE client (\n id INTEGER PRIMARY KEY,\n name TEXT NOT NULL,\n email TEXT NOT NULL,\n phone TEXT NOT NULL,\n total_hours DECIMAL(10,2) DEFAULT 0,\n total_amount DECIMAL(10,2) DEFAULT 0,\n budget_amount DECIMAL(10,2) DEFAULT 0,\n is_over_budget BOOLEAN DEFAULT FALSE\n);\n\nINSERT INTO client (id, name, email, phone, total_hours, total_amount, budget_amount, is_over_budget)\nVALUES (1, 'Acme Corp', 'acme@acme.com', '123-456-7890', 20, 5000, 10000, 0),\n (2, 'Beta LLC', 'beta@beta.com', '987-654-3210', 15, 3000, 5000, 0),\n (3, 'Gamma Industries', 'gamma@gamma.com', '456-123-6789', 30, 12000, 15000, 0),\n (4, 'Delta Services', 'delta@delta.com', '789-321-6540', 45, 9000, 20000, 0);\n\nCREATE TABLE project (\n id INTEGER PRIMARY KEY,\n client_id INTEGER,\n name TEXT NOT NULL,\n total_project_hours DECIMAL(10,2) DEFAULT 0,\n total_project_amount DECIMAL(10,2) DEFAULT 0,\n project_budget_amount DECIMAL(10,2) DEFAULT 0,\n is_over_budget BOOLEAN DEFAULT FALSE,\n FOREIGN KEY(client_id) REFERENCES client(id)\n);\n\nINSERT INTO project (id, client_id, name, total_project_hours, total_project_amount, project_budget_amount, is_over_budget)\nVALUES (1, 1, 'Project X', 50, 8000, 10000, 0),\n (2, 1, 'Project Y', 25, 4000, 7000, 0),\n (3, 2, 'Project Z', 30, 3000, 4000, 0),\n (4, 3, 'Project Alpha', 60, 15000, 20000, 0);\n\nCREATE TABLE invoice (\n id INTEGER PRIMARY KEY,\n project_id INTEGER,\n invoice_date DATE NOT NULL,\n invoice_amount DECIMAL(10,2) DEFAULT 0,\n payment_total DECIMAL(10,2) DEFAULT 0,\n invoice_balance DECIMAL(10,2) DEFAULT 0,\n is_paid BOOLEAN DEFAULT FALSE,\n FOREIGN KEY(project_id) REFERENCES project(id)\n);\n\nINSERT INTO invoice (id, project_id, invoice_date, invoice_amount, payment_total, invoice_balance, is_paid)\nVALUES (1, 1, '2023-02-15', 5000, 3000, 2000, 0),\n (2, 2, '2023-03-20', 1000, 1000, 0, 1),\n (3, 3, '2023-04-11', 2000, 1500, 500, 0),\n (4, 4, '2023-05-09', 7000, 5000, 2000, 0);\n\nCREATE TABLE task (\n id INTEGER PRIMARY KEY,\n project_id INTEGER,\n name TEXT NOT NULL,\n description TEXT,\n total_task_hours_worked DECIMAL(10,2) DEFAULT 0,\n total_task_amount_billed DECIMAL(10,2) DEFAULT 0,\n task_budget_hours DECIMAL(10,2) DEFAULT 0,\n is_over_budget BOOLEAN DEFAULT FALSE,\n invoice_id INTEGER,\n FOREIGN KEY(project_id) REFERENCES project(id),\n FOREIGN KEY(invoice_id) REFERENCES invoice(id)\n);\n\nINSERT INTO task (id, project_id, name, description, total_task_hours_worked, total_task_amount_billed, task_budget_hours, is_over_budget, invoice_id)\nVALUES (1, 1, 'Design Phase', 'Initial design work', 15, 1500, 20, 0, NULL),\n (2, 2, 'Development Phase', 'Coding and implementation', 30, 3000, 40, 0, NULL),\n (3, 3, 'Testing Phase', 'QA and testing', 10, 1000, 15, 0, NULL),\n (4, 4, 'Deployment Phase', 'Deployment and support', 20, 2000, 25, 0, NULL);\n\nCREATE TABLE person (\n id INTEGER PRIMARY KEY,\n client_id INTEGER,\n name TEXT NOT NULL,\n email TEXT NOT NULL,\n phone TEXT NOT NULL,\n billing_rate DECIMAL(10,2) DEFAULT 0,\n total_hours_entered DECIMAL(10,2) DEFAULT 0,\n total_amount_billed DECIMAL(10,2) DEFAULT 0,\n FOREIGN KEY(client_id) REFERENCES client(id)\n);\n\nINSERT INTO person (id, client_id, name, email, phone, billing_rate, total_hours_entered, total_amount_billed)\nVALUES (1, 1, 'Alice Smith', 'alice@example.com', '111-222-3333', 50, 10, 500),\n (2, 2, 'Bob Brown', 'bob@example.com', '444-555-6666', 75, 8, 600),\n (3, 3, 'Charlie Johnson', 'charlie@example.com', '777-888-9999', 60, 12, 720),\n (4, 4, 'Dana White', 'dana@example.com', '123-987-6543', 85, 15, 1275);\n\nCREATE TABLE timesheet (\n id INTEGER PRIMARY KEY,\n task_id INTEGER,\n person_id INTEGER,\n date_worked DATE NOT NULL,\n hours_worked DECIMAL(10,2) DEFAULT 0,\n month INTEGER,\n year INTEGER,\n billing_rate DECIMAL(10,2) DEFAULT 0,\n total_amount_billed DECIMAL(10,2) DEFAULT 0,\n FOREIGN KEY(task_id) REFERENCES task(id),\n FOREIGN KEY(person_id) REFERENCES person(id)\n);\n\nINSERT INTO timesheet (id, task_id, person_id, date_worked, hours_worked, month, year, billing_rate, total_amount_billed)\nVALUES (1, 1, 1, '2023-01-10', 5, 1, 2023, 50, 250),\n (2, 1, 2, '2023-01-12', 4, 1, 2023, 75, 300),\n (3, 2, 3, '2023-02-15', 8, 2, 2023, 60, 480),\n (4, 3, 4, '2023-03-20', 7, 3, 2023, 85, 595);\n\nCREATE TABLE payment (\n id INTEGER PRIMARY KEY,\n invoice_id INTEGER,\n payment_amount DECIMAL(10,2) DEFAULT 0,\n payment_date DATE NOT NULL,\n notes TEXT,\n FOREIGN KEY(invoice_id) REFERENCES invoice(id)\n);\n\nINSERT INTO payment (id, invoice_id, payment_amount, payment_date, notes)\nVALUES (1, 1, 1000, '2023-04-01', 'First payment'),\n (2, 2, 1000, '2023-04-05', 'Full settlement'),\n (3, 3, 500, '2023-04-10', 'Partial payment'),\n (4, 4, 2000, '2023-04-15', 'Advance payment');",
297
+ "name": "Time_Tracker_and_Billing_System"
298
+ }
@@ -0,0 +1,8 @@
1
+ This example illustrates that it's often a good idea to be more specific in the prompt,
2
+ for example to specify exact table and column names. Here, we create a time-tracking system, being specific about tables and columns in the [002_create_db_models.prompt](./).
3
+
4
+ To create this system:
5
+ ```bash
6
+ # create the time_tracking system
7
+ als genai --project-name=track --using=system/genai/examples/time_tracking_billing/002_create_db_models.prompt
8
+ ```
@@ -113,7 +113,7 @@ class Rule:
113
113
  """
114
114
  Copy declares child column copied from parent column.
115
115
 
116
- Example
116
+ Example:
117
117
  Prompt
118
118
  Store the Item.unit_price as a copy from Product.unit_price
119
119
  Response
@@ -190,7 +190,6 @@ Response is to create 2 rules - a derivation and a constraint, as follows:
190
190
  Intermediate sum/count values also work for counts. For example:
191
191
 
192
192
  Prompt:
193
-
194
193
  A airplane cannot have more passengers than its seating capacity.
195
194
 
196
195
  Response is to create 2 rules - a count derivation and a constraint, as follows:
@@ -212,12 +211,11 @@ Response is to create 2 rules - a derivation and a constraint, as follows:
212
211
  Rule.sum(derive=Employee.skill_rating_total, as_sum_of=EmployeeSkill.rating)
213
212
  And, be sure to create the second Rule:
214
213
  Rule.Formula(derive=Employee.skill_summary,
215
- as_condition=lambda row: row.skill_rating_total + 2 * row.years_of_service)
214
+ as_expression=lambda row: row.skill_rating_total + 2 * row.years_of_service)
216
215
 
217
216
 
218
217
  Prompt:
219
-
220
- A student cannot be an honor student unless they have mre than 2 service activities.
218
+ A student cannot be an honor student unless they have more than 2 service activities.
221
219
 
222
220
  Response is to create 2 rules - a count derivation and a constraint, as follows:
223
221
  First Rule to Create:
@@ -230,7 +228,6 @@ Response is to create 2 rules - a count derivation and a constraint, as follows:
230
228
  Here is an equivalent request:
231
229
 
232
230
  Prompt:
233
-
234
231
  A airplane's passengers must be less than its seating capacity.
235
232
 
236
233
  Response is to create 2 rules - a count derivation and a constraint, as follows:
@@ -244,20 +241,20 @@ Response is to create 2 rules - a count derivation and a constraint, as follows:
244
241
 
245
242
  For "more than" constraints, create columns with count rules:
246
243
 
247
- Prompt Reject Employees with more than 3 Felonies.
244
+ Prompt: Reject Employees with more than 3 Felonies.
248
245
 
249
246
  Response:
250
247
  First Rule is to create:
251
248
  Rule.count(derive=Employee.felony_count, as_count_of=Felonies)
252
249
  And, be sure to create the contraint rule:
253
250
  Rule.constraint(validate=Employee,
254
- as_condition=lambda row: row.felony_count>3,
251
+ as_condition=lambda row: row.felony_count<=3,
255
252
  error_msg="Employee has excessive Felonies")
256
253
 
257
254
 
258
255
  For "any" constraints, create columns with count rules:
259
256
 
260
- Prompt Reject Employees with any class 5 Felonies or more than 3 Felonies.
257
+ Prompt: Reject Employees with any class 5 Felonies or more than 3 Felonies.
261
258
 
262
259
  Response:
263
260
  First Rule is to create:
@@ -265,7 +262,7 @@ Response:
265
262
  Rule.count(derive=Employee.felony_count, as_count_of=Felonies)
266
263
  And, be sure to create the contraint rule:
267
264
  Rule.constraint(validate=Employee,
268
- as_condition=lambda row: row.class_5_felony_count > 0 or row.felony_count>3,
265
+ as_condition=lambda row: row.class_5_felony_count == 0 and row.felony_count<=3,
269
266
  error_msg="Employee has excessive Felonies")
270
267
 
271
268
  Formulas can reference parent values in 2 versions - choose formula vs copy as follows:
@@ -278,6 +275,13 @@ Formulas can reference parent values in 2 versions - choose formula vs copy as f
278
275
  Response
279
276
  Rule.copy(derive=Item.ready, from_parent=Order.ready)
280
277
 
278
+ Formulas can use Python conditions:
279
+ Prompt: Item amount is price * quantity, with a 10% discount for gold products
280
+ Response:
281
+ Rule.Formula(derive=Item.amount,
282
+ as_expression=lambda row: row.price * row.quantity if row.gold else .9 * row.price * row.quantity)
283
+ If the attributes are decimal, use the form Decimal('0.9')
284
+
281
285
  Sum and Count where clauses:
282
286
  1. must not restate the foreign key / primary key matchings
283
287
  2. Can only reference child attributes
@@ -1 +1,2 @@
1
- Update the prior response - be sure not to lose classes and test data already created.
1
+ Update the prior response - be sure not to lose classes, rules and test data already created.
2
+ If there is more than one derivation for the same column, use the last one provided.
@@ -1 +1 @@
1
- Project created as nw+ (nw, no customizations)
1
+ Project created as nw- (nw, no customizations)
@@ -0,0 +1,9 @@
1
+ <div fxLayout="row" fxLayoutAlign="center start" fxFlexFill class="container">
2
+ <o-tree #tree service="{{ service }}" entity="{{ entity }}"
3
+ keys="{{ keys }}" root-title="{{ entity }}" columns="{{ columns }}"
4
+ visible-columns="{{ favorite }}" route=":{{ keys }}" fxFlex="20">
5
+ </o-tree>
6
+ <div fxLayout="column" fxLayoutAlign="center stretch" fxFlex="80">
7
+ <router-outlet></router-outlet>
8
+ </div>
9
+ </div>
@@ -0,0 +1,32 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { RouterModule, Routes } from '@angular/router';
3
+ import { {{ entity_first_cap }}HomeComponent } from './home/{{ entity }}-home.component';
4
+ import { {{ entity_first_cap }}NewComponent } from './new/{{ entity }}-new.component';
5
+ import { {{ entity_first_cap }}DetailComponent } from './detail/{{ entity }}-detail.component';
6
+
7
+ const routes: Routes = [
8
+ {path: '', component: {{ entity_first_cap }}HomeComponent,
9
+ children: [
10
+ { path: 'new', component: {{ entity_first_cap }}NewComponent },
11
+ { path: ':{{ keyPath }}', component: {{ entity_first_cap }}DetailComponent,
12
+ data: {
13
+ oPermission: {
14
+ permissionId: '{{ entity }}-detail-permissions'
15
+ }
16
+ }
17
+ }{{ additional_routes }}
18
+ ]}
19
+ ];
20
+
21
+ export const {{ entity_upper}}_MODULE_DECLARATIONS = [
22
+ {{ entity_first_cap }}HomeComponent,
23
+ {{ entity_first_cap }}NewComponent,
24
+ {{ entity_first_cap }}DetailComponent
25
+ ];
26
+
27
+
28
+ @NgModule({
29
+ imports: [RouterModule.forChild(routes)],
30
+ exports: [RouterModule]
31
+ })
32
+ export class {{ entity_first_cap }}RoutingModule { }
@@ -1179,7 +1179,8 @@ else:
1179
1179
  render_coltype = not dedicated_fks or any(fk.column is column for fk in dedicated_fks)
1180
1180
  if 'DataTypes.char_type DEBUG ONLY' == str(column):
1181
1181
  debug_stop = "Debug Stop: Column" # char_type = Column(CHAR(1, 'SQL_Latin1_General_CP1_CI_AS'))
1182
-
1182
+ if str(column) in ['Credit_limit', 'credit_limit']:
1183
+ debug_stop = "Debug Stop: Column"
1183
1184
  if column.key != column.name:
1184
1185
  kwarg.append('key')
1185
1186
  if column.primary_key:
@@ -9,7 +9,7 @@ from importlib import import_module
9
9
  from pathlib import Path
10
10
  from werkzeug.utils import secure_filename
11
11
  from database.models import *
12
- from logic_bank.logic_bank import DeclareRule, Rule, LogicBank
12
+ from logic_bank.logic_bank import Rule, LogicBank
13
13
  from colorama import Fore, Style, init
14
14
  from logic_bank.logic_bank import RuleBank
15
15
  from logic_bank.rule_bank.rule_bank_setup import find_referenced_attributes