Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

WIP - Add Payment History dialog to Payments Tab (#2994) #3391

Closed
wants to merge 19 commits into from
Closed

WIP - Add Payment History dialog to Payments Tab (#2994) #3391

wants to merge 19 commits into from

Conversation

willy-b
Copy link
Contributor

@willy-b willy-b commented Aug 24, 2016

This pull request adds a Payment History dialog to the Payments Tab.
It is a work in progress: The Receipt Link column links do not work yet (working on generating the receipt PDFs now). But the rest of the content in the Payment History dialog should be correct.

Detailed discussions and @bradleyrichter's original mockup can be found in issue #2994 (see mockup at #2994 (comment)).

Willy Bruns added 5 commits August 24, 2016 10:13
- We now store the last BTC price with the ledgerInfo object in `ledger.js`, which becomes the `ledgerData` object in UI
- Why? The BTC price was being computed in a couple of places from the current account balance (balance $ / balance USD). Recomputation from derived quantities can lead to error, this is simpler.
- Displays a table of user payment history
  (Each row represents a batched payout to multiple publishers
  sometimes called a `reconciliation` or `transaction` elsewhere)
- 3 columns are shown for each payment: `Date`, `Total Amount`, & `Receipt Link`
- Data comes from `transactions` array in `ledgerData` obj in UI
  (same as `ledgerInfo` in `browser-laptop/app/ledger.js`)
- Next payment date in footer comes from `ledgerData.reconcileStamp`

Loose ends / unfinished items:
- `Receipt Link` is a dummy filename for now: PDF receipts are NOT impl yet
- `Total Amount` USD value fluctuates because the stored value is in BTC
  and current exchange rate is used. This will be fixed in followup commit
- The "Show Payment History" button is in an awkward spot

impls issue #2994
- restyle "View Payment History" button per updated spec
  Simple orange text in Account Balance box
  #2994 (comment)
if ((body.rates) && (body.rates[currency])) info.btc = (amount / body.rates[currency]).toFixed(8)
if ((body.rates) && (body.rates[currency])) {
info.btcPrice = body.rates[currency]
info.btc = (amount / body.rates[currency]).toFixed(8)
Copy link
Member

Choose a reason for hiding this comment

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

need @mrose17 to review this part

Copy link
Member

Choose a reason for hiding this comment

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

i guess this is obsolete now.

Copy link
Member

Choose a reason for hiding this comment

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

agreed. no longer needed.

@diracdeltas
Copy link
Member

I don't think we will add this to 0.11.6 @bbondy but looking good so far. Thanks @willy-b

@willy-b
Copy link
Contributor Author

willy-b commented Aug 25, 2016

Thanks for the code review @diracdeltas! I'll get those points addressed this afternoon.

@mrose17
Copy link
Member

mrose17 commented Aug 25, 2016

@willy-b what's your thinking in terms of a timeframe?

@willy-b
Copy link
Contributor Author

willy-b commented Aug 25, 2016

@mrose17, I will finish addressing the points @diracdeltas raised in her review by 3:30PM. (EDIT: merging ledger-client update from master dragged this out, but all done now)

Then I aim to post a proposal/breakdown for the Receipt PDF based on @bradleyrichter's gorgeous new Receipt PDF mockups (reference: #2994 (comment)) by 4:30PM. (EDIT: going to do in a separate PR and do CSV here to keep PRs small and avoid merge/rebase hell :-) )

For one I am going to suggest we omit absolute time figures for pages and only include contributions actually sent. This is the data available in the ledgerData.transactions array and also what I would argue is important to display (the probability of contributing to a site is less important after the fact than what was contributed).

We might want to do simple CSV receipts in this PR and implement @bradleyrichter's really nice mockups in a separate PR depending on schedule.

@diracdeltas
Copy link
Member

(the probability of contributing to a site is less important after the fact than what was contributed

agree, and i think simple CSV receipts are fine for now

@@ -695,6 +695,7 @@ var ledgerInfo = {

// the desired contribution (the btc value approximates the amount/currency designation)
btc: undefined,
btcPrice: undefined,
Copy link
Member

Choose a reason for hiding this comment

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

@willy-b not sure if this is obvious to you, but the BTC price should now be available as a property of transactions according to @mrose17. specifically ledgerInfo.transactions[i].contribution.rates is the BTC price in the local currency at the time of the transaction (i think).

Copy link
Contributor Author

@willy-b willy-b Aug 25, 2016

Choose a reason for hiding this comment

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

Yes, @mrose17's updates in ledger-client v0.8.46 brought in by #3397 are really nice.
They save me from having to add a historical btcPrice to the transactions entries, and obsolete the btcPrice I added :-)

}

get satoshis () {
return this.transaction.get('satoshis')
Copy link
Member

Choose a reason for hiding this comment

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

@mrose17 is this correct, or should it be this.transaction.get('contribution').get('satoshis') now?

Copy link
Contributor Author

@willy-b willy-b Aug 25, 2016

Choose a reason for hiding this comment

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

Sorry @diracdeltas, hold on just a minute, I haven't pushed the merge of @mrose17's update which includes this.
When you see the merge commit with latest master then you can come in full guns blazing :-).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@diracdeltas, while @mrose17 updated the docs/state.md in 5040058 , he didn't update app/ledger.js to whitelist the contribution field to be picked from ledger-client transaction result. Thus after #3397 the contribution field still wasn't making it to UI.
I am updating the comments and code in ledger.js right now. Let me know if this is available in a different commit I can cherry-pick, because enabling transactions[n].contribution probably shouldn't be part of this PR.

Copy link
Member

Choose a reason for hiding this comment

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

will defer to @mrose17 on that

Copy link
Member

Choose a reason for hiding this comment

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

oops! i'll fix it in master momentarily... sorry!

Copy link
Member

Choose a reason for hiding this comment

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

use this.transaction.get('contribution').get('satoshis')

@willy-b
Copy link
Contributor Author

willy-b commented Aug 25, 2016

Update: I merged latest master to get @mrose17's updates in ledger-client v0.8.46 brought in by #3397, specifically the awesome new transactions[n].contribution field.
But now I'm seeing some issues (ledger-client seems to be running over and over in a loop, and I'm trying to trigger a reconcile ahead of schedule to get real data with new format) so I'm running a bit behind schedule. (Only pushed 3 of the changes requested by @diracdeltas so far.)

@mrose17
Copy link
Member

mrose17 commented Aug 26, 2016

@willy-b - sorry about that. do me a favor and to your ledger-state.json file, towards the top look for

  "options": {
    "verboseP": false,

and change false to true and then let me know what it's doing... thanks!

@willy-b
Copy link
Contributor Author

willy-b commented Aug 26, 2016

@mrose17 no worries at all, thanks for the help.

It just appears to be logging the same line ledger client run over and over again:

ledger client run: clientP=true delayTime=0
ledger client run: clientP=true delayTime=0
ledger client run: clientP=true delayTime=0
...

Willy Bruns added 2 commits August 25, 2016 21:12
- text should not wrap/overflow when window is narrow
#3391 (comment)
- "View Payment History" should be left-aligned now, since #3396
}

get numericDateStr () {
var date = new Date(this.timestamp)
Copy link
Member

Choose a reason for hiding this comment

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

why not just return date.toLocaleDateString() here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I did do that for the displayed date: 48b0171#diff-e3eeb751016b2ce9f8278efce585a461R1258

This is for a filename, so toLocaleDateString is a little awkward with the slashes and lack of zero-padding. But sure, I can use toLocaleDateString and then replace the '/' with '-'s and let the lack of zero-padding be.

Copy link
Member

Choose a reason for hiding this comment

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

gotcha, i missed the fact that this is for a filename. sorry

@bradleyrichter
Copy link
Contributor

@willy-b Heads up for you. We are discussing a change that would swap the percent column for dollars (or local currency) per site. We should have this ironed out soon.

@willy-b
Copy link
Contributor Author

willy-b commented Aug 26, 2016

Thanks for heads up @bradleyrichter!
That's no problem. If I have the %, I can just multiply the % by the total in local currency. We do have the local currency value at historical exchange thanks to @mrose17's recent ledger-client update.

My semi-blocker right now is that the ballots field seems to have disappeared from the transactions entry -- that was what I used to get the %.

}

get satoshis () {
return this.transaction.get('contribution').get('satoshis')
Copy link
Member

Choose a reason for hiding this comment

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

contribution and other child properties may not necessarily exist, so this would throw cannot read property 'get' of undefined errors. please use this.transaction.getIn(['contribution', ...]).

@diracdeltas
Copy link
Member

@willy-b does the semi-blocker relating to the disappearance of ballots only affect the transaction CSV/PDF files? I am fine with merging this for now once the comments above are addressed, and the CSV/PDF part can be done in a follow-up PR.

Thanks for the work; please run git rebase -i to squash commits when you're done.

@willy-b
Copy link
Contributor Author

willy-b commented Aug 27, 2016

Thanks for all the testing and code reviewing @diracdeltas.

Yes, the ballots issue only affects the transaction-level CSV/PDF. If everyone is OK with it, I think it's a great idea to move the 'Receipt Link' to a separate PR.

@bradleyrichter
Copy link
Contributor

@willy-b False alarm on the change to currency. We are staying with percentages for now.

@bbondy
Copy link
Member

bbondy commented Aug 27, 2016

Is this ready to merge? I won't include it in beta5 yet because I'm not sure.

@mrose17
Copy link
Member

mrose17 commented Aug 27, 2016

@willy-b - what's your thinking on @bbondy's question?

@willy-b
Copy link
Contributor Author

willy-b commented Aug 27, 2016

Hey! If we are OK with doing the 'Receipt Link' in a separate PR then I
just need to disable that column and squash the commits for this to undergo
a final review for merging.
On Aug 26, 2016 10:32 PM, "Marshall T. Rose" [email protected]
wrote:

@willy-b https://github.com/willy-b - what's your thinking on @bbondy
https://github.com/bbondy's question?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#3391 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGpaA-_nvMZsQjzogvuCTwD4frW74QBSks5qj8vqgaJpZM4Jskfu
.

@mrose17
Copy link
Member

mrose17 commented Aug 27, 2016

@willy-b - i like that plan... please proceed

cc: @bbondy

@diracdeltas
Copy link
Member

@willy-b agree; that sounds like a good plan. you can just hide the receipt link column for now.

@willy-b
Copy link
Contributor Author

willy-b commented Aug 27, 2016

Sorry for the delay, coming right up!

On Fri, Aug 26, 2016 at 11:41 PM, yan zhu (@bcrypt) <
[email protected]> wrote:

@willy-b https://github.com/willy-b agree; that sounds like a good
plan. you can just hide the receipt link column for now.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#3391 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGpaA0gMsGvtxGxEXcl_F2jeOsegjwyVks5qj9wogaJpZM4Jskfu
.

@willy-b
Copy link
Contributor Author

willy-b commented Aug 27, 2016

The 'Receipt Link' has been disabled and this has been rebased down to two commits ready for review in PR #3473.

Thanks again @diracdeltas and @mrose17 for the code reviews / testing, and for helping me come up to speed on your project as I worked on this :-).

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

Successfully merging this pull request may close these issues.

7 participants