taxtank-core 0.28.1 → 0.28.4

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 (31) hide show
  1. package/bundles/taxtank-core.umd.js +343 -245
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/vehicle/vehicle-logbook.collection.js +2 -2
  4. package/esm2015/lib/db/Models/sole/sole-business-loss.js +1 -1
  5. package/esm2015/lib/forms/sole/sole-business.form.js +11 -2
  6. package/esm2015/lib/forms/sole/sole-details.form.js +3 -2
  7. package/esm2015/lib/interceptors/basiq-client-id.interceptor.js +31 -0
  8. package/esm2015/lib/interceptors/basiq-token.interceptor.js +35 -0
  9. package/esm2015/lib/interceptors/interceptors.module.js +15 -4
  10. package/esm2015/lib/models/endpoint/endpoints.const.js +3 -1
  11. package/esm2015/lib/models/event/app-event-type.enum.js +21 -19
  12. package/esm2015/lib/models/vehicle/vehicle-logbook.js +4 -4
  13. package/esm2015/lib/services/http/sole/sole-depreciation-method/sole-depreciation-method.service.js +12 -1
  14. package/esm2015/lib/services/http/sole/sole-details/sole-details.service.js +10 -4
  15. package/esm2015/lib/services/http/user/user.service.js +12 -1
  16. package/esm2015/lib/validators/min-date/min-date.validator.js +6 -2
  17. package/esm2015/lib/validators/required-length.validator.js +12 -0
  18. package/fesm2015/taxtank-core.js +316 -226
  19. package/fesm2015/taxtank-core.js.map +1 -1
  20. package/lib/db/Models/sole/sole-business-loss.d.ts +2 -3
  21. package/lib/forms/sole/sole-business.form.d.ts +1 -0
  22. package/lib/interceptors/basiq-client-id.interceptor.d.ts +15 -0
  23. package/lib/interceptors/{basiq.interceptor.d.ts → basiq-token.interceptor.d.ts} +3 -3
  24. package/lib/models/event/app-event-type.enum.d.ts +20 -18
  25. package/lib/models/vehicle/vehicle-logbook.d.ts +2 -2
  26. package/lib/services/http/sole/sole-depreciation-method/sole-depreciation-method.service.d.ts +4 -1
  27. package/lib/services/http/sole/sole-details/sole-details.service.d.ts +3 -1
  28. package/lib/services/http/user/user.service.d.ts +4 -0
  29. package/lib/validators/required-length.validator.d.ts +5 -0
  30. package/package.json +1 -1
  31. package/esm2015/lib/interceptors/basiq.interceptor.js +0 -35
@@ -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('@angular/common/http'), require('rxjs'), require('rxjs/operators'), require('class-transformer'), require('@auth0/angular-jwt'), require('lodash/get'), require('lodash/last'), require('lodash/flatten'), require('lodash/hasIn'), require('lodash/first'), require('moment'), require('moment-range'), require('lodash/uniqBy'), require('lodash/concat'), require('rxjs/internal/observable/throwError'), require('lodash/cloneDeep'), require('lodash/compact'), require('@angular/forms'), require('lodash/isEqual'), require('lodash/fromPairs'), require('lodash'), require('event-source-polyfill/src/eventsource.min.js'), require('@angular/router'), require('lodash/clone'), require('html2pdf.js'), 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/get', 'lodash/last', 'lodash/flatten', 'lodash/hasIn', 'lodash/first', 'moment', 'moment-range', 'lodash/uniqBy', 'lodash/concat', 'rxjs/internal/observable/throwError', 'lodash/cloneDeep', 'lodash/compact', '@angular/forms', 'lodash/isEqual', 'lodash/fromPairs', 'lodash', 'event-source-polyfill/src/eventsource.min.js', '@angular/router', 'lodash/clone', 'html2pdf.js', '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.get, global.last, global.flatten, global.hasIn, global.first, global.moment$1, global.momentRange, global.uniqBy, global.concat, global.rxjs["internal/observable/throwError"], global.cloneDeep$1, global.compact, global.ng.forms, global.isEqual, global.fromPairs, global._, global.eventsource_min_js, global.ng.router, global.clone, global.html2pdf, global.jsPDF, global.autoTable, global.stripeJs, global.xlsx, global.FileSaver));
5
- })(this, (function (exports, i0, i1$1, i1, rxjs, operators, classTransformer, angularJwt, get, last, flatten, hasIn, first, moment$1, momentRange, uniqBy, concat, throwError, cloneDeep$1, compact, forms, isEqual, fromPairs, _, eventsource_min_js, i1$2, clone, html2pdf, 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/get'), require('lodash/last'), require('lodash/flatten'), require('lodash/hasIn'), require('lodash/first'), require('moment'), require('moment-range'), require('lodash/uniqBy'), require('lodash/concat'), require('rxjs/internal/observable/throwError'), require('lodash/cloneDeep'), require('event-source-polyfill/src/eventsource.min.js'), require('lodash/compact'), require('@angular/forms'), require('lodash/isEqual'), require('lodash/fromPairs'), require('lodash'), require('@angular/router'), require('lodash/clone'), require('html2pdf.js'), 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/get', 'lodash/last', 'lodash/flatten', 'lodash/hasIn', 'lodash/first', 'moment', 'moment-range', 'lodash/uniqBy', 'lodash/concat', 'rxjs/internal/observable/throwError', 'lodash/cloneDeep', 'event-source-polyfill/src/eventsource.min.js', 'lodash/compact', '@angular/forms', 'lodash/isEqual', 'lodash/fromPairs', 'lodash', '@angular/router', 'lodash/clone', 'html2pdf.js', '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.get, global.last, global.flatten, global.hasIn, global.first, global.moment$1, global.momentRange, global.uniqBy, global.concat, global.rxjs["internal/observable/throwError"], global.cloneDeep$1, global.eventsource_min_js, global.compact, global.ng.forms, global.isEqual, global.fromPairs, global._, global.ng.router, global.clone, global.html2pdf, global.jsPDF, global.autoTable, global.stripeJs, global.xlsx, global.FileSaver));
5
+ })(this, (function (exports, i0, i1$1, i1, rxjs, operators, classTransformer, angularJwt, get, last, flatten, hasIn, first, moment$1, momentRange, uniqBy, concat, throwError, cloneDeep$1, eventsource_min_js, compact, forms, isEqual, fromPairs, _, i1$2, clone, html2pdf, 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
 
@@ -590,24 +590,26 @@
590
590
  AppEventTypeEnum[AppEventTypeEnum["SERVICE_SUBSCRIPTION_UPDATED"] = 40] = "SERVICE_SUBSCRIPTION_UPDATED";
591
591
  AppEventTypeEnum[AppEventTypeEnum["SOLE_BUSINESS_CREATED"] = 41] = "SOLE_BUSINESS_CREATED";
592
592
  AppEventTypeEnum[AppEventTypeEnum["SOLE_DEPRECIATION_METHOD_UPDATED"] = 42] = "SOLE_DEPRECIATION_METHOD_UPDATED";
593
- AppEventTypeEnum[AppEventTypeEnum["TAX_REVIEW_UPDATED"] = 43] = "TAX_REVIEW_UPDATED";
594
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_CREATED"] = 44] = "TRANSACTION_CREATED";
595
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_DELETED"] = 45] = "TRANSACTION_DELETED";
596
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED"] = 46] = "TRANSACTION_UPDATED";
597
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED_WITH_RECEIPT"] = 47] = "TRANSACTION_UPDATED_WITH_RECEIPT";
598
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED_WITH_DELETED_RECEIPT"] = 48] = "TRANSACTION_UPDATED_WITH_DELETED_RECEIPT";
599
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_RECEIPT_CREATED"] = 49] = "TRANSACTION_RECEIPT_CREATED";
600
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_RECEIPT_DELETED"] = 50] = "TRANSACTION_RECEIPT_DELETED";
601
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTIONS_CREATED"] = 51] = "TRANSACTIONS_CREATED";
602
- AppEventTypeEnum[AppEventTypeEnum["USER_UPDATED"] = 52] = "USER_UPDATED";
603
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_UPDATED"] = 53] = "VEHICLE_CLAIM_UPDATED";
604
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 54] = "VEHICLE_CLAIM_CREATED";
605
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_DETAILS_UPDATED"] = 55] = "VEHICLE_CLAIM_DETAILS_UPDATED";
606
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_DETAILS_CREATED"] = 56] = "VEHICLE_CLAIM_DETAILS_CREATED";
607
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_CREATED"] = 57] = "VEHICLE_LOGBOOK_CREATED";
608
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_UPDATED"] = 58] = "VEHICLE_LOGBOOK_UPDATED";
609
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_DELETED"] = 59] = "VEHICLE_LOGBOOK_DELETED";
610
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED"] = 60] = "VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED";
593
+ AppEventTypeEnum[AppEventTypeEnum["SOLE_DETAILS_CREATED"] = 43] = "SOLE_DETAILS_CREATED";
594
+ AppEventTypeEnum[AppEventTypeEnum["SOLE_DETAILS_UPDATED"] = 44] = "SOLE_DETAILS_UPDATED";
595
+ AppEventTypeEnum[AppEventTypeEnum["TAX_REVIEW_UPDATED"] = 45] = "TAX_REVIEW_UPDATED";
596
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_CREATED"] = 46] = "TRANSACTION_CREATED";
597
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_DELETED"] = 47] = "TRANSACTION_DELETED";
598
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED"] = 48] = "TRANSACTION_UPDATED";
599
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED_WITH_RECEIPT"] = 49] = "TRANSACTION_UPDATED_WITH_RECEIPT";
600
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED_WITH_DELETED_RECEIPT"] = 50] = "TRANSACTION_UPDATED_WITH_DELETED_RECEIPT";
601
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_RECEIPT_CREATED"] = 51] = "TRANSACTION_RECEIPT_CREATED";
602
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_RECEIPT_DELETED"] = 52] = "TRANSACTION_RECEIPT_DELETED";
603
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTIONS_CREATED"] = 53] = "TRANSACTIONS_CREATED";
604
+ AppEventTypeEnum[AppEventTypeEnum["USER_UPDATED"] = 54] = "USER_UPDATED";
605
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_UPDATED"] = 55] = "VEHICLE_CLAIM_UPDATED";
606
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 56] = "VEHICLE_CLAIM_CREATED";
607
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_DETAILS_UPDATED"] = 57] = "VEHICLE_CLAIM_DETAILS_UPDATED";
608
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_DETAILS_CREATED"] = 58] = "VEHICLE_CLAIM_DETAILS_CREATED";
609
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_CREATED"] = 59] = "VEHICLE_LOGBOOK_CREATED";
610
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_UPDATED"] = 60] = "VEHICLE_LOGBOOK_UPDATED";
611
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_DELETED"] = 61] = "VEHICLE_LOGBOOK_DELETED";
612
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED"] = 62] = "VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED";
611
613
  })(exports.AppEventTypeEnum || (exports.AppEventTypeEnum = {}));
612
614
 
613
615
  var EventDispatcherService = /** @class */ (function () {
@@ -961,6 +963,7 @@
961
963
  BANK_TRANSACTIONS_IMPORT_POST: new Endpoint('POST', '\\/bank-transactions\\/\\d+\\/import'),
962
964
  BASIQ_ACCOUNTS_GET: new Endpoint('GET', '\\/basiq\\/accounts'),
963
965
  BASIQ_TOKEN_GET: new Endpoint('GET', '\\/basiq\\/tokens'),
966
+ BORROWING_EXPENSES_GET: new Endpoint('GET', '\\/borrowing-expenses'),
964
967
  CHARTS_INCOME_GET: new Endpoint('GET', '\\/charts\\/\\incomes'),
965
968
  CHARTS_EXPENSES_GET: new Endpoint('GET', '\\/charts\\/\\expenses'),
966
969
  CHART_ACCOUNTS_GET: new Endpoint('GET', '\\/chart-accounts'),
@@ -1058,6 +1061,7 @@
1058
1061
  SOLE_BUSINESSES_GET: new Endpoint('GET', '\\/sole-businesses'),
1059
1062
  SOLE_BUSINESSES_POST: new Endpoint('POST', '\\/sole-businesses'),
1060
1063
  SOLE_BUSINESSES_PUT: new Endpoint('PUT', '\\/sole-businesses\\/\\d+'),
1064
+ BUSINESS_ACTIVITIES_GET: new Endpoint('GET', '\\/sole-business-activities'),
1061
1065
  SOLE_DEPRECIATION_METHODS_GET: new Endpoint('GET', '\\/sole-depreciation-methods'),
1062
1066
  SOLE_DEPRECIATION_METHODS_PUT: new Endpoint('PUT', '\\/sole-depreciation-methods\\/\\d+'),
1063
1067
  SOLE_INVOICES_GET: new Endpoint('GET', '\\/sole-invoices'),
@@ -3433,15 +3437,15 @@
3433
3437
  * Get logbook period date range from logbook date and weeksInPeriod duration
3434
3438
  */
3435
3439
  VehicleLogbook.prototype.getPeriod = function () {
3436
- return moment.rangeFromInterval('weeks', VehicleLogbook.bestPeriodWeeks, this.date);
3440
+ return moment.rangeFromInterval('milliseconds', VehicleLogbook.bestPeriodDuration, this.date);
3437
3441
  };
3438
3442
  return VehicleLogbook;
3439
3443
  }(VehicleLogbook$1));
3440
3444
  /**
3441
- * Logbook period duration in weeks.
3445
+ * Logbook period duration in milliseconds.
3442
3446
  * https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/211517441/Logbook+Vehicle
3443
3447
  */
3444
- VehicleLogbook.bestPeriodWeeks = 12;
3448
+ VehicleLogbook.bestPeriodDuration = 12 * 7 * 24 * 3600 * 1000;
3445
3449
  __decorate([
3446
3450
  classTransformer.Type(function () { return Date; })
3447
3451
  ], VehicleLogbook.prototype, "date", void 0);
@@ -6125,11 +6129,11 @@
6125
6129
  /**
6126
6130
  * Interceptor which adds user's basiq token to any http request to basiq api
6127
6131
  */
6128
- var BasiqInterceptor = /** @class */ (function () {
6129
- function BasiqInterceptor(basiqTokenService) {
6132
+ var BasiqTokenInterceptor = /** @class */ (function () {
6133
+ function BasiqTokenInterceptor(basiqTokenService) {
6130
6134
  this.basiqTokenService = basiqTokenService;
6131
6135
  }
6132
- BasiqInterceptor.prototype.intercept = function (request, next) {
6136
+ BasiqTokenInterceptor.prototype.intercept = function (request, next) {
6133
6137
  var _this = this;
6134
6138
  // skip non-basiq requests
6135
6139
  if (!request.url.includes(BasiqService.basiqApiUrl)) {
@@ -6139,21 +6143,264 @@
6139
6143
  return next.handle(_this.addToken(request, token));
6140
6144
  }));
6141
6145
  };
6142
- BasiqInterceptor.prototype.addToken = function (request, token) {
6146
+ BasiqTokenInterceptor.prototype.addToken = function (request, token) {
6143
6147
  return request.clone({
6144
6148
  setHeaders: {
6145
6149
  Authorization: 'Bearer ' + token.value
6146
6150
  }
6147
6151
  });
6148
6152
  };
6149
- return BasiqInterceptor;
6153
+ return BasiqTokenInterceptor;
6150
6154
  }());
6151
- BasiqInterceptor.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqInterceptor, deps: [{ token: BasiqTokenService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
6152
- BasiqInterceptor.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqInterceptor });
6153
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqInterceptor, decorators: [{
6155
+ BasiqTokenInterceptor.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqTokenInterceptor, deps: [{ token: BasiqTokenService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
6156
+ BasiqTokenInterceptor.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqTokenInterceptor });
6157
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqTokenInterceptor, decorators: [{
6154
6158
  type: i0.Injectable
6155
6159
  }], ctorParameters: function () { return [{ type: BasiqTokenService }]; } });
6156
6160
 
6161
+ /**
6162
+ * server sent events service
6163
+ * https://symfony.com/doc/current/mercure.html
6164
+ */
6165
+ var SseService = /** @class */ (function () {
6166
+ function SseService(zone, jwtService, environment) {
6167
+ this.zone = zone;
6168
+ this.jwtService = jwtService;
6169
+ this.environment = environment;
6170
+ }
6171
+ /**
6172
+ * list to url for server events
6173
+ */
6174
+ SseService.prototype.on = function (topic) {
6175
+ var _this = this;
6176
+ var url = new URL(this.environment.mercureUrl);
6177
+ url.searchParams.append('topic', this.environment.apiV2 + "/users/" + this.jwtService.decodeToken().username + "/" + topic);
6178
+ // tslint:disable-next-line:typedef
6179
+ return new rxjs.Observable(function (observer) {
6180
+ var es = new eventsource_min_js.EventSourcePolyfill(url, {
6181
+ headers: {
6182
+ Authorization: 'Bearer ' + _this.jwtService.getToken(),
6183
+ }
6184
+ });
6185
+ es.onmessage = function (event) {
6186
+ _this.zone.run(function () { return observer.next(event); });
6187
+ };
6188
+ })
6189
+ .pipe(operators.map(function (messageEvent) {
6190
+ return JSON.parse(messageEvent.data);
6191
+ }));
6192
+ };
6193
+ return SseService;
6194
+ }());
6195
+ SseService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SseService, deps: [{ token: i0__namespace.NgZone }, { token: JwtService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
6196
+ SseService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SseService, providedIn: 'root' });
6197
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SseService, decorators: [{
6198
+ type: i0.Injectable,
6199
+ args: [{
6200
+ providedIn: 'root'
6201
+ }]
6202
+ }], ctorParameters: function () {
6203
+ return [{ type: i0__namespace.NgZone }, { type: JwtService }, { type: undefined, decorators: [{
6204
+ type: i0.Inject,
6205
+ args: ['environment']
6206
+ }] }];
6207
+ } });
6208
+
6209
+ /**
6210
+ * Service to work with user
6211
+ */
6212
+ var UserService = /** @class */ (function () {
6213
+ function UserService(http, jwtService, eventDispatcherService, sseService, environment) {
6214
+ this.http = http;
6215
+ this.jwtService = jwtService;
6216
+ this.eventDispatcherService = eventDispatcherService;
6217
+ this.sseService = sseService;
6218
+ this.environment = environment;
6219
+ this.cacheSubject = new rxjs.ReplaySubject(1);
6220
+ this.listenEvents();
6221
+ }
6222
+ UserService.prototype.listenEvents = function () {
6223
+ this.listenServiceSubscriptionUpdated();
6224
+ };
6225
+ UserService.prototype.get = function () {
6226
+ var _this = this;
6227
+ if (!this.cache) {
6228
+ this.fetch().subscribe(function () { }, function (error) {
6229
+ // force logout user (clear localStorage) when get current user return error
6230
+ if (error.status === 500) {
6231
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.CURRENT_USER_GET_FAILED, null));
6232
+ }
6233
+ });
6234
+ }
6235
+ return this.cacheSubject.asObservable();
6236
+ };
6237
+ /**
6238
+ * Get current user
6239
+ */
6240
+ UserService.prototype.fetch = function () {
6241
+ var _this = this;
6242
+ return this.http.get(this.environment.apiV2 + "/users/current")
6243
+ .pipe(operators.map(function (userBase) {
6244
+ var user = classTransformer.plainToClass(User, userBase);
6245
+ localStorage.setItem('userId', user.id.toString());
6246
+ // @TODO remove
6247
+ localStorage.setItem('financialYear', user.financialYear.toString());
6248
+ _this.cache = user;
6249
+ _this.cacheSubject.next(_this.cache);
6250
+ return user;
6251
+ }));
6252
+ };
6253
+ /**
6254
+ * Register new user
6255
+ */
6256
+ UserService.prototype.register = function (data) {
6257
+ return this.http.post(this.environment.apiV2 + "/users/registration", data);
6258
+ };
6259
+ /**
6260
+ * Update user
6261
+ */
6262
+ UserService.prototype.update = function (user) {
6263
+ var _this = this;
6264
+ return this.http.put(this.environment.apiV2 + "/users/" + user.id, user)
6265
+ .pipe(operators.map(function (userBase) {
6266
+ _this.cache = classTransformer.plainToClass(User, userBase);
6267
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.USER_UPDATED, null));
6268
+ _this.cacheSubject.next(_this.cache);
6269
+ }));
6270
+ };
6271
+ /**
6272
+ * Change user password
6273
+ */
6274
+ UserService.prototype.changePassword = function (currentPassword, newPassword) {
6275
+ return this.http.put(this.environment.apiV2 + "/users/password/change", { currentPassword: currentPassword, newPassword: newPassword });
6276
+ };
6277
+ /**
6278
+ * Recovery user password
6279
+ */
6280
+ UserService.prototype.recoveryPassword = function (email) {
6281
+ return this.http.put(this.environment.apiV2 + "/users/password/recovery", { email: email });
6282
+ };
6283
+ /**
6284
+ * Reset user password
6285
+ */
6286
+ UserService.prototype.resetPassword = function (newPassword, resetToken) {
6287
+ return this.http.put(this.environment.apiV2 + "/users/password/reset", { newPassword: newPassword, resetToken: resetToken });
6288
+ };
6289
+ UserService.prototype.resendConfirmationEmail = function (email) {
6290
+ return this.http.post(this.environment.apiV2 + "/users/confirmation/resend", { email: email });
6291
+ };
6292
+ /**
6293
+ * Confirm registered user
6294
+ */
6295
+ UserService.prototype.confirm = function (verificationCode) {
6296
+ return this.http.post(this.environment.apiV2 + "/users/confirmation", { verificationCode: verificationCode });
6297
+ };
6298
+ /**
6299
+ * Search existing user
6300
+ */
6301
+ UserService.prototype.search = function (email) {
6302
+ return this.http.get(this.environment.apiV2 + "/users/search?email=" + email)
6303
+ .pipe(operators.map(function (userBase) {
6304
+ return classTransformer.plainToClass(User, userBase);
6305
+ }));
6306
+ };
6307
+ /**
6308
+ * Finish onboarding process
6309
+ */
6310
+ UserService.prototype.finishOnboarding = function (user) {
6311
+ var _this = this;
6312
+ return this.http.put(this.environment.apiV2 + "/users/status", user)
6313
+ .pipe(operators.map(function () {
6314
+ _this.cache = user;
6315
+ _this.cacheSubject.next(_this.cache);
6316
+ }));
6317
+ };
6318
+ /**
6319
+ * Update user photo
6320
+ */
6321
+ UserService.prototype.updatePhoto = function (photo) {
6322
+ var _this = this;
6323
+ return this.http.post(this.environment.apiV2 + "/users/photo?_method=PUT", photo)
6324
+ .pipe(operators.map(function (photoUrl) {
6325
+ _this.cache = classTransformer.plainToClass(User, Object.assign(_this.cache, { photo: photoUrl }));
6326
+ _this.cacheSubject.next(_this.cache);
6327
+ }));
6328
+ };
6329
+ UserService.prototype.switchFinancialYear = function (year) {
6330
+ return this.http.get(this.environment.apiV2 + "/financial-year/switch", { params: new i1.HttpParams({ fromString: "financialYear=" + year }) }).pipe(operators.map(function () {
6331
+ localStorage.setItem('financialYear', year.toString());
6332
+ window.location.reload();
6333
+ }));
6334
+ };
6335
+ /**
6336
+ * clear service cache
6337
+ */
6338
+ UserService.prototype.resetCache = function () {
6339
+ this.fetch().subscribe();
6340
+ };
6341
+ /**
6342
+ * Create basiq (if not exist yet) to provide access to basiq api
6343
+ */
6344
+ UserService.prototype.createBasiq = function () {
6345
+ var _this = this;
6346
+ return this.http.post(this.environment.apiV2 + "/basiq/user", {})
6347
+ .pipe(operators.map(function (basiqId) {
6348
+ _this.cache = classTransformer.plainToClass(User, Object.assign(_this.cache, { basiqId: basiqId }));
6349
+ _this.cacheSubject.next(_this.cache);
6350
+ return basiqId;
6351
+ }));
6352
+ };
6353
+ /**
6354
+ * Update cache when user's service subscription is updated
6355
+ */
6356
+ UserService.prototype.listenServiceSubscriptionUpdated = function () {
6357
+ var _this = this;
6358
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.SERVICE_SUBSCRIPTION_UPDATED).subscribe(function () { return _this.resetCache(); });
6359
+ };
6360
+ return UserService;
6361
+ }());
6362
+ UserService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserService, deps: [{ token: i1__namespace.HttpClient }, { token: JwtService }, { token: EventDispatcherService }, { token: SseService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
6363
+ UserService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserService, providedIn: 'root' });
6364
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserService, decorators: [{
6365
+ type: i0.Injectable,
6366
+ args: [{
6367
+ providedIn: 'root'
6368
+ }]
6369
+ }], ctorParameters: function () {
6370
+ return [{ type: i1__namespace.HttpClient }, { type: JwtService }, { type: EventDispatcherService }, { type: SseService }, { type: undefined, decorators: [{
6371
+ type: i0.Inject,
6372
+ args: ['environment']
6373
+ }] }];
6374
+ } });
6375
+
6376
+ /**
6377
+ * Interceptor which check if client's basiq id exist and request it if not
6378
+ */
6379
+ var BasiqClientIdInterceptor = /** @class */ (function () {
6380
+ function BasiqClientIdInterceptor(userService) {
6381
+ this.userService = userService;
6382
+ }
6383
+ BasiqClientIdInterceptor.prototype.intercept = function (request, next) {
6384
+ var _this = this;
6385
+ // Check if 'client id' URL segment contains null instead of id
6386
+ if (!request.url.startsWith(BasiqService.basiqApiUrl + "/users/null")) {
6387
+ return next.handle(request);
6388
+ }
6389
+ return this.userService.createBasiq().pipe(operators.mergeMap(function (basiqClientId) { return next.handle(_this.addId(request, basiqClientId)); }));
6390
+ };
6391
+ BasiqClientIdInterceptor.prototype.addId = function (request, basiqClientId) {
6392
+ return request.clone({
6393
+ url: request.url.replace('null', basiqClientId)
6394
+ });
6395
+ };
6396
+ return BasiqClientIdInterceptor;
6397
+ }());
6398
+ BasiqClientIdInterceptor.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqClientIdInterceptor, deps: [{ token: UserService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
6399
+ BasiqClientIdInterceptor.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqClientIdInterceptor });
6400
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqClientIdInterceptor, decorators: [{
6401
+ type: i0.Injectable
6402
+ }], ctorParameters: function () { return [{ type: UserService }]; } });
6403
+
6157
6404
  var InterceptorsModule = /** @class */ (function () {
6158
6405
  function InterceptorsModule() {
6159
6406
  }
@@ -6190,7 +6437,12 @@
6190
6437
  },
6191
6438
  {
6192
6439
  provide: i1.HTTP_INTERCEPTORS,
6193
- useClass: BasiqInterceptor,
6440
+ useClass: BasiqTokenInterceptor,
6441
+ multi: true
6442
+ },
6443
+ {
6444
+ provide: i1.HTTP_INTERCEPTORS,
6445
+ useClass: BasiqClientIdInterceptor,
6194
6446
  multi: true
6195
6447
  }
6196
6448
  ] });
@@ -6226,7 +6478,12 @@
6226
6478
  },
6227
6479
  {
6228
6480
  provide: i1.HTTP_INTERCEPTORS,
6229
- useClass: BasiqInterceptor,
6481
+ useClass: BasiqTokenInterceptor,
6482
+ multi: true
6483
+ },
6484
+ {
6485
+ provide: i1.HTTP_INTERCEPTORS,
6486
+ useClass: BasiqClientIdInterceptor,
6230
6487
  multi: true
6231
6488
  }
6232
6489
  ]
@@ -6309,7 +6566,7 @@
6309
6566
  if (this.items.length < 2) {
6310
6567
  return false;
6311
6568
  }
6312
- return VehicleLogbook.bestPeriodWeeks < (this.last.date.getTime() - this.first.date.getTime());
6569
+ return VehicleLogbook.bestPeriodDuration < (this.last.date.getTime() - this.first.date.getTime());
6313
6570
  };
6314
6571
  /**
6315
6572
  * Get collection of non-personal logbooks (work-related, sole-related).
@@ -11210,7 +11467,11 @@
11210
11467
  this.toastService = toastService;
11211
11468
  this.cacheSubject = new rxjs.ReplaySubject(1);
11212
11469
  this.url = 'sole-depreciation-methods';
11470
+ this.listenEvents();
11213
11471
  }
11472
+ SoleDepreciationMethodService.prototype.listenEvents = function () {
11473
+ this.listenSoleDetailsChanges();
11474
+ };
11214
11475
  SoleDepreciationMethodService.prototype.get = function () {
11215
11476
  var _this = this;
11216
11477
  if (!this.cache) {
@@ -11238,6 +11499,14 @@
11238
11499
  return throwError.throwError(error);
11239
11500
  }));
11240
11501
  };
11502
+ SoleDepreciationMethodService.prototype.listenSoleDetailsChanges = function () {
11503
+ var _this = this;
11504
+ this.eventDispatcherService.on([exports.AppEventTypeEnum.SOLE_DETAILS_CREATED, exports.AppEventTypeEnum.SOLE_DETAILS_UPDATED])
11505
+ .subscribe(function () {
11506
+ _this.cache = null;
11507
+ _this.get().subscribe();
11508
+ });
11509
+ };
11241
11510
  return SoleDepreciationMethodService;
11242
11511
  }());
11243
11512
  SoleDepreciationMethodService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleDepreciationMethodService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }, { token: EventDispatcherService }, { token: ToastService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
@@ -11258,9 +11527,10 @@
11258
11527
  * @TODO TT-1777 Alex: extend from rest service when it refactored
11259
11528
  */
11260
11529
  var SoleDetailsService = /** @class */ (function () {
11261
- function SoleDetailsService(http, environment) {
11530
+ function SoleDetailsService(http, environment, eventDispatcherService) {
11262
11531
  this.http = http;
11263
11532
  this.environment = environment;
11533
+ this.eventDispatcherService = eventDispatcherService;
11264
11534
  this.cacheSubject = new rxjs.ReplaySubject(1);
11265
11535
  }
11266
11536
  SoleDetailsService.prototype.get = function () {
@@ -11285,6 +11555,7 @@
11285
11555
  return this.http.post(this.environment.apiV2 + "/sole-details", soleDetails).pipe(operators.map(function (soleDetailsBase) {
11286
11556
  _this.cache = classTransformer.plainToClass(SoleDetails, soleDetailsBase);
11287
11557
  _this.cacheSubject.next(_this.cache);
11558
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.SOLE_DETAILS_CREATED, soleDetails));
11288
11559
  return _this.cache;
11289
11560
  }));
11290
11561
  };
@@ -11293,12 +11564,13 @@
11293
11564
  return this.http.put(this.environment.apiV2 + "/sole-details/" + soleDetails.id, soleDetails).pipe(operators.map(function (soleDetailsBase) {
11294
11565
  _this.cache = classTransformer.plainToClass(SoleDetails, soleDetailsBase);
11295
11566
  _this.cacheSubject.next(_this.cache);
11567
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.SOLE_DETAILS_UPDATED, soleDetails));
11296
11568
  return _this.cache;
11297
11569
  }));
11298
11570
  };
11299
11571
  return SoleDetailsService;
11300
11572
  }());
11301
- SoleDetailsService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleDetailsService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11573
+ SoleDetailsService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleDetailsService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }, { token: EventDispatcherService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11302
11574
  SoleDetailsService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleDetailsService, providedIn: 'root' });
11303
11575
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleDetailsService, decorators: [{
11304
11576
  type: i0.Injectable,
@@ -11309,7 +11581,7 @@
11309
11581
  return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
11310
11582
  type: i0.Inject,
11311
11583
  args: ['environment']
11312
- }] }];
11584
+ }] }, { type: EventDispatcherService }];
11313
11585
  } });
11314
11586
 
11315
11587
  var SoleInvoiceService = /** @class */ (function (_super) {
@@ -13448,54 +13720,6 @@
13448
13720
  }]
13449
13721
  }] });
13450
13722
 
13451
- /**
13452
- * server sent events service
13453
- * https://symfony.com/doc/current/mercure.html
13454
- */
13455
- var SseService = /** @class */ (function () {
13456
- function SseService(zone, jwtService, environment) {
13457
- this.zone = zone;
13458
- this.jwtService = jwtService;
13459
- this.environment = environment;
13460
- }
13461
- /**
13462
- * list to url for server events
13463
- */
13464
- SseService.prototype.on = function (topic) {
13465
- var _this = this;
13466
- var url = new URL(this.environment.mercureUrl);
13467
- url.searchParams.append('topic', this.environment.apiV2 + "/users/" + this.jwtService.decodeToken().username + "/" + topic);
13468
- // tslint:disable-next-line:typedef
13469
- return new rxjs.Observable(function (observer) {
13470
- var es = new eventsource_min_js.EventSourcePolyfill(url, {
13471
- headers: {
13472
- Authorization: 'Bearer ' + _this.jwtService.getToken(),
13473
- }
13474
- });
13475
- es.onmessage = function (event) {
13476
- _this.zone.run(function () { return observer.next(event); });
13477
- };
13478
- })
13479
- .pipe(operators.map(function (messageEvent) {
13480
- return JSON.parse(messageEvent.data);
13481
- }));
13482
- };
13483
- return SseService;
13484
- }());
13485
- SseService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SseService, deps: [{ token: i0__namespace.NgZone }, { token: JwtService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
13486
- SseService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SseService, providedIn: 'root' });
13487
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SseService, decorators: [{
13488
- type: i0.Injectable,
13489
- args: [{
13490
- providedIn: 'root'
13491
- }]
13492
- }], ctorParameters: function () {
13493
- return [{ type: i0__namespace.NgZone }, { type: JwtService }, { type: undefined, decorators: [{
13494
- type: i0.Inject,
13495
- args: ['environment']
13496
- }] }];
13497
- } });
13498
-
13499
13723
  /**
13500
13724
  * Service for work with chats
13501
13725
  */
@@ -16207,161 +16431,6 @@
16207
16431
  }]
16208
16432
  }] });
16209
16433
 
16210
- /**
16211
- * Service to work with user
16212
- */
16213
- var UserService = /** @class */ (function () {
16214
- function UserService(http, jwtService, eventDispatcherService, sseService, environment) {
16215
- this.http = http;
16216
- this.jwtService = jwtService;
16217
- this.eventDispatcherService = eventDispatcherService;
16218
- this.sseService = sseService;
16219
- this.environment = environment;
16220
- this.cacheSubject = new rxjs.ReplaySubject(1);
16221
- this.listenEvents();
16222
- }
16223
- UserService.prototype.listenEvents = function () {
16224
- this.listenServiceSubscriptionUpdated();
16225
- };
16226
- UserService.prototype.get = function () {
16227
- var _this = this;
16228
- if (!this.cache) {
16229
- this.fetch().subscribe(function () { }, function (error) {
16230
- // force logout user (clear localStorage) when get current user return error
16231
- if (error.status === 500) {
16232
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.CURRENT_USER_GET_FAILED, null));
16233
- }
16234
- });
16235
- }
16236
- return this.cacheSubject.asObservable();
16237
- };
16238
- /**
16239
- * Get current user
16240
- */
16241
- UserService.prototype.fetch = function () {
16242
- var _this = this;
16243
- return this.http.get(this.environment.apiV2 + "/users/current")
16244
- .pipe(operators.map(function (userBase) {
16245
- var user = classTransformer.plainToClass(User, userBase);
16246
- localStorage.setItem('userId', user.id.toString());
16247
- // @TODO remove
16248
- localStorage.setItem('financialYear', user.financialYear.toString());
16249
- _this.cache = user;
16250
- _this.cacheSubject.next(_this.cache);
16251
- return user;
16252
- }));
16253
- };
16254
- /**
16255
- * Register new user
16256
- */
16257
- UserService.prototype.register = function (data) {
16258
- return this.http.post(this.environment.apiV2 + "/users/registration", data);
16259
- };
16260
- /**
16261
- * Update user
16262
- */
16263
- UserService.prototype.update = function (user) {
16264
- var _this = this;
16265
- return this.http.put(this.environment.apiV2 + "/users/" + user.id, user)
16266
- .pipe(operators.map(function (userBase) {
16267
- _this.cache = classTransformer.plainToClass(User, userBase);
16268
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.USER_UPDATED, null));
16269
- _this.cacheSubject.next(_this.cache);
16270
- }));
16271
- };
16272
- /**
16273
- * Change user password
16274
- */
16275
- UserService.prototype.changePassword = function (currentPassword, newPassword) {
16276
- return this.http.put(this.environment.apiV2 + "/users/password/change", { currentPassword: currentPassword, newPassword: newPassword });
16277
- };
16278
- /**
16279
- * Recovery user password
16280
- */
16281
- UserService.prototype.recoveryPassword = function (email) {
16282
- return this.http.put(this.environment.apiV2 + "/users/password/recovery", { email: email });
16283
- };
16284
- /**
16285
- * Reset user password
16286
- */
16287
- UserService.prototype.resetPassword = function (newPassword, resetToken) {
16288
- return this.http.put(this.environment.apiV2 + "/users/password/reset", { newPassword: newPassword, resetToken: resetToken });
16289
- };
16290
- UserService.prototype.resendConfirmationEmail = function (email) {
16291
- return this.http.post(this.environment.apiV2 + "/users/confirmation/resend", { email: email });
16292
- };
16293
- /**
16294
- * Confirm registered user
16295
- */
16296
- UserService.prototype.confirm = function (verificationCode) {
16297
- return this.http.post(this.environment.apiV2 + "/users/confirmation", { verificationCode: verificationCode });
16298
- };
16299
- /**
16300
- * Search existing user
16301
- */
16302
- UserService.prototype.search = function (email) {
16303
- return this.http.get(this.environment.apiV2 + "/users/search?email=" + email)
16304
- .pipe(operators.map(function (userBase) {
16305
- return classTransformer.plainToClass(User, userBase);
16306
- }));
16307
- };
16308
- /**
16309
- * Finish onboarding process
16310
- */
16311
- UserService.prototype.finishOnboarding = function (user) {
16312
- var _this = this;
16313
- return this.http.put(this.environment.apiV2 + "/users/status", user)
16314
- .pipe(operators.map(function () {
16315
- _this.cache = user;
16316
- _this.cacheSubject.next(_this.cache);
16317
- }));
16318
- };
16319
- /**
16320
- * Update user photo
16321
- */
16322
- UserService.prototype.updatePhoto = function (photo) {
16323
- var _this = this;
16324
- return this.http.post(this.environment.apiV2 + "/users/photo?_method=PUT", photo)
16325
- .pipe(operators.map(function (photoUrl) {
16326
- _this.cache = classTransformer.plainToClass(User, Object.assign(_this.cache, { photo: photoUrl }));
16327
- _this.cacheSubject.next(_this.cache);
16328
- }));
16329
- };
16330
- UserService.prototype.switchFinancialYear = function (year) {
16331
- return this.http.get(this.environment.apiV2 + "/financial-year/switch", { params: new i1.HttpParams({ fromString: "financialYear=" + year }) }).pipe(operators.map(function () {
16332
- localStorage.setItem('financialYear', year.toString());
16333
- window.location.reload();
16334
- }));
16335
- };
16336
- /**
16337
- * clear service cache
16338
- */
16339
- UserService.prototype.resetCache = function () {
16340
- this.fetch().subscribe();
16341
- };
16342
- /**
16343
- * Update cache when user's service subscription is updated
16344
- */
16345
- UserService.prototype.listenServiceSubscriptionUpdated = function () {
16346
- var _this = this;
16347
- this.eventDispatcherService.on(exports.AppEventTypeEnum.SERVICE_SUBSCRIPTION_UPDATED).subscribe(function () { return _this.resetCache(); });
16348
- };
16349
- return UserService;
16350
- }());
16351
- UserService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserService, deps: [{ token: i1__namespace.HttpClient }, { token: JwtService }, { token: EventDispatcherService }, { token: SseService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
16352
- UserService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserService, providedIn: 'root' });
16353
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserService, decorators: [{
16354
- type: i0.Injectable,
16355
- args: [{
16356
- providedIn: 'root'
16357
- }]
16358
- }], ctorParameters: function () {
16359
- return [{ type: i1__namespace.HttpClient }, { type: JwtService }, { type: EventDispatcherService }, { type: SseService }, { type: undefined, decorators: [{
16360
- type: i0.Inject,
16361
- args: ['environment']
16362
- }] }];
16363
- } });
16364
-
16365
16434
  /**
16366
16435
  * Service to work with XLSX (generate, download, e.t.c.)
16367
16436
  */
@@ -16886,7 +16955,11 @@
16886
16955
  function minDateValidator(date, message) {
16887
16956
  if (message === void 0) { message = MessagesEnum.INVALID_DATE.replace('$1', new i1$1.DatePipe('en-US').transform(date)); }
16888
16957
  return function (control) {
16889
- if (!control.value || (control.value >= date)) {
16958
+ if (!control.value) {
16959
+ return null;
16960
+ }
16961
+ // form control value can be as a Moment object - we wrap it in "new Date()" to work with it like with JS Date
16962
+ if (new Date(control.value) >= new Date(date)) {
16890
16963
  return null;
16891
16964
  }
16892
16965
  return { minDate: message };
@@ -16990,7 +17063,7 @@
16990
17063
  name: new forms.FormControl(business.name, forms.Validators.required),
16991
17064
  activity: new forms.FormControl(business.activity, forms.Validators.required),
16992
17065
  description: new forms.FormControl(business.description),
16993
- website: new forms.FormControl(business.website),
17066
+ website: new forms.FormControl(business.website)
16994
17067
  }, business) || this;
16995
17068
  // User have to create income source with new business.
16996
17069
  // Income source is not able for edit business
@@ -17007,6 +17080,12 @@
17007
17080
  })
17008
17081
  ])
17009
17082
  }));
17083
+ _this.addControl('losses', new forms.FormArray([
17084
+ new forms.FormGroup({
17085
+ financialYear: new forms.FormControl(new FinancialYear().year),
17086
+ openBalance: new forms.FormControl(null, forms.Validators.required)
17087
+ })
17088
+ ]));
17010
17089
  }
17011
17090
  return _this;
17012
17091
  }
@@ -17017,6 +17096,13 @@
17017
17096
  enumerable: false,
17018
17097
  configurable: true
17019
17098
  });
17099
+ Object.defineProperty(SoleBusinessForm.prototype, "lossFormGroup", {
17100
+ get: function () {
17101
+ return this.get('losses').at(0);
17102
+ },
17103
+ enumerable: false,
17104
+ configurable: true
17105
+ });
17020
17106
  return SoleBusinessForm;
17021
17107
  }(AbstractForm));
17022
17108
 
@@ -17112,11 +17198,23 @@
17112
17198
  return SoleDepreciationMethodForm;
17113
17199
  }(AbstractForm));
17114
17200
 
17201
+ /**
17202
+ * Validator check if entered strong length is equal to passed length parameter
17203
+ */
17204
+ function requiredLengthValidator(length) {
17205
+ return function (control) {
17206
+ if (control.value && control.value.length !== length) {
17207
+ return { requiredLength: length };
17208
+ }
17209
+ return null;
17210
+ };
17211
+ }
17212
+
17115
17213
  var SoleDetailsForm = /** @class */ (function (_super) {
17116
17214
  __extends(SoleDetailsForm, _super);
17117
17215
  function SoleDetailsForm(soleDetails) {
17118
17216
  return _super.call(this, {
17119
- abn: new forms.FormControl(soleDetails.abn, [forms.Validators.required, forms.Validators.minLength(11), forms.Validators.maxLength(11)]),
17217
+ abn: new forms.FormControl(soleDetails.abn, [forms.Validators.required, requiredLengthValidator(11)]),
17120
17218
  isGST: new forms.FormControl(soleDetails.isGST || false)
17121
17219
  }, soleDetails) || this;
17122
17220
  }