Merge branch 'test' into project-front

This commit is contained in:
PotapovaA 2026-07-01 11:29:30 +03:00
commit 4e7cc9b3bd
14 changed files with 107 additions and 130 deletions

View File

@ -920,7 +920,6 @@ def upgrade() -> None:
sa.Column('vsp_type', sa.String(100)),
sa.Column('notes', sa.Text()),
sa.Column('location_form', sa.String()),
sa.Column('numbers', sa.Integer()),
sa.Column('rent_contract_num', sa.String()),
sa.Column('rent_end_date', sa.Date()),
schema='v3',

View File

@ -1123,9 +1123,9 @@ END;
$function$
;
-- DROP FUNCTION v3.add_vsp(int4, varchar, varchar, varchar, date, varchar, int4, numeric, date, bool, bool, varchar, int4, varchar, text, varchar, int4, varchar, date);
-- DROP FUNCTION v3.add_vsp(int4, varchar, varchar, varchar, date, varchar, int4, numeric, date, bool, bool, varchar, int4, varchar, text, varchar, date);
CREATE OR REPLACE FUNCTION v3.add_vsp(p_branch_id integer, p_reg_number character varying DEFAULT NULL::character varying, p_address character varying DEFAULT NULL::character varying, p_format character varying DEFAULT NULL::character varying, p_opened_at date DEFAULT NULL::date, p_placement_type character varying DEFAULT NULL::character varying, p_staff_count integer DEFAULT NULL::integer, p_total_area numeric DEFAULT NULL::numeric, p_closed_at date DEFAULT NULL::date, p_is_active boolean DEFAULT true, p_is_deleted boolean DEFAULT false, p_system_code character varying DEFAULT NULL::character varying, p_created_by integer DEFAULT NULL::integer, p_vsp_type character varying DEFAULT NULL::character varying, p_notes text DEFAULT NULL::text, p_location_form character varying DEFAULT NULL::character varying, p_numbers integer DEFAULT NULL::integer, p_rent_contract_num character varying DEFAULT NULL::character varying, p_rent_end_date date DEFAULT NULL::date)
CREATE OR REPLACE FUNCTION v3.add_vsp(p_branch_id integer, p_reg_number character varying DEFAULT NULL::character varying, p_address character varying DEFAULT NULL::character varying, p_format character varying DEFAULT NULL::character varying, p_opened_at date DEFAULT NULL::date, p_placement_type character varying DEFAULT NULL::character varying, p_staff_count integer DEFAULT NULL::integer, p_total_area numeric DEFAULT NULL::numeric, p_closed_at date DEFAULT NULL::date, p_is_active boolean DEFAULT true, p_is_deleted boolean DEFAULT false, p_system_code character varying DEFAULT NULL::character varying, p_created_by integer DEFAULT NULL::integer, p_vsp_type character varying DEFAULT NULL::character varying, p_notes text DEFAULT NULL::text, p_rent_contract_num character varying DEFAULT NULL::character varying, p_rent_end_date date DEFAULT NULL::date)
RETURNS integer
LANGUAGE plpgsql
AS $function$
@ -1153,14 +1153,12 @@ BEGIN
(branch_id, reg_number, address, format, opened_at,
placement_type, staff_count, total_area, closed_at,
is_active, is_deleted, system_code, created_by,
vsp_type, notes, location_form, numbers,
rent_contract_num, rent_end_date)
vsp_type, notes, rent_contract_num, rent_end_date)
VALUES
(p_branch_id, p_reg_number, p_address, p_format, p_opened_at,
p_placement_type, p_staff_count, p_total_area, p_closed_at,
p_is_active, p_is_deleted, p_system_code, p_created_by,
p_vsp_type, p_notes, p_location_form, p_numbers,
p_rent_contract_num, p_rent_end_date)
p_vsp_type, p_notes, p_rent_contract_num, p_rent_end_date)
RETURNING id INTO v_id;
PERFORM v3.log_event(
@ -1184,8 +1182,6 @@ BEGIN
'created_by', p_created_by,
'vsp_type', p_vsp_type,
'notes', p_notes,
'location_form', p_location_form,
'numbers', p_numbers,
'rent_contract_num', p_rent_contract_num,
'rent_end_date', v3._diff_val(p_rent_end_date),
'user_email', v_actor_email,
@ -1574,7 +1570,7 @@ AS $function$
DECLARE
v_report_id INT;
v_eid INT;
v_org_id INT;
v_form_id INT;
v_ei_path INT[];
BEGIN
-- Извлекаем report_id + ei ДО DELETE (нужен для path)
@ -1588,21 +1584,33 @@ BEGIN
v_ei_path := v3._expense_item_path_set(ARRAY[v_eid]);
SELECT bf.id
INTO v_form_id
FROM v3.rf_project_report r
JOIN v3.project p
ON p.id = r.project_id
LEFT JOIN v3.budget_form bf
ON bf.form_type_code = 'FORM_3'
AND bf.year = r.year
AND bf.org_unit_id = p.org_unit_id
WHERE r.id = v_report_id
LIMIT 1;
-- Каскад (FK без ON DELETE CASCADE)
DELETE FROM v3.rf_project_report_quarter WHERE rf_project_report_line_id = p_line_id;
DELETE FROM v3.rf_project_report_line WHERE id = p_line_id;
SELECT org_unit_id INTO v_org_id FROM v3.project WHERE id = v_report_id;
-- Аудит: ROW_DELETE
PERFORM v3.log_event(
'ROW_DELETE', 'ROW',
jsonb_build_object(
'sheet', 'FORM_3',
'line_id', p_line_id,
'entity_id', p_line_id,
'form_id', v_form_id,
'report_id', v_report_id,
'expense_item_id', v_eid
), null, null, v_org_id
),
v_form_id
);
-- Возврат: только иерархия по пути удалённой (INPUT уже нет)
@ -2738,9 +2746,9 @@ END;
$function$
;
-- DROP FUNCTION v3.upd_vsp(int4, int4, varchar, varchar, varchar, date, varchar, int4, numeric, date, bool, bool, varchar, int4, varchar, text, varchar, int4, varchar, date);
-- DROP FUNCTION v3.upd_vsp(int4, int4, varchar, varchar, varchar, date, varchar, int4, numeric, date, bool, bool, varchar, int4, varchar, text, varchar, date);
CREATE OR REPLACE FUNCTION v3.upd_vsp(p_vsp_id integer, p_branch_id integer DEFAULT NULL::integer, p_reg_number character varying DEFAULT NULL::character varying, p_address character varying DEFAULT NULL::character varying, p_format character varying DEFAULT NULL::character varying, p_opened_at date DEFAULT NULL::date, p_placement_type character varying DEFAULT NULL::character varying, p_staff_count integer DEFAULT NULL::integer, p_total_area numeric DEFAULT NULL::numeric, p_closed_at date DEFAULT NULL::date, p_is_active boolean DEFAULT NULL::boolean, p_is_deleted boolean DEFAULT NULL::boolean, p_system_code character varying DEFAULT NULL::character varying, p_updated_by integer DEFAULT NULL::integer, p_vsp_type character varying DEFAULT NULL::character varying, p_notes text DEFAULT NULL::text, p_location_form character varying DEFAULT NULL::character varying, p_numbers integer DEFAULT NULL::integer, p_rent_contract_num character varying DEFAULT NULL::character varying, p_rent_end_date date DEFAULT NULL::date)
CREATE OR REPLACE FUNCTION v3.upd_vsp(p_vsp_id integer, p_branch_id integer DEFAULT NULL::integer, p_reg_number character varying DEFAULT NULL::character varying, p_address character varying DEFAULT NULL::character varying, p_format character varying DEFAULT NULL::character varying, p_opened_at date DEFAULT NULL::date, p_placement_type character varying DEFAULT NULL::character varying, p_staff_count integer DEFAULT NULL::integer, p_total_area numeric DEFAULT NULL::numeric, p_closed_at date DEFAULT NULL::date, p_is_active boolean DEFAULT NULL::boolean, p_is_deleted boolean DEFAULT NULL::boolean, p_system_code character varying DEFAULT NULL::character varying, p_updated_by integer DEFAULT NULL::integer, p_vsp_type character varying DEFAULT NULL::character varying, p_notes text DEFAULT NULL::text, p_rent_contract_num character varying DEFAULT NULL::character varying, p_rent_end_date date DEFAULT NULL::date)
RETURNS void
LANGUAGE plpgsql
AS $function$
@ -2758,8 +2766,7 @@ BEGIN
SELECT v.branch_id, v.reg_number, v.address, v.format, v.opened_at,
v.placement_type, v.staff_count, v.total_area, v.closed_at,
v.is_active, v.is_deleted, v.system_code,
v.vsp_type, v.notes, v.location_form, v.numbers,
v.rent_contract_num, v.rent_end_date
v.vsp_type, v.notes, v.rent_contract_num, v.rent_end_date
INTO v_old
FROM v3.vsp v
WHERE v.id = p_vsp_id;
@ -2892,20 +2899,6 @@ BEGIN
'after', v3._diff_val(p_notes)));
END IF;
IF p_location_form IS NOT NULL AND p_location_form IS DISTINCT FROM v_old.location_form THEN
UPDATE v3.vsp SET location_form = p_location_form WHERE id = p_vsp_id;
v_changes := v_changes || jsonb_build_object('location_form',
jsonb_build_object('before', v3._diff_val(v_old.location_form),
'after', v3._diff_val(p_location_form)));
END IF;
IF p_numbers IS NOT NULL AND p_numbers IS DISTINCT FROM v_old.numbers THEN
UPDATE v3.vsp SET numbers = p_numbers WHERE id = p_vsp_id;
v_changes := v_changes || jsonb_build_object('numbers',
jsonb_build_object('before', v3._diff_val(v_old.numbers),
'after', v3._diff_val(p_numbers)));
END IF;
IF p_rent_contract_num IS NOT NULL AND p_rent_contract_num IS DISTINCT FROM v_old.rent_contract_num THEN
UPDATE v3.vsp SET rent_contract_num = p_rent_contract_num WHERE id = p_vsp_id;
v_changes := v_changes || jsonb_build_object('rent_contract_num',
@ -4085,26 +4078,12 @@ $function$
-- DROP FUNCTION v3.v_form1_smeta(int4, int4);
CREATE FUNCTION v3.v_form1_smeta(p_year INT, p_org_unit_id INT)
RETURNS TABLE (
row_type VARCHAR,
depth INT,
section_code VARCHAR,
name VARCHAR,
supp_plan_q1 NUMERIC, supp_plan_q2 NUMERIC, supp_plan_q3 NUMERIC, supp_plan_q4 NUMERIC, supp_plan_year NUMERIC,
dev_plan_q1 NUMERIC, dev_plan_q2 NUMERIC, dev_plan_q3 NUMERIC, dev_plan_q4 NUMERIC, dev_plan_year NUMERIC,
total_plan_year NUMERIC,
supp_appr_q1 NUMERIC, supp_appr_q2 NUMERIC, supp_appr_q3 NUMERIC, supp_appr_q4 NUMERIC, supp_appr_year NUMERIC,
dev_appr_q1 NUMERIC, dev_appr_q2 NUMERIC, dev_appr_q3 NUMERIC, dev_appr_q4 NUMERIC, dev_appr_year NUMERIC,
total_appr_year NUMERIC,
supp_act_q1 NUMERIC, supp_act_q2 NUMERIC, supp_act_q3 NUMERIC, supp_act_q4 NUMERIC, supp_act_year NUMERIC,
dev_act_q1 NUMERIC, dev_act_q2 NUMERIC, dev_act_q3 NUMERIC, dev_act_q4 NUMERIC, dev_act_year NUMERIC,
total_act_year NUMERIC,
supp_corr_q2 NUMERIC, supp_corr_q3 NUMERIC, supp_corr_q4 NUMERIC,
dev_corr_q2 NUMERIC, dev_corr_q3 NUMERIC, dev_corr_q4 NUMERIC
)
AS $$
CREATE OR REPLACE FUNCTION v3.v_form1_smeta(p_year integer, p_org_unit_id integer)
RETURNS TABLE(row_type character varying, depth integer, section_code character varying, name character varying, supp_plan_q1 numeric, supp_plan_q2 numeric, supp_plan_q3 numeric, supp_plan_q4 numeric, supp_plan_year numeric, dev_plan_q1 numeric, dev_plan_q2 numeric, dev_plan_q3 numeric, dev_plan_q4 numeric, dev_plan_year numeric, total_plan_year numeric, supp_appr_q1 numeric, supp_appr_q2 numeric, supp_appr_q3 numeric, supp_appr_q4 numeric, supp_appr_year numeric, dev_appr_q1 numeric, dev_appr_q2 numeric, dev_appr_q3 numeric, dev_appr_q4 numeric, dev_appr_year numeric, total_appr_year numeric, supp_act_q1 numeric, supp_act_q2 numeric, supp_act_q3 numeric, supp_act_q4 numeric, supp_act_year numeric, dev_act_q1 numeric, dev_act_q2 numeric, dev_act_q3 numeric, dev_act_q4 numeric, dev_act_year numeric, total_act_year numeric, supp_corr_q2 numeric, supp_corr_q3 numeric, supp_corr_q4 numeric, dev_corr_q2 numeric, dev_corr_q3 numeric, dev_corr_q4 numeric)
LANGUAGE plpgsql
STABLE
SET search_path TO 'v3', 'pg_catalog'
AS $function$
#variable_conflict use_column
DECLARE
v_ahr INT; v_cap INT; v_oper INT;
@ -4234,8 +4213,8 @@ BEGIN
FROM merged m
ORDER BY m.sc;
END;
$$ LANGUAGE plpgsql STABLE SET search_path = v3, pg_catalog;
$function$
;
-- DROP FUNCTION v3.v_form2_sheet_sections(int4, varchar, _text);
CREATE OR REPLACE FUNCTION v3.v_form2_sheet_sections(p_form_id integer, p_sheet character varying, p_sections text[] DEFAULT NULL::text[])

View File

@ -14,3 +14,4 @@ aiosqlite==0.20.0
asyncpg==0.30.0
pytest==8.3.2
pytest-asyncio==0.24.0
openpyxl==3.1.5

View File

@ -6,7 +6,7 @@ from src.core.errors import AccessDeniedException
from src.api.v1.deps import get_current_active_user, require_admin
from src.db.models.app_user import AppUser
from src.db.session import get_db
from src.domain.schemas import BaseListResponse, BaseSingleResponse, OrgUnitBaseSchema, OrgUnitListSchema, OrgUnitSchema, OrgUnitUpdateSchema, ResponseBase
from src.domain.schemas import BaseListResponse, BaseSingleResponse, OrgUnitCreateSchema, OrgUnitListSchema, OrgUnitSchema, OrgUnitUpdateSchema, ResponseBase
from src.services.org_unit_service import OrgUnitService
@ -66,7 +66,7 @@ async def org_unit_id(
@router.post("/")
async def create_ssp(
org_data: OrgUnitBaseSchema,
org_data: OrgUnitCreateSchema,
db: AsyncSession = Depends(get_db),
current_user: AppUser = Depends(require_admin),
) -> BaseSingleResponse[OrgUnitSchema]:

View File

@ -27,9 +27,9 @@ async def get_vsp(
ssp_id: int | None = None,
open_date_start: date | None = None,
open_date_end: date | None = None,
location_form: str | None = None,
numbers_min: int | None = None,
numbers_max: int | None = None,
placement_type: str | None = None,
staff_count_min: int | None = None,
staff_count_max: int | None = None,
db: AsyncSession = Depends(get_db),
current_user: AppUser = Depends(require_executor),
):
@ -42,9 +42,9 @@ async def get_vsp(
ssp_id=ssp_id,
open_date_start=open_date_start,
open_date_end=open_date_end,
location_form=location_form,
numbers_min=numbers_min,
numbers_max=numbers_max,
placement_type=placement_type,
staff_count_min=staff_count_min,
staff_count_max=staff_count_max,
load_org_unit=True,
with_count=True,
)
@ -89,9 +89,9 @@ async def export_info(
ssp_ids=body.ssp_ids,
open_date_start=body.open_date_start,
open_date_end=body.open_date_end,
location_form=body.location_form,
numbers_min=body.numbers_min,
numbers_max=body.numbers_max,
placement_type=body.placement_type,
staff_count_min=body.staff_count_min,
staff_count_max=body.staff_count_max,
)
return StreamingResponse(
stream,

View File

@ -45,8 +45,6 @@ class Vsp(Base):
)
vsp_type: Mapped[str | None] = mapped_column(String(100), nullable=True)
notes: Mapped[str | None] = mapped_column(Text, nullable=True)
location_form: Mapped[str | None] = mapped_column(String, nullable=True)
numbers: Mapped[int | None] = mapped_column(Integer, nullable=True)
rent_contract_num: Mapped[str | None] = mapped_column(String, nullable=True)
rent_end_date : Mapped[date | None]= mapped_column(Date, nullable=True)

View File

@ -233,6 +233,10 @@ class OrgUnitBaseSchema(BaseModel):
model_config = ConfigDict(from_attributes=True)
class OrgUnitCreateSchema(OrgUnitBaseSchema):
title: str = Field(..., min_length=1)
class OrgUnitUpdateSchema(OrgUnitBaseSchema):
title: Optional[str] = None
is_ssp: Optional[bool] = None
@ -490,8 +494,8 @@ class VSPBase(BaseModel):
serialization_alias='approved_format',
)
notes: Optional[str] = Field(None, description="Примечания")
location_form: Optional[str] = Field(None, description="Форма расположения")
numbers: Optional[int] = Field(None, description="Штатная численность")
placement_type: Optional[str] = Field(None, description="Тип размещения")
staff_count: Optional[int] = Field(None, description="Штатная численность")
area: Optional[float] = Field(
None,
description="Арендная площадь",
@ -539,8 +543,8 @@ class VSPEditBase(BaseModel):
serialization_alias='format',
)
notes: Optional[str] = Field(None, description="Примечания")
location_form: Optional[str] = Field(None, description="Форма расположения")
numbers: Optional[int] = Field(None, description="Штатная численность")
placement_type: Optional[str] = Field(None, description="Тип размещения")
staff_count: Optional[int] = Field(None, description="Штатная численность")
total_area: Optional[float] = Field(
None,
description="Арендная площадь",
@ -611,9 +615,9 @@ class VSPExportRequest(BaseModel):
ssp_ids: Optional[List[int]] = None
open_date_start: Optional[date] = None
open_date_end: Optional[date] = None
location_form: Optional[str] = None
numbers_min: Optional[int] = None
numbers_max: Optional[int] = None
placement_type: Optional[str] = None
staff_count_min: Optional[int] = None
staff_count_max: Optional[int] = None
class ExpenseItemBaseSchema(BaseModel):

View File

@ -36,9 +36,9 @@ class VSPRepository:
ssp_ids: list[int] | None = None,
open_date_start: date | None = None,
open_date_end: date | None = None,
location_form: str | None = None,
numbers_min: int | None = None,
numbers_max: int | None = None,
placement_type: str | None = None,
staff_count_min: int | None = None,
staff_count_max: int | None = None,
is_active: bool | None = True,
close_date_is_null: bool | None = None,
load_org_unit: bool = False,
@ -53,11 +53,11 @@ class VSPRepository:
filters = [
("registration_number", registration_number),
("address", address),
("location_form", location_form),
("placement_type", placement_type),
("open_date_start", open_date_start),
("open_date_end", open_date_end),
("numbers_min", numbers_min),
("numbers_max", numbers_max),
("staff_count_min", staff_count_min),
("staff_count_max", staff_count_max),
("is_active", is_active),
]
for filter_name, filter_value in filters:
@ -67,16 +67,16 @@ class VSPRepository:
queries.append(Vsp.reg_number.ilike(f"%{value}%"))
case ("address", str(value)) if value:
queries.append(Vsp.address.ilike(f"%{value}%"))
case ("location_form", str(value)) if value:
queries.append(Vsp.location_form.ilike(f"%{value}%"))
case ("placement_type", str(value)) if value:
queries.append(Vsp.placement_type.ilike(f"%{value}%"))
case ("open_date_start", value) if value is not None:
queries.append(Vsp.opened_at >= value)
case ("open_date_end", value) if value is not None:
queries.append(Vsp.opened_at <= value)
case ("numbers_min", value) if value is not None:
queries.append(Vsp.numbers >= value)
case ("numbers_max", value) if value is not None:
queries.append(Vsp.numbers <= value)
case ("staff_count_min", value) if value is not None:
queries.append(Vsp.staff_count >= value)
case ("staff_count_max", value) if value is not None:
queries.append(Vsp.staff_count <= value)
case ("is_active", value) if value is not None:
queries.append(Vsp.is_active == value)
case _:
@ -116,6 +116,7 @@ class VSPRepository:
async def create(self, payload: VSPCreate, created_by: int, load_org_unit: bool = False) -> Vsp:
data = payload.model_dump()
vsp_id = (
await self.db.execute(
text("""
@ -124,8 +125,7 @@ class VSPRepository:
:p_opened_at, :p_placement_type, :p_staff_count,
:p_total_area, :p_closed_at, :p_is_active, :p_is_deleted,
:p_system_code, :p_created_by, :p_vsp_type, :p_notes,
:p_location_form, :p_numbers, :p_rent_contract_num,
:p_rent_end_date
:p_rent_contract_num, :p_rent_end_date
)
"""),
{
@ -144,8 +144,6 @@ class VSPRepository:
"p_created_by": created_by,
"p_vsp_type": data.get("vsp_type"),
"p_notes": data.get("notes"),
"p_location_form": data.get("location_form"),
"p_numbers": data.get("numbers"),
"p_rent_contract_num": data.get("rent_contract_num"),
"p_rent_end_date": data.get("rent_end_date"),
}
@ -176,9 +174,9 @@ class VSPRepository:
"opened_at": "p_opened_at",
"closed_at": "p_closed_at",
"format": "p_format",
"placement_type": "p_placement_type",
"staff_count": "p_staff_count",
"notes": "p_notes",
"location_form": "p_location_form",
"numbers": "p_numbers",
"total_area": "p_total_area",
"rent_contract_num": "p_rent_contract_num",
"rent_end_date": "p_rent_end_date",
@ -190,8 +188,7 @@ class VSPRepository:
params = {"p_vsp_id": vsp.id, "p_updated_by": updated_by}
for field, param in FIELD_TO_PARAM.items():
params[param] = data.get(field)
params.setdefault("p_placement_type", data.get("placement_type"))
params.setdefault("p_staff_count", data.get("staff_count"))
await self.db.execute(
text("""
SELECT v3.upd_vsp(
@ -199,8 +196,7 @@ class VSPRepository:
:p_format, :p_opened_at, :p_placement_type, :p_staff_count,
:p_total_area, :p_closed_at, :p_is_active, :p_is_deleted,
:p_system_code, :p_updated_by, :p_vsp_type, :p_notes,
:p_location_form, :p_numbers, :p_rent_contract_num,
:p_rent_end_date
:p_rent_contract_num, :p_rent_end_date
)
"""),
params,

View File

@ -20,8 +20,8 @@ _info_close_sync_lock = asyncio.Lock()
class VSPService:
EXECUTOR_EDITABLE_FIELDS = {
"location_form",
"numbers",
"placement_type",
"staff_count",
"total_area",
"rent_contract_num",
"rent_end_date",
@ -54,9 +54,9 @@ class VSPService:
ssp_ids: list[int] | None = None,
open_date_start: date | None = None,
open_date_end: date | None = None,
location_form: str | None = None,
numbers_min: int | None = None,
numbers_max: int | None = None,
placement_type: str | None = None,
staff_count_min: int | None = None,
staff_count_max: int | None = None,
is_active: bool | None = None,
load_org_unit: bool = False,
with_count: bool = False,
@ -84,9 +84,9 @@ class VSPService:
ssp_ids=effective_ssp_ids,
open_date_start=open_date_start,
open_date_end=open_date_end,
location_form=location_form,
numbers_min=numbers_min,
numbers_max=numbers_max,
placement_type=placement_type,
staff_count_min=staff_count_min,
staff_count_max=staff_count_max,
is_active=is_active,
load_org_unit=load_org_unit,
with_count=with_count,
@ -154,9 +154,9 @@ class VSPService:
ssp_ids: list[int] | None = None,
open_date_start: date | None = None,
open_date_end: date | None = None,
location_form: str | None = None,
numbers_min: int | None = None,
numbers_max: int | None = None,
placement_type: str | None = None,
staff_count_min: int | None = None,
staff_count_max: int | None = None,
) -> tuple[io.BytesIO, str]:
data = await self.get_list(
user=user,
@ -165,9 +165,9 @@ class VSPService:
ssp_ids=ssp_ids,
open_date_start=open_date_start,
open_date_end=open_date_end,
location_form=location_form,
numbers_min=numbers_min,
numbers_max=numbers_max,
placement_type=placement_type,
staff_count_min=staff_count_min,
staff_count_max=staff_count_max,
is_active=None,
load_org_unit=True,
)
@ -188,8 +188,8 @@ class VSPService:
"open_date",
"close_date",
"notes",
"location_form",
"numbers",
"placement_type",
"staff_count",
"area",
"rent_contract_num",
"rent_end_date",
@ -215,8 +215,8 @@ class VSPService:
item.opened_at.isoformat() if item.opened_at else None,
item.closed_at.isoformat() if item.closed_at else None,
item.notes or None,
item.location_form or None,
item.numbers if item.numbers is not None else None,
item.placement_type or None,
item.staff_count if item.staff_count is not None else None,
float(item.total_area) if item.total_area is not None else None,
item.rent_contract_num or None,
item.rent_end_date.isoformat() if item.rent_end_date else None,

View File

@ -40,10 +40,10 @@ def test_vsp_dropdown_smoke(client, admin_tokens, auth_headers):
@pytest.mark.parametrize(
"params, count",
[
([("ssp_id", 2)], 1),
([("ssp_id", 2)], 2),
([("form_id", 1)], 0),
([("form_id", 2)], 1),
([("ssp_id", 2), ("form_id", 1)], 1),
([("form_id", 2)], 2),
([("ssp_id", 2), ("form_id", 1)], 2),
]
)
def test_vsp_dropdown_with_filter(client, admin_tokens, auth_headers, params, count):
@ -110,8 +110,8 @@ def test_vsp_create_with_all_fields(client, admin_tokens, auth_headers):
"close_date": "2025-12-31",
"approved_format": "Стандарт",
"notes": "Тестовое примечание",
"location_form": "Встроенное",
"numbers": 10,
"placement_type": "Аренда",
"staff_count": 10,
"area": 150.5,
"rent_contract_num": "Д-123/24",
"rent_end_date": "2025-12-31",
@ -127,8 +127,8 @@ def test_vsp_create_with_all_fields(client, admin_tokens, auth_headers):
assert payload["result"]["open_date"] == "2024-01-15"
assert payload["result"]["close_date"] == "2025-12-31"
assert payload["result"]["approved_format"] == "Стандарт"
assert payload["result"]["location_form"] == "Встроенное"
assert payload["result"]["numbers"] == 10
assert payload["result"]["placement_type"] == "Аренда"
assert payload["result"]["staff_count"] == 10
assert payload["result"]["area"] == 150.5
assert payload["result"]["rent_contract_num"] == "Д-123/24"
assert payload["result"]["rent_end_date"] == "2025-12-31"

View File

@ -26,7 +26,7 @@ SELECT setval('v3.budget_line_id_seq', 1);
INSERT INTO v3.form_phase (budget_form_id,sheet,phase_code,"role",column_keys,opens_at,closes_at) VALUES
(1,'AHR','test','DFIP','{{plan.q1}}','2026-05-05 03:00:00+03','2026-06-06 03:00:00+03');
INSERT INTO v3.vsp (id,branch_id,reg_number,address,format,opened_at,placement_type,staff_count,total_area,closed_at,is_active,updated_at,is_deleted,created_at,created_by,system_code,updated_by,vsp_type,notes,location_form,numbers,rent_contract_num,rent_end_date) VALUES
(1,2,'Тестовый всп 1','Тестовая 12','укукк','2026-05-07','ывс',2026,230,'2026-06-16',false,'2026-06-18 15:46:38.611903',false,'2026-06-04 14:36:59.737727',1,'1233',91,'','','встроенное помещение',NULL,'',NULL),
(2,2,'Test12 -----','Тестовая 125','формат 15 ','2026-06-08',NULL,NULL,58,NULL,true,'2026-06-16 18:53:17.986651',false,'2026-06-09 09:04:33.29858',91,'123-1234',91,'субаренда','Работает ','аренда',155,'12-45','2026-10-02');
INSERT INTO v3.vsp (id,branch_id,reg_number,address,format,opened_at,placement_type,staff_count,total_area,closed_at,is_active,updated_at,is_deleted,created_at,created_by,system_code,updated_by,vsp_type,notes,location_form,rent_contract_num,rent_end_date) VALUES
(1,2,'Тестовый всп 1','Тестовая 12','укукк','2026-05-07','ывс',2026,230,'2026-06-16',false,'2026-06-18 15:46:38.611903',false,'2026-06-04 14:36:59.737727',1,'1233',91,'','','встроенное помещение','',NULL),
(2,2,'Test12 -----','Тестовая 125','формат 15 ','2026-06-08',NULL,NULL,58,NULL,true,'2026-06-16 18:53:17.986651',false,'2026-06-09 09:04:33.29858',91,'123-1234',91,'субаренда','Работает ','аренда','12-45','2026-10-02');
SELECT setval('v3.vsp_id_seq', 2);

View File

@ -26,7 +26,7 @@ import { useRealtime } from './contexts/RealtimeContext';
import { toast } from 'react-toastify';
import { CircularProgress } from '@mui/material';
import { additionVspRowTable } from './constants/addingRowConfig';
import { SelectVspModal } from './Modals/selectVspModal';
import { SelectVspModal } from './Modals/SelectVspModal';
import { getRowId } from './utils/rowUtils';
const RealtimeTable = ({ formType, formId, sheetName, direction }) => {

View File

@ -95,7 +95,7 @@ const ModalEditAddVsp = ({
: null,
notes: initialData.notes || '',
location_form: initialData.location_form || '',
numbers: initialData.numbers?.toString() || '',
numbers: initialData.staff_count?.toString() || '',
area: initialData.area || null,
rent_contract_num: initialData.rent_contract_num || '',
rent_end_date: initialData.rent_end_date
@ -215,7 +215,7 @@ const ModalEditAddVsp = ({
const submitData = {
...formData,
numbers: formData.numbers ? parseInt(formData.numbers, 10) : null,
numbers: formData.staff_count ? parseInt(formData.staff_count, 10) : null,
area: formData.area ? parseFloat(formData.area) : null,
open_date: formData.open_date
? formData.open_date.toLocaleDateString('en-CA')
@ -495,11 +495,11 @@ const ModalEditAddVsp = ({
<FieldLabel>Штатная численность ВСП</FieldLabel>
<StyledTextField
type="text"
value={formData.numbers}
value={formData.staff_count}
onChange={handleNumberChange('numbers')}
placeholder="Введите численность"
error={!!errors.numbers}
helperText={errors.numbers}
error={!!errors.staff_count}
helperText={errors.staff_count}
disabled={loading}
slotProps={{
htmlInput: { min: 1, step: 1 },

View File

@ -204,7 +204,7 @@ const TableDictVsp = ({
enableSorting: false,
},
{
accessorKey: 'numbers',
accessorKey: 'staff_count',
header: 'Штатная численность ВСП',
size: 170,
minSize: 140,