alexis

Check the balance and subtract

Recommended Posts

I believe, it would be good to have a condition to check for the balance of a member: whether a user has a necessary amount of points for doing some certain actions.

Currently we have only six conditions, included in Points Economy, and some of them probably should help to check, whether points are enough, if we know some of PHP code:

56ab864f18fb4_phpcode.png.4e1844327f7da1

balance.png.1ea84f7d9d75cc2e4a5d7bc51225

The problem is, that not all the forum admins' php knowledge is good enough to fill that text area, so probably adding "points" to the data use for this condition will help?

number.PNG.b425f676fde4385ecbf18429ce63c

Since the amount of points should be an integer field, it won't be too complicated? :) 

(The event of the rule above is just a "Custom Data updated")

By the way, I didn't find a way, how to make such actions with points like we can do with Updating our custom data fields:

subtract.PNG.b2607ad3f7bef34c9dae03cfe66

As you can see, I'm particularly speaking about missing the "subtract" action. In the Actions, we only have two possible operations which we can do with Economy Points: "Credit or Debit a points balance" and "Transfer or exchange a points balance". With the first one, we only can proceed with Automatic Credit/Debit, Credit Only or Debit Only adjustment types. But none of them allow us to input a negative amount for adjustment! :( 

negative.PNG.b40029c671933b710fe905670e0

That's why for the operations, where we need the certain points amount to be subtracted, we have to use another E.Points action called "Transfer or exchange a points balance". Is it planned to be done in this way? Or do I miss something?

(Kevin, what about adding a Spoiler button to the Editor on your forum? :) )

  • Like 1

Share this post


Link to post
Share on other sites
13 minutes ago, alexis said:

I believe, it would be good to have a condition to check for the balance of a member

I agree.

14 minutes ago, alexis said:

and some of them probably should help to check, whether points are enough

You can check if a credit or debit is possible using the condition to check if an adjustment is possible.

16 minutes ago, alexis said:

so probably adding "points" to the data use for this condition will help?

Since the amount of points should be an integer field, it won't be too complicated?

Balances are different per bank, and currency can have decimal places, and available balance vs total balance are different, and the member might have a balance but has been moved to a group without permission to use it...  

23 minutes ago, alexis said:

As you can see, I'm particularly speaking about missing the "subtract" action. In the Actions, we only have two possible operations which we can do with Economy Points: "Credit or Debit a points balance"

Credit is addition, Debit is subtraction. 

26 minutes ago, alexis said:

But none of them allow us to input a negative amount for adjustment!

Because if you credit 1 point, that adds 1 point. If you debit 1 point, that subtracts 1 point.

You dont credit or debit negative values.

The "automatic" option will take an event argument and either credit or debit according to if it is negative or not.

30 minutes ago, alexis said:

That's why for the operations, where we need the certain points amount to be subtracted, we have to use another E.Points action called "Transfer or exchange a points balance". Is it planned to be done in this way? Or do I miss something?

Just choose debit to subtract points.

  • Like 1

Share this post


Link to post
Share on other sites
22 hours ago, Kevin Carwile said:

Balances are different per bank, and currency can have decimal places, and available balance vs total balance are different, and the member might have a balance but has been moved to a group without permission to use it...  

your words mean, that the implementing the requested feature will be a little bit complicated? :D

Actually, this kind of checking, whether a user has enough "money", is sometimes necessary, if this "money" is needed for some certain actions, for example, changing the title of a member: with the Event "update custom data field", each member can use this "paid service" for changing his title, but only if he has enough points to "pay" for it.

If using your advice with checking by "check if an adjustment is permissible",so it doesn't work for me, since it doesn't check, whether the user has enough points or not (neither with "Credit Only" nor with "Debit only" adjustment type).

Share this post


Link to post
Share on other sites
1 hour ago, alexis said:

Actually, this kind of checking, whether a user has enough "money", is sometimes necessary, if this "money" is needed for some certain actions, for example, changing the title of a member: with the Event "update custom data field", each member can use this "paid service" for changing his title, but only if he has enough points to "pay" for it.

If using your advice with checking by "check if an adjustment is permissible",so it doesn't work for me, since it doesn't check, whether the user has enough points or not (neither with "Credit Only" nor with "Debit only" adjustment type).

Yes, I understand there is a valuable condition missing from the set.

Share this post


Link to post
Share on other sites

Currently I'm stuck with finding out a way, how to check for the total balance of a member, which includes all the balance in the certain currency. This total amount is shown in the left panel under our post count:

56b9c91f5962c_94points.PNG.10b868b0d35d5

As you see, this number - 94 points - is the total amount of points the user currently has "in cash" in all his banks and accounts in this certain currency.

credit.PNG.91122b489a94d699d6b15bb2099fa

I suppose, we can output this value only using PHP code? :( 

(My main aim for figuring out this issue, is to assign the user with negative amount (total amount!) into a penalty group.)

 

Share this post


Link to post
Share on other sites

A big thank to Kevin for providing this perfect documentation!

All works fine and great, except for one moment, which I've failed to specify using your manual:

This code works only with one certain member, which we specify in the code:

$currency = \IPS\points\Currency::load( 1 );
$member = \IPS\Member::load( 26 );
$amount = $currency->netWorthAsOf( new \IPS\DateTime( 'now' ), $member );
return $amount;

In this example, which I use as a condition for the Rule, triggered by Event: A balance has been adjusted, the condition is checking only the user №26, I plan to check for the users, whose balance has been adjusted. And it could be any member, not only №26 :) 

I've tried    $member = $member ?: \IPS\Member::loggedIn();   and   $member = \IPS\Member::loggedIn(); -- but they don't fit to the rule, if the user could be offline when the adjustment has been proceeded.

Could you please share with me, how to check for the member, whose balance has been adjusted?

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.