taxtank-core 2.0.9 → 2.0.11
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/fesm2022/taxtank-core.mjs +458 -75
- package/fesm2022/taxtank-core.mjs.map +1 -1
- package/index.d.ts +5 -1
- package/package.json +1 -1
@@ -1,10 +1,10 @@
|
|
1
1
|
import * as i0 from '@angular/core';
|
2
2
|
import { Injectable, Inject, inject, EventEmitter, signal, NgModule, Pipe } from '@angular/core';
|
3
3
|
import * as i1$1 from '@angular/common';
|
4
|
-
import { formatDate, CommonModule, CurrencyPipe, DatePipe } from '@angular/common';
|
4
|
+
import { formatDate, CommonModule as CommonModule$1, CurrencyPipe, DatePipe } from '@angular/common';
|
5
5
|
import * as i1 from '@angular/common/http';
|
6
6
|
import { HttpParams, HttpClient, HttpErrorResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
|
7
|
-
import { map, catchError, mergeMap, filter, finalize, switchMap, first as first$1, startWith, debounceTime, distinctUntilChanged } from 'rxjs/operators';
|
7
|
+
import { map, catchError, mergeMap, filter, finalize, switchMap, first as first$1, take, startWith, debounceTime, distinctUntilChanged } from 'rxjs/operators';
|
8
8
|
import { ReplaySubject, throwError, Subject, Observable, shareReplay, of, forkJoin, combineLatest, BehaviorSubject, from, merge as merge$1 } from 'rxjs';
|
9
9
|
import { plainToClass, Type, Transform, Exclude, Expose, classToPlain } from 'class-transformer';
|
10
10
|
import 'reflect-metadata';
|
@@ -21,7 +21,7 @@ import uniq from 'lodash/uniq';
|
|
21
21
|
import moment from 'moment';
|
22
22
|
import { DateRange as DateRange$1 } from 'moment-range';
|
23
23
|
import * as i3 from 'taxtank-core/common';
|
24
|
-
import { UserRolesEnum, MixpanelService } from 'taxtank-core/common';
|
24
|
+
import { UserRolesEnum as UserRolesEnum$1, MixpanelService as MixpanelService$1 } from 'taxtank-core/common';
|
25
25
|
import round from 'lodash/round';
|
26
26
|
import range from 'lodash/range';
|
27
27
|
import { Validators, FormGroup, FormArray, UntypedFormControl, UntypedFormArray, UntypedFormGroup, FormControl } from '@angular/forms';
|
@@ -36,6 +36,8 @@ import _ from 'lodash';
|
|
36
36
|
import remove from 'lodash/remove';
|
37
37
|
import pick from 'lodash/pick';
|
38
38
|
import { checkAdBlock } from 'adblock-checker';
|
39
|
+
import mixpanel from 'mixpanel-browser';
|
40
|
+
import { JwtHelperService } from '@auth0/angular-jwt';
|
39
41
|
import { jsPDF } from 'jspdf';
|
40
42
|
import { applyPlugin } from 'jspdf-autotable';
|
41
43
|
import html2pdf from 'html2pdf.js';
|
@@ -4220,19 +4222,19 @@ class Occupation extends Occupation$1 {
|
|
4220
4222
|
* role hierarchy
|
4221
4223
|
*/
|
4222
4224
|
const USER_ROLES = {
|
4223
|
-
ROLE_FIRM_OWNER: [UserRolesEnum.FIRM_OWNER, UserRolesEnum.FIRM_MANAGER, UserRolesEnum.ACCOUNTANT, UserRolesEnum.ADVISOR],
|
4224
|
-
ROLE_FIRM_MANAGER: [UserRolesEnum.FIRM_MANAGER, UserRolesEnum.ACCOUNTANT, UserRolesEnum.ADVISOR],
|
4225
|
-
ROLE_EMPLOYEE: [UserRolesEnum.ACCOUNTANT, UserRolesEnum.ADVISOR],
|
4226
|
-
ROLE_ACCOUNTANT: [UserRolesEnum.ACCOUNTANT],
|
4227
|
-
ROLE_ADVISOR: [UserRolesEnum.ADVISOR],
|
4225
|
+
ROLE_FIRM_OWNER: [UserRolesEnum$1.FIRM_OWNER, UserRolesEnum$1.FIRM_MANAGER, UserRolesEnum$1.ACCOUNTANT, UserRolesEnum$1.ADVISOR],
|
4226
|
+
ROLE_FIRM_MANAGER: [UserRolesEnum$1.FIRM_MANAGER, UserRolesEnum$1.ACCOUNTANT, UserRolesEnum$1.ADVISOR],
|
4227
|
+
ROLE_EMPLOYEE: [UserRolesEnum$1.ACCOUNTANT, UserRolesEnum$1.ADVISOR],
|
4228
|
+
ROLE_ACCOUNTANT: [UserRolesEnum$1.ACCOUNTANT],
|
4229
|
+
ROLE_ADVISOR: [UserRolesEnum$1.ADVISOR],
|
4228
4230
|
// @TODO makes no sense, these roles can't be hierarchical
|
4229
|
-
ROLE_CLIENT: [UserRolesEnum.CLIENT],
|
4230
|
-
ROLE_USER_SUBSCRIPTION: [UserRolesEnum.SUBSCRIPTION],
|
4231
|
-
ROLE_USER_WORK: [UserRolesEnum.WORK_TANK],
|
4232
|
-
ROLE_USER_PROPERTY: [UserRolesEnum.PROPERTY_TANK],
|
4233
|
-
ROLE_USER_SOLE: [UserRolesEnum.SOLE_TANK],
|
4234
|
-
ROLE_USER_HOLDING: [UserRolesEnum.HOLDING_TANK],
|
4235
|
-
ROLE_PREVIOUS_ADMIN: [UserRolesEnum.SWITCH_USER],
|
4231
|
+
ROLE_CLIENT: [UserRolesEnum$1.CLIENT],
|
4232
|
+
ROLE_USER_SUBSCRIPTION: [UserRolesEnum$1.SUBSCRIPTION],
|
4233
|
+
ROLE_USER_WORK: [UserRolesEnum$1.WORK_TANK],
|
4234
|
+
ROLE_USER_PROPERTY: [UserRolesEnum$1.PROPERTY_TANK],
|
4235
|
+
ROLE_USER_SOLE: [UserRolesEnum$1.SOLE_TANK],
|
4236
|
+
ROLE_USER_HOLDING: [UserRolesEnum$1.HOLDING_TANK],
|
4237
|
+
ROLE_PREVIOUS_ADMIN: [UserRolesEnum$1.SWITCH_USER],
|
4236
4238
|
};
|
4237
4239
|
|
4238
4240
|
/**
|
@@ -4242,9 +4244,9 @@ class UserToRegister {
|
|
4242
4244
|
}
|
4243
4245
|
|
4244
4246
|
const USER_WORK_POSITION = {
|
4245
|
-
[UserRolesEnum.EMPLOYEE]: 'Employee',
|
4246
|
-
[UserRolesEnum.FIRM_MANAGER]: 'Manager',
|
4247
|
-
[UserRolesEnum.FIRM_OWNER]: 'Firm Owner'
|
4247
|
+
[UserRolesEnum$1.EMPLOYEE]: 'Employee',
|
4248
|
+
[UserRolesEnum$1.FIRM_MANAGER]: 'Manager',
|
4249
|
+
[UserRolesEnum$1.FIRM_OWNER]: 'Firm Owner'
|
4248
4250
|
};
|
4249
4251
|
|
4250
4252
|
var UserStatusEnum;
|
@@ -4746,10 +4748,10 @@ class ServiceSubscription extends ServiceSubscription$1 {
|
|
4746
4748
|
return this.items.find((item) => item.price.product.isProperties());
|
4747
4749
|
}
|
4748
4750
|
hasPropertyTank() {
|
4749
|
-
return !!this.items.find((subscriptionItem) => subscriptionItem.price.product.role.includes(UserRolesEnum.PROPERTY_TANK));
|
4751
|
+
return !!this.items.find((subscriptionItem) => subscriptionItem.price.product.role.includes(UserRolesEnum$1.PROPERTY_TANK));
|
4750
4752
|
}
|
4751
4753
|
hasWorkTank() {
|
4752
|
-
return !!this.items.find((subscriptionItem) => subscriptionItem.price.product.role.includes(UserRolesEnum.WORK_TANK));
|
4754
|
+
return !!this.items.find((subscriptionItem) => subscriptionItem.price.product.role.includes(UserRolesEnum$1.WORK_TANK));
|
4753
4755
|
}
|
4754
4756
|
/**
|
4755
4757
|
* bought before price updates, active for some time to let customer select a new plan
|
@@ -4921,10 +4923,10 @@ var ServiceProductIconsEnum;
|
|
4921
4923
|
* List of user roles related to tanks (subscription products)
|
4922
4924
|
*/
|
4923
4925
|
const SERVICE_PRODUCT_ROLES = [
|
4924
|
-
UserRolesEnum.WORK_TANK,
|
4925
|
-
UserRolesEnum.PROPERTY_TANK,
|
4926
|
-
UserRolesEnum.SOLE_TANK,
|
4927
|
-
UserRolesEnum.HOLDING_TANK
|
4926
|
+
UserRolesEnum$1.WORK_TANK,
|
4927
|
+
UserRolesEnum$1.PROPERTY_TANK,
|
4928
|
+
UserRolesEnum$1.SOLE_TANK,
|
4929
|
+
UserRolesEnum$1.HOLDING_TANK
|
4928
4930
|
];
|
4929
4931
|
|
4930
4932
|
class SoleBusinessAllocation extends SoleBusinessAllocation$1 {
|
@@ -5608,11 +5610,11 @@ class User extends User$1 {
|
|
5608
5610
|
get position() {
|
5609
5611
|
switch (true) {
|
5610
5612
|
case this.isFirmOwner():
|
5611
|
-
return USER_WORK_POSITION[UserRolesEnum.FIRM_OWNER];
|
5613
|
+
return USER_WORK_POSITION[UserRolesEnum$1.FIRM_OWNER];
|
5612
5614
|
case this.isManager():
|
5613
|
-
return USER_WORK_POSITION[UserRolesEnum.FIRM_MANAGER];
|
5615
|
+
return USER_WORK_POSITION[UserRolesEnum$1.FIRM_MANAGER];
|
5614
5616
|
case this.isEmployee():
|
5615
|
-
return USER_WORK_POSITION[UserRolesEnum.EMPLOYEE];
|
5617
|
+
return USER_WORK_POSITION[UserRolesEnum$1.EMPLOYEE];
|
5616
5618
|
default:
|
5617
5619
|
return '';
|
5618
5620
|
}
|
@@ -5633,16 +5635,16 @@ class User extends User$1 {
|
|
5633
5635
|
}
|
5634
5636
|
getTankTypes() {
|
5635
5637
|
const tankTypes = [];
|
5636
|
-
if (this.roles.includes(UserRolesEnum.WORK_TANK)) {
|
5638
|
+
if (this.roles.includes(UserRolesEnum$1.WORK_TANK)) {
|
5637
5639
|
tankTypes.push(TankTypeEnum.WORK);
|
5638
5640
|
}
|
5639
|
-
if (this.roles.includes(UserRolesEnum.PROPERTY_TANK)) {
|
5641
|
+
if (this.roles.includes(UserRolesEnum$1.PROPERTY_TANK)) {
|
5640
5642
|
tankTypes.push(TankTypeEnum.PROPERTY);
|
5641
5643
|
}
|
5642
|
-
if (this.roles.includes(UserRolesEnum.SOLE_TANK)) {
|
5644
|
+
if (this.roles.includes(UserRolesEnum$1.SOLE_TANK)) {
|
5643
5645
|
tankTypes.push(TankTypeEnum.SOLE);
|
5644
5646
|
}
|
5645
|
-
if (this.roles.includes(UserRolesEnum.HOLDING_TANK)) {
|
5647
|
+
if (this.roles.includes(UserRolesEnum$1.HOLDING_TANK)) {
|
5646
5648
|
tankTypes.push(TankTypeEnum.HOLDING);
|
5647
5649
|
}
|
5648
5650
|
tankTypes.push(TankTypeEnum.PERSONAL);
|
@@ -5655,37 +5657,37 @@ class User extends User$1 {
|
|
5655
5657
|
return this.status === UserStatusEnum.INACTIVE;
|
5656
5658
|
}
|
5657
5659
|
hasSubscription() {
|
5658
|
-
return this.roles.includes(UserRolesEnum.SUBSCRIPTION);
|
5660
|
+
return this.roles.includes(UserRolesEnum$1.SUBSCRIPTION);
|
5659
5661
|
}
|
5660
5662
|
isLoggedIn() {
|
5661
5663
|
return this.id === +localStorage.getItem('userId');
|
5662
5664
|
}
|
5663
5665
|
isClient() {
|
5664
|
-
return this.roles.includes(UserRolesEnum.CLIENT);
|
5666
|
+
return this.roles.includes(UserRolesEnum$1.CLIENT);
|
5665
5667
|
}
|
5666
5668
|
isEmployee() {
|
5667
5669
|
return this.isAccountant() || this.isAdvisor();
|
5668
5670
|
}
|
5669
5671
|
isAccountant() {
|
5670
|
-
return this.roles.includes(UserRolesEnum.ACCOUNTANT);
|
5672
|
+
return this.roles.includes(UserRolesEnum$1.ACCOUNTANT);
|
5671
5673
|
}
|
5672
5674
|
isAdvisor() {
|
5673
|
-
return this.roles.includes(UserRolesEnum.ADVISOR);
|
5675
|
+
return this.roles.includes(UserRolesEnum$1.ADVISOR);
|
5674
5676
|
}
|
5675
5677
|
isImpersonator() {
|
5676
|
-
return this.roles.includes(UserRolesEnum.SWITCH_USER);
|
5678
|
+
return this.roles.includes(UserRolesEnum$1.SWITCH_USER);
|
5677
5679
|
}
|
5678
5680
|
/**
|
5679
5681
|
* Check if current user is firm owner
|
5680
5682
|
*/
|
5681
5683
|
isFirmOwner() {
|
5682
|
-
return this.roles.includes(UserRolesEnum.FIRM_OWNER);
|
5684
|
+
return this.roles.includes(UserRolesEnum$1.FIRM_OWNER);
|
5683
5685
|
}
|
5684
5686
|
isTopManager() {
|
5685
|
-
return this.roles.includes(UserRolesEnum.FIRM_TOP_MANAGER) || this.roles.includes(UserRolesEnum.FIRM_OWNER);
|
5687
|
+
return this.roles.includes(UserRolesEnum$1.FIRM_TOP_MANAGER) || this.roles.includes(UserRolesEnum$1.FIRM_OWNER);
|
5686
5688
|
}
|
5687
5689
|
isManager() {
|
5688
|
-
return this.roles.includes(UserRolesEnum.FIRM_MANAGER) || this.roles.includes(UserRolesEnum.FIRM_TOP_MANAGER) || this.roles.includes(UserRolesEnum.FIRM_OWNER);
|
5690
|
+
return this.roles.includes(UserRolesEnum$1.FIRM_MANAGER) || this.roles.includes(UserRolesEnum$1.FIRM_TOP_MANAGER) || this.roles.includes(UserRolesEnum$1.FIRM_OWNER);
|
5689
5691
|
}
|
5690
5692
|
isCurrentFinancialYear() {
|
5691
5693
|
return new FinancialYear(new Date()).year === this.financialYear;
|
@@ -8324,7 +8326,7 @@ class VehicleExpense extends AbstractModel {
|
|
8324
8326
|
}
|
8325
8327
|
|
8326
8328
|
const REPORTS = {
|
8327
|
-
[UserRolesEnum.CLIENT]: [
|
8329
|
+
[UserRolesEnum$1.CLIENT]: [
|
8328
8330
|
{
|
8329
8331
|
title: 'Income & Expense Report',
|
8330
8332
|
description: 'Income and expense report with prior year comparison and monthly view option. Filter by Tank, property, business or personal categories.',
|
@@ -8346,7 +8348,7 @@ const REPORTS = {
|
|
8346
8348
|
routerLink: './net-assets',
|
8347
8349
|
},
|
8348
8350
|
],
|
8349
|
-
[UserRolesEnum.WORK_TANK]: [
|
8351
|
+
[UserRolesEnum$1.WORK_TANK]: [
|
8350
8352
|
{
|
8351
8353
|
title: 'Motor Vehicle Report',
|
8352
8354
|
description: 'Displays work-related vehicle expenses based upon your logbook claim method or percentage.',
|
@@ -8366,7 +8368,7 @@ const REPORTS = {
|
|
8366
8368
|
queryParams: { tankType: 2 }
|
8367
8369
|
},
|
8368
8370
|
],
|
8369
|
-
[UserRolesEnum.PROPERTY_TANK]: [
|
8371
|
+
[UserRolesEnum$1.PROPERTY_TANK]: [
|
8370
8372
|
{
|
8371
8373
|
title: 'Property Schedule',
|
8372
8374
|
description: 'Compliant property schedule detailing incomes, expenses and depreciation for each property and ownership percentage.',
|
@@ -8390,7 +8392,7 @@ const REPORTS = {
|
|
8390
8392
|
routerLink: './cgt/property',
|
8391
8393
|
},
|
8392
8394
|
],
|
8393
|
-
[UserRolesEnum.SOLE_TANK]: [
|
8395
|
+
[UserRolesEnum$1.SOLE_TANK]: [
|
8394
8396
|
{
|
8395
8397
|
title: 'Business Schedule',
|
8396
8398
|
description: 'Compliant schedule detailing profit and loss for each primary and non-primary production business.',
|
@@ -8420,7 +8422,7 @@ const REPORTS = {
|
|
8420
8422
|
routerLink: './bas',
|
8421
8423
|
},
|
8422
8424
|
],
|
8423
|
-
[UserRolesEnum.HOLDING_TANK]: [
|
8425
|
+
[UserRolesEnum$1.HOLDING_TANK]: [
|
8424
8426
|
{
|
8425
8427
|
title: 'CGT Report',
|
8426
8428
|
description: 'Calculate net capital gains across all asset classes, including the application of losses and eligible concessions.',
|
@@ -8716,7 +8718,7 @@ class ServiceSubscriptionCollection extends Collection {
|
|
8716
8718
|
getRoles() {
|
8717
8719
|
const roles = this.getActive().toArray().flatMap((subscription) => subscription.roles);
|
8718
8720
|
if (roles.length > 0) {
|
8719
|
-
roles.push(UserRolesEnum.SUBSCRIPTION);
|
8721
|
+
roles.push(UserRolesEnum$1.SUBSCRIPTION);
|
8720
8722
|
}
|
8721
8723
|
return roles;
|
8722
8724
|
}
|
@@ -12161,7 +12163,7 @@ class BankAccountService extends RestService$1 {
|
|
12161
12163
|
this.modelClass = BankAccount;
|
12162
12164
|
this.collectionClass = BankAccountCollection;
|
12163
12165
|
this.disabledMethods = ['post', 'putBatch', 'delete', 'deleteBatch'];
|
12164
|
-
this.roles = [UserRolesEnum.WORK_TANK, UserRolesEnum.PROPERTY_TANK, UserRolesEnum.SOLE_TANK];
|
12166
|
+
this.roles = [UserRolesEnum$1.WORK_TANK, UserRolesEnum$1.PROPERTY_TANK, UserRolesEnum$1.SOLE_TANK];
|
12165
12167
|
this.listenEvents();
|
12166
12168
|
}
|
12167
12169
|
getActive() {
|
@@ -13484,7 +13486,7 @@ class EmployeeService extends RestService$1 {
|
|
13484
13486
|
this.collectionClass = EmployeeCollection;
|
13485
13487
|
this.disabledMethods = ['postBatch', 'putBatch'];
|
13486
13488
|
this.messages = EmployeeMessagesEnum;
|
13487
|
-
this.roles = [UserRolesEnum.FIRM_MANAGER, UserRolesEnum.FIRM_TOP_MANAGER, UserRolesEnum.FIRM_OWNER];
|
13489
|
+
this.roles = [UserRolesEnum$1.FIRM_MANAGER, UserRolesEnum$1.FIRM_TOP_MANAGER, UserRolesEnum$1.FIRM_OWNER];
|
13488
13490
|
}
|
13489
13491
|
activateEmployee(employee) {
|
13490
13492
|
return super.put(employee, `${this.environment.apiV2}/${this.endpointUri}/${employee.id}/activate`);
|
@@ -13500,7 +13502,7 @@ class EmployeeService extends RestService$1 {
|
|
13500
13502
|
}));
|
13501
13503
|
}
|
13502
13504
|
toggleManagerRole(employee) {
|
13503
|
-
const role = UserRolesEnum.FIRM_MANAGER;
|
13505
|
+
const role = UserRolesEnum$1.FIRM_MANAGER;
|
13504
13506
|
const index = employee.roles.indexOf(role);
|
13505
13507
|
index === -1 ? employee.roles.push(role) : employee.roles.splice(index, 1);
|
13506
13508
|
return super.put(employee, `${this.environment.apiV2}/${this.endpointUri}/${employee.id}`);
|
@@ -13545,7 +13547,7 @@ class EmployeeInviteService extends RestService$1 {
|
|
13545
13547
|
this.endpointUri = 'employee-invites';
|
13546
13548
|
this.collectionClass = EmployeeInviteCollection;
|
13547
13549
|
this.modelClass = EmployeeInvite;
|
13548
|
-
this.roles = [UserRolesEnum.FIRM_MANAGER, UserRolesEnum.FIRM_TOP_MANAGER, UserRolesEnum.FIRM_OWNER];
|
13550
|
+
this.roles = [UserRolesEnum$1.FIRM_MANAGER, UserRolesEnum$1.FIRM_TOP_MANAGER, UserRolesEnum$1.FIRM_OWNER];
|
13549
13551
|
}
|
13550
13552
|
/**
|
13551
13553
|
* Import employees for firm from CSV file
|
@@ -14622,7 +14624,7 @@ class PropertySaleService extends RestService$1 {
|
|
14622
14624
|
this.collectionClass = PropertySaleCollection;
|
14623
14625
|
this.endpointUri = 'properties/sales';
|
14624
14626
|
this.disabledMethods = ['postBatch', 'putBatch', 'deleteBatch'];
|
14625
|
-
this.roles = [UserRolesEnum.PROPERTY_TANK];
|
14627
|
+
this.roles = [UserRolesEnum$1.PROPERTY_TANK];
|
14626
14628
|
}
|
14627
14629
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: PropertySaleService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
14628
14630
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: PropertySaleService, providedIn: 'root' }); }
|
@@ -14644,7 +14646,7 @@ class PropertyShareService extends RestService$1 {
|
|
14644
14646
|
this.modelClass = PropertyShare;
|
14645
14647
|
this.collectionClass = PropertyShareCollection;
|
14646
14648
|
this.disabledMethods = ['deleteBatch', 'putBatch', 'postBatch'];
|
14647
|
-
this.roles = [UserRolesEnum.PROPERTY_TANK];
|
14649
|
+
this.roles = [UserRolesEnum$1.PROPERTY_TANK];
|
14648
14650
|
this.listenEvents();
|
14649
14651
|
}
|
14650
14652
|
/**
|
@@ -14934,7 +14936,7 @@ class SoleBusinessService extends RestService$1 {
|
|
14934
14936
|
this.modelClass = SoleBusiness;
|
14935
14937
|
this.collectionClass = Collection;
|
14936
14938
|
this.endpointUri = 'sole-businesses';
|
14937
|
-
this.roles = [UserRolesEnum.SOLE_TANK];
|
14939
|
+
this.roles = [UserRolesEnum$1.SOLE_TANK];
|
14938
14940
|
}
|
14939
14941
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: SoleBusinessService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
14940
14942
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: SoleBusinessService, providedIn: 'root' }); }
|
@@ -14970,7 +14972,7 @@ class SoleBusinessLossService extends RestService$1 {
|
|
14970
14972
|
this.collectionClass = SoleBusinessLossCollection;
|
14971
14973
|
this.endpointUri = 'sole-business-losses';
|
14972
14974
|
this.disabledMethods = ['postBatch', 'putBatch', 'deleteBatch', 'delete'];
|
14973
|
-
this.roles = [UserRolesEnum.SOLE_TANK];
|
14975
|
+
this.roles = [UserRolesEnum$1.SOLE_TANK];
|
14974
14976
|
this.listenEvents();
|
14975
14977
|
}
|
14976
14978
|
listenEvents() {
|
@@ -15104,7 +15106,7 @@ class SoleDetailsService extends RestService$1 {
|
|
15104
15106
|
this.collectionClass = Collection;
|
15105
15107
|
this.endpointUri = 'sole-details';
|
15106
15108
|
this.disabledMethods = ['postBatch', 'putBatch', 'deleteBatch'];
|
15107
|
-
this.roles = [UserRolesEnum.SOLE_TANK];
|
15109
|
+
this.roles = [UserRolesEnum$1.SOLE_TANK];
|
15108
15110
|
}
|
15109
15111
|
get() {
|
15110
15112
|
return super.get().pipe(map(soleDetails => soleDetails.length ? soleDetails : new Collection([plainToClass(SoleDetails, {})])));
|
@@ -15126,7 +15128,7 @@ class SoleInvoiceService extends RestService$1 {
|
|
15126
15128
|
this.endpointUri = 'sole-invoices';
|
15127
15129
|
this.modelClass = SoleInvoice;
|
15128
15130
|
this.collectionClass = SoleInvoiceCollection;
|
15129
|
-
this.roles = [UserRolesEnum.SOLE_TANK];
|
15131
|
+
this.roles = [UserRolesEnum$1.SOLE_TANK];
|
15130
15132
|
}
|
15131
15133
|
updateStatus(invoice, status) {
|
15132
15134
|
// @TODO use id only to avoid unexpected changes
|
@@ -16363,7 +16365,7 @@ class PriorTransactionService extends RestService$1 {
|
|
16363
16365
|
this.modelClass = Transaction;
|
16364
16366
|
this.collectionClass = TransactionCollection;
|
16365
16367
|
this.disabledMethods = ['post', 'put', 'putBatch', 'delete', 'deleteBatch'];
|
16366
|
-
this.roles = [UserRolesEnum.WORK_TANK, UserRolesEnum.PROPERTY_TANK, UserRolesEnum.SOLE_TANK];
|
16368
|
+
this.roles = [UserRolesEnum$1.WORK_TANK, UserRolesEnum$1.PROPERTY_TANK, UserRolesEnum$1.SOLE_TANK];
|
16367
16369
|
}
|
16368
16370
|
get() {
|
16369
16371
|
const financialYear = new FinancialYear(new FinancialYear().year - 1);
|
@@ -16469,7 +16471,7 @@ class VehicleClaimService extends RestService$1 {
|
|
16469
16471
|
this.endpointUri = 'vehicle-claims';
|
16470
16472
|
this.modelClass = VehicleClaim;
|
16471
16473
|
this.collectionClass = VehicleClaimCollection;
|
16472
|
-
this.roles = [UserRolesEnum.WORK_TANK, UserRolesEnum.SOLE_TANK];
|
16474
|
+
this.roles = [UserRolesEnum$1.WORK_TANK, UserRolesEnum$1.SOLE_TANK];
|
16473
16475
|
this.listenEvents();
|
16474
16476
|
}
|
16475
16477
|
listenEvents() {
|
@@ -16800,7 +16802,7 @@ class UserService extends RestService$1 {
|
|
16800
16802
|
this.collectionClass = Collection;
|
16801
16803
|
this.endpointUri = 'users';
|
16802
16804
|
this.disabledMethods = ['postBatch', 'putBatch', 'deleteBatch', 'delete'];
|
16803
|
-
this.mpService = inject(MixpanelService);
|
16805
|
+
this.mpService = inject(MixpanelService$1);
|
16804
16806
|
this.listenEvents();
|
16805
16807
|
}
|
16806
16808
|
listenEvents() {
|
@@ -16996,7 +16998,7 @@ class HoldingTradeService extends RestService$1 {
|
|
16996
16998
|
this.collectionClass = HoldingTradeCollection;
|
16997
16999
|
this.endpointUri = 'holding-trades';
|
16998
17000
|
this.disabledMethods = ['postBatch', 'putBatch'];
|
16999
|
-
this.roles = [UserRolesEnum.HOLDING_TANK];
|
17001
|
+
this.roles = [UserRolesEnum$1.HOLDING_TANK];
|
17000
17002
|
this.listenEvents();
|
17001
17003
|
this.listenNotifications();
|
17002
17004
|
}
|
@@ -17032,7 +17034,7 @@ class HoldingTypeService extends RestService$1 {
|
|
17032
17034
|
this.collectionClass = HoldingTypeCollection;
|
17033
17035
|
this.endpointUri = 'holding-types';
|
17034
17036
|
this.disabledMethods = ['postBatch', 'putBatch', 'deleteBatch'];
|
17035
|
-
this.roles = [UserRolesEnum.HOLDING_TANK];
|
17037
|
+
this.roles = [UserRolesEnum$1.HOLDING_TANK];
|
17036
17038
|
this.listenEvents();
|
17037
17039
|
this.listenNotifications();
|
17038
17040
|
}
|
@@ -17071,7 +17073,7 @@ class HoldingSaleService extends RestService$1 {
|
|
17071
17073
|
this.collectionClass = HoldingSaleCollection;
|
17072
17074
|
this.endpointUri = 'holding-sales';
|
17073
17075
|
this.disabledMethods = ['postBatch', 'putBatch', 'deleteBatch'];
|
17074
|
-
this.roles = [UserRolesEnum.HOLDING_TANK];
|
17076
|
+
this.roles = [UserRolesEnum$1.HOLDING_TANK];
|
17075
17077
|
}
|
17076
17078
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: HoldingSaleService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
17077
17079
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: HoldingSaleService, providedIn: 'root' }); }
|
@@ -17099,7 +17101,7 @@ class HoldingTradeImportService extends RestService$1 {
|
|
17099
17101
|
this.collectionClass = (Collection);
|
17100
17102
|
this.endpointUri = 'holding-trade-imports';
|
17101
17103
|
this.disabledMethods = ['post', 'postBatch', 'putBatch', 'deleteBatch'];
|
17102
|
-
this.roles = [UserRolesEnum.HOLDING_TANK];
|
17104
|
+
this.roles = [UserRolesEnum$1.HOLDING_TANK];
|
17103
17105
|
}
|
17104
17106
|
import(file, exchangeId, isTaxFree) {
|
17105
17107
|
const formData = new FormData();
|
@@ -17250,7 +17252,7 @@ class HomeOfficeClaimService extends RestService$1 {
|
|
17250
17252
|
this.modelClass = HomeOfficeClaim;
|
17251
17253
|
this.collectionClass = HomeOfficeClaimCollection;
|
17252
17254
|
this.disabledMethods = ['postBatch', 'putBatch', 'deleteBatch'];
|
17253
|
-
this.roles = [UserRolesEnum.WORK_TANK, UserRolesEnum.SOLE_TANK];
|
17255
|
+
this.roles = [UserRolesEnum$1.WORK_TANK, UserRolesEnum$1.SOLE_TANK];
|
17254
17256
|
}
|
17255
17257
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: HomeOfficeClaimService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
17256
17258
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: HomeOfficeClaimService, providedIn: 'root' }); }
|
@@ -19705,11 +19707,383 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
|
|
19705
19707
|
}]
|
19706
19708
|
}], ctorParameters: () => [] });
|
19707
19709
|
|
19710
|
+
/**
|
19711
|
+
* Service to work with mixpanel https://docs.mixpanel.com/docs/tracking/reference/javascript
|
19712
|
+
*/
|
19713
|
+
class MixpanelService {
|
19714
|
+
constructor(environment) {
|
19715
|
+
this.environment = environment;
|
19716
|
+
}
|
19717
|
+
init() {
|
19718
|
+
if (!this.environment.enableMixpanel) {
|
19719
|
+
return;
|
19720
|
+
}
|
19721
|
+
mixpanel.init(this.environment.mixpanelToken);
|
19722
|
+
}
|
19723
|
+
identify(id) {
|
19724
|
+
if (!this.environment.enableMixpanel) {
|
19725
|
+
return;
|
19726
|
+
}
|
19727
|
+
mixpanel.identify(id);
|
19728
|
+
mixpanel.people.set({ 'last seen': new Date(Date.now()).toLocaleString() });
|
19729
|
+
}
|
19730
|
+
reset() {
|
19731
|
+
if (!this.environment.enableMixpanel) {
|
19732
|
+
return;
|
19733
|
+
}
|
19734
|
+
mixpanel.reset();
|
19735
|
+
}
|
19736
|
+
track(event, properties = {}) {
|
19737
|
+
if (!this.environment.enableMixpanel) {
|
19738
|
+
return;
|
19739
|
+
}
|
19740
|
+
console.log(event, properties);
|
19741
|
+
mixpanel.track(event, properties);
|
19742
|
+
}
|
19743
|
+
trackLink(id, event, properties = {}) {
|
19744
|
+
if (!this.environment.enableMixpanel) {
|
19745
|
+
return;
|
19746
|
+
}
|
19747
|
+
mixpanel.track_links(`#${id}`, event, properties);
|
19748
|
+
}
|
19749
|
+
trackPageView() {
|
19750
|
+
if (!this.environment.enableMixpanel) {
|
19751
|
+
return;
|
19752
|
+
}
|
19753
|
+
mixpanel['track_pageview']();
|
19754
|
+
}
|
19755
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: MixpanelService, deps: [{ token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
19756
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: MixpanelService, providedIn: 'root' }); }
|
19757
|
+
}
|
19758
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: MixpanelService, decorators: [{
|
19759
|
+
type: Injectable,
|
19760
|
+
args: [{
|
19761
|
+
providedIn: 'root'
|
19762
|
+
}]
|
19763
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
19764
|
+
type: Inject,
|
19765
|
+
args: ['environment']
|
19766
|
+
}] }] });
|
19767
|
+
|
19768
|
+
var UserRolesEnum;
|
19769
|
+
(function (UserRolesEnum) {
|
19770
|
+
UserRolesEnum["FIRM_OWNER"] = "ROLE_FIRM_OWNER";
|
19771
|
+
UserRolesEnum["FIRM_MANAGER"] = "ROLE_FIRM_MANAGER";
|
19772
|
+
UserRolesEnum["FIRM_TOP_MANAGER"] = "ROLE_FIRM_TOP_MANAGER";
|
19773
|
+
UserRolesEnum["CLIENT"] = "ROLE_CLIENT";
|
19774
|
+
UserRolesEnum["EMPLOYEE"] = "ROLE_EMPLOYEE";
|
19775
|
+
UserRolesEnum["ACCOUNTANT"] = "ROLE_ACCOUNTANT";
|
19776
|
+
UserRolesEnum["ADVISOR"] = "ROLE_ADVISOR";
|
19777
|
+
UserRolesEnum["USER"] = "ROLE_USER";
|
19778
|
+
UserRolesEnum["SUBSCRIPTION"] = "ROLE_USER_SUBSCRIPTION";
|
19779
|
+
UserRolesEnum["WORK_TANK"] = "ROLE_USER_WORK";
|
19780
|
+
UserRolesEnum["PROPERTY_TANK"] = "ROLE_USER_PROPERTY";
|
19781
|
+
UserRolesEnum["SOLE_TANK"] = "ROLE_USER_SOLE";
|
19782
|
+
UserRolesEnum["HOLDING_TANK"] = "ROLE_USER_HOLDING";
|
19783
|
+
UserRolesEnum["MONEY_TANK"] = "ROLE_USER_MONEY";
|
19784
|
+
UserRolesEnum["SWITCH_USER"] = "IS_IMPERSONATOR";
|
19785
|
+
})(UserRolesEnum || (UserRolesEnum = {}));
|
19786
|
+
|
19787
|
+
const NAME_TOKEN = 'token';
|
19788
|
+
const NAME_REFRESH_TOKEN = 'refreshToken';
|
19789
|
+
class JwtService extends JwtHelperService {
|
19790
|
+
constructor() {
|
19791
|
+
super(...arguments);
|
19792
|
+
this.mpService = inject(MixpanelService);
|
19793
|
+
this.isLoggedInSubject = new BehaviorSubject(!this.isTokenExpired());
|
19794
|
+
}
|
19795
|
+
getToken() {
|
19796
|
+
return localStorage[NAME_TOKEN];
|
19797
|
+
}
|
19798
|
+
getRefreshToken() {
|
19799
|
+
return localStorage[NAME_REFRESH_TOKEN];
|
19800
|
+
}
|
19801
|
+
saveTokens(tokens) {
|
19802
|
+
localStorage[NAME_TOKEN] = tokens.token;
|
19803
|
+
localStorage[NAME_REFRESH_TOKEN] = tokens.refreshToken;
|
19804
|
+
this.mpService.identify(this.decode(tokens.token).id.toString());
|
19805
|
+
this.isLoggedInSubject.next(true);
|
19806
|
+
}
|
19807
|
+
destroyTokens() {
|
19808
|
+
localStorage.removeItem(NAME_TOKEN);
|
19809
|
+
localStorage.removeItem(NAME_REFRESH_TOKEN);
|
19810
|
+
localStorage.removeItem('userId');
|
19811
|
+
localStorage.removeItem('_switch_user');
|
19812
|
+
this.mpService.track('logout');
|
19813
|
+
this.mpService.reset();
|
19814
|
+
this.isLoggedInSubject.next(false);
|
19815
|
+
}
|
19816
|
+
decode(token) {
|
19817
|
+
return super.decodeToken(token);
|
19818
|
+
}
|
19819
|
+
isClient() {
|
19820
|
+
return this.decode().roles.includes(UserRolesEnum.CLIENT);
|
19821
|
+
}
|
19822
|
+
isMe(userId) {
|
19823
|
+
return this.decode().id === userId;
|
19824
|
+
}
|
19825
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: JwtService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
19826
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: JwtService, providedIn: 'root' }); }
|
19827
|
+
}
|
19828
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: JwtService, decorators: [{
|
19829
|
+
type: Injectable,
|
19830
|
+
args: [{
|
19831
|
+
providedIn: 'root'
|
19832
|
+
}]
|
19833
|
+
}] });
|
19834
|
+
|
19835
|
+
class AuthService {
|
19836
|
+
constructor(http, jwtService, mpService, environment) {
|
19837
|
+
this.http = http;
|
19838
|
+
this.jwtService = jwtService;
|
19839
|
+
this.mpService = mpService;
|
19840
|
+
this.environment = environment;
|
19841
|
+
}
|
19842
|
+
setAuth(response) {
|
19843
|
+
this.jwtService.saveTokens(response);
|
19844
|
+
}
|
19845
|
+
login(username, password) {
|
19846
|
+
return this.http.post(`${this.environment.apiV2}/login`, { username, password }).pipe(map((response) => {
|
19847
|
+
if (response.token) {
|
19848
|
+
this.setAuth(response);
|
19849
|
+
}
|
19850
|
+
return response;
|
19851
|
+
}));
|
19852
|
+
}
|
19853
|
+
mfaLogin(otp) {
|
19854
|
+
return this.http.post(`${this.environment.apiV2}/2fa_check`, { otp }).pipe(map((response) => {
|
19855
|
+
this.setAuth(response);
|
19856
|
+
return response;
|
19857
|
+
}));
|
19858
|
+
}
|
19859
|
+
refresh(refreshToken) {
|
19860
|
+
return this.http.post(`${this.environment.apiV2}/token/refresh`, { refreshToken }).pipe(map((response) => {
|
19861
|
+
this.setAuth(response);
|
19862
|
+
return response;
|
19863
|
+
}));
|
19864
|
+
}
|
19865
|
+
logoutFront(url = '/login') {
|
19866
|
+
this.jwtService.destroyTokens();
|
19867
|
+
location.replace(url);
|
19868
|
+
}
|
19869
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: AuthService, deps: [{ token: i1.HttpClient }, { token: JwtService }, { token: MixpanelService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
19870
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: AuthService, providedIn: 'root' }); }
|
19871
|
+
}
|
19872
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: AuthService, decorators: [{
|
19873
|
+
type: Injectable,
|
19874
|
+
args: [{
|
19875
|
+
providedIn: 'root'
|
19876
|
+
}]
|
19877
|
+
}], ctorParameters: () => [{ type: i1.HttpClient }, { type: JwtService }, { type: MixpanelService }, { type: undefined, decorators: [{
|
19878
|
+
type: Inject,
|
19879
|
+
args: ['environment']
|
19880
|
+
}] }] });
|
19881
|
+
|
19882
|
+
var AuthMessagesEnum;
|
19883
|
+
(function (AuthMessagesEnum) {
|
19884
|
+
AuthMessagesEnum["ERROR_401"] = "Email or password is incorrect";
|
19885
|
+
})(AuthMessagesEnum || (AuthMessagesEnum = {}));
|
19886
|
+
|
19887
|
+
const MESSAGE_DEFAULT_500_ERROR = 'Unexpected error! Please try again later. You can send us via chat your questions.';
|
19888
|
+
/**
|
19889
|
+
* JWT Interceptor add jwt token to each request related with TaxTank API
|
19890
|
+
*/
|
19891
|
+
class JwtInterceptor {
|
19892
|
+
constructor(jwtService, authService, environment) {
|
19893
|
+
this.jwtService = jwtService;
|
19894
|
+
this.authService = authService;
|
19895
|
+
this.environment = environment;
|
19896
|
+
this.isRefreshingToken = false;
|
19897
|
+
this.tokenSubject = new BehaviorSubject(null);
|
19898
|
+
}
|
19899
|
+
addToken(req) {
|
19900
|
+
return req.clone({
|
19901
|
+
setHeaders: { Authorization: 'Bearer ' + this.jwtService.getToken() },
|
19902
|
+
withCredentials: true
|
19903
|
+
});
|
19904
|
+
}
|
19905
|
+
intercept(request, next) {
|
19906
|
+
// skip third party requests
|
19907
|
+
if (!request.url.includes(this.environment.apiV2)) {
|
19908
|
+
return next.handle(request);
|
19909
|
+
}
|
19910
|
+
// add token to every api request
|
19911
|
+
return next.handle(this.addToken(request)).pipe(
|
19912
|
+
// handle errors
|
19913
|
+
catchError((err) => {
|
19914
|
+
if (err instanceof HttpErrorResponse) {
|
19915
|
+
switch (err.status) {
|
19916
|
+
// unexpected errors
|
19917
|
+
case 405:
|
19918
|
+
case 500:
|
19919
|
+
this.handle500Error();
|
19920
|
+
break;
|
19921
|
+
// expected errors
|
19922
|
+
case 401:
|
19923
|
+
return this.handle401Error(request, next, err);
|
19924
|
+
case 400:
|
19925
|
+
case 403:
|
19926
|
+
// @TODO in most cases 404 is not an error, handle in components
|
19927
|
+
// case 404:
|
19928
|
+
this.showErrorMessages(err);
|
19929
|
+
break;
|
19930
|
+
}
|
19931
|
+
}
|
19932
|
+
return throwError(err);
|
19933
|
+
}));
|
19934
|
+
}
|
19935
|
+
/**
|
19936
|
+
* @TODO log
|
19937
|
+
* @TODO waiting for backend to handle errors in a better way
|
19938
|
+
*/
|
19939
|
+
handle400Error(err) {
|
19940
|
+
// this.snackBar.open(err.error['hydra:description'], '', {
|
19941
|
+
// panelClass: 'error'
|
19942
|
+
// });
|
19943
|
+
}
|
19944
|
+
/**
|
19945
|
+
* @TODO log
|
19946
|
+
* @TODO waiting for backend to handle errors in a better way
|
19947
|
+
*/
|
19948
|
+
handle403Error(err) {
|
19949
|
+
// this.snackBar.open(err.error['hydra:description'], '', {
|
19950
|
+
// panelClass: 'error'
|
19951
|
+
// });
|
19952
|
+
}
|
19953
|
+
/**
|
19954
|
+
* @TODO log
|
19955
|
+
*/
|
19956
|
+
handle500Error() {
|
19957
|
+
// this.snackBar.open(MESSAGE_DEFAULT_500_ERROR, '', {
|
19958
|
+
// panelClass: 'error'
|
19959
|
+
// });
|
19960
|
+
}
|
19961
|
+
handle401Error(req, next, err) {
|
19962
|
+
// skip 401 errors not from JWT (basiq login case or other)
|
19963
|
+
if (!err.error.message?.includes('JWT Token')) {
|
19964
|
+
return throwError(err);
|
19965
|
+
}
|
19966
|
+
if (req.url.includes('token/refresh') || req.url.includes('login')) {
|
19967
|
+
if (req.url.includes('token/refresh')) {
|
19968
|
+
this.authService.logoutFront();
|
19969
|
+
}
|
19970
|
+
return throwError(err);
|
19971
|
+
}
|
19972
|
+
// refreshing token, wait until it's done and retry the request
|
19973
|
+
if (this.isRefreshingToken) {
|
19974
|
+
return this.tokenSubject.pipe(filter(token => token != null), take(1), switchMap(token => next.handle(this.addToken(req))));
|
19975
|
+
// refresh token
|
19976
|
+
}
|
19977
|
+
// subsequent requests should wait until refresh token is ready
|
19978
|
+
this.isRefreshingToken = true;
|
19979
|
+
this.tokenSubject.next(null);
|
19980
|
+
return this.authService.refresh(this.jwtService.getRefreshToken()).pipe(switchMap((tokens) => {
|
19981
|
+
this.tokenSubject.next(tokens.token);
|
19982
|
+
return next.handle(this.addToken(req));
|
19983
|
+
}), catchError(() => {
|
19984
|
+
this.authService.logoutFront();
|
19985
|
+
return throwError(err);
|
19986
|
+
}), finalize(() => {
|
19987
|
+
this.isRefreshingToken = false;
|
19988
|
+
}));
|
19989
|
+
}
|
19990
|
+
/**
|
19991
|
+
* Handle error messages
|
19992
|
+
* @param errorResponse from which messages should be taken
|
19993
|
+
*
|
19994
|
+
* @TODO move to separated interceptor
|
19995
|
+
*/
|
19996
|
+
showErrorMessages(errorResponse) {
|
19997
|
+
if (!errorResponse.error.violations) {
|
19998
|
+
// this.snackBar.open('Something went wrong', '', {
|
19999
|
+
// panelClass: 'error'
|
20000
|
+
// });
|
20001
|
+
return;
|
20002
|
+
}
|
20003
|
+
errorResponse.error.violations.forEach((violation) => {
|
20004
|
+
// this.snackBar.open(violation['message'], '', {
|
20005
|
+
// panelClass: 'error'
|
20006
|
+
// });
|
20007
|
+
});
|
20008
|
+
}
|
20009
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: JwtInterceptor, deps: [{ token: JwtService }, { token: AuthService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
20010
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: JwtInterceptor }); }
|
20011
|
+
}
|
20012
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: JwtInterceptor, decorators: [{
|
20013
|
+
type: Injectable
|
20014
|
+
}], ctorParameters: () => [{ type: JwtService }, { type: AuthService }, { type: undefined, decorators: [{
|
20015
|
+
type: Inject,
|
20016
|
+
args: ['environment']
|
20017
|
+
}] }] });
|
20018
|
+
|
20019
|
+
let InterceptorsModule$1 = class InterceptorsModule {
|
20020
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: InterceptorsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
20021
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.6", ngImport: i0, type: InterceptorsModule }); }
|
20022
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: InterceptorsModule, providers: [
|
20023
|
+
{
|
20024
|
+
provide: HTTP_INTERCEPTORS,
|
20025
|
+
useClass: JwtInterceptor,
|
20026
|
+
multi: true
|
20027
|
+
}
|
20028
|
+
] }); }
|
20029
|
+
};
|
20030
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: InterceptorsModule$1, decorators: [{
|
20031
|
+
type: NgModule,
|
20032
|
+
args: [{
|
20033
|
+
providers: [
|
20034
|
+
{
|
20035
|
+
provide: HTTP_INTERCEPTORS,
|
20036
|
+
useClass: JwtInterceptor,
|
20037
|
+
multi: true
|
20038
|
+
}
|
20039
|
+
]
|
20040
|
+
}]
|
20041
|
+
}] });
|
20042
|
+
|
20043
|
+
/**
|
20044
|
+
* https://angular.io/guide/creating-libraries
|
20045
|
+
*/
|
20046
|
+
class CommonModule {
|
20047
|
+
static forRoot(environment) {
|
20048
|
+
// @TODO remove when bank model refactored (the only use case)
|
20049
|
+
localStorage.setItem('api_uri', environment['api_uri']);
|
20050
|
+
return {
|
20051
|
+
ngModule: CommonModule,
|
20052
|
+
providers: [
|
20053
|
+
{
|
20054
|
+
provide: 'environment',
|
20055
|
+
useValue: environment
|
20056
|
+
}
|
20057
|
+
]
|
20058
|
+
};
|
20059
|
+
}
|
20060
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: CommonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
20061
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.6", ngImport: i0, type: CommonModule, imports: [CommonModule$1,
|
20062
|
+
InterceptorsModule$1] }); }
|
20063
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: CommonModule, imports: [CommonModule$1,
|
20064
|
+
InterceptorsModule$1] }); }
|
20065
|
+
}
|
20066
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: CommonModule, decorators: [{
|
20067
|
+
type: NgModule,
|
20068
|
+
args: [{
|
20069
|
+
declarations: [],
|
20070
|
+
imports: [
|
20071
|
+
CommonModule$1,
|
20072
|
+
InterceptorsModule$1
|
20073
|
+
]
|
20074
|
+
}]
|
20075
|
+
}] });
|
20076
|
+
|
19708
20077
|
const KEY = '_switch_user';
|
19709
20078
|
/**
|
19710
20079
|
* provides user management to managers (users with ROLE_ACCOUNTANT for now, more in future)
|
19711
20080
|
*/
|
19712
20081
|
class UserSwitcherService {
|
20082
|
+
constructor(environment) {
|
20083
|
+
this.environment = environment;
|
20084
|
+
this.http = inject(HttpClient);
|
20085
|
+
this.jwtService = inject(JwtService);
|
20086
|
+
}
|
19713
20087
|
/**
|
19714
20088
|
* get switched username
|
19715
20089
|
*/
|
@@ -19719,18 +20093,24 @@ class UserSwitcherService {
|
|
19719
20093
|
/**
|
19720
20094
|
* switch to user (username should be used for correct work of backend)
|
19721
20095
|
*/
|
19722
|
-
set(
|
19723
|
-
|
19724
|
-
|
20096
|
+
set(user) {
|
20097
|
+
this.http.post(`${this.environment.apiV2}/impersonator/${user.id}/switch`, {}).subscribe((response) => {
|
20098
|
+
this.jwtService.saveTokens(response);
|
20099
|
+
localStorage[KEY] = user.email;
|
20100
|
+
window.location.replace('/client/dashboard');
|
20101
|
+
});
|
19725
20102
|
}
|
19726
20103
|
/**
|
19727
20104
|
* go back to original user
|
19728
20105
|
*/
|
19729
20106
|
reset() {
|
19730
|
-
|
19731
|
-
|
20107
|
+
this.http.post(`${this.environment.apiV2}/impersonator/reset`, {}).subscribe((response) => {
|
20108
|
+
this.jwtService.saveTokens(response);
|
20109
|
+
localStorage.removeItem(KEY);
|
20110
|
+
window.location.replace('/client/dashboard');
|
20111
|
+
});
|
19732
20112
|
}
|
19733
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: UserSwitcherService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
20113
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: UserSwitcherService, deps: [{ token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
19734
20114
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: UserSwitcherService, providedIn: 'root' }); }
|
19735
20115
|
}
|
19736
20116
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: UserSwitcherService, decorators: [{
|
@@ -19738,7 +20118,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
|
|
19738
20118
|
args: [{
|
19739
20119
|
providedIn: 'root'
|
19740
20120
|
}]
|
19741
|
-
}]
|
20121
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
20122
|
+
type: Inject,
|
20123
|
+
args: ['environment']
|
20124
|
+
}] }] });
|
19742
20125
|
|
19743
20126
|
/**
|
19744
20127
|
* Service to work with assets (documents, receipts, e.t.c.)
|
@@ -20581,7 +20964,7 @@ class UserSwitcherInterceptor {
|
|
20581
20964
|
*/
|
20582
20965
|
switch(req, username) {
|
20583
20966
|
// skip third party api requests
|
20584
|
-
if (!req.url.includes(this.environment.api_uri) || !username) {
|
20967
|
+
if (!req.url.includes(this.environment.api_uri) || !username || req.url.includes('impersonator')) {
|
20585
20968
|
return req;
|
20586
20969
|
}
|
20587
20970
|
return req.clone({ params: req.params.set('_switch_user', username) });
|
@@ -21176,9 +21559,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
|
|
21176
21559
|
*/
|
21177
21560
|
class CoreModule {
|
21178
21561
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: CoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
21179
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.6", ngImport: i0, type: CoreModule, imports: [CommonModule,
|
21562
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.6", ngImport: i0, type: CoreModule, imports: [CommonModule$1,
|
21180
21563
|
InterceptorsModule] }); }
|
21181
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: CoreModule, imports: [CommonModule,
|
21564
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: CoreModule, imports: [CommonModule$1,
|
21182
21565
|
InterceptorsModule] }); }
|
21183
21566
|
}
|
21184
21567
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: CoreModule, decorators: [{
|
@@ -21186,7 +21569,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
|
|
21186
21569
|
args: [{
|
21187
21570
|
declarations: [],
|
21188
21571
|
imports: [
|
21189
|
-
CommonModule,
|
21572
|
+
CommonModule$1,
|
21190
21573
|
InterceptorsModule
|
21191
21574
|
]
|
21192
21575
|
}]
|
@@ -23403,7 +23786,7 @@ class MfaDetailsForm extends AbstractForm {
|
|
23403
23786
|
class RegisterClientForm extends AbstractForm {
|
23404
23787
|
constructor(user = plainToClass(User, {})) {
|
23405
23788
|
super({
|
23406
|
-
firstName: new UntypedFormControl(user.firstName, [Validators.required,
|
23789
|
+
firstName: new UntypedFormControl(user.firstName, [Validators.required, Validators.maxLength(40)]),
|
23407
23790
|
lastName: new UntypedFormControl(user.lastName, [Validators.required, nameValidator(), Validators.maxLength(40)]),
|
23408
23791
|
email: new UntypedFormControl(user.email, [Validators.required, Validators.email]),
|
23409
23792
|
password: new PasswordForm(),
|