Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Bring back takes in payday #4102

Merged
merged 7 commits into from
Sep 1, 2016
Merged

Bring back takes in payday #4102

merged 7 commits into from
Sep 1, 2016

Conversation

chadwhitacre
Copy link
Contributor

@chadwhitacre chadwhitacre commented Jul 29, 2016

#3994

#4077#4113

Remake of #4025.

TODO

@chadwhitacre
Copy link
Contributor Author

Okay! I rebased #4025 on #4077. GitHub wouldn't let me reopen #4025 for whatever reason, so here we are. This is still work in progress.

@chadwhitacre
Copy link
Contributor Author

Made some progress on this on the bus this morning. Rebased and pushed.

@chadwhitacre
Copy link
Contributor Author

Alright, getting back to this. I'm looking at test_take_over_during_payin and finding some complication related to take_over, an interaction between clearing takes and checking for identities.

@chadwhitacre chadwhitacre force-pushed the takes-payday branch 8 times, most recently from e4cd2f6 to b3c050e Compare August 24, 2016 17:38
@chadwhitacre
Copy link
Contributor Author

This is ready for review, @Nashe @aandis @rohitpaulk! I split off a new PR for MassPay (#4111).

@chadwhitacre
Copy link
Contributor Author

Found a bug while working on #4111. Withdrawing Review and fixing here ...

@chadwhitacre chadwhitacre force-pushed the takes-payday branch 2 times, most recently from 06f3998 to 66d1023 Compare August 25, 2016 16:26
@chadwhitacre
Copy link
Contributor Author

Okay, fixed. Ready for review again! :-)

@chadwhitacre chadwhitacre changed the title bring back takes in payday Bring back takes in payday Aug 25, 2016
@ghost
Copy link

ghost commented Aug 25, 2016

I don't have a lot of things to say since I'm not familiar with this part of the code—but nothing shocked me. Waiting for a second approval?

@chadwhitacre
Copy link
Contributor Author

Thanks @Nashe.

@rohitpaulk Would you be able to spare any cycles this week to look this over? This and #4111 are the last two major PRs needed to land payouts for Team Gratipay!

@rohitpaulk rohitpaulk self-assigned this Aug 29, 2016
self.enterprise.set_take_for(self.picard, D('0.01'), self.picard)
with pytest.raises(NotAllowed):
self.enterprise.set_take_for(self.picard, 50, self.picard)
return # XXX allow owners to join teams!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, what is happening here? What is the limitation that we're facing in allowing owners to join teams? And if we are going to do it in the future, do we have a vague idea of how we'd do it? My main concern here is whether we're making a decision that will make it harder to re-introduce this functionality in the future. (we'll build more stuff that assumes this is not going to happen, and then that'll be harder to reverse)

I guess the fundamental issue here is that we don't allow a payment sink to be tied to a team (we drain funds to the owner's bank account) - however - We could still process takes to the owner, right? And in the future when we do allow linking bank accounts to teams - the only piece that will change is process_remainders.

I think this is also nice in terms of the payroll functionality - we want an owner to be able to set 'their' take - and have the rest go to the team. It won't make a different right now in terms of where the money goes - but teams could use that data to decide how to split money internally. For example, if @whit537 was the owner of Gratipay - he could set a take and have the rest flow to the team. And once a month, he could look at the takes history and decide how much to move to his personal account and how much to keep in the team's operations account.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know @kaguillera and I talked about this, and I thought I recorded somewhere that we thought it was okay to allow owners to join teams. Looking for that ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found it!

#4077 (comment)

Copy link
Contributor Author

@chadwhitacre chadwhitacre Sep 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready for review in 3ac7fee.

@rohitpaulk
Copy link
Contributor

FIrst pass done, only real concern is #4102 (comment) - the rest are just code-style/tests stuff that I'll clear myself in a while

@chadwhitacre
Copy link
Contributor Author

@rohitpaulk Awesome! I've updated the todo and will look into these right after lunch ... 🍗

@rohitpaulk
Copy link
Contributor

I like how all my comments have magically appeared as to-do items on the description of this ticket 😉

@chadwhitacre
Copy link
Contributor Author

Let's communicate if/what we're working on to avoid stepping on each others' toes. I'm working on putting food into my head. :)

@rohitpaulk
Copy link
Contributor

:) I'm working on " fix order of calls (and test!)" right now

@rohitpaulk
Copy link
Contributor

Done with that, now looking at "refactor process_distribution for clarity"

@chadwhitacre
Copy link
Contributor Author

refactor process_distribution for clarity

Should we rename it back to process_take since we're not really using "distribution" elsewhere in the code?

self.payday.update_balances(cursor)

assert P('alice').balance == D('100')
assert P('picard').balance == D('400') # Owner receives whatever is left
Copy link
Contributor Author

@chadwhitacre chadwhitacre Aug 31, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this test expected to fail without 84f4b31? That was my expectation, but when I manually revert that commit locally this test still passes.

Also: Let's find the right place for this in the test suite. Where it is now it should have a name like test_pt_ for both conceptual grouping and easy filtering with py.test -k test_pt_. Maybe it would work better up in the TestPayday class?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this test expected to fail without 84f4b31? That was my expectation, but when I manually revert that commit locally this test still passes.

I see how this is confusing - the first test is only testing process_remainder in isolation, and I think it'd be clearer if we just remove process_takes from there.

The order should only matter in the new test that I wrote (that tests the interaction between those two).

Maybe it would work better up in the TestPayday class?

Yep, agreed - on it

@chadwhitacre
Copy link
Contributor Author

Ducking out for gratipay/inside.gratipay.com#792, bbiab ...

@rohitpaulk
Copy link
Contributor

Decided that the extra 'isolated' test wasn't worth it, so merged both into one. Since both process_remainder and process_takes are part of payin(), I placed the test in the TestPayin section.

@rohitpaulk
Copy link
Contributor

Now to squash these commits a bit..

@rohitpaulk
Copy link
Contributor

Done.

@rohitpaulk
Copy link
Contributor

51af227 is what I could come up with to fix "refactor process_distribution for clarity"

Why I think it is better:

  • Unlike balance which goes from zero to positive and back during a payday, available was not created with the intention of being a variable during payday. available is a property on the team, and only the owner should be able to change it - we were piggybacking additional functionality on this column by decreasing it on every take.
  • Less comparison logic to read through - UPDATE payday_teams SET available_today = LEAST(available, balance); captures the idea more clearly than the two previous comparison statements we had.

@rohitpaulk
Copy link
Contributor

Off for tonight, will check back tomorrow morning! 😴

@chadwhitacre
Copy link
Contributor Author

Back from gratipay/inside.gratipay.com#792, catching up ...

@chadwhitacre
Copy link
Contributor Author

allow owners to join teams—#4102 (comment)

Looking at this ...

@chadwhitacre
Copy link
Contributor Author

I'm good to merge if you're good with 241bc51 and 3ac7fee, @rohitpaulk.

@rohitpaulk rohitpaulk merged commit 8c49b4b into master Sep 1, 2016
@rohitpaulk rohitpaulk deleted the takes-payday branch September 1, 2016 12:41
@chadwhitacre
Copy link
Contributor Author

🎉 Woo-hoo! 💃

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants