-
Notifications
You must be signed in to change notification settings - Fork 308
Conversation
!m @rorepo When you're ready, go ahead and apply the "Review" label. |
charge threshold, park this for the next week by adding the current subscription amount | ||
to giving_due | ||
""" | ||
cursor.run("""INSERT INTO participants_payments_uncharged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4-space indents instead of tabs, please.
Reformatting for readability. :-) Implemented the core part of the solution for issue "charge minimum in arrears, not in advance #3378"
Will await comments/suggestions before proceeding further. Further changes planned:
|
I think it should be the basic amount, because that will be more natural to people. "I give 50¢/wk, so I'll get charged every 20 weeks," rather than getting charged in the 19th week because the fee puts you over the top. I mean, that's pretty minor. It's implemented as checking the basic amount right now, iirc. |
We're going to need at least a few tests for this. |
I mean for this PR as a whole. I'm not seeing any tests for the new functionality. |
CREATE TABLE participants_payments_uncharged AS | ||
SELECT participant | ||
FROM payday_payment_instructions | ||
WHERE 1 = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's going on with this construction? One does not equal two. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The '1 = 2' thing is an old trick I've used quite a lot - when I wished to copy the structure (full or part) of some table, without the data. Might be overkill here for just one column, but for one thing, all other table creations in this script are in the form of selects and also, this usage means it will not break if the participant column is modified in payday_payment_instructions/payment_instructions.
@whit537 - Can you try re-enabling the repo at Travis? |
Have corrected the formatting and the extraneous argument. The '1 = 2' thing is an old trick I've used quite a lot - when I wished to copy the structure (full or part) of some table, without the data. Might be overkill here for just one column, but for one thing, all other table creations in this script are in the form of selects and also, this usage means it will not break if the participant column is modified in payday_payment_instructions/payment_instructions. Working on the tests now. Haven't used mock or vcr before, so took a while to figure these out. |
It appears to be re-enabled already. O.O The failure on e087c60 was spurious ("GitHub rate limit exceeded"), so I restarted that build. |
Cool. You almost certainly don't need vcr to test this code, and probably not even mock. |
@whit537 - I'm afraid I didn't get your comment about not needing vcr/mock. The way I figured it, I'd have to update test_billing_payday.py, which uses these. I'd have to add new tests as well as update existing ones, because the 'charge-in-arrears' functionality would make some of these invalid e.g. 'test_payday_moves_money', which was for a payment of $6 and which would now not be charged since this is now below the charge threshold. |
@rorepo I guess you're right. :-) I was just going on a hunch, since you're actually touching code, don't mind me. Sorry! :-) |
Looking at the tests exposed a few bugs as well as the fact that quite a few of the existing tests would have to change. The key points in tests:
@whit537 I've removed the method |
The commit log on this PR looks weird. Why are there two of some commits? Why is the 1880 version bump on here? |
I think maybe we need a rebase of this branch to clean up the commits. |
25da199
to
98f0f3e
Compare
Rebasing on master got rid of the 1880 version bump. Now for the duplicate commits ... |
Don't quite understand, @whit537. I did do a rebase before merging and I'd assume that's how the 1880 version came in. |
@rorepo After rebasing on master, here are the commits I'm seeing: It looks like we have duplicate commits for:
|
Neither do I. :-) My git-fu is not that strong. I think at this point we should rebase to squash the duplicate commits, and then make sure the overall diff is as expected, and then forge ahead. I'm going to rebase ... unless you object? |
... presents me with ...
|
You're welcome to proceed, @whit537. My git-fu is almost certainly weaker than yours, in any case :-) |
Good luck :-) |
Thanks! :-) |
@rorepo I looks like we have duplicate commits again ... |
feeec33
to
a8a6bc4
Compare
And now we're down to a pyflakes error! :-) |
Aaaaaaaand that's the error you were pointing out at #3675 (comment). :-( |
It's your latest commit, a8a6bc4, that adds the duplicate methods to |
a8a6bc4
to
aa12b9d
Compare
I've force-pushed a8a6bc4 off the branch, and now we're green again. What was the intention with that commit? The code doesn't seem to match what it says on the tin:
|
Once we land this, should we issue refunds for the remaining balances of people that we charged in advance? It would make #3539 easier. |
@rorepo I think we need you to redo your last commit. |
current_payment_instructions view used in place of the new payment_instructions_due table which has now been removed New update_due method added to participant to carry over existing due values to new (modified) payment instructions
I think where my merges go wrong is when things go to conflict resolution. Either I'm not reading/handling the conflicts right or git is deficient in picking up/highlighting things like duplicated code. But my understanding of git is improving, so hopefully this won't be a perennial problem. A few thoughts on refunding remaining balances charged in advance:
|
:-) Glad there were no more problems. What about the refund bit? Will it make sense to start looking at this? |
Implemented the core part of the solution for issue "charge minimum in arrears, not in advance #3378"
Overview of the solution:
i) Added a new column giving_due in payment_instructions. To be populated/incremented with the corresponding amount, each time the amount is not charged due to being under the minimum charge threshold
ii) After creation of payday_payment_instructions, the giving_due value for each participant-team combination is updated with the sum of giving_due values for that combination, from payment_instructions.
iii) The 'giving_today' value for each participant is calculated as sum(amount + giving_due) from all records for that participant in payday_payment_instructions
iv) The 'giving_today' value is checked against the MINIMUM_CHARGE threshold before creating card holds if at/above the threshold. Have a doubt here - whether it's the basic amount or the upcharged amount that is to be used in the check
v) In the case of participants who have been charged, all giving_due values in payment_instructions for those participants are reset to 0
vi) In the case of participants who have not been charged, the giving_due value in the current record in payment_instructions is updated to amount + giving_due
Will await comments/suggestions before proceeding further.
Further changes planned:
i) Add a new column giving_due in participants, to cache the total giving_due value for participants
ii) Update the UI to include the above