Skip to content
71 changes: 71 additions & 0 deletions app/controllers/account/billing/invoices/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,77 @@ export default class extends Controller.extend(EmberTableControllerMixin) {

];
} else if (this.model.params.invoice_status === 'all') {
columns = [
{
name : 'Invoice ID',
valuePath : 'identifier'
},
{
name : 'Event Name',
valuePath : 'event',
cellComponent : 'ui-table/cell/events/cell-event-invoice'
},
{
name : 'Date',
valuePath : 'createdAt',
isSortable : true
},
{
name : 'Amount',
valuePath : 'amount',
extraValuePaths : ['event'],
cellComponent : 'ui-table/cell/events/cell-amount',
isSortable : true,
headerComponent : 'tables/headers/sort'
},
{
name : 'Status',
valuePath : 'status',
isSortable : true,
headerComponent : 'tables/headers/sort'
},
{
name : 'Action',
valuePath : 'identifier',
extraValuePaths : ['status'],
cellComponent : 'ui-table/cell/events/cell-action'
}

];
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand. It's the exact same code. Why are there else if statements everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand. It's the exact same code. Why are there else if statements everywhere?

it will be changed, I don't know what would be the exact column name. Not mentioned in issue.

} else if (this.model.params.invoice_status === 'refunding') {
columns = [
{
name : 'Invoice ID',
valuePath : 'identifier'
},
{
name : 'Event Name',
valuePath : 'event',
cellComponent : 'ui-table/cell/events/cell-event-invoice'
},
{
name : 'Amount',
valuePath : 'amount',
extraValuePaths : ['event'],
cellComponent : 'ui-table/cell/events/cell-amount',
isSortable : true,
headerComponent : 'tables/headers/sort'
},
{
name : 'Status',
valuePath : 'status',
isSortable : true,
headerComponent : 'tables/headers/sort'
},
{
name : 'Action',
valuePath : 'identifier',
extraValuePaths : ['status'],
cellComponent : 'ui-table/cell/events/cell-action'
}

];
} else if (this.model.params.invoice_status === 'refunded') {
columns = [
{
name : 'Invoice ID',
Expand Down
8 changes: 7 additions & 1 deletion app/routes/account/billing/invoices/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ export default class extends Route.extend(EmberTableRouteMixin) {
return this.l10n.t('Due');
case 'upcoming':
return this.l10n.t('Upcoming');
case 'unpaid':
return this.l10n.t('Unpaid');
case 'refunding':
return this.l10n.t('Refunding');
case 'refunded':
return this.l10n.t('Refunded');
Copy link
Member

Choose a reason for hiding this comment

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

Simply use capitalize function instead of switch case. Check out admin/sessions/list route. Use All in else

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

case 'all':
return this.l10n.t('All');
}
Expand All @@ -21,7 +27,7 @@ export default class extends Route.extend(EmberTableRouteMixin) {
this.set('params', params);
const searchField = 'status';
let filterOptions = [];
if (params.invoice_status === 'paid' || params.invoice_status === 'due') {
if (params.invoice_status === 'paid' || params.invoice_status === 'due' || params.invoice_status === 'refunding' || params.invoice_status === 'refunded') {
Copy link
Member

@iamareebjamal iamareebjamal Sep 11, 2020

Choose a reason for hiding this comment

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

Use ['paid', ...].includes(params.invoice_status)

filterOptions = [
{
name : 'status',
Expand Down
2 changes: 1 addition & 1 deletion app/templates/account.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{t 'Profile'}}
</LinkTo>
<LinkTo @route="account.billing" class="item">
{{t 'Billing Info'}}
{{t 'Billing'}}
</LinkTo>
<LinkTo @route="account.password" class="item">
{{t 'Password'}}
Expand Down
6 changes: 6 additions & 0 deletions app/templates/account/billing/invoices.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
<LinkTo @route="account.billing.invoices.list" @model="upcoming" class="item">
{{t 'Upcoming'}}
</LinkTo>
<LinkTo @route="account.billing.invoices.list" @model="refunding" class="item">
{{t 'Refunding'}}
</LinkTo>
<LinkTo @route="account.billing.invoices.list" @model="refunded" class="item">
{{t 'Refunded'}}
</LinkTo>
</TabbedNavigation>
</div>
</div>
Expand Down