From 8afc6feba3c27f785e894db525451061e4f8fd84 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Mon, 22 Dec 2014 16:00:34 -0800 Subject: [PATCH 01/80] Add accounts and settlements models --- app/controllers/marketplace.js | 3 +- app/controllers/marketplace/settlements.js | 16 ++++++++ app/models/bk/account.coffee | 8 ++++ app/models/bk/bank-account.coffee | 6 +-- app/models/bk/settlement.coffee | 8 ++++ app/models/customer.js | 7 ++++ app/models/results-loaders/accounts.js | 8 ++++ app/models/results-loaders/settlements.js | 8 ++++ app/router.coffee | 3 ++ app/routes/customer.js | 7 ++++ app/routes/marketplace/settlements.js | 15 +++++++ app/routes/settlement.js | 13 ++++++ app/stores/balanced.coffee | 2 + app/templates/customer.hbs | 5 +++ app/templates/marketplace/settlements.hbs | 9 ++++ .../results/grouped-settlement-row.hbs | 28 +++++++++++++ app/templates/results/settlements-table.hbs | 41 +++++++++++++++++++ .../legacy-results-loader-wrapper.coffee | 28 +++++++++++++ app/views/results/settlements-table.js | 8 ++++ ...nts-transaction-results-dropdown-filter.js | 24 +++++++++++ app/views/sidebar/marketplace-sidebar.js | 23 +++++++---- bower.json | 2 +- 22 files changed, 258 insertions(+), 14 deletions(-) create mode 100644 app/controllers/marketplace/settlements.js create mode 100644 app/models/bk/account.coffee create mode 100644 app/models/bk/settlement.coffee create mode 100644 app/models/results-loaders/accounts.js create mode 100644 app/models/results-loaders/settlements.js create mode 100644 app/routes/marketplace/settlements.js create mode 100644 app/routes/settlement.js create mode 100644 app/templates/marketplace/settlements.hbs create mode 100644 app/templates/results/grouped-settlement-row.hbs create mode 100644 app/templates/results/settlements-table.hbs create mode 100644 app/utils/legacy-results-loader-wrapper.coffee create mode 100644 app/views/results/settlements-table.js create mode 100644 app/views/results/settlements-transaction-results-dropdown-filter.js diff --git a/app/controllers/marketplace.js b/app/controllers/marketplace.js index 5f8083b0b..91e6ee6dc 100644 --- a/app/controllers/marketplace.js +++ b/app/controllers/marketplace.js @@ -27,9 +27,10 @@ var MarketplaceController = Ember.ObjectController.extend({ transactionSelected: isSelected('marketplace.transactions', 'credits', 'debits', 'holds', 'refunds', 'reversals'), orderSelected: isSelected('marketplace.orders', 'orders'), + settlementSelected: isSelected('marketplace.settlements', 'settlement'), + disputeSelected: isSelected('marketplace.disputes', 'dispute'), customerSelected: isSelected('marketplace.customers', 'customer'), fundingInstrumentSelected: isSelected('marketplace.funding_instruments', 'bank_accounts', 'cards'), - disputeSelected: isSelected('marketplace.disputes', 'dispute'), logSelected: isSelected('marketplace.logs', 'log'), invoiceSelected: isSelected('marketplace.invoices', 'invoice'), settingSelected: isSelected('marketplace.settings'), diff --git a/app/controllers/marketplace/settlements.js b/app/controllers/marketplace/settlements.js new file mode 100644 index 000000000..0e82d77ef --- /dev/null +++ b/app/controllers/marketplace/settlements.js @@ -0,0 +1,16 @@ +import Ember from "ember"; + +var MarketplaceSettlementsController = Ember.ObjectController.extend({ + needs: ['marketplace'], + resultsLoader: Ember.computed.oneWay("model"), + actions: { + changeDateFilter: function(startTime, endTime) { + this.get("resultsLoader").setProperties({ + endTime: endTime, + startTime: startTime + }); + }, + } +}); + +export default MarketplaceSettlementsController; diff --git a/app/models/bk/account.coffee b/app/models/bk/account.coffee new file mode 100644 index 000000000..36c12c0d2 --- /dev/null +++ b/app/models/bk/account.coffee @@ -0,0 +1,8 @@ +`import Ember from "ember";` +`import BkAccount from "balanced-addon-models/models/account";` + +Account = BkAccount.extend( + routeName: "account" +) + +`export default Account;` diff --git a/app/models/bk/bank-account.coffee b/app/models/bk/bank-account.coffee index 19188a3c6..bd20b0496 100644 --- a/app/models/bk/bank-account.coffee +++ b/app/models/bk/bank-account.coffee @@ -1,7 +1,7 @@ `import Ember from "ember";` -`import BankAccount from "balanced-addon-models/models/bank-account";` +`import BkBankAccount from "balanced-addon-models/models/bank-account";` -BkBankAccount = BankAccount.extend( +BankAccount = BkBankAccount.extend( ) -`export default BkBankAccount;` +`export default BankAccount;` diff --git a/app/models/bk/settlement.coffee b/app/models/bk/settlement.coffee new file mode 100644 index 000000000..e937db708 --- /dev/null +++ b/app/models/bk/settlement.coffee @@ -0,0 +1,8 @@ +`import Ember from "ember";` +`import BkSettlement from "balanced-addon-models/models/settlement";` + +Settlement = BkSettlement.extend( + routeName: "settlement" +) + +`export default Settlement;` diff --git a/app/models/customer.js b/app/models/customer.js index 2a347ed63..bc4556a45 100644 --- a/app/models/customer.js +++ b/app/models/customer.js @@ -3,6 +3,7 @@ import Model from "./core/model"; import Computed from "balanced-dashboard/utils/computed"; import FundingInstrumentsResultsLoader from "./results-loaders/funding-instruments"; import TransactionsResultsLoader from "./results-loaders/transactions"; +import AccountsResultsLoader from "./results-loaders/accounts"; var CUSTOMER_TYPES = { BUSINESS: 'Business', @@ -73,6 +74,12 @@ var Customer = Model.extend({ }, attributes); return TransactionsResultsLoader.create(attributes); }, + getAccountsLoader: function(attributes) { + attributes = _.extend({ + path: this.get("accounts_uri"), + }, attributes); + return AccountsResultsLoader.create(attributes); + }, type: function() { return (this.get('ein') || this.get('business_name')) ? CUSTOMER_TYPES.BUSINESS : CUSTOMER_TYPES.PERSON; diff --git a/app/models/results-loaders/accounts.js b/app/models/results-loaders/accounts.js new file mode 100644 index 000000000..27c0cfbde --- /dev/null +++ b/app/models/results-loaders/accounts.js @@ -0,0 +1,8 @@ +import BaseResultsLoader from "./base"; +import Account from "../bk/account"; + +var AccountsResultsLoader = BaseResultsLoader.extend({ + resultsType: Account, +}); + +export default AccountsResultsLoader; diff --git a/app/models/results-loaders/settlements.js b/app/models/results-loaders/settlements.js new file mode 100644 index 000000000..98085e166 --- /dev/null +++ b/app/models/results-loaders/settlements.js @@ -0,0 +1,8 @@ +import BaseResultsLoader from "./base"; +import Settlement from "../bk/settlement"; + +var SettlementsResultsLoader = BaseResultsLoader.extend({ + resultsType: Settlement, +}); + +export default SettlementsResultsLoader; diff --git a/app/router.coffee b/app/router.coffee index 24796887c..2c8f5fe07 100644 --- a/app/router.coffee +++ b/app/router.coffee @@ -61,6 +61,9 @@ Router.map -> this.route("customers") this.resource('customer', path: '/customers/:item_id') + this.route("settlements") + this.resource('settlement', path: '/settlements/:item_id') + this.route("disputes") this.resource('dispute', path: '/disputes/:item_id') diff --git a/app/routes/customer.js b/app/routes/customer.js index 38f77a52f..805c95341 100644 --- a/app/routes/customer.js +++ b/app/routes/customer.js @@ -1,5 +1,6 @@ import ModelRoute from "./model"; import Customer from "../models/customer"; +import LegacyResultsLoaderWrapper from "balanced-dashboard/utils/legacy-results-loader-wrapper"; var CustomerRoute = ModelRoute.extend({ title: 'Customer', @@ -8,6 +9,12 @@ var CustomerRoute = ModelRoute.extend({ setupController: function(controller, customer) { this._super(controller, customer); + var store = this.container.lookup("controller:marketplace").get("store"); + store.fetchCollection("account", customer.get("accounts_uri"), { limit: 10 }).then(function(collection) { + var wrapper = LegacyResultsLoaderWrapper.create({collection: collection}); + controller.set("accountsResultsLoader", wrapper); + }); + controller.setProperties({ fundingInstrumentsResultsLoader: customer.getFundingInstrumentsLoader({ limit: 10 diff --git a/app/routes/marketplace/settlements.js b/app/routes/marketplace/settlements.js new file mode 100644 index 000000000..e6f3282b4 --- /dev/null +++ b/app/routes/marketplace/settlements.js @@ -0,0 +1,15 @@ +import AuthRoute from "../auth"; +import LegacyResultsLoaderWrapper from "balanced-dashboard/utils/legacy-results-loader-wrapper"; + +var MarketplaceSettlementsRoute = AuthRoute.extend({ + pageTitle: 'Settlements', + model: function() { + var store = this.container.lookup("controller:marketplace").get("store"); + return store.fetchCollection("settlement", "/settlements", { limit: 50 }).then(function(collection) { + var wrapper = LegacyResultsLoaderWrapper.create({collection: collection}); + return wrapper; + }); + }, +}); + +export default MarketplaceSettlementsRoute; diff --git a/app/routes/settlement.js b/app/routes/settlement.js new file mode 100644 index 000000000..8fce45a16 --- /dev/null +++ b/app/routes/settlement.js @@ -0,0 +1,13 @@ +import ModelRoute from "./model"; +import Settlement from "../models/bk/settlement"; + +var SettlementRoute = ModelRoute.extend({ + title: 'Settlement', + modelObject: Settlement, + marketplaceUri: 'settlements_uri', + setupController: function(controller, customer) { + this._super(controller, customer); + } +}); + +export default SettlementRoute; diff --git a/app/stores/balanced.coffee b/app/stores/balanced.coffee index 8ca9c450a..88460ff12 100644 --- a/app/stores/balanced.coffee +++ b/app/stores/balanced.coffee @@ -4,6 +4,8 @@ BalancedStore = Store.extend( modelMaps: bank_account: "model:bk/bank-account" customer: "model:bk/customer" + account: "model:bk/customer" + settlement: "model:bk/customer" ) `export default BalancedStore;` diff --git a/app/templates/customer.hbs b/app/templates/customer.hbs index 5404e1d15..5e9f845ae 100644 --- a/app/templates/customer.hbs +++ b/app/templates/customer.hbs @@ -35,6 +35,11 @@ {{view "results/embedded-funding-instruments-table" loader=fundingInstrumentsResultsLoader}} +

Accounts

+
+ {{view "results/embedded-funding-instruments-table" loader=accountsResultsLoader}} +
+

Logs

{{view "resource-logs" content=model}} diff --git a/app/templates/marketplace/settlements.hbs b/app/templates/marketplace/settlements.hbs new file mode 100644 index 000000000..cbe4fcda7 --- /dev/null +++ b/app/templates/marketplace/settlements.hbs @@ -0,0 +1,9 @@ +{{view "page-navigations/page-navigation" title="Settlements"}} + + + +
+
+ {{view "results/settlements-table" loader=resultsLoader}} +
+
diff --git a/app/templates/results/grouped-settlement-row.hbs b/app/templates/results/grouped-settlement-row.hbs new file mode 100644 index 000000000..3dbf0e385 --- /dev/null +++ b/app/templates/results/grouped-settlement-row.hbs @@ -0,0 +1,28 @@ + + {{#link-to view.routeName view.item}} + + {{view.displayValue}} + + {{/link-to}} + + + {{#link-to view.routeName view.item}} + + {{view.paymentMethodText}} + + {{/link-to}} + + + {{#link-to view.routeName view.item}} + + {{view.paymentMethodText}} + + {{/link-to}} + + + {{#link-to view.routeName view.item}} + + {{view.amountText}} + + {{/link-to}} + diff --git a/app/templates/results/settlements-table.hbs b/app/templates/results/settlements-table.hbs new file mode 100644 index 000000000..ef525cac8 --- /dev/null +++ b/app/templates/results/settlements-table.hbs @@ -0,0 +1,41 @@ + + + + {{view "results/settlements-transaction-results-dropdown-filter"}} + + Customer + Payment method + + + {{#view "results/results-loader-sort-column-header" resultsLoader=view.loader field="amount" actionName="changeDisputesSort"}} + Amount + {{/view}} + + + + +{{#if view.loader.results.hasNextPage}} + {{view "results/results-load-more" results=view.loader.results columns=view.colspan}} +{{/if}} + + + {{#each dispute in view.loader.results}} + + + {{#view "results/grouped-transactions-table"}} + {{view "results/grouped-settlement-row" item=view.parentView.transaction.dispute}} + {{/view}} + + + {{else}} + + + {{#if view.loader.results.isLoaded}} + No settlements + {{else}} + Loading... + {{/if}} + + + {{/each}} + diff --git a/app/utils/legacy-results-loader-wrapper.coffee b/app/utils/legacy-results-loader-wrapper.coffee new file mode 100644 index 000000000..5e6bb0e23 --- /dev/null +++ b/app/utils/legacy-results-loader-wrapper.coffee @@ -0,0 +1,28 @@ +`import Ember from "ember";` + +LegacyResultsLoaderWrapper = Ember.Object.extend( + results: Ember.computed.reads("collection") + isLoading: Ember.computed.reads("collection.isLoading") + + loadNextPage: -> + @get("collection").loadNextPage() +) + +LegacyResultsLoaderWrapper.reopenClass( + generateMethod: (methodName) -> + return (attributes) -> + LegacyResultsLoaderWrapper.createForCollection(=> + return @[methodName](attributes || {}) + ) + + createForCollection: (initializer) -> + loader = @create(collection: []) + if Ember.isArray(initializer) + loader.set("collection", initializer) + else + initializer().then (collection) -> + loader.set("collection", collection) + loader +) + +`export default LegacyResultsLoaderWrapper;` diff --git a/app/views/results/settlements-table.js b/app/views/results/settlements-table.js new file mode 100644 index 000000000..8bb78ee20 --- /dev/null +++ b/app/views/results/settlements-table.js @@ -0,0 +1,8 @@ +import ResultsTableView from "./results-table"; + +var SettlementsResultsView = ResultsTableView.extend({ + classNames: 'settlements', + templateName: 'results/settlements-table' +}); + +export default SettlementsResultsView; diff --git a/app/views/results/settlements-transaction-results-dropdown-filter.js b/app/views/results/settlements-transaction-results-dropdown-filter.js new file mode 100644 index 000000000..d040c54d2 --- /dev/null +++ b/app/views/results/settlements-transaction-results-dropdown-filter.js @@ -0,0 +1,24 @@ +import ResultsDropdownFilterView from "./results-dropdown-filter"; +import { defineFilter } from "./results-dropdown-filter"; + +var SettlementsTransactionResultsDropdownFilterView = ResultsDropdownFilterView.extend({ + toggleText: "Status", + filters: function() { + return [ + defineFilter("All", null, true), + defineFilter("Needs attention & Under review", ["pending"]), + defineFilter("Won", ["won"]), + defineFilter("Lost", ["lost"]) + ]; + }.property(), + + actions: { + setFilter: function(filterLink) { + var controller = this.get('controller'); + controller.send('changeDisputeStatusFilter', filterLink.value); + this.toggleSelected(filterLink); + } + } +}); + +export default SettlementsTransactionResultsDropdownFilterView; diff --git a/app/views/sidebar/marketplace-sidebar.js b/app/views/sidebar/marketplace-sidebar.js index 0d78e061f..1b30b7164 100644 --- a/app/views/sidebar/marketplace-sidebar.js +++ b/app/views/sidebar/marketplace-sidebar.js @@ -6,15 +6,10 @@ var SIDEBAR_ITEMS = [{ routeName: "marketplace.orders", isSelectedBinding: "controller.controllers.marketplace.paymentSelected", }, { - linkText: "Customers", - linkIcon: "icon-customers", - routeName: "marketplace.customers", - isSelectedBinding: "controller.controllers.marketplace.customerSelected" -}, { - linkText: "Payment methods", - linkIcon: "icon-card", - routeName: "marketplace.funding_instruments", - isSelectedBinding: "controller.controllers.marketplace.fundingInstrumentSelected" + linkText: "Settlements", + linkIcon: "icon-settlements", + routeName: "marketplace.settlements", + isSelectedBinding: "controller.controllers.marketplace.settlementSelected", }, { linkText: "Disputes", linkIcon: "icon-disputes", @@ -26,6 +21,16 @@ var SIDEBAR_ITEMS = [{ linkIcon: "icon-logs", routeName: "marketplace.logs", isSelectedBinding: "controller.controllers.marketplace.logSelected" +}, { + linkText: "Customers", + linkIcon: "icon-customers", + routeName: "marketplace.customers", + isSelectedBinding: "controller.controllers.marketplace.customerSelected" +}, { + linkText: "Payment methods", + linkIcon: "icon-card", + routeName: "marketplace.funding_instruments", + isSelectedBinding: "controller.controllers.marketplace.fundingInstrumentSelected" }, { linkText: "Account statements", linkIcon: "icon-invoices", diff --git a/bower.json b/bower.json index 543994980..bbf8b07df 100644 --- a/bower.json +++ b/bower.json @@ -13,7 +13,7 @@ "ember-validations": "lcoq/ember-validations", "google-code-prettify": "1.0.0", "handlebars": "~1.3.0", - "strapped": "0.3.14", + "strapped": "0.3.15", "jquery-csv": "", "jquery-hotkeys": "jeresig/jquery.hotkeys", "jquery.cookie": "1.3.1", From a93e510f3da8c49420345a37bbb9b57e225d5df5 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Tue, 23 Dec 2014 16:36:13 -0800 Subject: [PATCH 02/80] Add payable account page --- app/controllers/marketplace.js | 2 +- .../legacy-routes-initializer.coffee | 4 -- app/models/bk/account.coffee | 9 +++- app/models/bk/customer.coffee | 3 +- app/models/bk/settlement.coffee | 3 +- app/models/customer.js | 7 ---- app/models/settlement.js | 10 ----- app/router.coffee | 3 +- app/routes/account.coffee | 27 ++++++++++++ app/routes/customer.js | 2 +- app/routes/model.js | 4 ++ app/routes/settlement.coffee | 19 +++++++++ app/routes/settlement.js | 13 ------ app/stores/balanced.coffee | 4 +- app/styles/results.less | 5 +++ app/templates/account.hbs | 29 +++++++++++++ app/templates/accounts.hbs | 1 - app/templates/customer.hbs | 6 +-- .../embedded-internal-accounts-table.hbs | 42 +++++++++++++++++++ .../account-titled-key-values-section.js | 13 ++++++ .../account-summary-section.js | 10 +++++ .../embedded-internal-accounts-table.js | 7 ++++ 22 files changed, 177 insertions(+), 46 deletions(-) delete mode 100644 app/models/settlement.js create mode 100644 app/routes/account.coffee create mode 100644 app/routes/settlement.coffee delete mode 100644 app/routes/settlement.js create mode 100644 app/templates/account.hbs delete mode 100644 app/templates/accounts.hbs create mode 100644 app/templates/results/embedded-internal-accounts-table.hbs create mode 100644 app/views/detail-views/description-lists/account-titled-key-values-section.js create mode 100644 app/views/detail-views/summary-sections/account-summary-section.js create mode 100644 app/views/results/embedded-internal-accounts-table.js diff --git a/app/controllers/marketplace.js b/app/controllers/marketplace.js index 91e6ee6dc..d33646631 100644 --- a/app/controllers/marketplace.js +++ b/app/controllers/marketplace.js @@ -30,7 +30,7 @@ var MarketplaceController = Ember.ObjectController.extend({ settlementSelected: isSelected('marketplace.settlements', 'settlement'), disputeSelected: isSelected('marketplace.disputes', 'dispute'), customerSelected: isSelected('marketplace.customers', 'customer'), - fundingInstrumentSelected: isSelected('marketplace.funding_instruments', 'bank_accounts', 'cards'), + fundingInstrumentSelected: isSelected('marketplace.funding_instruments', 'bank_accounts', 'cards', 'accounts'), logSelected: isSelected('marketplace.logs', 'log'), invoiceSelected: isSelected('marketplace.invoices', 'invoice'), settingSelected: isSelected('marketplace.settings'), diff --git a/app/initializers/legacy-routes-initializer.coffee b/app/initializers/legacy-routes-initializer.coffee index 8db7d59e2..67b0129f8 100644 --- a/app/initializers/legacy-routes-initializer.coffee +++ b/app/initializers/legacy-routes-initializer.coffee @@ -7,10 +7,6 @@ LegacyRoutesInitializer = klass = createRedirectRoute(createArgs...) container.register("route:#{name}", klass) - defineRoute("account", "customer", "account") - defineRoute("accounts", "marketplace.customer") - defineRoute("accounts.index", 'marketplace.customers', "accounts") - defineRoute("bank-account.index", 'activity.funding_instruments') defineRoute("cards.index", "activity.funding_instruments") diff --git a/app/models/bk/account.coffee b/app/models/bk/account.coffee index 36c12c0d2..95393eb0c 100644 --- a/app/models/bk/account.coffee +++ b/app/models/bk/account.coffee @@ -1,8 +1,15 @@ `import Ember from "ember";` `import BkAccount from "balanced-addon-models/models/account";` +`import Computed from "balanced-dashboard/utils/computed";` Account = BkAccount.extend( - routeName: "account" + routeName: "account", + isPayableAccount: Ember.computed.equal("type", "payable"), + type_name: (-> + type = @get("type").capitalize() + "%@ account".fmt(type) + ).property("type"), + title_description: Ember.computed.reads("customer.display_me") ) `export default Account;` diff --git a/app/models/bk/customer.coffee b/app/models/bk/customer.coffee index 355b44f48..13415d0e7 100644 --- a/app/models/bk/customer.coffee +++ b/app/models/bk/customer.coffee @@ -2,7 +2,8 @@ `import BkCustomer from "balanced-addon-models/models/customer";` Customer = BkCustomer.extend( - routeName: "customer" + routeName: "customer", + display_me: "XXXX" ) `export default Customer;` diff --git a/app/models/bk/settlement.coffee b/app/models/bk/settlement.coffee index e937db708..bba8e1833 100644 --- a/app/models/bk/settlement.coffee +++ b/app/models/bk/settlement.coffee @@ -2,7 +2,8 @@ `import BkSettlement from "balanced-addon-models/models/settlement";` Settlement = BkSettlement.extend( - routeName: "settlement" + routeName: "settlement", + type_name: "settlement" ) `export default Settlement;` diff --git a/app/models/customer.js b/app/models/customer.js index bc4556a45..2a347ed63 100644 --- a/app/models/customer.js +++ b/app/models/customer.js @@ -3,7 +3,6 @@ import Model from "./core/model"; import Computed from "balanced-dashboard/utils/computed"; import FundingInstrumentsResultsLoader from "./results-loaders/funding-instruments"; import TransactionsResultsLoader from "./results-loaders/transactions"; -import AccountsResultsLoader from "./results-loaders/accounts"; var CUSTOMER_TYPES = { BUSINESS: 'Business', @@ -74,12 +73,6 @@ var Customer = Model.extend({ }, attributes); return TransactionsResultsLoader.create(attributes); }, - getAccountsLoader: function(attributes) { - attributes = _.extend({ - path: this.get("accounts_uri"), - }, attributes); - return AccountsResultsLoader.create(attributes); - }, type: function() { return (this.get('ein') || this.get('business_name')) ? CUSTOMER_TYPES.BUSINESS : CUSTOMER_TYPES.PERSON; diff --git a/app/models/settlement.js b/app/models/settlement.js deleted file mode 100644 index ce8e49a63..000000000 --- a/app/models/settlement.js +++ /dev/null @@ -1,10 +0,0 @@ -import Transaction from "./transaction"; -import Model from "./core/model"; - -var Settlement = Transaction.extend({ - debit: Model.belongsTo('debit', 'debit'), - type_name: 'settlement', - route_name: 'Settlement' -}); - -export default Settlement; diff --git a/app/router.coffee b/app/router.coffee index 2c8f5fe07..6c890272a 100644 --- a/app/router.coffee +++ b/app/router.coffee @@ -47,7 +47,6 @@ Router.map -> this.route('import_payouts') # exists to handle old URIs - this.resource('accounts', path: '/accounts/:item_id') this.route("redirect_activity_transactions", path: '/activity/transactions') this.route("redirect_activity_orders", path: '/activity/orders') this.route("redirect_activity_customers", path: 'activity/customers') @@ -55,6 +54,8 @@ Router.map -> this.route("redirect_activity_disputes", path: 'activity/disputes') this.route("redirect_invoices", path: 'invoices') + this.resource('account', path: '/accounts/:item_id') + this.route("orders") this.resource('orders', path: '/orders/:item_id') diff --git a/app/routes/account.coffee b/app/routes/account.coffee new file mode 100644 index 000000000..235486850 --- /dev/null +++ b/app/routes/account.coffee @@ -0,0 +1,27 @@ +`import ModelRoute from "./model"` +`import LegacyResultsLoaderWrapper from "balanced-dashboard/utils/legacy-results-loader-wrapper";` + +AccountRoute = ModelRoute.extend( + model: (params) -> + store = @getStore() + store.fetchItem("account", "/accounts/#{params.item_id}") + + setupController: (controller, model) -> + @_super(controller, model) + + this.get("container").lookupFactory("model:customer").find(model.get("customer_uri")).then (customer) -> + model.set("customer", customer) + + creditsResultsLoader = this.get("container").lookupFactory("results-loader:transactions").create({ + path: model.get("credits_uri") + }); + + settlementsResultsLoader = this.get("container").lookupFactory("results-loader:transactions").create({ + path: model.get("settlements_uri") + }); + + controller.set("creditsResultsLoader", creditsResultsLoader); + controller.set("settlementsResultsLoader", settlementsResultsLoader); +) + +`export default AccountRoute` diff --git a/app/routes/customer.js b/app/routes/customer.js index 805c95341..76b79487e 100644 --- a/app/routes/customer.js +++ b/app/routes/customer.js @@ -9,7 +9,7 @@ var CustomerRoute = ModelRoute.extend({ setupController: function(controller, customer) { this._super(controller, customer); - var store = this.container.lookup("controller:marketplace").get("store"); + var store = this.getStore(); store.fetchCollection("account", customer.get("accounts_uri"), { limit: 10 }).then(function(collection) { var wrapper = LegacyResultsLoaderWrapper.create({collection: collection}); controller.set("accountsResultsLoader", wrapper); diff --git a/app/routes/model.js b/app/routes/model.js index a98b1a410..8652636cf 100644 --- a/app/routes/model.js +++ b/app/routes/model.js @@ -2,6 +2,10 @@ import TitleRoute from "./title"; import Utils from "balanced-dashboard/lib/utils"; var ModelRoute = TitleRoute.extend({ + getStore: function() { + return this.get("container").lookup("controller:marketplace").get("store"); + }, + model: function(params) { var marketplace = this.modelFor('marketplace'); var modelObject = this.get('modelObject'); diff --git a/app/routes/settlement.coffee b/app/routes/settlement.coffee new file mode 100644 index 000000000..dad1c6b00 --- /dev/null +++ b/app/routes/settlement.coffee @@ -0,0 +1,19 @@ +`import ModelRoute from "./model";` +`import Settlement from "../models/bk/settlement";` + +SettlementRoute = ModelRoute.extend( + model: (params) -> + store = @getStore() + store.fetchItem("settlement", "/settlements/#{params.item_id}") + + setupController: (controller, model) -> + @_super(controller, model) + + creditsResultsLoader = this.get("container").lookupFactory("results-loader:transactions").create({ + path: model.get("credits_uri") + }); + + controller.set("creditsResultsLoader", creditsResultsLoader); +) + +`export default SettlementRoute;` diff --git a/app/routes/settlement.js b/app/routes/settlement.js deleted file mode 100644 index 8fce45a16..000000000 --- a/app/routes/settlement.js +++ /dev/null @@ -1,13 +0,0 @@ -import ModelRoute from "./model"; -import Settlement from "../models/bk/settlement"; - -var SettlementRoute = ModelRoute.extend({ - title: 'Settlement', - modelObject: Settlement, - marketplaceUri: 'settlements_uri', - setupController: function(controller, customer) { - this._super(controller, customer); - } -}); - -export default SettlementRoute; diff --git a/app/stores/balanced.coffee b/app/stores/balanced.coffee index 88460ff12..52131282e 100644 --- a/app/stores/balanced.coffee +++ b/app/stores/balanced.coffee @@ -4,8 +4,8 @@ BalancedStore = Store.extend( modelMaps: bank_account: "model:bk/bank-account" customer: "model:bk/customer" - account: "model:bk/customer" - settlement: "model:bk/customer" + account: "model:bk/account" + settlement: "model:bk/settlement" ) `export default BalancedStore;` diff --git a/app/styles/results.less b/app/styles/results.less index 06499d479..20a4d34f8 100644 --- a/app/styles/results.less +++ b/app/styles/results.less @@ -116,6 +116,11 @@ header.results-label h3 { } } + i.non-interactive { + color: @black; + margin-right: 5px; + } + td.unlinked-status { i.icon-unlinked { color: @imperialRed60; diff --git a/app/templates/account.hbs b/app/templates/account.hbs new file mode 100644 index 000000000..3d1b1f69a --- /dev/null +++ b/app/templates/account.hbs @@ -0,0 +1,29 @@ +{{view "page-navigations/page-navigation" pageType=model.type_name title=model.title_description}} + +{{#view "detail-views/body-panel"}} + {{#view "detail-views/api-model-panel" model=model}} + {{view detail-views/summary-sections/account-summary-section model=model}} + {{view detail-views/description-lists/account-titled-key-values-section model=model}} + {{view "meta-list" type=model}} + {{/view}} + + {{#view "detail-views/main-panel"}} +

Unsettled transactions

+
+ {{view "results/embedded-transactions-table" loader=creditsResultsLoader}} +
+

Settled transactions

+
+ {{view "results/embedded-transactions-table" loader=settlementsResultsLoader}} +
+

Logs

+
+ {{view "resource-logs" content=model}} +
+ +

Events

+
+ {{view "resource-events" content=model}} +
+ {{/view}} +{{/view}} diff --git a/app/templates/accounts.hbs b/app/templates/accounts.hbs deleted file mode 100644 index c24cd6895..000000000 --- a/app/templates/accounts.hbs +++ /dev/null @@ -1 +0,0 @@ -{{outlet}} diff --git a/app/templates/customer.hbs b/app/templates/customer.hbs index 5e9f845ae..a2694989f 100644 --- a/app/templates/customer.hbs +++ b/app/templates/customer.hbs @@ -30,14 +30,14 @@ Add a card
-

Payment methods

+

Cards & Bank accounts

{{view "results/embedded-funding-instruments-table" loader=fundingInstrumentsResultsLoader}}
-

Accounts

+

Internal accounts

- {{view "results/embedded-funding-instruments-table" loader=accountsResultsLoader}} + {{view "results/embedded-internal-accounts-table" loader=accountsResultsLoader}}

Logs

diff --git a/app/templates/results/embedded-internal-accounts-table.hbs b/app/templates/results/embedded-internal-accounts-table.hbs new file mode 100644 index 000000000..06a14814d --- /dev/null +++ b/app/templates/results/embedded-internal-accounts-table.hbs @@ -0,0 +1,42 @@ + + + + {{view "results/payment-methods-results-dropdown-filter" model=view.loader}} + + Balance + + + +{{#if view.loader.results.hasNextPage}} + {{view "results/results-load-more" results=view.loader.results columns=5}} +{{/if}} + + + {{#each account in view.loader.results}} + + + {{#link-to account.routeName account}} + + + {{sentence-case account.type}} account + + {{/link-to}} + + + {{#link-to account.routeName account}} + {{format-currency account.balance}} + {{/link-to}} + + + {{else}} + + + {{#if view.loader.results.isLoaded}} + No internal accounts + {{else}} + Loading... + {{/if}} + + + {{/each}} + diff --git a/app/views/detail-views/description-lists/account-titled-key-values-section.js b/app/views/detail-views/description-lists/account-titled-key-values-section.js new file mode 100644 index 000000000..7d8a8d8e9 --- /dev/null +++ b/app/views/detail-views/description-lists/account-titled-key-values-section.js @@ -0,0 +1,13 @@ +import TitledKeyValuesSectionView from "./titled-key-values-section"; +import ListValueGenerator from "./list-value-generator"; + +var AccountTitledKeyValuesSectionView = TitledKeyValuesSectionView.extend({ + title: "Account information", + + keyValueListViews: ListValueGenerator.create() + .add("Created at", "created_at") + .add("Account ID", "id") + .toProperty() +}); + +export default AccountTitledKeyValuesSectionView; diff --git a/app/views/detail-views/summary-sections/account-summary-section.js b/app/views/detail-views/summary-sections/account-summary-section.js new file mode 100644 index 000000000..2b4d08d61 --- /dev/null +++ b/app/views/detail-views/summary-sections/account-summary-section.js @@ -0,0 +1,10 @@ +import SummarySectionView from "./summary-section"; +import Utils from "balanced-dashboard/lib/utils"; + +var AccountSummarySectionView = SummarySectionView.extend({ + linkedResources: function() { + return this.resourceLinks("model.balance", "model.customer"); + }.property('model.balance', 'model.customer'), +}); + +export default AccountSummarySectionView; diff --git a/app/views/results/embedded-internal-accounts-table.js b/app/views/results/embedded-internal-accounts-table.js new file mode 100644 index 000000000..b19fa5c1c --- /dev/null +++ b/app/views/results/embedded-internal-accounts-table.js @@ -0,0 +1,7 @@ +import ResultsTableView from "./results-table"; + +var EmbeddedInternalAccountsTable = ResultsTableView.extend({ + templateName: 'results/embedded-internal-accounts-table' +}); + +export default EmbeddedInternalAccountsTable; From d75b7153cfccc360f9ba7e30c17cf051235fd479 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Fri, 26 Dec 2014 09:43:32 -0800 Subject: [PATCH 03/80] Upadte settlement summary section --- app/models/bk/settlement.coffee | 7 ++++++- app/routes/settlement.coffee | 6 ++++++ app/templates/results/settlements-table.hbs | 4 ++-- .../detail-views/summary-sections/summary-section.js | 9 ++++++++- app/views/results/grouped-transaction-row.js | 6 +++--- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/app/models/bk/settlement.coffee b/app/models/bk/settlement.coffee index bba8e1833..d083f7b70 100644 --- a/app/models/bk/settlement.coffee +++ b/app/models/bk/settlement.coffee @@ -1,9 +1,14 @@ `import Ember from "ember";` +`import Utils from "balanced-dashboard/lib/utils";` `import BkSettlement from "balanced-addon-models/models/settlement";` Settlement = BkSettlement.extend( routeName: "settlement", - type_name: "settlement" + route_name: "settlement", + type_name: "Settlement", + amountInDollars: (-> + "$%@".fmt(Utils.centsToDollars(@get("amount"))) + ).property("amount") ) `export default Settlement;` diff --git a/app/routes/settlement.coffee b/app/routes/settlement.coffee index dad1c6b00..b8ff92069 100644 --- a/app/routes/settlement.coffee +++ b/app/routes/settlement.coffee @@ -9,6 +9,12 @@ SettlementRoute = ModelRoute.extend( setupController: (controller, model) -> @_super(controller, model) + # this.get("container").lookupFactory("model:bk/account").find(model.get("source_uri")).then (source) -> + # model.set("source", source) + + this.get("container").lookupFactory("model:bank_account").find(model.get("destination_uri")).then (destination) -> + model.set("destination", destination) + creditsResultsLoader = this.get("container").lookupFactory("results-loader:transactions").create({ path: model.get("credits_uri") }); diff --git a/app/templates/results/settlements-table.hbs b/app/templates/results/settlements-table.hbs index ef525cac8..ec2a575c5 100644 --- a/app/templates/results/settlements-table.hbs +++ b/app/templates/results/settlements-table.hbs @@ -19,11 +19,11 @@ {{/if}} - {{#each dispute in view.loader.results}} + {{#each settlement in view.loader.results}} {{#view "results/grouped-transactions-table"}} - {{view "results/grouped-settlement-row" item=view.parentView.transaction.dispute}} + {{view "results/grouped-settlement-row" item=settlement}} {{/view}} diff --git a/app/views/detail-views/summary-sections/summary-section.js b/app/views/detail-views/summary-sections/summary-section.js index 0ae80ca47..dba52f74e 100644 --- a/app/views/detail-views/summary-sections/summary-section.js +++ b/app/views/detail-views/summary-sections/summary-section.js @@ -50,6 +50,7 @@ var SummarySectionView = Ember.View.extend({ }, generateResourceLink: function(parentModel, model) { + var Account = this.get("container").lookupFactory("model:bk/account"); var BankAccount = this.get("container").lookupFactory("model:bank-account"); var Card = this.get("container").lookupFactory("model:card"); var Credit = this.get("container").lookupFactory("model:credit"); @@ -149,9 +150,15 @@ var SummarySectionView = Ember.View.extend({ } if (model.constructor === BankAccount) { + title = model.get('type_name').split(' ')[0]; + + if (parentModel.routeName === 'account') { + title = "To"; + } + return { className: 'icon-bank-account', - title: model.get('type_name').split(' ')[0], + title: title, resource: model, }; } diff --git a/app/views/results/grouped-transaction-row.js b/app/views/results/grouped-transaction-row.js index ae0bf4162..5ff526c59 100644 --- a/app/views/results/grouped-transaction-row.js +++ b/app/views/results/grouped-transaction-row.js @@ -3,9 +3,9 @@ import Computed from "balanced-dashboard/utils/computed"; import LinkedTwoLinesCellView from "../tables/cells/linked-two-lines-cell"; import Utils from "balanced-dashboard/lib/utils"; -var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ +var GroupedSettlementRowView = LinkedTwoLinesCellView.extend({ tagName: 'tr', - templateName: 'results/grouped-transaction-row', + templateName: 'results/grouped-settlement-row', routeName: Ember.computed.oneWay("item.route_name"), spanClassNames: Ember.computed.oneWay("item.status"), @@ -64,4 +64,4 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ }.property("item.amount") }); -export default GroupedTransactionRowView; +export default GroupedSettlementRowView; From bfa55b05ee42359fac35e22f1c88755740c3f76d Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Fri, 26 Dec 2014 17:26:05 -0800 Subject: [PATCH 04/80] Rename files --- app/views/results/grouped-settlement-row.js | 67 ++++++++++++++++++++ app/views/results/grouped-transaction-row.js | 6 +- 2 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 app/views/results/grouped-settlement-row.js diff --git a/app/views/results/grouped-settlement-row.js b/app/views/results/grouped-settlement-row.js new file mode 100644 index 000000000..5ff526c59 --- /dev/null +++ b/app/views/results/grouped-settlement-row.js @@ -0,0 +1,67 @@ +import Ember from "ember"; +import Computed from "balanced-dashboard/utils/computed"; +import LinkedTwoLinesCellView from "../tables/cells/linked-two-lines-cell"; +import Utils from "balanced-dashboard/lib/utils"; + +var GroupedSettlementRowView = LinkedTwoLinesCellView.extend({ + tagName: 'tr', + templateName: 'results/grouped-settlement-row', + routeName: Ember.computed.oneWay("item.route_name"), + spanClassNames: Ember.computed.oneWay("item.status"), + + title: function() { + var description = this.get("item.description"); + + if (description) { + return description; + } + if (_.contains(this.get("classNames"), "current")) { + return 'You are currently viewing this transaction.'; + } + return '(Created at %@)'.fmt(this.get("secondaryLabelText")); + }.property("item.description", "primaryLabelText", "secondaryLabelText"), + + primaryLabelText: function() { + if (_.contains(this.get("classNames"), "current")) { + return '%@ (currently viewing)'.fmt(this.get('item.type_name')); + } + var transactionText; + var description = this.get('item.description'); + var status = Utils.capitalize(this.get('item.status')); + + if (status) { + status = status.toLowerCase(); + } + + if (description) { + transactionText = '%@ (%@) %@'.fmt(this.get('item.type_name'), description, status); + } else { + transactionText = '%@ %@'.fmt(this.get('item.type_name'), status); + } + + if (this.get('item.type_name') === 'Dispute') { + transactionText = '%@ %@'.fmt(this.get('item.type_name'), status); + } + + return Utils.safeFormat(transactionText).htmlSafe(); + }.property('classNames', 'item.type_name', 'item.status', 'item.description'), + + secondaryLabelText: function () { + return Utils.humanReadableDateTime(this.get('item.created_at')); + }.property('item.created_at'), + + paymentMethodText: function() { + var label = '%@%@'; + var secondaryLabel = this.get('paymentMethodSecondaryLabelText') || ''; + return Utils.safeFormat(label, this.get('paymentMethodPrimaryLabelText'), secondaryLabel).htmlSafe(); + }.property('paymentMethodPrimaryLabelText', 'paymentMethodSecondaryLabelText'), + + paymentMethodPrimaryLabelText: Computed.fmt('item.last_four', 'item.brand', '%@ %@'), + paymentMethodSecondaryLabelText: Ember.computed.reads('item.funding_instrument_type'), + + amountText: function() { + return Utils.formatCurrency(this.get("item.amount")); + }.property("item.amount") +}); + +export default GroupedSettlementRowView; diff --git a/app/views/results/grouped-transaction-row.js b/app/views/results/grouped-transaction-row.js index 5ff526c59..ae0bf4162 100644 --- a/app/views/results/grouped-transaction-row.js +++ b/app/views/results/grouped-transaction-row.js @@ -3,9 +3,9 @@ import Computed from "balanced-dashboard/utils/computed"; import LinkedTwoLinesCellView from "../tables/cells/linked-two-lines-cell"; import Utils from "balanced-dashboard/lib/utils"; -var GroupedSettlementRowView = LinkedTwoLinesCellView.extend({ +var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ tagName: 'tr', - templateName: 'results/grouped-settlement-row', + templateName: 'results/grouped-transaction-row', routeName: Ember.computed.oneWay("item.route_name"), spanClassNames: Ember.computed.oneWay("item.status"), @@ -64,4 +64,4 @@ var GroupedSettlementRowView = LinkedTwoLinesCellView.extend({ }.property("item.amount") }); -export default GroupedSettlementRowView; +export default GroupedTransactionRowView; From 9f05f99251cdc8b7e34be86e7bd3f03f07226096 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Mon, 29 Dec 2014 10:22:56 -0800 Subject: [PATCH 05/80] Display settlement table --- app/models/bk/account.coffee | 2 +- app/models/bk/customer.coffee | 1 - app/models/bk/settlement.coffee | 1 - app/routes/settlement.coffee | 5 ++-- .../detail-views/resource-summary.hbs | 13 +++++++--- .../results/grouped-settlement-row.hbs | 8 +++--- app/templates/settlement.hbs | 25 +++++++++++++++++++ .../resource-summary-base.coffee | 3 +++ .../settlement-summary-section.js | 10 ++++++++ .../summary-sections/summary-section.js | 21 ++++++++++++---- app/views/results/grouped-settlement-row.js | 18 +++++++++---- 11 files changed, 85 insertions(+), 22 deletions(-) create mode 100644 app/templates/settlement.hbs create mode 100644 app/views/detail-views/summary-sections/settlement-summary-section.js diff --git a/app/models/bk/account.coffee b/app/models/bk/account.coffee index 95393eb0c..94de00236 100644 --- a/app/models/bk/account.coffee +++ b/app/models/bk/account.coffee @@ -9,7 +9,7 @@ Account = BkAccount.extend( type = @get("type").capitalize() "%@ account".fmt(type) ).property("type"), - title_description: Ember.computed.reads("customer.display_me") + title_description: Ember.computed.reads("customer.display_me"), ) `export default Account;` diff --git a/app/models/bk/customer.coffee b/app/models/bk/customer.coffee index 13415d0e7..0bdffe6d7 100644 --- a/app/models/bk/customer.coffee +++ b/app/models/bk/customer.coffee @@ -3,7 +3,6 @@ Customer = BkCustomer.extend( routeName: "customer", - display_me: "XXXX" ) `export default Customer;` diff --git a/app/models/bk/settlement.coffee b/app/models/bk/settlement.coffee index d083f7b70..233e978fa 100644 --- a/app/models/bk/settlement.coffee +++ b/app/models/bk/settlement.coffee @@ -4,7 +4,6 @@ Settlement = BkSettlement.extend( routeName: "settlement", - route_name: "settlement", type_name: "Settlement", amountInDollars: (-> "$%@".fmt(Utils.centsToDollars(@get("amount"))) diff --git a/app/routes/settlement.coffee b/app/routes/settlement.coffee index b8ff92069..c33641c46 100644 --- a/app/routes/settlement.coffee +++ b/app/routes/settlement.coffee @@ -9,8 +9,9 @@ SettlementRoute = ModelRoute.extend( setupController: (controller, model) -> @_super(controller, model) - # this.get("container").lookupFactory("model:bk/account").find(model.get("source_uri")).then (source) -> - # model.set("source", source) + store = @getStore() + store.fetchItem("account", model.get("source_uri")).then (source) -> + model.set("source", source) this.get("container").lookupFactory("model:bank_account").find(model.get("destination_uri")).then (destination) -> model.set("destination", destination) diff --git a/app/templates/detail-views/resource-summary.hbs b/app/templates/detail-views/resource-summary.hbs index 053e7c8ee..0117760d0 100644 --- a/app/templates/detail-views/resource-summary.hbs +++ b/app/templates/detail-views/resource-summary.hbs @@ -6,9 +6,16 @@ {{/if}} {{else}} {{#if view.model}} - {{#link-to view.model.route_name view.model title=view.hoverValue}} - {{view.value}} - {{/link-to}} + {{#if view.model.route_name}} + {{#link-to view.model.route_name view.model title=view.hoverValue}} + {{view.value}} + {{/link-to}} + {{/if}} + {{#if view.model.routeName}} + {{#link-to view.model.routeName view.model title=view.hoverValue}} + {{view.value}} + {{/link-to}} + {{/if}} {{else}} none {{/if}} diff --git a/app/templates/results/grouped-settlement-row.hbs b/app/templates/results/grouped-settlement-row.hbs index 3dbf0e385..eddf51437 100644 --- a/app/templates/results/grouped-settlement-row.hbs +++ b/app/templates/results/grouped-settlement-row.hbs @@ -1,26 +1,26 @@ - {{#link-to view.routeName view.item}} + {{#link-to view.item.routeName view.item}} {{view.displayValue}} {{/link-to}} - {{#link-to view.routeName view.item}} + {{#link-to view.item.routeName view.item}} {{view.paymentMethodText}} {{/link-to}} - {{#link-to view.routeName view.item}} + {{#link-to view.item.routeName view.item}} {{view.paymentMethodText}} {{/link-to}} - {{#link-to view.routeName view.item}} + {{#link-to view.item.routeName view.item}} {{view.amountText}} diff --git a/app/templates/settlement.hbs b/app/templates/settlement.hbs new file mode 100644 index 000000000..c55a866c8 --- /dev/null +++ b/app/templates/settlement.hbs @@ -0,0 +1,25 @@ +{{view "page-navigations/page-navigation" pageType=model.type_name title=model.amountInDollars}} + +{{#view "detail-views/body-panel"}} + {{#view "detail-views/api-model-panel" model=model}} + {{view detail-views/summary-sections/settlement-summary-section model=model}} + {{view detail-views/description-lists/transaction-titled-key-values-section model=model}} + {{view "meta-list" type=model}} + {{/view}} + + {{#view "detail-views/main-panel"}} +

Related activity

+
+ {{view "results/embedded-transactions-table" loader=creditsResultsLoader}} +
+

Logs

+
+ {{view "resource-logs" content=model}} +
+ +

Events

+
+ {{view "resource-events" content=model}} +
+ {{/view}} +{{/view}} diff --git a/app/views/detail-views/resource-summaries/resource-summary-base.coffee b/app/views/detail-views/resource-summaries/resource-summary-base.coffee index 6f89cf991..1d2069b17 100644 --- a/app/views/detail-views/resource-summaries/resource-summary-base.coffee +++ b/app/views/detail-views/resource-summaries/resource-summary-base.coffee @@ -16,9 +16,12 @@ ResourceSummaryBase = Ember.View.extend( else if @isType("customer") model.get("display_me") else if @isType("card") + console.log(model) "#{model.get('last_four')} #{model.get('brand')}" else if @isType("bank-account") "#{model.get('last_four')} #{model.get('formatted_bank_name')}" + else if @isType("bk/account") + "Customer balance" else null ).property("model.amount_escrowed", "model.amount", "model.display_me", "model.last_four", "model.brand", "model.formatted_bank_name") diff --git a/app/views/detail-views/summary-sections/settlement-summary-section.js b/app/views/detail-views/summary-sections/settlement-summary-section.js new file mode 100644 index 000000000..6df136943 --- /dev/null +++ b/app/views/detail-views/summary-sections/settlement-summary-section.js @@ -0,0 +1,10 @@ +import SummarySectionView from "./summary-section"; +import Utils from "balanced-dashboard/lib/utils"; + +var SettlementSummarySectionView = SummarySectionView.extend({ + linkedResources: function() { + return this.resourceLinks("model.description", "model.source", "model.destination", "model.customer"); + }.property("model.description", "model.source", "model.destination", "model.customer"), +}); + +export default SettlementSummarySectionView; diff --git a/app/views/detail-views/summary-sections/summary-section.js b/app/views/detail-views/summary-sections/summary-section.js index dba52f74e..9c7e7bd9a 100644 --- a/app/views/detail-views/summary-sections/summary-section.js +++ b/app/views/detail-views/summary-sections/summary-section.js @@ -50,7 +50,6 @@ var SummarySectionView = Ember.View.extend({ }, generateResourceLink: function(parentModel, model) { - var Account = this.get("container").lookupFactory("model:bk/account"); var BankAccount = this.get("container").lookupFactory("model:bank-account"); var Card = this.get("container").lookupFactory("model:card"); var Credit = this.get("container").lookupFactory("model:credit"); @@ -149,19 +148,31 @@ var SummarySectionView = Ember.View.extend({ }; } - if (model.constructor === BankAccount) { - title = model.get('type_name').split(' ')[0]; + if (parentModel.routeName === 'settlement') { + var title = ""; + var className = ""; - if (parentModel.routeName === 'account') { + if (model.routeName === 'account') { + title = "From"; + } else if (model.route_name === 'bank_accounts') { title = "To"; + className = "icon-bank-account"; } return { - className: 'icon-bank-account', + className: className, title: title, resource: model, }; } + + if (model.constructor === BankAccount) { + return { + className: 'icon-bank-account', + title: model.get('type_name').split(' ')[0], + resource: model, + }; + } } }); diff --git a/app/views/results/grouped-settlement-row.js b/app/views/results/grouped-settlement-row.js index 5ff526c59..725a6bf11 100644 --- a/app/views/results/grouped-settlement-row.js +++ b/app/views/results/grouped-settlement-row.js @@ -51,13 +51,21 @@ var GroupedSettlementRowView = LinkedTwoLinesCellView.extend({ }.property('item.created_at'), paymentMethodText: function() { + var bankAccount = this.get('bankAccount'); var label = '%@%@'; - var secondaryLabel = this.get('paymentMethodSecondaryLabelText') || ''; - return Utils.safeFormat(label, this.get('paymentMethodPrimaryLabelText'), secondaryLabel).htmlSafe(); - }.property('paymentMethodPrimaryLabelText', 'paymentMethodSecondaryLabelText'), + console.log(bankAccount) + var primaryLabel = "%@ %@".fmt(bankAccount.get("last_four"), bankAccount.get("brand")); + var secondaryLabel = bankAccount.get("funding_instrument_type"); + return Utils.safeFormat(label, primaryLabel, secondaryLabel).htmlSafe(); + }.property("bankAccount.last_four", "bankAccount.brand", "bankAccount.funding_instrument_type"), - paymentMethodPrimaryLabelText: Computed.fmt('item.last_four', 'item.brand', '%@ %@'), - paymentMethodSecondaryLabelText: Ember.computed.reads('item.funding_instrument_type'), + bankAccount: function() { + var BankAccount = this.container.lookupFactory("model:bank-account"); + return BankAccount.find(this.get("item.destination_uri")); + }.property("item.destination_uri"), + + // paymentMethodPrimaryLabelText: Computed.fmt('settlementSource.last_four', 'settlementSource.brand', '%@ %@'), + // paymentMethodSecondaryLabelText: Ember.computed.reads('item.funding_instrument_type'), amountText: function() { return Utils.formatCurrency(this.get("item.amount")); From 7af062da3c7cd820fb7f4ca04d4e6dc8858473ed Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Tue, 30 Dec 2014 11:27:50 -0800 Subject: [PATCH 06/80] Group transactions by settlement and order --- app/models/bk/account.coffee | 3 +- app/styles/results.less | 23 ++++++++- app/templates/account.hbs | 6 +-- app/templates/marketplace/settlements.hbs | 2 +- app/templates/orders.hbs | 4 +- .../results/grouped-settlement-row.hbs | 30 ++++++----- .../results/grouped-transaction-row.hbs | 9 ++++ app/templates/results/settlements-table.hbs | 41 --------------- ...ransactions-table-grouped-by-customer.hbs} | 0 .../transactions-table-grouped-by-order.hbs | 44 ++++++++++++++++ ...ansactions-table-grouped-by-settlement.hbs | 44 ++++++++++++++++ app/templates/settlement.hbs | 2 +- .../resource-summary-base.coffee | 2 +- app/views/results/grouped-settlement-row.js | 26 ++++++---- app/views/results/grouped-transaction-row.js | 50 +++++++++++-------- app/views/results/settlements-table.js | 8 --- ...transactions-table-grouped-by-customer.js} | 16 +++--- .../transactions-table-grouped-by-order.js | 35 +++++++++++++ ...ransactions-table-grouped-by-settlement.js | 34 +++++++++++++ .../results/order-transactions-table-test.js | 2 +- 20 files changed, 269 insertions(+), 112 deletions(-) delete mode 100644 app/templates/results/settlements-table.hbs rename app/templates/results/{order-transactions-table.hbs => transactions-table-grouped-by-customer.hbs} (100%) create mode 100644 app/templates/results/transactions-table-grouped-by-order.hbs create mode 100644 app/templates/results/transactions-table-grouped-by-settlement.hbs delete mode 100644 app/views/results/settlements-table.js rename app/views/results/{order-transactions-table.js => transactions-table-grouped-by-customer.js} (62%) create mode 100644 app/views/results/transactions-table-grouped-by-order.js create mode 100644 app/views/results/transactions-table-grouped-by-settlement.js diff --git a/app/models/bk/account.coffee b/app/models/bk/account.coffee index 94de00236..430d1dd18 100644 --- a/app/models/bk/account.coffee +++ b/app/models/bk/account.coffee @@ -8,8 +8,7 @@ Account = BkAccount.extend( type_name: (-> type = @get("type").capitalize() "%@ account".fmt(type) - ).property("type"), - title_description: Ember.computed.reads("customer.display_me"), + ).property("type") ) `export default Account;` diff --git a/app/styles/results.less b/app/styles/results.less index 20a4d34f8..05f00ac79 100644 --- a/app/styles/results.less +++ b/app/styles/results.less @@ -149,6 +149,27 @@ header.results-label h3 { padding-left: 0; padding-right: 0; + &.nested { + table.grouped-transactions { + tr:first-of-type { + td.status:first-of-type { + padding-left: 25px; + } + } + td.status { + &:first-of-type { + padding-left: 50px; + } + + a > span:after { + position: absolute; + content: ''; + border-left: 0; + } + } + } + } + table.grouped-transactions { border-bottom: 1px solid @gray2; @@ -195,7 +216,7 @@ header.results-label h3 { margin-left: 14px; } - &.orders .order { + &.orders > a > span { &:before { font-family: 'Balanced-Icon'; background-color: transparent; diff --git a/app/templates/account.hbs b/app/templates/account.hbs index 3d1b1f69a..295f1daa2 100644 --- a/app/templates/account.hbs +++ b/app/templates/account.hbs @@ -1,4 +1,4 @@ -{{view "page-navigations/page-navigation" pageType=model.type_name title=model.title_description}} +{{view "page-navigations/page-navigation" pageType=model.type_name title=model.id}} {{#view "detail-views/body-panel"}} {{#view "detail-views/api-model-panel" model=model}} @@ -10,11 +10,11 @@ {{#view "detail-views/main-panel"}}

Unsettled transactions

- {{view "results/embedded-transactions-table" loader=creditsResultsLoader}} + {{view "results/transactions-table-grouped-by-order" loader=creditsResultsLoader embedded=true}}

Settled transactions

- {{view "results/embedded-transactions-table" loader=settlementsResultsLoader}} + {{view "results/transactions-table-grouped-by-settlement" loader=settlementsResultsLoader embedded=true}}

Logs

diff --git a/app/templates/marketplace/settlements.hbs b/app/templates/marketplace/settlements.hbs index cbe4fcda7..a9846634c 100644 --- a/app/templates/marketplace/settlements.hbs +++ b/app/templates/marketplace/settlements.hbs @@ -4,6 +4,6 @@
- {{view "results/settlements-table" loader=resultsLoader}} + {{view "results/transactions-table-grouped-by-settlement" loader=resultsLoader}}
diff --git a/app/templates/orders.hbs b/app/templates/orders.hbs index 84e6c2adc..3e0dee657 100644 --- a/app/templates/orders.hbs +++ b/app/templates/orders.hbs @@ -18,13 +18,13 @@ {{#if view.isChargesTabSelected}}
- {{view "results/order-transactions-table" loader=debitsResultsLoader customers=model.buyers}} + {{view "results/transactions-table-grouped-by-customer" loader=debitsResultsLoader customers=model.buyers}}
{{/if}} {{#if view.isPayoutsTabSelected}}
- {{view "results/order-transactions-table" loader=creditsResultsLoader customers=model.seller}} + {{view "results/transactions-table-grouped-by-customer" loader=creditsResultsLoader customers=model.seller}}
{{/if}} diff --git a/app/templates/results/grouped-settlement-row.hbs b/app/templates/results/grouped-settlement-row.hbs index eddf51437..64f4038f6 100644 --- a/app/templates/results/grouped-settlement-row.hbs +++ b/app/templates/results/grouped-settlement-row.hbs @@ -1,26 +1,30 @@ - - {{#link-to view.item.routeName view.item}} + + {{#link-to view.routeName view.item}} {{view.displayValue}} {{/link-to}} - - {{#link-to view.item.routeName view.item}} + +{{#unless view.embedded}} + + {{#link-to view.routeName view.item}} + + {{view.customerText}} + + {{/link-to}} + +{{/unless}} + + + {{#link-to view.routeName view.item}} {{view.paymentMethodText}} {{/link-to}} - - {{#link-to view.item.routeName view.item}} - - {{view.paymentMethodText}} - - {{/link-to}} - - - {{#link-to view.item.routeName view.item}} + + {{#link-to view.routeName view.item}} {{view.amountText}} diff --git a/app/templates/results/grouped-transaction-row.hbs b/app/templates/results/grouped-transaction-row.hbs index 90b64d887..f811d7b05 100644 --- a/app/templates/results/grouped-transaction-row.hbs +++ b/app/templates/results/grouped-transaction-row.hbs @@ -5,6 +5,15 @@ {{/link-to}} +{{#unless view.embedded}} + + {{#link-to view.routeName view.item}} + + {{view.customerText}} + + {{/link-to}} + +{{/unless}} {{#link-to view.routeName view.item}} diff --git a/app/templates/results/settlements-table.hbs b/app/templates/results/settlements-table.hbs deleted file mode 100644 index ec2a575c5..000000000 --- a/app/templates/results/settlements-table.hbs +++ /dev/null @@ -1,41 +0,0 @@ - - - - {{view "results/settlements-transaction-results-dropdown-filter"}} - - Customer - Payment method - - - {{#view "results/results-loader-sort-column-header" resultsLoader=view.loader field="amount" actionName="changeDisputesSort"}} - Amount - {{/view}} - - - - -{{#if view.loader.results.hasNextPage}} - {{view "results/results-load-more" results=view.loader.results columns=view.colspan}} -{{/if}} - - - {{#each settlement in view.loader.results}} - - - {{#view "results/grouped-transactions-table"}} - {{view "results/grouped-settlement-row" item=settlement}} - {{/view}} - - - {{else}} - - - {{#if view.loader.results.isLoaded}} - No settlements - {{else}} - Loading... - {{/if}} - - - {{/each}} - diff --git a/app/templates/results/order-transactions-table.hbs b/app/templates/results/transactions-table-grouped-by-customer.hbs similarity index 100% rename from app/templates/results/order-transactions-table.hbs rename to app/templates/results/transactions-table-grouped-by-customer.hbs diff --git a/app/templates/results/transactions-table-grouped-by-order.hbs b/app/templates/results/transactions-table-grouped-by-order.hbs new file mode 100644 index 000000000..c6385fcd1 --- /dev/null +++ b/app/templates/results/transactions-table-grouped-by-order.hbs @@ -0,0 +1,44 @@ + + + Transaction + {{#unless view.embedded}} + Customer + {{/unless}} + Payment method + Amount + + +{{#if view.loader.results.hasNextPage}} + {{view "results/results-load-more" results=view.loader.results columns=view.colspan}} +{{/if}} + + + {{#each order_group in view.groupedResults}} + + + {{#view "results/grouped-transactions-table"}} + {{view "results/grouped-transaction-row" item=order_group.order embedded=view.parentView.embedded}} + + {{#each transaction in order_group.transactions}} + {{view "results/grouped-transaction-row" item=transaction embedded=view.parentView.embedded}} + + {{#if transaction.reversals}} + {{#each reversal in transaction.reversals}} + {{view "results/grouped-transaction-row" item=reversal embedded=view.parentView.embedded}} + {{/each}} + {{/if}} + {{/each}} + {{/view}} + + {{else}} + + + {{#if view.loader.results.isLoaded}} + No transactions + {{else}} + Loading... + {{/if}} + + + {{/each}} + diff --git a/app/templates/results/transactions-table-grouped-by-settlement.hbs b/app/templates/results/transactions-table-grouped-by-settlement.hbs new file mode 100644 index 000000000..771d99263 --- /dev/null +++ b/app/templates/results/transactions-table-grouped-by-settlement.hbs @@ -0,0 +1,44 @@ + + + Transaction + {{#unless view.embedded}} + Customer + {{/unless}} + Payment method + Amount + + +{{#if view.loader.results.hasNextPage}} + {{view "results/results-load-more" results=view.loader.results columns="view.colspan"}} +{{/if}} + + + {{#each settlement_group in view.groupedResults}} + + + {{#view "results/grouped-transactions-table"}} + {{view "results/grouped-transaction-row" item=settlement_group.settlement embedded=view.parentView.embedded}} + + {{#each transaction in settlement_group.transactions}} + {{view "results/grouped-transaction-row" item=transaction embedded=view.parentView.embedded}} + + {{#if transaction.reversals}} + {{#each reversal in transaction.reversals}} + {{view "results/grouped-transaction-row" item=reversal embedded=view.parentView.embedded}} + {{/each}} + {{/if}} + {{/each}} + {{/view}} + + {{else}} + + + {{#if view.loader.results.isLoaded}} + No transactions + {{else}} + Loading... + {{/if}} + + + {{/each}} + diff --git a/app/templates/settlement.hbs b/app/templates/settlement.hbs index c55a866c8..cacbd42fc 100644 --- a/app/templates/settlement.hbs +++ b/app/templates/settlement.hbs @@ -10,7 +10,7 @@ {{#view "detail-views/main-panel"}}

Related activity

- {{view "results/embedded-transactions-table" loader=creditsResultsLoader}} + {{view "results/transactions-table-grouped-by-order" loader=creditsResultsLoader}}

Logs

diff --git a/app/views/detail-views/resource-summaries/resource-summary-base.coffee b/app/views/detail-views/resource-summaries/resource-summary-base.coffee index 1d2069b17..da0d87eae 100644 --- a/app/views/detail-views/resource-summaries/resource-summary-base.coffee +++ b/app/views/detail-views/resource-summaries/resource-summary-base.coffee @@ -21,7 +21,7 @@ ResourceSummaryBase = Ember.View.extend( else if @isType("bank-account") "#{model.get('last_four')} #{model.get('formatted_bank_name')}" else if @isType("bk/account") - "Customer balance" + "Payable account" else null ).property("model.amount_escrowed", "model.amount", "model.display_me", "model.last_four", "model.brand", "model.formatted_bank_name") diff --git a/app/views/results/grouped-settlement-row.js b/app/views/results/grouped-settlement-row.js index 725a6bf11..14a07b048 100644 --- a/app/views/results/grouped-settlement-row.js +++ b/app/views/results/grouped-settlement-row.js @@ -9,6 +9,11 @@ var GroupedSettlementRowView = LinkedTwoLinesCellView.extend({ routeName: Ember.computed.oneWay("item.route_name"), spanClassNames: Ember.computed.oneWay("item.status"), + bankAccount: function() { + var BankAccount = this.container.lookupFactory("model:bank-account"); + return BankAccount.find(this.get("item.destination_uri")); + }.property("item.destination_uri"), + title: function() { var description = this.get("item.description"); @@ -50,23 +55,26 @@ var GroupedSettlementRowView = LinkedTwoLinesCellView.extend({ return Utils.humanReadableDateTime(this.get('item.created_at')); }.property('item.created_at'), + customerText: function() { + var Customer = this.container.lookupFactory("model:customer"); + this.get("bankAccount").then(function(bankAccount) { + var customer = Customer.find(bankAccount.get("customer_uri")); + var label = '%@%@'; + var primaryLabel = customer.get("display_me"); + var secondaryLabel = customer.get("email_address"); + console.log(primaryLabel) + return Utils.safeFormat(label, primaryLabel, secondaryLabel).htmlSafe(); + }) + }.property("bankAccount", "bankAccount.customer", "bankAccount.customer.display_me", "bankAccount.customer.email_address"), + paymentMethodText: function() { var bankAccount = this.get('bankAccount'); var label = '%@%@'; - console.log(bankAccount) var primaryLabel = "%@ %@".fmt(bankAccount.get("last_four"), bankAccount.get("brand")); var secondaryLabel = bankAccount.get("funding_instrument_type"); return Utils.safeFormat(label, primaryLabel, secondaryLabel).htmlSafe(); }.property("bankAccount.last_four", "bankAccount.brand", "bankAccount.funding_instrument_type"), - bankAccount: function() { - var BankAccount = this.container.lookupFactory("model:bank-account"); - return BankAccount.find(this.get("item.destination_uri")); - }.property("item.destination_uri"), - - // paymentMethodPrimaryLabelText: Computed.fmt('settlementSource.last_four', 'settlementSource.brand', '%@ %@'), - // paymentMethodSecondaryLabelText: Ember.computed.reads('item.funding_instrument_type'), - amountText: function() { return Utils.formatCurrency(this.get("item.amount")); }.property("item.amount") diff --git a/app/views/results/grouped-transaction-row.js b/app/views/results/grouped-transaction-row.js index ae0bf4162..6056d17f2 100644 --- a/app/views/results/grouped-transaction-row.js +++ b/app/views/results/grouped-transaction-row.js @@ -6,20 +6,16 @@ import Utils from "balanced-dashboard/lib/utils"; var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ tagName: 'tr', templateName: 'results/grouped-transaction-row', - routeName: Ember.computed.oneWay("item.route_name"), - spanClassNames: Ember.computed.oneWay("item.status"), + routeName: Computed.orProperties("item.route_name", "item.routeName"), + spanClassNames: Ember.computed.reads("item.status"), title: function() { - var description = this.get("item.description"); - - if (description) { - return description; - } if (_.contains(this.get("classNames"), "current")) { return 'You are currently viewing this transaction.'; } - return '(Created at %@)'.fmt(this.get("secondaryLabelText")); - }.property("item.description", "primaryLabelText", "secondaryLabelText"), + + return this.get("primaryLabelText"); + }.property("primaryLabelText"), primaryLabelText: function() { if (_.contains(this.get("classNames"), "current")) { @@ -29,35 +25,47 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ var description = this.get('item.description'); var status = Utils.capitalize(this.get('item.status')); - if (status) { - status = status.toLowerCase(); - } - if (description) { - transactionText = '%@ (%@) %@'.fmt(this.get('item.type_name'), description, status); + transactionText = '%@ (%@)'.fmt(this.get('item.type_name'), description); } else { - transactionText = '%@ %@'.fmt(this.get('item.type_name'), status); + transactionText = this.get('item.type_name'); } - if (this.get('item.type_name') === 'Dispute') { - transactionText = '%@ %@'.fmt(this.get('item.type_name'), status); + if (status) { + transactionText = '%@ %@'.fmt(transactionText, status.toLowerCase()); } - return Utils.safeFormat(transactionText).htmlSafe(); - }.property('classNames', 'item.type_name', 'item.status', 'item.description'), + return transactionText; + }.property('classNames', 'item.status', 'item.description'), secondaryLabelText: function () { return Utils.humanReadableDateTime(this.get('item.created_at')); }.property('item.created_at'), + customerText: Ember.computed.reads("item.customer.display_me"), + paymentMethodText: function() { var label = '%@%@'; var secondaryLabel = this.get('paymentMethodSecondaryLabelText') || ''; return Utils.safeFormat(label, this.get('paymentMethodPrimaryLabelText'), secondaryLabel).htmlSafe(); }.property('paymentMethodPrimaryLabelText', 'paymentMethodSecondaryLabelText'), - paymentMethodPrimaryLabelText: Computed.fmt('item.last_four', 'item.brand', '%@ %@'), - paymentMethodSecondaryLabelText: Ember.computed.reads('item.funding_instrument_type'), + paymentMethodPrimaryLabelText: function() { + if (this.get("item.destination.type") === "payable") { + return this.get("item.destination.id"); + } else { + return "%@ %@".fmt(this.get("item.destination.last_four"), this.get("item.destination.brand")); + } + + }.property("item.destination.id", "item.destination.last_four", "item.destination.brand"), + paymentMethodSecondaryLabelText: function() { + if (this.get("item.destination.type") === "payable") { + return "Payable account"; + } else { + return this.get('item.destination.funding_instrument_type'); + } + + }.property('item.destination.funding_instrument_type'), amountText: function() { return Utils.formatCurrency(this.get("item.amount")); diff --git a/app/views/results/settlements-table.js b/app/views/results/settlements-table.js deleted file mode 100644 index 8bb78ee20..000000000 --- a/app/views/results/settlements-table.js +++ /dev/null @@ -1,8 +0,0 @@ -import ResultsTableView from "./results-table"; - -var SettlementsResultsView = ResultsTableView.extend({ - classNames: 'settlements', - templateName: 'results/settlements-table' -}); - -export default SettlementsResultsView; diff --git a/app/views/results/order-transactions-table.js b/app/views/results/transactions-table-grouped-by-customer.js similarity index 62% rename from app/views/results/order-transactions-table.js rename to app/views/results/transactions-table-grouped-by-customer.js index 422cd1e4d..5ebab831c 100644 --- a/app/views/results/order-transactions-table.js +++ b/app/views/results/transactions-table-grouped-by-customer.js @@ -1,7 +1,7 @@ import TransactionsTableView from "./transactions-table"; -var OrderTransactionsTableView = TransactionsTableView.extend({ - templateName: 'results/order-transactions-table', +var TransactionsTableGroupedByCustomerView = TransactionsTableView.extend({ + templateName: 'results/transactions-table-grouped-by-customer', classNames: 'non-interactive', customersArray: function() { @@ -17,24 +17,24 @@ var OrderTransactionsTableView = TransactionsTableView.extend({ var results = this.get("loader.results"); var groupedTransactions = []; - results.forEach(function(transactions) { - var buyer = customers.findBy("uri", transactions.get('customer_uri')); - var customer = groupedTransactions.findBy('customer_uri', transactions.get('customer_uri')); + results.forEach(function(transaction) { + var buyer = customers.findBy("uri", transaction.get('customer_uri')); + var customer = groupedTransactions.findBy('customer_uri', transaction.get('customer_uri')); if(!customer) { customer = Ember.Object.create({ - customer_uri: transactions.get('customer_uri'), + customer_uri: transaction.get('customer_uri'), customer: buyer, transactions: [] }); groupedTransactions.pushObject(customer); } - customer.get('transactions').pushObject(transactions); + customer.get('transactions').pushObject(transaction); }); return groupedTransactions; }.property("customersArray", "loader.results.length"), }); -export default OrderTransactionsTableView; +export default TransactionsTableGroupedByCustomerView; diff --git a/app/views/results/transactions-table-grouped-by-order.js b/app/views/results/transactions-table-grouped-by-order.js new file mode 100644 index 000000000..c884dd2ae --- /dev/null +++ b/app/views/results/transactions-table-grouped-by-order.js @@ -0,0 +1,35 @@ +import TransactionsTableView from "./transactions-table"; + +var TransactionsTableGroupedByOrderView = TransactionsTableView.extend({ + templateName: 'results/transactions-table-grouped-by-order', + classNames: 'non-interactive', + + colspan: function() { + return (this.get("embedded")) ? "3": "4"; + }.property("embedded"), + + groupedResults: function() { + var results = this.get("loader.results"); + var groupedTransactions = []; + var Order = this.container.lookupFactory("model:order"); + + results.forEach(function(transaction) { + var order = Order.find(transaction.get('order_uri')); + var orderGroup = groupedTransactions.findBy('order_uri', transaction.get('order_uri')); + + if (!orderGroup) { + orderGroup = Ember.Object.create({ + order_uri: transaction.get('order_uri'), + order: order, + transactions: [] + }); + groupedTransactions.pushObject(orderGroup); + } + orderGroup.get('transactions').pushObject(transaction); + }); + + return groupedTransactions; + }.property("loader.results.length"), +}); + +export default TransactionsTableGroupedByOrderView; diff --git a/app/views/results/transactions-table-grouped-by-settlement.js b/app/views/results/transactions-table-grouped-by-settlement.js new file mode 100644 index 000000000..36f16efb0 --- /dev/null +++ b/app/views/results/transactions-table-grouped-by-settlement.js @@ -0,0 +1,34 @@ +import ResultsTableView from "./results-table"; + +var TransactionsTableGroupedBySettlement = ResultsTableView.extend({ + templateName: 'results/transactions-table-grouped-by-settlement', + classNames: ['settlements', 'non-interactive'], + + colspan: function() { + return (this.get("embedded")) ? "3": "4"; + }.property("embedded"), + + groupedResults: function() { + var self = this; + var settlements = this.get("loader.results"); + var groupedTransactions = []; + + settlements.forEach(function(settlement) { + var credits = self.container.lookupFactory("results-loader:transactions").create({ + path: settlement.get("credits_uri") + }).get("results.content"); + + var settlementGroup = Ember.Object.create({ + settlement_uri: settlement.get('uri'), + settlement: settlement, + transactions: credits + }); + groupedTransactions.pushObject(settlementGroup); + }); + + return groupedTransactions; + }.property("loader.results.length"), + +}); + +export default TransactionsTableGroupedBySettlement; diff --git a/tests/unit/views/results/order-transactions-table-test.js b/tests/unit/views/results/order-transactions-table-test.js index d71fb2bb6..f219262e4 100644 --- a/tests/unit/views/results/order-transactions-table-test.js +++ b/tests/unit/views/results/order-transactions-table-test.js @@ -1,4 +1,4 @@ -import OrderTransactionsTable from "balanced-dashboard/views/results/order-transactions-table"; +import OrderTransactionsTable from "balanced-dashboard/views/results/transactions-table-grouped-by-customer"; import Testing from "balanced-dashboard/tests/helpers/testing"; module("View - OrderTransactionsTable", { From 54e6bebe57cff234af917803d018bf27b704a95a Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Tue, 30 Dec 2014 15:07:21 -0800 Subject: [PATCH 07/80] Filter out settled transactions in the unsettled transactions table --- .../result-loaders-initializer.coffee | 1 + .../results-loaders/unsettled-transactions.js | 35 +++++++++++++++++++ app/routes/account.coffee | 11 +++--- app/templates/account.hbs | 2 +- app/views/results/grouped-settlement-row.js | 4 +-- .../transactions-table-grouped-by-order.js | 2 +- 6 files changed, 46 insertions(+), 9 deletions(-) create mode 100644 app/models/results-loaders/unsettled-transactions.js diff --git a/app/initializers/result-loaders-initializer.coffee b/app/initializers/result-loaders-initializer.coffee index ab341f2f7..322547c53 100644 --- a/app/initializers/result-loaders-initializer.coffee +++ b/app/initializers/result-loaders-initializer.coffee @@ -12,6 +12,7 @@ LOADER_NAMES = [ "marketplace-search" "orders" "transactions" + "unsettled-transactions" ] ResultLoadersInitializer = diff --git a/app/models/results-loaders/unsettled-transactions.js b/app/models/results-loaders/unsettled-transactions.js new file mode 100644 index 000000000..5add5d299 --- /dev/null +++ b/app/models/results-loaders/unsettled-transactions.js @@ -0,0 +1,35 @@ +import TransactionsResultsLoader from "./transactions"; +import SearchModelArray from "../core/search-model-array"; + +var UnsettledTransactionsResultsLoader = TransactionsResultsLoader.extend({ + unfilteredResults: function() { + var uri = this.get('resultsUri'); + var type = this.get('resultsType'); + + if (Ember.isBlank(uri)) { + return ModelArray.create({ + isLoaded: true + }); + } else { + var searchArray = SearchModelArray.newArrayLoadedFromUri(uri, type); + searchArray.setProperties({ + sortProperties: [this.get('sortField') || 'created_at'], + sortAscending: this.get('sortDirection') === 'asc' + }); + + return searchArray; + } + }.property("resultsUri", "resultsType", "sortField", "sortDirection"), + + results: function() { + var self = this; + return this.get("unfilteredResults").filter(function(credit) { + return !self.get("settledTransactionIds").contains(credit.get("id")); + }) + }.property("unfilteredResults.@each.id", "settledTransactionIds"), + + // TODO: populate settled transaction IDs + settledTransactionIds: [] +}); + +export default UnsettledTransactionsResultsLoader; diff --git a/app/routes/account.coffee b/app/routes/account.coffee index 235486850..78859b063 100644 --- a/app/routes/account.coffee +++ b/app/routes/account.coffee @@ -12,15 +12,16 @@ AccountRoute = ModelRoute.extend( this.get("container").lookupFactory("model:customer").find(model.get("customer_uri")).then (customer) -> model.set("customer", customer) - creditsResultsLoader = this.get("container").lookupFactory("results-loader:transactions").create({ - path: model.get("credits_uri") - }); - settlementsResultsLoader = this.get("container").lookupFactory("results-loader:transactions").create({ path: model.get("settlements_uri") }); - controller.set("creditsResultsLoader", creditsResultsLoader); + unsettledCreditsResultsLoader = this.get("container").lookupFactory("results-loader:unsettled_transactions").create({ + path: model.get("credits_uri"), + settledTransactionsResultsLoader: settlementsResultsLoader + }); + + controller.set("creditsResultsLoader", unsettledCreditsResultsLoader); controller.set("settlementsResultsLoader", settlementsResultsLoader); ) diff --git a/app/templates/account.hbs b/app/templates/account.hbs index 295f1daa2..e963200eb 100644 --- a/app/templates/account.hbs +++ b/app/templates/account.hbs @@ -10,7 +10,7 @@ {{#view "detail-views/main-panel"}}

Unsettled transactions

- {{view "results/transactions-table-grouped-by-order" loader=creditsResultsLoader embedded=true}} + {{view "results/transactions-table-grouped-by-order" loader=creditsResultsLoader embedded=true}}

Settled transactions

diff --git a/app/views/results/grouped-settlement-row.js b/app/views/results/grouped-settlement-row.js index 14a07b048..f6740c81a 100644 --- a/app/views/results/grouped-settlement-row.js +++ b/app/views/results/grouped-settlement-row.js @@ -62,9 +62,9 @@ var GroupedSettlementRowView = LinkedTwoLinesCellView.extend({ var label = '%@%@'; var primaryLabel = customer.get("display_me"); var secondaryLabel = customer.get("email_address"); - console.log(primaryLabel) + return Utils.safeFormat(label, primaryLabel, secondaryLabel).htmlSafe(); - }) + }); }.property("bankAccount", "bankAccount.customer", "bankAccount.customer.display_me", "bankAccount.customer.email_address"), paymentMethodText: function() { diff --git a/app/views/results/transactions-table-grouped-by-order.js b/app/views/results/transactions-table-grouped-by-order.js index c884dd2ae..75b5d4c77 100644 --- a/app/views/results/transactions-table-grouped-by-order.js +++ b/app/views/results/transactions-table-grouped-by-order.js @@ -29,7 +29,7 @@ var TransactionsTableGroupedByOrderView = TransactionsTableView.extend({ }); return groupedTransactions; - }.property("loader.results.length"), + }.property("loader.results.length", "view.parentView.controller.settlementsResultsLoader.results"), }); export default TransactionsTableGroupedByOrderView; From c92ed75b5eafcd2aae683a5183feaf68fa3bfc8e Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Tue, 6 Jan 2015 10:11:33 -0800 Subject: [PATCH 08/80] Adjust the table column widths --- app/styles/results.less | 5 +++++ app/templates/results/grouped-transaction-row.hbs | 8 ++++---- .../results/grouped-transactions-table-layout.hbs | 10 ++++++++++ .../results/transactions-table-grouped-by-order.hbs | 8 ++++---- .../transactions-table-grouped-by-settlement.hbs | 8 ++++---- 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/app/styles/results.less b/app/styles/results.less index 05f00ac79..d1484572d 100644 --- a/app/styles/results.less +++ b/app/styles/results.less @@ -173,6 +173,11 @@ header.results-label h3 { table.grouped-transactions { border-bottom: 1px solid @gray2; + thead { + border: none; + margin-top: -1px; + } + &:last-of-type { border-bottom: none; } diff --git a/app/templates/results/grouped-transaction-row.hbs b/app/templates/results/grouped-transaction-row.hbs index f811d7b05..b760a71d5 100644 --- a/app/templates/results/grouped-transaction-row.hbs +++ b/app/templates/results/grouped-transaction-row.hbs @@ -1,4 +1,4 @@ - + {{#link-to view.routeName view.item}} {{view.displayValue}} @@ -6,7 +6,7 @@ {{/link-to}} {{#unless view.embedded}} - + {{#link-to view.routeName view.item}} {{view.customerText}} @@ -14,14 +14,14 @@ {{/link-to}} {{/unless}} - + {{#link-to view.routeName view.item}} {{view.paymentMethodText}} {{/link-to}} - + {{#link-to view.routeName view.item}} {{view.amountText}} diff --git a/app/templates/results/grouped-transactions-table-layout.hbs b/app/templates/results/grouped-transactions-table-layout.hbs index f5788cc73..54e21c4e5 100644 --- a/app/templates/results/grouped-transactions-table-layout.hbs +++ b/app/templates/results/grouped-transactions-table-layout.hbs @@ -1,3 +1,13 @@ + + + + {{#unless view.embedded}} + + {{/unless}} + + + + {{yield}} diff --git a/app/templates/results/transactions-table-grouped-by-order.hbs b/app/templates/results/transactions-table-grouped-by-order.hbs index c6385fcd1..5bba1fca4 100644 --- a/app/templates/results/transactions-table-grouped-by-order.hbs +++ b/app/templates/results/transactions-table-grouped-by-order.hbs @@ -16,15 +16,15 @@ {{#each order_group in view.groupedResults}} - {{#view "results/grouped-transactions-table"}} - {{view "results/grouped-transaction-row" item=order_group.order embedded=view.parentView.embedded}} + {{#view "results/grouped-transactions-table" embedded=view.embedded}} + {{view "results/grouped-transaction-row" item=order_group.order embedded=view.embedded}} {{#each transaction in order_group.transactions}} - {{view "results/grouped-transaction-row" item=transaction embedded=view.parentView.embedded}} + {{view "results/grouped-transaction-row" item=transaction embedded=view.embedded}} {{#if transaction.reversals}} {{#each reversal in transaction.reversals}} - {{view "results/grouped-transaction-row" item=reversal embedded=view.parentView.embedded}} + {{view "results/grouped-transaction-row" item=reversal embedded=view.embedded}} {{/each}} {{/if}} {{/each}} diff --git a/app/templates/results/transactions-table-grouped-by-settlement.hbs b/app/templates/results/transactions-table-grouped-by-settlement.hbs index 771d99263..ec84b270b 100644 --- a/app/templates/results/transactions-table-grouped-by-settlement.hbs +++ b/app/templates/results/transactions-table-grouped-by-settlement.hbs @@ -16,15 +16,15 @@ {{#each settlement_group in view.groupedResults}} - {{#view "results/grouped-transactions-table"}} - {{view "results/grouped-transaction-row" item=settlement_group.settlement embedded=view.parentView.embedded}} + {{#view "results/grouped-transactions-table" embedded=view.embedded}} + {{view "results/grouped-transaction-row" item=settlement_group.settlement embedded=view.embedded}} {{#each transaction in settlement_group.transactions}} - {{view "results/grouped-transaction-row" item=transaction embedded=view.parentView.embedded}} + {{view "results/grouped-transaction-row" item=transaction embedded=view.embedded}} {{#if transaction.reversals}} {{#each reversal in transaction.reversals}} - {{view "results/grouped-transaction-row" item=reversal embedded=view.parentView.embedded}} + {{view "results/grouped-transaction-row" item=reversal embedded=view.embedded}} {{/each}} {{/if}} {{/each}} From a9b44e420009924d6ae57a467722d6c7ed024377 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Tue, 6 Jan 2015 10:12:56 -0800 Subject: [PATCH 09/80] Populate settled transaction IDs (incomplte) --- app/models/results-loaders/settlements.js | 8 -------- .../results-loaders/unsettled-transactions.js | 16 +++++++++++++++- app/routes/account.coffee | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) delete mode 100644 app/models/results-loaders/settlements.js diff --git a/app/models/results-loaders/settlements.js b/app/models/results-loaders/settlements.js deleted file mode 100644 index 98085e166..000000000 --- a/app/models/results-loaders/settlements.js +++ /dev/null @@ -1,8 +0,0 @@ -import BaseResultsLoader from "./base"; -import Settlement from "../bk/settlement"; - -var SettlementsResultsLoader = BaseResultsLoader.extend({ - resultsType: Settlement, -}); - -export default SettlementsResultsLoader; diff --git a/app/models/results-loaders/unsettled-transactions.js b/app/models/results-loaders/unsettled-transactions.js index 5add5d299..a5ec6d4f2 100644 --- a/app/models/results-loaders/unsettled-transactions.js +++ b/app/models/results-loaders/unsettled-transactions.js @@ -23,13 +23,27 @@ var UnsettledTransactionsResultsLoader = TransactionsResultsLoader.extend({ results: function() { var self = this; + return this.get("unfilteredResults").filter(function(credit) { return !self.get("settledTransactionIds").contains(credit.get("id")); }) }.property("unfilteredResults.@each.id", "settledTransactionIds"), // TODO: populate settled transaction IDs - settledTransactionIds: [] + settledTransactionIds: function() { + var self = this; + var settlements = this.get("settlementsResultsLoader.results"); + var settledTransactions = []; + + settlements.forEach(function(settlement) { + var credits = TransactionsResultsLoader.create({ + path: settlement.get("credits_uri") + }).get("results.content"); + settledTransactions.pushObject(credits); + }); + + return _.flatten(settledTransactions); + }.property("settlementsResultsLoader.results.length") }); export default UnsettledTransactionsResultsLoader; diff --git a/app/routes/account.coffee b/app/routes/account.coffee index 78859b063..62977f057 100644 --- a/app/routes/account.coffee +++ b/app/routes/account.coffee @@ -18,7 +18,7 @@ AccountRoute = ModelRoute.extend( unsettledCreditsResultsLoader = this.get("container").lookupFactory("results-loader:unsettled_transactions").create({ path: model.get("credits_uri"), - settledTransactionsResultsLoader: settlementsResultsLoader + settlementsResultsLoader: settlementsResultsLoader }); controller.set("creditsResultsLoader", unsettledCreditsResultsLoader); From 476c973e25b7bfddaae591c8b5e66316e20f93fb Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Tue, 6 Jan 2015 10:57:55 -0800 Subject: [PATCH 10/80] Fix table columns --- .../results/embedded-transactions-table.hbs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/templates/results/embedded-transactions-table.hbs b/app/templates/results/embedded-transactions-table.hbs index ea3067905..f7d870cd2 100644 --- a/app/templates/results/embedded-transactions-table.hbs +++ b/app/templates/results/embedded-transactions-table.hbs @@ -19,31 +19,31 @@ {{#each transaction in view.filteredResults}} - {{#view "results/grouped-transactions-table"}} + {{#view "results/grouped-transactions-table" embedded=true}} {{#if transaction.order}} - {{view "results/grouped-order-row" item=transaction.order}} + {{view "results/grouped-order-row" item=transaction.order embedded=true}} {{/if}} {{#if transaction.dispute}} - {{view "results/grouped-transaction-row" item=transaction.dispute}} + {{view "results/grouped-transaction-row" item=transaction.dispute embedded=true}} {{/if}} {{#if transaction.refunds}} {{#each refund in transaction.refunds}} - {{view "results/grouped-transaction-row" item=refund}} + {{view "results/grouped-transaction-row" item=refund embedded=true}} {{/each}} {{/if}} {{#if transaction.reversals}} {{#each reversal in transaction.reversals}} - {{view "results/grouped-transaction-row" item=reversal}} + {{view "results/grouped-transaction-row" item=reversal embedded=true}} {{/each}} {{/if}} - {{view "results/grouped-transaction-row" item=transaction}} + {{view "results/grouped-transaction-row" item=transaction embedded=true}} {{#if transaction.hold}} - {{view "results/grouped-transaction-row" item=transaction.hold}} + {{view "results/grouped-transaction-row" item=transaction.hold embedded=true}} {{/if}} {{/view}} From 947e7b52d80ae2b51bc9e60d3f7a805766681d1f Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Tue, 6 Jan 2015 14:42:46 -0800 Subject: [PATCH 11/80] Filter unsettled credits --- .../results-loaders/unsettled-transactions.js | 19 +++-- .../results/grouped-settlement-row.hbs | 32 ------- app/views/results/grouped-settlement-row.js | 83 ------------------- app/views/results/grouped-transaction-row.js | 45 +++++++++- ...ransactions-table-grouped-by-settlement.js | 41 +++++++-- 5 files changed, 86 insertions(+), 134 deletions(-) delete mode 100644 app/templates/results/grouped-settlement-row.hbs delete mode 100644 app/views/results/grouped-settlement-row.js diff --git a/app/models/results-loaders/unsettled-transactions.js b/app/models/results-loaders/unsettled-transactions.js index a5ec6d4f2..1a1348768 100644 --- a/app/models/results-loaders/unsettled-transactions.js +++ b/app/models/results-loaders/unsettled-transactions.js @@ -1,4 +1,5 @@ import TransactionsResultsLoader from "./transactions"; +import ModelArray from "../core/model-array"; import SearchModelArray from "../core/search-model-array"; var UnsettledTransactionsResultsLoader = TransactionsResultsLoader.extend({ @@ -26,23 +27,25 @@ var UnsettledTransactionsResultsLoader = TransactionsResultsLoader.extend({ return this.get("unfilteredResults").filter(function(credit) { return !self.get("settledTransactionIds").contains(credit.get("id")); - }) + }); }.property("unfilteredResults.@each.id", "settledTransactionIds"), - // TODO: populate settled transaction IDs settledTransactionIds: function() { + return this.get("settledTransactions").mapBy("id"); + }.property("settledTransactions.@each.id"), + + settledTransactions: function() { var self = this; var settlements = this.get("settlementsResultsLoader.results"); var settledTransactions = []; settlements.forEach(function(settlement) { - var credits = TransactionsResultsLoader.create({ - path: settlement.get("credits_uri") - }).get("results.content"); - settledTransactions.pushObject(credits); + var promise = SearchModelArray.newArrayLoadedFromUri(settlement.get("credits_uri"), "credit"); + promise.then(function(credits) { + settledTransactions.pushObjects(credits.content); + }); }); - - return _.flatten(settledTransactions); + return settledTransactions; }.property("settlementsResultsLoader.results.length") }); diff --git a/app/templates/results/grouped-settlement-row.hbs b/app/templates/results/grouped-settlement-row.hbs deleted file mode 100644 index 64f4038f6..000000000 --- a/app/templates/results/grouped-settlement-row.hbs +++ /dev/null @@ -1,32 +0,0 @@ - - {{#link-to view.routeName view.item}} - - {{view.displayValue}} - - {{/link-to}} - - -{{#unless view.embedded}} - - {{#link-to view.routeName view.item}} - - {{view.customerText}} - - {{/link-to}} - -{{/unless}} - - - {{#link-to view.routeName view.item}} - - {{view.paymentMethodText}} - - {{/link-to}} - - - {{#link-to view.routeName view.item}} - - {{view.amountText}} - - {{/link-to}} - diff --git a/app/views/results/grouped-settlement-row.js b/app/views/results/grouped-settlement-row.js deleted file mode 100644 index f6740c81a..000000000 --- a/app/views/results/grouped-settlement-row.js +++ /dev/null @@ -1,83 +0,0 @@ -import Ember from "ember"; -import Computed from "balanced-dashboard/utils/computed"; -import LinkedTwoLinesCellView from "../tables/cells/linked-two-lines-cell"; -import Utils from "balanced-dashboard/lib/utils"; - -var GroupedSettlementRowView = LinkedTwoLinesCellView.extend({ - tagName: 'tr', - templateName: 'results/grouped-settlement-row', - routeName: Ember.computed.oneWay("item.route_name"), - spanClassNames: Ember.computed.oneWay("item.status"), - - bankAccount: function() { - var BankAccount = this.container.lookupFactory("model:bank-account"); - return BankAccount.find(this.get("item.destination_uri")); - }.property("item.destination_uri"), - - title: function() { - var description = this.get("item.description"); - - if (description) { - return description; - } - if (_.contains(this.get("classNames"), "current")) { - return 'You are currently viewing this transaction.'; - } - return '(Created at %@)'.fmt(this.get("secondaryLabelText")); - }.property("item.description", "primaryLabelText", "secondaryLabelText"), - - primaryLabelText: function() { - if (_.contains(this.get("classNames"), "current")) { - return '%@ (currently viewing)'.fmt(this.get('item.type_name')); - } - var transactionText; - var description = this.get('item.description'); - var status = Utils.capitalize(this.get('item.status')); - - if (status) { - status = status.toLowerCase(); - } - - if (description) { - transactionText = '%@ (%@) %@'.fmt(this.get('item.type_name'), description, status); - } else { - transactionText = '%@ %@'.fmt(this.get('item.type_name'), status); - } - - if (this.get('item.type_name') === 'Dispute') { - transactionText = '%@ %@'.fmt(this.get('item.type_name'), status); - } - - return Utils.safeFormat(transactionText).htmlSafe(); - }.property('classNames', 'item.type_name', 'item.status', 'item.description'), - - secondaryLabelText: function () { - return Utils.humanReadableDateTime(this.get('item.created_at')); - }.property('item.created_at'), - - customerText: function() { - var Customer = this.container.lookupFactory("model:customer"); - this.get("bankAccount").then(function(bankAccount) { - var customer = Customer.find(bankAccount.get("customer_uri")); - var label = '%@%@'; - var primaryLabel = customer.get("display_me"); - var secondaryLabel = customer.get("email_address"); - - return Utils.safeFormat(label, primaryLabel, secondaryLabel).htmlSafe(); - }); - }.property("bankAccount", "bankAccount.customer", "bankAccount.customer.display_me", "bankAccount.customer.email_address"), - - paymentMethodText: function() { - var bankAccount = this.get('bankAccount'); - var label = '%@%@'; - var primaryLabel = "%@ %@".fmt(bankAccount.get("last_four"), bankAccount.get("brand")); - var secondaryLabel = bankAccount.get("funding_instrument_type"); - return Utils.safeFormat(label, primaryLabel, secondaryLabel).htmlSafe(); - }.property("bankAccount.last_four", "bankAccount.brand", "bankAccount.funding_instrument_type"), - - amountText: function() { - return Utils.formatCurrency(this.get("item.amount")); - }.property("item.amount") -}); - -export default GroupedSettlementRowView; diff --git a/app/views/results/grouped-transaction-row.js b/app/views/results/grouped-transaction-row.js index 6056d17f2..cbdcebff9 100644 --- a/app/views/results/grouped-transaction-row.js +++ b/app/views/results/grouped-transaction-row.js @@ -17,6 +17,11 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ return this.get("primaryLabelText"); }.property("primaryLabelText"), + bankAccount: function() { + var BankAccount = this.container.lookupFactory("model:bank-account"); + return BankAccount.find(this.get("item.destination_uri")); + }.property("item.destination_uri"), + primaryLabelText: function() { if (_.contains(this.get("classNames"), "current")) { return '%@ (currently viewing)'.fmt(this.get('item.type_name')); @@ -42,13 +47,48 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ return Utils.humanReadableDateTime(this.get('item.created_at')); }.property('item.created_at'), - customerText: Ember.computed.reads("item.customer.display_me"), + customerText: function() { + if (this.get('item.type_name') === "Settlement") { + console.log(this.get("settlementCustomerText")) + return this.get("settlementCustomerText"); + } else { + return this.get("item.customer.display_me"); + } + }.property("item.customer.display_me", "settlementCustomerText"), + + // customer: function() { + // var self = this; + // this.get("bankAccount").then(function(bankAccount) { + // var customer = self.container.lookupFactory("model:customer").find(bankAccount.get("customer_uri")); + // return customer; + // }); + // }.property("bankAccount", "bankAccount.customer_uri"), + customer: Ember.computed.reads("bankAccount.customer"), + + settlementCustomerText: function() { + var label = '%@%@'; + var primaryLabel = this.get("customer.display_me"); + var secondaryLabel = this.get("customer.email_address"); + + return Utils.safeFormat(label, primaryLabel, secondaryLabel).htmlSafe(); + }.property("customer.display_me", "customer.email_address"), paymentMethodText: function() { + if (this.get('item.type_name') === "Settlement") { + return this.get("settlementPaymentMethodText"); + } var label = '%@%@'; var secondaryLabel = this.get('paymentMethodSecondaryLabelText') || ''; return Utils.safeFormat(label, this.get('paymentMethodPrimaryLabelText'), secondaryLabel).htmlSafe(); - }.property('paymentMethodPrimaryLabelText', 'paymentMethodSecondaryLabelText'), + }.property('paymentMethodPrimaryLabelText', 'paymentMethodSecondaryLabelText', "settlementPaymentMethodText", "item.type_name"), + + settlementPaymentMethodText: function() { + var bankAccount = this.get('bankAccount'); + var label = '%@%@'; + var primaryLabel = "%@ %@".fmt(bankAccount.get("last_four"), bankAccount.get("brand")); + var secondaryLabel = bankAccount.get("funding_instrument_type"); + return Utils.safeFormat(label, primaryLabel, secondaryLabel).htmlSafe(); + }.property("bankAccount.last_four", "bankAccount.brand", "bankAccount.funding_instrument_type"), paymentMethodPrimaryLabelText: function() { if (this.get("item.destination.type") === "payable") { @@ -58,6 +98,7 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ } }.property("item.destination.id", "item.destination.last_four", "item.destination.brand"), + paymentMethodSecondaryLabelText: function() { if (this.get("item.destination.type") === "payable") { return "Payable account"; diff --git a/app/views/results/transactions-table-grouped-by-settlement.js b/app/views/results/transactions-table-grouped-by-settlement.js index 36f16efb0..37a72f587 100644 --- a/app/views/results/transactions-table-grouped-by-settlement.js +++ b/app/views/results/transactions-table-grouped-by-settlement.js @@ -1,4 +1,5 @@ import ResultsTableView from "./results-table"; +import SearchModelArray from "balanced-dashboard/models/core/search-model-array"; var TransactionsTableGroupedBySettlement = ResultsTableView.extend({ templateName: 'results/transactions-table-grouped-by-settlement', @@ -14,21 +15,43 @@ var TransactionsTableGroupedBySettlement = ResultsTableView.extend({ var groupedTransactions = []; settlements.forEach(function(settlement) { - var credits = self.container.lookupFactory("results-loader:transactions").create({ - path: settlement.get("credits_uri") - }).get("results.content"); - - var settlementGroup = Ember.Object.create({ - settlement_uri: settlement.get('uri'), - settlement: settlement, - transactions: credits + var promise = SearchModelArray.newArrayLoadedFromUri(settlement.get("credits_uri"), "credit"); + promise.then(function(credits) { + // credits = self.groupCreditsByOrder(credits); + + var settlementGroup = Ember.Object.create({ + settlement_uri: settlement.get('uri'), + settlement: settlement, + transactions: credits + }); + groupedTransactions.pushObject(settlementGroup); }); - groupedTransactions.pushObject(settlementGroup); }); return groupedTransactions; }.property("loader.results.length"), + groupCreditsByOrder: function(credits) { + var groupedCredits = []; + var Order = this.container.lookupFactory("model:order"); + + credits.forEach(function(transaction) { + var order = Order.find(transaction.get('order_uri')); + var orderGroup = groupedCredits.findBy('order_uri', transaction.get('order_uri')); + + if (!orderGroup) { + orderGroup = Ember.Object.create({ + order_uri: transaction.get('order_uri'), + order: order, + transactions: [] + }); + groupedCredits.pushObject(orderGroup); + } + orderGroup.get('transactions').pushObject(transaction); + }); + + return groupedCredits; + } }); export default TransactionsTableGroupedBySettlement; From 3ce3959c30281d3806c7b7aa1676e7c4e6c89bd6 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Wed, 7 Jan 2015 18:11:35 -0800 Subject: [PATCH 12/80] Group transactions by order by settlement --- app/styles/results.less | 19 ++++++------- ...ansactions-table-grouped-by-settlement.hbs | 27 +++++++++++-------- .../transactions-table-grouped-by-order.js | 2 +- ...ransactions-table-grouped-by-settlement.js | 6 ++--- 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/app/styles/results.less b/app/styles/results.less index d1484572d..1a3c0fb13 100644 --- a/app/styles/results.less +++ b/app/styles/results.less @@ -150,22 +150,23 @@ header.results-label h3 { padding-right: 0; &.nested { - table.grouped-transactions { - tr:first-of-type { - td.status:first-of-type { + table.grouped-transactions:first-of-type { + border-bottom: none; + + td.status { + &:first-of-type { padding-left: 25px; } } + } + + table.grouped-transactions { + border-bottom: none; + td.status { &:first-of-type { padding-left: 50px; } - - a > span:after { - position: absolute; - content: ''; - border-left: 0; - } } } } diff --git a/app/templates/results/transactions-table-grouped-by-settlement.hbs b/app/templates/results/transactions-table-grouped-by-settlement.hbs index ec84b270b..83aa85530 100644 --- a/app/templates/results/transactions-table-grouped-by-settlement.hbs +++ b/app/templates/results/transactions-table-grouped-by-settlement.hbs @@ -13,22 +13,27 @@ {{/if}} - {{#each settlement_group in view.groupedResults}} + {{#each settlementGroup in view.groupedResults}} {{#view "results/grouped-transactions-table" embedded=view.embedded}} - {{view "results/grouped-transaction-row" item=settlement_group.settlement embedded=view.embedded}} + {{view "results/grouped-transaction-row" item=settlementGroup.settlement embedded=view.embedded}} + {{/view}} + {{#each orderGroup in settlementGroup.orderGroups}} + {{#view "results/grouped-transactions-table" embedded=view.embedded}} + {{view "results/grouped-transaction-row" item=orderGroup.order embedded=view.embedded}} - {{#each transaction in settlement_group.transactions}} - {{view "results/grouped-transaction-row" item=transaction embedded=view.embedded}} + {{#each transaction in orderGroup.transactions}} + {{view "results/grouped-transaction-row" item=transaction embedded=view.embedded}} - {{#if transaction.reversals}} - {{#each reversal in transaction.reversals}} - {{view "results/grouped-transaction-row" item=reversal embedded=view.embedded}} - {{/each}} - {{/if}} - {{/each}} - {{/view}} + {{#if transaction.reversals}} + {{#each reversal in transaction.reversals}} + {{view "results/grouped-transaction-row" item=reversal embedded=view.embedded}} + {{/each}} + {{/if}} + {{/each}} + {{/view}} + {{/each}} {{else}} diff --git a/app/views/results/transactions-table-grouped-by-order.js b/app/views/results/transactions-table-grouped-by-order.js index 75b5d4c77..c884dd2ae 100644 --- a/app/views/results/transactions-table-grouped-by-order.js +++ b/app/views/results/transactions-table-grouped-by-order.js @@ -29,7 +29,7 @@ var TransactionsTableGroupedByOrderView = TransactionsTableView.extend({ }); return groupedTransactions; - }.property("loader.results.length", "view.parentView.controller.settlementsResultsLoader.results"), + }.property("loader.results.length"), }); export default TransactionsTableGroupedByOrderView; diff --git a/app/views/results/transactions-table-grouped-by-settlement.js b/app/views/results/transactions-table-grouped-by-settlement.js index 37a72f587..fbe937c4b 100644 --- a/app/views/results/transactions-table-grouped-by-settlement.js +++ b/app/views/results/transactions-table-grouped-by-settlement.js @@ -17,17 +17,15 @@ var TransactionsTableGroupedBySettlement = ResultsTableView.extend({ settlements.forEach(function(settlement) { var promise = SearchModelArray.newArrayLoadedFromUri(settlement.get("credits_uri"), "credit"); promise.then(function(credits) { - // credits = self.groupCreditsByOrder(credits); - var settlementGroup = Ember.Object.create({ settlement_uri: settlement.get('uri'), settlement: settlement, - transactions: credits + orderGroups: self.groupCreditsByOrder(credits) }); groupedTransactions.pushObject(settlementGroup); }); }); - + console.log(groupedTransactions) return groupedTransactions; }.property("loader.results.length"), From 13cd4b4ff07357b4b6f8b83a742eee233c40dfb8 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Wed, 7 Jan 2015 18:12:57 -0800 Subject: [PATCH 13/80] Beautify --- app/views/results/transactions-table-grouped-by-settlement.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/results/transactions-table-grouped-by-settlement.js b/app/views/results/transactions-table-grouped-by-settlement.js index fbe937c4b..df94ba3c4 100644 --- a/app/views/results/transactions-table-grouped-by-settlement.js +++ b/app/views/results/transactions-table-grouped-by-settlement.js @@ -25,7 +25,7 @@ var TransactionsTableGroupedBySettlement = ResultsTableView.extend({ groupedTransactions.pushObject(settlementGroup); }); }); - console.log(groupedTransactions) + return groupedTransactions; }.property("loader.results.length"), From d1b3d6e20608b6b916a906567e02194c3397f28a Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Thu, 8 Jan 2015 13:16:32 -0800 Subject: [PATCH 14/80] Add tabs in the customer page --- app/templates/customer.hbs | 76 +++++++++++--------- app/templates/orders.hbs | 2 +- app/views/detail-views/main-panel.js | 3 +- app/views/detail-views/order-main-panel.js | 8 --- app/views/detail-views/tabs/order-tab.js | 18 ----- app/views/detail-views/tabs/tab.js | 24 +++++-- app/views/results/grouped-transaction-row.js | 22 ++---- 7 files changed, 70 insertions(+), 83 deletions(-) delete mode 100644 app/views/detail-views/order-main-panel.js diff --git a/app/templates/customer.hbs b/app/templates/customer.hbs index a2694989f..e9ed43f43 100644 --- a/app/templates/customer.hbs +++ b/app/templates/customer.hbs @@ -11,44 +11,52 @@ {{view "detail-views/description-lists/customer-titled-key-values-section" model=model}} {{view "meta-list" type=model}} {{/view}} - {{#view "detail-views/main-panel"}} -

Disputes

-
- {{view "results/embedded-disputes-table" loader=disputesResultsLoader}} -
+ {{#view "detail-views/main-panel" model=model}} + {{view "detail-views/tabs/customer-tab" model=model}} -

Payments

-
- {{view "results/embedded-transactions-table" loader=transactionsResultsLoader}} -
+ {{#if view.isActivityTabSelected}} +

Payments

+
+ {{view "results/embedded-transactions-table" loader=transactionsResultsLoader}} +
+ {{/if}} + {{#if view.isDisputesTabSelected}} +

Disputes

+
+ {{view "results/embedded-disputes-table" loader=disputesResultsLoader}} +
+ {{/if}} + {{#if view.isPaymentMethodsTabSelected}} + +

Cards & Bank accounts

+
+ {{view "results/embedded-funding-instruments-table" loader=fundingInstrumentsResultsLoader}} +
- -

Cards & Bank accounts

-
- {{view "results/embedded-funding-instruments-table" loader=fundingInstrumentsResultsLoader}} -
+

Internal accounts

+
+ {{view "results/embedded-internal-accounts-table" loader=accountsResultsLoader}} +
+ {{/if}} -

Internal accounts

-
- {{view "results/embedded-internal-accounts-table" loader=accountsResultsLoader}} -
+ {{#if view.isLogsEventsTabSelected}} +

Logs

+
+ {{view "resource-logs" content=model}} +
-

Logs

-
- {{view "resource-logs" content=model}} -
- -

Events

-
- {{view "resource-events" content=model}} -
+

Events

+
+ {{view "resource-events" content=model}} +
+ {{/if}} {{/view}} {{/view}} diff --git a/app/templates/orders.hbs b/app/templates/orders.hbs index dd11245c3..06babc8a8 100644 --- a/app/templates/orders.hbs +++ b/app/templates/orders.hbs @@ -13,7 +13,7 @@ {{view "meta-list" type=model}} {{/view}} - {{#view "detail-views/order-main-panel" model=model}} + {{#view "detail-views/main-panel" model=model}} {{view "detail-views/tabs/order-tab" model=model}} {{#if view.isActivityTabSelected}} diff --git a/app/views/detail-views/main-panel.js b/app/views/detail-views/main-panel.js index 0fc1e9e26..f47e6f8d8 100644 --- a/app/views/detail-views/main-panel.js +++ b/app/views/detail-views/main-panel.js @@ -1,7 +1,8 @@ import Ember from "ember"; var MainPanelView = Ember.View.extend({ - classNameBindings: [":main-panel", ":span"] + classNameBindings: [":main-panel", ":span"], + isActivityTabSelected: true }); export default MainPanelView; diff --git a/app/views/detail-views/order-main-panel.js b/app/views/detail-views/order-main-panel.js deleted file mode 100644 index 34dcaa3ed..000000000 --- a/app/views/detail-views/order-main-panel.js +++ /dev/null @@ -1,8 +0,0 @@ -import Ember from "ember"; -import MainPanelView from "./main-panel"; - -var OrderMainPanelView = MainPanelView.extend({ - isActivityTabSelected: true -}); - -export default OrderMainPanelView; diff --git a/app/views/detail-views/tabs/order-tab.js b/app/views/detail-views/tabs/order-tab.js index 76fc936fe..44c0281e5 100644 --- a/app/views/detail-views/tabs/order-tab.js +++ b/app/views/detail-views/tabs/order-tab.js @@ -8,24 +8,6 @@ var OrderTabView = TabView.extend({ defineFilter("Logs & Events", "logsEvents"), ]; }.property(), - - actions: { - setTab: function(tabLink) { - if (tabLink.value === "activity") { - this.get("parentView").setProperties({ - "isActivityTabSelected": true, - "isLogsEventsTabSelected": false - }); - } else if (tabLink.value === "logsEvents") { - this.get("parentView").setProperties({ - "isActivityTabSelected": false, - "isLogsEventsTabSelected": true - }); - } - - this.toggleSelected(tabLink); - } - } }); export default OrderTabView; diff --git a/app/views/detail-views/tabs/tab.js b/app/views/detail-views/tabs/tab.js index e8a2838f3..b413b2223 100644 --- a/app/views/detail-views/tabs/tab.js +++ b/app/views/detail-views/tabs/tab.js @@ -1,15 +1,27 @@ +import Utils from 'balanced-dashboard/lib/utils'; + var TabView = Ember.View.extend({ templateName: "detail-views/tab", isSelected: false, - toggleSelected: function(tabLink) { - var tabs = this.get("tabs"); - tabs.map(function(tab) { - tab.set("isSelected", false); - }); + actions: { + setTab: function(tabLink) { + var self = this; + var tabs = this.get("tabs"); + var isTabSelected = ""; + + tabs.map(function(tab) { + isTabSelected = "is%@TabSelected".fmt(Utils.capitalize(tab.value)); + self.get("parentView").set(isTabSelected, false); + tab.set("isSelected", false); + }); - tabLink.set("isSelected", true); + isTabSelected = "is%@TabSelected".fmt(Utils.capitalize(tabLink.value)); + this.get("parentView").set(isTabSelected, true); + tabLink.set("isSelected", true); + } } + }); export default TabView; diff --git a/app/views/results/grouped-transaction-row.js b/app/views/results/grouped-transaction-row.js index cbdcebff9..a0efb77f5 100644 --- a/app/views/results/grouped-transaction-row.js +++ b/app/views/results/grouped-transaction-row.js @@ -17,11 +17,6 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ return this.get("primaryLabelText"); }.property("primaryLabelText"), - bankAccount: function() { - var BankAccount = this.container.lookupFactory("model:bank-account"); - return BankAccount.find(this.get("item.destination_uri")); - }.property("item.destination_uri"), - primaryLabelText: function() { if (_.contains(this.get("classNames"), "current")) { return '%@ (currently viewing)'.fmt(this.get('item.type_name')); @@ -47,24 +42,21 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ return Utils.humanReadableDateTime(this.get('item.created_at')); }.property('item.created_at'), + bankAccount: function() { + var BankAccount = this.container.lookupFactory("model:bank-account"); + return BankAccount.find(this.get("item.destination_uri")); + }.property("item.destination_uri"), + + customer: Ember.computed.reads("bankAccount.customer"), + customerText: function() { if (this.get('item.type_name') === "Settlement") { - console.log(this.get("settlementCustomerText")) return this.get("settlementCustomerText"); } else { return this.get("item.customer.display_me"); } }.property("item.customer.display_me", "settlementCustomerText"), - // customer: function() { - // var self = this; - // this.get("bankAccount").then(function(bankAccount) { - // var customer = self.container.lookupFactory("model:customer").find(bankAccount.get("customer_uri")); - // return customer; - // }); - // }.property("bankAccount", "bankAccount.customer_uri"), - customer: Ember.computed.reads("bankAccount.customer"), - settlementCustomerText: function() { var label = '%@%@'; var primaryLabel = this.get("customer.display_me"); From 87d0e2f8f053f293793b5ba03f039f0221a61c7d Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Thu, 8 Jan 2015 14:12:09 -0800 Subject: [PATCH 15/80] Add tabs in the customer page --- app/views/detail-views/tabs/customer-tab.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 app/views/detail-views/tabs/customer-tab.js diff --git a/app/views/detail-views/tabs/customer-tab.js b/app/views/detail-views/tabs/customer-tab.js new file mode 100644 index 000000000..aa7e05a30 --- /dev/null +++ b/app/views/detail-views/tabs/customer-tab.js @@ -0,0 +1,15 @@ +import { defineFilter } from "balanced-dashboard/views/results/results-dropdown-filter"; +import TabView from "./tab"; + +var CustomerTabView = TabView.extend({ + tabs: function(){ + return [ + defineFilter("Activity", "activity", true), + defineFilter("Disputes", "disputes"), + defineFilter("Payment methods", "paymentMethods"), + defineFilter("Logs & Events", "logsEvents"), + ]; + }.property(), +}); + +export default CustomerTabView; From b1d3233ba8a3e2dc5d37f8ce74b5ab5eff91d4cd Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Thu, 8 Jan 2015 14:12:31 -0800 Subject: [PATCH 16/80] Display payable account balance in the customer page --- app/models/customer.js | 2 ++ app/templates/customer.hbs | 2 +- .../resource-summary-base.coffee | 2 +- .../summary-sections/customer-summary-section.js | 4 ++++ .../summary-sections/summary-section.js | 15 ++++++++++++--- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/app/models/customer.js b/app/models/customer.js index 2a347ed63..ad938f7c9 100644 --- a/app/models/customer.js +++ b/app/models/customer.js @@ -25,6 +25,8 @@ var Customer = Model.extend({ type_name: 'Customer', has_bank_account: Ember.computed.and('bank_accounts.isLoaded', 'bank_accounts.length'), + account: Ember.computed.reads("accountsResultsLoader.results.content.0"), + accountBalance: Ember.computed.reads("accountsResultsLoader.results.content.0.balance"), orders_list: function() { var customer_uri = this.get('href'); diff --git a/app/templates/customer.hbs b/app/templates/customer.hbs index e9ed43f43..334afb250 100644 --- a/app/templates/customer.hbs +++ b/app/templates/customer.hbs @@ -17,7 +17,7 @@ {{#if view.isActivityTabSelected}}

Payments

- {{view "results/embedded-transactions-table" loader=transactionsResultsLoader}} + {{view "results/transactions-table-grouped-by-order" loader=transactionsResultsLoader embedded=true}}
{{/if}} {{#if view.isDisputesTabSelected}} diff --git a/app/views/detail-views/resource-summaries/resource-summary-base.coffee b/app/views/detail-views/resource-summaries/resource-summary-base.coffee index da0d87eae..3b860fe94 100644 --- a/app/views/detail-views/resource-summaries/resource-summary-base.coffee +++ b/app/views/detail-views/resource-summaries/resource-summary-base.coffee @@ -21,7 +21,7 @@ ResourceSummaryBase = Ember.View.extend( else if @isType("bank-account") "#{model.get('last_four')} #{model.get('formatted_bank_name')}" else if @isType("bk/account") - "Payable account" + "Payable account: #{model.get('balance')}" else null ).property("model.amount_escrowed", "model.amount", "model.display_me", "model.last_four", "model.brand", "model.formatted_bank_name") diff --git a/app/views/detail-views/summary-sections/customer-summary-section.js b/app/views/detail-views/summary-sections/customer-summary-section.js index 91c912464..039412023 100644 --- a/app/views/detail-views/summary-sections/customer-summary-section.js +++ b/app/views/detail-views/summary-sections/customer-summary-section.js @@ -14,6 +14,10 @@ var CustomerSummarySectionView = SummarySectionView.extend({ text: "For an individual, you may collect full legal name, email, permanent street address, and last four digits of SSN. For a business, we also recommend collecting the full business name and EIN number." }; }.property(), + + linkedResources: function() { + return this.resourceLinks("model.account"); + }.property("model.account") }); export default CustomerSummarySectionView; diff --git a/app/views/detail-views/summary-sections/summary-section.js b/app/views/detail-views/summary-sections/summary-section.js index 9c7e7bd9a..96241df51 100644 --- a/app/views/detail-views/summary-sections/summary-section.js +++ b/app/views/detail-views/summary-sections/summary-section.js @@ -148,12 +148,21 @@ var SummarySectionView = Ember.View.extend({ }; } + if (model.constructor === BankAccount) { + return { + className: 'icon-bank-account', + title: model.get('type_name').split(' ')[0], + resource: model, + }; + } + if (parentModel.routeName === 'settlement') { var title = ""; var className = ""; if (model.routeName === 'account') { title = "From"; + className = "icon-payable-account"; } else if (model.route_name === 'bank_accounts') { title = "To"; className = "icon-bank-account"; @@ -166,10 +175,10 @@ var SummarySectionView = Ember.View.extend({ }; } - if (model.constructor === BankAccount) { + if (model.routeName === 'account') { return { - className: 'icon-bank-account', - title: model.get('type_name').split(' ')[0], + className: 'icon-payable-account', + title: model.get('type_name'), resource: model, }; } From 3a3b0107b5ecb2cf5151d6ca16bcbc4aa3d2ef52 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Thu, 8 Jan 2015 14:38:04 -0800 Subject: [PATCH 17/80] Update search to include settlements --- app/lib/utils.js | 47 ------------------- app/models/marketplace.js | 13 ----- .../results-loaders/marketplace-search.js | 14 ++---- app/utils/constants.js | 6 ++- 4 files changed, 9 insertions(+), 71 deletions(-) diff --git a/app/lib/utils.js b/app/lib/utils.js index 69f432c2d..a49cdb75d 100644 --- a/app/lib/utils.js +++ b/app/lib/utils.js @@ -239,53 +239,6 @@ var Utils = Ember.Namespace.create({ } }, - applyUriFilters: function(uri, params) { - if (!uri) { - return uri; - } - - var transformedParams = ['limit', 'offset', 'sortField', 'sortOrder', 'minDate', 'maxDate', 'type', 'query']; - - var filteringParams = { - limit: params.limit || 10, - offset: params.offset || 0 - }; - - if (params.sortField && params.sortOrder && params.sortOrder !== 'none') { - filteringParams.sort = params.sortField + ',' + params.sortOrder; - } - - if (params.minDate) { - filteringParams['created_at[>]'] = params.minDate.toISOString(); - } - if (params.maxDate) { - filteringParams['created_at[<]'] = params.maxDate.toISOString(); - } - if (params.type) { - switch (params.type) { - case 'search': - filteringParams['type[in]'] = Constants.SEARCH.SEARCH_TYPES.join(','); - break; - case 'transaction': - filteringParams['type[in]'] = Constants.SEARCH.TRANSACTION_TYPES.join(','); - break; - case 'funding_instrument': - filteringParams['type[in]'] = Constants.SEARCH.FUNDING_INSTRUMENT_TYPES.join(','); - break; - default: - filteringParams.type = params.type; - } - } - filteringParams.q = ''; - if (params.query && params.query !== '%') { - filteringParams.q = params.query; - } - - filteringParams = _.extend(filteringParams, _.omit(params, transformedParams)); - filteringParams = Utils.sortDict(filteringParams); - return this.buildUri(uri, filteringParams); - }, - buildUri: function(path, queryStringObject) { var queryString = _.isString(queryStringObject) ? queryStringObject : diff --git a/app/models/marketplace.js b/app/models/marketplace.js index ea6c6b6eb..fc075a727 100644 --- a/app/models/marketplace.js +++ b/app/models/marketplace.js @@ -85,19 +85,6 @@ var Marketplace = UserMarketplace.extend({ }); }, - search: function(query, resultsType, params) { - var baseUri = this.get("uri") + "/search"; - var searchParams = _.extend({ - sortField: "created_at", - sortOrder: "desc", - limit: 10, - query: query - }, params); - - var resultsUri = Utils.applyUriFilters(baseUri, searchParams); - return SearchModelArray.newArrayLoadedFromUri(resultsUri, resultsType); - }, - has_debitable_bank_account: Ember.computed.readOnly('owner_customer.has_debitable_bank_account'), has_bank_account: Ember.computed.readOnly('owner_customer.has_bank_account'), diff --git a/app/models/results-loaders/marketplace-search.js b/app/models/results-loaders/marketplace-search.js index 7382ed10b..e3475bd2a 100644 --- a/app/models/results-loaders/marketplace-search.js +++ b/app/models/results-loaders/marketplace-search.js @@ -5,11 +5,7 @@ import FundingInstrument from "../funding-instrument"; import Customer from "../customer"; import Order from "../order"; import SearchModelArray from "../core/search-model-array"; - -var TRANSACTION_TYPES = ["credit", "debit", "card_hold", "refund", "reversal"]; -var FUNDING_INSTRUMENT_TYPES = ["card", "bank_account"]; -var CUSTOMER_TYPES = ["customer"]; -var ORDER_TYPES = ["order"]; +import Constants from "balanced-dashboard/utils/constants"; var MarketplaceSearchResultsLoader = BaseResultsLoader.extend({ searchType: "transaction", @@ -17,12 +13,12 @@ var MarketplaceSearchResultsLoader = BaseResultsLoader.extend({ type: function() { var mapping = { - "funding_instrument": FUNDING_INSTRUMENT_TYPES, - "customer": CUSTOMER_TYPES, - "order": ORDER_TYPES + "funding_instrument": Constants.SEARCH.FUNDING_INSTRUMENT_TYPES, + "customer": Constants.SEARCH.CUSTOMER_TYPES, + "order": Constants.SEARCH.ORDER_TYPES }; - return mapping[this.get("searchType")] || TRANSACTION_TYPES; + return mapping[this.get("searchType")] || Constants.SEARCH.SEARCH_TYPES; }.property("searchType"), resultsType: function() { diff --git a/app/utils/constants.js b/app/utils/constants.js index f340fec3f..a2925b271 100644 --- a/app/utils/constants.js +++ b/app/utils/constants.js @@ -22,10 +22,12 @@ Constants.BANK_ACCOUNT_TYPES = [{ Constants.SEARCH = { CATEGORIES: ['order', 'transaction', 'search', 'customer', 'funding_instrument', 'dispute'], - SEARCH_TYPES: ['debit', 'credit', 'card_hold', 'refund', "reversal"], + SEARCH_TYPES: ['debit', 'credit', 'card_hold', 'refund', "reversal", 'settlement'], TRANSACTION_TYPES: ['debit', 'credit', 'hold', 'refund'], FUNDING_INSTRUMENT_TYPES: ['bank_account', 'card'], - DISPUTE_TYPES: ['pending', 'won', 'lost', 'arbitration'] + DISPUTE_TYPES: ['pending', 'won', 'lost', 'arbitration'], + CUSTOMER_TYPES: ["customer"], + ORDER_TYPES: ["order"] }; // time in ms to throttle between key presses for search From ffd40fb5ea687d30344501800defae628e9cda01 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Thu, 8 Jan 2015 14:47:57 -0800 Subject: [PATCH 18/80] Update transactions grouped by order table --- app/styles/results.less | 3 +-- app/templates/results/transactions-table-grouped-by-order.hbs | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/styles/results.less b/app/styles/results.less index 1a3c0fb13..afe2c2d4b 100644 --- a/app/styles/results.less +++ b/app/styles/results.less @@ -298,8 +298,7 @@ header.results-label h3 { } a > span.failed:before { - float: left; - margin-top: 14px; + margin-bottom: 10px; } } diff --git a/app/templates/results/transactions-table-grouped-by-order.hbs b/app/templates/results/transactions-table-grouped-by-order.hbs index 5bba1fca4..2d5dcccd2 100644 --- a/app/templates/results/transactions-table-grouped-by-order.hbs +++ b/app/templates/results/transactions-table-grouped-by-order.hbs @@ -18,7 +18,8 @@ {{#view "results/grouped-transactions-table" embedded=view.embedded}} {{view "results/grouped-transaction-row" item=order_group.order embedded=view.embedded}} - + {{/view}} + {{#view "results/grouped-transactions-table" embedded=view.embedded}} {{#each transaction in order_group.transactions}} {{view "results/grouped-transaction-row" item=transaction embedded=view.embedded}} From a434c70a503990bb73ceaa5fd639750b9095e84d Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Thu, 8 Jan 2015 18:27:23 -0800 Subject: [PATCH 19/80] Polish accounts and settlements pages --- app/controllers/marketplace.js | 2 +- app/templates/account.hbs | 12 +++------- .../resource-summary-base.coffee | 7 ++++-- .../account-summary-section.js | 4 ++-- .../summary-sections/summary-section.js | 22 +++++++++---------- app/views/results/grouped-transaction-row.js | 8 +++++-- 6 files changed, 28 insertions(+), 27 deletions(-) diff --git a/app/controllers/marketplace.js b/app/controllers/marketplace.js index d33646631..62af1c641 100644 --- a/app/controllers/marketplace.js +++ b/app/controllers/marketplace.js @@ -30,7 +30,7 @@ var MarketplaceController = Ember.ObjectController.extend({ settlementSelected: isSelected('marketplace.settlements', 'settlement'), disputeSelected: isSelected('marketplace.disputes', 'dispute'), customerSelected: isSelected('marketplace.customers', 'customer'), - fundingInstrumentSelected: isSelected('marketplace.funding_instruments', 'bank_accounts', 'cards', 'accounts'), + fundingInstrumentSelected: isSelected('marketplace.funding_instruments', 'bank_accounts', 'cards', 'account'), logSelected: isSelected('marketplace.logs', 'log'), invoiceSelected: isSelected('marketplace.invoices', 'invoice'), settingSelected: isSelected('marketplace.settings'), diff --git a/app/templates/account.hbs b/app/templates/account.hbs index e963200eb..c3302a51c 100644 --- a/app/templates/account.hbs +++ b/app/templates/account.hbs @@ -2,6 +2,9 @@ {{#view "detail-views/body-panel"}} {{#view "detail-views/api-model-panel" model=model}} + {{view detail-views/summary-sections/account-summary-section model=model}} {{view detail-views/description-lists/account-titled-key-values-section model=model}} {{view "meta-list" type=model}} @@ -16,14 +19,5 @@
{{view "results/transactions-table-grouped-by-settlement" loader=settlementsResultsLoader embedded=true}}
-

Logs

-
- {{view "resource-logs" content=model}} -
- -

Events

-
- {{view "resource-events" content=model}} -
{{/view}} {{/view}} diff --git a/app/views/detail-views/resource-summaries/resource-summary-base.coffee b/app/views/detail-views/resource-summaries/resource-summary-base.coffee index 3b860fe94..12932a103 100644 --- a/app/views/detail-views/resource-summaries/resource-summary-base.coffee +++ b/app/views/detail-views/resource-summaries/resource-summary-base.coffee @@ -16,12 +16,15 @@ ResourceSummaryBase = Ember.View.extend( else if @isType("customer") model.get("display_me") else if @isType("card") - console.log(model) "#{model.get('last_four')} #{model.get('brand')}" else if @isType("bank-account") "#{model.get('last_four')} #{model.get('formatted_bank_name')}" else if @isType("bk/account") - "Payable account: #{model.get('balance')}" + currentRoute = @container.lookup("controller:application").get('currentRouteName') + if currentRoute == "settlement" + "Payable account" + else + "Balance: $%@".fmt(Utils.centsToDollars(model.get('balance'))) else null ).property("model.amount_escrowed", "model.amount", "model.display_me", "model.last_four", "model.brand", "model.formatted_bank_name") diff --git a/app/views/detail-views/summary-sections/account-summary-section.js b/app/views/detail-views/summary-sections/account-summary-section.js index 2b4d08d61..d95af371f 100644 --- a/app/views/detail-views/summary-sections/account-summary-section.js +++ b/app/views/detail-views/summary-sections/account-summary-section.js @@ -3,8 +3,8 @@ import Utils from "balanced-dashboard/lib/utils"; var AccountSummarySectionView = SummarySectionView.extend({ linkedResources: function() { - return this.resourceLinks("model.balance", "model.customer"); - }.property('model.balance', 'model.customer'), + return this.resourceLinks("model.customer"); + }.property('model.customer'), }); export default AccountSummarySectionView; diff --git a/app/views/detail-views/summary-sections/summary-section.js b/app/views/detail-views/summary-sections/summary-section.js index 96241df51..8805ece8a 100644 --- a/app/views/detail-views/summary-sections/summary-section.js +++ b/app/views/detail-views/summary-sections/summary-section.js @@ -61,7 +61,9 @@ var SummarySectionView = Ember.View.extend({ var Refund = this.get("container").lookupFactory("model:refund"); var Reversal = this.get("container").lookupFactory("model:reversal"); - var title; + var title = ""; + var className = ""; + if (Ember.isBlank(model) || parentModel.uri === model.uri) { return; } @@ -148,18 +150,8 @@ var SummarySectionView = Ember.View.extend({ }; } - if (model.constructor === BankAccount) { - return { - className: 'icon-bank-account', - title: model.get('type_name').split(' ')[0], - resource: model, - }; - } if (parentModel.routeName === 'settlement') { - var title = ""; - var className = ""; - if (model.routeName === 'account') { title = "From"; className = "icon-payable-account"; @@ -182,6 +174,14 @@ var SummarySectionView = Ember.View.extend({ resource: model, }; } + + if (model.constructor === BankAccount) { + return { + className: 'icon-bank-account', + title: model.get('type_name').split(' ')[0], + resource: model, + }; + } } }); diff --git a/app/views/results/grouped-transaction-row.js b/app/views/results/grouped-transaction-row.js index a0efb77f5..300fcf12b 100644 --- a/app/views/results/grouped-transaction-row.js +++ b/app/views/results/grouped-transaction-row.js @@ -101,8 +101,12 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ }.property('item.destination.funding_instrument_type'), amountText: function() { - return Utils.formatCurrency(this.get("item.amount")); - }.property("item.amount") + var amount = this.get("item.amount"); + if (this.get("item.type_name") === "Order") { + amount = this.get("item.amount_escrowed"); + } + return Utils.formatCurrency(amount); + }.property("item.amount", "item.type_name") }); export default GroupedTransactionRowView; From 1003a93ee914d136562863100ffa1b5ab6712722 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Fri, 9 Jan 2015 12:38:42 -0800 Subject: [PATCH 20/80] Fix tables in the order page --- app/templates/orders.hbs | 4 ++-- .../transactions-table-grouped-by-customer.hbs | 14 +++++++------- app/views/results/grouped-transaction-row.js | 10 ++++++---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/templates/orders.hbs b/app/templates/orders.hbs index 06babc8a8..079eb10f7 100644 --- a/app/templates/orders.hbs +++ b/app/templates/orders.hbs @@ -19,12 +19,12 @@ {{#if view.isActivityTabSelected}}

Charges

- {{view "results/transactions-table-grouped-by-customer" loader=debitsResultsLoader customers=model.buyers}} + {{view "results/transactions-table-grouped-by-customer" loader=debitsResultsLoader customers=model.buyers embedded=true}}

Payouts

- {{view "results/transactions-table-grouped-by-customer" loader=creditsResultsLoader customers=model.seller}} + {{view "results/transactions-table-grouped-by-customer" loader=creditsResultsLoader customers=model.seller embedded=true}}
{{/if}} diff --git a/app/templates/results/transactions-table-grouped-by-customer.hbs b/app/templates/results/transactions-table-grouped-by-customer.hbs index e4c2653c4..6b18fa4ba 100644 --- a/app/templates/results/transactions-table-grouped-by-customer.hbs +++ b/app/templates/results/transactions-table-grouped-by-customer.hbs @@ -25,28 +25,28 @@ title=customer_group.customer.display_me_with_email class="customer-group two-lines" }} - + {{#each transaction in customer_group.transactions}} - {{#view "results/grouped-transactions-table"}} + {{#view "results/grouped-transactions-table" embedded=view.embedded}} {{#if transaction.dispute}} - {{view "results/grouped-transaction-row" item=transaction.dispute}} + {{view "results/grouped-transaction-row" item=transaction.dispute embedded=view.embedded}} {{/if}} - {{view "results/grouped-transaction-row" item=transaction}} + {{view "results/grouped-transaction-row" item=transaction embedded=view.embedded}} {{#if transaction.hold}} - {{view "results/grouped-transaction-row" item=transaction.hold}} + {{view "results/grouped-transaction-row" item=transaction.hold embedded=view.embedded}} {{/if}} {{#if transaction.refunds}} {{#each refund in transaction.refunds}} - {{view "results/grouped-transaction-row" item=refund}} + {{view "results/grouped-transaction-row" item=refund embedded=view.embedded}} {{/each}} {{/if}} {{#if transaction.reversals}} {{#each reversal in transaction.reversals}} - {{view "results/grouped-transaction-row" item=reversal}} + {{view "results/grouped-transaction-row" item=reversal embedded=view.embedded}} {{/each}} {{/if}} {{/view}} diff --git a/app/views/results/grouped-transaction-row.js b/app/views/results/grouped-transaction-row.js index 300fcf12b..4db988e4d 100644 --- a/app/views/results/grouped-transaction-row.js +++ b/app/views/results/grouped-transaction-row.js @@ -85,20 +85,22 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ paymentMethodPrimaryLabelText: function() { if (this.get("item.destination.type") === "payable") { return this.get("item.destination.id"); + } else if (this.get("item.source")) { + return "%@ %@".fmt(this.get("item.source.last_four"), this.get("item.source.brand")); } else { return "%@ %@".fmt(this.get("item.destination.last_four"), this.get("item.destination.brand")); } - - }.property("item.destination.id", "item.destination.last_four", "item.destination.brand"), + }.property("item.source.id", "item.source.last_four", "item.source.brand", "item.destination.id", "item.destination.last_four", "item.destination.brand"), paymentMethodSecondaryLabelText: function() { if (this.get("item.destination.type") === "payable") { return "Payable account"; + } else if (this.get("item.source")) { + return this.get('item.source.funding_instrument_type'); } else { return this.get('item.destination.funding_instrument_type'); } - - }.property('item.destination.funding_instrument_type'), + }.property('item.source.funding_instrument_type', 'item.destination.funding_instrument_type'), amountText: function() { var amount = this.get("item.amount"); From 202206e504dbe556221b6b06de9304c22f49904c Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Fri, 9 Jan 2015 12:39:04 -0800 Subject: [PATCH 21/80] Increase the order icon size and fix alignments --- app/styles/results.less | 49 +++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/app/styles/results.less b/app/styles/results.less index afe2c2d4b..8509fb87e 100644 --- a/app/styles/results.less +++ b/app/styles/results.less @@ -153,20 +153,24 @@ header.results-label h3 { table.grouped-transactions:first-of-type { border-bottom: none; - td.status { - &:first-of-type { - padding-left: 25px; - } + td:first-of-type { + padding-left: 25px; } } table.grouped-transactions { border-bottom: none; - td.status { - &:first-of-type { - padding-left: 50px; - } + td:first-of-type { + padding-left: 50px; + } + } + } + + &.divided { + table.grouped-transactions { + td:first-of-type { + padding-left: 10px; } } } @@ -200,6 +204,7 @@ header.results-label h3 { } } } + td { a.active { pointer-events: none; @@ -210,16 +215,22 @@ header.results-label h3 { } } + &:first-of-type { + padding-left: 25px; + } + &.status { text-transform: none; padding-left: 10px; - &:first-of-type { - padding-left: 25px; - } + & > a > span { + &:before { + margin-left: 2px; + } - a > span > .secondary { - margin-left: 14px; + & > .primary, & > .secondary { + margin-left: 16px; + } } &.orders > a > span { @@ -227,12 +238,10 @@ header.results-label h3 { font-family: 'Balanced-Icon'; background-color: transparent; &:extend(.icon-orders:before); - font-size: 10px; + font-size: 12px; color: @gray4; margin-top: -14px; - } - > .primary { - margin-left: 14px; + margin-left: 0; } } @@ -261,10 +270,6 @@ header.results-label h3 { &.lost:before { color: @imperialRed80; } - - > .primary { - margin-left: 14px; - } } a > span:after { @@ -273,7 +278,7 @@ header.results-label h3 { border-left: 2px solid @gray3; height: 30px; margin-top: -19px; - margin-left: 3px; + margin-left: 5px; } } } From 056b6dfe4437a1cb01897527b40e54fb99bc5287 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Tue, 13 Jan 2015 14:34:13 -0800 Subject: [PATCH 22/80] Update balanced addon model version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6f2d5424d..ebce9f6cf 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "repository": "git@github.com:balanced/balanced-dashboard.git", "author": "Balanced ", "devDependencies": { - "balanced-addon-models": "0.0.3", + "balanced-addon-models": "git://github.com/balanced/balanced-addon-models", "body-parser": "1.2.0", "bower": "1.3.12", "broccoli-asset-rev": "0.3.1", From e5cb42a55b789b8bd7b1eb3feaa28488abff80a7 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Tue, 13 Jan 2015 14:34:36 -0800 Subject: [PATCH 23/80] Update accounts and settlements tables --- app/models/core/search-model-array.js | 1 + app/styles/results.less | 24 ++++++ app/templates/modals/search-modal.hbs | 16 ++++ app/templates/results/accounts-table.hbs | 71 ++++++++++++++++ .../results/embedded-transactions-table.hbs | 82 +++++++++++++------ .../results/grouped-transaction-row.hbs | 2 +- .../transactions-table-grouped-by-order.hbs | 49 +++++++---- app/utils/constants.js | 2 +- app/views/modals/search-modal.coffee | 4 + app/views/results/accounts-table.js | 8 ++ .../transactions-table-grouped-by-order.js | 5 +- 11 files changed, 218 insertions(+), 46 deletions(-) create mode 100644 app/templates/results/accounts-table.hbs create mode 100644 app/views/results/accounts-table.js diff --git a/app/models/core/search-model-array.js b/app/models/core/search-model-array.js index 639e85168..3b12aa4b3 100644 --- a/app/models/core/search-model-array.js +++ b/app/models/core/search-model-array.js @@ -18,6 +18,7 @@ var SearchModelArray = ModelArray.extend(Ember.SortableMixin, { total_disputes: readOnly('dispute'), total_transactions: Computed.sumAll('total_credits', 'total_debits', 'total_card_holds', 'total_refunds'), total_funding_instruments: Computed.sumAll('total_bank_accounts', 'total_cards'), + total_settlements: readOnly('settlement'), total_results: Computed.sumAll('total_orders', 'total_transactions', 'total_funding_instruments', 'total_customers') }); diff --git a/app/styles/results.less b/app/styles/results.less index 8509fb87e..599cbe35e 100644 --- a/app/styles/results.less +++ b/app/styles/results.less @@ -145,6 +145,30 @@ header.results-label h3 { } } + td.ungrouped-transactions-container { + padding-left: 0; + padding-right: 0; + + table.grouped-transactions { + border-bottom: none; + + thead { + border: none; + margin-top: -1px; + } + + tr { + &:last-of-type { + border-bottom: none; + } + + &:hover { + background-color: @persianBlue10; + } + } + } + } + td.grouped-transactions-container { padding-left: 0; padding-right: 0; diff --git a/app/templates/modals/search-modal.hbs b/app/templates/modals/search-modal.hbs index f67a560cc..2b48af91e 100644 --- a/app/templates/modals/search-modal.hbs +++ b/app/templates/modals/search-modal.hbs @@ -16,6 +16,14 @@ {{format-number view.totalFundingInstruments}} Payment methods +
  • + {{format-number view.totalAccounts}} Accounts +
  • + +
  • + {{format-number view.totalSettlements}} Settlements +
  • +
  • {{format-number view.totalLogs}} Logs
  • @@ -43,6 +51,14 @@ {{view "results/funding-instruments-table" loader=view.resultsLoader isSearch=true}} {{/if}} + {{#if view.isAccountsTabSelected}} + {{view "results/accounts-table" loader=view.resultsLoader isSearch=true}} + {{/if}} + + {{#if view.isSettlementsTabSelected}} + {{view "results/transactions-table" loader=view.resultsLoader isSearch=true}} + {{/if}} + {{#if view.isLogsTabSelected}} {{view "results/logs-table" loader=view.logsResultsLoader isSearch=true}} {{/if}} diff --git a/app/templates/results/accounts-table.hbs b/app/templates/results/accounts-table.hbs new file mode 100644 index 000000000..c15bad498 --- /dev/null +++ b/app/templates/results/accounts-table.hbs @@ -0,0 +1,71 @@ + + + + {{#if view.isSearch}} + {{#view "results/search-results-loader-sort-column-header" resultsLoader=view.loader field="created_at" actionName="changeSortOrder"}} + Date + {{/view}} + {{else}} + {{#view "results/results-loader-sort-column-header" resultsLoader=view.loader field="created_at" actionName="changeSortOrder"}} + Date + {{/view}} + {{/if}} + + Payment method + Customer + Balance + + + +{{#if view.loader.results.hasNextPage}} + {{view "results/results-load-more" results=view.loader.results columns=6}} +{{/if}} + + + {{#each funding_instrument in view.loader.results}} + + + {{funding_instrument.routeName}} + {{#link-to funding_instrument.routeName funding_instrument}} + + {{/link-to}} + + + {{#link-to funding_instrument.routeName funding_instrument}} + {{funding_instrument.id}} + {{sentence-case funding_instrument.type}} account + {{/link-to}} + + + {{#link-to funding_instrument.routeName funding_instrument}} + {{#if funding_instrument.customer.display_me}} + {{funding_instrument.customer.display_me}} + {{#if funding_instrument.customer.email}} + {{funding_instrument.customer.email}} + {{/if}} + {{else}} + none + {{/if}} + {{/link-to}} + + + {{#link-to funding_instrument.routeName funding_instrument}} + {{format-currency funding_instrument.balance}} + {{/link-to}} + + + {{else}} + + + {{#if view.loader.results.isLoaded}} + No accounts + {{else}} + Loading... + {{/if}} + + + {{/each}} + diff --git a/app/templates/results/embedded-transactions-table.hbs b/app/templates/results/embedded-transactions-table.hbs index 33dfef157..65831c26a 100644 --- a/app/templates/results/embedded-transactions-table.hbs +++ b/app/templates/results/embedded-transactions-table.hbs @@ -18,39 +18,69 @@ {{#each transaction in view.filteredResults}} - - {{#view "results/grouped-transactions-table" embedded=true}} - {{#if transaction.order}} + {{#if transaction.order}} + + {{#view "results/grouped-transactions-table" embedded=true}} {{view "results/grouped-order-row" item=transaction.order embedded=true}} - {{/if}} + {{/view}} + {{#view "results/grouped-transactions-table" embedded=view.embedded}} + {{#if transaction.dispute}} + {{view "results/grouped-transaction-row" item=transaction.dispute embedded=true}} + {{/if}} - {{#if transaction.dispute}} - {{view "results/grouped-transaction-row" item=transaction.dispute embedded=true}} - {{/if}} + {{#if transaction.refunds}} + {{#each refund in transaction.refunds}} + {{view "results/grouped-transaction-row" item=refund embedded=true}} + {{/each}} + {{/if}} - {{#if transaction.refunds}} - {{#each refund in transaction.refunds}} - {{view "results/grouped-transaction-row" item=refund embedded=true}} - {{/each}} - {{/if}} + {{#if transaction.reversals}} + {{#each reversal in transaction.reversals}} + {{view "results/grouped-transaction-row" item=reversal embedded=true}} + {{/each}} + {{/if}} - {{#if transaction.reversals}} - {{#each reversal in transaction.reversals}} - {{view "results/grouped-transaction-row" item=reversal embedded=true}} - {{/each}} - {{/if}} + {{view "results/grouped-transaction-row" item=transaction embedded=true}} - {{view "results/grouped-transaction-row" item=transaction embedded=true}} + {{#if transaction.transaction}} + {{view "results/grouped-transaction-row" item=transaction.transaction}} + {{/if}} - {{#if transaction.transaction}} - {{view "results/grouped-transaction-row" item=transaction.transaction}} - {{/if}} + {{#if transaction.hold}} + {{view "results/grouped-transaction-row" item=transaction.hold embedded=true}} + {{/if}} + {{/view}} + {{else}} + + {{#view "results/grouped-transactions-table" embedded=view.embedded}} + {{#if transaction.dispute}} + {{view "results/grouped-transaction-row" item=transaction.dispute embedded=true}} + {{/if}} - {{#if transaction.hold}} - {{view "results/grouped-transaction-row" item=transaction.hold embedded=true}} - {{/if}} - {{/view}} - + {{#if transaction.refunds}} + {{#each refund in transaction.refunds}} + {{view "results/grouped-transaction-row" item=refund embedded=true}} + {{/each}} + {{/if}} + + {{#if transaction.reversals}} + {{#each reversal in transaction.reversals}} + {{view "results/grouped-transaction-row" item=reversal embedded=true}} + {{/each}} + {{/if}} + + {{view "results/grouped-transaction-row" item=transaction embedded=true}} + + {{#if transaction.transaction}} + {{view "results/grouped-transaction-row" item=transaction.transaction}} + {{/if}} + + {{#if transaction.hold}} + {{view "results/grouped-transaction-row" item=transaction.hold embedded=true}} + {{/if}} + {{/view}} + + {{/if}} {{else}} diff --git a/app/templates/results/grouped-transaction-row.hbs b/app/templates/results/grouped-transaction-row.hbs index b760a71d5..ce637bf51 100644 --- a/app/templates/results/grouped-transaction-row.hbs +++ b/app/templates/results/grouped-transaction-row.hbs @@ -1,4 +1,4 @@ - + {{#link-to view.routeName view.item}} {{view.displayValue}} diff --git a/app/templates/results/transactions-table-grouped-by-order.hbs b/app/templates/results/transactions-table-grouped-by-order.hbs index 2d5dcccd2..db41f8c4f 100644 --- a/app/templates/results/transactions-table-grouped-by-order.hbs +++ b/app/templates/results/transactions-table-grouped-by-order.hbs @@ -13,24 +13,41 @@ {{/if}} - {{#each order_group in view.groupedResults}} + {{#each orderGroup in view.groupedResults}} - - {{#view "results/grouped-transactions-table" embedded=view.embedded}} - {{view "results/grouped-transaction-row" item=order_group.order embedded=view.embedded}} - {{/view}} - {{#view "results/grouped-transactions-table" embedded=view.embedded}} - {{#each transaction in order_group.transactions}} - {{view "results/grouped-transaction-row" item=transaction embedded=view.embedded}} + {{#if orderGroup.order}} + + {{#view "results/grouped-transactions-table" embedded=view.embedded}} + {{view "results/grouped-transaction-row" item=orderGroup.order embedded=view.embedded}} + {{/view}} + {{#view "results/grouped-transactions-table" embedded=view.embedded}} + {{#each transaction in orderGroup.transactions}} + {{view "results/grouped-transaction-row" item=transaction embedded=view.embedded}} - {{#if transaction.reversals}} - {{#each reversal in transaction.reversals}} - {{view "results/grouped-transaction-row" item=reversal embedded=view.embedded}} - {{/each}} - {{/if}} - {{/each}} - {{/view}} - + {{#if transaction.reversals}} + {{#each reversal in transaction.reversals}} + {{view "results/grouped-transaction-row" item=reversal embedded=view.embedded}} + {{/each}} + {{/if}} + {{/each}} + {{/view}} + + {{else}} + + {{#view "results/grouped-transactions-table" embedded=view.embedded}} + {{#each transaction in orderGroup.transactions}} + {{view "results/grouped-transaction-row" item=transaction embedded=view.embedded}} + + {{#if transaction.reversals}} + {{#each reversal in transaction.reversals}} + {{view "results/grouped-transaction-row" item=reversal embedded=view.embedded}} + {{/each}} + {{/if}} + {{/each}} + {{/view}} + + {{/if}} + {{else}} diff --git a/app/utils/constants.js b/app/utils/constants.js index a2925b271..7c6152019 100644 --- a/app/utils/constants.js +++ b/app/utils/constants.js @@ -22,7 +22,7 @@ Constants.BANK_ACCOUNT_TYPES = [{ Constants.SEARCH = { CATEGORIES: ['order', 'transaction', 'search', 'customer', 'funding_instrument', 'dispute'], - SEARCH_TYPES: ['debit', 'credit', 'card_hold', 'refund', "reversal", 'settlement'], + SEARCH_TYPES: ['debit', 'credit', 'card_hold', 'refund', "reversal", 'settlement', 'account'], TRANSACTION_TYPES: ['debit', 'credit', 'hold', 'refund'], FUNDING_INSTRUMENT_TYPES: ['bank_account', 'card'], DISPUTE_TYPES: ['pending', 'won', 'lost', 'arbitration'], diff --git a/app/views/modals/search-modal.coffee b/app/views/modals/search-modal.coffee index 0df5924e1..0423792a6 100644 --- a/app/views/modals/search-modal.coffee +++ b/app/views/modals/search-modal.coffee @@ -16,13 +16,17 @@ SearchModalView = ModalBaseView.extend(Search, isTransactionsTabSelected: isTabSelected("transaction") isCustomersTabSelected: isTabSelected("customer") isFundingInstrumentsTabSelected: isTabSelected("funding_instrument") + isAccountsTabSelected: isTabSelected("account") + isSettlementsTabSelected: isTabSelected("settlement") isLogsTabSelected: isTabSelected("log") totalResults: Computed.sumAll("resultsLoader.results.total_results", "totalLogs") totalOrders: Ember.computed.oneWay("resultsLoader.results.total_orders") totalTransactions: Ember.computed.oneWay("resultsLoader.results.total_transactions") totalCustomers: Ember.computed.oneWay("resultsLoader.results.counts.customer") + totalAccounts: Ember.computed.oneWay("totalCustomers") totalFundingInstruments: Ember.computed.oneWay("resultsLoader.results.total_funding_instruments") + totalSettlements: Ember.computed.oneWay("resultsLoader.results.total_settlements") totalLogs: Ember.computed.oneWay("logsResultsLoader.results.length") isLoaded: Ember.computed.oneWay("resultsLoader.results.isLoaded") diff --git a/app/views/results/accounts-table.js b/app/views/results/accounts-table.js new file mode 100644 index 000000000..2510de3dc --- /dev/null +++ b/app/views/results/accounts-table.js @@ -0,0 +1,8 @@ +import ResultsTableView from "./results-table"; + +var AccountsTableView = ResultsTableView.extend({ + classNames: 'accounts', + templateName: 'results/accounts-table' +}); + +export default AccountsTableView; diff --git a/app/views/results/transactions-table-grouped-by-order.js b/app/views/results/transactions-table-grouped-by-order.js index c884dd2ae..2d43422ab 100644 --- a/app/views/results/transactions-table-grouped-by-order.js +++ b/app/views/results/transactions-table-grouped-by-order.js @@ -14,12 +14,13 @@ var TransactionsTableGroupedByOrderView = TransactionsTableView.extend({ var Order = this.container.lookupFactory("model:order"); results.forEach(function(transaction) { - var order = Order.find(transaction.get('order_uri')); + var orderUri = transaction.get('order_uri'); + var order = orderUri ? Order.find(orderUri) : null; var orderGroup = groupedTransactions.findBy('order_uri', transaction.get('order_uri')); if (!orderGroup) { orderGroup = Ember.Object.create({ - order_uri: transaction.get('order_uri'), + order_uri: orderUri, order: order, transactions: [] }); From 0995ac202349bd0eb457666261b8919611cf94f1 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Tue, 13 Jan 2015 16:45:12 -0800 Subject: [PATCH 24/80] Add regular settlement model --- app/models/settlement.coffee | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 app/models/settlement.coffee diff --git a/app/models/settlement.coffee b/app/models/settlement.coffee new file mode 100644 index 000000000..53e1feced --- /dev/null +++ b/app/models/settlement.coffee @@ -0,0 +1,13 @@ +`import Ember from "ember";` +`import Utils from "balanced-dashboard/lib/utils";` +`import Model from "./core/model";` + +Settlement = Model.extend( + routeName: "settlement", + type_name: "Settlement", + amountInDollars: (-> + "$%@".fmt(Utils.centsToDollars(@get("amount"))) + ).property("amount") +) + +`export default Settlement;` From 767ccc0ec4d07c12bcb4eddecad393202af7d7c2 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Tue, 13 Jan 2015 17:36:28 -0800 Subject: [PATCH 25/80] Fix accounts/settlements results table by adding regular models --- app/initializers/type-mappings-initializer.coffee | 1 + app/models/account.coffee | 14 ++++++++++++++ app/models/core/search-model-array.js | 2 +- app/models/results-loaders/marketplace-search.js | 10 ++++++++-- .../results-loaders/unsettled-transactions.js | 9 +++++++-- app/templates/marketplace/settings.hbs | 5 +++++ app/templates/modals/search-modal.hbs | 2 +- app/templates/results/accounts-table.hbs | 2 +- app/utils/constants.js | 6 ++++-- 9 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 app/models/account.coffee diff --git a/app/initializers/type-mappings-initializer.coffee b/app/initializers/type-mappings-initializer.coffee index 150d55671..342ccae2f 100644 --- a/app/initializers/type-mappings-initializer.coffee +++ b/app/initializers/type-mappings-initializer.coffee @@ -9,6 +9,7 @@ TypeMappingsInitializer = TypeMappings.addTypeMapping(key, klass) registerMapping "api_key", "api-key" + registerMapping "account" registerMapping "bank_account", "bank-account" registerMapping "bank-account", "bank-account" registerMapping "bank_account_verification", "verification" diff --git a/app/models/account.coffee b/app/models/account.coffee new file mode 100644 index 000000000..765635f20 --- /dev/null +++ b/app/models/account.coffee @@ -0,0 +1,14 @@ +`import Ember from "ember";` +`import Model from "./core/model";` +`import Computed from "balanced-dashboard/utils/computed";` + +Account = Model.extend( + routeName: "account", + isPayableAccount: Ember.computed.equal("type", "payable"), + type_name: (-> + type = @get("type").capitalize() + "%@ account".fmt(type) + ).property("type") +) + +`export default Account;` diff --git a/app/models/core/search-model-array.js b/app/models/core/search-model-array.js index 3b12aa4b3..13f200974 100644 --- a/app/models/core/search-model-array.js +++ b/app/models/core/search-model-array.js @@ -19,7 +19,7 @@ var SearchModelArray = ModelArray.extend(Ember.SortableMixin, { total_transactions: Computed.sumAll('total_credits', 'total_debits', 'total_card_holds', 'total_refunds'), total_funding_instruments: Computed.sumAll('total_bank_accounts', 'total_cards'), total_settlements: readOnly('settlement'), - total_results: Computed.sumAll('total_orders', 'total_transactions', 'total_funding_instruments', 'total_customers') + total_results: Computed.sumAll('total_orders', 'total_transactions', 'total_funding_instruments', 'total_customers', 'total_settlements') }); export default SearchModelArray; diff --git a/app/models/results-loaders/marketplace-search.js b/app/models/results-loaders/marketplace-search.js index e3475bd2a..035d09532 100644 --- a/app/models/results-loaders/marketplace-search.js +++ b/app/models/results-loaders/marketplace-search.js @@ -4,6 +4,8 @@ import Transaction from "../transaction"; import FundingInstrument from "../funding-instrument"; import Customer from "../customer"; import Order from "../order"; +import Account from "../account"; +import Settlement from "../settlement"; import SearchModelArray from "../core/search-model-array"; import Constants from "balanced-dashboard/utils/constants"; @@ -15,7 +17,9 @@ var MarketplaceSearchResultsLoader = BaseResultsLoader.extend({ var mapping = { "funding_instrument": Constants.SEARCH.FUNDING_INSTRUMENT_TYPES, "customer": Constants.SEARCH.CUSTOMER_TYPES, - "order": Constants.SEARCH.ORDER_TYPES + "order": Constants.SEARCH.ORDER_TYPES, + "account": Constants.SEARCH.ACCOUNT_TYPES, + "settlement": Constants.SEARCH.SETTLEMENT_TYPES, }; return mapping[this.get("searchType")] || Constants.SEARCH.SEARCH_TYPES; @@ -25,7 +29,9 @@ var MarketplaceSearchResultsLoader = BaseResultsLoader.extend({ var mapping = { "funding_instrument": FundingInstrument, "customer": Customer, - "order": Order + "order": Order, + "account": Account, + "settlement": Settlement }; return mapping[this.get("searchType")] || Transaction; }.property("searchType"), diff --git a/app/models/results-loaders/unsettled-transactions.js b/app/models/results-loaders/unsettled-transactions.js index 1a1348768..f48f84b34 100644 --- a/app/models/results-loaders/unsettled-transactions.js +++ b/app/models/results-loaders/unsettled-transactions.js @@ -15,7 +15,8 @@ var UnsettledTransactionsResultsLoader = TransactionsResultsLoader.extend({ var searchArray = SearchModelArray.newArrayLoadedFromUri(uri, type); searchArray.setProperties({ sortProperties: [this.get('sortField') || 'created_at'], - sortAscending: this.get('sortDirection') === 'asc' + sortAscending: this.get('sortDirection') === 'asc', + isLoaded: true }); return searchArray; @@ -25,9 +26,13 @@ var UnsettledTransactionsResultsLoader = TransactionsResultsLoader.extend({ results: function() { var self = this; - return this.get("unfilteredResults").filter(function(credit) { + var r = this.get("unfilteredResults").filter(function(credit) { return !self.get("settledTransactionIds").contains(credit.get("id")); }); + return ModelArray.create({ + isLoaded: true, + content: r + }); }.property("unfilteredResults.@each.id", "settledTransactionIds"), settledTransactionIds: function() { diff --git a/app/templates/marketplace/settings.hbs b/app/templates/marketplace/settings.hbs index 8a57138ce..3efe0f230 100644 --- a/app/templates/marketplace/settings.hbs +++ b/app/templates/marketplace/settings.hbs @@ -16,6 +16,11 @@
    {{view "results/embedded-funding-instruments-table" loader=fundingInstrumentsResultsLoader}}
    + +

    Internal accounts

    +
    + {{view "results/embedded-internal-accounts-table" loader=accountsResultsLoader}} +
    diff --git a/app/templates/modals/search-modal.hbs b/app/templates/modals/search-modal.hbs index 2b48af91e..e2b8812a0 100644 --- a/app/templates/modals/search-modal.hbs +++ b/app/templates/modals/search-modal.hbs @@ -17,7 +17,7 @@
  • - {{format-number view.totalAccounts}} Accounts + {{format-number view.totalAccounts}} Internal accounts
  • diff --git a/app/templates/results/accounts-table.hbs b/app/templates/results/accounts-table.hbs index c15bad498..c3b2e0303 100644 --- a/app/templates/results/accounts-table.hbs +++ b/app/templates/results/accounts-table.hbs @@ -61,7 +61,7 @@ {{#if view.loader.results.isLoaded}} - No accounts + No internal accounts {{else}} Loading... {{/if}} diff --git a/app/utils/constants.js b/app/utils/constants.js index 7c6152019..1773dccef 100644 --- a/app/utils/constants.js +++ b/app/utils/constants.js @@ -22,12 +22,14 @@ Constants.BANK_ACCOUNT_TYPES = [{ Constants.SEARCH = { CATEGORIES: ['order', 'transaction', 'search', 'customer', 'funding_instrument', 'dispute'], - SEARCH_TYPES: ['debit', 'credit', 'card_hold', 'refund', "reversal", 'settlement', 'account'], + SEARCH_TYPES: ['debit', 'credit', 'card_hold', 'refund', "reversal"], TRANSACTION_TYPES: ['debit', 'credit', 'hold', 'refund'], FUNDING_INSTRUMENT_TYPES: ['bank_account', 'card'], DISPUTE_TYPES: ['pending', 'won', 'lost', 'arbitration'], CUSTOMER_TYPES: ["customer"], - ORDER_TYPES: ["order"] + ORDER_TYPES: ["order"], + SETTLEMENT_TYPES: ['settlement'], + ACCOUNT_TYPES: ['account'], }; // time in ms to throttle between key presses for search From a798d86507a12034340ab84c7ce1e2d61d338853 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Wed, 14 Jan 2015 14:24:51 -0800 Subject: [PATCH 26/80] Add accounts to creditable funding instruments --- app/models/account.coffee | 6 +++++- app/models/bk/account.coffee | 5 ++++- app/models/customer.js | 3 ++- app/models/results-loaders/unsettled-transactions.js | 4 ++-- app/models/settlement.coffee | 1 + app/templates/detail-views/resource-summary.hbs | 11 ++++++----- .../resource-summaries/resource-summary-base.coffee | 4 ++-- 7 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/models/account.coffee b/app/models/account.coffee index 765635f20..18cd918ce 100644 --- a/app/models/account.coffee +++ b/app/models/account.coffee @@ -4,11 +4,15 @@ Account = Model.extend( routeName: "account", + route_name: "account", isPayableAccount: Ember.computed.equal("type", "payable"), type_name: (-> type = @get("type").capitalize() "%@ account".fmt(type) - ).property("type") + ).property("type"), + description_with_type: Ember.computed("id", -> + "Payable account: #{@get("id")}" + ) ) `export default Account;` diff --git a/app/models/bk/account.coffee b/app/models/bk/account.coffee index 430d1dd18..f21cdee4c 100644 --- a/app/models/bk/account.coffee +++ b/app/models/bk/account.coffee @@ -8,7 +8,10 @@ Account = BkAccount.extend( type_name: (-> type = @get("type").capitalize() "%@ account".fmt(type) - ).property("type") + ).property("type"), + description_with_type: Ember.computed("id", -> + "Payable account: #{@get("id")}" + ) ) `export default Account;` diff --git a/app/models/customer.js b/app/models/customer.js index ad938f7c9..92809a928 100644 --- a/app/models/customer.js +++ b/app/models/customer.js @@ -19,6 +19,7 @@ var Customer = Model.extend({ refunds: Model.hasMany('refunds', 'refund'), orders: Model.hasMany('orders', 'order'), disputes: Model.hasMany('disputes', 'dispute'), + accounts: Model.hasMany('accounts', 'account'), uri: '/customers', route_name: 'customer', @@ -54,7 +55,7 @@ var Customer = Model.extend({ funding_instruments: Ember.computed.union('bank_accounts', 'cards'), debitable_funding_instruments: Ember.computed.union('debitable_bank_accounts', 'cards'), - creditable_funding_instruments: Ember.computed.union('bank_accounts', 'creditable_cards'), + creditable_funding_instruments: Ember.computed.union('bank_accounts', 'creditable_cards', 'accounts'), getFundingInstrumentsLoader: function(attributes) { attributes = _.extend({ diff --git a/app/models/results-loaders/unsettled-transactions.js b/app/models/results-loaders/unsettled-transactions.js index f48f84b34..25214f129 100644 --- a/app/models/results-loaders/unsettled-transactions.js +++ b/app/models/results-loaders/unsettled-transactions.js @@ -26,12 +26,12 @@ var UnsettledTransactionsResultsLoader = TransactionsResultsLoader.extend({ results: function() { var self = this; - var r = this.get("unfilteredResults").filter(function(credit) { + var results = this.get("unfilteredResults").filter(function(credit) { return !self.get("settledTransactionIds").contains(credit.get("id")); }); return ModelArray.create({ isLoaded: true, - content: r + content: results }); }.property("unfilteredResults.@each.id", "settledTransactionIds"), diff --git a/app/models/settlement.coffee b/app/models/settlement.coffee index 53e1feced..ade299289 100644 --- a/app/models/settlement.coffee +++ b/app/models/settlement.coffee @@ -4,6 +4,7 @@ Settlement = Model.extend( routeName: "settlement", + route_name: "settlement", type_name: "Settlement", amountInDollars: (-> "$%@".fmt(Utils.centsToDollars(@get("amount"))) diff --git a/app/templates/detail-views/resource-summary.hbs b/app/templates/detail-views/resource-summary.hbs index 0117760d0..7361c72de 100644 --- a/app/templates/detail-views/resource-summary.hbs +++ b/app/templates/detail-views/resource-summary.hbs @@ -10,11 +10,12 @@ {{#link-to view.model.route_name view.model title=view.hoverValue}} {{view.value}} {{/link-to}} - {{/if}} - {{#if view.model.routeName}} - {{#link-to view.model.routeName view.model title=view.hoverValue}} - {{view.value}} - {{/link-to}} + {{else}} + {{#if view.model.routeName}} + {{#link-to view.model.routeName view.model title=view.hoverValue}} + {{view.value}} + {{/link-to}} + {{/if}} {{/if}} {{else}} none diff --git a/app/views/detail-views/resource-summaries/resource-summary-base.coffee b/app/views/detail-views/resource-summaries/resource-summary-base.coffee index 12932a103..56ab2a77f 100644 --- a/app/views/detail-views/resource-summaries/resource-summary-base.coffee +++ b/app/views/detail-views/resource-summaries/resource-summary-base.coffee @@ -19,7 +19,7 @@ ResourceSummaryBase = Ember.View.extend( "#{model.get('last_four')} #{model.get('brand')}" else if @isType("bank-account") "#{model.get('last_four')} #{model.get('formatted_bank_name')}" - else if @isType("bk/account") + else if @isType("bk/account") || @isType("account") currentRoute = @container.lookup("controller:application").get('currentRouteName') if currentRoute == "settlement" "Payable account" @@ -27,7 +27,7 @@ ResourceSummaryBase = Ember.View.extend( "Balance: $%@".fmt(Utils.centsToDollars(model.get('balance'))) else null - ).property("model.amount_escrowed", "model.amount", "model.display_me", "model.last_four", "model.brand", "model.formatted_bank_name") + ).property("model.amount_escrowed", "model.amount", "model.display_me", "model.last_four", "model.brand", "model.formatted_bank_name", "model.balance") hoverValue: (-> model = @get("model") From 66ca248568ef8ff907e4c50d3ab4246473a71cdc Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Wed, 14 Jan 2015 14:58:52 -0800 Subject: [PATCH 27/80] Display internal accounts table on settings page --- app/controllers/marketplace/settings.js | 10 ++++++++++ app/models/customer.js | 7 +++++++ app/models/results-loaders/accounts.js | 2 +- app/routes/account.coffee | 1 - 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/controllers/marketplace/settings.js b/app/controllers/marketplace/settings.js index c96137c50..e518d9f65 100644 --- a/app/controllers/marketplace/settings.js +++ b/app/controllers/marketplace/settings.js @@ -10,6 +10,16 @@ var MarketplaceSettingsController = Ember.ObjectController.extend(actionsMixin, ownerCustomer: Ember.computed.oneWay("marketplace.owner_customer"), + accountsResultsLoader: function() { + if (this.get("owner_customer")) { + return this.get("owner_customer").getAccountsLoader({ + limit: 10 + }); + } else { + return this.get("container").lookup("results-loader:base"); + } + }.property("owner_customer"), + fundingInstrumentsResultsLoader: function() { if (this.get("owner_customer")) { return this.get("owner_customer").getFundingInstrumentsLoader({ diff --git a/app/models/customer.js b/app/models/customer.js index 92809a928..87e015e1a 100644 --- a/app/models/customer.js +++ b/app/models/customer.js @@ -76,6 +76,13 @@ var Customer = Model.extend({ }, attributes); return TransactionsResultsLoader.create(attributes); }, + getAccountsLoader: function(attributes) { + var AccountsResultsLoader = require("balanced-dashboard/models/results-loaders/accounts")["default"]; + attributes = _.extend({ + path: this.get("accounts_uri"), + }, attributes); + return AccountsResultsLoader.create(attributes); + }, type: function() { return (this.get('ein') || this.get('business_name')) ? CUSTOMER_TYPES.BUSINESS : CUSTOMER_TYPES.PERSON; diff --git a/app/models/results-loaders/accounts.js b/app/models/results-loaders/accounts.js index 27c0cfbde..04f9d0341 100644 --- a/app/models/results-loaders/accounts.js +++ b/app/models/results-loaders/accounts.js @@ -1,5 +1,5 @@ import BaseResultsLoader from "./base"; -import Account from "../bk/account"; +import Account from "../account"; var AccountsResultsLoader = BaseResultsLoader.extend({ resultsType: Account, diff --git a/app/routes/account.coffee b/app/routes/account.coffee index 62977f057..de90b81f0 100644 --- a/app/routes/account.coffee +++ b/app/routes/account.coffee @@ -1,5 +1,4 @@ `import ModelRoute from "./model"` -`import LegacyResultsLoaderWrapper from "balanced-dashboard/utils/legacy-results-loader-wrapper";` AccountRoute = ModelRoute.extend( model: (params) -> From 63d1ac13a2387e4c0dd88f3870b6410fb12aa8a4 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Wed, 14 Jan 2015 15:40:56 -0800 Subject: [PATCH 28/80] Update balanced addon model version --- app/stores/balanced.coffee | 3 --- package.json | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/stores/balanced.coffee b/app/stores/balanced.coffee index 258d10a16..5ab873a8e 100644 --- a/app/stores/balanced.coffee +++ b/app/stores/balanced.coffee @@ -4,13 +4,10 @@ BalancedStore = Store.extend( modelMaps: bank_account: "model:bk/bank-account" customer: "model:bk/customer" -<<<<<<< HEAD account: "model:bk/account" settlement: "model:bk/settlement" -======= api_key_production: "model:bk/api-key-production" marketplace: "model:bk/marketplace" ->>>>>>> 06920b71424deb16c41bac88d9320cdf51f54514 ) `export default BalancedStore;` diff --git a/package.json b/package.json index 9d4fd0e80..ccf101003 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "repository": "git@github.com:balanced/balanced-dashboard.git", "author": "Balanced ", "devDependencies": { - "balanced-addon-models": "balanced/balanced-addon-models#gandalf", + "balanced-addon-models": "git://github.com/balanced/balanced-addon-models#gandalf", "body-parser": "1.2.0", "bower": "1.3.12", "broccoli-asset-rev": "0.3.1", From d5c1487f37169cfd13637a84e47dc1ddac811132 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Wed, 14 Jan 2015 17:24:23 -0800 Subject: [PATCH 29/80] Combine orders and transactions tab --- app/controllers/marketplace.js | 6 +-- app/controllers/marketplace/import-payouts.js | 2 +- .../legacy-routes-initializer.coffee | 3 +- app/router.coffee | 15 +++--- app/routes/marketplace/index.js | 9 ---- app/routes/marketplace/orders.js | 2 +- app/templates/marketplace/orders.hbs | 2 +- app/templates/marketplace/payments-layout.hbs | 52 ++++++------------- .../results/grouped-transaction-row.hbs | 2 +- app/views/marketplace/transactions.js | 7 --- app/views/results/grouped-transaction-row.js | 8 +-- app/views/sidebar/marketplace-sidebar.js | 6 +-- 12 files changed, 38 insertions(+), 76 deletions(-) delete mode 100644 app/views/marketplace/transactions.js diff --git a/app/controllers/marketplace.js b/app/controllers/marketplace.js index f5fddb2bc..bf59822cd 100644 --- a/app/controllers/marketplace.js +++ b/app/controllers/marketplace.js @@ -29,8 +29,7 @@ var MarketplaceController = Ember.ObjectController.extend({ return this.get("auth.signedIn") && this.get("model"); }.property("auth.signedIn", "model"), - transactionSelected: isSelected('marketplace.transactions', 'credits', 'debits', 'holds', 'refunds', 'reversals'), - orderSelected: isSelected('marketplace.orders', 'orders'), + orderSelected: isSelected('marketplace.orders', 'orders', 'credits', 'debits', 'holds', 'refunds', 'reversals'), settlementSelected: isSelected('marketplace.settlements', 'settlement'), disputeSelected: isSelected('marketplace.disputes', 'dispute'), customerSelected: isSelected('marketplace.customers', 'customer'), @@ -39,9 +38,6 @@ var MarketplaceController = Ember.ObjectController.extend({ invoiceSelected: isSelected('marketplace.invoices', 'invoice'), settingSelected: isSelected('marketplace.settings'), - // Note: need this since bind-attr only works for a single property - paymentSelected: Ember.computed.or('transactionSelected', 'orderSelected'), - disputesResultsLoader: function() { if (this.get("model")) { return this.get('model').getDisputesLoader({ diff --git a/app/controllers/marketplace/import-payouts.js b/app/controllers/marketplace/import-payouts.js index d210298bc..2025c26ff 100644 --- a/app/controllers/marketplace/import-payouts.js +++ b/app/controllers/marketplace/import-payouts.js @@ -51,7 +51,7 @@ var MarketplaceImportPayoutsController = Ember.Controller.extend(Ember.Evented, callback(); } var count = collection.filterBy('isSaved').get('length'); - self.transitionToRoute('marketplace.transactions'); + self.transitionToRoute('marketplace.orders'); self.refresh(''); var message = '%@ payouts were successfully submitted. Payouts might take a couple seconds to appear in the transactions list.'.fmt(count); diff --git a/app/initializers/legacy-routes-initializer.coffee b/app/initializers/legacy-routes-initializer.coffee index 67b0129f8..b73c54c17 100644 --- a/app/initializers/legacy-routes-initializer.coffee +++ b/app/initializers/legacy-routes-initializer.coffee @@ -10,7 +10,8 @@ LegacyRoutesInitializer = defineRoute("bank-account.index", 'activity.funding_instruments') defineRoute("cards.index", "activity.funding_instruments") - defineRoute("marketplace-redirect-activity-transactions", "marketplace.transactions") + defineRoute("marketplace-redirect-activity-transactions", "marketplace.orders") + defineRoute("marketplace-redirect-transactions", "marketplace.orders") defineRoute("marketplace-redirect-activity-orders", "activity.orders") defineRoute("marketplace-redirect-activity-customers", "marketplace.customers") defineRoute("marketplace-redirect-activity-funding-instruments", "marketplace.funding-instruments") diff --git a/app/router.coffee b/app/router.coffee index 1ce0b2cee..498d46543 100644 --- a/app/router.coffee +++ b/app/router.coffee @@ -49,6 +49,7 @@ Router.map -> # exists to handle old URIs this.route("redirect_activity_transactions", path: '/activity/transactions') + this.route("redirect_transactions", path: '/transactions') this.route("redirect_activity_orders", path: '/activity/orders') this.route("redirect_activity_customers", path: 'activity/customers') this.route("redirect_activity_funding_instruments", path: 'activity/funding_instruments') @@ -59,6 +60,12 @@ Router.map -> this.route("orders") this.resource('orders', path: '/orders/:item_id') + this.resource('credits', path: '/credits/:item_id') + this.resource('reversals', path: '/reversals/:item_id') + this.resource('debits', path: '/debits/:item_id') + this.resource('holds', path: '/holds/:item_id') + this.resource('refunds', path: '/refunds/:item_id') + this.resource('events', path: '/events/:item_id') this.route("customers") this.resource('customer', path: '/customers/:item_id') @@ -73,14 +80,6 @@ Router.map -> this.resource('bank_accounts', path: '/bank_accounts/:item_id') this.resource('cards', path: '/cards/:item_id') - this.route("transactions") - this.resource('credits', path: '/credits/:item_id') - this.resource('reversals', path: '/reversals/:item_id') - this.resource('debits', path: '/debits/:item_id') - this.resource('holds', path: '/holds/:item_id') - this.resource('refunds', path: '/refunds/:item_id') - this.resource('events', path: '/events/:item_id') - this.route("logs") this.resource("log", path: "/logs/:item_id") diff --git a/app/routes/marketplace/index.js b/app/routes/marketplace/index.js index 48100c297..2af358f69 100644 --- a/app/routes/marketplace/index.js +++ b/app/routes/marketplace/index.js @@ -1,15 +1,6 @@ import AuthRoute from "balanced-dashboard/routes/auth"; var MarketplaceIndexRoute = AuthRoute.extend({ - beforeModel: function() { - var mp = this.modelFor("marketplace"); - if (mp.get("isOrdersRequired")) { - this.transitionTo('marketplace.orders'); - } - else { - this.transitionTo('marketplace.transactions'); - } - } }); export default MarketplaceIndexRoute; diff --git a/app/routes/marketplace/orders.js b/app/routes/marketplace/orders.js index 332543ef8..4ad519563 100644 --- a/app/routes/marketplace/orders.js +++ b/app/routes/marketplace/orders.js @@ -4,7 +4,7 @@ var MarketplaceOrdersRoute = AuthRoute.extend({ pageTitle: 'Orders', model: function() { var marketplace = this.modelFor("marketplace"); - return marketplace.getOrdersLoader(); + return marketplace.getTransactionsLoader(); }, }); diff --git a/app/templates/marketplace/orders.hbs b/app/templates/marketplace/orders.hbs index 6e8f3a547..49bf1a593 100644 --- a/app/templates/marketplace/orders.hbs +++ b/app/templates/marketplace/orders.hbs @@ -1,5 +1,5 @@
    - {{view "results/orders-table" loader=resultsLoader}} + {{view "results/transactions-table-grouped-by-order" loader=resultsLoader}}
    diff --git a/app/templates/marketplace/payments-layout.hbs b/app/templates/marketplace/payments-layout.hbs index c50b97b79..5e3c3cb9a 100644 --- a/app/templates/marketplace/payments-layout.hbs +++ b/app/templates/marketplace/payments-layout.hbs @@ -1,43 +1,23 @@ -{{#view "page-navigations/page-navigation" title="Payments"}} - {{#if view.parentView.showActionButtons}} - - {{/if}} +{{#view "page-navigations/page-navigation" title="Orders"}} + {{/view}} diff --git a/app/templates/results/grouped-transaction-row.hbs b/app/templates/results/grouped-transaction-row.hbs index ce637bf51..0f020dcdc 100644 --- a/app/templates/results/grouped-transaction-row.hbs +++ b/app/templates/results/grouped-transaction-row.hbs @@ -21,7 +21,7 @@ {{/link-to}} - + {{#link-to view.routeName view.item}} {{view.amountText}} diff --git a/app/views/marketplace/transactions.js b/app/views/marketplace/transactions.js deleted file mode 100644 index 20a9da160..000000000 --- a/app/views/marketplace/transactions.js +++ /dev/null @@ -1,7 +0,0 @@ -var MarketplaceTransactionsView = Ember.View.extend({ - layoutName: "marketplace/payments-layout", - templateName: "marketplace/transactions", - showActionButtons: true -}); - -export default MarketplaceTransactionsView; diff --git a/app/views/results/grouped-transaction-row.js b/app/views/results/grouped-transaction-row.js index 4db988e4d..cef2ff3a6 100644 --- a/app/views/results/grouped-transaction-row.js +++ b/app/views/results/grouped-transaction-row.js @@ -103,11 +103,13 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ }.property('item.source.funding_instrument_type', 'item.destination.funding_instrument_type'), amountText: function() { - var amount = this.get("item.amount"); if (this.get("item.type_name") === "Order") { - amount = this.get("item.amount_escrowed"); + var label = '%@Order balance'; + var primaryLabel = Utils.formatCurrency(this.get("item.amount_escrowed")); + return Utils.safeFormat(label, primaryLabel).htmlSafe(); + } else { + return Utils.formatCurrency(this.get("item.amount")); } - return Utils.formatCurrency(amount); }.property("item.amount", "item.type_name") }); diff --git a/app/views/sidebar/marketplace-sidebar.js b/app/views/sidebar/marketplace-sidebar.js index 1b30b7164..61a802bbf 100644 --- a/app/views/sidebar/marketplace-sidebar.js +++ b/app/views/sidebar/marketplace-sidebar.js @@ -1,10 +1,10 @@ import SidebarView from "./sidebar"; var SIDEBAR_ITEMS = [{ - linkText: "Payments", - linkIcon: "icon-payments", + linkText: "Orders", + linkIcon: "icon-orders", routeName: "marketplace.orders", - isSelectedBinding: "controller.controllers.marketplace.paymentSelected", + isSelectedBinding: "controller.controllers.marketplace.orderSelected", }, { linkText: "Settlements", linkIcon: "icon-settlements", From 4af6f8349e3f2308800327ac5f6227801210d168 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Wed, 14 Jan 2015 18:02:06 -0800 Subject: [PATCH 30/80] Simplify payment method text in the transactions table --- app/routes/marketplace/transactions.js | 11 ----- app/styles/results.less | 14 ++++++ app/views/results/grouped-transaction-row.js | 51 +++++++++++--------- 3 files changed, 41 insertions(+), 35 deletions(-) delete mode 100644 app/routes/marketplace/transactions.js diff --git a/app/routes/marketplace/transactions.js b/app/routes/marketplace/transactions.js deleted file mode 100644 index 770e87255..000000000 --- a/app/routes/marketplace/transactions.js +++ /dev/null @@ -1,11 +0,0 @@ -import AuthRoute from "../auth"; - -var MarketplaceTransactionsRoute = AuthRoute.extend({ - pageTitle: 'Transactions', - model: function() { - var marketplace = this.modelFor("marketplace"); - return marketplace.getTransactionsLoader(); - }, -}); - -export default MarketplaceTransactionsRoute; diff --git a/app/styles/results.less b/app/styles/results.less index 599cbe35e..159a894e8 100644 --- a/app/styles/results.less +++ b/app/styles/results.less @@ -310,6 +310,20 @@ header.results-label h3 { } } + td.payment-method { + [class^="icon-"] { + font-family: 'Balanced-Icon'; + color: @gray4; + } + .icon-credit-card:before, .icon-debit-card:before { + &:extend(.icon-card:before); + } + + .icon-checking-account:before, .icon-savings-account:before { + &:extend(.icon-bank-account:before); + } + } + td.status { a > span:before { content: ''; diff --git a/app/views/results/grouped-transaction-row.js b/app/views/results/grouped-transaction-row.js index cef2ff3a6..d3eb41cbf 100644 --- a/app/views/results/grouped-transaction-row.js +++ b/app/views/results/grouped-transaction-row.js @@ -8,6 +8,7 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ templateName: 'results/grouped-transaction-row', routeName: Computed.orProperties("item.route_name", "item.routeName"), spanClassNames: Ember.computed.reads("item.status"), + typeName: Ember.computed.reads("item.type_name"), title: function() { if (_.contains(this.get("classNames"), "current")) { @@ -19,16 +20,16 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ primaryLabelText: function() { if (_.contains(this.get("classNames"), "current")) { - return '%@ (currently viewing)'.fmt(this.get('item.type_name')); + return '%@ (currently viewing)'.fmt(this.get('typeName')); } var transactionText; var description = this.get('item.description'); var status = Utils.capitalize(this.get('item.status')); if (description) { - transactionText = '%@ (%@)'.fmt(this.get('item.type_name'), description); + transactionText = '%@ (%@)'.fmt(this.get('typeName'), description); } else { - transactionText = this.get('item.type_name'); + transactionText = this.get('typeName'); } if (status) { @@ -50,12 +51,19 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ customer: Ember.computed.reads("bankAccount.customer"), customerText: function() { - if (this.get('item.type_name') === "Settlement") { + var typeName = this.get('typeName'); + + if (typeName === "Order") { + var label = '%@Merchant'; + var primaryLabel = this.get("item.seller.display_me"); + + return Utils.safeFormat(label, primaryLabel).htmlSafe(); + } else if (typeName === "Settlement") { return this.get("settlementCustomerText"); } else { return this.get("item.customer.display_me"); } - }.property("item.customer.display_me", "settlementCustomerText"), + }.property("item.seller.display_me", "item.customer.display_me", "settlementCustomerText"), settlementCustomerText: function() { var label = '%@%@'; @@ -66,13 +74,12 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ }.property("customer.display_me", "customer.email_address"), paymentMethodText: function() { - if (this.get('item.type_name') === "Settlement") { + if (this.get('typeName') === "Settlement") { return this.get("settlementPaymentMethodText"); } var label = '%@%@'; - var secondaryLabel = this.get('paymentMethodSecondaryLabelText') || ''; - return Utils.safeFormat(label, this.get('paymentMethodPrimaryLabelText'), secondaryLabel).htmlSafe(); - }.property('paymentMethodPrimaryLabelText', 'paymentMethodSecondaryLabelText', "settlementPaymentMethodText", "item.type_name"), + return Utils.safeFormat(label, this.get('paymentMethodPrimaryLabelText')).htmlSafe(); + }.property('paymentMethodPrimaryLabelText', "settlementPaymentMethodText", "typeName"), settlementPaymentMethodText: function() { var bankAccount = this.get('bankAccount'); @@ -82,35 +89,31 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ return Utils.safeFormat(label, primaryLabel, secondaryLabel).htmlSafe(); }.property("bankAccount.last_four", "bankAccount.brand", "bankAccount.funding_instrument_type"), + dasherizedPaymentMethodType: Ember.computed.reads("item.dasherized_funding_instrument_type"), + paymentMethodPrimaryLabelText: function() { - if (this.get("item.destination.type") === "payable") { - return this.get("item.destination.id"); - } else if (this.get("item.source")) { - return "%@ %@".fmt(this.get("item.source.last_four"), this.get("item.source.brand")); - } else { - return "%@ %@".fmt(this.get("item.destination.last_four"), this.get("item.destination.brand")); - } - }.property("item.source.id", "item.source.last_four", "item.source.brand", "item.destination.id", "item.destination.last_four", "item.destination.brand"), + var label = ""; + var dasherizedPaymentMethodType = this.get("dasherizedPaymentMethodType"); - paymentMethodSecondaryLabelText: function() { if (this.get("item.destination.type") === "payable") { - return "Payable account"; + label = "Payable account"; } else if (this.get("item.source")) { - return this.get('item.source.funding_instrument_type'); + label = this.get("item.source.last_four"); } else { - return this.get('item.destination.funding_instrument_type'); + label = this.get("item.destination.last_four"); } - }.property('item.source.funding_instrument_type', 'item.destination.funding_instrument_type'), + return Utils.safeFormat('%@', dasherizedPaymentMethodType, label).htmlSafe(); + }.property("item.source.last_four", "item.destination.last_four", "dasherizedPaymentMethodType"), amountText: function() { - if (this.get("item.type_name") === "Order") { + if (this.get("typeName") === "Order") { var label = '%@Order balance'; var primaryLabel = Utils.formatCurrency(this.get("item.amount_escrowed")); return Utils.safeFormat(label, primaryLabel).htmlSafe(); } else { return Utils.formatCurrency(this.get("item.amount")); } - }.property("item.amount", "item.type_name") + }.property("item.amount", "typeName") }); export default GroupedTransactionRowView; From be250bdb403c1e3ac9764f89fb6070bec9356d67 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Thu, 15 Jan 2015 17:51:24 -0800 Subject: [PATCH 31/80] Display payment source and destination for all tables --- app/models/bk/account.coffee | 5 +- app/models/bk/bank-account.coffee | 3 + app/routes/settlement.coffee | 6 +- app/styles/results.less | 11 ++ app/templates/orders.hbs | 4 +- .../results/associated-transactions-table.hbs | 37 +++--- .../results/embedded-transactions-table.hbs | 21 +-- .../results/grouped-transaction-row.hbs | 25 +++- .../grouped-transactions-table-layout.hbs | 13 +- ...transactions-table-grouped-by-customer.hbs | 22 +-- .../transactions-table-grouped-by-order.hbs | 7 +- ...ansactions-table-grouped-by-settlement.hbs | 3 +- app/templates/settlement.hbs | 2 +- app/utils/bk-utils.coffee | 5 + .../resource-summary-base.coffee | 2 +- .../settlement-summary-section.js | 34 ++++- .../summary-sections/summary-section.js | 17 --- .../results/associated-transactions-table.js | 4 +- .../results/embedded-transactions-table.js | 3 + app/views/results/grouped-transaction-row.js | 125 ++++++++++++------ .../transactions-table-grouped-by-customer.js | 4 + .../transactions-table-grouped-by-order.js | 2 +- ...ransactions-table-grouped-by-settlement.js | 2 +- 23 files changed, 235 insertions(+), 122 deletions(-) create mode 100644 app/utils/bk-utils.coffee diff --git a/app/models/bk/account.coffee b/app/models/bk/account.coffee index f21cdee4c..910cc2025 100644 --- a/app/models/bk/account.coffee +++ b/app/models/bk/account.coffee @@ -1,9 +1,11 @@ `import Ember from "ember";` `import BkAccount from "balanced-addon-models/models/account";` `import Computed from "balanced-dashboard/utils/computed";` +`import BkUtils from "balanced-dashboard/utils/bk-utils";` Account = BkAccount.extend( routeName: "account", + route_name: "account", isPayableAccount: Ember.computed.equal("type", "payable"), type_name: (-> type = @get("type").capitalize() @@ -11,7 +13,8 @@ Account = BkAccount.extend( ).property("type"), description_with_type: Ember.computed("id", -> "Payable account: #{@get("id")}" - ) + ), + toLegacyModel: BkUtils.generateToLegacyModelMethod("account") ) `export default Account;` diff --git a/app/models/bk/bank-account.coffee b/app/models/bk/bank-account.coffee index bd20b0496..2cc02dbb6 100644 --- a/app/models/bk/bank-account.coffee +++ b/app/models/bk/bank-account.coffee @@ -1,7 +1,10 @@ `import Ember from "ember";` `import BkBankAccount from "balanced-addon-models/models/bank-account";` +`import BkUtils from "balanced-dashboard/utils/bk-utils";` BankAccount = BkBankAccount.extend( + routeName: "bank_accounts" + toLegacyModel: BkUtils.generateToLegacyModelMethod("bank_account") ) `export default BankAccount;` diff --git a/app/routes/settlement.coffee b/app/routes/settlement.coffee index c33641c46..fafe8e95f 100644 --- a/app/routes/settlement.coffee +++ b/app/routes/settlement.coffee @@ -11,10 +11,10 @@ SettlementRoute = ModelRoute.extend( store = @getStore() store.fetchItem("account", model.get("source_uri")).then (source) -> - model.set("source", source) + model.set("source", source.toLegacyModel()) - this.get("container").lookupFactory("model:bank_account").find(model.get("destination_uri")).then (destination) -> - model.set("destination", destination) + store.fetchItem("account", model.get("destination_uri")).then (destination) -> + model.set("destination", destination.toLegacyModel()) creditsResultsLoader = this.get("container").lookupFactory("results-loader:transactions").create({ path: model.get("credits_uri") diff --git a/app/styles/results.less b/app/styles/results.less index 159a894e8..8a789d43c 100644 --- a/app/styles/results.less +++ b/app/styles/results.less @@ -155,6 +155,11 @@ header.results-label h3 { thead { border: none; margin-top: -1px; + + th { + border-top: none; + border-bottom: none; + } } tr { @@ -205,6 +210,11 @@ header.results-label h3 { thead { border: none; margin-top: -1px; + + th { + border-top: none; + border-bottom: none; + } } &:last-of-type { @@ -315,6 +325,7 @@ header.results-label h3 { font-family: 'Balanced-Icon'; color: @gray4; } + .icon-credit-card:before, .icon-debit-card:before { &:extend(.icon-card:before); } diff --git a/app/templates/orders.hbs b/app/templates/orders.hbs index 079eb10f7..7c9b1a2f0 100644 --- a/app/templates/orders.hbs +++ b/app/templates/orders.hbs @@ -19,12 +19,12 @@ {{#if view.isActivityTabSelected}}

    Charges

    - {{view "results/transactions-table-grouped-by-customer" loader=debitsResultsLoader customers=model.buyers embedded=true}} + {{view "results/transactions-table-grouped-by-customer" loader=debitsResultsLoader paymentMethodText="From" customers=model.buyers embedded=true}}

    Payouts

    - {{view "results/transactions-table-grouped-by-customer" loader=creditsResultsLoader customers=model.seller embedded=true}} + {{view "results/transactions-table-grouped-by-customer" loader=creditsResultsLoader paymentMethodText="To" customers=model.seller embedded=true}}
    {{/if}} diff --git a/app/templates/results/associated-transactions-table.hbs b/app/templates/results/associated-transactions-table.hbs index 3ea93f753..36b4279f8 100644 --- a/app/templates/results/associated-transactions-table.hbs +++ b/app/templates/results/associated-transactions-table.hbs @@ -1,12 +1,15 @@ - + Transaction - - Payment method + + From - + + To + + Amount @@ -15,51 +18,51 @@ {{#if view.transaction}} - - {{#view "results/grouped-transactions-table"}} + + {{#view "results/grouped-transactions-table" embedded=true}} {{#if view.parentView.transaction.dispute}} - {{view "results/grouped-transaction-row" item=view.parentView.transaction.dispute}} + {{view "results/grouped-transaction-row" item=view.parentView.transaction.dispute embedded=true}} {{/if}} {{#if view.parentView.transaction.refunds}} {{#each refund in view.parentView.transaction.refunds}} - {{view "results/grouped-transaction-row" item=refund}} + {{view "results/grouped-transaction-row" item=refund embedded=true}} {{/each}} {{/if}} {{#if view.parentView.transaction.reversals}} {{#each reversal in view.parentView.transaction.reversals}} - {{view "results/grouped-transaction-row" item=reversal}} + {{view "results/grouped-transaction-row" item=reversal embedded=true}} {{/each}} {{/if}} {{#if view.parentView.transaction.debit}} {{#if view.parentView.transaction.debit.dispute}} - {{view "results/grouped-transaction-row" item=view.parentView.transaction.debit.dispute}} + {{view "results/grouped-transaction-row" item=view.parentView.transaction.debit.dispute embedded=true}} {{/if}} - {{view "results/grouped-transaction-row" item=view.parentView.transaction.debit}} + {{view "results/grouped-transaction-row" item=view.parentView.transaction.debit embedded=true}} {{/if}} {{#if view.parentView.transaction.credit}} - {{view "results/grouped-transaction-row" item=view.parentView.transaction.credit}} + {{view "results/grouped-transaction-row" item=view.parentView.transaction.credit embedded=true}} {{/if}} - {{view "results/grouped-transaction-row" item=view.parentView.transaction class="current"}} + {{view "results/grouped-transaction-row" item=view.parentView.transaction class="current" embedded=true}} {{#if view.parentView.transaction.transaction}} - {{view "results/grouped-transaction-row" item=view.parentView.transaction.transaction}} - {{view "results/grouped-transaction-row" item=view.parentView.transaction.transaction.hold}} + {{view "results/grouped-transaction-row" item=view.parentView.transaction.transaction embedded=true}} + {{view "results/grouped-transaction-row" item=view.parentView.transaction.transaction.hold embedded=true}} {{/if}} {{#if view.parentView.transaction.hold}} - {{view "results/grouped-transaction-row" item=view.parentView.transaction.hold}} + {{view "results/grouped-transaction-row" item=view.parentView.transaction.hold embedded=true}} {{/if}} {{/view}} {{else}} - + {{#if view.transaction.isLoaded}} No transactions {{else}} diff --git a/app/templates/results/embedded-transactions-table.hbs b/app/templates/results/embedded-transactions-table.hbs index 65831c26a..f1406ec85 100644 --- a/app/templates/results/embedded-transactions-table.hbs +++ b/app/templates/results/embedded-transactions-table.hbs @@ -1,25 +1,28 @@ - - Transaction + + Order - - Payment method + + From - + + To + + Amount {{#if view.loader.results.hasNextPage}} - {{view "results/results-load-more" results=view.loader.results columns=3}} + {{view "results/results-load-more" results=view.loader.results columns=view.colspan}} {{/if}} {{#each transaction in view.filteredResults}} {{#if transaction.order}} - + {{#view "results/grouped-transactions-table" embedded=true}} {{view "results/grouped-order-row" item=transaction.order embedded=true}} {{/view}} @@ -51,7 +54,7 @@ {{/if}} {{/view}} {{else}} - + {{#view "results/grouped-transactions-table" embedded=view.embedded}} {{#if transaction.dispute}} {{view "results/grouped-transaction-row" item=transaction.dispute embedded=true}} @@ -84,7 +87,7 @@ {{else}} - + {{#if view.loader.results.isLoaded}} No transactions {{else}} diff --git a/app/templates/results/grouped-transaction-row.hbs b/app/templates/results/grouped-transaction-row.hbs index 0f020dcdc..087200f2c 100644 --- a/app/templates/results/grouped-transaction-row.hbs +++ b/app/templates/results/grouped-transaction-row.hbs @@ -14,13 +14,24 @@ {{/link-to}} {{/unless}} - - {{#link-to view.routeName view.item}} - - {{view.paymentMethodText}} - - {{/link-to}} - +{{#unless view.hideFromColumn}} + + {{#link-to view.routeName view.item}} + + {{view.paymentMethodFromText}} + + {{/link-to}} + +{{/unless}} +{{#unless view.hideToColumn}} + + {{#link-to view.routeName view.item}} + + {{view.paymentMethodToText}} + + {{/link-to}} + +{{/unless}} {{#link-to view.routeName view.item}} diff --git a/app/templates/results/grouped-transactions-table-layout.hbs b/app/templates/results/grouped-transactions-table-layout.hbs index 54e21c4e5..ef376af6e 100644 --- a/app/templates/results/grouped-transactions-table-layout.hbs +++ b/app/templates/results/grouped-transactions-table-layout.hbs @@ -1,11 +1,16 @@ - + {{#unless view.embedded}} - + {{/unless}} - - + {{#unless view.hideFromColumn}} + + {{/unless}} + {{#unless view.hideToColumn}} + + {{/unless}} + diff --git a/app/templates/results/transactions-table-grouped-by-customer.hbs b/app/templates/results/transactions-table-grouped-by-customer.hbs index 6b18fa4ba..0ecac2fbd 100644 --- a/app/templates/results/transactions-table-grouped-by-customer.hbs +++ b/app/templates/results/transactions-table-grouped-by-customer.hbs @@ -1,9 +1,9 @@ Customer - Transaction + Transaction - Payment method + {{view.paymentMethodText}} Amount @@ -11,7 +11,7 @@ {{#if view.loader.results.hasNextPage}} - {{view "results/results-load-more" results=view.loader.results columns=4}} + {{view "results/results-load-more" results=view.loader.results columns=view.colspan}} {{/if}} @@ -25,28 +25,28 @@ title=customer_group.customer.display_me_with_email class="customer-group two-lines" }} - + {{#each transaction in customer_group.transactions}} - {{#view "results/grouped-transactions-table" embedded=view.embedded}} + {{#view "results/grouped-transactions-table" embedded=view.embedded hideFromColumn=view.hideFromColumn hideToColumn=view.hideToColumn}} {{#if transaction.dispute}} - {{view "results/grouped-transaction-row" item=transaction.dispute embedded=view.embedded}} + {{view "results/grouped-transaction-row" item=transaction.dispute embedded=view.embedded hideFromColumn=view.hideFromColumn hideToColumn=view.hideToColumn}} {{/if}} - {{view "results/grouped-transaction-row" item=transaction embedded=view.embedded}} + {{view "results/grouped-transaction-row" item=transaction embedded=view.embedded hideFromColumn=view.hideFromColumn hideToColumn=view.hideToColumn}} {{#if transaction.hold}} - {{view "results/grouped-transaction-row" item=transaction.hold embedded=view.embedded}} + {{view "results/grouped-transaction-row" item=transaction.hold embedded=view.embedded hideFromColumn=view.hideFromColumn hideToColumn=view.hideToColumn}} {{/if}} {{#if transaction.refunds}} {{#each refund in transaction.refunds}} - {{view "results/grouped-transaction-row" item=refund embedded=view.embedded}} + {{view "results/grouped-transaction-row" item=refund embedded=view.embedded hideFromColumn=view.hideFromColumn hideToColumn=view.hideToColumn}} {{/each}} {{/if}} {{#if transaction.reversals}} {{#each reversal in transaction.reversals}} - {{view "results/grouped-transaction-row" item=reversal embedded=view.embedded}} + {{view "results/grouped-transaction-row" item=reversal embedded=view.embedded hideFromColumn=view.hideFromColumn hideToColumn=view.hideToColumn}} {{/each}} {{/if}} {{/view}} @@ -54,7 +54,7 @@ {{else}} - + {{#if view.loader.results.isLoaded}} No transactions {{else}} diff --git a/app/templates/results/transactions-table-grouped-by-order.hbs b/app/templates/results/transactions-table-grouped-by-order.hbs index db41f8c4f..efa4260db 100644 --- a/app/templates/results/transactions-table-grouped-by-order.hbs +++ b/app/templates/results/transactions-table-grouped-by-order.hbs @@ -1,11 +1,12 @@ - Transaction + Transaction {{#unless view.embedded}} Customer {{/unless}} - Payment method - Amount + From + To + Amount {{#if view.loader.results.hasNextPage}} diff --git a/app/templates/results/transactions-table-grouped-by-settlement.hbs b/app/templates/results/transactions-table-grouped-by-settlement.hbs index 83aa85530..b82739f37 100644 --- a/app/templates/results/transactions-table-grouped-by-settlement.hbs +++ b/app/templates/results/transactions-table-grouped-by-settlement.hbs @@ -4,7 +4,8 @@ {{#unless view.embedded}} Customer {{/unless}} - Payment method + From + To Amount diff --git a/app/templates/settlement.hbs b/app/templates/settlement.hbs index cacbd42fc..0690b2f0d 100644 --- a/app/templates/settlement.hbs +++ b/app/templates/settlement.hbs @@ -10,7 +10,7 @@ {{#view "detail-views/main-panel"}}

    Related activity

    - {{view "results/transactions-table-grouped-by-order" loader=creditsResultsLoader}} + {{view "results/transactions-table-grouped-by-order" loader=creditsResultsLoader embedded=true}}

    Logs

    diff --git a/app/utils/bk-utils.coffee b/app/utils/bk-utils.coffee new file mode 100644 index 000000000..1e4db70d4 --- /dev/null +++ b/app/utils/bk-utils.coffee @@ -0,0 +1,5 @@ +BkUtils = + generateToLegacyModelMethod: (klassName) -> + return -> + BalancedApp.__container__.lookupFactory("model:#{klassName}").find(@get("href")) +`export default BkUtils;` diff --git a/app/views/detail-views/resource-summaries/resource-summary-base.coffee b/app/views/detail-views/resource-summaries/resource-summary-base.coffee index 56ab2a77f..13eeb113b 100644 --- a/app/views/detail-views/resource-summaries/resource-summary-base.coffee +++ b/app/views/detail-views/resource-summaries/resource-summary-base.coffee @@ -17,7 +17,7 @@ ResourceSummaryBase = Ember.View.extend( model.get("display_me") else if @isType("card") "#{model.get('last_four')} #{model.get('brand')}" - else if @isType("bank-account") + else if @isType("bank-account") || @isType("bk/bank-account") "#{model.get('last_four')} #{model.get('formatted_bank_name')}" else if @isType("bk/account") || @isType("account") currentRoute = @container.lookup("controller:application").get('currentRouteName') diff --git a/app/views/detail-views/summary-sections/settlement-summary-section.js b/app/views/detail-views/summary-sections/settlement-summary-section.js index 6df136943..f0c5b008d 100644 --- a/app/views/detail-views/summary-sections/settlement-summary-section.js +++ b/app/views/detail-views/summary-sections/settlement-summary-section.js @@ -3,8 +3,40 @@ import Utils from "balanced-dashboard/lib/utils"; var SettlementSummarySectionView = SummarySectionView.extend({ linkedResources: function() { - return this.resourceLinks("model.description", "model.source", "model.destination", "model.customer"); + return _.flatten([ + this.generateDescriptionResource(this.get("model")), + this.getResource(this.get("model.source")), + this.getResource(this.get("model.destination")), + this.generateResourceLink(this.get("model"), this.get("model.customer")) + ]).compact(); }.property("model.description", "model.source", "model.destination", "model.customer"), + + isSource: function(resource) { + return this.get("model.source_uri").indexOf(resource.get("id")) >= 0; + }, + + isDestination: function(resource) { + return this.get("model.destination_uri").indexOf(resource.get("id")) >= 0; + }, + + getResource: function(resource) { + if (resource) { + var title = ""; + + if (this.isSource(resource)) { + title = "From"; + } else if (this.isDestination(resource)) { + title = "To"; + } + + return { + className: 'icon-payable-account', + title: title, + resource: resource + }; + } + return null; + }, }); export default SettlementSummarySectionView; diff --git a/app/views/detail-views/summary-sections/summary-section.js b/app/views/detail-views/summary-sections/summary-section.js index 8805ece8a..a5f1105e6 100644 --- a/app/views/detail-views/summary-sections/summary-section.js +++ b/app/views/detail-views/summary-sections/summary-section.js @@ -150,23 +150,6 @@ var SummarySectionView = Ember.View.extend({ }; } - - if (parentModel.routeName === 'settlement') { - if (model.routeName === 'account') { - title = "From"; - className = "icon-payable-account"; - } else if (model.route_name === 'bank_accounts') { - title = "To"; - className = "icon-bank-account"; - } - - return { - className: className, - title: title, - resource: model, - }; - } - if (model.routeName === 'account') { return { className: 'icon-payable-account', diff --git a/app/views/results/associated-transactions-table.js b/app/views/results/associated-transactions-table.js index 11af90dca..879b2f96b 100644 --- a/app/views/results/associated-transactions-table.js +++ b/app/views/results/associated-transactions-table.js @@ -2,7 +2,9 @@ import TransactionsTableView from "./transactions-table"; var AssociatedTransactionsTableView = TransactionsTableView.extend({ templateName: "results/associated-transactions-table", - classNames: ["non-interactive"] + classNames: ["non-interactive"], + colspan: 4, + embedded: true }); export default AssociatedTransactionsTableView; diff --git a/app/views/results/embedded-transactions-table.js b/app/views/results/embedded-transactions-table.js index 3bf85d789..77d6f80ea 100644 --- a/app/views/results/embedded-transactions-table.js +++ b/app/views/results/embedded-transactions-table.js @@ -3,6 +3,9 @@ import TransactionsTableView from "./transactions-table"; var EmbeddedTransactionsTableView = TransactionsTableView.extend({ templateName: "results/embedded-transactions-table", classNames: ["non-interactive"], + embedded: true, + colspan: 4, + filteredResults: function() { var results = this.get("loader.results"); var filteredResults = []; diff --git a/app/views/results/grouped-transaction-row.js b/app/views/results/grouped-transaction-row.js index d3eb41cbf..df4ba57c8 100644 --- a/app/views/results/grouped-transaction-row.js +++ b/app/views/results/grouped-transaction-row.js @@ -43,9 +43,90 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ return Utils.humanReadableDateTime(this.get('item.created_at')); }.property('item.created_at'), - bankAccount: function() { - var BankAccount = this.container.lookupFactory("model:bank-account"); - return BankAccount.find(this.get("item.destination_uri")); + paymentMethodFromText: function() { + var label = ""; + var type = ""; + var typeName = this.get('typeName'); + + if (typeName === "Debit" || typeName === "Hold") { + label = this.get("item.source.last_four"); + type = this.get("dasherizedPaymentMethodType"); + } + if (typeName === "Credit" || typeName === "Refund") { + label = "Order balance"; + type = "orders"; + } + if (typeName === "Reversal") { + if (this.get("item.credit.destination.last_four")) { + label = this.get("item.credit.destination.last_four"); + type = Ember.String.dasherize(this.get("item.credit.destination.type_name")); + } else { + label = "Payable account"; + type = "payable-account"; + } + } + if (typeName === "Settlement") { + if (this.get("settlementSource")) { + label = this.get("settlementSource.last_four"); + type = Ember.String.dasherize(this.get("settlementSource.type_name")); + } else if (this.get("settlementDestination.type") === "payable") { + label = "Payable account"; + type = "payable-account"; + } + } + return Utils.safeFormat('%@', type, label).htmlSafe(); + }.property("typeName", "item.source.last_four", "item.source.type_name", "dasherizedPaymentMethodType", "item.credit.destination.last_four", "item.credit.destination.type_name", "settlementSource.last_four", "settlementSource.type_name"), + + paymentMethodToText: function() { + var label = ""; + var type = ""; + var typeName = this.get('typeName'); + if (typeName === "Debit" || typeName === "Hold") { + label = "Order balance"; + type = "orders"; + } + if (typeName === "Credit") { + if (this.get("item.destination.last_four")) { + label = this.get("item.destination.last_four"); + type = this.get("dasherizedPaymentMethodType"); + } else { + label = "Payable account"; + type = "payable-account"; + } + } + if (typeName === "Refund") { + label = this.get("item.debit.source.last_four"); + type = Ember.String.dasherize(this.get("item.debit.source.type_name")); + } + if (typeName === "Reversal") { + label = "Order balance"; + type = "orders"; + } + if (typeName === "Settlement") { + console.log(this.get("settlementDestination")) + if (this.get("settlementDestination.last_four")) { + label = this.get("settlementDestination.last_four"); + type = Ember.String.dasherize(this.get("settlementDestination.type_name")); + } else if (this.get("settlementDestination.type") === "payable") { + label = "Payable account"; + type = "payable-account"; + } + } + return Utils.safeFormat('%@', type, label).htmlSafe(); + }.property("typeName", "item.destination.last_four", "item.destination.type_name", "dasherizedPaymentMethodType", "item.debit.source.last_four", "item.debit.source.type_name", "settlementDestination.last_four", "settlementDestination.type_name"), + + settlementSource: function() { + var store = this.container.lookup("controller:marketplace").get("store"); + store.fetchItem("account", this.get("item.source_uri")).then(function(source) { + return source.toLegacyModel(); + }); + }.property("item.source_uri"), + + settlementDestination: function() { + var store = this.container.lookup("controller:marketplace").get("store"); + store.fetchItem("account", this.get("item.destination_uri")).then(function(destination) { + return destination.toLegacyModel(); + }); }.property("item.destination_uri"), customer: Ember.computed.reads("bankAccount.customer"), @@ -65,46 +146,8 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ } }.property("item.seller.display_me", "item.customer.display_me", "settlementCustomerText"), - settlementCustomerText: function() { - var label = '%@%@'; - var primaryLabel = this.get("customer.display_me"); - var secondaryLabel = this.get("customer.email_address"); - - return Utils.safeFormat(label, primaryLabel, secondaryLabel).htmlSafe(); - }.property("customer.display_me", "customer.email_address"), - - paymentMethodText: function() { - if (this.get('typeName') === "Settlement") { - return this.get("settlementPaymentMethodText"); - } - var label = '%@%@'; - return Utils.safeFormat(label, this.get('paymentMethodPrimaryLabelText')).htmlSafe(); - }.property('paymentMethodPrimaryLabelText', "settlementPaymentMethodText", "typeName"), - - settlementPaymentMethodText: function() { - var bankAccount = this.get('bankAccount'); - var label = '%@%@'; - var primaryLabel = "%@ %@".fmt(bankAccount.get("last_four"), bankAccount.get("brand")); - var secondaryLabel = bankAccount.get("funding_instrument_type"); - return Utils.safeFormat(label, primaryLabel, secondaryLabel).htmlSafe(); - }.property("bankAccount.last_four", "bankAccount.brand", "bankAccount.funding_instrument_type"), - dasherizedPaymentMethodType: Ember.computed.reads("item.dasherized_funding_instrument_type"), - paymentMethodPrimaryLabelText: function() { - var label = ""; - var dasherizedPaymentMethodType = this.get("dasherizedPaymentMethodType"); - - if (this.get("item.destination.type") === "payable") { - label = "Payable account"; - } else if (this.get("item.source")) { - label = this.get("item.source.last_four"); - } else { - label = this.get("item.destination.last_four"); - } - return Utils.safeFormat('%@', dasherizedPaymentMethodType, label).htmlSafe(); - }.property("item.source.last_four", "item.destination.last_four", "dasherizedPaymentMethodType"), - amountText: function() { if (this.get("typeName") === "Order") { var label = '%@Order balance'; diff --git a/app/views/results/transactions-table-grouped-by-customer.js b/app/views/results/transactions-table-grouped-by-customer.js index 5ebab831c..4fce801b7 100644 --- a/app/views/results/transactions-table-grouped-by-customer.js +++ b/app/views/results/transactions-table-grouped-by-customer.js @@ -4,6 +4,10 @@ var TransactionsTableGroupedByCustomerView = TransactionsTableView.extend({ templateName: 'results/transactions-table-grouped-by-customer', classNames: 'non-interactive', + colspan: 3, + hideFromColumn: Ember.computed.equal("paymentMethodText", "To"), + hideToColumn: Ember.computed.equal("paymentMethodText", "From"), + customersArray: function() { var customers = this.get("customers"); if (!Ember.isArray(customers)) { diff --git a/app/views/results/transactions-table-grouped-by-order.js b/app/views/results/transactions-table-grouped-by-order.js index 2d43422ab..641b2d698 100644 --- a/app/views/results/transactions-table-grouped-by-order.js +++ b/app/views/results/transactions-table-grouped-by-order.js @@ -5,7 +5,7 @@ var TransactionsTableGroupedByOrderView = TransactionsTableView.extend({ classNames: 'non-interactive', colspan: function() { - return (this.get("embedded")) ? "3": "4"; + return (this.get("embedded")) ? "4": "5"; }.property("embedded"), groupedResults: function() { diff --git a/app/views/results/transactions-table-grouped-by-settlement.js b/app/views/results/transactions-table-grouped-by-settlement.js index df94ba3c4..72bd9b6df 100644 --- a/app/views/results/transactions-table-grouped-by-settlement.js +++ b/app/views/results/transactions-table-grouped-by-settlement.js @@ -6,7 +6,7 @@ var TransactionsTableGroupedBySettlement = ResultsTableView.extend({ classNames: ['settlements', 'non-interactive'], colspan: function() { - return (this.get("embedded")) ? "3": "4"; + return (this.get("embedded")) ? "4": "5"; }.property("embedded"), groupedResults: function() { From 7c1ed2e58cdb5c0ddc9cc2b92b111bb9c5e12033 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Fri, 16 Jan 2015 11:41:30 -0800 Subject: [PATCH 32/80] Display settlment payment methods --- app/styles/results.less | 5 +---- app/views/results/grouped-transaction-row.js | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/app/styles/results.less b/app/styles/results.less index 8a789d43c..b20f42ae1 100644 --- a/app/styles/results.less +++ b/app/styles/results.less @@ -349,10 +349,7 @@ header.results-label h3 { a > span:before { float: left; margin-top: 7px; - } - - a > span.failed:before { - margin-bottom: 10px; + margin-bottom: 10px; } } diff --git a/app/views/results/grouped-transaction-row.js b/app/views/results/grouped-transaction-row.js index df4ba57c8..63410bc14 100644 --- a/app/views/results/grouped-transaction-row.js +++ b/app/views/results/grouped-transaction-row.js @@ -66,16 +66,16 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ } } if (typeName === "Settlement") { - if (this.get("settlementSource")) { + if (this.get("settlementSource.last_four")) { label = this.get("settlementSource.last_four"); type = Ember.String.dasherize(this.get("settlementSource.type_name")); - } else if (this.get("settlementDestination.type") === "payable") { + } else if (this.get("settlementSource.type") === "payable") { label = "Payable account"; type = "payable-account"; } } return Utils.safeFormat('%@', type, label).htmlSafe(); - }.property("typeName", "item.source.last_four", "item.source.type_name", "dasherizedPaymentMethodType", "item.credit.destination.last_four", "item.credit.destination.type_name", "settlementSource.last_four", "settlementSource.type_name"), + }.property("typeName", "item.source.last_four", "item.source.type_name", "dasherizedPaymentMethodType", "item.credit.destination.last_four", "item.credit.destination.type_name", "settlementSource.last_four", "settlementSource.type_name", "settlementSource.type"), paymentMethodToText: function() { var label = ""; @@ -103,7 +103,6 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ type = "orders"; } if (typeName === "Settlement") { - console.log(this.get("settlementDestination")) if (this.get("settlementDestination.last_four")) { label = this.get("settlementDestination.last_four"); type = Ember.String.dasherize(this.get("settlementDestination.type_name")); @@ -113,19 +112,22 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ } } return Utils.safeFormat('%@', type, label).htmlSafe(); - }.property("typeName", "item.destination.last_four", "item.destination.type_name", "dasherizedPaymentMethodType", "item.debit.source.last_four", "item.debit.source.type_name", "settlementDestination.last_four", "settlementDestination.type_name"), + }.property("typeName", "item.destination.last_four", "item.destination.type_name", "dasherizedPaymentMethodType", "item.debit.source.last_four", "item.debit.source.type_name", "settlementDestination.last_four", "settlementDestination.type_name", "settlementDestination.type"), - settlementSource: function() { + settlementSource: function(attr) { + var self = this; var store = this.container.lookup("controller:marketplace").get("store"); store.fetchItem("account", this.get("item.source_uri")).then(function(source) { - return source.toLegacyModel(); + self.set(attr, source.toLegacyModel()); }); + return null; }.property("item.source_uri"), - settlementDestination: function() { + settlementDestination: function(attr) { + var self = this; var store = this.container.lookup("controller:marketplace").get("store"); store.fetchItem("account", this.get("item.destination_uri")).then(function(destination) { - return destination.toLegacyModel(); + self.set(attr, destination.toLegacyModel()); }); }.property("item.destination_uri"), From 7a1fb84ff972e2ddc89d45925c3370c03788e74d Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Fri, 16 Jan 2015 18:08:58 -0800 Subject: [PATCH 33/80] Refactor grouped transaction tables and update tests --- app/routes/marketplace/index.js | 3 + app/styles/results.less | 2 +- app/templates/account.hbs | 4 +- app/templates/marketplace/settlements.hbs | 2 +- .../results/associated-transactions-table.hbs | 4 + .../credits-table-grouped-by-settlement.hbs | 32 ++++++ ...ummy-grouped-transactions-table-header.hbs | 18 ++++ app/templates/results/grouped-credits-row.hbs | 41 ++++++++ .../results/grouped-transaction-row.hbs | 2 +- .../grouped-transactions-table-layout.hbs | 18 ++-- ...transactions-table-grouped-by-customer.hbs | 22 ++--- .../transactions-table-grouped-by-order.hbs | 99 ++++++++----------- ...ansactions-table-grouped-by-settlement.hbs | 50 ---------- app/templates/settlement.hbs | 2 +- ...=> credits-table-grouped-by-settlement.js} | 7 +- app/views/results/grouped-credits-row.js | 0 app/views/results/grouped-transaction-row.js | 5 + .../results/grouped-transactions-table.js | 2 +- .../transactions-table-grouped-by-customer.js | 2 +- .../transactions-table-grouped-by-order.js | 1 + tests/helpers/testing.js | 2 +- tests/integration/charge-card-test.js | 4 +- ...ansactions-test.js => marketplace-test.js} | 82 ++------------- tests/integration/orders-test.js | 28 +++++- tests/integration/pay-seller-test.js | 4 +- tests/integration/search-test.js | 2 +- tests/unit/models/hold-test.coffee | 2 +- 27 files changed, 215 insertions(+), 225 deletions(-) create mode 100644 app/templates/results/credits-table-grouped-by-settlement.hbs create mode 100644 app/templates/results/dummy-grouped-transactions-table-header.hbs create mode 100644 app/templates/results/grouped-credits-row.hbs delete mode 100644 app/templates/results/transactions-table-grouped-by-settlement.hbs rename app/views/results/{transactions-table-grouped-by-settlement.js => credits-table-grouped-by-settlement.js} (86%) create mode 100644 app/views/results/grouped-credits-row.js rename tests/integration/{transactions-test.js => marketplace-test.js} (70%) diff --git a/app/routes/marketplace/index.js b/app/routes/marketplace/index.js index 2af358f69..1bbbc1d12 100644 --- a/app/routes/marketplace/index.js +++ b/app/routes/marketplace/index.js @@ -1,6 +1,9 @@ import AuthRoute from "balanced-dashboard/routes/auth"; var MarketplaceIndexRoute = AuthRoute.extend({ + beforeModel: function() { + this.transitionTo('marketplace.orders'); + } }); export default MarketplaceIndexRoute; diff --git a/app/styles/results.less b/app/styles/results.less index b20f42ae1..d2051b9c1 100644 --- a/app/styles/results.less +++ b/app/styles/results.less @@ -306,7 +306,7 @@ header.results-label h3 { } } - a > span:after { + &.connected a > span:after { position: absolute; content: ''; border-left: 2px solid @gray3; diff --git a/app/templates/account.hbs b/app/templates/account.hbs index c3302a51c..30a050d68 100644 --- a/app/templates/account.hbs +++ b/app/templates/account.hbs @@ -13,11 +13,11 @@ {{#view "detail-views/main-panel"}}

    Unsettled transactions

    - {{view "results/transactions-table-grouped-by-order" loader=creditsResultsLoader embedded=true}} + {{view "results/transactions-table-grouped-by-order" isCredit=true loader=creditsResultsLoader embedded=true}}

    Settled transactions

    - {{view "results/transactions-table-grouped-by-settlement" loader=settlementsResultsLoader embedded=true}} + {{view "results/credits-table-grouped-by-settlement" loader=settlementsResultsLoader embedded=true}}
    {{/view}} {{/view}} diff --git a/app/templates/marketplace/settlements.hbs b/app/templates/marketplace/settlements.hbs index a9846634c..9eacae6de 100644 --- a/app/templates/marketplace/settlements.hbs +++ b/app/templates/marketplace/settlements.hbs @@ -4,6 +4,6 @@
    - {{view "results/transactions-table-grouped-by-settlement" loader=resultsLoader}} + {{view "results/credits-table-grouped-by-settlement" loader=resultsLoader}}
    diff --git a/app/templates/results/associated-transactions-table.hbs b/app/templates/results/associated-transactions-table.hbs index 36b4279f8..4a65cd2c0 100644 --- a/app/templates/results/associated-transactions-table.hbs +++ b/app/templates/results/associated-transactions-table.hbs @@ -20,6 +20,10 @@ {{#view "results/grouped-transactions-table" embedded=true}} + {{#if view.parentView.transaction.order}} + {{view "results/grouped-transaction-row" item=view.parentView.transaction.order embedded=true}} + {{/if}} + {{#if view.parentView.transaction.dispute}} {{view "results/grouped-transaction-row" item=view.parentView.transaction.dispute embedded=true}} {{/if}} diff --git a/app/templates/results/credits-table-grouped-by-settlement.hbs b/app/templates/results/credits-table-grouped-by-settlement.hbs new file mode 100644 index 000000000..4b21749d0 --- /dev/null +++ b/app/templates/results/credits-table-grouped-by-settlement.hbs @@ -0,0 +1,32 @@ +{{#each settlementGroup in view.groupedResults}} + + + {{#view "results/grouped-transactions-table" embedded=view.embedded}} + {{view "results/grouped-transaction-row" item=settlementGroup.settlement embedded=view.embedded}} + {{/view}} + {{#each orderGroup in settlementGroup.orderGroups}} + {{#view "results/grouped-transactions-table" embedded=view.embedded}} + {{view "results/grouped-transaction-row" item=orderGroup.order embedded=view.embedded}} + + {{#each transaction in orderGroup.transactions}} + {{#if transaction.reversals}} + {{#each reversal in transaction.reversals}} + {{view "results/grouped-transaction-row" item=reversal embedded=view.embedded}} + {{/each}} + {{/if}} + {{view "results/grouped-transaction-row" item=transaction embedded=view.embedded}} + {{/each}} + {{/view}} + {{/each}} + +{{else}} + + + {{#if view.loader.results.isLoaded}} + No transactions + {{else}} + Loading... + {{/if}} + + +{{/each}} diff --git a/app/templates/results/dummy-grouped-transactions-table-header.hbs b/app/templates/results/dummy-grouped-transactions-table-header.hbs new file mode 100644 index 000000000..ef376af6e --- /dev/null +++ b/app/templates/results/dummy-grouped-transactions-table-header.hbs @@ -0,0 +1,18 @@ + + + + {{#unless view.embedded}} + + {{/unless}} + {{#unless view.hideFromColumn}} + + {{/unless}} + {{#unless view.hideToColumn}} + + {{/unless}} + + + + + {{yield}} + diff --git a/app/templates/results/grouped-credits-row.hbs b/app/templates/results/grouped-credits-row.hbs new file mode 100644 index 000000000..663352c89 --- /dev/null +++ b/app/templates/results/grouped-credits-row.hbs @@ -0,0 +1,41 @@ + + {{#link-to view.routeName view.item}} + + {{view.displayValue}} + + {{/link-to}} + +{{#unless view.embedded}} + + {{#link-to view.routeName view.item}} + + {{view.customerText}} + + {{/link-to}} + +{{/unless}} +{{#unless view.hideFromColumn}} + + {{#link-to view.routeName view.item}} + + {{view.paymentMethodFromText}} + + {{/link-to}} + +{{/unless}} +{{#unless view.hideToColumn}} + + {{#link-to view.routeName view.item}} + + {{view.paymentMethodToText}} + + {{/link-to}} + +{{/unless}} + + {{#link-to view.routeName view.item}} + + {{view.amountText}} + + {{/link-to}} + diff --git a/app/templates/results/grouped-transaction-row.hbs b/app/templates/results/grouped-transaction-row.hbs index 087200f2c..663352c89 100644 --- a/app/templates/results/grouped-transaction-row.hbs +++ b/app/templates/results/grouped-transaction-row.hbs @@ -1,4 +1,4 @@ - + {{#link-to view.routeName view.item}} {{view.displayValue}} diff --git a/app/templates/results/grouped-transactions-table-layout.hbs b/app/templates/results/grouped-transactions-table-layout.hbs index ef376af6e..c12feeb2e 100644 --- a/app/templates/results/grouped-transactions-table-layout.hbs +++ b/app/templates/results/grouped-transactions-table-layout.hbs @@ -1,18 +1,18 @@ - + Transaction {{#unless view.embedded}} - + Customer {{/unless}} - {{#unless view.hideFromColumn}} - - {{/unless}} - {{#unless view.hideToColumn}} - - {{/unless}} - + From + To + Amount +{{#if view.loader.results.hasNextPage}} + {{view "results/results-load-more" results=view.loader.results columns="view.colspan"}} +{{/if}} + {{yield}} diff --git a/app/templates/results/transactions-table-grouped-by-customer.hbs b/app/templates/results/transactions-table-grouped-by-customer.hbs index 0ecac2fbd..046992e6f 100644 --- a/app/templates/results/transactions-table-grouped-by-customer.hbs +++ b/app/templates/results/transactions-table-grouped-by-customer.hbs @@ -25,19 +25,9 @@ title=customer_group.customer.display_me_with_email class="customer-group two-lines" }} - + {{#each transaction in customer_group.transactions}} {{#view "results/grouped-transactions-table" embedded=view.embedded hideFromColumn=view.hideFromColumn hideToColumn=view.hideToColumn}} - {{#if transaction.dispute}} - {{view "results/grouped-transaction-row" item=transaction.dispute embedded=view.embedded hideFromColumn=view.hideFromColumn hideToColumn=view.hideToColumn}} - {{/if}} - - {{view "results/grouped-transaction-row" item=transaction embedded=view.embedded hideFromColumn=view.hideFromColumn hideToColumn=view.hideToColumn}} - - {{#if transaction.hold}} - {{view "results/grouped-transaction-row" item=transaction.hold embedded=view.embedded hideFromColumn=view.hideFromColumn hideToColumn=view.hideToColumn}} - {{/if}} - {{#if transaction.refunds}} {{#each refund in transaction.refunds}} {{view "results/grouped-transaction-row" item=refund embedded=view.embedded hideFromColumn=view.hideFromColumn hideToColumn=view.hideToColumn}} @@ -49,6 +39,16 @@ {{view "results/grouped-transaction-row" item=reversal embedded=view.embedded hideFromColumn=view.hideFromColumn hideToColumn=view.hideToColumn}} {{/each}} {{/if}} + + {{#if transaction.dispute}} + {{view "results/grouped-transaction-row" item=transaction.dispute embedded=view.embedded hideFromColumn=view.hideFromColumn hideToColumn=view.hideToColumn}} + {{/if}} + + {{view "results/grouped-transaction-row" item=transaction embedded=view.embedded hideFromColumn=view.hideFromColumn hideToColumn=view.hideToColumn}} + + {{#if transaction.hold}} + {{view "results/grouped-transaction-row" item=transaction.hold embedded=view.embedded hideFromColumn=view.hideFromColumn hideToColumn=view.hideToColumn}} + {{/if}} {{/view}} {{/each}} diff --git a/app/templates/results/transactions-table-grouped-by-order.hbs b/app/templates/results/transactions-table-grouped-by-order.hbs index efa4260db..435ae2ecd 100644 --- a/app/templates/results/transactions-table-grouped-by-order.hbs +++ b/app/templates/results/transactions-table-grouped-by-order.hbs @@ -1,63 +1,44 @@ - +{{#each orderGroup in view.groupedResults}} - Transaction - {{#unless view.embedded}} - Customer - {{/unless}} - From - To - Amount + {{#if orderGroup.order}} + + {{#view "results/grouped-transactions-table" embedded=view.embedded}} + {{view "results/grouped-transaction-row" item=orderGroup.order embedded=view.embedded}} + {{/view}} + {{#view "results/grouped-transactions-table" embedded=view.embedded}} + {{#each transaction in orderGroup.transactions}} + {{#if transaction.reversals}} + {{#each reversal in transaction.reversals}} + {{view "results/grouped-transaction-row" item=reversal embedded=view.embedded}} + {{/each}} + {{/if}} + {{view "results/grouped-transaction-row" item=transaction embedded=view.embedded}} + {{/each}} + {{/view}} + + {{else}} + + {{#view "results/grouped-transactions-table" embedded=view.embedded}} + {{#each transaction in orderGroup.transactions}} + {{#if transaction.reversals}} + {{#each reversal in transaction.reversals}} + {{view "results/grouped-transaction-row" item=reversal embedded=view.embedded}} + {{/each}} + {{/if}} + {{view "results/grouped-transaction-row" item=transaction embedded=view.embedded}} + {{/each}} + {{/view}} + + {{/if}} - -{{#if view.loader.results.hasNextPage}} - {{view "results/results-load-more" results=view.loader.results columns=view.colspan}} -{{/if}} - - - {{#each orderGroup in view.groupedResults}} - - {{#if orderGroup.order}} - - {{#view "results/grouped-transactions-table" embedded=view.embedded}} - {{view "results/grouped-transaction-row" item=orderGroup.order embedded=view.embedded}} - {{/view}} - {{#view "results/grouped-transactions-table" embedded=view.embedded}} - {{#each transaction in orderGroup.transactions}} - {{view "results/grouped-transaction-row" item=transaction embedded=view.embedded}} - - {{#if transaction.reversals}} - {{#each reversal in transaction.reversals}} - {{view "results/grouped-transaction-row" item=reversal embedded=view.embedded}} - {{/each}} - {{/if}} - {{/each}} - {{/view}} - +{{else}} + + + {{#if view.loader.results.isLoaded}} + No transactions {{else}} - - {{#view "results/grouped-transactions-table" embedded=view.embedded}} - {{#each transaction in orderGroup.transactions}} - {{view "results/grouped-transaction-row" item=transaction embedded=view.embedded}} - - {{#if transaction.reversals}} - {{#each reversal in transaction.reversals}} - {{view "results/grouped-transaction-row" item=reversal embedded=view.embedded}} - {{/each}} - {{/if}} - {{/each}} - {{/view}} - + Loading... {{/if}} - - {{else}} - - - {{#if view.loader.results.isLoaded}} - No transactions - {{else}} - Loading... - {{/if}} - - - {{/each}} - + + +{{/each}} diff --git a/app/templates/results/transactions-table-grouped-by-settlement.hbs b/app/templates/results/transactions-table-grouped-by-settlement.hbs deleted file mode 100644 index b82739f37..000000000 --- a/app/templates/results/transactions-table-grouped-by-settlement.hbs +++ /dev/null @@ -1,50 +0,0 @@ - - - Transaction - {{#unless view.embedded}} - Customer - {{/unless}} - From - To - Amount - - -{{#if view.loader.results.hasNextPage}} - {{view "results/results-load-more" results=view.loader.results columns="view.colspan"}} -{{/if}} - - - {{#each settlementGroup in view.groupedResults}} - - - {{#view "results/grouped-transactions-table" embedded=view.embedded}} - {{view "results/grouped-transaction-row" item=settlementGroup.settlement embedded=view.embedded}} - {{/view}} - {{#each orderGroup in settlementGroup.orderGroups}} - {{#view "results/grouped-transactions-table" embedded=view.embedded}} - {{view "results/grouped-transaction-row" item=orderGroup.order embedded=view.embedded}} - - {{#each transaction in orderGroup.transactions}} - {{view "results/grouped-transaction-row" item=transaction embedded=view.embedded}} - - {{#if transaction.reversals}} - {{#each reversal in transaction.reversals}} - {{view "results/grouped-transaction-row" item=reversal embedded=view.embedded}} - {{/each}} - {{/if}} - {{/each}} - {{/view}} - {{/each}} - - {{else}} - - - {{#if view.loader.results.isLoaded}} - No transactions - {{else}} - Loading... - {{/if}} - - - {{/each}} - diff --git a/app/templates/settlement.hbs b/app/templates/settlement.hbs index 0690b2f0d..7989b4f18 100644 --- a/app/templates/settlement.hbs +++ b/app/templates/settlement.hbs @@ -10,7 +10,7 @@ {{#view "detail-views/main-panel"}}

    Related activity

    - {{view "results/transactions-table-grouped-by-order" loader=creditsResultsLoader embedded=true}} + {{view "results/transactions-table-grouped-by-order" isCredit=true loader=creditsResultsLoader embedded=true}}

    Logs

    diff --git a/app/views/results/transactions-table-grouped-by-settlement.js b/app/views/results/credits-table-grouped-by-settlement.js similarity index 86% rename from app/views/results/transactions-table-grouped-by-settlement.js rename to app/views/results/credits-table-grouped-by-settlement.js index 72bd9b6df..79ec70263 100644 --- a/app/views/results/transactions-table-grouped-by-settlement.js +++ b/app/views/results/credits-table-grouped-by-settlement.js @@ -1,8 +1,9 @@ import ResultsTableView from "./results-table"; import SearchModelArray from "balanced-dashboard/models/core/search-model-array"; -var TransactionsTableGroupedBySettlement = ResultsTableView.extend({ - templateName: 'results/transactions-table-grouped-by-settlement', +var CreditsTableGroupedBySettlement = ResultsTableView.extend({ + layoutName: 'results/grouped-transactions-table-layout', + templateName: 'results/credits-table-grouped-by-settlement', classNames: ['settlements', 'non-interactive'], colspan: function() { @@ -52,4 +53,4 @@ var TransactionsTableGroupedBySettlement = ResultsTableView.extend({ } }); -export default TransactionsTableGroupedBySettlement; +export default CreditsTableGroupedBySettlement; diff --git a/app/views/results/grouped-credits-row.js b/app/views/results/grouped-credits-row.js new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/results/grouped-transaction-row.js b/app/views/results/grouped-transaction-row.js index 63410bc14..011307de5 100644 --- a/app/views/results/grouped-transaction-row.js +++ b/app/views/results/grouped-transaction-row.js @@ -9,6 +9,7 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ routeName: Computed.orProperties("item.route_name", "item.routeName"), spanClassNames: Ember.computed.reads("item.status"), typeName: Ember.computed.reads("item.type_name"), + connected: true, title: function() { if (_.contains(this.get("classNames"), "current")) { @@ -152,6 +153,10 @@ var GroupedTransactionRowView = LinkedTwoLinesCellView.extend({ amountText: function() { if (this.get("typeName") === "Order") { + if (["account", "settlement"].contains(this.container.lookup("controller:application").get('currentRouteName'))) { + return null; + } + var label = '%@Order balance'; var primaryLabel = Utils.formatCurrency(this.get("item.amount_escrowed")); return Utils.safeFormat(label, primaryLabel).htmlSafe(); diff --git a/app/views/results/grouped-transactions-table.js b/app/views/results/grouped-transactions-table.js index 5fdbb5fe0..bad3277dd 100644 --- a/app/views/results/grouped-transactions-table.js +++ b/app/views/results/grouped-transactions-table.js @@ -1,7 +1,7 @@ import Ember from "ember"; var GroupedTransactionsTableView = Ember.View.extend({ - layoutName: 'results/grouped-transactions-table-layout', + layoutName: 'results/dummy-grouped-transactions-table-header', tagName: 'table', classNames: ["items", "grouped-transactions"], }); diff --git a/app/views/results/transactions-table-grouped-by-customer.js b/app/views/results/transactions-table-grouped-by-customer.js index 4fce801b7..7e01a7644 100644 --- a/app/views/results/transactions-table-grouped-by-customer.js +++ b/app/views/results/transactions-table-grouped-by-customer.js @@ -4,7 +4,7 @@ var TransactionsTableGroupedByCustomerView = TransactionsTableView.extend({ templateName: 'results/transactions-table-grouped-by-customer', classNames: 'non-interactive', - colspan: 3, + colspan: 4, hideFromColumn: Ember.computed.equal("paymentMethodText", "To"), hideToColumn: Ember.computed.equal("paymentMethodText", "From"), diff --git a/app/views/results/transactions-table-grouped-by-order.js b/app/views/results/transactions-table-grouped-by-order.js index 641b2d698..8bab4bb1e 100644 --- a/app/views/results/transactions-table-grouped-by-order.js +++ b/app/views/results/transactions-table-grouped-by-order.js @@ -1,6 +1,7 @@ import TransactionsTableView from "./transactions-table"; var TransactionsTableGroupedByOrderView = TransactionsTableView.extend({ + layoutName: 'results/grouped-transactions-table-layout', templateName: 'results/transactions-table-grouped-by-order', classNames: 'non-interactive', diff --git a/tests/helpers/testing.js b/tests/helpers/testing.js index aa863add0..0240715f7 100644 --- a/tests/helpers/testing.js +++ b/tests/helpers/testing.js @@ -25,7 +25,7 @@ var Testing = { // constant routes MARKETPLACES_ROUTE: '/marketplaces', - TRANSACTIONS_ROUTE: null, + MARKETPLACE_ROUTE: null, ADD_CUSTOMER_ROUTE: null, BANK_ACCOUNT_ROUTE: null, CARD_ROUTE: null, diff --git a/tests/integration/charge-card-test.js b/tests/integration/charge-card-test.js index 544da2636..282011885 100644 --- a/tests/integration/charge-card-test.js +++ b/tests/integration/charge-card-test.js @@ -26,7 +26,7 @@ module('Integration - Charge Card', { }); test('form validation', 2, function() { - visit(Testing.TRANSACTIONS_ROUTE) + visit(Testing.MARKETPLACE_ROUTE) .click('.page-navigation a:contains(Debit a card)') .checkElements({ "#charge-card button:contains(Debit)": 1 @@ -45,7 +45,7 @@ test('can charge a card', function() { }] }); - visit(Testing.TRANSACTIONS_ROUTE) + visit(Testing.MARKETPLACE_ROUTE) .click('.page-navigation a:contains(Debit a card)') .fillForm('#charge-card', { name: 'Tarun Chaudhry', diff --git a/tests/integration/transactions-test.js b/tests/integration/marketplace-test.js similarity index 70% rename from tests/integration/transactions-test.js rename to tests/integration/marketplace-test.js index bdca1be09..3ade32ae9 100644 --- a/tests/integration/transactions-test.js +++ b/tests/integration/marketplace-test.js @@ -12,7 +12,7 @@ var App, Adapter, ADD_FUNDS_SELECTOR = "#marketplace-escrow-menu a:contains(Add funds)", WITHDRAW_FUNDS_SELECTOR = "#marketplace-escrow-menu a:contains(Withdraw funds)"; -module('Integration - Transactions', { +module('Integration - Marketplace', { setup: function() { App = startApp(); Adapter = App.__container__.lookup("adapter:main"); @@ -38,40 +38,12 @@ var setupMarketplaceController = function(bankAccounts) { })); }); }; -var assertQueryString = function(string, expected) { - var qsParameters = Utils.queryStringToObject(string); - _.each(expected, function(value, key) { - deepEqual(qsParameters[key], value, "Query string parameter %@".fmt(key)); - }); -}; - -var getResultsUri = function() { - var controller = BalancedApp.__container__.lookup("controller:marketplace/transactions"); - return controller.get("resultsLoader.resultsUri"); -}; - -test('can visit page', function() { - visit(Testing.TRANSACTIONS_ROUTE) - .click(".nav-pills a:contains(Transactions)") - .checkPageTitle("Payments") - .checkElements({ - '.payments-navbar a:contains(Export)': 1 - }) - .then(function() { - var resultsUri = getResultsUri(); - deepEqual(resultsUri.split("?")[0], '/transactions', 'Transactions URI is correct'); - assertQueryString(resultsUri, { - limit: "50", - sort: "created_at,desc" - }); - }); -}); test('add funds', function() { var spy = sinon.spy(Adapter, "create"); var bankAccounts = Models.BankAccount.findAll(); - visit(Testing.TRANSACTIONS_ROUTE) + visit(Testing.MARKETPLACE_ROUTE) .then(function() { setupMarketplaceController(bankAccounts); }) @@ -107,7 +79,7 @@ test('add funds only adds once despite multiple clicks', function() { var stub = sinon.stub(Adapter, "create"); var bankAccounts = Models.BankAccount.findAll(); - visit(Testing.TRANSACTIONS_ROUTE) + visit(Testing.MARKETPLACE_ROUTE) .then(function() { setupMarketplaceController(bankAccounts); }) @@ -127,7 +99,7 @@ test('withdraw funds', function() { var spy = sinon.spy(Adapter, "create"); var bankAccounts = Models.BankAccount.findAll(); - visit(Testing.TRANSACTIONS_ROUTE) + visit(Testing.MARKETPLACE_ROUTE) .then(function() { setupMarketplaceController(bankAccounts); }) @@ -167,7 +139,7 @@ test('withdraw funds only withdraws once despite multiple clicks', function() { var stub = sinon.stub(Adapter, "create"); var bankAccounts = Models.BankAccount.findAll(); - visit(Testing.TRANSACTIONS_ROUTE) + visit(Testing.MARKETPLACE_ROUTE) .then(function() { setupMarketplaceController(bankAccounts); }) @@ -182,10 +154,10 @@ test('withdraw funds only withdraws once despite multiple clicks', function() { }); }); -test('download activity', function() { +test('download transactions', function() { var stub; - visit(Testing.TRANSACTIONS_ROUTE) + visit(Testing.MARKETPLACE_ROUTE) .then(function() { var controller = BalancedApp.__container__.lookup("controller:marketplace/transactions"); var loader = controller.get("resultsLoader"); @@ -211,43 +183,3 @@ test('download activity', function() { "#header .notification-center-message:last": "We're processing your request. We will email you once the exported data is ready to view." }); }); - -test('transactions date sort has different states', function() { - var objectPath = ".results th.date .sortable"; - var states = []; - var count = 0; - var testAmount = 5; - - visit(Testing.TRANSACTIONS_ROUTE) - .then(function() { - ok($(objectPath).is(".descending"), "Search defaults to descending"); - }) - .click(objectPath) - .then(function() { - ok($(objectPath).is(".ascending"), "Search is set to ascending"); - }); -}); - -test('Filter Activity transactions table by type & status', function() { - visit(Testing.TRANSACTIONS_ROUTE) - .click('#content .results table.transactions th.type .type-filter li a:contains(Holds)') - .then(function() { - var resultsUri = getResultsUri(); - deepEqual(resultsUri.split("?")[0], '/transactions', 'Activity Transactions URI is correct'); - assertQueryString(resultsUri, { - type: "hold", - 'status[in]': 'failed,succeeded,pending', - limit: "50", - sort: "created_at,desc" - }); - }) - .click('#content table.transactions th.type a:contains(All)') - .click("#content table.transactions th.status a:contains(Succeeded)") - .then(function() { - assertQueryString(getResultsUri(), { - status: "succeeded", - limit: "50", - sort: "created_at,desc" - }); - }); -}); diff --git a/tests/integration/orders-test.js b/tests/integration/orders-test.js index 4802299d6..04b7ac046 100644 --- a/tests/integration/orders-test.js +++ b/tests/integration/orders-test.js @@ -39,9 +39,7 @@ var assertQueryString = function(string, expected) { test("can visit orders page", function() { visit(Testing.MARKETPLACE_ROUTE) - .click(".sidebar a:contains(Payments)") - .click(".nav-pills a:contains(Orders)") - .checkPageTitle("Payments") + .checkPageTitle("Orders") .then(function() { var resultsUri = BalancedApp.__container__.lookup('controller:marketplace/orders').get("resultsLoader.resultsUri"); deepEqual(resultsUri.split("?")[0], "/orders"); @@ -64,6 +62,30 @@ test('can sort orders by date', function() { }); }); +test('Filter orders table by type & status', function() { + visit(Testing.MARKETPLACE_ROUTE) + .click('#content .results table.transactions th:first-of-type li a:contains(Holds)') + .then(function() { + var resultsUri = getResultsUri(); + deepEqual(resultsUri.split("?")[0], '/transactions', 'Activity Transactions URI is correct'); + assertQueryString(resultsUri, { + type: "hold", + 'status[in]': 'failed,succeeded,pending', + limit: "50", + sort: "created_at,desc" + }); + }) + .click('#content table.transactions th:first-of-type a:contains(All)') + .click("#content table.transactions th.status a:contains(Succeeded)") + .then(function() { + assertQueryString(getResultsUri(), { + status: "succeeded", + limit: "50", + sort: "created_at,desc" + }); + }); +}); + test('can visit order page', function() { visit(Testing.ORDER_ROUTE) .checkPageType("Order") diff --git a/tests/integration/pay-seller-test.js b/tests/integration/pay-seller-test.js index 60c6796df..002a12275 100644 --- a/tests/integration/pay-seller-test.js +++ b/tests/integration/pay-seller-test.js @@ -26,7 +26,7 @@ module('Integration - Pay Seller', { test('can pay a seller', function() { var stub = sinon.stub(Adapter, "create"); - visit(Testing.TRANSACTIONS_ROUTE) + visit(Testing.MARKETPLACE_ROUTE) .click(".page-navigation a:contains(Credit a bank account)") .fillForm('#pay-seller', { 'name': 'TEST', @@ -58,7 +58,7 @@ test('can pay a seller', function() { test('pay a seller only submits once despite multiple button clicks', function() { var stub = sinon.stub(Adapter, "create"); - visit(Testing.TRANSACTIONS_ROUTE) + visit(Testing.MARKETPLACE_ROUTE) .click(".page-navigation a:contains(Credit a bank account)") .fillForm('#pay-seller', { 'name': 'TEST', diff --git a/tests/integration/search-test.js b/tests/integration/search-test.js index 1860b1c5d..6aca409a4 100644 --- a/tests/integration/search-test.js +++ b/tests/integration/search-test.js @@ -112,7 +112,7 @@ test('search date range pick', function() { "created_at[<]": "2013-08-01T23:59:00.000Z", "created_at[>]": "2013-08-01T00:00:00.000Z", sort: "created_at,desc", - "type[in]": "credit,debit,card_hold,refund,reversal" + "type[in]": "debit,credit,card_hold,refund,reversal" }); }); }); diff --git a/tests/unit/models/hold-test.coffee b/tests/unit/models/hold-test.coffee index cbab7a908..615446acd 100644 --- a/tests/unit/models/hold-test.coffee +++ b/tests/unit/models/hold-test.coffee @@ -21,7 +21,7 @@ test "#status", -> s.set "debit", "Some value" t "captured" -tet "#can_void_or_capture", -> +test "#can_void_or_capture", -> s = Hold.create() t = (expected) -> deepEqual s.get("can_void_or_capture"), expected From 106c753e779f4fc99bdc17d9b33f423feeeb9308 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Mon, 19 Jan 2015 16:00:27 -0800 Subject: [PATCH 34/80] Update tests --- tests/integration/orders-test.js | 2 +- .../results-loaders/marketplace-search-results-loader-test.js | 2 +- tests/unit/views/sidebar/marketplace-sidebar-test.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integration/orders-test.js b/tests/integration/orders-test.js index 04b7ac046..a566dfc97 100644 --- a/tests/integration/orders-test.js +++ b/tests/integration/orders-test.js @@ -106,6 +106,6 @@ test('displays correct number of charges and payouts per customer', function() { ".customer-group": 2, ".grouped-transactions-container": 2, ".grouped-transactions-container .grouped-transactions": 3, - ".grouped-transactions-container .grouped-transactions tr": 5 + ".grouped-transactions-container .grouped-transactions tr": 8 }); }); diff --git a/tests/unit/models/results-loaders/marketplace-search-results-loader-test.js b/tests/unit/models/results-loaders/marketplace-search-results-loader-test.js index 95fc587fd..00dcca9bd 100644 --- a/tests/unit/models/results-loaders/marketplace-search-results-loader-test.js +++ b/tests/unit/models/results-loaders/marketplace-search-results-loader-test.js @@ -30,7 +30,7 @@ test("#results", function() { subject.set("query", "Kermit"); subject.get("results"); deepEqual(searchStub.firstCall.args, [ - "/search?sort=created_at%2Cdesc&type%5Bin%5D=credit%2Cdebit%2Ccard_hold%2Crefund%2Creversal&q=Kermit", + "/search?sort=created_at%2Cdesc&type%5Bin%5D=debit%2Ccredit%2Ccard_hold%2Crefund%2Creversal&q=Kermit", Customer ]); }); diff --git a/tests/unit/views/sidebar/marketplace-sidebar-test.js b/tests/unit/views/sidebar/marketplace-sidebar-test.js index 4f321400f..579d85939 100644 --- a/tests/unit/views/sidebar/marketplace-sidebar-test.js +++ b/tests/unit/views/sidebar/marketplace-sidebar-test.js @@ -10,7 +10,7 @@ test("#sidebarItemsDefinition", function() { } }); - deepEqual(view.get("items.length"), 7); + deepEqual(view.get("items.length"), 8); view.set("marketplace", null); deepEqual(view.get("items.length"), 0); }); From 9579cb06a5baa0a7bf98ad5e1e3723a1d1873968 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Mon, 19 Jan 2015 16:01:16 -0800 Subject: [PATCH 35/80] Display payable account balance in order summary section --- .../summary-sections/order-summary-section.js | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/app/views/detail-views/summary-sections/order-summary-section.js b/app/views/detail-views/summary-sections/order-summary-section.js index aad10b716..de088526b 100644 --- a/app/views/detail-views/summary-sections/order-summary-section.js +++ b/app/views/detail-views/summary-sections/order-summary-section.js @@ -9,8 +9,29 @@ var OrderSummarySectionView = SummarySectionView.extend({ }.property("model.status"), linkedResources: function() { - return this.resourceLinks("model.description", "model.seller"); - }.property("model.description", "model.seller") + return _.flatten([ + this.generateDescriptionResource(this.get("model")), + this.generateResourceLink(this.get("model"), this.get("model.seller")), + { + className: "icon-payable-account", + title: "Merchant payable account", + resource: this.get("sellerAccount") + } + ]).compact(); + }.property("model.description", "model.seller", "model.seller.accounts_uri", "sellerAccount"), + + sellerAccount: function(attr) { + var self = this; + var accountsUri = this.get("model.seller.accounts_uri"); + + if (accountsUri) { + var store = this.container.lookup("controller:marketplace").get("store"); + store.fetchItem("account", accountsUri).then(function(account) { + self.set(attr, account.toLegacyModel()); + }); + } + return null; + }.property("model.seller.accounts_uri") }); export default OrderSummarySectionView; From e43d9a85712444af21e83ec05d65ef144372ac6f Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Mon, 19 Jan 2015 16:01:43 -0800 Subject: [PATCH 36/80] Display correct payment icons in settlment summary section --- app/models/customer.js | 3 +- app/styles/results.less | 8 ----- .../settlement-summary-section.js | 32 +++++++------------ bower.json | 2 +- 4 files changed, 14 insertions(+), 31 deletions(-) diff --git a/app/models/customer.js b/app/models/customer.js index 87e015e1a..4db5499fe 100644 --- a/app/models/customer.js +++ b/app/models/customer.js @@ -20,14 +20,13 @@ var Customer = Model.extend({ orders: Model.hasMany('orders', 'order'), disputes: Model.hasMany('disputes', 'dispute'), accounts: Model.hasMany('accounts', 'account'), + account: Ember.computed.reads("accountsResultsLoader.results.content.0"), uri: '/customers', route_name: 'customer', type_name: 'Customer', has_bank_account: Ember.computed.and('bank_accounts.isLoaded', 'bank_accounts.length'), - account: Ember.computed.reads("accountsResultsLoader.results.content.0"), - accountBalance: Ember.computed.reads("accountsResultsLoader.results.content.0.balance"), orders_list: function() { var customer_uri = this.get('href'); diff --git a/app/styles/results.less b/app/styles/results.less index d2051b9c1..c8ebfe384 100644 --- a/app/styles/results.less +++ b/app/styles/results.less @@ -325,14 +325,6 @@ header.results-label h3 { font-family: 'Balanced-Icon'; color: @gray4; } - - .icon-credit-card:before, .icon-debit-card:before { - &:extend(.icon-card:before); - } - - .icon-checking-account:before, .icon-savings-account:before { - &:extend(.icon-bank-account:before); - } } td.status { diff --git a/app/views/detail-views/summary-sections/settlement-summary-section.js b/app/views/detail-views/summary-sections/settlement-summary-section.js index f0c5b008d..c2edf6dbe 100644 --- a/app/views/detail-views/summary-sections/settlement-summary-section.js +++ b/app/views/detail-views/summary-sections/settlement-summary-section.js @@ -5,32 +5,24 @@ var SettlementSummarySectionView = SummarySectionView.extend({ linkedResources: function() { return _.flatten([ this.generateDescriptionResource(this.get("model")), - this.getResource(this.get("model.source")), - this.getResource(this.get("model.destination")), + this.get("sourceResource"), + this.get("destinationResource"), this.generateResourceLink(this.get("model"), this.get("model.customer")) ]).compact(); - }.property("model.description", "model.source", "model.destination", "model.customer"), + }.property("model.description", "model.customer", "sourceResource", "destinationResource"), - isSource: function(resource) { - return this.get("model.source_uri").indexOf(resource.get("id")) >= 0; - }, - - isDestination: function(resource) { - return this.get("model.destination_uri").indexOf(resource.get("id")) >= 0; - }, - - getResource: function(resource) { - if (resource) { - var title = ""; + sourceResource: function() { + return this.getResource("From", this.get("model.source")); + }.property("model.source", "model.source.isLoaded", "model.source.type_name"), - if (this.isSource(resource)) { - title = "From"; - } else if (this.isDestination(resource)) { - title = "To"; - } + destinationResource: function() { + return this.getResource("To", this.get("model.destination")); + }.property("model.destination", "model.destination.isLoaded", "model.destination.type_name"), + getResource: function(title, resource) { + if (resource && resource.get("isLoaded")) { return { - className: 'icon-payable-account', + className: 'icon-%@'.fmt(Ember.String.dasherize(resource.get("type_name"))), title: title, resource: resource }; diff --git a/bower.json b/bower.json index 227851fe3..c8a0e3cf2 100644 --- a/bower.json +++ b/bower.json @@ -12,7 +12,7 @@ "ember-validations": "lcoq/ember-validations", "google-code-prettify": "1.0.0", "handlebars": "1.3.0", - "strapped": "0.3.15", + "strapped": "0.3.16", "jquery-csv": "", "jquery-hotkeys": "jeresig/jquery.hotkeys", "jquery.cookie": "1.3.1", From ce97c5d786ba558f97f718e50b8e36235e3194a1 Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Mon, 19 Jan 2015 16:42:39 -0800 Subject: [PATCH 37/80] Display merchant link in settlment summary section --- .../settlement-summary-section.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/views/detail-views/summary-sections/settlement-summary-section.js b/app/views/detail-views/summary-sections/settlement-summary-section.js index c2edf6dbe..b877b93d6 100644 --- a/app/views/detail-views/summary-sections/settlement-summary-section.js +++ b/app/views/detail-views/summary-sections/settlement-summary-section.js @@ -5,11 +5,11 @@ var SettlementSummarySectionView = SummarySectionView.extend({ linkedResources: function() { return _.flatten([ this.generateDescriptionResource(this.get("model")), + this.get("customerResource"), this.get("sourceResource"), this.get("destinationResource"), - this.generateResourceLink(this.get("model"), this.get("model.customer")) ]).compact(); - }.property("model.description", "model.customer", "sourceResource", "destinationResource"), + }.property("model.description", "customerResource", "sourceResource", "destinationResource"), sourceResource: function() { return this.getResource("From", this.get("model.source")); @@ -19,7 +19,18 @@ var SettlementSummarySectionView = SummarySectionView.extend({ return this.getResource("To", this.get("model.destination")); }.property("model.destination", "model.destination.isLoaded", "model.destination.type_name"), - getResource: function(title, resource) { + customer: function() { + var customerUri = this.get("model.destination.customer_uri"); + if (customerUri) { + return this.container.lookupFactory("model:customer").find(customerUri); + } + }.property("model.destination.customer_uri"), + + customerResource: function(attr) { + return this.getResource("Merchant", this.get("customer")); + }.property("customer", "customer.isLoaded"), + + getResource: function(title, resource, className) { if (resource && resource.get("isLoaded")) { return { className: 'icon-%@'.fmt(Ember.String.dasherize(resource.get("type_name"))), From 18c3a4768d98cd813e64d6bd9a1feff5cb7cb2ee Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Tue, 20 Jan 2015 10:37:22 -0800 Subject: [PATCH 38/80] Replace old loading and delete icons --- Brocfile.js | 2 +- app/styles/marketplace.less | 11 +++++++++-- app/templates/events.hbs | 4 ++-- .../marketplaces/add-existing-marketplace.hbs | 4 +++- app/templates/marketplaces/add-test-marketplace.hbs | 4 +++- app/templates/marketplaces/marketplace-link-bar.hbs | 4 +++- app/templates/modals/evidence-portal-modal.hbs | 4 ++-- .../results/grouped-transactions-table-layout.hbs | 2 +- app/templates/results/orders-table.hbs | 6 +++--- app/templates/results/results-load-more.hbs | 4 ++-- bower.json | 2 +- tests/integration/marketplaces-test.js | 2 +- 12 files changed, 31 insertions(+), 18 deletions(-) diff --git a/Brocfile.js b/Brocfile.js index 97a74dfa3..1028d9867 100644 --- a/Brocfile.js +++ b/Brocfile.js @@ -34,7 +34,7 @@ var fonts = pickFiles('bower_components/strapped/static/fonts', { var images = pickFiles('bower_components/strapped/static/images', { srcDir: '/', - files: ['**/*.png', '**/*.gif'], + files: ['**/*.png'], destDir: '/images' }); diff --git a/app/styles/marketplace.less b/app/styles/marketplace.less index 9db8ce92a..d26231d57 100644 --- a/app/styles/marketplace.less +++ b/app/styles/marketplace.less @@ -112,8 +112,15 @@ form { li { margin: 5px 0; position: relative; - .delete { - float: right; + + .icon-table-x { + color: @gray1; + margin-top: 25px; + margin-right: 10px; + + &:hover { + color: @white; + } } .info { height: 65px; diff --git a/app/templates/events.hbs b/app/templates/events.hbs index c50934ead..c50e5a6f0 100644 --- a/app/templates/events.hbs +++ b/app/templates/events.hbs @@ -39,8 +39,8 @@
    {{eventCallback.status}}
    {{#if eventCallback.isSaving}} -
    - +
    + Loading...
    {{else}} Replay diff --git a/app/templates/marketplaces/add-existing-marketplace.hbs b/app/templates/marketplaces/add-existing-marketplace.hbs index 11fdfe45b..f826df9b2 100644 --- a/app/templates/marketplaces/add-existing-marketplace.hbs +++ b/app/templates/marketplaces/add-existing-marketplace.hbs @@ -1,6 +1,8 @@
    {{#if view.isSubmitting}} - + + Adding... + {{else}} {{/if}} diff --git a/app/templates/marketplaces/add-test-marketplace.hbs b/app/templates/marketplaces/add-test-marketplace.hbs index 69812388e..e4e8abc29 100644 --- a/app/templates/marketplaces/add-test-marketplace.hbs +++ b/app/templates/marketplaces/add-test-marketplace.hbs @@ -1,6 +1,8 @@
    {{#if view.isSubmitting}} - + + Adding... + {{else}} {{/if}} diff --git a/app/templates/marketplaces/marketplace-link-bar.hbs b/app/templates/marketplaces/marketplace-link-bar.hbs index 246bf8cf5..2d4069396 100644 --- a/app/templates/marketplaces/marketplace-link-bar.hbs +++ b/app/templates/marketplaces/marketplace-link-bar.hbs @@ -1,5 +1,7 @@ {{#if view.isTest}} - × + + + {{/if}}
    diff --git a/app/templates/modals/evidence-portal-modal.hbs b/app/templates/modals/evidence-portal-modal.hbs index 80861712a..e4fda356c 100644 --- a/app/templates/modals/evidence-portal-modal.hbs +++ b/app/templates/modals/evidence-portal-modal.hbs @@ -23,8 +23,8 @@ {{format-file-size doc.file_size}} {{#if doc.isUploading}} - {{#if view.loader.results.loadingNextPage}} -
    - +
    + Loading...
    {{else}} {{#if view.loader.results.hasNextPage}} - {{view "results/results-load-more" results=view.loader.results}} + {{view "results/results-load-more" results=view.loader.results columns=5}}
    {{/if}} {{/if}} diff --git a/app/templates/results/results-load-more.hbs b/app/templates/results/results-load-more.hbs index b3dd77fc2..ef131ecb6 100644 --- a/app/templates/results/results-load-more.hbs +++ b/app/templates/results/results-load-more.hbs @@ -1,8 +1,8 @@ {{#if view.results.loadingNextPage}} -
    - +
    + Loading...
    {{else}} {{#if view.results.hasNextPage}}
    Load more diff --git a/bower.json b/bower.json index c8a0e3cf2..8bcb6ea80 100644 --- a/bower.json +++ b/bower.json @@ -12,7 +12,7 @@ "ember-validations": "lcoq/ember-validations", "google-code-prettify": "1.0.0", "handlebars": "1.3.0", - "strapped": "0.3.16", + "strapped": "0.3.18", "jquery-csv": "", "jquery-hotkeys": "jeresig/jquery.hotkeys", "jquery.cookie": "1.3.1", diff --git a/tests/integration/marketplaces-test.js b/tests/integration/marketplaces-test.js index 93bbdb401..d8e58cd0e 100644 --- a/tests/integration/marketplaces-test.js +++ b/tests/integration/marketplaces-test.js @@ -100,7 +100,7 @@ test('delete marketplace', function() { var uri; visit(Testing.MARKETPLACES_ROUTE) - .click(".marketplace-list.test li:first-of-type .icon-delete") + .click(".marketplace-list.test li:first-of-type .icon-table-x") .then(function() { stub = sinon.stub(jQuery, "ajax").returns(Ember.RSVP.resolve()); var mp = BalancedApp.__container__.lookup("controller:modals-container").get("currentModal.marketplace"); From ebfc2353dd1b8cf1e57b59d6fec0b85e7b3ab4de Mon Sep 17 00:00:00 2001 From: Kyungmin Kim Date: Wed, 21 Jan 2015 14:02:38 -0800 Subject: [PATCH 39/80] Update search results tab --- .../results-loaders/marketplace-search.js | 3 +- app/templates/modals/search-modal.hbs | 16 +++------ app/templates/results/accounts-table.hbs | 1 - app/templates/results/orders-table.hbs | 34 ------------------- app/utils/constants.js | 1 + app/views/modals/search-modal.coffee | 7 ++-- app/views/results/orders-table.js | 9 ----- .../transactions-table-grouped-by-order.js | 1 + 8 files changed, 11 insertions(+), 61 deletions(-) delete mode 100644 app/templates/results/orders-table.hbs delete mode 100644 app/views/results/orders-table.js diff --git a/app/models/results-loaders/marketplace-search.js b/app/models/results-loaders/marketplace-search.js index 035d09532..48bbf51be 100644 --- a/app/models/results-loaders/marketplace-search.js +++ b/app/models/results-loaders/marketplace-search.js @@ -10,11 +10,12 @@ import SearchModelArray from "../core/search-model-array"; import Constants from "balanced-dashboard/utils/constants"; var MarketplaceSearchResultsLoader = BaseResultsLoader.extend({ - searchType: "transaction", + searchType: "order_transaction", limit: null, type: function() { var mapping = { + "order_transaction": Constants.SEARCH.ORDER_TRANSACTION_TYPES, "funding_instrument": Constants.SEARCH.FUNDING_INSTRUMENT_TYPES, "customer": Constants.SEARCH.CUSTOMER_TYPES, "order": Constants.SEARCH.ORDER_TYPES, diff --git a/app/templates/modals/search-modal.hbs b/app/templates/modals/search-modal.hbs index e2b8812a0..584b3fd2f 100644 --- a/app/templates/modals/search-modal.hbs +++ b/app/templates/modals/search-modal.hbs @@ -1,11 +1,7 @@
    • - {{format-number view.totalOrders}} Orders -
    • - -
    • - {{format-number view.totalTransactions}} Transactions + {{format-number view.totalOrders}} Orders
    • @@ -36,11 +32,7 @@ {{view "form-fields/search-date-picker" viewName="dateTimePicker"}} {{#if view.isOrdersTabSelected}} - {{view "results/orders-table" loader=view.resultsLoader}} - {{/if}} - - {{#if view.isTransactionsTabSelected}} - {{view "results/transactions-table" loader=view.resultsLoader isSearch=true}} + {{view "results/transactions-table-grouped-by-order" loader=view.resultsLoader isSearch=true}} {{/if}} {{#if view.isCustomersTabSelected}} @@ -71,7 +63,9 @@ {{render "results/keyboard-shortcuts"}} {{/if}} {{else}} - Loading... +
      + Loading... +
      {{/if}} {{/if}}
    diff --git a/app/templates/results/accounts-table.hbs b/app/templates/results/accounts-table.hbs index c3b2e0303..a7a49d40e 100644 --- a/app/templates/results/accounts-table.hbs +++ b/app/templates/results/accounts-table.hbs @@ -25,7 +25,6 @@ {{#each funding_instrument in view.loader.results}} - {{funding_instrument.routeName}} {{#link-to funding_instrument.routeName funding_instrument}}