IF EXISTS ( SELECT * 
            FROM   sysobjects 
            WHERE  id = object_id(N'[dbo].[sp_ReconByFiscalPeriod]') 
                   and OBJECTPROPERTY(id, N'IsProcedure') = 1 )
BEGIN
    DROP PROCEDURE [dbo].[sp_ReconByFiscalPeriod]
END

IF EXISTS(select * FROM sys.views where name = 'v_DebitListing')
BEGIN
	DROP VIEW v_DebitListing
END

IF EXISTS(select * FROM sys.views where name = 'v_InvoiceListing')
BEGIN
	DROP VIEW v_InvoiceListing
END

IF EXISTS(select * FROM sys.views where name = 'v_CreditListing')
BEGIN
	DROP VIEW v_CreditListing
END

IF EXISTS(select * FROM sys.views where name = 'v_ReceiptListing')
BEGIN
	DROP VIEW v_ReceiptListing
END

IF EXISTS(select * FROM sys.views where name = 'v_ReconByFiscalPeriod')
BEGIN
	DROP VIEW v_ReconByFiscalPeriod
END

UPDATE	A
	SET	dateOfTransaction = 
		CASE WHEN A.dateOfCapture < '1 mar 2017'
		THEN dateOfService
		ELSE CASE WHEN procedureType IN ('PM','PA','CJ','DJ') THEN dateOfService ELSE dateOfCapture END
		END
--SELECT	*
FROM	pal_Account A