feat: add deposit edit and delete for pending deposits
Add PUT /api/v1/dca/deposits/{id} endpoint to update amount, currency,
and notes on pending deposits. Add DELETE endpoint to remove deposits
not yet inserted into the machine. Both endpoints reject confirmed
deposits. Frontend now shows edit/delete buttons only for pending rows.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6eb076d5f6
commit
28241e70c3
5 changed files with 121 additions and 3 deletions
24
crud.py
24
crud.py
|
|
@ -8,7 +8,7 @@ from lnbits.helpers import urlsafe_short_hash
|
|||
|
||||
from .models import (
|
||||
CreateDcaClientData, DcaClient, UpdateDcaClientData,
|
||||
CreateDepositData, DcaDeposit, UpdateDepositStatusData,
|
||||
CreateDepositData, DcaDeposit, UpdateDepositData, UpdateDepositStatusData,
|
||||
CreateDcaPaymentData, DcaPayment,
|
||||
ClientBalanceSummary,
|
||||
CreateLamassuConfigData, LamassuConfig, UpdateLamassuConfigData,
|
||||
|
|
@ -153,6 +153,28 @@ async def update_deposit_status(deposit_id: str, data: UpdateDepositStatusData)
|
|||
return await get_deposit(deposit_id)
|
||||
|
||||
|
||||
async def update_deposit(deposit_id: str, data: UpdateDepositData) -> Optional[DcaDeposit]:
|
||||
update_data = {k: v for k, v in data.dict().items() if v is not None}
|
||||
if not update_data:
|
||||
return await get_deposit(deposit_id)
|
||||
|
||||
set_clause = ", ".join([f"{k} = :{k}" for k in update_data.keys()])
|
||||
update_data["id"] = deposit_id
|
||||
|
||||
await db.execute(
|
||||
f"UPDATE satoshimachine.dca_deposits SET {set_clause} WHERE id = :id",
|
||||
update_data
|
||||
)
|
||||
return await get_deposit(deposit_id)
|
||||
|
||||
|
||||
async def delete_deposit(deposit_id: str) -> None:
|
||||
await db.execute(
|
||||
"DELETE FROM satoshimachine.dca_deposits WHERE id = :id",
|
||||
{"id": deposit_id}
|
||||
)
|
||||
|
||||
|
||||
# DCA Payment CRUD Operations
|
||||
async def create_dca_payment(data: CreateDcaPaymentData) -> DcaPayment:
|
||||
payment_id = urlsafe_short_hash()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue