generated from bcgov/bcrs-template-ui
-
Notifications
You must be signed in to change notification settings - Fork 51
/
getters.ts
245 lines (203 loc) · 7.27 KB
/
getters.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
import { CorpTypeCd, EntityState, EntityStatus, FilingStatus, FilingTypes } from '@/enums'
import {
ApiFilingIF, ApiTaskIF, DissolutionConfirmationResourceIF, OfficeAddressIF, PartyIF,
StateIF, TodoListResourceIF, IsoDatePacific
} from '@/interfaces'
export default {
/** The list of filings from the API. */
getFilings (state: StateIF): ApiFilingIF[] {
return state.filings
},
/** The list of tasks from the API. */
getTasks (state: StateIF): ApiTaskIF[] {
return state.tasks
},
/**
* The current JS Date object, which was refreshed when the dashload loaded.
* NB: internally this is stored as UTC
* NB: use date mixins to display this
*/
getCurrentJsDate (state: StateIF): Date {
return state.currentJsDate
},
/**
* The current date (YYYY-MM-DD), which was refreshed when the dashload loaded,
* in Pacific timezone.
*/
getCurrentDate (state: StateIF): IsoDatePacific {
return state.currentDate
},
/** The current year. */
getCurrentYear (state: StateIF): number {
return (state.currentDate ? +state.currentDate.substring(0, 4) : 0)
},
/** Is True if there are any pending tasks or filings. */
hasBlockerExceptStaffApproval (state: StateIF): boolean {
return (state.hasBlockerTask || state.hasBlockerFiling || state.isCoaPending)
},
/** Is True if there are any pending tasks or filings. */
hasBlocker (_state: StateIF, getters): boolean {
let blocker = getters.hasBlockerExceptStaffApproval
// check for complaints warnings for SP and GP
if (getters.isFirm && getters.isNotInCompliance) {
blocker = getters.isNotInCompliance
}
return blocker
},
/** Is True if a COA filing is pending. */
isCoaPending (state: StateIF): boolean {
return state.isCoaPending
},
/** The COA effective date (valid if a COA is pending). */
getCoaEffectiveDate (state: StateIF): Date {
return state.coaEffectiveDate
},
/** The business identifier (aka Incorporation Number). */
getIdentifier (state: StateIF): string {
return state.identifier
},
/** The business number (aka Tax ID). */
getBusinessNumber (state: StateIF): string {
return state.businessNumber
},
/** The entity name. */
getEntityName (state: StateIF): string {
return state.entityName
},
/** Is True if entity is a Benefit Company. */
isBComp (state: StateIF): boolean {
return (state.entityType === CorpTypeCd.BENEFIT_COMPANY)
},
/** Is True if entity is a Cooperative. */
isCoop (state: StateIF): boolean {
return (state.entityType === CorpTypeCd.COOP)
},
/** Is True if entity is a BC Corporation. */
isCorp (state: StateIF): boolean {
return (state.entityType === CorpTypeCd.BC_CORPORATION)
},
/** Is True if entity is a Sole Proprietorship or General Partnership. */
isFirm (state: StateIF): boolean {
return (state.entityType === CorpTypeCd.SOLE_PROP || state.entityType === CorpTypeCd.PARTNERSHIP)
},
/** Is True if entity is a Sole Proprietorship. */
isSoleProp (state: StateIF): boolean {
return (state.entityType === CorpTypeCd.SOLE_PROP)
},
/** Is True if entity is a General Partnership. */
isPartnership (state: StateIF): boolean {
return (state.entityType === CorpTypeCd.PARTNERSHIP)
},
/** Is True if entity is a BC Company. */
isBcCompany (state: StateIF): boolean {
return (state.entityType === CorpTypeCd.BC_COMPANY)
},
/** Is True if entity is a BC ULC Company. */
isUlc (state: StateIF): boolean {
return (state.entityType === CorpTypeCd.BC_ULC_COMPANY)
},
/** Is True if Staff role is set. */
isRoleStaff (state: StateIF): boolean {
return state.keycloakRoles.includes('staff')
},
/** Is True if Edit role is set. */
isRoleEdit (state: StateIF): boolean {
return state.authRoles.includes('edit')
},
/** Is True if View role is set. */
isRoleView (state: StateIF): boolean {
return state.authRoles.includes('view')
},
/** Is True if business is pending dissolution. */
isPendingDissolution (state: StateIF): boolean {
return false // FUTURE: implement this
},
/** Is True if business is in good standing. */
isGoodStanding (state: StateIF): boolean {
return state.goodStanding
},
/** Is True if business is not in compliance. */
isNotInCompliance (state: StateIF): boolean {
const warnings = state.businessWarnings
return (warnings.length > 0 && warnings.some(item => item.warningType?.includes('COMPLIANCE')))
},
/** Is True if this is a Draft Application. */
isAppTask (state: StateIF): boolean {
return (state.entityStatus === EntityStatus.DRAFT_APP)
},
/** Is True if this is a Paid or Completed Application. */
isAppFiling (state: StateIF): boolean {
return (state.entityStatus === EntityStatus.FILED_APP)
},
/** Is True if business is active. */
isActive (state: StateIF): boolean {
return (state.entityState === EntityState.ACTIVE)
},
/** Is True if business is historical (ie, dissolved). */
isHistorical (state: StateIF): boolean {
return (state.entityState === EntityState.HISTORICAL)
},
/** Is True if business is in liquidation. */
isLiquidation (state: StateIF): boolean {
return (state.entityState === EntityState.LIQUIDATION)
},
getNrNumber (state: StateIF): string {
// workaround for old or new property name
return (state.nameRequest?.nrNum || state.nameRequest?.nrNumber)
},
isCurrentFilingEditable (state: StateIF): boolean {
return (state.currentFilingStatus === FilingStatus.NEW || state.currentFilingStatus === FilingStatus.DRAFT)
},
getReportState (state: StateIF): string {
switch (state.currentFilingStatus) {
case FilingStatus.NEW: return ''
case FilingStatus.DRAFT: return 'Draft'
}
return state.currentFilingStatus
},
/**
* This is used to show Legal Obligations only for a new business
* that has no tasks and hasn't filed anything yet (except their IA).
**/
isBusinessWithNoMaintenanceFilings (state: StateIF): boolean {
return (
// no todo items
state.tasks.length === 0 &&
// only the IA filing history item
state.filings.length === 1 &&
[FilingTypes.INCORPORATION_APPLICATION, FilingTypes.REGISTRATION].includes(state.filings[0].name)
)
},
/** The Entity Type. */
getEntityType (state: StateIF): CorpTypeCd {
return state.entityType
},
/** The Entity Status. */
getEntityStatus (state: StateIF): EntityStatus {
return state.entityStatus
},
/** The Entity Founding Date. */
getEntityFoundingDate (state: StateIF): Date {
return state.entityFoundingDate
},
/** The entity registered office address. */
getRegisteredOfficeAddress (state: StateIF): OfficeAddressIF {
return state.registeredAddress
},
/** The parties list from the API. */
getParties (state: StateIF): Array<PartyIF> {
return state.parties
},
/** The entity busness address. */
getBusinessAddress (state: StateIF): OfficeAddressIF {
return state.businessAddress
},
/** The entity resource text for confirmation modal. */
getDissolutionConfirmationResource (state: StateIF): DissolutionConfirmationResourceIF {
return state.configObject?.dissolutionConfirmation
},
/** The entity TodoList resources. */
getTodoListResource (state: StateIF): TodoListResourceIF {
return state.configObject?.todoList
}
}