taxtank-core 0.2.3 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/bundles/taxtank-core.umd.js +969 -479
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/bank-account.collection.js +3 -3
  4. package/esm2015/lib/collections/bank-transaction.collection.js +3 -3
  5. package/esm2015/lib/collections/client-movement.collection.js +3 -3
  6. package/esm2015/lib/collections/client-portfolio-report.collection.js +3 -3
  7. package/esm2015/lib/collections/client.collection.js +3 -3
  8. package/esm2015/lib/collections/collection-dictionary.js +1 -1
  9. package/esm2015/lib/collections/collection.js +75 -0
  10. package/esm2015/lib/collections/depreciation-forecast.collection.js +5 -5
  11. package/esm2015/lib/collections/depreciation.collection.js +3 -3
  12. package/esm2015/lib/collections/employee.collection.js +3 -3
  13. package/esm2015/lib/collections/income-source.collection.js +3 -3
  14. package/esm2015/lib/collections/loan.collection.js +3 -3
  15. package/esm2015/lib/collections/message-document.collection.js +3 -3
  16. package/esm2015/lib/collections/message.collection.js +3 -3
  17. package/esm2015/lib/collections/property.collection.js +10 -3
  18. package/esm2015/lib/collections/service-price.collection.js +3 -3
  19. package/esm2015/lib/collections/service-subscription.collection.js +3 -3
  20. package/esm2015/lib/collections/tax-return-category-item.collection.js +3 -3
  21. package/esm2015/lib/collections/tax-review.collection.js +3 -3
  22. package/esm2015/lib/collections/transaction-allocation.collection.js +3 -3
  23. package/esm2015/lib/collections/transaction.collection.js +3 -3
  24. package/esm2015/lib/collections/user-event-setting.collection.js +3 -3
  25. package/esm2015/lib/db/Enums/chart-accounts-metadata-list.enum.js +2 -1
  26. package/esm2015/lib/interceptors/corelogic-interceptor.js +44 -0
  27. package/esm2015/lib/interceptors/financial-year-interceptor.js +30 -0
  28. package/esm2015/lib/interceptors/interceptors.module.js +74 -0
  29. package/esm2015/lib/interceptors/jwt-interceptor.js +137 -0
  30. package/esm2015/lib/interceptors/preloader.interceptor.js +32 -0
  31. package/esm2015/lib/interceptors/user-switcher-interceptor.js +42 -0
  32. package/esm2015/lib/models/color/alphabet-colors.enum.js +30 -0
  33. package/esm2015/lib/models/data-table/data-table.js +6 -4
  34. package/esm2015/lib/models/logbook/vehicle-claim.js +7 -1
  35. package/esm2015/lib/models/transaction/transaction.js +11 -2
  36. package/esm2015/lib/services/bank/bank-account.service.js +7 -1
  37. package/esm2015/lib/services/pdf/pdf.service.js +39 -6
  38. package/esm2015/lib/services/property/equity-position-chart.service.js +45 -0
  39. package/esm2015/lib/services/xlsx/xlsx.service.js +1 -1
  40. package/esm2015/lib/tt-core.module.js +8 -4
  41. package/esm2015/public-api.js +8 -2
  42. package/fesm2015/taxtank-core.js +893 -437
  43. package/fesm2015/taxtank-core.js.map +1 -1
  44. package/lib/collections/bank-account.collection.d.ts +2 -2
  45. package/lib/collections/bank-transaction.collection.d.ts +2 -2
  46. package/lib/collections/client-movement.collection.d.ts +2 -2
  47. package/lib/collections/client-portfolio-report.collection.d.ts +2 -2
  48. package/lib/collections/client.collection.d.ts +2 -2
  49. package/lib/collections/collection-dictionary.d.ts +2 -2
  50. package/lib/collections/{abstract.collection.d.ts → collection.d.ts} +3 -9
  51. package/lib/collections/depreciation-forecast.collection.d.ts +2 -2
  52. package/lib/collections/depreciation.collection.d.ts +2 -2
  53. package/lib/collections/employee.collection.d.ts +2 -2
  54. package/lib/collections/income-source.collection.d.ts +2 -2
  55. package/lib/collections/loan.collection.d.ts +2 -2
  56. package/lib/collections/message-document.collection.d.ts +2 -2
  57. package/lib/collections/message.collection.d.ts +2 -2
  58. package/lib/collections/property.collection.d.ts +7 -2
  59. package/lib/collections/service-price.collection.d.ts +2 -2
  60. package/lib/collections/service-subscription.collection.d.ts +2 -2
  61. package/lib/collections/tax-return-category-item.collection.d.ts +2 -2
  62. package/lib/collections/tax-review.collection.d.ts +2 -2
  63. package/lib/collections/transaction-allocation.collection.d.ts +2 -2
  64. package/lib/collections/transaction.collection.d.ts +2 -2
  65. package/lib/collections/user-event-setting.collection.d.ts +2 -2
  66. package/lib/db/Enums/chart-accounts-metadata-list.enum.d.ts +1 -0
  67. package/lib/interceptors/corelogic-interceptor.d.ts +20 -0
  68. package/lib/interceptors/financial-year-interceptor.d.ts +12 -0
  69. package/lib/interceptors/interceptors.module.d.ts +6 -0
  70. package/lib/interceptors/jwt-interceptor.d.ts +42 -0
  71. package/lib/interceptors/preloader.interceptor.d.ts +15 -0
  72. package/lib/interceptors/user-switcher-interceptor.d.ts +19 -0
  73. package/lib/models/color/alphabet-colors.enum.d.ts +28 -0
  74. package/lib/models/data-table/data-table.d.ts +2 -2
  75. package/lib/models/logbook/vehicle-claim.d.ts +4 -0
  76. package/lib/models/transaction/transaction.d.ts +3 -0
  77. package/lib/services/bank/bank-account.service.d.ts +1 -0
  78. package/lib/services/pdf/pdf.service.d.ts +10 -1
  79. package/lib/services/property/equity-position-chart.service.d.ts +15 -0
  80. package/lib/services/xlsx/xlsx.service.d.ts +1 -1
  81. package/lib/tt-core.module.d.ts +2 -1
  82. package/package.json +1 -1
  83. package/public-api.d.ts +7 -1
  84. package/esm2015/lib/collections/abstract.collection.js +0 -83
@@ -1,6 +1,12 @@
1
1
  import * as i0 from '@angular/core';
2
- import { NgModule, Injectable, Inject, EventEmitter } from '@angular/core';
2
+ import { Injectable, Inject, NgModule, EventEmitter } from '@angular/core';
3
3
  import { CommonModule } from '@angular/common';
4
+ import * as i1 from '@angular/common/http';
5
+ import { HttpParams, HttpErrorResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
6
+ import { ReplaySubject, BehaviorSubject, throwError, Subject, Observable, combineLatest, forkJoin } from 'rxjs';
7
+ import { map, catchError, filter, take, switchMap, finalize, mergeMap } from 'rxjs/operators';
8
+ import { plainToClass, Type, Exclude, Transform, Expose, classToPlain } from 'class-transformer';
9
+ import { JwtHelperService } from '@auth0/angular-jwt';
4
10
  import has from 'lodash/has';
5
11
  import get from 'lodash/get';
6
12
  import flatten from 'lodash/flatten';
@@ -10,15 +16,10 @@ import uniqBy from 'lodash/uniqBy';
10
16
  import concat from 'lodash/concat';
11
17
  import compact from 'lodash/compact';
12
18
  import { __decorate, __awaiter } from 'tslib';
13
- import { Type, plainToClass, Exclude, Transform, Expose, classToPlain } from 'class-transformer';
14
19
  import * as moment from 'moment';
15
20
  import { DateRange } from 'moment-range';
16
21
  import cloneDeep$1 from 'lodash/cloneDeep';
17
22
  import { Validators } from '@angular/forms';
18
- import { ReplaySubject, BehaviorSubject, Subject, Observable, combineLatest, forkJoin } from 'rxjs';
19
- import { map, filter, mergeMap } from 'rxjs/operators';
20
- import * as i1 from '@angular/common/http';
21
- import { JwtHelperService } from '@auth0/angular-jwt';
22
23
  import _ from 'lodash';
23
24
  import { EventSourcePolyfill } from 'event-source-polyfill/src/eventsource.min.js';
24
25
  import * as i1$1 from '@angular/router';
@@ -30,6 +31,682 @@ import { loadStripe } from '@stripe/stripe-js';
30
31
  import * as xlsx from 'xlsx';
31
32
  import * as FileSaver from 'file-saver';
32
33
 
34
+ /**
35
+ * https://api-uat.corelogic.asia/property/au/v2/suggest.json
36
+ * address suggestion from corelogic service
37
+ */
38
+ class CorelogicSuggestion {
39
+ }
40
+
41
+ class CorelogicService {
42
+ constructor(http, environment) {
43
+ this.http = http;
44
+ this.environment = environment;
45
+ this.accessTokenSubject = new ReplaySubject(1);
46
+ }
47
+ getAccessToken(force = false) {
48
+ if (!this._accessToken || force) {
49
+ this.http.get(`${this.environment.coreLogicUrl}/access/oauth/token?grant_type=client_credentials&client_id=${this.environment.coreLogicId}&client_secret=${this.environment.coreLogicSecret}`)
50
+ .pipe(map((response) => {
51
+ return response.access_token;
52
+ }))
53
+ .subscribe((token) => {
54
+ this._accessToken = token;
55
+ this.accessTokenSubject.next(this._accessToken);
56
+ });
57
+ }
58
+ return this.accessTokenSubject.asObservable();
59
+ }
60
+ getSuggestions(query, country = 'au') {
61
+ // @TODO handle different countries in future
62
+ return this.http.get(`${this.environment.coreLogicUrl}/property/${country}/v2/suggest.json?q=${query}`)
63
+ .pipe(map((response) => {
64
+ return response.suggestions.map((item) => plainToClass(CorelogicSuggestion, item));
65
+ }));
66
+ }
67
+ }
68
+ CorelogicService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: CorelogicService, deps: [{ token: i1.HttpClient }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
69
+ CorelogicService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: CorelogicService, providedIn: 'root' });
70
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: CorelogicService, decorators: [{
71
+ type: Injectable,
72
+ args: [{
73
+ providedIn: 'root'
74
+ }]
75
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: undefined, decorators: [{
76
+ type: Inject,
77
+ args: ['environment']
78
+ }] }]; } });
79
+
80
+ /**
81
+ * Corelogic interceptor add Core Logic access token for each search requests related with Core Logic API
82
+ */
83
+ class CorelogicInterceptor {
84
+ constructor(corelogicService, environment) {
85
+ this.corelogicService = corelogicService;
86
+ this.environment = environment;
87
+ }
88
+ /**
89
+ * Check if requested url requested core logic, but not core logic auth api
90
+ * @param req
91
+ */
92
+ addToken(req) {
93
+ // don't need token for this endpoint
94
+ if (req.url.includes(`${this.environment.coreLogicUrl}/access/oauth/token`)) {
95
+ return req;
96
+ }
97
+ // add core logic token to request headers
98
+ if (req.url.includes(this.environment.coreLogicUrl)) {
99
+ return req.clone({
100
+ setHeaders: {
101
+ Authorization: 'Bearer ' + this.corelogicService._accessToken
102
+ }
103
+ });
104
+ }
105
+ // return request without changes if url not related with core logic
106
+ return req;
107
+ }
108
+ intercept(request, next) {
109
+ return next.handle(this.addToken(request));
110
+ }
111
+ }
112
+ CorelogicInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: CorelogicInterceptor, deps: [{ token: CorelogicService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
113
+ CorelogicInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: CorelogicInterceptor });
114
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: CorelogicInterceptor, decorators: [{
115
+ type: Injectable
116
+ }], ctorParameters: function () { return [{ type: CorelogicService }, { type: undefined, decorators: [{
117
+ type: Inject,
118
+ args: ['environment']
119
+ }] }]; } });
120
+
121
+ /**
122
+ * Financial Year interceptor add financialYear parameter to requests because a lot of POST and GET requests require this parameter
123
+ * @TODO now we can get current fin year from user on backend. So we can remove this interceptor
124
+ */
125
+ class FinancialYearInterceptor {
126
+ intercept(request, next) {
127
+ // Set financial year parameter to requests
128
+ let params = new HttpParams({
129
+ fromString: request.params.toString()
130
+ });
131
+ // clone request to add new parameters
132
+ let clonedReq = request.clone();
133
+ if (!params.get('financialYear')) {
134
+ params = params.set('financialYear', localStorage.getItem('financialYear'));
135
+ clonedReq = request.clone({
136
+ params: params
137
+ });
138
+ }
139
+ return next.handle(clonedReq);
140
+ }
141
+ }
142
+ FinancialYearInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FinancialYearInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
143
+ FinancialYearInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FinancialYearInterceptor });
144
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FinancialYearInterceptor, decorators: [{
145
+ type: Injectable
146
+ }] });
147
+
148
+ const NAME_TOKEN = 'token';
149
+ const NAME_REFRESH_TOKEN = 'refreshToken';
150
+ class JwtService extends JwtHelperService {
151
+ getToken() {
152
+ return localStorage[NAME_TOKEN];
153
+ }
154
+ getRefreshToken() {
155
+ return localStorage[NAME_REFRESH_TOKEN];
156
+ }
157
+ saveTokens(tokens) {
158
+ localStorage[NAME_TOKEN] = tokens.token;
159
+ localStorage[NAME_REFRESH_TOKEN] = tokens.refreshToken;
160
+ }
161
+ destroyTokens() {
162
+ localStorage.removeItem(NAME_TOKEN);
163
+ localStorage.removeItem(NAME_REFRESH_TOKEN);
164
+ }
165
+ getUser() {
166
+ return this.decodeToken();
167
+ }
168
+ isMe(userId) {
169
+ return this.getUser().id === userId;
170
+ }
171
+ }
172
+ JwtService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: JwtService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
173
+ JwtService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: JwtService, providedIn: 'root' });
174
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: JwtService, decorators: [{
175
+ type: Injectable,
176
+ args: [{
177
+ providedIn: 'root'
178
+ }]
179
+ }] });
180
+
181
+ class AuthService {
182
+ constructor(http, jwtService, environment) {
183
+ this.http = http;
184
+ this.jwtService = jwtService;
185
+ this.environment = environment;
186
+ this.isLoggedInSubject = new BehaviorSubject(!this.jwtService.isTokenExpired());
187
+ }
188
+ setAuth(response) {
189
+ this.jwtService.saveTokens(response);
190
+ this.isLoggedInSubject.next(true);
191
+ }
192
+ login(username, password) {
193
+ return this.http.post(`${this.environment.apiV2}/login_check`, { username, password }).pipe(map((response) => {
194
+ this.setAuth(response);
195
+ return response;
196
+ }));
197
+ }
198
+ refresh(refreshToken) {
199
+ return this.http.post(`${this.environment.apiV2}/token/refresh`, { refreshToken }).pipe(map((response) => {
200
+ this.setAuth(response);
201
+ return response;
202
+ }));
203
+ }
204
+ logoutFront(url = '/login') {
205
+ localStorage.clear();
206
+ location.replace(url);
207
+ }
208
+ }
209
+ AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AuthService, deps: [{ token: i1.HttpClient }, { token: JwtService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
210
+ AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AuthService, providedIn: 'root' });
211
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AuthService, decorators: [{
212
+ type: Injectable,
213
+ args: [{
214
+ providedIn: 'root'
215
+ }]
216
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: JwtService }, { type: undefined, decorators: [{
217
+ type: Inject,
218
+ args: ['environment']
219
+ }] }]; } });
220
+
221
+ const MESSAGE_DEFAULT_500_ERROR = 'Unexpected error! Please try again later. You can send us via chat your questions.';
222
+ /**
223
+ * JWT Interceptor add jwt token to each request related with TaxTank API
224
+ */
225
+ class JwtInterceptor {
226
+ constructor(jwtService, authService, environment) {
227
+ this.jwtService = jwtService;
228
+ this.authService = authService;
229
+ this.environment = environment;
230
+ this.isRefreshingToken = false;
231
+ this.tokenSubject = new BehaviorSubject(null);
232
+ }
233
+ addToken(req) {
234
+ return req.clone({
235
+ setHeaders: { Authorization: 'Bearer ' + this.jwtService.getToken() },
236
+ withCredentials: true
237
+ });
238
+ }
239
+ intercept(request, next) {
240
+ // skip third party requests
241
+ if (!request.url.includes(this.environment.api_uri)) {
242
+ return next.handle(request);
243
+ }
244
+ // add token to every api request
245
+ return next.handle(this.addToken(request)).pipe(
246
+ // handle errors
247
+ catchError((err) => {
248
+ if (err instanceof HttpErrorResponse) {
249
+ switch (err.status) {
250
+ // unexpected errors
251
+ case 405:
252
+ case 500:
253
+ this.handle500Error();
254
+ break;
255
+ // expected errors
256
+ case 401:
257
+ return this.handle401Error(request, next, err);
258
+ case 400:
259
+ case 403:
260
+ // @TODO in most cases 404 is not an error, handle in components
261
+ // case 404:
262
+ this.showErrorMessages(err);
263
+ break;
264
+ }
265
+ }
266
+ return throwError(err);
267
+ }));
268
+ }
269
+ /**
270
+ * @TODO log
271
+ * @TODO waiting for backend to handle errors in a better way
272
+ */
273
+ handle400Error(err) {
274
+ // this.snackBar.open(err.error['hydra:description'], '', {
275
+ // panelClass: 'error'
276
+ // });
277
+ }
278
+ /**
279
+ * @TODO log
280
+ * @TODO waiting for backend to handle errors in a better way
281
+ */
282
+ handle403Error(err) {
283
+ // this.snackBar.open(err.error['hydra:description'], '', {
284
+ // panelClass: 'error'
285
+ // });
286
+ }
287
+ /**
288
+ * @TODO log
289
+ */
290
+ handle500Error() {
291
+ // this.snackBar.open(MESSAGE_DEFAULT_500_ERROR, '', {
292
+ // panelClass: 'error'
293
+ // });
294
+ }
295
+ handle401Error(req, next, err) {
296
+ if (req.url.includes('token/refresh') || req.url.includes('login')) {
297
+ if (req.url.includes('token/refresh')) {
298
+ this.authService.logoutFront();
299
+ }
300
+ return throwError(err);
301
+ }
302
+ // refreshing token, wait until it's done and retry the request
303
+ if (this.isRefreshingToken) {
304
+ return this.tokenSubject.pipe(filter(token => token != null), take(1), switchMap(token => next.handle(this.addToken(req))));
305
+ // refresh token
306
+ }
307
+ else {
308
+ // subsequent requests should wait until refresh token is ready
309
+ this.isRefreshingToken = true;
310
+ this.tokenSubject.next(null);
311
+ return this.authService.refresh(this.jwtService.getRefreshToken()).pipe(switchMap((tokens) => {
312
+ this.tokenSubject.next(tokens.token);
313
+ return next.handle(this.addToken(req));
314
+ }), catchError(() => {
315
+ this.authService.logoutFront();
316
+ return throwError(err);
317
+ }), finalize(() => {
318
+ this.isRefreshingToken = false;
319
+ }));
320
+ }
321
+ }
322
+ /**
323
+ * Handle error messages
324
+ * @param errorResponse from which messages should be taken
325
+ *
326
+ * @TODO move to separated interceptor
327
+ */
328
+ showErrorMessages(errorResponse) {
329
+ if (!errorResponse.error.violations) {
330
+ // this.snackBar.open('Something went wrong', '', {
331
+ // panelClass: 'error'
332
+ // });
333
+ return;
334
+ }
335
+ errorResponse.error.violations.forEach((violation) => {
336
+ // this.snackBar.open(violation['message'], '', {
337
+ // panelClass: 'error'
338
+ // });
339
+ });
340
+ }
341
+ }
342
+ JwtInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: JwtInterceptor, deps: [{ token: JwtService }, { token: AuthService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
343
+ JwtInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: JwtInterceptor });
344
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: JwtInterceptor, decorators: [{
345
+ type: Injectable
346
+ }], ctorParameters: function () { return [{ type: JwtService }, { type: AuthService }, { type: undefined, decorators: [{
347
+ type: Inject,
348
+ args: ['environment']
349
+ }] }]; } });
350
+
351
+ const KEY = '_switch_user';
352
+ /**
353
+ * provides user management to managers (users with ROLE_ACCOUNTANT for now, more in future)
354
+ */
355
+ class UserSwitcherService {
356
+ /**
357
+ * get switched username
358
+ */
359
+ get() {
360
+ return localStorage[KEY];
361
+ }
362
+ /**
363
+ * switch to user (username should be used for correct work of backend)
364
+ */
365
+ set(username) {
366
+ localStorage[KEY] = username;
367
+ window.location.replace('/client/dashboard');
368
+ }
369
+ /**
370
+ * go back to original user
371
+ */
372
+ reset() {
373
+ localStorage.removeItem(KEY);
374
+ window.location.replace('/firm/dashboard');
375
+ }
376
+ }
377
+ UserSwitcherService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: UserSwitcherService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
378
+ UserSwitcherService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: UserSwitcherService, providedIn: 'root' });
379
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: UserSwitcherService, decorators: [{
380
+ type: Injectable,
381
+ args: [{
382
+ providedIn: 'root'
383
+ }]
384
+ }] });
385
+
386
+ /**
387
+ * Impersonate current's user (manager) to client experience with help of special header
388
+ */
389
+ class UserSwitcherInterceptor {
390
+ constructor(userSwitcherService, environment) {
391
+ this.userSwitcherService = userSwitcherService;
392
+ this.environment = environment;
393
+ }
394
+ /**
395
+ * add token header if request url contain TaxTank API URL
396
+ */
397
+ switch(req, username) {
398
+ // skip third party api requests
399
+ if (!req.url.includes(this.environment.api_uri) || !username) {
400
+ return req;
401
+ }
402
+ const params = new HttpParams({ fromString: req.params.toString() }).set('_switch_user', username);
403
+ return req.clone({ params });
404
+ // @TODO move to header solution when backend can support it
405
+ // return req.clone({
406
+ // setHeaders: {
407
+ // HTTP_X_SWITCH_USER: username
408
+ // }
409
+ // });
410
+ }
411
+ intercept(request, next) {
412
+ return next.handle(this.switch(request, this.userSwitcherService.get()));
413
+ }
414
+ }
415
+ UserSwitcherInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: UserSwitcherInterceptor, deps: [{ token: UserSwitcherService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
416
+ UserSwitcherInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: UserSwitcherInterceptor });
417
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: UserSwitcherInterceptor, decorators: [{
418
+ type: Injectable
419
+ }], ctorParameters: function () { return [{ type: UserSwitcherService }, { type: undefined, decorators: [{
420
+ type: Inject,
421
+ args: ['environment']
422
+ }] }]; } });
423
+
424
+ /**
425
+ * Backend endpoint class
426
+ */
427
+ class Endpoint {
428
+ constructor(method, pattern) {
429
+ this.method = method;
430
+ this.pattern = pattern;
431
+ }
432
+ /**
433
+ * check url with regexp
434
+ * @param url
435
+ */
436
+ test(url) {
437
+ return this.regexp.test(url);
438
+ }
439
+ /**
440
+ * Get regexp for endpoint
441
+ */
442
+ get regexp() {
443
+ return new RegExp(`^${this.method} \.\*${this.pattern}$`);
444
+ }
445
+ }
446
+
447
+ /**
448
+ * List of all app endpoints
449
+ */
450
+ const ENDPOINTS = {
451
+ ASSETS_GET: new Endpoint('GET', '\\/assets\\/\.\*\\/\\d+'),
452
+ BANK_ACCOUNTS_GET: new Endpoint('GET', '\\/bank-accounts'),
453
+ BANK_ACCOUNTS_POST: new Endpoint('POST', '\\/bank-accounts'),
454
+ BANK_ACCOUNTS_PUT: new Endpoint('PUT', '\\/bank-accounts\\/\\d+'),
455
+ BANK_CONNECTION_POST: new Endpoint('POST', '\\/bank-connections'),
456
+ BANK_TRANSACTIONS_GET: new Endpoint('GET', '\\/bank-transactions'),
457
+ BANK_TRANSACTIONS_DELETE: new Endpoint('DELETE', '\\/bank-transactions\\/\\d+'),
458
+ BANK_TRANSACTIONS_IMPORT_POST: new Endpoint('POST', '\\/bank-transactions\\/\\d+\\/import'),
459
+ BASIQ_ACCOUNTS_GET: new Endpoint('GET', '\\/basiq\\/\\accounts'),
460
+ CAPITAL_COSTS_GET: new Endpoint('GET', '\\/capital-costs'),
461
+ CHARTS_INCOME_GET: new Endpoint('GET', '\\/charts\\/\\incomes'),
462
+ CHARTS_EXPENSES_GET: new Endpoint('GET', '\\/charts\\/\\expenses'),
463
+ CHART_ACCOUNTS_GET: new Endpoint('GET', '\\/chart-accounts'),
464
+ CLIENTS_GET: new Endpoint('GET', '\\/clients'),
465
+ CLIENTS_PUT: new Endpoint('PUT', '\\/clients'),
466
+ CLIENTS_EXCLUDE_PUT: new Endpoint('PUT', '\\/clients\\/\\d+\\/exclude'),
467
+ CLIENTS_INVITES_GET: new Endpoint('GET', '\\/clients\\/\\invites'),
468
+ CLIENTS_INVITES_POST: new Endpoint('POST', '\\/clients\\/\\invites'),
469
+ CLIENTS_INVITES_DELETE: new Endpoint('DELETE', '\\/clients\\/\\invites\\/\\d+'),
470
+ CLIENTS_INVITES_ACCEPT_POST: new Endpoint('POST', '\\/clients\\/\\invites\\/\\d+\\/accept'),
471
+ CLIENTS_INVITES_REJECT_POST: new Endpoint('POST', '\\/clients\\/\\invites\\/\\d+\\/reject'),
472
+ CLIENTS_INVITES_RESEND_POST: new Endpoint('POST', '\\/clients\\/\\invites\\/\\d+\\/resend'),
473
+ CLIENT_MOVEMENTS_GET: new Endpoint('GET', '\\/client-movements'),
474
+ CLIENT_MOVEMENTS_POST: new Endpoint('POST', '\\/client-movements'),
475
+ COUNTRIES_GET: new Endpoint('GET', '\\/countries'),
476
+ DEPRECIATIONS_CLOSING_GET: new Endpoint('GET', '\\/depreciations\\/\\closing-balance\.\*'),
477
+ DEPRECIATIONS_GET: new Endpoint('GET', '\\/depreciations'),
478
+ DEPRECIATIONS_POST: new Endpoint('POST', '\\/depreciations'),
479
+ DEPRECIATIONS_PUT: new Endpoint('PUT', '\\/depreciations\\/\\d+'),
480
+ EMPLOYEES_GET: new Endpoint('GET', '\\/employees'),
481
+ EMPLOYEES_INVITES_GET: new Endpoint('GET', '\\/employees\\/\\invites'),
482
+ EMPLOYEES_INVITES_DELETE: new Endpoint('DELETE', '\\/employees\\/\\invites\\/\\d+'),
483
+ EMPLOYEES_INVITE_POST: new Endpoint('POST', '\\/employees\\/\\invites'),
484
+ EMPLOYEES_INVITES_REJECT_POST: new Endpoint('POST', '\\/employees\\/\\invites\\/\\d+\\/\\reject'),
485
+ EMPLOYEES_INVITES_RESEND_POST: new Endpoint('POST', '\\/employees\\/\\invites\\/\\d+\\/\\resend'),
486
+ FIRM_GET: new Endpoint('GET', '\\/firms'),
487
+ FIRM_CURRENT_GET: new Endpoint('GET', '\\/firms\\/current'),
488
+ FIRM_CURRENT_PUT: new Endpoint('PUT', '\\/firms\\/current\.\*'),
489
+ FIRM_INVITE_POST: new Endpoint('POST', '\\/firms\\/invite'),
490
+ FIRM_REGISTRATION_POST: new Endpoint('POST', '\\/firms\\/registration'),
491
+ FIRM_UPDATE_PHOTO_POST: new Endpoint('POST', '\\/firms\\/photo\.\*'),
492
+ FOLDERS_GET: new Endpoint('GET', '\\/folders'),
493
+ FOLDERS_POST: new Endpoint('POST', '\\/folders'),
494
+ FOLDERS_PUT: new Endpoint('PUT', '\\/folders\\/\\d+'),
495
+ FOLDERS_DOCUMENTS_POST: new Endpoint('POST', '\\/folders\\/\\d+\\/documents'),
496
+ FOLDERS_DOCUMENTS_PUT: new Endpoint('PUT', '\\/folders\\/\\d+\\/documents\\/\\d+'),
497
+ INCOME_SOURCES_GET: new Endpoint('GET', '\\/income-sources'),
498
+ INCOME_SOURCES_POST: new Endpoint('POST', '\\/income-sources'),
499
+ INCOME_SOURCES_PUT: new Endpoint('PUT', '\\/income-sources'),
500
+ INCOME_SOURCES_DELETE: new Endpoint('DELETE', '\\/income-sources\\/\\d+'),
501
+ INCOME_SOURCE_FORECAST_GET: new Endpoint('GET', '\\/income-source-forecasts'),
502
+ INCOME_SOURCE_FORECAST_POST: new Endpoint('POST', '\\/income-source-forecasts'),
503
+ INCOME_SOURCE_FORECAST_PUT: new Endpoint('PUT', '\\/income-source-forecasts'),
504
+ INCOME_SOURCE_FORECAST_DELETE: new Endpoint('DELETE', '\\/income-source-forecasts\\/\\d+'),
505
+ INCOME_SOURCE_TYPES_GET: new Endpoint('GET', '\\/income-source-types'),
506
+ LOANS_GET: new Endpoint('GET', '\\/bank-accounts\\/loans'),
507
+ LOANS_POST: new Endpoint('POST', '\\/bank-accounts\\/loans'),
508
+ LOANS_PUT: new Endpoint('PUT', '\\/bank-accounts\\/loans/\\d+'),
509
+ LOANS_PAYOUT_POST: new Endpoint('POST', '\\/loans\\/\\d+\\/payout'),
510
+ LOANS_PAYOUT_PUT: new Endpoint('PUT', '\\/loans\\/\\d+\\/payout\\/\\d+'),
511
+ LOANS_PAYOUT_DELETE: new Endpoint('DELETE', '\\/loans\\/\\d+\\/payout\\/\\d+'),
512
+ LOANS_CALCULATION_POST: new Endpoint('POST', '\\/bank-accounts\\/loans\\/calculation'),
513
+ LOGIN_CHECK_POST: new Endpoint('POST', '\\/login_check'),
514
+ NOTIFICATIONS_GET: new Endpoint('GET', '\\/service-notifications'),
515
+ OCCUPATIONS_GET: new Endpoint('GET', '\\/occupations'),
516
+ PROPERTIES_GET: new Endpoint('GET', '\\/properties'),
517
+ PROPERTIES_POST: new Endpoint('POST', '\\/properties'),
518
+ PROPERTY_PUT: new Endpoint('PUT', '\\/properties/\\d+'),
519
+ PROPERTIES_PUT: new Endpoint('PUT', '\\/properties'),
520
+ PROPERTIES_CATEGORIES_EQUITY_GET: new Endpoint('GET', '\\/properties\\/categories\\/equity'),
521
+ PROPERTIES_CATEGORIES_GET: new Endpoint('GET', '\\/properties\\/categories'),
522
+ PROPERTIES_CATEGORIES_PUT: new Endpoint('PUT', '\\/properties\\/categories\\/\\d+'),
523
+ PROPERTIES_CATEGORIES_POST: new Endpoint('POST', '\\/properties\\/categories'),
524
+ PROPERTIES_CATEGORY_MOVEMENTS_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/category-movements'),
525
+ PROPERTIES_CATEGORY_MOVEMENTS_PUT: new Endpoint('PUT', '\\/properties\\/\\d+\\/category-movements\\/\\d+'),
526
+ PROPERTIES_CO_OWNERS_PUT: new Endpoint('PUT', '\\/properties\\/co-owners\\/\\d+'),
527
+ PROPERTIES_CO_OWNERS_GET: new Endpoint('GET', '\\/properties\\/co-owners'),
528
+ PROPERTIES_CO_OWNERS_POST: new Endpoint('POST', '\\/properties\\/co-owners'),
529
+ PROPERTIES_DEACTIVATE_PUT: new Endpoint('PUT', '\\/properties\\/\\d+\\/deactivate'),
530
+ PROPERTIES_DEPRECIATION_CAPITAL_PROJECT_GET: new Endpoint('GET', '\\/properties\\/\\d+\\/depreciation-capital-projects'),
531
+ PROPERTIES_DEPRECIATION_CAPITAL_PROJECT_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/depreciation-capital-projects'),
532
+ PROPERTIES_DEPRECIATION_CAPITAL_PROJECT_PUT: new Endpoint('PUT', '\\/properties\\/\\d+\\/depreciation-capital-projects\\/\\d+'),
533
+ PROPERTIES_DEPRECIATION_CAPITAL_PROJECT_DELETE: new Endpoint('DELETE', '\\/properties\\/\\d+\\/depreciation-capital-projects\\/\\d+'),
534
+ PROPERTIES_DOCUMENTS_GET: new Endpoint('GET', '\\/properties\\/documents'),
535
+ PROPERTIES_DOCUMENTS_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/documents'),
536
+ PROPERTIES_DOCUMENTS_PUT: new Endpoint('PUT', '\\/properties\\/documents\\/\\d+'),
537
+ PROPERTIES_DOCUMENTS_DELETE: new Endpoint('DELETE', '\\/properties\\/documents\\/\\d+'),
538
+ PROPERTIES_PHOTO_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/photo\.\*'),
539
+ PROPERTIES_SUGGESTIONS_GET: new Endpoint('GET', '/property\\/\\w+\\/v2\\/.*$'),
540
+ PROPERTIES_VALUATIONS_DOCUMENTS_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/valuations\\/\\d+\\/documents'),
541
+ PRORATION_COST_POST: new Endpoint('POST', '\\/subscriptions\\/proration-cost'),
542
+ SALARY_FORECAST_GET: new Endpoint('GET', '\\/salary-forecasts'),
543
+ SALARY_FORECAST_POST: new Endpoint('POST', '\\/salary-forecasts'),
544
+ SALARY_FORECAST_PUT: new Endpoint('PUT', '\\/salary-forecasts'),
545
+ SERVICE_PRICES_GET: new Endpoint('GET', '\\/service-prices'),
546
+ SERVICE_PAYMENTS_GET: new Endpoint('GET', '\\/service-payments'),
547
+ STRIPE_BILLING_PORTAL_GET: new Endpoint('GET', '\\/stripe\\/billing-portal-session'),
548
+ STRIPE_CHECKOUT_SESSION_POST: new Endpoint('POST', '\\/stripe\\/checkout-session'),
549
+ SUBSCRIPTION_LAST_GET: new Endpoint('GET', '\\/subscriptions\\/last'),
550
+ SUBSCRIPTION_ITEMS_PUT: new Endpoint('PUT', '\\/subscriptions\\/items'),
551
+ TAX_CALCULATION_POST: new Endpoint('POST', '\\/tax-calculation'),
552
+ TAX_REVIEWS_GET: new Endpoint('GET', '\\/tax-reviews'),
553
+ TAX_REVIEWS_DELETE: new Endpoint('DELETE', '\\/tax-reviews\\/\\d+'),
554
+ TAX_REVIEWS_POST: new Endpoint('POST', '\\/tax-reviews'),
555
+ TAX_REVIEWS_PUT: new Endpoint('PUT', '\\/tax-reviews\\/\\d+'),
556
+ TAX_SUMMARY_ACTUAL_GET: new Endpoint('GET', '\\/tax-summary\\/actuals'),
557
+ TAX_SUMMARY_FORECAST_GET: new Endpoint('GET', '\\/tax-summary\\/forecasts'),
558
+ TRANSACTION_DELETE: new Endpoint('DELETE', '\\/transactions\\/\\d+'),
559
+ TRANSACTION_PUT: new Endpoint('PUT', '\\/transactions\\/\\d+'),
560
+ TRANSACTIONS_GET: new Endpoint('GET', '\\/transactions'),
561
+ TRANSACTIONS_POST: new Endpoint('POST', '\\/transactions'),
562
+ TRANSACTIONS_PUT: new Endpoint('PUT', '\\/transactions'),
563
+ TRANSACTIONS_ALLOCATIONS_GET: new Endpoint('GET', '\\/transactions-allocations'),
564
+ TRANSACTIONS_ALLOCATIONS_POST: new Endpoint('POST', '\\/transactions-allocations'),
565
+ TRANSACTIONS_ALLOCATIONS_DELETE: new Endpoint('DELETE', '\\/transactions-allocations\\/\\d+'),
566
+ USER_CONFIRMATION_POST: new Endpoint('POST', '\\/users\\/confirmation'),
567
+ USER_CURRENT_GET: new Endpoint('GET', '\\/users\\/current'),
568
+ USER_CURRENT_PASSWORD_PUT: new Endpoint('PUT', '\\/users\\/current\\/password\.\*'),
569
+ USER_EVENT_SETTINGS_GET: new Endpoint('GET', '\\/user-event-settings'),
570
+ USER_EVENT_TYPES_GET: new Endpoint('GET', '\\/user-event-types'),
571
+ USER_INVITE_DELETE: new Endpoint('DELETE', '\\/users\\/invite\\/\\d+'),
572
+ USER_INVITE_POST: new Endpoint('POST', '\\/users\\/invite'),
573
+ USER_INVITE_RESEND_POST: new Endpoint('POST', '\\/users\\/invite/\\d+\\/resend'),
574
+ USER_PUT: new Endpoint('PUT', '\\/users\\/\\d+'),
575
+ USER_REGISTRATION_POST: new Endpoint('POST', '\\/users\\/registration'),
576
+ USER_RESET_PASSWORD_PUT: new Endpoint('PUT', '\\/users\\/reset-password'),
577
+ USER_SEARCH_GET: new Endpoint('GET', '\\/users\\/search\.\*'),
578
+ USER_UPDATE_PHOTO_POST: new Endpoint('POST', '\\/users\\/photo\.\*'),
579
+ USER_STATUS_PUT: new Endpoint('PUT', '\\/users\\/status'),
580
+ VEHICLES_GET: new Endpoint('GET', '\\/vehicles'),
581
+ VEHICLES_POST: new Endpoint('POST', '\\/vehicles'),
582
+ VEHICLES_PUT: new Endpoint('PUT', '\\/vehicles\\/\\d+'),
583
+ VEHICLE_CLAIMS_GET: new Endpoint('GET', '\\/vehicle-claims'),
584
+ VEHICLE_CLAIMS_POST: new Endpoint('POST', '\\/vehicle-claims'),
585
+ VEHICLE_LOGBOOK_POST: new Endpoint('POST', '\\/vehicles\\/\\d+\\/logbooks'),
586
+ VEHICLE_LOGBOOK_PUT: new Endpoint('PUT', '\\/vehicles\\/\\d+\\/logbooks\\/\\d+'),
587
+ VEHICLE_CLAIMS_PUT: new Endpoint('PUT', '\\/vehicle-claims\\/\\d+')
588
+ };
589
+
590
+ class PreloaderService {
591
+ constructor() {
592
+ this.activePreloaders = new BehaviorSubject([]);
593
+ }
594
+ get() {
595
+ return this.activePreloaders.asObservable();
596
+ }
597
+ add(endpoint) {
598
+ const activePreloaders = this.activePreloaders.getValue();
599
+ activePreloaders.push(endpoint);
600
+ this.activePreloaders.next(activePreloaders);
601
+ }
602
+ delete(endpoint) {
603
+ let activePreloaders = this.activePreloaders.getValue();
604
+ activePreloaders = activePreloaders.filter((preloader) => preloader !== endpoint);
605
+ this.activePreloaders.next(activePreloaders);
606
+ }
607
+ }
608
+ PreloaderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreloaderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
609
+ PreloaderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreloaderService, providedIn: 'root' });
610
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreloaderService, decorators: [{
611
+ type: Injectable,
612
+ args: [{
613
+ providedIn: 'root'
614
+ }]
615
+ }], ctorParameters: function () { return []; } });
616
+
617
+ /**
618
+ * interceptor for preloader handling
619
+ */
620
+ class PreloaderInterceptor {
621
+ constructor(preloaderService) {
622
+ this.preloaderService = preloaderService;
623
+ }
624
+ intercept(request, next) {
625
+ const endpoint = this.findEndpoint(`${request.method} ${request.url}`);
626
+ if (!!endpoint) {
627
+ this.preloaderService.add(endpoint);
628
+ return next.handle(request).pipe(finalize(() => {
629
+ this.preloaderService.delete(endpoint);
630
+ }));
631
+ }
632
+ return next.handle(request);
633
+ }
634
+ findEndpoint(requestPath) {
635
+ return Object.values(ENDPOINTS).find((endpoint) => endpoint.test(requestPath));
636
+ }
637
+ }
638
+ PreloaderInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreloaderInterceptor, deps: [{ token: PreloaderService }], target: i0.ɵɵFactoryTarget.Injectable });
639
+ PreloaderInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreloaderInterceptor });
640
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreloaderInterceptor, decorators: [{
641
+ type: Injectable
642
+ }], ctorParameters: function () { return [{ type: PreloaderService }]; } });
643
+
644
+ class InterceptorsModule {
645
+ }
646
+ InterceptorsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: InterceptorsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
647
+ InterceptorsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: InterceptorsModule });
648
+ InterceptorsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: InterceptorsModule, providers: [
649
+ {
650
+ provide: HTTP_INTERCEPTORS,
651
+ useClass: CorelogicInterceptor,
652
+ multi: true
653
+ },
654
+ // @TODO move to user module
655
+ {
656
+ provide: HTTP_INTERCEPTORS,
657
+ useClass: FinancialYearInterceptor,
658
+ multi: true
659
+ },
660
+ {
661
+ provide: HTTP_INTERCEPTORS,
662
+ useClass: JwtInterceptor,
663
+ multi: true
664
+ },
665
+ {
666
+ provide: HTTP_INTERCEPTORS,
667
+ useClass: UserSwitcherInterceptor,
668
+ multi: true
669
+ },
670
+ {
671
+ provide: HTTP_INTERCEPTORS,
672
+ useClass: PreloaderInterceptor,
673
+ multi: true
674
+ }
675
+ ] });
676
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: InterceptorsModule, decorators: [{
677
+ type: NgModule,
678
+ args: [{
679
+ providers: [
680
+ {
681
+ provide: HTTP_INTERCEPTORS,
682
+ useClass: CorelogicInterceptor,
683
+ multi: true
684
+ },
685
+ // @TODO move to user module
686
+ {
687
+ provide: HTTP_INTERCEPTORS,
688
+ useClass: FinancialYearInterceptor,
689
+ multi: true
690
+ },
691
+ {
692
+ provide: HTTP_INTERCEPTORS,
693
+ useClass: JwtInterceptor,
694
+ multi: true
695
+ },
696
+ {
697
+ provide: HTTP_INTERCEPTORS,
698
+ useClass: UserSwitcherInterceptor,
699
+ multi: true
700
+ },
701
+ {
702
+ provide: HTTP_INTERCEPTORS,
703
+ useClass: PreloaderInterceptor,
704
+ multi: true
705
+ }
706
+ ]
707
+ }]
708
+ }] });
709
+
33
710
  class TtCoreModule {
34
711
  static forRoot(environment) {
35
712
  localStorage.setItem('api_uri', environment['api_uri']);
@@ -45,16 +722,19 @@ class TtCoreModule {
45
722
  }
46
723
  }
47
724
  TtCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TtCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
48
- TtCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TtCoreModule, imports: [CommonModule] });
725
+ TtCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TtCoreModule, imports: [CommonModule,
726
+ InterceptorsModule] });
49
727
  TtCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TtCoreModule, imports: [[
50
- CommonModule
728
+ CommonModule,
729
+ InterceptorsModule
51
730
  ]] });
52
731
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TtCoreModule, decorators: [{
53
732
  type: NgModule,
54
733
  args: [{
55
734
  declarations: [],
56
735
  imports: [
57
- CommonModule
736
+ CommonModule,
737
+ InterceptorsModule
58
738
  ]
59
739
  }]
60
740
  }] });
@@ -144,9 +824,9 @@ class CollectionDictionary {
144
824
 
145
825
  const DEFAULT_INDEX = 'other';
146
826
  /**
147
- * collection abstract class. Contains common properties and methods for all collections
827
+ * Base collection class. Contains common properties and methods for all collections
148
828
  */
149
- class AbstractCollection {
829
+ class Collection {
150
830
  constructor(items = []) {
151
831
  this.items = items;
152
832
  }
@@ -180,14 +860,6 @@ class AbstractCollection {
180
860
  get length() {
181
861
  return this.items.length;
182
862
  }
183
- /**
184
- * method returns amount of fields from passed items
185
- * @param field Name of field for calculation
186
- * @param items (optional) Array of items need to be calculated. All collection's items by default
187
- */
188
- getSummary(field, items = this.toArray()) {
189
- return items.reduce((sum, item) => sum += item[field], 0);
190
- }
191
863
  /**
192
864
  * Get list of items ids
193
865
  */
@@ -242,7 +914,7 @@ const TYPE_LOAN = [
242
914
  /**
243
915
  * Collection of bank accounts.
244
916
  */
245
- class BankAccountCollection extends AbstractCollection {
917
+ class BankAccountCollection extends Collection {
246
918
  /**
247
919
  * get list of bank accounts with passed types
248
920
  */
@@ -386,7 +1058,7 @@ const TRANSACTION_TRANSFER_DELAY = 96 * 3600 * 1000;
386
1058
  * @TODO find way to accept interface with allocation instead of bankTransaction to prevent wrong usage
387
1059
  * because all amounts calculates with allocated amounts but not from bank transactions amounts.
388
1060
  */
389
- class BankTransactionCollection extends AbstractCollection {
1061
+ class BankTransactionCollection extends Collection {
390
1062
  getAmount() {
391
1063
  return this.sumBy('amount');
392
1064
  }
@@ -492,7 +1164,7 @@ class BankTransactionCollection extends AbstractCollection {
492
1164
  }
493
1165
  }
494
1166
 
495
- class ClientCollection extends AbstractCollection {
1167
+ class ClientCollection extends Collection {
496
1168
  }
497
1169
 
498
1170
  var FirmTypeEnum;
@@ -501,7 +1173,7 @@ var FirmTypeEnum;
501
1173
  FirmTypeEnum[FirmTypeEnum["ADVISOR"] = 2] = "ADVISOR";
502
1174
  })(FirmTypeEnum || (FirmTypeEnum = {}));
503
1175
 
504
- class EmployeeCollection extends AbstractCollection {
1176
+ class EmployeeCollection extends Collection {
505
1177
  get accountant() {
506
1178
  var _a;
507
1179
  return (_a = this.items.filter((user) => user.employeeDetails.firm.type === FirmTypeEnum.ACCOUNTANT)[0]) !== null && _a !== void 0 ? _a : null;
@@ -514,7 +1186,7 @@ class EmployeeCollection extends AbstractCollection {
514
1186
  /**
515
1187
  * Collection of tax review
516
1188
  */
517
- class ClientMovementCollection extends AbstractCollection {
1189
+ class ClientMovementCollection extends Collection {
518
1190
  get active() {
519
1191
  return new ClientMovementCollection(this.items.filter((clientMovement) => !clientMovement.dateTo));
520
1192
  }
@@ -542,7 +1214,7 @@ class ClientMovementCollection extends AbstractCollection {
542
1214
  /**
543
1215
  * Collection of employee clients tax summary information
544
1216
  */
545
- class ClientPortfolioReportCollection extends AbstractCollection {
1217
+ class ClientPortfolioReportCollection extends Collection {
546
1218
  get marketValue() {
547
1219
  return this.sumBy('marketValue');
548
1220
  }
@@ -585,7 +1257,7 @@ var TankTypeEnum;
585
1257
  TankTypeEnum[TankTypeEnum["OTHER"] = 3] = "OTHER";
586
1258
  })(TankTypeEnum || (TankTypeEnum = {}));
587
1259
 
588
- class DepreciationCollection extends AbstractCollection {
1260
+ class DepreciationCollection extends Collection {
589
1261
  /**
590
1262
  * Get total amount of all depreciations in the collection
591
1263
  */
@@ -651,7 +1323,7 @@ class DepreciationCollection extends AbstractCollection {
651
1323
  /**
652
1324
  * Collection of depreciations
653
1325
  */
654
- class DepreciationForecastCollection extends AbstractCollection {
1326
+ class DepreciationForecastCollection extends Collection {
655
1327
  filterByYear(financialYear) {
656
1328
  return new DepreciationForecastCollection(this.items.filter((forecast) => forecast.financialYear === financialYear));
657
1329
  }
@@ -659,17 +1331,17 @@ class DepreciationForecastCollection extends AbstractCollection {
659
1331
  return this.items.reduce((sum, item) => sum + item.getClaimAmountByMonth(month), 0);
660
1332
  }
661
1333
  get amount() {
662
- return this.getSummary('amount');
1334
+ return this.sumBy('amount');
663
1335
  }
664
1336
  get claimAmount() {
665
- return this.getSummary('claimAmount');
1337
+ return this.sumBy('claimAmount');
666
1338
  }
667
1339
  }
668
1340
 
669
1341
  /**
670
1342
  * Collection of income sources
671
1343
  */
672
- class IncomeSourceCollection extends AbstractCollection {
1344
+ class IncomeSourceCollection extends Collection {
673
1345
  filterByTank(tank) {
674
1346
  return this.items.filter((incomeSource) => {
675
1347
  switch (tank) {
@@ -702,7 +1374,7 @@ class IncomeSourceCollection extends AbstractCollection {
702
1374
  }
703
1375
  }
704
1376
 
705
- class LoanCollection extends AbstractCollection {
1377
+ class LoanCollection extends Collection {
706
1378
  /**
707
1379
  * Get new collection of loans filtered by bank accounts ids
708
1380
  * @param ids list of bank accounts ids for filter
@@ -866,7 +1538,7 @@ class LogbookCollection {
866
1538
  }
867
1539
  }
868
1540
 
869
- class MessageCollection extends AbstractCollection {
1541
+ class MessageCollection extends Collection {
870
1542
  getFirstUnreadMessage(user) {
871
1543
  return this.items.find((message) => {
872
1544
  return !message.isRead() && message.isFromEmployee() !== user.isEmployee();
@@ -889,7 +1561,7 @@ class MessageCollection extends AbstractCollection {
889
1561
  /**
890
1562
  * Collection of MessageDocument instances
891
1563
  */
892
- class MessageDocumentCollection extends AbstractCollection {
1564
+ class MessageDocumentCollection extends Collection {
893
1565
  /**
894
1566
  * get list of documents which are not attached to any message
895
1567
  */
@@ -898,7 +1570,7 @@ class MessageDocumentCollection extends AbstractCollection {
898
1570
  }
899
1571
  }
900
1572
 
901
- class PropertyCollection extends AbstractCollection {
1573
+ class PropertyCollection extends Collection {
902
1574
  /**
903
1575
  * Get new property collection filtered by category id
904
1576
  * @param id id of category for filter
@@ -959,9 +1631,15 @@ class PropertyCollection extends AbstractCollection {
959
1631
  return min < property.purchaseDate ? min : property.purchaseDate;
960
1632
  }, new FinancialYear(new Date()).startDate);
961
1633
  }
1634
+ /**
1635
+ * Get list of unique property categories from collection
1636
+ */
1637
+ getCategories() {
1638
+ return uniqBy(this.items.map((property) => property.category), 'id');
1639
+ }
962
1640
  }
963
1641
 
964
- class ServicePriceCollection extends AbstractCollection {
1642
+ class ServicePriceCollection extends Collection {
965
1643
  get work() {
966
1644
  return this.items.filter((price) => price.product.isWork())[0];
967
1645
  }
@@ -970,7 +1648,7 @@ class ServicePriceCollection extends AbstractCollection {
970
1648
  }
971
1649
  }
972
1650
 
973
- class ServiceSubscriptionCollection extends AbstractCollection {
1651
+ class ServiceSubscriptionCollection extends Collection {
974
1652
  get individual() {
975
1653
  return this.items.filter((subscription) => subscription.isIndividual())[0];
976
1654
  }
@@ -1025,7 +1703,7 @@ var TaxReturnCategorySectionEnum;
1025
1703
  /**
1026
1704
  * collection for tax return category items
1027
1705
  */
1028
- class TaxReturnCategoryItemCollection extends AbstractCollection {
1706
+ class TaxReturnCategoryItemCollection extends Collection {
1029
1707
  /**
1030
1708
  * Work income
1031
1709
  */
@@ -1163,7 +1841,7 @@ class TaxReturnCategoryItemCollection extends AbstractCollection {
1163
1841
  /**
1164
1842
  * Collection of tax review
1165
1843
  */
1166
- class TaxReviewCollection extends AbstractCollection {
1844
+ class TaxReviewCollection extends Collection {
1167
1845
  /**
1168
1846
  * Get tax reviews items with SENT & COMPLETED statuses
1169
1847
  */
@@ -1213,7 +1891,7 @@ class TaxReviewCollection extends AbstractCollection {
1213
1891
  }
1214
1892
  }
1215
1893
 
1216
- class TransactionAllocationCollection extends AbstractCollection {
1894
+ class TransactionAllocationCollection extends Collection {
1217
1895
  get amount() {
1218
1896
  return this.sumBy('amount');
1219
1897
  }
@@ -1254,7 +1932,7 @@ class TransactionAllocationCollection extends AbstractCollection {
1254
1932
  /**
1255
1933
  * Collection of transactions
1256
1934
  */
1257
- class TransactionCollection extends AbstractCollection {
1935
+ class TransactionCollection extends Collection {
1258
1936
  /**
1259
1937
  * Get total amount of all transactions in the collection
1260
1938
  */
@@ -1373,7 +2051,7 @@ class TransactionCollection extends AbstractCollection {
1373
2051
  /**
1374
2052
  * Collection of user event settings
1375
2053
  */
1376
- class UserEventSettingCollection extends AbstractCollection {
2054
+ class UserEventSettingCollection extends Collection {
1377
2055
  getConfigurableBy(field) {
1378
2056
  return new UserEventSettingCollection(this.items.filter((setting) => setting[field] !== null));
1379
2057
  }
@@ -1577,6 +2255,7 @@ var ChartAccountsMetadataListEnum;
1577
2255
  (function (ChartAccountsMetadataListEnum) {
1578
2256
  ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["TAX_INSTALMENTS"] = 4] = "TAX_INSTALMENTS";
1579
2257
  ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["FRANKING_CREDIT"] = 5] = "FRANKING_CREDIT";
2258
+ ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["ELIGIBLE_FOR_REDUCTION"] = 6] = "ELIGIBLE_FOR_REDUCTION";
1580
2259
  ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["SHARE_PERCENTAGE"] = 7] = "SHARE_PERCENTAGE";
1581
2260
  ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["TAX_OFFSETS"] = 8] = "TAX_OFFSETS";
1582
2261
  ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["HOURS"] = 11] = "HOURS";
@@ -3617,6 +4296,9 @@ class Transaction extends Transaction$1 {
3617
4296
  get frankingCredit() {
3618
4297
  return this.getMetadataFieldValue(ChartAccountsMetadataListEnum.FRANKING_CREDIT);
3619
4298
  }
4299
+ get eligibleForReduction() {
4300
+ return this.getMetadataFieldValue(ChartAccountsMetadataListEnum.ELIGIBLE_FOR_REDUCTION);
4301
+ }
3620
4302
  get untaxedElement() {
3621
4303
  return this.getMetadataFieldValue(ChartAccountsMetadataListEnum.UNTAXED_ELEMENT);
3622
4304
  }
@@ -3627,6 +4309,12 @@ class Transaction extends Transaction$1 {
3627
4309
  get isTransfer() {
3628
4310
  return this.operation === TransactionOperationEnum.TRANSFER;
3629
4311
  }
4312
+ get debit() {
4313
+ return this.isDebit() ? Math.abs(this.amount) : null;
4314
+ }
4315
+ get credit() {
4316
+ return this.isCredit() ? Math.abs(this.amount) : null;
4317
+ }
3630
4318
  /**
3631
4319
  * Get value of transaction metadata field
3632
4320
  * @param field for which value should be returned
@@ -3650,7 +4338,7 @@ class Transaction extends Transaction$1 {
3650
4338
  (this.transactions
3651
4339
  .reduce((sum, transaction) => sum + Math.abs(transaction.amount), 0) * modifier);
3652
4340
  case this.isWorkTank():
3653
- return this.amount + ((this.tax + this.frankingCredit - this.taxFreeComponent) * modifier);
4341
+ return this.amount + ((this.tax + this.frankingCredit - this.taxFreeComponent - this.eligibleForReduction) * modifier);
3654
4342
  default:
3655
4343
  return this.amount || 0;
3656
4344
  }
@@ -4245,6 +4933,36 @@ class ClientPortfolioChartData {
4245
4933
  class ClientPortfolioReport {
4246
4934
  }
4247
4935
 
4936
+ var AlphabetColorsEnum;
4937
+ (function (AlphabetColorsEnum) {
4938
+ AlphabetColorsEnum["A"] = "#9CC3D5";
4939
+ AlphabetColorsEnum["B"] = "#E69A8D";
4940
+ AlphabetColorsEnum["C"] = "#ED2B33";
4941
+ AlphabetColorsEnum["D"] = "#E3CD81";
4942
+ AlphabetColorsEnum["E"] = "#343148";
4943
+ AlphabetColorsEnum["F"] = "#2C5F2D";
4944
+ AlphabetColorsEnum["G"] = "#FFA177";
4945
+ AlphabetColorsEnum["H"] = "#435E55";
4946
+ AlphabetColorsEnum["I"] = "#2BAE66";
4947
+ AlphabetColorsEnum["J"] = "#3C1053";
4948
+ AlphabetColorsEnum["K"] = "#DD4132";
4949
+ AlphabetColorsEnum["L"] = "#FC766A";
4950
+ AlphabetColorsEnum["M"] = "#ADEFD1";
4951
+ AlphabetColorsEnum["N"] = "#79C000";
4952
+ AlphabetColorsEnum["O"] = "#D198C5";
4953
+ AlphabetColorsEnum["P"] = "#5B84B1";
4954
+ AlphabetColorsEnum["Q"] = "#A13941";
4955
+ AlphabetColorsEnum["R"] = "#D85A7F";
4956
+ AlphabetColorsEnum["S"] = "#00203F";
4957
+ AlphabetColorsEnum["T"] = "#42EADD";
4958
+ AlphabetColorsEnum["U"] = "#5F4B8B";
4959
+ AlphabetColorsEnum["V"] = "#FDDB27";
4960
+ AlphabetColorsEnum["W"] = "#CDB599";
4961
+ AlphabetColorsEnum["X"] = "#4B878B";
4962
+ AlphabetColorsEnum["Y"] = "#B0B8B4";
4963
+ AlphabetColorsEnum["Z"] = "#E3C9CE";
4964
+ })(AlphabetColorsEnum || (AlphabetColorsEnum = {}));
4965
+
4248
4966
  /**
4249
4967
  * Class to generate data-table structure based on provided collection.
4250
4968
  * Use to work with HTML/PDF/XLSX tables
@@ -4278,9 +4996,11 @@ class DataTable {
4278
4996
  if (!column.total) {
4279
4997
  return '';
4280
4998
  }
4281
- return collection.items
4282
- .reduce((sum, item) => sum + Number(item[column.key]), 0)
4283
- .toString();
4999
+ const totalValue = collection.items.reduce((sum, item) => {
5000
+ // check if current collection item has value. If not - don't add it to the sum
5001
+ return item[column.key] !== null ? sum + Number(item[column.key]) : sum;
5002
+ }, null);
5003
+ return (totalValue !== null && totalValue !== void 0 ? totalValue : '-').toString();
4284
5004
  });
4285
5005
  }
4286
5006
  }
@@ -4391,231 +5111,65 @@ class Document extends Document$1 {
4391
5111
  super(...arguments);
4392
5112
  this.type = AssetTypeEnum.DOCUMENTS;
4393
5113
  this.entityType = AssetEntityTypeEnum.FOLDERS;
4394
- }
4395
- /**
4396
- * Get folder as document parent entity
4397
- */
4398
- getEntity() {
4399
- return this.folder;
4400
- }
4401
- /**
4402
- * Get API url prefix
4403
- */
4404
- getApiUrlPrefix() {
4405
- return DocumentApiUrlPrefixEnum.FOLDERS;
4406
- }
4407
- }
4408
-
4409
- const DOCUMENT_FILE_TYPES = {
4410
- image: [
4411
- 'image/png',
4412
- 'image/jpg',
4413
- 'image/jpeg',
4414
- 'image/tiff',
4415
- 'image/bmp'
4416
- ],
4417
- all: [
4418
- 'image/png',
4419
- 'image/jpg',
4420
- 'image/jpeg',
4421
- 'image/tiff',
4422
- 'image/bmp',
4423
- 'application/msword',
4424
- 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
4425
- 'application/pdf',
4426
- 'application/vnd.ms-excel',
4427
- 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
4428
- 'text/csv'
4429
- ]
4430
- };
4431
-
4432
- class DocumentFolder$1 {
4433
- }
4434
-
4435
- class DocumentFolder extends DocumentFolder$1 {
4436
- }
4437
- __decorate([
4438
- Type(() => Document)
4439
- ], DocumentFolder.prototype, "documents", void 0);
4440
-
4441
- class EmployeeInvite$1 {
4442
- }
4443
-
4444
- class EmployeeInvite extends EmployeeInvite$1 {
4445
- }
4446
- __decorate([
4447
- Type(() => RegistrationInvite)
4448
- ], EmployeeInvite.prototype, "registrationInvite", void 0);
4449
- __decorate([
4450
- Type(() => User)
4451
- ], EmployeeInvite.prototype, "employee", void 0);
4452
-
4453
- /**
4454
- * Backend endpoint class
4455
- */
4456
- class Endpoint {
4457
- constructor(method, pattern) {
4458
- this.method = method;
4459
- this.pattern = pattern;
4460
- }
4461
- /**
4462
- * check url with regexp
4463
- * @param url
4464
- */
4465
- test(url) {
4466
- return this.regexp.test(url);
4467
- }
4468
- /**
4469
- * Get regexp for endpoint
4470
- */
4471
- get regexp() {
4472
- return new RegExp(`^${this.method} \.\*${this.pattern}$`);
4473
- }
4474
- }
4475
-
4476
- /**
4477
- * List of all app endpoints
4478
- */
4479
- const ENDPOINTS = {
4480
- ASSETS_GET: new Endpoint('GET', '\\/assets\\/\.\*\\/\\d+'),
4481
- BANK_ACCOUNTS_GET: new Endpoint('GET', '\\/bank-accounts'),
4482
- BANK_ACCOUNTS_POST: new Endpoint('POST', '\\/bank-accounts'),
4483
- BANK_ACCOUNTS_PUT: new Endpoint('PUT', '\\/bank-accounts\\/\\d+'),
4484
- BANK_CONNECTION_POST: new Endpoint('POST', '\\/bank-connections'),
4485
- BANK_TRANSACTIONS_GET: new Endpoint('GET', '\\/bank-transactions'),
4486
- BANK_TRANSACTIONS_DELETE: new Endpoint('DELETE', '\\/bank-transactions\\/\\d+'),
4487
- BANK_TRANSACTIONS_IMPORT_POST: new Endpoint('POST', '\\/bank-transactions\\/\\d+\\/import'),
4488
- BASIQ_ACCOUNTS_GET: new Endpoint('GET', '\\/basiq\\/\\accounts'),
4489
- CAPITAL_COSTS_GET: new Endpoint('GET', '\\/capital-costs'),
4490
- CHARTS_INCOME_GET: new Endpoint('GET', '\\/charts\\/\\incomes'),
4491
- CHARTS_EXPENSES_GET: new Endpoint('GET', '\\/charts\\/\\expenses'),
4492
- CHART_ACCOUNTS_GET: new Endpoint('GET', '\\/chart-accounts'),
4493
- CLIENTS_GET: new Endpoint('GET', '\\/clients'),
4494
- CLIENTS_PUT: new Endpoint('PUT', '\\/clients'),
4495
- CLIENTS_EXCLUDE_PUT: new Endpoint('PUT', '\\/clients\\/\\d+\\/exclude'),
4496
- CLIENTS_INVITES_GET: new Endpoint('GET', '\\/clients\\/\\invites'),
4497
- CLIENTS_INVITES_POST: new Endpoint('POST', '\\/clients\\/\\invites'),
4498
- CLIENTS_INVITES_DELETE: new Endpoint('DELETE', '\\/clients\\/\\invites\\/\\d+'),
4499
- CLIENTS_INVITES_ACCEPT_POST: new Endpoint('POST', '\\/clients\\/\\invites\\/\\d+\\/accept'),
4500
- CLIENTS_INVITES_REJECT_POST: new Endpoint('POST', '\\/clients\\/\\invites\\/\\d+\\/reject'),
4501
- CLIENTS_INVITES_RESEND_POST: new Endpoint('POST', '\\/clients\\/\\invites\\/\\d+\\/resend'),
4502
- CLIENT_MOVEMENTS_GET: new Endpoint('GET', '\\/client-movements'),
4503
- CLIENT_MOVEMENTS_POST: new Endpoint('POST', '\\/client-movements'),
4504
- COUNTRIES_GET: new Endpoint('GET', '\\/countries'),
4505
- DEPRECIATIONS_CLOSING_GET: new Endpoint('GET', '\\/depreciations\\/\\closing-balance\.\*'),
4506
- DEPRECIATIONS_GET: new Endpoint('GET', '\\/depreciations'),
4507
- DEPRECIATIONS_POST: new Endpoint('POST', '\\/depreciations'),
4508
- DEPRECIATIONS_PUT: new Endpoint('PUT', '\\/depreciations\\/\\d+'),
4509
- EMPLOYEES_GET: new Endpoint('GET', '\\/employees'),
4510
- EMPLOYEES_INVITES_GET: new Endpoint('GET', '\\/employees\\/\\invites'),
4511
- EMPLOYEES_INVITES_DELETE: new Endpoint('DELETE', '\\/employees\\/\\invites\\/\\d+'),
4512
- EMPLOYEES_INVITE_POST: new Endpoint('POST', '\\/employees\\/\\invites'),
4513
- EMPLOYEES_INVITES_REJECT_POST: new Endpoint('POST', '\\/employees\\/\\invites\\/\\d+\\/\\reject'),
4514
- EMPLOYEES_INVITES_RESEND_POST: new Endpoint('POST', '\\/employees\\/\\invites\\/\\d+\\/\\resend'),
4515
- FIRM_GET: new Endpoint('GET', '\\/firms'),
4516
- FIRM_CURRENT_GET: new Endpoint('GET', '\\/firms\\/current'),
4517
- FIRM_CURRENT_PUT: new Endpoint('PUT', '\\/firms\\/current\.\*'),
4518
- FIRM_INVITE_POST: new Endpoint('POST', '\\/firms\\/invite'),
4519
- FIRM_REGISTRATION_POST: new Endpoint('POST', '\\/firms\\/registration'),
4520
- FIRM_UPDATE_PHOTO_POST: new Endpoint('POST', '\\/firms\\/photo\.\*'),
4521
- FOLDERS_GET: new Endpoint('GET', '\\/folders'),
4522
- FOLDERS_POST: new Endpoint('POST', '\\/folders'),
4523
- FOLDERS_PUT: new Endpoint('PUT', '\\/folders\\/\\d+'),
4524
- FOLDERS_DOCUMENTS_POST: new Endpoint('POST', '\\/folders\\/\\d+\\/documents'),
4525
- FOLDERS_DOCUMENTS_PUT: new Endpoint('PUT', '\\/folders\\/\\d+\\/documents\\/\\d+'),
4526
- INCOME_SOURCES_GET: new Endpoint('GET', '\\/income-sources'),
4527
- INCOME_SOURCES_POST: new Endpoint('POST', '\\/income-sources'),
4528
- INCOME_SOURCES_PUT: new Endpoint('PUT', '\\/income-sources'),
4529
- INCOME_SOURCES_DELETE: new Endpoint('DELETE', '\\/income-sources\\/\\d+'),
4530
- INCOME_SOURCE_FORECAST_GET: new Endpoint('GET', '\\/income-source-forecasts'),
4531
- INCOME_SOURCE_FORECAST_POST: new Endpoint('POST', '\\/income-source-forecasts'),
4532
- INCOME_SOURCE_FORECAST_PUT: new Endpoint('PUT', '\\/income-source-forecasts'),
4533
- INCOME_SOURCE_FORECAST_DELETE: new Endpoint('DELETE', '\\/income-source-forecasts\\/\\d+'),
4534
- INCOME_SOURCE_TYPES_GET: new Endpoint('GET', '\\/income-source-types'),
4535
- LOANS_GET: new Endpoint('GET', '\\/bank-accounts\\/loans'),
4536
- LOANS_POST: new Endpoint('POST', '\\/bank-accounts\\/loans'),
4537
- LOANS_PUT: new Endpoint('PUT', '\\/bank-accounts\\/loans/\\d+'),
4538
- LOANS_PAYOUT_POST: new Endpoint('POST', '\\/loans\\/\\d+\\/payout'),
4539
- LOANS_PAYOUT_PUT: new Endpoint('PUT', '\\/loans\\/\\d+\\/payout\\/\\d+'),
4540
- LOANS_PAYOUT_DELETE: new Endpoint('DELETE', '\\/loans\\/\\d+\\/payout\\/\\d+'),
4541
- LOANS_CALCULATION_POST: new Endpoint('POST', '\\/bank-accounts\\/loans\\/calculation'),
4542
- LOGIN_CHECK_POST: new Endpoint('POST', '\\/login_check'),
4543
- NOTIFICATIONS_GET: new Endpoint('GET', '\\/service-notifications'),
4544
- OCCUPATIONS_GET: new Endpoint('GET', '\\/occupations'),
4545
- PROPERTIES_GET: new Endpoint('GET', '\\/properties'),
4546
- PROPERTIES_POST: new Endpoint('POST', '\\/properties'),
4547
- PROPERTY_PUT: new Endpoint('PUT', '\\/properties/\\d+'),
4548
- PROPERTIES_PUT: new Endpoint('PUT', '\\/properties'),
4549
- PROPERTIES_CATEGORIES_EQUITY_GET: new Endpoint('GET', '\\/properties\\/categories\\/equity'),
4550
- PROPERTIES_CATEGORIES_GET: new Endpoint('GET', '\\/properties\\/categories'),
4551
- PROPERTIES_CATEGORIES_PUT: new Endpoint('PUT', '\\/properties\\/categories\\/\\d+'),
4552
- PROPERTIES_CATEGORIES_POST: new Endpoint('POST', '\\/properties\\/categories'),
4553
- PROPERTIES_CATEGORY_MOVEMENTS_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/category-movements'),
4554
- PROPERTIES_CATEGORY_MOVEMENTS_PUT: new Endpoint('PUT', '\\/properties\\/\\d+\\/category-movements\\/\\d+'),
4555
- PROPERTIES_CO_OWNERS_PUT: new Endpoint('PUT', '\\/properties\\/co-owners\\/\\d+'),
4556
- PROPERTIES_CO_OWNERS_GET: new Endpoint('GET', '\\/properties\\/co-owners'),
4557
- PROPERTIES_CO_OWNERS_POST: new Endpoint('POST', '\\/properties\\/co-owners'),
4558
- PROPERTIES_DEACTIVATE_PUT: new Endpoint('PUT', '\\/properties\\/\\d+\\/deactivate'),
4559
- PROPERTIES_DEPRECIATION_CAPITAL_PROJECT_GET: new Endpoint('GET', '\\/properties\\/\\d+\\/depreciation-capital-projects'),
4560
- PROPERTIES_DEPRECIATION_CAPITAL_PROJECT_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/depreciation-capital-projects'),
4561
- PROPERTIES_DEPRECIATION_CAPITAL_PROJECT_PUT: new Endpoint('PUT', '\\/properties\\/\\d+\\/depreciation-capital-projects\\/\\d+'),
4562
- PROPERTIES_DEPRECIATION_CAPITAL_PROJECT_DELETE: new Endpoint('DELETE', '\\/properties\\/\\d+\\/depreciation-capital-projects\\/\\d+'),
4563
- PROPERTIES_DOCUMENTS_GET: new Endpoint('GET', '\\/properties\\/documents'),
4564
- PROPERTIES_DOCUMENTS_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/documents'),
4565
- PROPERTIES_DOCUMENTS_PUT: new Endpoint('PUT', '\\/properties\\/documents\\/\\d+'),
4566
- PROPERTIES_DOCUMENTS_DELETE: new Endpoint('DELETE', '\\/properties\\/documents\\/\\d+'),
4567
- PROPERTIES_PHOTO_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/photo\.\*'),
4568
- PROPERTIES_SUGGESTIONS_GET: new Endpoint('GET', '/property\\/\\w+\\/v2\\/.*$'),
4569
- PROPERTIES_VALUATIONS_DOCUMENTS_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/valuations\\/\\d+\\/documents'),
4570
- PRORATION_COST_POST: new Endpoint('POST', '\\/subscriptions\\/proration-cost'),
4571
- SALARY_FORECAST_GET: new Endpoint('GET', '\\/salary-forecasts'),
4572
- SALARY_FORECAST_POST: new Endpoint('POST', '\\/salary-forecasts'),
4573
- SALARY_FORECAST_PUT: new Endpoint('PUT', '\\/salary-forecasts'),
4574
- SERVICE_PRICES_GET: new Endpoint('GET', '\\/service-prices'),
4575
- SERVICE_PAYMENTS_GET: new Endpoint('GET', '\\/service-payments'),
4576
- STRIPE_BILLING_PORTAL_GET: new Endpoint('GET', '\\/stripe\\/billing-portal-session'),
4577
- STRIPE_CHECKOUT_SESSION_POST: new Endpoint('POST', '\\/stripe\\/checkout-session'),
4578
- SUBSCRIPTION_LAST_GET: new Endpoint('GET', '\\/subscriptions\\/last'),
4579
- SUBSCRIPTION_ITEMS_PUT: new Endpoint('PUT', '\\/subscriptions\\/items'),
4580
- TAX_CALCULATION_POST: new Endpoint('POST', '\\/tax-calculation'),
4581
- TAX_REVIEWS_GET: new Endpoint('GET', '\\/tax-reviews'),
4582
- TAX_REVIEWS_DELETE: new Endpoint('DELETE', '\\/tax-reviews\\/\\d+'),
4583
- TAX_REVIEWS_POST: new Endpoint('POST', '\\/tax-reviews'),
4584
- TAX_REVIEWS_PUT: new Endpoint('PUT', '\\/tax-reviews\\/\\d+'),
4585
- TAX_SUMMARY_ACTUAL_GET: new Endpoint('GET', '\\/tax-summary\\/actuals'),
4586
- TAX_SUMMARY_FORECAST_GET: new Endpoint('GET', '\\/tax-summary\\/forecasts'),
4587
- TRANSACTION_DELETE: new Endpoint('DELETE', '\\/transactions\\/\\d+'),
4588
- TRANSACTION_PUT: new Endpoint('PUT', '\\/transactions\\/\\d+'),
4589
- TRANSACTIONS_GET: new Endpoint('GET', '\\/transactions'),
4590
- TRANSACTIONS_POST: new Endpoint('POST', '\\/transactions'),
4591
- TRANSACTIONS_PUT: new Endpoint('PUT', '\\/transactions'),
4592
- TRANSACTIONS_ALLOCATIONS_GET: new Endpoint('GET', '\\/transactions-allocations'),
4593
- TRANSACTIONS_ALLOCATIONS_POST: new Endpoint('POST', '\\/transactions-allocations'),
4594
- TRANSACTIONS_ALLOCATIONS_DELETE: new Endpoint('DELETE', '\\/transactions-allocations\\/\\d+'),
4595
- USER_CONFIRMATION_POST: new Endpoint('POST', '\\/users\\/confirmation'),
4596
- USER_CURRENT_GET: new Endpoint('GET', '\\/users\\/current'),
4597
- USER_CURRENT_PASSWORD_PUT: new Endpoint('PUT', '\\/users\\/current\\/password\.\*'),
4598
- USER_EVENT_SETTINGS_GET: new Endpoint('GET', '\\/user-event-settings'),
4599
- USER_EVENT_TYPES_GET: new Endpoint('GET', '\\/user-event-types'),
4600
- USER_INVITE_DELETE: new Endpoint('DELETE', '\\/users\\/invite\\/\\d+'),
4601
- USER_INVITE_POST: new Endpoint('POST', '\\/users\\/invite'),
4602
- USER_INVITE_RESEND_POST: new Endpoint('POST', '\\/users\\/invite/\\d+\\/resend'),
4603
- USER_PUT: new Endpoint('PUT', '\\/users\\/\\d+'),
4604
- USER_REGISTRATION_POST: new Endpoint('POST', '\\/users\\/registration'),
4605
- USER_RESET_PASSWORD_PUT: new Endpoint('PUT', '\\/users\\/reset-password'),
4606
- USER_SEARCH_GET: new Endpoint('GET', '\\/users\\/search\.\*'),
4607
- USER_UPDATE_PHOTO_POST: new Endpoint('POST', '\\/users\\/photo\.\*'),
4608
- USER_STATUS_PUT: new Endpoint('PUT', '\\/users\\/status'),
4609
- VEHICLES_GET: new Endpoint('GET', '\\/vehicles'),
4610
- VEHICLES_POST: new Endpoint('POST', '\\/vehicles'),
4611
- VEHICLES_PUT: new Endpoint('PUT', '\\/vehicles\\/\\d+'),
4612
- VEHICLE_CLAIMS_GET: new Endpoint('GET', '\\/vehicle-claims'),
4613
- VEHICLE_CLAIMS_POST: new Endpoint('POST', '\\/vehicle-claims'),
4614
- VEHICLE_LOGBOOK_POST: new Endpoint('POST', '\\/vehicles\\/\\d+\\/logbooks'),
4615
- VEHICLE_LOGBOOK_PUT: new Endpoint('PUT', '\\/vehicles\\/\\d+\\/logbooks\\/\\d+'),
4616
- VEHICLE_CLAIMS_PUT: new Endpoint('PUT', '\\/vehicle-claims\\/\\d+')
5114
+ }
5115
+ /**
5116
+ * Get folder as document parent entity
5117
+ */
5118
+ getEntity() {
5119
+ return this.folder;
5120
+ }
5121
+ /**
5122
+ * Get API url prefix
5123
+ */
5124
+ getApiUrlPrefix() {
5125
+ return DocumentApiUrlPrefixEnum.FOLDERS;
5126
+ }
5127
+ }
5128
+
5129
+ const DOCUMENT_FILE_TYPES = {
5130
+ image: [
5131
+ 'image/png',
5132
+ 'image/jpg',
5133
+ 'image/jpeg',
5134
+ 'image/tiff',
5135
+ 'image/bmp'
5136
+ ],
5137
+ all: [
5138
+ 'image/png',
5139
+ 'image/jpg',
5140
+ 'image/jpeg',
5141
+ 'image/tiff',
5142
+ 'image/bmp',
5143
+ 'application/msword',
5144
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
5145
+ 'application/pdf',
5146
+ 'application/vnd.ms-excel',
5147
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
5148
+ 'text/csv'
5149
+ ]
4617
5150
  };
4618
5151
 
5152
+ class DocumentFolder$1 {
5153
+ }
5154
+
5155
+ class DocumentFolder extends DocumentFolder$1 {
5156
+ }
5157
+ __decorate([
5158
+ Type(() => Document)
5159
+ ], DocumentFolder.prototype, "documents", void 0);
5160
+
5161
+ class EmployeeInvite$1 {
5162
+ }
5163
+
5164
+ class EmployeeInvite extends EmployeeInvite$1 {
5165
+ }
5166
+ __decorate([
5167
+ Type(() => RegistrationInvite)
5168
+ ], EmployeeInvite.prototype, "registrationInvite", void 0);
5169
+ __decorate([
5170
+ Type(() => User)
5171
+ ], EmployeeInvite.prototype, "employee", void 0);
5172
+
4619
5173
  /**
4620
5174
  * any event happened in the app, which needs to be handled somehow (distributed to other part of the app)
4621
5175
  */
@@ -4829,6 +5383,12 @@ class VehicleClaim extends VehicleClaim$1 {
4829
5383
  get isLogbookMethod() {
4830
5384
  return this.method === VehicleClaimMethodEnum.LOGBOOK;
4831
5385
  }
5386
+ /**
5387
+ * Claim amount for Kms method
5388
+ */
5389
+ getKmsClaimAmount(vehicleClaimRate) {
5390
+ return +(this.kilometers * vehicleClaimRate).toFixed(2);
5391
+ }
4832
5392
  }
4833
5393
 
4834
5394
  class ServiceNotification {
@@ -4945,13 +5505,6 @@ const CAPITAL_COSTS_ITEMS = [
4945
5505
  }),
4946
5506
  ];
4947
5507
 
4948
- /**
4949
- * https://api-uat.corelogic.asia/property/au/v2/suggest.json
4950
- * address suggestion from corelogic service
4951
- */
4952
- class CorelogicSuggestion {
4953
- }
4954
-
4955
5508
  /**
4956
5509
  * Enum with properties ownership filter options
4957
5510
  */
@@ -5563,41 +6116,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
5563
6116
  args: ['environment']
5564
6117
  }] }]; } });
5565
6118
 
5566
- const KEY = '_switch_user';
5567
- /**
5568
- * provides user management to managers (users with ROLE_ACCOUNTANT for now, more in future)
5569
- */
5570
- class UserSwitcherService {
5571
- /**
5572
- * get switched username
5573
- */
5574
- get() {
5575
- return localStorage[KEY];
5576
- }
5577
- /**
5578
- * switch to user (username should be used for correct work of backend)
5579
- */
5580
- set(username) {
5581
- localStorage[KEY] = username;
5582
- window.location.replace('/client/dashboard');
5583
- }
5584
- /**
5585
- * go back to original user
5586
- */
5587
- reset() {
5588
- localStorage.removeItem(KEY);
5589
- window.location.replace('/firm/dashboard');
5590
- }
5591
- }
5592
- UserSwitcherService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: UserSwitcherService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
5593
- UserSwitcherService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: UserSwitcherService, providedIn: 'root' });
5594
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: UserSwitcherService, decorators: [{
5595
- type: Injectable,
5596
- args: [{
5597
- providedIn: 'root'
5598
- }]
5599
- }] });
5600
-
5601
6119
  /**
5602
6120
  * Service to work with assets (documents, receipts, e.t.c.)
5603
6121
  */
@@ -5645,79 +6163,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
5645
6163
  args: ['environment']
5646
6164
  }] }]; } });
5647
6165
 
5648
- const NAME_TOKEN = 'token';
5649
- const NAME_REFRESH_TOKEN = 'refreshToken';
5650
- class JwtService extends JwtHelperService {
5651
- getToken() {
5652
- return localStorage[NAME_TOKEN];
5653
- }
5654
- getRefreshToken() {
5655
- return localStorage[NAME_REFRESH_TOKEN];
5656
- }
5657
- saveTokens(tokens) {
5658
- localStorage[NAME_TOKEN] = tokens.token;
5659
- localStorage[NAME_REFRESH_TOKEN] = tokens.refreshToken;
5660
- }
5661
- destroyTokens() {
5662
- localStorage.removeItem(NAME_TOKEN);
5663
- localStorage.removeItem(NAME_REFRESH_TOKEN);
5664
- }
5665
- getUser() {
5666
- return this.decodeToken();
5667
- }
5668
- isMe(userId) {
5669
- return this.getUser().id === userId;
5670
- }
5671
- }
5672
- JwtService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: JwtService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
5673
- JwtService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: JwtService, providedIn: 'root' });
5674
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: JwtService, decorators: [{
5675
- type: Injectable,
5676
- args: [{
5677
- providedIn: 'root'
5678
- }]
5679
- }] });
5680
-
5681
- class AuthService {
5682
- constructor(http, jwtService, environment) {
5683
- this.http = http;
5684
- this.jwtService = jwtService;
5685
- this.environment = environment;
5686
- this.isLoggedInSubject = new BehaviorSubject(!this.jwtService.isTokenExpired());
5687
- }
5688
- setAuth(response) {
5689
- this.jwtService.saveTokens(response);
5690
- this.isLoggedInSubject.next(true);
5691
- }
5692
- login(username, password) {
5693
- return this.http.post(`${this.environment.apiV2}/login_check`, { username, password }).pipe(map((response) => {
5694
- this.setAuth(response);
5695
- return response;
5696
- }));
5697
- }
5698
- refresh(refreshToken) {
5699
- return this.http.post(`${this.environment.apiV2}/token/refresh`, { refreshToken }).pipe(map((response) => {
5700
- this.setAuth(response);
5701
- return response;
5702
- }));
5703
- }
5704
- logoutFront(url = '/login') {
5705
- localStorage.clear();
5706
- location.replace(url);
5707
- }
5708
- }
5709
- AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AuthService, deps: [{ token: i1.HttpClient }, { token: JwtService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
5710
- AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AuthService, providedIn: 'root' });
5711
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: AuthService, decorators: [{
5712
- type: Injectable,
5713
- args: [{
5714
- providedIn: 'root'
5715
- }]
5716
- }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: JwtService }, { type: undefined, decorators: [{
5717
- type: Inject,
5718
- args: ['environment']
5719
- }] }]; } });
5720
-
5721
6166
  // replace array element with the new one (only arrays of objects)
5722
6167
  function replace(array, item, matchField = 'id') {
5723
6168
  const index = array.findIndex((i) => i[matchField] === item[matchField]);
@@ -6059,6 +6504,12 @@ class BankAccountService extends BaseRestService {
6059
6504
  return updatedBankAccount;
6060
6505
  }));
6061
6506
  }
6507
+ getOwn() {
6508
+ return this.get()
6509
+ .pipe(map((bankAccounts) => {
6510
+ return bankAccounts.filter((bankAccount) => bankAccount.isOwner(+localStorage.getItem('userId')));
6511
+ }));
6512
+ }
6062
6513
  /**
6063
6514
  * Listen to EventDispatcherService events
6064
6515
  */
@@ -7979,14 +8430,47 @@ class PdfService {
7979
8430
  document.save(`${fileName}.pdf`);
7980
8431
  }
7981
8432
  /**
8433
+ * @Todo rename when all DataTable dependent methods will be cleared-up
8434
+ */
8435
+ exportTables(tables, title, fileName) {
8436
+ const document = this.generateFromTables(tables, title);
8437
+ document.save(`${fileName}.pdf`);
8438
+ }
8439
+ /**
8440
+ * @Todo rename when all DataTable dependent methods will be cleared-up
8441
+ */
8442
+ generateFromTables(tables, title) {
8443
+ const pdf = new jsPDF();
8444
+ // set document title
8445
+ pdf.setFontSize(PDF_CONFIG.text.fontSize)
8446
+ .setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight)
8447
+ .text(title, PDF_CONFIG.text.positionX, PDF_CONFIG.text.positionY);
8448
+ tables.forEach((table) => {
8449
+ // coords of last table
8450
+ const lastTableCoords = pdf['lastAutoTable'].finalY || PDF_CONFIG.contentCoords.marginTop;
8451
+ // table options
8452
+ const options = {
8453
+ html: table,
8454
+ startY: lastTableCoords + PDF_CONFIG.contentTitleCoords.marginTop,
8455
+ footStyles: {
8456
+ fillColor: PDF_CONFIG.text.fillColor,
8457
+ textColor: PDF_CONFIG.text.textColor
8458
+ }
8459
+ };
8460
+ autoTable(pdf, options);
8461
+ });
8462
+ return pdf;
8463
+ }
8464
+ /**
8465
+ * @Todo remove/refactor when all DataTable dependent methods will be cleared-up
7982
8466
  * Generate PDF file from provided data
7983
8467
  */
7984
8468
  generatePdfFile(tables, title) {
7985
8469
  const pdf = new jsPDF();
7986
- // set document title
7987
- pdf.setFontSize(PDF_CONFIG.text.fontSize);
7988
- pdf.setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight);
7989
- pdf.text(title, PDF_CONFIG.text.positionX, PDF_CONFIG.text.positionY);
8470
+ // set document font params
8471
+ pdf.setFontSize(PDF_CONFIG.text.fontSize)
8472
+ .setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight)
8473
+ .text(title, PDF_CONFIG.text.positionX, PDF_CONFIG.text.positionY);
7990
8474
  tables.forEach((table) => {
7991
8475
  // coords of last table
7992
8476
  const lastTableCoords = pdf['lastAutoTable'].finalY || PDF_CONFIG.contentCoords.marginTop;
@@ -8016,63 +8500,35 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
8016
8500
  }]
8017
8501
  }] });
8018
8502
 
8019
- class PreloaderService {
8020
- constructor() {
8021
- this.activePreloaders = new BehaviorSubject([]);
8022
- }
8023
- get() {
8024
- return this.activePreloaders.asObservable();
8025
- }
8026
- add(endpoint) {
8027
- const activePreloaders = this.activePreloaders.getValue();
8028
- activePreloaders.push(endpoint);
8029
- this.activePreloaders.next(activePreloaders);
8030
- }
8031
- delete(endpoint) {
8032
- let activePreloaders = this.activePreloaders.getValue();
8033
- activePreloaders = activePreloaders.filter((preloader) => preloader !== endpoint);
8034
- this.activePreloaders.next(activePreloaders);
8035
- }
8036
- }
8037
- PreloaderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreloaderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
8038
- PreloaderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreloaderService, providedIn: 'root' });
8039
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreloaderService, decorators: [{
8040
- type: Injectable,
8041
- args: [{
8042
- providedIn: 'root'
8043
- }]
8044
- }], ctorParameters: function () { return []; } });
8045
-
8046
- class CorelogicService {
8503
+ /**
8504
+ * Service for get property equity position half-year history chart data
8505
+ */
8506
+ class EquityPositionChartService {
8047
8507
  constructor(http, environment) {
8048
8508
  this.http = http;
8049
8509
  this.environment = environment;
8050
- this.accessTokenSubject = new ReplaySubject(1);
8051
- }
8052
- getAccessToken(force = false) {
8053
- if (!this._accessToken || force) {
8054
- this.http.get(`${this.environment.coreLogicUrl}/access/oauth/token?grant_type=client_credentials&client_id=${this.environment.coreLogicId}&client_secret=${this.environment.coreLogicSecret}`)
8055
- .pipe(map((response) => {
8056
- return response.access_token;
8057
- }))
8058
- .subscribe((token) => {
8059
- this._accessToken = token;
8060
- this.accessTokenSubject.next(this._accessToken);
8061
- });
8062
- }
8063
- return this.accessTokenSubject.asObservable();
8064
8510
  }
8065
- getSuggestions(query, country = 'au') {
8066
- // @TODO handle different countries in future
8067
- return this.http.get(`${this.environment.coreLogicUrl}/property/${country}/v2/suggest.json?q=${query}`)
8511
+ get() {
8512
+ // @TODO refactor backend
8513
+ return this.http.get(`${this.environment.apiV2}/properties/categories/equity`)
8068
8514
  .pipe(map((response) => {
8069
- return response.suggestions.map((item) => plainToClass(CorelogicSuggestion, item));
8515
+ return response.map((item) => {
8516
+ return plainToClass(ChartData, {
8517
+ name: item.category.name,
8518
+ data: item.equity.map((serie) => {
8519
+ return plainToClass(ChartSerie, {
8520
+ label: serie.date,
8521
+ value: serie.amount
8522
+ });
8523
+ })
8524
+ });
8525
+ });
8070
8526
  }));
8071
8527
  }
8072
8528
  }
8073
- CorelogicService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: CorelogicService, deps: [{ token: i1.HttpClient }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
8074
- CorelogicService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: CorelogicService, providedIn: 'root' });
8075
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: CorelogicService, decorators: [{
8529
+ EquityPositionChartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: EquityPositionChartService, deps: [{ token: i1.HttpClient }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
8530
+ EquityPositionChartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: EquityPositionChartService, providedIn: 'root' });
8531
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: EquityPositionChartService, decorators: [{
8076
8532
  type: Injectable,
8077
8533
  args: [{
8078
8534
  providedIn: 'root'
@@ -9859,5 +10315,5 @@ function taxReviewFilterPredicate(data, filter) {
9859
10315
  * Generated bundle index. Do not edit.
9860
10316
  */
9861
10317
 
9862
- export { AbstractCollection, Address, AddressService, AddressTypeEnum, AppEvent, AppEventTypeEnum, AssetEntityTypeEnum, AssetTypeEnum, AssetsService, AuthService, BANK_ACCOUNT_TYPES, Bank, BankAccount, BankAccountCalculationService, BankAccountChartData, BankAccountCollection, BankAccountProperty, BankAccountService, BankAccountStatusEnum, BankAccountTypeEnum, BankConnection, BankConnectionService, BankConnectionStatusEnum, BankService, BankTransaction, BankTransactionCalculationService, BankTransactionChartData, BankTransactionCollection, BankTransactionService, BankTransactionSummaryFieldsEnum, BankTransactionTypeEnum, BasiqJob, BasiqService, BasiqToken, BorrowingExpense, BorrowingExpenseLoan, BorrowingExpenseService, CAPITAL_COSTS_ITEMS, CHART_ACCOUNTS_CATEGORIES, CalculationFormItem, CalculationFormTypeEnum, CapitalProjectService, ChartAccounts, ChartAccountsCategoryEnum, ChartAccountsDepreciation, ChartAccountsDepreciationService, ChartAccountsEtpEnum, ChartAccountsHeading, ChartAccountsHeadingTaxDeductibleEnum, ChartAccountsHeadingTaxableEnum, ChartAccountsHeadingVehicleListEnum, ChartAccountsListEnum, ChartAccountsMetadata, ChartAccountsMetadataListEnum, ChartAccountsMetadataTypeEnum, ChartAccountsService, ChartAccountsTaxLabelsEnum, ChartAccountsTypeEnum, ChartData, ChartSerie, Chat, ChatService, ChatStatusEnum, ChatViewTypeEnum, ClientCollection, ClientDetails, ClientDetailsMedicareExemptionEnum, ClientDetailsWorkDepreciationCalculationEnum, ClientDetailsWorkingHolidayMakerEnum, ClientInvite, ClientInviteService, ClientInviteStatusEnum, ClientInviteTypeEnum, ClientMovement, ClientMovementCollection, ClientMovementService, ClientPortfolioChartData, ClientPortfolioReport, ClientPortfolioReportCollection, ClientPortfolioReportService, CollectionDictionary, CorelogicService, CorelogicSuggestion, Country, DEFAULT_VEHICLE_EXPENSE, DEPRECIATION_GROUPS, DOCUMENT_FILE_TYPES, DataTable, DataTableColumn, Depreciation, DepreciationCalculationEnum, DepreciationCalculationPercentEnum, DepreciationCapitalProject, DepreciationCollection, DepreciationForecast, DepreciationForecastCollection, DepreciationGroup, DepreciationGroupEnum, DepreciationGroupItem, DepreciationReceipt, DepreciationService, DepreciationTypeEnum, DepreciationWriteOffAmountEnum, Document, DocumentApiUrlPrefixEnum, DocumentFolder, DocumentFolderService, ENDPOINTS, EmployeeCollection, EmployeeDetails, EmployeeInvite, EmployeeInviteService, EmployeeService, Endpoint, EventDispatcherService, FinancialYear, Firm, FirmService, FirmTypeEnum, HeaderTitleService, IconsFileEnum, IncomeAmountTypeEnum, IncomePosition, IncomeSource, IncomeSourceChartData, IncomeSourceCollection, IncomeSourceForecast, IncomeSourceForecastService, IncomeSourceService, IncomeSourceType, IncomeSourceTypeEnum, IncomeSourceTypeListOtherEnum, IncomeSourceTypeListSalaryEnum, IncomeSourceTypeListWorkEnum, IntercomService, InviteStatusEnum, JwtService, Loan, LoanBankTypeEnum, LoanCollection, LoanFrequencyEnum, LoanInterestTypeEnum, LoanMaxNumberOfPaymentsEnum, LoanPayment, LoanPayout, LoanPayoutTypeEnum, LoanRepaymentFrequencyEnum, LoanRepaymentTypeEnum, LoanService, LoanTypeEnum, LoanVehicleTypeEnum, LogbookCollection, LogbookPeriod, MODULE_URL_LIST, MONTHS, Message, MessageCollection, MessageDocument, MessageDocumentCollection, MessageDocumentService, MessageService, MonthNameShortEnum, MonthNumberEnum, MyAccountHistory, MyAccountHistoryInitiatedByEnum, MyAccountHistoryStatusEnum, MyAccountHistoryTypeEnum, Notification, NotificationService, Occupation, OccupationService, OwnershipFilterOptionsEnum, PdfService, Phone, PhoneTypeEnum, PreloaderService, Property, PropertyCalculationService, PropertyCapitalCost, PropertyCapitalCostService, PropertyCategory, PropertyCategoryMovement, PropertyCategoryService, PropertyCollection, PropertyDepreciationCalculationEnum, PropertyDocument, PropertyDocumentService, PropertyEquityChartData, PropertyEquityChartItem, PropertyForecast, PropertyOwner, PropertyOwnerAccessEnum, PropertyOwnerService, PropertyOwnerStatusEnum, PropertyService, PropertySold, PropertySoldService, PropertySubscription, PropertyValuation, RegistrationInvite, RegistrationInviteStatusEnum, SUBSCRIPTION_DESCRIPTION, SUBSCRIPTION_TITLE, SalaryForecast, SalaryForecastFrequencyEnum, SalaryForecastService, ServiceNotificationStatusEnum, ServiceNotificationTypeEnum, ServicePayment, ServicePaymentStatusEnum, ServicePrice, ServicePriceCollection, ServicePriceRecurringIntervalEnum, ServicePriceTypeEnum, ServiceProduct, ServiceSubscription, ServiceSubscriptionCollection, ServiceSubscriptionItem, ServiceSubscriptionStatusEnum, SpareDocumentSpareTypeEnum, SseService, SubscriptionService, SubscriptionTypeEnum, TYPE_LOAN, TankTypeEnum, TaxCalculationMedicareExemptionEnum, TaxCalculationTypeEnum, TaxReturnCategoryItem, TaxReturnCategoryItemCollection, TaxReturnCategoryItemDetails, TaxReturnCategoryListEnum, TaxReturnCategorySectionEnum, TaxReview, TaxReviewCollection, TaxReviewHistoryService, TaxReviewService, TaxReviewStatusEnum, TaxSummary, TaxSummaryListEnum, TaxSummarySection, TaxSummarySectionEnum, TaxSummaryService, TaxSummaryTaxSummaryEnum, TaxSummaryTypeEnum, TicketFeedbackEnum, TicketStatusEnum, TicketTypesEnum, Transaction, TransactionAllocation, TransactionAllocationCollection, TransactionAllocationService, TransactionBase, TransactionCalculationService, TransactionCollection, TransactionMetadata, TransactionOperationEnum, TransactionReceipt, TransactionService, TransactionSourceEnum, TransactionTypeEnum, TtCoreModule, USER_ROLES, USER_WORK_POSITION, User, UserEventSetting, UserEventSettingCollection, UserEventSettingFieldEnum, UserEventSettingService, UserEventStatusEnum, UserEventType, UserEventTypeCategory, UserEventTypeClientTypeEnum, UserEventTypeEmployeeTypeEnum, UserEventTypeFrequencyEnum, UserEventTypeService, UserEventTypeUserTypeEnum, UserMedicareExemptionEnum, UserRolesEnum, UserService, UserStatusEnum, UserSwitcherService, UserTitleEnum, UserToRegister, UserWorkDepreciationCalculationEnum, UserWorkingHolidayMakerEnum, Vehicle, VehicleClaim, VehicleClaimMethodEnum, VehicleLogbook, VehicleLogbookPurposeEnum, WORK_TANK_LOGBOOK_PURPOSE_OPTIONS, WorkTankService, XlsxService, cloneDeep, compare, compareMatOptions, createDate, displayMatOptions, enumToList, getDocIcon, replace, roundTo, sort, sortDeep, taxReviewFilterPredicate };
10318
+ export { Address, AddressService, AddressTypeEnum, AlphabetColorsEnum, AppEvent, AppEventTypeEnum, AssetEntityTypeEnum, AssetTypeEnum, AssetsService, AuthService, BANK_ACCOUNT_TYPES, Bank, BankAccount, BankAccountCalculationService, BankAccountChartData, BankAccountCollection, BankAccountProperty, BankAccountService, BankAccountStatusEnum, BankAccountTypeEnum, BankConnection, BankConnectionService, BankConnectionStatusEnum, BankService, BankTransaction, BankTransactionCalculationService, BankTransactionChartData, BankTransactionCollection, BankTransactionService, BankTransactionSummaryFieldsEnum, BankTransactionTypeEnum, BasiqJob, BasiqService, BasiqToken, BorrowingExpense, BorrowingExpenseLoan, BorrowingExpenseService, CAPITAL_COSTS_ITEMS, CHART_ACCOUNTS_CATEGORIES, CalculationFormItem, CalculationFormTypeEnum, CapitalProjectService, ChartAccounts, ChartAccountsCategoryEnum, ChartAccountsDepreciation, ChartAccountsDepreciationService, ChartAccountsEtpEnum, ChartAccountsHeading, ChartAccountsHeadingTaxDeductibleEnum, ChartAccountsHeadingTaxableEnum, ChartAccountsHeadingVehicleListEnum, ChartAccountsListEnum, ChartAccountsMetadata, ChartAccountsMetadataListEnum, ChartAccountsMetadataTypeEnum, ChartAccountsService, ChartAccountsTaxLabelsEnum, ChartAccountsTypeEnum, ChartData, ChartSerie, Chat, ChatService, ChatStatusEnum, ChatViewTypeEnum, ClientCollection, ClientDetails, ClientDetailsMedicareExemptionEnum, ClientDetailsWorkDepreciationCalculationEnum, ClientDetailsWorkingHolidayMakerEnum, ClientInvite, ClientInviteService, ClientInviteStatusEnum, ClientInviteTypeEnum, ClientMovement, ClientMovementCollection, ClientMovementService, ClientPortfolioChartData, ClientPortfolioReport, ClientPortfolioReportCollection, ClientPortfolioReportService, Collection, CollectionDictionary, CorelogicService, CorelogicSuggestion, Country, DEFAULT_VEHICLE_EXPENSE, DEPRECIATION_GROUPS, DOCUMENT_FILE_TYPES, DataTable, DataTableColumn, Depreciation, DepreciationCalculationEnum, DepreciationCalculationPercentEnum, DepreciationCapitalProject, DepreciationCollection, DepreciationForecast, DepreciationForecastCollection, DepreciationGroup, DepreciationGroupEnum, DepreciationGroupItem, DepreciationReceipt, DepreciationService, DepreciationTypeEnum, DepreciationWriteOffAmountEnum, Document, DocumentApiUrlPrefixEnum, DocumentFolder, DocumentFolderService, ENDPOINTS, EmployeeCollection, EmployeeDetails, EmployeeInvite, EmployeeInviteService, EmployeeService, Endpoint, EquityPositionChartService, EventDispatcherService, FinancialYear, Firm, FirmService, FirmTypeEnum, HeaderTitleService, IconsFileEnum, IncomeAmountTypeEnum, IncomePosition, IncomeSource, IncomeSourceChartData, IncomeSourceCollection, IncomeSourceForecast, IncomeSourceForecastService, IncomeSourceService, IncomeSourceType, IncomeSourceTypeEnum, IncomeSourceTypeListOtherEnum, IncomeSourceTypeListSalaryEnum, IncomeSourceTypeListWorkEnum, InterceptorsModule, IntercomService, InviteStatusEnum, JwtService, Loan, LoanBankTypeEnum, LoanCollection, LoanFrequencyEnum, LoanInterestTypeEnum, LoanMaxNumberOfPaymentsEnum, LoanPayment, LoanPayout, LoanPayoutTypeEnum, LoanRepaymentFrequencyEnum, LoanRepaymentTypeEnum, LoanService, LoanTypeEnum, LoanVehicleTypeEnum, LogbookCollection, LogbookPeriod, MODULE_URL_LIST, MONTHS, Message, MessageCollection, MessageDocument, MessageDocumentCollection, MessageDocumentService, MessageService, MonthNameShortEnum, MonthNumberEnum, MyAccountHistory, MyAccountHistoryInitiatedByEnum, MyAccountHistoryStatusEnum, MyAccountHistoryTypeEnum, Notification, NotificationService, Occupation, OccupationService, OwnershipFilterOptionsEnum, PdfService, Phone, PhoneTypeEnum, PreloaderService, Property, PropertyCalculationService, PropertyCapitalCost, PropertyCapitalCostService, PropertyCategory, PropertyCategoryMovement, PropertyCategoryService, PropertyCollection, PropertyDepreciationCalculationEnum, PropertyDocument, PropertyDocumentService, PropertyEquityChartData, PropertyEquityChartItem, PropertyForecast, PropertyOwner, PropertyOwnerAccessEnum, PropertyOwnerService, PropertyOwnerStatusEnum, PropertyService, PropertySold, PropertySoldService, PropertySubscription, PropertyValuation, RegistrationInvite, RegistrationInviteStatusEnum, SUBSCRIPTION_DESCRIPTION, SUBSCRIPTION_TITLE, SalaryForecast, SalaryForecastFrequencyEnum, SalaryForecastService, ServiceNotificationStatusEnum, ServiceNotificationTypeEnum, ServicePayment, ServicePaymentStatusEnum, ServicePrice, ServicePriceCollection, ServicePriceRecurringIntervalEnum, ServicePriceTypeEnum, ServiceProduct, ServiceSubscription, ServiceSubscriptionCollection, ServiceSubscriptionItem, ServiceSubscriptionStatusEnum, SpareDocumentSpareTypeEnum, SseService, SubscriptionService, SubscriptionTypeEnum, TYPE_LOAN, TankTypeEnum, TaxCalculationMedicareExemptionEnum, TaxCalculationTypeEnum, TaxReturnCategoryItem, TaxReturnCategoryItemCollection, TaxReturnCategoryItemDetails, TaxReturnCategoryListEnum, TaxReturnCategorySectionEnum, TaxReview, TaxReviewCollection, TaxReviewHistoryService, TaxReviewService, TaxReviewStatusEnum, TaxSummary, TaxSummaryListEnum, TaxSummarySection, TaxSummarySectionEnum, TaxSummaryService, TaxSummaryTaxSummaryEnum, TaxSummaryTypeEnum, TicketFeedbackEnum, TicketStatusEnum, TicketTypesEnum, Transaction, TransactionAllocation, TransactionAllocationCollection, TransactionAllocationService, TransactionBase, TransactionCalculationService, TransactionCollection, TransactionMetadata, TransactionOperationEnum, TransactionReceipt, TransactionService, TransactionSourceEnum, TransactionTypeEnum, TtCoreModule, USER_ROLES, USER_WORK_POSITION, User, UserEventSetting, UserEventSettingCollection, UserEventSettingFieldEnum, UserEventSettingService, UserEventStatusEnum, UserEventType, UserEventTypeCategory, UserEventTypeClientTypeEnum, UserEventTypeEmployeeTypeEnum, UserEventTypeFrequencyEnum, UserEventTypeService, UserEventTypeUserTypeEnum, UserMedicareExemptionEnum, UserRolesEnum, UserService, UserStatusEnum, UserSwitcherService, UserTitleEnum, UserToRegister, UserWorkDepreciationCalculationEnum, UserWorkingHolidayMakerEnum, Vehicle, VehicleClaim, VehicleClaimMethodEnum, VehicleLogbook, VehicleLogbookPurposeEnum, WORK_TANK_LOGBOOK_PURPOSE_OPTIONS, WorkTankService, XlsxService, cloneDeep, compare, compareMatOptions, createDate, displayMatOptions, enumToList, getDocIcon, replace, roundTo, sort, sortDeep, taxReviewFilterPredicate };
9863
10319
  //# sourceMappingURL=taxtank-core.js.map