Skip to content

Commit 45cd8f2

Browse files
author
Artjom Aralov
committed
PH-1067 fix function add_mandate exception
1 parent a6bc6f4 commit 45cd8f2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

api/services.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def create_mandate_pg(uri, data):
274274
data['mandate_role'],
275275
data['mandate_validity_period_from'],
276276
data['mandate_validity_period_through'],
277-
'YES' if data['mandate_can_sub_delegate'] else 'NO',
277+
data['mandate_can_sub_delegate'],
278278
data['data_created_by'],
279279
data['document_uuid'],
280280
data['data_can_display_document_to_delegate']

tests/pg_data/03a_function_add_mandate.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ CREATE OR REPLACE FUNCTION paasuke_add_mandate(
1414
p_role TEXT,
1515
p_validity_period_from DATE,
1616
p_validity_period_through DATE,
17-
p_sub_delegable TEXT,
17+
p_can_sub_delegate BOOLEAN,
1818
p_created_by TEXT,
1919
p_document_uuid TEXT,
2020
p_can_display_document_to_delegate BOOLEAN
@@ -40,8 +40,8 @@ BEGIN
4040
end if;
4141

4242

43-
IF p_sub_delegable = 'YES' AND rec_role_conf.sub_delegable = 'NO' THEN
44-
RAISE 'The role with code=% is defined with sub_delegable=NO', p_role USING ERRCODE = '23011';
43+
IF p_can_sub_delegate = TRUE AND rec_role_conf.sub_delegable = 'NO' THEN
44+
RAISE 'The role with code=% is defined with sub_delegable=NO but mandate to be added has it true', p_role USING ERRCODE = '23011';
4545
end if;
4646

4747
-- Insert or update person record corresponding to representee
@@ -67,6 +67,6 @@ BEGIN
6767
INSERT INTO mandate (representee_id, delegate_id, role, validity_period_from, validity_period_through,
6868
can_sub_delegate, created_by)
6969
VALUES (v_representee_id, v_delegate_id, p_role, p_validity_period_from::DATE, p_validity_period_through::DATE,
70-
p_sub_delegable, p_created_by);
70+
p_can_sub_delegate, p_created_by);
7171
END;
7272
$$ LANGUAGE PLPGSQL;

0 commit comments

Comments
 (0)