|
|
@@ -40,6 +40,7 @@ from app.services.bx.reimburse_import import (
|
|
|
load_applicant_options,
|
|
|
load_expense_nodes_flat,
|
|
|
)
|
|
|
+from app.services.bx.reimburse_list_filters import build_reimburse_column_filters
|
|
|
from app.utils.bx_codegen import generate_apply_code, generate_title, parse_optional_date
|
|
|
from app.utils.bx_date_range import append_create_time_filters
|
|
|
|
|
|
@@ -63,34 +64,27 @@ REIMBURSE_EXPORT_COLUMNS = [
|
|
|
|
|
|
|
|
|
def _reimburse_list_filters(body: BxApplyListExportBody, db: Session, tenant_no: str) -> list:
|
|
|
- filters = []
|
|
|
- if body.status:
|
|
|
- filters.append(BxReimburseApply.status == body.status)
|
|
|
- if body.keyword:
|
|
|
- filters.append(
|
|
|
- or_(
|
|
|
- BxReimburseApply.apply_code.contains(body.keyword),
|
|
|
- BxReimburseApply.applicant_name.contains(body.keyword),
|
|
|
- BxReimburseApply.title.contains(body.keyword),
|
|
|
- )
|
|
|
- )
|
|
|
- if body.expense_id:
|
|
|
- filters.append(BxReimburseApply.expense_id == str(body.expense_id).strip())
|
|
|
- expense_filter = ReimburseService.build_expense_name_condition(db, tenant_no, body.expense_name)
|
|
|
- if expense_filter is not None:
|
|
|
- filters.append(expense_filter)
|
|
|
- if body.applicant_id:
|
|
|
- filters.append(BxReimburseApply.applicant_id == str(body.applicant_id).strip())
|
|
|
- if body.ids:
|
|
|
- filters.append(BxReimburseApply.id.in_([str(i) for i in body.ids]))
|
|
|
- append_create_time_filters(
|
|
|
- filters,
|
|
|
- BxReimburseApply,
|
|
|
+ return build_reimburse_column_filters(
|
|
|
+ db=db,
|
|
|
+ tenant_no=tenant_no,
|
|
|
+ keyword=body.keyword or "",
|
|
|
+ status=body.status,
|
|
|
+ status_in=body.status_in,
|
|
|
+ apply_code=body.apply_code,
|
|
|
+ title=body.title,
|
|
|
+ expense_name=body.expense_name,
|
|
|
+ expense_id=body.expense_id,
|
|
|
+ applicant_id=body.applicant_id,
|
|
|
+ current_node=body.current_node,
|
|
|
+ amount_op=body.amount_op,
|
|
|
+ amount=body.amount,
|
|
|
+ amount_min=body.amount_min,
|
|
|
+ amount_max=body.amount_max,
|
|
|
apply_date=body.apply_date,
|
|
|
apply_date_from=body.apply_date_from,
|
|
|
apply_date_to=body.apply_date_to,
|
|
|
+ ids=body.ids,
|
|
|
)
|
|
|
- return filters
|
|
|
|
|
|
|
|
|
def _export_reimburse_rows(db: Session, tenant_no: str, rows) -> list:
|
|
|
@@ -252,6 +246,14 @@ def my_reimburses(
|
|
|
status: Optional[str] = None,
|
|
|
keyword: str = "",
|
|
|
expenseName: Optional[str] = None,
|
|
|
+ applyCode: Optional[str] = None,
|
|
|
+ title: Optional[str] = None,
|
|
|
+ currentNode: Optional[str] = None,
|
|
|
+ statusIn: Optional[str] = None,
|
|
|
+ amountOp: Optional[str] = None,
|
|
|
+ amount: Optional[str] = None,
|
|
|
+ amountMin: Optional[str] = None,
|
|
|
+ amountMax: Optional[str] = None,
|
|
|
applyDate: Optional[str] = None,
|
|
|
applyDateFrom: Optional[str] = None,
|
|
|
applyDateTo: Optional[str] = None,
|
|
|
@@ -265,25 +267,25 @@ def my_reimburses(
|
|
|
BxReimburseApply.create_by == user.id,
|
|
|
)
|
|
|
]
|
|
|
- if status:
|
|
|
- filters.append(BxReimburseApply.status == status)
|
|
|
- if keyword:
|
|
|
- filters.append(
|
|
|
- or_(
|
|
|
- BxReimburseApply.apply_code.contains(keyword),
|
|
|
- BxReimburseApply.applicant_name.contains(keyword),
|
|
|
- BxReimburseApply.title.contains(keyword),
|
|
|
- )
|
|
|
+ filters.extend(
|
|
|
+ build_reimburse_column_filters(
|
|
|
+ db=db,
|
|
|
+ tenant_no=tenant_no,
|
|
|
+ keyword=keyword or "",
|
|
|
+ status=status,
|
|
|
+ status_in=statusIn,
|
|
|
+ apply_code=applyCode,
|
|
|
+ title=title,
|
|
|
+ expense_name=expenseName,
|
|
|
+ current_node=currentNode,
|
|
|
+ amount_op=amountOp,
|
|
|
+ amount=amount,
|
|
|
+ amount_min=amountMin,
|
|
|
+ amount_max=amountMax,
|
|
|
+ apply_date=applyDate,
|
|
|
+ apply_date_from=applyDateFrom,
|
|
|
+ apply_date_to=applyDateTo,
|
|
|
)
|
|
|
- expense_filter = ReimburseService.build_expense_name_condition(db, tenant_no, expenseName)
|
|
|
- if expense_filter is not None:
|
|
|
- filters.append(expense_filter)
|
|
|
- append_create_time_filters(
|
|
|
- filters,
|
|
|
- BxReimburseApply,
|
|
|
- apply_date=applyDate,
|
|
|
- apply_date_from=applyDateFrom,
|
|
|
- apply_date_to=applyDateTo,
|
|
|
)
|
|
|
rows, total = ReimburseService.get_paged(db, tenant_no, page=page, page_size=pageSize, filters=filters, user=user)
|
|
|
out_rows = ReimburseService.out_rows_with_attachment_counts(db, tenant_no, list(rows))
|