Skip to content

Commit

Permalink
Feature/eui 140 fee account (#278)
Browse files Browse the repository at this point in the history
* Part changes only

* Invite user changes

* Change Preview to Demo for testing on the PR

* Fix the Failing test and email property

* rpe secret values (#234)

* Adding Routes to the Fee And Pay

* Fix the Fee account routing

* Fee and Pay changes

* Changes to the Fee and Account

* Account name changes

* Integrating summary details with api

* Transaction changes

* Fee account making it work with refresh

* Config changes for Fee And Pay Api

* Adding back Url to Fee and transaction page

* Changes to the format date

* Adding OrderId to do custom sorting now.

* pointing local to aat

* config changes

* Fix the url

* Fix the failing test

* Fix the failing test

* removing the hard coded account number

* Adding the Accounts guard back

* Fix the build error

* merge from Master

* Change of header as per change asked by BA

* Code review comment

* fix linter issues

* Using promise.all

* Adding unsubscribtion events to the component
  • Loading branch information
udaydenduluri33 authored and Vamshi-Muniganti committed Oct 11, 2019
1 parent e429524 commit d3ec393
Show file tree
Hide file tree
Showing 41 changed files with 325 additions and 341 deletions.
67 changes: 0 additions & 67 deletions api/accounts/data.mock.ts

This file was deleted.

112 changes: 41 additions & 71 deletions api/accounts/index.ts
Original file line number Diff line number Diff line change
@@ -1,81 +1,51 @@
import { AxiosPromise } from 'axios'
import * as express from 'express'
import * as log4js from 'log4js'
import { config } from '../lib/config'
import { EnhancedRequest } from '../lib/models'
import { PaymentAccountDto } from '../lib/models/transactions'
import { asyncReturnOrError } from '../lib/util'
import { getAccount, getPayments } from '../services/payment'
import { getAccountsForOrganisation } from '../services/rdProfessional'
import { mockReq, mockRes } from 'sinon-express-mock'
const logger = log4js.getLogger('auth')
logger.level = config.logging
export const router = express.Router({ mergeParams: true })

export async function accountsForOrganisation(req: EnhancedRequest, res: express.Response): Promise<PaymentAccountDto[]> {
return await asyncReturnOrError(
getAccountsForOrganisation(req.session.auth.orgId),
'3rd party service payment api return error - Cannot get accounts for organisation',
res,
logger
)
}

export async function handleAccountPbasRoute(req: EnhancedRequest, res: express.Response) {
const accounts: PaymentAccountDto[] = await this.accountsForOrganisation(req, res)

if (accounts) {
res.send(accounts)
}
}

export async function validatePBANumberForOrganisation(req: EnhancedRequest, res: express.Response): Promise<boolean> {
const accounts: PaymentAccountDto[] = await this.accountsForOrganisation(req, res)

if (accounts && !accounts.some(account => account.pbaNumber === req.params.id)) {
res.status(401).send('Unauthorised PBA number for organisation')
return false
}

return !!accounts.length || false
}

export async function handleAccountRoute(req: EnhancedRequest, res: express.Response) {
const isValidPBA = await this.validatePBANumberForOrganisation(req, res)

if (isValidPBA) {
const response = await asyncReturnOrError(
getAccount(req.params.id),
'3rd party service payment api return error - cannot get account',
res,
logger
)

if (response) {
res.send(response.data)
import { http } from '../lib/http'

async function handleAddressRoute(req, res) {
let errReport: any
if (!req.query.accountNames) {
errReport = {
apiError: 'Account is missing',
apiStatusCode: '400',
message: 'Fee And Pay route error',
}
res.status(500).send(errReport)
}
const accountNames = req.query.accountNames.split(',')
console.log('accountNames', accountNames)
const accounts = new Array()
const accountPromises = new Array<AxiosPromise<any>>()
accountNames.forEach((accountName: string) => accountPromises.push(getAccount(accountName)))

try {
await Promise.all(accountPromises).then(allAccounts => {
allAccounts.forEach(account => {
accounts.push(account.data)
})
})
} catch (error) {
console.error(error)
errReport = {
apiError: error && error.data && error.data.message ? error.data.message : error,
apiStatusCode: error && error.status ? error.status : '',
message: `Fee And Pay route error `,
}
res.status(500).send(errReport)
return
}
res.send(accounts)
}

export async function handleAccountPbaTransactionsRoute(req: EnhancedRequest, res: express.Response) {
const isValidPBA = await this.validatePBANumberForOrganisation(req, res)
function getAccount(accountName: string): AxiosPromise<any> {
const url = `${config.services.feeAndPayApi}/accounts/${accountName}`
const promise = http.get(url)
return promise
}

if (isValidPBA) {
const response = await asyncReturnOrError(
getPayments(req.params.id),
'3rd party service payment api return error - cannot get account payments',
res,
logger
)
export const router = express.Router({ mergeParams: true })

if (response) {
res.send(response.data)
}
}
}
// overview
router.get('/pbas', handleAccountPbasRoute)
// Single account
router.get('/:id', handleAccountRoute)
router.get('/:id/transactions', handleAccountPbaTransactionsRoute)
router.get('', handleAddressRoute)

export default router
75 changes: 37 additions & 38 deletions api/lib/config/environments/demo.config.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,42 @@
export default {

services: {
ccdDataApi: 'https://ccd-data-store-api-demo.service.core-compute-demo.internal',
ccdDefApi: 'https://ccd-definition-store-api-demo.service.core-compute-demo.internal',
idamWeb: 'https://idam-web-public.demo.platform.hmcts.net',
idamApi: 'https://idam-api.demo.platform.hmcts.net',
s2s: 'http://rpe-service-auth-provider-demo.service.core-compute-demo.internal',
draftStoreApi: 'https://draft-store-service-demo.service.core-compute-demo.internal',
dmStoreApi: 'https://dm-store-demo.service.core-compute-demo.internal',
emAnnoApi: 'https://em-anno-demo.service.core-compute-demo.internal',
emNpaApi: 'https://em-npa-demo.service.core-compute-demo.internal',
rdProfessionalApi: 'https://rd-professional-api-demo.service.core-compute-demo.internal',
ccdDataApi: 'http://ccd-data-store-api-demo.service.core-compute-demo.internal',
ccdDefApi: 'http://ccd-definition-store-api-demo.service.core-compute-demo.internal',
idamWeb: 'https://idam-web-public.aat.platform.hmcts.net',
idamApi: 'https://idam-api.aat.platform.hmcts.net',
s2s: 'http://rpe-service-auth-provider-aat.service.core-compute-aat.internal',
rdProfessionalApi: 'http://rd-professional-api-aat.service.core-compute-aat.internal',
feeAndPayApi: 'https://payment-api-demo.service.core-compute-demo.internal',
},
health: {
ccdDataApi: 'https://ccd-data-store-api-demo.service.core-compute-demo.internal/health',
ccdDefApi: 'https://ccd-definition-store-api-demo.service.core-compute-demo.internal/health',
idamWeb: 'https://idam-web-public.demo.platform.hmcts.net/health',
idamApi: 'https://idam-api.demo.platform.hmcts.net/health',
s2s: 'http://rpe-service-auth-provider-demo.service.core-compute-demo.internal/health',
draftStoreApi: 'https://draft-store-service-demo.service.core-compute-demo.internal/health',
dmStoreApi: 'https://dm-store-demo.service.core-compute-demo.internal/health',
emAnnoApi: 'https://em-anno-demo.service.core-compute-demo.internal/health',
emNpaApi: 'https://em-npa-demo.service.core-compute-demo.internal/health',
rdProfessionalApi: 'https://rd-professional-api-demo.service.core-compute-demo.internal/health',
ccdDataApi: 'http://ccd-data-store-api-demo.service.core-compute-demo.internal/health',
ccdDefApi: 'http://ccd-definition-store-api-demo.service.core-compute-demo.internal/health',
idamWeb: 'https://idam-web-public.aat.platform.hmcts.net/health',
idamApi: 'https://idam-api.aat.platform.hmcts.net/health',
s2s: 'http://rpe-service-auth-provider-aat.service.core-compute-aat.internal/health',
rdProfessionalApi: 'http://rd-professional-api-aat.service.core-compute-aat.internal/health',
feeAndPayApi: 'https://payment-api-demo.service.core-compute-demo.internal/health',

},
useProxy: false,
secureCookie: false,
sessionSecret: 'secretSauce',
logging: 'debug',
jurisdictions: [
{id: 'SSCS'},
{id: 'AUTOTEST1'},
{id: 'DIVORCE'},
{id: 'PROBATE'},
{id: 'PUBLICLAW'},
{id: 'bulkscan'},
{id: 'BULKSCAN'},
{id: 'IA'},
{id: 'EMPLOYMENT'},
{id: 'CMC'}
],
}
proxy: {
host: '172.16.0.7',
port: 8080,
},
protocol: 'http',
secureCookie: false,
sessionSecret: 'secretSauce',
logging: 'debug',
jurisdictions: [
{id: 'SSCS'},
{id: 'SSCS'},
{id: 'AUTOTEST1'},
{id: 'DIVORCE'},
{id: 'PROBATE'},
{id: 'PUBLICLAW'},
{id: 'bulkscan'},
{id: 'BULKSCAN'},
{id: 'IA'},
{id: 'EMPLOYMENT'},
{id: 'CMC'},
],
}
4 changes: 3 additions & 1 deletion api/lib/config/environments/local.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default {
idamApi: 'https://idam-api.aat.platform.hmcts.net',
s2s: 'http://rpe-service-auth-provider-aat.service.core-compute-aat.internal',
rdProfessionalApi: 'http://rd-professional-api-aat.service.core-compute-aat.internal',
feeAndPayApi: 'https://payment-api-aat.service.core-compute-aat.internal',
},
health: {
ccdDataApi: 'http://ccd-data-store-api-demo.service.core-compute-demo.internal/health',
Expand All @@ -14,6 +15,7 @@ export default {
idamApi: 'https://idam-api.aat.platform.hmcts.net/health',
s2s: 'http://rpe-service-auth-provider-aat.service.core-compute-aat.internal/health',
rdProfessionalApi: 'http://rd-professional-api-aat.service.core-compute-aat.internal/health',
feeAndPayApi: 'https://payment-api-aat.service.core-compute-aat.internal/health',
},
proxy: {
host: '172.16.0.7',
Expand All @@ -36,4 +38,4 @@ export default {
{id: 'EMPLOYMENT'},
{id: 'CMC'},
],
}
}
34 changes: 34 additions & 0 deletions api/payments/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as express from 'express'
import { config } from '../lib/config'
import { http } from '../lib/http'

async function handleAddressRoute(req, res) {
let errReport: any
if (!req.params.account) {
errReport = {
apiError: 'Account is missing',
apiStatusCode: '400',
message: 'Fee And Pay route error',
}
res.status(500).send(errReport)
}
try {
const response = await http.get(
`${config.services.feeAndPayApi}/pba-accounts/${req.params.account}/payments/`
)
res.send(response.data.payments)
} catch (error) {
errReport = {
apiError: error.data.message,
apiStatusCode: error.status,
message: 'Fee And Pay route error',
}
res.status(500).send(errReport)
}
}

export const router = express.Router({ mergeParams: true })

router.get('', handleAddressRoute)

export default router
2 changes: 2 additions & 0 deletions api/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import healthCheck from './healthCheck'
import inviteUser from './inviteUser'
import getJurisdictions from './jurisdictions'
import organisationRouter from './organisation'
import payments from './payments'
import userDetailsRouter from './user'
import getUserList from './userList'

Expand All @@ -20,5 +21,6 @@ router.use('/inviteUser', inviteUser)
router.use('/userList', getUserList)
router.use('/userDetails', getUserList)
router.use('/jurisdictions', getJurisdictions)
router.use('/payments/:account', payments)

export default router
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
</ng-container>
</th>
<td data-selector="table-cell" class="govuk-table__cell" *ngIf="!(isFirst && firstCellIsHeader)">
<ng-container *ngIf="!col.type || col.type === 'text' || !r.routerLink">{{r[col.key]}}</ng-container>
<ng-container *ngIf="col.type === 'date'">{{formatDate(r[col.key])}}</ng-container>
<ng-container *ngIf="!col.type || col.type === 'text'">{{r[col.key]}}</ng-container>
<ng-container *ngIf="col.type === 'link' && r.routerLink">
<a class="govuk-link" [routerLink]="r.routerLink">{{r[col.key]}}</a>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Component, Input} from '@angular/core';
import {formatDate} from '@angular/common';

@Component({
selector: 'app-govuk-table',
Expand All @@ -21,6 +22,10 @@ export class GovukTableComponent {

constructor() { }

formatDate(date: Date): string {
return formatDate(date, 'dd/MM/yyyy', 'en-UK');
}

}

export class GovukTableColumnConfig {
Expand Down
Loading

0 comments on commit d3ec393

Please sign in to comment.