taxtank-core 0.28.0 → 0.28.3
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 +366 -245
- package/bundles/taxtank-core.umd.js.map +1 -1
- package/esm2015/lib/collections/index.js +2 -1
- package/esm2015/lib/collections/sole/index.js +2 -0
- package/esm2015/lib/collections/sole/sole-invoice.collection.js +13 -0
- 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/sole/sole-invoice.js +7 -1
- 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/min-date/min-date.validator.js +6 -2
- package/esm2015/lib/validators/required-length.validator.js +12 -0
- package/fesm2015/taxtank-core.js +334 -227
- package/fesm2015/taxtank-core.js.map +1 -1
- package/lib/collections/index.d.ts +1 -0
- package/lib/collections/sole/index.d.ts +1 -0
- package/lib/collections/sole/sole-invoice.collection.d.ts +7 -0
- 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/sole/sole-invoice.d.ts +2 -0
- 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'),
|
|
@@ -3333,6 +3336,12 @@
|
|
|
3333
3336
|
SoleInvoice.prototype.isPaid = function () {
|
|
3334
3337
|
return this.status === exports.SoleInvoiceStatusesEnum.PAID;
|
|
3335
3338
|
};
|
|
3339
|
+
SoleInvoice.prototype.isOverdue = function () {
|
|
3340
|
+
return this.isPending() && this.dateTo < new Date();
|
|
3341
|
+
};
|
|
3342
|
+
SoleInvoice.prototype.isUnpaid = function () {
|
|
3343
|
+
return this.isPending() && this.dateTo >= new Date();
|
|
3344
|
+
};
|
|
3336
3345
|
return SoleInvoice;
|
|
3337
3346
|
}(SoleInvoice$1));
|
|
3338
3347
|
__decorate([
|
|
@@ -3427,15 +3436,15 @@
|
|
|
3427
3436
|
* Get logbook period date range from logbook date and weeksInPeriod duration
|
|
3428
3437
|
*/
|
|
3429
3438
|
VehicleLogbook.prototype.getPeriod = function () {
|
|
3430
|
-
return moment.rangeFromInterval('
|
|
3439
|
+
return moment.rangeFromInterval('milliseconds', VehicleLogbook.bestPeriodDuration, this.date);
|
|
3431
3440
|
};
|
|
3432
3441
|
return VehicleLogbook;
|
|
3433
3442
|
}(VehicleLogbook$1));
|
|
3434
3443
|
/**
|
|
3435
|
-
* Logbook period duration in
|
|
3444
|
+
* Logbook period duration in milliseconds.
|
|
3436
3445
|
* https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/211517441/Logbook+Vehicle
|
|
3437
3446
|
*/
|
|
3438
|
-
VehicleLogbook.
|
|
3447
|
+
VehicleLogbook.bestPeriodDuration = 12 * 7 * 24 * 3600 * 1000;
|
|
3439
3448
|
__decorate([
|
|
3440
3449
|
classTransformer.Type(function () { return Date; })
|
|
3441
3450
|
], VehicleLogbook.prototype, "date", void 0);
|
|
@@ -6119,11 +6128,11 @@
|
|
|
6119
6128
|
/**
|
|
6120
6129
|
* Interceptor which adds user's basiq token to any http request to basiq api
|
|
6121
6130
|
*/
|
|
6122
|
-
var
|
|
6123
|
-
function
|
|
6131
|
+
var BasiqTokenInterceptor = /** @class */ (function () {
|
|
6132
|
+
function BasiqTokenInterceptor(basiqTokenService) {
|
|
6124
6133
|
this.basiqTokenService = basiqTokenService;
|
|
6125
6134
|
}
|
|
6126
|
-
|
|
6135
|
+
BasiqTokenInterceptor.prototype.intercept = function (request, next) {
|
|
6127
6136
|
var _this = this;
|
|
6128
6137
|
// skip non-basiq requests
|
|
6129
6138
|
if (!request.url.includes(BasiqService.basiqApiUrl)) {
|
|
@@ -6133,21 +6142,264 @@
|
|
|
6133
6142
|
return next.handle(_this.addToken(request, token));
|
|
6134
6143
|
}));
|
|
6135
6144
|
};
|
|
6136
|
-
|
|
6145
|
+
BasiqTokenInterceptor.prototype.addToken = function (request, token) {
|
|
6137
6146
|
return request.clone({
|
|
6138
6147
|
setHeaders: {
|
|
6139
6148
|
Authorization: 'Bearer ' + token.value
|
|
6140
6149
|
}
|
|
6141
6150
|
});
|
|
6142
6151
|
};
|
|
6143
|
-
return
|
|
6152
|
+
return BasiqTokenInterceptor;
|
|
6144
6153
|
}());
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
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: [{
|
|
6148
6157
|
type: i0.Injectable
|
|
6149
6158
|
}], ctorParameters: function () { return [{ type: BasiqTokenService }]; } });
|
|
6150
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
|
+
|
|
6151
6403
|
var InterceptorsModule = /** @class */ (function () {
|
|
6152
6404
|
function InterceptorsModule() {
|
|
6153
6405
|
}
|
|
@@ -6184,7 +6436,12 @@
|
|
|
6184
6436
|
},
|
|
6185
6437
|
{
|
|
6186
6438
|
provide: i1.HTTP_INTERCEPTORS,
|
|
6187
|
-
useClass:
|
|
6439
|
+
useClass: BasiqTokenInterceptor,
|
|
6440
|
+
multi: true
|
|
6441
|
+
},
|
|
6442
|
+
{
|
|
6443
|
+
provide: i1.HTTP_INTERCEPTORS,
|
|
6444
|
+
useClass: BasiqClientIdInterceptor,
|
|
6188
6445
|
multi: true
|
|
6189
6446
|
}
|
|
6190
6447
|
] });
|
|
@@ -6220,7 +6477,12 @@
|
|
|
6220
6477
|
},
|
|
6221
6478
|
{
|
|
6222
6479
|
provide: i1.HTTP_INTERCEPTORS,
|
|
6223
|
-
useClass:
|
|
6480
|
+
useClass: BasiqTokenInterceptor,
|
|
6481
|
+
multi: true
|
|
6482
|
+
},
|
|
6483
|
+
{
|
|
6484
|
+
provide: i1.HTTP_INTERCEPTORS,
|
|
6485
|
+
useClass: BasiqClientIdInterceptor,
|
|
6224
6486
|
multi: true
|
|
6225
6487
|
}
|
|
6226
6488
|
]
|
|
@@ -6303,7 +6565,7 @@
|
|
|
6303
6565
|
if (this.items.length < 2) {
|
|
6304
6566
|
return false;
|
|
6305
6567
|
}
|
|
6306
|
-
return VehicleLogbook.
|
|
6568
|
+
return VehicleLogbook.bestPeriodDuration < (this.last.date.getTime() - this.first.date.getTime());
|
|
6307
6569
|
};
|
|
6308
6570
|
/**
|
|
6309
6571
|
* Get collection of non-personal logbooks (work-related, sole-related).
|
|
@@ -6386,6 +6648,23 @@
|
|
|
6386
6648
|
return VehicleLogbookCollection;
|
|
6387
6649
|
}(Collection));
|
|
6388
6650
|
|
|
6651
|
+
var SoleInvoiceCollection = /** @class */ (function (_super) {
|
|
6652
|
+
__extends(SoleInvoiceCollection, _super);
|
|
6653
|
+
function SoleInvoiceCollection() {
|
|
6654
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6655
|
+
}
|
|
6656
|
+
SoleInvoiceCollection.prototype.getOverdue = function () {
|
|
6657
|
+
return this.filter(function (invoice) { return invoice.isOverdue(); });
|
|
6658
|
+
};
|
|
6659
|
+
SoleInvoiceCollection.prototype.getUnpaid = function () {
|
|
6660
|
+
return this.filter(function (invoice) { return invoice.isUnpaid(); });
|
|
6661
|
+
};
|
|
6662
|
+
SoleInvoiceCollection.prototype.getPaid = function () {
|
|
6663
|
+
return this.filter(function (invoice) { return invoice.isPaid(); });
|
|
6664
|
+
};
|
|
6665
|
+
return SoleInvoiceCollection;
|
|
6666
|
+
}(Collection));
|
|
6667
|
+
|
|
6389
6668
|
// @TODO Alex move here all collections
|
|
6390
6669
|
|
|
6391
6670
|
var AccountSetupItemCollection = /** @class */ (function (_super) {
|
|
@@ -11187,7 +11466,11 @@
|
|
|
11187
11466
|
this.toastService = toastService;
|
|
11188
11467
|
this.cacheSubject = new rxjs.ReplaySubject(1);
|
|
11189
11468
|
this.url = 'sole-depreciation-methods';
|
|
11469
|
+
this.listenEvents();
|
|
11190
11470
|
}
|
|
11471
|
+
SoleDepreciationMethodService.prototype.listenEvents = function () {
|
|
11472
|
+
this.listenSoleDetailsChanges();
|
|
11473
|
+
};
|
|
11191
11474
|
SoleDepreciationMethodService.prototype.get = function () {
|
|
11192
11475
|
var _this = this;
|
|
11193
11476
|
if (!this.cache) {
|
|
@@ -11215,6 +11498,14 @@
|
|
|
11215
11498
|
return throwError.throwError(error);
|
|
11216
11499
|
}));
|
|
11217
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
|
+
};
|
|
11218
11509
|
return SoleDepreciationMethodService;
|
|
11219
11510
|
}());
|
|
11220
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 });
|
|
@@ -11235,9 +11526,10 @@
|
|
|
11235
11526
|
* @TODO TT-1777 Alex: extend from rest service when it refactored
|
|
11236
11527
|
*/
|
|
11237
11528
|
var SoleDetailsService = /** @class */ (function () {
|
|
11238
|
-
function SoleDetailsService(http, environment) {
|
|
11529
|
+
function SoleDetailsService(http, environment, eventDispatcherService) {
|
|
11239
11530
|
this.http = http;
|
|
11240
11531
|
this.environment = environment;
|
|
11532
|
+
this.eventDispatcherService = eventDispatcherService;
|
|
11241
11533
|
this.cacheSubject = new rxjs.ReplaySubject(1);
|
|
11242
11534
|
}
|
|
11243
11535
|
SoleDetailsService.prototype.get = function () {
|
|
@@ -11262,6 +11554,7 @@
|
|
|
11262
11554
|
return this.http.post(this.environment.apiV2 + "/sole-details", soleDetails).pipe(operators.map(function (soleDetailsBase) {
|
|
11263
11555
|
_this.cache = classTransformer.plainToClass(SoleDetails, soleDetailsBase);
|
|
11264
11556
|
_this.cacheSubject.next(_this.cache);
|
|
11557
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.SOLE_DETAILS_CREATED, soleDetails));
|
|
11265
11558
|
return _this.cache;
|
|
11266
11559
|
}));
|
|
11267
11560
|
};
|
|
@@ -11270,12 +11563,13 @@
|
|
|
11270
11563
|
return this.http.put(this.environment.apiV2 + "/sole-details/" + soleDetails.id, soleDetails).pipe(operators.map(function (soleDetailsBase) {
|
|
11271
11564
|
_this.cache = classTransformer.plainToClass(SoleDetails, soleDetailsBase);
|
|
11272
11565
|
_this.cacheSubject.next(_this.cache);
|
|
11566
|
+
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.SOLE_DETAILS_UPDATED, soleDetails));
|
|
11273
11567
|
return _this.cache;
|
|
11274
11568
|
}));
|
|
11275
11569
|
};
|
|
11276
11570
|
return SoleDetailsService;
|
|
11277
11571
|
}());
|
|
11278
|
-
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 });
|
|
11279
11573
|
SoleDetailsService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleDetailsService, providedIn: 'root' });
|
|
11280
11574
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleDetailsService, decorators: [{
|
|
11281
11575
|
type: i0.Injectable,
|
|
@@ -11286,7 +11580,7 @@
|
|
|
11286
11580
|
return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
|
|
11287
11581
|
type: i0.Inject,
|
|
11288
11582
|
args: ['environment']
|
|
11289
|
-
}] }];
|
|
11583
|
+
}] }, { type: EventDispatcherService }];
|
|
11290
11584
|
} });
|
|
11291
11585
|
|
|
11292
11586
|
var SoleInvoiceService = /** @class */ (function (_super) {
|
|
@@ -13425,54 +13719,6 @@
|
|
|
13425
13719
|
}]
|
|
13426
13720
|
}] });
|
|
13427
13721
|
|
|
13428
|
-
/**
|
|
13429
|
-
* server sent events service
|
|
13430
|
-
* https://symfony.com/doc/current/mercure.html
|
|
13431
|
-
*/
|
|
13432
|
-
var SseService = /** @class */ (function () {
|
|
13433
|
-
function SseService(zone, jwtService, environment) {
|
|
13434
|
-
this.zone = zone;
|
|
13435
|
-
this.jwtService = jwtService;
|
|
13436
|
-
this.environment = environment;
|
|
13437
|
-
}
|
|
13438
|
-
/**
|
|
13439
|
-
* list to url for server events
|
|
13440
|
-
*/
|
|
13441
|
-
SseService.prototype.on = function (topic) {
|
|
13442
|
-
var _this = this;
|
|
13443
|
-
var url = new URL(this.environment.mercureUrl);
|
|
13444
|
-
url.searchParams.append('topic', this.environment.apiV2 + "/users/" + this.jwtService.decodeToken().username + "/" + topic);
|
|
13445
|
-
// tslint:disable-next-line:typedef
|
|
13446
|
-
return new rxjs.Observable(function (observer) {
|
|
13447
|
-
var es = new eventsource_min_js.EventSourcePolyfill(url, {
|
|
13448
|
-
headers: {
|
|
13449
|
-
Authorization: 'Bearer ' + _this.jwtService.getToken(),
|
|
13450
|
-
}
|
|
13451
|
-
});
|
|
13452
|
-
es.onmessage = function (event) {
|
|
13453
|
-
_this.zone.run(function () { return observer.next(event); });
|
|
13454
|
-
};
|
|
13455
|
-
})
|
|
13456
|
-
.pipe(operators.map(function (messageEvent) {
|
|
13457
|
-
return JSON.parse(messageEvent.data);
|
|
13458
|
-
}));
|
|
13459
|
-
};
|
|
13460
|
-
return SseService;
|
|
13461
|
-
}());
|
|
13462
|
-
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 });
|
|
13463
|
-
SseService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SseService, providedIn: 'root' });
|
|
13464
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SseService, decorators: [{
|
|
13465
|
-
type: i0.Injectable,
|
|
13466
|
-
args: [{
|
|
13467
|
-
providedIn: 'root'
|
|
13468
|
-
}]
|
|
13469
|
-
}], ctorParameters: function () {
|
|
13470
|
-
return [{ type: i0__namespace.NgZone }, { type: JwtService }, { type: undefined, decorators: [{
|
|
13471
|
-
type: i0.Inject,
|
|
13472
|
-
args: ['environment']
|
|
13473
|
-
}] }];
|
|
13474
|
-
} });
|
|
13475
|
-
|
|
13476
13722
|
/**
|
|
13477
13723
|
* Service for work with chats
|
|
13478
13724
|
*/
|
|
@@ -16184,161 +16430,6 @@
|
|
|
16184
16430
|
}]
|
|
16185
16431
|
}] });
|
|
16186
16432
|
|
|
16187
|
-
/**
|
|
16188
|
-
* Service to work with user
|
|
16189
|
-
*/
|
|
16190
|
-
var UserService = /** @class */ (function () {
|
|
16191
|
-
function UserService(http, jwtService, eventDispatcherService, sseService, environment) {
|
|
16192
|
-
this.http = http;
|
|
16193
|
-
this.jwtService = jwtService;
|
|
16194
|
-
this.eventDispatcherService = eventDispatcherService;
|
|
16195
|
-
this.sseService = sseService;
|
|
16196
|
-
this.environment = environment;
|
|
16197
|
-
this.cacheSubject = new rxjs.ReplaySubject(1);
|
|
16198
|
-
this.listenEvents();
|
|
16199
|
-
}
|
|
16200
|
-
UserService.prototype.listenEvents = function () {
|
|
16201
|
-
this.listenServiceSubscriptionUpdated();
|
|
16202
|
-
};
|
|
16203
|
-
UserService.prototype.get = function () {
|
|
16204
|
-
var _this = this;
|
|
16205
|
-
if (!this.cache) {
|
|
16206
|
-
this.fetch().subscribe(function () { }, function (error) {
|
|
16207
|
-
// force logout user (clear localStorage) when get current user return error
|
|
16208
|
-
if (error.status === 500) {
|
|
16209
|
-
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.CURRENT_USER_GET_FAILED, null));
|
|
16210
|
-
}
|
|
16211
|
-
});
|
|
16212
|
-
}
|
|
16213
|
-
return this.cacheSubject.asObservable();
|
|
16214
|
-
};
|
|
16215
|
-
/**
|
|
16216
|
-
* Get current user
|
|
16217
|
-
*/
|
|
16218
|
-
UserService.prototype.fetch = function () {
|
|
16219
|
-
var _this = this;
|
|
16220
|
-
return this.http.get(this.environment.apiV2 + "/users/current")
|
|
16221
|
-
.pipe(operators.map(function (userBase) {
|
|
16222
|
-
var user = classTransformer.plainToClass(User, userBase);
|
|
16223
|
-
localStorage.setItem('userId', user.id.toString());
|
|
16224
|
-
// @TODO remove
|
|
16225
|
-
localStorage.setItem('financialYear', user.financialYear.toString());
|
|
16226
|
-
_this.cache = user;
|
|
16227
|
-
_this.cacheSubject.next(_this.cache);
|
|
16228
|
-
return user;
|
|
16229
|
-
}));
|
|
16230
|
-
};
|
|
16231
|
-
/**
|
|
16232
|
-
* Register new user
|
|
16233
|
-
*/
|
|
16234
|
-
UserService.prototype.register = function (data) {
|
|
16235
|
-
return this.http.post(this.environment.apiV2 + "/users/registration", data);
|
|
16236
|
-
};
|
|
16237
|
-
/**
|
|
16238
|
-
* Update user
|
|
16239
|
-
*/
|
|
16240
|
-
UserService.prototype.update = function (user) {
|
|
16241
|
-
var _this = this;
|
|
16242
|
-
return this.http.put(this.environment.apiV2 + "/users/" + user.id, user)
|
|
16243
|
-
.pipe(operators.map(function (userBase) {
|
|
16244
|
-
_this.cache = classTransformer.plainToClass(User, userBase);
|
|
16245
|
-
_this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.USER_UPDATED, null));
|
|
16246
|
-
_this.cacheSubject.next(_this.cache);
|
|
16247
|
-
}));
|
|
16248
|
-
};
|
|
16249
|
-
/**
|
|
16250
|
-
* Change user password
|
|
16251
|
-
*/
|
|
16252
|
-
UserService.prototype.changePassword = function (currentPassword, newPassword) {
|
|
16253
|
-
return this.http.put(this.environment.apiV2 + "/users/password/change", { currentPassword: currentPassword, newPassword: newPassword });
|
|
16254
|
-
};
|
|
16255
|
-
/**
|
|
16256
|
-
* Recovery user password
|
|
16257
|
-
*/
|
|
16258
|
-
UserService.prototype.recoveryPassword = function (email) {
|
|
16259
|
-
return this.http.put(this.environment.apiV2 + "/users/password/recovery", { email: email });
|
|
16260
|
-
};
|
|
16261
|
-
/**
|
|
16262
|
-
* Reset user password
|
|
16263
|
-
*/
|
|
16264
|
-
UserService.prototype.resetPassword = function (newPassword, resetToken) {
|
|
16265
|
-
return this.http.put(this.environment.apiV2 + "/users/password/reset", { newPassword: newPassword, resetToken: resetToken });
|
|
16266
|
-
};
|
|
16267
|
-
UserService.prototype.resendConfirmationEmail = function (email) {
|
|
16268
|
-
return this.http.post(this.environment.apiV2 + "/users/confirmation/resend", { email: email });
|
|
16269
|
-
};
|
|
16270
|
-
/**
|
|
16271
|
-
* Confirm registered user
|
|
16272
|
-
*/
|
|
16273
|
-
UserService.prototype.confirm = function (verificationCode) {
|
|
16274
|
-
return this.http.post(this.environment.apiV2 + "/users/confirmation", { verificationCode: verificationCode });
|
|
16275
|
-
};
|
|
16276
|
-
/**
|
|
16277
|
-
* Search existing user
|
|
16278
|
-
*/
|
|
16279
|
-
UserService.prototype.search = function (email) {
|
|
16280
|
-
return this.http.get(this.environment.apiV2 + "/users/search?email=" + email)
|
|
16281
|
-
.pipe(operators.map(function (userBase) {
|
|
16282
|
-
return classTransformer.plainToClass(User, userBase);
|
|
16283
|
-
}));
|
|
16284
|
-
};
|
|
16285
|
-
/**
|
|
16286
|
-
* Finish onboarding process
|
|
16287
|
-
*/
|
|
16288
|
-
UserService.prototype.finishOnboarding = function (user) {
|
|
16289
|
-
var _this = this;
|
|
16290
|
-
return this.http.put(this.environment.apiV2 + "/users/status", user)
|
|
16291
|
-
.pipe(operators.map(function () {
|
|
16292
|
-
_this.cache = user;
|
|
16293
|
-
_this.cacheSubject.next(_this.cache);
|
|
16294
|
-
}));
|
|
16295
|
-
};
|
|
16296
|
-
/**
|
|
16297
|
-
* Update user photo
|
|
16298
|
-
*/
|
|
16299
|
-
UserService.prototype.updatePhoto = function (photo) {
|
|
16300
|
-
var _this = this;
|
|
16301
|
-
return this.http.post(this.environment.apiV2 + "/users/photo?_method=PUT", photo)
|
|
16302
|
-
.pipe(operators.map(function (photoUrl) {
|
|
16303
|
-
_this.cache = classTransformer.plainToClass(User, Object.assign(_this.cache, { photo: photoUrl }));
|
|
16304
|
-
_this.cacheSubject.next(_this.cache);
|
|
16305
|
-
}));
|
|
16306
|
-
};
|
|
16307
|
-
UserService.prototype.switchFinancialYear = function (year) {
|
|
16308
|
-
return this.http.get(this.environment.apiV2 + "/financial-year/switch", { params: new i1.HttpParams({ fromString: "financialYear=" + year }) }).pipe(operators.map(function () {
|
|
16309
|
-
localStorage.setItem('financialYear', year.toString());
|
|
16310
|
-
window.location.reload();
|
|
16311
|
-
}));
|
|
16312
|
-
};
|
|
16313
|
-
/**
|
|
16314
|
-
* clear service cache
|
|
16315
|
-
*/
|
|
16316
|
-
UserService.prototype.resetCache = function () {
|
|
16317
|
-
this.fetch().subscribe();
|
|
16318
|
-
};
|
|
16319
|
-
/**
|
|
16320
|
-
* Update cache when user's service subscription is updated
|
|
16321
|
-
*/
|
|
16322
|
-
UserService.prototype.listenServiceSubscriptionUpdated = function () {
|
|
16323
|
-
var _this = this;
|
|
16324
|
-
this.eventDispatcherService.on(exports.AppEventTypeEnum.SERVICE_SUBSCRIPTION_UPDATED).subscribe(function () { return _this.resetCache(); });
|
|
16325
|
-
};
|
|
16326
|
-
return UserService;
|
|
16327
|
-
}());
|
|
16328
|
-
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 });
|
|
16329
|
-
UserService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserService, providedIn: 'root' });
|
|
16330
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserService, decorators: [{
|
|
16331
|
-
type: i0.Injectable,
|
|
16332
|
-
args: [{
|
|
16333
|
-
providedIn: 'root'
|
|
16334
|
-
}]
|
|
16335
|
-
}], ctorParameters: function () {
|
|
16336
|
-
return [{ type: i1__namespace.HttpClient }, { type: JwtService }, { type: EventDispatcherService }, { type: SseService }, { type: undefined, decorators: [{
|
|
16337
|
-
type: i0.Inject,
|
|
16338
|
-
args: ['environment']
|
|
16339
|
-
}] }];
|
|
16340
|
-
} });
|
|
16341
|
-
|
|
16342
16433
|
/**
|
|
16343
16434
|
* Service to work with XLSX (generate, download, e.t.c.)
|
|
16344
16435
|
*/
|
|
@@ -16863,7 +16954,11 @@
|
|
|
16863
16954
|
function minDateValidator(date, message) {
|
|
16864
16955
|
if (message === void 0) { message = MessagesEnum.INVALID_DATE.replace('$1', new i1$1.DatePipe('en-US').transform(date)); }
|
|
16865
16956
|
return function (control) {
|
|
16866
|
-
if (!control.value
|
|
16957
|
+
if (!control.value) {
|
|
16958
|
+
return null;
|
|
16959
|
+
}
|
|
16960
|
+
// form control value can be as a Moment object - we wrap it in "new Date()" to work with it like with JS Date
|
|
16961
|
+
if (new Date(control.value) >= new Date(date)) {
|
|
16867
16962
|
return null;
|
|
16868
16963
|
}
|
|
16869
16964
|
return { minDate: message };
|
|
@@ -16967,7 +17062,7 @@
|
|
|
16967
17062
|
name: new forms.FormControl(business.name, forms.Validators.required),
|
|
16968
17063
|
activity: new forms.FormControl(business.activity, forms.Validators.required),
|
|
16969
17064
|
description: new forms.FormControl(business.description),
|
|
16970
|
-
website: new forms.FormControl(business.website)
|
|
17065
|
+
website: new forms.FormControl(business.website)
|
|
16971
17066
|
}, business) || this;
|
|
16972
17067
|
// User have to create income source with new business.
|
|
16973
17068
|
// Income source is not able for edit business
|
|
@@ -16984,6 +17079,12 @@
|
|
|
16984
17079
|
})
|
|
16985
17080
|
])
|
|
16986
17081
|
}));
|
|
17082
|
+
_this.addControl('losses', new forms.FormArray([
|
|
17083
|
+
new forms.FormGroup({
|
|
17084
|
+
financialYear: new forms.FormControl(new FinancialYear().year),
|
|
17085
|
+
openBalance: new forms.FormControl(null, forms.Validators.required)
|
|
17086
|
+
})
|
|
17087
|
+
]));
|
|
16987
17088
|
}
|
|
16988
17089
|
return _this;
|
|
16989
17090
|
}
|
|
@@ -16994,6 +17095,13 @@
|
|
|
16994
17095
|
enumerable: false,
|
|
16995
17096
|
configurable: true
|
|
16996
17097
|
});
|
|
17098
|
+
Object.defineProperty(SoleBusinessForm.prototype, "lossFormGroup", {
|
|
17099
|
+
get: function () {
|
|
17100
|
+
return this.get('losses').at(0);
|
|
17101
|
+
},
|
|
17102
|
+
enumerable: false,
|
|
17103
|
+
configurable: true
|
|
17104
|
+
});
|
|
16997
17105
|
return SoleBusinessForm;
|
|
16998
17106
|
}(AbstractForm));
|
|
16999
17107
|
|
|
@@ -17089,11 +17197,23 @@
|
|
|
17089
17197
|
return SoleDepreciationMethodForm;
|
|
17090
17198
|
}(AbstractForm));
|
|
17091
17199
|
|
|
17200
|
+
/**
|
|
17201
|
+
* Validator check if entered strong length is equal to passed length parameter
|
|
17202
|
+
*/
|
|
17203
|
+
function requiredLengthValidator(length) {
|
|
17204
|
+
return function (control) {
|
|
17205
|
+
if (control.value && control.value.length !== length) {
|
|
17206
|
+
return { requiredLength: length };
|
|
17207
|
+
}
|
|
17208
|
+
return null;
|
|
17209
|
+
};
|
|
17210
|
+
}
|
|
17211
|
+
|
|
17092
17212
|
var SoleDetailsForm = /** @class */ (function (_super) {
|
|
17093
17213
|
__extends(SoleDetailsForm, _super);
|
|
17094
17214
|
function SoleDetailsForm(soleDetails) {
|
|
17095
17215
|
return _super.call(this, {
|
|
17096
|
-
abn: new forms.FormControl(soleDetails.abn, [forms.Validators.required,
|
|
17216
|
+
abn: new forms.FormControl(soleDetails.abn, [forms.Validators.required, requiredLengthValidator(11)]),
|
|
17097
17217
|
isGST: new forms.FormControl(soleDetails.isGST || false)
|
|
17098
17218
|
}, soleDetails) || this;
|
|
17099
17219
|
}
|
|
@@ -18328,6 +18448,7 @@
|
|
|
18328
18448
|
exports.SoleForecast = SoleForecast;
|
|
18329
18449
|
exports.SoleForecastService = SoleForecastService;
|
|
18330
18450
|
exports.SoleInvoice = SoleInvoice;
|
|
18451
|
+
exports.SoleInvoiceCollection = SoleInvoiceCollection;
|
|
18331
18452
|
exports.SoleInvoiceForm = SoleInvoiceForm;
|
|
18332
18453
|
exports.SoleInvoiceItem = SoleInvoiceItem;
|
|
18333
18454
|
exports.SoleInvoiceItemForm = SoleInvoiceItemForm;
|