shakun
1 year ago
10 changed files with 4295 additions and 0 deletions
-
13ReferEarn/FNA_GET_RUNNING_BALANCE_POINT.sql
-
39ReferEarn/Tables_Referral.sql
-
114ReferEarn/proc_InsertRewardPoints.sql
-
1605ReferEarn/proc_SendTransaction.sql
-
917ReferEarn/proc_get_exRate_master.sql
-
BINStoredProc/JsonRx_Proc_UserRegistration_V2.sql
-
BINStoredProc/PROC_GENERATE_MEMBERSHIP_ID.sql
-
1598StoredProc/proc_SendTransaction.sql
-
BINStoredProc/proc_get_exrate_master.sql
-
9insertAC.sql
@ -0,0 +1,13 @@ |
|||||
|
|
||||
|
ALTER FUNCTION [dbo].[FNA_GET_AVAILABLE_BALANCE_POINTS](@CustomerId BIGINT) |
||||
|
RETURNS MONEY |
||||
|
AS |
||||
|
BEGIN |
||||
|
DECLARE @BALANCE MONEY |
||||
|
|
||||
|
SELECT @BALANCE = ISNULL(SUM(CASE WHEN tranType = 'CR' THEN amount ELSE -1 * amount END), 0) |
||||
|
FROM Customer_Promotion CP(NOLOCK) |
||||
|
WHERE sourceCustomerId = @CustomerId |
||||
|
|
||||
|
RETURN ISNULL(@BALANCE, 0) |
||||
|
END |
@ -0,0 +1,39 @@ |
|||||
|
select * from Customer_Promotion |
||||
|
|
||||
|
CREATE TABLE TBL_PROMOTION_MASTER_SETUP |
||||
|
( |
||||
|
RowId TINYINT NOT NULL IDENTITY(1, 1) PRIMARY KEY |
||||
|
, Points INT NOT NULL |
||||
|
, IsActive BIT NOT NULL DEFAULT(1) |
||||
|
, UpdatedBy VARCHAR(40) NULL |
||||
|
, UpdatedDate DATETIME NULL |
||||
|
); |
||||
|
|
||||
|
select * from TBL_PROMOTION_MASTER_SETUP |
||||
|
ALTER TABLE Customer_Promotion ADD EquivalentPoints INT |
||||
|
|
||||
|
insert into TBL_PROMOTION_MASTER_SETUP |
||||
|
select 100, 1, null, null |
||||
|
|
||||
|
CREATE TABLE TBL_PROMOTION_SETUP |
||||
|
( |
||||
|
RowId INT NOT NULL IDENTITY(1, 1) PRIMARY KEY |
||||
|
, Points INT NOT NULL |
||||
|
, PromotionType VARCHAR(15) NOT NULL |
||||
|
, IsActive BIT NOT NULL DEFAULT(1) |
||||
|
, UpdatedBy VARCHAR(40) NULL |
||||
|
, UpdatedDate DATETIME NULL |
||||
|
); |
||||
|
|
||||
|
INSERT INTO TBL_PROMOTION_SETUP |
||||
|
SELECT 100, 'REGISTRATION', 1, NULL, NULL UNION |
||||
|
SELECT 400, 'TRANSACTION', 1, NULL, NULL |
||||
|
|
||||
|
|
||||
|
SELECT * FROM TBL_PROMOTION_SETUP |
||||
|
|
||||
|
SELECT * FROM staticDataValue (NOLOCK) |
||||
|
WHERE typeId = 8106 |
||||
|
AND isActive = 'Y' |
||||
|
|
||||
|
|
@ -0,0 +1,114 @@ |
|||||
|
|
||||
|
|
||||
|
ALTER PROC [dbo].[proc_InsertRewardPoints] ( |
||||
|
@Flag VARCHAR(20) |
||||
|
,@TranId BIGINT = NULL |
||||
|
,@CustomerId BIGINT = NULL |
||||
|
,@ReferralId BIGINT = NULL |
||||
|
,@rewardPoints INT = NULL |
||||
|
,@rewardValue MONEY = NULL |
||||
|
) |
||||
|
AS; |
||||
|
SET NOCOUNT ON; |
||||
|
SET XACT_ABORT ON; |
||||
|
-- #1526 - Post production fixes for Redeem & Earn |
||||
|
BEGIN |
||||
|
DECLARE @sourceCustomerId INT, @destinationCustomerId INT, @code NVARCHAR(50), @runningBalance MONEY, @totalDrAmount MONEY |
||||
|
, @totalCrAmount MONEY , @transactionPoints INT, @registrationPoints INT, @EquivalentPointsForOne INT, @AvailableBalance MONEY |
||||
|
|
||||
|
SELECT @transactionPoints = Points |
||||
|
FROM TBL_PROMOTION_SETUP (NOLOCK) |
||||
|
WHERE PromotionType = 'REGISTRATION' |
||||
|
AND IsActive = 1 |
||||
|
|
||||
|
SELECT @registrationPoints = Points |
||||
|
FROM TBL_PROMOTION_SETUP (NOLOCK) |
||||
|
WHERE PromotionType = 'TRANSACTION' |
||||
|
AND IsActive = 1 |
||||
|
|
||||
|
SELECT @EquivalentPointsForOne = Points |
||||
|
FROM TBL_PROMOTION_MASTER_SETUP (NOLOCK) |
||||
|
WHERE IsActive = 1 |
||||
|
|
||||
|
IF @Flag = 'REGISTER' |
||||
|
BEGIN |
||||
|
--@CustomerId = Customer who is newly registering in the system |
||||
|
--@ReferralId = Customer who is already in the system/ who have referred @CustomerId |
||||
|
--EXEC proc_InsertRewardPoints @Flag = 'REGISTER', @CustomerId = 1, @ReferralId = 2 |
||||
|
INSERT INTO Customer_Promotion(sourceCustomerId, destinationCustomerId, code, codeType, referenceId, rewardType, amount, createdDate, status, approvedDate, tranType, runningBalance, EquivalentPoints) |
||||
|
SELECT @CustomerId, @ReferralId, membershipId, 'REGISTRATION', @ReferralId, 'REFER_EARN', @registrationPoints/@EquivalentPointsForOne, GETDATE(), 1, GETDATE(), 'CR' |
||||
|
, DBO.FNA_GET_AVAILABLE_BALANCE_POINTS(@CustomerId) + (@registrationPoints/@EquivalentPointsForOne), @registrationPoints |
||||
|
FROM customerMaster (NOLOCK) |
||||
|
WHERE customerId = @CustomerId |
||||
|
|
||||
|
UNION |
||||
|
|
||||
|
SELECT @ReferralId, @ReferralId, membershipId, 'REGISTRATION', @ReferralId, 'REFER_EARN', @registrationPoints/@EquivalentPointsForOne, GETDATE(), 1, GETDATE(), 'CR' |
||||
|
, DBO.FNA_GET_AVAILABLE_BALANCE_POINTS(@ReferralId) + (@registrationPoints/@EquivalentPointsForOne), @registrationPoints |
||||
|
FROM customerMaster (NOLOCK) |
||||
|
WHERE customerId = @ReferralId |
||||
|
|
||||
|
UPDATE customerMaster SET bonusPoint = ISNULL(bonusPoint, 0) + @registrationPoints WHERE customerId = @CustomerId |
||||
|
UPDATE customerMaster SET bonusPoint = ISNULL(bonusPoint, 0) + @registrationPoints WHERE customerId = @ReferralId |
||||
|
END |
||||
|
ELSE IF @Flag = 'TRANSACTION' |
||||
|
BEGIN |
||||
|
--@CustomerId = Customer who is doing transaction |
||||
|
--EXEC proc_InsertRewardPoints @Flag = 'TRANSACTION', @CustomerId = 1, @TranId = 1234567890 |
||||
|
IF EXISTS(SELECT 'X' FROM REMITTRAN(NOLOCK) WHERE ID = @TranId AND CAMT <= 100) |
||||
|
BEGIN |
||||
|
SELECT @sourceCustomerId = sourceCustomerId, @destinationCustomerId = destinationCustomerId |
||||
|
FROM Customer_Promotion (NOLOCK) |
||||
|
WHERE sourceCustomerId = @CustomerId |
||||
|
and code = 'REGISTRATION' |
||||
|
|
||||
|
IF ISNULL(@destinationCustomerId, 0) <> 0 |
||||
|
BEGIN |
||||
|
IF NOT EXISTS(SELECT 'X' FROM Customer_Promotion(NOLOCK) WHERE code = 'FIRST_TXN' AND sourceCustomerId = @CustomerId) |
||||
|
BEGIN |
||||
|
INSERT INTO Customer_Promotion(sourceCustomerId, destinationCustomerId, code, codeType, referenceId, rewardType, amount, createdDate, status, approvedDate, tranType, runningBalance, EquivalentPoints) |
||||
|
SELECT @sourceCustomerId, @destinationCustomerId, membershipId, 'FIRST_TXN', @TranId, 'REFER_EARN', @transactionPoints/@EquivalentPointsForOne, GETDATE(), 1, GETDATE(), 'CR' |
||||
|
, DBO.FNA_GET_AVAILABLE_BALANCE_POINTS(@sourceCustomerId) + (@transactionPoints/@EquivalentPointsForOne), @transactionPoints |
||||
|
FROM customerMaster (NOLOCK) |
||||
|
WHERE customerId = @sourceCustomerId |
||||
|
|
||||
|
UNION |
||||
|
|
||||
|
SELECT @destinationCustomerId, @sourceCustomerId, membershipId, 'FIRST_TXN', @TranId, 'REFER_EARN', @transactionPoints/@EquivalentPointsForOne, GETDATE(), 1, GETDATE(), 'CR' |
||||
|
, DBO.FNA_GET_AVAILABLE_BALANCE_POINTS(@destinationCustomerId) + (@transactionPoints/@EquivalentPointsForOne), @transactionPoints |
||||
|
FROM customerMaster (NOLOCK) |
||||
|
WHERE customerId = @destinationCustomerId |
||||
|
|
||||
|
UPDATE customerMaster SET bonusPoint = ISNULL(bonusPoint, 0) + @transactionPoints WHERE customerId = @sourceCustomerId |
||||
|
UPDATE customerMaster SET bonusPoint = ISNULL(bonusPoint, 0) + @transactionPoints WHERE customerId = @destinationCustomerId |
||||
|
END |
||||
|
END |
||||
|
END |
||||
|
END |
||||
|
ELSE IF @Flag = 'DEBIT' |
||||
|
BEGIN |
||||
|
IF ISNULL(@rewardPoints, 0) > 0 |
||||
|
BEGIN |
||||
|
--@CustomerId = Customer who is doing transaction |
||||
|
--EXEC proc_InsertRewardPoints @Flag = 'DEBIT', @CustomerId = 1, @rewardPoints = 100, @TranId = 1234567890 |
||||
|
|
||||
|
SELECT @AvailableBalance = DBO.FNA_GET_AVAILABLE_BALANCE_POINTS(@CustomerId) |
||||
|
|
||||
|
IF ISNULL(@rewardPoints, 0) > ISNULL(@AvailableBalance, 0) |
||||
|
BEGIN |
||||
|
SELECT 1 Code, 'Insufficient Balance For Rededem!' msg, NULL id |
||||
|
RETURN; |
||||
|
END |
||||
|
|
||||
|
INSERT INTO Customer_Promotion(sourceCustomerId, destinationCustomerId, code, codeType, referenceId, rewardType, amount, createdDate, status, approvedDate, tranType, runningBalance, EquivalentPoints) |
||||
|
SELECT @CustomerId, 0, membershipId, 'REDEEM', @TranId, 'REFER_EARN', @rewardValue, GETDATE(), 1, GETDATE(), 'DR' |
||||
|
, DBO.FNA_GET_AVAILABLE_BALANCE_POINTS(@CustomerId) - @rewardValue, @rewardValue * @EquivalentPointsForOne |
||||
|
FROM customerMaster (NOLOCK) |
||||
|
WHERE customerId = @CustomerId |
||||
|
|
||||
|
UPDATE customerMaster SET bonusPoint = ISNULL(bonusPoint, 0) - @rewardPoints WHERE customerId = @CustomerId |
||||
|
END |
||||
|
END |
||||
|
END |
||||
|
|
||||
|
|
1605
ReferEarn/proc_SendTransaction.sql
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,917 @@ |
|||||
|
|
||||
|
|
||||
|
ALTER PROC [dbo].[proc_get_exRate_master] ( |
||||
|
@flag VARCHAR(20) |
||||
|
,@user VARCHAR(100) = NULL |
||||
|
,@sCountryId INT = NULL |
||||
|
,@sAgent INT = NULL |
||||
|
,@sSuperAgent INT = NULL |
||||
|
,@sBranch INT = NULL |
||||
|
,@senderId BIGINT = NULL |
||||
|
,@collCurr VARCHAR(5) = NULL |
||||
|
,@pCountryId INT = NULL |
||||
|
,@pCountry VARCHAR(50) = NULL |
||||
|
,@pAgent INT = NULL |
||||
|
,@pCurr VARCHAR(5) = NULL |
||||
|
,@deliveryMethodId INT = NULL |
||||
|
,@cAmt MONEY = NULL |
||||
|
,@pAmt MONEY = NULL |
||||
|
,@calBy CHAR(1) = NULL |
||||
|
,@couponCode VARCHAR(30) = NULL |
||||
|
,@schemeId INT = NULL |
||||
|
,@payOutPartner INT = NULL |
||||
|
,@paymentType VARCHAR(50) = NULL |
||||
|
,@cardOnline VARCHAR(10) = NULL |
||||
|
,@tpExRate FLOAT = NULL |
||||
|
,@isManualSc CHAR(1) = NULL |
||||
|
,@manualSc MONEY = NULL |
||||
|
,@ProcessFor VARCHAR(20) = NULL |
||||
|
,@discountedFee MONEY = NULL |
||||
|
) |
||||
|
AS |
||||
|
SET NOCOUNT ON; |
||||
|
SET XACT_ABORT ON; |
||||
|
|
||||
|
----------------------------------------- |
||||
|
--Sep 22 -> #109 ->Change the logic to choose highest Rate in case of Nepal |
||||
|
-- #101 , #361 - Mobile Changes for Multi-Lingual |
||||
|
-- #1526 - Post production fixes for Redeem & Earn |
||||
|
-- #1590 - Customer Loyalty |
||||
|
-- #5968 - sc revised |
||||
|
-------------------------------------------- |
||||
|
BEGIN |
||||
|
DECLARE @scValue MONEY |
||||
|
,@scAction CHAR(2) |
||||
|
,@scOffer MONEY |
||||
|
,@exRateOffer FLOAT |
||||
|
,@scDiscount MONEY |
||||
|
DECLARE @place INT |
||||
|
,@currDecimal INT |
||||
|
,@collMode VARCHAR(30) |
||||
|
,@sendingCustType VARCHAR(30) |
||||
|
,@msg VARCHAR(150) |
||||
|
,@errorCode INT |
||||
|
DECLARE @exRateCalByPartner BIT |
||||
|
,@pSuperAgent INT |
||||
|
,@serviceCharge MONEY |
||||
|
,@serviceChargetmp MONEY |
||||
|
,@tAmt MONEY |
||||
|
,@pSuperAgentName VARCHAR(100) |
||||
|
,@pBranch INT |
||||
|
DECLARE @pAgentName VARCHAR(100) |
||||
|
,@pBranchName VARCHAR(100) |
||||
|
,@exRate FLOAT |
||||
|
,@pCurrHoMargin FLOAT |
||||
|
,@FOREX_SESSION_ID VARCHAR(40) |
||||
|
DECLARE @tranCount INT = 0 |
||||
|
,@schemeCount INT = 0 |
||||
|
,@schemeAppliedMsg VARCHAR(100) = '' |
||||
|
,@isFirstTran CHAR(1) = 'N' |
||||
|
,@createdFrom CHAR(1) = NULL |
||||
|
,@isEligible CHAR(1) = NULL |
||||
|
,@introducer VARCHAR(25) = NULL |
||||
|
|
||||
|
--IF @ProcessFor IN ('send') |
||||
|
--BEGIN |
||||
|
IF ISNULL(@user, 'onlinedefault') <> 'onlinedefault' --OR @user is not null |
||||
|
BEGIN |
||||
|
SET @senderId = ( |
||||
|
SELECT customerId |
||||
|
FROM mobile_userRegistration(NOLOCK) |
||||
|
WHERE username = @user |
||||
|
) |
||||
|
EXEC PROC_Customer_LoyaltyV2 @flag = 'check-eligible-v2' |
||||
|
,@isEligible = @isEligible OUT |
||||
|
,@referralCode = @introducer |
||||
|
,@tranCount = @trancount OUT |
||||
|
,@schemeCount = @schemeCount OUT |
||||
|
,@customerId = @senderId |
||||
|
,@createdFrom = 'M' |
||||
|
|
||||
|
IF NOT EXISTS ( |
||||
|
SELECT 1 |
||||
|
FROM ( |
||||
|
SELECT TOP 1 customerId |
||||
|
FROM TRANSENDERS TS(NOLOCK) |
||||
|
INNER JOIN remittran(NOLOCK) rt ON rt.id = ts.tranId |
||||
|
WHERE customerId = @SenderId |
||||
|
AND rt.tranStatus <> 'CANCEL' AND rt.tranType='M' |
||||
|
|
||||
|
UNION ALL |
||||
|
|
||||
|
SELECT TOP 1 customerId |
||||
|
FROM TRANSENDERSTEMP TT(NOLOCK) |
||||
|
INNER JOIN remittrantemp(NOLOCK) rt ON rt.id = tt.tranId |
||||
|
WHERE customerId = @SenderId |
||||
|
AND rt.tranStatus <> 'CANCEL' AND rt.tranType='M' |
||||
|
) a |
||||
|
WHERE customerId = @SenderId |
||||
|
) |
||||
|
BEGIN |
||||
|
SET @isFirstTran = 'Y' |
||||
|
END |
||||
|
|
||||
|
END |
||||
|
print '@isFirstTran' + '-> ' + @isFirstTran |
||||
|
SELECT @createdFrom = serviceUsedFor |
||||
|
FROM customerMaster(NOLOCK) |
||||
|
WHERE customerId = @senderId |
||||
|
|
||||
|
SET @sCountryId = 233 |
||||
|
|
||||
|
IF ISNULL(@pCountryId, 0) = 0 |
||||
|
SELECT @pCountryId = countryId |
||||
|
FROM countryMaster(NOLOCK) |
||||
|
WHERE COUNTRYNAME = @pCountry |
||||
|
|
||||
|
--IF (@ProcessFor = 'send') |
||||
|
--BEGIN |
||||
|
--IF NOT EXISTS ( |
||||
|
-- SELECT 1 |
||||
|
-- FROM ( |
||||
|
-- SELECT TOP 1 customerId |
||||
|
-- FROM TRANSENDERS TS(NOLOCK) |
||||
|
-- INNER JOIN remittran(NOLOCK) rt ON rt.id = ts.tranId |
||||
|
-- WHERE customerId = @SenderId |
||||
|
-- AND rt.tranStatus <> 'CANCEL' AND rt.tranType='M' |
||||
|
|
||||
|
-- UNION ALL |
||||
|
|
||||
|
-- SELECT TOP 1 customerId |
||||
|
-- FROM TRANSENDERSTEMP TT(NOLOCK) |
||||
|
-- INNER JOIN remittrantemp(NOLOCK) rt ON rt.id = tt.tranId |
||||
|
-- WHERE customerId = @SenderId |
||||
|
-- AND rt.tranStatus <> 'CANCEL' AND rt.tranType='M' |
||||
|
-- ) a |
||||
|
-- WHERE customerId = @SenderId |
||||
|
-- ) |
||||
|
--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') |
||||
|
BEGIN |
||||
|
SELECT @payoutPartner = AGENTID |
||||
|
,@exRateCalByPartner = ISNULL(exRateCalByPartner, 0) |
||||
|
FROM TblPartnerwiseCountry(NOLOCK) |
||||
|
WHERE CountryId = @pCountryId |
||||
|
AND IsActive = 1 |
||||
|
AND ISNULL(IsMobileEnabled, 0) = 1 |
||||
|
AND ISNULL(PaymentMethod, @deliveryMethodId) = @deliveryMethodId |
||||
|
END |
||||
|
ELSE |
||||
|
BEGIN |
||||
|
SELECT @payoutPartner = AGENTID |
||||
|
,@exRateCalByPartner = ISNULL(exRateCalByPartner, 0) |
||||
|
FROM TblPartnerwiseCountry(NOLOCK) |
||||
|
WHERE CountryId = @pCountryId |
||||
|
AND IsActive = 1 |
||||
|
AND ISNULL(PaymentMethod, @deliveryMethodId) = @deliveryMethodId |
||||
|
END |
||||
|
PRINT '@payoutPartner' |
||||
|
PRINT @payoutPartner; |
||||
|
IF @payoutPartner IS NOT NULL |
||||
|
BEGIN |
||||
|
--GET PAYOUT AGENT DETAILS |
||||
|
SELECT @PAGENT = AGENTID |
||||
|
FROM AGENTMASTER(NOLOCK) |
||||
|
WHERE PARENTID = @payoutPartner |
||||
|
AND ISNULL(ISSETTLINGAGENT, 'N') = 'Y'; |
||||
|
|
||||
|
SELECT @pSuperAgent = sSuperAgent |
||||
|
,@pSuperAgentName = sSuperAgentName |
||||
|
,@pAgent = sAgent |
||||
|
,@pAgentName = sAgentName |
||||
|
,@pBranch = sBranch |
||||
|
,@pBranchName = sBranchName |
||||
|
FROM dbo.FNAGetBranchFullDetails(@PAGENT) |
||||
|
END |
||||
|
ELSE |
||||
|
BEGIN |
||||
|
SELECT '1' ErrorCode |
||||
|
,'Partner not yet mapped for the selected country!' Msg |
||||
|
,NULL id |
||||
|
|
||||
|
RETURN |
||||
|
END |
||||
|
|
||||
|
DECLARE @rowId INT |
||||
|
|
||||
|
SELECT @scValue = 0 |
||||
|
,@scOffer = 0 |
||||
|
,@exRateOffer = 0 |
||||
|
,@scDiscount = 0 |
||||
|
|
||||
|
SELECT @place = place |
||||
|
,@currDecimal = currDecimal |
||||
|
FROM currencyPayoutRound WITH (NOLOCK) |
||||
|
WHERE ISNULL(isDeleted, 'N') = 'N' |
||||
|
AND currency = @pCurr |
||||
|
AND ISNULL(tranType, @deliveryMethodId) = @deliveryMethodId |
||||
|
|
||||
|
SET @currDecimal = ISNULL(@currDecimal, 0) |
||||
|
|
||||
|
IF @pCurr IS NULL |
||||
|
BEGIN |
||||
|
SELECT '2' ErrorCode |
||||
|
,'Currency not been defined yet for receiving country' Msg |
||||
|
,NULL id |
||||
|
|
||||
|
RETURN |
||||
|
END |
||||
|
|
||||
|
IF (ISNULL(@discountedFee, 0) <> FLOOR(ISNULL(@discountedFee, 0))) |
||||
|
BEGIN |
||||
|
SELECT '9' ErrorCode |
||||
|
,'Discount Fee cannot be in decimal points.' Msg |
||||
|
,NULL id |
||||
|
|
||||
|
RETURN |
||||
|
END |
||||
|
|
||||
|
pRINT '@pAgent'; |
||||
|
--pRINT @pAgent; |
||||
|
|
||||
|
IF @flag = 'false' |
||||
|
BEGIN |
||||
|
IF @pCountryId = 151 |
||||
|
AND @deliveryMethodId = 1 |
||||
|
BEGIN |
||||
|
SELECT AgentId |
||||
|
INTO #AgentList |
||||
|
FROM agentMaster(NOLOCK) |
||||
|
WHERE extCode = 'NP ANYWHERE' |
||||
|
PRINT @sCountryId; |
||||
|
PRINT @sAgent; |
||||
|
PRINT @sBranch; |
||||
|
PRINT @collCurr; |
||||
|
PRINT @pCountryId; |
||||
|
PRINT @pCurr; |
||||
|
PRINT @deliveryMethodId; |
||||
|
SELECT @exRate = customerRate |
||||
|
,@pCurrHoMargin = pCurrHoMargin |
||||
|
FROM ( |
||||
|
SELECT ROW_NUMBER() OVER ( |
||||
|
ORDER BY CUSTOMERRATE DESC |
||||
|
) ROW_NUM |
||||
|
,CUSTOMERRATE |
||||
|
,pCurrHoMargin |
||||
|
FROM #AgentList A |
||||
|
CROSS APPLY dbo.FNAGetExRate(@sCountryId, @sAgent, @sBranch, @collCurr, @pCountryId, AgentId, @pCurr, @deliveryMethodId) FN |
||||
|
) X |
||||
|
WHERE X.ROW_NUM = 1 |
||||
|
END |
||||
|
ELSE |
||||
|
BEGIN |
||||
|
SELECT @exRate = customerRate |
||||
|
,@pCurrHoMargin = pCurrHoMargin |
||||
|
FROM dbo.FNAGetExRate(@sCountryId, @sAgent, @sBranch, @collCurr, @pCountryId, @pAgent, @pCurr, @deliveryMethodId) |
||||
|
END |
||||
|
|
||||
|
IF ISNULL(@exRate, 0) = 0 |
||||
|
BEGIN |
||||
|
SELECT '3' ErrorCode |
||||
|
,'Exchange rate not defined yet for receiving currency (' + @pCurr + ')' Msg |
||||
|
,NULL id |
||||
|
|
||||
|
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); |
||||
|
IF @calBy = 'C' |
||||
|
BEGIN |
||||
|
IF ( @tranCount >= @schemeCount |
||||
|
AND ISNULL(@user, 'onlinedefault') <> 'onlinedefault' |
||||
|
--AND ISNULL(@ProcessFor, '') = 'send' |
||||
|
AND @isEligible = 'Y' |
||||
|
) |
||||
|
OR (@isFirstTran = 'Y') |
||||
|
BEGIN |
||||
|
SET @serviceCharge = 0 |
||||
|
|
||||
|
IF @isFirstTran = 'Y' |
||||
|
BEGIN |
||||
|
SET @schemeAppliedMsg = 'Enjoy zero (0) service charge due to First Transaction!'; |
||||
|
END |
||||
|
ELSE |
||||
|
SET @schemeAppliedMsg = 'Enjoy zero (0) service charge due to Loyalty Scheme!'; |
||||
|
END |
||||
|
ELSE |
||||
|
BEGIN |
||||
|
IF ISNULL(@isManualSc, 'N') = 'N' |
||||
|
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 |
||||
|
END |
||||
|
ELSE |
||||
|
BEGIN |
||||
|
SET @serviceCharge = ISNULL(@manualSc, 0) |
||||
|
END |
||||
|
|
||||
|
IF @serviceCharge IS NULL |
||||
|
AND ISNULL(@isManualSc, 'N') = 'N' |
||||
|
BEGIN |
||||
|
SELECT '4' ErrorCode |
||||
|
,'Service charge not defined yet for receiving country' Msg |
||||
|
,NULL id |
||||
|
|
||||
|
RETURN; |
||||
|
END |
||||
|
END |
||||
|
|
||||
|
IF @scAction = 'PD' -- Percent Discount |
||||
|
BEGIN |
||||
|
SET @scOffer = (@scValue / 100) * @serviceCharge |
||||
|
SET @scDiscount = (@scValue / 100) * @serviceCharge |
||||
|
END |
||||
|
ELSE IF @scAction = 'FD' -- Flat Discount |
||||
|
BEGIN |
||||
|
SET @scDiscount = @scValue |
||||
|
END |
||||
|
ELSE IF @scAction = 'FV' -- Fixed Value |
||||
|
BEGIN |
||||
|
SET @scOffer = @scValue |
||||
|
SET @scDiscount = @serviceCharge - @scValue |
||||
|
END |
||||
|
|
||||
|
SET @tAmt = @cAmt - @serviceCharge + @scDiscount + ISNULL(@discountedFee, 0) |
||||
|
SET @pAmt = @tAmt * (@exRate + @exRateOffer) |
||||
|
SET @pAmt = FLOOR(@pAmt) |
||||
|
END |
||||
|
ELSE |
||||
|
BEGIN |
||||
|
--SET @tAmt = CEILING(@pAmt/(@exRate + @exRateOffer), 0) |
||||
|
SET @tAmt = CEILING(@pAmt / (@exRate + @exRateOffer)) |
||||
|
|
||||
|
IF ( |
||||
|
@tranCount >= @schemeCount |
||||
|
AND ISNULL(@user, 'onlinedefault') <> 'onlinedefault' |
||||
|
--AND ISNULL(@ProcessFor, '') = 'send' |
||||
|
AND @isEligible = 'Y' |
||||
|
) |
||||
|
OR (@isFirstTran = 'Y') |
||||
|
BEGIN |
||||
|
SET @serviceCharge = 0 |
||||
|
|
||||
|
IF @isFirstTran = 'Y' |
||||
|
BEGIN |
||||
|
SET @schemeAppliedMsg = 'Enjoy zero (0) service charge due to First Transaction!'; |
||||
|
END |
||||
|
ELSE |
||||
|
SET @schemeAppliedMsg = 'Enjoy zero (0) service charge due to Loyalty Scheme!'; |
||||
|
END |
||||
|
ELSE |
||||
|
BEGIN |
||||
|
IF ISNULL(@isManualSc, 'N') = 'N' |
||||
|
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 |
||||
|
END |
||||
|
ELSE |
||||
|
BEGIN |
||||
|
SET @serviceCharge = ISNULL(@manualSc, 0) |
||||
|
END |
||||
|
|
||||
|
IF @serviceCharge IS NULL |
||||
|
BEGIN |
||||
|
SELECT '4' ErrorCode |
||||
|
,'Service charge not defined yet for receiving country' Msg |
||||
|
,NULL id |
||||
|
|
||||
|
RETURN; |
||||
|
END |
||||
|
END |
||||
|
|
||||
|
IF @scAction = 'PD' |
||||
|
BEGIN |
||||
|
SET @scOffer = (@scValue / 100) * @serviceCharge |
||||
|
SET @scDiscount = (@scValue / 100) * @serviceCharge |
||||
|
END |
||||
|
ELSE IF @scAction = 'FD' |
||||
|
BEGIN |
||||
|
SET @scDiscount = @scValue |
||||
|
END |
||||
|
ELSE IF @scAction = 'FV' |
||||
|
BEGIN |
||||
|
SET @scOffer = @scValue |
||||
|
SET @scDiscount = @serviceCharge - @scValue |
||||
|
END |
||||
|
|
||||
|
SET @cAmt = (@tAmt + @serviceCharge - @scDiscount) - ISNULL(@discountedFee, 0) |
||||
|
SET @cAmt = CEILING(@cAmt) |
||||
|
END |
||||
|
|
||||
|
--4. Validate Country Sending Limit |
||||
|
EXEC PROC_CHECKCOUNTRYLIMIT @flag = 's-limit' |
||||
|
,@cAmt = @cAmt |
||||
|
,@pAmt = @pAmt |
||||
|
,@sCountryId = @sCountryId |
||||
|
,@collMode = @collMode |
||||
|
,@deliveryMethod = @deliveryMethodId |
||||
|
,@sendingCustType = @sendingCustType |
||||
|
,@pCountryId = @pCountryId |
||||
|
,@pCurr = @pCurr |
||||
|
,@collCurr = @collCurr |
||||
|
,@pAgent = @pAgent |
||||
|
,@sAgent = @sAgent |
||||
|
,@sBranch = @sBranch |
||||
|
,@msg = @msg OUT |
||||
|
,@errorCode = @errorCode OUT |
||||
|
|
||||
|
IF @errorCode <> '0' |
||||
|
BEGIN |
||||
|
SELECT @errorCode ErrorCode |
||||
|
,@msg Msg |
||||
|
|
||||
|
RETURN; |
||||
|
END |
||||
|
|
||||
|
--Validate Country Sending Limit END |
||||
|
--5. Validate Country Receiving Limit |
||||
|
EXEC PROC_CHECKCOUNTRYLIMIT @flag = 'r-limit' |
||||
|
,@cAmt = @cAmt |
||||
|
,@pAmt = @pAmt |
||||
|
,@sCountryId = @sCountryId |
||||
|
,@collMode = @collMode |
||||
|
,@deliveryMethod = @deliveryMethodId |
||||
|
,@sendingCustType = @sendingCustType |
||||
|
,@pCountryId = @pCountryId |
||||
|
,@pCurr = @pCurr |
||||
|
,@collCurr = @collCurr |
||||
|
,@pAgent = @pAgent |
||||
|
,@sAgent = @sAgent |
||||
|
,@sBranch = @sBranch |
||||
|
,@msg = @msg OUT |
||||
|
,@errorCode = @errorCode OUT |
||||
|
|
||||
|
IF @errorCode <> '0' |
||||
|
BEGIN |
||||
|
SELECT @errorCode ErrorCode |
||||
|
,@msg Msg |
||||
|
|
||||
|
RETURN; |
||||
|
END |
||||
|
|
||||
|
IF ISNULL(@ProcessFor, '') = 'send' |
||||
|
BEGIN |
||||
|
SET @FOREX_SESSION_ID = NEWID() |
||||
|
|
||||
|
----## lock ex rate for individual txn |
||||
|
UPDATE exRateCalcHistory |
||||
|
SET isExpired = 1 |
||||
|
WHERE CUSTOMER_ID = @senderId |
||||
|
AND isExpired = 0 |
||||
|
|
||||
|
PRINT @serviceCharge; |
||||
|
|
||||
|
INSERT INTO exRateCalcHistory ( |
||||
|
CUSTOMER_ID |
||||
|
,[USER_ID] |
||||
|
,FOREX_SESSION_ID |
||||
|
,serviceCharge |
||||
|
,pAmt |
||||
|
,customerRate |
||||
|
,sCurrCostRate |
||||
|
,sCurrHoMargin |
||||
|
,sCurrAgentMargin |
||||
|
,pCurrCostRate |
||||
|
,pCurrHoMargin |
||||
|
,pCurrAgentMargin |
||||
|
,agentCrossSettRate |
||||
|
,createdDate |
||||
|
,isExpired |
||||
|
,tAmt |
||||
|
,schemeId |
||||
|
,discountedFee |
||||
|
,sharingValue |
||||
|
) |
||||
|
SELECT @senderId |
||||
|
,@user |
||||
|
,@FOREX_SESSION_ID |
||||
|
,@serviceCharge |
||||
|
,@pAmt |
||||
|
,@exRate |
||||
|
,1 |
||||
|
,0 |
||||
|
,0 |
||||
|
,@pCurrHoMargin + @exRate |
||||
|
,@pCurrHoMargin |
||||
|
,0 |
||||
|
,@exRate |
||||
|
,GETDATE() |
||||
|
,0 |
||||
|
,@tAmt |
||||
|
,@schemeId |
||||
|
,ISNULL(@discountedFee, 0) |
||||
|
,@schemeCount |
||||
|
END |
||||
|
|
||||
|
SET @msg = 'Success' |
||||
|
|
||||
|
SELECT @errorCode ErrorCode |
||||
|
,@msg Msg |
||||
|
,scCharge = @serviceCharge |
||||
|
,exRate = @exRate |
||||
|
,place = @place |
||||
|
,pCurr = @pCurr |
||||
|
,currDecimal = @currDecimal |
||||
|
,pAmt = @pAmt |
||||
|
,sAmt = @tAmt |
||||
|
,place = @place |
||||
|
,disc = 0.00 |
||||
|
,collAmt = @cAmt |
||||
|
,exRateOffer = @exRateOffer |
||||
|
,scOffer = @scDiscount |
||||
|
,scAction = @scAction |
||||
|
,scValue = @scValue |
||||
|
,scDiscount = @scDiscount |
||||
|
,tpExRate = 0 |
||||
|
,amountLimitPerDay = 0 |
||||
|
,amountLimitPerTran = 0 |
||||
|
,customerTotalSentAmt = 0 |
||||
|
,exRateDisplay = @exRate |
||||
|
,EXRATEID = @FOREX_SESSION_ID |
||||
|
,maxAmountLimitPerTran = 0 |
||||
|
,minAmountLimitPerTran = 0 |
||||
|
,PerTxnMinimumAmt = 0 |
||||
|
,schemeAppliedMsg = @schemeAppliedMsg |
||||
|
,schemeId = @schemeId |
||||
|
,tpPCurr = @pCurr |
||||
|
,collCurr = @collCurr |
||||
|
,ForexSessionId = @FOREX_SESSION_ID |
||||
|
,discountedFee = ISNULL(@discountedFee, 0) |
||||
|
END |
||||
|
ELSE IF @FLAG = 'true' |
||||
|
BEGIN |
||||
|
IF ISNULL(@tpExRate, 0) = 0 |
||||
|
BEGIN |
||||
|
SELECT '5' ErrorCode |
||||
|
,'Third Party Exchange rate fetching error for currency (' + @pCurr + ')' Msg |
||||
|
|
||||
|
RETURN |
||||
|
END |
||||
|
|
||||
|
DECLARE @exRateDonga FLOAT, @exRateBRAC FLOAT |
||||
|
|
||||
|
PRINT @sCountryId; |
||||
|
PRINT @sCountryId; |
||||
|
PRINT @sAgent; |
||||
|
PRINT @sBranch; |
||||
|
PRINT @collCurr; |
||||
|
PRINT @pCountryId; |
||||
|
PRINT @pAgent; |
||||
|
PRINT @pCurr; |
||||
|
PRINT @deliveryMethodId; |
||||
|
|
||||
|
SELECT @pCurrHoMargin = pCurrHoMargin |
||||
|
FROM dbo.FNAGetExRate(@sCountryId, @sAgent, @sBranch, @collCurr, @pCountryId, @pAgent, @pCurr, @deliveryMethodId) |
||||
|
|
||||
|
SELECT @exRate = @tpExRate - ISNULL(@pCurrHoMargin, 0) |
||||
|
|
||||
|
IF ISNULL(@exRate, 0) = 0 |
||||
|
BEGIN |
||||
|
SELECT '3' ErrorCode |
||||
|
,'Exchange rate not defined yet for receiving currency (' + @pCurr + ')' Msg |
||||
|
,NULL id |
||||
|
|
||||
|
RETURN |
||||
|
END |
||||
|
|
||||
|
IF @user = 'onlinedefault' |
||||
|
AND @pCountryId = 203 |
||||
|
BEGIN |
||||
|
SELECT @exRateDonga = dbo.FNAGetCustomerRate(113, 0, 394395, 'JPY', 203, 394133, 'VND', 1) |
||||
|
|
||||
|
IF @exRateDonga > @exRate |
||||
|
SET @exRate = @exRateDonga |
||||
|
END |
||||
|
|
||||
|
|
||||
|
IF @user = 'onlinedefault' |
||||
|
AND @pCountryId = 16 |
||||
|
BEGIN |
||||
|
SELECT @exRateBRAC = dbo.FNAGetCustomerRate(113, 0, 394395, 'JPY', 16, 394414, 'BDT', 1) |
||||
|
|
||||
|
IF @exRateBRAC > @exRate |
||||
|
SET @exRate = @exRateBRAC |
||||
|
END |
||||
|
|
||||
|
IF @calBy = 'C' |
||||
|
BEGIN |
||||
|
IF ( |
||||
|
@tranCount = @schemeCount |
||||
|
AND ISNULL(@user, 'onlinedefault') <> 'onlinedefault' |
||||
|
-- AND ISNULL(@ProcessFor, '') = 'send' |
||||
|
AND @isEligible = 'Y' |
||||
|
) |
||||
|
OR (@isFirstTran = 'Y') |
||||
|
BEGIN |
||||
|
SET @serviceCharge = 0 |
||||
|
|
||||
|
IF @isFirstTran = 'Y' |
||||
|
BEGIN |
||||
|
SET @schemeAppliedMsg = 'Enjoy zero (0) service charge due to First Transaction!'; |
||||
|
END |
||||
|
ELSE |
||||
|
SET @schemeAppliedMsg = 'Enjoy zero (0) service charge due to Loyalty Scheme!'; |
||||
|
END |
||||
|
ELSE |
||||
|
BEGIN |
||||
|
IF ISNULL(@isManualSc, 'N') = 'N' |
||||
|
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 |
||||
|
END |
||||
|
ELSE |
||||
|
BEGIN |
||||
|
SET @serviceCharge = ISNULL(@manualSc, 0) |
||||
|
END |
||||
|
|
||||
|
IF @serviceCharge IS NULL |
||||
|
AND ISNULL(@isManualSc, 'N') = 'N' |
||||
|
BEGIN |
||||
|
SELECT '4' ErrorCode |
||||
|
,'Service charge not defined yet for receiving country' Msg |
||||
|
,NULL id |
||||
|
|
||||
|
RETURN; |
||||
|
END |
||||
|
END |
||||
|
|
||||
|
IF @scAction = 'PD' -- Percent Discount |
||||
|
BEGIN |
||||
|
SET @scOffer = (@scValue / 100) * @serviceCharge |
||||
|
SET @scDiscount = (@scValue / 100) * @serviceCharge |
||||
|
END |
||||
|
ELSE IF @scAction = 'FD' -- Flat Discount |
||||
|
BEGIN |
||||
|
SET @scDiscount = @scValue |
||||
|
END |
||||
|
ELSE IF @scAction = 'FV' -- Fixed Value |
||||
|
BEGIN |
||||
|
SET @scOffer = @scValue |
||||
|
SET @scDiscount = @serviceCharge - @scValue |
||||
|
END |
||||
|
|
||||
|
SET @tAmt = @cAmt - @serviceCharge + @scDiscount + ISNULL(@discountedFee, 0) |
||||
|
SET @pAmt = @tAmt * (@exRate + @exRateOffer) |
||||
|
SET @pAmt = FLOOR(@pAmt) |
||||
|
END |
||||
|
ELSE |
||||
|
BEGIN |
||||
|
SET @tAmt = CEILING(@pAmt / (@exRate + @exRateOffer)) |
||||
|
|
||||
|
IF ISNULL(@isManualSc, 'N') = 'N' |
||||
|
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 |
||||
|
END |
||||
|
ELSE |
||||
|
BEGIN |
||||
|
SET @serviceCharge = ISNULL(@manualSc, 0) |
||||
|
END |
||||
|
|
||||
|
IF @serviceCharge IS NULL |
||||
|
BEGIN |
||||
|
SELECT '4' ErrorCode |
||||
|
,'Service charge not defined yet for receiving country' Msg |
||||
|
,NULL id |
||||
|
|
||||
|
RETURN; |
||||
|
END |
||||
|
|
||||
|
IF @scAction = 'PD' |
||||
|
BEGIN |
||||
|
SET @scOffer = (@scValue / 100) * @serviceCharge |
||||
|
SET @scDiscount = (@scValue / 100) * @serviceCharge |
||||
|
END |
||||
|
ELSE IF @scAction = 'FD' |
||||
|
BEGIN |
||||
|
SET @scDiscount = @scValue |
||||
|
END |
||||
|
ELSE IF @scAction = 'FV' |
||||
|
BEGIN |
||||
|
SET @scOffer = @scValue |
||||
|
SET @scDiscount = @serviceCharge - @scValue |
||||
|
END |
||||
|
|
||||
|
SET @cAmt = (@tAmt + @serviceCharge - @scDiscount)-- - ISNULL(@discountedFee, 0) |
||||
|
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 |
||||
|
EXEC PROC_CHECKCOUNTRYLIMIT @flag = 's-limit' |
||||
|
,@cAmt = @cAmt |
||||
|
,@pAmt = @pAmt |
||||
|
,@sCountryId = @sCountryId |
||||
|
,@collMode = @collMode |
||||
|
,@deliveryMethod = @deliveryMethodId |
||||
|
,@sendingCustType = @sendingCustType |
||||
|
,@pCountryId = @pCountryId |
||||
|
,@pCurr = @pCurr |
||||
|
,@collCurr = @collCurr |
||||
|
,@pAgent = @pAgent |
||||
|
,@sAgent = @sAgent |
||||
|
,@sBranch = @sBranch |
||||
|
,@msg = @msg OUT |
||||
|
,@errorCode = @errorCode OUT |
||||
|
|
||||
|
IF @errorCode <> '0' |
||||
|
BEGIN |
||||
|
SELECT @errorCode ErrorCode |
||||
|
,@msg Msg |
||||
|
|
||||
|
RETURN; |
||||
|
END |
||||
|
|
||||
|
--Validate Country Sending Limit END |
||||
|
--5. Validate Country Receiving Limit |
||||
|
EXEC PROC_CHECKCOUNTRYLIMIT @flag = 'r-limit' |
||||
|
,@cAmt = @cAmt |
||||
|
,@pAmt = @pAmt |
||||
|
,@sCountryId = @sCountryId |
||||
|
,@collMode = @collMode |
||||
|
,@deliveryMethod = @deliveryMethodId |
||||
|
,@sendingCustType = @sendingCustType |
||||
|
,@pCountryId = @pCountryId |
||||
|
,@pCurr = @pCurr |
||||
|
,@collCurr = @collCurr |
||||
|
,@pAgent = @pAgent |
||||
|
,@sAgent = @sAgent |
||||
|
,@sBranch = @sBranch |
||||
|
,@msg = @msg OUT |
||||
|
,@errorCode = @errorCode OUT |
||||
|
|
||||
|
IF @errorCode <> '0' |
||||
|
BEGIN |
||||
|
SELECT @errorCode ErrorCode |
||||
|
,@msg Msg |
||||
|
|
||||
|
RETURN; |
||||
|
END |
||||
|
|
||||
|
--Validate Country Receiving Limit |
||||
|
IF ISNULL(@ProcessFor, '') = 'send' |
||||
|
BEGIN |
||||
|
SET @FOREX_SESSION_ID = NEWID() |
||||
|
|
||||
|
----## lock ex rate for individual txn |
||||
|
UPDATE exRateCalcHistory |
||||
|
SET isExpired = 1 |
||||
|
WHERE CUSTOMER_ID = @senderId |
||||
|
AND isExpired = 0 |
||||
|
|
||||
|
INSERT INTO exRateCalcHistory ( |
||||
|
CUSTOMER_ID |
||||
|
,[USER_ID] |
||||
|
,FOREX_SESSION_ID |
||||
|
,serviceCharge |
||||
|
,pAmt |
||||
|
,customerRate |
||||
|
,sCurrCostRate |
||||
|
,sCurrHoMargin |
||||
|
,sCurrAgentMargin |
||||
|
,pCurrCostRate |
||||
|
,pCurrHoMargin |
||||
|
,pCurrAgentMargin |
||||
|
,agentCrossSettRate |
||||
|
,createdDate |
||||
|
,isExpired |
||||
|
,tAmt |
||||
|
,schemeId |
||||
|
,discountedFee |
||||
|
,sharingValue |
||||
|
) |
||||
|
SELECT @senderId |
||||
|
,@user |
||||
|
,@FOREX_SESSION_ID |
||||
|
,@serviceCharge |
||||
|
,@pAmt |
||||
|
,@exRate |
||||
|
,1 |
||||
|
,0 |
||||
|
,0 |
||||
|
,@pCurrHoMargin + @exRate |
||||
|
,@pCurrHoMargin |
||||
|
,0 |
||||
|
,@exRate |
||||
|
,GETDATE() |
||||
|
,0 |
||||
|
,@tAmt |
||||
|
,@schemeId |
||||
|
,ISNULL(@discountedFee, 0) |
||||
|
,@schemeCount |
||||
|
END |
||||
|
|
||||
|
SET @msg = 'Success' |
||||
|
|
||||
|
SELECT @errorCode ErrorCode |
||||
|
,@msg Msg |
||||
|
,scCharge = @serviceCharge |
||||
|
,exRate = @exRate |
||||
|
,place = @place |
||||
|
,pCurr = @pCurr |
||||
|
,currDecimal = @currDecimal |
||||
|
,pAmt = @pAmt |
||||
|
,sAmt = @tAmt |
||||
|
,place = @place |
||||
|
,disc = 0.00 |
||||
|
,collAmt = @cAmt |
||||
|
,exRateOffer = @exRateOffer |
||||
|
,scOffer = @scDiscount |
||||
|
,scAction = @scAction |
||||
|
,scValue = @scValue |
||||
|
,scDiscount = @scDiscount |
||||
|
,tpExRate = @tpExRate |
||||
|
,amountLimitPerDay = 0 |
||||
|
,amountLimitPerTran = 0 |
||||
|
,customerTotalSentAmt = 0 |
||||
|
,exRateDisplay = @exRate |
||||
|
,EXRATEID = @FOREX_SESSION_ID |
||||
|
,maxAmountLimitPerTran = 0 |
||||
|
,minAmountLimitPerTran = 0 |
||||
|
,PerTxnMinimumAmt = 0 |
||||
|
,schemeAppliedMsg = @schemeAppliedMsg |
||||
|
,schemeId = @schemeId |
||||
|
,tpPCurr = @pCurr |
||||
|
,collCurr = @collCurr |
||||
|
,ForexSessionId = @FOREX_SESSION_ID |
||||
|
,discountedFee = ISNULL(@discountedFee, 0) |
||||
|
END |
||||
|
END |
||||
|
|
1598
StoredProc/proc_SendTransaction.sql
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,9 @@ |
|||||
|
INSERT INTO FASTMONEYPRO_ACCOUNT.DBO.AC_MASTER(acct_num, acct_name, GL_CODE, agent_id, acct_ownership, acct_rpt_code, acct_opn_date, ac_currency, created_by, created_date, company_id) |
||||
|
SELECT '100139297574' ,'Teller Cash - ajey', 120, 52768, 'o','TCA', GETDATE(), 'JPY', 'system', GETDATE(), 1 |
||||
|
|
||||
|
|
||||
|
INSERT INTO FASTMONEYPRO_ACCOUNT.DBO.AC_MASTER(acct_num, acct_name, GL_CODE, agent_id, acct_ownership, acct_rpt_code, acct_opn_date, ac_currency, created_by, created_date, company_id) |
||||
|
SELECT '100139297575' ,'Teller Cash - kewal', 120, 52896, 'o','TCA', GETDATE(), 'JPY', 'system', GETDATE(), 1 |
||||
|
|
||||
|
INSERT INTO FASTMONEYPRO_ACCOUNT.DBO.AC_MASTER(acct_num, acct_name, GL_CODE, agent_id, branch_id, acct_ownership, acct_rpt_code, acct_opn_date, ac_currency, created_by, created_date, company_id) |
||||
|
SELECT '100139219838' ,'Vault-IME London Head Office', 120, 394390,1001, 'o','BVA', GETDATE(), 'JPY', 'system', GETDATE(), 1 |
Write
Preview
Loading…
Cancel
Save
Reference in new issue