aonestar
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sp_check_transaction
Parameters
Name
Type
Mode
trn_id
integer
IN
modify_type
text
IN
check_enday
boolean
IN (DEFAULT true)
Definition
DECLARE _voided bool; _transfer_out bool; _post_flag char(1); _register_status char(1); _folio_status char(1); _folio_locked bool; _folio_item int; _charge_date date; _reference TEXT; messages jsonb = $${ "30201" : "Transaction does not exists", "30202" : "Transaction already voided", "30203" : "Transaction already transfered out", "30204" : "Cannot modify deposit transaction", "30205" : "Cannot void outdated transaction", "30206" : "Cannot modify auto-post transaction", "90001" : "End-day process in progress" }$$; BEGIN /* modify_type : void, update, split */ if check_enday THEN CALL sp_check_endday_process(); END IF; SELECT t.voided, t.transfer_out, t.post_flag, t.folio_item, t.charge_date, t.reference FROM transactions t WHERE id = $1 INTO _voided, _transfer_out, _post_flag, _folio_item, _charge_date, _reference; CASE WHEN _folio_item IS NULL THEN RAISE EXCEPTION SQLSTATE '99999' USING detail = fn_result_error('30201', messages->>'30201'); WHEN _voided THEN RAISE EXCEPTION SQLSTATE '99999' USING detail = fn_result_error('30202', messages->>'30202'); WHEN _transfer_out THEN RAISE EXCEPTION SQLSTATE '99999' USING detail = fn_result_error('30203', messages->>'30203'); WHEN (modify_type in ('update','void') AND _post_flag = 'D') THEN RAISE EXCEPTION SQLSTATE '99999' USING detail = fn_result_error('30204', messages->>'30204'); WHEN (modify_type = 'void' AND _charge_date < fn_system_date()) THEN RAISE EXCEPTION SQLSTATE '99999' USING detail = fn_result_error('30205', messages->>'30205'); WHEN (modify_type = 'update' AND _reference = 'AUTO POST') THEN RAISE EXCEPTION SQLSTATE '99999' USING detail = fn_result_error('30206', messages->>'30206'); ELSE END CASE; if modify_type <> 'update' THEN CALL sp_check_folio_item(_folio_item); END IF; END