diff --git a/api/__pycache__/settings.cpython-313.pyc b/api/__pycache__/settings.cpython-313.pyc index 2274696f..96e8ce74 100644 Binary files a/api/__pycache__/settings.cpython-313.pyc and b/api/__pycache__/settings.cpython-313.pyc differ diff --git a/app/__pycache__/models.cpython-313.pyc b/app/__pycache__/models.cpython-313.pyc index f4a43330..f52d7a2d 100644 Binary files a/app/__pycache__/models.cpython-313.pyc and b/app/__pycache__/models.cpython-313.pyc differ diff --git a/app/__pycache__/workflow_utils.cpython-313.pyc b/app/__pycache__/workflow_utils.cpython-313.pyc index 0f4ac96b..c87b238e 100644 Binary files a/app/__pycache__/workflow_utils.cpython-313.pyc and b/app/__pycache__/workflow_utils.cpython-313.pyc differ diff --git a/app/migrations/0351_remove_transaction_detail_amount_recived.py b/app/migrations/0351_remove_transaction_detail_amount_recived.py new file mode 100644 index 00000000..ffe785b8 --- /dev/null +++ b/app/migrations/0351_remove_transaction_detail_amount_recived.py @@ -0,0 +1,17 @@ +# Generated by Django 5.1.7 on 2026-01-08 16:56 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('app', '0350_transaction_current'), + ] + + operations = [ + migrations.RemoveField( + model_name='transaction_detail', + name='amount_recived', + ), + ] diff --git a/app/models.py b/app/models.py index 428828c8..7eebb309 100644 --- a/app/models.py +++ b/app/models.py @@ -1390,7 +1390,6 @@ class Transaction_Detail(AutoCodeModel): status = models.ForeignKey(Transaction_Status, null=True, related_name='+', on_delete=models.PROTECT, default=1) approver = models.ForeignKey(User, null=True, related_name='+', on_delete=models.PROTECT) approve_time = models.DateTimeField(null=True) - amount_recived = models.DecimalField(max_digits=15, decimal_places=2, null=True) create_time = models.DateTimeField(null=True, auto_now_add=True) update_time = models.DateTimeField(null=True, auto_now=True) diff --git a/app/workflow_utils.py b/app/workflow_utils.py index 54424e5e..3b160130 100644 --- a/app/workflow_utils.py +++ b/app/workflow_utils.py @@ -86,6 +86,48 @@ def resolve_value(expr, context): target_list.append(element_to_append) return target_list + # ============================================= + # 2.2. Hàm tổng hợp list: $agg(list, operation, field?) + # ============================================= + agg_match = re.match(r"^\$agg\(([^,]+),\s*'([^']+)'(?:,\s*['\"]?([^'\"]+)['\"]?)?\)$", expr.strip()) + if agg_match: + list_expr = agg_match.group(1).strip() + operation = agg_match.group(2).strip() + field_expr = agg_match.group(3).strip() if agg_match.group(3) else None + + # 1. Resolve the list + target_list = resolve_value(list_expr, context) + if target_list is None: + target_list = [] + + if not isinstance(target_list, list): + return 0 + + # 2. Perform operation + if operation == 'count': + return len(target_list) + + if operation == 'sum': + if not field_expr: + return 0 + + total = 0 + for item in target_list: + value = 0 + if isinstance(item, dict): + value = item.get(field_expr) + else: + value = getattr(item, field_expr, 0) + + try: + total += float(value or 0) + except (ValueError, TypeError): + pass + return total + + print(f" [ERROR] Unknown $agg operation: {operation}") + return 0 + # ============================================= # 3. Helper: Lấy giá trị từ context theo đường dẫn dotted # ============================================= diff --git a/static/contract/TTTHNVCN_371_1767901475.docx b/static/contract/TTTHNVCN_371_1767901475.docx new file mode 100644 index 00000000..7b331c4e Binary files /dev/null and b/static/contract/TTTHNVCN_371_1767901475.docx differ diff --git a/static/contract/TTTHNVCN_371_1767901475.pdf b/static/contract/TTTHNVCN_371_1767901475.pdf new file mode 100644 index 00000000..109c01c8 Binary files /dev/null and b/static/contract/TTTHNVCN_371_1767901475.pdf differ diff --git a/static/contract/TTTHNVCN_373_1767901599.docx b/static/contract/TTTHNVCN_373_1767901599.docx new file mode 100644 index 00000000..ee98525b Binary files /dev/null and b/static/contract/TTTHNVCN_373_1767901599.docx differ diff --git a/static/contract/TTTHNVCN_373_1767901599.pdf b/static/contract/TTTHNVCN_373_1767901599.pdf new file mode 100644 index 00000000..8773b25e Binary files /dev/null and b/static/contract/TTTHNVCN_373_1767901599.pdf differ