fix: computed fields missing in anniversary endpoints + missing account_id validation in installment update

This commit is contained in:
祀梦
2026-05-17 12:00:54 +08:00
parent 3c03866021
commit 5f23b8ef5b
3 changed files with 38 additions and 18 deletions

View File

@@ -390,6 +390,11 @@ def update_installment(installment_id: int, data: DebtInstallmentUpdate, db: Ses
installment = get_or_404(db, DebtInstallment, installment_id, "分期计划")
update_data = data.model_dump(exclude_unset=True)
if "account_id" in update_data:
account = get_or_404(db, FinancialAccount, update_data["account_id"], "账户")
if account.account_type != "debt":
raise HTTPException(status_code=400, detail="分期计划只能关联欠款类型的账户")
for field, value in update_data.items():
setattr(installment, field, value)