changes
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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',
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -1390,7 +1390,6 @@ class Transaction_Detail(AutoCodeModel):
|
|||||||
status = models.ForeignKey(Transaction_Status, null=True, related_name='+', on_delete=models.PROTECT, default=1)
|
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)
|
approver = models.ForeignKey(User, null=True, related_name='+', on_delete=models.PROTECT)
|
||||||
approve_time = models.DateTimeField(null=True)
|
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)
|
create_time = models.DateTimeField(null=True, auto_now_add=True)
|
||||||
update_time = models.DateTimeField(null=True, auto_now=True)
|
update_time = models.DateTimeField(null=True, auto_now=True)
|
||||||
|
|
||||||
|
|||||||
@@ -86,6 +86,48 @@ def resolve_value(expr, context):
|
|||||||
target_list.append(element_to_append)
|
target_list.append(element_to_append)
|
||||||
return target_list
|
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
|
# 3. Helper: Lấy giá trị từ context theo đường dẫn dotted
|
||||||
# =============================================
|
# =============================================
|
||||||
|
|||||||
BIN
static/contract/TTTHNVCN_371_1767901475.docx
Normal file
BIN
static/contract/TTTHNVCN_371_1767901475.docx
Normal file
Binary file not shown.
BIN
static/contract/TTTHNVCN_371_1767901475.pdf
Normal file
BIN
static/contract/TTTHNVCN_371_1767901475.pdf
Normal file
Binary file not shown.
BIN
static/contract/TTTHNVCN_373_1767901599.docx
Normal file
BIN
static/contract/TTTHNVCN_373_1767901599.docx
Normal file
Binary file not shown.
BIN
static/contract/TTTHNVCN_373_1767901599.pdf
Normal file
BIN
static/contract/TTTHNVCN_373_1767901599.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user