feat: add project requisites and agreement cancellation

This commit is contained in:
Александр Арсентьев
2026-09-30 16:42:02 +03:00
parent 3c8bbe8b4b
commit a2a01e24e6
21 changed files with 1828 additions and 12 deletions
+30 -1
View File
@@ -348,12 +348,23 @@ async def update_project(
start_date: str = Form(None),
end_date: str = Form(None),
status: str = Form("active"),
investor_name: str = Form(None),
customer_name: str = Form(None),
contractor_name: str = Form(None),
construction_name: str = Form(None),
object_name: str = Form(None),
contract_amount: str = Form(None),
contractor_signer_name: str = Form(None),
contractor_signer_position: str = Form(None),
customer_signer_name: str = Form(None),
customer_signer_position: str = Form(None),
db: Session = Depends(get_db),
):
db_project = db.query(project.Project).filter(project.Project.id == project_id).first()
if db_project is None:
raise HTTPException(status_code=404, detail="Project not found")
from datetime import datetime
from decimal import Decimal, InvalidOperation
try:
db_project.contract_date = datetime.strptime(contract_date, "%Y-%m-%d").date() if contract_date else None
db_project.start_date = datetime.strptime(start_date, "%Y-%m-%d").date() if start_date else None
@@ -362,9 +373,27 @@ async def update_project(
raise HTTPException(status_code=400, detail="Dates must use YYYY-MM-DD format") from exc
db_project.name = name.strip()
db_project.contract_number = contract_number.strip() if contract_number else None
db_project.customer = customer.strip() if customer else None
# customer_name is the domain field; customer is kept in sync for compatibility
resolved_customer = (customer_name or customer or "").strip() or None
db_project.customer_name = resolved_customer
db_project.customer = resolved_customer
db_project.currency = currency.strip() if currency else "RUB"
db_project.status = status
db_project.investor_name = investor_name.strip() if investor_name else None
db_project.contractor_name = contractor_name.strip() if contractor_name else None
db_project.construction_name = construction_name.strip() if construction_name else None
db_project.object_name = object_name.strip() if object_name else None
db_project.contractor_signer_name = contractor_signer_name.strip() if contractor_signer_name else None
db_project.contractor_signer_position = contractor_signer_position.strip() if contractor_signer_position else None
db_project.customer_signer_name = customer_signer_name.strip() if customer_signer_name else None
db_project.customer_signer_position = customer_signer_position.strip() if customer_signer_position else None
if contract_amount:
try:
db_project.contract_amount = Decimal(contract_amount.strip().replace(",", "."))
except InvalidOperation:
raise HTTPException(status_code=400, detail="Сумма договора должна быть числом")
else:
db_project.contract_amount = None
db.commit()
return RedirectResponse(url=f"/projects/{project_id}", status_code=303)