Оказывается location_form это и есть placement_type, убрал location_form #21

Merged
Raykov-MS merged 1 commits from location_from_to_placement_type into test 2026-07-01 11:22:00 +03:00
8 changed files with 30 additions and 42 deletions

View File

@ -1123,9 +1123,9 @@ END;
$function$ $function$
; ;
-- DROP FUNCTION v3.add_vsp(int4, varchar, varchar, varchar, date, varchar, int4, numeric, date, bool, bool, varchar, int4, varchar, text, varchar, 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_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 RETURNS integer
LANGUAGE plpgsql LANGUAGE plpgsql
AS $function$ AS $function$
@ -1153,12 +1153,12 @@ BEGIN
(branch_id, reg_number, address, format, opened_at, (branch_id, reg_number, address, format, opened_at,
placement_type, staff_count, total_area, closed_at, placement_type, staff_count, total_area, closed_at,
is_active, is_deleted, system_code, created_by, is_active, is_deleted, system_code, created_by,
vsp_type, notes, location_form, rent_contract_num, rent_end_date) vsp_type, notes, rent_contract_num, rent_end_date)
VALUES VALUES
(p_branch_id, p_reg_number, p_address, p_format, p_opened_at, (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_placement_type, p_staff_count, p_total_area, p_closed_at,
p_is_active, p_is_deleted, p_system_code, p_created_by, p_is_active, p_is_deleted, p_system_code, p_created_by,
p_vsp_type, p_notes, p_location_form, 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; RETURNING id INTO v_id;
PERFORM v3.log_event( PERFORM v3.log_event(
@ -1182,7 +1182,6 @@ BEGIN
'created_by', p_created_by, 'created_by', p_created_by,
'vsp_type', p_vsp_type, 'vsp_type', p_vsp_type,
'notes', p_notes, 'notes', p_notes,
'location_form', p_location_form,
'rent_contract_num', p_rent_contract_num, 'rent_contract_num', p_rent_contract_num,
'rent_end_date', v3._diff_val(p_rent_end_date), 'rent_end_date', v3._diff_val(p_rent_end_date),
'user_email', v_actor_email, 'user_email', v_actor_email,
@ -2747,9 +2746,9 @@ END;
$function$ $function$
; ;
-- DROP FUNCTION v3.upd_vsp(int4, int4, varchar, varchar, varchar, date, varchar, int4, numeric, date, bool, bool, varchar, int4, varchar, text, varchar, 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_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 RETURNS void
LANGUAGE plpgsql LANGUAGE plpgsql
AS $function$ AS $function$
@ -2767,7 +2766,7 @@ BEGIN
SELECT v.branch_id, v.reg_number, v.address, v.format, v.opened_at, 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.placement_type, v.staff_count, v.total_area, v.closed_at,
v.is_active, v.is_deleted, v.system_code, v.is_active, v.is_deleted, v.system_code,
v.vsp_type, v.notes, v.location_form, v.rent_contract_num, v.rent_end_date v.vsp_type, v.notes, v.rent_contract_num, v.rent_end_date
INTO v_old INTO v_old
FROM v3.vsp v FROM v3.vsp v
WHERE v.id = p_vsp_id; WHERE v.id = p_vsp_id;
@ -2900,13 +2899,6 @@ BEGIN
'after', v3._diff_val(p_notes))); 'after', v3._diff_val(p_notes)));
END IF; 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_rent_contract_num IS NOT NULL AND p_rent_contract_num IS DISTINCT FROM v_old.rent_contract_num THEN 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; 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', v_changes := v_changes || jsonb_build_object('rent_contract_num',

View File

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

View File

@ -27,7 +27,7 @@ async def get_vsp(
ssp_id: int | None = None, ssp_id: int | None = None,
open_date_start: date | None = None, open_date_start: date | None = None,
open_date_end: date | None = None, open_date_end: date | None = None,
location_form: str | None = None, placement_type: str | None = None,
staff_count_min: int | None = None, staff_count_min: int | None = None,
staff_count_max: int | None = None, staff_count_max: int | None = None,
db: AsyncSession = Depends(get_db), db: AsyncSession = Depends(get_db),
@ -42,7 +42,7 @@ async def get_vsp(
ssp_id=ssp_id, ssp_id=ssp_id,
open_date_start=open_date_start, open_date_start=open_date_start,
open_date_end=open_date_end, open_date_end=open_date_end,
location_form=location_form, placement_type=placement_type,
staff_count_min=staff_count_min, staff_count_min=staff_count_min,
staff_count_max=staff_count_max, staff_count_max=staff_count_max,
load_org_unit=True, load_org_unit=True,
@ -89,7 +89,7 @@ async def export_info(
ssp_ids=body.ssp_ids, ssp_ids=body.ssp_ids,
open_date_start=body.open_date_start, open_date_start=body.open_date_start,
open_date_end=body.open_date_end, open_date_end=body.open_date_end,
location_form=body.location_form, placement_type=body.placement_type,
staff_count_min=body.staff_count_min, staff_count_min=body.staff_count_min,
staff_count_max=body.staff_count_max, staff_count_max=body.staff_count_max,
) )

View File

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

View File

@ -492,7 +492,6 @@ class VSPBase(BaseModel):
notes: Optional[str] = Field(None, description="Примечания") notes: Optional[str] = Field(None, description="Примечания")
placement_type: Optional[str] = Field(None, description="Тип размещения") placement_type: Optional[str] = Field(None, description="Тип размещения")
staff_count: Optional[int] = Field(None, description="Штатная численность") staff_count: Optional[int] = Field(None, description="Штатная численность")
location_form: Optional[str] = Field(None, description="Форма расположения")
area: Optional[float] = Field( area: Optional[float] = Field(
None, None,
description="Арендная площадь", description="Арендная площадь",
@ -542,7 +541,6 @@ class VSPEditBase(BaseModel):
notes: Optional[str] = Field(None, description="Примечания") notes: Optional[str] = Field(None, description="Примечания")
placement_type: Optional[str] = Field(None, description="Тип размещения") placement_type: Optional[str] = Field(None, description="Тип размещения")
staff_count: Optional[int] = Field(None, description="Штатная численность") staff_count: Optional[int] = Field(None, description="Штатная численность")
location_form: Optional[str] = Field(None, description="Форма расположения")
total_area: Optional[float] = Field( total_area: Optional[float] = Field(
None, None,
description="Арендная площадь", description="Арендная площадь",
@ -613,7 +611,7 @@ class VSPExportRequest(BaseModel):
ssp_ids: Optional[List[int]] = None ssp_ids: Optional[List[int]] = None
open_date_start: Optional[date] = None open_date_start: Optional[date] = None
open_date_end: Optional[date] = None open_date_end: Optional[date] = None
location_form: Optional[str] = None placement_type: Optional[str] = None
staff_count_min: Optional[int] = None staff_count_min: Optional[int] = None
staff_count_max: Optional[int] = None staff_count_max: Optional[int] = None

View File

@ -36,7 +36,7 @@ class VSPRepository:
ssp_ids: list[int] | None = None, ssp_ids: list[int] | None = None,
open_date_start: date | None = None, open_date_start: date | None = None,
open_date_end: date | None = None, open_date_end: date | None = None,
location_form: str | None = None, placement_type: str | None = None,
staff_count_min: int | None = None, staff_count_min: int | None = None,
staff_count_max: int | None = None, staff_count_max: int | None = None,
is_active: bool | None = True, is_active: bool | None = True,
@ -53,7 +53,7 @@ class VSPRepository:
filters = [ filters = [
("registration_number", registration_number), ("registration_number", registration_number),
("address", address), ("address", address),
("location_form", location_form), ("placement_type", placement_type),
("open_date_start", open_date_start), ("open_date_start", open_date_start),
("open_date_end", open_date_end), ("open_date_end", open_date_end),
("staff_count_min", staff_count_min), ("staff_count_min", staff_count_min),
@ -67,8 +67,8 @@ class VSPRepository:
queries.append(Vsp.reg_number.ilike(f"%{value}%")) queries.append(Vsp.reg_number.ilike(f"%{value}%"))
case ("address", str(value)) if value: case ("address", str(value)) if value:
queries.append(Vsp.address.ilike(f"%{value}%")) queries.append(Vsp.address.ilike(f"%{value}%"))
case ("location_form", str(value)) if value: case ("placement_type", str(value)) if value:
queries.append(Vsp.location_form.ilike(f"%{value}%")) queries.append(Vsp.placement_type.ilike(f"%{value}%"))
case ("open_date_start", value) if value is not None: case ("open_date_start", value) if value is not None:
queries.append(Vsp.opened_at >= value) queries.append(Vsp.opened_at >= value)
case ("open_date_end", value) if value is not None: case ("open_date_end", value) if value is not None:
@ -125,7 +125,7 @@ class VSPRepository:
:p_opened_at, :p_placement_type, :p_staff_count, :p_opened_at, :p_placement_type, :p_staff_count,
:p_total_area, :p_closed_at, :p_is_active, :p_is_deleted, :p_total_area, :p_closed_at, :p_is_active, :p_is_deleted,
:p_system_code, :p_created_by, :p_vsp_type, :p_notes, :p_system_code, :p_created_by, :p_vsp_type, :p_notes,
:p_location_form, :p_rent_contract_num, :p_rent_end_date :p_rent_contract_num, :p_rent_end_date
) )
"""), """),
{ {
@ -144,7 +144,6 @@ class VSPRepository:
"p_created_by": created_by, "p_created_by": created_by,
"p_vsp_type": data.get("vsp_type"), "p_vsp_type": data.get("vsp_type"),
"p_notes": data.get("notes"), "p_notes": data.get("notes"),
"p_location_form": data.get("location_form"),
"p_rent_contract_num": data.get("rent_contract_num"), "p_rent_contract_num": data.get("rent_contract_num"),
"p_rent_end_date": data.get("rent_end_date"), "p_rent_end_date": data.get("rent_end_date"),
} }
@ -178,7 +177,6 @@ class VSPRepository:
"placement_type": "p_placement_type", "placement_type": "p_placement_type",
"staff_count": "p_staff_count", "staff_count": "p_staff_count",
"notes": "p_notes", "notes": "p_notes",
"location_form": "p_location_form",
"total_area": "p_total_area", "total_area": "p_total_area",
"rent_contract_num": "p_rent_contract_num", "rent_contract_num": "p_rent_contract_num",
"rent_end_date": "p_rent_end_date", "rent_end_date": "p_rent_end_date",
@ -198,7 +196,7 @@ class VSPRepository:
:p_format, :p_opened_at, :p_placement_type, :p_staff_count, :p_format, :p_opened_at, :p_placement_type, :p_staff_count,
:p_total_area, :p_closed_at, :p_is_active, :p_is_deleted, :p_total_area, :p_closed_at, :p_is_active, :p_is_deleted,
:p_system_code, :p_updated_by, :p_vsp_type, :p_notes, :p_system_code, :p_updated_by, :p_vsp_type, :p_notes,
:p_location_form, :p_rent_contract_num, :p_rent_end_date :p_rent_contract_num, :p_rent_end_date
) )
"""), """),
params, params,

View File

@ -20,7 +20,7 @@ _info_close_sync_lock = asyncio.Lock()
class VSPService: class VSPService:
EXECUTOR_EDITABLE_FIELDS = { EXECUTOR_EDITABLE_FIELDS = {
"location_form", "placement_type",
"staff_count", "staff_count",
"total_area", "total_area",
"rent_contract_num", "rent_contract_num",
@ -54,7 +54,7 @@ class VSPService:
ssp_ids: list[int] | None = None, ssp_ids: list[int] | None = None,
open_date_start: date | None = None, open_date_start: date | None = None,
open_date_end: date | None = None, open_date_end: date | None = None,
location_form: str | None = None, placement_type: str | None = None,
staff_count_min: int | None = None, staff_count_min: int | None = None,
staff_count_max: int | None = None, staff_count_max: int | None = None,
is_active: bool | None = None, is_active: bool | None = None,
@ -84,7 +84,7 @@ class VSPService:
ssp_ids=effective_ssp_ids, ssp_ids=effective_ssp_ids,
open_date_start=open_date_start, open_date_start=open_date_start,
open_date_end=open_date_end, open_date_end=open_date_end,
location_form=location_form, placement_type=placement_type,
staff_count_min=staff_count_min, staff_count_min=staff_count_min,
staff_count_max=staff_count_max, staff_count_max=staff_count_max,
is_active=is_active, is_active=is_active,
@ -154,7 +154,7 @@ class VSPService:
ssp_ids: list[int] | None = None, ssp_ids: list[int] | None = None,
open_date_start: date | None = None, open_date_start: date | None = None,
open_date_end: date | None = None, open_date_end: date | None = None,
location_form: str | None = None, placement_type: str | None = None,
staff_count_min: int | None = None, staff_count_min: int | None = None,
staff_count_max: int | None = None, staff_count_max: int | None = None,
) -> tuple[io.BytesIO, str]: ) -> tuple[io.BytesIO, str]:
@ -165,7 +165,7 @@ class VSPService:
ssp_ids=ssp_ids, ssp_ids=ssp_ids,
open_date_start=open_date_start, open_date_start=open_date_start,
open_date_end=open_date_end, open_date_end=open_date_end,
location_form=location_form, placement_type=placement_type,
staff_count_min=staff_count_min, staff_count_min=staff_count_min,
staff_count_max=staff_count_max, staff_count_max=staff_count_max,
is_active=None, is_active=None,
@ -188,7 +188,7 @@ class VSPService:
"open_date", "open_date",
"close_date", "close_date",
"notes", "notes",
"location_form", "placement_type",
"staff_count", "staff_count",
"area", "area",
"rent_contract_num", "rent_contract_num",
@ -215,7 +215,7 @@ class VSPService:
item.opened_at.isoformat() if item.opened_at else None, item.opened_at.isoformat() if item.opened_at else None,
item.closed_at.isoformat() if item.closed_at else None, item.closed_at.isoformat() if item.closed_at else None,
item.notes or None, item.notes or None,
item.location_form or None, item.placement_type or None,
item.staff_count if item.staff_count is not None else 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, float(item.total_area) if item.total_area is not None else None,
item.rent_contract_num or None, item.rent_contract_num or None,

View File

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