fix(pl): hide non-ETC vehicle recharge rows in list and get APIs
Force etc on reads so historical fuel data stays in DB but out of this module. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
542ecc63e7
commit
27d69f1af9
1 file changed
+9
-2
@@ -27,6 +27,9 @@ from app.schemas.pl.vehicle_recharge import (
|
||||
)
|
||||
from app.services.pl_data_scope import apply_pl_scope, assert_pl_row_in_scope
|
||||
|
||||
# 本期本模块仅服务 ETC;历史 fuel 行保留但不暴露
|
||||
MODULE_RECHARGE_TYPE = "etc"
|
||||
|
||||
|
||||
def _generate_seq_no(
|
||||
db: Session, model, column_attr: str, prefix: str, *, seq_width: int = 6
|
||||
@@ -117,6 +120,7 @@ def _get_apply_row(
|
||||
PlVehicleRechargeApply.id == apply_id,
|
||||
PlVehicleRechargeApply.tenant_no == tenant_no,
|
||||
PlVehicleRechargeApply.del_flag == 0,
|
||||
PlVehicleRechargeApply.recharge_type == MODULE_RECHARGE_TYPE,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
@@ -135,6 +139,7 @@ def _get_record_row(
|
||||
PlVehicleRechargeRecord.id == record_id,
|
||||
PlVehicleRechargeRecord.tenant_no == tenant_no,
|
||||
PlVehicleRechargeRecord.del_flag == 0,
|
||||
PlVehicleRechargeRecord.recharge_type == MODULE_RECHARGE_TYPE,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
@@ -269,6 +274,7 @@ def list_applies(
|
||||
query = db.query(PlVehicleRechargeApply).filter(
|
||||
PlVehicleRechargeApply.tenant_no == tenant_no,
|
||||
PlVehicleRechargeApply.del_flag == 0,
|
||||
PlVehicleRechargeApply.recharge_type == MODULE_RECHARGE_TYPE,
|
||||
)
|
||||
if q:
|
||||
query = query.filter(
|
||||
@@ -418,6 +424,7 @@ def list_pending_apply_options(
|
||||
PlVehicleRechargeApply.tenant_no == tenant_no,
|
||||
PlVehicleRechargeApply.del_flag == 0,
|
||||
PlVehicleRechargeApply.status == "pending",
|
||||
PlVehicleRechargeApply.recharge_type == MODULE_RECHARGE_TYPE,
|
||||
)
|
||||
query = apply_pl_scope(query, PlVehicleRechargeApply, user, db, tenant_no)
|
||||
rows = query.order_by(PlVehicleRechargeApply.create_time.desc()).all()
|
||||
@@ -458,8 +465,7 @@ def list_records(
|
||||
func.coalesce(PlVehicleRechargeRecord.card_no, "").contains(q),
|
||||
)
|
||||
)
|
||||
if recharge_type:
|
||||
query = query.filter(PlVehicleRechargeRecord.recharge_type == recharge_type)
|
||||
query = query.filter(PlVehicleRechargeRecord.recharge_type == MODULE_RECHARGE_TYPE)
|
||||
if recharge_date_from:
|
||||
query = query.filter(PlVehicleRechargeRecord.recharge_date >= recharge_date_from)
|
||||
if recharge_date_to:
|
||||
@@ -547,6 +553,7 @@ def list_disburse_board(
|
||||
.filter(
|
||||
PlVehicleRechargeApply.tenant_no == tenant_no,
|
||||
PlVehicleRechargeApply.del_flag == 0,
|
||||
PlVehicleRechargeApply.recharge_type == MODULE_RECHARGE_TYPE,
|
||||
)
|
||||
)
|
||||
if q:
|
||||
|
||||
Reference in new issue
Block a user