Skip to content

Commit

Permalink
UI-1245: Clarified the transactions tab with the right information
Browse files Browse the repository at this point in the history
Conflicts:
	apps/myaccount/i18n/en-US.json
	apps/myaccount/views/transactions-layout.html
	apps/myaccount/views/transactions-list.html
  • Loading branch information
JRMaitre committed Mar 13, 2015
1 parent cc4aba8 commit 13294df
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 44 deletions.
33 changes: 32 additions & 1 deletion apps/myaccount/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,37 @@
"admin_discretion": "Admin Discretion",
"__comment": "UI-383: Fixing transactions for good",
"__version": "v3.20_s0",
"unknown": "Charge"
"unknown": "Charge",
"__comment": "UI-1014: Redesign of MyAccount",
"__version": "v3.20_s1",
"startDate": "Start Date",
"endDate": "End Date",
"total": "Total",

"__comment": "UI-1248: Work on transactions to fix the way they're displayed",
"__version": "3.19",
"codes": {
"1001": "Per Minute Call",
"1002": "Sub-Account Per Minute Call",
"2001": "Feature Activation",
"2002": "Sub-Account Feature Activation",
"2003": "Number Activation",
"2004": "Sub-Account Number Activation",
"3001": "Manual Addition",
"3002": "Sub-Account Manual Addition",
"3003": "Auto-Addition",
"3004": "Sub-Account Auto-Addition",
"3005": "Admin Discretion",
"3006": "Top Up",
"4000": "Balance Carry-over",
"5000": "Recurring",
"5001": "Monthly Recurring",
"5002": "Monthly Recurring (Pro-rated)",
"9999": "Unknown"
},
"errorStatuses": {
"voided": "Voided",
"declined": "Declined"
}
}
}
40 changes: 11 additions & 29 deletions apps/myaccount/submodules/transactions/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ define(function(require){
return a.created < b.created;
});

if(data.listTransactions) {
$.each(data.listTransactions, function(k, v) {
v.reason = self.i18n.active().transactions[v.reason ? v.reason : 'oneTimeCharge'];
});
}

return data;
},

Expand Down Expand Up @@ -95,9 +89,9 @@ define(function(require){

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

parent.find('.billing-date.start').html(data.billingStartDate);
parent.find('.billing-date.end').html(data.billingEndDate);
parent.find('.total-amount').html(data.amount);
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);
});
});
},
Expand Down Expand Up @@ -127,32 +121,20 @@ define(function(require){
};

monster.parallel({
monthly: function(callback) {
self.transactionsGetMonthly(from, to, function(dataMonthly) {
var arrayTransactions = [];

$.each(dataMonthly.data, function(k, v) {
v = monster.util.formatTransaction(v, false, self);

if(v.approved) {
defaults.amount += parseFloat(v.amount);
}
});

callback(null, arrayTransactions);
});
},
charges: function(callback) {
self.transactionsGetCharges(from, to, function(dataCharges) {
var arrayCharges = [];

$.each(dataCharges.data, function(k, v) {
v = monster.util.formatTransaction(v, true, self);
// We don't want to display Balance Carry-Over anymore
if(v.code !== 4000) {
v = monster.util.formatTransaction(v, self);

arrayCharges.push(v);
arrayCharges.push(v);

if(v.approved) {
defaults.amount += parseFloat(v.amount);
if(v.approved) {
defaults.amount += parseFloat(v.amount);
}
}
});

Expand All @@ -163,7 +145,7 @@ define(function(require){
function(err, results) {
var renderData = defaults;

renderData.listTransactions = (results.charges).concat(results.monthly);
renderData.listTransactions = results.charges;

renderData = self.transactionsFormatData(renderData);

Expand Down
15 changes: 6 additions & 9 deletions apps/myaccount/views/transactions-list.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{{#each listTransactions}}
<div class="box-top-blue transaction">
{{debug this}}
{{#compare this.type '===' 'charges'}}
<div class="expand-box">
</div>
<div class="text-box {{#unless this.approved}}declined{{/unless}}">
<div class="title">
{{#if this.approved}}
{{ this.reason }}
{{ this.friendlyName }}
{{else}}
<i class="icon-red icon-warning-sign"></i>
&nbsp;{{ this.reason }}
&nbsp;({{../../../i18n.transactions.declined}})
&nbsp;{{ this.friendlyName }}
&nbsp;({{ this.errorMessage }})
{{/if}}
</div>
<div class="date">{{ this.friendlyCreated }}</div>
Expand All @@ -28,14 +29,10 @@
&nbsp;
{{/unless}}

{{#compare this.type '===' 'monthly'}}
{{ ../../../i18n.transactions.monthlyCharge }}
{{else}}
{{ ../../../i18n.transactions.serviceCharge }}
{{/compare}}
{{ this.friendlyName }}

{{#unless this.approved}}
&nbsp;({{../../../i18n.transactions.declined}})
&nbsp;({{ this.errorMessage }})
{{/unless}}
</div>
<div class="date">{{ this.friendlyCreated }}</div>
Expand Down
19 changes: 14 additions & 5 deletions js/lib/monster.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ 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, isProrated, app) {
formatTransaction: function(transaction, app) {
// 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 All @@ -329,7 +329,7 @@ define(function(require){
mapDiscounts[discount.id] = discount;
});

transaction.type = isProrated ? 'prorated' : 'monthly';
transaction.type = 'monthly';
transaction.services = [];

$.each(transaction.metadata.add_ons, function(k, addOn) {
Expand Down Expand Up @@ -365,12 +365,21 @@ define(function(require){

transaction.amount = parseFloat(transaction.amount).toFixed(2);

// If there are no processor response text, we assume it was approved
transaction.approved = transaction.hasOwnProperty('processor_response_text') ? transaction.processor_response_text === 'Approved' : true,
if(transaction.hasOwnProperty('code')) {
transaction.friendlyName = app.i18n.active().transactions.codes[transaction.code];
}

// If status is missing or among the following list, the transaction is approved
transaction.approved = !transaction.hasOwnProperty('status') || ['authorized','settled','settlement_confirmed'].indexOf(transaction.status) >= 0;

if(!transaction.approved) {
transaction.errorMessage = transaction.status in app.i18n.active().transactions.errorStatuses ? app.i18n.active().transactions.errorStatuses[transaction.status] : transaction.status;
}

// Our API return created but braintree returns created_at
transaction.created = transaction.created_at || transaction.created;

transaction.friendlyCreated = monster.util.toFriendlyDate(transaction.created, 'short');
transaction.friendlyCreated = monster.util.toFriendlyDate(transaction.created, 'MM/DD/year hh:mm:ss');

return transaction;
},
Expand Down

0 comments on commit 13294df

Please sign in to comment.