{"action":"created","issue":{"url":"https://api.github.com/repos/gratipay/gratipay.com/issues/3675","labels_url":"https://api.github.com/repos/gratipay/gratipay.com/issues/3675/labels{/name}","comments_url":"https://api.github.com/repos/gratipay/gratipay.com/issues/3675/comments","events_url":"https://api.github.com/repos/gratipay/gratipay.com/issues/3675/events","html_url":"https://github.com/gratipay/gratipay.com/pull/3675","id":99932428,"number":3675,"title":"Charge in arrears","user":{"login":"rorepo","id":7984085,"avatar_url":"https://avatars.githubusercontent.com/u/7984085?v=3","gravatar_id":"","url":"https://api.github.com/users/rorepo","html_url":"https://github.com/rorepo","followers_url":"https://api.github.com/users/rorepo/followers","following_url":"https://api.github.com/users/rorepo/following{/other_user}","gists_url":"https://api.github.com/users/rorepo/gists{/gist_id}","starred_url":"https://api.github.com/users/rorepo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rorepo/subscriptions","organizations_url":"https://api.github.com/users/rorepo/orgs","repos_url":"https://api.github.com/users/rorepo/repos","events_url":"https://api.github.com/users/rorepo/events{/privacy}","received_events_url":"https://api.github.com/users/rorepo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/gratipay/gratipay.com/labels/Review","name":"Review","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-08-09T21:53:39Z","updated_at":"2015-08-17T07:30:27Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/gratipay/gratipay.com/pulls/3675","html_url":"https://github.com/gratipay/gratipay.com/pull/3675","diff_url":"https://github.com/gratipay/gratipay.com/pull/3675.diff","patch_url":"https://github.com/gratipay/gratipay.com/pull/3675.patch"},"body":"Implemented the core part of the solution for issue \"charge minimum in arrears, not in advance #3378\" \r\nOverview of the solution:\r\ni) 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\r\nii) 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. \r\niii) The 'giving_today' value for each participant is calculated as sum(amount + giving_due) from all records for that participant in payday_payment_instructions\r\niv) 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\r\nv) In the case of participants who have been charged, all giving_due values in payment_instructions for those participants are reset to 0\r\nvi) 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\r\n\r\nWill await comments/suggestions before proceeding further. \r\n\r\nFurther changes planned:\r\ni) Add a new column giving_due in participants, to cache the total giving_due value for participants\r\nii) Update the UI to include the above\r\n"},"comment":{"url":"https://api.github.com/repos/gratipay/gratipay.com/issues/comments/131705592","html_url":"https://github.com/gratipay/gratipay.com/pull/3675#issuecomment-131705592","issue_url":"https://api.github.com/repos/gratipay/gratipay.com/issues/3675","id":131705592,"user":{"login":"rorepo","id":7984085,"avatar_url":"https://avatars.githubusercontent.com/u/7984085?v=3","gravatar_id":"","url":"https://api.github.com/users/rorepo","html_url":"https://github.com/rorepo","followers_url":"https://api.github.com/users/rorepo/followers","following_url":"https://api.github.com/users/rorepo/following{/other_user}","gists_url":"https://api.github.com/users/rorepo/gists{/gist_id}","starred_url":"https://api.github.com/users/rorepo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rorepo/subscriptions","organizations_url":"https://api.github.com/users/rorepo/orgs","repos_url":"https://api.github.com/users/rorepo/repos","events_url":"https://api.github.com/users/rorepo/events{/privacy}","received_events_url":"https://api.github.com/users/rorepo/received_events","type":"User","site_admin":false},"created_at":"2015-08-17T07:30:27Z","updated_at":"2015-08-17T07:30:27Z","body":"Have corrected the formatting and the extraneous argument. \r\n\r\nThe '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.\r\n\r\nWorking on the tests now. Haven't used mock or vcr before, so took a while to figure these out."}}