File tree 3 files changed +36
-3
lines changed
nomad-front-end/src/components
nomad-rest-api/controllers/admin
3 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,18 @@ const AccountsTable = props => {
16
16
}
17
17
]
18
18
19
+ //add the grantCode column if data are for user calculation
20
+ if ( props . header === 'User Name' ) {
21
+ columns . push ( {
22
+ title : 'Grant Code' ,
23
+ width : 35 ,
24
+ dataIndex : 'grantCode' ,
25
+ key : 'grantCode' ,
26
+ fixed : 'left' ,
27
+ align : 'center'
28
+ } )
29
+ }
30
+
19
31
//Getting dynamic table headers from the first data object
20
32
props . data [ 0 ] . costsPerInstrument . forEach ( ( cost , index ) => {
21
33
columns . push ( {
@@ -61,6 +73,7 @@ const AccountsTable = props => {
61
73
const data = props . data . map ( ( entry , key ) => {
62
74
const newEntry = {
63
75
name : entry . name ,
76
+ grantCode : entry . grantCode || undefined ,
64
77
totalCost : entry . totalCost ,
65
78
key
66
79
}
Original file line number Diff line number Diff line change @@ -17,12 +17,15 @@ const AccountingControls = props => {
17
17
columns = standardColumns . grants
18
18
} else {
19
19
columns = [ head ]
20
+ if ( type === 'Users' ) {
21
+ columns = [ ...columns , 'Grant Code' ]
22
+ }
20
23
let presentColumns = data [ 0 ] . costsPerInstrument
21
24
presentColumns . forEach ( ( { instrument } ) => {
22
25
const newColumnsToAdd = [
23
26
instrument + ' Exp Time Manual' ,
24
27
instrument + ' Exp Time Auto' ,
25
- instrument + ' Exp Time Cost [£]'
28
+ instrument + ' Cost [£]'
26
29
]
27
30
columns = [ ...columns , ...newColumnsToAdd ]
28
31
} )
@@ -54,6 +57,11 @@ const AccountingControls = props => {
54
57
} else {
55
58
data . forEach ( row => {
56
59
let FlatRow = [ row . name ]
60
+
61
+ if ( type === 'Users' ) {
62
+ FlatRow = [ ...FlatRow , row . grantCode ]
63
+ }
64
+
57
65
row . costsPerInstrument . forEach ( instrumentData => {
58
66
const { cost, expTimeAuto, expTimeClaims } = instrumentData
59
67
FlatRow = [ ...FlatRow , expTimeClaims , expTimeAuto , cost ]
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import Instrument from '../../models/instrument.js'
9
9
import Grant from '../../models/grant.js'
10
10
import {
11
11
checkDuplicate ,
12
+ getGrantInfo ,
12
13
getSearchParams ,
13
14
getSearchParamsClaims
14
15
} from '../../utils/accountsUtils.js'
@@ -82,14 +83,25 @@ export async function getCosts(req, res) {
82
83
83
84
await Promise . all (
84
85
usrArray . map ( async usrId => {
85
- const user = await User . findById ( usrId )
86
+ const [ user , grantInfo ] = await Promise . all ( [ User . findById ( usrId ) , getGrantInfo ( usrId ) ] )
87
+
88
+ let grant
89
+ if ( grantInfo ) {
90
+ grant = await Grant . findById ( grantInfo . grantId )
91
+ }
92
+
86
93
const usrInactive = ! user . isActive || user . group . toString ( ) !== groupId
87
94
const newEntry = {
88
- name : `${ user . username } - ${ user . fullName } ${ usrInactive ? '(Inactive)' : '' } ` ,
95
+ name : `${ user . username } - ${ user . fullName } ` ,
96
+ grantCode : grant && grant . grantCode ,
89
97
costsPerInstrument : [ ] ,
90
98
totalCost : 0
91
99
}
92
100
101
+ if ( groupId !== 'all' ) {
102
+ newEntry . name += `${ usrInactive ? '(Inactive)' : '' } `
103
+ }
104
+
93
105
instrumentList . forEach ( i => {
94
106
const filteredExpArray = expArray . filter (
95
107
exp => exp . instrument . name === i . name && exp . user . id . toString ( ) === usrId
You can’t perform that action at this time.
0 commit comments