|
|
@ -1,3 +1,10 @@ |
|
|
|
USE [FastMoneyPro_Remit] |
|
|
|
GO |
|
|
|
/****** Object: StoredProcedure [dbo].[proc_get_exRate_master] Script Date: 9/4/2023 4:33:08 PM ******/ |
|
|
|
SET ANSI_NULLS ON |
|
|
|
GO |
|
|
|
SET QUOTED_IDENTIFIER ON |
|
|
|
GO |
|
|
|
|
|
|
|
|
|
|
|
ALTER PROC [dbo].[proc_get_exRate_master] ( |
|
|
@ -87,6 +94,7 @@ BEGIN |
|
|
|
,@schemeCount = @schemeCount OUT |
|
|
|
,@customerId = @senderId |
|
|
|
,@createdFrom = 'M' |
|
|
|
,@pCountry = @pCountryId |
|
|
|
|
|
|
|
IF NOT EXISTS ( |
|
|
|
SELECT 1 |
|
|
@ -112,12 +120,12 @@ BEGIN |
|
|
|
END |
|
|
|
|
|
|
|
END |
|
|
|
print '@isFirstTran' + '-> ' + @isFirstTran |
|
|
|
|
|
|
|
SELECT @createdFrom = serviceUsedFor |
|
|
|
FROM customerMaster(NOLOCK) |
|
|
|
WHERE customerId = @senderId |
|
|
|
|
|
|
|
SET @sCountryId = 233 |
|
|
|
SET @sCountryId = 113 |
|
|
|
|
|
|
|
IF ISNULL(@pCountryId, 0) = 0 |
|
|
|
SELECT @pCountryId = countryId |
|
|
@ -149,14 +157,6 @@ BEGIN |
|
|
|
-- SET @isFirstTran = 'Y' |
|
|
|
--END |
|
|
|
-- END |
|
|
|
IF dbo.FNA_GET_AVAILABLE_BALANCE_POINTS(@senderId) < ISNULL(@discountedFee, 0) |
|
|
|
BEGIN |
|
|
|
SELECT '1' ErrorCode |
|
|
|
,'You do not have sufficient points for redeem!' Msg |
|
|
|
,NULL id |
|
|
|
|
|
|
|
RETURN |
|
|
|
END |
|
|
|
|
|
|
|
IF @flag = 'False' |
|
|
|
AND @ProcessFor IN ('dashboard') |
|
|
@ -178,8 +178,7 @@ BEGIN |
|
|
|
AND IsActive = 1 |
|
|
|
AND ISNULL(PaymentMethod, @deliveryMethodId) = @deliveryMethodId |
|
|
|
END |
|
|
|
PRINT '@payoutPartner' |
|
|
|
PRINT @payoutPartner; |
|
|
|
|
|
|
|
IF @payoutPartner IS NOT NULL |
|
|
|
BEGIN |
|
|
|
--GET PAYOUT AGENT DETAILS |
|
|
@ -239,9 +238,6 @@ BEGIN |
|
|
|
RETURN |
|
|
|
END |
|
|
|
|
|
|
|
pRINT '@pAgent'; |
|
|
|
--pRINT @pAgent; |
|
|
|
|
|
|
|
IF @flag = 'false' |
|
|
|
BEGIN |
|
|
|
IF @pCountryId = 151 |
|
|
@ -251,13 +247,12 @@ BEGIN |
|
|
|
INTO #AgentList |
|
|
|
FROM agentMaster(NOLOCK) |
|
|
|
WHERE extCode = 'NP ANYWHERE' |
|
|
|
PRINT @sCountryId; |
|
|
|
PRINT @sAgent; |
|
|
|
PRINT @sBranch; |
|
|
|
PRINT @collCurr; |
|
|
|
PRINT @pCountryId; |
|
|
|
PRINT @pCurr; |
|
|
|
PRINT @deliveryMethodId; |
|
|
|
|
|
|
|
PRINT '@sAgent' |
|
|
|
PRINT @sAgent |
|
|
|
PRINT '@sBranch' |
|
|
|
PRINT @sBranch |
|
|
|
|
|
|
|
SELECT @exRate = customerRate |
|
|
|
,@pCurrHoMargin = pCurrHoMargin |
|
|
|
FROM ( |
|
|
@ -267,7 +262,7 @@ BEGIN |
|
|
|
,CUSTOMERRATE |
|
|
|
,pCurrHoMargin |
|
|
|
FROM #AgentList A |
|
|
|
CROSS APPLY dbo.FNAGetExRate(@sCountryId, @sAgent, @sBranch, @collCurr, @pCountryId, AgentId, @pCurr, @deliveryMethodId) FN |
|
|
|
CROSS APPLY dbo.FNAGetExRate(@sCountryId, CASE @sAgent WHEN 0 THEN @sBranch ELSE @sAgent END , @sBranch, @collCurr, @pCountryId, AgentId, @pCurr, @deliveryMethodId) FN |
|
|
|
) X |
|
|
|
WHERE X.ROW_NUM = 1 |
|
|
|
END |
|
|
@ -287,14 +282,13 @@ BEGIN |
|
|
|
RETURN |
|
|
|
END |
|
|
|
|
|
|
|
|
|
|
|
PRINT '@isFirstTran:' + CAST( @isFirstTran AS VARCHAR); |
|
|
|
PRINT '@isEligible:' + CAST( @isEligible AS VARCHAR); |
|
|
|
PRINT '@tranCount:' + CAST( @tranCount AS VARCHAR); |
|
|
|
PRINT '@@schemeCount:' + CAST( @schemeCount AS VARCHAR); |
|
|
|
PRINT @isFirstTran |
|
|
|
PRINT @isEligible |
|
|
|
|
|
|
|
IF @calBy = 'C' |
|
|
|
BEGIN |
|
|
|
IF ( @tranCount >= @schemeCount |
|
|
|
IF ( |
|
|
|
@tranCount = @schemeCount |
|
|
|
AND ISNULL(@user, 'onlinedefault') <> 'onlinedefault' |
|
|
|
--AND ISNULL(@ProcessFor, '') = 'send' |
|
|
|
AND @isEligible = 'Y' |
|
|
@ -317,19 +311,19 @@ BEGIN |
|
|
|
SELECT @serviceChargetmp = isnull(amount, 0) |
|
|
|
FROM [dbo].FNAGetServiceCharge(@sCountryId, @sSuperAgent, @sAgent, @sBranch, @pCountryId, @pSuperAgent, @pAgent, @pBranch, @deliveryMethodId, @cAmt, @collCurr) |
|
|
|
|
|
|
|
--IF (@discountedFee > '0.00') |
|
|
|
-- AND (@serviceChargetmp < @discountedFee) |
|
|
|
--BEGIN |
|
|
|
-- SELECT '8' ErrorCode |
|
|
|
-- ,'Redeem point can not be more than service charge' Msg |
|
|
|
-- ,NULL id |
|
|
|
|
|
|
|
-- RETURN; |
|
|
|
--END |
|
|
|
--ELSE |
|
|
|
--BEGIN |
|
|
|
-- SELECT @serviceCharge = @serviceChargetmp - ISNULL(@discountedFee, 0) |
|
|
|
--END |
|
|
|
IF (@discountedFee > '0.00') |
|
|
|
AND (@serviceChargetmp < @discountedFee) |
|
|
|
BEGIN |
|
|
|
SELECT '8' ErrorCode |
|
|
|
,'Redeem point can not be more than service charge' Msg |
|
|
|
,NULL id |
|
|
|
|
|
|
|
RETURN; |
|
|
|
END |
|
|
|
ELSE |
|
|
|
BEGIN |
|
|
|
SELECT @serviceCharge = @serviceChargetmp - ISNULL(@discountedFee, 0) |
|
|
|
END |
|
|
|
END |
|
|
|
ELSE |
|
|
|
BEGIN |
|
|
@ -362,7 +356,7 @@ BEGIN |
|
|
|
SET @scDiscount = @serviceCharge - @scValue |
|
|
|
END |
|
|
|
|
|
|
|
SET @tAmt = @cAmt - @serviceCharge + @scDiscount + ISNULL(@discountedFee, 0) |
|
|
|
SET @tAmt = @cAmt - @serviceCharge + @scDiscount |
|
|
|
SET @pAmt = @tAmt * (@exRate + @exRateOffer) |
|
|
|
SET @pAmt = FLOOR(@pAmt) |
|
|
|
END |
|
|
@ -372,7 +366,7 @@ BEGIN |
|
|
|
SET @tAmt = CEILING(@pAmt / (@exRate + @exRateOffer)) |
|
|
|
|
|
|
|
IF ( |
|
|
|
@tranCount >= @schemeCount |
|
|
|
@tranCount = @schemeCount |
|
|
|
AND ISNULL(@user, 'onlinedefault') <> 'onlinedefault' |
|
|
|
--AND ISNULL(@ProcessFor, '') = 'send' |
|
|
|
AND @isEligible = 'Y' |
|
|
@ -395,19 +389,19 @@ BEGIN |
|
|
|
SELECT @serviceChargetmp = isnull(amount, 0) |
|
|
|
FROM [dbo].FNAGetServiceCharge(@sCountryId, @sSuperAgent, @sAgent, @sBranch, @pCountryId, @pSuperAgent, @pAgent, @pBranch, @deliveryMethodId, @tAmt, @collCurr) |
|
|
|
|
|
|
|
--IF (@discountedFee > '0.00') |
|
|
|
-- AND (@serviceChargetmp < @discountedFee) |
|
|
|
--BEGIN |
|
|
|
-- SELECT '8' ErrorCode |
|
|
|
-- ,'Redeem point can not be more than service charge' Msg |
|
|
|
-- ,NULL id |
|
|
|
|
|
|
|
-- RETURN; |
|
|
|
--END |
|
|
|
--ELSE |
|
|
|
--BEGIN |
|
|
|
-- SELECT @serviceCharge = @serviceChargetmp - ISNULL(@discountedFee, 0) |
|
|
|
--END |
|
|
|
IF (@discountedFee > '0.00') |
|
|
|
AND (@serviceChargetmp < @discountedFee) |
|
|
|
BEGIN |
|
|
|
SELECT '8' ErrorCode |
|
|
|
,'Redeem point can not be more than service charge' Msg |
|
|
|
,NULL id |
|
|
|
|
|
|
|
RETURN; |
|
|
|
END |
|
|
|
ELSE |
|
|
|
BEGIN |
|
|
|
SELECT @serviceCharge = @serviceChargetmp - ISNULL(@discountedFee, 0) |
|
|
|
END |
|
|
|
END |
|
|
|
ELSE |
|
|
|
BEGIN |
|
|
@ -439,7 +433,7 @@ BEGIN |
|
|
|
SET @scDiscount = @serviceCharge - @scValue |
|
|
|
END |
|
|
|
|
|
|
|
SET @cAmt = (@tAmt + @serviceCharge - @scDiscount) - ISNULL(@discountedFee, 0) |
|
|
|
SET @cAmt = (@tAmt + @serviceCharge - @scDiscount) |
|
|
|
SET @cAmt = CEILING(@cAmt) |
|
|
|
END |
|
|
|
|
|
|
@ -664,19 +658,19 @@ BEGIN |
|
|
|
SELECT @serviceChargetmp = ISNULL(amount, 0) |
|
|
|
FROM [dbo].FNAGetServiceCharge(@sCountryId, @sSuperAgent, @sAgent, @sBranch, @pCountryId, @pSuperAgent, @pAgent, @pBranch, @deliveryMethodId, @cAmt, @collCurr) |
|
|
|
|
|
|
|
--IF (@discountedFee > '0.00') |
|
|
|
-- AND (@serviceChargetmp < @discountedFee) |
|
|
|
--BEGIN |
|
|
|
-- SELECT '8' ErrorCode |
|
|
|
-- ,'Redeem points can not be more than service charge' Msg |
|
|
|
-- ,NULL id |
|
|
|
|
|
|
|
-- RETURN; |
|
|
|
--END |
|
|
|
--ELSE |
|
|
|
--BEGIN |
|
|
|
-- SELECT @serviceCharge = ISNULL(@serviceChargetmp, 0) - ISNULL(@discountedFee, 0) |
|
|
|
--END |
|
|
|
IF (@discountedFee > '0.00') |
|
|
|
AND (@serviceChargetmp < @discountedFee) |
|
|
|
BEGIN |
|
|
|
SELECT '8' ErrorCode |
|
|
|
,'Redeem points can not be more than service charge' Msg |
|
|
|
,NULL id |
|
|
|
|
|
|
|
RETURN; |
|
|
|
END |
|
|
|
ELSE |
|
|
|
BEGIN |
|
|
|
SELECT @serviceCharge = ISNULL(@serviceChargetmp, 0) - ISNULL(@discountedFee, 0) |
|
|
|
END |
|
|
|
END |
|
|
|
ELSE |
|
|
|
BEGIN |
|
|
@ -709,7 +703,7 @@ BEGIN |
|
|
|
SET @scDiscount = @serviceCharge - @scValue |
|
|
|
END |
|
|
|
|
|
|
|
SET @tAmt = @cAmt - @serviceCharge + @scDiscount + ISNULL(@discountedFee, 0) |
|
|
|
SET @tAmt = @cAmt - @serviceCharge + @scDiscount |
|
|
|
SET @pAmt = @tAmt * (@exRate + @exRateOffer) |
|
|
|
SET @pAmt = FLOOR(@pAmt) |
|
|
|
END |
|
|
@ -722,19 +716,19 @@ BEGIN |
|
|
|
SELECT @serviceChargetmp = isnull(amount, 0) |
|
|
|
FROM [dbo].FNAGetServiceCharge(@sCountryId, @sSuperAgent, @sAgent, @sBranch, @pCountryId, @pSuperAgent, @pAgent, @pBranch, @deliveryMethodId, @tAmt, @collCurr) |
|
|
|
|
|
|
|
--IF (@discountedFee > '0.00') |
|
|
|
-- AND (@serviceCharge < @discountedFee) |
|
|
|
--BEGIN |
|
|
|
-- SELECT '8' ErrorCode |
|
|
|
-- ,'Redeem points can not be more than service charge' Msg |
|
|
|
-- ,NULL id |
|
|
|
|
|
|
|
-- RETURN; |
|
|
|
--END |
|
|
|
--ELSE |
|
|
|
--BEGIN |
|
|
|
-- SELECT @serviceCharge = ISNULL(@serviceChargetmp, 0) - ISNULL(@discountedFee, 0) |
|
|
|
--END |
|
|
|
IF (@discountedFee > '0.00') |
|
|
|
AND (@serviceCharge < @discountedFee) |
|
|
|
BEGIN |
|
|
|
SELECT '8' ErrorCode |
|
|
|
,'Redeem points can not be more than service charge' Msg |
|
|
|
,NULL id |
|
|
|
|
|
|
|
RETURN; |
|
|
|
END |
|
|
|
ELSE |
|
|
|
BEGIN |
|
|
|
SELECT @serviceCharge = ISNULL(@serviceChargetmp, 0) - ISNULL(@discountedFee, 0) |
|
|
|
END |
|
|
|
END |
|
|
|
ELSE |
|
|
|
BEGIN |
|
|
@ -765,13 +759,8 @@ BEGIN |
|
|
|
SET @scDiscount = @serviceCharge - @scValue |
|
|
|
END |
|
|
|
|
|
|
|
SET @cAmt = (@tAmt + @serviceCharge - @scDiscount)-- - ISNULL(@discountedFee, 0) |
|
|
|
SET @cAmt = (@tAmt + @serviceCharge - @scDiscount) |
|
|
|
SET @cAmt = ROUND(@cAmt, @currDecimal) |
|
|
|
|
|
|
|
--New logic for calculating new tAmt and pAmt after adding discount fee |
|
|
|
SET @tAmt = @tAmt + ISNULL(@discountedFee, 0) |
|
|
|
SET @pAmt = @tAmt * (@exRate + @exRateOffer) |
|
|
|
SET @pAmt = FLOOR(@pAmt) |
|
|
|
END |
|
|
|
|
|
|
|
--4. Validate Country Sending Limit |
|
|
@ -914,4 +903,3 @@ BEGIN |
|
|
|
,discountedFee = ISNULL(@discountedFee, 0) |
|
|
|
END |
|
|
|
END |
|
|
|
|