--create or replace view ke019t3.BCD_ICT_RCT_DETAILS as
select
extract(year from RH_DOC_DATE) Year, extract(month from RH_DOC_DATE) Month,RH_DOC_DATE, rh_doc_type, RH_DOC_NUMBER,
Replace(replace(replace(replace(replace(replace(RH_NOTES,',','-'),'/','-'),chr(9),'-'),chr(10),'-'),chr(13),'-') ,'.','-') RH_NOTES,
RH_CASH_BANK_CODE,
decode((select  bank_type from ke019t3.id_bank_master where bank_type='C' and RH_CASH_BANK_CODE=BANK_CODE and rownum=1),'C','CASH','BANK') Bank_Type,
RH_CURRENCY, RH_EXCHANGE_RATE,
RH_FOREIGN_AMOUNT,
(case
when rh_currency='KES' then RH_FOREIGN_AMOUNT
end) KES_AMT,
(case
when rh_currency='USD' then RH_FOREIGN_AMOUNT
end) USD_AMT,
Replace(replace(replace(replace(replace(replace(RH_OTHER_REFERENCE,',','-'),'/','-'),chr(9),'-'),chr(10),'-'),chr(13),'-') ,'.','-') RH_OTHER_REFERENCE,
RH_CHEQUE_NUMBER,
Replace(replace(replace(replace(replace(replace(RH_NARRATION,',','-'),'/','-'),chr(9),'-'),chr(10),'-'),chr(13),'-') ,'.','-') RH_NARRATION,
RH_CREATED_BY, RH_CREATED_ON
from
ke019t3.id_receipt_header where RH_STATUS='P' and RH_BASE_DOC_TYPE<>'RCT-REV' and RH_DOC_DATE>'31-DEC-2018' order by rh_doc_date

