Compare commits
No commits in common. "047cabe14b1b0462d786b69d0b0fea91a04f9f64" and "7fabb22c45f24cccaf023b25538b0bf26df6707c" have entirely different histories.
047cabe14b
...
7fabb22c45
@ -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, date);
|
||||
-- DROP FUNCTION v3.add_vsp(int4, varchar, varchar, varchar, date, varchar, int4, numeric, date, bool, bool, varchar, int4, varchar, text, varchar, 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_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_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)
|
||||
RETURNS integer
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
@ -1153,12 +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, rent_contract_num, rent_end_date)
|
||||
vsp_type, notes, location_form, 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_rent_contract_num, p_rent_end_date)
|
||||
p_vsp_type, p_notes, p_location_form, p_rent_contract_num, p_rent_end_date)
|
||||
RETURNING id INTO v_id;
|
||||
|
||||
PERFORM v3.log_event(
|
||||
@ -1182,6 +1182,7 @@ BEGIN
|
||||
'created_by', p_created_by,
|
||||
'vsp_type', p_vsp_type,
|
||||
'notes', p_notes,
|
||||
'location_form', p_location_form,
|
||||
'rent_contract_num', p_rent_contract_num,
|
||||
'rent_end_date', v3._diff_val(p_rent_end_date),
|
||||
'user_email', v_actor_email,
|
||||
@ -2746,9 +2747,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, date);
|
||||
-- DROP FUNCTION v3.upd_vsp(int4, int4, varchar, varchar, varchar, date, varchar, int4, numeric, date, bool, bool, varchar, int4, varchar, text, varchar, 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_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_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)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
@ -2766,7 +2767,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.rent_contract_num, v.rent_end_date
|
||||
v.vsp_type, v.notes, v.location_form, v.rent_contract_num, v.rent_end_date
|
||||
INTO v_old
|
||||
FROM v3.vsp v
|
||||
WHERE v.id = p_vsp_id;
|
||||
@ -2899,6 +2900,13 @@ 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_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',
|
||||
|
||||
@ -14,4 +14,3 @@ aiosqlite==0.20.0
|
||||
asyncpg==0.30.0
|
||||
pytest==8.3.2
|
||||
pytest-asyncio==0.24.0
|
||||
openpyxl==3.1.5
|
||||
|
||||
@ -27,7 +27,7 @@ async def get_vsp(
|
||||
ssp_id: int | None = None,
|
||||
open_date_start: date | None = None,
|
||||
open_date_end: date | None = None,
|
||||
placement_type: str | None = None,
|
||||
location_form: str | None = None,
|
||||
staff_count_min: int | None = None,
|
||||
staff_count_max: int | None = None,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
@ -42,7 +42,7 @@ async def get_vsp(
|
||||
ssp_id=ssp_id,
|
||||
open_date_start=open_date_start,
|
||||
open_date_end=open_date_end,
|
||||
placement_type=placement_type,
|
||||
location_form=location_form,
|
||||
staff_count_min=staff_count_min,
|
||||
staff_count_max=staff_count_max,
|
||||
load_org_unit=True,
|
||||
@ -89,7 +89,7 @@ async def export_info(
|
||||
ssp_ids=body.ssp_ids,
|
||||
open_date_start=body.open_date_start,
|
||||
open_date_end=body.open_date_end,
|
||||
placement_type=body.placement_type,
|
||||
location_form=body.location_form,
|
||||
staff_count_min=body.staff_count_min,
|
||||
staff_count_max=body.staff_count_max,
|
||||
)
|
||||
|
||||
@ -45,6 +45,7 @@ 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)
|
||||
rent_contract_num: Mapped[str | None] = mapped_column(String, nullable=True)
|
||||
rent_end_date : Mapped[date | None]= mapped_column(Date, nullable=True)
|
||||
|
||||
|
||||
@ -496,6 +496,7 @@ class VSPBase(BaseModel):
|
||||
notes: Optional[str] = Field(None, description="Примечания")
|
||||
placement_type: Optional[str] = Field(None, description="Тип размещения")
|
||||
staff_count: Optional[int] = Field(None, description="Штатная численность")
|
||||
location_form: Optional[str] = Field(None, description="Форма расположения")
|
||||
area: Optional[float] = Field(
|
||||
None,
|
||||
description="Арендная площадь",
|
||||
@ -545,6 +546,7 @@ class VSPEditBase(BaseModel):
|
||||
notes: Optional[str] = Field(None, description="Примечания")
|
||||
placement_type: Optional[str] = Field(None, description="Тип размещения")
|
||||
staff_count: Optional[int] = Field(None, description="Штатная численность")
|
||||
location_form: Optional[str] = Field(None, description="Форма расположения")
|
||||
total_area: Optional[float] = Field(
|
||||
None,
|
||||
description="Арендная площадь",
|
||||
@ -615,7 +617,7 @@ class VSPExportRequest(BaseModel):
|
||||
ssp_ids: Optional[List[int]] = None
|
||||
open_date_start: Optional[date] = None
|
||||
open_date_end: Optional[date] = None
|
||||
placement_type: Optional[str] = None
|
||||
location_form: Optional[str] = None
|
||||
staff_count_min: Optional[int] = None
|
||||
staff_count_max: Optional[int] = None
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ class VSPRepository:
|
||||
ssp_ids: list[int] | None = None,
|
||||
open_date_start: date | None = None,
|
||||
open_date_end: date | None = None,
|
||||
placement_type: str | None = None,
|
||||
location_form: str | None = None,
|
||||
staff_count_min: int | None = None,
|
||||
staff_count_max: int | None = None,
|
||||
is_active: bool | None = True,
|
||||
@ -53,7 +53,7 @@ class VSPRepository:
|
||||
filters = [
|
||||
("registration_number", registration_number),
|
||||
("address", address),
|
||||
("placement_type", placement_type),
|
||||
("location_form", location_form),
|
||||
("open_date_start", open_date_start),
|
||||
("open_date_end", open_date_end),
|
||||
("staff_count_min", staff_count_min),
|
||||
@ -67,8 +67,8 @@ class VSPRepository:
|
||||
queries.append(Vsp.reg_number.ilike(f"%{value}%"))
|
||||
case ("address", str(value)) if value:
|
||||
queries.append(Vsp.address.ilike(f"%{value}%"))
|
||||
case ("placement_type", str(value)) if value:
|
||||
queries.append(Vsp.placement_type.ilike(f"%{value}%"))
|
||||
case ("location_form", str(value)) if value:
|
||||
queries.append(Vsp.location_form.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:
|
||||
@ -125,7 +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_rent_contract_num, :p_rent_end_date
|
||||
:p_location_form, :p_rent_contract_num, :p_rent_end_date
|
||||
)
|
||||
"""),
|
||||
{
|
||||
@ -144,6 +144,7 @@ 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_rent_contract_num": data.get("rent_contract_num"),
|
||||
"p_rent_end_date": data.get("rent_end_date"),
|
||||
}
|
||||
@ -177,6 +178,7 @@ class VSPRepository:
|
||||
"placement_type": "p_placement_type",
|
||||
"staff_count": "p_staff_count",
|
||||
"notes": "p_notes",
|
||||
"location_form": "p_location_form",
|
||||
"total_area": "p_total_area",
|
||||
"rent_contract_num": "p_rent_contract_num",
|
||||
"rent_end_date": "p_rent_end_date",
|
||||
@ -196,7 +198,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_rent_contract_num, :p_rent_end_date
|
||||
:p_location_form, :p_rent_contract_num, :p_rent_end_date
|
||||
)
|
||||
"""),
|
||||
params,
|
||||
|
||||
@ -20,7 +20,7 @@ _info_close_sync_lock = asyncio.Lock()
|
||||
|
||||
class VSPService:
|
||||
EXECUTOR_EDITABLE_FIELDS = {
|
||||
"placement_type",
|
||||
"location_form",
|
||||
"staff_count",
|
||||
"total_area",
|
||||
"rent_contract_num",
|
||||
@ -54,7 +54,7 @@ class VSPService:
|
||||
ssp_ids: list[int] | None = None,
|
||||
open_date_start: date | None = None,
|
||||
open_date_end: date | None = None,
|
||||
placement_type: str | None = None,
|
||||
location_form: str | None = None,
|
||||
staff_count_min: int | None = None,
|
||||
staff_count_max: int | None = None,
|
||||
is_active: bool | None = None,
|
||||
@ -84,7 +84,7 @@ class VSPService:
|
||||
ssp_ids=effective_ssp_ids,
|
||||
open_date_start=open_date_start,
|
||||
open_date_end=open_date_end,
|
||||
placement_type=placement_type,
|
||||
location_form=location_form,
|
||||
staff_count_min=staff_count_min,
|
||||
staff_count_max=staff_count_max,
|
||||
is_active=is_active,
|
||||
@ -154,7 +154,7 @@ class VSPService:
|
||||
ssp_ids: list[int] | None = None,
|
||||
open_date_start: date | None = None,
|
||||
open_date_end: date | None = None,
|
||||
placement_type: str | None = None,
|
||||
location_form: str | None = None,
|
||||
staff_count_min: int | None = None,
|
||||
staff_count_max: int | None = None,
|
||||
) -> tuple[io.BytesIO, str]:
|
||||
@ -165,7 +165,7 @@ class VSPService:
|
||||
ssp_ids=ssp_ids,
|
||||
open_date_start=open_date_start,
|
||||
open_date_end=open_date_end,
|
||||
placement_type=placement_type,
|
||||
location_form=location_form,
|
||||
staff_count_min=staff_count_min,
|
||||
staff_count_max=staff_count_max,
|
||||
is_active=None,
|
||||
@ -188,7 +188,7 @@ class VSPService:
|
||||
"open_date",
|
||||
"close_date",
|
||||
"notes",
|
||||
"placement_type",
|
||||
"location_form",
|
||||
"staff_count",
|
||||
"area",
|
||||
"rent_contract_num",
|
||||
@ -215,7 +215,7 @@ 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.placement_type or None,
|
||||
item.location_form 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,
|
||||
|
||||
@ -40,10 +40,10 @@ def test_vsp_dropdown_smoke(client, admin_tokens, auth_headers):
|
||||
@pytest.mark.parametrize(
|
||||
"params, count",
|
||||
[
|
||||
([("ssp_id", 2)], 2),
|
||||
([("ssp_id", 2)], 1),
|
||||
([("form_id", 1)], 0),
|
||||
([("form_id", 2)], 2),
|
||||
([("ssp_id", 2), ("form_id", 1)], 2),
|
||||
([("form_id", 2)], 1),
|
||||
([("ssp_id", 2), ("form_id", 1)], 1),
|
||||
]
|
||||
)
|
||||
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",
|
||||
"approved_format": "Стандарт",
|
||||
"notes": "Тестовое примечание",
|
||||
"placement_type": "Аренда",
|
||||
"location_form": "Встроенное",
|
||||
"staff_count": 10,
|
||||
"area": 150.5,
|
||||
"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"]["close_date"] == "2025-12-31"
|
||||
assert payload["result"]["approved_format"] == "Стандарт"
|
||||
assert payload["result"]["placement_type"] == "Аренда"
|
||||
assert payload["result"]["location_form"] == "Встроенное"
|
||||
assert payload["result"]["staff_count"] == 10
|
||||
assert payload["result"]["area"] == 150.5
|
||||
assert payload["result"]["rent_contract_num"] == "Д-123/24"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user