Skip to content

Commit 17e41ba

Browse files
fix: Restructure Account Invoice Tab (#5049)
Co-authored-by: iamareebjamal <[email protected]>
1 parent 620ad65 commit 17e41ba

File tree

8 files changed

+63
-147
lines changed

8 files changed

+63
-147
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import classic from 'ember-classic-decorator';
2+
import Component from '@ember/component';
3+
4+
@classic
5+
export default class CellDownloadInvoice extends Component {}

app/controllers/account/billing/invoices/list.js

Lines changed: 38 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -3,138 +3,43 @@ import EmberTableControllerMixin from 'open-event-frontend/mixins/ember-table-co
33

44
export default class extends Controller.extend(EmberTableControllerMixin) {
55
get columns() {
6-
let columns = [];
7-
if (this.model.params.invoice_status === 'upcoming') {
8-
columns = [
9-
{
10-
name : 'Invoice ID',
11-
valuePath : 'identifier'
12-
},
13-
{
14-
name : 'Event Name',
15-
valuePath : 'event',
16-
cellComponent : 'ui-table/cell/events/cell-event-invoice'
17-
},
18-
{
19-
name : 'Date Issued',
20-
valuePath : 'createdAt'
21-
},
22-
{
23-
name : 'Outstanding Amount',
24-
valuePath : 'amount',
25-
extraValuePaths : ['event'],
26-
cellComponent : 'ui-table/cell/events/cell-amount'
27-
},
28-
{
29-
name : 'View Invoice',
30-
valuePath : 'invoicePdfUrl'
31-
}
32-
];
33-
} else if (this.model.params.invoice_status === 'paid') {
34-
columns = [
35-
{
36-
name : 'Invoice ID',
37-
valuePath : 'identifier'
38-
},
39-
{
40-
name : 'Event Name',
41-
valuePath : 'event',
42-
cellComponent : 'ui-table/cell/events/cell-event-invoice'
43-
},
44-
{
45-
name : 'Date Issued',
46-
valuePath : 'createdAt'
47-
},
48-
{
49-
name : 'Amount',
50-
valuePath : 'amount',
51-
extraValuePaths : ['event'],
52-
cellComponent : 'ui-table/cell/events/cell-amount'
53-
},
54-
{
55-
name : 'Date Paid',
56-
valuePath : 'completedAt'
57-
},
58-
{
59-
name : 'View Invoice',
60-
valuePath : 'invoicePdfUrl'
61-
},
62-
{
63-
name : 'Action',
64-
valuePath : 'identifier',
65-
extraValuePaths : ['status'],
66-
cellComponent : 'ui-table/cell/events/cell-action'
67-
}
68-
69-
];
70-
} else if (this.model.params.invoice_status === 'due') {
71-
columns = [
72-
{
73-
name : 'Invoice ID',
74-
valuePath : 'identifier'
75-
},
76-
{
77-
name : 'Event Name',
78-
valuePath : 'event',
79-
cellComponent : 'ui-table/cell/events/cell-event-invoice'
80-
81-
},
82-
{
83-
name : 'Date Issued',
84-
valuePath : 'createdAt'
85-
},
86-
{
87-
name : 'Amount Due',
88-
valuePath : 'amount',
89-
extraValuePaths : ['event'],
90-
cellComponent : 'ui-table/cell/events/cell-amount'
91-
},
92-
{
93-
name : 'View Invoice',
94-
valuePath : 'invoicePdfUrl'
95-
},
96-
{
97-
name : 'Action',
98-
valuePath : 'identifier',
99-
extraValuePaths : ['status'],
100-
cellComponent : 'ui-table/cell/events/cell-action'
101-
}
102-
103-
];
104-
} else if (this.model.params.invoice_status === 'all') {
105-
columns = [
106-
{
107-
name : 'Invoice ID',
108-
valuePath : 'identifier'
109-
},
110-
{
111-
name : 'Event Name',
112-
valuePath : 'event',
113-
cellComponent : 'ui-table/cell/events/cell-event-invoice'
114-
},
115-
{
116-
name : 'Amount',
117-
valuePath : 'amount',
118-
extraValuePaths : ['event'],
119-
cellComponent : 'ui-table/cell/events/cell-amount',
120-
isSortable : true,
121-
headerComponent : 'tables/headers/sort'
122-
},
123-
{
124-
name : 'Status',
125-
valuePath : 'status',
126-
isSortable : true,
127-
headerComponent : 'tables/headers/sort'
128-
},
129-
{
130-
name : 'Action',
131-
valuePath : 'identifier',
132-
extraValuePaths : ['status'],
133-
cellComponent : 'ui-table/cell/events/cell-action'
134-
}
135-
136-
];
137-
}
138-
return columns;
6+
return [
7+
{
8+
name : 'Invoice ID',
9+
valuePath : 'identifier',
10+
extraValuePaths : ['invoicePdfUrl'],
11+
cellComponent : 'ui-table/cell/events/cell-download-invoice'
12+
},
13+
{
14+
name : 'Event Name',
15+
valuePath : 'event',
16+
cellComponent : 'ui-table/cell/events/cell-event-invoice'
17+
},
18+
{
19+
name : 'Date',
20+
valuePath : 'createdAt',
21+
isSortable : true
22+
},
23+
{
24+
name : 'Amount',
25+
valuePath : 'amount',
26+
extraValuePaths : ['event'],
27+
cellComponent : 'ui-table/cell/events/cell-amount',
28+
isSortable : true,
29+
headerComponent : 'tables/headers/sort'
30+
},
31+
{
32+
name : 'Status',
33+
valuePath : 'status',
34+
isSortable : true,
35+
headerComponent : 'tables/headers/sort'
36+
},
37+
{
38+
name : 'Action',
39+
valuePath : 'identifier',
40+
extraValuePaths : ['status'],
41+
cellComponent : 'ui-table/cell/events/cell-action'
42+
}
43+
];
13944
}
14045
}

app/models/user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export default ModelBase.extend({
8383
events : hasMany('event', { inverse: 'user' }),
8484
sessions : hasMany('session'),
8585
feedbacks : hasMany('feedback'),
86-
invoice : hasMany('event-invoice'),
86+
eventInvoices : hasMany('event-invoice'),
8787
attendees : hasMany('attendee'),
8888
speakers : hasMany('speaker'),
8989
discountCodes : hasMany('discount-code'),

app/routes/account/billing/invoices/list.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,22 @@ import Route from '@ember/routing/route';
22
import moment from 'moment';
33
import EmberTableRouteMixin from 'open-event-frontend/mixins/ember-table-route';
44
import { action } from '@ember/object';
5+
import { capitalize } from 'lodash-es';
56

67
export default class extends Route.extend(EmberTableRouteMixin) {
78
titleToken() {
8-
switch (this.params.invoice_status) {
9-
case 'paid':
10-
return this.l10n.t('Paid');
11-
case 'due':
12-
return this.l10n.t('Due');
13-
case 'upcoming':
14-
return this.l10n.t('Upcoming');
15-
case 'all':
16-
return this.l10n.t('All');
9+
if (['paid', 'due', 'refunding', 'refunded'].includes(this.params.invoice_status)) {
10+
return this.l10n.t(capitalize(this.params.invoice_status));
11+
} else {
12+
return this.l10n.t('All');
1713
}
1814
}
1915

2016
async model(params) {
2117
this.set('params', params);
2218
const searchField = 'status';
2319
let filterOptions = [];
24-
if (params.invoice_status === 'paid' || params.invoice_status === 'due') {
20+
if (['paid', 'due', 'refunding', 'refunded'].includes(params.invoice_status)) {
2521
filterOptions = [
2622
{
2723
name : 'status',
@@ -60,7 +56,7 @@ export default class extends Route.extend(EmberTableRouteMixin) {
6056

6157
queryString = this.applySortFilters(queryString, params);
6258
return {
63-
eventInvoices: await this.asArray(this.store.query('event-invoice', queryString)),
59+
eventInvoices: await this.asArray(this.authManager.currentUser.query('eventInvoices', queryString)),
6460
params
6561

6662
};

app/templates/account.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{{t 'Profile'}}
77
</LinkTo>
88
<LinkTo @route="account.billing" class="item">
9-
{{t 'Billing Info'}}
9+
{{t 'Billing'}}
1010
</LinkTo>
1111
<LinkTo @route="account.password" class="item">
1212
{{t 'Password'}}

app/templates/account/billing/invoices.hbs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
<LinkTo @route="account.billing.invoices.list" @model="upcoming" class="item">
1515
{{t 'Upcoming'}}
1616
</LinkTo>
17+
<LinkTo @route="account.billing.invoices.list" @model="refunding" class="item">
18+
{{t 'Refunding'}}
19+
</LinkTo>
20+
<LinkTo @route="account.billing.invoices.list" @model="refunded" class="item">
21+
{{t 'Refunded'}}
22+
</LinkTo>
1723
</TabbedNavigation>
1824
</div>
1925
</div>

app/templates/components/ui-table/cell/events/cell-action.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{#if (eq this.extraRecords.status 'due')}}
22
<LinkTo @route="event-invoice.review" @model={{this.record}} class="ui blue button">
3-
{{t 'Review and Pay'}}
3+
{{t 'Review and Pay'}}
44
</LinkTo>
55
{{else}}
66
<LinkTo @route="event-invoice.paid" @model={{this.record}} class="ui green button">
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<p> {{this.record}} </p>
2+
<a href="{{this.extraRecords.invoicePdfUrl}}">
3+
<i class="download icon"></i>
4+
</a>

0 commit comments

Comments
 (0)