修复编辑交易记录时手续费字段报错的问题
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
FROM python:3.11-slim
|
FROM python:3.13.11-slim
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|||||||
@@ -116,8 +116,8 @@ def edit_trade(
|
|||||||
open_price: float = Form(...),
|
open_price: float = Form(...),
|
||||||
open_fee: float = Form(0.0),
|
open_fee: float = Form(0.0),
|
||||||
close_date: str = Form(""),
|
close_date: str = Form(""),
|
||||||
close_price: float = Form(None),
|
close_price: str = Form(""),
|
||||||
close_fee: float = Form(None),
|
close_fee: str = Form(""),
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
):
|
):
|
||||||
t = db.query(OptionTrade).filter(OptionTrade.id == trade_id).first()
|
t = db.query(OptionTrade).filter(OptionTrade.id == trade_id).first()
|
||||||
@@ -132,10 +132,10 @@ def edit_trade(
|
|||||||
t.open_date = date.fromisoformat(open_date)
|
t.open_date = date.fromisoformat(open_date)
|
||||||
t.open_price = open_price
|
t.open_price = open_price
|
||||||
t.open_fee = open_fee
|
t.open_fee = open_fee
|
||||||
if close_date and close_price is not None:
|
if close_date and close_price:
|
||||||
t.close_date = date.fromisoformat(close_date)
|
t.close_date = date.fromisoformat(close_date)
|
||||||
t.close_price = close_price
|
t.close_price = float(close_price)
|
||||||
t.close_fee = close_fee or 0
|
t.close_fee = float(close_fee) if close_fee else 0.0
|
||||||
db.commit()
|
db.commit()
|
||||||
return RedirectResponse("/options/", status_code=303)
|
return RedirectResponse("/options/", status_code=303)
|
||||||
|
|
||||||
|
|||||||
@@ -119,8 +119,8 @@ def edit_trade(
|
|||||||
open_price: float = Form(...),
|
open_price: float = Form(...),
|
||||||
open_fee: float = Form(0.0),
|
open_fee: float = Form(0.0),
|
||||||
close_date: str = Form(""),
|
close_date: str = Form(""),
|
||||||
close_price: float = Form(None),
|
close_price: str = Form(""),
|
||||||
close_fee: float = Form(None),
|
close_fee: str = Form(""),
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
):
|
):
|
||||||
t = db.query(Trade).filter(Trade.id == trade_id).first()
|
t = db.query(Trade).filter(Trade.id == trade_id).first()
|
||||||
@@ -133,10 +133,10 @@ def edit_trade(
|
|||||||
t.open_date = date.fromisoformat(open_date)
|
t.open_date = date.fromisoformat(open_date)
|
||||||
t.open_price = open_price
|
t.open_price = open_price
|
||||||
t.open_fee = open_fee
|
t.open_fee = open_fee
|
||||||
if close_date and close_price is not None:
|
if close_date and close_price:
|
||||||
t.close_date = date.fromisoformat(close_date)
|
t.close_date = date.fromisoformat(close_date)
|
||||||
t.close_price = close_price
|
t.close_price = float(close_price)
|
||||||
t.close_fee = close_fee or 0
|
t.close_fee = float(close_fee) if close_fee else 0.0
|
||||||
db.commit()
|
db.commit()
|
||||||
return RedirectResponse("/trades/", status_code=303)
|
return RedirectResponse("/trades/", status_code=303)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user