Skip to content

Commit c00e254

Browse files
mrsaicharan1abhinavk96
authored andcommitted
feat: Implemented event invoices for organizers (#3230)
1 parent 2a9e44f commit c00e254

File tree

9 files changed

+230
-33
lines changed

9 files changed

+230
-33
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Controller from '@ember/controller';
2+
3+
export default class extends Controller {
4+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import Controller from '@ember/controller';
2+
import EmberTableControllerMixin from 'open-event-frontend/mixins/ember-table-controller';
3+
import { computed } from '@ember/object';
4+
5+
export default class extends Controller.extend(EmberTableControllerMixin) {
6+
@computed()
7+
get columns() {
8+
let columns = [];
9+
if (this.model.params.invoice_status === 'upcoming') {
10+
columns = [
11+
{
12+
name : 'Invoice ID',
13+
valuePath : 'id'
14+
},
15+
{
16+
name : 'Name',
17+
valuePath : 'event',
18+
cellComponent : 'ui-table/cell/events/cell-event-invoice'
19+
},
20+
{
21+
name : 'Date Issued',
22+
valuePath : 'createdAt'
23+
},
24+
{
25+
name : 'Outstanding Amount',
26+
valuePath : '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 : 'id'
38+
},
39+
{
40+
name : '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+
},
52+
{
53+
name : 'Date Paid',
54+
valuePath : 'completedAt'
55+
},
56+
{
57+
name : 'View Invoice',
58+
valuePath : 'invoicePdfUrl'
59+
}
60+
61+
];
62+
} else if (this.model.params.invoice_status === 'due') {
63+
columns = [
64+
{
65+
name : 'Invoice ID',
66+
valuePath : 'id'
67+
},
68+
{
69+
name : 'Name',
70+
valuePath : 'event',
71+
cellComponent : 'ui-table/cell/events/cell-event-invoice'
72+
73+
},
74+
{
75+
name : 'Date Issued',
76+
valuePath : 'createdAt'
77+
},
78+
{
79+
name : 'Amount Due',
80+
valuePath : 'amount'
81+
},
82+
{
83+
name : 'View Invoice',
84+
valuePath : 'invoicePdfUrl'
85+
}
86+
87+
];
88+
} else if (this.model.params.invoice_status === 'due') {
89+
columns = [
90+
{
91+
name : 'Invoice ID',
92+
valuePath : 'id'
93+
},
94+
{
95+
name : 'Name',
96+
valuePath : 'event',
97+
cellComponent : 'ui-table/cell/events/cell-event-invoice'
98+
},
99+
{
100+
name : 'Amount',
101+
valuePath : 'amount'
102+
},
103+
{
104+
name : 'Status',
105+
valuePath : 'status'
106+
}
107+
108+
];
109+
}
110+
return columns;
111+
}
112+
}

app/models/event-invoice.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default ModelBase.extend({
2626
expYear : attr('number'),
2727
amount : attr('number'),
2828
completedAt : attr('moment'),
29+
invoicePdfUrl : attr('string'),
2930

3031
/** relationships
3132
*

app/router.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ router.map(function() {
115115
this.route('danger-zone');
116116
this.route('billing', function() {
117117
this.route('payment-info');
118-
this.route('invoices');
118+
this.route('invoices', function() {
119+
this.route('list', { path: '/:invoice_status' });
120+
});
119121
});
120122
});
121123
this.route('explore');
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import Route from '@ember/routing/route';
2+
import moment from 'moment';
3+
import EmberTableRouteMixin from 'open-event-frontend/mixins/ember-table-route';
4+
import { action } from '@ember/object';
5+
6+
export default class extends Route.extend(EmberTableRouteMixin) {
7+
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');
17+
}
18+
}
19+
async model(params) {
20+
this.set('params', params);
21+
const searchField = 'name';
22+
let filterOptions = [];
23+
if (params.invoice_status === 'paid' || params.invoice_status === 'due') {
24+
filterOptions = [
25+
{
26+
name : 'status',
27+
op : 'eq',
28+
val : params.invoice_status
29+
}
30+
];
31+
} else if (params.invoice_status === 'upcoming') {
32+
filterOptions = [
33+
{
34+
and: [
35+
{
36+
name : 'deleted-at',
37+
op : 'eq',
38+
val : null
39+
},
40+
{
41+
name : 'created-at',
42+
op : 'ge',
43+
val : moment().subtract(30, 'days').toISOString()
44+
}
45+
]
46+
}
47+
];
48+
}
49+
50+
51+
filterOptions = this.applySearchFilters(filterOptions, params, searchField);
52+
53+
let queryString = {
54+
include : 'event',
55+
filter : filterOptions,
56+
'page[size]' : params.per_page || 10,
57+
'page[number]' : params.page || 1
58+
};
59+
60+
queryString = this.applySortFilters(queryString, params);
61+
return {
62+
eventInvoices: (await this.store.query('event-invoice', queryString)).toArray(),
63+
params
64+
65+
};
66+
67+
}
68+
@action
69+
refreshRoute() {
70+
this.refresh();
71+
}
72+
}
Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
<div class="ui grid stackable">
2-
<div class="thirteen wide column">
3-
<h2 class="ui header column">{{t 'Due Invoices'}}</h2>
2+
<div class="row">
3+
<div class="eight wide column">
4+
{{#tabbed-navigation isNonPointing=true}}
5+
{{#link-to 'account.billing.invoices.list' 'all' class='item'}}
6+
{{t 'All'}}
7+
{{/link-to}}
8+
{{#link-to 'account.billing.invoices.list' 'due' class='item'}}
9+
{{t 'Due'}}
10+
{{/link-to}}
11+
{{#link-to 'account.billing.invoices.list' 'paid' class='item'}}
12+
{{t 'Paid'}}
13+
{{/link-to}}
14+
{{#link-to 'account.billing.invoices.list' 'upcoming' class='item'}}
15+
{{t 'Upcoming'}}
16+
{{/link-to}}
17+
{{/tabbed-navigation}}
18+
</div>
419
</div>
5-
<div class="ui hidden divider"></div>
6-
<div class="thirteen wide column">
7-
<h2 class="ui header column">{{t 'Upcoming Invoices'}}</h2>
20+
<div class="row">
21+
{{outlet}}
822
</div>
9-
<div class="ui hidden divider"></div>
10-
<div class="thirteen wide column">
11-
<h2 class="ui header column">{{t 'Paid Invoices'}}</h2>
12-
</div>
13-
<div class="ui hidden divider"></div>
14-
</div>
23+
</div>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<div class="sixteen wide column">
2+
{{tables/default columns=columns
3+
rows=model.eventInvoices
4+
currentPage=page
5+
pageSize=per_page
6+
searchQuery=search
7+
sortBy=sort_by
8+
sortDir=sort_dir
9+
metaData=model.eventInvoices.meta
10+
filterOptions=filterOptions
11+
widthConstraint="eq-container"
12+
resizeMode="fluid"
13+
fillMode="equal-column"
14+
}}
15+
</div>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="ui header weight-400">
2+
<img src="{{if record.logoUrl record.logoUrl '/images/placeholders/Other.jpg'}}" alt="Event Logo" class="ui image"> <br> {{record.name}}
3+
</div>

tests/acceptance/billing-info-test.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)