taxtank-core 0.2.2 → 0.3.1

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 -484
  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 -3
  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 -5
  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 -442
  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 -2
  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 -3
  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,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('lodash/has'), require('lodash/get'), require('lodash/flatten'), require('lodash/first'), require('lodash/last'), require('lodash/uniqBy'), require('lodash/concat'), require('lodash/compact'), require('class-transformer'), require('moment'), require('moment-range'), require('lodash/cloneDeep'), require('@angular/forms'), require('rxjs'), require('rxjs/operators'), require('@angular/common/http'), require('@auth0/angular-jwt'), require('lodash'), require('event-source-polyfill/src/eventsource.min.js'), require('@angular/router'), require('lodash/clone'), require('jspdf'), require('jspdf-autotable'), require('@stripe/stripe-js'), require('xlsx'), require('file-saver')) :
3
- typeof define === 'function' && define.amd ? define('taxtank-core', ['exports', '@angular/core', '@angular/common', 'lodash/has', 'lodash/get', 'lodash/flatten', 'lodash/first', 'lodash/last', 'lodash/uniqBy', 'lodash/concat', 'lodash/compact', 'class-transformer', 'moment', 'moment-range', 'lodash/cloneDeep', '@angular/forms', 'rxjs', 'rxjs/operators', '@angular/common/http', '@auth0/angular-jwt', 'lodash', 'event-source-polyfill/src/eventsource.min.js', '@angular/router', 'lodash/clone', 'jspdf', 'jspdf-autotable', '@stripe/stripe-js', 'xlsx', 'file-saver'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["taxtank-core"] = {}, global.ng.core, global.ng.common, global.has, global.get, global.flatten, global.first, global.last, global.uniqBy, global.concat, global.compact, global.classTransformer, global.moment, global.momentRange, global.cloneDeep$1, global.ng.forms, global.rxjs, global.rxjs.operators, global.ng.common.http, global.angularJwt, global._, global.eventsource_min_js, global.ng.router, global.clone, global.jsPDF, global.autoTable, global.stripeJs, global.xlsx, global.FileSaver));
5
- })(this, (function (exports, i0, common, has, get, flatten, first, last, uniqBy, concat, compact, classTransformer, moment, momentRange, cloneDeep$1, forms, rxjs, operators, i1, angularJwt, _, eventsource_min_js, i1$1, clone, jsPDF, autoTable, stripeJs, xlsx, FileSaver) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/common/http'), require('rxjs'), require('rxjs/operators'), require('class-transformer'), require('@auth0/angular-jwt'), require('lodash/has'), require('lodash/get'), require('lodash/flatten'), require('lodash/first'), require('lodash/last'), require('lodash/uniqBy'), require('lodash/concat'), require('lodash/compact'), require('moment'), require('moment-range'), require('lodash/cloneDeep'), require('@angular/forms'), require('lodash'), require('event-source-polyfill/src/eventsource.min.js'), require('@angular/router'), require('lodash/clone'), require('jspdf'), require('jspdf-autotable'), require('@stripe/stripe-js'), require('xlsx'), require('file-saver')) :
3
+ typeof define === 'function' && define.amd ? define('taxtank-core', ['exports', '@angular/core', '@angular/common', '@angular/common/http', 'rxjs', 'rxjs/operators', 'class-transformer', '@auth0/angular-jwt', 'lodash/has', 'lodash/get', 'lodash/flatten', 'lodash/first', 'lodash/last', 'lodash/uniqBy', 'lodash/concat', 'lodash/compact', 'moment', 'moment-range', 'lodash/cloneDeep', '@angular/forms', 'lodash', 'event-source-polyfill/src/eventsource.min.js', '@angular/router', 'lodash/clone', 'jspdf', 'jspdf-autotable', '@stripe/stripe-js', 'xlsx', 'file-saver'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["taxtank-core"] = {}, global.ng.core, global.ng.common, global.ng.common.http, global.rxjs, global.rxjs.operators, global.classTransformer, global.angularJwt, global.has, global.get, global.flatten, global.first, global.last, global.uniqBy, global.concat, global.compact, global.moment, global.momentRange, global.cloneDeep$1, global.ng.forms, global._, global.eventsource_min_js, global.ng.router, global.clone, global.jsPDF, global.autoTable, global.stripeJs, global.xlsx, global.FileSaver));
5
+ })(this, (function (exports, i0, common, i1, rxjs, operators, classTransformer, angularJwt, has, get, flatten, first, last, uniqBy, concat, compact, moment, momentRange, cloneDeep$1, forms, _, eventsource_min_js, i1$1, clone, jsPDF, autoTable, stripeJs, xlsx, FileSaver) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -25,6 +25,7 @@
25
25
  }
26
26
 
27
27
  var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
+ var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
28
29
  var has__default = /*#__PURE__*/_interopDefaultLegacy(has);
29
30
  var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
30
31
  var flatten__default = /*#__PURE__*/_interopDefaultLegacy(flatten);
@@ -35,7 +36,6 @@
35
36
  var compact__default = /*#__PURE__*/_interopDefaultLegacy(compact);
36
37
  var moment__namespace = /*#__PURE__*/_interopNamespace(moment);
37
38
  var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep$1);
38
- var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
39
39
  var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
40
40
  var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1$1);
41
41
  var clone__default = /*#__PURE__*/_interopDefaultLegacy(clone);
@@ -44,36 +44,133 @@
44
44
  var xlsx__namespace = /*#__PURE__*/_interopNamespace(xlsx);
45
45
  var FileSaver__namespace = /*#__PURE__*/_interopNamespace(FileSaver);
46
46
 
47
- var TtCoreModule = /** @class */ (function () {
48
- function TtCoreModule() {
47
+ /**
48
+ * https://api-uat.corelogic.asia/property/au/v2/suggest.json
49
+ * address suggestion from corelogic service
50
+ */
51
+ var CorelogicSuggestion = /** @class */ (function () {
52
+ function CorelogicSuggestion() {
49
53
  }
50
- TtCoreModule.forRoot = function (environment) {
51
- localStorage.setItem('api_uri', environment['api_uri']);
52
- return {
53
- ngModule: TtCoreModule,
54
- providers: [
55
- {
56
- provide: 'environment',
57
- useValue: environment
58
- }
59
- ]
60
- };
54
+ return CorelogicSuggestion;
55
+ }());
56
+
57
+ var CorelogicService = /** @class */ (function () {
58
+ function CorelogicService(http, environment) {
59
+ this.http = http;
60
+ this.environment = environment;
61
+ this.accessTokenSubject = new rxjs.ReplaySubject(1);
62
+ }
63
+ CorelogicService.prototype.getAccessToken = function (force) {
64
+ var _this = this;
65
+ if (force === void 0) { force = false; }
66
+ if (!this._accessToken || force) {
67
+ this.http.get(this.environment.coreLogicUrl + "/access/oauth/token?grant_type=client_credentials&client_id=" + this.environment.coreLogicId + "&client_secret=" + this.environment.coreLogicSecret)
68
+ .pipe(operators.map(function (response) {
69
+ return response.access_token;
70
+ }))
71
+ .subscribe(function (token) {
72
+ _this._accessToken = token;
73
+ _this.accessTokenSubject.next(_this._accessToken);
74
+ });
75
+ }
76
+ return this.accessTokenSubject.asObservable();
61
77
  };
62
- return TtCoreModule;
78
+ CorelogicService.prototype.getSuggestions = function (query, country) {
79
+ if (country === void 0) { country = 'au'; }
80
+ // @TODO handle different countries in future
81
+ return this.http.get(this.environment.coreLogicUrl + "/property/" + country + "/v2/suggest.json?q=" + query)
82
+ .pipe(operators.map(function (response) {
83
+ return response.suggestions.map(function (item) { return classTransformer.plainToClass(CorelogicSuggestion, item); });
84
+ }));
85
+ };
86
+ return CorelogicService;
63
87
  }());
64
- TtCoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
65
- TtCoreModulemod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, imports: [common.CommonModule] });
66
- TtCoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, imports: [[
67
- common.CommonModule
68
- ]] });
69
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, decorators: [{
70
- type: i0.NgModule,
88
+ CorelogicService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: CorelogicService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
89
+ CorelogicServiceprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: CorelogicService, providedIn: 'root' });
90
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: CorelogicService, decorators: [{
91
+ type: i0.Injectable,
71
92
  args: [{
72
- declarations: [],
73
- imports: [
74
- common.CommonModule
75
- ]
93
+ providedIn: 'root'
76
94
  }]
95
+ }], ctorParameters: function () {
96
+ return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
97
+ type: i0.Inject,
98
+ args: ['environment']
99
+ }] }];
100
+ } });
101
+
102
+ /**
103
+ * Corelogic interceptor add Core Logic access token for each search requests related with Core Logic API
104
+ */
105
+ var CorelogicInterceptor = /** @class */ (function () {
106
+ function CorelogicInterceptor(corelogicService, environment) {
107
+ this.corelogicService = corelogicService;
108
+ this.environment = environment;
109
+ }
110
+ /**
111
+ * Check if requested url requested core logic, but not core logic auth api
112
+ * @param req
113
+ */
114
+ CorelogicInterceptor.prototype.addToken = function (req) {
115
+ // don't need token for this endpoint
116
+ if (req.url.includes(this.environment.coreLogicUrl + "/access/oauth/token")) {
117
+ return req;
118
+ }
119
+ // add core logic token to request headers
120
+ if (req.url.includes(this.environment.coreLogicUrl)) {
121
+ return req.clone({
122
+ setHeaders: {
123
+ Authorization: 'Bearer ' + this.corelogicService._accessToken
124
+ }
125
+ });
126
+ }
127
+ // return request without changes if url not related with core logic
128
+ return req;
129
+ };
130
+ CorelogicInterceptor.prototype.intercept = function (request, next) {
131
+ return next.handle(this.addToken(request));
132
+ };
133
+ return CorelogicInterceptor;
134
+ }());
135
+ CorelogicInterceptor.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: CorelogicInterceptor, deps: [{ token: CorelogicService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
136
+ CorelogicInterceptor.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: CorelogicInterceptor });
137
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: CorelogicInterceptor, decorators: [{
138
+ type: i0.Injectable
139
+ }], ctorParameters: function () {
140
+ return [{ type: CorelogicService }, { type: undefined, decorators: [{
141
+ type: i0.Inject,
142
+ args: ['environment']
143
+ }] }];
144
+ } });
145
+
146
+ /**
147
+ * Financial Year interceptor add financialYear parameter to requests because a lot of POST and GET requests require this parameter
148
+ * @TODO now we can get current fin year from user on backend. So we can remove this interceptor
149
+ */
150
+ var FinancialYearInterceptor = /** @class */ (function () {
151
+ function FinancialYearInterceptor() {
152
+ }
153
+ FinancialYearInterceptor.prototype.intercept = function (request, next) {
154
+ // Set financial year parameter to requests
155
+ var params = new i1.HttpParams({
156
+ fromString: request.params.toString()
157
+ });
158
+ // clone request to add new parameters
159
+ var clonedReq = request.clone();
160
+ if (!params.get('financialYear')) {
161
+ params = params.set('financialYear', localStorage.getItem('financialYear'));
162
+ clonedReq = request.clone({
163
+ params: params
164
+ });
165
+ }
166
+ return next.handle(clonedReq);
167
+ };
168
+ return FinancialYearInterceptor;
169
+ }());
170
+ FinancialYearInterceptor.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FinancialYearInterceptor, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
171
+ FinancialYearInterceptor.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FinancialYearInterceptor });
172
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FinancialYearInterceptor, decorators: [{
173
+ type: i0.Injectable
77
174
  }] });
78
175
 
79
176
  /*! *****************************************************************************
@@ -394,6 +491,636 @@
394
491
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
395
492
  }
396
493
 
494
+ var NAME_TOKEN = 'token';
495
+ var NAME_REFRESH_TOKEN = 'refreshToken';
496
+ var JwtService = /** @class */ (function (_super) {
497
+ __extends(JwtService, _super);
498
+ function JwtService() {
499
+ return _super !== null && _super.apply(this, arguments) || this;
500
+ }
501
+ JwtService.prototype.getToken = function () {
502
+ return localStorage[NAME_TOKEN];
503
+ };
504
+ JwtService.prototype.getRefreshToken = function () {
505
+ return localStorage[NAME_REFRESH_TOKEN];
506
+ };
507
+ JwtService.prototype.saveTokens = function (tokens) {
508
+ localStorage[NAME_TOKEN] = tokens.token;
509
+ localStorage[NAME_REFRESH_TOKEN] = tokens.refreshToken;
510
+ };
511
+ JwtService.prototype.destroyTokens = function () {
512
+ localStorage.removeItem(NAME_TOKEN);
513
+ localStorage.removeItem(NAME_REFRESH_TOKEN);
514
+ };
515
+ JwtService.prototype.getUser = function () {
516
+ return this.decodeToken();
517
+ };
518
+ JwtService.prototype.isMe = function (userId) {
519
+ return this.getUser().id === userId;
520
+ };
521
+ return JwtService;
522
+ }(angularJwt.JwtHelperService));
523
+ JwtService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: JwtService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
524
+ JwtService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: JwtService, providedIn: 'root' });
525
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: JwtService, decorators: [{
526
+ type: i0.Injectable,
527
+ args: [{
528
+ providedIn: 'root'
529
+ }]
530
+ }] });
531
+
532
+ var AuthService = /** @class */ (function () {
533
+ function AuthService(http, jwtService, environment) {
534
+ this.http = http;
535
+ this.jwtService = jwtService;
536
+ this.environment = environment;
537
+ this.isLoggedInSubject = new rxjs.BehaviorSubject(!this.jwtService.isTokenExpired());
538
+ }
539
+ AuthService.prototype.setAuth = function (response) {
540
+ this.jwtService.saveTokens(response);
541
+ this.isLoggedInSubject.next(true);
542
+ };
543
+ AuthService.prototype.login = function (username, password) {
544
+ var _this = this;
545
+ return this.http.post(this.environment.apiV2 + "/login_check", { username: username, password: password }).pipe(operators.map(function (response) {
546
+ _this.setAuth(response);
547
+ return response;
548
+ }));
549
+ };
550
+ AuthService.prototype.refresh = function (refreshToken) {
551
+ var _this = this;
552
+ return this.http.post(this.environment.apiV2 + "/token/refresh", { refreshToken: refreshToken }).pipe(operators.map(function (response) {
553
+ _this.setAuth(response);
554
+ return response;
555
+ }));
556
+ };
557
+ AuthService.prototype.logoutFront = function (url) {
558
+ if (url === void 0) { url = '/login'; }
559
+ localStorage.clear();
560
+ location.replace(url);
561
+ };
562
+ return AuthService;
563
+ }());
564
+ AuthService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AuthService, deps: [{ token: i1__namespace.HttpClient }, { token: JwtService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
565
+ AuthService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AuthService, providedIn: 'root' });
566
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AuthService, decorators: [{
567
+ type: i0.Injectable,
568
+ args: [{
569
+ providedIn: 'root'
570
+ }]
571
+ }], ctorParameters: function () {
572
+ return [{ type: i1__namespace.HttpClient }, { type: JwtService }, { type: undefined, decorators: [{
573
+ type: i0.Inject,
574
+ args: ['environment']
575
+ }] }];
576
+ } });
577
+
578
+ var MESSAGE_DEFAULT_500_ERROR = 'Unexpected error! Please try again later. You can send us via chat your questions.';
579
+ /**
580
+ * JWT Interceptor add jwt token to each request related with TaxTank API
581
+ */
582
+ var JwtInterceptor = /** @class */ (function () {
583
+ function JwtInterceptor(jwtService, authService, environment) {
584
+ this.jwtService = jwtService;
585
+ this.authService = authService;
586
+ this.environment = environment;
587
+ this.isRefreshingToken = false;
588
+ this.tokenSubject = new rxjs.BehaviorSubject(null);
589
+ }
590
+ JwtInterceptor.prototype.addToken = function (req) {
591
+ return req.clone({
592
+ setHeaders: { Authorization: 'Bearer ' + this.jwtService.getToken() },
593
+ withCredentials: true
594
+ });
595
+ };
596
+ JwtInterceptor.prototype.intercept = function (request, next) {
597
+ var _this = this;
598
+ // skip third party requests
599
+ if (!request.url.includes(this.environment.api_uri)) {
600
+ return next.handle(request);
601
+ }
602
+ // add token to every api request
603
+ return next.handle(this.addToken(request)).pipe(
604
+ // handle errors
605
+ operators.catchError(function (err) {
606
+ if (err instanceof i1.HttpErrorResponse) {
607
+ switch (err.status) {
608
+ // unexpected errors
609
+ case 405:
610
+ case 500:
611
+ _this.handle500Error();
612
+ break;
613
+ // expected errors
614
+ case 401:
615
+ return _this.handle401Error(request, next, err);
616
+ case 400:
617
+ case 403:
618
+ // @TODO in most cases 404 is not an error, handle in components
619
+ // case 404:
620
+ _this.showErrorMessages(err);
621
+ break;
622
+ }
623
+ }
624
+ return rxjs.throwError(err);
625
+ }));
626
+ };
627
+ /**
628
+ * @TODO log
629
+ * @TODO waiting for backend to handle errors in a better way
630
+ */
631
+ JwtInterceptor.prototype.handle400Error = function (err) {
632
+ // this.snackBar.open(err.error['hydra:description'], '', {
633
+ // panelClass: 'error'
634
+ // });
635
+ };
636
+ /**
637
+ * @TODO log
638
+ * @TODO waiting for backend to handle errors in a better way
639
+ */
640
+ JwtInterceptor.prototype.handle403Error = function (err) {
641
+ // this.snackBar.open(err.error['hydra:description'], '', {
642
+ // panelClass: 'error'
643
+ // });
644
+ };
645
+ /**
646
+ * @TODO log
647
+ */
648
+ JwtInterceptor.prototype.handle500Error = function () {
649
+ // this.snackBar.open(MESSAGE_DEFAULT_500_ERROR, '', {
650
+ // panelClass: 'error'
651
+ // });
652
+ };
653
+ JwtInterceptor.prototype.handle401Error = function (req, next, err) {
654
+ var _this = this;
655
+ if (req.url.includes('token/refresh') || req.url.includes('login')) {
656
+ if (req.url.includes('token/refresh')) {
657
+ this.authService.logoutFront();
658
+ }
659
+ return rxjs.throwError(err);
660
+ }
661
+ // refreshing token, wait until it's done and retry the request
662
+ if (this.isRefreshingToken) {
663
+ return this.tokenSubject.pipe(operators.filter(function (token) { return token != null; }), operators.take(1), operators.switchMap(function (token) { return next.handle(_this.addToken(req)); }));
664
+ // refresh token
665
+ }
666
+ else {
667
+ // subsequent requests should wait until refresh token is ready
668
+ this.isRefreshingToken = true;
669
+ this.tokenSubject.next(null);
670
+ return this.authService.refresh(this.jwtService.getRefreshToken()).pipe(operators.switchMap(function (tokens) {
671
+ _this.tokenSubject.next(tokens.token);
672
+ return next.handle(_this.addToken(req));
673
+ }), operators.catchError(function () {
674
+ _this.authService.logoutFront();
675
+ return rxjs.throwError(err);
676
+ }), operators.finalize(function () {
677
+ _this.isRefreshingToken = false;
678
+ }));
679
+ }
680
+ };
681
+ /**
682
+ * Handle error messages
683
+ * @param errorResponse from which messages should be taken
684
+ *
685
+ * @TODO move to separated interceptor
686
+ */
687
+ JwtInterceptor.prototype.showErrorMessages = function (errorResponse) {
688
+ if (!errorResponse.error.violations) {
689
+ // this.snackBar.open('Something went wrong', '', {
690
+ // panelClass: 'error'
691
+ // });
692
+ return;
693
+ }
694
+ errorResponse.error.violations.forEach(function (violation) {
695
+ // this.snackBar.open(violation['message'], '', {
696
+ // panelClass: 'error'
697
+ // });
698
+ });
699
+ };
700
+ return JwtInterceptor;
701
+ }());
702
+ JwtInterceptor.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: JwtInterceptor, deps: [{ token: JwtService }, { token: AuthService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
703
+ JwtInterceptor.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: JwtInterceptor });
704
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: JwtInterceptor, decorators: [{
705
+ type: i0.Injectable
706
+ }], ctorParameters: function () {
707
+ return [{ type: JwtService }, { type: AuthService }, { type: undefined, decorators: [{
708
+ type: i0.Inject,
709
+ args: ['environment']
710
+ }] }];
711
+ } });
712
+
713
+ var KEY = '_switch_user';
714
+ /**
715
+ * provides user management to managers (users with ROLE_ACCOUNTANT for now, more in future)
716
+ */
717
+ var UserSwitcherService = /** @class */ (function () {
718
+ function UserSwitcherService() {
719
+ }
720
+ /**
721
+ * get switched username
722
+ */
723
+ UserSwitcherService.prototype.get = function () {
724
+ return localStorage[KEY];
725
+ };
726
+ /**
727
+ * switch to user (username should be used for correct work of backend)
728
+ */
729
+ UserSwitcherService.prototype.set = function (username) {
730
+ localStorage[KEY] = username;
731
+ window.location.replace('/client/dashboard');
732
+ };
733
+ /**
734
+ * go back to original user
735
+ */
736
+ UserSwitcherService.prototype.reset = function () {
737
+ localStorage.removeItem(KEY);
738
+ window.location.replace('/firm/dashboard');
739
+ };
740
+ return UserSwitcherService;
741
+ }());
742
+ UserSwitcherService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserSwitcherService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
743
+ UserSwitcherService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserSwitcherService, providedIn: 'root' });
744
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserSwitcherService, decorators: [{
745
+ type: i0.Injectable,
746
+ args: [{
747
+ providedIn: 'root'
748
+ }]
749
+ }] });
750
+
751
+ /**
752
+ * Impersonate current's user (manager) to client experience with help of special header
753
+ */
754
+ var UserSwitcherInterceptor = /** @class */ (function () {
755
+ function UserSwitcherInterceptor(userSwitcherService, environment) {
756
+ this.userSwitcherService = userSwitcherService;
757
+ this.environment = environment;
758
+ }
759
+ /**
760
+ * add token header if request url contain TaxTank API URL
761
+ */
762
+ UserSwitcherInterceptor.prototype.switch = function (req, username) {
763
+ // skip third party api requests
764
+ if (!req.url.includes(this.environment.api_uri) || !username) {
765
+ return req;
766
+ }
767
+ var params = new i1.HttpParams({ fromString: req.params.toString() }).set('_switch_user', username);
768
+ return req.clone({ params: params });
769
+ // @TODO move to header solution when backend can support it
770
+ // return req.clone({
771
+ // setHeaders: {
772
+ // HTTP_X_SWITCH_USER: username
773
+ // }
774
+ // });
775
+ };
776
+ UserSwitcherInterceptor.prototype.intercept = function (request, next) {
777
+ return next.handle(this.switch(request, this.userSwitcherService.get()));
778
+ };
779
+ return UserSwitcherInterceptor;
780
+ }());
781
+ UserSwitcherInterceptor.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserSwitcherInterceptor, deps: [{ token: UserSwitcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
782
+ UserSwitcherInterceptor.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserSwitcherInterceptor });
783
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserSwitcherInterceptor, decorators: [{
784
+ type: i0.Injectable
785
+ }], ctorParameters: function () {
786
+ return [{ type: UserSwitcherService }, { type: undefined, decorators: [{
787
+ type: i0.Inject,
788
+ args: ['environment']
789
+ }] }];
790
+ } });
791
+
792
+ /**
793
+ * Backend endpoint class
794
+ */
795
+ var Endpoint = /** @class */ (function () {
796
+ function Endpoint(method, pattern) {
797
+ this.method = method;
798
+ this.pattern = pattern;
799
+ }
800
+ /**
801
+ * check url with regexp
802
+ * @param url
803
+ */
804
+ Endpoint.prototype.test = function (url) {
805
+ return this.regexp.test(url);
806
+ };
807
+ Object.defineProperty(Endpoint.prototype, "regexp", {
808
+ /**
809
+ * Get regexp for endpoint
810
+ */
811
+ get: function () {
812
+ return new RegExp("^" + this.method + " .*" + this.pattern + "$");
813
+ },
814
+ enumerable: false,
815
+ configurable: true
816
+ });
817
+ return Endpoint;
818
+ }());
819
+
820
+ /**
821
+ * List of all app endpoints
822
+ */
823
+ var ENDPOINTS = {
824
+ ASSETS_GET: new Endpoint('GET', '\\/assets\\/\.\*\\/\\d+'),
825
+ BANK_ACCOUNTS_GET: new Endpoint('GET', '\\/bank-accounts'),
826
+ BANK_ACCOUNTS_POST: new Endpoint('POST', '\\/bank-accounts'),
827
+ BANK_ACCOUNTS_PUT: new Endpoint('PUT', '\\/bank-accounts\\/\\d+'),
828
+ BANK_CONNECTION_POST: new Endpoint('POST', '\\/bank-connections'),
829
+ BANK_TRANSACTIONS_GET: new Endpoint('GET', '\\/bank-transactions'),
830
+ BANK_TRANSACTIONS_DELETE: new Endpoint('DELETE', '\\/bank-transactions\\/\\d+'),
831
+ BANK_TRANSACTIONS_IMPORT_POST: new Endpoint('POST', '\\/bank-transactions\\/\\d+\\/import'),
832
+ BASIQ_ACCOUNTS_GET: new Endpoint('GET', '\\/basiq\\/\\accounts'),
833
+ CAPITAL_COSTS_GET: new Endpoint('GET', '\\/capital-costs'),
834
+ CHARTS_INCOME_GET: new Endpoint('GET', '\\/charts\\/\\incomes'),
835
+ CHARTS_EXPENSES_GET: new Endpoint('GET', '\\/charts\\/\\expenses'),
836
+ CHART_ACCOUNTS_GET: new Endpoint('GET', '\\/chart-accounts'),
837
+ CLIENTS_GET: new Endpoint('GET', '\\/clients'),
838
+ CLIENTS_PUT: new Endpoint('PUT', '\\/clients'),
839
+ CLIENTS_EXCLUDE_PUT: new Endpoint('PUT', '\\/clients\\/\\d+\\/exclude'),
840
+ CLIENTS_INVITES_GET: new Endpoint('GET', '\\/clients\\/\\invites'),
841
+ CLIENTS_INVITES_POST: new Endpoint('POST', '\\/clients\\/\\invites'),
842
+ CLIENTS_INVITES_DELETE: new Endpoint('DELETE', '\\/clients\\/\\invites\\/\\d+'),
843
+ CLIENTS_INVITES_ACCEPT_POST: new Endpoint('POST', '\\/clients\\/\\invites\\/\\d+\\/accept'),
844
+ CLIENTS_INVITES_REJECT_POST: new Endpoint('POST', '\\/clients\\/\\invites\\/\\d+\\/reject'),
845
+ CLIENTS_INVITES_RESEND_POST: new Endpoint('POST', '\\/clients\\/\\invites\\/\\d+\\/resend'),
846
+ CLIENT_MOVEMENTS_GET: new Endpoint('GET', '\\/client-movements'),
847
+ CLIENT_MOVEMENTS_POST: new Endpoint('POST', '\\/client-movements'),
848
+ COUNTRIES_GET: new Endpoint('GET', '\\/countries'),
849
+ DEPRECIATIONS_CLOSING_GET: new Endpoint('GET', '\\/depreciations\\/\\closing-balance\.\*'),
850
+ DEPRECIATIONS_GET: new Endpoint('GET', '\\/depreciations'),
851
+ DEPRECIATIONS_POST: new Endpoint('POST', '\\/depreciations'),
852
+ DEPRECIATIONS_PUT: new Endpoint('PUT', '\\/depreciations\\/\\d+'),
853
+ EMPLOYEES_GET: new Endpoint('GET', '\\/employees'),
854
+ EMPLOYEES_INVITES_GET: new Endpoint('GET', '\\/employees\\/\\invites'),
855
+ EMPLOYEES_INVITES_DELETE: new Endpoint('DELETE', '\\/employees\\/\\invites\\/\\d+'),
856
+ EMPLOYEES_INVITE_POST: new Endpoint('POST', '\\/employees\\/\\invites'),
857
+ EMPLOYEES_INVITES_REJECT_POST: new Endpoint('POST', '\\/employees\\/\\invites\\/\\d+\\/\\reject'),
858
+ EMPLOYEES_INVITES_RESEND_POST: new Endpoint('POST', '\\/employees\\/\\invites\\/\\d+\\/\\resend'),
859
+ FIRM_GET: new Endpoint('GET', '\\/firms'),
860
+ FIRM_CURRENT_GET: new Endpoint('GET', '\\/firms\\/current'),
861
+ FIRM_CURRENT_PUT: new Endpoint('PUT', '\\/firms\\/current\.\*'),
862
+ FIRM_INVITE_POST: new Endpoint('POST', '\\/firms\\/invite'),
863
+ FIRM_REGISTRATION_POST: new Endpoint('POST', '\\/firms\\/registration'),
864
+ FIRM_UPDATE_PHOTO_POST: new Endpoint('POST', '\\/firms\\/photo\.\*'),
865
+ FOLDERS_GET: new Endpoint('GET', '\\/folders'),
866
+ FOLDERS_POST: new Endpoint('POST', '\\/folders'),
867
+ FOLDERS_PUT: new Endpoint('PUT', '\\/folders\\/\\d+'),
868
+ FOLDERS_DOCUMENTS_POST: new Endpoint('POST', '\\/folders\\/\\d+\\/documents'),
869
+ FOLDERS_DOCUMENTS_PUT: new Endpoint('PUT', '\\/folders\\/\\d+\\/documents\\/\\d+'),
870
+ INCOME_SOURCES_GET: new Endpoint('GET', '\\/income-sources'),
871
+ INCOME_SOURCES_POST: new Endpoint('POST', '\\/income-sources'),
872
+ INCOME_SOURCES_PUT: new Endpoint('PUT', '\\/income-sources'),
873
+ INCOME_SOURCES_DELETE: new Endpoint('DELETE', '\\/income-sources\\/\\d+'),
874
+ INCOME_SOURCE_FORECAST_GET: new Endpoint('GET', '\\/income-source-forecasts'),
875
+ INCOME_SOURCE_FORECAST_POST: new Endpoint('POST', '\\/income-source-forecasts'),
876
+ INCOME_SOURCE_FORECAST_PUT: new Endpoint('PUT', '\\/income-source-forecasts'),
877
+ INCOME_SOURCE_FORECAST_DELETE: new Endpoint('DELETE', '\\/income-source-forecasts\\/\\d+'),
878
+ INCOME_SOURCE_TYPES_GET: new Endpoint('GET', '\\/income-source-types'),
879
+ LOANS_GET: new Endpoint('GET', '\\/bank-accounts\\/loans'),
880
+ LOANS_POST: new Endpoint('POST', '\\/bank-accounts\\/loans'),
881
+ LOANS_PUT: new Endpoint('PUT', '\\/bank-accounts\\/loans/\\d+'),
882
+ LOANS_PAYOUT_POST: new Endpoint('POST', '\\/loans\\/\\d+\\/payout'),
883
+ LOANS_PAYOUT_PUT: new Endpoint('PUT', '\\/loans\\/\\d+\\/payout\\/\\d+'),
884
+ LOANS_PAYOUT_DELETE: new Endpoint('DELETE', '\\/loans\\/\\d+\\/payout\\/\\d+'),
885
+ LOANS_CALCULATION_POST: new Endpoint('POST', '\\/bank-accounts\\/loans\\/calculation'),
886
+ LOGIN_CHECK_POST: new Endpoint('POST', '\\/login_check'),
887
+ NOTIFICATIONS_GET: new Endpoint('GET', '\\/service-notifications'),
888
+ OCCUPATIONS_GET: new Endpoint('GET', '\\/occupations'),
889
+ PROPERTIES_GET: new Endpoint('GET', '\\/properties'),
890
+ PROPERTIES_POST: new Endpoint('POST', '\\/properties'),
891
+ PROPERTY_PUT: new Endpoint('PUT', '\\/properties/\\d+'),
892
+ PROPERTIES_PUT: new Endpoint('PUT', '\\/properties'),
893
+ PROPERTIES_CATEGORIES_EQUITY_GET: new Endpoint('GET', '\\/properties\\/categories\\/equity'),
894
+ PROPERTIES_CATEGORIES_GET: new Endpoint('GET', '\\/properties\\/categories'),
895
+ PROPERTIES_CATEGORIES_PUT: new Endpoint('PUT', '\\/properties\\/categories\\/\\d+'),
896
+ PROPERTIES_CATEGORIES_POST: new Endpoint('POST', '\\/properties\\/categories'),
897
+ PROPERTIES_CATEGORY_MOVEMENTS_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/category-movements'),
898
+ PROPERTIES_CATEGORY_MOVEMENTS_PUT: new Endpoint('PUT', '\\/properties\\/\\d+\\/category-movements\\/\\d+'),
899
+ PROPERTIES_CO_OWNERS_PUT: new Endpoint('PUT', '\\/properties\\/co-owners\\/\\d+'),
900
+ PROPERTIES_CO_OWNERS_GET: new Endpoint('GET', '\\/properties\\/co-owners'),
901
+ PROPERTIES_CO_OWNERS_POST: new Endpoint('POST', '\\/properties\\/co-owners'),
902
+ PROPERTIES_DEACTIVATE_PUT: new Endpoint('PUT', '\\/properties\\/\\d+\\/deactivate'),
903
+ PROPERTIES_DEPRECIATION_CAPITAL_PROJECT_GET: new Endpoint('GET', '\\/properties\\/\\d+\\/depreciation-capital-projects'),
904
+ PROPERTIES_DEPRECIATION_CAPITAL_PROJECT_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/depreciation-capital-projects'),
905
+ PROPERTIES_DEPRECIATION_CAPITAL_PROJECT_PUT: new Endpoint('PUT', '\\/properties\\/\\d+\\/depreciation-capital-projects\\/\\d+'),
906
+ PROPERTIES_DEPRECIATION_CAPITAL_PROJECT_DELETE: new Endpoint('DELETE', '\\/properties\\/\\d+\\/depreciation-capital-projects\\/\\d+'),
907
+ PROPERTIES_DOCUMENTS_GET: new Endpoint('GET', '\\/properties\\/documents'),
908
+ PROPERTIES_DOCUMENTS_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/documents'),
909
+ PROPERTIES_DOCUMENTS_PUT: new Endpoint('PUT', '\\/properties\\/documents\\/\\d+'),
910
+ PROPERTIES_DOCUMENTS_DELETE: new Endpoint('DELETE', '\\/properties\\/documents\\/\\d+'),
911
+ PROPERTIES_PHOTO_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/photo\.\*'),
912
+ PROPERTIES_SUGGESTIONS_GET: new Endpoint('GET', '/property\\/\\w+\\/v2\\/.*$'),
913
+ PROPERTIES_VALUATIONS_DOCUMENTS_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/valuations\\/\\d+\\/documents'),
914
+ PRORATION_COST_POST: new Endpoint('POST', '\\/subscriptions\\/proration-cost'),
915
+ SALARY_FORECAST_GET: new Endpoint('GET', '\\/salary-forecasts'),
916
+ SALARY_FORECAST_POST: new Endpoint('POST', '\\/salary-forecasts'),
917
+ SALARY_FORECAST_PUT: new Endpoint('PUT', '\\/salary-forecasts'),
918
+ SERVICE_PRICES_GET: new Endpoint('GET', '\\/service-prices'),
919
+ SERVICE_PAYMENTS_GET: new Endpoint('GET', '\\/service-payments'),
920
+ STRIPE_BILLING_PORTAL_GET: new Endpoint('GET', '\\/stripe\\/billing-portal-session'),
921
+ STRIPE_CHECKOUT_SESSION_POST: new Endpoint('POST', '\\/stripe\\/checkout-session'),
922
+ SUBSCRIPTION_LAST_GET: new Endpoint('GET', '\\/subscriptions\\/last'),
923
+ SUBSCRIPTION_ITEMS_PUT: new Endpoint('PUT', '\\/subscriptions\\/items'),
924
+ TAX_CALCULATION_POST: new Endpoint('POST', '\\/tax-calculation'),
925
+ TAX_REVIEWS_GET: new Endpoint('GET', '\\/tax-reviews'),
926
+ TAX_REVIEWS_DELETE: new Endpoint('DELETE', '\\/tax-reviews\\/\\d+'),
927
+ TAX_REVIEWS_POST: new Endpoint('POST', '\\/tax-reviews'),
928
+ TAX_REVIEWS_PUT: new Endpoint('PUT', '\\/tax-reviews\\/\\d+'),
929
+ TAX_SUMMARY_ACTUAL_GET: new Endpoint('GET', '\\/tax-summary\\/actuals'),
930
+ TAX_SUMMARY_FORECAST_GET: new Endpoint('GET', '\\/tax-summary\\/forecasts'),
931
+ TRANSACTION_DELETE: new Endpoint('DELETE', '\\/transactions\\/\\d+'),
932
+ TRANSACTION_PUT: new Endpoint('PUT', '\\/transactions\\/\\d+'),
933
+ TRANSACTIONS_GET: new Endpoint('GET', '\\/transactions'),
934
+ TRANSACTIONS_POST: new Endpoint('POST', '\\/transactions'),
935
+ TRANSACTIONS_PUT: new Endpoint('PUT', '\\/transactions'),
936
+ TRANSACTIONS_ALLOCATIONS_GET: new Endpoint('GET', '\\/transactions-allocations'),
937
+ TRANSACTIONS_ALLOCATIONS_POST: new Endpoint('POST', '\\/transactions-allocations'),
938
+ TRANSACTIONS_ALLOCATIONS_DELETE: new Endpoint('DELETE', '\\/transactions-allocations\\/\\d+'),
939
+ USER_CONFIRMATION_POST: new Endpoint('POST', '\\/users\\/confirmation'),
940
+ USER_CURRENT_GET: new Endpoint('GET', '\\/users\\/current'),
941
+ USER_CURRENT_PASSWORD_PUT: new Endpoint('PUT', '\\/users\\/current\\/password\.\*'),
942
+ USER_EVENT_SETTINGS_GET: new Endpoint('GET', '\\/user-event-settings'),
943
+ USER_EVENT_TYPES_GET: new Endpoint('GET', '\\/user-event-types'),
944
+ USER_INVITE_DELETE: new Endpoint('DELETE', '\\/users\\/invite\\/\\d+'),
945
+ USER_INVITE_POST: new Endpoint('POST', '\\/users\\/invite'),
946
+ USER_INVITE_RESEND_POST: new Endpoint('POST', '\\/users\\/invite/\\d+\\/resend'),
947
+ USER_PUT: new Endpoint('PUT', '\\/users\\/\\d+'),
948
+ USER_REGISTRATION_POST: new Endpoint('POST', '\\/users\\/registration'),
949
+ USER_RESET_PASSWORD_PUT: new Endpoint('PUT', '\\/users\\/reset-password'),
950
+ USER_SEARCH_GET: new Endpoint('GET', '\\/users\\/search\.\*'),
951
+ USER_UPDATE_PHOTO_POST: new Endpoint('POST', '\\/users\\/photo\.\*'),
952
+ USER_STATUS_PUT: new Endpoint('PUT', '\\/users\\/status'),
953
+ VEHICLES_GET: new Endpoint('GET', '\\/vehicles'),
954
+ VEHICLES_POST: new Endpoint('POST', '\\/vehicles'),
955
+ VEHICLES_PUT: new Endpoint('PUT', '\\/vehicles\\/\\d+'),
956
+ VEHICLE_CLAIMS_GET: new Endpoint('GET', '\\/vehicle-claims'),
957
+ VEHICLE_CLAIMS_POST: new Endpoint('POST', '\\/vehicle-claims'),
958
+ VEHICLE_LOGBOOK_POST: new Endpoint('POST', '\\/vehicles\\/\\d+\\/logbooks'),
959
+ VEHICLE_LOGBOOK_PUT: new Endpoint('PUT', '\\/vehicles\\/\\d+\\/logbooks\\/\\d+'),
960
+ VEHICLE_CLAIMS_PUT: new Endpoint('PUT', '\\/vehicle-claims\\/\\d+')
961
+ };
962
+
963
+ var PreloaderService = /** @class */ (function () {
964
+ function PreloaderService() {
965
+ this.activePreloaders = new rxjs.BehaviorSubject([]);
966
+ }
967
+ PreloaderService.prototype.get = function () {
968
+ return this.activePreloaders.asObservable();
969
+ };
970
+ PreloaderService.prototype.add = function (endpoint) {
971
+ var activePreloaders = this.activePreloaders.getValue();
972
+ activePreloaders.push(endpoint);
973
+ this.activePreloaders.next(activePreloaders);
974
+ };
975
+ PreloaderService.prototype.delete = function (endpoint) {
976
+ var activePreloaders = this.activePreloaders.getValue();
977
+ activePreloaders = activePreloaders.filter(function (preloader) { return preloader !== endpoint; });
978
+ this.activePreloaders.next(activePreloaders);
979
+ };
980
+ return PreloaderService;
981
+ }());
982
+ PreloaderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PreloaderService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
983
+ PreloaderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PreloaderService, providedIn: 'root' });
984
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PreloaderService, decorators: [{
985
+ type: i0.Injectable,
986
+ args: [{
987
+ providedIn: 'root'
988
+ }]
989
+ }], ctorParameters: function () { return []; } });
990
+
991
+ /**
992
+ * interceptor for preloader handling
993
+ */
994
+ var PreloaderInterceptor = /** @class */ (function () {
995
+ function PreloaderInterceptor(preloaderService) {
996
+ this.preloaderService = preloaderService;
997
+ }
998
+ PreloaderInterceptor.prototype.intercept = function (request, next) {
999
+ var _this = this;
1000
+ var endpoint = this.findEndpoint(request.method + " " + request.url);
1001
+ if (!!endpoint) {
1002
+ this.preloaderService.add(endpoint);
1003
+ return next.handle(request).pipe(operators.finalize(function () {
1004
+ _this.preloaderService.delete(endpoint);
1005
+ }));
1006
+ }
1007
+ return next.handle(request);
1008
+ };
1009
+ PreloaderInterceptor.prototype.findEndpoint = function (requestPath) {
1010
+ return Object.values(ENDPOINTS).find(function (endpoint) { return endpoint.test(requestPath); });
1011
+ };
1012
+ return PreloaderInterceptor;
1013
+ }());
1014
+ PreloaderInterceptor.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PreloaderInterceptor, deps: [{ token: PreloaderService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1015
+ PreloaderInterceptor.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PreloaderInterceptor });
1016
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PreloaderInterceptor, decorators: [{
1017
+ type: i0.Injectable
1018
+ }], ctorParameters: function () { return [{ type: PreloaderService }]; } });
1019
+
1020
+ var InterceptorsModule = /** @class */ (function () {
1021
+ function InterceptorsModule() {
1022
+ }
1023
+ return InterceptorsModule;
1024
+ }());
1025
+ InterceptorsModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: InterceptorsModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1026
+ InterceptorsModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: InterceptorsModule });
1027
+ InterceptorsModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: InterceptorsModule, providers: [
1028
+ {
1029
+ provide: i1.HTTP_INTERCEPTORS,
1030
+ useClass: CorelogicInterceptor,
1031
+ multi: true
1032
+ },
1033
+ // @TODO move to user module
1034
+ {
1035
+ provide: i1.HTTP_INTERCEPTORS,
1036
+ useClass: FinancialYearInterceptor,
1037
+ multi: true
1038
+ },
1039
+ {
1040
+ provide: i1.HTTP_INTERCEPTORS,
1041
+ useClass: JwtInterceptor,
1042
+ multi: true
1043
+ },
1044
+ {
1045
+ provide: i1.HTTP_INTERCEPTORS,
1046
+ useClass: UserSwitcherInterceptor,
1047
+ multi: true
1048
+ },
1049
+ {
1050
+ provide: i1.HTTP_INTERCEPTORS,
1051
+ useClass: PreloaderInterceptor,
1052
+ multi: true
1053
+ }
1054
+ ] });
1055
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: InterceptorsModule, decorators: [{
1056
+ type: i0.NgModule,
1057
+ args: [{
1058
+ providers: [
1059
+ {
1060
+ provide: i1.HTTP_INTERCEPTORS,
1061
+ useClass: CorelogicInterceptor,
1062
+ multi: true
1063
+ },
1064
+ // @TODO move to user module
1065
+ {
1066
+ provide: i1.HTTP_INTERCEPTORS,
1067
+ useClass: FinancialYearInterceptor,
1068
+ multi: true
1069
+ },
1070
+ {
1071
+ provide: i1.HTTP_INTERCEPTORS,
1072
+ useClass: JwtInterceptor,
1073
+ multi: true
1074
+ },
1075
+ {
1076
+ provide: i1.HTTP_INTERCEPTORS,
1077
+ useClass: UserSwitcherInterceptor,
1078
+ multi: true
1079
+ },
1080
+ {
1081
+ provide: i1.HTTP_INTERCEPTORS,
1082
+ useClass: PreloaderInterceptor,
1083
+ multi: true
1084
+ }
1085
+ ]
1086
+ }]
1087
+ }] });
1088
+
1089
+ var TtCoreModule = /** @class */ (function () {
1090
+ function TtCoreModule() {
1091
+ }
1092
+ TtCoreModule.forRoot = function (environment) {
1093
+ localStorage.setItem('api_uri', environment['api_uri']);
1094
+ return {
1095
+ ngModule: TtCoreModule,
1096
+ providers: [
1097
+ {
1098
+ provide: 'environment',
1099
+ useValue: environment
1100
+ }
1101
+ ]
1102
+ };
1103
+ };
1104
+ return TtCoreModule;
1105
+ }());
1106
+ TtCoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1107
+ TtCoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, imports: [common.CommonModule,
1108
+ InterceptorsModule] });
1109
+ TtCoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, imports: [[
1110
+ common.CommonModule,
1111
+ InterceptorsModule
1112
+ ]] });
1113
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, decorators: [{
1114
+ type: i0.NgModule,
1115
+ args: [{
1116
+ declarations: [],
1117
+ imports: [
1118
+ common.CommonModule,
1119
+ InterceptorsModule
1120
+ ]
1121
+ }]
1122
+ }] });
1123
+
397
1124
  /**
398
1125
  * List of collections grouped by passed property
399
1126
  */
@@ -489,25 +1216,25 @@
489
1216
 
490
1217
  var DEFAULT_INDEX = 'other';
491
1218
  /**
492
- * collection abstract class. Contains common properties and methods for all collections
1219
+ * Base collection class. Contains common properties and methods for all collections
493
1220
  */
494
- var AbstractCollection = /** @class */ (function () {
495
- function AbstractCollection(items) {
1221
+ var Collection = /** @class */ (function () {
1222
+ function Collection(items) {
496
1223
  if (items === void 0) { items = []; }
497
1224
  this.items = items;
498
1225
  }
499
- AbstractCollection.prototype.create = function (items) {
1226
+ Collection.prototype.create = function (items) {
500
1227
  if (items === void 0) { items = []; }
501
1228
  return new this.constructor(items);
502
1229
  };
503
- AbstractCollection.prototype.getBy = function (field, value) {
1230
+ Collection.prototype.getBy = function (field, value) {
504
1231
  return this.create(this.items.filter(function (item) { return item[field] === value; }));
505
1232
  };
506
- AbstractCollection.prototype.groupBy = function (path) {
1233
+ Collection.prototype.groupBy = function (path) {
507
1234
  if (path === void 0) { path = ''; }
508
1235
  return new CollectionDictionary(this, path);
509
1236
  };
510
- AbstractCollection.prototype.indexBy = function (path) {
1237
+ Collection.prototype.indexBy = function (path) {
511
1238
  // Create empty initial object for groups
512
1239
  var result = {};
513
1240
  this.toArray().forEach(function (model) {
@@ -518,11 +1245,11 @@
518
1245
  /**
519
1246
  * Iterator that allow to iterate collection items
520
1247
  */
521
- AbstractCollection.prototype[Symbol.iterator] = function () {
1248
+ Collection.prototype[Symbol.iterator] = function () {
522
1249
  // .values() returns Iterator instance for array
523
1250
  return this.items.values();
524
1251
  };
525
- Object.defineProperty(AbstractCollection.prototype, "length", {
1252
+ Object.defineProperty(Collection.prototype, "length", {
526
1253
  /**
527
1254
  * get collection length
528
1255
  */
@@ -532,55 +1259,46 @@
532
1259
  enumerable: false,
533
1260
  configurable: true
534
1261
  });
535
- /**
536
- * method returns amount of fields from passed items
537
- * @param field Name of field for calculation
538
- * @param items (optional) Array of items need to be calculated. All collection's items by default
539
- */
540
- AbstractCollection.prototype.getSummary = function (field, items) {
541
- if (items === void 0) { items = this.toArray(); }
542
- return items.reduce(function (sum, item) { return sum += item[field]; }, 0);
543
- };
544
1262
  /**
545
1263
  * Get list of items ids
546
1264
  */
547
- AbstractCollection.prototype.getIds = function () {
1265
+ Collection.prototype.getIds = function () {
548
1266
  return this.items.map(function (item) { return item['id']; });
549
1267
  };
550
1268
  /**
551
1269
  * Get single item by id
552
1270
  */
553
- AbstractCollection.prototype.getById = function (id) {
1271
+ Collection.prototype.getById = function (id) {
554
1272
  return this.items.find(function (item) { return item['id'] === id; });
555
1273
  };
556
- AbstractCollection.prototype.getByIds = function (ids) {
1274
+ Collection.prototype.getByIds = function (ids) {
557
1275
  return this.items.filter(function (item) { return ids.includes(item['id']); });
558
1276
  };
559
1277
  /**
560
1278
  * Get total sum of items by field
561
1279
  * @param field Name of the field for sum
562
1280
  */
563
- AbstractCollection.prototype.sumBy = function (field) {
1281
+ Collection.prototype.sumBy = function (field) {
564
1282
  return +this.items.reduce(function (sum, item) { return sum + Number(item[field]); }, 0).toFixed(2);
565
1283
  };
566
- AbstractCollection.prototype.toArray = function () {
1284
+ Collection.prototype.toArray = function () {
567
1285
  return __spreadArray([], __read(this.items));
568
1286
  };
569
- Object.defineProperty(AbstractCollection.prototype, "first", {
1287
+ Object.defineProperty(Collection.prototype, "first", {
570
1288
  get: function () {
571
1289
  return first__default["default"](this.items);
572
1290
  },
573
1291
  enumerable: false,
574
1292
  configurable: true
575
1293
  });
576
- Object.defineProperty(AbstractCollection.prototype, "last", {
1294
+ Object.defineProperty(Collection.prototype, "last", {
577
1295
  get: function () {
578
1296
  return last__default["default"](this.items);
579
1297
  },
580
1298
  enumerable: false,
581
1299
  configurable: true
582
1300
  });
583
- return AbstractCollection;
1301
+ return Collection;
584
1302
  }());
585
1303
 
586
1304
  exports.BankAccountTypeEnum = void 0;
@@ -739,7 +1457,7 @@
739
1457
  }, 0);
740
1458
  };
741
1459
  return BankAccountCollection;
742
- }(AbstractCollection));
1460
+ }(Collection));
743
1461
 
744
1462
  exports.TransactionOperationEnum = void 0;
745
1463
  (function (TransactionOperationEnum) {
@@ -880,7 +1598,7 @@
880
1598
  return new BankTransactionCollection(this.items.filter(function (bankTransaction) { return !bankTransaction.isAllocated(allocations); }));
881
1599
  };
882
1600
  return BankTransactionCollection;
883
- }(AbstractCollection));
1601
+ }(Collection));
884
1602
 
885
1603
  var ClientCollection = /** @class */ (function (_super) {
886
1604
  __extends(ClientCollection, _super);
@@ -888,7 +1606,7 @@
888
1606
  return _super !== null && _super.apply(this, arguments) || this;
889
1607
  }
890
1608
  return ClientCollection;
891
- }(AbstractCollection));
1609
+ }(Collection));
892
1610
 
893
1611
  exports.FirmTypeEnum = void 0;
894
1612
  (function (FirmTypeEnum) {
@@ -917,7 +1635,7 @@
917
1635
  configurable: true
918
1636
  });
919
1637
  return EmployeeCollection;
920
- }(AbstractCollection));
1638
+ }(Collection));
921
1639
 
922
1640
  /**
923
1641
  * Collection of tax review
@@ -970,7 +1688,7 @@
970
1688
  return new ClientMovementCollection(this.items.filter(function (clientMovement) { return clientMovement.firm.type === firmType; }));
971
1689
  };
972
1690
  return ClientMovementCollection;
973
- }(AbstractCollection));
1691
+ }(Collection));
974
1692
 
975
1693
  var ClientPortfolioReportCollection = /** @class */ (function (_super) {
976
1694
  __extends(ClientPortfolioReportCollection, _super);
@@ -1035,7 +1753,7 @@
1035
1753
  return this.items.find(function (item) { return item.category === name; });
1036
1754
  };
1037
1755
  return ClientPortfolioReportCollection;
1038
- }(AbstractCollection));
1756
+ }(Collection));
1039
1757
 
1040
1758
  exports.TankTypeEnum = void 0;
1041
1759
  (function (TankTypeEnum) {
@@ -1122,7 +1840,7 @@
1122
1840
  })), 'id');
1123
1841
  };
1124
1842
  return DepreciationCollection;
1125
- }(AbstractCollection));
1843
+ }(Collection));
1126
1844
 
1127
1845
  /**
1128
1846
  * Collection of depreciations
@@ -1140,20 +1858,20 @@
1140
1858
  };
1141
1859
  Object.defineProperty(DepreciationForecastCollection.prototype, "amount", {
1142
1860
  get: function () {
1143
- return this.getSummary('amount');
1861
+ return this.sumBy('amount');
1144
1862
  },
1145
1863
  enumerable: false,
1146
1864
  configurable: true
1147
1865
  });
1148
1866
  Object.defineProperty(DepreciationForecastCollection.prototype, "claimAmount", {
1149
1867
  get: function () {
1150
- return this.getSummary('claimAmount');
1868
+ return this.sumBy('claimAmount');
1151
1869
  },
1152
1870
  enumerable: false,
1153
1871
  configurable: true
1154
1872
  });
1155
1873
  return DepreciationForecastCollection;
1156
- }(AbstractCollection));
1874
+ }(Collection));
1157
1875
 
1158
1876
  /**
1159
1877
  * Collection of income sources
@@ -1198,7 +1916,7 @@
1198
1916
  configurable: true
1199
1917
  });
1200
1918
  return IncomeSourceCollection;
1201
- }(AbstractCollection));
1919
+ }(Collection));
1202
1920
 
1203
1921
  var LoanCollection = /** @class */ (function (_super) {
1204
1922
  __extends(LoanCollection, _super);
@@ -1220,7 +1938,7 @@
1220
1938
  return this.items.find(function (loan) { var _a; return ((_a = loan.bankAccount) === null || _a === void 0 ? void 0 : _a.id) === id; });
1221
1939
  };
1222
1940
  return LoanCollection;
1223
- }(AbstractCollection));
1941
+ }(Collection));
1224
1942
 
1225
1943
  var FinancialYear = /** @class */ (function () {
1226
1944
  function FinancialYear(date) {
@@ -1414,7 +2132,7 @@
1414
2132
  return !!this.getUnread().length;
1415
2133
  };
1416
2134
  return MessageCollection;
1417
- }(AbstractCollection));
2135
+ }(Collection));
1418
2136
 
1419
2137
  /**
1420
2138
  * Collection of MessageDocument instances
@@ -1431,7 +2149,7 @@
1431
2149
  return new MessageDocumentCollection(this.items.filter(function (doc) { return !doc.message; }));
1432
2150
  };
1433
2151
  return MessageDocumentCollection;
1434
- }(AbstractCollection));
2152
+ }(Collection));
1435
2153
 
1436
2154
  var PropertyCollection = /** @class */ (function (_super) {
1437
2155
  __extends(PropertyCollection, _super);
@@ -1530,8 +2248,14 @@
1530
2248
  enumerable: false,
1531
2249
  configurable: true
1532
2250
  });
2251
+ /**
2252
+ * Get list of unique property categories from collection
2253
+ */
2254
+ PropertyCollection.prototype.getCategories = function () {
2255
+ return uniqBy__default["default"](this.items.map(function (property) { return property.category; }), 'id');
2256
+ };
1533
2257
  return PropertyCollection;
1534
- }(AbstractCollection));
2258
+ }(Collection));
1535
2259
 
1536
2260
  var ServicePriceCollection = /** @class */ (function (_super) {
1537
2261
  __extends(ServicePriceCollection, _super);
@@ -1553,7 +2277,7 @@
1553
2277
  configurable: true
1554
2278
  });
1555
2279
  return ServicePriceCollection;
1556
- }(AbstractCollection));
2280
+ }(Collection));
1557
2281
 
1558
2282
  var ServiceSubscriptionCollection = /** @class */ (function (_super) {
1559
2283
  __extends(ServiceSubscriptionCollection, _super);
@@ -1586,7 +2310,7 @@
1586
2310
  return (_a = this.items.filter(function (subscription) { return subscription.propertyQuantity === properties; })[0]) !== null && _a !== void 0 ? _a : this.investor;
1587
2311
  };
1588
2312
  return ServiceSubscriptionCollection;
1589
- }(AbstractCollection));
2313
+ }(Collection));
1590
2314
 
1591
2315
  exports.TaxReturnCategoryListEnum = void 0;
1592
2316
  (function (TaxReturnCategoryListEnum) {
@@ -1846,7 +2570,7 @@
1846
2570
  return this.items.find(function (item) { return item.taxReturnCategory.id === category; });
1847
2571
  };
1848
2572
  return TaxReturnCategoryItemCollection;
1849
- }(AbstractCollection));
2573
+ }(Collection));
1850
2574
 
1851
2575
  /**
1852
2576
  * Collection of tax review
@@ -1904,7 +2628,7 @@
1904
2628
  return uniqBy__default["default"](this.items.map(function (review) { return review.employee; }), 'id');
1905
2629
  };
1906
2630
  return TaxReviewCollection;
1907
- }(AbstractCollection));
2631
+ }(Collection));
1908
2632
 
1909
2633
  var TransactionAllocationCollection = /** @class */ (function (_super) {
1910
2634
  __extends(TransactionAllocationCollection, _super);
@@ -1952,7 +2676,7 @@
1952
2676
  return !!this.items.find(function (allocation) { return allocation.bankTransaction.id === bankTransaction.id; });
1953
2677
  };
1954
2678
  return TransactionAllocationCollection;
1955
- }(AbstractCollection));
2679
+ }(Collection));
1956
2680
 
1957
2681
  /**
1958
2682
  * Collection of transactions
@@ -2100,7 +2824,7 @@
2100
2824
  return new TransactionCollection(this.items.filter(function (transaction) { return allocations.hasTransaction(transaction); }));
2101
2825
  };
2102
2826
  return TransactionCollection;
2103
- }(AbstractCollection));
2827
+ }(Collection));
2104
2828
 
2105
2829
  /**
2106
2830
  * Collection of user event settings
@@ -2114,7 +2838,7 @@
2114
2838
  return new UserEventSettingCollection(this.items.filter(function (setting) { return setting[field] !== null; }));
2115
2839
  };
2116
2840
  return UserEventSettingCollection;
2117
- }(AbstractCollection));
2841
+ }(Collection));
2118
2842
 
2119
2843
  exports.ChartAccountsCategoryEnum = void 0;
2120
2844
  (function (ChartAccountsCategoryEnum) {
@@ -2321,8 +3045,7 @@
2321
3045
  ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["TAX_OFFSETS"] = 8] = "TAX_OFFSETS";
2322
3046
  ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["HOURS"] = 11] = "HOURS";
2323
3047
  ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["TAX_PAID"] = 13] = "TAX_PAID";
2324
- ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["REDUNDANCY"] = 17] = "REDUNDANCY";
2325
- ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["NON_REDUNDANCY"] = 18] = "NON_REDUNDANCY";
3048
+ ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["TAX_FREE_COMPONENT"] = 18] = "TAX_FREE_COMPONENT";
2326
3049
  ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["YEARS_OF_SERVICE"] = 19] = "YEARS_OF_SERVICE";
2327
3050
  ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["UNTAXED_ELEMENT"] = 24] = "UNTAXED_ELEMENT";
2328
3051
  ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["FRANKED"] = 26] = "FRANKED";
@@ -4884,10 +5607,14 @@
4884
5607
  // @TODO fix hack while transactions refactoring (use class-transformer)
4885
5608
  return +(Math.round(this.getIncomeAmountByType(exports.IncomeAmountTypeEnum.GROSS) * 100) / 100).toFixed(2);
4886
5609
  };
5610
+ Object.defineProperty(Transaction.prototype, "taxFreeComponent", {
5611
+ get: function () {
5612
+ return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.TAX_FREE_COMPONENT);
5613
+ },
5614
+ enumerable: false,
5615
+ configurable: true
5616
+ });
4887
5617
  Object.defineProperty(Transaction.prototype, "frankingCredit", {
4888
- /**
4889
- * find franking credits metadata and return value
4890
- */
4891
5618
  get: function () {
4892
5619
  return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.FRANKING_CREDIT);
4893
5620
  },
@@ -4912,6 +5639,20 @@
4912
5639
  enumerable: false,
4913
5640
  configurable: true
4914
5641
  });
5642
+ Object.defineProperty(Transaction.prototype, "debit", {
5643
+ get: function () {
5644
+ return this.isDebit() ? Math.abs(this.amount) : null;
5645
+ },
5646
+ enumerable: false,
5647
+ configurable: true
5648
+ });
5649
+ Object.defineProperty(Transaction.prototype, "credit", {
5650
+ get: function () {
5651
+ return this.isCredit() ? Math.abs(this.amount) : null;
5652
+ },
5653
+ enumerable: false,
5654
+ configurable: true
5655
+ });
4915
5656
  /**
4916
5657
  * Get value of transaction metadata field
4917
5658
  * @param field for which value should be returned
@@ -4935,7 +5676,7 @@
4935
5676
  (this.transactions
4936
5677
  .reduce(function (sum, transaction) { return sum + Math.abs(transaction.amount); }, 0) * modifier);
4937
5678
  case this.isWorkTank():
4938
- return this.amount + ((this.tax + this.frankingCredit) * modifier);
5679
+ return this.amount + ((this.tax + this.frankingCredit - this.taxFreeComponent) * modifier);
4939
5680
  default:
4940
5681
  return this.amount || 0;
4941
5682
  }
@@ -5642,6 +6383,36 @@
5642
6383
  return ClientPortfolioReport;
5643
6384
  }());
5644
6385
 
6386
+ exports.AlphabetColorsEnum = void 0;
6387
+ (function (AlphabetColorsEnum) {
6388
+ AlphabetColorsEnum["A"] = "#9CC3D5";
6389
+ AlphabetColorsEnum["B"] = "#E69A8D";
6390
+ AlphabetColorsEnum["C"] = "#ED2B33";
6391
+ AlphabetColorsEnum["D"] = "#E3CD81";
6392
+ AlphabetColorsEnum["E"] = "#343148";
6393
+ AlphabetColorsEnum["F"] = "#2C5F2D";
6394
+ AlphabetColorsEnum["G"] = "#FFA177";
6395
+ AlphabetColorsEnum["H"] = "#435E55";
6396
+ AlphabetColorsEnum["I"] = "#2BAE66";
6397
+ AlphabetColorsEnum["J"] = "#3C1053";
6398
+ AlphabetColorsEnum["K"] = "#DD4132";
6399
+ AlphabetColorsEnum["L"] = "#FC766A";
6400
+ AlphabetColorsEnum["M"] = "#ADEFD1";
6401
+ AlphabetColorsEnum["N"] = "#79C000";
6402
+ AlphabetColorsEnum["O"] = "#D198C5";
6403
+ AlphabetColorsEnum["P"] = "#5B84B1";
6404
+ AlphabetColorsEnum["Q"] = "#A13941";
6405
+ AlphabetColorsEnum["R"] = "#D85A7F";
6406
+ AlphabetColorsEnum["S"] = "#00203F";
6407
+ AlphabetColorsEnum["T"] = "#42EADD";
6408
+ AlphabetColorsEnum["U"] = "#5F4B8B";
6409
+ AlphabetColorsEnum["V"] = "#FDDB27";
6410
+ AlphabetColorsEnum["W"] = "#CDB599";
6411
+ AlphabetColorsEnum["X"] = "#4B878B";
6412
+ AlphabetColorsEnum["Y"] = "#B0B8B4";
6413
+ AlphabetColorsEnum["Z"] = "#E3C9CE";
6414
+ })(exports.AlphabetColorsEnum || (exports.AlphabetColorsEnum = {}));
6415
+
5645
6416
  /**
5646
6417
  * Class to generate data-table structure based on provided collection.
5647
6418
  * Use to work with HTML/PDF/XLSX tables
@@ -5676,9 +6447,11 @@
5676
6447
  if (!column.total) {
5677
6448
  return '';
5678
6449
  }
5679
- return collection.items
5680
- .reduce(function (sum, item) { return sum + Number(item[column.key]); }, 0)
5681
- .toString();
6450
+ var totalValue = collection.items.reduce(function (sum, item) {
6451
+ // check if current collection item has value. If not - don't add it to the sum
6452
+ return item[column.key] !== null ? sum + Number(item[column.key]) : sum;
6453
+ }, null);
6454
+ return (totalValue !== null && totalValue !== void 0 ? totalValue : '-').toString();
5682
6455
  });
5683
6456
  };
5684
6457
  return DataTable;
@@ -5848,211 +6621,40 @@
5848
6621
 
5849
6622
  var DocumentFolder$1 = /** @class */ (function () {
5850
6623
  function DocumentFolder() {
5851
- }
5852
- return DocumentFolder;
5853
- }());
5854
-
5855
- var DocumentFolder = /** @class */ (function (_super) {
5856
- __extends(DocumentFolder, _super);
5857
- function DocumentFolder() {
5858
- return _super !== null && _super.apply(this, arguments) || this;
5859
- }
5860
- return DocumentFolder;
5861
- }(DocumentFolder$1));
5862
- __decorate([
5863
- classTransformer.Type(function () { return Document; })
5864
- ], DocumentFolder.prototype, "documents", void 0);
5865
-
5866
- var EmployeeInvite$1 = /** @class */ (function () {
5867
- function EmployeeInvite() {
5868
- }
5869
- return EmployeeInvite;
5870
- }());
5871
-
5872
- var EmployeeInvite = /** @class */ (function (_super) {
5873
- __extends(EmployeeInvite, _super);
5874
- function EmployeeInvite() {
5875
- return _super !== null && _super.apply(this, arguments) || this;
5876
- }
5877
- return EmployeeInvite;
5878
- }(EmployeeInvite$1));
5879
- __decorate([
5880
- classTransformer.Type(function () { return RegistrationInvite; })
5881
- ], EmployeeInvite.prototype, "registrationInvite", void 0);
5882
- __decorate([
5883
- classTransformer.Type(function () { return User; })
5884
- ], EmployeeInvite.prototype, "employee", void 0);
5885
-
5886
- /**
5887
- * Backend endpoint class
5888
- */
5889
- var Endpoint = /** @class */ (function () {
5890
- function Endpoint(method, pattern) {
5891
- this.method = method;
5892
- this.pattern = pattern;
5893
- }
5894
- /**
5895
- * check url with regexp
5896
- * @param url
5897
- */
5898
- Endpoint.prototype.test = function (url) {
5899
- return this.regexp.test(url);
5900
- };
5901
- Object.defineProperty(Endpoint.prototype, "regexp", {
5902
- /**
5903
- * Get regexp for endpoint
5904
- */
5905
- get: function () {
5906
- return new RegExp("^" + this.method + " .*" + this.pattern + "$");
5907
- },
5908
- enumerable: false,
5909
- configurable: true
5910
- });
5911
- return Endpoint;
5912
- }());
5913
-
5914
- /**
5915
- * List of all app endpoints
5916
- */
5917
- var ENDPOINTS = {
5918
- ASSETS_GET: new Endpoint('GET', '\\/assets\\/\.\*\\/\\d+'),
5919
- BANK_ACCOUNTS_GET: new Endpoint('GET', '\\/bank-accounts'),
5920
- BANK_ACCOUNTS_POST: new Endpoint('POST', '\\/bank-accounts'),
5921
- BANK_ACCOUNTS_PUT: new Endpoint('PUT', '\\/bank-accounts\\/\\d+'),
5922
- BANK_CONNECTION_POST: new Endpoint('POST', '\\/bank-connections'),
5923
- BANK_TRANSACTIONS_GET: new Endpoint('GET', '\\/bank-transactions'),
5924
- BANK_TRANSACTIONS_DELETE: new Endpoint('DELETE', '\\/bank-transactions\\/\\d+'),
5925
- BANK_TRANSACTIONS_IMPORT_POST: new Endpoint('POST', '\\/bank-transactions\\/\\d+\\/import'),
5926
- BASIQ_ACCOUNTS_GET: new Endpoint('GET', '\\/basiq\\/\\accounts'),
5927
- CAPITAL_COSTS_GET: new Endpoint('GET', '\\/capital-costs'),
5928
- CHARTS_INCOME_GET: new Endpoint('GET', '\\/charts\\/\\incomes'),
5929
- CHARTS_EXPENSES_GET: new Endpoint('GET', '\\/charts\\/\\expenses'),
5930
- CHART_ACCOUNTS_GET: new Endpoint('GET', '\\/chart-accounts'),
5931
- CLIENTS_GET: new Endpoint('GET', '\\/clients'),
5932
- CLIENTS_PUT: new Endpoint('PUT', '\\/clients'),
5933
- CLIENTS_EXCLUDE_PUT: new Endpoint('PUT', '\\/clients\\/\\d+\\/exclude'),
5934
- CLIENTS_INVITES_GET: new Endpoint('GET', '\\/clients\\/\\invites'),
5935
- CLIENTS_INVITES_POST: new Endpoint('POST', '\\/clients\\/\\invites'),
5936
- CLIENTS_INVITES_DELETE: new Endpoint('DELETE', '\\/clients\\/\\invites\\/\\d+'),
5937
- CLIENTS_INVITES_ACCEPT_POST: new Endpoint('POST', '\\/clients\\/\\invites\\/\\d+\\/accept'),
5938
- CLIENTS_INVITES_REJECT_POST: new Endpoint('POST', '\\/clients\\/\\invites\\/\\d+\\/reject'),
5939
- CLIENTS_INVITES_RESEND_POST: new Endpoint('POST', '\\/clients\\/\\invites\\/\\d+\\/resend'),
5940
- CLIENT_MOVEMENTS_GET: new Endpoint('GET', '\\/client-movements'),
5941
- CLIENT_MOVEMENTS_POST: new Endpoint('POST', '\\/client-movements'),
5942
- COUNTRIES_GET: new Endpoint('GET', '\\/countries'),
5943
- DEPRECIATIONS_CLOSING_GET: new Endpoint('GET', '\\/depreciations\\/\\closing-balance\.\*'),
5944
- DEPRECIATIONS_GET: new Endpoint('GET', '\\/depreciations'),
5945
- DEPRECIATIONS_POST: new Endpoint('POST', '\\/depreciations'),
5946
- DEPRECIATIONS_PUT: new Endpoint('PUT', '\\/depreciations\\/\\d+'),
5947
- EMPLOYEES_GET: new Endpoint('GET', '\\/employees'),
5948
- EMPLOYEES_INVITES_GET: new Endpoint('GET', '\\/employees\\/\\invites'),
5949
- EMPLOYEES_INVITES_DELETE: new Endpoint('DELETE', '\\/employees\\/\\invites\\/\\d+'),
5950
- EMPLOYEES_INVITE_POST: new Endpoint('POST', '\\/employees\\/\\invites'),
5951
- EMPLOYEES_INVITES_REJECT_POST: new Endpoint('POST', '\\/employees\\/\\invites\\/\\d+\\/\\reject'),
5952
- EMPLOYEES_INVITES_RESEND_POST: new Endpoint('POST', '\\/employees\\/\\invites\\/\\d+\\/\\resend'),
5953
- FIRM_GET: new Endpoint('GET', '\\/firms'),
5954
- FIRM_CURRENT_GET: new Endpoint('GET', '\\/firms\\/current'),
5955
- FIRM_CURRENT_PUT: new Endpoint('PUT', '\\/firms\\/current\.\*'),
5956
- FIRM_INVITE_POST: new Endpoint('POST', '\\/firms\\/invite'),
5957
- FIRM_REGISTRATION_POST: new Endpoint('POST', '\\/firms\\/registration'),
5958
- FIRM_UPDATE_PHOTO_POST: new Endpoint('POST', '\\/firms\\/photo\.\*'),
5959
- FOLDERS_GET: new Endpoint('GET', '\\/folders'),
5960
- FOLDERS_POST: new Endpoint('POST', '\\/folders'),
5961
- FOLDERS_PUT: new Endpoint('PUT', '\\/folders\\/\\d+'),
5962
- FOLDERS_DOCUMENTS_POST: new Endpoint('POST', '\\/folders\\/\\d+\\/documents'),
5963
- FOLDERS_DOCUMENTS_PUT: new Endpoint('PUT', '\\/folders\\/\\d+\\/documents\\/\\d+'),
5964
- INCOME_SOURCES_GET: new Endpoint('GET', '\\/income-sources'),
5965
- INCOME_SOURCES_POST: new Endpoint('POST', '\\/income-sources'),
5966
- INCOME_SOURCES_PUT: new Endpoint('PUT', '\\/income-sources'),
5967
- INCOME_SOURCES_DELETE: new Endpoint('DELETE', '\\/income-sources\\/\\d+'),
5968
- INCOME_SOURCE_FORECAST_GET: new Endpoint('GET', '\\/income-source-forecasts'),
5969
- INCOME_SOURCE_FORECAST_POST: new Endpoint('POST', '\\/income-source-forecasts'),
5970
- INCOME_SOURCE_FORECAST_PUT: new Endpoint('PUT', '\\/income-source-forecasts'),
5971
- INCOME_SOURCE_FORECAST_DELETE: new Endpoint('DELETE', '\\/income-source-forecasts\\/\\d+'),
5972
- INCOME_SOURCE_TYPES_GET: new Endpoint('GET', '\\/income-source-types'),
5973
- LOANS_GET: new Endpoint('GET', '\\/bank-accounts\\/loans'),
5974
- LOANS_POST: new Endpoint('POST', '\\/bank-accounts\\/loans'),
5975
- LOANS_PUT: new Endpoint('PUT', '\\/bank-accounts\\/loans/\\d+'),
5976
- LOANS_PAYOUT_POST: new Endpoint('POST', '\\/loans\\/\\d+\\/payout'),
5977
- LOANS_PAYOUT_PUT: new Endpoint('PUT', '\\/loans\\/\\d+\\/payout\\/\\d+'),
5978
- LOANS_PAYOUT_DELETE: new Endpoint('DELETE', '\\/loans\\/\\d+\\/payout\\/\\d+'),
5979
- LOANS_CALCULATION_POST: new Endpoint('POST', '\\/bank-accounts\\/loans\\/calculation'),
5980
- LOGIN_CHECK_POST: new Endpoint('POST', '\\/login_check'),
5981
- NOTIFICATIONS_GET: new Endpoint('GET', '\\/service-notifications'),
5982
- OCCUPATIONS_GET: new Endpoint('GET', '\\/occupations'),
5983
- PROPERTIES_GET: new Endpoint('GET', '\\/properties'),
5984
- PROPERTIES_POST: new Endpoint('POST', '\\/properties'),
5985
- PROPERTY_PUT: new Endpoint('PUT', '\\/properties/\\d+'),
5986
- PROPERTIES_PUT: new Endpoint('PUT', '\\/properties'),
5987
- PROPERTIES_CATEGORIES_EQUITY_GET: new Endpoint('GET', '\\/properties\\/categories\\/equity'),
5988
- PROPERTIES_CATEGORIES_GET: new Endpoint('GET', '\\/properties\\/categories'),
5989
- PROPERTIES_CATEGORIES_PUT: new Endpoint('PUT', '\\/properties\\/categories\\/\\d+'),
5990
- PROPERTIES_CATEGORIES_POST: new Endpoint('POST', '\\/properties\\/categories'),
5991
- PROPERTIES_CATEGORY_MOVEMENTS_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/category-movements'),
5992
- PROPERTIES_CATEGORY_MOVEMENTS_PUT: new Endpoint('PUT', '\\/properties\\/\\d+\\/category-movements\\/\\d+'),
5993
- PROPERTIES_CO_OWNERS_PUT: new Endpoint('PUT', '\\/properties\\/co-owners\\/\\d+'),
5994
- PROPERTIES_CO_OWNERS_GET: new Endpoint('GET', '\\/properties\\/co-owners'),
5995
- PROPERTIES_CO_OWNERS_POST: new Endpoint('POST', '\\/properties\\/co-owners'),
5996
- PROPERTIES_DEACTIVATE_PUT: new Endpoint('PUT', '\\/properties\\/\\d+\\/deactivate'),
5997
- PROPERTIES_DEPRECIATION_CAPITAL_PROJECT_GET: new Endpoint('GET', '\\/properties\\/\\d+\\/depreciation-capital-projects'),
5998
- PROPERTIES_DEPRECIATION_CAPITAL_PROJECT_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/depreciation-capital-projects'),
5999
- PROPERTIES_DEPRECIATION_CAPITAL_PROJECT_PUT: new Endpoint('PUT', '\\/properties\\/\\d+\\/depreciation-capital-projects\\/\\d+'),
6000
- PROPERTIES_DEPRECIATION_CAPITAL_PROJECT_DELETE: new Endpoint('DELETE', '\\/properties\\/\\d+\\/depreciation-capital-projects\\/\\d+'),
6001
- PROPERTIES_DOCUMENTS_GET: new Endpoint('GET', '\\/properties\\/documents'),
6002
- PROPERTIES_DOCUMENTS_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/documents'),
6003
- PROPERTIES_DOCUMENTS_PUT: new Endpoint('PUT', '\\/properties\\/documents\\/\\d+'),
6004
- PROPERTIES_DOCUMENTS_DELETE: new Endpoint('DELETE', '\\/properties\\/documents\\/\\d+'),
6005
- PROPERTIES_PHOTO_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/photo\.\*'),
6006
- PROPERTIES_SUGGESTIONS_GET: new Endpoint('GET', '/property\\/\\w+\\/v2\\/.*$'),
6007
- PROPERTIES_VALUATIONS_DOCUMENTS_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/valuations\\/\\d+\\/documents'),
6008
- PRORATION_COST_POST: new Endpoint('POST', '\\/subscriptions\\/proration-cost'),
6009
- SALARY_FORECAST_GET: new Endpoint('GET', '\\/salary-forecasts'),
6010
- SALARY_FORECAST_POST: new Endpoint('POST', '\\/salary-forecasts'),
6011
- SALARY_FORECAST_PUT: new Endpoint('PUT', '\\/salary-forecasts'),
6012
- SERVICE_PRICES_GET: new Endpoint('GET', '\\/service-prices'),
6013
- SERVICE_PAYMENTS_GET: new Endpoint('GET', '\\/service-payments'),
6014
- STRIPE_BILLING_PORTAL_GET: new Endpoint('GET', '\\/stripe\\/billing-portal-session'),
6015
- STRIPE_CHECKOUT_SESSION_POST: new Endpoint('POST', '\\/stripe\\/checkout-session'),
6016
- SUBSCRIPTION_LAST_GET: new Endpoint('GET', '\\/subscriptions\\/last'),
6017
- SUBSCRIPTION_ITEMS_PUT: new Endpoint('PUT', '\\/subscriptions\\/items'),
6018
- TAX_CALCULATION_POST: new Endpoint('POST', '\\/tax-calculation'),
6019
- TAX_REVIEWS_GET: new Endpoint('GET', '\\/tax-reviews'),
6020
- TAX_REVIEWS_DELETE: new Endpoint('DELETE', '\\/tax-reviews\\/\\d+'),
6021
- TAX_REVIEWS_POST: new Endpoint('POST', '\\/tax-reviews'),
6022
- TAX_REVIEWS_PUT: new Endpoint('PUT', '\\/tax-reviews\\/\\d+'),
6023
- TAX_SUMMARY_ACTUAL_GET: new Endpoint('GET', '\\/tax-summary\\/actuals'),
6024
- TAX_SUMMARY_FORECAST_GET: new Endpoint('GET', '\\/tax-summary\\/forecasts'),
6025
- TRANSACTION_DELETE: new Endpoint('DELETE', '\\/transactions\\/\\d+'),
6026
- TRANSACTION_PUT: new Endpoint('PUT', '\\/transactions\\/\\d+'),
6027
- TRANSACTIONS_GET: new Endpoint('GET', '\\/transactions'),
6028
- TRANSACTIONS_POST: new Endpoint('POST', '\\/transactions'),
6029
- TRANSACTIONS_PUT: new Endpoint('PUT', '\\/transactions'),
6030
- TRANSACTIONS_ALLOCATIONS_GET: new Endpoint('GET', '\\/transactions-allocations'),
6031
- TRANSACTIONS_ALLOCATIONS_POST: new Endpoint('POST', '\\/transactions-allocations'),
6032
- TRANSACTIONS_ALLOCATIONS_DELETE: new Endpoint('DELETE', '\\/transactions-allocations\\/\\d+'),
6033
- USER_CONFIRMATION_POST: new Endpoint('POST', '\\/users\\/confirmation'),
6034
- USER_CURRENT_GET: new Endpoint('GET', '\\/users\\/current'),
6035
- USER_CURRENT_PASSWORD_PUT: new Endpoint('PUT', '\\/users\\/current\\/password\.\*'),
6036
- USER_EVENT_SETTINGS_GET: new Endpoint('GET', '\\/user-event-settings'),
6037
- USER_EVENT_TYPES_GET: new Endpoint('GET', '\\/user-event-types'),
6038
- USER_INVITE_DELETE: new Endpoint('DELETE', '\\/users\\/invite\\/\\d+'),
6039
- USER_INVITE_POST: new Endpoint('POST', '\\/users\\/invite'),
6040
- USER_INVITE_RESEND_POST: new Endpoint('POST', '\\/users\\/invite/\\d+\\/resend'),
6041
- USER_PUT: new Endpoint('PUT', '\\/users\\/\\d+'),
6042
- USER_REGISTRATION_POST: new Endpoint('POST', '\\/users\\/registration'),
6043
- USER_RESET_PASSWORD_PUT: new Endpoint('PUT', '\\/users\\/reset-password'),
6044
- USER_SEARCH_GET: new Endpoint('GET', '\\/users\\/search\.\*'),
6045
- USER_UPDATE_PHOTO_POST: new Endpoint('POST', '\\/users\\/photo\.\*'),
6046
- USER_STATUS_PUT: new Endpoint('PUT', '\\/users\\/status'),
6047
- VEHICLES_GET: new Endpoint('GET', '\\/vehicles'),
6048
- VEHICLES_POST: new Endpoint('POST', '\\/vehicles'),
6049
- VEHICLES_PUT: new Endpoint('PUT', '\\/vehicles\\/\\d+'),
6050
- VEHICLE_CLAIMS_GET: new Endpoint('GET', '\\/vehicle-claims'),
6051
- VEHICLE_CLAIMS_POST: new Endpoint('POST', '\\/vehicle-claims'),
6052
- VEHICLE_LOGBOOK_POST: new Endpoint('POST', '\\/vehicles\\/\\d+\\/logbooks'),
6053
- VEHICLE_LOGBOOK_PUT: new Endpoint('PUT', '\\/vehicles\\/\\d+\\/logbooks\\/\\d+'),
6054
- VEHICLE_CLAIMS_PUT: new Endpoint('PUT', '\\/vehicle-claims\\/\\d+')
6055
- };
6624
+ }
6625
+ return DocumentFolder;
6626
+ }());
6627
+
6628
+ var DocumentFolder = /** @class */ (function (_super) {
6629
+ __extends(DocumentFolder, _super);
6630
+ function DocumentFolder() {
6631
+ return _super !== null && _super.apply(this, arguments) || this;
6632
+ }
6633
+ return DocumentFolder;
6634
+ }(DocumentFolder$1));
6635
+ __decorate([
6636
+ classTransformer.Type(function () { return Document; })
6637
+ ], DocumentFolder.prototype, "documents", void 0);
6638
+
6639
+ var EmployeeInvite$1 = /** @class */ (function () {
6640
+ function EmployeeInvite() {
6641
+ }
6642
+ return EmployeeInvite;
6643
+ }());
6644
+
6645
+ var EmployeeInvite = /** @class */ (function (_super) {
6646
+ __extends(EmployeeInvite, _super);
6647
+ function EmployeeInvite() {
6648
+ return _super !== null && _super.apply(this, arguments) || this;
6649
+ }
6650
+ return EmployeeInvite;
6651
+ }(EmployeeInvite$1));
6652
+ __decorate([
6653
+ classTransformer.Type(function () { return RegistrationInvite; })
6654
+ ], EmployeeInvite.prototype, "registrationInvite", void 0);
6655
+ __decorate([
6656
+ classTransformer.Type(function () { return User; })
6657
+ ], EmployeeInvite.prototype, "employee", void 0);
6056
6658
 
6057
6659
  /**
6058
6660
  * any event happened in the app, which needs to be handled somehow (distributed to other part of the app)
@@ -6329,6 +6931,12 @@
6329
6931
  enumerable: false,
6330
6932
  configurable: true
6331
6933
  });
6934
+ /**
6935
+ * Claim amount for Kms method
6936
+ */
6937
+ VehicleClaim.prototype.getKmsClaimAmount = function (vehicleClaimRate) {
6938
+ return +(this.kilometers * vehicleClaimRate).toFixed(2);
6939
+ };
6332
6940
  return VehicleClaim;
6333
6941
  }(VehicleClaim$1));
6334
6942
 
@@ -6463,16 +7071,6 @@
6463
7071
  }),
6464
7072
  ];
6465
7073
 
6466
- /**
6467
- * https://api-uat.corelogic.asia/property/au/v2/suggest.json
6468
- * address suggestion from corelogic service
6469
- */
6470
- var CorelogicSuggestion = /** @class */ (function () {
6471
- function CorelogicSuggestion() {
6472
- }
6473
- return CorelogicSuggestion;
6474
- }());
6475
-
6476
7074
  /**
6477
7075
  * Enum with properties ownership filter options
6478
7076
  */
@@ -7232,44 +7830,6 @@
7232
7830
  }] }];
7233
7831
  } });
7234
7832
 
7235
- var KEY = '_switch_user';
7236
- /**
7237
- * provides user management to managers (users with ROLE_ACCOUNTANT for now, more in future)
7238
- */
7239
- var UserSwitcherService = /** @class */ (function () {
7240
- function UserSwitcherService() {
7241
- }
7242
- /**
7243
- * get switched username
7244
- */
7245
- UserSwitcherService.prototype.get = function () {
7246
- return localStorage[KEY];
7247
- };
7248
- /**
7249
- * switch to user (username should be used for correct work of backend)
7250
- */
7251
- UserSwitcherService.prototype.set = function (username) {
7252
- localStorage[KEY] = username;
7253
- window.location.replace('/client/dashboard');
7254
- };
7255
- /**
7256
- * go back to original user
7257
- */
7258
- UserSwitcherService.prototype.reset = function () {
7259
- localStorage.removeItem(KEY);
7260
- window.location.replace('/firm/dashboard');
7261
- };
7262
- return UserSwitcherService;
7263
- }());
7264
- UserSwitcherService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserSwitcherService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
7265
- UserSwitcherService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserSwitcherService, providedIn: 'root' });
7266
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserSwitcherService, decorators: [{
7267
- type: i0.Injectable,
7268
- args: [{
7269
- providedIn: 'root'
7270
- }]
7271
- }] });
7272
-
7273
7833
  /**
7274
7834
  * Service to work with assets (documents, receipts, e.t.c.)
7275
7835
  */
@@ -7320,90 +7880,6 @@
7320
7880
  }] }];
7321
7881
  } });
7322
7882
 
7323
- var NAME_TOKEN = 'token';
7324
- var NAME_REFRESH_TOKEN = 'refreshToken';
7325
- var JwtService = /** @class */ (function (_super) {
7326
- __extends(JwtService, _super);
7327
- function JwtService() {
7328
- return _super !== null && _super.apply(this, arguments) || this;
7329
- }
7330
- JwtService.prototype.getToken = function () {
7331
- return localStorage[NAME_TOKEN];
7332
- };
7333
- JwtService.prototype.getRefreshToken = function () {
7334
- return localStorage[NAME_REFRESH_TOKEN];
7335
- };
7336
- JwtService.prototype.saveTokens = function (tokens) {
7337
- localStorage[NAME_TOKEN] = tokens.token;
7338
- localStorage[NAME_REFRESH_TOKEN] = tokens.refreshToken;
7339
- };
7340
- JwtService.prototype.destroyTokens = function () {
7341
- localStorage.removeItem(NAME_TOKEN);
7342
- localStorage.removeItem(NAME_REFRESH_TOKEN);
7343
- };
7344
- JwtService.prototype.getUser = function () {
7345
- return this.decodeToken();
7346
- };
7347
- JwtService.prototype.isMe = function (userId) {
7348
- return this.getUser().id === userId;
7349
- };
7350
- return JwtService;
7351
- }(angularJwt.JwtHelperService));
7352
- JwtService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: JwtService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
7353
- JwtService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: JwtService, providedIn: 'root' });
7354
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: JwtService, decorators: [{
7355
- type: i0.Injectable,
7356
- args: [{
7357
- providedIn: 'root'
7358
- }]
7359
- }] });
7360
-
7361
- var AuthService = /** @class */ (function () {
7362
- function AuthService(http, jwtService, environment) {
7363
- this.http = http;
7364
- this.jwtService = jwtService;
7365
- this.environment = environment;
7366
- this.isLoggedInSubject = new rxjs.BehaviorSubject(!this.jwtService.isTokenExpired());
7367
- }
7368
- AuthService.prototype.setAuth = function (response) {
7369
- this.jwtService.saveTokens(response);
7370
- this.isLoggedInSubject.next(true);
7371
- };
7372
- AuthService.prototype.login = function (username, password) {
7373
- var _this = this;
7374
- return this.http.post(this.environment.apiV2 + "/login_check", { username: username, password: password }).pipe(operators.map(function (response) {
7375
- _this.setAuth(response);
7376
- return response;
7377
- }));
7378
- };
7379
- AuthService.prototype.refresh = function (refreshToken) {
7380
- var _this = this;
7381
- return this.http.post(this.environment.apiV2 + "/token/refresh", { refreshToken: refreshToken }).pipe(operators.map(function (response) {
7382
- _this.setAuth(response);
7383
- return response;
7384
- }));
7385
- };
7386
- AuthService.prototype.logoutFront = function (url) {
7387
- if (url === void 0) { url = '/login'; }
7388
- localStorage.clear();
7389
- location.replace(url);
7390
- };
7391
- return AuthService;
7392
- }());
7393
- AuthService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AuthService, deps: [{ token: i1__namespace.HttpClient }, { token: JwtService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
7394
- AuthService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AuthService, providedIn: 'root' });
7395
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AuthService, decorators: [{
7396
- type: i0.Injectable,
7397
- args: [{
7398
- providedIn: 'root'
7399
- }]
7400
- }], ctorParameters: function () {
7401
- return [{ type: i1__namespace.HttpClient }, { type: JwtService }, { type: undefined, decorators: [{
7402
- type: i0.Inject,
7403
- args: ['environment']
7404
- }] }];
7405
- } });
7406
-
7407
7883
  // replace array element with the new one (only arrays of objects)
7408
7884
  function replace(array, item, matchField) {
7409
7885
  if (matchField === void 0) { matchField = 'id'; }
@@ -7776,6 +8252,12 @@
7776
8252
  return updatedBankAccount;
7777
8253
  }));
7778
8254
  };
8255
+ BankAccountService.prototype.getOwn = function () {
8256
+ return this.get()
8257
+ .pipe(operators.map(function (bankAccounts) {
8258
+ return bankAccounts.filter(function (bankAccount) { return bankAccount.isOwner(+localStorage.getItem('userId')); });
8259
+ }));
8260
+ };
7779
8261
  /**
7780
8262
  * Listen to EventDispatcherService events
7781
8263
  */
@@ -9874,14 +10356,47 @@
9874
10356
  document.save(fileName + ".pdf");
9875
10357
  };
9876
10358
  /**
10359
+ * @Todo rename when all DataTable dependent methods will be cleared-up
10360
+ */
10361
+ PdfService.prototype.exportTables = function (tables, title, fileName) {
10362
+ var document = this.generateFromTables(tables, title);
10363
+ document.save(fileName + ".pdf");
10364
+ };
10365
+ /**
10366
+ * @Todo rename when all DataTable dependent methods will be cleared-up
10367
+ */
10368
+ PdfService.prototype.generateFromTables = function (tables, title) {
10369
+ var pdf = new jsPDF__default["default"]();
10370
+ // set document title
10371
+ pdf.setFontSize(PDF_CONFIG.text.fontSize)
10372
+ .setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight)
10373
+ .text(title, PDF_CONFIG.text.positionX, PDF_CONFIG.text.positionY);
10374
+ tables.forEach(function (table) {
10375
+ // coords of last table
10376
+ var lastTableCoords = pdf['lastAutoTable'].finalY || PDF_CONFIG.contentCoords.marginTop;
10377
+ // table options
10378
+ var options = {
10379
+ html: table,
10380
+ startY: lastTableCoords + PDF_CONFIG.contentTitleCoords.marginTop,
10381
+ footStyles: {
10382
+ fillColor: PDF_CONFIG.text.fillColor,
10383
+ textColor: PDF_CONFIG.text.textColor
10384
+ }
10385
+ };
10386
+ autoTable__default["default"](pdf, options);
10387
+ });
10388
+ return pdf;
10389
+ };
10390
+ /**
10391
+ * @Todo remove/refactor when all DataTable dependent methods will be cleared-up
9877
10392
  * Generate PDF file from provided data
9878
10393
  */
9879
10394
  PdfService.prototype.generatePdfFile = function (tables, title) {
9880
10395
  var pdf = new jsPDF__default["default"]();
9881
- // set document title
9882
- pdf.setFontSize(PDF_CONFIG.text.fontSize);
9883
- pdf.setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight);
9884
- pdf.text(title, PDF_CONFIG.text.positionX, PDF_CONFIG.text.positionY);
10396
+ // set document font params
10397
+ pdf.setFontSize(PDF_CONFIG.text.fontSize)
10398
+ .setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight)
10399
+ .text(title, PDF_CONFIG.text.positionX, PDF_CONFIG.text.positionY);
9885
10400
  tables.forEach(function (table) {
9886
10401
  // coords of last table
9887
10402
  var lastTableCoords = pdf['lastAutoTable'].finalY || PDF_CONFIG.contentCoords.marginTop;
@@ -9912,68 +10427,36 @@
9912
10427
  }]
9913
10428
  }] });
9914
10429
 
9915
- var PreloaderService = /** @class */ (function () {
9916
- function PreloaderService() {
9917
- this.activePreloaders = new rxjs.BehaviorSubject([]);
9918
- }
9919
- PreloaderService.prototype.get = function () {
9920
- return this.activePreloaders.asObservable();
9921
- };
9922
- PreloaderService.prototype.add = function (endpoint) {
9923
- var activePreloaders = this.activePreloaders.getValue();
9924
- activePreloaders.push(endpoint);
9925
- this.activePreloaders.next(activePreloaders);
9926
- };
9927
- PreloaderService.prototype.delete = function (endpoint) {
9928
- var activePreloaders = this.activePreloaders.getValue();
9929
- activePreloaders = activePreloaders.filter(function (preloader) { return preloader !== endpoint; });
9930
- this.activePreloaders.next(activePreloaders);
9931
- };
9932
- return PreloaderService;
9933
- }());
9934
- PreloaderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PreloaderService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
9935
- PreloaderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PreloaderService, providedIn: 'root' });
9936
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PreloaderService, decorators: [{
9937
- type: i0.Injectable,
9938
- args: [{
9939
- providedIn: 'root'
9940
- }]
9941
- }], ctorParameters: function () { return []; } });
9942
-
9943
- var CorelogicService = /** @class */ (function () {
9944
- function CorelogicService(http, environment) {
10430
+ /**
10431
+ * Service for get property equity position half-year history chart data
10432
+ */
10433
+ var EquityPositionChartService = /** @class */ (function () {
10434
+ function EquityPositionChartService(http, environment) {
9945
10435
  this.http = http;
9946
10436
  this.environment = environment;
9947
- this.accessTokenSubject = new rxjs.ReplaySubject(1);
9948
10437
  }
9949
- CorelogicService.prototype.getAccessToken = function (force) {
9950
- var _this = this;
9951
- if (force === void 0) { force = false; }
9952
- if (!this._accessToken || force) {
9953
- this.http.get(this.environment.coreLogicUrl + "/access/oauth/token?grant_type=client_credentials&client_id=" + this.environment.coreLogicId + "&client_secret=" + this.environment.coreLogicSecret)
9954
- .pipe(operators.map(function (response) {
9955
- return response.access_token;
9956
- }))
9957
- .subscribe(function (token) {
9958
- _this._accessToken = token;
9959
- _this.accessTokenSubject.next(_this._accessToken);
9960
- });
9961
- }
9962
- return this.accessTokenSubject.asObservable();
9963
- };
9964
- CorelogicService.prototype.getSuggestions = function (query, country) {
9965
- if (country === void 0) { country = 'au'; }
9966
- // @TODO handle different countries in future
9967
- return this.http.get(this.environment.coreLogicUrl + "/property/" + country + "/v2/suggest.json?q=" + query)
10438
+ EquityPositionChartService.prototype.get = function () {
10439
+ // @TODO refactor backend
10440
+ return this.http.get(this.environment.apiV2 + "/properties/categories/equity")
9968
10441
  .pipe(operators.map(function (response) {
9969
- return response.suggestions.map(function (item) { return classTransformer.plainToClass(CorelogicSuggestion, item); });
10442
+ return response.map(function (item) {
10443
+ return classTransformer.plainToClass(ChartData, {
10444
+ name: item.category.name,
10445
+ data: item.equity.map(function (serie) {
10446
+ return classTransformer.plainToClass(ChartSerie, {
10447
+ label: serie.date,
10448
+ value: serie.amount
10449
+ });
10450
+ })
10451
+ });
10452
+ });
9970
10453
  }));
9971
10454
  };
9972
- return CorelogicService;
10455
+ return EquityPositionChartService;
9973
10456
  }());
9974
- CorelogicService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: CorelogicService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
9975
- CorelogicService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: CorelogicService, providedIn: 'root' });
9976
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: CorelogicService, decorators: [{
10457
+ EquityPositionChartService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: EquityPositionChartService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
10458
+ EquityPositionChartService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: EquityPositionChartService, providedIn: 'root' });
10459
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: EquityPositionChartService, decorators: [{
9977
10460
  type: i0.Injectable,
9978
10461
  args: [{
9979
10462
  providedIn: 'root'
@@ -11914,7 +12397,6 @@
11914
12397
  * Generated bundle index. Do not edit.
11915
12398
  */
11916
12399
 
11917
- exports.AbstractCollection = AbstractCollection;
11918
12400
  exports.Address = Address;
11919
12401
  exports.AddressService = AddressService;
11920
12402
  exports.AppEvent = AppEvent;
@@ -11967,6 +12449,7 @@
11967
12449
  exports.ClientPortfolioReport = ClientPortfolioReport;
11968
12450
  exports.ClientPortfolioReportCollection = ClientPortfolioReportCollection;
11969
12451
  exports.ClientPortfolioReportService = ClientPortfolioReportService;
12452
+ exports.Collection = Collection;
11970
12453
  exports.CollectionDictionary = CollectionDictionary;
11971
12454
  exports.CorelogicService = CorelogicService;
11972
12455
  exports.CorelogicSuggestion = CorelogicSuggestion;
@@ -11995,6 +12478,7 @@
11995
12478
  exports.EmployeeInviteService = EmployeeInviteService;
11996
12479
  exports.EmployeeService = EmployeeService;
11997
12480
  exports.Endpoint = Endpoint;
12481
+ exports.EquityPositionChartService = EquityPositionChartService;
11998
12482
  exports.EventDispatcherService = EventDispatcherService;
11999
12483
  exports.FinancialYear = FinancialYear;
12000
12484
  exports.Firm = Firm;
@@ -12008,6 +12492,7 @@
12008
12492
  exports.IncomeSourceForecastService = IncomeSourceForecastService;
12009
12493
  exports.IncomeSourceService = IncomeSourceService;
12010
12494
  exports.IncomeSourceType = IncomeSourceType;
12495
+ exports.InterceptorsModule = InterceptorsModule;
12011
12496
  exports.IntercomService = IntercomService;
12012
12497
  exports.JwtService = JwtService;
12013
12498
  exports.Loan = Loan;