提交
This commit is contained in:
1 parent
e6072457fd
commit
be4fab78e1
578 files changed
+174415
-214
No files matched your search
@@ -22,6 +22,7 @@ from app.models.models import (
|
||||
BizCollectionProtocol,
|
||||
BizProtocolAudit,
|
||||
BizProtocolCollectionInfo,
|
||||
BizProtocolFullmoonTodo,
|
||||
BizProtocolPartyCustomer,
|
||||
BizProtocolPayment,
|
||||
BizProtocolPaymentDetail,
|
||||
@@ -2215,3 +2216,107 @@ def upsert_storage_cert(
|
||||
db.commit()
|
||||
db.refresh(obj)
|
||||
return obj
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 子表:满月待办
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def _fullmoon_todo_to_dict(ft: BizProtocolFullmoonTodo) -> Dict[str, Any]:
|
||||
return {
|
||||
"id": ft.id,
|
||||
"collectionProtocolId": ft.collection_protocol_id,
|
||||
"todoStatus": ft.todo_status or "0",
|
||||
"handleDate": (ft.handle_date or "").strip() if ft.handle_date else "",
|
||||
"handleRemark": ft.handle_remark or "",
|
||||
"insuranceAttachments": ft.insurance_attachments or "",
|
||||
"insuranceCompanyId": ft.insurance_company_id or "",
|
||||
"insuranceCompanyName": ft.insurance_company_name or "",
|
||||
"insuranceType": ft.insurance_type or "",
|
||||
"insurancePolicyNo": ft.insurance_policy_no or "",
|
||||
"insuranceEffectiveDate": (ft.insurance_effective_date or "").strip() if ft.insurance_effective_date else "",
|
||||
"insuranceExpiryDate": (ft.insurance_expiry_date or "").strip() if ft.insurance_expiry_date else "",
|
||||
"insuranceSubscribed": ft.insurance_subscribed or "0",
|
||||
"insuranceFee": _dec(ft.insurance_fee),
|
||||
"tenantNo": ft.tenant_no,
|
||||
"orderNum": ft.order_num if ft.order_num is not None else 0,
|
||||
"remark": ft.remark or "",
|
||||
"createTime": _fmt_dt(ft.create_time),
|
||||
"updateTime": _fmt_dt(ft.update_time),
|
||||
}
|
||||
|
||||
|
||||
def get_fullmoon_todo(
|
||||
db: Session,
|
||||
collection_protocol_id: str,
|
||||
tenant_no: str,
|
||||
) -> Optional[BizProtocolFullmoonTodo]:
|
||||
return (
|
||||
db.query(BizProtocolFullmoonTodo)
|
||||
.filter(
|
||||
and_(
|
||||
BizProtocolFullmoonTodo.collection_protocol_id == collection_protocol_id,
|
||||
BizProtocolFullmoonTodo.tenant_no == tenant_no,
|
||||
BizProtocolFullmoonTodo.del_flag == 0,
|
||||
)
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
|
||||
def upsert_fullmoon_todo(
|
||||
db: Session,
|
||||
collection_protocol_id: str,
|
||||
tenant_no: str,
|
||||
user_id: Optional[str],
|
||||
**fields,
|
||||
) -> BizProtocolFullmoonTodo:
|
||||
fields = _normalize_fields(fields)
|
||||
obj = get_fullmoon_todo(db, collection_protocol_id, tenant_no)
|
||||
_STR_FIELDS = [
|
||||
"todo_status", "handle_date", "handle_remark",
|
||||
"insurance_attachments", "insurance_company_id",
|
||||
"insurance_company_name", "insurance_type",
|
||||
"insurance_policy_no", "insurance_effective_date",
|
||||
"insurance_expiry_date", "insurance_subscribed",
|
||||
]
|
||||
_DEC_FIELDS = ["insurance_fee"]
|
||||
if obj:
|
||||
for k in _STR_FIELDS:
|
||||
if k in fields:
|
||||
setattr(obj, k, (fields[k] or "").strip() or None)
|
||||
for k in _DEC_FIELDS:
|
||||
if k in fields and fields[k] is not None:
|
||||
setattr(obj, k, Decimal(str(fields[k])))
|
||||
if "remark" in fields:
|
||||
obj.remark = (fields["remark"] or "").strip() or None
|
||||
obj.update_by = user_id
|
||||
obj.update_time = datetime.now()
|
||||
db.add(obj)
|
||||
db.commit()
|
||||
db.refresh(obj)
|
||||
return obj
|
||||
obj = BizProtocolFullmoonTodo(
|
||||
id=generate_uuid(),
|
||||
collection_protocol_id=collection_protocol_id,
|
||||
tenant_no=tenant_no,
|
||||
order_num=0,
|
||||
remark=(fields.get("remark") or "").strip() or None,
|
||||
create_by=user_id,
|
||||
create_dept_id="",
|
||||
create_time=datetime.now(),
|
||||
update_by=user_id,
|
||||
update_time=datetime.now(),
|
||||
del_flag=0,
|
||||
)
|
||||
for k in _STR_FIELDS:
|
||||
if k in fields:
|
||||
setattr(obj, k, (fields[k] or "").strip() or None)
|
||||
for k in _DEC_FIELDS:
|
||||
if k in fields and fields[k] is not None:
|
||||
setattr(obj, k, Decimal(str(fields[k])))
|
||||
db.add(obj)
|
||||
db.commit()
|
||||
db.refresh(obj)
|
||||
return obj
|
||||
Reference in new issue
Block a user