File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
frontend/app/subscriptions/list Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -87,18 +87,22 @@ export default class SubscriptionsListController extends Controller {
87
87
const lines = this . projects
88
88
. toArray ( )
89
89
. map ( ( project ) => {
90
- const costCenterFullName = project . get ( "costCenter.name" ) . trim ( ) ;
91
- // Cost center name always starts with 5 digits
92
- const costCenterSplitName = costCenterFullName . split (
93
- new RegExp ( "^(\\d{5})" )
94
- ) ;
90
+ // Example cost center name: 12345 EXPENSE
91
+ const costCenterFullName = project . get ( "costCenter.name" ) ;
92
+ let costCenterSplitName = [ ] ;
93
+ if ( costCenterFullName ) {
94
+ costCenterSplitName = costCenterFullName
95
+ . trim ( )
96
+ . match ( / ^ ( \S * \d { 5 } \S * ) ( .+ ) $ / ) ;
97
+ }
95
98
96
99
return [
97
100
project . get ( "customer.name" ) ,
98
101
project . get ( "name" ) ,
99
102
project . get ( "billingType.name" ) ,
100
- costCenterSplitName [ 1 ] ,
101
- costCenterSplitName [ 2 ] . trim ( ) ,
103
+ ...( costCenterFullName
104
+ ? [ costCenterSplitName [ 1 ] , costCenterSplitName [ 2 ] . trim ( ) ]
105
+ : [ "" , "" ] ) ,
102
106
formatDurationShort ( project . get ( "purchasedTime" ) ) ,
103
107
formatDurationShort ( project . get ( "spentTime" ) ) ,
104
108
formatDurationShort ( project . get ( "totalTime" ) ) ,
You can’t perform that action at this time.
0 commit comments