
create or replace view BCD_ICT_SV_DATA_VIEW
as
(
select 'HO' BRANCH, TBK_BOOKING_NUMBER IB_OB, TBSVH_SV_NUMBER SV_NO, TBSVH_DATE SV_DATE, TBSVH_SUPPLIER SUPPLIER, TBSVH_PROVIDER PROVIDER, 
TBSVH_AP_CODE IN_AP, AP_NAME AP_NAME, TBSVH_CURRENCY, TBSVH_EX_RATE EX_RATE, TBSVH_FOREIGN_AMOUNT FOR_AMT, TBSVH_LOCAL_AMOUNT KES_AMT,
TBSVH_VOUCHER_REMARKS SV_REM, TBSVH_STATUS SV_STATUS, TBSVH_CREATED_BY SV_CREATED_BY,
TBSVH_VOUCHER_DESCRIPTION SER_DES
from
ke014t3.id_tb_booking_header A, ke014t3.ID_TB_SERVICE_VOUCHER_DETAILS B, ke014t3.id_tb_service_voucher_header c,ke014t3.id_ap_master d
where TBK_BOOKING_NUMBER=TBSVD_BOOKING_NUMBER
and tbk_status<>'F'
and TBSVH_AP_CODE=AP_CODE
and TBSVD_SV_SERIAL=TBSVH_SERIAL
union all
select 'SAFCOM' BRANCH, TBK_BOOKING_NUMBER IB_OB, TBSVH_SV_NUMBER SV_NO, TBSVH_DATE SV_DATE, TBSVH_SUPPLIER SUPPLIER, TBSVH_PROVIDER PROVIDER, 
TBSVH_AP_CODE IN_AP, AP_NAME AP_NAME, TBSVH_CURRENCY, TBSVH_EX_RATE EX_RATE, TBSVH_FOREIGN_AMOUNT FOR_AMT, TBSVH_LOCAL_AMOUNT KES_AMT,
TBSVH_VOUCHER_REMARKS SV_REM, TBSVH_STATUS SV_STATUS, TBSVH_CREATED_BY SV_CREATED_BY,
TBSVH_VOUCHER_DESCRIPTION SER_DES
from
ke074t3.id_tb_booking_header A, ke074t3.ID_TB_SERVICE_VOUCHER_DETAILS B, ke074t3.id_tb_service_voucher_header c,ke074t3.id_ap_master d
where TBK_BOOKING_NUMBER=TBSVD_BOOKING_NUMBER
and tbk_status<>'F'
and TBSVH_AP_CODE=AP_CODE
and TBSVD_SV_SERIAL=TBSVH_SERIAL
)
