You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

38 lines
998 B

USE [FastMoneyPro_Remit]
GO
/****** Object: StoredProcedure [dbo].[proc_UpdateCustomerBalance] Script Date: 7/4/2019 11:35:48 AM ******/
DROP PROCEDURE [dbo].[proc_UpdateCustomerBalance]
GO
/****** Object: StoredProcedure [dbo].[proc_UpdateCustomerBalance] Script Date: 7/4/2019 11:35:48 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[proc_UpdateCustomerBalance]
(
@controlNo VARCHAR(20)=NULL,
@type VARCHAR(20)=NULL
)
AS
BEGIN
IF(@type='deduct')
BEGIN
UPDATE cm
SET cm.availableBalance=ISNULL(cm.availableBalance,0) -rt.cAmt + ISNULL(rt.schemePremium,0)
FROM dbo.remitTranTemp rt WITH (NOLOCK)
INNER JOIN dbo.customerMaster cm
ON rt.createdBy=cm.email
WHERE rt.controlNo=@controlNo
END
ELSE
BEGIN
UPDATE cm
SET cm.availableBalance=ISNULL(cm.availableBalance,0) + rt.cAmt - ISNULL(rt.schemePremium,0)
FROM dbo.remitTranTemp rt WITH (NOLOCK)
INNER JOIN dbo.customerMaster cm
ON rt.createdBy=cm.email
WHERE rt.controlNo=@controlNo
END
END
GO