taxtank-core 0.28.1 → 0.28.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/taxtank-core.umd.js +337 -244
- package/bundles/taxtank-core.umd.js.map +1 -1
- package/esm2015/lib/collections/vehicle/vehicle-logbook.collection.js +2 -2
- package/esm2015/lib/db/Models/sole/sole-business-loss.js +1 -1
- package/esm2015/lib/forms/sole/sole-business.form.js +11 -2
- package/esm2015/lib/forms/sole/sole-details.form.js +3 -2
- package/esm2015/lib/interceptors/basiq-client-id.interceptor.js +31 -0
- package/esm2015/lib/interceptors/basiq-token.interceptor.js +35 -0
- package/esm2015/lib/interceptors/interceptors.module.js +15 -4
- package/esm2015/lib/models/endpoint/endpoints.const.js +2 -1
- package/esm2015/lib/models/event/app-event-type.enum.js +21 -19
- package/esm2015/lib/models/vehicle/vehicle-logbook.js +4 -4
- package/esm2015/lib/services/http/sole/sole-depreciation-method/sole-depreciation-method.service.js +12 -1
- package/esm2015/lib/services/http/sole/sole-details/sole-details.service.js +10 -4
- package/esm2015/lib/services/http/user/user.service.js +12 -1
- package/esm2015/lib/validators/required-length.validator.js +12 -0
- package/fesm2015/taxtank-core.js +310 -225
- package/fesm2015/taxtank-core.js.map +1 -1
- package/lib/db/Models/sole/sole-business-loss.d.ts +2 -3
- package/lib/forms/sole/sole-business.form.d.ts +1 -0
- package/lib/interceptors/basiq-client-id.interceptor.d.ts +15 -0
- package/lib/interceptors/{basiq.interceptor.d.ts → basiq-token.interceptor.d.ts} +3 -3
- package/lib/models/event/app-event-type.enum.d.ts +20 -18
- package/lib/models/vehicle/vehicle-logbook.d.ts +2 -2
- package/lib/services/http/sole/sole-depreciation-method/sole-depreciation-method.service.d.ts +4 -1
- package/lib/services/http/sole/sole-details/sole-details.service.d.ts +3 -1
- package/lib/services/http/user/user.service.d.ts +4 -0
- package/lib/validators/required-length.validator.d.ts +5 -0
- package/package.json +1 -1
- 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('
|
|
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', '
|
|
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.
|
|
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, _,
|
|
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["
|
|
594
|
-
AppEventTypeEnum[AppEventTypeEnum["
|
|
595
|
-
AppEventTypeEnum[AppEventTypeEnum["
|
|
596
|
-
AppEventTypeEnum[AppEventTypeEnum["
|
|
597
|
-
AppEventTypeEnum[AppEventTypeEnum["
|
|
598
|
-
AppEventTypeEnum[AppEventTypeEnum["
|
|
599
|
-
AppEventTypeEnum[AppEventTypeEnum["
|
|
600
|
-
AppEventTypeEnum[AppEventTypeEnum["
|
|
601
|
-
AppEventTypeEnum[AppEventTypeEnum["
|
|
602
|
-
AppEventTypeEnum[AppEventTypeEnum["
|
|
603
|
-
AppEventTypeEnum[AppEventTypeEnum["
|
|
604
|
-
AppEventTypeEnum[AppEventTypeEnum["
|
|
605
|
-
AppEventTypeEnum[AppEventTypeEnum["
|
|
606
|
-
AppEventTypeEnum[AppEventTypeEnum["
|
|
607
|
-
AppEventTypeEnum[AppEventTypeEnum["
|
|
608
|
-
AppEventTypeEnum[AppEventTypeEnum["
|
|
609
|
-
AppEventTypeEnum[AppEventTypeEnum["
|
|
610
|
-
AppEventTypeEnum[AppEventTypeEnum["
|
|
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 () {
|
|
@@ -1058,6 +1060,7 @@
|
|
|
1058
1060
|
SOLE_BUSINESSES_GET: new Endpoint('GET', '\\/sole-businesses'),
|
|
1059
1061
|
SOLE_BUSINESSES_POST: new Endpoint('POST', '\\/sole-businesses'),
|
|
1060
1062
|
SOLE_BUSINESSES_PUT: new Endpoint('PUT', '\\/sole-businesses\\/\\d+'),
|
|
1063
|
+
BUSINESS_ACTIVITIES_GET: new Endpoint('GET', '\\/sole-business-activities'),
|
|
1061
1064
|
SOLE_DEPRECIATION_METHODS_GET: new Endpoint('GET', '\\/sole-depreciation-methods'),
|
|
1062
1065
|
SOLE_DEPRECIATION_METHODS_PUT: new Endpoint('PUT', '\\/sole-depreciation-methods\\/\\d+'),
|
|
1063
1066
|
SOLE_INVOICES_GET: new Endpoint('GET', '\\/sole-invoices'),
|
|
@@ -3433,15 +3436,15 @@
|
|
|
3433
3436
|
* Get logbook period date range from logbook date and weeksInPeriod duration
|
|
3434
3437
|
*/
|
|
3435
3438
|
VehicleLogbook.prototype.getPeriod = function () {
|
|
3436
|
-
return moment.rangeFromInterval('
|
|
3439
|
+
return moment.rangeFromInterval('milliseconds', VehicleLogbook.bestPeriodDuration, this.date);
|
|
3437
3440
|
};
|
|
3438
3441
|
return VehicleLogbook;
|
|
3439
3442
|
}(VehicleLogbook$1));
|
|
3440
3443
|
/**
|
|
3441
|
-
* Logbook period duration in
|
|
3444
|
+
* Logbook period duration in milliseconds.
|
|
3442
3445
|
* https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/211517441/Logbook+Vehicle
|
|
3443
3446
|
*/
|
|
3444
|
-
VehicleLogbook.
|
|
3447
|
+
VehicleLogbook.bestPeriodDuration = 12 * 7 * 24 * 3600 * 1000;
|
|
3445
3448
|
__decorate([
|
|
3446
3449
|
classTransformer.Type(function () { return Date; })
|
|
3447
3450
|
], VehicleLogbook.prototype, "date", void 0);
|
|
@@ -6125,11 +6128,11 @@
|
|
|
6125
6128
|
/**
|
|
6126
6129
|
* Interceptor which adds user's basiq token to any http request to basiq api
|
|
6127
6130
|
*/
|
|
6128
|
-
var
|
|
6129
|
-
function
|
|
6131
|
+
var BasiqTokenInterceptor = /** @class */ (function () {
|
|
6132
|
+
function BasiqTokenInterceptor(basiqTokenService) {
|
|
6130
6133
|
this.basiqTokenService = basiqTokenService;
|
|
6131
6134
|
}
|
|
6132
|
-
|
|
6135
|
+
BasiqTokenInterceptor.prototype.intercept = function (request, next) {
|
|
6133
6136
|
var _this = this;
|
|
6134
6137
|
// skip non-basiq requests
|
|
6135
6138
|
if (!request.url.includes(BasiqService.basiqApiUrl)) {
|
|
@@ -6139,21 +6142,264 @@
|
|
|
6139
6142
|
return next.handle(_this.addToken(request, token));
|
|
6140
6143
|
}));
|
|
6141
6144
|
};
|
|
6142
|
-
|
|
6145
|
+
BasiqTokenInterceptor.prototype.addToken = function (request, token) {
|
|
6143
6146
|
return request.clone({
|
|
6144
6147
|
setHeaders: {
|
|
6145
6148
|
Authorization: 'Bearer ' + token.value
|
|
6146
6149
|
}
|
|
6147
6150
|
});
|
|
6148
6151
|
};
|
|
6149
|
-
return
|
|
6152
|
+
return BasiqTokenInterceptor;
|
|
6150
6153
|
}());
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type:
|
|
6154
|
+
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 });
|
|
6155
|
+
BasiqTokenInterceptor.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqTokenInterceptor });
|
|
6156
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqTokenInterceptor, decorators: [{
|
|
6154
6157
|
type: i0.Injectable
|
|
6155
6158
|
}], ctorParameters: function () { return [{ type: BasiqTokenService }]; } });
|
|
6156
6159
|
|
|
6160
|
+
/**
|
|
6161
|
+
* server sent events service
|
|
6162
|
+
* https://symfony.com/doc/current/mercure.html
|
|
6163
|
+
*/
|
|
6164
|
+
var SseService = /** @class */ (function () {
|
|
6165
|
+
function SseService(zone, jwtService, environment) {
|
|
6166
|
+
this.zone = zone;
|
|
6167
|
+
this.jwtService = jwtService;
|
|
6168
|
+
this.environment = environment;
|
|
6169
|
+
}
|
|
6170
|
+
/**
|
|
6171
|
+
* list to url for server events
|
|
6172
|
+
*/
|
|
6173
|
+
SseService.prototype.on = function (topic) {
|
|
6174
|
+
var _this = this;
|
|
6175
|
+
var url = new URL(this.environment.mercureUrl);
|
|
6176
|
+
url.searchParams.append('topic', this.environment.apiV2 + "/users/" + this.jwtService.decodeToken().username + "/" + topic);
|
|
6177
|
+
// tslint:disable-next-line:typedef
|
|
6178
|
+
return new rxjs.Observable(function (observer) {
|
|
6179
|
+
var es = new eventsource_min_js.EventSourcePolyfill(url, {
|
|
6180
|
+
headers: {
|
|
6181
|
+
Authorization: 'Bearer ' + _this.jwtService.getToken(),
|
|
6182
|
+
}
|
|
6183
|
+
});
|
|
6184
|
+
es.onmessage = function (event) {
|
|
6185
|
+
_this.zone.run(function () { return observer.next(event); });
|
|
6186
|
+
};
|
|
6187
|
+
})
|
|
6188
|
+
.pipe(operators.map(function (messageEvent) {
|
|
6189
|
+
return JSON.parse(messageEvent.data);
|
|
6190
|
+
}));
|
|
6191
|
+
};
|
|
6192
|
+
return SseService;
|
|
6193
|
+
}());
|
|
6194
|
+
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 });
|
|
6195
|
+
SseService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SseService, providedIn: 'root' });
|
|
6196
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SseService, decorators: [{
|
|
6197
|
+
type: i0.Injectable,
|
|
6198
|
+
args: [{
|
|
6199
|
+
providedIn: 'root'
|
|
6200
|
+
}]
|
|
6201
|
+
}], ctorParameters: function () {
|
|
6202
|
+
return [{ type: i0__namespace.NgZone }, { type: JwtService }, { type: undefined, decorators: [{
|
|
6203
|
+
type: i0.Inject,
|
|
6204
|
+
args: ['environment']
|
|
6205
|
+
}] }];
|
|
6206
|
+
} });
|
|
6207
|
+
|
|
6208
|
+
/**
|
|
6209
|
+
* Service to work with user
|
|
6210
|
+
*/
|
|
6211
|
+
var UserService = /** @class */ (function () {
|
|
6212
|
+
function UserService(http, jwtService, eventDispatcherService, sseService, environment) {
|
|
6213
|
+
this.http = http;
|
|
6214
|
+
this.jwtService = jwtService;
|
|
6215
|
+
this.eventDispatcherService = eventDispatcherService;
|
|
6216
|
+
this.sseService = sseService;
|
|
6217
|
+
this.environment = environment;
|
|
6218
|
+
this.cacheSubject = new rxjs.ReplaySubject(1);
|
|
6219
|
+
this.listenEvents();
|
|
6220
|
+
}
|
|
6221
|
+
UserService.prototype.listenEvents = function () {
|
|
6222
|
+
this.listenServiceSubscriptionUpdated();
|
|
6223
|
+
};
|
|
6224
|
+
UserService.prototype.get = function () {
|
|
6225
|
+
var _this = this;
|
|
6226
|
+
if (!this.cache) {
|
|
6227
|
+
this.fetch().subscribe(function () { }, function (error) {
|
|
6228
|
+
// force logout user (clear localStorage) when get current user return error
|
|
6229
|
+
if (error.status === 500) {
|
|
6230
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.CURRENT_USER_GET_FAILED, null));
|
|
6231
|
+
}
|
|
6232
|
+
});
|
|
6233
|
+
}
|
|
6234
|
+
return this.cacheSubject.asObservable();
|
|
6235
|
+
};
|
|
6236
|
+
/**
|
|
6237
|
+
* Get current user
|
|
6238
|
+
*/
|
|
6239
|
+
UserService.prototype.fetch = function () {
|
|
6240
|
+
var _this = this;
|
|
6241
|
+
return this.http.get(this.environment.apiV2 + "/users/current")
|
|
6242
|
+
.pipe(operators.map(function (userBase) {
|
|
6243
|
+
var user = classTransformer.plainToClass(User, userBase);
|
|
6244
|
+
localStorage.setItem('userId', user.id.toString());
|
|
6245
|
+
// @TODO remove
|
|
6246
|
+
localStorage.setItem('financialYear', user.financialYear.toString());
|
|
6247
|
+
_this.cache = user;
|
|
6248
|
+
_this.cacheSubject.next(_this.cache);
|
|
6249
|
+
return user;
|
|
6250
|
+
}));
|
|
6251
|
+
};
|
|
6252
|
+
/**
|
|
6253
|
+
* Register new user
|
|
6254
|
+
*/
|
|
6255
|
+
UserService.prototype.register = function (data) {
|
|
6256
|
+
return this.http.post(this.environment.apiV2 + "/users/registration", data);
|
|
6257
|
+
};
|
|
6258
|
+
/**
|
|
6259
|
+
* Update user
|
|
6260
|
+
*/
|
|
6261
|
+
UserService.prototype.update = function (user) {
|
|
6262
|
+
var _this = this;
|
|
6263
|
+
return this.http.put(this.environment.apiV2 + "/users/" + user.id, user)
|
|
6264
|
+
.pipe(operators.map(function (userBase) {
|
|
6265
|
+
_this.cache = classTransformer.plainToClass(User, userBase);
|
|
6266
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.USER_UPDATED, null));
|
|
6267
|
+
_this.cacheSubject.next(_this.cache);
|
|
6268
|
+
}));
|
|
6269
|
+
};
|
|
6270
|
+
/**
|
|
6271
|
+
* Change user password
|
|
6272
|
+
*/
|
|
6273
|
+
UserService.prototype.changePassword = function (currentPassword, newPassword) {
|
|
6274
|
+
return this.http.put(this.environment.apiV2 + "/users/password/change", { currentPassword: currentPassword, newPassword: newPassword });
|
|
6275
|
+
};
|
|
6276
|
+
/**
|
|
6277
|
+
* Recovery user password
|
|
6278
|
+
*/
|
|
6279
|
+
UserService.prototype.recoveryPassword = function (email) {
|
|
6280
|
+
return this.http.put(this.environment.apiV2 + "/users/password/recovery", { email: email });
|
|
6281
|
+
};
|
|
6282
|
+
/**
|
|
6283
|
+
* Reset user password
|
|
6284
|
+
*/
|
|
6285
|
+
UserService.prototype.resetPassword = function (newPassword, resetToken) {
|
|
6286
|
+
return this.http.put(this.environment.apiV2 + "/users/password/reset", { newPassword: newPassword, resetToken: resetToken });
|
|
6287
|
+
};
|
|
6288
|
+
UserService.prototype.resendConfirmationEmail = function (email) {
|
|
6289
|
+
return this.http.post(this.environment.apiV2 + "/users/confirmation/resend", { email: email });
|
|
6290
|
+
};
|
|
6291
|
+
/**
|
|
6292
|
+
* Confirm registered user
|
|
6293
|
+
*/
|
|
6294
|
+
UserService.prototype.confirm = function (verificationCode) {
|
|
6295
|
+
return this.http.post(this.environment.apiV2 + "/users/confirmation", { verificationCode: verificationCode });
|
|
6296
|
+
};
|
|
6297
|
+
/**
|
|
6298
|
+
* Search existing user
|
|
6299
|
+
*/
|
|
6300
|
+
UserService.prototype.search = function (email) {
|
|
6301
|
+
return this.http.get(this.environment.apiV2 + "/users/search?email=" + email)
|
|
6302
|
+
.pipe(operators.map(function (userBase) {
|
|
6303
|
+
return classTransformer.plainToClass(User, userBase);
|
|
6304
|
+
}));
|
|
6305
|
+
};
|
|
6306
|
+
/**
|
|
6307
|
+
* Finish onboarding process
|
|
6308
|
+
*/
|
|
6309
|
+
UserService.prototype.finishOnboarding = function (user) {
|
|
6310
|
+
var _this = this;
|
|
6311
|
+
return this.http.put(this.environment.apiV2 + "/users/status", user)
|
|
6312
|
+
.pipe(operators.map(function () {
|
|
6313
|
+
_this.cache = user;
|
|
6314
|
+
_this.cacheSubject.next(_this.cache);
|
|
6315
|
+
}));
|
|
6316
|
+
};
|
|
6317
|
+
/**
|
|
6318
|
+
* Update user photo
|
|
6319
|
+
*/
|
|
6320
|
+
UserService.prototype.updatePhoto = function (photo) {
|
|
6321
|
+
var _this = this;
|
|
6322
|
+
return this.http.post(this.environment.apiV2 + "/users/photo?_method=PUT", photo)
|
|
6323
|
+
.pipe(operators.map(function (photoUrl) {
|
|
6324
|
+
_this.cache = classTransformer.plainToClass(User, Object.assign(_this.cache, { photo: photoUrl }));
|
|
6325
|
+
_this.cacheSubject.next(_this.cache);
|
|
6326
|
+
}));
|
|
6327
|
+
};
|
|
6328
|
+
UserService.prototype.switchFinancialYear = function (year) {
|
|
6329
|
+
return this.http.get(this.environment.apiV2 + "/financial-year/switch", { params: new i1.HttpParams({ fromString: "financialYear=" + year }) }).pipe(operators.map(function () {
|
|
6330
|
+
localStorage.setItem('financialYear', year.toString());
|
|
6331
|
+
window.location.reload();
|
|
6332
|
+
}));
|
|
6333
|
+
};
|
|
6334
|
+
/**
|
|
6335
|
+
* clear service cache
|
|
6336
|
+
*/
|
|
6337
|
+
UserService.prototype.resetCache = function () {
|
|
6338
|
+
this.fetch().subscribe();
|
|
6339
|
+
};
|
|
6340
|
+
/**
|
|
6341
|
+
* Create basiq (if not exist yet) to provide access to basiq api
|
|
6342
|
+
*/
|
|
6343
|
+
UserService.prototype.createBasiq = function () {
|
|
6344
|
+
var _this = this;
|
|
6345
|
+
return this.http.post(this.environment.apiV2 + "/basiq/user", {})
|
|
6346
|
+
.pipe(operators.map(function (basiqId) {
|
|
6347
|
+
_this.cache = classTransformer.plainToClass(User, Object.assign(_this.cache, { basiqId: basiqId }));
|
|
6348
|
+
_this.cacheSubject.next(_this.cache);
|
|
6349
|
+
return basiqId;
|
|
6350
|
+
}));
|
|
6351
|
+
};
|
|
6352
|
+
/**
|
|
6353
|
+
* Update cache when user's service subscription is updated
|
|
6354
|
+
*/
|
|
6355
|
+
UserService.prototype.listenServiceSubscriptionUpdated = function () {
|
|
6356
|
+
var _this = this;
|
|
6357
|
+
this.eventDispatcherService.on(exports.AppEventTypeEnum.SERVICE_SUBSCRIPTION_UPDATED).subscribe(function () { return _this.resetCache(); });
|
|
6358
|
+
};
|
|
6359
|
+
return UserService;
|
|
6360
|
+
}());
|
|
6361
|
+
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 });
|
|
6362
|
+
UserService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserService, providedIn: 'root' });
|
|
6363
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserService, decorators: [{
|
|
6364
|
+
type: i0.Injectable,
|
|
6365
|
+
args: [{
|
|
6366
|
+
providedIn: 'root'
|
|
6367
|
+
}]
|
|
6368
|
+
}], ctorParameters: function () {
|
|
6369
|
+
return [{ type: i1__namespace.HttpClient }, { type: JwtService }, { type: EventDispatcherService }, { type: SseService }, { type: undefined, decorators: [{
|
|
6370
|
+
type: i0.Inject,
|
|
6371
|
+
args: ['environment']
|
|
6372
|
+
}] }];
|
|
6373
|
+
} });
|
|
6374
|
+
|
|
6375
|
+
/**
|
|
6376
|
+
* Interceptor which check if client's basiq id exist and request it if not
|
|
6377
|
+
*/
|
|
6378
|
+
var BasiqClientIdInterceptor = /** @class */ (function () {
|
|
6379
|
+
function BasiqClientIdInterceptor(userService) {
|
|
6380
|
+
this.userService = userService;
|
|
6381
|
+
}
|
|
6382
|
+
BasiqClientIdInterceptor.prototype.intercept = function (request, next) {
|
|
6383
|
+
var _this = this;
|
|
6384
|
+
// Check if 'client id' URL segment contains null instead of id
|
|
6385
|
+
if (!request.url.startsWith(BasiqService.basiqApiUrl + "/users/null")) {
|
|
6386
|
+
return next.handle(request);
|
|
6387
|
+
}
|
|
6388
|
+
return this.userService.createBasiq().pipe(operators.mergeMap(function (basiqClientId) { return next.handle(_this.addId(request, basiqClientId)); }));
|
|
6389
|
+
};
|
|
6390
|
+
BasiqClientIdInterceptor.prototype.addId = function (request, basiqClientId) {
|
|
6391
|
+
return request.clone({
|
|
6392
|
+
url: request.url.replace('null', basiqClientId)
|
|
6393
|
+
});
|
|
6394
|
+
};
|
|
6395
|
+
return BasiqClientIdInterceptor;
|
|
6396
|
+
}());
|
|
6397
|
+
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 });
|
|
6398
|
+
BasiqClientIdInterceptor.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqClientIdInterceptor });
|
|
6399
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqClientIdInterceptor, decorators: [{
|
|
6400
|
+
type: i0.Injectable
|
|
6401
|
+
}], ctorParameters: function () { return [{ type: UserService }]; } });
|
|
6402
|
+
|
|
6157
6403
|
var InterceptorsModule = /** @class */ (function () {
|
|
6158
6404
|
function InterceptorsModule() {
|
|
6159
6405
|
}
|
|
@@ -6190,7 +6436,12 @@
|
|
|
6190
6436
|
},
|
|
6191
6437
|
{
|
|
6192
6438
|
provide: i1.HTTP_INTERCEPTORS,
|
|
6193
|
-
useClass:
|
|
6439
|
+
useClass: BasiqTokenInterceptor,
|
|
6440
|
+
multi: true
|
|
6441
|
+
},
|
|
6442
|
+
{
|
|
6443
|
+
provide: i1.HTTP_INTERCEPTORS,
|
|
6444
|
+
useClass: BasiqClientIdInterceptor,
|
|
6194
6445
|
multi: true
|
|
6195
6446
|
}
|
|
6196
6447
|
] });
|
|
@@ -6226,7 +6477,12 @@
|
|
|
6226
6477
|
},
|
|
6227
6478
|
{
|
|
6228
6479
|
provide: i1.HTTP_INTERCEPTORS,
|
|
6229
|
-
useClass:
|
|
6480
|
+
useClass: BasiqTokenInterceptor,
|
|
6481
|
+
multi: true
|
|
6482
|
+
},
|
|
6483
|
+
{
|
|
6484
|
+
provide: i1.HTTP_INTERCEPTORS,
|
|
6485
|
+
useClass: BasiqClientIdInterceptor,
|
|
6230
6486
|
multi: true
|
|
6231
6487
|
}
|
|
6232
6488
|
]
|
|
@@ -6309,7 +6565,7 @@
|
|
|
6309
6565
|
if (this.items.length < 2) {
|
|
6310
6566
|
return false;
|
|
6311
6567
|
}
|
|
6312
|
-
return VehicleLogbook.
|
|
6568
|
+
return VehicleLogbook.bestPeriodDuration < (this.last.date.getTime() - this.first.date.getTime());
|
|
6313
6569
|
};
|
|
6314
6570
|
/**
|
|
6315
6571
|
* Get collection of non-personal logbooks (work-related, sole-related).
|
|
@@ -11210,7 +11466,11 @@
|
|
|
11210
11466
|
this.toastService = toastService;
|
|
11211
11467
|
this.cacheSubject = new rxjs.ReplaySubject(1);
|
|
11212
11468
|
this.url = 'sole-depreciation-methods';
|
|
11469
|
+
this.listenEvents();
|
|
11213
11470
|
}
|
|
11471
|
+
SoleDepreciationMethodService.prototype.listenEvents = function () {
|
|
11472
|
+
this.listenSoleDetailsChanges();
|
|
11473
|
+
};
|
|
11214
11474
|
SoleDepreciationMethodService.prototype.get = function () {
|
|
11215
11475
|
var _this = this;
|
|
11216
11476
|
if (!this.cache) {
|
|
@@ -11238,6 +11498,14 @@
|
|
|
11238
11498
|
return throwError.throwError(error);
|
|
11239
11499
|
}));
|
|
11240
11500
|
};
|
|
11501
|
+
SoleDepreciationMethodService.prototype.listenSoleDetailsChanges = function () {
|
|
11502
|
+
var _this = this;
|
|
11503
|
+
this.eventDispatcherService.on([exports.AppEventTypeEnum.SOLE_DETAILS_CREATED, exports.AppEventTypeEnum.SOLE_DETAILS_UPDATED])
|
|
11504
|
+
.subscribe(function () {
|
|
11505
|
+
_this.cache = null;
|
|
11506
|
+
_this.get().subscribe();
|
|
11507
|
+
});
|
|
11508
|
+
};
|
|
11241
11509
|
return SoleDepreciationMethodService;
|
|
11242
11510
|
}());
|
|
11243
11511
|
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 +11526,10 @@
|
|
|
11258
11526
|
* @TODO TT-1777 Alex: extend from rest service when it refactored
|
|
11259
11527
|
*/
|
|
11260
11528
|
var SoleDetailsService = /** @class */ (function () {
|
|
11261
|
-
function SoleDetailsService(http, environment) {
|
|
11529
|
+
function SoleDetailsService(http, environment, eventDispatcherService) {
|
|
11262
11530
|
this.http = http;
|
|
11263
11531
|
this.environment = environment;
|
|
11532
|
+
this.eventDispatcherService = eventDispatcherService;
|
|
11264
11533
|
this.cacheSubject = new rxjs.ReplaySubject(1);
|
|
11265
11534
|
}
|
|
11266
11535
|
SoleDetailsService.prototype.get = function () {
|
|
@@ -11285,6 +11554,7 @@
|
|
|
11285
11554
|
return this.http.post(this.environment.apiV2 + "/sole-details", soleDetails).pipe(operators.map(function (soleDetailsBase) {
|
|
11286
11555
|
_this.cache = classTransformer.plainToClass(SoleDetails, soleDetailsBase);
|
|
11287
11556
|
_this.cacheSubject.next(_this.cache);
|
|
11557
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.SOLE_DETAILS_CREATED, soleDetails));
|
|
11288
11558
|
return _this.cache;
|
|
11289
11559
|
}));
|
|
11290
11560
|
};
|
|
@@ -11293,12 +11563,13 @@
|
|
|
11293
11563
|
return this.http.put(this.environment.apiV2 + "/sole-details/" + soleDetails.id, soleDetails).pipe(operators.map(function (soleDetailsBase) {
|
|
11294
11564
|
_this.cache = classTransformer.plainToClass(SoleDetails, soleDetailsBase);
|
|
11295
11565
|
_this.cacheSubject.next(_this.cache);
|
|
11566
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.SOLE_DETAILS_UPDATED, soleDetails));
|
|
11296
11567
|
return _this.cache;
|
|
11297
11568
|
}));
|
|
11298
11569
|
};
|
|
11299
11570
|
return SoleDetailsService;
|
|
11300
11571
|
}());
|
|
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 });
|
|
11572
|
+
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
11573
|
SoleDetailsService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleDetailsService, providedIn: 'root' });
|
|
11303
11574
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleDetailsService, decorators: [{
|
|
11304
11575
|
type: i0.Injectable,
|
|
@@ -11309,7 +11580,7 @@
|
|
|
11309
11580
|
return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
|
|
11310
11581
|
type: i0.Inject,
|
|
11311
11582
|
args: ['environment']
|
|
11312
|
-
}] }];
|
|
11583
|
+
}] }, { type: EventDispatcherService }];
|
|
11313
11584
|
} });
|
|
11314
11585
|
|
|
11315
11586
|
var SoleInvoiceService = /** @class */ (function (_super) {
|
|
@@ -13448,54 +13719,6 @@
|
|
|
13448
13719
|
}]
|
|
13449
13720
|
}] });
|
|
13450
13721
|
|
|
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
13722
|
/**
|
|
13500
13723
|
* Service for work with chats
|
|
13501
13724
|
*/
|
|
@@ -16207,161 +16430,6 @@
|
|
|
16207
16430
|
}]
|
|
16208
16431
|
}] });
|
|
16209
16432
|
|
|
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
16433
|
/**
|
|
16366
16434
|
* Service to work with XLSX (generate, download, e.t.c.)
|
|
16367
16435
|
*/
|
|
@@ -16990,7 +17058,7 @@
|
|
|
16990
17058
|
name: new forms.FormControl(business.name, forms.Validators.required),
|
|
16991
17059
|
activity: new forms.FormControl(business.activity, forms.Validators.required),
|
|
16992
17060
|
description: new forms.FormControl(business.description),
|
|
16993
|
-
website: new forms.FormControl(business.website)
|
|
17061
|
+
website: new forms.FormControl(business.website)
|
|
16994
17062
|
}, business) || this;
|
|
16995
17063
|
// User have to create income source with new business.
|
|
16996
17064
|
// Income source is not able for edit business
|
|
@@ -17007,6 +17075,12 @@
|
|
|
17007
17075
|
})
|
|
17008
17076
|
])
|
|
17009
17077
|
}));
|
|
17078
|
+
_this.addControl('losses', new forms.FormArray([
|
|
17079
|
+
new forms.FormGroup({
|
|
17080
|
+
financialYear: new forms.FormControl(new FinancialYear().year),
|
|
17081
|
+
openBalance: new forms.FormControl(null, forms.Validators.required)
|
|
17082
|
+
})
|
|
17083
|
+
]));
|
|
17010
17084
|
}
|
|
17011
17085
|
return _this;
|
|
17012
17086
|
}
|
|
@@ -17017,6 +17091,13 @@
|
|
|
17017
17091
|
enumerable: false,
|
|
17018
17092
|
configurable: true
|
|
17019
17093
|
});
|
|
17094
|
+
Object.defineProperty(SoleBusinessForm.prototype, "lossFormGroup", {
|
|
17095
|
+
get: function () {
|
|
17096
|
+
return this.get('losses').at(0);
|
|
17097
|
+
},
|
|
17098
|
+
enumerable: false,
|
|
17099
|
+
configurable: true
|
|
17100
|
+
});
|
|
17020
17101
|
return SoleBusinessForm;
|
|
17021
17102
|
}(AbstractForm));
|
|
17022
17103
|
|
|
@@ -17112,11 +17193,23 @@
|
|
|
17112
17193
|
return SoleDepreciationMethodForm;
|
|
17113
17194
|
}(AbstractForm));
|
|
17114
17195
|
|
|
17196
|
+
/**
|
|
17197
|
+
* Validator check if entered strong length is equal to passed length parameter
|
|
17198
|
+
*/
|
|
17199
|
+
function requiredLengthValidator(length) {
|
|
17200
|
+
return function (control) {
|
|
17201
|
+
if (control.value && control.value.length !== length) {
|
|
17202
|
+
return { requiredLength: length };
|
|
17203
|
+
}
|
|
17204
|
+
return null;
|
|
17205
|
+
};
|
|
17206
|
+
}
|
|
17207
|
+
|
|
17115
17208
|
var SoleDetailsForm = /** @class */ (function (_super) {
|
|
17116
17209
|
__extends(SoleDetailsForm, _super);
|
|
17117
17210
|
function SoleDetailsForm(soleDetails) {
|
|
17118
17211
|
return _super.call(this, {
|
|
17119
|
-
abn: new forms.FormControl(soleDetails.abn, [forms.Validators.required,
|
|
17212
|
+
abn: new forms.FormControl(soleDetails.abn, [forms.Validators.required, requiredLengthValidator(11)]),
|
|
17120
17213
|
isGST: new forms.FormControl(soleDetails.isGST || false)
|
|
17121
17214
|
}, soleDetails) || this;
|
|
17122
17215
|
}
|