Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OPALSUP-194] Fix customer link in invoices #314

Open
wants to merge 2 commits into
base: 2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/app/components/mnoe-config/mnoe-admin-config.svc.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This service is a wrapper around the config we fetch from the backend
@App.factory 'MnoeAdminConfig', ($log, ADMIN_ROLES, ADMIN_PANEL_CONFIG, DASHBOARD_CONFIG, INTERCOM_ID) ->
@App.factory 'MnoeAdminConfig', ($log, ADMIN_ROLES, STATUS, ADMIN_PANEL_CONFIG, DASHBOARD_CONFIG, INTERCOM_ID) ->
_self = @

# Only expose subtenant_admin when subtenants are enabled
Expand All @@ -9,6 +9,10 @@
else
_.reject(ADMIN_ROLES, (role) -> role.value == 'sub_tenant_admin')

#Get list of statuses for invoices
@invoicesStatus = () ->
STATUS

# If the feature is enabled a "staff" user can be assigned to customers and can only see those ones
# If the feature is disabled, the screen to assign customers is not showing and a staff can see all customers (only difference with "admin" in this case is some screens are limited)
@isAccountManagerEnabled = () ->
Expand Down
13 changes: 12 additions & 1 deletion src/app/components/mnoe-invoices-list/mnoe-invoices-list.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
# Initialize
# -----------------------------------------------------------------
ctrl.isPaymentEnabled = MnoeAdminConfig.isPaymentEnabled()

ctrl.invoices =
list: []
nbItems: 10
search: {}
offset: 0
page: 1
status: MnoeAdminConfig.invoicesStatus()
pageChangedCb: (nbItems, page) ->
ctrl.invoices.nbItems = nbItems
ctrl.invoices.page = page
Expand Down Expand Up @@ -42,7 +44,16 @@
search = {}
if searchingState.predicateObject
for attr, value of searchingState.predicateObject
search[ 'where[' + attr + '.like]' ] = value + '%'
switch attr
when 'paid_at'
switch value
when 'Paid' then search[ 'where[' + attr + '.not]' ] = 'null'
when 'Pending' then search[ 'where[' + attr + '.none]' ] = 'true'
else
if _.isObject(value)
search[ 'where[' + attr + '.' + _.keys(value)[0] + '.like]' ] = '%' + _.values(value)[0] + '%'
else
search[ 'where[' + attr + '.like]' ] = '%' + value + '%'
ctrl.invoices.search = search
return search

Expand Down
13 changes: 10 additions & 3 deletions src/app/components/mnoe-invoices-list/mnoe-invoices-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,24 @@
<th>
<input ng-show="!$ctrl.invoices.loading" st-search="slug" placeholder="{{'mnoe_admin_panel.dashboard.invoices.search_reference' | translate}}" class="form-control input-sm search-bar" type="text"/>
</th>
<th></th>
<th>
<input ng-show="!$ctrl.invoices.loading" st-search="organization.name" placeholder="{{'mnoe_admin_panel.dashboard.invoices.search_customer' | translate}}" class="form-control input-sm search-bar" type="text"/>
</th>
<th></th>
<th ng-if="$ctrl.isPaymentEnabled"></th>
<th></th>
<th></th>
<th>
<select st-search="paid_at" class="form-control input-sm">
<option value="" selected translate>mnoe_admin_panel.dashboard.staffs.widget.list.table.admin_role.all</option>
<option value="{{status.value}}" ng-repeat="status in $ctrl.invoices.status">{{ status.label | translate }}</option>
</select>
</th>
</tr>
</thead>
<tbody ng-show="!$ctrl.invoices.loading">
<tr ng-repeat="invoice in $ctrl.invoices.list" ng-click="$ctrl.goToInvoice(invoice.id)">
<td>{{invoice.slug}}</td>
<td><a href="">{{invoice.organization.name}}</a></td>
<td><a ui-sref="dashboard.customers.organization({orgId: invoice.organization.id})">{{invoice.organization.name}}</a></td>
<td>{{invoice.started_at | amCalendar}} - {{invoice.ended_at | amCalendar}}</td>
<td ng-if="$ctrl.isPaymentEnabled">{{$ctrl.expectedPaymentDate(invoice.ended_at) | amCalendar }}</td>
<td>{{invoice.price.currency.iso_code}} {{invoice.price.fractional/100}}</td>
Expand Down
4 changes: 4 additions & 0 deletions src/app/index.constants.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
{value: 'sub_tenant_admin', label: 'mnoe_admin_panel.constants.admin_roles.sub_tenant_admin'},
{value: 'staff', label: 'mnoe_admin_panel.constants.admin_roles.staff'}
]) # Must be lower case
.constant('STATUS', [
{value: 'Paid', label: 'mnoe_admin_panel.constants.status.paid'},
{value: 'Pending', label: 'mnoe_admin_panel.constants.status.pending'}
])
.constant('STAFF_PAGE_AUTH', ['admin', 'sub_tenant_admin'])
.constant('OBS_KEYS', {
organizationChanged: 'organizationListChanged',
Expand Down
3 changes: 3 additions & 0 deletions src/locales/en-AU.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"mnoe_admin_panel.constants.admin_roles.admin": "owner",
"mnoe_admin_panel.constants.admin_roles.staff": "user",
"mnoe_admin_panel.constants.admin_roles.sub_tenant_admin": "division admin",
"mnoe_admin_panel.constants.status.paid": "Paid",
"mnoe_admin_panel.constants.status.pending": "Awaiting for payment",
"mnoe_admin_panel.constants.countries.australia": "Australia",
"mnoe_admin_panel.constants.countries.usa": "USA",
"mnoe_admin_panel.constants.transaction_types.credit": "Credit",
Expand Down Expand Up @@ -719,6 +721,7 @@
"mnoe_admin_panel.dashboard.invoice.send_invoice.toastr_error": "An error occured while creating request to send invoice",
"mnoe_admin_panel.dashboard.invoices.title": "Invoices",
"mnoe_admin_panel.dashboard.invoices.search_reference": "Search reference",
"mnoe_admin_panel.dashboard.invoices.search_customer": "Search customer",
"mnoe_admin_panel.dashboard.invoices.widget.list.title": "All invoices",
"mnoe_admin_panel.dashboard.invoices.widget.list.table.reference": "Reference",
"mnoe_admin_panel.dashboard.invoices.widget.list.table.customer": "Customer",
Expand Down