Repository: liberapay/liberapay.com

Issue:
Raising amount possible bug?
My actual take on the LP team is 5€ a week.

The following is displayed on liberapay.com when I'm logged in:

![bug2-lp](https://user-images.githubusercontent.com/8705846/48136092-14b6c580-e29f-11e8-8ada-9cf29c3f0683.png)

According to https://liberapay.com/about/teams#throttling , I shouldn't be able to ask for more than a 10€ take for next week if the "Regulation of take amounts" functionality is activated on the LP team. If this functionality isn't activated on the LP team, then I don't know where the _26,50€_ amount calculation comes from since (at the time of writing), the LP team leftover is _5,00 € and 2,93 $US_ which would make the following calculation for the maximum amount I could ask for: 5€ (week take) + 5€ + 2.93$ which equals to roughly a bit less than half of the _26,50€_ mentioned above.

It doesn't looks clear to me what's going on, and I might be totally/partially wrong with how the system works, but something sounds fishy here.



Discussion:
€26.50 is indeed a weird limit given the current situation. Looking at the code I see a bug that might be responsible.
After fixing that bug I'm getting €21.65, which is €5.00 + a leftover of €16.65.
Does that corresponds to the actual leftover of the team? _(I guess you're trying that on a home-made installation of LP which might not be on the same state than the production one)_

Also, that would means that the [Regulation of take amounts](https://liberapay.com/about/teams#throttling) isn't activated on the LP team account. Note that I didn't see where this option can be activated/deactivated in the LP team profile on liberapay.com .

Note that, as of right now I've got this:
![lp-team-raising-bug](https://user-images.githubusercontent.com/8705846/48215924-a861c200-e383-11e8-801a-f00100638515.png)
which sounds to indicate that the "Regulation of take amounts" is activated.

The take throttling can't be turned off from the website.
OK
Going further, how does a team can enable the take throttling?
https://liberapay.com/about/teams

![image](https://user-images.githubusercontent.com/3729038/48225270-ecdc6600-e361-11e8-9da8-f23ea53478e1.png)

I think you need to request it be changed.
OK, so that means that one can enable or not this feature at the very moment he creates the team, but then need to ask (to who ?) if later he wants to change?

Adding or removing take throttling requires sending an email to support. I remember this happening at least once.
The remaining TODO before closing this issue is to figure out why the team's estimated income is fluctuating between ~€160 and ~€190, thus resulting in a different leftover and different take limits.
> Adding or removing take throttling requires sending an email to support. I remember this happening at least once.

I've made a PR to add this knowledge to the https://liberapay.com/about/teams page. See #1330 .


Resolving patch:
diff --git a/liberapay/models/participant.py b/liberapay/models/participant.py
--- a/liberapay/models/participant.py
+++ b/liberapay/models/participant.py
@@ -2438,10 +2438,12 @@ def update_receiving(self, cursor=None):
             zero = Money.ZEROS[self.main_currency]
             r = c.one("""
                 WITH our_tips AS (
-                         SELECT amount
-                           FROM current_tips
-                          WHERE tippee = %(id)s
-                            AND is_funded
+                         SELECT tip.amount
+                           FROM current_tips tip
+                           JOIN participants tipper_p ON tipper_p.id = tip.tipper
+                          WHERE tip.tippee = %(id)s
+                            AND tip.is_funded
+                            AND tipper_p.is_suspended IS NOT true
                      )
                 UPDATE participants p
                    SET receiving = taking + coalesce_currency_amount(


Test patch:
diff --git a/tests/py/test_payday.py b/tests/py/test_payday.py
--- a/tests/py/test_payday.py
+++ b/tests/py/test_payday.py
@@ -125,6 +125,12 @@ def test_update_cached_amounts(self):
         bob.set_tip_to(emma, EUR('7.00'))  # not funded, insufficient receiving
         carl.set_tip_to(dana, EUR('2.08'))  # not funded, insufficient balance
         self.make_payin_and_transfer(carl_card, dana, EUR('1.56'))
+        fred = self.make_participant('fred')
+        fred_card = self.upsert_route(fred, 'stripe-card')
+        fred.set_tip_to(dana, EUR('2.22'))
+        self.make_payin_and_transfer(fred_card, dana, EUR('8.88'))
+        self.db.run("UPDATE participants SET is_suspended = true WHERE username = 'fred'")
+        dana.update_receiving()
 
         def check():
             alice = Participant.from_username('alice')
@@ -152,7 +158,7 @@ def check():
             assert emma.npatrons == 1
             assert emma.nteampatrons == 0
             funded_tips = self.db.all("SELECT amount FROM tips WHERE is_funded ORDER BY id")
-            assert funded_tips == [3, 6, 0.5, EUR('1.20'), EUR('0.49')]
+            assert funded_tips == [3, 6, 0.5, EUR('1.20'), EUR('0.49'), EUR('2.22')]
 
             team = Participant.from_username('team')
             assert team.receiving == EUR('1.20')