Skip to content

Commit

Permalink
PH-1067 fix function add_mandate exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Artjom Aralov committed Feb 28, 2024
1 parent a6bc6f4 commit 45cd8f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def create_mandate_pg(uri, data):
data['mandate_role'],
data['mandate_validity_period_from'],
data['mandate_validity_period_through'],
'YES' if data['mandate_can_sub_delegate'] else 'NO',
data['mandate_can_sub_delegate'],
data['data_created_by'],
data['document_uuid'],
data['data_can_display_document_to_delegate']
Expand Down
8 changes: 4 additions & 4 deletions tests/pg_data/03a_function_add_mandate.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CREATE OR REPLACE FUNCTION paasuke_add_mandate(
p_role TEXT,
p_validity_period_from DATE,
p_validity_period_through DATE,
p_sub_delegable TEXT,
p_can_sub_delegate BOOLEAN,
p_created_by TEXT,
p_document_uuid TEXT,
p_can_display_document_to_delegate BOOLEAN
Expand All @@ -40,8 +40,8 @@ BEGIN
end if;


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

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

0 comments on commit 45cd8f2

Please sign in to comment.