diff --git a/src/apps/__test__/middleware.test.js b/src/apps/__test__/middleware.test.js
index 3cad8ed0f32..7210f5801f3 100644
--- a/src/apps/__test__/middleware.test.js
+++ b/src/apps/__test__/middleware.test.js
@@ -267,47 +267,6 @@ describe('Apps middleware', () => {
})
})
- describe('setDefaultQuery()', () => {
- beforeEach(() => {
- this.resMock = {
- redirect: sinon.spy(),
- }
- })
-
- it('should redirect to default query if initial query is empty', () => {
- const reqMock = {
- query: {},
- originalUrl: '/sub-app',
- }
- this.middleware.setDefaultQuery({
- filter: 'apple',
- sortby: 'sweetness',
- })(reqMock, this.resMock, this.nextSpy)
-
- expect(this.nextSpy).to.not.have.been.called
- expect(this.resMock.redirect).to.be.calledWith(
- '?filter=apple&sortby=sweetness'
- )
- })
-
- it('should not redirect if query contains properties', () => {
- const reqMock = {
- query: {
- filter: 'pear',
- },
- originalUrl: '/sub-app',
- }
-
- this.middleware.setDefaultQuery({
- filter: 'apple',
- sortby: 'sweetness',
- })(reqMock, this.resMock, this.nextSpy)
-
- expect(this.nextSpy).to.have.been.called
- expect(this.resMock.redirect).to.not.have.been.called
- })
- })
-
describe('handleRoutePermissions()', () => {
const mockUrl = '/mock-url'
diff --git a/src/apps/middleware.js b/src/apps/middleware.js
index 31d4c723dff..4c7f53796db 100644
--- a/src/apps/middleware.js
+++ b/src/apps/middleware.js
@@ -1,4 +1,4 @@
-const { get, isEmpty, assign, intersection, isUndefined } = require('lodash')
+const { get, assign, intersection, isUndefined } = require('lodash')
const queryString = require('qs')
const { parse } = require('url')
const path = require('path')
@@ -22,11 +22,6 @@ function setHomeBreadcrumb(text) {
}
}
-function removeBreadcrumb(req, res, next) {
- res.removeBreadcrumb()
- next()
-}
-
function isPermittedRoute(pathname, routes, userPermissions) {
const routePermissions = get(
routes.find((route) => {
@@ -77,15 +72,6 @@ function setLocalNav(items = [], appendBaseUrl = true) {
}
}
-function setDefaultQuery(query = {}) {
- return function handleDefaultRedirect(req, res, next) {
- if (isEmpty(req.query)) {
- return res.redirect(`?${queryString.stringify(query)}`)
- }
- next()
- }
-}
-
function redirectToFirstNavItem(req, res) {
return res.redirect(res.locals.localNavItems[0].url)
}
@@ -99,10 +85,8 @@ function redirectWithQueryString(req, res, relativeUrl) {
module.exports = {
setHomeBreadcrumb,
- removeBreadcrumb,
setLocalNav,
redirectToFirstNavItem,
- setDefaultQuery,
handleRoutePermissions,
isPermittedRoute,
redirectWithQueryString,
diff --git a/src/apps/omis/__test__/transformers.test.js b/src/apps/omis/__test__/transformers.test.js
index 7854ec21eb5..aa2e7ae8ddc 100644
--- a/src/apps/omis/__test__/transformers.test.js
+++ b/src/apps/omis/__test__/transformers.test.js
@@ -150,33 +150,4 @@ describe('OMIS list transformers', () => {
})
})
})
-
- describe('#transformOrderToTableItem', () => {
- const simpleOrder = require('../../../../test/unit/data/omis/simple-order.json')
-
- context('when given an unqualified result', () => {
- it('should return undefined', () => {
- expect(this.transformers.transformOrderToTableItem()).to.be.undefined
- expect(this.transformers.transformOrderToTableItem({ a: 'b' })).to.be
- .undefined
- expect(this.transformers.transformOrderToTableItem({ id: 'abcd' })).to
- .be.undefined
- expect(
- this.transformers.transformOrderToTableItem({ reference: 'Z123/SD' })
- ).to.be.undefined
- })
- })
-
- context('when given a qualified result', () => {
- it('should return a transformed object', () => {
- const actual = this.transformers.transformOrderToTableItem(simpleOrder)
-
- expect(actual).to.have.property('id').a('string')
- expect(actual).to.have.property('reference').a('string')
- expect(actual).to.have.property('subtotal_cost').a('number')
- expect(actual).to.have.property('total_cost').a('number')
- expect(actual).to.have.property('company').a('string')
- })
- })
- })
})
diff --git a/src/apps/omis/apps/reconciliation/controllers.js b/src/apps/omis/apps/reconciliation/controllers.js
deleted file mode 100644
index 4610f8ab844..00000000000
--- a/src/apps/omis/apps/reconciliation/controllers.js
+++ /dev/null
@@ -1,7 +0,0 @@
-function renderList(req, res) {
- res.render('omis/apps/reconciliation/views/list-reconciliation')
-}
-
-module.exports = {
- renderList,
-}
diff --git a/src/apps/omis/apps/reconciliation/index.js b/src/apps/omis/apps/reconciliation/index.js
deleted file mode 100644
index e7addc6ae01..00000000000
--- a/src/apps/omis/apps/reconciliation/index.js
+++ /dev/null
@@ -1,7 +0,0 @@
-const router = require('./router')
-
-module.exports = {
- displayName: 'Orders (OMIS)',
- mountpath: '/reconciliation',
- router,
-}
diff --git a/src/apps/omis/apps/reconciliation/router.js b/src/apps/omis/apps/reconciliation/router.js
deleted file mode 100644
index 037de1384aa..00000000000
--- a/src/apps/omis/apps/reconciliation/router.js
+++ /dev/null
@@ -1,28 +0,0 @@
-const router = require('express').Router()
-
-const { ENTITIES } = require('../../../search/constants')
-
-const {
- getCollection,
-} = require('../../../../modules/search/middleware/collection')
-
-const { setDefaultQuery } = require('../../../middleware')
-const { setOrder } = require('../../middleware')
-const { renderList } = require('./controllers')
-const { transformOrderToTableItem } = require('../../transformers')
-
-const DEFAULT_QUERY_RECONCILIATION = {
- sortby: 'payment_due_date:asc',
- status: 'quote_accepted',
-}
-
-router.param('orderId', setOrder)
-
-router.get(
- '/',
- setDefaultQuery(DEFAULT_QUERY_RECONCILIATION),
- getCollection('order', ENTITIES, transformOrderToTableItem),
- renderList
-)
-
-module.exports = router
diff --git a/src/apps/omis/apps/reconciliation/views/list-reconciliation.njk b/src/apps/omis/apps/reconciliation/views/list-reconciliation.njk
deleted file mode 100644
index 1cab82f5f09..00000000000
--- a/src/apps/omis/apps/reconciliation/views/list-reconciliation.njk
+++ /dev/null
@@ -1,11 +0,0 @@
-{% extends "_layouts/template.njk" %}
-
-{% block content %}
-
- {% component 'react-slot', {
- id: 'orders-reconciliation-collection',
- props: props
- }
- %}
-
-{% endblock %}
diff --git a/src/apps/omis/fields.js b/src/apps/omis/fields.js
deleted file mode 100644
index eaebdd875ef..00000000000
--- a/src/apps/omis/fields.js
+++ /dev/null
@@ -1,54 +0,0 @@
-module.exports = {
- company: {
- label: 'fields.company.label',
- validate: 'required',
- invalidates: ['contact', 'use_sector_from_company', 'sector'],
- },
- contact: {
- fieldType: 'MultipleChoiceField',
- label: 'fields.contact.label',
- validate: 'required',
- initialOption: '-- Select contact --',
- options: [],
- },
- primary_market: {
- fieldType: 'MultipleChoiceField',
- label: 'fields.primary_market.label',
- validate: 'required',
- initialOption: '-- Select country --',
- options: [],
- },
- use_sector_from_company: {
- fieldType: 'MultipleChoiceField',
- type: 'radio',
- modifier: ['inline'],
- validate: 'required',
- label: 'fields.use_sector_from_company.label',
- options: [
- {
- value: 'true',
- label: 'Yes',
- },
- {
- value: 'false',
- label: 'No',
- },
- ],
- },
- sector: {
- fieldType: 'MultipleChoiceField',
- label: 'fields.sector.label',
- modifier: ['subfield'],
- validate: 'required',
- initialOption: '-- Select sector --',
- options: [],
- condition: {
- name: 'use_sector_from_company',
- value: 'false',
- },
- dependent: {
- field: 'use_sector_from_company',
- value: 'false',
- },
- },
-}
diff --git a/src/apps/omis/router.js b/src/apps/omis/router.js
index 03b1a261bde..673932eb0a5 100644
--- a/src/apps/omis/router.js
+++ b/src/apps/omis/router.js
@@ -2,26 +2,15 @@ const router = require('express').Router()
const { APP_PERMISSIONS } = require('./constants')
-const {
- setHomeBreadcrumb,
- removeBreadcrumb,
- handleRoutePermissions,
-} = require('../middleware')
+const { handleRoutePermissions } = require('../middleware')
const { setOrder } = require('./middleware')
const viewApp = require('./apps/view')
const listApp = require('./apps/list')
-const reconciliationApp = require('./apps/reconciliation')
router.use(handleRoutePermissions(APP_PERMISSIONS))
router.param('orderId', setOrder)
router.use(listApp.mountpath, listApp.router)
-router.use(
- reconciliationApp.mountpath,
- removeBreadcrumb,
- setHomeBreadcrumb(reconciliationApp.displayName),
- reconciliationApp.router
-)
router.use(viewApp.mountpath, viewApp.router)
module.exports = router
diff --git a/src/apps/omis/transformers.js b/src/apps/omis/transformers.js
index 7ff6dd8f0f7..a0dc8cb46c2 100644
--- a/src/apps/omis/transformers.js
+++ b/src/apps/omis/transformers.js
@@ -77,29 +77,6 @@ function transformOrderToListItem({
return item
}
-function transformOrderToTableItem({
- id,
- reference,
- payment_due_date,
- company,
- subtotal_cost,
- total_cost,
-} = {}) {
- if (!id || !reference) {
- return
- }
-
- return {
- id,
- reference,
- payment_due_date,
- company: get(company, 'name'),
- subtotal_cost: parseInt(subtotal_cost) / 100,
- total_cost: parseInt(total_cost) / 100,
- }
-}
-
module.exports = {
transformOrderToListItem,
- transformOrderToTableItem,
}
diff --git a/src/apps/routers.js b/src/apps/routers.js
index dad5a8458ec..a4dc7937608 100644
--- a/src/apps/routers.js
+++ b/src/apps/routers.js
@@ -127,6 +127,7 @@ const reactRoutes = [
'/companies/:companyId/exports/history',
'/companies/:companyId/exports/history/:countryId',
'/omis/:orderId/quote',
+ '/omis/reconciliation',
]
reactRoutes.forEach((path) => {
diff --git a/src/client/index.jsx b/src/client/index.jsx
index 04d491b7af2..ee52afe1d61 100644
--- a/src/client/index.jsx
+++ b/src/client/index.jsx
@@ -31,7 +31,6 @@ import ContactLocalHeader from './components/ContactLocalHeader'
import ContactDetails from './modules/Contacts/ContactDetails/ContactDetails'
import ContactAuditHistory from './modules/Contacts/ContactAuditHistory/ContactAuditHistory'
import InteractionDetails from './modules/Interactions/InteractionDetails'
-import OrdersReconciliationCollection from './modules/Omis/CollectionList/OrdersReconciliationCollection'
import PropositionDetails from './modules/Investments/Projects/Propositions/PropositionDetails'
import CompanyHierarchy from './modules/Companies/CompanyHierarchy'
@@ -221,9 +220,6 @@ function App() {
{(props) => }
-
- {(props) => }
-
{(props) => }
diff --git a/src/client/modules/Omis/CollectionList/OrdersReconciliationCollection.jsx b/src/client/modules/Omis/CollectionList/OrdersReconciliationCollection.jsx
index cf7d2a59f90..c9b1b30c47e 100644
--- a/src/client/modules/Omis/CollectionList/OrdersReconciliationCollection.jsx
+++ b/src/client/modules/Omis/CollectionList/OrdersReconciliationCollection.jsx
@@ -12,6 +12,7 @@ import { ORDERS__LOADED, ORDERS__METADATA_LOADED } from '../../../actions'
import {
CollectionFilters,
+ DefaultLayout,
FilteredCollectionList,
Filters,
} from '../../../components'
@@ -83,60 +84,62 @@ const OrdersReconciliationCollection = ({
)
return (
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
)
}
export default connect(reconciliationOrdersState2props)(
diff --git a/src/client/modules/Omis/CollectionList/tasks.js b/src/client/modules/Omis/CollectionList/tasks.js
index 00a289cae03..d4b88df2318 100644
--- a/src/client/modules/Omis/CollectionList/tasks.js
+++ b/src/client/modules/Omis/CollectionList/tasks.js
@@ -7,6 +7,7 @@ import {
import { getPageOffset } from '../../../utils/pagination'
import { metadata } from '../../../../lib/urls'
import { apiProxyAxios } from '../../../components/Task/utils'
+import { STATUS } from '../constants'
const handleError = (e) => Promise.reject(Error(e.response.data.detail))
@@ -66,7 +67,14 @@ export const getOrdersReconciliation = ({
.post('/v3/search/order', {
limit,
offset: getPageOffset({ limit, page }),
- status,
+ status: status
+ ? status
+ : [
+ STATUS.QUOTE_ACCEPTED,
+ STATUS.PAID,
+ STATUS.CANCELLED,
+ STATUS.COMPLETE,
+ ],
sortby,
uk_region,
reference,
diff --git a/src/client/routes.js b/src/client/routes.js
index 14a604cd70c..474391d8d81 100644
--- a/src/client/routes.js
+++ b/src/client/routes.js
@@ -96,6 +96,7 @@ import ExportsIndex from './modules/Companies/CompanyExports/ExportsIndex'
import ExportsHistory from './modules/Companies/CompanyExports/ExportHistory'
import InvestmentProjectAdmin from './modules/Investments/Projects/InvestmentProjectAdmin'
import OrderQuote from './modules/Omis/OrderQuote'
+import OrdersReconciliationCollection from './modules/Omis/CollectionList/OrdersReconciliationCollection'
const routes = {
companies: [
@@ -414,6 +415,11 @@ const routes = {
module: 'datahub:orders',
component: OrderQuote,
},
+ {
+ path: '/omis/reconciliation',
+ module: 'datahub:orders',
+ component: OrdersReconciliationCollection,
+ },
],
reminders: [
{
diff --git a/src/modules/search/middleware/__test__/collection.test.js b/src/modules/search/middleware/__test__/collection.test.js
deleted file mode 100644
index f64c603d79c..00000000000
--- a/src/modules/search/middleware/__test__/collection.test.js
+++ /dev/null
@@ -1,59 +0,0 @@
-const config = require('../../../../config')
-
-describe('Collection middleware', () => {
- beforeEach(() => {
- this.middleware = require('../collection')
- this.reqMock = {
- session: {
- token: '1234',
- },
- }
- this.resMock = {
- locals: {},
- }
- this.nextSpy = sinon.spy()
- this.mockEntityResults = {
- count: 3,
- results: [
- { id: '111', name: 'A' },
- { id: '222', name: 'B' },
- { id: '333', name: 'C' },
- ],
- }
- })
-
- describe('#getCollection', () => {
- beforeEach(async () => {
- nock(config.apiRoot)
- .post(`/v3/search/entity`)
- .reply(200, this.mockEntityResults)
-
- this.reqMock.query = {
- sortby: 'name:asc',
- }
- await this.middleware.getCollection('entity')(
- this.reqMock,
- this.resMock,
- this.nextSpy
- )
-
- this.actual = this.resMock.locals.results
- })
-
- it('should set the count', () => {
- expect(this.actual).to.have.property('count')
- })
-
- it('should set the items', () => {
- expect(this.actual).to.have.property('items').to.have.length(3)
- })
-
- it('should set the pagination', () => {
- expect(this.actual).to.have.property('pagination')
- })
-
- it('should call next once', () => {
- expect(this.nextSpy).to.have.been.calledOnce
- })
- })
-})
diff --git a/src/modules/search/middleware/collection.js b/src/modules/search/middleware/collection.js
index 28792b8ee4f..ac9fa1a0faf 100644
--- a/src/modules/search/middleware/collection.js
+++ b/src/modules/search/middleware/collection.js
@@ -1,29 +1,4 @@
-const { search, exportSearch } = require('../services')
-const { transformApiResponseToSearchCollection } = require('../transformers')
-
-function getCollection(searchEntity, entityDetails, ...itemTransformers) {
- return async function (req, res, next) {
- try {
- res.locals.results = await search({
- searchEntity,
- requestBody: req.body,
- req,
- page: req.query.page,
- isAggregation: false,
- }).then(
- transformApiResponseToSearchCollection(
- { query: req.query },
- entityDetails,
- ...itemTransformers
- )
- )
-
- next()
- } catch (error) {
- next(error)
- }
- }
-}
+const { exportSearch } = require('../services')
function exportCollection(searchEntity) {
return async function (req, res, next) {
@@ -45,5 +20,4 @@ function exportCollection(searchEntity) {
module.exports = {
exportCollection,
- getCollection,
}