Developer forum

Forum » Ecommerce - Standard features » LoyaltyPoint Expiration logic

LoyaltyPoint Expiration logic

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

We are trying to use the Loyalty points and we stumbled upon the expiration of LoyaltyPoints. We have tested a few scenarios where we manually changed the Transaction Date on the loyalty points transaction and it doesn't seem to make any difference, no matter what we set as expiration date.

We are using DW 9.6.12.

We have have investigated a bit the RedeemPoints add in, that is supposed to invalidate the points and it seems that the reference when checking the points seems to look in the TransactionDate instead of the Expiration date.

I am not 100% the above is right.

Maybe you guys can have a look?

Thank you,
Adrian


Replies

 
Oleg Rodionov Dynamicweb Employee
Oleg Rodionov
Reply

Hi Adrian,

The issue seems to be bugged by TFS 73716 already exists - nowaday user total loyalty points are not recalculated correctly not to take in account expired transactions. So, waiting for fixing. Thanks for observing.

BR, Oleg QA  

 
Oleg Rodionov Dynamicweb Employee
Oleg Rodionov
Reply

Hi Adrian,

Since the date was changed manually, try to use the following workaround. Set the "/Globalsettings/Ecom/LoyaltyPoints/LastExpirationAddInRun" setting to date in past not early than end of period boundary and perform appropriate ("Redeem expired points") scheduler task. It should fix total points for each users according expiration period set (the folowing logic is now applied - if TransactionDate value less then "LastExpirationAddInRun" value such transaction will be skipped on the next "Redeem expired points" task executing). Next run of the task will update the date correctly. 

BR, Oleg QA

 
Kim Søjborg Pedersen
Reply

Hi Oleg

Is the TFS 73716 fixed? I'm on 9.7.4 and the redeem add in does not work here either

Thanks
Kim

 
Nicolai Pedersen
Reply
This post has been marked as an answer

You can find that here: https://doc.dynamicweb.com/downloads/releases/bug-fixes/bug-fixes-for-9-7#9.7.6

It is fixed in 9.7.6+

Or in Dynamicweb.Scheduling.Providers.PointExpirationScheduledTaskAddIn 2.0.2

BR Nicolai

Votes for this answer: 1
 
Kim Søjborg Pedersen
Reply

Hi Nicolai

After upgrading to 9.9.0 I still don't think it works. The AccessUserPointBalance is not correct. The value in "Expiration period (in months)" is in my case 3, but it looks like every row from EcomLoyaltyUserTransaction is added to the calculation.

I looked inside the addin and I'm not sure I understand this part  "x => x.ExpirationDate > lastRun

List<UserTransaction> list = transactionManager.GetUserTransactions().Where<UserTransaction>((Func<UserTransaction, bool>) (x => x.ExpirationDate > lastRun && x.ExpirationDate <= systemTime)).OrderBy<UserTransaction, int>((Func<UserTransaction, int>) (x => x.UserId)).ThenBy<UserTransaction, DateTime>((Func<UserTransaction, DateTime>) (x => x.TransactionDate)).ToList<UserTransaction>();

Thanks
Kim

 
Nicolai Pedersen
Reply

My guess is that it is to avoid expiring points twice. Expiration of points is a transaction, and to avoid that the same expiration transaction is added more than once, this was the solution.

So if you try to clean your transaction table from all expiration records ([LoyaltyUserTransactionRewardId] = -1 and [LoyaltyUserTransactionComment] = "Points expired" and then set the "/Globalsettings/Ecom/LoyaltyPoints/LastExpirationAddInRun" global setting to old days and run the addin, you should get the right balance.

Granted - it is not the best implementation logic around - it is error prone if scheduled tasks have been out of service, moving database between installations or if error occurs during the expiration task is running...

It should be possible to completely change that logic - to just calculate it on the fly and add 'virtual' transactions to users for the expired points and let the point total be a sum of that instead of calculated value. But as you can figure out, this is not a simple change as it will be a problem for existing implementations.

 
Kim Søjborg Pedersen
Reply

Hi Nicolai

Thanks for the explanation. That's not quite the logic we need, so we'll see if we can make our own.

Thanks
Kim
 

 
Nicolai Pedersen
Reply

Hi Kim

Ok - feel free to keep us in the loop, we might learn something!

Thanks, Nicolai

 
Kim Søjborg Pedersen
Reply

I think you will need to keep track of and distinguish between whether the individual transaction has been redeemed by the user or has actually expired before redemption. It will probably require an extension of the table.
 

 
Nicolai Pedersen
Reply

Hi Kim

I do not think that is needed. There is a setting that defines when points are expiring, and if you know when a transaction is made you should be able to figure out the rest "runtime"

Given these transactions and a expiration of 30 days:

  1. Gain 100 points (day 1) *** balance = 100
  2. Gain 50 points (day 10) *** balance = 150
  3. Spend 60 points (day 15) *** balance = 90
  4. Gain 25 points (day 20) *** balance = 115
  5. ... Day 30 ... virtual calculation ... you have 100 points that expires - but you spent 60 after the reward date, so 40 will expire. *** balance = 75
  6. Gain 10 points (day 35) *** balance = 85
  7. Spend 5 points (day 40) *** balance = 80 
  8. ... Day 40 ... virtual calculation ... you have 50 points that expires - but you spent 5 after the last virtual expiration date, so 45 will expire. *** balance = 35

Should be possible to make as a relatively simple loop over the transactions and calculate the virtual point expirations. You could create a sorted list of the transactions on load, and as part of that add items on the expected expiration dates of earnings.

Makes sense?

BR Nicolai

 
Kim Søjborg Pedersen
Reply

Hi Nicolai

Yes and if the virtual calculation at #5 fails and you have "no last virtual expiration date" to use in #8  I guess it would say

8. Day 40 ... virtual calculation ... you have 150 points that expire – but you spent 65 since start, so 85 will expire balance = 35

I'm not 100% sure what you meen by runtime in this context, but we still need the balance in AccessUserPointBalance so we can make a smart search on that like query all users with more then 100 points.

Thanks
Kim

 
Nicolai Pedersen
Reply

Hi Kim

By runtime I mean to not let the expired point transactions be in the transaction table - or alternatively, delete them and recalculate expiration everytime the total is calculated.

 

You must be logged in to post in the forum