Skip to content

Commit

Permalink
UI-1248: Fixed credit/debit transactions to properly display
Browse files Browse the repository at this point in the history
Conflicts:
	apps/myaccount/submodules/transactions/transactions.css
	apps/myaccount/submodules/transactions/transactions.js
	apps/myaccount/views/transactions-list.html
  • Loading branch information
JRMaitre committed Mar 13, 2015
1 parent 13294df commit aa1035a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
7 changes: 5 additions & 2 deletions apps/myaccount/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@

"__comment": "UI-1248: Work on transactions to fix the way they're displayed",
"__version": "3.19",
"refundText": "(Refund)",
"codes": {
"1001": "Per Minute Call",
"1002": "Sub-Account Per Minute Call",
Expand All @@ -225,11 +226,13 @@
"5000": "Recurring",
"5001": "Monthly Recurring",
"5002": "Monthly Recurring (Pro-rated)",
"9999": "Unknown"
"9999": "Unknown Refund",
"0": "Unknown"
},
"errorStatuses": {
"voided": "Voided",
"declined": "Declined"
"declined": "Declined",
"processor_declined": "Declined"
}
}
}
4 changes: 4 additions & 0 deletions apps/myaccount/submodules/transactions/transactions.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
margin-bottom: 15px;
}

.transactions-content-wrapper .list-transactions .transaction.refund {
color: #22A5FF;
}

.transactions-content-wrapper .list-transactions .transaction > *:not(.expandable) {
line-height: 65px;
height: 65px;
Expand Down
33 changes: 10 additions & 23 deletions apps/myaccount/submodules/transactions/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ define(function(require){

parent.find('.expandable').hide();

parent.find('.start-date .value').html(data.billingStartDate);
parent.find('.end-date .value').html(data.billingEndDate);
parent.find('.total-amount .value').html(self.i18n.active().currencyUsed + data.amount);
parent.find('.billing-date.start').html(data.billingStartDate);
parent.find('.billing-date.end').html(data.billingEndDate);
parent.find('.total-amount').html(self.i18n.active().currencyUsed + data.amount);
});
});
},
Expand Down Expand Up @@ -133,7 +133,13 @@ define(function(require){
arrayCharges.push(v);

if(v.approved) {
defaults.amount += parseFloat(v.amount);
// All the codes that are in the 5xx and above are refunds
if(v.code % 1000 > 500) {
defaults.amount -= parseFloat(v.amount);
}
else {
defaults.amount += parseFloat(v.amount);
}
}
}
});
Expand All @@ -154,25 +160,6 @@ define(function(require){
);
},

transactionsGetMonthly: function(from, to, success, error) {
var self = this;

monster.request({
resource: 'myaccount.transactions.getMonthly',
data: {
accountId: self.accountId,
from: from,
to: to
},
success: function(data, status) {
success && success(data, status);
},
error: function(data, status) {
error && error(data, status);
}
});
},

transactionsGetCharges: function(from, to, success, error) {
var self = this;

Expand Down
6 changes: 2 additions & 4 deletions apps/myaccount/views/transactions-list.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{{#each listTransactions}}
<div class="box-top-blue transaction">
{{debug this}}
<div class="box-top-blue transaction{{#if this.isARefund}} refund{{/if}}">
{{#compare this.type '===' 'charges'}}
<div class="expand-box">
</div>
Expand Down Expand Up @@ -30,13 +29,12 @@
{{/unless}}

{{ this.friendlyName }}

{{#unless this.approved}}
&nbsp;({{ this.errorMessage }})
{{/unless}}
</div>
<div class="date">{{ this.friendlyCreated }}</div>
<div class="price">{{ ../../i18n.currencyUsed }}{{ this.amount }}</div>
<div class="price">{{ ../../i18n.currencyUsed }}{{#if this.isARefund}}-{{/if}}{{ this.amount }}</div>
</div>
<div class="expandable">
<div class="table-content">
Expand Down
10 changes: 9 additions & 1 deletion js/lib/monster.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ define(function(require){
// Not Intended to be used by most developers for now, we need to use it to have a standard transaction formatter.
// The input needed is an object from the array of transaction returned by the /transactions API.
formatTransaction: function(transaction, app) {
transaction.isARefund = false;

// If transaction has accounts/discounts and if at least one of these properties is not empty, run this code
if(transaction.hasOwnProperty('metadata') && transaction.metadata.hasOwnProperty('add_ons') && transaction.metadata.hasOwnProperty('discounts')
&& !(transaction.metadata.add_ons.length === 0 && transaction.metadata.discounts.length === 0)) {
Expand Down Expand Up @@ -366,7 +368,13 @@ define(function(require){
transaction.amount = parseFloat(transaction.amount).toFixed(2);

if(transaction.hasOwnProperty('code')) {
transaction.friendlyName = app.i18n.active().transactions.codes[transaction.code];
if(transaction.code === 9999 || transaction.code % 1000 < 500) {
transaction.friendlyName = app.i18n.active().transactions.codes[transaction.code];
}
else {
transaction.isARefund = true;
transaction.friendlyName = app.i18n.active().transactions.codes[transaction.code - 500] + ' ' + app.i18n.active().transactions.refundText;
}
}

// If status is missing or among the following list, the transaction is approved
Expand Down

0 comments on commit aa1035a

Please sign in to comment.