Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

[FIX] History: show price for orders (RT-1385) #2409

Merged
merged 1 commit into from
May 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/js/util/jsonrewriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,30 @@ var getPrice = function(effect, referenceDate) {
return price || 0;
};

var getStraightPrice = function(effect, referenceDate) {
var g = effect.got ? effect.got : effect.gets;
Copy link
Contributor

Choose a reason for hiding this comment

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

var g = effect.got ? effect.got : effect.gets
is the same as
var g = effect.got || effect.gets

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks! I tend to forget that notation :)

var p = effect.paid ? effect.paid : effect.pays;
var price;

if (!p.is_zero() && !g.is_zero()) {
price = g.ratio_human(p, {reference_date: referenceDate});
}

return price || 0;
};

var getInvStraightPrice = function(effect, referenceDate) {
var g = effect.got ? effect.got : effect.gets;
var p = effect.paid ? effect.paid : effect.pays;
var price;

if (!p.is_zero() && !g.is_zero()) {
price = p.ratio_human(g, {reference_date: referenceDate});
}

return price || 0;
};

/**
* Determine if the transaction is a 'rippling' transaction based on effects
*
Expand Down Expand Up @@ -573,6 +597,8 @@ var JsonRewriter = module.exports = {
}

effect.price = getPrice(effect, tx.date);
effect.straightPrice = getStraightPrice(effect, tx.date);
effect.invStraightPrice = getInvStraightPrice(effect, tx.date);

// Flags
if (node.fields.Flags) {
Expand Down
75 changes: 53 additions & 22 deletions src/templates/tabs/history/effects.jade
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,58 @@ ul.effects(ng-show="entry.effects")
span.amount(rp-pretty-amount-high-precision="effect.gets")
| for
span.amount(rp-pretty-amount-high-precision="effect.pays")
| (
span(l10n-inc) price :
strong(rp-address-popover, rp-address-popover-sum="effect.invStraightPrice") {{effect.invStraightPrice | rpamount:{abs_precision: 6} }}
span {{ effect.pays | rpcurrency }}
| per
span {{ effect.gets | rpcurrency }}
| ).
span(ng-hide="effect.sell", l10n, rp-span-spacing) You bought
span.amount(rp-pretty-amount-high-precision="effect.pays")
| for
span.amount(rp-pretty-amount-high-precision="effect.gets")
| (
span(l10n) price
span :
strong(rp-address-popover, rp-address-popover-sum="effect.price") {{effect.price | rpamount:{abs_precision: 4} }}
| ).
| (
span(l10n) price :
strong(rp-address-popover, rp-address-popover-sum="effect.straightPrice") {{effect.straightPrice | rpamount:{abs_precision: 6} }}
span {{ effect.gets | rpcurrency }}
| per
span {{ effect.pays | rpcurrency }}
| ).
span(l10n) This order has been filled.
span(ng-switch-when="offer_partially_funded")
span(ng-show="effect.sell", l10n, rp-span-spacing) You sold
span.amount(rp-pretty-amount-high-precision="effect.got")
| for
span.amount(rp-pretty-amount-high-precision="effect.paid")
| (
span(l10n-inc) price :
strong(rp-address-popover, rp-address-popover-sum="effect.invStraightPrice") {{effect.invStraightPrice | rpamount:{abs_precision: 6} }}
span {{ effect.paid | rpcurrency }}
| per
span {{ effect.got | rpcurrency }}
| ).
span(ng-hide="effect.sell", l10n, rp-span-spacing) You bought
span.amount(rp-pretty-amount-high-precision="effect.paid")
| for
span.amount(rp-pretty-amount-high-precision="effect.got")
| (
span(l10n) price
span :
strong(rp-address-popover, rp-address-popover-sum="effect.price") {{effect.price | rpamount:{abs_precision: 4} }}
| ).
| (
span(l10n-inc) price :
strong(rp-address-popover, rp-address-popover-sum="effect.straightPrice") {{effect.straightPrice | rpamount:{abs_precision: 6} }}
span {{ effect.got | rpcurrency }}
| per
span {{ effect.paid | rpcurrency }}
| ).
span(ng-show="effect.cancelled", l10n) The rest of your order has been cancelled due to lack of funds.
span(ng-hide="effect.deleted", l10n, rp-span-spacing) This order has
span(rp-pretty-amount-high-precision="effect.remaining")
| remaining.
//- We don't show this if it's an offer_cancel transaction.
//- Instead we show it if the order has been cancelled because of luck of
//- funds by some other non related transaction.
span(ng-switch-when="offer_cancelled", l10n) Order (
span(ng-switch-when="offer_cancelled", l10n, rp-span-spacing) Order (
span.amount(rp-pretty-amount-high-precision="effect.pays")
| for 
| for
span.amount(rp-pretty-amount-high-precision="effect.gets")
| ) has been cancelled due to lack of funds.
span(ng-switch-when="offer_created")
Expand All @@ -50,16 +68,29 @@ ul.effects(ng-show="entry.effects")
span.amount(rp-pretty-amount-high-precision="effect.pays")
| for
span.amount(rp-pretty-amount-high-precision="effect.pays")
span(ng-switch-when="offer_bought", l10n, rp-span-spacing) You bought
span.amount(rp-pretty-amount-high-precision="effect.got")
| for
span.amount(rp-pretty-amount-high-precision="effect.paid")
| (
span(l10n-inc) price
span :
strong(rp-address-popover, rp-address-popover-sum="effect.price") {{effect.price | rpamount:{abs_precision: 6} }}
| ).

span(ng-switch-when="offer_bought",)
span(ng-hide="entry.transaction.sell", l10n, rp-span-spacing) You bought
span.amount(rp-pretty-amount-high-precision="effect.got")
| for
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be localized although nested twice in the l10n? Otherwise you might need to mark it as l10n-inc.

span.amount(rp-pretty-amount-high-precision="effect.paid")
| (
span(l10n-inc) price :
strong(rp-address-popover, rp-address-popover-sum="effect.invStraightPrice") {{effect.invStraightPrice | rpamount:{abs_precision: 6} }}
span {{ effect.paid | rpcurrency }}
| per
span {{ effect.got | rpcurrency }}
| ).
span(ng-show="entry.transaction.sell", l10n, rp-span-spacing) You sold
span.amount(rp-pretty-amount-high-precision="effect.paid")
| for
span.amount(rp-pretty-amount-high-precision="effect.got")
| (
span(l10n-inc) price :
strong(rp-address-popover, rp-address-popover-sum="effect.straightPrice") {{effect.straightPrice | rpamount:{abs_precision: 6} }}
span {{ effect.got | rpcurrency }}
| per
span {{ effect.paid | rpcurrency }}
| ).
span(ng-switch-when="trust_create_local", l10n) You have now connected to the gateway 
span(rp-pretty-identity="effect.counterparty", rp-address-popover="effect.counterparty")
span(l10n-inc)  for 
Expand Down